xref: /OK3568_Linux_fs/external/gstreamer-rockchip/gst/rockchipmpp/gstmppvpxalphadecodebin.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /* GStreamer
2  * Copyright (C) <2021> Collabora Ltd.
3  *   Author: Nicolas Dufresne <nicolas.dufresne@collabora.com>
4  *   Author: Julian Bouzas <julian.bouzas@collabora.com>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21 
22 /**
23  * SECTION:element-mppvpxalphadecodebin
24  * @title: Wrapper to decode MPP VP8/VP9 alpha using mppvideodec
25  *
26  * Use two `mppvideodec` instance in order to decode VP8/VP9 alpha channel.
27  *
28  * Since: 1.20
29  */
30 
31 #ifdef HAVE_CONFIG_H
32 #include "config.h"
33 #endif
34 
35 #include "gstmppvpxalphadecodebin.h"
36 
37 static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
38     GST_PAD_SINK,
39     GST_PAD_ALWAYS,
40     GST_STATIC_CAPS ("video/x-vp8, codec-alpha = (boolean) true; "
41         "video/x-vp9, codec-alpha = (boolean) true"));
42 
43 struct _GstMppVpxAlphaDecodeBin
44 {
45   GstMppAlphaDecodeBin parent;
46 };
47 
48 #define gst_mpp_vpx_alpha_decode_bin_parent_class parent_class
49 G_DEFINE_TYPE (GstMppVpxAlphaDecodeBin, gst_mpp_vpx_alpha_decode_bin,
50     GST_TYPE_MPP_ALPHA_DECODE_BIN);
51 
52 static void
gst_mpp_vpx_alpha_decode_bin_class_init(GstMppVpxAlphaDecodeBinClass * klass)53 gst_mpp_vpx_alpha_decode_bin_class_init (GstMppVpxAlphaDecodeBinClass * klass)
54 {
55   GstMppAlphaDecodeBinClass *adbin_class = (GstMppAlphaDecodeBinClass *) klass;
56   GstElementClass *element_class = (GstElementClass *) klass;
57 
58   adbin_class->decoder_name = "mppvideodec";
59   gst_element_class_add_static_pad_template (element_class, &sink_template);
60 
61   gst_element_class_set_static_metadata (element_class,
62       "VP8/VP9 Alpha Decoder", "Codec/Decoder/Video",
63       "Wrapper bin to decode VP8/VP9 with alpha stream.",
64       "Julian Bouzas <julian.bouzas@collabora.com>");
65 }
66 
67 static void
gst_mpp_vpx_alpha_decode_bin_init(GstMppVpxAlphaDecodeBin * self)68 gst_mpp_vpx_alpha_decode_bin_init (GstMppVpxAlphaDecodeBin * self)
69 {
70   (void) self;
71 }
72 
73 gboolean
gst_mpp_vpx_alpha_decode_bin_register(GstPlugin * plugin,guint rank)74 gst_mpp_vpx_alpha_decode_bin_register (GstPlugin * plugin, guint rank)
75 {
76   return gst_element_register (plugin, "mppvpxalphadecodebin", rank,
77       gst_mpp_vpx_alpha_decode_bin_get_type ());
78 }
79