Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
c2b0d1b7
authored
Jan 30, 2023
by
samrobinson
Committed by
christosts
Feb 01, 2023
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add ChannelMixingMatrix property unit tests.
PiperOrigin-RevId: 505720834
parent
f5e31989
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
145 additions
and
0 deletions
libraries/transformer/src/test/java/androidx/media3/transformer/ChannelMixingMatrixTest.java
libraries/transformer/src/test/java/androidx/media3/transformer/ChannelMixingMatrixTest.java
0 → 100644
View file @
c2b0d1b7
/*
* 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
[]
{
0
f
,
0
f
,
0
f
,
0
f
,
0
f
,
0
f
,
};
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
[]
{
0
f
,
0
f
,
0
f
,
0
f
,
0
f
,
0
f
,
0
f
,
0
f
,
0
f
,
};
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
[]
{
0
f
,
0
f
,
0
f
,
0
f
,
0
f
,
0
f
,
0
f
,
0
f
,
0
f
,
0
f
,
0
f
,
0
f
,
};
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
[]
{
0
f
,
0
f
,
0
f
,
0
f
,
0
f
,
0
f
,
0
f
,
0.2f
,
0
f
,
0
f
,
0
f
,
0
f
,
};
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
[]
{
0
f
,
1
f
,
2
f
,
0
f
,
};
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
[]
{
1
f
,
0
f
,
0
f
,
0
f
,
0
f
,
2
f
,
0
f
,
0
f
,
0
f
,
0
f
,
3
f
,
0
f
,
0
f
,
0
f
,
0
f
,
0
f
,
};
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
[]
{
1
f
,
3
f
,
5
f
,
10
f
,
4
f
,
2
f
,
9
f
,
123
f
,
};
ChannelMixingMatrix
matrix
=
new
ChannelMixingMatrix
(
inputCount
,
outputCount
,
coefficients
);
assertThat
(
matrix
.
isZero
()).
isFalse
();
assertThat
(
matrix
.
isSquare
()).
isFalse
();
assertThat
(
matrix
.
isDiagonal
()).
isFalse
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment