android.media.MediaCodecInfo.CodecProfileLevel Java Examples

The following examples show how to use android.media.MediaCodecInfo.CodecProfileLevel. 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: IjkMediaCodecInfo.java    From TvPlayer with Apache License 2.0 6 votes vote down vote up
public static String getProfileName(int profile) {
    switch (profile) {
    case CodecProfileLevel.AVCProfileBaseline:
        return "Baseline";
    case CodecProfileLevel.AVCProfileMain:
        return "Main";
    case CodecProfileLevel.AVCProfileExtended:
        return "Extends";
    case CodecProfileLevel.AVCProfileHigh:
        return "High";
    case CodecProfileLevel.AVCProfileHigh10:
        return "High10";
    case CodecProfileLevel.AVCProfileHigh422:
        return "High422";
    case CodecProfileLevel.AVCProfileHigh444:
        return "High444";
    default:
        return "Unknown";
    }
}
 
Example #2
Source File: MediaCodecUtil.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the maximum frame size supported by the default H264 decoder.
 *
 * @return The maximum frame size for an H264 stream that can be decoded on the device.
 */
public static int maxH264DecodableFrameSize() throws DecoderQueryException {
  if (maxH264DecodableFrameSize == -1) {
    int result = 0;
    MediaCodecInfo decoderInfo =
        getDecoderInfo(MimeTypes.VIDEO_H264, /* secure= */ false, /* tunneling= */ false);
    if (decoderInfo != null) {
      for (CodecProfileLevel profileLevel : decoderInfo.getProfileLevels()) {
        result = Math.max(avcLevelToMaxFrameSize(profileLevel.level), result);
      }
      // We assume support for at least 480p (SDK_INT >= 21) or 360p (SDK_INT < 21), which are
      // the levels mandated by the Android CDD.
      result = Math.max(result, Util.SDK_INT >= 21 ? (720 * 480) : (480 * 360));
    }
    maxH264DecodableFrameSize = result;
  }
  return maxH264DecodableFrameSize;
}
 
Example #3
Source File: MediaCodecUtil.java    From Exoplayer_VLC with Apache License 2.0 6 votes vote down vote up
/**
 * @param profile An AVC profile constant from {@link CodecProfileLevel}.
 * @param level An AVC profile level from {@link CodecProfileLevel}.
 * @return Whether the specified profile is supported at the specified level.
 */
public static boolean isH264ProfileSupported(int profile, int level)
    throws DecoderQueryException {
  Pair<String, CodecCapabilities> info = getMediaCodecInfo(MimeTypes.VIDEO_H264, false);
  if (info == null) {
    return false;
  }

  CodecCapabilities capabilities = info.second;
  for (int i = 0; i < capabilities.profileLevels.length; i++) {
    CodecProfileLevel profileLevel = capabilities.profileLevels[i];
    if (profileLevel.profile == profile && profileLevel.level >= level) {
      return true;
    }
  }

  return false;
}
 
Example #4
Source File: IjkMediaCodecInfo.java    From GiraffePlayer with Apache License 2.0 6 votes vote down vote up
public static String getProfileName(int profile) {
    switch (profile) {
    case CodecProfileLevel.AVCProfileBaseline:
        return "Baseline";
    case CodecProfileLevel.AVCProfileMain:
        return "Main";
    case CodecProfileLevel.AVCProfileExtended:
        return "Extends";
    case CodecProfileLevel.AVCProfileHigh:
        return "High";
    case CodecProfileLevel.AVCProfileHigh10:
        return "High10";
    case CodecProfileLevel.AVCProfileHigh422:
        return "High422";
    case CodecProfileLevel.AVCProfileHigh444:
        return "High444";
    default:
        return "Unknown";
    }
}
 
Example #5
Source File: MediaCodecUtil.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
  * Return an array of supported codecs and profiles.
  */
@CalledByNative
private static Object[] getSupportedCodecProfileLevels() {
    CodecProfileLevelList profileLevels = new CodecProfileLevelList();
    MediaCodecListHelper codecListHelper = new MediaCodecListHelper();
    for (MediaCodecInfo info : codecListHelper) {
        for (String mime : info.getSupportedTypes()) {
            // On versions L and M, VP9 codecCapabilities do not advertise profile level
            // support. In this case, estimate the level from MediaCodecInfo.VideoCapabilities
            // instead. Assume VP9 is not supported before L. For more information, consult
            // https://developer.android.com/reference/android/media/MediaCodecInfo.CodecProfileLevel.html
            CodecCapabilities codecCapabilities = info.getCapabilitiesForType(mime);
            if (mime.endsWith("vp9") && Build.VERSION_CODES.LOLLIPOP <= Build.VERSION.SDK_INT
                    && Build.VERSION.SDK_INT <= Build.VERSION_CODES.M) {
                addVp9CodecProfileLevels(profileLevels, codecCapabilities);
                continue;
            }
            for (CodecProfileLevel profileLevel : codecCapabilities.profileLevels) {
                profileLevels.addCodecProfileLevel(mime, profileLevel);
            }
        }
    }
    return profileLevels.toArray();
}
 
Example #6
Source File: MediaCodecUtil.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the maximum frame size supported by the default H264 decoder.
 *
 * @return The maximum frame size for an H264 stream that can be decoded on the device.
 */
public static int maxH264DecodableFrameSize() throws DecoderQueryException {
  if (maxH264DecodableFrameSize == -1) {
    int result = 0;
    @Nullable
    MediaCodecInfo decoderInfo =
        getDecoderInfo(MimeTypes.VIDEO_H264, /* secure= */ false, /* tunneling= */ false);
    if (decoderInfo != null) {
      for (CodecProfileLevel profileLevel : decoderInfo.getProfileLevels()) {
        result = Math.max(avcLevelToMaxFrameSize(profileLevel.level), result);
      }
      // We assume support for at least 480p (SDK_INT >= 21) or 360p (SDK_INT < 21), which are
      // the levels mandated by the Android CDD.
      result = Math.max(result, Util.SDK_INT >= 21 ? (720 * 480) : (480 * 360));
    }
    maxH264DecodableFrameSize = result;
  }
  return maxH264DecodableFrameSize;
}
 
Example #7
Source File: FimiMediaCodecInfo.java    From FimiX8-RE with MIT License 6 votes vote down vote up
@TargetApi(16)
public void dumpProfileLevels(String mimeType) {
    if (VERSION.SDK_INT >= 16) {
        try {
            CodecCapabilities caps = this.mCodecInfo.getCapabilitiesForType(mimeType);
            int maxProfile = 0;
            int maxLevel = 0;
            if (!(caps == null || caps.profileLevels == null)) {
                for (CodecProfileLevel profileLevel : caps.profileLevels) {
                    if (profileLevel != null) {
                        maxProfile = Math.max(maxProfile, profileLevel.profile);
                        maxLevel = Math.max(maxLevel, profileLevel.level);
                    }
                }
            }
            Log.i(TAG, String.format(Locale.US, "%s", new Object[]{getProfileLevelName(maxProfile, maxLevel)}));
        } catch (Throwable th) {
            Log.i(TAG, "profile-level: exception");
        }
    }
}
 
Example #8
Source File: CodecSpecificDataUtil.java    From Exoplayer_VLC with Apache License 2.0 6 votes vote down vote up
@SuppressLint("InlinedApi")
private static int parseAvcProfile(byte[] data) {
  int profileIdc = data[6] & 0xFF;
  switch (profileIdc) {
    case 0x42:
      return CodecProfileLevel.AVCProfileBaseline;
    case 0x4d:
      return CodecProfileLevel.AVCProfileMain;
    case 0x58:
      return CodecProfileLevel.AVCProfileExtended;
    case 0x64:
      return CodecProfileLevel.AVCProfileHigh;
    case 0x6e:
      return CodecProfileLevel.AVCProfileHigh10;
    case 0x7a:
      return CodecProfileLevel.AVCProfileHigh422;
    case 0xf4:
      return CodecProfileLevel.AVCProfileHigh444;
    default:
      return 0;
  }
}
 
Example #9
Source File: IjkMediaCodecInfo.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
public static String getProfileName(int profile) {
    switch (profile) {
    case CodecProfileLevel.AVCProfileBaseline:
        return "Baseline";
    case CodecProfileLevel.AVCProfileMain:
        return "Main";
    case CodecProfileLevel.AVCProfileExtended:
        return "Extends";
    case CodecProfileLevel.AVCProfileHigh:
        return "High";
    case CodecProfileLevel.AVCProfileHigh10:
        return "High10";
    case CodecProfileLevel.AVCProfileHigh422:
        return "High422";
    case CodecProfileLevel.AVCProfileHigh444:
        return "High444";
    default:
        return "Unknown";
    }
}
 
Example #10
Source File: MediaCodecUtil.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the maximum frame size supported by the default H264 decoder.
 *
 * @return The maximum frame size for an H264 stream that can be decoded on the device.
 */
public static int maxH264DecodableFrameSize() throws DecoderQueryException {
  if (maxH264DecodableFrameSize == -1) {
    int result = 0;
    MediaCodecInfo decoderInfo = getDecoderInfo(MimeTypes.VIDEO_H264, false);
    if (decoderInfo != null) {
      for (CodecProfileLevel profileLevel : decoderInfo.getProfileLevels()) {
        result = Math.max(avcLevelToMaxFrameSize(profileLevel.level), result);
      }
      // We assume support for at least 480p (SDK_INT >= 21) or 360p (SDK_INT < 21), which are
      // the levels mandated by the Android CDD.
      result = Math.max(result, Util.SDK_INT >= 21 ? (720 * 480) : (480 * 360));
    }
    maxH264DecodableFrameSize = result;
  }
  return maxH264DecodableFrameSize;
}
 
Example #11
Source File: MediaCodecUtil.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Conversion values taken from ISO 14496-10 Table A-1.
 *
 * @param avcLevel one of CodecProfileLevel.AVCLevel* constants.
 * @return maximum frame size that can be decoded by a decoder with the specified avc level
 *     (or {@code -1} if the level is not recognized)
 */
private static int avcLevelToMaxFrameSize(int avcLevel) {
  switch (avcLevel) {
    case CodecProfileLevel.AVCLevel1: return 99 * 16 * 16;
    case CodecProfileLevel.AVCLevel1b: return 99 * 16 * 16;
    case CodecProfileLevel.AVCLevel12: return 396 * 16 * 16;
    case CodecProfileLevel.AVCLevel13: return 396 * 16 * 16;
    case CodecProfileLevel.AVCLevel2: return 396 * 16 * 16;
    case CodecProfileLevel.AVCLevel21: return 792 * 16 * 16;
    case CodecProfileLevel.AVCLevel22: return 1620 * 16 * 16;
    case CodecProfileLevel.AVCLevel3: return 1620 * 16 * 16;
    case CodecProfileLevel.AVCLevel31: return 3600 * 16 * 16;
    case CodecProfileLevel.AVCLevel32: return 5120 * 16 * 16;
    case CodecProfileLevel.AVCLevel4: return 8192 * 16 * 16;
    case CodecProfileLevel.AVCLevel41: return 8192 * 16 * 16;
    case CodecProfileLevel.AVCLevel42: return 8704 * 16 * 16;
    case CodecProfileLevel.AVCLevel5: return 22080 * 16 * 16;
    case CodecProfileLevel.AVCLevel51: return 36864 * 16 * 16;
    case CodecProfileLevel.AVCLevel52: return 36864 * 16 * 16;
    default: return -1;
  }
}
 
Example #12
Source File: IjkMediaCodecInfo.java    From JZVideoDemo with MIT License 6 votes vote down vote up
public static String getProfileName(int profile) {
    switch (profile) {
    case CodecProfileLevel.AVCProfileBaseline:
        return "Baseline";
    case CodecProfileLevel.AVCProfileMain:
        return "Main";
    case CodecProfileLevel.AVCProfileExtended:
        return "Extends";
    case CodecProfileLevel.AVCProfileHigh:
        return "High";
    case CodecProfileLevel.AVCProfileHigh10:
        return "High10";
    case CodecProfileLevel.AVCProfileHigh422:
        return "High422";
    case CodecProfileLevel.AVCProfileHigh444:
        return "High444";
    default:
        return "Unknown";
    }
}
 
Example #13
Source File: MediaCodecUtil.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the maximum frame size supported by the default H264 decoder.
 *
 * @return The maximum frame size for an H264 stream that can be decoded on the device.
 */
public static int maxH264DecodableFrameSize() throws DecoderQueryException {
  if (maxH264DecodableFrameSize == -1) {
    int result = 0;
    MediaCodecInfo decoderInfo = getDecoderInfo(MimeTypes.VIDEO_H264, false);
    if (decoderInfo != null) {
      for (CodecProfileLevel profileLevel : decoderInfo.getProfileLevels()) {
        result = Math.max(avcLevelToMaxFrameSize(profileLevel.level), result);
      }
      // We assume support for at least 480p (SDK_INT >= 21) or 360p (SDK_INT < 21), which are
      // the levels mandated by the Android CDD.
      result = Math.max(result, Util.SDK_INT >= 21 ? (720 * 480) : (480 * 360));
    }
    maxH264DecodableFrameSize = result;
  }
  return maxH264DecodableFrameSize;
}
 
Example #14
Source File: MediaCodecUtil.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Conversion values taken from ISO 14496-10 Table A-1.
 *
 * @param avcLevel one of CodecProfileLevel.AVCLevel* constants.
 * @return maximum frame size that can be decoded by a decoder with the specified avc level
 *     (or {@code -1} if the level is not recognized)
 */
private static int avcLevelToMaxFrameSize(int avcLevel) {
  switch (avcLevel) {
    case CodecProfileLevel.AVCLevel1: return 99 * 16 * 16;
    case CodecProfileLevel.AVCLevel1b: return 99 * 16 * 16;
    case CodecProfileLevel.AVCLevel12: return 396 * 16 * 16;
    case CodecProfileLevel.AVCLevel13: return 396 * 16 * 16;
    case CodecProfileLevel.AVCLevel2: return 396 * 16 * 16;
    case CodecProfileLevel.AVCLevel21: return 792 * 16 * 16;
    case CodecProfileLevel.AVCLevel22: return 1620 * 16 * 16;
    case CodecProfileLevel.AVCLevel3: return 1620 * 16 * 16;
    case CodecProfileLevel.AVCLevel31: return 3600 * 16 * 16;
    case CodecProfileLevel.AVCLevel32: return 5120 * 16 * 16;
    case CodecProfileLevel.AVCLevel4: return 8192 * 16 * 16;
    case CodecProfileLevel.AVCLevel41: return 8192 * 16 * 16;
    case CodecProfileLevel.AVCLevel42: return 8704 * 16 * 16;
    case CodecProfileLevel.AVCLevel5: return 22080 * 16 * 16;
    case CodecProfileLevel.AVCLevel51: return 36864 * 16 * 16;
    case CodecProfileLevel.AVCLevel52: return 36864 * 16 * 16;
    default: return -1;
  }
}
 
Example #15
Source File: IjkMediaCodecInfo.java    From WliveTV with Apache License 2.0 6 votes vote down vote up
public static String getProfileName(int profile) {
    switch (profile) {
    case CodecProfileLevel.AVCProfileBaseline:
        return "Baseline";
    case CodecProfileLevel.AVCProfileMain:
        return "Main";
    case CodecProfileLevel.AVCProfileExtended:
        return "Extends";
    case CodecProfileLevel.AVCProfileHigh:
        return "High";
    case CodecProfileLevel.AVCProfileHigh10:
        return "High10";
    case CodecProfileLevel.AVCProfileHigh422:
        return "High422";
    case CodecProfileLevel.AVCProfileHigh444:
        return "High444";
    default:
        return "Unknown";
    }
}
 
Example #16
Source File: IjkMediaCodecInfo.java    From MKVideoPlayer with MIT License 6 votes vote down vote up
public static String getProfileName(int profile) {
    switch (profile) {
    case CodecProfileLevel.AVCProfileBaseline:
        return "Baseline";
    case CodecProfileLevel.AVCProfileMain:
        return "Main";
    case CodecProfileLevel.AVCProfileExtended:
        return "Extends";
    case CodecProfileLevel.AVCProfileHigh:
        return "High";
    case CodecProfileLevel.AVCProfileHigh10:
        return "High10";
    case CodecProfileLevel.AVCProfileHigh422:
        return "High422";
    case CodecProfileLevel.AVCProfileHigh444:
        return "High444";
    default:
        return "Unknown";
    }
}
 
Example #17
Source File: IjkMediaCodecInfo.java    From talk-android with MIT License 6 votes vote down vote up
public static String getProfileName(int profile) {
    switch (profile) {
    case CodecProfileLevel.AVCProfileBaseline:
        return "Baseline";
    case CodecProfileLevel.AVCProfileMain:
        return "Main";
    case CodecProfileLevel.AVCProfileExtended:
        return "Extends";
    case CodecProfileLevel.AVCProfileHigh:
        return "High";
    case CodecProfileLevel.AVCProfileHigh10:
        return "High10";
    case CodecProfileLevel.AVCProfileHigh422:
        return "High422";
    case CodecProfileLevel.AVCProfileHigh444:
        return "High444";
    default:
        return "Unknown";
    }
}
 
Example #18
Source File: IjkMediaCodecInfo.java    From ShareBox with Apache License 2.0 6 votes vote down vote up
public static String getProfileName(int profile) {
    switch (profile) {
    case CodecProfileLevel.AVCProfileBaseline:
        return "Baseline";
    case CodecProfileLevel.AVCProfileMain:
        return "Main";
    case CodecProfileLevel.AVCProfileExtended:
        return "Extends";
    case CodecProfileLevel.AVCProfileHigh:
        return "High";
    case CodecProfileLevel.AVCProfileHigh10:
        return "High10";
    case CodecProfileLevel.AVCProfileHigh422:
        return "High422";
    case CodecProfileLevel.AVCProfileHigh444:
        return "High444";
    default:
        return "Unknown";
    }
}
 
Example #19
Source File: MediaCodecUtil.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the maximum frame size supported by the default H264 decoder.
 *
 * @return The maximum frame size for an H264 stream that can be decoded on the device.
 */
public static int maxH264DecodableFrameSize() throws DecoderQueryException {
  if (maxH264DecodableFrameSize == -1) {
    int result = 0;
    MediaCodecInfo decoderInfo =
        getDecoderInfo(MimeTypes.VIDEO_H264, /* secure= */ false, /* tunneling= */ false);
    if (decoderInfo != null) {
      for (CodecProfileLevel profileLevel : decoderInfo.getProfileLevels()) {
        result = Math.max(avcLevelToMaxFrameSize(profileLevel.level), result);
      }
      // We assume support for at least 480p (SDK_INT >= 21) or 360p (SDK_INT < 21), which are
      // the levels mandated by the Android CDD.
      result = Math.max(result, Util.SDK_INT >= 21 ? (720 * 480) : (480 * 360));
    }
    maxH264DecodableFrameSize = result;
  }
  return maxH264DecodableFrameSize;
}
 
Example #20
Source File: IjkMediaCodecInfo.java    From LivePlayback with Apache License 2.0 6 votes vote down vote up
public static String getProfileName(int profile) {
    switch (profile) {
    case CodecProfileLevel.AVCProfileBaseline:
        return "Baseline";
    case CodecProfileLevel.AVCProfileMain:
        return "Main";
    case CodecProfileLevel.AVCProfileExtended:
        return "Extends";
    case CodecProfileLevel.AVCProfileHigh:
        return "High";
    case CodecProfileLevel.AVCProfileHigh10:
        return "High10";
    case CodecProfileLevel.AVCProfileHigh422:
        return "High422";
    case CodecProfileLevel.AVCProfileHigh444:
        return "High444";
    default:
        return "Unknown";
    }
}
 
Example #21
Source File: IjkMediaCodecInfo.java    From AndroidTvDemo with Apache License 2.0 6 votes vote down vote up
public static String getProfileName(int profile) {
    switch (profile) {
    case CodecProfileLevel.AVCProfileBaseline:
        return "Baseline";
    case CodecProfileLevel.AVCProfileMain:
        return "Main";
    case CodecProfileLevel.AVCProfileExtended:
        return "Extends";
    case CodecProfileLevel.AVCProfileHigh:
        return "High";
    case CodecProfileLevel.AVCProfileHigh10:
        return "High10";
    case CodecProfileLevel.AVCProfileHigh422:
        return "High422";
    case CodecProfileLevel.AVCProfileHigh444:
        return "High444";
    default:
        return "Unknown";
    }
}
 
Example #22
Source File: MediaCodecUtil.java    From K-Sonic with MIT License 6 votes vote down vote up
/**
 * Returns the maximum frame size supported by the default H264 decoder.
 *
 * @return The maximum frame size for an H264 stream that can be decoded on the device.
 */
public static int maxH264DecodableFrameSize() throws DecoderQueryException {
  if (maxH264DecodableFrameSize == -1) {
    int result = 0;
    MediaCodecInfo decoderInfo = getDecoderInfo(MimeTypes.VIDEO_H264, false);
    if (decoderInfo != null) {
      for (CodecProfileLevel profileLevel : decoderInfo.getProfileLevels()) {
        result = Math.max(avcLevelToMaxFrameSize(profileLevel.level), result);
      }
      // We assume support for at least 480p (SDK_INT >= 21) or 360p (SDK_INT < 21), which are
      // the levels mandated by the Android CDD.
      result = Math.max(result, Util.SDK_INT >= 21 ? (720 * 480) : (480 * 360));
    }
    maxH264DecodableFrameSize = result;
  }
  return maxH264DecodableFrameSize;
}
 
Example #23
Source File: MediaCodecUtil.java    From K-Sonic with MIT License 6 votes vote down vote up
/**
 * Conversion values taken from ISO 14496-10 Table A-1.
 *
 * @param avcLevel one of CodecProfileLevel.AVCLevel* constants.
 * @return maximum frame size that can be decoded by a decoder with the specified avc level
 *     (or {@code -1} if the level is not recognized)
 */
private static int avcLevelToMaxFrameSize(int avcLevel) {
  switch (avcLevel) {
    case CodecProfileLevel.AVCLevel1: return 99 * 16 * 16;
    case CodecProfileLevel.AVCLevel1b: return 99 * 16 * 16;
    case CodecProfileLevel.AVCLevel12: return 396 * 16 * 16;
    case CodecProfileLevel.AVCLevel13: return 396 * 16 * 16;
    case CodecProfileLevel.AVCLevel2: return 396 * 16 * 16;
    case CodecProfileLevel.AVCLevel21: return 792 * 16 * 16;
    case CodecProfileLevel.AVCLevel22: return 1620 * 16 * 16;
    case CodecProfileLevel.AVCLevel3: return 1620 * 16 * 16;
    case CodecProfileLevel.AVCLevel31: return 3600 * 16 * 16;
    case CodecProfileLevel.AVCLevel32: return 5120 * 16 * 16;
    case CodecProfileLevel.AVCLevel4: return 8192 * 16 * 16;
    case CodecProfileLevel.AVCLevel41: return 8192 * 16 * 16;
    case CodecProfileLevel.AVCLevel42: return 8704 * 16 * 16;
    case CodecProfileLevel.AVCLevel5: return 22080 * 16 * 16;
    case CodecProfileLevel.AVCLevel51: return 36864 * 16 * 16;
    default: return -1;
  }
}
 
Example #24
Source File: IjkMediaCodecInfo.java    From DanDanPlayForAndroid with MIT License 6 votes vote down vote up
public static String getProfileName(int profile) {
    switch (profile) {
    case CodecProfileLevel.AVCProfileBaseline:
        return "Baseline";
    case CodecProfileLevel.AVCProfileMain:
        return "Main";
    case CodecProfileLevel.AVCProfileExtended:
        return "Extends";
    case CodecProfileLevel.AVCProfileHigh:
        return "High";
    case CodecProfileLevel.AVCProfileHigh10:
        return "High10";
    case CodecProfileLevel.AVCProfileHigh422:
        return "High422";
    case CodecProfileLevel.AVCProfileHigh444:
        return "High444";
    default:
        return "Unknown";
    }
}
 
Example #25
Source File: IjkMediaCodecInfo.java    From IjkPlayerDemo with Apache License 2.0 6 votes vote down vote up
public static String getProfileName(int profile) {
    switch (profile) {
    case CodecProfileLevel.AVCProfileBaseline:
        return "Baseline";
    case CodecProfileLevel.AVCProfileMain:
        return "Main";
    case CodecProfileLevel.AVCProfileExtended:
        return "Extends";
    case CodecProfileLevel.AVCProfileHigh:
        return "High";
    case CodecProfileLevel.AVCProfileHigh10:
        return "High10";
    case CodecProfileLevel.AVCProfileHigh422:
        return "High422";
    case CodecProfileLevel.AVCProfileHigh444:
        return "High444";
    default:
        return "Unknown";
    }
}
 
Example #26
Source File: MediaCodecUtil.java    From K-Sonic with MIT License 5 votes vote down vote up
private static Pair<Integer, Integer> getHevcProfileAndLevel(String codec, String[] parts) {
  if (parts.length < 4) {
    // The codec has fewer parts than required by the HEVC codec string format.
    Log.w(TAG, "Ignoring malformed HEVC codec string: " + codec);
    return null;
  }
  // The profile_space gets ignored.
  Matcher matcher = PROFILE_PATTERN.matcher(parts[1]);
  if (!matcher.matches()) {
    Log.w(TAG, "Ignoring malformed HEVC codec string: " + codec);
    return null;
  }
  String profileString = matcher.group(1);
  int profile;
  if ("1".equals(profileString)) {
    profile = CodecProfileLevel.HEVCProfileMain;
  } else if ("2".equals(profileString)) {
    profile = CodecProfileLevel.HEVCProfileMain10;
  } else {
    Log.w(TAG, "Unknown HEVC profile string: " + profileString);
    return null;
  }
  Integer level = HEVC_CODEC_STRING_TO_PROFILE_LEVEL.get(parts[3]);
  if (level == null) {
    Log.w(TAG, "Unknown HEVC level string: " + matcher.group(1));
    return null;
  }
  return new Pair<>(profile, level);
}
 
Example #27
Source File: IjkMediaCodecInfo.java    From GiraffePlayer with Apache License 2.0 5 votes vote down vote up
public static String getLevelName(int level) {
    switch (level) {
    case CodecProfileLevel.AVCLevel1:
        return "1";
    case CodecProfileLevel.AVCLevel1b:
        return "1b";
    case CodecProfileLevel.AVCLevel11:
        return "11";
    case CodecProfileLevel.AVCLevel12:
        return "12";
    case CodecProfileLevel.AVCLevel13:
        return "13";
    case CodecProfileLevel.AVCLevel2:
        return "2";
    case CodecProfileLevel.AVCLevel21:
        return "21";
    case CodecProfileLevel.AVCLevel22:
        return "22";
    case CodecProfileLevel.AVCLevel3:
        return "3";
    case CodecProfileLevel.AVCLevel31:
        return "31";
    case CodecProfileLevel.AVCLevel32:
        return "32";
    case CodecProfileLevel.AVCLevel4:
        return "4";
    case CodecProfileLevel.AVCLevel41:
        return "41";
    case CodecProfileLevel.AVCLevel42:
        return "42";
    case CodecProfileLevel.AVCLevel5:
        return "5";
    case CodecProfileLevel.AVCLevel51:
        return "51";
    case 65536: // CodecProfileLevel.AVCLevel52:
        return "52";
    default:
        return "0";
    }
}
 
Example #28
Source File: MediaCodecInfo.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Whether the decoder supports the given {@code codec}. If there is insufficient information to
 * decide, returns true.
 *
 * @param codec Codec string as defined in RFC 6381.
 * @return True if the given codec is supported by the decoder.
 */
public boolean isCodecSupported(String codec) {
  if (codec == null || mimeType == null) {
    return true;
  }
  String codecMimeType = MimeTypes.getMediaMimeType(codec);
  if (codecMimeType == null) {
    return true;
  }
  if (!mimeType.equals(codecMimeType)) {
    logNoSupport("codec.mime " + codec + ", " + codecMimeType);
    return false;
  }
  Pair<Integer, Integer> codecProfileAndLevel = MediaCodecUtil.getCodecProfileAndLevel(codec);
  if (codecProfileAndLevel == null) {
    // If we don't know any better, we assume that the profile and level are supported.
    return true;
  }
  int profile = codecProfileAndLevel.first;
  int level = codecProfileAndLevel.second;
  if (!isVideo && profile != CodecProfileLevel.AACObjectXHE) {
    // Some devices/builds underreport audio capabilities, so assume support except for xHE-AAC
    // which may not be widely supported. See https://github.com/google/ExoPlayer/issues/5145.
    return true;
  }
  for (CodecProfileLevel capabilities : getProfileLevels()) {
    if (capabilities.profile == profile && capabilities.level >= level) {
      return true;
    }
  }
  logNoSupport("codec.profileLevel, " + codec + ", " + codecMimeType);
  return false;
}
 
Example #29
Source File: IjkMediaCodecInfo.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public void dumpProfileLevels(String mimeType) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN)
        return;

    try {
        CodecCapabilities caps = mCodecInfo
                .getCapabilitiesForType(mimeType);
        int maxProfile = 0;
        int maxLevel = 0;
        if (caps != null) {
            if (caps.profileLevels != null) {
                for (CodecProfileLevel profileLevel : caps.profileLevels) {
                    if (profileLevel == null)
                        continue;

                    maxProfile = Math.max(maxProfile, profileLevel.profile);
                    maxLevel = Math.max(maxLevel, profileLevel.level);
                }
            }
        }

        Log.i(TAG,
                String.format(Locale.US, "%s",
                        getProfileLevelName(maxProfile, maxLevel)));
    } catch (Throwable e) {
        Log.i(TAG, "profile-level: exception");
    }
}
 
Example #30
Source File: IjkMediaCodecInfo.java    From TvPlayer with Apache License 2.0 5 votes vote down vote up
public static String getLevelName(int level) {
    switch (level) {
    case CodecProfileLevel.AVCLevel1:
        return "1";
    case CodecProfileLevel.AVCLevel1b:
        return "1b";
    case CodecProfileLevel.AVCLevel11:
        return "11";
    case CodecProfileLevel.AVCLevel12:
        return "12";
    case CodecProfileLevel.AVCLevel13:
        return "13";
    case CodecProfileLevel.AVCLevel2:
        return "2";
    case CodecProfileLevel.AVCLevel21:
        return "21";
    case CodecProfileLevel.AVCLevel22:
        return "22";
    case CodecProfileLevel.AVCLevel3:
        return "3";
    case CodecProfileLevel.AVCLevel31:
        return "31";
    case CodecProfileLevel.AVCLevel32:
        return "32";
    case CodecProfileLevel.AVCLevel4:
        return "4";
    case CodecProfileLevel.AVCLevel41:
        return "41";
    case CodecProfileLevel.AVCLevel42:
        return "42";
    case CodecProfileLevel.AVCLevel5:
        return "5";
    case CodecProfileLevel.AVCLevel51:
        return "51";
    case 65536: // CodecProfileLevel.AVCLevel52:
        return "52";
    default:
        return "0";
    }
}