changeset 22277:de3ca43ae51e

reinit the vo when aspect ratio changes; patch by C.E. Hoyos approved by Michael
author nicodvb
date Tue, 20 Feb 2007 20:09:29 +0000
parents 9f95f9dcf832
children ac8ac9e3761d
files libmpcodecs/vd_ffmpeg.c
diffstat 1 files changed, 4 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/vd_ffmpeg.c	Tue Feb 20 17:22:34 2007 +0000
+++ b/libmpcodecs/vd_ffmpeg.c	Tue Feb 20 20:09:29 2007 +0000
@@ -39,7 +39,6 @@
     AVCodecContext *avctx;
     AVFrame *pic;
     enum PixelFormat pix_fmt;
-    float last_aspect;
     int do_slices;
     int do_dr1;
     int vo_inited;
@@ -51,6 +50,7 @@
     double inv_qp_sum;
     int ip_count;
     int b_count;
+    AVRational last_sample_aspect_ratio;
 } vd_ffmpeg_ctx;
 
 //#ifdef USE_LIBPOSTPROC
@@ -411,7 +411,6 @@
         return 0;
     }
     mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: libavcodec init OK!\n");
-    ctx->last_aspect=-3;
     return 1; //mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YV12);
 }
 
@@ -498,17 +497,15 @@
     
      // it is possible another vo buffers to be used after vo config()
      // lavc reset its buffers on width/heigh change but not on aspect change!!!
-    if (// aspect != ctx->last_aspect ||
+    if (av_cmp_q(avctx->sample_aspect_ratio, ctx->last_sample_aspect_ratio) ||
 	width != sh->disp_w  ||
 	height != sh->disp_h ||
 	pix_fmt != ctx->pix_fmt ||
 	!ctx->vo_inited)
     {
 	mp_msg(MSGT_DECVIDEO, MSGL_V, "[ffmpeg] aspect_ratio: %f\n", aspect);
-        ctx->last_aspect = aspect;
-//	if(ctx->last_aspect>=0.01 && ctx->last_aspect<100)
-	if(sh->aspect==0.0)
-	    sh->aspect = ctx->last_aspect;
+	ctx->last_sample_aspect_ratio = avctx->sample_aspect_ratio;
+	sh->aspect = aspect;
 	sh->disp_w = width;
 	sh->disp_h = height;
 	ctx->pix_fmt = pix_fmt;