• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GStreamer
2  * Copyright (C) <2021> Collabora Ltd.
3  *   Author: Nicolas Dufresne <nicolas.dufresne@collabora.com>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20 
21 /**
22  * SECTION:plugin-codecalpha
23  *
24  * This plugin contains a set of utilities that helps handling alpha encoded
25  * streams as produced by some WebM streams using VP8/VP9. The elements are
26  * meant to be used in decoder wrappers which allows playbin to automatically
27  * handle these streams.
28  *
29  * `codecalphademux` will produce two streams out of a stream of buffers holding
30  * the #GstVideoCodecAlphaMeta. The presence of the meta is indicated by the
31  * usage of the field `codec-alpha=(boolean)true` in the caps. This is only
32  * applicable to VP8 and VP9 for now.
33  *
34  * Wrappers for vp8dec and vp9dec are available, allowing seamless support for
35  * these streams inside playbin (which is used by WebKit GTK and WPE).
36  *
37  * Since: 1.20
38  */
39 
40 #ifdef HAVE_CONFIG_H
41 #  include <config.h>
42 #endif
43 
44 #include <gst/gst.h>
45 
46 #include "gstcodecalphademux.h"
47 #include "gstalphacombine.h"
48 #include "gstvp8alphadecodebin.h"
49 #include "gstvp9alphadecodebin.h"
50 
51 /* When wrapping, use the original rank plus this offset. The ad-hoc rules is
52  * that hardware implementation will use PRIMARY+1 or +2 to override the
53  * software decoder, so the offset must be large enough to jump over those.
54  * This should also be small enough so that a marginal (64) or secondary
55  * wrapper does not cross the PRIMARY line.
56  */
57 #define RANK_OFFSET 10
58 
59 static gboolean
plugin_init(GstPlugin * plugin)60 plugin_init (GstPlugin * plugin)
61 {
62   gboolean ret = FALSE;
63 
64   ret |= GST_ELEMENT_REGISTER (codec_alpha_demux, plugin);
65   ret |= GST_ELEMENT_REGISTER (alpha_combine, plugin);
66   ret |= GST_ELEMENT_REGISTER (vp8_alpha_decode_bin, plugin);
67   ret |= GST_ELEMENT_REGISTER (vp9_alpha_decode_bin, plugin);
68 
69   return ret;
70 }
71 
72 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
73     GST_VERSION_MINOR,
74     codecalpha,
75     "CODEC Alpha Utilities",
76     plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
77