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
e1b6ed32
authored
Jul 26, 2022
by
samrobinson
Committed by
Marc Baechinger
Oct 19, 2022
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add H265 as a parameter to SsimMapperTest.
PiperOrigin-RevId: 463452893
parent
03ff5246
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
9 deletions
library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/mh/analysis/SsimMapperTest.java
library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/mh/analysis/SsimMapperTest.java
View file @
e1b6ed32
...
@@ -36,6 +36,7 @@ import static com.google.android.exoplayer2.transformer.AndroidTestUtil.skipAndL
...
@@ -36,6 +36,7 @@ import static com.google.android.exoplayer2.transformer.AndroidTestUtil.skipAndL
import
static
com
.
google
.
android
.
exoplayer2
.
transformer
.
TransformationTestResult
.
SSIM_UNSET
;
import
static
com
.
google
.
android
.
exoplayer2
.
transformer
.
TransformationTestResult
.
SSIM_UNSET
;
import
static
com
.
google
.
android
.
exoplayer2
.
util
.
Assertions
.
checkNotNull
;
import
static
com
.
google
.
android
.
exoplayer2
.
util
.
Assertions
.
checkNotNull
;
import
static
com
.
google
.
android
.
exoplayer2
.
util
.
Assertions
.
checkState
;
import
static
com
.
google
.
android
.
exoplayer2
.
util
.
Assertions
.
checkState
;
import
static
com
.
google
.
common
.
collect
.
Iterables
.
getLast
;
import
android.content.Context
;
import
android.content.Context
;
import
android.net.Uri
;
import
android.net.Uri
;
...
@@ -45,13 +46,17 @@ import com.google.android.exoplayer2.Format;
...
@@ -45,13 +46,17 @@ import com.google.android.exoplayer2.Format;
import
com.google.android.exoplayer2.MediaItem
;
import
com.google.android.exoplayer2.MediaItem
;
import
com.google.android.exoplayer2.transformer.AndroidTestUtil
;
import
com.google.android.exoplayer2.transformer.AndroidTestUtil
;
import
com.google.android.exoplayer2.transformer.DefaultEncoderFactory
;
import
com.google.android.exoplayer2.transformer.DefaultEncoderFactory
;
import
com.google.android.exoplayer2.transformer.TransformationRequest
;
import
com.google.android.exoplayer2.transformer.Transformer
;
import
com.google.android.exoplayer2.transformer.Transformer
;
import
com.google.android.exoplayer2.transformer.TransformerAndroidTestRunner
;
import
com.google.android.exoplayer2.transformer.TransformerAndroidTestRunner
;
import
com.google.android.exoplayer2.transformer.VideoEncoderSettings
;
import
com.google.android.exoplayer2.transformer.VideoEncoderSettings
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
com.google.android.exoplayer2.util.Util
;
import
com.google.common.base.Splitter
;
import
com.google.common.base.Splitter
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.Iterables
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
...
@@ -67,6 +72,8 @@ import org.junit.runners.Parameterized.Parameters;
...
@@ -67,6 +72,8 @@ import org.junit.runners.Parameterized.Parameters;
@RunWith
(
Parameterized
.
class
)
@RunWith
(
Parameterized
.
class
)
public
class
SsimMapperTest
{
public
class
SsimMapperTest
{
private
static
final
Splitter
FORWARD_SLASH_SPLITTER
=
Splitter
.
on
(
'/'
);
// When running this test, input file list should be restricted more than this. Binary search can
// When running this test, input file list should be restricted more than this. Binary search can
// take up to 40 minutes to complete for a single clip on lower end devices.
// take up to 40 minutes to complete for a single clip on lower end devices.
private
static
final
ImmutableList
<
String
>
INPUT_FILES
=
private
static
final
ImmutableList
<
String
>
INPUT_FILES
=
...
@@ -88,25 +95,46 @@ public class SsimMapperTest {
...
@@ -88,25 +95,46 @@ public class SsimMapperTest {
MP4_REMOTE_7680W_4320H_31_SECOND_ROOF_SAMSUNGS20ULTRA5G
);
MP4_REMOTE_7680W_4320H_31_SECOND_ROOF_SAMSUNGS20ULTRA5G
);
@Parameters
@Parameters
public
static
ImmutableList
<
String
>
parameters
()
{
public
static
List
<
Object
[]>
parameters
()
{
return
INPUT_FILES
;
List
<
Object
[]>
parameterList
=
new
ArrayList
<>();
for
(
String
file
:
INPUT_FILES
)
{
parameterList
.
add
(
new
Object
[]
{
file
,
MimeTypes
.
VIDEO_H264
});
// TODO(210593256): Test pre 24 once in-app muxing implemented.
if
(
Util
.
SDK_INT
>=
24
)
{
parameterList
.
add
(
new
Object
[]
{
file
,
MimeTypes
.
VIDEO_H265
});
}
}
return
parameterList
;
}
}
@Parameter
@Nullable
public
String
fileUri
;
@Parameter
(
0
)
@Nullable
public
String
fileUri
;
@Parameter
(
1
)
@Nullable
public
String
mimeType
;
@Test
@Test
public
void
findSsimMapping
()
throws
Exception
{
public
void
findSsimMapping
()
throws
Exception
{
String
fileUri
=
checkNotNull
(
this
.
fileUri
);
String
fileUri
=
checkNotNull
(
this
.
fileUri
);
String
mimeType
=
checkNotNull
(
this
.
mimeType
);
String
testIdPrefix
=
String
.
format
(
"ssim_search_VBR_%s"
,
checkNotNull
(
getLast
(
FORWARD_SLASH_SPLITTER
.
split
(
mimeType
))));
if
(
skipAndLogIfInsufficientCodecSupport
(
if
(
skipAndLogIfInsufficientCodecSupport
(
ApplicationProvider
.
getApplicationContext
(),
ApplicationProvider
.
getApplicationContext
(),
/* testId= */
"ssim_search_VBR
_codecSupport"
,
testIdPrefix
+
"
_codecSupport"
,
/* decodingFormat= */
getFormatForTestFile
(
fileUri
),
/* decodingFormat= */
getFormatForTestFile
(
fileUri
),
/* encodingFormat= */
null
))
{
/* encodingFormat= */
null
))
{
return
;
return
;
}
}
new
SsimBinarySearcher
(
ApplicationProvider
.
getApplicationContext
(),
fileUri
).
search
();
new
SsimBinarySearcher
(
ApplicationProvider
.
getApplicationContext
(),
testIdPrefix
,
fileUri
,
mimeType
)
.
search
();
}
}
private
static
final
class
SsimBinarySearcher
{
private
static
final
class
SsimBinarySearcher
{
...
@@ -116,8 +144,10 @@ public class SsimMapperTest {
...
@@ -116,8 +144,10 @@ public class SsimMapperTest {
private
static
final
int
MAX_TRANSFORMATIONS
=
12
;
private
static
final
int
MAX_TRANSFORMATIONS
=
12
;
private
final
Context
context
;
private
final
Context
context
;
private
final
String
testIdPrefix
;
private
final
String
videoUri
;
private
final
String
videoUri
;
private
final
Format
format
;
private
final
Format
format
;
private
final
String
outputMimeType
;
private
int
transformationsLeft
;
private
int
transformationsLeft
;
private
double
ssimLowerBound
;
private
double
ssimLowerBound
;
...
@@ -129,11 +159,17 @@ public class SsimMapperTest {
...
@@ -129,11 +159,17 @@ public class SsimMapperTest {
* Creates a new instance.
* Creates a new instance.
*
*
* @param context The {@link Context}.
* @param context The {@link Context}.
* @param testIdPrefix The test ID prefix.
* @param videoUri The URI of the video to transform.
* @param videoUri The URI of the video to transform.
* @param outputMimeType The video sample MIME type to output, see {@link
* TransformationRequest.Builder#setVideoMimeType}.
*/
*/
public
SsimBinarySearcher
(
Context
context
,
String
videoUri
)
{
public
SsimBinarySearcher
(
Context
context
,
String
testIdPrefix
,
String
videoUri
,
String
outputMimeType
)
{
this
.
context
=
context
;
this
.
context
=
context
;
this
.
testIdPrefix
=
testIdPrefix
;
this
.
videoUri
=
videoUri
;
this
.
videoUri
=
videoUri
;
this
.
outputMimeType
=
outputMimeType
;
transformationsLeft
=
MAX_TRANSFORMATIONS
;
transformationsLeft
=
MAX_TRANSFORMATIONS
;
format
=
AndroidTestUtil
.
getFormatForTestFile
(
videoUri
);
format
=
AndroidTestUtil
.
getFormatForTestFile
(
videoUri
);
}
}
...
@@ -222,8 +258,8 @@ public class SsimMapperTest {
...
@@ -222,8 +258,8 @@ public class SsimMapperTest {
private
double
transformAndGetSsim
(
int
bitrate
)
throws
Exception
{
private
double
transformAndGetSsim
(
int
bitrate
)
throws
Exception
{
// TODO(b/238094555): Force specific encoders to be used.
// TODO(b/238094555): Force specific encoders to be used.
String
fileName
=
checkNotNull
(
Iterables
.
getLast
(
Splitter
.
on
(
"/"
)
.
split
(
videoUri
)));
String
fileName
=
checkNotNull
(
getLast
(
FORWARD_SLASH_SPLITTER
.
split
(
videoUri
)));
String
testId
=
String
.
format
(
"
ssim_search_%s_VBR_%s"
,
bitrate
,
fileName
);
String
testId
=
String
.
format
(
"
%s_%s_%s"
,
testIdPrefix
,
bitrate
,
fileName
);
Map
<
String
,
Object
>
inputValues
=
new
HashMap
<>();
Map
<
String
,
Object
>
inputValues
=
new
HashMap
<>();
inputValues
.
put
(
"targetBitrate"
,
bitrate
);
inputValues
.
put
(
"targetBitrate"
,
bitrate
);
...
@@ -236,6 +272,8 @@ public class SsimMapperTest {
...
@@ -236,6 +272,8 @@ public class SsimMapperTest {
Transformer
transformer
=
Transformer
transformer
=
new
Transformer
.
Builder
(
context
)
new
Transformer
.
Builder
(
context
)
.
setRemoveAudio
(
true
)
.
setRemoveAudio
(
true
)
.
setTransformationRequest
(
new
TransformationRequest
.
Builder
().
setVideoMimeType
(
outputMimeType
).
build
())
.
setEncoderFactory
(
.
setEncoderFactory
(
new
DefaultEncoderFactory
.
Builder
(
context
)
new
DefaultEncoderFactory
.
Builder
(
context
)
.
setRequestedVideoEncoderSettings
(
.
setRequestedVideoEncoderSettings
(
...
@@ -243,6 +281,7 @@ public class SsimMapperTest {
...
@@ -243,6 +281,7 @@ public class SsimMapperTest {
.
setBitrate
(
bitrate
)
.
setBitrate
(
bitrate
)
.
setBitrateMode
(
BITRATE_MODE_VBR
)
.
setBitrateMode
(
BITRATE_MODE_VBR
)
.
build
())
.
build
())
.
setEnableFallback
(
false
)
.
build
())
.
build
())
.
build
();
.
build
();
...
...
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