[vlc-commits] demux: h26x: increment by field count

Francois Cartegnie git at videolan.org
Fri Feb 17 19:13:06 CET 2017


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Feb 17 19:10:25 2017 +0100| [f72f0fec4a71bcf724caa74bd59853af7756bdc2] | committer: Francois Cartegnie

demux: h26x: increment by field count

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f72f0fec4a71bcf724caa74bd59853af7756bdc2
---

 modules/demux/mpeg/h26x.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/modules/demux/mpeg/h26x.c b/modules/demux/mpeg/h26x.c
index 9c2992b..5872832 100644
--- a/modules/demux/mpeg/h26x.c
+++ b/modules/demux/mpeg/h26x.c
@@ -442,6 +442,8 @@ static int Demux( demux_t *p_demux)
 
             /* h264 packetizer does merge multiple NAL into AU, but slice flag persists */
             bool frame = p_block_out->i_flags & BLOCK_FLAG_TYPE_MASK;
+            const mtime_t i_frame_dts = p_block_out->i_dts;
+            const mtime_t i_frame_length = p_block_out->i_length;
             es_out_Send( p_demux->out, p_sys->p_es, p_block_out );
             if( frame )
             {
@@ -459,13 +461,23 @@ static int Demux( demux_t *p_demux)
                         p_sys->frame_rate_num = 25000;
                         p_sys->frame_rate_den = 1000;
                     }
-                    date_Init( &p_sys->dts, p_sys->frame_rate_num, p_sys->frame_rate_den );
+                    date_Init( &p_sys->dts, 2 * p_sys->frame_rate_num, p_sys->frame_rate_den );
                     date_Set( &p_sys->dts, VLC_TS_0 );
                     msg_Dbg( p_demux, "using %.2f fps", (double) p_sys->frame_rate_num / p_sys->frame_rate_den );
                 }
 
                 es_out_Control( p_demux->out, ES_OUT_SET_PCR, date_Get( &p_sys->dts ) );
-                date_Increment( &p_sys->dts, 1 );
+                unsigned i_nb_fields;
+                if( i_frame_length > 0 )
+                {
+                    i_nb_fields = 3 * i_frame_length * p_sys->frame_rate_num /
+                                  ( p_sys->frame_rate_den * CLOCK_FREQ);
+                }
+                else i_nb_fields = 2;
+                if( i_nb_fields <= 6 ) /* in the legit range */
+                    date_Increment( &p_sys->dts, i_nb_fields );
+                else /* Somehow some discontinuity */
+                    date_Set( &p_sys->dts, i_frame_dts );
             }
 
             p_block_out = p_next;



More information about the vlc-commits mailing list