libs: encoder: Add properties for jpeg encoder.

Install properties for jpeg encoder class. Also set the new get/set
property functions for gobject class. Still use the old properties
way now and this new feature will be enabled later.
This commit is contained in:
He Junyan 2019-08-20 14:53:06 +08:00
parent 9348ed9e1c
commit 8641c27a13

View file

@ -763,7 +763,7 @@ gst_vaapi_encoder_jpeg_init (GstVaapiEncoderJpeg * encoder)
}
static GstVaapiEncoderStatus
gst_vaapi_encoder_jpeg_set_property (GstVaapiEncoder * base_encoder,
_gst_vaapi_encoder_jpeg_set_property (GstVaapiEncoder * base_encoder,
gint prop_id, const GValue * value)
{
GstVaapiEncoderJpeg *const encoder = GST_VAAPI_ENCODER_JPEG (base_encoder);
@ -778,11 +778,80 @@ gst_vaapi_encoder_jpeg_set_property (GstVaapiEncoder * base_encoder,
return GST_VAAPI_ENCODER_STATUS_SUCCESS;
}
/**
* @ENCODER_JPEG_PROP_RATECONTROL: Rate control (#GstVaapiRateControl).
* @ENCODER_JPEG_PROP_TUNE: The tuning options (#GstVaapiEncoderTune).
* @ENCODER_JPEG_PROP_QUALITY: Quality Factor value (uint).
*
* The set of JPEG encoder specific configurable properties.
*/
enum
{
ENCODER_JPEG_PROP_RATECONTROL = 1,
ENCODER_JPEG_PROP_TUNE,
ENCODER_JPEG_PROP_QUALITY,
ENCODER_JPEG_N_PROPERTIES
};
static GParamSpec *properties[ENCODER_JPEG_N_PROPERTIES];
static void
gst_vaapi_encoder_jpeg_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstVaapiEncoder *const base_encoder = GST_VAAPI_ENCODER (object);
GstVaapiEncoderJpeg *const encoder = GST_VAAPI_ENCODER_JPEG (object);
if (base_encoder->num_codedbuf_queued > 0) {
GST_ERROR_OBJECT (object,
"failed to set any property after encoding started");
return;
}
switch (prop_id) {
case ENCODER_JPEG_PROP_RATECONTROL:
gst_vaapi_encoder_set_rate_control (base_encoder,
g_value_get_enum (value));
break;
case ENCODER_JPEG_PROP_TUNE:
gst_vaapi_encoder_set_tuning (base_encoder, g_value_get_enum (value));
break;
case ENCODER_JPEG_PROP_QUALITY:
encoder->quality = g_value_get_uint (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
gst_vaapi_encoder_jpeg_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstVaapiEncoderJpeg *const encoder = GST_VAAPI_ENCODER_JPEG (object);
GstVaapiEncoder *const base_encoder = GST_VAAPI_ENCODER (object);
switch (prop_id) {
case ENCODER_JPEG_PROP_RATECONTROL:
g_value_set_enum (value, base_encoder->rate_control);
break;
case ENCODER_JPEG_PROP_TUNE:
g_value_set_enum (value, base_encoder->tune);
break;
case ENCODER_JPEG_PROP_QUALITY:
g_value_set_uint (value, encoder->quality);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
GST_VAAPI_ENCODER_DEFINE_CLASS_DATA (JPEG);
static void
gst_vaapi_encoder_jpeg_class_init (GstVaapiEncoderJpegClass * klass)
{
GObjectClass *const object_class = G_OBJECT_CLASS (klass);
GstVaapiEncoderClass *const encoder_class = GST_VAAPI_ENCODER_CLASS (klass);
encoder_class->class_data = &g_class_data;
@ -792,7 +861,33 @@ gst_vaapi_encoder_jpeg_class_init (GstVaapiEncoderJpegClass * klass)
encoder_class->reordering = gst_vaapi_encoder_jpeg_reordering;
encoder_class->encode = gst_vaapi_encoder_jpeg_encode;
encoder_class->flush = gst_vaapi_encoder_jpeg_flush;
encoder_class->set_property = gst_vaapi_encoder_jpeg_set_property;
encoder_class->set_property = _gst_vaapi_encoder_jpeg_set_property;
object_class->set_property = gst_vaapi_encoder_jpeg_set_property;
object_class->get_property = gst_vaapi_encoder_jpeg_get_property;
properties[ENCODER_JPEG_PROP_RATECONTROL] =
g_param_spec_enum ("rate-control",
"Rate Control", "Rate control mode",
g_class_data.rate_control_get_type (),
g_class_data.default_rate_control,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
properties[ENCODER_JPEG_PROP_TUNE] =
g_param_spec_enum ("tune",
"Encoder Tuning",
"Encoder tuning option",
g_class_data.encoder_tune_get_type (),
g_class_data.default_encoder_tune,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
properties[ENCODER_JPEG_PROP_QUALITY] =
g_param_spec_uint ("quality",
"Quality factor",
"Quality factor", 0, 100, 50, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, ENCODER_JPEG_N_PROPERTIES,
properties);
}
/**