Mercurial > libavcodec.hg
changeset 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 | 69d4f0d2a23f |
children | fdedaa2e6da4 |
files | xvidff.c |
diffstat | 1 files changed, 24 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/xvidff.c Fri Aug 05 23:25:35 2005 +0000 +++ b/xvidff.c Sat Aug 06 09:46:04 2005 +0000 @@ -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 @@ 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 @@ 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");