88 Commits

Author SHA1 Message Date
Víctor Manuel Jáquez Leal
5e995b2b21 vulkanh26xdec: fix discont state handling
It fixes a couple tests in fluster for H.265 decoding.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9610>
2025-08-27 11:32:32 +00:00
Víctor Manuel Jáquez Leal
fc647552fa vulkan: enable video maintenance2 for inline session parameters
.. in decoders.

Inline session parameters allows to not create session parameters handlers for
every new stream parameters (such as SPS and PPS for H.264, for example), but
instead to pass them as a chained structure in the decoding main structure. This
is completely align with GStreamer decoder base classes.

Even that the previous approach is kept, if the devices doesn't support video
maintenance2, it shows a lot of validation errors.

Also it was required to add another parameter when enabling extension to verify
if the extension is linked with a device feature and if it is enabled.

Bump Vulkan API (and driver version for both decoders and encoders) to 1.4.306

Also bumped the ABI_CHECK_TAG because the CI finally catches up with the vulkan
video symbols that are not exposed by a public header (tough they are binary
public).

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9585>
2025-08-21 05:22:19 +00:00
Víctor Manuel Jáquez Leal
48dd6aee51 vulkanh265dec: fix validation layer complain
Silence the validation VUID-VkImageMemoryBarrier2-srcAccessMask-03915

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9591>
2025-08-20 20:11:18 +02:00
Víctor Manuel Jáquez Leal
c1d0fb0165 vulkanh26xdec: fix debug category name
This is a regression from merge request !78011

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9560>
2025-08-16 16:33:14 +00:00
Víctor Manuel Jáquez Leal
9c93152599 vulkanh26xdec: re-negotiate after FLUSH
Vulkan decoders also have the same issue as VA decoders fixed in !9457, where
FLUSH event doesn't renegotiate downstream the pipeline.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9560>
2025-08-16 16:33:14 +00:00
Víctor Manuel Jáquez Leal
c84982b5c9 vulkan: fine grained access to API
This patch is the payment to my technical debt.

The symbol GST_VULKAN_HAVE_VIDEO_EXTENSIONS is defined at compilation-time if
the user requests for the usage of the Vulkan Video extensions. And we used this
symbol for anything related with Vulkan Video. But this is not the smartest
approach.

The rule should be:

- If the code allocates Vulkan Video resources, use
  GST_VULKAN_HAVE_VIDEO_EXTENSIONS

- Otherwise, use the Vulkan's guard for the used API

In this way, API version bumps will be easier.

Also, this commit marks the end of GST_VULKAN_HAVE_VIDEO_EXTENSIONS guarded code
for readability.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9492>
2025-08-08 11:48:25 +00:00
Víctor Manuel Jáquez Leal
6cfc1d383c vulkanh264enc: calculate latency with corrected framerate
Fix for the h264encoder base class in the same spirit of !9437.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9465>
2025-07-30 15:37:21 +00:00
Stéphane Cerveau
7320acdaca vkdownload: implement decide_allocation virtual method
In the case of caps change such as frame size, a new buffer pool should be
created according to this new caps via the decide_allocation() vmethod.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8931>
2025-07-23 09:45:20 +00:00
Stéphane Cerveau
d1022fb469 vkupload: fix the refactored frame copy
When refactoring the code in 743c425f64,
the wrong GstBuffer has been used to copy to,
leading to a failing frame copy.

The bug has been discovered running
elements_vkcolorconvert.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9373>
2025-07-17 15:30:25 +00:00
Víctor Manuel Jáquez Leal
41ff02c349 vulkanh264enc: add Vulkan H264 encoder
Add an element to encode h264 content using the vulkan API.

Co-authored-by: Stéphane Cerveau <scerveau@igalia.com>
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7197>
2025-07-03 13:41:32 +02:00
Víctor Manuel Jáquez Leal
d81726f8d2 vulkan: h264encoder: introduce base class
H.264 base class oriented for hardware accelerated encoders, such as Vulkan, VA
and others.

1. It can be parametrized for hardware limits, such as lists size, b-frames
   supports, etc.
2. It produces a GOP structure map [IDR, R/I/B, ...)
3. It proposes parameters set and other strucures such as bitrate limites.
   Subclases can modify those structures.
4. It calls the subclass encode virtual method implementation.

It doesn't handle rate control algorithms or other encoding quality mechanisms.

For a deeper introduction to the class there was a lighting talk in the GstConf
2024: <https://www.youtube.com/watch?v=-fQY54KHH38>

Co-authored-by: He Junyan <junyan.he@intel.com>
Co-authored-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Co-authored-by: Stéphane Cerveau <scerveau@igalia.com>
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7197>
2025-07-03 13:41:32 +02:00
Víctor Manuel Jáquez Leal
743c425f64 vulkanupload: refactor frame copy in a single function
Avoiding code duplication

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9222>
2025-06-20 11:08:17 +00:00
Víctor Manuel Jáquez Leal
bcf97b088f vulkanupload: use gst_video_frame_copy() for VulkanBuffer
There's no need of a custom copy.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9222>
2025-06-20 11:08:17 +00:00
Víctor Manuel Jáquez Leal
76f52e5f98 vkupload: use gst_buffer_find_memory() to select memory
We never implemented correctly the selection of memories in a buffer given the
plane.

This patch uses gst_buffer_find_memory() for that. The offset is checked via the
video meta either in the input and output buffers, or the default offset given
the format and size.

This patch also requests the video meta option for the output buffers.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9219>
2025-06-18 09:06:55 +00:00
Víctor Manuel Jáquez Leal
717198b38b vulkanupload: fix regression for uploading VulkanBuffer
Merge request !5651 introduced a regression for uploading VulkanBuffer. It can
be verified by

gst-launch-1.0 videotestsrc ! video/x-raw, format=NV12 ! vulkanupload ! \
  video/x-raw\(memory:VulkanBuffer\) ! fakesink

Nobody has complained about this regression, so we assume it's a very niche
use-case.

This patch solve the regression by instantiating a different buffer pool
depending on the output cap features, and configuring it accordingly.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9218>
2025-06-16 23:23:44 +00:00
Alexander Slobodeniuk
a03c4de48f elements: use set_static_metadata when it's allowed
Those strings are nice but CPU doesn't want to copy them

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8905>
2025-04-26 19:30:15 +02:00
Stéphane Cerveau
a2793a4663 vkh265dec: add main-10 support
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8282>
2025-04-10 19:58:47 +00:00
Víctor Manuel Jáquez Leal
6cf03e31bc vulkan: fix memory leak at dynamic registering
Also it cleans up a bit the code.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8639>
2025-03-14 17:13:29 +00:00
Matthew Waters
156b05d52b vulkan: plugin: add debug for why an instance fails to open
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8554>
2025-03-06 12:14:20 +00:00
Matthew Waters
9f7fe58054 vkupload: don't require that input memory count matches output memory count
It can very easily not. e.g.

videotestsrc ! video/x-raw,format=NV12 ! identity drop-allocation=true ! \
    vulkanupload ! vulkancolorconvert ! vulkansink

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8530>
2025-02-21 17:22:15 +11:00
Stéphane Cerveau
7ef98ba41d vulkan: register always vulkansink elements
vulkansink elements were enabled only if
the video extensions were present which
is breaking backward compatibility such as Android
or ios.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8488>
2025-02-17 12:00:17 +00:00
Stéphane Cerveau
6989938dd8 vksink: allow multiple device registration
As for decoders, the plugin can register multiple
device present on the system.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7011>
2025-02-10 16:13:20 +00:00
Stéphane Cerveau
3e62435755 vkh26xdec: register multiple elements
Register the multiple devices available on the system in
separate features in the registry for the vulkan decoders.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7011>
2025-02-10 16:13:20 +00:00
Stéphane Cerveau
ee7d41f76b vkh264dec: enhance interlaced content support
- Use frame_num instead of pic_num to set the long_term_pic_num
fixing 10 interlaced tests in fluster test suite: JVT-AVC_V1

- Send the slice offset only once in case of interlaced content.
Fixing 5 interlaced tests in fluster test suite: JVT-AVC_V1.

- The default value for top and bottom field flag should be 0 in the
case of a progressive content.

- Use short and long term refs helper getter method to retrieve the
reference frames according its none existing and interlaced state

- Reorganize the find_next_slot_idx code to be easier to read.

Co-authored-by: Daniel Almeida <daniel.almeida@collabora.com>
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7854>
2025-01-16 19:18:22 +00:00
Víctor Manuel Jáquez Leal
3090cefbc5 vkh264dec: enable h264 interlaced decoding
First the slot_index shall have the same value for the first and second
fields.

Also, the reference frames are only those with both fields.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7854>
2025-01-16 19:18:22 +00:00
Víctor Manuel Jáquez Leal
f5f20ce85e vkh264dec: make GstVulkanH264Picture a reference count
Thus we could re-use the same structure for interlaced fields: a single bistream,
single output buffer and single vulkan structures.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7854>
2025-01-16 19:18:21 +00:00
Stéphane Cerveau
c38a847fe1 vkh264dec: non existing picture are not refs
The non existing picture or gap picture should not be
considered as refs for vulkan decoder.

Fix fluster tests:

MR3_TANDBERG_B
MR4_TANDBERG_C
MR5_TANDBERG_C

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7854>
2025-01-16 19:18:21 +00:00
Stéphane Cerveau
538747907d vkh264dec: support h264 extended profile
Extended is identical to main but allows FMO/ASO features to be used,
and prevent using CABAC.
Using similar logic to "baseline", assume that if we support main,
we can also do extended.

This fixes the following fluster vectors, which otherwise would fail when trying to link the parsebin pad.

BA3_SVA_C
MR6_BT_B
MR7_BT_B
MR8_BT_B

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7854>
2025-01-16 19:18:21 +00:00
Mathieu Duponchelle
3de86b2b97 docs: port plugins to explicit sources
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8273>
2025-01-13 19:17:13 +01:00
Stéphane Cerveau
570c086254 vkh265dec: update only vps/sps on demand and pass pps always
As PPS can change over the stream, the pps should be always
updated to avoid missing picture parameters sets.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8124>
2025-01-08 18:50:33 +00:00
Stéphane Cerveau
73c4eb3001 vkh264dec: update only sps on demand and pass pps always
As PPS can change over the stream, the pps should be always
updated to avoid missing picture parameters sets.

See CABA3_TOSHIBA_E.264 in fluster resources.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8124>
2025-01-08 18:50:33 +00:00
Stéphane Cerveau
0dd706a420 vkutils: add gst_vulkan_ensure_element_device
In order to keep the same device across
the elements in the pipeline, use either the device id
to create the device or get the device from the context
set by the peer elements.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7843>
2024-11-15 20:32:24 +00:00
Sebastian Dröge
b7b24573ce common: Use more efficient versions of GstCapsFeatures API where possible
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7432>
2024-09-26 19:26:18 +03:00
Víctor Manuel Jáquez Leal
ef9875640e vulkanupload: honor downstream pool allocation parameters
If a downstream buffer pool is offered, vulkanupload checks its allocation
parameters to honor them. Only adds to usage the TRANSFER bits, which are
required to upload buffers.

Also, fail if the buffer pool cannot be configured with the current parameters.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7219>
2024-07-31 12:15:43 +00:00
Víctor Manuel Jáquez Leal
bff24e5ab7 vulkanupload: comment zero value usage with VK_ACCESS_NONE
Zero is used only for Vulkan version prior to 1.3, because it wasn't defined
before.

Just for readability.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7247>
2024-07-29 17:10:15 +02:00
Stéphane Cerveau
9736b9e7b7 vulkan{up,down}load: check for a graphics family queue
Vulkan queue retrieved from peer elements should be a graphics family one.
Otherwise, get a compatible queue from the given device.

Co-Authored-By: Víctor Jáquez <vjaquez@igalia.com>
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7162>
2024-07-22 15:18:35 +00:00
Víctor Manuel Jáquez Leal
cdf07cd912 vulkanh264dec: set access NONE at buffer pool allocation parameters
Since the decoding queue might not have transfer capabilities.

This change also applies to unit test.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7165>
2024-07-19 14:45:39 +02:00
Víctor Manuel Jáquez Leal
2990cc5f71 vulkan: add source pipeline stage to _operation_add_frame_barrier()
Instead of dragging the last destination pipeline stage as current barrier
source pipeline stage (which isn't a valid semantic) this patch adds a parameter
to gst_vulkan_operation_add_frame_barrier() to set the source pipeline stage to
define the barrier.

The previous logic brought problems particularly with queue transfers, when the
new queue doesn't support the stage set during a previous operation in a
different queue.

Now the operation API is closer to Vulkan semantics.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7165>
2024-07-19 14:45:39 +02:00
Víctor Manuel Jáquez Leal
dd4027388e vulkan: fix wrong stages or access in barriers
While working on !7165 we found out that some parameters for barriers were wrong
or the destination pipeline stage was too coarse.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7200>
2024-07-19 12:44:51 +02:00
Víctor Manuel Jáquez Leal
17f3a22130 vulkanupload: request storage usage for bufferpool
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6798>
2024-07-11 10:52:19 +02:00
Ruben Gonzalez
1c238aaa37 vkh265dec: Fix H.264 ref in logs
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7146>
2024-07-08 15:30:45 +02:00
Nirbheek Chauhan
8619e163bf vk-video: Fix uint64_t string format errors
With clang on macOS:

```
error: format specifies type 'long' but the argument has type 'uint64_t' (aka 'unsigned long long')
...
error: format specifies type 'unsigned long' but the argument has type 'VkImageView' (aka 'unsigned long long')
```

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7091>
2024-07-07 13:20:12 +00:00
Stéphane Cerveau
a4c976dd20 vkdecoder: support layered and non dedicated DPB
As NVIDIA Amperium. In this case the each output buffer is also a DPB,
but using a different view layer.

Still pending a validation layer issue:

VUID-VkVideoBeginCodingInfoKHR-flags-07244

Co-authored-by: Victor Jaquez <vjaquez@igalia.com>
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6954>
2024-06-19 10:37:32 +00:00
Matthew Waters
5b471311c5 vulkan: also support glslang as a shader compiler
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6980>
2024-06-01 12:41:49 +00:00
Matthew Waters
346df4cb3f vulkan: support not having glslc available for building vulkan plugin
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6980>
2024-06-01 12:41:49 +00:00
Víctor Manuel Jáquez Leal
ecf852d529 vulkanh264dec: code style fix
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6901>
2024-05-24 17:40:04 +00:00
Víctor Manuel Jáquez Leal
4a88137b2f vulkanh265dec: fix reference set
`StdVideoDecodeH265PictureInfo.flags.IsReference` refers to section 3.132 ITU-T
H.265 specification:

reference picture: A picture that is a short-term reference picture or a
long-term reference picture.

`GstH265Picture.ref` doesn't reflect this, but we need to query the NAL type of
the processed slice.

This patch fixes the validation layer error
`VUID-vkCmdBeginVideoCodingKHR-slotIndex-07239` while using the NVIDIA driver.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6901>
2024-05-24 17:40:04 +00:00
Stéphane Cerveau
ddb9b9d9ca vkdecoder: change dstmask in decoder frame barrier
Use of VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT instead of
specific VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR

Fix for VUID-vkCmdPipelineBarrier2-srcStageMask-03849

pDependencyInfo->pImageMemoryBarriers[0].srcStageMask
(VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR) is not compatible with
the queue family properties
(VK_QUEUE_GRAPHICS_BIT|VK_QUEUE_COMPUTE_BIT|VK_QUEUE_TRANSFER_BIT|
VK_QUEUE_SPARSE_BINDING_BIT|VK_QUEUE_PROTECTED_BIT) of this
command buffer. The Vulkan spec states: The srcStageMask member
of any element of the pMemoryBarriers, pBufferMemoryBarriers, or
pImageMemoryBarriers members of pDependencyInfo must only
include pipeline stages valid for the queue family that was
used to create the command pool that commandBuffer was allocated
 from (
https://www.khronos.org/registry/vulkan/specs/1.3-extensions/
html/vkspec.html#VUID-vkCmdPipelineBarrier2-srcStageMask-03849)

The frame barrier should use a compatible srcStageMask for all
the queues.

Remove reset_pipeline_stage_mask as it is redundant

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6780>
2024-05-02 18:07:25 +00:00
Stéphane Cerveau
10ce5a6857 vkh26xdec: Fix stop memory leak
The h26xdecoder 'stop' method was not called
as the vulkan h26x class rewires the video decoder
'stop' base method to its own one.

It was causing some memory leaks such as dangling parser
and dpb in h26xdecoder base class.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6782>
2024-04-30 18:51:10 +00:00
Víctor Manuel Jáquez Leal
1f080391ed vulkan: replace gst_vulkan_queue_create_decoder() with gst_vulkan_decoder_new_from_queue()
The purpose of this refactor is to hide decoding code from public API.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6723>
2024-04-26 16:24:22 +00:00