mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-19 06:46:38 +00:00
vkvideoutils: add GstVulkanVideoOperation enum
To differentiate a video/x-h264 caps use with a decoder or an encoder and get the correct video profile, the API expects an enum GstVulkanVideoOperation to handle this difference. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4850>
This commit is contained in:
parent
8ee0f04d8d
commit
96daac8ac7
4 changed files with 33 additions and 9 deletions
|
@ -169,7 +169,8 @@ gst_vulkan_image_buffer_pool_set_config (GstBufferPool * pool,
|
||||||
& (VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR
|
& (VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR
|
||||||
| VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR)) != 0)) {
|
| VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR)) != 0)) {
|
||||||
priv->has_profile =
|
priv->has_profile =
|
||||||
gst_vulkan_video_profile_from_caps (&priv->profile, decode_caps);
|
gst_vulkan_video_profile_from_caps (&priv->profile, decode_caps,
|
||||||
|
GST_VULKAN_VIDEO_OPERATION_DECODE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
gst_clear_caps (&decode_caps);
|
gst_clear_caps (&decode_caps);
|
||||||
|
|
|
@ -27,13 +27,14 @@
|
||||||
#if GST_VULKAN_HAVE_VIDEO_EXTENSIONS
|
#if GST_VULKAN_HAVE_VIDEO_EXTENSIONS
|
||||||
/* *INDENT-OFF* */
|
/* *INDENT-OFF* */
|
||||||
static const struct {
|
static const struct {
|
||||||
|
GstVulkanVideoOperation video_operation;
|
||||||
VkVideoCodecOperationFlagBitsKHR codec;
|
VkVideoCodecOperationFlagBitsKHR codec;
|
||||||
const char *mime;
|
const char *mime;
|
||||||
VkStructureType stype;
|
VkStructureType stype;
|
||||||
} video_codecs_map[] = {
|
} video_codecs_map[] = {
|
||||||
{ VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR, "video/x-h264",
|
{ GST_VULKAN_VIDEO_OPERATION_DECODE, VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR, "video/x-h264",
|
||||||
VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_PROFILE_INFO_KHR },
|
VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_PROFILE_INFO_KHR },
|
||||||
{ VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR, "video/x-h265",
|
{ GST_VULKAN_VIDEO_OPERATION_DECODE, VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR, "video/x-h265",
|
||||||
VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_PROFILE_INFO_KHR },
|
VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_PROFILE_INFO_KHR },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -201,6 +202,7 @@ gst_vulkan_video_profile_to_caps (const GstVulkanVideoProfile * profile)
|
||||||
* gst_vulkan_video_profile_from_caps: (skip)
|
* gst_vulkan_video_profile_from_caps: (skip)
|
||||||
* @profile: (out): the output profile
|
* @profile: (out): the output profile
|
||||||
* @caps: a #GstCaps to parse
|
* @caps: a #GstCaps to parse
|
||||||
|
* @video_operation: a supported video operation
|
||||||
*
|
*
|
||||||
* Returns: %TRUE if @caps was parsed correctly, otherwise %FALSE
|
* Returns: %TRUE if @caps was parsed correctly, otherwise %FALSE
|
||||||
*
|
*
|
||||||
|
@ -208,15 +210,17 @@ gst_vulkan_video_profile_to_caps (const GstVulkanVideoProfile * profile)
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
gst_vulkan_video_profile_from_caps (GstVulkanVideoProfile * profile,
|
gst_vulkan_video_profile_from_caps (GstVulkanVideoProfile * profile,
|
||||||
GstCaps * caps)
|
GstCaps * caps, GstVulkanVideoOperation video_operation)
|
||||||
{
|
{
|
||||||
#if GST_VULKAN_HAVE_VIDEO_EXTENSIONS
|
#if GST_VULKAN_HAVE_VIDEO_EXTENSIONS
|
||||||
const GstStructure *structure;
|
const GstStructure *structure;
|
||||||
const char *mime, *chroma_sub, *profile_str = NULL, *layout = NULL;
|
const gchar *mime, *chroma_sub, *profile_str = NULL, *layout = NULL;
|
||||||
int i, luma, chroma;
|
gint i, luma, chroma;
|
||||||
|
|
||||||
g_return_val_if_fail (GST_IS_CAPS (caps), FALSE);
|
g_return_val_if_fail (GST_IS_CAPS (caps), FALSE);
|
||||||
g_return_val_if_fail (profile, FALSE);
|
g_return_val_if_fail (profile, FALSE);
|
||||||
|
g_return_val_if_fail (video_operation < GST_VULKAN_VIDEO_OPERATION_UNKNOWN,
|
||||||
|
FALSE);
|
||||||
|
|
||||||
structure = gst_caps_get_structure (caps, 0);
|
structure = gst_caps_get_structure (caps, 0);
|
||||||
|
|
||||||
|
@ -228,7 +232,8 @@ gst_vulkan_video_profile_from_caps (GstVulkanVideoProfile * profile,
|
||||||
|
|
||||||
mime = gst_structure_get_name (structure);
|
mime = gst_structure_get_name (structure);
|
||||||
for (i = 0; i < G_N_ELEMENTS (video_codecs_map); i++) {
|
for (i = 0; i < G_N_ELEMENTS (video_codecs_map); i++) {
|
||||||
if (g_strcmp0 (video_codecs_map[i].mime, mime) == 0) {
|
if ((video_codecs_map[i].video_operation == video_operation)
|
||||||
|
&& (g_strcmp0 (video_codecs_map[i].mime, mime) == 0)) {
|
||||||
profile->profile.videoCodecOperation = video_codecs_map[i].codec;
|
profile->profile.videoCodecOperation = video_codecs_map[i].codec;
|
||||||
|
|
||||||
switch (profile->profile.videoCodecOperation) {
|
switch (profile->profile.videoCodecOperation) {
|
||||||
|
|
|
@ -67,11 +67,28 @@ struct _GstVulkanVideoCapabilities
|
||||||
gpointer _reserved[GST_PADDING];
|
gpointer _reserved[GST_PADDING];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GstVulkanVideoOperation:
|
||||||
|
* @GST_VULKAN_VIDEO_OPERATION_DECODE: decode operation
|
||||||
|
* @GST_VULKAN_VIDEO_OPERATION_ENCODE: encode operation
|
||||||
|
* @GST_VULKAN_VIDEO_OPERATION_UNKNOWN: unknown
|
||||||
|
*
|
||||||
|
* The type of video operation.
|
||||||
|
*
|
||||||
|
* Since: 1.24
|
||||||
|
*/
|
||||||
|
typedef enum {
|
||||||
|
GST_VULKAN_VIDEO_OPERATION_DECODE = 0,
|
||||||
|
GST_VULKAN_VIDEO_OPERATION_ENCODE,
|
||||||
|
GST_VULKAN_VIDEO_OPERATION_UNKNOWN,
|
||||||
|
} GstVulkanVideoOperation;
|
||||||
|
|
||||||
GST_VULKAN_API
|
GST_VULKAN_API
|
||||||
GstCaps * gst_vulkan_video_profile_to_caps (const GstVulkanVideoProfile * profile);
|
GstCaps * gst_vulkan_video_profile_to_caps (const GstVulkanVideoProfile * profile);
|
||||||
GST_VULKAN_API
|
GST_VULKAN_API
|
||||||
gboolean gst_vulkan_video_profile_from_caps (GstVulkanVideoProfile * profile,
|
gboolean gst_vulkan_video_profile_from_caps (GstVulkanVideoProfile * profile,
|
||||||
GstCaps * caps);
|
GstCaps * caps,
|
||||||
|
GstVulkanVideoOperation video_operation);
|
||||||
GST_VULKAN_API
|
GST_VULKAN_API
|
||||||
gboolean gst_vulkan_video_profile_is_valid (GstVulkanVideoProfile * profile,
|
gboolean gst_vulkan_video_profile_is_valid (GstVulkanVideoProfile * profile,
|
||||||
guint codec);
|
guint codec);
|
||||||
|
|
|
@ -144,7 +144,8 @@ GST_START_TEST (test_vulkan_profiles)
|
||||||
caps = gst_vulkan_video_profile_to_caps (&profile);
|
caps = gst_vulkan_video_profile_to_caps (&profile);
|
||||||
fail_unless (caps);
|
fail_unless (caps);
|
||||||
|
|
||||||
fail_unless (gst_vulkan_video_profile_from_caps (&profile2, caps));
|
fail_unless (gst_vulkan_video_profile_from_caps (&profile2, caps,
|
||||||
|
GST_VULKAN_VIDEO_OPERATION_DECODE));
|
||||||
gst_caps_unref (caps);
|
gst_caps_unref (caps);
|
||||||
fail_unless (profile2.profile.sType
|
fail_unless (profile2.profile.sType
|
||||||
== VK_STRUCTURE_TYPE_VIDEO_PROFILE_INFO_KHR);
|
== VK_STRUCTURE_TYPE_VIDEO_PROFILE_INFO_KHR);
|
||||||
|
|
Loading…
Reference in a new issue