[vlc-devel] [PATCH 3/3] packetizer: h264: reuse interlaced frame dts and interpolate pts (#6539)

Francois Cartegnie fcvlcdev at free.fr
Wed Mar 25 23:11:29 CET 2015


---
 modules/packetizer/h264.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/modules/packetizer/h264.c b/modules/packetizer/h264.c
index 89cca0b..56e1e60 100644
--- a/modules/packetizer/h264.c
+++ b/modules/packetizer/h264.c
@@ -134,6 +134,7 @@ struct decoder_sys_t
     /* */
     mtime_t i_frame_pts;
     mtime_t i_frame_dts;
+    int     i_fields_dts;
 
     /* */
     uint32_t i_cc_flags;
@@ -251,6 +252,7 @@ static int Open( vlc_object_t *p_this )
 
     p_sys->i_frame_dts = VLC_TS_INVALID;
     p_sys->i_frame_pts = VLC_TS_INVALID;
+    p_sys->i_fields_dts = 0;
 
     /* Setup properties */
     es_format_Copy( &p_dec->fmt_out, &p_dec->fmt_in );
@@ -690,6 +692,7 @@ static block_t *ParseNALBlock( decoder_t *p_dec, bool *pb_ts_used, block_t *p_fr
     {
         p_sys->i_frame_dts = i_frag_dts;
         p_sys->i_frame_pts = i_frag_pts;
+        p_sys->i_fields_dts = 2;
         *pb_ts_used = true;
     }
     return p_pic;
@@ -789,10 +792,20 @@ static block_t *OutputPicture( decoder_t *p_dec )
         }
     }
 
+    p_sys->i_fields_dts -= (1 + p_sys->b_frame_mbs_only);
+    if( p_sys->i_fields_dts <= 0 )
+    {
+        p_sys->i_frame_dts = VLC_TS_INVALID;
+        p_sys->i_frame_pts = VLC_TS_INVALID;
+    }
+    else if( p_sys->b_timing_info_present_flag )
+    {
+        p_sys->i_frame_pts += CLOCK_FREQ * p_sys->i_num_units_in_tick / p_sys->i_time_scale;
+    }
+    else p_sys->i_frame_pts = VLC_TS_INVALID;
+
     p_sys->slice.i_frame_type = 0;
     p_sys->p_frame = NULL;
-    p_sys->i_frame_dts = VLC_TS_INVALID;
-    p_sys->i_frame_pts = VLC_TS_INVALID;
     p_sys->b_frame_sps = false;
     p_sys->b_frame_pps = false;
     p_sys->b_slice = false;
-- 
2.1.0




More information about the vlc-devel mailing list