[MPlayer-dev-eng] [PATCH] leak in vo_yuv4mpeg with -fixed-vo

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Sat Dec 11 12:53:42 CET 2004


Hi,
the attached patch fixes a leak with -fixed-vo in vo_yuv4mpeg.c when
using -fixed-vo (the file wasn't closed before being reopened).
Even more important, it allows to properly concatenate videos that have
the same properties (width, height, fps), as it neither reopens nor
rewrites the file header in this case (when -fixed-vo is given).
I will apply tomorrow if nobody objects.

Greetings,
Reimar Döffinger
-------------- next part --------------
--- libvo/vo_yuv4mpeg.c	2004-12-03 22:04:29.000000000 +0100
+++ libvo/vo_yuv4mpeg.c	2004-12-05 14:40:05.418121159 +0100
@@ -51,8 +50,9 @@
 
 LIBVO_EXTERN (yuv4mpeg)
 
-static int image_width;
-static int image_height;
+static int image_width = 0;
+static int image_height = 0;
+static float image_fps = 0;
 
 static uint8_t *image = NULL;
 static uint8_t *image_y = NULL;
@@ -80,8 +80,19 @@
        uint32_t d_height, uint32_t fullscreen, char *title, 
        uint32_t format)
 {
+	if (image_width == width && image_height == height &&
+	     image_fps == vo_fps && vo_config_count)
+	  return 0;
+	if (vo_config_count) {
+	  mp_msg(MSGT_VO, MSGL_WARN,
+	    "Video formats differ (w:%i=>%i, h:%i=>%i, fps:%f=>%f), "
+	    "restarting output.\n",
+	    image_width, width, image_height, height, image_fps, vo_fps);
+	  uninit();
+	}
 	image_height = height;
 	image_width = width;
+	image_fps = vo_fps;
 	using_format = format;
 
 	if (Y4M_IS_INTERLACED)
@@ -146,7 +157,7 @@
 
 	/* At least the interlacing is ok now */
 	fprintf(yuv_out, "YUV4MPEG2 W%d H%d F%ld:%ld I%c A0:0\n", 
-			image_width, image_height, (long)(vo_fps * 1000000.0), 
+			image_width, image_height, (long)(image_fps * 1000000.0), 
 			(long)1000000, config_interlace);
 
 	fflush(yuv_out);
@@ -448,6 +459,7 @@
 	return 0;
 }
 
+// WARNING: config(...) also uses this
 static void uninit(void)
 {
     if(image)
@@ -469,6 +481,9 @@
 	if (yuv_filename)
 		free(yuv_filename);
 	yuv_filename = NULL;
+	image_width = 0;
+	image_height = 0;
+	image_fps = 0;
 }
 
 


More information about the MPlayer-dev-eng mailing list