[vlc-devel] [PATCH 2/2] decoder: fix pf_decode_* and pf_packetize behavior

Thomas Guillem thomas at gllm.fr
Mon Dec 14 16:53:18 CET 2015


Audio, video, and sub decoders were not drained. Indeed, pf_decode_* functions
were called with *pp_block == NULL instead of pp_block == NULL. There was no
way to distinguish a drain from an other call from the decoder loop.

There was also an issue with the packetizer. Indeed, a successful call to
pf_packetize leaded to a drain.

We may have to fix some decoders modules to behave correctly when drained.
---
 src/input/decoder.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/src/input/decoder.c b/src/input/decoder.c
index 91f1b51..415914b 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -716,9 +716,10 @@ static void DecoderProcessSout( decoder_t *p_dec, block_t *p_block )
 {
     decoder_owner_sys_t *p_owner = p_dec->p_owner;
     block_t *p_sout_block;
+    block_t **pp_block = p_block ? &p_block : NULL;
 
     while( ( p_sout_block =
-                 p_dec->pf_packetize( p_dec, p_block ? &p_block : NULL ) ) )
+                 p_dec->pf_packetize( p_dec, pp_block ) ) )
     {
         if( p_owner->p_sout_input == NULL )
         {
@@ -962,11 +963,12 @@ static int DecoderQueueVideo( decoder_t *p_dec, picture_t *p_pic )
 static void DecoderDecodeVideo( decoder_t *p_dec, block_t *p_block )
 {
     picture_t      *p_pic;
+    block_t **pp_block = p_block ? &p_block : NULL;
     int i_lost = 0;
     int i_decoded = 0;
     int i_displayed = 0;
 
-    while( (p_pic = p_dec->pf_decode_video( p_dec, &p_block )) )
+    while( (p_pic = p_dec->pf_decode_video( p_dec, pp_block ) ) )
     {
         i_decoded++;
 
@@ -988,10 +990,11 @@ static void DecoderProcessVideo( decoder_t *p_dec, block_t *p_block )
     if( p_owner->p_packetizer )
     {
         block_t *p_packetized_block;
+        block_t **pp_block = p_block ? &p_block : NULL;
         decoder_t *p_packetizer = p_owner->p_packetizer;
 
         while( (p_packetized_block =
-                p_packetizer->pf_packetize( p_packetizer, p_block ? &p_block : NULL )) )
+                p_packetizer->pf_packetize( p_packetizer, pp_block ) ) )
         {
             if( !es_format_IsSimilar( &p_dec->fmt_in, &p_packetizer->fmt_out ) )
             {
@@ -1144,11 +1147,12 @@ static int DecoderQueueAudio( decoder_t *p_dec, block_t *p_aout_buf )
 static void DecoderDecodeAudio( decoder_t *p_dec, block_t *p_block )
 {
     block_t *p_aout_buf;
+    block_t **pp_block = p_block ? &p_block : NULL;
     int i_decoded = 0;
     int i_lost = 0;
     int i_played = 0;
 
-    while( (p_aout_buf = p_dec->pf_decode_audio( p_dec, &p_block )) )
+    while( (p_aout_buf = p_dec->pf_decode_audio( p_dec, pp_block ) ) )
     {
         i_decoded++;
 
@@ -1170,10 +1174,11 @@ static void DecoderProcessAudio( decoder_t *p_dec, block_t *p_block )
     if( p_owner->p_packetizer )
     {
         block_t *p_packetized_block;
+        block_t **pp_block = p_block ? &p_block : NULL;
         decoder_t *p_packetizer = p_owner->p_packetizer;
 
         while( (p_packetized_block =
-                p_packetizer->pf_packetize( p_packetizer, p_block ? &p_block : NULL )) )
+                p_packetizer->pf_packetize( p_packetizer, pp_block ) ) )
         {
             if( !es_format_IsSimilar( &p_dec->fmt_in, &p_packetizer->fmt_out ) )
             {
@@ -1295,8 +1300,9 @@ 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;
 
-    while( (p_spu = p_dec->pf_decode_sub( p_dec, p_block ? &p_block : NULL ) ) )
+    while( (p_spu = p_dec->pf_decode_sub( p_dec, pp_block ) ) )
         DecoderQueueSpu( p_dec, p_spu );
 }
 
-- 
2.1.4



More information about the vlc-devel mailing list