@@ -419,6 +419,9 @@ public DecoderReuseEvaluation canReuseCodec(Format oldFormat, Format newFormat)
419
419
&& !oldFormat .initializationDataEquals (newFormat )) {
420
420
discardReasons |= DISCARD_REASON_WORKAROUND ;
421
421
}
422
+ if (needsReconfigureDueAspectRatioChangesWorkaround (name , oldFormat , newFormat )) {
423
+ discardReasons |= DISCARD_REASON_WORKAROUND ;
424
+ }
422
425
423
426
if (discardReasons == 0 ) {
424
427
return new DecoderReuseEvaluation (
@@ -797,6 +800,31 @@ private static boolean needsAdaptationReconfigureWorkaround(String name) {
797
800
return Util .MODEL .startsWith ("SM-T230" ) && "OMX.MARVELL.VIDEO.HW.CODA7542DECODER" .equals (name );
798
801
}
799
802
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
+
800
828
/**
801
829
* Returns whether the decoder is known to behave incorrectly if flushed to adapt to a new format.
802
830
*
0 commit comments