# ByteBufferGlEffect

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/ByteBufferGlEffect.java+class:androidx.media3.effect.ByteBufferGlEffect)

*** ** * ** ***


```
@UnstableApi
public class ByteBufferGlEffect<T> implements GlEffect
```

<br />

*** ** * ** ***

A `https://developer.android.com/reference/androidx/media3/effect/GlEffect` implementation that runs an asynchronous `https://developer.android.com/reference/androidx/media3/effect/ByteBufferGlEffect.Processor` on video frame data passed in as a `https://developer.android.com/reference/androidx/media3/effect/ByteBufferGlEffect.Image`.

This effect can be used to apply CPU-based effects. Or the provided `https://developer.android.com/reference/androidx/media3/effect/ByteBufferGlEffect.Image` can be passed to other heterogeneous compute components that are available such as another GPU context, FPGAs, or NPUs.

## Summary

| ### Nested types |
|---|
| `public class https://developer.android.com/reference/androidx/media3/effect/ByteBufferGlEffect.Image` A class that represents image data is backed by a `https://developer.android.com/reference/java/nio/ByteBuffer.html`. |
| `public interface https://developer.android.com/reference/androidx/media3/effect/ByteBufferGlEffect.Processor<T>` A processor that takes in `https://developer.android.com/reference/java/nio/ByteBuffer.html` that represent input image data, and produces results of type `<T>`. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/effect/ByteBufferGlEffect#ByteBufferGlEffect(androidx.media3.effect.ByteBufferGlEffect.Processor<T>)(https://developer.android.com/reference/androidx/media3/effect/ByteBufferGlEffect.Processor<T> processor)` Creates an instance. |

| ### Public methods |
|---|---|
| `https://developer.android.com/reference/androidx/media3/effect/GlShaderProgram` | `https://developer.android.com/reference/androidx/media3/effect/ByteBufferGlEffect#toGlShaderProgram(android.content.Context,boolean)(https://developer.android.com/reference/android/content/Context.html context, boolean useHdr)` Returns a `https://developer.android.com/reference/androidx/media3/effect/GlShaderProgram` that applies the effect. |

| ### Inherited methods |
|---|
| From [androidx.media3.common.Effect](https://developer.android.com/reference/androidx/media3/common/Effect) |---|---| | `long` | `https://developer.android.com/reference/androidx/media3/common/Effect#getDurationAfterEffectApplied(long)(long durationUs)` Returns the expected duration of the output stream when the effect is applied given a input `durationUs`. | |
| From [androidx.media3.effect.GlEffect](https://developer.android.com/reference/androidx/media3/effect/GlEffect) |---|---| | `boolean` | `https://developer.android.com/reference/androidx/media3/effect/GlEffect#isNoOp(int,int)(int inputWidth, int inputHeight)` Returns whether a `https://developer.android.com/reference/androidx/media3/effect/GlEffect` applies no change at every timestamp. | |

## Public constructors

### ByteBufferGlEffect

```
public ByteBufferGlEffect(ByteBufferGlEffect.Processor<T> processor)
```

Creates an instance.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/effect/ByteBufferGlEffect.Processor<T> processor` | The effect to apply. |

## Public methods

### toGlShaderProgram

```
public GlShaderProgram toGlShaderProgram(Context context, boolean useHdr)
```

Returns a `https://developer.android.com/reference/androidx/media3/effect/GlShaderProgram` that applies the effect.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/content/Context.html context` | A `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. |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/VideoFrameProcessingException` | If an error occurs while creating the `https://developer.android.com/reference/androidx/media3/effect/GlShaderProgram`. |