diff options
author | Víctor Manuel Jáquez Leal <vjaquez@igalia.com> | 2020-12-21 18:17:24 +0100 |
---|---|---|
committer | Víctor Manuel Jáquez Leal <vjaquez@igalia.com> | 2021-09-10 17:48:22 +0200 |
commit | 101dcb55d9adfde0c327d3f0021c34500a11ab3d (patch) | |
tree | 84bca5cb5429cf4b0dc1cca60a7f38aa9175998b /sys | |
parent | 51dcba7b1e0de470a16a5ce0f14f246ae11c75ce (diff) |
va: filter: Add deinterlacing method parameter.
For exposing that gobject parameter a new helper function is added:
gst_va_filter_install_deinterlace_properties()
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2495>
Diffstat (limited to 'sys')
-rw-r--r-- | sys/va/gstvafilter.c | 123 | ||||
-rw-r--r-- | sys/va/gstvafilter.h | 11 |
2 files changed, 134 insertions, 0 deletions
diff --git a/sys/va/gstvafilter.c b/sys/va/gstvafilter.c index d5c716d7d..a033e125c 100644 --- a/sys/va/gstvafilter.c +++ b/sys/va/gstvafilter.c @@ -699,6 +699,129 @@ gst_va_filter_install_properties (GstVaFilter * self, GObjectClass * klass) return TRUE; } +/** + * GstVaDeinterlaceMethods: + * @GST_VA_DEINTERLACE_BOB: Interpolating missing lines by using the + * adjacent lines. + * @GST_VA_DEINTERLACE_WEAVE: Show both fields per frame. (don't use) + * @GST_VA_DEINTERLACE_ADAPTIVE: Interpolating missing lines by using + * spatial/temporal references. + * @GST_VA_DEINTERLACE_COMPENSATED: Recreating missing lines by using + * motion vector. + * + * Since: 1.20 + */ +/* *INDENT-OFF* */ +static const GEnumValue di_desc[] = { + [GST_VA_DEINTERLACE_BOB] = + { VAProcDeinterlacingBob, + "Bob: Interpolating missing lines by using the adjacent lines.", "bob" }, + [GST_VA_DEINTERLACE_WEAVE] = + { VAProcDeinterlacingWeave, "Weave: Show both fields per frame. (don't use)", + "weave" }, + [GST_VA_DEINTERLACE_ADAPTIVE] = + { VAProcDeinterlacingMotionAdaptive, + "Adaptive: Interpolating missing lines by using spatial/temporal references.", + "adaptive" }, + [GST_VA_DEINTERLACE_COMPENSATED] = + { VAProcDeinterlacingMotionCompensated, + "Compensation: Recreating missing lines by using motion vector.", + "compensated" }, +}; +/* *INDENT-ON* */ + +static GType +gst_va_deinterlace_methods_get_type (guint num_caps, + const VAProcFilterCapDeinterlacing * caps) +{ + guint i, j = 0; + static GType deinterlace_methods_type = 0; + static GEnumValue methods_types[VAProcDeinterlacingCount]; + + if (deinterlace_methods_type > 0) + return deinterlace_methods_type; + + for (i = 0; i < num_caps; i++) { + if (caps[i].type > VAProcDeinterlacingNone + && caps[i].type < VAProcDeinterlacingCount) + methods_types[j++] = di_desc[caps[i].type]; + } + + /* *INDENT-OFF* */ + methods_types[j] = (GEnumValue) { 0, NULL, NULL }; + /* *INDENT-ON* */ + + deinterlace_methods_type = g_enum_register_static ("GstVaDeinterlaceMethods", + (const GEnumValue *) methods_types); + + return deinterlace_methods_type; +} + +gboolean +gst_va_filter_install_deinterlace_properties (GstVaFilter * self, + GObjectClass * klass) +{ + GType type; + guint i; + const GParamFlags common_flags = G_PARAM_READWRITE + | G_PARAM_STATIC_STRINGS | GST_PARAM_MUTABLE_PLAYING; + + g_return_val_if_fail (GST_IS_VA_FILTER (self), FALSE); + + if (!gst_va_filter_is_open (self)) + return FALSE; + + if (!gst_va_filter_ensure_filters (self)) + return FALSE; + + for (i = 0; i < self->available_filters->len; i++) { + const struct VaFilter *filter = + &g_array_index (self->available_filters, struct VaFilter, i); + + if (filter->type == VAProcFilterDeinterlacing) { + guint i, default_method = 0; + const VAProcFilterCapDeinterlacing *caps = filter->caps.deint; + if (!caps) + break; + + /* use the first method in the list as default */ + for (i = 0; i < filter->num_caps; i++) { + if (caps[i].type > VAProcDeinterlacingNone + && caps[i].type < VAProcDeinterlacingCount) { + default_method = caps[i].type; + break; + } + } + + if (default_method == 0) + break; + + type = gst_va_deinterlace_methods_get_type (filter->num_caps, caps); + gst_type_mark_as_plugin_api (type, 0); + + /** + * GstVaDeinterlace:method + * + * Selects the different deinterlacing algorithms that can be used. + * + * It depends on the driver the number of available algorithms, + * and they provide different quality and different processing + * consumption. + * + * Since: 1.20 + */ + g_object_class_install_property (klass, + GST_VA_FILTER_PROP_DEINTERLACE_METHOD, + g_param_spec_enum ("method", "Method", "Deinterlace Method", + type, default_method, common_flags)); + + return TRUE; + } + } + + return FALSE; +} + gboolean gst_va_filter_has_filter (GstVaFilter * self, VAProcFilterType type) { diff --git a/sys/va/gstvafilter.h b/sys/va/gstvafilter.h index fa3b5843b..d5a698992 100644 --- a/sys/va/gstvafilter.h +++ b/sys/va/gstvafilter.h @@ -31,6 +31,13 @@ G_BEGIN_DECLS #define GST_TYPE_VA_FILTER (gst_va_filter_get_type()) G_DECLARE_FINAL_TYPE (GstVaFilter, gst_va_filter, GST, VA_FILTER, GstObject) +typedef enum { + GST_VA_DEINTERLACE_BOB = VAProcDeinterlacingBob, + GST_VA_DEINTERLACE_WEAVE = VAProcDeinterlacingWeave, + GST_VA_DEINTERLACE_ADAPTIVE = VAProcDeinterlacingMotionAdaptive, + GST_VA_DEINTERLACE_COMPENSATED = VAProcDeinterlacingMotionCompensated, +} GstVaDeinterlaceMethods; + enum { GST_VA_FILTER_PROP_DENOISE = 1, GST_VA_FILTER_PROP_SHARPEN, @@ -44,6 +51,7 @@ enum { GST_VA_FILTER_PROP_AUTO_BRIGHTNESS, GST_VA_FILTER_PROP_AUTO_CONTRAST, GST_VA_FILTER_PROP_DISABLE_PASSTHROUGH, + GST_VA_FILTER_PROP_DEINTERLACE_METHOD, GST_VA_FILTER_PROP_LAST }; @@ -66,6 +74,9 @@ gboolean gst_va_filter_has_filter (GstVaFilter * self, VAProcFilterType type); gboolean gst_va_filter_install_properties (GstVaFilter * self, GObjectClass * klass); +gboolean gst_va_filter_install_deinterlace_properties + (GstVaFilter * self, + GObjectClass * klass); gboolean gst_va_filter_set_orientation (GstVaFilter * self, GstVideoOrientationMethod orientation); GstVideoOrientationMethod gst_va_filter_get_orientation (GstVaFilter * self); |