533 Commits

Author SHA1 Message Date
kimvde
0baa4ff621 Reset input capacity when setting external shader program
Before this CL, externalShaderProgramInputCapacity was not reset when
the external shader program was reset (which occurs when  the
InputSwitcher switches to an input with a different ColorInfo). This is
due to a regression introduced in bef3d518d2.

PiperOrigin-RevId: 637869215
2024-05-28 05:55:00 -07:00
tofunmi
9622411b50 Add support for ultra HDR overlays
PiperOrigin-RevId: 637863706
2024-05-28 05:28:03 -07:00
tofunmi
8feaf82768 UltraHdr: Fix calculations to apply gainmap
PiperOrigin-RevId: 636964921
2024-05-24 10:39:36 -07:00
tofunmi
db6144e7dd Maintain a consistent luminance range across HDR content in effects
PQ and HLG have different luminance ranges (max 10k nits and max 1k nits resp). In GL, colors work in a normalised 0 to 1 scale, so for PQ content, 1=10k nits and and for HLG content, 1=1k nits.

This cl scales and normalises PQ content appropriately so that all HDR content works in the HLG luminance range. This fixes two things

1. Conversions between HLG and PQ are "fixed" (before the output colors looked too bright or too dark depending on which way you are converting)
2. color-altering effects will be able to work consistently across HLG and PQ content

1 is tested in this cl. 2 will be tested when ultra HDR overlays are implemented, both cases have been manually tested to ensure the output looks correct on a screen.

PiperOrigin-RevId: 636851701
2024-05-24 03:05:34 -07:00
andrewlewis
174d452bf7 Add missing module registrations
PiperOrigin-RevId: 636506860
2024-05-23 04:50:01 -07:00
samrobinson
b6ce35d741 Migrate debug trace logs to track generic events for Muxer.
Track information is added to the details string where relevant.

PiperOrigin-RevId: 635815866
2024-05-21 08:33:12 -07:00
andrewlewis
2585051294 Move license to top for consistency
PiperOrigin-RevId: 635742699
2024-05-21 03:16:30 -07:00
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
tofunmi
c409623ca0 Create equals method for gainmaps
Gainmaps don't currently have an equals override, only reference equality is checked by Objects.equals(gainmap1, gainmap2). Create an equals method for gainmaps with the fields we care about to ensure we don't incur false positives in our equality checks.

PiperOrigin-RevId: 635510451
2024-05-20 11:06:03 -07:00
samrobinson
c9854cd695 Make flag for debug traces in logcat private and final.
PiperOrigin-RevId: 635465538
2024-05-20 08:38:33 -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
samrobinson
1abcf5c22c Add debug trace log for AssetLoader Renderer format events.
PiperOrigin-RevId: 634474584
2024-05-16 11:32:13 -07:00
samrobinson
5c6f48ecaf Add debug trace logs for AudioMixer & AudioGraph events.
PiperOrigin-RevId: 633973723
2024-05-15 09:06:34 -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
samrobinson
e17b3d7f83 Omit "last: []" from debug trace json if less than 10 event logged.
Reduces the boilerplate from the json produced without any information
loss.

PiperOrigin-RevId: 633540269
2024-05-14 04:45:42 -07:00
samrobinson
95c13819af Log DebugTraceUtil events to logcat as they occur.
PiperOrigin-RevId: 633512813
2024-05-14 03:08:43 -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
samrobinson
30624aae6e Pass component of event to debug trace logEvent as parameter.
PiperOrigin-RevId: 633176557
2024-05-13 05:33:31 -07:00
samrobinson
325f4ec502 Add debug trace JSON nesting per component.
PiperOrigin-RevId: 632424814
2024-05-10 02:13:56 -07:00
samrobinson
fff68f1932 Order DebugTraceUtil JSON output by each component.
PiperOrigin-RevId: 632193924
2024-05-09 10:28:49 -07:00
samrobinson
49fa343127 Remove unused DebugTraceUtil VFP event.
PiperOrigin-RevId: 632109159
2024-05-09 05:00:39 -07:00
claincly
145e0faf3d Make DefaultVideoCompositor use the first registered input as primary
PiperOrigin-RevId: 632079022
2024-05-09 02:21:31 -07:00
claincly
d977eab5f1 Minor code move for readability
PiperOrigin-RevId: 631922318
2024-05-08 14:19:04 -07:00
samrobinson
8b14d71ff0 Handle null extraFormat on entry in DebugTraceUtil.
PiperOrigin-RevId: 631821753
2024-05-08 09:14:06 -07:00
samrobinson
8b78e04ba3 Add time units to DebugTraceUtil logging.
PiperOrigin-RevId: 631764751
2024-05-08 05:29: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
tofunmi
620cb32667 effect: use constants for error colors in shaders
PiperOrigin-RevId: 630194321
2024-05-02 15:21:40 -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
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
claincly
43de3b67cf Fix PassthroughShaderProgram flush
PiperOrigin-RevId: 629007018
2024-04-29 02:51:27 -07:00
tofunmi
73f614b14d Effect: support disabling color transfers when HDR->SDR tonemapping
also makes the setter more flexible by ignoring the value of the setter when the output is hdr rather than throwing (since all HDR content must be have a linear color space)

PiperOrigin-RevId: 627388436
2024-04-23 08:02:30 -07:00
tofunmi
fb037b9847 TimestampWrapper: fix signaling input capacity
fixes https://github.com/androidx/media/issues/821

PiperOrigin-RevId: 626407880
2024-04-19 10:40:59 -07:00
tofunmi
0bc5ac24b0 Effect: remove duplicate inputColorInfo checks
We currently check certain properties about inputColorInfo twice: once in checkColors in the DVFP and once when creating the samplers in the defaultshaderprogam. The inputcolorinfo shouldn't change between these two components so removing the checks in the shader program to have one source of truth for inputColorInfo checks, which will make the code simpler when it comes to adding to color-related features (like the ones related to removing de-gamma-ing)

PiperOrigin-RevId: 626400960
2024-04-19 10:18:33 -07:00
tofunmi
300e83414d Effect: Change link in shader ahead of deletion
PiperOrigin-RevId: 626044561
2024-04-18 08:38:41 -07:00
kimvde
71e7e0f2cf Make VideoFrameProcessor.flush() more resilient
Allow flush to be called before registerInputStream. It's less error
prone to allow methods to be called in any order.

PiperOrigin-RevId: 624873772
2024-04-15 01:43:13 -07:00
huangdarwin
24e92bb04f Update TODO link for mastering luminance
PiperOrigin-RevId: 623186293
2024-04-09 09:13:17 -07:00
tofunmi
d4df814502 Effect: Change link to public available one in shader
PiperOrigin-RevId: 622178740
2024-04-05 08:04:01 -07:00