diff options
author | Clément Bœsch <clement.boesch@smartjog.com> | 2012-09-20 10:34:28 +0200 |
---|---|---|
committer | Clément Bœsch <ubitux@gmail.com> | 2012-09-27 08:59:36 +0200 |
commit | e17a2aba2528e333bf63580af48eb0fbfc36f4f5 (patch) | |
tree | 7887f78961ee94ede3354c37721cad335c60db2b /libavformat | |
parent | 65f7aee63b6283a2336d03046faa37f2391d98e0 (diff) | |
download | ffmpeg-e17a2aba2528e333bf63580af48eb0fbfc36f4f5.tar.gz |
lavf/movenc: add get_moov_size and use it in fragment code.
This function will be re-used in the following commits.
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/movenc.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c index fffa88c95f..1d09420b95 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -2876,6 +2876,21 @@ static void mov_parse_vc1_frame(AVPacket *pkt, MOVTrack *trk, int fragment) } } +static int get_moov_size(AVFormatContext *s) +{ + int ret; + uint8_t *buf; + AVIOContext *moov_buf; + MOVMuxContext *mov = s->priv_data; + + if ((ret = avio_open_dyn_buf(&moov_buf)) < 0) + return ret; + mov_write_moov_tag(moov_buf, mov, s); + ret = avio_close_dyn_buf(moov_buf, &buf); + av_free(buf); + return ret; +} + static int mov_flush_fragment(AVFormatContext *s) { MOVMuxContext *mov = s->priv_data; @@ -2887,10 +2902,8 @@ static int mov_flush_fragment(AVFormatContext *s) if (!(mov->flags & FF_MOV_FLAG_EMPTY_MOOV) && mov->fragments == 0) { int64_t pos = avio_tell(s->pb); - int ret; - AVIOContext *moov_buf; uint8_t *buf; - int buf_size; + int buf_size, moov_size; for (i = 0; i < mov->nb_streams; i++) if (!mov->tracks[i].entry) @@ -2899,13 +2912,9 @@ static int mov_flush_fragment(AVFormatContext *s) if (i < mov->nb_streams) return 0; - if ((ret = avio_open_dyn_buf(&moov_buf)) < 0) - return ret; - mov_write_moov_tag(moov_buf, mov, s); - buf_size = avio_close_dyn_buf(moov_buf, &buf); - av_free(buf); + moov_size = get_moov_size(s); for (i = 0; i < mov->nb_streams; i++) - mov->tracks[i].data_offset = pos + buf_size + 8; + mov->tracks[i].data_offset = pos + moov_size + 8; mov_write_moov_tag(s->pb, mov, s); |