Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
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-gpu
Commits
76081cde
Commit
76081cde
authored
Jul 26, 2008
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed timestamp.
Fixed an infinite loop. Fixed aspect ratio extraction.
parent
1afe7311
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
19 deletions
+54
-19
modules/packetizer/h264.c
modules/packetizer/h264.c
+54
-19
No files found.
modules/packetizer/h264.c
View file @
76081cde
...
@@ -117,6 +117,10 @@ struct decoder_sys_t
...
@@ -117,6 +117,10 @@ struct decoder_sys_t
/* Useful values of the Slice Header */
/* Useful values of the Slice Header */
slice_t
slice
;
slice_t
slice
;
/* */
mtime_t
i_frame_pts
;
mtime_t
i_frame_dts
;
};
};
enum
enum
...
@@ -148,7 +152,7 @@ enum nal_priority_e
...
@@ -148,7 +152,7 @@ enum nal_priority_e
NAL_PRIORITY_HIGHEST
=
3
,
NAL_PRIORITY_HIGHEST
=
3
,
};
};
static
block_t
*
ParseNALBlock
(
decoder_t
*
,
block_t
*
);
static
block_t
*
ParseNALBlock
(
decoder_t
*
,
b
ool
*
pb_used_ts
,
b
lock_t
*
);
static
block_t
*
CreateAnnexbNAL
(
decoder_t
*
,
const
uint8_t
*
p
,
int
);
static
block_t
*
CreateAnnexbNAL
(
decoder_t
*
,
const
uint8_t
*
p
,
int
);
...
@@ -214,6 +218,9 @@ static int Open( vlc_object_t *p_this )
...
@@ -214,6 +218,9 @@ static int Open( vlc_object_t *p_this )
p_sys
->
slice
.
i_pic_order_cnt_lsb
=
-
1
;
p_sys
->
slice
.
i_pic_order_cnt_lsb
=
-
1
;
p_sys
->
slice
.
i_delta_pic_order_cnt_bottom
=
-
1
;
p_sys
->
slice
.
i_delta_pic_order_cnt_bottom
=
-
1
;
p_sys
->
i_frame_dts
=
-
1
;
p_sys
->
i_frame_pts
=
-
1
;
/* Setup properties */
/* Setup properties */
es_format_Copy
(
&
p_dec
->
fmt_out
,
&
p_dec
->
fmt_in
);
es_format_Copy
(
&
p_dec
->
fmt_out
,
&
p_dec
->
fmt_in
);
p_dec
->
fmt_out
.
i_codec
=
VLC_FOURCC
(
'h'
,
'2'
,
'6'
,
'4'
);
p_dec
->
fmt_out
.
i_codec
=
VLC_FOURCC
(
'h'
,
'2'
,
'6'
,
'4'
);
...
@@ -226,6 +233,7 @@ static int Open( vlc_object_t *p_this )
...
@@ -226,6 +233,7 @@ static int Open( vlc_object_t *p_this )
* The fmt_out.p_extra should contain all the SPS and PPS with 4 byte startcodes */
* The fmt_out.p_extra should contain all the SPS and PPS with 4 byte startcodes */
uint8_t
*
p
=
&
((
uint8_t
*
)
p_dec
->
fmt_in
.
p_extra
)[
4
];
uint8_t
*
p
=
&
((
uint8_t
*
)
p_dec
->
fmt_in
.
p_extra
)[
4
];
int
i_sps
,
i_pps
;
int
i_sps
,
i_pps
;
bool
b_dummy
;
int
i
;
int
i
;
/* Parse avcC */
/* Parse avcC */
...
@@ -244,7 +252,7 @@ static int Open( vlc_object_t *p_this )
...
@@ -244,7 +252,7 @@ static int Open( vlc_object_t *p_this )
block_t
*
p_sps
=
CreateAnnexbNAL
(
p_dec
,
p
,
i_length
);
block_t
*
p_sps
=
CreateAnnexbNAL
(
p_dec
,
p
,
i_length
);
if
(
!
p_sps
)
if
(
!
p_sps
)
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
ParseNALBlock
(
p_dec
,
p_sps
);
ParseNALBlock
(
p_dec
,
&
b_dummy
,
p_sps
);
p
+=
i_length
;
p
+=
i_length
;
}
}
/* Read PPS */
/* Read PPS */
...
@@ -260,7 +268,7 @@ static int Open( vlc_object_t *p_this )
...
@@ -260,7 +268,7 @@ static int Open( vlc_object_t *p_this )
block_t
*
p_pps
=
CreateAnnexbNAL
(
p_dec
,
p
,
i_length
);
block_t
*
p_pps
=
CreateAnnexbNAL
(
p_dec
,
p
,
i_length
);
if
(
!
p_pps
)
if
(
!
p_pps
)
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
ParseNALBlock
(
p_dec
,
p_pps
);
ParseNALBlock
(
p_dec
,
&
b_dummy
,
p_pps
);
p
+=
i_length
;
p
+=
i_length
;
}
}
msg_Dbg
(
p_dec
,
"avcC length size=%d, sps=%d, pps=%d"
,
msg_Dbg
(
p_dec
,
"avcC length size=%d, sps=%d, pps=%d"
,
...
@@ -404,6 +412,8 @@ static block_t *Packetize( decoder_t *p_dec, block_t **pp_block )
...
@@ -404,6 +412,8 @@ static block_t *Packetize( decoder_t *p_dec, block_t **pp_block )
for
(
;;
)
for
(
;;
)
{
{
bool
b_used_ts
;
switch
(
p_sys
->
i_state
)
switch
(
p_sys
->
i_state
)
{
{
case
STATE_NOSYNC
:
case
STATE_NOSYNC
:
...
@@ -438,11 +448,15 @@ static block_t *Packetize( decoder_t *p_dec, block_t **pp_block )
...
@@ -438,11 +448,15 @@ static block_t *Packetize( decoder_t *p_dec, block_t **pp_block )
/* Need more data */
/* Need more data */
return
NULL
;
return
NULL
;
}
}
block_BytestreamFlush
(
&
p_sys
->
bytestream
);
/* Get the new fragment and set the pts/dts */
/* Get the new fragment and set the pts/dts */
block_t
*
p_block_bytestream
=
p_sys
->
bytestream
.
p_block
;
p_pic
=
block_New
(
p_dec
,
p_sys
->
i_offset
+
1
);
p_pic
=
block_New
(
p_dec
,
p_sys
->
i_offset
+
1
);
p_pic
->
i_pts
=
p_sys
->
bytestream
.
p_block
->
i_pts
;
p_pic
->
i_pts
=
p_block_bytestream
->
i_pts
;
p_pic
->
i_dts
=
p_sys
->
bytestream
.
p_block
->
i_dts
;
p_pic
->
i_dts
=
p_block_bytestream
->
i_dts
;
/* Force 4 byte startcode 0 0 0 1 */
/* Force 4 byte startcode 0 0 0 1 */
p_pic
->
p_buffer
[
0
]
=
0
;
p_pic
->
p_buffer
[
0
]
=
0
;
...
@@ -455,7 +469,14 @@ static block_t *Packetize( decoder_t *p_dec, block_t **pp_block )
...
@@ -455,7 +469,14 @@ static block_t *Packetize( decoder_t *p_dec, block_t **pp_block )
p_sys
->
i_offset
=
0
;
p_sys
->
i_offset
=
0
;
/* Parse the NAL */
/* Parse the NAL */
if
(
!
(
p_pic
=
ParseNALBlock
(
p_dec
,
p_pic
)
)
)
p_pic
=
ParseNALBlock
(
p_dec
,
&
b_used_ts
,
p_pic
);
if
(
b_used_ts
)
{
p_block_bytestream
->
i_dts
=
-
1
;
p_block_bytestream
->
i_pts
=
-
1
;
}
if
(
!
p_pic
)
{
{
p_sys
->
i_state
=
STATE_NOSYNC
;
p_sys
->
i_state
=
STATE_NOSYNC
;
break
;
break
;
...
@@ -501,6 +522,7 @@ static block_t *PacketizeAVC1( decoder_t *p_dec, block_t **pp_block )
...
@@ -501,6 +522,7 @@ static block_t *PacketizeAVC1( decoder_t *p_dec, block_t **pp_block )
for
(
p
=
p_block
->
p_buffer
;
p
<
&
p_block
->
p_buffer
[
p_block
->
i_buffer
];
)
for
(
p
=
p_block
->
p_buffer
;
p
<
&
p_block
->
p_buffer
[
p_block
->
i_buffer
];
)
{
{
block_t
*
p_pic
;
block_t
*
p_pic
;
bool
b_dummy
;
int
i_size
=
0
;
int
i_size
=
0
;
int
i
;
int
i
;
...
@@ -519,11 +541,12 @@ static block_t *PacketizeAVC1( decoder_t *p_dec, block_t **pp_block )
...
@@ -519,11 +541,12 @@ static block_t *PacketizeAVC1( decoder_t *p_dec, block_t **pp_block )
block_t
*
p_part
=
CreateAnnexbNAL
(
p_dec
,
p
,
i_size
);
block_t
*
p_part
=
CreateAnnexbNAL
(
p_dec
,
p
,
i_size
);
if
(
!
p_part
)
if
(
!
p_part
)
break
;
break
;
p_part
->
i_dts
=
p_block
->
i_dts
;
p_part
->
i_dts
=
p_block
->
i_dts
;
p_part
->
i_pts
=
p_block
->
i_pts
;
p_part
->
i_pts
=
p_block
->
i_pts
;
/* Parse the NAL */
/* Parse the NAL */
if
(
(
p_pic
=
ParseNALBlock
(
p_dec
,
p_part
)
)
)
if
(
(
p_pic
=
ParseNALBlock
(
p_dec
,
&
b_dummy
,
p_part
)
)
)
{
{
block_ChainAppend
(
&
p_ret
,
p_pic
);
block_ChainAppend
(
&
p_ret
,
p_pic
);
}
}
...
@@ -606,13 +629,15 @@ static inline int bs_read_se( bs_t *s )
...
@@ -606,13 +629,15 @@ static inline int bs_read_se( bs_t *s )
* ParseNALBlock: parses annexB type NALs
* ParseNALBlock: parses annexB type NALs
* All p_frag blocks are required to start with 0 0 0 1 4-byte startcode
* All p_frag blocks are required to start with 0 0 0 1 4-byte startcode
*****************************************************************************/
*****************************************************************************/
static
block_t
*
ParseNALBlock
(
decoder_t
*
p_dec
,
block_t
*
p_frag
)
static
block_t
*
ParseNALBlock
(
decoder_t
*
p_dec
,
b
ool
*
pb_used_ts
,
b
lock_t
*
p_frag
)
{
{
decoder_sys_t
*
p_sys
=
p_dec
->
p_sys
;
decoder_sys_t
*
p_sys
=
p_dec
->
p_sys
;
block_t
*
p_pic
=
NULL
;
block_t
*
p_pic
=
NULL
;
const
int
i_nal_ref_idc
=
(
p_frag
->
p_buffer
[
4
]
>>
5
)
&
0x03
;
const
int
i_nal_ref_idc
=
(
p_frag
->
p_buffer
[
4
]
>>
5
)
&
0x03
;
const
int
i_nal_type
=
p_frag
->
p_buffer
[
4
]
&
0x1f
;
const
int
i_nal_type
=
p_frag
->
p_buffer
[
4
]
&
0x1f
;
const
mtime_t
i_frag_dts
=
p_frag
->
i_dts
;
const
mtime_t
i_frag_pts
=
p_frag
->
i_pts
;
if
(
p_sys
->
b_slice
&&
(
!
p_sys
->
b_sps
||
!
p_sys
->
b_pps
)
)
if
(
p_sys
->
b_slice
&&
(
!
p_sys
->
b_sps
||
!
p_sys
->
b_pps
)
)
{
{
...
@@ -634,7 +659,7 @@ static block_t *ParseNALBlock( decoder_t *p_dec, block_t *p_frag )
...
@@ -634,7 +659,7 @@ static block_t *ParseNALBlock( decoder_t *p_dec, block_t *p_frag )
else
if
(
i_nal_type
>=
NAL_SLICE
&&
i_nal_type
<=
NAL_SLICE_IDR
)
else
if
(
i_nal_type
>=
NAL_SLICE
&&
i_nal_type
<=
NAL_SLICE_IDR
)
{
{
slice_t
slice
;
slice_t
slice
;
bool
b_new_picture
;
bool
b_new_picture
;
ParseSlice
(
p_dec
,
&
b_new_picture
,
&
slice
,
i_nal_ref_idc
,
i_nal_type
,
p_frag
);
ParseSlice
(
p_dec
,
&
b_new_picture
,
&
slice
,
i_nal_ref_idc
,
i_nal_type
,
p_frag
);
...
@@ -654,7 +679,7 @@ static block_t *ParseNALBlock( decoder_t *p_dec, block_t *p_frag )
...
@@ -654,7 +679,7 @@ static block_t *ParseNALBlock( decoder_t *p_dec, block_t *p_frag )
PutSPS
(
p_dec
,
p_frag
);
PutSPS
(
p_dec
,
p_frag
);
/* Do not append the SPS because we will insert it on keyframes */
/* Do not append the SPS because we will insert it on keyframes */
return
p_pic
;
p_frag
=
NULL
;
}
}
else
if
(
i_nal_type
==
NAL_PPS
)
else
if
(
i_nal_type
==
NAL_PPS
)
{
{
...
@@ -664,7 +689,7 @@ static block_t *ParseNALBlock( decoder_t *p_dec, block_t *p_frag )
...
@@ -664,7 +689,7 @@ static block_t *ParseNALBlock( decoder_t *p_dec, block_t *p_frag )
PutPPS
(
p_dec
,
p_frag
);
PutPPS
(
p_dec
,
p_frag
);
/* Do not append the PPS because we will insert it on keyframes */
/* Do not append the PPS because we will insert it on keyframes */
return
p_pic
;
p_frag
=
NULL
;
}
}
else
if
(
i_nal_type
==
NAL_AU_DELIMITER
||
else
if
(
i_nal_type
==
NAL_AU_DELIMITER
||
i_nal_type
==
NAL_SEI
||
i_nal_type
==
NAL_SEI
||
...
@@ -677,8 +702,16 @@ static block_t *ParseNALBlock( decoder_t *p_dec, block_t *p_frag )
...
@@ -677,8 +702,16 @@ static block_t *ParseNALBlock( decoder_t *p_dec, block_t *p_frag )
}
}
/* Append the block */
/* Append the block */
block_ChainAppend
(
&
p_sys
->
p_frame
,
p_frag
);
if
(
p_frag
)
block_ChainAppend
(
&
p_sys
->
p_frame
,
p_frag
);
*
pb_used_ts
=
false
;
if
(
p_sys
->
i_frame_dts
<
0
&&
p_sys
->
i_frame_pts
<
0
)
{
p_sys
->
i_frame_dts
=
i_frag_dts
;
p_sys
->
i_frame_pts
=
i_frag_pts
;
*
pb_used_ts
=
true
;
}
return
p_pic
;
return
p_pic
;
}
}
...
@@ -706,11 +739,8 @@ static block_t *OutputPicture( decoder_t *p_dec )
...
@@ -706,11 +739,8 @@ static block_t *OutputPicture( decoder_t *p_dec )
block_ChainAppend
(
&
p_list
,
block_Duplicate
(
p_sys
->
pp_pps
[
i
]
)
);
block_ChainAppend
(
&
p_list
,
block_Duplicate
(
p_sys
->
pp_pps
[
i
]
)
);
}
}
if
(
p_list
)
if
(
p_list
)
{
p_list
->
i_dts
=
p_sys
->
p_frame
->
i_dts
;
p_list
->
i_pts
=
p_sys
->
p_frame
->
i_pts
;
p_sys
->
b_header
=
true
;
p_sys
->
b_header
=
true
;
}
block_ChainAppend
(
&
p_list
,
p_sys
->
p_frame
);
block_ChainAppend
(
&
p_list
,
p_sys
->
p_frame
);
p_pic
=
block_ChainGather
(
p_list
);
p_pic
=
block_ChainGather
(
p_list
);
}
}
...
@@ -718,11 +748,15 @@ static block_t *OutputPicture( decoder_t *p_dec )
...
@@ -718,11 +748,15 @@ static block_t *OutputPicture( decoder_t *p_dec )
{
{
p_pic
=
block_ChainGather
(
p_sys
->
p_frame
);
p_pic
=
block_ChainGather
(
p_sys
->
p_frame
);
}
}
p_pic
->
i_dts
=
p_sys
->
i_frame_dts
;
p_pic
->
i_pts
=
p_sys
->
i_frame_pts
;
p_pic
->
i_length
=
0
;
/* FIXME */
p_pic
->
i_length
=
0
;
/* FIXME */
p_pic
->
i_flags
|=
p_sys
->
slice
.
i_frame_type
;
p_pic
->
i_flags
|=
p_sys
->
slice
.
i_frame_type
;
p_sys
->
slice
.
i_frame_type
=
0
;
p_sys
->
slice
.
i_frame_type
=
0
;
p_sys
->
p_frame
=
NULL
;
p_sys
->
p_frame
=
NULL
;
p_sys
->
i_frame_dts
=
-
1
;
p_sys
->
i_frame_pts
=
-
1
;
p_sys
->
b_slice
=
false
;
p_sys
->
b_slice
=
false
;
return
p_pic
;
return
p_pic
;
...
@@ -783,6 +817,7 @@ static void PutSPS( decoder_t *p_dec, block_t *p_frag )
...
@@ -783,6 +817,7 @@ static void PutSPS( decoder_t *p_dec, block_t *p_frag )
{
{
/* skip i_offset_for_ref_frame */
/* skip i_offset_for_ref_frame */
bs_read_se
(
&
s
);
bs_read_se
(
&
s
);
i_cycle
--
;
}
}
}
}
/* i_num_ref_frames */
/* i_num_ref_frames */
...
@@ -852,9 +887,9 @@ static void PutSPS( decoder_t *p_dec, block_t *p_frag )
...
@@ -852,9 +887,9 @@ static void PutSPS( decoder_t *p_dec, block_t *p_frag )
h
=
0
;
h
=
0
;
}
}
if
(
h
!=
0
)
if
(
h
!=
0
)
p_dec
->
fmt_out
.
video
.
i_aspect
=
VOUT_ASPECT_FACTOR
*
w
/
p_dec
->
fmt_out
.
video
.
i_aspect
=
VOUT_ASPECT_FACTOR
*
h
*
p_dec
->
fmt_out
.
video
.
i_width
/
(
w
*
p_dec
->
fmt_out
.
video
.
i_width
)
/
p_dec
->
fmt_out
.
video
.
i_height
;
(
h
*
p_dec
->
fmt_out
.
video
.
i_height
)
;
else
else
p_dec
->
fmt_out
.
video
.
i_aspect
=
VOUT_ASPECT_FACTOR
;
p_dec
->
fmt_out
.
video
.
i_aspect
=
VOUT_ASPECT_FACTOR
;
}
}
...
...
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