[vlc-devel] [RFC-PATCH 02/12] core: removal of DecoderUpdatePreroll

Filip Roséen filip at videolabs.io
Wed May 11 18:56:47 CEST 2016


DecoderUpdatePreroll was a function that was used to update a decoders
preroll-end timestamp, based on a number of different properties of the
block received.

There are a few key points that lead to the removal (and simplification)
of the relevant implementation:

  - An individual block_t flagged with BLOCK_FLAG_PREROLL should /not/
    cause other blocks that may not include the flag to be prerolled.

  - The prerolling value should always be the PTS of a block, given its
    relationship with DEMUX_SET_NEXT_DISPLAY_TIME and the rest of the core.

  - Keeping the preroll-end timestamp to always be at least the value of a
    block's DTS/PTS (if any) will lead to more complicated code elsewhere (and
    it does not make sense overall).

This patch simply replace the function with a relatively simple
if-statement that will only update the preroll if a block is found with
BLOCK_FLAG_DISCONTINUITY.

Updating the preroll to the highest of { i_preroll_end, p_block->i_pts }
will allow us to handle BLOCK_FLAG_DISCONTINUITY during preroll.
---
 src/input/decoder.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/src/input/decoder.c b/src/input/decoder.c
index 847736c..b20bc35 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -637,16 +637,6 @@ static int DecoderTimedWait( decoder_t *p_dec, mtime_t deadline )
     return ret;
 }
 
-static inline void DecoderUpdatePreroll( int64_t *pi_preroll, const block_t *p )
-{
-    if( p->i_flags & (BLOCK_FLAG_PREROLL|BLOCK_FLAG_DISCONTINUITY) )
-        *pi_preroll = INT64_MAX;
-    else if( p->i_dts > VLC_TS_INVALID )
-        *pi_preroll = __MIN( *pi_preroll, p->i_dts );
-    else if( p->i_pts > VLC_TS_INVALID )
-        *pi_preroll = __MIN( *pi_preroll, p->i_pts );
-}
-
 static void DecoderFixTs( decoder_t *p_dec, mtime_t *pi_ts0, mtime_t *pi_ts1,
                           mtime_t *pi_duration, int *pi_rate, mtime_t i_ts_bound )
 {
@@ -1328,10 +1318,12 @@ static void DecoderProcess( decoder_t *p_dec, block_t *p_block )
         return;
     }
 
-    if( p_block )
+    if( p_block && p_block->i_flags & BLOCK_FLAG_DISCONTINUITY )
     {
         vlc_mutex_lock( &p_owner->lock );
-        DecoderUpdatePreroll( &p_owner->i_preroll_end, p_block );
+
+        p_owner->i_preroll_end = __MAX( p_owner->i_preroll_end, p_block->i_pts );
+
         vlc_mutex_unlock( &p_owner->lock );
     }
 
-- 
2.8.2



More information about the vlc-devel mailing list