# 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)

*** ** * ** ***


```
@UnstableApi
public class SeparableConvolutionShaderProgram implements GlShaderProgram
```

<br />

*** ** * ** ***

A `https://developer.android.com/reference/androidx/media3/effect/GlShaderProgram` for performing separable convolutions.

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

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/effect/SeparableConvolutionShaderProgram#SeparableConvolutionShaderProgram(android.content.Context,boolean,androidx.media3.effect.ConvolutionFunction1D.Provider)( https://developer.android.com/reference/android/content/Context.html context, boolean useHdr, https://developer.android.com/reference/androidx/media3/effect/ConvolutionFunction1D.Provider convolutionFunction1DProvider )` Creates an instance. |
| `https://developer.android.com/reference/androidx/media3/effect/SeparableConvolutionShaderProgram#SeparableConvolutionShaderProgram(android.content.Context,boolean,androidx.media3.effect.SeparableConvolution,float,float)( https://developer.android.com/reference/android/content/Context.html context, boolean useHdr, https://developer.android.com/reference/androidx/media3/effect/SeparableConvolution convolution, float scaleWidth, float scaleHeight )` Creates an instance. |

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

| ### Protected methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/media3/effect/SeparableConvolutionShaderProgram#onBlurRendered(androidx.media3.common.GlTextureInfo)(https://developer.android.com/reference/androidx/media3/common/GlTextureInfo inputTexture)` Called when the blur has been rendered onto the frame. |

## Public constructors

### SeparableConvolutionShaderProgram

```
public SeparableConvolutionShaderProgram(
    Context context,
    boolean useHdr,
    ConvolutionFunction1D.Provider convolutionFunction1DProvider
)
```

Creates an instance.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/content/Context.html context` | The `https://developer.android.com/reference/android/content/Context.html`. |
| `boolean useHdr` | 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. |
| `https://developer.android.com/reference/androidx/media3/effect/ConvolutionFunction1D.Provider convolutionFunction1DProvider` | The `https://developer.android.com/reference/androidx/media3/effect/ConvolutionFunction1D.Provider` which will provide the 1D convolution function to apply in each direction. |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/VideoFrameProcessingException` | If a problem occurs while reading shader files. |

### SeparableConvolutionShaderProgram

```
public SeparableConvolutionShaderProgram(
    Context context,
    boolean useHdr,
    SeparableConvolution convolution,
    float scaleWidth,
    float scaleHeight
)
```

Creates an instance.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/content/Context.html context` | The `https://developer.android.com/reference/android/content/Context.html`. |
| `boolean useHdr` | 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. |
| `https://developer.android.com/reference/androidx/media3/effect/SeparableConvolution convolution` | The `https://developer.android.com/reference/androidx/media3/effect/SeparableConvolution` to apply in each direction. |
| `float scaleWidth` | The scaling factor used to determine the width of the output relative to the input. |
| `float scaleHeight` | The scaling factor used to determine the height of the output relative to the input. |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/VideoFrameProcessingException` | If a problem occurs while reading shader files. |

## Public methods

### flush

```
public final void flush()
```

Flushes the `GlShaderProgram`.

The `GlShaderProgram` should reclaim the ownership of its allocated textures, `https://developer.android.com/reference/androidx/media3/effect/GlShaderProgram.InputListener#onFlush()` its `https://developer.android.com/reference/androidx/media3/effect/GlShaderProgram.InputListener` about the flush event, and `https://developer.android.com/reference/androidx/media3/effect/GlShaderProgram.InputListener#onReadyToAcceptInputFrame()` if necessary.

The implementation must not `https://developer.android.com/reference/androidx/media3/effect/GlShaderProgram.OutputListener#onOutputFrameAvailable(androidx.media3.common.GlTextureInfo,long)` until after this method returns.

### queueInputFrame

```
public final void queueInputFrame(
    GlObjectsProvider glObjectsProvider,
    GlTextureInfo inputTexture,
    long presentationTimeUs
)
```

Processes an input frame if possible.

The `GlShaderProgram` owns the accepted frame until it calls `https://developer.android.com/reference/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 `https://developer.android.com/reference/androidx/media3/effect/GlShaderProgram.InputListener#onReadyToAcceptInputFrame()`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/GlObjectsProvider glObjectsProvider` | The `https://developer.android.com/reference/androidx/media3/common/GlObjectsProvider` for using EGL and GLES. |
| `https://developer.android.com/reference/androidx/media3/common/GlTextureInfo inputTexture` | A `https://developer.android.com/reference/androidx/media3/common/GlTextureInfo` describing the texture containing the input frame. |
| `long presentationTimeUs` | The presentation timestamp of the input frame, in microseconds. |

### release

```
@CallSuper
public void release()
```

Releases all resources.

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/VideoFrameProcessingException` | If an error occurs while releasing resources. |

### releaseOutputFrame

```
public final void releaseOutputFrame(GlTextureInfo outputTexture)
```

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

### setErrorListener

```
public final void setErrorListener(
    Executor errorListenerExecutor,
    GlShaderProgram.ErrorListener errorListener
)
```

Sets the `https://developer.android.com/reference/androidx/media3/effect/GlShaderProgram.ErrorListener`.

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

### setInputListener

```
public final void setInputListener(GlShaderProgram.InputListener inputListener)
```

Sets the `https://developer.android.com/reference/androidx/media3/effect/GlShaderProgram.InputListener`.

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

### setOutputListener

```
public final void setOutputListener(GlShaderProgram.OutputListener outputListener)
```

Sets the `https://developer.android.com/reference/androidx/media3/effect/GlShaderProgram.OutputListener`.

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

### signalEndOfCurrentInputStream

```
public final void signalEndOfCurrentInputStream()
```

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 methods

### onBlurRendered

```
protected void onBlurRendered(GlTextureInfo inputTexture)
```

Called when the blur has been rendered onto the frame.

The default implementation is a no-op.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/GlTextureInfo inputTexture` | The input texture. |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/util/GlUtil.GlException` | If an error occurs. |