mpeg2dec: Fix negotiation issue with playbin
[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_MAKE ("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 #define gst_ducati_h264enc_parent_class parent_class
103 G_DEFINE_TYPE (GstDucatiH264Enc, gst_ducati_h264enc, 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_class_init (GstDucatiH264EncClass * klass)
247   GObjectClass *gobject_class;
248   GstDucatiVidEncClass *videnc_class;
249   GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
251   gobject_class = G_OBJECT_CLASS (klass);
252   videnc_class = GST_DUCATIVIDENC_CLASS (klass);
253   parent_class = g_type_class_peek_parent (klass);
256   gst_element_class_add_pad_template (element_class,
257       gst_static_pad_template_get (&gst_ducati_h264enc_src_template));
258   gst_element_class_add_pad_template (element_class,
259       gst_static_pad_template_get (&gst_ducati_h264enc_sink_template));
261   gst_element_class_set_metadata (element_class, "H264 Encoder",
262       "Codec/Encoder/Video",
263       "Encode raw video into H264 stream",
264       "Alessandro Decina <alessandro.decina@collabora.com>");
266   GST_DUCATIVIDENC_CLASS (element_class)->codec_name = "ivahd_h264enc";
268   gobject_class->set_property = gst_ducati_h264enc_set_property;
269   gobject_class->get_property = gst_ducati_h264enc_get_property;
271   videnc_class->allocate_params = gst_ducati_h264enc_allocate_params;
272   videnc_class->configure = gst_ducati_h264enc_configure;
273   videnc_class->is_sync_point = gst_ducati_h264enc_is_sync_point;
275   g_object_class_install_property (gobject_class, PROP_PROFILE,
276       g_param_spec_enum ("profile", "H.264 Profile", "H.264 Profile",
277           GST_TYPE_DUCATI_H264ENC_PROFILE, DEFAULT_PROFILE, G_PARAM_READWRITE));
279   g_object_class_install_property (gobject_class, PROP_LEVEL,
280       g_param_spec_enum ("level", "H.264 Level", "H.264 Level",
281           GST_TYPE_DUCATI_H264ENC_LEVEL, DEFAULT_LEVEL, G_PARAM_READWRITE));
283   g_object_class_install_property (gobject_class, PROP_INTER_INTERVAL,
284       g_param_spec_uint ("inter-interval", "Inter-frame interval",
285           "Max inter frame interval (B frames are allowed between them if > 1)",
286           1, 31, DEFAULT_INTER_INTERVAL, G_PARAM_READWRITE));
288   g_object_class_install_property (gobject_class,
289       PROP_RATE_CONTROL_PARAMS_PRESET,
290       g_param_spec_enum ("rate-control-params-preset",
291           "H.264 rate control params preset",
292           "This preset controls the USER_DEFINED versus "
293           "DEFAULT mode. If you are not aware about the "
294           "fields, it should be set as 'rate-control-params-preset-default'",
295           GST_TYPE_DUCATI_H264ENC_RCPP, IH264_RATECONTROLPARAMS_DEFAULT,
296           G_PARAM_READWRITE));
298   g_object_class_install_property (gobject_class, PROP_RATE_CONTROL_ALGO,
299       g_param_spec_enum ("rate-control-algo", "H.264 rate control algorithm",
300           "This defines the rate control algorithm to be used. Only useful if "
301           " 'rate-control-params-preset' is set as "
302           "'rate-control-params-preset-user-defined'",
303           GST_TYPE_DUCATI_H264ENC_RATE_CONTROL_ALGO, IH264_RATECONTROL_DEFAULT,
304           G_PARAM_READWRITE));
306   g_object_class_install_property (gobject_class, PROP_QPI,
307       g_param_spec_int ("qpi", "Initial quantization parameter",
308           "Initial quantization parameter for I/IDR frames.", -1, 51,
309           DEFAULT_QPI, G_PARAM_READWRITE));
311   g_object_class_install_property (gobject_class, PROP_QP_MIN_I,
312       g_param_spec_int ("qp-min-i", "Minimum quantization parameter",
313           "Minimum quantization parameter for I/IDR frames.", 0, 51,
314           DEFAULT_QP_MIN_I, G_PARAM_READWRITE));
316   g_object_class_install_property (gobject_class, PROP_QP_MAX_I,
317       g_param_spec_int ("qp-max-i", "Maximum quantization parameter",
318           "Maximum quantization parameter for I/IDR frames.", 0, 51,
319           DEFAULT_QP_MAX_I, G_PARAM_READWRITE));
321   g_object_class_install_property (gobject_class, PROP_HRD_BUFFER_SIZE,
322       g_param_spec_uint ("hrd-buffer-size",
323           "Hypothetical reference decoder buffer size",
324           "Hypothetical reference decoder buffer size. This "
325           "size controls the frame skip logic of the encoder. "
326           "For low delay applications this size should be "
327           "small. This size is in bits. Maximum Value is level "
328           "dependant and min value is 4096",
329           4096, G_MAXUINT, DEFAULT_HRD_BUFFER_SIZE, G_PARAM_READWRITE));
331   g_object_class_install_property (gobject_class, PROP_ENTROPY_CODING_MODE,
332       g_param_spec_enum ("entropy-coding-mode", "H.264 entropy coding mode",
333           "Controls the entropy coding type.",
334           GST_TYPE_DUCATI_H264ENC_ENTROPY_CODING_MODE,
335           IH264_ENTROPYCODING_DEFAULT, G_PARAM_READWRITE));
337   g_object_class_install_property (gobject_class, PROP_SLICE_MODE,
338       g_param_spec_enum ("slice-mode", "H.264 slice mode",
339           "This defines the control mechanism to split a picture in slices."
340           " It can be either MB based or bytes based",
341           GST_TYPE_DUCATI_H264ENC_SLICE_MODE,
342           IH264_SLICEMODE_DEFAULT, G_PARAM_READWRITE));
346 static void
347 gst_ducati_h264enc_init (GstDucatiH264Enc * self)
349   GST_DEBUG ("gst_ducati_h264enc_init");
351   self->profile = DEFAULT_PROFILE;
352   self->level = DEFAULT_LEVEL;
353   self->rate_control_params_preset = IH264_RATECONTROLPARAMS_DEFAULT;
354   self->rate_control_algo = IH264_RATECONTROL_DEFAULT;
355   self->qpi = DEFAULT_QPI;
356   self->qp_min_i = DEFAULT_QP_MIN_I;
357   self->qp_max_i = DEFAULT_QP_MAX_I;
358   self->hrd_buffer_size = DEFAULT_HRD_BUFFER_SIZE;
359   self->inter_interval = DEFAULT_INTER_INTERVAL;
362 static void
363 gst_ducati_h264enc_set_property (GObject * object, guint prop_id,
364     const GValue * value, GParamSpec * pspec)
366   GstDucatiH264Enc *self = GST_DUCATIH264ENC (object);
367   GstDucatiVidEnc *venc = GST_DUCATIVIDENC (object);
368   IH264ENC_DynamicParams *dynParams =
369       (IH264ENC_DynamicParams *) venc->dynParams;
371   self = GST_DUCATIH264ENC (object);
373   switch (prop_id) {
374     case PROP_PROFILE:
375       self->profile = g_value_get_enum (value);
376       break;
377     case PROP_LEVEL:
378       self->level = g_value_get_enum (value);
379       break;
380     case PROP_RATE_CONTROL_PARAMS_PRESET:
381       self->rate_control_params_preset = g_value_get_enum (value);
382       if (dynParams)
383         dynParams->rateControlParams.rateControlParamsPreset =
384             self->rate_control_params_preset;
385       break;
386     case PROP_RATE_CONTROL_ALGO:
387       self->rate_control_algo = g_value_get_enum (value);
389       if (self->rate_control_params_preset !=
390           IH264_RATECONTROLPARAMS_USERDEFINED)
391         GST_INFO_OBJECT (self,
392             "Setting rcAlgo but rateControlParamsPreset not "
393             "'rate-control-params-preset-user-defined' config won't be taken "
394             "into account");
396       if (dynParams)
397         dynParams->rateControlParams.rcAlgo = self->rate_control_algo;
398       break;
399     case PROP_QPI:
400       self->qpi = g_value_get_int (value);
401       if (dynParams)
402         dynParams->rateControlParams.qpI = self->qpi;
404       break;
405     case PROP_QP_MIN_I:
406       self->qp_min_i = g_value_get_int (value);
407       if (dynParams)
408         dynParams->rateControlParams.qpMinI = self->qp_min_i;
409       break;
410     case PROP_QP_MAX_I:
411       self->qp_max_i = g_value_get_int (value);
412       if (dynParams)
413         dynParams->rateControlParams.qpMaxI = self->qp_max_i;
414       break;
415     case PROP_HRD_BUFFER_SIZE:
416       self->hrd_buffer_size = g_value_get_uint (value);
417       break;
418     case PROP_ENTROPY_CODING_MODE:
419       self->entropy_coding_mode = g_value_get_enum (value);
420       break;
421     case PROP_SLICE_MODE:
422       self->slice_mode = g_value_get_enum (value);
423       break;
424     case PROP_INTER_INTERVAL:
425       self->inter_interval = g_value_get_uint (value);
426       break;
427     default:
428       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
429   }
432 static void
433 gst_ducati_h264enc_get_property (GObject * object, guint prop_id,
434     GValue * value, GParamSpec * pspec)
436   GstDucatiH264Enc *self = GST_DUCATIH264ENC (object);
438   g_return_if_fail (GST_IS_DUCATIH264ENC (object));
439   self = GST_DUCATIH264ENC (object);
441   switch (prop_id) {
442     case PROP_PROFILE:
443       g_value_set_enum (value, self->profile);
444       break;
445     case PROP_LEVEL:
446       g_value_set_enum (value, self->level);
447       break;
448     case PROP_RATE_CONTROL_PARAMS_PRESET:
449       g_value_set_enum (value, self->rate_control_params_preset);
450       break;
451     case PROP_RATE_CONTROL_ALGO:
452       g_value_set_enum (value, self->rate_control_algo);
453       break;
454     case PROP_QPI:
455       g_value_set_int (value, self->qpi);
456       break;
457     case PROP_QP_MIN_I:
458       g_value_set_int (value, self->qp_min_i);
459       break;
460     case PROP_QP_MAX_I:
461       g_value_set_int (value, self->qp_max_i);
462       break;
463     case PROP_HRD_BUFFER_SIZE:
464       g_value_set_uint (value, self->hrd_buffer_size);
465       break;
466     case PROP_ENTROPY_CODING_MODE:
467       g_value_set_enum (value, self->entropy_coding_mode);
468       break;
469     case PROP_SLICE_MODE:
470       g_value_set_enum (value, self->slice_mode);
471       break;
472     case PROP_INTER_INTERVAL:
473       g_value_set_uint (value, self->inter_interval);
474       break;
475     default:
476       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
477   }
480 static const char *
481 get_profile_name (guint profile)
483   switch (profile) {
484     case IH264_BASELINE_PROFILE:
485       return "baseline";
486     case IH264_MAIN_PROFILE:
487       return "main";
488     case IH264_EXTENDED_PROFILE:
489       return "extended";
490     case IH264_HIGH_PROFILE:
491       return "high";
492     case IH264_HIGH10_PROFILE:
493       return "high-10";
494     case IH264_HIGH422_PROFILE:
495       return "high-422";
496     default:
497       return NULL;
498   }
501 static const char *
502 get_level_name (guint level)
504   switch (level) {
505     case IH264_LEVEL_10:
506       return "1";
507     case IH264_LEVEL_1b:
508       return "1b";
509     case IH264_LEVEL_11:
510       return "1.1";
511     case IH264_LEVEL_12:
512       return "1.2";
513     case IH264_LEVEL_13:
514       return "1.3";
515     case IH264_LEVEL_20:
516       return "2";
517     case IH264_LEVEL_21:
518       return "2.1";
519     case IH264_LEVEL_22:
520       return "2.2";
521     case IH264_LEVEL_30:
522       return "3";
523     case IH264_LEVEL_31:
524       return "3.1";
525     case IH264_LEVEL_32:
526       return "3.2";
527     case IH264_LEVEL_40:
528       return "4";
529     case IH264_LEVEL_41:
530       return "4.1";
531     case IH264_LEVEL_42:
532       return "4.2";
533     case IH264_LEVEL_50:
534       return "5";
535     case IH264_LEVEL_51:
536       return "5.1";
537     default:
538       return NULL;
539   }
542 static gboolean
543 gst_ducati_h264enc_configure (GstDucatiVidEnc * videnc)
545   GstDucatiH264Enc *self = GST_DUCATIH264ENC (videnc);
546   IH264ENC_Params *params;
547   IH264ENC_DynamicParams *dynParams;
548   gboolean ret;
549   const char *s;
550   const GstVideoCodecState *state;
551   GstCaps *caps;
552   int inter_interval;
554   ret = GST_DUCATIVIDENC_CLASS (parent_class)->configure (videnc);
555   if (!ret)
556     return FALSE;
558   videnc->params->profile = self->profile;
559   videnc->params->level = self->level;
561   inter_interval = self->inter_interval;
562   if (self->profile == IH264_BASELINE_PROFILE)
563     inter_interval = 1;
564   else if (videnc->rate_preset == IVIDEO_LOW_DELAY)
565     inter_interval = 1;
567   params = (IH264ENC_Params *) videnc->params;
568   /* this is the only non-base field strictly required */
569   params->maxIntraFrameInterval = 0x7fffffff;
570   params->IDRFrameInterval = 1;
571   params->numTemporalLayer = 1;
572   params->entropyCodingMode = self->entropy_coding_mode;
573   videnc->params->maxInterFrameInterval = inter_interval;
575   /* Dynamic params */
576   dynParams = (IH264ENC_DynamicParams *) videnc->dynParams;
577   dynParams->rateControlParams.rateControlParamsPreset =
578       self->rate_control_params_preset;
579   dynParams->rateControlParams.rcAlgo = self->rate_control_algo;
580   dynParams->rateControlParams.qpI = self->qpi;
581   dynParams->rateControlParams.qpMaxI = self->qp_max_i;
582   dynParams->rateControlParams.qpMinI = self->qp_min_i;
583   dynParams->rateControlParams.HRDBufferSize = self->hrd_buffer_size;
584   dynParams->sliceCodingParams.sliceMode = self->slice_mode;
585   videnc->dynParams->interFrameInterval = inter_interval;
587   state = videnc->input_state;
588   caps = gst_caps_new_simple ("video/x-h264",
589       "width", G_TYPE_INT, videnc->rect.w,
590       "height", G_TYPE_INT, videnc->rect.h,
591       "framerate", GST_TYPE_FRACTION, GST_VIDEO_INFO_FPS_N (&state->info), GST_VIDEO_INFO_FPS_D (&state->info),
592       "pixel-aspect-ratio", GST_TYPE_FRACTION, GST_VIDEO_INFO_PAR_N (&state->info), GST_VIDEO_INFO_PAR_D (&state->info),
593       "stream-format", G_TYPE_STRING, "byte-stream",
594       "align", G_TYPE_STRING, "au",
595       "num-reorder-frames", G_TYPE_INT, inter_interval - 1, NULL);
596   s = get_profile_name (self->profile);
597   if (s)
598     gst_caps_set_simple (caps, "profile", G_TYPE_STRING, s, NULL);
599   s = get_level_name (self->level);
600   if (s)
601     gst_caps_set_simple (caps, "level", G_TYPE_STRING, s, NULL);
602   ret = gst_pad_set_caps (GST_VIDEO_ENCODER_SRC_PAD (self), caps);
604   return ret;
607 static gboolean
608 gst_ducati_h264enc_allocate_params (GstDucatiVidEnc *
609     videnc, gint params_sz, gint dynparams_sz, gint status_sz, gint inargs_sz,
610     gint outargs_sz)
612   gboolean ret = GST_DUCATIVIDENC_CLASS (parent_class)->allocate_params (videnc,
613       sizeof (IH264ENC_Params), sizeof (IH264ENC_DynamicParams),
614       sizeof (IVIDENC2_Status), sizeof (IVIDENC2_InArgs),
615       sizeof (IVIDENC2_OutArgs));
617   GstDucatiH264Enc *self = GST_DUCATIH264ENC (videnc);
619   if (ret == TRUE) {
620     IH264ENC_DynamicParams *dynParams =
621         (IH264ENC_DynamicParams *) videnc->dynParams;
623     dynParams->rateControlParams.rateControlParamsPreset =
624         self->rate_control_params_preset;
625     dynParams->rateControlParams.rcAlgo = self->rate_control_algo;
626     dynParams->rateControlParams.qpI = self->qpi;
627     dynParams->rateControlParams.qpMaxI = self->qp_max_i;
628     dynParams->rateControlParams.qpMinI = self->qp_min_i;
629     dynParams->rateControlParams.HRDBufferSize = self->hrd_buffer_size;
630     dynParams->sliceCodingParams.sliceMode = self->slice_mode;
631   }
633   return ret;
636 static gboolean
637 gst_ducati_h264enc_is_sync_point (GstDucatiVidEnc * enc, int type)
639   return type == IVIDEO_IDR_FRAME;