diff xvidff.c @ 3233:18af2f7788c6 libavcodec

- Add new file internal.h for common internal-use-only functions. - Add new function av_tempfile() for creating temporary files; contains workaround for MinGW. - Make XviD stuff use av_tempfile().
author corey
date Thu, 30 Mar 2006 04:33:05 +0000
parents 89348aaf566e
children 35757cceddd0
line wrap: on
line diff
--- a/xvidff.c	Wed Mar 29 21:11:57 2006 +0000
+++ b/xvidff.c	Thu Mar 30 04:33:05 2006 +0000
@@ -27,9 +27,7 @@
 #include <unistd.h>
 #include "common.h"
 #include "avcodec.h"
-#ifdef CONFIG_WIN32
-#include <fcntl.h>
-#endif
+#include "internal.h"
 
 /**
  * Buffer management macros.
@@ -229,39 +227,7 @@
         rc2pass2.version = XVID_VERSION;
         rc2pass2.bitrate = avctx->bit_rate;
 
-#ifdef CONFIG_WIN32 /* Ugly work around */
-        {
-           char *tempname;
-
-           tempname = tempnam(".", "xvidff");
-            fd = -1;
-            if( tempname &&
-                (fd = open(tempname, _O_RDWR | _O_BINARY)) != -1 ) {
-                x->twopassfile = av_strdup(tempname);
-#undef free
-                free(tempname);
-#define free please_use_av_free
-                if( x->twopassfile == NULL ) {
-                    av_log(avctx, AV_LOG_ERROR,
-                        "XviD: Cannot allocate 2-pass buffer\n");
-                    return -1;
-                }
-            }
-       }
-#else
-        x->twopassfile = av_malloc(BUFFER_SIZE);
-        if( x->twopassfile == NULL ) {
-            av_log(avctx, AV_LOG_ERROR,
-                "XviD: Cannot allocate 2-pass buffer\n");
-            return -1;
-        }
-        strcpy(x->twopassfile, "/tmp/xvidff.XXXXXX");
-        fd = mkstemp(x->twopassfile);
-        if(fd < 0){
-            strcpy(x->twopassfile, "./xvidff.XXXXXX");
-            fd = mkstemp(x->twopassfile);
-        }
-#endif
+        fd = av_tempfile("xvidff.", &(x->twopassfile));
         if( fd == -1 ) {
             av_log(avctx, AV_LOG_ERROR,
                 "XviD: Cannot write 2-pass pipe\n");