mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-28 03:00:35 +00:00
va: add interpolation method for scaling
For description of interpolation methods, see: <https://intel.github.io/libva/structVAProcPipelineParameterBuffer.html#abb95e119ed7f841f71b2afbec2104784> Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7301>
This commit is contained in:
parent
d301324652
commit
671281d860
4 changed files with 102 additions and 2 deletions
|
@ -262,6 +262,7 @@ struct _GstVaCompositor
|
|||
GstBufferPool *other_pool; /* downstream pool */
|
||||
|
||||
guint32 scale_method;
|
||||
guint32 interpolation_method;
|
||||
};
|
||||
|
||||
struct CData
|
||||
|
@ -274,6 +275,7 @@ enum
|
|||
{
|
||||
PROP_DEVICE_PATH = 1,
|
||||
PROP_SCALE_METHOD,
|
||||
PROP_INTERPOLATION_METHOD,
|
||||
N_PROPERTIES
|
||||
};
|
||||
|
||||
|
@ -294,6 +296,13 @@ gst_va_compositor_set_property (GObject * object, guint prop_id,
|
|||
GST_OBJECT_UNLOCK (object);
|
||||
break;
|
||||
}
|
||||
case PROP_INTERPOLATION_METHOD:
|
||||
{
|
||||
GST_OBJECT_LOCK (object);
|
||||
self->interpolation_method = g_value_get_enum (value);
|
||||
GST_OBJECT_UNLOCK (object);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
|
@ -325,6 +334,13 @@ gst_va_compositor_get_property (GObject * object, guint prop_id,
|
|||
GST_OBJECT_UNLOCK (object);
|
||||
break;
|
||||
}
|
||||
case PROP_INTERPOLATION_METHOD:
|
||||
{
|
||||
GST_OBJECT_LOCK (object);
|
||||
g_value_set_enum (value, self->interpolation_method);
|
||||
GST_OBJECT_UNLOCK (object);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
|
@ -1028,6 +1044,10 @@ gst_va_compositor_aggregate_frames (GstVideoAggregator * vagg,
|
|||
if (!gst_va_filter_set_scale_method (self->filter, self->scale_method))
|
||||
GST_WARNING_OBJECT (self, "couldn't set filter scale method");
|
||||
|
||||
if (!gst_va_filter_set_interpolation_method (self->filter,
|
||||
self->interpolation_method))
|
||||
GST_WARNING_OBJECT (self, "couldn't set filter interpolation method");
|
||||
|
||||
if (!gst_va_filter_compose (self->filter, &tx)) {
|
||||
GST_ERROR_OBJECT (self, "couldn't apply filter");
|
||||
ret = GST_FLOW_ERROR;
|
||||
|
@ -1643,6 +1663,17 @@ gst_va_compositor_class_init (gpointer g_class, gpointer class_data)
|
|||
|
||||
gst_type_mark_as_plugin_api (GST_TYPE_VA_SCALE_METHOD, 0);
|
||||
|
||||
/**
|
||||
* GstVaCompositor:interpolation-method:
|
||||
*
|
||||
* Sets the interpolation method algorithm to use when resizing.
|
||||
*/
|
||||
properties[PROP_INTERPOLATION_METHOD] =
|
||||
g_param_spec_enum ("interpolation-method", "Interpolation Method",
|
||||
"Interpolation method to use for scaling",
|
||||
GST_TYPE_VA_INTERPOLATION_METHOD, VA_FILTER_INTERPOLATION_DEFAULT,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (object_class, N_PROPERTIES, properties);
|
||||
|
||||
g_free (long_name);
|
||||
|
|
|
@ -61,6 +61,7 @@ struct _GstVaFilter
|
|||
GstVideoOrientationMethod orientation;
|
||||
|
||||
guint32 scale_method;
|
||||
guint32 interpolation_method;
|
||||
|
||||
gboolean crop_enabled;
|
||||
|
||||
|
@ -154,6 +155,8 @@ gst_va_filter_class_init (GstVaFilterClass * klass)
|
|||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (gobject_class, N_PROPERTIES, g_properties);
|
||||
|
||||
gst_type_mark_as_plugin_api (GST_TYPE_VA_INTERPOLATION_METHOD, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -930,6 +933,18 @@ gst_va_filter_set_scale_method (GstVaFilter * self, guint32 method)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_va_filter_set_interpolation_method (GstVaFilter * self, guint32 method)
|
||||
{
|
||||
g_return_val_if_fail (GST_IS_VA_FILTER (self), FALSE);
|
||||
|
||||
GST_OBJECT_LOCK (self);
|
||||
self->interpolation_method = method;
|
||||
GST_OBJECT_UNLOCK (self);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_from_video_orientation_method (GstVideoOrientationMethod orientation,
|
||||
guint * mirror, guint * rotation)
|
||||
|
@ -1612,7 +1627,7 @@ _create_pipeline_buffer (GstVaFilter * self, GstVaSample * src,
|
|||
.output_surface_flag = dst->flags,
|
||||
.input_color_properties = self->input_color_properties,
|
||||
.output_color_properties = self->output_color_properties,
|
||||
.filter_flags = self->scale_method,
|
||||
.filter_flags = self->scale_method | self->interpolation_method,
|
||||
/* output to SDR */
|
||||
.output_hdr_metadata = NULL,
|
||||
};
|
||||
|
@ -1795,7 +1810,7 @@ gst_va_filter_compose (GstVaFilter * self, GstVaComposeTransaction * tx)
|
|||
.surface_region = &sample->input_region,
|
||||
.output_region = &sample->output_region,
|
||||
.output_background_color = 0xff000000,
|
||||
.filter_flags = self->scale_method,
|
||||
.filter_flags = self->scale_method | self->interpolation_method,
|
||||
};
|
||||
/* *INDENT-ON* */
|
||||
GST_OBJECT_UNLOCK (self);
|
||||
|
@ -1947,3 +1962,26 @@ gst_va_scale_method_get_type (void)
|
|||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
GType
|
||||
gst_va_interpolation_method_get_type (void)
|
||||
{
|
||||
static gsize type = 0;
|
||||
static const GEnumValue values[] = {
|
||||
{VA_FILTER_INTERPOLATION_DEFAULT, "Default interpolation", "default"},
|
||||
{VA_FILTER_INTERPOLATION_NEAREST_NEIGHBOR, "Nearest neighbor interpolation",
|
||||
"nearest-neighbor"},
|
||||
{VA_FILTER_INTERPOLATION_BILINEAR, "Bilinear interpolation", "bilinear"},
|
||||
{VA_FILTER_INTERPOLATION_ADVANCED, "Advanced interpolation method is "
|
||||
"defined by each implementation and usually gives best quality.",
|
||||
"advanced"},
|
||||
{0, NULL, NULL},
|
||||
};
|
||||
|
||||
if (g_once_init_enter (&type)) {
|
||||
const GType _type =
|
||||
g_enum_register_static ("GstVaInterpolationMethod", values);
|
||||
g_once_init_leave (&type, _type);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
|
|
@ -58,6 +58,9 @@ enum {
|
|||
#define GST_TYPE_VA_SCALE_METHOD gst_va_scale_method_get_type()
|
||||
GType gst_va_scale_method_get_type (void) G_GNUC_CONST;
|
||||
|
||||
#define GST_TYPE_VA_INTERPOLATION_METHOD gst_va_interpolation_method_get_type()
|
||||
GType gst_va_interpolation_method_get_type (void) G_GNUC_CONST;
|
||||
|
||||
typedef struct _GstVaSample GstVaSample;
|
||||
struct _GstVaSample
|
||||
{
|
||||
|
@ -117,6 +120,9 @@ gboolean gst_va_filter_install_deinterlace_properties
|
|||
GObjectClass * klass);
|
||||
gboolean gst_va_filter_set_scale_method (GstVaFilter * self,
|
||||
guint32 method);
|
||||
gboolean gst_va_filter_set_interpolation_method
|
||||
(GstVaFilter * self,
|
||||
guint32 method);
|
||||
gboolean gst_va_filter_set_orientation (GstVaFilter * self,
|
||||
GstVideoOrientationMethod orientation);
|
||||
GstVideoOrientationMethod gst_va_filter_get_orientation (GstVaFilter * self);
|
||||
|
|
|
@ -120,6 +120,7 @@ struct _GstVaVpp
|
|||
gint borders_h;
|
||||
gint borders_w;
|
||||
guint32 scale_method;
|
||||
guint32 interpolation_method;
|
||||
|
||||
gboolean hdr_mapping;
|
||||
gboolean has_hdr_meta;
|
||||
|
@ -143,6 +144,7 @@ enum
|
|||
PROP_DISABLE_PASSTHROUGH = GST_VA_FILTER_PROP_LAST + 1,
|
||||
PROP_ADD_BORDERS,
|
||||
PROP_SCALE_METHOD,
|
||||
PROP_INTERPOLATION_METHOD,
|
||||
N_PROPERTIES
|
||||
};
|
||||
|
||||
|
@ -254,6 +256,9 @@ _update_properties_unlocked (GstVaVpp * self)
|
|||
|
||||
if (!gst_va_filter_set_scale_method (btrans->filter, self->scale_method))
|
||||
GST_WARNING_OBJECT (self, "could not set the filter scale method.");
|
||||
if (!gst_va_filter_set_interpolation_method (btrans->filter,
|
||||
self->interpolation_method))
|
||||
GST_WARNING_OBJECT (self, "could not set the filter interpolation method.");
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -332,6 +337,9 @@ gst_va_vpp_set_property (GObject * object, guint prop_id,
|
|||
case PROP_SCALE_METHOD:
|
||||
self->scale_method = g_value_get_enum (value);
|
||||
break;
|
||||
case PROP_INTERPOLATION_METHOD:
|
||||
self->interpolation_method = g_value_get_enum (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
@ -399,6 +407,9 @@ gst_va_vpp_get_property (GObject * object, guint prop_id, GValue * value,
|
|||
case PROP_SCALE_METHOD:
|
||||
g_value_set_enum (value, self->scale_method);
|
||||
break;
|
||||
case PROP_INTERPOLATION_METHOD:
|
||||
g_value_set_enum (value, self->interpolation_method);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
@ -2169,6 +2180,20 @@ _install_static_properties (GObjectClass * klass)
|
|||
| GST_PARAM_MUTABLE_PLAYING);
|
||||
g_object_class_install_property (klass, PROP_SCALE_METHOD,
|
||||
PROPERTIES (PROP_SCALE_METHOD));
|
||||
|
||||
/**
|
||||
* GstVaPostProc:interpolation-method
|
||||
*
|
||||
* Sets the interpolation method algorithm to use when resizing.
|
||||
*
|
||||
*/
|
||||
PROPERTIES (PROP_INTERPOLATION_METHOD) =
|
||||
g_param_spec_enum ("interpolation-method", "Interpolation Method",
|
||||
"Interpolation method to use for scaling",
|
||||
GST_TYPE_VA_INTERPOLATION_METHOD, VA_FILTER_INTERPOLATION_DEFAULT,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_MUTABLE_PLAYING);
|
||||
g_object_class_install_property (klass, PROP_INTERPOLATION_METHOD,
|
||||
PROPERTIES (PROP_INTERPOLATION_METHOD));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in a new issue