diff options
author | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2009-01-16 01:12:32 +0000 |
---|---|---|
committer | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2009-01-16 01:12:32 +0000 |
commit | 5d2160a0dd5ea2c584458c0aeb1a52817e6330ce (patch) | |
tree | 03f7552eb7c7a20a8f630537ddf018070e6ea6a3 /libavformat/movenc.c | |
parent | a97772b166ff5cd1c7dfaa9a3bca7303cca0b582 (diff) | |
download | ffmpeg-5d2160a0dd5ea2c584458c0aeb1a52817e6330ce.tar.gz |
move actual writing before so new size can be taken into account
Originally committed as revision 16623 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/movenc.c')
-rw-r--r-- | libavformat/movenc.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c index b0945bb18d..e07ded3a11 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -1732,6 +1732,14 @@ static int mov_write_packet(AVFormatContext *s, AVPacket *pkt) memcpy(trk->vosData, enc->extradata, trk->vosLen); } + if (enc->codec_id == CODEC_ID_H264 && trk->vosLen > 0 && *(uint8_t *)trk->vosData != 1) { + /* from x264 or from bytestream h264 */ + /* nal reformating needed */ + size = ff_avc_parse_nal_units(pb, pkt->data, pkt->size); + } else { + put_buffer(pb, pkt->data, size); + } + if ((enc->codec_id == CODEC_ID_DNXHD || enc->codec_id == CODEC_ID_AC3) && !trk->vosLen) { /* copy frame to create needed atoms */ @@ -1748,7 +1756,7 @@ static int mov_write_packet(AVFormatContext *s, AVPacket *pkt) return -1; } - trk->cluster[trk->entry].pos = url_ftell(pb); + trk->cluster[trk->entry].pos = url_ftell(pb) - size; trk->cluster[trk->entry].samplesInChunk = samplesInChunk; trk->cluster[trk->entry].size = size; trk->cluster[trk->entry].entries = samplesInChunk; @@ -1769,14 +1777,6 @@ static int mov_write_packet(AVFormatContext *s, AVPacket *pkt) trk->sampleCount += samplesInChunk; mov->mdat_size += size; - if (enc->codec_id == CODEC_ID_H264 && trk->vosLen > 0 && *(uint8_t *)trk->vosData != 1) { - /* from x264 or from bytestream h264 */ - /* nal reformating needed */ - ff_avc_parse_nal_units(pb, pkt->data, pkt->size); - } else { - put_buffer(pb, pkt->data, size); - } - put_flush_packet(pb); return 0; } |