mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 16:50:47 +00:00
libs: encoder: h264: support ICQ/QVBR bitrate control mode
ICQ is Intelligent Constant Quality. It will use the initial QP vaule of icq-quality-factor to adjust QP at MB level intelligently to improve subjective quality. QVBR is Quality defined VBR. It will use qvbr-quality-factor to adjust QP for each MB to get enough quality picture without waste of bits.
This commit is contained in:
parent
f5c9d86f9c
commit
9e0c133a24
5 changed files with 71 additions and 1 deletions
|
@ -54,7 +54,9 @@
|
|||
(GST_VAAPI_RATECONTROL_MASK (CQP) | \
|
||||
GST_VAAPI_RATECONTROL_MASK (CBR) | \
|
||||
GST_VAAPI_RATECONTROL_MASK (VBR) | \
|
||||
GST_VAAPI_RATECONTROL_MASK (VBR_CONSTRAINED))
|
||||
GST_VAAPI_RATECONTROL_MASK (VBR_CONSTRAINED) | \
|
||||
GST_VAAPI_RATECONTROL_MASK (ICQ) | \
|
||||
GST_VAAPI_RATECONTROL_MASK (QVBR))
|
||||
|
||||
/* Supported set of tuning options, within this implementation */
|
||||
#define SUPPORTED_TUNE_OPTIONS \
|
||||
|
@ -753,6 +755,7 @@ struct _GstVaapiEncoderH264
|
|||
guint32 num_bframes;
|
||||
guint32 mb_width;
|
||||
guint32 mb_height;
|
||||
guint32 quality_factor;
|
||||
gboolean use_cabac;
|
||||
gboolean use_dct8x8;
|
||||
guint temporal_levels; /* Number of temporal levels */
|
||||
|
@ -2514,6 +2517,14 @@ ensure_control_rate_params (GstVaapiEncoderH264 * encoder)
|
|||
if (GST_VAAPI_ENCODER_RATE_CONTROL (encoder) == GST_VAAPI_RATECONTROL_CQP)
|
||||
return TRUE;
|
||||
|
||||
#if VA_CHECK_VERSION(1,1,0)
|
||||
if (GST_VAAPI_ENCODER_RATE_CONTROL (encoder) == GST_VAAPI_RATECONTROL_ICQ) {
|
||||
GST_VAAPI_ENCODER_VA_RATE_CONTROL (encoder).ICQ_quality_factor =
|
||||
encoder->quality_factor;
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* RateControl params */
|
||||
GST_VAAPI_ENCODER_VA_RATE_CONTROL (encoder).bits_per_second =
|
||||
encoder->bitrate_bits;
|
||||
|
@ -2530,6 +2541,11 @@ ensure_control_rate_params (GstVaapiEncoderH264 * encoder)
|
|||
(guint) encoder->mbbrc;
|
||||
#endif
|
||||
|
||||
#if VA_CHECK_VERSION(1,3,0)
|
||||
GST_VAAPI_ENCODER_VA_RATE_CONTROL (encoder).quality_factor =
|
||||
encoder->quality_factor;
|
||||
#endif
|
||||
|
||||
/* HRD params */
|
||||
fill_hrd_params (encoder, &GST_VAAPI_ENCODER_VA_HRD (encoder));
|
||||
|
||||
|
@ -2681,6 +2697,7 @@ ensure_bitrate (GstVaapiEncoderH264 * encoder)
|
|||
case GST_VAAPI_RATECONTROL_CBR:
|
||||
case GST_VAAPI_RATECONTROL_VBR:
|
||||
case GST_VAAPI_RATECONTROL_VBR_CONSTRAINED:
|
||||
case GST_VAAPI_RATECONTROL_QVBR:
|
||||
if (!base_encoder->bitrate) {
|
||||
/* According to the literature and testing, CABAC entropy coding
|
||||
mode could provide for +10% to +18% improvement in general,
|
||||
|
@ -3552,6 +3569,9 @@ gst_vaapi_encoder_h264_set_property (GstVaapiEncoder * base_encoder,
|
|||
case GST_VAAPI_ENCODER_H264_PROP_MAX_QP:
|
||||
encoder->max_qp = g_value_get_uint (value);
|
||||
break;
|
||||
case GST_VAAPI_ENCODER_H264_PROP_QUALITY_FACTOR:
|
||||
encoder->quality_factor = g_value_get_uint (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
return GST_VAAPI_ENCODER_STATUS_ERROR_INVALID_PARAMETER;
|
||||
|
@ -3838,6 +3858,19 @@ gst_vaapi_encoder_h264_get_default_properties (void)
|
|||
gst_vaapi_encoder_h264_compliance_mode_type (),
|
||||
GST_VAAPI_ENCODER_H264_COMPLIANCE_MODE_STRICT, G_PARAM_READWRITE));
|
||||
|
||||
/**
|
||||
* GstVaapiEncoderH264:quality_factor:
|
||||
*
|
||||
* quality factor used under ICQ/QVBR bitrate control mode.
|
||||
*/
|
||||
GST_VAAPI_ENCODER_PROPERTIES_APPEND (props,
|
||||
GST_VAAPI_ENCODER_H264_PROP_QUALITY_FACTOR,
|
||||
g_param_spec_uint ("quality-factor",
|
||||
"Quality factor for ICQ/QVBR",
|
||||
"quality factor for ICQ/QVBR bitrate control mode"
|
||||
"(low value means higher-quality, higher value means lower-quality)",
|
||||
1, 51, 26, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
return props;
|
||||
}
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@ typedef struct _GstVaapiEncoderH264 GstVaapiEncoderH264;
|
|||
* @GST_VAAPI_ENCODER_H264_PROP_TEMPORAL_LEVELS: Number of temporal levels
|
||||
* @GST_VAAPI_ENCODER_H264_PROP_PREDICTION_TYPE: Reference picture selection modes
|
||||
* @GST_VAAPI_ENCODER_H264_PROP_MAX_QP: Maximal quantizer value (uint).
|
||||
* @GST_VAAPI_ENCODER_H264_PROP_QUALITY_FACTOR: Factor for ICQ/QVBR bitrate control mode.
|
||||
*
|
||||
* The set of H.264 encoder specific configurable properties.
|
||||
*/
|
||||
|
@ -79,6 +80,7 @@ typedef enum {
|
|||
GST_VAAPI_ENCODER_H264_PROP_TEMPORAL_LEVELS = -16,
|
||||
GST_VAAPI_ENCODER_H264_PROP_PREDICTION_TYPE = -17,
|
||||
GST_VAAPI_ENCODER_H264_PROP_MAX_QP = -18,
|
||||
GST_VAAPI_ENCODER_H264_PROP_QUALITY_FACTOR = -19,
|
||||
} GstVaapiEncoderH264Prop;
|
||||
|
||||
GstVaapiEncoder *
|
||||
|
|
|
@ -148,6 +148,10 @@ typedef enum {
|
|||
* @GST_VAAPI_RATECONTROL_VBR_CONSTRAINED: Variable bitrate with peak
|
||||
* rate higher than average bitrate
|
||||
* @GST_VAAPI_RATECONTROL_MB: Macroblock based rate control
|
||||
* @GST_VAAPI_RATECONTROL_ICQ: Intelligent Constant QP, use
|
||||
* quality_factor to improve subjective quality base on motion
|
||||
* @GST_VAAPI_RATECONTROL_QVBR: Quality defined VBR, use
|
||||
* quality_factor to get good enough quality and save bits
|
||||
*
|
||||
* The set of allowed rate control values for #GstVaapiRateControl.
|
||||
* Note: this is only valid for encoders.
|
||||
|
@ -160,6 +164,8 @@ typedef enum {
|
|||
GST_VAAPI_RATECONTROL_VBR,
|
||||
GST_VAAPI_RATECONTROL_VBR_CONSTRAINED,
|
||||
GST_VAAPI_RATECONTROL_MB,
|
||||
GST_VAAPI_RATECONTROL_ICQ,
|
||||
GST_VAAPI_RATECONTROL_QVBR,
|
||||
} GstVaapiRateControl;
|
||||
|
||||
/* Define a mask for GstVaapiRateControl */
|
||||
|
|
|
@ -341,6 +341,14 @@ string_of_VARateControl (guint rate_control)
|
|||
#if VA_CHECK_VERSION(0,39,1)
|
||||
case VA_RC_MB:
|
||||
return "MB";
|
||||
#endif
|
||||
#if VA_CHECK_VERSION(1,1,0)
|
||||
case VA_RC_ICQ:
|
||||
return "VA_RC_ICQ";
|
||||
#endif
|
||||
#if VA_CHECK_VERSION(1,3,0)
|
||||
case VA_RC_QVBR:
|
||||
return "VA_RC_QVBR";
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
|
@ -710,6 +718,14 @@ from_GstVaapiRateControl (guint value)
|
|||
#if VA_CHECK_VERSION(0,39,1)
|
||||
case GST_VAAPI_RATECONTROL_MB:
|
||||
return VA_RC_MB;
|
||||
#endif
|
||||
#if VA_CHECK_VERSION(1,1,0)
|
||||
case GST_VAAPI_RATECONTROL_ICQ:
|
||||
return VA_RC_ICQ;
|
||||
#endif
|
||||
#if VA_CHECK_VERSION(1,3,0)
|
||||
case GST_VAAPI_RATECONTROL_QVBR:
|
||||
return VA_RC_QVBR;
|
||||
#endif
|
||||
}
|
||||
GST_ERROR ("unsupported GstVaapiRateControl value %u", value);
|
||||
|
@ -736,6 +752,15 @@ to_GstVaapiRateControl (guint value)
|
|||
case VA_RC_MB:
|
||||
return GST_VAAPI_RATECONTROL_MB;
|
||||
#endif
|
||||
#if VA_CHECK_VERSION(1,1,0)
|
||||
case VA_RC_ICQ:
|
||||
return GST_VAAPI_RATECONTROL_ICQ;
|
||||
#endif
|
||||
#if VA_CHECK_VERSION(1,3,0)
|
||||
case VA_RC_QVBR:
|
||||
return GST_VAAPI_RATECONTROL_QVBR;
|
||||
#endif
|
||||
|
||||
}
|
||||
GST_ERROR ("unsupported VA-API Rate Control value %u", value);
|
||||
return GST_VAAPI_RATECONTROL_NONE;
|
||||
|
|
|
@ -150,6 +150,10 @@ gst_vaapi_rate_control_get_type (void)
|
|||
"Variable bitrate - Constrained", "vbr_constrained"},
|
||||
{GST_VAAPI_RATECONTROL_MB,
|
||||
"Macroblock based rate control", "mb"},
|
||||
{GST_VAAPI_RATECONTROL_ICQ,
|
||||
"Constant QP - Intelligent", "icq"},
|
||||
{GST_VAAPI_RATECONTROL_QVBR,
|
||||
"Variable bitrate - Quality defined", "qvbr"},
|
||||
{0, NULL, NULL},
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue