Commit 08d7aa3b by huangdarwin Committed by Tofunmi Adigun-Hameed

Codec: Reduce limit for max decoder pending output frames.

Tentative/experimental value to reduce codec timeouts. We will reconsider using a larger limit after seeing whether this really does reduce error rate.

PiperOrigin-RevId: 534491615
(cherry picked from commit 8d7848a5bd72298c8a521414a95763982a74f032)
parent 4a0660f9
...@@ -1011,12 +1011,6 @@ public final class C { ...@@ -1011,12 +1011,6 @@ public final class C {
/** See {@link MediaFormat#COLOR_RANGE_FULL}. */ /** See {@link MediaFormat#COLOR_RANGE_FULL}. */
public static final int COLOR_RANGE_FULL = MediaFormat.COLOR_RANGE_FULL; public static final int COLOR_RANGE_FULL = MediaFormat.COLOR_RANGE_FULL;
/**
* Represents applying no limit to the number of input frames a {@link MediaCodec} encoder
* accepts.
*/
public static final int UNLIMITED_PENDING_FRAME_COUNT = Integer.MAX_VALUE;
/** Video projection types. */ /** Video projection types. */
@Documented @Documented
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
package com.google.android.exoplayer2.util; package com.google.android.exoplayer2.util;
import static android.content.Context.UI_MODE_SERVICE; import static android.content.Context.UI_MODE_SERVICE;
import static com.google.android.exoplayer2.C.UNLIMITED_PENDING_FRAME_COUNT;
import static com.google.android.exoplayer2.Player.COMMAND_PLAY_PAUSE; import static com.google.android.exoplayer2.Player.COMMAND_PLAY_PAUSE;
import static com.google.android.exoplayer2.Player.COMMAND_PREPARE; import static com.google.android.exoplayer2.Player.COMMAND_PREPARE;
import static com.google.android.exoplayer2.Player.COMMAND_SEEK_BACK; import static com.google.android.exoplayer2.Player.COMMAND_SEEK_BACK;
...@@ -2691,25 +2690,20 @@ public final class Util { ...@@ -2691,25 +2690,20 @@ public final class Util {
// TODO(b/226330223): Investigate increasing this limit. // TODO(b/226330223): Investigate increasing this limit.
return 1; return 1;
} }
if (Ascii.toUpperCase(codecName).startsWith("OMX.")) { // Limit the maximum amount of frames for all decoders. This is a tentative value that should be
// Some OMX decoders don't correctly track their number of output buffers available, and get // large enough to avoid significant performance degradation, but small enough to bypass decoder
// stuck if too many frames are rendered without being processed, so limit the number of // issues.
// pending frames to avoid getting stuck. This value is experimentally determined. See also //
// b/213455700, b/230097284, b/229978305, and b/245491744. // TODO: b/278234847 - Evaluate whether this reduces decoder timeouts, and consider restoring
// // prior higher limits as appropriate.
// OMX video codecs should no longer exist from android.os.Build.DEVICE_INITIAL_SDK_INT 31+. //
return 5; // Some OMX decoders don't correctly track their number of output buffers available, and get
} // stuck if too many frames are rendered without being processed. This value is experimentally
if (requestedHdrToneMapping && codecName.equals("c2.qti.hevc.decoder")) { // determined. See also
// This decoder drops frames if too many frames are rendered without being processed when // b/213455700, b/230097284, b/229978305, and b/245491744.
// 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. // OMX video codecs should no longer exist from android.os.Build.DEVICE_INITIAL_SDK_INT 31+.
return 12; return 5;
}
// Otherwise don't limit the number of frames that can be pending at a time, to maximize
// throughput.
return UNLIMITED_PENDING_FRAME_COUNT;
} }
/** /**
......
...@@ -130,10 +130,10 @@ public interface Codec { ...@@ -130,10 +130,10 @@ public interface Codec {
/** /**
* Returns the maximum number of frames that may be pending in the output {@code Codec} at a time, * Returns the maximum number of frames that may be pending in the output {@code Codec} at a time,
* or {@link C#UNLIMITED_PENDING_FRAME_COUNT} if it's not necessary to enforce a limit. * or {@code 5} as a default value.
*/ */
default int getMaxPendingFrameCount() { default int getMaxPendingFrameCount() {
return C.UNLIMITED_PENDING_FRAME_COUNT; return 5;
} }
/** /**
......
...@@ -147,8 +147,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull; ...@@ -147,8 +147,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
return true; return true;
} }
if (maxDecoderPendingFrameCount != C.UNLIMITED_PENDING_FRAME_COUNT if (sampleConsumer.getPendingVideoFrameCount() == maxDecoderPendingFrameCount) {
&& sampleConsumer.getPendingVideoFrameCount() == maxDecoderPendingFrameCount) {
return false; return false;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment