FFmpeg
Loading...
Searching...
No Matches
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 "avcodec.h"
23#include "libavutil/vulkan.h"
24
25#include <vk_video/vulkan_video_codecs_common.h>
26
27#define CODEC_VER_MAJ(ver) (ver >> 22)
28#define CODEC_VER_MIN(ver) ((ver >> 12) & ((1 << 10) - 1))
29#define CODEC_VER_PAT(ver) (ver & ((1 << 12) - 1))
30#define CODEC_VER(ver) CODEC_VER_MAJ(ver), CODEC_VER_MIN(ver), CODEC_VER_PAT(ver)
31
32typedef struct FFVkVideoSession {
33 VkVideoSessionKHR session;
34 VkDeviceMemory *mem;
35 uint32_t nb_mem;
36
40 VkImageView layered_view;
41 VkImageAspectFlags layered_aspect;
43
44/**
45 * Get pixfmt from a Vulkan format.
46 */
48
49/**
50 * Get aspect bits which include all planes from a VkFormat.
51 */
52VkImageAspectFlags ff_vk_aspect_bits_from_vkfmt(VkFormat vkf);
53
54/**
55 * Get Vulkan's chroma subsampling from a pixfmt descriptor.
56 */
57VkVideoChromaSubsamplingFlagBitsKHR ff_vk_subsampling_from_av_desc(const AVPixFmtDescriptor *desc);
58
59/**
60 * Get Vulkan's bit depth from an [8:12] integer.
61 */
62VkVideoComponentBitDepthFlagBitsKHR ff_vk_depth_from_av_depth(int depth);
63
64/**
65 * Convert level from Vulkan to AV.
66 */
67int ff_vk_h264_level_to_av(StdVideoH264LevelIdc level);
68int ff_vk_h265_level_to_av(StdVideoH265LevelIdc level);
69
70StdVideoH264LevelIdc ff_vk_h264_level_to_vk(int level_idc);
71StdVideoH265LevelIdc ff_vk_h265_level_to_vk(int level_idc);
72StdVideoAV1Level ff_vk_av1_level_to_vk(int level);
73
74/**
75 * Convert profile from/to AV to Vulkan
76 */
77StdVideoH264ProfileIdc ff_vk_h264_profile_to_vk(int profile);
78StdVideoH265ProfileIdc ff_vk_h265_profile_to_vk(int profile);
79StdVideoAV1Profile ff_vk_av1_profile_to_vk(int profile);
80
81/**
82 * Creates image views for video frames.
83 */
85 VkImageView *view, VkImageAspectFlags *aspect,
86 AVVkFrame *src, VkFormat vkf, VkImageUsageFlags flags);
87
88/**
89 * Initialize video session, allocating and binding necessary memory.
90 */
92 FFVkVideoCommon *common,
93 VkVideoSessionCreateInfoKHR *session_create);
94
95/**
96 * Free video session and required resources.
97 */
99
100#endif /* AVCODEC_VULKAN_VIDEO_H */
Libavcodec external API header.
#define flags(name, subs,...)
Definition cbs_h264.c:74
#define s(width, name)
Definition cbs_vp9.c:198
enum VkFormat VkFormat
const char * desc
Definition libsvtav1.c:83
int profile
Definition mxfenc.c:2299
AVPixelFormat
Pixel format.
Definition pixfmt.h:71
A reference to a data buffer.
Definition buffer.h:82
main external API structure.
Definition avcodec.h:443
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition pixdesc.h:69
VkImageAspectFlags layered_aspect
VkDeviceMemory * mem
VkVideoSessionKHR session
AVFrame * layered_frame
AVBufferRef * dpb_hwfc_ref
VkImageView layered_view
uint8_t level
Definition svq3.c:208
#define src
Definition vp8dsp.c:248
int level_idc
Definition h264_levels.c:29
void ff_vk_video_common_uninit(FFVulkanContext *s, FFVkVideoCommon *common)
Free video session and required resources.
VkVideoComponentBitDepthFlagBitsKHR ff_vk_depth_from_av_depth(int depth)
Get Vulkan's bit depth from an [8:12] integer.
VkVideoChromaSubsamplingFlagBitsKHR ff_vk_subsampling_from_av_desc(const AVPixFmtDescriptor *desc)
Get Vulkan's chroma subsampling from a pixfmt descriptor.
int ff_vk_h265_level_to_av(StdVideoH265LevelIdc level)
StdVideoH265ProfileIdc ff_vk_h265_profile_to_vk(int profile)
int ff_vk_h264_level_to_av(StdVideoH264LevelIdc level)
Convert level from Vulkan to AV.
int ff_vk_create_view(FFVulkanContext *s, FFVkVideoCommon *common, VkImageView *view, VkImageAspectFlags *aspect, AVVkFrame *src, VkFormat vkf, VkImageUsageFlags flags)
Creates image views for video frames.
StdVideoH265LevelIdc ff_vk_h265_level_to_vk(int level_idc)
StdVideoAV1Profile ff_vk_av1_profile_to_vk(int profile)
enum AVPixelFormat ff_vk_pix_fmt_from_vkfmt(VkFormat vkf)
Get pixfmt from a Vulkan format.
int ff_vk_video_common_init(AVCodecContext *avctx, FFVulkanContext *s, FFVkVideoCommon *common, VkVideoSessionCreateInfoKHR *session_create)
Initialize video session, allocating and binding necessary memory.
StdVideoH264LevelIdc ff_vk_h264_level_to_vk(int level_idc)
StdVideoH264ProfileIdc ff_vk_h264_profile_to_vk(int profile)
Convert profile from/to AV to Vulkan.
VkImageAspectFlags ff_vk_aspect_bits_from_vkfmt(VkFormat vkf)
Get aspect bits which include all planes from a VkFormat.
StdVideoAV1Level ff_vk_av1_level_to_vk(int level)