484 Commits

Author SHA1 Message Date
huangdarwin
b1cf5fb320 Effect: Reduce Compositor exception try/catch redirection.
The VideoFrameProcessingTaskExecutor already handles wrapping
GlUtil.GlException errors into VideoFrameProcessingExceptions.
Therefore, stop wrapping this ourselves, so that errors are
attributed to the correct line number with less indirection.

PiperOrigin-RevId: 549959258
2023-08-01 13:46:28 +01:00
tofunmi
7eee15ecb4 Update OverlaySettings to explicitly state overlay transformations
Alters the OverlayShaderProgram implementation to support rotations, however we need to apply the transformations separately in order for them to work as expected so the matrix is removed from the interface in favour of explicit methods.

Adds a rotation test to ensure this ability doesn't regress

PiperOrigin-RevId: 549890847
2023-08-01 13:45:22 +01:00
huangdarwin
836720ebfa Compositor: Use timestamps for compositing.
For now, just identical timestamps. A follow-up CL will allow for different
framerates. Prior tests already send identical timestamp frames, so no new
tests were added

PiperOrigin-RevId: 548676759
2023-07-20 10:13:28 +01:00
huangdarwin
0c29dacde3 Compositor: Use timestamps to release frames.
Also, implement back-pressure to avoid requesting more than all of the
compositor's texturepool textures

PiperOrigin-RevId: 548179800
2023-07-20 10:04:55 +01:00
tofunmi
453431fef2 Fix TextOverlay's overlay width measuring strategy
Before this CL, the text with a scale span would wrap text, with because the scale wasn't taken into account when measuring the width of the overlay.

PiperOrigin-RevId: 548123626
2023-07-20 10:00:05 +01:00
huangdarwin
c122c0ca05 Compositor: Add support for multiple bitmaps, and add testrunner
* Allow more than one input bitmap at a time.
* Allow Compositor to take in and set up an Executor. Otherwise,
Compositor resources may be created on one thread and accessed on another.
* Add a Compositor TestRunner to reuse test code more.
* Update VideoFrameProcessingTaskExecutor to use a new onError listener, so
that it's more reusable in non-DVFP contexts, like for Compositor.

PiperOrigin-RevId: 547206053
2023-07-13 15:45:30 +01:00
huangdarwin
7c9e6ad2ea Effect: Only allow setExecutorService with @NonNull values.
PiperOrigin-RevId: 546828814
2023-07-13 15:30:07 +01:00
huangdarwin
cd0b45092e Test: Rename bitmap test method from Current to Focused GlFrameBuffer
Frame buffers are focused, not current. EGL Contexts may be current but this
is a prerequisite for focusing a framebuffer, and this alone isn't
sufficient to make a bitmap.

Clear this up as it can make some complex tests harder to understand, if the
methods needed don't match up in naming.

PiperOrigin-RevId: 546305118
2023-07-13 15:15:34 +01:00
huangdarwin
4adb5d771e Effect: Remove obsolete TODO
PiperOrigin-RevId: 546285094
2023-07-13 15:13:02 +01:00
andrewlewis
1ef7579f5c Fix stale javadoc
The method no longer returns anything. We don't need javadoc for this as it's
default visibility.

PiperOrigin-RevId: 545981702
2023-07-13 15:07:17 +01:00
Googler
5050171ff6 Rename "useHdr" to "useHighPrecisionColorComponents."
BaseGlShaderProgram and SingleFrameGlShaderProgram are technically color space agnostic. useHdr is passed to the TexturePool, which only uses the value to choose between high/regular precision. useHdr is therefore a bit misleading and should be generalized to "useHighPrecisionColorComponents."

PiperOrigin-RevId: 545726629
2023-07-13 14:56:37 +01:00
huangdarwin
7a368b9a11 Effect: Remove GlTextureInfo accessor methods.
The extra check was a bit excessive, especially as it's called multiple times
per frame.

PiperOrigin-RevId: 545657102
2023-07-13 14:51:38 +01:00
huangdarwin
fa781782da Effect: Share ExecutorService and thread between VFP instances.
This allows us to simplify and reduce thread initialization, hops and the
synchronization cost associated with them, especially when more and more VFPs
are used.

PiperOrigin-RevId: 545622169
2023-07-05 13:58:43 +00:00
huangdarwin
9945033867 Effect: Create basic VideoCompositor.
Allow two DefaultVideoFrameProcessor instances to output to one
VideoCompositor, which then outputs a frame.

PiperOrigin-RevId: 544705821
2023-07-05 09:02:45 +00:00
tofunmi
d14122b029 Create queue of sync objects in FinalShaderProgramWrapper
PiperOrigin-RevId: 544683524
2023-07-05 09:00:20 +00:00
tofunmi
6f9731ce7e TextureInput: Advise client to delete syncObject after use
PiperOrigin-RevId: 544670927
2023-07-05 08:57:55 +00:00
claincly
98eb339333 Add tracing info for EOS signaling in the texture managers
PiperOrigin-RevId: 544063377
2023-06-29 23:11:44 +00:00
tofunmi
a98b33b03c Replace glFinish in texture output with Gl sync token
Providing the sync token in the api allows the client to decide which waiting method they would like to use depending on the use case, allowing them to optimise if possible.

PiperOrigin-RevId: 543997311
2023-06-29 23:07:56 +00:00
tofunmi
8cecb93570 Texture Input: Add GLSyncToken to the OnInputFrameProcessedListener
PiperOrigin-RevId: 543867944
2023-06-29 23:02:20 +00:00
claincly
f98a10f3f2 Move GlShaderProgram creation away from VFP creation
PiperOrigin-RevId: 543773418
2023-06-29 23:00:11 +00:00
tonihei
2322462404 Do not trim audio samples by changing their timestamp
MP4 edit lists sometimes ask to start playback between two samples.
If this happens, we currently change the timestamp of the first
sample to zero to trim it (e.g. to display the first frame for a
slightly shorter period of time). However, we can't do this to audio
samples are they have an inherent duration and trimming them this
way is not possible.

#minor-release

PiperOrigin-RevId: 543420218
2023-06-29 22:50:04 +00:00
andrewlewis
90c8f642af Pass GlObjectsProvider to methods
By passing this class where it's needed, implementations don't need to store it
in a field (reducing boilerplate) and it's clearer that it can't be unset when
needed.

PiperOrigin-RevId: 542823522
2023-06-23 16:49:12 +00:00
claincly
1831220a53 Fix the last shader program doesn't get GlObjectsProvider
PiperOrigin-RevId: 542299317
2023-06-22 15:40:33 +00:00
tofunmi
09fe0d7390 Correct the DefaultFrameDroppingShaderProgram logic
copies the previous texture to a temp texture to ensure the correct frame is queued.

#minor-release

PiperOrigin-RevId: 541972349
2023-06-22 15:29:41 +00:00
huangdarwin
949e9cbd96 GL: Rename GL methods.
To more accurately describe what they do, especially as Compositor will
starts to use more contexts or threads, and it's important to know what
needs to be reset/recreated/focused before what methods.

PiperOrigin-RevId: 541010135
2023-06-19 16:29:03 +01:00
huangdarwin
daa42322d7 GL: Remove configAttributes from createFocusedPlaceholderEglSurface.
PiperOrigin-RevId: 540901189
2023-06-19 16:27:02 +01:00
claincly
fe33f0e390 Simplify EOS signaling in DefaultVideoFrameProcessor
Previously, TextureMangers have a method to signal ending of a current input
stream, and a method to end the **entire input**. The responsibility of both
methods are not easy to document, understand and read.

With the new design,

- Only `TextureManager.signalEndOfCurrentInputStream()` is kept
  - It's called for every MediaItem in the sequence, include the final one
- FinalWrapper now takes explicit signal that frame processing is ending,
  rather than relying on the return value of `onCurrentInputStreamProcessed()`
- On DVFP receiving EOS from the pipeline, it signals FinalWrapper the stream
  is ending, **before** signaling the input switcher, so that FinalWrapper is
  able to end the stream when the onCurrentInputStreamEnded signal eventually
  reaches FinalWrapper

PiperOrigin-RevId: 540856680
2023-06-19 16:24:33 +01:00
huangdarwin
4178d61ccd Effect: Move VideoFrameProcessingTask to VFPTaskexecutor
Group things that are closely related. VFPTask is only ever
used alongside VFPTaskExecutor.

PiperOrigin-RevId: 540850948
2023-06-19 16:22:09 +01:00
tofunmi
251fb013c3 Reset the simple frame dropping logic on flush or EOS.
#minor-release

PiperOrigin-RevId: 540633875
2023-06-19 16:20:09 +01:00
huangdarwin
5fc5105f7a Test: Log saved bitmap file path.
This helps debug bitmap tests. Without this CL, I typically
need to go into the file to find the test name and absolute
path. With this CL, I can just adb pull the printed file path,
which is much simpler.

PiperOrigin-RevId: 540539042
2023-06-19 16:10:30 +01:00
tonihei
51fb72b00d Replace deprecated NullableType from checkerframework with our own one
The existing NullableType has been deprecated 5 years ago and causes
crashes in Kotlin apps because Kotlin doesn't recognize this annotation
as a nullable type annotation.

While we can't align on a single @Nullable annotation yet, we can at
least replace this one by JSR305's @Nonnull(MAYBE) as it fulfils all
requirements, including full Kotlin compatiblity. To avoid the
cumbersome name, we can redefine it as our own @NullableType
annotation. (We can't use @Nullable to avoid name clashes with the main
@Nullable annotation from AndroidX)

Issue: google/ExoPlayer#6792
PiperOrigin-RevId: 540497469
2023-06-19 16:08:20 +01:00
claincly
aa94f4e128 Add a blank line to break long paragraph
PiperOrigin-RevId: 540222936
2023-06-14 20:38:24 +01:00
claincly
abd96598d9 Add a timer to end a video stream prematurely in ExtTexMgr
Partially roll forward of 5c29abbbf4, and adds some extra logic

Changes to the original CL

The original logic (a66f08ba97) fails in the following case:

> This is only seem on emulators.

- EOS is sent to ExtTexMgr
- The timer starts
- One frame arrives on SurfaceTexture, reset the timer
  - The frame is sent for processing, now `availablFrames == 0`
- One frame arrives on Surface, reset the timer
  - The frame is kept on SurfaceTexture for the downstream shader doesn't have
    capacity, `availablFrames == 1`
- Timer times out as the downstream processor doesn't report being able to take
  another frame.
  - Although there's a frame available on the SurfaceTexture

This is solved by having the force EOS logic clear all the frames that the
SurfaceTexture holds. This also ensures the first frame dequeued from the next
stream isn't from the previous stream.

PiperOrigin-RevId: 540023359
2023-06-14 20:34:17 +01:00
tofunmi
219212d54f rename videoFrameProcessorTestRunner.queueInputBitmap
This methods currently registers and queues the bitmaps Will need to have a method that just queues bitmaps in future CLs.

#minor-release

PiperOrigin-RevId: 539605628
2023-06-12 14:06:22 +00:00
claincly
5f43180a68 Allow using different video effects per MediaItem
PiperOrigin-RevId: 539596345
2023-06-12 14:04:42 +00:00
kimvde
1c18503ad0 Transmux video with negative rotation if possible
PiperOrigin-RevId: 539593035
2023-06-12 14:03:06 +00:00
Googler
5c29abbbf4 Rollback of a66f08ba97
*** Original commit ***

Add a timer to end a video stream prematurely in ExtTexMgr

***

This has been submitting for more than 1.5hrs. "This presubmit is running slowly because you have been throttled by Build Queue due to using too much of your Product Area's quota."

adding NO_SQ as this is a pure rollback

PiperOrigin-RevId: 539135970
2023-06-09 18:36:17 +00:00
claincly
edf30433b6 Add missing empty lines
PiperOrigin-RevId: 539100987
2023-06-10 20:22:38 +00:00
claincly
a66f08ba97 Add a timer to end a video stream prematurely in ExtTexMgr
PiperOrigin-RevId: 539036285
2023-06-09 14:04:49 +00:00
tofunmi
276f2f1fe6 Add 'Keep every nth frame' frame dropping strategy.
#minor-release

PiperOrigin-RevId: 538804347
2023-06-09 13:55:39 +00:00
claincly
a7cff4e0e3 Fix calling extra registerInputStream and not handling EOS
PiperOrigin-RevId: 538796466
2023-06-09 13:52:44 +00:00
huangdarwin
0c924fcb40 Test: Add no-op effect test for GL tone mapping.
To ensure no regressions for the potentially confusing pipeline of:
* HDR electrical -> SDR linear EOTF+OOTF, and
* SDR linear -> SDR electrical OETF

PiperOrigin-RevId: 538741079
2023-06-08 12:46:34 +00:00
tofunmi
c3b9328d74 Tests for disabled color transfers
#minor-release

PiperOrigin-RevId: 538466615
2023-06-08 12:38:36 +00:00
claincly
133943a635 Fix recreation of DefaultShaderProgram in FinalWrapper
`outputSurfaceInfoChanged` is not reset when `defaultShaderProgram` is null.
That is, on the first time `ensureConfigured()` is called with output size
changed, `outputSurfaceInfoChanged` is not set to false after creating the
`defaultShaderProgram`, and `defaultShaderProgram` will be created again on the
second time `ensureConfigured()` is called.

PiperOrigin-RevId: 537870404
2023-06-06 18:01:20 +00:00
ibaker
7e6dae7b31 Remove exoplayer2-only javadoc machinery from media3
This introduces whitespace-only changes in exoplayer2 due to the way
copybara stripping works.

PiperOrigin-RevId: 537296933
2023-06-05 09:47:58 +00:00
claincly
f6dbe99c79 Use the designated UNSET value for aspect ratio
PiperOrigin-RevId: 536770380
2023-06-02 09:12:38 +00:00
huangdarwin
1c172e0bed Effect: Remove extra wait on taskExecutor release()
This future.get() duplicates the wait done in
singleThreadExecutorService.awaitTermination(). If awaitTermination times out, this future.get() would also result in unnecessary blocking.

PiperOrigin-RevId: 536442153
2023-05-30 18:46:43 +00:00
kimvde
f4d1a6c453 Transmux video if rotation is only effect applied
PiperOrigin-RevId: 535554628
2023-05-26 15:14:52 +00:00
tofunmi
a19e07c4d2 Move OnInputFrameProcessedListener into it's own file
PiperOrigin-RevId: 535183521
2023-05-25 15:09:36 +00:00
huangdarwin
abf649cdfa Effects: Have VFP texture output disable surface output.
Also, document that texture output disables manual frame release.

In the past, texture output would lead to surface output methods throwing. Now,
they're simply no-ops instead.

PiperOrigin-RevId: 534894168
2023-05-25 09:57:16 +01:00