mirror of
https://github.com/samsonjs/media.git
synced 2026-04-05 11:15:46 +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
|
||||
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);
|
||||
// TODO(b/205002913): check the loaded program is consistent with the attributes and uniforms
|
||||
// expected in the code.
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
package androidx.media3.transformer;
|
||||
|
||||
import static androidx.media3.common.util.Assertions.checkArgument;
|
||||
import static androidx.media3.common.util.Assertions.checkStateNotNull;
|
||||
|
||||
import android.content.Context;
|
||||
|
|
@ -61,6 +62,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||
|
||||
@Override
|
||||
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);
|
||||
// TODO(b/205002913): check the loaded program is consistent with the attributes and uniforms
|
||||
// expected in the code.
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
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.checkState;
|
||||
import static androidx.media3.common.util.Assertions.checkStateNotNull;
|
||||
|
|
@ -86,6 +87,9 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||
List<GlFrameProcessor> frameProcessors,
|
||||
boolean enableExperimentalHdrEditing)
|
||||
throws TransformationException {
|
||||
checkArgument(inputWidth > 0, "inputWidth must be positive");
|
||||
checkArgument(inputHeight > 0, "inputHeight must be positive");
|
||||
|
||||
if (pixelWidthHeightRatio != 1.0f) {
|
||||
// TODO(b/211782176): Consider implementing support for non-square pixels.
|
||||
throw TransformationException.createForFrameProcessorChain(
|
||||
|
|
|
|||
|
|
@ -284,6 +284,7 @@ public final class PresentationFrameProcessor implements GlFrameProcessor {
|
|||
/* package */ void configureOutputSizeAndTransformationMatrix(int inputWidth, int inputHeight) {
|
||||
checkArgument(inputWidth > 0, "inputWidth must be positive");
|
||||
checkArgument(inputHeight > 0, "inputHeight must be positive");
|
||||
|
||||
transformationMatrix = new Matrix();
|
||||
outputWidth = inputWidth;
|
||||
outputHeight = inputHeight;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
package androidx.media3.transformer;
|
||||
|
||||
import static androidx.media3.common.util.Assertions.checkArgument;
|
||||
import static androidx.media3.common.util.Assertions.checkStateNotNull;
|
||||
import static java.lang.Math.max;
|
||||
import static java.lang.Math.min;
|
||||
|
|
@ -148,6 +149,9 @@ public final class ScaleToFitFrameProcessor implements GlFrameProcessor {
|
|||
@EnsuresNonNull("adjustedTransformationMatrix")
|
||||
@VisibleForTesting // Allows robolectric testing of output size calculation without OpenGL.
|
||||
/* 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);
|
||||
|
||||
if (transformationMatrix.isIdentity()) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue