[MPlayer-dev-eng] [PATCH] aspect support in YUV4MPEG2

Rik Snel rsnel at cube.dyndns.org
Thu Dec 27 14:53:13 CET 2001


Hello,

This patch provides aspect ratio support for the YUV4MPEG2 parser.
And it fixes a bug in demux_close_y4m(), priv was not initialized.

Please apply.

Greetings,

Rik.

--------
Nothing is ever a total loss; it can always serve as a bad example.
-------------- next part --------------
diff -Naur main/libmpdemux/demux_y4m.c main.dev/libmpdemux/demux_y4m.c
--- main/libmpdemux/demux_y4m.c	Thu Dec 27 13:07:40 2001
+++ main.dev/libmpdemux/demux_y4m.c	Thu Dec 27 14:40:59 2001
@@ -116,7 +116,7 @@
 
 void demux_open_y4m(demuxer_t* demuxer){
     y4m_priv_t* priv = demuxer->priv;
-    y4m_ratio_t framerate;
+    y4m_ratio_t ratio; /* used for framerate and aspect ratio */
     sh_video_t* sh=new_sh_video(demuxer,0);
     int err;
 
@@ -186,14 +186,18 @@
 	    mp_msg(MSGT_DEMUXER, MSGL_FATAL, "error parsing YUV4MPEG header: %s\n", y4m_strerr(err));
 	
 	if(!sh->fps) {
-    	    framerate = y4m_si_get_framerate(priv->si);
-    	    if (framerate.d != 0)
-        	sh->fps=(float)framerate.n/(float)framerate.d;
+    	    ratio = y4m_si_get_framerate(priv->si);
+    	    if (ratio.d != 0)
+        	sh->fps=(float)ratio.n/(float)ratio.d;
     	    else
         	sh->fps=15.0f;
 	}
 	sh->frametime=1.0f/sh->fps;
 
+	ratio = y4m_si_get_sampleaspect(priv->si);
+	if (ratio.d != 0 && ratio.n != 0) {
+	    sh->aspect = (float)ratio.n/(float)ratio.d;
+	}
 	sh->disp_w = y4m_si_get_width(priv->si);
 	sh->disp_h = y4m_si_get_height(priv->si);
     }
@@ -224,7 +228,7 @@
 
 void demux_close_y4m(demuxer_t *demuxer)
 {
-    y4m_priv_t* priv;
+    y4m_priv_t* priv = demuxer->priv;
     
     if (!priv->is_older)
 	y4m_fini_stream_info(((y4m_priv_t*)demuxer->priv)->si);


More information about the MPlayer-dev-eng mailing list