[MPlayer-cvslog] r36412 - in trunk: command.c gui/dialog/menu.c libmpcodecs/vd.c libmpcodecs/vd_ffmpeg.c libmpcodecs/vd_libmpeg2.c libmpcodecs/vd_mpegpes.c libmpcodecs/vd_realvid.c libmpcodecs/vd_theora.c libmpcode...

ib subversion at mplayerhq.hu
Wed Aug 7 22:41:34 CEST 2013


Author: ib
Date: Wed Aug  7 22:41:34 2013
New Revision: 36412

Log:
Don't subsequently calculate original_aspect from last movie_aspect.

Instead, differentiate between the original aspect ratio stored in or
determined from the video file and the forced, i.e. current, aspect
ratio (e.g. forced by command line override).

This enables multiple independent instances of vd.c again which has
been broken by introducing a static variable in r36401.

Without the subsequent calculation of original_aspect it now contains
nothing but the pure video file aspect ratio which makes it possible
to use movie_aspect -1 to set the original aspect ratio which explains
the changes in command.c and gui/dialog/menu.c.

The changes in vd_mpegpes due to the impact of original_aspect will
fix a bug there at the same time where the condition in order to call
mpcodecs_config_vo() should only trigger once when the encoded aspect
changes. So far, the forced, i.e. current, aspect has been checked.

The whole is related to enabling special argument -1 to switch_ratio
started in r36391.

Modified:
   trunk/command.c
   trunk/gui/dialog/menu.c
   trunk/libmpcodecs/vd.c
   trunk/libmpcodecs/vd_ffmpeg.c
   trunk/libmpcodecs/vd_libmpeg2.c
   trunk/libmpcodecs/vd_mpegpes.c
   trunk/libmpcodecs/vd_realvid.c
   trunk/libmpcodecs/vd_theora.c
   trunk/libmpcodecs/vd_xvid4.c
   trunk/libmpdemux/asfheader.c
   trunk/libmpdemux/aviheader.c
   trunk/libmpdemux/demux_lavf.c
   trunk/libmpdemux/demux_mkv.c
   trunk/libmpdemux/demux_mov.c
   trunk/libmpdemux/demux_nut.c
   trunk/libmpdemux/demux_real.c
   trunk/libmpdemux/demux_y4m.c
   trunk/libmpdemux/demuxer.c

Modified: trunk/command.c
==============================================================================
--- trunk/command.c	Wed Aug  7 20:21:06 2013	(r36411)
+++ trunk/command.c	Wed Aug  7 22:41:34 2013	(r36412)
@@ -2717,8 +2717,8 @@ int run_command(MPContext *mpctx, mp_cmd
         case MP_CMD_SWITCH_RATIO:
             if (!sh_video)
                 break;
-            if (cmd->nargs == 0 || cmd->args[0].v.f == -1)
-                movie_aspect = sh_video->original_aspect;
+            if (cmd->nargs == 0)
+                movie_aspect = -1.0;
             else
                 movie_aspect = cmd->args[0].v.f;
             mpcodecs_config_vo(sh_video, sh_video->disp_w, sh_video->disp_h, 0);

Modified: trunk/gui/dialog/menu.c
==============================================================================
--- trunk/gui/dialog/menu.c	Wed Aug  7 20:21:06 2013	(r36411)
+++ trunk/gui/dialog/menu.c	Wed Aug  7 22:41:34 2013	(r36412)
@@ -584,7 +584,7 @@ GtkWidget * CreatePopUpMenu( void )
    {
     int a11 = False, a169 = False, a43 = False, a235 = False;
 
-    if (!guiInfo.sh_video || (FFABS(guiInfo.sh_video->aspect - guiInfo.sh_video->original_aspect) <= 0.01f)) a11 = True;
+    if (movie_aspect == -1.0f) a11 = True;
     else
      {
        a169 = (FFABS(movie_aspect - 16.0f / 9.0f) <= 0.01f);

Modified: trunk/libmpcodecs/vd.c
==============================================================================
--- trunk/libmpcodecs/vd.c	Wed Aug  7 20:21:06 2013	(r36411)
+++ trunk/libmpcodecs/vd.c	Wed Aug  7 22:41:34 2013	(r36412)
@@ -158,7 +158,6 @@ int mpcodecs_config_vo(sh_video_t *sh, i
     vf_instance_t *vf = sh->vfilter, *sc = NULL;
     int palette = 0;
     int vocfg_flags = 0;
-    static float last_movie_aspect;
 
     if (w)
         sh->disp_w = w;
@@ -291,25 +290,14 @@ int mpcodecs_config_vo(sh_video_t *sh, i
         vf_add_before_vo(&vf, "flip", NULL);
         sh->vfilter = vf;
     }
-    // time to do aspect ratio corrections (after saving the original aspect ratio)...
-
-    if (sh->original_aspect == -1.0) {
-        sh->original_aspect = sh->stream_aspect != 0.0 ? sh->stream_aspect : sh->aspect;
-        last_movie_aspect = -1.0;
-    }
+    // time to do aspect ratio corrections...
 
-    if (movie_aspect > -1.0) {
-        if (sh->aspect != movie_aspect && movie_aspect == last_movie_aspect)
-            sh->original_aspect = sh->stream_aspect != 0.0 ? sh->stream_aspect : sh->aspect;
+    if (movie_aspect > -1.0)
         sh->aspect = movie_aspect;      // cmdline overrides autodetect
-    }
     else if (sh->stream_aspect != 0.0)
-        sh->original_aspect = sh->aspect = sh->stream_aspect;
+        sh->aspect = sh->stream_aspect;
     else
-        sh->original_aspect = sh->aspect;
-//  if(!sh->aspect) sh->aspect=1.0;
-
-    last_movie_aspect = movie_aspect;
+        sh->aspect = sh->original_aspect;
 
     if (opt_screen_size_x || opt_screen_size_y) {
         screen_size_x = opt_screen_size_x;

Modified: trunk/libmpcodecs/vd_ffmpeg.c
==============================================================================
--- trunk/libmpcodecs/vd_ffmpeg.c	Wed Aug  7 20:21:06 2013	(r36411)
+++ trunk/libmpcodecs/vd_ffmpeg.c	Wed Aug  7 22:41:34 2013	(r36412)
@@ -510,13 +510,13 @@ static void update_configuration(sh_vide
         set_format_params(avctx, pix_fmt);
         mp_msg(MSGT_DECVIDEO, MSGL_V, "[ffmpeg] aspect_ratio: %f\n", aspect);
 
-        // Do not overwrite s->aspect on the first call, so that a container
-        // aspect if available is preferred.
+        // Do not overwrite sh->original_aspect on the first call,
+        // if a container aspect is available (which is preferred then).
         // But set it even if the sample aspect did not change, since a
         // resolution change can cause an aspect change even if the
         // _sample_ aspect is unchanged.
-        if (sh->aspect == 0 || ctx->last_sample_aspect_ratio.den)
-            sh->aspect = aspect;
+        if (sh->original_aspect == 0 || ctx->last_sample_aspect_ratio.den)
+            sh->original_aspect = aspect;
         ctx->last_sample_aspect_ratio = avctx->sample_aspect_ratio;
         ctx->pix_fmt = pix_fmt;
         ctx->best_csp = pixfmt2imgfmt(pix_fmt);

Modified: trunk/libmpcodecs/vd_libmpeg2.c
==============================================================================
--- trunk/libmpcodecs/vd_libmpeg2.c	Wed Aug  7 20:21:06 2013	(r36411)
+++ trunk/libmpcodecs/vd_libmpeg2.c	Wed Aug  7 22:41:34 2013	(r36412)
@@ -196,7 +196,7 @@ static mp_image_t* decode(sh_video_t *sh
 	case STATE_SEQUENCE:
 	    pw = info->sequence->display_width * info->sequence->pixel_width;
 	    ph = info->sequence->display_height * info->sequence->pixel_height;
-	    if(ph) sh->aspect = (float) pw / (float) ph;
+	    if(ph) sh->original_aspect = (float) pw / (float) ph;
 	    // video parameters initialized/changed, (re)init libvo:
 	    if (info->sequence->width >> 1 == info->sequence->chroma_width &&
 		info->sequence->height >> 1 == info->sequence->chroma_height) {

Modified: trunk/libmpcodecs/vd_mpegpes.c
==============================================================================
--- trunk/libmpcodecs/vd_mpegpes.c	Wed Aug  7 20:21:06 2013	(r36411)
+++ trunk/libmpcodecs/vd_mpegpes.c	Wed Aug  7 22:41:34 2013	(r36412)
@@ -64,13 +64,13 @@ static mp_image_t* decode(sh_video_t *sh
     if (len <= 0 && !data) return NULL; // delay flush
 
     if(len>10 && !d[0] && !d[1] && d[2]==1 && d[3]==0xB3) {
-        float old_aspect = sh->aspect;
+        float old_aspect = sh->original_aspect;
         int oldw = sh->disp_w, oldh = sh->disp_h;
         mp_header_process_sequence_header(&picture, &d[4]);
-        sh->aspect = mpeg12_aspect_info(&picture);
+        sh->original_aspect = mpeg12_aspect_info(&picture);
         sh->disp_w = picture.display_picture_width;
         sh->disp_h = picture.display_picture_height;
-        if(sh->aspect != old_aspect || sh->disp_w != oldw || sh->disp_h != oldh) {
+        if(sh->original_aspect != old_aspect || sh->disp_w != oldw || sh->disp_h != oldh) {
             if(!mpcodecs_config_vo(sh, sh->disp_w,sh->disp_h,IMGFMT_MPEGPES))
                 return 0;
         }

Modified: trunk/libmpcodecs/vd_realvid.c
==============================================================================
--- trunk/libmpcodecs/vd_realvid.c	Wed Aug  7 20:21:06 2013	(r36411)
+++ trunk/libmpcodecs/vd_realvid.c	Wed Aug  7 22:41:34 2013	(r36412)
@@ -405,7 +405,7 @@ static mp_image_t* decode(sh_video_t *sh
 		transform_out, sh->context);
 
 	if(!initialized){  // rv30 width/height now known
-	    sh->aspect=(float)sh->disp_w/(float)sh->disp_h;
+	    sh->original_aspect=(float)sh->disp_w/(float)sh->disp_h;
 	    sh->disp_w=transform_out[3];
 	    sh->disp_h=transform_out[4];
 	    if (!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_I420)) return 0;

Modified: trunk/libmpcodecs/vd_theora.c
==============================================================================
--- trunk/libmpcodecs/vd_theora.c	Wed Aug  7 20:21:06 2013	(r36411)
+++ trunk/libmpcodecs/vd_theora.c	Wed Aug  7 22:41:34 2013	(r36412)
@@ -130,8 +130,8 @@ static int init(sh_video_t *sh)
     th_setup_free(context->tsi);
 
     if (sh->aspect == 0.0 && context->ti.aspect_denominator != 0) {
-        sh->aspect = ((double)context->ti.aspect_numerator * context->ti.frame_width) /
-                     ((double)context->ti.aspect_denominator * context->ti.frame_height);
+        sh->original_aspect = ((double)context->ti.aspect_numerator * context->ti.frame_width) /
+                              ((double)context->ti.aspect_denominator * context->ti.frame_height);
     }
 
     mp_msg(MSGT_DECVIDEO, MSGL_V, "INFO: Theora video init ok!\n");

Modified: trunk/libmpcodecs/vd_xvid4.c
==============================================================================
--- trunk/libmpcodecs/vd_xvid4.c	Wed Aug  7 20:21:06 2013	(r36411)
+++ trunk/libmpcodecs/vd_xvid4.c	Wed Aug  7 22:41:34 2013	(r36412)
@@ -278,7 +278,7 @@ static mp_image_t* decode(sh_video_t *sh
 		/* 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);
+			sh->original_aspect = stats2aspect(&stats);
 			if(!mpcodecs_config_vo(sh, stats.data.vol.width, stats.data.vol.height, IMGFMT_YV12))
 				return NULL;
 

Modified: trunk/libmpdemux/asfheader.c
==============================================================================
--- trunk/libmpdemux/asfheader.c	Wed Aug  7 20:21:06 2013	(r36411)
+++ trunk/libmpdemux/asfheader.c	Wed Aug  7 22:41:34 2013	(r36412)
@@ -512,7 +512,7 @@ int read_asf_header(demuxer_t *demuxer,s
         if (!get_ext_stream_properties(hdr, hdr_len, streamh->stream_no, asf, 1))
             goto len_err_out;
         if (get_meta(hdr, hdr_len, streamh->stream_no, &asp_ratio)) {
-          sh_video->aspect = asp_ratio * sh_video->bih->biWidth /
+          sh_video->original_aspect = asp_ratio * sh_video->bih->biWidth /
             sh_video->bih->biHeight;
         }
         sh_video->i_bps = asf->bps;

Modified: trunk/libmpdemux/aviheader.c
==============================================================================
--- trunk/libmpdemux/aviheader.c	Wed Aug  7 20:21:06 2013	(r36411)
+++ trunk/libmpdemux/aviheader.c	Wed Aug  7 22:41:34 2013	(r36412)
@@ -364,7 +364,7 @@ while(1){
 		le2me_VIDEO_FIELD_DESC(&vprp->FieldInfo[i]);
 	}
 	if (sh_video) {
-		sh_video->aspect = GET_AVI_ASPECT(vprp->dwFrameAspectRatio);
+		sh_video->original_aspect = GET_AVI_ASPECT(vprp->dwFrameAspectRatio);
 	}
 	if( mp_msg_test(MSGT_HEADER,MSGL_V) ) print_vprp(vprp,MSGL_V);
 	free(vprp);

Modified: trunk/libmpdemux/demux_lavf.c
==============================================================================
--- trunk/libmpdemux/demux_lavf.c	Wed Aug  7 20:21:06 2013	(r36411)
+++ trunk/libmpdemux/demux_lavf.c	Wed Aug  7 22:41:34 2013	(r36412)
@@ -394,10 +394,10 @@ static void handle_stream(demuxer_t *dem
             sh_video->frametime=1/av_q2d(st->r_frame_rate);
             sh_video->format=bih->biCompression;
             if(st->sample_aspect_ratio.num)
-                sh_video->aspect = codec->width  * st->sample_aspect_ratio.num
+                sh_video->original_aspect = codec->width * st->sample_aspect_ratio.num
                          / (float)(codec->height * st->sample_aspect_ratio.den);
             else
-                sh_video->aspect=codec->width  * codec->sample_aspect_ratio.num
+                sh_video->original_aspect = codec->width * codec->sample_aspect_ratio.num
                        / (float)(codec->height * codec->sample_aspect_ratio.den);
             sh_video->i_bps=codec->bit_rate/8;
             if (title && title->value)

Modified: trunk/libmpdemux/demux_mkv.c
==============================================================================
--- trunk/libmpdemux/demux_mkv.c	Wed Aug  7 20:21:06 2013	(r36411)
+++ trunk/libmpdemux/demux_mkv.c	Wed Aug  7 22:41:34 2013	(r36412)
@@ -1618,12 +1618,12 @@ static int demux_mkv_open_video(demuxer_
         track->v_frate = 25.0;
     sh_v->fps = track->v_frate;
     sh_v->frametime = 1 / track->v_frate;
-    sh_v->aspect = 0;
+    sh_v->original_aspect = 0;
     if (!track->realmedia) {
         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;
+            sh_v->original_aspect = (float) track->v_dwidth / (float) track->v_dheight;
     } else {
         // vd_realvid.c will set aspect to disp_w/disp_h and rederive
         // disp_w and disp_h from the RealVideo stream contents returned

Modified: trunk/libmpdemux/demux_mov.c
==============================================================================
--- trunk/libmpdemux/demux_mov.c	Wed Aug  7 20:21:06 2013	(r36411)
+++ trunk/libmpdemux/demux_mov.c	Wed Aug  7 22:41:34 2013	(r36412)
@@ -1143,8 +1143,8 @@ static int gen_sh_video(sh_video_t* sh, 
 		    sh->disp_h=trak->tkdata[81]|(trak->tkdata[80]<<8);
 		  } else if(sh->disp_w!=(trak->tkdata[77]|(trak->tkdata[76]<<8))){
 		    // codec and display width differ... use display one for aspect
-		    sh->aspect=trak->tkdata[77]|(trak->tkdata[76]<<8);
-		    sh->aspect/=trak->tkdata[81]|(trak->tkdata[80]<<8);
+		    sh->original_aspect=trak->tkdata[77]|(trak->tkdata[76]<<8);
+		    sh->original_aspect/=trak->tkdata[81]|(trak->tkdata[80]<<8);
 		  }
 		}
 

Modified: trunk/libmpdemux/demux_nut.c
==============================================================================
--- trunk/libmpdemux/demux_nut.c	Wed Aug  7 20:21:06 2013	(r36411)
+++ trunk/libmpdemux/demux_nut.c	Wed Aug  7 22:41:34 2013	(r36412)
@@ -166,8 +166,8 @@ static demuxer_t * demux_open_nut(demuxe
 			sh_video->format = 0;
 			for (j = 0; j < s[i].fourcc_len && j < 4; j++)
 				sh_video->format |= s[i].fourcc[j]<<(j*8);
-			if (!s[i].sample_height) sh_video->aspect = 0;
-			else sh_video->aspect =
+			if (!s[i].sample_height) sh_video->original_aspect = 0;
+			else sh_video->original_aspect =
 				s[i].sample_width / (float)s[i].sample_height;
 			sh_video->i_bps = 0; // FIXME
 

Modified: trunk/libmpdemux/demux_real.c
==============================================================================
--- trunk/libmpdemux/demux_real.c	Wed Aug  7 20:21:06 2013	(r36411)
+++ trunk/libmpdemux/demux_real.c	Wed Aug  7 22:41:34 2013	(r36412)
@@ -1537,7 +1537,7 @@ static demuxer_t* demux_open_real(demuxe
 		    sh->disp_w = sh->bih->biWidth = stream_read_word(demuxer->stream);
 		    sh->disp_h = sh->bih->biHeight = stream_read_word(demuxer->stream);
 		    if (sh->disp_w > 0 && sh->disp_h > 0)
-			sh->aspect = (float)sh->disp_w / sh->disp_h;
+			sh->original_aspect = (float)sh->disp_w / sh->disp_h;
 		    sh->bih->biPlanes = 1;
 		    sh->bih->biBitCount = 24;
 		    sh->bih->biCompression = sh->format;

Modified: trunk/libmpdemux/demux_y4m.c
==============================================================================
--- trunk/libmpdemux/demux_y4m.c	Wed Aug  7 20:21:06 2013	(r36411)
+++ trunk/libmpdemux/demux_y4m.c	Wed Aug  7 22:41:34 2013	(r36412)
@@ -232,7 +232,7 @@ static void read_streaminfo(demuxer_t *d
 	sh->disp_h = y4m_si_get_height(priv->si);
 
 	if (ratio.d != 0 && ratio.n != 0)
-	    sh->aspect = (float)(sh->disp_w*ratio.n)/(float)(sh->disp_h*ratio.d);
+	    sh->original_aspect = (float)(sh->disp_w*ratio.n)/(float)(sh->disp_h*ratio.d);
 
     	demuxer->seekable = 0;
     }

Modified: trunk/libmpdemux/demuxer.c
==============================================================================
--- trunk/libmpdemux/demuxer.c	Wed Aug  7 20:21:06 2013	(r36411)
+++ trunk/libmpdemux/demuxer.c	Wed Aug  7 22:41:34 2013	(r36412)
@@ -380,7 +380,6 @@ sh_video_t *new_sh_video_vid(demuxer_t *
         mp_msg(MSGT_DEMUXER, MSGL_WARN, MSGTR_VideoStreamRedefined, id);
     else {
         sh_video_t *sh = calloc(1, sizeof(sh_video_t));
-        sh->original_aspect = -1.0;
         mp_msg(MSGT_DEMUXER, MSGL_V, "==> Found video stream: %d\n", id);
         demuxer->v_streams[id] = sh;
         sh->vid = vid;


More information about the MPlayer-cvslog mailing list