comparison xvidff.c @ 2821:0f428b024677 libavcodec

mkstemp on win32 workaround by (Ivan Wong: email, ivanwong info)
author michael
date Sat, 06 Aug 2005 09:46:04 +0000
parents ef44d24680d1
children ef2149182f1c
comparison
equal deleted inserted replaced
2820:69d4f0d2a23f 2821:0f428b024677
25 25
26 #include <xvid.h> 26 #include <xvid.h>
27 #include <unistd.h> 27 #include <unistd.h>
28 #include "common.h" 28 #include "common.h"
29 #include "avcodec.h" 29 #include "avcodec.h"
30 #ifdef CONFIG_WIN32
31 #include <fcntl.h>
32 #endif
30 33
31 /** 34 /**
32 * Buffer management macros. 35 * Buffer management macros.
33 */ 36 */
34 #define BUFFER_SIZE 1024 37 #define BUFFER_SIZE 1024
224 } else if( xvid_flags & CODEC_FLAG_PASS2 ) { 227 } else if( xvid_flags & CODEC_FLAG_PASS2 ) {
225 memset(&rc2pass2, 0, sizeof(xvid_plugin_2pass2_t)); 228 memset(&rc2pass2, 0, sizeof(xvid_plugin_2pass2_t));
226 rc2pass2.version = XVID_VERSION; 229 rc2pass2.version = XVID_VERSION;
227 rc2pass2.bitrate = avctx->bit_rate; 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 x->twopassfile = av_malloc(BUFFER_SIZE); 252 x->twopassfile = av_malloc(BUFFER_SIZE);
230 if( x->twopassfile == NULL ) { 253 if( x->twopassfile == NULL ) {
231 av_log(avctx, AV_LOG_ERROR, 254 av_log(avctx, AV_LOG_ERROR,
232 "XviD: Cannot allocate 2-pass buffer\n"); 255 "XviD: Cannot allocate 2-pass buffer\n");
233 return -1; 256 return -1;
236 fd = mkstemp(x->twopassfile); 259 fd = mkstemp(x->twopassfile);
237 if(fd < 0){ 260 if(fd < 0){
238 strcpy(x->twopassfile, "./xvidff.XXXXXX"); 261 strcpy(x->twopassfile, "./xvidff.XXXXXX");
239 fd = mkstemp(x->twopassfile); 262 fd = mkstemp(x->twopassfile);
240 } 263 }
264 #endif
241 if( fd == -1 ) { 265 if( fd == -1 ) {
242 av_log(avctx, AV_LOG_ERROR, 266 av_log(avctx, AV_LOG_ERROR,
243 "XviD: Cannot write 2-pass pipe\n"); 267 "XviD: Cannot write 2-pass pipe\n");
244 return -1; 268 return -1;
245 } 269 }