diff options
author | Baptiste Coudurier | 2010-11-23 00:51:12 +0000 |
---|---|---|
committer | Baptiste Coudurier | 2010-11-23 00:51:12 +0000 |
commit | 798c6facb7bd3ad5b46baf0e12ff02bc9c6e1bb6 (patch) | |
tree | 906b1cb961fe0d4ac6398fda991c20209b3622aa /libavformat/mov.c | |
parent | 91360ce61d00bb20429fb41857abebf50a5c6b1d (diff) |
In ts demuxer, support aac flexmux using extradata in iods, issue #2346
Originally committed as revision 25806 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/mov.c')
-rw-r--r-- | libavformat/mov.c | 84 |
1 files changed, 4 insertions, 80 deletions
diff --git a/libavformat/mov.c b/libavformat/mov.c index cdaf6d36ba..1fc86ea332 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -31,8 +31,6 @@ #include "avformat.h" #include "riff.h" #include "isom.h" -#include "libavcodec/mpeg4audio.h" -#include "libavcodec/mpegaudiodata.h" #include "libavcodec/get_bits.h" #if CONFIG_ZLIB @@ -462,41 +460,6 @@ static int mov_read_hdlr(MOVContext *c, ByteIOContext *pb, MOVAtom atom) return 0; } -int ff_mp4_read_descr_len(ByteIOContext *pb) -{ - int len = 0; - int count = 4; - while (count--) { - int c = get_byte(pb); - len = (len << 7) | (c & 0x7f); - if (!(c & 0x80)) - break; - } - return len; -} - -static int mp4_read_descr(AVFormatContext *fc, ByteIOContext *pb, int *tag) -{ - int len; - *tag = get_byte(pb); - len = ff_mp4_read_descr_len(pb); - dprintf(fc, "MPEG4 description: tag=0x%02x len=%d\n", *tag, len); - return len; -} - -#define MP4ESDescrTag 0x03 -#define MP4DecConfigDescrTag 0x04 -#define MP4DecSpecificDescrTag 0x05 - -static const AVCodecTag mp4_audio_types[] = { - { CODEC_ID_MP3ON4, AOT_PS }, /* old mp3on4 draft */ - { CODEC_ID_MP3ON4, AOT_L1 }, /* layer 1 */ - { CODEC_ID_MP3ON4, AOT_L2 }, /* layer 2 */ - { CODEC_ID_MP3ON4, AOT_L3 }, /* layer 3 */ - { CODEC_ID_MP4ALS, AOT_ALS }, /* MPEG-4 ALS */ - { CODEC_ID_NONE, AOT_NULL }, -}; - int ff_mov_read_esds(AVFormatContext *fc, ByteIOContext *pb, MOVAtom atom) { AVStream *st; @@ -507,55 +470,16 @@ int ff_mov_read_esds(AVFormatContext *fc, ByteIOContext *pb, MOVAtom atom) st = fc->streams[fc->nb_streams-1]; get_be32(pb); /* version + flags */ - len = mp4_read_descr(fc, pb, &tag); + len = ff_mp4_read_descr(fc, pb, &tag); if (tag == MP4ESDescrTag) { get_be16(pb); /* ID */ get_byte(pb); /* priority */ } else get_be16(pb); /* ID */ - len = mp4_read_descr(fc, pb, &tag); - if (tag == MP4DecConfigDescrTag) { - int object_type_id = get_byte(pb); - get_byte(pb); /* stream type */ - get_be24(pb); /* buffer size db */ - get_be32(pb); /* max bitrate */ - get_be32(pb); /* avg bitrate */ - - st->codec->codec_id= ff_codec_get_id(ff_mp4_obj_type, object_type_id); - dprintf(fc, "esds object type id 0x%02x\n", object_type_id); - len = mp4_read_descr(fc, pb, &tag); - if (tag == MP4DecSpecificDescrTag) { - dprintf(fc, "Specific MPEG4 header len=%d\n", len); - if((uint64_t)len > (1<<30)) - return -1; - av_free(st->codec->extradata); - st->codec->extradata = av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE); - if (!st->codec->extradata) - return AVERROR(ENOMEM); - get_buffer(pb, st->codec->extradata, len); - st->codec->extradata_size = len; - if (st->codec->codec_id == CODEC_ID_AAC) { - MPEG4AudioConfig cfg; - ff_mpeg4audio_get_config(&cfg, st->codec->extradata, - st->codec->extradata_size); - st->codec->channels = cfg.channels; - if (cfg.object_type == 29 && cfg.sampling_index < 3) // old mp3on4 - st->codec->sample_rate = ff_mpa_freq_tab[cfg.sampling_index]; - else if (cfg.ext_sample_rate) - st->codec->sample_rate = cfg.ext_sample_rate; - else - st->codec->sample_rate = cfg.sample_rate; - dprintf(fc, "mp4a config channels %d obj %d ext obj %d " - "sample rate %d ext sample rate %d\n", st->codec->channels, - cfg.object_type, cfg.ext_object_type, - cfg.sample_rate, cfg.ext_sample_rate); - if (!(st->codec->codec_id = ff_codec_get_id(mp4_audio_types, - cfg.object_type))) - st->codec->codec_id = CODEC_ID_AAC; - } - } - } + len = ff_mp4_read_descr(fc, pb, &tag); + if (tag == MP4DecConfigDescrTag) + ff_mp4_read_dec_config_descr(fc, st, pb); return 0; } |