From: Andre Noll Date: Wed, 11 Aug 2021 17:26:00 +0000 (+0200) Subject: mp4: Don't parse the esds atom any more. X-Git-Tag: v0.7.1~7^2~101 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=e69d1a6b30876ed1e18a9ea4057a0f64bde9a33f;p=paraslash.git mp4: Don't parse the esds atom any more. With the decoder specific config no longer in use, we can simplify mp4.c further by getting rid of some cryptic and underdocumented code which no longer does anything useful for us. --- diff --git a/mp4.c b/mp4.c index be974b3c..5eef09de 100644 --- a/mp4.c +++ b/mp4.c @@ -17,7 +17,6 @@ struct mp4_track { int32_t channelCount; int32_t sampleSize; uint16_t sampleRate; - int32_t audioType; /* stsd */ int32_t stsd_entry_count; @@ -47,10 +46,6 @@ struct mp4_track { int32_t *ctts_sample_count; int32_t *ctts_sample_offset; - /* esde */ - uint8_t *decoderConfig; - int32_t decoderConfigLen; - uint32_t maxBitrate; uint32_t avgBitrate; @@ -591,74 +586,6 @@ static uint16_t read_int16(struct mp4 *f) 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; @@ -689,8 +616,6 @@ static int32_t read_mp4a(struct mp4 *f) read_int16(f); atom_read_header(f, &atom_type, &header_size); - if (atom_type == ATOM_ESDS) - read_esds(f); return 0; } @@ -1279,7 +1204,6 @@ void mp4_close(struct mp4 *ff) 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]);