[FFmpeg-cvslog] vulkan_decode: convert max level from vulkan to av for comparisons
Lynne
git at videolan.org
Fri Sep 8 07:57:23 EEST 2023
ffmpeg | branch: master | Lynne <dev at lynne.ee> | Wed Sep 6 06:15:32 2023 +0200| [398467f519b3b4e954ac9e6868358c052b407fc5] | committer: Lynne
vulkan_decode: convert max level from vulkan to av for comparisons
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=398467f519b3b4e954ac9e6868358c052b407fc5
---
libavcodec/vulkan_decode.c | 4 ++--
libavcodec/vulkan_video.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
libavcodec/vulkan_video.h | 7 +++++++
3 files changed, 54 insertions(+), 2 deletions(-)
diff --git a/libavcodec/vulkan_decode.c b/libavcodec/vulkan_decode.c
index 9a57369df7..3986330c81 100644
--- a/libavcodec/vulkan_decode.c
+++ b/libavcodec/vulkan_decode.c
@@ -837,8 +837,8 @@ static int vulkan_decode_get_profile(AVCodecContext *avctx, AVBufferRef *frames_
return AVERROR_EXTERNAL;
}
- max_level = avctx->codec_id == AV_CODEC_ID_H264 ? h264_caps.maxLevelIdc :
- avctx->codec_id == AV_CODEC_ID_H265 ? h265_caps.maxLevelIdc :
+ max_level = avctx->codec_id == AV_CODEC_ID_H264 ? ff_vk_h264_level_to_av(h264_caps.maxLevelIdc) :
+ avctx->codec_id == AV_CODEC_ID_H265 ? ff_vk_h265_level_to_av(h265_caps.maxLevelIdc) :
avctx->codec_id == AV_CODEC_ID_AV1 ? av1_caps.maxLevelIdc :
0;
diff --git a/libavcodec/vulkan_video.c b/libavcodec/vulkan_video.c
index 9a363aab02..236aa124bb 100644
--- a/libavcodec/vulkan_video.c
+++ b/libavcodec/vulkan_video.c
@@ -154,6 +154,51 @@ VkVideoComponentBitDepthFlagBitsKHR ff_vk_depth_from_av_depth(int depth)
return VK_VIDEO_COMPONENT_BIT_DEPTH_INVALID_KHR;
}
+int ff_vk_h264_level_to_av(StdVideoH264LevelIdc level)
+{
+ switch (level) {
+ case STD_VIDEO_H264_LEVEL_IDC_1_0: return 10;
+ case STD_VIDEO_H264_LEVEL_IDC_1_1: return 11;
+ case STD_VIDEO_H264_LEVEL_IDC_1_2: return 12;
+ case STD_VIDEO_H264_LEVEL_IDC_1_3: return 13;
+ case STD_VIDEO_H264_LEVEL_IDC_2_0: return 20;
+ case STD_VIDEO_H264_LEVEL_IDC_2_1: return 21;
+ case STD_VIDEO_H264_LEVEL_IDC_2_2: return 22;
+ case STD_VIDEO_H264_LEVEL_IDC_3_0: return 30;
+ case STD_VIDEO_H264_LEVEL_IDC_3_1: return 31;
+ case STD_VIDEO_H264_LEVEL_IDC_3_2: return 32;
+ case STD_VIDEO_H264_LEVEL_IDC_4_0: return 40;
+ case STD_VIDEO_H264_LEVEL_IDC_4_1: return 41;
+ case STD_VIDEO_H264_LEVEL_IDC_4_2: return 42;
+ case STD_VIDEO_H264_LEVEL_IDC_5_0: return 50;
+ case STD_VIDEO_H264_LEVEL_IDC_5_1: return 51;
+ case STD_VIDEO_H264_LEVEL_IDC_5_2: return 52;
+ case STD_VIDEO_H264_LEVEL_IDC_6_0: return 60;
+ case STD_VIDEO_H264_LEVEL_IDC_6_1: return 61;
+ default:
+ case STD_VIDEO_H264_LEVEL_IDC_6_2: return 62;
+ }
+}
+
+int ff_vk_h265_level_to_av(StdVideoH265LevelIdc level)
+{
+ switch (level) {
+ case STD_VIDEO_H265_LEVEL_IDC_1_0: return 10;
+ case STD_VIDEO_H265_LEVEL_IDC_2_0: return 20;
+ case STD_VIDEO_H265_LEVEL_IDC_2_1: return 21;
+ case STD_VIDEO_H265_LEVEL_IDC_3_0: return 30;
+ case STD_VIDEO_H265_LEVEL_IDC_3_1: return 31;
+ case STD_VIDEO_H265_LEVEL_IDC_4_0: return 40;
+ case STD_VIDEO_H265_LEVEL_IDC_4_1: return 41;
+ case STD_VIDEO_H265_LEVEL_IDC_5_0: return 50;
+ case STD_VIDEO_H265_LEVEL_IDC_5_1: return 51;
+ case STD_VIDEO_H265_LEVEL_IDC_6_0: return 60;
+ case STD_VIDEO_H265_LEVEL_IDC_6_1: return 61;
+ default:
+ case STD_VIDEO_H265_LEVEL_IDC_6_2: return 62;
+ }
+}
+
static void free_data_buf(void *opaque, uint8_t *data)
{
FFVulkanContext *ctx = opaque;
diff --git a/libavcodec/vulkan_video.h b/libavcodec/vulkan_video.h
index 183ce89bf0..b28e3fe0bd 100644
--- a/libavcodec/vulkan_video.h
+++ b/libavcodec/vulkan_video.h
@@ -71,6 +71,13 @@ VkVideoChromaSubsamplingFlagBitsKHR ff_vk_subsampling_from_av_desc(const AVPixFm
*/
VkVideoComponentBitDepthFlagBitsKHR ff_vk_depth_from_av_depth(int depth);
+
+/**
+ * Convert level from Vulkan to AV.
+ */
+int ff_vk_h264_level_to_av(StdVideoH264LevelIdc level);
+int ff_vk_h265_level_to_av(StdVideoH265LevelIdc level);
+
typedef struct FFVkVideoBuffer {
FFVkBuffer buf;
uint8_t *mem;
More information about the ffmpeg-cvslog
mailing list