aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/avienc.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-03-19 03:28:08 +0100
committerMichael Niedermayer <michaelni@gmx.at>2015-03-19 16:33:50 +0100
commit01775c8858c171787bc475471ba2cd6e6264b00c (patch)
tree69b209ce9960a041b002d3958050fa6bde6a8dc0 /libavformat/avienc.c
parentc3a6d179fbfa30150dda0c30c3f70e289420bfa4 (diff)
downloadffmpeg-01775c8858c171787bc475471ba2cd6e6264b00c.tar.gz
avformat/avienc: factor out update_odml_entry()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/avienc.c')
-rw-r--r--libavformat/avienc.c59
1 files changed, 35 insertions, 24 deletions
diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index 9dd13ff57d..5f1908dee2 100644
--- a/libavformat/avienc.c
+++ b/libavformat/avienc.c
@@ -469,6 +469,39 @@ static int avi_write_header(AVFormatContext *s)
return 0;
}
+static void update_odml_entry(AVFormatContext *s, int stream_index, int64_t ix)
+{
+ AVIOContext *pb = s->pb;
+ AVIContext *avi = s->priv_data;
+ AVIStream *avist = s->streams[stream_index]->priv_data;
+ int64_t pos;
+ int au_byterate, au_ssize, au_scale;
+
+ avio_flush(pb);
+ pos = avio_tell(pb);
+
+ /* Updating one entry in the AVI OpenDML master index */
+ avio_seek(pb, avist->indexes.indx_start - 8, SEEK_SET);
+ ffio_wfourcc(pb, "indx"); /* enabling this entry */
+ avio_skip(pb, 8);
+ avio_wl32(pb, avi->riff_id); /* nEntriesInUse */
+ avio_skip(pb, 16 * avi->riff_id);
+ avio_wl64(pb, ix); /* qwOffset */
+ avio_wl32(pb, pos - ix); /* dwSize */
+ ff_parse_specific_params(s->streams[stream_index], &au_byterate, &au_ssize, &au_scale);
+ if (s->streams[stream_index]->codec->codec_type == AVMEDIA_TYPE_AUDIO && au_ssize > 0) {
+ uint32_t audio_segm_size = (avist->audio_strm_length - avist->indexes.audio_strm_offset);
+ if ((audio_segm_size % au_ssize > 0) && !avist->sample_requested) {
+ avpriv_request_sample(s, "OpenDML index duration for audio packets with partial frames");
+ avist->sample_requested = 1;
+ }
+ avio_wl32(pb, audio_segm_size / au_ssize); /* dwDuration (sample count) */
+ } else
+ avio_wl32(pb, avist->indexes.entry); /* dwDuration (packet count) */
+
+ avio_seek(pb, pos, SEEK_SET);
+}
+
static int avi_write_ix(AVFormatContext *s)
{
AVIOContext *pb = s->pb;
@@ -487,8 +520,7 @@ static int avi_write_ix(AVFormatContext *s)
for (i = 0; i < s->nb_streams; i++) {
AVIStream *avist = s->streams[i]->priv_data;
- int64_t ix, pos;
- int au_byterate, au_ssize, au_scale;
+ int64_t ix;
avi_stream2fourcc(tag, i, s->streams[i]->codec->codec_type);
ix_tag[3] = '0' + i;
@@ -513,29 +545,8 @@ static int avi_write_ix(AVFormatContext *s)
avio_wl32(pb, ((uint32_t) ie->len & ~0x80000000) |
(ie->flags & 0x10 ? 0 : 0x80000000));
}
- avio_flush(pb);
- pos = avio_tell(pb);
-
- /* Updating one entry in the AVI OpenDML master index */
- avio_seek(pb, avist->indexes.indx_start - 8, SEEK_SET);
- ffio_wfourcc(pb, "indx"); /* enabling this entry */
- avio_skip(pb, 8);
- avio_wl32(pb, avi->riff_id); /* nEntriesInUse */
- avio_skip(pb, 16 * avi->riff_id);
- avio_wl64(pb, ix); /* qwOffset */
- avio_wl32(pb, pos - ix); /* dwSize */
- ff_parse_specific_params(s->streams[i], &au_byterate, &au_ssize, &au_scale);
- if (s->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO && au_ssize > 0) {
- uint32_t audio_segm_size = (avist->audio_strm_length - avist->indexes.audio_strm_offset);
- if ((audio_segm_size % au_ssize > 0) && !avist->sample_requested) {
- avpriv_request_sample(s, "OpenDML index duration for audio packets with partial frames");
- avist->sample_requested = 1;
- }
- avio_wl32(pb, audio_segm_size / au_ssize); /* dwDuration (sample count) */
- } else
- avio_wl32(pb, avist->indexes.entry); /* dwDuration (packet count) */
- avio_seek(pb, pos, SEEK_SET);
+ update_odml_entry(s, i, ix);
}
return 0;
}