--
Mats Peterson
http://matsp888.no-ip.org/~mats/
>From 0b38769f175ceafff8150a97be06b1a2fbf0bc3d Mon Sep 17 00:00:00 2001
From: Mats Peterson <[email protected]>
Date: Mon, 7 Mar 2016 14:54:26 +0100
Subject: [PATCH 2/2] lavf/avienc: New static function avi_write_xxpc()
---
libavformat/avienc.c | 38 +++++++++++++++++++++++++-------------
1 file changed, 25 insertions(+), 13 deletions(-)
diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index b7fd12a..fe4dc7e 100644
--- a/libavformat/avienc.c
+++ b/libavformat/avienc.c
@@ -654,9 +654,31 @@ static int write_skip_frames(AVFormatContext *s, int stream_index, int64_t dts)
return 0;
}
-static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
+static int avi_write_xxpc(AVFormatContext *s, int stream_index, uint32_t *palette)
{
+ AVIOContext *pb = s->pb;
+ AVCodecContext *enc = s->streams[stream_index]->codec;
+ int pal_size = 1 << enc->bits_per_coded_sample;
unsigned char tag[5];
+ int pc_tag, i;
+
+ avi_stream2fourcc(tag, stream_index, enc->codec_type);
+ tag[2] = 'p'; tag[3] = 'c';
+ pc_tag = ff_start_tag(pb, tag);
+ avio_w8(pb, 0);
+ avio_w8(pb, pal_size & 0xFF);
+ avio_wl16(pb, 0); // reserved
+ for (i = 0; i < pal_size; i++) {
+ uint32_t v = palette[i];
+ avio_wb32(pb, v<<8);
+ }
+ ff_end_tag(pb, pc_tag);
+
+ return 0;
+}
+
+static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
+{
const int stream_index = pkt->stream_index;
AVIOContext *pb = s->pb;
AVCodecContext *enc = s->streams[stream_index]->codec;
@@ -691,7 +713,7 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
return ret2;
if (ret2) {
int pal_size = 1 << enc->bits_per_coded_sample;
- int pc_tag, i;
+ int i;
av_assert0(enc->bits_per_coded_sample >= 0 && enc->bits_per_coded_sample <= 8);
@@ -707,17 +729,7 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
avist->pal_offset = 0;
}
if (memcmp(avist->palette, avist->old_palette, pal_size * 4)) {
- avi_stream2fourcc(tag, stream_index, enc->codec_type);
- tag[2] = 'p'; tag[3] = 'c';
- pc_tag = ff_start_tag(pb, tag);
- avio_w8(pb, 0);
- avio_w8(pb, pal_size & 0xFF);
- avio_wl16(pb, 0); // reserved
- for (i = 0; i < pal_size; i++) {
- uint32_t v = avist->palette[i];
- avio_wb32(pb, v<<8);
- }
- ff_end_tag(pb, pc_tag);
+ avi_write_xxpc(s, stream_index, avist->palette);
memcpy(avist->old_palette, avist->palette, pal_size * 4);
if (pb->seekable && avist->strh_flags_offset) {
int64_t cur_offset = avio_tell(pb);
--
1.7.10.4
_______________________________________________
ffmpeg-devel mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel