2 * Copyright (C) 2020 Intel Corporation
3 * Author: He Junyan <junyan.he@intel.com>
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.
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.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the0
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
22 * SECTION:element-vampeg2dec
24 * @short_description: A VA-API based Mpeg2 video decoder
26 * vampeg2dec decodes Mpeg2 bitstreams to VA surfaces using the
27 * installed and chosen [VA-API](https://01.org/linuxmedia/vaapi)
30 * The decoding surfaces can be mapped onto main memory as video
33 * ## Example launch line
35 * gst-launch-1.0 filesrc location=sample.mpg ! parsebin ! vampeg2dec ! autovideosink
46 #include "gstvampeg2dec.h"
48 #include "gstvabasedec.h"
50 GST_DEBUG_CATEGORY_STATIC (gst_va_mpeg2dec_debug);
51 #ifndef GST_DISABLE_GST_DEBUG
52 #define GST_CAT_DEFAULT gst_va_mpeg2dec_debug
54 #define GST_CAT_DEFAULT NULL
57 #define GST_VA_MPEG2_DEC(obj) ((GstVaMpeg2Dec *) obj)
58 #define GST_VA_MPEG2_DEC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), G_TYPE_FROM_INSTANCE (obj), GstVaMpeg2DecClass))
59 #define GST_VA_MPEG2_DEC_CLASS(klass) ((GstVaMpeg2DecClass *) klass)
61 typedef struct _GstVaMpeg2Dec GstVaMpeg2Dec;
62 typedef struct _GstVaMpeg2DecClass GstVaMpeg2DecClass;
64 struct _GstVaMpeg2DecClass
66 GstVaBaseDecClass parent_class;
74 GstMpegVideoSequenceHdr seq;
77 static GstElementClass *parent_class = NULL;
80 static const gchar *src_caps_str =
81 GST_VIDEO_CAPS_MAKE_WITH_FEATURES (GST_CAPS_FEATURE_MEMORY_VA,
83 GST_VIDEO_CAPS_MAKE ("{ NV12 }");
86 static const gchar *sink_caps_str = "video/x-mpeg2";
89 _map_profile (GstMpegVideoProfile profile)
91 VAProfile p = VAProfileNone;
94 case GST_MPEG_VIDEO_PROFILE_SIMPLE:
95 p = VAProfileMPEG2Simple;
97 case GST_MPEG_VIDEO_PROFILE_MAIN:
98 p = VAProfileMPEG2Main;
109 _get_profile (GstVaMpeg2Dec * self, GstMpegVideoProfile profile,
110 const GstMpegVideoSequenceExt * seq_ext,
111 const GstMpegVideoSequenceScalableExt * seq_scalable_ext)
113 GstVaBaseDec *base = GST_VA_BASE_DEC (self);
114 VAProfile hw_profile;
116 hw_profile = _map_profile (profile);
117 if (hw_profile == VAProfileNone)
120 /* promote the profile if hw does not support, until we get one */
122 if (gst_va_decoder_has_profile (base->decoder, hw_profile))
125 /* Otherwise, try to map to a higher profile */
127 case GST_MPEG_VIDEO_PROFILE_SIMPLE:
128 hw_profile = VAProfileMPEG2Main;
130 case GST_MPEG_VIDEO_PROFILE_HIGH:
131 /* Try to map to main profile if no high profile specific bits used */
132 if (!seq_scalable_ext && (seq_ext && seq_ext->chroma_format == 1)) {
133 hw_profile = VAProfileMPEG2Main;
138 GST_ERROR_OBJECT (self, "profile %d is unsupported.", profile);
139 hw_profile = VAProfileNone;
142 } while (hw_profile != VAProfileNone);
148 _get_rtformat (GstVaMpeg2Dec * self, GstMpegVideoChromaFormat chroma_format)
152 switch (chroma_format) {
153 case GST_MPEG_VIDEO_CHROMA_420:
154 ret = VA_RT_FORMAT_YUV420;
156 case GST_MPEG_VIDEO_CHROMA_422:
157 ret = VA_RT_FORMAT_YUV422;
159 case GST_MPEG_VIDEO_CHROMA_444:
160 ret = VA_RT_FORMAT_YUV444;
163 GST_ERROR_OBJECT (self, "Unsupported chroma format: %d ", chroma_format);
171 gst_va_mpeg2_dec_new_sequence (GstMpeg2Decoder * decoder,
172 const GstMpegVideoSequenceHdr * seq,
173 const GstMpegVideoSequenceExt * seq_ext,
174 const GstMpegVideoSequenceDisplayExt * seq_display_ext,
175 const GstMpegVideoSequenceScalableExt * seq_scalable_ext, gint max_dpb_size)
177 GstVaBaseDec *base = GST_VA_BASE_DEC (decoder);
178 GstVaMpeg2Dec *self = GST_VA_MPEG2_DEC (decoder);
179 GstVideoInfo *info = &base->output_info;
181 GstMpegVideoProfile mpeg_profile;
182 gboolean negotiation_needed = FALSE;
185 gboolean progressive;
190 height = seq->height;
192 width = (width & 0x0fff) | ((guint32) seq_ext->horiz_size_ext << 12);
193 height = (height & 0x0fff) | ((guint32) seq_ext->vert_size_ext << 12);
196 mpeg_profile = GST_MPEG_VIDEO_PROFILE_MAIN;
198 mpeg_profile = seq_ext->profile;
200 profile = _get_profile (self, mpeg_profile, seq_ext, seq_scalable_ext);
201 if (profile == VAProfileNone)
202 return GST_FLOW_NOT_NEGOTIATED;
204 rt_format = _get_rtformat (self,
205 seq_ext ? seq_ext->chroma_format : GST_MPEG_VIDEO_CHROMA_420);
207 return GST_FLOW_NOT_NEGOTIATED;
209 if (!gst_va_decoder_config_is_equal (base->decoder, profile,
210 rt_format, width, height)) {
211 base->profile = profile;
212 base->rt_format = rt_format;
213 GST_VIDEO_INFO_WIDTH (info) = base->width = width;
214 GST_VIDEO_INFO_HEIGHT (info) = base->height = height;
216 negotiation_needed = TRUE;
218 GST_INFO_OBJECT (self, "Format changed to %s [%x] (%dx%d)",
219 gst_va_profile_name (profile), rt_format, base->width, base->height);
222 progressive = seq_ext ? seq_ext->progressive : 1;
223 if (self->progressive != progressive) {
224 self->progressive = progressive;
225 GST_VIDEO_INFO_INTERLACE_MODE (info) = progressive ?
226 GST_VIDEO_INTERLACE_MODE_PROGRESSIVE : GST_VIDEO_INTERLACE_MODE_MIXED;
227 negotiation_needed = TRUE;
228 GST_INFO_OBJECT (self, "Interlaced mode changed to %d", !progressive);
231 base->need_valign = FALSE;
232 base->min_buffers = 2 + 4; /* max num pic references + scratch surfaces */
233 base->need_negotiation = negotiation_needed;
234 g_clear_pointer (&base->input_state, gst_video_codec_state_unref);
235 base->input_state = gst_video_codec_state_ref (decoder->input_state);
241 gst_va_mpeg2_dec_new_picture (GstMpeg2Decoder * decoder,
242 GstVideoCodecFrame * frame, GstMpeg2Picture * picture)
244 GstVaMpeg2Dec *self = GST_VA_MPEG2_DEC (decoder);
245 GstVaBaseDec *base = GST_VA_BASE_DEC (decoder);
246 GstVaDecodePicture *pic;
249 ret = gst_va_base_dec_prepare_output_frame (base, frame);
250 if (ret != GST_FLOW_OK)
253 pic = gst_va_decode_picture_new (base->decoder, frame->output_buffer);
255 gst_mpeg2_picture_set_user_data (picture, pic,
256 (GDestroyNotify) gst_va_decode_picture_free);
258 GST_LOG_OBJECT (self, "New va decode picture %p - %#x", pic,
259 gst_va_decode_picture_get_surface (pic));
265 GST_WARNING_OBJECT (self, "Failed to allocated output buffer, return %s",
266 gst_flow_get_name (ret));
272 gst_va_mpeg2_dec_new_field_picture (GstMpeg2Decoder * decoder,
273 GstMpeg2Picture * first_field, GstMpeg2Picture * second_field)
275 GstVaDecodePicture *first_pic, *second_pic;
276 GstVaMpeg2Dec *self = GST_VA_MPEG2_DEC (decoder);
277 GstVaBaseDec *base = GST_VA_BASE_DEC (decoder);
279 first_pic = gst_mpeg2_picture_get_user_data (first_field);
281 return GST_FLOW_ERROR;
283 second_pic = gst_va_decode_picture_new (base->decoder, first_pic->gstbuffer);
284 gst_mpeg2_picture_set_user_data (second_field, second_pic,
285 (GDestroyNotify) gst_va_decode_picture_free);
287 GST_LOG_OBJECT (self, "New va decode picture %p - %#x", second_pic,
288 gst_va_decode_picture_get_surface (second_pic));
293 static inline guint32
294 _pack_f_code (guint8 f_code[2][2])
296 return (((guint32) f_code[0][0] << 12)
297 | ((guint32) f_code[0][1] << 8)
298 | ((guint32) f_code[1][0] << 4)
303 _copy_quant_matrix (guint8 dst[64], const guint8 src[64])
305 memcpy (dst, src, 64);
309 gst_va_mpeg2_dec_add_quant_matrix (GstMpeg2Decoder * decoder,
310 GstMpeg2Picture * picture, GstMpeg2Slice * slice)
312 GstVaBaseDec *base = GST_VA_BASE_DEC (decoder);
313 GstVaMpeg2Dec *self = GST_VA_MPEG2_DEC (decoder);
314 GstMpegVideoQuantMatrixExt *const quant_matrix = slice->quant_matrix;
315 guint8 *intra_quant_matrix = NULL;
316 guint8 *non_intra_quant_matrix = NULL;
317 guint8 *chroma_intra_quant_matrix = NULL;
318 guint8 *chroma_non_intra_quant_matrix = NULL;
319 VAIQMatrixBufferMPEG2 iq_matrix = { 0 };
320 GstVaDecodePicture *va_pic;
322 intra_quant_matrix = self->seq.intra_quantizer_matrix;
323 non_intra_quant_matrix = self->seq.non_intra_quantizer_matrix;
326 if (quant_matrix->load_intra_quantiser_matrix)
327 intra_quant_matrix = quant_matrix->intra_quantiser_matrix;
328 if (quant_matrix->load_non_intra_quantiser_matrix)
329 non_intra_quant_matrix = quant_matrix->non_intra_quantiser_matrix;
330 if (quant_matrix->load_chroma_intra_quantiser_matrix)
331 chroma_intra_quant_matrix = quant_matrix->chroma_intra_quantiser_matrix;
332 if (quant_matrix->load_chroma_non_intra_quantiser_matrix)
333 chroma_non_intra_quant_matrix =
334 quant_matrix->chroma_non_intra_quantiser_matrix;
337 iq_matrix.load_intra_quantiser_matrix = intra_quant_matrix != NULL;
338 if (intra_quant_matrix)
339 _copy_quant_matrix (iq_matrix.intra_quantiser_matrix, intra_quant_matrix);
341 iq_matrix.load_non_intra_quantiser_matrix = non_intra_quant_matrix != NULL;
342 if (non_intra_quant_matrix)
343 _copy_quant_matrix (iq_matrix.non_intra_quantiser_matrix,
344 non_intra_quant_matrix);
346 iq_matrix.load_chroma_intra_quantiser_matrix =
347 chroma_intra_quant_matrix != NULL;
348 if (chroma_intra_quant_matrix)
349 _copy_quant_matrix (iq_matrix.chroma_intra_quantiser_matrix,
350 chroma_intra_quant_matrix);
352 iq_matrix.load_chroma_non_intra_quantiser_matrix =
353 chroma_non_intra_quant_matrix != NULL;
354 if (chroma_non_intra_quant_matrix)
355 _copy_quant_matrix (iq_matrix.chroma_non_intra_quantiser_matrix,
356 chroma_non_intra_quant_matrix);
358 va_pic = gst_mpeg2_picture_get_user_data (picture);
359 return gst_va_decoder_add_param_buffer (base->decoder, va_pic,
360 VAIQMatrixBufferType, &iq_matrix, sizeof (iq_matrix));
363 static inline uint32_t
364 _is_frame_start (GstMpeg2Picture * picture)
366 return (!picture->first_field
367 || (picture->structure == GST_MPEG_VIDEO_PICTURE_STRUCTURE_FRAME))
371 static inline VASurfaceID
372 _get_surface_id (GstMpeg2Picture * picture)
374 GstVaDecodePicture *va_pic;
377 return VA_INVALID_ID;
379 va_pic = gst_mpeg2_picture_get_user_data (picture);
381 return VA_INVALID_ID;
382 return gst_va_decode_picture_get_surface (va_pic);
386 gst_va_mpeg2_dec_start_picture (GstMpeg2Decoder * decoder,
387 GstMpeg2Picture * picture, GstMpeg2Slice * slice,
388 GstMpeg2Picture * prev_picture, GstMpeg2Picture * next_picture)
390 GstVaBaseDec *base = GST_VA_BASE_DEC (decoder);
391 GstVaMpeg2Dec *self = GST_VA_MPEG2_DEC (decoder);
392 GstVaDecodePicture *va_pic;
393 VAPictureParameterBufferMPEG2 pic_param;
395 va_pic = gst_mpeg2_picture_get_user_data (picture);
398 pic_param = (VAPictureParameterBufferMPEG2) {
399 .horizontal_size = base->width,
400 .vertical_size = base->height,
401 .forward_reference_picture = VA_INVALID_ID,
402 .backward_reference_picture = VA_INVALID_ID,
403 .picture_coding_type = slice->pic_hdr->pic_type,
404 .f_code = _pack_f_code (slice->pic_ext->f_code),
405 .picture_coding_extension.bits = {
406 .is_first_field = _is_frame_start (picture),
407 .intra_dc_precision = slice->pic_ext->intra_dc_precision,
408 .picture_structure = slice->pic_ext->picture_structure,
409 .top_field_first = slice->pic_ext->top_field_first,
410 .frame_pred_frame_dct = slice->pic_ext->frame_pred_frame_dct,
411 .concealment_motion_vectors = slice->pic_ext->concealment_motion_vectors,
412 .q_scale_type = slice->pic_ext->q_scale_type,
413 .intra_vlc_format = slice->pic_ext->intra_vlc_format,
414 .alternate_scan = slice->pic_ext->alternate_scan,
415 .repeat_first_field = slice->pic_ext->repeat_first_field,
416 .progressive_frame = slice->pic_ext->progressive_frame,
421 switch (picture->type) {
422 case GST_MPEG_VIDEO_PICTURE_TYPE_B:{
423 VASurfaceID surface = _get_surface_id (next_picture);
424 if (surface == VA_INVALID_ID) {
425 GST_WARNING_OBJECT (self, "Missing the backward reference picture");
426 if (GST_VA_DISPLAY_IS_IMPLEMENTATION (base->display, MESA_GALLIUM))
427 return GST_FLOW_ERROR;
428 else if (GST_VA_DISPLAY_IS_IMPLEMENTATION (base->display, INTEL_IHD))
429 surface = gst_va_decode_picture_get_surface (va_pic);
431 pic_param.backward_reference_picture = surface;
434 case GST_MPEG_VIDEO_PICTURE_TYPE_P:{
435 VASurfaceID surface = _get_surface_id (prev_picture);
436 if (surface == VA_INVALID_ID) {
437 GST_WARNING_OBJECT (self, "Missing the forward reference picture");
438 if (GST_VA_DISPLAY_IS_IMPLEMENTATION (base->display, MESA_GALLIUM))
439 return GST_FLOW_ERROR;
440 else if (GST_VA_DISPLAY_IS_IMPLEMENTATION (base->display, INTEL_IHD))
441 surface = gst_va_decode_picture_get_surface (va_pic);
443 pic_param.forward_reference_picture = surface;
449 if (!gst_va_decoder_add_param_buffer (base->decoder, va_pic,
450 VAPictureParameterBufferType, &pic_param, sizeof (pic_param)))
451 return GST_FLOW_ERROR;
453 if (!gst_va_mpeg2_dec_add_quant_matrix (decoder, picture, slice))
454 return GST_FLOW_ERROR;
460 gst_va_mpeg2_dec_decode_slice (GstMpeg2Decoder * decoder,
461 GstMpeg2Picture * picture, GstMpeg2Slice * slice)
463 GstVaBaseDec *base = GST_VA_BASE_DEC (decoder);
464 GstMpegVideoSliceHdr *header = &slice->header;
465 GstMpegVideoPacket *packet = &slice->packet;
466 GstVaDecodePicture *va_pic;
467 VASliceParameterBufferMPEG2 slice_param;
470 slice_param = (VASliceParameterBufferMPEG2) {
471 .slice_data_size = slice->size,
472 .slice_data_offset = 0,
473 .slice_data_flag = VA_SLICE_DATA_FLAG_ALL,
474 .macroblock_offset = header->header_size + 32,
475 .slice_horizontal_position = header->mb_column,
476 .slice_vertical_position = header->mb_row,
477 .quantiser_scale_code = header->quantiser_scale_code,
478 .intra_slice_flag = header->intra_slice,
482 va_pic = gst_mpeg2_picture_get_user_data (picture);
483 if (!gst_va_decoder_add_slice_buffer (base->decoder, va_pic,
484 &slice_param, sizeof (slice_param),
485 (guint8 *) (packet->data + slice->sc_offset), slice->size))
486 return GST_FLOW_ERROR;
492 gst_va_mpeg2_dec_end_picture (GstMpeg2Decoder * decoder,
493 GstMpeg2Picture * picture)
495 GstVaBaseDec *base = GST_VA_BASE_DEC (decoder);
496 GstVaDecodePicture *va_pic;
498 GST_LOG_OBJECT (base, "end picture %p, (poc %d)",
499 picture, picture->pic_order_cnt);
501 va_pic = gst_mpeg2_picture_get_user_data (picture);
503 if (!gst_va_decoder_decode (base->decoder, va_pic))
504 return GST_FLOW_ERROR;
510 gst_va_mpeg2_dec_output_picture (GstMpeg2Decoder * decoder,
511 GstVideoCodecFrame * frame, GstMpeg2Picture * picture)
513 GstVaBaseDec *base = GST_VA_BASE_DEC (decoder);
514 GstVaMpeg2Dec *self = GST_VA_MPEG2_DEC (decoder);
515 GstVideoDecoder *vdec = GST_VIDEO_DECODER (decoder);
518 GST_LOG_OBJECT (self,
519 "Outputting picture %p (poc %d)", picture, picture->pic_order_cnt);
521 ret = gst_va_base_dec_process_output (base, frame, picture->discont_state,
522 picture->buffer_flags);
523 gst_mpeg2_picture_unref (picture);
526 return gst_video_decoder_finish_frame (vdec, frame);
527 return GST_FLOW_ERROR;
531 gst_va_mpeg2_dec_init (GTypeInstance * instance, gpointer g_class)
533 gst_va_base_dec_init (GST_VA_BASE_DEC (instance), GST_CAT_DEFAULT);
534 GST_VA_MPEG2_DEC (instance)->progressive = 1;
538 gst_va_mpeg2_dec_dispose (GObject * object)
540 gst_va_base_dec_close (GST_VIDEO_DECODER (object));
541 G_OBJECT_CLASS (parent_class)->dispose (object);
545 gst_va_mpeg2_dec_class_init (gpointer g_class, gpointer class_data)
547 GstCaps *src_doc_caps, *sink_doc_caps;
548 GObjectClass *gobject_class = G_OBJECT_CLASS (g_class);
549 GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
550 GstMpeg2DecoderClass *mpeg2decoder_class = GST_MPEG2_DECODER_CLASS (g_class);
551 struct CData *cdata = class_data;
554 if (cdata->description) {
555 long_name = g_strdup_printf ("VA-API Mpeg2 Decoder in %s",
558 long_name = g_strdup ("VA-API Mpeg2 Decoder");
561 gst_element_class_set_metadata (element_class, long_name,
562 "Codec/Decoder/Video/Hardware",
563 "VA-API based Mpeg2 video decoder", "He Junyan <junyan.he@intel.com>");
565 sink_doc_caps = gst_caps_from_string (sink_caps_str);
566 src_doc_caps = gst_caps_from_string (src_caps_str);
568 parent_class = g_type_class_peek_parent (g_class);
571 * GstVaMpeg2Dec:device-path:
573 * It shows the DRM device path used for the VA operation, if any.
577 gst_va_base_dec_class_init (GST_VA_BASE_DEC_CLASS (g_class), MPEG2,
578 cdata->render_device_path, cdata->sink_caps, cdata->src_caps,
579 src_doc_caps, sink_doc_caps);
581 gobject_class->dispose = gst_va_mpeg2_dec_dispose;
583 mpeg2decoder_class->new_sequence =
584 GST_DEBUG_FUNCPTR (gst_va_mpeg2_dec_new_sequence);
585 mpeg2decoder_class->new_picture =
586 GST_DEBUG_FUNCPTR (gst_va_mpeg2_dec_new_picture);
587 mpeg2decoder_class->new_field_picture =
588 GST_DEBUG_FUNCPTR (gst_va_mpeg2_dec_new_field_picture);
589 mpeg2decoder_class->start_picture =
590 GST_DEBUG_FUNCPTR (gst_va_mpeg2_dec_start_picture);
591 mpeg2decoder_class->decode_slice =
592 GST_DEBUG_FUNCPTR (gst_va_mpeg2_dec_decode_slice);
593 mpeg2decoder_class->end_picture =
594 GST_DEBUG_FUNCPTR (gst_va_mpeg2_dec_end_picture);
595 mpeg2decoder_class->output_picture =
596 GST_DEBUG_FUNCPTR (gst_va_mpeg2_dec_output_picture);
599 g_free (cdata->description);
600 g_free (cdata->render_device_path);
601 gst_caps_unref (cdata->src_caps);
602 gst_caps_unref (cdata->sink_caps);
607 _register_debug_category (gpointer data)
609 GST_DEBUG_CATEGORY_INIT (gst_va_mpeg2dec_debug, "vampeg2dec", 0,
616 gst_va_mpeg2_dec_register (GstPlugin * plugin, GstVaDevice * device,
617 GstCaps * sink_caps, GstCaps * src_caps, guint rank)
619 static GOnce debug_once = G_ONCE_INIT;
621 GTypeInfo type_info = {
622 .class_size = sizeof (GstVaMpeg2DecClass),
623 .class_init = gst_va_mpeg2_dec_class_init,
624 .instance_size = sizeof (GstVaMpeg2Dec),
625 .instance_init = gst_va_mpeg2_dec_init,
629 gchar *type_name, *feature_name;
631 g_return_val_if_fail (GST_IS_PLUGIN (plugin), FALSE);
632 g_return_val_if_fail (GST_IS_VA_DEVICE (device), FALSE);
633 g_return_val_if_fail (GST_IS_CAPS (sink_caps), FALSE);
634 g_return_val_if_fail (GST_IS_CAPS (src_caps), FALSE);
636 cdata = g_new (struct CData, 1);
637 cdata->description = NULL;
638 cdata->render_device_path = g_strdup (device->render_device_path);
639 cdata->sink_caps = gst_caps_ref (sink_caps);
640 cdata->src_caps = gst_caps_ref (src_caps);
642 /* class data will be leaked if the element never gets instantiated */
643 GST_MINI_OBJECT_FLAG_SET (cdata->sink_caps,
644 GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED);
645 GST_MINI_OBJECT_FLAG_SET (src_caps, GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED);
647 type_info.class_data = cdata;
649 /* The first decoder to be registered should use a constant name,
650 * like vampeg2dec, for any additional decoders, we create unique
651 * names, using inserting the render device name. */
652 if (device->index == 0) {
653 type_name = g_strdup ("GstVaMpeg2Dec");
654 feature_name = g_strdup ("vampeg2dec");
656 gchar *basename = g_path_get_basename (device->render_device_path);
657 type_name = g_strdup_printf ("GstVa%sMpeg2Dec", basename);
658 feature_name = g_strdup_printf ("va%smpeg2dec", basename);
659 cdata->description = basename;
661 /* lower rank for non-first device */
666 g_once (&debug_once, _register_debug_category, NULL);
668 type = g_type_register_static (GST_TYPE_MPEG2_DECODER,
669 type_name, &type_info, 0);
671 ret = gst_element_register (plugin, feature_name, rank, type);
674 g_free (feature_name);