當前位置: 首頁>>代碼示例>>Java>>正文


Java Util.binarySearchFloor方法代碼示例

本文整理匯總了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;
}
 
開發者ID:sanjaysingh1990,項目名稱:Exoplayer2Radio,代碼行數:19,代碼來源:XingSeeker.java

示例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;
}
 
開發者ID:sanjaysingh1990,項目名稱:Exoplayer2Radio,代碼行數:8,代碼來源:FlacReader.java

示例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;
}
 
開發者ID:sanjaysingh1990,項目名稱:Exoplayer2Radio,代碼行數:19,代碼來源:TrackSampleTable.java

示例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]);
  }
}
 
開發者ID:sanjaysingh1990,項目名稱:Exoplayer2Radio,代碼行數:11,代碼來源:SubripSubtitle.java

示例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];
}
 
開發者ID:sanjaysingh1990,項目名稱:Exoplayer2Radio,代碼行數:7,代碼來源:FlacReader.java

示例6: getPosition

import com.google.android.exoplayer2.util.Util; //導入方法依賴的package包/類
@Override
public long getPosition(long timeUs) {
  return positions[Util.binarySearchFloor(timesUs, timeUs, true, true)];
}
 
開發者ID:sanjaysingh1990,項目名稱:Exoplayer2Radio,代碼行數:5,代碼來源:VbriSeeker.java

示例7: getTimeUs

import com.google.android.exoplayer2.util.Util; //導入方法依賴的package包/類
@Override
public long getTimeUs(long position) {
  return timesUs[Util.binarySearchFloor(positions, position, true, true)];
}
 
開發者ID:sanjaysingh1990,項目名稱:Exoplayer2Radio,代碼行數:5,代碼來源:VbriSeeker.java

示例8: getSourceIndexForPeriod

import com.google.android.exoplayer2.util.Util; //導入方法依賴的package包/類
private int getSourceIndexForPeriod(int periodIndex) {
  return Util.binarySearchFloor(sourcePeriodOffsets, periodIndex, true, false) + 1;
}
 
開發者ID:sanjaysingh1990,項目名稱:Exoplayer2Radio,代碼行數:4,代碼來源:ConcatenatingMediaSource.java

示例9: getSourceIndexForWindow

import com.google.android.exoplayer2.util.Util; //導入方法依賴的package包/類
private int getSourceIndexForWindow(int windowIndex) {
  return Util.binarySearchFloor(sourceWindowOffsets, windowIndex, true, false) + 1;
}
 
開發者ID:sanjaysingh1990,項目名稱:Exoplayer2Radio,代碼行數:4,代碼來源:ConcatenatingMediaSource.java

示例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);
}
 
開發者ID:sanjaysingh1990,項目名稱:Exoplayer2Radio,代碼行數:10,代碼來源:ChunkIndex.java


注:本文中的com.google.android.exoplayer2.util.Util.binarySearchFloor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。