# SeparableConvolutionShaderProgram

# SeparableConvolutionShaderProgram

Artifact:[androidx.media3:media3-effect](https://developer.android.com/jetpack/androidx/releases/media3)  
[View Source](https://cs.android.com/search?q=file:androidx/media3/effect/SeparableConvolutionShaderProgram.java+class:androidx.media3.effect.SeparableConvolutionShaderProgram)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/media3/effect/SeparableConvolutionShaderProgram "View this page in Java")

<br />

```
@UnstableApi
class SeparableConvolutionShaderProgram : GlShaderProgram
```

<br />

*** ** * ** ***

A[GlShaderProgram](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlShaderProgram)for performing separable convolutions.

A single[ConvolutionFunction1D](https://developer.android.com/reference/kotlin/androidx/media3/effect/ConvolutionFunction1D)is applied horizontally on a first pass and vertically on a second pass.

## Summary

|                                                                                                                                                                                                                                                                                                                                                                                                            ### Public constructors                                                                                                                                                                                                                                                                                                                                                                                                             |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [SeparableConvolutionShaderProgram](https://developer.android.com/reference/kotlin/androidx/media3/effect/SeparableConvolutionShaderProgram#SeparableConvolutionShaderProgram(android.content.Context,boolean,androidx.media3.effect.ConvolutionFunction1D.Provider))`(` ` context: `[Context](https://developer.android.com/reference/android/content/Context.html)`!,` ` useHdr: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`,` ` convolutionFunction1DProvider: `[ConvolutionFunction1D.Provider](https://developer.android.com/reference/kotlin/androidx/media3/effect/ConvolutionFunction1D.Provider)`!` `)` Creates an instance.                                                                                                                                                                |
| [SeparableConvolutionShaderProgram](https://developer.android.com/reference/kotlin/androidx/media3/effect/SeparableConvolutionShaderProgram#SeparableConvolutionShaderProgram(android.content.Context,boolean,androidx.media3.effect.SeparableConvolution,float,float))`(` ` context: `[Context](https://developer.android.com/reference/android/content/Context.html)`!,` ` useHdr: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`,` ` convolution: `[SeparableConvolution](https://developer.android.com/reference/kotlin/androidx/media3/effect/SeparableConvolution)`!,` ` scaleWidth: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`,` ` scaleHeight: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) `)` Creates an instance. |

|                             ### Public functions                              |
|-------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [flush](https://developer.android.com/reference/kotlin/androidx/media3/effect/SeparableConvolutionShaderProgram#flush())`()` Flushes the`GlShaderProgram`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [queueInputFrame](https://developer.android.com/reference/kotlin/androidx/media3/effect/SeparableConvolutionShaderProgram#queueInputFrame(androidx.media3.common.GlObjectsProvider,androidx.media3.common.GlTextureInfo,long))`(` ` glObjectsProvider: `[GlObjectsProvider](https://developer.android.com/reference/kotlin/androidx/media3/common/GlObjectsProvider)`!,` ` inputTexture: `[GlTextureInfo](https://developer.android.com/reference/kotlin/androidx/media3/common/GlTextureInfo)`!,` ` presentationTimeUs: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) `)` Processes an input frame if possible.    |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | `@`[CallSuper](https://developer.android.com/reference/kotlin/androidx/annotation/CallSuper) [release](https://developer.android.com/reference/kotlin/androidx/media3/effect/SeparableConvolutionShaderProgram#release())`()` Releases all resources.                                                                                                                                                                                                                                                                                                                                                                                                |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [releaseOutputFrame](https://developer.android.com/reference/kotlin/androidx/media3/effect/SeparableConvolutionShaderProgram#releaseOutputFrame(androidx.media3.common.GlTextureInfo))`(outputTexture: `[GlTextureInfo](https://developer.android.com/reference/kotlin/androidx/media3/common/GlTextureInfo)`!)` Notifies the`GlShaderProgram`that the frame on the given output texture is no longer used and can be overwritten.                                                                                                                                                                                                                   |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [setErrorListener](https://developer.android.com/reference/kotlin/androidx/media3/effect/SeparableConvolutionShaderProgram#setErrorListener(java.util.concurrent.Executor,androidx.media3.effect.GlShaderProgram.ErrorListener))`(` ` errorListenerExecutor: `[Executor](https://developer.android.com/reference/java/util/concurrent/Executor.html)`!,` ` errorListener: `[GlShaderProgram.ErrorListener](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlShaderProgram.ErrorListener)`!` `)` Sets the[ErrorListener](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlShaderProgram.ErrorListener). |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [setInputListener](https://developer.android.com/reference/kotlin/androidx/media3/effect/SeparableConvolutionShaderProgram#setInputListener(androidx.media3.effect.GlShaderProgram.InputListener))`(inputListener: `[GlShaderProgram.InputListener](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlShaderProgram.InputListener)`!)` Sets the[InputListener](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlShaderProgram.InputListener).                                                                                                                                                           |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [setOutputListener](https://developer.android.com/reference/kotlin/androidx/media3/effect/SeparableConvolutionShaderProgram#setOutputListener(androidx.media3.effect.GlShaderProgram.OutputListener))`(outputListener: `[GlShaderProgram.OutputListener](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlShaderProgram.OutputListener)`!)` Sets the[OutputListener](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlShaderProgram.OutputListener).                                                                                                                                                   |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [signalEndOfCurrentInputStream](https://developer.android.com/reference/kotlin/androidx/media3/effect/SeparableConvolutionShaderProgram#signalEndOfCurrentInputStream())`()` Notifies the`GlShaderProgram`that no further input frames belonging to the current input stream will be queued.                                                                                                                                                                                                                                                                                                                                                         |

|                            ### Protected functions                            |
|-------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [onBlurRendered](https://developer.android.com/reference/kotlin/androidx/media3/effect/SeparableConvolutionShaderProgram#onBlurRendered(androidx.media3.common.GlTextureInfo))`(inputTexture: `[GlTextureInfo](https://developer.android.com/reference/kotlin/androidx/media3/common/GlTextureInfo)`!)` Called when the blur has been rendered onto the frame. |

## Public constructors

### SeparableConvolutionShaderProgram

```
SeparableConvolutionShaderProgram(
    context: Context!,
    useHdr: Boolean,
    convolutionFunction1DProvider: ConvolutionFunction1D.Provider!
)
```

Creates an instance.  

|                                                                                 Parameters                                                                                 |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `context: `[Context](https://developer.android.com/reference/android/content/Context.html)`!`                                                                              | The[Context](https://developer.android.com/reference/android/content/Context.html).                                                                                                                                 |
| `useHdr: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                                                              | 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.                                                                     |
| `convolutionFunction1DProvider: `[ConvolutionFunction1D.Provider](https://developer.android.com/reference/kotlin/androidx/media3/effect/ConvolutionFunction1D.Provider)`!` | The[ConvolutionFunction1D.Provider](https://developer.android.com/reference/kotlin/androidx/media3/effect/ConvolutionFunction1D.Provider)which will provide the 1D convolution function to apply in each direction. |

|                                                                           Throws                                                                            |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------|
| [androidx.media3.common.VideoFrameProcessingException](https://developer.android.com/reference/kotlin/androidx/media3/common/VideoFrameProcessingException) | If a problem occurs while reading shader files. |

### SeparableConvolutionShaderProgram

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

Creates an instance.  

|                                                              Parameters                                                              |
|--------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|
| `context: `[Context](https://developer.android.com/reference/android/content/Context.html)`!`                                        | The[Context](https://developer.android.com/reference/android/content/Context.html).                                                              |
| `useHdr: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                        | 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](https://developer.android.com/reference/kotlin/androidx/media3/effect/SeparableConvolution)`!` | The[SeparableConvolution](https://developer.android.com/reference/kotlin/androidx/media3/effect/SeparableConvolution)to apply in each direction. |
| `scaleWidth: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)                                        | The scaling factor used to determine the width of the output relative to the input.                                                              |
| `scaleHeight: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)                                       | The scaling factor used to determine the height of the output relative to the input.                                                             |

|                                                                           Throws                                                                            |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------|
| [androidx.media3.common.VideoFrameProcessingException](https://developer.android.com/reference/kotlin/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](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlShaderProgram.InputListener#onFlush())its[InputListener](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlShaderProgram.InputListener)about the flush event, and[report its availability](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlShaderProgram.InputListener#onReadyToAcceptInputFrame())if necessary.

The implementation must not[output frames](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlShaderProgram.OutputListener#onOutputFrameAvailable(androidx.media3.common.GlTextureInfo,long))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](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlShaderProgram.InputListener#onInputFrameProcessed(androidx.media3.common.GlTextureInfo)). 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](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlShaderProgram.InputListener#onReadyToAcceptInputFrame()).  

|                                                              Parameters                                                              |
|--------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|
| `glObjectsProvider: `[GlObjectsProvider](https://developer.android.com/reference/kotlin/androidx/media3/common/GlObjectsProvider)`!` | The[GlObjectsProvider](https://developer.android.com/reference/kotlin/androidx/media3/common/GlObjectsProvider)for using EGL and GLES.                  |
| `inputTexture: `[GlTextureInfo](https://developer.android.com/reference/kotlin/androidx/media3/common/GlTextureInfo)`!`              | A[GlTextureInfo](https://developer.android.com/reference/kotlin/androidx/media3/common/GlTextureInfo)describing the texture containing the input frame. |
| `presentationTimeUs: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                                  | The presentation timestamp of the input frame, in microseconds.                                                                                         |

### release

```
@CallSuper
fun release(): Unit
```

Releases all resources.  

|                                                                           Throws                                                                            |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------|
| [androidx.media3.common.VideoFrameProcessingException](https://developer.android.com/reference/kotlin/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](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlShaderProgram.ErrorListener).

The[ErrorListener](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlShaderProgram.ErrorListener)is invoked on the provided[Executor](https://developer.android.com/reference/java/util/concurrent/Executor.html).  

### setInputListener

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

Sets the[InputListener](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlShaderProgram.InputListener).

The[InputListener](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlShaderProgram.InputListener)should be invoked on the thread that owns the parent OpenGL context. For example,[DefaultVideoFrameProcessor](https://developer.android.com/reference/kotlin/androidx/media3/effect/DefaultVideoFrameProcessor)invokes the[InputListener](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlShaderProgram.InputListener)methods on its internal thread.  

### setOutputListener

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

Sets the[OutputListener](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlShaderProgram.OutputListener).

The[OutputListener](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlShaderProgram.OutputListener)should be invoked on the thread that owns the parent OpenGL context. For example,[DefaultVideoFrameProcessor](https://developer.android.com/reference/kotlin/androidx/media3/effect/DefaultVideoFrameProcessor)invokes the[OutputListener](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlShaderProgram.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](https://developer.android.com/reference/kotlin/androidx/media3/common/GlTextureInfo)`!` | The input texture. |

|                                                                     Throws                                                                      |
|-------------------------------------------------------------------------------------------------------------------------------------------------|---------------------|
| [androidx.media3.common.util.GlUtil.GlException](https://developer.android.com/reference/kotlin/androidx/media3/common/util/GlUtil.GlException) | If an error occurs. |