]> git.sesse.net Git - vlc/commitdiff
* modules/codec/ffmpeg/video.c: fixed the last direct rendering bug.
authorGildas Bazin <gbazin@videolan.org>
Mon, 16 Jun 2003 20:49:12 +0000 (20:49 +0000)
committerGildas Bazin <gbazin@videolan.org>
Mon, 16 Jun 2003 20:49:12 +0000 (20:49 +0000)
modules/codec/ffmpeg/video.c

index af1d9699a005b7cb7ff153d563d70e8833f0edfb..0cc770210fbefc38533193f64f1125c12a4e0198 100644 (file)
@@ -2,7 +2,7 @@
  * video.c: video decoder using ffmpeg library
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: video.c,v 1.30 2003/06/16 20:23:41 gbazin Exp $
+ * $Id: video.c,v 1.31 2003/06/16 20:49:12 gbazin Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *          Gildas Bazin <gbazin@netcourrier.com>
@@ -267,6 +267,8 @@ int E_( InitThread_Video )( vdec_thread_t *p_vdec )
         p_vdec->p_context->pix_fmt != PIX_FMT_YUV422P &&
         !(p_vdec->p_context->width % 16) && !(p_vdec->p_context->height % 16) )
     {
+        /* Some codecs set pix_fmt only after the 1st frame has been decoded,
+         * so we need to do another check in ffmpeg_GetFrameBuf() */
         p_vdec->b_direct_rendering = 1;
     }
 
@@ -314,8 +316,6 @@ int E_( InitThread_Video )( vdec_thread_t *p_vdec )
 
     if( p_vdec->b_direct_rendering )
     {
-        /* FIXME: some codecs set pix_fmt only after a frame
-         * has been decoded. */
         msg_Dbg( p_vdec->p_fifo, "using direct rendering" );
         p_vdec->p_context->flags|= CODEC_FLAG_EMU_EDGE;
         p_vdec->p_context->get_buffer     = ffmpeg_GetFrameBuf;
@@ -754,6 +754,17 @@ static int ffmpeg_GetFrameBuf( struct AVCodecContext *p_context,
     vdec_thread_t *p_vdec = (vdec_thread_t *)p_context->opaque;
     picture_t *p_pic;
 
+    /* Some codecs set pix_fmt only after the 1st frame has been decoded,
+     * so this check is necessary. */
+    if( !ffmpeg_PixFmtToChroma( p_context->pix_fmt ) )
+    {
+        p_context->get_buffer = avcodec_default_get_buffer;
+        p_context->release_buffer = avcodec_default_release_buffer;
+        p_vdec->b_direct_rendering = 0;
+        msg_Dbg( p_vdec->p_fifo, "disabling direct rendering" );
+        return p_context->get_buffer( p_context, p_ff_pic );
+    }
+
     /* Check and (re)create our vout if needed */
     p_vdec->p_vout = ffmpeg_CreateVout( p_vdec, p_vdec->p_context );
     if( !p_vdec->p_vout )