mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 18:21:04 +00:00
vaapipostproc: Use level value for skin-tone-enhancement filter.
Currently the parameter of skin-tone-enhancement filter is forced to zero. In fact it could be set different value by the user. So create a new property named as "skin-tone-enhancement-level" for accepting the used defined parameter value. At the same time, skin-tone-enhancement is marked as deprecated. When skin-tone-enhancement-level is set, skin-tone-enhancement will be ignored.
This commit is contained in:
parent
f67ec886a3
commit
4c87644914
4 changed files with 179 additions and 14 deletions
|
@ -330,7 +330,10 @@ enum
|
|||
PROP_DEINTERLACING = GST_VAAPI_FILTER_OP_DEINTERLACING,
|
||||
PROP_SCALING = GST_VAAPI_FILTER_OP_SCALING,
|
||||
PROP_VIDEO_DIRECTION = GST_VAAPI_FILTER_OP_VIDEO_DIRECTION,
|
||||
#ifndef GST_REMOVE_DEPRECATED
|
||||
PROP_SKINTONE = GST_VAAPI_FILTER_OP_SKINTONE,
|
||||
#endif
|
||||
PROP_SKINTONE_LEVEL = GST_VAAPI_FILTER_OP_SKINTONE_LEVEL,
|
||||
|
||||
N_PROPERTIES
|
||||
};
|
||||
|
@ -465,6 +468,7 @@ init_properties (void)
|
|||
GST_TYPE_VIDEO_ORIENTATION_METHOD,
|
||||
DEFAULT_VIDEO_DIRECTION, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
#ifndef GST_REMOVE_DEPRECATED
|
||||
/**
|
||||
* GstVaapiFilter:skin-tone-enhancement:
|
||||
*
|
||||
|
@ -474,6 +478,18 @@ init_properties (void)
|
|||
"Skin tone enhancement",
|
||||
"Apply the skin tone enhancement algorithm",
|
||||
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* GstVaapiFilter:skin-tone-enhancement-level:
|
||||
*
|
||||
* Apply the skin tone enhancement algorithm with specified value.
|
||||
*/
|
||||
g_properties[PROP_SKINTONE_LEVEL] =
|
||||
g_param_spec_uint ("skin-tone-enhancement-level",
|
||||
"Skin tone enhancement level",
|
||||
"Apply the skin tone enhancement algorithm with specified level", 0, 9, 3,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -523,7 +539,10 @@ op_data_new (GstVaapiFilterOp op, GParamSpec * pspec)
|
|||
op_data->va_cap_size = sizeof (VAProcFilterCap);
|
||||
op_data->va_buffer_size = sizeof (VAProcFilterParameterBuffer);
|
||||
break;
|
||||
#ifndef GST_REMOVE_DEPRECATED
|
||||
case GST_VAAPI_FILTER_OP_SKINTONE:
|
||||
#endif
|
||||
case GST_VAAPI_FILTER_OP_SKINTONE_LEVEL:
|
||||
op_data->va_type = VAProcFilterSkinToneEnhancement;
|
||||
op_data->va_buffer_size = sizeof (VAProcFilterParameterBuffer);
|
||||
break;
|
||||
|
@ -1023,29 +1042,56 @@ op_set_deinterlace (GstVaapiFilter * filter, GstVaapiFilterOpData * op_data,
|
|||
return success;
|
||||
}
|
||||
|
||||
/* Update skin tone enhancement */
|
||||
/* Update skin tone enhancement level */
|
||||
static gboolean
|
||||
op_set_skintone_unlocked (GstVaapiFilter * filter,
|
||||
GstVaapiFilterOpData * op_data, gboolean value)
|
||||
op_set_skintone_level_unlocked (GstVaapiFilter * filter,
|
||||
GstVaapiFilterOpData * op_data, guint value)
|
||||
{
|
||||
VAProcFilterParameterBuffer *buf;
|
||||
|
||||
if (!op_data || !op_ensure_buffer (filter, op_data))
|
||||
return FALSE;
|
||||
|
||||
op_data->is_enabled = value;
|
||||
if (!op_data->is_enabled)
|
||||
return TRUE;
|
||||
op_data->is_enabled = 1;
|
||||
|
||||
buf = vaapi_map_buffer (filter->va_display, op_data->va_buffer);
|
||||
if (!buf)
|
||||
return FALSE;
|
||||
buf->type = op_data->va_type;
|
||||
buf->value = 0;
|
||||
buf->value = value;
|
||||
vaapi_unmap_buffer (filter->va_display, op_data->va_buffer, NULL);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
op_set_skintone_level (GstVaapiFilter * filter,
|
||||
GstVaapiFilterOpData * op_data, guint value)
|
||||
{
|
||||
gboolean success = FALSE;
|
||||
|
||||
GST_VAAPI_DISPLAY_LOCK (filter->display);
|
||||
success = op_set_skintone_level_unlocked (filter, op_data, value);
|
||||
GST_VAAPI_DISPLAY_UNLOCK (filter->display);
|
||||
return success;
|
||||
}
|
||||
|
||||
#ifndef GST_REMOVE_DEPRECATED
|
||||
/* Update skin tone enhancement */
|
||||
static gboolean
|
||||
op_set_skintone_unlocked (GstVaapiFilter * filter,
|
||||
GstVaapiFilterOpData * op_data, gboolean value)
|
||||
{
|
||||
if (!op_data)
|
||||
return FALSE;
|
||||
|
||||
if (!value) {
|
||||
op_data->is_enabled = 0;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return op_set_skintone_level_unlocked (filter, op_data, 3);
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
op_set_skintone (GstVaapiFilter * filter, GstVaapiFilterOpData * op_data,
|
||||
gboolean enhance)
|
||||
|
@ -1057,6 +1103,7 @@ op_set_skintone (GstVaapiFilter * filter, GstVaapiFilterOpData * op_data,
|
|||
GST_VAAPI_DISPLAY_UNLOCK (filter->display);
|
||||
return success;
|
||||
}
|
||||
#endif
|
||||
|
||||
static gboolean
|
||||
deint_refs_set (GArray * refs, GstVaapiSurface ** surfaces, guint num_surfaces)
|
||||
|
@ -1441,10 +1488,16 @@ gst_vaapi_filter_set_operation (GstVaapiFilter * filter, GstVaapiFilterOp op,
|
|||
case GST_VAAPI_FILTER_OP_SCALING:
|
||||
return gst_vaapi_filter_set_scaling (filter, value ?
|
||||
g_value_get_enum (value) : DEFAULT_SCALING);
|
||||
#ifndef GST_REMOVE_DEPRECATED
|
||||
case GST_VAAPI_FILTER_OP_SKINTONE:
|
||||
return op_set_skintone (filter, op_data,
|
||||
(value ? g_value_get_boolean (value) :
|
||||
G_PARAM_SPEC_BOOLEAN (op_data->pspec)->default_value));
|
||||
#endif
|
||||
case GST_VAAPI_FILTER_OP_SKINTONE_LEVEL:
|
||||
return op_set_skintone_level (filter, op_data,
|
||||
(value ? g_value_get_uint (value) :
|
||||
G_PARAM_SPEC_UINT (op_data->pspec)->default_value));
|
||||
case GST_VAAPI_FILTER_OP_VIDEO_DIRECTION:
|
||||
return gst_vaapi_filter_set_video_direction (filter, value ?
|
||||
g_value_get_enum (value) : DEFAULT_VIDEO_DIRECTION);
|
||||
|
@ -1985,6 +2038,7 @@ gst_vaapi_filter_set_scaling (GstVaapiFilter * filter,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
#ifndef GST_REMOVE_DEPRECATED
|
||||
/**
|
||||
* gst_vaapi_filter_set_skintone:
|
||||
* @filter: a #GstVaapiFilter
|
||||
|
@ -2003,6 +2057,26 @@ gst_vaapi_filter_set_skintone (GstVaapiFilter * filter, gboolean enhance)
|
|||
return op_set_skintone (filter,
|
||||
find_operation (filter, GST_VAAPI_FILTER_OP_SKINTONE), enhance);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* gst_vaapi_filter_set_skintone_level:
|
||||
* @filter: a #GstVaapiFilter
|
||||
* @value: the value if enable the skin tone enhancement algorithm
|
||||
*
|
||||
* Applies the skin tone enhancement algorithm with specifled value.
|
||||
*
|
||||
* Return value: %TRUE if the operation is supported, %FALSE
|
||||
* otherwise.
|
||||
**/
|
||||
gboolean
|
||||
gst_vaapi_filter_set_skintone_level (GstVaapiFilter * filter, guint value)
|
||||
{
|
||||
g_return_val_if_fail (filter != NULL, FALSE);
|
||||
|
||||
return op_set_skintone_level (filter,
|
||||
find_operation (filter, GST_VAAPI_FILTER_OP_SKINTONE_LEVEL), value);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_filter_set_video_direction:
|
||||
|
@ -2124,6 +2198,7 @@ gst_vaapi_filter_get_scaling_default (GstVaapiFilter * filter)
|
|||
return DEFAULT_SCALING;
|
||||
}
|
||||
|
||||
#ifndef GST_REMOVE_DEPRECATED
|
||||
gboolean
|
||||
gst_vaapi_filter_get_skintone_default (GstVaapiFilter * filter)
|
||||
{
|
||||
|
@ -2131,6 +2206,15 @@ gst_vaapi_filter_get_skintone_default (GstVaapiFilter * filter)
|
|||
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
guint
|
||||
gst_vaapi_filter_get_skintone_level_default (GstVaapiFilter * filter)
|
||||
{
|
||||
g_return_val_if_fail (filter != NULL, FALSE);
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
GstVideoOrientationMethod
|
||||
gst_vaapi_filter_get_video_direction_default (GstVaapiFilter * filter)
|
||||
|
|
|
@ -51,6 +51,7 @@ typedef struct _GstVaapiFilterOpInfo GstVaapiFilterOpInfo;
|
|||
* @GST_VAAPI_FILTER_OP_VIDEO_DIRECTION: Change video direction
|
||||
* (#GstVideoOrientationMethod).
|
||||
* @GST_VAAPI_FILTER_OP_SKINTONE: Skin tone enhancement (bool).
|
||||
* @GST_VAAPI_FILTER_OP_SKINTONE_LEVEL: Skin tone enhancement (uint).
|
||||
*
|
||||
* The set of operations that could be applied to the filter.
|
||||
*/
|
||||
|
@ -66,7 +67,10 @@ typedef enum {
|
|||
GST_VAAPI_FILTER_OP_DEINTERLACING,
|
||||
GST_VAAPI_FILTER_OP_SCALING,
|
||||
GST_VAAPI_FILTER_OP_VIDEO_DIRECTION,
|
||||
#ifndef GST_REMOVE_DEPRECATED
|
||||
GST_VAAPI_FILTER_OP_SKINTONE,
|
||||
#endif
|
||||
GST_VAAPI_FILTER_OP_SKINTONE_LEVEL,
|
||||
} GstVaapiFilterOp;
|
||||
|
||||
/**
|
||||
|
@ -259,9 +263,14 @@ gst_vaapi_filter_set_video_direction (GstVaapiFilter * filter,
|
|||
GstVideoOrientationMethod
|
||||
gst_vaapi_filter_get_video_direction (GstVaapiFilter * filter);
|
||||
|
||||
#ifndef GST_REMOVE_DEPRECATED
|
||||
gboolean
|
||||
gst_vaapi_filter_set_skintone (GstVaapiFilter * filter,
|
||||
gboolean enhance);
|
||||
#endif
|
||||
|
||||
gboolean
|
||||
gst_vaapi_filter_set_skintone_level (GstVaapiFilter * filter, guint value);
|
||||
|
||||
gfloat
|
||||
gst_vaapi_filter_get_denoising_level_default (GstVaapiFilter * filter);
|
||||
|
@ -287,8 +296,13 @@ gst_vaapi_filter_get_scaling_default (GstVaapiFilter * filter);
|
|||
GstVideoOrientationMethod
|
||||
gst_vaapi_filter_get_video_direction_default (GstVaapiFilter * filter);
|
||||
|
||||
#ifndef GST_REMOVE_DEPRECATED
|
||||
gboolean
|
||||
gst_vaapi_filter_get_skintone_default (GstVaapiFilter * filter);
|
||||
#endif
|
||||
|
||||
guint
|
||||
gst_vaapi_filter_get_skintone_level_default (GstVaapiFilter * filter);
|
||||
|
||||
#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstVaapiFilter, gst_object_unref)
|
||||
|
|
|
@ -127,7 +127,10 @@ enum
|
|||
PROP_CROP_RIGHT,
|
||||
PROP_CROP_TOP,
|
||||
PROP_CROP_BOTTOM,
|
||||
#ifndef GST_REMOVE_DEPRECATED
|
||||
PROP_SKIN_TONE_ENHANCEMENT,
|
||||
#endif
|
||||
PROP_SKIN_TONE_ENHANCEMENT_LEVEL,
|
||||
};
|
||||
|
||||
#define GST_VAAPI_TYPE_DEINTERLACE_MODE \
|
||||
|
@ -519,7 +522,8 @@ check_filter_update (GstVaapiPostproc * postproc)
|
|||
if (!postproc->has_vpp)
|
||||
return FALSE;
|
||||
|
||||
for (i = GST_VAAPI_FILTER_OP_DENOISE; i <= GST_VAAPI_FILTER_OP_SKINTONE; i++) {
|
||||
for (i = GST_VAAPI_FILTER_OP_DENOISE;
|
||||
i <= GST_VAAPI_FILTER_OP_SKINTONE_LEVEL; i++) {
|
||||
op_flag = (filter_flag >> i) & 1;
|
||||
if (op_flag)
|
||||
return TRUE;
|
||||
|
@ -628,14 +632,33 @@ update_filter (GstVaapiPostproc * postproc)
|
|||
| postproc->crop_bottom) == 0)
|
||||
postproc->flags &= ~(GST_VAAPI_POSTPROC_FLAG_CROP);
|
||||
|
||||
if (postproc->flags & GST_VAAPI_POSTPROC_FLAG_SKINTONE) {
|
||||
if (!gst_vaapi_filter_set_skintone (postproc->filter,
|
||||
postproc->skintone_enhance))
|
||||
if (postproc->flags & GST_VAAPI_POSTPROC_FLAG_SKINTONE_LEVEL) {
|
||||
if (!gst_vaapi_filter_set_skintone_level (postproc->filter,
|
||||
postproc->skintone_value))
|
||||
return FALSE;
|
||||
|
||||
if (gst_vaapi_filter_get_skintone_default (postproc->filter) ==
|
||||
postproc->skintone_enhance)
|
||||
postproc->flags &= ~(GST_VAAPI_POSTPROC_FLAG_SKINTONE);
|
||||
if (gst_vaapi_filter_get_skintone_level_default (postproc->filter) ==
|
||||
postproc->skintone_value)
|
||||
postproc->flags &= ~(GST_VAAPI_POSTPROC_FLAG_SKINTONE_LEVEL);
|
||||
|
||||
#ifndef GST_REMOVE_DEPRECATED
|
||||
/*
|
||||
* When use skin tone level property, disable old skin tone property always
|
||||
*/
|
||||
postproc->flags &= ~(GST_VAAPI_POSTPROC_FLAG_SKINTONE);
|
||||
#endif
|
||||
} else {
|
||||
#ifndef GST_REMOVE_DEPRECATED
|
||||
if (postproc->flags & GST_VAAPI_POSTPROC_FLAG_SKINTONE) {
|
||||
if (!gst_vaapi_filter_set_skintone (postproc->filter,
|
||||
postproc->skintone_enhance))
|
||||
return FALSE;
|
||||
|
||||
if (gst_vaapi_filter_get_skintone_default (postproc->filter) ==
|
||||
postproc->skintone_enhance)
|
||||
postproc->flags &= ~(GST_VAAPI_POSTPROC_FLAG_SKINTONE);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
@ -1969,10 +1992,16 @@ gst_vaapipostproc_set_property (GObject * object,
|
|||
postproc->video_direction = g_value_get_enum (value);
|
||||
postproc->flags |= GST_VAAPI_POSTPROC_FLAG_VIDEO_DIRECTION;
|
||||
break;
|
||||
#ifndef GST_REMOVE_DEPRECATED
|
||||
case PROP_SKIN_TONE_ENHANCEMENT:
|
||||
postproc->skintone_enhance = g_value_get_boolean (value);
|
||||
postproc->flags |= GST_VAAPI_POSTPROC_FLAG_SKINTONE;
|
||||
break;
|
||||
#endif
|
||||
case PROP_SKIN_TONE_ENHANCEMENT_LEVEL:
|
||||
postproc->skintone_value = g_value_get_uint (value);
|
||||
postproc->flags |= GST_VAAPI_POSTPROC_FLAG_SKINTONE_LEVEL;
|
||||
break;
|
||||
case PROP_CROP_LEFT:
|
||||
postproc->crop_left = g_value_get_uint (value);
|
||||
postproc->flags |= GST_VAAPI_POSTPROC_FLAG_CROP;
|
||||
|
@ -2049,9 +2078,14 @@ gst_vaapipostproc_get_property (GObject * object,
|
|||
case PROP_VIDEO_DIRECTION:
|
||||
g_value_set_enum (value, postproc->video_direction);
|
||||
break;
|
||||
#ifndef GST_REMOVE_DEPRECATED
|
||||
case PROP_SKIN_TONE_ENHANCEMENT:
|
||||
g_value_set_boolean (value, postproc->skintone_enhance);
|
||||
break;
|
||||
#endif
|
||||
case PROP_SKIN_TONE_ENHANCEMENT_LEVEL:
|
||||
g_value_set_uint (value, postproc->skintone_value);
|
||||
break;
|
||||
case PROP_CROP_LEFT:
|
||||
g_value_set_uint (value, postproc->crop_left);
|
||||
break;
|
||||
|
@ -2346,6 +2380,7 @@ gst_vaapipostproc_class_init (GstVaapiPostprocClass * klass)
|
|||
g_object_class_install_property (object_class,
|
||||
PROP_VIDEO_DIRECTION, filter_op->pspec);
|
||||
|
||||
#ifndef GST_REMOVE_DEPRECATED
|
||||
/**
|
||||
* GstVaapiPostproc:skin-tone-enhancement:
|
||||
*
|
||||
|
@ -2355,6 +2390,17 @@ gst_vaapipostproc_class_init (GstVaapiPostprocClass * klass)
|
|||
if (filter_op)
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_SKIN_TONE_ENHANCEMENT, filter_op->pspec);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* GstVaapiPostproc:skin-tone-enhancement-setting:
|
||||
*
|
||||
* Apply the skin tone enhancement algorithm with specified value.
|
||||
*/
|
||||
filter_op = find_filter_op (filter_ops, GST_VAAPI_FILTER_OP_SKINTONE_LEVEL);
|
||||
if (filter_op)
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_SKIN_TONE_ENHANCEMENT_LEVEL, filter_op->pspec);
|
||||
|
||||
g_ptr_array_unref (filter_ops);
|
||||
}
|
||||
|
@ -2394,6 +2440,19 @@ cb_set_default_value (GstVaapiPostproc * postproc, GPtrArray * filter_ops,
|
|||
*var = pspec->default_value;
|
||||
}
|
||||
|
||||
static void
|
||||
skintone_set_default_value (GstVaapiPostproc * postproc, GPtrArray * filter_ops)
|
||||
{
|
||||
GstVaapiFilterOpInfo *filter_op;
|
||||
GParamSpecUInt *pspec;
|
||||
|
||||
filter_op = find_filter_op (filter_ops, GST_VAAPI_FILTER_OP_SKINTONE_LEVEL);
|
||||
if (!filter_op)
|
||||
return;
|
||||
pspec = G_PARAM_SPEC_UINT (filter_op->pspec);
|
||||
postproc->skintone_value = pspec->default_value;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_vaapipostproc_init (GstVaapiPostproc * postproc)
|
||||
{
|
||||
|
@ -2420,6 +2479,8 @@ gst_vaapipostproc_init (GstVaapiPostproc * postproc)
|
|||
if (filter_ops) {
|
||||
for (i = GST_VAAPI_FILTER_OP_HUE; i <= GST_VAAPI_FILTER_OP_CONTRAST; i++)
|
||||
cb_set_default_value (postproc, filter_ops, i);
|
||||
|
||||
skintone_set_default_value (postproc, filter_ops);
|
||||
g_ptr_array_unref (filter_ops);
|
||||
}
|
||||
|
||||
|
|
|
@ -88,6 +88,7 @@ typedef enum
|
|||
* @GST_VAAPI_POSTPROC_FLAG_SCALE: Video scaling mode.
|
||||
* @GST_VAAPI_POSTPROC_FLAG_VIDEO_DIRECTION: Video rotation and flip/mirroring.
|
||||
* @GST_VAAPI_POSTPROC_FLAG_SKINTONE: Skin tone enhancement.
|
||||
* @GST_VAAPI_POSTPROC_FLAG_SKINTONE_LEVEL: Skin tone enhancement with value.
|
||||
*
|
||||
* The set of operations that are to be performed for each frame.
|
||||
*/
|
||||
|
@ -105,7 +106,11 @@ typedef enum
|
|||
GST_VAAPI_POSTPROC_FLAG_VIDEO_DIRECTION =
|
||||
1 << GST_VAAPI_FILTER_OP_VIDEO_DIRECTION,
|
||||
GST_VAAPI_POSTPROC_FLAG_CROP = 1 << GST_VAAPI_FILTER_OP_CROP,
|
||||
#ifndef GST_REMOVE_DEPRECATED
|
||||
GST_VAAPI_POSTPROC_FLAG_SKINTONE = 1 << GST_VAAPI_FILTER_OP_SKINTONE,
|
||||
#endif
|
||||
GST_VAAPI_POSTPROC_FLAG_SKINTONE_LEVEL =
|
||||
1 << GST_VAAPI_FILTER_OP_SKINTONE_LEVEL,
|
||||
|
||||
/* Additional custom flags */
|
||||
GST_VAAPI_POSTPROC_FLAG_CUSTOM = 1 << 20,
|
||||
|
@ -182,6 +187,7 @@ struct _GstVaapiPostproc
|
|||
gfloat contrast;
|
||||
|
||||
gboolean skintone_enhance;
|
||||
guint skintone_value;
|
||||
gboolean forward_crop;
|
||||
|
||||
guint get_va_surfaces:1;
|
||||
|
|
Loading…
Reference in a new issue