Commit c8103097 by claincly Committed by bachinger

Validate input format.

The format should have the following fields set (as specified in the javadoc):

- width
- height
- frame rate, and
- averageBitrate.

PiperOrigin-RevId: 400204510
parent f94148c4
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
package com.google.android.exoplayer2.transformer; package com.google.android.exoplayer2.transformer;
import static com.google.android.exoplayer2.util.Assertions.checkArgument;
import static com.google.android.exoplayer2.util.Assertions.checkNotNull; import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
import static com.google.android.exoplayer2.util.Assertions.checkState; import static com.google.android.exoplayer2.util.Assertions.checkState;
import static java.lang.Math.ceil; import static java.lang.Math.ceil;
...@@ -212,6 +213,11 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; ...@@ -212,6 +213,11 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
*/ */
public static MediaCodecAdapterWrapper createForVideoEncoding( public static MediaCodecAdapterWrapper createForVideoEncoding(
Format format, Map<String, Integer> additionalEncoderConfig) throws IOException { Format format, Map<String, Integer> additionalEncoderConfig) throws IOException {
checkArgument(format.width != Format.NO_VALUE);
checkArgument(format.height != Format.NO_VALUE);
checkArgument(format.frameRate != Format.NO_VALUE);
checkArgument(format.averageBitrate != Format.NO_VALUE);
@Nullable MediaCodecAdapter adapter = null; @Nullable MediaCodecAdapter adapter = null;
try { try {
MediaFormat mediaFormat = MediaFormat mediaFormat =
......
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