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
bcbe3f1f
authored
Feb 15, 2023
by
samrobinson
Committed by
Andrew Lewis
Feb 15, 2023
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Clarify the mime type used in EncoderUtilTest.
PiperOrigin-RevId: 509750806
parent
d91afa06
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
19 deletions
library/transformer/src/test/java/com/google/android/exoplayer2/transformer/EncoderUtilTest.java
library/transformer/src/test/java/com/google/android/exoplayer2/transformer/EncoderUtilTest.java
View file @
bcbe3f1f
...
...
@@ -16,6 +16,7 @@
package
com
.
google
.
android
.
exoplayer2
.
transformer
;
import
static
com
.
google
.
android
.
exoplayer2
.
util
.
MimeTypes
.
VIDEO_H264
;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
import
android.media.MediaCodecInfo
;
...
...
@@ -24,7 +25,6 @@ import android.util.Size;
import
androidx.annotation.Nullable
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
com.google.android.exoplayer2.video.ColorInfo
;
import
com.google.common.collect.ImmutableList
;
import
org.junit.After
;
...
...
@@ -45,12 +45,10 @@ import org.robolectric.shadows.ShadowMediaCodecList;
*/
@RunWith
(
AndroidJUnit4
.
class
)
public
class
EncoderUtilTest
{
private
static
final
String
MIME_TYPE
=
MimeTypes
.
VIDEO_H264
;
@Before
public
void
setUp
()
{
MediaFormat
avcFormat
=
new
MediaFormat
();
avcFormat
.
setString
(
MediaFormat
.
KEY_MIME
,
MediaFormat
.
MIMETYPE_VIDEO_AVC
);
avcFormat
.
setString
(
MediaFormat
.
KEY_MIME
,
VIDEO_H264
);
MediaCodecInfo
.
CodecProfileLevel
profileLevel
=
new
MediaCodecInfo
.
CodecProfileLevel
();
profileLevel
.
profile
=
MediaCodecInfo
.
CodecProfileLevel
.
AVCProfileHigh
;
// Using Level4 gives us 8192 16x16 blocks. If using width 1920 uses 120 blocks, 8192 / 120 = 68
...
...
@@ -81,12 +79,12 @@ public class EncoderUtilTest {
@Test
public
void
getSupportedResolution_withSupportedResolution_succeeds
()
{
ImmutableList
<
MediaCodecInfo
>
supportedEncoders
=
EncoderUtil
.
getSupportedEncoders
(
MIME_TYPE
);
ImmutableList
<
MediaCodecInfo
>
supportedEncoders
=
EncoderUtil
.
getSupportedEncoders
(
VIDEO_H264
);
MediaCodecInfo
encoderInfo
=
supportedEncoders
.
get
(
0
);
@Nullable
Size
closestSupportedResolution
=
EncoderUtil
.
getSupportedResolution
(
encoderInfo
,
MIME_TYPE
,
1920
,
1080
);
EncoderUtil
.
getSupportedResolution
(
encoderInfo
,
VIDEO_H264
,
1920
,
1080
);
assertThat
(
closestSupportedResolution
).
isNotNull
();
assertThat
(
closestSupportedResolution
.
getWidth
()).
isEqualTo
(
1920
);
...
...
@@ -95,12 +93,12 @@ public class EncoderUtilTest {
@Test
public
void
getSupportedResolution_withUnalignedSize_findsMostCloselySupportedResolution
()
{
ImmutableList
<
MediaCodecInfo
>
supportedEncoders
=
EncoderUtil
.
getSupportedEncoders
(
MIME_TYPE
);
ImmutableList
<
MediaCodecInfo
>
supportedEncoders
=
EncoderUtil
.
getSupportedEncoders
(
VIDEO_H264
);
MediaCodecInfo
encoderInfo
=
supportedEncoders
.
get
(
0
);
@Nullable
Size
closestSupportedResolution
=
EncoderUtil
.
getSupportedResolution
(
encoderInfo
,
MIME_TYPE
,
1919
,
1081
);
EncoderUtil
.
getSupportedResolution
(
encoderInfo
,
VIDEO_H264
,
1919
,
1081
);
assertThat
(
closestSupportedResolution
).
isNotNull
();
assertThat
(
closestSupportedResolution
.
getWidth
()).
isEqualTo
(
1920
);
...
...
@@ -110,12 +108,12 @@ public class EncoderUtilTest {
@Test
public
void
getSupportedResolution_findsThreeQuartersOfTheOriginalSize
()
{
// The supported resolution will try to match the aspect ratio where possible.
ImmutableList
<
MediaCodecInfo
>
supportedEncoders
=
EncoderUtil
.
getSupportedEncoders
(
MIME_TYPE
);
ImmutableList
<
MediaCodecInfo
>
supportedEncoders
=
EncoderUtil
.
getSupportedEncoders
(
VIDEO_H264
);
MediaCodecInfo
encoderInfo
=
supportedEncoders
.
get
(
0
);
@Nullable
Size
closestSupportedResolution
=
EncoderUtil
.
getSupportedResolution
(
encoderInfo
,
MIME_TYPE
,
1920
,
1920
);
EncoderUtil
.
getSupportedResolution
(
encoderInfo
,
VIDEO_H264
,
1920
,
1920
);
assertThat
(
closestSupportedResolution
).
isNotNull
();
assertThat
(
closestSupportedResolution
.
getWidth
()).
isEqualTo
(
1440
);
...
...
@@ -124,12 +122,12 @@ public class EncoderUtilTest {
@Test
public
void
getSupportedResolution_findsTwoThirdsOfTheOriginalSize
()
{
ImmutableList
<
MediaCodecInfo
>
supportedEncoders
=
EncoderUtil
.
getSupportedEncoders
(
MIME_TYPE
);
ImmutableList
<
MediaCodecInfo
>
supportedEncoders
=
EncoderUtil
.
getSupportedEncoders
(
VIDEO_H264
);
MediaCodecInfo
encoderInfo
=
supportedEncoders
.
get
(
0
);
@Nullable
Size
closestSupportedResolution
=
EncoderUtil
.
getSupportedResolution
(
encoderInfo
,
MIME_TYPE
,
2880
,
1620
);
EncoderUtil
.
getSupportedResolution
(
encoderInfo
,
VIDEO_H264
,
2880
,
1620
);
assertThat
(
closestSupportedResolution
).
isNotNull
();
assertThat
(
closestSupportedResolution
.
getWidth
()).
isEqualTo
(
1920
);
...
...
@@ -138,12 +136,12 @@ public class EncoderUtilTest {
@Test
public
void
getSupportedResolution_findsHalfOfTheOriginalSize
()
{
ImmutableList
<
MediaCodecInfo
>
supportedEncoders
=
EncoderUtil
.
getSupportedEncoders
(
MIME_TYPE
);
ImmutableList
<
MediaCodecInfo
>
supportedEncoders
=
EncoderUtil
.
getSupportedEncoders
(
VIDEO_H264
);
MediaCodecInfo
encoderInfo
=
supportedEncoders
.
get
(
0
);
@Nullable
Size
closestSupportedResolution
=
EncoderUtil
.
getSupportedResolution
(
encoderInfo
,
MIME_TYPE
,
2160
,
3840
);
EncoderUtil
.
getSupportedResolution
(
encoderInfo
,
VIDEO_H264
,
2160
,
3840
);
assertThat
(
closestSupportedResolution
).
isNotNull
();
assertThat
(
closestSupportedResolution
.
getWidth
()).
isEqualTo
(
1080
);
...
...
@@ -152,12 +150,12 @@ public class EncoderUtilTest {
@Test
public
void
getSupportedResolution_findsOneQuarterOfTheOriginalSize
()
{
ImmutableList
<
MediaCodecInfo
>
supportedEncoders
=
EncoderUtil
.
getSupportedEncoders
(
MIME_TYPE
);
ImmutableList
<
MediaCodecInfo
>
supportedEncoders
=
EncoderUtil
.
getSupportedEncoders
(
VIDEO_H264
);
MediaCodecInfo
encoderInfo
=
supportedEncoders
.
get
(
0
);
@Nullable
Size
closestSupportedResolution
=
EncoderUtil
.
getSupportedResolution
(
encoderInfo
,
MIME_TYPE
,
7680
,
4320
);
EncoderUtil
.
getSupportedResolution
(
encoderInfo
,
VIDEO_H264
,
7680
,
4320
);
assertThat
(
closestSupportedResolution
).
isNotNull
();
assertThat
(
closestSupportedResolution
.
getWidth
()).
isEqualTo
(
1920
);
...
...
@@ -166,14 +164,14 @@ public class EncoderUtilTest {
@Test
public
void
getSupportedResolution_requestedReallyLarge_matchesAspectRatio
()
{
ImmutableList
<
MediaCodecInfo
>
supportedEncoders
=
EncoderUtil
.
getSupportedEncoders
(
MIME_TYPE
);
ImmutableList
<
MediaCodecInfo
>
supportedEncoders
=
EncoderUtil
.
getSupportedEncoders
(
VIDEO_H264
);
MediaCodecInfo
encoderInfo
=
supportedEncoders
.
get
(
0
);
double
aspectRatio
=
1.5
;
@Nullable
Size
closestSupportedResolution
=
EncoderUtil
.
getSupportedResolution
(
encoderInfo
,
MIME_TYPE
,
(
int
)
(
aspectRatio
*
5000
),
5000
);
encoderInfo
,
VIDEO_H264
,
(
int
)
(
aspectRatio
*
5000
),
5000
);
assertThat
(
closestSupportedResolution
).
isNotNull
();
assertThat
(
...
...
@@ -193,7 +191,7 @@ public class EncoderUtilTest {
// support HDR.
assertThat
(
EncoderUtil
.
getSupportedEncodersForHdrEditing
(
MIME_TYPE
,
VIDEO_H264
,
new
ColorInfo
.
Builder
()
.
setColorSpace
(
C
.
COLOR_SPACE_BT2020
)
.
setColorRange
(
C
.
COLOR_RANGE_FULL
)
...
...
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