[vlc-commits] [Git][videolan/vlc][master] 2 commits: codec: avcodec: handle per-frame palette changes
Steve Lhomme (@robUx4)
gitlab at videolan.org
Tue Jun 16 12:32:32 UTC 2026
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
81612520 by Tristan Matthews at 2026-06-16T12:21:30+00:00
codec: avcodec: handle per-frame palette changes
Previously we were only ever using the initial palette, whereas e.g. mpv and
ffmpeg correctly handle per-frame palette updates.
- - - - -
6805e458 by Tristan Matthews at 2026-06-16T12:21:30+00:00
swscale: allow for per-frame palette changes
Fixes #24859 and #25017
- - - - -
2 changed files:
- modules/codec/avcodec/video.c
- modules/video_chroma/swscale.c
Changes:
=====================================
modules/codec/avcodec/video.c
=====================================
@@ -1667,6 +1667,14 @@ static int DecodeBlock( decoder_t *p_dec, block_t **pp_block )
}
}
+ /* The palette can change on any frame; avcodec exposes the current one
+ * in frame->data[1]. The fmt_out palette and the chroma converter are
+ * only set up once (on the first frame above), so refresh the output
+ * picture's own palette every frame to keep the colors up-to-date. */
+ if( p_context->pix_fmt == AV_PIX_FMT_PAL8 && frame->data[1] != NULL
+ && p_pic->format.p_palette != NULL )
+ lavc_Frame8PaletteCopy( p_pic->format.p_palette, frame->data[1] );
+
p_pic->date = i_pts;
/* Hack to force display of still pictures */
p_pic->b_force = p_sys->b_first_frame;
=====================================
modules/video_chroma/swscale.c
=====================================
@@ -673,9 +673,10 @@ static void Convert( filter_t *p_filter, struct SwsContext *ctx,
p_src, i_plane_count, b_swap_uvi );
if( p_filter->fmt_in.video.i_chroma == VLC_CODEC_RGBP )
{
- if( p_filter->fmt_in.video.p_palette )
+ /* The palette may change every picture, that's why we check it here. */
+ const video_palette_t *p_palette = p_src->format.p_palette;
+ if( p_palette )
{
- const video_palette_t *p_palette = p_filter->fmt_in.video.p_palette;
static_assert(sizeof(p_palette->palette) == AVPALETTE_SIZE,
"Palette size mismatch between vlc and libavutil");
uint8_t *dstp = palette;
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/3c4953e746e19df5df04e4af36ebd17b2b73ce94...6805e4584e6bafa77dd22f26049ea0cd49a7c17a
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/3c4953e746e19df5df04e4af36ebd17b2b73ce94...6805e4584e6bafa77dd22f26049ea0cd49a7c17a
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help
More information about the vlc-commits
mailing list