Java Code Examples for android.media.MediaCodecInfo.CodecProfileLevel

The following examples show how to use android.media.MediaCodecInfo.CodecProfileLevel. These examples are extracted from open source projects. 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 Project: MediaSDK   Source File: IjkMediaCodecInfo.java    License: 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 Project: MediaSDK   Source File: MediaCodecUtil.java    License: 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 3
Source Project: FimiX8-RE   Source File: FimiMediaCodecInfo.java    License: 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 4
/**
 * 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 5
/**
 * 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 6
Source Project: JZVideoDemo   Source File: IjkMediaCodecInfo.java    License: 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 7
/**
 * 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 8
/**
 * 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 9
Source Project: DanDanPlayForAndroid   Source File: IjkMediaCodecInfo.java    License: 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 10
Source Project: AndroidTvDemo   Source File: IjkMediaCodecInfo.java    License: 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 11
Source Project: ShareBox   Source File: IjkMediaCodecInfo.java    License: 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 12
Source Project: MKVideoPlayer   Source File: IjkMediaCodecInfo.java    License: 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 Project: TvPlayer   Source File: IjkMediaCodecInfo.java    License: 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 14
Source Project: talk-android   Source File: IjkMediaCodecInfo.java    License: 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 15
Source Project: Telegram   Source File: MediaCodecUtil.java    License: 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 16
Source Project: LivePlayback   Source File: IjkMediaCodecInfo.java    License: 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 17
Source Project: K-Sonic   Source File: MediaCodecUtil.java    License: 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 18
Source Project: K-Sonic   Source File: MediaCodecUtil.java    License: 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 19
Source Project: IjkPlayerDemo   Source File: IjkMediaCodecInfo.java    License: 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 20
Source Project: WliveTV   Source File: IjkMediaCodecInfo.java    License: 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 Project: 365browser   Source File: MediaCodecUtil.java    License: 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 22
Source Project: Exoplayer_VLC   Source File: CodecSpecificDataUtil.java    License: 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 23
Source Project: Exoplayer_VLC   Source File: MediaCodecUtil.java    License: 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 24
Source Project: GiraffePlayer   Source File: IjkMediaCodecInfo.java    License: 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 25
Source Project: Telegram-FOSS   Source File: MediaCodecUtil.java    License: 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 26
Source Project: MediaSDK   Source File: IjkMediaCodecInfo.java    License: 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 27
Source Project: MediaSDK   Source File: IjkMediaCodecInfo.java    License: 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 Project: MediaSDK   Source File: MediaCodecInfo.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Whether the decoder supports the codec of the given {@code format}. If there is insufficient
 * information to decide, returns true.
 *
 * @param format The input media format.
 * @return True if the codec of the given {@code format} is supported by the decoder.
 */
public boolean isCodecSupported(Format format) {
  if (format.codecs == null || mimeType == null) {
    return true;
  }
  String codecMimeType = MimeTypes.getMediaMimeType(format.codecs);
  if (codecMimeType == null) {
    return true;
  }
  if (!mimeType.equals(codecMimeType)) {
    logNoSupport("codec.mime " + format.codecs + ", " + codecMimeType);
    return false;
  }
  Pair<Integer, Integer> codecProfileAndLevel = MediaCodecUtil.getCodecProfileAndLevel(format);
  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, " + format.codecs + ", " + codecMimeType);
  return false;
}
 
Example 29
Source Project: MediaSDK   Source File: MediaCodecInfo.java    License: Apache License 2.0 5 votes vote down vote up
/** Whether the codec handles HDR10+ out-of-band metadata. */
public boolean isHdr10PlusOutOfBandMetadataSupported() {
  if (Util.SDK_INT >= 29 && MimeTypes.VIDEO_VP9.equals(mimeType)) {
    for (CodecProfileLevel capabilities : getProfileLevels()) {
      if (capabilities.profile == CodecProfileLevel.VP9Profile2HDR10Plus) {
        return true;
      }
    }
  }
  return false;
}
 
Example 30
Source Project: MediaSDK   Source File: MediaCodecInfo.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Returns whether it is possible to adapt the decoder seamlessly from {@code oldFormat} to {@code
 * newFormat}. If {@code newFormat} may not be completely populated, pass {@code false} for {@code
 * isNewFormatComplete}.
 *
 * @param oldFormat The format being decoded.
 * @param newFormat The new format.
 * @param isNewFormatComplete Whether {@code newFormat} is populated with format-specific
 *     metadata.
 * @return Whether it is possible to adapt the decoder seamlessly.
 */
public boolean isSeamlessAdaptationSupported(
    Format oldFormat, Format newFormat, boolean isNewFormatComplete) {
  if (isVideo) {
    return oldFormat.sampleMimeType.equals(newFormat.sampleMimeType)
        && oldFormat.rotationDegrees == newFormat.rotationDegrees
        && (adaptive
            || (oldFormat.width == newFormat.width && oldFormat.height == newFormat.height))
        && ((!isNewFormatComplete && newFormat.colorInfo == null)
            || Util.areEqual(oldFormat.colorInfo, newFormat.colorInfo));
  } else {
    if (!MimeTypes.AUDIO_AAC.equals(mimeType)
        || !oldFormat.sampleMimeType.equals(newFormat.sampleMimeType)
        || oldFormat.channelCount != newFormat.channelCount
        || oldFormat.sampleRate != newFormat.sampleRate) {
      return false;
    }
    // Check the codec profile levels support adaptation.
    Pair<Integer, Integer> oldCodecProfileLevel =
        MediaCodecUtil.getCodecProfileAndLevel(oldFormat);
    Pair<Integer, Integer> newCodecProfileLevel =
        MediaCodecUtil.getCodecProfileAndLevel(newFormat);
    if (oldCodecProfileLevel == null || newCodecProfileLevel == null) {
      return false;
    }
    int oldProfile = oldCodecProfileLevel.first;
    int newProfile = newCodecProfileLevel.first;
    return oldProfile == CodecProfileLevel.AACObjectXHE
        && newProfile == CodecProfileLevel.AACObjectXHE;
  }
}