[vlc-commits] codec: add S/PDIF pass-through decoder
Thomas Guillem
git at videolan.org
Thu Jul 28 09:04:36 CEST 2016
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Jul 26 09:01:28 2016 +0200| [8c2aa3bb711a7a92d8e094be0905e6f304d9f881] | committer: Thomas Guillem
codec: add S/PDIF pass-through decoder
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8c2aa3bb711a7a92d8e094be0905e6f304d9f881
---
modules/MODULES_LIST | 1 +
modules/codec/Makefile.am | 2 +
modules/codec/spdif.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++
po/POTFILES.in | 1 +
4 files changed, 103 insertions(+)
diff --git a/modules/MODULES_LIST b/modules/MODULES_LIST
index 3fd8103..d3579c1 100644
--- a/modules/MODULES_LIST
+++ b/modules/MODULES_LIST
@@ -353,6 +353,7 @@ $Id$
* sndio: OpenBSD sndio audio output
* soxr: SoX Resampler library audio filter
* spatializer: A spatializer audio filter
+ * spdif: S/PDIF audio pass-through decoder
* speex: a speex audio decoder/packetizer using the libspeex library
* speex_resampler: audio resampler using the libspeexdsp library
* spudec: RLE DVD subtitles decoder
diff --git a/modules/codec/Makefile.am b/modules/codec/Makefile.am
index a77476c..6703091 100644
--- a/modules/codec/Makefile.am
+++ b/modules/codec/Makefile.am
@@ -13,6 +13,8 @@ endif
### Audio codecs ###
+libspdif_plugin_la_SOURCES = codec/spdif.c
+codec_LTLIBRARIES += libspdif_plugin.la
liba52_plugin_la_SOURCES = codec/a52.c codec/a52.h
codec_LTLIBRARIES += liba52_plugin.la
diff --git a/modules/codec/spdif.c b/modules/codec/spdif.c
new file mode 100644
index 0000000..bbd0e4d
--- /dev/null
+++ b/modules/codec/spdif.c
@@ -0,0 +1,99 @@
+/*****************************************************************************
+ * spdif.c: S/PDIF pass-though decoder
+ *****************************************************************************
+ * Copyright (C) 2016 VLC authors and VideoLAN
+ *
+ * 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_plugin.h>
+#include <vlc_aout.h>
+#include <vlc_codec.h>
+#include <vlc_modules.h>
+
+static int OpenDecoder(vlc_object_t *);
+
+vlc_module_begin()
+ set_category(CAT_INPUT)
+ set_subcategory(SUBCAT_INPUT_ACODEC)
+ set_description(N_("S/PDIF pass-through decoder"))
+ set_capability("decoder", 120)
+ set_callbacks(OpenDecoder, NULL)
+vlc_module_end()
+
+static block_t *
+DecodeBlock(decoder_t *p_dec, block_t **pp_block)
+{
+ (void) p_dec;
+ if (pp_block != NULL)
+ {
+ block_t *p_block = *pp_block;
+ *pp_block = NULL;
+ return p_block;
+ }
+ else
+ return NULL;
+}
+
+static int
+OpenDecoder(vlc_object_t *p_this)
+{
+ decoder_t *p_dec = (decoder_t*)p_this;
+
+ switch (p_dec->fmt_in.i_codec)
+ {
+ case VLC_CODEC_MPGA:
+ case VLC_CODEC_MP3:
+ /* Disabled by default */
+ if (!p_dec->obj.force)
+ return VLC_EGENERIC;
+ break;
+ case VLC_CODEC_A52:
+ case VLC_CODEC_EAC3:
+ case VLC_CODEC_DTS:
+ case VLC_CODEC_SPDIFL:
+ case VLC_CODEC_SPDIFB:
+ /* Enabled by default */
+ break;
+ default:
+ return VLC_EGENERIC;
+ }
+
+ /* Set output properties */
+ p_dec->fmt_out.i_cat = AUDIO_ES;
+ p_dec->fmt_out.i_codec = p_dec->fmt_in.i_codec;
+ p_dec->fmt_out.audio = p_dec->fmt_in.audio;
+ p_dec->fmt_out.audio.i_format = p_dec->fmt_out.i_codec;
+
+ if (p_dec->fmt_out.audio.i_physical_channels == 0
+ || p_dec->fmt_out.audio.i_original_channels == 0
+ || p_dec->fmt_out.audio.i_bytes_per_frame == 0
+ || p_dec->fmt_out.audio.i_frame_length == 0
+ || decoder_UpdateAudioFormat(p_dec))
+ {
+ es_format_Init(&p_dec->fmt_out, UNKNOWN_ES, 0);
+ return VLC_EGENERIC;
+ }
+
+ p_dec->pf_decode_audio = DecodeBlock;
+ p_dec->pf_flush = NULL;
+
+ return VLC_SUCCESS;
+}
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 95e8915..6d5801c 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -395,6 +395,7 @@ modules/codec/scte18.c
modules/codec/scte18.h
modules/codec/sdl_image.c
modules/codec/shine.c
+modules/codec/spdif.c
modules/codec/speex.c
modules/codec/spudec/parse.c
modules/codec/spudec/spudec.c
More information about the vlc-commits
mailing list