From b8bd7e787bfb3d2877ba87846c39d260287c02f1 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Mon, 23 Aug 2021 20:18:54 +0200 Subject: [PATCH] mp4: Avoid camel case for members of struct mp4_track. Only three members of struct mp4 are in camel case while all others follow the underscore convention, which is the standard coding style of the paraslash code base. Let's be consistent here. Add comments which indicate the origin of the values stored while at it. --- mp4.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/mp4.c b/mp4.c index d73165a3..b2cc8e29 100644 --- a/mp4.c +++ b/mp4.c @@ -14,8 +14,9 @@ #include "mp4.h" struct mp4_track { - uint16_t channelCount; - uint16_t sampleRate; + /* mp4a */ + uint16_t channel_count; + uint16_t sample_rate; /* stsz */ uint32_t stsz_sample_size; @@ -35,7 +36,8 @@ struct mp4_track { uint32_t stco_entry_count; uint32_t *stco_chunk_offset; - uint32_t timeScale; + /* mdhd */ + uint32_t time_scale; uint64_t duration; }; @@ -377,7 +379,7 @@ static int read_mp4a(struct mp4 *f) ret = read_int32(f, NULL); /* reserved */ if (ret <= 0) return ret; - ret = read_int16(f, &t->channelCount); + ret = read_int16(f, &t->channel_count); if (ret <= 0) return ret; ret = read_int16(f, NULL); @@ -389,7 +391,7 @@ static int read_mp4a(struct mp4 *f) ret = read_int16(f, NULL); if (ret <= 0) return ret; - return read_int16(f, &t->sampleRate); + return read_int16(f, &t->sample_rate); } static int read_stsd(struct mp4 *f) @@ -516,7 +518,7 @@ static int read_mdhd(struct mp4 *f) ret = read_int64(f, NULL); /* modification-time */ if (ret <= 0) return ret; - ret = read_int32(f, &t->timeScale); + ret = read_int32(f, &t->time_scale); if (ret <= 0) return ret; ret = read_int64(f, &t->duration); @@ -531,7 +533,7 @@ static int read_mdhd(struct mp4 *f) ret = read_int32(f, NULL); /* modification-time */ if (ret <= 0) return ret; - ret = read_int32(f, &t->timeScale); + ret = read_int32(f, &t->time_scale); if (ret <= 0) return ret; ret = read_int32(f, &temp); @@ -778,9 +780,9 @@ uint64_t mp4_get_duration(const struct mp4 *f) { const struct mp4_track *t = f->audio_track; - if (t->timeScale == 0) + if (t->time_scale == 0) return 0; - return t->duration * 1000 / t->timeScale; + return t->duration * 1000 / t->time_scale; } int mp4_set_sample_position(struct mp4 *f, int32_t sample) @@ -819,12 +821,12 @@ int32_t mp4_get_sample_size(const struct mp4 *f, int sample) uint32_t mp4_get_sample_rate(const struct mp4 *f) { - return f->audio_track->sampleRate; + return f->audio_track->sample_rate; } uint32_t mp4_get_channel_count(const struct mp4 *f) { - return f->audio_track->channelCount ; + return f->audio_track->channel_count; } int32_t mp4_num_samples(const struct mp4 *f) -- 2.39.2