SeparableConvolutionShaderProgram


@RequiresApi(value = 26)
@UnstableApi
class SeparableConvolutionShaderProgram : GlShaderProgram


A GlShaderProgram for performing separable convolutions.

A single ConvolutionFunction1D is applied horizontally on a first pass and vertically on a second pass.

Summary

Public constructors

SeparableConvolutionShaderProgram(
    context: Context!,
    useHdr: Boolean,
    convolution: SeparableConvolution!,
    scaleWidth: Float,
    scaleHeight: Float
)

Creates an instance.

Public functions

Unit

Flushes the GlShaderProgram.

Unit
queueInputFrame(
    glObjectsProvider: GlObjectsProvider!,
    inputTexture: GlTextureInfo!,
    presentationTimeUs: Long
)

Processes an input frame if possible.

Unit

Releases all resources.

Unit

Notifies the GlShaderProgram that the frame on the given output texture is no longer used and can be overwritten.

Unit
setErrorListener(
    errorListenerExecutor: Executor!,
    errorListener: GlShaderProgram.ErrorListener!
)

Sets the ErrorListener.

Unit

Sets the InputListener.

Unit

Sets the OutputListener.

Unit

Notifies the GlShaderProgram that no further input frames belonging to the current input stream will be queued.

Protected functions

Unit
onBlurRendered(inputTexture: GlTextureInfo!)

Called when the blur has been rendered onto the frame.

Public constructors

SeparableConvolutionShaderProgram

SeparableConvolutionShaderProgram(
    context: Context!,
    useHdr: Boolean,
    convolution: SeparableConvolution!,
    scaleWidth: Float,
    scaleHeight: Float
)

Creates an instance.

Parameters
context: Context!

The Context.

useHdr: Boolean

Whether input textures come from an HDR source. If true, colors will be in linear RGB BT.2020. If false, colors will be in linear RGB BT.709.

convolution: SeparableConvolution!

The SeparableConvolution to apply in each direction.

scaleWidth: Float

The scaling factor used to determine the width of the output relative to the input.

scaleHeight: Float

The scaling factor used to determine the height of the output relative to the input.

Throws
androidx.media3.common.VideoFrameProcessingException

If a problem occurs while reading shader files.

Public functions

flush

fun flush(): Unit

Flushes the GlShaderProgram.

The GlShaderProgram should reclaim the ownership of its allocated textures, notify its InputListener about the flush event, and report its availability if necessary.

The implementation must not output frames until after this method returns.

queueInputFrame

fun queueInputFrame(
    glObjectsProvider: GlObjectsProvider!,
    inputTexture: GlTextureInfo!,
    presentationTimeUs: Long
): Unit

Processes an input frame if possible.

The GlShaderProgram owns the accepted frame until it calls onInputFrameProcessed. The caller should not overwrite or release the texture before the GlShaderProgram has finished processing it.

This method must only be called when the GlShaderProgram can accept an input frame.

Parameters
glObjectsProvider: GlObjectsProvider!

The GlObjectsProvider for using EGL and GLES.

inputTexture: GlTextureInfo!

A GlTextureInfo describing the texture containing the input frame.

presentationTimeUs: Long

The presentation timestamp of the input frame, in microseconds.

release

@CallSuper
fun release(): Unit

Releases all resources.

Throws
androidx.media3.common.VideoFrameProcessingException

If an error occurs while releasing resources.

releaseOutputFrame

fun releaseOutputFrame(outputTexture: GlTextureInfo!): Unit

Notifies the GlShaderProgram that the frame on the given output texture is no longer used and can be overwritten.

setErrorListener

fun setErrorListener(
    errorListenerExecutor: Executor!,
    errorListener: GlShaderProgram.ErrorListener!
): Unit

Sets the ErrorListener.

The ErrorListener is invoked on the provided Executor.

setInputListener

fun setInputListener(inputListener: GlShaderProgram.InputListener!): Unit

Sets the InputListener.

The InputListener should be invoked on the thread that owns the parent OpenGL context. For example, DefaultVideoFrameProcessor invokes the InputListener methods on its internal thread.

setOutputListener

fun setOutputListener(outputListener: GlShaderProgram.OutputListener!): Unit

Sets the OutputListener.

The OutputListener should be invoked on the thread that owns the parent OpenGL context. For example, DefaultVideoFrameProcessor invokes the OutputListener methods on its internal thread.

signalEndOfCurrentInputStream

fun signalEndOfCurrentInputStream(): Unit

Notifies the GlShaderProgram that no further input frames belonging to the current input stream will be queued.

Input frames that are queued after this method is called belong to a different input stream.

Protected functions

onBlurRendered

protected fun onBlurRendered(inputTexture: GlTextureInfo!): Unit

Called when the blur has been rendered onto the frame.

The default implementation is a no-op.

Parameters
inputTexture: GlTextureInfo!

The input texture.