int32_t channelCount;
int32_t sampleSize;
uint16_t sampleRate;
- int32_t audioType;
/* stsd */
int32_t stsd_entry_count;
int32_t *ctts_sample_count;
int32_t *ctts_sample_offset;
- /* esde */
- uint8_t *decoderConfig;
- int32_t decoderConfigLen;
-
uint32_t maxBitrate;
uint32_t avgBitrate;
return read_u16_be(data);
}
-static uint32_t read_mp4_descr_length(struct mp4 *f)
-{
- uint8_t b;
- uint8_t numBytes = 0;
- uint32_t length = 0;
-
- do {
- b = read_char(f);
- numBytes++;
- length = (length << 7) | (b & 0x7F);
- } while ((b & 0x80) && numBytes < 4);
-
- return length;
-}
-static int32_t read_esds(struct mp4 *f)
-{
- uint8_t tag;
- uint32_t temp;
- struct mp4_track *t;
-
- if (f->total_tracks == 0)
- return f->error++;
- t = f->track[f->total_tracks - 1];
- read_char(f); /* version */
- read_int24(f); /* flags */
- /* get and verify ES_DescrTag */
- tag = read_char(f);
- if (tag == 0x03) {
- /* read length */
- if (read_mp4_descr_length(f) < 5 + 15) {
- return 1;
- }
- /* skip 3 bytes */
- read_int24(f);
- } else {
- /* skip 2 bytes */
- read_int16(f);
- }
-
- /* get and verify DecoderConfigDescrTab */
- if (read_char(f) != 0x04) {
- return 1;
- }
-
- /* read length */
- temp = read_mp4_descr_length(f);
- if (temp < 13)
- return 1;
-
- t->audioType = read_char(f);
- read_int32(f); //0x15000414 ????
- t->maxBitrate = read_int32(f);
- t->avgBitrate = read_int32(f);
-
- /* get and verify DecSpecificInfoTag */
- if (read_char(f) != 0x05) {
- return 1;
- }
-
- /* read length */
- t->decoderConfigLen = read_mp4_descr_length(f);
- free(t->decoderConfig);
- t->decoderConfig = para_malloc(t->decoderConfigLen);
- read_data(f, t->decoderConfig, t->decoderConfigLen);
- /* will skip the remainder of the atom */
- return 0;
-}
-
static int32_t read_mp4a(struct mp4 *f)
{
int32_t i;
read_int16(f);
atom_read_header(f, &atom_type, &header_size);
- if (atom_type == ATOM_ESDS)
- read_esds(f);
return 0;
}
free(ff->track[i]->stsc_samples_per_chunk);
free(ff->track[i]->stsc_sample_desc_index);
free(ff->track[i]->stco_chunk_offset);
- free(ff->track[i]->decoderConfig);
free(ff->track[i]->ctts_sample_count);
free(ff->track[i]->ctts_sample_offset);
free(ff->track[i]);