[FFmpeg-devel] [PATCH] avformat/avienc: store palette at keyframes if it differs from the global one

Mats Peterson matsp888 at yahoo.com
Sat Mar 5 22:12:49 CET 2016


On 03/05/2016 08:44 PM, Michael Niedermayer wrote:
> ---
>   libavformat/avienc.c |    9 ++++++++-
>   1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/avienc.c b/libavformat/avienc.c
> index 0cfffb7..8804ece 100644
> --- a/libavformat/avienc.c
> +++ b/libavformat/avienc.c
> @@ -84,6 +84,7 @@ typedef struct AVIStream {
>
>       uint32_t palette[AVPALETTE_COUNT];
>       uint32_t old_palette[AVPALETTE_COUNT];
> +    uint32_t global_palette[AVPALETTE_COUNT];
>       int64_t pal_offset;
>   } AVIStream;
>
> @@ -711,9 +712,15 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
>                       }
>                       avio_seek(pb, cur_offset, SEEK_SET);
>                       memcpy(avist->old_palette, avist->palette, pal_size * 4);
> +                    memcpy(avist->global_palette, avist->palette, pal_size * 4);
>                       avist->pal_offset = 0;
>                   }
> -                if (memcmp(avist->palette, avist->old_palette, pal_size * 4)) {
> +                if (memcmp(avist->palette, avist->old_palette, pal_size * 4) ||
> +                    (memcmp(avist->palette, avist->global_palette, pal_size * 4) ||
> +                     avist->strh_flags_offset == 0 ||
> +                     !pb->seekable
> +                    ) && (pkt->flags & AV_PKT_FLAG_KEY)
> +                ) {
>                       avi_stream2fourcc(tag, stream_index, enc->codec_type);
>                       tag[2] = 'p'; tag[3] = 'c';
>                       pc_tag = ff_start_tag(pb, tag);
>



Doesn't seem to work quite as expected, Michael.
Try ffmpeg -i toon.avi -vcodec copy out.avi.
The destination file will still contain only two xxpc chunks.

Mats

-- 
Mats Peterson
http://matsp888.no-ip.org/~mats/


More information about the ffmpeg-devel mailing list