Title: [245289] trunk
Revision
245289
Author
[email protected]
Date
2019-05-14 10:43:19 -0700 (Tue, 14 May 2019)

Log Message

Video frame resizing should be using Trim
https://bugs.webkit.org/show_bug.cgi?id=197722
<rdar://problem/50602188>

Reviewed by Eric Carlson.

Source/WebCore:

Move from letter box to trim mode for resizing.
This ensures no black stripes are present when rendering the stream.

Test: fast/mediastream/resize-trim.html

* platform/cocoa/VideoToolboxSoftLink.cpp:
* platform/cocoa/VideoToolboxSoftLink.h:
* platform/graphics/cv/ImageTransferSessionVT.mm:
(WebCore::ImageTransferSessionVT::ImageTransferSessionVT):

LayoutTests:

* fast/mediastream/resize-trim-expected.txt: Renamed from LayoutTests/fast/mediastream/resize-letterbox-expected.txt.
* fast/mediastream/resize-trim.html: Renamed from LayoutTests/fast/mediastream/resize-letterbox.html.
* platform/gtk/TestExpectations:

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (245288 => 245289)


--- trunk/LayoutTests/ChangeLog	2019-05-14 17:31:53 UTC (rev 245288)
+++ trunk/LayoutTests/ChangeLog	2019-05-14 17:43:19 UTC (rev 245289)
@@ -1,3 +1,15 @@
+2019-05-14  Youenn Fablet  <[email protected]>
+
+        Video frame resizing should be using Trim
+        https://bugs.webkit.org/show_bug.cgi?id=197722
+        <rdar://problem/50602188>
+
+        Reviewed by Eric Carlson.
+
+        * fast/mediastream/resize-trim-expected.txt: Renamed from LayoutTests/fast/mediastream/resize-letterbox-expected.txt.
+        * fast/mediastream/resize-trim.html: Renamed from LayoutTests/fast/mediastream/resize-letterbox.html.
+        * platform/gtk/TestExpectations:
+
 2019-05-14  Antoine Quint  <[email protected]>
 
         [Pointer Events] The pointerenter and pointerleave events target the wrong element on iOS

Deleted: trunk/LayoutTests/fast/mediastream/resize-letterbox-expected.txt (245288 => 245289)


--- trunk/LayoutTests/fast/mediastream/resize-letterbox-expected.txt	2019-05-14 17:31:53 UTC (rev 245288)
+++ trunk/LayoutTests/fast/mediastream/resize-letterbox-expected.txt	2019-05-14 17:43:19 UTC (rev 245289)
@@ -1,4 +0,0 @@
-
-
-PASS Video frames are resized in letterbox-mode when captured at non-native size. 
-

Deleted: trunk/LayoutTests/fast/mediastream/resize-letterbox.html (245288 => 245289)


--- trunk/LayoutTests/fast/mediastream/resize-letterbox.html	2019-05-14 17:31:53 UTC (rev 245288)
+++ trunk/LayoutTests/fast/mediastream/resize-letterbox.html	2019-05-14 17:43:19 UTC (rev 245289)
@@ -1,67 +0,0 @@
-<!DOCTYPE html>
-<html>
-    <head>
-        <video id="video" autoplay width=480px height=480px controls ></video>
-        <canvas id="canvas" width=480px height=480px></canvas>
-        <script src=""
-        <script src=""
-        <script>
-
-const canvas = document.getElementById("canvas");
-const video = document.getElementById("video");
-
-function isPixelBlack(pixel)
-{
-    return pixel[0] === 0 && pixel[1] === 0 && pixel[2] === 0 && pixel[3] === 255;
-}
-
-function isPixelGray(pixel)
-{
-    return pixel[0] === 128 && pixel[1] === 128 && pixel[2] === 128 && pixel[3] === 255;
-}
-
-function logPixel(name, pixel)
-{
-    console.log(`${name}: ${pixel[0]}, ${pixel[1]}, ${pixel[2]}, ${pixel[3]}`);
-}
-
-function checkCanvas(canvas, stream)
-{
-    return new Promise((resolve, reject) => {
-        video.srcObject = stream;
-        video._onplay_ = () => {
-            const ctx = canvas.getContext("2d");
-            ctx.drawImage(video, 0 ,0);
-
-            try {
-                setTimeout(() => {
-                    assert_true(isPixelBlack(ctx.getImageData(5, 5, 1, 1).data), "Pixel at 5x5 is NOT from camera.");
-                    assert_true(isPixelGray(ctx.getImageData(50, 200, 1, 1).data), "Pixel at 50x200 is from camera.");
-                    resolve();
-                }, 500);
-            } catch(err) {
-                reject(err);
-                return;
-            }
-        }
-    });
-}
-
-promise_test(async () => {
-    let stream = await navigator.mediaDevices.getUserMedia({ video: true });
-    stream = null;
-
-    const devices = await navigator.mediaDevices.enumerateDevices();
-    let cameraID = undefined;
-    devices.forEach(device => { if (device.label == "Mock video device 2") cameraID = device.deviceId; });
-    assert_true(cameraID !== undefined, "Found camera2");
-    
-    stream = await navigator.mediaDevices.getUserMedia({ video: { deviceId: { exact: cameraID }, width: 480, height: 480 } });
-    
-    return checkCanvas(canvas, stream);
-
-}, "Video frames are resized in letterbox-mode when captured at non-native size.");
-
-        </script>
-    </head>
-</html>

Copied: trunk/LayoutTests/fast/mediastream/resize-trim-expected.txt (from rev 245288, trunk/LayoutTests/fast/mediastream/resize-letterbox-expected.txt) (0 => 245289)


--- trunk/LayoutTests/fast/mediastream/resize-trim-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/mediastream/resize-trim-expected.txt	2019-05-14 17:43:19 UTC (rev 245289)
@@ -0,0 +1,4 @@
+
+
+PASS Video frames are resized in letterbox-mode when captured at non-native size. 
+

Copied: trunk/LayoutTests/fast/mediastream/resize-trim.html (from rev 245288, trunk/LayoutTests/fast/mediastream/resize-letterbox.html) (0 => 245289)


--- trunk/LayoutTests/fast/mediastream/resize-trim.html	                        (rev 0)
+++ trunk/LayoutTests/fast/mediastream/resize-trim.html	2019-05-14 17:43:19 UTC (rev 245289)
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <video id="video" autoplay width=480px height=480px controls ></video>
+        <canvas id="canvas" width=480px height=480px></canvas>
+        <script src=""
+        <script src=""
+        <script>
+
+function isPixelGray(pixel)
+{
+    return pixel[0] === 128 && pixel[1] === 128 && pixel[2] === 128 && pixel[3] === 255;
+}
+
+promise_test(async () => {
+    let stream = await navigator.mediaDevices.getUserMedia({ video: true });
+    stream = null;
+
+    const devices = await navigator.mediaDevices.enumerateDevices();
+    let cameraID = undefined;
+    devices.forEach(device => { if (device.label == "Mock video device 2") cameraID = device.deviceId; });
+    assert_true(cameraID !== undefined, "Found camera2");
+    
+    stream = await navigator.mediaDevices.getUserMedia({ video: { deviceId: { exact: cameraID }, width: 480, height: 480 } });
+    video.srcObject = stream;
+    await video.play();
+    
+    const ctx = canvas.getContext("2d");
+    ctx.drawImage(video, 0 ,0);
+
+    assert_true(isPixelGray(ctx.getImageData(5, 5, 1, 1).data), "Pixel at 5x5 is not black.");
+    assert_true(isPixelGray(ctx.getImageData(10, 200, 1, 1).data), "Pixel at 10x200 is not black.");
+}, "Video frames are resized in letterbox-mode when captured at non-native size.");
+
+        </script>
+    </head>
+</html>

Modified: trunk/LayoutTests/platform/gtk/TestExpectations (245288 => 245289)


--- trunk/LayoutTests/platform/gtk/TestExpectations	2019-05-14 17:31:53 UTC (rev 245288)
+++ trunk/LayoutTests/platform/gtk/TestExpectations	2019-05-14 17:43:19 UTC (rev 245289)
@@ -3709,7 +3709,7 @@
 webkit.org/b/192883 fast/cookies/local-file-can-set-cookies.html [ Failure ]
 
 webkit.org/b/192886 fast/mediastream/media-stream-renders-first-frame.html [ Failure ]
-webkit.org/b/192888 fast/mediastream/resize-letterbox.html [ Failure ]
+webkit.org/b/192888 fast/mediastream/resize-trim.html [ Failure ]
 
 webkit.org/b/192900 imported/w3c/web-platform-tests/eventsource/format-mime-bogus.htm [ Failure ]
 

Modified: trunk/Source/WebCore/ChangeLog (245288 => 245289)


--- trunk/Source/WebCore/ChangeLog	2019-05-14 17:31:53 UTC (rev 245288)
+++ trunk/Source/WebCore/ChangeLog	2019-05-14 17:43:19 UTC (rev 245289)
@@ -1,3 +1,21 @@
+2019-05-14  Youenn Fablet  <[email protected]>
+
+        Video frame resizing should be using Trim
+        https://bugs.webkit.org/show_bug.cgi?id=197722
+        <rdar://problem/50602188>
+
+        Reviewed by Eric Carlson.
+
+        Move from letter box to trim mode for resizing.
+        This ensures no black stripes are present when rendering the stream.
+
+        Test: fast/mediastream/resize-trim.html
+
+        * platform/cocoa/VideoToolboxSoftLink.cpp:
+        * platform/cocoa/VideoToolboxSoftLink.h:
+        * platform/graphics/cv/ImageTransferSessionVT.mm:
+        (WebCore::ImageTransferSessionVT::ImageTransferSessionVT):
+
 2019-05-14  Yusuke Suzuki  <[email protected]>
 
         [JSC] Shrink sizeof(UnlinkedFunctionExecutable) more

Modified: trunk/Source/WebCore/platform/cocoa/VideoToolboxSoftLink.cpp (245288 => 245289)


--- trunk/Source/WebCore/platform/cocoa/VideoToolboxSoftLink.cpp	2019-05-14 17:31:53 UTC (rev 245288)
+++ trunk/Source/WebCore/platform/cocoa/VideoToolboxSoftLink.cpp	2019-05-14 17:43:19 UTC (rev 245289)
@@ -64,6 +64,7 @@
 SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, VideoToolbox, VTSessionSetProperty, OSStatus, (VTSessionRef session, CFStringRef propertyKey, CFTypeRef propertyValue), (session, propertyKey, propertyValue))
 SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, VideoToolbox, kVTPixelTransferPropertyKey_ScalingMode, CFStringRef)
 SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, VideoToolbox, kVTScalingMode_Letterbox, CFStringRef)
+SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, VideoToolbox, kVTScalingMode_Trim, CFStringRef)
 SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, VideoToolbox, kVTPixelTransferPropertyKey_EnableHardwareAcceleratedTransfer, CFStringRef)
 SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, VideoToolbox, kVTPixelTransferPropertyKey_EnableHighSpeedTransfer, CFStringRef)
 SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, VideoToolbox, kVTPixelTransferPropertyKey_RealTime, CFStringRef)

Modified: trunk/Source/WebCore/platform/cocoa/VideoToolboxSoftLink.h (245288 => 245289)


--- trunk/Source/WebCore/platform/cocoa/VideoToolboxSoftLink.h	2019-05-14 17:31:53 UTC (rev 245288)
+++ trunk/Source/WebCore/platform/cocoa/VideoToolboxSoftLink.h	2019-05-14 17:43:19 UTC (rev 245289)
@@ -91,6 +91,8 @@
 #define kVTPixelTransferPropertyKey_ScalingMode get_VideoToolbox_kVTPixelTransferPropertyKey_ScalingMode()
 SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, VideoToolbox, kVTScalingMode_Letterbox, CFStringRef)
 #define kVTScalingMode_Letterbox get_VideoToolbox_kVTScalingMode_Letterbox()
+SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, VideoToolbox, kVTScalingMode_Trim, CFStringRef)
+#define kVTScalingMode_Trim get_VideoToolbox_kVTScalingMode_Trim()
 SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, VideoToolbox, kVTPixelTransferPropertyKey_EnableHardwareAcceleratedTransfer, CFStringRef)
 #define kVTPixelTransferPropertyKey_EnableHardwareAcceleratedTransfer get_VideoToolbox_kVTPixelTransferPropertyKey_EnableHardwareAcceleratedTransfer()
 SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, VideoToolbox, kVTPixelTransferPropertyKey_EnableHighSpeedTransfer, CFStringRef)

Modified: trunk/Source/WebCore/platform/graphics/cv/ImageTransferSessionVT.mm (245288 => 245289)


--- trunk/Source/WebCore/platform/graphics/cv/ImageTransferSessionVT.mm	2019-05-14 17:31:53 UTC (rev 245288)
+++ trunk/Source/WebCore/platform/graphics/cv/ImageTransferSessionVT.mm	2019-05-14 17:43:19 UTC (rev 245289)
@@ -59,7 +59,7 @@
     ASSERT(transferSession);
     m_transferSession = adoptCF(transferSession);
 
-    auto status = VTSessionSetProperty(transferSession, kVTPixelTransferPropertyKey_ScalingMode, kVTScalingMode_Letterbox);
+    auto status = VTSessionSetProperty(transferSession, kVTPixelTransferPropertyKey_ScalingMode, kVTScalingMode_Trim);
     if (status != kCVReturnSuccess)
         RELEASE_LOG(Media, "ImageTransferSessionVT::ImageTransferSessionVT: VTSessionSetProperty(kVTPixelTransferPropertyKey_ScalingMode) failed with error %d", static_cast<int>(status));
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to