471 Commits

Author SHA1 Message Date
huangdarwin
45f6c24bf2 HDR: Implement ForceInterpretHdrVideoAsSdr
Also, document that we tone map when no HDR features are explicitly set

PiperOrigin-RevId: 487310971
(cherry picked from commit 2ff5dab0039c44d767dc831fec92724254e5e0aa)
2022-11-09 20:05:24 +00:00
claincly
e57838d7f5 Set HDR color info on FrameworkMuxer
Not setting the color info results in a missing "colr" box in the produced
container, under file/moov/trak/mdia/minf/stbl/stsd/hvc1. This means extractors
will not be able to find out the transcoded file is HDR.

In `Transformer`, this means it can't transcode this transcoded file, because
it currently relies on the container bearing HDR info to construct the
transcoding sample pipeline.

PiperOrigin-RevId: 487276712
(cherry picked from commit 3c74e076fef6ef9ae892dcfda9026ae1be83c1b0)
2022-11-09 18:05:24 +00:00
sheenachhabra
bc3aef081e Change UnsupportedEncodingException to IllegalArgumentException
In startTransformation method we were throwing UnsupportedEncodingException (IOException) when mediaItem with unsupported arguments is passed.
Changed this to IllegalArgumentException which seems more logical here.

PiperOrigin-RevId: 487259296
(cherry picked from commit 818bf4a20a4bb55d57e26b6c200c9857d4caf659)
2022-11-09 17:00:14 +00:00
kimvde
c89ceb878d Add ExoPlayerAssetLoader
Just move some code around for now, to start setting up the overall
structure.

PiperOrigin-RevId: 487229329
(cherry picked from commit 95f37b4df8475e5eaf09da0a5d4dee04a81646a0)
2022-11-09 14:45:12 +00:00
kimvde
5976955241 Move slow mo logic to sample pipelines
This is to avoid having this logic in TransformerInternal once it is
added.

PiperOrigin-RevId: 487159941
(cherry picked from commit 714e5565053ad48ec23b1f1640851a1e784a6726)
2022-11-09 08:25:53 +00:00
kimvde
9dfa32fe84 Move muxing inside sample pipelines
This logic is currently in the player renderers. With multi-asset, the
renderers will go into the AssetLoader, which shouldn't be responsible
for muxing.

PiperOrigin-RevId: 486860502
(cherry picked from commit 61471474c7441d60a5d452d9acd8a1a2a1c88ca6)
2022-11-08 07:25:42 +00:00
sheenachhabra
64c87a5fa1 Move muxer initialization off application thread
Problem: We are initialising muxer as soon as we start the transformation. Now the startTransformation() method can be called from main thread, but muxer creation is an I/O operation and should be not be done on main thread.

Solution: Added lazy initialisation of muxer object. The actual transformation happens on background thread so the muxer will be initialised lazily from background thread only.

Another way was to provide an initialize() method on MuxerWrapper which will explicitly initialise muxer object but with this approach the caller need to call the initialise method before calling anything else. With current implementation the renderers are calling MuxerWrapper methods on various callbacks (Not sequentially) and also we are sharing same muxer with multiple renderers so It might become confusing for the caller on when to call the initialise() method. Also there are few methods on MuxerWrapper which dont really need muxer object. So in short it might make MuxerWrapper APIs more confusing.

Validation: Verified the transformation from demo app.
PiperOrigin-RevId: 486735787
(cherry picked from commit eb357654bbd11f6304a6f5495bb209e59307dfcb)
2022-11-07 20:38:44 +00:00
huangdarwin
a42050f441 HDR: Set decoder codec profile and level if available.
This should be necessary to ensure decoders see fewer errors.

Setting this resulted in removing native_dequeueOutputBuffer errors on OMX.MTK decoders for in-app tone mapping prototyping.

PiperOrigin-RevId: 486715941
(cherry picked from commit e510d9903ff30c4ec308bdcfba114e8889aad20c)
2022-11-07 19:21:21 +00:00
huangdarwin
b770eb86b2 HDR: Update test FileUtil to handle null ColorInfo.
PiperOrigin-RevId: 486706595
(cherry picked from commit 23e724a00be4e286505a9a4bed8f291787b579a6)
2022-11-07 18:49:14 +00:00
huangdarwin
99bb183c35 HDR Test: Add link to tested method.
PiperOrigin-RevId: 485890141
(cherry picked from commit 58b32b61291648b35fb696ae547d03698b6062b1)
2022-11-03 16:13:17 +00:00
huangdarwin
a66dfa87a4 Apply tone mapping workaround to Pixel Watch as well.
Not sure what BUILD.ID the fix will first be applied on though.

PiperOrigin-RevId: 485389618
(cherry picked from commit 91b286c4f813cdecf3999319c3b2c73fbee3c00a)
2022-11-01 19:36:40 +00:00
huangdarwin
9b81c2d114 HDR: Generalize Pixel 6 workaround to TP
PiperOrigin-RevId: 485366659
(cherry picked from commit a65ff85a98f25ae73a08842f1f3f6c5d1433e7e9)
2022-11-01 18:09:01 +00:00
samrobinson
3449734b9a Disable the muxer watchdog if all tracks have ended.
PiperOrigin-RevId: 484512661
(cherry picked from commit bcc2fe40078924a672ffce97f42aaa44e0ad7526)
2022-10-28 13:13:05 +00:00
kimvde
2a809dcebd Add test for muxer watchdog timer
PiperOrigin-RevId: 484298261
(cherry picked from commit 1730334133cfac2a90144bfc88a324e270154688)
2022-10-27 18:01:11 +00:00
kimvde
868375ead1 Add muxer timer to detect when generating an output sample is too slow
This allows to throw when the Transformer is stuck or is too slow.

PiperOrigin-RevId: 484179037
(cherry picked from commit 16cb5cbc1f6f729d39bf8747e7c0a0f7aea7326d)
2022-10-27 07:58:56 +00:00
samrobinson
35900f94fa Move AudioProcessor to common.
PiperOrigin-RevId: 483699606
(cherry picked from commit fc34542864dac5045d0fb460fd51c6bb2f1112c6)
2022-10-25 16:40:38 +00:00
samrobinson
6dd0ace992 Add CanIgnoreReturnValue to AudioProcessor#configure + implementations
Although it can be useful to check the output format, it's not required or needed.

For some AudioProcessor implementations, it is stated/obvious that
the output format will match the input, in which case there is no
a need to check the return value.

#cleanup

PiperOrigin-RevId: 483403679
(cherry picked from commit 8723e74b1f48377ea8962247e10ee54252dd2de3)
2022-10-24 16:27:18 +00:00
kimvde
f10021ff7f Remove muxerFactory dependency on playerListener
This listener will need to be passed to the MuxerWrapper to throw when
the Transformer is stuck.

PiperOrigin-RevId: 482433552
(cherry picked from commit e6d5595545ac4e0715b8b914a9a4b4a2757911d7)
2022-10-20 09:36:28 +00:00
kimvde
b0ad5c2681 Make Muxer public
The reason for making the Muxer public is that we want to add an option
to disable or configure the timer that will throw when the muxer doesn't
receive any data for a given period of time.

PiperOrigin-RevId: 482199360
(cherry picked from commit cf14d0687db5b8c0ea9edeae67a0b91affacbcd8)
2022-10-19 14:31:06 +00:00
kimvde
b5af908e53 Remove deprecated setOutputMimeType
This is to prepare Muxer to become public

PiperOrigin-RevId: 481893842
(cherry picked from commit 9221b1251cc1c614e4edc421c847f8fa2ce329a6)
2022-10-18 12:26:36 +00:00
samrobinson
130edf8f26 Fix parameter comment block.
#cleanup

PiperOrigin-RevId: 481882181
(cherry picked from commit 7ac7e643acb3486e5c7004e35ad3c214d47c1860)
2022-10-18 11:13:44 +00:00
kimvde
34dd66d674 Add DefaultMuxer forwarding to FrameworkMuxer
- The naming DefaultMuxer is more consistent with the rest of
Transformer codebase (e.g. DefaultEncoderFactory).
- By hiding the implementation details of DefaultMuxer, the transition
to in-app Muxer will be seamless for apps using DefaultMuxer.
- The current plan is that DefaultMuxer will become the in-app muxer.

PiperOrigin-RevId: 481838790
(cherry picked from commit 3399f4ecdfd0354f49a8599d04e4cc68295f2af5)
2022-10-18 07:23:57 +00:00
kimvde
7a488a192b Remove supportsSampleMimeType from Muxer.Factory
- This method is redundant with getSupportedSampleMimeTypes().
- This is to prepare the Muxer class to become public.

PiperOrigin-RevId: 480840902
(cherry picked from commit 2786db9e73505a8d6d4c4f2c284aacb605006ab8)
2022-10-13 09:52:26 +00:00
huangdarwin
355d81c6bb HDR: Disable tone mapping on unsupported pixel build ID.
Also, update tests to allow AnyOf error codes, and no longer check exception messages, which caused quite a bit of churn.

PiperOrigin-RevId: 479570861
(cherry picked from commit 8548e3519e3d6ef214d5c18d640a8bf6efe19c83)
2022-10-07 13:57:06 +00:00
huangdarwin
4449ba9c99 HDR: Check isToneMappingApplied in HDR editing test.
Assert that tone mapping is applied when an HDR edit cannot be HDR, but is successfully tone mapped. Meanwhile, assert that fallback, which is applied after codec configuration (which throws the "Tone-mapping requested but not supported by the decoder" error) is not applied when that error is called.

PiperOrigin-RevId: 478762951
(cherry picked from commit 253486d4af057776da0eb5926e31190f43dbe3b3)
2022-10-04 13:01:27 +00:00
huangdarwin
186f516b65 HDR: Add tests with HLG10 input.
PiperOrigin-RevId: 478019046
(cherry picked from commit 6e5a4c05b5f4404b09628ae9e9029d046b601865)
2022-09-30 17:02:37 +00:00
huangdarwin
3fd8e47245 Test: Rename to avoid redundant substrings.
Rename test files to avoid substrings that can be implied by the directory name,
like "Transformation" and "Test"

No functional changes. Renaming-only.

PiperOrigin-RevId: 477724724
(cherry picked from commit 62b95a71902349e95693174f83bb48e6927d5249)
2022-09-29 14:54:25 +00:00
huangdarwin
55a7316158 HDR: Add period to end of error message.
For tone mapping error messages.

PiperOrigin-RevId: 477447799
(cherry picked from commit 1711d7f4c2de8ccd7e5a476c79cdf51685ca7334)
2022-09-28 14:30:48 +00:00
huangdarwin
875766ddfe HDR: Add tests for tone mapping.
Also, add checks for output file color.

PiperOrigin-RevId: 477439139
(cherry picked from commit aec4fe738709b3ca564c5309d8623bfbf1298c33)
2022-09-28 13:42:36 +00:00
huangdarwin
ab37184917 HDR: Assert output C.ColorTransfer for tests.
To confirm that tone mapping did or did not happen.

PiperOrigin-RevId: 476354606
(cherry picked from commit 87fd51a39b784707d9f28caac6fa6d6abc6b8b33)
2022-09-23 13:33:28 +00:00
leonwind
63f9df5b1a Add OETF and EOTF ES2 fragment shaders for non-HDR frames.
* Transform the intermediate color space to linear SDR by applying the SMPTE 170M EOTF and OETF.
* Use linear colors for the color filter pixel tests and update all golden bitmaps.

PiperOrigin-RevId: 476124592
(cherry picked from commit 3433758c3b1f02c0ec28b86a8c3b659171f6f92b)
2022-09-22 16:45:28 +00:00
samrobinson
7ce758f40b Add file size to TransformationResult at the end of a Transformation.
Tested:
  * Manually using both path and file descriptor.
PiperOrigin-RevId: 475860978
(cherry picked from commit 9ec4e1340a97472c63e9f017f95f2b1a38f88588)
2022-09-21 17:18:42 +00:00
samrobinson
c7cd3b9c91 Add support for skipping windows in MssimCalculator.
By skipping every other row and column, SSIM calculation time reduces by 10-30%.

PiperOrigin-RevId: 474286702
(cherry picked from commit 314b312af18c568c5353b661b31ebc60a0736678)
2022-09-14 14:35:12 +00:00
samrobinson
eeba63ab3e Add MssimCalculatorTest to verify SSIM calculations.
As part of this change, MssimCalculator is moved from androidTest/ to main/

PiperOrigin-RevId: 473771344
(cherry picked from commit 8ce42f0670504a89c5c3e546f8be3d849be36195)
2022-09-12 16:45:36 +00:00
samrobinson
8085fe22f5 Rollback of 3d5ddf0c42
*** Original commit ***

Handle int instead of byte in SSIM.

The value of pixels are converted to integers at the point of use,
move this logic to the initialisation step.

This is a prerequisite step for testing SSIM calculation, which
will lead on to some SSIM improvements being verifiable.

Tested manually and SSIM values match for the same video
before and after this change.

***

PiperOrigin-RevId: 473259446
(cherry picked from commit d188babd2daea5b737ef43604aa00baf157a2df5)
2022-09-09 15:33:08 +00:00
samrobinson
88584c311d Handle int instead of byte in SSIM.
The value of pixels are converted to integers at the point of use,
move this logic to the initialisation step.

This is a prerequisite step for testing SSIM calculation, which
will lead on to some SSIM improvements being verifiable.

Tested manually and SSIM values match for the same video
before and after this change.

PiperOrigin-RevId: 473231779
(cherry picked from commit 3d5ddf0c42f1d2b91d4ef33c75f59656c6e566bc)
2022-09-09 13:07:14 +00:00
huangdarwin
60737f66a6 Decoder: Reduce max pending frame count limit down to 5.
PiperOrigin-RevId: 473212543
(cherry picked from commit 4133bb6070fd1bb000958000d2d4b953cbfc0576)
2022-09-09 10:56:03 +00:00
huangdarwin
0a13578989 HDR: Add fallback MH tests.
Test that HDR editing succeeds on devices supporting HDR editing, tone maps on
devices supporting tone mapping, and throws exceptions on all other devices.

Also, only restrict HDR editing and tone mapping support to API 31+ only when
transcoding, not for all transformations.

PiperOrigin-RevId: 472958965
(cherry picked from commit 0d8fd3d4fc1da31c05fa82bb5e815332a6c7fa12)
2022-09-08 12:03:40 +00:00
claincly
1ded03ce13 Remove conditional check for no-longer flaky API version
PiperOrigin-RevId: 472949850
(cherry picked from commit 8b7638bed352ced64e176b068a6524141a3fbf5c)
2022-09-08 11:02:51 +00:00
claincly
17cc7b59b8 Remove redundant constant definition
PiperOrigin-RevId: 472522846
(cherry picked from commit c401fb9771454e48b2b7eddba281ddda0ca5e398)
2022-09-06 19:06:17 +00:00
claincly
18188ebe01 Include CamcorderProfile resolution in encoder capability test
PiperOrigin-RevId: 472459423
(cherry picked from commit 3f6a59f0f776e160aa88e69af69aa5749f594f2a)
2022-09-06 15:05:46 +00:00
huangdarwin
c4fa1978b8 Minor javadoc and scoping cleanup.
No functional changes.

PiperOrigin-RevId: 472245797
(cherry picked from commit fa1f09fc51ea7a54052562e6a40e48e55fed4a67)
2022-09-05 11:06:21 +00:00
huangdarwin
eac4829406 Rename shouldPassthrough to shouldTranscode
shouldPassthrough's internal checks seem to be check whether we should *not*
pass through, which seemed a bit like a confusing double-negative to me.

shouldTranscode is slightly more clear, by instead returning true when we do
want to transcode.

No functional changes intended.

PiperOrigin-RevId: 471753771
(cherry picked from commit 7085c2fa6e90834b7ace3b22b16d9f14f5e9eb66)
2022-09-02 09:49:26 +00:00
Googler
15f8e361b6 Skip transcoding if HDR video does not need encoding.
3b0d2c1586 made `shouldPassthrough` always return false for `enableHdrVideoEditing`:

>We force using `FrameEditor` (no passthrough) to avoid the need to select another edit operation, and use the new shaders. The `EGLContext` and `EGLSurface` also need to be set up differently for this path.

However, this was introduced before the `videoNeedsEncoding` setting was introduced in 3f615040c0. That setting should apply to HDR videos as much as SDR videos.

PiperOrigin-RevId: 471569853
(cherry picked from commit bc88f8be54b5c666d9ad591c04ac9faa4457454a)
2022-09-01 17:37:30 +00:00
ibaker
30e55ad772 Remove media3-only line from exoplayer2 build.gradle file
#minor-release

PiperOrigin-RevId: 470999044
(cherry picked from commit 932f0d2248d1779940c7d5e7cbb9c214222321c0)
2022-08-30 15:27:12 +00:00
andrewlewis
19fad593e5 Update color info mismatch test
This should now expect transformation to succeed.

PiperOrigin-RevId: 470950411
(cherry picked from commit daf1e5e2eb536d6f4fa6ccb2b7234d474bfcd248)
2022-08-30 11:02:46 +00:00
andrewlewis
f3adc5a5d2 Log instead of throwing for transfer mismatch
PiperOrigin-RevId: 470354448
(cherry picked from commit dbe66775518a02c138e138a990939729bd9a3b23)
2022-08-26 23:08:53 +00:00
Googler
373ac4c7bd Change onOutputFrameAvailable timestamp from nanos to micros.
Upstream timestamps from the decoder are also in microseconds,
so using microseconds here is consistent with that.

PiperOrigin-RevId: 468659099
(cherry picked from commit 0b1c540ff96b4f4f4ff7cff16a2e51674a42a0c2)
2022-08-19 09:47:28 +00:00
Googler
166838ae70 Allow frame release to be controlled outside FrameProcessor.
Adds a method to FrameProcessor.Listener to be called when an
output frame is available and a method releaseOutputFrame in
FrameProcessor allowing the caller to trigger release of the
oldest available output frame at a given timestamp. Late frames
or frames with unset release times are dropped in the
FinalMatrixTransformationProcessorWrapper.

More than one output frame can become available before they are
released if the penultimate GlTextureProcessor is capable of producing
multiple output frames. Processing continues while waiting for
releaseOutputFrame to be called. Frame release tasks are prioritized
over other tasks.

PiperOrigin-RevId: 468473072
(cherry picked from commit a5d7fdcab52ea6c12fa35efc348b69eccb53f715)
2022-08-18 16:10:48 +00:00
huangdarwin
da10c96229 HDR: Clarify tone mapping fallback.
createSupportedTransformationRequest is more accurate than
createFallbackTransformationRequest, as a TransformationRequest will be returned
regardless of whether any fallback is applied.

PiperOrigin-RevId: 466641277
(cherry picked from commit c5a5364673749cb737be3df92c9521fc15207658)
2022-08-10 11:25:56 +00:00