public interface

MatrixTransformation

implements GlMatrixTransformation

 androidx.media3.effect.MatrixTransformation

Subclasses:

Crop, Presentation, ScaleAndRotateTransformation

Gradle dependencies

compile group: 'androidx.media3', name: 'media3-effect', version: '1.5.0-alpha01'

  • groupId: androidx.media3
  • artifactId: media3-effect
  • version: 1.5.0-alpha01

Artifact androidx.media3:media3-effect:1.5.0-alpha01 it located at Google repository (https://maven.google.com/)

Overview

Specifies a 3x3 transformation to apply in the vertex shader for each frame.

The matrix is applied to points given in normalized device coordinates (-1 to 1 on x and y axes). Transformed pixels that are moved outside of the normal device coordinate range are clipped.

Output frame pixels outside of the transformed input frame will be black, with alpha = 0 if applicable.

Summary

Methods
public float[]getGlMatrixArray(long presentationTimeUs)

public MatrixgetMatrix(long presentationTimeUs)

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

Methods

public Matrix getMatrix(long presentationTimeUs)

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

public float[] getGlMatrixArray(long presentationTimeUs)

Source

/*
 * Copyright 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package androidx.media3.effect;

import android.graphics.Matrix;
import androidx.media3.common.util.UnstableApi;

/**
 * Specifies a 3x3 transformation {@link Matrix} to apply in the vertex shader for each frame.
 *
 * <p>The matrix is applied to points given in normalized device coordinates (-1 to 1 on x and y
 * axes). Transformed pixels that are moved outside of the normal device coordinate range are
 * clipped.
 *
 * <p>Output frame pixels outside of the transformed input frame will be black, with alpha = 0 if
 * applicable.
 */
@UnstableApi
public interface MatrixTransformation extends GlMatrixTransformation {
  /**
   * Returns the 3x3 transformation {@link Matrix} to apply to the frame with the given timestamp.
   */
  Matrix getMatrix(long presentationTimeUs);

  @Override
  default float[] getGlMatrixArray(long presentationTimeUs) {
    return MatrixUtils.getGlMatrixArray(getMatrix(presentationTimeUs));
  }
}