Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(464)

Unified Diff: media/base/android/java/src/org/chromium/media/MediaCodecUtil.java

Issue 2434053002: Android: tuning Exynos HW H264 encoding performance. (Closed)
Patch Set: address comments Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/base/android/java/src/org/chromium/media/MediaCodecUtil.java
diff --git a/media/base/android/java/src/org/chromium/media/MediaCodecUtil.java b/media/base/android/java/src/org/chromium/media/MediaCodecUtil.java
index e3673d73aa5ed0f86e03d1d93df5fed0ceecedd1..93da01007a8e9ec701e86e17021fc0f1c0a0d4c0 100644
--- a/media/base/android/java/src/org/chromium/media/MediaCodecUtil.java
+++ b/media/base/android/java/src/org/chromium/media/MediaCodecUtil.java
@@ -37,6 +37,7 @@ class MediaCodecUtil {
public static class CodecCreationInfo {
public MediaCodec mediaCodec = null;
public boolean supportsAdaptivePlayback = false;
+ public BitrateAdjustmentTypes bitrateAdjustmentType = BitrateAdjustmentTypes.NO_ADJUSTMENT;
}
@MainDex
@@ -49,6 +50,17 @@ class MediaCodecUtil {
public static final String VIDEO_VP9 = "video/x-vnd.on2.vp9";
}
+ // Type of bitrate adjustment for video encoder.
+ @MainDex
+ public enum BitrateAdjustmentTypes {
+ // No adjustment - video encoder has no known bitrate problem.
+ NO_ADJUSTMENT,
+ // Framerate based bitrate adjustment is required - HW encoder does not use frame
+ // timestamps to calculate frame bitrate budget and instead is relying on initial
+ // fps configuration assuming that all frames are coming at fixed initial frame rate.
+ FRAMERATE_ADJUSTMENT,
+ }
+
/**
* Class to abstract platform version API differences for interacting with
* the MediaCodecList.
@@ -361,19 +373,26 @@ class MediaCodecUtil {
// List of supported HW encoders.
private static enum HWEncoderProperties {
- QcomVp8(MimeTypes.VIDEO_VP8, "OMX.qcom.", Build.VERSION_CODES.KITKAT),
- QcomH264(MimeTypes.VIDEO_H264, "OMX.qcom.", Build.VERSION_CODES.KITKAT),
- ExynosVp8(MimeTypes.VIDEO_VP8, "OMX.Exynos.", Build.VERSION_CODES.M),
- ExynosH264(MimeTypes.VIDEO_H264, "OMX.Exynos.", Build.VERSION_CODES.LOLLIPOP);
+ QcomVp8(MimeTypes.VIDEO_VP8, "OMX.qcom.", Build.VERSION_CODES.KITKAT,
+ BitrateAdjustmentTypes.NO_ADJUSTMENT),
+ QcomH264(MimeTypes.VIDEO_H264, "OMX.qcom.", Build.VERSION_CODES.KITKAT,
+ BitrateAdjustmentTypes.NO_ADJUSTMENT),
+ ExynosVp8(MimeTypes.VIDEO_VP8, "OMX.Exynos.", Build.VERSION_CODES.M,
+ BitrateAdjustmentTypes.NO_ADJUSTMENT),
+ ExynosH264(MimeTypes.VIDEO_H264, "OMX.Exynos.", Build.VERSION_CODES.LOLLIPOP,
+ BitrateAdjustmentTypes.FRAMERATE_ADJUSTMENT);
private final String mMime;
private final String mPrefix;
private final int mMinSDK;
+ private final BitrateAdjustmentTypes mBitrateAdjustmentType;
- private HWEncoderProperties(String mime, String prefix, int minSDK) {
+ private HWEncoderProperties(String mime, String prefix, int minSDK,
+ BitrateAdjustmentTypes bitrateAdjustmentType) {
this.mMime = mime;
this.mPrefix = prefix;
this.mMinSDK = minSDK;
+ this.mBitrateAdjustmentType = bitrateAdjustmentType;
}
public String getMime() {
@@ -387,6 +406,10 @@ class MediaCodecUtil {
public int getMinSDK() {
return mMinSDK;
}
+
+ public BitrateAdjustmentTypes getBitrateAdjustmentType() {
+ return mBitrateAdjustmentType;
+ }
}
// List of devices with poor H.264 encoder quality.
@@ -405,11 +428,15 @@ class MediaCodecUtil {
// if we cannot create the codec.
CodecCreationInfo result = new CodecCreationInfo();
- if (!isEncoderSupportedByDevice(mime)) return result;
+ HWEncoderProperties encoderProperties = findHWEncoder(mime);
+ if (encoderProperties == null) {
+ return result;
+ }
try {
result.mediaCodec = MediaCodec.createEncoderByType(mime);
result.supportsAdaptivePlayback = false;
+ result.bitrateAdjustmentType = encoderProperties.getBitrateAdjustmentType();
} catch (Exception e) {
Log.e(TAG, "Failed to create MediaCodec: %s", mime, e);
}
@@ -439,6 +466,19 @@ class MediaCodecUtil {
}
}
+ if (findHWEncoder(mime) == null) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Find HW encoder with given MIME type.
+ * @param mime MIME type of the media.
+ * @return HWEncoderProperties object.
+ */
+ private static HWEncoderProperties findHWEncoder(String mime) {
MediaCodecListHelper codecListHelper = new MediaCodecListHelper();
int codecCount = codecListHelper.getCodecCount();
for (int i = 0; i < codecCount; ++i) {
@@ -469,12 +509,12 @@ class MediaCodecUtil {
continue;
}
Log.d(TAG, "Found target encoder for mime " + mime + " : " + encoderName);
- return true;
+ return codecProperties;
}
}
}
Log.w(TAG, "HW encoder for " + mime + " is not available on this device.");
- return false;
+ return null;
}
}
« no previous file with comments | « media/base/android/java/src/org/chromium/media/MediaCodecBridge.java ('k') | media/base/android/sdk_media_codec_bridge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698