зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1778393 - allow 10-bit video on Android. r=azebrowski,geckoview-reviewers,m_kato
Depends on D164723 Differential Revision: https://phabricator.services.mozilla.com/D164724
This commit is contained in:
Родитель
e4e830571f
Коммит
f893685c3c
|
@ -148,6 +148,40 @@ media::DecodeSupportSet AndroidDecoderModule::SupportsMimeType(
|
|||
return AndroidDecoderModule::SupportsMimeType(aMimeType);
|
||||
}
|
||||
|
||||
bool AndroidDecoderModule::SupportsColorDepth(
|
||||
gfx::ColorDepth aColorDepth, DecoderDoctorDiagnostics* aDiagnostics) const {
|
||||
// 10-bit support is codec dependent so this is not entirely accurate.
|
||||
// Supports() will correct it.
|
||||
return aColorDepth == gfx::ColorDepth::COLOR_8 ||
|
||||
aColorDepth == gfx::ColorDepth::COLOR_10;
|
||||
}
|
||||
|
||||
// Further check is needed because the base class uses the inaccurate
|
||||
// SupportsColorDepth().
|
||||
media::DecodeSupportSet AndroidDecoderModule::Supports(
|
||||
const SupportDecoderParams& aParams,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const {
|
||||
media::DecodeSupportSet support =
|
||||
PlatformDecoderModule::Supports(aParams, aDiagnostics);
|
||||
|
||||
// Short-circuit.
|
||||
if (support == media::DecodeSupport::Unsupported) {
|
||||
return support;
|
||||
}
|
||||
|
||||
// Check 10-bit video.
|
||||
const TrackInfo& trackInfo = aParams.mConfig;
|
||||
const VideoInfo* videoInfo = trackInfo.GetAsVideoInfo();
|
||||
if (!videoInfo || videoInfo->mColorDepth != gfx::ColorDepth::COLOR_10) {
|
||||
return support;
|
||||
}
|
||||
|
||||
return java::HardwareCodecCapabilityUtils::Decodes10Bit(
|
||||
TranslateMimeType(aParams.MimeType()))
|
||||
? support
|
||||
: media::DecodeSupport::Unsupported;
|
||||
}
|
||||
|
||||
already_AddRefed<MediaDataDecoder> AndroidDecoderModule::CreateVideoDecoder(
|
||||
const CreateDecoderParams& aParams) {
|
||||
// Temporary - forces use of VPXDecoder when alpha is present.
|
||||
|
|
|
@ -35,6 +35,15 @@ class AndroidDecoderModule : public PlatformDecoderModule {
|
|||
|
||||
static void SetSupportedMimeTypes(nsTArray<nsCString>&& aSupportedTypes);
|
||||
|
||||
media::DecodeSupportSet Supports(
|
||||
const SupportDecoderParams& aParams,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const override;
|
||||
|
||||
protected:
|
||||
bool SupportsColorDepth(
|
||||
gfx::ColorDepth aColorDepth,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const override;
|
||||
|
||||
private:
|
||||
explicit AndroidDecoderModule(CDMProxy* aProxy = nullptr);
|
||||
virtual ~AndroidDecoderModule() = default;
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
package org.mozilla.gecko.util;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.media.MediaCodec;
|
||||
import android.media.MediaCodecInfo;
|
||||
import android.media.MediaCodecInfo.CodecCapabilities;
|
||||
|
@ -262,4 +263,58 @@ public final class HardwareCodecCapabilityUtils {
|
|||
return getHWCodecCapability(H264_MIME_TYPE, true)
|
||||
&& getHWCodecCapability(H264_MIME_TYPE, false);
|
||||
}
|
||||
|
||||
@WrapForJNI
|
||||
@SuppressLint("NewApi")
|
||||
public static boolean decodes10Bit(final String aMimeType) {
|
||||
if (Build.VERSION.SDK_INT < 24) {
|
||||
// Be conservative when we cannot get supported profile.
|
||||
return false;
|
||||
}
|
||||
|
||||
final MediaCodecList codecs = new MediaCodecList(MediaCodecList.REGULAR_CODECS);
|
||||
for (final MediaCodecInfo info : codecs.getCodecInfos()) {
|
||||
if (info.isEncoder()) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
for (final MediaCodecInfo.CodecProfileLevel pl :
|
||||
info.getCapabilitiesForType(aMimeType).profileLevels) {
|
||||
if ((aMimeType.equals(H264_MIME_TYPE)
|
||||
&& pl.profile == MediaCodecInfo.CodecProfileLevel.AVCProfileHigh10)
|
||||
|| (aMimeType.equals(VP9_MIME_TYPE) && is10BitVP9Profile(pl.profile))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (final IllegalArgumentException e) {
|
||||
// Type not supported.
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
private static boolean is10BitVP9Profile(final int profile) {
|
||||
if (Build.VERSION.SDK_INT < 24) {
|
||||
// Be conservative when we cannot get supported profile.
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((profile == MediaCodecInfo.CodecProfileLevel.VP9Profile2)
|
||||
|| (profile == MediaCodecInfo.CodecProfileLevel.VP9Profile3)
|
||||
|| (profile == MediaCodecInfo.CodecProfileLevel.VP9Profile2HDR)
|
||||
|| (profile == MediaCodecInfo.CodecProfileLevel.VP9Profile3HDR)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 29
|
||||
&& ((profile == MediaCodecInfo.CodecProfileLevel.VP9Profile2HDR10Plus)
|
||||
|| (profile == MediaCodecInfo.CodecProfileLevel.VP9Profile3HDR10Plus))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче