From 02185e35505dd103b873294b365957d1ee1bed81 Mon Sep 17 00:00:00 2001 From: Paul Adenot Date: Wed, 17 Jul 2024 04:59:51 +0000 Subject: [PATCH] Support planar -> interleaved copy. https://github.com/w3c/webcodecs/issues/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 --- webcodecs/audio-data.any.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/webcodecs/audio-data.any.js b/webcodecs/audio-data.any.js index d5d950647767bc4..67fef3c83c858f2 100644 --- a/webcodecs/audio-data.any.js +++ b/webcodecs/audio-data.any.js @@ -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], @@ -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 => { @@ -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}`); }