[MPlayer-users] Re: [BUG] movie-aspect autodetection failes for mkv in r22325

lists at eastcheap.org lists at eastcheap.org
Tue Mar 6 22:46:25 CET 2007


On Tue, 6 Mar 2007, lists at eastcheap.org wrote:

>> Additionally, it was reported that my patch fixes the problem on mkv. Not 
>> for you?
> 
> Mkv is next.  Right now I'm working on getting mkvtoolnix up and running so I 
> can build test files.

And the deed is done.  Appears to work for AVI and Matroska, doesn't interfere 
with the -aspect option, and shouldn't hurt on-the-fly aspect changes (where 
aspect is otherwise unspecified, of course).  Only works for certain with the 
ffmpeg and xvid codecs.

Unfortunately, it's not a simple patch.  I had to add a new variable, 
aspect_override, to the sh_video_t struct.  Only nonzero values are used, and 
the variable is initialized to 0.0 by new_sh_video_vid(), so there *shouldn't* 
be any conflicts.

A "make clean" is almost certainly required after applying the patch.

This really needs to be wrung out before I can even contemplate submitting it 
for general inclusion.
-------------- next part --------------
Index: libmpcodecs/vd_xvid4.c
===================================================================
--- libmpcodecs/vd_xvid4.c	(revision 22472)
+++ libmpcodecs/vd_xvid4.c	(working copy)
@@ -278,7 +278,11 @@
 		/* Found a VOL information stats, if VO plugin is not initialized
 		 * yet then do it now */
 		if (stats.type == XVID_TYPE_VOL && !p->vo_initialized) {
-			sh->aspect = stats2aspect(&stats);
+		        if (sh->aspect_override > 0.0) {
+			    	sh->aspect = sh->aspect_override;
+			} else {
+				sh->aspect = stats2aspect(&stats);
+			}
 			if(!mpcodecs_config_vo(sh, stats.data.vol.width, stats.data.vol.height, IMGFMT_YV12))
 				return(NULL);
 			
Index: libmpcodecs/vd_ffmpeg.c
===================================================================
--- libmpcodecs/vd_ffmpeg.c	(revision 22472)
+++ libmpcodecs/vd_ffmpeg.c	(working copy)
@@ -505,7 +505,11 @@
     {
 	mp_msg(MSGT_DECVIDEO, MSGL_V, "[ffmpeg] aspect_ratio: %f\n", aspect);
 	ctx->last_sample_aspect_ratio = avctx->sample_aspect_ratio;
-	sh->aspect = aspect;
+	if (sh->aspect_override > 0.0) {
+	    sh->aspect = sh->aspect_override;
+	} else {
+	    sh->aspect = aspect;
+	}
 	sh->disp_w = width;
 	sh->disp_h = height;
 	ctx->pix_fmt = pix_fmt;
Index: libmpdemux/demux_mkv.c
===================================================================
--- libmpdemux/demux_mkv.c	(revision 22472)
+++ libmpdemux/demux_mkv.c	(working copy)
@@ -1955,8 +1955,10 @@
     {
       sh_v->disp_w = track->v_width;
       sh_v->disp_h = track->v_height;
-      if (track->v_dheight)
-      sh_v->aspect = (float)track->v_dwidth / (float)track->v_dheight;
+      if (track->v_dheight) {
+        sh_v->aspect = sh_v->aspect_override =
+	  (float)track->v_dwidth / (float)track->v_dheight;
+      }
     }
   else
     {
Index: libmpdemux/aviheader.c
===================================================================
--- libmpdemux/aviheader.c	(revision 22472)
+++ libmpdemux/aviheader.c	(working copy)
@@ -345,7 +345,8 @@
 		le2me_VIDEO_FIELD_DESC(&vprp->FieldInfo[i]);
 	}
 	if (sh_video) {
-		sh_video->aspect = GET_AVI_ASPECT(vprp->dwFrameAspectRatio);
+		sh_video->aspect = sh_video->aspect_override =
+		    GET_AVI_ASPECT(vprp->dwFrameAspectRatio);
 	}
 	if( mp_msg_test(MSGT_HEADER,MSGL_V) ) print_vprp(vprp,MSGL_V);
 	free(vprp);
Index: libmpdemux/stheader.h
===================================================================
--- libmpdemux/stheader.h	(revision 22472)
+++ libmpdemux/stheader.h	(working copy)
@@ -74,6 +74,7 @@
   float fps;              // frames per second (set only if constant fps)
   float frametime;        // 1/fps
   float aspect;           // aspect ratio stored in the file (for prescaling)
+  float aspect_override;  // aspect ratio override
   int i_bps;              // == bitrate  (compressed bytes/sec)
   int disp_w,disp_h;      // display size (filled by fileformat parser)
   // output driver/filters: (set by libmpcodecs core)
Index: libmpdemux/demuxer.c
===================================================================
--- libmpdemux/demuxer.c	(revision 22472)
+++ libmpdemux/demuxer.c	(working copy)
@@ -270,6 +270,7 @@
           mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_ID=%d\n", vid);
     }
     ((sh_video_t *)demuxer->v_streams[id])->vid = vid;
+    ((sh_video_t *)demuxer->v_streams[id])->aspect_override = 0.0;
     return demuxer->v_streams[id];
 }
 


More information about the MPlayer-users mailing list