From 990fbb3b526c8b4ce7bf48722a7124fd07b428e7 Mon Sep 17 00:00:00 2001 From: He Junyan Date: Wed, 23 Feb 2022 15:40:19 +0800 Subject: [PATCH] va: Move allocators and pool objects into gstva library. In order to other plugins use gstva objects, such as allocators and buffer pools, this merge request move them from the va plugin to the gstva library. This objects are not exposed in since they are not expected to be used by users, only by plugin implementators. Because of the surface copy design, which is used to implement allocator's mem_copy() virtual function, depends on the vafilter, which is kept inside the plugin, memory copy through VAPosproc is disabled and removed temporarly. Also added some missing parameter validation. Part-of: --- .../{sys => gst-libs/gst}/va/gstvaallocator.c | 57 +++++++++++++++---- .../{sys => gst-libs/gst}/va/gstvaallocator.h | 42 ++++++++++++-- .../{sys => gst-libs/gst}/va/gstvapool.c | 10 +++- .../{sys => gst-libs/gst}/va/gstvapool.h | 32 ++++++++--- .../gst}/va/gstvasurfacecopy.c | 45 ++------------- .../gst}/va/gstvasurfacecopy.h | 0 .../gst-libs/gst/va/meson.build | 10 +++- .../{sys => gst-libs/gst}/va/vasurfaceimage.c | 7 ++- .../{sys => gst-libs/gst}/va/vasurfaceimage.h | 0 .../gst-plugins-bad/sys/va/gstvaav1dec.c | 4 +- .../gst-plugins-bad/sys/va/gstvabasedec.c | 4 +- .../sys/va/gstvabasetransform.c | 5 +- .../gst-plugins-bad/sys/va/gstvadecoder.c | 2 +- .../gst-plugins-bad/sys/va/gstvadeinterlace.c | 5 +- .../gst-plugins-bad/sys/va/gstvaencoder.c | 9 +-- .../gst-plugins-bad/sys/va/gstvafilter.c | 25 ++++++-- .../gst-plugins-bad/sys/va/gstvah264enc.c | 12 ++-- subprojects/gst-plugins-bad/sys/va/gstvavpp.c | 5 +- .../gst-plugins-bad/sys/va/meson.build | 11 ++-- 19 files changed, 181 insertions(+), 104 deletions(-) rename subprojects/gst-plugins-bad/{sys => gst-libs/gst}/va/gstvaallocator.c (97%) rename subprojects/gst-plugins-bad/{sys => gst-libs/gst}/va/gstvaallocator.h (70%) rename subprojects/gst-plugins-bad/{sys => gst-libs/gst}/va/gstvapool.c (98%) rename subprojects/gst-plugins-bad/{sys => gst-libs/gst}/va/gstvapool.h (51%) rename subprojects/gst-plugins-bad/{sys => gst-libs/gst}/va/gstvasurfacecopy.c (75%) rename subprojects/gst-plugins-bad/{sys => gst-libs/gst}/va/gstvasurfacecopy.h (100%) rename subprojects/gst-plugins-bad/{sys => gst-libs/gst}/va/vasurfaceimage.c (99%) rename subprojects/gst-plugins-bad/{sys => gst-libs/gst}/va/vasurfaceimage.h (100%) diff --git a/subprojects/gst-plugins-bad/sys/va/gstvaallocator.c b/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.c similarity index 97% rename from subprojects/gst-plugins-bad/sys/va/gstvaallocator.c rename to subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.c index 337e3b9881..c439a64655 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvaallocator.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.c @@ -24,12 +24,11 @@ #include "gstvaallocator.h" -#include #include #include -#include "gstvacaps.h" #include "gstvasurfacecopy.h" +#include "gstvavideoformat.h" #include "vasurfaceimage.h" #define GST_CAT_DEFAULT gst_va_memory_debug @@ -254,6 +253,11 @@ struct _GstVaDmabufAllocator GstVaMemoryPool pool; }; +struct _GstVaDmabufAllocatorClass +{ + GstDmaBufAllocatorClass parent_class; +}; + #define gst_va_dmabuf_allocator_parent_class dmabuf_parent_class G_DEFINE_TYPE_WITH_CODE (GstVaDmabufAllocator, gst_va_dmabuf_allocator, GST_TYPE_DMABUF_ALLOCATOR, _init_debug_category ()); @@ -735,9 +739,13 @@ gboolean gst_va_dmabuf_allocator_prepare_buffer (GstAllocator * allocator, GstBuffer * buffer) { - GstVaDmabufAllocator *self = GST_VA_DMABUF_ALLOCATOR (allocator); + GstVaDmabufAllocator *self; VASurfaceID surface; + g_return_val_if_fail (GST_IS_VA_DMABUF_ALLOCATOR (allocator), FALSE); + + self = GST_VA_DMABUF_ALLOCATOR (allocator); + GST_VA_MEMORY_POOL_LOCK (&self->pool); surface = gst_va_dmabuf_allocator_prepare_buffer_unlocked (self, buffer); GST_VA_MEMORY_POOL_UNLOCK (&self->pool); @@ -748,7 +756,11 @@ gst_va_dmabuf_allocator_prepare_buffer (GstAllocator * allocator, void gst_va_dmabuf_allocator_flush (GstAllocator * allocator) { - GstVaDmabufAllocator *self = GST_VA_DMABUF_ALLOCATOR (allocator); + GstVaDmabufAllocator *self; + + g_return_if_fail (GST_IS_VA_DMABUF_ALLOCATOR (allocator)); + + self = GST_VA_DMABUF_ALLOCATOR (allocator); gst_va_memory_pool_flush (&self->pool, self->display); } @@ -757,10 +769,15 @@ static gboolean gst_va_dmabuf_allocator_try (GstAllocator * allocator) { GstBuffer *buffer; - GstVaDmabufAllocator *self = GST_VA_DMABUF_ALLOCATOR (allocator); - GstVideoInfo info = self->info; + GstVaDmabufAllocator *self; + GstVideoInfo info; gboolean ret; + g_return_val_if_fail (GST_IS_VA_DMABUF_ALLOCATOR (allocator), FALSE); + + self = GST_VA_DMABUF_ALLOCATOR (allocator); + info = self->info; + buffer = gst_buffer_new (); ret = gst_va_dmabuf_allocator_setup_buffer_full (allocator, buffer, &info); gst_buffer_unref (buffer); @@ -920,6 +937,11 @@ struct _GstVaAllocator GstVaMemoryPool pool; }; +struct _GstVaAllocatorClass +{ + GstAllocatorClass parent_class; +}; + typedef struct _GstVaMemory GstVaMemory; struct _GstVaMemory { @@ -1452,9 +1474,13 @@ gst_va_allocator_prepare_buffer_unlocked (GstVaAllocator * self, gboolean gst_va_allocator_prepare_buffer (GstAllocator * allocator, GstBuffer * buffer) { - GstVaAllocator *self = GST_VA_ALLOCATOR (allocator); + GstVaAllocator *self; VASurfaceID surface; + g_return_val_if_fail (GST_IS_VA_ALLOCATOR (allocator), FALSE); + + self = GST_VA_ALLOCATOR (allocator); + GST_VA_MEMORY_POOL_LOCK (&self->pool); surface = gst_va_allocator_prepare_buffer_unlocked (self, buffer); GST_VA_MEMORY_POOL_UNLOCK (&self->pool); @@ -1465,7 +1491,11 @@ gst_va_allocator_prepare_buffer (GstAllocator * allocator, GstBuffer * buffer) void gst_va_allocator_flush (GstAllocator * allocator) { - GstVaAllocator *self = GST_VA_ALLOCATOR (allocator); + GstVaAllocator *self; + + g_return_if_fail (GST_IS_VA_ALLOCATOR (allocator)); + + self = GST_VA_ALLOCATOR (allocator); gst_va_memory_pool_flush (&self->pool, self->display); } @@ -1473,7 +1503,11 @@ gst_va_allocator_flush (GstAllocator * allocator) static gboolean gst_va_allocator_try (GstAllocator * allocator) { - GstVaAllocator *self = GST_VA_ALLOCATOR (allocator); + GstVaAllocator *self; + + g_return_val_if_fail (GST_IS_VA_ALLOCATOR (allocator), FALSE); + + self = GST_VA_ALLOCATOR (allocator); self->fourcc = 0; self->rt_format = 0; @@ -1553,7 +1587,10 @@ gboolean gst_va_allocator_get_format (GstAllocator * allocator, GstVideoInfo * info, guint * usage_hint) { - GstVaAllocator *self = GST_VA_ALLOCATOR (allocator); + GstVaAllocator *self; + + g_return_val_if_fail (GST_IS_VA_ALLOCATOR (allocator), FALSE); + self = GST_VA_ALLOCATOR (allocator); if (GST_VIDEO_INFO_FORMAT (&self->info) == GST_VIDEO_FORMAT_UNKNOWN) return FALSE; diff --git a/subprojects/gst-plugins-bad/sys/va/gstvaallocator.h b/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.h similarity index 70% rename from subprojects/gst-plugins-bad/sys/va/gstvaallocator.h rename to subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.h index 3475859b3c..a61b7c6a08 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvaallocator.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.h @@ -28,23 +28,40 @@ G_BEGIN_DECLS -#define GST_TYPE_VA_DMABUF_ALLOCATOR (gst_va_dmabuf_allocator_get_type()) -G_DECLARE_FINAL_TYPE (GstVaDmabufAllocator, gst_va_dmabuf_allocator, GST, - VA_DMABUF_ALLOCATOR, GstDmaBufAllocator); +typedef struct _GstVaAllocator GstVaAllocator; +typedef struct _GstVaAllocatorClass GstVaAllocatorClass; +typedef struct _GstVaDmabufAllocator GstVaDmabufAllocator; +typedef struct _GstVaDmabufAllocatorClass GstVaDmabufAllocatorClass; +#define GST_TYPE_VA_DMABUF_ALLOCATOR (gst_va_dmabuf_allocator_get_type()) +#define GST_VA_DMABUF_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_VA_DMABUF_ALLOCATOR, GstVaDmabufAllocator)) +#define GST_VA_DMABUF_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_VA_DMABUF_ALLOCATOR, GstVaDmabufAllocatorClass)) +#define GST_IS_VA_DMABUF_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_VA_DMABUF_ALLOCATOR)) +#define GST_IS_VA_DMABUF_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_VA_DMABUF_ALLOCATOR)) +#define GST_VA_DMABUF_ALLOCATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_VA_DMABUF_ALLOCATOR, GstVaDmabufAllocatorClass)) + +GST_VA_API +GType gst_va_dmabuf_allocator_get_type (void); +GST_VA_API GstAllocator * gst_va_dmabuf_allocator_new (GstVaDisplay * display); +GST_VA_API gboolean gst_va_dmabuf_allocator_setup_buffer (GstAllocator * allocator, GstBuffer * buffer); +GST_VA_API gboolean gst_va_dmabuf_allocator_prepare_buffer (GstAllocator * allocator, GstBuffer * buffer); +GST_VA_API void gst_va_dmabuf_allocator_flush (GstAllocator * allocator); +GST_VA_API gboolean gst_va_dmabuf_allocator_set_format (GstAllocator * allocator, GstVideoInfo * info, guint usage_hint); +GST_VA_API gboolean gst_va_dmabuf_allocator_get_format (GstAllocator * allocator, GstVideoInfo * info, guint * usage_hint); +GST_VA_API gboolean gst_va_dmabuf_memories_setup (GstVaDisplay * display, GstVideoInfo * info, guint n_planes, @@ -54,31 +71,48 @@ gboolean gst_va_dmabuf_memories_setup (GstVaDisplay * displa guint usage_hint); #define GST_TYPE_VA_ALLOCATOR (gst_va_allocator_get_type()) -G_DECLARE_FINAL_TYPE (GstVaAllocator, gst_va_allocator, GST, VA_ALLOCATOR, GstAllocator); +#define GST_VA_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_VA_ALLOCATOR, GstVaAllocator)) +#define GST_VA_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_VA_ALLOCATOR, GstVaAllocatorClass)) +#define GST_IS_VA_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_VA_ALLOCATOR)) +#define GST_IS_VA_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_VA_ALLOCATOR)) +#define GST_VA_ALLOCATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_VA_ALLOCATOR, GstVaAllocatorClass)) #define GST_ALLOCATOR_VASURFACE "VAMemory" #define GST_MAP_VA (GST_MAP_FLAG_LAST << 1) +GST_VA_API +GType gst_va_allocator_get_type (void); +GST_VA_API GstAllocator * gst_va_allocator_new (GstVaDisplay * display, GArray * surface_formats); +GST_VA_API GstMemory * gst_va_allocator_alloc (GstAllocator * allocator); +GST_VA_API gboolean gst_va_allocator_setup_buffer (GstAllocator * allocator, GstBuffer * buffer); +GST_VA_API gboolean gst_va_allocator_prepare_buffer (GstAllocator * allocator, GstBuffer * buffer); +GST_VA_API void gst_va_allocator_flush (GstAllocator * allocator); +GST_VA_API gboolean gst_va_allocator_set_format (GstAllocator * allocator, GstVideoInfo * info, guint usage_hint); +GST_VA_API gboolean gst_va_allocator_get_format (GstAllocator * allocator, GstVideoInfo * info, guint * usage_hint); +GST_VA_API VASurfaceID gst_va_memory_get_surface (GstMemory * mem); +GST_VA_API VASurfaceID gst_va_buffer_get_surface (GstBuffer * buffer); +GST_VA_API gboolean gst_va_buffer_create_aux_surface (GstBuffer * buffer); +GST_VA_API VASurfaceID gst_va_buffer_get_aux_surface (GstBuffer * buffer); G_END_DECLS diff --git a/subprojects/gst-plugins-bad/sys/va/gstvapool.c b/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvapool.c similarity index 98% rename from subprojects/gst-plugins-bad/sys/va/gstvapool.c rename to subprojects/gst-plugins-bad/gst-libs/gst/va/gstvapool.c index 42bfbfc7e0..fda830e383 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvapool.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvapool.c @@ -23,9 +23,7 @@ #endif #include "gstvapool.h" - #include "gstvaallocator.h" -#include "gstvacaps.h" GST_DEBUG_CATEGORY_STATIC (gst_va_pool_debug); #define GST_CAT_DEFAULT gst_va_pool_debug @@ -45,6 +43,11 @@ struct _GstVaPool gboolean starting; }; +struct _GstVaPoolClass +{ + GstBufferPoolClass parent_class; +}; + #define gst_va_pool_parent_class parent_class G_DEFINE_TYPE_WITH_CODE (GstVaPool, gst_va_pool, GST_TYPE_BUFFER_POOL, GST_DEBUG_CATEGORY_INIT (gst_va_pool_debug, "vapool", 0, "VA Pool")); @@ -341,6 +344,9 @@ gst_buffer_pool_config_set_va_allocation_params (GstStructure * config, gboolean gst_va_pool_requires_video_meta (GstBufferPool * pool) { + + g_return_val_if_fail (GST_IS_VA_POOL (pool), FALSE); + return GST_VA_POOL (pool)->force_videometa; } diff --git a/subprojects/gst-plugins-bad/sys/va/gstvapool.h b/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvapool.h similarity index 51% rename from subprojects/gst-plugins-bad/sys/va/gstvapool.h rename to subprojects/gst-plugins-bad/gst-libs/gst/va/gstvapool.h index 080168ab49..d38a6a08e9 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvapool.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvapool.h @@ -20,24 +20,38 @@ #pragma once +#include +#include #include G_BEGIN_DECLS +typedef struct _GstVaPool GstVaPool; +typedef struct _GstVaPoolClass GstVaPoolClass; + #define GST_TYPE_VA_POOL (gst_va_pool_get_type()) -G_DECLARE_FINAL_TYPE (GstVaPool, gst_va_pool, GST, VA_POOL, GstBufferPool) +#define GST_VA_POOL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_VA_POOL, GstVaPool)) +#define GST_VA_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_VA_POOL, GstVaPoolClass)) +#define GST_IS_VA_POOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_VA_POOL)) +#define GST_IS_VA_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_VA_POOL)) +#define GST_VA_POOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_VA_POOL, GstVaPoolClass)) +GST_VA_API +GType gst_va_pool_get_type (void); +GST_VA_API GstBufferPool * gst_va_pool_new (void); +GST_VA_API gboolean gst_va_pool_requires_video_meta (GstBufferPool * pool); +GST_VA_API void gst_buffer_pool_config_set_va_allocation_params (GstStructure * config, - guint usage_hint); - + guint usage_hint); +GST_VA_API GstBufferPool * gst_va_pool_new_with_config (GstCaps * caps, - guint size, - guint min_buffers, - guint max_buffers, - guint usage_hint, - GstAllocator * allocator, - GstAllocationParams * alloc_params); + guint size, + guint min_buffers, + guint max_buffers, + guint usage_hint, + GstAllocator * allocator, + GstAllocationParams * alloc_params); G_END_DECLS diff --git a/subprojects/gst-plugins-bad/sys/va/gstvasurfacecopy.c b/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvasurfacecopy.c similarity index 75% rename from subprojects/gst-plugins-bad/sys/va/gstvasurfacecopy.c rename to subprojects/gst-plugins-bad/gst-libs/gst/va/gstvasurfacecopy.c index 9b897c9b9b..038a1080f7 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvasurfacecopy.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvasurfacecopy.c @@ -18,11 +18,11 @@ * Boston, MA 02110-1301, USA. */ -#include "gstvasurfacecopy.h" +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif -#include "gstvaallocator.h" -#include "gstvadisplay_priv.h" -#include "gstvafilter.h" +#include "gstvasurfacecopy.h" #include "vasurfaceimage.h" #define GST_CAT_DEFAULT gst_va_memory_debug @@ -36,7 +36,6 @@ struct _GstVaSurfaceCopy gboolean has_copy; GRecMutex lock; - GstVaFilter *filter; }; static gboolean @@ -76,16 +75,8 @@ gst_va_surface_copy_new (GstVaDisplay * display, GstVideoInfo * vinfo) self->display = gst_object_ref (display); self->has_copy = _has_copy (display); self->info = *vinfo; - self->filter = NULL; g_rec_mutex_init (&self->lock); - if (gst_va_display_has_vpp (display)) { - self->filter = gst_va_filter_new (display); - if (!(gst_va_filter_open (self->filter) - && gst_va_filter_set_video_info (self->filter, vinfo, vinfo))) - gst_clear_object (&self->filter); - } - return self; } @@ -95,35 +86,12 @@ gst_va_surface_copy_free (GstVaSurfaceCopy * self) g_return_if_fail (self && GST_IS_VA_DISPLAY (self->display)); gst_clear_object (&self->display); - if (self->filter) { - gst_va_filter_close (self->filter); - gst_clear_object (&self->filter); - } g_rec_mutex_clear (&self->lock); g_slice_free (GstVaSurfaceCopy, self); } -static gboolean -_vpp_copy_surface (GstVaSurfaceCopy * self, VASurfaceID dst, VASurfaceID src) -{ - gboolean ret; - - GstVaSample gst_src = { - .surface = src, - }; - GstVaSample gst_dst = { - .surface = dst, - }; - - g_rec_mutex_lock (&self->lock); - ret = gst_va_filter_process (self->filter, &gst_src, &gst_dst); - g_rec_mutex_unlock (&self->lock); - - return ret; -} - gboolean gst_va_surface_copy (GstVaSurfaceCopy * self, VASurfaceID dst, VASurfaceID src) { @@ -137,10 +105,7 @@ gst_va_surface_copy (GstVaSurfaceCopy * self, VASurfaceID dst, VASurfaceID src) return TRUE; } - if (self->filter && _vpp_copy_surface (self, dst, src)) { - GST_LOG ("VPP copy of %#x to %#x", src, dst); - return TRUE; - } + /* TODO: Add the VPP copy. */ if (!va_ensure_image (self->display, src, &self->info, &image, FALSE)) return FALSE; diff --git a/subprojects/gst-plugins-bad/sys/va/gstvasurfacecopy.h b/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvasurfacecopy.h similarity index 100% rename from subprojects/gst-plugins-bad/sys/va/gstvasurfacecopy.h rename to subprojects/gst-plugins-bad/gst-libs/gst/va/gstvasurfacecopy.h diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/va/meson.build b/subprojects/gst-plugins-bad/gst-libs/gst/va/meson.build index bb2ad0f4fd..8d5ee3a4cb 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/va/meson.build +++ b/subprojects/gst-plugins-bad/gst-libs/gst/va/meson.build @@ -1,20 +1,26 @@ va_sources = [ + 'gstvaallocator.c', 'gstvadisplay.c', 'gstvadisplay_drm.c', 'gstvadisplay_wrapped.c', + 'gstvapool.c', + 'gstvasurfacecopy.c', 'gstvautils.c', 'gstvavideoformat.c', + 'vasurfaceimage.c', ] va_headers = [ 'gstva.h', + 'gstvaallocator.h', 'gstvadisplay.h', 'gstvadisplay_drm.h', 'gstvadisplay_wrapped.h', + 'gstvapool.h', 'gstvautils.h', 'gstvavideoformat.h', - 'va_fwd.h', 'va-prelude.h', + 'va_fwd.h', ] gstva_dep = dependency('', required : false) @@ -51,5 +57,5 @@ libraries += [[pkg_name, {'lib': gstva}]] gstva_dep = declare_dependency(link_with : gstva, include_directories : [libsinc], - dependencies : [gst_dep, gstvideo_dep, libva_dep, libva_drm_dep, libdrm_dep]) + dependencies : [gst_dep, gstvideo_dep, gstallocators_dep, libva_dep, libva_drm_dep, libdrm_dep]) meson.override_dependency(pkg_name, gstva_dep) diff --git a/subprojects/gst-plugins-bad/sys/va/vasurfaceimage.c b/subprojects/gst-plugins-bad/gst-libs/gst/va/vasurfaceimage.c similarity index 99% rename from subprojects/gst-plugins-bad/sys/va/vasurfaceimage.c rename to subprojects/gst-plugins-bad/gst-libs/gst/va/vasurfaceimage.c index 695c5c4754..6baec64a4e 100644 --- a/subprojects/gst-plugins-bad/sys/va/vasurfaceimage.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/va/vasurfaceimage.c @@ -18,9 +18,12 @@ * Boston, MA 02110-1301, USA. */ -#include "vasurfaceimage.h" +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif -#include +#include "vasurfaceimage.h" +#include "gstvavideoformat.h" #include gboolean diff --git a/subprojects/gst-plugins-bad/sys/va/vasurfaceimage.h b/subprojects/gst-plugins-bad/gst-libs/gst/va/vasurfaceimage.h similarity index 100% rename from subprojects/gst-plugins-bad/sys/va/vasurfaceimage.h rename to subprojects/gst-plugins-bad/gst-libs/gst/va/vasurfaceimage.h diff --git a/subprojects/gst-plugins-bad/sys/va/gstvaav1dec.c b/subprojects/gst-plugins-bad/sys/va/gstvaav1dec.c index 429a8d3da4..fd8300ce0c 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvaav1dec.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvaav1dec.c @@ -43,10 +43,10 @@ #include "config.h" #endif -#include +#include + #include "gstvaav1dec.h" #include "gstvabasedec.h" -#include "gstvaallocator.h" GST_DEBUG_CATEGORY_STATIC (gst_va_av1dec_debug); #ifndef GST_DISABLE_GST_DEBUG diff --git a/subprojects/gst-plugins-bad/sys/va/gstvabasedec.c b/subprojects/gst-plugins-bad/sys/va/gstvabasedec.c index d59ff7230f..f00ebf41af 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvabasedec.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvabasedec.c @@ -20,11 +20,11 @@ #include "gstvabasedec.h" +#include +#include #include -#include "gstvaallocator.h" #include "gstvacaps.h" -#include "gstvapool.h" #define GST_CAT_DEFAULT (base->debug_category) #define GST_VA_BASE_DEC_GET_PARENT_CLASS(obj) (GST_VA_BASE_DEC_GET_CLASS(obj)->parent_decoder_class) diff --git a/subprojects/gst-plugins-bad/sys/va/gstvabasetransform.c b/subprojects/gst-plugins-bad/sys/va/gstvabasetransform.c index 36a3fefdc7..98435ec448 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvabasetransform.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvabasetransform.c @@ -24,9 +24,10 @@ #include "gstvabasetransform.h" -#include "gstvaallocator.h" +#include +#include + #include "gstvacaps.h" -#include "gstvapool.h" #define GST_CAT_DEFAULT gst_va_base_transform_debug GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT); diff --git a/subprojects/gst-plugins-bad/sys/va/gstvadecoder.c b/subprojects/gst-plugins-bad/sys/va/gstvadecoder.c index 9330b9d491..50f7e4c64b 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvadecoder.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvadecoder.c @@ -24,9 +24,9 @@ #include "gstvadecoder.h" +#include #include -#include "gstvaallocator.h" #include "gstvacaps.h" #include "gstvadisplay_priv.h" #include "gstvaprofile.h" diff --git a/subprojects/gst-plugins-bad/sys/va/gstvadeinterlace.c b/subprojects/gst-plugins-bad/sys/va/gstvadeinterlace.c index 8cb50a5793..ff2aad60c1 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvadeinterlace.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvadeinterlace.c @@ -51,16 +51,15 @@ #include "gstvadeinterlace.h" +#include +#include #include - #include -#include "gstvaallocator.h" #include "gstvabasetransform.h" #include "gstvacaps.h" #include "gstvadisplay_priv.h" #include "gstvafilter.h" -#include "gstvapool.h" GST_DEBUG_CATEGORY_STATIC (gst_va_deinterlace_debug); #define GST_CAT_DEFAULT gst_va_deinterlace_debug diff --git a/subprojects/gst-plugins-bad/sys/va/gstvaencoder.c b/subprojects/gst-plugins-bad/sys/va/gstvaencoder.c index f35b346506..55a77540d1 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvaencoder.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvaencoder.c @@ -25,13 +25,14 @@ #include "gstvaencoder.h" +#include +#include +#include +#include + #include "vacompat.h" -#include "gstvaallocator.h" -#include "gstvapool.h" #include "gstvacaps.h" #include "gstvadisplay_priv.h" -#include "gstvavideoformat.h" -#include #define VA_ENTRYPOINT_FLAG(entry) (1U << G_PASTE(VAEntrypoint, entry)) diff --git a/subprojects/gst-plugins-bad/sys/va/gstvafilter.c b/subprojects/gst-plugins-bad/sys/va/gstvafilter.c index dc5c13e5e1..5979fd13cb 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvafilter.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvafilter.c @@ -24,15 +24,13 @@ #include "gstvafilter.h" -#include +#include #include - +#include #include -#include "gstvaallocator.h" #include "gstvacaps.h" #include "gstvadisplay_priv.h" -#include "vasurfaceimage.h" struct _GstVaFilter { @@ -1521,6 +1519,23 @@ gst_va_filter_drop_filter_buffers (GstVaFilter * self) return ret; } +static gboolean +_check_surface (GstVaDisplay * display, VASurfaceID surface) +{ + VADisplay dpy = gst_va_display_get_va_dpy (display); + VAStatus status; + VASurfaceStatus state; + + status = vaQuerySurfaceStatus (dpy, surface, &state); + + if (status != VA_STATUS_SUCCESS) + GST_ERROR ("vaQuerySurfaceStatus: %s", vaErrorStr (status)); + + GST_LOG ("surface %#x status %d", surface, state); + + return (status == VA_STATUS_SUCCESS); +} + static gboolean _fill_va_sample (GstVaFilter * self, GstVaSample * sample, GstPadDirection direction) @@ -1535,7 +1550,7 @@ _fill_va_sample (GstVaFilter * self, GstVaSample * sample, /* @FIXME: in gallium vaQuerySurfaceStatus only seems to work with * encoder's surfaces */ if (!GST_VA_DISPLAY_IS_IMPLEMENTATION (self->display, MESA_GALLIUM)) { - if (!va_check_surface (self->display, sample->surface)) + if (!_check_surface (self->display, sample->surface)) return FALSE; } diff --git a/subprojects/gst-plugins-bad/sys/va/gstvah264enc.c b/subprojects/gst-plugins-bad/sys/va/gstvah264enc.c index b8ef38ff1d..124ba0f70e 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvah264enc.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvah264enc.c @@ -50,22 +50,22 @@ #include "config.h" #endif -#include -#include +#include "gstvah264enc.h" #include +#include +#include #include +#include +#include +#include #include "vacompat.h" -#include "gstvah264enc.h" #include "gstvaencoder.h" -#include "gstvavideoformat.h" -#include "gstvaallocator.h" #include "gstvacaps.h" #include "gstvaprofile.h" #include "gstvadisplay_priv.h" -#include "gstvapool.h" GST_DEBUG_CATEGORY_STATIC (gst_va_h264enc_debug); #ifndef GST_DISABLE_GST_DEBUG diff --git a/subprojects/gst-plugins-bad/sys/va/gstvavpp.c b/subprojects/gst-plugins-bad/sys/va/gstvavpp.c index f08f0c29f1..9ec189afac 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvavpp.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvavpp.c @@ -63,15 +63,14 @@ #include "gstvavpp.h" #include - +#include +#include #include -#include "gstvaallocator.h" #include "gstvabasetransform.h" #include "gstvacaps.h" #include "gstvadisplay_priv.h" #include "gstvafilter.h" -#include "gstvapool.h" GST_DEBUG_CATEGORY_STATIC (gst_va_vpp_debug); #define GST_CAT_DEFAULT gst_va_vpp_debug diff --git a/subprojects/gst-plugins-bad/sys/va/meson.build b/subprojects/gst-plugins-bad/sys/va/meson.build index 83cba95aae..4b65b94777 100644 --- a/subprojects/gst-plugins-bad/sys/va/meson.build +++ b/subprojects/gst-plugins-bad/sys/va/meson.build @@ -1,6 +1,5 @@ va_sources = [ 'plugin.c', - 'gstvaallocator.c', 'gstvabasedec.c', 'gstvabasetransform.c', 'gstvacaps.c', @@ -9,18 +8,16 @@ va_sources = [ 'gstvaencoder.c', 'gstvadevice.c', 'gstvadisplay_priv.c', + 'gstvaencoder.c', 'gstvafilter.c', 'gstvah264dec.c', + 'gstvah264enc.c', 'gstvah265dec.c', - 'gstvapool.c', + 'gstvampeg2dec.c', 'gstvaprofile.c', - 'gstvasurfacecopy.c', 'gstvavp8dec.c', 'gstvavp9dec.c', - 'gstvampeg2dec.c', 'gstvavpp.c', - 'gstvah264enc.c', - 'vasurfaceimage.c' ] if host_system != 'linux' @@ -53,7 +50,7 @@ gstva = library('gstva', va_sources, c_args : gst_plugins_bad_args + gstva_cargs, include_directories : [configinc], - dependencies : [gstvideo_dep, gstcodecs_dep, gstallocators_dep, gstva_dep, libgudev_dep] + extra_dep, + dependencies : [gstcodecs_dep, gstva_dep, libgudev_dep] + extra_dep, install : true, install_dir : plugins_install_dir, )