vkencoder: add gstvkencoder helper object

Add a gstvkencoder class to support Vulkan encoder such as H26X
formats.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6676>
This commit is contained in:
Víctor Manuel Jáquez Leal 2024-02-01 20:43:04 +01:00 committed by GStreamer Marge Bot
parent 66c1383051
commit 1b1593568f
14 changed files with 1822 additions and 34 deletions

View file

@ -2269,6 +2269,22 @@ second argument is @data.</doc>
</parameters>
</function>
</bitfield>
<record name="VulkanEncodeQueryResult" c:type="GstVulkanEncodeQueryResult" version="1.26">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkoperation.h">Encoder query result. Expected to be used in gst_vulkan_operation_get_query()</doc>
<source-position filename="../subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkoperation.h"/>
<field name="offset" writable="1">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkoperation.h">buffer offset</doc>
<type name="guint32" c:type="guint32"/>
</field>
<field name="data_size" writable="1">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkoperation.h">data size</doc>
<type name="guint32" c:type="guint32"/>
</field>
<field name="status" writable="1">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkoperation.h">status</doc>
<type name="guint32" c:type="guint32"/>
</field>
</record>
<enumeration name="VulkanError" version="1.18" glib:type-name="GstVulkanError" glib:get-type="gst_vulkan_error_get_type" c:type="GstVulkanError" glib:error-domain="gst-vulkan-error">
<member name="failed" value="0" c:identifier="GST_VULKAN_FAILED" glib:nick="failed">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkerror.h">undetermined error</doc>
@ -3515,6 +3531,24 @@ dest or DPB images.</doc>
</parameter>
</parameters>
</function>
<function name="config_set_encode_caps" c:identifier="gst_vulkan_image_buffer_pool_config_set_encode_caps" version="1.26">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkimagebufferpool.c">Encode @caps are used when the buffers are going to be used either as encoded
src or DPB images.</doc>
<source-position filename="../subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkimagebufferpool.h"/>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<parameter name="config" transfer-ownership="none">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkimagebufferpool.c">the #GstStructure with the pool's configuration.</doc>
<type name="Gst.Structure" c:type="GstStructure*"/>
</parameter>
<parameter name="caps" transfer-ownership="none">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkimagebufferpool.c">Upstream encode caps.</doc>
<type name="Gst.Caps" c:type="GstCaps*"/>
</parameter>
</parameters>
</function>
<field name="bufferpool">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkimagebufferpool.h">parent #GstBufferPool</doc>
<type name="Gst.BufferPool" c:type="GstBufferPool"/>

View file

@ -17,6 +17,7 @@ G_BEGIN_DECLS
#mesondefine GST_VULKAN_HAVE_WINDOW_WIN32
#mesondefine GST_VULKAN_HAVE_WINDOW_ANDROID
#mesondefine GST_VULKAN_HAVE_VIDEO_EXTENSIONS
#mesondefine GST_VULKAN_HAVE_VIDEO_ENCODERS
G_END_DECLS

View file

@ -191,10 +191,10 @@ gst_vulkan_device_constructed (GObject * object)
VK_KHR_VIDEO_DECODE_QUEUE_EXTENSION_NAME,
VK_KHR_VIDEO_DECODE_H264_EXTENSION_NAME,
VK_KHR_VIDEO_DECODE_H265_EXTENSION_NAME,
#ifdef VK_ENABLE_BETA_EXTENSIONS
#if GST_VULKAN_HAVE_VIDEO_ENCODERS
VK_KHR_VIDEO_ENCODE_QUEUE_EXTENSION_NAME,
VK_EXT_VIDEO_ENCODE_H264_EXTENSION_NAME,
VK_EXT_VIDEO_ENCODE_H265_EXTENSION_NAME,
VK_KHR_VIDEO_ENCODE_H264_EXTENSION_NAME,
VK_KHR_VIDEO_ENCODE_H265_EXTENSION_NAME,
#endif
#endif
};
@ -375,7 +375,7 @@ gst_vulkan_device_choose_queues (GstVulkanDevice * device)
int graph_index, comp_index, tx_index;
#if GST_VULKAN_HAVE_VIDEO_EXTENSIONS
int dec_index = -1;
#ifdef VK_ENABLE_BETA_EXTENSIONS
#if GST_VULKAN_HAVE_VIDEO_ENCODERS
int enc_index = -1;
#endif
#endif
@ -401,7 +401,7 @@ gst_vulkan_device_choose_queues (GstVulkanDevice * device)
dec_index = _pick_queue_family (queue_family_props, n_queue_families,
VK_QUEUE_VIDEO_DECODE_BIT_KHR, family_scores);
array = _append_queue_create_info (array, dec_index, queue_family_props);
#ifdef VK_ENABLE_BETA_EXTENSIONS
#if GST_VULKAN_HAVE_VIDEO_ENCODERS
enc_index = _pick_queue_family (queue_family_props, n_queue_families,
VK_QUEUE_VIDEO_ENCODE_BIT_KHR, family_scores);
array = _append_queue_create_info (array, enc_index, queue_family_props);

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,193 @@
/*
* GStreamer
* Copyright (C) 2023 Igalia, S.L.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#pragma once
#include <gst/vulkan/vulkan.h>
#define GST_TYPE_VULKAN_ENCODER (gst_vulkan_encoder_get_type())
#define GST_VULKAN_ENCODER(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GST_TYPE_VULKAN_ENCODER, GstVulkanEncoder))
#define GST_VULKAN_ENCODER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GST_TYPE_VULKAN_ENCODER, GstVulkanEncoderClass))
#define GST_IS_VULKAN_ENCODER(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GST_TYPE_VULKAN_ENCODER))
#define GST_IS_VULKAN_ENCODER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GST_TYPE_VULKAN_ENCODER))
#define GST_VULKAN_ENCODER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_TYPE_VULKAN_ENCODER, GstVulkanEncoderClass))
GST_VULKAN_API
GType gst_vulkan_encoder_get_type (void);
typedef struct _GstVulkanEncoder GstVulkanEncoder;
typedef struct _GstVulkanEncoderClass GstVulkanEncoderClass;
typedef union _GstVulkanEncoderParameters GstVulkanEncoderParameters;
typedef union _GstVulkanEncoderParametersOverrides GstVulkanEncoderParametersOverrides;
typedef union _GstVulkanEncoderParametersFeedback GstVulkanEncoderParametersFeedback;
typedef struct _GstVulkanEncodePicture GstVulkanEncodePicture;
/**
* GstVulkanEncodePicture:
* @is_ref: picture is reference
* @nb_refs: number of references
* @slotIndex: slot index
* @packed_headers: packed headers
* @pic_num: picture number
* @pic_order_cnt: order count
* @width: picture width
* @height: picture height
* @fps_n: fps numerator
* @fps_d: fps denominator
* @in_buffer: input buffer
* @out_buffer: output buffer
*
* It contains the whole state for encoding a single picture.
*
* Since: 1.24
*/
struct _GstVulkanEncodePicture
{
gboolean is_ref;
gint nb_refs;
gint slotIndex;
/* picture parameters */
GPtrArray *packed_headers;
gint pic_num;
gint pic_order_cnt;
gint width;
gint height;
gint fps_n;
gint fps_d;
GstBuffer *in_buffer;
GstBuffer *dpb_buffer;
GstBuffer *out_buffer;
/* Input frame */
GstVulkanImageView *img_view;
GstVulkanImageView *dpb_view;
VkVideoPictureResourceInfoKHR dpb;
void *codec_rc_info;
void *codec_pic_info;
void *codec_rc_layer_info;
void *codec_dpb_slot_info;
void *codec_quality_level;
};
/**
* GstVulkanEncoder:
* @parent: the parent #GstObject
* @queue: the #GstVulkanQueue to command buffers will be allocated from
*
* Since: 1.24
**/
struct _GstVulkanEncoder
{
GstObject parent;
GstVulkanQueue *queue;
guint codec;
/* <private> */
gpointer _reserved [GST_PADDING];
};
/**
* GstVulkanEncoderClass:
* @parent_class: the parent #GstObjectClass
*
* Since: 1.24
*/
struct _GstVulkanEncoderClass
{
GstObjectClass parent;
/* <private> */
gpointer _reserved [GST_PADDING];
};
union _GstVulkanEncoderParameters
{
/*< private >*/
VkVideoEncodeH264SessionParametersCreateInfoKHR h264;
VkVideoEncodeH265SessionParametersCreateInfoKHR h265;
};
union _GstVulkanEncoderParametersOverrides
{
/*< private >*/
VkVideoEncodeH264SessionParametersGetInfoKHR h264;
VkVideoEncodeH265SessionParametersGetInfoKHR h265;
};
union _GstVulkanEncoderParametersFeedback
{
VkVideoEncodeH264SessionParametersFeedbackInfoKHR h264;
VkVideoEncodeH265SessionParametersFeedbackInfoKHR h265;
};
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GstVulkanEncoder, gst_object_unref)
GST_VULKAN_API
GstVulkanEncoder * gst_vulkan_encoder_create_from_queue (GstVulkanQueue * queue,
guint codec);
GST_VULKAN_API
gboolean gst_vulkan_encoder_start (GstVulkanEncoder * self,
GstVulkanVideoProfile * profile,
guint32 out_buffer_size,
GError ** error);
GST_VULKAN_API
gboolean gst_vulkan_encoder_stop (GstVulkanEncoder * self);
GST_VULKAN_API
gboolean gst_vulkan_encoder_update_video_session_parameters
(GstVulkanEncoder * self,
GstVulkanEncoderParameters *enc_params,
GError ** error);
GST_VULKAN_API
gboolean gst_vulkan_encoder_video_session_parameters_overrides
(GstVulkanEncoder * self,
GstVulkanEncoderParametersOverrides * params,
GstVulkanEncoderParametersFeedback * feedback,
gsize * data_size,
gpointer * data,
GError ** error);
GST_VULKAN_API
gboolean gst_vulkan_encoder_create_dpb_pool (GstVulkanEncoder * self,
GstCaps * caps);
GST_VULKAN_API
gboolean gst_vulkan_encoder_encode (GstVulkanEncoder * self,
GstVulkanEncodePicture * pic,
GstVulkanEncodePicture ** ref_pics);
GST_VULKAN_API
gboolean gst_vulkan_encoder_caps (GstVulkanEncoder * self,
GstVulkanVideoCapabilities * caps);
GST_VULKAN_API
GstCaps * gst_vulkan_encoder_profile_caps (GstVulkanEncoder * self);
GST_VULKAN_API
GstVulkanEncodePicture * gst_vulkan_encode_picture_new (GstVulkanEncoder * self,
GstBuffer * in_buffer,
gint width,
gint height,
gboolean is_ref,
gint nb_refs);
GST_VULKAN_API
void gst_vulkan_encode_picture_free (GstVulkanEncodePicture * pic);

View file

@ -48,8 +48,8 @@ struct _GstVulkanImageBufferPoolPrivate
VkFormat vk_fmts[GST_VIDEO_MAX_PLANES];
int n_imgs;
guint32 n_layers;
gboolean has_profile;
GstVulkanVideoProfile profile;
guint32 n_profiles;
GstVulkanVideoProfile profiles[2];
GstVulkanOperation *exec;
};
@ -109,11 +109,30 @@ gst_vulkan_image_buffer_pool_config_set_decode_caps (GstStructure * config,
gst_structure_set (config, "decode-caps", GST_TYPE_CAPS, caps, NULL);
}
/**
* gst_vulkan_image_buffer_pool_config_set_encode_caps:
* @config: the #GstStructure with the pool's configuration.
* @caps: Upstream encode caps.
*
* Encode @caps are used when the buffers are going to be used either as encoded
* src or DPB images.
*
* Since: 1.26
*/
void
gst_vulkan_image_buffer_pool_config_set_encode_caps (GstStructure * config,
GstCaps * caps)
{
g_return_if_fail (GST_IS_CAPS (caps));
gst_structure_set (config, "encode-caps", GST_TYPE_CAPS, caps, NULL);
}
static inline gboolean
gst_vulkan_image_buffer_pool_config_get_allocation_params (GstStructure *
config, VkImageUsageFlags * usage, VkMemoryPropertyFlags * mem_props,
VkImageLayout * initial_layout, guint64 * initial_access,
guint32 * n_layers, GstCaps ** decode_caps)
guint32 * n_layers, GstCaps ** decode_caps, GstCaps ** encode_caps)
{
if (!gst_structure_get_uint (config, "usage", usage)) {
*usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT
@ -136,6 +155,9 @@ gst_vulkan_image_buffer_pool_config_get_allocation_params (GstStructure *
if (decode_caps)
gst_structure_get (config, "decode-caps", GST_TYPE_CAPS, decode_caps, NULL);
if (encode_caps)
gst_structure_get (config, "encode-caps", GST_TYPE_CAPS, encode_caps, NULL);
return TRUE;
}
@ -149,7 +171,8 @@ gst_vulkan_image_buffer_pool_set_config (GstBufferPool * pool,
VkImageUsageFlags requested_usage, supported_usage;
VkImageCreateInfo image_info;
guint min_buffers, max_buffers;
GstCaps *caps = NULL, *decode_caps = NULL;
GstCaps *caps = NULL, *decode_caps = NULL, *encode_caps = NULL;
GstCapsFeatures *features;
gboolean found, no_multiplane, ret = TRUE;
guint i;
@ -176,27 +199,37 @@ gst_vulkan_image_buffer_pool_set_config (GstBufferPool * pool,
gst_vulkan_image_buffer_pool_config_get_allocation_params (config,
&priv->usage, &priv->mem_props, &priv->initial_layout,
&priv->initial_access, &priv->n_layers, &decode_caps);
&priv->initial_access, &priv->n_layers, &decode_caps, &encode_caps);
priv->has_profile = FALSE;
#if GST_VULKAN_HAVE_VIDEO_EXTENSIONS
if (decode_caps && ((priv->usage
& (VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR
| VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR)) != 0)) {
priv->has_profile =
gst_vulkan_video_profile_from_caps (&priv->profile, decode_caps,
GST_VULKAN_VIDEO_OPERATION_DECODE);
}
{
guint n = 0;
if (decode_caps && ((priv->usage
& (VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR
| VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR)) != 0)) {
n++;
if (gst_vulkan_video_profile_from_caps (&priv->profiles[priv->n_profiles],
decode_caps, GST_VULKAN_VIDEO_OPERATION_DECODE))
priv->n_profiles++;
}
gst_clear_caps (&decode_caps);
#if GST_VULKAN_HAVE_VIDEO_ENCODERS
if (encode_caps && ((priv->usage
& (VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR
| VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR)) != 0)) {
n++;
if (gst_vulkan_video_profile_from_caps (&priv->profiles[priv->n_profiles],
encode_caps, GST_VULKAN_VIDEO_OPERATION_ENCODE))
priv->n_profiles++;
}
gst_clear_caps (&encode_caps);
#endif
gst_clear_caps (&decode_caps);
#if GST_VULKAN_HAVE_VIDEO_EXTENSIONS
if (((priv->usage & (VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR
| VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR)) != 0)
&& !priv->has_profile)
goto missing_profile;
if (priv->has_profile) {
if (priv->n_profiles != n)
goto missing_profile;
}
if (priv->n_profiles > 0) {
no_multiplane = FALSE;
/* HACK(victor): NVIDIA & RADV drivers don't report decoding features for
@ -249,10 +282,12 @@ gst_vulkan_image_buffer_pool_set_config (GstBufferPool * pool,
GstVulkanImageMemory *img_mem;
guint width, height;
#if GST_VULKAN_HAVE_VIDEO_EXTENSIONS
VkVideoProfileInfoKHR profiles[] =
{ priv->profiles[0].profile, priv->profiles[1].profile };
VkVideoProfileListInfoKHR profile_list = {
.sType = VK_STRUCTURE_TYPE_VIDEO_PROFILE_LIST_INFO_KHR,
.profileCount = 1,
.pProfiles = &priv->profile.profile,
.profileCount = priv->n_profiles,
.pProfiles = profiles,
};
#endif
@ -269,7 +304,7 @@ gst_vulkan_image_buffer_pool_set_config (GstBufferPool * pool,
image_info.extent = (VkExtent3D) { width, height, 1 };
/* *INDENT-ON* */
#if GST_VULKAN_HAVE_VIDEO_EXTENSIONS
if (priv->has_profile)
if (priv->n_profiles > 0)
image_info.pNext = &profile_list;
#endif
@ -456,10 +491,12 @@ gst_vulkan_image_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
GstMemory *mem;
guint width, height;
#if GST_VULKAN_HAVE_VIDEO_EXTENSIONS
VkVideoProfileInfoKHR profiles[] =
{ priv->profiles[0].profile, priv->profiles[1].profile };
VkVideoProfileListInfoKHR profile_list = {
.sType = VK_STRUCTURE_TYPE_VIDEO_PROFILE_LIST_INFO_KHR,
.profileCount = 1,
.pProfiles = &priv->profile.profile,
.profileCount = priv->n_profiles,
.pProfiles = profiles,
};
#endif
@ -476,7 +513,7 @@ gst_vulkan_image_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
image_info.extent = (VkExtent3D) { width, height, 1 };
/* *INDENT-ON* */
#if GST_VULKAN_HAVE_VIDEO_EXTENSIONS
if (priv->has_profile)
if (priv->n_profiles > 0)
image_info.pNext = &profile_list;
#endif

View file

@ -93,6 +93,11 @@ void gst_vulkan_image_buffer_pool_config_set_decode_caps
(GstStructure * config,
GstCaps * caps);
GST_VULKAN_API
void gst_vulkan_image_buffer_pool_config_set_encode_caps
(GstStructure * config,
GstCaps * caps);
G_END_DECLS
#endif /* __GST_VULKAN_IMAGE_BUFFER_POOL_H__ */

View file

@ -1249,7 +1249,14 @@ gst_vulkan_operation_enable_query (GstVulkanOperation * self,
if (priv->has_video)
stride = sizeof (guint32);
break;
#if GST_VULKAN_HAVE_VIDEO_ENCODERS
case VK_QUERY_TYPE_VIDEO_ENCODE_FEEDBACK_KHR:
if (priv->has_video)
stride = sizeof (GstVulkanEncodeQueryResult);
break;
#endif
#endif
default:
break;
}
@ -1291,7 +1298,11 @@ gst_vulkan_operation_get_query (GstVulkanOperation * self, gpointer * result,
#if GST_VULKAN_HAVE_VIDEO_EXTENSIONS
if (priv->has_video
&& (priv->query_type == VK_QUERY_TYPE_RESULT_STATUS_ONLY_KHR)) {
&& (priv->query_type == VK_QUERY_TYPE_RESULT_STATUS_ONLY_KHR
#if GST_VULKAN_HAVE_VIDEO_ENCODERS
|| priv->query_type == VK_QUERY_TYPE_VIDEO_ENCODE_FEEDBACK_KHR
#endif
)) {
flags |= VK_QUERY_RESULT_WITH_STATUS_BIT_KHR;
}
#endif

View file

@ -63,6 +63,23 @@ struct _GstVulkanOperationClass
};
/**
* GstVulkanEncodeQueryResult:
* @offset: buffer offset
* @data_size: data size
* @status: status
*
* Encoder query result. Expected to be used in gst_vulkan_operation_get_query()
*
* Since: 1.26
*/
struct _GstVulkanEncodeQueryResult
{
guint32 offset;
guint32 data_size;
guint32 status;
};
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GstVulkanOperation, gst_object_unref)
GST_VULKAN_API

View file

@ -37,6 +37,12 @@ const VkExtensionProperties _vk_codec_extensions[] = {
.extensionName = VK_STD_VULKAN_VIDEO_CODEC_H265_DECODE_EXTENSION_NAME,
.specVersion = VK_STD_VULKAN_VIDEO_CODEC_H265_DECODE_SPEC_VERSION,
},
#if GST_VULKAN_HAVE_VIDEO_ENCODERS
[GST_VK_VIDEO_EXTENSION_ENCODE_H264] = {
.extensionName = VK_STD_VULKAN_VIDEO_CODEC_H264_ENCODE_EXTENSION_NAME,
.specVersion = VK_STD_VULKAN_VIDEO_CODEC_H264_ENCODE_SPEC_VERSION,
},
#endif
};
const VkComponentMapping _vk_identity_component_map = {
@ -66,6 +72,9 @@ gst_vulkan_video_get_vk_functions (GstVulkanInstance * instance,
} \
} G_STMT_END;
GST_VULKAN_VIDEO_FN_LIST (GET_PROC_ADDRESS_REQUIRED)
#if GST_VULKAN_HAVE_VIDEO_ENCODERS
GST_VULKAN_VIDEO_ENCODING_FN_LIST (GET_PROC_ADDRESS_REQUIRED)
#endif
#undef GET_PROC_ADDRESS_REQUIRED
ret = TRUE;

View file

@ -43,6 +43,8 @@ struct _GstVulkanVideoSession
typedef enum {
GST_VK_VIDEO_EXTENSION_DECODE_H264,
GST_VK_VIDEO_EXTENSION_DECODE_H265,
GST_VK_VIDEO_EXTENSION_ENCODE_H264,
GST_VK_VIDEO_EXTENSION_ENCODE_H265,
} GST_VK_VIDEO_EXTENSIONS;
#define GST_VULKAN_VIDEO_FN_LIST(V) \
@ -61,14 +63,23 @@ typedef enum {
V(CmdEndVideoCoding) \
V(CmdDecodeVideo)
#if GST_VULKAN_HAVE_VIDEO_ENCODERS
#define GST_VULKAN_VIDEO_ENCODING_FN_LIST(V) \
V(CmdEncodeVideo) \
V(GetEncodedVideoSessionParameters)
#endif
struct _GstVulkanVideoFunctions
{
#define DEFINE_FUNCTION(name) G_PASTE(G_PASTE(PFN_vk, name), KHR) name;
GST_VULKAN_VIDEO_FN_LIST (DEFINE_FUNCTION)
#if GST_VULKAN_HAVE_VIDEO_ENCODERS
GST_VULKAN_VIDEO_ENCODING_FN_LIST (DEFINE_FUNCTION)
#endif
#undef DEFINE_FUNCTION
};
extern const VkExtensionProperties _vk_codec_extensions[2];
extern const VkExtensionProperties _vk_codec_extensions[3];
extern const VkComponentMapping _vk_identity_component_map;
gboolean gst_vulkan_video_get_vk_functions (GstVulkanInstance * instance,

View file

@ -39,6 +39,9 @@ struct _GstVulkanVideoProfile
VkVideoProfileInfoKHR profile;
union {
VkVideoDecodeUsageInfoKHR decode;
#if GST_VULKAN_HAVE_VIDEO_ENCODERS
VkVideoEncodeUsageInfoKHR encode;
#endif
} usage;
union {
@ -65,6 +68,10 @@ struct _GstVulkanVideoCapabilities
VkBaseInStructure base;
VkVideoDecodeH264CapabilitiesKHR h264dec;
VkVideoDecodeH265CapabilitiesKHR h265dec;
#if GST_VULKAN_HAVE_VIDEO_ENCODERS
VkVideoEncodeH264CapabilitiesKHR h264enc;
VkVideoEncodeH265CapabilitiesKHR h265enc;
#endif
} codec;
#endif
gpointer _reserved[GST_PADDING];

View file

@ -100,6 +100,7 @@ vulkan_conf_options = [
'GST_VULKAN_HAVE_WINDOW_WIN32',
'GST_VULKAN_HAVE_WINDOW_ANDROID',
'GST_VULKAN_HAVE_VIDEO_EXTENSIONS',
'GST_VULKAN_HAVE_VIDEO_ENCODERS',
]
foreach option : vulkan_conf_options
@ -337,6 +338,29 @@ static StdVideoH265PictureParameterSet h265_pps;
'gstvkvideo-private.c',
'gstvkdecoder-private.c',
)
encoder_test = '''
#include <vulkan/vulkan.h>
#if !(defined(VERSION_1_4) || (defined(VK_VERSION_1_3) && VK_HEADER_VERSION >= 275))
#error "Need at least Vulkan 1.3.275"
#endif
static VkVideoEncodeH264ProfileInfoKHR h264_profile;
static VkVideoEncodeH265ProfileInfoKHR h265_profile;
'''
if vulkan_inc_dir != ''
have_vk_encoder = cc.compiles(encoder_test, dependencies : vulkan_dep, args: '-I' + vulkan_inc_dir)
else
have_vk_encoder = cc.compiles(encoder_test, dependencies : vulkan_dep)
endif
if have_vk_encoder
vulkan_conf.set('GST_VULKAN_HAVE_VIDEO_ENCODERS', 1)
vulkan_sources += files(
'gstvkencoder-private.c',
)
endif
elif get_option('vulkan-video').enabled()
error('Vulkan Video extensions headers not found')
endif

View file

@ -118,6 +118,7 @@ typedef struct _GstVulkanVideoCapabilities GstVulkanVideoCapabilities;
typedef struct _GstVulkanOperation GstVulkanOperation;
typedef struct _GstVulkanOperationClass GstVulkanOperationClass;
typedef struct _GstVulkanOperationPrivate GstVulkanOperationPrivate;
typedef struct _GstVulkanEncodeQueryResult GstVulkanEncodeQueryResult;
G_END_DECLS