]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
mp4: Don't store track type anymore.
authorAndre Noll <maan@tuebingen.mpg.de>
Wed, 11 Aug 2021 17:36:59 +0000 (19:36 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Mon, 30 May 2022 19:37:35 +0000 (21:37 +0200)
The only thing we care about is whether or not a track is an audio
track. Hence a simple boolean suffices and the "tracks" enum can
be removed.

mp4.c

diff --git a/mp4.c b/mp4.c
index 5eef09de489829a3284d0eef36339e74a857e366..959dbde8c677676eff5464476b66a35e87f22ff3 100644 (file)
--- a/mp4.c
+++ b/mp4.c
@@ -13,7 +13,7 @@
 #include "mp4.h"
 
 struct mp4_track {
-       int32_t type;
+       bool is_audio;
        int32_t channelCount;
        int32_t sampleSize;
        uint16_t sampleRate;
@@ -117,13 +117,6 @@ static int32_t atom_compare(int8_t a1, int8_t b1, int8_t c1, int8_t d1,
                return 0;
 }
 
-enum tracks {
-       TRACK_UNKNOWN = 0,
-       TRACK_AUDIO  = 1,
-       TRACK_VIDEO = 2,
-       TRACK_SYSTEM = 3
-};
-
 enum atoms {
        /* atoms with subatoms */
        ATOM_MOOV = 1,
@@ -642,17 +635,9 @@ static int32_t read_stsd(struct mp4 *f)
                uint8_t atom_type = 0;
                size = atom_read_header(f, &atom_type, &header_size);
                skip += size;
-
-               if (atom_type == ATOM_MP4A) {
-                       t->type = TRACK_AUDIO;
+               t->is_audio = atom_type == ATOM_MP4A;
+               if (t->is_audio)
                        read_mp4a(f);
-               } else if (atom_type == ATOM_MP4V) {
-                       t->type = TRACK_VIDEO;
-               } else if (atom_type == ATOM_MP4S) {
-                       t->type = TRACK_SYSTEM;
-               } else {
-                       t->type = TRACK_UNKNOWN;
-               }
                set_position(f, skip);
        }
 
@@ -1339,7 +1324,7 @@ uint64_t mp4_get_duration(const struct mp4 *f, int32_t track)
  */
 bool mp4_is_audio_track(const struct mp4 *f, int32_t track)
 {
-       return f->track[track]->type == TRACK_AUDIO;
+       return f->track[track]->is_audio;
 }
 
 void mp4_set_sample_position(struct mp4 *f, int32_t track, int32_t sample)