Removed redundant definitions in h264enc fields
[glsdk/gst-plugin-ducati.git] / src / gstducatih264enc.c
1 /* GStreamer
2  * Copyright (c) 2011, Texas Instruments Incorporated
3  * Copyright (c) 2011, Collabora Ltd.
4  *
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.
9  *
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.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  *
20  * Author: Alessandro Decina <alessandro.decina@collabora.com>
21  */
23 #ifdef HAVE_CONFIG_H
24 #include "config.h"
25 #endif
27 #include "gstducati.h"
28 #include "gstducatih264enc.h"
30 #include <string.h>
32 #include <math.h>
34 #define GST_CAT_DEFAULT gst_ducati_debug
36 #define DEFAULT_PROFILE IH264_HIGH_PROFILE
37 #define DEFAULT_LEVEL IH264_LEVEL_40
38 #define DEFAULT_QPI 28
39 #define DEFAULT_QP_MAX_I 36
40 #define DEFAULT_QP_MIN_I 10
41 /* 2 x targetBitRate for VBR Rate Control */
42 #define DEFAULT_HRD_BUFFER_SIZE 40960000
43 #define DEFAULT_INTER_INTERVAL 4
45 #define GST_TYPE_DUCATI_H264ENC_PROFILE (gst_ducati_h264enc_profile_get_type ())
46 #define GST_TYPE_DUCATI_H264ENC_LEVEL (gst_ducati_h264enc_level_get_type ())
47 #define GST_TYPE_DUCATI_H264ENC_RCPP (gst_ducati_h264enc_get_rate_control_params_preset_type ())
48 #define GST_TYPE_DUCATI_H264ENC_RATE_CONTROL_ALGO (gst_ducati_h264enc_get_rate_control_algo_type ())
49 #define GST_TYPE_DUCATI_H264ENC_ENTROPY_CODING_MODE (gst_ducati_h264enc_get_entropy_coding_mode_type ())
50 #define GST_TYPE_DUCATI_H264ENC_SLICE_MODE (gst_ducati_h264enc_get_slice_mode_type ())
53 enum
54 {
55   LAST_SIGNAL
56 };
58 enum
59 {
60   PROP_0,
61   PROP_PROFILE,
62   PROP_LEVEL,
63   PROP_RATE_CONTROL_PARAMS_PRESET,
64   PROP_RATE_CONTROL_ALGO,
65   PROP_QPI,
66   PROP_QP_MAX_I,
67   PROP_QP_MIN_I,
68   PROP_HRD_BUFFER_SIZE,
69   PROP_ENTROPY_CODING_MODE,
70   PROP_INTER_INTERVAL,
71   PROP_SLICE_MODE,
72 };
74 static void gst_ducati_h264enc_set_property (GObject * object, guint prop_id,
75     const GValue * value, GParamSpec * pspec);
76 static void gst_ducati_h264enc_get_property (GObject * object, guint prop_id,
77     GValue * value, GParamSpec * pspec);
79 static gboolean gst_ducati_h264enc_allocate_params (GstDucatiVidEnc *
80     self, gint params_sz, gint dynparams_sz, gint status_sz, gint inargs_sz,
81     gint outargs_sz);
82 static gboolean gst_ducati_h264enc_configure (GstDucatiVidEnc * self);
83 static gboolean gst_ducati_h264enc_is_sync_point (GstDucatiVidEnc * enc,
84     int type);
87 static GstStaticPadTemplate gst_ducati_h264enc_sink_template =
88 GST_STATIC_PAD_TEMPLATE ("sink",
89     GST_PAD_SINK,
90     GST_PAD_ALWAYS,
91     GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("NV12"))
92     );
94 static GstStaticPadTemplate gst_ducati_h264enc_src_template =
95 GST_STATIC_PAD_TEMPLATE ("src",
96     GST_PAD_SRC,
97     GST_PAD_ALWAYS,
98     GST_STATIC_CAPS
99     ("video/x-h264, alignment=(string)au, stream-format=(string)byte-stream")
100     );
102 GST_BOILERPLATE (GstDucatiH264Enc, gst_ducati_h264enc, GstDucatiVidEnc,
103     GST_TYPE_DUCATIVIDENC);
106 static GType
107 gst_ducati_h264enc_profile_get_type (void)
109   static GType type = 0;
111   if (!type) {
112     static const GEnumValue vals[] = {
113       {IH264_BASELINE_PROFILE, "Base Profile", "baseline"},
114       {IH264_MAIN_PROFILE, "Main Profile", "main"},
115       {IH264_EXTENDED_PROFILE, "Extended Profile", "extended"},
116       {IH264_HIGH_PROFILE, "High Profile", "high"},
117       {IH264_HIGH10_PROFILE, "High 10 Profile", "high-10"},
118       {IH264_HIGH422_PROFILE, "High 4:2:2 Profile", "high-422"},
119       {0, NULL, NULL},
120     };
122     type = g_enum_register_static ("GstDucatiH264EncProfile", vals);
123   }
125   return type;
128 static GType
129 gst_ducati_h264enc_get_rate_control_params_preset_type (void)
131   static GType type = 0;
133   if (!type) {
134     static const GEnumValue vals[] = {
135       {IH264_RATECONTROLPARAMS_DEFAULT, "Rate Control params preset default",
136           "rate-control-params-preset-default"},
137       {IH264_RATECONTROLPARAMS_USERDEFINED, "User defined rate control",
138           "rate-control-params-preset-user-defined"},
139       {IH264_RATECONTROLPARAMS_EXISTING, "Existing rate control params",
140           "rate-control-params-preset-existing"},
141       {0, NULL, NULL},
142     };
144     type = g_enum_register_static ("GstDucatiH264EncRateControlParams", vals);
145   }
147   return type;
150 static GType
151 gst_ducati_h264enc_get_rate_control_algo_type (void)
153   static GType type = 0;
155   if (!type) {
156     static const GEnumValue vals[] = {
157       {IH264_RATECONTROL_PRC, "Perceptual rate control",
158           "perceptual-rate-control"},
159       {IH264_RATECONTROL_PRC_LOW_DELAY, "Low delay rate control",
160           "low-delay-rate-control"},
161       {0, NULL, NULL},
162     };
164     type = g_enum_register_static ("GstDucatiH264EncRateControlAlgo", vals);
165   }
167   return type;
170 static GType
171 gst_ducati_h264enc_level_get_type (void)
173   static GType type = 0;
175   if (!type) {
176     static const GEnumValue vals[] = {
177       {IH264_LEVEL_10, "Level 1", "level-1"},
178       {IH264_LEVEL_1b, "Level 1b", "level-1b"},
179       {IH264_LEVEL_11, "Level 11", "level-11"},
180       {IH264_LEVEL_12, "Level 12", "level-12"},
181       {IH264_LEVEL_13, "Level 13", "level-13"},
182       {IH264_LEVEL_20, "Level 2", "level-2"},
183       {IH264_LEVEL_21, "Level 21", "level-21"},
184       {IH264_LEVEL_22, "Level 22", "level-22"},
185       {IH264_LEVEL_30, "Level 3", "level-3"},
186       {IH264_LEVEL_31, "Level 31", "level-31"},
187       {IH264_LEVEL_32, "Level 32", "level-32"},
188       {IH264_LEVEL_40, "Level 4", "level-4"},
189       {IH264_LEVEL_41, "Level 41", "level-41"},
190       {IH264_LEVEL_42, "Level 42", "level-42"},
191       {IH264_LEVEL_50, "Level 5", "level-5"},
192       {IH264_LEVEL_51, "Level 51", "level-51"},
193       {0, NULL, NULL},
194     };
196     type = g_enum_register_static ("GstDucatiH264EncLevel", vals);
197   }
199   return type;
202 static GType
203 gst_ducati_h264enc_get_entropy_coding_mode_type (void)
205   static GType type = 0;
207   if (!type) {
208     static const GEnumValue vals[] = {
209       {IH264_ENTROPYCODING_CAVLC, "CAVLC coding type", "cavlc"},
210       {IH264_ENTROPYCODING_CABAC, "Cabac coding mode", "cabac"},
211       {0, NULL, NULL},
212     };
214     type = g_enum_register_static ("GstDucatiEntropyCodingMode", vals);
215   }
217   return type;
220 static GType
221 gst_ducati_h264enc_get_slice_mode_type (void)
223   static GType type = 0;
225   if (!type) {
226     static const GEnumValue vals[] = {
227       {IH264_SLICEMODE_NONE, "No slice mode", "none"},
228       {IH264_SLICEMODE_MBUNIT,
229           "Slices are controlled based upon number of Macroblocks", "mbunit"},
230       {IH264_SLICEMODE_BYTES,
231           "Slices are controlled based upon number of bytes", "bytes"},
232       {IH264_SLICEMODE_OFFSET,
233           "Slices are controlled based upon user defined offset unit of Row",
234           "offset"},
235       {0, NULL, NULL},
236     };
238     type = g_enum_register_static ("GstDucatiSliceMode", vals);
239   }
241   return type;
244 static void
245 gst_ducati_h264enc_base_init (gpointer g_class)
248   GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
250   gst_element_class_add_pad_template (element_class,
251       gst_static_pad_template_get (&gst_ducati_h264enc_src_template));
252   gst_element_class_add_pad_template (element_class,
253       gst_static_pad_template_get (&gst_ducati_h264enc_sink_template));
255   gst_element_class_set_details_simple (element_class, "H264 Encoder",
256       "Codec/Encoder/Video",
257       "Encode raw video into H264 stream",
258       "Alessandro Decina <alessandro.decina@collabora.com>");
260   GST_DUCATIVIDENC_CLASS (element_class)->codec_name = "ivahd_h264enc";
263 static void
264 gst_ducati_h264enc_class_init (GstDucatiH264EncClass * klass)
266   GObjectClass *gobject_class;
267   GstDucatiVidEncClass *videnc_class;
269   gobject_class = G_OBJECT_CLASS (klass);
270   videnc_class = GST_DUCATIVIDENC_CLASS (klass);
272   gobject_class->set_property = gst_ducati_h264enc_set_property;
273   gobject_class->get_property = gst_ducati_h264enc_get_property;
275   videnc_class->allocate_params = gst_ducati_h264enc_allocate_params;
276   videnc_class->configure = gst_ducati_h264enc_configure;
277   videnc_class->is_sync_point = gst_ducati_h264enc_is_sync_point;
279   g_object_class_install_property (gobject_class, PROP_PROFILE,
280       g_param_spec_enum ("profile", "H.264 Profile", "H.264 Profile",
281           GST_TYPE_DUCATI_H264ENC_PROFILE, DEFAULT_PROFILE, G_PARAM_READWRITE));
283   g_object_class_install_property (gobject_class, PROP_LEVEL,
284       g_param_spec_enum ("level", "H.264 Level", "H.264 Level",
285           GST_TYPE_DUCATI_H264ENC_LEVEL, DEFAULT_LEVEL, G_PARAM_READWRITE));
287   g_object_class_install_property (gobject_class, PROP_INTER_INTERVAL,
288       g_param_spec_uint ("inter-interval", "Inter-frame interval",
289           "Max inter frame interval (B frames are allowed between them if > 1)",
290           1, 31, DEFAULT_INTER_INTERVAL, G_PARAM_READWRITE));
292   g_object_class_install_property (gobject_class,
293       PROP_RATE_CONTROL_PARAMS_PRESET,
294       g_param_spec_enum ("rate-control-params-preset",
295           "H.264 rate control params preset",
296           "This preset controls the USER_DEFINED versus "
297           "DEFAULT mode. If you are not aware about the "
298           "fields, it should be set as 'rate-control-params-preset-default'",
299           GST_TYPE_DUCATI_H264ENC_RCPP, IH264_RATECONTROLPARAMS_DEFAULT,
300           G_PARAM_READWRITE));
302   g_object_class_install_property (gobject_class, PROP_RATE_CONTROL_ALGO,
303       g_param_spec_enum ("rate-control-algo", "H.264 rate control algorithm",
304           "This defines the rate control algorithm to be used. Only useful if "
305           " 'rate-control-params-preset' is set as "
306           "'rate-control-params-preset-user-defined'",
307           GST_TYPE_DUCATI_H264ENC_RATE_CONTROL_ALGO, IH264_RATECONTROL_DEFAULT,
308           G_PARAM_READWRITE));
310   g_object_class_install_property (gobject_class, PROP_QPI,
311       g_param_spec_int ("qpi", "Initial quantization parameter",
312           "Initial quantization parameter for I/IDR frames.", -1, 51,
313           DEFAULT_QPI, G_PARAM_READWRITE));
315   g_object_class_install_property (gobject_class, PROP_QP_MIN_I,
316       g_param_spec_int ("qp-min-i", "Minimum quantization parameter",
317           "Minimum quantization parameter for I/IDR frames.", 0, 51,
318           DEFAULT_QP_MIN_I, G_PARAM_READWRITE));
320   g_object_class_install_property (gobject_class, PROP_QP_MAX_I,
321       g_param_spec_int ("qp-max-i", "Maximum quantization parameter",
322           "Maximum quantization parameter for I/IDR frames.", 0, 51,
323           DEFAULT_QP_MAX_I, G_PARAM_READWRITE));
325   g_object_class_install_property (gobject_class, PROP_HRD_BUFFER_SIZE,
326       g_param_spec_uint ("hrd-buffer-size",
327           "Hypothetical reference decoder buffer size",
328           "Hypothetical reference decoder buffer size. This "
329           "size controls the frame skip logic of the encoder. "
330           "For low delay applications this size should be "
331           "small. This size is in bits. Maximum Value is level "
332           "dependant and min value is 4096",
333           4096, G_MAXUINT, DEFAULT_HRD_BUFFER_SIZE, G_PARAM_READWRITE));
335   g_object_class_install_property (gobject_class, PROP_ENTROPY_CODING_MODE,
336       g_param_spec_enum ("entropy-coding-mode", "H.264 entropy coding mode",
337           "Controls the entropy coding type.",
338           GST_TYPE_DUCATI_H264ENC_ENTROPY_CODING_MODE,
339           IH264_ENTROPYCODING_DEFAULT, G_PARAM_READWRITE));
341   g_object_class_install_property (gobject_class, PROP_SLICE_MODE,
342       g_param_spec_enum ("slice-mode", "H.264 slice mode",
343           "This defines the control mechanism to split a picture in slices."
344           " It can be either MB based or bytes based",
345           GST_TYPE_DUCATI_H264ENC_SLICE_MODE,
346           IH264_SLICEMODE_DEFAULT, G_PARAM_READWRITE));
350 static void
351 gst_ducati_h264enc_init (GstDucatiH264Enc * self, GstDucatiH264EncClass * klass)
353   GST_DEBUG ("gst_ducati_h264enc_init");
355   self->profile = DEFAULT_PROFILE;
356   self->level = DEFAULT_LEVEL;
357   self->rate_control_params_preset = IH264_RATECONTROLPARAMS_DEFAULT;
358   self->rate_control_algo = IH264_RATECONTROL_DEFAULT;
359   self->qpi = DEFAULT_QPI;
360   self->qp_min_i = DEFAULT_QP_MIN_I;
361   self->qp_max_i = DEFAULT_QP_MAX_I;
362   self->hrd_buffer_size = DEFAULT_HRD_BUFFER_SIZE;
363   self->inter_interval = DEFAULT_INTER_INTERVAL;
366 static void
367 gst_ducati_h264enc_set_property (GObject * object, guint prop_id,
368     const GValue * value, GParamSpec * pspec)
370   GstDucatiH264Enc *self = GST_DUCATIH264ENC (object);
371   GstDucatiVidEnc *venc = GST_DUCATIVIDENC (object);
372   IH264ENC_DynamicParams *dynParams =
373       (IH264ENC_DynamicParams *) venc->dynParams;
375   self = GST_DUCATIH264ENC (object);
377   switch (prop_id) {
378     case PROP_PROFILE:
379       self->profile = g_value_get_enum (value);
380       break;
381     case PROP_LEVEL:
382       self->level = g_value_get_enum (value);
383       break;
384     case PROP_RATE_CONTROL_PARAMS_PRESET:
385       self->rate_control_params_preset = g_value_get_enum (value);
386       if (dynParams)
387         dynParams->rateControlParams.rateControlParamsPreset =
388             self->rate_control_params_preset;
389       break;
390     case PROP_RATE_CONTROL_ALGO:
391       self->rate_control_algo = g_value_get_enum (value);
393       if (self->rate_control_params_preset !=
394           IH264_RATECONTROLPARAMS_USERDEFINED)
395         GST_INFO_OBJECT (self,
396             "Setting rcAlgo but rateControlParamsPreset not "
397             "'rate-control-params-preset-user-defined' config won't be taken "
398             "into account");
400       if (dynParams)
401         dynParams->rateControlParams.rcAlgo = self->rate_control_algo;
402       break;
403     case PROP_QPI:
404       self->qpi = g_value_get_int (value);
405       if (dynParams)
406         dynParams->rateControlParams.qpI = self->qpi;
408       break;
409     case PROP_QP_MIN_I:
410       self->qp_min_i = g_value_get_int (value);
411       if (dynParams)
412         dynParams->rateControlParams.qpMinI = self->qp_min_i;
413       break;
414     case PROP_QP_MAX_I:
415       self->qp_max_i = g_value_get_int (value);
416       if (dynParams)
417         dynParams->rateControlParams.qpMaxI = self->qp_max_i;
418       break;
419     case PROP_HRD_BUFFER_SIZE:
420       self->hrd_buffer_size = g_value_get_uint (value);
421       break;
422     case PROP_ENTROPY_CODING_MODE:
423       self->entropy_coding_mode = g_value_get_enum (value);
424       break;
425     case PROP_SLICE_MODE:
426       self->slice_mode = g_value_get_enum (value);
427       break;
428     case PROP_INTER_INTERVAL:
429       self->inter_interval = g_value_get_uint (value);
430       break;
431     default:
432       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
433   }
436 static void
437 gst_ducati_h264enc_get_property (GObject * object, guint prop_id,
438     GValue * value, GParamSpec * pspec)
440   GstDucatiH264Enc *self = GST_DUCATIH264ENC (object);
442   g_return_if_fail (GST_IS_DUCATIH264ENC (object));
443   self = GST_DUCATIH264ENC (object);
445   switch (prop_id) {
446     case PROP_PROFILE:
447       g_value_set_enum (value, self->profile);
448       break;
449     case PROP_LEVEL:
450       g_value_set_enum (value, self->level);
451       break;
452     case PROP_RATE_CONTROL_PARAMS_PRESET:
453       g_value_set_enum (value, self->rate_control_params_preset);
454       break;
455     case PROP_RATE_CONTROL_ALGO:
456       g_value_set_enum (value, self->rate_control_algo);
457       break;
458     case PROP_QPI:
459       g_value_set_int (value, self->qpi);
460       break;
461     case PROP_QP_MIN_I:
462       g_value_set_int (value, self->qp_min_i);
463       break;
464     case PROP_QP_MAX_I:
465       g_value_set_int (value, self->qp_max_i);
466       break;
467     case PROP_HRD_BUFFER_SIZE:
468       g_value_set_uint (value, self->hrd_buffer_size);
469       break;
470     case PROP_ENTROPY_CODING_MODE:
471       g_value_set_enum (value, self->entropy_coding_mode);
472       break;
473     case PROP_SLICE_MODE:
474       g_value_set_enum (value, self->slice_mode);
475       break;
476     case PROP_INTER_INTERVAL:
477       g_value_set_uint (value, self->inter_interval);
478       break;
479     default:
480       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
481   }
484 static const char *
485 get_profile_name (guint profile)
487   switch (profile) {
488     case IH264_BASELINE_PROFILE:
489       return "baseline";
490     case IH264_MAIN_PROFILE:
491       return "main";
492     case IH264_EXTENDED_PROFILE:
493       return "extended";
494     case IH264_HIGH_PROFILE:
495       return "high";
496     case IH264_HIGH10_PROFILE:
497       return "high-10";
498     case IH264_HIGH422_PROFILE:
499       return "high-422";
500     default:
501       return NULL;
502   }
505 static const char *
506 get_level_name (guint level)
508   switch (level) {
509     case IH264_LEVEL_10:
510       return "1";
511     case IH264_LEVEL_1b:
512       return "1b";
513     case IH264_LEVEL_11:
514       return "1.1";
515     case IH264_LEVEL_12:
516       return "1.2";
517     case IH264_LEVEL_13:
518       return "1.3";
519     case IH264_LEVEL_20:
520       return "2";
521     case IH264_LEVEL_21:
522       return "2.1";
523     case IH264_LEVEL_22:
524       return "2.2";
525     case IH264_LEVEL_30:
526       return "3";
527     case IH264_LEVEL_31:
528       return "3.1";
529     case IH264_LEVEL_32:
530       return "3.2";
531     case IH264_LEVEL_40:
532       return "4";
533     case IH264_LEVEL_41:
534       return "4.1";
535     case IH264_LEVEL_42:
536       return "4.2";
537     case IH264_LEVEL_50:
538       return "5";
539     case IH264_LEVEL_51:
540       return "5.1";
541     default:
542       return NULL;
543   }
546 static gboolean
547 gst_ducati_h264enc_configure (GstDucatiVidEnc * videnc)
549   GstDucatiH264Enc *self = GST_DUCATIH264ENC (videnc);
550   IH264ENC_Params *params;
551   IH264ENC_DynamicParams *dynParams;
552   gboolean ret;
553   const char *s;
554   const GstVideoState *state;
555   GstCaps *caps;
556   int inter_interval;
558   ret = GST_DUCATIVIDENC_CLASS (parent_class)->configure (videnc);
559   if (!ret)
560     return FALSE;
562   videnc->params->profile = self->profile;
563   videnc->params->level = self->level;
565   inter_interval = self->inter_interval;
566   if (self->profile == IH264_BASELINE_PROFILE)
567     inter_interval = 1;
568   else if (videnc->rate_preset == IVIDEO_LOW_DELAY)
569     inter_interval = 1;
571   params = (IH264ENC_Params *) videnc->params;
572   /* this is the only non-base field strictly required */
573   params->maxIntraFrameInterval = 0x7fffffff;
574   params->IDRFrameInterval = 1;
575   params->numTemporalLayer = 1;
576   params->entropyCodingMode = self->entropy_coding_mode;
577   videnc->params->maxInterFrameInterval = inter_interval;
579   /* Dynamic params */
580   dynParams = (IH264ENC_DynamicParams *) videnc->dynParams;
581   dynParams->rateControlParams.rateControlParamsPreset =
582       self->rate_control_params_preset;
583   dynParams->rateControlParams.rcAlgo = self->rate_control_algo;
584   dynParams->rateControlParams.qpI = self->qpi;
585   dynParams->rateControlParams.qpMaxI = self->qp_max_i;
586   dynParams->rateControlParams.qpMinI = self->qp_min_i;
587   dynParams->rateControlParams.HRDBufferSize = self->hrd_buffer_size;
588   dynParams->sliceCodingParams.sliceMode = self->slice_mode;
589   videnc->dynParams->interFrameInterval = inter_interval;
591   state = gst_base_video_encoder_get_state (GST_BASE_VIDEO_ENCODER (videnc));
592   caps = gst_caps_new_simple ("video/x-h264",
593       "width", G_TYPE_INT, videnc->rect.w,
594       "height", G_TYPE_INT, videnc->rect.h,
595       "framerate", GST_TYPE_FRACTION, state->fps_n, state->fps_d,
596       "pixel-aspect-ratio", GST_TYPE_FRACTION, state->par_n, state->par_d,
597       "stream-format", G_TYPE_STRING, "byte-stream",
598       "align", G_TYPE_STRING, "au",
599       "num-reorder-frames", G_TYPE_INT, inter_interval - 1, NULL);
600   s = get_profile_name (self->profile);
601   if (s)
602     gst_caps_set_simple (caps, "profile", G_TYPE_STRING, s, NULL);
603   s = get_level_name (self->level);
604   if (s)
605     gst_caps_set_simple (caps, "level", G_TYPE_STRING, s, NULL);
606   ret = gst_pad_set_caps (GST_BASE_VIDEO_CODEC_SRC_PAD (self), caps);
608   return ret;
611 static gboolean
612 gst_ducati_h264enc_allocate_params (GstDucatiVidEnc *
613     videnc, gint params_sz, gint dynparams_sz, gint status_sz, gint inargs_sz,
614     gint outargs_sz)
616   gboolean ret = GST_DUCATIVIDENC_CLASS (parent_class)->allocate_params (videnc,
617       sizeof (IH264ENC_Params), sizeof (IH264ENC_DynamicParams),
618       sizeof (IVIDENC2_Status), sizeof (IVIDENC2_InArgs),
619       sizeof (IVIDENC2_OutArgs));
621   GstDucatiH264Enc *self = GST_DUCATIH264ENC (videnc);
623   if (ret == TRUE) {
624     IH264ENC_DynamicParams *dynParams =
625         (IH264ENC_DynamicParams *) videnc->dynParams;
627     dynParams->rateControlParams.rateControlParamsPreset =
628         self->rate_control_params_preset;
629     dynParams->rateControlParams.rcAlgo = self->rate_control_algo;
630     dynParams->rateControlParams.qpI = self->qpi;
631     dynParams->rateControlParams.qpMaxI = self->qp_max_i;
632     dynParams->rateControlParams.qpMinI = self->qp_min_i;
633     dynParams->rateControlParams.HRDBufferSize = self->hrd_buffer_size;
634     dynParams->sliceCodingParams.sliceMode = self->slice_mode;
635   }
637   return ret;
640 static gboolean
641 gst_ducati_h264enc_is_sync_point (GstDucatiVidEnc * enc, int type)
643   return type == IVIDEO_IDR_FRAME;