public List<TimeToSampleBox.Entry> getDecodingTimeEntries() { LinkedList<TimeToSampleBox.Entry> timesToSample = new LinkedList<TimeToSampleBox.Entry>(); LinkedList<Long> keys = new LinkedList<Long>(rawSamples.keySet()); Collections.sort(keys); long lastTimeStamp = 0; for (Long key : keys) { long delta = key - lastTimeStamp; if (timesToSample.size() > 0 && timesToSample.peek().getDelta() == delta) { timesToSample.peek().setCount(timesToSample.peek().getCount() + 1); } else { timesToSample.add(new TimeToSampleBox.Entry(1, delta)); } lastTimeStamp = key; } return timesToSample; }
public List<TimeToSampleBox.Entry> getDecodingTimeEntries() { LinkedList<TimeToSampleBox.Entry> timesToSample = new LinkedList<TimeToSampleBox.Entry>(); LinkedList<Long> keys = new LinkedList<Long>(rawSamples.keySet()); Collections.sort(keys); long lastTimeStamp = 0; for (Long key : keys) { long delta = key - lastTimeStamp; if (timesToSample.size() > 0 && timesToSample.peek().getDelta() == delta) { timesToSample.peek().setCount(timesToSample.peek().getCount() + 1); } else { timesToSample.add(new TimeToSampleBox.Entry(1, delta)); } lastTimeStamp = key; } return timesToSample; }
public List<TimeToSampleBox.Entry> getDecodingTimeEntries() { if (origTrack.getDecodingTimeEntries() != null && !origTrack.getDecodingTimeEntries().isEmpty()) { // todo optimize! too much long is allocated but then not used long[] decodingTimes = TimeToSampleBox.blowupTimeToSamples(origTrack.getDecodingTimeEntries()); long[] nuDecodingTimes = new long[toSample - fromSample]; System.arraycopy(decodingTimes, fromSample, nuDecodingTimes, 0, toSample - fromSample); LinkedList<TimeToSampleBox.Entry> returnDecodingEntries = new LinkedList<TimeToSampleBox.Entry>(); for (long nuDecodingTime : nuDecodingTimes) { if (returnDecodingEntries.isEmpty() || returnDecodingEntries.getLast().getDelta() != nuDecodingTime) { TimeToSampleBox.Entry e = new TimeToSampleBox.Entry(1, nuDecodingTime); returnDecodingEntries.add(e); } else { TimeToSampleBox.Entry e = returnDecodingEntries.getLast(); e.setCount(e.getCount() + 1); } } return returnDecodingEntries; } else { return null; } }
} else { TimeToSampleBox.Entry e = decodingTimeEntries.get(decodingTimeEntries.size() - 1); e.setCount(e.getCount() + 1);
} else { TimeToSampleBox.Entry e = decodingTimeEntries.get(decodingTimeEntries.size() - 1); e.setCount(e.getCount() + 1);
} else { TimeToSampleBox.Entry e = decodingTimeEntries.get(decodingTimeEntries.size() - 1); e.setCount(e.getCount() + 1);
static List<TimeToSampleBox.Entry> adjustTts(List<TimeToSampleBox.Entry> source, double timeScaleFactor, long[] syncSample, long[] syncSampleTimes) { long[] sourceArray = TimeToSampleBox.blowupTimeToSamples(source); long summedDurations = 0; LinkedList<TimeToSampleBox.Entry> entries2 = new LinkedList<TimeToSampleBox.Entry>(); for (int i = 1; i <= sourceArray.length; i++) { long duration = sourceArray[i - 1]; long x = Math.round(timeScaleFactor * duration); TimeToSampleBox.Entry last = entries2.peekLast(); int ssIndex; if ((ssIndex = Arrays.binarySearch(syncSample, i + 1)) >= 0) { // we are at the sample before sync point if (syncSampleTimes[ssIndex] != summedDurations) { long correction = syncSampleTimes[ssIndex] - (summedDurations + x); LOG.finest(String.format("Sample %d %d / %d - correct by %d", i, summedDurations, syncSampleTimes[ssIndex], correction)); x += correction; } } summedDurations += x; if (last == null) { entries2.add(new TimeToSampleBox.Entry(1, x)); } else if (last.getDelta() != x) { entries2.add(new TimeToSampleBox.Entry(1, x)); } else { last.setCount(last.getCount() + 1); } } return entries2; }
static List<TimeToSampleBox.Entry> adjustTts(List<TimeToSampleBox.Entry> source, double timeScaleFactor, long[] syncSample, long[] syncSampleTimes) { long[] sourceArray = TimeToSampleBox.blowupTimeToSamples(source); long summedDurations = 0; LinkedList<TimeToSampleBox.Entry> entries2 = new LinkedList<TimeToSampleBox.Entry>(); for (int i = 1; i <= sourceArray.length; i++) { long duration = sourceArray[i - 1]; long x = Math.round(timeScaleFactor * duration); TimeToSampleBox.Entry last = entries2.peekLast(); int ssIndex; if ((ssIndex = Arrays.binarySearch(syncSample, i + 1)) >= 0) { // we are at the sample before sync point if (syncSampleTimes[ssIndex] != summedDurations) { long correction = syncSampleTimes[ssIndex] - (summedDurations + x); LOG.finest(String.format("Sample %d %d / %d - correct by %d", i, summedDurations, syncSampleTimes[ssIndex], correction)); x += correction; } } summedDurations += x; if (last == null) { entries2.add(new TimeToSampleBox.Entry(1, x)); } else if (last.getDelta() != x) { entries2.add(new TimeToSampleBox.Entry(1, x)); } else { last.setCount(last.getCount() + 1); } } return entries2; }
public List<TimeToSampleBox.Entry> getDecodingTimeEntries() { if (tracks[0].getDecodingTimeEntries() != null && !tracks[0].getDecodingTimeEntries().isEmpty()) { List<long[]> lists = new LinkedList<long[]>(); for (Track track : tracks) { lists.add(TimeToSampleBox.blowupTimeToSamples(track.getDecodingTimeEntries())); } LinkedList<TimeToSampleBox.Entry> returnDecodingEntries = new LinkedList<TimeToSampleBox.Entry>(); for (long[] list : lists) { for (long nuDecodingTime : list) { if (returnDecodingEntries.isEmpty() || returnDecodingEntries.getLast().getDelta() != nuDecodingTime) { TimeToSampleBox.Entry e = new TimeToSampleBox.Entry(1, nuDecodingTime); returnDecodingEntries.add(e); } else { TimeToSampleBox.Entry e = returnDecodingEntries.getLast(); e.setCount(e.getCount() + 1); } } } return returnDecodingEntries; } else { return null; } }
public List<TimeToSampleBox.Entry> getDecodingTimeEntries() { if (tracks[0].getDecodingTimeEntries() != null && !tracks[0].getDecodingTimeEntries().isEmpty()) { List<long[]> lists = new LinkedList<long[]>(); for (Track track : tracks) { lists.add(TimeToSampleBox.blowupTimeToSamples(track.getDecodingTimeEntries())); } LinkedList<TimeToSampleBox.Entry> returnDecodingEntries = new LinkedList<TimeToSampleBox.Entry>(); for (long[] list : lists) { for (long nuDecodingTime : list) { if (returnDecodingEntries.isEmpty() || returnDecodingEntries.getLast().getDelta() != nuDecodingTime) { TimeToSampleBox.Entry e = new TimeToSampleBox.Entry(1, nuDecodingTime); returnDecodingEntries.add(e); } else { TimeToSampleBox.Entry e = returnDecodingEntries.getLast(); e.setCount(e.getCount() + 1); } } } return returnDecodingEntries; } else { return null; } }
public List<TimeToSampleBox.Entry> getDecodingTimeEntries() { if (origTrack.getDecodingTimeEntries() != null && !origTrack.getDecodingTimeEntries().isEmpty()) { // todo optimize! too much long is allocated but then not used long[] decodingTimes = TimeToSampleBox.blowupTimeToSamples(origTrack.getDecodingTimeEntries()); long[] nuDecodingTimes = new long[toSample - fromSample]; System.arraycopy(decodingTimes, fromSample, nuDecodingTimes, 0, toSample - fromSample); LinkedList<TimeToSampleBox.Entry> returnDecodingEntries = new LinkedList<TimeToSampleBox.Entry>(); for (long nuDecodingTime : nuDecodingTimes) { if (returnDecodingEntries.isEmpty() || returnDecodingEntries.getLast().getDelta() != nuDecodingTime) { TimeToSampleBox.Entry e = new TimeToSampleBox.Entry(1, nuDecodingTime); returnDecodingEntries.add(e); } else { TimeToSampleBox.Entry e = returnDecodingEntries.getLast(); e.setCount(e.getCount() + 1); } } return returnDecodingEntries; } else { return null; } }
protected void createStts(Track track, SampleTableBox stbl) { TimeToSampleBox.Entry lastEntry = null; List<TimeToSampleBox.Entry> entries = new ArrayList<>(); for (long delta : track.getSampleDurations()) { if (lastEntry != null && lastEntry.getDelta() == delta) { lastEntry.setCount(lastEntry.getCount() + 1); } else { lastEntry = new TimeToSampleBox.Entry(1, delta); entries.add(lastEntry); } } TimeToSampleBox stts = new TimeToSampleBox(); stts.setEntries(entries); stbl.addBox(stts); }
protected void createStts(Track track, SampleTableBox stbl) { TimeToSampleBox.Entry lastEntry = null; List<TimeToSampleBox.Entry> entries = new ArrayList<>(); for (long delta : track.getSampleDurations()) { if (lastEntry != null && lastEntry.getDelta() == delta) { lastEntry.setCount(lastEntry.getCount() + 1); } else { lastEntry = new TimeToSampleBox.Entry(1, delta); entries.add(lastEntry); } } TimeToSampleBox stts = new TimeToSampleBox(); stts.setEntries(entries); stbl.addBox(stts); }
protected void createStts(Track track, SampleTableBox stbl) { TimeToSampleBox.Entry lastEntry = null; List<TimeToSampleBox.Entry> entries = new ArrayList<>(); for (long delta : track.getSampleDurations()) { if (lastEntry != null && lastEntry.getDelta() == delta) { lastEntry.setCount(lastEntry.getCount() + 1); } else { lastEntry = new TimeToSampleBox.Entry(1, delta); entries.add(lastEntry); } } TimeToSampleBox stts = new TimeToSampleBox(); stts.setEntries(entries); stbl.addBox(stts); }
protected void createStts(Track track, SampleTableBox stbl) { TimeToSampleBox.Entry lastEntry = null; List<TimeToSampleBox.Entry> entries = new ArrayList<TimeToSampleBox.Entry>(); for (long delta : track.getSampleDurations()) { if (lastEntry != null && lastEntry.getDelta() == delta) { lastEntry.setCount(lastEntry.getCount() + 1); } else { lastEntry = new TimeToSampleBox.Entry(1, delta); entries.add(lastEntry); } } TimeToSampleBox stts = new TimeToSampleBox(); stts.setEntries(entries); stbl.addBox(stts); }