Revision 1005f542 libavcodec/xvidff.c

View differences:

libavcodec/xvidff.c
27 27
#include <unistd.h>
28 28
#include "common.h"
29 29
#include "avcodec.h"
30
#ifdef CONFIG_WIN32
31
#include <fcntl.h>
32
#endif
30
#include "internal.h"
33 31

  
34 32
/**
35 33
 * Buffer management macros.
......
229 227
        rc2pass2.version = XVID_VERSION;
230 228
        rc2pass2.bitrate = avctx->bit_rate;
231 229

  
232
#ifdef CONFIG_WIN32 /* Ugly work around */
233
        {
234
           char *tempname;
235

  
236
           tempname = tempnam(".", "xvidff");
237
            fd = -1;
238
            if( tempname &&
239
                (fd = open(tempname, _O_RDWR | _O_BINARY)) != -1 ) {
240
                x->twopassfile = av_strdup(tempname);
241
#undef free
242
                free(tempname);
243
#define free please_use_av_free
244
                if( x->twopassfile == NULL ) {
245
                    av_log(avctx, AV_LOG_ERROR,
246
                        "XviD: Cannot allocate 2-pass buffer\n");
247
                    return -1;
248
                }
249
            }
250
       }
251
#else
252
        x->twopassfile = av_malloc(BUFFER_SIZE);
253
        if( x->twopassfile == NULL ) {
254
            av_log(avctx, AV_LOG_ERROR,
255
                "XviD: Cannot allocate 2-pass buffer\n");
256
            return -1;
257
        }
258
        strcpy(x->twopassfile, "/tmp/xvidff.XXXXXX");
259
        fd = mkstemp(x->twopassfile);
260
        if(fd < 0){
261
            strcpy(x->twopassfile, "./xvidff.XXXXXX");
262
            fd = mkstemp(x->twopassfile);
263
        }
264
#endif
230
        fd = av_tempfile("xvidff.", &(x->twopassfile));
265 231
        if( fd == -1 ) {
266 232
            av_log(avctx, AV_LOG_ERROR,
267 233
                "XviD: Cannot write 2-pass pipe\n");

Also available in: Unified diff