Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue-2003: add workaround for h264 decoders #2004

Open
wants to merge 1 commit into
base: release
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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