Title: [276478] trunk
Revision
276478
Author
[email protected]
Date
2021-04-22 17:56:56 -0700 (Thu, 22 Apr 2021)

Log Message

Fix color gamut in WebRTC when using VPx software decoder.
https://bugs.webkit.org/show_bug.cgi?id=220972
<rdar://problem/73616455>

Reviewed by Youenn Fablet.

Source/WebCore:

By default, and how libwebrtc is configuring its encoders and decoder, video range levels are used
(16-235). Video range was assumed to use full range instead (0-255), causing blacks to look grey and
whites to appear washed-out.
It is theoretically possible, when using VP9 that full-range level are used. While the information
related to video levels is available at the VP9 codec level; only the color space information is
being made available in libwebrtc's public image data structure, color range isn't.
For now we can assume the default is sufficient, and a follow-up change will be submitted to libwebrtc
later on.

In memory of Dr. Alex. May he rest in peace.
Test: webrtc/video-vp8-videorange.html

* platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm:
(WebCore::RealtimeIncomingVideoSourceCocoa::pixelBufferPool):

LayoutTests:

* webrtc/video-vp8-videorange-expected.txt: Added.
* webrtc/video-vp8-videorange.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (276477 => 276478)


--- trunk/LayoutTests/ChangeLog	2021-04-23 00:42:09 UTC (rev 276477)
+++ trunk/LayoutTests/ChangeLog	2021-04-23 00:56:56 UTC (rev 276478)
@@ -1,3 +1,14 @@
+2021-04-22  Jean-Yves Avenard  <[email protected]>
+
+        Fix color gamut in WebRTC when using VPx software decoder.
+        https://bugs.webkit.org/show_bug.cgi?id=220972
+        <rdar://problem/73616455>
+
+        Reviewed by Youenn Fablet.
+
+        * webrtc/video-vp8-videorange-expected.txt: Added.
+        * webrtc/video-vp8-videorange.html: Added.
+
 2021-04-22  Robert Jenner  <[email protected]>
 
         REGRESSION (Metal ANGLE): webgl/2.0.0/conformance/glsl/misc/shader-uniform-packing-restrictions.html is constantly timing out. 

Added: trunk/LayoutTests/webrtc/video-vp8-videorange-expected.txt (0 => 276478)


--- trunk/LayoutTests/webrtc/video-vp8-videorange-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/webrtc/video-vp8-videorange-expected.txt	2021-04-23 00:56:56 UTC (rev 276478)
@@ -0,0 +1,6 @@
+Video should be running, a checker be drawn and colors matching the original.
+
+
+PASS Setting video exchange
+PASS Track is enabled, video should not be black
+

Added: trunk/LayoutTests/webrtc/video-vp8-videorange.html (0 => 276478)


--- trunk/LayoutTests/webrtc/video-vp8-videorange.html	                        (rev 0)
+++ trunk/LayoutTests/webrtc/video-vp8-videorange.html	2021-04-23 00:56:56 UTC (rev 276478)
@@ -0,0 +1,80 @@
+<!doctype html>
+<html>
+    <head>
+        <meta charset="utf-8">
+        <title>Testing that VP8 videos are using limited video range</title>
+        <script src=""
+        <script src=""
+    </head>
+    <body>
+        <div>Video should be running, a checker be drawn and colors matching the original.</div>
+        <canvas id="canvas1" width="320" height="320"></canvas>
+        <video id="video" autoplay playsInline width="320" height="320"></video>
+        <canvas id="canvas2" width="320" height="320"></canvas>
+        <script src =""
+        <script>
+
+var ctx = canvas1.getContext("2d");
+
+// draw black and white checker.
+function drawChecker(ctx, x, y, width, height) {
+  for (var i = 0; i < x; i++) {
+      for (var j = 0; j < y; j++) {
+        if ((i + j) % 2 == 0)
+            ctx.fillStyle = "#000000";
+        else
+            ctx.fillStyle = "#FFFFFF";
+        ctx.fillRect(i * width / x, j * height / y, width / x, height / y);
+      }
+  }
+}
+
+const FPS = 30;
+var track;
+var remoteTrack;
+var receivingConnection;
+var localStream;
+
+// TODO. Bug 224960: Investigate why we need to redraw the canvas for the play promise to later be resolved.
+// Repeatedly redraw the checker to get the video stream going.
+setInterval(() => drawChecker(ctx, 2, 2, canvas1.width, canvas1.height), 1000 / FPS);
+
+promise_test(async (test) => {
+    const remoteStream = await new Promise((resolve, reject) => {
+        localStream = canvas1.captureStream(FPS);
+        track = localStream.getVideoTracks()[0];
+
+        createConnections((firstConnection) => {
+            firstConnection.addTrack(track, localStream);
+            firstConnection.getTransceivers()[0].setCodecPreferences([{mimeType: "video/VP8", clockRate: 90000}]);
+        }, (secondConnection) => {
+            receivingConnection = secondConnection;
+            secondConnection._ontrack_ = (trackEvent) => {
+                remoteTrack = trackEvent.track;
+                resolve(trackEvent.streams[0]);
+            };
+        }, { observeOffer : test.step_func((offer) => {
+            assert_false(offer.sdp.includes("H264"), "No H264");
+            assert_true(offer.sdp.includes("VP8"), "VP8");
+            return offer;
+        })
+        });
+        setTimeout(() => reject("Test timed out"), 5000);
+    });
+    video.srcObject = remoteStream;
+    return video.play();
+}, "Setting video exchange");
+
+promise_test(async (test) => {
+    await checkVideoBlack(false, canvas2, video);
+    let context = canvas2.getContext('2d');
+    // Check pixel is pure black in top left square.
+    let pixelData = context.getImageData(canvas2.width / 4, canvas2.height / 4, 1, 1).data;
+    assert_equals([ pixelData[0], pixelData[1], pixelData[2] ].join(), [0, 0, 0].join());
+    // Check pixel is pure white in top right square.
+    pixelData = context.getImageData(3 * canvas2.width / 4, canvas2.height / 4, 1, 1).data;
+    assert_equals([ pixelData[0], pixelData[1], pixelData[2] ].join(), [255, 255, 255].join());
+}, "Track is enabled, video should not be black");
+        </script>
+    </body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (276477 => 276478)


--- trunk/Source/WebCore/ChangeLog	2021-04-23 00:42:09 UTC (rev 276477)
+++ trunk/Source/WebCore/ChangeLog	2021-04-23 00:56:56 UTC (rev 276478)
@@ -1,3 +1,26 @@
+2021-04-22  Jean-Yves Avenard  <[email protected]>
+
+        Fix color gamut in WebRTC when using VPx software decoder.
+        https://bugs.webkit.org/show_bug.cgi?id=220972
+        <rdar://problem/73616455>
+
+        Reviewed by Youenn Fablet.
+
+        By default, and how libwebrtc is configuring its encoders and decoder, video range levels are used
+        (16-235). Video range was assumed to use full range instead (0-255), causing blacks to look grey and
+        whites to appear washed-out.
+        It is theoretically possible, when using VP9 that full-range level are used. While the information
+        related to video levels is available at the VP9 codec level; only the color space information is
+        being made available in libwebrtc's public image data structure, color range isn't.
+        For now we can assume the default is sufficient, and a follow-up change will be submitted to libwebrtc
+        later on.
+
+        In memory of Dr. Alex. May he rest in peace.
+        Test: webrtc/video-vp8-videorange.html
+
+        * platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm:
+        (WebCore::RealtimeIncomingVideoSourceCocoa::pixelBufferPool):
+
 2021-04-22  Michael Catanzaro  <[email protected]>
 
         [SOUP] Null pointer dereference in ResourceLoader::didReceiveAuthenticationChallenge

Modified: trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm (276477 => 276478)


--- trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm	2021-04-23 00:42:09 UTC (rev 276477)
+++ trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm	2021-04-23 00:56:56 UTC (rev 276478)
@@ -94,10 +94,10 @@
         OSType poolBufferType;
         switch (bufferType) {
         case webrtc::BufferType::I420:
-            poolBufferType = kCVPixelFormatType_420YpCbCr8BiPlanarFullRange;
+            poolBufferType = kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange;
             break;
         case webrtc::BufferType::I010:
-            poolBufferType = kCVPixelFormatType_420YpCbCr10BiPlanarFullRange;
+            poolBufferType = kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange;
         }
         m_pixelBufferPool = createPixelBufferPool(width, height, poolBufferType);
         m_pixelBufferPoolWidth = width;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to