aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/avienc.c
diff options
context:
space:
mode:
authorMats Peterson <matsp888@yahoo.com>2016-03-12 16:18:36 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2016-03-13 16:06:09 +0100
commit77bc3e1944a912d712aa0d6d146b991a3686d618 (patch)
treeeaf1eed11208cbcb31bce4e5ff61393d83dc45ba /libavformat/avienc.c
parent9ee5b4096476d369157accc491b0f69a28cb9b6b (diff)
downloadffmpeg-77bc3e1944a912d712aa0d6d146b991a3686d618.tar.gz
lavf/avienc: Add xxpc entries to index
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat/avienc.c')
-rw-r--r--libavformat/avienc.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index 1090f14d98..dceb2efcec 100644
--- a/libavformat/avienc.c
+++ b/libavformat/avienc.c
@@ -52,8 +52,6 @@ typedef struct AVIIentry {
#define AVI_INDEX_CLUSTER_SIZE 16384
-#define AVISF_VIDEO_PALCHANGES 0x00010000
-
typedef struct AVIIndex {
int64_t indx_start;
int64_t audio_strm_offset;
@@ -652,9 +650,13 @@ static int avi_write_idx1(AVFormatContext *s)
}
if (!empty) {
avist = s->streams[stream_id]->priv_data;
- avi_stream2fourcc(tag, stream_id,
+ if (*ie->tag)
+ ffio_wfourcc(pb, ie->tag);
+ else {
+ avi_stream2fourcc(tag, stream_id,
s->streams[stream_id]->codec->codec_type);
- ffio_wfourcc(pb, tag);
+ ffio_wfourcc(pb, tag);
+ }
avio_wl32(pb, ie->flags);
avio_wl32(pb, ie->pos);
avio_wl32(pb, ie->len);
@@ -749,6 +751,20 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
unsigned char tag[5];
avi_stream2fourcc(tag, stream_index, enc->codec_type);
tag[2] = 'p'; tag[3] = 'c';
+ if (s->pb->seekable) {
+ int ret;
+ if (avist->strh_flags_offset) {
+ int64_t cur_offset = avio_tell(pb);
+ avio_seek(pb, avist->strh_flags_offset, SEEK_SET);
+ avio_wl32(pb, AVISF_VIDEO_PALCHANGES);
+ avio_seek(pb, cur_offset, SEEK_SET);
+ avist->strh_flags_offset = 0;
+ }
+ ret = avi_add_ientry(s, stream_index, tag, AVIIF_NO_TIME,
+ pal_size * 4 + 4);
+ if (ret < 0)
+ return ret;
+ }
pc_tag = ff_start_tag(pb, tag);
avio_w8(pb, 0);
avio_w8(pb, pal_size & 0xFF);
@@ -759,13 +775,6 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
}
ff_end_tag(pb, pc_tag);
memcpy(avist->old_palette, avist->palette, pal_size * 4);
- if (pb->seekable && avist->strh_flags_offset) {
- int64_t cur_offset = avio_tell(pb);
- avio_seek(pb, avist->strh_flags_offset, SEEK_SET);
- avio_wl32(pb, AVISF_VIDEO_PALCHANGES);
- avio_seek(pb, cur_offset, SEEK_SET);
- avist->strh_flags_offset = 0;
- }
}
}
}