libs: filter: use macro for returning op default value

The code is essentially the same for getting all op default
values.  Thus, use a macro to help minimize code duplication
and [hopefully] encourage using the same mechanism for all
default getters.
This commit is contained in:
U. Artie Eoff 2019-10-07 11:39:19 -07:00
parent 6690031b2b
commit f232f87f70

View file

@ -308,6 +308,15 @@ vpp_get_pipeline_caps (GstVaapiFilter * filter)
#define DEFAULT_FORMAT GST_VIDEO_FORMAT_UNKNOWN #define DEFAULT_FORMAT GST_VIDEO_FORMAT_UNKNOWN
#define OP_DATA_DEFAULT_VALUE(type, op_data) \
g_value_get_##type (g_param_spec_get_default_value (op_data->pspec))
#define OP_RET_DEFAULT_VALUE(type, filter, op) \
do { \
g_return_val_if_fail (filter != NULL, FALSE); \
return OP_DATA_DEFAULT_VALUE (type, find_operation (filter, op)); \
} while (0)
enum enum
{ {
PROP_DISPLAY = 1, PROP_DISPLAY = 1,
@ -2165,91 +2174,61 @@ op_get_bool_default_value (GstVaapiFilter * filter,
gfloat gfloat
gst_vaapi_filter_get_denoising_level_default (GstVaapiFilter * filter) gst_vaapi_filter_get_denoising_level_default (GstVaapiFilter * filter)
{ {
g_return_val_if_fail (filter != NULL, FALSE); OP_RET_DEFAULT_VALUE (float, filter, GST_VAAPI_FILTER_OP_DENOISE);
return op_get_float_default_value (filter,
find_operation (filter, GST_VAAPI_FILTER_OP_DENOISE));
} }
gfloat gfloat
gst_vaapi_filter_get_sharpening_level_default (GstVaapiFilter * filter) gst_vaapi_filter_get_sharpening_level_default (GstVaapiFilter * filter)
{ {
g_return_val_if_fail (filter != NULL, FALSE); OP_RET_DEFAULT_VALUE (float, filter, GST_VAAPI_FILTER_OP_SHARPEN);
return op_get_float_default_value (filter,
find_operation (filter, GST_VAAPI_FILTER_OP_SHARPEN));
} }
gfloat gfloat
gst_vaapi_filter_get_hue_default (GstVaapiFilter * filter) gst_vaapi_filter_get_hue_default (GstVaapiFilter * filter)
{ {
g_return_val_if_fail (filter != NULL, FALSE); OP_RET_DEFAULT_VALUE (float, filter, GST_VAAPI_FILTER_OP_HUE);
return op_get_float_default_value (filter,
find_operation (filter, GST_VAAPI_FILTER_OP_HUE));
} }
gfloat gfloat
gst_vaapi_filter_get_saturation_default (GstVaapiFilter * filter) gst_vaapi_filter_get_saturation_default (GstVaapiFilter * filter)
{ {
g_return_val_if_fail (filter != NULL, FALSE); OP_RET_DEFAULT_VALUE (float, filter, GST_VAAPI_FILTER_OP_SATURATION);
return op_get_float_default_value (filter,
find_operation (filter, GST_VAAPI_FILTER_OP_SATURATION));
} }
gfloat gfloat
gst_vaapi_filter_get_brightness_default (GstVaapiFilter * filter) gst_vaapi_filter_get_brightness_default (GstVaapiFilter * filter)
{ {
g_return_val_if_fail (filter != NULL, FALSE); OP_RET_DEFAULT_VALUE (float, filter, GST_VAAPI_FILTER_OP_BRIGHTNESS);
return op_get_float_default_value (filter,
find_operation (filter, GST_VAAPI_FILTER_OP_BRIGHTNESS));
} }
gfloat gfloat
gst_vaapi_filter_get_contrast_default (GstVaapiFilter * filter) gst_vaapi_filter_get_contrast_default (GstVaapiFilter * filter)
{ {
g_return_val_if_fail (filter != NULL, FALSE); OP_RET_DEFAULT_VALUE (float, filter, GST_VAAPI_FILTER_OP_CONTRAST);
return op_get_float_default_value (filter,
find_operation (filter, GST_VAAPI_FILTER_OP_CONTRAST));
} }
GstVaapiScaleMethod GstVaapiScaleMethod
gst_vaapi_filter_get_scaling_default (GstVaapiFilter * filter) gst_vaapi_filter_get_scaling_default (GstVaapiFilter * filter)
{ {
g_return_val_if_fail (filter != NULL, FALSE); OP_RET_DEFAULT_VALUE (enum, filter, GST_VAAPI_FILTER_OP_SCALING);
return op_get_enum_default_value (filter,
find_operation (filter, GST_VAAPI_FILTER_OP_SCALING));
} }
#ifndef GST_REMOVE_DEPRECATED #ifndef GST_REMOVE_DEPRECATED
gboolean gboolean
gst_vaapi_filter_get_skintone_default (GstVaapiFilter * filter) gst_vaapi_filter_get_skintone_default (GstVaapiFilter * filter)
{ {
g_return_val_if_fail (filter != NULL, FALSE); OP_RET_DEFAULT_VALUE (boolean, filter, GST_VAAPI_FILTER_OP_SKINTONE);
return op_get_bool_default_value (filter,
find_operation (filter, GST_VAAPI_FILTER_OP_SKINTONE));
} }
#endif #endif
guint guint
gst_vaapi_filter_get_skintone_level_default (GstVaapiFilter * filter) gst_vaapi_filter_get_skintone_level_default (GstVaapiFilter * filter)
{ {
g_return_val_if_fail (filter != NULL, FALSE); OP_RET_DEFAULT_VALUE (uint, filter, GST_VAAPI_FILTER_OP_SKINTONE_LEVEL);
return op_get_uint_default_value (filter,
find_operation (filter, GST_VAAPI_FILTER_OP_SKINTONE_LEVEL));
} }
GstVideoOrientationMethod GstVideoOrientationMethod
gst_vaapi_filter_get_video_direction_default (GstVaapiFilter * filter) gst_vaapi_filter_get_video_direction_default (GstVaapiFilter * filter)
{ {
g_return_val_if_fail (filter != NULL, FALSE); OP_RET_DEFAULT_VALUE (boolean, filter, GST_VAAPI_FILTER_OP_VIDEO_DIRECTION);
return op_get_enum_default_value (filter,
find_operation (filter, GST_VAAPI_FILTER_OP_VIDEO_DIRECTION));
} }