]> git.sesse.net Git - vlc/blobdiff - modules/codec/ffmpeg/video.c
* modules/codec/ffmpeg/video.c: fixed crash when disabling post-processing with video...
[vlc] / modules / codec / ffmpeg / video.c
index 8ba3eb19cd2a86a525c25edab641549c47a20175..8c4467cb85caa3b9240ca4ee3caafcf20c4a82c1 100644 (file)
@@ -2,7 +2,7 @@
  * video.c: video decoder using the ffmpeg library
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: video.c,v 1.58 2004/01/08 00:12:50 gbazin Exp $
+ * $Id: video.c,v 1.63 2004/02/08 12:09:50 gbazin Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *          Gildas Bazin <gbazin@netcourrier.com>
@@ -81,6 +81,9 @@ struct decoder_sys_t
     vlc_bool_t b_pp_init;
 };
 
+/* FIXME (dummy palette for now) */
+static AVPaletteControl palette_control;
+
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
@@ -332,6 +335,15 @@ int E_(InitVideoDec)( decoder_t *p_dec, AVCodecContext *p_context,
     p_dec->fmt_out.i_cat = VIDEO_ES;
     p_dec->fmt_out.i_codec = ffmpeg_PixFmtToChroma( p_context->pix_fmt );
 
+    /* Setup palette */
+#if LIBAVCODEC_BUILD >= 4688
+    if( p_dec->fmt_in.video.p_palette )
+        p_sys->p_context->palctrl =
+            (AVPaletteControl *)p_dec->fmt_in.video.p_palette;
+    else
+        p_sys->p_context->palctrl = &palette_control;
+#endif
+
     /* ***** Open the codec ***** */
     vlc_mutex_lock( lockval.p_address );
     if( avcodec_open( p_sys->p_context, p_sys->p_codec ) < 0 )
@@ -479,7 +491,14 @@ picture_t *E_(DecodeVideo)( decoder_t *p_dec, block_t **pp_block )
         p_sys->p_buffer += i_used;
 
         /* Nothing to display */
-        if( !b_gotpicture ) continue;
+        if( !b_gotpicture )
+        {
+            if( i_used == 0 )
+            {
+                break;
+            }
+            continue;
+        }
 
         /* Update frame late count*/
         if( p_sys->i_pts && p_sys->i_pts <= mdate() )
@@ -499,7 +518,8 @@ picture_t *E_(DecodeVideo)( decoder_t *p_dec, block_t **pp_block )
             continue;
         }
 
-        if( !p_sys->b_direct_rendering || p_sys->b_pp )
+        if( !p_sys->b_direct_rendering ||
+            p_sys->b_pp || !p_sys->p_ff_pic->opaque )
         {
             /* Get a new picture */
             p_pic = ffmpeg_NewPictBuf( p_dec, p_sys->p_context );
@@ -670,6 +690,7 @@ static int ffmpeg_GetFrameBuf( struct AVCodecContext *p_context,
     else p_ff_pic->pts = 0;
 
     p_sys->input_pts = p_sys->input_dts = 0;
+    p_ff_pic->opaque = 0;
 
     /* Not much to do in indirect rendering mode */
     if( !p_sys->b_direct_rendering || p_sys->b_pp )