[vlc-commits] avcodec: fix palette propagation

Thomas Guillem git at videolan.org
Tue Sep 27 09:56:40 CEST 2016


vlc/vlc-2.2 | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Sep 27 09:26:29 2016 +0200| [57dfd58532ec7086f8cd745969f9203a260823cf] | committer: Jean-Baptiste Kempf

avcodec: fix palette propagation

closes #9940, #14975

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.2.git/?a=commit;h=57dfd58532ec7086f8cd745969f9203a260823cf
---

 modules/codec/avcodec/video.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index ae600e8..9712386 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -681,6 +681,27 @@ picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
             continue;
         }
 
+#if LIBAVCODEC_VERSION_MAJOR >= 54
+        if( p_context->pix_fmt == AV_PIX_FMT_PAL8
+         && !p_dec->fmt_out.video.p_palette && p_sys->p_ff_pic->data[1] )
+        {
+            video_palette_t *p_palette;
+            p_palette = p_dec->fmt_out.video.p_palette
+                      = malloc( sizeof(video_palette_t) );
+            if( !p_palette )
+            {
+                if( p_block )
+                    block_Release( p_block );
+                return NULL;
+            }
+            static_assert( sizeof(p_palette->palette) == AVPALETTE_SIZE,
+                           "Palette size mismatch between vlc and libavutil" );
+            memcpy( p_palette->palette, p_sys->p_ff_pic->data[1],
+                    AVPALETTE_SIZE );
+            p_palette->i_entries = AVPALETTE_COUNT;
+        }
+#endif
+
         /* Sanity check (seems to be needed for some streams) */
         if( p_sys->p_ff_pic->pict_type == AV_PICTURE_TYPE_B)
         {



More information about the vlc-commits mailing list