ScaleAndRotateTransformation


@UnstableApi
public final class ScaleAndRotateTransformation implements MatrixTransformation


Specifies a simple rotation and/or scale to apply in the vertex shader.

All input frames' pixels will be preserved and copied into an output frame, potentially changing the width and height of the frame by scaling dimensions to fit.

The background color of the output frame will be black, with alpha = 0 if applicable.

Summary

Nested types

A builder for ScaleAndRotateTransformation instances.

Public fields

final float

The counterclockwise rotation, in degrees.

final float

The multiplier by which the frame will scale horizontally, along the x-axis.

final float

The multiplier by which the frame will scale vertically, along the y-axis.

Public methods

Size
configure(int inputWidth, int inputHeight)

Configures the input and output dimensions.

Matrix
getMatrix(long presentationTimeUs)

Returns the 3x3 transformation Matrix to apply to the frame with the given timestamp.

boolean
isNoOp(int inputWidth, int inputHeight)

Returns whether a GlEffect applies no change at every timestamp.

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
abstract GlShaderProgram
toGlShaderProgram(Context context, boolean useHdr)

Returns a GlShaderProgram that applies the effect.

From androidx.media3.effect.GlMatrixTransformation
BaseGlShaderProgram
toGlShaderProgram(Context context, boolean useHdr)

Returns a GlShaderProgram that applies the effect.

From androidx.media3.effect.MatrixTransformation
float[]
getGlMatrixArray(long presentationTimeUs)

Returns the 4x4 transformation Matrix to apply to the frame with the given timestamp.

Public fields

rotationDegrees

public final float rotationDegrees

The counterclockwise rotation, in degrees. The value should always be between 0 (included) and 360 degrees (excluded).

scaleX

public final float scaleX

The multiplier by which the frame will scale horizontally, along the x-axis.

scaleY

public final float scaleY

The multiplier by which the frame will scale vertically, along the y-axis.

Public methods

configure

public Size configure(int inputWidth, int inputHeight)

Configures the input and output dimensions.

Must be called before getGlMatrixArray.

Parameters
int inputWidth

The input frame width, in pixels.

int inputHeight

The input frame height, in pixels.

Returns
Size

The output frame width and height, in pixels.

getMatrix

public Matrix getMatrix(long presentationTimeUs)

Returns the 3x3 transformation Matrix to apply to the frame with the given timestamp.

isNoOp

public boolean isNoOp(int inputWidth, int inputHeight)

Returns whether a GlEffect applies no change at every timestamp.

This can be used as a hint to skip this instance.

Parameters
int inputWidth

The input frame width, in pixels.

int inputHeight

The input frame height, in pixels.