Make mov LPCM and AAC parsing functions public

Originally committed as revision 19878 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Peter Ross 2009-09-16 11:35:01 +00:00
parent fa77dd639d
commit 2d423666c0
2 changed files with 24 additions and 15 deletions

View File

@ -137,4 +137,8 @@ typedef struct MOVContext {
int itunes_metadata; ///< metadata are itunes style int itunes_metadata; ///< metadata are itunes style
} MOVContext; } MOVContext;
int ff_mp4_read_descr_len(ByteIOContext *pb);
int ff_mov_read_esds(AVFormatContext *fc, ByteIOContext *pb, MOVAtom atom);
enum CodecID ff_mov_get_lpcm_codec_id(int bps, int flags);
#endif /* AVFORMAT_ISOM_H */ #endif /* AVFORMAT_ISOM_H */

View File

@ -358,7 +358,7 @@ static int mov_read_hdlr(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
return 0; return 0;
} }
static int mp4_read_descr_len(ByteIOContext *pb) int ff_mp4_read_descr_len(ByteIOContext *pb)
{ {
int len = 0; int len = 0;
int count = 4; int count = 4;
@ -371,12 +371,12 @@ static int mp4_read_descr_len(ByteIOContext *pb)
return len; return len;
} }
static int mp4_read_descr(MOVContext *c, ByteIOContext *pb, int *tag) int mp4_read_descr(AVFormatContext *fc, ByteIOContext *pb, int *tag)
{ {
int len; int len;
*tag = get_byte(pb); *tag = get_byte(pb);
len = mp4_read_descr_len(pb); len = ff_mp4_read_descr_len(pb);
dprintf(c->fc, "MPEG4 description: tag=0x%02x len=%d\n", *tag, len); dprintf(fc, "MPEG4 description: tag=0x%02x len=%d\n", *tag, len);
return len; return len;
} }
@ -393,24 +393,24 @@ static const AVCodecTag mp4_audio_types[] = {
{ CODEC_ID_NONE, AOT_NULL }, { CODEC_ID_NONE, AOT_NULL },
}; };
static int mov_read_esds(MOVContext *c, ByteIOContext *pb, MOVAtom atom) int ff_mov_read_esds(AVFormatContext *fc, ByteIOContext *pb, MOVAtom atom)
{ {
AVStream *st; AVStream *st;
int tag, len; int tag, len;
if (c->fc->nb_streams < 1) if (fc->nb_streams < 1)
return 0; return 0;
st = c->fc->streams[c->fc->nb_streams-1]; st = fc->streams[fc->nb_streams-1];
get_be32(pb); /* version + flags */ get_be32(pb); /* version + flags */
len = mp4_read_descr(c, pb, &tag); len = mp4_read_descr(fc, pb, &tag);
if (tag == MP4ESDescrTag) { if (tag == MP4ESDescrTag) {
get_be16(pb); /* ID */ get_be16(pb); /* ID */
get_byte(pb); /* priority */ get_byte(pb); /* priority */
} else } else
get_be16(pb); /* ID */ get_be16(pb); /* ID */
len = mp4_read_descr(c, pb, &tag); len = mp4_read_descr(fc, pb, &tag);
if (tag == MP4DecConfigDescrTag) { if (tag == MP4DecConfigDescrTag) {
int object_type_id = get_byte(pb); int object_type_id = get_byte(pb);
get_byte(pb); /* stream type */ get_byte(pb); /* stream type */
@ -419,10 +419,10 @@ static int mov_read_esds(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
get_be32(pb); /* avg bitrate */ get_be32(pb); /* avg bitrate */
st->codec->codec_id= ff_codec_get_id(ff_mp4_obj_type, object_type_id); st->codec->codec_id= ff_codec_get_id(ff_mp4_obj_type, object_type_id);
dprintf(c->fc, "esds object type id %d\n", object_type_id); dprintf(fc, "esds object type id %d\n", object_type_id);
len = mp4_read_descr(c, pb, &tag); len = mp4_read_descr(fc, pb, &tag);
if (tag == MP4DecSpecificDescrTag) { if (tag == MP4DecSpecificDescrTag) {
dprintf(c->fc, "Specific MPEG4 header len=%d\n", len); dprintf(fc, "Specific MPEG4 header len=%d\n", len);
if((uint64_t)len > (1<<30)) if((uint64_t)len > (1<<30))
return -1; return -1;
st->codec->extradata = av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE); st->codec->extradata = av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE);
@ -441,7 +441,7 @@ static int mov_read_esds(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
st->codec->sample_rate = ff_mpa_freq_tab[cfg.sampling_index]; st->codec->sample_rate = ff_mpa_freq_tab[cfg.sampling_index];
else else
st->codec->sample_rate = cfg.sample_rate; // ext sample rate ? st->codec->sample_rate = cfg.sample_rate; // ext sample rate ?
dprintf(c->fc, "mp4a config channels %d obj %d ext obj %d " dprintf(fc, "mp4a config channels %d obj %d ext obj %d "
"sample rate %d ext sample rate %d\n", st->codec->channels, "sample rate %d ext sample rate %d\n", st->codec->channels,
cfg.object_type, cfg.ext_object_type, cfg.object_type, cfg.ext_object_type,
cfg.sample_rate, cfg.ext_sample_rate); cfg.sample_rate, cfg.ext_sample_rate);
@ -454,6 +454,11 @@ static int mov_read_esds(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
return 0; return 0;
} }
static int mov_read_esds(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
{
return ff_mov_read_esds(c->fc, pb, atom);
}
static int mov_read_pasp(MOVContext *c, ByteIOContext *pb, MOVAtom atom) static int mov_read_pasp(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
{ {
const int num = get_be32(pb); const int num = get_be32(pb);
@ -760,7 +765,7 @@ static int mov_read_stco(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
* Compute codec id for 'lpcm' tag. * Compute codec id for 'lpcm' tag.
* See CoreAudioTypes and AudioStreamBasicDescription at Apple. * See CoreAudioTypes and AudioStreamBasicDescription at Apple.
*/ */
static enum CodecID mov_get_lpcm_codec_id(int bps, int flags) enum CodecID ff_mov_get_lpcm_codec_id(int bps, int flags)
{ {
if (flags & 1) { // floating point if (flags & 1) { // floating point
if (flags & 2) { // big endian if (flags & 2) { // big endian
@ -998,7 +1003,7 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
sc->bytes_per_frame = get_be32(pb); /* bytes per audio packet if constant */ sc->bytes_per_frame = get_be32(pb); /* bytes per audio packet if constant */
sc->samples_per_frame = get_be32(pb); /* lpcm frames per audio packet if constant */ sc->samples_per_frame = get_be32(pb); /* lpcm frames per audio packet if constant */
if (format == MKTAG('l','p','c','m')) if (format == MKTAG('l','p','c','m'))
st->codec->codec_id = mov_get_lpcm_codec_id(st->codec->bits_per_coded_sample, flags); st->codec->codec_id = ff_mov_get_lpcm_codec_id(st->codec->bits_per_coded_sample, flags);
} }
} }