[vlc-devel] [PATCH 05/14] codec: spudec: prepare for put pf_packetize and pf_decode into a union

Zhao Zhili quinkblack at foxmail.com
Fri Jun 8 07:42:52 CEST 2018


---
 modules/codec/spudec/spudec.c | 52 ++++++++++++++++---------------------------
 1 file changed, 19 insertions(+), 33 deletions(-)

diff --git a/modules/codec/spudec/spudec.c b/modules/codec/spudec/spudec.c
index 6be4ab9..9e757cc 100644
--- a/modules/codec/spudec/spudec.c
+++ b/modules/codec/spudec/spudec.c
@@ -69,13 +69,7 @@ static block_t *      Reassemble( decoder_t *, block_t * );
 static int            Decode    ( decoder_t *, block_t * );
 static block_t *      Packetize ( decoder_t *, block_t ** );
 
-/*****************************************************************************
- * DecoderOpen
- *****************************************************************************
- * Tries to launch a decoder and return score so that the interface is able
- * to chose.
- *****************************************************************************/
-static int DecoderOpen( vlc_object_t *p_this )
+static int OpenCommon( vlc_object_t *p_this, bool b_packetizer )
 {
     decoder_t     *p_dec = (decoder_t*)p_this;
     decoder_sys_t *p_sys;
@@ -85,43 +79,35 @@ static int DecoderOpen( vlc_object_t *p_this )
 
     p_dec->p_sys = p_sys = malloc( sizeof( decoder_sys_t ) );
 
-    p_sys->b_packetizer = false;
+    p_sys->b_packetizer = b_packetizer;
     p_sys->b_disabletrans = var_InheritBool( p_dec, "dvdsub-transparency" );
     p_sys->i_spu_size = 0;
     p_sys->i_spu      = 0;
     p_sys->p_block    = NULL;
 
-    p_dec->fmt_out.i_codec = VLC_CODEC_SPU;
-
-    p_dec->pf_decode    = Decode;
-    p_dec->pf_packetize = NULL;
+    if( b_packetizer )
+    {
+        p_dec->pf_packetize  = Packetize;
+        es_format_Copy( &p_dec->fmt_out, &p_dec->fmt_in );
+        p_dec->fmt_out.i_codec = VLC_CODEC_SPU;
+    }
+    else
+    {
+        p_dec->fmt_out.i_codec = VLC_CODEC_SPU;
+        p_dec->pf_decode    = Decode;
+    }
 
     return VLC_SUCCESS;
 }
 
-/*****************************************************************************
- * PacketizerOpen
- *****************************************************************************
- * Tries to launch a decoder and return score so that the interface is able
- * to chose.
- *****************************************************************************/
-static int PacketizerOpen( vlc_object_t *p_this )
+static int DecoderOpen( vlc_object_t *p_this )
 {
-    decoder_t *p_dec = (decoder_t*)p_this;
-
-    if( DecoderOpen( p_this ) )
-    {
-        return VLC_EGENERIC;
-    }
-
-    decoder_sys_t *p_sys = p_dec->p_sys;
-
-    p_dec->pf_packetize  = Packetize;
-    p_sys->b_packetizer = true;
-    es_format_Copy( &p_dec->fmt_out, &p_dec->fmt_in );
-    p_dec->fmt_out.i_codec = VLC_CODEC_SPU;
+    return OpenCommon( p_this, false );
+}
 
-    return VLC_SUCCESS;
+static int PacketizerOpen( vlc_object_t *p_this )
+{
+    return OpenCommon( p_this, true );
 }
 
 /*****************************************************************************
-- 
2.9.5




More information about the vlc-devel mailing list