本文整理汇总了Java中com.google.android.exoplayer.util.Util.ceilDivide方法的典型用法代码示例。如果您正苦于以下问题:Java Util.ceilDivide方法的具体用法?Java Util.ceilDivide怎么用?Java Util.ceilDivide使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.exoplayer.util.Util
的用法示例。
在下文中一共展示了Util.ceilDivide方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMaxVideoSizeInViewport
import com.google.android.exoplayer.util.Util; //导入方法依赖的package包/类
/**
* Given viewport dimensions and video dimensions, computes the maximum size of the video as it
* will be rendered to fit inside of the viewport.
*/
private static Point getMaxVideoSizeInViewport(boolean orientationMayChange, int viewportWidth,
int viewportHeight, int videoWidth, int videoHeight) {
if (orientationMayChange && (videoWidth > videoHeight) != (viewportWidth > viewportHeight)) {
// Rotation is allowed, and the video will be larger in the rotated viewport.
int tempViewportWidth = viewportWidth;
viewportWidth = viewportHeight;
viewportHeight = tempViewportWidth;
}
if (videoWidth * viewportHeight >= videoHeight * viewportWidth) {
// Horizontal letter-boxing along top and bottom.
return new Point(viewportWidth, Util.ceilDivide(viewportWidth * videoHeight, videoWidth));
} else {
// Vertical letter-boxing along edges.
return new Point(Util.ceilDivide(viewportHeight * videoWidth, videoHeight), viewportHeight);
}
}
示例2: buildSegmentTimelineRepresentation
import com.google.android.exoplayer.util.Util; //导入方法依赖的package包/类
private static Representation buildSegmentTimelineRepresentation(long timelineDurationMs,
long timelineStartTimeMs) {
List<SegmentTimelineElement> segmentTimeline = new ArrayList<>();
List<RangedUri> mediaSegments = new ArrayList<>();
long segmentStartTimeMs = timelineStartTimeMs;
long byteStart = 0;
// Create all but the last segment with LIVE_SEGMENT_DURATION_MS.
int segmentCount = (int) Util.ceilDivide(timelineDurationMs, LIVE_SEGMENT_DURATION_MS);
for (int i = 0; i < segmentCount - 1; i++) {
segmentTimeline.add(new SegmentTimelineElement(segmentStartTimeMs, LIVE_SEGMENT_DURATION_MS));
mediaSegments.add(new RangedUri("", "", byteStart, 500L));
segmentStartTimeMs += LIVE_SEGMENT_DURATION_MS;
byteStart += 500;
}
// The final segment duration is calculated so that the total duration is timelineDurationMs.
long finalSegmentDurationMs = (timelineStartTimeMs + timelineDurationMs) - segmentStartTimeMs;
segmentTimeline.add(new SegmentTimelineElement(segmentStartTimeMs, finalSegmentDurationMs));
mediaSegments.add(new RangedUri("", "", byteStart, 500L));
segmentStartTimeMs += finalSegmentDurationMs;
byteStart += 500;
// Construct the list.
MultiSegmentBase segmentBase = new SegmentList(null, 1000, 0, 0, 0, segmentTimeline,
mediaSegments);
return Representation.newInstance(null, 0, REGULAR_VIDEO, segmentBase);
}
示例3: getLastSegmentNum
import com.google.android.exoplayer.util.Util; //导入方法依赖的package包/类
@Override
public int getLastSegmentNum() {
if (segmentTimeline != null) {
return segmentTimeline.size() + startNumber - 1;
} else if (periodDurationMs == -1) {
return DashSegmentIndex.INDEX_UNBOUNDED;
} else {
long durationMs = (duration * 1000) / timescale;
return startNumber + (int) Util.ceilDivide(periodDurationMs, durationMs) - 1;
}
}
示例4: getLastSegmentNum
import com.google.android.exoplayer.util.Util; //导入方法依赖的package包/类
@Override
public int getLastSegmentNum(long periodDurationUs) {
if (segmentTimeline != null) {
return segmentTimeline.size() + startNumber - 1;
} else if (periodDurationUs == C.UNKNOWN_TIME_US) {
return DashSegmentIndex.INDEX_UNBOUNDED;
} else {
long durationUs = (duration * C.MICROS_PER_SECOND) / timescale;
return startNumber + (int) Util.ceilDivide(periodDurationUs, durationUs) - 1;
}
}
示例5: trim
import com.google.android.exoplayer.util.Util; //导入方法依赖的package包/类
@Override
public synchronized void trim(int targetSize) {
int targetAllocationCount = Util.ceilDivide(targetSize, individualAllocationSize);
int targetAvailableCount = Math.max(0, targetAllocationCount - allocatedCount);
if (targetAvailableCount >= availableCount) {
// We're already at or below the target.
return;
}
if (initialAllocationBlock != null) {
// Some allocations are backed by an initial block. We need to make sure that we hold onto all
// such allocations. Re-order the available allocations so that the ones backed by the initial
// block come first.
int lowIndex = 0;
int highIndex = availableCount - 1;
while (lowIndex <= highIndex) {
Allocation lowAllocation = availableAllocations[lowIndex];
if (lowAllocation.data == initialAllocationBlock) {
lowIndex++;
} else {
Allocation highAllocation = availableAllocations[lowIndex];
if (highAllocation.data != initialAllocationBlock) {
highIndex--;
} else {
availableAllocations[lowIndex++] = highAllocation;
availableAllocations[highIndex--] = lowAllocation;
}
}
}
// lowIndex is the index of the first allocation not backed by an initial block.
targetAvailableCount = Math.max(targetAvailableCount, lowIndex);
if (targetAvailableCount >= availableCount) {
// We're already at or below the target.
return;
}
}
// Discard allocations beyond the target.
Arrays.fill(availableAllocations, targetAvailableCount, availableCount, null);
availableCount = targetAvailableCount;
}
示例6: rechunk
import com.google.android.exoplayer.util.Util; //导入方法依赖的package包/类
/**
* Rechunk the given fixed sample size input to produce a new sequence of samples.
*
* @param fixedSampleSize Size in bytes of each sample.
* @param chunkOffsets Chunk offsets in the MP4 stream to rechunk.
* @param chunkSampleCounts Sample counts for each of the MP4 stream's chunks.
* @param timestampDeltaInTimeUnits Timestamp delta between each sample in time units.
*/
public static Results rechunk(
int fixedSampleSize,
long[] chunkOffsets,
int[] chunkSampleCounts,
long timestampDeltaInTimeUnits) {
int maxSampleCount = MAX_SAMPLE_SIZE / fixedSampleSize;
// Count the number of new, rechunked buffers.
int rechunkedSampleCount = 0;
for (int chunkSampleCount : chunkSampleCounts) {
rechunkedSampleCount += Util.ceilDivide(chunkSampleCount, maxSampleCount);
}
long[] offsets = new long[rechunkedSampleCount];
int[] sizes = new int[rechunkedSampleCount];
int maximumSize = 0;
long[] timestamps = new long[rechunkedSampleCount];
int[] flags = new int[rechunkedSampleCount];
int originalSampleIndex = 0;
int newSampleIndex = 0;
for (int chunkIndex = 0; chunkIndex < chunkSampleCounts.length; chunkIndex++) {
int chunkSamplesRemaining = chunkSampleCounts[chunkIndex];
long sampleOffset = chunkOffsets[chunkIndex];
while (chunkSamplesRemaining > 0) {
int bufferSampleCount = Math.min(maxSampleCount, chunkSamplesRemaining);
offsets[newSampleIndex] = sampleOffset;
sizes[newSampleIndex] = fixedSampleSize * bufferSampleCount;
maximumSize = Math.max(maximumSize, sizes[newSampleIndex]);
timestamps[newSampleIndex] = (timestampDeltaInTimeUnits * originalSampleIndex);
flags[newSampleIndex] = C.SAMPLE_FLAG_SYNC;
sampleOffset += sizes[newSampleIndex];
originalSampleIndex += bufferSampleCount;
chunkSamplesRemaining -= bufferSampleCount;
newSampleIndex++;
}
}
return new Results(offsets, sizes, maximumSize, timestamps, flags);
}