mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-23 18:14:06 +00:00
[inter] Fix how references are signalled for PU
This commit is contained in:
parent
a0d56bef7b
commit
907fa6a36a
|
@ -633,25 +633,22 @@ static void encode_inter_prediction_unit(encoder_state_t * const state,
|
|||
int32_t ref_frame = cur_cu->inter.mv_ref[ref_list_idx];
|
||||
|
||||
cabac->cur_ctx = &(cabac->ctx.cu_ref_pic_model[0]);
|
||||
CABAC_BIN(cabac, (ref_frame != 0), "ref_idx_lX");
|
||||
CABAC_BIN(cabac, (ref_frame > 0), "ref_idx_lX");
|
||||
|
||||
if (ref_frame > 0) {
|
||||
ref_frame--;
|
||||
if (ref_frame > 0 && ref_LX_size > 2) {
|
||||
cabac->cur_ctx = &(cabac->ctx.cu_ref_pic_model[1]);
|
||||
CABAC_BIN(cabac, (ref_frame > 1), "ref_idx_lX");
|
||||
|
||||
int32_t ref_num = ref_LX_size - 2;
|
||||
|
||||
for (int32_t i = 0; i < ref_num; ++i) {
|
||||
const uint32_t symbol = (i == ref_frame) ? 0 : 1;
|
||||
|
||||
if (i == 0) {
|
||||
cabac->cur_ctx = &cabac->ctx.cu_ref_pic_model[1];
|
||||
CABAC_BIN(cabac, symbol, "ref_idx_lX");
|
||||
} else {
|
||||
CABAC_BIN_EP(cabac, symbol, "ref_idx_lX");
|
||||
if (ref_frame > 1 && ref_LX_size > 3) {
|
||||
for (int idx = 3; idx < ref_LX_size; idx++)
|
||||
{
|
||||
uint8_t val = (ref_frame > idx - 1) ? 1 : 0;
|
||||
CABAC_BIN_EP(cabac, val, "ref_idx_lX");
|
||||
if (!val) break;
|
||||
}
|
||||
if (symbol == 0) break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (state->frame->ref_list != REF_PIC_LIST_1 || cur_cu->inter.mv_dir != 3) {
|
||||
|
@ -670,11 +667,8 @@ static void encode_inter_prediction_unit(encoder_state_t * const state,
|
|||
}
|
||||
|
||||
// Signal which candidate MV to use
|
||||
kvz_cabac_write_unary_max_symbol(cabac,
|
||||
&cabac->ctx.mvp_idx_model,
|
||||
CU_GET_MV_CAND(cur_cu, ref_list_idx),
|
||||
1,
|
||||
AMVP_MAX_NUM_CANDS - 1);
|
||||
cabac->cur_ctx = &(cabac->ctx.mvp_idx_model);
|
||||
CABAC_BIN(cabac, CU_GET_MV_CAND(cur_cu, ref_list_idx), "mvp_flag");
|
||||
|
||||
} // for ref_list
|
||||
} // if !merge
|
||||
|
|
|
@ -1236,6 +1236,12 @@ static void kvz_encoder_state_write_bitstream_ref_pic_list(
|
|||
last_poc = delta_poc;
|
||||
}
|
||||
|
||||
if (ref_negative > 1 || ref_positive > 1) {
|
||||
WRITE_U(stream, 1, 1, "sh_num_ref_idx_active_override_flag");
|
||||
if (ref_negative > 1) WRITE_UE(stream, ref_negative - 1, "sh_num_ref_idx_active_minus1[0]");
|
||||
if (ref_positive > 1) WRITE_UE(stream, ref_positive - 1, "sh_num_ref_idx_active_minus1[1]");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void kvz_encoder_state_write_bitstream_slice_header(
|
||||
|
@ -1262,17 +1268,16 @@ void kvz_encoder_state_write_bitstream_slice_header(
|
|||
|
||||
kvz_encoder_state_write_bitstream_picture_header(stream, state);
|
||||
|
||||
if (encoder->cfg.jccr) {
|
||||
WRITE_U(stream, 0, 1, "ph_joint_cbcr_sign_flag");
|
||||
}
|
||||
|
||||
if (state->frame->pictype != KVZ_NAL_IDR_W_RADL
|
||||
&& state->frame->pictype != KVZ_NAL_IDR_N_LP) {
|
||||
WRITE_UE(stream, state->frame->slicetype, "sh_slice_type");
|
||||
kvz_encoder_state_write_bitstream_ref_pic_list(stream, state);
|
||||
}
|
||||
|
||||
|
||||
if (encoder->cfg.jccr) {
|
||||
WRITE_U(stream, 0, 1, "ph_joint_cbcr_sign_flag");
|
||||
}
|
||||
|
||||
if (state->frame->pictype == KVZ_NAL_CRA_NUT || state->frame->pictype == KVZ_NAL_IDR_N_LP || state->frame->pictype == KVZ_NAL_IDR_W_RADL || state->frame->pictype == KVZ_NAL_GDR_NUT)
|
||||
{
|
||||
WRITE_U(stream, 0, 1, "sh_no_output_of_prior_pics_flag");
|
||||
|
|
Loading…
Reference in a new issue