mirror of
https://github.com/samsonjs/media.git
synced 2026-04-04 11:05:47 +00:00
Fix wrong RF64 data size and add unit test
This commit is contained in:
parent
55a86b8a00
commit
8501e997e0
3 changed files with 13 additions and 4 deletions
|
|
@ -48,7 +48,7 @@ import java.io.IOException;
|
|||
// Allocate a scratch buffer large enough to store the format chunk.
|
||||
ParsableByteArray scratch = new ParsableByteArray(16);
|
||||
|
||||
// Attempt to read the RIFF chunk.
|
||||
// Attempt to read the RIFF or RF64 chunk.
|
||||
ChunkHeader chunkHeader = ChunkHeader.peek(input, scratch);
|
||||
if (chunkHeader.id != WavUtil.RIFF_FOURCC && chunkHeader.id != WavUtil.RF64_FOURCC) {
|
||||
return null;
|
||||
|
|
@ -117,7 +117,10 @@ import java.io.IOException;
|
|||
ParsableByteArray scratch = new ParsableByteArray(ChunkHeader.SIZE_IN_BYTES);
|
||||
// Skip all chunks until we find the data header.
|
||||
ChunkHeader chunkHeader = ChunkHeader.peek(input, scratch);
|
||||
|
||||
// Data size holder. To be determined from data chunk or ds64 chunk in case of RF64.
|
||||
long dataSize = -1;
|
||||
|
||||
while (chunkHeader.id != WavUtil.DATA_FOURCC) {
|
||||
if (chunkHeader.id != WavUtil.RIFF_FOURCC && chunkHeader.id != WavUtil.FMT_FOURCC) {
|
||||
Log.w(TAG, "Ignoring unknown WAV chunk: " + chunkHeader.id);
|
||||
|
|
@ -131,9 +134,9 @@ import java.io.IOException;
|
|||
int ds64Size = (int) chunkHeader.size;
|
||||
ParsableByteArray ds64Bytes = new ParsableByteArray(ds64Size);
|
||||
input.peekFully(ds64Bytes.getData(), 0, ds64Size);
|
||||
// ds64 chunk contains 64bit sizes. From position 12 to 20 is the data size
|
||||
ds64Bytes.setPosition(12);
|
||||
dataSize = ds64Bytes.readLong();
|
||||
// ds64 chunk contains 64bit sizes. From position 8 to 16 is the data size
|
||||
ds64Bytes.setPosition(8);
|
||||
dataSize = ds64Bytes.readLittleEndianLong();
|
||||
}
|
||||
if (bytesToSkip > Integer.MAX_VALUE) {
|
||||
throw ParserException.createForUnsupportedContainerFeature(
|
||||
|
|
|
|||
|
|
@ -53,4 +53,10 @@ public final class WavExtractorTest {
|
|||
ExtractorAsserts.assertBehavior(
|
||||
WavExtractor::new, "media/wav/sample_ima_adpcm.wav", simulationConfig);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sample_RF64() throws Exception {
|
||||
ExtractorAsserts
|
||||
.assertBehavior(WavExtractor::new, "media/wav/sample_rf64.wav", simulationConfig);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
BIN
testdata/src/test/assets/media/wav/sample_rf64.wav
vendored
Normal file
BIN
testdata/src/test/assets/media/wav/sample_rf64.wav
vendored
Normal file
Binary file not shown.
Loading…
Reference in a new issue