[alf] use correct lcu index with wpp and use proper cabac context for alf search

This commit is contained in:
Marko Viitanen 2021-07-25 20:19:17 +03:00
parent 90ed51a6ad
commit 0f8f422ad6
3 changed files with 13 additions and 7 deletions

View file

@ -1644,7 +1644,8 @@ static void encode_alf_aps(encoder_state_t * const state)
{
const encoder_control_t * const encoder = state->encoder_control;
bitstream_t * const stream = &state->stream;
if (encoder->cfg.alf_type) // && (state->slice->alf->tile_group_alf_enabled_flag[COMPONENT_Y] || state->slice->alf->tile_group_cc_alf_cb_enabled_flag || state->slice->alf->tile_group_cc_alf_cr_enabled_flag))
if (encoder->cfg.alf_type && (state->slice->alf->tile_group_alf_enabled_flag[COMPONENT_Y] || state->slice->alf->tile_group_cc_alf_cb_enabled_flag || state->slice->alf->tile_group_cc_alf_cr_enabled_flag))
{
param_set_map *aps_map = state->tile->frame->alf_param_set_map;
for (int aps_id = 0; aps_id < ALF_CTB_MAX_NUM_APS; aps_id++)

View file

@ -703,7 +703,7 @@ static void encoder_state_write_bitstream_seq_parameter_set(bitstream_t* stream,
WRITE_U(stream, 0, 1, "sps_palette_enabled_flag");
if (encoder->cfg.trskip_enable /* || pcSPS->getPLTMode()*/) {
WRITE_UE(stream, MIN_QP_PRIME_TS, "sps_min_qp_prime_ts");
WRITE_UE(stream, 0, "sps_internal_bit_depth_minus_input_bit_depth");
}
WRITE_U(stream, 0, 1, "sps_ibc_enabled_flag");

View file

@ -695,7 +695,7 @@ static void encoder_state_worker_encode_lcu_bitstream(void * opaque)
}
//Encode ALF
kvz_encode_alf_bits(state, lcu->index);
kvz_encode_alf_bits(state, lcu->position.y * frame->width_in_lcu + lcu->position.x);
//Encode coding tree
kvz_encode_coding_tree(state, lcu->position.x * LCU_WIDTH, lcu->position.y * LCU_WIDTH, 0, lcu->coeff);
@ -1615,12 +1615,17 @@ void kvz_encode_one_frame(encoder_state_t * const state, kvz_picture* frame)
if (state->frame->num == 0) kvz_cabac_bins_verbose = true;
else kvz_cabac_bins_verbose = false;
#endif
// Create a separate job for ALF done after everything else, and only then do final bitstream writing (for ALF parameters)
if (state->encoder_control->cfg.alf_type && state->encoder_control->cfg.wpp) {
state->tqj_alf_process = kvz_threadqueue_job_create(kvz_alf_enc_process_job, state);
}
encoder_state_init_new_frame(state, frame);
// Create a separate job for ALF done after everything else, and only then do final bitstream writing (for ALF parameters)
if (state->encoder_control->cfg.alf_type && state->encoder_control->cfg.wpp) {
encoder_state_t* child_state = state;
while (child_state->lcu_order == NULL) child_state = &child_state->children[0];
state->tqj_alf_process = kvz_threadqueue_job_create(kvz_alf_enc_process_job, child_state);
}
encoder_state_encode(state);
threadqueue_job_t *job =