Skip to content

Commit b98a598

Browse files
author
vkadyrov
committed
add needsReconfigureDueAspectRatioChangesWorkaround check
1 parent 76088cd commit b98a598

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

libraries/exoplayer/src/main/java/androidx/media3/exoplayer/mediacodec/MediaCodecInfo.java

+28
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,9 @@ public DecoderReuseEvaluation canReuseCodec(Format oldFormat, Format newFormat)
419419
&& !oldFormat.initializationDataEquals(newFormat)) {
420420
discardReasons |= DISCARD_REASON_WORKAROUND;
421421
}
422+
if (needsReconfigureDueAspectRatioChangesWorkaround(name, oldFormat, newFormat)) {
423+
discardReasons |= DISCARD_REASON_WORKAROUND;
424+
}
422425

423426
if (discardReasons == 0) {
424427
return new DecoderReuseEvaluation(
@@ -797,6 +800,31 @@ private static boolean needsAdaptationReconfigureWorkaround(String name) {
797800
return Util.MODEL.startsWith("SM-T230") && "OMX.MARVELL.VIDEO.HW.CODA7542DECODER".equals(name);
798801
}
799802

803+
/**
804+
* Returns whether the decoder is known to behave incorrectly if reused
805+
* when the new format has a different aspect ratio.
806+
*
807+
* @param name The name of the decoder.
808+
* @param oldFormat The format being decoded.
809+
* @param newFormat The new format.
810+
* @return Whether the decoder is known to behave incorrectly if reused when the new format has
811+
* a different aspect ratio.
812+
*/
813+
private static boolean needsReconfigureDueAspectRatioChangesWorkaround(
814+
String name,
815+
Format oldFormat,
816+
Format newFormat
817+
) {
818+
// See https://github.com/androidx/media/issues/2003
819+
if ("c2.exynos.h264.decoder".equals(name) || "c2.android.avc.decoder".equals(name)) {
820+
float oldAspectRatio = (float) oldFormat.width / oldFormat.height;
821+
float newAspectRatio = (float) newFormat.width / newFormat.height;
822+
return oldAspectRatio != newAspectRatio;
823+
}
824+
825+
return false;
826+
}
827+
800828
/**
801829
* Returns whether the decoder is known to behave incorrectly if flushed to adapt to a new format.
802830
*

0 commit comments

Comments
 (0)