392 Commits

Author SHA1 Message Date
hschlueter
990d5ccf4d Use @linkplain for link text that doesn't match symbol name.
PiperOrigin-RevId: 437992927
2022-04-07 15:09:42 +01:00
andrewlewis
35528fd1bf Add support for requesting color transfer to SDR
From Android T onwards `MediaCodec` supports requesting tone-mapping down to
SDR. Add an option to request this behavior and document that it isn't
supported before T. Also add an option in the demo app to try it out.

Tested manually on a prerelease build.

PiperOrigin-RevId: 437765325
2022-04-07 14:44:59 +01:00
andrewlewis
001c6c2dac Remove unnecessary initialization
PiperOrigin-RevId: 437753013
2022-04-07 14:41:24 +01:00
hschlueter
f3c861a6de Check thread name for GL methods.
The thread name is used to verify the thread in both  createOpenGlObjectsAndInitializeFrameProcessors() and processFrame().
Also remove glThread field that was only used for this verification.

PiperOrigin-RevId: 437730804
2022-04-07 14:37:56 +01:00
hschlueter
d1394780ec Fix output viewport size of empty FrameProcessorChain.
Since the output size can be overridden, the viewport should be
ouputWidth/Height and NOT the ExternalCopyFrameProcessor's output size
which matches the input size.

PiperOrigin-RevId: 437256635
2022-04-07 14:17:01 +01:00
hschlueter
9cd37385d0 Remove old TODOs and reassign another TODO.
* The AdvancedFrameProcessor calls use() in updateProgramAndDraw().
* The AdvancedFrameProcessor has the same input and output dimensions.

PiperOrigin-RevId: 437231350
2022-03-25 14:43:01 +00:00
hschlueter
f42d09cf15 Allow frame processors to be set on Transformer.Builder.
Also make GlFrameProcessor, ScaleToFitFrameProcessor, and
AdvancedFrameProcessor public.

PiperOrigin-RevId: 437227388
2022-03-25 14:36:02 +00:00
hschlueter
8dc039c084 Check for GL errors after glClear and glDrawArrays.
These methods can cause errors so we should check for them.
https://www.khronos.org/registry/OpenGL-Refpages/es2.0/xhtml/glClear.xml
https://www.khronos.org/registry/OpenGL-Refpages/es2.0/xhtml/glDrawArrays.xml

PiperOrigin-RevId: 437218519
2022-03-25 14:32:20 +00:00
andrewlewis
f41ebf6c65 Improve throughput on devices requiring workaround
On some devices, decoding gets stuck when the number of frames pending at the
`SurfaceTexture` is too high. We added a workaround that only allows one frame
to be pending at a time. That fixed the issue, however, based on on-device
testing it seems that it's safe to queue more than one frame.

Add a method that returns a safe estimate of the number of frames that can be
pending at a time, and use this to limit the number of frames that can be
released from the decoder but not processed by the frame processor chain.

PiperOrigin-RevId: 437057075
2022-03-25 14:17:50 +00:00
hschlueter
dbe57af553 Configure the frame sizes in FrameProcessorChain instead of caller.
Configuring the frame sizes between frame processors is now the
FrameProcessorChain's rather than the caller's responsibility.
The caller can getOutputSize() and override it for encoder fallback
in configure().

PiperOrigin-RevId: 437048436
2022-03-25 14:14:28 +00:00
hschlueter
4e63bdf3cc Move OpenGL setup to FrameProcessorChain#configure().
The factory method is replaced by a public constructor and
configure() method which configures the input/output surfaces
and handles the OpenGL setup.

This is a prerequisite for removing the responsibility of the
caller to configureSizes() before creating the chain in a follow-up.

PiperOrigin-RevId: 437028882
2022-03-25 14:10:52 +00:00
huangdarwin
40c8dae55b 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
22830dcdd0 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
5afd6af2c4 Increase test frame processing wait time.
PiperOrigin-RevId: 436961627
2022-03-24 11:29:52 +00:00
hschlueter
91bef31e6e Add javadoc for more FrameProcessorChain fields.
PiperOrigin-RevId: 436723149
2022-03-23 13:36:22 +00:00
samrobinson
ee2d7d1e1a 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
4e248cb6f1 Remove FrameEditor reference.
PiperOrigin-RevId: 436702840
2022-03-23 11:25:58 +00:00
andrewlewis
2f24476bb2 Remove analysis error suppression
PiperOrigin-RevId: 436470453
2022-03-22 14:42:02 +00:00
hschlueter
1f00aae373 Remove unnecessary 'final' from local variables.
PiperOrigin-RevId: 436469107
2022-03-22 14:35:19 +00:00
hschlueter
c93b31cc36 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
a74034d6c2 FrameProcessor: Make a class member private final.
PiperOrigin-RevId: 436211808
2022-03-21 15:21:17 +00:00
samrobinson
18388f02c0 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
ea470893cd 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
3f5d723311 Fix end of stream detection for SSIM helper
PiperOrigin-RevId: 436165237
2022-03-21 11:00:21 +00:00
andrewlewis
47b6195340 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
1e50313047 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
3f7b70d4f4 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
274785f583 Always use FrameEditor for Nexus 5 and Moto Z Play.
PiperOrigin-RevId: 435628703
2022-03-18 14:10:07 +00:00
claincly
79a6c806da Add encoding options.
PiperOrigin-RevId: 435398814
2022-03-17 18:22:42 +00:00
huangdarwin
d1b99f0103 Transformer: Split javadoc summary fragment and descriptive text.
PiperOrigin-RevId: 435368283
2022-03-17 16:33:35 +00:00
hschlueter
cd16995877 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
3961cd77db Making mediaCodecName @NonNull in DefaultCodec constructor.
PiperOrigin-RevId: 435045138
2022-03-16 14:34:52 +00:00
claincly
64bad1cfe2 Add test for DefaultEncoderFactory.
PiperOrigin-RevId: 435009545
2022-03-16 11:10:06 +00:00
huangdarwin
4dcb9b66e1 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
e8293915b3 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
371c5c1b2e 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
8763843c84 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
255007623d Clarify GlProgram parameter name.
PiperOrigin-RevId: 434441008
2022-03-15 00:45:50 +00:00
hschlueter
64d174b39c Move inputTexId parameter to GlFrameProcessor#initialize().
This parameter will not change between frames in the near
future.

PiperOrigin-RevId: 433765986
2022-03-15 00:38:59 +00:00
claincly
da2f61e035 Fix namings in SsimHelper.
There's no use of encoders in SsimHelper, changed all to "decoder".

PiperOrigin-RevId: 433730292
2022-03-15 00:32:30 +00:00
huangdarwin
b31cd08d7e 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:48:18 +00:00
huangdarwin
a703223534 Transformer GL: Remove unused setResolution exception javadoc.
PiperOrigin-RevId: 433467719
2022-03-09 14:55:33 +00:00
hschlueter
f5796b2d48 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:37:30 +00:00
samrobinson
82a50154db Disable calculating SSIM on instrumentation tests.
PiperOrigin-RevId: 433237266
2022-03-09 15:30:18 +00:00
claincly
f40f97fa79 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:26:54 +00:00
samrobinson
0770d55c1a Nit cleanup of SsimHelper.
PiperOrigin-RevId: 433174767
2022-03-09 15:23:20 +00:00
claincly
661d7ddedb Record transformation duration in TransformerAndroidTestRunner.
The change will be useful in testing transcoding performance

PiperOrigin-RevId: 432956283
2022-03-09 15:12:53 +00:00
samrobinson
3877171f18 Remove SSIM calculation on audio only output.
PiperOrigin-RevId: 432937645
2022-03-09 15:09:27 +00:00
samrobinson
8adc145fa2 Add regression test forcing encode/decode.
PiperOrigin-RevId: 432928418
2022-03-09 15:05:29 +00:00
claincly
e5c229be00 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:02:07 +00:00