[FFmpeg-devel] [PATCH] avformat/avienc: store palette at keyframes if it differs from the global one
Michael Niedermayer
michael at niedermayer.cc
Sat Mar 5 20:44:39 CET 2016
---
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);
--
1.7.9.5
More information about the ffmpeg-devel
mailing list