Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
826338ca
Commit
826338ca
authored
Dec 08, 2015
by
Francois Cartegnie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packetizer: h264: h264 prefix nal structs
parent
a26999c1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
67 deletions
+67
-67
modules/packetizer/h264.c
modules/packetizer/h264.c
+27
-27
modules/packetizer/h264_nal.c
modules/packetizer/h264_nal.c
+19
-19
modules/packetizer/h264_nal.h
modules/packetizer/h264_nal.h
+21
-21
No files found.
modules/packetizer/h264.c
View file @
826338ca
...
@@ -97,8 +97,8 @@ struct decoder_sys_t
...
@@ -97,8 +97,8 @@ struct decoder_sys_t
bool
b_header
;
bool
b_header
;
bool
b_sps
;
bool
b_sps
;
bool
b_pps
;
bool
b_pps
;
block_t
*
pp_sps
[
SPS_MAX
];
block_t
*
pp_sps
[
H264_
SPS_MAX
];
block_t
*
pp_pps
[
PPS_MAX
];
block_t
*
pp_pps
[
H264_
PPS_MAX
];
int
i_recovery_frames
;
/* -1 = no recovery */
int
i_recovery_frames
;
/* -1 = no recovery */
/* avcC data */
/* avcC data */
...
@@ -204,9 +204,9 @@ static int Open( vlc_object_t *p_this )
...
@@ -204,9 +204,9 @@ static int Open( vlc_object_t *p_this )
p_sys
->
b_header
=
false
;
p_sys
->
b_header
=
false
;
p_sys
->
b_sps
=
false
;
p_sys
->
b_sps
=
false
;
p_sys
->
b_pps
=
false
;
p_sys
->
b_pps
=
false
;
for
(
i
=
0
;
i
<
SPS_MAX
;
i
++
)
for
(
i
=
0
;
i
<
H264_
SPS_MAX
;
i
++
)
p_sys
->
pp_sps
[
i
]
=
NULL
;
p_sys
->
pp_sps
[
i
]
=
NULL
;
for
(
i
=
0
;
i
<
PPS_MAX
;
i
++
)
for
(
i
=
0
;
i
<
H264_
PPS_MAX
;
i
++
)
p_sys
->
pp_pps
[
i
]
=
NULL
;
p_sys
->
pp_pps
[
i
]
=
NULL
;
p_sys
->
i_recovery_frames
=
-
1
;
p_sys
->
i_recovery_frames
=
-
1
;
...
@@ -296,12 +296,12 @@ static int Open( vlc_object_t *p_this )
...
@@ -296,12 +296,12 @@ static int Open( vlc_object_t *p_this )
p_dec
->
fmt_out
.
p_extra
=
NULL
;
p_dec
->
fmt_out
.
p_extra
=
NULL
;
/* Set the new extradata */
/* Set the new extradata */
for
(
i
=
0
;
i
<
SPS_MAX
;
i
++
)
for
(
i
=
0
;
i
<
H264_
SPS_MAX
;
i
++
)
{
{
if
(
p_sys
->
pp_sps
[
i
]
)
if
(
p_sys
->
pp_sps
[
i
]
)
p_dec
->
fmt_out
.
i_extra
+=
p_sys
->
pp_sps
[
i
]
->
i_buffer
;
p_dec
->
fmt_out
.
i_extra
+=
p_sys
->
pp_sps
[
i
]
->
i_buffer
;
}
}
for
(
i
=
0
;
i
<
PPS_MAX
;
i
++
)
for
(
i
=
0
;
i
<
H264_
PPS_MAX
;
i
++
)
{
{
if
(
p_sys
->
pp_pps
[
i
]
)
if
(
p_sys
->
pp_pps
[
i
]
)
p_dec
->
fmt_out
.
i_extra
+=
p_sys
->
pp_pps
[
i
]
->
i_buffer
;
p_dec
->
fmt_out
.
i_extra
+=
p_sys
->
pp_pps
[
i
]
->
i_buffer
;
...
@@ -311,7 +311,7 @@ static int Open( vlc_object_t *p_this )
...
@@ -311,7 +311,7 @@ static int Open( vlc_object_t *p_this )
{
{
uint8_t
*
p_dst
=
p_dec
->
fmt_out
.
p_extra
;
uint8_t
*
p_dst
=
p_dec
->
fmt_out
.
p_extra
;
for
(
i
=
0
;
i
<
SPS_MAX
;
i
++
)
for
(
i
=
0
;
i
<
H264_
SPS_MAX
;
i
++
)
{
{
if
(
p_sys
->
pp_sps
[
i
]
)
if
(
p_sys
->
pp_sps
[
i
]
)
{
{
...
@@ -319,7 +319,7 @@ static int Open( vlc_object_t *p_this )
...
@@ -319,7 +319,7 @@ static int Open( vlc_object_t *p_this )
p_dst
+=
p_sys
->
pp_sps
[
i
]
->
i_buffer
;
p_dst
+=
p_sys
->
pp_sps
[
i
]
->
i_buffer
;
}
}
}
}
for
(
i
=
0
;
i
<
PPS_MAX
;
i
++
)
for
(
i
=
0
;
i
<
H264_
PPS_MAX
;
i
++
)
{
{
if
(
p_sys
->
pp_pps
[
i
]
)
if
(
p_sys
->
pp_pps
[
i
]
)
{
{
...
@@ -377,12 +377,12 @@ static void Close( vlc_object_t *p_this )
...
@@ -377,12 +377,12 @@ static void Close( vlc_object_t *p_this )
if
(
p_sys
->
p_frame
)
if
(
p_sys
->
p_frame
)
block_ChainRelease
(
p_sys
->
p_frame
);
block_ChainRelease
(
p_sys
->
p_frame
);
for
(
i
=
0
;
i
<
SPS_MAX
;
i
++
)
for
(
i
=
0
;
i
<
H264_
SPS_MAX
;
i
++
)
{
{
if
(
p_sys
->
pp_sps
[
i
]
)
if
(
p_sys
->
pp_sps
[
i
]
)
block_Release
(
p_sys
->
pp_sps
[
i
]
);
block_Release
(
p_sys
->
pp_sps
[
i
]
);
}
}
for
(
i
=
0
;
i
<
PPS_MAX
;
i
++
)
for
(
i
=
0
;
i
<
H264_
PPS_MAX
;
i
++
)
{
{
if
(
p_sys
->
pp_pps
[
i
]
)
if
(
p_sys
->
pp_pps
[
i
]
)
block_Release
(
p_sys
->
pp_pps
[
i
]
);
block_Release
(
p_sys
->
pp_pps
[
i
]
);
...
@@ -591,12 +591,12 @@ static block_t *ParseNALBlock( decoder_t *p_dec, bool *pb_ts_used, block_t *p_fr
...
@@ -591,12 +591,12 @@ static block_t *ParseNALBlock( decoder_t *p_dec, bool *pb_ts_used, block_t *p_fr
}
}
if
(
(
!
p_sys
->
b_sps
||
!
p_sys
->
b_pps
)
&&
if
(
(
!
p_sys
->
b_sps
||
!
p_sys
->
b_pps
)
&&
i_nal_type
>=
NAL_SLICE
&&
i_nal_type
<=
NAL_SLICE_IDR
)
i_nal_type
>=
H264_NAL_SLICE
&&
i_nal_type
<=
H264_
NAL_SLICE_IDR
)
{
{
p_sys
->
b_slice
=
true
;
p_sys
->
b_slice
=
true
;
/* Fragment will be discarded later on */
/* Fragment will be discarded later on */
}
}
else
if
(
i_nal_type
>=
NAL_SLICE
&&
i_nal_type
<=
NAL_SLICE_IDR
)
else
if
(
i_nal_type
>=
H264_NAL_SLICE
&&
i_nal_type
<=
H264_
NAL_SLICE_IDR
)
{
{
slice_t
slice
;
slice_t
slice
;
bool
b_new_picture
;
bool
b_new_picture
;
...
@@ -611,7 +611,7 @@ static block_t *ParseNALBlock( decoder_t *p_dec, bool *pb_ts_used, block_t *p_fr
...
@@ -611,7 +611,7 @@ static block_t *ParseNALBlock( decoder_t *p_dec, bool *pb_ts_used, block_t *p_fr
p_sys
->
slice
=
slice
;
p_sys
->
slice
=
slice
;
p_sys
->
b_slice
=
true
;
p_sys
->
b_slice
=
true
;
}
}
else
if
(
i_nal_type
==
NAL_SPS
)
else
if
(
i_nal_type
==
H264_
NAL_SPS
)
{
{
if
(
p_sys
->
b_slice
)
if
(
p_sys
->
b_slice
)
p_pic
=
OutputPicture
(
p_dec
);
p_pic
=
OutputPicture
(
p_dec
);
...
@@ -622,7 +622,7 @@ static block_t *ParseNALBlock( decoder_t *p_dec, bool *pb_ts_used, block_t *p_fr
...
@@ -622,7 +622,7 @@ static block_t *ParseNALBlock( decoder_t *p_dec, bool *pb_ts_used, block_t *p_fr
/* Do not append the SPS because we will insert it on keyframes */
/* Do not append the SPS because we will insert it on keyframes */
p_frag
=
NULL
;
p_frag
=
NULL
;
}
}
else
if
(
i_nal_type
==
NAL_PPS
)
else
if
(
i_nal_type
==
H264_
NAL_PPS
)
{
{
if
(
p_sys
->
b_slice
)
if
(
p_sys
->
b_slice
)
p_pic
=
OutputPicture
(
p_dec
);
p_pic
=
OutputPicture
(
p_dec
);
...
@@ -633,19 +633,19 @@ static block_t *ParseNALBlock( decoder_t *p_dec, bool *pb_ts_used, block_t *p_fr
...
@@ -633,19 +633,19 @@ static block_t *ParseNALBlock( decoder_t *p_dec, bool *pb_ts_used, block_t *p_fr
/* Do not append the PPS because we will insert it on keyframes */
/* Do not append the PPS because we will insert it on keyframes */
p_frag
=
NULL
;
p_frag
=
NULL
;
}
}
else
if
(
i_nal_type
==
NAL_AU_DELIMITER
||
else
if
(
i_nal_type
==
H264_
NAL_AU_DELIMITER
||
i_nal_type
==
NAL_SEI
||
i_nal_type
==
H264_
NAL_SEI
||
(
i_nal_type
>=
13
&&
i_nal_type
<=
18
)
)
(
i_nal_type
>=
13
&&
i_nal_type
<=
18
)
)
{
{
if
(
p_sys
->
b_slice
)
if
(
p_sys
->
b_slice
)
p_pic
=
OutputPicture
(
p_dec
);
p_pic
=
OutputPicture
(
p_dec
);
/* Parse SEI for CC support */
/* Parse SEI for CC support */
if
(
i_nal_type
==
NAL_SEI
)
if
(
i_nal_type
==
H264_
NAL_SEI
)
{
{
ParseSei
(
p_dec
,
p_frag
);
ParseSei
(
p_dec
,
p_frag
);
}
}
else
if
(
i_nal_type
==
NAL_AU_DELIMITER
)
else
if
(
i_nal_type
==
H264_
NAL_AU_DELIMITER
)
{
{
if
(
p_sys
->
p_frame
&&
(
p_sys
->
p_frame
->
i_flags
&
BLOCK_FLAG_PRIVATE_AUD
)
)
if
(
p_sys
->
p_frame
&&
(
p_sys
->
p_frame
->
i_flags
&
BLOCK_FLAG_PRIVATE_AUD
)
)
{
{
...
@@ -706,12 +706,12 @@ static block_t *OutputPicture( decoder_t *p_dec )
...
@@ -706,12 +706,12 @@ static block_t *OutputPicture( decoder_t *p_dec )
}
}
block_t
*
p_list
=
NULL
;
block_t
*
p_list
=
NULL
;
for
(
int
i
=
0
;
i
<
SPS_MAX
&&
(
b_sps_pps_i
||
p_sys
->
b_frame_sps
);
i
++
)
for
(
int
i
=
0
;
i
<
H264_
SPS_MAX
&&
(
b_sps_pps_i
||
p_sys
->
b_frame_sps
);
i
++
)
{
{
if
(
p_sys
->
pp_sps
[
i
]
)
if
(
p_sys
->
pp_sps
[
i
]
)
block_ChainAppend
(
&
p_list
,
block_Duplicate
(
p_sys
->
pp_sps
[
i
]
)
);
block_ChainAppend
(
&
p_list
,
block_Duplicate
(
p_sys
->
pp_sps
[
i
]
)
);
}
}
for
(
int
i
=
0
;
i
<
PPS_MAX
&&
(
b_sps_pps_i
||
p_sys
->
b_frame_pps
);
i
++
)
for
(
int
i
=
0
;
i
<
H264_
PPS_MAX
&&
(
b_sps_pps_i
||
p_sys
->
b_frame_pps
);
i
++
)
{
{
if
(
p_sys
->
pp_pps
[
i
]
)
if
(
p_sys
->
pp_pps
[
i
]
)
block_ChainAppend
(
&
p_list
,
block_Duplicate
(
p_sys
->
pp_pps
[
i
]
)
);
block_ChainAppend
(
&
p_list
,
block_Duplicate
(
p_sys
->
pp_pps
[
i
]
)
);
...
@@ -821,7 +821,7 @@ static block_t *OutputPicture( decoder_t *p_dec )
...
@@ -821,7 +821,7 @@ static block_t *OutputPicture( decoder_t *p_dec )
static
void
PutSPS
(
decoder_t
*
p_dec
,
block_t
*
p_frag
)
static
void
PutSPS
(
decoder_t
*
p_dec
,
block_t
*
p_frag
)
{
{
decoder_sys_t
*
p_sys
=
p_dec
->
p_sys
;
decoder_sys_t
*
p_sys
=
p_dec
->
p_sys
;
struct
nal_sps
sps
;
struct
h264_
nal_sps
sps
;
if
(
h264_parse_sps
(
p_frag
->
p_buffer
,
p_frag
->
i_buffer
,
&
sps
)
!=
0
)
if
(
h264_parse_sps
(
p_frag
->
p_buffer
,
p_frag
->
i_buffer
,
&
sps
)
!=
0
)
{
{
...
@@ -871,7 +871,7 @@ static void PutSPS( decoder_t *p_dec, block_t *p_frag )
...
@@ -871,7 +871,7 @@ static void PutSPS( decoder_t *p_dec, block_t *p_frag )
static
void
PutPPS
(
decoder_t
*
p_dec
,
block_t
*
p_frag
)
static
void
PutPPS
(
decoder_t
*
p_dec
,
block_t
*
p_frag
)
{
{
decoder_sys_t
*
p_sys
=
p_dec
->
p_sys
;
decoder_sys_t
*
p_sys
=
p_dec
->
p_sys
;
struct
nal_pps
pps
;
struct
h264_
nal_pps
pps
;
if
(
h264_parse_pps
(
p_frag
->
p_buffer
,
p_frag
->
i_buffer
,
&
pps
)
!=
0
)
if
(
h264_parse_pps
(
p_frag
->
p_buffer
,
p_frag
->
i_buffer
,
&
pps
)
!=
0
)
{
{
...
@@ -950,7 +950,7 @@ static void ParseSlice( decoder_t *p_dec, bool *pb_new_picture, slice_t *p_slice
...
@@ -950,7 +950,7 @@ static void ParseSlice( decoder_t *p_dec, bool *pb_new_picture, slice_t *p_slice
}
}
slice
.
i_idr_pic_id
=
p_sys
->
slice
.
i_idr_pic_id
;
slice
.
i_idr_pic_id
=
p_sys
->
slice
.
i_idr_pic_id
;
if
(
slice
.
i_nal_type
==
NAL_SLICE_IDR
)
if
(
slice
.
i_nal_type
==
H264_
NAL_SLICE_IDR
)
slice
.
i_idr_pic_id
=
bs_read_ue
(
&
s
);
slice
.
i_idr_pic_id
=
bs_read_ue
(
&
s
);
slice
.
i_pic_order_cnt_lsb
=
-
1
;
slice
.
i_pic_order_cnt_lsb
=
-
1
;
...
@@ -992,7 +992,7 @@ static void ParseSlice( decoder_t *p_dec, bool *pb_new_picture, slice_t *p_slice
...
@@ -992,7 +992,7 @@ static void ParseSlice( decoder_t *p_dec, bool *pb_new_picture, slice_t *p_slice
(
slice
.
i_delta_pic_order_cnt0
!=
p_sys
->
slice
.
i_delta_pic_order_cnt0
||
(
slice
.
i_delta_pic_order_cnt0
!=
p_sys
->
slice
.
i_delta_pic_order_cnt0
||
slice
.
i_delta_pic_order_cnt1
!=
p_sys
->
slice
.
i_delta_pic_order_cnt1
)
)
slice
.
i_delta_pic_order_cnt1
!=
p_sys
->
slice
.
i_delta_pic_order_cnt1
)
)
b_pic
=
true
;
b_pic
=
true
;
if
(
(
slice
.
i_nal_type
==
NAL_SLICE_IDR
||
p_sys
->
slice
.
i_nal_type
==
NAL_SLICE_IDR
)
&&
if
(
(
slice
.
i_nal_type
==
H264_NAL_SLICE_IDR
||
p_sys
->
slice
.
i_nal_type
==
H264_
NAL_SLICE_IDR
)
&&
(
slice
.
i_nal_type
!=
p_sys
->
slice
.
i_nal_type
||
slice
.
i_idr_pic_id
!=
p_sys
->
slice
.
i_idr_pic_id
)
)
(
slice
.
i_nal_type
!=
p_sys
->
slice
.
i_nal_type
||
slice
.
i_idr_pic_id
!=
p_sys
->
slice
.
i_idr_pic_id
)
)
b_pic
=
true
;
b_pic
=
true
;
...
@@ -1038,7 +1038,7 @@ static void ParseSei( decoder_t *p_dec, block_t *p_frag )
...
@@ -1038,7 +1038,7 @@ static void ParseSei( decoder_t *p_dec, block_t *p_frag )
break
;
break
;
/* Look for pic timing */
/* Look for pic timing */
if
(
i_type
==
SEI_PIC_TIMING
)
if
(
i_type
==
H264_
SEI_PIC_TIMING
)
{
{
bs_t
s
;
bs_t
s
;
const
int
i_tim
=
i_size
;
const
int
i_tim
=
i_size
;
...
@@ -1058,7 +1058,7 @@ static void ParseSei( decoder_t *p_dec, block_t *p_frag )
...
@@ -1058,7 +1058,7 @@ static void ParseSei( decoder_t *p_dec, block_t *p_frag )
}
}
/* Look for user_data_registered_itu_t_t35 */
/* Look for user_data_registered_itu_t_t35 */
if
(
i_type
==
SEI_USER_DATA_REGISTERED_ITU_T_T35
)
if
(
i_type
==
H264_
SEI_USER_DATA_REGISTERED_ITU_T_T35
)
{
{
/* TS 101 154 Auxiliary Data and H264/AVC video */
/* TS 101 154 Auxiliary Data and H264/AVC video */
static
const
uint8_t
p_DVB1_data_start_code
[]
=
{
static
const
uint8_t
p_DVB1_data_start_code
[]
=
{
...
@@ -1089,7 +1089,7 @@ static void ParseSei( decoder_t *p_dec, block_t *p_frag )
...
@@ -1089,7 +1089,7 @@ static void ParseSei( decoder_t *p_dec, block_t *p_frag )
}
}
/* Look for SEI recovery point */
/* Look for SEI recovery point */
if
(
i_type
==
SEI_RECOVERY_POINT
)
if
(
i_type
==
H264_
SEI_RECOVERY_POINT
)
{
{
bs_t
s
;
bs_t
s
;
const
int
i_rec
=
i_size
;
const
int
i_rec
=
i_size
;
...
...
modules/packetizer/h264_nal.c
View file @
826338ca
...
@@ -335,7 +335,7 @@ int h264_get_spspps( uint8_t *p_buf, size_t i_buf,
...
@@ -335,7 +335,7 @@ int h264_get_spspps( uint8_t *p_buf, size_t i_buf,
{
{
uint8_t
*
p_sps
=
NULL
,
*
p_pps
=
NULL
;
uint8_t
*
p_sps
=
NULL
,
*
p_pps
=
NULL
;
size_t
i_sps_size
=
0
,
i_pps_size
=
0
;
size_t
i_sps_size
=
0
,
i_pps_size
=
0
;
int
i_nal_type
=
NAL_UNKNOWN
;
int
i_nal_type
=
H264_
NAL_UNKNOWN
;
bool
b_first_nal
=
true
;
bool
b_first_nal
=
true
;
bool
b_has_zero_byte
=
false
;
bool
b_has_zero_byte
=
false
;
...
@@ -346,12 +346,12 @@ int h264_get_spspps( uint8_t *p_buf, size_t i_buf,
...
@@ -346,12 +346,12 @@ int h264_get_spspps( uint8_t *p_buf, size_t i_buf,
/* cf B.1.1: a NAL unit starts and ends with 0x000001 or 0x00000001 */
/* cf B.1.1: a NAL unit starts and ends with 0x000001 or 0x00000001 */
if
(
i_buf
>
3
&&
!
memcmp
(
p_buf
,
annexb_startcode
,
3
)
)
if
(
i_buf
>
3
&&
!
memcmp
(
p_buf
,
annexb_startcode
,
3
)
)
{
{
if
(
i_nal_type
!=
NAL_UNKNOWN
)
if
(
i_nal_type
!=
H264_
NAL_UNKNOWN
)
{
{
/* update SPS/PPS size */
/* update SPS/PPS size */
if
(
i_nal_type
==
NAL_SPS
)
if
(
i_nal_type
==
H264_
NAL_SPS
)
i_sps_size
=
p_buf
-
p_sps
-
(
b_has_zero_byte
?
1
:
0
);
i_sps_size
=
p_buf
-
p_sps
-
(
b_has_zero_byte
?
1
:
0
);
if
(
i_nal_type
==
NAL_PPS
)
if
(
i_nal_type
==
H264_
NAL_PPS
)
i_pps_size
=
p_buf
-
p_pps
-
(
b_has_zero_byte
?
1
:
0
);
i_pps_size
=
p_buf
-
p_pps
-
(
b_has_zero_byte
?
1
:
0
);
if
(
i_sps_size
&&
i_pps_size
)
if
(
i_sps_size
&&
i_pps_size
)
...
@@ -364,16 +364,16 @@ int h264_get_spspps( uint8_t *p_buf, size_t i_buf,
...
@@ -364,16 +364,16 @@ int h264_get_spspps( uint8_t *p_buf, size_t i_buf,
/* The start prefix is always 0x00000001 (annexb_startcode + a
/* The start prefix is always 0x00000001 (annexb_startcode + a
* leading zero byte) for SPS, PPS or the first NAL */
* leading zero byte) for SPS, PPS or the first NAL */
if
(
!
b_has_zero_byte
&&
(
b_first_nal
||
i_nal_type
==
NAL_SPS
if
(
!
b_has_zero_byte
&&
(
b_first_nal
||
i_nal_type
==
H264_
NAL_SPS
||
i_nal_type
==
NAL_PPS
)
)
||
i_nal_type
==
H264_
NAL_PPS
)
)
return
-
1
;
return
-
1
;
b_first_nal
=
false
;
b_first_nal
=
false
;
/* Pointer to the beginning of the SPS/PPS starting with the
/* Pointer to the beginning of the SPS/PPS starting with the
* leading zero byte */
* leading zero byte */
if
(
i_nal_type
==
NAL_SPS
&&
!
p_sps
)
if
(
i_nal_type
==
H264_
NAL_SPS
&&
!
p_sps
)
p_sps
=
p_buf
-
1
;
p_sps
=
p_buf
-
1
;
if
(
i_nal_type
==
NAL_PPS
&&
!
p_pps
)
if
(
i_nal_type
==
H264_
NAL_PPS
&&
!
p_pps
)
p_pps
=
p_buf
-
1
;
p_pps
=
p_buf
-
1
;
/* cf. 7.4.1.2.3 */
/* cf. 7.4.1.2.3 */
...
@@ -381,7 +381,7 @@ int h264_get_spspps( uint8_t *p_buf, size_t i_buf,
...
@@ -381,7 +381,7 @@ int h264_get_spspps( uint8_t *p_buf, size_t i_buf,
return
-
1
;
return
-
1
;
/* SPS/PPS are before the slices */
/* SPS/PPS are before the slices */
if
(
i_nal_type
>=
NAL_SLICE
&&
i_nal_type
<=
NAL_SLICE_IDR
)
if
(
i_nal_type
>=
H264_NAL_SLICE
&&
i_nal_type
<=
H264_
NAL_SLICE_IDR
)
break
;
break
;
i_move
=
4
;
i_move
=
4
;
}
}
...
@@ -398,9 +398,9 @@ int h264_get_spspps( uint8_t *p_buf, size_t i_buf,
...
@@ -398,9 +398,9 @@ int h264_get_spspps( uint8_t *p_buf, size_t i_buf,
if
(
i_buf
==
0
)
if
(
i_buf
==
0
)
{
{
/* update SPS/PPS size if we reach the end of the bytestream */
/* update SPS/PPS size if we reach the end of the bytestream */
if
(
!
i_sps_size
&&
i_nal_type
==
NAL_SPS
)
if
(
!
i_sps_size
&&
i_nal_type
==
H264_
NAL_SPS
)
i_sps_size
=
p_buf
-
p_sps
;
i_sps_size
=
p_buf
-
p_sps
;
if
(
!
i_pps_size
&&
i_nal_type
==
NAL_PPS
)
if
(
!
i_pps_size
&&
i_nal_type
==
H264_
NAL_PPS
)
i_pps_size
=
p_buf
-
p_pps
;
i_pps_size
=
p_buf
-
p_pps
;
}
}
if
(
(
!
p_sps
||
!
i_sps_size
)
&&
(
!
p_pps
||
!
i_pps_size
)
)
if
(
(
!
p_sps
||
!
i_sps_size
)
&&
(
!
p_pps
||
!
i_pps_size
)
)
...
@@ -414,17 +414,17 @@ int h264_get_spspps( uint8_t *p_buf, size_t i_buf,
...
@@ -414,17 +414,17 @@ int h264_get_spspps( uint8_t *p_buf, size_t i_buf,
}
}
int
h264_parse_sps
(
const
uint8_t
*
p_sps_buf
,
int
i_sps_size
,
int
h264_parse_sps
(
const
uint8_t
*
p_sps_buf
,
int
i_sps_size
,
struct
nal_sps
*
p_sps
)
struct
h264_
nal_sps
*
p_sps
)
{
{
uint8_t
*
pb_dec
=
NULL
;
uint8_t
*
pb_dec
=
NULL
;
size_t
i_dec
=
0
;
size_t
i_dec
=
0
;
bs_t
s
;
bs_t
s
;
int
i_tmp
;
int
i_tmp
;
if
(
i_sps_size
<
5
||
(
p_sps_buf
[
4
]
&
0x1f
)
!=
NAL_SPS
)
if
(
i_sps_size
<
5
||
(
p_sps_buf
[
4
]
&
0x1f
)
!=
H264_
NAL_SPS
)
return
-
1
;
return
-
1
;
memset
(
p_sps
,
0
,
sizeof
(
struct
nal_sps
)
);
memset
(
p_sps
,
0
,
sizeof
(
struct
h264_
nal_sps
)
);
CreateRbspFromNAL
(
&
pb_dec
,
&
i_dec
,
&
p_sps_buf
[
5
],
CreateRbspFromNAL
(
&
pb_dec
,
&
i_dec
,
&
p_sps_buf
[
5
],
i_sps_size
-
5
);
i_sps_size
-
5
);
if
(
!
pb_dec
)
if
(
!
pb_dec
)
...
@@ -437,7 +437,7 @@ int h264_parse_sps( const uint8_t *p_sps_buf, int i_sps_size,
...
@@ -437,7 +437,7 @@ int h264_parse_sps( const uint8_t *p_sps_buf, int i_sps_size,
p_sps
->
i_level
=
bs_read
(
&
s
,
8
);
p_sps
->
i_level
=
bs_read
(
&
s
,
8
);
/* sps id */
/* sps id */
p_sps
->
i_id
=
bs_read_ue
(
&
s
);
p_sps
->
i_id
=
bs_read_ue
(
&
s
);
if
(
p_sps
->
i_id
>=
SPS_MAX
)
if
(
p_sps
->
i_id
>=
H264_
SPS_MAX
)
{
{
free
(
pb_dec
);
free
(
pb_dec
);
return
-
1
;
return
-
1
;
...
@@ -682,18 +682,18 @@ int h264_parse_sps( const uint8_t *p_sps_buf, int i_sps_size,
...
@@ -682,18 +682,18 @@ int h264_parse_sps( const uint8_t *p_sps_buf, int i_sps_size,
}
}
int
h264_parse_pps
(
const
uint8_t
*
p_pps_buf
,
int
i_pps_size
,
int
h264_parse_pps
(
const
uint8_t
*
p_pps_buf
,
int
i_pps_size
,
struct
nal_pps
*
p_pps
)
struct
h264_
nal_pps
*
p_pps
)
{
{
bs_t
s
;
bs_t
s
;
if
(
i_pps_size
<
5
||
(
p_pps_buf
[
4
]
&
0x1f
)
!=
NAL_PPS
)
if
(
i_pps_size
<
5
||
(
p_pps_buf
[
4
]
&
0x1f
)
!=
H264_
NAL_PPS
)
return
-
1
;
return
-
1
;
memset
(
p_pps
,
0
,
sizeof
(
struct
nal_pps
)
);
memset
(
p_pps
,
0
,
sizeof
(
struct
h264_
nal_pps
)
);
bs_init
(
&
s
,
&
p_pps_buf
[
5
],
i_pps_size
-
5
);
bs_init
(
&
s
,
&
p_pps_buf
[
5
],
i_pps_size
-
5
);
p_pps
->
i_id
=
bs_read_ue
(
&
s
);
// pps id
p_pps
->
i_id
=
bs_read_ue
(
&
s
);
// pps id
p_pps
->
i_sps_id
=
bs_read_ue
(
&
s
);
// sps id
p_pps
->
i_sps_id
=
bs_read_ue
(
&
s
);
// sps id
if
(
p_pps
->
i_id
>=
PPS_MAX
||
p_pps
->
i_sps_id
>=
SPS_MAX
)
if
(
p_pps
->
i_id
>=
H264_PPS_MAX
||
p_pps
->
i_sps_id
>=
H264_
SPS_MAX
)
{
{
return
-
1
;
return
-
1
;
}
}
...
...
modules/packetizer/h264_nal.h
View file @
826338ca
...
@@ -49,33 +49,33 @@
...
@@ -49,33 +49,33 @@
#define PROFILE_H264_MVC_MULTIVIEW_DEPTH_HIGH 138
#define PROFILE_H264_MVC_MULTIVIEW_DEPTH_HIGH 138
#define PROFILE_H264_MVC_ENHANCED_MULTIVIEW_DEPTH_HIGH 139
#define PROFILE_H264_MVC_ENHANCED_MULTIVIEW_DEPTH_HIGH 139
#define SPS_MAX (32)
#define
H264_
SPS_MAX (32)
#define PPS_MAX (256)
#define
H264_
PPS_MAX (256)
enum
nal_unit_type_e
enum
h264_
nal_unit_type_e
{
{
NAL_UNKNOWN
=
0
,
H264_
NAL_UNKNOWN
=
0
,
NAL_SLICE
=
1
,
H264_
NAL_SLICE
=
1
,
NAL_SLICE_DPA
=
2
,
H264_
NAL_SLICE_DPA
=
2
,
NAL_SLICE_DPB
=
3
,
H264_
NAL_SLICE_DPB
=
3
,
NAL_SLICE_DPC
=
4
,
H264_
NAL_SLICE_DPC
=
4
,
NAL_SLICE_IDR
=
5
,
/* ref_idc != 0 */
H264_
NAL_SLICE_IDR
=
5
,
/* ref_idc != 0 */
NAL_SEI
=
6
,
/* ref_idc == 0 */
H264_
NAL_SEI
=
6
,
/* ref_idc == 0 */
NAL_SPS
=
7
,
H264_
NAL_SPS
=
7
,
NAL_PPS
=
8
,
H264_
NAL_PPS
=
8
,
NAL_AU_DELIMITER
=
9
H264_
NAL_AU_DELIMITER
=
9
/* ref_idc == 0 for 6,9,10,11,12 */
/* ref_idc == 0 for 6,9,10,11,12 */
};
};
/* Defined in H.264 annex D */
/* Defined in H.264 annex D */
enum
sei_type_e
enum
h264_
sei_type_e
{
{
SEI_PIC_TIMING
=
1
,
H264_
SEI_PIC_TIMING
=
1
,
SEI_USER_DATA_REGISTERED_ITU_T_T35
=
4
,
H264_
SEI_USER_DATA_REGISTERED_ITU_T_T35
=
4
,
SEI_RECOVERY_POINT
=
6
H264_
SEI_RECOVERY_POINT
=
6
};
};
struct
nal_sps
struct
h264_
nal_sps
{
{
int
i_id
;
int
i_id
;
int
i_profile
,
i_profile_compatibility
,
i_level
;
int
i_profile
,
i_profile_compatibility
,
i_level
;
...
@@ -100,7 +100,7 @@ struct nal_sps
...
@@ -100,7 +100,7 @@ struct nal_sps
}
vui
;
}
vui
;
};
};
struct
nal_pps
struct
h264_
nal_pps
{
{
int
i_id
;
int
i_id
;
int
i_sps_id
;
int
i_sps_id
;
...
@@ -143,12 +143,12 @@ int h264_get_spspps( uint8_t *p_buf, size_t i_buf,
...
@@ -143,12 +143,12 @@ int h264_get_spspps( uint8_t *p_buf, size_t i_buf,
/* Parse a SPS into the struct nal_sps
/* Parse a SPS into the struct nal_sps
* Returns 0 in case of success */
* Returns 0 in case of success */
int
h264_parse_sps
(
const
uint8_t
*
p_sps_buf
,
int
i_sps_size
,
int
h264_parse_sps
(
const
uint8_t
*
p_sps_buf
,
int
i_sps_size
,
struct
nal_sps
*
p_sps
);
struct
h264_
nal_sps
*
p_sps
);
/* Parse a PPS into the struct nal_pps
/* Parse a PPS into the struct nal_pps
* Returns 0 in case of success */
* Returns 0 in case of success */
int
h264_parse_pps
(
const
uint8_t
*
p_pps_buf
,
int
i_pps_size
,
int
h264_parse_pps
(
const
uint8_t
*
p_pps_buf
,
int
i_pps_size
,
struct
nal_pps
*
p_pps
);
struct
h264_
nal_pps
*
p_pps
);
/* Create a AVCDecoderConfigurationRecord from SPS/PPS
/* Create a AVCDecoderConfigurationRecord from SPS/PPS
* Returns a valid block_t on success, must be freed with block_Release */
* Returns a valid block_t on success, must be freed with block_Release */
...
...
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