[vlc-devel] [RFC-PATCH 08/12] core: refactored prerolling related to video

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


Given the name "DecoderPlayVideo" one could assume that the function would
"play" the picture_t that it is being passed, but within its implementation
there was piece of code that will drop (ie. not play) a picture /if/ it is part
of the current preroll (if any).

This commit:

    - moves the appropriate "drop" logic from DecoderPlayVideo to
      DecoderDecodeVideo, and;
    - makes use of DecoderPrerollBlock in order to avoid code
      duplication, and;
    - refactors the implementation to aid readability.

When a video-track's preroll has ended, DecoderPrerolledVideo is called
which will effectivelly output a diagnostic, and flush the video_output
(if any).
---
 src/input/decoder.c | 52 ++++++++++++++++++++++++++--------------------------
 1 file changed, 26 insertions(+), 26 deletions(-)

diff --git a/src/input/decoder.c b/src/input/decoder.c
index 70154eb..4fa81d0 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -849,27 +849,6 @@ static int DecoderPlayVideo( decoder_t *p_dec, picture_t *p_picture,
 {
     decoder_owner_sys_t *p_owner = p_dec->p_owner;
     vout_thread_t  *p_vout = p_owner->p_vout;
-    bool prerolled;
-
-    vlc_mutex_lock( &p_owner->lock );
-    if( p_owner->i_preroll_end > p_picture->date )
-    {
-        vlc_mutex_unlock( &p_owner->lock );
-        picture_Release( p_picture );
-        return -1;
-    }
-
-    prerolled = p_owner->i_preroll_end > INT64_MIN;
-    p_owner->i_preroll_end = INT64_MIN;
-    vlc_mutex_unlock( &p_owner->lock );
-
-    if( unlikely(prerolled) )
-    {
-        msg_Dbg( p_dec, "end of video preroll" );
-
-        if( p_vout )
-            vout_Flush( p_vout, VLC_TS_INVALID+1 );
-    }
 
     if( p_dec->pf_get_cc &&
         ( !p_owner->p_packetizer || !p_owner->p_packetizer->pf_get_cc ) )
@@ -984,15 +963,36 @@ static int DecoderQueueVideo( decoder_t *p_dec, picture_t *p_pic )
     return ret;
 }
 
+static void DecoderPrerolledVideo( decoder_t * p_dec )
+{
+    vout_thread_t * p_vout  = p_dec->p_owner->p_vout;
+
+    msg_Dbg( p_dec, "end of video preroll" );
+
+    if( p_vout )
+        vout_Flush( p_vout, VLC_TS_0 );
+}
+
 static void DecoderDecodeVideo( decoder_t *p_dec, block_t *p_block )
 {
-    picture_t      *p_pic;
-    block_t **pp_block = p_block ? &p_block : NULL;
-    unsigned i_lost = 0, i_decoded = 0;
+    unsigned i_lost = 0;
+    unsigned i_decoded = 0;
 
-    while( (p_pic = p_dec->pf_decode_video( p_dec, pp_block ) ) )
+    for( ;; )
     {
-        i_decoded++;
+        uint32_t  i_flags = ( p_block ? p_block->i_flags : 0 );
+        picture_t * p_pic = p_dec->pf_decode_video( p_dec, &p_block );
+
+        if( !p_pic )
+            break;
+
+        ++i_decoded;
+
+        if( DecoderPrerollBlock( p_dec, i_flags, p_pic->date, VLC_TS_INVALID, &DecoderPrerolledVideo ) )
+        {
+            picture_Release( p_pic );
+            continue;
+        }
 
         DecoderPlayVideo( p_dec, p_pic, &i_lost );
     }
-- 
2.8.2



More information about the vlc-devel mailing list