diff --git a/src/cabac.h b/src/cabac.h index 0088d5d9..d53ac3b9 100644 --- a/src/cabac.h +++ b/src/cabac.h @@ -73,6 +73,7 @@ typedef struct cabac_ctx_t alf_cc_filter_control_flag[6]; cabac_ctx_t sao_merge_flag_model; cabac_ctx_t sao_type_idx_model; + cabac_ctx_t lfnst_idx[3]; cabac_ctx_t mts_idx_model[4]; cabac_ctx_t split_flag_model[9]; //!< \brief split flag context models cabac_ctx_t qt_split_flag_model[6]; //!< \brief qt split flag context models diff --git a/src/cfg.c b/src/cfg.c index 25c9e328..f545b5d8 100644 --- a/src/cfg.c +++ b/src/cfg.c @@ -204,6 +204,8 @@ int uvg_config_init(uvg_config *cfg) cfg->mip = false; + cfg->lfnst = false; + parse_qp_map(cfg, 0); cfg->jccr = 0; @@ -1439,6 +1441,9 @@ int uvg_config_parse(uvg_config *cfg, const char *name, const char *value) else if OPT("mip") { cfg->mip = atobool(value); } + else if OPT("lfnst") { + cfg->lfnst = atobool(value); + } else if OPT("jccr") { cfg->jccr = (bool)atobool(value); } diff --git a/src/cli.c b/src/cli.c index df486797..1cd3c6cc 100644 --- a/src/cli.c +++ b/src/cli.c @@ -174,6 +174,8 @@ static const struct option long_options[] = { { "no-mrl", no_argument, NULL, 0 }, { "mip", no_argument, NULL, 0 }, { "no-mip", no_argument, NULL, 0 }, + { "lfnst", no_argument, NULL, 0 }, + { "no-lfnst", no_argument, NULL, 0 }, { "jccr", no_argument, NULL, 0 }, { "no-jccr", no_argument, NULL, 0 }, { "amvr", no_argument, NULL, 0 }, @@ -647,6 +649,7 @@ void print_help(void) " --(no-)mrl : Enable use of multiple reference lines in intra\n" " predictions.\n" " --(no-)mip : Enable matrix weighted intra prediction.\n" + " --(no-)lfnst : Enable low frequency non-separable transform. [disabled]" " --mts : Multiple Transform Selection [off].\n" " (Currently only implemented for intra\n" " and has effect only when rd >= 2)\n" diff --git a/src/context.c b/src/context.c index c1b1a58f..f9d54a0d 100644 --- a/src/context.c +++ b/src/context.c @@ -284,6 +284,13 @@ static const uint8_t INIT_SAO_MERGE_FLAG[4] = { 2, 60, 60, 0 }; static const uint8_t INIT_SAO_TYPE_IDX[4] = { 2, 5, 13, 4 }; +static const uint8_t INIT_LFNST_IDX[4][3] = { + { 52, 37, 27, }, + { 37, 45, 27, }, + { 28, 52, 42, }, + { 9, 9, 10, }, +}; + static const uint8_t INIT_MTS_IDX[4][4] = { { 45, 25, 27, 0, }, { 45, 40, 27, 0, }, @@ -502,7 +509,8 @@ void uvg_init_contexts(encoder_state_t *state, int8_t QP, int8_t slice) for (i = 0; i < 3; i++) { uvg_ctx_init(&cabac->ctx.cu_skip_flag_model[i], QP, INIT_SKIP_FLAG[slice][i], INIT_SKIP_FLAG[3][i]); - uvg_ctx_init(&cabac->ctx.joint_cb_cr[i], QP, INIT_JOINT_CB_CR_FLAG[slice][i], INIT_JOINT_CB_CR_FLAG[3][i]); + uvg_ctx_init(&cabac->ctx.joint_cb_cr[i], QP, INIT_JOINT_CB_CR_FLAG[slice][i], INIT_JOINT_CB_CR_FLAG[3][i]); + uvg_ctx_init(&cabac->ctx.lfnst_idx[i], QP, INIT_LFNST_IDX[slice][i], INIT_LFNST_IDX[3][i]); uvg_ctx_init(&cabac->ctx.transform_skip_sig_coeff_group[i], QP, INIT_TRANSFORM_SKIP_SIG_COEFF_GROUP[slice][i], INIT_TRANSFORM_SKIP_SIG_COEFF_GROUP[3][i]); uvg_ctx_init(&cabac->ctx.transform_skip_sig[i], QP, INIT_TRANSFORM_SKIP_SIG[slice][i], INIT_TRANSFORM_SKIP_SIG[3][i]); } diff --git a/src/encoder_state-bitstream.c b/src/encoder_state-bitstream.c index 1fb4f720..e7d6eff9 100644 --- a/src/encoder_state-bitstream.c +++ b/src/encoder_state-bitstream.c @@ -667,6 +667,12 @@ static void encoder_state_write_bitstream_seq_parameter_set(bitstream_t* stream, } else { WRITE_U(stream, 0, 1, "sps_mrl_enabled_flag"); } + + if (state->encoder_control->cfg.lfnst) { + WRITE_U(stream, 1, 1, "sps_lfnst_enabled_flag"); + } else { + WRITE_U(stream, 0, 1, "sps_lfnst_enabled_flag"); + } if (state->encoder_control->cfg.mip) { WRITE_U(stream, 1, 1, "sps_mip_enabled_flag"); diff --git a/src/uvg266.h b/src/uvg266.h index 0dbe5ead..91a1e52c 100644 --- a/src/uvg266.h +++ b/src/uvg266.h @@ -518,10 +518,12 @@ typedef struct uvg_config int8_t chroma_scale_out[3][17]; /** \brief enable use of multiple reference lines in intra prediction */ - int8_t mrl; + int8_t mrl; /** \brief enable matrix weighted intra prediction */ int8_t mip; + /** \brief enable low frequency non-separable transform */ + int8_t lfnst; int8_t jccr;