Fix HDR tone mapping stuck on SM device

Tone-mapping an HDR video with MediaCodec on sm-s908u1 was timing out.
The reason for that is that the decoder was dropping frames, and the
ExternalTextureManager was therefore never propagating the end-of-stream
signal.

There was already a workaround for a similar issue but restricted to
sm-f936b. Removed the model check as the bug is probably present on more
devices.

PiperOrigin-RevId: 530639437
This commit is contained in:
kimvde 2023-05-09 16:59:29 +00:00 committed by Tofunmi Adigun-Hameed
parent 5e4421c2ba
commit dc4c6daf0b
3 changed files with 8 additions and 10 deletions

View file

@ -2792,11 +2792,11 @@ public final class Util {
}
/**
* Returns the number of maximum pending input frames that are allowed on a {@link MediaCodec}
* encoder.
* Returns the number of maximum pending output frames that are allowed on a {@link MediaCodec}
* decoder.
*/
@UnstableApi
public static int getMaxPendingFramesCountForMediaCodecEncoders(
public static int getMaxPendingFramesCountForMediaCodecDecoders(
Context context, String codecName, boolean requestedHdrToneMapping) {
if (SDK_INT < 29
|| context.getApplicationContext().getApplicationInfo().targetSdkVersion < 29) {
@ -2818,11 +2818,9 @@ public final class Util {
// OMX video codecs should no longer exist from android.os.Build.DEVICE_INITIAL_SDK_INT 31+.
return 5;
}
if (requestedHdrToneMapping
&& codecName.equals("c2.qti.hevc.decoder")
&& MODEL.equals("SM-F936B")) {
// This decoder gets stuck if too many frames are rendered without being processed when
// tone-mapping HDR10. This value is experimentally determined. See also b/260408846.
if (requestedHdrToneMapping && codecName.equals("c2.qti.hevc.decoder")) {
// This decoder drops frames if too many frames are rendered without being processed when
// tone-mapping HDR. This value is experimentally determined. See also b/260408846.
// TODO(b/260713009): Add API version check after bug is fixed on new API versions.
return 12;
}

View file

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

View file

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