From: Andre Noll Date: Wed, 11 Aug 2021 17:36:59 +0000 (+0200) Subject: mp4: Don't store track type anymore. X-Git-Tag: v0.7.1~7^2~100 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=87e0ea6a858f3727d0f6c8a0ace440146bb68afe;p=paraslash.git 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. --- 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)