Util.getMaxPendingFramesCountForMediaCodecDecoders(): Remove unused arguments

PiperOrigin-RevId: 554838494
This commit is contained in:
christosts 2023-08-08 15:52:29 +00:00 committed by Tianyi Feng
parent 7be15b7603
commit cba027c3b4
3 changed files with 13 additions and 13 deletions

View file

@ -3012,19 +3012,22 @@ public final class Util {
} }
} }
@UnstableApi
public static boolean isFrameDropAllowedOnSurfaceInput(Context context) {
// Prior to API 29, decoders may drop frames to keep their output surface from growing out of
// bounds. From API 29, if the app targets API 29 or later, the {@link
// MediaFormat#KEY_ALLOW_FRAME_DROP} key prevents frame dropping even when the surface is
// full.
return Util.SDK_INT < 29 || context.getApplicationInfo().targetSdkVersion < 29;
}
/** /**
* Returns the number of maximum pending output frames that are allowed on a {@link MediaCodec} * Returns the number of maximum pending output frames that are allowed on a {@link MediaCodec}
* decoder. * decoder.
*/ */
@UnstableApi @UnstableApi
public static int getMaxPendingFramesCountForMediaCodecDecoders( public static int getMaxPendingFramesCountForMediaCodecDecoders(Context context) {
Context context, String codecName, boolean requestedHdrToneMapping) { if (isFrameDropAllowedOnSurfaceInput(context)) {
if (SDK_INT < 29
|| context.getApplicationContext().getApplicationInfo().targetSdkVersion < 29) {
// Prior to API 29, decoders may drop frames to keep their output surface from growing out of
// bounds. From API 29, if the app targets API 29 or later, the {@link
// MediaFormat#KEY_ALLOW_FRAME_DROP} key prevents frame dropping even when the surface is
// full.
// Frame dropping is never desired, so a workaround is needed for older API levels. // Frame dropping is never desired, so a workaround is needed for older API levels.
// Allow a maximum of one frame to be pending at a time to prevent frame dropping. // Allow a maximum of one frame to be pending at a time to prevent frame dropping.
// TODO(b/226330223): Investigate increasing this limit. // TODO(b/226330223): Investigate increasing this limit.

View file

@ -2264,8 +2264,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
*/ */
public void onCodecInitialized(String codecName) { public void onCodecInitialized(String codecName) {
videoFrameProcessorMaxPendingFrameCount = videoFrameProcessorMaxPendingFrameCount =
Util.getMaxPendingFramesCountForMediaCodecDecoders( Util.getMaxPendingFramesCountForMediaCodecDecoders(renderer.context);
renderer.context, codecName, /* requestedHdrToneMapping= */ false);
} }
/** /**

View file

@ -154,9 +154,7 @@ public final class DefaultCodec implements Codec {
} }
this.mediaCodec = mediaCodec; this.mediaCodec = mediaCodec;
this.inputSurface = inputSurface; this.inputSurface = inputSurface;
maxPendingFrameCount = maxPendingFrameCount = Util.getMaxPendingFramesCountForMediaCodecDecoders(context);
Util.getMaxPendingFramesCountForMediaCodecDecoders(
context, mediaCodecName, requestedHdrToneMapping);
} }
@Override @Override