diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2005-08-06 09:46:04 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2005-08-06 09:46:04 +0000 |
commit | 77b854883ea012d9262f5e159cc71af5d7e34a44 (patch) | |
tree | 172068e0ee20e2c99f39f3269fbc5fd71e8d883e /libavcodec/xvidff.c | |
parent | 6987c58a0a0e23c78a3ea91faed1e94f698942a0 (diff) | |
download | ffmpeg-77b854883ea012d9262f5e159cc71af5d7e34a44.tar.gz |
mkstemp on win32 workaround by (Ivan Wong: email, ivanwong info)
Originally committed as revision 4495 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/xvidff.c')
-rw-r--r-- | libavcodec/xvidff.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/libavcodec/xvidff.c b/libavcodec/xvidff.c index 9156b2e47f..b287c4e847 100644 --- a/libavcodec/xvidff.c +++ b/libavcodec/xvidff.c @@ -27,6 +27,9 @@ #include <unistd.h> #include "common.h" #include "avcodec.h" +#ifdef CONFIG_WIN32 +#include <fcntl.h> +#endif /** * Buffer management macros. @@ -226,6 +229,26 @@ int ff_xvid_encode_init(AVCodecContext *avctx) { 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, @@ -238,6 +261,7 @@ int ff_xvid_encode_init(AVCodecContext *avctx) { strcpy(x->twopassfile, "./xvidff.XXXXXX"); fd = mkstemp(x->twopassfile); } +#endif if( fd == -1 ) { av_log(avctx, AV_LOG_ERROR, "XviD: Cannot write 2-pass pipe\n"); |