[vlc-devel] [RFC-PATCH 07/12] core: introduced DecoderPrerollBlock

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


This function will be used to query whether a certain block is part of
the current preroll (if any). Introducing this helper will shorten code
that deals with these cases since we currently have three cases of
code-duplication related to the problem solved.

The 3rd and 4th arguments are used to determine whether the block should
be prerolled based on the PTS of the decoded entity. Given that we
should not preroll entities which duration spans across the
preroll-end-timestamp, the 4th argument (i_pts_stop) is very much
relevant.

The function accepts a function-pointer (5th argument) as last argument, which referred
to function will be called if a block is received that ends the preroll
(ie. the callback is a suitable location to flush the underlying
*_output).
---
 src/input/decoder.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/src/input/decoder.c b/src/input/decoder.c
index 66b3725..70154eb 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -211,6 +211,31 @@ static void DecoderUpdateFormatLocked( decoder_t *p_dec )
     p_owner->b_fmt_description = true;
 }
 
+static int DecoderPrerollBlock( decoder_t * p_dec,
+  uint32_t i_flags, mtime_t i_pts, mtime_t i_pts_stop, void(*pf_prerolled)(decoder_t*) )
+{
+    bool b_flag_preroll = i_flags & BLOCK_FLAG_PREROLL;
+    bool b_flag_forced  = i_flags & BLOCK_FLAG_DISPLAY_FORCED;
+
+    if( b_flag_preroll && !b_flag_forced )
+        return 1;
+
+    mtime_t i_preroll_end = input_DecoderGetPrerollEnd( p_dec );
+
+    if( i_preroll_end <= VLC_TS_INVALID )
+        return 0;
+
+    if( i_pts < i_preroll_end && i_pts_stop < i_preroll_end )
+        return !b_flag_forced;
+
+    input_DecoderSetPrerollEnd( p_dec, VLC_TS_INVALID );
+
+    if( pf_prerolled )
+        pf_prerolled( p_dec );
+
+    return 0;
+}
+
 /*****************************************************************************
  * Buffers allocation callbacks for the decoders
  *****************************************************************************/
-- 
2.8.2



More information about the vlc-devel mailing list