mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
lavc: add hevc_vulkan hardware encoder
This commit adds a Vulkan hardware HEVC encoder, with full support of the spec - I, P, and B-frames.
This commit is contained in:
parent
b4283f93e1
commit
4b4f0b68f8
1
configure
vendored
1
configure
vendored
@ -3388,6 +3388,7 @@ hevc_rkmpp_decoder_deps="rkmpp"
|
||||
hevc_rkmpp_decoder_select="hevc_mp4toannexb_bsf"
|
||||
hevc_vaapi_encoder_deps="VAEncPictureParameterBufferHEVC"
|
||||
hevc_vaapi_encoder_select="atsc_a53 cbs_h265 vaapi_encode"
|
||||
hevc_vulkan_encoder_select="atsc_a53 cbs_h265 vulkan_encode"
|
||||
hevc_v4l2m2m_decoder_deps="v4l2_m2m hevc_v4l2_m2m"
|
||||
hevc_v4l2m2m_decoder_select="hevc_mp4toannexb_bsf"
|
||||
hevc_v4l2m2m_encoder_deps="v4l2_m2m hevc_v4l2_m2m"
|
||||
|
@ -452,6 +452,9 @@ OBJS-$(CONFIG_HEVC_QSV_ENCODER) += qsvenc_hevc.o hevc/ps_enc.o
|
||||
OBJS-$(CONFIG_HEVC_RKMPP_DECODER) += rkmppdec.o
|
||||
OBJS-$(CONFIG_HEVC_VAAPI_ENCODER) += vaapi_encode_h265.o h265_profile_level.o \
|
||||
h2645data.o hw_base_encode_h265.o
|
||||
OBJS-$(CONFIG_HEVC_VULKAN_ENCODER) += vulkan_encode.o vulkan_encode_h265.o \
|
||||
hw_base_encode.o hw_base_encode_h265.o \
|
||||
h265_profile_level.o h2645data.o
|
||||
OBJS-$(CONFIG_HEVC_V4L2M2M_DECODER) += v4l2_m2m_dec.o
|
||||
OBJS-$(CONFIG_HEVC_V4L2M2M_ENCODER) += v4l2_m2m_enc.o
|
||||
OBJS-$(CONFIG_HEVC_VIDEOTOOLBOX_ENCODER) += videotoolboxenc.o
|
||||
|
@ -862,6 +862,7 @@ extern const FFCodec ff_hevc_qsv_encoder;
|
||||
extern const FFCodec ff_hevc_v4l2m2m_encoder;
|
||||
extern const FFCodec ff_hevc_vaapi_encoder;
|
||||
extern const FFCodec ff_hevc_videotoolbox_encoder;
|
||||
extern const FFCodec ff_hevc_vulkan_encoder;
|
||||
extern const FFCodec ff_libkvazaar_encoder;
|
||||
extern const FFCodec ff_mjpeg_cuvid_decoder;
|
||||
extern const FFCodec ff_mjpeg_qsv_encoder;
|
||||
|
1810
libavcodec/vulkan_encode_h265.c
Normal file
1810
libavcodec/vulkan_encode_h265.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -179,25 +179,6 @@ static int vk_hevc_fill_pict(AVCodecContext *avctx, HEVCFrame **ref_src,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static StdVideoH265LevelIdc convert_to_vk_level_idc(int level_idc)
|
||||
{
|
||||
switch (level_idc) {
|
||||
case 10: return STD_VIDEO_H265_LEVEL_IDC_1_0;
|
||||
case 20: return STD_VIDEO_H265_LEVEL_IDC_2_0;
|
||||
case 21: return STD_VIDEO_H265_LEVEL_IDC_2_1;
|
||||
case 30: return STD_VIDEO_H265_LEVEL_IDC_3_0;
|
||||
case 31: return STD_VIDEO_H265_LEVEL_IDC_3_1;
|
||||
case 40: return STD_VIDEO_H265_LEVEL_IDC_4_0;
|
||||
case 41: return STD_VIDEO_H265_LEVEL_IDC_4_1;
|
||||
case 50: return STD_VIDEO_H265_LEVEL_IDC_5_0;
|
||||
case 51: return STD_VIDEO_H265_LEVEL_IDC_5_1;
|
||||
case 60: return STD_VIDEO_H265_LEVEL_IDC_6_0;
|
||||
case 61: return STD_VIDEO_H265_LEVEL_IDC_6_1;
|
||||
default:
|
||||
case 62: return STD_VIDEO_H265_LEVEL_IDC_6_2;
|
||||
}
|
||||
}
|
||||
|
||||
static void copy_scaling_list(const ScalingList *sl, StdVideoH265ScalingLists *vksl)
|
||||
{
|
||||
for (int i = 0; i < STD_VIDEO_H265_SCALING_LIST_4X4_NUM_LISTS; i++) {
|
||||
@ -338,7 +319,7 @@ static void set_sps(const HEVCSPS *sps, int sps_idx,
|
||||
.general_frame_only_constraint_flag = sps->ptl.general_ptl.frame_only_constraint_flag,
|
||||
},
|
||||
.general_profile_idc = sps->ptl.general_ptl.profile_idc,
|
||||
.general_level_idc = convert_to_vk_level_idc(sps->ptl.general_ptl.level_idc),
|
||||
.general_level_idc = ff_vk_h265_level_to_vk(sps->ptl.general_ptl.level_idc),
|
||||
};
|
||||
|
||||
for (int i = 0; i < sps->max_sub_layers; i++) {
|
||||
@ -607,8 +588,8 @@ static void set_vps(const HEVCVPS *vps,
|
||||
.general_non_packed_constraint_flag = vps->ptl.general_ptl.non_packed_constraint_flag,
|
||||
.general_frame_only_constraint_flag = vps->ptl.general_ptl.frame_only_constraint_flag,
|
||||
},
|
||||
.general_profile_idc = vps->ptl.general_ptl.profile_idc,
|
||||
.general_level_idc = convert_to_vk_level_idc(vps->ptl.general_ptl.level_idc),
|
||||
.general_profile_idc = ff_vk_h265_profile_to_vk(vps->ptl.general_ptl.profile_idc),
|
||||
.general_level_idc = ff_vk_h265_level_to_vk(vps->ptl.general_ptl.level_idc),
|
||||
};
|
||||
|
||||
for (int i = 0; i < vps->vps_max_sub_layers; i++) {
|
||||
|
@ -203,6 +203,25 @@ int ff_vk_h265_level_to_av(StdVideoH265LevelIdc level)
|
||||
}
|
||||
}
|
||||
|
||||
StdVideoH265LevelIdc ff_vk_h265_level_to_vk(int level_idc)
|
||||
{
|
||||
switch (level_idc) {
|
||||
case 10: return STD_VIDEO_H265_LEVEL_IDC_1_0;
|
||||
case 20: return STD_VIDEO_H265_LEVEL_IDC_2_0;
|
||||
case 21: return STD_VIDEO_H265_LEVEL_IDC_2_1;
|
||||
case 30: return STD_VIDEO_H265_LEVEL_IDC_3_0;
|
||||
case 31: return STD_VIDEO_H265_LEVEL_IDC_3_1;
|
||||
case 40: return STD_VIDEO_H265_LEVEL_IDC_4_0;
|
||||
case 41: return STD_VIDEO_H265_LEVEL_IDC_4_1;
|
||||
case 50: return STD_VIDEO_H265_LEVEL_IDC_5_0;
|
||||
case 51: return STD_VIDEO_H265_LEVEL_IDC_5_1;
|
||||
case 60: return STD_VIDEO_H265_LEVEL_IDC_6_0;
|
||||
case 61: return STD_VIDEO_H265_LEVEL_IDC_6_1;
|
||||
default:
|
||||
case 62: return STD_VIDEO_H265_LEVEL_IDC_6_2;
|
||||
}
|
||||
}
|
||||
|
||||
StdVideoH264ProfileIdc ff_vk_h264_profile_to_vk(int profile)
|
||||
{
|
||||
switch (profile) {
|
||||
@ -214,6 +233,16 @@ StdVideoH264ProfileIdc ff_vk_h264_profile_to_vk(int profile)
|
||||
}
|
||||
}
|
||||
|
||||
StdVideoH265ProfileIdc ff_vk_h265_profile_to_vk(int profile)
|
||||
{
|
||||
switch (profile) {
|
||||
case AV_PROFILE_HEVC_MAIN: return STD_VIDEO_H265_PROFILE_IDC_MAIN;
|
||||
case AV_PROFILE_HEVC_MAIN_10: return STD_VIDEO_H265_PROFILE_IDC_MAIN_10;
|
||||
case AV_PROFILE_HEVC_REXT: return STD_VIDEO_H265_PROFILE_IDC_FORMAT_RANGE_EXTENSIONS;
|
||||
default: return STD_VIDEO_H265_PROFILE_IDC_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
int ff_vk_h264_profile_to_av(StdVideoH264ProfileIdc profile)
|
||||
{
|
||||
switch (profile) {
|
||||
@ -225,6 +254,16 @@ int ff_vk_h264_profile_to_av(StdVideoH264ProfileIdc profile)
|
||||
}
|
||||
}
|
||||
|
||||
int ff_vk_h265_profile_to_av(StdVideoH264ProfileIdc profile)
|
||||
{
|
||||
switch (profile) {
|
||||
case STD_VIDEO_H265_PROFILE_IDC_MAIN: return AV_PROFILE_HEVC_MAIN;
|
||||
case STD_VIDEO_H265_PROFILE_IDC_MAIN_10: return AV_PROFILE_HEVC_MAIN_10;
|
||||
case STD_VIDEO_H265_PROFILE_IDC_FORMAT_RANGE_EXTENSIONS: return AV_PROFILE_HEVC_REXT;
|
||||
default: return AV_PROFILE_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
int ff_vk_video_qf_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf,
|
||||
VkQueueFlagBits family, VkVideoCodecOperationFlagBitsKHR caps)
|
||||
{
|
||||
|
@ -76,12 +76,15 @@ 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);
|
||||
StdVideoH265LevelIdc ff_vk_h265_level_to_vk(int level_idc);
|
||||
|
||||
/**
|
||||
* Convert profile from/to AV to Vulkan
|
||||
*/
|
||||
StdVideoH264ProfileIdc ff_vk_h264_profile_to_vk(int profile);
|
||||
StdVideoH265ProfileIdc ff_vk_h265_profile_to_vk(int profile);
|
||||
int ff_vk_h264_profile_to_av(StdVideoH264ProfileIdc profile);
|
||||
int ff_vk_h265_profile_to_av(StdVideoH264ProfileIdc profile);
|
||||
|
||||
/**
|
||||
* Creates image views for video frames.
|
||||
|
Loading…
Reference in New Issue
Block a user