]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
mp4: Merge read_mp4a() into read_stsd().
authorAndre Noll <maan@tuebingen.mpg.de>
Wed, 25 Aug 2021 16:41:07 +0000 (18:41 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Mon, 30 May 2022 19:37:36 +0000 (21:37 +0200)
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.

mp4.c

diff --git a/mp4.c b/mp4.c
index 20aaa2ccc98f609b13faeee08da5dda441acb5e3..365dce6550a5a150d1736cd194de8318667f4492 100644 (file)
--- 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);
        }