Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public double correctTimeToSyncSample(Track track, double cutHere, boolean next) {
- double[] timeOfSyncSamples = new double[track.getSyncSamples().length];
- long currentSample = 0;
- double currentTime = 0;
- for (int i = 0; i < track.getDecodingTimeEntries().size(); i++) {
- TimeToSampleBox.Entry entry = track.getDecodingTimeEntries().get(i);
- for (int j = 0; j < entry.getCount(); j++) {
- if (Arrays.binarySearch(track.getSyncSamples(),
- currentSample + 1) >= 0) {
- // samples always start with 1 but we start with zero
- // therefore +1
- timeOfSyncSamples[Arrays.binarySearch(
- track.getSyncSamples(), currentSample + 1)] = currentTime;
- }
- currentTime += (double) entry.getDelta()
- / (double) track.getTrackMetaData().getTimescale();
- currentSample++;
- }
- }
- double previous = 0;
- for (double timeOfSyncSample : timeOfSyncSamples) {
- if (timeOfSyncSample > cutHere) {
- if (next) {
- return timeOfSyncSample;
- } else {
- return previous;
- }
- }
- previous = timeOfSyncSample;
- }
- return timeOfSyncSamples[timeOfSyncSamples.length - 1];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement