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
dbc70887
authored
Sep 13, 2021
by
Marcus Wichelmann
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Keep the existing parseSpsNalUnit (and similar) methods to avoid breaking changes
parent
296074fb
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
59 additions
and
20 deletions
library/common/src/main/java/com/google/android/exoplayer2/util/NalUnitUtil.java
library/common/src/test/java/com/google/android/exoplayer2/util/NalUnitUtilTest.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/H264Reader.java
library/extractor/src/main/java/com/google/android/exoplayer2/video/AvcConfig.java
library/extractor/src/main/java/com/google/android/exoplayer2/video/HevcConfig.java
library/rtsp/src/main/java/com/google/android/exoplayer2/source/rtsp/RtspMediaTrack.java
library/common/src/main/java/com/google/android/exoplayer2/util/NalUnitUtil.java
View file @
dbc70887
...
@@ -292,11 +292,24 @@ public final class NalUnitUtil {
...
@@ -292,11 +292,24 @@ public final class NalUnitUtil {
}
}
/**
/**
* Parses a SPS NAL unit payload using the syntax defined in ITU-T Recommendation H.264 (2013)
* Parses a SPS NAL unit using the syntax defined in ITU-T Recommendation H.264 (2013) subsection
* 7.3.2.1.1.
*
* @param nalData A buffer containing escaped SPS data.
* @param nalOffset The offset of the NAL unit header in {@code nalData}.
* @param nalLimit The limit of the NAL unit in {@code nalData}.
* @return A parsed representation of the SPS data.
*/
public
static
SpsData
parseSpsNalUnit
(
byte
[]
nalData
,
int
nalOffset
,
int
nalLimit
)
{
return
parseSpsNalUnitPayload
(
nalData
,
nalOffset
+
1
,
nalLimit
);
}
/**
* Parses a SPS NAL unit payload (excluding the NAL unit header) using the syntax defined in ITU-T Recommendation H.264 (2013)
* subsection 7.3.2.1.1.
* subsection 7.3.2.1.1.
*
*
* @param nalData A buffer containing escaped SPS data.
* @param nalData A buffer containing escaped SPS data.
* @param nalOffset The offset of the NAL unit in {@code nalData}.
* @param nalOffset The offset of the NAL unit
payload
in {@code nalData}.
* @param nalLimit The limit of the NAL unit in {@code nalData}.
* @param nalLimit The limit of the NAL unit in {@code nalData}.
* @return A parsed representation of the SPS data.
* @return A parsed representation of the SPS data.
*/
*/
...
@@ -426,11 +439,24 @@ public final class NalUnitUtil {
...
@@ -426,11 +439,24 @@ public final class NalUnitUtil {
}
}
/**
/**
* Parses a H.265 SPS NAL unit
payload
using the syntax defined in ITU-T Recommendation H.265 (2019)
* Parses a H.265 SPS NAL unit using the syntax defined in ITU-T Recommendation H.265 (2019)
* subsection 7.3.2.2.1.
* subsection 7.3.2.2.1.
*
*
* @param nalData A buffer containing escaped SPS data.
* @param nalData A buffer containing escaped SPS data.
* @param nalOffset The offset of the NAL unit in {@code nalData}.
* @param nalOffset The offset of the NAL unit header in {@code nalData}.
* @param nalLimit The limit of the NAL unit in {@code nalData}.
* @return A parsed representation of the SPS data.
*/
public
static
H265SpsData
parseH265SpsNalUnit
(
byte
[]
nalData
,
int
nalOffset
,
int
nalLimit
)
{
return
parseH265SpsNalUnitPayload
(
nalData
,
nalOffset
+
1
,
nalLimit
);
}
/**
* Parses a H.265 SPS NAL unit payload (excluding the NAL unit header) using the syntax defined in ITU-T Recommendation H.265 (2019)
* subsection 7.3.2.2.1.
*
* @param nalData A buffer containing escaped SPS data.
* @param nalOffset The offset of the NAL unit payload in {@code nalData}.
* @param nalLimit The limit of the NAL unit in {@code nalData}.
* @param nalLimit The limit of the NAL unit in {@code nalData}.
* @return A parsed representation of the SPS data.
* @return A parsed representation of the SPS data.
*/
*/
...
@@ -576,11 +602,24 @@ public final class NalUnitUtil {
...
@@ -576,11 +602,24 @@ public final class NalUnitUtil {
}
}
/**
/**
* Parses a PPS NAL unit payload using the syntax defined in ITU-T Recommendation H.264 (2013)
* Parses a PPS NAL unit using the syntax defined in ITU-T Recommendation H.264 (2013) subsection
* 7.3.2.2.
*
* @param nalData A buffer containing escaped PPS data.
* @param nalOffset The offset of the NAL unit header in {@code nalData}.
* @param nalLimit The limit of the NAL unit in {@code nalData}.
* @return A parsed representation of the PPS data.
*/
public
static
PpsData
parsePpsNalUnit
(
byte
[]
nalData
,
int
nalOffset
,
int
nalLimit
)
{
return
parsePpsNalUnitPayload
(
nalData
,
nalOffset
+
1
,
nalLimit
);
}
/**
* Parses a PPS NAL unit payload (excluding the NAL unit header) using the syntax defined in ITU-T Recommendation H.264 (2013)
* subsection 7.3.2.2.
* subsection 7.3.2.2.
*
*
* @param nalData A buffer containing escaped PPS data.
* @param nalData A buffer containing escaped PPS data.
* @param nalOffset The offset of the NAL unit in {@code nalData}.
* @param nalOffset The offset of the NAL unit
payload
in {@code nalData}.
* @param nalLimit The limit of the NAL unit in {@code nalData}.
* @param nalLimit The limit of the NAL unit in {@code nalData}.
* @return A parsed representation of the PPS data.
* @return A parsed representation of the PPS data.
*/
*/
...
...
library/common/src/test/java/com/google/android/exoplayer2/util/NalUnitUtilTest.java
View file @
dbc70887
...
@@ -33,7 +33,7 @@ public final class NalUnitUtilTest {
...
@@ -33,7 +33,7 @@ public final class NalUnitUtilTest {
createByteArray
(
createByteArray
(
0x00
,
0x00
,
0x01
,
0x67
,
0x4D
,
0x40
,
0x16
,
0xEC
,
0xA0
,
0x50
,
0x17
,
0xFC
,
0xB8
,
0x08
,
0x80
,
0x00
,
0x00
,
0x01
,
0x67
,
0x4D
,
0x40
,
0x16
,
0xEC
,
0xA0
,
0x50
,
0x17
,
0xFC
,
0xB8
,
0x08
,
0x80
,
0x00
,
0x00
,
0x03
,
0x00
,
0x80
,
0x00
,
0x00
,
0x0F
,
0x47
,
0x8B
,
0x16
,
0xCB
);
0x00
,
0x00
,
0x03
,
0x00
,
0x80
,
0x00
,
0x00
,
0x0F
,
0x47
,
0x8B
,
0x16
,
0xCB
);
private
static
final
int
SPS_TEST_DATA_OFFSET
=
4
;
private
static
final
int
SPS_TEST_DATA_OFFSET
=
3
;
@Test
@Test
public
void
findNalUnit
()
{
public
void
findNalUnit
()
{
...
@@ -121,10 +121,9 @@ public final class NalUnitUtilTest {
...
@@ -121,10 +121,9 @@ public final class NalUnitUtilTest {
}
}
@Test
@Test
public
void
parseSpsNalUnit
Payload
()
{
public
void
parseSpsNalUnit
()
{
NalUnitUtil
.
SpsData
data
=
NalUnitUtil
.
SpsData
data
=
NalUnitUtil
.
parseSpsNalUnitPayload
(
NalUnitUtil
.
parseSpsNalUnit
(
SPS_TEST_DATA
,
SPS_TEST_DATA_OFFSET
,
SPS_TEST_DATA
.
length
);
SPS_TEST_DATA
,
SPS_TEST_DATA_OFFSET
,
SPS_TEST_DATA
.
length
);
assertThat
(
data
.
width
).
isEqualTo
(
640
);
assertThat
(
data
.
width
).
isEqualTo
(
640
);
assertThat
(
data
.
height
).
isEqualTo
(
360
);
assertThat
(
data
.
height
).
isEqualTo
(
360
);
assertThat
(
data
.
deltaPicOrderAlwaysZeroFlag
).
isFalse
();
assertThat
(
data
.
deltaPicOrderAlwaysZeroFlag
).
isFalse
();
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/H264Reader.java
View file @
dbc70887
...
@@ -200,8 +200,8 @@ public final class H264Reader implements ElementaryStreamReader {
...
@@ -200,8 +200,8 @@ public final class H264Reader implements ElementaryStreamReader {
List
<
byte
[]>
initializationData
=
new
ArrayList
<>();
List
<
byte
[]>
initializationData
=
new
ArrayList
<>();
initializationData
.
add
(
Arrays
.
copyOf
(
sps
.
nalData
,
sps
.
nalLength
));
initializationData
.
add
(
Arrays
.
copyOf
(
sps
.
nalData
,
sps
.
nalLength
));
initializationData
.
add
(
Arrays
.
copyOf
(
pps
.
nalData
,
pps
.
nalLength
));
initializationData
.
add
(
Arrays
.
copyOf
(
pps
.
nalData
,
pps
.
nalLength
));
NalUnitUtil
.
SpsData
spsData
=
NalUnitUtil
.
parseSpsNalUnit
Payload
(
sps
.
nalData
,
4
,
sps
.
nalLength
);
NalUnitUtil
.
SpsData
spsData
=
NalUnitUtil
.
parseSpsNalUnit
(
sps
.
nalData
,
3
,
sps
.
nalLength
);
NalUnitUtil
.
PpsData
ppsData
=
NalUnitUtil
.
parsePpsNalUnit
Payload
(
pps
.
nalData
,
4
,
pps
.
nalLength
);
NalUnitUtil
.
PpsData
ppsData
=
NalUnitUtil
.
parsePpsNalUnit
(
pps
.
nalData
,
3
,
pps
.
nalLength
);
String
codecs
=
String
codecs
=
CodecSpecificDataUtil
.
buildAvcCodecString
(
CodecSpecificDataUtil
.
buildAvcCodecString
(
spsData
.
profileIdc
,
spsData
.
profileIdc
,
...
@@ -224,11 +224,11 @@ public final class H264Reader implements ElementaryStreamReader {
...
@@ -224,11 +224,11 @@ public final class H264Reader implements ElementaryStreamReader {
pps
.
reset
();
pps
.
reset
();
}
}
}
else
if
(
sps
.
isCompleted
())
{
}
else
if
(
sps
.
isCompleted
())
{
NalUnitUtil
.
SpsData
spsData
=
NalUnitUtil
.
parseSpsNalUnit
Payload
(
sps
.
nalData
,
4
,
sps
.
nalLength
);
NalUnitUtil
.
SpsData
spsData
=
NalUnitUtil
.
parseSpsNalUnit
(
sps
.
nalData
,
3
,
sps
.
nalLength
);
sampleReader
.
putSps
(
spsData
);
sampleReader
.
putSps
(
spsData
);
sps
.
reset
();
sps
.
reset
();
}
else
if
(
pps
.
isCompleted
())
{
}
else
if
(
pps
.
isCompleted
())
{
NalUnitUtil
.
PpsData
ppsData
=
NalUnitUtil
.
parsePpsNalUnit
Payload
(
pps
.
nalData
,
4
,
pps
.
nalLength
);
NalUnitUtil
.
PpsData
ppsData
=
NalUnitUtil
.
parsePpsNalUnit
(
pps
.
nalData
,
3
,
pps
.
nalLength
);
sampleReader
.
putPps
(
ppsData
);
sampleReader
.
putPps
(
ppsData
);
pps
.
reset
();
pps
.
reset
();
}
}
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/video/AvcConfig.java
View file @
dbc70887
...
@@ -66,8 +66,9 @@ public final class AvcConfig {
...
@@ -66,8 +66,9 @@ public final class AvcConfig {
@Nullable
String
codecs
=
null
;
@Nullable
String
codecs
=
null
;
if
(
numSequenceParameterSets
>
0
)
{
if
(
numSequenceParameterSets
>
0
)
{
byte
[]
sps
=
initializationData
.
get
(
0
);
byte
[]
sps
=
initializationData
.
get
(
0
);
SpsData
spsData
=
NalUnitUtil
.
parseSpsNalUnitPayload
(
sps
,
SpsData
spsData
=
nalUnitLengthFieldLength
+
1
,
sps
.
length
);
NalUnitUtil
.
parseSpsNalUnit
(
initializationData
.
get
(
0
),
nalUnitLengthFieldLength
,
sps
.
length
);
width
=
spsData
.
width
;
width
=
spsData
.
width
;
height
=
spsData
.
height
;
height
=
spsData
.
height
;
pixelWidthAspectRatio
=
spsData
.
pixelWidthAspectRatio
;
pixelWidthAspectRatio
=
spsData
.
pixelWidthAspectRatio
;
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/video/HevcConfig.java
View file @
dbc70887
...
@@ -78,8 +78,8 @@ public final class HevcConfig {
...
@@ -78,8 +78,8 @@ public final class HevcConfig {
data
.
getData
(),
data
.
getPosition
(),
buffer
,
bufferPosition
,
nalUnitLength
);
data
.
getData
(),
data
.
getPosition
(),
buffer
,
bufferPosition
,
nalUnitLength
);
if
(
nalUnitType
==
SPS_NAL_UNIT_TYPE
&&
j
==
0
)
{
if
(
nalUnitType
==
SPS_NAL_UNIT_TYPE
&&
j
==
0
)
{
NalUnitUtil
.
H265SpsData
spsData
=
NalUnitUtil
.
H265SpsData
spsData
=
NalUnitUtil
.
parseH265SpsNalUnit
Payload
(
NalUnitUtil
.
parseH265SpsNalUnit
(
buffer
,
bufferPosition
+
1
,
bufferPosition
+
nalUnitLength
);
buffer
,
bufferPosition
,
bufferPosition
+
nalUnitLength
);
width
=
spsData
.
picWidthInLumaSamples
;
width
=
spsData
.
picWidthInLumaSamples
;
height
=
spsData
.
picHeightInLumaSamples
;
height
=
spsData
.
picHeightInLumaSamples
;
pixelWidthAspectRatio
=
spsData
.
pixelWidthHeightRatio
;
pixelWidthAspectRatio
=
spsData
.
pixelWidthHeightRatio
;
...
...
library/rtsp/src/main/java/com/google/android/exoplayer2/source/rtsp/RtspMediaTrack.java
View file @
dbc70887
...
@@ -183,8 +183,8 @@ import com.google.common.collect.ImmutableMap;
...
@@ -183,8 +183,8 @@ import com.google.common.collect.ImmutableMap;
// Process SPS (Sequence Parameter Set).
// Process SPS (Sequence Parameter Set).
byte
[]
spsNalDataWithStartCode
=
initializationData
.
get
(
0
);
byte
[]
spsNalDataWithStartCode
=
initializationData
.
get
(
0
);
NalUnitUtil
.
SpsData
spsData
=
NalUnitUtil
.
SpsData
spsData
=
NalUnitUtil
.
parseSpsNalUnit
Payload
(
NalUnitUtil
.
parseSpsNalUnit
(
spsNalDataWithStartCode
,
NAL_START_CODE
.
length
+
1
,
spsNalDataWithStartCode
.
length
);
spsNalDataWithStartCode
,
NAL_START_CODE
.
length
,
spsNalDataWithStartCode
.
length
);
formatBuilder
.
setPixelWidthHeightRatio
(
spsData
.
pixelWidthAspectRatio
);
formatBuilder
.
setPixelWidthHeightRatio
(
spsData
.
pixelWidthAspectRatio
);
formatBuilder
.
setHeight
(
spsData
.
height
);
formatBuilder
.
setHeight
(
spsData
.
height
);
formatBuilder
.
setWidth
(
spsData
.
width
);
formatBuilder
.
setWidth
(
spsData
.
width
);
...
...
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