2016 Commits

Author SHA1 Message Date
samrobinson
2baa70206c Fix disallowed tag.
If ChannelMixingMatrix is public, this causes code to not build.

PiperOrigin-RevId: 511500694
2023-02-27 18:25:27 +00:00
kimvde
bede06546d 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-27 18:24:22 +00:00
samrobinson
f4d470ac4c 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-27 18:23:29 +00:00
kimvde
9771629498 Make sure that VideoSamplePipeline is picked for image input
PiperOrigin-RevId: 511449658
2023-02-27 18:22:28 +00:00
huangdarwin
d73c0b3cc0 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-27 18:21:39 +00:00
sheenachhabra
2515e39fa2 Move FtypAdjusterTest.java into muxer module
Changes include:
1. Move the test file into muxer module
2. Code improvement
2. Remove dependency from Mp4Slicer library

PiperOrigin-RevId: 511191076
2023-02-27 18:20:48 +00:00
kimvde
2365bbf3db Document that the output file is not deleted in case of error/cancel
PiperOrigin-RevId: 511189130
2023-02-27 18:19:56 +00:00
huangdarwin
465301da7c 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-27 18:18:53 +00:00
kimvde
faad46318b 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-27 18:18:00 +00:00
kimvde
d0dc4817c6 Rename transformation to export in DebugViewProvider
PiperOrigin-RevId: 511173451
2023-02-27 18:16:54 +00:00
samrobinson
3511e08340 Use the supported codec name in DecodeOneFrameUtil.
Tested:
  Before: fusion2/7d7db2d1-1c3e-3df3-8507-73b929c6eac8 (Weekly triage)
  After: sponge2/4c078211-e08c-43fa-91d5-346fccc04bcd (custom run)
PiperOrigin-RevId: 511157461
2023-02-27 18:16:02 +00:00
samrobinson
37bb432869 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-27 18:14:47 +00:00
kimvde
86dca78845 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-27 18:13:58 +00:00
sheenachhabra
85e49fc4e2 Add missing test cases for sample table boxes
Test cases for following boxes are added:
1. stsc
2. co64
3. stss

PiperOrigin-RevId: 511002841
2023-02-27 18:12:57 +00:00
huangdarwin
518fe3771a 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-27 18:12:06 +00:00
samrobinson
0ce1fcc4ad Release the created placeholder surface in DecodeOneFrameUtil.
PiperOrigin-RevId: 511000498
2023-02-27 18:11:18 +00:00
sheenachhabra
a33b0d64c1 Move SampleTableBoxesTest.java into third_party/.../muxer/...
Following changes are included:
1. Move test file into third_party/.../muxer/...
2. Rewrite tests for stts box and stsz box to use dump file infra instead of Mp4Slicer.
3. Remove existing test cases related to stts box which are kind of duplicate as it tries to cover the scenarios which are already covered by "DurationsVuForStts" related test cases.

PiperOrigin-RevId: 510977119
2023-02-27 18:10:23 +00:00
kimvde
ac12b96f11 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-27 18:09:20 +00:00
huangdarwin
e282c0ad67 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-27 18:08:28 +00:00
christosts
ab7e84fb34 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-27 18:07:13 +00:00
tonihei
9eccf09165 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-27 18:06:20 +00:00
huangdarwin
d1df8e21d2 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-27 18:05:16 +00:00
samrobinson
4a7326a286 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-27 18:04:26 +00:00
huangdarwin
92138fc83c Effect: Rename to DefaultShaderProgram.
Rename:
* MatrixShaderProgram to DefaultShaderProgram, and
* FinalMatrixShaderProgramWrapper to FinalShaderProgramWrapper.
PiperOrigin-RevId: 510498547
2023-02-27 18:03:38 +00:00
huangdarwin
84acfe7867 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-27 18:02:45 +00:00
huangdarwin
f295dd4211 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-27 18:01:53 +00:00
tofunmi
1308e22813 fix nits and enhance DefaultVideoFrameProcessorImageFrameOutputTest
resolving comments from 71e92f7512.

PiperOrigin-RevId: 510457401
2023-02-27 18:01:00 +00:00
bachinger
ba49b6b81b Map PLAYER_STATE_LOADING to STATE_BUFFERING
#minor-release
Issue: androidx/media#245
PiperOrigin-RevId: 510456793
2023-02-27 17:59:16 +00:00
tofunmi
71e92f7512 Add multi-image input FrameProcessor tests
PiperOrigin-RevId: 510441777
2023-02-27 17:58:25 +00:00
andrewlewis
b89b13f16b Align test codec caps check with real implementation
PiperOrigin-RevId: 510437262
2023-02-27 17:57:30 +00:00
sheenachhabra
f6155557eb Change DumpableBox to dump recursively
PiperOrigin-RevId: 510433206
2023-02-27 17:56:22 +00:00
kimvde
5806414fba Move generateSilentAudio to Composition
Also rename to forceAudioTrack

PiperOrigin-RevId: 510394620
2023-02-27 17:55:27 +00:00
tofunmi
a1f7960eab InternalTextureManager: delete texture after use
PiperOrigin-RevId: 510377977
2023-02-17 11:57:15 +00:00
Googler
fc642eb45f Fix error in documentation string
The current javadoc refers to the SessionCallback#onConnected, which doesn't exist.

PiperOrigin-RevId: 510261965
2023-02-17 11:55:35 +00:00
sheenachhabra
6711a59564 Move BoxesTest.java into muxer module
Following changes are included:
1. Move BoxesTest.java into muxer module.
2. Change test code to use dump file infra.

BoxesTest.java does not cover all the boxes implemented in Boxes.java so created a WI to track it b/269471752

PiperOrigin-RevId: 510219645
2023-02-17 11:54:46 +00:00
huangdarwin
da8b4db278 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 11:53:53 +00:00
samrobinson
e3484d632f Remove space in exception message.
This space was added by mistake in a prior CL of mine.

PiperOrigin-RevId: 510157363
2023-02-17 11:53:03 +00:00
huangdarwin
77ea31e01c HDR: Add comment explaining force-SDR and AssetLoader interaction.
PiperOrigin-RevId: 510155318
2023-02-17 11:52:13 +00:00
huangdarwin
fb8bbce5f1 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 11:51:23 +00:00
kimvde
221c5afb1b Rename occurrences of transform in lib-transformer
PiperOrigin-RevId: 510118760
2023-02-17 11:50:20 +00:00
andrewlewis
5d8a83f924 Remove Pixel watch check
It's unlikely anyone will try to use Transformer on watches.

PiperOrigin-RevId: 510115645
2023-02-17 11:49:29 +00:00
claincly
cec603393d Fix a missed rename.
PiperOrigin-RevId: 510100709
2023-02-17 11:48:39 +00:00
andrewlewis
2ed5819a19 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 11:45:46 +00:00
kimvde
afb52627b6 Rename TransformationTest to ExportTest
PiperOrigin-RevId: 510087543
2023-02-17 11:44:57 +00:00
huangdarwin
ece49e3515 Effects: Update javadoc to link to method.
PiperOrigin-RevId: 510077348
2023-02-17 11:44:05 +00:00
kimvde
c2fdab847f Rename TransformationException to ExportException
PiperOrigin-RevId: 510062674
2023-02-17 11:42:50 +00:00
Googler
5410286955 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 11:41:53 +00:00
huangdarwin
cf768329e6 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 11:41:06 +00:00
andrewlewis
41a03dd8a6 Fix some minor nits
PiperOrigin-RevId: 509879029
2023-02-17 11:40:13 +00:00
tofunmi
7e33bdfc94 Change FrameProcessor.create() inputTrackType parameter to a boolean
PiperOrigin-RevId: 509808913
2023-02-15 18:17:52 +00:00