423 Commits

Author SHA1 Message Date
ibaker
711d18de03 Fix index out of bounds exception when a Subtitle is empty
Issue: androidx/media#1516

#cherrypick

PiperOrigin-RevId: 648416119
2024-07-01 10:40:15 -07:00
Googler
3da63eeaa7 Add NAL unit parsing needed for stereo MV-HEVC playback.
Add the following NAL unit parsing utility functions that will be needed for the MV-HEVC support as proposed in Apple's HEVC stereo video interoperability profile:
- NAL unit header parsing to get the layer information needed for MV-HEVC support.
- VPS parsing, including vps_extension() needed for MV-HEVC support.
- SPS parsing modifications to support MV-HEVC.

PiperOrigin-RevId: 647329211
2024-06-27 08:39:12 -07:00
tonihei
867410fece Rename DummyTrackOutput and DummyExtractorOutput
#cherrypick

PiperOrigin-RevId: 646434450
2024-06-25 05:07:56 -07:00
kimvde
d27549d29a Skip 4K export test on Pixel 3a
PiperOrigin-RevId: 644659699
2024-06-19 01:18:05 -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
andrewlewis
a0312615f2 Fix AVI extractor WAVE format extraction
Allow `WAVEFORMAT` (in addition to `WAVEFORMATEX`), which omits initialization
data.

Fix reading of bits per sample to use little endian byte order like the other
reads. See also the wave format docs linked from
https://learn.microsoft.com/en-us/windows/win32/directshow/avi-riff-file-reference#avi-stream-headers.

PiperOrigin-RevId: 642962893
2024-06-13 06:19:10 -07:00
Googler
32d7516237 Add helper function in Track.java to copy track without edit lists.
PiperOrigin-RevId: 642038117
2024-06-10 15:19:29 -07:00
ibaker
08d1eb4376 Remove ShadowLog references from tests
These were accidentally submitted after being added for local debugging.

PiperOrigin-RevId: 636865825
2024-05-24 04:10:27 -07:00
Ian Baker
3aebb38cd3 Rename and reshuffle tests 2024-05-23 15:27:19 +01:00
datdoantelus
ed5d47e856 Add cea708Decoder test for setPenLocation command and newline handling 2024-05-23 15:22:13 +01:00
datdoantelus
327d26cb32 remove test comment 2024-05-23 15:21:45 +01:00
datdoantelus
ec3065e981 revert rowLock and colomnLock changes since it will be done separately 2024-05-23 15:21:32 +01:00
datdoantelus
3b7ec52ca8 Ignore rowLock and numLock as define in CTA-708 spec.
Update current row value when new line is added.
2024-05-23 15:21:11 +01:00
ibaker
8d515c8cdc MP3: Make a defensive copy of the header in XingFrame constructor
This is currently set from `Mp3Extractor.synchronizedHeader` which
gets overwritten every time we read a new frame. It seems safer to make
this defensive copy (and there will be at most one `XingFrame` instance
per-playback, so this is not prohibitively expensive).

PiperOrigin-RevId: 636181038
2024-05-22 08:48:35 -07: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
ibaker
8fdf105ab4 Re-apply CEA-608 validDataChannelTimeoutMs assertion
This change was originally made in 379cb3ba54.

It was then accidentally lost in when `Cea608Parser` was merged back
into `Cea608Decoder` in 25498b151b.

This was spotted when re-doing a similar lost change to `Cea708Decoder`,
reported in https://github.com/androidx/media/pull/1315.

See reasoning on e2847b3b80
about why this is the only 'lost' CEA-608 change.

PiperOrigin-RevId: 635803536
2024-05-21 07:45:35 -07:00
ibaker
e2847b3b80 Re-apply CEA-708 rowLock/columnLock fix
This change was originally made in 6f8249184b

It was then accidentally lost in when `Cea708Parser` was merged back
into `Cea708Decoder` in 51b4fa2cc8.

This is the only change made to the actual 'decoding' logic in
`Cea708Parser` between it being split from `Cea708Decoder` and merged
back in again, all the other changes in this period relate to the
implementation of the `SubtitleParser` interface, so don't need to be
preserved in `Cea708Decoder`:
51b4fa2cc8/libraries/extractor/src/main/java/androidx/media3/extractor/text/cea/Cea708Parser.java

`Cea608Parser` was also merged back into `Cea608Decoder` in
25498b151b
and so is vulnerable to the same risk of accidental loss of changes. To
be sure, I also checked the history of this file:
25498b151b/libraries/extractor/src/main/java/androidx/media3/extractor/text/cea/Cea608Parser.java

The only 'decoding logic' change there is 379cb3ba54,
which was also lost in 25498b151b.
I will send a separate change to resolve this.

PiperOrigin-RevId: 635796696
2024-05-21 07:16:04 -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
ibaker
eca6cb23d8 Clean up unused members in XingFrame
PiperOrigin-RevId: 634817614
2024-05-17 10:26:49 -07:00
ibaker
2ac8247cf4 Fix and/or bug in XingSeeker
This was accidentally introduced in 4fde35c9cc

PiperOrigin-RevId: 634465380
2024-05-16 11:06:05 -07:00
Ian Baker
743e7942b6 Format with google-java-format and add release note 2024-05-16 10:04:49 +01:00
Simon Hung
d2f677bc4c Update PgsParser.java
Fix "subtitles rendered with border and no fill color" problem:
https://github.com/moneytoo/Player/issues/413

because '0' means it's an index to the palette table, not an RGBA value of 0
2024-05-16 10:02:46 +01:00
ibaker
0352db9a37 Default to parse subtitles while extracting, instead of while rendering
To override this change, and go back to parsing during rendering,
apps must make two method calls:

1. `MediaSource.Factory.experimentalParseSubtitlesDuringExtraction(false)`
2. `TextRenderer.experimentalSetLegacyDecodingEnabled(true)`

PiperOrigin-RevId: 634262798
2024-05-16 01:42:56 -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
ibaker
ed4820cb61 Remove @UnstableApi from package-private files
This annotation is only needed on public classes.

This change also removes the `/* package */` comment from some `public`
classes.

PiperOrigin-RevId: 633864544
2024-05-15 02:26:55 -07:00
ibaker
f73c24a10d Bump Truth dep to 1.4.0 so we can assert directly on Java 8 types
https://truth.dev/faq#java8

Also use this change to remove most test usages of
`Lists.transform(...)` and replace them with `.stream().map(...)`.

PiperOrigin-RevId: 633523904
2024-05-14 03:38:31 -07:00
rohks
e25bd07a81 Parse initialization data from AV1 tracks
Initialization data is not passed to `MediaCodecRenderer` as it is not required for playing AV1 video.

See: https://developer.android.com/reference/android/media/MediaCodec#CSD
PiperOrigin-RevId: 629729301
2024-05-01 08:23:43 -07:00
tonihei
1af86d4c4d Fix issue where subtitles starting before a seek position are skipped
These subtitles were skipped because they are marked as shouldBeSkipped
based on their timestamps. The fix removes this flag entirely in
SimpleSubtitleDecoder because TextRenderer handles potential skipping
if needed.

PiperOrigin-RevId: 629717970
2024-05-01 07:34:40 -07:00
Rohit Singh
a09c2f1701 Add boolean input to MpeghReader 2024-04-30 16:36:51 +01:00
Rohit Singh
0a436ad491 Use inclusive language 2024-04-30 16:31:50 +01:00
Rohit Singh
1ab91a64c2 Refactor and add release notes 2024-04-30 16:31:50 +01:00
Rohit Singh
e1294c0d5c Format with google-java-format 2024-04-30 16:31:50 +01:00
Daniele Sparano
029b8bad86 Fix H264 transformer test, fix H265 byterange case; re-enable file H262 case 2024-04-30 16:31:50 +01:00
Rohit Singh
3cafb08a32 Fix condition to send dummy end of input and update dump files 2024-04-30 16:31:50 +01:00
Rohit Singh
4b14bc2c3e Format with google-java-format 2024-04-30 16:31:50 +01:00
Daniele Sparano
b82f4b8e28 Tidy up dummy pusi, do not apply to H262 streams 2024-04-30 16:31:50 +01:00
Daniele Sparano
85826ebc19 Fix dummy pusi solution for byte range and key frame only NAL stream cases 2024-04-30 16:31:49 +01:00
Tofunmi Adigun-Hameed
c002ff6a6f Merge pull request #419 from v-novaltd:vnova-104 2024-04-30 16:31:49 +01:00
Rohit Kumar Singh
43f098da0f Merge Issue: androidx/media#882: Extend MPEG2TS implementation with MPEG-H support
Imported from GitHub PR https://github.com/androidx/media/pull/882

Merge 27a4c43de6294a5482b85ff8e2b4501057f3e946 into a49b625cc585970843f27410b614c6470924e7e5

COPYBARA_INTEGRATE_REVIEW=https://github.com/androidx/media/pull/882 from androidx:ts_mpegh_reader_patch 27a4c43de6294a5482b85ff8e2b4501057f3e946
PiperOrigin-RevId: 629132035
2024-04-29 11:33:38 -07:00
ibaker
96bc9e9652 Propagate ID3 TCON frame to MediaMetada.genre
This change also includes mapping the numeric ID3v1 codes to their
string equivalents before setting them into `MediaMetadata`. This
mapping already existed, but it was previously only used when parsing
MP4 `gnre` atoms.

Issue: androidx/media#1305
PiperOrigin-RevId: 629113480
2024-04-29 10:38:51 -07:00
rohks
c6492e01e4 Remove redundant final in PesReader methods
Since the class is final, declaring the overridden methods as final is unnecessary.

PiperOrigin-RevId: 629103982
2024-04-29 10:12:05 -07:00
ibaker
b0e48175f0 Add ID3 TCON genre to MP3 test samples
This change adds a 'free-form' text genre to the existing
`bear-id3.mp3` sample, and adds a new sample with a 'numeric' genre ([9
is Metal](https://mutagen-specs.readthedocs.io/en/latest/id3/id3v2.4.0-frames.html#appendix-a-genre-list-from-id3v1)).

The samples were modified with:

```shell
$ id3edit --set-genre "Gorpcore" bear-id3.mp3
$ id3edit --set-genre "9" bear-id3-numeric-genre.mp3
```

Reading the numeric genre with `exiftool` shows the mapping back to
'Metal':

```
$ exiftool bear-id3-numeric-genre.mp3 | grep Genre
Genre                           : Metal
```

The playback dumps don't contain the genre because it's not yet
propagated to `MediaMetadata.genre`. That is done in a follow-up
change.

Issue: androidx/media#1305
PiperOrigin-RevId: 629043506
2024-04-29 06:03:39 -07:00
ibaker
e194225b32 Fix parsing some MP4 metadata fields we wrongly assumed were 1 byte
This fixes parsing the `gnre` and `tmpo` values, as seen in the test
dump changes in this CL.

Issue: androidx/media#1305
PiperOrigin-RevId: 628352773
2024-04-26 03:30:14 -07:00
ibaker
d76ee54ca6 Add two MP4 samples with metadata
The first has a string genre, and various other values set, generated
from `sample.mp4` with the command below [1].

The second has a numeric genre, to test `gnre` atom parsing. This
parsing is currently broken, the fix is in a follow-up change. This
file was also generated from `sample.mp4` with the command below [2].

This change also includes `CommentFrame.text` in its `toString`
representation, otherwise there's no difference between e.g. different
levels of `ITUNESADVISORY` in the extractor dump files.

Issue: androidx/media#1305

-----

[1]

```shell
$ AP_PADDING="DEFAULT_PAD=0" \
    AtomicParsley sample.mp4 \
    --artist "Test Artist" \
    --album "Test Album" \
    --tracknum 2/12 \
    --disk 2/3 \
    --year 2024  \
    --genre "Gorpcore" \
    --bpm 120 \
    --compilation true \
    --advisory clean \
    --gapless true \
    --sortOrder artist "Sorting Artist" \
    --sortOrder album "Sorting Album" \
    --preventOptimizing \
    -o sample_with_metadata.mp4
```

[2]
```shell
$ AP_PADDING="DEFAULT_PAD=0" \
    AtomicParsley sample.mp4 \
    --genre "Metal" \
    --preventOptimizing \
    -o sample_with_numeric_genre.mp4
```

PiperOrigin-RevId: 628345458
2024-04-26 02:53:33 -07:00
ibaker
3322092070 Fix MP4 ID3 sort tag mapping
The ID3 tags are documented here:
https://wiki.hydrogenaud.io/index.php?title=Foobar2000:ID3_Tag_Mapping

The MP4 fourcc types are documented here:
https://mutagen.readthedocs.io/en/latest/api/mp4.html#mutagen.mp4.MP4Tags

From the field definitions at the top of this file:

* `TYPE_SORT_ALBUM = 0x736f616c = 'soal'`
* `TYPE_SORT_ARTIST = 0x736f6172 = 'soar'`
* `TYPE_SORT_ALBUM_ARTIST = 0x736f6161 = 'soaa'`

Issue: androidx/media#1302

#minor-release

PiperOrigin-RevId: 627486902
2024-04-23 13:29:40 -07:00
rohks
8ff9e4a838 Add test for H.264 I-frames only track in TsExtractorTest
Sample is created by re-encoding the existing H.264 sample with `ffmpeg`.

PiperOrigin-RevId: 627470063
2024-04-23 12:30:11 -07:00
ibaker
b60cd2c033 Rollback of e665e2aee8
PiperOrigin-RevId: 619871653
2024-03-28 04:04:01 -07:00
ibaker
7a105e0e57 Fix XingSeeker @param tags - follow-up to 4fde35c9cc
PiperOrigin-RevId: 619249887
2024-03-26 11:11:58 -07:00
ibaker
d00ca1e343 Plumb MP3 average bitrate from metadata frames into Format
Issue: androidx/media#1081

#minor-release

PiperOrigin-RevId: 619185083
2024-03-26 07:40:08 -07:00
tonihei
6e0f8e3b0d Remove decode-only flag
No known component is using this flag anymore and it has been
deprecated for a while for custom renderers and decoders.

PiperOrigin-RevId: 619154299
2024-03-26 05:28:27 -07:00