Title: [278906] trunk/Source/ThirdParty/libwebrtc
Revision
278906
Author
you...@apple.com
Date
2021-06-15 15:00:45 -0700 (Tue, 15 Jun 2021)

Log Message

Enable kVTVideoEncoderSpecification_RequiredLowLatency in case of MacOS software encoder
https://bugs.webkit.org/show_bug.cgi?id=226873

Reviewed by Eric Carlson.

In case software encoder is being created for baseline, we can use kVTVideoEncoderSpecification_RequiredLowLatency
which provides better bitrate management than the regular SW encoder while still generating baseline content.
We check whether SW encoder is created based on kVTCompressionPropertyKey_UsingHardwareAcceleratedVideoEncoder.
If property is unsupported or if its value is false, it means the encoder is software.

* Source/webrtc/sdk/objc/components/video_codec/RTCVideoEncoderH264.mm:
(-[RTCVideoEncoderH264 resetCompressionSessionWithPixelFormat:]):

Modified Paths

Diff

Modified: trunk/Source/ThirdParty/libwebrtc/ChangeLog (278905 => 278906)


--- trunk/Source/ThirdParty/libwebrtc/ChangeLog	2021-06-15 21:49:42 UTC (rev 278905)
+++ trunk/Source/ThirdParty/libwebrtc/ChangeLog	2021-06-15 22:00:45 UTC (rev 278906)
@@ -1,5 +1,20 @@
 2021-06-15  Youenn Fablet  <you...@apple.com>
 
+        Enable kVTVideoEncoderSpecification_RequiredLowLatency in case of MacOS software encoder
+        https://bugs.webkit.org/show_bug.cgi?id=226873
+
+        Reviewed by Eric Carlson.
+
+        In case software encoder is being created for baseline, we can use kVTVideoEncoderSpecification_RequiredLowLatency
+        which provides better bitrate management than the regular SW encoder while still generating baseline content.
+        We check whether SW encoder is created based on kVTCompressionPropertyKey_UsingHardwareAcceleratedVideoEncoder.
+        If property is unsupported or if its value is false, it means the encoder is software.
+
+        * Source/webrtc/sdk/objc/components/video_codec/RTCVideoEncoderH264.mm:
+        (-[RTCVideoEncoderH264 resetCompressionSessionWithPixelFormat:]):
+
+2021-06-15  Youenn Fablet  <you...@apple.com>
+
         REGRESSION: [ BigSur iOS wk1 Debug ] imported/w3c/web-platform-tests/html/dom/usvstring-reflection.https.html is flaky crashing
         https://bugs.webkit.org/show_bug.cgi?id=226928
         <rdar://problem/79205526>

Modified: trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/RTCVideoEncoderH264.mm (278905 => 278906)


--- trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/RTCVideoEncoderH264.mm	2021-06-15 21:49:42 UTC (rev 278905)
+++ trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/RTCVideoEncoderH264.mm	2021-06-15 22:00:45 UTC (rev 278906)
@@ -769,7 +769,27 @@
   CFBooleanRef hwaccl_enabled = nullptr;
   if (status == noErr) {
     auto result = VTSessionCopyProperty(_vtCompressionSession, kVTCompressionPropertyKey_UsingHardwareAcceleratedVideoEncoder, nullptr, &hwaccl_enabled);
-    _isUsingSoftwareEncoder = result == noErr ? !CFBooleanGetValue(hwaccl_enabled) : _width <= 480 && _height <= 480;
+    _isUsingSoftwareEncoder = result == noErr ? !CFBooleanGetValue(hwaccl_enabled) : true;
+#if HAVE_VTB_REQUIREDLOWLATENCY
+    if (_isUsingSoftwareEncoder && _isH264LowLatencyEncoderEnabled && _vtCompressionSession && !_useVCP) {
+      VTCompressionSessionInvalidate(_vtCompressionSession);
+      CFRelease(_vtCompressionSession);
+      _vtCompressionSession = nullptr;
+
+      CFDictionarySetValue(encoderSpecs, kVTVideoEncoderSpecification_RequiredLowLatency, kCFBooleanTrue);
+      CFDictionarySetValue(encoderSpecs, kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder, kCFBooleanFalse);
+      status = VTCompressionSessionCreate(nullptr,  // use default allocator
+                                       _width,
+                                       _height,
+                                       kCMVideoCodecType_H264,
+                                       encoderSpecs,  // use hardware accelerated encoder if available
+                                       sourceAttributes,
+                                       nullptr,  // use default compressed data allocator
+                                       compressionOutputCallback,
+                                       nullptr,
+                                       &_vtCompressionSession);
+    }
+#endif
   }
 #else
   // Provided encoder should be good enough.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to