{@inheritDoc}
List<TimeToSampleBox.Entry> entries = track.getDecodingTimeEntries();
double trackLength = 0;
for (Track thisTrack : movie.getTracks()) {
double thisTracksLength = getDuration(thisTrack) / thisTrack.getTrackMetaData().getTimescale();
if (trackLength < thisTracksLength) {
trackLength = thisTracksLength;
}
}
int fragmentCount = (int) Math.ceil(trackLength / fragmentLength) - 1;
if (fragmentCount < 1) {
fragmentCount = 1;
}
long fragments[] = new long[fragmentCount];
Arrays.fill(fragments, -1);
fragments[0] = 1;
long time = 0;
int samples = 0;
for (TimeToSampleBox.Entry entry : entries) {
for (int i = 0; i < entry.getCount(); i++) {
int currentFragment = (int) (time / track.getTrackMetaData().getTimescale() / fragmentLength) + 1;
if (currentFragment >= fragments.length) {
break;
}
fragments[currentFragment] = samples++ + 1;
time += entry.getDelta();
}
}
long last = samples + 1;
// fill all -1 ones.
for (int i = fragments.length - 1; i >= 0; i--) {
if (fragments[i] == -1) {
fragments[i] = last;
}
last = fragments[i];
}
return fragments;