Support VP9 HW video decoding on Android.
Preliminary verification is done for OMX.google.vp9.decoder codec. R=magjed@webrtc.org Review URL: https://codereview.webrtc.org/1416023005 . Cr-Commit-Position: refs/heads/master@{#10586}
This commit is contained in:
parent
ed8275a44f
commit
69a7fd5047
@ -72,6 +72,8 @@ enum { kMediaCodecTimeoutMs = 1000 };
|
||||
enum { kMediaCodecStatisticsIntervalMs = 3000 };
|
||||
// Maximum amount of pending frames for VP8 decoder.
|
||||
enum { kMaxPendingFramesVp8 = 1 };
|
||||
// Maximum amount of pending frames for VP9 decoder.
|
||||
enum { kMaxPendingFramesVp9 = 1 };
|
||||
// Maximum amount of pending frames for H.264 decoder.
|
||||
enum { kMaxPendingFramesH264 = 30 };
|
||||
// Maximum amount of decoded frames for which per-frame logging is enabled.
|
||||
|
||||
@ -62,6 +62,7 @@ using webrtc::VideoCodec;
|
||||
using webrtc::VideoCodecType;
|
||||
using webrtc::kVideoCodecH264;
|
||||
using webrtc::kVideoCodecVP8;
|
||||
using webrtc::kVideoCodecVP9;
|
||||
|
||||
namespace webrtc_jni {
|
||||
|
||||
@ -332,6 +333,9 @@ int32_t MediaCodecVideoDecoder::InitDecodeOnCodecThread() {
|
||||
case kVideoCodecVP8:
|
||||
max_pending_frames_ = kMaxPendingFramesVp8;
|
||||
break;
|
||||
case kVideoCodecVP9:
|
||||
max_pending_frames_ = kMaxPendingFramesVp9;
|
||||
break;
|
||||
case kVideoCodecH264:
|
||||
max_pending_frames_ = kMaxPendingFramesH264;
|
||||
break;
|
||||
@ -790,6 +794,17 @@ MediaCodecVideoDecoderFactory::MediaCodecVideoDecoderFactory() :
|
||||
supported_codec_types_.push_back(kVideoCodecVP8);
|
||||
}
|
||||
|
||||
bool is_vp9_hw_supported = jni->CallStaticBooleanMethod(
|
||||
j_decoder_class,
|
||||
GetStaticMethodID(jni, j_decoder_class, "isVp9HwSupported", "()Z"));
|
||||
if (CheckException(jni)) {
|
||||
is_vp9_hw_supported = false;
|
||||
}
|
||||
if (is_vp9_hw_supported) {
|
||||
ALOGD << "VP9 HW Decoder supported.";
|
||||
supported_codec_types_.push_back(kVideoCodecVP9);
|
||||
}
|
||||
|
||||
bool is_h264_hw_supported = jni->CallStaticBooleanMethod(
|
||||
j_decoder_class,
|
||||
GetStaticMethodID(jni, j_decoder_class, "isH264HwSupported", "()Z"));
|
||||
|
||||
@ -77,10 +77,14 @@ public class MediaCodecVideoDecoder {
|
||||
private ByteBuffer[] inputBuffers;
|
||||
private ByteBuffer[] outputBuffers;
|
||||
private static final String VP8_MIME_TYPE = "video/x-vnd.on2.vp8";
|
||||
private static final String VP9_MIME_TYPE = "video/x-vnd.on2.vp9";
|
||||
private static final String H264_MIME_TYPE = "video/avc";
|
||||
// List of supported HW VP8 decoders.
|
||||
private static final String[] supportedVp8HwCodecPrefixes =
|
||||
{"OMX.qcom.", "OMX.Nvidia.", "OMX.Exynos.", "OMX.Intel." };
|
||||
// List of supported HW VP9 decoders.
|
||||
private static final String[] supportedVp9HwCodecPrefixes =
|
||||
{"OMX.qcom."};
|
||||
// List of supported HW H.264 decoders.
|
||||
private static final String[] supportedH264HwCodecPrefixes =
|
||||
{"OMX.qcom.", "OMX.Intel." };
|
||||
@ -135,6 +139,7 @@ public class MediaCodecVideoDecoder {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
|
||||
return null; // MediaCodec.setParameters is missing.
|
||||
}
|
||||
Logging.d(TAG, "Trying to find HW decoder for mime " + mime);
|
||||
for (int i = 0; i < MediaCodecList.getCodecCount(); ++i) {
|
||||
MediaCodecInfo info = MediaCodecList.getCodecInfoAt(i);
|
||||
if (info.isEncoder()) {
|
||||
@ -150,7 +155,7 @@ public class MediaCodecVideoDecoder {
|
||||
if (name == null) {
|
||||
continue; // No HW support in this codec; try the next one.
|
||||
}
|
||||
Logging.v(TAG, "Found candidate decoder " + name);
|
||||
Logging.d(TAG, "Found candidate decoder " + name);
|
||||
|
||||
// Check if this is supported decoder.
|
||||
boolean supportedCodec = false;
|
||||
@ -181,6 +186,7 @@ public class MediaCodecVideoDecoder {
|
||||
}
|
||||
}
|
||||
}
|
||||
Logging.d(TAG, "No HW decoder found for mime " + mime);
|
||||
return null; // No HW decoder.
|
||||
}
|
||||
|
||||
@ -188,6 +194,10 @@ public class MediaCodecVideoDecoder {
|
||||
return findDecoder(VP8_MIME_TYPE, supportedVp8HwCodecPrefixes) != null;
|
||||
}
|
||||
|
||||
public static boolean isVp9HwSupported() {
|
||||
return findDecoder(VP9_MIME_TYPE, supportedVp9HwCodecPrefixes) != null;
|
||||
}
|
||||
|
||||
public static boolean isH264HwSupported() {
|
||||
return findDecoder(H264_MIME_TYPE, supportedH264HwCodecPrefixes) != null;
|
||||
}
|
||||
@ -223,6 +233,9 @@ public class MediaCodecVideoDecoder {
|
||||
if (type == VideoCodecType.VIDEO_CODEC_VP8) {
|
||||
mime = VP8_MIME_TYPE;
|
||||
supportedCodecPrefixes = supportedVp8HwCodecPrefixes;
|
||||
} else if (type == VideoCodecType.VIDEO_CODEC_VP9) {
|
||||
mime = VP9_MIME_TYPE;
|
||||
supportedCodecPrefixes = supportedVp9HwCodecPrefixes;
|
||||
} else if (type == VideoCodecType.VIDEO_CODEC_H264) {
|
||||
mime = H264_MIME_TYPE;
|
||||
supportedCodecPrefixes = supportedH264HwCodecPrefixes;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user