]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - mp4.c
mp4: Merge chunk_to_offset() into mp4_set_sample_position().
[paraslash.git] / mp4.c
diff --git a/mp4.c b/mp4.c
index 9f11a66e52aca8b9e561542be7ba6d65b36d9d0b..1c20d89f27d28b5245095394eee52848fda1c8f0 100644 (file)
--- a/mp4.c
+++ b/mp4.c
@@ -1023,23 +1023,6 @@ static int32_t chunk_of_sample(const struct mp4 *f, int32_t track,
        return 0;
 }
 
-static int32_t chunk_to_offset(const struct mp4 *f, int32_t track,
-               int32_t chunk)
-{
-       const struct mp4_track *p_track = f->track[track];
-
-       if (p_track->stco_entry_count && (chunk > p_track->stco_entry_count)) {
-               return p_track->stco_chunk_offset[p_track->stco_entry_count -
-                                                 1];
-       } else if (p_track->stco_entry_count) {
-               return p_track->stco_chunk_offset[chunk - 1];
-       } else {
-               return 8;
-       }
-
-       return 0;
-}
-
 /**
  * Return the number of milliseconds of the given track.
  *
@@ -1092,8 +1075,13 @@ int mp4_set_sample_position(struct mp4 *f, uint32_t track, int32_t sample)
                for (srs = 0, n = chunk_sample; n < sample; n++)
                        srs += t->stsz_table[n];
        }
-       offset = chunk_to_offset(f, track, chunk) + srs;
-       set_position(f, offset);
+       if (t->stco_entry_count > 0 && chunk > t->stco_entry_count)
+               offset = t->stco_chunk_offset[t->stco_entry_count - 1];
+       else if (t->stco_entry_count > 0)
+               offset = t->stco_chunk_offset[chunk - 1];
+       else
+               offset = 8;
+       set_position(f, offset + srs);
        return 1;
 }