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
0eb30eac
authored
Oct 20, 2022
by
michaelkatz
Committed by
Rohit Singh
Oct 24, 2022
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Change areSizeAndRateSupported to use PerfomancePoint.covers
PiperOrigin-RevId: 482461219
parent
e3f28421
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
4 deletions
library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecInfo.java
library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecInfo.java
View file @
0eb30eac
...
@@ -28,6 +28,7 @@ import static com.google.android.exoplayer2.decoder.DecoderReuseEvaluation.REUSE
...
@@ -28,6 +28,7 @@ import static com.google.android.exoplayer2.decoder.DecoderReuseEvaluation.REUSE
import
static
com
.
google
.
android
.
exoplayer2
.
decoder
.
DecoderReuseEvaluation
.
REUSE_RESULT_YES_WITHOUT_RECONFIGURATION
;
import
static
com
.
google
.
android
.
exoplayer2
.
decoder
.
DecoderReuseEvaluation
.
REUSE_RESULT_YES_WITHOUT_RECONFIGURATION
;
import
static
com
.
google
.
android
.
exoplayer2
.
decoder
.
DecoderReuseEvaluation
.
REUSE_RESULT_YES_WITH_FLUSH
;
import
static
com
.
google
.
android
.
exoplayer2
.
decoder
.
DecoderReuseEvaluation
.
REUSE_RESULT_YES_WITH_FLUSH
;
import
static
com
.
google
.
android
.
exoplayer2
.
decoder
.
DecoderReuseEvaluation
.
REUSE_RESULT_YES_WITH_RECONFIGURATION
;
import
static
com
.
google
.
android
.
exoplayer2
.
decoder
.
DecoderReuseEvaluation
.
REUSE_RESULT_YES_WITH_RECONFIGURATION
;
import
static
java
.
lang
.
annotation
.
ElementType
.
TYPE_USE
;
import
android.graphics.Point
;
import
android.graphics.Point
;
import
android.media.MediaCodec
;
import
android.media.MediaCodec
;
...
@@ -35,7 +36,10 @@ import android.media.MediaCodecInfo.AudioCapabilities;
...
@@ -35,7 +36,10 @@ import android.media.MediaCodecInfo.AudioCapabilities;
import
android.media.MediaCodecInfo.CodecCapabilities
;
import
android.media.MediaCodecInfo.CodecCapabilities
;
import
android.media.MediaCodecInfo.CodecProfileLevel
;
import
android.media.MediaCodecInfo.CodecProfileLevel
;
import
android.media.MediaCodecInfo.VideoCapabilities
;
import
android.media.MediaCodecInfo.VideoCapabilities
;
import
android.media.MediaCodecInfo.VideoCapabilities.PerformancePoint
;
import
android.util.Pair
;
import
android.util.Pair
;
import
androidx.annotation.DoNotInline
;
import
androidx.annotation.IntDef
;
import
androidx.annotation.Nullable
;
import
androidx.annotation.Nullable
;
import
androidx.annotation.RequiresApi
;
import
androidx.annotation.RequiresApi
;
import
androidx.annotation.VisibleForTesting
;
import
androidx.annotation.VisibleForTesting
;
...
@@ -47,6 +51,11 @@ import com.google.android.exoplayer2.util.Assertions;
...
@@ -47,6 +51,11 @@ import com.google.android.exoplayer2.util.Assertions;
import
com.google.android.exoplayer2.util.Log
;
import
com.google.android.exoplayer2.util.Log
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
com.google.android.exoplayer2.util.Util
;
import
com.google.android.exoplayer2.util.Util
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
import
java.util.List
;
/** Information about a {@link MediaCodec} for a given mime type. */
/** Information about a {@link MediaCodec} for a given mime type. */
@SuppressWarnings
(
"InlinedApi"
)
@SuppressWarnings
(
"InlinedApi"
)
...
@@ -480,8 +489,6 @@ public final class MediaCodecInfo {
...
@@ -480,8 +489,6 @@ public final class MediaCodecInfo {
/**
/**
* Whether the decoder supports video with a given width, height and frame rate.
* Whether the decoder supports video with a given width, height and frame rate.
*
*
* <p>Must not be called if the device SDK version is less than 21.
*
* @param width Width in pixels.
* @param width Width in pixels.
* @param height Height in pixels.
* @param height Height in pixels.
* @param frameRate Optional frame rate in frames per second. Ignored if set to {@link
* @param frameRate Optional frame rate in frames per second. Ignored if set to {@link
...
@@ -499,14 +506,28 @@ public final class MediaCodecInfo {
...
@@ -499,14 +506,28 @@ public final class MediaCodecInfo {
logNoSupport
(
"sizeAndRate.vCaps"
);
logNoSupport
(
"sizeAndRate.vCaps"
);
return
false
;
return
false
;
}
}
if
(
Util
.
SDK_INT
>=
29
)
{
@PerformancePointCoverageResult
int
evaluation
=
Api29
.
areResolutionAndFrameRateCovered
(
videoCapabilities
,
width
,
height
,
frameRate
);
if
(
evaluation
==
COVERAGE_RESULT_YES
)
{
return
true
;
}
else
if
(
evaluation
==
COVERAGE_RESULT_NO
)
{
logNoSupport
(
"sizeAndRate.cover, "
+
width
+
"x"
+
height
+
"@"
+
frameRate
);
return
false
;
}
// COVERAGE_RESULT_NO_EMPTY_LIST falls through to API 21+ code below
}
if
(!
areSizeAndRateSupportedV21
(
videoCapabilities
,
width
,
height
,
frameRate
))
{
if
(!
areSizeAndRateSupportedV21
(
videoCapabilities
,
width
,
height
,
frameRate
))
{
if
(
width
>=
height
if
(
width
>=
height
||
!
needsRotatedVerticalResolutionWorkaround
(
name
)
||
!
needsRotatedVerticalResolutionWorkaround
(
name
)
||
!
areSizeAndRateSupportedV21
(
videoCapabilities
,
height
,
width
,
frameRate
))
{
||
!
areSizeAndRateSupportedV21
(
videoCapabilities
,
height
,
width
,
frameRate
))
{
logNoSupport
(
"sizeAndRate.support, "
+
width
+
"x"
+
height
+
"
x
"
+
frameRate
);
logNoSupport
(
"sizeAndRate.support, "
+
width
+
"x"
+
height
+
"
@
"
+
frameRate
);
return
false
;
return
false
;
}
}
logAssumedSupport
(
"sizeAndRate.rotated, "
+
width
+
"x"
+
height
+
"
x
"
+
frameRate
);
logAssumedSupport
(
"sizeAndRate.rotated, "
+
width
+
"x"
+
height
+
"
@
"
+
frameRate
);
}
}
return
true
;
return
true
;
}
}
...
@@ -842,4 +863,47 @@ public final class MediaCodecInfo {
...
@@ -842,4 +863,47 @@ public final class MediaCodecInfo {
&&
CodecProfileLevel
.
HEVCProfileMain10
==
profile
&&
CodecProfileLevel
.
HEVCProfileMain10
==
profile
&&
(
"sailfish"
.
equals
(
Util
.
DEVICE
)
||
"marlin"
.
equals
(
Util
.
DEVICE
));
&&
(
"sailfish"
.
equals
(
Util
.
DEVICE
)
||
"marlin"
.
equals
(
Util
.
DEVICE
));
}
}
/** Possible outcomes of evaluating PerformancePoint coverage */
@Documented
@Retention
(
RetentionPolicy
.
SOURCE
)
@Target
(
TYPE_USE
)
@IntDef
({
COVERAGE_RESULT_YES
,
COVERAGE_RESULT_NO
,
COVERAGE_RESULT_NO_EMPTY_LIST
})
private
@interface
PerformancePointCoverageResult
{}
/** The decoder has a PerformancePoint that covers the resolution and frame rate */
private
static
final
int
COVERAGE_RESULT_YES
=
2
;
/**
* The decoder has at least one PerformancePoint, but none of them cover the resolution and frame
* rate
*/
private
static
final
int
COVERAGE_RESULT_NO
=
1
;
/** The VideoCapabilities does not contain any PerformancePoints */
private
static
final
int
COVERAGE_RESULT_NO_EMPTY_LIST
=
0
;
@RequiresApi
(
29
)
private
static
final
class
Api29
{
@DoNotInline
public
static
@PerformancePointCoverageResult
int
areResolutionAndFrameRateCovered
(
VideoCapabilities
videoCapabilities
,
int
width
,
int
height
,
double
frameRate
)
{
List
<
PerformancePoint
>
performancePointList
=
videoCapabilities
.
getSupportedPerformancePoints
();
if
(
performancePointList
==
null
||
performancePointList
.
isEmpty
())
{
return
COVERAGE_RESULT_NO_EMPTY_LIST
;
}
// Round frame rate down to to avoid situations where a range check in
// covers fails due to slightly exceeding the limits for a standard format
// (e.g., 1080p at 30 fps). [Internal ref: b/134706676]
PerformancePoint
targetPerformancePoint
=
new
PerformancePoint
(
width
,
height
,
(
int
)
frameRate
);
for
(
int
i
=
0
;
i
<
performancePointList
.
size
();
i
++)
{
if
(
performancePointList
.
get
(
i
).
covers
(
targetPerformancePoint
))
{
return
COVERAGE_RESULT_YES
;
}
}
return
COVERAGE_RESULT_NO
;
}
}
}
}
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