Unreviewed, rolling out r230862.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 21 Apr 2018 01:24:53 +0000 (01:24 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 21 Apr 2018 01:24:53 +0000 (01:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=184855

it is making some tests to time out on bots (Requested by
youenn on #webkit).

Reverted changeset:

"Mandate H264 hardware encoder for Mac in libwebrtc"
https://bugs.webkit.org/show_bug.cgi?id=184835
https://trac.webkit.org/changeset/230862

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@230871 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/ThirdParty/libwebrtc/ChangeLog
Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoEncoderH264.mm
Source/ThirdParty/libwebrtc/WebKit/0001-Update-RTCVideoEncoderH264.mm-for-WebKit.patch [deleted file]

index f80ac69..ff209a0 100644 (file)
@@ -1,3 +1,17 @@
+2018-04-20  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r230862.
+        https://bugs.webkit.org/show_bug.cgi?id=184855
+
+        it is making some tests to time out on bots (Requested by
+        youenn on #webkit).
+
+        Reverted changeset:
+
+        "Mandate H264 hardware encoder for Mac in libwebrtc"
+        https://bugs.webkit.org/show_bug.cgi?id=184835
+        https://trac.webkit.org/changeset/230862
+
 2018-04-20  Youenn Fablet  <youenn@apple.com>
 
         Mandate H264 hardware encoder for Mac in libwebrtc
index c5493d6..bc7437f 100644 (file)
@@ -607,21 +607,22 @@ CFStringRef ExtractProfile(webrtc::SdpVideoFormat videoFormat) {
     CFRelease(pixelFormat);
     pixelFormat = nullptr;
   }
-  CFDictionaryRef encoderSpecs = nullptr;
+  CFMutableDictionaryRef encoder_specs = nullptr;
 #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
-  auto useHardwareEncoder = webrtc::isH264HardwareEncoderAllowed() ? kCFBooleanTrue : kCFBooleanFalse;
   // Currently hw accl is supported above 360p on mac, below 360p
   // the compression session will be created with hw accl disabled.
-  CFTypeRef sessionKeys[] = {kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder, kVTVideoEncoderSpecification_RequireHardwareAcceleratedVideoEncoder, kVTCompressionPropertyKey_RealTime };
-  CFTypeRef sessionValues[] = {  useHardwareEncoder, useHardwareEncoder, kCFBooleanTrue };
-  encoderSpecs = CFDictionaryCreate(kCFAllocatorDefault, sessionKeys, sessionValues, 3, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+  encoder_specs = CFDictionaryCreateMutable(
+      nullptr, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+  CFDictionarySetValue(encoder_specs,
+                       kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder,
+                       webrtc::isH264HardwareEncoderAllowed() ? kCFBooleanTrue : kCFBooleanFalse);
 #endif
   OSStatus status =
       CompressionSessionCreate(nullptr,  // use default allocator
                                  _width,
                                  _height,
                                  kCodecTypeH264,
-                                 encoderSpecs,  // use hardware accelerated encoder if available
+                                 encoder_specs,  // use hardware accelerated encoder if available
                                  sourceAttributes,
                                  nullptr,  // use default compressed data allocator
                                  compressionOutputCallback,
@@ -631,9 +632,9 @@ CFStringRef ExtractProfile(webrtc::SdpVideoFormat videoFormat) {
     CFRelease(sourceAttributes);
     sourceAttributes = nullptr;
   }
-  if (encoderSpecs) {
-    CFRelease(encoderSpecs);
-    encoderSpecs = nullptr;
+  if (encoder_specs) {
+    CFRelease(encoder_specs);
+    encoder_specs = nullptr;
   }
   if (status != noErr) {
     RTC_LOG(LS_ERROR) << "Failed to create compression session: " << status;
@@ -713,9 +714,9 @@ CFStringRef ExtractProfile(webrtc::SdpVideoFormat videoFormat) {
       CFRelease(sourceAttributes);
       sourceAttributes = nullptr;
     }
-    if (encoderSpecs) {
-      CFRelease(encoderSpecs);
-      encoderSpecs = nullptr;
+    if (encoder_specs) {
+      CFRelease(encoder_specs);
+      encoder_specs = nullptr;
     }
     if (status != noErr) {
       return WEBRTC_VIDEO_CODEC_ERROR;
diff --git a/Source/ThirdParty/libwebrtc/WebKit/0001-Update-RTCVideoEncoderH264.mm-for-WebKit.patch b/Source/ThirdParty/libwebrtc/WebKit/0001-Update-RTCVideoEncoderH264.mm-for-WebKit.patch
deleted file mode 100644 (file)
index c98a09e..0000000
+++ /dev/null
@@ -1,188 +0,0 @@
-From 4a7b6915b1bcdcfd17eae8910a55116bf5594a2b Mon Sep 17 00:00:00 2001
-From: Youenn Fablet <youenn@apple.com>
-Date: Fri, 20 Apr 2018 13:43:59 -0700
-Subject: [PATCH] Update RTCVideoEncoderH264.mm for WebKit
-
-This reverts commit 455ac9ced9b3c5a938b189c955602819dd8eb3b6.
----
- .../Classes/VideoToolbox/RTCVideoEncoderH264.mm    | 127 +++++++++++++++++++--
- 1 file changed, 117 insertions(+), 10 deletions(-)
-
-diff --git a/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoEncoderH264.mm b/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoEncoderH264.mm
-index 8c27e7667cd..6a17889ae7b 100644
---- a/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoEncoderH264.mm
-+++ b/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoEncoderH264.mm
-@@ -38,6 +38,40 @@
- #include "sdk/WebKit/EncoderUtilities.h"
- #include "sdk/WebKit/WebKitUtilities.h"
-+#import <dlfcn.h>
-+#import <objc/runtime.h>
-+
-+SOFT_LINK_FRAMEWORK_OPTIONAL(VideoToolBox)
-+SOFT_LINK_POINTER_OPTIONAL(VideoToolBox, kVTVideoEncoderSpecification_Usage, NSString *)
-+
-+#if !ENABLE_VCP_ENCODER && !defined(WEBRTC_IOS)
-+static inline bool isStandardFrameSize(int32_t width, int32_t height)
-+{
-+    // FIXME: Envision relaxing this rule, something like width and height dividable by 4 or 8 should be good enough.
-+    if (width == 1280)
-+        return height == 720;
-+    if (width == 720)
-+        return height == 1280;
-+    if (width == 960)
-+        return height == 540;
-+    if (width == 540)
-+        return height == 960;
-+    if (width == 640)
-+        return height == 480;
-+    if (width == 480)
-+        return height == 640;
-+    if (width == 288)
-+        return height == 352;
-+    if (width == 352)
-+        return height == 288;
-+    if (width == 320)
-+        return height == 240;
-+    if (width == 240)
-+        return height == 320;
-+    return false;
-+}
-+#endif
-+
- @interface RTCVideoEncoderH264 ()
- - (void)frameWasEncoded:(OSStatus)status
-@@ -573,22 +607,20 @@ - (int)resetCompressionSessionWithPixelFormat:(OSType)framePixelFormat {
-     CFRelease(pixelFormat);
-     pixelFormat = nullptr;
-   }
--  CFMutableDictionaryRef encoder_specs = nullptr;
-+  CFDictionaryRef encoderSpecs = nullptr;
- #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
-   // Currently hw accl is supported above 360p on mac, below 360p
-   // the compression session will be created with hw accl disabled.
--  encoder_specs = CFDictionaryCreateMutable(
--      nullptr, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
--  CFDictionarySetValue(encoder_specs,
--                       kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder,
--                       webrtc::isH264HardwareEncoderAllowed() ? kCFBooleanTrue : kCFBooleanFalse);
-+  CFTypeRef sessionKeys[] = {kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder, kVTVideoEncoderSpecification_RequireHardwareAcceleratedVideoEncoder, kVTCompressionPropertyKey_RealTime };
-+  CFTypeRef sessionValues[] = { webrtc::isH264HardwareEncoderAllowed() ? kCFBooleanTrue : kCFBooleanFalse, webrtc::isH264HardwareEncoderAllowed() ? kCFBooleanTrue : kCFBooleanFalse, kCFBooleanTrue };
-+  encoderSpecs = CFDictionaryCreate(kCFAllocatorDefault, sessionKeys, sessionValues, 3, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
- #endif
-   OSStatus status =
-       CompressionSessionCreate(nullptr,  // use default allocator
-                                  _width,
-                                  _height,
-                                  kCodecTypeH264,
--                                 encoder_specs,  // use hardware accelerated encoder if available
-+                                 encoderSpecs,  // use hardware accelerated encoder if available
-                                  sourceAttributes,
-                                  nullptr,  // use default compressed data allocator
-                                  compressionOutputCallback,
-@@ -598,9 +630,9 @@ - (int)resetCompressionSessionWithPixelFormat:(OSType)framePixelFormat {
-     CFRelease(sourceAttributes);
-     sourceAttributes = nullptr;
-   }
--  if (encoder_specs) {
--    CFRelease(encoder_specs);
--    encoder_specs = nullptr;
-+  if (encoderSpecs) {
-+    CFRelease(encoderSpecs);
-+    encoderSpecs = nullptr;
-   }
-   if (status != noErr) {
-     RTC_LOG(LS_ERROR) << "Failed to create compression session: " << status;
-@@ -616,6 +648,78 @@ - (int)resetCompressionSessionWithPixelFormat:(OSType)framePixelFormat {
-     RTC_LOG(LS_INFO) << "Compression session created with hw accl enabled";
-   } else {
-     RTC_LOG(LS_INFO) << "Compression session created with hw accl disabled";
-+
-+#if !ENABLE_VCP_ENCODER && !defined(WEBRTC_IOS)
-+    if (!isStandardFrameSize(_width, _height)) {
-+      RTC_LOG(LS_ERROR) << "Using H264 software encoder with non standard size is not supported";
-+      return WEBRTC_VIDEO_CODEC_ERROR;
-+    }
-+
-+    if (!getkVTVideoEncoderSpecification_Usage()) {
-+      RTC_LOG(LS_ERROR) << "RTCVideoEncoderH264 cannot create a H264 software encoder";
-+      return WEBRTC_VIDEO_CODEC_ERROR;
-+    }
-+
-+    CFDictionaryRef ioSurfaceValue = CreateCFTypeDictionary(nullptr, nullptr, 0);
-+    int64_t pixelFormatType = framePixelFormat;
-+    CFNumberRef pixelFormat = CFNumberCreate(nullptr, kCFNumberLongType, &pixelFormatType);
-+
-+    const size_t attributesSize = 3;
-+    CFTypeRef keys[attributesSize] = {
-+      kCVPixelBufferOpenGLCompatibilityKey,
-+      kCVPixelBufferIOSurfacePropertiesKey,
-+      kCVPixelBufferPixelFormatTypeKey
-+    };
-+    CFTypeRef values[attributesSize] = {
-+      kCFBooleanTrue,
-+      ioSurfaceValue,
-+      pixelFormat};
-+    CFDictionaryRef sourceAttributes = CreateCFTypeDictionary(keys, values, attributesSize);
-+
-+    if (ioSurfaceValue) {
-+      CFRelease(ioSurfaceValue);
-+      ioSurfaceValue = nullptr;
-+    }
-+    if (pixelFormat) {
-+      CFRelease(pixelFormat);
-+      pixelFormat = nullptr;
-+    }
-+
-+    CFMutableDictionaryRef encoderSpecs = CFDictionaryCreateMutable(nullptr, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
-+    CFDictionarySetValue(encoderSpecs, kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder, kCFBooleanFalse);
-+    int usageValue = 1;
-+    CFNumberRef usage = CFNumberCreate(nullptr, kCFNumberIntType, &usageValue);
-+    CFDictionarySetValue(encoderSpecs, getkVTVideoEncoderSpecification_Usage(), usage);
-+    if (usage) {
-+      CFRelease(usage);
-+      usage = nullptr;
-+    }
-+
-+    [self destroyCompressionSession];
-+
-+    OSStatus status =
-+      CompressionSessionCreate(nullptr,  // use default allocator
-+                                 _width,
-+                                 _height,
-+                                 kCodecTypeH264,
-+                                 encoderSpecs,
-+                                 sourceAttributes,
-+                                 nullptr,  // use default compressed data allocator
-+                                 compressionOutputCallback,
-+                                 nullptr,
-+                                 &_compressionSession);
-+    if (sourceAttributes) {
-+      CFRelease(sourceAttributes);
-+      sourceAttributes = nullptr;
-+    }
-+    if (encoder_specs) {
-+      CFRelease(encoder_specs);
-+      encoder_specs = nullptr;
-+    }
-+    if (status != noErr) {
-+      return WEBRTC_VIDEO_CODEC_ERROR;
-+    }
-+#endif
-   }
- #endif
-   [self configureCompressionSession];
-@@ -627,6 +731,9 @@ - (void)configureCompressionSession {
-   SetVTSessionProperty(_compressionSession, kVTCompressionPropertyKey_RealTime, true);
-   SetVTSessionProperty(_compressionSession, kVTCompressionPropertyKey_ProfileLevel, _profile);
-   SetVTSessionProperty(_compressionSession, kVTCompressionPropertyKey_AllowFrameReordering, false);
-+#if ENABLE_VCP_ENCODER
-+  SetVTSessionProperty(_compressionSession, (__bridge CFStringRef)getkVTVideoEncoderSpecification_Usage(), 1);
-+#endif
-   [self setEncoderBitrateBps:_targetBitrateBps];
-   // TODO(tkchin): Look at entropy mode and colorspace matrices.
-   // TODO(tkchin): Investigate to see if there's any way to make this work.
--- 
-2.15.1 (Apple Git-101)
-