Deprecate SingleFrameShaderProgram
PiperOrigin-RevId: 555450958
This commit is contained in:
parent
4d0fb4326a
commit
c1913e8d89
@ -23,14 +23,15 @@ import androidx.media3.common.VideoFrameProcessingException;
|
||||
import androidx.media3.common.util.GlProgram;
|
||||
import androidx.media3.common.util.GlUtil;
|
||||
import androidx.media3.common.util.Size;
|
||||
import androidx.media3.effect.SingleFrameGlShaderProgram;
|
||||
import androidx.media3.effect.BaseGlShaderProgram;
|
||||
import androidx.media3.effect.GlShaderProgram;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* A {@link SingleFrameGlShaderProgram} that periodically dims the frames such that pixels are
|
||||
* darker the further they are away from the frame center.
|
||||
* A {@link GlShaderProgram} that periodically dims the frames such that pixels are darker the
|
||||
* further they are away from the frame center.
|
||||
*/
|
||||
/* package */ final class PeriodicVignetteShaderProgram extends SingleFrameGlShaderProgram {
|
||||
/* package */ final class PeriodicVignetteShaderProgram extends BaseGlShaderProgram {
|
||||
|
||||
private static final String VERTEX_SHADER_PATH = "vertex_shader_copy_es2.glsl";
|
||||
private static final String FRAGMENT_SHADER_PATH = "fragment_shader_vignette_es2.glsl";
|
||||
@ -70,7 +71,7 @@ import java.io.IOException;
|
||||
float maxInnerRadius,
|
||||
float outerRadius)
|
||||
throws VideoFrameProcessingException {
|
||||
super(/* useHighPrecisionColorComponents= */ useHdr);
|
||||
super(/* useHighPrecisionColorComponents= */ useHdr, /* texturePoolCapacity= */ 1);
|
||||
checkArgument(minInnerRadius <= maxInnerRadius);
|
||||
checkArgument(maxInnerRadius <= outerRadius);
|
||||
this.minInnerRadius = minInnerRadius;
|
||||
|
@ -78,7 +78,7 @@ public class ContrastPixelTest {
|
||||
private @MonotonicNonNull EGLDisplay eglDisplay;
|
||||
private @MonotonicNonNull EGLContext eglContext;
|
||||
private @MonotonicNonNull EGLSurface placeholderEglSurface;
|
||||
private @MonotonicNonNull SingleFrameGlShaderProgram contrastShaderProgram;
|
||||
private @MonotonicNonNull BaseGlShaderProgram contrastShaderProgram;
|
||||
private int inputTexId;
|
||||
private int inputWidth;
|
||||
private int inputHeight;
|
||||
|
@ -70,7 +70,7 @@ public final class CropPixelTest {
|
||||
private @MonotonicNonNull String testId;
|
||||
private @MonotonicNonNull EGLDisplay eglDisplay;
|
||||
private @MonotonicNonNull EGLContext eglContext;
|
||||
private @MonotonicNonNull SingleFrameGlShaderProgram cropShaderProgram;
|
||||
private @MonotonicNonNull BaseGlShaderProgram cropShaderProgram;
|
||||
private @MonotonicNonNull EGLSurface placeholderEglSurface;
|
||||
private int inputTexId;
|
||||
private int inputWidth;
|
||||
|
@ -71,7 +71,7 @@ public final class DefaultShaderProgramPixelTest {
|
||||
private @MonotonicNonNull String testId;
|
||||
private @MonotonicNonNull EGLDisplay eglDisplay;
|
||||
private @MonotonicNonNull EGLContext eglContext;
|
||||
private @MonotonicNonNull SingleFrameGlShaderProgram defaultShaderProgram;
|
||||
private @MonotonicNonNull BaseGlShaderProgram defaultShaderProgram;
|
||||
private int inputTexId;
|
||||
private int inputWidth;
|
||||
private int inputHeight;
|
||||
|
@ -75,7 +75,7 @@ public final class HslAdjustmentPixelTest {
|
||||
|
||||
private @MonotonicNonNull EGLDisplay eglDisplay;
|
||||
private @MonotonicNonNull EGLContext eglContext;
|
||||
private @MonotonicNonNull SingleFrameGlShaderProgram hslProcessor;
|
||||
private @MonotonicNonNull BaseGlShaderProgram hslProcessor;
|
||||
private @MonotonicNonNull EGLSurface placeholderEglSurface;
|
||||
private int inputTexId;
|
||||
private int inputWidth;
|
||||
|
@ -96,7 +96,7 @@ public class OverlayShaderProgramPixelTest {
|
||||
private @MonotonicNonNull String testId;
|
||||
private @MonotonicNonNull EGLDisplay eglDisplay;
|
||||
private @MonotonicNonNull EGLContext eglContext;
|
||||
private @MonotonicNonNull SingleFrameGlShaderProgram overlayShaderProgram;
|
||||
private @MonotonicNonNull BaseGlShaderProgram overlayShaderProgram;
|
||||
private @MonotonicNonNull EGLSurface placeholderEglSurface;
|
||||
private int inputTexId;
|
||||
private int inputWidth;
|
||||
|
@ -79,7 +79,7 @@ public final class PresentationPixelTest {
|
||||
private @MonotonicNonNull String testId;
|
||||
private @MonotonicNonNull EGLDisplay eglDisplay;
|
||||
private @MonotonicNonNull EGLContext eglContext;
|
||||
private @MonotonicNonNull SingleFrameGlShaderProgram presentationShaderProgram;
|
||||
private @MonotonicNonNull BaseGlShaderProgram presentationShaderProgram;
|
||||
private @MonotonicNonNull EGLSurface placeholderEglSurface;
|
||||
private int inputTexId;
|
||||
private int inputWidth;
|
||||
|
@ -76,7 +76,7 @@ public final class RgbAdjustmentPixelTest {
|
||||
private @MonotonicNonNull String testId;
|
||||
private @MonotonicNonNull EGLDisplay eglDisplay;
|
||||
private @MonotonicNonNull EGLContext eglContext;
|
||||
private @MonotonicNonNull SingleFrameGlShaderProgram defaultShaderProgram;
|
||||
private @MonotonicNonNull BaseGlShaderProgram defaultShaderProgram;
|
||||
private @MonotonicNonNull EGLSurface placeholderEglSurface;
|
||||
private int inputTexId;
|
||||
private int inputWidth;
|
||||
|
@ -71,7 +71,7 @@ public final class RgbFilterPixelTest {
|
||||
private @MonotonicNonNull String testId;
|
||||
private @MonotonicNonNull EGLDisplay eglDisplay;
|
||||
private @MonotonicNonNull EGLContext eglContext;
|
||||
private @MonotonicNonNull SingleFrameGlShaderProgram defaultShaderProgram;
|
||||
private @MonotonicNonNull BaseGlShaderProgram defaultShaderProgram;
|
||||
private @MonotonicNonNull EGLSurface placeholderEglSurface;
|
||||
private int inputTexId;
|
||||
private int inputWidth;
|
||||
|
@ -77,7 +77,7 @@ public class SingleColorLutPixelTest {
|
||||
private @MonotonicNonNull EGLDisplay eglDisplay;
|
||||
private @MonotonicNonNull EGLContext eglContext;
|
||||
private @MonotonicNonNull EGLSurface placeholderEglSurface;
|
||||
private @MonotonicNonNull SingleFrameGlShaderProgram colorLutShaderProgram;
|
||||
private @MonotonicNonNull BaseGlShaderProgram colorLutShaderProgram;
|
||||
private int inputTexId;
|
||||
private int inputWidth;
|
||||
private int inputHeight;
|
||||
|
@ -35,8 +35,7 @@ import java.util.concurrent.Executor;
|
||||
* into an output frame, with changes to pixels specific to the implementation.
|
||||
*
|
||||
* <p>{@code BaseShaderProgram} implementations can produce any number of output frames per input
|
||||
* frame with the same presentation timestamp. {@link SingleFrameGlShaderProgram} can be used to
|
||||
* implement a {@link GlShaderProgram} that produces exactly one output frame per input frame.
|
||||
* frame with the same presentation timestamp.
|
||||
*
|
||||
* <p>All methods in this class must be called on the thread that owns the OpenGL context.
|
||||
*/
|
||||
|
@ -41,7 +41,7 @@ public interface ColorLut extends GlEffect {
|
||||
void release() throws GlUtil.GlException;
|
||||
|
||||
@Override
|
||||
default SingleFrameGlShaderProgram toGlShaderProgram(Context context, boolean useHdr)
|
||||
default GlShaderProgram toGlShaderProgram(Context context, boolean useHdr)
|
||||
throws VideoFrameProcessingException {
|
||||
return new ColorLutShaderProgram(context, /* colorLut= */ this, useHdr);
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import androidx.media3.common.util.Size;
|
||||
import java.io.IOException;
|
||||
|
||||
/** Applies a {@link ColorLut} to each frame in the fragment shader. */
|
||||
/* package */ final class ColorLutShaderProgram extends SingleFrameGlShaderProgram {
|
||||
/* package */ final class ColorLutShaderProgram extends BaseGlShaderProgram {
|
||||
private static final String VERTEX_SHADER_PATH = "shaders/vertex_shader_transformation_es2.glsl";
|
||||
private static final String FRAGMENT_SHADER_PATH = "shaders/fragment_shader_lut_es2.glsl";
|
||||
|
||||
@ -45,7 +45,7 @@ import java.io.IOException;
|
||||
*/
|
||||
public ColorLutShaderProgram(Context context, ColorLut colorLut, boolean useHdr)
|
||||
throws VideoFrameProcessingException {
|
||||
super(/* useHighPrecisionColorComponents= */ useHdr);
|
||||
super(/* useHighPrecisionColorComponents= */ useHdr, /* texturePoolCapacity= */ 1);
|
||||
// TODO(b/246315245): Add HDR support.
|
||||
checkArgument(!useHdr, "ColorLutShaderProgram does not support HDR colors.");
|
||||
this.colorLut = colorLut;
|
||||
|
@ -54,7 +54,7 @@ import java.util.List;
|
||||
*/
|
||||
@UnstableApi
|
||||
@SuppressWarnings("FunctionalInterfaceClash") // b/228192298
|
||||
/* package */ final class DefaultShaderProgram extends SingleFrameGlShaderProgram
|
||||
/* package */ final class DefaultShaderProgram extends BaseGlShaderProgram
|
||||
implements ExternalShaderProgram {
|
||||
|
||||
private static final String VERTEX_SHADER_TRANSFORMATION_PATH =
|
||||
@ -387,7 +387,7 @@ import java.util.List;
|
||||
checkArgument(
|
||||
outputColorTransfer == C.COLOR_TRANSFER_SDR
|
||||
|| outputColorTransfer == C.COLOR_TRANSFER_LINEAR);
|
||||
// The SDR shader automatically applies an COLOR_TRANSFER_SDR EOTF.
|
||||
// The SDR shader automatically applies a COLOR_TRANSFER_SDR EOTF.
|
||||
glProgram.setIntUniform("uOutputColorTransfer", outputColorTransfer);
|
||||
}
|
||||
|
||||
@ -417,7 +417,7 @@ import java.util.List;
|
||||
ImmutableList<RgbMatrix> rgbMatrices,
|
||||
int outputColorTransfer,
|
||||
boolean useHdr) {
|
||||
super(/* useHighPrecisionColorComponents= */ useHdr);
|
||||
super(/* useHighPrecisionColorComponents= */ useHdr, /* texturePoolCapacity= */ 1);
|
||||
this.glProgram = glProgram;
|
||||
this.outputColorTransfer = outputColorTransfer;
|
||||
this.matrixTransformations = matrixTransformations;
|
||||
|
@ -53,7 +53,7 @@ public interface GlMatrixTransformation extends GlEffect {
|
||||
float[] getGlMatrixArray(long presentationTimeUs);
|
||||
|
||||
@Override
|
||||
default SingleFrameGlShaderProgram toGlShaderProgram(Context context, boolean useHdr)
|
||||
default BaseGlShaderProgram toGlShaderProgram(Context context, boolean useHdr)
|
||||
throws VideoFrameProcessingException {
|
||||
return DefaultShaderProgram.create(
|
||||
context,
|
||||
|
@ -116,7 +116,7 @@ public final class HslAdjustment implements GlEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SingleFrameGlShaderProgram toGlShaderProgram(Context context, boolean useHdr)
|
||||
public BaseGlShaderProgram toGlShaderProgram(Context context, boolean useHdr)
|
||||
throws VideoFrameProcessingException {
|
||||
return new HslShaderProgram(context, /* hslAdjustment= */ this, useHdr);
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import androidx.media3.common.util.Size;
|
||||
import java.io.IOException;
|
||||
|
||||
/** Applies the {@link HslAdjustment} to each frame in the fragment shader. */
|
||||
/* package */ final class HslShaderProgram extends SingleFrameGlShaderProgram {
|
||||
/* package */ final class HslShaderProgram extends BaseGlShaderProgram {
|
||||
private static final String VERTEX_SHADER_PATH = "shaders/vertex_shader_transformation_es2.glsl";
|
||||
private static final String FRAGMENT_SHADER_PATH = "shaders/fragment_shader_hsl_es2.glsl";
|
||||
|
||||
@ -44,7 +44,7 @@ import java.io.IOException;
|
||||
*/
|
||||
public HslShaderProgram(Context context, HslAdjustment hslAdjustment, boolean useHdr)
|
||||
throws VideoFrameProcessingException {
|
||||
super(/* useHighPrecisionColorComponents= */ useHdr);
|
||||
super(/* useHighPrecisionColorComponents= */ useHdr, /* texturePoolCapacity= */ 1);
|
||||
// TODO(b/241241680): Check if HDR <-> HSL works the same or not.
|
||||
checkArgument(!useHdr, "HDR is not yet supported.");
|
||||
|
||||
|
@ -39,7 +39,7 @@ public final class OverlayEffect implements GlEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SingleFrameGlShaderProgram toGlShaderProgram(Context context, boolean useHdr)
|
||||
public BaseGlShaderProgram toGlShaderProgram(Context context, boolean useHdr)
|
||||
throws VideoFrameProcessingException {
|
||||
return new OverlayShaderProgram(context, useHdr, overlays);
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ import androidx.media3.common.util.Util;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
/** Applies zero or more {@link TextureOverlay}s onto each frame. */
|
||||
/* package */ final class OverlayShaderProgram extends SingleFrameGlShaderProgram {
|
||||
/* package */ final class OverlayShaderProgram extends BaseGlShaderProgram {
|
||||
|
||||
private static final int MATRIX_OFFSET = 0;
|
||||
|
||||
@ -61,7 +61,7 @@ import com.google.common.collect.ImmutableList;
|
||||
public OverlayShaderProgram(
|
||||
Context context, boolean useHdr, ImmutableList<TextureOverlay> overlays)
|
||||
throws VideoFrameProcessingException {
|
||||
super(/* useHighPrecisionColorComponents= */ useHdr);
|
||||
super(/* useHighPrecisionColorComponents= */ useHdr, /* texturePoolCapacity= */ 1);
|
||||
checkArgument(!useHdr, "OverlayShaderProgram does not support HDR colors yet.");
|
||||
// The maximum number of samplers allowed in a single GL program is 16.
|
||||
// We use one for every overlay and one for the video.
|
||||
|
@ -92,7 +92,7 @@ public final class RgbFilter implements RgbMatrix {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SingleFrameGlShaderProgram toGlShaderProgram(Context context, boolean useHdr)
|
||||
public BaseGlShaderProgram toGlShaderProgram(Context context, boolean useHdr)
|
||||
throws VideoFrameProcessingException {
|
||||
checkForConsistentHdrSetting(useHdr);
|
||||
return RgbMatrix.super.toGlShaderProgram(context, useHdr);
|
||||
|
@ -40,7 +40,7 @@ public interface RgbMatrix extends GlEffect {
|
||||
float[] getMatrix(long presentationTimeUs, boolean useHdr);
|
||||
|
||||
@Override
|
||||
default SingleFrameGlShaderProgram toGlShaderProgram(Context context, boolean useHdr)
|
||||
default BaseGlShaderProgram toGlShaderProgram(Context context, boolean useHdr)
|
||||
throws VideoFrameProcessingException {
|
||||
return DefaultShaderProgram.create(
|
||||
context,
|
||||
|
@ -149,7 +149,7 @@ public final class SingleColorLut implements ColorLut {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SingleFrameGlShaderProgram toGlShaderProgram(Context context, boolean useHdr)
|
||||
public BaseGlShaderProgram toGlShaderProgram(Context context, boolean useHdr)
|
||||
throws VideoFrameProcessingException {
|
||||
checkState(!useHdr, "HDR is currently not supported.");
|
||||
|
||||
|
@ -26,8 +26,11 @@ import androidx.media3.common.util.UnstableApi;
|
||||
* GlShaderProgram} directly.
|
||||
*
|
||||
* <p>All methods in this class must be called on the thread that owns the OpenGL context.
|
||||
*
|
||||
* @deprecated Use {@link BaseGlShaderProgram} instead.
|
||||
*/
|
||||
@UnstableApi
|
||||
@Deprecated
|
||||
public abstract class SingleFrameGlShaderProgram extends BaseGlShaderProgram {
|
||||
|
||||
// TODO(b/275384398): Remove this class as it only wraps the BaseGlShaderProgram.
|
||||
|
@ -28,7 +28,7 @@ import java.io.IOException;
|
||||
* Draws the target input frame at a given horizontal position of the output texture to generate an
|
||||
* horizontal tiling effect.
|
||||
*/
|
||||
/* package */ final class ThumbnailStripShaderProgram extends SingleFrameGlShaderProgram {
|
||||
/* package */ final class ThumbnailStripShaderProgram extends BaseGlShaderProgram {
|
||||
private static final String VERTEX_SHADER_PATH = "shaders/vertex_shader_thumbnail_strip_es2.glsl";
|
||||
private static final String FRAGMENT_SHADER_PATH = "shaders/fragment_shader_copy_es2.glsl";
|
||||
|
||||
@ -38,7 +38,7 @@ import java.io.IOException;
|
||||
public ThumbnailStripShaderProgram(
|
||||
Context context, boolean useHdr, ThumbnailStripEffect thumbnailStripEffect)
|
||||
throws VideoFrameProcessingException {
|
||||
super(useHdr);
|
||||
super(useHdr, /* texturePoolCapacity= */ 1);
|
||||
this.thumbnailStripEffect = thumbnailStripEffect;
|
||||
|
||||
try {
|
||||
|
Loading…
x
Reference in New Issue
Block a user