From bfa699fac6ce5956ca615f08e09834b3e8e7a11a Mon Sep 17 00:00:00 2001 From: Joose Sainio Date: Wed, 11 Jan 2023 10:12:59 +0200 Subject: [PATCH] [DepQuant] WPP: API --- src/cfg.c | 4 ++++ src/cli.c | 3 +++ src/encoder_state-bitstream.c | 9 ++++++--- src/strategies/generic/encode_coding_tree-generic.c | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/cfg.c b/src/cfg.c index a7555ddc..bf9e1307 100644 --- a/src/cfg.c +++ b/src/cfg.c @@ -242,6 +242,7 @@ int uvg_config_init(uvg_config *cfg) cfg->ibc = 0; + cfg->dep_quant = 0; return 1; } @@ -1551,6 +1552,9 @@ int uvg_config_parse(uvg_config *cfg, const char *name, const char *value) } cfg->ibc = (uint8_t)ibc_value; } + else if OPT("dep-quant") { + cfg->dep_quant = (bool)atobool(value); + } else { return 0; } diff --git a/src/cli.c b/src/cli.c index ab91e844..ce238506 100644 --- a/src/cli.c +++ b/src/cli.c @@ -199,6 +199,8 @@ static const struct option long_options[] = { {"max_tt_size", required_argument, NULL, 0 }, { "intra-rough-granularity",required_argument, NULL, 0 }, { "ibc", required_argument, NULL, 0 }, + { "dep-quant", no_argument, NULL, 0 }, + { "no-dep-quant", no_argument, NULL, 0 }, {0, 0, 0, 0} }; @@ -577,6 +579,7 @@ void print_help(void) " - full: Full ALF\n" " --(no-)rdoq : Rate-distortion optimized quantization [enabled]\n" " --(no-)rdoq-skip : Skip RDOQ for 4x4 blocks. [disabled]\n" + " --(no-)dep-quant : Use dependent quantization. [disabled]\n" " --(no-)signhide : Sign hiding [disabled]\n" " --rd : Intra mode search complexity [0]\n" " - 0: Skip intra if inter is good enough.\n" diff --git a/src/encoder_state-bitstream.c b/src/encoder_state-bitstream.c index 920331a5..f4716c67 100644 --- a/src/encoder_state-bitstream.c +++ b/src/encoder_state-bitstream.c @@ -689,7 +689,7 @@ static void encoder_state_write_bitstream_seq_parameter_set(bitstream_t* stream, WRITE_U(stream, 0, 1, "scaling_list_enabled_flag"); - WRITE_U(stream, 0, 1, "pic_dep_quant_enabled_flag"); + WRITE_U(stream, encoder->cfg.dep_quant, 1, "pic_dep_quant_enabled_flag"); WRITE_U(stream, encoder->cfg.signhide_enable, 1, "pic_sign_data_hiding_enabled_flag"); @@ -1358,11 +1358,14 @@ void uvg_encoder_state_write_bitstream_slice_header( } // ToDo: depquant + if (encoder->cfg.dep_quant) { + WRITE_U(stream, 1, 1, "sh_dep_quant_used_flag"); + } - if (state->encoder_control->cfg.signhide_enable) { + if (state->encoder_control->cfg.signhide_enable && !encoder->cfg.dep_quant) { WRITE_U(stream, 1, 1, "sh_sign_data_hiding_used_flag"); } - if (state->encoder_control->cfg.trskip_enable && !state->encoder_control->cfg.signhide_enable /* && !cfg.dep_quant*/) + if (state->encoder_control->cfg.trskip_enable && !state->encoder_control->cfg.signhide_enable && !encoder->cfg.dep_quant) { // TODO: find out what this is actually about and parametrize it WRITE_U(stream, 0, 1, "sh_ts_residual_coding_disabled_flag"); diff --git a/src/strategies/generic/encode_coding_tree-generic.c b/src/strategies/generic/encode_coding_tree-generic.c index 48a5cc3d..21854920 100644 --- a/src/strategies/generic/encode_coding_tree-generic.c +++ b/src/strategies/generic/encode_coding_tree-generic.c @@ -302,7 +302,7 @@ void uvg_encode_coeff_nxn_generic(encoder_state_t * const state, uint32_t num_signs = num_non_zero; - if (state->encoder_control->cfg.signhide_enable && (last_nz_pos_in_cg - first_nz_pos_in_cg >= 4)) { + if (state->encoder_control->cfg.signhide_enable && !state->encoder_control->cfg.dep_quant && (last_nz_pos_in_cg - first_nz_pos_in_cg >= 4)) { num_signs--; coeff_signs >>= 1; }