mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00

ExoPlayer assumed 4-bytes for length in two places (by assuming the length is the same as the 4-byte NAL start code): 1. In `AvcConfig` we transform length-delimited to start-delimited before writing into `initializationData`, and then skip 'nal unit length field' bytes when parsing from `initializationData` (when we should skip 'start code length' bytes instead). 2. In `Mp4Extractor.readSample` we modify the local variable `sampleSize` to fix the difference between length field length and start code length, but **only on the first attempt to read a sample**. If we are resuming in the middle of reading a sample (after a recoverable I/O error), this fix for `sampleSize` is not done, which means we end up missing the last 2-3 bytes of the sample when the NAL length is 1-2 bytes. * This is fixed by moving the `sampleSize` 'fixing' code to outside the `if (sampleCurrentNalBytesRemaining == 0)` block. * `FragmentedMp4Extractor` has very similar code, but uses a field for `sampleSize`, rather than a local, so doesn't look vulnerable to the same problem (though I haven't totally tested this). This change adds a test file with 2-byte NAL lengths, generated by hacking the media3 muxer to emit 2-byte NAL lengths and transforming `sample.mp4` using the transformer demo app. PiperOrigin-RevId: 713709203
Test data module
Provides sample data for media unit and instrumentation tests.