author | Bogdan Tara <btara@mozilla.com> |
Wed, 12 Aug 2020 11:14:44 +0300 | |
changeset 544372 | 6e2551ab206bb2f30f65e12d6c619e48bb277ebd |
parent 544371 | 547bd3a15586f6a2cec66e3a45023265b55e1619 |
child 544373 | 6a2b9be4ce0097d0d137e2184ec4576328ee292c |
push id | 123997 |
push user | btara@mozilla.com |
push date | Wed, 12 Aug 2020 08:19:49 +0000 |
treeherder | autoland@6a2b9be4ce00 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
bugs | 1657521 |
milestone | 81.0a1 |
backs out | a0f450666c5bbd60efb09ab2ed3ef7107cf30282 e97937bf5e3a386e08d67112e5cbc2bd56777137 8d70f3cb5e3b28e7e55e3ce23f66a99104034148 5c3c1ec039d2579557cf4f15789c0d7d356a0e78 132eb437fdda4a5cde692625073778696d67be74 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/dom/media/platforms/PDMFactory.cpp +++ b/dom/media/platforms/PDMFactory.cpp @@ -356,20 +356,16 @@ void PDMFactory::CreatePDMs() { RefPtr<PlatformDecoderModule> remote = new GpuDecoderModule(m); StartupPDM(remote); mWMFFailedToLoad = !StartupPDM(m); } else { mWMFFailedToLoad = StaticPrefs::media_decoder_doctor_wmf_disabled_is_failure(); } #endif -#ifdef MOZ_APPLEMEDIA - m = new AppleDecoderModule(); - StartupPDM(m); -#endif #ifdef MOZ_OMX if (StaticPrefs::media_omx_enabled()) { m = OmxDecoderModule::Create(); StartupPDM(m); } #endif #ifdef MOZ_FFVPX if (StaticPrefs::media_ffvpx_enabled()) { @@ -380,16 +376,20 @@ void PDMFactory::CreatePDMs() { #ifdef MOZ_FFMPEG if (StaticPrefs::media_ffmpeg_enabled()) { m = FFmpegRuntimeLinker::CreateDecoderModule(); mFFmpegFailedToLoad = !StartupPDM(m); } else { mFFmpegFailedToLoad = false; } #endif +#ifdef MOZ_APPLEMEDIA + m = new AppleDecoderModule(); + StartupPDM(m); +#endif #ifdef MOZ_WIDGET_ANDROID if (StaticPrefs::media_android_media_codec_enabled()) { m = new AndroidDecoderModule(); StartupPDM(m, StaticPrefs::media_android_media_codec_preferred()); } #endif m = new AgnosticDecoderModule();
--- a/dom/media/platforms/PlatformDecoderModule.h +++ b/dom/media/platforms/PlatformDecoderModule.h @@ -61,17 +61,17 @@ struct MOZ_STACK_CLASS CreateDecoderPara using OptionSet = EnumSet<Option>; struct UseNullDecoder { UseNullDecoder() = default; explicit UseNullDecoder(bool aUseNullDecoder) : mUse(aUseNullDecoder) {} bool mUse = false; }; - // Do not wrap decoder in a MediaChangeMonitor. + // Do not wrap H264 decoder in a H264Converter. struct NoWrapper { NoWrapper() = default; explicit NoWrapper(bool aDontUseWrapper) : mDontUseWrapper(aDontUseWrapper) {} bool mDontUseWrapper = false; }; struct VideoFrameRate {
--- a/dom/media/platforms/agnostic/VPXDecoder.cpp +++ b/dom/media/platforms/agnostic/VPXDecoder.cpp @@ -1,29 +1,27 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim:set ts=2 sw=2 sts=2 et cindent: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "VPXDecoder.h" - -#include <algorithm> - #include "BitReader.h" -#include "ByteWriter.h" -#include "ImageContainer.h" #include "TimeUnits.h" #include "gfx2DGlue.h" #include "mozilla/PodOperations.h" #include "mozilla/SyncRunnable.h" #include "mozilla/Unused.h" +#include "ImageContainer.h" #include "nsError.h" #include "prsystem.h" +#include <algorithm> + #undef LOG #define LOG(arg, ...) \ DDMOZ_LOG(sPDMLog, mozilla::LogLevel::Debug, "::%s: " arg, __func__, \ ##__VA_ARGS__) namespace mozilla { using namespace gfx; @@ -479,65 +477,10 @@ bool VPXDecoder::GetStreamInfo(Span<cons Unused << br.ReadBits(8); // refresh_frame_flags frame_size(); render_size(); } } return true; } -// Ref: "VP Codec ISO Media File Format Binding, v1.0, 2017-03-31" -// <https://www.webmproject.org/vp9/mp4/> -// -// class VPCodecConfigurationBox extends FullBox('vpcC', version = 1, 0) -// { -// VPCodecConfigurationRecord() vpcConfig; -// } -// -// aligned (8) class VPCodecConfigurationRecord { -// unsigned int (8) profile; -// unsigned int (8) level; -// unsigned int (4) bitDepth; -// unsigned int (3) chromaSubsampling; -// unsigned int (1) videoFullRangeFlag; -// unsigned int (8) colourPrimaries; -// unsigned int (8) transferCharacteristics; -// unsigned int (8) matrixCoefficients; -// unsigned int (16) codecIntializationDataSize; -// unsigned int (8)[] codecIntializationData; -// } - -/* static */ -void VPXDecoder::GetVPCCBox(MediaByteBuffer* aDestBox, - const VPXStreamInfo& aInfo) { - ByteWriter<BigEndian> writer(*aDestBox); - - int chroma = [&]() { - if (aInfo.mSubSampling_x && aInfo.mSubSampling_y) { - return 1; // 420 Colocated; - } - if (aInfo.mSubSampling_x && !aInfo.mSubSampling_y) { - return 2; // 422 - } - if (!aInfo.mSubSampling_x && !aInfo.mSubSampling_y) { - return 3; // 444 - } - // This indicates 4:4:0 subsampling, which is not expressable in the - // 'vpcC' box. Default to 4:2:0. - return 1; - }(); - - MOZ_ALWAYS_TRUE(writer.WriteU32(1 << 24)); // version & flag - MOZ_ALWAYS_TRUE(writer.WriteU8(aInfo.mProfile)); // profile - MOZ_ALWAYS_TRUE(writer.WriteU8(10)); // level set it to 1.0 - MOZ_ALWAYS_TRUE(writer.WriteU8( - (0xF & aInfo.mBitDepth) << 4 | (0x7 & chroma) << 1 | - (0x1 & aInfo.mFullRange))); // bitdepth (4 bits), chroma (3 bits), - // video full/restrice range (1 bit) - MOZ_ALWAYS_TRUE(writer.WriteU8(2)); // color primaries: unknown - MOZ_ALWAYS_TRUE(writer.WriteU8(2)); // transfer characteristics: unknown - MOZ_ALWAYS_TRUE(writer.WriteU8(2)); // matrix coefficient: unknown - MOZ_ALWAYS_TRUE( - writer.WriteU16(0)); // codecIntializationDataSize (must be 0 for VP9) -} - } // namespace mozilla #undef LOG
--- a/dom/media/platforms/agnostic/VPXDecoder.h +++ b/dom/media/platforms/agnostic/VPXDecoder.h @@ -1,20 +1,20 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim:set ts=2 sw=2 sts=2 et cindent: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #if !defined(VPXDecoder_h_) # define VPXDecoder_h_ -# include <stdint.h> - # include "PlatformDecoderModule.h" # include "mozilla/Span.h" + +# include <stdint.h> # include "mozilla/gfx/Types.h" # include "vpx/vp8dx.h" # include "vpx/vpx_codec.h" # include "vpx/vpx_decoder.h" namespace mozilla { DDLoggedTypeDeclNameAndBase(VPXDecoder, MediaDataDecoder); @@ -89,70 +89,16 @@ class VPXDecoder : public MediaDataDecod return gfx::YUVColorSpace::BT709; case 5: return gfx::YUVColorSpace::BT2020; default: return gfx::YUVColorSpace::UNKNOWN; } } - // Ref: ISO/IEC 23091-2:2019 - enum class ColorPrimaries { - BT_709_6 = 1, - Unspecified = 2, - BT_470_6_M = 4, - BT_470_7_BG = 5, - BT_601_7 = 6, - SMPTE_ST_240 = 7, - Film = 8, - BT_2020_Nonconstant_Luminance = 9, - SMPTE_ST_428_1 = 10, - SMPTE_RP_431_2 = 11, - SMPTE_EG_432_1 = 12, - EBU_Tech_3213_E = 22, - }; - - // Ref: ISO/IEC 23091-2:2019 - enum class TransferCharacteristics { - BT_709_6 = 1, - Unspecified = 2, - BT_470_6_M = 4, - BT_470_7_BG = 5, - BT_601_7 = 6, - SMPTE_ST_240 = 7, - Linear = 8, - Logrithmic = 9, - Logrithmic_Sqrt = 10, - IEC_61966_2_4 = 11, - BT_1361_0 = 12, - IEC_61966_2_1 = 13, - BT_2020_10bit = 14, - BT_2020_12bit = 15, - SMPTE_ST_2084 = 16, - SMPTE_ST_428_1 = 17, - BT_2100_HLG = 18, - }; - - enum class MatrixCoefficients { - Identity = 0, - BT_709_6 = 1, - Unspecified = 2, - FCC = 4, - BT_470_7_BG = 5, - BT_601_7 = 6, - SMPTE_ST_240 = 7, - YCgCo = 8, - BT_2020_Nonconstant_Luminance = 9, - BT_2020_Constant_Luminance = 10, - SMPTE_ST_2085 = 11, - Chromacity_Constant_Luminance = 12, - Chromacity_Nonconstant_Luminance = 13, - BT_2100_ICC = 14, - }; - /* mFullRange == false then: For BitDepth equals 8: Y is between 16 and 235 inclusive. U and V are between 16 and 240 inclusive. For BitDepth equals 10: Y is between 64 and 940 inclusive. U and V are between 64 and 960 inclusive. @@ -187,18 +133,16 @@ class VPXDecoder : public MediaDataDecod mColorSpace == aOther.mColorSpace && mFullRange == aOther.mFullRange; } }; static bool GetStreamInfo(Span<const uint8_t> aBuffer, VPXStreamInfo& aInfo, Codec aCodec); - static void GetVPCCBox(MediaByteBuffer* aDestBox, const VPXStreamInfo& aInfo); - private: ~VPXDecoder(); RefPtr<DecodePromise> ProcessDecode(MediaRawData* aSample); MediaResult DecodeAlpha(vpx_image_t** aImgAlpha, const MediaRawData* aSample); const RefPtr<layers::ImageContainer> mImageContainer; RefPtr<layers::KnowsCompositor> mImageAllocator; const RefPtr<TaskQueue> mTaskQueue;
--- a/dom/media/platforms/apple/AppleDecoderModule.cpp +++ b/dom/media/platforms/apple/AppleDecoderModule.cpp @@ -1,166 +1,64 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim:set ts=2 sw=2 sts=2 et cindent: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "AppleATDecoder.h" #include "AppleDecoderModule.h" - -#include <dlfcn.h> - -#include "AppleATDecoder.h" #include "AppleVTDecoder.h" -#include "MP4Decoder.h" -#include "VPXDecoder.h" #include "mozilla/DebugOnly.h" #include "mozilla/Logging.h" #include "mozilla/gfx/gfxVars.h" -extern "C" { -// Only exists from MacOS 11 -extern void VTRegisterSupplementalVideoDecoderIfAvailable( - CMVideoCodecType codecType) __attribute__((weak_import)); -extern Boolean VTIsHardwareDecodeSupported(CMVideoCodecType codecType) - __attribute__((weak_import)); -} - namespace mozilla { bool AppleDecoderModule::sInitialized = false; bool AppleDecoderModule::sCanUseHardwareVideoDecoder = true; -bool AppleDecoderModule::sCanUseVP9Decoder = false; AppleDecoderModule::AppleDecoderModule() {} AppleDecoderModule::~AppleDecoderModule() {} /* static */ void AppleDecoderModule::Init() { if (sInitialized) { return; } sCanUseHardwareVideoDecoder = gfx::gfxVars::CanUseHardwareVideoDecoding(); sInitialized = true; - if (RegisterSupplementalVP9Decoder()) { - sCanUseVP9Decoder = CanCreateVP9Decoder(); - } } nsresult AppleDecoderModule::Startup() { if (!sInitialized) { return NS_ERROR_FAILURE; } return NS_OK; } already_AddRefed<MediaDataDecoder> AppleDecoderModule::CreateVideoDecoder( const CreateDecoderParams& aParams) { - RefPtr<MediaDataDecoder> decoder; - if (IsVideoSupported(aParams.VideoConfig(), aParams.mOptions)) { - decoder = new AppleVTDecoder(aParams.VideoConfig(), aParams.mTaskQueue, - aParams.mImageContainer, aParams.mOptions, - aParams.mKnowsCompositor); - } + RefPtr<MediaDataDecoder> decoder = new AppleVTDecoder( + aParams.VideoConfig(), aParams.mTaskQueue, aParams.mImageContainer, + aParams.mOptions, aParams.mKnowsCompositor); return decoder.forget(); } already_AddRefed<MediaDataDecoder> AppleDecoderModule::CreateAudioDecoder( const CreateDecoderParams& aParams) { RefPtr<MediaDataDecoder> decoder = new AppleATDecoder(aParams.AudioConfig(), aParams.mTaskQueue); return decoder.forget(); } bool AppleDecoderModule::SupportsMimeType( const nsACString& aMimeType, DecoderDoctorDiagnostics* aDiagnostics) const { return aMimeType.EqualsLiteral("audio/mpeg") || aMimeType.EqualsLiteral("audio/mp4a-latm") || - MP4Decoder::IsH264(aMimeType) || VPXDecoder::IsVP9(aMimeType); -} - -bool AppleDecoderModule::Supports( - const TrackInfo& aTrackInfo, DecoderDoctorDiagnostics* aDiagnostics) const { - if (aTrackInfo.IsAudio()) { - return SupportsMimeType(aTrackInfo.mMimeType, aDiagnostics); - } - return aTrackInfo.GetAsVideoInfo() && - IsVideoSupported(*aTrackInfo.GetAsVideoInfo()); -} - -bool AppleDecoderModule::IsVideoSupported( - const VideoInfo& aConfig, - const CreateDecoderParams::OptionSet& aOptions) const { - if (MP4Decoder::IsH264(aConfig.mMimeType)) { - return true; - } - if (!VPXDecoder::IsVP9(aConfig.mMimeType) || !sCanUseVP9Decoder || - aOptions.contains( - CreateDecoderParams::Option::HardwareDecoderNotAllowed)) { - return false; - } - if (aConfig.HasAlpha()) { - return false; - } - - // HW VP9 decoder only supports 8 or 10 bit color. - if (aConfig.mColorDepth != gfx::ColorDepth::COLOR_8 && - aConfig.mColorDepth != gfx::ColorDepth::COLOR_10) { - return false; - } - - // See if we have a vpcC box, and check further constraints. - // HW VP9 Decoder supports Profile 0 & 2 (YUV420) - if (aConfig.mExtraData && aConfig.mExtraData->Length() < 5) { - return true; // Assume it's okay. - } - int profile = aConfig.mExtraData->ElementAt(4); - - if (profile != 0 && profile != 2) { - return false; - } - - return true; -} - -/* static */ -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, *)) { - // Only use VP9 decoder if it's hardware accelerated. - if (!sCanUseHardwareVideoDecoder || !VTIsHardwareDecodeSupported || - !VTIsHardwareDecodeSupported(kCMVideoCodecType_VP9)) { - return false; - } - - VideoInfo info(1920, 1080); - VPXDecoder::GetVPCCBox(info.mExtraData, VPXDecoder::VPXStreamInfo()); - - RefPtr<AppleVTDecoder> decoder = - new AppleVTDecoder(info, nullptr, nullptr, {}, nullptr); - nsAutoCString reason; - MediaResult rv = decoder->InitializeSession(); - bool isHardwareAccelerated = decoder->IsHardwareAccelerated(reason); - decoder->Shutdown(); - - return NS_SUCCEEDED(rv) && isHardwareAccelerated; - } - - return false; -} - -/* static */ -bool AppleDecoderModule::RegisterSupplementalVP9Decoder() { - static bool sRegisterIfAvailable = []() { - if (VTRegisterSupplementalVideoDecoderIfAvailable) { - VTRegisterSupplementalVideoDecoderIfAvailable(kCMVideoCodecType_VP9); - return true; - } - return false; - }(); - return sRegisterIfAvailable; + aMimeType.EqualsLiteral("video/mp4") || + aMimeType.EqualsLiteral("video/avc"); } } // namespace mozilla
--- a/dom/media/platforms/apple/AppleDecoderModule.h +++ b/dom/media/platforms/apple/AppleDecoderModule.h @@ -24,32 +24,19 @@ class AppleDecoderModule : public Platfo // Decode thread. already_AddRefed<MediaDataDecoder> CreateAudioDecoder( const CreateDecoderParams& aParams) override; bool SupportsMimeType(const nsACString& aMimeType, DecoderDoctorDiagnostics* aDiagnostics) const override; - bool Supports(const TrackInfo& aTrackInfo, - DecoderDoctorDiagnostics* aDiagnostics) const override; - static void Init(); static bool sCanUseHardwareVideoDecoder; - static bool sCanUseVP9Decoder; - - static constexpr int kCMVideoCodecType_VP9{'vp09'}; private: static bool sInitialized; - bool IsVideoSupported(const VideoInfo& aConfig, - const CreateDecoderParams::OptionSet& aOptions = - CreateDecoderParams::OptionSet()) const; - // Enable VP9 HW decoder. - static bool RegisterSupplementalVP9Decoder(); - // Return true if a dummy hardware VP9 decoder could be created. - static bool CanCreateVP9Decoder(); }; } // namespace mozilla #endif // mozilla_AppleDecoderModule_h
--- a/dom/media/platforms/apple/AppleVTDecoder.cpp +++ b/dom/media/platforms/apple/AppleVTDecoder.cpp @@ -6,26 +6,25 @@ #include "AppleVTDecoder.h" #include <CoreVideo/CVPixelBufferIOSurface.h> #include <IOSurface/IOSurface.h> #include "AppleDecoderModule.h" #include "AppleUtils.h" -#include "H264.h" -#include "MP4Decoder.h" #include "MacIOSurfaceImage.h" #include "MediaData.h" -#include "VPXDecoder.h" +#include "mozilla/ArrayUtils.h" +#include "H264.h" +#include "nsThreadUtils.h" +#include "mozilla/Logging.h" #include "VideoUtils.h" #include "gfxPlatform.h" -#include "mozilla/ArrayUtils.h" -#include "mozilla/Logging.h" -#include "nsThreadUtils.h" +#include "MacIOSurfaceImage.h" #define LOG(...) DDMOZ_LOG(sPDMLog, mozilla::LogLevel::Debug, __VA_ARGS__) #define LOGEX(_this, ...) \ DDMOZ_LOGEX(_this, sPDMLog, mozilla::LogLevel::Debug, __VA_ARGS__) namespace mozilla { using namespace layers; @@ -38,27 +37,20 @@ AppleVTDecoder::AppleVTDecoder(const Vid mPictureWidth(aConfig.mImage.width), mPictureHeight(aConfig.mImage.height), mDisplayWidth(aConfig.mDisplay.width), mDisplayHeight(aConfig.mDisplay.height), mColorSpace(aConfig.mColorSpace == gfx::YUVColorSpace::UNKNOWN ? DefaultColorSpace({mPictureWidth, mPictureHeight}) : aConfig.mColorSpace), mColorRange(aConfig.mColorRange), - mStreamType(MP4Decoder::IsH264(aConfig.mMimeType) - ? StreamType::H264 - : VPXDecoder::IsVP9(aConfig.mMimeType) - ? StreamType::VP9 - : StreamType::Unknown), mTaskQueue(aTaskQueue), - mMaxRefFrames( - mStreamType != StreamType::H264 || - aOptions.contains(CreateDecoderParams::Option::LowLatency) - ? 0 - : H264::ComputeMaxRefFrames(aConfig.mExtraData)), + mMaxRefFrames(aOptions.contains(CreateDecoderParams::Option::LowLatency) + ? 0 + : H264::ComputeMaxRefFrames(aConfig.mExtraData)), mImageContainer(aImageContainer), mKnowsCompositor(aKnowsCompositor) #ifdef MOZ_WIDGET_UIKIT , mUseSoftwareImages(true) #else , mUseSoftwareImages(false) @@ -67,20 +59,19 @@ AppleVTDecoder::AppleVTDecoder(const Vid mIsFlushing(false), mMonitor("AppleVTDecoder"), mPromise(&mMonitor), // To ensure our PromiseHolder is only ever accessed // with the monitor held. mFormat(nullptr), mSession(nullptr), mIsHardwareAccelerated(false) { MOZ_COUNT_CTOR(AppleVTDecoder); - MOZ_ASSERT(mStreamType != StreamType::Unknown); // TODO: Verify aConfig.mime_type. - LOG("Creating AppleVTDecoder for %dx%d %s video", mDisplayWidth, - mDisplayHeight, mStreamType == StreamType::H264 ? "H.264" : "VP9"); + LOG("Creating AppleVTDecoder for %dx%d h.264 video", mDisplayWidth, + mDisplayHeight); } AppleVTDecoder::~AppleVTDecoder() { MOZ_COUNT_DTOR(AppleVTDecoder); } RefPtr<MediaDataDecoder::InitPromise> AppleVTDecoder::Init() { MediaResult rv = InitializeSession(); if (NS_SUCCEEDED(rv)) { @@ -500,22 +491,19 @@ nsresult AppleVTDecoder::WaitForAsynchro return NS_OK; } MediaResult AppleVTDecoder::InitializeSession() { OSStatus rv; AutoCFRelease<CFDictionaryRef> extensions = CreateDecoderExtensions(); - rv = CMVideoFormatDescriptionCreate( - kCFAllocatorDefault, - mStreamType == StreamType::H264 - ? kCMVideoCodecType_H264 - : CMVideoCodecType(AppleDecoderModule::kCMVideoCodecType_VP9), - mPictureWidth, mPictureHeight, extensions, &mFormat); + rv = CMVideoFormatDescriptionCreate(kCFAllocatorDefault, + kCMVideoCodecType_H264, mPictureWidth, + mPictureHeight, extensions, &mFormat); if (rv != noErr) { return MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR, RESULT_DETAIL("Couldn't create format description!")); } // Contruct video decoder selection spec. AutoCFRelease<CFDictionaryRef> spec = CreateDecoderSpecification(); @@ -546,22 +534,21 @@ MediaResult AppleVTDecoder::InitializeSe mIsHardwareAccelerated = rv == noErr && isUsingHW == kCFBooleanTrue; LOG("AppleVTDecoder: %s hardware accelerated decoding", mIsHardwareAccelerated ? "using" : "not using"); return NS_OK; } CFDictionaryRef AppleVTDecoder::CreateDecoderExtensions() { - AutoCFRelease<CFDataRef> data = CFDataCreate( + AutoCFRelease<CFDataRef> avc_data = CFDataCreate( kCFAllocatorDefault, mExtraData->Elements(), mExtraData->Length()); - const void* atomsKey[1]; - atomsKey[0] = mStreamType == StreamType::H264 ? CFSTR("avcC") : CFSTR("vpcC"); - const void* atomsValue[] = {data}; + const void* atomsKey[] = {CFSTR("avcC")}; + const void* atomsValue[] = {avc_data}; static_assert(ArrayLength(atomsKey) == ArrayLength(atomsValue), "Non matching keys/values array size"); AutoCFRelease<CFDictionaryRef> atoms = CFDictionaryCreate( kCFAllocatorDefault, atomsKey, atomsValue, ArrayLength(atomsKey), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); const void* extensionKeys[] = {
--- a/dom/media/platforms/apple/AppleVTDecoder.h +++ b/dom/media/platforms/apple/AppleVTDecoder.h @@ -5,17 +5,16 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef mozilla_AppleVTDecoder_h #define mozilla_AppleVTDecoder_h #include <CoreFoundation/CFDictionary.h> // For CFDictionaryRef #include <CoreMedia/CoreMedia.h> // For CMVideoFormatDescriptionRef #include <VideoToolbox/VideoToolbox.h> // For VTDecompressionSessionRef -#include "AppleDecoderModule.h" #include "PlatformDecoderModule.h" #include "ReorderQueue.h" #include "TimeUnits.h" #include "mozilla/Atomics.h" #include "mozilla/gfx/Types.h" namespace mozilla { @@ -66,17 +65,16 @@ class AppleVTDecoder : public MediaDataD } // Access from the taskqueue and the decoder's thread. // OutputFrame is thread-safe. void OutputFrame(CVPixelBufferRef aImage, AppleFrameRef aFrameRef); void OnDecodeError(OSStatus aError); private: - friend class AppleDecoderModule; // To access InitializeSession. virtual ~AppleVTDecoder(); RefPtr<FlushPromise> ProcessFlush(); RefPtr<DecodePromise> ProcessDrain(); void ProcessShutdown(); void ProcessDecode(MediaRawData* aSample); void MaybeResolveBufferedFrames(); void AssertOnTaskQueueThread() { @@ -95,18 +93,16 @@ class AppleVTDecoder : public MediaDataD const gfx::ColorRange mColorRange; // Method to set up the decompression session. MediaResult InitializeSession(); nsresult WaitForAsynchronousFrames(); CFDictionaryRef CreateDecoderSpecification(); CFDictionaryRef CreateDecoderExtensions(); - enum class StreamType { Unknown, H264, VP9 }; - const StreamType mStreamType; const RefPtr<TaskQueue> mTaskQueue; const uint32_t mMaxRefFrames; const RefPtr<layers::ImageContainer> mImageContainer; const RefPtr<layers::KnowsCompositor> mKnowsCompositor; const bool mUseSoftwareImages; // Set on reader/decode thread calling Flush() to indicate that output is // not required and so input samples on mTaskQueue need not be processed.
--- a/dom/media/platforms/moz.build +++ b/dom/media/platforms/moz.build @@ -104,23 +104,16 @@ if CONFIG['MOZ_APPLEMEDIA']: ] LOCAL_INCLUDES += [ '/media/libyuv/libyuv/include', ] OS_LIBS += [ '-framework AudioToolbox', '-framework CoreMedia', '-framework VideoToolbox', - # For some unknown reason, the documented method of using weak_import - # attribute doesn't work with VideoToolbox's functions. - # We want to lazily load _VTRegisterSupplementalVideoDecoderIfAvailable - # symbol as it's only available in macOS 11 and later. - '-Wl,-U,_VTRegisterSupplementalVideoDecoderIfAvailable', - # Same for VTIsHardwareDecodeSupported available from macOS 10.13. - '-Wl,-U,_VTIsHardwareDecodeSupported', ] include('/ipc/chromium/chromium-config.mozbuild') if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android': EXPORTS += [ 'android/AndroidDecoderModule.h', 'android/AndroidEncoderModule.h',
--- a/dom/media/platforms/wrappers/MediaChangeMonitor.cpp +++ b/dom/media/platforms/wrappers/MediaChangeMonitor.cpp @@ -151,22 +151,17 @@ class VPXChangeMonitor : public MediaCha public: explicit VPXChangeMonitor(const VideoInfo& aInfo) : mCurrentConfig(aInfo), mCodec(VPXDecoder::IsVP8(aInfo.mMimeType) ? VPXDecoder::Codec::VP8 : VPXDecoder::Codec::VP9) { mTrackInfo = new TrackInfoSharedPtr(mCurrentConfig, mStreamID++); } - bool CanBeInstantiated() const override { - // We want to see at least one sample before we create a decoder so that we - // can create the vpcC content on mCurrentConfig.mExtraData. - return mCodec == VPXDecoder::Codec::VP8 || mInfo || - mCurrentConfig.mCrypto.IsEncrypted(); - } + bool CanBeInstantiated() const override { return true; } MediaResult CheckForChange(MediaRawData* aSample) override { // Don't look at encrypted content. if (aSample->mCrypto.IsEncrypted()) { return NS_OK; } // For both VP8 and VP9, we only look for resolution changes // on keyframes. Other resolution changes are invalid. @@ -194,19 +189,16 @@ class VPXChangeMonitor : public MediaCha } mInfo = Some(info); // For the first frame, we leave the mDisplay/mImage untouched as they // contain aspect ratio (AR) information set by the demuxer. // The AR data isn't found in the VP8/VP9 bytestream. mCurrentConfig.mColorDepth = gfx::ColorDepthForBitDepth(info.mBitDepth); mCurrentConfig.mColorSpace = info.ColorSpace(); mCurrentConfig.mColorRange = info.ColorRange(); - if (mCodec == VPXDecoder::Codec::VP9) { - VPXDecoder::GetVPCCBox(mCurrentConfig.mExtraData, info); - } mTrackInfo = new TrackInfoSharedPtr(mCurrentConfig, mStreamID++); return rv; } const TrackInfo& Config() const override { return mCurrentConfig; } MediaResult PrepareSample(MediaDataDecoder::ConversionRequired aConversion, @@ -465,29 +457,20 @@ MediaResult MediaChangeMonitor::CreateDe MediaResult error = NS_OK; mDecoder = mPDM->CreateVideoDecoder( {mCurrentConfig, mTaskQueue, aDiagnostics, mImageContainer, mKnowsCompositor, mGMPCrashHelper, mType, mOnWaitingForKeyEvent, mDecoderOptions, mRate, &error}); if (!mDecoder) { - // We failed to create a decoder with the existing PDM; attempt once again - // with a PDMFactory. - RefPtr<PDMFactory> factory = new PDMFactory(); - mDecoder = factory->CreateDecoder( - {mCurrentConfig, mTaskQueue, aDiagnostics, mImageContainer, - mKnowsCompositor, mGMPCrashHelper, mType, mOnWaitingForKeyEvent, - mDecoderOptions, mRate, &error, CreateDecoderParams::NoWrapper(true)}); - - if (!mDecoder) { - if (NS_FAILED(error)) { - // The decoder supports CreateDecoderParam::mError, returns the value. - return error; - } + if (NS_FAILED(error)) { + // The decoder supports CreateDecoderParam::mError, returns the value. + return error; + } else { return MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR, RESULT_DETAIL("Unable to create decoder")); } } DDLINKCHILD("decoder", mDecoder.get()); mNeedKeyframe = true;
--- a/security/sandbox/mac/SandboxPolicyContent.h +++ b/security/sandbox/mac/SandboxPolicyContent.h @@ -192,17 +192,16 @@ static const char SandboxPolicyContent[] (iokit-property "board-id") (iokit-property "vendor-id") (iokit-property "device-id") (iokit-property "IODVDBundleName") (iokit-property "IOGLBundleName") (iokit-property "IOGVACodec") (iokit-property "IOGVAHEVCDecode") (iokit-property "IOGVAHEVCEncode") - (iokit-property "IOGVAXDecode") (iokit-property "IOPCITunnelled") (iokit-property "IOVARendererID") (iokit-property "MetalPluginName") (iokit-property "MetalPluginClassName"))) ; depending on systems, the 1st, 2nd or both rules are necessary (allow user-preference-read (preference-domain "com.apple.HIToolbox")) (allow file-read-data (literal "/Library/Preferences/com.apple.HIToolbox.plist"))