85 Commits

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

PiperOrigin-RevId: 487310971
(cherry picked from commit 2ff5dab0039c44d767dc831fec92724254e5e0aa)
2022-11-09 20:05:24 +00:00
tofunmi
36225d0ff9 Mute input video player in transformer demo
PiperOrigin-RevId: 483969411
(cherry picked from commit f1ca4f41b1fb4d0c16a53918f0aceb960a3f5134)
2022-10-26 15:01:30 +00:00
Googler
82e51d5669 Fix blank toast in Transformer Demo
PiperOrigin-RevId: 480847967
(cherry picked from commit 7e8f0f0918bdcaa855160151861f23c9b1a90392)
2022-10-13 10:32:32 +00:00
huangdarwin
cc67241062 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
(cherry picked from commit f35bda3524408d8bf560c080bd6a80698c7c08e1)
2022-10-12 12:58:12 +00:00
huangdarwin
28763e7d21 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
(cherry picked from commit 51edb329a124e5af302e1ebbd3527300619ac86a)
2022-10-12 12:26:07 +00:00
huangdarwin
8f3070834f 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
(cherry picked from commit fb5cd18dcd8b8e2a6baa308d6907f2e02751474e)
2022-10-11 17:57:01 +00:00
Googler
c40da71a3a Add local file picker to ConfigurationActivity
PiperOrigin-RevId: 480349627
(cherry picked from commit b515e0bd7fd382a7b3485e83ad7c65df4eff1a85)
2022-10-11 14:21:12 +00:00
Googler
3ff7c05044 Add button to show/hide input player in TransformerActivity
PiperOrigin-RevId: 479003655
(cherry picked from commit 50df923b258ce89c3bbebac1aa8f48e385e358d2)
2022-10-05 10:26:27 +00:00
Googler
c8917b50e6 Add second player for input video
PiperOrigin-RevId: 478510687
(cherry picked from commit 48a7f6a9240cd7c0ce8016915de630d903e5c393)
2022-10-03 15:27:33 +00:00
samrobinson
c08e4b664b Demo: Split video Effect generation out of createTransformer.
PiperOrigin-RevId: 477524540
(cherry picked from commit 1cfe18cd1f45e850df3b21ca8e63635956cf758e)
2022-09-28 19:39:09 +00:00
Googler
ff22da9011 Fix checkboxes on configuration page
PiperOrigin-RevId: 477166507
(cherry picked from commit bb811f0da50b632d68ae50ace90028e10f6bab8e)
2022-09-27 14:31:59 +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
638d806a49 Add example CLUT to demo.
PiperOrigin-RevId: 476390089
(cherry picked from commit 5b3efa8ad9557419a68a1a172c1d584aeecfd433)
2022-09-23 16:28:25 +00:00
leonwind
20518cc151 Add HSL Adjustments to the demo.
PiperOrigin-RevId: 476373520
(cherry picked from commit 7626f70cef1e6a431fbe2773a3a930904a67c803)
2022-09-23 15:11:52 +00:00
leonwind
873b806389 Add RGB Adjustments to transformer demo.
PiperOrigin-RevId: 476049125
(cherry picked from commit 9ccdd22e856251e7529fb893edbaa118f4285e49)
2022-09-22 10:04:42 +00:00
leonwind
2dfca4fca8 Add sepia, grayscale, and inverted filters to the demo app.
PiperOrigin-RevId: 471782565
(cherry picked from commit 305ea20518b037566839c64bafbc9e42f3d7a8b2)
2022-09-02 13:10:29 +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
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
6b4d174cde 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
(cherry picked from commit 97e6a86d2b1f72de9f95658f90ea40d1e1e4fac2)
2022-08-10 09:56:24 +00:00
huangdarwin
b89320521a 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
(cherry picked from commit ec6ed0d55f59c9387aa09b1514bea9951a6206f8)
2022-08-09 17:28:31 +00:00
Googler
cdd47ff703 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
(cherry picked from commit 7dc05edbab233dcd631a4a78ad65f1c30a1e9734)
2022-08-09 10:05:14 +00:00
hschlueter
bb57996c53 Fix ConcurrentHashMap usage in demo MediaPipeProcessor.
PiperOrigin-RevId: 465563540
(cherry picked from commit c95bfe325d75c991937fb8e2ecda58e59b6ca8df)
2022-08-05 14:56:54 +00:00
hschlueter
fa1a7eb51e Use multiple output frames in transformer MediaPipe demo pre API 23.
PiperOrigin-RevId: 465545764
(cherry picked from commit 51a1a879faadf749348902c12b382b42d54cd202)
2022-08-05 12:58:48 +00:00
hschlueter
8b9203a3ea Move effects functionality out of transformer to effects module.
PiperOrigin-RevId: 465038852
(cherry picked from commit 22725ddfa8f5c39c83b792a176339700364b724e)
2022-08-03 13:19:15 +00:00
hschlueter
de4c2e08e1 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
(cherry picked from commit 480c129c54777780f298d7e5dbd9fa23a371f660)
2022-07-29 12:54:30 +00:00
leonwind
1b5e3ceb32 Add slider option for contrast in demo app
PiperOrigin-RevId: 464050072
(cherry picked from commit 3fae9df8a9a1ab844d65a2336fc75a57e53d78d2)
2022-07-29 11:30:44 +00:00
hschlueter
6e390771a0 Add Effect marker interface.
This allows non-GL effects to be passed to custom FrameProcessor
implementations.

PiperOrigin-RevId: 463696384
(cherry picked from commit 580e44fc47ec5b62da5a133d12048a20d716e94f)
2022-07-27 22:40:20 +00:00
hschlueter
4001e699a1 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
(cherry picked from commit 4adf19939839baa3eaf018fef0d1b58049fd3b91)
2022-07-25 23:39:59 +00:00
hschlueter
9eeb4bc272 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
(cherry picked from commit 30e5bc9837e2423cd2bb426c5797211e0f6ad76b)
2022-07-22 22:18:55 +00:00
huangdarwin
06d3c07a1c 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
(cherry picked from commit 2f977eeec93be5cc71fda57f80362c1bc639c041)
2022-07-21 00:24:41 +00:00
olly
e959af40f1 Add ContrastProcessor for contrast adjustments.
PiperOrigin-RevId: 462232813
(cherry picked from commit 714edc93be549f93194ad0a1d7e187c32b49d1e8)
2022-07-20 21:38:10 +00:00
huangdarwin
54cdec4614 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
(cherry picked from commit ba9c9bb96471a9589d391ae498ebb0c194a5b41e)
2022-07-18 14:21:17 +00:00
andrewlewis
c4e64c3d0d 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
(cherry picked from commit 794e366b3661e9dfec01abcbd4598a26bec9e235)
2022-07-18 08:51:54 +00:00
hschlueter
d48507a2d1 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
(cherry picked from commit cd0e5b99de9577ff1af0da15a9ea6c9041f38361)
2022-06-29 17:56:53 +00:00
hschlueter
864230fd11 Rename setVideoFrameEffects to setVideoEffects.
PiperOrigin-RevId: 457023382
(cherry picked from commit 4819b28587c41e75c716ba3fa84fa84a8934c78e)
2022-06-24 17:04:45 +01:00
samrobinson
90c904b089 Add a Builder for DefaultEncoderFactory.
PiperOrigin-RevId: 456728032
(cherry picked from commit 352967f65661296ff5551138fd6346fce0c52a3f)
2022-06-23 11:37:19 +01:00
hschlueter
26ee3d32b2 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
(cherry picked from commit 69ab79418ef21033ca25cebdf5a5e80752818ab5)
2022-06-22 17:16:54 +01:00
hschlueter
0007a47365 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
(cherry picked from commit 555ab97e34d6586d38a9979bc0595a4818b7ecb8)
2022-06-22 12:03:41 +01:00
hschlueter
fab04c45f1 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
(cherry picked from commit 931562c24380ff8bd1f8fad6b2c0bb3581dc65e5)
2022-06-20 13:50:16 +01:00
hschlueter
56f234ea75 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
(cherry picked from commit a105d033a7d44b8c3afb0e8134ad65f624caf256)
2022-06-09 18:22:39 +00:00
hschlueter
0b08396255 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
(cherry picked from commit cc1f32d094cc4371d92b3ddab144d8965e1bc1c3)
2022-06-09 17:53:39 +00:00
hschlueter
dac3878273 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
(cherry picked from commit 457f446114823831b940bf46fb256daa0ea00815)
2022-06-08 09:44:25 +00:00
hschlueter
22ee071b53 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
(cherry picked from commit 87ab96d352c0ffbf83d514d93193638895b61e5e)
2022-05-31 09:36:18 +00:00
olly
e665edc863 Fix handling of content URIs by demo apps
PiperOrigin-RevId: 453510883
(cherry picked from commit 96274bfd98b45347e6a06059465625e01e952158)
2022-06-07 20:23:51 +00:00
andrewlewis
9cd84696c7 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
(cherry picked from commit 208a9114a9f516f7034b75b4f21f9ded34de8501)
2022-05-31 14:07:20 +00:00
hschlueter
fe3831c5b4 Fix handling clipping in transformer renderers.
Decode-only video frames (needed when the frame at / first frame after the
clipping start is not a key frame) need to be decoded but not passed to
the frame processor chain or encoder.

The clipping start offset needs to be removed from the frame timestamps
in the passthrough and video pipelines.
There are no changes needed for this in the audio pipeline, as it doesn't
use the input timestamps -- it uses its own timestamps derived from the
buffer sizes instead.

Also add demo option to try this out.

#minor-release

PiperOrigin-RevId: 451353609
2022-05-30 16:34:38 +00:00
hschlueter
0eaf3d30c8 Rename GlFrameProcessor to SingleFrameGlTextureProcessor.
Also update names of implementations to match design doc.
In follow-ups, SingleFrameGlTextureProcessor will become
an abstract implementation of a new GlTextureProcessor
interface.

Texture processor makes sense as it processes OpenGL textures.
The term frame processor will be used for something else in
follow-ups.

PiperOrigin-RevId: 451142085
2022-05-30 16:31:13 +00:00
andrewlewis
0fa0735935 Reorder demo samples
Put cloud storage samples at the top to avoid having a sample at the top of the list where we don't control the server.

Also update labels not to mention progressive container type, as it's irrelevant for Transformer, which always transmuxes even if it doesn't transcode.

#ame-bug-week

PiperOrigin-RevId: 450403784
2022-05-24 11:09:55 +01:00
andrewlewis
a9bdd6e2e9 Attempt to load OpenCV when loading MediaPipe
PiperOrigin-RevId: 449227706
2022-05-24 10:51:36 +01:00
andrewlewis
d8caa2b4c1 Fix initialization of media pipe processors with assets
PiperOrigin-RevId: 449221156
2022-05-24 10:50:41 +01:00