63 Commits

Author SHA1 Message Date
ibaker
14b0dcb957 Add missing @param tags
Dackka generates a warning if a method has at least one `@param` tag,
but not all of them are documented.

PiperOrigin-RevId: 513873453
(cherry picked from commit cb7d565fd47fc0b818ec0d5c7529e19df44022b5)
2023-03-14 16:19:20 +00:00
ibaker
3df6949c52 Add javadoc links to README files
Fix some other link titles and destinations spotted along the way.

#minor-release

PiperOrigin-RevId: 493276172
(cherry picked from commit 636a4a8538ccfb235eeca7d9131d4b5d4d95e9aa)
2023-01-25 18:01:21 +00:00
ibaker
484e72970d Fix Dackka/Metalava errors in the effects module
Public methods may only refer to public types in their signature. This
change ensures that by switching to a public supertype everywhere.

PiperOrigin-RevId: 485568625
(cherry picked from commit 40b5cba3c89398697d405d673bd09bf540dc3d88)
2022-11-02 12:21:56 +00:00
claincly
5974bee7c5 Add GL utility methods to get 4x4 identity and set identity
PiperOrigin-RevId: 483671580
(cherry picked from commit be7bb0eea4f01e5c73c2aa604c5b3126230586b4)
2022-10-25 14:47:52 +00:00
huangdarwin
ebc6b67e72 HDR: Support RGBA_1010102 in GlUtil as a parameter.
Make it easier to support use of RGBA_101012 rather than RGBA_8888 for EGL
contexts, displays, and surfaces.

This tangentially supports adding HDR tests, by slightly simplifying the color
selection logic we'd have to add in HDR tests.

PiperOrigin-RevId: 482219428
(cherry picked from commit bb215857e5fd0768ce53c7c61ba91c48dab14bd2)
2022-10-19 16:04:41 +00:00
huangdarwin
8aa2198667 Effect: Remove unnecessary "this" qualifier
`transformationMatrix` is not ambiguous, as there's no other local
transformationMatrix variable nearby.

PiperOrigin-RevId: 482184602
(cherry picked from commit e39826a8db9f478b56403c8afe7b73b88f57c1c2)
2022-10-19 13:08:03 +00:00
huangdarwin
d8b6c2971b Test: Update MatrixProcessorPixelTest to use input width and height.
Before, they used `width` and `height`, which was inconsistent with other pixel tests, and less descriptive.

Refactoring change only. No functional change intended.

PiperOrigin-RevId: 481970243
(cherry picked from commit cce79a70402a231ff1ae6924ea75d59c5680e7b4)
2022-10-18 18:12:06 +00:00
huangdarwin
632c9cb57d Effect: Remove unused private int ouptutTexId in pixel tests.
PiperOrigin-RevId: 481143798
(cherry picked from commit f9724e9fb61b14678d73e6d4cf1c7196e4092797)
2022-10-14 14:43:41 +00:00
claincly
b436001e32 Remove late frame dropping in FrameProcessor
Currently, a frame is dropped if it's requested release time is in the past.
This mode was added to support previewing. However, in normal ExoPlayer
playback, slightly late frames (<30ms late) are also rendered. On MediaCodec
side, this means calling `releaseOutputBuffer` with a release time in the
past.

PiperOrigin-RevId: 479615291
(cherry picked from commit a426cb27c0d0c85bd6cb4c04cb27957e3075754c)
2022-10-07 17:29:15 +00:00
claincly
8b193f2bb9 Add a FrameProcessor flag to drop the processed frame
This mode is supported by using `C.TIME_UNSET` (which is a negative value). The
new logic decouples the value of `C.TIME_UNSET` and the frame dropping
behaviour.

PiperOrigin-RevId: 479368880
(cherry picked from commit 26be9ae88548bcf95327801931b3b5797304bc66)
2022-10-06 18:30:14 +00:00
claincly
1b25dc2627 Add FrameProcessor functionality to release a frame immediately
Currently `FrameProcessor.releaseOutputFrame()` method supports

Release at a specific system time
Drops the frame
This API is not that convenient to use when the caller wants to release a frame, now, regardless of the release time. A use case is to release (present) a frame when no frame is shown for a while, and it's thus better to just release the frame, now.

Currently if MCVR wants a frame to be rendered now, MCVR calls release frame with a set offset like 10us: `releaseOutputFrame(System.nanoTime() + 10_000)`. The 10us offset is to prevent the frame processor dropping the frame, due to thread hopping delays.

To make the API better usable, consider adding a mode for releasing the frame now, like (bold marks the new mode)

- Use C.TIME_UNSET to drop
- **Use -1 to release the frame immediately, or**
- Use an actual release time.

PiperOrigin-RevId: 479044215
(cherry picked from commit 139a6e8d3175143957c44e4c4b5e15853202682e)
2022-10-05 14:45:27 +00:00
huangdarwin
65a9bd2dfa Tests: Statically import BitmapTestUtil methods.
Per go/java-practices/imports#static

No functional changes intended.

PiperOrigin-RevId: 477974779
(cherry picked from commit d5c272fde88f3efde7535933331270d2aea2fbb9)
2022-09-30 13:20:49 +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
4c3acbf739 HDR: Update gamma comments to linear.
Comment-only change.

PiperOrigin-RevId: 476873286
(cherry picked from commit 16dca1828c30c99fef9b63b46a5fe0cd7e7f65dc)
2022-09-26 13:00:17 +00:00
leonwind
09e0dd8505 Store LUT bitmap as texture with processor creation.
* Before this CL, the texture was stored during the construction of the LUT processor. This failed since if one creates a list of GlEffects on the application thread, the texture will get stored in the application thread during the effect creation and not on the GL thread, which executes the FrameProcessors.
* This is an issue since the executing thread then can't index from the texture stored on a different thread.

PiperOrigin-RevId: 476388021
(cherry picked from commit 44b9aec0b973b1cd5df31df32fff276f340e6ce4)
2022-09-23 16:19:43 +00:00
leonwind
a21d79cf1f Remove TODOs for merging RGB and MatrixTransformation processors.
PiperOrigin-RevId: 476362571
(cherry picked from commit 7eb0ce623bc1b29db9896cacbde4c6008b02ed32)
2022-09-23 14:21:38 +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
25a5fdfdac Add HSL Adjustments to the effects module.
PiperOrigin-RevId: 476144167
(cherry picked from commit dc9fa4f463a20a39984ea9d041ced0c4aed53291)
2022-09-22 17:56:54 +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
leonwind
ae18b30782 Use golden bitmaps in contrast pixel tests.
PiperOrigin-RevId: 475805421
(cherry picked from commit f00e43cf814df6bf71348a32d65b01ffada9d311)
2022-09-21 12:53:42 +00:00
leonwind
40cec25d20 Add LUT functionalities to transformer.
* Adds SDR 3D LUT functionalities with OpenGL 2.0 support.

PiperOrigin-RevId: 474561060
(cherry picked from commit f55a5146e01d0e5496ca97a5cfa7f47426d0932c)
2022-09-15 14:49:19 +00:00
leonwind
80d4d3717c Fix testId and match it to the test name.
PiperOrigin-RevId: 474363545
(cherry picked from commit ab6562e05235d65349a33d1649249e4049c358c2)
2022-09-14 19:41:11 +00:00
leonwind
74ec58514a Change ContrastProcessor java doc for consistency.
PiperOrigin-RevId: 474002026
(cherry picked from commit 60ea64734b3c5cc12ed81434d96e0b9337c37f46)
2022-09-13 13:28:30 +00:00
leonwind
46ff38ebe2 Add java docs for ContrastProcessor constructor.
* Add docs for the public constructor for consistency with all the
other frame processors.

PiperOrigin-RevId: 473726586
(cherry picked from commit 7a460fa3bd1abe6207049cf70b7ce4efd6cf12fd)
2022-09-12 13:02:32 +00:00
leonwind
03a2fb1194 Add rgb matrices to java docs for public constructors.
PiperOrigin-RevId: 473699927
(cherry picked from commit 10cb5f17e0169d669866bc6fcf1825b48102cd3d)
2022-09-12 09:52:09 +00:00
claincly
84a46053d6 Split decoding out of the test
This method is useful for other tests also.

PiperOrigin-RevId: 473574282
(cherry picked from commit 7f42e19f09e2fbda5d6c84e04cbabd2b1612a2d7)
2022-09-11 13:01:26 +00:00
leonwind
4e57accb1a Rename MatrixTransformationProcessor to MatrixTextureProcessor.
PiperOrigin-RevId: 473283967
(cherry picked from commit 5c78444bf84f4efb4c9e9997253f9c10e7c2d296)
2022-09-09 17:23:24 +00:00
leonwind
ac60e53fcb Add caching for compositeRgbMatrixArray.
* Refactor caching for matrix transformations to reuse it for rgb matrices.

PiperOrigin-RevId: 473042194
(cherry picked from commit 55afa598e74271e3802020f13ad5d23d27e88bb1)
2022-09-08 18:31:11 +00:00
claincly
fac7b16915 Clarify GlTextureProcessor.InputListener contract
PiperOrigin-RevId: 472745311
(cherry picked from commit 5e2823bb1e9d6c4331dba083ff1d050743bd2e25)
2022-09-07 16:33:44 +00:00
leonwind
0ac950321e Make MatrixTransformationsProcessor constructor to take in Lists.
* Replace ImmutableLists to List interface for constructors

PiperOrigin-RevId: 472433434
(cherry picked from commit 5b556b3c3365ca8b7a165f354aeb395658ceb887)
2022-09-06 12:37:47 +00:00
leonwind
70d29f6147 Use super class for toGlProcessor in RgbFilter.
PiperOrigin-RevId: 472405147
(cherry picked from commit 91e1209e82d09524cb88f5a9c814933b9b8130b7)
2022-09-06 09:31:05 +00:00
leonwind
8da65d01d2 Merge RgbProcessor and MatrixTransformation.
PiperOrigin-RevId: 472325145
(cherry picked from commit 672405afdff53ee746a4bcd237170de3b9feb1f7)
2022-09-05 21:51:11 +00:00
huangdarwin
6c51aa949d HDR: Use factory for MatrixTransformationProcessor.
Separate MatrixTransformationProcessor constructors by color input and output.

PiperOrigin-RevId: 471034768
(cherry picked from commit 1b6482960e9240a7697c6a13fdde198e3bf375a1)
2022-08-30 17:50:21 +00:00
leonwind
fb43ce2005 Add static Grayscale and Inverted RGB Filter.
PiperOrigin-RevId: 471017440
(cherry picked from commit 859504230240eacd3255cdf6be987412a4ff6c69)
2022-08-30 16:47:02 +00:00
claincly
7fc1e4a674 Fix ExternalTextureManager: repeated queueing input frame in preview
TL;DR: we should check if there are new frames available to queue to the
ExternalTextureProcessor before actually queueing a frame.

The overall flow on the external texture processor:

- `SurfaceTexture.onFrameAvailable` is called on `ExtTexMgr`, and
  - it calls `updateTexImage()`, and sets `frame`
  - it calls `maybeQueueFrameToExtTexProc()`
    - the frame is queued to `ExtTexProc` if `frame` is set

  - From `ExtTexProc.queueInputFrame()`:
    - notifies the `frameProcessorListener` of available frame
    - notifies the `inputListener` of `onReadyToAcceptInputFrame`
      - (`ExtTexMgr` is the listener), it calls `maybeQueueFrameToExtTexProc()`
       again

-- Parallelly --
- `ExtTexProc` calls `inputListener.onInputFrameProcessed`, when the frame is
released
  - (`ExtTexMgr` is the listener), sets `frame` to `null`

*Problem*

This logic relies on `frame` to be cleared at the right time.

In transformer, it's OK b/c `ExtTexProc` release the frame immediately in
`queueInputFrame()` and calls `onInputFrameProcessed` which also reset `frame`

But in previewing, the frame is not released for a while, up to 10 ms.
In this case, `frame` will not reset in this 10 ms, and
`maybeQueueFrameToExtTexProc()` is repeatedly queueing the same input frame.

PiperOrigin-RevId: 470211620
(cherry picked from commit 91709831ede920a38fc7dc3510973a434f390611)
2022-08-26 11:03:54 +00:00
leonwind
bf299da11c Delete glPrograms in Contrast and RgbMatrix.
Remove unecessary null checks.

PiperOrigin-RevId: 469999952
(cherry picked from commit a7d3752c6655d6572101b4b4c8b88c885fcf80de)
2022-08-25 15:49:13 +00:00
huangdarwin
893bf0db7c HDR: Rename GL_COLOR_TRANSFER instances to COLOR_TRANSFER
PiperOrigin-RevId: 469959215
(cherry picked from commit 2a05a5040379ae93c5b0c2b0aecd2345da84461d)
2022-08-25 11:43:40 +00:00
huangdarwin
7e7f07f8ab HDR: Add PQ support.
Use the PQ OETF and EOTF to ensure that intermediate fragment shader operations
using PQ are in linear BT.2020 rather than PQ and HLG-1 BT.2020.

Also, swap the OETF and EOTF in shaders, as they were used incorrectly before

Manually tested by verifying transformer demo HLG and PQ videos look the same with and without this CL, including with a BitmapOverlayProcessor enabled to test flows both with one MatrixTransformationProcessor that skips HDR TFs, and with one that doesn't.

PiperOrigin-RevId: 469736067
(cherry picked from commit 2ad07e88ee39ed5f662df91dc7034bd0ce478abe)
2022-08-24 15:44:22 +00:00
leonwind
5ace28044d Bind contrastFactor in constructor instead of drawFrame method.
PiperOrigin-RevId: 469438747
(cherry picked from commit 7e5dcf2360190e05d000d0fe4a18f2bca252fabe)
2022-08-23 13:16:17 +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
068a9d1099 HDR: Clamp YUV to RGB conversion.
Manually tested using transformer demo HLG videos. Before this CL, RGB values after the YUV to RGB conversion reached up to 1.025. After this CL, RGB values correctly clamp at 1.0.

PiperOrigin-RevId: 468426092
(cherry picked from commit 244d38cf0e5640b6c07abaeebcaffce2d3913345)
2022-08-18 11:31:03 +00:00
Googler
823df91ca0 Defensively cancel frame processing tasks on error.
FrameProcessingTaskExecutor should be released on error.
There can be a delay until this happens, so
FrameProcessingTaskExecutor will cancel any pending tasks
and drop new tasks until it is released.

PiperOrigin-RevId: 468171820
(cherry picked from commit 0c961a7abdc6ea7ef1b3f33dfd44d01459d2344a)
2022-08-17 12:25:53 +00:00
leonwind
06e95f9f59 Fix typo
PiperOrigin-RevId: 468152718
(cherry picked from commit 9f6940eaa4d60ac48d1e7be92d81e81a8793ce75)
2022-08-17 10:15:21 +00:00
leonwind
ec9948e9f2 Compact a RGB Matrix chain into a singular RGB Matrix.
PiperOrigin-RevId: 468013019
(cherry picked from commit 045a396167e9cfc7faf35a94d1f63971bec3d290)
2022-08-16 20:39:42 +00:00
huangdarwin
d91f60b6e6 HDR: Update limited range and add full range YUV to RGB color transforms.
PiperOrigin-RevId: 467910378
(cherry picked from commit d963dfbd3e478f01077e45ad84bae6d1ea666038)
2022-08-16 13:33:32 +00:00
Googler
f6dde78204 Allow high-priority tasks to be executed before other tasks.
This is needed as a pre-requisite for allowing MCVR to control
FrameProcessor frame release for previewing.

Submitting a high-priority task is conceptually different from
posting at the front of a single queue of tasks, as the high-priority
tasks are executed in FIFO order among themselves. This will ensure
that frame release tasks submitted in close succession are executed
in the order they are submitted but before any lower priority tasks.

PiperOrigin-RevId: 467675137
(cherry picked from commit 59be732230fe9bfdc27c27d6a6866abacbdda3fe)
2022-08-15 15:27:21 +00:00
andrewlewis
a2815141e6 Increase pixel difference threshold
PiperOrigin-RevId: 467610621
(cherry picked from commit 73d606acf3dd371232f874b20a1534952f8d560d)
2022-08-15 07:59:28 +00:00
leonwind
1076f3f7d7 Refactor RgbaMatrix to RgbMatrix.
* Rename all Rgba instances to Rgb.
* Remove alpha value from the RGBA Matrices and apply the 4x4 matrix
only to the R, G, B channels.
* Restore the alpha from the input unchanged.

PiperOrigin-RevId: 467208888
(cherry picked from commit 8760ee48b910a4a34e6cc5008b660513203b05e8)
2022-08-12 14:51:25 +00:00
Googler
19dfbeae5b Avoid spinning while queueing input to ExternalTextureProcessor.
This change adds ExternalTextureManager which implements
InputListener to only queue input frames to the
ExternalTextureProcessor when it is ready to accept an input
frame. This replaces the old retry-logic in GlEffectsFrameProcessor.

Before this change, the retrying in GlEffectFrameProcessor wasted
CPU time if input becomes available faster than the
ExternalTextureProcessor can process it.

PiperOrigin-RevId: 467177659
(cherry picked from commit d7bf1ed2d7f5cd1e3893000d9d917ae69b814848)
2022-08-12 11:10:47 +00:00