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 "gstnvvp9dec.h"
25 #include "gstcudautils.h"
26 #include "gstnvdecoder.h"
30 GST_DEBUG_CATEGORY_STATIC (gst_nv_vp9_dec_debug);
31 #define GST_CAT_DEFAULT gst_nv_vp9_dec_debug
33 /* reference list 8 + 2 margin */
34 #define NUM_OUTPUT_VIEW 10
40 GstVideoCodecState *output_state;
42 GstCudaContext *context;
43 GstNvDecoder *decoder;
44 CUVIDPICPARAMS params;
47 GstVP9Profile profile;
50 struct _GstNvVp9DecClass
52 GstVp9DecoderClass parent_class;
56 #define gst_nv_vp9_dec_parent_class parent_class
63 G_DEFINE_TYPE (GstNvVp9Dec, gst_nv_vp9_dec, GST_TYPE_VP9_DECODER);
65 static void gst_nv_vp9_dec_set_context (GstElement * element,
66 GstContext * context);
67 static gboolean gst_nv_vp9_dec_open (GstVideoDecoder * decoder);
68 static gboolean gst_nv_vp9_dec_close (GstVideoDecoder * decoder);
69 static gboolean gst_nv_vp9_dec_negotiate (GstVideoDecoder * decoder);
70 static gboolean gst_nv_vp9_dec_decide_allocation (GstVideoDecoder *
71 decoder, GstQuery * query);
72 static gboolean gst_nv_vp9_dec_src_query (GstVideoDecoder * decoder,
76 static GstFlowReturn gst_nv_vp9_dec_new_sequence (GstVp9Decoder * decoder,
77 const GstVp9FrameHeader * frame_hdr);
78 static GstFlowReturn gst_nv_vp9_dec_new_picture (GstVp9Decoder * decoder,
79 GstVideoCodecFrame * frame, GstVp9Picture * picture);
80 static GstVp9Picture *gst_nv_vp9_dec_duplicate_picture (GstVp9Decoder *
81 decoder, GstVideoCodecFrame * frame, GstVp9Picture * picture);
82 static GstFlowReturn gst_nv_vp9_dec_decode_picture (GstVp9Decoder * decoder,
83 GstVp9Picture * picture, GstVp9Dpb * dpb);
84 static GstFlowReturn gst_nv_vp9_dec_output_picture (GstVp9Decoder *
85 decoder, GstVideoCodecFrame * frame, GstVp9Picture * picture);
86 static guint gst_nv_vp9_dec_get_preferred_output_delay (GstVp9Decoder * decoder,
90 gst_nv_vp9_dec_class_init (GstNvVp9DecClass * klass)
92 GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
93 GstVideoDecoderClass *decoder_class = GST_VIDEO_DECODER_CLASS (klass);
94 GstVp9DecoderClass *vp9decoder_class = GST_VP9_DECODER_CLASS (klass);
96 element_class->set_context = GST_DEBUG_FUNCPTR (gst_nv_vp9_dec_set_context);
98 decoder_class->open = GST_DEBUG_FUNCPTR (gst_nv_vp9_dec_open);
99 decoder_class->close = GST_DEBUG_FUNCPTR (gst_nv_vp9_dec_close);
100 decoder_class->negotiate = GST_DEBUG_FUNCPTR (gst_nv_vp9_dec_negotiate);
101 decoder_class->decide_allocation =
102 GST_DEBUG_FUNCPTR (gst_nv_vp9_dec_decide_allocation);
103 decoder_class->src_query = GST_DEBUG_FUNCPTR (gst_nv_vp9_dec_src_query);
105 vp9decoder_class->new_sequence =
106 GST_DEBUG_FUNCPTR (gst_nv_vp9_dec_new_sequence);
107 vp9decoder_class->new_picture =
108 GST_DEBUG_FUNCPTR (gst_nv_vp9_dec_new_picture);
109 vp9decoder_class->duplicate_picture =
110 GST_DEBUG_FUNCPTR (gst_nv_vp9_dec_duplicate_picture);
111 vp9decoder_class->decode_picture =
112 GST_DEBUG_FUNCPTR (gst_nv_vp9_dec_decode_picture);
113 vp9decoder_class->output_picture =
114 GST_DEBUG_FUNCPTR (gst_nv_vp9_dec_output_picture);
115 vp9decoder_class->get_preferred_output_delay =
116 GST_DEBUG_FUNCPTR (gst_nv_vp9_dec_get_preferred_output_delay);
118 GST_DEBUG_CATEGORY_INIT (gst_nv_vp9_dec_debug,
119 "nvvp9dec", 0, "NVIDIA VP9 Decoder");
121 gst_type_mark_as_plugin_api (GST_TYPE_NV_VP9_DEC, 0);
125 gst_nv_vp9_dec_init (GstNvVp9Dec * self)
130 gst_nv_vp9_dec_set_context (GstElement * element, GstContext * context)
132 GstNvVp9Dec *self = GST_NV_VP9_DEC (element);
133 GstNvVp9DecClass *klass = GST_NV_VP9_DEC_GET_CLASS (self);
135 GST_DEBUG_OBJECT (self, "set context %s",
136 gst_context_get_context_type (context));
138 if (gst_cuda_handle_set_context (element, context, klass->cuda_device_id,
144 gst_nv_decoder_handle_set_context (self->decoder, element, context);
147 GST_ELEMENT_CLASS (parent_class)->set_context (element, context);
151 gst_nv_vp9_dec_open (GstVideoDecoder * decoder)
153 GstVp9Decoder *vp9dec = GST_VP9_DECODER (decoder);
154 GstNvVp9Dec *self = GST_NV_VP9_DEC (decoder);
155 GstNvVp9DecClass *klass = GST_NV_VP9_DEC_GET_CLASS (self);
157 if (!gst_cuda_ensure_element_context (GST_ELEMENT (self),
158 klass->cuda_device_id, &self->context)) {
159 GST_ERROR_OBJECT (self, "Required element data is unavailable");
163 self->decoder = gst_nv_decoder_new (self->context);
164 if (!self->decoder) {
165 GST_ERROR_OBJECT (self, "Failed to create decoder object");
166 gst_clear_object (&self->context);
171 /* NVDEC doesn't support non-keyframe resolution change and it will result
172 * in outputting broken frames */
173 gst_vp9_decoder_set_non_keyframe_format_change_support (vp9dec, FALSE);
179 gst_nv_vp9_dec_close (GstVideoDecoder * decoder)
181 GstNvVp9Dec *self = GST_NV_VP9_DEC (decoder);
183 g_clear_pointer (&self->output_state, gst_video_codec_state_unref);
184 gst_clear_object (&self->decoder);
185 gst_clear_object (&self->context);
191 gst_nv_vp9_dec_negotiate (GstVideoDecoder * decoder)
193 GstNvVp9Dec *self = GST_NV_VP9_DEC (decoder);
194 GstVp9Decoder *vp9dec = GST_VP9_DECODER (decoder);
196 GST_DEBUG_OBJECT (self, "negotiate");
198 gst_nv_decoder_negotiate (self->decoder, decoder, vp9dec->input_state,
199 &self->output_state);
201 /* TODO: add support D3D11 memory */
203 return GST_VIDEO_DECODER_CLASS (parent_class)->negotiate (decoder);
207 gst_nv_vp9_dec_decide_allocation (GstVideoDecoder * decoder, GstQuery * query)
209 GstNvVp9Dec *self = GST_NV_VP9_DEC (decoder);
211 if (!gst_nv_decoder_decide_allocation (self->decoder, decoder, query)) {
212 GST_WARNING_OBJECT (self, "Failed to handle decide allocation");
216 return GST_VIDEO_DECODER_CLASS (parent_class)->decide_allocation
221 gst_nv_vp9_dec_src_query (GstVideoDecoder * decoder, GstQuery * query)
223 GstNvVp9Dec *self = GST_NV_VP9_DEC (decoder);
225 switch (GST_QUERY_TYPE (query)) {
226 case GST_QUERY_CONTEXT:
227 if (gst_cuda_handle_context_query (GST_ELEMENT (decoder), query,
230 } else if (self->decoder &&
231 gst_nv_decoder_handle_context_query (self->decoder, decoder, query)) {
239 return GST_VIDEO_DECODER_CLASS (parent_class)->src_query (decoder, query);
243 gst_nv_vp9_dec_new_sequence (GstVp9Decoder * decoder,
244 const GstVp9FrameHeader * frame_hdr)
246 GstNvVp9Dec *self = GST_NV_VP9_DEC (decoder);
247 GstVideoFormat out_format = GST_VIDEO_FORMAT_UNKNOWN;
250 GST_LOG_OBJECT (self, "new sequence");
252 self->width = frame_hdr->width;
253 self->height = frame_hdr->height;
254 self->profile = frame_hdr->profile;
256 if (self->profile == GST_VP9_PROFILE_0) {
257 out_format = GST_VIDEO_FORMAT_NV12;
258 } else if (self->profile == GST_VP9_PROFILE_2) {
259 if (frame_hdr->bit_depth == 10)
260 out_format = GST_VIDEO_FORMAT_P010_10LE;
262 out_format = GST_VIDEO_FORMAT_P016_LE;
265 if (out_format == GST_VIDEO_FORMAT_UNKNOWN) {
266 GST_ERROR_OBJECT (self, "Could not support profile %d", self->profile);
267 return GST_FLOW_NOT_NEGOTIATED;
270 gst_video_info_set_format (&info, out_format, self->width, self->height);
271 if (!gst_nv_decoder_configure (self->decoder,
272 cudaVideoCodec_VP9, &info, self->width, self->height,
273 /* +4 for render delay */
275 GST_ERROR_OBJECT (self, "Failed to configure decoder");
276 return GST_FLOW_NOT_NEGOTIATED;
279 if (!gst_video_decoder_negotiate (GST_VIDEO_DECODER (self))) {
280 GST_ERROR_OBJECT (self, "Failed to negotiate with downstream");
281 return GST_FLOW_NOT_NEGOTIATED;
284 memset (&self->params, 0, sizeof (CUVIDPICPARAMS));
286 self->params.CodecSpecific.vp9.colorSpace = frame_hdr->color_space;
292 gst_nv_vp9_dec_new_picture (GstVp9Decoder * decoder,
293 GstVideoCodecFrame * frame, GstVp9Picture * picture)
295 GstNvVp9Dec *self = GST_NV_VP9_DEC (decoder);
296 GstNvDecoderFrame *nv_frame;
298 nv_frame = gst_nv_decoder_new_frame (self->decoder);
300 GST_ERROR_OBJECT (self, "No available decoder frame");
301 return GST_FLOW_ERROR;
304 GST_LOG_OBJECT (self,
305 "New decoder frame %p (index %d)", nv_frame, nv_frame->index);
307 gst_vp9_picture_set_user_data (picture,
308 nv_frame, (GDestroyNotify) gst_nv_decoder_frame_unref);
313 static GstNvDecoderFrame *
314 gst_nv_vp9_dec_get_decoder_frame_from_picture (GstNvVp9Dec * self,
315 GstVp9Picture * picture)
317 GstNvDecoderFrame *frame;
319 frame = (GstNvDecoderFrame *) gst_vp9_picture_get_user_data (picture);
322 GST_DEBUG_OBJECT (self, "current picture does not have decoder frame");
327 static GstVp9Picture *
328 gst_nv_vp9_dec_duplicate_picture (GstVp9Decoder * decoder,
329 GstVideoCodecFrame * frame, GstVp9Picture * picture)
331 GstNvVp9Dec *self = GST_NV_VP9_DEC (decoder);
332 GstNvDecoderFrame *nv_frame;
333 GstVp9Picture *new_picture;
335 nv_frame = gst_nv_vp9_dec_get_decoder_frame_from_picture (self, picture);
338 GST_ERROR_OBJECT (self, "Parent picture does not have decoder frame");
342 new_picture = gst_vp9_picture_new ();
343 new_picture->frame_hdr = picture->frame_hdr;
345 gst_vp9_picture_set_user_data (new_picture,
346 gst_nv_decoder_frame_ref (nv_frame),
347 (GDestroyNotify) gst_nv_decoder_frame_unref);
353 gst_nv_vp9_dec_decode_picture (GstVp9Decoder * decoder,
354 GstVp9Picture * picture, GstVp9Dpb * dpb)
356 GstNvVp9Dec *self = GST_NV_VP9_DEC (decoder);
357 const GstVp9FrameHeader *frame_hdr = &picture->frame_hdr;
358 const GstVp9LoopFilterParams *lfp = &frame_hdr->loop_filter_params;
359 const GstVp9SegmentationParams *sp = &frame_hdr->segmentation_params;
360 const GstVp9QuantizationParams *qp = &frame_hdr->quantization_params;
361 CUVIDPICPARAMS *params = &self->params;
362 CUVIDVP9PICPARAMS *vp9_params = ¶ms->CodecSpecific.vp9;
363 GstNvDecoderFrame *frame;
364 GstNvDecoderFrame *other_frame;
366 guint8 ref_frame_map[GST_VP9_REF_FRAMES];
369 G_STATIC_ASSERT (G_N_ELEMENTS (vp9_params->mbRefLfDelta) ==
370 GST_VP9_MAX_REF_LF_DELTAS);
371 G_STATIC_ASSERT (G_N_ELEMENTS (vp9_params->mbModeLfDelta) ==
372 GST_VP9_MAX_MODE_LF_DELTAS);
373 G_STATIC_ASSERT (G_N_ELEMENTS (vp9_params->mb_segment_tree_probs) ==
374 GST_VP9_SEG_TREE_PROBS);
375 G_STATIC_ASSERT (sizeof (vp9_params->mb_segment_tree_probs) ==
376 sizeof (sp->segmentation_tree_probs));
377 G_STATIC_ASSERT (G_N_ELEMENTS (vp9_params->segment_pred_probs) ==
378 GST_VP9_PREDICTION_PROBS);
379 G_STATIC_ASSERT (sizeof (vp9_params->segment_pred_probs) ==
380 sizeof (sp->segmentation_pred_prob));
381 G_STATIC_ASSERT (G_N_ELEMENTS (vp9_params->refFrameSignBias) ==
382 GST_VP9_REFS_PER_FRAME + 1);
383 G_STATIC_ASSERT (sizeof (vp9_params->refFrameSignBias) ==
384 sizeof (frame_hdr->ref_frame_sign_bias));
385 G_STATIC_ASSERT (G_N_ELEMENTS (vp9_params->activeRefIdx) ==
386 GST_VP9_REFS_PER_FRAME);
387 G_STATIC_ASSERT (G_N_ELEMENTS (vp9_params->segmentFeatureEnable) ==
388 GST_VP9_MAX_SEGMENTS);
389 G_STATIC_ASSERT (sizeof (vp9_params->segmentFeatureEnable) ==
390 sizeof (sp->feature_enabled));
391 G_STATIC_ASSERT (G_N_ELEMENTS (vp9_params->segmentFeatureData) ==
392 GST_VP9_MAX_SEGMENTS);
393 G_STATIC_ASSERT (sizeof (vp9_params->segmentFeatureData) ==
394 sizeof (sp->feature_data));
396 GST_LOG_OBJECT (self, "Decode picture, size %" G_GSIZE_FORMAT, picture->size);
398 frame = gst_nv_vp9_dec_get_decoder_frame_from_picture (self, picture);
400 GST_ERROR_OBJECT (self, "Decoder frame is unavailable");
401 return GST_FLOW_ERROR;
404 params->nBitstreamDataLen = picture->size;
405 params->pBitstreamData = picture->data;
406 params->nNumSlices = 1;
407 params->pSliceDataOffsets = &offset;
409 params->PicWidthInMbs = GST_ROUND_UP_16 (frame_hdr->width) >> 4;
410 params->FrameHeightInMbs = GST_ROUND_UP_16 (frame_hdr->height) >> 4;
411 params->CurrPicIdx = frame->index;
413 vp9_params->width = frame_hdr->width;
414 vp9_params->height = frame_hdr->height;
416 for (i = 0; i < GST_VP9_REF_FRAMES; i++) {
417 if (dpb->pic_list[i]) {
418 other_frame = gst_nv_vp9_dec_get_decoder_frame_from_picture (self,
421 GST_ERROR_OBJECT (self, "Couldn't get decoder frame from picture");
425 ref_frame_map[i] = other_frame->index;
427 ref_frame_map[i] = 0xff;
431 vp9_params->LastRefIdx = ref_frame_map[frame_hdr->ref_frame_idx[0]];
432 vp9_params->GoldenRefIdx = ref_frame_map[frame_hdr->ref_frame_idx[1]];
433 vp9_params->AltRefIdx = ref_frame_map[frame_hdr->ref_frame_idx[2]];
435 vp9_params->profile = frame_hdr->profile;
436 vp9_params->frameContextIdx = frame_hdr->frame_context_idx;
437 vp9_params->frameType = frame_hdr->frame_type;
438 vp9_params->showFrame = frame_hdr->show_frame;
439 vp9_params->errorResilient = frame_hdr->error_resilient_mode;
440 vp9_params->frameParallelDecoding = frame_hdr->frame_parallel_decoding_mode;
441 vp9_params->subSamplingX = frame_hdr->subsampling_x;
442 vp9_params->subSamplingY = frame_hdr->subsampling_y;
443 vp9_params->intraOnly = frame_hdr->intra_only;
444 vp9_params->allow_high_precision_mv = frame_hdr->allow_high_precision_mv;
445 vp9_params->refreshEntropyProbs = frame_hdr->refresh_frame_context;
446 vp9_params->bitDepthMinus8Luma = frame_hdr->bit_depth - 8;
447 vp9_params->bitDepthMinus8Chroma = frame_hdr->bit_depth - 8;
449 vp9_params->loopFilterLevel = lfp->loop_filter_level;
450 vp9_params->loopFilterSharpness = lfp->loop_filter_sharpness;
451 vp9_params->modeRefLfEnabled = lfp->loop_filter_delta_enabled;
453 vp9_params->log2_tile_columns = frame_hdr->tile_cols_log2;
454 vp9_params->log2_tile_rows = frame_hdr->tile_rows_log2;
456 vp9_params->segmentEnabled = sp->segmentation_enabled;
457 vp9_params->segmentMapUpdate = sp->segmentation_update_map;
458 vp9_params->segmentMapTemporalUpdate = sp->segmentation_temporal_update;
459 vp9_params->segmentFeatureMode = sp->segmentation_abs_or_delta_update;
461 vp9_params->qpYAc = qp->base_q_idx;
462 vp9_params->qpYDc = qp->delta_q_y_dc;
463 vp9_params->qpChDc = qp->delta_q_uv_dc;
464 vp9_params->qpChAc = qp->delta_q_uv_ac;
466 vp9_params->resetFrameContext = frame_hdr->reset_frame_context;
467 vp9_params->mcomp_filter_type = frame_hdr->interpolation_filter;
468 vp9_params->frameTagSize = frame_hdr->frame_header_length_in_bytes;
469 vp9_params->offsetToDctParts = frame_hdr->header_size_in_bytes;
471 for (i = 0; i < GST_VP9_MAX_REF_LF_DELTAS; i++)
472 vp9_params->mbRefLfDelta[i] = lfp->loop_filter_ref_deltas[i];
474 for (i = 0; i < GST_VP9_MAX_MODE_LF_DELTAS; i++)
475 vp9_params->mbModeLfDelta[i] = lfp->loop_filter_mode_deltas[i];
477 memcpy (vp9_params->mb_segment_tree_probs, sp->segmentation_tree_probs,
478 sizeof (sp->segmentation_tree_probs));
479 memcpy (vp9_params->segment_pred_probs, sp->segmentation_pred_prob,
480 sizeof (sp->segmentation_pred_prob));
481 memcpy (vp9_params->refFrameSignBias, frame_hdr->ref_frame_sign_bias,
482 sizeof (frame_hdr->ref_frame_sign_bias));
484 for (i = 0; i < GST_VP9_REFS_PER_FRAME; i++) {
485 vp9_params->activeRefIdx[i] = frame_hdr->ref_frame_idx[i];
488 memcpy (vp9_params->segmentFeatureEnable, sp->feature_enabled,
489 sizeof (sp->feature_enabled));
490 memcpy (vp9_params->segmentFeatureData, sp->feature_data,
491 sizeof (sp->feature_data));
493 if (!gst_nv_decoder_decode_picture (self->decoder, &self->params))
494 return GST_FLOW_ERROR;
500 gst_nv_vp9_dec_output_picture (GstVp9Decoder * decoder,
501 GstVideoCodecFrame * frame, GstVp9Picture * picture)
503 GstNvVp9Dec *self = GST_NV_VP9_DEC (decoder);
504 GstVideoDecoder *vdec = GST_VIDEO_DECODER (decoder);
505 GstNvDecoderFrame *decoder_frame;
507 GST_LOG_OBJECT (self, "Outputting picture %p", picture);
509 decoder_frame = (GstNvDecoderFrame *) gst_vp9_picture_get_user_data (picture);
510 if (!decoder_frame) {
511 GST_ERROR_OBJECT (self, "No decoder frame in picture %p", picture);
515 if (!gst_nv_decoder_finish_frame (self->decoder, vdec, decoder_frame,
516 &frame->output_buffer)) {
517 GST_ERROR_OBJECT (self, "Failed to handle output picture");
521 gst_vp9_picture_unref (picture);
523 return gst_video_decoder_finish_frame (vdec, frame);
526 gst_video_decoder_drop_frame (vdec, frame);
527 gst_vp9_picture_unref (picture);
529 return GST_FLOW_ERROR;
533 gst_nv_vp9_dec_get_preferred_output_delay (GstVp9Decoder * decoder,
536 /* Prefer to zero latency for live pipeline */
540 /* NVCODEC SDK uses 4 frame delay for better throughput performance */
548 guint cuda_device_id;
550 } GstNvVp9DecClassData;
553 gst_nv_vp9_dec_subclass_init (gpointer klass, GstNvVp9DecClassData * cdata)
555 GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
556 GstNvVp9DecClass *nvdec_class = (GstNvVp9DecClass *) (klass);
559 if (cdata->is_default) {
560 long_name = g_strdup_printf ("NVDEC VP9 Stateless Decoder");
562 long_name = g_strdup_printf ("NVDEC VP9 Stateless Decoder with device %d",
563 cdata->cuda_device_id);
566 gst_element_class_set_metadata (element_class, long_name,
567 "Codec/Decoder/Video/Hardware",
568 "NVIDIA VP9 video decoder", "Seungha Yang <seungha@centricular.com>");
571 gst_element_class_add_pad_template (element_class,
572 gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
574 gst_element_class_add_pad_template (element_class,
575 gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
578 nvdec_class->cuda_device_id = cdata->cuda_device_id;
580 gst_caps_unref (cdata->sink_caps);
581 gst_caps_unref (cdata->src_caps);
586 gst_nv_vp9_dec_register (GstPlugin * plugin, guint device_id, guint rank,
587 GstCaps * sink_caps, GstCaps * src_caps, gboolean is_primary)
589 GTypeQuery type_query;
590 GTypeInfo type_info = { 0, };
594 GstNvVp9DecClassData *cdata;
595 gboolean is_default = TRUE;
598 * element-nvvp9sldec:
603 cdata = g_new0 (GstNvVp9DecClassData, 1);
604 cdata->sink_caps = gst_caps_copy (sink_caps);
605 gst_caps_set_simple (cdata->sink_caps,
606 "alignment", G_TYPE_STRING, "frame", NULL);
607 GST_MINI_OBJECT_FLAG_SET (cdata->sink_caps,
608 GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED);
609 cdata->src_caps = gst_caps_ref (src_caps);
610 cdata->cuda_device_id = device_id;
612 g_type_query (GST_TYPE_NV_VP9_DEC, &type_query);
613 memset (&type_info, 0, sizeof (type_info));
614 type_info.class_size = type_query.class_size;
615 type_info.instance_size = type_query.instance_size;
616 type_info.class_init = (GClassInitFunc) gst_nv_vp9_dec_subclass_init;
617 type_info.class_data = cdata;
620 type_name = g_strdup ("GstNvVP9StatelessPrimaryDec");
621 feature_name = g_strdup ("nvvp9dec");
623 type_name = g_strdup ("GstNvVP9StatelessDec");
624 feature_name = g_strdup ("nvvp9sldec");
627 if (g_type_from_name (type_name) != 0) {
629 g_free (feature_name);
632 g_strdup_printf ("GstNvVP9StatelessPrimaryDevice%dDec", device_id);
633 feature_name = g_strdup_printf ("nvvp9device%ddec", device_id);
635 type_name = g_strdup_printf ("GstNvVP9StatelessDevice%dDec", device_id);
636 feature_name = g_strdup_printf ("nvvp9sldevice%ddec", device_id);
642 cdata->is_default = is_default;
643 subtype = g_type_register_static (GST_TYPE_NV_VP9_DEC,
644 type_name, &type_info, 0);
646 /* make lower rank than default device */
647 if (rank > 0 && !is_default)
650 if (!gst_element_register (plugin, feature_name, rank, subtype))
651 GST_WARNING ("Failed to register plugin '%s'", type_name);
654 g_free (feature_name);