From: Andre Noll Date: Wed, 25 Aug 2021 16:41:07 +0000 (+0200) Subject: mp4: Merge read_mp4a() into read_stsd(). X-Git-Tag: v0.7.1~7^2~22 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=2ca18e6d22391a7eded4a21925a44860a9840ecf;p=paraslash.git mp4: Merge read_mp4a() into read_stsd(). This shortens the code because we already have a track pointer here and can get rid of the duplicated check for the number of tracks. The commit also adds the missing error check for the last read operation, i.e. the one which reads the sample rate. --- diff --git a/mp4.c b/mp4.c index 20aaa2cc..365dce65 100644 --- a/mp4.c +++ b/mp4.c @@ -309,23 +309,6 @@ static int read_stco(struct mp4 *f) return 1; } -static int read_mp4a(struct mp4 *f) -{ - int ret; - struct mp4_track *t; - - if (f->total_tracks == 0) - return -1; - t = f->track[f->total_tracks - 1]; - /* reserved (6), data reference index (2), reserved (8) */ - skip_bytes(f, 16); - ret = read_int16(f, &t->channel_count); - if (ret <= 0) - return ret; - skip_bytes(f, 6); - return read_int16(f, &t->sample_rate); -} - static int read_stsd(struct mp4 *f) { int ret; @@ -349,7 +332,15 @@ static int read_stsd(struct mp4 *f) skip += size; if (!f->audio_track && atom_type == ATOM_MP4A) { f->audio_track = t; - read_mp4a(f); + /* reserved (6), data reference index (2), reserved (8) */ + skip_bytes(f, 16); + ret = read_int16(f, &t->channel_count); + if (ret <= 0) + return ret; + skip_bytes(f, 6); + ret = read_int16(f, &t->sample_rate); + if (ret <= 0) + return ret; } set_position(f, skip); }