Skip to content

Commit

Permalink
Support planar -> interleaved copy.
Browse files Browse the repository at this point in the history
w3c/webcodecs#819

Differential Revision: https://phabricator.services.mozilla.com/D216561

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1907438
gecko-commit: f909b83620331385e7bb8ef1291b7df7a310f9a5
gecko-reviewers: chunmin
  • Loading branch information
padenot authored and marcoscaceres committed Jul 22, 2024
1 parent c83f0d1 commit 02185e3
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion webcodecs/audio-data.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ const TEST_TEMPLATE = {
// For each test, copy this template and replace the number by the appropriate
// number for this type
testInput: [MIN, BIAS, MAX, MIN, HALF, NEGATIVE_HALF, BIAS, MAX, BIAS, BIAS],
testInterleavedResult: [MIN, NEGATIVE_HALF, BIAS, BIAS, MAX, MAX, MIN, BIAS, HALF, BIAS],
testVectorInterleavedResult: [
[MIN, MAX, HALF, BIAS, BIAS],
[BIAS, MIN, NEGATIVE_HALF, MAX, BIAS],
Expand Down Expand Up @@ -274,6 +275,10 @@ function get_type_values(type) {
cloned.testInput,
idx => TEST_VALUES[type][idx]
);
cloned.testInterleavedResult = Array.from(
cloned.testInterleavedResult,
idx => TEST_VALUES[type][idx]
);
cloned.testVectorInterleavedResult = Array.from(
cloned.testVectorInterleavedResult,
c => {
Expand Down Expand Up @@ -418,7 +423,15 @@ function conversionTest(sourceType, destinationType) {
"planar channel 1",
assert_func
);
// Planar to interleaved isn't supported
// Copy to interleaved from planar: all channels are copied
data.copyTo(destInterleaved, {planeIndex: 0, format: destinationType});
check_array_equality(
destInterleaved,
result.testInterleavedResult,
sourceType,
"planar to interleaved",
assert_func
);
}, `Test conversion of ${sourceType} to ${destinationType}`);
}

Expand Down

0 comments on commit 02185e3

Please sign in to comment.