327 Commits

Author SHA1 Message Date
huangdarwin
2a363ac3fc Transformer: Always use FrameProcessorChain when decoding.
This allows us to bypass many device-specific issues, that only occur when
decoding directly to an encoder surface, without OpenGL. This also allows us
to maintain fewer code branches, which require additional testing to verify
correctness.

PiperOrigin-RevId: 437003138
2022-03-24 15:42:12 +00:00
huangdarwin
5bc94da16a FrameProcessor: Create PresentationFrameProcessor.
Allow apps to modify how frames are presented, via modifying resolution.

A follow-up CL will provide aspect ratio, cropping, etc.

PiperOrigin-RevId: 436963312
2022-03-24 11:42:05 +00:00
hschlueter
c5e8503e2c Increase test frame processing wait time.
PiperOrigin-RevId: 436961627
2022-03-24 11:29:52 +00:00
hschlueter
831866f441 Add javadoc for more FrameProcessorChain fields.
PiperOrigin-RevId: 436723149
2022-03-23 13:36:22 +00:00
samrobinson
76d44bec30 Remove SSIM calculation on SEF videos.
SEF is similar to frame editing, where the input and output videos are
not intended to match, so SSIM will not provide a reliable value. To
check SSIM correctly in future, we would need to provide
golden/expected video files to compare output against.

PiperOrigin-RevId: 436707240
2022-03-23 11:56:30 +00:00
hschlueter
bda6604757 Remove FrameEditor reference.
PiperOrigin-RevId: 436702840
2022-03-23 11:25:58 +00:00
andrewlewis
89098a8a83 Remove analysis error suppression
PiperOrigin-RevId: 436470453
2022-03-22 14:42:02 +00:00
hschlueter
e14b8b0c6e Remove unnecessary 'final' from local variables.
PiperOrigin-RevId: 436469107
2022-03-22 14:35:19 +00:00
hschlueter
ecfbc65a0d Convert FrameEditor to a FrameProcessorChain.
The FrameProcessorChain manages a List<GlFrameProcessor>.
FrameProcessorChainDataProcessingTest now tests chaining ScaleToFit-
and AdvancedFrameProcessors.

PiperOrigin-RevId: 436468037
2022-03-22 14:29:53 +00:00
huangdarwin
57953d8947 FrameProcessor: Make a class member private final.
PiperOrigin-RevId: 436211808
2022-03-21 15:21:17 +00:00
samrobinson
a60e5f597b Force video encoding if VideoEncoderSettings are not default.
Add a MH test exercising this behaviour.

PiperOrigin-RevId: 436177198
2022-03-21 12:16:50 +00:00
huangdarwin
2a14e3c604 FrameProcessor: Add a ScaleToFitFrameProcessor builder.
This allows us to input scale and rotation in an easier-to-use manner.

PiperOrigin-RevId: 436175982
2022-03-21 12:08:18 +00:00
andrewlewis
0292f82ddf Fix end of stream detection for SSIM helper
PiperOrigin-RevId: 436165237
2022-03-21 11:00:21 +00:00
andrewlewis
9e62ea3fca Move image buffer extraction to test thread
This also ensures that if there's an error reading the image data then this
gets surfaced as an analysis exception.

PiperOrigin-RevId: 435680785
2022-03-18 17:55:26 +00:00
claincly
12543a9682 Split method findEncoderWithClosestFormatSupport.
Add checking for bitrate mode settings.
Add logging to the encoder filtering.

PiperOrigin-RevId: 435662418
2022-03-18 16:43:26 +00:00
andrewlewis
db0093f4c8 Remove AMR NB encoding from SSIM quality test
This currently causes the test to fail on Pixel 6 Pro running a recent S build
SQ1D.220205.004.

There is no need to test audio transcoding while we are measuring video
quality.

PiperOrigin-RevId: 435635314
2022-03-18 14:42:49 +00:00
hschlueter
96f8771de0 Always use FrameEditor for Nexus 5 and Moto Z Play.
PiperOrigin-RevId: 435628703
2022-03-18 14:10:07 +00:00
claincly
e476337dd5 Add encoding options.
PiperOrigin-RevId: 435398814
2022-03-17 18:22:42 +00:00
huangdarwin
481b9bd63d Transformer: Split javadoc summary fragment and descriptive text.
PiperOrigin-RevId: 435368283
2022-03-17 16:33:35 +00:00
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