[vlc-commits] codec: spudec: prepare to put pf_packetize and pf_decode into a union

Zhao Zhili git at videolan.org
Tue Jun 19 11:26:34 CEST 2018


vlc | branch: master | Zhao Zhili <quinkblack at foxmail.com> | Fri Jun  8 17:47:11 2018 +0800| [1c820ca4e017f08dc173dfcde02e5bf1e56c9f89] | committer: Thomas Guillem

codec: spudec: prepare to put pf_packetize and pf_decode into a union

Signed-off-by: Thomas Guillem <thomas at gllm.fr>

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

 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 6be4ab91cf..9e757cc7b6 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 );
 }
 
 /*****************************************************************************



More information about the vlc-commits mailing list