Commit d5cb1007 by olly Committed by Ian Baker

Fix Sample Size For Supplemental Data In MatroskaExtractor

For when a track is both encrypted and has supplemental data, the sample size will be equal to `block sample size - encryption data size`.

PiperOrigin-RevId: 427807612
parent 2a187cbf
...@@ -1550,12 +1550,13 @@ public class MatroskaExtractor implements Extractor { ...@@ -1550,12 +1550,13 @@ public class MatroskaExtractor implements Extractor {
blockFlags |= C.BUFFER_FLAG_HAS_SUPPLEMENTAL_DATA; blockFlags |= C.BUFFER_FLAG_HAS_SUPPLEMENTAL_DATA;
blockAdditionalData.reset(/* limit= */ 0); blockAdditionalData.reset(/* limit= */ 0);
// If there is supplemental data, the structure of the sample data is: // If there is supplemental data, the structure of the sample data is:
// sample size (4 bytes) || sample data || supplemental data // encryption data (if any) || sample size (4 bytes) || sample data || supplemental data
int sampleSize = size + sampleStrippedBytes.limit() - sampleBytesRead;
scratch.reset(/* limit= */ 4); scratch.reset(/* limit= */ 4);
scratch.getData()[0] = (byte) ((size >> 24) & 0xFF); scratch.getData()[0] = (byte) ((sampleSize >> 24) & 0xFF);
scratch.getData()[1] = (byte) ((size >> 16) & 0xFF); scratch.getData()[1] = (byte) ((sampleSize >> 16) & 0xFF);
scratch.getData()[2] = (byte) ((size >> 8) & 0xFF); scratch.getData()[2] = (byte) ((sampleSize >> 8) & 0xFF);
scratch.getData()[3] = (byte) (size & 0xFF); scratch.getData()[3] = (byte) (sampleSize & 0xFF);
output.sampleData(scratch, 4, TrackOutput.SAMPLE_DATA_PART_SUPPLEMENTAL); output.sampleData(scratch, 4, TrackOutput.SAMPLE_DATA_PART_SUPPLEMENTAL);
sampleBytesWritten += 4; sampleBytesWritten += 4;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment