[vlc-commits] avcodec: copy frame-based palette

Daniel Verkamp git at videolan.org
Sun Jun 15 23:02:01 CEST 2014


vlc | branch: master | Daniel Verkamp <daniel at drv.nu> | Sun Jun 15 19:47:19 2014 +0000| [24c25e9999f6dd90efe22ad8c1af744f9b3452b0] | committer: Jean-Baptiste Kempf

avcodec: copy frame-based palette

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=24c25e9999f6dd90efe22ad8c1af744f9b3452b0
---

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

diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index fd0a870..65c6773 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -852,6 +852,19 @@ static void ffmpeg_CopyPicture( decoder_t *p_dec,
         uint8_t *p_dst, *p_src;
         int i_src_stride, i_dst_stride;
 
+        if( p_sys->p_context->pix_fmt == PIX_FMT_PAL8 )
+        {
+            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 7d6faf6..8ce512c 100644
--- a/modules/video_chroma/swscale.c
+++ b/modules/video_chroma/swscale.c
@@ -583,9 +583,13 @@ static void Convert( filter_t *p_filter, struct SwsContext *ctx,
     GetPixels( src, src_stride, p_src, i_plane_start, i_plane_count, b_swap_uvi );
     if( p_filter->fmt_in.video.i_chroma == VLC_CODEC_RGBP )
     {
+        video_palette_t *src_pal =
+            p_src->format.p_palette ?
+            p_src->format.p_palette :
+            p_filter->fmt_in.video.p_palette;
         memset( palette, 0, sizeof(palette) );
-        if( p_filter->fmt_in.video.p_palette )
-            memcpy( palette, p_filter->fmt_in.video.p_palette->palette,
+        if( src_pal )
+            memcpy( palette, src_pal->palette,
                     __MIN( sizeof(video_palette_t), AVPALETTE_SIZE ) );
         src[1] = palette;
         src_stride[1] = 4;



More information about the vlc-commits mailing list