Bug 1911245 [wpt PR 47429] - [webcodecs] Add vorbis test case, a=testonly

Automatic update from web-platform-tests
Add vorbis test case

--
Ignore *.ogg files when linting

--
Remove whitespace

--
Use full config when checking for codec support

--
Handle priming samples discarded by vorbis

--
Add accidentially removed handling for unsupported codecs

--
Explain description for vorbis codec

--

wpt-commits: b5ddbed0d2e23772f881adae6adda75d1c438a41, c6f16338bd4a855f7f3a1400199447dc67bfb024, 9b889f5013eda0ee6bf77669303595946f8b3536, 98347e02f86af09f5c0068ccbe26e8581d08694e, d6dd417771d3bb27e098ad0534375f6c288963b9, 4c4211933dc921706e8287ab6433c8f568635f9a, 550fb109615cf434b03b30b76aa0dea6bfb0ebe1
wpt-pr: 47429
This commit is contained in:
Christoph Guttandin
2024-11-27 22:02:17 +00:00
committed by moz-wptsync-bot
parent 682c96c7dd
commit d0102842a0
4 changed files with 63 additions and 6 deletions

View File

@@ -28,6 +28,7 @@ TRAILING WHITESPACE, INDENT TABS, CR AT EOL: *.mp3
TRAILING WHITESPACE, INDENT TABS, CR AT EOL: *.m4a
TRAILING WHITESPACE, INDENT TABS, CR AT EOL: *.mov
TRAILING WHITESPACE, INDENT TABS, CR AT EOL: *.oga
TRAILING WHITESPACE, INDENT TABS, CR AT EOL: *.ogg
TRAILING WHITESPACE, INDENT TABS, CR AT EOL: *.ogv
TRAILING WHITESPACE, INDENT TABS, CR AT EOL: *.webm
TRAILING WHITESPACE, INDENT TABS, CR AT EOL: *.mp4

View File

@@ -152,6 +152,12 @@ done
sox -n -r 48000 sfx.wav synth 1 sine 480
ffmpeg -i sfx.wav -frames:a 10 -acodec libopus -b:a 96K sfx-opus.ogg
### sfx-vorbis.ogg
```
sox -n -r 48000 sfx.wav synth 1 sine 480
ffmpeg -i sfx.wav -frames:a 10 -acodec libvorbis -b:a 96K sfx-vorbis.ogg
```
### av1.mp4
```
ffmpeg -f lavfi -i testsrc=rate=10:n=1 -t 1 -pix_fmt yuv420p -vcodec libaom-av1 av1.mp4

View File

@@ -12,6 +12,7 @@
// META: variant=?pcm_s32
// META: variant=?pcm_f32
// META: variant=?flac
// META: variant=?vorbis
const ADTS_AAC_DATA = {
src: 'sfx.adts',
@@ -128,6 +129,30 @@ const PCM_S24_DATA = pcm("pcm-s24", 0x66);
const PCM_S32_DATA = pcm("pcm-s32", 0x66);
const PCM_F32_DATA = pcm("pcm-f32", 0x72);
const VORBIS_DATA = {
src: 'sfx-vorbis.ogg',
config: {
codec: 'vorbis',
description: [
2,
30,
62,
{offset: 28, size: 30},
{offset: 101, size: 62},
{offset: 163, size: 3771}
],
numberOfChannels: 1,
sampleRate: 48000,
},
chunks: [
{offset: 3968, size: 44}, {offset: 4012, size: 21},
{offset: 4033, size: 57}, {offset: 4090, size: 37},
{offset: 4127, size: 37}, {offset: 4164, size: 107},
{offset: 4271, size: 172}
],
duration: 21333
};
// Allows mutating `callbacks` after constructing the AudioDecoder, wraps calls
// in t.step().
function createAudioDecoder(t, callbacks) {
@@ -171,6 +196,7 @@ promise_setup(async () => {
'?pcm_s32': PCM_S32_DATA,
'?pcm_f32': PCM_F32_DATA,
'?flac': FLAC_DATA,
'?vorbis': VORBIS_DATA,
}[location.search];
// Don't run any tests if the codec is not supported.
@@ -193,7 +219,28 @@ promise_setup(async () => {
CONFIG = {...data.config};
if (data.config.description) {
CONFIG.description = view(buf, data.config.description);
// The description for decoding vorbis is expected to be in Xiph extradata format.
// https://w3c.github.io/webcodecs/vorbis_codec_registration.html#audiodecoderconfig-description
if (Array.isArray(data.config.description)) {
const length = data.config.description.reduce((sum, value) => sum + ((typeof value === 'number') ? 1 : value.size), 0);
const description = new Uint8Array(length);
data.config.description.reduce((offset, value) => {
if (typeof value === 'number') {
description[offset] = value;
return offset + 1;
}
description.set(view(buf, value), offset);
return offset + value.size;
}, 0);
CONFIG.description = description;
} else {
CONFIG.description = view(buf, data.config.description);
}
}
CHUNK_DATA = [];
@@ -300,7 +347,7 @@ promise_test(async t => {
});
await decoder.flush();
assert_equals(outputs, CHUNKS.length, 'outputs');
assert_equals(outputs, CONFIG.codec === 'vorbis' ? CHUNKS.length - 1 : CHUNKS.length, 'outputs');
}, 'Test decoding');
promise_test(async t => {
@@ -316,9 +363,11 @@ promise_test(async t => {
decoder.configure(CONFIG);
decoder.decode(new EncodedAudioChunk(
{type: 'key', timestamp: -42, data: CHUNK_DATA[0]}));
decoder.decode(new EncodedAudioChunk(
{type: 'key', timestamp: CHUNKS[0].duration - 42, data: CHUNK_DATA[1]}));
await decoder.flush();
assert_equals(outputs, 1, 'outputs');
assert_equals(outputs, CONFIG.codec === 'vorbis' ? 1 : 2, 'outputs');
}, 'Test decoding a with negative timestamp');
promise_test(async t => {
@@ -333,13 +382,14 @@ promise_test(async t => {
decoder.configure(CONFIG);
decoder.decode(CHUNKS[0]);
decoder.decode(CHUNKS[1]);
await decoder.flush();
assert_equals(outputs, 1, 'outputs');
assert_equals(outputs, CONFIG.codec === 'vorbis' ? 1 : 2, 'outputs');
decoder.decode(CHUNKS[0]);
decoder.decode(CHUNKS[2]);
await decoder.flush();
assert_equals(outputs, 2, 'outputs');
assert_equals(outputs, CONFIG.codec === 'vorbis' ? 2 : 3, 'outputs');
}, 'Test decoding after flush');
promise_test(async t => {

Binary file not shown.