Skip to content

Commit

Permalink
add needsReconfigureDueAspectRatioChangesWorkaround check
Browse files Browse the repository at this point in the history
  • Loading branch information
vladikadiroff committed Dec 26, 2024
1 parent 76088cd commit 60ce524
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,9 @@ public DecoderReuseEvaluation canReuseCodec(Format oldFormat, Format newFormat)
&& !oldFormat.initializationDataEquals(newFormat)) {
discardReasons |= DISCARD_REASON_WORKAROUND;
}
if (needsReconfigureDueAspectRatioChangesWorkaround(name, oldFormat, newFormat)) {
discardReasons |= DISCARD_REASON_WORKAROUND;
}

if (discardReasons == 0) {
return new DecoderReuseEvaluation(
Expand Down Expand Up @@ -797,6 +800,31 @@ 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 reused
* when the new format has a different aspect ratio.
*
* @param name The name of the decoder.
* @param oldFormat The format being decoded.
* @param newFormat The new format.
* @return Whether the decoder is known to behave incorrectly if reused when the new format has
* a different aspect ratio.
*/
private static boolean needsReconfigureDueAspectRatioChangesWorkaround(
String name,
Format oldFormat,
Format newFormat
) {
// See https://github.com/androidx/media/issues/2003
if ("c2.exynos.h264.decoder".equals(name) || "c2.android.avc.decoder".equals(name)) {
float oldAspectRatio = (float) oldFormat.width / oldFormat.height;
float newAspectRatio = (float) newFormat.width / newFormat.height;
return oldAspectRatio != newAspectRatio;
}

return false;
}

/**
* Returns whether the decoder is known to behave incorrectly if flushed to adapt to a new format.
*
Expand Down

0 comments on commit 60ce524

Please sign in to comment.