diff --git a/gst-libs/gst/vaapi/gstvaapiencoder.c b/gst-libs/gst/vaapi/gstvaapiencoder.c index f0e694c974..8befeeed70 100644 --- a/gst-libs/gst/vaapi/gstvaapiencoder.c +++ b/gst-libs/gst/vaapi/gstvaapiencoder.c @@ -1702,3 +1702,25 @@ gst_vaapi_encoder_tune_get_type (void) } return g_type; } + +/** Returns a GType for the #GstVaapiEncoderMbbrc set */ +GType +gst_vaapi_encoder_mbbrc_get_type (void) +{ + static volatile gsize g_type = 0; + + if (g_once_init_enter (&g_type)) { + static const GEnumValue encoder_mbbrc_values[] = { + {GST_VAAPI_ENCODER_MBBRC_AUTO, "Auto", "auto"}, + {GST_VAAPI_ENCODER_MBBRC_ON, "On", "on"}, + {GST_VAAPI_ENCODER_MBBRC_OFF, "Off", "off"}, + {0, NULL, NULL}, + }; + + GType type = + g_enum_register_static (g_intern_static_string ("GstVaapiEncoderMbbrc"), + encoder_mbbrc_values); + g_once_init_leave (&g_type, type); + } + return g_type; +} diff --git a/gst-libs/gst/vaapi/gstvaapiencoder.h b/gst-libs/gst/vaapi/gstvaapiencoder.h index e3627ac2cc..d186905733 100644 --- a/gst-libs/gst/vaapi/gstvaapiencoder.h +++ b/gst-libs/gst/vaapi/gstvaapiencoder.h @@ -93,6 +93,23 @@ typedef enum { GST_VAAPI_ENCODER_TUNE_LOW_POWER, } GstVaapiEncoderTune; +/** + * GstVaapiEncoderMbbrc: + * @GST_VAAPI_ENCODER_MBBRC_AUTO: bitrate control auto + * @GST_VAAPI_ENCODER_MBBRC_ON: bitrate control on + * @GST_VAAPI_ENCODER_MBBRC_OFF: bitrate control off + * + * Values for the macroblock level bitrate control. + * + * This property values are only available for H264 and H265 (HEVC) + * encoders, when rate control is not Constant QP. + **/ +typedef enum { + GST_VAAPI_ENCODER_MBBRC_AUTO = 0, + GST_VAAPI_ENCODER_MBBRC_ON = 1, + GST_VAAPI_ENCODER_MBBRC_OFF = 2, +} GstVaapiEncoderMbbrc; + /** * GstVaapiEncoderProp: * @GST_VAAPI_ENCODER_PROP_RATECONTROL: Rate control (#GstVaapiRateControl). @@ -131,6 +148,9 @@ typedef struct _GstVaapiROI { GType gst_vaapi_encoder_tune_get_type (void) G_GNUC_CONST; +GType +gst_vaapi_encoder_mbbrc_get_type (void) G_GNUC_CONST; + GstVaapiEncoder * gst_vaapi_encoder_ref (GstVaapiEncoder * encoder); diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_h264.c b/gst-libs/gst/vaapi/gstvaapiencoder_h264.c index 949f268665..cd9adf808d 100644 --- a/gst-libs/gst/vaapi/gstvaapiencoder_h264.c +++ b/gst-libs/gst/vaapi/gstvaapiencoder_h264.c @@ -737,7 +737,7 @@ struct _GstVaapiEncoderH264 guint bitrate_bits; // bitrate (bits) guint cpb_length; // length of CPB buffer (ms) guint cpb_length_bits; // length of CPB buffer (bits) - guint mbbrc; // macroblock bitrate control + GstVaapiEncoderMbbrc mbbrc; // macroblock bitrate control /* MVC */ gboolean is_mvc; @@ -2288,7 +2288,7 @@ ensure_control_rate_params (GstVaapiEncoderH264 * encoder) GST_VAAPI_ENCODER_VA_RATE_CONTROL (encoder).initial_qp = encoder->init_qp; GST_VAAPI_ENCODER_VA_RATE_CONTROL (encoder).min_qp = encoder->min_qp; GST_VAAPI_ENCODER_VA_RATE_CONTROL (encoder).rc_flags.bits.mb_rate_control = - encoder->mbbrc; + (guint) encoder->mbbrc; /* HRD params */ fill_hrd_params (encoder, &GST_VAAPI_ENCODER_VA_HRD (encoder)); @@ -3117,7 +3117,7 @@ gst_vaapi_encoder_h264_set_property (GstVaapiEncoder * base_encoder, encoder->num_ref_frames = g_value_get_uint (value); break; case GST_VAAPI_ENCODER_H264_PROP_MBBRC: - encoder->mbbrc = g_value_get_uint (value); + encoder->mbbrc = g_value_get_enum (value); break; default: @@ -3294,10 +3294,11 @@ gst_vaapi_encoder_h264_get_default_properties (void) */ GST_VAAPI_ENCODER_PROPERTIES_APPEND (props, GST_VAAPI_ENCODER_H264_PROP_MBBRC, - g_param_spec_uint ("mbbrc", + g_param_spec_enum ("mbbrc", "Macroblock level Bitrate Control", - "Macroblock level Bitrate Control (0: auto, 1: on, 2: off)", 0, 2, - 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + "Macroblock level Bitrate Control", + GST_VAAPI_TYPE_ENCODER_MBBRC, GST_VAAPI_ENCODER_MBBRC_AUTO, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); /** * GstVaapiEncoderH264:cpb-length: diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_h265.c b/gst-libs/gst/vaapi/gstvaapiencoder_h265.c index 603ab6c94e..5e4c84081b 100644 --- a/gst-libs/gst/vaapi/gstvaapiencoder_h265.c +++ b/gst-libs/gst/vaapi/gstvaapiencoder_h265.c @@ -130,7 +130,7 @@ struct _GstVaapiEncoderH265 guint bitrate_bits; // bitrate (bits) guint cpb_length; // length of CPB buffer (ms) guint cpb_length_bits; // length of CPB buffer (bits) - guint mbbrc; // macroblock bitrate control + GstVaapiEncoderMbbrc mbbrc; // macroblock bitrate control /* Crop rectangle */ guint conformance_window_flag:1; @@ -1834,7 +1834,7 @@ ensure_control_rate_params (GstVaapiEncoderH265 * encoder) GST_VAAPI_ENCODER_VA_RATE_CONTROL (encoder).initial_qp = encoder->init_qp; GST_VAAPI_ENCODER_VA_RATE_CONTROL (encoder).min_qp = encoder->min_qp; GST_VAAPI_ENCODER_VA_RATE_CONTROL (encoder).rc_flags.bits.mb_rate_control = - encoder->mbbrc; + (guint) encoder->mbbrc; /* HRD params */ fill_hrd_params (encoder, &GST_VAAPI_ENCODER_VA_HRD (encoder)); @@ -2576,7 +2576,7 @@ gst_vaapi_encoder_h265_set_property (GstVaapiEncoder * base_encoder, encoder->num_ref_frames = g_value_get_uint (value); break; case GST_VAAPI_ENCODER_H265_PROP_MBBRC: - encoder->mbbrc = g_value_get_uint (value); + encoder->mbbrc = g_value_get_enum (value); break; default: return GST_VAAPI_ENCODER_STATUS_ERROR_INVALID_PARAMETER; @@ -2737,10 +2737,11 @@ gst_vaapi_encoder_h265_get_default_properties (void) */ GST_VAAPI_ENCODER_PROPERTIES_APPEND (props, GST_VAAPI_ENCODER_H265_PROP_MBBRC, - g_param_spec_uint ("mbbrc", + g_param_spec_enum ("mbbrc", "Macroblock level Bitrate Control", - "Macroblock level Bitrate Control (0: auto, 1: on, 2: off)", 0, 2, - 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + "Macroblock level Bitrate Control", + GST_VAAPI_TYPE_ENCODER_MBBRC, GST_VAAPI_ENCODER_MBBRC_AUTO, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); return props; } diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_priv.h b/gst-libs/gst/vaapi/gstvaapiencoder_priv.h index ead9f5eec3..d71a49e1aa 100644 --- a/gst-libs/gst/vaapi/gstvaapiencoder_priv.h +++ b/gst-libs/gst/vaapi/gstvaapiencoder_priv.h @@ -215,6 +215,9 @@ G_BEGIN_DECLS #define GST_VAAPI_TYPE_ENCODER_TUNE \ (gst_vaapi_encoder_tune_get_type ()) +#define GST_VAAPI_TYPE_ENCODER_MBBRC \ + (gst_vaapi_encoder_mbbrc_get_type ()) + typedef struct _GstVaapiEncoderClass GstVaapiEncoderClass; typedef struct _GstVaapiEncoderClassData GstVaapiEncoderClassData;