msdkenc: support tune property in msdkh264enc and msdkh265enc
[platform/upstream/gstreamer.git] / sys / msdk / gstmsdkh265enc.c
1 /* GStreamer Intel MSDK plugin
2  * Copyright (c) 2016, Oblong Industries, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  *    this list of conditions and the following disclaimer.
10  *
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.
14  *
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.
18  *
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 NEGLIGENCE
28  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31
32 #ifdef HAVE_CONFIG_H
33 #  include <config.h>
34 #endif
35
36 #include <gst/allocators/gstdmabuf.h>
37
38 #include "gstmsdkh265enc.h"
39
40 GST_DEBUG_CATEGORY_EXTERN (gst_msdkh265enc_debug);
41 #define GST_CAT_DEFAULT gst_msdkh265enc_debug
42
43 enum
44 {
45 #ifndef GST_REMOVE_DEPRECATED
46   PROP_LOW_POWER = GST_MSDKENC_PROP_MAX,
47   PROP_TILE_ROW,
48 #else
49   PROP_TILE_ROW = GST_MSDKENC_PROP_MAX,
50 #endif
51   PROP_TILE_COL,
52   PROP_MAX_SLICE_SIZE,
53   PROP_TUNE_MODE,
54 };
55
56 enum
57 {
58   GST_MSDK_FLAG_LOW_POWER = 1 << 0,
59   GST_MSDK_FLAG_TUNE_MODE = 1 << 1,
60 };
61
62 #define PROP_LOWPOWER_DEFAULT           FALSE
63 #define PROP_TILE_ROW_DEFAULT           1
64 #define PROP_TILE_COL_DEFAULT           1
65 #define PROP_MAX_SLICE_SIZE_DEFAULT     0
66 #define PROP_TUNE_MODE_DEFAULT          MFX_CODINGOPTION_UNKNOWN
67
68 #define RAW_FORMATS "NV12, I420, YV12, YUY2, UYVY, BGRA, P010_10LE, VUYA"
69 #define PROFILES    "main, main-10, main-444"
70
71 #if (MFX_VERSION >= 1031)
72 #define COMMON_FORMAT "{ " RAW_FORMATS ", Y410, Y210, P012_LE }"
73 #define PRFOLIE_STR   "{ " PROFILES ", main-444-10, main-422-10, main-12 }"
74 #elif (MFX_VERSION >= 1027)
75 #define COMMON_FORMAT "{ " RAW_FORMATS ", Y410, Y210 }"
76 #define PRFOLIE_STR   "{ " PROFILES ", main-444-10, main-422-10 }"
77 #else
78 #define COMMON_FORMAT "{ " RAW_FORMATS " }"
79 #define PRFOLIE_STR   "{ " PROFILES " }"
80 #endif
81
82 static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
83     GST_PAD_SINK,
84     GST_PAD_ALWAYS,
85     GST_STATIC_CAPS (GST_MSDK_CAPS_STR (COMMON_FORMAT,
86             "{ NV12, P010_10LE }")));
87
88 static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
89     GST_PAD_SRC,
90     GST_PAD_ALWAYS,
91     GST_STATIC_CAPS ("video/x-h265, "
92         "framerate = (fraction) [0/1, MAX], "
93         "width = (int) [ 1, MAX ], height = (int) [ 1, MAX ], "
94         "stream-format = (string) byte-stream , alignment = (string) au , "
95         "profile = (string) " PRFOLIE_STR)
96     );
97
98 #define gst_msdkh265enc_parent_class parent_class
99 G_DEFINE_TYPE (GstMsdkH265Enc, gst_msdkh265enc, GST_TYPE_MSDKENC);
100
101 static void
102 gst_msdkh265enc_insert_sei (GstMsdkH265Enc * thiz, GstVideoCodecFrame * frame,
103     GstMemory * sei_mem)
104 {
105   GstBuffer *new_buffer;
106
107   if (!thiz->parser)
108     thiz->parser = gst_h265_parser_new ();
109
110   new_buffer = gst_h265_parser_insert_sei (thiz->parser,
111       frame->output_buffer, sei_mem);
112
113   if (!new_buffer) {
114     GST_WARNING_OBJECT (thiz, "Cannot insert SEI nal into AU buffer");
115     return;
116   }
117
118   gst_buffer_unref (frame->output_buffer);
119   frame->output_buffer = new_buffer;
120 }
121
122 static void
123 gst_msdkh265enc_add_cc (GstMsdkH265Enc * thiz, GstVideoCodecFrame * frame)
124 {
125   GstVideoCaptionMeta *cc_meta;
126   gpointer iter = NULL;
127   GstBuffer *in_buf = frame->input_buffer;
128   GstMemory *mem = NULL;
129
130   if (thiz->cc_sei_array)
131     g_array_set_size (thiz->cc_sei_array, 0);
132
133   while ((cc_meta =
134           (GstVideoCaptionMeta *) gst_buffer_iterate_meta_filtered (in_buf,
135               &iter, GST_VIDEO_CAPTION_META_API_TYPE))) {
136     GstH265SEIMessage sei;
137     GstH265RegisteredUserData *rud;
138     guint8 *data;
139
140     if (cc_meta->caption_type != GST_VIDEO_CAPTION_TYPE_CEA708_RAW)
141       continue;
142
143     memset (&sei, 0, sizeof (GstH265SEIMessage));
144     sei.payloadType = GST_H265_SEI_REGISTERED_USER_DATA;
145     rud = &sei.payload.registered_user_data;
146
147     rud->country_code = 181;
148     rud->size = cc_meta->size + 10;
149
150     data = g_malloc (rud->size);
151     memcpy (data + 9, cc_meta->data, cc_meta->size);
152
153     data[0] = 0;                /* 16-bits itu_t_t35_provider_code */
154     data[1] = 49;
155     data[2] = 'G';              /* 32-bits ATSC_user_identifier */
156     data[3] = 'A';
157     data[4] = '9';
158     data[5] = '4';
159     data[6] = 3;                /* 8-bits ATSC1_data_user_data_type_code */
160     /* 8-bits:
161      * 1 bit process_em_data_flag (0)
162      * 1 bit process_cc_data_flag (1)
163      * 1 bit additional_data_flag (0)
164      * 5-bits cc_count
165      */
166     data[7] = ((cc_meta->size / 3) & 0x1f) | 0x40;
167     data[8] = 255;              /* 8 bits em_data, unused */
168     data[cc_meta->size + 9] = 255;      /* 8 marker bits */
169
170     rud->data = data;
171
172     if (!thiz->cc_sei_array) {
173       thiz->cc_sei_array =
174           g_array_new (FALSE, FALSE, sizeof (GstH265SEIMessage));
175       g_array_set_clear_func (thiz->cc_sei_array,
176           (GDestroyNotify) gst_h265_sei_free);
177     }
178
179     g_array_append_val (thiz->cc_sei_array, sei);
180   }
181
182   if (!thiz->cc_sei_array || !thiz->cc_sei_array->len)
183     return;
184
185   /* layer_id and temporal_id will be updated by parser later */
186   mem = gst_h265_create_sei_memory (0, 1, 4, thiz->cc_sei_array);
187
188   if (!mem) {
189     GST_WARNING_OBJECT (thiz, "Cannot create SEI nal unit");
190     return;
191   }
192
193   GST_DEBUG_OBJECT (thiz,
194       "Inserting %d closed caption SEI message(s)", thiz->cc_sei_array->len);
195
196   gst_msdkh265enc_insert_sei (thiz, frame, mem);
197   gst_memory_unref (mem);
198 }
199
200 static GstFlowReturn
201 gst_msdkh265enc_pre_push (GstVideoEncoder * encoder, GstVideoCodecFrame * frame)
202 {
203   GstMsdkH265Enc *thiz = GST_MSDKH265ENC (encoder);
204
205   gst_msdkh265enc_add_cc (thiz, frame);
206
207   return GST_FLOW_OK;
208 }
209
210 static gboolean
211 gst_msdkh265enc_set_format (GstMsdkEnc * encoder)
212 {
213   return TRUE;
214 }
215
216 static gboolean
217 gst_msdkh265enc_configure (GstMsdkEnc * encoder)
218 {
219   GstMsdkH265Enc *h265enc = GST_MSDKH265ENC (encoder);
220   mfxSession session;
221   const mfxPluginUID *uid;
222
223   session = gst_msdk_context_get_session (encoder->context);
224
225   if (encoder->hardware)
226     uid = &MFX_PLUGINID_HEVCE_HW;
227   else
228     uid = &MFX_PLUGINID_HEVCE_SW;
229
230   if (!gst_msdk_load_plugin (session, uid, 1, "msdkh265enc"))
231     return FALSE;
232
233   encoder->param.mfx.CodecId = MFX_CODEC_HEVC;
234
235   switch (encoder->param.mfx.FrameInfo.FourCC) {
236     case MFX_FOURCC_P010:
237       encoder->param.mfx.CodecProfile = MFX_PROFILE_HEVC_MAIN10;
238       break;
239     case MFX_FOURCC_AYUV:
240     case MFX_FOURCC_YUY2:
241 #if (MFX_VERSION >= 1027)
242     case MFX_FOURCC_Y410:
243     case MFX_FOURCC_Y210:
244 #endif
245 #if (MFX_VERSION >= 1031)
246     case MFX_FOURCC_P016:
247 #endif
248       encoder->param.mfx.CodecProfile = MFX_PROFILE_HEVC_REXT;
249       break;
250     default:
251       encoder->param.mfx.CodecProfile = MFX_PROFILE_HEVC_MAIN;
252   }
253
254   /* IdrInterval field of MediaSDK HEVC encoder behaves differently
255    * than other encoders. IdrInteval == 1 indicate every
256    * I-frame should be an IDR, IdrInteval == 2 means every other
257    * I-frame is an IDR etc. So we generalize the behaviour of property
258    * "i-frames" by incrementing the value by one in each case*/
259   encoder->param.mfx.IdrInterval += 1;
260
261   /* Enable Extended coding options */
262   encoder->option2.MaxSliceSize = h265enc->max_slice_size;
263   gst_msdkenc_ensure_extended_coding_options (encoder);
264
265   if (h265enc->num_tile_rows > 1 || h265enc->num_tile_cols > 1) {
266     h265enc->ext_tiles.Header.BufferId = MFX_EXTBUFF_HEVC_TILES;
267     h265enc->ext_tiles.Header.BufferSz = sizeof (h265enc->ext_tiles);
268     h265enc->ext_tiles.NumTileRows = h265enc->num_tile_rows;
269     h265enc->ext_tiles.NumTileColumns = h265enc->num_tile_cols;
270
271     gst_msdkenc_add_extra_param (encoder,
272         (mfxExtBuffer *) & h265enc->ext_tiles);
273
274     /* Set a valid value to NumSlice */
275     if (encoder->param.mfx.NumSlice == 0)
276       encoder->param.mfx.NumSlice =
277           h265enc->num_tile_rows * h265enc->num_tile_cols;
278   }
279
280   encoder->param.mfx.LowPower = h265enc->tune_mode;
281
282   return TRUE;
283 }
284
285 static inline const gchar *
286 level_to_string (gint level)
287 {
288   switch (level) {
289     case MFX_LEVEL_HEVC_1:
290       return "1";
291     case MFX_LEVEL_HEVC_2:
292       return "2";
293     case MFX_LEVEL_HEVC_21:
294       return "2.1";
295     case MFX_LEVEL_HEVC_3:
296       return "3";
297     case MFX_LEVEL_HEVC_31:
298       return "3.1";
299     case MFX_LEVEL_HEVC_4:
300       return "4";
301     case MFX_LEVEL_HEVC_41:
302       return "4.1";
303     case MFX_LEVEL_HEVC_5:
304       return "5";
305     case MFX_LEVEL_HEVC_51:
306       return "5.1";
307     case MFX_LEVEL_HEVC_52:
308       return "5.2";
309     case MFX_LEVEL_HEVC_6:
310       return "6";
311     case MFX_LEVEL_HEVC_61:
312       return "6.1";
313     case MFX_LEVEL_HEVC_62:
314       return "6.2";
315     default:
316       break;
317   }
318
319   return NULL;
320 }
321
322 static GstCaps *
323 gst_msdkh265enc_set_src_caps (GstMsdkEnc * encoder)
324 {
325   GstCaps *caps;
326   GstStructure *structure;
327   const gchar *level;
328
329   caps = gst_caps_new_empty_simple ("video/x-h265");
330   structure = gst_caps_get_structure (caps, 0);
331
332   gst_structure_set (structure, "stream-format", G_TYPE_STRING, "byte-stream",
333       NULL);
334
335   gst_structure_set (structure, "alignment", G_TYPE_STRING, "au", NULL);
336
337   switch (encoder->param.mfx.FrameInfo.FourCC) {
338     case MFX_FOURCC_P010:
339       gst_structure_set (structure, "profile", G_TYPE_STRING, "main-10", NULL);
340       break;
341     case MFX_FOURCC_AYUV:
342       gst_structure_set (structure, "profile", G_TYPE_STRING, "main-444", NULL);
343       break;
344     case MFX_FOURCC_YUY2:
345       /* The profile is main-422-10 for 8-bit 422 */
346       gst_structure_set (structure, "profile", G_TYPE_STRING, "main-422-10",
347           NULL);
348       break;
349 #if (MFX_VERSION >= 1027)
350     case MFX_FOURCC_Y410:
351       gst_structure_set (structure, "profile", G_TYPE_STRING, "main-444-10",
352           NULL);
353       break;
354     case MFX_FOURCC_Y210:
355       gst_structure_set (structure, "profile", G_TYPE_STRING, "main-422-10",
356           NULL);
357       break;
358 #endif
359 #if (MFX_VERSION >= 1031)
360     case MFX_FOURCC_P016:
361       gst_structure_set (structure, "profile", G_TYPE_STRING, "main-12", NULL);
362       break;
363 #endif
364     default:
365       gst_structure_set (structure, "profile", G_TYPE_STRING, "main", NULL);
366       break;
367   }
368
369   level = level_to_string (encoder->param.mfx.CodecLevel);
370   if (level)
371     gst_structure_set (structure, "level", G_TYPE_STRING, level, NULL);
372
373   return caps;
374 }
375
376 static void
377 gst_msdkh265enc_finalize (GObject * object)
378 {
379   GstMsdkH265Enc *thiz = GST_MSDKH265ENC (object);
380
381   if (thiz->parser)
382     gst_h265_parser_free (thiz->parser);
383   if (thiz->cc_sei_array)
384     g_array_unref (thiz->cc_sei_array);
385
386   G_OBJECT_CLASS (parent_class)->finalize (object);
387 }
388
389 static void
390 gst_msdkh265enc_set_property (GObject * object, guint prop_id,
391     const GValue * value, GParamSpec * pspec)
392 {
393   GstMsdkH265Enc *thiz = GST_MSDKH265ENC (object);
394
395   if (gst_msdkenc_set_common_property (object, prop_id, value, pspec))
396     return;
397
398   GST_OBJECT_LOCK (thiz);
399
400   switch (prop_id) {
401 #ifndef GST_REMOVE_DEPRECATED
402     case PROP_LOW_POWER:
403       thiz->lowpower = g_value_get_boolean (value);
404       thiz->prop_flag |= GST_MSDK_FLAG_LOW_POWER;
405
406       /* Ignore it if user set tune mode explicitly */
407       if (!(thiz->prop_flag & GST_MSDK_FLAG_TUNE_MODE))
408         thiz->tune_mode =
409             thiz->lowpower ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
410
411       break;
412 #endif
413
414     case PROP_TILE_ROW:
415       thiz->num_tile_rows = g_value_get_uint (value);
416       break;
417
418     case PROP_TILE_COL:
419       thiz->num_tile_cols = g_value_get_uint (value);
420       break;
421
422     case PROP_MAX_SLICE_SIZE:
423       thiz->max_slice_size = g_value_get_uint (value);
424       break;
425
426     case PROP_TUNE_MODE:
427       thiz->tune_mode = g_value_get_enum (value);
428       thiz->prop_flag |= GST_MSDK_FLAG_TUNE_MODE;
429       break;
430
431     default:
432       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
433       break;
434   }
435   GST_OBJECT_UNLOCK (thiz);
436 }
437
438 static void
439 gst_msdkh265enc_get_property (GObject * object, guint prop_id, GValue * value,
440     GParamSpec * pspec)
441 {
442   GstMsdkH265Enc *thiz = GST_MSDKH265ENC (object);
443
444   if (gst_msdkenc_get_common_property (object, prop_id, value, pspec))
445     return;
446
447   GST_OBJECT_LOCK (thiz);
448   switch (prop_id) {
449 #ifndef GST_REMOVE_DEPRECATED
450     case PROP_LOW_POWER:
451       g_value_set_boolean (value, thiz->lowpower);
452       break;
453 #endif
454
455     case PROP_TILE_ROW:
456       g_value_set_uint (value, thiz->num_tile_rows);
457       break;
458
459     case PROP_TILE_COL:
460       g_value_set_uint (value, thiz->num_tile_cols);
461       break;
462
463     case PROP_MAX_SLICE_SIZE:
464       g_value_set_uint (value, thiz->max_slice_size);
465       break;
466
467     case PROP_TUNE_MODE:
468       g_value_set_enum (value, thiz->tune_mode);
469       break;
470
471     default:
472       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
473       break;
474   }
475   GST_OBJECT_UNLOCK (thiz);
476 }
477
478 static gboolean
479 gst_msdkh265enc_need_reconfig (GstMsdkEnc * encoder, GstVideoCodecFrame * frame)
480 {
481   GstMsdkH265Enc *h265enc = GST_MSDKH265ENC (encoder);
482
483   return gst_msdkenc_get_roi_params (encoder, frame, h265enc->roi);
484 }
485
486 static void
487 gst_msdkh265enc_set_extra_params (GstMsdkEnc * encoder,
488     GstVideoCodecFrame * frame)
489 {
490   GstMsdkH265Enc *h265enc = GST_MSDKH265ENC (encoder);
491
492   if (h265enc->roi[0].NumROI)
493     gst_msdkenc_add_extra_param (encoder, (mfxExtBuffer *) & h265enc->roi[0]);
494 }
495
496 static gboolean
497 gst_msdkh265enc_need_conversion (GstMsdkEnc * encoder, GstVideoInfo * info,
498     GstVideoFormat * out_format)
499 {
500   GstMsdkH265Enc *h265enc = GST_MSDKH265ENC (encoder);
501
502   switch (GST_VIDEO_INFO_FORMAT (info)) {
503     case GST_VIDEO_FORMAT_NV12:
504     case GST_VIDEO_FORMAT_P010_10LE:
505     case GST_VIDEO_FORMAT_VUYA:
506 #if (MFX_VERSION >= 1027)
507     case GST_VIDEO_FORMAT_Y410:
508     case GST_VIDEO_FORMAT_Y210:
509 #endif
510 #if (MFX_VERSION >= 1031)
511     case GST_VIDEO_FORMAT_P012_LE:
512 #endif
513       return FALSE;
514
515     case GST_VIDEO_FORMAT_YUY2:
516 #if (MFX_VERSION >= 1027)
517       if (encoder->codename >= MFX_PLATFORM_ICELAKE &&
518           h265enc->tune_mode == MFX_CODINGOPTION_OFF)
519         return FALSE;
520 #endif
521     default:
522       if (GST_VIDEO_INFO_COMP_DEPTH (info, 0) == 10)
523         *out_format = GST_VIDEO_FORMAT_P010_10LE;
524       else
525         *out_format = GST_VIDEO_FORMAT_NV12;
526       return TRUE;
527   }
528 }
529
530 static void
531 gst_msdkh265enc_class_init (GstMsdkH265EncClass * klass)
532 {
533   GObjectClass *gobject_class;
534   GstElementClass *element_class;
535   GstVideoEncoderClass *videoencoder_class;
536   GstMsdkEncClass *encoder_class;
537
538   gobject_class = G_OBJECT_CLASS (klass);
539   element_class = GST_ELEMENT_CLASS (klass);
540   videoencoder_class = GST_VIDEO_ENCODER_CLASS (klass);
541   encoder_class = GST_MSDKENC_CLASS (klass);
542
543   gobject_class->finalize = gst_msdkh265enc_finalize;
544   gobject_class->set_property = gst_msdkh265enc_set_property;
545   gobject_class->get_property = gst_msdkh265enc_get_property;
546
547   videoencoder_class->pre_push = gst_msdkh265enc_pre_push;
548
549   encoder_class->set_format = gst_msdkh265enc_set_format;
550   encoder_class->configure = gst_msdkh265enc_configure;
551   encoder_class->set_src_caps = gst_msdkh265enc_set_src_caps;
552   encoder_class->need_reconfig = gst_msdkh265enc_need_reconfig;
553   encoder_class->set_extra_params = gst_msdkh265enc_set_extra_params;
554   encoder_class->need_conversion = gst_msdkh265enc_need_conversion;
555
556   gst_msdkenc_install_common_properties (encoder_class);
557
558 #ifndef GST_REMOVE_DEPRECATED
559   g_object_class_install_property (gobject_class, PROP_LOW_POWER,
560       g_param_spec_boolean ("low-power", "Low power",
561           "Enable low power mode (DEPRECATED, use tune instead)",
562           PROP_LOWPOWER_DEFAULT,
563           G_PARAM_DEPRECATED | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
564 #endif
565
566   g_object_class_install_property (gobject_class, PROP_TILE_ROW,
567       g_param_spec_uint ("num-tile-rows", "number of rows for tiled encoding",
568           "number of rows for tiled encoding",
569           1, 8192, PROP_TILE_ROW_DEFAULT,
570           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
571
572   g_object_class_install_property (gobject_class, PROP_TILE_COL,
573       g_param_spec_uint ("num-tile-cols",
574           "number of columns for tiled encoding",
575           "number of columns for tiled encoding", 1, 8192,
576           PROP_TILE_COL_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
577
578   g_object_class_install_property (gobject_class, PROP_MAX_SLICE_SIZE,
579       g_param_spec_uint ("max-slice-size", "Max Slice Size",
580           "Maximum slice size in bytes (if enabled MSDK will ignore the control over num-slices)",
581           0, G_MAXUINT32, PROP_MAX_SLICE_SIZE_DEFAULT,
582           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
583
584   g_object_class_install_property (gobject_class, PROP_TUNE_MODE,
585       g_param_spec_enum ("tune", "Encoder tuning",
586           "Encoder tuning option",
587           gst_msdkenc_tune_mode_get_type (), PROP_TUNE_MODE_DEFAULT,
588           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
589
590   gst_element_class_set_static_metadata (element_class,
591       "Intel MSDK H265 encoder",
592       "Codec/Encoder/Video/Hardware",
593       "H265 video encoder based on Intel Media SDK",
594       "Josep Torra <jtorra@oblong.com>");
595
596   gst_element_class_add_static_pad_template (element_class, &sink_factory);
597   gst_element_class_add_static_pad_template (element_class, &src_factory);
598 }
599
600 static void
601 gst_msdkh265enc_init (GstMsdkH265Enc * thiz)
602 {
603   GstMsdkEnc *msdk_enc = (GstMsdkEnc *) thiz;
604   thiz->lowpower = PROP_LOWPOWER_DEFAULT;
605   thiz->num_tile_rows = PROP_TILE_ROW_DEFAULT;
606   thiz->num_tile_cols = PROP_TILE_COL_DEFAULT;
607   thiz->max_slice_size = PROP_MAX_SLICE_SIZE_DEFAULT;
608   thiz->tune_mode = PROP_TUNE_MODE_DEFAULT;
609   msdk_enc->num_extra_frames = 1;
610 }