Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
8501e997
authored
Oct 14, 2021
by
Kasem
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Fix wrong RF64 data size and add unit test
parent
55a86b8a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
4 deletions
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/wav/WavHeaderReader.java
library/extractor/src/test/java/com/google/android/exoplayer2/extractor/wav/WavExtractorTest.java
testdata/src/test/assets/media/wav/sample_rf64.wav
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/wav/WavHeaderReader.java
View file @
8501e997
...
@@ -48,7 +48,7 @@ import java.io.IOException;
...
@@ -48,7 +48,7 @@ import java.io.IOException;
// Allocate a scratch buffer large enough to store the format chunk.
// Allocate a scratch buffer large enough to store the format chunk.
ParsableByteArray
scratch
=
new
ParsableByteArray
(
16
);
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
);
ChunkHeader
chunkHeader
=
ChunkHeader
.
peek
(
input
,
scratch
);
if
(
chunkHeader
.
id
!=
WavUtil
.
RIFF_FOURCC
&&
chunkHeader
.
id
!=
WavUtil
.
RF64_FOURCC
)
{
if
(
chunkHeader
.
id
!=
WavUtil
.
RIFF_FOURCC
&&
chunkHeader
.
id
!=
WavUtil
.
RF64_FOURCC
)
{
return
null
;
return
null
;
...
@@ -117,7 +117,10 @@ import java.io.IOException;
...
@@ -117,7 +117,10 @@ import java.io.IOException;
ParsableByteArray
scratch
=
new
ParsableByteArray
(
ChunkHeader
.
SIZE_IN_BYTES
);
ParsableByteArray
scratch
=
new
ParsableByteArray
(
ChunkHeader
.
SIZE_IN_BYTES
);
// Skip all chunks until we find the data header.
// Skip all chunks until we find the data header.
ChunkHeader
chunkHeader
=
ChunkHeader
.
peek
(
input
,
scratch
);
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
;
long
dataSize
=
-
1
;
while
(
chunkHeader
.
id
!=
WavUtil
.
DATA_FOURCC
)
{
while
(
chunkHeader
.
id
!=
WavUtil
.
DATA_FOURCC
)
{
if
(
chunkHeader
.
id
!=
WavUtil
.
RIFF_FOURCC
&&
chunkHeader
.
id
!=
WavUtil
.
FMT_FOURCC
)
{
if
(
chunkHeader
.
id
!=
WavUtil
.
RIFF_FOURCC
&&
chunkHeader
.
id
!=
WavUtil
.
FMT_FOURCC
)
{
Log
.
w
(
TAG
,
"Ignoring unknown WAV chunk: "
+
chunkHeader
.
id
);
Log
.
w
(
TAG
,
"Ignoring unknown WAV chunk: "
+
chunkHeader
.
id
);
...
@@ -131,9 +134,9 @@ import java.io.IOException;
...
@@ -131,9 +134,9 @@ import java.io.IOException;
int
ds64Size
=
(
int
)
chunkHeader
.
size
;
int
ds64Size
=
(
int
)
chunkHeader
.
size
;
ParsableByteArray
ds64Bytes
=
new
ParsableByteArray
(
ds64Size
);
ParsableByteArray
ds64Bytes
=
new
ParsableByteArray
(
ds64Size
);
input
.
peekFully
(
ds64Bytes
.
getData
(),
0
,
ds64Size
);
input
.
peekFully
(
ds64Bytes
.
getData
(),
0
,
ds64Size
);
// ds64 chunk contains 64bit sizes. From position
12 to 20
is the data size
// ds64 chunk contains 64bit sizes. From position
8 to 16
is the data size
ds64Bytes
.
setPosition
(
12
);
ds64Bytes
.
setPosition
(
8
);
dataSize
=
ds64Bytes
.
readLong
();
dataSize
=
ds64Bytes
.
readL
ittleEndianL
ong
();
}
}
if
(
bytesToSkip
>
Integer
.
MAX_VALUE
)
{
if
(
bytesToSkip
>
Integer
.
MAX_VALUE
)
{
throw
ParserException
.
createForUnsupportedContainerFeature
(
throw
ParserException
.
createForUnsupportedContainerFeature
(
...
...
library/extractor/src/test/java/com/google/android/exoplayer2/extractor/wav/WavExtractorTest.java
View file @
8501e997
...
@@ -53,4 +53,10 @@ public final class WavExtractorTest {
...
@@ -53,4 +53,10 @@ public final class WavExtractorTest {
ExtractorAsserts
.
assertBehavior
(
ExtractorAsserts
.
assertBehavior
(
WavExtractor:
:
new
,
"media/wav/sample_ima_adpcm.wav"
,
simulationConfig
);
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
);
}
}
}
testdata/src/test/assets/media/wav/sample_rf64.wav
0 → 100644
View file @
8501e997
No preview for this file type
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment