]> git.sesse.net Git - vlc/commitdiff
avcodec: copy frame-based palette
authorDaniel Verkamp <daniel@drv.nu>
Sun, 15 Jun 2014 19:47:19 +0000 (19:47 +0000)
committerJean-Baptiste Kempf <jb@videolan.org>
Sun, 15 Jun 2014 21:01:48 +0000 (23:01 +0200)
Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
modules/codec/avcodec/video.c
modules/video_chroma/swscale.c

index fd0a870876cc3909024835a920adcdec472fef8b..65c6773681345f1a6ce5e5addc6c044443bb23d5 100644 (file)
@@ -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];
index 7d6faf61d9a8aa80650b1e4bdf5ee46b6df6b956..8ce512c3e9f8c9d5f36675d77cdda5a00a9db2e2 100644 (file)
@@ -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;