diff options
-rw-r--r-- | include/vk_video/vulkan_video_codec_h264std.h | 299 | ||||
-rw-r--r-- | include/vk_video/vulkan_video_codec_h264std_decode.h | 87 | ||||
-rw-r--r-- | include/vk_video/vulkan_video_codec_h264std_encode.h | 94 | ||||
-rw-r--r-- | include/vk_video/vulkan_video_codec_h265std.h | 341 | ||||
-rw-r--r-- | include/vk_video/vulkan_video_codec_h265std_decode.h | 59 | ||||
-rw-r--r-- | include/vk_video/vulkan_video_codecs_common.h | 21 |
6 files changed, 901 insertions, 0 deletions
diff --git a/include/vk_video/vulkan_video_codec_h264std.h b/include/vk_video/vulkan_video_codec_h264std.h new file mode 100644 index 0000000..123822a --- /dev/null +++ b/include/vk_video/vulkan_video_codec_h264std.h @@ -0,0 +1,299 @@ +/* +** Copyright (c) 2019-2021 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +#ifndef VULKAN_VIDEO_CODEC_H264STD_H_ +#define VULKAN_VIDEO_CODEC_H264STD_H_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vk_video/vulkan_video_codecs_common.h" + +// Vulkan 0.9 provisional Vulkan video H.264 encode and decode std specification version number +#define VK_STD_VULKAN_VIDEO_CODEC_H264_API_VERSION_0_9 VK_MAKE_VIDEO_STD_VERSION(0, 9, 0) // Patch version should always be set to 0 + +// Format must be in the form XX.XX where the first two digits are the major and the second two, the minor. +#define VK_STD_VULKAN_VIDEO_CODEC_H264_SPEC_VERSION VK_STD_VULKAN_VIDEO_CODEC_H264_API_VERSION_0_9 +#define VK_STD_VULKAN_VIDEO_CODEC_H264_EXTENSION_NAME "VK_STD_vulkan_video_codec_h264" + +// ************************************************* +// Video H.264 common definitions: +// ************************************************* + +typedef enum StdVideoH264ChromaFormatIdc { + std_video_h264_chroma_format_idc_monochrome = 0, + std_video_h264_chroma_format_idc_420 = 1, + std_video_h264_chroma_format_idc_422 = 2, + std_video_h264_chroma_format_idc_444 = 3, +} StdVideoH264ChromaFormatIdc; + +typedef enum StdVideoH264ProfileIdc { + std_video_h264_profile_idc_baseline = 66, /* Only constrained baseline is supported */ + std_video_h264_profile_idc_main = 77, + std_video_h264_profile_idc_high = 100, + std_video_h264_profile_idc_high_444_predictive = 244, + std_video_h264_profile_idc_invalid = 0x7FFFFFFF +} StdVideoH264ProfileIdc; + +typedef enum StdVideoH264Level { + std_video_h264_level_1_0 = 0, + std_video_h264_level_1_1 = 1, + std_video_h264_level_1_2 = 2, + std_video_h264_level_1_3 = 3, + std_video_h264_level_2_0 = 4, + std_video_h264_level_2_1 = 5, + std_video_h264_level_2_2 = 6, + std_video_h264_level_3_0 = 7, + std_video_h264_level_3_1 = 8, + std_video_h264_level_3_2 = 9, + std_video_h264_level_4_0 = 10, + std_video_h264_level_4_1 = 11, + std_video_h264_level_4_2 = 12, + std_video_h264_level_5_0 = 13, + std_video_h264_level_5_1 = 14, + std_video_h264_level_5_2 = 15, + std_video_h264_level_6_0 = 16, + std_video_h264_level_6_1 = 17, + std_video_h264_level_6_2 = 18, + std_video_h264_level_invalid = 0x7FFFFFFF +} StdVideoH264Level; + +typedef enum StdVideoH264PocType { + std_video_h264_poc_type_0 = 0, + std_video_h264_poc_type_1 = 1, + std_video_h264_poc_type_2 = 2, + std_video_h264_poc_type_invalid = 0x7FFFFFFF +} StdVideoH264PocType; + +typedef enum StdVideoH264AspectRatioIdc { + std_video_h264_aspect_ratio_idc_unspecified = 0, + std_video_h264_aspect_ratio_idc_square = 1, + std_video_h264_aspect_ratio_idc_12_11 = 2, + std_video_h264_aspect_ratio_idc_10_11 = 3, + std_video_h264_aspect_ratio_idc_16_11 = 4, + std_video_h264_aspect_ratio_idc_40_33 = 5, + std_video_h264_aspect_ratio_idc_24_11 = 6, + std_video_h264_aspect_ratio_idc_20_11 = 7, + std_video_h264_aspect_ratio_idc_32_11 = 8, + std_video_h264_aspect_ratio_idc_80_33 = 9, + std_video_h264_aspect_ratio_idc_18_11 = 10, + std_video_h264_aspect_ratio_idc_15_11 = 11, + std_video_h264_aspect_ratio_idc_64_33 = 12, + std_video_h264_aspect_ratio_idc_160_99 = 13, + std_video_h264_aspect_ratio_idc_4_3 = 14, + std_video_h264_aspect_ratio_idc_3_2 = 15, + std_video_h264_aspect_ratio_idc_2_1 = 16, + std_video_h264_aspect_ratio_idc_extended_sar = 255, + std_video_h264_aspect_ratio_idc_invalid = 0x7FFFFFFF +} StdVideoH264AspectRatioIdc; + +typedef enum StdVideoH264WeightedBiPredIdc { + std_video_h264_default_weighted_b_slices_prediction_idc = 0, + std_video_h264_explicit_weighted_b_slices_prediction_idc = 1, + std_video_h264_implicit_weighted_b_slices_prediction_idc = 2, + std_video_h264_invalid_weighted_b_slices_prediction_idc = 0x7FFFFFFF +} StdVideoH264WeightedBiPredIdc; + +typedef enum StdVideoH264ModificationOfPicNumsIdc { + std_video_h264_modification_of_pic_nums_idc_short_term_subtract = 0, + std_video_h264_modification_of_pic_nums_idc_short_term_add = 1, + std_video_h264_modification_of_pic_nums_idc_long_term = 2, + std_video_h264_modification_of_pic_nums_idc_end = 3, + std_video_h264_modification_of_pic_nums_idc_invalid = 0x7FFFFFFF +} StdVideoH264ModificationOfPicNumsIdc; + +typedef enum StdVideoH264MemMgmtControlOp { + std_video_h264_mem_mgmt_control_op_end = 0, + std_video_h264_mem_mgmt_control_op_unmark_short_term = 1, + std_video_h264_mem_mgmt_control_op_unmark_long_term = 2, + std_video_h264_mem_mgmt_control_op_mark_long_term = 3, + std_video_h264_mem_mgmt_control_op_set_max_long_term_index = 4, + std_video_h264_mem_mgmt_control_op_unmark_all = 5, + std_video_h264_mem_mgmt_control_op_mark_current_as_long_term = 6, + std_video_h264_mem_mgmt_control_op_invalid = 0x7FFFFFFF +} StdVideoH264MemMgmtControlOp; + +typedef enum StdVideoH264CabacInitIdc { + std_video_h264_cabac_init_idc_0 = 0, + std_video_h264_cabac_init_idc_1 = 1, + std_video_h264_cabac_init_idc_2 = 2, + std_video_h264_cabac_init_idc_invalid = 0x7FFFFFFF +} StdVideoH264CabacInitIdc; + +typedef enum StdVideoH264DisableDeblockingFilterIdc { + std_video_h264_disable_deblocking_filter_idc_disabled = 0, + std_video_h264_disable_deblocking_filter_idc_enabled = 1, + std_video_h264_disable_deblocking_filter_idc_partial = 2, + std_video_h264_disable_deblocking_filter_idc_invalid = 0x7FFFFFFF +} StdVideoH264DisableDeblockingFilterIdc; + +typedef enum StdVideoH264PictureType { + std_video_h264_picture_type_i = 0, + std_video_h264_picture_type_p = 1, + std_video_h264_picture_type_b = 2, + std_video_h264_picture_type_invalid = 0x7FFFFFFF +} StdVideoH264PictureType; + +typedef enum StdVideoH264SliceType { + std_video_h264_slice_type_i = 0, + std_video_h264_slice_type_p = 1, + std_video_h264_slice_type_b = 2, + std_video_h264_slice_type_invalid = 0x7FFFFFFF +} StdVideoH264SliceType; + +typedef enum StdVideoH264NonVclNaluType { + std_video_h264_non_vcl_nalu_type_sps = 0, + std_video_h264_non_vcl_nalu_type_pps = 1, + std_video_h264_non_vcl_nalu_type_aud = 2, + std_video_h264_non_vcl_nalu_type_prefix = 3, + std_video_h264_non_vcl_nalu_type_end_of_sequence = 4, + std_video_h264_non_vcl_nalu_type_end_of_stream = 5, + std_video_h264_non_vcl_nalu_type_precoded = 6, + std_video_h264_non_vcl_nalu_type_invalid = 0x7FFFFFFF +} StdVideoH264NonVclNaluType; + +typedef struct StdVideoH264SpsVuiFlags { + uint32_t aspect_ratio_info_present_flag:1; + uint32_t overscan_info_present_flag:1; + uint32_t overscan_appropriate_flag:1; + uint32_t video_signal_type_present_flag:1; + uint32_t video_full_range_flag:1; + uint32_t color_description_present_flag:1; + uint32_t chroma_loc_info_present_flag:1; + uint32_t timing_info_present_flag:1; + uint32_t fixed_frame_rate_flag:1; + uint32_t bitstream_restriction_flag:1; + uint32_t nal_hrd_parameters_present_flag:1; + uint32_t vcl_hrd_parameters_present_flag:1; +} StdVideoH264SpsVuiFlags; + +typedef struct StdVideoH264HrdParameters { + uint8_t cpb_cnt_minus1; + uint8_t bit_rate_scale; + uint8_t cpb_size_scale; + uint32_t bit_rate_value_minus1[32]; + uint32_t cpb_size_value_minus1[32]; + uint8_t cbr_flag[32]; + uint32_t initial_cpb_removal_delay_length_minus1; + uint32_t cpb_removal_delay_length_minus1; + uint32_t dpb_output_delay_length_minus1; + uint32_t time_offset_length; +} StdVideoH264HrdParameters; + +typedef struct StdVideoH264SequenceParameterSetVui { + StdVideoH264AspectRatioIdc aspect_ratio_idc; + uint16_t sar_width; + uint16_t sar_height; + uint8_t video_format; + uint8_t color_primaries; + uint8_t transfer_characteristics; + uint8_t matrix_coefficients; + uint32_t num_units_in_tick; + uint32_t time_scale; + StdVideoH264HrdParameters hrd_parameters; + uint8_t num_reorder_frames; + uint8_t max_dec_frame_buffering; + StdVideoH264SpsVuiFlags flags; +} StdVideoH264SequenceParameterSetVui; + +typedef struct StdVideoH264SpsFlags { + uint32_t constraint_set0_flag:1; + uint32_t constraint_set1_flag:1; + uint32_t constraint_set2_flag:1; + uint32_t constraint_set3_flag:1; + uint32_t constraint_set4_flag:1; + uint32_t constraint_set5_flag:1; + uint32_t direct_8x8_inference_flag:1; + uint32_t mb_adaptive_frame_field_flag:1; + uint32_t frame_mbs_only_flag:1; + uint32_t delta_pic_order_always_zero_flag:1; + uint32_t residual_colour_transform_flag:1; + uint32_t gaps_in_frame_num_value_allowed_flag:1; + uint32_t first_picture_after_seek_flag:1; // where is this being documented? + uint32_t qpprime_y_zero_transform_bypass_flag:1; + uint32_t frame_cropping_flag:1; + uint32_t scaling_matrix_present_flag:1; + uint32_t vui_parameters_present_flag:1; +} StdVideoH264SpsFlags; + +typedef struct StdVideoH264ScalingLists +{ + // scaling_list_present_mask has one bit for each + // seq_scaling_list_present_flag[i] for SPS OR + // pic_scaling_list_present_flag[i] for PPS, + // bit 0 - 5 are for each entry of ScalingList4x4 + // bit 6 - 7 are for each entry plus 6 for ScalingList8x8 + uint8_t scaling_list_present_mask; + // use_default_scaling_matrix_mask has one bit for each + // UseDefaultScalingMatrix4x4Flag[ i ] and + // UseDefaultScalingMatrix8x8Flag[ i − 6 ] for SPS OR PPS + // bit 0 - 5 are for each entry of ScalingList4x4 + // bit 6 - 7 are for each entry plus 6 for ScalingList8x8 + uint8_t use_default_scaling_matrix_mask; + uint8_t ScalingList4x4[6][16]; + uint8_t ScalingList8x8[2][64]; +} StdVideoH264ScalingLists; + +typedef struct StdVideoH264SequenceParameterSet +{ + StdVideoH264ProfileIdc profile_idc; + StdVideoH264Level level_idc; + uint8_t seq_parameter_set_id; + StdVideoH264ChromaFormatIdc chroma_format_idc; + uint8_t bit_depth_luma_minus8; + uint8_t bit_depth_chroma_minus8; + uint8_t log2_max_frame_num_minus4; + StdVideoH264PocType pic_order_cnt_type; + uint8_t log2_max_pic_order_cnt_lsb_minus4; + int32_t offset_for_non_ref_pic; + int32_t offset_for_top_to_bottom_field; + uint8_t num_ref_frames_in_pic_order_cnt_cycle; + uint8_t max_num_ref_frames; + uint32_t pic_width_in_mbs_minus1; + uint32_t pic_height_in_map_units_minus1; + uint32_t frame_crop_left_offset; + uint32_t frame_crop_right_offset; + uint32_t frame_crop_top_offset; + uint32_t frame_crop_bottom_offset; + StdVideoH264SpsFlags flags; + int32_t offset_for_ref_frame[255]; // The number of valid values are defined by the num_ref_frames_in_pic_order_cnt_cycle + StdVideoH264ScalingLists* pScalingLists; // Must be a valid pointer if scaling_matrix_present_flag is set + StdVideoH264SequenceParameterSetVui* pSequenceParameterSetVui; // Must be a valid pointer if StdVideoH264SpsFlags:vui_parameters_present_flag is set +} StdVideoH264SequenceParameterSet; + +typedef struct StdVideoH264PpsFlags { + uint32_t transform_8x8_mode_flag:1; + uint32_t redundant_pic_cnt_present_flag:1; + uint32_t constrained_intra_pred_flag:1; + uint32_t deblocking_filter_control_present_flag:1; + uint32_t weighted_bipred_idc_flag:1; + uint32_t weighted_pred_flag:1; + uint32_t pic_order_present_flag:1; + uint32_t entropy_coding_mode_flag:1; + uint32_t scaling_matrix_present_flag:1; +} StdVideoH264PpsFlags; + +typedef struct StdVideoH264PictureParameterSet +{ + uint8_t seq_parameter_set_id; + uint8_t pic_parameter_set_id; + uint8_t num_ref_idx_l0_default_active_minus1; + uint8_t num_ref_idx_l1_default_active_minus1; + StdVideoH264WeightedBiPredIdc weighted_bipred_idc; + int8_t pic_init_qp_minus26; + int8_t pic_init_qs_minus26; + int8_t chroma_qp_index_offset; + int8_t second_chroma_qp_index_offset; + StdVideoH264PpsFlags flags; + StdVideoH264ScalingLists* pScalingLists; // Must be a valid pointer if StdVideoH264PpsFlags::scaling_matrix_present_flag is set. +} StdVideoH264PictureParameterSet; + +#ifdef __cplusplus +} +#endif + +#endif // VULKAN_VIDEO_CODEC_H264STD_H_ diff --git a/include/vk_video/vulkan_video_codec_h264std_decode.h b/include/vk_video/vulkan_video_codec_h264std_decode.h new file mode 100644 index 0000000..2b4fc64 --- /dev/null +++ b/include/vk_video/vulkan_video_codec_h264std_decode.h @@ -0,0 +1,87 @@ +/* +** Copyright (c) 2019-2020 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +#ifndef VULKAN_VIDEO_CODEC_H264STD_DECODE_H_ +#define VULKAN_VIDEO_CODEC_H264STD_DECODE_H_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vk_video/vulkan_video_codec_h264std.h" + +// ************************************************* +// Video H.264 Decode related parameters: +// ************************************************* + +typedef struct StdVideoDecodeH264PictureInfoFlags { + uint32_t field_pic_flag:1; // Is field picture + uint32_t is_intra:1; // Is intra picture + uint32_t bottom_field_flag:1; // bottom (true) or top (false) field if field_pic_flag is set. + uint32_t is_reference:1; // This only applies to picture info, and not to the DPB lists. + uint32_t complementary_field_pair:1; // complementary field pair, complementary non-reference field pair, complementary reference field pair +} StdVideoDecodeH264PictureInfoFlags; + +typedef struct StdVideoDecodeH264PictureInfo { + uint8_t seq_parameter_set_id; // Selecting SPS from the Picture Parameters + uint8_t pic_parameter_set_id; // Selecting PPS from the Picture Parameters and the SPS + uint16_t reserved; // for structure members 32-bit packing/alignment + uint16_t frame_num; // 7.4.3 Slice header semantics + uint16_t idr_pic_id; // 7.4.3 Slice header semantics + // PicOrderCnt is based on TopFieldOrderCnt and BottomFieldOrderCnt. See 8.2.1 Decoding process for picture order count type 0 - 2 + int32_t PicOrderCnt[2]; // TopFieldOrderCnt and BottomFieldOrderCnt fields. + StdVideoDecodeH264PictureInfoFlags flags; +} StdVideoDecodeH264PictureInfo; + +typedef struct StdVideoDecodeH264ReferenceInfoFlags { + uint32_t top_field_flag:1; // Reference is used for top field reference. + uint32_t bottom_field_flag:1; // Reference is used for bottom field reference. + uint32_t is_long_term:1; // this is a long term reference + uint32_t is_non_existing:1; // Must be handled in accordance with 8.2.5.2: Decoding process for gaps in frame_num +} StdVideoDecodeH264ReferenceInfoFlags; + +typedef struct StdVideoDecodeH264ReferenceInfo { + // FrameNum = is_long_term ? long_term_frame_idx : frame_num + uint16_t FrameNum; // 7.4.3.3 Decoded reference picture marking semantics + uint16_t reserved; // for structure members 32-bit packing/alignment + int32_t PicOrderCnt[2]; // TopFieldOrderCnt and BottomFieldOrderCnt fields. + StdVideoDecodeH264ReferenceInfoFlags flags; +} StdVideoDecodeH264ReferenceInfo; + +typedef struct StdVideoDecodeH264MvcElementFlags { + uint32_t non_idr:1; + uint32_t anchor_pic:1; + uint32_t inter_view:1; +} StdVideoDecodeH264MvcElementFlags; + +typedef struct StdVideoDecodeH264MvcElement { + StdVideoDecodeH264MvcElementFlags flags; + uint16_t viewOrderIndex; + uint16_t viewId; + uint16_t temporalId; // move out? + uint16_t priorityId; // move out? + uint16_t numOfAnchorRefsInL0; + uint16_t viewIdOfAnchorRefsInL0[15]; + uint16_t numOfAnchorRefsInL1; + uint16_t viewIdOfAnchorRefsInL1[15]; + uint16_t numOfNonAnchorRefsInL0; + uint16_t viewIdOfNonAnchorRefsInL0[15]; + uint16_t numOfNonAnchorRefsInL1; + uint16_t viewIdOfNonAnchorRefsInL1[15]; +} StdVideoDecodeH264MvcElement; + +typedef struct StdVideoDecodeH264Mvc { + uint32_t viewId0; + uint32_t mvcElementCount; + StdVideoDecodeH264MvcElement* pMvcElements; +} StdVideoDecodeH264Mvc; + + +#ifdef __cplusplus +} +#endif + +#endif // VULKAN_VIDEO_CODEC_H264STD_DECODE_H_ diff --git a/include/vk_video/vulkan_video_codec_h264std_encode.h b/include/vk_video/vulkan_video_codec_h264std_encode.h new file mode 100644 index 0000000..7184562 --- /dev/null +++ b/include/vk_video/vulkan_video_codec_h264std_encode.h @@ -0,0 +1,94 @@ +/* +** Copyright (c) 2019-2021 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +#ifndef VULKAN_VIDEO_CODEC_H264STD_ENCODE_H_ +#define VULKAN_VIDEO_CODEC_H264STD_ENCODE_H_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vk_video/vulkan_video_codec_h264std.h" + +// ************************************************* +// Video H.264 Encode related parameters: +// ************************************************* + +typedef struct StdVideoEncodeH264SliceHeaderFlags { + uint32_t idr_flag:1; + uint32_t is_reference_flag:1; + uint32_t num_ref_idx_active_override_flag:1; + uint32_t no_output_of_prior_pics_flag:1; + uint32_t long_term_reference_flag:1; + uint32_t adaptive_ref_pic_marking_mode_flag:1; + uint32_t no_prior_references_available_flag:1; +} StdVideoEncodeH264SliceHeaderFlags; + +typedef struct StdVideoEncodeH264PictureInfoFlags { + uint32_t idr_flag:1; + uint32_t is_reference_flag:1; + uint32_t long_term_reference_flag:1; +} StdVideoEncodeH264PictureInfoFlags; + +typedef struct StdVideoEncodeH264RefMgmtFlags { + uint32_t ref_pic_list_modification_l0_flag:1; + uint32_t ref_pic_list_modification_l1_flag:1; +} StdVideoEncodeH264RefMgmtFlags; + +typedef struct StdVideoEncodeH264RefListModEntry { + StdVideoH264ModificationOfPicNumsIdc modification_of_pic_nums_idc; + uint16_t abs_diff_pic_num_minus1; + uint16_t long_term_pic_num; +} StdVideoEncodeH264RefListModEntry; + +typedef struct StdVideoEncodeH264RefPicMarkingEntry { + StdVideoH264MemMgmtControlOp operation; + uint16_t difference_of_pic_nums_minus1; + uint16_t long_term_pic_num; + uint16_t long_term_frame_idx; + uint16_t max_long_term_frame_idx_plus1; +} StdVideoEncodeH264RefPicMarkingEntry; + +typedef struct StdVideoEncodeH264RefMemMgmtCtrlOperations { + StdVideoEncodeH264RefMgmtFlags flags; + uint8_t refList0ModOpCount; + StdVideoEncodeH264RefListModEntry* pRefList0ModOperations; + uint8_t refList1ModOpCount; + StdVideoEncodeH264RefListModEntry* pRefList1ModOperations; + uint8_t refPicMarkingOpCount; + StdVideoEncodeH264RefPicMarkingEntry* pRefPicMarkingOperations; +} StdVideoEncodeH264RefMemMgmtCtrlOperations; + +typedef struct StdVideoEncodeH264PictureInfo { + StdVideoEncodeH264PictureInfoFlags flags; + StdVideoH264PictureType pictureType; + uint32_t frameNum; + uint32_t pictureOrderCount; + uint16_t long_term_pic_num; + uint16_t long_term_frame_idx; +} StdVideoEncodeH264PictureInfo; + +typedef struct StdVideoEncodeH264SliceHeader { + StdVideoEncodeH264SliceHeaderFlags flags; + StdVideoH264SliceType slice_type; + uint8_t seq_parameter_set_id; + uint8_t pic_parameter_set_id; + uint16_t idr_pic_id; + uint8_t num_ref_idx_l0_active_minus1; + uint8_t num_ref_idx_l1_active_minus1; + StdVideoH264CabacInitIdc cabac_init_idc; + StdVideoH264DisableDeblockingFilterIdc disable_deblocking_filter_idc; + int8_t slice_alpha_c0_offset_div2; + int8_t slice_beta_offset_div2; + StdVideoEncodeH264RefMemMgmtCtrlOperations* pMemMgmtCtrlOperations; +} StdVideoEncodeH264SliceHeader; + + +#ifdef __cplusplus +} +#endif + +#endif // VULKAN_VIDEO_CODEC_H264STD_ENCODE_H_ diff --git a/include/vk_video/vulkan_video_codec_h265std.h b/include/vk_video/vulkan_video_codec_h265std.h new file mode 100644 index 0000000..185b550 --- /dev/null +++ b/include/vk_video/vulkan_video_codec_h265std.h @@ -0,0 +1,341 @@ +/* +** Copyright (c) 2019-2021 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +#ifndef VULKAN_VIDEO_CODEC_H265STD_H_ +#define VULKAN_VIDEO_CODEC_H265STD_H_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vk_video/vulkan_video_codecs_common.h" + +// Vulkan 0.5 version number WIP +#define VK_STD_VULKAN_VIDEO_CODEC_H265_API_VERSION_0_5 VK_MAKE_VIDEO_STD_VERSION(0, 5, 0) // Patch version should always be set to 0 + +// Format must be in the form XX.XX where the first two digits are the major and the second two, the minor. +#define VK_STD_VULKAN_VIDEO_CODEC_H265_SPEC_VERSION VK_STD_VULKAN_VIDEO_CODEC_H265_API_VERSION_0_5 +#define VK_STD_VULKAN_VIDEO_CODEC_H265_EXTENSION_NAME "VK_STD_vulkan_video_codec_h265" + +typedef enum StdVideoH265ChromaFormatIdc { + std_video_h265_chroma_format_idc_monochrome = 0, + std_video_h265_chroma_format_idc_420 = 1, + std_video_h265_chroma_format_idc_422 = 2, + std_video_h265_chroma_format_idc_444 = 3, +} StdVideoH265ChromaFormatIdc; + +typedef enum StdVideoH265ProfileIdc { + std_video_h265_profile_idc_main = 1, + std_video_h265_profile_idc_main_10 = 2, + std_video_h265_profile_idc_main_still_picture = 3, + std_video_h265_profile_idc_format_range_extensions = 4, + std_video_h265_profile_idc_scc_extensions = 9, + std_video_h265_profile_idc_invalid = 0x7FFFFFFF +} StdVideoH265ProfileIdc; + +typedef enum StdVideoH265Level { + std_video_h265_level_1_0 = 0, + std_video_h265_level_2_0 = 1, + std_video_h265_level_2_1 = 2, + std_video_h265_level_3_0 = 3, + std_video_h265_level_3_1 = 4, + std_video_h265_level_4_0 = 5, + std_video_h265_level_4_1 = 6, + std_video_h265_level_5_0 = 7, + std_video_h265_level_5_1 = 8, + std_video_h265_level_5_2 = 9, + std_video_h265_level_6_0 = 10, + std_video_h265_level_6_1 = 11, + std_video_h265_level_6_2 = 12, + std_video_h265_level_invalid = 0x7FFFFFFF +} StdVideoH265Level; + + +typedef struct StdVideoH265DecPicBufMgr +{ + uint32_t max_latency_increase_plus1[7]; + uint8_t max_dec_pic_buffering_minus1[7]; + uint8_t max_num_reorder_pics[7]; +} StdVideoH265DecPicBufMgr; + +typedef struct StdVideoH265SubLayerHrdParameters { + uint32_t bit_rate_value_minus1[32]; + uint32_t cpb_size_value_minus1[32]; + uint32_t cpb_size_du_value_minus1[32]; + uint32_t bit_rate_du_value_minus1[32]; + uint32_t cbr_flag; // each bit represents a range of CpbCounts (bit 0 - cpb_cnt_minus1) per sub-layer +} StdVideoH265SubLayerHrdParameters; + +typedef struct StdVideoH265HrdFlags { + uint32_t nal_hrd_parameters_present_flag : 1; + uint32_t vcl_hrd_parameters_present_flag : 1; + uint32_t sub_pic_hrd_params_present_flag : 1; + uint32_t sub_pic_cpb_params_in_pic_timing_sei_flag : 1; + uint8_t fixed_pic_rate_general_flag; // each bit represents a sublayer, bit 0 - vps_max_sub_layers_minus1 + uint8_t fixed_pic_rate_within_cvs_flag; // each bit represents a sublayer, bit 0 - vps_max_sub_layers_minus1 + uint8_t low_delay_hrd_flag; // each bit represents a sublayer, bit 0 - vps_max_sub_layers_minus1 +} StdVideoH265HrdFlags; + +typedef struct StdVideoH265HrdParameters { + uint8_t tick_divisor_minus2; + uint8_t du_cpb_removal_delay_increment_length_minus1; + uint8_t dpb_output_delay_du_length_minus1; + uint8_t bit_rate_scale; + uint8_t cpb_size_scale; + uint8_t cpb_size_du_scale; + uint8_t initial_cpb_removal_delay_length_minus1; + uint8_t au_cpb_removal_delay_length_minus1; + uint8_t dpb_output_delay_length_minus1; + uint8_t cpb_cnt_minus1[7]; + uint16_t elemental_duration_in_tc_minus1[7]; + StdVideoH265SubLayerHrdParameters* SubLayerHrdParametersNal[7]; + StdVideoH265SubLayerHrdParameters* SubLayerHrdParametersVcl[7]; + StdVideoH265HrdFlags flags; +} StdVideoH265HrdParameters; + +typedef struct StdVideoH265VpsFlags { + uint32_t vps_temporal_id_nesting_flag : 1; + uint32_t vps_sub_layer_ordering_info_present_flag : 1; + uint32_t vps_timing_info_present_flag : 1; + uint32_t vps_poc_proportional_to_timing_flag : 1; +} StdVideoH265VpsFlags; + +typedef struct StdVideoH265VideoParameterSet +{ + uint8_t vps_video_parameter_set_id; + uint8_t vps_max_sub_layers_minus1; + uint32_t vps_num_units_in_tick; + uint32_t vps_time_scale; + uint32_t vps_num_ticks_poc_diff_one_minus1; + StdVideoH265DecPicBufMgr* pDecPicBufMgr; + StdVideoH265HrdParameters* hrd_parameters; + StdVideoH265VpsFlags flags; +} StdVideoH265VideoParameterSet; + +typedef struct StdVideoH265ScalingLists +{ + uint8_t ScalingList4x4[6][16]; // ScalingList[ 0 ][ MatrixID ][ i ] (sizeID = 0) + uint8_t ScalingList8x8[6][64]; // ScalingList[ 1 ][ MatrixID ][ i ] (sizeID = 1) + uint8_t ScalingList16x16[6][64]; // ScalingList[ 2 ][ MatrixID ][ i ] (sizeID = 2) + uint8_t ScalingList32x32[2][64]; // ScalingList[ 3 ][ MatrixID ][ i ] (sizeID = 3) + uint8_t ScalingListDCCoef16x16[6]; // scaling_list_dc_coef_minus8[ sizeID - 2 ][ matrixID ] + 8, sizeID = 2 + uint8_t ScalingListDCCoef32x32[2]; // scaling_list_dc_coef_minus8[ sizeID - 2 ][ matrixID ] + 8. sizeID = 3 +} StdVideoH265ScalingLists; + +typedef struct StdVideoH265SpsVuiFlags { + uint32_t aspect_ratio_info_present_flag : 1; + uint32_t overscan_info_present_flag : 1; + uint32_t overscan_appropriate_flag : 1; + uint32_t video_signal_type_present_flag : 1; + uint32_t video_full_range_flag : 1; + uint32_t colour_description_present_flag : 1; + uint32_t chroma_loc_info_present_flag : 1; + uint32_t neutral_chroma_indication_flag : 1; + uint32_t field_seq_flag : 1; + uint32_t frame_field_info_present_flag : 1; + uint32_t default_display_window_flag : 1; + uint32_t vui_timing_info_present_flag : 1; + uint32_t vui_poc_proportional_to_timing_flag : 1; + uint32_t vui_hrd_parameters_present_flag : 1; + uint32_t bitstream_restriction_flag : 1; + uint32_t tiles_fixed_structure_flag : 1; + uint32_t motion_vectors_over_pic_boundaries_flag : 1; + uint32_t restricted_ref_pic_lists_flag : 1; +} StdVideoH265SpsVuiFlags; + +typedef struct StdVideoH265SequenceParameterSetVui { + uint8_t aspect_ratio_idc; + uint16_t sar_width; + uint16_t sar_height; + uint8_t video_format; + uint8_t colour_primaries; + uint8_t transfer_characteristics; + uint8_t matrix_coeffs; + uint8_t chroma_sample_loc_type_top_field; + uint8_t chroma_sample_loc_type_bottom_field; + uint16_t def_disp_win_left_offset; + uint16_t def_disp_win_right_offset; + uint16_t def_disp_win_top_offset; + uint16_t def_disp_win_bottom_offset; + uint32_t vui_num_units_in_tick; + uint32_t vui_time_scale; + uint32_t vui_num_ticks_poc_diff_one_minus1; + StdVideoH265HrdParameters* hrd_parameters; + uint16_t min_spatial_segmentation_idc; + uint8_t max_bytes_per_pic_denom; + uint8_t max_bits_per_min_cu_denom; + uint8_t log2_max_mv_length_horizontal; + uint8_t log2_max_mv_length_vertical; + StdVideoH265SpsVuiFlags flags; +} StdVideoH265SequenceParameterSetVui; + +typedef struct StdVideoH265PredictorPaletteEntries +{ + uint16_t PredictorPaletteEntries[3][128]; +} StdVideoH265PredictorPaletteEntries; + + +typedef struct StdVideoH265SpsFlags { + uint32_t sps_temporal_id_nesting_flag : 1; + uint32_t separate_colour_plane_flag : 1; + uint32_t scaling_list_enabled_flag : 1; + uint32_t sps_scaling_list_data_present_flag : 1; + uint32_t amp_enabled_flag : 1; + uint32_t sample_adaptive_offset_enabled_flag : 1; + uint32_t pcm_enabled_flag : 1; + uint32_t pcm_loop_filter_disabled_flag : 1; + uint32_t long_term_ref_pics_present_flag : 1; + uint32_t sps_temporal_mvp_enabled_flag : 1; + uint32_t strong_intra_smoothing_enabled_flag : 1; + uint32_t vui_parameters_present_flag : 1; + uint32_t sps_extension_present_flag : 1; + uint32_t sps_range_extension_flag : 1; + + // extension SPS flags, valid when std_video_h265_profile_idc_format_range_extensions is set + uint32_t transform_skip_rotation_enabled_flag : 1; + uint32_t transform_skip_context_enabled_flag : 1; + uint32_t implicit_rdpcm_enabled_flag : 1; + uint32_t explicit_rdpcm_enabled_flag : 1; + uint32_t extended_precision_processing_flag : 1; + uint32_t intra_smoothing_disabled_flag : 1; + uint32_t high_precision_offsets_enabled_flag : 1; + uint32_t persistent_rice_adaptation_enabled_flag : 1; + uint32_t cabac_bypass_alignment_enabled_flag : 1; + + // extension SPS flags, valid when std_video_h265_profile_idc_scc_extensions is set + uint32_t sps_curr_pic_ref_enabled_flag : 1; + uint32_t palette_mode_enabled_flag : 1; + uint32_t sps_palette_predictor_initializer_present_flag : 1; + uint32_t intra_boundary_filtering_disabled_flag : 1; +} StdVideoH265SpsFlags; + +typedef struct StdVideoH265SequenceParameterSet +{ + StdVideoH265ProfileIdc profile_idc; + StdVideoH265Level level_idc; + uint32_t pic_width_in_luma_samples; + uint32_t pic_height_in_luma_samples; + uint8_t sps_video_parameter_set_id; + uint8_t sps_max_sub_layers_minus1; + uint8_t sps_seq_parameter_set_id; + uint8_t chroma_format_idc; + uint8_t bit_depth_luma_minus8; + uint8_t bit_depth_chroma_minus8; + uint8_t log2_max_pic_order_cnt_lsb_minus4; + uint8_t sps_max_dec_pic_buffering_minus1; + uint8_t log2_min_luma_coding_block_size_minus3; + uint8_t log2_diff_max_min_luma_coding_block_size; + uint8_t log2_min_luma_transform_block_size_minus2; + uint8_t log2_diff_max_min_luma_transform_block_size; + uint8_t max_transform_hierarchy_depth_inter; + uint8_t max_transform_hierarchy_depth_intra; + uint8_t num_short_term_ref_pic_sets; + uint8_t num_long_term_ref_pics_sps; + uint8_t pcm_sample_bit_depth_luma_minus1; + uint8_t pcm_sample_bit_depth_chroma_minus1; + uint8_t log2_min_pcm_luma_coding_block_size_minus3; + uint8_t log2_diff_max_min_pcm_luma_coding_block_size; + uint32_t conf_win_left_offset; + uint32_t conf_win_right_offset; + uint32_t conf_win_top_offset; + uint32_t conf_win_bottom_offset; + StdVideoH265DecPicBufMgr* pDecPicBufMgr; + StdVideoH265SpsFlags flags; + StdVideoH265ScalingLists* pScalingLists; // Must be a valid pointer if sps_scaling_list_data_present_flag is set + StdVideoH265SequenceParameterSetVui* pSequenceParameterSetVui; // Must be a valid pointer if StdVideoH265SpsFlags:vui_parameters_present_flag is set palette_max_size; + + // extension SPS flags, valid when std_video_h265_profile_idc_scc_extensions is set + uint8_t palette_max_size; + uint8_t delta_palette_max_predictor_size; + uint8_t motion_vector_resolution_control_idc; + uint8_t sps_num_palette_predictor_initializer_minus1; + StdVideoH265PredictorPaletteEntries* pPredictorPaletteEntries; // Must be a valid pointer if sps_palette_predictor_initializer_present_flag is set +} StdVideoH265SequenceParameterSet; + + +typedef struct StdVideoH265PpsFlags { + uint32_t dependent_slice_segments_enabled_flag : 1; + uint32_t output_flag_present_flag : 1; + uint32_t sign_data_hiding_enabled_flag : 1; + uint32_t cabac_init_present_flag : 1; + uint32_t constrained_intra_pred_flag : 1; + uint32_t transform_skip_enabled_flag : 1; + uint32_t cu_qp_delta_enabled_flag : 1; + uint32_t pps_slice_chroma_qp_offsets_present_flag : 1; + uint32_t weighted_pred_flag : 1; + uint32_t weighted_bipred_flag : 1; + uint32_t transquant_bypass_enabled_flag : 1; + uint32_t tiles_enabled_flag : 1; + uint32_t entropy_coding_sync_enabled_flag : 1; + uint32_t uniform_spacing_flag : 1; + uint32_t loop_filter_across_tiles_enabled_flag : 1; + uint32_t pps_loop_filter_across_slices_enabled_flag : 1; + uint32_t deblocking_filter_control_present_flag : 1; + uint32_t deblocking_filter_override_enabled_flag : 1; + uint32_t pps_deblocking_filter_disabled_flag : 1; + uint32_t pps_scaling_list_data_present_flag : 1; + uint32_t lists_modification_present_flag : 1; + uint32_t slice_segment_header_extension_present_flag : 1; + uint32_t pps_extension_present_flag : 1; + + // extension PPS flags, valid when std_video_h265_profile_idc_format_range_extensions is set + uint32_t cross_component_prediction_enabled_flag : 1; + uint32_t chroma_qp_offset_list_enabled_flag : 1; + + // extension PPS flags, valid when std_video_h265_profile_idc_scc_extensions is set + uint32_t pps_curr_pic_ref_enabled_flag : 1; + uint32_t residual_adaptive_colour_transform_enabled_flag : 1; + uint32_t pps_slice_act_qp_offsets_present_flag : 1; + uint32_t pps_palette_predictor_initializer_present_flag : 1; + uint32_t monochrome_palette_flag : 1; + uint32_t pps_range_extension_flag : 1; +} StdVideoH265PpsFlags; + +typedef struct StdVideoH265PictureParameterSet +{ + uint8_t pps_pic_parameter_set_id; + uint8_t pps_seq_parameter_set_id; + uint8_t num_extra_slice_header_bits; + uint8_t num_ref_idx_l0_default_active_minus1; + uint8_t num_ref_idx_l1_default_active_minus1; + int8_t init_qp_minus26; + uint8_t diff_cu_qp_delta_depth; + int8_t pps_cb_qp_offset; + int8_t pps_cr_qp_offset; + uint8_t num_tile_columns_minus1; + uint8_t num_tile_rows_minus1; + uint16_t column_width_minus1[19]; + uint16_t row_height_minus1[21]; + int8_t pps_beta_offset_div2; + int8_t pps_tc_offset_div2; + uint8_t log2_parallel_merge_level_minus2; + StdVideoH265PpsFlags flags; + StdVideoH265ScalingLists* pScalingLists; // Must be a valid pointer if pps_scaling_list_data_present_flag is set + + // extension PPS, valid when std_video_h265_profile_idc_format_range_extensions is set + uint8_t log2_max_transform_skip_block_size_minus2; + uint8_t diff_cu_chroma_qp_offset_depth; + uint8_t chroma_qp_offset_list_len_minus1; + int8_t cb_qp_offset_list[6]; + int8_t cr_qp_offset_list[6]; + uint8_t log2_sao_offset_scale_luma; + uint8_t log2_sao_offset_scale_chroma; + + // extension PPS, valid when std_video_h265_profile_idc_scc_extensions is set + int8_t pps_act_y_qp_offset_plus5; + int8_t pps_act_cb_qp_offset_plus5; + int8_t pps_act_cr_qp_offset_plus5; + uint8_t pps_num_palette_predictor_initializer; + uint8_t luma_bit_depth_entry_minus8; + uint8_t chroma_bit_depth_entry_minus8; + StdVideoH265PredictorPaletteEntries* pPredictorPaletteEntries; // Must be a valid pointer if pps_palette_predictor_initializer_present_flag is set +} StdVideoH265PictureParameterSet; + +#ifdef __cplusplus +} +#endif + +#endif // VULKAN_VIDEO_CODEC_H265STD_H_ diff --git a/include/vk_video/vulkan_video_codec_h265std_decode.h b/include/vk_video/vulkan_video_codec_h265std_decode.h new file mode 100644 index 0000000..4be8b5f --- /dev/null +++ b/include/vk_video/vulkan_video_codec_h265std_decode.h @@ -0,0 +1,59 @@ +/* +** Copyright (c) 2019-2021 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +#ifndef VULKAN_VIDEO_CODEC_H265STD_DECODE_H_ +#define VULKAN_VIDEO_CODEC_H265STD_DECODE_H_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vk_video/vulkan_video_codec_h265std.h" + +// ************************************************* +// Video h265 Decode related parameters: +// ************************************************* + +typedef struct StdVideoDecodeH265PictureInfoFlags { + uint32_t IrapPicFlag : 1; + uint32_t IdrPicFlag : 1; + uint32_t IsReference : 1; + uint32_t short_term_ref_pic_set_sps_flag : 1; +} StdVideoDecodeH265PictureInfoFlags; + +typedef struct StdVideoDecodeH265PictureInfo { + uint8_t vps_video_parameter_set_id; + uint8_t sps_seq_parameter_set_id; + uint8_t pps_pic_parameter_set_id; + uint8_t num_short_term_ref_pic_sets; + int32_t PicOrderCntVal; + uint16_t NumBitsForSTRefPicSetInSlice; // number of bits used in st_ref_pic_set() + //when short_term_ref_pic_set_sps_flag is 0; otherwise set to 0. + uint8_t NumDeltaPocsOfRefRpsIdx; // NumDeltaPocs[ RefRpsIdx ] when short_term_ref_pic_set_sps_flag = 1, otherwise 0 + uint8_t RefPicSetStCurrBefore[8]; // slotIndex as used in VkVideoReferenceSlotKHR structures representing + //pReferenceSlots in VkVideoDecodeInfoKHR, 0xff for invalid slotIndex + uint8_t RefPicSetStCurrAfter[8]; // slotIndex as used in VkVideoReferenceSlotKHR structures representing + //pReferenceSlots in VkVideoDecodeInfoKHR, 0xff for invalid slotIndex + uint8_t RefPicSetLtCurr[8]; // slotIndex as used in VkVideoReferenceSlotKHR structures representing + //pReferenceSlots in VkVideoDecodeInfoKHR, 0xff for invalid slotIndex + StdVideoDecodeH265PictureInfoFlags flags; +} StdVideoDecodeH265PictureInfo; + +typedef struct StdVideoDecodeH265ReferenceInfoFlags { + uint32_t is_long_term : 1; + uint32_t is_non_existing : 1; +} StdVideoDecodeH265ReferenceInfoFlags; + +typedef struct StdVideoDecodeH265ReferenceInfo { + int32_t PicOrderCntVal; + StdVideoDecodeH265ReferenceInfoFlags flags; +} StdVideoDecodeH265ReferenceInfo; + +#ifdef __cplusplus +} +#endif + +#endif // VULKAN_VIDEO_CODEC_H265STD_DECODE_H_ diff --git a/include/vk_video/vulkan_video_codecs_common.h b/include/vk_video/vulkan_video_codecs_common.h new file mode 100644 index 0000000..8cc227a --- /dev/null +++ b/include/vk_video/vulkan_video_codecs_common.h @@ -0,0 +1,21 @@ +/* +** Copyright (c) 2019-2021 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +#ifndef VULKAN_VIDEO_CODEC_COMMON_H_ +#define VULKAN_VIDEO_CODEC_COMMON_H_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +#define VK_MAKE_VIDEO_STD_VERSION(major, minor, patch) \ + ((((uint32_t)(major)) << 22) | (((uint32_t)(minor)) << 12) | ((uint32_t)(patch))) + +#ifdef __cplusplus +} +#endif + +#endif // VULKAN_VIDEO_CODEC_COMMON_H_ |