From 08766c0bb3adab2104eeadd8901ec78d8d2cd069 Mon Sep 17 00:00:00 2001 From: Marko Viitanen Date: Mon, 25 Oct 2021 11:25:23 +0300 Subject: [PATCH] [inter] Fix max-merge usage --- src/cfg.c | 26 +++++++++++++------------- src/encode_coding_tree.c | 4 ++-- src/encoder_state-bitstream.c | 4 ++-- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/cfg.c b/src/cfg.c index 195993cf..4dda007f 100644 --- a/src/cfg.c +++ b/src/cfg.c @@ -156,7 +156,7 @@ int kvz_config_init(kvz_config *cfg) cfg->scaling_list = KVZ_SCALING_LIST_OFF; - cfg->max_merge = 5; + cfg->max_merge = 6; cfg->early_skip = true; cfg->intra_smoothing_disabled = false; @@ -575,7 +575,7 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) "intra-rdo-et", "0", "early-skip", "1", "fast-residual-cost", "28", - "max-merge", "5", + "max-merge", "6", NULL }, { @@ -603,7 +603,7 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) "intra-rdo-et", "0", "early-skip", "1", "fast-residual-cost", "28", - "max-merge", "5", + "max-merge", "6", NULL }, { @@ -631,7 +631,7 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) "intra-rdo-et", "0", "early-skip", "1", "fast-residual-cost", "28", - "max-merge", "5", + "max-merge", "6", NULL }, { @@ -659,7 +659,7 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) "intra-rdo-et", "0", "early-skip", "1", "fast-residual-cost", "0", - "max-merge", "5", + "max-merge", "6", NULL }, { @@ -687,7 +687,7 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) "intra-rdo-et", "0", "early-skip", "1", "fast-residual-cost", "0", - "max-merge", "5", + "max-merge", "6", NULL }, { @@ -715,7 +715,7 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) "intra-rdo-et", "0", "early-skip", "1", "fast-residual-cost", "0", - "max-merge", "5", + "max-merge", "6", NULL }, { @@ -743,7 +743,7 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) "intra-rdo-et", "0", "early-skip", "1", "fast-residual-cost", "0", - "max-merge", "5", + "max-merge", "6", NULL }, { @@ -771,7 +771,7 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) "intra-rdo-et", "0", "early-skip", "1", "fast-residual-cost", "0", - "max-merge", "5", + "max-merge", "6", NULL }, { @@ -799,7 +799,7 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) "intra-rdo-et", "0", "early-skip", "1", "fast-residual-cost", "0", - "max-merge", "5", + "max-merge", "6", NULL }, { @@ -827,7 +827,7 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) "intra-rdo-et", "0", "early-skip", "0", "fast-residual-cost", "0", - "max-merge", "5", + "max-merge", "6", NULL }, { NULL } @@ -1393,8 +1393,8 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) } else if (OPT("max-merge")) { int max_merge = atoi(value); - if (max_merge < 1 || max_merge > 5) { - fprintf(stderr, "max-merge needs to be between 1 and 5\n"); + if (max_merge < 1 || max_merge > 6) { + fprintf(stderr, "max-merge needs to be between 1 and 6\n"); return 0; } cfg->max_merge = (uint8_t)max_merge; diff --git a/src/encode_coding_tree.c b/src/encode_coding_tree.c index 28884f92..d8b43d4b 100644 --- a/src/encode_coding_tree.c +++ b/src/encode_coding_tree.c @@ -589,7 +589,7 @@ static void encode_inter_prediction_unit(encoder_state_t * const state, int16_t num_cand = 0; cabac->cur_ctx = &(cabac->ctx.cu_merge_flag_ext_model); CABAC_BIN(cabac, cur_cu->merged, "MergeFlag"); - num_cand = MRG_MAX_NUM_CANDS; + num_cand = state->encoder_control->cfg.max_merge; if (cur_cu->merged) { //merge if (num_cand > 1) { int32_t ui; @@ -1263,7 +1263,7 @@ void kvz_encode_coding_tree(encoder_state_t * const state, if (cur_cu->skipped) { kvz_hmvp_add_mv(state, x, y, cu_width, cu_width, cur_cu); - int16_t num_cand = MRG_MAX_NUM_CANDS; + int16_t num_cand = state->encoder_control->cfg.max_merge; if (num_cand > 1) { for (int ui = 0; ui < num_cand - 1; ui++) { int32_t symbol = (ui != cur_cu->merge_idx); diff --git a/src/encoder_state-bitstream.c b/src/encoder_state-bitstream.c index 23dfc561..212692b1 100644 --- a/src/encoder_state-bitstream.c +++ b/src/encoder_state-bitstream.c @@ -674,14 +674,14 @@ static void encoder_state_write_bitstream_seq_parameter_set(bitstream_t* stream, WRITE_U(stream, 0, 1, "sps_mmvd_enabled_flag"); - WRITE_UE(stream, 6 - MRG_MAX_NUM_CANDS, "six_minus_max_num_merge_cand"); + WRITE_UE(stream, 6 - state->encoder_control->cfg.max_merge, "six_minus_max_num_merge_cand"); WRITE_U(stream, 0, 1, "sps_sbt_enabled_flag"); WRITE_U(stream, 0, 1, "sps_affine_enabled_flag"); WRITE_U(stream, 0, 1, "sps_bcw_enabled_flag"); WRITE_U(stream, 0, 1, "sps_ciip_enabled_flag"); - if (MRG_MAX_NUM_CANDS >= 2) + if (state->encoder_control->cfg.max_merge >= 2) { WRITE_U(stream, 0, 1, "sps_gpm_enabled_flag"); }