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

Rémi Denis-Courmont remi at remlab.net
Fri Jun 8 10:59:52 CEST 2018


Maybe keep the not common code in not common functions? Otherwise LGTM

Le 8 juin 2018 08:42:49 GMT+03:00, Zhao Zhili <quinkblack at foxmail.com> a écrit :
>---
> modules/codec/vorbis.c | 42 +++++++++++++++++++-----------------------
> 1 file changed, 19 insertions(+), 23 deletions(-)
>
>diff --git a/modules/codec/vorbis.c b/modules/codec/vorbis.c
>index a1577d6..7939005 100644
>--- a/modules/codec/vorbis.c
>+++ b/modules/codec/vorbis.c
>@@ -227,10 +227,7 @@ static const char *const ppsz_enc_options[] = {
> };
> #endif
> 
>-/*****************************************************************************
>- * 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;
>@@ -246,42 +243,41 @@ static int OpenDecoder( vlc_object_t *p_this )
>     /* Misc init */
>     date_Set( &p_sys->end_date, VLC_TS_INVALID );
>     p_sys->i_last_block_size = 0;
>-    p_sys->b_packetizer = false;
>+    p_sys->b_packetizer = b_packetizer;
>     p_sys->b_has_headers = false;
> 
>     /* Take care of vorbis init */
>     vorbis_info_init( &p_sys->vi );
>     vorbis_comment_init( &p_sys->vc );
> 
>-    /* Set output properties */
>+    if( b_packetizer )
>+    {
>+        p_dec->fmt_out.i_codec = VLC_CODEC_VORBIS;
>+        p_dec->pf_packetize  = Packetize;
>+    }
>+    else
>+    {
> #ifdef MODULE_NAME_IS_tremor
>-    p_dec->fmt_out.i_codec = VLC_CODEC_S32N;
>+        p_dec->fmt_out.i_codec = VLC_CODEC_S32N;
> #else
>-    p_dec->fmt_out.i_codec = VLC_CODEC_FL32;
>+        p_dec->fmt_out.i_codec = VLC_CODEC_FL32;
> #endif
>+        p_dec->pf_decode     = DecodeAudio;
>+    }
> 
>-    /* Set callbacks */
>-    p_dec->pf_decode     = DecodeAudio;
>-    p_dec->pf_packetize  = Packetize;
>     p_dec->pf_flush      = Flush;
> 
>     return VLC_SUCCESS;
> }
> 
>-static int OpenPacketizer( vlc_object_t *p_this )
>+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_VORBIS;
>-    }
>+    return OpenCommon( p_this, false );
>+}
> 
>-    return i_ret;
>+static int OpenPacketizer( vlc_object_t *p_this )
>+{
>+    return OpenCommon( p_this, true );
> }
> 
>/****************************************************************************
>-- 
>2.9.5
>
>
>
>_______________________________________________
>vlc-devel mailing list
>To unsubscribe or modify your subscription options:
>https://mailman.videolan.org/listinfo/vlc-devel

-- 
Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20180608/8d1fd6cb/attachment.html>


More information about the vlc-devel mailing list