diff options
author | Nicolas Dufresne <nicolas.dufresne@collabora.com> | 2021-03-24 16:48:35 -0400 |
---|---|---|
committer | Nicolas Dufresne <nicolas.dufresne@collabora.com> | 2021-05-11 16:06:56 -0400 |
commit | f3114d4d7ed03107ac1c85c8b25bff0ee38e255e (patch) | |
tree | bdcf137ec8cde26138f90169334ca57f2b28732a | |
parent | 4eeaa8f170cf55ce8067cf78e8b737e70922ce5b (diff) | |
download | gstreamer-plugins-bad-f3114d4d7ed03107ac1c85c8b25bff0ee38e255e.tar.gz |
Introduce CODEC Alpha plugin
This plugin contains a set of utility elements allowing to extract,
decode and combine CODEC (typically VP8/VP9) alpha stream.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2199>
-rw-r--r-- | gst/codecalpha/gstcodecalphademux.c | 106 | ||||
-rw-r--r-- | gst/codecalpha/gstcodecalphademux.h | 35 | ||||
-rw-r--r-- | gst/codecalpha/gstplugin.c | 43 | ||||
-rw-r--r-- | gst/codecalpha/meson.build | 15 | ||||
-rw-r--r-- | gst/meson.build | 2 | ||||
-rw-r--r-- | meson_options.txt | 1 |
6 files changed, 201 insertions, 1 deletions
diff --git a/gst/codecalpha/gstcodecalphademux.c b/gst/codecalpha/gstcodecalphademux.c new file mode 100644 index 000000000..2d013bce8 --- /dev/null +++ b/gst/codecalpha/gstcodecalphademux.c @@ -0,0 +1,106 @@ +/* GStreamer + * Copyright (C) <2021> Collabora Ltd. + * Author: Nicolas Dufresne <nicolas.dufresne@collabora.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +/** + * SECTION:element-codecalphademux + * @title: CODEC Alpha Demuxer + * + * Extract the CODEC (typically VP8/VP9) alpha stream stored at meta and + * expose it as a stream. This element allow using single stream VP9 decoders + * in order to decode both streams. + * + * ## Example launch line + * |[ + * gst-launch-1.0 -v filesrc location=transparency.webm ! matroskademux ! + * codecalphademux name=d + * d.video ! queue ! vp9dec ! autovideosink + * d.alpha ! queue ! vp9dec ! autovideosink + * ]| This pipeline splits and decode the video and the alpha stream, showing + * the result on seperate window. + * + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <gst/video/video.h> +#include "gstcodecalphademux.h" + +GST_DEBUG_CATEGORY_STATIC (codecalphademux_debug); +#define GST_CAT_DEFAULT (codecalphademux_debug) + +struct _GstCodecAlphaDemux +{ + GstElement parent; +}; + +#define gst_codec_alpha_demux_parent_class parent_class +G_DEFINE_TYPE_WITH_CODE (GstCodecAlphaDemux, gst_codec_alpha_demux, + GST_TYPE_ELEMENT, + GST_DEBUG_CATEGORY_INIT (codecalphademux_debug, "codecalphademux", 0, + "codecalphademux")); + +GST_ELEMENT_REGISTER_DEFINE (codec_alpha_demux, "codecalphademux", + GST_RANK_NONE, GST_TYPE_CODEC_ALPHA_DEMUX); + +static GstStaticPadTemplate gst_codec_alpha_demux_sink_template = +GST_STATIC_PAD_TEMPLATE ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("ANY") + ); + +static GstStaticPadTemplate gst_codec_alpha_demux_src_template = +GST_STATIC_PAD_TEMPLATE ("src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("ANY") + ); + +static GstStaticPadTemplate gst_codec_alpha_demux_alpha_template = +GST_STATIC_PAD_TEMPLATE ("alpha", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("ANY") + ); + +static void +gst_codec_alpha_demux_class_init (GstCodecAlphaDemuxClass * klass) +{ + GstElementClass *element_class = (GstElementClass *) klass; + + gst_element_class_set_static_metadata (element_class, + "CODEC Alpha Demuxer", "Codec/Demuxer", + "Extract and expose as a stream the CODEC alpha.", + "Nicolas Dufresne <nicolas.dufresne@collabora.com>"); + + gst_element_class_add_static_pad_template (element_class, + &gst_codec_alpha_demux_sink_template); + gst_element_class_add_static_pad_template (element_class, + &gst_codec_alpha_demux_src_template); + gst_element_class_add_static_pad_template (element_class, + &gst_codec_alpha_demux_alpha_template); +} + +static void +gst_codec_alpha_demux_init (GstCodecAlphaDemux * demux) +{ +} diff --git a/gst/codecalpha/gstcodecalphademux.h b/gst/codecalpha/gstcodecalphademux.h new file mode 100644 index 000000000..3bb252300 --- /dev/null +++ b/gst/codecalpha/gstcodecalphademux.h @@ -0,0 +1,35 @@ +/* GStreamer + * Copyright (C) <2021> Collabora Ltd. + * Author: Nicolas Dufresne <nicolas.dufresne@collabora.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __GST_CODEC_ALPHA_DEMUX_H__ +#define __GST_CODEC_ALPHA_DEMUX_H__ + +#include <gst/gst.h> + +G_BEGIN_DECLS + +#define GST_TYPE_CODEC_ALPHA_DEMUX (gst_codec_alpha_demux_get_type()) +G_DECLARE_FINAL_TYPE (GstCodecAlphaDemux, + gst_codec_alpha_demux, GST, CODEC_ALPHA_DEMUX, GstElement); + +GST_ELEMENT_REGISTER_DECLARE (codec_alpha_demux); + +G_END_DECLS +#endif diff --git a/gst/codecalpha/gstplugin.c b/gst/codecalpha/gstplugin.c new file mode 100644 index 000000000..3a92c6a8c --- /dev/null +++ b/gst/codecalpha/gstplugin.c @@ -0,0 +1,43 @@ +/* GStreamer + * Copyright (C) <2021> Collabora Ltd. + * Author: Nicolas Dufresne <nicolas.dufresne@collabora.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include <gst/gst.h> + +#include "gstcodecalphademux.h" + +static gboolean +plugin_init (GstPlugin * plugin) +{ + gboolean ret = FALSE; + + ret |= GST_ELEMENT_REGISTER (codec_alpha_demux, plugin); + + return ret; +} + +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + codecalpha, + "CODEC Alpha Utilities", + plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN) diff --git a/gst/codecalpha/meson.build b/gst/codecalpha/meson.build new file mode 100644 index 000000000..1c9d3b34e --- /dev/null +++ b/gst/codecalpha/meson.build @@ -0,0 +1,15 @@ +codecalpha_sources = [ + 'gstplugin.c', + 'gstcodecalphademux.c', +] + +gstcodecalpha = library('gstcodecalpha', + codecalpha_sources, + c_args : gst_plugins_bad_args, + include_directories : [configinc], + dependencies : [gstvideo_dep], + install : true, + install_dir : plugins_install_dir, +) +pkgconfig.generate(gstcodecalpha, install_dir : plugins_pkgconfig_install_dir) +plugins += [gstcodecalpha] diff --git a/gst/meson.build b/gst/meson.build index 201e7890e..9cf62db98 100644 --- a/gst/meson.build +++ b/gst/meson.build @@ -1,7 +1,7 @@ foreach plugin : ['accurip', 'adpcmdec', 'adpcmenc', 'aiff', 'asfmux', 'audiobuffersplit', 'audiofxbad', 'audiomixmatrix', 'audiolatency', 'audiovisualizers', 'autoconvert', 'bayer', - 'camerabin2', 'coloreffects', 'debugutils', 'dvbsubenc', + 'camerabin2', 'codecalpha', 'coloreffects', 'debugutils', 'dvbsubenc', 'dvbsuboverlay', 'dvdspu', 'faceoverlay', 'festival', 'fieldanalysis', 'freeverb', 'frei0r', 'gaudieffects', 'gdp', 'geometrictransform', 'id3tag', 'inter', 'interlace', diff --git a/meson_options.txt b/meson_options.txt index e2f13e77e..81eabbc8a 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -15,6 +15,7 @@ option('audiovisualizers', type : 'feature', value : 'auto') option('autoconvert', type : 'feature', value : 'auto') option('bayer', type : 'feature', value : 'auto') option('camerabin2', type : 'feature', value : 'auto') +option('codecalpha', type : 'feature', value : 'auto') option('coloreffects', type : 'feature', value : 'auto') option('debugutils', type : 'feature', value : 'auto') option('dvbsubenc', type : 'feature', value : 'auto') |