[lfnst] Add commandline option for lfnst. Implement cabac lfnst flag init and sps flag.

This commit is contained in:
siivonek 2022-02-22 20:06:53 +02:00 committed by Joose Sainio
parent 4880b47a4e
commit 213fe13a27
6 changed files with 27 additions and 2 deletions

View file

@ -73,6 +73,7 @@ typedef struct
cabac_ctx_t alf_cc_filter_control_flag[6]; cabac_ctx_t alf_cc_filter_control_flag[6];
cabac_ctx_t sao_merge_flag_model; cabac_ctx_t sao_merge_flag_model;
cabac_ctx_t sao_type_idx_model; cabac_ctx_t sao_type_idx_model;
cabac_ctx_t lfnst_idx[3];
cabac_ctx_t mts_idx_model[4]; cabac_ctx_t mts_idx_model[4];
cabac_ctx_t split_flag_model[9]; //!< \brief split flag context models 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 cabac_ctx_t qt_split_flag_model[6]; //!< \brief qt split flag context models

View file

@ -204,6 +204,8 @@ int uvg_config_init(uvg_config *cfg)
cfg->mip = false; cfg->mip = false;
cfg->lfnst = false;
parse_qp_map(cfg, 0); parse_qp_map(cfg, 0);
cfg->jccr = 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") { else if OPT("mip") {
cfg->mip = atobool(value); cfg->mip = atobool(value);
} }
else if OPT("lfnst") {
cfg->lfnst = atobool(value);
}
else if OPT("jccr") { else if OPT("jccr") {
cfg->jccr = (bool)atobool(value); cfg->jccr = (bool)atobool(value);
} }

View file

@ -174,6 +174,8 @@ static const struct option long_options[] = {
{ "no-mrl", no_argument, NULL, 0 }, { "no-mrl", no_argument, NULL, 0 },
{ "mip", no_argument, NULL, 0 }, { "mip", no_argument, NULL, 0 },
{ "no-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 }, { "jccr", no_argument, NULL, 0 },
{ "no-jccr", no_argument, NULL, 0 }, { "no-jccr", no_argument, NULL, 0 },
{ "amvr", 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" " --(no-)mrl : Enable use of multiple reference lines in intra\n"
" predictions.\n" " predictions.\n"
" --(no-)mip : Enable matrix weighted intra prediction.\n" " --(no-)mip : Enable matrix weighted intra prediction.\n"
" --(no-)lfnst : Enable low frequency non-separable transform. [disabled]"
" --mts <string> : Multiple Transform Selection [off].\n" " --mts <string> : Multiple Transform Selection [off].\n"
" (Currently only implemented for intra\n" " (Currently only implemented for intra\n"
" and has effect only when rd >= 2)\n" " and has effect only when rd >= 2)\n"

View file

@ -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_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] = { static const uint8_t INIT_MTS_IDX[4][4] = {
{ 45, 25, 27, 0, }, { 45, 25, 27, 0, },
{ 45, 40, 27, 0, }, { 45, 40, 27, 0, },
@ -503,6 +510,7 @@ void uvg_init_contexts(encoder_state_t *state, int8_t QP, int8_t slice)
for (i = 0; i < 3; i++) { 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.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_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]); uvg_ctx_init(&cabac->ctx.transform_skip_sig[i], QP, INIT_TRANSFORM_SKIP_SIG[slice][i], INIT_TRANSFORM_SKIP_SIG[3][i]);
} }

View file

@ -668,6 +668,12 @@ static void encoder_state_write_bitstream_seq_parameter_set(bitstream_t* stream,
WRITE_U(stream, 0, 1, "sps_mrl_enabled_flag"); 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) { if (state->encoder_control->cfg.mip) {
WRITE_U(stream, 1, 1, "sps_mip_enabled_flag"); WRITE_U(stream, 1, 1, "sps_mip_enabled_flag");
} else { } else {

View file

@ -522,6 +522,8 @@ typedef struct uvg_config
/** \brief enable matrix weighted intra prediction */ /** \brief enable matrix weighted intra prediction */
int8_t mip; int8_t mip;
/** \brief enable low frequency non-separable transform */
int8_t lfnst;
int8_t jccr; int8_t jccr;