[vlc-commits] packetizer: h264: try to set dts without bframes
Francois Cartegnie
git at videolan.org
Thu Jul 12 20:35:14 CEST 2018
vlc/vlc-3.0 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Jul 10 15:26:12 2018 +0200| [4dfc8f9da5d618697409f2271108da0c6e819631] | committer: Francois Cartegnie
packetizer: h264: try to set dts without bframes
(cherry picked from commit 2174cba9af6d66a1864c5e4f5081148f9eaef51e)
> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=4dfc8f9da5d618697409f2271108da0c6e819631
---
modules/packetizer/h264.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/modules/packetizer/h264.c b/modules/packetizer/h264.c
index 76b6ed5286..14a622f7cc 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_TS_INVALID &&
+ CanSwapPTSwithDTS( &p_sys->slice, p_sps ) )
+ {
+ p_pic->i_dts = p_pic->i_pts;
+ if( date_Get( &p_sys->dts ) == VLC_TS_INVALID )
+ date_Set( &p_sys->dts, p_pic->i_pts );
+ }
if( p_pic->i_pts > VLC_TS_INVALID )
{
More information about the vlc-commits
mailing list