|
@@ -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 */
|