462 Commits

Author SHA1 Message Date
Googler
aaa6561aa9 Rename tests in Boxestest
Replace the box name with Codec name in the test.

PiperOrigin-RevId: 655915063
2024-07-25 05:09:43 -07:00
dancho
7103f21da9 Use WORKING_COLOR_SPACE_DEFAULT in multi-sequence compositions
Build upon Transformer.videoFrameProcessorFactory in MultipleInputVideoGraph
Check that Transformer.videoFrameProcessorFactory is DefaultVideoFrameProcessor
for multi-input video

Fixes https://github.com/androidx/media/issues/1509

PiperOrigin-RevId: 655232381
2024-07-23 11:14:12 -07:00
Googler
b77f1d0f99 Add support for Audio Vorbis codec in Mp4Muxer.
Update esdsBox to support muxing of files encoded with Vorbis audio codec .

PiperOrigin-RevId: 655159074
2024-07-23 07:39:26 -07:00
Googler
3c5c81fc3e BoxesTest: Add default format builders
Move the common initialization code for format builder into separate methods to reduce code duplication.

PiperOrigin-RevId: 655118764
2024-07-23 04:54:32 -07:00
Googler
01dda6d3e5 Add support for Opus audio codec.
Implement dOpsBox to provide support for Opus audio codec

PiperOrigin-RevId: 653288049
2024-07-17 10:51:43 -07:00
samrobinson
d0afb96c40 Implement repeat mode for CompositionPlayer.
-----

Context:
* Each sequence is wrapped as a single MediaSource, each being played
by an underlying ExoPlayer.
* Repeat mode is typically implemented in Players as a seek to the next
item in the playlist.

-----

This CL:

Repeat mode is triggered by listening for when the main input player
sees a play when ready change due to the end of the media item.

There is a slight delay at the end of the playback, before it repeats.
Setting repeat mode on the underlying players addresses this, but means
that the players will seek without waiting for the CompositionPlayer,
and as such previewAudioPipeline does not get the correct signals
around blocking/flushing.

PreviewAudioPipeline - The seek position can validly be C.TIME_UNSET,
however preview pipeline did not handle this case.

CompositionPlayer getContentPosition is given (through a lambda) as a
supplier to the State object, which means any comparisons between
previous/new state for this value does not work. In SimpleBasePlayer,
there is logic to use the positionDiscontinuityPositionUs for the
position change (see getPositionInfo called from
updateStateAndInformListeners), however this logic is not considered in
getMediaItemTransitionReason, so a condition needed to be added for
this case.

-----

Tests:
* Dump files clearly show the position and data is repeated.
* Assertions on the reasons for transitions or position
discontinuities.
PiperOrigin-RevId: 653210278
2024-07-17 06:22:02 -07:00
Googler
951f296851 Add support for 3gpp h263 codec in Mp4Muxer.
Implement d263Box to provide support for muxing video encoded with the h263 codec.

PiperOrigin-RevId: 653188633
2024-07-17 04:53:28 -07:00
Googler
11ca78761e Add support for 3gpp amr-nb audio codec.
To support AMR audio codec(audio/3gpp) add `0x81FF` mode to create damrBox.

Add unit test and an Android end to end test.

PiperOrigin-RevId: 652438693
2024-07-15 04:48:28 -07:00
Googler
735e0cf8a1 Add an MV-HEVC test to Mp4ExtractorParameterizedTest.
PiperOrigin-RevId: 651392787
2024-07-11 06:52:15 -07:00
ktrajkovski
b7f141ad2a Replace sample mp4 files related to IAMF and update the dump files.
PiperOrigin-RevId: 651347968
2024-07-11 03:41:56 -07:00
dancho
0ff9e0723d Expose fMP4 FLAG_READ_WITHIN_GOP_SAMPLE_DEPENDENCIES to DASH
In order for DASH playback to benefit from
FLAG_READ_WITHIN_GOP_SAMPLE_DEPENDENCIES, the fMP4 extractor flag
must be set. The smallest API change that allows this is to add an
experimental method to BundledChunkExtractor.

Add a dash end-to-end test to verify that video frames are skipped at
decoder input.

PiperOrigin-RevId: 651046676
2024-07-10 09:23:35 -07:00
Googler
34a802ef38 Add support to MPEG4 codec in Mp4Muxer.
Add support for MPEG4 codec to enable muxing video encoded with the mp4v-es codec. Use esdsBox method to generate esds box required for Mp4v box.

PiperOrigin-RevId: 651000744
2024-07-10 06:55:00 -07:00
dancho
439536480b Parse the H264 bitstream of fMP4 files to identify sample dependencies
Changes to FragmentedMp4Extractor to parse additional sample dependency
information and mark output samples as "no other samples depend on this".
Only applies to H.264 tracks.
Controlled by new fMP4 flag: FLAG_READ_WITHIN_GOP_SAMPLE_DEPENDENCIES

PiperOrigin-RevId: 650538377
2024-07-09 01:53:51 -07:00
andrewlewis
74c06dc2f4 Add SurfaceAssetLoader
This supports queueing input to Transformer via a `Surface`.

PiperOrigin-RevId: 650318396
2024-07-08 11:33:05 -07:00
rohks
007c258ceb Fix maxInputSize for AMR-NB
The `maxInputSize` for AMR-NB should be 32, not 61. The `maxInputSize` for AMR-WB is 61.

PiperOrigin-RevId: 650282516
2024-07-08 09:52:54 -07:00
Googler
6e18cb0053 Add support for amr-wb audio codec.
Implement damrBox to provide support for amr-wb audio codec.

Add unit test and an Android end to end test.

PiperOrigin-RevId: 650210732
2024-07-08 05:13:18 -07:00
ktrajkovski
35a43d5c43 Add support for IAMF audio in MP4 Extractors.
A new IAMF type can now be recognized as an audio sample entry. A new mime type was created.

PiperOrigin-RevId: 649658865
2024-07-05 08:40:18 -07:00
dancho
40a5d31753 Parse the H264 bitstream of mp4 files to identify sample dependencies
Changes to Mp4Extractor to parse additional sample dependency information
and mark output samples as "no other sample depend on this".
Only applies to H.264 tracks.
Controlled by new mp4 flag: FLAG_READ_WITHIN_GOP_SAMPLE_DEPENDENCIES

PiperOrigin-RevId: 649640184
2024-07-05 06:45:40 -07:00
ibaker
bb2fd002ae Fix TTML handling of inherited percentage tts:fontSize values
The percentage should be interpreted as relative to the size of a parent
node.

This change makes this inheritance work correctly for percentages in
both the parent and child. It does not fix the case of a non-percentage
parent size with a percentage child size.

PiperOrigin-RevId: 649631055
2024-07-05 05:57:54 -07:00
sheenachhabra
3793a06bdd Add support for file format for depth/editing in Mp4Muxer
PiperOrigin-RevId: 648747038
2024-07-02 09:42:36 -07:00
dancho
9939d77d14 Change test to output 16x width and height
PiperOrigin-RevId: 647716870
2024-06-28 10:03:48 -07:00
claincly
174d5ea530 Update test golden images
Now VFP receives actual (un-offsetted) frame presentation time, updates the
test goldens to match.

PiperOrigin-RevId: 647665323
2024-06-28 07:04:47 -07:00
sheenachhabra
aeb8fd134b Write moov box at the start of the file if possible
This is done by reserving some space for moov box at the start of the file and writing it there if it fits. If it doesn't fit, then it is written at the end of the file.

PiperOrigin-RevId: 643944698
2024-06-17 03:38:11 -07:00
ibaker
93af537af7 Parse 'max num reorder samples' values from h.264 and h.265 videos
This value is used in a follow-up change to re-order SEI messages
containing CEA-6/708 data from decode order to presentation order.

PiperOrigin-RevId: 643296338
2024-06-14 03:31:38 -07:00
tofunmi
174c49313c support hdr text overlays
adds luminance multiplier to allow the luminance (i.e. brightness) over a text overlay to be scaled

PiperOrigin-RevId: 643047928
2024-06-13 10:41:09 -07:00
rohks
df5352752f Add a drop-in replacement for MediaExtractor in Media3
This change introduces a new class in Media3 `MediaExtractorCompat`, designed to be a drop-in replacement for platform `MediaExtractor`. While not all APIs are currently supported, the core functionality for the most common use cases of `MediaExtractor` is now available. Full API compatibility will be achieved in the future.

PiperOrigin-RevId: 643045429
2024-06-13 10:33:38 -07:00
tianyifeng
86a60e6ec2 Schedule refresh for all the playing playlists for HLS live stream
Issue: androidx/media#1240
PiperOrigin-RevId: 642927082
2024-06-13 03:52:16 -07:00
dancho
abf601feaa Support upscaling with LanczosResample
Avoid scaling the lanczos windown function when scaling up.
When scaling up (output > input), we shouldn't scale the window
function or we risk not sampling any of the input pixels.

PiperOrigin-RevId: 641838149
2024-06-10 03:01:11 -07:00
tofunmi
228d63848e HDR-only assets sequence effect test: rename golden files
rename to match test name

PiperOrigin-RevId: 641836522
2024-06-10 02:53:34 -07:00
tofunmi
0d2fdcd025 Add Transformer HDR-only assets sequence effect tests.
PiperOrigin-RevId: 641828107
2024-06-10 02:11:09 -07:00
claincly
39e572ad6d Fix a concurrency issue that shader capacity is set off GL thread
Also add test to cover transitions between BT709 and 601.

PiperOrigin-RevId: 641224971
2024-06-07 05:59:20 -07:00
samrobinson
67c19f87a7 Update FILE_UNKNOWN_DURATION to a longer fmp4 (~15s),
Removes the flakiness of
MediaItemExportTest.getProgress_unknownDuration_returnsConsistentStates
by using a longer input asset, such that ExoPlayer does not determine
the duration of the media.

PiperOrigin-RevId: 640502470
2024-06-05 06:19:11 -07:00
dancho
9c4a532d5c Add LanczosResample effect to scale videos in Transformer
Add SeparableConvolution.configure(inputSize) to allow effect configuration
depending on input dimensions.
Add LanczosResample.scaleToFit method to scale input images to fit inside
given dimensions.

PiperOrigin-RevId: 640498008
2024-06-05 06:00:25 -07:00
dancho
73dd743929 Support Separable Convolutions with negative coefficients
fragment_shader_separable_convolution_es2.glsl had optimizations that assumed
all convolution coefficients are positive. Support negative coefficients,
and add tests.

PiperOrigin-RevId: 640104741
2024-06-04 04:26:26 -07:00
dancho
2bb12de00d Drop API requirement from SeparableConvolution
Switch from 4-channel RGBA_16F lookup texture to 1-channel R_16F.
Do not use a bitmap when creating the lookup table texture.
Instead, fill the texture directly.
Do not manually convert 32-bit float to 16-bit. Instead, let OpenGL
libraries do this for us.

PiperOrigin-RevId: 639717235
2024-06-03 03:31:41 -07:00
rohks
387153fcf2 Fix CMCD data assignment for init segment
The CMCD data was incorrectly added to the `dataSpec` of the media segment instead of the init segment.

Also relaxed the condition for playbackRate to be C.RATE_UNSET when creating an instance of CmcdData.Factory as there was nothing enforcing this check.

#minor-release

PiperOrigin-RevId: 639046080
2024-05-31 08:42:53 -07:00
kimvde
151a2be141 Regenerate TransformerHdrTest goldens after removing degammaing
Degammaing has been removed in cb4b2ea55c. The goldens for
TransformerHdrTest (previously TransformerSequenceEffectTestWithHdr)
were not regenerated because the test wasn't running due to its name
(fixed in e41a966237).

PiperOrigin-RevId: 638645635
2024-05-30 07:32:22 -07:00
dancho
02df88e5d9 Speed up image to video Export
Only sample from input bitmap when the input image has changed.
Introduce GainmapShaderProgram.newImmutableBitmap API that signals
input bitmap changes to GainmapShaderProgram (DefaultShaderProgram).

PiperOrigin-RevId: 637920207
2024-05-28 09:12:24 -07:00
tofunmi
9622411b50 Add support for ultra HDR overlays
PiperOrigin-RevId: 637863706
2024-05-28 05:28:03 -07:00
tofunmi
8feaf82768 UltraHdr: Fix calculations to apply gainmap
PiperOrigin-RevId: 636964921
2024-05-24 10:39:36 -07:00
tofunmi
db6144e7dd Maintain a consistent luminance range across HDR content in effects
PQ and HLG have different luminance ranges (max 10k nits and max 1k nits resp). In GL, colors work in a normalised 0 to 1 scale, so for PQ content, 1=10k nits and and for HLG content, 1=1k nits.

This cl scales and normalises PQ content appropriately so that all HDR content works in the HLG luminance range. This fixes two things

1. Conversions between HLG and PQ are "fixed" (before the output colors looked too bright or too dark depending on which way you are converting)
2. color-altering effects will be able to work consistently across HLG and PQ content

1 is tested in this cl. 2 will be tested when ultra HDR overlays are implemented, both cases have been manually tested to ensure the output looks correct on a screen.

PiperOrigin-RevId: 636851701
2024-05-24 03:05:34 -07:00
Googler
37c2d9957e Fragmented Mp4Muxer: add support to B-frame Muxing
Add composition time offset parameter to TRUN box to
support muxing of videos containing B-frames by FragmentedMp4Muxer.
Update TRUN box version from 0 to 1 in order to manage signed
composition time offset.

PiperOrigin-RevId: 636426397
2024-05-22 23:07:35 -07:00
tonihei
9ccc4b27ef Add test and formatting changes 2024-05-22 15:08:52 +01:00
ibaker
5b3066f380 MP3: Derive duration and bitrate from frame count in Info header
`Info` header is used for CBR files, but in some cases not **every**
frame in these files is the same size. This change stops using the
single frame after the `Info` frame as the 'template' (and assuming all
subsequent frames are the same size/bitrate), and instead derives the
bitrate from fields in the `Info` header. This works for files which are
'almost' constant bitrate, like the one in Issue: androidx/media#1376 where every
frame is either 1044 or 1045 bytes except the one immediately after the
`Info` frame which is 104 bytes (32kbps), resulting in a wildly
incorrect duration calculation.

PiperOrigin-RevId: 636151605
2024-05-22 06:59:10 -07:00
dancho
c2fb2f1520 Work around 1080p export failures on certain devices
Fall back to using software decoder for 1920x1080 for certain
devices.

PiperOrigin-RevId: 636132298
2024-05-22 05:38:50 -07:00
ibaker
17bf47ed24 MP3: Add test CBR sample with 'too small' PCUT frame
This shows ExoPlayer currently wrongly reports the duration of this
sample, because it assumes every frame is 32kbps (104 bytes) due to the
`PCUT` frame immediately after the `Info` frame.

A follow-up change will modify `Info` frame handling to resolve this
issue.

This sample was crafted using a hex editor to insert the additional
`PCUT` frame (the pattern of `null` and `x` is taken from the sample
file in Issue: androidx/media#1376, the header is modified to set the channel count
to 1 to match the rest of the file), and then update the frame count
and data size of the `Info` header to match.

Issue: androidx/media#1376
PiperOrigin-RevId: 635772837
2024-05-21 05:31:44 -07:00
dancho
ae240606db Move bitmap coordinate flip out of fragment shader
Fragment shaders in OpenGL ES shader language aren't guaranteed
to support highp, required to correctly represent pixel coordinates
inside large images (e.g. 1920x1080).
This change moves coordinate mirroring for images out of fragment shader.

Fixes http://Issue: androidx/media#1331

PiperOrigin-RevId: 635732208
2024-05-21 02:31:43 -07:00
dancho
b047e81e02 Work around SurfaceTexture implicit scale
If MediaCodec allocates passes an image buffer with a cropped region,
SurfaceTexture.getTransformMatrix will cut off 2 pixels from each dimensions.
The resulting videos will appear a little stretched.

This patch inspects the SurfaceTexture transform matrix, and guesses what the
unscaled transform matrix should be.
Behind experimentalAdjustSurfaceTextureTransformationMatrix flag

PiperOrigin-RevId: 635721267
2024-05-21 01:46:21 -07:00
dancho
b9ec24a269 Fix AV sync for sequences with audio track shorter than video
For each item, AudioGraphInput now pads the input audio track with silence
to the duration given in onMediaItemChanged.

Possibly resolves Issue: androidx/media#921 .

PiperOrigin-RevId: 634753721
2024-05-17 06:54:39 -07:00
tofunmi
7b357337d2 Support AVIF in exoplayer
https://developer.android.com/media/platform/supported-formats#image-formats was updated to include AVIF support in API 34+, so <unknown commit> updated our associated Util's to reflect this. After that change, ExoPlayer's BitmapFactoryImageDecoder will be able to decode AVIF, but the player won't be able to detect or extract it. Add this support for completeness, so that ExoPlayer can continue to say it supports all formats in https://developer.android.com/media/platform/supported-formats#image-formats.

PiperOrigin-RevId: 633956245
2024-05-15 08:04:41 -07:00