mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00: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
d629e45cfa
commit
3f4d03e731
5 changed files with 16 additions and 0 deletions
|
|
@ -169,6 +169,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 androidx.media3.transformer;
|
package androidx.media3.transformer;
|
||||||
|
|
||||||
|
import static androidx.media3.common.util.Assertions.checkArgument;
|
||||||
import static androidx.media3.common.util.Assertions.checkStateNotNull;
|
import static androidx.media3.common.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 androidx.media3.transformer;
|
package androidx.media3.transformer;
|
||||||
|
|
||||||
|
import static androidx.media3.common.util.Assertions.checkArgument;
|
||||||
import static androidx.media3.common.util.Assertions.checkNotNull;
|
import static androidx.media3.common.util.Assertions.checkNotNull;
|
||||||
import static androidx.media3.common.util.Assertions.checkState;
|
import static androidx.media3.common.util.Assertions.checkState;
|
||||||
import static androidx.media3.common.util.Assertions.checkStateNotNull;
|
import static androidx.media3.common.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(
|
||||||
|
|
|
||||||
|
|
@ -284,6 +284,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 androidx.media3.transformer;
|
package androidx.media3.transformer;
|
||||||
|
|
||||||
|
import static androidx.media3.common.util.Assertions.checkArgument;
|
||||||
import static androidx.media3.common.util.Assertions.checkStateNotNull;
|
import static androidx.media3.common.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;
|
||||||
|
|
@ -148,6 +149,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…
Reference in a new issue