1 /* GStreamer Intel MSDK plugin
2 * Copyright (c) 2017, Intel Corporation
3 * Copyright (c) 2017, Igalia S.L.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
9 * 1. Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright notice,
13 * this list of conditions and the following disclaimer in the documentation
14 * and/or other materials provided with the distribution.
16 * 3. Neither the name of the copyright holder nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGDECE
29 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 * SECTION:element-msdkvp8dec
36 * @short_description: Intel MSDK VP8 decoder
38 * VP8 video decoder based on Intel MFX
40 * ## Example launch line
42 * gst-launch-1.0 filesrc location=sample.webm ! matroskademux ! msdkvp8dec ! glimagesink
53 #include "gstmsdkvp8dec.h"
57 GST_DEBUG_CATEGORY_EXTERN (gst_msdkvp8dec_debug);
58 #define GST_CAT_DEFAULT gst_msdkvp8dec_debug
60 static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
63 GST_STATIC_CAPS ("video/x-vp8")
66 #define gst_msdkvp8dec_parent_class parent_class
67 G_DEFINE_TYPE (GstMsdkVP8Dec, gst_msdkvp8dec, GST_TYPE_MSDKDEC);
70 gst_msdkvp8dec_configure (GstMsdkDec * decoder)
72 GstMsdkVP8Dec *vp8dec = GST_MSDKVP8DEC (decoder);
74 const mfxPluginUID *uid;
76 session = gst_msdk_context_get_session (decoder->context);
78 uid = &MFX_PLUGINID_VP8D_HW;
80 if (!gst_msdk_load_plugin (session, uid, 1, "msdkvp8dec"))
83 decoder->param.mfx.CodecId = MFX_CODEC_VP8;
84 /* Replaced with width and height rounded up to 16 */
85 decoder->param.mfx.FrameInfo.Width =
86 GST_ROUND_UP_16 (decoder->param.mfx.FrameInfo.CropW);
87 decoder->param.mfx.FrameInfo.Height =
88 GST_ROUND_UP_16 (decoder->param.mfx.FrameInfo.CropH);
90 /* This is a deprecated attribute in msdk-2017 version, but some
91 * customers still using this for low-latency streaming of non-b-frame
93 decoder->param.mfx.DecodedOrder = vp8dec->output_order;
98 gst_msdkdec_vp8_set_property (GObject * object, guint prop_id,
99 const GValue * value, GParamSpec * pspec)
101 GstMsdkVP8Dec *thiz = GST_MSDKVP8DEC (object);
104 GST_OBJECT_LOCK (thiz);
105 state = GST_STATE (thiz);
107 if (!gst_msdkdec_prop_check_state (state, pspec)) {
108 GST_WARNING_OBJECT (thiz, "setting property in wrong state");
109 GST_OBJECT_UNLOCK (thiz);
113 case GST_MSDKDEC_PROP_OUTPUT_ORDER:
114 thiz->output_order = g_value_get_enum (value);
117 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
120 GST_OBJECT_UNLOCK (thiz);
125 gst_msdkdec_vp8_get_property (GObject * object, guint prop_id, GValue * value,
128 GstMsdkVP8Dec *thiz = GST_MSDKVP8DEC (object);
130 GST_OBJECT_LOCK (thiz);
132 case GST_MSDKDEC_PROP_OUTPUT_ORDER:
133 g_value_set_enum (value, thiz->output_order);
136 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
139 GST_OBJECT_UNLOCK (thiz);
143 gst_msdkvp8dec_preinit_decoder (GstMsdkDec * decoder)
145 decoder->param.mfx.FrameInfo.Width =
146 GST_ROUND_UP_16 (decoder->param.mfx.FrameInfo.Width);
147 decoder->param.mfx.FrameInfo.Height =
148 GST_ROUND_UP_16 (decoder->param.mfx.FrameInfo.Height);
150 decoder->param.mfx.FrameInfo.PicStruct =
151 decoder->param.mfx.FrameInfo.PicStruct ? decoder->param.mfx.
152 FrameInfo.PicStruct : MFX_PICSTRUCT_PROGRESSIVE;
158 gst_msdkvp8dec_postinit_decoder (GstMsdkDec * decoder)
160 /* Force the structure to MFX_PICSTRUCT_PROGRESSIVE if it is unknow to
161 * work-around MSDK issue:
162 * https://github.com/Intel-Media-SDK/MediaSDK/issues/1139
164 if (decoder->param.mfx.FrameInfo.PicStruct == MFX_PICSTRUCT_UNKNOWN)
165 decoder->param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_PROGRESSIVE;
171 gst_msdkvp8dec_class_init (GstMsdkVP8DecClass * klass)
173 GObjectClass *gobject_class;
174 GstElementClass *element_class;
175 GstMsdkDecClass *decoder_class;
177 gobject_class = G_OBJECT_CLASS (klass);
178 element_class = GST_ELEMENT_CLASS (klass);
179 decoder_class = GST_MSDKDEC_CLASS (klass);
181 gobject_class->set_property = gst_msdkdec_vp8_set_property;
182 gobject_class->get_property = gst_msdkdec_vp8_get_property;
184 decoder_class->configure = GST_DEBUG_FUNCPTR (gst_msdkvp8dec_configure);
185 decoder_class->preinit_decoder =
186 GST_DEBUG_FUNCPTR (gst_msdkvp8dec_preinit_decoder);
187 decoder_class->postinit_decoder =
188 GST_DEBUG_FUNCPTR (gst_msdkvp8dec_postinit_decoder);
190 gst_element_class_set_static_metadata (element_class,
191 "Intel MSDK VP8 decoder",
192 "Codec/Decoder/Video/Hardware",
193 "VP8 video decoder based on " MFX_API_SDK,
194 "Hyunjun Ko <zzoon@igalia.com>");
196 gst_msdkdec_prop_install_output_oder_property (gobject_class);
198 gst_element_class_add_static_pad_template (element_class, &sink_factory);
202 gst_msdkvp8dec_init (GstMsdkVP8Dec * thiz)
204 thiz->output_order = PROP_OUTPUT_ORDER_DEFAULT;