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
db750125
authored
Jan 16, 2020
by
kimvde
Committed by
Oliver Woodman
Jan 16, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
FlacExtractor: handle case where last frame < MAX_FRAME_HEADER_SIZE
PiperOrigin-RevId: 290079840
parent
a99ab622
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
1 deletions
library/core/src/main/java/com/google/android/exoplayer2/extractor/flac/FlacExtractor.java
library/core/src/main/java/com/google/android/exoplayer2/extractor/flac/FlacExtractor.java
View file @
db750125
...
@@ -344,7 +344,49 @@ public final class FlacExtractor implements Extractor {
...
@@ -344,7 +344,49 @@ public final class FlacExtractor implements Extractor {
}
}
if
(
foundEndOfInput
)
{
if
(
foundEndOfInput
)
{
// Reached the end of the file. Assume it's the end of the frame.
// Verify whether there is a frame of size < MAX_FRAME_HEADER_SIZE at the end of the stream by
// checking at every position at a distance between MAX_FRAME_HEADER_SIZE and minFrameSize
// from the buffer limit if it corresponds to a valid frame header.
// At every offset, the different possibilities are:
// 1. The current offset indicates the start of a valid frame header. In this case, consider
// that a frame has been found and stop searching.
// 2. A frame starting at the current offset would be invalid. In this case, keep looking for
// a valid frame header.
// 3. The current offset could be the start of a valid frame header, but there is not enough
// bytes remaining to complete the header. As the end of the file has been reached, this
// means that the current offset does not correspond to a new frame and that the last bytes
// of the last frame happen to be a valid partial frame header. This case can occur in two
// ways:
// 3.1. An attempt to read past the buffer is made when reading the potential frame header.
// 3.2. Reading the potential frame header does not exceed the buffer size, but exceeds the
// buffer limit.
// Note that the third case is very unlikely. It never happens if the end of the input has not
// been reached as it is always made sure that the buffer has at least MAX_FRAME_HEADER_SIZE
// bytes available when reading a potential frame header.
while
(
frameOffset
<=
data
.
limit
()
-
minFrameSize
)
{
data
.
setPosition
(
frameOffset
);
boolean
frameFound
;
try
{
frameFound
=
FlacFrameReader
.
checkAndReadFrameHeader
(
data
,
flacStreamMetadata
,
frameStartMarker
,
sampleNumberHolder
);
}
catch
(
IndexOutOfBoundsException
e
)
{
// Case 3.1.
frameFound
=
false
;
}
if
(
data
.
getPosition
()
>
data
.
limit
())
{
// TODO: Remove (and update above comments) once [Internal ref: b/147657250] is fixed.
// Case 3.2.
frameFound
=
false
;
}
if
(
frameFound
)
{
// Case 1.
data
.
setPosition
(
frameOffset
);
return
sampleNumberHolder
.
sampleNumber
;
}
frameOffset
++;
}
// The end of the frame is the end of the file.
data
.
setPosition
(
data
.
limit
());
data
.
setPosition
(
data
.
limit
());
}
else
{
}
else
{
data
.
setPosition
(
frameOffset
);
data
.
setPosition
(
frameOffset
);
...
...
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