1208 Commits

Author SHA1 Message Date
hschlueter
b2b27dc571 Fix FrameEditor intermediate texture size.
ExternalCopyFrameProcessor's output dimensions match the input
size not the output size. So the intermediate texture size
should match the input size.

Also rename configureOutputDimensions to configureOutputSize.

PiperOrigin-RevId: 435058789
2022-03-16 15:36:06 +00:00
claincly
191629ed7c Making mediaCodecName @NonNull in DefaultCodec constructor.
PiperOrigin-RevId: 435045138
2022-03-16 14:34:52 +00:00
claincly
1b3838cb0e Add test for DefaultEncoderFactory.
PiperOrigin-RevId: 435009545
2022-03-16 11:10:06 +00:00
huangdarwin
03c02b8b5d Transformer: Use Size for output dimensions.
Use android.util.Size, whose naming is much easier to understand than Pair<Integer, Integer>, in both FrameProcessor and EncoderUtil.

PiperOrigin-RevId: 434813986
2022-03-15 18:48:25 +00:00
samrobinson
fb03db8108 Add analysisException field to TransformationTestResult new Builder.
Having this in place means that analysis exceptions can be swallowed
or thrown as needed.

PiperOrigin-RevId: 434788802
2022-03-15 17:26:52 +00:00
huangdarwin
72aca58286 Transformer GL: Split out ScaleToFit and Advanced GlFrameProcessors
* Move auto-adjustments for transformation matrices from the
  VideoTranscodingSamplePipeline constructor to the new
  ScaleToFitFrameProcessor.
* Add GlFrameProcessor#getOutputDimensions() to allow for GlFrameProcessors with
  different input and output dimensions. This is a prerequisite for
  Presentation.
* Tested with unit tests (and manually just in case).
* A follow up CL will implement change the FrameProcessor input to be scale and
  rotate values as requested by the user. This was kept out of this CL to
  reduce CL review size. Presentation will also be implemented in a follow up
  CL.

PiperOrigin-RevId: 434774854
2022-03-15 16:36:52 +00:00
huangdarwin
628a8dd4fc Transformer: Add javadoc to VideoTranscodingSamplePipeline.
As pointed out in a previous review, createFallbackTransformationRequest
can be a bit confusing to parse.

Added javadocs and renamed parameters appropriately, to make it slightly
more easy to understand.

PiperOrigin-RevId: 434733313
2022-03-15 13:24:28 +00:00
hschlueter
682a5ca77b Clarify GlProgram parameter name.
PiperOrigin-RevId: 434441008
2022-03-14 12:52:16 +00:00
hschlueter
0e98c044da Move inputTexId parameter to GlFrameProcessor#initialize().
This parameter will not change between frames in the near
future.

PiperOrigin-RevId: 433765986
2022-03-24 17:24:14 +00:00
claincly
2e991acbdc Fix namings in SsimHelper.
There's no use of encoders in SsimHelper, changed all to "decoder".

PiperOrigin-RevId: 433730292
2022-03-24 17:22:12 +00:00
huangdarwin
0587a4f9c4 Transformer GL: Rename TexCoords to TexSampleCoords.
The variable marks the coordinates used to sample from a texture, so hopefully
this makes the naming a bit more descriptive.

This renames vTexCoords and aTexCoords. No functional changes intended.

PiperOrigin-RevId: 433499934
2022-03-09 17:38:35 +00:00
huangdarwin
d06d690d78 Transformer GL: Remove unused setResolution exception javadoc.
PiperOrigin-RevId: 433467719
2022-03-09 14:55:33 +00:00
hschlueter
140be836dd Use background thread for FrameEditor's OpenGL calls.
If an OpenGL call blocks because the encoder's input surface is full,
this will now block the background thread while the main thread can
continue querying encoder output and free up encoder capacity until
it accepts more input unblocking the background thread.

PiperOrigin-RevId: 433283287
2022-03-09 15:12:28 +00:00
samrobinson
3ef4f6ff24 Disable calculating SSIM on instrumentation tests.
PiperOrigin-RevId: 433237266
2022-03-09 15:10:24 +00:00
claincly
2f4630a8e8 Improve resolution fallback logic.
With the new version, we try the following before fixing resolution:

- Fix size alignment
- Try 3/4 the width and height
- Try 2/3 the width and height
- Try 1/2 the width and height

Also: align the resolution ends in 1 or 9 to 0.
PiperOrigin-RevId: 433206358
2022-03-09 15:08:15 +00:00
samrobinson
a349f311d4 Nit cleanup of SsimHelper.
PiperOrigin-RevId: 433174767
2022-03-09 15:07:15 +00:00
claincly
5ab32b6e0d Record transformation duration in TransformerAndroidTestRunner.
The change will be useful in testing transcoding performance

PiperOrigin-RevId: 432956283
2022-03-09 15:03:10 +00:00
samrobinson
743c6cf5f8 Remove SSIM calculation on audio only output.
PiperOrigin-RevId: 432937645
2022-03-09 15:02:02 +00:00
samrobinson
04ed774bef Add regression test forcing encode/decode.
PiperOrigin-RevId: 432928418
2022-03-09 15:01:00 +00:00
claincly
461effc6c2 Use getSupportedWidth/HeightFor() API for finding resolution.
Previously, we've used getSupportedHeights/Widths() to find the supported
resolution. However, the height/width can be over-reported when using these
APIs. For example, getSupportedWidths and getSupportedHeights can both return
3840, but the supported height when using 3840 as width is only 2160.

PiperOrigin-RevId: 432926192
2022-03-09 15:00:00 +00:00
claincly
6ae2629c60 Add method to disable passthrough.
PiperOrigin-RevId: 432461547
2022-03-04 17:15:16 +00:00
samrobinson
0316c03319 Move AndroidTestUtil run methods to a TransformerAndroidTestRunner.
This will allow for easier customisation of the additional tasks
performed by the test runner, such as calculating metrics like SSIM.

PiperOrigin-RevId: 432434850
2022-03-04 14:52:55 +00:00
hschlueter
273d80c4a0 Use asset with increasing timestamps for matrix transformation test.
PiperOrigin-RevId: 431658068
2022-03-03 12:13:46 +00:00
hschlueter
0bc9470ce5 Don't delete textures before destroying OpenGL context.
Destroying the context destroys all of OpenGL (see
https://www.khronos.org/opengl/wiki/OpenGL_Context), so deleting
textures is redundant.

PiperOrigin-RevId: 431653728
2022-03-03 12:11:56 +00:00
hschlueter
422dfe0f95 Add an instrumentation unit test for TransformationFrameProcessor.
This test tests the same cases as the FrameEditorDataProcessingTest
as currently the main FrameEditor functionality is to apply a
transformation matrix using a TransformationFrameProcessor.

PiperOrigin-RevId: 431642066
2022-03-03 12:11:00 +00:00
samrobinson
d187df9afe Restructure regression androidTests, adding a 4k60 video and test.
Test list can be structured so tests don't need to be in different
classes, cleaning up the location of new test cases.

PiperOrigin-RevId: 431492941
2022-03-01 09:47:53 +00:00
claincly
50ac89eb82 Add SSIM support to AndroidTestUtil.
PiperOrigin-RevId: 431479473
2022-03-01 09:47:11 +00:00
hschlueter
da9aa4fded Use Color helper for packing in BitmapTestUtil.
PiperOrigin-RevId: 431451974
2022-03-01 09:46:31 +00:00
claincly
f3cc75cf58 Add SSIM helper for transcoding quality measurements.
We use SSIM to measure the transcoding quality between. SSIM is a widely used
tool that compares the luma channel between two images, and generates a score
from 0 to 1 that indicates "how similar" the two images are.

In `SsimHelper`, we decode the two videos, extract matching frames and
calculates the mean SSIM (SSIM averaged all matching frames) for both videos.
Matching frames are referred to as "comparisonFrame" in the CL, which is
selected based on the frame number and a user-set comparison interval.
For instance, if the interval is 7, then every seventh frames are compared.

We use MediaCodec/MediaExtractor to decode the video, and use ImageReader to
extract the decoded frame.

The SSIM calculation logic is a inspired by and modified from the CTS
[MSSIMMatcher](https://cs.android.com/android/platform/superproject/+/master:cts/tests/tests/uirendering/src/android/uirendering/cts/bitmapcomparers/MSSIMComparer.java;l=1?q=mssimcom)
that has some errors and extra features we don't need (like handling RGB
images).

Adds TranscodeQualityTest to ensure high quality transcoding.

PiperOrigin-RevId: 430951206
2022-03-01 09:40:52 +00:00
samrobinson
8d852f3a99 Allow the difference Bitmap to be saved to device cache.
When investigating how 'bad' a failure is, it's useful to see the diff
between input and output bitmaps.

PiperOrigin-RevId: 430917732
2022-03-01 09:39:19 +00:00
hschlueter
6779290724 Move bitmap helpers to new BitmapTestUtil class.
These helpers will also be useful for future frame processor tests
outside FrameEditorDataProcessingTest.

PiperOrigin-RevId: 430409172
2022-02-23 16:19:26 +00:00
hschlueter
650f71d022 Clarify instructions for updating expected output bitmaps.
Also replace the bitmaps with bitmaps obtained by following
the instructions.

PiperOrigin-RevId: 430232369
2022-02-23 16:17:57 +00:00
andrewlewis
5867a3a29c Fix typos
PiperOrigin-RevId: 430220416
2022-02-22 17:05:01 +00:00
ibaker
805959df8b Suppress @VisibleForTesting violation in Transformer
#minor-release

PiperOrigin-RevId: 430200331
2022-02-22 17:03:56 +00:00
andrewlewis
0490839fce Suppress framework muxer lint warning
We need to access internal state to work around resources not being released on
old API versions. Add a reference to the bug about this and suppress the lint
warning.

#minor-release

PiperOrigin-RevId: 430190794
2022-02-22 17:03:06 +00:00
hschlueter
e8977d00c5 Split out ExternalCopyFrameProcessor.
All (later customizable) GlFrameProcessors after the
ExternalCopyFrameProcessor receive their input from a normal OpenGL
texture not an external texture, so they won't need to worry about
the textureTransformMatrix.

PiperOrigin-RevId: 430165652
2022-02-22 17:01:04 +00:00
samrobinson
3851ef3d69 Reduce the length of the FrameEditorDataProcessingTest TAG.
As per f2ad8ccd3c, log tags can not be longer than 23 chars.

PiperOrigin-RevId: 430032243
2022-02-22 10:34:16 +00:00
huangdarwin
3e9d45f0ea Transformer: Work around Samsung/OnePlus decoder dequeueBuffer failed.
#mse-bug-week

PiperOrigin-RevId: 430028245
2022-02-22 10:32:46 +00:00
claincly
a196b5ec43 Re-enable RepeatedTranscodeTransformationTest.
There are two major blockers to this test:

- H265 muxing is not available for API<24, so setting video mimeType to H265
  will fail on those devices.
- AMR audio encoding is buggy on some device and it's not a widely used format.

The solution: use a video that is encoded with AVC/MP3, to ensure transcoding
to AVC/AAC.

PiperOrigin-RevId: 429648598
2022-02-22 10:31:07 +00:00
samrobinson
d7adb94669 Add a new sample file to assets, which has increasing timestamps.
Re-enable tests that have no muxer support for timestamps going backwards.

Tests running on the B-frame sample will be added in a future commit.

#mse-bug-week

PiperOrigin-RevId: 429599177
2022-02-22 10:30:18 +00:00
samrobinson
4b72335d51 Add a TestTransformationResult class for additional test values.
This class will contain additional details such as frame count, once implemented.

#mse-bug-week

PiperOrigin-RevId: 429567678
2022-02-18 16:42:07 +00:00
claincly
99074f703a Improve exception message.
We use the `createForCodec` method that does not take a `MediaFormat` during
transformation, the error message always includes "no configured MediaFormat",
which is false.

PiperOrigin-RevId: 429553573
2022-02-18 16:40:19 +00:00
Ian Baker
38717ce969 Reformat some javadoc 2022-02-18 14:54:02 +00:00
samrobinson
7a5b3b3e5c Save the bitmap produced by the FrameEditorDataProcessingTest to cache.
The bitmap can then be retrieved through ADB.

#mse-bug-week

PiperOrigin-RevId: 429293231
2022-02-17 15:02:09 +00:00
hschlueter
61354497e3 Add enable fallback option to transformer demo.
Also invert disableFallback parameter in DefaultEncoderFactory
to enableFallback. Fallback is still enabled by default.

PiperOrigin-RevId: 429253266
2022-02-17 14:59:32 +00:00
andrewlewis
b96787d374 Avoid attempting to mux out of order pre-API 25
Calling `MediaMuxer.writeSampleData` can block indefinitely on old API versions. It is better not to call this method to fail quickly with an exception rather than getting stuck.

Based on on-device testing media muxer doesn't generally handle out of order samples before API 25. There are a small number of devices where this does succeed but it seems preferable to turn this off everywhere to keep the code simple and have consistent behavior. Once we switch to in-app muxing this limitation will no longer apply.

#mse-bug-week

PiperOrigin-RevId: 429070255
2022-02-17 11:52:24 +00:00
samrobinson
1af841698f Add exception information to AndroidTest analysis file.
Tested:
  Verified that the additional information is available through
  instrumentation tests, as well as via manual testing.

#mse-bug-week

PiperOrigin-RevId: 429038695
2022-02-17 11:52:23 +00:00
andrewlewis
677c5dc6d4 Skip tests requiring out of order muxing pre API 25
PiperOrigin-RevId: 429029496
2022-02-17 11:52:23 +00:00
kimvde
f8d8bfb664 Handle player release timing out in transformer
- The resources were released twice before, which is not necessary since
  the MSG_RELEASE message is already in the internal player queue.
- The demo app was failing because the stop watch was stopped in
  onTransformationError after being reset.

#minor-release
#mse-bug-week

PiperOrigin-RevId: 428794426
2022-02-17 11:52:23 +00:00
hschlueter
3cd23de1cb Split GlFrameProcessor out of FrameEditor.
The GlFrameProcessor handles everything related to the GLSL program,
the FrameEditor manages the GL context and the data flow including
the input SurfaceTexture and output EGLSurface.

This will be split up further in follow-up CLs so that
GlFrameProcessors can be chained. At this CL, there are no
functional changes intended.

PiperOrigin-RevId: 428779179
2022-02-17 11:52:23 +00:00