@UnstableApi
public final class RgbFilter implements RgbMatrix


Provides common color filters.

This effect assumes a linear working color space.

Summary

Public methods

static RgbFilter

Creates a new grayscale RgbFilter instance.

static RgbFilter

Creates a new inverted RgbFilter instance.

float[]
getMatrix(long presentationTimeUs, boolean useHdr)

Returns the 4x4 RGB transformation matrix to apply to the color values of each pixel in the frame with the given timestamp.

BaseGlShaderProgram
toGlShaderProgram(Context context, boolean useHdr)

Returns a GlShaderProgram that applies the effect.

Inherited methods

From androidx.media3.common.Effect
long

Returns the expected duration of the output stream when the effect is applied given a input durationUs.

From androidx.media3.effect.GlEffect
boolean
isNoOp(int inputWidth, int inputHeight)

Returns whether a GlEffect applies no change at every timestamp.

abstract GlShaderProgram
toGlShaderProgram(Context context, boolean useHdr)

Returns a GlShaderProgram that applies the effect.

Public methods

createGrayscaleFilter

public static RgbFilter createGrayscaleFilter()

Creates a new grayscale RgbFilter instance.

createInvertedFilter

public static RgbFilter createInvertedFilter()

Creates a new inverted RgbFilter instance.

getMatrix

public float[] getMatrix(long presentationTimeUs, boolean useHdr)

Returns the 4x4 RGB transformation matrix to apply to the color values of each pixel in the frame with the given timestamp.

Parameters
long presentationTimeUs

The timestamp of the frame to apply the matrix on.

boolean useHdr

If true, colors will be in linear RGB BT.2020. If false, colors will be in linear RGB BT.709. Must be consistent with useHdr in toGlShaderProgram.

Returns
float[]

The RgbMatrix to apply to the frame.

toGlShaderProgram

public BaseGlShaderProgram toGlShaderProgram(Context context, boolean useHdr)

Returns a GlShaderProgram that applies the effect.

Parameters
Context context

A Context.

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
androidx.media3.common.VideoFrameProcessingException

If an error occurs while creating the .