diff options
author | Aurelien Jacobs <aurel@gnuage.org> | 2008-01-11 01:04:01 +0000 |
---|---|---|
committer | Aurelien Jacobs <aurel@gnuage.org> | 2008-01-11 01:04:01 +0000 |
commit | 6e6eebf9197803a84adda7ae95ec97fbec86d4dd (patch) | |
tree | ea491e8d108e2fbb40091337fd5510a9f697d9ca /libavformat/movenc.c | |
parent | de04ad45ec92dd14b9e60085c130c1707cdb726c (diff) | |
download | ffmpeg-6e6eebf9197803a84adda7ae95ec97fbec86d4dd.tar.gz |
extract isom_write_avcc into a function
Originally committed as revision 11497 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/movenc.c')
-rw-r--r-- | libavformat/movenc.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c index d8a6fd87f9..377d03a6b9 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -475,24 +475,20 @@ static int avc_parse_nal_units(uint8_t *buf_in, uint8_t **buf, int *size) return 0; } -static int mov_write_avcc_tag(ByteIOContext *pb, MOVTrack *track) +static int isom_write_avcc(ByteIOContext *pb, uint8_t *data, int len) { - offset_t pos = url_ftell(pb); - - put_be32(pb, 0); - put_tag(pb, "avcC"); - if (track->vosLen > 6) { + if (len > 6) { /* check for h264 start code */ - if (AV_RB32(track->vosData) == 0x00000001) { - uint8_t *buf, *end; + if (AV_RB32(data) == 0x00000001) { + uint8_t *buf=NULL, *end; uint32_t sps_size=0, pps_size=0; uint8_t *sps=0, *pps=0; - int ret = avc_parse_nal_units(track->vosData, &track->vosData, &track->vosLen); + int ret = avc_parse_nal_units(data, &buf, &len); if (ret < 0) return ret; - buf = track->vosData; - end = track->vosData + track->vosLen; + data = buf; + end = buf + len; /* look for sps and pps */ while (buf < end) { @@ -524,10 +520,21 @@ static int mov_write_avcc_tag(ByteIOContext *pb, MOVTrack *track) put_byte(pb, 1); /* number of pps */ put_be16(pb, pps_size); put_buffer(pb, pps, pps_size); + av_free(data); } else { - put_buffer(pb, track->vosData, track->vosLen); + put_buffer(pb, data, len); } } + return 0; +} + +static int mov_write_avcc_tag(ByteIOContext *pb, MOVTrack *track) +{ + offset_t pos = url_ftell(pb); + + put_be32(pb, 0); + put_tag(pb, "avcC"); + isom_write_avcc(pb, track->vosData, track->vosLen); return updateSize(pb, pos); } |