FrameProcessor: Move test bitmaps to a separate directory.

* Group what's now many related test PNGs by moving them to their own directory.
* Move bitmap references to files where they're used, as each bitmap is only
used once each, except the original bitmap.

PiperOrigin-RevId: 441485489
This commit is contained in:
huangdarwin 2022-04-13 16:17:13 +01:00 committed by Ian Baker
parent 22e016e851
commit 29e32540de
21 changed files with 91 additions and 89 deletions

View File

@ -0,0 +1,32 @@
Expected first frame of
[sample.mp4](https://github.com/androidx/media/blob/main/libraries/test_data/src/test/assets/media/mp4/sample.mp4)
after a
[Transformer](https://github.com/androidx/media/tree/main/libraries/transformer)
transformation. Used to validate that frame operations produce expected output
in
[pixel tests](https://github.com/androidx/media/tree/main/libraries/transformer/src/androidTest/java/androidx/media3/transformer).
<!-- copybara:strip_begin -->
To generate new "expected" assets:
1. Start an emulator with the same configuration as on presubmit. The emulator
is given
[here](cs/target_device%20f:media/libraries/transformer/src/androidTest/BUILD)
and can be run locally, using go/crow:
```shell
crow --device generic_phone --api_level 30 --arch x86
```
2. Run the test.
3. Copy the file from the device to the assets directory, e.g.,
```shell
adb pull \
/sdcard/Android/data/androidx.media3.transformer.test/cache/drawFrame_rotate90_actual.png \
third_party/java_src/android_libs/media/libraries/test_data/src/test/assets/media/bitmap/sample_mp4_first_frame/rotate90.png
```
<!-- copybara:strip_end -->

View File

@ -15,11 +15,7 @@
*/ */
package androidx.media3.transformer; package androidx.media3.transformer;
import static androidx.media3.transformer.BitmapTestUtil.FIRST_FRAME_PNG_ASSET_STRING;
import static androidx.media3.transformer.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; import static androidx.media3.transformer.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE;
import static androidx.media3.transformer.BitmapTestUtil.ROTATE_90_EXPECTED_OUTPUT_PNG_ASSET_STRING;
import static androidx.media3.transformer.BitmapTestUtil.SCALE_NARROW_EXPECTED_OUTPUT_PNG_ASSET_STRING;
import static androidx.media3.transformer.BitmapTestUtil.TRANSLATE_RIGHT_EXPECTED_OUTPUT_PNG_ASSET_STRING;
import static androidx.test.core.app.ApplicationProvider.getApplicationContext; import static androidx.test.core.app.ApplicationProvider.getApplicationContext;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
@ -48,6 +44,14 @@ import org.junit.runner.RunWith;
*/ */
@RunWith(AndroidJUnit4.class) @RunWith(AndroidJUnit4.class)
public final class AdvancedFrameProcessorPixelTest { public final class AdvancedFrameProcessorPixelTest {
public static final String ORIGINAL_PNG_ASSET_PATH =
"media/bitmap/sample_mp4_first_frame/original.png";
public static final String TRANSLATE_RIGHT_PNG_ASSET_PATH =
"media/bitmap/sample_mp4_first_frame/translate_right.png";
public static final String SCALE_NARROW_PNG_ASSET_PATH =
"media/bitmap/sample_mp4_first_frame/scale_narrow.png";
public static final String ROTATE_90_PNG_ASSET_PATH =
"media/bitmap/sample_mp4_first_frame/rotate90.png";
static { static {
GlUtil.glAssertionsEnabled = true; GlUtil.glAssertionsEnabled = true;
@ -63,7 +67,7 @@ public final class AdvancedFrameProcessorPixelTest {
@Before @Before
public void createTextures() throws IOException { public void createTextures() throws IOException {
Bitmap inputBitmap = BitmapTestUtil.readBitmap(FIRST_FRAME_PNG_ASSET_STRING); Bitmap inputBitmap = BitmapTestUtil.readBitmap(ORIGINAL_PNG_ASSET_PATH);
width = inputBitmap.getWidth(); width = inputBitmap.getWidth();
height = inputBitmap.getHeight(); height = inputBitmap.getHeight();
// This surface is needed for focussing a render target, but the tests don't write output to it. // This surface is needed for focussing a render target, but the tests don't write output to it.
@ -91,7 +95,7 @@ public final class AdvancedFrameProcessorPixelTest {
Matrix identityMatrix = new Matrix(); Matrix identityMatrix = new Matrix();
advancedFrameProcessor = new AdvancedFrameProcessor(getApplicationContext(), identityMatrix); advancedFrameProcessor = new AdvancedFrameProcessor(getApplicationContext(), identityMatrix);
advancedFrameProcessor.initialize(inputTexId, width, height); advancedFrameProcessor.initialize(inputTexId, width, height);
Bitmap expectedBitmap = BitmapTestUtil.readBitmap(FIRST_FRAME_PNG_ASSET_STRING); Bitmap expectedBitmap = BitmapTestUtil.readBitmap(ORIGINAL_PNG_ASSET_PATH);
advancedFrameProcessor.drawFrame(/* presentationTimeUs= */ 0); advancedFrameProcessor.drawFrame(/* presentationTimeUs= */ 0);
Bitmap actualBitmap = Bitmap actualBitmap =
@ -114,8 +118,7 @@ public final class AdvancedFrameProcessorPixelTest {
advancedFrameProcessor = advancedFrameProcessor =
new AdvancedFrameProcessor(getApplicationContext(), translateRightMatrix); new AdvancedFrameProcessor(getApplicationContext(), translateRightMatrix);
advancedFrameProcessor.initialize(inputTexId, width, height); advancedFrameProcessor.initialize(inputTexId, width, height);
Bitmap expectedBitmap = Bitmap expectedBitmap = BitmapTestUtil.readBitmap(TRANSLATE_RIGHT_PNG_ASSET_PATH);
BitmapTestUtil.readBitmap(TRANSLATE_RIGHT_EXPECTED_OUTPUT_PNG_ASSET_STRING);
advancedFrameProcessor.drawFrame(/* presentationTimeUs= */ 0); advancedFrameProcessor.drawFrame(/* presentationTimeUs= */ 0);
Bitmap actualBitmap = Bitmap actualBitmap =
@ -137,8 +140,7 @@ public final class AdvancedFrameProcessorPixelTest {
scaleNarrowMatrix.postScale(.5f, 1.2f); scaleNarrowMatrix.postScale(.5f, 1.2f);
advancedFrameProcessor = new AdvancedFrameProcessor(getApplicationContext(), scaleNarrowMatrix); advancedFrameProcessor = new AdvancedFrameProcessor(getApplicationContext(), scaleNarrowMatrix);
advancedFrameProcessor.initialize(inputTexId, width, height); advancedFrameProcessor.initialize(inputTexId, width, height);
Bitmap expectedBitmap = Bitmap expectedBitmap = BitmapTestUtil.readBitmap(SCALE_NARROW_PNG_ASSET_PATH);
BitmapTestUtil.readBitmap(SCALE_NARROW_EXPECTED_OUTPUT_PNG_ASSET_STRING);
advancedFrameProcessor.drawFrame(/* presentationTimeUs= */ 0); advancedFrameProcessor.drawFrame(/* presentationTimeUs= */ 0);
Bitmap actualBitmap = Bitmap actualBitmap =
@ -160,7 +162,7 @@ public final class AdvancedFrameProcessorPixelTest {
rotate90Matrix.postRotate(/* degrees= */ 90); rotate90Matrix.postRotate(/* degrees= */ 90);
advancedFrameProcessor = new AdvancedFrameProcessor(getApplicationContext(), rotate90Matrix); advancedFrameProcessor = new AdvancedFrameProcessor(getApplicationContext(), rotate90Matrix);
advancedFrameProcessor.initialize(inputTexId, width, height); advancedFrameProcessor.initialize(inputTexId, width, height);
Bitmap expectedBitmap = BitmapTestUtil.readBitmap(ROTATE_90_EXPECTED_OUTPUT_PNG_ASSET_STRING); Bitmap expectedBitmap = BitmapTestUtil.readBitmap(ROTATE_90_PNG_ASSET_PATH);
advancedFrameProcessor.drawFrame(/* presentationTimeUs= */ 0); advancedFrameProcessor.drawFrame(/* presentationTimeUs= */ 0);
Bitmap actualBitmap = Bitmap actualBitmap =

View File

@ -46,42 +46,6 @@ public class BitmapTestUtil {
private static final String TAG = "BitmapTestUtil"; private static final String TAG = "BitmapTestUtil";
/* Expected first frames after transformation. */
public static final String FIRST_FRAME_PNG_ASSET_STRING =
"media/bitmap/sample_mp4_first_frame.png";
public static final String TRANSLATE_RIGHT_EXPECTED_OUTPUT_PNG_ASSET_STRING =
"media/bitmap/sample_mp4_first_frame_translate_right.png";
public static final String SCALE_NARROW_EXPECTED_OUTPUT_PNG_ASSET_STRING =
"media/bitmap/sample_mp4_first_frame_scale_narrow.png";
public static final String ROTATE_THEN_TRANSLATE_EXPECTED_OUTPUT_PNG_ASSET_STRING =
"media/bitmap/sample_mp4_first_frame_rotate_then_translate.png";
public static final String TRANSLATE_THEN_ROTATE_EXPECTED_OUTPUT_PNG_ASSET_STRING =
"media/bitmap/sample_mp4_first_frame_translate_then_rotate.png";
public static final String ROTATE_90_EXPECTED_OUTPUT_PNG_ASSET_STRING =
"media/bitmap/sample_mp4_first_frame_rotate90.png";
public static final String REQUEST_OUTPUT_HEIGHT_EXPECTED_OUTPUT_PNG_ASSET_STRING =
"media/bitmap/sample_mp4_first_frame_request_output_height.png";
public static final String ROTATE45_SCALE_TO_FIT_EXPECTED_OUTPUT_PNG_ASSET_STRING =
"media/bitmap/sample_mp4_first_frame_rotate_45_scale_to_fit.png";
public static final String CROP_SMALLER_EXPECTED_OUTPUT_PNG_ASSET_STRING =
"media/bitmap/sample_mp4_first_frame_crop_smaller.png";
public static final String CROP_LARGER_EXPECTED_OUTPUT_PNG_ASSET_STRING =
"media/bitmap/sample_mp4_first_frame_crop_larger.png";
public static final String ASPECT_RATIO_SCALE_TO_FIT_NARROW_EXPECTED_OUTPUT_PNG_ASSET_STRING =
"media/bitmap/sample_mp4_first_frame_aspect_ratio_scale_to_fit_narrow.png";
public static final String ASPECT_RATIO_SCALE_TO_FIT_WIDE_EXPECTED_OUTPUT_PNG_ASSET_STRING =
"media/bitmap/sample_mp4_first_frame_aspect_ratio_scale_to_fit_wide.png";
public static final String
ASPECT_RATIO_SCALE_TO_FIT_WITH_CROP_NARROW_EXPECTED_OUTPUT_PNG_ASSET_STRING =
"media/bitmap/sample_mp4_first_frame_aspect_ratio_scale_to_fit_with_crop_narrow.png";
public static final String
ASPECT_RATIO_SCALE_TO_FIT_WITH_CROP_WIDE_EXPECTED_OUTPUT_PNG_ASSET_STRING =
"media/bitmap/sample_mp4_first_frame_aspect_ratio_scale_to_fit_with_crop_wide.png";
public static final String ASPECT_RATIO_STRETCH_TO_FIT_NARROW_EXPECTED_OUTPUT_PNG_ASSET_STRING =
"media/bitmap/sample_mp4_first_frame_aspect_ratio_stretch_to_fit_narrow.png";
public static final String ASPECT_RATIO_STRETCH_TO_FIT_WIDE_EXPECTED_OUTPUT_PNG_ASSET_STRING =
"media/bitmap/sample_mp4_first_frame_aspect_ratio_stretch_to_fit_wide.png";
/** /**
* Maximum allowed average pixel difference between the expected and actual edited images in pixel * Maximum allowed average pixel difference between the expected and actual edited images in pixel
* difference-based tests. The value is chosen so that differences in decoder behavior across * difference-based tests. The value is chosen so that differences in decoder behavior across

View File

@ -16,13 +16,7 @@
package androidx.media3.transformer; package androidx.media3.transformer;
import static androidx.media3.common.util.Assertions.checkNotNull; import static androidx.media3.common.util.Assertions.checkNotNull;
import static androidx.media3.transformer.BitmapTestUtil.FIRST_FRAME_PNG_ASSET_STRING;
import static androidx.media3.transformer.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; import static androidx.media3.transformer.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE;
import static androidx.media3.transformer.BitmapTestUtil.REQUEST_OUTPUT_HEIGHT_EXPECTED_OUTPUT_PNG_ASSET_STRING;
import static androidx.media3.transformer.BitmapTestUtil.ROTATE45_SCALE_TO_FIT_EXPECTED_OUTPUT_PNG_ASSET_STRING;
import static androidx.media3.transformer.BitmapTestUtil.ROTATE_THEN_TRANSLATE_EXPECTED_OUTPUT_PNG_ASSET_STRING;
import static androidx.media3.transformer.BitmapTestUtil.TRANSLATE_RIGHT_EXPECTED_OUTPUT_PNG_ASSET_STRING;
import static androidx.media3.transformer.BitmapTestUtil.TRANSLATE_THEN_ROTATE_EXPECTED_OUTPUT_PNG_ASSET_STRING;
import static androidx.test.core.app.ApplicationProvider.getApplicationContext; import static androidx.test.core.app.ApplicationProvider.getApplicationContext;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static java.util.Arrays.asList; import static java.util.Arrays.asList;
@ -57,6 +51,18 @@ import org.junit.runner.RunWith;
*/ */
@RunWith(AndroidJUnit4.class) @RunWith(AndroidJUnit4.class)
public final class FrameProcessorChainPixelTest { public final class FrameProcessorChainPixelTest {
public static final String ORIGINAL_PNG_ASSET_PATH =
"media/bitmap/sample_mp4_first_frame/original.png";
public static final String TRANSLATE_RIGHT_PNG_ASSET_PATH =
"media/bitmap/sample_mp4_first_frame/translate_right.png";
public static final String ROTATE_THEN_TRANSLATE_PNG_ASSET_PATH =
"media/bitmap/sample_mp4_first_frame/rotate_then_translate.png";
public static final String TRANSLATE_THEN_ROTATE_PNG_ASSET_PATH =
"media/bitmap/sample_mp4_first_frame/translate_then_rotate.png";
public static final String REQUEST_OUTPUT_HEIGHT_PNG_ASSET_PATH =
"media/bitmap/sample_mp4_first_frame/request_output_height.png";
public static final String ROTATE45_SCALE_TO_FIT_PNG_ASSET_PATH =
"media/bitmap/sample_mp4_first_frame/rotate_45_scale_to_fit.png";
/** Input video of which we only use the first frame. */ /** Input video of which we only use the first frame. */
private static final String INPUT_MP4_ASSET_STRING = "media/mp4/sample.mp4"; private static final String INPUT_MP4_ASSET_STRING = "media/mp4/sample.mp4";
@ -85,7 +91,7 @@ public final class FrameProcessorChainPixelTest {
public void processData_noEdits_producesExpectedOutput() throws Exception { public void processData_noEdits_producesExpectedOutput() throws Exception {
String testId = "processData_noEdits"; String testId = "processData_noEdits";
setUpAndPrepareFirstFrame(); setUpAndPrepareFirstFrame();
Bitmap expectedBitmap = BitmapTestUtil.readBitmap(FIRST_FRAME_PNG_ASSET_STRING); Bitmap expectedBitmap = BitmapTestUtil.readBitmap(ORIGINAL_PNG_ASSET_PATH);
Bitmap actualBitmap = processFirstFrameAndEnd(); Bitmap actualBitmap = processFirstFrameAndEnd();
@ -107,8 +113,7 @@ public final class FrameProcessorChainPixelTest {
GlFrameProcessor glFrameProcessor = GlFrameProcessor glFrameProcessor =
new AdvancedFrameProcessor(getApplicationContext(), translateRightMatrix); new AdvancedFrameProcessor(getApplicationContext(), translateRightMatrix);
setUpAndPrepareFirstFrame(glFrameProcessor); setUpAndPrepareFirstFrame(glFrameProcessor);
Bitmap expectedBitmap = Bitmap expectedBitmap = BitmapTestUtil.readBitmap(TRANSLATE_RIGHT_PNG_ASSET_PATH);
BitmapTestUtil.readBitmap(TRANSLATE_RIGHT_EXPECTED_OUTPUT_PNG_ASSET_STRING);
Bitmap actualBitmap = processFirstFrameAndEnd(); Bitmap actualBitmap = processFirstFrameAndEnd();
@ -134,8 +139,7 @@ public final class FrameProcessorChainPixelTest {
.setRotationDegrees(45) .setRotationDegrees(45)
.build(); .build();
setUpAndPrepareFirstFrame(translateRightFrameProcessor, rotate45FrameProcessor); setUpAndPrepareFirstFrame(translateRightFrameProcessor, rotate45FrameProcessor);
Bitmap expectedBitmap = Bitmap expectedBitmap = BitmapTestUtil.readBitmap(TRANSLATE_THEN_ROTATE_PNG_ASSET_PATH);
BitmapTestUtil.readBitmap(TRANSLATE_THEN_ROTATE_EXPECTED_OUTPUT_PNG_ASSET_STRING);
Bitmap actualBitmap = processFirstFrameAndEnd(); Bitmap actualBitmap = processFirstFrameAndEnd();
@ -161,8 +165,7 @@ public final class FrameProcessorChainPixelTest {
GlFrameProcessor translateRightFrameProcessor = GlFrameProcessor translateRightFrameProcessor =
new AdvancedFrameProcessor(getApplicationContext(), translateRightMatrix); new AdvancedFrameProcessor(getApplicationContext(), translateRightMatrix);
setUpAndPrepareFirstFrame(rotate45FrameProcessor, translateRightFrameProcessor); setUpAndPrepareFirstFrame(rotate45FrameProcessor, translateRightFrameProcessor);
Bitmap expectedBitmap = Bitmap expectedBitmap = BitmapTestUtil.readBitmap(ROTATE_THEN_TRANSLATE_PNG_ASSET_PATH);
BitmapTestUtil.readBitmap(ROTATE_THEN_TRANSLATE_EXPECTED_OUTPUT_PNG_ASSET_STRING);
Bitmap actualBitmap = processFirstFrameAndEnd(); Bitmap actualBitmap = processFirstFrameAndEnd();
@ -182,8 +185,7 @@ public final class FrameProcessorChainPixelTest {
GlFrameProcessor glFrameProcessor = GlFrameProcessor glFrameProcessor =
new PresentationFrameProcessor.Builder(getApplicationContext()).setResolution(480).build(); new PresentationFrameProcessor.Builder(getApplicationContext()).setResolution(480).build();
setUpAndPrepareFirstFrame(glFrameProcessor); setUpAndPrepareFirstFrame(glFrameProcessor);
Bitmap expectedBitmap = Bitmap expectedBitmap = BitmapTestUtil.readBitmap(REQUEST_OUTPUT_HEIGHT_PNG_ASSET_PATH);
BitmapTestUtil.readBitmap(REQUEST_OUTPUT_HEIGHT_EXPECTED_OUTPUT_PNG_ASSET_STRING);
Bitmap actualBitmap = processFirstFrameAndEnd(); Bitmap actualBitmap = processFirstFrameAndEnd();
@ -205,8 +207,7 @@ public final class FrameProcessorChainPixelTest {
.setRotationDegrees(45) .setRotationDegrees(45)
.build(); .build();
setUpAndPrepareFirstFrame(glFrameProcessor); setUpAndPrepareFirstFrame(glFrameProcessor);
Bitmap expectedBitmap = Bitmap expectedBitmap = BitmapTestUtil.readBitmap(ROTATE45_SCALE_TO_FIT_PNG_ASSET_PATH);
BitmapTestUtil.readBitmap(ROTATE45_SCALE_TO_FIT_EXPECTED_OUTPUT_PNG_ASSET_STRING);
Bitmap actualBitmap = processFirstFrameAndEnd(); Bitmap actualBitmap = processFirstFrameAndEnd();

View File

@ -15,15 +15,6 @@
*/ */
package androidx.media3.transformer; package androidx.media3.transformer;
import static androidx.media3.transformer.BitmapTestUtil.ASPECT_RATIO_SCALE_TO_FIT_NARROW_EXPECTED_OUTPUT_PNG_ASSET_STRING;
import static androidx.media3.transformer.BitmapTestUtil.ASPECT_RATIO_SCALE_TO_FIT_WIDE_EXPECTED_OUTPUT_PNG_ASSET_STRING;
import static androidx.media3.transformer.BitmapTestUtil.ASPECT_RATIO_SCALE_TO_FIT_WITH_CROP_NARROW_EXPECTED_OUTPUT_PNG_ASSET_STRING;
import static androidx.media3.transformer.BitmapTestUtil.ASPECT_RATIO_SCALE_TO_FIT_WITH_CROP_WIDE_EXPECTED_OUTPUT_PNG_ASSET_STRING;
import static androidx.media3.transformer.BitmapTestUtil.ASPECT_RATIO_STRETCH_TO_FIT_NARROW_EXPECTED_OUTPUT_PNG_ASSET_STRING;
import static androidx.media3.transformer.BitmapTestUtil.ASPECT_RATIO_STRETCH_TO_FIT_WIDE_EXPECTED_OUTPUT_PNG_ASSET_STRING;
import static androidx.media3.transformer.BitmapTestUtil.CROP_LARGER_EXPECTED_OUTPUT_PNG_ASSET_STRING;
import static androidx.media3.transformer.BitmapTestUtil.CROP_SMALLER_EXPECTED_OUTPUT_PNG_ASSET_STRING;
import static androidx.media3.transformer.BitmapTestUtil.FIRST_FRAME_PNG_ASSET_STRING;
import static androidx.media3.transformer.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; import static androidx.media3.transformer.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE;
import static androidx.test.core.app.ApplicationProvider.getApplicationContext; import static androidx.test.core.app.ApplicationProvider.getApplicationContext;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
@ -54,6 +45,24 @@ import org.junit.runner.RunWith;
*/ */
@RunWith(AndroidJUnit4.class) @RunWith(AndroidJUnit4.class)
public final class PresentationFrameProcessorPixelTest { public final class PresentationFrameProcessorPixelTest {
public static final String ORIGINAL_PNG_ASSET_PATH =
"media/bitmap/sample_mp4_first_frame/original.png";
public static final String CROP_SMALLER_PNG_ASSET_PATH =
"media/bitmap/sample_mp4_first_frame/crop_smaller.png";
public static final String CROP_LARGER_PNG_ASSET_PATH =
"media/bitmap/sample_mp4_first_frame/crop_larger.png";
public static final String ASPECT_RATIO_SCALE_TO_FIT_NARROW_PNG_ASSET_PATH =
"media/bitmap/sample_mp4_first_frame/aspect_ratio_scale_to_fit_narrow.png";
public static final String ASPECT_RATIO_SCALE_TO_FIT_WIDE_PNG_ASSET_PATH =
"media/bitmap/sample_mp4_first_frame/aspect_ratio_scale_to_fit_wide.png";
public static final String ASPECT_RATIO_SCALE_TO_FIT_WITH_CROP_NARROW_PNG_ASSET_PATH =
"media/bitmap/sample_mp4_first_frame/aspect_ratio_scale_to_fit_with_crop_narrow.png";
public static final String ASPECT_RATIO_SCALE_TO_FIT_WITH_CROP_WIDE_PNG_ASSET_PATH =
"media/bitmap/sample_mp4_first_frame/aspect_ratio_scale_to_fit_with_crop_wide.png";
public static final String ASPECT_RATIO_STRETCH_TO_FIT_NARROW_PNG_ASSET_PATH =
"media/bitmap/sample_mp4_first_frame/aspect_ratio_stretch_to_fit_narrow.png";
public static final String ASPECT_RATIO_STRETCH_TO_FIT_WIDE_PNG_ASSET_PATH =
"media/bitmap/sample_mp4_first_frame/aspect_ratio_stretch_to_fit_wide.png";
static { static {
GlUtil.glAssertionsEnabled = true; GlUtil.glAssertionsEnabled = true;
@ -70,7 +79,7 @@ public final class PresentationFrameProcessorPixelTest {
@Before @Before
public void createTextures() throws IOException { public void createTextures() throws IOException {
Bitmap inputBitmap = BitmapTestUtil.readBitmap(FIRST_FRAME_PNG_ASSET_STRING); Bitmap inputBitmap = BitmapTestUtil.readBitmap(ORIGINAL_PNG_ASSET_PATH);
inputWidth = inputBitmap.getWidth(); inputWidth = inputBitmap.getWidth();
inputHeight = inputBitmap.getHeight(); inputHeight = inputBitmap.getHeight();
// This surface is needed for focussing a render target, but the tests don't write output to it. // This surface is needed for focussing a render target, but the tests don't write output to it.
@ -97,7 +106,7 @@ public final class PresentationFrameProcessorPixelTest {
presentationFrameProcessor.initialize(inputTexId, inputWidth, inputHeight); presentationFrameProcessor.initialize(inputTexId, inputWidth, inputHeight);
Size outputSize = presentationFrameProcessor.getOutputSize(); Size outputSize = presentationFrameProcessor.getOutputSize();
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
Bitmap expectedBitmap = BitmapTestUtil.readBitmap(FIRST_FRAME_PNG_ASSET_STRING); Bitmap expectedBitmap = BitmapTestUtil.readBitmap(ORIGINAL_PNG_ASSET_PATH);
presentationFrameProcessor.drawFrame(/* presentationTimeUs= */ 0); presentationFrameProcessor.drawFrame(/* presentationTimeUs= */ 0);
Bitmap actualBitmap = Bitmap actualBitmap =
@ -123,8 +132,7 @@ public final class PresentationFrameProcessorPixelTest {
presentationFrameProcessor.initialize(inputTexId, inputWidth, inputHeight); presentationFrameProcessor.initialize(inputTexId, inputWidth, inputHeight);
Size outputSize = presentationFrameProcessor.getOutputSize(); Size outputSize = presentationFrameProcessor.getOutputSize();
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
Bitmap expectedBitmap = Bitmap expectedBitmap = BitmapTestUtil.readBitmap(CROP_SMALLER_PNG_ASSET_PATH);
BitmapTestUtil.readBitmap(CROP_SMALLER_EXPECTED_OUTPUT_PNG_ASSET_STRING);
presentationFrameProcessor.drawFrame(/* presentationTimeUs= */ 0); presentationFrameProcessor.drawFrame(/* presentationTimeUs= */ 0);
Bitmap actualBitmap = Bitmap actualBitmap =
@ -150,7 +158,7 @@ public final class PresentationFrameProcessorPixelTest {
presentationFrameProcessor.initialize(inputTexId, inputWidth, inputHeight); presentationFrameProcessor.initialize(inputTexId, inputWidth, inputHeight);
Size outputSize = presentationFrameProcessor.getOutputSize(); Size outputSize = presentationFrameProcessor.getOutputSize();
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
Bitmap expectedBitmap = BitmapTestUtil.readBitmap(CROP_LARGER_EXPECTED_OUTPUT_PNG_ASSET_STRING); Bitmap expectedBitmap = BitmapTestUtil.readBitmap(CROP_LARGER_PNG_ASSET_PATH);
presentationFrameProcessor.drawFrame(/* presentationTimeUs= */ 0); presentationFrameProcessor.drawFrame(/* presentationTimeUs= */ 0);
Bitmap actualBitmap = Bitmap actualBitmap =
@ -178,8 +186,7 @@ public final class PresentationFrameProcessorPixelTest {
Size outputSize = presentationFrameProcessor.getOutputSize(); Size outputSize = presentationFrameProcessor.getOutputSize();
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
Bitmap expectedBitmap = Bitmap expectedBitmap =
BitmapTestUtil.readBitmap( BitmapTestUtil.readBitmap(ASPECT_RATIO_SCALE_TO_FIT_NARROW_PNG_ASSET_PATH);
ASPECT_RATIO_SCALE_TO_FIT_NARROW_EXPECTED_OUTPUT_PNG_ASSET_STRING);
presentationFrameProcessor.drawFrame(/* presentationTimeUs= */ 0); presentationFrameProcessor.drawFrame(/* presentationTimeUs= */ 0);
Bitmap actualBitmap = Bitmap actualBitmap =
@ -207,7 +214,7 @@ public final class PresentationFrameProcessorPixelTest {
Size outputSize = presentationFrameProcessor.getOutputSize(); Size outputSize = presentationFrameProcessor.getOutputSize();
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
Bitmap expectedBitmap = Bitmap expectedBitmap =
BitmapTestUtil.readBitmap(ASPECT_RATIO_SCALE_TO_FIT_WIDE_EXPECTED_OUTPUT_PNG_ASSET_STRING); BitmapTestUtil.readBitmap(ASPECT_RATIO_SCALE_TO_FIT_WIDE_PNG_ASSET_PATH);
presentationFrameProcessor.drawFrame(/* presentationTimeUs= */ 0); presentationFrameProcessor.drawFrame(/* presentationTimeUs= */ 0);
Bitmap actualBitmap = Bitmap actualBitmap =
@ -235,8 +242,7 @@ public final class PresentationFrameProcessorPixelTest {
Size outputSize = presentationFrameProcessor.getOutputSize(); Size outputSize = presentationFrameProcessor.getOutputSize();
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
Bitmap expectedBitmap = Bitmap expectedBitmap =
BitmapTestUtil.readBitmap( BitmapTestUtil.readBitmap(ASPECT_RATIO_SCALE_TO_FIT_WITH_CROP_NARROW_PNG_ASSET_PATH);
ASPECT_RATIO_SCALE_TO_FIT_WITH_CROP_NARROW_EXPECTED_OUTPUT_PNG_ASSET_STRING);
presentationFrameProcessor.drawFrame(/* presentationTimeUs= */ 0); presentationFrameProcessor.drawFrame(/* presentationTimeUs= */ 0);
Bitmap actualBitmap = Bitmap actualBitmap =
@ -264,8 +270,7 @@ public final class PresentationFrameProcessorPixelTest {
Size outputSize = presentationFrameProcessor.getOutputSize(); Size outputSize = presentationFrameProcessor.getOutputSize();
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
Bitmap expectedBitmap = Bitmap expectedBitmap =
BitmapTestUtil.readBitmap( BitmapTestUtil.readBitmap(ASPECT_RATIO_SCALE_TO_FIT_WITH_CROP_WIDE_PNG_ASSET_PATH);
ASPECT_RATIO_SCALE_TO_FIT_WITH_CROP_WIDE_EXPECTED_OUTPUT_PNG_ASSET_STRING);
presentationFrameProcessor.drawFrame(/* presentationTimeUs= */ 0); presentationFrameProcessor.drawFrame(/* presentationTimeUs= */ 0);
Bitmap actualBitmap = Bitmap actualBitmap =
@ -293,8 +298,7 @@ public final class PresentationFrameProcessorPixelTest {
Size outputSize = presentationFrameProcessor.getOutputSize(); Size outputSize = presentationFrameProcessor.getOutputSize();
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
Bitmap expectedBitmap = Bitmap expectedBitmap =
BitmapTestUtil.readBitmap( BitmapTestUtil.readBitmap(ASPECT_RATIO_STRETCH_TO_FIT_NARROW_PNG_ASSET_PATH);
ASPECT_RATIO_STRETCH_TO_FIT_NARROW_EXPECTED_OUTPUT_PNG_ASSET_STRING);
presentationFrameProcessor.drawFrame(/* presentationTimeUs= */ 0); presentationFrameProcessor.drawFrame(/* presentationTimeUs= */ 0);
Bitmap actualBitmap = Bitmap actualBitmap =
@ -322,8 +326,7 @@ public final class PresentationFrameProcessorPixelTest {
Size outputSize = presentationFrameProcessor.getOutputSize(); Size outputSize = presentationFrameProcessor.getOutputSize();
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
Bitmap expectedBitmap = Bitmap expectedBitmap =
BitmapTestUtil.readBitmap( BitmapTestUtil.readBitmap(ASPECT_RATIO_STRETCH_TO_FIT_WIDE_PNG_ASSET_PATH);
ASPECT_RATIO_STRETCH_TO_FIT_WIDE_EXPECTED_OUTPUT_PNG_ASSET_STRING);
presentationFrameProcessor.drawFrame(/* presentationTimeUs= */ 0); presentationFrameProcessor.drawFrame(/* presentationTimeUs= */ 0);
Bitmap actualBitmap = Bitmap actualBitmap =