libs: encoder: h264: Add mbbrc property

This property supports Macroblock level Bitrate Control as the
following:
0: auto
1: on
2: off

https://bugzilla.gnome.org/show_bug.cgi?id=785917
This commit is contained in:
Hyunjun Ko 2017-09-13 12:02:53 +09:00 committed by Víctor Manuel Jáquez Leal
parent aa6aa996d6
commit 6816d7c151
2 changed files with 21 additions and 0 deletions

View file

@ -734,6 +734,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
/* MVC */
gboolean is_mvc;
@ -2270,6 +2271,8 @@ ensure_control_rate_params (GstVaapiEncoderH264 * encoder)
GST_VAAPI_ENCODER_VA_RATE_CONTROL (encoder).window_size = encoder->cpb_length;
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;
/* HRD params */
fill_hrd_params (encoder, &GST_VAAPI_ENCODER_VA_HRD (encoder));
@ -3092,6 +3095,9 @@ gst_vaapi_encoder_h264_set_property (GstVaapiEncoder * base_encoder,
case GST_VAAPI_ENCODER_H264_PROP_NUM_REF_FRAMES:
encoder->num_ref_frames = g_value_get_uint (value);
break;
case GST_VAAPI_ENCODER_H264_PROP_MBBRC:
encoder->mbbrc = g_value_get_uint (value);
break;
default:
return GST_VAAPI_ENCODER_STATUS_ERROR_INVALID_PARAMETER;
@ -3233,6 +3239,19 @@ gst_vaapi_encoder_h264_get_default_properties (void)
"Enable adaptive use of 8x8 transforms in I-frames",
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GstVaapiEncoderH264:mbbrc:
*
* Macroblock level bitrate control.
* This is not compatible with Constant QP rate control.
*/
GST_VAAPI_ENCODER_PROPERTIES_APPEND (props,
GST_VAAPI_ENCODER_H264_PROP_MBBRC,
g_param_spec_uint ("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));
/**
* GstVaapiEncoderH264:cpb-length:
*

View file

@ -51,6 +51,7 @@ typedef struct _GstVaapiEncoderH264 GstVaapiEncoderH264;
* @GST_VAAPI_ENCODER_H264_PROP_AUD: Insert AUD as first NAL per frame.
* @GST_VAAPI_ENCODER_H264_PROP_COMPLIANCE_MODE: Relax Compliance restrictions
* @GST_VAAPI_ENCODER_H264_PROP_NUM_REF_FRAMES: Maximum number of reference frames.
* @GST_VAAPI_ENCODER_H264_PROP_MBBRC: Macroblock level Bitrate Control.
*
* The set of H.264 encoder specific configurable properties.
*/
@ -67,6 +68,7 @@ typedef enum {
GST_VAAPI_ENCODER_H264_PROP_AUD = -10,
GST_VAAPI_ENCODER_H264_PROP_COMPLIANCE_MODE = -11,
GST_VAAPI_ENCODER_H264_PROP_NUM_REF_FRAMES = -12,
GST_VAAPI_ENCODER_H264_PROP_MBBRC = -13,
} GstVaapiEncoderH264Prop;
GstVaapiEncoder *