From 87e0ea6a858f3727d0f6c8a0ace440146bb68afe Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Wed, 11 Aug 2021 19:36:59 +0200 Subject: [PATCH] mp4: Don't store track type anymore. 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 | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/mp4.c b/mp4.c index 5eef09de..959dbde8 100644 --- 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) -- 2.39.2