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
5b186a2a
authored
Jun 01, 2015
by
Andrew Lewis
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add support for reading H.265 in MPEG TS.
parent
02d5cb81
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
12 deletions
library/src/main/java/com/google/android/exoplayer/extractor/ts/H264Reader.java
library/src/main/java/com/google/android/exoplayer/extractor/ts/H265Reader.java
library/src/main/java/com/google/android/exoplayer/extractor/ts/SeiReader.java
library/src/main/java/com/google/android/exoplayer/extractor/ts/TsExtractor.java
library/src/main/java/com/google/android/exoplayer/util/NalUnitUtil.java
library/src/main/java/com/google/android/exoplayer/extractor/ts/H264Reader.java
View file @
5b186a2a
...
...
@@ -77,7 +77,7 @@ import java.util.List;
private
final
NalUnitTargetBuffer
sps
;
private
final
NalUnitTargetBuffer
pps
;
private
final
NalUnitTargetBuffer
sei
;
private
boolean
writing
Sample
;
private
boolean
foundFirst
Sample
;
private
long
totalBytesWritten
;
// Per sample state that gets reset at the start of each sample.
...
...
@@ -111,7 +111,7 @@ import java.util.List;
if
(
ifrParserBuffer
!=
null
)
{
ifrParserBuffer
.
reset
();
}
writing
Sample
=
false
;
foundFirst
Sample
=
false
;
totalBytesWritten
=
0
;
}
...
...
@@ -146,7 +146,7 @@ import java.util.List;
isKeyframe
=
true
;
break
;
case
NAL_UNIT_TYPE_AUD:
if
(
writing
Sample
)
{
if
(
foundFirst
Sample
)
{
if
(
ifrParserBuffer
!=
null
&&
ifrParserBuffer
.
isCompleted
())
{
int
sliceType
=
ifrParserBuffer
.
getSliceType
();
isKeyframe
|=
(
sliceType
==
FRAME_TYPE_I
||
sliceType
==
FRAME_TYPE_ALL_I
);
...
...
@@ -158,9 +158,8 @@ import java.util.List;
int
flags
=
isKeyframe
?
C
.
SAMPLE_FLAG_SYNC
:
0
;
int
size
=
(
int
)
(
totalBytesWritten
-
samplePosition
)
-
bytesWrittenPastNalUnit
;
output
.
sampleMetadata
(
sampleTimeUs
,
flags
,
size
,
bytesWrittenPastNalUnit
,
null
);
writingSample
=
false
;
}
writing
Sample
=
true
;
foundFirst
Sample
=
true
;
samplePosition
=
totalBytesWritten
-
bytesWrittenPastNalUnit
;
sampleTimeUs
=
pesTimeUs
;
isKeyframe
=
false
;
...
...
@@ -215,6 +214,7 @@ import java.util.List;
if
(
sei
.
endNalUnit
(
discardPadding
))
{
int
unescapedLength
=
unescapeStream
(
sei
.
nalData
,
sei
.
nalLength
);
seiWrapper
.
reset
(
sei
.
nalData
,
unescapedLength
);
seiWrapper
.
setPosition
(
4
);
// NAL prefix and nal_unit() header.
seiReader
.
consume
(
seiWrapper
,
pesTimeUs
,
true
);
}
}
...
...
@@ -385,7 +385,7 @@ import java.util.List;
return
unescapedLength
;
}
private
int
findNextUnescapeIndex
(
byte
[]
bytes
,
int
offset
,
int
limit
)
{
private
static
int
findNextUnescapeIndex
(
byte
[]
bytes
,
int
offset
,
int
limit
)
{
for
(
int
i
=
offset
;
i
<
limit
-
2
;
i
++)
{
if
(
bytes
[
i
]
==
0x00
&&
bytes
[
i
+
1
]
==
0x00
&&
bytes
[
i
+
2
]
==
0x03
)
{
return
i
;
...
...
library/src/main/java/com/google/android/exoplayer/extractor/ts/H265Reader.java
0 → 100644
View file @
5b186a2a
This diff is collapsed.
Click to expand it.
library/src/main/java/com/google/android/exoplayer/extractor/ts/SeiReader.java
View file @
5b186a2a
...
...
@@ -41,9 +41,6 @@ import com.google.android.exoplayer.util.ParsableByteArray;
@Override
public
void
consume
(
ParsableByteArray
seiBuffer
,
long
pesTimeUs
,
boolean
startOfPacket
)
{
// Skip the NAL prefix and type.
seiBuffer
.
skipBytes
(
4
);
int
b
;
while
(
seiBuffer
.
bytesLeft
()
>
1
/* last byte will be rbsp_trailing_bits */
)
{
// Parse payload type.
...
...
library/src/main/java/com/google/android/exoplayer/extractor/ts/TsExtractor.java
View file @
5b186a2a
...
...
@@ -46,6 +46,7 @@ public final class TsExtractor implements Extractor, SeekMap {
private
static
final
int
TS_STREAM_TYPE_ATSC_AC3
=
0x81
;
private
static
final
int
TS_STREAM_TYPE_ATSC_E_AC3
=
0x87
;
private
static
final
int
TS_STREAM_TYPE_H264
=
0x1B
;
private
static
final
int
TS_STREAM_TYPE_H265
=
0x24
;
private
static
final
int
TS_STREAM_TYPE_ID3
=
0x15
;
private
static
final
int
TS_STREAM_TYPE_EIA608
=
0x100
;
// 0xFF + 1
...
...
@@ -361,9 +362,12 @@ public final class TsExtractor implements Extractor, SeekMap {
pesPayloadReader
=
new
Ac3Reader
(
output
.
track
(
streamType
));
break
;
case
TS_STREAM_TYPE_H264:
SeiReader
seiReader
=
new
SeiReader
(
output
.
track
(
TS_STREAM_TYPE_EIA608
));
pesPayloadReader
=
new
H264Reader
(
output
.
track
(
TS_STREAM_TYPE_H264
),
seiReader
,
idrKeyframesOnly
);
pesPayloadReader
=
new
H264Reader
(
output
.
track
(
TS_STREAM_TYPE_H264
),
new
SeiReader
(
output
.
track
(
TS_STREAM_TYPE_EIA608
)),
idrKeyframesOnly
);
break
;
case
TS_STREAM_TYPE_H265:
pesPayloadReader
=
new
H265Reader
(
output
.
track
(
TS_STREAM_TYPE_H265
),
new
SeiReader
(
output
.
track
(
TS_STREAM_TYPE_EIA608
)));
break
;
case
TS_STREAM_TYPE_ID3:
pesPayloadReader
=
id3Reader
;
...
...
library/src/main/java/com/google/android/exoplayer/util/NalUnitUtil.java
View file @
5b186a2a
...
...
@@ -65,6 +65,18 @@ public final class NalUnitUtil {
}
/**
* Gets the type of the H.265 NAL unit in {@code data} that starts at {@code offset}.
*
* @param data The data to search.
* @param offset The start offset of a NAL unit. Must lie between {@code -3} (inclusive) and
* {@code data.length - 3} (exclusive).
* @return The type of the unit.
*/
public
static
int
getH265NalUnitType
(
byte
[]
data
,
int
offset
)
{
return
(
data
[
offset
+
3
]
&
0x7E
)
>>
1
;
}
/**
* Finds the first NAL unit in {@code data}.
* <p>
* If {@code prefixFlags} is null then the first four bytes of a NAL unit must be entirely
...
...
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