summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gst-libs/gst/meson.build1
-rw-r--r--gst-libs/gst/va/gstvadisplay.c (renamed from sys/va/gstvadisplay.c)159
-rw-r--r--gst-libs/gst/va/gstvadisplay.h134
-rw-r--r--gst-libs/gst/va/gstvadisplay_drm.c (renamed from sys/va/gstvadisplay_drm.c)8
-rw-r--r--gst-libs/gst/va/gstvadisplay_drm.h39
-rw-r--r--gst-libs/gst/va/gstvadisplay_wrapped.c (renamed from sys/va/gstvadisplay_wrapped.c)8
-rw-r--r--gst-libs/gst/va/gstvadisplay_wrapped.h39
-rw-r--r--gst-libs/gst/va/meson.build60
-rw-r--r--gst-libs/gst/va/va-prelude.h30
-rw-r--r--gst-libs/gst/va/va_fwd.h (renamed from sys/va/gstvadisplay_drm.h)16
-rw-r--r--sys/va/gstvaallocator.h4
-rw-r--r--sys/va/gstvacaps.c6
-rw-r--r--sys/va/gstvacaps.h3
-rw-r--r--sys/va/gstvadecoder.c3
-rw-r--r--sys/va/gstvadecoder.h3
-rw-r--r--sys/va/gstvadevice.c1
-rw-r--r--sys/va/gstvadevice.h2
-rw-r--r--sys/va/gstvadisplay.h68
-rw-r--r--sys/va/gstvadisplay_priv.c137
-rw-r--r--sys/va/gstvadisplay_priv.h (renamed from sys/va/gstvadisplay_wrapped.h)13
-rw-r--r--sys/va/gstvafilter.c1
-rw-r--r--sys/va/gstvafilter.h4
-rw-r--r--sys/va/gstvautils.c15
-rw-r--r--sys/va/gstvautils.h2
-rw-r--r--sys/va/gstvavpp.c2
-rw-r--r--sys/va/meson.build28
26 files changed, 548 insertions, 238 deletions
diff --git a/gst-libs/gst/meson.build b/gst-libs/gst/meson.build
index 809ab4ac0..a2862a3d8 100644
--- a/gst-libs/gst/meson.build
+++ b/gst-libs/gst/meson.build
@@ -18,3 +18,4 @@ subdir('transcoder')
subdir('vulkan')
subdir('wayland')
subdir('webrtc')
+subdir('va')
diff --git a/sys/va/gstvadisplay.c b/gst-libs/gst/va/gstvadisplay.c
index a5139b172..65a0511aa 100644
--- a/sys/va/gstvadisplay.c
+++ b/gst-libs/gst/va/gstvadisplay.c
@@ -23,8 +23,7 @@
#endif
#include "gstvadisplay.h"
-#include "gstvaprofile.h"
-#include "gstvavideoformat.h"
+#include <va/va.h>
GST_DEBUG_CATEGORY (gst_va_display_debug);
#define GST_CAT_DEFAULT gst_va_display_debug
@@ -208,6 +207,15 @@ gst_va_display_init (GstVaDisplay * self)
priv->impl = GST_VA_IMPLEMENTATION_INVALID;
}
+/**
+ * gst_va_display_lock:
+ * @self: a #GstVaDisplay
+ *
+ * Lock the display. It will be used before we call the
+ * VA API functions to serialize the VA commands.
+ *
+ * Since: 1.20
+ **/
void
gst_va_display_lock (GstVaDisplay * self)
{
@@ -220,6 +228,15 @@ gst_va_display_lock (GstVaDisplay * self)
g_rec_mutex_lock (&priv->lock);
}
+/**
+ * gst_va_display_unlock:
+ * @self: a #GstVaDisplay
+ *
+ * Unlock the display. It will be used after we call the
+ * VA API functions.
+ *
+ * Since: 1.20
+ **/
void
gst_va_display_unlock (GstVaDisplay * self)
{
@@ -282,6 +299,8 @@ _va_info (gpointer object, const char *message)
*
* Returns: %TRUE if the VA driver can be initialized; %FALSE
* otherwise
+ *
+ * Since: 1.20
**/
gboolean
gst_va_display_initialize (GstVaDisplay * self)
@@ -321,127 +340,37 @@ gst_va_display_initialize (GstVaDisplay * self)
return TRUE;
}
-VADisplay
+/**
+ * gst_va_display_get_va_dpy:
+ * @self: a #GstVaDisplay type display.
+ *
+ * Get the VA display handle of the @self.
+ *
+ * Returns: the VA display handle.
+ *
+ * Since: 1.20
+ */
+gpointer
gst_va_display_get_va_dpy (GstVaDisplay * self)
{
- VADisplay dpy = 0;
-
- g_return_val_if_fail (GST_IS_VA_DISPLAY (self), 0);
-
- g_object_get (self, "va-display", &dpy, NULL);
- return dpy;
-}
-
-GArray *
-gst_va_display_get_profiles (GstVaDisplay * self, guint32 codec,
- VAEntrypoint entrypoint)
-{
- GArray *ret = NULL;
VADisplay dpy;
- VAEntrypoint *entrypoints;
- VAProfile *profiles;
- VAStatus status;
- gint i, j, num_entrypoints = 0, num_profiles = 0;
g_return_val_if_fail (GST_IS_VA_DISPLAY (self), NULL);
- dpy = gst_va_display_get_va_dpy (self);
-
- gst_va_display_lock (self);
- num_profiles = vaMaxNumProfiles (dpy);
- num_entrypoints = vaMaxNumEntrypoints (dpy);
- gst_va_display_unlock (self);
-
- profiles = g_new (VAProfile, num_profiles);
- entrypoints = g_new (VAEntrypoint, num_entrypoints);
-
- gst_va_display_lock (self);
- status = vaQueryConfigProfiles (dpy, profiles, &num_profiles);
- gst_va_display_unlock (self);
- if (status != VA_STATUS_SUCCESS) {
- GST_ERROR ("vaQueryConfigProfile: %s", vaErrorStr (status));
- goto bail;
- }
-
- for (i = 0; i < num_profiles; i++) {
- if (codec != gst_va_profile_codec (profiles[i]))
- continue;
-
- gst_va_display_lock (self);
- status = vaQueryConfigEntrypoints (dpy, profiles[i], entrypoints,
- &num_entrypoints);
- gst_va_display_unlock (self);
- if (status != VA_STATUS_SUCCESS) {
- GST_ERROR ("vaQueryConfigEntrypoints: %s", vaErrorStr (status));
- goto bail;
- }
-
- for (j = 0; j < num_entrypoints; j++) {
- if (entrypoints[j] == entrypoint) {
- if (!ret)
- ret = g_array_new (FALSE, FALSE, sizeof (VAProfile));
- g_array_append_val (ret, profiles[i]);
- break;
- }
- }
- }
-
-bail:
- g_free (entrypoints);
- g_free (profiles);
- return ret;
-}
-
-GArray *
-gst_va_display_get_image_formats (GstVaDisplay * self)
-{
- GArray *ret = NULL;
- GstVideoFormat format;
- VADisplay dpy;
- VAImageFormat *va_formats;
- VAStatus status;
- int i, max, num = 0;
-
- g_return_val_if_fail (GST_IS_VA_DISPLAY (self), NULL);
-
- dpy = gst_va_display_get_va_dpy (self);
-
- gst_va_display_lock (self);
- max = vaMaxNumImageFormats (dpy);
- gst_va_display_unlock (self);
- if (max == 0)
- return NULL;
-
- va_formats = g_new (VAImageFormat, max);
-
- gst_va_display_lock (self);
- status = vaQueryImageFormats (dpy, va_formats, &num);
- gst_va_display_unlock (self);
-
- gst_va_video_format_fix_map (va_formats, num);
-
- if (status != VA_STATUS_SUCCESS) {
- GST_ERROR ("vaQueryImageFormats: %s", vaErrorStr (status));
- goto bail;
- }
-
- ret = g_array_sized_new (FALSE, FALSE, sizeof (GstVideoFormat), num);
- for (i = 0; i < num; i++) {
- format = gst_va_video_format_from_va_image_format (&va_formats[i]);
- if (format != GST_VIDEO_FORMAT_UNKNOWN)
- g_array_append_val (ret, format);
- }
-
- if (ret->len == 0) {
- g_array_unref (ret);
- ret = NULL;
- }
-
-bail:
- g_free (va_formats);
- return ret;
+ g_object_get (self, "va-display", &dpy, NULL);
+ return dpy;
}
+/**
+ * gst_va_display_get_implementation:
+ * @self: a #GstVaDisplay type display.
+ *
+ * Get the the #GstVaImplementation type of @self.
+ *
+ * Returns: #GstVaImplementation.
+ *
+ * Since: 1.20
+ */
GstVaImplementation
gst_va_display_get_implementation (GstVaDisplay * self)
{
diff --git a/gst-libs/gst/va/gstvadisplay.h b/gst-libs/gst/va/gstvadisplay.h
new file mode 100644
index 000000000..09def14da
--- /dev/null
+++ b/gst-libs/gst/va/gstvadisplay.h
@@ -0,0 +1,134 @@
+/* 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 <gst/va/va_fwd.h>
+#include <gst/va/va-prelude.h>
+#include <gst/gst.h>
+
+G_BEGIN_DECLS
+
+/**
+ * GstVaImplementation:
+ * @GST_VA_IMPLEMENTATION_MESA_GALLIUM: The mesa gallium implementation.
+ * @GST_VA_IMPLEMENTATION_INTEL_I965: The legacy i965 intel implementation.
+ * @GST_VA_IMPLEMENTATION_INTEL_IHD: The iHD intel implementation.
+ * @GST_VA_IMPLEMENTATION_OTHER: Other implementation.
+ * @GST_VA_IMPLEMENTATION_INVALID: Invalid implementation.
+ *
+ * Types of different VA API implemented drivers. These are the typical and
+ * the most widely used VA drivers.
+ *
+ * Since: 1.20
+ */
+typedef enum
+{
+ GST_VA_IMPLEMENTATION_MESA_GALLIUM,
+ GST_VA_IMPLEMENTATION_INTEL_I965,
+ GST_VA_IMPLEMENTATION_INTEL_IHD,
+ GST_VA_IMPLEMENTATION_OTHER,
+ GST_VA_IMPLEMENTATION_INVALID,
+} GstVaImplementation;
+
+/**
+ * GST_VA_DISPLAY_HANDLE_CONTEXT_TYPE_STR:
+ *
+ * Since: 1.20
+ */
+#define GST_VA_DISPLAY_HANDLE_CONTEXT_TYPE_STR "gst.va.display.handle"
+
+/**
+ * GST_VA_DISPLAY_IS_IMPLEMENTATION: (skip)
+ *
+ * Check whether the display is the implementation of the specified
+ * #GstVaImplementation type.
+ */
+#define GST_VA_DISPLAY_IS_IMPLEMENTATION(display, impl) \
+ (gst_va_display_is_implementation (display, G_PASTE (GST_VA_IMPLEMENTATION_, impl)))
+
+#define GST_TYPE_VA_DISPLAY (gst_va_display_get_type())
+#define GST_VA_DISPLAY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_VA_DISPLAY, GstVaDisplay))
+#define GST_VA_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_VA_DISPLAY, GstVaDisplayClass))
+#define GST_IS_VA_DISPLAY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_VA_DISPLAY))
+#define GST_IS_VA_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_VA_DISPLAY))
+#define GST_VA_DISPLAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_VA_DISPLAY, GstVaDisplayClass))
+
+/**
+ * GstVaDisplay:
+ *
+ * The common VA display object structure.
+ *
+ * Since: 1.20
+ */
+struct _GstVaDisplay
+{
+ /*< private > */
+ GstObject parent;
+};
+
+/**
+ * GstVaDisplayClass:
+ *
+ * The common VA display object class structure.
+ * @create_va_display: The function to create the real VA display.
+ *
+ * Since: 1.20
+ */
+struct _GstVaDisplayClass
+{
+ /*< private > */
+ GstObjectClass parent_class;
+
+ /*< public > */
+ gpointer (*create_va_display) (GstVaDisplay * self);
+};
+
+GST_VA_API
+GType gst_va_display_get_type (void);
+GST_VA_API
+void gst_va_display_lock (GstVaDisplay * self);
+GST_VA_API
+void gst_va_display_unlock (GstVaDisplay * self);
+GST_VA_API
+gboolean gst_va_display_initialize (GstVaDisplay * self);
+GST_VA_API
+gpointer gst_va_display_get_va_dpy (GstVaDisplay * self);
+GST_VA_API
+GstVaImplementation gst_va_display_get_implementation (GstVaDisplay * self);
+
+/**
+ * gst_va_display_is_implementation:
+ * @display: the #GstVaDisplay to check.
+ * @impl: the specified #GstVaImplementation.
+ *
+ * Check whether the @display is the implementation of the @impl type.
+ *
+ * Returns: %TRUE if the @display is the implementation of the @impl type.
+ *
+ * Since: 1.20
+ */
+static inline gboolean
+gst_va_display_is_implementation (GstVaDisplay * display, GstVaImplementation impl)
+{
+ return (gst_va_display_get_implementation (display) == impl);
+}
+
+G_END_DECLS
diff --git a/sys/va/gstvadisplay_drm.c b/gst-libs/gst/va/gstvadisplay_drm.c
index 93625ea43..092bab58b 100644
--- a/sys/va/gstvadisplay_drm.c
+++ b/gst-libs/gst/va/gstvadisplay_drm.c
@@ -41,6 +41,12 @@ struct _GstVaDisplayDrm
gint fd;
};
+struct _GstVaDisplayDrmClass
+{
+ /*< private > */
+ GstVaDisplayClass parent_class;
+};
+
GST_DEBUG_CATEGORY_EXTERN (gst_va_display_debug);
#define GST_CAT_DEFAULT gst_va_display_debug
@@ -170,6 +176,8 @@ gst_va_display_drm_init (GstVaDisplayDrm * self)
* Returns: a newly allocated #GstVaDisplay if the specified DRM
* render device could be opened and initialized; otherwise %NULL
* is returned.
+ *
+ * Since: 1.20
**/
GstVaDisplay *
gst_va_display_drm_new_from_path (const gchar * path)
diff --git a/gst-libs/gst/va/gstvadisplay_drm.h b/gst-libs/gst/va/gstvadisplay_drm.h
new file mode 100644
index 000000000..6cf9326c4
--- /dev/null
+++ b/gst-libs/gst/va/gstvadisplay_drm.h
@@ -0,0 +1,39 @@
+/* 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"
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_VA_DISPLAY_DRM (gst_va_display_drm_get_type())
+#define GST_VA_DISPLAY_DRM(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_VA_DISPLAY_DRM, GstVaDisplayDrm))
+#define GST_VA_DISPLAY_DRM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_VA_DISPLAY_DRM, GstVaDisplayDrmClass))
+#define GST_IS_VA_DISPLAY_DRM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_VA_DISPLAY_DRM))
+#define GST_IS_VA_DISPLAY_DRM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_VA_DISPLAY_DRM))
+#define GST_VA_DISPLAY_DRM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_VA_DISPLAY_DRM, GstVaDisplayDrmClass))
+
+GST_VA_API
+GType gst_va_display_drm_get_type (void);
+GST_VA_API
+GstVaDisplay * gst_va_display_drm_new_from_path (const gchar * path);
+
+G_END_DECLS
diff --git a/sys/va/gstvadisplay_wrapped.c b/gst-libs/gst/va/gstvadisplay_wrapped.c
index dd9825110..9a3fea112 100644
--- a/sys/va/gstvadisplay_wrapped.c
+++ b/gst-libs/gst/va/gstvadisplay_wrapped.c
@@ -29,6 +29,12 @@ struct _GstVaDisplayWrapped
GstVaDisplay parent;
};
+struct _GstVaDisplayWrappedClass
+{
+ /*< private > */
+ GstVaDisplayClass parent_class;
+};
+
#define gst_va_display_wrapped_parent_class parent_class
G_DEFINE_TYPE (GstVaDisplayWrapped, gst_va_display_wrapped,
GST_TYPE_VA_DISPLAY);
@@ -51,6 +57,8 @@ gst_va_display_wrapped_init (GstVaDisplayWrapped * self)
* VADisplay.
*
* Returns: a new #GstVaDisplay if @handle is valid, Otherwise %NULL.
+ *
+ * Since: 1.20
**/
GstVaDisplay *
gst_va_display_wrapped_new (guintptr handle)
diff --git a/gst-libs/gst/va/gstvadisplay_wrapped.h b/gst-libs/gst/va/gstvadisplay_wrapped.h
new file mode 100644
index 000000000..93f36c969
--- /dev/null
+++ b/gst-libs/gst/va/gstvadisplay_wrapped.h
@@ -0,0 +1,39 @@
+/* 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"
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_VA_DISPLAY_WRAPPED (gst_va_display_wrapped_get_type())
+#define GST_VA_DISPLAY_WRAPPED(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_VA_DISPLAY_WRAPPED, GstVaDisplayWrapped))
+#define GST_VA_DISPLAY_WRAPPED_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_VA_DISPLAY_WRAPPED, GstVaDisplayWrappedClass))
+#define GST_IS_VA_DISPLAY_WRAPPED(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_VA_DISPLAY_WRAPPED))
+#define GST_IS_VA_DISPLAY_WRAPPED_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_VA_DISPLAY_WRAPPED))
+#define GST_VA_DISPLAY_WRAPPED_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_VA_DISPLAY_WRAPPED, GstVaDisplayWrappedClass))
+
+GST_VA_API
+GType gst_va_display_wrapped_get_type (void);
+GST_VA_API
+GstVaDisplay * gst_va_display_wrapped_new (guintptr handle);
+
+G_END_DECLS
diff --git a/gst-libs/gst/va/meson.build b/gst-libs/gst/va/meson.build
new file mode 100644
index 000000000..9999fbd92
--- /dev/null
+++ b/gst-libs/gst/va/meson.build
@@ -0,0 +1,60 @@
+va_sources = [
+ 'gstvadisplay.c',
+ 'gstvadisplay_drm.c',
+ 'gstvadisplay_wrapped.c',
+]
+
+va_headers = [
+ 'gstvadisplay.h',
+ 'gstvadisplay_drm.h',
+ 'gstvadisplay_wrapped.h',
+ 'va_fwd.h',
+ 'va-prelude.h',
+]
+
+gstva_dep = dependency('', required : false)
+
+have_va = false
+va_option = get_option('va')
+if va_option.disabled() or host_system != 'linux'
+ subdir_done()
+endif
+
+libva_req = ['>= 1.6']
+
+libva_dep = dependency('libva', version: libva_req, required: va_option)
+libva_drm_dep = dependency('libva-drm', version: libva_req, required: va_option)
+libgudev_dep = dependency('gudev-1.0', required: va_option)
+libdrm_dep = dependency('libdrm', required: false, fallback: ['libdrm', 'ext_libdrm'])
+
+have_va = libva_dep.found() and libva_drm_dep.found()
+if not (have_va and libgudev_dep.found())
+ if va_option.enabled()
+ error('The va lib was enabled explicity, but required dependencies were not found.')
+ endif
+ subdir_done()
+endif
+
+
+gstva = library('gstva-' + api_version,
+ va_sources,
+ c_args : gst_plugins_bad_args + ['-DGST_USE_UNSTABLE_API', '-DBUILDING_GST_VA'],
+ include_directories : [configinc, libsinc],
+ version : libversion,
+ soversion : soversion,
+ install : true,
+ dependencies : [gst_dep, libva_dep, libva_drm_dep, libgudev_dep, libdrm_dep],
+)
+
+pkgconfig.generate(gstva,
+ libraries : gst_dep,
+ variables : pkgconfig_variables,
+ subdirs : pkgconfig_subdirs,
+ name : 'gstreamer-va-1.0',
+ description : 'GStreamer VA support',
+)
+
+gstva_dep = declare_dependency(link_with : gstva,
+ include_directories : [libsinc],
+ dependencies : [gst_dep, libva_dep, libva_drm_dep, libgudev_dep, libdrm_dep])
+meson.override_dependency('gstreamer-va-1.0', gstva_dep)
diff --git a/gst-libs/gst/va/va-prelude.h b/gst-libs/gst/va/va-prelude.h
new file mode 100644
index 000000000..3c901b2a8
--- /dev/null
+++ b/gst-libs/gst/va/va-prelude.h
@@ -0,0 +1,30 @@
+/* GStreamer
+ * Copyright (C) 2021 GStreamer developers
+ *
+ * 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 <gst/gst.h>
+
+#ifndef GST_VA_API
+# ifdef BUILDING_GST_VA
+# define GST_VA_API GST_API_EXPORT /* from config.h */
+# else
+# define GST_VA_API GST_API_IMPORT
+# endif
+#endif
diff --git a/sys/va/gstvadisplay_drm.h b/gst-libs/gst/va/va_fwd.h
index 1b3121a25..0b1b8cb33 100644
--- a/sys/va/gstvadisplay_drm.h
+++ b/gst-libs/gst/va/va_fwd.h
@@ -1,6 +1,5 @@
/* GStreamer
- * Copyright (C) 2020 Igalia, S.L.
- * Author: Víctor Jáquez <vjaquez@igalia.com>
+ * Copyright (C) 2021 GStreamer developers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -20,14 +19,17 @@
#pragma once
-#include "gstvadisplay.h"
+#include <gst/gst.h>
G_BEGIN_DECLS
-#define GST_TYPE_VA_DISPLAY_DRM (gst_va_display_drm_get_type())
-G_DECLARE_FINAL_TYPE (GstVaDisplayDrm, gst_va_display_drm, GST, VA_DISPLAY_DRM,
- GstVaDisplay)
+typedef struct _GstVaDisplay GstVaDisplay;
+typedef struct _GstVaDisplayClass GstVaDisplayClass;
-GstVaDisplay * gst_va_display_drm_new_from_path (const gchar * path);
+typedef struct _GstVaDisplayDrm GstVaDisplayDrm;
+typedef struct _GstVaDisplayDrmClass GstVaDisplayDrmClass;
+
+typedef struct _GstVaDisplayWrapped GstVaDisplayWrapped;
+typedef struct _GstVaDisplayWrappedClass GstVaDisplayWrappedClass;
G_END_DECLS
diff --git a/sys/va/gstvaallocator.h b/sys/va/gstvaallocator.h
index e4123c251..de97fd685 100644
--- a/sys/va/gstvaallocator.h
+++ b/sys/va/gstvaallocator.h
@@ -21,9 +21,9 @@
#pragma once
#include <gst/allocators/allocators.h>
+#include <gst/va/gstvadisplay.h>
#include <gst/video/video.h>
-
-#include "gstvadisplay.h"
+#include <va/va.h>
G_BEGIN_DECLS
diff --git a/sys/va/gstvacaps.c b/sys/va/gstvacaps.c
index e421c812b..1b0dd651c 100644
--- a/sys/va/gstvacaps.c
+++ b/sys/va/gstvacaps.c
@@ -28,12 +28,12 @@
#include <va/va_drmcommon.h>
-#include "gstvadisplay.h"
+#include "gstvadisplay_priv.h"
#include "gstvaprofile.h"
#include "gstvavideoformat.h"
-GST_DEBUG_CATEGORY_EXTERN (gst_va_display_debug);
-#define GST_CAT_DEFAULT gst_va_display_debug
+GST_DEBUG_CATEGORY_EXTERN (gstva_debug);
+#define GST_CAT_DEFAULT gstva_debug
static const guint va_rt_format_list[] = {
#define R(name) G_PASTE (VA_RT_FORMAT_, name)
diff --git a/sys/va/gstvacaps.h b/sys/va/gstvacaps.h
index c36ef0501..096e656e4 100644
--- a/sys/va/gstvacaps.h
+++ b/sys/va/gstvacaps.h
@@ -20,7 +20,8 @@
#pragma once
-#include "gstvadisplay.h"
+#include <gst/va/gstvadisplay.h>
+#include <va/va.h>
G_BEGIN_DECLS
diff --git a/sys/va/gstvadecoder.c b/sys/va/gstvadecoder.c
index f47728258..17c814a07 100644
--- a/sys/va/gstvadecoder.c
+++ b/sys/va/gstvadecoder.c
@@ -26,8 +26,9 @@
#include "gstvaallocator.h"
#include "gstvacaps.h"
-#include "gstvadisplay_wrapped.h"
+#include "gstvadisplay_priv.h"
#include "gstvavideoformat.h"
+#include <gst/va/gstvadisplay_wrapped.h>
struct _GstVaDecoder
{
diff --git a/sys/va/gstvadecoder.h b/sys/va/gstvadecoder.h
index c3a16a354..c6e31e26d 100644
--- a/sys/va/gstvadecoder.h
+++ b/sys/va/gstvadecoder.h
@@ -20,7 +20,8 @@
#pragma once
-#include "gstvadisplay.h"
+#include <gst/va/gstvadisplay.h>
+#include <va/va.h>
G_BEGIN_DECLS
diff --git a/sys/va/gstvadevice.c b/sys/va/gstvadevice.c
index 0e251e158..1faa61fa8 100644
--- a/sys/va/gstvadevice.c
+++ b/sys/va/gstvadevice.c
@@ -25,7 +25,6 @@
#include "gstvadevice.h"
#include <gudev/gudev.h>
-#include "gstvadisplay_drm.h"
#define GST_CAT_DEFAULT gstva_debug
GST_DEBUG_CATEGORY_EXTERN (gstva_debug);
diff --git a/sys/va/gstvadevice.h b/sys/va/gstvadevice.h
index f5bc7df3a..774741a84 100644
--- a/sys/va/gstvadevice.h
+++ b/sys/va/gstvadevice.h
@@ -24,7 +24,7 @@
G_BEGIN_DECLS
-#include "gstvadisplay.h"
+#include <gst/va/gstvadisplay_drm.h>
#define GST_TYPE_VA_DEVICE (gst_va_device_get_type())
#define GST_IS_VA_DEVICE(obj) (GST_IS_MINI_OBJECT_TYPE((obj), GST_TYPE_VA_DEVICE))
diff --git a/sys/va/gstvadisplay.h b/sys/va/gstvadisplay.h
deleted file mode 100644
index a30c4bba0..000000000
--- a/sys/va/gstvadisplay.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* 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 <gst/gst.h>
-#include <va/va.h>
-
-G_BEGIN_DECLS
-
-typedef enum
-{
- GST_VA_IMPLEMENTATION_MESA_GALLIUM,
- GST_VA_IMPLEMENTATION_INTEL_I965,
- GST_VA_IMPLEMENTATION_INTEL_IHD,
- GST_VA_IMPLEMENTATION_OTHER,
- GST_VA_IMPLEMENTATION_INVALID,
-} GstVaImplementation;
-
-#define GST_VA_DISPLAY_IS_IMPLEMENTATION(display, impl) \
- (gst_va_display_is_implementation (display, G_PASTE (GST_VA_IMPLEMENTATION_, impl)))
-
-#define GST_TYPE_VA_DISPLAY (gst_va_display_get_type())
-G_DECLARE_DERIVABLE_TYPE (GstVaDisplay, gst_va_display, GST, VA_DISPLAY, GstObject)
-
-struct _GstVaDisplayClass
-{
- /*< private > */
- GstObjectClass parent_class;
-
- /*< public > */
- gpointer (*create_va_display) (GstVaDisplay * self);
-};
-
-void gst_va_display_lock (GstVaDisplay * self);
-void gst_va_display_unlock (GstVaDisplay * self);
-gboolean gst_va_display_initialize (GstVaDisplay * self);
-VADisplay gst_va_display_get_va_dpy (GstVaDisplay * self);
-GArray * gst_va_display_get_profiles (GstVaDisplay * self,
- guint32 codec,
- VAEntrypoint entrypoint);
-GArray * gst_va_display_get_image_formats (GstVaDisplay * self);
-GstVaImplementation gst_va_display_get_implementation (GstVaDisplay * self);
-
-static inline gboolean
-gst_va_display_is_implementation (GstVaDisplay * self, GstVaImplementation impl)
-{
- return (gst_va_display_get_implementation (self) == impl);
-}
-
-G_END_DECLS
diff --git a/sys/va/gstvadisplay_priv.c b/sys/va/gstvadisplay_priv.c
new file mode 100644
index 000000000..b9f970f9a
--- /dev/null
+++ b/sys/va/gstvadisplay_priv.c
@@ -0,0 +1,137 @@
+/* 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "gstvadisplay_priv.h"
+#include "gstvaprofile.h"
+#include "gstvavideoformat.h"
+
+GArray *
+gst_va_display_get_profiles (GstVaDisplay * self, guint32 codec,
+ VAEntrypoint entrypoint)
+{
+ GArray *ret = NULL;
+ VADisplay dpy;
+ VAEntrypoint *entrypoints;
+ VAProfile *profiles;
+ VAStatus status;
+ gint i, j, num_entrypoints = 0, num_profiles = 0;
+
+ g_return_val_if_fail (GST_IS_VA_DISPLAY (self), NULL);
+
+ dpy = gst_va_display_get_va_dpy (self);
+
+ gst_va_display_lock (self);
+ num_profiles = vaMaxNumProfiles (dpy);
+ num_entrypoints = vaMaxNumEntrypoints (dpy);
+ gst_va_display_unlock (self);
+
+ profiles = g_new (VAProfile, num_profiles);
+ entrypoints = g_new (VAEntrypoint, num_entrypoints);
+
+ gst_va_display_lock (self);
+ status = vaQueryConfigProfiles (dpy, profiles, &num_profiles);
+ gst_va_display_unlock (self);
+ if (status != VA_STATUS_SUCCESS) {
+ GST_ERROR ("vaQueryConfigProfile: %s", vaErrorStr (status));
+ goto bail;
+ }
+
+ for (i = 0; i < num_profiles; i++) {
+ if (codec != gst_va_profile_codec (profiles[i]))
+ continue;
+
+ gst_va_display_lock (self);
+ status = vaQueryConfigEntrypoints (dpy, profiles[i], entrypoints,
+ &num_entrypoints);
+ gst_va_display_unlock (self);
+ if (status != VA_STATUS_SUCCESS) {
+ GST_ERROR ("vaQueryConfigEntrypoints: %s", vaErrorStr (status));
+ goto bail;
+ }
+
+ for (j = 0; j < num_entrypoints; j++) {
+ if (entrypoints[j] == entrypoint) {
+ if (!ret)
+ ret = g_array_new (FALSE, FALSE, sizeof (VAProfile));
+ g_array_append_val (ret, profiles[i]);
+ break;
+ }
+ }
+ }
+
+bail:
+ g_free (entrypoints);
+ g_free (profiles);
+ return ret;
+}
+
+GArray *
+gst_va_display_get_image_formats (GstVaDisplay * self)
+{
+ GArray *ret = NULL;
+ GstVideoFormat format;
+ VADisplay dpy;
+ VAImageFormat *va_formats;
+ VAStatus status;
+ int i, max, num = 0;
+
+ g_return_val_if_fail (GST_IS_VA_DISPLAY (self), NULL);
+
+ dpy = gst_va_display_get_va_dpy (self);
+
+ gst_va_display_lock (self);
+ max = vaMaxNumImageFormats (dpy);
+ gst_va_display_unlock (self);
+ if (max == 0)
+ return NULL;
+
+ va_formats = g_new (VAImageFormat, max);
+
+ gst_va_display_lock (self);
+ status = vaQueryImageFormats (dpy, va_formats, &num);
+ gst_va_display_unlock (self);
+
+ gst_va_video_format_fix_map (va_formats, num);
+
+ if (status != VA_STATUS_SUCCESS) {
+ GST_ERROR ("vaQueryImageFormats: %s", vaErrorStr (status));
+ goto bail;
+ }
+
+ ret = g_array_sized_new (FALSE, FALSE, sizeof (GstVideoFormat), num);
+ for (i = 0; i < num; i++) {
+ format = gst_va_video_format_from_va_image_format (&va_formats[i]);
+ if (format != GST_VIDEO_FORMAT_UNKNOWN)
+ g_array_append_val (ret, format);
+ }
+
+ if (ret->len == 0) {
+ g_array_unref (ret);
+ ret = NULL;
+ }
+
+bail:
+ g_free (va_formats);
+ return ret;
+}
diff --git a/sys/va/gstvadisplay_wrapped.h b/sys/va/gstvadisplay_priv.h
index 752ecb503..86e5a6d51 100644
--- a/sys/va/gstvadisplay_wrapped.h
+++ b/sys/va/gstvadisplay_priv.h
@@ -20,14 +20,13 @@
#pragma once
-#include "gstvadisplay.h"
+#include <gst/va/gstvadisplay.h>
+#include <va/va.h>
G_BEGIN_DECLS
-
-#define GST_TYPE_VA_DISPLAY_WRAPPED gst_va_display_wrapped_get_type()
-G_DECLARE_FINAL_TYPE (GstVaDisplayWrapped, gst_va_display_wrapped, GST,
- VA_DISPLAY_WRAPPED, GstVaDisplay)
-
-GstVaDisplay * gst_va_display_wrapped_new (guintptr handle);
+GArray * gst_va_display_get_profiles (GstVaDisplay * self,
+ guint32 codec,
+ VAEntrypoint entrypoint);
+GArray * gst_va_display_get_image_formats (GstVaDisplay * self);
G_END_DECLS
diff --git a/sys/va/gstvafilter.c b/sys/va/gstvafilter.c
index afd1f5846..35e946a16 100644
--- a/sys/va/gstvafilter.c
+++ b/sys/va/gstvafilter.c
@@ -30,6 +30,7 @@
#include "gstvaallocator.h"
#include "gstvacaps.h"
+#include "gstvadisplay_priv.h"
#include "gstvavideoformat.h"
struct _GstVaFilter
diff --git a/sys/va/gstvafilter.h b/sys/va/gstvafilter.h
index 896694b74..d6dbfb3d4 100644
--- a/sys/va/gstvafilter.h
+++ b/sys/va/gstvafilter.h
@@ -20,10 +20,10 @@
#pragma once
-#include "gstvadisplay.h"
-
+#include <gst/va/gstvadisplay.h>
#include <gst/video/video.h>
+#include <va/va.h>
#include <va/va_vpp.h>
G_BEGIN_DECLS
diff --git a/sys/va/gstvautils.c b/sys/va/gstvautils.c
index 6014f321a..b11f50166 100644
--- a/sys/va/gstvautils.c
+++ b/sys/va/gstvautils.c
@@ -22,9 +22,9 @@
#include "config.h"
#endif
-#include "gstvadisplay_drm.h"
-#include "gstvadisplay_wrapped.h"
#include "gstvautils.h"
+#include <gst/va/gstvadisplay_drm.h>
+#include <gst/va/gstvadisplay_wrapped.h>
GST_DEBUG_CATEGORY_STATIC (GST_CAT_CONTEXT);
@@ -164,7 +164,7 @@ gst_va_element_propagate_display_context (GstElement * element,
_init_context_debug ();
- ctxt = gst_context_new ("gst.va.display.handle", TRUE);
+ ctxt = gst_context_new (GST_VA_DISPLAY_HANDLE_CONTEXT_TYPE_STR, TRUE);
gst_context_set_va_display (ctxt, display);
GST_CAT_INFO_OBJECT (GST_CAT_CONTEXT, element,
@@ -189,7 +189,7 @@ gst_va_ensure_element_data (gpointer element, const gchar * render_device_path,
if (gst_va_display_found (element, g_atomic_pointer_get (display_ptr)))
goto done;
- _gst_context_query (element, "gst.va.display.handle");
+ _gst_context_query (element, GST_VA_DISPLAY_HANDLE_CONTEXT_TYPE_STR);
/* Neighbour found and it updated the display */
if (gst_va_display_found (element, g_atomic_pointer_get (display_ptr)))
@@ -222,7 +222,7 @@ gst_va_handle_set_context (GstElement * element, GstContext * context,
context_type = gst_context_get_context_type (context);
- if (g_strcmp0 (context_type, "gst.va.display.handle") == 0) {
+ if (g_strcmp0 (context_type, GST_VA_DISPLAY_HANDLE_CONTEXT_TYPE_STR) == 0) {
type_name = G_OBJECT_TYPE_NAME (element);
if (!gst_context_get_va_display (context, type_name, render_device_path,
&display_replacement)) {
@@ -258,7 +258,8 @@ gst_va_handle_context_query (GstElement * element, GstQuery * query,
"handle context query %" GST_PTR_FORMAT, query);
gst_query_parse_context_type (query, &context_type);
- if (!display || g_strcmp0 (context_type, "gst.va.display.handle") != 0)
+ if (!display
+ || g_strcmp0 (context_type, GST_VA_DISPLAY_HANDLE_CONTEXT_TYPE_STR) != 0)
return FALSE;
gst_query_parse_context (query, &old_ctxt);
@@ -266,7 +267,7 @@ gst_va_handle_context_query (GstElement * element, GstQuery * query,
if (old_ctxt)
ctxt = gst_context_copy (old_ctxt);
else
- ctxt = gst_context_new ("gst.va.display.handle", TRUE);
+ ctxt = gst_context_new (GST_VA_DISPLAY_HANDLE_CONTEXT_TYPE_STR, TRUE);
gst_context_set_va_display (ctxt, display);
gst_query_set_context (query, ctxt);
diff --git a/sys/va/gstvautils.h b/sys/va/gstvautils.h
index 44ef7a9ad..3bca0b82f 100644
--- a/sys/va/gstvautils.h
+++ b/sys/va/gstvautils.h
@@ -20,7 +20,7 @@
#pragma once
-#include "gstvadisplay.h"
+#include <gst/va/gstvadisplay.h>
G_BEGIN_DECLS
diff --git a/sys/va/gstvavpp.c b/sys/va/gstvavpp.c
index a7ce71b04..70642c513 100644
--- a/sys/va/gstvavpp.c
+++ b/sys/va/gstvavpp.c
@@ -77,7 +77,7 @@
#include "gstvaallocator.h"
#include "gstvacaps.h"
-#include "gstvadisplay_drm.h"
+#include "gstvadisplay_priv.h"
#include "gstvafilter.h"
#include "gstvapool.h"
#include "gstvautils.h"
diff --git a/sys/va/meson.build b/sys/va/meson.build
index 803b7e2df..55b664beb 100644
--- a/sys/va/meson.build
+++ b/sys/va/meson.build
@@ -4,10 +4,8 @@ va_sources = [
'gstvabasedec.c',
'gstvacaps.c',
'gstvadecoder.c',
- 'gstvadisplay.c',
- 'gstvadisplay_drm.c',
- 'gstvadisplay_wrapped.c',
'gstvadevice.c',
+ 'gstvadisplay_priv.c',
'gstvafilter.c',
'gstvah264dec.c',
'gstvah265dec.c',
@@ -21,19 +19,17 @@ va_sources = [
'gstvavpp.c'
]
-have_va = false
va_option = get_option('va')
if va_option.disabled() or host_system != 'linux'
subdir_done()
endif
-libva_req = ['>= 1.6']
-
-libva_dep = dependency('libva', version: libva_req, required: va_option)
-libva_drm_dep = dependency('libva-drm', version: libva_req, required: va_option)
-libgudev_dep = dependency('gudev-1.0', required: va_option)
-libdrm_dep = dependency('libdrm', required: false,
- fallback: ['libdrm', 'ext_libdrm'])
+if not gstva_dep.found()
+ if va_option.enabled()
+ error('The va plugin was enabled explicity, but required dependencies were not found.')
+ endif
+ subdir_done()
+endif
libva_av1_req = ['>= 1.8']
libva_av1_dep = dependency('libva', version: libva_av1_req, required: va_option)
@@ -41,14 +37,6 @@ if libva_av1_dep.found()
va_sources += 'gstvaav1dec.c'
endif
-have_va = libva_dep.found() and libva_drm_dep.found()
-if not (have_va and libgudev_dep.found())
- if va_option.enabled()
- error('The va plugin was enabled explicity, but required dependencies were not found.')
- endif
- subdir_done()
-endif
-
cdata.set10('HAVE_LIBDRM', libdrm_dep.found())
driverdir = libva_dep.get_pkgconfig_variable('driverdir')
@@ -61,7 +49,7 @@ gstva = library('gstva',
va_sources,
c_args : gst_plugins_bad_args + extra_c_args + gstva_cargs + ['-std=c99'],
include_directories : [configinc],
- dependencies : [gstbase_dep, gstvideo_dep, gstcodecs_dep, libva_dep, gstallocators_dep, libva_drm_dep, libgudev_dep, libdrm_dep] + extra_dep,
+ dependencies : [libva_dep, gstvideo_dep, gstcodecs_dep, gstallocators_dep, gstva_dep] + extra_dep,
install : true,
install_dir : plugins_install_dir,
)