platform/upstream/gstreamer.git
4 years agolibs: encoder: h265: support ICQ/QVBR BRC
U. Artie Eoff [Wed, 4 Mar 2020 20:35:42 +0000 (12:35 -0800)]
libs: encoder: h265: support ICQ/QVBR BRC

Enable support for ICQ and QVBR bitrate control.

The code is essentially the same for h264 ICQ/QVBR support
which was added in commit 9e0c133a2403.

4 years agolibs: encoder: set VA HRD param before RC param
U. Artie Eoff [Thu, 19 Mar 2020 18:19:18 +0000 (11:19 -0700)]
libs: encoder: set VA HRD param before RC param

This is a workaround for intel-media-driver bug
https://github.com/intel/media-driver/issues/865

The driver will force the RC method to CBR for HEVCe
when it parses the HRD param.  Thus, any RC method
param submitted "prior" to the HRD param will be lost.
Therefore, VBR, ICQ and QVBR for HEVCe can't be
effectively enabled if the RC method param "precedes"
the HRD param.

To work around this issue, set the HRD param before
the RC method param so the driver will parse the RC
method param "after" the HRD param.

Afaict, other codecs in the driver (and other drivers)
do not appear to be dependent on the order of HRD and
RC param submission.

4 years agovaapijpegenc: Add a quantization quirk for iHD driver
Haihao Xiang [Mon, 25 Nov 2019 06:16:30 +0000 (14:16 +0800)]
vaapijpegenc: Add a quantization quirk for iHD driver

iHD driver shifts the value by 50 when calculating quantization for JPEG
encoding, so we should add 50 in this plugin for iHD driver too.

4 years agolibs: remove GstVaapiPixmap
Víctor Manuel Jáquez Leal [Fri, 13 Mar 2020 20:49:15 +0000 (21:49 +0100)]
libs: remove GstVaapiPixmap

GstVaapiPixmap is an abstract base class which only implementation
were GstVaapiPixmapX11. This class were used for a special type of
rendering in the tests apps, utterly unrelated in GStreamer.

Since gstreamer-vaapi is no longer a general-user wrapper for VA-API
we should remove this unused API.

This removal drops libxrender dependency.

4 years agolibs: utils: Add HEVC Main444 sting in string_of_VAProfile
He Junyan [Tue, 17 Mar 2020 10:51:19 +0000 (18:51 +0800)]
libs: utils: Add HEVC Main444 sting in string_of_VAProfile

HEVCMain444_10 is already a supported profile and misses the strings.

4 years agoplugin: don't error if cannot create display
Víctor Manuel Jáquez Leal [Tue, 17 Mar 2020 11:47:33 +0000 (12:47 +0100)]
plugin: don't error if cannot create display

This might generated errors on automatic tools such as CI. Let's
rather just raise a warning and let continue.

4 years agotest: fix a ninja test failure for vaapioverlay.
He Junyan [Sun, 8 Mar 2020 17:52:57 +0000 (01:52 +0800)]
test: fix a ninja test failure for vaapioverlay.

That test case only works with drm display, so the build such as

meson -Dwith_x11=yes -Dwith_wayland=no -Dwith_drm=no -Dwith_egl=no
-Dwith_glx=no

gets a failure when run ninja test. Just enable this test when drm
is enabled.

4 years agolibs: videopool: fix a condition race for pool allocate.
He Junyan [Fri, 7 Feb 2020 15:56:13 +0000 (23:56 +0800)]
libs: videopool: fix a condition race for pool allocate.

4 years agovaapivideobufferpool: force video meta if sizes are different
U. Artie Eoff [Thu, 5 Mar 2020 21:22:23 +0000 (13:22 -0800)]
vaapivideobufferpool: force video meta if sizes are different

The strides and offsets could be the same, but the allocation
size might be different (e.g. alignment).  Thus, ensure we also
set the flag to copy from VA memory to system memory when alloc
size differs.

Fixes #243

4 years agovaapidecode: don't set base sink caps twice
Víctor Manuel Jáquez Leal [Thu, 5 Mar 2020 13:18:32 +0000 (14:18 +0100)]
vaapidecode: don't set base sink caps twice

Base class's sink pad caps are already set when calling set_format().
There's no need to call it again in gst_vaapidecode_negotiate().

4 years agovaapidecode: unlock stream if caps update fails
Víctor Manuel Jáquez Leal [Thu, 5 Mar 2020 12:26:38 +0000 (13:26 +0100)]
vaapidecode: unlock stream if caps update fails

If caps update fail a dead lock occurs since the stream mutex is not
unlocked.

4 years agolibs: decoder: h265: parser state after update dependent slice
Xu Guangxin [Tue, 3 Mar 2020 07:24:32 +0000 (15:24 +0800)]
libs: decoder: h265: parser state after update dependent slice

If the dependent_slice_segment_flag is true, most slice info derived from last slice.
So we need check the slice type after we call populate_dependent_slice_hdr

4 years agolibs: display: force RGBA image format for i965 driver
Víctor Manuel Jáquez Leal [Sun, 16 Feb 2020 11:21:28 +0000 (12:21 +0100)]
libs: display: force RGBA image format for i965 driver

Since commit 32bf6f1e GLTextureUpload is broken because i965
doesn't report properly RGBA support. It could be possible to use RGBx
but GLTextureUpload only regotiates RGBA.

The simplest fix to this regression is adding synthetically the RGBA
format in the internal format map.

4 years agolibs: display: iterate all quirks table
Víctor Manuel Jáquez Leal [Fri, 14 Feb 2020 18:30:54 +0000 (19:30 +0100)]
libs: display: iterate all quirks table

Instead of break at the fist foud quirk in the table, iterate all over
so it would be feasible to add several quirks for one driver per
element in array.

4 years agolibs: filter: handle RGB to/from YUV color primary driver quirk
U. Artie Eoff [Tue, 25 Feb 2020 20:05:28 +0000 (12:05 -0800)]
libs: filter: handle RGB to/from YUV color primary driver quirk

The intel-media-driver (iHD) can't convert output color
primaries when doing YUV to/from RGB CSC.  Thus, we must
keep the output color primaries the same as the input
color primaries for this case.

fixes #238

4 years agolibs: display: add YUV to/from RGB color primary quirk
U. Artie Eoff [Tue, 25 Feb 2020 20:00:36 +0000 (12:00 -0800)]
libs: display: add YUV to/from RGB color primary quirk

The intel-media-driver (iHD) can't convert output color
primaries when doing YUV to/from RGB CSC.

4 years agoRevert "vaapivideomemory: Store surface allocation flags."
Víctor Manuel Jáquez Leal [Fri, 28 Feb 2020 10:33:18 +0000 (11:33 +0100)]
Revert "vaapivideomemory: Store surface allocation flags."

This reverts commit dd428cc4a12c2d5c694fcd3303811cf486002c9d because
it rewrites the buffer size whilst surface allocation flags are
stored when allocator_params_init() is called since fab890ce.

Fix: #239

4 years agovaapivideomemory: Try surface with allocation flags.
Víctor Manuel Jáquez Leal [Mon, 27 Jan 2020 17:19:57 +0000 (18:19 +0100)]
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.

4 years agovaapivideomemory: Store surface allocation flags.
Víctor Manuel Jáquez Leal [Mon, 27 Jan 2020 17:10:18 +0000 (18:10 +0100)]
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.

4 years agolibs: surface: Add hints to allocation flags.
Víctor Manuel Jáquez Leal [Fri, 24 Jan 2020 18:32:52 +0000 (19:32 +0100)]
libs: surface: Add hints to allocation flags.

When creating surfaces it is possible to pass to VA hints of its usage,
so the driver may do some optimizations.

This commit adds the handling of encoding/decoding hints.

4 years agolibs: surface: surfacepool: Add allocation flags in constructors.
Víctor Manuel Jáquez Leal [Fri, 24 Jan 2020 21:08:50 +0000 (22:08 +0100)]
libs: surface: surfacepool: Add allocation flags in constructors.

4 years agobuild: let the build fail if none if X11, wayland or drm.
He Junyan [Sat, 22 Feb 2020 08:06:13 +0000 (16:06 +0800)]
build: let the build fail if none if X11, wayland or drm.

In fact, gst_vaapi_create_test_display only test x11, wayland and
drm, no glx and egl entries. So if none of them is enabled, no
vaapi element can be detected.

4 years agotest: avoid unused warning for test-display
He Junyan [Thu, 20 Feb 2020 16:58:47 +0000 (00:58 +0800)]
test: avoid unused warning for test-display

meson -Dwith_x11=yes -Dwith_wayland=no -Dwith_drm=no -Dwith_egl=no
-Dwith_glx=no buildir

generate unused warnings.

4 years agobuild: fix meson build error when without x11.
He Junyan [Thu, 20 Feb 2020 16:50:47 +0000 (00:50 +0800)]
build: fix meson build error when without x11.

meson -Dwith_x11=no build_dir
can not success build the project because the glx is still enabled.
We need to disable GLX when X11 is disabled.

4 years agolibs: h265enc: Set max_transform_hierarchy_depth_{inter, intra} to 2
Haihao Xiang [Fri, 14 Feb 2020 11:53:09 +0000 (19:53 +0800)]
libs: h265enc: Set max_transform_hierarchy_depth_{inter, intra} to 2

Intel HW has limitation on max_transform_hierarchy_depth_inter and
max_transform_hierarchy_depth_intra (see [1]). We can provide a quirk for
other HWs if other HWs may support other values

[1] https://01.org/sites/default/files/documentation/intel-gfx-prm-osrc-kbl-vol10-hevc.pdf

4 years agovaapipostproc: do not compensate for crop/direction if no VPP
U. Artie Eoff [Fri, 21 Feb 2020 15:37:50 +0000 (07:37 -0800)]
vaapipostproc: do not compensate for crop/direction if no VPP

If we do not have functional VPP, then cropping and video
direction is non-functional and we should avoid calling
any of the gst_vaapi_filter* APIs.

4 years agovaapipostproc: only set VPP colorimetry when VPP is available
U. Artie Eoff [Fri, 21 Feb 2020 14:54:47 +0000 (06:54 -0800)]
vaapipostproc: only set VPP colorimetry when VPP is available

If we don't have functional vpp then we should not call
gst_vaapi_filter_set_colorimetry.

4 years agovideobufferpool: don't reset surface when created internally
He Junyan [Sat, 15 Feb 2020 17:25:37 +0000 (01:25 +0800)]
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

4 years agolibs: blend: filter: handle finalize() if display isn't assigned
Víctor Manuel Jáquez Leal [Sun, 16 Feb 2020 16:19:04 +0000 (17:19 +0100)]
libs: blend: filter: handle finalize() if display isn't assigned

I've just discovered iHD driver in Skylake doesn't have VideoProc
entry point, hence, in this platform, when vaapioverlay is tried to be
registered, critical warnings are raised because blend doesn't have a
display assigned.

As it is possible to have drivers without EntryPointVideoProc it is
required to handle it gracefully. This patch does that: only tries to
register vaapioverlay if the testing display has VPP and finalize()
vmethods, in filter and blend, bail out if display is NULL.

4 years agolibs: filter: guard all color properties to VA-API 1.2.0
U. Artie Eoff [Sat, 15 Feb 2020 19:02:49 +0000 (11:02 -0800)]
libs: filter: guard all color properties to VA-API 1.2.0

Older VA-API (0.39.0) doesn't have VAProcColorProperties.

Thus, guard all colorimetry -> VA-API support to version
1.2.0.

Fixes #234

4 years agolibs: decoder: h265: set parser info state at decoding codec data
Víctor Manuel Jáquez Leal [Mon, 17 Feb 2020 07:55:36 +0000 (08:55 +0100)]
libs: decoder: h265: set parser info state at decoding codec data

Commit 1168d6d5 showed up a regression: decode_sps() stores the unit's
parser info in sps array. If that parser info comes from decoding
codec data, that parser info will have an undefined state which might
break ensure_sps().

This patch sets the parser info state, at decoding codec data, with
the internal parser state. This is similar with h264 decoder apprach.

Original-patch-by: Xu Guangxin <guangxin.xu@intel.com>
4 years agovaapipostproc: demote log message to trace level
Víctor Manuel Jáquez Leal [Fri, 7 Feb 2020 14:24:18 +0000 (15:24 +0100)]
vaapipostproc: demote log message to trace level

4 years agolibs: video-format: set general vaapi log category
Víctor Manuel Jáquez Leal [Fri, 14 Feb 2020 13:45:56 +0000 (14:45 +0100)]
libs: video-format: set general vaapi log category

Instead of logging in an unspecified category, set the default vaapi.

4 years agolibs: utils: guard EncSliceLP for VA-API < 0.39.1
U. Artie Eoff [Sat, 15 Feb 2020 19:44:48 +0000 (11:44 -0800)]
libs: utils: guard EncSliceLP for VA-API < 0.39.1

Relates to #234

4 years agolibs: h265enc: Set VA_PICTURE_HEVC_INVALID flag for invalid picture
Haihao Xiang [Fri, 14 Feb 2020 08:17:04 +0000 (16:17 +0800)]
libs: h265enc: Set VA_PICTURE_HEVC_INVALID flag for invalid picture

4 years agolibs: remove crumbs of libva < 0.39
Víctor Manuel Jáquez Leal [Tue, 11 Feb 2020 10:31:31 +0000 (11:31 +0100)]
libs: remove crumbs of libva < 0.39

All these guarded code seem like leftovers of commit 920b1ec7a. This
patch completes that missing clean up.

4 years agolibs: VA explicit color standard not supported until 1.2.0
U. Artie Eoff [Tue, 11 Feb 2020 08:38:40 +0000 (00:38 -0800)]
libs: VA explicit color standard not supported until 1.2.0

VAProcColorStandardExplicit and associated VAProcColorProperties
(primaries, transfer and matrix) are not supported until
VA-API 1.2.0.

Use VAProcColorStandardNone instead of VAProcColorStandardExplicit
if VA-API < 1.2.0.

Fixes #231

4 years agolibs: utils: WA: use explicit for sRGB colorimetry
U. Artie Eoff [Mon, 10 Feb 2020 17:31:15 +0000 (09:31 -0800)]
libs: utils: WA: use explicit for sRGB colorimetry

Addresses #228 on iHD side.  It seems iHD can't handle
VAProcColorStandardSRGB in all situations for vpp.  But
it has no problem when we specify the sRGB parameters
via VAProcColorStandardExplicit parameters.

4 years agolibs: filter: set vpp input/output color range
U. Artie Eoff [Fri, 7 Feb 2020 19:25:31 +0000 (11:25 -0800)]
libs: filter: set vpp input/output color range

We've always sent VA_SOURCE_RANGE_UNKNOWN to the driver.
And, the [iHD] driver essentially computes the same color
range as gstreamer when we send VA_SOURCE_RANGE_UNKNOWN for
cases were gstreamer computes it automatically.  But,
if the user wants to make it explicit, we should try
to honor it.

4 years agolibs: utils: map GstVideoColorRange to VAAPI VPP
U. Artie Eoff [Fri, 7 Feb 2020 19:20:11 +0000 (11:20 -0800)]
libs: utils: map GstVideoColorRange to VAAPI VPP

4 years agovaapidecode: don't remove chroma-site nor colorimetry
Víctor Manuel Jáquez Leal [Fri, 7 Feb 2020 14:28:24 +0000 (15:28 +0100)]
vaapidecode: don't remove chroma-site nor colorimetry

Since now they can be handled by vaapipostproc.

4 years agovaapipostproc: use sink resolution to calculate src colorimetry
U. Artie Eoff [Tue, 4 Feb 2020 22:17:43 +0000 (14:17 -0800)]
vaapipostproc: use sink resolution to calculate src colorimetry

The default output colorimetry is persuaded by the output
resolution, which is too naive when doing VPP cropping
and/or scaling.  For example, scaling 4K(sink)->1080P(src)
resolution (i.e. both YUV) results in bt2020(sink)->bt709(src)
colorimetry selection and some drivers don't support that
mode in vpp.

Thus, if output (i.e. downstream) does not specify a
colorimetry then we use the input resolution instead of the
output resolution to create the default colorimetry.  Also,
note that we still use the output format since it may be a
different color space than the input.  As in the example
above, this will result in bt2020(sink)->bt2020(src)
colorimetry selection and all drivers (afaik) should support
that in vpp.

4 years agovaapipostproc: set srcpad colorimetry unconditionally
U. Artie Eoff [Tue, 4 Feb 2020 17:57:42 +0000 (09:57 -0800)]
vaapipostproc: set srcpad colorimetry unconditionally

We always need a srcpad colorimetry for VAAPI VPP
operations.

Also, check the return value of _set_colorimetry.

4 years agovaapipostproc: do not override explicit srcpad colorimetry
U. Artie Eoff [Thu, 30 Jan 2020 20:34:07 +0000 (12:34 -0800)]
vaapipostproc: do not override explicit srcpad colorimetry

If colorimetry has been set by a capsfilter (e.g.
vaapipostproc ! video/x-raw,colorimetry=bt709) then
don't try to override it.  Previously, the aforementioned
capsfilter will fail to negotiate if default colorimetry
is not the same as the capsfilter (e.g. 4K resolutions).

4 years agovaapipostproc: set vpp filter colorimetry
U. Artie Eoff [Thu, 30 Jan 2020 17:37:18 +0000 (09:37 -0800)]
vaapipostproc: set vpp filter colorimetry

Set the input and output colorimetry for vpp filter.

4 years agolibs: filter: support vpp input/output color standard
U. Artie Eoff [Thu, 30 Jan 2020 17:34:10 +0000 (09:34 -0800)]
libs: filter: support vpp input/output color standard

Add API function to allow setting the input and output vpp
color standard from GstVideoColorimetry.

4 years agolibs: utils: map GstVideoColorimetry to VAAPI VPP
U. Artie Eoff [Tue, 4 Feb 2020 19:32:54 +0000 (11:32 -0800)]
libs: utils: map GstVideoColorimetry to VAAPI VPP

Fallback to VAProcColorStandardExplicit if there is no
1:1 mapping.

4 years agolibs: display: add vpp color standard quirk for i965 driver
U. Artie Eoff [Tue, 4 Feb 2020 18:27:23 +0000 (10:27 -0800)]
libs: display: add vpp color standard quirk for i965 driver

The i965 does not properly report supported vpp color
standards.

4 years agovaapivideobufferpool: dmabuf implies allocator
Víctor Manuel Jáquez Leal [Sun, 2 Feb 2020 17:04:35 +0000 (18:04 +0100)]
vaapivideobufferpool: dmabuf implies allocator

Some code can be optimized since only if the dmabuf allocator is set,
the internal flag of dmabuf is TRUE, thus there's no need to evaluate
the allocator address.

4 years agovaapivideobufferpool: reject configuration if allocator isn't vaapi
Víctor Manuel Jáquez Leal [Wed, 29 Jan 2020 10:55:39 +0000 (11:55 +0100)]
vaapivideobufferpool: reject configuration if allocator isn't vaapi

If the requested allocator in set_config() is not a VAAPI valid one,
reject the configuration, instead of lying and using a private one.

This patch superseeds !254 and !24

4 years agovaapivideobufferpool: add explanation for allocator reconfig
Víctor Manuel Jáquez Leal [Wed, 29 Jan 2020 10:55:28 +0000 (11:55 +0100)]
vaapivideobufferpool: add explanation for allocator reconfig

4 years agovaapivideobufferpool: check for vaapi meta first
Víctor Manuel Jáquez Leal [Wed, 29 Jan 2020 10:54:38 +0000 (11:54 +0100)]
vaapivideobufferpool: check for vaapi meta first

If the configured meta doesn't request vaapi meta then it is not a
vaapi buffer pool. Bail out as soon as possible.

4 years agovaapivideobufferpool: turn errors into warnings
Víctor Manuel Jáquez Leal [Wed, 29 Jan 2020 10:52:38 +0000 (11:52 +0100)]
vaapivideobufferpool: turn errors into warnings

set_config() vmethod should fail gracefully, thus upstream could
negotiate another pool if possible.

Instead of sending error messages to the bus, let demote the level
to warning.

4 years agolibs: display: log out vendor string when available
Víctor Manuel Jáquez Leal [Wed, 29 Jan 2020 10:51:47 +0000 (11:51 +0100)]
libs: display: log out vendor string when available

This is useful while asking for logs to know the used driver.

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.