本文整理匯總了Java中com.google.android.exoplayer2.util.Util.binarySearchFloor方法的典型用法代碼示例。如果您正苦於以下問題:Java Util.binarySearchFloor方法的具體用法?Java Util.binarySearchFloor怎麽用?Java Util.binarySearchFloor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.android.exoplayer2.util.Util
的用法示例。
在下文中一共展示了Util.binarySearchFloor方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getTimeUs
import com.google.android.exoplayer2.util.Util; //導入方法依賴的package包/類
@Override
public long getTimeUs(long position) {
if (!isSeekable() || position < firstFramePosition) {
return 0L;
}
double offsetByte = 256.0 * (position - firstFramePosition) / sizeBytes;
int previousTocPosition =
Util.binarySearchFloor(tableOfContents, (long) offsetByte, true, false) + 1;
long previousTime = getTimeUsForTocPosition(previousTocPosition);
// Linearly interpolate the time taking into account the next entry.
long previousByte = previousTocPosition == 0 ? 0 : tableOfContents[previousTocPosition - 1];
long nextByte = previousTocPosition == 99 ? 256 : tableOfContents[previousTocPosition];
long nextTime = getTimeUsForTocPosition(previousTocPosition + 1);
long timeOffset = nextByte == previousByte ? 0 : (long) ((nextTime - previousTime)
* (offsetByte - previousByte) / (nextByte - previousByte));
return previousTime + timeOffset;
}
示例2: startSeek
import com.google.android.exoplayer2.util.Util; //導入方法依賴的package包/類
@Override
public long startSeek(long timeUs) {
long granule = convertTimeToGranule(timeUs);
int index = Util.binarySearchFloor(seekPointGranules, granule, true, true);
pendingSeekGranule = seekPointGranules[index];
return granule;
}
示例3: getIndexOfEarlierOrEqualSynchronizationSample
import com.google.android.exoplayer2.util.Util; //導入方法依賴的package包/類
/**
* Returns the sample index of the closest synchronization sample at or before the given
* timestamp, if one is available.
*
* @param timeUs Timestamp adjacent to which to find a synchronization sample.
* @return Index of the synchronization sample, or {@link C#INDEX_UNSET} if none.
*/
public int getIndexOfEarlierOrEqualSynchronizationSample(long timeUs) {
// Video frame timestamps may not be sorted, so the behavior of this call can be undefined.
// Frames are not reordered past synchronization samples so this works in practice.
int startIndex = Util.binarySearchFloor(timestampsUs, timeUs, true, false);
for (int i = startIndex; i >= 0; i--) {
if ((flags[i] & C.BUFFER_FLAG_KEY_FRAME) != 0) {
return i;
}
}
return C.INDEX_UNSET;
}
示例4: getCues
import com.google.android.exoplayer2.util.Util; //導入方法依賴的package包/類
@Override
public List<Cue> getCues(long timeUs) {
int index = Util.binarySearchFloor(cueTimesUs, timeUs, true, false);
if (index == -1 || cues[index] == null) {
// timeUs is earlier than the start of the first cue, or we have an empty cue.
return Collections.emptyList();
} else {
return Collections.singletonList(cues[index]);
}
}
示例5: getPosition
import com.google.android.exoplayer2.util.Util; //導入方法依賴的package包/類
@Override
public long getPosition(long timeUs) {
long granule = convertTimeToGranule(timeUs);
int index = Util.binarySearchFloor(seekPointGranules, granule, true, true);
return firstFrameOffset + seekPointOffsets[index];
}
示例6: getPosition
import com.google.android.exoplayer2.util.Util; //導入方法依賴的package包/類
@Override
public long getPosition(long timeUs) {
return positions[Util.binarySearchFloor(timesUs, timeUs, true, true)];
}
示例7: getTimeUs
import com.google.android.exoplayer2.util.Util; //導入方法依賴的package包/類
@Override
public long getTimeUs(long position) {
return timesUs[Util.binarySearchFloor(positions, position, true, true)];
}
示例8: getSourceIndexForPeriod
import com.google.android.exoplayer2.util.Util; //導入方法依賴的package包/類
private int getSourceIndexForPeriod(int periodIndex) {
return Util.binarySearchFloor(sourcePeriodOffsets, periodIndex, true, false) + 1;
}
示例9: getSourceIndexForWindow
import com.google.android.exoplayer2.util.Util; //導入方法依賴的package包/類
private int getSourceIndexForWindow(int windowIndex) {
return Util.binarySearchFloor(sourceWindowOffsets, windowIndex, true, false) + 1;
}
示例10: getChunkIndex
import com.google.android.exoplayer2.util.Util; //導入方法依賴的package包/類
/**
* Obtains the index of the chunk corresponding to a given time.
*
* @param timeUs The time, in microseconds.
* @return The index of the corresponding chunk.
*/
public int getChunkIndex(long timeUs) {
return Util.binarySearchFloor(timesUs, timeUs, true, true);
}