Diff
Modified: trunk/LayoutTests/ChangeLog (270719 => 270720)
--- trunk/LayoutTests/ChangeLog 2020-12-12 00:43:52 UTC (rev 270719)
+++ trunk/LayoutTests/ChangeLog 2020-12-12 00:57:14 UTC (rev 270720)
@@ -1,3 +1,14 @@
+2020-12-11 Jer Noble <[email protected]>
+
+ [Cocoa] Add Experimental VP8 support
+ https://bugs.webkit.org/show_bug.cgi?id=219732
+
+ Reviewed by Eric Carlson.
+
+ * platform/mac/TestExpectations:
+ * platform/mac-bigsur/imported/w3c/web-platform-tests/media-source/mediasource-addsourcebuffer-expected.txt:
+ * platform/mac-bigsur/imported/w3c/web-platform-tests/media-source/mediasource-invalid-codec-expected.txt:
+
2020-12-11 Aditya Keerthi <[email protected]>
[iOS][FCR] Add new look for select elements
Modified: trunk/LayoutTests/platform/mac/TestExpectations (270719 => 270720)
--- trunk/LayoutTests/platform/mac/TestExpectations 2020-12-12 00:43:52 UTC (rev 270719)
+++ trunk/LayoutTests/platform/mac/TestExpectations 2020-12-12 00:57:14 UTC (rev 270720)
@@ -858,8 +858,8 @@
webkit.org/b/161725 imported/w3c/web-platform-tests/media-source/mediasource-is-type-supported.html [ Skip ]
webkit.org/b/161725 imported/w3c/web-platform-tests/media-source/mediasource-removesourcebuffer.html [ Skip ]
webkit.org/b/161725 imported/w3c/web-platform-tests/media-source/mediasource-seek-beyond-duration.html [ Skip ]
-webkit.org/b/161725 imported/w3c/web-platform-tests/media-source/mediasource-seek-during-pending-seek.html [ Skip ]
-webkit.org/b/161725 imported/w3c/web-platform-tests/media-source/mediasource-seekable.html [ Skip ]
+webkit.org/b/161725 [ Mojave Catalina ] imported/w3c/web-platform-tests/media-source/mediasource-seek-during-pending-seek.html [ Skip ]
+webkit.org/b/161725 [ Mojave Catalina ] imported/w3c/web-platform-tests/media-source/mediasource-seekable.html [ Skip ]
webkit.org/b/161725 imported/w3c/web-platform-tests/media-source/mediasource-sequencemode-append-buffer.html [ Skip ]
webkit.org/b/161725 imported/w3c/web-platform-tests/media-source/mediasource-sourcebuffer-mode-timestamps.html [ Skip ]
webkit.org/b/161725 imported/w3c/web-platform-tests/media-source/mediasource-sourcebuffer-mode.html [ Skip ]
@@ -870,9 +870,9 @@
imported/w3c/web-platform-tests/media-source/mediasource-config-change-webm-av-audio-bitrate.html [ Skip ]
imported/w3c/web-platform-tests/media-source/mediasource-config-change-webm-av-framesize.html [ Skip ]
imported/w3c/web-platform-tests/media-source/mediasource-config-change-webm-av-video-bitrate.html [ Skip ]
-imported/w3c/web-platform-tests/media-source/mediasource-config-change-webm-v-bitrate.html [ Skip ]
-imported/w3c/web-platform-tests/media-source/mediasource-config-change-webm-v-framerate.html [ Skip ]
-imported/w3c/web-platform-tests/media-source/mediasource-config-change-webm-v-framesize.html [ Skip ]
+[ Mojave Catalina ] imported/w3c/web-platform-tests/media-source/mediasource-config-change-webm-v-bitrate.html [ Skip ]
+[ Mojave Catalina ] imported/w3c/web-platform-tests/media-source/mediasource-config-change-webm-v-framerate.html [ Skip ]
+[ Mojave Catalina ] imported/w3c/web-platform-tests/media-source/mediasource-config-change-webm-v-framesize.html [ Skip ]
# Skipped in W3C Web Platform Test manifest
imported/w3c/web-platform-tests/media-source/mediasource-getvideoplaybackquality.html [ Skip ]
Added: trunk/LayoutTests/platform/mac-bigsur/imported/w3c/web-platform-tests/media-source/mediasource-addsourcebuffer-expected.txt (0 => 270720)
--- trunk/LayoutTests/platform/mac-bigsur/imported/w3c/web-platform-tests/media-source/mediasource-addsourcebuffer-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/mac-bigsur/imported/w3c/web-platform-tests/media-source/mediasource-addsourcebuffer-expected.txt 2020-12-12 00:57:14 UTC (rev 270720)
@@ -0,0 +1,12 @@
+
+PASS Test addSourceBuffer() in 'ended' state.
+PASS Test addSourceBuffer() with empty type
+PASS Test addSourceBuffer() with null
+PASS Test addSourceBuffer() with unsupported type
+FAIL Test addSourceBuffer() with Vorbis and VP8 assert_true: video/webm;codecs="vp8,vorbis" is supported expected true got false
+FAIL Test addSourceBuffer() with Vorbis and VP8 in separate SourceBuffers assert_true: audio/webm;codecs="vorbis" is supported expected true got false
+PASS Test addSourceBuffer() video only
+PASS Test addSourceBuffer() audio only
+PASS Test addSourceBuffer() with AAC and H.264
+PASS Test addSourceBuffer() with AAC and H.264 in separate SourceBuffers
+
Added: trunk/LayoutTests/platform/mac-bigsur/imported/w3c/web-platform-tests/media-source/mediasource-invalid-codec-expected.txt (0 => 270720)
--- trunk/LayoutTests/platform/mac-bigsur/imported/w3c/web-platform-tests/media-source/mediasource-invalid-codec-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/mac-bigsur/imported/w3c/web-platform-tests/media-source/mediasource-invalid-codec-expected.txt 2020-12-12 00:57:14 UTC (rev 270720)
@@ -0,0 +1,4 @@
+
+PASS Test an MP4 with an invalid codec results in an error.
+PASS Test a WebM with an invalid codec results in an error.
+
Modified: trunk/Source/ThirdParty/libwebrtc/ChangeLog (270719 => 270720)
--- trunk/Source/ThirdParty/libwebrtc/ChangeLog 2020-12-12 00:43:52 UTC (rev 270719)
+++ trunk/Source/ThirdParty/libwebrtc/ChangeLog 2020-12-12 00:57:14 UTC (rev 270720)
@@ -1,3 +1,46 @@
+2020-12-11 Jer Noble <[email protected]>
+
+ [Cocoa] Add Experimental VP8 support
+ https://bugs.webkit.org/show_bug.cgi?id=219732
+
+ Reviewed by Eric Carlson.
+
+ Add a new decoder for VP8 video using the decoder exposed by libwebrtc. Refactor
+ WebKitDecoderReceiver into its own file, to be used by both the VP8 and VP9 decoders.
+
+ * Configurations/libwebrtc.iOS.exp:
+ * Configurations/libwebrtc.iOSsim.exp:
+ * Configurations/libwebrtc.mac.exp:
+ * Source/webrtc/sdk/WebKit/WebKitDecoderReceiver.cpp: Added.
+ (webrtc::WebKitDecoderReceiver::WebKitDecoderReceiver):
+ (webrtc::WebKitDecoderReceiver::~WebKitDecoderReceiver):
+ (webrtc::WebKitDecoderReceiver::initializeFromFormatDescription):
+ (webrtc::WebKitDecoderReceiver::pixelBufferPool):
+ (webrtc::WebKitDecoderReceiver::decoderFailed):
+ (webrtc::WebKitDecoderReceiver::Decoded):
+ * Source/webrtc/sdk/WebKit/WebKitDecoderReceiver.h: Added
+ * Source/webrtc/sdk/WebKit/WebKitVP8Decoder.cpp: Added.
+ (webrtc::registerWebKitVP8Decoder):
+ (webrtc::createWebKitVP8Decoder):
+ (webrtc::invalidateVP8Decoder):
+ (webrtc::finalizeVP8Decoder):
+ (webrtc::copyVP8DecoderDebugDescription):
+ (webrtc::webKitVP8DecoderFromVTDecoder):
+ (webrtc::startVP8DecoderSession):
+ (webrtc::decodeVP8DecoderFrameFromContiguousBlock):
+ (webrtc::decodeVP8DecoderFrame):
+ * Source/webrtc/sdk/WebKit/WebKitVP8Decoder.h: Copied from Source/WebCore/platform/graphics/cocoa/VP9UtilitiesCocoa.h.
+ * Source/webrtc/sdk/WebKit/WebKitVP9Decoder.cpp:
+ (webrtc::createWebKitVP9Decoder):
+ (webrtc::startVP9DecoderSession):
+ (webrtc::WebKitVP9DecoderReceiver::WebKitVP9DecoderReceiver): Deleted.
+ (webrtc::WebKitVP9DecoderReceiver::~WebKitVP9DecoderReceiver): Deleted.
+ (webrtc::WebKitVP9DecoderReceiver::initializeFromFormatDescription): Deleted.
+ (webrtc::WebKitVP9DecoderReceiver::pixelBufferPool): Deleted.
+ (webrtc::WebKitVP9DecoderReceiver::decoderFailed): Deleted.
+ (webrtc::WebKitVP9DecoderReceiver::Decoded): Deleted.
+ * libwebrtc.xcodeproj/project.pbxproj:
+
2020-12-10 Youenn Fablet <[email protected]>
ICE does not resolve for `turns` relay candidates rooted in LetsEncrypt CA
Modified: trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOS.exp (270719 => 270720)
--- trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOS.exp 2020-12-12 00:43:52 UTC (rev 270719)
+++ trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOS.exp 2020-12-12 00:57:14 UTC (rev 270720)
@@ -101,6 +101,7 @@
__ZN6webrtc26createWebKitDecoderFactoryENS_10WebKitH265ENS_9WebKitVP9ENS_12WebKitVP9VTBE
__ZN6webrtc26createWebKitEncoderFactoryENS_10WebKitH265ENS_9WebKitVP9ENS_20WebKitH264LowLatencyE
__ZN6webrtc29setH264HardwareEncoderAllowedEb
+__ZN6webrtc24registerWebKitVP8DecoderEv
__ZN6webrtc24registerWebKitVP9DecoderEv
__ZN6webrtc20pixelBufferFromFrameERKNS_10VideoFrameERKNSt3__18functionIFP10__CVBuffermmNS_10BufferTypeEEEE
__ZN6webrtc18pixelBufferToFrameEP10__CVBuffer
Modified: trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOSsim.exp (270719 => 270720)
--- trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOSsim.exp 2020-12-12 00:43:52 UTC (rev 270719)
+++ trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOSsim.exp 2020-12-12 00:57:14 UTC (rev 270720)
@@ -101,6 +101,7 @@
__ZN6webrtc26createWebKitDecoderFactoryENS_10WebKitH265ENS_9WebKitVP9ENS_12WebKitVP9VTBE
__ZN6webrtc26createWebKitEncoderFactoryENS_10WebKitH265ENS_9WebKitVP9ENS_20WebKitH264LowLatencyE
__ZN6webrtc29setH264HardwareEncoderAllowedEb
+__ZN6webrtc24registerWebKitVP8DecoderEv
__ZN6webrtc24registerWebKitVP9DecoderEv
__ZN6webrtc20pixelBufferFromFrameERKNS_10VideoFrameERKNSt3__18functionIFP10__CVBuffermmNS_10BufferTypeEEEE
__ZN6webrtc18pixelBufferToFrameEP10__CVBuffer
Modified: trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.mac.exp (270719 => 270720)
--- trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.mac.exp 2020-12-12 00:43:52 UTC (rev 270719)
+++ trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.mac.exp 2020-12-12 00:57:14 UTC (rev 270720)
@@ -101,6 +101,7 @@
__ZN6webrtc26createWebKitDecoderFactoryENS_10WebKitH265ENS_9WebKitVP9ENS_12WebKitVP9VTBE
__ZN6webrtc26createWebKitEncoderFactoryENS_10WebKitH265ENS_9WebKitVP9ENS_20WebKitH264LowLatencyE
__ZN6webrtc29setH264HardwareEncoderAllowedEb
+__ZN6webrtc24registerWebKitVP8DecoderEv
__ZN6webrtc24registerWebKitVP9DecoderEv
__ZN6webrtc20pixelBufferFromFrameERKNS_10VideoFrameERKNSt3__18functionIFP10__CVBuffermmNS_10BufferTypeEEEE
__ZN6webrtc18pixelBufferToFrameEP10__CVBuffer
Modified: trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/VTVideoDecoderSPI.h (270719 => 270720)
--- trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/VTVideoDecoderSPI.h 2020-12-12 00:43:52 UTC (rev 270719)
+++ trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/VTVideoDecoderSPI.h 2020-12-12 00:57:14 UTC (rev 270720)
@@ -25,6 +25,9 @@
#pragma once
+#include <VideoToolbox/VideoToolbox.h>
+#include "CMBaseObjectSPI.h"
+
#if defined __has_include && __has_include(<CoreFoundation/CFPriv.h>)
#include <VideoToolbox/VTVideoDecoder.h>
#include <VideoToolbox/VTVideoDecoderRegistration.h>
Added: trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitDecoderReceiver.cpp (0 => 270720)
--- trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitDecoderReceiver.cpp (rev 0)
+++ trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitDecoderReceiver.cpp 2020-12-12 00:57:14 UTC (rev 270720)
@@ -0,0 +1,192 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "WebKitVP9Decoder.h"
+
+#include "WebKitDecoderReceiver.h"
+#include "modules/video_coding/include/video_error_codes.h"
+#include "rtc_base/logging.h"
+
+namespace webrtc {
+
+WebKitDecoderReceiver::WebKitDecoderReceiver(VTVideoDecoderSession session)
+ : m_session(session)
+{
+}
+
+WebKitDecoderReceiver::~WebKitDecoderReceiver()
+{
+ if (m_pixelBufferPool)
+ CFRelease(m_pixelBufferPool);
+}
+
+void WebKitDecoderReceiver::initializeFromFormatDescription(CMFormatDescriptionRef formatDescription)
+{
+ // CoreAnimation doesn't support full-planar YUV, so we must convert the buffers output
+ // by libvpx to bi-planar YUV. Create pixel buffer attributes and give those to the
+ // decoder session for use in creating its own internal CVPixelBufferPool, which we
+ // will use post-decode.
+ m_isFullRange = false;
+ m_is10bit = false;
+
+ auto extensions = CMFormatDescriptionGetExtensions(formatDescription);
+ if (!extensions)
+ return;
+
+ CFTypeRef extensionAtoms = CFDictionaryGetValue(extensions, kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms);
+ if (!extensionAtoms || CFGetTypeID(extensionAtoms) != CFDictionaryGetTypeID())
+ return;
+
+ auto configurationRecord = static_cast<CFDataRef>(CFDictionaryGetValue((CFDictionaryRef)extensionAtoms, CFSTR("vpcC")));
+ if (!configurationRecord || CFGetTypeID(configurationRecord) != CFDataGetTypeID())
+ return;
+
+ auto configurationRecordSize = CFDataGetLength(configurationRecord);
+ if (configurationRecordSize < 12)
+ return;
+
+ auto configurationRecordData = CFDataGetBytePtr(configurationRecord);
+ auto bitDepthChromaAndRange = *(configurationRecordData + 6);
+
+ if ((bitDepthChromaAndRange >> 4) == 10)
+ m_is10bit = true;
+
+ if (bitDepthChromaAndRange & 0x1)
+ m_isFullRange = true;
+}
+
+CVPixelBufferPoolRef WebKitDecoderReceiver::pixelBufferPool(size_t pixelBufferWidth, size_t pixelBufferHeight, bool is10bit)
+{
+ if (m_pixelBufferPool && m_pixelBufferWidth == pixelBufferWidth && m_pixelBufferHeight == pixelBufferHeight && m_is10bit == is10bit)
+ return m_pixelBufferPool;
+
+ OSType pixelFormat;
+ if (is10bit)
+ pixelFormat = m_isFullRange ? kCVPixelFormatType_420YpCbCr10BiPlanarFullRange : kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange;
+ else
+ pixelFormat = m_isFullRange ? kCVPixelFormatType_420YpCbCr8BiPlanarFullRange : kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange;
+
+ auto createPixelFormatAttributes = [] (OSType pixelFormat) {
+ auto createNumber = [] (int32_t format) -> CFNumberRef {
+ return CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &format);
+ };
+ auto cfPixelFormats = CFArrayCreateMutable(kCFAllocatorDefault, 2, &kCFTypeArrayCallBacks);
+ auto formatNumber = createNumber(pixelFormat);
+ CFArrayAppendValue(cfPixelFormats, formatNumber);
+ CFRelease(formatNumber);
+
+ auto borderPixelsValue = createNumber(32);
+
+ const void* keys[] = {
+ kCVPixelBufferPixelFormatTypeKey,
+ kCVPixelBufferExtendedPixelsLeftKey,
+ kCVPixelBufferExtendedPixelsRightKey,
+ kCVPixelBufferExtendedPixelsTopKey,
+ kCVPixelBufferExtendedPixelsBottomKey,
+ };
+ const void* values[] = {
+ cfPixelFormats,
+ borderPixelsValue,
+ borderPixelsValue,
+ borderPixelsValue,
+ borderPixelsValue,
+ };
+ auto attributes = CFDictionaryCreate(kCFAllocatorDefault, keys, values, std::size(keys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+ CFRelease(borderPixelsValue);
+ CFRelease(cfPixelFormats);
+ return attributes;
+ };
+
+ auto pixelBufferAttributes = createPixelFormatAttributes(pixelFormat);
+ VTDecoderSessionSetPixelBufferAttributes(m_session, pixelBufferAttributes);
+ CFRelease(pixelBufferAttributes);
+
+ if (m_pixelBufferPool) {
+ CFRelease(m_pixelBufferPool);
+ m_pixelBufferPool = nullptr;
+ }
+
+ m_pixelBufferPool = VTDecoderSessionGetPixelBufferPool(m_session);
+ if (m_pixelBufferPool)
+ CFRetain(m_pixelBufferPool);
+
+ m_pixelBufferWidth = pixelBufferWidth;
+ m_pixelBufferHeight = pixelBufferHeight;
+ m_is10bit = is10bit;
+
+ return m_pixelBufferPool;
+}
+
+OSStatus WebKitDecoderReceiver::decoderFailed(int error)
+{
+ OSStatus vtError;
+ if (error == WEBRTC_VIDEO_CODEC_NO_OUTPUT)
+ vtError = noErr;
+ else if (error == WEBRTC_VIDEO_CODEC_UNINITIALIZED)
+ vtError = kVTVideoDecoderMalfunctionErr;
+ else if (error == WEBRTC_VIDEO_CODEC_MEMORY)
+ vtError = kVTAllocationFailedErr;
+ else
+ vtError = kVTVideoDecoderBadDataErr;
+
+ VTDecoderSessionEmitDecodedFrame(m_session, m_currentFrame, vtError, 0, nullptr);
+ m_currentFrame = nullptr;
+
+ RTC_LOG(LS_ERROR) << "VP9 decoder: decoder failed with error " << error << ", vtError " << vtError;
+ return vtError;
+}
+
+int32_t WebKitDecoderReceiver::Decoded(VideoFrame& frame)
+{
+ auto pixelBuffer = pixelBufferFromFrame(frame, [this](size_t width, size_t height, BufferType type) -> CVPixelBufferRef {
+ auto pixelBufferPool = this->pixelBufferPool(width, height, type == BufferType::I010);
+ if (!pixelBufferPool)
+ return nullptr;
+
+ CVPixelBufferRef pixelBuffer = nullptr;
+ if (CVPixelBufferPoolCreatePixelBuffer(kCFAllocatorDefault, m_pixelBufferPool, &pixelBuffer) == kCVReturnSuccess)
+ return pixelBuffer;
+ return nullptr;
+ });
+
+ VTDecoderSessionEmitDecodedFrame(m_session, m_currentFrame, pixelBuffer ? noErr : -1, 0, pixelBuffer);
+ m_currentFrame = nullptr;
+ if (pixelBuffer)
+ CFRelease(pixelBuffer);
+ return 0;
+}
+
+int32_t WebKitDecoderReceiver::Decoded(VideoFrame& frame, int64_t)
+{
+ Decoded(frame);
+ return 0;
+}
+
+void WebKitDecoderReceiver::Decoded(VideoFrame& frame, absl::optional<int32_t>, absl::optional<uint8_t>)
+{
+ Decoded(frame);
+}
+
+}
Copied: trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitDecoderReceiver.h (from rev 270719, trunk/Source/WebCore/platform/graphics/cocoa/VP9UtilitiesCocoa.h) (0 => 270720)
--- trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitDecoderReceiver.h (rev 0)
+++ trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitDecoderReceiver.h 2020-12-12 00:57:14 UTC (rev 270720)
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "api/video_codecs/video_decoder.h"
+#include "VTVideoDecoderSPI.h"
+#include "WebKitUtilities.h"
+
+namespace webrtc {
+
+class WebKitDecoderReceiver final : public DecodedImageCallback {
+public:
+ explicit WebKitDecoderReceiver(VTVideoDecoderSession);
+ ~WebKitDecoderReceiver();
+
+ VTVideoDecoderFrame currentFrame() const { return m_currentFrame; }
+ void setCurrentFrame(VTVideoDecoderFrame currentFrame) { m_currentFrame = currentFrame; }
+ OSStatus decoderFailed(int error);
+
+ void initializeFromFormatDescription(CMFormatDescriptionRef);
+
+private:
+ int32_t Decoded(VideoFrame&) final;
+ int32_t Decoded(VideoFrame&, int64_t decode_time_ms) final;
+ void Decoded(VideoFrame&, absl::optional<int32_t> decode_time_ms, absl::optional<uint8_t> qp) final;
+
+ CVPixelBufferPoolRef pixelBufferPool(size_t pixelBufferWidth, size_t pixelBufferHeight, bool is10bit);
+
+ VTVideoDecoderSession m_session { nullptr };
+ VTVideoDecoderFrame m_currentFrame { nullptr };
+ size_t m_pixelBufferWidth { 0 };
+ size_t m_pixelBufferHeight { 0 };
+ bool m_is10bit { false };
+ bool m_isFullRange { false };
+ CVPixelBufferPoolRef m_pixelBufferPool { nullptr };
+};
+
+}
Added: trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitVP8Decoder.cpp (0 => 270720)
--- trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitVP8Decoder.cpp (rev 0)
+++ trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitVP8Decoder.cpp 2020-12-12 00:57:14 UTC (rev 270720)
@@ -0,0 +1,221 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "WebKitVP8Decoder.h"
+
+#include "WebKitDecoderReceiver.h"
+#include "modules/video_coding/codecs/vp8/libvpx_vp8_decoder.h"
+#include "rtc_base/logging.h"
+#include "system_wrappers/include/cpu_info.h"
+
+namespace webrtc {
+
+static OSStatus createWebKitVP8Decoder(FigVideoCodecType, CFAllocatorRef allocator, VTVideoDecoderRef*);
+void registerWebKitVP8Decoder()
+{
+ VTRegisterVideoDecoder('vp08', createWebKitVP8Decoder);
+}
+
+typedef struct {
+ std::unique_ptr<LibvpxVp8Decoder> m_instance;
+ std::unique_ptr<WebKitDecoderReceiver> m_receiver;
+} WebKitVP8Decoder;
+
+static OSStatus invalidateVP8Decoder(CMBaseObjectRef);
+static void finalizeVP8Decoder(CMBaseObjectRef);
+static CFStringRef copyVP8DecoderDebugDescription(CMBaseObjectRef);
+
+static const CMBaseClass WebKitVP8Decoder_BaseClass =
+{
+ kCMBaseObject_ClassVersion_1,
+ sizeof(WebKitVP8Decoder),
+ nullptr, // Comparison by pointer equality
+ invalidateVP8Decoder,
+ finalizeVP8Decoder,
+ copyVP8DecoderDebugDescription,
+ nullptr, // CopyProperty
+ nullptr, // SetProperty
+ nullptr,
+ nullptr
+};
+
+static OSStatus startVP8DecoderSession(VTVideoDecoderRef, VTVideoDecoderSession, CMVideoFormatDescriptionRef);
+static OSStatus decodeVP8DecoderFrame(VTVideoDecoderRef, VTVideoDecoderFrame, CMSampleBufferRef, VTDecodeFrameFlags, VTDecodeInfoFlags*);
+
+static const VTVideoDecoderClass WebKitVP8Decoder_VideoDecoderClass =
+{
+ kVTVideoDecoder_ClassVersion_1,
+ startVP8DecoderSession,
+ decodeVP8DecoderFrame,
+ nullptr, // VTVideoDecoderFunction_CopySupportedPropertyDictionary,
+ nullptr, // VTVideoDecoderFunction_SetProperties
+ nullptr, // VTVideoDecoderFunction_CopySerializableProperties
+ nullptr, // VTVideoDecoderFunction_CanAcceptFormatDescription
+ nullptr, // VTVideoDecoderFunction_FinishDelayedFrames
+ nullptr, // VTVideoDecoderFunction_StartTileSession
+ nullptr, // VTVideoDecoderFunction_DecodeTile
+ nullptr // VTVideoDecoderFunction_FinishDelayedTiles
+};
+
+static const VTVideoDecoderVTable WebKitVP8DecoderVTable =
+{
+ { nullptr, &WebKitVP8Decoder_BaseClass },
+ &WebKitVP8Decoder_VideoDecoderClass
+};
+
+OSStatus createWebKitVP8Decoder(FigVideoCodecType, CFAllocatorRef allocator, VTVideoDecoderRef* decoderOut)
+{
+ if (!decoderOut) {
+ RTC_LOG(LS_ERROR) << "VP8 decoder creation failed, no decoder output";
+ return kVTParameterErr;
+ }
+
+ VTVideoDecoderRef decoder = nullptr;
+ auto error = CMDerivedObjectCreate(allocator, &WebKitVP8DecoderVTable.base, VTVideoDecoderGetClassID(), (CMBaseObjectRef*)&decoder);
+
+ if (!decoder) {
+ RTC_LOG(LS_ERROR) << "VP8 decoder creation failed, CMDerivedObjectCreate failed with error " << error;
+ return kVTAllocationFailedErr;
+ }
+
+ if(error) {
+ CFRelease(decoder);
+ decoder = NULL;
+ }
+ *decoderOut = decoder;
+ return error;
+}
+
+OSStatus invalidateVP8Decoder(CMBaseObjectRef instance)
+{
+ auto* decoder = static_cast<WebKitVP8Decoder*>(CMBaseObjectGetDerivedStorage(instance));
+ if (!decoder)
+ RTC_LOG(LS_ERROR) << "VP8 decoder: invalidation failed as instance has no decoder";
+ else {
+ decoder->m_instance = nullptr;
+ decoder->m_receiver = nullptr;
+ }
+ return noErr;
+}
+
+void finalizeVP8Decoder(CMBaseObjectRef instance)
+{
+ invalidateVP8Decoder(instance);
+}
+
+CFStringRef copyVP8DecoderDebugDescription(CMBaseObjectRef)
+{
+ return CFSTR("WebKit VP8 decoder");
+}
+
+WebKitVP8Decoder* webKitVP8DecoderFromVTDecoder(VTVideoDecoderRef decoder)
+{
+ return static_cast<WebKitVP8Decoder*>(CMBaseObjectGetDerivedStorage(reinterpret_cast<CMBaseObjectRef>(decoder)));
+}
+OSStatus startVP8DecoderSession(VTVideoDecoderRef instance, VTVideoDecoderSession session, CMVideoFormatDescriptionRef formatDescription)
+{
+ auto* decoder = webKitVP8DecoderFromVTDecoder(instance);
+ if (!decoder) {
+ RTC_LOG(LS_ERROR) << "VP8 decoder: failed to get decoder from instance while starting";
+ return kVTParameterErr;
+ }
+
+ decoder->m_instance = std::make_unique<LibvpxVp8Decoder>();
+ decoder->m_receiver = std::make_unique<WebKitDecoderReceiver>(session);
+ decoder->m_receiver->initializeFromFormatDescription(formatDescription);
+
+ decoder->m_instance->RegisterDecodeCompleteCallback(decoder->m_receiver.get());
+
+ VideoCodec codec;
+ auto dimensions = CMVideoFormatDescriptionGetDimensions(formatDescription);
+ codec.width = dimensions.width;
+ codec.height = dimensions.height;
+
+ decoder->m_instance->InitDecode(&codec, CpuInfo::DetectNumberOfCores());
+
+ return noErr;
+}
+
+static OSStatus decodeVP8DecoderFrameFromContiguousBlock(WebKitVP8Decoder& decoder, VTVideoDecoderFrame frame, CMBlockBufferRef encodedBuffer)
+{
+ RTC_DCHECK(CMBlockBufferIsRangeContiguous(encodedBuffer, 0, 0));
+
+ auto size = CMBlockBufferGetDataLength(encodedBuffer);
+ char* data = ""
+ if (auto error = CMBlockBufferGetDataPointer(encodedBuffer, 0, nullptr, nullptr, &data)) {
+ RTC_LOG(LS_ERROR) << "VP8 decoder: CMBlockBufferGetDataPointer failed with error " << error;
+ return error;
+ }
+
+ RTC_DCHECK(!decoder.m_receiver->currentFrame());
+ decoder.m_receiver->setCurrentFrame(frame);
+
+ EncodedImage image { reinterpret_cast<uint8_t*>(data), size, size };
+ // We set those values as VP8DecoderImpl checks for getting a full key frame as first frame.
+ image._frameType = VideoFrameType::kVideoFrameKey;
+ image._completeFrame = true;
+ auto error = decoder.m_instance->Decode(image, false, 0);
+ if (error)
+ return decoder.m_receiver->decoderFailed(error);
+
+ RTC_DCHECK(!decoder.m_receiver->currentFrame());
+
+ return 0;
+}
+
+OSStatus decodeVP8DecoderFrame(VTVideoDecoderRef instance, VTVideoDecoderFrame frame, CMSampleBufferRef sampleBuffer, VTDecodeFrameFlags, VTDecodeInfoFlags*)
+{
+ auto* decoder = webKitVP8DecoderFromVTDecoder(instance);
+ if (!decoder || !decoder->m_instance || !decoder->m_receiver) {
+ RTC_LOG(LS_ERROR) << "VP8 decoder: failed to get decoder from instance while decoding";
+ return kVTParameterErr;
+ }
+
+ auto encodedBuffer = CMSampleBufferGetDataBuffer(sampleBuffer);
+ if (!encodedBuffer) {
+ RTC_LOG(LS_ERROR) << "VP8 decoder: failed to get data buffer";
+ return kVTParameterErr;
+ }
+
+ CMBlockBufferRef contiguousBuffer = nullptr;
+ // Make sure block buffer is contiguous.
+ if (!CMBlockBufferIsRangeContiguous(encodedBuffer, 0, 0)) {
+ auto status = CMBlockBufferCreateContiguous(nullptr, encodedBuffer, nullptr, nullptr, 0, 0, 0, &contiguousBuffer);
+ if (status != noErr) {
+ RTC_LOG(LS_ERROR) << "VP8 decoder: failed to create contiguous block buffer with error " << status;
+ return kVTAllocationFailedErr;
+ }
+ encodedBuffer = contiguousBuffer;
+ }
+
+ auto result = decodeVP8DecoderFrameFromContiguousBlock(*decoder, frame, encodedBuffer);
+
+ if (contiguousBuffer)
+ CFRelease(contiguousBuffer);
+
+ return result;
+}
+
+}
Copied: trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitVP8Decoder.h (from rev 270719, trunk/Source/WebCore/platform/graphics/cocoa/VP9UtilitiesCocoa.h) (0 => 270720)
--- trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitVP8Decoder.h (rev 0)
+++ trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitVP8Decoder.h 2020-12-12 00:57:14 UTC (rev 270720)
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+namespace webrtc {
+
+void registerWebKitVP8Decoder();
+
+}
Modified: trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitVP9Decoder.cpp (270719 => 270720)
--- trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitVP9Decoder.cpp 2020-12-12 00:43:52 UTC (rev 270719)
+++ trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitVP9Decoder.cpp 2020-12-12 00:57:14 UTC (rev 270720)
@@ -25,15 +25,11 @@
#include "WebKitVP9Decoder.h"
-#include "WebKitUtilities.h"
-#include <VideoToolbox/VideoToolbox.h>
+#include "WebKitDecoderReceiver.h"
#include "modules/video_coding/codecs/vp9/vp9_impl.h"
#include "rtc_base/logging.h"
#include "system_wrappers/include/cpu_info.h"
-#include "CMBaseObjectSPI.h"
-#include "VTVideoDecoderSPI.h"
-
namespace webrtc {
static OSStatus createWebKitVP9Decoder(FigVideoCodecType, CFAllocatorRef allocator, VTVideoDecoderRef*);
@@ -42,39 +38,11 @@
VTRegisterVideoDecoder('vp09', createWebKitVP9Decoder);
}
-class WebKitVP9DecoderReceiver;
typedef struct {
std::unique_ptr<VP9DecoderImpl> m_instance;
- std::unique_ptr<WebKitVP9DecoderReceiver> m_receiver;
+ std::unique_ptr<WebKitDecoderReceiver> m_receiver;
} WebKitVP9Decoder;
-class WebKitVP9DecoderReceiver final : public DecodedImageCallback {
-public:
- explicit WebKitVP9DecoderReceiver(VTVideoDecoderSession);
- ~WebKitVP9DecoderReceiver();
-
- VTVideoDecoderFrame currentFrame() const { return m_currentFrame; }
- void setCurrentFrame(VTVideoDecoderFrame currentFrame) { m_currentFrame = currentFrame; }
- OSStatus decoderFailed(int error);
-
- void initializeFromFormatDescription(CMFormatDescriptionRef);
-
-private:
- int32_t Decoded(VideoFrame&) final;
- int32_t Decoded(VideoFrame&, int64_t decode_time_ms) final;
- void Decoded(VideoFrame&, absl::optional<int32_t> decode_time_ms, absl::optional<uint8_t> qp) final;
-
- CVPixelBufferPoolRef pixelBufferPool(size_t pixelBufferWidth, size_t pixelBufferHeight, bool is10bit);
-
- VTVideoDecoderSession m_session { nullptr };
- VTVideoDecoderFrame m_currentFrame { nullptr };
- size_t m_pixelBufferWidth { 0 };
- size_t m_pixelBufferHeight { 0 };
- bool m_is10bit { false };
- bool m_isFullRange { false };
- CVPixelBufferPoolRef m_pixelBufferPool { nullptr };
-};
-
static OSStatus invalidateVP9Decoder(CMBaseObjectRef);
static void finalizeVP9Decoder(CMBaseObjectRef);
static CFStringRef copyVP9DecoderDebugDescription(CMBaseObjectRef);
@@ -175,7 +143,7 @@
}
decoder->m_instance = std::make_unique<VP9DecoderImpl>();
- decoder->m_receiver = std::make_unique<WebKitVP9DecoderReceiver>(session);
+ decoder->m_receiver = std::make_unique<WebKitDecoderReceiver>(session);
decoder->m_receiver->initializeFromFormatDescription(formatDescription);
decoder->m_instance->RegisterDecodeCompleteCallback(decoder->m_receiver.get());
@@ -250,161 +218,4 @@
return result;
}
-WebKitVP9DecoderReceiver::WebKitVP9DecoderReceiver(VTVideoDecoderSession session)
- : m_session(session)
-{
}
-
-WebKitVP9DecoderReceiver::~WebKitVP9DecoderReceiver()
-{
- if (m_pixelBufferPool)
- CFRelease(m_pixelBufferPool);
-}
-
-void WebKitVP9DecoderReceiver::initializeFromFormatDescription(CMFormatDescriptionRef formatDescription)
-{
- // CoreAnimation doesn't support full-planar YUV, so we must convert the buffers output
- // by libvpx to bi-planar YUV. Create pixel buffer attributes and give those to the
- // decoder session for use in creating its own internal CVPixelBufferPool, which we
- // will use post-decode.
- m_isFullRange = false;
- m_is10bit = false;
-
- do {
- auto extensions = CMFormatDescriptionGetExtensions(formatDescription);
- if (!extensions)
- break;
-
- CFTypeRef extensionAtoms = CFDictionaryGetValue(extensions, kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms);
- if (!extensionAtoms || CFGetTypeID(extensionAtoms) != CFDictionaryGetTypeID())
- break;
-
- auto configurationRecord = static_cast<CFDataRef>(CFDictionaryGetValue((CFDictionaryRef)extensionAtoms, CFSTR("vpcC")));
- if (!configurationRecord || CFGetTypeID(configurationRecord) != CFDataGetTypeID())
- break;
-
- auto configurationRecordSize = CFDataGetLength(configurationRecord);
- if (configurationRecordSize < 12)
- break;
-
- auto configurationRecordData = CFDataGetBytePtr(configurationRecord);
- auto bitDepthChromaAndRange = *(configurationRecordData + 6);
-
- if ((bitDepthChromaAndRange >> 4) == 10)
- m_is10bit = true;
-
- if (bitDepthChromaAndRange & 0x1)
- m_isFullRange = true;
- } while (false);
-}
-
-CVPixelBufferPoolRef WebKitVP9DecoderReceiver::pixelBufferPool(size_t pixelBufferWidth, size_t pixelBufferHeight, bool is10bit)
-{
- if (m_pixelBufferPool && m_pixelBufferWidth == pixelBufferWidth && m_pixelBufferHeight == pixelBufferHeight && m_is10bit == is10bit)
- return m_pixelBufferPool;
-
- OSType pixelFormat;
- if (is10bit)
- pixelFormat = m_isFullRange ? kCVPixelFormatType_420YpCbCr10BiPlanarFullRange : kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange;
- else
- pixelFormat = m_isFullRange ? kCVPixelFormatType_420YpCbCr8BiPlanarFullRange : kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange;
-
- auto createPixelFormatAttributes = [] (OSType pixelFormat, int32_t borderPixels) {
- auto createNumber = [] (int32_t format) -> CFNumberRef {
- return CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &format);
- };
- auto cfPixelFormats = CFArrayCreateMutable(kCFAllocatorDefault, 2, &kCFTypeArrayCallBacks);
- auto formatNumber = createNumber(pixelFormat);
- CFArrayAppendValue(cfPixelFormats, formatNumber);
- CFRelease(formatNumber);
-
- auto borderPixelsValue = createNumber(32);
-
- const void* keys[] = {
- kCVPixelBufferPixelFormatTypeKey,
- kCVPixelBufferExtendedPixelsLeftKey,
- kCVPixelBufferExtendedPixelsRightKey,
- kCVPixelBufferExtendedPixelsTopKey,
- kCVPixelBufferExtendedPixelsBottomKey,
- };
- const void* values[] = {
- cfPixelFormats,
- borderPixelsValue,
- borderPixelsValue,
- borderPixelsValue,
- borderPixelsValue,
- };
- auto attributes = CFDictionaryCreate(kCFAllocatorDefault, keys, values, std::size(keys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
- CFRelease(borderPixelsValue);
- CFRelease(cfPixelFormats);
- return attributes;
- };
-
- auto pixelBufferAttributes = createPixelFormatAttributes(pixelFormat, 32);
- VTDecoderSessionSetPixelBufferAttributes(m_session, pixelBufferAttributes);
- CFRelease(pixelBufferAttributes);
-
- if (m_pixelBufferPool) {
- CFRelease(m_pixelBufferPool);
- m_pixelBufferPool = nullptr;
- }
-
- m_pixelBufferPool = VTDecoderSessionGetPixelBufferPool(m_session);
- if (m_pixelBufferPool)
- CFRetain(m_pixelBufferPool);
-
- m_pixelBufferWidth = pixelBufferWidth;
- m_pixelBufferHeight = pixelBufferHeight;
- m_is10bit = is10bit;
-
- return m_pixelBufferPool;
-}
-
-OSStatus WebKitVP9DecoderReceiver::decoderFailed(int error)
-{
- OSStatus vtError = kVTVideoDecoderBadDataErr;
- if (error == WEBRTC_VIDEO_CODEC_NO_OUTPUT)
- vtError = noErr;
- else if (error == WEBRTC_VIDEO_CODEC_UNINITIALIZED)
- vtError = kVTVideoDecoderMalfunctionErr;
- else if (error == WEBRTC_VIDEO_CODEC_MEMORY)
- vtError = kVTAllocationFailedErr;
- VTDecoderSessionEmitDecodedFrame(m_session, m_currentFrame, vtError, 0, nullptr);
- m_currentFrame = nullptr;
-
- RTC_LOG(LS_ERROR) << "VP9 decoder: decoder failed with error " << error << ", vtError " << vtError;
- return vtError;
-}
-
-int32_t WebKitVP9DecoderReceiver::Decoded(VideoFrame& frame)
-{
- auto pixelBuffer = pixelBufferFromFrame(frame, [this](size_t width, size_t height, BufferType type) -> CVPixelBufferRef {
- auto pixelBufferPool = this->pixelBufferPool(width, height, type == BufferType::I010);
- if (!pixelBufferPool)
- return nullptr;
-
- CVPixelBufferRef pixelBuffer = nullptr;
- if (CVPixelBufferPoolCreatePixelBuffer(kCFAllocatorDefault, m_pixelBufferPool, &pixelBuffer) == kCVReturnSuccess)
- return pixelBuffer;
- return nullptr;
- });
-
- VTDecoderSessionEmitDecodedFrame(m_session, m_currentFrame, pixelBuffer ? noErr : -1, 0, pixelBuffer);
- m_currentFrame = nullptr;
- if (pixelBuffer)
- CFRelease(pixelBuffer);
- return 0;
-}
-
-int32_t WebKitVP9DecoderReceiver::Decoded(VideoFrame& frame, int64_t)
-{
- Decoded(frame);
- return 0;
-}
-
-void WebKitVP9DecoderReceiver::Decoded(VideoFrame& frame, absl::optional<int32_t>, absl::optional<uint8_t>)
-{
- Decoded(frame);
-}
-
-}
Modified: trunk/Source/ThirdParty/libwebrtc/libwebrtc.xcodeproj/project.pbxproj (270719 => 270720)
--- trunk/Source/ThirdParty/libwebrtc/libwebrtc.xcodeproj/project.pbxproj 2020-12-12 00:43:52 UTC (rev 270719)
+++ trunk/Source/ThirdParty/libwebrtc/libwebrtc.xcodeproj/project.pbxproj 2020-12-12 00:57:14 UTC (rev 270720)
@@ -3909,6 +3909,10 @@
5CFD53921E4BD3A300482908 /* row_neon64.cc in Sources */ = {isa = PBXBuildFile; fileRef = 5CFD538A1E4BD3A300482908 /* row_neon64.cc */; };
5CFD53931E4BD3A300482908 /* scale_neon.cc in Sources */ = {isa = PBXBuildFile; fileRef = 5CFD538B1E4BD3A300482908 /* scale_neon.cc */; };
5CFD53941E4BD3A300482908 /* scale_neon64.cc in Sources */ = {isa = PBXBuildFile; fileRef = 5CFD538C1E4BD3A300482908 /* scale_neon64.cc */; };
+ CD381F272581591F0077DEC8 /* WebKitVP8Decoder.h in Headers */ = {isa = PBXBuildFile; fileRef = CD381F252581591F0077DEC8 /* WebKitVP8Decoder.h */; };
+ CD381F292581591F0077DEC8 /* WebKitVP8Decoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD381F282581591F0077DEC8 /* WebKitVP8Decoder.cpp */; };
+ CD381F2B2581FEBA0077DEC8 /* WebKitDecoderReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD381F2A2581FEBA0077DEC8 /* WebKitDecoderReceiver.cpp */; };
+ CD381F2D2581FF0B0077DEC8 /* WebKitDecoderReceiver.h in Headers */ = {isa = PBXBuildFile; fileRef = CD381F2C2581FF0B0077DEC8 /* WebKitDecoderReceiver.h */; };
CDEBB4B624C019C400ADBD44 /* unknown_parser.cc in Sources */ = {isa = PBXBuildFile; fileRef = CDEBB46424C0191A00ADBD44 /* unknown_parser.cc */; };
CDEBB4B724C019C400ADBD44 /* master_parser.cc in Sources */ = {isa = PBXBuildFile; fileRef = CDEBB46F24C0191A00ADBD44 /* master_parser.cc */; };
CDEBB4B824C019C400ADBD44 /* block_parser.cc in Sources */ = {isa = PBXBuildFile; fileRef = CDEBB47624C0191A00ADBD44 /* block_parser.cc */; };
@@ -8432,6 +8436,10 @@
5D7C59C61208C68B001C873E /* Base.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Base.xcconfig; sourceTree = "<group>"; };
5D7C59C71208C68B001C873E /* DebugRelease.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = DebugRelease.xcconfig; sourceTree = "<group>"; };
A1B89B8A221E004C00EB4CEA /* SDKVariant.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = SDKVariant.xcconfig; sourceTree = "<group>"; };
+ CD381F252581591F0077DEC8 /* WebKitVP8Decoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitVP8Decoder.h; sourceTree = "<group>"; };
+ CD381F282581591F0077DEC8 /* WebKitVP8Decoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebKitVP8Decoder.cpp; sourceTree = "<group>"; };
+ CD381F2A2581FEBA0077DEC8 /* WebKitDecoderReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebKitDecoderReceiver.cpp; sourceTree = "<group>"; };
+ CD381F2C2581FF0B0077DEC8 /* WebKitDecoderReceiver.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebKitDecoderReceiver.h; sourceTree = "<group>"; };
CDEBB11924C0187400ADBD44 /* libwebm.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libwebm.a; sourceTree = BUILT_PRODUCTS_DIR; };
CDEBB11E24C0189600ADBD44 /* libwebm.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = libwebm.xcconfig; sourceTree = "<group>"; };
CDEBB40524C0191A00ADBD44 /* reader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = reader.h; sourceTree = "<group>"; };
@@ -10962,10 +10970,14 @@
412FF935253D8F0A001DF036 /* VTVideoDecoderSPI.h */,
41E84BC92434C4A200D34E41 /* WebKitDecoder.h */,
41E84BCA2434C4A300D34E41 /* WebKitDecoder.mm */,
+ CD381F2A2581FEBA0077DEC8 /* WebKitDecoderReceiver.cpp */,
+ CD381F2C2581FF0B0077DEC8 /* WebKitDecoderReceiver.h */,
4158649623BE05E800A0A61E /* WebKitEncoder.h */,
4158649723BE05E900A0A61E /* WebKitEncoder.mm */,
41ECEABB206403C1009D5141 /* WebKitUtilities.h */,
41ECEABD20640498009D5141 /* WebKitUtilities.mm */,
+ CD381F282581591F0077DEC8 /* WebKitVP8Decoder.cpp */,
+ CD381F252581591F0077DEC8 /* WebKitVP8Decoder.h */,
414037BA24AC76E900BCE9B2 /* WebKitVP9Decoder.cpp */,
414037B924AC76E900BCE9B2 /* WebKitVP9Decoder.h */,
);
@@ -17496,8 +17508,10 @@
5C4B4C811E431F9C002651C8 /* wav_file.h in Headers */,
5C4B4C841E431F9C002651C8 /* wav_header.h in Headers */,
4131C163234B89E20028A615 /* weak_ptr.h in Headers */,
+ CD381F2D2581FF0B0077DEC8 /* WebKitDecoderReceiver.h in Headers */,
4158649823BE05E900A0A61E /* WebKitEncoder.h in Headers */,
41ECEABC206403C2009D5141 /* WebKitUtilities.h in Headers */,
+ CD381F272581591F0077DEC8 /* WebKitVP8Decoder.h in Headers */,
414037BB24AC76EA00BCE9B2 /* WebKitVP9Decoder.h in Headers */,
5CDD8CAB1E43C6F700621E92 /* webrtc_cng.h in Headers */,
4145E4911EF88EF700FCF6E6 /* webrtc_libyuv.h in Headers */,
@@ -20039,8 +20053,10 @@
5C4B4C831E431F9C002651C8 /* wav_header.cc in Sources */,
4131C0F9234B89E20028A615 /* weak_ptr.cc in Sources */,
41E84BD524373F7200D34E41 /* WebKitDecoder.mm in Sources */,
+ CD381F2B2581FEBA0077DEC8 /* WebKitDecoderReceiver.cpp in Sources */,
4158649923BE05E900A0A61E /* WebKitEncoder.mm in Sources */,
41ECEABE20640498009D5141 /* WebKitUtilities.mm in Sources */,
+ CD381F292581591F0077DEC8 /* WebKitVP8Decoder.cpp in Sources */,
414037BC24AC76EA00BCE9B2 /* WebKitVP9Decoder.cpp in Sources */,
5CDD8CAA1E43C6F700621E92 /* webrtc_cng.cc in Sources */,
5CDD83671E4325D500621E92 /* webrtc_libyuv.cc in Sources */,
Modified: trunk/Source/WTF/ChangeLog (270719 => 270720)
--- trunk/Source/WTF/ChangeLog 2020-12-12 00:43:52 UTC (rev 270719)
+++ trunk/Source/WTF/ChangeLog 2020-12-12 00:57:14 UTC (rev 270720)
@@ -1,3 +1,14 @@
+2020-12-11 Jer Noble <[email protected]>
+
+ [Cocoa] Add Experimental VP8 support
+ https://bugs.webkit.org/show_bug.cgi?id=219732
+
+ Reviewed by Eric Carlson.
+
+ Add a new VP8 experimental feature flag.
+
+ * Scripts/Preferences/WebPreferencesExperimental.yaml:
+
2020-12-11 Tim Horton <[email protected]>
Trackpad and Mouse scroll events on iPad only fire "pointermove" -- not "wheel"
Modified: trunk/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml (270719 => 270720)
--- trunk/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml 2020-12-12 00:43:52 UTC (rev 270719)
+++ trunk/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml 2020-12-12 00:57:14 UTC (rev 270720)
@@ -852,6 +852,16 @@
WebKit:
default: true
+VP8DecoderEnabled:
+ type: bool
+ humanReadableName: "VP8 decoder"
+ humanReadableDescription: "Enable VP8 decoder"
+ webcoreBinding: none
+ condition: ENABLE(VP9)
+ defaultValue:
+ WebKit:
+ default: WebKit::defaultVP8DecoderEnabled()
+
# FIXME: Is this implemented for WebKitLegacy? If not, this should be excluded from WebKitLegacy entirely.
VP9DecoderEnabled:
type: bool
Modified: trunk/Source/WebCore/ChangeLog (270719 => 270720)
--- trunk/Source/WebCore/ChangeLog 2020-12-12 00:43:52 UTC (rev 270719)
+++ trunk/Source/WebCore/ChangeLog 2020-12-12 00:57:14 UTC (rev 270720)
@@ -1,3 +1,45 @@
+2020-12-11 Jer Noble <[email protected]>
+
+ [Cocoa] Add Experimental VP8 support
+ https://bugs.webkit.org/show_bug.cgi?id=219732
+
+ Reviewed by Eric Carlson.
+
+ Newly passing tests:
+ imported/w3c/web-platform-tests/media-source/mediasource-addsourcebuffer.html
+ imported/w3c/web-platform-tests/media-source/mediasource-seek-during-pending-seek.html
+ imported/w3c/web-platform-tests/media-source/mediasource-seekable.html
+ imported/w3c/web-platform-tests/media-source/mediasource-config-change-webm-v-bitrate.html
+ imported/w3c/web-platform-tests/media-source/mediasource-config-change-webm-v-framerate.html
+ imported/w3c/web-platform-tests/media-source/mediasource-config-change-webm-v-framesize.html
+ imported/w3c/web-platform-tests/media-source/mediasource-invalid-codec.html
+
+ Parse VP8 video tracks out of WebM files. Add a simple VP8 frame header parser to extract width
+ height and color information out of keyframe headers, and create a CMFormatDescription from that
+ header.
+
+ Throw an error during parsing if an Audio or Video track is encountered with an unsupported codec.
+
+ * platform/graphics/VP9Utilities.cpp:
+ (WebCore::parseVPCodecParameters):
+ * platform/graphics/cocoa/SourceBufferParserWebM.cpp:
+ (WebCore::SourceBufferParserWebM::isContentTypeSupported):
+ (WebCore::createFormatDescriptionFromVPCodecConfigurationRecord):
+ (WebCore::createFormatDescriptionFromVP9HeaderParser):
+ (WebCore::parseVP8FrameHeader):
+ (WebCore::createFormatDescriptionFromVP8Header):
+ (WebCore::SourceBufferParserWebM::OnFrame):
+ * platform/graphics/cocoa/VP9UtilitiesCocoa.h:
+ * platform/graphics/cocoa/VP9UtilitiesCocoa.mm:
+ (WebCore::registerWebKitVP8Decoder):
+ (WebCore::isVP8DecoderAvailable):
+ (WebCore::isVP9CodecConfigurationRecordSupported):
+ (WebCore::isVP8CodecConfigurationRecordSupported):
+ (WebCore::isVPCodecConfigurationRecordSupported):
+ * platform/mediastream/libwebrtc/LibWebRTCProvider.h:
+ * platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.cpp:
+ (WebCore::LibWebRTCProvider::registerWebKitVP8Decoder):
+
2020-12-11 Chris Dumez <[email protected]>
Potential null dereference of m_frame under DocumentLoader::stopLoading()
Modified: trunk/Source/WebCore/platform/graphics/VP9Utilities.cpp (270719 => 270720)
--- trunk/Source/WebCore/platform/graphics/VP9Utilities.cpp 2020-12-12 00:43:52 UTC (rev 270719)
+++ trunk/Source/WebCore/platform/graphics/VP9Utilities.cpp 2020-12-12 00:57:14 UTC (rev 270720)
@@ -124,12 +124,6 @@
Optional<VPCodecConfigurationRecord> parseVPCodecParameters(StringView codecView)
{
- // The format of the 'vp09' codec string is specified in the webm GitHub repo:
- // <https://github.com/webmproject/vp9-dash/blob/master/VPCodecISOMediaFileFormatBinding.md#codecs-parameter-string>
-
- // "sample entry 4CC, profile, level, and bitDepth are all mandatory fields. If any of these fields are empty, or not
- // within their allowed range, the processing device SHALL treat it as an error."
-
auto codecSplit = codecView.split('.');
auto nextElement = codecSplit.begin();
if (nextElement == codecSplit.end())
@@ -137,12 +131,24 @@
VPCodecConfigurationRecord configuration;
+ configuration.codecName = (*nextElement).toString();
+ ++nextElement;
+
+ // Support the legacy identifiers (with no parameters) for VP8 and VP9.
+ if ((configuration.codecName == "vp8" || configuration.codecName == "vp9") && nextElement == codecSplit.end())
+ return configuration;
+
+ // The format of the 'vp09' codec string is specified in the webm GitHub repo:
+ // <https://github.com/webmproject/vp9-dash/blob/master/VPCodecISOMediaFileFormatBinding.md#codecs-parameter-string>
+
+ // "sample entry 4CC, profile, level, and bitDepth are all mandatory fields. If any of these fields are empty, or not
+ // within their allowed range, the processing device SHALL treat it as an error."
+
// Codec identifier: legal values are 'vp08' or 'vp09'.
- configuration.codecName = (*nextElement).toString();
if (configuration.codecName != "vp08" && configuration.codecName != "vp09")
return WTF::nullopt;
- if (++nextElement == codecSplit.end())
+ if (nextElement == codecSplit.end())
return WTF::nullopt;
// First element: profile. Legal values are 0-3.
Modified: trunk/Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.cpp (270719 => 270720)
--- trunk/Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.cpp 2020-12-12 00:43:52 UTC (rev 270719)
+++ trunk/Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.cpp 2020-12-12 00:57:14 UTC (rev 270720)
@@ -461,7 +461,7 @@
auto splitResults = StringView(codecsParameter).split(',');
for (auto split : splitResults) {
#if ENABLE(VP9)
- if (split.startsWith("vp09")) {
+ if (split.startsWith("vp09") || split.startsWith("vp08") || equal(split, "vp8") || equal(split, "vp9")) {
if (!isVP9DecoderAvailable())
return MediaPlayerEnums::SupportsType::IsNotSupported;
@@ -778,6 +778,18 @@
return Status(Status::kOkCompleted);
auto trackType = trackEntry.track_type.value();
+ String codecId { trackEntry.codec_id.value().data(), (unsigned)trackEntry.codec_id.value().length() };
+
+ if (trackType == TrackType::kVideo && !supportedVideoCodecs().contains(codecId)) {
+ ERROR_LOG_IF_POSSIBLE(LOGIDENTIFIER, "Encountered unsupported video codec ID \"", codecId, "\", bailing");
+ return Status(Status::Code(ErrorCode::UnsupportedVideoCodec));
+ }
+
+ if (trackType == TrackType::kAudio && !supportedAudioCodecs().contains(codecId)) {
+ ERROR_LOG_IF_POSSIBLE(LOGIDENTIFIER, "Encountered unsupported audio codec ID \"", codecId, "\", bailing");
+ return Status(Status::Code(ErrorCode::UnsupportedAudioCodec));
+ }
+
if (trackType == TrackType::kVideo)
m_initializationSegment->videoTracks.append({ MediaDescriptionWebM::create(TrackEntry(trackEntry)), VideoTrackPrivateWebM::create(TrackEntry(trackEntry)) });
else if (trackType == TrackType::kAudio)
@@ -789,6 +801,10 @@
m_tracks.append(VideoTrackData::create(CodecType::VP9, trackEntry, *this));
return Status(Status::kOkCompleted);
}
+ if (codecString == "V_VP8" && isVP8DecoderAvailable()) {
+ m_tracks.append(VideoTrackData::create(CodecType::VP8, trackEntry, *this));
+ return Status(Status::kOkCompleted);
+ }
#endif
#if ENABLE(VORBIS)
@@ -875,7 +891,6 @@
return Status(Status::kOkCompleted);
}
-
webm::Status SourceBufferParserWebM::OnFrame(const FrameMetadata& metadata, Reader* reader, uint64_t* bytesRemaining)
{
ASSERT(reader);
@@ -901,6 +916,7 @@
}
switch (trackData->codec()) {
+ case CodecType::VP8:
case CodecType::VP9:
case CodecType::Vorbis:
case CodecType::Opus:
@@ -992,23 +1008,38 @@
return;
}
- if (!m_headerParser.ParseUncompressedHeader(blockBufferData, segmentSizeAtPosition)) {
- PARSER_LOG_ERROR_IF_POSSIBLE("ParseUncompressedHeader failed");
- return;
- }
+ bool isKey = false;
+ RetainPtr<CMFormatDescriptionRef> formatDescription;
+ if (codec() == CodecType::VP9) {
+ if (!m_headerParser.ParseUncompressedHeader(blockBufferData, segmentSizeAtPosition))
+ return;
- // Only update the format description when the header indicates that the sample is
- // a key-frame, otherwise color information will not be parsed.
- auto track = this->track();
- if (m_headerParser.key()) {
- auto formatDescription = createFormatDescriptionFromVP9HeaderParser(m_headerParser, track.video.value().colour);
- if (!formatDescription) {
- PARSER_LOG_ERROR_IF_POSSIBLE("failed to create format description from VP9 header");
+ if (m_headerParser.key()) {
+ isKey = true;
+ auto formatDescription = createFormatDescriptionFromVP9HeaderParser(m_headerParser, track().video.value().colour);
+ if (!formatDescription) {
+ PARSER_LOG_ERROR_IF_POSSIBLE("failed to create format description from VPX header");
+ return;
+ }
+ setFormatDescription(WTFMove(formatDescription));
+ }
+ } else if (codec() == CodecType::VP8) {
+ auto header = parseVP8FrameHeader(blockBufferData, segmentSizeAtPosition);
+ if (!header)
return;
+
+ if (header->keyframe) {
+ isKey = true;
+ auto formatDescription = createFormatDescriptionFromVP8Header(*header, track().video.value().colour);
+ if (!formatDescription) {
+ PARSER_LOG_ERROR_IF_POSSIBLE("failed to create format description from VPX header");
+ return;
+ }
+ setFormatDescription(WTFMove(formatDescription));
}
- setFormatDescription(WTFMove(formatDescription));
}
+ auto track = this->track();
// FIXME: A block might contain more than one frame, but only this frame has been read into `currentBlockBuffer`.
// Below we create sample buffers for each frame, each with the block's timecode and `num_frames` value.
// Shouldn't we create just one sample buffer once all the block's frames have been read into `currentBlockBuffer`?
@@ -1020,7 +1051,7 @@
CMSampleBufferRef rawSampleBuffer = nullptr;
size_t frameSize = CMBlockBufferGetDataLength(m_currentBlockBuffer.get());
CMSampleTimingInfo timing = { CMTimeMake(duration, presentationTime.timescale), presentationTime, presentationTime };
- err = CMSampleBufferCreateReady(kCFAllocatorDefault, m_currentBlockBuffer.get(), formatDescription().get(), sampleCount, 1, &timing, 1, &frameSize, &rawSampleBuffer);
+ err = CMSampleBufferCreateReady(kCFAllocatorDefault, m_currentBlockBuffer.get(), this->formatDescription().get(), sampleCount, 1, &timing, 1, &frameSize, &rawSampleBuffer);
if (err) {
PARSER_LOG_ERROR_IF_POSSIBLE("CMSampleBufferCreateReady failed with error", err);
return;
@@ -1162,6 +1193,18 @@
m_minimumAudioSampleDuration = duration;
}
+const HashSet<String>& SourceBufferParserWebM::supportedVideoCodecs()
+{
+ static auto codecs = makeNeverDestroyed<HashSet<String>>({ "V_VP8", "V_VP9" });
+ return codecs;
}
+const HashSet<String>& SourceBufferParserWebM::supportedAudioCodecs()
+{
+ static auto codecs = makeNeverDestroyed<HashSet<String>>({ });
+ return codecs;
+}
+
+}
+
#endif // ENABLE(MEDIA_SOURCE)
Modified: trunk/Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.h (270719 => 270720)
--- trunk/Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.h 2020-12-12 00:43:52 UTC (rev 270719)
+++ trunk/Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.h 2020-12-12 00:57:14 UTC (rev 270720)
@@ -89,6 +89,8 @@
InvalidDocType,
InvalidInitSegment,
ReceivedEbmlInsideSegment,
+ UnsupportedVideoCodec,
+ UnsupportedAudioCodec,
};
enum class State : uint8_t {
@@ -106,6 +108,7 @@
enum class CodecType : uint8_t {
Unsupported,
+ VP8,
VP9,
Vorbis,
Opus,
@@ -220,6 +223,9 @@
TrackData* trackDataForTrackNumber(uint64_t);
+ static const HashSet<String>& supportedVideoCodecs();
+ static const HashSet<String>& supportedAudioCodecs();
+
// webm::Callback
webm::Status OnElementBegin(const webm::ElementMetadata&, webm::Action*) final;
webm::Status OnElementEnd(const webm::ElementMetadata&) final;
Modified: trunk/Source/WebCore/platform/graphics/cocoa/VP9UtilitiesCocoa.h (270719 => 270720)
--- trunk/Source/WebCore/platform/graphics/cocoa/VP9UtilitiesCocoa.h 2020-12-12 00:43:52 UTC (rev 270719)
+++ trunk/Source/WebCore/platform/graphics/cocoa/VP9UtilitiesCocoa.h 2020-12-12 00:57:14 UTC (rev 270720)
@@ -46,13 +46,31 @@
WEBCORE_EXPORT extern void resetOverrideVP9ScreenSizeAndScaleForTesting();
WEBCORE_EXPORT extern void registerWebKitVP9Decoder();
+WEBCORE_EXPORT extern void registerWebKitVP8Decoder();
WEBCORE_EXPORT extern void registerSupplementalVP9Decoder();
extern bool isVP9DecoderAvailable();
+extern bool isVP8DecoderAvailable();
extern bool isVPCodecConfigurationRecordSupported(VPCodecConfigurationRecord&);
extern bool validateVPParameters(VPCodecConfigurationRecord&, MediaCapabilitiesInfo&, const VideoConfiguration&);
RetainPtr<CMFormatDescriptionRef> createFormatDescriptionFromVP9HeaderParser(const vp9_parser::Vp9HeaderParser&, const webm::Element<webm::Colour>&);
+struct VP8FrameHeader {
+ bool keyframe { false };
+ uint8_t version { 0 };
+ bool showFrame { true };
+ uint32_t partitionSize { 0 };
+ uint8_t horizontalScale { 0 };
+ uint16_t width { 0 };
+ uint8_t verticalScale { 0 };
+ uint16_t height;
+ bool colorSpace { false };
+ bool needsClamping { false };
+};
+
+Optional<VP8FrameHeader> parseVP8FrameHeader(uint8_t* frameData, size_t frameSize);
+RetainPtr<CMFormatDescriptionRef> createFormatDescriptionFromVP8Header(const VP8FrameHeader&, const webm::Element<webm::Colour>&);
+
}
#endif
Modified: trunk/Source/WebCore/platform/graphics/cocoa/VP9UtilitiesCocoa.mm (270719 => 270720)
--- trunk/Source/WebCore/platform/graphics/cocoa/VP9UtilitiesCocoa.mm 2020-12-12 00:43:52 UTC (rev 270719)
+++ trunk/Source/WebCore/platform/graphics/cocoa/VP9UtilitiesCocoa.mm 2020-12-12 00:57:14 UTC (rev 270720)
@@ -107,6 +107,11 @@
LibWebRTCProvider::registerWebKitVP9Decoder();
}
+void registerWebKitVP8Decoder()
+{
+ LibWebRTCProvider::registerWebKitVP8Decoder();
+}
+
void registerSupplementalVP9Decoder()
{
if (!VideoToolboxLibrary(true))
@@ -123,8 +128,15 @@
return noErr == VTSelectAndCreateVideoDecoderInstance(kCMVideoCodecType_VP9, kCFAllocatorDefault, nullptr, nullptr);
}
-bool isVPCodecConfigurationRecordSupported(VPCodecConfigurationRecord& codecConfiguration)
+bool isVP8DecoderAvailable()
{
+ if (!VideoToolboxLibrary(true))
+ return false;
+ return noErr == VTSelectAndCreateVideoDecoderInstance('vp08', kCFAllocatorDefault, nullptr, nullptr);
+}
+
+static bool isVP9CodecConfigurationRecordSupported(VPCodecConfigurationRecord& codecConfiguration)
+{
if (!isVP9DecoderAvailable())
return false;
@@ -175,6 +187,37 @@
return has4kScreen;
}
+static bool isVP8CodecConfigurationRecordSupported(VPCodecConfigurationRecord& codecConfiguration)
+{
+ if (!isVP8DecoderAvailable())
+ return false;
+
+ // VP8 decoder only supports Profile 0;
+ if (codecConfiguration.profile)
+ return false;
+
+ // VP8 decoder only supports 420 chroma subsampling.
+ if (codecConfiguration.chromaSubsampling > VPConfigurationChromaSubsampling::Subsampling_420_Colocated)
+ return false;
+
+ // VP8 decoder only supports 8-bit color:
+ if (codecConfiguration.bitDepth > 8)
+ return false;
+
+ return true;
+}
+
+bool isVPCodecConfigurationRecordSupported(VPCodecConfigurationRecord& codecConfiguration)
+{
+ if (codecConfiguration.codecName == "vp08" || codecConfiguration.codecName == "vp8")
+ return isVP8CodecConfigurationRecordSupported(codecConfiguration);
+
+ if (codecConfiguration.codecName == "vp09" || codecConfiguration.codecName == "vp9")
+ return isVP9CodecConfigurationRecordSupported(codecConfiguration);
+
+ return false;
+}
+
bool validateVPParameters(VPCodecConfigurationRecord& codecConfiguration, MediaCapabilitiesInfo& info, const VideoConfiguration& videoConfiguration)
{
if (!isVPCodecConfigurationRecordSupported(codecConfiguration))
@@ -435,7 +478,7 @@
return VPConfigurationChromaSubsampling::Subsampling_420_Colocated;
}
-RetainPtr<CMFormatDescriptionRef> createFormatDescriptionFromVP9HeaderParser(const vp9_parser::Vp9HeaderParser& parser, const webm::Element<Colour>& color)
+static RetainPtr<CMFormatDescriptionRef> createFormatDescriptionFromVPCodecConfigurationRecord(const VPCodecConfigurationRecord& record, int32_t width, int32_t height)
{
// Ref: "VP Codec ISO Media File Format Binding, v1.0, 2017-03-31"
// <https://www.webmproject.org/vp9/mp4/>
@@ -464,35 +507,6 @@
// FIXME: Convert existing struct to an ISOBox and replace the writing code below
// with a subclass of ISOFullBox.
- VPCodecConfigurationRecord record;
-
- record.profile = ""
- // CoreMedia does nat care about the VP9 codec level; hard-code to Level 1.0 here:
- record.level = 10;
- record.bitDepth = parser.bit_depth();
- record.videoFullRangeFlag = parser.color_range() ? VPConfigurationRange::FullRange : VPConfigurationRange::VideoRange;
- record.chromaSubsampling = convertSubsamplingXYToChromaSubsampling(parser.subsampling_x(), parser.subsampling_y());
- record.colorPrimaries = VPConfigurationColorPrimaries::Unspecified;
- record.transferCharacteristics = VPConfigurationTransferCharacteristics::Unspecified;
- record.matrixCoefficients = VPConfigurationMatrixCoefficients::Unspecified;
-
- // Container color values can override per-sample ones:
- if (color.is_present()) {
- auto& colorValue = color.value();
- if (colorValue.chroma_subsampling_x.is_present() && colorValue.chroma_subsampling_y.is_present())
- record.chromaSubsampling = convertSubsamplingXYToChromaSubsampling(colorValue.chroma_subsampling_x.value(), colorValue.chroma_subsampling_y.value());
- if (colorValue.range.is_present() && colorValue.range.value() != Range::kUnspecified)
- record.videoFullRangeFlag = colorValue.range.value() == Range::kFull ? VPConfigurationRange::FullRange : VPConfigurationRange::VideoRange;
- if (colorValue.bits_per_channel.is_present())
- record.bitDepth = colorValue.bits_per_channel.value();
- if (colorValue.transfer_characteristics.is_present())
- record.transferCharacteristics = convertToTransferCharacteristics(colorValue.transfer_characteristics.value());
- if (colorValue.matrix_coefficients.is_present())
- record.matrixCoefficients = convertToMatrixCoefficients(colorValue.matrix_coefficients.value());
- if (colorValue.primaries.is_present())
- record.colorPrimaries = convertToColorPrimaries(colorValue.primaries.value());
- }
-
constexpr size_t VPCodecConfigurationContentsSize = 12;
uint32_t versionAndFlags = 1 << 24;
@@ -541,11 +555,142 @@
auto extensions = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, extensionsKeys.data(), extensionsValues.data(), extensionsKeys.size(), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
CMVideoFormatDescriptionRef formatDescription = nullptr;
- if (noErr != CMVideoFormatDescriptionCreate(kCFAllocatorDefault, kCMVideoCodecType_VP9, parser.width(), parser.height(), extensions.get(), &formatDescription))
+ CMVideoCodecType codec = record.codecName == "vp09" ? kCMVideoCodecType_VP9 : 'vp08';
+ if (noErr != CMVideoFormatDescriptionCreate(kCFAllocatorDefault, codec, width, height, extensions.get(), &formatDescription))
return nullptr;
return adoptCF(formatDescription);
}
+RetainPtr<CMFormatDescriptionRef> createFormatDescriptionFromVP9HeaderParser(const vp9_parser::Vp9HeaderParser& parser, const webm::Element<Colour>& color)
+{
+ VPCodecConfigurationRecord record;
+
+ record.codecName = "vp09";
+ record.profile = ""
+ // CoreMedia does nat care about the VP9 codec level; hard-code to Level 1.0 here:
+ record.level = 10;
+ record.bitDepth = parser.bit_depth();
+ record.videoFullRangeFlag = parser.color_range() ? VPConfigurationRange::FullRange : VPConfigurationRange::VideoRange;
+ record.chromaSubsampling = convertSubsamplingXYToChromaSubsampling(parser.subsampling_x(), parser.subsampling_y());
+ record.colorPrimaries = VPConfigurationColorPrimaries::Unspecified;
+ record.transferCharacteristics = VPConfigurationTransferCharacteristics::Unspecified;
+ record.matrixCoefficients = VPConfigurationMatrixCoefficients::Unspecified;
+
+ // Container color values can override per-sample ones:
+ if (color.is_present()) {
+ auto& colorValue = color.value();
+ if (colorValue.chroma_subsampling_x.is_present() && colorValue.chroma_subsampling_y.is_present())
+ record.chromaSubsampling = convertSubsamplingXYToChromaSubsampling(colorValue.chroma_subsampling_x.value(), colorValue.chroma_subsampling_y.value());
+ if (colorValue.range.is_present() && colorValue.range.value() != Range::kUnspecified)
+ record.videoFullRangeFlag = colorValue.range.value() == Range::kFull ? VPConfigurationRange::FullRange : VPConfigurationRange::VideoRange;
+ if (colorValue.bits_per_channel.is_present())
+ record.bitDepth = colorValue.bits_per_channel.value();
+ if (colorValue.transfer_characteristics.is_present())
+ record.transferCharacteristics = convertToTransferCharacteristics(colorValue.transfer_characteristics.value());
+ if (colorValue.matrix_coefficients.is_present())
+ record.matrixCoefficients = convertToMatrixCoefficients(colorValue.matrix_coefficients.value());
+ if (colorValue.primaries.is_present())
+ record.colorPrimaries = convertToColorPrimaries(colorValue.primaries.value());
+ }
+
+ return createFormatDescriptionFromVPCodecConfigurationRecord(record, parser.width(), parser.height());
}
+Optional<VP8FrameHeader> parseVP8FrameHeader(uint8_t* frameData, size_t frameSize)
+{
+ // VP8 frame headers are defined in RFC 6386: <https://tools.ietf.org/html/rfc6386>.
+
+ // Bail if the header is below a minimum size
+ if (frameSize < 11)
+ return WTF::nullopt;
+
+ VP8FrameHeader header;
+ size_t headerSize = 11;
+
+ auto view = JSC::DataView::create(ArrayBuffer::create(frameData, headerSize), 0, headerSize);
+ bool status = true;
+
+ auto uncompressedChunk = view->get<uint32_t>(0, true, &status);
+ if (!status)
+ return WTF::nullopt;
+
+ header.keyframe = uncompressedChunk & 0x80000000;
+ header.version = (uncompressedChunk >> 28) & 0x7;
+ header.showFrame = uncompressedChunk & 0x8000000;
+ header.partitionSize = (uncompressedChunk >> 8) & 0x7FFFF;
+
+ if (!header.keyframe)
+ return header;
+
+ auto startCode0 = view->get<uint8_t>(3, true, &status);
+ if (!status || startCode0 != 0x9d)
+ return WTF::nullopt;
+
+ auto startCode1 = view->get<uint8_t>(4, true, &status);
+ if (!status || startCode1 != 0x01)
+ return WTF::nullopt;
+
+ auto startCode2 = view->get<uint8_t>(5, true, &status);
+ if (!status || startCode2 != 0x2a)
+ return WTF::nullopt;
+
+ auto horizontalAndWidthField = view->get<uint16_t>(6, true, &status);
+ if (!status)
+ return WTF::nullopt;
+
+ header.horizontalScale = static_cast<uint8_t>(horizontalAndWidthField >> 14);
+ header.width = static_cast<uint16_t>(horizontalAndWidthField & 0x3FFF);
+
+ auto verticalAndHeightField = view->get<uint16_t>(8, true, &status);
+ if (!status)
+ return WTF::nullopt;
+
+ header.verticalScale = static_cast<uint8_t>(verticalAndHeightField >> 14);
+ header.height = static_cast<uint16_t>(verticalAndHeightField & 0x3FFF);
+
+ auto colorSpaceAndClampingField = view->get<uint8_t>(10, true, &status);
+ if (!status)
+ return WTF::nullopt;
+
+ header.colorSpace = colorSpaceAndClampingField & 0x80;
+ header.needsClamping = colorSpaceAndClampingField & 0x40;
+
+ return header;
+}
+
+RetainPtr<CMFormatDescriptionRef> createFormatDescriptionFromVP8Header(const VP8FrameHeader& header, const webm::Element<Colour>& color)
+{
+ VPCodecConfigurationRecord record;
+ record.codecName = "vp08";
+ record.profile = ""
+ record.level = 10;
+ record.bitDepth = 8;
+ record.videoFullRangeFlag = VPConfigurationRange::FullRange;
+ record.chromaSubsampling = VPConfigurationChromaSubsampling::Subsampling_420_Colocated;
+ record.colorPrimaries = header.colorSpace ? VPConfigurationColorPrimaries::Unspecified : VPConfigurationColorPrimaries::BT_601_7;
+ record.transferCharacteristics = header.colorSpace ? VPConfigurationTransferCharacteristics::Unspecified : VPConfigurationTransferCharacteristics::BT_601_7;
+ record.matrixCoefficients = header.colorSpace ? VPConfigurationMatrixCoefficients::Unspecified : VPConfigurationMatrixCoefficients::BT_601_7;
+
+ // Container color values can override per-sample ones:
+ if (color.is_present()) {
+ auto& colorValue = color.value();
+ if (colorValue.chroma_subsampling_x.is_present() && colorValue.chroma_subsampling_y.is_present())
+ record.chromaSubsampling = convertSubsamplingXYToChromaSubsampling(colorValue.chroma_subsampling_x.value(), colorValue.chroma_subsampling_y.value());
+ if (colorValue.range.is_present() && colorValue.range.value() != Range::kUnspecified)
+ record.videoFullRangeFlag = colorValue.range.value() == Range::kFull ? VPConfigurationRange::FullRange : VPConfigurationRange::VideoRange;
+ if (colorValue.bits_per_channel.is_present())
+ record.bitDepth = colorValue.bits_per_channel.value();
+ if (colorValue.transfer_characteristics.is_present())
+ record.transferCharacteristics = convertToTransferCharacteristics(colorValue.transfer_characteristics.value());
+ if (colorValue.matrix_coefficients.is_present())
+ record.matrixCoefficients = convertToMatrixCoefficients(colorValue.matrix_coefficients.value());
+ if (colorValue.primaries.is_present())
+ record.colorPrimaries = convertToColorPrimaries(colorValue.primaries.value());
+ }
+
+ return createFormatDescriptionFromVPCodecConfigurationRecord(record, header.width, header.height);
+}
+
+}
+
#endif // PLATFORM(COCOA)
Modified: trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.h (270719 => 270720)
--- trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.h 2020-12-12 00:43:52 UTC (rev 270719)
+++ trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.h 2020-12-12 00:57:14 UTC (rev 270720)
@@ -75,6 +75,7 @@
static bool webRTCAvailable();
static void registerWebKitVP9Decoder();
+ static void registerWebKitVP8Decoder();
static void setH264HardwareEncoderAllowed(bool);
virtual void setActive(bool);
Modified: trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.cpp (270719 => 270720)
--- trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.cpp 2020-12-12 00:43:52 UTC (rev 270719)
+++ trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.cpp 2020-12-12 00:57:14 UTC (rev 270720)
@@ -34,6 +34,7 @@
#include <webrtc/sdk/WebKit/WebKitDecoder.h>
#include <webrtc/sdk/WebKit/WebKitEncoder.h>
ALLOW_UNUSED_PARAMETERS_END
+#include <webrtc/sdk/WebKit/WebKitVP8Decoder.h>
#include <webrtc/sdk/WebKit/WebKitVP9Decoder.h>
#include <wtf/MainThread.h>
#include <wtf/darwin/WeakLinking.h>
@@ -99,6 +100,13 @@
if (webRTCAvailable())
webrtc::registerWebKitVP9Decoder();
}
+
+void LibWebRTCProvider::registerWebKitVP8Decoder()
+{
+ if (webRTCAvailable())
+ webrtc::registerWebKitVP8Decoder();
+}
+
} // namespace WebCore
#endif // USE(LIBWEBRTC)
Modified: trunk/Source/WebKit/ChangeLog (270719 => 270720)
--- trunk/Source/WebKit/ChangeLog 2020-12-12 00:43:52 UTC (rev 270719)
+++ trunk/Source/WebKit/ChangeLog 2020-12-12 00:57:14 UTC (rev 270720)
@@ -1,3 +1,38 @@
+2020-12-11 Jer Noble <[email protected]>
+
+ [Cocoa] Add Experimental VP8 support
+ https://bugs.webkit.org/show_bug.cgi?id=219732
+
+ Reviewed by Eric Carlson.
+
+ Add new WebPageCreationParameter flags to enable VP8 decoders in the WebContent and GPU
+ processes when the experimental feature is enabled.
+
+ * GPUProcess/GPUConnectionToWebProcess.cpp:
+ (WebKit::GPUConnectionToWebProcess::enableVP9Decoders):
+ * GPUProcess/GPUConnectionToWebProcess.h:
+ * GPUProcess/GPUConnectionToWebProcess.messages.in:
+ * GPUProcess/GPUProcess.cpp:
+ (WebKit::GPUProcess::enableVP9Decoders):
+ * GPUProcess/GPUProcess.h:
+ * Shared/WebPageCreationParameters.cpp:
+ (WebKit::WebPageCreationParameters::encode const):
+ (WebKit::WebPageCreationParameters::decode):
+ * Shared/WebPageCreationParameters.h:
+ * Shared/WebPreferencesDefaultValues.cpp:
+ (WebKit::defaultVP8DecoderEnabled):
+ * Shared/WebPreferencesDefaultValues.h:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::creationParameters):
+ * WebProcess/GPU/GPUProcessConnection.cpp:
+ (WebKit::GPUProcessConnection::updateParameters):
+ * WebProcess/GPU/GPUProcessConnection.h:
+ (WebKit::GPUProcessConnection::isVP8DecoderEnabled const):
+ * WebProcess/WebPage/WebPage.cpp:
+ * WebProcess/WebProcess.cpp:
+ (WebKit::WebProcess::enableVP8SWDecoder):
+ * WebProcess/WebProcess.h:
+
2020-12-11 Chris Dumez <[email protected]>
Potential null dereference of m_frame under DocumentLoader::stopLoading()
Modified: trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp (270719 => 270720)
--- trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp 2020-12-12 00:43:52 UTC (rev 270719)
+++ trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp 2020-12-12 00:57:14 UTC (rev 270720)
@@ -538,9 +538,9 @@
#endif
#if ENABLE(VP9)
-void GPUConnectionToWebProcess::enableVP9Decoders(bool shouldEnableVP9Decoder, bool shouldEnableVP9SWDecoder)
+void GPUConnectionToWebProcess::enableVP9Decoders(bool shouldEnableVP8Decoder, bool shouldEnableVP9Decoder, bool shouldEnableVP9SWDecoder)
{
- m_gpuProcess->enableVP9Decoders(shouldEnableVP9Decoder, shouldEnableVP9SWDecoder);
+ m_gpuProcess->enableVP9Decoders(shouldEnableVP8Decoder, shouldEnableVP9Decoder, shouldEnableVP9SWDecoder);
}
#endif
Modified: trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h (270719 => 270720)
--- trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h 2020-12-12 00:43:52 UTC (rev 270719)
+++ trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h 2020-12-12 00:57:14 UTC (rev 270720)
@@ -136,7 +136,7 @@
void setNowPlayingInfo(bool setAsNowPlayingApplication, WebCore::NowPlayingInfo&&);
#if ENABLE(VP9)
- void enableVP9Decoders(bool shouldEnableVP9Decoder, bool shouldEnableVP9SWDecoder);
+ void enableVP9Decoders(bool shouldEnableVP8Decoder, bool shouldEnableVP9Decoder, bool shouldEnableVP9SWDecoder);
#endif
#if USE(AUDIO_SESSION)
Modified: trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.messages.in (270719 => 270720)
--- trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.messages.in 2020-12-12 00:43:52 UTC (rev 270719)
+++ trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.messages.in 2020-12-12 00:57:14 UTC (rev 270720)
@@ -38,7 +38,7 @@
EnsureMediaSessionHelper()
#endif
#if ENABLE(VP9)
- EnableVP9Decoders(bool shouldEnableVP9Decoder, bool shouldEnableVP9SWDecoder)
+ EnableVP9Decoders(bool shouldEnableVP8Decoder, bool shouldEnableVP9Decoder, bool shouldEnableVP9SWDecoder)
#endif
}
Modified: trunk/Source/WebKit/GPUProcess/GPUProcess.cpp (270719 => 270720)
--- trunk/Source/WebKit/GPUProcess/GPUProcess.cpp 2020-12-12 00:43:52 UTC (rev 270719)
+++ trunk/Source/WebKit/GPUProcess/GPUProcess.cpp 2020-12-12 00:57:14 UTC (rev 270720)
@@ -292,7 +292,7 @@
#endif
#if ENABLE(VP9)
-void GPUProcess::enableVP9Decoders(bool shouldEnableVP9Decoder, bool shouldEnableVP9SWDecoder)
+void GPUProcess::enableVP9Decoders(bool shouldEnableVP8Decoder, bool shouldEnableVP9Decoder, bool shouldEnableVP9SWDecoder)
{
if (shouldEnableVP9Decoder && !m_enableVP9Decoder) {
m_enableVP9Decoder = true;
@@ -300,6 +300,12 @@
WebCore::registerSupplementalVP9Decoder();
#endif
}
+ if (shouldEnableVP8Decoder && !m_enableVP8Decoder) {
+ m_enableVP8Decoder = true;
+#if PLATFORM(COCOA)
+ WebCore::registerWebKitVP8Decoder();
+#endif
+ }
if (shouldEnableVP9SWDecoder && !m_enableVP9SWDecoder) {
m_enableVP9SWDecoder = true;
#if PLATFORM(COCOA)
Modified: trunk/Source/WebKit/GPUProcess/GPUProcess.h (270719 => 270720)
--- trunk/Source/WebKit/GPUProcess/GPUProcess.h 2020-12-12 00:43:52 UTC (rev 270719)
+++ trunk/Source/WebKit/GPUProcess/GPUProcess.h 2020-12-12 00:57:14 UTC (rev 270720)
@@ -84,7 +84,7 @@
#endif
#if ENABLE(VP9)
- void enableVP9Decoders(bool shouldEnableVP9Decoder, bool shouldEnableVP9SWDecoder);
+ void enableVP9Decoders(bool shouldEnableVP8Decoder, bool shouldEnableVP9Decoder, bool shouldEnableVP9SWDecoder);
#endif
private:
@@ -148,6 +148,7 @@
mutable std::unique_ptr<RemoteAudioSessionProxyManager> m_audioSessionManager;
#endif
#if ENABLE(VP9)
+ bool m_enableVP8Decoder { false };
bool m_enableVP9Decoder { false };
bool m_enableVP9SWDecoder { false };
#endif
Modified: trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp (270719 => 270720)
--- trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp 2020-12-12 00:43:52 UTC (rev 270719)
+++ trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp 2020-12-12 00:57:14 UTC (rev 270720)
@@ -162,6 +162,7 @@
#if ENABLE(WEBGL)
encoder << shouldRenderWebGLInGPUProcess;
#endif
+ encoder << shouldEnableVP8Decoder;
encoder << shouldEnableVP9Decoder;
encoder << shouldEnableVP9SWDecoder;
#if ENABLE(APP_BOUND_DOMAINS)
@@ -527,6 +528,9 @@
return WTF::nullopt;
#endif
+ if (!decoder.decode(parameters.shouldEnableVP8Decoder))
+ return WTF::nullopt;
+
if (!decoder.decode(parameters.shouldEnableVP9Decoder))
return WTF::nullopt;
Modified: trunk/Source/WebKit/Shared/WebPageCreationParameters.h (270719 => 270720)
--- trunk/Source/WebKit/Shared/WebPageCreationParameters.h 2020-12-12 00:43:52 UTC (rev 270719)
+++ trunk/Source/WebKit/Shared/WebPageCreationParameters.h 2020-12-12 00:57:14 UTC (rev 270720)
@@ -233,6 +233,7 @@
#if ENABLE(WEBGL)
bool shouldRenderWebGLInGPUProcess { false };
#endif
+ bool shouldEnableVP8Decoder { false };
bool shouldEnableVP9Decoder { false };
bool shouldEnableVP9SWDecoder { false };
#if ENABLE(APP_BOUND_DOMAINS)
Modified: trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.cpp (270719 => 270720)
--- trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.cpp 2020-12-12 00:43:52 UTC (rev 270719)
+++ trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.cpp 2020-12-12 00:57:14 UTC (rev 270720)
@@ -278,6 +278,15 @@
#if ENABLE(VP9)
+bool defaultVP8DecoderEnabled()
+{
+#if HAVE(SYSTEM_FEATURE_FLAGS)
+ return isFeatureFlagEnabled("vp8_decoder");
+#endif
+
+ return false;
+}
+
bool defaultVP9DecoderEnabled()
{
#if HAVE(SYSTEM_FEATURE_FLAGS)
Modified: trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.h (270719 => 270720)
--- trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.h 2020-12-12 00:43:52 UTC (rev 270719)
+++ trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.h 2020-12-12 00:57:14 UTC (rev 270720)
@@ -100,6 +100,7 @@
#endif
#if ENABLE(VP9)
+bool defaultVP8DecoderEnabled();
bool defaultVP9DecoderEnabled();
bool defaultVP9SWDecoderEnabledOnBattery();
#if ENABLE(MEDIA_SOURCE)
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (270719 => 270720)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2020-12-12 00:43:52 UTC (rev 270719)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2020-12-12 00:57:14 UTC (rev 270720)
@@ -8001,6 +8001,7 @@
parameters.shouldEnableVP9Decoder = preferences().vp9DecoderEnabled();
#if ENABLE(VP9) && PLATFORM(COCOA)
+ parameters.shouldEnableVP8Decoder = preferences().vp9DecoderEnabled();
parameters.shouldEnableVP9SWDecoder = preferences().vp9DecoderEnabled() && (!WebCore::systemHasBattery() || preferences().vp9SWDecoderEnabledOnBattery());
#endif
parameters.shouldCaptureDisplayInUIProcess = m_process->processPool().configuration().shouldCaptureDisplayInUIProcess();
Modified: trunk/Source/WebKit/WebProcess/GPU/GPUProcessConnection.cpp (270719 => 270720)
--- trunk/Source/WebKit/WebProcess/GPU/GPUProcessConnection.cpp 2020-12-12 00:43:52 UTC (rev 270719)
+++ trunk/Source/WebKit/WebProcess/GPU/GPUProcessConnection.cpp 2020-12-12 00:57:14 UTC (rev 270720)
@@ -185,12 +185,13 @@
void GPUProcessConnection::updateParameters(const WebPageCreationParameters& parameters)
{
#if ENABLE(VP9)
- if (m_enableVP9Decoder == parameters.shouldEnableVP9Decoder && m_enableVP9SWDecoder == parameters.shouldEnableVP9SWDecoder)
+ if (m_enableVP8Decoder == parameters.shouldEnableVP8Decoder && m_enableVP9Decoder == parameters.shouldEnableVP9Decoder && m_enableVP9SWDecoder == parameters.shouldEnableVP9SWDecoder)
return;
+ m_enableVP9Decoder = parameters.shouldEnableVP8Decoder;
m_enableVP9Decoder = parameters.shouldEnableVP9Decoder;
m_enableVP9SWDecoder = parameters.shouldEnableVP9SWDecoder;
- connection().send(Messages::GPUConnectionToWebProcess::EnableVP9Decoders(parameters.shouldEnableVP9Decoder, parameters.shouldEnableVP9SWDecoder), { });
+ connection().send(Messages::GPUConnectionToWebProcess::EnableVP9Decoders(parameters.shouldEnableVP8Decoder, parameters.shouldEnableVP9Decoder, parameters.shouldEnableVP9SWDecoder), { });
#endif
}
Modified: trunk/Source/WebKit/WebProcess/GPU/GPUProcessConnection.h (270719 => 270720)
--- trunk/Source/WebKit/WebProcess/GPU/GPUProcessConnection.h 2020-12-12 00:43:52 UTC (rev 270719)
+++ trunk/Source/WebKit/WebProcess/GPU/GPUProcessConnection.h 2020-12-12 00:57:14 UTC (rev 270720)
@@ -82,6 +82,7 @@
void updateParameters(const WebPageCreationParameters&);
#if ENABLE(VP9)
+ bool isVP8DecoderEnabled() const { return m_enableVP8Decoder; }
bool isVP9DecoderEnabled() const { return m_enableVP9Decoder; }
bool isVPSWDecoderEnabled() const { return m_enableVP9SWDecoder; }
#endif
@@ -123,6 +124,7 @@
RefPtr<RemoteAudioSourceProviderManager> m_audioSourceProviderManager;
#endif
#if ENABLE(VP9)
+ bool m_enableVP8Decoder { false };
bool m_enableVP9Decoder { false };
bool m_enableVP9SWDecoder { false };
#endif
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (270719 => 270720)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2020-12-12 00:43:52 UTC (rev 270719)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2020-12-12 00:57:14 UTC (rev 270720)
@@ -819,6 +819,9 @@
if (parameters.shouldEnableVP9Decoder)
WebProcess::singleton().enableVP9Decoder();
+ if (parameters.shouldEnableVP8Decoder)
+ WebProcess::singleton().enableVP8SWDecoder();
+
if (parameters.shouldEnableVP9SWDecoder)
WebProcess::singleton().enableVP9SWDecoder();
#endif
Modified: trunk/Source/WebKit/WebProcess/WebProcess.cpp (270719 => 270720)
--- trunk/Source/WebKit/WebProcess/WebProcess.cpp 2020-12-12 00:43:52 UTC (rev 270719)
+++ trunk/Source/WebKit/WebProcess/WebProcess.cpp 2020-12-12 00:57:14 UTC (rev 270720)
@@ -1983,6 +1983,17 @@
#endif
}
+void WebProcess::enableVP8SWDecoder()
+{
+ if (m_vp9SWDecoderEnabled)
+ return;
+
+ m_vp8SWDecoderEnabled = true;
+#if PLATFORM(COCOA)
+ WebCore::registerWebKitVP8Decoder();
+#endif
+}
+
void WebProcess::enableVP9SWDecoder()
{
if (m_vp9SWDecoderEnabled)
Modified: trunk/Source/WebKit/WebProcess/WebProcess.h (270719 => 270720)
--- trunk/Source/WebKit/WebProcess/WebProcess.h 2020-12-12 00:43:52 UTC (rev 270719)
+++ trunk/Source/WebKit/WebProcess/WebProcess.h 2020-12-12 00:57:14 UTC (rev 270720)
@@ -359,6 +359,7 @@
#if ENABLE(VP9)
void enableVP9Decoder();
+ void enableVP8SWDecoder();
void enableVP9SWDecoder();
#endif
@@ -706,6 +707,7 @@
#if ENABLE(VP9)
bool m_vp9DecoderEnabled { false };
+ bool m_vp8SWDecoderEnabled { false };
bool m_vp9SWDecoderEnabled { false };
#endif