Replace Pair with Size in effects.
PiperOrigin-RevId: 495646341
This commit is contained in:
parent
22dfd4cb32
commit
6376f5f7c7
@ -28,11 +28,11 @@ import android.graphics.Paint;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.opengl.GLES20;
|
||||
import android.opengl.GLUtils;
|
||||
import android.util.Pair;
|
||||
import androidx.media3.common.C;
|
||||
import androidx.media3.common.FrameProcessingException;
|
||||
import androidx.media3.common.util.GlProgram;
|
||||
import androidx.media3.common.util.GlUtil;
|
||||
import androidx.media3.common.util.Size;
|
||||
import androidx.media3.effect.SingleFrameGlTextureProcessor;
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
@ -111,7 +111,7 @@ import java.util.Locale;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Integer, Integer> configure(int inputWidth, int inputHeight) {
|
||||
public Size configure(int inputWidth, int inputHeight) {
|
||||
if (inputWidth > inputHeight) {
|
||||
bitmapScaleX = inputWidth / (float) inputHeight;
|
||||
bitmapScaleY = 1f;
|
||||
@ -123,7 +123,7 @@ import java.util.Locale;
|
||||
glProgram.setFloatUniform("uScaleX", bitmapScaleX);
|
||||
glProgram.setFloatUniform("uScaleY", bitmapScaleY);
|
||||
|
||||
return Pair.create(inputWidth, inputHeight);
|
||||
return new Size(inputWidth, inputHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,10 +19,10 @@ import static androidx.media3.common.util.Assertions.checkArgument;
|
||||
|
||||
import android.content.Context;
|
||||
import android.opengl.GLES20;
|
||||
import android.util.Pair;
|
||||
import androidx.media3.common.FrameProcessingException;
|
||||
import androidx.media3.common.util.GlProgram;
|
||||
import androidx.media3.common.util.GlUtil;
|
||||
import androidx.media3.common.util.Size;
|
||||
import androidx.media3.effect.SingleFrameGlTextureProcessor;
|
||||
import java.io.IOException;
|
||||
|
||||
@ -90,8 +90,8 @@ import java.io.IOException;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Integer, Integer> configure(int inputWidth, int inputHeight) {
|
||||
return Pair.create(inputWidth, inputHeight);
|
||||
public Size configure(int inputWidth, int inputHeight) {
|
||||
return new Size(inputWidth, inputHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -33,9 +33,9 @@ import android.graphics.Color;
|
||||
import android.opengl.EGLContext;
|
||||
import android.opengl.EGLDisplay;
|
||||
import android.opengl.EGLSurface;
|
||||
import android.util.Pair;
|
||||
import androidx.media3.common.FrameProcessingException;
|
||||
import androidx.media3.common.util.GlUtil;
|
||||
import androidx.media3.common.util.Size;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
import org.junit.After;
|
||||
@ -100,13 +100,13 @@ public class ContrastPixelTest {
|
||||
String testId = "drawFrame_noContrastChange";
|
||||
contrastProcessor =
|
||||
new Contrast(/* contrast= */ 0.0f).toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = contrastProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.first, outputSize.second);
|
||||
Size outputSize = contrastProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
|
||||
Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
|
||||
|
||||
contrastProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
@ -119,8 +119,8 @@ public class ContrastPixelTest {
|
||||
String testId = "drawFrame_minimumContrast";
|
||||
contrastProcessor =
|
||||
new Contrast(/* contrast= */ -1.0f).toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = contrastProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.first, outputSize.second);
|
||||
Size outputSize = contrastProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
|
||||
Bitmap expectedBitmap =
|
||||
createArgb8888BitmapWithSolidColor(
|
||||
inputWidth,
|
||||
@ -130,7 +130,7 @@ public class ContrastPixelTest {
|
||||
|
||||
contrastProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
@ -144,13 +144,13 @@ public class ContrastPixelTest {
|
||||
String testId = "drawFrame_decreaseContrast";
|
||||
contrastProcessor =
|
||||
new Contrast(/* contrast= */ -0.75f).toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = contrastProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.first, outputSize.second);
|
||||
Size outputSize = contrastProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
|
||||
Bitmap expectedBitmap = readBitmap(DECREASE_CONTRAST_PNG_ASSET_PATH);
|
||||
|
||||
contrastProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
@ -164,13 +164,13 @@ public class ContrastPixelTest {
|
||||
String testId = "drawFrame_increaseContrast";
|
||||
contrastProcessor =
|
||||
new Contrast(/* contrast= */ 0.75f).toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = contrastProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.first, outputSize.second);
|
||||
Size outputSize = contrastProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
|
||||
Bitmap expectedBitmap = readBitmap(INCREASE_CONTRAST_PNG_ASSET_PATH);
|
||||
|
||||
contrastProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
@ -183,13 +183,13 @@ public class ContrastPixelTest {
|
||||
String testId = "drawFrame_maximumContrast";
|
||||
contrastProcessor =
|
||||
new Contrast(/* contrast= */ 1.0f).toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = contrastProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.first, outputSize.second);
|
||||
Size outputSize = contrastProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
|
||||
Bitmap expectedBitmap = readBitmap(MAXIMUM_CONTRAST_PNG_ASSET_PATH);
|
||||
|
||||
contrastProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
|
@ -30,9 +30,9 @@ import android.graphics.Bitmap;
|
||||
import android.opengl.EGLContext;
|
||||
import android.opengl.EGLDisplay;
|
||||
import android.opengl.EGLSurface;
|
||||
import android.util.Pair;
|
||||
import androidx.media3.common.FrameProcessingException;
|
||||
import androidx.media3.common.util.GlUtil;
|
||||
import androidx.media3.common.util.Size;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import java.io.IOException;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
@ -96,13 +96,13 @@ public final class CropPixelTest {
|
||||
cropTextureProcessor =
|
||||
new Crop(/* left= */ -1, /* right= */ 1, /* bottom= */ -1, /* top= */ 1)
|
||||
.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = cropTextureProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.first, outputSize.second);
|
||||
Size outputSize = cropTextureProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
|
||||
Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
|
||||
|
||||
cropTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
|
||||
@ -117,13 +117,13 @@ public final class CropPixelTest {
|
||||
cropTextureProcessor =
|
||||
new Crop(/* left= */ -.9f, /* right= */ .1f, /* bottom= */ -1f, /* top= */ .5f)
|
||||
.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = cropTextureProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.first, outputSize.second);
|
||||
Size outputSize = cropTextureProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
|
||||
Bitmap expectedBitmap = readBitmap(CROP_SMALLER_PNG_ASSET_PATH);
|
||||
|
||||
cropTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
|
||||
@ -138,13 +138,13 @@ public final class CropPixelTest {
|
||||
cropTextureProcessor =
|
||||
new Crop(/* left= */ -2f, /* right= */ 2f, /* bottom= */ -1f, /* top= */ 2f)
|
||||
.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = cropTextureProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.first, outputSize.second);
|
||||
Size outputSize = cropTextureProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
|
||||
Bitmap expectedBitmap = readBitmap(CROP_LARGER_PNG_ASSET_PATH);
|
||||
|
||||
cropTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
|
||||
|
@ -33,7 +33,6 @@ import android.graphics.PixelFormat;
|
||||
import android.media.Image;
|
||||
import android.media.ImageReader;
|
||||
import android.media.MediaFormat;
|
||||
import android.util.Pair;
|
||||
import androidx.media3.common.C;
|
||||
import androidx.media3.common.ColorInfo;
|
||||
import androidx.media3.common.DebugViewProvider;
|
||||
@ -42,6 +41,7 @@ import androidx.media3.common.FrameInfo;
|
||||
import androidx.media3.common.FrameProcessingException;
|
||||
import androidx.media3.common.FrameProcessor;
|
||||
import androidx.media3.common.SurfaceInfo;
|
||||
import androidx.media3.common.util.Size;
|
||||
import androidx.media3.test.utils.DecodeOneFrameUtil;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@ -547,14 +547,14 @@ public final class GlEffectsFrameProcessorPixelTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Integer, Integer> configure(int inputWidth, int inputHeight) {
|
||||
public Size configure(int inputWidth, int inputHeight) {
|
||||
adjustedTransformationMatrix = new Matrix();
|
||||
adjustedTransformationMatrix.postRotate(degrees);
|
||||
float inputAspectRatio = (float) inputWidth / inputHeight;
|
||||
adjustedTransformationMatrix.preScale(/* sx= */ inputAspectRatio, /* sy= */ 1f);
|
||||
adjustedTransformationMatrix.postScale(/* sx= */ 1f / inputAspectRatio, /* sy= */ 1f);
|
||||
|
||||
return Pair.create(inputWidth, inputHeight);
|
||||
return new Size(inputWidth, inputHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -32,9 +32,9 @@ import android.graphics.Color;
|
||||
import android.opengl.EGLContext;
|
||||
import android.opengl.EGLDisplay;
|
||||
import android.opengl.EGLSurface;
|
||||
import android.util.Pair;
|
||||
import androidx.media3.common.FrameProcessingException;
|
||||
import androidx.media3.common.util.GlUtil;
|
||||
import androidx.media3.common.util.Size;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import java.io.IOException;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
@ -111,12 +111,12 @@ public final class HslAdjustmentPixelTest {
|
||||
String testId = "drawFrame_noOpAdjustment";
|
||||
HslAdjustment noOpAdjustment = new HslAdjustment.Builder().build();
|
||||
hslProcessor = noOpAdjustment.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = hslProcessor.configure(inputWidth, inputHeight);
|
||||
Size outputSize = hslProcessor.configure(inputWidth, inputHeight);
|
||||
Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
|
||||
|
||||
hslProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
@ -129,12 +129,12 @@ public final class HslAdjustmentPixelTest {
|
||||
String testId = "drawFrame_minimumSaturation";
|
||||
HslAdjustment minimumSaturation = new HslAdjustment.Builder().adjustSaturation(-100).build();
|
||||
hslProcessor = minimumSaturation.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = hslProcessor.configure(inputWidth, inputHeight);
|
||||
Size outputSize = hslProcessor.configure(inputWidth, inputHeight);
|
||||
Bitmap expectedBitmap = readBitmap(MINIMUM_SATURATION_PNG_ASSET_PATH);
|
||||
|
||||
hslProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
@ -147,12 +147,12 @@ public final class HslAdjustmentPixelTest {
|
||||
String testId = "drawFrame_maximumSaturation";
|
||||
HslAdjustment maximumSaturation = new HslAdjustment.Builder().adjustSaturation(100).build();
|
||||
hslProcessor = maximumSaturation.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = hslProcessor.configure(inputWidth, inputHeight);
|
||||
Size outputSize = hslProcessor.configure(inputWidth, inputHeight);
|
||||
Bitmap expectedBitmap = readBitmap(MAXIMUM_SATURATION_PNG_ASSET_PATH);
|
||||
|
||||
hslProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
@ -165,12 +165,12 @@ public final class HslAdjustmentPixelTest {
|
||||
String testId = "drawFrame_rotateHueByNegative90Degrees";
|
||||
HslAdjustment negativeHueRotation90Degrees = new HslAdjustment.Builder().adjustHue(-90).build();
|
||||
hslProcessor = negativeHueRotation90Degrees.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = hslProcessor.configure(inputWidth, inputHeight);
|
||||
Size outputSize = hslProcessor.configure(inputWidth, inputHeight);
|
||||
Bitmap expectedBitmap = readBitmap(ROTATE_HUE_BY_NEGATIVE_90_DEGREES_PNG_ASSET_PATH);
|
||||
|
||||
hslProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
@ -183,12 +183,12 @@ public final class HslAdjustmentPixelTest {
|
||||
String testId = "drawFrame_rotateHueBy60Degrees";
|
||||
HslAdjustment hueRotation60Degrees = new HslAdjustment.Builder().adjustHue(60).build();
|
||||
hslProcessor = hueRotation60Degrees.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = hslProcessor.configure(inputWidth, inputHeight);
|
||||
Size outputSize = hslProcessor.configure(inputWidth, inputHeight);
|
||||
Bitmap expectedBitmap = readBitmap(ROTATE_HUE_BY_60_DEGREES_PNG_ASSET_PATH);
|
||||
|
||||
hslProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
@ -202,12 +202,12 @@ public final class HslAdjustmentPixelTest {
|
||||
String testId = "drawFrame_rotateHueByNegative300Degrees";
|
||||
HslAdjustment hueRotation420Degrees = new HslAdjustment.Builder().adjustHue(-300).build();
|
||||
hslProcessor = hueRotation420Degrees.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = hslProcessor.configure(inputWidth, inputHeight);
|
||||
Size outputSize = hslProcessor.configure(inputWidth, inputHeight);
|
||||
Bitmap expectedBitmap = readBitmap(ROTATE_HUE_BY_60_DEGREES_PNG_ASSET_PATH);
|
||||
|
||||
hslProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
@ -220,12 +220,12 @@ public final class HslAdjustmentPixelTest {
|
||||
String testId = "drawFrame_rotateHueBy360Degrees";
|
||||
HslAdjustment hueRotation360Degrees = new HslAdjustment.Builder().adjustHue(360).build();
|
||||
hslProcessor = hueRotation360Degrees.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = hslProcessor.configure(inputWidth, inputHeight);
|
||||
Size outputSize = hslProcessor.configure(inputWidth, inputHeight);
|
||||
Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
|
||||
|
||||
hslProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
@ -238,13 +238,13 @@ public final class HslAdjustmentPixelTest {
|
||||
String testId = "drawFrame_minimumLightness";
|
||||
HslAdjustment minimumLightness = new HslAdjustment.Builder().adjustLightness(-100).build();
|
||||
hslProcessor = minimumLightness.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = hslProcessor.configure(inputWidth, inputHeight);
|
||||
Size outputSize = hslProcessor.configure(inputWidth, inputHeight);
|
||||
Bitmap expectedBitmap =
|
||||
createArgb8888BitmapWithSolidColor(inputWidth, inputHeight, Color.BLACK);
|
||||
|
||||
hslProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
@ -257,12 +257,12 @@ public final class HslAdjustmentPixelTest {
|
||||
String testId = "drawFrame_decreaseLightness";
|
||||
HslAdjustment decreasedLightness = new HslAdjustment.Builder().adjustLightness(-50).build();
|
||||
hslProcessor = decreasedLightness.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = hslProcessor.configure(inputWidth, inputHeight);
|
||||
Size outputSize = hslProcessor.configure(inputWidth, inputHeight);
|
||||
Bitmap expectedBitmap = readBitmap(DECREASE_LIGHTNESS_PNG_ASSET_PATH);
|
||||
|
||||
hslProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
@ -275,12 +275,12 @@ public final class HslAdjustmentPixelTest {
|
||||
String testId = "drawFrame_increaseLightness";
|
||||
HslAdjustment increasedLightness = new HslAdjustment.Builder().adjustLightness(50).build();
|
||||
hslProcessor = increasedLightness.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = hslProcessor.configure(inputWidth, inputHeight);
|
||||
Size outputSize = hslProcessor.configure(inputWidth, inputHeight);
|
||||
Bitmap expectedBitmap = readBitmap(INCREASE_LIGHTNESS_PNG_ASSET_PATH);
|
||||
|
||||
hslProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
@ -293,13 +293,13 @@ public final class HslAdjustmentPixelTest {
|
||||
String testId = "drawFrame_maximumLightness";
|
||||
HslAdjustment maximumLightness = new HslAdjustment.Builder().adjustLightness(100).build();
|
||||
hslProcessor = maximumLightness.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = hslProcessor.configure(inputWidth, inputHeight);
|
||||
Size outputSize = hslProcessor.configure(inputWidth, inputHeight);
|
||||
Bitmap expectedBitmap =
|
||||
createArgb8888BitmapWithSolidColor(inputWidth, inputHeight, Color.WHITE);
|
||||
|
||||
hslProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
@ -313,12 +313,12 @@ public final class HslAdjustmentPixelTest {
|
||||
HslAdjustment allHslSettingsAdjusted =
|
||||
new HslAdjustment.Builder().adjustHue(60).adjustSaturation(30).adjustLightness(50).build();
|
||||
hslProcessor = allHslSettingsAdjusted.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = hslProcessor.configure(inputWidth, inputHeight);
|
||||
Size outputSize = hslProcessor.configure(inputWidth, inputHeight);
|
||||
Bitmap expectedBitmap = readBitmap(ADJUST_ALL_HSL_SETTINGS_PNG_ASSET_PATH);
|
||||
|
||||
hslProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
|
@ -35,9 +35,9 @@ import android.opengl.Matrix;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.util.Pair;
|
||||
import androidx.media3.common.FrameProcessingException;
|
||||
import androidx.media3.common.util.GlUtil;
|
||||
import androidx.media3.common.util.Size;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import java.io.IOException;
|
||||
@ -107,13 +107,13 @@ public class OverlayTextureProcessorPixelTest {
|
||||
overlayTextureProcessor =
|
||||
new OverlayEffect(/* textureOverlays= */ ImmutableList.of())
|
||||
.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = overlayTextureProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.first, outputSize.second);
|
||||
Size outputSize = overlayTextureProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
|
||||
Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
|
||||
|
||||
overlayTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
@ -129,13 +129,13 @@ public class OverlayTextureProcessorPixelTest {
|
||||
overlayTextureProcessor =
|
||||
new OverlayEffect(ImmutableList.of(scaledBitmapOverlay))
|
||||
.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = overlayTextureProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.first, outputSize.second);
|
||||
Size outputSize = overlayTextureProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
|
||||
Bitmap expectedBitmap = readBitmap(OVERLAY_BITMAP_DEFAULT);
|
||||
|
||||
overlayTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
@ -155,13 +155,13 @@ public class OverlayTextureProcessorPixelTest {
|
||||
overlayTextureProcessor =
|
||||
new OverlayEffect(ImmutableList.of(staticBitmapOverlay))
|
||||
.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = overlayTextureProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.first, outputSize.second);
|
||||
Size outputSize = overlayTextureProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
|
||||
Bitmap expectedBitmap = readBitmap(OVERLAY_BITMAP_SCALED);
|
||||
|
||||
overlayTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
@ -179,13 +179,13 @@ public class OverlayTextureProcessorPixelTest {
|
||||
overlayTextureProcessor =
|
||||
new OverlayEffect(ImmutableList.of(translucentBitmapOverlay))
|
||||
.toGlTextureProcessor(context, false);
|
||||
Pair<Integer, Integer> outputSize = overlayTextureProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.first, outputSize.second);
|
||||
Size outputSize = overlayTextureProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
|
||||
Bitmap expectedBitmap = readBitmap(OVERLAY_BITMAP_TRANSLUCENT);
|
||||
|
||||
overlayTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
@ -208,13 +208,13 @@ public class OverlayTextureProcessorPixelTest {
|
||||
overlayTextureProcessor =
|
||||
new OverlayEffect(ImmutableList.of(staticTextOverlay))
|
||||
.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = overlayTextureProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.first, outputSize.second);
|
||||
Size outputSize = overlayTextureProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
|
||||
Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
|
||||
|
||||
overlayTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
@ -235,13 +235,13 @@ public class OverlayTextureProcessorPixelTest {
|
||||
overlayTextureProcessor =
|
||||
new OverlayEffect(ImmutableList.of(staticTextOverlay))
|
||||
.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = overlayTextureProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.first, outputSize.second);
|
||||
Size outputSize = overlayTextureProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
|
||||
Bitmap expectedBitmap = readBitmap(OVERLAY_TEXT_DEFAULT);
|
||||
|
||||
overlayTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
@ -267,13 +267,13 @@ public class OverlayTextureProcessorPixelTest {
|
||||
overlayTextureProcessor =
|
||||
new OverlayEffect(ImmutableList.of(staticTextOverlay))
|
||||
.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = overlayTextureProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.first, outputSize.second);
|
||||
Size outputSize = overlayTextureProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
|
||||
Bitmap expectedBitmap = readBitmap(OVERLAY_TEXT_TRANSLATE);
|
||||
|
||||
overlayTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
|
@ -30,10 +30,10 @@ import android.graphics.Bitmap;
|
||||
import android.opengl.EGLContext;
|
||||
import android.opengl.EGLDisplay;
|
||||
import android.opengl.EGLSurface;
|
||||
import android.util.Pair;
|
||||
import androidx.media3.common.C;
|
||||
import androidx.media3.common.FrameProcessingException;
|
||||
import androidx.media3.common.util.GlUtil;
|
||||
import androidx.media3.common.util.Size;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import java.io.IOException;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
@ -105,14 +105,13 @@ public final class PresentationPixelTest {
|
||||
presentationTextureProcessor =
|
||||
Presentation.createForHeight(C.LENGTH_UNSET)
|
||||
.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize =
|
||||
presentationTextureProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.first, outputSize.second);
|
||||
Size outputSize = presentationTextureProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
|
||||
Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
|
||||
|
||||
presentationTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
|
||||
@ -128,14 +127,13 @@ public final class PresentationPixelTest {
|
||||
presentationTextureProcessor =
|
||||
Presentation.createForAspectRatio(/* aspectRatio= */ 1f, Presentation.LAYOUT_SCALE_TO_FIT)
|
||||
.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize =
|
||||
presentationTextureProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.first, outputSize.second);
|
||||
Size outputSize = presentationTextureProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
|
||||
Bitmap expectedBitmap = readBitmap(ASPECT_RATIO_SCALE_TO_FIT_NARROW_PNG_ASSET_PATH);
|
||||
|
||||
presentationTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
|
||||
@ -151,14 +149,13 @@ public final class PresentationPixelTest {
|
||||
presentationTextureProcessor =
|
||||
Presentation.createForAspectRatio(/* aspectRatio= */ 2f, Presentation.LAYOUT_SCALE_TO_FIT)
|
||||
.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize =
|
||||
presentationTextureProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.first, outputSize.second);
|
||||
Size outputSize = presentationTextureProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
|
||||
Bitmap expectedBitmap = readBitmap(ASPECT_RATIO_SCALE_TO_FIT_WIDE_PNG_ASSET_PATH);
|
||||
|
||||
presentationTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
|
||||
@ -175,14 +172,13 @@ public final class PresentationPixelTest {
|
||||
Presentation.createForAspectRatio(
|
||||
/* aspectRatio= */ 1f, Presentation.LAYOUT_SCALE_TO_FIT_WITH_CROP)
|
||||
.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize =
|
||||
presentationTextureProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.first, outputSize.second);
|
||||
Size outputSize = presentationTextureProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
|
||||
Bitmap expectedBitmap = readBitmap(ASPECT_RATIO_SCALE_TO_FIT_WITH_CROP_NARROW_PNG_ASSET_PATH);
|
||||
|
||||
presentationTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
|
||||
@ -199,14 +195,13 @@ public final class PresentationPixelTest {
|
||||
Presentation.createForAspectRatio(
|
||||
/* aspectRatio= */ 2f, Presentation.LAYOUT_SCALE_TO_FIT_WITH_CROP)
|
||||
.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize =
|
||||
presentationTextureProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.first, outputSize.second);
|
||||
Size outputSize = presentationTextureProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
|
||||
Bitmap expectedBitmap = readBitmap(ASPECT_RATIO_SCALE_TO_FIT_WITH_CROP_WIDE_PNG_ASSET_PATH);
|
||||
|
||||
presentationTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
|
||||
@ -222,14 +217,13 @@ public final class PresentationPixelTest {
|
||||
presentationTextureProcessor =
|
||||
Presentation.createForAspectRatio(/* aspectRatio= */ 1f, Presentation.LAYOUT_STRETCH_TO_FIT)
|
||||
.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize =
|
||||
presentationTextureProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.first, outputSize.second);
|
||||
Size outputSize = presentationTextureProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
|
||||
Bitmap expectedBitmap = readBitmap(ASPECT_RATIO_STRETCH_TO_FIT_NARROW_PNG_ASSET_PATH);
|
||||
|
||||
presentationTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
|
||||
@ -245,14 +239,13 @@ public final class PresentationPixelTest {
|
||||
presentationTextureProcessor =
|
||||
Presentation.createForAspectRatio(/* aspectRatio= */ 2f, Presentation.LAYOUT_STRETCH_TO_FIT)
|
||||
.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize =
|
||||
presentationTextureProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.first, outputSize.second);
|
||||
Size outputSize = presentationTextureProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
|
||||
Bitmap expectedBitmap = readBitmap(ASPECT_RATIO_STRETCH_TO_FIT_WIDE_PNG_ASSET_PATH);
|
||||
|
||||
presentationTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
|
||||
|
@ -33,9 +33,9 @@ import android.graphics.Color;
|
||||
import android.opengl.EGLContext;
|
||||
import android.opengl.EGLDisplay;
|
||||
import android.opengl.EGLSurface;
|
||||
import android.util.Pair;
|
||||
import androidx.media3.common.FrameProcessingException;
|
||||
import androidx.media3.common.util.GlUtil;
|
||||
import androidx.media3.common.util.Size;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import java.io.IOException;
|
||||
@ -110,12 +110,12 @@ public final class RgbAdjustmentPixelTest {
|
||||
String testId = "drawFrame_identityMatrix";
|
||||
RgbMatrix identityMatrix = new RgbAdjustment.Builder().build();
|
||||
matrixTextureProcessor = identityMatrix.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight);
|
||||
Size outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight);
|
||||
Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
|
||||
|
||||
matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
@ -129,13 +129,14 @@ public final class RgbAdjustmentPixelTest {
|
||||
RgbMatrix removeColorMatrix =
|
||||
new RgbAdjustment.Builder().setRedScale(0).setGreenScale(0).setBlueScale(0).build();
|
||||
matrixTextureProcessor = removeColorMatrix.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight);
|
||||
Size outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight);
|
||||
Bitmap expectedBitmap =
|
||||
createArgb8888BitmapWithSolidColor(outputSize.first, outputSize.second, Color.BLACK);
|
||||
createArgb8888BitmapWithSolidColor(
|
||||
outputSize.getWidth(), outputSize.getHeight(), Color.BLACK);
|
||||
|
||||
matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
@ -148,12 +149,12 @@ public final class RgbAdjustmentPixelTest {
|
||||
String testId = "drawFrame_redOnlyFilter";
|
||||
RgbMatrix redOnlyMatrix = new RgbAdjustment.Builder().setBlueScale(0).setGreenScale(0).build();
|
||||
matrixTextureProcessor = redOnlyMatrix.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight);
|
||||
Size outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight);
|
||||
Bitmap expectedBitmap = readBitmap(ONLY_RED_CHANNEL_PNG_ASSET_PATH);
|
||||
|
||||
matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
@ -166,12 +167,12 @@ public final class RgbAdjustmentPixelTest {
|
||||
String testId = "drawFrame_increaseRedChannel";
|
||||
RgbMatrix increaseRedMatrix = new RgbAdjustment.Builder().setRedScale(5).build();
|
||||
matrixTextureProcessor = increaseRedMatrix.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight);
|
||||
Size outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight);
|
||||
Bitmap expectedBitmap = readBitmap(INCREASE_RED_CHANNEL_PNG_ASSET_PATH);
|
||||
|
||||
matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
@ -186,12 +187,12 @@ public final class RgbAdjustmentPixelTest {
|
||||
new RgbAdjustment.Builder().setRedScale(5).setGreenScale(5).setBlueScale(5).build();
|
||||
matrixTextureProcessor =
|
||||
increaseBrightnessMatrix.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight);
|
||||
Size outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight);
|
||||
Bitmap expectedBitmap = readBitmap(INCREASE_BRIGHTNESS_PNG_ASSET_PATH);
|
||||
|
||||
matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
@ -211,13 +212,14 @@ public final class RgbAdjustmentPixelTest {
|
||||
/* matrixTransformations= */ ImmutableList.of(),
|
||||
/* rgbMatrices= */ ImmutableList.of(noRed, noGreen, noBlue),
|
||||
/* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight);
|
||||
Size outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight);
|
||||
Bitmap expectedBitmap =
|
||||
createArgb8888BitmapWithSolidColor(outputSize.first, outputSize.second, Color.BLACK);
|
||||
createArgb8888BitmapWithSolidColor(
|
||||
outputSize.getWidth(), outputSize.getHeight(), Color.BLACK);
|
||||
|
||||
matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
@ -236,12 +238,12 @@ public final class RgbAdjustmentPixelTest {
|
||||
/* matrixTransformations= */ ImmutableList.of(),
|
||||
/* rgbMatrices= */ ImmutableList.of(noGreen, noBlue),
|
||||
/* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight);
|
||||
Size outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight);
|
||||
Bitmap expectedBitmap = readBitmap(ONLY_RED_CHANNEL_PNG_ASSET_PATH);
|
||||
|
||||
matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
@ -262,12 +264,12 @@ public final class RgbAdjustmentPixelTest {
|
||||
/* matrixTransformations= */ ImmutableList.of(),
|
||||
/* rgbMatrices= */ ImmutableList.of(scaleRedMatrix, scaleRedByInverseMatrix),
|
||||
/* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight);
|
||||
Size outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight);
|
||||
Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
|
||||
|
||||
matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
|
@ -31,9 +31,9 @@ import android.graphics.Bitmap;
|
||||
import android.opengl.EGLContext;
|
||||
import android.opengl.EGLDisplay;
|
||||
import android.opengl.EGLSurface;
|
||||
import android.util.Pair;
|
||||
import androidx.media3.common.FrameProcessingException;
|
||||
import androidx.media3.common.util.GlUtil;
|
||||
import androidx.media3.common.util.Size;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import java.io.IOException;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
@ -105,12 +105,12 @@ public final class RgbFilterPixelTest {
|
||||
String testId = "drawFrame_grayscale";
|
||||
RgbMatrix grayscaleMatrix = RgbFilter.createGrayscaleFilter();
|
||||
matrixTextureProcessor = grayscaleMatrix.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight);
|
||||
Size outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight);
|
||||
Bitmap expectedBitmap = readBitmap(GRAYSCALE_PNG_ASSET_PATH);
|
||||
|
||||
matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
@ -123,12 +123,12 @@ public final class RgbFilterPixelTest {
|
||||
String testId = "drawFrame_inverted";
|
||||
RgbMatrix invertedMatrix = RgbFilter.createInvertedFilter();
|
||||
matrixTextureProcessor = invertedMatrix.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight);
|
||||
Size outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight);
|
||||
Bitmap expectedBitmap = readBitmap(INVERT_PNG_ASSET_PATH);
|
||||
|
||||
matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
|
@ -32,9 +32,9 @@ import android.graphics.Color;
|
||||
import android.opengl.EGLContext;
|
||||
import android.opengl.EGLDisplay;
|
||||
import android.opengl.EGLSurface;
|
||||
import android.util.Pair;
|
||||
import androidx.media3.common.FrameProcessingException;
|
||||
import androidx.media3.common.util.GlUtil;
|
||||
import androidx.media3.common.util.Size;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
import org.junit.After;
|
||||
@ -101,13 +101,13 @@ public class SingleColorLutPixelTest {
|
||||
colorLutProcessor =
|
||||
SingleColorLut.createFromCube(cubeIdentityLut)
|
||||
.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = colorLutProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.first, outputSize.second);
|
||||
Size outputSize = colorLutProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
|
||||
Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
|
||||
|
||||
colorLutProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
@ -122,13 +122,13 @@ public class SingleColorLutPixelTest {
|
||||
colorLutProcessor =
|
||||
SingleColorLut.createFromCube(cubeIdentityLut)
|
||||
.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = colorLutProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.first, outputSize.second);
|
||||
Size outputSize = colorLutProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
|
||||
Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
|
||||
|
||||
colorLutProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
@ -143,13 +143,13 @@ public class SingleColorLutPixelTest {
|
||||
colorLutProcessor =
|
||||
SingleColorLut.createFromBitmap(bitmapLut)
|
||||
.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = colorLutProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.first, outputSize.second);
|
||||
Size outputSize = colorLutProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
|
||||
Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
|
||||
|
||||
colorLutProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
@ -164,13 +164,13 @@ public class SingleColorLutPixelTest {
|
||||
colorLutProcessor =
|
||||
SingleColorLut.createFromBitmap(bitmapLut)
|
||||
.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = colorLutProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.first, outputSize.second);
|
||||
Size outputSize = colorLutProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
|
||||
Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
|
||||
|
||||
colorLutProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
@ -185,13 +185,13 @@ public class SingleColorLutPixelTest {
|
||||
colorLutProcessor =
|
||||
SingleColorLut.createFromBitmap(bitmapLut)
|
||||
.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = colorLutProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.first, outputSize.second);
|
||||
Size outputSize = colorLutProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
|
||||
Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
|
||||
|
||||
colorLutProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
@ -208,13 +208,13 @@ public class SingleColorLutPixelTest {
|
||||
colorLutProcessor =
|
||||
SingleColorLut.createFromCube(mapWhiteToGreen)
|
||||
.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = colorLutProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.first, outputSize.second);
|
||||
Size outputSize = colorLutProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
|
||||
Bitmap expectedBitmap = readBitmap(LUT_MAP_WHITE_TO_GREEN_ASSET_PATH);
|
||||
|
||||
colorLutProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
@ -229,13 +229,13 @@ public class SingleColorLutPixelTest {
|
||||
colorLutProcessor =
|
||||
SingleColorLut.createFromBitmap(invertedLutBitmap)
|
||||
.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = colorLutProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.first, outputSize.second);
|
||||
Size outputSize = colorLutProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
|
||||
Bitmap expectedBitmap = readBitmap(INVERT_PNG_ASSET_PATH);
|
||||
|
||||
colorLutProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
@ -250,13 +250,13 @@ public class SingleColorLutPixelTest {
|
||||
colorLutProcessor =
|
||||
SingleColorLut.createFromBitmap(grayscaleLutBitmap)
|
||||
.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||
Pair<Integer, Integer> outputSize = colorLutProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.first, outputSize.second);
|
||||
Size outputSize = colorLutProcessor.configure(inputWidth, inputHeight);
|
||||
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
|
||||
Bitmap expectedBitmap = readBitmap(GRAYSCALE_PNG_ASSET_PATH);
|
||||
|
||||
colorLutProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||
Bitmap actualBitmap =
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, "actual", actualBitmap);
|
||||
float averagePixelAbsoluteDifference =
|
||||
|
@ -21,9 +21,9 @@ import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.opengl.GLES20;
|
||||
import android.opengl.GLUtils;
|
||||
import android.util.Pair;
|
||||
import androidx.media3.common.FrameProcessingException;
|
||||
import androidx.media3.common.util.GlUtil;
|
||||
import androidx.media3.common.util.Size;
|
||||
import androidx.media3.common.util.UnstableApi;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
@ -55,8 +55,8 @@ public abstract class BitmapOverlay extends TextureOverlay {
|
||||
* @param presentationTimeUs The presentation timestamp of the current frame, in microseconds.
|
||||
*/
|
||||
@Override
|
||||
public Pair<Integer, Integer> getTextureSize(long presentationTimeUs) {
|
||||
return Pair.create(checkNotNull(lastBitmap).getWidth(), checkNotNull(lastBitmap).getHeight());
|
||||
public Size getTextureSize(long presentationTimeUs) {
|
||||
return new Size(checkNotNull(lastBitmap).getWidth(), checkNotNull(lastBitmap).getHeight());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -20,10 +20,10 @@ import static androidx.media3.common.util.Assertions.checkArgument;
|
||||
|
||||
import android.content.Context;
|
||||
import android.opengl.GLES20;
|
||||
import android.util.Pair;
|
||||
import androidx.media3.common.FrameProcessingException;
|
||||
import androidx.media3.common.util.GlProgram;
|
||||
import androidx.media3.common.util.GlUtil;
|
||||
import androidx.media3.common.util.Size;
|
||||
import java.io.IOException;
|
||||
|
||||
/** Applies a {@link ColorLut} to each frame in the fragment shader. */
|
||||
@ -68,8 +68,8 @@ import java.io.IOException;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Integer, Integer> configure(int inputWidth, int inputHeight) {
|
||||
return Pair.create(inputWidth, inputHeight);
|
||||
public Size configure(int inputWidth, int inputHeight) {
|
||||
return new Size(inputWidth, inputHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -18,10 +18,10 @@ package androidx.media3.effect;
|
||||
|
||||
import android.content.Context;
|
||||
import android.opengl.GLES20;
|
||||
import android.util.Pair;
|
||||
import androidx.media3.common.FrameProcessingException;
|
||||
import androidx.media3.common.util.GlProgram;
|
||||
import androidx.media3.common.util.GlUtil;
|
||||
import androidx.media3.common.util.Size;
|
||||
import java.io.IOException;
|
||||
|
||||
/** Applies a {@link Contrast} to each frame in the fragment shader. */
|
||||
@ -65,8 +65,8 @@ import java.io.IOException;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Integer, Integer> configure(int inputWidth, int inputHeight) {
|
||||
return Pair.create(inputWidth, inputHeight);
|
||||
public Size configure(int inputWidth, int inputHeight) {
|
||||
return new Size(inputWidth, inputHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,8 +19,8 @@ import static androidx.media3.common.util.Assertions.checkArgument;
|
||||
import static androidx.media3.common.util.Assertions.checkStateNotNull;
|
||||
|
||||
import android.graphics.Matrix;
|
||||
import android.util.Pair;
|
||||
import androidx.media3.common.util.GlUtil;
|
||||
import androidx.media3.common.util.Size;
|
||||
import androidx.media3.common.util.UnstableApi;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
|
||||
@ -66,14 +66,14 @@ public final class Crop implements MatrixTransformation {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Integer, Integer> configure(int inputWidth, int inputHeight) {
|
||||
public Size configure(int inputWidth, int inputHeight) {
|
||||
checkArgument(inputWidth > 0, "inputWidth must be positive");
|
||||
checkArgument(inputHeight > 0, "inputHeight must be positive");
|
||||
|
||||
transformationMatrix = new Matrix();
|
||||
if (left == -1f && right == 1f && bottom == -1f && top == 1f) {
|
||||
// No crop needed.
|
||||
return Pair.create(inputWidth, inputHeight);
|
||||
return new Size(inputWidth, inputHeight);
|
||||
}
|
||||
|
||||
float scaleX = (right - left) / GlUtil.LENGTH_NDC;
|
||||
@ -86,7 +86,7 @@ public final class Crop implements MatrixTransformation {
|
||||
|
||||
int outputWidth = Math.round(inputWidth * scaleX);
|
||||
int outputHeight = Math.round(inputHeight * scaleY);
|
||||
return Pair.create(outputWidth, outputHeight);
|
||||
return new Size(outputWidth, outputHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -40,6 +40,7 @@ import androidx.media3.common.FrameProcessor;
|
||||
import androidx.media3.common.SurfaceInfo;
|
||||
import androidx.media3.common.util.GlUtil;
|
||||
import androidx.media3.common.util.Log;
|
||||
import androidx.media3.common.util.Size;
|
||||
import androidx.media3.common.util.Util;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import java.util.Queue;
|
||||
@ -84,7 +85,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
@Nullable private MatrixTextureProcessor matrixTextureProcessor;
|
||||
@Nullable private SurfaceViewWrapper debugSurfaceViewWrapper;
|
||||
private InputListener inputListener;
|
||||
private @MonotonicNonNull Pair<Integer, Integer> outputSizeBeforeSurfaceTransformation;
|
||||
private @MonotonicNonNull Size outputSizeBeforeSurfaceTransformation;
|
||||
@Nullable private SurfaceView debugSurfaceView;
|
||||
|
||||
private volatile boolean outputSizeOrRotationChanged;
|
||||
@ -313,7 +314,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
|| this.outputSizeBeforeSurfaceTransformation == null) {
|
||||
this.inputWidth = inputWidth;
|
||||
this.inputHeight = inputHeight;
|
||||
Pair<Integer, Integer> outputSizeBeforeSurfaceTransformation =
|
||||
Size outputSizeBeforeSurfaceTransformation =
|
||||
MatrixUtils.configureAndGetOutputSize(inputWidth, inputHeight, matrixTransformations);
|
||||
if (!Util.areEqual(
|
||||
this.outputSizeBeforeSurfaceTransformation, outputSizeBeforeSurfaceTransformation)) {
|
||||
@ -321,8 +322,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
frameProcessorListenerExecutor.execute(
|
||||
() ->
|
||||
frameProcessorListener.onOutputSizeChanged(
|
||||
outputSizeBeforeSurfaceTransformation.first,
|
||||
outputSizeBeforeSurfaceTransformation.second));
|
||||
outputSizeBeforeSurfaceTransformation.getWidth(),
|
||||
outputSizeBeforeSurfaceTransformation.getHeight()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -406,9 +407,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
}
|
||||
|
||||
matrixTextureProcessor.setTextureTransformMatrix(textureTransformMatrix);
|
||||
Pair<Integer, Integer> outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight);
|
||||
checkState(outputSize.first == outputSurfaceInfo.width);
|
||||
checkState(outputSize.second == outputSurfaceInfo.height);
|
||||
Size outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight);
|
||||
checkState(outputSize.getWidth() == outputSurfaceInfo.width);
|
||||
checkState(outputSize.getHeight() == outputSurfaceInfo.height);
|
||||
return matrixTextureProcessor;
|
||||
}
|
||||
|
||||
|
@ -17,8 +17,8 @@ package androidx.media3.effect;
|
||||
|
||||
import android.content.Context;
|
||||
import android.opengl.Matrix;
|
||||
import android.util.Pair;
|
||||
import androidx.media3.common.FrameProcessingException;
|
||||
import androidx.media3.common.util.Size;
|
||||
import androidx.media3.common.util.UnstableApi;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
@ -43,8 +43,8 @@ public interface GlMatrixTransformation extends GlEffect {
|
||||
* @param inputHeight The input frame height, in pixels.
|
||||
* @return The output frame width and height, in pixels.
|
||||
*/
|
||||
default Pair<Integer, Integer> configure(int inputWidth, int inputHeight) {
|
||||
return Pair.create(inputWidth, inputHeight);
|
||||
default Size configure(int inputWidth, int inputHeight) {
|
||||
return new Size(inputWidth, inputHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -20,10 +20,10 @@ import static androidx.media3.common.util.Assertions.checkArgument;
|
||||
|
||||
import android.content.Context;
|
||||
import android.opengl.GLES20;
|
||||
import android.util.Pair;
|
||||
import androidx.media3.common.FrameProcessingException;
|
||||
import androidx.media3.common.util.GlProgram;
|
||||
import androidx.media3.common.util.GlUtil;
|
||||
import androidx.media3.common.util.Size;
|
||||
import java.io.IOException;
|
||||
|
||||
/** Applies the {@link HslAdjustment} to each frame in the fragment shader. */
|
||||
@ -73,8 +73,8 @@ import java.io.IOException;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Integer, Integer> configure(int inputWidth, int inputHeight) {
|
||||
return Pair.create(inputWidth, inputHeight);
|
||||
public Size configure(int inputWidth, int inputHeight) {
|
||||
return new Size(inputWidth, inputHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -21,13 +21,13 @@ import static androidx.media3.common.util.Assertions.checkState;
|
||||
import android.content.Context;
|
||||
import android.opengl.GLES20;
|
||||
import android.opengl.Matrix;
|
||||
import android.util.Pair;
|
||||
import androidx.media3.common.C;
|
||||
import androidx.media3.common.ColorInfo;
|
||||
import androidx.media3.common.Format;
|
||||
import androidx.media3.common.FrameProcessingException;
|
||||
import androidx.media3.common.util.GlProgram;
|
||||
import androidx.media3.common.util.GlUtil;
|
||||
import androidx.media3.common.util.Size;
|
||||
import androidx.media3.common.util.UnstableApi;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import java.io.IOException;
|
||||
@ -356,7 +356,7 @@ import java.util.List;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Integer, Integer> configure(int inputWidth, int inputHeight) {
|
||||
public Size configure(int inputWidth, int inputHeight) {
|
||||
return MatrixUtils.configureAndGetOutputSize(inputWidth, inputHeight, matrixTransformations);
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ package androidx.media3.effect;
|
||||
import static androidx.media3.common.util.Assertions.checkArgument;
|
||||
|
||||
import android.opengl.Matrix;
|
||||
import android.util.Pair;
|
||||
import androidx.media3.common.util.Size;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import java.util.Arrays;
|
||||
|
||||
@ -222,16 +222,17 @@ import java.util.Arrays;
|
||||
* Returns the output frame size after applying the given list of {@link GlMatrixTransformation
|
||||
* GlMatrixTransformations} to an input frame with the given size.
|
||||
*/
|
||||
public static Pair<Integer, Integer> configureAndGetOutputSize(
|
||||
public static Size configureAndGetOutputSize(
|
||||
int inputWidth,
|
||||
int inputHeight,
|
||||
ImmutableList<GlMatrixTransformation> matrixTransformations) {
|
||||
checkArgument(inputWidth > 0, "inputWidth must be positive");
|
||||
checkArgument(inputHeight > 0, "inputHeight must be positive");
|
||||
|
||||
Pair<Integer, Integer> outputSize = Pair.create(inputWidth, inputHeight);
|
||||
Size outputSize = new Size(inputWidth, inputHeight);
|
||||
for (int i = 0; i < matrixTransformations.size(); i++) {
|
||||
outputSize = matrixTransformations.get(i).configure(outputSize.first, outputSize.second);
|
||||
outputSize =
|
||||
matrixTransformations.get(i).configure(outputSize.getWidth(), outputSize.getHeight());
|
||||
}
|
||||
|
||||
return outputSize;
|
||||
|
@ -20,10 +20,10 @@ import static androidx.media3.common.util.Assertions.checkArgument;
|
||||
import android.content.Context;
|
||||
import android.opengl.GLES20;
|
||||
import android.opengl.Matrix;
|
||||
import android.util.Pair;
|
||||
import androidx.media3.common.FrameProcessingException;
|
||||
import androidx.media3.common.util.GlProgram;
|
||||
import androidx.media3.common.util.GlUtil;
|
||||
import androidx.media3.common.util.Size;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import java.io.IOException;
|
||||
|
||||
@ -76,10 +76,10 @@ import java.io.IOException;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Integer, Integer> configure(int inputWidth, int inputHeight) {
|
||||
public Size configure(int inputWidth, int inputHeight) {
|
||||
videoWidth = inputWidth;
|
||||
videoHeight = inputHeight;
|
||||
return Pair.create(inputWidth, inputHeight);
|
||||
return new Size(inputWidth, inputHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -90,13 +90,13 @@ import java.io.IOException;
|
||||
TextureOverlay overlay = overlays.get(0);
|
||||
glProgram.setSamplerTexIdUniform(
|
||||
"uOverlayTexSampler1", overlay.getTextureId(presentationTimeUs), /* texUnitIndex= */ 1);
|
||||
Pair<Integer, Integer> overlayTextureSize = overlay.getTextureSize(presentationTimeUs);
|
||||
Size overlayTextureSize = overlay.getTextureSize(presentationTimeUs);
|
||||
GlUtil.setToIdentity(aspectRatioMatrix);
|
||||
Matrix.scaleM(
|
||||
aspectRatioMatrix,
|
||||
MATRIX_OFFSET,
|
||||
videoWidth / (float) overlayTextureSize.first,
|
||||
videoHeight / (float) overlayTextureSize.second,
|
||||
videoWidth / (float) overlayTextureSize.getWidth(),
|
||||
videoHeight / (float) overlayTextureSize.getHeight(),
|
||||
/* z= */ 1);
|
||||
glProgram.setFloatsUniform("uAspectRatioMatrix", aspectRatioMatrix);
|
||||
Matrix.invertM(
|
||||
|
@ -21,9 +21,9 @@ import static java.lang.annotation.ElementType.TYPE_USE;
|
||||
import static java.lang.annotation.RetentionPolicy.SOURCE;
|
||||
|
||||
import android.graphics.Matrix;
|
||||
import android.util.Pair;
|
||||
import androidx.annotation.IntDef;
|
||||
import androidx.media3.common.C;
|
||||
import androidx.media3.common.util.Size;
|
||||
import androidx.media3.common.util.UnstableApi;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
@ -181,7 +181,7 @@ public final class Presentation implements MatrixTransformation {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Integer, Integer> configure(int inputWidth, int inputHeight) {
|
||||
public Size configure(int inputWidth, int inputHeight) {
|
||||
checkArgument(inputWidth > 0, "inputWidth must be positive");
|
||||
checkArgument(inputHeight > 0, "inputHeight must be positive");
|
||||
|
||||
@ -206,7 +206,7 @@ public final class Presentation implements MatrixTransformation {
|
||||
}
|
||||
outputHeight = requestedHeightPixels;
|
||||
}
|
||||
return Pair.create(Math.round(outputWidth), Math.round(outputHeight));
|
||||
return new Size(Math.round(outputWidth), Math.round(outputHeight));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -21,8 +21,8 @@ import static java.lang.Math.max;
|
||||
import static java.lang.Math.min;
|
||||
|
||||
import android.graphics.Matrix;
|
||||
import android.util.Pair;
|
||||
import androidx.media3.common.util.GlUtil;
|
||||
import androidx.media3.common.util.Size;
|
||||
import androidx.media3.common.util.UnstableApi;
|
||||
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
@ -105,14 +105,14 @@ public final class ScaleToFitTransformation implements MatrixTransformation {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Integer, Integer> configure(int inputWidth, int inputHeight) {
|
||||
public Size configure(int inputWidth, int inputHeight) {
|
||||
checkArgument(inputWidth > 0, "inputWidth must be positive");
|
||||
checkArgument(inputHeight > 0, "inputHeight must be positive");
|
||||
|
||||
adjustedTransformationMatrix = new Matrix(transformationMatrix);
|
||||
|
||||
if (transformationMatrix.isIdentity()) {
|
||||
return Pair.create(inputWidth, inputHeight);
|
||||
return new Size(inputWidth, inputHeight);
|
||||
}
|
||||
|
||||
float inputAspectRatio = (float) inputWidth / inputHeight;
|
||||
@ -141,7 +141,7 @@ public final class ScaleToFitTransformation implements MatrixTransformation {
|
||||
float scaleX = (maxX - minX) / GlUtil.LENGTH_NDC;
|
||||
float scaleY = (maxY - minY) / GlUtil.LENGTH_NDC;
|
||||
adjustedTransformationMatrix.postScale(1f / scaleX, 1f / scaleY);
|
||||
return Pair.create(Math.round(inputWidth * scaleX), Math.round(inputHeight * scaleY));
|
||||
return new Size(Math.round(inputWidth * scaleX), Math.round(inputHeight * scaleY));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -17,10 +17,10 @@ package androidx.media3.effect;
|
||||
|
||||
import static androidx.media3.common.util.Assertions.checkState;
|
||||
|
||||
import android.util.Pair;
|
||||
import androidx.annotation.CallSuper;
|
||||
import androidx.media3.common.FrameProcessingException;
|
||||
import androidx.media3.common.util.GlUtil;
|
||||
import androidx.media3.common.util.Size;
|
||||
import androidx.media3.common.util.UnstableApi;
|
||||
import com.google.common.util.concurrent.MoreExecutors;
|
||||
import java.util.concurrent.Executor;
|
||||
@ -75,7 +75,7 @@ public abstract class SingleFrameGlTextureProcessor implements GlTextureProcesso
|
||||
* @param inputHeight The input height, in pixels.
|
||||
* @return The output width and height of frames processed through {@link #drawFrame(int, long)}.
|
||||
*/
|
||||
public abstract Pair<Integer, Integer> configure(int inputWidth, int inputHeight);
|
||||
public abstract Size configure(int inputWidth, int inputHeight);
|
||||
|
||||
/**
|
||||
* Draws one frame.
|
||||
@ -147,17 +147,17 @@ public abstract class SingleFrameGlTextureProcessor implements GlTextureProcesso
|
||||
private void configureOutputTexture(int inputWidth, int inputHeight) throws GlUtil.GlException {
|
||||
this.inputWidth = inputWidth;
|
||||
this.inputHeight = inputHeight;
|
||||
Pair<Integer, Integer> outputSize = configure(inputWidth, inputHeight);
|
||||
Size outputSize = configure(inputWidth, inputHeight);
|
||||
if (outputTexture == null
|
||||
|| outputSize.first != outputTexture.width
|
||||
|| outputSize.second != outputTexture.height) {
|
||||
|| outputSize.getWidth() != outputTexture.width
|
||||
|| outputSize.getHeight() != outputTexture.height) {
|
||||
if (outputTexture != null) {
|
||||
GlUtil.deleteTexture(outputTexture.texId);
|
||||
}
|
||||
int outputTexId = GlUtil.createTexture(outputSize.first, outputSize.second, useHdr);
|
||||
int outputTexId = GlUtil.createTexture(outputSize.getWidth(), outputSize.getHeight(), useHdr);
|
||||
int outputFboId = GlUtil.createFboForTexture(outputTexId);
|
||||
outputTexture =
|
||||
new TextureInfo(outputTexId, outputFboId, outputSize.first, outputSize.second);
|
||||
new TextureInfo(outputTexId, outputFboId, outputSize.getWidth(), outputSize.getHeight());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,8 +15,8 @@
|
||||
*/
|
||||
package androidx.media3.effect;
|
||||
|
||||
import android.util.Pair;
|
||||
import androidx.media3.common.FrameProcessingException;
|
||||
import androidx.media3.common.util.Size;
|
||||
import androidx.media3.common.util.UnstableApi;
|
||||
|
||||
/** Creates overlays from OpenGL textures. */
|
||||
@ -39,7 +39,7 @@ public abstract class TextureOverlay {
|
||||
*
|
||||
* @param presentationTimeUs The presentation timestamp of the current frame, in microseconds.
|
||||
*/
|
||||
public abstract Pair<Integer, Integer> getTextureSize(long presentationTimeUs);
|
||||
public abstract Size getTextureSize(long presentationTimeUs);
|
||||
|
||||
/**
|
||||
* Returns the {@link OverlaySettings} controlling how the overlay is displayed at the specified
|
||||
|
@ -17,8 +17,8 @@ package androidx.media3.effect;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.util.Pair;
|
||||
import androidx.media3.common.util.GlUtil;
|
||||
import androidx.media3.common.util.Size;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@ -36,10 +36,10 @@ public final class CropTest {
|
||||
int inputHeight = 150;
|
||||
Crop crop = new Crop(/* left= */ -1, /* right= */ 1, /* bottom= */ -1, /* top= */ 1);
|
||||
|
||||
Pair<Integer, Integer> outputSize = crop.configure(inputWidth, inputHeight);
|
||||
Size outputSize = crop.configure(inputWidth, inputHeight);
|
||||
|
||||
assertThat(outputSize.first).isEqualTo(inputWidth);
|
||||
assertThat(outputSize.second).isEqualTo(inputHeight);
|
||||
assertThat(outputSize.getWidth()).isEqualTo(inputWidth);
|
||||
assertThat(outputSize.getHeight()).isEqualTo(inputHeight);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -52,11 +52,11 @@ public final class CropTest {
|
||||
float top = 1f;
|
||||
Crop crop = new Crop(left, right, bottom, top);
|
||||
|
||||
Pair<Integer, Integer> outputSize = crop.configure(inputWidth, inputHeight);
|
||||
Size outputSize = crop.configure(inputWidth, inputHeight);
|
||||
|
||||
int expectedPostCropWidth = Math.round(inputWidth * (right - left) / GlUtil.LENGTH_NDC);
|
||||
int expectedPostCropHeight = Math.round(inputHeight * (top - bottom) / GlUtil.LENGTH_NDC);
|
||||
assertThat(outputSize.first).isEqualTo(expectedPostCropWidth);
|
||||
assertThat(outputSize.second).isEqualTo(expectedPostCropHeight);
|
||||
assertThat(outputSize.getWidth()).isEqualTo(expectedPostCropWidth);
|
||||
assertThat(outputSize.getHeight()).isEqualTo(expectedPostCropHeight);
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,8 @@ package androidx.media3.effect;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.util.Pair;
|
||||
import androidx.media3.common.C;
|
||||
import androidx.media3.common.util.Size;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@ -36,10 +36,10 @@ public final class PresentationTest {
|
||||
int inputHeight = 150;
|
||||
Presentation presentation = Presentation.createForHeight(C.LENGTH_UNSET);
|
||||
|
||||
Pair<Integer, Integer> outputSize = presentation.configure(inputWidth, inputHeight);
|
||||
Size outputSize = presentation.configure(inputWidth, inputHeight);
|
||||
|
||||
assertThat(outputSize.first).isEqualTo(inputWidth);
|
||||
assertThat(outputSize.second).isEqualTo(inputHeight);
|
||||
assertThat(outputSize.getWidth()).isEqualTo(inputWidth);
|
||||
assertThat(outputSize.getHeight()).isEqualTo(inputHeight);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -49,10 +49,10 @@ public final class PresentationTest {
|
||||
int requestedHeight = 300;
|
||||
Presentation presentation = Presentation.createForHeight(requestedHeight);
|
||||
|
||||
Pair<Integer, Integer> outputSize = presentation.configure(inputWidth, inputHeight);
|
||||
Size outputSize = presentation.configure(inputWidth, inputHeight);
|
||||
|
||||
assertThat(outputSize.first).isEqualTo(requestedHeight * inputWidth / inputHeight);
|
||||
assertThat(outputSize.second).isEqualTo(requestedHeight);
|
||||
assertThat(outputSize.getWidth()).isEqualTo(requestedHeight * inputWidth / inputHeight);
|
||||
assertThat(outputSize.getHeight()).isEqualTo(requestedHeight);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -63,10 +63,10 @@ public final class PresentationTest {
|
||||
Presentation presentation =
|
||||
Presentation.createForAspectRatio(aspectRatio, Presentation.LAYOUT_SCALE_TO_FIT);
|
||||
|
||||
Pair<Integer, Integer> outputSize = presentation.configure(inputWidth, inputHeight);
|
||||
Size outputSize = presentation.configure(inputWidth, inputHeight);
|
||||
|
||||
assertThat(outputSize.first).isEqualTo(Math.round(aspectRatio * inputHeight));
|
||||
assertThat(outputSize.second).isEqualTo(inputHeight);
|
||||
assertThat(outputSize.getWidth()).isEqualTo(Math.round(aspectRatio * inputHeight));
|
||||
assertThat(outputSize.getHeight()).isEqualTo(inputHeight);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -79,9 +79,9 @@ public final class PresentationTest {
|
||||
Presentation.createForWidthAndHeight(
|
||||
requestedWidth, requestedHeight, Presentation.LAYOUT_SCALE_TO_FIT);
|
||||
|
||||
Pair<Integer, Integer> outputSize = presentation.configure(inputWidth, inputHeight);
|
||||
Size outputSize = presentation.configure(inputWidth, inputHeight);
|
||||
|
||||
assertThat(outputSize.first).isEqualTo(requestedWidth);
|
||||
assertThat(outputSize.second).isEqualTo(requestedHeight);
|
||||
assertThat(outputSize.getWidth()).isEqualTo(requestedWidth);
|
||||
assertThat(outputSize.getHeight()).isEqualTo(requestedHeight);
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ package androidx.media3.effect;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.util.Pair;
|
||||
import androidx.media3.common.util.Size;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@ -38,10 +38,10 @@ public final class ScaleToFitTransformationTest {
|
||||
ScaleToFitTransformation scaleToFitTransformation =
|
||||
new ScaleToFitTransformation.Builder().build();
|
||||
|
||||
Pair<Integer, Integer> outputSize = scaleToFitTransformation.configure(inputWidth, inputHeight);
|
||||
Size outputSize = scaleToFitTransformation.configure(inputWidth, inputHeight);
|
||||
|
||||
assertThat(outputSize.first).isEqualTo(inputWidth);
|
||||
assertThat(outputSize.second).isEqualTo(inputHeight);
|
||||
assertThat(outputSize.getWidth()).isEqualTo(inputWidth);
|
||||
assertThat(outputSize.getHeight()).isEqualTo(inputHeight);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -53,10 +53,10 @@ public final class ScaleToFitTransformationTest {
|
||||
.setScale(/* scaleX= */ .5f, /* scaleY= */ 1f)
|
||||
.build();
|
||||
|
||||
Pair<Integer, Integer> outputSize = scaleToFitTransformation.configure(inputWidth, inputHeight);
|
||||
Size outputSize = scaleToFitTransformation.configure(inputWidth, inputHeight);
|
||||
|
||||
assertThat(outputSize.first).isEqualTo(Math.round(inputWidth * .5f));
|
||||
assertThat(outputSize.second).isEqualTo(inputHeight);
|
||||
assertThat(outputSize.getWidth()).isEqualTo(Math.round(inputWidth * .5f));
|
||||
assertThat(outputSize.getHeight()).isEqualTo(inputHeight);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -66,10 +66,10 @@ public final class ScaleToFitTransformationTest {
|
||||
ScaleToFitTransformation scaleToFitTransformation =
|
||||
new ScaleToFitTransformation.Builder().setScale(/* scaleX= */ 2f, /* scaleY= */ 1f).build();
|
||||
|
||||
Pair<Integer, Integer> outputSize = scaleToFitTransformation.configure(inputWidth, inputHeight);
|
||||
Size outputSize = scaleToFitTransformation.configure(inputWidth, inputHeight);
|
||||
|
||||
assertThat(outputSize.first).isEqualTo(inputWidth * 2);
|
||||
assertThat(outputSize.second).isEqualTo(inputHeight);
|
||||
assertThat(outputSize.getWidth()).isEqualTo(inputWidth * 2);
|
||||
assertThat(outputSize.getHeight()).isEqualTo(inputHeight);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -79,10 +79,10 @@ public final class ScaleToFitTransformationTest {
|
||||
ScaleToFitTransformation scaleToFitTransformation =
|
||||
new ScaleToFitTransformation.Builder().setScale(/* scaleX= */ 1f, /* scaleY= */ 2f).build();
|
||||
|
||||
Pair<Integer, Integer> outputSize = scaleToFitTransformation.configure(inputWidth, inputHeight);
|
||||
Size outputSize = scaleToFitTransformation.configure(inputWidth, inputHeight);
|
||||
|
||||
assertThat(outputSize.first).isEqualTo(inputWidth);
|
||||
assertThat(outputSize.second).isEqualTo(inputHeight * 2);
|
||||
assertThat(outputSize.getWidth()).isEqualTo(inputWidth);
|
||||
assertThat(outputSize.getHeight()).isEqualTo(inputHeight * 2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -92,10 +92,10 @@ public final class ScaleToFitTransformationTest {
|
||||
ScaleToFitTransformation scaleToFitTransformation =
|
||||
new ScaleToFitTransformation.Builder().setRotationDegrees(90).build();
|
||||
|
||||
Pair<Integer, Integer> outputSize = scaleToFitTransformation.configure(inputWidth, inputHeight);
|
||||
Size outputSize = scaleToFitTransformation.configure(inputWidth, inputHeight);
|
||||
|
||||
assertThat(outputSize.first).isEqualTo(inputHeight);
|
||||
assertThat(outputSize.second).isEqualTo(inputWidth);
|
||||
assertThat(outputSize.getWidth()).isEqualTo(inputHeight);
|
||||
assertThat(outputSize.getHeight()).isEqualTo(inputWidth);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -106,9 +106,9 @@ public final class ScaleToFitTransformationTest {
|
||||
new ScaleToFitTransformation.Builder().setRotationDegrees(45).build();
|
||||
long expectedOutputWidthHeight = 247;
|
||||
|
||||
Pair<Integer, Integer> outputSize = scaleToFitTransformation.configure(inputWidth, inputHeight);
|
||||
Size outputSize = scaleToFitTransformation.configure(inputWidth, inputHeight);
|
||||
|
||||
assertThat(outputSize.first).isEqualTo(expectedOutputWidthHeight);
|
||||
assertThat(outputSize.second).isEqualTo(expectedOutputWidthHeight);
|
||||
assertThat(outputSize.getWidth()).isEqualTo(expectedOutputWidthHeight);
|
||||
assertThat(outputSize.getHeight()).isEqualTo(expectedOutputWidthHeight);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user