]> git.sesse.net Git - vlc/blobdiff - modules/codec/ffmpeg/video.c
* vorbis comments can be mixed case. strstr -> strcasestr
[vlc] / modules / codec / ffmpeg / video.c
index 0f7b2c2bc85219841c49e55d123012d9e455d2b3..70b28b60228fc4164b49832ef465ed2c4c00f320 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * video.c: video decoder using the ffmpeg library
  *****************************************************************************
- * Copyright (C) 1999-2001 VideoLAN
+ * Copyright (C) 1999-2001 the VideoLAN team
  * $Id$
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
@@ -579,12 +579,35 @@ picture_t *E_(DecodeVideo)( decoder_t *p_dec, block_t **pp_block )
         /* Set the PTS */
         if( p_sys->p_ff_pic->pts ) p_sys->i_pts = p_sys->p_ff_pic->pts;
 
-        /* Sanity check (seems to be needed for some streams ) */
+        /* Sanity check (seems to be needed for some streams) */
         if( p_sys->p_ff_pic->pict_type == FF_B_TYPE )
         {
             p_sys->b_has_b_frames = VLC_TRUE;
         }
 
+        if( !p_dec->fmt_in.video.i_aspect )
+        {
+            /* Fetch again the aspect ratio in case it changed */
+#if LIBAVCODEC_BUILD >= 4687
+            p_dec->fmt_out.video.i_aspect =
+                VOUT_ASPECT_FACTOR
+                    * ( av_q2d(p_sys->p_context->sample_aspect_ratio)
+                    * p_sys->p_context->width / p_sys->p_context->height );
+            p_dec->fmt_out.video.i_sar_num
+                = p_sys->p_context->sample_aspect_ratio.num;
+            p_dec->fmt_out.video.i_sar_den
+                = p_sys->p_context->sample_aspect_ratio.den;
+#else
+            p_dec->fmt_out.video.i_aspect =
+                VOUT_ASPECT_FACTOR * p_sys->p_context->aspect_ratio;
+#endif
+            if( p_dec->fmt_out.video.i_aspect == 0 )
+            {
+                p_dec->fmt_out.video.i_aspect = VOUT_ASPECT_FACTOR
+                    * p_sys->p_context->width / p_sys->p_context->height;
+            }
+        }
+
         /* Send decoded frame to vout */
         if( p_sys->i_pts )
         {