[vlc-commits] codec: theora: prepare to put pf_packetize and pf_decode into a union
Zhao Zhili
git at videolan.org
Tue Jun 19 11:26:40 CEST 2018
vlc | branch: master | Zhao Zhili <quinkblack at foxmail.com> | Fri Jun 8 17:47:16 2018 +0800| [72845f74008fcddad118b851e70b71053dd11aa7] | committer: Thomas Guillem
codec: theora: 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=72845f74008fcddad118b851e70b71053dd11aa7
---
modules/codec/theora.c | 46 ++++++++++++++++++++++------------------------
1 file changed, 22 insertions(+), 24 deletions(-)
diff --git a/modules/codec/theora.c b/modules/codec/theora.c
index 595a200e8f..c826f20093 100644
--- a/modules/codec/theora.c
+++ b/modules/codec/theora.c
@@ -143,10 +143,7 @@ static const char *const ppsz_enc_options[] = {
"quality", NULL
};
-/*****************************************************************************
- * OpenDecoder: probe the decoder and return score
- *****************************************************************************/
-static int OpenDecoder( 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;
@@ -159,19 +156,23 @@ static int OpenDecoder( vlc_object_t *p_this )
/* Allocate the memory needed to store the decoder's structure */
if( ( p_dec->p_sys = p_sys = malloc(sizeof(*p_sys)) ) == NULL )
return VLC_ENOMEM;
- p_sys->b_packetizer = false;
+ p_sys->b_packetizer = b_packetizer;
p_sys->b_has_headers = false;
p_sys->i_pts = VLC_TS_INVALID;
p_sys->b_decoded_first_keyframe = false;
p_sys->tcx = NULL;
- /* Set output properties */
- p_dec->fmt_out.i_codec = VLC_CODEC_I420;
-
- /* Set callbacks */
- p_dec->pf_decode = DecodeVideo;
- p_dec->pf_packetize = Packetize;
- p_dec->pf_flush = Flush;
+ if( b_packetizer )
+ {
+ p_dec->fmt_out.i_codec = VLC_CODEC_THEORA;
+ p_dec->pf_packetize = Packetize;
+ }
+ else
+ {
+ p_dec->fmt_out.i_codec = VLC_CODEC_I420;
+ p_dec->pf_decode = DecodeVideo;
+ }
+ p_dec->pf_flush = Flush;
/* Init supporting Theora structures needed in header parsing */
th_comment_init( &p_sys->tc );
@@ -180,20 +181,17 @@ static int OpenDecoder( vlc_object_t *p_this )
return VLC_SUCCESS;
}
-static int OpenPacketizer( vlc_object_t *p_this )
+/*****************************************************************************
+ * OpenDecoder: probe the decoder and return score
+ *****************************************************************************/
+static int OpenDecoder( vlc_object_t *p_this )
{
- decoder_t *p_dec = (decoder_t*)p_this;
- decoder_sys_t *p_sys = p_dec->p_sys;
-
- int i_ret = OpenDecoder( p_this );
-
- if( i_ret == VLC_SUCCESS )
- {
- p_sys->b_packetizer = true;
- p_dec->fmt_out.i_codec = VLC_CODEC_THEORA;
- }
+ return OpenCommon( p_this, false );
+}
- return i_ret;
+static int OpenPacketizer( vlc_object_t *p_this )
+{
+ return OpenCommon( p_this, true );
}
/****************************************************************************
More information about the vlc-commits
mailing list