mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-18 07:47:17 +00:00
vah264enc: Fail if unsupported rate control.
Handle when encoder doesn't support rate control, which is set as VA_RC_NONE, and if the set rate control mode is not supported by the GStreamer element, the element configuration fails. Also it logs out max and target bitrate. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3063>
This commit is contained in:
parent
5e531c1a88
commit
4ffb3663a8
2 changed files with 21 additions and 4 deletions
|
@ -342,7 +342,6 @@ gst_va_encoder_open (GstVaEncoder * self, VAProfile profile,
|
|||
/* *INDENT-OFF* */
|
||||
VAConfigAttrib attribs[3] = {
|
||||
{ .type = VAConfigAttribRTFormat, .value = rt_format, },
|
||||
{ .type = VAConfigAttribRateControl, .value = rc_ctrl, },
|
||||
};
|
||||
/* *INDENT-ON* */
|
||||
VAConfigID config = VA_INVALID_ID;
|
||||
|
@ -365,6 +364,12 @@ gst_va_encoder_open (GstVaEncoder * self, VAProfile profile,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (rc_ctrl != VA_RC_NONE) {
|
||||
attribs[attrib_idx].type = VAConfigAttribRateControl;
|
||||
attribs[attrib_idx].value = rc_ctrl;
|
||||
attrib_idx++;
|
||||
}
|
||||
|
||||
if (packed_headers > 0) {
|
||||
attribs[attrib_idx].type = VAConfigAttribEncPackedHeaders;
|
||||
attribs[attrib_idx].value = packed_headers;
|
||||
|
|
|
@ -441,7 +441,7 @@ _calculate_bitrate_hrd (GstVaH264Enc * self)
|
|||
update_property (bool, obj, old_val, new_val, prop_id)
|
||||
|
||||
/* Estimates a good enough bitrate if none was supplied */
|
||||
static void
|
||||
static gboolean
|
||||
_ensure_rate_control (GstVaH264Enc * self)
|
||||
{
|
||||
/* User can specify the properties of: "bitrate", "target-percentage",
|
||||
|
@ -604,6 +604,7 @@ _ensure_rate_control (GstVaH264Enc * self)
|
|||
|
||||
/* Adjust the setting based on RC mode. */
|
||||
switch (self->rc.rc_ctrl_mode) {
|
||||
case VA_RC_NONE:
|
||||
case VA_RC_CQP:
|
||||
self->rc.max_bitrate = 0;
|
||||
self->rc.target_bitrate = 0;
|
||||
|
@ -636,9 +637,17 @@ _ensure_rate_control (GstVaH264Enc * self)
|
|||
self->gop.b_pyramid = FALSE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
GST_WARNING_OBJECT (self, "Unsupported rate control");
|
||||
return FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (self->rc.rc_ctrl_mode != VA_RC_CQP)
|
||||
GST_DEBUG_OBJECT (self, "Max bitrate: %u bits/sec, "
|
||||
"Target bitrate: %u bits/sec", self->rc.max_bitrate,
|
||||
self->rc.target_bitrate);
|
||||
|
||||
if (self->rc.rc_ctrl_mode != VA_RC_NONE && self->rc.rc_ctrl_mode != VA_RC_CQP)
|
||||
_calculate_bitrate_hrd (self);
|
||||
|
||||
/* update & notifications */
|
||||
|
@ -650,6 +659,8 @@ _ensure_rate_control (GstVaH264Enc * self)
|
|||
update_property_uint (base, &self->prop.qp_i, self->rc.qp_i, PROP_QP_I);
|
||||
update_property_uint (base, &self->prop.qp_p, self->rc.qp_p, PROP_QP_P);
|
||||
update_property_uint (base, &self->prop.qp_b, self->rc.qp_b, PROP_QP_B);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static guint
|
||||
|
@ -1545,7 +1556,8 @@ gst_va_h264_enc_reconfig (GstVaBaseEnc * base)
|
|||
|
||||
_validate_parameters (self);
|
||||
|
||||
_ensure_rate_control (self);
|
||||
if (!_ensure_rate_control (self))
|
||||
return FALSE;
|
||||
|
||||
if (!_calculate_level (self))
|
||||
return FALSE;
|
||||
|
|
Loading…
Reference in a new issue