本文整理汇总了Java中com.coremedia.iso.boxes.TimeToSampleBox类的典型用法代码示例。如果您正苦于以下问题:Java TimeToSampleBox类的具体用法?Java TimeToSampleBox怎么用?Java TimeToSampleBox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TimeToSampleBox类属于com.coremedia.iso.boxes包,在下文中一共展示了TimeToSampleBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createStts
import com.coremedia.iso.boxes.TimeToSampleBox; //导入依赖的package包/类
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);
}
示例2: correctTimeToNextSyncSample
import com.coremedia.iso.boxes.TimeToSampleBox; //导入依赖的package包/类
private double correctTimeToNextSyncSample(Track track, double cutHere) {
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++;
}
}
for (double timeOfSyncSample : timeOfSyncSamples) {
if (timeOfSyncSample > cutHere) {
return timeOfSyncSample;
}
}
return timeOfSyncSamples[timeOfSyncSamples.length - 1];
}
示例3: calculateFragmentDurations
import com.coremedia.iso.boxes.TimeToSampleBox; //导入依赖的package包/类
/**
* Calculates the length of each fragment in the given <code>track</code> (as part of <code>movie</code>).
*
* @param track target of calculation
* @param movie the <code>track</code> must be part of this <code>movie</code>
* @return the duration of each fragment in track timescale
*/
public long[] calculateFragmentDurations(Track track, Movie movie) {
long[] startSamples = intersectionFinder.sampleNumbers(track, movie);
long[] durations = new long[startSamples.length];
int currentFragment = 0;
int currentSample = 1; // sync samples start with 1 !
for (TimeToSampleBox.Entry entry : track.getDecodingTimeEntries()) {
for (int max = currentSample + l2i(entry.getCount()); currentSample < max; currentSample++) {
// in this loop we go through the entry.getCount() samples starting from current sample.
// the next entry.getCount() samples have the same decoding time.
if (currentFragment != startSamples.length - 1 && currentSample == startSamples[currentFragment + 1]) {
// we are not in the last fragment && the current sample is the start sample of the next fragment
currentFragment++;
}
durations[currentFragment] += entry.getDelta();
}
}
return durations;
}
示例4: getDecodingTimeEntries
import com.coremedia.iso.boxes.TimeToSampleBox; //导入依赖的package包/类
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;
}
示例5: SilenceTrackImpl
import com.coremedia.iso.boxes.TimeToSampleBox; //导入依赖的package包/类
public SilenceTrackImpl(Track ofType, long ms) {
source = ofType;
if ("mp4a".equals(ofType.getSampleDescriptionBox().getSampleEntry().getType())) {
long numFrames = getTrackMetaData().getTimescale() * ms / 1000 / 1024;
long standZeit = getTrackMetaData().getTimescale() * ms / numFrames / 1000;
entry = new TimeToSampleBox.Entry(numFrames, standZeit);
while (numFrames-- > 0) {
samples.add((ByteBuffer) ByteBuffer.wrap(new byte[]{
0x21, 0x10, 0x04, 0x60, (byte) 0x8c, 0x1c,
}).rewind());
}
} else {
throw new RuntimeException("Tracks of type " + ofType.getClass().getSimpleName() + " are not supported");
}
}
示例6: readSamples
import com.coremedia.iso.boxes.TimeToSampleBox; //导入依赖的package包/类
private boolean readSamples() throws IOException {
if (readSamples) {
return true;
}
readSamples = true;
byte[] header = new byte[5];
boolean ret = false;
inputStream.mark(5);
while (-1 != inputStream.read(header)) {
ret = true;
int frmsizecode = header[4] & 63;
calcBitrateAndFrameSize(frmsizecode);
inputStream.reset();
byte[] data = new byte[frameSize];
inputStream.read(data);
samples.add(ByteBuffer.wrap(data));
stts.add(new TimeToSampleBox.Entry(1, 1536));
inputStream.mark(5);
}
return ret;
}
示例7: getTimes
import com.coremedia.iso.boxes.TimeToSampleBox; //导入依赖的package包/类
private static long[] getTimes(Track track, long[] syncSamples, long targetTimeScale) {
long[] syncSampleTimes = new long[syncSamples.length];
Queue<TimeToSampleBox.Entry> timeQueue = new LinkedList<TimeToSampleBox.Entry>(track.getDecodingTimeEntries());
int currentSample = 1; // first syncsample is 1
long currentDuration = 0;
long currentDelta = 0;
int currentSyncSampleIndex = 0;
long left = 0;
while (currentSample <= syncSamples[syncSamples.length - 1]) {
if (currentSample++ == syncSamples[currentSyncSampleIndex]) {
syncSampleTimes[currentSyncSampleIndex++] = (currentDuration * targetTimeScale) / track.getTrackMetaData().getTimescale();
}
if (left-- == 0) {
TimeToSampleBox.Entry entry = timeQueue.poll();
left = entry.getCount() - 1;
currentDelta = entry.getDelta();
}
currentDuration += currentDelta;
}
return syncSampleTimes;
}
示例8: adjustTts
import com.coremedia.iso.boxes.TimeToSampleBox; //导入依赖的package包/类
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;
}
示例9: createStts
import com.coremedia.iso.boxes.TimeToSampleBox; //导入依赖的package包/类
private 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);
}
示例10: createStts
import com.coremedia.iso.boxes.TimeToSampleBox; //导入依赖的package包/类
protected void createStts(Track track, SampleTableBox stbl) {
TimeToSampleBox.Entry lastEntry = null;
List<TimeToSampleBox.Entry> entries = new ArrayList<>();
long[] deltas = track.getSampleDurations();
for (int a = 0; a < deltas.length; a++) {
long delta = deltas[a];
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);
}
示例11: getDuration
import com.coremedia.iso.boxes.TimeToSampleBox; //导入依赖的package包/类
protected static long getDuration(Track track) {
long duration = 0;
for (TimeToSampleBox.Entry entry : track.getDecodingTimeEntries()) {
duration += entry.getCount() * entry.getDelta();
}
return duration;
}
示例12: getTimes
import com.coremedia.iso.boxes.TimeToSampleBox; //导入依赖的package包/类
private static long[] getTimes(Track track, Movie m) {
final CacheTuple key = new CacheTuple(track, m);
final long[] result = getTimesCache.get(key);
if (result != null) {
return result;
}
long[] syncSamples = track.getSyncSamples();
long[] syncSampleTimes = new long[syncSamples.length];
Queue<TimeToSampleBox.Entry> timeQueue = new LinkedList<TimeToSampleBox.Entry>(track.getDecodingTimeEntries());
int currentSample = 1; // first syncsample is 1
long currentDuration = 0;
long currentDelta = 0;
int currentSyncSampleIndex = 0;
long left = 0;
final long scalingFactor = calculateTracktimesScalingFactor(m, track);
while (currentSample <= syncSamples[syncSamples.length - 1]) {
if (currentSample++ == syncSamples[currentSyncSampleIndex]) {
syncSampleTimes[currentSyncSampleIndex++] = currentDuration * scalingFactor;
}
if (left-- == 0) {
TimeToSampleBox.Entry entry = timeQueue.poll();
left = entry.getCount() - 1;
currentDelta = entry.getDelta();
}
currentDuration += currentDelta;
}
getTimesCache.put(key, syncSampleTimes);
return syncSampleTimes;
}
示例13: getDuration
import com.coremedia.iso.boxes.TimeToSampleBox; //导入依赖的package包/类
protected long getDuration(Track track) {
long duration = 0;
for (TimeToSampleBox.Entry entry : track.getDecodingTimeEntries()) {
duration += entry.getCount() * entry.getDelta();
}
return duration;
}
示例14: adjustTts
import com.coremedia.iso.boxes.TimeToSampleBox; //导入依赖的package包/类
static List<TimeToSampleBox.Entry> adjustTts(List<TimeToSampleBox.Entry> source, int timeScaleFactor) {
LinkedList<TimeToSampleBox.Entry> entries2 = new LinkedList<TimeToSampleBox.Entry>();
for (TimeToSampleBox.Entry e : source) {
entries2.add(new TimeToSampleBox.Entry(e.getCount(), timeScaleFactor * e.getDelta()));
}
return entries2;
}
示例15: readSamples
import com.coremedia.iso.boxes.TimeToSampleBox; //导入依赖的package包/类
private boolean readSamples() throws IOException {
int read = frameSize;
boolean ret = false;
while (frameSize == read) {
ret = true;
byte[] data = new byte[frameSize];
read = inputStream.read(data);
if (read == frameSize) {
samples.add(ByteBuffer.wrap(data));
stts.add(new TimeToSampleBox.Entry(1, 1536));
}
}
return ret;
}