[vlc-commits] input decoder: clean-up of DecoderProcess

Filip Roséen git at videolan.org
Wed May 25 00:02:55 CEST 2016


vlc | branch: master | Filip Roséen <filip at videolabs.io> | Mon May 23 15:57:53 2016 +0200| [4e82ba21f4c49d90d21ba5f910318abf1ab36183] | committer: Jean-Baptiste Kempf

input decoder: clean-up of DecoderProcess

The functionality remains the same, though the code should be easier to
follow and maintain.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4e82ba21f4c49d90d21ba5f910318abf1ab36183
---

 src/input/decoder.c |   46 ++++++++++++++++------------------------------
 1 file changed, 16 insertions(+), 30 deletions(-)

diff --git a/src/input/decoder.c b/src/input/decoder.c
index 66bbfc8..bd966c1 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -1315,20 +1315,13 @@ static void DecoderProcess( decoder_t *p_dec, block_t *p_block )
     decoder_owner_sys_t *p_owner = p_dec->p_owner;
 
     if( p_dec->b_error )
-    {
-        if( p_block )
-            block_Release( p_block );
-        return;
-    }
-
-    if( p_block && p_block->i_buffer <= 0 )
-    {
-        block_Release( p_block );
-        return;
-    }
+        goto error;
 
     if( p_block )
     {
+        if( p_block->i_buffer <= 0 )
+            goto error;
+
         vlc_mutex_lock( &p_owner->lock );
         DecoderUpdatePreroll( &p_owner->i_preroll_end, p_block );
         vlc_mutex_unlock( &p_owner->lock );
@@ -1336,30 +1329,23 @@ static void DecoderProcess( decoder_t *p_dec, block_t *p_block )
 
 #ifdef ENABLE_SOUT
     if( p_owner->p_sout != NULL )
-    {
-        DecoderProcessSout( p_dec, p_block );
-    }
-    else
+        return DecoderProcessSout( p_dec, p_block );
 #endif
+
+    switch( p_dec->fmt_out.i_cat )
     {
-        if( p_dec->fmt_out.i_cat == AUDIO_ES )
-        {
-            DecoderProcessAudio( p_dec, p_block );
-        }
-        else if( p_dec->fmt_out.i_cat == VIDEO_ES )
-        {
-            DecoderProcessVideo( p_dec, p_block );
-        }
-        else if( p_dec->fmt_out.i_cat == SPU_ES )
-        {
-            DecoderProcessSpu( p_dec, p_block );
-        }
-        else
-        {
+        case VIDEO_ES: return DecoderProcessVideo( p_dec, p_block );
+        case AUDIO_ES: return DecoderProcessAudio( p_dec, p_block );
+        case   SPU_ES: return DecoderProcessSpu( p_dec, p_block );
+
+        default:
             msg_Err( p_dec, "unknown ES format" );
             p_dec->b_error = true;
-        }
     }
+
+error:
+    if( p_block )
+        block_Release( p_block );
 }
 
 static void DecoderProcessFlush( decoder_t *p_dec )



More information about the vlc-commits mailing list