]> git.sesse.net Git - vlc/commitdiff
Fixed segfault when doing rendering without respecting ffmpeg requirements.
authorLaurent Aimar <fenrir@videolan.org>
Fri, 29 Aug 2008 10:10:43 +0000 (12:10 +0200)
committerLaurent Aimar <fenrir@videolan.org>
Fri, 29 Aug 2008 10:12:57 +0000 (12:12 +0200)
It fixes at least SVQ1 segfaults.

modules/codec/avcodec/video.c

index fe544eecce3ecca18dae742f022ae3dbfde09fb6..1ec058fd71bbb83302123ea3ac1d6dce645ebae2 100644 (file)
@@ -852,9 +852,16 @@ static int ffmpeg_GetFrameBuf( struct AVCodecContext *p_context,
     }
 
     /* Some codecs set pix_fmt only after the 1st frame has been decoded,
-     * so this check is necessary. */
+     * so we need to check for direct rendering again. */
+
+    int i_width = p_sys->p_context->width;
+    int i_height = p_sys->p_context->height;
+    avcodec_align_dimensions( p_sys->p_context, &i_width, &i_height );
+
     if( GetVlcChroma( &p_dec->fmt_out.video, p_context->pix_fmt ) != VLC_SUCCESS ||
-        p_sys->p_context->width % 16 || p_sys->p_context->height % 16 )
+        p_sys->p_context->width % 16 || p_sys->p_context->height % 16 ||
+        /* We only pad picture up to 16 */
+        PAD(p_sys->p_context->width,16) < i_width || PAD(p_sys->p_context->height,16) < i_height )
     {
         msg_Dbg( p_dec, "disabling direct rendering" );
         p_sys->b_direct_rendering = 0;