[vlc-commits] packetizer: h264: use poc to compute missing pic_struct
Francois Cartegnie
git at videolan.org
Mon Mar 27 14:17:58 CEST 2017
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Mar 27 12:28:40 2017 +0200| [9415d99b4565004456ed9a85c12ccb3dad3e89a8] | committer: Francois Cartegnie
packetizer: h264: use poc to compute missing pic_struct
Since we now have poc, we no longer need to default to pic_struct=4
(num_ts=2)
also refactors for decoder usage.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9415d99b4565004456ed9a85c12ccb3dad3e89a8
---
modules/packetizer/h264.c | 28 ++++++++--------------------
modules/packetizer/h264_slice.c | 29 +++++++++++++++++++++++++++++
modules/packetizer/h264_slice.h | 4 ++++
3 files changed, 41 insertions(+), 20 deletions(-)
diff --git a/modules/packetizer/h264.c b/modules/packetizer/h264.c
index b0496c5..87ed2fe 100644
--- a/modules/packetizer/h264.c
+++ b/modules/packetizer/h264.c
@@ -509,7 +509,7 @@ static void PacketizeReset( void *p_private, bool b_broken )
p_sys->prevdatedpoc.pts = VLC_TS_INVALID;
/* From SEI */
p_sys->i_dpb_output_delay = 0;
- p_sys->i_pic_struct = 0;
+ p_sys->i_pic_struct = UINT8_MAX;
}
p_sys->b_discontinuity = true;
date_Set( &p_sys->dts, VLC_TS_INVALID );
@@ -555,7 +555,7 @@ static block_t *ParseNALBlock( decoder_t *p_dec, bool *pb_ts_used, block_t *p_fr
DropStoredNAL( p_sys );
/* From SEI */
p_sys->i_dpb_output_delay = 0;
- p_sys->i_pic_struct = 0;
+ p_sys->i_pic_struct = UINT8_MAX;
cc_storage_reset( p_sys->p_ccs );
}
@@ -750,19 +750,11 @@ static block_t *OutputPicture( decoder_t *p_dec )
if( !p_pic )
return NULL;
- unsigned i_num_clock_ts = 2;
- if( p_sps->frame_mbs_only_flag == 0 )
- {
- if( p_sps->vui.b_pic_struct_present_flag && p_sys->i_pic_struct < 9 )
- {
- const uint8_t rgi_numclock[9] = { 1, 1, 1, 2, 2, 3, 3, 2, 3 };
- i_num_clock_ts = rgi_numclock[ p_sys->i_pic_struct ];
- }
- else if( p_sys->slice.i_field_pic_flag ) /* See D-1 and E-6 */
- {
- i_num_clock_ts = 1;
- }
- }
+ /* for PTS Fixup, interlaced fields (multiple AU/block) */
+ int tFOC = 0, bFOC = 0, PictureOrderCount = 0;
+ h264_compute_poc( p_sps, &p_sys->slice, &p_sys->pocctx, &PictureOrderCount, &tFOC, &bFOC );
+
+ unsigned i_num_clock_ts = h264_get_num_ts( p_sps, &p_sys->slice, p_sys->i_pic_struct, tFOC, bFOC );
if( p_sps->frame_mbs_only_flag == 0 && p_sps->vui.b_pic_struct_present_flag )
{
@@ -800,10 +792,6 @@ static block_t *OutputPicture( decoder_t *p_dec )
if( p_pic->i_dts <= VLC_TS_INVALID )
p_pic->i_dts = date_Get( &p_sys->dts );
- /* PTS Fixup, interlaced fields (multiple AU/block) */
- int tFOC = 0, bFOC = 0, PictureOrderCount = 0;
- h264_compute_poc( p_sps, &p_sys->slice, &p_sys->pocctx, &PictureOrderCount, &tFOC, &bFOC );
-
if( p_sys->slice.type == H264_SLICE_TYPE_I )
p_sys->prevdatedpoc.pts = VLC_TS_INVALID;
@@ -901,7 +889,7 @@ static block_t *OutputPicture( decoder_t *p_dec )
p_sys->i_frame_dts = VLC_TS_INVALID;
p_sys->i_frame_pts = VLC_TS_INVALID;
p_sys->i_dpb_output_delay = 0;
- p_sys->i_pic_struct = 0;
+ p_sys->i_pic_struct = UINT8_MAX;
p_sys->slice.type = H264_SLICE_TYPE_UNKNOWN;
p_sys->p_sei = NULL;
p_sys->pp_sei_last = &p_sys->p_sei;
diff --git a/modules/packetizer/h264_slice.c b/modules/packetizer/h264_slice.c
index 98f487e..6cc9acb 100644
--- a/modules/packetizer/h264_slice.c
+++ b/modules/packetizer/h264_slice.c
@@ -345,3 +345,32 @@ void h264_compute_poc( const h264_sequence_parameter_set_t *p_sps,
else
*p_PictureOrderCount = *p_tFOC;
}
+
+static uint8_t h264_infer_pic_struct( const h264_sequence_parameter_set_t *p_sps,
+ const h264_slice_t *p_slice,
+ uint8_t i_pic_struct, int tFOC, int bFOC )
+{
+ /* See D-1 and note 6 */
+ if( !p_sps->vui.b_pic_struct_present_flag || i_pic_struct >= 9 )
+ {
+ if( p_slice->i_field_pic_flag )
+ i_pic_struct = 1 + p_slice->i_bottom_field_flag;
+ else if( tFOC == bFOC )
+ i_pic_struct = 0;
+ else if( tFOC < bFOC )
+ i_pic_struct = 3;
+ else
+ i_pic_struct = 4;
+ }
+
+ return i_pic_struct;
+}
+
+uint8_t h264_get_num_ts( const h264_sequence_parameter_set_t *p_sps,
+ const h264_slice_t *p_slice, uint8_t i_pic_struct,
+ int tFOC, int bFOC )
+{
+ i_pic_struct = h264_infer_pic_struct( p_sps, p_slice, i_pic_struct, tFOC, bFOC );
+ const uint8_t rgi_numclock[9] = { 1, 1, 1, 2, 2, 3, 3, 2, 3 };
+ return rgi_numclock[ i_pic_struct ];
+}
diff --git a/modules/packetizer/h264_slice.h b/modules/packetizer/h264_slice.h
index 5729bdc..03fccfd 100644
--- a/modules/packetizer/h264_slice.h
+++ b/modules/packetizer/h264_slice.h
@@ -105,4 +105,8 @@ static inline void h264_poc_context_init( poc_context_t *p_ctx )
void h264_compute_poc( const h264_sequence_parameter_set_t *p_sps,
const h264_slice_t *p_slice, poc_context_t *p_ctx,
int *p_PictureOrderCount, int *p_tFOC, int *p_bFOC );
+
+uint8_t h264_get_num_ts( const h264_sequence_parameter_set_t *p_sps,
+ const h264_slice_t *p_slice, uint8_t pic_struct, int tFOC, int bFOC );
+
#endif
More information about the vlc-commits
mailing list