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


Java Util.ceilDivide方法代码示例

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


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

示例1: getMaxVideoSizeInViewport

import com.google.android.exoplayer2.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);
  }
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:22,代码来源:DefaultTrackSelector.java

示例2: alignVideoSizeV21

import com.google.android.exoplayer2.util.Util; //导入方法依赖的package包/类
/**
 * Returns the smallest video size greater than or equal to a specified size that also satisfies
 * the {@link MediaCodec}'s width and height alignment requirements.
 * <p>
 * Must not be called if the device SDK version is less than 21.
 *
 * @param width Width in pixels.
 * @param height Height in pixels.
 * @return The smallest video size greater than or equal to the specified size that also satisfies
 *     the {@link MediaCodec}'s width and height alignment requirements, or null if not a video
 *     codec.
 */
@TargetApi(21)
public Point alignVideoSizeV21(int width, int height) {
  if (capabilities == null) {
    logNoSupport("align.caps");
    return null;
  }
  VideoCapabilities videoCapabilities = capabilities.getVideoCapabilities();
  if (videoCapabilities == null) {
    logNoSupport("align.vCaps");
    return null;
  }
  int widthAlignment = videoCapabilities.getWidthAlignment();
  int heightAlignment = videoCapabilities.getHeightAlignment();
  return new Point(Util.ceilDivide(width, widthAlignment) * widthAlignment,
      Util.ceilDivide(height, heightAlignment) * heightAlignment);
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:29,代码来源:MediaCodecInfo.java

示例3: getCodecMaxSize

import com.google.android.exoplayer2.util.Util; //导入方法依赖的package包/类
/**
 * Returns a maximum video size to use when configuring a codec for {@code format} in a way
 * that will allow possible adaptation to other compatible formats that are expected to have the
 * same aspect ratio, but whose sizes are unknown.
 *
 * @param codecInfo Information about the {@link MediaCodec} being configured.
 * @param format The format for which the codec is being configured.
 * @return The maximum video size to use, or null if the size of {@code format} should be used.
 * @throws DecoderQueryException If an error occurs querying {@code codecInfo}.
 */
private static Point getCodecMaxSize(MediaCodecInfo codecInfo, Format format)
    throws DecoderQueryException {
  boolean isVerticalVideo = format.height > format.width;
  int formatLongEdgePx = isVerticalVideo ? format.height : format.width;
  int formatShortEdgePx = isVerticalVideo ? format.width : format.height;
  float aspectRatio = (float) formatShortEdgePx / formatLongEdgePx;
  for (int longEdgePx : STANDARD_LONG_EDGE_VIDEO_PX) {
    int shortEdgePx = (int) (longEdgePx * aspectRatio);
    if (longEdgePx <= formatLongEdgePx || shortEdgePx <= formatShortEdgePx) {
      // Don't return a size not larger than the format for which the codec is being configured.
      return null;
    } else if (Util.SDK_INT >= 21) {
      Point alignedSize = codecInfo.alignVideoSizeV21(isVerticalVideo ? shortEdgePx : longEdgePx,
          isVerticalVideo ? longEdgePx : shortEdgePx);
      float frameRate = format.frameRate;
      if (codecInfo.isVideoSizeAndRateSupportedV21(alignedSize.x, alignedSize.y, frameRate)) {
        return alignedSize;
      }
    } else {
      // Conservatively assume the codec requires 16px width and height alignment.
      longEdgePx = Util.ceilDivide(longEdgePx, 16) * 16;
      shortEdgePx = Util.ceilDivide(shortEdgePx, 16) * 16;
      if (longEdgePx * shortEdgePx <= MediaCodecUtil.maxH264DecodableFrameSize()) {
        return new Point(isVerticalVideo ? shortEdgePx : longEdgePx,
            isVerticalVideo ? longEdgePx : shortEdgePx);
      }
    }
  }
  return null;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:41,代码来源:MediaCodecVideoRenderer.java

示例4: rechunk

import com.google.android.exoplayer2.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.BUFFER_FLAG_KEY_FRAME;

      sampleOffset += sizes[newSampleIndex];
      originalSampleIndex += bufferSampleCount;

      chunkSamplesRemaining -= bufferSampleCount;
      newSampleIndex++;
    }
  }

  return new Results(offsets, sizes, maximumSize, timestamps, flags);
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:50,代码来源:FixedSampleSizeRechunker.java

示例5: trim

import com.google.android.exoplayer2.util.Util; //导入方法依赖的package包/类
@Override
public synchronized void trim() {
  int targetAllocationCount = Util.ceilDivide(targetBufferSize, 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[highIndex];
        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;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:42,代码来源:DefaultAllocator.java

示例6: getMaxInputSize

import com.google.android.exoplayer2.util.Util; //导入方法依赖的package包/类
/**
 * Returns a maximum input size for a given mime type, width and height.
 *
 * @param sampleMimeType The format mime type.
 * @param width The width in pixels.
 * @param height The height in pixels.
 * @return A maximum input size in bytes, or {@link Format#NO_VALUE} if a maximum could not be
 *     determined.
 */
private static int getMaxInputSize(String sampleMimeType, int width, int height) {
  if (width == Format.NO_VALUE || height == Format.NO_VALUE) {
    // We can't infer a maximum input size without video dimensions.
    return Format.NO_VALUE;
  }

  // Attempt to infer a maximum input size from the format.
  int maxPixels;
  int minCompressionRatio;
  switch (sampleMimeType) {
    case MimeTypes.VIDEO_H263:
    case MimeTypes.VIDEO_MP4V:
      maxPixels = width * height;
      minCompressionRatio = 2;
      break;
    case MimeTypes.VIDEO_H264:
      if ("BRAVIA 4K 2015".equals(Util.MODEL)) {
        // The Sony BRAVIA 4k TV has input buffers that are too small for the calculated 4k video
        // maximum input size, so use the default value.
        return Format.NO_VALUE;
      }
      // Round up width/height to an integer number of macroblocks.
      maxPixels = Util.ceilDivide(width, 16) * Util.ceilDivide(height, 16) * 16 * 16;
      minCompressionRatio = 2;
      break;
    case MimeTypes.VIDEO_VP8:
      // VPX does not specify a ratio so use the values from the platform's SoftVPX.cpp.
      maxPixels = width * height;
      minCompressionRatio = 2;
      break;
    case MimeTypes.VIDEO_H265:
    case MimeTypes.VIDEO_VP9:
      maxPixels = width * height;
      minCompressionRatio = 4;
      break;
    default:
      // Leave the default max input size.
      return Format.NO_VALUE;
  }
  // Estimate the maximum input size assuming three channel 4:2:0 subsampled input frames.
  return (maxPixels * 3) / (2 * minCompressionRatio);
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:52,代码来源:MediaCodecVideoRenderer.java


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