mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-05-05 16:04:50 +00:00
va: add vapostproc element
Video postprocessor for VA-API Funcionalities: resize frames, change format, import buffers, apply filters (such as denoise, sharpen, orientation, if driver offers them). Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1529>
This commit is contained in:
parent
117453b947
commit
9845ec68dc
6 changed files with 3511 additions and 1 deletions
1072
sys/va/gstvafilter.c
Normal file
1072
sys/va/gstvafilter.c
Normal file
File diff suppressed because it is too large
Load diff
72
sys/va/gstvafilter.h
Normal file
72
sys/va/gstvafilter.h
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
/* GStreamer
|
||||||
|
* Copyright (C) 2020 Igalia, S.L.
|
||||||
|
* Author: Víctor Jáquez <vjaquez@igalia.com>
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||||
|
* Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "gstvadisplay.h"
|
||||||
|
|
||||||
|
#include <gst/video/video.h>
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
enum {
|
||||||
|
GST_VA_FILTER_PROP_DENOISE = 1,
|
||||||
|
GST_VA_FILTER_PROP_SHARPEN,
|
||||||
|
GST_VA_FILTER_PROP_SKINTONE,
|
||||||
|
GST_VA_FILTER_PROP_VIDEO_DIR,
|
||||||
|
GST_VA_FILTER_PROP_HUE,
|
||||||
|
GST_VA_FILTER_PROP_SATURATION,
|
||||||
|
GST_VA_FILTER_PROP_BRIGHTNESS,
|
||||||
|
GST_VA_FILTER_PROP_CONTRAST,
|
||||||
|
GST_VA_FILTER_PROP_AUTO_SATURATION,
|
||||||
|
GST_VA_FILTER_PROP_AUTO_BRIGHTNESS,
|
||||||
|
GST_VA_FILTER_PROP_AUTO_CONTRAST,
|
||||||
|
GST_VA_FILTER_PROP_LAST
|
||||||
|
};
|
||||||
|
|
||||||
|
GstVaFilter * gst_va_filter_new (GstVaDisplay * display);
|
||||||
|
gboolean gst_va_filter_open (GstVaFilter * self);
|
||||||
|
gboolean gst_va_filter_close (GstVaFilter * self);
|
||||||
|
gboolean gst_va_filter_is_open (GstVaFilter * self);
|
||||||
|
gboolean gst_va_filter_install_properties (GstVaFilter * self,
|
||||||
|
GObjectClass * klass);
|
||||||
|
gboolean gst_va_filter_set_orientation (GstVaFilter * self,
|
||||||
|
GstVideoOrientationMethod orientation);
|
||||||
|
GstVideoOrientationMethod gst_va_filter_get_orientation (GstVaFilter * self);
|
||||||
|
const gpointer gst_va_filter_get_filter_caps (GstVaFilter * self,
|
||||||
|
VAProcFilterType type,
|
||||||
|
guint * num_caps);
|
||||||
|
guint32 gst_va_filter_get_mem_types (GstVaFilter * self);
|
||||||
|
GArray * gst_va_filter_get_surface_formats (GstVaFilter * self);
|
||||||
|
GstCaps * gst_va_filter_get_caps (GstVaFilter * self);
|
||||||
|
gboolean gst_va_filter_add_filter_buffer (GstVaFilter * self,
|
||||||
|
gpointer data,
|
||||||
|
gsize size,
|
||||||
|
guint num);
|
||||||
|
gboolean gst_va_filter_convert_surface (GstVaFilter * self,
|
||||||
|
VASurfaceID in_surface,
|
||||||
|
GstVideoInfo * in_info,
|
||||||
|
VASurfaceID out_surface,
|
||||||
|
GstVideoInfo * out_info);
|
||||||
|
|
||||||
|
G_END_DECLS
|
2311
sys/va/gstvavpp.c
Normal file
2311
sys/va/gstvavpp.c
Normal file
File diff suppressed because it is too large
Load diff
31
sys/va/gstvavpp.h
Normal file
31
sys/va/gstvavpp.h
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
/* GStreamer
|
||||||
|
* Copyright (C) 2020 Igalia, S.L.
|
||||||
|
* Author: Víctor Jáquez <vjaquez@igalia.com>
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||||
|
* Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "gstvadevice.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
gboolean gst_va_vpp_register (GstPlugin * plugin,
|
||||||
|
GstVaDevice * device,
|
||||||
|
guint rank);
|
||||||
|
|
||||||
|
G_END_DECLS
|
|
@ -7,11 +7,13 @@ va_sources = [
|
||||||
'gstvadisplay_drm.c',
|
'gstvadisplay_drm.c',
|
||||||
'gstvadisplay_wrapped.c',
|
'gstvadisplay_wrapped.c',
|
||||||
'gstvadevice.c',
|
'gstvadevice.c',
|
||||||
|
'gstvafilter.c',
|
||||||
'gstvah264dec.c',
|
'gstvah264dec.c',
|
||||||
'gstvapool.c',
|
'gstvapool.c',
|
||||||
'gstvaprofile.c',
|
'gstvaprofile.c',
|
||||||
'gstvautils.c',
|
'gstvautils.c',
|
||||||
'gstvavideoformat.c',
|
'gstvavideoformat.c',
|
||||||
|
'gstvavpp.c'
|
||||||
]
|
]
|
||||||
|
|
||||||
va_option = get_option('va')
|
va_option = get_option('va')
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "gstvadevice.h"
|
#include "gstvadevice.h"
|
||||||
#include "gstvah264dec.h"
|
#include "gstvah264dec.h"
|
||||||
#include "gstvaprofile.h"
|
#include "gstvaprofile.h"
|
||||||
|
#include "gstvavpp.h"
|
||||||
|
|
||||||
#define GST_CAT_DEFAULT gstva_debug
|
#define GST_CAT_DEFAULT gstva_debug
|
||||||
GST_DEBUG_CATEGORY (gstva_debug);
|
GST_DEBUG_CATEGORY (gstva_debug);
|
||||||
|
@ -138,6 +139,13 @@ plugin_register_encoders (GstPlugin * plugin, GstVaDevice * device,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
plugin_register_vpp (GstPlugin * plugin, GstVaDevice * device)
|
||||||
|
{
|
||||||
|
if (!gst_va_vpp_register (plugin, device, GST_RANK_NONE))
|
||||||
|
GST_WARNING ("Failed to register postproc: %s", device->render_device_path);
|
||||||
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
_insert_profile_in_table (GHashTable * table, VAProfile profile)
|
_insert_profile_in_table (GHashTable * table, VAProfile profile)
|
||||||
{
|
{
|
||||||
|
@ -167,7 +175,7 @@ plugin_register_elements (GstPlugin * plugin, GstVaDevice * device)
|
||||||
VAStatus status;
|
VAStatus status;
|
||||||
GHashTable *decoders, *encoders, *encoderslp, *encodersimg;
|
GHashTable *decoders, *encoders, *encoderslp, *encodersimg;
|
||||||
gint i, j, num_entrypoints = 0, num_profiles = 0;
|
gint i, j, num_entrypoints = 0, num_profiles = 0;
|
||||||
gboolean ret = FALSE;
|
gboolean has_vpp = FALSE, ret = FALSE;
|
||||||
|
|
||||||
decoders = g_hash_table_new_full (g_int64_hash, g_int64_equal,
|
decoders = g_hash_table_new_full (g_int64_hash, g_int64_equal,
|
||||||
(GDestroyNotify) g_free, (GDestroyNotify) g_array_unref);
|
(GDestroyNotify) g_free, (GDestroyNotify) g_array_unref);
|
||||||
|
@ -204,11 +212,25 @@ plugin_register_elements (GstPlugin * plugin, GstVaDevice * device)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
status = vaQueryConfigEntrypoints (dpy, VAProfileNone, entrypoints,
|
||||||
|
&num_entrypoints);
|
||||||
|
if (status != VA_STATUS_SUCCESS) {
|
||||||
|
GST_ERROR ("vaQueryConfigEntrypoints: %s", vaErrorStr (status));
|
||||||
|
goto bail;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (j = 0; j < num_entrypoints; j++) {
|
||||||
|
if ((has_vpp = (entrypoints[j] == VAEntrypointVideoProc)))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
plugin_register_decoders (plugin, device, decoders);
|
plugin_register_decoders (plugin, device, decoders);
|
||||||
plugin_register_encoders (plugin, device, encoders, VAEntrypointEncSlice);
|
plugin_register_encoders (plugin, device, encoders, VAEntrypointEncSlice);
|
||||||
plugin_register_encoders (plugin, device, encoderslp, VAEntrypointEncSliceLP);
|
plugin_register_encoders (plugin, device, encoderslp, VAEntrypointEncSliceLP);
|
||||||
plugin_register_encoders (plugin, device, encodersimg,
|
plugin_register_encoders (plugin, device, encodersimg,
|
||||||
VAEntrypointEncPicture);
|
VAEntrypointEncPicture);
|
||||||
|
if (has_vpp)
|
||||||
|
plugin_register_vpp (plugin, device);
|
||||||
|
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue