avcodec/evc_ps: use unsigned types in structs where corresponds

Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
James Almer 2023-06-22 19:46:27 -03:00
parent 5b966be5b8
commit 7347b44224
2 changed files with 161 additions and 166 deletions

View File

@ -27,9 +27,9 @@
static int ref_pic_list_struct(GetBitContext *gb, RefPicListStruct *rpl)
{
uint32_t delta_poc_st, strp_entry_sign_flag = 0;
rpl->ref_pic_num = get_ue_golomb(gb);
rpl->ref_pic_num = get_ue_golomb_long(gb);
if (rpl->ref_pic_num > 0) {
delta_poc_st = get_ue_golomb(gb);
delta_poc_st = get_ue_golomb_long(gb);
rpl->ref_pics[0] = delta_poc_st;
if (rpl->ref_pics[0] != 0) {
@ -40,7 +40,7 @@ static int ref_pic_list_struct(GetBitContext *gb, RefPicListStruct *rpl)
}
for (int i = 1; i < rpl->ref_pic_num; ++i) {
delta_poc_st = get_ue_golomb(gb);
delta_poc_st = get_ue_golomb_long(gb);
if (delta_poc_st != 0)
strp_entry_sign_flag = get_bits(gb, 1);
rpl->ref_pics[i] = rpl->ref_pics[i - 1] + delta_poc_st * (1 - (strp_entry_sign_flag << 1));
@ -52,12 +52,12 @@ static int ref_pic_list_struct(GetBitContext *gb, RefPicListStruct *rpl)
// @see ISO_IEC_23094-1 (E.2.2 HRD parameters syntax)
static int hrd_parameters(GetBitContext *gb, HRDParameters *hrd)
{
hrd->cpb_cnt_minus1 = get_ue_golomb(gb);
hrd->cpb_cnt_minus1 = get_ue_golomb_31(gb);
hrd->bit_rate_scale = get_bits(gb, 4);
hrd->cpb_size_scale = get_bits(gb, 4);
for (int SchedSelIdx = 0; SchedSelIdx <= hrd->cpb_cnt_minus1; SchedSelIdx++) {
hrd->bit_rate_value_minus1[SchedSelIdx] = get_ue_golomb(gb);
hrd->cpb_size_value_minus1[SchedSelIdx] = get_ue_golomb(gb);
hrd->bit_rate_value_minus1[SchedSelIdx] = get_ue_golomb_long(gb);
hrd->cpb_size_value_minus1[SchedSelIdx] = get_ue_golomb_long(gb);
hrd->cbr_flag[SchedSelIdx] = get_bits(gb, 1);
}
hrd->initial_cpb_removal_delay_length_minus1 = get_bits(gb, 5);
@ -95,8 +95,8 @@ static int vui_parameters(GetBitContext *gb, VUIParameters *vui)
}
vui->chroma_loc_info_present_flag = get_bits(gb, 1);
if (vui->chroma_loc_info_present_flag) {
vui->chroma_sample_loc_type_top_field = get_ue_golomb(gb);
vui->chroma_sample_loc_type_bottom_field = get_ue_golomb(gb);
vui->chroma_sample_loc_type_top_field = get_ue_golomb_31(gb);
vui->chroma_sample_loc_type_bottom_field = get_ue_golomb_31(gb);
}
vui->neutral_chroma_indication_flag = get_bits(gb, 1);
@ -120,12 +120,12 @@ static int vui_parameters(GetBitContext *gb, VUIParameters *vui)
vui->bitstream_restriction_flag = get_bits(gb, 1);
if (vui->bitstream_restriction_flag) {
vui->motion_vectors_over_pic_boundaries_flag = get_bits(gb, 1);
vui->max_bytes_per_pic_denom = get_ue_golomb(gb);
vui->max_bits_per_mb_denom = get_ue_golomb(gb);
vui->log2_max_mv_length_horizontal = get_ue_golomb(gb);
vui->log2_max_mv_length_vertical = get_ue_golomb(gb);
vui->num_reorder_pics = get_ue_golomb(gb);
vui->max_dec_pic_buffering = get_ue_golomb(gb);
vui->max_bytes_per_pic_denom = get_ue_golomb_31(gb);
vui->max_bits_per_mb_denom = get_ue_golomb_31(gb);
vui->log2_max_mv_length_horizontal = get_ue_golomb_31(gb);
vui->log2_max_mv_length_vertical = get_ue_golomb_31(gb);
vui->num_reorder_pics = get_ue_golomb_long(gb);
vui->max_dec_pic_buffering = get_ue_golomb_long(gb);
}
return 0;
@ -135,7 +135,7 @@ static int vui_parameters(GetBitContext *gb, VUIParameters *vui)
int ff_evc_parse_sps(GetBitContext *gb, EVCParamSets *ps)
{
EVCParserSPS *sps;
int sps_seq_parameter_set_id;
unsigned sps_seq_parameter_set_id;
int ret;
sps_seq_parameter_set_id = get_ue_golomb(gb);
@ -164,27 +164,27 @@ int ff_evc_parse_sps(GetBitContext *gb, EVCParamSets *ps)
// 1 - 4:2:0
// 2 - 4:2:2
// 3 - 4:4:4
sps->chroma_format_idc = get_ue_golomb(gb);
sps->chroma_format_idc = get_ue_golomb_31(gb);
sps->pic_width_in_luma_samples = get_ue_golomb(gb);
sps->pic_height_in_luma_samples = get_ue_golomb(gb);
sps->pic_width_in_luma_samples = get_ue_golomb_long(gb);
sps->pic_height_in_luma_samples = get_ue_golomb_long(gb);
sps->bit_depth_luma_minus8 = get_ue_golomb(gb);
sps->bit_depth_chroma_minus8 = get_ue_golomb(gb);
sps->bit_depth_luma_minus8 = get_ue_golomb_31(gb);
sps->bit_depth_chroma_minus8 = get_ue_golomb_31(gb);
sps->sps_btt_flag = get_bits1(gb);
if (sps->sps_btt_flag) {
sps->log2_ctu_size_minus5 = get_ue_golomb(gb);
sps->log2_min_cb_size_minus2 = get_ue_golomb(gb);
sps->log2_diff_ctu_max_14_cb_size = get_ue_golomb(gb);
sps->log2_diff_ctu_max_tt_cb_size = get_ue_golomb(gb);
sps->log2_diff_min_cb_min_tt_cb_size_minus2 = get_ue_golomb(gb);
sps->log2_ctu_size_minus2 = get_ue_golomb_long(gb);
sps->log2_min_cb_size_minus2 = get_ue_golomb_long(gb);
sps->log2_diff_ctu_max_14_cb_size = get_ue_golomb_long(gb);
sps->log2_diff_ctu_max_tt_cb_size = get_ue_golomb_long(gb);
sps->log2_diff_min_cb_min_tt_cb_size_minus2 = get_ue_golomb_long(gb);
}
sps->sps_suco_flag = get_bits1(gb);
if (sps->sps_suco_flag) {
sps->log2_diff_ctu_size_max_suco_cb_size = get_ue_golomb(gb);
sps->log2_diff_max_suco_min_suco_cb_size = get_ue_golomb(gb);
sps->log2_diff_ctu_size_max_suco_cb_size = get_ue_golomb_long(gb);
sps->log2_diff_max_suco_min_suco_cb_size = get_ue_golomb_long(gb);
}
sps->sps_admvp_flag = get_bits1(gb);
@ -238,9 +238,9 @@ int ff_evc_parse_sps(GetBitContext *gb, EVCParamSets *ps)
}
if (!sps->sps_rpl_flag)
sps->max_num_tid0_ref_pics = get_ue_golomb(gb);
sps->max_num_tid0_ref_pics = get_ue_golomb_31(gb);
else {
sps->sps_max_dec_pic_buffering_minus1 = get_ue_golomb(gb);
sps->sps_max_dec_pic_buffering_minus1 = get_ue_golomb_long(gb);
sps->long_term_ref_pic_flag = get_bits1(gb);
sps->rpl1_same_as_rpl0_flag = get_bits1(gb);
sps->num_ref_pic_list_in_sps[0] = get_ue_golomb(gb);
@ -258,10 +258,10 @@ int ff_evc_parse_sps(GetBitContext *gb, EVCParamSets *ps)
sps->picture_cropping_flag = get_bits1(gb);
if (sps->picture_cropping_flag) {
sps->picture_crop_left_offset = get_ue_golomb(gb);
sps->picture_crop_right_offset = get_ue_golomb(gb);
sps->picture_crop_top_offset = get_ue_golomb(gb);
sps->picture_crop_bottom_offset = get_ue_golomb(gb);
sps->picture_crop_left_offset = get_ue_golomb_long(gb);
sps->picture_crop_right_offset = get_ue_golomb_long(gb);
sps->picture_crop_top_offset = get_ue_golomb_long(gb);
sps->picture_crop_bottom_offset = get_ue_golomb_long(gb);
}
if (sps->chroma_format_idc != 0) {
@ -278,7 +278,7 @@ int ff_evc_parse_sps(GetBitContext *gb, EVCParamSets *ps)
}
for (int j = 0; j <= sps->chroma_qp_table_struct.num_points_in_qp_table_minus1[i]; j++) {
sps->chroma_qp_table_struct.delta_qp_in_val_minus1[i][j] = get_bits(gb, 6);
sps->chroma_qp_table_struct.delta_qp_out_val[i][j] = get_se_golomb(gb);
sps->chroma_qp_table_struct.delta_qp_out_val[i][j] = get_se_golomb_long(gb);
}
}
}
@ -311,7 +311,7 @@ fail:
int ff_evc_parse_pps(GetBitContext *gb, EVCParamSets *ps)
{
EVCParserPPS *pps;
int pps_pic_parameter_set_id;
unsigned pps_pic_parameter_set_id;
int ret;
pps_pic_parameter_set_id = get_ue_golomb(gb);

View File

@ -34,75 +34,70 @@
// rpl structure
typedef struct RefPicListStruct {
int poc;
int tid;
int ref_pic_num;
int ref_pic_active_num;
int ref_pics[EVC_MAX_NUM_REF_PICS];
char pic_type;
uint32_t ref_pic_num;
uint32_t ref_pics[EVC_MAX_NUM_REF_PICS];
} RefPicListStruct;
// chromaQP table structure to be signalled in SPS
typedef struct ChromaQpTable {
int chroma_qp_table_present_flag; // u(1)
int same_qp_table_for_chroma; // u(1)
int global_offset_flag; // u(1)
int num_points_in_qp_table_minus1[2]; // ue(v)
int delta_qp_in_val_minus1[2][EVC_MAX_QP_TABLE_SIZE]; // u(6)
uint8_t chroma_qp_table_present_flag; // u(1)
uint8_t same_qp_table_for_chroma; // u(1)
uint8_t global_offset_flag; // u(1)
uint8_t num_points_in_qp_table_minus1[2]; // ue(v)
uint8_t delta_qp_in_val_minus1[2][EVC_MAX_QP_TABLE_SIZE]; // u(6)
int delta_qp_out_val[2][EVC_MAX_QP_TABLE_SIZE]; // se(v)
} ChromaQpTable;
// Hypothetical Reference Decoder (HRD) parameters, part of VUI
typedef struct HRDParameters {
int cpb_cnt_minus1; // ue(v)
int bit_rate_scale; // u(4)
int cpb_size_scale; // u(4)
int bit_rate_value_minus1[NUM_CPB]; // ue(v)
int cpb_size_value_minus1[NUM_CPB]; // ue(v)
int cbr_flag[NUM_CPB]; // u(1)
int initial_cpb_removal_delay_length_minus1; // u(5)
int cpb_removal_delay_length_minus1; // u(5)
int dpb_output_delay_length_minus1; // u(5)
int time_offset_length; // u(5)
uint8_t cpb_cnt_minus1; // ue(v)
uint8_t bit_rate_scale; // u(4)
uint8_t cpb_size_scale; // u(4)
uint32_t bit_rate_value_minus1[NUM_CPB]; // ue(v)
uint32_t cpb_size_value_minus1[NUM_CPB]; // ue(v)
uint8_t cbr_flag[NUM_CPB]; // u(1)
uint8_t initial_cpb_removal_delay_length_minus1; // u(5)
uint8_t cpb_removal_delay_length_minus1; // u(5)
uint8_t dpb_output_delay_length_minus1; // u(5)
uint8_t time_offset_length; // u(5)
} HRDParameters;
// video usability information (VUI) part of SPS
typedef struct VUIParameters {
int aspect_ratio_info_present_flag; // u(1)
int aspect_ratio_idc; // u(8)
int sar_width; // u(16)
int sar_height; // u(16)
int overscan_info_present_flag; // u(1)
int overscan_appropriate_flag; // u(1)
int video_signal_type_present_flag; // u(1)
int video_format; // u(3)
int video_full_range_flag; // u(1)
int colour_description_present_flag; // u(1)
int colour_primaries; // u(8)
int transfer_characteristics; // u(8)
int matrix_coefficients; // u(8)
int chroma_loc_info_present_flag; // u(1)
int chroma_sample_loc_type_top_field; // ue(v)
int chroma_sample_loc_type_bottom_field; // ue(v)
int neutral_chroma_indication_flag; // u(1)
int field_seq_flag; // u(1)
int timing_info_present_flag; // u(1)
int num_units_in_tick; // u(32)
int time_scale; // u(32)
int fixed_pic_rate_flag; // u(1)
int nal_hrd_parameters_present_flag; // u(1)
int vcl_hrd_parameters_present_flag; // u(1)
int low_delay_hrd_flag; // u(1)
int pic_struct_present_flag; // u(1)
int bitstream_restriction_flag; // u(1)
int motion_vectors_over_pic_boundaries_flag; // u(1)
int max_bytes_per_pic_denom; // ue(v)
int max_bits_per_mb_denom; // ue(v)
int log2_max_mv_length_horizontal; // ue(v)
int log2_max_mv_length_vertical; // ue(v)
int num_reorder_pics; // ue(v)
int max_dec_pic_buffering; // ue(v)
uint8_t aspect_ratio_info_present_flag; // u(1)
uint8_t aspect_ratio_idc; // u(8)
uint16_t sar_width; // u(16)
uint16_t sar_height; // u(16)
uint8_t overscan_info_present_flag; // u(1)
uint8_t overscan_appropriate_flag; // u(1)
uint8_t video_signal_type_present_flag; // u(1)
uint8_t video_format; // u(3)
uint8_t video_full_range_flag; // u(1)
uint8_t colour_description_present_flag; // u(1)
uint8_t colour_primaries; // u(8)
uint8_t transfer_characteristics; // u(8)
uint8_t matrix_coefficients; // u(8)
uint8_t chroma_loc_info_present_flag; // u(1)
uint8_t chroma_sample_loc_type_top_field; // ue(v)
uint8_t chroma_sample_loc_type_bottom_field; // ue(v)
uint8_t neutral_chroma_indication_flag; // u(1)
uint8_t field_seq_flag; // u(1)
uint8_t timing_info_present_flag; // u(1)
uint32_t num_units_in_tick; // u(32)
uint32_t time_scale; // u(32)
uint8_t fixed_pic_rate_flag; // u(1)
uint8_t nal_hrd_parameters_present_flag; // u(1)
uint8_t vcl_hrd_parameters_present_flag; // u(1)
uint8_t low_delay_hrd_flag; // u(1)
uint8_t pic_struct_present_flag; // u(1)
uint8_t bitstream_restriction_flag; // u(1)
uint8_t motion_vectors_over_pic_boundaries_flag; // u(1)
uint8_t max_bytes_per_pic_denom; // ue(v)
uint8_t max_bits_per_mb_denom; // ue(v)
uint8_t log2_max_mv_length_horizontal; // ue(v)
uint8_t log2_max_mv_length_vertical; // ue(v)
uint32_t num_reorder_pics; // ue(v)
uint32_t max_dec_pic_buffering; // ue(v)
HRDParameters hrd_parameters;
} VUIParameters;
@ -114,102 +109,102 @@ typedef struct VUIParameters {
// u(n) - unsigned integer using n bits
// ue(v) - unsigned integer 0-th order Exp_Golomb-coded syntax element with the left bit first
typedef struct EVCParserSPS {
int sps_seq_parameter_set_id; // ue(v)
int profile_idc; // u(8)
int level_idc; // u(8)
int toolset_idc_h; // u(32)
int toolset_idc_l; // u(32)
int chroma_format_idc; // ue(v)
int pic_width_in_luma_samples; // ue(v)
int pic_height_in_luma_samples; // ue(v)
int bit_depth_luma_minus8; // ue(v)
int bit_depth_chroma_minus8; // ue(v)
uint8_t sps_seq_parameter_set_id; // ue(v)
uint8_t profile_idc; // u(8)
uint8_t level_idc; // u(8)
uint32_t toolset_idc_h; // u(32)
uint32_t toolset_idc_l; // u(32)
uint8_t chroma_format_idc; // ue(v)
uint32_t pic_width_in_luma_samples; // ue(v)
uint32_t pic_height_in_luma_samples; // ue(v)
uint8_t bit_depth_luma_minus8; // ue(v)
uint8_t bit_depth_chroma_minus8; // ue(v)
int sps_btt_flag; // u(1)
int log2_ctu_size_minus5; // ue(v)
int log2_min_cb_size_minus2; // ue(v)
int log2_diff_ctu_max_14_cb_size; // ue(v)
int log2_diff_ctu_max_tt_cb_size; // ue(v)
int log2_diff_min_cb_min_tt_cb_size_minus2; // ue(v)
uint8_t sps_btt_flag; // u(1)
uint32_t log2_ctu_size_minus2; // ue(v)
uint32_t log2_min_cb_size_minus2; // ue(v)
uint32_t log2_diff_ctu_max_14_cb_size; // ue(v)
uint32_t log2_diff_ctu_max_tt_cb_size; // ue(v)
uint32_t log2_diff_min_cb_min_tt_cb_size_minus2; // ue(v)
int sps_suco_flag; // u(1)
int log2_diff_ctu_size_max_suco_cb_size; // ue(v)
int log2_diff_max_suco_min_suco_cb_size; // ue(v)
uint8_t sps_suco_flag; // u(1)
uint32_t log2_diff_ctu_size_max_suco_cb_size; // ue(v)
uint32_t log2_diff_max_suco_min_suco_cb_size; // ue(v)
int sps_admvp_flag; // u(1)
int sps_affine_flag; // u(1)
int sps_amvr_flag; // u(1)
int sps_dmvr_flag; // u(1)
int sps_mmvd_flag; // u(1)
int sps_hmvp_flag; // u(1)
uint8_t sps_admvp_flag; // u(1)
uint8_t sps_affine_flag; // u(1)
uint8_t sps_amvr_flag; // u(1)
uint8_t sps_dmvr_flag; // u(1)
uint8_t sps_mmvd_flag; // u(1)
uint8_t sps_hmvp_flag; // u(1)
int sps_eipd_flag; // u(1)
int sps_ibc_flag; // u(1)
int log2_max_ibc_cand_size_minus2; // ue(v)
uint8_t sps_eipd_flag; // u(1)
uint8_t sps_ibc_flag; // u(1)
uint32_t log2_max_ibc_cand_size_minus2; // ue(v)
int sps_cm_init_flag; // u(1)
int sps_adcc_flag; // u(1)
uint8_t sps_cm_init_flag; // u(1)
uint8_t sps_adcc_flag; // u(1)
int sps_iqt_flag; // u(1)
int sps_ats_flag; // u(1)
uint8_t sps_iqt_flag; // u(1)
uint8_t sps_ats_flag; // u(1)
int sps_addb_flag; // u(1)
int sps_alf_flag; // u(1)
int sps_htdf_flag; // u(1)
int sps_rpl_flag; // u(1)
int sps_pocs_flag; // u(1)
int sps_dquant_flag; // u(1)
int sps_dra_flag; // u(1)
uint8_t sps_addb_flag; // u(1)
uint8_t sps_alf_flag; // u(1)
uint8_t sps_htdf_flag; // u(1)
uint8_t sps_rpl_flag; // u(1)
uint8_t sps_pocs_flag; // u(1)
uint8_t sps_dquant_flag; // u(1)
uint8_t sps_dra_flag; // u(1)
int log2_max_pic_order_cnt_lsb_minus4; // ue(v)
int log2_sub_gop_length; // ue(v)
int log2_ref_pic_gap_length; // ue(v)
uint32_t log2_max_pic_order_cnt_lsb_minus4; // ue(v)
uint32_t log2_sub_gop_length; // ue(v)
uint32_t log2_ref_pic_gap_length; // ue(v)
int max_num_tid0_ref_pics; // ue(v)
uint8_t max_num_tid0_ref_pics; // ue(v)
int sps_max_dec_pic_buffering_minus1; // ue(v)
int long_term_ref_pic_flag; // u(1)
int rpl1_same_as_rpl0_flag; // u(1)
int num_ref_pic_list_in_sps[2]; // ue(v)
uint32_t sps_max_dec_pic_buffering_minus1; // ue(v)
uint8_t long_term_ref_pic_flag; // u(1)
uint8_t rpl1_same_as_rpl0_flag; // u(1)
uint8_t num_ref_pic_list_in_sps[2]; // ue(v)
struct RefPicListStruct rpls[2][EVC_MAX_NUM_RPLS];
int picture_cropping_flag; // u(1)
int picture_crop_left_offset; // ue(v)
int picture_crop_right_offset; // ue(v)
int picture_crop_top_offset; // ue(v)
int picture_crop_bottom_offset; // ue(v)
uint8_t picture_cropping_flag; // u(1)
uint32_t picture_crop_left_offset; // ue(v)
uint32_t picture_crop_right_offset; // ue(v)
uint32_t picture_crop_top_offset; // ue(v)
uint32_t picture_crop_bottom_offset; // ue(v)
struct ChromaQpTable chroma_qp_table_struct;
int vui_parameters_present_flag; // u(1)
uint8_t vui_parameters_present_flag; // u(1)
struct VUIParameters vui_parameters;
} EVCParserSPS;
typedef struct EVCParserPPS {
int pps_pic_parameter_set_id; // ue(v)
int pps_seq_parameter_set_id; // ue(v)
int num_ref_idx_default_active_minus1[2]; // ue(v)
int additional_lt_poc_lsb_len; // ue(v)
int rpl1_idx_present_flag; // u(1)
int single_tile_in_pic_flag; // u(1)
int num_tile_columns_minus1; // ue(v)
int num_tile_rows_minus1; // ue(v)
int uniform_tile_spacing_flag; // u(1)
int tile_column_width_minus1[EVC_MAX_TILE_ROWS]; // ue(v)
int tile_row_height_minus1[EVC_MAX_TILE_COLUMNS]; // ue(v)
int loop_filter_across_tiles_enabled_flag; // u(1)
int tile_offset_len_minus1; // ue(v)
int tile_id_len_minus1; // ue(v)
int explicit_tile_id_flag; // u(1)
int tile_id_val[EVC_MAX_TILE_ROWS][EVC_MAX_TILE_COLUMNS]; // u(v)
int pic_dra_enabled_flag; // u(1)
int pic_dra_aps_id; // u(5)
int arbitrary_slice_present_flag; // u(1)
int constrained_intra_pred_flag; // u(1)
int cu_qp_delta_enabled_flag; // u(1)
int log2_cu_qp_delta_area_minus6; // ue(v)
uint8_t pps_pic_parameter_set_id; // ue(v)
uint8_t pps_seq_parameter_set_id; // ue(v)
uint8_t num_ref_idx_default_active_minus1[2]; // ue(v)
uint8_t additional_lt_poc_lsb_len; // ue(v)
uint8_t rpl1_idx_present_flag; // u(1)
uint8_t single_tile_in_pic_flag; // u(1)
uint32_t num_tile_columns_minus1; // ue(v)
uint32_t num_tile_rows_minus1; // ue(v)
uint8_t uniform_tile_spacing_flag; // u(1)
uint32_t tile_column_width_minus1[EVC_MAX_TILE_ROWS]; // ue(v)
uint32_t tile_row_height_minus1[EVC_MAX_TILE_COLUMNS]; // ue(v)
uint8_t loop_filter_across_tiles_enabled_flag; // u(1)
uint32_t tile_offset_len_minus1; // ue(v)
uint8_t tile_id_len_minus1; // ue(v)
uint8_t explicit_tile_id_flag; // u(1)
uint32_t tile_id_val[EVC_MAX_TILE_ROWS][EVC_MAX_TILE_COLUMNS]; // u(v)
uint8_t pic_dra_enabled_flag; // u(1)
uint8_t pic_dra_aps_id; // u(5)
uint8_t arbitrary_slice_present_flag; // u(1)
uint8_t constrained_intra_pred_flag; // u(1)
uint8_t cu_qp_delta_enabled_flag; // u(1)
uint32_t log2_cu_qp_delta_area_minus6; // ue(v)
} EVCParserPPS;