[vlc-devel] [RFC] avcodec: copy frame-based palette

Daniel Verkamp daniel at drv.nu
Wed May 14 07:08:48 CEST 2014


---
 modules/codec/avcodec/video.c  | 13 +++++++++++++
 modules/video_chroma/swscale.c |  2 ++
 2 files changed, 15 insertions(+)

diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 2e119d0..3e47cab 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -890,6 +890,19 @@ static void ffmpeg_CopyPicture( decoder_t *p_dec,
         uint8_t *p_dst, *p_src;
         int i_src_stride, i_dst_stride;
 
+        if( p_ff_pic->palette_has_changed )
+        {
+            if( !p_pic->format.p_palette )
+            {
+                p_pic->format.p_palette = calloc( 1, sizeof(video_palette_t) );
+                p_pic->format.p_palette->i_entries = 256;
+            }
+            if( p_pic->format.p_palette )
+            {
+                memcpy( p_pic->format.p_palette->palette, p_ff_pic->data[1], AVPALETTE_SIZE );
+            }
+        }
+
         for( i_plane = 0; i_plane < p_pic->i_planes; i_plane++ )
         {
             p_src  = p_ff_pic->data[i_plane];
diff --git a/modules/video_chroma/swscale.c b/modules/video_chroma/swscale.c
index 2763e43..3b2981d 100644
--- a/modules/video_chroma/swscale.c
+++ b/modules/video_chroma/swscale.c
@@ -584,6 +584,8 @@ static void Convert( filter_t *p_filter, struct SwsContext *ctx,
     if( p_filter->fmt_in.video.i_chroma == VLC_CODEC_RGBP )
     {
         memset( palette, 0, sizeof(palette) );
+        if( p_src->format.p_palette )
+            p_filter->fmt_in.video.p_palette = p_src->format.p_palette;
         if( p_filter->fmt_in.video.p_palette )
             memcpy( palette, p_filter->fmt_in.video.p_palette->palette,
                     __MIN( sizeof(video_palette_t), AVPALETTE_SIZE ) );
-- 
1.9.2




More information about the vlc-devel mailing list