mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
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 66554b9b68)
This commit is contained in:
parent
38a341a458
commit
9e19c60907
4 changed files with 17 additions and 30 deletions
|
|
@ -1036,12 +1036,6 @@ public final class C {
|
||||||
/** See {@link MediaFormat#COLOR_RANGE_FULL}. */
|
/** See {@link MediaFormat#COLOR_RANGE_FULL}. */
|
||||||
@UnstableApi public static final int COLOR_RANGE_FULL = MediaFormat.COLOR_RANGE_FULL;
|
@UnstableApi 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.
|
|
||||||
*/
|
|
||||||
@UnstableApi public static final int UNLIMITED_PENDING_FRAME_COUNT = Integer.MAX_VALUE;
|
|
||||||
|
|
||||||
/** Video projection types. */
|
/** Video projection types. */
|
||||||
@UnstableApi
|
@UnstableApi
|
||||||
@Documented
|
@Documented
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@
|
||||||
package androidx.media3.common.util;
|
package androidx.media3.common.util;
|
||||||
|
|
||||||
import static android.content.Context.UI_MODE_SERVICE;
|
import static android.content.Context.UI_MODE_SERVICE;
|
||||||
import static androidx.media3.common.C.UNLIMITED_PENDING_FRAME_COUNT;
|
|
||||||
import static androidx.media3.common.Player.COMMAND_PLAY_PAUSE;
|
import static androidx.media3.common.Player.COMMAND_PLAY_PAUSE;
|
||||||
import static androidx.media3.common.Player.COMMAND_PREPARE;
|
import static androidx.media3.common.Player.COMMAND_PREPARE;
|
||||||
import static androidx.media3.common.Player.COMMAND_SEEK_BACK;
|
import static androidx.media3.common.Player.COMMAND_SEEK_BACK;
|
||||||
|
|
@ -2809,25 +2808,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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -132,10 +132,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;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (maxDecoderPendingFrameCount != C.UNLIMITED_PENDING_FRAME_COUNT
|
if (sampleConsumer.getPendingVideoFrameCount() == maxDecoderPendingFrameCount) {
|
||||||
&& sampleConsumer.getPendingVideoFrameCount() == maxDecoderPendingFrameCount) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue