[vlc-commits] codec: cvdsub: prepare to put pf_packetize and pf_decode into a union
Zhao Zhili
git at videolan.org
Tue Jun 19 11:26:33 CEST 2018
vlc | branch: master | Zhao Zhili <quinkblack at foxmail.com> | Fri Jun 8 17:47:10 2018 +0800| [f0db636b033df4820604f355d4aad96760c003d2] | committer: Thomas Guillem
codec: cvdsub: 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=f0db636b033df4820604f355d4aad96760c003d2
---
modules/codec/cvdsub.c | 39 ++++++++++++++++++++-------------------
1 file changed, 20 insertions(+), 19 deletions(-)
diff --git a/modules/codec/cvdsub.c b/modules/codec/cvdsub.c
index d24a599c1f..aefca5cc12 100644
--- a/modules/codec/cvdsub.c
+++ b/modules/codec/cvdsub.c
@@ -102,10 +102,7 @@ typedef struct
uint8_t p_palette_highlight[4][4];
} decoder_sys_t;
-/*****************************************************************************
- * DecoderOpen: open/initialize the cvdsub decoder.
- *****************************************************************************/
-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;
@@ -117,34 +114,38 @@ static int DecoderOpen( vlc_object_t *p_this )
if( !p_sys )
return VLC_ENOMEM;
- p_sys->b_packetizer = false;
+ p_sys->b_packetizer = b_packetizer;
p_sys->i_state = SUBTITLE_BLOCK_EMPTY;
p_sys->p_spu = NULL;
- p_dec->pf_decode = Decode;
- p_dec->pf_packetize = Packetize;
-
- p_dec->fmt_out.i_codec = VLC_CODEC_YUVP;
+ if( b_packetizer )
+ {
+ p_dec->pf_packetize = Packetize;
+ p_dec->fmt_out.i_codec = VLC_CODEC_CVD;
+ }
+ else
+ {
+ p_dec->pf_decode = Decode;
+ p_dec->fmt_out.i_codec = VLC_CODEC_YUVP;
+ }
return VLC_SUCCESS;
}
+/*****************************************************************************
+ * DecoderOpen: open/initialize the cvdsub decoder.
+ *****************************************************************************/
+static int DecoderOpen( vlc_object_t *p_this )
+{
+ return OpenCommon( p_this, false );
+}
/*****************************************************************************
* PacketizerOpen: open/initialize the cvdsub packetizer.
*****************************************************************************/
static int PacketizerOpen( vlc_object_t *p_this )
{
- decoder_t *p_dec = (decoder_t*)p_this;
-
- if( DecoderOpen( p_this ) != VLC_SUCCESS ) return VLC_EGENERIC;
-
- decoder_sys_t *p_sys = p_dec->p_sys;
-
- p_dec->fmt_out.i_codec = VLC_CODEC_CVD;
- p_sys->b_packetizer = true;
-
- return VLC_SUCCESS;
+ return OpenCommon( p_this, true );
}
/*****************************************************************************
More information about the vlc-commits
mailing list