return 0;
}
-static int32_t sample_range_size(const struct mp4 *f, int32_t track,
- int32_t chunk_sample, int32_t sample)
-{
- int32_t i, total;
- const struct mp4_track *t = f->track[track];
-
- if (t->stsz_sample_size)
- return (sample - chunk_sample) * t->stsz_sample_size;
- for (i = chunk_sample, total = 0; i < sample; i++)
- total += t->stsz_table[i];
- return total;
-}
-
/**
* Return the number of milliseconds of the given track.
*
{
const struct mp4_track *t = f->track[track];
int32_t offset, chunk, chunk_sample;
+ uint32_t n, srs; /* sample range size */
if (sample >= t->stsz_sample_count || track >= f->total_tracks)
return -ERRNO_TO_PARA_ERROR(EINVAL);
chunk_of_sample(f, track, sample, &chunk_sample, &chunk);
- offset = chunk_to_offset(f, track, chunk)
- + sample_range_size(f, track, chunk_sample, sample);
+ if (t->stsz_sample_size > 0)
+ srs = (sample - chunk_sample) * t->stsz_sample_size;
+ else {
+ 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);
return 1;
}