aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLynne <dev@lynne.ee>2024-08-30 16:42:45 +0000
committerLynne <dev@lynne.ee>2024-09-09 07:05:42 +0200
commit0a1f724bf4a252f2752a52517858744c382266b7 (patch)
tree956168ce2f698abcc407cf55c5b36cfbae06f23e
parent3de73f1262732a70f10e3d60a4f0951fd322fcfa (diff)
downloadffmpeg-0a1f724bf4a252f2752a52517858744c382266b7.tar.gz
vulkan_video: add utilities for H264 level/profile mapping
-rw-r--r--libavcodec/vulkan_video.c49
-rw-r--r--libavcodec/vulkan_video.h8
2 files changed, 57 insertions, 0 deletions
diff --git a/libavcodec/vulkan_video.c b/libavcodec/vulkan_video.c
index b9a0ed5022..a676f0332a 100644
--- a/libavcodec/vulkan_video.c
+++ b/libavcodec/vulkan_video.c
@@ -16,6 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "defs.h"
#include "libavutil/mem.h"
#include "vulkan_video.h"
@@ -158,6 +159,32 @@ int ff_vk_h264_level_to_av(StdVideoH264LevelIdc level)
}
}
+StdVideoH264LevelIdc ff_vk_h264_level_to_vk(int level_idc)
+{
+ switch (level_idc) {
+ case 10: return STD_VIDEO_H264_LEVEL_IDC_1_0;
+ case 11: return STD_VIDEO_H264_LEVEL_IDC_1_1;
+ case 12: return STD_VIDEO_H264_LEVEL_IDC_1_2;
+ case 13: return STD_VIDEO_H264_LEVEL_IDC_1_3;
+ case 20: return STD_VIDEO_H264_LEVEL_IDC_2_0;
+ case 21: return STD_VIDEO_H264_LEVEL_IDC_2_1;
+ case 22: return STD_VIDEO_H264_LEVEL_IDC_2_2;
+ case 30: return STD_VIDEO_H264_LEVEL_IDC_3_0;
+ case 31: return STD_VIDEO_H264_LEVEL_IDC_3_1;
+ case 32: return STD_VIDEO_H264_LEVEL_IDC_3_2;
+ case 40: return STD_VIDEO_H264_LEVEL_IDC_4_0;
+ case 41: return STD_VIDEO_H264_LEVEL_IDC_4_1;
+ case 42: return STD_VIDEO_H264_LEVEL_IDC_4_2;
+ case 50: return STD_VIDEO_H264_LEVEL_IDC_5_0;
+ case 51: return STD_VIDEO_H264_LEVEL_IDC_5_1;
+ case 52: return STD_VIDEO_H264_LEVEL_IDC_5_2;
+ case 60: return STD_VIDEO_H264_LEVEL_IDC_6_0;
+ case 61: return STD_VIDEO_H264_LEVEL_IDC_6_1;
+ default:
+ case 62: return STD_VIDEO_H264_LEVEL_IDC_6_2;
+ }
+}
+
int ff_vk_h265_level_to_av(StdVideoH265LevelIdc level)
{
switch (level) {
@@ -177,6 +204,28 @@ int ff_vk_h265_level_to_av(StdVideoH265LevelIdc level)
}
}
+StdVideoH264ProfileIdc ff_vk_h264_profile_to_vk(int profile)
+{
+ switch (profile) {
+ case AV_PROFILE_H264_CONSTRAINED_BASELINE: return STD_VIDEO_H264_PROFILE_IDC_BASELINE;
+ case AV_PROFILE_H264_MAIN: return STD_VIDEO_H264_PROFILE_IDC_MAIN;
+ case AV_PROFILE_H264_HIGH: return STD_VIDEO_H264_PROFILE_IDC_HIGH;
+ case AV_PROFILE_H264_HIGH_444_PREDICTIVE: return STD_VIDEO_H264_PROFILE_IDC_HIGH_444_PREDICTIVE;
+ default: return STD_VIDEO_H264_PROFILE_IDC_INVALID;
+ }
+}
+
+int ff_vk_h264_profile_to_av(StdVideoH264ProfileIdc profile)
+{
+ switch (profile) {
+ case STD_VIDEO_H264_PROFILE_IDC_BASELINE: return AV_PROFILE_H264_CONSTRAINED_BASELINE;
+ case STD_VIDEO_H264_PROFILE_IDC_MAIN: return AV_PROFILE_H264_MAIN;
+ case STD_VIDEO_H264_PROFILE_IDC_HIGH: return AV_PROFILE_H264_HIGH;
+ case STD_VIDEO_H264_PROFILE_IDC_HIGH_444_PREDICTIVE: return AV_PROFILE_H264_HIGH_444_PREDICTIVE;
+ default: return AV_PROFILE_UNKNOWN;
+ }
+}
+
int ff_vk_video_qf_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf,
VkQueueFlagBits family, VkVideoCodecOperationFlagBitsKHR caps)
{
diff --git a/libavcodec/vulkan_video.h b/libavcodec/vulkan_video.h
index 2cb9419fd8..a5f69c576c 100644
--- a/libavcodec/vulkan_video.h
+++ b/libavcodec/vulkan_video.h
@@ -66,6 +66,14 @@ int ff_vk_video_qf_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf,
int ff_vk_h264_level_to_av(StdVideoH264LevelIdc level);
int ff_vk_h265_level_to_av(StdVideoH265LevelIdc level);
+StdVideoH264LevelIdc ff_vk_h264_level_to_vk(int level_idc);
+
+/**
+ * Convert profile from/to AV to Vulkan
+ */
+StdVideoH264ProfileIdc ff_vk_h264_profile_to_vk(int profile);
+int ff_vk_h264_profile_to_av(StdVideoH264ProfileIdc profile);
+
/**
* Initialize video session, allocating and binding necessary memory.
*/