mirror of
https://github.com/androidx/media.git
synced 2025-05-14 19:19:58 +08:00
FrameProcessor: Add checks to ensure width and height are positive.
Negative and zero values should be disallowed. PiperOrigin-RevId: 441757246
This commit is contained in:
parent
ef96932ea1
commit
96b501409d
@ -167,6 +167,9 @@ public final class AdvancedFrameProcessor implements GlFrameProcessor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(int inputTexId, int inputWidth, int inputHeight) throws IOException {
|
public void initialize(int inputTexId, int inputWidth, int inputHeight) throws IOException {
|
||||||
|
checkArgument(inputWidth > 0, "inputWidth must be positive");
|
||||||
|
checkArgument(inputHeight > 0, "inputHeight must be positive");
|
||||||
|
|
||||||
size = new Size(inputWidth, inputHeight);
|
size = new Size(inputWidth, inputHeight);
|
||||||
// TODO(b/205002913): check the loaded program is consistent with the attributes and uniforms
|
// TODO(b/205002913): check the loaded program is consistent with the attributes and uniforms
|
||||||
// expected in the code.
|
// expected in the code.
|
||||||
|
@ -15,6 +15,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.checkStateNotNull;
|
import static com.google.android.exoplayer2.util.Assertions.checkStateNotNull;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -61,6 +62,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(int inputTexId, int inputWidth, int inputHeight) throws IOException {
|
public void initialize(int inputTexId, int inputWidth, int inputHeight) throws IOException {
|
||||||
|
checkArgument(inputWidth > 0, "inputWidth must be positive");
|
||||||
|
checkArgument(inputHeight > 0, "inputHeight must be positive");
|
||||||
|
|
||||||
size = new Size(inputWidth, inputHeight);
|
size = new Size(inputWidth, inputHeight);
|
||||||
// TODO(b/205002913): check the loaded program is consistent with the attributes and uniforms
|
// TODO(b/205002913): check the loaded program is consistent with the attributes and uniforms
|
||||||
// expected in the code.
|
// expected in the code.
|
||||||
|
@ -15,6 +15,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 com.google.android.exoplayer2.util.Assertions.checkStateNotNull;
|
import static com.google.android.exoplayer2.util.Assertions.checkStateNotNull;
|
||||||
@ -86,6 +87,9 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
List<GlFrameProcessor> frameProcessors,
|
List<GlFrameProcessor> frameProcessors,
|
||||||
boolean enableExperimentalHdrEditing)
|
boolean enableExperimentalHdrEditing)
|
||||||
throws TransformationException {
|
throws TransformationException {
|
||||||
|
checkArgument(inputWidth > 0, "inputWidth must be positive");
|
||||||
|
checkArgument(inputHeight > 0, "inputHeight must be positive");
|
||||||
|
|
||||||
if (pixelWidthHeightRatio != 1.0f) {
|
if (pixelWidthHeightRatio != 1.0f) {
|
||||||
// TODO(b/211782176): Consider implementing support for non-square pixels.
|
// TODO(b/211782176): Consider implementing support for non-square pixels.
|
||||||
throw TransformationException.createForFrameProcessorChain(
|
throw TransformationException.createForFrameProcessorChain(
|
||||||
|
@ -282,6 +282,7 @@ public final class PresentationFrameProcessor implements GlFrameProcessor {
|
|||||||
/* package */ void configureOutputSizeAndTransformationMatrix(int inputWidth, int inputHeight) {
|
/* package */ void configureOutputSizeAndTransformationMatrix(int inputWidth, int inputHeight) {
|
||||||
checkArgument(inputWidth > 0, "inputWidth must be positive");
|
checkArgument(inputWidth > 0, "inputWidth must be positive");
|
||||||
checkArgument(inputHeight > 0, "inputHeight must be positive");
|
checkArgument(inputHeight > 0, "inputHeight must be positive");
|
||||||
|
|
||||||
transformationMatrix = new Matrix();
|
transformationMatrix = new Matrix();
|
||||||
outputWidth = inputWidth;
|
outputWidth = inputWidth;
|
||||||
outputHeight = inputHeight;
|
outputHeight = inputHeight;
|
||||||
|
@ -15,6 +15,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.checkStateNotNull;
|
import static com.google.android.exoplayer2.util.Assertions.checkStateNotNull;
|
||||||
import static java.lang.Math.max;
|
import static java.lang.Math.max;
|
||||||
import static java.lang.Math.min;
|
import static java.lang.Math.min;
|
||||||
@ -146,6 +147,9 @@ public final class ScaleToFitFrameProcessor implements GlFrameProcessor {
|
|||||||
@EnsuresNonNull("adjustedTransformationMatrix")
|
@EnsuresNonNull("adjustedTransformationMatrix")
|
||||||
@VisibleForTesting // Allows robolectric testing of output size calculation without OpenGL.
|
@VisibleForTesting // Allows robolectric testing of output size calculation without OpenGL.
|
||||||
/* package */ void configureOutputSizeAndTransformationMatrix(int inputWidth, int inputHeight) {
|
/* package */ void configureOutputSizeAndTransformationMatrix(int inputWidth, int inputHeight) {
|
||||||
|
checkArgument(inputWidth > 0, "inputWidth must be positive");
|
||||||
|
checkArgument(inputHeight > 0, "inputHeight must be positive");
|
||||||
|
|
||||||
adjustedTransformationMatrix = new Matrix(transformationMatrix);
|
adjustedTransformationMatrix = new Matrix(transformationMatrix);
|
||||||
|
|
||||||
if (transformationMatrix.isIdentity()) {
|
if (transformationMatrix.isIdentity()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user