From c2e987abfcf711c85e00fc11b9ef00d38ad89f3a Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Fri, 27 Aug 2021 19:10:51 +0200 Subject: [PATCH] mp4: Return proper types for sample rate and count. The sample rate and the number of samples are stored as 16-bit/32-bit unsigned integers in the mp4 file, so let mp4_get_sample_rate() and mp4_num_samples() return these types. --- mp4.c | 6 +++--- mp4.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mp4.c b/mp4.c index b12cbbf4..1c33a176 100644 --- a/mp4.c +++ b/mp4.c @@ -710,7 +710,7 @@ int mp4_get_sample_size(const struct mp4 *f, uint32_t sample, uint32_t *result) return 1; } -uint32_t mp4_get_sample_rate(const struct mp4 *f) +uint16_t mp4_get_sample_rate(const struct mp4 *f) { return f->track.sample_rate; } @@ -720,10 +720,10 @@ uint16_t mp4_get_channel_count(const struct mp4 *f) return f->track.channel_count; } -int32_t mp4_num_samples(const struct mp4 *f) +uint32_t mp4_num_samples(const struct mp4 *f) { const struct mp4_track *t = &f->track; - int32_t total = 0; + uint32_t total = 0; for (uint32_t n = 0; n < t->stts_entry_count; n++) total += t->stts_sample_count[n]; diff --git a/mp4.h b/mp4.h index 5a07fadc..00de8d64 100644 --- a/mp4.h +++ b/mp4.h @@ -23,9 +23,9 @@ int mp4_set_sample_position(struct mp4 *f, uint32_t sample); int mp4_open_read(const struct mp4_callback *cb, struct mp4 **result); void mp4_close(struct mp4 *f); int mp4_get_sample_size(const struct mp4 *f, uint32_t sample, uint32_t *result); -uint32_t mp4_get_sample_rate(const struct mp4 *f); +uint16_t mp4_get_sample_rate(const struct mp4 *f); uint16_t mp4_get_channel_count(const struct mp4 *f); -int32_t mp4_num_samples(const struct mp4 *f); +uint32_t mp4_num_samples(const struct mp4 *f); uint64_t mp4_get_duration(const struct mp4 *f); int mp4_open_meta(const struct mp4_callback *cb, struct mp4 **result); struct mp4_metadata *mp4_get_meta(struct mp4 *f); -- 2.39.5