Commit graph

998 commits

Author SHA1 Message Date
Michael Tretter
aed4088967 vaapipostproc: lock ensure_filter with postproc_lock
gst_vaapipostproc_ensure_filter might free the allowed_srcpad_caps
and allowed_sinkpad_caps. This can race with copying these caps in
gst_vaapipostproc_transform_caps and lead to segfaults.

The gst_vaapipostproc_transform_caps function already locks
postproc_lock before copying the caps. Make sure that calls to
gst_vaapipostproc_ensure_filter also acquire this lock.

https://bugzilla.gnome.org/show_bug.cgi?id=791404
2018-01-12 19:10:35 +01:00
Nicolas Dufresne
b0d41c5db8 videoconvert: gst_element_post_message() is transfer full on msg
For this reson we need not to unref the message, even if it failed.
2017-12-06 16:11:46 -05:00
Nicolas Dufresne
f9a57ccece Revert "vaapivideocontext: possible memleak when no bus attached"
This reverts commit 0438a3e626.
2017-12-06 16:11:25 -05:00
Víctor Manuel Jáquez Leal
8f5933cd80 vaapivideocontext: only vaapisink process app context
gst.vaapi.app.Display context is made for applications that will
provide the VA display and the native display to used by the
pipeline, when are using vaapisink as overlay. There are no use
case for encoders, decoders, neither for the postprocessor.

In the case of the vaapisink, it shall query for gst.vaapi.Display
upstream first, and then, if there is no reply,
gst.vaapi.app.Display context will be posted in the bus for the
application. If the application replies, a GstVaapiDisplay object
is instantiated given the context info, otherwise a
GstVaapiDisplay is created with the normal algorithm to guess the
graphics platform. Either way, the instantiated GstVaapiDisplay
is propagated among the pipeline and the have-message bus message.

Also only vaapisink will process the gst.vaapi.app.Display, if
and only if, it doesn't have a display already set. This is
caused because if vaapisink is in a bin (playsink, for example)
the need-context is posted twice, leading to an error state.

https://bugzilla.gnome.org/show_bug.cgi?id=790999
2017-12-01 23:11:11 +01:00
Víctor Manuel Jáquez Leal
466c839990 vaapivideocontext: log the name of GstVaapiDisplay
https://bugzilla.gnome.org/show_bug.cgi?id=790999
2017-12-01 23:11:11 +01:00
Víctor Manuel Jáquez Leal
0438a3e626 vaapivideocontext: possible memleak when no bus attached
https://bugzilla.gnome.org/show_bug.cgi?id=790999
2017-12-01 23:11:11 +01:00
Víctor Manuel Jáquez Leal
8092537763 plugins: centralize assignation of GL objects
Add plugin_set_gst_gl() where the GstGL objects are assigned.

https://bugzilla.gnome.org/show_bug.cgi?id=773453
2017-11-01 11:27:36 +01:00
Víctor Manuel Jáquez Leal
3d56306c37 plugins: set GL objects if ensured
Only set the GL display and GL other context if they are ensured.

https://bugzilla.gnome.org/show_bug.cgi?id=773453
2017-11-01 11:27:36 +01:00
Víctor Manuel Jáquez Leal
fc1c415515 plugins: set GL objects if context is handled
Only set the GL display and GL other context if they are extracted
correctly from the gstreamer's context.

https://bugzilla.gnome.org/show_bug.cgi?id=773453
2017-11-01 11:27:36 +01:00
Víctor Manuel Jáquez Leal
4866e4c452 plugins: fix memory leak when GL context is created
When the GL display and context are created inside an VAAPI element
the created GL context is leaked.

https://bugzilla.gnome.org/show_bug.cgi?id=773453
2017-11-01 11:27:36 +01:00
Víctor Manuel Jáquez Leal
72362e1063 plugins: direct rendering on memory:VASurface
As buffers negotiated with memory:VASurface caps feature can also be
mapped, they can also be configured to use VA derived images, in other
words "direct rendering".

Also, because of the changes in dmabuf allocator as default allocator,
the code for configuring the direct rendering was not clear.

This patch cleans up the code and enables direct rendering when the
environment variable GST_VAAPI_ENABLE_DIRECT_RENDERING is defined,
even then the memory:VASurface cap feature is negotiated.

https://bugzilla.gnome.org/show_bug.cgi?id=786054
2017-10-31 18:26:42 +01:00
Víctor Manuel Jáquez Leal
0a36a707ba plugins: only dmabuf on srcpad if downstream
Set if source pad can handle dmabuf only if the GstGL context comes
from downstream.

It is possible to know that at two moments:

1\ In the case of GstGLTextureUpload caps feature is negotiated and
   downstream pool reports back gst.gl.GstGLContext.

2\ When GstGLContext is found as GstContext from dowstream.

https://bugzilla.gnome.org/show_bug.cgi?id=788503
2017-10-20 16:36:04 +02:00
Víctor Manuel Jáquez Leal
1135e8bd31 vaapivideocontext: add inline documentation
Document function gst_vaapi_find_gl_local_context().

https://bugzilla.gnome.org/show_bug.cgi?id=788503
2017-10-20 16:36:04 +02:00
Víctor Manuel Jáquez Leal
6b2b1294f8 vaapivideocontext: return the direction of gl context
In function gst_vaapi_find_gl_context() add a direction parameter to
return back the direction where the GstGL context was found.

This is going to be useful when checking if downstream can import
dmabuf-based buffers.

https://bugzilla.gnome.org/show_bug.cgi?id=788503
2017-10-20 16:36:04 +02:00
Víctor Manuel Jáquez Leal
998e79ced6 plugins: add gst_vaapi_plugin_base_set_srcpad_can_dmabuf()
This patch refactors the code by adding the function
vaapi_plugin_base_set_srcpad_can_dmabuf(), it determines if the passed
GstGLContext can handle dmabuf-based buffers.

The function is exposed publicly since it is intended to be used later
at GstVaapiDisplay instantiation.

https://bugzilla.gnome.org/show_bug.cgi?id=788503
2017-10-20 16:36:04 +02:00
Hyunjun Ko
8ef3bc3cc2 vaapiencode: allow to set property on runtime
Tis patch, allows some properties that we want to be set on
runtime. (eg. bitrate)

Note that all properties are under control by num_codedbuf_queued.

https://bugzilla.gnome.org/show_bug.cgi?id=786321
2017-10-20 13:22:51 +02:00
Sebastian Dröge
a8f2309595 vaapidecodebin: Register element if no VPP support is available too
VPP support is only needed for advanced deinterlacing, which is not
enabled by default either. Error out if it is selected but VPP is not
supported, and otherwise just work without VPP support.

https://bugzilla.gnome.org/show_bug.cgi?id=788758
2017-10-20 12:59:10 +02:00
Thibault Saunier
a6e191e09c Avoid infinite loop when vaapi_create_display fails
Which might be the case when using, for example, xvfb.
2017-10-16 11:59:11 +02:00
Víctor Manuel Jáquez Leal
68aca503ce plugins: try to create test display in order
When creating the test display for querying capabilites, it try in
certain order: DRM, Wayland and finally X11. GLX nor EGL are tried
since they are either composited with X11 or Wayland.

The reason for this is to reduce the posibility of failure that could
blacklist the plugin.

https://bugzilla.gnome.org/show_bug.cgi?id=782212
2017-10-03 13:14:55 +02:00
Sebastian Dröge
8a0e22a5bb vaapi: Also register vaapipostproc without VPP support
It can still do simple deinterlacing then.
2017-10-03 13:06:33 +02:00
Sebastian Dröge
76e9ad8646 vaapipostproc: Allow running without VPP support
We returned FALSE from ::start() if VPP support is not available, but it
is only really needed for complex filters and during transform we check
for that. For simple deinterlacing it is not needed.
2017-10-03 12:04:42 +02:00
Víctor Manuel Jáquez Leal
bedaa13d7c vaapipostproc: use scoped variable for return value
Instead of reusing a parameter variable for the return value of
gst_vaapipostproc_transform_caps(), this patch uses the function
scoped pointer. Thus, the code is cleaner.

https://bugzilla.gnome.org/show_bug.cgi?id=785706
2017-09-28 13:56:13 +02:00
Víctor Manuel Jáquez Leal
d3732a7cf8 vaapipostproc: removed unused parameter
Removed caps parameter from gst_vaapipostproc_transform_caps_impl()
helper function since the it is not used.

https://bugzilla.gnome.org/show_bug.cgi?id=785706
2017-09-28 13:56:13 +02:00
Víctor Manuel Jáquez Leal
f6fc1774b9 vaapipostproc: use scoped variable for return value
Instead of reusing a parameter variable for the return value of
gst_vaapipostproc_fixate_caps(), this patch uses the function scoped
pointer. Thus, the code is cleaner.

https://bugzilla.gnome.org/show_bug.cgi?id=785706
2017-09-28 13:56:13 +02:00
Víctor Manuel Jáquez Leal
8fee85ecaa plugins: memory:DMABuf only handles planar formats
When glimagesink negotiates the caps feature memory:DMABuf the
exported dmabufs buffers with NV12 format are not well rendered, thus
setting only planar.

https://bugzilla.gnome.org/show_bug.cgi?id=788229
2017-09-27 11:46:33 +02:00
Víctor Manuel Jáquez Leal
9f4a5762d5 vaapiencode: flush pending frames before set format
Flush pending frames, if any, in the internal encorder, before setting
the new negotiated format.

https://bugzilla.gnome.org/show_bug.cgi?id=786173
2017-09-26 11:34:20 +02:00
Víctor Manuel Jáquez Leal
a4daa2a04a vaapidecode: drain pending frames before set format
Drain pending frames, if any, in the internal decoder before setting
the new negotiated format.

https://bugzilla.gnome.org/show_bug.cgi?id=786173
2017-09-26 10:48:20 +02:00
Víctor Manuel Jáquez Leal
b063511c05 vaapisink: use GObject setter and getter
Instead of using gst_vaapi_display_set_property() or
gst_vaapi_display_get_property(), this patch set replace it usage
with g_object_set() or g_object_get().

Also the internal helper cb_set_value() is removed since it is not
used anymore.

https://bugzilla.gnome.org/show_bug.cgi?id=788058
2017-09-22 20:06:42 +02:00
Hyunjun Ko
148f867c12 vaapiencode/libs: encoder: fix leaks of properties
https://bugzilla.gnome.org/show_bug.cgi?id=786321
2017-09-15 11:07:55 +02:00
Nicolas Dufresne
2039eb882e Request minimum buffer even if need_pool is FALSE
When tee is used, it will not request a pool, but still it wants to
know how many buffers are required.

https://bugzilla.gnome.org/show_bug.cgi?id=730758
2017-09-06 14:21:31 -04:00
Sreerenj Balachandran
782184e781 vaapisink: Fix rendering in drm display
Make sure vaapisink create a va surface backed buffer pool and all
required attributes get assigned correctly for drm display type.

This is needed to make the below pipeline working:
gst-launch-1.0 filesrc location= raw_video.mov ! videoparse format=uyvy
width=320 height=240 framerate=30/1 ! vaapisink display=drm

https://bugzilla.gnome.org/show_bug.cgi?id=786954
2017-09-01 13:48:01 -07:00
Sreerenj Balachandran
5750bd7850 FEI: plugin: Add vaapih264feienc element
A new FEI based encoder element for h264 is added: vaapih264feienc

FEI is a an extension to VA-API which is providing low level
advanced control over different stages of encoding.
Extending vaapih264enc with fei support is possible, but it will
make the code too much complicated and will be difficult
to debug. So adding the new encoder element, but keeping
the rank as 0 , vaapih264enc will stay as the primary
encoder for normal use cases.

The vaaih264feienc is mainly useful for customers who want to play
with MotionVectors and Macroblock Predictions. Also user can
do one stage of encoding(eg: only the Motion Vector Calculation)
in software and offload trasformation/entroy-coding etc to
Hardware (which is what PAK module is doing) using FEI element.

vaapih264feienc can work in  different modes using fei-mode properoty

eg: gst-launch-1.0 videotestsrc ! vaapih264feienc fei-mode=ENC+PAK ! filesink location=sample.264

Important Note: ENC only mode won't produce any encoded data which is expected.
But ENC alwys requires the output of PAK in order to do the inter-prediction
over reconstructed frames.
Similary PAK mode alway requires MV and MBCode as input, so unless there is an
upstream element providing those buffers, PAK only won't work as expected.

In a nutshell, ENC_PAK and the ENC+PAK modes are the only options we can verify
with vaapih264feienc. But ideally, EN+PAK mode verification is enough to make sure
that ENC and PAK are working as expected since ENC+PAK mode always invoke ENC and PAK
separately in vaapih264feienc.

People contributed:
        Wang, Yi <yi.a.wang@intel.com>
        Leilei <leilei.shang@intel.com>
        Zhong, Xiaoxia <xiaoxia.zhong@intel.com>
        xiaominc <xiaomin.chen@intel.com>
        Li, Jing B <jing.b.li@intel.com>

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

Signed-off-by: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
2017-09-01 13:15:05 +02:00
Yi A Wang
a46ad6b5be FEI: plugin: Add virtual methods to base encode
Two new virtual methods are added to gstvaapiencode.

load_control_data():  load the FEI input buffers set by the upstream elements
save_stats_to_meta(): save the FEI output buffers to Meta for downnstream elements

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

Signed-off-by: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
2017-09-01 11:36:49 +02:00
Yi A Wang
0fdef0e349 FEI: plugin: Add fei specific video meta
GstVaapiFeiVideoMeta holds the below fei codec objects:
  GstVaapiEncFeiMbCode
  GstVaapiEncFeiMv
  GstVaapiEncFeiMvPredictor
  GstVaapiEncFeiMbControl
  GstVaapiEncFeiQp
  GstVaapiEncFeiDistortion

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

Signed-off-by: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
2017-09-01 11:36:49 +02:00
Orestis Floros
1ae42facc1 vaapidecode: force add h264 SVC profiles in caps
When vaapih264dec's base-only profile is set to TRUE, fake SVC profile
support in caps.

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

Signed-off-by: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
2017-08-28 17:34:50 -07:00
Víctor Manuel Jáquez Leal
466c0548dc plugins: include main gstgl header
Instead including particular gstgl header files in a header file
that doesn't export a gstgl symbol, the main gstgl header file is
included in gstvaapipluginutil.c where the symbols are used.

https://bugzilla.gnome.org/show_bug.cgi?id=786597
2017-08-22 11:41:21 +02:00
Hyunjun Ko
ee159b58ee vaapidecode: fix mismatch of the return type
https://bugzilla.gnome.org/show_bug.cgi?id=786307
2017-08-15 11:50:22 +03:00
Víctor Manuel Jáquez Leal
9578fd1f7b vaapiencode: h264: remove spurious code
Coverity scan bug:

An unsigned value can never be negative, so this test will always
evaluate the same way.

As len is guint32, there is no need to check it if it is equal or
bigger than zero.
2017-08-08 17:38:51 +02:00
Víctor Manuel Jáquez Leal
0b3ca62632 vaapidecode: initialize variable
Coverity scan bug:

The variable will contain an arbitrary value left from earlier
computations.

Variable base_only is fetched from base-only property, and it may be
not assigned. It needs to be initialized.
2017-08-08 17:34:12 +02:00
orestisf
3bb96eff14 vaapidecode: fix gst_caps_new_simple call
https://bugzilla.gnome.org/show_bug.cgi?id=732265
2017-08-03 23:28:59 +02:00
orestisf
d4b6459bb2 vaapidecode: force add h264 MVC profiles in caps
When vaapih264dec's base-only profile is set to TRUE, fake MVC profile
support in caps.

https://bugzilla.gnome.org/show_bug.cgi?id=732265
2017-08-03 17:07:22 +02:00
orestisf
66703a7835 vaapidecode: set h264 base-only to decoder
Set the base-only value when property is set and the internal
decoder is already instantiated or when the internal decoder
is created.

https://bugzilla.gnome.org/show_bug.cgi?id=732265
2017-08-03 17:07:14 +02:00
orestisf
bd040adb9c vaapidecode_props: h264: add base-only property
https://bugzilla.gnome.org/show_bug.cgi?id=732265
2017-08-03 17:07:01 +02:00
Víctor Manuel Jáquez Leal
7d6a80e13d vaapiencode: h265: compare an unsigned int if not zero
An unsigned value can never be negative, so this test (greater than
zero) will always evaluate the same way. Thus change it to just if
it's not zero.
2017-08-01 18:38:40 +02:00
Víctor Manuel Jáquez Leal
5f64d6df6c plugins: check gst_gl_ensure_element_data() return value
Refactor gst_vaapi_plugin_base_create_gl_context() in order to check
the return value of gst_gl_ensure_element_data(). The result is a code
bit cleaner.
2017-08-01 18:10:50 +02:00
Víctor Manuel Jáquez Leal
02e48ad8dc plugins: avoid dead code detection
By using #elif macro, the static code analysis would stop to detect
these lines as dead code. Also it is inforced the mutually exclusive
environments.
2017-08-01 17:59:38 +02:00
Víctor Manuel Jáquez Leal
de0f8936f8 vaapivideobufferpool: don't shift by negative since it's undefined
The function g_bit_nth_lsf() may return -1 if the request bit position
is not avaible. Thus, this patch check if the return value is not -1
in order to continue.
2017-08-01 17:39:04 +02:00
Víctor Manuel Jáquez Leal
19444ce184 vaapisink: fix memory leak 2017-08-01 17:29:40 +02:00
Víctor Manuel Jáquez Leal
ce03fa8ed0 vaapipostproc: fix memory leaks 2017-08-01 17:23:48 +02:00
Hyunjun Ko
736478d2a7 vaapisink: fail if surface display is different
Replacing GstVaapiDisplay during rendering might be hiding problems
at some cases, even though it's safe currently since we use cache
of GstVaapidisplay.

Play safe by failing if this happens.

https://bugzilla.gnome.org/show_bug.cgi?id=766704
2017-07-26 14:21:54 +02:00