1 /* GStreamer Intel MSDK plugin
2 * Copyright (c) 2016, Intel Corporation
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
15 * 3. Neither the name of the copyright holder nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGDECE
28 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 * SECTION: element-msdkh264dec
35 * @short_description: Intel MSDK H264 decoder
37 * H264 video decoder based on Intel MFX
39 * ## Example launch line
41 * gst-launch-1.0 filesrc location=sample.h264 ! h264parse ! msdkh264dec ! glimagesink
52 #include "gstmsdkh264dec.h"
54 GST_DEBUG_CATEGORY_EXTERN (gst_msdkh264dec_debug);
55 #define GST_CAT_DEFAULT gst_msdkh264dec_debug
57 static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
60 GST_STATIC_CAPS ("video/x-h264, "
61 "width = (int) [ 1, MAX ], height = (int) [ 1, MAX ], "
62 "stream-format = (string) byte-stream , alignment = (string) au , "
63 "profile = (string) { high, progressive-high, constrained-high, main, baseline, constrained-baseline }")
66 #define gst_msdkh264dec_parent_class parent_class
67 G_DEFINE_TYPE (GstMsdkH264Dec, gst_msdkh264dec, GST_TYPE_MSDKDEC);
70 gst_msdkh264dec_configure (GstMsdkDec * decoder)
72 GstMsdkH264Dec *h264dec = GST_MSDKH264DEC (decoder);
74 decoder->param.mfx.CodecId = MFX_CODEC_AVC;
76 /* This is a deprecated attribute in msdk-2017 version, but some
77 * customers still using this for low-latency streaming of non-b-frame
79 decoder->param.mfx.DecodedOrder = h264dec->output_order;
81 #if (MFX_VERSION >= 1025)
82 if (decoder->report_error) {
83 decoder->error_report.Header.BufferId = MFX_EXTBUFF_DECODE_ERROR_REPORT;
84 decoder->error_report.Header.BufferSz = sizeof (decoder->error_report);
85 decoder->error_report.ErrorTypes = 0;
86 gst_msdkdec_add_bs_extra_param (decoder,
87 (mfxExtBuffer *) & decoder->error_report);
95 gst_msdkdec_h264_set_property (GObject * object, guint prop_id,
96 const GValue * value, GParamSpec * pspec)
98 GstMsdkH264Dec *thiz = GST_MSDKH264DEC (object);
99 #if (MFX_VERSION >= 1025)
100 GstMsdkDec *dec = GST_MSDKDEC (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);
116 #if (MFX_VERSION >= 1025)
117 case GST_MSDKDEC_PROP_ERROR_REPORT:
118 dec->report_error = g_value_get_boolean (value);
122 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
125 GST_OBJECT_UNLOCK (thiz);
130 gst_msdkdec_h264_get_property (GObject * object, guint prop_id, GValue * value,
133 GstMsdkH264Dec *thiz = GST_MSDKH264DEC (object);
134 #if (MFX_VERSION >= 1025)
135 GstMsdkDec *dec = GST_MSDKDEC (object);
138 GST_OBJECT_LOCK (thiz);
140 case GST_MSDKDEC_PROP_OUTPUT_ORDER:
141 g_value_set_enum (value, thiz->output_order);
143 #if (MFX_VERSION >= 1025)
144 case GST_MSDKDEC_PROP_ERROR_REPORT:
145 g_value_set_boolean (value, dec->report_error);
149 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
152 GST_OBJECT_UNLOCK (thiz);
156 gst_msdkh264dec_class_init (GstMsdkH264DecClass * klass)
158 GObjectClass *gobject_class;
159 GstElementClass *element_class;
160 GstMsdkDecClass *decoder_class;
162 gobject_class = G_OBJECT_CLASS (klass);
163 element_class = GST_ELEMENT_CLASS (klass);
164 decoder_class = GST_MSDKDEC_CLASS (klass);
166 gobject_class->set_property = gst_msdkdec_h264_set_property;
167 gobject_class->get_property = gst_msdkdec_h264_get_property;
169 decoder_class->configure = GST_DEBUG_FUNCPTR (gst_msdkh264dec_configure);
171 gst_element_class_set_static_metadata (element_class,
172 "Intel MSDK H264 decoder",
173 "Codec/Decoder/Video/Hardware",
174 "H264 video decoder based on " MFX_API_SDK,
175 "Scott D Phillips <scott.d.phillips@intel.com>");
177 gst_msdkdec_prop_install_output_oder_property (gobject_class);
179 #if (MFX_VERSION >= 1025)
180 gst_msdkdec_prop_install_error_report_property (gobject_class);
183 gst_element_class_add_static_pad_template (element_class, &sink_factory);
187 gst_msdkh264dec_init (GstMsdkH264Dec * thiz)
189 thiz->output_order = PROP_OUTPUT_ORDER_DEFAULT;