]> 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 cad8c207a50a33a41d05743c081e31ee0926feaf..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.59 2004/01/09 00:02:55 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>
@@ -335,8 +335,14 @@ 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 dummy palette to avoid segfaults with some codecs */
-    p_sys->p_context->palctrl = &palette_control;
+    /* 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 );
@@ -485,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() )
@@ -505,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 );
@@ -676,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 )