avcodec/hevc_ps: fix setting HEVCHdrParams fields

These were defined in a way compatible with the Vulkan HEVC acceleration, which
expects bitmasks, yet the fields were being overwritting on each loop with the
latest read value.

Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
James Almer 2024-03-20 20:17:29 -03:00
parent 456c8ebe7c
commit 535b1a93f5
3 changed files with 40 additions and 35 deletions

View File

@ -370,7 +370,7 @@ static void decode_sublayer_hrd(GetBitContext *gb, unsigned int nb_cpb,
par->bit_rate_du_value_minus1[i] = get_ue_golomb_long(gb);
}
par->cbr_flag = get_bits1(gb);
par->cbr_flag |= get_bits1(gb) << i;
}
}
@ -378,24 +378,24 @@ static int decode_hrd(GetBitContext *gb, int common_inf_present,
HEVCHdrParams *hdr, int max_sublayers)
{
if (common_inf_present) {
hdr->flags.nal_hrd_parameters_present_flag = get_bits1(gb);
hdr->flags.vcl_hrd_parameters_present_flag = get_bits1(gb);
hdr->nal_hrd_parameters_present_flag = get_bits1(gb);
hdr->vcl_hrd_parameters_present_flag = get_bits1(gb);
if (hdr->flags.nal_hrd_parameters_present_flag ||
hdr->flags.vcl_hrd_parameters_present_flag) {
hdr->flags.sub_pic_hrd_params_present_flag = get_bits1(gb);
if (hdr->nal_hrd_parameters_present_flag ||
hdr->vcl_hrd_parameters_present_flag) {
hdr->sub_pic_hrd_params_present_flag = get_bits1(gb);
if (hdr->flags.sub_pic_hrd_params_present_flag) {
if (hdr->sub_pic_hrd_params_present_flag) {
hdr->tick_divisor_minus2 = get_bits(gb, 8);
hdr->du_cpb_removal_delay_increment_length_minus1 = get_bits(gb, 5);
hdr->flags.sub_pic_cpb_params_in_pic_timing_sei_flag = get_bits1(gb);
hdr->sub_pic_cpb_params_in_pic_timing_sei_flag = get_bits1(gb);
hdr->dpb_output_delay_du_length_minus1 = get_bits(gb, 5);
}
hdr->bit_rate_scale = get_bits(gb, 4);
hdr->cpb_size_scale = get_bits(gb, 4);
if (hdr->flags.sub_pic_hrd_params_present_flag)
if (hdr->sub_pic_hrd_params_present_flag)
hdr->cpb_size_du_scale = get_bits(gb, 4);
hdr->initial_cpb_removal_delay_length_minus1 = get_bits(gb, 5);
@ -405,18 +405,22 @@ static int decode_hrd(GetBitContext *gb, int common_inf_present,
}
for (int i = 0; i < max_sublayers; i++) {
hdr->flags.fixed_pic_rate_general_flag = get_bits1(gb);
unsigned fixed_pic_rate_general_flag = get_bits1(gb);
unsigned fixed_pic_rate_within_cvs_flag = 0;
unsigned low_delay_hrd_flag = 0;
hdr->flags.fixed_pic_rate_general_flag |= fixed_pic_rate_general_flag << i;
if (!hdr->flags.fixed_pic_rate_general_flag)
hdr->flags.fixed_pic_rate_within_cvs_flag = get_bits1(gb);
if (!fixed_pic_rate_general_flag)
fixed_pic_rate_within_cvs_flag = get_bits1(gb);
hdr->flags.fixed_pic_rate_within_cvs_flag |= fixed_pic_rate_within_cvs_flag << i;
if (hdr->flags.fixed_pic_rate_within_cvs_flag ||
hdr->flags.fixed_pic_rate_general_flag)
if (fixed_pic_rate_within_cvs_flag || fixed_pic_rate_general_flag)
hdr->elemental_duration_in_tc_minus1[i] = get_ue_golomb_long(gb);
else
hdr->flags.low_delay_hrd_flag = get_bits1(gb);
low_delay_hrd_flag = get_bits1(gb);
hdr->flags.low_delay_hrd_flag |= low_delay_hrd_flag << i;
if (!hdr->flags.low_delay_hrd_flag) {
if (!low_delay_hrd_flag) {
unsigned cpb_cnt_minus1 = get_ue_golomb_long(gb);
if (cpb_cnt_minus1 > 31) {
av_log(NULL, AV_LOG_ERROR, "nb_cpb %d invalid\n",
@ -426,13 +430,13 @@ static int decode_hrd(GetBitContext *gb, int common_inf_present,
hdr->cpb_cnt_minus1[i] = cpb_cnt_minus1;
}
if (hdr->flags.nal_hrd_parameters_present_flag)
if (hdr->nal_hrd_parameters_present_flag)
decode_sublayer_hrd(gb, hdr->cpb_cnt_minus1[i]+1, &hdr->nal_params[i],
hdr->flags.sub_pic_hrd_params_present_flag);
hdr->sub_pic_hrd_params_present_flag);
if (hdr->flags.vcl_hrd_parameters_present_flag)
if (hdr->vcl_hrd_parameters_present_flag)
decode_sublayer_hrd(gb, hdr->cpb_cnt_minus1[i]+1, &hdr->vcl_params[i],
hdr->flags.sub_pic_hrd_params_present_flag);
hdr->sub_pic_hrd_params_present_flag);
}
return 0;

View File

@ -39,18 +39,19 @@ typedef struct HEVCSublayerHdrParams {
uint32_t cbr_flag;
} HEVCSublayerHdrParams;
// flags in bitmask form
typedef struct HEVCHdrFlagParams {
uint32_t nal_hrd_parameters_present_flag;
uint32_t vcl_hrd_parameters_present_flag;
uint32_t sub_pic_hrd_params_present_flag;
uint32_t sub_pic_cpb_params_in_pic_timing_sei_flag;
uint32_t fixed_pic_rate_general_flag;
uint32_t fixed_pic_rate_within_cvs_flag;
uint32_t low_delay_hrd_flag;
uint8_t fixed_pic_rate_general_flag;
uint8_t fixed_pic_rate_within_cvs_flag;
uint8_t low_delay_hrd_flag;
} HEVCHdrFlagParams;
typedef struct HEVCHdrParams {
HEVCHdrFlagParams flags;
uint8_t nal_hrd_parameters_present_flag;
uint8_t vcl_hrd_parameters_present_flag;
uint8_t sub_pic_hrd_params_present_flag;
uint8_t sub_pic_cpb_params_in_pic_timing_sei_flag;
uint8_t tick_divisor_minus2;
uint8_t du_cpb_removal_delay_increment_length_minus1;

View File

@ -250,10 +250,10 @@ static void set_sps(const HEVCSPS *sps, int sps_idx,
*vksps_vui_header = (StdVideoH265HrdParameters) {
.flags = (StdVideoH265HrdFlags) {
.nal_hrd_parameters_present_flag = sps->hdr.flags.nal_hrd_parameters_present_flag,
.vcl_hrd_parameters_present_flag = sps->hdr.flags.vcl_hrd_parameters_present_flag,
.sub_pic_hrd_params_present_flag = sps->hdr.flags.sub_pic_hrd_params_present_flag,
.sub_pic_cpb_params_in_pic_timing_sei_flag = sps->hdr.flags.sub_pic_cpb_params_in_pic_timing_sei_flag,
.nal_hrd_parameters_present_flag = sps->hdr.nal_hrd_parameters_present_flag,
.vcl_hrd_parameters_present_flag = sps->hdr.vcl_hrd_parameters_present_flag,
.sub_pic_hrd_params_present_flag = sps->hdr.sub_pic_hrd_params_present_flag,
.sub_pic_cpb_params_in_pic_timing_sei_flag = sps->hdr.sub_pic_cpb_params_in_pic_timing_sei_flag,
.fixed_pic_rate_general_flag = sps->hdr.flags.fixed_pic_rate_general_flag,
.fixed_pic_rate_within_cvs_flag = sps->hdr.flags.fixed_pic_rate_within_cvs_flag,
.low_delay_hrd_flag = sps->hdr.flags.low_delay_hrd_flag,
@ -567,10 +567,10 @@ static void set_vps(const HEVCVPS *vps,
sls_hdr[i] = (StdVideoH265HrdParameters) {
.flags = (StdVideoH265HrdFlags) {
.nal_hrd_parameters_present_flag = src->flags.nal_hrd_parameters_present_flag,
.vcl_hrd_parameters_present_flag = src->flags.vcl_hrd_parameters_present_flag,
.sub_pic_hrd_params_present_flag = src->flags.sub_pic_hrd_params_present_flag,
.sub_pic_cpb_params_in_pic_timing_sei_flag = src->flags.sub_pic_cpb_params_in_pic_timing_sei_flag,
.nal_hrd_parameters_present_flag = src->nal_hrd_parameters_present_flag,
.vcl_hrd_parameters_present_flag = src->vcl_hrd_parameters_present_flag,
.sub_pic_hrd_params_present_flag = src->sub_pic_hrd_params_present_flag,
.sub_pic_cpb_params_in_pic_timing_sei_flag = src->sub_pic_cpb_params_in_pic_timing_sei_flag,
.fixed_pic_rate_general_flag = src->flags.fixed_pic_rate_general_flag,
.fixed_pic_rate_within_cvs_flag = src->flags.fixed_pic_rate_within_cvs_flag,
.low_delay_hrd_flag = src->flags.low_delay_hrd_flag,