libs: encoder: Fix the quality level clamping

Change the hard-coded range of quality-level from {1-8} to {1-7},
since it is the range Intel Open source driver supports.
Also perform the range clamping only if the user provided
quality-level is greater than the max-range suppored by the driver,
because there could be non-intel drivers giving lower value than
the hard-coded max value 7.

https://bugzilla.gnome.org/show_bug.cgi?id=783567
This commit is contained in:
Sreerenj Balachandran 2017-06-09 14:02:20 -07:00 committed by Víctor Manuel Jáquez Leal
parent eee8a78173
commit 595f8b7d4b

View file

@ -188,9 +188,10 @@ gst_vaapi_encoder_properties_get_default (const GstVaapiEncoderClass * klass)
GST_VAAPI_ENCODER_PROPERTIES_APPEND (props, GST_VAAPI_ENCODER_PROPERTIES_APPEND (props,
GST_VAAPI_ENCODER_PROP_QUALITY_LEVEL, GST_VAAPI_ENCODER_PROP_QUALITY_LEVEL,
g_param_spec_uint ("quality-level", g_param_spec_uint ("quality-level",
"Quality Level", "Quality Level", "Encoding Quality Level "
"Encoding Quality Level ", 1, 8, "(lower value means higher-quality/slow-encode, "
4, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); " higher value means lower-quality/fast-encode)",
1, 7, 4, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
return props; return props;
} }
@ -840,8 +841,7 @@ gst_vaapi_encoder_reconfigure_internal (GstVaapiEncoder * encoder)
if (get_config_attribute (encoder, VAConfigAttribEncQualityRange, if (get_config_attribute (encoder, VAConfigAttribEncQualityRange,
&quality_level_max) && quality_level_max > 0) { &quality_level_max) && quality_level_max > 0) {
GST_VAAPI_ENCODER_QUALITY_LEVEL (encoder) = GST_VAAPI_ENCODER_QUALITY_LEVEL (encoder) =
gst_util_uint64_scale_int_ceil (GST_VAAPI_ENCODER_QUALITY_LEVEL CLAMP (GST_VAAPI_ENCODER_QUALITY_LEVEL (encoder), 1, quality_level_max);
(encoder), quality_level_max, 8);
} else { } else {
GST_VAAPI_ENCODER_QUALITY_LEVEL (encoder) = 0; GST_VAAPI_ENCODER_QUALITY_LEVEL (encoder) = 0;
} }