Commit graph

78 commits

Author SHA1 Message Date
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
Víctor Manuel Jáquez Leal
3f61394cb0 vaapivideomemory: use allocator custom alloc flag
Instead of a dummy alloc() vmethod, the allocator instance set the flag
GST_ALLOCATOR_FLAG_CUSTOM_ALLOC, which is used by the framework to avoid call
gst_allocator_alloc() on the allocator.
2016-05-19 16:38:40 +02:00
Sreerenj Balachandran
fd04a7c046 gst/vaapi: keep precedence for NV12 over I420
Use NV12 as default "assumption" format all over.
NV12 is the default high priority format used my most of the
vaapi-drivers.
2016-03-29 15:02:46 +03:00
Víctor Manuel Jáquez Leal
4b5be5973e libs: small refactors to enhance the code style
As gst-indent generated ugly code in these cases, this patch changes the used
idiomatic into other one.

No functional changes were introduced.

Signed-off-by: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
2016-02-03 20:03:47 +01:00
Víctor Manuel Jáquez Leal
bb2248ab66 plugins: fix code style
Minor code style changes by executing gst-indent in gst/vaapi directory.

Signed-off-by: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
2016-02-03 12:17:59 +01:00
Víctor Manuel Jáquez Leal
f0d6b0ac3f gstvaapivideomemory: native format with no derived image
If USE_NATIVE_FORMATS is defined we bail out before configuring the surface
info based on the derived image configuration.

Signed-off-by: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com>

https://bugzilla.gnome.org/show_bug.cgi?id=744042
2015-08-13 17:20:19 +02:00
Víctor Manuel Jáquez Leal
ceb70c3ca6 surface pool config based on video info
First added the function gst_vaapi_video_format_get_best_native(), which
returns the best native format that matches a particular chroma type:

YUV 4:2:0 -> NV12, YUV 4:2:2 -> YUY2, YUV 4:0:0 -> Y800

RGB32 chroma and encoded format map to NV12 too.

That format is used to configure, initially, the surface's pool for the
allocator.

Signed-off-by: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com>

https://bugzilla.gnome.org/show_bug.cgi?id=744042
2015-08-13 17:20:19 +02:00
Víctor Manuel Jáquez Leal
940dc1a18e gstvaapivideomemory: refactor gst_vaapi_video_allocator_new()
Signed-off-by: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com>

https://bugzilla.gnome.org/show_bug.cgi?id=744042
2015-08-13 17:20:19 +02:00
Sreerenj Balachandran
b4154ac85c gst/vaapi: Switch to upstreram like indentation.
gst-indent for all gst/vaapi/*.c source files
2015-06-30 09:44:18 +03:00
Víctor Manuel Jáquez Leal
c561b8da8a update and move gstcompat.h
The purpose of gstcompat.h is to couple the API differences among
gstreamer-1.0 and gstreamer-0.10. Since gstreamer-0.10 is obsolete, the code
in this compatibility layer shall be removed.

Nevertheless, the gstcompat.h header should be kept, if new incompatibilites
appear in the future, but it shall live in gst/vaapi, not in gst-libs.

This patch removes the crumbs defined gstcompat.h and moves it to gst/vaapi.
In order to avoid layer violations, gstcompat.h includes sysdeps.h and all
the includes in gst/vaapi of sysdeps.h are replaced with gstcompat.h

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

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
Signed-off-by: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
2015-04-03 17:08:30 +03:00
Gwenole Beauchesne
8b91ddac0b plugins: fix allocation of DMABUF memory.
The dmabuf allocator would close the DMABUF handle passed in the init
function gst_dmabuf_allocator_alloc(). So, we need to dup() it so that
to avoid a double close, ultimately in the underlying driver that owns
the DMABUF handle.
2015-03-02 13:41:29 +01:00
Víctor Manuel Jáquez Leal
671b1ea305 Fix compiler warnings
This patch fixes some warnings that gcc 4.9 reports.

https://bugzilla.gnome.org/show_bug.cgi?id=744411
2015-02-18 11:46:11 +02:00
Gwenole Beauchesne
82fc406dfd plugins: add support for dma_buf exports (v4l2src).
Allow v4l2src element to connected to vaapipostproc or vaapisink when
"io-mode" is set to "dmabuf-import". In practice, this is a more likely
operational mode with uvcvideo. Supporting v4lsrc with "io-mode" set
to "dmabuf" could work, but with more demanding driver or kernel reqs.

Note: with GStreamer 1.4, v4l2src (gst-plugins-good) needs to be built
with --without-libv4l2.

https://bugzilla.gnome.org/show_bug.cgi?id=743635
2015-01-28 17:36:21 +01:00
Gwenole Beauchesne
96ce1bc761 videopool: add optional flags for surface pool allocation.
Reword surface pool allocation helpers so that to allow for a simple
form, e.g. gst_vaapi_surface_pool_new(format, width, height); and a
somewhat more elaborated/flexible form with optional allocation flags
and precise GstVideoInfo specification.

This is an API/ABI change, and SONAME version needs to be bumped.
2015-01-27 18:11:45 +01:00
Gwenole Beauchesne
09dcb1e0f7 vaapivideomemory: don't crash when trying to allocate 0x0 images.
In some occasions, a buffer pool is created for pre-initialization
purposes regardless of whether a valid image size is available or
not. However, during actual decode stage, the vaapidecode element
is expected to update the srcpad caps with the new dimensions, thus
also triggering a reset of the underlying bufferpool.
2015-01-15 17:13:52 +01:00
Gwenole Beauchesne
cf352336b3 plugins: further fixes to the new "current" storage tracker.
The ensure_surface() and ensure_image() functions shall only relate
to the underlying backing store. The actual current flags are to be
updated only through ensure_{surface,image}_is_current() or very other
particular cases in GstMemory hooks.
2014-11-24 13:20:33 +01:00
Gwenole Beauchesne
5fd643bf49 plugins: fix "current" video memory flags.
If the surface proxy is updated into the GstVaapiVideoMemory, then
it is assumed it is the most current representation of the current
video frame. Likewise, make a few more arrangements to have the
"current " flags set more consistently.
2014-11-21 15:50:35 +01:00
Gwenole Beauchesne
ceb60285ea plugins: ensure VA surface is current prior to using it.
When interacting with SW elements, the buffers and underlying video
memory could be mapped as read/write. However, we need to use those
buffers again as plain VA surfaces, we have to make sure the VA image
is thus committed back to VA surface memory.

This fixes pipelines involving avdec_* and vaapi{postproc,sink}.
2014-11-21 15:29:33 +01:00
Víctor Manuel Jáquez Leal
0e87abc574 plugins: enable memory maps for read & write.
Hence vaapisink can display buffers decoded by gst-libav, or HW decoded
buffers can be further processed in-place, e.g. with a textoverlay.

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

[ported to current git master branch, amended commit message]
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-11-19 10:36:27 +01:00
Sreerenj Balachandran
aa4d1f5a1e vaapivideomemory: avoid NULL pointer unref if GstVaapiImage creation failed.
https://bugzilla.gnome.org/show_bug.cgi?id=735156
2014-08-22 15:54:32 +02:00
Gwenole Beauchesne
1ef5a3a200 plugins: allow bufferpool to not allocate vaapi video meta.
Add GST_VAAPI_VIDEO_BUFFER_POOL_ACQUIRE_FLAG_NO_ALLOC params flag that
can be used to disable early allocations of vaapi video metas on buffers,
thus delagating that to the bufferpool user.
2014-08-22 15:54:32 +02:00
Gwenole Beauchesne
038d56bdca plugins: re-indent all GstVaapiVideo* related source code. 2014-08-22 15:54:32 +02:00