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
08faafb4
authored
Aug 01, 2017
by
ojw28
Committed by
GitHub
Aug 01, 2017
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge pull request #3115 from goffioul/h262-segmentation
Fix H262 segmentation.
parents
b562eb21
908362bd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
15 deletions
library/core/src/main/java/com/google/android/exoplayer2/extractor/ts/H262Reader.java
library/core/src/main/java/com/google/android/exoplayer2/extractor/ts/H262Reader.java
View file @
08faafb4
...
@@ -51,7 +51,7 @@ public final class H262Reader implements ElementaryStreamReader {
...
@@ -51,7 +51,7 @@ public final class H262Reader implements ElementaryStreamReader {
// State that should be reset on seek.
// State that should be reset on seek.
private
final
boolean
[]
prefixFlags
;
private
final
boolean
[]
prefixFlags
;
private
final
CsdBuffer
csdBuffer
;
private
final
CsdBuffer
csdBuffer
;
private
boolean
found
FirstFrameInGroup
;
private
boolean
found
Picture
;
private
long
totalBytesWritten
;
private
long
totalBytesWritten
;
// Per packet state that gets reset at the start of each packet.
// Per packet state that gets reset at the start of each packet.
...
@@ -60,8 +60,8 @@ public final class H262Reader implements ElementaryStreamReader {
...
@@ -60,8 +60,8 @@ public final class H262Reader implements ElementaryStreamReader {
// Per sample state that gets reset at the start of each frame.
// Per sample state that gets reset at the start of each frame.
private
boolean
isKeyframe
;
private
boolean
isKeyframe
;
private
long
fram
ePosition
;
private
long
sampl
ePosition
;
private
long
fram
eTimeUs
;
private
long
sampl
eTimeUs
;
public
H262Reader
()
{
public
H262Reader
()
{
prefixFlags
=
new
boolean
[
4
];
prefixFlags
=
new
boolean
[
4
];
...
@@ -73,7 +73,8 @@ public final class H262Reader implements ElementaryStreamReader {
...
@@ -73,7 +73,8 @@ public final class H262Reader implements ElementaryStreamReader {
NalUnitUtil
.
clearPrefixFlags
(
prefixFlags
);
NalUnitUtil
.
clearPrefixFlags
(
prefixFlags
);
csdBuffer
.
reset
();
csdBuffer
.
reset
();
pesPtsUsAvailable
=
false
;
pesPtsUsAvailable
=
false
;
foundFirstFrameInGroup
=
false
;
foundPicture
=
false
;
samplePosition
=
C
.
POSITION_UNSET
;
totalBytesWritten
=
0
;
totalBytesWritten
=
0
;
}
}
...
@@ -136,25 +137,28 @@ public final class H262Reader implements ElementaryStreamReader {
...
@@ -136,25 +137,28 @@ public final class H262Reader implements ElementaryStreamReader {
}
}
}
}
if
(
hasOutputFormat
&&
(
startCodeValue
==
START_
GROUP
||
startCodeValue
==
START_PICTURE
))
{
if
(
hasOutputFormat
&&
(
startCodeValue
==
START_
PICTURE
||
startCodeValue
==
START_SEQUENCE_HEADER
))
{
int
bytesWrittenPastStartCode
=
limit
-
startCodeOffset
;
int
bytesWrittenPastStartCode
=
limit
-
startCodeOffset
;
if
(
foundFirstFrameInGroup
)
{
boolean
resetSample
=
(
samplePosition
==
C
.
POSITION_UNSET
);
if
(
foundPicture
)
{
@C
.
BufferFlags
int
flags
=
isKeyframe
?
C
.
BUFFER_FLAG_KEY_FRAME
:
0
;
@C
.
BufferFlags
int
flags
=
isKeyframe
?
C
.
BUFFER_FLAG_KEY_FRAME
:
0
;
int
size
=
(
int
)
(
totalBytesWritten
-
fram
ePosition
)
-
bytesWrittenPastStartCode
;
int
size
=
(
int
)
(
totalBytesWritten
-
sampl
ePosition
)
-
bytesWrittenPastStartCode
;
output
.
sampleMetadata
(
fram
eTimeUs
,
flags
,
size
,
bytesWrittenPastStartCode
,
null
);
output
.
sampleMetadata
(
sampl
eTimeUs
,
flags
,
size
,
bytesWrittenPastStartCode
,
null
);
isKeyframe
=
false
;
isKeyframe
=
false
;
resetSample
=
true
;
}
}
if
(
startCodeValue
==
START_GROUP
)
{
foundPicture
=
(
startCodeValue
==
START_PICTURE
);
foundFirstFrameInGroup
=
false
;
if
(
resetSample
)
{
isKeyframe
=
true
;
samplePosition
=
totalBytesWritten
-
bytesWrittenPastStartCode
;
}
else
/* startCodeValue == START_PICTURE */
{
sampleTimeUs
=
(
pesPtsUsAvailable
?
pesTimeUs
:
sampleTimeUs
+
frameDurationUs
);
frameTimeUs
=
pesPtsUsAvailable
?
pesTimeUs
:
(
frameTimeUs
+
frameDurationUs
);
framePosition
=
totalBytesWritten
-
bytesWrittenPastStartCode
;
pesPtsUsAvailable
=
false
;
pesPtsUsAvailable
=
false
;
foundFirstFrameInGroup
=
true
;
}
}
}
}
if
(
hasOutputFormat
&&
startCodeValue
==
START_GROUP
)
{
isKeyframe
=
true
;
}
offset
=
startCodeOffset
;
offset
=
startCodeOffset
;
searchOffset
=
offset
+
3
;
searchOffset
=
offset
+
3
;
}
}
...
...
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