Commit graph

109 commits

Author SHA1 Message Date
Víctor Manuel Jáquez Leal
164656ee1d Revert "vaapivideomemory: Store surface allocation flags."
This reverts commit dd428cc4a1 because
it rewrites the buffer size whilst surface allocation flags are
stored when allocator_params_init() is called since fab890ce.

Fix: #239
2020-02-28 11:37:06 +01:00
Víctor Manuel Jáquez Leal
fab890ceb5 vaapivideomemory: Try surface with allocation flags.
When a vaapi allocator is instantiated, it first try to generate a
surface with the specified configuration.

This patch adds, in this tried buffer, the requested allocation flags.
2020-02-23 13:12:15 +01:00
Víctor Manuel Jáquez Leal
dd428cc4a1 vaapivideomemory: Store surface allocation flags.
Store surface allocation flags passed to the vaapi allocator in
GObject's qdata, because it might be used by the vaapivideobufferpool
when recreating the allocator given any resolution change.
2020-02-23 13:12:15 +01:00
He Junyan
15e169fbf1 videobufferpool: don't reset surface when created internally
The bug fixing, in commit 89f202ea, just considers the case when
surface's DMABuf is set through gst_buffer_pool_acquire_buffer(),
which is typically a decoder's behavior. But vaapipostproc doesn't
provide any surface when calling gst_buffer_pool_acquire_buffer(),
thus a surface is created when GstMemory is allocated.

If the surface proxy in buffer's meta is reset at
buffer_pool_reset_buffer(), that surface will be destroyed and it
won't be available anymore. But GstBuffers are cached in the buffer
pool and they are reused again, hence only those images are rendered
repeatedly.

Fixes: #232
2020-02-21 15:52:43 +00:00
He Junyan
608ce681e5 libs: surface: port to GstMiniObject
GstVaapiMiniObject and GstVaapiObject are deprecated.

This is the first step to remove them by porting GstVaapiSurface as
a GstMiniBuffer descendant.

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
2019-12-20 05:01:08 +00:00
He Junyan
d56824c05c libs: image: port to GstMiniObject base class
GstVaapiMiniObject and GstVaapiObject are deprecrated. This is the
first step to remove them, by porting GstVaapiImage as a
GstMiniObject.

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
2019-12-20 05:01:07 +00:00
Víctor Manuel Jáquez Leal
e48b0a90f1 vaapivideomemory: demote error message to info
The main reason to demote the message's level is because it is not an
error, it's a possible output of the trial and there's a code path
that handles it.

Secondly, it's very annoying when using gallium driver for radeon.
2019-08-15 12:58:44 +02:00
U. Artie Eoff
5f41422215 vaapivideomemory: allow negotiated info to be removed
Allow NULL negotiated_vinfo to be passed into
gst_allocator_set_vaapi_negotiated_video_info to allow
any previously set info to be removed.
2019-06-10 20:39:28 -07:00
He Junyan
ee21fd9053 vaapivideomemory: Prefer same format for surface and image
We prefer to use the same format between image and surface for gst
vaapi allocator. The old way may choose different formats between
image and surface. For example, the RGBA image may have a NV12 surface.

So we need to do format conversion when we put/get image to surface.

Some drivers such as iHD can not support such conversion and always
cause a data flow error. There may also have some performance cost
for format conversion when put/get images.

So we prefer to use the same format for image and surface in the
allocator. If the surface can not support that format, we then
fallback to find a best one as the surface format.

Co-authored-by: Víctor Jáquez <vjaquez@igalia.com>
2019-02-21 13:41:46 +01:00
Xiang, Haihao
c728fb4ff6 Close dmabuf_fd
Otherwise it will result in resource leak when failed to create
dmabuf memory
2018-11-20 16:18:58 +08:00
Víctor Manuel Jáquez Leal
5312923d1c vaapivideomemory: add gst_vaapi_dmabuf_can_map()
This new method checks the specified allocator can create GstMemory that can
be mapped.

https://bugzilla.gnome.org/show_bug.cgi?id=755072
2017-06-23 18:44:42 +02:00
Víctor Manuel Jáquez Leal
7a20692364 plugins: distinguish allocation and negotiation caps
The vaapi video decoders might have different allocation caps from
the negotiation caps, thus the GstVideoMeta shall use the negotiation
caps, not the allocation caps.

This was done before reusing gst_allocator_get_vaapi_video_info(),
storing there the negotiation caps if they differ from the allocation
ones, but this strategy felt short when the allocator had to be reset
in the vaapi buffer pool, since we need both.

This patch adds gst_allocator_set_vaapi_negotiated_video_info() and
gst_allocator_get_vaapi_negotiated_video_info() to store the
negotiated video info in the allocator, and distinguish it from
the allocation video info.

https://bugzilla.gnome.org/show_bug.cgi?id=783599
2017-06-12 18:41:14 +02:00
Víctor Manuel Jáquez Leal
36cf510ce8 vaapivideomemory: rename qdata quarks and ids
Also the parameter names were renamed to reflect their origin
and purpose.

https://bugzilla.gnome.org/show_bug.cgi?id=783599
2017-06-09 17:10:35 +02:00
Julien Isorce
6a0375d96e vaapivideomemory: export surface if it is provided
gst_vaapi_dmabuf_memory_new() always exports a surface. Previously, it
had to create that surface. Now it can also export an already provided
surface. It is useful to export decoder's surfaces (from VA context).

https://bugzilla.gnome.org/show_bug.cgi?id=755072
2017-02-02 20:33:36 +01:00
Julien Isorce
33af1fc578 vaapivideomemory: release proxy's data if downstream
The surface created for downstream is going to be filled by VAAPI
elements. So, the driver needs write access on that surface.

This patch releases the derived image held by the proxy, thus the
surface is unmarked as busy.

This is how it has to be done as discussed on libva mailing list.

https://bugzilla.gnome.org/show_bug.cgi?id=755072
2017-02-02 20:33:36 +01:00
Julien Isorce
fbed3c3366 vaapivideomemory: add direction to dmabuf allocator
Add GstPadDirection param to gst_vaapi_dmabuf_allocator_new(), thus
we later could do different thing when the allocated memory is for
upstream or dowstream, as required by VA-API.

https://bugzilla.gnome.org/show_bug.cgi?id=755072
2017-02-02 20:33:36 +01:00
Víctor Manuel Jáquez Leal
a1f7b5573d vaapivideomemory: check for display
This patch fixes the check of display, rather than check for the
meta, which it is known it exists.
2017-01-09 19:25:24 +01:00
Víctor Manuel Jáquez Leal
eb1d396536 vaapivideomemory: rename dmabuf allocator parameters
Rename the parameters 'vip' and 'flags' to 'alloc_info' and
'surface_alloc_flags' respectively. The purpose of this change is
to auto-document those parameters.

Also, aligned to this patch, the local 'alloc_info' variable was
renamed as 'surface_info', because it stores the possible surface's
video info, not the allocate one.
2017-01-09 18:07:41 +01:00
Víctor Manuel Jáquez Leal
2534dab8d8 vaapivideomemory: rename vip to alloc_info parameter
In order to auto-document the code, this patch renames the 'vip'
parameter in the functions related to gst_vaapi_video_allocator_new ()
to 'alloc_info', since it declares the allocation video info from
the vaapi buffer pool.
2017-01-09 16:26:22 +01:00
Víctor Manuel Jáquez Leal
d3d489a855 vaapivideomemory: use GST_VIDEO_INFO_FORMAT_STRING()
Use the existing local macro GST_VIDEO_INFO_FORMAT_STRING() to get
the video format string.
2017-01-09 16:16:36 +01:00
Víctor Manuel Jáquez Leal
7ced30dbac vaapivideomemory: unroll gst_vaapi_surface_new_with_format()
gst_vaapi_surface_new_with_format() is a wrapper for
gst_vaapi_surface_new_full (). In this case, the former is simpler
than the first. This patch changes that.
2017-01-09 12:51:11 +01:00
Hyunjun Ko
a66c2d44bf vaapivideomemory: fail surface/image configuration
To detect and handle errors during allocator_configure_surface_info()
and allocator_conigure_image_info().

https://bugzilla.gnome.org/show_bug.cgi?id=776084

Signed-off-by: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
2016-12-21 11:22:31 +01:00
Víctor Manuel Jáquez Leal
0f819fa190 vaapivideomemory: add gst_video_info_update_from_surface()
With this function is possible to refactor and remove duplicated code
between dmabuf configuration and direct rendering/uploading
configuration.
2016-12-14 17:25:43 +01:00
Víctor Manuel Jáquez Leal
7b2f774036 vaapivideomemory: no log object at initialization
When an instance of GstVaapiVideoAllocator fails at initializing, the
log message should not include the allocator's object, because it is
going to be unrefed.
2016-12-14 17:25:43 +01:00
Víctor Manuel Jáquez Leal
ad8da84062 vaapivideomemory: refactor code for readability
Added the inlined function allocator_configure_pools() moving out code
from gst_vaapi_video_allocator_new() to make clear that it is a
post-initalization of the object.
2016-12-05 17:42:38 +01:00
Víctor Manuel Jáquez Leal
b9b8c26c40 vaapivideomemory: log error if not VA image
Log an error message if the test image for surface downloading
cannot be allocated or mapped.
2016-12-05 17:42:38 +01:00
Víctor Manuel Jáquez Leal
f88ce54b65 vaapivideomemory: remove unused macros
These macros are not used. Let us remove them.
2016-12-05 17:42:38 +01:00
Víctor Manuel Jáquez Leal
4dffc12d6b vaapivideomemory: rename video for allocation_info
Since video_info stores the GstVideoInfo of the allocation caps,
it is clear if we rename it as allocation_info, to distinguish it
later from negotiation_info.
2016-12-05 17:42:38 +01:00
Julien Isorce
952b20a893 vaapivideomemory: add real GstVaapiDmaBufAllocator
Instead of defining GstVaapiDmaBufAllocator as a hackish decorator of
GstDmaBufAllocator, now, since the expose of the GstDmaBufAllocator's
GType, GstVaapiDmaBufAllocator is a full feature GstAllocator inherited
from GstDmaBufAllocator.

https://bugzilla.gnome.org/show_bug.cgi?id=755072

Signed-off-by: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
2016-12-05 17:41:58 +01:00
Julien Isorce
bb4dc645f0 vaapivideomemory: errors in gst_vaapi_dmabuf_allocator_new()
Add a helper function to initialize the gst_debug_vaapivideomemory,
to use it either by the GstVaapiVideoAllocatorClass or
GstVaapiDmabufAllocator (which is a decorator of GstDmaBufAllocator).

Later, log possible errors when calling gst_vaapi_dmabuf_allocator_new ()

https://bugzilla.gnome.org/show_bug.cgi?id=755072
2016-12-05 17:33:40 +01:00
Víctor Manuel Jáquez Leal
22463b96f3 vaapivideomemory: remove GST_VAAPI_TYPE_VIDEO_INFO
Remove redundant GST_VAAPI_TYPE_VIDEO_INFO, since it is a duplicate of
GST_TYPE_VIDEO_INFO created before gstreamer 1.6, where the boxed type
was created.

https://bugzilla.gnome.org/show_bug.cgi?id=774782
2016-11-21 17:22:31 +01:00
Víctor Manuel Jáquez Leal
432731e636 vaapivideomemory: add missing documentation
https://bugzilla.gnome.org/show_bug.cgi?id=774782
2016-11-21 16:37:36 +01:00
Víctor Manuel Jáquez Leal
acefc7e384 plugins: add allocator to allocation query
This patch adds the created allocator to the allocation query either
in decide_allocation() and propose_allocation() vmehtods.

With it, there's no need to set the modified allocator's size in the
pool configuration.

https://bugzilla.gnome.org/show_bug.cgi?id=774782
2016-11-21 16:37:36 +01:00
Víctor Manuel Jáquez Leal
e265788271 vaapivideomemory: check for memory allocator
When calling gst_vaapi_video_memory_copy() the allocator of the memory
to copy should be allocated by the vaapi allocator.

This patch does this verification.
2016-11-11 11:59:18 +01:00
Víctor Manuel Jáquez Leal
f6566a2c98 vaapivideomemory: code style fixes
A cosmetic commit for enhance readability of the casts and method
preconditions.
2016-11-11 11:59:18 +01:00
Víctor Manuel Jáquez Leal
85b3af62b4 vaapivideomemory: unroll gst_vaapi_video_allocator_free()
Instead of having a gst_vaapi_video_memory_free() that is only going to
be called by gst_vaapi_video_allocator_free(), let's just remove the first
and merged into the second.
2016-11-11 11:59:18 +01:00
Víctor Manuel Jáquez Leal
582d4d47f9 vaapivideomemory: avoid virtual methods casting
Use the expected virtual method signatures for readability.
2016-11-11 11:59:18 +01:00
Víctor Manuel Jáquez Leal
82cb89e1ed vaapivideomemory: remove unimplemented methods
Remove unimplemented method for allocator mem_share() and mem_is_span().
2016-11-11 11:59:18 +01:00
Víctor Manuel Jáquez Leal
a02c86b395 vaapivideomemory: fail if frame map can't get plane
If map() vmethod in GstVideMeta cannot get the plane data, return false,
thus the caller will not try to read invalid memory.

https://bugzilla.gnome.org/show_bug.cgi?id=774213
2016-11-11 11:59:18 +01:00
Víctor Manuel Jáquez Leal
3fa9af225f vaapivideomemory: lock map and unmap operations
In order to avoid race condition when two threads call map/unmap the same
VA surface, this patch mutex these operations.

https://bugzilla.gnome.org/show_bug.cgi?id=774213
2016-11-11 11:59:18 +01:00
Víctor Manuel Jáquez Leal
4ae9428072 vaapivideomemory: refactor vaapi memory unmapping
There were duplicated code in gst_video_meta_unmap_vaapi_memory() and
gst_vaapi_video_memory_unmap() when unmapping.

This patch refactors both methods adding the common function
unmap_vaapi_memory(). This also ensures, if direct rendering is enabled, it
is correctly reset.

Additionally, only when mapping flag has the WRITE bit, it set the image as
current, which was done in gst_video_meta_map_vaapi_memory() but no in
gst_vaapi_video_memory_map().

In order to make this, the mapping flags were required, so instead of
overloading mem_unmap() virtual function, mem_unmap_full() is overloaded.

https://bugzilla.gnome.org/show_bug.cgi?id=774213
2016-11-11 11:59:18 +01:00
Víctor Manuel Jáquez Leal
eda03230d9 vaapivideomemory: refactor vaapi memory mapping
There were duplicated code in gst_video_meta_map_vaapi_memory() and
gst_vaapi_video_memory_map() when doing the READ and WRITE mapping.

This patch refactors both methods adding the common function
map_vaapi_memory().

Additionally, only when flag has the READ bit it calls
ensure_images_is_current(), which was done in
gst_video_meta_map_vaapi_memory() but no in
gst_vaapi_video_memory_map().

https://bugzilla.gnome.org/show_bug.cgi?id=772151
2016-11-11 11:34:31 +01:00
Víctor Manuel Jáquez Leal
ae8e5d44f7 vaapivideomemory: increment map counter only if succeeded
Previously the frame map counter increased independently if the map succeeded
or not. This leaded to critical messages and crashes if the frame was unable
to be mapped, but the counter increased.

This patch increases the map counter only if the map operation occurred.

https://bugzilla.gnome.org/show_bug.cgi?id=773939
2016-11-04 13:44:29 +01:00
Víctor Manuel Jáquez Leal
2761e472af vaapivideomemory: destroy derived image at unmap
If the allocator was configured to use direct upload or rendering, the
generated derived image created at mapping needs to be destroyed after
unmapping, because, in order to process the surface, it should not be marked
as "busy" by the driver.
2016-11-03 08:35:29 +01:00
Víctor Manuel Jáquez Leal
ce8b14858f vaapivideomemory: enhance logs for direct modes
Print, conditionally, only the enabled direct mode.
2016-11-03 08:35:29 +01:00
Víctor Manuel Jáquez Leal
7c692265d8 vaapivideomemory: add direct upload flag
Adds the direct-upload flag in the GstVaapiVideoAllocator and
GstVaapiVideoMemory.

It still doesn't apply any functional change.
2016-11-03 08:35:28 +01:00
Víctor Manuel Jáquez Leal
e988298782 vaapivideomemory: set direct rendering at run-time
The way to experiment with the direct rendering is through and internal
compiler pre-processor flag.

The current change set enables a way to specified at run-time, as a flag
passed to the allocator at instanciation time.
2016-11-03 08:35:28 +01:00
Víctor Manuel Jáquez Leal
1bc5f00dfe vaapivideomemory: log in perf category when copy
Log in performance category when the derive image handling fails, falling back
to memory copy.
2016-11-03 08:35:28 +01:00
Víctor Manuel Jáquez Leal
7e90ae4c2e vaapivideomemory: error log is derive image fails
Instead of a silently failure of the derive image, this patch log an error
message according to the failure.
2016-11-03 08:35:28 +01:00
Víctor Manuel Jáquez Leal
dcbd411275 vaapivideomemory: store surface alloc flags in qdata
For sake of consistency, we should add the requested surface allocation flags
to the object's qdata structure.
2016-11-03 08:35:28 +01:00