Commit graph

1255 commits

Author SHA1 Message Date
He Junyan
ce3bf2c2ae plugin: bufferpool: use hashmap to cache dmabuf mem-surface
The old way of refer memory by bufferproxy is not a good one, since it
make the logic error prone.

Now it is established a map between surface-bufferproxy and its GstMemory,
caching the memory bound by a surface looked for the specified surface.
2020-04-04 14:21:57 +02:00
He Junyan
7701844813 plugin: bufferpool: Delete ACQUIRE_FLAG_NO_ALLOC flag.
Delete the GST_VAAPI_VIDEO_BUFFER_POOL_ACQUIRE_FLAG_NO_ALLOC flag.
In fact, no one is using that flag, and all vaapi buffers should
have GstVaapiVideoMeta.
2020-04-04 13:47:51 +02:00
U. Artie Eoff
4913d2b595 vaapipostproc: enable HDR10 tone mapping 2020-04-03 09:23:32 -07:00
He Junyan
026c01875c libs: encoder: h265: Support MAIN 4:4:4 10 profile.
Using Y410 as the input of the encoder can generate main_444_10 bit
streams.
2020-04-02 23:01:46 +08:00
Víctor Manuel Jáquez Leal
b1f859116d vaapivideometa: remove compiler warning 2020-03-27 10:35:31 +01:00
Víctor Manuel Jáquez Leal
222dc8d7d8 vaapipostproc: deprecate format, width and size parameters
Since they should only be controlled by caps negotiation.
2020-03-20 16:07:43 +00:00
He Junyan
532a1e5509 libs,plugins: decoder: Add -intra profile support for hevc.
In hevc, we can consider the -intra profile a subset of the none
-intra profile. The -intra profiles just contain I frames and we
definitely can use the none -intra profiles's context to decode
them.

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
2020-03-20 14:57:49 +01:00
Víctor Manuel Jáquez Leal
d6bcbe47e9 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.
2020-03-17 12:49:12 +01:00
U. Artie Eoff
da008baac2 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
2020-03-06 12:08:44 +00:00
Víctor Manuel Jáquez Leal
385892dd32 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().
2020-03-05 14:18:32 +01:00
Víctor Manuel Jáquez Leal
6e65356017 vaapidecode: unlock stream if caps update fails
If caps update fail a dead lock occurs since the stream mutex is not
unlocked.
2020-03-05 13:26:38 +01:00
Víctor Manuel Jáquez Leal
164656ee1d Revert "vaapivideomemory: Store surface allocation flags."
This reverts commit dd428cc4a1 because
it rewrites the buffer size whilst surface allocation flags are
stored when allocator_params_init() is called since fab890ce.

Fix: #239
2020-02-28 11:37:06 +01:00
Víctor Manuel Jáquez Leal
fab890ceb5 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.
2020-02-23 13:12:15 +01:00
Víctor Manuel Jáquez Leal
dd428cc4a1 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.
2020-02-23 13:12:15 +01:00
U. Artie Eoff
4573d3eefe 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.
2020-02-21 08:49:06 -08:00
U. Artie Eoff
39f2c932ee 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.
2020-02-21 08:28:10 -08:00
He Junyan
15e169fbf1 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
2020-02-21 15:52:43 +00:00
Víctor Manuel Jáquez Leal
57e792136c 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.
2020-02-21 15:11:31 +00:00
Víctor Manuel Jáquez Leal
566af572af vaapipostproc: demote log message to trace level 2020-02-16 12:22:16 +00:00
Víctor Manuel Jáquez Leal
33c80bccfe vaapidecode: don't remove chroma-site nor colorimetry
Since now they can be handled by vaapipostproc.
2020-02-07 15:54:27 +01:00
U. Artie Eoff
2b6fa19665 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.
2020-02-05 10:33:23 -08:00
U. Artie Eoff
c6d8ee737f vaapipostproc: set srcpad colorimetry unconditionally
We always need a srcpad colorimetry for VAAPI VPP
operations.

Also, check the return value of _set_colorimetry.
2020-02-05 10:16:16 -08:00
U. Artie Eoff
654e824555 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).
2020-02-05 10:16:16 -08:00
U. Artie Eoff
c01f2e30d6 vaapipostproc: set vpp filter colorimetry
Set the input and output colorimetry for vpp filter.
2020-02-05 10:16:16 -08:00
Víctor Manuel Jáquez Leal
7f61ad7938 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.
2020-02-02 18:04:35 +01:00
Víctor Manuel Jáquez Leal
62f3329455 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
2020-02-02 17:22:43 +01:00
Víctor Manuel Jáquez Leal
5eca31b5e8 vaapivideobufferpool: add explanation for allocator reconfig 2020-02-02 17:22:43 +01:00
Víctor Manuel Jáquez Leal
377dd0cc6c 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.
2020-02-02 17:22:43 +01:00
Víctor Manuel Jáquez Leal
ed505f5ed4 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.
2020-02-02 17:22:43 +01:00
Víctor Manuel Jáquez Leal
4778882728 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.
2020-01-27 20:31:12 +00:00
Víctor Manuel Jáquez Leal
9fa177951e 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.
2020-01-27 19:08:37 +01:00
Víctor Manuel Jáquez Leal
ee3d4c3206 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
2020-01-24 12:21:59 +00:00
Víctor Manuel Jáquez Leal
7a186975cc plugins: renable Mesa Gallium driver 2020-01-24 12:21:59 +00:00
Víctor Manuel Jáquez Leal
0815899121 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.
2020-01-24 11:55:22 +01:00
Philipp Zabel
89f202ea2e 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().
2020-01-24 09:10:44 +00:00
Víctor Manuel Jáquez Leal
e25ef7dfc2 vaapiencode: promote info to warning
Let's notify user about using constrained-baseline instead on
requested basline profile.
2020-01-21 14:12:29 +01:00
Nicolas Dufresne
866a9f069d 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.
2020-01-19 15:55:47 +00:00
Víctor Manuel Jáquez Leal
73159cdc5d vaapih264enc: accept baseline as constrained baseline compatible 2020-01-19 15:14:14 +00:00
Víctor Manuel Jáquez Leal
9f627ef234 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.
2020-01-19 14:26:18 +00:00
Víctor Manuel Jáquez Leal
5e26efbcf2 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()
2020-01-19 14:57:04 +01:00
Philipp Zabel
d576963979 vaaph264enc: suppress avc if the driver does not support packed headers
Do not negotiate AVC output if the driver does not support it.
2020-01-19 14:57:04 +01:00
Víctor Manuel Jáquez Leal
38d7297bb6 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.
2020-01-19 12:54:02 +00:00
Víctor Manuel Jáquez Leal
8b4d18da0a 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.
2020-01-19 12:54:02 +00:00
Víctor Manuel Jáquez Leal
a56ac3bffe vaapih264enc: common fail for gst_vaapiencode_h264_set_config()
Add a common fail code path for gst_vaapiencode_h264_set_config().
2020-01-19 12:54:02 +00:00
Víctor Manuel Jáquez Leal
6eafebc804 vaapih264enc: fix log message
Before the log wasn't processed because wrong instance pointer.
2020-01-19 10:46:13 +01:00
He Junyan
25422b6766 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.
2020-01-17 11:02:44 +00:00
Víctor Manuel Jáquez Leal
1db3ce56a0 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.
2020-01-17 11:31:57 +01:00
Víctor Manuel Jáquez Leal
9da5196b5a 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.
2020-01-15 07:30:15 +00:00
U. Artie Eoff
1364070eca 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.
2020-01-14 11:37:22 -08:00
Víctor Manuel Jáquez Leal
889fac3823 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.
2020-01-14 19:52:18 +01:00