mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-26 10:10:32 +00:00
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>
This commit is contained in:
parent
18c32272bd
commit
1f080391ed
10 changed files with 79 additions and 111 deletions
|
@ -1314,12 +1314,6 @@ need to use this function.</doc>
|
|||
<record name="VulkanCommandPoolPrivate" c:type="GstVulkanCommandPoolPrivate" disguised="1">
|
||||
<source-position filename="../subprojects/gst-plugins-bad/gst-libs/gst/vulkan/vulkan_fwd.h"/>
|
||||
</record>
|
||||
<record name="VulkanDecoder" c:type="GstVulkanDecoder" disguised="1">
|
||||
<source-position filename="../subprojects/gst-plugins-bad/gst-libs/gst/vulkan/vulkan_fwd.h"/>
|
||||
</record>
|
||||
<record name="VulkanDecoderClass" c:type="GstVulkanDecoderClass" disguised="1">
|
||||
<source-position filename="../subprojects/gst-plugins-bad/gst-libs/gst/vulkan/vulkan_fwd.h"/>
|
||||
</record>
|
||||
<class name="VulkanDescriptorCache" c:symbol-prefix="vulkan_descriptor_cache" c:type="GstVulkanDescriptorCache" version="1.18" parent="VulkanHandlePool" glib:type-name="GstVulkanDescriptorCache" glib:get-type="gst_vulkan_descriptor_cache_get_type" glib:type-struct="VulkanDescriptorCacheClass">
|
||||
<source-position filename="../subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkdescriptorcache.h"/>
|
||||
<constructor name="new" c:identifier="gst_vulkan_descriptor_cache_new" version="1.18">
|
||||
|
@ -5169,24 +5163,6 @@ surrounding elements of @element.</doc>
|
|||
</instance-parameter>
|
||||
</parameters>
|
||||
</method>
|
||||
<method name="create_decoder" c:identifier="gst_vulkan_queue_create_decoder" version="1.24" introspectable="0">
|
||||
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkqueue.c">Creates a #GstVulkanDecoder object if @codec decoding is supported by @queue</doc>
|
||||
<source-position filename="../subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkqueue.h"/>
|
||||
<return-value transfer-ownership="full" nullable="1">
|
||||
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkqueue.c">the #GstVulkanDecoder object</doc>
|
||||
<type name="VulkanDecoder" c:type="GstVulkanDecoder*"/>
|
||||
</return-value>
|
||||
<parameters>
|
||||
<instance-parameter name="queue" transfer-ownership="none">
|
||||
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkqueue.c">a #GstVulkanQueue</doc>
|
||||
<type name="VulkanQueue" c:type="GstVulkanQueue*"/>
|
||||
</instance-parameter>
|
||||
<parameter name="codec" transfer-ownership="none">
|
||||
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkqueue.c">the VkVideoCodecOperationFlagBitsKHR to decode</doc>
|
||||
<type name="guint" c:type="guint"/>
|
||||
</parameter>
|
||||
</parameters>
|
||||
</method>
|
||||
<method name="get_device" c:identifier="gst_vulkan_queue_get_device" version="1.18">
|
||||
<source-position filename="../subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkqueue.h"/>
|
||||
<return-value transfer-ownership="full" nullable="1">
|
||||
|
|
|
@ -44932,7 +44932,6 @@
|
|||
"gst_vulkan_physical_device_type_to_string",
|
||||
"gst_vulkan_present_mode_to_string",
|
||||
"gst_vulkan_queue_create_command_pool",
|
||||
"gst_vulkan_queue_create_decoder",
|
||||
"gst_vulkan_queue_flags_to_string",
|
||||
"gst_vulkan_queue_get_device",
|
||||
"gst_vulkan_queue_handle_context_query",
|
||||
|
|
|
@ -162,7 +162,7 @@ gst_vulkan_h264_decoder_open (GstVideoDecoder * decoder)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
self->decoder = gst_vulkan_queue_create_decoder (self->decode_queue,
|
||||
self->decoder = gst_vulkan_decoder_new_from_queue (self->decode_queue,
|
||||
VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR);
|
||||
if (!self->decoder) {
|
||||
GST_ELEMENT_ERROR (self, RESOURCE, NOT_FOUND,
|
||||
|
|
|
@ -220,7 +220,7 @@ gst_vulkan_h265_decoder_open (GstVideoDecoder * decoder)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
self->decoder = gst_vulkan_queue_create_decoder (self->decode_queue,
|
||||
self->decoder = gst_vulkan_decoder_new_from_queue (self->decode_queue,
|
||||
VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR);
|
||||
if (!self->decoder) {
|
||||
GST_ELEMENT_ERROR (self, RESOURCE, NOT_FOUND,
|
||||
|
|
|
@ -1310,3 +1310,72 @@ gst_vulkan_decoder_wait (GstVulkanDecoder * self)
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vulkan_decoder_new_from_queue:
|
||||
* @queue: a #GstVulkanQueue
|
||||
* @codec: (type guint): the VkVideoCodecOperationFlagBitsKHR to decode
|
||||
*
|
||||
* Creates a #GstVulkanDecoder object if @codec decoding is supported by @queue
|
||||
*
|
||||
* Returns: (transfer full) (nullable): the #GstVulkanDecoder object
|
||||
*/
|
||||
GstVulkanDecoder *
|
||||
gst_vulkan_decoder_new_from_queue (GstVulkanQueue * queue, guint codec)
|
||||
{
|
||||
GstVulkanPhysicalDevice *device;
|
||||
GstVulkanDecoder *decoder;
|
||||
guint flags, expected_flag, supported_video_ops;
|
||||
const char *extension;
|
||||
|
||||
g_return_val_if_fail (GST_IS_VULKAN_QUEUE (queue), NULL);
|
||||
|
||||
device = queue->device->physical_device;
|
||||
expected_flag = VK_QUEUE_VIDEO_DECODE_BIT_KHR;
|
||||
flags = device->queue_family_props[queue->family].queueFlags;
|
||||
supported_video_ops = device->queue_family_ops[queue->family].video;
|
||||
|
||||
if (device->properties.apiVersion < VK_MAKE_VERSION (1, 3, 238)) {
|
||||
GST_WARNING_OBJECT (queue,
|
||||
"Driver API version [%d.%d.%d] doesn't support Video extensions",
|
||||
VK_VERSION_MAJOR (device->properties.apiVersion),
|
||||
VK_VERSION_MINOR (device->properties.apiVersion),
|
||||
VK_VERSION_PATCH (device->properties.apiVersion));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch (codec) {
|
||||
case VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR:
|
||||
extension = VK_KHR_VIDEO_DECODE_H264_EXTENSION_NAME;
|
||||
break;
|
||||
case VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR:
|
||||
extension = VK_KHR_VIDEO_DECODE_H265_EXTENSION_NAME;
|
||||
break;
|
||||
default:
|
||||
GST_WARNING_OBJECT (queue, "Unsupported codec %u", codec);
|
||||
return NULL;
|
||||
}
|
||||
if ((flags & expected_flag) != expected_flag) {
|
||||
GST_WARNING_OBJECT (queue, "Queue doesn't support decoding");
|
||||
return NULL;
|
||||
}
|
||||
if ((supported_video_ops & codec) != codec) {
|
||||
GST_WARNING_OBJECT (queue, "Queue doesn't support codec %u decoding",
|
||||
codec);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(gst_vulkan_device_is_extension_enabled (queue->device,
|
||||
VK_KHR_VIDEO_QUEUE_EXTENSION_NAME)
|
||||
&& gst_vulkan_device_is_extension_enabled (queue->device,
|
||||
VK_KHR_VIDEO_DECODE_QUEUE_EXTENSION_NAME)
|
||||
&& gst_vulkan_device_is_extension_enabled (queue->device, extension)))
|
||||
return NULL;
|
||||
|
||||
decoder = g_object_new (GST_TYPE_VULKAN_DECODER, NULL);
|
||||
gst_object_ref_sink (decoder);
|
||||
decoder->queue = gst_object_ref (queue);
|
||||
decoder->codec = codec;
|
||||
|
||||
return decoder;
|
||||
}
|
||||
|
|
|
@ -33,6 +33,8 @@ G_BEGIN_DECLS
|
|||
GST_VULKAN_API
|
||||
GType gst_vulkan_decoder_get_type (void);
|
||||
|
||||
typedef struct _GstVulkanDecoder GstVulkanDecoder;
|
||||
typedef struct _GstVulkanDecoderClass GstVulkanDecoderClass;
|
||||
typedef struct _GstVulkanDecoderPicture GstVulkanDecoderPicture;
|
||||
typedef union _GstVulkanDecoderParameters GstVulkanDecoderParameters;
|
||||
|
||||
|
@ -134,6 +136,9 @@ union _GstVulkanDecoderParameters
|
|||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GstVulkanDecoder, gst_object_unref)
|
||||
|
||||
GST_VULKAN_API
|
||||
GstVulkanDecoder * gst_vulkan_decoder_new_from_queue (GstVulkanQueue * queue,
|
||||
guint codec);
|
||||
GST_VULKAN_API
|
||||
gboolean gst_vulkan_decoder_start (GstVulkanDecoder * self,
|
||||
GstVulkanVideoProfile * profile,
|
||||
|
|
|
@ -157,81 +157,6 @@ error:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vulkan_queue_create_decoder:
|
||||
* @queue: a #GstVulkanQueue
|
||||
* @codec: (type guint): the VkVideoCodecOperationFlagBitsKHR to decode
|
||||
*
|
||||
* Creates a #GstVulkanDecoder object if @codec decoding is supported by @queue
|
||||
*
|
||||
* Returns: (transfer full) (nullable): the #GstVulkanDecoder object
|
||||
*
|
||||
* Since: 1.24
|
||||
*/
|
||||
GstVulkanDecoder *
|
||||
gst_vulkan_queue_create_decoder (GstVulkanQueue * queue, guint codec)
|
||||
{
|
||||
#if GST_VULKAN_HAVE_VIDEO_EXTENSIONS
|
||||
GstVulkanPhysicalDevice *device;
|
||||
GstVulkanDecoder *decoder;
|
||||
guint flags, expected_flag, supported_video_ops;
|
||||
const char *extension;
|
||||
|
||||
g_return_val_if_fail (GST_IS_VULKAN_QUEUE (queue), NULL);
|
||||
|
||||
device = queue->device->physical_device;
|
||||
expected_flag = VK_QUEUE_VIDEO_DECODE_BIT_KHR;
|
||||
flags = device->queue_family_props[queue->family].queueFlags;
|
||||
supported_video_ops = device->queue_family_ops[queue->family].video;
|
||||
|
||||
if (device->properties.apiVersion < VK_MAKE_VERSION (1, 3, 238)) {
|
||||
GST_WARNING_OBJECT (queue,
|
||||
"Driver API version [%d.%d.%d] doesn't support Video extensions",
|
||||
VK_VERSION_MAJOR (device->properties.apiVersion),
|
||||
VK_VERSION_MINOR (device->properties.apiVersion),
|
||||
VK_VERSION_PATCH (device->properties.apiVersion));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch (codec) {
|
||||
case VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR:
|
||||
extension = VK_KHR_VIDEO_DECODE_H264_EXTENSION_NAME;
|
||||
break;
|
||||
case VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR:
|
||||
extension = VK_KHR_VIDEO_DECODE_H265_EXTENSION_NAME;
|
||||
break;
|
||||
default:
|
||||
GST_WARNING_OBJECT (queue, "Unsupported codec %u", codec);
|
||||
return NULL;
|
||||
}
|
||||
if ((flags & expected_flag) != expected_flag) {
|
||||
GST_WARNING_OBJECT (queue, "Queue doesn't support decoding");
|
||||
return NULL;
|
||||
}
|
||||
if ((supported_video_ops & codec) != codec) {
|
||||
GST_WARNING_OBJECT (queue, "Queue doesn't support codec %u decoding",
|
||||
codec);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(gst_vulkan_device_is_extension_enabled (queue->device,
|
||||
VK_KHR_VIDEO_QUEUE_EXTENSION_NAME)
|
||||
&& gst_vulkan_device_is_extension_enabled (queue->device,
|
||||
VK_KHR_VIDEO_DECODE_QUEUE_EXTENSION_NAME)
|
||||
&& gst_vulkan_device_is_extension_enabled (queue->device, extension)))
|
||||
return NULL;
|
||||
|
||||
decoder = g_object_new (GST_TYPE_VULKAN_DECODER, NULL);
|
||||
gst_object_ref_sink (decoder);
|
||||
decoder->queue = gst_object_ref (queue);
|
||||
decoder->codec = codec;
|
||||
|
||||
return decoder;
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_context_set_vulkan_queue:
|
||||
* @context: a #GstContext
|
||||
|
|
|
@ -80,15 +80,12 @@ struct _GstVulkanQueueClass
|
|||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GstVulkanQueue, gst_object_unref)
|
||||
|
||||
GST_VULKAN_API
|
||||
GST_VULKAN_API
|
||||
GstVulkanDevice * gst_vulkan_queue_get_device (GstVulkanQueue * queue);
|
||||
|
||||
GST_VULKAN_API
|
||||
GstVulkanCommandPool * gst_vulkan_queue_create_command_pool (GstVulkanQueue * queue,
|
||||
GError ** error);
|
||||
GST_VULKAN_API
|
||||
GstVulkanDecoder * gst_vulkan_queue_create_decoder (GstVulkanQueue * queue,
|
||||
guint codec);
|
||||
|
||||
GST_VULKAN_API
|
||||
void gst_vulkan_queue_submit_lock (GstVulkanQueue * queue);
|
||||
|
|
|
@ -119,9 +119,6 @@ typedef struct _GstVulkanOperation GstVulkanOperation;
|
|||
typedef struct _GstVulkanOperationClass GstVulkanOperationClass;
|
||||
typedef struct _GstVulkanOperationPrivate GstVulkanOperationPrivate;
|
||||
|
||||
typedef struct _GstVulkanDecoder GstVulkanDecoder;
|
||||
typedef struct _GstVulkanDecoderClass GstVulkanDecoderClass;
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_VULKAN_FWD_H__ */
|
||||
|
|
|
@ -329,7 +329,7 @@ GST_START_TEST (test_h264_decoder)
|
|||
return;
|
||||
}
|
||||
|
||||
dec = gst_vulkan_queue_create_decoder (video_queue,
|
||||
dec = gst_vulkan_decoder_new_from_queue (video_queue,
|
||||
VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR);
|
||||
if (!dec) {
|
||||
GST_WARNING ("Unable to create a vulkan decoder");
|
||||
|
@ -497,7 +497,7 @@ GST_START_TEST (test_h265_decoder)
|
|||
return;
|
||||
}
|
||||
|
||||
dec = gst_vulkan_queue_create_decoder (video_queue,
|
||||
dec = gst_vulkan_decoder_new_from_queue (video_queue,
|
||||
VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR);
|
||||
if (!dec) {
|
||||
GST_WARNING ("Unable to create a vulkan decoder");
|
||||
|
|
Loading…
Reference in a new issue