Commit graph

99 commits

Author SHA1 Message Date
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
Víctor Manuel Jáquez Leal
4016388565 vaapivideomemory: category init when object define
Move the Gstreamer debug category initialize to the GObject definition.
2016-11-03 08:35:28 +01:00
Víctor Manuel Jáquez Leal
0f938be7a4 plugins: fix code style for errors
https://bugzilla.gnome.org/show_bug.cgi?id=773497
2016-10-25 19:38:26 +02:00
Víctor Manuel Jáquez Leal
34e8579238 vaapivideomemory: comment style
https://bugzilla.gnome.org/show_bug.cgi?id=773497
2016-10-25 19:38:26 +02:00
Víctor Manuel Jáquez Leal
289a8e5b87 vaapivideomemory: rename input parameter
In order to clarify the use of flag as input parameter, it is renamed to
surface_alloc_flag, since it is used when creating a VA surface with certain
properties.

https://bugzilla.gnome.org/show_bug.cgi?id=773497
2016-10-25 19:38:26 +02:00
Julien Isorce
84f7a3ec51 vaapivideomemory: add explanation about the call 'dup (dmabuf_fd)'
In short GstFdMemory is configured to call close when using
GstDmabufMemory.

https://bugzilla.gnome.org/show_bug.cgi?id=755072
2016-10-19 19:45:08 +02:00
Víctor Manuel Jáquez Leal
abffbfc71f Revert "vaapivideomemory: load VA Image when mapping to write"
This reverts commit c67edea4ab.
2016-09-12 12:45:01 +02:00
Hyunjun Ko
c67edea4ab vaapivideomemory: load VA Image when mapping to write
When calling gst_video_frame_map() with GST_MAP_WRITE flag, it doesn't call
ensure_image_is_current(), which means it doesn't guarentee VAImage is valid
in this case.

https://bugzilla.gnome.org/show_bug.cgi?id=766978
2016-09-08 16:38:52 +02:00
Víctor Manuel Jáquez Leal
892b6d3822 gstvaapivideomemory: allocator's image size getter
Add the method gst_allocator_get_vaapi_image_size() for the
GstVaapiVideoAllocator, which gets the size of the allocated images with the
current video info.

This method replaces the direct call to the allocator's image info when the
pool is configured.
2016-07-29 15:13:29 +02:00
Víctor Manuel Jáquez Leal
50b2423a2b pluginbase negotiates allocator with bufferpool
Originally vaapivideobufferpool instantiates its own allocator regardless the
received configuration, and it relies in custom configuration options to
choose which kind of allocator instantiate.

This patch transfers the responsibility of the allocator instantiate to
vaapipluginbase and pass it to the vaapivideobufferpool through its
configuration.

* gst/vaapi/gstvaapipluginbase.c
  + set_dmabuf_allocator(): inserts a dmabuf allocator in the bufferpool
  + ensure_sinkpad_buffer_pool(): set a normal vaapi video allocator in
    bufferpool configuration
  + gst_vaapi_plugin_base_propose_allocation(): call set_dmabuf_allocator() if
    needed.
  + gst_vaapi_plugin_base_decide_allocation(): set a normal vaapi video
    allocator in bufferpool configuration
* gst/vaapi/gstvaapivideobufferpool.c
  + gst_vaapi_video_buffer_pool_set_config(): instead of instantiate the
    allocator, process the received one through its configuration.
* gst/vaapi/gstvaapivideobufferpool.h: removed
  GST_BUFFER_POOL_OPTION_DMABUF_MEMORY since it is not used anymore.
* gst/vaapi/gstvaapivideomemory.c
  + gst_vaapi_is_dmabuf_allocator(): new helper function to identify a dmabuf
    allocator with the vaapi qdata.

https://bugzilla.gnome.org/show_bug.cgi?id=765435
2016-06-08 10:19:01 +02:00
Víctor Manuel Jáquez Leal
3d9f8dd41f pluginutil: add gst_video_info_force_nv12_if_encoded()
This lines repeat a couple times in the code, so it would be better to put it
a helper function.

https://bugzilla.gnome.org/show_bug.cgi?id=765435
2016-06-08 10:19:01 +02:00