Skip to content

Commit 9da0fa4

Browse files
committed
Add support for VideoFrame.rotation
https://bugs.webkit.org/show_bug.cgi?id=327664 rdar://problem/190098439 Reviewed by Philippe Normand. We expose, under a feature flag, WebCodecs VideoFrame.rotation. We add support for creating rotated VideoFrames as well. We do not yet support proper rendering of rotated VideoFrames, this will be done as a follow-up. In case the feature flag is off, there should be no observable changes. We introduce some routines to handle rotation parsing and combining as per spec. Covered by rebased tests and added test. * LayoutTests/imported/w3c/web-platform-tests/webcodecs/idlharness.https.any-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/webcodecs/idlharness.https.any.worker-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/webcodecs/videoDecoder-codec-specific-orientation.https.any.worker_av1-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/webcodecs/videoDecoder-codec-specific-orientation.https.any.worker_h264_annexb-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/webcodecs/videoDecoder-codec-specific-orientation.https.any.worker_h264_avc-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/webcodecs/videoDecoder-codec-specific-orientation.https.any.worker_h265_annexb-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/webcodecs/videoDecoder-codec-specific-orientation.https.any.worker_h265_hevc-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/webcodecs/videoDecoder-codec-specific-orientation.https.any.worker_vp8-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/webcodecs/videoDecoder-codec-specific-orientation.https.any.worker_vp9-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/webcodecs/videoDecoder-codec-specific-orientation.https.any_av1-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/webcodecs/videoDecoder-codec-specific-orientation.https.any_h264_annexb-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/webcodecs/videoDecoder-codec-specific-orientation.https.any_h264_avc-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/webcodecs/videoDecoder-codec-specific-orientation.https.any_h265_annexb-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/webcodecs/videoDecoder-codec-specific-orientation.https.any_h265_hevc-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/webcodecs/videoDecoder-codec-specific-orientation.https.any_vp8-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/webcodecs/videoDecoder-codec-specific-orientation.https.any_vp9-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/webcodecs/videoFrame-orientation.any-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/webcodecs/videoFrame-orientation.any.worker-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/webcodecs/videoFrame-rotation.any-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/webcodecs/videoFrame-rotation.any.html: Added. * LayoutTests/imported/w3c/web-platform-tests/webcodecs/videoFrame-rotation.any.js: Added. (makeData): (makeFrame): (expectedDisplaySize): (verifyFrame): (test): (270.test): (270.270.test): (expected.of.kRotations.test): (Infinity.test): (promise_test.async t): * LayoutTests/imported/w3c/web-platform-tests/webcodecs/videoFrame-rotation.any.worker-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/webcodecs/videoFrame-rotation.any.worker.html: Added. * Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml: * Source/WebCore/Modules/webcodecs/WebCodecsVideoFrame.cpp: (WebCore::WebCodecsVideoFrame::create): (WebCore::WebCodecsVideoFrame::initializeFrameFromOtherFrame): (WebCore::WebCodecsVideoFrame::initializeFrameWithResourceAndSize): (WebCore::WebCodecsVideoFrame::rotation const): * Source/WebCore/Modules/webcodecs/WebCodecsVideoFrame.h: * Source/WebCore/Modules/webcodecs/WebCodecsVideoFrame.idl: * Source/WebCore/Modules/webcodecs/WebCodecsVideoFrameAlgorithms.cpp: (WebCore::makeSureRotationIsBetween0And360): (WebCore::parseVideoFrameRotation): (WebCore::addVideoFrameRotations): (WebCore::combineVideoFrameRotations): (WebCore::initializeVisibleRectAndDisplaySize): * Source/WebCore/Modules/webcodecs/WebCodecsVideoFrameAlgorithms.h: * Source/WebCore/platform/VideoFrame.cpp: (WebCore::VideoFrame::updateRotation): (WebCore::VideoFrame::createNV12): (WebCore::VideoFrame::createRGBA): (WebCore::VideoFrame::createRGBX): (WebCore::VideoFrame::createBGRA): (WebCore::VideoFrame::createBGRX): (WebCore::VideoFrame::createI420): (WebCore::VideoFrame::createI420A): * Source/WebCore/platform/VideoFrame.h: (WebCore::is90DegreeRotation): (WebCore::VideoFrame::has90DegreeRotation const): * Source/WebCore/platform/graphics/cv/VideoFrameCV.mm: (WebCore::VideoFrame::createNV12): (WebCore::VideoFrame::createRGBA): (WebCore::VideoFrame::createRGBX): (WebCore::VideoFrame::createBGRA): (WebCore::VideoFrame::createBGRX): (WebCore::VideoFrame::createI420): (WebCore::VideoFrame::createI420A): * Source/WebCore/platform/graphics/gstreamer/VideoFrameGStreamer.cpp: (WebCore::createOptionsWithRotation): (WebCore::VideoFrame::createNV12): (WebCore::VideoFrame::createRGBA): (WebCore::VideoFrame::createBGRA): (WebCore::VideoFrame::createRGBX): (WebCore::VideoFrame::createBGRX): (WebCore::VideoFrame::createI420): (WebCore::VideoFrame::createI420A): Canonical link: https://commits.webkit.org/324125@main
1 parent 0f863d2 commit 9da0fa4

33 files changed

Lines changed: 646 additions & 78 deletions

File tree

‎LayoutTests/imported/w3c/web-platform-tests/webcodecs/idlharness.https.any-expected.txt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ PASS VideoFrame interface: attribute codedWidth
198198
PASS VideoFrame interface: attribute codedHeight
199199
PASS VideoFrame interface: attribute codedRect
200200
PASS VideoFrame interface: attribute visibleRect
201-
FAIL VideoFrame interface: attribute rotation assert_true: The prototype object must have a property "rotation" expected true got false
201+
PASS VideoFrame interface: attribute rotation
202202
FAIL VideoFrame interface: attribute flip assert_true: The prototype object must have a property "flip" expected true got false
203203
PASS VideoFrame interface: attribute displayWidth
204204
PASS VideoFrame interface: attribute displayHeight
@@ -217,7 +217,7 @@ PASS VideoFrame interface: new VideoFrame(makeImageBitmap(32, 16), {timestamp: 1
217217
PASS VideoFrame interface: new VideoFrame(makeImageBitmap(32, 16), {timestamp: 100, duration: 33}) must inherit property "codedHeight" with the proper type
218218
PASS VideoFrame interface: new VideoFrame(makeImageBitmap(32, 16), {timestamp: 100, duration: 33}) must inherit property "codedRect" with the proper type
219219
PASS VideoFrame interface: new VideoFrame(makeImageBitmap(32, 16), {timestamp: 100, duration: 33}) must inherit property "visibleRect" with the proper type
220-
FAIL VideoFrame interface: new VideoFrame(makeImageBitmap(32, 16), {timestamp: 100, duration: 33}) must inherit property "rotation" with the proper type assert_inherits: property "rotation" not found in prototype chain
220+
PASS VideoFrame interface: new VideoFrame(makeImageBitmap(32, 16), {timestamp: 100, duration: 33}) must inherit property "rotation" with the proper type
221221
FAIL VideoFrame interface: new VideoFrame(makeImageBitmap(32, 16), {timestamp: 100, duration: 33}) must inherit property "flip" with the proper type assert_inherits: property "flip" not found in prototype chain
222222
PASS VideoFrame interface: new VideoFrame(makeImageBitmap(32, 16), {timestamp: 100, duration: 33}) must inherit property "displayWidth" with the proper type
223223
PASS VideoFrame interface: new VideoFrame(makeImageBitmap(32, 16), {timestamp: 100, duration: 33}) must inherit property "displayHeight" with the proper type

‎LayoutTests/imported/w3c/web-platform-tests/webcodecs/idlharness.https.any.worker-expected.txt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ PASS VideoFrame interface: attribute codedWidth
198198
PASS VideoFrame interface: attribute codedHeight
199199
PASS VideoFrame interface: attribute codedRect
200200
PASS VideoFrame interface: attribute visibleRect
201-
FAIL VideoFrame interface: attribute rotation assert_true: The prototype object must have a property "rotation" expected true got false
201+
PASS VideoFrame interface: attribute rotation
202202
FAIL VideoFrame interface: attribute flip assert_true: The prototype object must have a property "flip" expected true got false
203203
PASS VideoFrame interface: attribute displayWidth
204204
PASS VideoFrame interface: attribute displayHeight
@@ -217,7 +217,7 @@ PASS VideoFrame interface: new VideoFrame(makeImageBitmap(32, 16), {timestamp: 1
217217
PASS VideoFrame interface: new VideoFrame(makeImageBitmap(32, 16), {timestamp: 100, duration: 33}) must inherit property "codedHeight" with the proper type
218218
PASS VideoFrame interface: new VideoFrame(makeImageBitmap(32, 16), {timestamp: 100, duration: 33}) must inherit property "codedRect" with the proper type
219219
PASS VideoFrame interface: new VideoFrame(makeImageBitmap(32, 16), {timestamp: 100, duration: 33}) must inherit property "visibleRect" with the proper type
220-
FAIL VideoFrame interface: new VideoFrame(makeImageBitmap(32, 16), {timestamp: 100, duration: 33}) must inherit property "rotation" with the proper type assert_inherits: property "rotation" not found in prototype chain
220+
PASS VideoFrame interface: new VideoFrame(makeImageBitmap(32, 16), {timestamp: 100, duration: 33}) must inherit property "rotation" with the proper type
221221
FAIL VideoFrame interface: new VideoFrame(makeImageBitmap(32, 16), {timestamp: 100, duration: 33}) must inherit property "flip" with the proper type assert_inherits: property "flip" not found in prototype chain
222222
PASS VideoFrame interface: new VideoFrame(makeImageBitmap(32, 16), {timestamp: 100, duration: 33}) must inherit property "displayWidth" with the proper type
223223
PASS VideoFrame interface: new VideoFrame(makeImageBitmap(32, 16), {timestamp: 100, duration: 33}) must inherit property "displayHeight" with the proper type
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

22
FAIL Test that isConfigSupported() with orientation assert_equals: rotation expected (number) 90 but got (undefined) undefined
3-
FAIL Decode frames with orientation metadata assert_equals: rotation expected (number) 90 but got (undefined) undefined
3+
FAIL Decode frames with orientation metadata assert_equals: rotation expected 90 but got 0
44

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

22
FAIL Test that isConfigSupported() with orientation assert_equals: rotation expected (number) 90 but got (undefined) undefined
3-
FAIL Decode frames with orientation metadata assert_equals: rotation expected (number) 90 but got (undefined) undefined
3+
FAIL Decode frames with orientation metadata assert_equals: rotation expected 90 but got 0
44

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

22
FAIL Test that isConfigSupported() with orientation assert_equals: rotation expected (number) 90 but got (undefined) undefined
3-
FAIL Decode frames with orientation metadata assert_equals: rotation expected (number) 90 but got (undefined) undefined
3+
FAIL Decode frames with orientation metadata assert_equals: rotation expected 90 but got 0
44

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

22
FAIL Test that isConfigSupported() with orientation assert_equals: rotation expected (number) 90 but got (undefined) undefined
3-
FAIL Decode frames with orientation metadata assert_equals: rotation expected (number) 90 but got (undefined) undefined
3+
FAIL Decode frames with orientation metadata assert_equals: rotation expected 90 but got 0
44

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

22
FAIL Test that isConfigSupported() with orientation assert_equals: rotation expected (number) 90 but got (undefined) undefined
3-
FAIL Decode frames with orientation metadata assert_equals: rotation expected (number) 90 but got (undefined) undefined
3+
FAIL Decode frames with orientation metadata assert_equals: rotation expected 90 but got 0
44

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

22
FAIL Test that isConfigSupported() with orientation assert_equals: rotation expected (number) 90 but got (undefined) undefined
3-
FAIL Decode frames with orientation metadata assert_equals: rotation expected (number) 90 but got (undefined) undefined
3+
FAIL Decode frames with orientation metadata assert_equals: rotation expected 90 but got 0
44

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

22
FAIL Test that isConfigSupported() with orientation assert_equals: rotation expected (number) 90 but got (undefined) undefined
3-
FAIL Decode frames with orientation metadata assert_equals: rotation expected (number) 90 but got (undefined) undefined
3+
FAIL Decode frames with orientation metadata assert_equals: rotation expected 90 but got 0
44

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

22
FAIL Test that isConfigSupported() with orientation assert_equals: rotation expected (number) 90 but got (undefined) undefined
3-
FAIL Decode frames with orientation metadata assert_equals: rotation expected (number) 90 but got (undefined) undefined
3+
FAIL Decode frames with orientation metadata assert_equals: rotation expected 90 but got 0
44

0 commit comments

Comments
 (0)