1508 Commits

Author SHA1 Message Date
dancho
ae240606db Move bitmap coordinate flip out of fragment shader
Fragment shaders in OpenGL ES shader language aren't guaranteed
to support highp, required to correctly represent pixel coordinates
inside large images (e.g. 1920x1080).
This change moves coordinate mirroring for images out of fragment shader.

Fixes http://Issue: androidx/media#1331

PiperOrigin-RevId: 635732208
2024-05-21 02:31:43 -07:00
dancho
b047e81e02 Work around SurfaceTexture implicit scale
If MediaCodec allocates passes an image buffer with a cropped region,
SurfaceTexture.getTransformMatrix will cut off 2 pixels from each dimensions.
The resulting videos will appear a little stretched.

This patch inspects the SurfaceTexture transform matrix, and guesses what the
unscaled transform matrix should be.
Behind experimentalAdjustSurfaceTextureTransformationMatrix flag

PiperOrigin-RevId: 635721267
2024-05-21 01:46:21 -07:00
samrobinson
07ddc0fca5 Add debug trace for Muxer completely ending.
PiperOrigin-RevId: 635459757
2024-05-20 08:12:57 -07:00
claincly
dc4f20ed84 Fix image seeking
Queue image again after position reset, and reset timestamp iterator.

PiperOrigin-RevId: 635049953
2024-05-18 07:41:14 -07:00
dancho
b9ec24a269 Fix AV sync for sequences with audio track shorter than video
For each item, AudioGraphInput now pads the input audio track with silence
to the duration given in onMediaItemChanged.

Possibly resolves Issue: androidx/media#921 .

PiperOrigin-RevId: 634753721
2024-05-17 06:54:39 -07:00
samrobinson
1abcf5c22c Add debug trace log for AssetLoader Renderer format events.
PiperOrigin-RevId: 634474584
2024-05-16 11:32:13 -07:00
claincly
f0e420e101 Use List in createRenderers for better readability
Also Use `Iterables.toArray()` to void the confusing `List.toArray()` method call

PiperOrigin-RevId: 634351844
2024-05-16 06:04:58 -07:00
kimvde
e23cc756e2 Handle playToEndOfStream called before configuring the audio sink
ExoPlayer sometimes calls AudioSink.playToEndOfStream before configuring
the sink. Before this CL, the composition player was failing if this
happened.

PiperOrigin-RevId: 634306592
2024-05-16 04:19:36 -07:00
samrobinson
5c6f48ecaf Add debug trace logs for AudioMixer & AudioGraph events.
PiperOrigin-RevId: 633973723
2024-05-15 09:06:34 -07:00
ibaker
0e5a5e0294 Publish CompositionPlayer for playing compositions
This class is not ready for production app usage yet, so it is still
marked `@RestrictTo(LIBRARY_GROUP)` for now. Apps can experiment with it
in a non-prod context by suppressing the associated lint error.

* Issue: androidx/media#1014
* Issue: androidx/media#1185
* Issue: androidx/media#816

PiperOrigin-RevId: 633921353
2024-05-15 05:55:08 -07:00
ibaker
ed4820cb61 Remove @UnstableApi from package-private files
This annotation is only needed on public classes.

This change also removes the `/* package */` comment from some `public`
classes.

PiperOrigin-RevId: 633864544
2024-05-15 02:26:55 -07:00
tofunmi
f7390faeb0 Update supported image formats in line with platform standards
This treats heic as a separate mimetype to heif (even though heic files are a subset of heif files). This is in line with other platform classes like android.content.ContentResolver

https://developer.android.com/media/platform/supported-formats#image-formats was updated to include avif support or API level 34, so added this MimeType as well and updated our associated util.

solves Issue: androidx/media#1373

PiperOrigin-RevId: 633616214
2024-05-14 09:50:38 -07:00
Googler
55b9c391e8 Box: Implement ctts box
Add ctts box implementation to handle muxing B-frame videos.
Add method convertPresentationTimestampsToCompositionOffset to
provide sample offsets. Return empty ctts box in case of video
does not contain B-frame. Add ctts box to MoovStructure to handle
muxing the video containing B-frames.

PiperOrigin-RevId: 633537106
2024-05-14 04:32:04 -07:00
tonihei
cf1f9b04cf Add more predefined priority values
Also add documentation that suggests to use them in
PriorityTaskManager and adjust codec priorities in
Transformer's DefaultDe/EncoderFactory accordingly.

PiperOrigin-RevId: 633272667
2024-05-13 11:18:41 -07:00
samrobinson
acf1ede644 Add debug trace logs for input/output events for codecs.
PiperOrigin-RevId: 633244952
2024-05-13 10:01:47 -07:00
samrobinson
04ab71a1d4 Remove component names from event strings.
PiperOrigin-RevId: 633212723
2024-05-13 08:06:44 -07:00
sheenachhabra
3a3145521b Replace Transformer.Muxer interface with Muxer.Muxer
PiperOrigin-RevId: 633193701
2024-05-13 06:54:19 -07:00
sheenachhabra
5950e884f6 Skip TransformerPauseResumeTest on vivo 1820 and vivo 1906
The process crashes unexpectedly on these devices.

The new changes skips running these tests instead of marking them pass, when
the device needs to be skipped.

PiperOrigin-RevId: 633183638
2024-05-13 06:07:20 -07:00
samrobinson
30624aae6e Pass component of event to debug trace logEvent as parameter.
PiperOrigin-RevId: 633176557
2024-05-13 05:33:31 -07:00
sheenachhabra
71e36ac6d2 Remove missing frame workaround from TransformerPauseResumeTest
Two devices were producing B-frames earlier and were causing
frame mismatch. So we had added a workaround for them.
Those devices does not produce B-frames now
after disabling high profile on them, so we don't need workaround now.

PiperOrigin-RevId: 633127755
2024-05-13 01:35:34 -07:00
tofunmi
1749726bc9 Texture input tests: use separate textures to queue to transformer
Use different textures in calls to queueInputTexture(). Allows the texture to be deleted one it is used in transformer and effect.

PiperOrigin-RevId: 632430866
2024-05-10 02:41:51 -07:00
tofunmi
753f607a81 Test: Remove the invalid dataspace device list when asserting sdr
PiperOrigin-RevId: 632137474
2024-05-09 07:07:51 -07:00
tofunmi
e432005653 make TransformerUtil public
help apps statically calculate what transformer will do with certain inputs without running transformer.

PiperOrigin-RevId: 632087821
2024-05-09 03:06:30 -07:00
tofunmi
ad2fc4fbb1 move Output Mime Type And Hdr Mode Fallback logic to TransformerUtil
allows apps to use the logic statically before running transformer.

Also ensure the mime type reported is the mime type outputted

PiperOrigin-RevId: 631811763
2024-05-08 08:40:01 -07:00
kimvde
9adb532b6c Only set image duration on images in demo app
The Javadoc is stating that the image duration is ignored for non-image
input but this is incorrect (for example, it affects seeking
performance). The Javadoc will be updated in another CL.

PiperOrigin-RevId: 631730980
2024-05-08 03:25:04 -07:00
Copybara-Service
c5964d197c Merge pull request #1055 from AradiPatrik:z-order-fix
PiperOrigin-RevId: 631616905
2024-05-07 18:45:09 -07:00
Luyuan Chen
766ff44a2c Fix review comment 2024-05-08 00:11:21 +00:00
Luyuan Chen
0403e5881d Format with google-java-format 2024-05-08 00:07:38 +00:00
Patrik Aradi
51a9bcca61 Refactor according to reviews. 2024-05-08 00:07:38 +00:00
Patrik Aradi
52adaf8d26 implement top down approach for passing input source id 2024-05-08 00:07:38 +00:00
Luyuan Chen
3cccecf368 Format with google-java-format 2024-05-08 00:07:38 +00:00
Patrik Aradi
84df55c6e8 fix naming and formatting 2024-05-08 00:07:38 +00:00
Patrik Aradi
b909162daa Use sparse array in MultipleInputVideoGraph, fix formatting 2024-05-08 00:07:37 +00:00
Patrik Aradi
177f1f33d0 Fix indeterminate z-order of EditedMediaItemSequences by passing sequenceIndex when registeringInput 2024-05-08 00:07:37 +00:00
claincly
bef3d518d2 Revise seeking in ExternalTextureManager (ETM)
After this CL, DVFP waits for flushing until all frames registered previously
arrives.

Previously, ETM records the difference between the number of registered frames,
and the number of frames arrivd on the SurfaceTexture, when flushing. (Note
that ETM is flushed the last in the chain, as flushing is done backwards from
FinalShaderProgramWrapper). ETM then waits until the number of frames arrive
after flush.

The normal flow is, MediaCodecVideoRenderer (MCVR) registers a new decoded
frame, in `processOutputBuffer()` to DVFP, MCVR call `codec.releaseOutputBuffer()`
to have MediaCodec render the frame, and then the frame arrives in DVFP's ETM.

However there might be a discrepancy. When registering the frame, ETM records
the frame on the calling thread, ~instantly. Later when the rendered frame
arrive, ETM records a frame is available on the task executor thread (or
commonly known as the GL thread). More specifically, when a frame arrives
in `onFrameAvailableListener`, ETM posts all subsequent processing to
the task executor. When seeking, the task executor is flushed as the first
step. It might be a frame that has already arrived on ETM, and the processing
of such frame has already been queued into the task executor; only to be
flushed as a result of flushing the task executor. If this happens, the frame
is considered to be never have arrived. This causes a freeze on the app,
because ETM'll wait until this frame arrives to declare flushing has completed.

PiperOrigin-RevId: 631524332
2024-05-07 13:15:46 -07:00
tonihei
6ac60c6dff Disable enhanced Java 8 desugaring
This avoids that apps have to depend on this additional config

Issue: androidx/media#1312
PiperOrigin-RevId: 631447767
2024-05-07 09:26:36 -07:00
samrobinson
9942255894 Allow any pcm encoding raw input pre-effects in AudioGraphInput.
AudioGraphInput now accepts a range of inputs, as long as the effects
provided modify the audio to be int 16.

As part of this, add the workaround to DefaultCodec to ensure pcm
encoding is correct, and remove parameterized tests that are not valid.

PiperOrigin-RevId: 631404152
2024-05-07 06:39:09 -07:00
tofunmi
b2d30a5722 Fallback to hevc transcoding for hdr AV1 files
PiperOrigin-RevId: 631362735
2024-05-07 03:34:31 -07:00
sheenachhabra
24305c043e Remove forCancellation flag from Transformer/Muxer.release() method
PiperOrigin-RevId: 630337930
2024-05-03 03:18:24 -07:00
claincly
d59f1cb6e3 Add test for seeking composition playback
PiperOrigin-RevId: 630184355
2024-05-02 14:46:39 -07:00
tofunmi
cb4b2ea55c remove degammaing: change setSdrWorkingColorSpace default
The second stage of the changes remove the conversion to linear colors in the SDR effects pipeline by default.

also resolves Issue: androidx/media#1050

PiperOrigin-RevId: 630108296
2024-05-02 10:35:48 -07:00
claincly
45ccc6978a Add setVideoSurface override
Also adds first frame rendered test for playing back compositions.
- This test checks the output pixels using an `ImageReader` to retrieve the
output bitmap

PiperOrigin-RevId: 630100817
2024-05-02 10:14:07 -07:00
samrobinson
cb846f0b0d Move raw audio decoder channel count workaround to DefaultCodec.
PiperOrigin-RevId: 630071329
2024-05-02 08:31:28 -07:00
sheenachhabra
6956d8099a Rename Muxer.addMetadata to addMetadataEntry
This is to make it clear that the method adds a single metadata entry, not a collection of metadata entries.

PiperOrigin-RevId: 629398485
2024-04-30 06:55:50 -07:00
sheenachhabra
bc77cef403 Rollback of 08abc964ab
PiperOrigin-RevId: 629382753
2024-04-30 05:41:45 -07:00
tofunmi
28655d27a7 test: use Ascii.equalsIgnoreCase for device model matching
PiperOrigin-RevId: 629349367
2024-04-30 02:54:38 -07:00
tofunmi
7089253bef Effect:migrate setEnableColorTransfers to setSdrWorkingColorSpace
Part of a two stage change to remove the conversion to linear colors in the SDR effects pipeline by default. Changes the boolean to an intdef, introducing a third option that gets all sdr input into the same colorspace.

This is a planned API breaking change, but this change should not change the behavior of the pipeline.

PiperOrigin-RevId: 629013747
2024-04-29 03:26:58 -07:00
ibaker
5666678d8a Use Dumper.addTime in more places
This ensures that `C.TIME_UNSET` is more clear in dump files. Some of
these call-sites will **never** pass `C.TIME_UNSET`, but it seems
clearest to always use `addTime` and maybe it will ensure when these
sites are copied in future, `addTime` will be used in the new location
too.

PiperOrigin-RevId: 628363183
2024-04-26 04:20:56 -07:00
Googler
08abc964ab Box: Implement ctts box
Add ctts box implementation to handle muxing B-frame videos.
Add method convertPresentationTimestampsToCompositionOffset to
provide sample offsets. Return empty ctts box in case of video
does not contain B-frame. Add ctts box to MoovStructure to handle
muxing the video containing B-frames.

PiperOrigin-RevId: 628346257
2024-04-26 02:57:53 -07:00
tofunmi
5ee6c9b16d ultraHdr test: add checks for devices with invalid color formats
PiperOrigin-RevId: 628101730
2024-04-25 09:37:16 -07:00