mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Add ChannelMixingMatrix property unit tests.
PiperOrigin-RevId: 505720834
This commit is contained in:
parent
f5e31989ab
commit
c2b0d1b756
@ -0,0 +1,145 @@
|
||||
/*
|
||||
* Copyright 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package androidx.media3.transformer;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
/** Unit tests for {@link ChannelMixingMatrix}. */
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ChannelMixingMatrixTest {
|
||||
|
||||
@Test
|
||||
public void allZeroValues_3To2_hasCorrectProperties() {
|
||||
int inputCount = 3;
|
||||
int outputCount = 2;
|
||||
float[] coefficients =
|
||||
new float[] {
|
||||
0f, 0f,
|
||||
0f, 0f,
|
||||
0f, 0f,
|
||||
};
|
||||
|
||||
ChannelMixingMatrix matrix = new ChannelMixingMatrix(inputCount, outputCount, coefficients);
|
||||
assertThat(matrix.isZero()).isTrue();
|
||||
assertThat(matrix.isSquare()).isFalse();
|
||||
assertThat(matrix.isDiagonal()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void allZeroValues_3To3_hasCorrectProperties() {
|
||||
int inputCount = 3;
|
||||
int outputCount = 3;
|
||||
float[] coefficients =
|
||||
new float[] {
|
||||
0f, 0f, 0f,
|
||||
0f, 0f, 0f,
|
||||
0f, 0f, 0f,
|
||||
};
|
||||
|
||||
ChannelMixingMatrix matrix = new ChannelMixingMatrix(inputCount, outputCount, coefficients);
|
||||
assertThat(matrix.isZero()).isTrue();
|
||||
assertThat(matrix.isSquare()).isTrue();
|
||||
assertThat(matrix.isDiagonal()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void allZeroValues_3To4_hasCorrectProperties() {
|
||||
int inputCount = 3;
|
||||
int outputCount = 4;
|
||||
float[] coefficients =
|
||||
new float[] {
|
||||
0f, 0f, 0f, 0f,
|
||||
0f, 0f, 0f, 0f,
|
||||
0f, 0f, 0f, 0f,
|
||||
};
|
||||
|
||||
ChannelMixingMatrix matrix = new ChannelMixingMatrix(inputCount, outputCount, coefficients);
|
||||
assertThat(matrix.isZero()).isTrue();
|
||||
assertThat(matrix.isSquare()).isFalse();
|
||||
assertThat(matrix.isDiagonal()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void oneNonZeroValue_3To4_hasCorrectProperties() {
|
||||
int inputCount = 3;
|
||||
int outputCount = 4;
|
||||
float[] coefficients =
|
||||
new float[] {
|
||||
0f, 0f, 0f, 0f,
|
||||
0f, 0f, 0f, 0.2f,
|
||||
0f, 0f, 0f, 0f,
|
||||
};
|
||||
|
||||
ChannelMixingMatrix matrix = new ChannelMixingMatrix(inputCount, outputCount, coefficients);
|
||||
assertThat(matrix.isZero()).isFalse();
|
||||
assertThat(matrix.isSquare()).isFalse();
|
||||
assertThat(matrix.isDiagonal()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void zeroValuesOnDiagonal_2To2_hasCorrectProperties() {
|
||||
int inputCount = 2;
|
||||
int outputCount = 2;
|
||||
float[] coefficients =
|
||||
new float[] {
|
||||
0f, 1f,
|
||||
2f, 0f,
|
||||
};
|
||||
|
||||
ChannelMixingMatrix matrix = new ChannelMixingMatrix(inputCount, outputCount, coefficients);
|
||||
assertThat(matrix.isZero()).isFalse();
|
||||
assertThat(matrix.isSquare()).isTrue();
|
||||
assertThat(matrix.isDiagonal()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nonZeroValuesOnDiagonal_4To4_hasCorrectProperties() {
|
||||
int inputCount = 4;
|
||||
int outputCount = 4;
|
||||
float[] coefficients =
|
||||
new float[] {
|
||||
1f, 0f, 0f, 0f,
|
||||
0f, 2f, 0f, 0f,
|
||||
0f, 0f, 3f, 0f,
|
||||
0f, 0f, 0f, 0f,
|
||||
};
|
||||
|
||||
ChannelMixingMatrix matrix = new ChannelMixingMatrix(inputCount, outputCount, coefficients);
|
||||
assertThat(matrix.isZero()).isFalse();
|
||||
assertThat(matrix.isSquare()).isTrue();
|
||||
assertThat(matrix.isDiagonal()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void allNonZeroValues_2To4_hasCorrectProperties() {
|
||||
int inputCount = 2;
|
||||
int outputCount = 4;
|
||||
float[] coefficients =
|
||||
new float[] {
|
||||
1f, 3f, 5f, 10f,
|
||||
4f, 2f, 9f, 123f,
|
||||
};
|
||||
|
||||
ChannelMixingMatrix matrix = new ChannelMixingMatrix(inputCount, outputCount, coefficients);
|
||||
assertThat(matrix.isZero()).isFalse();
|
||||
assertThat(matrix.isSquare()).isFalse();
|
||||
assertThat(matrix.isDiagonal()).isFalse();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user