diff --git a/library/effect/src/main/java/com/google/android/exoplayer2/effect/Contrast.java b/library/effect/src/main/java/com/google/android/exoplayer2/effect/Contrast.java index ad1f950600..c45f92ba28 100644 --- a/library/effect/src/main/java/com/google/android/exoplayer2/effect/Contrast.java +++ b/library/effect/src/main/java/com/google/android/exoplayer2/effect/Contrast.java @@ -19,6 +19,7 @@ package com.google.android.exoplayer2.effect; import static com.google.android.exoplayer2.util.Assertions.checkArgument; import android.content.Context; +import androidx.annotation.FloatRange; import com.google.android.exoplayer2.util.VideoFrameProcessingException; /** A {@link GlEffect} to control the contrast of video frames. */ @@ -33,7 +34,7 @@ public class Contrast implements GlEffect { *

Contrast values range from -1 (all gray pixels) to 1 (maximum difference of colors). 0 means * to add no contrast and leaves the frames unchanged. */ - public Contrast(float contrast) { + public Contrast(@FloatRange(from = -1, to = 1) float contrast) { checkArgument(-1 <= contrast && contrast <= 1, "Contrast needs to be in the interval [-1, 1]."); this.contrast = contrast; } diff --git a/library/effect/src/main/java/com/google/android/exoplayer2/effect/HslAdjustment.java b/library/effect/src/main/java/com/google/android/exoplayer2/effect/HslAdjustment.java index 7c19374afc..ab65c48c1d 100644 --- a/library/effect/src/main/java/com/google/android/exoplayer2/effect/HslAdjustment.java +++ b/library/effect/src/main/java/com/google/android/exoplayer2/effect/HslAdjustment.java @@ -19,6 +19,7 @@ package com.google.android.exoplayer2.effect; import static com.google.android.exoplayer2.util.Assertions.checkArgument; import android.content.Context; +import androidx.annotation.FloatRange; import com.google.android.exoplayer2.util.VideoFrameProcessingException; import com.google.errorprone.annotations.CanIgnoreReturnValue; @@ -61,7 +62,7 @@ public class HslAdjustment implements GlEffect { * {@code 0}, which means no change is applied. */ @CanIgnoreReturnValue - public Builder adjustSaturation(float saturationAdjustment) { + public Builder adjustSaturation(@FloatRange(from = -100, to = 100) float saturationAdjustment) { checkArgument( -100 <= saturationAdjustment && saturationAdjustment <= 100, "Can adjust the saturation by only 100 in either direction, but provided " @@ -81,7 +82,7 @@ public class HslAdjustment implements GlEffect { * {@code 0}, which means no change is applied. */ @CanIgnoreReturnValue - public Builder adjustLightness(float lightnessAdjustment) { + public Builder adjustLightness(@FloatRange(from = -100, to = 100) float lightnessAdjustment) { checkArgument( -100 <= lightnessAdjustment && lightnessAdjustment <= 100, "Can adjust the lightness by only 100 in either direction, but provided " diff --git a/library/effect/src/main/java/com/google/android/exoplayer2/effect/Presentation.java b/library/effect/src/main/java/com/google/android/exoplayer2/effect/Presentation.java index 9c1b352b0c..d300bc77c3 100644 --- a/library/effect/src/main/java/com/google/android/exoplayer2/effect/Presentation.java +++ b/library/effect/src/main/java/com/google/android/exoplayer2/effect/Presentation.java @@ -21,6 +21,7 @@ import static java.lang.annotation.ElementType.TYPE_USE; import static java.lang.annotation.RetentionPolicy.SOURCE; import android.graphics.Matrix; +import androidx.annotation.FloatRange; import androidx.annotation.IntDef; import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.util.Size; @@ -114,7 +115,8 @@ public final class Presentation implements MatrixTransformation { * @param aspectRatio The aspect ratio (width/height ratio) of the output frame. Must be positive. * @param layout The layout of the output frame. */ - public static Presentation createForAspectRatio(float aspectRatio, @Layout int layout) { + public static Presentation createForAspectRatio( + @FloatRange(from = 0, fromInclusive = false) float aspectRatio, @Layout int layout) { checkArgument( aspectRatio == C.LENGTH_UNSET || aspectRatio > 0, "aspect ratio " + aspectRatio + " must be positive or unset"); diff --git a/library/effect/src/main/java/com/google/android/exoplayer2/effect/RgbAdjustment.java b/library/effect/src/main/java/com/google/android/exoplayer2/effect/RgbAdjustment.java index d917d0acff..5d562aaa8c 100644 --- a/library/effect/src/main/java/com/google/android/exoplayer2/effect/RgbAdjustment.java +++ b/library/effect/src/main/java/com/google/android/exoplayer2/effect/RgbAdjustment.java @@ -19,6 +19,7 @@ package com.google.android.exoplayer2.effect; import static com.google.android.exoplayer2.util.Assertions.checkArgument; import android.opengl.Matrix; +import androidx.annotation.FloatRange; import com.google.android.exoplayer2.util.GlUtil; import com.google.errorprone.annotations.CanIgnoreReturnValue; @@ -45,7 +46,7 @@ public final class RgbAdjustment implements RgbMatrix { * default value is {@code 1}. */ @CanIgnoreReturnValue - public Builder setRedScale(float redScale) { + public Builder setRedScale(@FloatRange(from = 0) float redScale) { checkArgument(0 <= redScale, "Red scale needs to be non-negative."); this.redScale = redScale; return this; @@ -58,7 +59,7 @@ public final class RgbAdjustment implements RgbMatrix { * default value is {@code 1}. */ @CanIgnoreReturnValue - public Builder setGreenScale(float greenScale) { + public Builder setGreenScale(@FloatRange(from = 0) float greenScale) { checkArgument(0 <= greenScale, "Green scale needs to be non-negative."); this.greenScale = greenScale; return this; @@ -71,7 +72,7 @@ public final class RgbAdjustment implements RgbMatrix { * default value is {@code 1}. */ @CanIgnoreReturnValue - public Builder setBlueScale(float blueScale) { + public Builder setBlueScale(@FloatRange(from = 0) float blueScale) { checkArgument(0 <= blueScale, "Blue scale needs to be non-negative."); this.blueScale = blueScale; return this;