summaryrefslogtreecommitdiff
path: root/libavformat/avienc.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2016-02-18 20:57:32 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2016-02-19 15:47:33 +0100
commit7ac962af38f0f0adf6dcfb6716faee9729ef8036 (patch)
treedc6b6759716e2b1f7340e6d8c1937c4dc98a1c5d /libavformat/avienc.c
parent4956dc88d1fee9f4fa8ae0e26cec0593fef68179 (diff)
avformat/avienc: Store pal8 palette
This can be made more efficient, but first and the main goal of this change is to store it at all Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat/avienc.c')
-rw-r--r--libavformat/avienc.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index 09ec63beba..4e7bca43fe 100644
--- a/libavformat/avienc.c
+++ b/libavformat/avienc.c
@@ -646,7 +646,11 @@ static int write_skip_frames(AVFormatContext *s, int stream_index, int64_t dts)
static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
{
+ unsigned char tag[5];
const int stream_index = pkt->stream_index;
+ const uint8_t *data = pkt->data;
+ int size = pkt->size;
+ AVIOContext *pb = s->pb;
AVCodecContext *enc = s->streams[stream_index]->codec;
int ret;
@@ -667,6 +671,21 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
if (ret < 0)
return ret;
if (ret) {
+ if (ret == CONTAINS_PAL) {
+ 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, 0);
+ avio_wl16(pb, 0); // reserved
+ for (i = 0; i<256; i++) {
+ uint32_t v = AV_RL32(data + size - 1024 + 4*i);
+ avio_wb32(pb, v<<8);
+ }
+ ff_end_tag(pb, pc_tag);
+ }
ret = avi_write_packet_internal(s, pkt);
av_packet_free(&pkt);
return ret;