Backed out 4 changesets (bug 1792257) for causing bustages on AppleDecoderModule.cpp. CLOSED TREE

Backed out changeset 85d8ad7e1407 (bug 1792257)
Backed out changeset 94d65008a526 (bug 1792257)
Backed out changeset 739f03187387 (bug 1792257)
Backed out changeset a868515e644e (bug 1792257)
This commit is contained in:
Marian-Vasile Laza 2022-10-12 06:51:02 +03:00
Родитель ff05850ef8
Коммит fc32c40760
3 изменённых файлов: 34 добавлений и 74 удалений

Просмотреть файл

@ -15,7 +15,6 @@
#include "mozilla/DebugOnly.h"
#include "mozilla/Logging.h"
#include "mozilla/StaticPrefs_media.h"
#include "mozilla/gfx/gfxVars.h"
extern "C" {
// Only exists from MacOS 11
@ -38,7 +37,7 @@ void AppleDecoderModule::Init() {
sInitialized = true;
if (RegisterSupplementalVP9Decoder()) {
sCanUseVP9Decoder = CanCreateHWDecoder(media::MediaCodec::VP9);
sCanUseVP9Decoder = CanCreateVP9Decoder();
}
}
@ -75,30 +74,19 @@ already_AddRefed<MediaDataDecoder> AppleDecoderModule::CreateAudioDecoder(
media::DecodeSupportSet AppleDecoderModule::SupportsMimeType(
const nsACString& aMimeType, DecoderDoctorDiagnostics* aDiagnostics) const {
bool checkSupport = (aMimeType.EqualsLiteral("audio/mpeg") &&
bool supports = (aMimeType.EqualsLiteral("audio/mpeg") &&
!StaticPrefs::media_ffvpx_mp3_enabled()) ||
aMimeType.EqualsLiteral("audio/mp4a-latm") ||
MP4Decoder::IsH264(aMimeType) ||
VPXDecoder::IsVP9(aMimeType);
media::DecodeSupportSet supportType{media::DecodeSupport::Unsupported};
if (checkSupport) {
UniquePtr<TrackInfo> trackInfo = CreateTrackInfoWithMIMEType(aMimeType);
if (!trackInfo) {
supportType = media::DecodeSupport::Unsupported;
} else if (trackInfo->IsAudio()) {
supportType = media::DecodeSupport::SoftwareDecode;
} else {
supportType = Supports(SupportDecoderParams(*trackInfo), aDiagnostics);
}
}
MP4Decoder::IsH264(aMimeType) || VPXDecoder::IsVP9(aMimeType);
MOZ_LOG(sPDMLog, LogLevel::Debug,
("Apple decoder %s requested type '%s'",
supportType == media::DecodeSupport::Unsupported ? "rejects"
: "supports",
aMimeType.BeginReading()));
return supportType;
supports ? "supports" : "rejects", aMimeType.BeginReading()));
if (supports) {
// TODO: Note that we do not yet distinguish between SW/HW decode support.
// Will be done in bug 1754239.
return media::DecodeSupport::SoftwareDecode;
}
return media::DecodeSupport::Unsupported;
}
media::DecodeSupportSet AppleDecoderModule::Supports(
@ -108,17 +96,11 @@ media::DecodeSupportSet AppleDecoderModule::Supports(
if (trackInfo.IsAudio()) {
return SupportsMimeType(trackInfo.mMimeType, aDiagnostics);
}
bool checkSupport = trackInfo.GetAsVideoInfo() &&
bool supports = trackInfo.GetAsVideoInfo() &&
IsVideoSupported(*trackInfo.GetAsVideoInfo());
if (checkSupport) {
if (trackInfo.mMimeType == "video/vp9" &&
CanCreateHWDecoder(media::MediaCodec::VP9)) {
return media::DecodeSupport::HardwareDecode;
}
if (trackInfo.mMimeType == "video/avc" &&
CanCreateHWDecoder(media::MediaCodec::H264)) {
return media::DecodeSupport::HardwareDecode;
}
if (supports) {
// TODO: Note that we do not yet distinguish between SW/HW decode support.
// Will be done in bug 1754239.
return media::DecodeSupport::SoftwareDecode;
}
return media::DecodeSupport::Unsupported;
@ -160,50 +142,29 @@ bool AppleDecoderModule::IsVideoSupported(
}
/* static */
bool AppleDecoderModule::CanCreateHWDecoder(media::MediaCodec aCodec) {
// Check whether HW decode should even be enabled
if (!gfx::gfxVars::CanUseHardwareVideoDecoding()) {
return false;
}
VideoInfo info(1920, 1080);
bool checkSupport = false;
// HW codecs require 10.13+, with the exception of H264
bool AppleDecoderModule::CanCreateVP9Decoder() {
// We must wrap the code within __builtin_available to avoid compilation
// warning as VTIsHardwareDecodeSupported is only available from macOS 10.13.
if (__builtin_available(macOS 10.13, *)) {
if (!VTIsHardwareDecodeSupported) {
// Only use VP9 decoder if it's hardware accelerated.
if (!VTIsHardwareDecodeSupported ||
!VTIsHardwareDecodeSupported(kCMVideoCodecType_VP9)) {
return false;
}
switch (aCodec) {
case media::MediaCodec::VP9:
// Check that we can instantiate a VP9 decoder.
VideoInfo info(1920, 1080);
info.mMimeType = "video/vp9";
VPXDecoder::GetVPCCBox(info.mExtraData, VPXDecoder::VPXStreamInfo());
checkSupport = VTIsHardwareDecodeSupported(kCMVideoCodecType_VP9);
break;
case media::MediaCodec::H264:
info.mMimeType = "video/avc";
checkSupport = VTIsHardwareDecodeSupported(kCMVideoCodecType_H264);
break;
default:
break;
}
} else if (aCodec == media::MediaCodec::H264) {
// VTIsHardwareDecodeSupported function is only available on 10.13+.
// For earlier versions, we must check H264 support by always
// attempting to create a decoder.
info.mMimeType = "video/avc";
checkSupport = true;
}
// Attempt to create decoder
if (checkSupport) {
RefPtr<AppleVTDecoder> decoder =
new AppleVTDecoder(info, nullptr, {}, nullptr);
MediaResult rv = decoder->InitializeSession();
decoder->Shutdown();
nsAutoCString failureReason;
return (NS_SUCCEEDED(rv) && decoder->IsHardwareAccelerated(failureReason));
return NS_SUCCEEDED(rv);
}
return false;
}

Просмотреть файл

@ -40,7 +40,6 @@ class AppleDecoderModule : public PlatformDecoderModule {
static bool sCanUseVP9Decoder;
static constexpr int kCMVideoCodecType_H264{'avc1'};
static constexpr int kCMVideoCodecType_VP9{'vp09'};
private:
@ -53,8 +52,8 @@ class AppleDecoderModule : public PlatformDecoderModule {
CreateDecoderParams::OptionSet()) const;
// Enable VP9 HW decoder.
static bool RegisterSupplementalVP9Decoder();
// Return true if a dummy hardware decoder could be created.
static bool CanCreateHWDecoder(media::MediaCodec aCodec);
// Return true if a dummy hardware VP9 decoder could be created.
static bool CanCreateVP9Decoder();
};
} // namespace mozilla

Просмотреть файл

@ -1049,7 +1049,7 @@ var snapshotFormatters = {
// Codec decode/encode support information (inc. HW accel)
// Currently supported on Windows with Linux/OS X support under development
if (AppConstants.platform == "win" || AppConstants.platform == "macosx") {
if (AppConstants.platform == "win") {
insertBasicInfo("media-codec-support-info", data.codecSupportInfo);
}
},