ducatih264enc is now using ih264enc.h from ducati side, rather than re-defining enums
[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       {IH264_RATECONTROLPARAMS_MAX, "Max rate control",
142           "rate-control-params-preset-control"},
143       {0, NULL, NULL},
144     };
146     type = g_enum_register_static ("GstDucatiH264EncRateControlParams", vals);
147   }
149   return type;
152 static GType
153 gst_ducati_h264enc_get_rate_control_algo_type (void)
155   static GType type = 0;
157   if (!type) {
158     static const GEnumValue vals[] = {
159       {IH264_RATECONTROL_PRC, "Perceptual rate control",
160           "perceptual-rate-control"},
161       {IH264_RATECONTROL_PRC_LOW_DELAY, "Low delay rate control",
162           "low-delay-rate-control"},
163       {IH264_RATECONTROL_DEFAULT, "Default rcAlgo (PRC)",
164           "default-rate-control"},
165       {0, NULL, NULL},
166     };
168     type = g_enum_register_static ("GstDucatiH264EncRateControlAlgo", vals);
169   }
171   return type;
174 static GType
175 gst_ducati_h264enc_level_get_type (void)
177   static GType type = 0;
179   if (!type) {
180     static const GEnumValue vals[] = {
181       {IH264_LEVEL_10, "Level 1", "level-1"},
182       {IH264_LEVEL_1b, "Level 1b", "level-1b"},
183       {IH264_LEVEL_11, "Level 11", "level-11"},
184       {IH264_LEVEL_12, "Level 12", "level-12"},
185       {IH264_LEVEL_13, "Level 13", "level-13"},
186       {IH264_LEVEL_20, "Level 2", "level-2"},
187       {IH264_LEVEL_21, "Level 21", "level-21"},
188       {IH264_LEVEL_22, "Level 22", "level-22"},
189       {IH264_LEVEL_30, "Level 3", "level-3"},
190       {IH264_LEVEL_31, "Level 31", "level-31"},
191       {IH264_LEVEL_32, "Level 32", "level-32"},
192       {IH264_LEVEL_40, "Level 4", "level-4"},
193       {IH264_LEVEL_41, "Level 41", "level-41"},
194       {IH264_LEVEL_42, "Level 42", "level-42"},
195       {IH264_LEVEL_50, "Level 5", "level-5"},
196       {IH264_LEVEL_51, "Level 51", "level-51"},
197       {0, NULL, NULL},
198     };
200     type = g_enum_register_static ("GstDucatiH264EncLevel", vals);
201   }
203   return type;
206 static GType
207 gst_ducati_h264enc_get_entropy_coding_mode_type (void)
209   static GType type = 0;
211   if (!type) {
212     static const GEnumValue vals[] = {
213       {IH264_ENTROPYCODING_CAVLC, "CAVLC coding type", "cavlc"},
214       {IH264_ENTROPYCODING_DEFAULT, "Default coding type (cavlc)", "default"},
215       {IH264_ENTROPYCODING_CABAC, "Cabac coding mode", "cabac"},
216       {0, NULL, NULL},
217     };
219     type = g_enum_register_static ("GstDucatiEntropyCodingMode", vals);
220   }
222   return type;
225 static GType
226 gst_ducati_h264enc_get_slice_mode_type (void)
228   static GType type = 0;
230   if (!type) {
231     static const GEnumValue vals[] = {
232       {IH264_SLICEMODE_NONE, "No slice mode", "none"},
233       {IH264_SLICEMODE_DEFAULT, "Default slice coding mode is MB based",
234           "default"},
235       {IH264_SLICEMODE_MBUNIT,
236           "Slices are controlled based upon number of Macroblocks", "mbunit"},
237       {IH264_SLICEMODE_BYTES,
238           "Slices are controlled based upon number of bytes", "bytes"},
239       {IH264_SLICEMODE_OFFSET,
240             "Slices are controlled based upon user defined offset unit of Row",
241           "offset"},
242       {0, NULL, NULL},
243     };
245     type = g_enum_register_static ("GstDucatiSliceMode", vals);
246   }
248   return type;
251 static void
252 gst_ducati_h264enc_base_init (gpointer g_class)
255   GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
257   gst_element_class_add_pad_template (element_class,
258       gst_static_pad_template_get (&gst_ducati_h264enc_src_template));
259   gst_element_class_add_pad_template (element_class,
260       gst_static_pad_template_get (&gst_ducati_h264enc_sink_template));
262   gst_element_class_set_details_simple (element_class, "H264 Encoder",
263       "Codec/Encoder/Video",
264       "Encode raw video into H264 stream",
265       "Alessandro Decina <alessandro.decina@collabora.com>");
267   GST_DUCATIVIDENC_CLASS (element_class)->codec_name = "ivahd_h264enc";
270 static void
271 gst_ducati_h264enc_class_init (GstDucatiH264EncClass * klass)
273   GObjectClass *gobject_class;
274   GstDucatiVidEncClass *videnc_class;
276   gobject_class = G_OBJECT_CLASS (klass);
277   videnc_class = GST_DUCATIVIDENC_CLASS (klass);
279   gobject_class->set_property = gst_ducati_h264enc_set_property;
280   gobject_class->get_property = gst_ducati_h264enc_get_property;
282   videnc_class->allocate_params = gst_ducati_h264enc_allocate_params;
283   videnc_class->configure = gst_ducati_h264enc_configure;
284   videnc_class->is_sync_point = gst_ducati_h264enc_is_sync_point;
286   g_object_class_install_property (gobject_class, PROP_PROFILE,
287       g_param_spec_enum ("profile", "H.264 Profile", "H.264 Profile",
288           GST_TYPE_DUCATI_H264ENC_PROFILE, DEFAULT_PROFILE, G_PARAM_READWRITE));
290   g_object_class_install_property (gobject_class, PROP_LEVEL,
291       g_param_spec_enum ("level", "H.264 Level", "H.264 Level",
292           GST_TYPE_DUCATI_H264ENC_LEVEL, DEFAULT_LEVEL, G_PARAM_READWRITE));
294   g_object_class_install_property (gobject_class, PROP_INTER_INTERVAL,
295       g_param_spec_uint ("inter-interval", "Inter-frame interval",
296           "Max inter frame interval (B frames are allowed between them if > 1)",
297           1, 31, DEFAULT_INTER_INTERVAL, G_PARAM_READWRITE));
299   g_object_class_install_property (gobject_class,
300       PROP_RATE_CONTROL_PARAMS_PRESET,
301       g_param_spec_enum ("rate-control-params-preset",
302           "H.264 rate control params preset",
303           "This preset controls the USER_DEFINED versus "
304           "DEFAULT mode. If you are not aware about the "
305           "fields, it should be set as IH264_RATECONTROLPARAMS_DEFAULT",
306           GST_TYPE_DUCATI_H264ENC_RCPP, IH264_RATECONTROLPARAMS_DEFAULT,
307           G_PARAM_READWRITE));
309   g_object_class_install_property (gobject_class, PROP_RATE_CONTROL_ALGO,
310       g_param_spec_enum ("rate-control-algo", "H.264 rate control algorithm",
311           "This defines the rate control algorithm to be used. Only useful if "
312           " 'rate-control-params-preset' is set as "
313           "'rate-control-params-preset-user-defined'",
314           GST_TYPE_DUCATI_H264ENC_RATE_CONTROL_ALGO, IH264_RATECONTROL_DEFAULT,
315           G_PARAM_READWRITE));
317   g_object_class_install_property (gobject_class, PROP_QPI,
318       g_param_spec_int ("qpi", "Initial quantization parameter",
319           "Initial quantization parameter for I/IDR frames.", -1, 51,
320           DEFAULT_QPI, G_PARAM_READWRITE));
322   g_object_class_install_property (gobject_class, PROP_QP_MIN_I,
323       g_param_spec_int ("qp-min-i", "Minimum quantization parameter",
324           "Minimum quantization parameter for I/IDR frames.", 0, 51,
325           DEFAULT_QP_MIN_I, G_PARAM_READWRITE));
327   g_object_class_install_property (gobject_class, PROP_QP_MAX_I,
328       g_param_spec_int ("qp-max-i", "Maximum quantization parameter",
329           "Maximum quantization parameter for I/IDR frames.", 0, 51,
330           DEFAULT_QP_MAX_I, G_PARAM_READWRITE));
332   g_object_class_install_property (gobject_class, PROP_HRD_BUFFER_SIZE,
333       g_param_spec_uint ("hrd-buffer-size",
334           "Hypothetical reference decoder buffer size",
335           "Hypothetical reference decoder buffer size. This "
336           "size controls the frame skip logic of the encoder. "
337           "For low delay applications this size should be "
338           "small. This size is in bits. Maximum Value is level "
339           "dependant and min value is 4096",
340           4096, G_MAXUINT, DEFAULT_HRD_BUFFER_SIZE, G_PARAM_READWRITE));
342   g_object_class_install_property (gobject_class, PROP_ENTROPY_CODING_MODE,
343       g_param_spec_enum ("entropy-coding-mode", "H.264 entropy coding mode",
344           "Controls the entropy coding type.",
345           GST_TYPE_DUCATI_H264ENC_ENTROPY_CODING_MODE,
346           IH264_ENTROPYCODING_DEFAULT, G_PARAM_READWRITE));
348   g_object_class_install_property (gobject_class, PROP_SLICE_MODE,
349       g_param_spec_enum ("slice-mode", "H.264 slice mode",
350           "This defines the control mechanism to split a picture in slices."
351           " It can be either MB based or bytes based",
352           GST_TYPE_DUCATI_H264ENC_SLICE_MODE,
353           IH264_SLICEMODE_DEFAULT, G_PARAM_READWRITE));
357 static void
358 gst_ducati_h264enc_init (GstDucatiH264Enc * self, GstDucatiH264EncClass * klass)
360   GST_DEBUG ("gst_ducati_h264enc_init");
362   self->profile = DEFAULT_PROFILE;
363   self->level = DEFAULT_LEVEL;
364   self->rate_control_params_preset = IH264_RATECONTROLPARAMS_DEFAULT;
365   self->rate_control_algo = IH264_RATECONTROL_DEFAULT;
366   self->qpi = DEFAULT_QPI;
367   self->qp_min_i = DEFAULT_QP_MIN_I;
368   self->qp_max_i = DEFAULT_QP_MAX_I;
369   self->hrd_buffer_size = DEFAULT_HRD_BUFFER_SIZE;
370   self->inter_interval = DEFAULT_INTER_INTERVAL;
373 static void
374 gst_ducati_h264enc_set_property (GObject * object, guint prop_id,
375     const GValue * value, GParamSpec * pspec)
377   GstDucatiH264Enc *self = GST_DUCATIH264ENC (object);
378   GstDucatiVidEnc *venc = GST_DUCATIVIDENC (object);
379   IH264ENC_DynamicParams *dynParams =
380       (IH264ENC_DynamicParams *) venc->dynParams;
382   self = GST_DUCATIH264ENC (object);
384   switch (prop_id) {
385     case PROP_PROFILE:
386       self->profile = g_value_get_enum (value);
387       break;
388     case PROP_LEVEL:
389       self->level = g_value_get_enum (value);
390       break;
391     case PROP_RATE_CONTROL_PARAMS_PRESET:
392       self->rate_control_params_preset = g_value_get_enum (value);
393       if (dynParams)
394         dynParams->rateControlParams.rateControlParamsPreset =
395             self->rate_control_params_preset;
396       break;
397     case PROP_RATE_CONTROL_ALGO:
398       self->rate_control_algo = g_value_get_enum (value);
400       if (self->rate_control_params_preset !=
401           IH264_RATECONTROLPARAMS_USERDEFINED)
402         GST_INFO_OBJECT (self,
403             "Setting rcAlgo but rateControlParamsPreset not "
404             "'rate-control-params-preset-user-defined' config won't be taken "
405             "into account");
407       if (dynParams)
408         dynParams->rateControlParams.rcAlgo = self->rate_control_algo;
409       break;
410     case PROP_QPI:
411       self->qpi = g_value_get_int (value);
412       if (dynParams)
413         dynParams->rateControlParams.qpI = self->qpi;
415       break;
416     case PROP_QP_MIN_I:
417       self->qp_min_i = g_value_get_int (value);
418       if (dynParams)
419         dynParams->rateControlParams.qpMinI = self->qp_min_i;
420       break;
421     case PROP_QP_MAX_I:
422       self->qp_max_i = g_value_get_int (value);
423       if (dynParams)
424         dynParams->rateControlParams.qpMaxI = self->qp_max_i;
425       break;
426     case PROP_HRD_BUFFER_SIZE:
427       self->hrd_buffer_size = g_value_get_uint (value);
428       break;
429     case PROP_ENTROPY_CODING_MODE:
430       self->entropy_coding_mode = g_value_get_enum (value);
431       break;
432     case PROP_SLICE_MODE:
433       self->slice_mode = g_value_get_enum (value);
434       break;
435     case PROP_INTER_INTERVAL:
436       self->inter_interval = g_value_get_uint (value);
437       break;
438     default:
439       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
440   }
443 static void
444 gst_ducati_h264enc_get_property (GObject * object, guint prop_id,
445     GValue * value, GParamSpec * pspec)
447   GstDucatiH264Enc *self = GST_DUCATIH264ENC (object);
449   g_return_if_fail (GST_IS_DUCATIH264ENC (object));
450   self = GST_DUCATIH264ENC (object);
452   switch (prop_id) {
453     case PROP_PROFILE:
454       g_value_set_enum (value, self->profile);
455       break;
456     case PROP_LEVEL:
457       g_value_set_enum (value, self->level);
458       break;
459     case PROP_RATE_CONTROL_PARAMS_PRESET:
460       g_value_set_enum (value, self->rate_control_params_preset);
461       break;
462     case PROP_RATE_CONTROL_ALGO:
463       g_value_set_enum (value, self->rate_control_algo);
464       break;
465     case PROP_QPI:
466       g_value_set_int (value, self->qpi);
467       break;
468     case PROP_QP_MIN_I:
469       g_value_set_int (value, self->qp_min_i);
470       break;
471     case PROP_QP_MAX_I:
472       g_value_set_int (value, self->qp_max_i);
473       break;
474     case PROP_HRD_BUFFER_SIZE:
475       g_value_set_uint (value, self->hrd_buffer_size);
476       break;
477     case PROP_ENTROPY_CODING_MODE:
478       g_value_set_enum (value, self->entropy_coding_mode);
479       break;
480     case PROP_SLICE_MODE:
481       g_value_set_enum (value, self->slice_mode);
482       break;
483     case PROP_INTER_INTERVAL:
484       g_value_set_uint (value, self->inter_interval);
485       break;
486     default:
487       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
488   }
491 static const char *
492 get_profile_name (guint profile)
494   switch (profile) {
495     case IH264_BASELINE_PROFILE:
496       return "baseline";
497     case IH264_MAIN_PROFILE:
498       return "main";
499     case IH264_EXTENDED_PROFILE:
500       return "extended";
501     case IH264_HIGH_PROFILE:
502       return "high";
503     case IH264_HIGH10_PROFILE:
504       return "high-10";
505     case IH264_HIGH422_PROFILE:
506       return "high-422";
507     default:
508       return NULL;
509   }
512 static const char *
513 get_level_name (guint level)
515   switch (level) {
516     case IH264_LEVEL_10:
517       return "1";
518     case IH264_LEVEL_1b:
519       return "1b";
520     case IH264_LEVEL_11:
521       return "1.1";
522     case IH264_LEVEL_12:
523       return "1.2";
524     case IH264_LEVEL_13:
525       return "1.3";
526     case IH264_LEVEL_20:
527       return "2";
528     case IH264_LEVEL_21:
529       return "2.1";
530     case IH264_LEVEL_22:
531       return "2.2";
532     case IH264_LEVEL_30:
533       return "3";
534     case IH264_LEVEL_31:
535       return "3.1";
536     case IH264_LEVEL_32:
537       return "3.2";
538     case IH264_LEVEL_40:
539       return "4";
540     case IH264_LEVEL_41:
541       return "4.1";
542     case IH264_LEVEL_42:
543       return "4.2";
544     case IH264_LEVEL_50:
545       return "5";
546     case IH264_LEVEL_51:
547       return "5.1";
548     default:
549       return NULL;
550   }
553 static gboolean
554 gst_ducati_h264enc_configure (GstDucatiVidEnc * videnc)
556   GstDucatiH264Enc *self = GST_DUCATIH264ENC (videnc);
557   IH264ENC_Params *params;
558   IH264ENC_DynamicParams *dynParams;
559   gboolean ret;
560   const char *s;
561   const GstVideoState *state;
562   GstCaps *caps;
563   int inter_interval;
565   ret = GST_DUCATIVIDENC_CLASS (parent_class)->configure (videnc);
566   if (!ret)
567     return FALSE;
569   videnc->params->profile = self->profile;
570   videnc->params->level = self->level;
572   inter_interval = self->inter_interval;
573   if (self->profile == IH264_BASELINE_PROFILE)
574     inter_interval = 1;
575   else if (videnc->rate_preset == IVIDEO_LOW_DELAY)
576     inter_interval = 1;
578   params = (IH264ENC_Params *) videnc->params;
579   /* this is the only non-base field strictly required */
580   params->maxIntraFrameInterval = 0x7fffffff;
581   params->IDRFrameInterval = 1;
582   params->numTemporalLayer = 1;
583   params->entropyCodingMode = self->entropy_coding_mode;
584   videnc->params->maxInterFrameInterval = inter_interval;
586   /* Dynamic params */
587   dynParams = (IH264ENC_DynamicParams *) videnc->dynParams;
588   dynParams->rateControlParams.rateControlParamsPreset =
589       self->rate_control_params_preset;
590   dynParams->rateControlParams.rcAlgo = self->rate_control_algo;
591   dynParams->rateControlParams.qpI = self->qpi;
592   dynParams->rateControlParams.qpMaxI = self->qp_max_i;
593   dynParams->rateControlParams.qpMinI = self->qp_min_i;
594   dynParams->rateControlParams.HRDBufferSize = self->hrd_buffer_size;
595   dynParams->sliceCodingParams.sliceMode = self->slice_mode;
596   videnc->dynParams->interFrameInterval = inter_interval;
598   state = gst_base_video_encoder_get_state (GST_BASE_VIDEO_ENCODER (videnc));
599   caps = gst_caps_new_simple ("video/x-h264",
600       "width", G_TYPE_INT, videnc->rect.w,
601       "height", G_TYPE_INT, videnc->rect.h,
602       "framerate", GST_TYPE_FRACTION, state->fps_n, state->fps_d,
603       "pixel-aspect-ratio", GST_TYPE_FRACTION, state->par_n, state->par_d,
604       "stream-format", G_TYPE_STRING, "byte-stream",
605       "align", G_TYPE_STRING, "au",
606       "num-reorder-frames", G_TYPE_INT, inter_interval - 1, NULL);
607   s = get_profile_name (self->profile);
608   if (s)
609     gst_caps_set_simple (caps, "profile", G_TYPE_STRING, s, NULL);
610   s = get_level_name (self->level);
611   if (s)
612     gst_caps_set_simple (caps, "level", G_TYPE_STRING, s, NULL);
613   ret = gst_pad_set_caps (GST_BASE_VIDEO_CODEC_SRC_PAD (self), caps);
615   return ret;
618 static gboolean
619 gst_ducati_h264enc_allocate_params (GstDucatiVidEnc *
620     videnc, gint params_sz, gint dynparams_sz, gint status_sz, gint inargs_sz,
621     gint outargs_sz)
623   gboolean ret = GST_DUCATIVIDENC_CLASS (parent_class)->allocate_params (videnc,
624       sizeof (IH264ENC_Params), sizeof (IH264ENC_DynamicParams),
625       sizeof (IVIDENC2_Status), sizeof (IVIDENC2_InArgs),
626       sizeof (IVIDENC2_OutArgs));
628   GstDucatiH264Enc *self = GST_DUCATIH264ENC (videnc);
630   if (ret == TRUE) {
631     IH264ENC_DynamicParams *dynParams =
632         (IH264ENC_DynamicParams *) videnc->dynParams;
634     dynParams->rateControlParams.rateControlParamsPreset =
635         self->rate_control_params_preset;
636     dynParams->rateControlParams.rcAlgo = self->rate_control_algo;
637     dynParams->rateControlParams.qpI = self->qpi;
638     dynParams->rateControlParams.qpMaxI = self->qp_max_i;
639     dynParams->rateControlParams.qpMinI = self->qp_min_i;
640     dynParams->rateControlParams.HRDBufferSize = self->hrd_buffer_size;
641     dynParams->sliceCodingParams.sliceMode = self->slice_mode;
642   }
644   return ret;
647 static gboolean
648 gst_ducati_h264enc_is_sync_point (GstDucatiVidEnc * enc, int type)
650   return type == IVIDEO_IDR_FRAME;