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

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


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

codec: daala: 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=a585cb1af0794aabb5e7b5c9c30ccf1ba86b70eb
---

 modules/codec/daala.c | 43 +++++++++++++++++++++----------------------
 1 file changed, 21 insertions(+), 22 deletions(-)

diff --git a/modules/codec/daala.c b/modules/codec/daala.c
index ea90132198..e3f1afc2c4 100644
--- a/modules/codec/daala.c
+++ b/modules/codec/daala.c
@@ -154,10 +154,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;
@@ -173,18 +170,22 @@ static int OpenDecoder( vlc_object_t *p_this )
         return VLC_ENOMEM;
 
     p_dec->p_sys = p_sys;
-    p_dec->p_sys->b_packetizer = false;
+    p_dec->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->dcx = 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;
+    if( b_packetizer )
+    {
+        p_dec->fmt_out.i_codec = VLC_CODEC_DAALA;
+        p_dec->pf_packetize = Packetize;
+    }
+    else
+    {
+        p_dec->fmt_out.i_codec = VLC_CODEC_I420;
+        p_dec->pf_decode = DecodeVideo;
+    }
 
     /* Init supporting Daala structures needed in header parsing */
     daala_comment_init( &p_sys->dc );
@@ -193,19 +194,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;
-
-    int i_ret = OpenDecoder( p_this );
-
-    if( i_ret == VLC_SUCCESS )
-    {
-        p_dec->p_sys->b_packetizer = true;
-        p_dec->fmt_out.i_codec = VLC_CODEC_DAALA;
-    }
+    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