Java Code Examples for com.google.android.exoplayer2.C#COLOR_TRANSFER_ST2084

The following examples show how to use com.google.android.exoplayer2.C#COLOR_TRANSFER_ST2084 . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MediaCodecUtil.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
@Nullable
private static Pair<Integer, Integer> getAv1ProfileAndLevel(
    String codec, String[] parts, @Nullable ColorInfo colorInfo) {
  if (parts.length < 4) {
    Log.w(TAG, "Ignoring malformed AV1 codec string: " + codec);
    return null;
  }
  int profileInteger;
  int levelInteger;
  int bitDepthInteger;
  try {
    profileInteger = Integer.parseInt(parts[1]);
    levelInteger = Integer.parseInt(parts[2].substring(0, 2));
    bitDepthInteger = Integer.parseInt(parts[3]);
  } catch (NumberFormatException e) {
    Log.w(TAG, "Ignoring malformed AV1 codec string: " + codec);
    return null;
  }

  if (profileInteger != 0) {
    Log.w(TAG, "Unknown AV1 profile: " + profileInteger);
    return null;
  }
  if (bitDepthInteger != 8 && bitDepthInteger != 10) {
    Log.w(TAG, "Unknown AV1 bit depth: " + bitDepthInteger);
    return null;
  }
  int profile;
  if (bitDepthInteger == 8) {
    profile = CodecProfileLevel.AV1ProfileMain8;
  } else if (colorInfo != null
      && (colorInfo.hdrStaticInfo != null
          || colorInfo.colorTransfer == C.COLOR_TRANSFER_HLG
          || colorInfo.colorTransfer == C.COLOR_TRANSFER_ST2084)) {
    profile = CodecProfileLevel.AV1ProfileMain10HDR10;
  } else {
    profile = CodecProfileLevel.AV1ProfileMain10;
  }

  int level = AV1_LEVEL_NUMBER_TO_CONST.get(levelInteger, -1);
  if (level == -1) {
    Log.w(TAG, "Unknown AV1 level: " + levelInteger);
    return null;
  }
  return new Pair<>(profile, level);
}