From b3ac1dc38bb8366ece6cbaf2adf95e964e0295c7 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Wed, 18 Aug 2021 20:36:50 +0200 Subject: [PATCH] mp4: Merge sample_to_offset() into mp4_set_sample_position(). The former is only called by the latter, and both are short. De-obfuscate the code a little by avoiding pointless local variables. --- mp4.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/mp4.c b/mp4.c index 49ab1371..1b387534 100644 --- a/mp4.c +++ b/mp4.c @@ -1062,19 +1062,6 @@ static int32_t sample_range_size(const struct mp4 *f, int32_t track, return total; } -static int32_t sample_to_offset(const struct mp4 *f, int32_t track, - int32_t sample) -{ - int32_t chunk, chunk_sample, chunk_offset1, chunk_offset2; - - chunk_of_sample(f, track, sample, &chunk_sample, &chunk); - - chunk_offset1 = chunk_to_offset(f, track, chunk); - chunk_offset2 = chunk_offset1 + sample_range_size(f, - track, chunk_sample, sample); - return chunk_offset2; -} - /** * Return the number of milliseconds of the given track. * @@ -1114,7 +1101,11 @@ bool mp4_is_audio_track(const struct mp4 *f, int32_t track) void mp4_set_sample_position(struct mp4 *f, int32_t track, int32_t sample) { - int32_t offset = sample_to_offset(f, track, sample); + int32_t offset, chunk, chunk_sample; + + chunk_of_sample(f, track, sample, &chunk_sample, &chunk); + offset = chunk_to_offset(f, track, chunk) + + sample_range_size(f, track, chunk_sample, sample); set_position(f, offset); } -- 2.39.5