]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
mp4: Merge sample_to_offset() into mp4_set_sample_position().
authorAndre Noll <maan@tuebingen.mpg.de>
Wed, 18 Aug 2021 18:36:50 +0000 (20:36 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Mon, 30 May 2022 19:37:35 +0000 (21:37 +0200)
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

diff --git a/mp4.c b/mp4.c
index 49ab1371fbff23dd202555a656dd78c84d7b969b..1b387534d6adcbca4521472d473ebad49c7973cb 100644 (file)
--- 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);
 }