[vlc-commits] decoder: add helper Init function for decoder owners

Steve Lhomme git at videolan.org
Mon Feb 18 16:11:18 CET 2019


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon Feb 18 14:33:57 2019 +0100| [2502d87e2714054a15bfca811d87eea0bf2133b3] | committer: Steve Lhomme

decoder: add helper Init function for decoder owners

The same code is done by all owners before creating a decoder.

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

 include/vlc_codec.h         |  8 ++++++++
 src/Makefile.am             |  1 +
 src/input/decoder_helpers.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
 src/libvlccore.sym          |  1 +
 4 files changed, 55 insertions(+)

diff --git a/include/vlc_codec.h b/include/vlc_codec.h
index 750b49c477..c287953ba7 100644
--- a/include/vlc_codec.h
+++ b/include/vlc_codec.h
@@ -312,6 +312,14 @@ static inline picture_t *decoder_NewPicture( decoder_t *dec )
 VLC_API void decoder_AbortPictures( decoder_t *dec, bool b_abort );
 
 /**
+ * Initialize a decoder structure before creating the decoder.
+ *
+ * To be used by decoder owners.
+ * By default frame drop is not allowed.
+ */
+VLC_API void decoder_Init( decoder_t *dec, const es_format_t * );
+
+/**
  * This function queues a single picture to the video output.
  *
  * \note
diff --git a/src/Makefile.am b/src/Makefile.am
index 0b07a8cb76..5f90229486 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -264,6 +264,7 @@ libvlccore_la_SOURCES = \
 	clock/input_clock.c \
 	input/control.c \
 	input/decoder.c \
+	input/decoder_helpers.c \
 	input/demux.c \
 	input/demux_chained.c \
 	input/es_out.c \
diff --git a/src/input/decoder_helpers.c b/src/input/decoder_helpers.c
new file mode 100644
index 0000000000..51f7ce8f6d
--- /dev/null
+++ b/src/input/decoder_helpers.c
@@ -0,0 +1,45 @@
+/*****************************************************************************
+ * decoder_helpers.c: Functions for the management of decoders
+ *****************************************************************************
+ * Copyright (C) 1999-2019 VLC authors and VideoLAN
+ *
+ * Authors: Christophe Massiot <massiot at via.ecp.fr>
+ *          Gildas Bazin <gbazin at videolan.org>
+ *          Laurent Aimar <fenrir at via.ecp.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_codec.h>
+
+void decoder_Init( decoder_t *p_dec, const es_format_t *restrict p_fmt )
+{
+    p_dec->i_extra_picture_buffers = 0;
+    p_dec->b_frame_drop_allowed = false;
+
+    p_dec->pf_decode = NULL;
+    p_dec->pf_get_cc = NULL;
+    p_dec->pf_packetize = NULL;
+    p_dec->pf_flush = NULL;
+    p_dec->p_module = NULL;
+
+    es_format_Copy( &p_dec->fmt_in, p_fmt );
+    es_format_Init( &p_dec->fmt_out, p_fmt->i_cat, 0 );
+}
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index f91040df68..09b5936180 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -73,6 +73,7 @@ date_Change
 date_Decrement
 date_Increment
 date_Init
+decoder_Init
 decoder_AbortPictures
 decoder_NewAudioBuffer
 demux_PacketizerDestroy



More information about the vlc-commits mailing list