[vlc-devel] [RFC-PATCH 12/12] core: refactored DecoderProcessSpu

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


The purpose of this function is to decode and play subtitle blocks, the
previous implementation simply decoded and queued the block in question
(which is wrong).

Making use of DecoderPrerollBlock makes it really easy to handle
subtitle blocks that has a duration that span from before the preroll to
some time after.

This patch effectivelly fixes:

    - https://trac.videolan.org/vlc/ticket/10638
    - https://trac.videolan.org/vlc/ticket/16361
---
 src/input/decoder.c | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/src/input/decoder.c b/src/input/decoder.c
index 30ccad8..2ef6678 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -1291,11 +1291,27 @@ static int DecoderQueueSpu( decoder_t *p_dec, subpicture_t *p_spu )
  */
 static void DecoderProcessSpu( decoder_t *p_dec, block_t *p_block )
 {
-    subpicture_t *p_spu;
-    block_t **pp_block = p_block ? &p_block : NULL;
+    unsigned i_decoded = 0;
+
+    for( ;; )
+    {
+        subpicture_t *p_spu = p_dec->pf_decode_sub( p_dec, &p_block );
+
+        if( !p_spu )
+            break;
+
+        ++i_decoded;
+
+        if( DecoderPrerollBlock( p_dec, 0, p_spu->i_start, p_spu->i_stop, NULL ) )
+        {
+            subpicture_Delete( p_spu );  
+            continue;
+        }
+
+        DecoderPlaySpu( p_dec, p_spu );
+    }
 
-    while( (p_spu = p_dec->pf_decode_sub( p_dec, pp_block ) ) )
-        DecoderQueueSpu( p_dec, p_spu );
+    DecoderUpdateStatSpu( p_dec, i_decoded );
 }
 
 /**
-- 
2.8.2



More information about the vlc-devel mailing list