686 Commits

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

PiperOrigin-RevId: 487310971
2022-11-10 15:09:41 +00:00
bachinger
136addf640 Make adding ad live breaks more robust
This change makes adding ad events in live streams more robust by allowing ad
groups to grow in number of ads if more ad events are received than initially
announced by the SDK.

With the IMA prefetch feature, an AdPod can grow in size in certain conditions
like from initially 2 ads to 4 ads being part of the ad group. With this change,
if an additional ad event arrives while the ad group is still being played,
the ad group is expanded. If the event arrives late and the ad group is already
completed, a new group is created for the remaining ads.

This also covers the case where we join the live stream while an ad is being
played and we missed at least one LOADED event from the SDK. Ads of the group
before the first LOADED event are ignored in such a case.

PiperOrigin-RevId: 484214760
2022-10-31 16:29:48 +00:00
Googler
8181b3c6a1 Mute input video player in transformer demo
PiperOrigin-RevId: 483969411
2022-10-31 16:15:17 +00:00
bachinger
28c4be2f6b Map lib-effect from androidx to exoplayer2
PiperOrigin-RevId: 482179761
2022-10-20 03:15:38 +00:00
Googler
446c9943f9 Fix blank toast in Transformer Demo
PiperOrigin-RevId: 480847967
2022-10-20 01:57:57 +00:00
huangdarwin
3142a2127d Demo: Shorten trim range from 60 seconds to 10 seconds.
Most demo videos aren't very long, and the default demo video is only 10 seconds.

Shorten the maximum trim duration to 10 seconds, to demonstrate transformer functionality more easily, and allow this to be used more easily when trimming short sections of a longer video (ex. to make test clips)

PiperOrigin-RevId: 480602037
2022-10-20 01:46:55 +00:00
huangdarwin
91a61cecbe Demo: Hide player controls by default.
Player controls are somewhat distracting when showing the difference between the
input and output video, as they obscure and darken the video players.

PiperOrigin-RevId: 480597804
2022-10-20 01:43:22 +00:00
huangdarwin
6c59f9ece4 Demo: Read long values from trim slider.
Before, slider values were read as `floor()`'ed `longValue()`s, so that trimming to
intervals less than one second would be interpreted as a request for a zero-
duration trim.

Also, rename `radiusRange` references here to `trimRange`, since this is not a
radius range.

PiperOrigin-RevId: 480401556
2022-10-20 01:39:10 +00:00
Googler
225d0dcdd1 Add local file picker to ConfigurationActivity
PiperOrigin-RevId: 480349627
2022-10-20 01:35:37 +00:00
Googler
20c1ae1411 Add button to show/hide input player in TransformerActivity
PiperOrigin-RevId: 479003655
2022-10-20 00:52:19 +00:00
Googler
6f2bc16b60 Add second player for input video
PiperOrigin-RevId: 478510687
2022-10-20 00:41:39 +00:00
samrobinson
26a73605f8 Demo: Split video Effect generation out of createTransformer.
PiperOrigin-RevId: 477524540
2022-10-20 00:23:57 +00:00
Googler
bcea7bd355 Fix checkboxes on configuration page
PiperOrigin-RevId: 477166507
2022-10-20 00:09:13 +00:00
huangdarwin
f3d132141e HDR: Update gamma comments to linear.
Comment-only change.

PiperOrigin-RevId: 476873286
2022-10-19 23:57:16 +00:00
leonwind
29cf09316e Add example CLUT to demo.
PiperOrigin-RevId: 476390089
2022-10-19 23:50:03 +00:00
leonwind
5725ebbeea Add HSL Adjustments to the demo.
PiperOrigin-RevId: 476373520
2022-10-19 23:39:19 +00:00
leonwind
cfc0eef24e Add RGB Adjustments to transformer demo.
PiperOrigin-RevId: 476049125
2022-10-19 23:06:07 +00:00
leonwind
87926f0ba8 Add sepia, grayscale, and inverted filters to the demo app.
PiperOrigin-RevId: 471782565
2022-10-19 20:40:47 +00:00
rohks
a395b23d98 Switch incorrectly configured native multidex to legacy for demos
Native multidex can only be used for binaries with minSdkVersion of 21 or higher, but minSdkVersion was specified to 16.

PiperOrigin-RevId: 470004102
2022-10-19 19:43:43 +00:00
leonwind
f454c9aa74 Delete glPrograms in Contrast and RgbMatrix.
Remove unecessary null checks.

PiperOrigin-RevId: 469999952
2022-10-19 19:36:11 +00:00
rohks
2c70383d38 Fix missing id error
PiperOrigin-RevId: 469750922
2022-10-19 19:28:37 +00:00
huangdarwin
130a536287 HDR: Update limited range and add full range YUV to RGB color transforms.
PiperOrigin-RevId: 467910378
2022-10-19 18:26:58 +00:00
Googler
9c366b3cfd Avoid spinning in between intermediate texture processors.
This change adds a new method onReadyToAcceptInputFrame to
GlTextureProcesssor.InputListener and changes maybeQueueInputFrame
to queueInputFrame, removing the boolean return value.
This avoids the re-trying in ChainingGlTextureProcessorListener
by allowing it to only feed frames from the producing to the consuming
GlTextureProcessor when there is capacity.

MediaPipeProcessor still needs re-trying when processing isn't 1:1.

PiperOrigin-RevId: 466626369
2022-10-19 17:42:37 +00:00
huangdarwin
051dee68e3 Demo: Add legacy external storage permission for intents.
Without this permission, files in `/sdcard` or other directories cannot be read by the demo, as they're not in the transformer demo's scoped storage container.

For more information, see https://developer.android.com/training/data-storage/use-cases

Tested by uninstalling and re-installing the demo app, granting permission by
starting a transformation, and launching an intent using a local file in `/sdcard`
to start another transformation. Without this CL, this threw an error, and with
this CL it succeeded.

PiperOrigin-RevId: 466399023
2022-10-19 17:35:20 +00:00
Googler
a2166a4142 Split GlTextureProcessor.Listener into input/output/error listener.
This simplifies ChainingGlTextureProcessor as it now only connects a
consuming and a producing GlTextureProcessor rather than a previous,
current, and next GlTextureProcessor.

Also use default no-op implementations of the listeners in
SingleFrameGlTextureProcessor and MediaPipeProcessor to avoid
null-checks.

PiperOrigin-RevId: 466301642
2022-10-19 17:20:38 +00:00
Googler
6e4fc47522 Fix ConcurrentHashMap usage in demo MediaPipeProcessor.
PiperOrigin-RevId: 465563540
2022-10-19 16:51:30 +00:00
Googler
6da0a35434 Use multiple output frames in transformer MediaPipe demo pre API 23.
PiperOrigin-RevId: 465545764
2022-10-19 16:40:29 +00:00
Googler
707b061838 Move effects functionality out of transformer to effects module.
PiperOrigin-RevId: 465038852
2022-10-19 16:00:13 +00:00
Googler
06d41c2775 Move FrameProcessor and related interfaces to common.
This will allow effects preview in ExoPlayer to use the
Effect and FrameProcessor interface (and the interfaces
they depend on) without depending on transformer or the
future effects module.

PiperOrigin-RevId: 464060047
2022-10-19 15:34:54 +00:00
leonwind
9df0d40583 Add slider option for contrast in demo app
PiperOrigin-RevId: 464050072
2022-10-19 15:31:03 +00:00
Googler
66dde42989 Add Effect marker interface.
This allows non-GL effects to be passed to custom FrameProcessor
implementations.

PiperOrigin-RevId: 463696384
2022-10-19 14:56:44 +00:00
Googler
b994f8bfa0 Replace Size with Pair in effects.
Size requires API 21. Using Pair instead will allow effects to be
used from API 18 during previewing once they are moved out of
transformer.

PiperOrigin-RevId: 463206474
2022-10-19 14:11:40 +00:00
hschlueter
46ab06b816 Allow stream offset passed to GlEffectsFrameProcessor to change.
This is needed for applying effects to a playlist.

The effects are applied based on the presentation time of the
frame in its corresponding media item and the offset is added
back before encoding.

Each time the offset changes, end of input stream is signalled
to the texture processors. This is needed because the texture
processors can expect monotonically increasing timestamp within
the same input stream but when the offset changes, the timstamps
jump back to 0.

PiperOrigin-RevId: 462714966
2022-07-25 22:23:20 +01:00
huangdarwin
1ecf1eb7bf HDR: Implement HLG EOTF and OETF.
This allows us to use BT.2020 RGB linear for intermediate shaders, which also
allows us to re-enable PeriodicVignetteProcessor, which should work properly in
linear color-spaces.

Manually tested by adding a GlEffectsWrapper, and confirming that HLG HDR editing still looks correct.

PiperOrigin-RevId: 462265821
2022-07-21 13:23:20 +00:00
olly
7ef41c7321 Add ContrastProcessor for contrast adjustments.
PiperOrigin-RevId: 462232813
2022-07-21 13:19:55 +00:00
huangdarwin
f67c1a73f4 HDR: Use FP16 color representation for texture processors.
* Introduced `useHdr` for `GlEffect#toGlTextureProcessor`, so
  `TextureProcessor` implementations can decide how to handle HDR.
* Creating FP16 color textures for HDR input.

Tested via manual testing, adding a no-op GlEffectWrapper to the transformation to
force use of intermediate textures, adding a linear ramp to the fragment shader,
and trying to ascertain that there's a real reduction in posterization when
switching from 4-bit to 8-bit unsigned bytes, and again from 8-bit unsigned bytes
to 16-bit floating point.

PiperOrigin-RevId: 461613117
2022-07-21 12:55:36 +00:00
andrewlewis
405be80fe5 Update demo HDR10 video URL
The old URL doesn't correctly signal the HDR10 color info in the container.

The new URL signals ST2084 (PQ) transfer function and BT.2020 color space as expected.

PiperOrigin-RevId: 461560107
2022-07-21 12:40:03 +00:00
hschlueter
f41e6796ce Move DebugViewProvider out of Transformer class.
The GlEffectsFrameProcessor that will be part of the effects module
uses the DebugViewProvider. So it does not make sense for it
to be an inner interface of Transformer.

PiperOrigin-RevId: 458014932
2022-07-07 17:16:30 +00:00
hschlueter
20d220193e Rename setVideoFrameEffects to setVideoEffects.
PiperOrigin-RevId: 457023382
2022-06-27 12:03:04 +01:00
samrobinson
19bdff96ba Add a Builder for DefaultEncoderFactory.
PiperOrigin-RevId: 456728032
2022-06-27 11:40:04 +01:00
hschlueter
e25bf81195 Use GlTextureProcessor to avoid redundant copy in MediaPipeProcessor.
After this change GlEffects can use any GlTextureProcessor not just
SingleFrameGlTextureProcessor.
MediaPipeProcessor now implements GlTextureProcessor directly which
allows it to reuse MediaPipe's output texture for its output texture
and avoids an extra copy shader step.

PiperOrigin-RevId: 456530718
2022-06-27 11:33:30 +01:00
hschlueter
3a96691654 Support chaining async GlTextureProcessors in FrameProcessorChain.
After this change, FrameProcessorChain chains any GlTextureProcessors
instead of only SingleFrameGlTextureProcessors.

The GlTextureProcessors are chained in a bidirectional manner using
ChainingGlTextureProcessorListener to feed input and output related
events forward and release events backwards.

PiperOrigin-RevId: 456478414
2022-06-27 11:30:18 +01:00
hschlueter
a444bb8ca2 Add option to disable debug preview.
This is useful for testing Transformer in the same way as it is used
in tests and to see only the real transformation time.

PiperOrigin-RevId: 456058466
2022-06-27 11:16:53 +01:00
hschlueter
3f718b0d10 Check targetSdkVersion for frame dropping workaround.
Based on
https://developer.android.com/reference/android/media/MediaCodec#using-an-output-surface,
frame dropping behaviour depends on the target SDK version.
After this change transformer will only use
MediaFormat#KEY_ALLOW_FRAME_DROP if both the target and system SDK
version are at least 29 and default to its pre 29 behaviour where each
decoder output frame must be processed before a new one is rendered
to prevent frame dropping otherwise.

Also remove deprecated Transformer.Builder constructor without a
context and the context setter.

PiperOrigin-RevId: 453971097
2022-06-09 18:41:03 +00:00
hschlueter
dc668f2b59 Make GlUtil.GlException checked and remove flag to disable it.
Transformer always enabled glAssertionsEnabled, so there should
be no functional change.

ExoPlayer previously disabled glAssertionsEnabled, so GlUtil logged
GlExceptions instead of throwing them. The GlExceptions are now
caught and logged by the callers so that there should also be no
functional change overall.

This change also replaces EGLSurfaceTexture#GlException with
GlUtil#GlException.

PiperOrigin-RevId: 453963741
2022-06-09 18:37:29 +00:00
hschlueter
0b37d860d1 Implement default GlTextureProcessor in SingleFrameGlTextureProcessor.
SingleFrameGlTextureProcessor is now an abstract class containing a
default implementation of the more flexible GlTextureProcessor interface
while still exposing the same simple abstract methods for single frame
processing it previously did.

FrameProcessorChain and GlEffect will be changed to use
GlTextureProcessor in follow-ups.

PiperOrigin-RevId: 453633000
2022-06-09 16:56:11 +00:00
olly
21ad8cfd6b Fix handling of content URIs by demo apps
PiperOrigin-RevId: 453510883
2022-06-09 16:48:40 +00:00
andrewlewis
14ed32c68f Create withMediaPipe variant only if AAR is present
This should fix running `./gradlew clean test` if MediaPipe hasn't been built, for example.

PiperOrigin-RevId: 452033698
2022-05-31 14:04:44 +00:00
bachinger
5460ac8e60 Remove deprecated calls
#minor-release

PiperOrigin-RevId: 452006137
2022-05-31 11:13:33 +00:00
hschlueter
54d44d38b6 Move program initialization to texture processor constructor.
Once the more advanced GlTextureProcessor interface exists,
it will be possible to change the output size of a GlTextureProcessor
between frames. To keep the re-configuration based on the frame sizes
minimal, things indepedent of the frame size, such as the GlProgram,
can be initialized in the constructor.

PiperOrigin-RevId: 451997584
2022-05-31 11:02:40 +00:00