From 6816d7c151111087a539309fdf27fd92931ffcaf Mon Sep 17 00:00:00 2001 From: Hyunjun Ko Date: Wed, 13 Sep 2017 12:02:53 +0900 Subject: [PATCH] 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 --- gst-libs/gst/vaapi/gstvaapiencoder_h264.c | 19 +++++++++++++++++++ gst-libs/gst/vaapi/gstvaapiencoder_h264.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_h264.c b/gst-libs/gst/vaapi/gstvaapiencoder_h264.c index 5512a50..61fd9d2 100644 --- a/gst-libs/gst/vaapi/gstvaapiencoder_h264.c +++ b/gst-libs/gst/vaapi/gstvaapiencoder_h264.c @@ -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; @@ -3234,6 +3240,19 @@ gst_vaapi_encoder_h264_get_default_properties (void) 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: * * The size of the CPB buffer in milliseconds. diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_h264.h b/gst-libs/gst/vaapi/gstvaapiencoder_h264.h index 89eab76..b56416a 100644 --- a/gst-libs/gst/vaapi/gstvaapiencoder_h264.h +++ b/gst-libs/gst/vaapi/gstvaapiencoder_h264.h @@ -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 * -- 2.7.4