[vlc-commits] mux: ts: fix rate shaping backward PCR bug

Francois Cartegnie git at videolan.org
Thu May 28 16:33:33 CEST 2020


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed May 27 20:54:21 2020 +0200| [6b6387a50991fd00cfb13135bee1741a15e596ae] | committer: Steve Lhomme

mux: ts: fix rate shaping backward PCR bug

16y old bug with spu or es add..

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

 modules/mux/mpeg/ts.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/modules/mux/mpeg/ts.c b/modules/mux/mpeg/ts.c
index b1ebe0712f..d52289a325 100644
--- a/modules/mux/mpeg/ts.c
+++ b/modules/mux/mpeg/ts.c
@@ -1732,19 +1732,16 @@ static void TSSchedule( sout_mux_t *p_mux, sout_buffer_chain_t *p_chain_ts,
         vlc_tick_t i_max_diff = i_new_dts - p_ts->i_dts;
         vlc_tick_t i_cut_dts = p_ts->i_dts;
 
-        p_ts = BufferChainPeek( p_chain_ts );
-        i++;
-        i_new_dts = i_pcr_dts + i_pcr_length * i / i_packet_count;
-        while ( p_ts != NULL && i_new_dts - p_ts->i_dts >= i_max_diff )
+        while( (p_ts = BufferChainPeek( p_chain_ts )) )
         {
+            i_new_dts = i_pcr_dts + i_pcr_length * i++ / i_packet_count;
+            if( p_ts->i_dts >= i_pcr_dts &&
+                i_new_dts - p_ts->i_dts >= i_max_diff )
+               break;
             p_ts = BufferChainGet( p_chain_ts );
+            BufferChainAppend( &new_chain, p_ts );
             i_max_diff = i_new_dts - p_ts->i_dts;
             i_cut_dts = p_ts->i_dts;
-            BufferChainAppend( &new_chain, p_ts );
-
-            p_ts = BufferChainPeek( p_chain_ts );
-            i++;
-            i_new_dts = i_pcr_dts + i_pcr_length * i / i_packet_count;
         }
         msg_Dbg( p_mux, "adjusting rate at %"PRId64"/%"PRId64" (%d/%d)",
                  i_cut_dts - i_pcr_dts, i_pcr_length, new_chain.i_depth,



More information about the vlc-commits mailing list