Changeset 245289 in webkit


Ignore:
Timestamp:
May 14, 2019 10:43:19 AM (5 years ago)
Author:
youenn@apple.com
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:
Location:
trunk
Files:
6 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r245286 r245289  
     12019-05-14  Youenn Fablet  <youenn@apple.com>
     2
     3        Video frame resizing should be using Trim
     4        https://bugs.webkit.org/show_bug.cgi?id=197722
     5        <rdar://problem/50602188>
     6
     7        Reviewed by Eric Carlson.
     8
     9        * fast/mediastream/resize-trim-expected.txt: Renamed from LayoutTests/fast/mediastream/resize-letterbox-expected.txt.
     10        * fast/mediastream/resize-trim.html: Renamed from LayoutTests/fast/mediastream/resize-letterbox.html.
     11        * platform/gtk/TestExpectations:
     12
    1132019-05-14  Antoine Quint  <graouts@apple.com>
    214
  • trunk/LayoutTests/fast/mediastream/resize-trim.html

    r245288 r245289  
    88        <script>
    99
    10 const canvas = document.getElementById("canvas");
    11 const video = document.getElementById("video");
    12 
    13 function isPixelBlack(pixel)
    14 {
    15     return pixel[0] === 0 && pixel[1] === 0 && pixel[2] === 0 && pixel[3] === 255;
    16 }
    17 
    1810function isPixelGray(pixel)
    1911{
    2012    return pixel[0] === 128 && pixel[1] === 128 && pixel[2] === 128 && pixel[3] === 255;
    21 }
    22 
    23 function logPixel(name, pixel)
    24 {
    25     console.log(`${name}: ${pixel[0]}, ${pixel[1]}, ${pixel[2]}, ${pixel[3]}`);
    26 }
    27 
    28 function checkCanvas(canvas, stream)
    29 {
    30     return new Promise((resolve, reject) => {
    31         video.srcObject = stream;
    32         video.onplay = () => {
    33             const ctx = canvas.getContext("2d");
    34             ctx.drawImage(video, 0 ,0);
    35 
    36             try {
    37                 setTimeout(() => {
    38                     assert_true(isPixelBlack(ctx.getImageData(5, 5, 1, 1).data), "Pixel at 5x5 is NOT from camera.");
    39                     assert_true(isPixelGray(ctx.getImageData(50, 200, 1, 1).data), "Pixel at 50x200 is from camera.");
    40                     resolve();
    41                 }, 500);
    42             } catch(err) {
    43                 reject(err);
    44                 return;
    45             }
    46         }
    47     });
    4813}
    4914
     
    5823   
    5924    stream = await navigator.mediaDevices.getUserMedia({ video: { deviceId: { exact: cameraID }, width: 480, height: 480 } });
     25    video.srcObject = stream;
     26    await video.play();
    6027   
    61     return checkCanvas(canvas, stream);
     28    const ctx = canvas.getContext("2d");
     29    ctx.drawImage(video, 0 ,0);
    6230
     31    assert_true(isPixelGray(ctx.getImageData(5, 5, 1, 1).data), "Pixel at 5x5 is not black.");
     32    assert_true(isPixelGray(ctx.getImageData(10, 200, 1, 1).data), "Pixel at 10x200 is not black.");
    6333}, "Video frames are resized in letterbox-mode when captured at non-native size.");
    6434
  • trunk/LayoutTests/platform/gtk/TestExpectations

    r245074 r245289  
    37103710
    37113711webkit.org/b/192886 fast/mediastream/media-stream-renders-first-frame.html [ Failure ]
    3712 webkit.org/b/192888 fast/mediastream/resize-letterbox.html [ Failure ]
     3712webkit.org/b/192888 fast/mediastream/resize-trim.html [ Failure ]
    37133713
    37143714webkit.org/b/192900 imported/w3c/web-platform-tests/eventsource/format-mime-bogus.htm [ Failure ]
  • trunk/Source/WebCore/ChangeLog

    r245288 r245289  
     12019-05-14  Youenn Fablet  <youenn@apple.com>
     2
     3        Video frame resizing should be using Trim
     4        https://bugs.webkit.org/show_bug.cgi?id=197722
     5        <rdar://problem/50602188>
     6
     7        Reviewed by Eric Carlson.
     8
     9        Move from letter box to trim mode for resizing.
     10        This ensures no black stripes are present when rendering the stream.
     11
     12        Test: fast/mediastream/resize-trim.html
     13
     14        * platform/cocoa/VideoToolboxSoftLink.cpp:
     15        * platform/cocoa/VideoToolboxSoftLink.h:
     16        * platform/graphics/cv/ImageTransferSessionVT.mm:
     17        (WebCore::ImageTransferSessionVT::ImageTransferSessionVT):
     18
    1192019-05-14  Yusuke Suzuki  <ysuzuki@apple.com>
    220
  • trunk/Source/WebCore/platform/cocoa/VideoToolboxSoftLink.cpp

    r243109 r245289  
    6565SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, VideoToolbox, kVTPixelTransferPropertyKey_ScalingMode, CFStringRef)
    6666SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, VideoToolbox, kVTScalingMode_Letterbox, CFStringRef)
     67SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, VideoToolbox, kVTScalingMode_Trim, CFStringRef)
    6768SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, VideoToolbox, kVTPixelTransferPropertyKey_EnableHardwareAcceleratedTransfer, CFStringRef)
    6869SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, VideoToolbox, kVTPixelTransferPropertyKey_EnableHighSpeedTransfer, CFStringRef)
  • trunk/Source/WebCore/platform/cocoa/VideoToolboxSoftLink.h

    r243109 r245289  
    9292SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, VideoToolbox, kVTScalingMode_Letterbox, CFStringRef)
    9393#define kVTScalingMode_Letterbox get_VideoToolbox_kVTScalingMode_Letterbox()
     94SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, VideoToolbox, kVTScalingMode_Trim, CFStringRef)
     95#define kVTScalingMode_Trim get_VideoToolbox_kVTScalingMode_Trim()
    9496SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, VideoToolbox, kVTPixelTransferPropertyKey_EnableHardwareAcceleratedTransfer, CFStringRef)
    9597#define kVTPixelTransferPropertyKey_EnableHardwareAcceleratedTransfer get_VideoToolbox_kVTPixelTransferPropertyKey_EnableHardwareAcceleratedTransfer()
  • trunk/Source/WebCore/platform/graphics/cv/ImageTransferSessionVT.mm

    r239016 r245289  
    6060    m_transferSession = adoptCF(transferSession);
    6161
    62     auto status = VTSessionSetProperty(transferSession, kVTPixelTransferPropertyKey_ScalingMode, kVTScalingMode_Letterbox);
     62    auto status = VTSessionSetProperty(transferSession, kVTPixelTransferPropertyKey_ScalingMode, kVTScalingMode_Trim);
    6363    if (status != kCVReturnSuccess)
    6464        RELEASE_LOG(Media, "ImageTransferSessionVT::ImageTransferSessionVT: VTSessionSetProperty(kVTPixelTransferPropertyKey_ScalingMode) failed with error %d", static_cast<int>(status));
Note: See TracChangeset for help on using the changeset viewer.