[vlc-commits] packetizer: h264: try to set dts without bframes
Francois Cartegnie
git at videolan.org
Wed Jul 11 14:30:48 CEST 2018
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Jul 10 15:26:12 2018 +0200| [2174cba9af6d66a1864c5e4f5081148f9eaef51e] | committer: Francois Cartegnie
packetizer: h264: try to set dts without bframes
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2174cba9af6d66a1864c5e4f5081148f9eaef51e
---
modules/access/live555_dtsgen.h | 0
modules/packetizer/h264.c | 21 +++++++++++++++++++--
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/modules/access/live555_dtsgen.h b/modules/access/live555_dtsgen.h
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/modules/packetizer/h264.c b/modules/packetizer/h264.c
index b6c97ca24b..686659f03a 100644
--- a/modules/packetizer/h264.c
+++ b/modules/packetizer/h264.c
@@ -749,6 +749,17 @@ static block_t *ParseNALBlock( decoder_t *p_dec, bool *pb_ts_used, block_t *p_fr
return p_pic;
}
+static bool CanSwapPTSwithDTS( const h264_slice_t *p_slice,
+ const h264_sequence_parameter_set_t *p_sps )
+{
+ if( p_slice->i_nal_ref_idc == 0 && p_slice->type == H264_SLICE_TYPE_B )
+ return true;
+ else if( p_sps->vui.b_valid )
+ return p_sps->vui.i_max_num_reorder_frames == 0;
+ else
+ return p_sps->i_profile == PROFILE_H264_CAVLC_INTRA;
+}
+
static block_t *OutputPicture( decoder_t *p_dec )
{
decoder_sys_t *p_sys = p_dec->p_sys;
@@ -929,8 +940,7 @@ static block_t *OutputPicture( decoder_t *p_dec )
p_pic->i_pts = date_Get( &pts );
}
/* In case there's no PTS at all */
- else if( p_sys->slice.i_nal_ref_idc == 0 &&
- p_sys->slice.type == H264_SLICE_TYPE_B )
+ else if( CanSwapPTSwithDTS( &p_sys->slice, p_sps ) )
{
p_pic->i_pts = p_pic->i_dts;
}
@@ -943,6 +953,13 @@ static block_t *OutputPicture( decoder_t *p_dec )
p_pic->i_pts = date_Get( &pts );
}
}
+ else if( p_pic->i_dts == VLC_TICK_INVALID &&
+ CanSwapPTSwithDTS( &p_sys->slice, p_sps ) )
+ {
+ p_pic->i_dts = p_pic->i_pts;
+ if( date_Get( &p_sys->dts ) == VLC_TICK_INVALID )
+ date_Set( &p_sys->dts, p_pic->i_pts );
+ }
if( p_pic->i_pts != VLC_TICK_INVALID )
{
More information about the vlc-commits
mailing list