platform/upstream/gstreamer.git
4 years agolibs: surface: initialize VASurfaceAttribExternalBuffers
Víctor Manuel Jáquez Leal [Mon, 27 Jan 2020 10:49:26 +0000 (11:49 +0100)]
libs: surface: initialize VASurfaceAttribExternalBuffers

Initialize VASurfaceAttribExternalBuffers using compiler's syntax
rather than using memset().

4 years agolibs: surface: merge two loops into one
Víctor Manuel Jáquez Leal [Mon, 27 Jan 2020 10:44:49 +0000 (11:44 +0100)]
libs: surface: merge two loops into one

Merge two loops into one for setting offsets and strides in the
external buffer descriptor.

4 years agolibs: surface: surfacepool: rename variable for clearity
Víctor Manuel Jáquez Leal [Wed, 22 Jan 2020 09:42:35 +0000 (10:42 +0100)]
libs: surface: surfacepool: rename variable for clearity

In order to be readable, the meaningless 'flags' is renamed to
surface_allocation_flags, which is clearer.

4 years agovaapivideobufferpool: Reuse internal allocator is possible.
Víctor Manuel Jáquez Leal [Mon, 27 Jan 2020 17:40:46 +0000 (18:40 +0100)]
vaapivideobufferpool: Reuse internal allocator is possible.

Instead of creating a new allocator when upstream requests a different
allocator, this patch tries to reuse the internal allocator if it was
already initializated.

If the stream changes, then either one will be unref and a new
allocator is created.

4 years agovaapivideobufferpool: Log messages in proper category.
Víctor Manuel Jáquez Leal [Mon, 27 Jan 2020 17:05:14 +0000 (18:05 +0100)]
vaapivideobufferpool: Log messages in proper category.

The log messages where logged in the GstBufferPool category because
the instance was not properly casted. This fix that situation.

4 years agolibs: display: driver quirks mechanism
Víctor Manuel Jáquez Leal [Thu, 16 Jan 2020 10:49:21 +0000 (11:49 +0100)]
libs: display: driver quirks mechanism

This mechanism comes from ffmpeg vaapi implementation, where they have
their own quirks.

A specific driver is identified by a substring present in the vendor
string. If that substring is found, a set of bitwise flags are store.
These flags can be accessed through the function
gst_vaapi_display_has_driver_quirks().

The purpose for this first quirks is to disable the put image try for
AMD Gallium driver (see [1]).

1. https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/merge_requests/72

4 years agoplugins: renable Mesa Gallium driver
Víctor Manuel Jáquez Leal [Wed, 15 Jan 2020 22:07:29 +0000 (23:07 +0100)]
plugins: renable Mesa Gallium driver

4 years agovaapivideobufferpool: validate returned meta
Víctor Manuel Jáquez Leal [Fri, 24 Jan 2020 10:55:22 +0000 (11:55 +0100)]
vaapivideobufferpool: validate returned meta

Validate if the meta returned by gst_buffer_get_vaapi_video_meta() in
the acquired buffer is not null.

This situation should be very "pathological", but still it is better
be safe since that meta might be used later to create a new dma
buffer.

4 years agovaapivideobufferpool: always update/release the underlying surface proxy
Philipp Zabel [Wed, 22 Jan 2020 17:50:36 +0000 (18:50 +0100)]
vaapivideobufferpool: always update/release the underlying surface proxy

gst_vaapi_video_buffer_pool_reset_buffer() is called when the sink
releases the last reference on an exported DMA buffer. This should
release the underlying surface proxy. To avoid releasing the wrong
surface due to a stale surface proxy reference in the buffer's
GstVaapiVideoMeta, always update the reference to the correct surface
in gst_vaapi_video_buffer_pool_acquire_buffer().

4 years agolibs: context: select vaCreateSurfaces version according attributes
Víctor Manuel Jáquez Leal [Thu, 23 Jan 2020 15:56:44 +0000 (16:56 +0100)]
libs: context: select vaCreateSurfaces version according attributes

This commit tries to centralize the selection of vaCreateSurfaces
version, instead of having fallbacks everywhere.

These fallbacks are hacks, added because new drivers use the latest
version of vaCreateSurfaces (with surface attributes) [1], meanwhile
old drivers (or profiles as JPEG decoder in i965) might rather use the
old version.

In order to select which method, there's detected hack: each config
context has a list of valid formats, in the case of JPEG decoder the
list only contains "rare" 4:2:2 formats (ICM3, GRAY8) which aren't
handled correctly by the current gstreamer-vaapi code [2].

The hack consist in identify if the format list contains an arbitrary
preferred format (which is suposedly well supported by
gstreamer-vaapi, mostly NV12). If no prefered colour format is found,
the the old version of vaCreateSurfaces is used, and the surfaces wil
be mapped into a image with their own color format.

1. https://bugzilla.gnome.org/show_bug.cgi?id=797143
2. https://bugzilla.gnome.org/show_bug.cgi?id=797222

4 years agolibs: context: add debug category for context
Víctor Manuel Jáquez Leal [Tue, 21 Jan 2020 18:35:02 +0000 (19:35 +0100)]
libs: context: add debug category for context

4 years agolibs: blend: guard VA_BLEND_GLOBAL_ALPHA
Víctor Manuel Jáquez Leal [Wed, 22 Jan 2020 19:20:30 +0000 (20:20 +0100)]
libs: blend: guard VA_BLEND_GLOBAL_ALPHA

4 years agovaapiencode: promote info to warning
Víctor Manuel Jáquez Leal [Tue, 21 Jan 2020 13:09:33 +0000 (14:09 +0100)]
vaapiencode: promote info to warning

Let's notify user about using constrained-baseline instead on
requested basline profile.

4 years agovaapih264dec: Add a property to assume constrained-baseline
Nicolas Dufresne [Fri, 28 Jun 2019 19:41:16 +0000 (15:41 -0400)]
vaapih264dec: Add a property to assume constrained-baseline

When baseline-as-constrained is set, the decoder will expose support
for baseline decoding and assume that the baseline content is
constrained-baseline. This can be handy to decode streams in hardware
that would otherwise not be possible to decode. A lot of baseline
content is in fact constrained.

4 years agovaapih264enc: accept baseline as constrained baseline compatible
Víctor Manuel Jáquez Leal [Fri, 17 Jan 2020 15:19:52 +0000 (16:19 +0100)]
vaapih264enc: accept baseline as constrained baseline compatible

4 years agovaapih264enc: update level in src caps
Víctor Manuel Jáquez Leal [Fri, 17 Jan 2020 13:24:37 +0000 (14:24 +0100)]
vaapih264enc: update level in src caps

And, if downstream requests a specific level, the caps are not
negotiated, because there is no mechanism right now to specify a
custom level in the internal encoder.

4 years agolibs: encoder: h264: document gst_vaapi_encoder_h264_supports_avc()
Víctor Manuel Jáquez Leal [Fri, 17 Jan 2020 16:12:53 +0000 (17:12 +0100)]
libs: encoder: h264: document gst_vaapi_encoder_h264_supports_avc()

4 years agovaapih264enc: force byte-stream if avc isn't supported
Víctor Manuel Jáquez Leal [Fri, 17 Jan 2020 12:38:29 +0000 (13:38 +0100)]
vaapih264enc: force byte-stream if avc isn't supported

Removing the validation in gst_vaapiencode_h264_get_caps() since that
ought be handled in gst_vaapiencode_h264_set_config()

4 years agovaaph264enc: suppress avc if the driver does not support packed headers
Philipp Zabel [Wed, 8 Jan 2020 16:37:22 +0000 (17:37 +0100)]
vaaph264enc: suppress avc if the driver does not support packed headers

Do not negotiate AVC output if the driver does not support it.

4 years agolibs: encoder: h264: Add gst_vaapi_encoder_h264_supports_avc()
Philipp Zabel [Wed, 8 Jan 2020 16:16:35 +0000 (17:16 +0100)]
libs: encoder: h264: Add gst_vaapi_encoder_h264_supports_avc()

AVC output requires packed header support in the driver.

4 years agovaapih264enc: intersect the new proposed caps
Víctor Manuel Jáquez Leal [Fri, 17 Jan 2020 12:07:04 +0000 (13:07 +0100)]
vaapih264enc: intersect the new proposed caps

Instead of just leave to keep the proposed caps, with the best profile
in the allowed caps, is its intersected again.

4 years agovaapih264enc: propose new profile caps and fixate it
Víctor Manuel Jáquez Leal [Fri, 17 Jan 2020 11:58:58 +0000 (12:58 +0100)]
vaapih264enc: propose new profile caps and fixate it

When the available caps doesn't intersect with the allowed caps in the
pipeline, a new caps is proposed rather than just expecting to
iterate.

Later, the intersected caps (profile_caps) is fixated in order to
extract the configuration.

4 years agovaapih264enc: common fail for gst_vaapiencode_h264_set_config()
Víctor Manuel Jáquez Leal [Fri, 17 Jan 2020 12:18:28 +0000 (13:18 +0100)]
vaapih264enc: common fail for gst_vaapiencode_h264_set_config()

Add a common fail code path for gst_vaapiencode_h264_set_config().

4 years agolibs: encoder: unref formats array if none
Víctor Manuel Jáquez Leal [Fri, 17 Jan 2020 11:54:21 +0000 (12:54 +0100)]
libs: encoder: unref formats array if none

The formats array is always created, in order to keep the logic and
to avoid broken caps, if this formats array doesn't contain any
elements, it has to be unref and the function should return NULL.

4 years agovaapih264enc: fix log message
Víctor Manuel Jáquez Leal [Fri, 17 Jan 2020 13:22:48 +0000 (14:22 +0100)]
vaapih264enc: fix log message

Before the log wasn't processed because wrong instance pointer.

4 years agoplugin: encode: Add H265 main-444 profile.
He Junyan [Fri, 21 Jun 2019 16:44:25 +0000 (00:44 +0800)]
plugin: encode: Add H265 main-444 profile.

Expose the main-444 profile to h265enc caps, when the upstream
chooses to use VUYA as input, we choose main 4:4:4 profile to encode
the frames.

4 years agolibs: encoder: h265: Consider main-444 profile when encoding.
He Junyan [Wed, 15 Jan 2020 11:36:00 +0000 (19:36 +0800)]
libs: encoder: h265: Consider main-444 profile when encoding.

Add support of main-444 profile for parameter setting and packed header
generation.

4 years agovaapiencode: DMABuf only if PRIME is available
Víctor Manuel Jáquez Leal [Wed, 15 Jan 2020 22:04:08 +0000 (23:04 +0100)]
vaapiencode: DMABuf only if PRIME is available

Add DMABuf capsfeature in encoders' allowed sinkcaps only if PRIME
memory type is available in the VA surface attributes of codec
context.

4 years agoAdd hooks/pre-commit.hook
Haihao Xiang [Thu, 16 Jan 2020 01:14:30 +0000 (09:14 +0800)]
Add hooks/pre-commit.hook

meson.build in gstreamer-vaapi requires hooks/pre-commit.hook

Copied and pasted pre-commit.hook from other gstreamer modules to make
sure gstreamer-vaapi follows the same code style

4 years agolibs: encoder: h265: Set encoder paramters base on entrypoint.
He Junyan [Thu, 26 Dec 2019 08:45:51 +0000 (16:45 +0800)]
libs: encoder: h265: Set encoder paramters base on entrypoint.

When the tune is NONE, we now can choose entrypoint freely. So the
GST_VAAPI_ENCODER_TUNE macro may not return the correct current
entrypoint.
We also delay CTU size calculation after entrypoint has been decided.

4 years agoRemove all FEI related
Víctor Manuel Jáquez Leal [Sat, 28 Dec 2019 18:18:12 +0000 (19:18 +0100)]
Remove all FEI related

FEI encoders are not actively mantained neither tested, and it is
using infrastructure that is changing and FEI is stopping this
effort.

Also it is required to rethink how FEI can be used in GStreamer.

4 years agovaapioverlay: ensure sinkpad has current buffer
U. Artie Eoff [Tue, 14 Jan 2020 19:17:49 +0000 (11:17 -0800)]
vaapioverlay: ensure sinkpad has current buffer

Use the gst_video_aggregator_pad_has_current_buffer API
to check if the current sinkpad has a queued buffer before
attempting to obtain a input buffer from the base plugin.
If the sinkpad does not have a current buffer, then it is
either not producing them yet (e.g. current time < sinkpad
start time) or it has reached EOS.

Previously, we only handled EOS case.

Example:

 gst-launch-1.0 videotestsrc num-buffers=100 \
  ! vaapipostproc ! vaapioverlay name=overlay \
  ! vaapisink videotestsrc timestamp-offset=1000000000 \
  num-buffers=100 ! video/x-raw,width=160,height=120 \
  ! overlay.

4 years agovaapioverlay: unroll the recursive call
Víctor Manuel Jáquez Leal [Tue, 14 Jan 2020 17:57:31 +0000 (18:57 +0100)]
vaapioverlay: unroll the recursive call

Recursive functions are elegant but dangerous since they might
overflow the stack. It is better to turn them into a list tranversal
if possible, as this case.

4 years agovaapioverlay: add minimal documentation
Víctor Manuel Jáquez Leal [Tue, 14 Jan 2020 17:46:49 +0000 (18:46 +0100)]
vaapioverlay: add minimal documentation

4 years agolibs: blend: simplify generator API
Víctor Manuel Jáquez Leal [Tue, 14 Jan 2020 17:25:11 +0000 (18:25 +0100)]
libs: blend: simplify generator API

Instead of using a parent structure that has to be derived by API
consumers, this change propse a simplification by using the common
pattern of GTK of passing a function pointer and user data which will
be passed as its parameter. That user data contains the state and the
function will be called to update that state.

4 years agolibs: blend: remove begin/render/end API
U. Artie Eoff [Fri, 10 Jan 2020 18:14:38 +0000 (10:14 -0800)]
libs: blend: remove begin/render/end API

This API was risky and is superseded by the surface
generator (process) API.

Resolves #219

4 years agovaapioverlay: use blend surface generator API
U. Artie Eoff [Fri, 10 Jan 2020 18:12:36 +0000 (10:12 -0800)]
vaapioverlay: use blend surface generator API

See #219

4 years agolibs: blend: add surface generator API
U. Artie Eoff [Fri, 10 Jan 2020 17:54:30 +0000 (09:54 -0800)]
libs: blend: add surface generator API

This new API allows the user to call a single method (process)
which handles the [display] lock/unlock logic internally for
them.

This API supersedes the risky begin, render, end API.
It eliminates the need for the user to call a lock method
(process_begin) before processing the input buffers
(process_render) and calling an unlock method (process_end)
afterwards.

See #219

4 years agoplugin: encode: List all possible profiles to detect input formats.
He Junyan [Mon, 23 Dec 2019 06:29:08 +0000 (14:29 +0800)]
plugin: encode: List all possible profiles to detect input formats.

The current get_profile just return one possible profile for the encode,
which is not enough.  For example, if we want to support HEVC 4:4:4
profile, the input of encode should be VYUA rather than NV12 in HEVC
main profile. So the command line:

gst-launch-1.0 videotestsrc num-buffers=200 ! capsfilter \
caps=video/x-raw,format=VUYA,width=800,height=600 ! vaapih265enc \
tune=low-power init-qp=30 ! fakesink

can not work because vaapih265enc just report NV12 in sink caps, we need
to specify the profile obviously like:

gst-launch-1.0 videotestsrc num-buffers=200 ! capsfilter \
caps=video/x-raw,format=VUYA,width=800,height=600 ! vaapih265enc \
tune=low-power init-qp=30 ! capsfilter caps=video/x-h265, \
profile=main-444 ! fakesink

The encode should have the ability to choose the profile based on input
format automatically. If the input video format is VUYA, the main-444
profile should be auto choosed.

We modify to let get_allowed_profiles of each encode sub class to return
an array of all supported profiles based on downstream's allowed caps, or
return NULL if no valid profiles specified by downstream.
If no allowed profiles found, all profiles which belong to the current
encoder's codec will be the candidates.
The function gst_vaapi_encoder_get_surface_attributes collects the surface's
attributes for that profile list we just get.

So for this case, both NV12 and VUYA should be returned.

TODO: some codec like VP9, need to implement the get_profile() function.

4 years agoplugin: util: add helper function to detect profiles in caps.
He Junyan [Wed, 8 Jan 2020 07:07:36 +0000 (15:07 +0800)]
plugin: util: add helper function to detect profiles in caps.

4 years agolibs: encoder: add a helper function to get all supported profiles
He Junyan [Wed, 8 Jan 2020 07:04:18 +0000 (15:04 +0800)]
libs: encoder: add a helper function to get all supported profiles

4 years agolibs: decoder: Don't unref null object
Seungha Yang [Mon, 13 Jan 2020 06:34:54 +0000 (15:34 +0900)]
libs: decoder: Don't unref null object

** (gst-launch-1.0:9789): CRITICAL **: 15:29:09.330:
  gst_vaapi_context_unref: assertion 'context != NULL' failed

4 years agoplugins: overlay: use proper NULL check on double pointer
U. Artie Eoff [Fri, 10 Jan 2020 17:26:44 +0000 (09:26 -0800)]
plugins: overlay: use proper NULL check on double pointer

Check the address of the variable is not NULL,
not the address of the pointer.

4 years agolibs: codedbuf: delete a useless field.
He Junyan [Wed, 8 Jan 2020 15:42:21 +0000 (23:42 +0800)]
libs: codedbuf: delete a useless field.

The context field in GstVaapiCodedBuffer is not inited correctly
and is never used, just delete it.

4 years agoplugins: add iHD driver in whitelist
Víctor Manuel Jáquez Leal [Sun, 29 Dec 2019 16:57:52 +0000 (17:57 +0100)]
plugins: add iHD driver in whitelist

4 years agolibs: encoder: modify 265 SPS header's profile compatibility flag.
He Junyan [Thu, 2 Jan 2020 13:02:40 +0000 (21:02 +0800)]
libs: encoder: modify 265 SPS header's profile compatibility flag.

Make the SPS profile compatibility flags more precisely conform to
the HEVC Spec.

4 years agotest: vaapioverlay: bail test if not available
Víctor Manuel Jáquez Leal [Mon, 6 Jan 2020 18:39:06 +0000 (19:39 +0100)]
test: vaapioverlay: bail test if not available

vaapioverlay is only registered if the VA driver support the blend
operation.

This patch only executes the test if vaapioverlay is available,
otherwise the test is bail out without raising an error.

4 years agotests: vaapioverlay: force drm backend
Víctor Manuel Jáquez Leal [Mon, 6 Jan 2020 13:53:28 +0000 (14:53 +0100)]
tests: vaapioverlay: force drm backend

4 years agolibs: blend: update to new mini-object API
Víctor Manuel Jáquez Leal [Sun, 22 Dec 2019 16:32:19 +0000 (17:32 +0100)]
libs: blend: update to new mini-object API

4 years agotests: check: add basic vaapioverlay test
U. Artie Eoff [Tue, 19 Nov 2019 21:48:22 +0000 (13:48 -0800)]
tests: check: add basic vaapioverlay test

Add test_overlay_position test to verify sink_1 input
is overlayed onto sink_0 input at the appropriate
position.

4 years agoplugins: add vaapioverlay plugin
U. Artie Eoff [Thu, 14 Nov 2019 20:03:57 +0000 (12:03 -0800)]
plugins: add vaapioverlay plugin

A plugin similar to the base compositor element but
uses VA-API VPP blend functions to accelerate the
overlay/compositing.

Simple example:

 gst-launch-1.0 -vf videotestsrc ! vaapipostproc \
  ! tee name=testsrc ! queue \
  ! vaapioverlay sink_1::xpos=300 sink_1::alpha=0.75 \
  name=overlay ! vaapisink testsrc. ! queue ! overlay.

4 years agolibs: add a vaapi blend class
U. Artie Eoff [Thu, 14 Nov 2019 20:02:19 +0000 (12:02 -0800)]
libs: add a vaapi blend class

Support for the VA-API VPP blend functions.

4 years agoplugins: base: add GstVideoAggregator subclass support
U. Artie Eoff [Thu, 14 Nov 2019 19:54:59 +0000 (11:54 -0800)]
plugins: base: add GstVideoAggregator subclass support

4 years agolibs: image: init all image fields correctly.
He Junyan [Sun, 5 Jan 2020 11:32:16 +0000 (19:32 +0800)]
libs: image: init all image fields correctly.

4 years agodoc: fix pipeline typo in vaapipostproc
Stéphane Cerveau [Mon, 6 Jan 2020 16:41:53 +0000 (17:41 +0100)]
doc: fix pipeline typo in vaapipostproc

4 years agolibs: encoder: modify 265 VPS header fields.
He Junyan [Thu, 2 Jan 2020 13:11:44 +0000 (21:11 +0800)]
libs: encoder: modify 265 VPS header fields.

vps_base_layer_internal_flag and vps_base_layer_available_flag
have been clearly defined now.

4 years agolibs: display: fix a resource leak in X11 pixmap format.
He Junyan [Wed, 1 Jan 2020 11:54:13 +0000 (19:54 +0800)]
libs: display: fix a resource leak in X11 pixmap format.

4 years agolibs: utils: delete useless gst_vaapi_profile_caps_append_encoder.
Víctor Manuel Jáquez Leal [Thu, 2 Jan 2020 17:00:21 +0000 (18:00 +0100)]
libs: utils: delete useless gst_vaapi_profile_caps_append_encoder.

4 years agolibs: encoder: get surfaces resolution the same time with formats.
He Junyan [Mon, 30 Dec 2019 06:09:17 +0000 (14:09 +0800)]
libs: encoder: get surfaces resolution the same time with formats.

We can get all the information about the video format at one shot
when we create the test context for getting the supported formats.

The current way to get the width and height ranges are inefficient,
since it calls the function gst_vaapi_profile_caps_append_encoder()
and it creates another temporal context to detect the resolution
information.

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
4 years agolibs: encoder: vp9: fix code style
Víctor Manuel Jáquez Leal [Sat, 28 Dec 2019 16:42:55 +0000 (17:42 +0100)]
libs: encoder: vp9: fix code style

4 years agolibs: encoder: set entrypoint based on tune automatically
He Junyan [Mon, 16 Dec 2019 15:19:46 +0000 (23:19 +0800)]
libs: encoder: set entrypoint based on tune automatically

Some profile, such as H265_MAIN_444 on new Intel platform, may only
support ENTRYPOINT_SLICE_ENCODE_LP entrypoint. This leads two
problems:

1. We need to specify the tune mode like `vaapih265enc tune=low-power`
   every time when we need to use this kind of profile. Or we can not
   create the encoder context successfully.

2. More seriously, we set the entrypoint to a fixed value in
   init_context_info() and so the create_test_context_config() can not
   create the test context for these profile and can not get the
   supported video formats, either.

We now change the entrypoint setting based on the tune option of the
encoder. If no tune property provided, we just choose the first
available entrypoint.

4 years agolibs: encoder: set context info profile by encoder
He Junyan [Mon, 16 Dec 2019 15:19:46 +0000 (23:19 +0800)]
libs: encoder: set context info profile by encoder

Instead of init_context_info() setting the passed profile, it is
assumed that it has to be set by each encoder.

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
4 years agolibs: context: add invalid entrypoint symbol
He Junyan [Fri, 27 Dec 2019 17:49:02 +0000 (18:49 +0100)]
libs: context: add invalid entrypoint symbol

The symbol GST_VAAPI_ENTRYPOINT_INVALID is just a representation of
zero, which was already used as an invalid value tacitly. This patch
only makes it explicit.

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
4 years agolibs: pixmap: Fix a pixmap creation crash.
He Junyan [Sat, 28 Dec 2019 17:13:29 +0000 (01:13 +0800)]
libs: pixmap: Fix a pixmap creation crash.

We use GST_VAAPI_OBJECT_NATIVE_DISPLAY with wrong parameter for x11
pixmap creation, which causes crash if we run the internal test case
of:

test-decode --pixmap

4 years agoplugin: encode: set allowed_sinkpad_caps to empty.
He Junyan [Sun, 22 Dec 2019 06:35:18 +0000 (14:35 +0800)]
plugin: encode: set allowed_sinkpad_caps to empty.

We now set encode->allowed_sinkpad_caps to NULL if we fail to get
surfaces formats. This causes two problem:
1. gst_video_encoder_proxy_getcaps use NULL as its caps parameter,
which changes its behavior. It will use encode's sinkpad template
rather than empty caps to do the clip job. So even if we fail to set
allowed_sinkpad_caps, gst_video_encoder_proxy_getcaps can still return
valid caps.
2. We should just set the allowed_sinkpad_caps once. The NULL point
make the ensure_allowed_sinkpad_caps function works again and again.

4 years agolibs: encoder: Add NULL pointer check for context when finalize.
He Junyan [Sun, 22 Dec 2019 07:22:57 +0000 (15:22 +0800)]
libs: encoder: Add NULL pointer check for context when finalize.

Context may be NULL if pipeline fail in early stage, and the
ensure_context will not be called. Need to add a pointer protection
for it.

4 years agoplugins: base: do not reset can_dmabuf
U. Artie Eoff [Fri, 20 Dec 2019 14:38:42 +0000 (06:38 -0800)]
plugins: base: do not reset can_dmabuf

Don't reset the can_dmabuf field.  This restores the
close/reset logic that existed prior to commit
ca2942176b5632e07eebac23336954f9aaf1cb26 in regards to
dmabuf support.

Plugins only call gst_vaapi_plugin_base_set_srcpad_can_dmabuf
once during startup, but may need to reset the other private
fields multiple times during negotiation.  Thus, can_dmabuf
should be exempt from the resets.

Fixes #208

4 years agoplugin: encode: Refine encode's sink caps.
He Junyan [Thu, 5 Dec 2019 16:21:12 +0000 (00:21 +0800)]
plugin: encode: Refine encode's sink caps.

The old manner to get the encode's sink caps is not correct.
Such as 264 encode, it gets:

video/x-raw(memory:VASurface),
format=(string){ ENCODED, NV12, I420, YV12, YUY2, UYVY, Y210,
P010_10LE, AYUV, Y410, Y444 }, width=(int)[ 32, 4096 ],
height=(int)[ 32, 4096 ], framerate=(fraction)[ 0/1, 2147483647/1 ];
video/x-raw(memory:DMABuf), format=(string){ I420, YV12, RGBA },
width=(int)[ 32, 4096 ], height=(int)[ 32, 4096 ],
framerate=(fraction)[ 0/1, 2147483647/1 ];
video/x-raw, format=(string){ NV12 }, width=(int)[ 32, 4096 ],
height=(int)[ 32, 4096 ], framerate=(fraction)[ 0/1, 2147483647/1 ]

where the formats for memory:VASurface and memory:DMABuf are superfluous.
All the "I420, YV12, YUY2, UYVY, Y210, RGBA" can not be really used as
input format for encoder.

We should get:
video/x-raw, format=(string){ NV12 }, width=(int)[ 32, 4096 ],
height=(int)[ 32, 4096 ], framerate=(fraction)[ 0/1, 2147483647/1 ];
video/x-raw(memory:VASurface), format=(string){ NV12 },
width=(int)[ 32, 4096 ], height=(int)[ 32, 4096 ],
framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw(memory:DMABuf),
format=(string){ NV12 }, width=(int)[ 32, 4096 ],
height=(int)[ 32, 4096 ], framerate=(fraction)[ 0/1, 2147483647/1 ]

as the correct result.

4 years agolibs: display: code clean up
Víctor Manuel Jáquez Leal [Fri, 20 Dec 2019 07:37:11 +0000 (08:37 +0100)]
libs: display: code clean up

4 years agolibs: display: refine the profile/entrypoint map.
He Junyan [Thu, 12 Dec 2019 13:34:21 +0000 (21:34 +0800)]
libs: display: refine the profile/entrypoint map.

The old way make the one config for each profile/entrypoint pair,
which is not very convenient for description the relationship
between them. One profile may contain more than one entrypoints
to within it, so a set like data structure should be more suitable.

4 years agolibs: surface: port to GstMiniObject
He Junyan [Thu, 19 Dec 2019 13:19:10 +0000 (14:19 +0100)]
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>
4 years agolibs: surface: rename create function names to init
Víctor Manuel Jáquez Leal [Thu, 19 Dec 2019 17:26:10 +0000 (18:26 +0100)]
libs: surface: rename create function names to init

There are several internal functions with 'create' name, but they
don't create any new structure, but rather it initializes that
structure. Renaming those function to reflect better their purpose.

4 years agolibs: surface: use macro accessors
Víctor Manuel Jáquez Leal [Thu, 19 Dec 2019 13:17:34 +0000 (14:17 +0100)]
libs: surface: use macro accessors

4 years agolibs: surface: fix internal documentation
Víctor Manuel Jáquez Leal [Thu, 19 Dec 2019 12:46:09 +0000 (13:46 +0100)]
libs: surface: fix internal documentation

4 years agolibs: codedbuffer: port to GstMiniObject
He Junyan [Wed, 18 Dec 2019 17:00:49 +0000 (18:00 +0100)]
libs: codedbuffer: port to GstMiniObject

GstVaapiMiniObject and GstVaapiObject are deprecated.

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

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
4 years agolibs: image: port to GstMiniObject base class
He Junyan [Wed, 18 Dec 2019 11:57:01 +0000 (12:57 +0100)]
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>
4 years agolibs: context: port to a plain C structure
He Junyan [Mon, 23 Sep 2019 17:01:22 +0000 (01:01 +0800)]
libs: context: port to a plain C structure

The GstVaapiMiniObject is obsolete and we need to replace it. This
patch turns GstVaapiContext into a plain C structure with its own
reference counting mechanism.

Also this patch removes unused overlays attributes.

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
4 years agoplugin: encode: change the dmabuf caps to all supported formats.
He Junyan [Tue, 17 Dec 2019 16:40:58 +0000 (00:40 +0800)]
plugin: encode: change the dmabuf caps to all supported formats.

The encode's dmabuf caps definition is obsolete, it can support
more formats now. Re-define it to include all supported formats
in video format map.

4 years agolibs: encoder: h264fei: remove unnecessary check
Víctor Manuel Jáquez Leal [Tue, 17 Dec 2019 16:09:37 +0000 (17:09 +0100)]
libs: encoder: h264fei: remove unnecessary check

Issue detected by Coverity

`info_to_pack.h264_slice_header` is always allocated by
gst_vaapi_feipak_h264_encode(), thus checking it to free it afterwards
in doesn't make much sense.  But it requires to be free on the error
path.

There may be a null pointer dereference, or else the comparison
against null is unnecessary.

In gst_vaapi_encoder_h264_fei_encode: All paths that lead to this null
pointer comparison already dereference the pointer earlier

4 years agolibs: encoder: h264fei: remove unnecessary assert
Víctor Manuel Jáquez Leal [Tue, 17 Dec 2019 16:05:22 +0000 (17:05 +0100)]
libs: encoder: h264fei: remove unnecessary assert

Issue detected by Coverity

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

In add_slice_headers: An unsigned value can never be less than 0

4 years agolibs: encoder: h264fei: remove unnecessary check
Víctor Manuel Jáquez Leal [Tue, 17 Dec 2019 15:57:41 +0000 (16:57 +0100)]
libs: encoder: h264fei: remove unnecessary check

Issue detected by Coverity

There may be a null pointer dereference, or else the comparison
against null is unnecessary.

In gst_vaapi_encoder_h264_fei_encode: All paths that lead to this null
pointer comparison already dereference the pointer earlier

4 years agolibs: encoder: h264fei: don't free memory on stack
Víctor Manuel Jáquez Leal [Tue, 17 Dec 2019 15:49:47 +0000 (16:49 +0100)]
libs: encoder: h264fei: don't free memory on stack

Issue detected by Coverity

`info_to_pak` variable in gst_vaapi_encoder_h264_fei_encode() is
declared in the stack, but it is free in
gst_vaapi_feienc_h264_encode() as if declared on the heap.

This patch initializes the structure and removes the free.

A non-heap pointer is placed on the free list, likely causing a crash
later.

In gst_vaapi_encoder_h264_fei_encode: Free of an address-of
expression, which can never be heap allocated.

4 years agolibs: encoder: h264fei: fix surface leak
Víctor Manuel Jáquez Leal [Tue, 17 Dec 2019 12:22:12 +0000 (13:22 +0100)]
libs: encoder: h264fei: fix surface leak

Issue detected by Coverity

If the FEI mode is not handled the created resources should be
released and return and error code.

The system resource will not be reclaimed and reused, reducing the
future availability of the resource.

In gst_vaapi_encoder_h264_fei_encode: Leak of memory or pointers to
system resources

4 years agotests: check return calling of gst_navigation_event_parse.*
Víctor Manuel Jáquez Leal [Tue, 17 Dec 2019 12:09:58 +0000 (13:09 +0100)]
tests: check return calling of gst_navigation_event_parse.*

This issue was detected by Coverity.

If the function returns an error value, the error value may be mistaken
for a normal value.

In cb_mouse_event: Value returned from a function is not checked for
errors before being used

4 years agoplugin: encode: set sink's raw caps to GST_VAAPI_FORMATS_ALL.
He Junyan [Mon, 16 Dec 2019 08:25:02 +0000 (16:25 +0800)]
plugin: encode: set sink's raw caps to GST_VAAPI_FORMATS_ALL.

Then encode plugin just supports raw formats declared in vaapi video
format map. This modification makes the template caps more precise.

4 years agoplugins: base: add GstPad param to internal helper functions
U. Artie Eoff [Thu, 14 Nov 2019 19:13:51 +0000 (11:13 -0800)]
plugins: base: add GstPad param to internal helper functions

The base plugin public API function implementations determine
which pad should be passed to the internal helper functions.
Currently, only the base plugin static sinkpad and static
srcpad are supported/used.  However, this change enables future
API functions to be added that can accept a pad (i.e. request pad)
from an element subclass (e.g. a GstVideoAggregator subclass).

4 years agoplugins: base: manage pad-specific data in a single struct
U. Artie Eoff [Tue, 12 Nov 2019 20:21:52 +0000 (12:21 -0800)]
plugins: base: manage pad-specific data in a single struct

Define a struct (GstVaapiPadPrivate) to encapsulate the
pad-specific data (i.e. buffer pool, allocator, info,
caps, etc.).

Add an interface to retrieve the data struct for a given
pad.

Finally, update the base plugin to use the data struct
throughout the implementation.

This will enable us to easily extend the base plugin in the
future to allow for N-to-1 pad subclasses (e.g. overlay/
composite).

4 years agoplugins: use plugin base macros to access pad specific data
U. Artie Eoff [Tue, 29 Oct 2019 22:13:44 +0000 (15:13 -0700)]
plugins: use plugin base macros to access pad specific data

Don't access base struct fields directly since the underlying
definition can change.  Instead, use the accessor macros.

4 years agolibs: decoder: Modify decode src's template raw formats
He Junyan [Mon, 2 Dec 2019 16:52:45 +0000 (00:52 +0800)]
libs: decoder: Modify decode src's template raw formats

We do not need to maintain a standalone list of decoder's output
template for raw formats and that is easy to make mistake(for
example, the AYVU is wrong in that list, should be VUYA).
Just use GST_VAAPI_FORMATS_ALL to replace the raw formats list for
src template.

4 years agolibs: postproc: Modify src/sink template raw formats
He Junyan [Wed, 11 Dec 2019 06:11:13 +0000 (14:11 +0800)]
libs: postproc: Modify src/sink template raw formats

We need to provide more precise template caps for postproc's src
and sink pads. The GST_VIDEO_FORMATS_ALL make all video formats
available which are really superfluous.

4 years agoDo not mix declaration and code
Thibault Saunier [Tue, 10 Dec 2019 21:40:42 +0000 (18:40 -0300)]
Do not mix declaration and code

4 years agolibs: decoder: h265: skip all pictures prior the first I-frame
Víctor Manuel Jáquez Leal [Sun, 3 Nov 2019 16:59:01 +0000 (17:59 +0100)]
libs: decoder: h265: skip all pictures prior the first I-frame

Don't try to decode until the first I-frame is received within the
currently active sequence. i965 H265 decoder don't show any artifact
but it crashes.

Fixes: #98

4 years agolibs: video-format: remove dead code
Víctor Manuel Jáquez Leal [Wed, 27 Nov 2019 00:44:05 +0000 (01:44 +0100)]
libs: video-format: remove dead code

4 years agolibs: video-format: add GST_VAAPI_FORMATS_ALL
He Junyan [Wed, 30 Oct 2019 16:59:34 +0000 (00:59 +0800)]
libs: video-format: add GST_VAAPI_FORMATS_ALL

GST_VAAPI_FORMATS_ALL collects all declared formats in video-format
as a caps template string, and make them available in caps with
memory:VASurface feature.

Fixes: #199

5 years agolibs: video-format: change GST_VIDEO_FORMAT_AYUV to VUYA.
He Junyan [Wed, 6 Nov 2019 14:37:12 +0000 (22:37 +0800)]
libs: video-format: change GST_VIDEO_FORMAT_AYUV to VUYA.

We only support VUYA format in gst vaapi now, need to correct
the mapping.

5 years agotests: check: vaapipostproc test_orientation_mouse_events
U. Artie Eoff [Wed, 9 Oct 2019 22:13:09 +0000 (15:13 -0700)]
tests: check: vaapipostproc test_orientation_mouse_events

Test that vaapipostproc properly translates mouse events
when using video-direction (orientation).

5 years agotests: check: vaapipostproc test_crop_mouse_events
U. Artie Eoff [Wed, 9 Oct 2019 17:11:54 +0000 (10:11 -0700)]
tests: check: vaapipostproc test_crop_mouse_events

Test that vaapipostproc properly translates mouse events
when cropping.

5 years agotests: check: initial unit test support
U. Artie Eoff [Tue, 8 Oct 2019 19:20:26 +0000 (12:20 -0700)]
tests: check: initial unit test support

Add minimal unit test toolchain files and a simple
vaapipostproc unit test.

5 years agotests: move examples and tests to subfolders
U. Artie Eoff [Tue, 8 Oct 2019 19:19:06 +0000 (12:19 -0700)]
tests: move examples and tests to subfolders

This makes way for adding unit (check) tests.

5 years agoRemove autotools build
Tim-Philipp Müller [Mon, 14 Oct 2019 00:01:27 +0000 (01:01 +0100)]
Remove autotools build