mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 18:05:37 +00:00
filter: add initial support for high quality scaling.
Add support for video scaling options in VPP pipelines. Only the DEFAULT mode is bound to exist. Others might be folded into that mode.
This commit is contained in:
parent
c537648c5b
commit
3656659d1c
4 changed files with 141 additions and 1 deletions
|
@ -65,6 +65,7 @@ struct _GstVaapiFilter
|
|||
VAContextID va_context;
|
||||
GPtrArray *operations;
|
||||
GstVideoFormat format;
|
||||
GstVaapiScaleMethod scale_method;
|
||||
GArray *formats;
|
||||
GArray *forward_references;
|
||||
GArray *backward_references;
|
||||
|
@ -78,6 +79,29 @@ struct _GstVaapiFilter
|
|||
/* --- VPP Types --- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
GType
|
||||
gst_vaapi_scale_method_get_type (void)
|
||||
{
|
||||
static gsize g_type = 0;
|
||||
|
||||
static const GEnumValue enum_values[] = {
|
||||
{GST_VAAPI_SCALE_METHOD_DEFAULT,
|
||||
"Default scaling mode", "default"},
|
||||
{GST_VAAPI_SCALE_METHOD_FAST,
|
||||
"Fast scaling mode", "fast"},
|
||||
{GST_VAAPI_SCALE_METHOD_HQ,
|
||||
"High quality scaling mode", "hq"},
|
||||
{0, NULL, NULL},
|
||||
};
|
||||
|
||||
if (g_once_init_enter (&g_type)) {
|
||||
const GType type =
|
||||
g_enum_register_static ("GstVaapiScaleMethod", enum_values);
|
||||
g_once_init_leave (&g_type, type);
|
||||
}
|
||||
return g_type;
|
||||
}
|
||||
|
||||
GType
|
||||
gst_vaapi_deinterlace_method_get_type (void)
|
||||
{
|
||||
|
@ -238,6 +262,7 @@ vpp_get_filter_caps (GstVaapiFilter * filter, VAProcFilterType type,
|
|||
|
||||
#if USE_VA_VPP
|
||||
#define DEFAULT_FORMAT GST_VIDEO_FORMAT_UNKNOWN
|
||||
#define DEFAULT_SCALING GST_VAAPI_SCALE_METHOD_DEFAULT
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -252,6 +277,7 @@ enum
|
|||
PROP_BRIGHTNESS = GST_VAAPI_FILTER_OP_BRIGHTNESS,
|
||||
PROP_CONTRAST = GST_VAAPI_FILTER_OP_CONTRAST,
|
||||
PROP_DEINTERLACING = GST_VAAPI_FILTER_OP_DEINTERLACING,
|
||||
PROP_SCALING = GST_VAAPI_FILTER_OP_SCALING,
|
||||
|
||||
N_PROPERTIES
|
||||
};
|
||||
|
@ -361,6 +387,18 @@ init_properties (void)
|
|||
GST_VAAPI_TYPE_DEINTERLACE_METHOD,
|
||||
GST_VAAPI_DEINTERLACE_METHOD_NONE,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GstVaapiFilter:scale-method:
|
||||
*
|
||||
* The scaling method to use, expressed as an enum value. See
|
||||
* #GstVaapiScaleMethod.
|
||||
*/
|
||||
g_properties[PROP_SCALING] = g_param_spec_enum ("scale-method",
|
||||
"Scaling Method",
|
||||
"Scaling method to use",
|
||||
GST_VAAPI_TYPE_SCALE_METHOD,
|
||||
DEFAULT_SCALING, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -396,6 +434,7 @@ op_data_new (GstVaapiFilterOp op, GParamSpec * pspec)
|
|||
switch (op) {
|
||||
case GST_VAAPI_FILTER_OP_FORMAT:
|
||||
case GST_VAAPI_FILTER_OP_CROP:
|
||||
case GST_VAAPI_FILTER_OP_SCALING:
|
||||
op_data->va_type = VAProcFilterNone;
|
||||
break;
|
||||
case GST_VAAPI_FILTER_OP_DENOISE:
|
||||
|
@ -1258,6 +1297,9 @@ gst_vaapi_filter_set_operation (GstVaapiFilter * filter, GstVaapiFilterOp op,
|
|||
(value ? g_value_get_enum (value) :
|
||||
G_PARAM_SPEC_ENUM (op_data->pspec)->default_value), 0);
|
||||
break;
|
||||
case GST_VAAPI_FILTER_OP_SCALING:
|
||||
return gst_vaapi_filter_set_scaling (filter, value ?
|
||||
g_value_get_enum (value) : DEFAULT_SCALING);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -1369,7 +1411,8 @@ gst_vaapi_filter_process_unlocked (GstVaapiFilter * filter,
|
|||
pipeline_param->output_region = &dst_rect;
|
||||
pipeline_param->output_color_standard = VAProcColorStandardNone;
|
||||
pipeline_param->output_background_color = 0xff000000;
|
||||
pipeline_param->filter_flags = from_GstVaapiSurfaceRenderFlags (flags);
|
||||
pipeline_param->filter_flags = from_GstVaapiSurfaceRenderFlags (flags) |
|
||||
from_GstVaapiScaleMethod (filter->scale_method);
|
||||
pipeline_param->filters = filters;
|
||||
pipeline_param->num_filters = num_filters;
|
||||
|
||||
|
@ -1727,3 +1770,22 @@ gst_vaapi_filter_set_deinterlacing_references (GstVaapiFilter * filter,
|
|||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_filter_set_scaling:
|
||||
* @filter: a #GstVaapiFilter
|
||||
* @method: the scaling algorithm (see #GstVaapiScaleMethod)
|
||||
*
|
||||
* Applies scaling algorithm to the video processing pipeline.
|
||||
*
|
||||
* Return value: %TRUE if the operation is supported, %FALSE otherwise.
|
||||
*/
|
||||
gboolean
|
||||
gst_vaapi_filter_set_scaling (GstVaapiFilter * filter,
|
||||
GstVaapiScaleMethod method)
|
||||
{
|
||||
g_return_val_if_fail (filter != NULL, FALSE);
|
||||
|
||||
filter->scale_method = method;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ typedef struct _GstVaapiFilterOpInfo GstVaapiFilterOpInfo;
|
|||
* @GST_VAAPI_FILTER_OP_SATURATION: Change saturation (float).
|
||||
* @GST_VAAPI_FILTER_OP_BRIGHTNESS: Change brightness (float).
|
||||
* @GST_VAAPI_FILTER_OP_CONTRAST: Change contrast (float).
|
||||
* @GST_VAAPI_FILTER_OP_SCALING: Change scaling method (#GstVaapiScaleMethod).
|
||||
*
|
||||
* The set of operations that could be applied to the filter.
|
||||
*/
|
||||
|
@ -53,6 +54,7 @@ typedef enum {
|
|||
GST_VAAPI_FILTER_OP_BRIGHTNESS,
|
||||
GST_VAAPI_FILTER_OP_CONTRAST,
|
||||
GST_VAAPI_FILTER_OP_DEINTERLACING,
|
||||
GST_VAAPI_FILTER_OP_SCALING,
|
||||
} GstVaapiFilterOp;
|
||||
|
||||
/**
|
||||
|
@ -88,6 +90,21 @@ typedef enum {
|
|||
GST_VAAPI_FILTER_STATUS_ERROR_UNSUPPORTED_FORMAT,
|
||||
} GstVaapiFilterStatus;
|
||||
|
||||
/**
|
||||
* GstVaapiScaleMethod:
|
||||
* @GST_VAAPI_SCALE_METHOD_DEFAULT: Default scaling mode.
|
||||
* @GST_VAAPI_SCALE_METHOD_FAST: Fast scaling mode, at the expense of quality.
|
||||
* @GST_VAAPI_SCALE_METHOD_HQ: High quality scaling mode, at the
|
||||
* expense of speed.
|
||||
*
|
||||
* Scaling algorithms.
|
||||
*/
|
||||
typedef enum {
|
||||
GST_VAAPI_SCALE_METHOD_DEFAULT,
|
||||
GST_VAAPI_SCALE_METHOD_FAST,
|
||||
GST_VAAPI_SCALE_METHOD_HQ,
|
||||
} GstVaapiScaleMethod;
|
||||
|
||||
/**
|
||||
* GstVaapiDeinterlaceMethod:
|
||||
* @GST_VAAPI_DEINTERLACE_METHOD_NONE: No deinterlacing.
|
||||
|
@ -130,12 +147,18 @@ typedef enum {
|
|||
GST_VAAPI_DEINTERLACE_FLAG_TOPFIELD = 1 << 29,
|
||||
} GstVaapiDeinterlaceFlags;
|
||||
|
||||
#define GST_VAAPI_TYPE_SCALE_METHOD \
|
||||
gst_vaapi_scale_method_get_type()
|
||||
|
||||
#define GST_VAAPI_TYPE_DEINTERLACE_METHOD \
|
||||
gst_vaapi_deinterlace_method_get_type()
|
||||
|
||||
#define GST_VAAPI_TYPE_DEINTERLACE_FLAGS \
|
||||
gst_vaapi_deinterlace_flags_get_type()
|
||||
|
||||
GType
|
||||
gst_vaapiscale_method_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GType
|
||||
gst_vaapi_deinterlace_method_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
@ -213,4 +236,8 @@ gst_vaapi_filter_set_deinterlacing_references (GstVaapiFilter * filter,
|
|||
GstVaapiSurface ** forward_references, guint num_forward_references,
|
||||
GstVaapiSurface ** backward_references, guint num_backward_references);
|
||||
|
||||
gboolean
|
||||
gst_vaapi_filter_set_scaling (GstVaapiFilter * filter,
|
||||
GstVaapiScaleMethod method);
|
||||
|
||||
#endif /* GST_VAAPI_FILTER_H */
|
||||
|
|
|
@ -610,3 +610,46 @@ from_GstVaapiDeinterlaceFlags (guint flags)
|
|||
#endif
|
||||
return va_flags;
|
||||
}
|
||||
|
||||
/* VPP: translate GstVaapiScaleMethod into VA scaling flags */
|
||||
guint
|
||||
from_GstVaapiScaleMethod (guint value)
|
||||
{
|
||||
guint va_flags;
|
||||
|
||||
switch (value) {
|
||||
case GST_VAAPI_SCALE_METHOD_DEFAULT:
|
||||
va_flags = VA_FILTER_SCALING_DEFAULT;
|
||||
break;
|
||||
case GST_VAAPI_SCALE_METHOD_FAST:
|
||||
va_flags = VA_FILTER_SCALING_FAST;
|
||||
break;
|
||||
case GST_VAAPI_SCALE_METHOD_HQ:
|
||||
va_flags = VA_FILTER_SCALING_HQ;
|
||||
break;
|
||||
default:
|
||||
va_flags = 0;
|
||||
break;
|
||||
}
|
||||
return va_flags;
|
||||
}
|
||||
|
||||
/* VPP: translate VA scaling flags into GstVaapiScale Method */
|
||||
guint
|
||||
to_GstVaapiScaleMethod (guint flags)
|
||||
{
|
||||
GstVaapiScaleMethod method;
|
||||
|
||||
switch (flags) {
|
||||
case VA_FILTER_SCALING_FAST:
|
||||
method = GST_VAAPI_SCALE_METHOD_FAST;
|
||||
break;
|
||||
case VA_FILTER_SCALING_HQ:
|
||||
method = GST_VAAPI_SCALE_METHOD_HQ;
|
||||
break;
|
||||
default:
|
||||
method = GST_VAAPI_SCALE_METHOD_DEFAULT;
|
||||
break;
|
||||
}
|
||||
return method;
|
||||
}
|
||||
|
|
|
@ -132,4 +132,12 @@ G_GNUC_INTERNAL
|
|||
guint
|
||||
from_GstVaapiDeinterlaceFlags (guint flags);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
guint
|
||||
from_GstVaapiScaleMethod (guint value);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
guint
|
||||
to_GstVaapiScaleMethod (guint flags);
|
||||
|
||||
#endif /* GST_VAAPI_UTILS_H */
|
||||
|
|
Loading…
Reference in a new issue