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

Daniel Verkamp daniel at drv.nu
Sun Jun 15 22:45:45 CEST 2014


On Sat, Jun 14, 2014 at 6:25 AM, Jean-Baptiste Kempf <jb at videolan.org> wrote:
> On 13 May, Daniel Verkamp wrote :
>> > 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 ) );
>>
>> Later frames don't have the palette, so I copy the video_palette_t
>> pointer into the filter input format in swscale.  This seems a little
>> ugly to me; perhaps there is a better place to store the palette
>> between palette changes.
>>
>> I am also not sure where the palette is actually freed, so the palette
>> pointer may not be safe to copy into the filter.
>
> It should be potentially freed when the p_src picture_t is released, so,
> it could be just after the Filter() is called.
>
> So, from my understanding either you set the p_palette to NULL in the
> swscale, or you need to cpy it.

I did some more investigation, and it looks like the palette is set in
every frame returned from avcodec, not just when palette_has_changed
is set.  This will make things much simpler since then the palette
does not need to be shared between frames.  I will send an updated
patch.

Thanks,
-- Daniel Verkamp



More information about the vlc-devel mailing list