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
6d20a5cf
authored
Jul 31, 2019
by
olly
Committed by
Oliver Woodman
Aug 01, 2019
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
WavExtractor: Skip to data start position if position reset to 0
PiperOrigin-RevId: 260970865
parent
c373ff0a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
9 deletions
library/core/src/main/java/com/google/android/exoplayer2/extractor/wav/WavExtractor.java
library/core/src/main/java/com/google/android/exoplayer2/extractor/wav/WavHeader.java
library/core/src/main/java/com/google/android/exoplayer2/extractor/wav/WavHeaderReader.java
library/core/src/main/java/com/google/android/exoplayer2/extractor/wav/WavExtractor.java
View file @
6d20a5cf
...
...
@@ -87,6 +87,8 @@ public final class WavExtractor implements Extractor {
if
(!
wavHeader
.
hasDataBounds
())
{
WavHeaderReader
.
skipToData
(
input
,
wavHeader
);
extractorOutput
.
seekMap
(
wavHeader
);
}
else
if
(
input
.
getPosition
()
==
0
)
{
input
.
skipFully
(
wavHeader
.
getDataStartPosition
());
}
long
dataLimit
=
wavHeader
.
getDataLimit
();
...
...
library/core/src/main/java/com/google/android/exoplayer2/extractor/wav/WavHeader.java
View file @
6d20a5cf
...
...
@@ -37,9 +37,9 @@ import com.google.android.exoplayer2.util.Util;
@C
.
PcmEncoding
private
final
int
encoding
;
/**
Offset to the start of sample data
. */
private
long
dataStartPosition
;
/** Total size
in bytes of the sample data
. */
/**
Position of the start of the sample data, in bytes
. */
private
int
dataStartPosition
;
/** Total size
of the sample data, in bytes
. */
private
long
dataSize
;
public
WavHeader
(
int
numChannels
,
int
sampleRateHz
,
int
averageBytesPerSecond
,
int
blockAlignment
,
...
...
@@ -50,6 +50,7 @@ import com.google.android.exoplayer2.util.Util;
this
.
blockAlignment
=
blockAlignment
;
this
.
bitsPerSample
=
bitsPerSample
;
this
.
encoding
=
encoding
;
dataStartPosition
=
C
.
POSITION_UNSET
;
}
// Data bounds.
...
...
@@ -57,22 +58,33 @@ import com.google.android.exoplayer2.util.Util;
/**
* Sets the data start position and size in bytes of sample data in this WAV.
*
* @param dataStartPosition The
data start position
in bytes.
* @param dataSize The
data size
in bytes.
* @param dataStartPosition The
position of the start of the sample data,
in bytes.
* @param dataSize The
total size of the sample data,
in bytes.
*/
public
void
setDataBounds
(
long
dataStartPosition
,
long
dataSize
)
{
public
void
setDataBounds
(
int
dataStartPosition
,
long
dataSize
)
{
this
.
dataStartPosition
=
dataStartPosition
;
this
.
dataSize
=
dataSize
;
}
/** Returns the data limit, or {@link C#POSITION_UNSET} if the data bounds have not been set. */
/**
* Returns the position of the start of the sample data, in bytes, or {@link C#POSITION_UNSET} if
* the data bounds have not been set.
*/
public
int
getDataStartPosition
()
{
return
dataStartPosition
;
}
/**
* Returns the limit of the sample data, in bytes, or {@link C#POSITION_UNSET} if the data bounds
* have not been set.
*/
public
long
getDataLimit
()
{
return
hasDataBounds
()
?
(
dataStartPosition
+
dataSize
)
:
C
.
POSITION_UNSET
;
}
/** Returns whether the data start position and size have been set. */
public
boolean
hasDataBounds
()
{
return
dataStartPosition
!=
0
&&
dataSize
!=
0
;
return
dataStartPosition
!=
C
.
POSITION_UNSET
;
}
// SeekMap implementation.
...
...
library/core/src/main/java/com/google/android/exoplayer2/extractor/wav/WavHeaderReader.java
View file @
6d20a5cf
...
...
@@ -139,7 +139,7 @@ import java.io.IOException;
// Skip past the "data" header.
input
.
skipFully
(
ChunkHeader
.
SIZE_IN_BYTES
);
wavHeader
.
setDataBounds
(
input
.
getPosition
(),
chunkHeader
.
size
);
wavHeader
.
setDataBounds
(
(
int
)
input
.
getPosition
(),
chunkHeader
.
size
);
}
private
WavHeaderReader
()
{
...
...
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