9890 Commits

Author SHA1 Message Date
kimvde
50f5e34583 Improve shouldTranscode() logic
PiperOrigin-RevId: 511767953
2023-02-24 11:11:40 +00:00
kimvde
c5c171beba Add unit tests for audio track dis(appearing) during export
PiperOrigin-RevId: 511764841
2023-02-24 11:08:07 +00:00
kimvde
4c9b8cb694 Document that slow mo flattening is only supported for single-asset
PiperOrigin-RevId: 511757712
2023-02-24 11:04:33 +00:00
kimvde
0205e75ff8 Split transmux into transmuxAudio/Video
- Split the transmux setting into transmuxAudio and transmuxVideo. This
  is more flexible for apps and will also be useful for unit testing
  (particularly as we can't test video transcoding on Robolectric at the
  moment).
- Move these settings to Composition. It makes sense for these settings
  to be next to forceAudioTrack. Apps may also want to set these
  settings based on the current Composition's MediaItems.
- Add a Composition.Builder because Composition now contains a few
  optional fields.

PiperOrigin-RevId: 511708618
2023-02-24 11:01:03 +00:00
samrobinson
7f3eb113e5 Fix disallowed tag.
If ChannelMixingMatrix is public, this causes code to not build.

PiperOrigin-RevId: 511500694
2023-02-24 10:57:22 +00:00
kimvde
379c3e1eb2 Restrict SampleConsumer and OnMediaItemChanged threading
This is more future-proof because it is likely to simplify the upcoming
changes to the sample pipelines.

PiperOrigin-RevId: 511492014
2023-02-24 10:53:53 +00:00
samrobinson
9a8026f27e Only log list of removed encoders if not empty.
Logcat had the following lines, with no other information.
```
DefaultEncoderFactory: Encoders removed for resolution:
DefaultEncoderFactory: Encoders removed for bitrate:
DefaultEncoderFactory: Encoders removed for bitrate mode:
```
PiperOrigin-RevId: 511470231
2023-02-24 10:50:20 +00:00
kimvde
12a6183312 Make sure that VideoSamplePipeline is picked for image input
PiperOrigin-RevId: 511449658
2023-02-24 10:46:49 +00:00
huangdarwin
cb7a8d2d03 Effect: Implement isNoOp on GlEffect interfaces.
Also, allow isNoOp to default to false without the TODO, so that implementations
of isNoOp must opt-in to implementing the override in order to be considered for
skipping the effect (ex. for transcoding in Transformer).

PiperOrigin-RevId: 511223540
2023-02-24 10:43:08 +00:00
kimvde
948ccfe2a6 Document that the output file is not deleted in case of error/cancel
PiperOrigin-RevId: 511189130
2023-02-24 10:36:05 +00:00
huangdarwin
7e377854a3 MediaFormatUtil: Reduce Color API 29 restriction to API 24.
Implement getMediaFormatInteger, a helper method simulating mediaformat.getInteger(name, defaultValue).

This reduces the API 29 restriction from MediaFormatUtil.getColorInfo to API 24, in
particular removing the method-based restriction to a constant-based restriction,
so that we can reduce usage of the API 29 class.

This also allows us to slightly simplify prior use-cases where we'd check
containsKey and getInteger to have a default value.

PiperOrigin-RevId: 511184301
2023-02-24 10:32:22 +00:00
kimvde
f4766ee4db Fix clipping in AudioSamplePipeline
When clipping a MediaItem with start time > 0, the audio was ending
before the video. This is because:
- Audio timestamps are computed based on the sample sizes, with a start
  time set to streamOffsetUs (i.e. the streamStartPositionUs is not
  taken into account).
- The SamplePipeline was subtracting streamStartPositionUs from the
  timestamps before sending the samples to the muxer.
- As a result, the audio timestamps were shifted by
  streamStartPositionUs, while they should be shifter by streamOffsetUs.

PiperOrigin-RevId: 511175923
2023-02-24 10:28:53 +00:00
kimvde
3009b4d5d1 Rename transformation to export in DebugViewProvider
PiperOrigin-RevId: 511173451
2023-02-24 10:25:18 +00:00
samrobinson
9ecab028a0 Expand and refactor TransformerInternal#shouldTranscode.
* Account for `AssetLoader` output types.
* Consider cases that are not audio/video specific.
* Use `Format#sampleMimeType` for track specific conditions to check.
* Untangle `SamplePipeline` initilization from `AssetLoader` state.

PiperOrigin-RevId: 511020865
2023-02-24 10:18:06 +00:00
kimvde
79d32c2488 Support added/removed audio track between MediaItems
- Add silent audio when the output contains an audio track but the
  current MediaItem doesn't have any audio.
- Add an audio track when generateSilentAudio is set to true.

PiperOrigin-RevId: 511005887
2023-02-24 10:14:26 +00:00
huangdarwin
b206a1afec HDR: Fix ForceInterpretHdrVideoAsSdrTest, and expand to all APIs.
Previously, this was limited to API 29. Expand this to all API versions.

Also, update the test to:
(1) skip based on SDR format input instead of HDR format input
(2) Check the exception message in order to disambiguate between the decoder tone
mapping error, and general video format support error.

PiperOrigin-RevId: 511002218
2023-02-24 10:07:18 +00:00
kimvde
b88025cc3d Fix stuck muxer
Unstuck the muxer if the next timestamp in the track with the minimum
timestamp is larger than this minimum timestamp plus
MAX_TRACK_WRITE_AHEAD_US.

PiperOrigin-RevId: 510977088
2023-02-24 09:53:06 +00:00
huangdarwin
c79eb7466a Effect: Add FloatRange to public GlEffect impl interfaces.
Using these annotations/checkers should hopefully make it marginally harder to use the wrong input values in the API.

PiperOrigin-RevId: 510966941
2023-02-24 09:49:37 +00:00
christosts
cbb6878f9f Skip rendering multiple frames on the same vsync
When rendering frames at a rate higher than the screen refresh rate,
e.g. playing at 8x, the player is releasing multiple frames at the same
release time (nanos) which are then dropped by the platform. The output
buffers are available later and as a result MediaCodec cannot keep up
decoding fast enough.

This change skips releasing multiple video frames on the same vsync
period and proactivelly drops the frame. The frame is counted as skipped
rather than dropped to differentiate with frames dropped due to slow
decoding.

PiperOrigin-RevId: 510964976
2023-02-24 09:46:06 +00:00
tonihei
829b49d724 Reduce number of calls to AudioTrack.getPlaybackHeadPosition
This call may cause performance overhead in some situations,
for example if the AudioTrack needs to query an offload DSP
for the current position. We don't need to check this multiple
times per doSomeWork iteration as the value is unlikely to
change in any meaningful way.

PiperOrigin-RevId: 510957116
2023-02-24 09:42:39 +00:00
huangdarwin
6a91b2df51 HDR: Remove comment explaining force sdr behavior with assetloaders.
Before, if the upstream AssetLoader provides HDR to the VideoSamplePipeline when
HDR_MODE_EXPERIMENTAL_FORCE_INTERPRET_HDR_AS_SDR is requested, the
VideoSamplePipeline would attempt to tell the AssetLoader to output SDR, which
could be accomplished via MediaCodec tone-mapping in the AssetLoader.

However, this makes an assumption of the AssetLoader implementation, and
AssetLoaders may not all implement support for decoder tone-mapping. Remove javadoc
attempting to explain how AssetLoaders (ex. custom ones) could behave.

PiperOrigin-RevId: 510956820
2023-02-24 09:39:08 +00:00
samrobinson
363b85226e Pass AudioFormat to ASP#computeNextEncoderInputBufferTimeUs.
This method uses sampleRate, channelCount and pcmEncoding, so passing
AudioFormat is easier.

This will lead into a future change that builds the
encoderInputAudioFormat from encoder.getConfigurationFormat()

PiperOrigin-RevId: 510956177
2023-02-24 09:35:35 +00:00
huangdarwin
ae37d33b18 Effect: Rename to DefaultShaderProgram.
Rename:
* MatrixShaderProgram to DefaultShaderProgram, and
* FinalMatrixShaderProgramWrapper to FinalShaderProgramWrapper.
PiperOrigin-RevId: 510498547
2023-02-24 09:32:08 +00:00
huangdarwin
540f5d681d Effect: Rename to ScaleAndRotateTransformation
Rename ScaleToFitTransformation to ScaleAndRotateTransformation.

This better represents the operations that can be accomplished using this
effect. The name was originally named ScaleToFit* because it's not obvious how
to scale to fit using OpenGL, and this effect handled the scaling to fit in a way that no other MatrixTransformations did.

However, it's hard to discover how to rotate when skimming names of effects, so
it's probably more useful to convey that this effect rotates, than that it
scales to fit.

PiperOrigin-RevId: 510480078
2023-02-24 09:28:37 +00:00
huangdarwin
84fe683ca3 HDR: Add colorinfo to exception logs.
Format.toString unfortunately doesn't log colorInfo, and as Format holds a very
large set of values, it's unclear that it should. ColorInfo is useful for codec
exceptions though, so log this in ExportException.createForCodec.

PiperOrigin-RevId: 510475520
2023-02-24 09:25:07 +00:00
tofunmi
5e93616ad2 fix nits and enhance DefaultVideoFrameProcessorImageFrameOutputTest
resolving comments from 8aa1638fe4.

PiperOrigin-RevId: 510457401
2023-02-24 09:21:39 +00:00
tofunmi
8aa1638fe4 Add multi-image input FrameProcessor tests
PiperOrigin-RevId: 510441777
2023-02-24 09:14:39 +00:00
andrewlewis
bd4a5ecf6a Align test codec caps check with real implementation
PiperOrigin-RevId: 510437262
2023-02-24 09:11:12 +00:00
kimvde
2163cfb24a Move generateSilentAudio to Composition
Also rename to forceAudioTrack

PiperOrigin-RevId: 510394620
2023-02-17 14:22:50 +00:00
tofunmi
a4ad85d25a InternalTextureManager: delete texture after use
PiperOrigin-RevId: 510377977
2023-02-17 14:09:55 +00:00
huangdarwin
0cb5c58834 HDR: Catch test util decoder support error.
Otherwise, a lack of HDR decoding support will result in the tests checking output files for HDR output, like HdrEditingTest.transform_noRequestedTranscode_hdr10File_transformsOrThrows, failing.

PiperOrigin-RevId: 510213020
2023-02-17 13:57:07 +00:00
samrobinson
9ca1122bed Remove space in exception message.
This space was added by mistake in a prior CL of mine.

PiperOrigin-RevId: 510157363
2023-02-17 13:52:22 +00:00
huangdarwin
aa7abd5518 HDR: Add comment explaining force-SDR and AssetLoader interaction.
PiperOrigin-RevId: 510155318
2023-02-17 13:48:00 +00:00
huangdarwin
7d54f24473 HDR: Put force HDR as SDR into AssetLoader
This allows us to fix usage of HDR_MODE_EXPERIMENTAL_FORCE_INTERPRET_HDR_AS_SDR.

Before, this was checked in the VideoSamplePipeline, which no longer decides on the decoder configuration input format.

PiperOrigin-RevId: 510142097
2023-02-17 13:43:42 +00:00
kimvde
4cc5080db0 Rename occurrences of transform in lib-transformer
PiperOrigin-RevId: 510118760
2023-02-17 13:39:21 +00:00
andrewlewis
37768ed099 Remove Pixel watch check
It's unlikely anyone will try to use Transformer on watches.

PiperOrigin-RevId: 510115645
2023-02-17 13:34:56 +00:00
claincly
f74cd7b17e Fix a missed rename.
PiperOrigin-RevId: 510100709
2023-02-17 13:30:26 +00:00
andrewlewis
ab2cabe3da Check capabilities for more tests
Some of the test methods in `TransformationTest` don't check
capabilities. Add a check just scoped to decoding (not checking
encoding, but the default encoder factory may fall back).

PiperOrigin-RevId: 510088562
2023-02-17 13:25:57 +00:00
kimvde
3f84c86977 Rename TransformationTest to ExportTest
PiperOrigin-RevId: 510087543
2023-02-17 13:21:35 +00:00
huangdarwin
5fee7df622 Effects: Update javadoc to link to method.
PiperOrigin-RevId: 510077348
2023-02-17 13:17:10 +00:00
kimvde
774b44c6e2 Rename TransformationException to ExportException
PiperOrigin-RevId: 510062674
2023-02-17 13:12:44 +00:00
Googler
6867f56658 Update instrumentation to avoid making all constructors public
Previously, any constructors instrumented by Robolectric were made public. This
caused two types of issues:

1) If Android classes had non-public constructors which were made public and
added to the Android API, Robolectric allowed tests to incorrectly use the
constructors on older SDK levels (where they were non-public). This most
commonly occurs for AccessibiltyEvent and AccessibilityNodeInfo.

2) When reflection was used to instantiate classes that were instrumented by
Robolectric, all constructors were accessible, which did not match what
happened when running on an Android test.

Update the instrumentation in Robolectric to prevent making all public
constructors.

PiperOrigin-RevId: 510049123
2023-02-17 13:08:23 +00:00
huangdarwin
413f61b96d Effect: Rename FrameProcessor
Rename FrameProcessor to VideoFrameProcessor, and GlEffectsFrameProcessor to
DefaultVideoFrameProcessor.

Most changes are semi-mechanical, semi-manual find-replace, preserving case:
* "FrameProc" -> "VideoFrameProc" (ex. FrameProcessor -> VideoFrameProcessor, and
   FrameProcessingException -> VideoFrameProcessingException)
* "GlEffectsVideoFrameProc" -> "DefaultVideoFrameProc"

PiperOrigin-RevId: 509887384
2023-02-17 13:04:02 +00:00
andrewlewis
3e5ae92bc6 Fix some minor nits
PiperOrigin-RevId: 509879029
2023-02-17 12:59:36 +00:00
tofunmi
5168a35654 Change FrameProcessor.create() inputTrackType parameter to a boolean
PiperOrigin-RevId: 509808913
2023-02-15 18:28:54 +00:00
andrewlewis
6d9baa6e99 Skip tests if muxing is unsupported
PiperOrigin-RevId: 509802784
2023-02-15 18:24:47 +00:00
tofunmi
f7621aacc3 Move inputExternalSurfaceTexture to the ExternalTextureManager
Now that the GLEffectFrameProcessor handles external (video) and internal (image) input, components used only for external input needs should be moved to the ExternalTextureManager for code clarity

PiperOrigin-RevId: 509787494
2023-02-15 12:31:27 +00:00
samrobinson
7497b1e003 Use MediaFormatUtil for creating MediaFormat from Format.
PiperOrigin-RevId: 509785247
2023-02-15 12:27:43 +00:00
andrewlewis
3b7cf8f003 Add missing import for ExoPlayer v2 codebase
Issue: google/ExoPlayer#10989
PiperOrigin-RevId: 509771687
2023-02-15 10:49:11 +00:00
samrobinson
bcbe3f1f80 Clarify the mime type used in EncoderUtilTest.
PiperOrigin-RevId: 509750806
2023-02-15 10:45:30 +00:00