summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Wonsik Kim <wonsik@google.com> 2022-09-12 13:46:01 -0700
committer Wonsik Kim <wonsik@google.com> 2022-09-12 23:05:27 +0000
commitb5547085bcd8105d690d5175a9cf183445d4be68 (patch)
treef1840e00a161064003ba1f68fe018991a9154ee1
parente91c7faf4ecb3fe17ec5b1e02255db9a9e35bdb2 (diff)
MediaCodec: skip index validation at buffer validations
The index validation will happen at the MediaCodec native layer. Bug: 244121189 Test: atest CtsMediaCodecTestCases Test: atest CtsMediaDecoderTestCases Test: atest CtsMediaEncoderTestCases Test: atest CtsMediaV2TestCases Merged-In: I1af0cd61ae19e86a115b5e347625b8476440e848 Change-Id: I1af0cd61ae19e86a115b5e347625b8476440e848
-rw-r--r--media/java/android/media/MediaCodec.java24
1 files changed, 10 insertions, 14 deletions
diff --git a/media/java/android/media/MediaCodec.java b/media/java/android/media/MediaCodec.java
index c08f5a293e1d..220232d6e38f 100644
--- a/media/java/android/media/MediaCodec.java
+++ b/media/java/android/media/MediaCodec.java
@@ -3835,11 +3835,10 @@ final public class MediaCodec {
private void invalidateByteBufferLocked(
@Nullable ByteBuffer[] buffers, int index, boolean input) {
if (buffers == null) {
- if (index < 0) {
- throw new IllegalStateException("index is negative (" + index + ")");
+ if (index >= 0) {
+ BitSet indices = input ? mValidInputIndices : mValidOutputIndices;
+ indices.clear(index);
}
- BitSet indices = input ? mValidInputIndices : mValidOutputIndices;
- indices.clear(index);
} else if (index >= 0 && index < buffers.length) {
ByteBuffer buffer = buffers[index];
if (buffer != null) {
@@ -3851,10 +3850,9 @@ final public class MediaCodec {
private void validateInputByteBufferLocked(
@Nullable ByteBuffer[] buffers, int index) {
if (buffers == null) {
- if (index < 0) {
- throw new IllegalStateException("index is negative (" + index + ")");
+ if (index >= 0) {
+ mValidInputIndices.set(index);
}
- mValidInputIndices.set(index);
} else if (index >= 0 && index < buffers.length) {
ByteBuffer buffer = buffers[index];
if (buffer != null) {
@@ -3868,11 +3866,10 @@ final public class MediaCodec {
@Nullable ByteBuffer[] buffers, int index, boolean input) {
synchronized(mBufferLock) {
if (buffers == null) {
- if (index < 0) {
- throw new IllegalStateException("index is negative (" + index + ")");
+ if (index >= 0) {
+ BitSet indices = input ? mValidInputIndices : mValidOutputIndices;
+ indices.set(index);
}
- BitSet indices = input ? mValidInputIndices : mValidOutputIndices;
- indices.set(index);
} else if (index >= 0 && index < buffers.length) {
ByteBuffer buffer = buffers[index];
if (buffer != null) {
@@ -3885,10 +3882,9 @@ final public class MediaCodec {
private void validateOutputByteBufferLocked(
@Nullable ByteBuffer[] buffers, int index, @NonNull BufferInfo info) {
if (buffers == null) {
- if (index < 0) {
- throw new IllegalStateException("index is negative (" + index + ")");
+ if (index >= 0) {
+ mValidOutputIndices.set(index);
}
- mValidOutputIndices.set(index);
} else if (index >= 0 && index < buffers.length) {
ByteBuffer buffer = buffers[index];
if (buffer != null) {