FFmpeg
vulkan_video.h
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #ifndef AVCODEC_VULKAN_VIDEO_H
20 #define AVCODEC_VULKAN_VIDEO_H
21 
22 #include "vulkan.h"
23 
24 #include <vk_video/vulkan_video_codecs_common.h>
25 
26 #define CODEC_VER_MAJ(ver) (ver >> 22)
27 #define CODEC_VER_MIN(ver) ((ver >> 12) & ((1 << 10) - 1))
28 #define CODEC_VER_PAT(ver) (ver & ((1 << 12) - 1))
29 #define CODEC_VER(ver) CODEC_VER_MAJ(ver), CODEC_VER_MIN(ver), CODEC_VER_PAT(ver)
30 
31 typedef struct FFVkVideoSession {
32  VkVideoSessionKHR session;
33  VkDeviceMemory *mem;
34  uint32_t nb_mem;
35 
37 } FFVkVideoCommon;
38 
39 /**
40  * Get pixfmt from a Vulkan format.
41  */
43 
44 /**
45  * Get aspect bits which include all planes from a VkFormat.
46  */
47 VkImageAspectFlags ff_vk_aspect_bits_from_vkfmt(VkFormat vkf);
48 
49 /**
50  * Get Vulkan's chroma subsampling from a pixfmt descriptor.
51  */
52 VkVideoChromaSubsamplingFlagBitsKHR ff_vk_subsampling_from_av_desc(const AVPixFmtDescriptor *desc);
53 
54 /**
55  * Get Vulkan's bit depth from an [8:12] integer.
56  */
57 VkVideoComponentBitDepthFlagBitsKHR ff_vk_depth_from_av_depth(int depth);
58 
59 
60 /**
61  * Convert level from Vulkan to AV.
62  */
63 int ff_vk_h264_level_to_av(StdVideoH264LevelIdc level);
64 int ff_vk_h265_level_to_av(StdVideoH265LevelIdc level);
65 
66 typedef struct FFVkVideoBuffer {
68  uint8_t *mem;
70 
71 /**
72  * Get a mapped FFVkPooledBuffer with a specific guaranteed minimum size
73  * from a pool.
74  */
75 int ff_vk_video_get_buffer(FFVulkanContext *ctx, FFVkVideoCommon *s,
76  AVBufferRef **buf, VkBufferUsageFlags usage,
77  void *create_pNext, size_t size);
78 
79 /**
80  * Initialize video session, allocating and binding necessary memory.
81  */
83  FFVkVideoCommon *common,
84  VkVideoSessionCreateInfoKHR *session_create);
85 
86 /**
87  * Free video session and required resources.
88  */
89 void ff_vk_video_common_uninit(FFVulkanContext *s, FFVkVideoCommon *common);
90 
91 #endif /* AVCODEC_VULKAN_VIDEO_H */
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
level
uint8_t level
Definition: svq3.c:204
AVBufferPool
The buffer pool.
Definition: buffer_internal.h:88
FFVkVideoBuffer
Definition: vulkan_video.h:66
normalize.log
log
Definition: normalize.py:21
FFVkVideoBuffer::buf
FFVkBuffer buf
Definition: vulkan_video.h:67
FFVkVideoSession::mem
VkDeviceMemory * mem
Definition: vulkan_video.h:33
FFVkVideoSession
Definition: vulkan_video.h:31
ff_vk_h265_level_to_av
int ff_vk_h265_level_to_av(StdVideoH265LevelIdc level)
Definition: vulkan_video.c:160
s
#define s(width, name)
Definition: cbs_vp9.c:198
ctx
AVFormatContext * ctx
Definition: movenc.c:48
ff_vk_video_get_buffer
int ff_vk_video_get_buffer(FFVulkanContext *ctx, FFVkVideoCommon *s, AVBufferRef **buf, VkBufferUsageFlags usage, void *create_pNext, size_t size)
Get a mapped FFVkPooledBuffer with a specific guaranteed minimum size from a pool.
Definition: vulkan_video.c:201
FFVkVideoSession::session
VkVideoSessionKHR session
Definition: vulkan_video.h:32
FFVkVideoBuffer::mem
uint8_t * mem
Definition: vulkan_video.h:68
FFVulkanContext
Definition: vulkan.h:228
ff_vk_pix_fmt_from_vkfmt
enum AVPixelFormat ff_vk_pix_fmt_from_vkfmt(VkFormat vkf)
Get pixfmt from a Vulkan format.
Definition: vulkan_video.c:94
ff_vk_aspect_bits_from_vkfmt
VkImageAspectFlags ff_vk_aspect_bits_from_vkfmt(VkFormat vkf)
Get aspect bits which include all planes from a VkFormat.
Definition: vulkan_video.c:102
usage
const char * usage
Definition: floatimg_cmp.c:60
vulkan.h
ff_vk_video_common_init
int ff_vk_video_common_init(void *log, FFVulkanContext *s, FFVkVideoCommon *common, VkVideoSessionCreateInfoKHR *session_create)
Initialize video session, allocating and binding necessary memory.
Definition: vulkan_video.c:279
size
int size
Definition: twinvq_data.h:10344
ff_vk_subsampling_from_av_desc
VkVideoChromaSubsamplingFlagBitsKHR ff_vk_subsampling_from_av_desc(const AVPixFmtDescriptor *desc)
Get Vulkan's chroma subsampling from a pixfmt descriptor.
Definition: vulkan_video.c:110
VkFormat
enum VkFormat VkFormat
Definition: hwcontext_stub.c:25
FFVkVideoSession::nb_mem
uint32_t nb_mem
Definition: vulkan_video.h:34
desc
const char * desc
Definition: libsvtav1.c:75
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
ff_vk_depth_from_av_depth
VkVideoComponentBitDepthFlagBitsKHR ff_vk_depth_from_av_depth(int depth)
Get Vulkan's bit depth from an [8:12] integer.
Definition: vulkan_video.c:123
FFVkBuffer
Definition: vulkan.h:95
ff_vk_h264_level_to_av
int ff_vk_h264_level_to_av(StdVideoH264LevelIdc level)
Convert level from Vulkan to AV.
Definition: vulkan_video.c:134
ff_vk_video_common_uninit
void ff_vk_video_common_uninit(FFVulkanContext *s, FFVkVideoCommon *common)
Free video session and required resources.
Definition: vulkan_video.c:259
FFVkVideoSession::buf_pool
AVBufferPool * buf_pool
Definition: vulkan_video.h:36