[vlc-devel] [PATCH 3/3] demux: h26x: fix rounding errors

Zhao Zhili quinkblack at foxmail.com
Tue Mar 20 10:18:18 CET 2018


---
 modules/demux/mpeg/h26x.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/modules/demux/mpeg/h26x.c b/modules/demux/mpeg/h26x.c
index 0e04d80..a97d6f5 100644
--- a/modules/demux/mpeg/h26x.c
+++ b/modules/demux/mpeg/h26x.c
@@ -475,17 +475,16 @@ static int Demux( demux_t *p_demux)
                 }
 
                 es_out_SetPCR( p_demux->out, date_Get( &p_sys->dts ) );
-                unsigned i_nb_fields;
                 if( i_frame_length > 0 )
                 {
-                    i_nb_fields = i_frame_length * 2 * p_sys->frame_rate_num /
+                    unsigned i_nb_fields = i_frame_length * 2 * p_sys->frame_rate_num /
                                   ( p_sys->frame_rate_den * CLOCK_FREQ );
+                    if( i_nb_fields <= 6 ) /* in the legit range */
+                        date_Move( &p_sys->dts, i_frame_length );
+                    else /* Somehow some discontinuity */
+                        date_Set( &p_sys->dts, i_frame_dts );
                 }
-                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 );
+                else date_Increment( &p_sys->dts, 2 );
             }
 
             p_block_out = p_next;
-- 
2.9.5





More information about the vlc-devel mailing list