-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
VideoEncoder produces no frames with latencyMode "realtime" when fram…
…erate/bitrate are not given https://bugs.webkit.org/show_bug.cgi?id=264894 rdar://118725549 Reviewed by Eric Carlson. When frame rate and/or bitrate is not set, use default values for them. For frame rate, we use 30 frames. For bitrate, we use the max bit rate as per H264 table A.1. * LayoutTests/http/wpt/webcodecs/h264-encoder-default-config.https.any-expected.txt: Added. * LayoutTests/http/wpt/webcodecs/h264-encoder-default-config.https.any.html: Added. * LayoutTests/http/wpt/webcodecs/h264-encoder-default-config.https.any.js: Added. (async encoderTest): (promise_test.async return): (promise_test): * LayoutTests/http/wpt/webcodecs/h264-encoder-default-config.https.any.worker-expected.txt: Added. * LayoutTests/http/wpt/webcodecs/h264-encoder-default-config.https.any.worker.html: Added. * Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/RTCVideoEncoderH264.mm: (-[RTCVideoEncoderH264 startEncodeWithSettings:numberOfCores:]): (-[RTCVideoEncoderH264 setBitrate:framerate:]): (-[RTCVideoEncoderH264 setEncoderBitrateBps:frameRate:]): Canonical link: https://commits.webkit.org/271087@main
- Loading branch information
Showing
7 changed files
with
138 additions
and
7 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
LayoutTests/http/wpt/webcodecs/h264-encoder-default-config.https.any-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
PASS Realtime encoding without framerate and bitrate | ||
PASS Realtime encoding without bitrate | ||
PASS Realtime encoding without framerate | ||
|
1 change: 1 addition & 0 deletions
1
LayoutTests/http/wpt/webcodecs/h264-encoder-default-config.https.any.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<!-- This file is required for WebKit test infrastructure to run the templated test --> |
68 changes: 68 additions & 0 deletions
68
LayoutTests/http/wpt/webcodecs/h264-encoder-default-config.https.any.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
async function encoderTest(testConfig) | ||
{ | ||
const width = 200; | ||
const height = 100; | ||
const img = new ImageData(width, height); | ||
|
||
for (let r = 0; r < height; r++) { | ||
for (let c = 0; c < width; c++) { | ||
const index = (r * width + c) * 4; | ||
img.data[index + 0] = 127; | ||
img.data[index + 1] = 127; | ||
img.data[index + 2] = 127; | ||
img.data[index + 3] = 255; | ||
} | ||
} | ||
const bitmap = await createImageBitmap(img); | ||
|
||
let framesCount = 0; | ||
let errorCount = 0; | ||
const encoder = new VideoEncoder({ | ||
output: (chunk, metadata) => { | ||
++framesCount; | ||
}, error: (err) => { | ||
++errorCount; | ||
} | ||
}) | ||
|
||
const encoderConfig = { | ||
codec: "avc1.42001f", // Baseline profile (42 00) with level 3.1 (1f) | ||
width, | ||
height, | ||
latencyMode: "realtime", | ||
avc: { format: "annexb" }, | ||
} | ||
if (testConfig.framerate) | ||
encoderConfig.framerate = testConfig.framerate; | ||
if (testConfig.bitrate) | ||
encoderConfig.bitrate = testConfig.bitrate; | ||
|
||
encoder.configure(encoderConfig); | ||
|
||
for (let i = 0; i < 20; i++) { | ||
const frame = new VideoFrame(bitmap, { timestamp: i }); | ||
encoder.encode(frame, {keyFrame: i === 0}); | ||
frame.close(); | ||
} | ||
|
||
bitmap.close(); | ||
|
||
await encoder.flush(); | ||
encoder.close(); | ||
|
||
assert_greater_than(framesCount, 0, "frames count"); | ||
assert_equals(errorCount, 0, "error count"); | ||
} | ||
|
||
promise_test(async () => { | ||
return encoderTest({ }); | ||
}, "Realtime encoding without framerate and bitrate"); | ||
|
||
promise_test(async () => { | ||
return encoderTest({ frameRate: 10 }); | ||
}, "Realtime encoding without bitrate"); | ||
|
||
promise_test(async () => { | ||
return encoderTest({ bitrate: 1000 }); | ||
}, "Realtime encoding without framerate"); | ||
|
5 changes: 5 additions & 0 deletions
5
LayoutTests/http/wpt/webcodecs/h264-encoder-default-config.https.any.worker-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
PASS Realtime encoding without framerate and bitrate | ||
PASS Realtime encoding without bitrate | ||
PASS Realtime encoding without framerate | ||
|
1 change: 1 addition & 0 deletions
1
LayoutTests/http/wpt/webcodecs/h264-encoder-default-config.https.any.worker.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<!-- This file is required for WebKit test infrastructure to run the templated test --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters