aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/libxvidff.c
diff options
context:
space:
mode:
authorMåns Rullgård <mans@mansr.com>2010-07-09 10:53:30 +0000
committerMåns Rullgård <mans@mansr.com>2010-07-09 10:53:30 +0000
commita30b33606193388d01b33db72d4e0351c5ec279f (patch)
treeeb83e890eb67a8b2084ee45bf1265058d3429777 /libavcodec/libxvidff.c
parent7e264ca136afec5ab8ef4e554e34c10610f4b9b8 (diff)
downloadffmpeg-a30b33606193388d01b33db72d4e0351c5ec279f.tar.gz
Allow using libxvid RC without enabling encoding wrapper
Originally committed as revision 24137 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/libxvidff.c')
-rw-r--r--libavcodec/libxvidff.c76
1 files changed, 40 insertions, 36 deletions
diff --git a/libavcodec/libxvidff.c b/libavcodec/libxvidff.c
index e37b900c1d..834e02d25c 100644
--- a/libavcodec/libxvidff.c
+++ b/libavcodec/libxvidff.c
@@ -80,6 +80,44 @@ int xvid_strip_vol_header(AVCodecContext *avctx, unsigned char *frame, unsigned
int xvid_ff_2pass(void *ref, int opt, void *p1, void *p2);
void xvid_correct_framerate(AVCodecContext *avctx);
+/* Wrapper to work around the lack of mkstemp() on mingw/cygin.
+ * Also, tries to create file in /tmp first, if possible.
+ * *prefix can be a character constant; *filename will be allocated internally.
+ * @return file descriptor of opened file (or -1 on error)
+ * and opened file name in **filename. */
+int ff_tempfile(char *prefix, char **filename) {
+ int fd=-1;
+#if !HAVE_MKSTEMP
+ *filename = tempnam(".", prefix);
+#else
+ size_t len = strlen(prefix) + 12; /* room for "/tmp/" and "XXXXXX\0" */
+ *filename = av_malloc(len);
+#endif
+ /* -----common section-----*/
+ if (*filename == NULL) {
+ av_log(NULL, AV_LOG_ERROR, "ff_tempfile: Cannot allocate file name\n");
+ return -1;
+ }
+#if !HAVE_MKSTEMP
+ fd = open(*filename, O_RDWR | O_BINARY | O_CREAT, 0444);
+#else
+ snprintf(*filename, len, "/tmp/%sXXXXXX", prefix);
+ fd = mkstemp(*filename);
+ if (fd < 0) {
+ snprintf(*filename, len, "./%sXXXXXX", prefix);
+ fd = mkstemp(*filename);
+ }
+#endif
+ /* -----common section-----*/
+ if (fd < 0) {
+ av_log(NULL, AV_LOG_ERROR, "ff_tempfile: Cannot open temporary file %s\n", *filename);
+ return -1;
+ }
+ return fd; /* success */
+}
+
+#if CONFIG_LIBXVID_ENCODER
+
/**
* Create the private context for the encoder.
* All buffers are allocated, settings are loaded from the user,
@@ -770,42 +808,6 @@ int xvid_ff_2pass(void *ref, int cmd, void *p1, void *p2) {
}
}
-/* Wrapper to work around the lack of mkstemp() on mingw/cygin.
- * Also, tries to create file in /tmp first, if possible.
- * *prefix can be a character constant; *filename will be allocated internally.
- * @return file descriptor of opened file (or -1 on error)
- * and opened file name in **filename. */
-int ff_tempfile(char *prefix, char **filename) {
- int fd=-1;
-#if !HAVE_MKSTEMP
- *filename = tempnam(".", prefix);
-#else
- size_t len = strlen(prefix) + 12; /* room for "/tmp/" and "XXXXXX\0" */
- *filename = av_malloc(len);
-#endif
- /* -----common section-----*/
- if (*filename == NULL) {
- av_log(NULL, AV_LOG_ERROR, "ff_tempfile: Cannot allocate file name\n");
- return -1;
- }
-#if !HAVE_MKSTEMP
- fd = open(*filename, O_RDWR | O_BINARY | O_CREAT, 0444);
-#else
- snprintf(*filename, len, "/tmp/%sXXXXXX", prefix);
- fd = mkstemp(*filename);
- if (fd < 0) {
- snprintf(*filename, len, "./%sXXXXXX", prefix);
- fd = mkstemp(*filename);
- }
-#endif
- /* -----common section-----*/
- if (fd < 0) {
- av_log(NULL, AV_LOG_ERROR, "ff_tempfile: Cannot open temporary file %s\n", *filename);
- return -1;
- }
- return fd; /* success */
-}
-
/**
* Xvid codec definition for libavcodec.
*/
@@ -820,3 +822,5 @@ AVCodec libxvid_encoder = {
.pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
.long_name= NULL_IF_CONFIG_SMALL("libxvidcore MPEG-4 part 2"),
};
+
+#endif /* CONFIG_LIBXVID_ENCODER */