Revision 77b85488

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 33

  
31 34
/**
32 35
 * Buffer management macros.
......
226 229
        rc2pass2.version = XVID_VERSION;
227 230
        rc2pass2.bitrate = avctx->bit_rate;
228 231
        
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
229 252
        x->twopassfile = av_malloc(BUFFER_SIZE);
230 253
        if( x->twopassfile == NULL ) {
231 254
            av_log(avctx, AV_LOG_ERROR,
......
238 261
            strcpy(x->twopassfile, "./xvidff.XXXXXX");
239 262
            fd = mkstemp(x->twopassfile);
240 263
        }
264
#endif
241 265
        if( fd == -1 ) {
242 266
            av_log(avctx, AV_LOG_ERROR,
243 267
                "XviD: Cannot write 2-pass pipe\n");

Also available in: Unified diff