]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
mp4: Simplify mp4_num_samples().
authorAndre Noll <maan@tuebingen.mpg.de>
Sat, 28 Aug 2021 18:29:06 +0000 (20:29 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Mon, 27 Jun 2022 14:45:56 +0000 (16:45 +0200)
We don't need to iterate over the entries of the stts_sample_count
array because the number stored in the stsz_sample_count field should
be identical to the sum of the sample counts.

mp4.c

diff --git a/mp4.c b/mp4.c
index 9e33eb4c298e49ad5fd2f8ed40824200966e1d03..381c9a21d8d24a709d7b474f90ad5e97bb87374d 100644 (file)
--- a/mp4.c
+++ b/mp4.c
@@ -722,12 +722,7 @@ uint16_t mp4_get_channel_count(const struct mp4 *f)
 
 uint32_t mp4_num_samples(const struct mp4 *f)
 {
-       const struct mp4_track *t = &f->track;
-       uint32_t total = 0;
-
-       for (uint32_t n = 0; n < t->stts_entry_count; n++)
-               total += t->stts_sample_count[n];
-       return total;
+       return f->track.stsz_sample_count;
 }
 
 int mp4_open_meta(const struct mp4_callback *cb, struct mp4 **result)