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
c9e80a20
authored
Nov 04, 2020
by
olly
Committed by
Andrew Lewis
Nov 06, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Move reconfiguration workaround to canKeepCodec
PiperOrigin-RevId: 340651654
parent
7f49b33f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
43 deletions
library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecInfo.java
library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java
library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecInfo.java
View file @
c9e80a20
...
@@ -393,9 +393,11 @@ public final class MediaCodecInfo {
...
@@ -393,9 +393,11 @@ public final class MediaCodecInfo {
&&
(
adaptive
&&
(
adaptive
||
(
oldFormat
.
width
==
newFormat
.
width
&&
oldFormat
.
height
==
newFormat
.
height
))
||
(
oldFormat
.
width
==
newFormat
.
width
&&
oldFormat
.
height
==
newFormat
.
height
))
&&
Util
.
areEqual
(
oldFormat
.
colorInfo
,
newFormat
.
colorInfo
))
{
&&
Util
.
areEqual
(
oldFormat
.
colorInfo
,
newFormat
.
colorInfo
))
{
return
oldFormat
.
initializationDataEquals
(
newFormat
)
if
(
oldFormat
.
initializationDataEquals
(
newFormat
))
{
?
KEEP_CODEC_RESULT_YES_WITHOUT_RECONFIGURATION
return
KEEP_CODEC_RESULT_YES_WITHOUT_RECONFIGURATION
;
:
KEEP_CODEC_RESULT_YES_WITH_RECONFIGURATION
;
}
else
if
(!
needsAdaptationReconfigureWorkaround
(
name
))
{
return
KEEP_CODEC_RESULT_YES_WITH_RECONFIGURATION
;
}
}
}
}
else
{
}
else
{
if
(
oldFormat
.
channelCount
!=
newFormat
.
channelCount
if
(
oldFormat
.
channelCount
!=
newFormat
.
channelCount
...
@@ -423,11 +425,8 @@ public final class MediaCodecInfo {
...
@@ -423,11 +425,8 @@ public final class MediaCodecInfo {
}
}
}
}
// For Opus, we don't flush and reuse the codec because the decoder may discard samples after
if
(
oldFormat
.
initializationDataEquals
(
newFormat
)
// flushing, which would result in audio being dropped just after a stream change (see
&&
!
needsAdaptationFlushWorkaround
(
mimeType
))
{
// [Internal: b/143450854]). For other formats, we allow reuse after flushing if the codec
// initialization data is unchanged.
if
(!
MimeTypes
.
AUDIO_OPUS
.
equals
(
mimeType
)
&&
oldFormat
.
initializationDataEquals
(
newFormat
))
{
return
KEEP_CODEC_RESULT_YES_WITH_FLUSH
;
return
KEEP_CODEC_RESULT_YES_WITH_FLUSH
;
}
}
}
}
...
@@ -459,7 +458,7 @@ public final class MediaCodecInfo {
...
@@ -459,7 +458,7 @@ public final class MediaCodecInfo {
}
}
if
(!
areSizeAndRateSupportedV21
(
videoCapabilities
,
width
,
height
,
frameRate
))
{
if
(!
areSizeAndRateSupportedV21
(
videoCapabilities
,
width
,
height
,
frameRate
))
{
if
(
width
>=
height
if
(
width
>=
height
||
!
enable
RotatedVerticalResolutionWorkaround
(
name
)
||
!
needs
RotatedVerticalResolutionWorkaround
(
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
+
"x"
+
frameRate
);
return
false
;
return
false
;
...
@@ -655,6 +654,33 @@ public final class MediaCodecInfo {
...
@@ -655,6 +654,33 @@ public final class MediaCodecInfo {
}
}
/**
/**
* Returns whether the decoder is known to fail when an attempt is made to reconfigure it with a
* new format's configuration data.
*
* @param name The name of the decoder.
* @return Whether the decoder is known to fail when an attempt is made to reconfigure it with a
* new format's configuration data.
*/
private
static
boolean
needsAdaptationReconfigureWorkaround
(
String
name
)
{
return
Util
.
MODEL
.
startsWith
(
"SM-T230"
)
&&
"OMX.MARVELL.VIDEO.HW.CODA7542DECODER"
.
equals
(
name
);
}
/**
* Returns whether the decoder is known to behave incorrectly if flushed to adapt to a new format.
*
* @param mimeType The name of the MIME type.
* @return Whether the decoder is known to to behave incorrectly if flushed to adapt to a new
* format.
*/
private
static
boolean
needsAdaptationFlushWorkaround
(
String
mimeType
)
{
// For Opus, we don't flush and reuse the codec because the decoder may discard samples after
// flushing, which would result in audio being dropped just after a stream change (see
// [Internal: b/143450854]). For other formats, we allow reuse after flushing if the codec
// initialization data is unchanged.
return
MimeTypes
.
AUDIO_OPUS
.
equals
(
mimeType
);
}
/**
* Capabilities are known to be inaccurately reported for vertical resolutions on some devices.
* Capabilities are known to be inaccurately reported for vertical resolutions on some devices.
* [Internal ref: b/31387661]. When this workaround is enabled, we also check whether the
* [Internal ref: b/31387661]. When this workaround is enabled, we also check whether the
* capabilities indicate support if the width and height are swapped. If they do, we assume that
* capabilities indicate support if the width and height are swapped. If they do, we assume that
...
@@ -663,7 +689,7 @@ public final class MediaCodecInfo {
...
@@ -663,7 +689,7 @@ public final class MediaCodecInfo {
* @param name The name of the codec.
* @param name The name of the codec.
* @return Whether to enable the workaround.
* @return Whether to enable the workaround.
*/
*/
private
static
final
boolean
enable
RotatedVerticalResolutionWorkaround
(
String
name
)
{
private
static
final
boolean
needs
RotatedVerticalResolutionWorkaround
(
String
name
)
{
if
(
"OMX.MTK.VIDEO.DECODER.HEVC"
.
equals
(
name
)
&&
"mcv5a"
.
equals
(
Util
.
DEVICE
))
{
if
(
"OMX.MTK.VIDEO.DECODER.HEVC"
.
equals
(
name
)
&&
"mcv5a"
.
equals
(
Util
.
DEVICE
))
{
// See https://github.com/google/ExoPlayer/issues/6612.
// See https://github.com/google/ExoPlayer/issues/6612.
return
false
;
return
false
;
...
...
library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java
View file @
c9e80a20
...
@@ -316,7 +316,6 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
...
@@ -316,7 +316,6 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
@Nullable
private
DecoderInitializationException
preferredDecoderInitializationException
;
@Nullable
private
DecoderInitializationException
preferredDecoderInitializationException
;
@Nullable
private
MediaCodecInfo
codecInfo
;
@Nullable
private
MediaCodecInfo
codecInfo
;
@AdaptationWorkaroundMode
private
int
codecAdaptationWorkaroundMode
;
@AdaptationWorkaroundMode
private
int
codecAdaptationWorkaroundMode
;
private
boolean
codecNeedsReconfigureWorkaround
;
private
boolean
codecNeedsDiscardToSpsWorkaround
;
private
boolean
codecNeedsDiscardToSpsWorkaround
;
private
boolean
codecNeedsFlushWorkaround
;
private
boolean
codecNeedsFlushWorkaround
;
private
boolean
codecNeedsSosFlushWorkaround
;
private
boolean
codecNeedsSosFlushWorkaround
;
...
@@ -894,7 +893,6 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
...
@@ -894,7 +893,6 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
codecHasOutputMediaFormat
=
false
;
codecHasOutputMediaFormat
=
false
;
codecOperatingRate
=
CODEC_OPERATING_RATE_UNSET
;
codecOperatingRate
=
CODEC_OPERATING_RATE_UNSET
;
codecAdaptationWorkaroundMode
=
ADAPTATION_WORKAROUND_MODE_NEVER
;
codecAdaptationWorkaroundMode
=
ADAPTATION_WORKAROUND_MODE_NEVER
;
codecNeedsReconfigureWorkaround
=
false
;
codecNeedsDiscardToSpsWorkaround
=
false
;
codecNeedsDiscardToSpsWorkaround
=
false
;
codecNeedsFlushWorkaround
=
false
;
codecNeedsFlushWorkaround
=
false
;
codecNeedsSosFlushWorkaround
=
false
;
codecNeedsSosFlushWorkaround
=
false
;
...
@@ -1085,7 +1083,6 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
...
@@ -1085,7 +1083,6 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
this
.
codecOperatingRate
=
codecOperatingRate
;
this
.
codecOperatingRate
=
codecOperatingRate
;
codecInputFormat
=
inputFormat
;
codecInputFormat
=
inputFormat
;
codecAdaptationWorkaroundMode
=
codecAdaptationWorkaroundMode
(
codecName
);
codecAdaptationWorkaroundMode
=
codecAdaptationWorkaroundMode
(
codecName
);
codecNeedsReconfigureWorkaround
=
codecNeedsReconfigureWorkaround
(
codecName
);
codecNeedsDiscardToSpsWorkaround
=
codecNeedsDiscardToSpsWorkaround
=
codecNeedsDiscardToSpsWorkaround
(
codecName
,
codecInputFormat
);
codecNeedsDiscardToSpsWorkaround
(
codecName
,
codecInputFormat
);
codecNeedsFlushWorkaround
=
codecNeedsFlushWorkaround
(
codecName
);
codecNeedsFlushWorkaround
=
codecNeedsFlushWorkaround
(
codecName
);
...
@@ -1428,21 +1425,17 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
...
@@ -1428,21 +1425,17 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
}
}
break
;
break
;
case
KEEP_CODEC_RESULT_YES_WITH_RECONFIGURATION:
case
KEEP_CODEC_RESULT_YES_WITH_RECONFIGURATION:
if
(
codecNeedsReconfigureWorkaround
)
{
codecReconfigured
=
true
;
drainAndReinitializeCodec
();
codecReconfigurationState
=
RECONFIGURATION_STATE_WRITE_PENDING
;
}
else
{
codecNeedsAdaptationWorkaroundBuffer
=
codecReconfigured
=
true
;
codecAdaptationWorkaroundMode
==
ADAPTATION_WORKAROUND_MODE_ALWAYS
codecReconfigurationState
=
RECONFIGURATION_STATE_WRITE_PENDING
;
||
(
codecAdaptationWorkaroundMode
==
ADAPTATION_WORKAROUND_MODE_SAME_RESOLUTION
codecNeedsAdaptationWorkaroundBuffer
=
&&
newFormat
.
width
==
codecInputFormat
.
width
codecAdaptationWorkaroundMode
==
ADAPTATION_WORKAROUND_MODE_ALWAYS
&&
newFormat
.
height
==
codecInputFormat
.
height
);
||
(
codecAdaptationWorkaroundMode
==
ADAPTATION_WORKAROUND_MODE_SAME_RESOLUTION
codecInputFormat
=
newFormat
;
&&
newFormat
.
width
==
codecInputFormat
.
width
updateCodecOperatingRate
();
&&
newFormat
.
height
==
codecInputFormat
.
height
);
if
(
drainAndUpdateCodecDrmSession
)
{
codecInputFormat
=
newFormat
;
drainAndUpdateCodecDrmSessionV23
();
updateCodecOperatingRate
();
if
(
drainAndUpdateCodecDrmSession
)
{
drainAndUpdateCodecDrmSessionV23
();
}
}
}
break
;
break
;
case
KEEP_CODEC_RESULT_YES_WITHOUT_RECONFIGURATION:
case
KEEP_CODEC_RESULT_YES_WITHOUT_RECONFIGURATION:
...
@@ -2245,21 +2238,6 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
...
@@ -2245,21 +2238,6 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
}
}
/**
/**
* Returns whether the decoder is known to fail when an attempt is made to reconfigure it with a
* new format's configuration data.
*
* <p>When enabled, the workaround will always release and recreate the decoder, rather than
* attempting to reconfigure the existing instance.
*
* @param name The name of the decoder.
* @return True if the decoder is known to fail when an attempt is made to reconfigure it with a
* new format's configuration data.
*/
private
static
boolean
codecNeedsReconfigureWorkaround
(
String
name
)
{
return
Util
.
MODEL
.
startsWith
(
"SM-T230"
)
&&
"OMX.MARVELL.VIDEO.HW.CODA7542DECODER"
.
equals
(
name
);
}
/**
* Returns whether the decoder is an H.264/AVC decoder known to fail if NAL units are queued
* Returns whether the decoder is an H.264/AVC decoder known to fail if NAL units are queued
* before the codec specific data.
* before the codec specific data.
*
*
...
...
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