2 * Copyright (C) 2020 Seungha Yang <seungha@centricular.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
24 #include <gst/cuda/gstcudautils.h>
26 #include "gstnvvp9dec.h"
27 #include "gstnvdecoder.h"
31 GST_DEBUG_CATEGORY_STATIC (gst_nv_vp9_dec_debug);
32 #define GST_CAT_DEFAULT gst_nv_vp9_dec_debug
38 GstVideoCodecState *output_state;
40 GstCudaContext *context;
41 GstNvDecoder *decoder;
42 CUVIDPICPARAMS params;
45 GstVP9Profile profile;
48 struct _GstNvVp9DecClass
50 GstVp9DecoderClass parent_class;
54 #define gst_nv_vp9_dec_parent_class parent_class
61 G_DEFINE_TYPE (GstNvVp9Dec, gst_nv_vp9_dec, GST_TYPE_VP9_DECODER);
63 static void gst_nv_vp9_dec_set_context (GstElement * element,
64 GstContext * context);
65 static gboolean gst_nv_vp9_dec_open (GstVideoDecoder * decoder);
66 static gboolean gst_nv_vp9_dec_close (GstVideoDecoder * decoder);
67 static gboolean gst_nv_vp9_dec_negotiate (GstVideoDecoder * decoder);
68 static gboolean gst_nv_vp9_dec_decide_allocation (GstVideoDecoder *
69 decoder, GstQuery * query);
70 static gboolean gst_nv_vp9_dec_src_query (GstVideoDecoder * decoder,
74 static GstFlowReturn gst_nv_vp9_dec_new_sequence (GstVp9Decoder * decoder,
75 const GstVp9FrameHeader * frame_hdr, gint max_dpb_size);
76 static GstFlowReturn gst_nv_vp9_dec_new_picture (GstVp9Decoder * decoder,
77 GstVideoCodecFrame * frame, GstVp9Picture * picture);
78 static GstVp9Picture *gst_nv_vp9_dec_duplicate_picture (GstVp9Decoder *
79 decoder, GstVideoCodecFrame * frame, GstVp9Picture * picture);
80 static GstFlowReturn gst_nv_vp9_dec_decode_picture (GstVp9Decoder * decoder,
81 GstVp9Picture * picture, GstVp9Dpb * dpb);
82 static GstFlowReturn gst_nv_vp9_dec_output_picture (GstVp9Decoder *
83 decoder, GstVideoCodecFrame * frame, GstVp9Picture * picture);
84 static guint gst_nv_vp9_dec_get_preferred_output_delay (GstVp9Decoder * decoder,
88 gst_nv_vp9_dec_class_init (GstNvVp9DecClass * klass)
90 GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
91 GstVideoDecoderClass *decoder_class = GST_VIDEO_DECODER_CLASS (klass);
92 GstVp9DecoderClass *vp9decoder_class = GST_VP9_DECODER_CLASS (klass);
94 element_class->set_context = GST_DEBUG_FUNCPTR (gst_nv_vp9_dec_set_context);
96 decoder_class->open = GST_DEBUG_FUNCPTR (gst_nv_vp9_dec_open);
97 decoder_class->close = GST_DEBUG_FUNCPTR (gst_nv_vp9_dec_close);
98 decoder_class->negotiate = GST_DEBUG_FUNCPTR (gst_nv_vp9_dec_negotiate);
99 decoder_class->decide_allocation =
100 GST_DEBUG_FUNCPTR (gst_nv_vp9_dec_decide_allocation);
101 decoder_class->src_query = GST_DEBUG_FUNCPTR (gst_nv_vp9_dec_src_query);
103 vp9decoder_class->new_sequence =
104 GST_DEBUG_FUNCPTR (gst_nv_vp9_dec_new_sequence);
105 vp9decoder_class->new_picture =
106 GST_DEBUG_FUNCPTR (gst_nv_vp9_dec_new_picture);
107 vp9decoder_class->duplicate_picture =
108 GST_DEBUG_FUNCPTR (gst_nv_vp9_dec_duplicate_picture);
109 vp9decoder_class->decode_picture =
110 GST_DEBUG_FUNCPTR (gst_nv_vp9_dec_decode_picture);
111 vp9decoder_class->output_picture =
112 GST_DEBUG_FUNCPTR (gst_nv_vp9_dec_output_picture);
113 vp9decoder_class->get_preferred_output_delay =
114 GST_DEBUG_FUNCPTR (gst_nv_vp9_dec_get_preferred_output_delay);
116 GST_DEBUG_CATEGORY_INIT (gst_nv_vp9_dec_debug,
117 "nvvp9dec", 0, "NVIDIA VP9 Decoder");
119 gst_type_mark_as_plugin_api (GST_TYPE_NV_VP9_DEC, 0);
123 gst_nv_vp9_dec_init (GstNvVp9Dec * self)
128 gst_nv_vp9_dec_set_context (GstElement * element, GstContext * context)
130 GstNvVp9Dec *self = GST_NV_VP9_DEC (element);
131 GstNvVp9DecClass *klass = GST_NV_VP9_DEC_GET_CLASS (self);
133 GST_DEBUG_OBJECT (self, "set context %s",
134 gst_context_get_context_type (context));
136 if (gst_cuda_handle_set_context (element, context, klass->cuda_device_id,
142 gst_nv_decoder_handle_set_context (self->decoder, element, context);
145 GST_ELEMENT_CLASS (parent_class)->set_context (element, context);
149 gst_nv_vp9_dec_open (GstVideoDecoder * decoder)
151 GstVp9Decoder *vp9dec = GST_VP9_DECODER (decoder);
152 GstNvVp9Dec *self = GST_NV_VP9_DEC (decoder);
153 GstNvVp9DecClass *klass = GST_NV_VP9_DEC_GET_CLASS (self);
155 if (!gst_cuda_ensure_element_context (GST_ELEMENT (self),
156 klass->cuda_device_id, &self->context)) {
157 GST_ERROR_OBJECT (self, "Required element data is unavailable");
161 self->decoder = gst_nv_decoder_new (self->context);
162 if (!self->decoder) {
163 GST_ERROR_OBJECT (self, "Failed to create decoder object");
164 gst_clear_object (&self->context);
169 /* NVDEC doesn't support non-keyframe resolution change and it will result
170 * in outputting broken frames */
171 gst_vp9_decoder_set_non_keyframe_format_change_support (vp9dec, FALSE);
177 gst_nv_vp9_dec_close (GstVideoDecoder * decoder)
179 GstNvVp9Dec *self = GST_NV_VP9_DEC (decoder);
181 g_clear_pointer (&self->output_state, gst_video_codec_state_unref);
182 gst_clear_object (&self->decoder);
183 gst_clear_object (&self->context);
189 gst_nv_vp9_dec_negotiate (GstVideoDecoder * decoder)
191 GstNvVp9Dec *self = GST_NV_VP9_DEC (decoder);
192 GstVp9Decoder *vp9dec = GST_VP9_DECODER (decoder);
194 GST_DEBUG_OBJECT (self, "negotiate");
196 gst_nv_decoder_negotiate (self->decoder, decoder, vp9dec->input_state,
197 &self->output_state);
199 /* TODO: add support D3D11 memory */
201 return GST_VIDEO_DECODER_CLASS (parent_class)->negotiate (decoder);
205 gst_nv_vp9_dec_decide_allocation (GstVideoDecoder * decoder, GstQuery * query)
207 GstNvVp9Dec *self = GST_NV_VP9_DEC (decoder);
209 if (!gst_nv_decoder_decide_allocation (self->decoder, decoder, query)) {
210 GST_WARNING_OBJECT (self, "Failed to handle decide allocation");
214 return GST_VIDEO_DECODER_CLASS (parent_class)->decide_allocation
219 gst_nv_vp9_dec_src_query (GstVideoDecoder * decoder, GstQuery * query)
221 GstNvVp9Dec *self = GST_NV_VP9_DEC (decoder);
223 switch (GST_QUERY_TYPE (query)) {
224 case GST_QUERY_CONTEXT:
225 if (gst_cuda_handle_context_query (GST_ELEMENT (decoder), query,
228 } else if (self->decoder &&
229 gst_nv_decoder_handle_context_query (self->decoder, decoder, query)) {
237 return GST_VIDEO_DECODER_CLASS (parent_class)->src_query (decoder, query);
241 gst_nv_vp9_dec_new_sequence (GstVp9Decoder * decoder,
242 const GstVp9FrameHeader * frame_hdr, gint max_dpb_size)
244 GstNvVp9Dec *self = GST_NV_VP9_DEC (decoder);
245 GstVideoFormat out_format = GST_VIDEO_FORMAT_UNKNOWN;
248 GST_LOG_OBJECT (self, "new sequence");
250 self->width = frame_hdr->width;
251 self->height = frame_hdr->height;
252 self->profile = frame_hdr->profile;
254 if (self->profile == GST_VP9_PROFILE_0) {
255 out_format = GST_VIDEO_FORMAT_NV12;
256 } else if (self->profile == GST_VP9_PROFILE_2) {
257 if (frame_hdr->bit_depth == 10) {
258 out_format = GST_VIDEO_FORMAT_P010_10LE;
260 out_format = GST_VIDEO_FORMAT_P016_LE;
264 if (out_format == GST_VIDEO_FORMAT_UNKNOWN) {
265 GST_ERROR_OBJECT (self, "Could not support profile %d", self->profile);
266 return GST_FLOW_NOT_NEGOTIATED;
269 gst_video_info_set_format (&info, out_format, self->width, self->height);
270 if (!gst_nv_decoder_configure (self->decoder,
271 cudaVideoCodec_VP9, &info, self->width, self->height,
272 frame_hdr->bit_depth, max_dpb_size)) {
273 GST_ERROR_OBJECT (self, "Failed to configure decoder");
274 return GST_FLOW_NOT_NEGOTIATED;
277 if (!gst_video_decoder_negotiate (GST_VIDEO_DECODER (self))) {
278 GST_ERROR_OBJECT (self, "Failed to negotiate with downstream");
279 return GST_FLOW_NOT_NEGOTIATED;
282 memset (&self->params, 0, sizeof (CUVIDPICPARAMS));
284 self->params.CodecSpecific.vp9.colorSpace = frame_hdr->color_space;
290 gst_nv_vp9_dec_new_picture (GstVp9Decoder * decoder,
291 GstVideoCodecFrame * frame, GstVp9Picture * picture)
293 GstNvVp9Dec *self = GST_NV_VP9_DEC (decoder);
294 GstNvDecoderFrame *nv_frame;
296 nv_frame = gst_nv_decoder_new_frame (self->decoder);
298 GST_ERROR_OBJECT (self, "No available decoder frame");
299 return GST_FLOW_ERROR;
302 GST_LOG_OBJECT (self,
303 "New decoder frame %p (index %d)", nv_frame, nv_frame->index);
305 gst_vp9_picture_set_user_data (picture,
306 nv_frame, (GDestroyNotify) gst_nv_decoder_frame_unref);
311 static GstNvDecoderFrame *
312 gst_nv_vp9_dec_get_decoder_frame_from_picture (GstNvVp9Dec * self,
313 GstVp9Picture * picture)
315 GstNvDecoderFrame *frame;
317 frame = (GstNvDecoderFrame *) gst_vp9_picture_get_user_data (picture);
320 GST_DEBUG_OBJECT (self, "current picture does not have decoder frame");
325 static GstVp9Picture *
326 gst_nv_vp9_dec_duplicate_picture (GstVp9Decoder * decoder,
327 GstVideoCodecFrame * frame, GstVp9Picture * picture)
329 GstNvVp9Dec *self = GST_NV_VP9_DEC (decoder);
330 GstNvDecoderFrame *nv_frame;
331 GstVp9Picture *new_picture;
333 nv_frame = gst_nv_vp9_dec_get_decoder_frame_from_picture (self, picture);
336 GST_ERROR_OBJECT (self, "Parent picture does not have decoder frame");
340 new_picture = gst_vp9_picture_new ();
341 new_picture->frame_hdr = picture->frame_hdr;
343 gst_vp9_picture_set_user_data (new_picture,
344 gst_nv_decoder_frame_ref (nv_frame),
345 (GDestroyNotify) gst_nv_decoder_frame_unref);
351 gst_nv_vp9_dec_decode_picture (GstVp9Decoder * decoder,
352 GstVp9Picture * picture, GstVp9Dpb * dpb)
354 GstNvVp9Dec *self = GST_NV_VP9_DEC (decoder);
355 const GstVp9FrameHeader *frame_hdr = &picture->frame_hdr;
356 const GstVp9LoopFilterParams *lfp = &frame_hdr->loop_filter_params;
357 const GstVp9SegmentationParams *sp = &frame_hdr->segmentation_params;
358 const GstVp9QuantizationParams *qp = &frame_hdr->quantization_params;
359 CUVIDPICPARAMS *params = &self->params;
360 CUVIDVP9PICPARAMS *vp9_params = ¶ms->CodecSpecific.vp9;
361 GstNvDecoderFrame *frame;
362 GstNvDecoderFrame *other_frame;
364 guint8 ref_frame_map[GST_VP9_REF_FRAMES];
367 G_STATIC_ASSERT (G_N_ELEMENTS (vp9_params->mbRefLfDelta) ==
368 GST_VP9_MAX_REF_LF_DELTAS);
369 G_STATIC_ASSERT (G_N_ELEMENTS (vp9_params->mbModeLfDelta) ==
370 GST_VP9_MAX_MODE_LF_DELTAS);
371 G_STATIC_ASSERT (G_N_ELEMENTS (vp9_params->mb_segment_tree_probs) ==
372 GST_VP9_SEG_TREE_PROBS);
373 G_STATIC_ASSERT (sizeof (vp9_params->mb_segment_tree_probs) ==
374 sizeof (sp->segmentation_tree_probs));
375 G_STATIC_ASSERT (G_N_ELEMENTS (vp9_params->segment_pred_probs) ==
376 GST_VP9_PREDICTION_PROBS);
377 G_STATIC_ASSERT (sizeof (vp9_params->segment_pred_probs) ==
378 sizeof (sp->segmentation_pred_prob));
379 G_STATIC_ASSERT (G_N_ELEMENTS (vp9_params->refFrameSignBias) ==
380 GST_VP9_REFS_PER_FRAME + 1);
381 G_STATIC_ASSERT (sizeof (vp9_params->refFrameSignBias) ==
382 sizeof (frame_hdr->ref_frame_sign_bias));
383 G_STATIC_ASSERT (G_N_ELEMENTS (vp9_params->activeRefIdx) ==
384 GST_VP9_REFS_PER_FRAME);
385 G_STATIC_ASSERT (G_N_ELEMENTS (vp9_params->segmentFeatureEnable) ==
386 GST_VP9_MAX_SEGMENTS);
387 G_STATIC_ASSERT (sizeof (vp9_params->segmentFeatureEnable) ==
388 sizeof (sp->feature_enabled));
389 G_STATIC_ASSERT (G_N_ELEMENTS (vp9_params->segmentFeatureData) ==
390 GST_VP9_MAX_SEGMENTS);
391 G_STATIC_ASSERT (sizeof (vp9_params->segmentFeatureData) ==
392 sizeof (sp->feature_data));
394 GST_LOG_OBJECT (self, "Decode picture, size %" G_GSIZE_FORMAT, picture->size);
396 frame = gst_nv_vp9_dec_get_decoder_frame_from_picture (self, picture);
398 GST_ERROR_OBJECT (self, "Decoder frame is unavailable");
399 return GST_FLOW_ERROR;
402 params->nBitstreamDataLen = picture->size;
403 params->pBitstreamData = picture->data;
404 params->nNumSlices = 1;
405 params->pSliceDataOffsets = &offset;
407 params->PicWidthInMbs = GST_ROUND_UP_16 (frame_hdr->width) >> 4;
408 params->FrameHeightInMbs = GST_ROUND_UP_16 (frame_hdr->height) >> 4;
409 params->CurrPicIdx = frame->index;
411 vp9_params->width = frame_hdr->width;
412 vp9_params->height = frame_hdr->height;
414 for (i = 0; i < GST_VP9_REF_FRAMES; i++) {
415 if (dpb->pic_list[i]) {
416 other_frame = gst_nv_vp9_dec_get_decoder_frame_from_picture (self,
419 GST_ERROR_OBJECT (self, "Couldn't get decoder frame from picture");
423 ref_frame_map[i] = other_frame->index;
425 ref_frame_map[i] = 0xff;
429 vp9_params->LastRefIdx = ref_frame_map[frame_hdr->ref_frame_idx[0]];
430 vp9_params->GoldenRefIdx = ref_frame_map[frame_hdr->ref_frame_idx[1]];
431 vp9_params->AltRefIdx = ref_frame_map[frame_hdr->ref_frame_idx[2]];
433 vp9_params->profile = frame_hdr->profile;
434 vp9_params->frameContextIdx = frame_hdr->frame_context_idx;
435 vp9_params->frameType = frame_hdr->frame_type;
436 vp9_params->showFrame = frame_hdr->show_frame;
437 vp9_params->errorResilient = frame_hdr->error_resilient_mode;
438 vp9_params->frameParallelDecoding = frame_hdr->frame_parallel_decoding_mode;
439 vp9_params->subSamplingX = frame_hdr->subsampling_x;
440 vp9_params->subSamplingY = frame_hdr->subsampling_y;
441 vp9_params->intraOnly = frame_hdr->intra_only;
442 vp9_params->allow_high_precision_mv = frame_hdr->allow_high_precision_mv;
443 vp9_params->refreshEntropyProbs = frame_hdr->refresh_frame_context;
444 vp9_params->bitDepthMinus8Luma = frame_hdr->bit_depth - 8;
445 vp9_params->bitDepthMinus8Chroma = frame_hdr->bit_depth - 8;
447 vp9_params->loopFilterLevel = lfp->loop_filter_level;
448 vp9_params->loopFilterSharpness = lfp->loop_filter_sharpness;
449 vp9_params->modeRefLfEnabled = lfp->loop_filter_delta_enabled;
451 vp9_params->log2_tile_columns = frame_hdr->tile_cols_log2;
452 vp9_params->log2_tile_rows = frame_hdr->tile_rows_log2;
454 vp9_params->segmentEnabled = sp->segmentation_enabled;
455 vp9_params->segmentMapUpdate = sp->segmentation_update_map;
456 vp9_params->segmentMapTemporalUpdate = sp->segmentation_temporal_update;
457 vp9_params->segmentFeatureMode = sp->segmentation_abs_or_delta_update;
459 vp9_params->qpYAc = qp->base_q_idx;
460 vp9_params->qpYDc = qp->delta_q_y_dc;
461 vp9_params->qpChDc = qp->delta_q_uv_dc;
462 vp9_params->qpChAc = qp->delta_q_uv_ac;
464 vp9_params->resetFrameContext = frame_hdr->reset_frame_context;
465 vp9_params->mcomp_filter_type = frame_hdr->interpolation_filter;
466 vp9_params->frameTagSize = frame_hdr->frame_header_length_in_bytes;
467 vp9_params->offsetToDctParts = frame_hdr->header_size_in_bytes;
469 for (i = 0; i < GST_VP9_MAX_REF_LF_DELTAS; i++)
470 vp9_params->mbRefLfDelta[i] = lfp->loop_filter_ref_deltas[i];
472 for (i = 0; i < GST_VP9_MAX_MODE_LF_DELTAS; i++)
473 vp9_params->mbModeLfDelta[i] = lfp->loop_filter_mode_deltas[i];
475 memcpy (vp9_params->mb_segment_tree_probs, sp->segmentation_tree_probs,
476 sizeof (sp->segmentation_tree_probs));
477 memcpy (vp9_params->segment_pred_probs, sp->segmentation_pred_prob,
478 sizeof (sp->segmentation_pred_prob));
479 memcpy (vp9_params->refFrameSignBias, frame_hdr->ref_frame_sign_bias,
480 sizeof (frame_hdr->ref_frame_sign_bias));
482 for (i = 0; i < GST_VP9_REFS_PER_FRAME; i++) {
483 vp9_params->activeRefIdx[i] = frame_hdr->ref_frame_idx[i];
486 memcpy (vp9_params->segmentFeatureEnable, sp->feature_enabled,
487 sizeof (sp->feature_enabled));
488 memcpy (vp9_params->segmentFeatureData, sp->feature_data,
489 sizeof (sp->feature_data));
491 if (!gst_nv_decoder_decode_picture (self->decoder, &self->params))
492 return GST_FLOW_ERROR;
498 gst_nv_vp9_dec_output_picture (GstVp9Decoder * decoder,
499 GstVideoCodecFrame * frame, GstVp9Picture * picture)
501 GstNvVp9Dec *self = GST_NV_VP9_DEC (decoder);
502 GstVideoDecoder *vdec = GST_VIDEO_DECODER (decoder);
503 GstNvDecoderFrame *decoder_frame;
505 GST_LOG_OBJECT (self, "Outputting picture %p", picture);
507 decoder_frame = (GstNvDecoderFrame *) gst_vp9_picture_get_user_data (picture);
508 if (!decoder_frame) {
509 GST_ERROR_OBJECT (self, "No decoder frame in picture %p", picture);
513 if (!gst_nv_decoder_finish_frame (self->decoder, vdec, decoder_frame,
514 &frame->output_buffer)) {
515 GST_ERROR_OBJECT (self, "Failed to handle output picture");
519 gst_vp9_picture_unref (picture);
521 return gst_video_decoder_finish_frame (vdec, frame);
524 gst_video_decoder_drop_frame (vdec, frame);
525 gst_vp9_picture_unref (picture);
527 return GST_FLOW_ERROR;
531 gst_nv_vp9_dec_get_preferred_output_delay (GstVp9Decoder * decoder,
534 /* Prefer to zero latency for live pipeline */
538 /* NVCODEC SDK uses 4 frame delay for better throughput performance */
546 guint cuda_device_id;
548 } GstNvVp9DecClassData;
551 gst_nv_vp9_dec_subclass_init (gpointer klass, GstNvVp9DecClassData * cdata)
553 GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
554 GstNvVp9DecClass *nvdec_class = (GstNvVp9DecClass *) (klass);
557 if (cdata->is_default) {
558 long_name = g_strdup_printf ("NVDEC VP9 Stateless Decoder");
560 long_name = g_strdup_printf ("NVDEC VP9 Stateless Decoder with device %d",
561 cdata->cuda_device_id);
564 gst_element_class_set_metadata (element_class, long_name,
565 "Codec/Decoder/Video/Hardware",
566 "NVIDIA VP9 video decoder", "Seungha Yang <seungha@centricular.com>");
569 gst_element_class_add_pad_template (element_class,
570 gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
572 gst_element_class_add_pad_template (element_class,
573 gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
576 nvdec_class->cuda_device_id = cdata->cuda_device_id;
578 gst_caps_unref (cdata->sink_caps);
579 gst_caps_unref (cdata->src_caps);
584 gst_nv_vp9_dec_register (GstPlugin * plugin, guint device_id, guint rank,
585 GstCaps * sink_caps, GstCaps * src_caps, gboolean is_primary)
587 GTypeQuery type_query;
588 GTypeInfo type_info = { 0, };
592 GstNvVp9DecClassData *cdata;
593 gboolean is_default = TRUE;
596 * element-nvvp9sldec:
601 cdata = g_new0 (GstNvVp9DecClassData, 1);
602 cdata->sink_caps = gst_caps_copy (sink_caps);
603 gst_caps_set_simple (cdata->sink_caps,
604 "alignment", G_TYPE_STRING, "frame", NULL);
605 GST_MINI_OBJECT_FLAG_SET (cdata->sink_caps,
606 GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED);
607 cdata->src_caps = gst_caps_ref (src_caps);
608 cdata->cuda_device_id = device_id;
610 g_type_query (GST_TYPE_NV_VP9_DEC, &type_query);
611 memset (&type_info, 0, sizeof (type_info));
612 type_info.class_size = type_query.class_size;
613 type_info.instance_size = type_query.instance_size;
614 type_info.class_init = (GClassInitFunc) gst_nv_vp9_dec_subclass_init;
615 type_info.class_data = cdata;
618 type_name = g_strdup ("GstNvVP9StatelessPrimaryDec");
619 feature_name = g_strdup ("nvvp9dec");
621 type_name = g_strdup ("GstNvVP9StatelessDec");
622 feature_name = g_strdup ("nvvp9sldec");
625 if (g_type_from_name (type_name) != 0) {
627 g_free (feature_name);
630 g_strdup_printf ("GstNvVP9StatelessPrimaryDevice%dDec", device_id);
631 feature_name = g_strdup_printf ("nvvp9device%ddec", device_id);
633 type_name = g_strdup_printf ("GstNvVP9StatelessDevice%dDec", device_id);
634 feature_name = g_strdup_printf ("nvvp9sldevice%ddec", device_id);
640 cdata->is_default = is_default;
641 subtype = g_type_register_static (GST_TYPE_NV_VP9_DEC,
642 type_name, &type_info, 0);
644 /* make lower rank than default device */
645 if (rank > 0 && !is_default)
648 if (!gst_element_register (plugin, feature_name, rank, subtype))
649 GST_WARNING ("Failed to register plugin '%s'", type_name);
652 g_free (feature_name);