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
55a86b8a
authored
Oct 05, 2021
by
Kasem SAEED
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add support for RF64 wave files
parent
47573d45
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
3 deletions
library/extractor/src/main/java/com/google/android/exoplayer2/audio/WavUtil.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/wav/WavHeaderReader.java
library/extractor/src/main/java/com/google/android/exoplayer2/audio/WavUtil.java
View file @
55a86b8a
...
@@ -22,6 +22,10 @@ import com.google.android.exoplayer2.util.Util;
...
@@ -22,6 +22,10 @@ import com.google.android.exoplayer2.util.Util;
/** Utilities for handling WAVE files. */
/** Utilities for handling WAVE files. */
public
final
class
WavUtil
{
public
final
class
WavUtil
{
/** Four character code for "RF64". */
public
static
final
int
RF64_FOURCC
=
0x52463634
;
/** Four character code for "ds64". */
public
static
final
int
DS64_FOURCC
=
0x64733634
;
/** Four character code for "RIFF". */
/** Four character code for "RIFF". */
public
static
final
int
RIFF_FOURCC
=
0x52494646
;
public
static
final
int
RIFF_FOURCC
=
0x52494646
;
/** Four character code for "WAVE". */
/** Four character code for "WAVE". */
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/wav/WavHeaderReader.java
View file @
55a86b8a
...
@@ -50,7 +50,7 @@ import java.io.IOException;
...
@@ -50,7 +50,7 @@ import java.io.IOException;
// Attempt to read the RIFF chunk.
// Attempt to read the RIFF chunk.
ChunkHeader
chunkHeader
=
ChunkHeader
.
peek
(
input
,
scratch
);
ChunkHeader
chunkHeader
=
ChunkHeader
.
peek
(
input
,
scratch
);
if
(
chunkHeader
.
id
!=
WavUtil
.
RIFF_FOURCC
)
{
if
(
chunkHeader
.
id
!=
WavUtil
.
RIFF_FOURCC
&&
chunkHeader
.
id
!=
WavUtil
.
RF64_FOURCC
)
{
return
null
;
return
null
;
}
}
...
@@ -117,14 +117,23 @@ import java.io.IOException;
...
@@ -117,14 +117,23 @@ 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
);
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
);
}
}
long
bytesToSkip
=
ChunkHeader
.
SIZE_IN_BYTES
+
chunkHeader
.
size
;
long
bytesToSkip
=
ChunkHeader
.
SIZE_IN_BYTES
+
chunkHeader
.
size
;
// Override size of RIFF chunk, since it describes its size as the entire file.
// Override size of RIFF chunk, since it describes its size as the entire file.
if
(
chunkHeader
.
id
==
WavUtil
.
RIFF_FOURCC
)
{
// Also, ignore the size of RF64 chunk, since its always going to be 0xFFFFFFFF
if
(
chunkHeader
.
id
==
WavUtil
.
RIFF_FOURCC
||
chunkHeader
.
id
==
WavUtil
.
RF64_FOURCC
)
{
bytesToSkip
=
ChunkHeader
.
SIZE_IN_BYTES
+
4
;
bytesToSkip
=
ChunkHeader
.
SIZE_IN_BYTES
+
4
;
}
else
if
(
chunkHeader
.
id
==
WavUtil
.
DS64_FOURCC
)
{
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
();
}
}
if
(
bytesToSkip
>
Integer
.
MAX_VALUE
)
{
if
(
bytesToSkip
>
Integer
.
MAX_VALUE
)
{
throw
ParserException
.
createForUnsupportedContainerFeature
(
throw
ParserException
.
createForUnsupportedContainerFeature
(
...
@@ -133,11 +142,15 @@ import java.io.IOException;
...
@@ -133,11 +142,15 @@ import java.io.IOException;
input
.
skipFully
((
int
)
bytesToSkip
);
input
.
skipFully
((
int
)
bytesToSkip
);
chunkHeader
=
ChunkHeader
.
peek
(
input
,
scratch
);
chunkHeader
=
ChunkHeader
.
peek
(
input
,
scratch
);
}
}
// Use size from data chunk if it wasn't determined from ds64 chunk
if
(
dataSize
==
-
1
)
{
dataSize
=
chunkHeader
.
size
;
}
// Skip past the "data" header.
// Skip past the "data" header.
input
.
skipFully
(
ChunkHeader
.
SIZE_IN_BYTES
);
input
.
skipFully
(
ChunkHeader
.
SIZE_IN_BYTES
);
long
dataStartPosition
=
input
.
getPosition
();
long
dataStartPosition
=
input
.
getPosition
();
long
dataEndPosition
=
dataStartPosition
+
chunkHeader
.
s
ize
;
long
dataEndPosition
=
dataStartPosition
+
dataS
ize
;
long
inputLength
=
input
.
getLength
();
long
inputLength
=
input
.
getLength
();
if
(
inputLength
!=
C
.
LENGTH_UNSET
&&
dataEndPosition
>
inputLength
)
{
if
(
inputLength
!=
C
.
LENGTH_UNSET
&&
dataEndPosition
>
inputLength
)
{
Log
.
w
(
TAG
,
"Data exceeds input length: "
+
dataEndPosition
+
", "
+
inputLength
);
Log
.
w
(
TAG
,
"Data exceeds input length: "
+
dataEndPosition
+
", "
+
inputLength
);
...
...
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