当前位置: 首页>>代码示例>>Java>>正文


Java Util.binarySearchFloor方法代码示例

本文整理汇总了Java中com.google.android.exoplayer.util.Util.binarySearchFloor方法的典型用法代码示例。如果您正苦于以下问题:Java Util.binarySearchFloor方法的具体用法?Java Util.binarySearchFloor怎么用?Java Util.binarySearchFloor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.android.exoplayer.util.Util的用法示例。


在下文中一共展示了Util.binarySearchFloor方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTimeUs

import com.google.android.exoplayer.util.Util; //导入方法依赖的package包/类
@Override
public long getTimeUs(long position) {
  long offsetByte = 256 * (position - firstFramePosition) / sizeBytes;
  int previousIndex = Util.binarySearchFloor(tableOfContents, offsetByte, true, false);
  long previousTime = getTimeUsForTocIndex(previousIndex);
  if (previousIndex == 98) {
    return previousTime;
  }

  // Linearly interpolate the time taking into account the next entry.
  long previousByte = previousIndex == -1 ? 0 : tableOfContents[previousIndex];
  long nextByte = tableOfContents[previousIndex + 1];
  long nextTime = getTimeUsForTocIndex(previousIndex + 1);
  long timeOffset =
      (nextTime - previousTime) * (offsetByte - previousByte) / (nextByte - previousByte);
  return previousTime + timeOffset;
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:18,代码来源:XingSeeker.java

示例2: getTimeUs

import com.google.android.exoplayer.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:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:19,代码来源:XingSeeker.java

示例3: getIndexOfEarlierOrEqualSynchronizationSample

import com.google.android.exoplayer.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 #NO_SAMPLE} if none.
 */
public int getIndexOfEarlierOrEqualSynchronizationSample(long timeUs) {
  int startIndex = Util.binarySearchFloor(timestampsUs, timeUs, true, false);
  for (int i = startIndex; i >= 0; i--) {
    if (timestampsUs[i] <= timeUs && (flags[i] & C.SAMPLE_FLAG_SYNC) != 0) {
      return i;
    }
  }
  return NO_SAMPLE;
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:17,代码来源:TrackSampleTable.java

示例4: getCues

import com.google.android.exoplayer.util.Util; //导入方法依赖的package包/类
@Override
public List<Cue> getCues(long timeUs) {
  int index = Util.binarySearchFloor(cueTimesUs, timeUs, true, false);
  if (index == -1 || index % 2 == 1) {
    // timeUs is earlier than the start of the first cue, or corresponds to a gap between cues.
    return Collections.<Cue>emptyList();
  } else {
    return Collections.singletonList(cues[index / 2]);
  }
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:11,代码来源:SubripSubtitle.java

示例5: getIndexOfEarlierOrEqualSynchronizationSample

import com.google.android.exoplayer.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 #NO_SAMPLE} 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.SAMPLE_FLAG_SYNC) != 0) {
      return i;
    }
  }
  return NO_SAMPLE;
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:19,代码来源:TrackSampleTable.java

示例6: getCues

import com.google.android.exoplayer.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.<Cue>emptyList();
  } else {
    return Collections.singletonList(cues[index]);
  }
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:11,代码来源:SubripSubtitle.java

示例7: getPosition

import com.google.android.exoplayer.util.Util; //导入方法依赖的package包/类
@Override
public long getPosition(long timeUs) {
  int index = Util.binarySearchFloor(timesUs, timeUs, false, false);
  return basePosition + (index == -1 ? 0L : positions[index]);
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:6,代码来源:VbriSeeker.java

示例8: getTimeUs

import com.google.android.exoplayer.util.Util; //导入方法依赖的package包/类
@Override
public long getTimeUs(long position) {
  return timesUs[Util.binarySearchFloor(positions, position, true, true)];
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:5,代码来源:VbriSeeker.java

示例9: getPosition

import com.google.android.exoplayer.util.Util; //导入方法依赖的package包/类
@Override
public long getPosition(long timeUs) {
  return positions[Util.binarySearchFloor(timesUs, timeUs, true, true)];
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:5,代码来源:VbriSeeker.java

示例10: getChunkIndex

import com.google.android.exoplayer.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:XueyanLiu,项目名称:miku,代码行数:10,代码来源:ChunkIndex.java

示例11: getChunkIndex

import com.google.android.exoplayer.util.Util; //导入方法依赖的package包/类
/**
 * Gets the index of the chunk that contains the specified time.
 *
 * @param timeUs The time in microseconds.
 * @return The index of the corresponding chunk.
 */
public int getChunkIndex(long timeUs) {
  return Util.binarySearchFloor(chunkStartTimesUs, timeUs, true, true);
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:10,代码来源:SmoothStreamingManifest.java


注:本文中的com.google.android.exoplayer.util.Util.binarySearchFloor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。