static List<TimeToSampleBox.Entry> getDecodingTimeEntries(List<TimeToSampleBox.Entry> origSamples, long fromSample, long toSample) { if (origSamples != null && !origSamples.isEmpty()) { long current = 0; ListIterator<TimeToSampleBox.Entry> e = origSamples.listIterator(); LinkedList<TimeToSampleBox.Entry> nuList = new LinkedList<TimeToSampleBox.Entry>(); // Skip while not yet reached: TimeToSampleBox.Entry currentEntry; while ((currentEntry = e.next()).getCount() + current <= fromSample) { current += currentEntry.getCount(); } // Take just a bit from the next if (currentEntry.getCount() + current >= toSample) { nuList.add(new TimeToSampleBox.Entry(toSample - fromSample, currentEntry.getDelta())); return nuList; // done in one step } else { nuList.add(new TimeToSampleBox.Entry(currentEntry.getCount() + current - fromSample, currentEntry.getDelta())); } current += currentEntry.getCount(); while (e.hasNext() && (currentEntry = e.next()).getCount() + current < toSample) { nuList.add(currentEntry); current += currentEntry.getCount(); } nuList.add(new TimeToSampleBox.Entry(toSample - current, currentEntry.getDelta())); return nuList; } else { return null; } }
@Override public void _parseDetails(ByteBuffer content) { parseVersionAndFlags(content); int entryCount = CastUtils.l2i(IsoTypeReader.readUInt32(content)); entries = new ArrayList<Entry>(entryCount); for (int i = 0; i < entryCount; i++) { entries.add(new Entry(IsoTypeReader.readUInt32(content), IsoTypeReader.readUInt32(content))); } }
if (stts.getEntries().isEmpty()) { ArrayList<TimeToSampleBox.Entry> entries = new ArrayList<TimeToSampleBox.Entry>(stts.getEntries()); entries.add(new TimeToSampleBox.Entry(1, sample.getDuration())); stts.setEntries(entries); } else { sttsEntry.setCount(sttsEntry.getCount() + 1); } else { stts.getEntries().add(new TimeToSampleBox.Entry(1, sample.getDuration()));
if (decodingTimeEntries.size() == 0 || decodingTimeEntries.get(decodingTimeEntries.size() - 1).getDelta() != entry.getSampleDuration()) { decodingTimeEntries.add(new TimeToSampleBox.Entry(1, entry.getSampleDuration())); } else { TimeToSampleBox.Entry e = decodingTimeEntries.get(decodingTimeEntries.size() - 1); decodingTimeEntries.add(new TimeToSampleBox.Entry(1, tfhd.getDefaultSampleDuration())); } else { decodingTimeEntries.add(new TimeToSampleBox.Entry(1, trex.getDefaultSampleDuration()));
static List<TimeToSampleBox.Entry> getDecodingTimeEntries(List<TimeToSampleBox.Entry> origSamples, long fromSample, long toSample) { if (origSamples != null && !origSamples.isEmpty()) { long current = 0; ListIterator<TimeToSampleBox.Entry> e = origSamples.listIterator(); LinkedList<TimeToSampleBox.Entry> nuList = new LinkedList<TimeToSampleBox.Entry>(); // Skip while not yet reached: TimeToSampleBox.Entry currentEntry; while ((currentEntry = e.next()).getCount() + current <= fromSample) { current += currentEntry.getCount(); } // Take just a bit from the next if (currentEntry.getCount() + current >= toSample) { nuList.add(new TimeToSampleBox.Entry(toSample - fromSample, currentEntry.getDelta())); return nuList; // done in one step } else { nuList.add(new TimeToSampleBox.Entry(currentEntry.getCount() + current - fromSample, currentEntry.getDelta())); } current += currentEntry.getCount(); while (e.hasNext() && (currentEntry = e.next()).getCount() + current < toSample) { nuList.add(currentEntry); current += currentEntry.getCount(); } nuList.add(new TimeToSampleBox.Entry(toSample - current, currentEntry.getDelta())); return nuList; } else { return null; } }
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); }
@Override public void _parseDetails(ByteBuffer content) { parseVersionAndFlags(content); int entryCount = CastUtils.l2i(IsoTypeReader.readUInt32(content)); entries = new ArrayList<Entry>(entryCount); for (int i = 0; i < entryCount; i++) { entries.add(new Entry(IsoTypeReader.readUInt32(content), IsoTypeReader.readUInt32(content))); } }
if (decodingTimeEntries.size() == 0 || decodingTimeEntries.get(decodingTimeEntries.size() - 1).getDelta() != entry.getSampleDuration()) { decodingTimeEntries.add(new TimeToSampleBox.Entry(1, entry.getSampleDuration())); } else { TimeToSampleBox.Entry e = decodingTimeEntries.get(decodingTimeEntries.size() - 1); decodingTimeEntries.add(new TimeToSampleBox.Entry(1, tfhd.getDefaultSampleDuration())); } else { decodingTimeEntries.add(new TimeToSampleBox.Entry(1, trex.getDefaultSampleDuration()));
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); }