FG8 combined test: Test 9 and Test 10 This MR adds FG8 tests 9 and 10 to change PH and UV syntaxes to bypass coding. STATS_CHANGED
diff --git a/av1/common/entropy.c b/av1/common/entropy.c index f2ed42f..ba828e7 100644 --- a/av1/common/entropy.c +++ b/av1/common/entropy.c
@@ -78,8 +78,10 @@ av1_default_coeff_base_lf_multi_uv_cdfs[index]); av1_copy(cm->fc->coeff_base_lf_eob_uv_cdf, av1_default_coeff_base_lf_eob_multi_uv_cdfs[index]); +#if !CONFIG_COEFF_BR_LF_UV_BYPASS av1_copy(cm->fc->coeff_br_lf_uv_cdf, av1_default_coeff_lps_lf_multi_uv_cdfs[index]); +#endif av1_copy(cm->fc->coeff_br_uv_cdf, av1_default_coeff_lps_multi_uv_cdfs[index]); av1_copy(cm->fc->coeff_base_uv_cdf, av1_default_coeff_base_multi_uv_cdfs[index]); @@ -94,7 +96,9 @@ av1_copy(cm->fc->eob_flag_cdf512, av1_default_eob_multi512_cdfs[index]); av1_copy(cm->fc->eob_flag_cdf1024, av1_default_eob_multi1024_cdfs[index]); av1_copy(cm->fc->coeff_base_ph_cdf, av1_default_coeff_base_ph_cdfs[index]); +#if !CONFIG_COEFF_BR_PH_BYPASS av1_copy(cm->fc->coeff_br_ph_cdf, av1_default_coeff_br_ph_cdfs[index]); +#endif av1_copy(cm->fc->coeff_base_bob_cdf, av1_default_coeff_base_bob_multi_cdfs[index]); #if CONFIG_DIP @@ -194,7 +198,9 @@ #if CONFIG_CHROMA_CODING RESET_CDF_COUNTER(fc->coeff_base_lf_uv_cdf, LF_BASE_SYMBOLS); RESET_CDF_COUNTER(fc->coeff_base_lf_eob_uv_cdf, LF_BASE_SYMBOLS - 1); +#if !CONFIG_COEFF_BR_LF_UV_BYPASS RESET_CDF_COUNTER(fc->coeff_br_lf_uv_cdf, BR_CDF_SIZE); +#endif RESET_CDF_COUNTER(fc->coeff_base_uv_cdf, 4); RESET_CDF_COUNTER(fc->coeff_base_eob_uv_cdf, 3); RESET_CDF_COUNTER(fc->coeff_br_uv_cdf, BR_CDF_SIZE); @@ -534,6 +540,8 @@ } RESET_CDF_COUNTER(fc->coeff_base_ph_cdf, NUM_BASE_LEVELS + 2); +#if !CONFIG_COEFF_BR_PH_BYPASS RESET_CDF_COUNTER(fc->coeff_br_ph_cdf, BR_CDF_SIZE); +#endif RESET_CDF_COUNTER(fc->cctx_type_cdf, CCTX_TYPES); }
diff --git a/av1/common/entropymode.c b/av1/common/entropymode.c index 526046c..f215e83 100644 --- a/av1/common/entropymode.c +++ b/av1/common/entropymode.c
@@ -8825,8 +8825,10 @@ ctx_tr->coeff_base_lf_uv_cdf, LF_BASE_SYMBOLS); CUMULATIVE_AVERAGE_CDF(ctx_left->coeff_base_lf_eob_uv_cdf, ctx_tr->coeff_base_lf_eob_uv_cdf, LF_BASE_SYMBOLS - 1); +#if !CONFIG_COEFF_BR_LF_UV_BYPASS CUMULATIVE_AVERAGE_CDF(ctx_left->coeff_br_lf_uv_cdf, ctx_tr->coeff_br_lf_uv_cdf, BR_CDF_SIZE); +#endif #endif // CONFIG_CHROMA_CODING CUMULATIVE_AVERAGE_CDF(ctx_left->inter_warp_mode_cdf, @@ -9221,7 +9223,9 @@ CUMULATIVE_AVERAGE_CDF(ctx_left->coeff_base_ph_cdf, ctx_tr->coeff_base_ph_cdf, 4); +#if !CONFIG_COEFF_BR_PH_BYPASS CUMULATIVE_AVERAGE_CDF(ctx_left->coeff_br_ph_cdf, ctx_tr->coeff_br_ph_cdf, 4); +#endif CUMULATIVE_AVERAGE_CDF(ctx_left->cctx_type_cdf, ctx_tr->cctx_type_cdf, CCTX_TYPES); } @@ -9329,7 +9333,9 @@ SHIFT_CDF(ctx_ptr->coeff_base_eob_uv_cdf, 3); SHIFT_CDF(ctx_ptr->coeff_base_lf_uv_cdf, LF_BASE_SYMBOLS); SHIFT_CDF(ctx_ptr->coeff_base_lf_eob_uv_cdf, LF_BASE_SYMBOLS - 1); +#if !CONFIG_COEFF_BR_LF_UV_BYPASS SHIFT_CDF(ctx_ptr->coeff_br_lf_uv_cdf, BR_CDF_SIZE); +#endif #endif // CONFIG_CHROMA_CODING SHIFT_CDF(ctx_ptr->inter_warp_mode_cdf, 2); @@ -9609,7 +9615,9 @@ } SHIFT_CDF(ctx_ptr->coeff_base_ph_cdf, 4); +#if !CONFIG_COEFF_BR_PH_BYPASS SHIFT_CDF(ctx_ptr->coeff_br_ph_cdf, 4); +#endif SHIFT_CDF(ctx_ptr->cctx_type_cdf, CCTX_TYPES); } #endif // CONFIG_TILE_CDFS_AVG_TO_FRAME @@ -9757,8 +9765,10 @@ LF_BASE_SYMBOLS); AVERAGE_CDF(ctx_left->coeff_base_lf_eob_uv_cdf, ctx_tr->coeff_base_lf_eob_uv_cdf, LF_BASE_SYMBOLS - 1); +#if !CONFIG_COEFF_BR_LF_UV_BYPASS AVERAGE_CDF(ctx_left->coeff_br_lf_uv_cdf, ctx_tr->coeff_br_lf_uv_cdf, BR_CDF_SIZE); +#endif #endif // CONFIG_CHROMA_CODING AVERAGE_CDF(ctx_left->inter_warp_mode_cdf, ctx_tr->inter_warp_mode_cdf, 2); @@ -10090,7 +10100,9 @@ } AVERAGE_CDF(ctx_left->coeff_base_ph_cdf, ctx_tr->coeff_base_ph_cdf, 4); +#if !CONFIG_COEFF_BR_PH_BYPASS AVERAGE_CDF(ctx_left->coeff_br_ph_cdf, ctx_tr->coeff_br_ph_cdf, 4); +#endif AVERAGE_CDF(ctx_left->cctx_type_cdf, ctx_tr->cctx_type_cdf, CCTX_TYPES); } #endif // CONFIG_ENHANCED_FRAME_CONTEXT_INIT
diff --git a/av1/common/entropymode.h b/av1/common/entropymode.h index 78dc2fa..411c0dd 100644 --- a/av1/common/entropymode.h +++ b/av1/common/entropymode.h
@@ -240,7 +240,9 @@ #endif // CONFIG_TCQ [CDF_SIZE(4)]; aom_cdf_prob coeff_base_eob_uv_cdf[SIG_COEF_CONTEXTS_EOB][CDF_SIZE(3)]; +#if !CONFIG_COEFF_BR_LF_UV_BYPASS aom_cdf_prob coeff_br_lf_uv_cdf[LF_LEVEL_CONTEXTS_UV][CDF_SIZE(BR_CDF_SIZE)]; +#endif aom_cdf_prob coeff_br_uv_cdf[LEVEL_CONTEXTS_UV][CDF_SIZE(BR_CDF_SIZE)]; #else aom_cdf_prob coeff_base_eob_cdf[TX_SIZES][PLANE_TYPES][SIG_COEF_CONTEXTS_EOB] @@ -270,8 +272,9 @@ #endif // CONFIG_IMPROVEIDTX aom_cdf_prob coeff_base_ph_cdf[COEFF_BASE_PH_CONTEXTS] [CDF_SIZE(NUM_BASE_LEVELS + 2)]; +#if !CONFIG_COEFF_BR_PH_BYPASS aom_cdf_prob coeff_br_ph_cdf[COEFF_BR_PH_CONTEXTS][CDF_SIZE(BR_CDF_SIZE)]; - +#endif #if CONFIG_OPT_INTER_MODE_CTX aom_cdf_prob inter_single_mode_cdf[INTER_MODE_CONTEXTS] [CDF_SIZE(INTER_SINGLE_MODES)];
diff --git a/av1/common/quant_common.c b/av1/common/quant_common.c index 9e9a06d..0902a91 100644 --- a/av1/common/quant_common.c +++ b/av1/common/quant_common.c
@@ -93,14 +93,8 @@ return par; } -int tcq_init_state(int tcq_mode, int plane, TX_CLASS tx_class) { +int tcq_init_state(int tcq_mode) { int state = tcq_mode << 8; - if (TCQ_DIS_CHR && plane != 0) { - state = 0; - } - if (TCQ_DIS_1D && tx_class != TX_CLASS_2D) { - state = 0; - } return state; }
diff --git a/av1/common/quant_common.h b/av1/common/quant_common.h index 3187996..1aaff10 100644 --- a/av1/common/quant_common.h +++ b/av1/common/quant_common.h
@@ -90,7 +90,7 @@ // Find parity of absLevel. Used to find the next state in trellis coded quant int tcq_parity(int absLevel); // Set the initial state at beginning of trellis coding -int tcq_init_state(int tcq_mode, int plane, TX_CLASS tx_class); +int tcq_init_state(int tcq_mode); // Find the next state in trellis codec quant int tcq_next_state(const int curState, const int absLevel); #endif // CONFIG_TCQ
diff --git a/av1/common/token_cdfs.h b/av1/common/token_cdfs.h index c4725c1..8a2523c 100644 --- a/av1/common/token_cdfs.h +++ b/av1/common/token_cdfs.h
@@ -18928,7 +18928,7 @@ { AOM_CDF4(7108, 15722, 21972), 90 }, }, }; - +#if !CONFIG_COEFF_BR_PH_BYPASS static const aom_cdf_prob av1_default_coeff_br_ph_cdfs[TOKEN_CDF_Q_CTXS][COEFF_BR_PH_CONTEXTS] [CDF_SIZE(BR_CDF_SIZE)] = { @@ -18969,6 +18969,7 @@ { AOM_CDF4(6535, 12315, 17263), 101 }, }, }; +#endif #else static const aom_cdf_prob av1_default_coeff_base_ph_cdfs[TOKEN_CDF_Q_CTXS][COEFF_BASE_PH_CONTEXTS] @@ -18994,7 +18995,7 @@ { AOM_CDF4(11324, 22960, 28501) }, { AOM_CDF4(7895, 17320, 23747) } } }; - +#if !CONFIG_COEFF_BR_PH_BYPASS static const aom_cdf_prob av1_default_coeff_br_ph_cdfs[TOKEN_CDF_Q_CTXS][COEFF_BR_PH_CONTEXTS] [CDF_SIZE(BR_CDF_SIZE)] = { @@ -19027,6 +19028,7 @@ { AOM_CDF4(11557, 20493, 26021) }, { AOM_CDF4(8902, 15844, 21619) } }, }; +#endif #endif // CONFIG_ENTROPY_PARA #if CONFIG_DIP
diff --git a/av1/common/txb_common.h b/av1/common/txb_common.h index f88f83a..2cca621 100644 --- a/av1/common/txb_common.h +++ b/av1/common/txb_common.h
@@ -127,11 +127,13 @@ } #if CONFIG_CHROMA_CODING +#if !CONFIG_COEFF_BR_LF_UV_BYPASS static AOM_FORCE_INLINE int get_br_ctx_lf_eob_chroma(const int c, const TX_CLASS tx_class) { if (tx_class == TX_CLASS_2D && c == 0) return 0; return 4; } +#endif static INLINE int get_br_ctx_2d_chroma(const uint8_t *const levels, const int c, const int bwl) { @@ -175,6 +177,7 @@ return mag + 4; } +#if !CONFIG_COEFF_BR_LF_UV_BYPASS // This function returns the low range context index/increment for the // coefficients residing in the low-frequency region for 1D and 2D // transforms and covers the 1D and 2D TX DC terms. For chroma only. @@ -207,6 +210,7 @@ } return mag + 4; } +#endif // This function returns the low range context index/increment for the // coefficients residing in the higher-frequency default region
diff --git a/av1/decoder/decodetxb.c b/av1/decoder/decodetxb.c index 58ec2d6..2be74ec 100644 --- a/av1/decoder/decodetxb.c +++ b/av1/decoder/decodetxb.c
@@ -157,8 +157,18 @@ , int *hr_avg #endif +#if CONFIG_COEFF_BR_LF_UV_BYPASS + , + int plane +#endif ) { +#if CONFIG_COEFF_BR_LF_UV_BYPASS // code_hr_t + int max_br = lf ? (plane == 0 ? LF_MAX_BASE_BR_RANGE // 8 + : LF_NUM_BASE_LEVELS + 1) + : MAX_BASE_BR_RANGE; +#else int max_br = lf ? LF_MAX_BASE_BR_RANGE : MAX_BASE_BR_RANGE; +#endif int use_tcq_hr = tcq_mode && (level >= max_br - 1); #if CONFIG_COEFF_HR_ADAPTIVE int hr_level_avg = *hr_avg; @@ -210,7 +220,10 @@ int plane, base_cdf_arr base_cdf, br_cdf_arr br_cdf #if CONFIG_CHROMA_CODING , - base_lf_cdf_arr base_lf_uv_cdf, br_cdf_arr br_lf_uv_cdf, + base_lf_cdf_arr base_lf_uv_cdf, +#if !CONFIG_COEFF_BR_LF_UV_BYPASS + br_cdf_arr br_lf_uv_cdf, +#endif base_cdf_arr base_uv_cdf, br_cdf_arr br_uv_cdf #endif // CONFIG_CHROMA_CODING #if CONFIG_TCQ @@ -240,11 +253,13 @@ level += aom_read_symbol(r, base_lf_uv_cdf[coeff_ctx], LF_BASE_SYMBOLS, ACCT_INFO("level", "base_lf_uv_cdf")); #endif // CONFIG_TCQ +#if !CONFIG_COEFF_BR_LF_UV_BYPASS if (level > LF_NUM_BASE_LEVELS) { const int br_ctx = get_br_lf_ctx_2d_chroma(levels, pos, bwl); aom_cdf_prob *cdf = br_lf_uv_cdf[br_ctx]; level += read_low_range(r, cdf); } +#endif } else { const int coeff_ctx = get_lower_levels_ctx_2d_chroma(levels, pos, bwl, plane); @@ -355,7 +370,10 @@ br_cdf_arr br_lf_cdf, int plane, base_cdf_arr base_cdf, br_cdf_arr br_cdf #if CONFIG_CHROMA_CODING , - base_lf_cdf_arr base_lf_uv_cdf, br_cdf_arr br_lf_uv_cdf, + base_lf_cdf_arr base_lf_uv_cdf, +#if !CONFIG_COEFF_BR_LF_UV_BYPASS + br_cdf_arr br_lf_uv_cdf, +#endif base_cdf_arr base_uv_cdf, br_cdf_arr br_uv_cdf #endif // CONFIG_CHROMA_CODING #if CONFIG_TCQ @@ -386,11 +404,13 @@ level += aom_read_symbol(r, base_lf_uv_cdf[coeff_ctx], LF_BASE_SYMBOLS, ACCT_INFO("level", "base_lf_uv_cdf")); #endif // CONFIG_TCQ +#if !CONFIG_COEFF_BR_LF_UV_BYPASS if (level > LF_NUM_BASE_LEVELS) { const int br_ctx = get_br_lf_ctx_chroma(levels, pos, bwl, tx_class); aom_cdf_prob *cdf = br_lf_uv_cdf[br_ctx]; level += read_low_range(r, cdf); } +#endif } else { const int coeff_ctx = get_lower_levels_ctx_chroma(levels, pos, bwl, tx_class, plane); @@ -924,6 +944,10 @@ , &hr_level_avg #endif +#if CONFIG_COEFF_BR_LF_UV_BYPASS + , + plane +#endif ); #endif if (c == 0) dc_val = sign ? -level : level; @@ -959,18 +983,24 @@ static INLINE tran_low_t read_coeff_hidden(aom_reader *r, TX_CLASS tx_class, const int16_t *scan, int bwl, uint8_t *levels, int parity, - base_ph_cdf_arr base_cdf_ph, - br_cdf_arr br_cdf_ph) { + base_ph_cdf_arr base_cdf_ph +#if !CONFIG_COEFF_BR_PH_BYPASS + , + br_cdf_arr br_cdf_ph +#endif +) { int q_index; const int pos = scan[0]; int ctx_idx = get_base_ctx_ph(levels, pos, bwl, tx_class); q_index = aom_read_symbol(r, base_cdf_ph[ctx_idx], 4, ACCT_INFO("q_index")); +#if !CONFIG_COEFF_BR_PH_BYPASS if (q_index > NUM_BASE_LEVELS) { ctx_idx = get_par_br_ctx(levels, pos, bwl, tx_class); aom_cdf_prob *cdf_br = br_cdf_ph[ctx_idx]; q_index += read_low_range(r, cdf_br); } +#endif assert(q_index <= MAX_BASE_BR_RANGE); uint8_t level = (q_index << 1) + parity; levels[get_padded_idx(pos, bwl)] = level; @@ -1017,9 +1047,6 @@ eob_info *eob_data = dcb->eob_data[plane] + dcb->txb_offset[plane]; uint16_t *const eob = &(eob_data->eob); uint16_t *const max_scan_line = &(eob_data->max_scan_line); -#if CONFIG_TCQ - int tcq_mode = cm->features.tcq_mode; -#endif // CONFIG_TCQ #if DEBUG_EXTQUANT fprintf(cm->fDecCoeffLog, @@ -1060,7 +1087,8 @@ #endif #if CONFIG_TCQ - int state = tcq_init_state(cm->features.tcq_mode, plane, tx_class); + int tcq_mode = tcq_enable(cm->features.tcq_mode, plane, tx_class); + int state = tcq_init_state(tcq_mode); #endif // CONFIG_TCQ { @@ -1082,12 +1110,13 @@ aom_read_symbol(r, cdf, LF_BASE_SYMBOLS - 1, ACCT_INFO("level", "coeff_base_lf_eob_uv_cdf")) + 1; - +#if !CONFIG_COEFF_BR_LF_UV_BYPASS if (level > LF_NUM_BASE_LEVELS) { const int br_ctx = get_br_ctx_lf_eob_chroma(pos, tx_class); cdf = ec_ctx->coeff_br_lf_uv_cdf[br_ctx]; level += read_low_range(r, cdf); } +#endif } else { aom_cdf_prob *cdf = ec_ctx->coeff_base_eob_uv_cdf[coeff_ctx]; level += aom_read_symbol(r, cdf, 3, @@ -1173,7 +1202,9 @@ base_cdf_arr base_cdf = ec_ctx->coeff_base_cdf[txs_ctx]; br_cdf_arr br_cdf = ec_ctx->coeff_br_cdf; base_lf_cdf_arr base_lf_uv_cdf = ec_ctx->coeff_base_lf_uv_cdf; +#if !CONFIG_COEFF_BR_LF_UV_BYPASS br_cdf_arr br_lf_uv_cdf = ec_ctx->coeff_br_lf_uv_cdf; +#endif base_cdf_arr base_uv_cdf = ec_ctx->coeff_base_uv_cdf; br_cdf_arr br_uv_cdf = ec_ctx->coeff_br_uv_cdf; #else @@ -1189,8 +1220,11 @@ br_lf_cdf, plane, base_cdf, br_cdf #if CONFIG_CHROMA_CODING , - base_lf_uv_cdf, br_lf_uv_cdf, base_uv_cdf, - br_uv_cdf + base_lf_uv_cdf, +#if !CONFIG_COEFF_BR_LF_UV_BYPASS + br_lf_uv_cdf, +#endif + base_uv_cdf, br_uv_cdf #endif // CONFIG_CHROMA_CODING #if CONFIG_TCQ , @@ -1211,13 +1245,22 @@ } if (is_hidden) { read_coeff_hidden(r, tx_class, scan, bwl, levels, (sum_abs1 & 1), - ec_ctx->coeff_base_ph_cdf, ec_ctx->coeff_br_ph_cdf); + ec_ctx->coeff_base_ph_cdf +#if !CONFIG_COEFF_BR_PH_BYPASS + , + ec_ctx->coeff_br_ph_cdf +#endif + ); } else { read_coeffs_reverse(r, tx_class, 0, 0, scan, bwl, levels, base_lf_cdf, br_lf_cdf, plane, base_cdf, br_cdf #if CONFIG_CHROMA_CODING , - base_lf_uv_cdf, br_lf_uv_cdf, base_uv_cdf, br_uv_cdf + base_lf_uv_cdf, +#if !CONFIG_COEFF_BR_LF_UV_BYPASS + br_lf_uv_cdf, +#endif + base_uv_cdf, br_uv_cdf #endif // CONFIG_CHROMA_CODING #if CONFIG_TCQ , @@ -1230,7 +1273,11 @@ base_lf_cdf, br_lf_cdf, plane, base_cdf, br_cdf #if CONFIG_CHROMA_CODING , - base_lf_uv_cdf, br_lf_uv_cdf, base_uv_cdf, br_uv_cdf + base_lf_uv_cdf, +#if !CONFIG_COEFF_BR_LF_UV_BYPASS + br_lf_uv_cdf, +#endif + base_uv_cdf, br_uv_cdf #endif // CONFIG_CHROMA_CODING #if CONFIG_TCQ , @@ -1251,13 +1298,22 @@ } if (is_hidden) { read_coeff_hidden(r, tx_class, scan, bwl, levels, (sum_abs1 & 1), - ec_ctx->coeff_base_ph_cdf, ec_ctx->coeff_br_ph_cdf); + ec_ctx->coeff_base_ph_cdf +#if !CONFIG_COEFF_BR_PH_BYPASS + , + ec_ctx->coeff_br_ph_cdf +#endif + ); } else { read_coeffs_reverse(r, tx_class, 0, 0, scan, bwl, levels, base_lf_cdf, br_lf_cdf, plane, base_cdf, br_cdf #if CONFIG_CHROMA_CODING , - base_lf_uv_cdf, br_lf_uv_cdf, base_uv_cdf, br_uv_cdf + base_lf_uv_cdf, +#if !CONFIG_COEFF_BR_LF_UV_BYPASS + br_lf_uv_cdf, +#endif + base_uv_cdf, br_uv_cdf #endif // CONFIG_CHROMA_CODING #if CONFIG_TCQ , @@ -1349,6 +1405,13 @@ } if (is_hidden && c == 0) { +#if CONFIG_COEFF_BR_PH_BYPASS + if (level >= ((NUM_BASE_LEVELS + 1) << 1)) { + int hr_level = (read_adaptive_hr(xd, r, hr_level_avg >> 1) << 1); + level += hr_level; + hr_level_avg = (hr_level_avg + hr_level) >> 1; + } +#else if (level >= (MAX_BASE_BR_RANGE << 1)) { #if CONFIG_COEFF_HR_ADAPTIVE int hr_level = (read_adaptive_hr(xd, r, hr_level_avg >> 1) << 1); @@ -1358,6 +1421,7 @@ level += (read_exp_golomb(xd, r, 0) << 1); #endif // CONFIG_COEFF_HR_ADAPTIVE } +#endif } else { #if !CONFIG_IMPROVEIDTX const int row = pos >> bwl; @@ -1392,6 +1456,10 @@ , &hr_level_avg #endif +#if CONFIG_COEFF_BR_LF_UV_BYPASS + , + plane +#endif ); #endif } @@ -1402,8 +1470,7 @@ level &= 0xfffff; cul_level += level; #if CONFIG_TCQ - if (!xd->lossless[mbmi->segment_id] && - tcq_enable(tcq_mode, plane, tx_class)) { + if (!xd->lossless[mbmi->segment_id] && tcq_mode) { tcoeffs[pos] = sign ? -level : level; } else { tran_low_t dq_coeff; @@ -1444,9 +1511,8 @@ } } #if CONFIG_TCQ - if (!xd->lossless[mbmi->segment_id] && - tcq_enable(tcq_mode, plane, tx_class)) { - state = tcq_init_state(tcq_mode, plane, tx_class); + if (!xd->lossless[mbmi->segment_id] && tcq_mode) { + state = tcq_init_state(tcq_mode); for (int c = *eob - 1; c >= 0; --c) { const int pos = scan[c]; int Qx = tcq_quant(state);
diff --git a/av1/encoder/block.h b/av1/encoder/block.h index 958cdf9..e6a626c 100644 --- a/av1/encoder/block.h +++ b/av1/encoder/block.h
@@ -193,8 +193,10 @@ #endif // CONFIG_TCQ [LF_BASE_SYMBOLS * 2]; //! Cost for encoding an increment to the low-frequency chroma coefficient +#if !CONFIG_COEFF_BR_LF_UV_BYPASS int lps_lf_cost_uv[LF_LEVEL_CONTEXTS_UV] [COEFF_BASE_RANGE + 1 + COEFF_BASE_RANGE + 1]; +#endif /*! \brief Cost for encoding the base_eob of a chroma level. * * Decoder uses base_eob to derive the base_level as base_eob := base_eob+1. @@ -231,8 +233,10 @@ //! Cost for encoding the base level of a parity-hidden coefficient int base_ph_cost[COEFF_BASE_PH_CONTEXTS][4]; //! Cost for encoding an increment to the parity-hidden coefficient +#if !CONFIG_COEFF_BR_PH_BYPASS int lps_ph_cost[COEFF_BR_PH_CONTEXTS] [COEFF_BASE_RANGE + 1 + COEFF_BASE_RANGE + 1]; +#endif /*! \brief Cost for encoding the base_eob of a level. * * Decoder uses base_eob to derive the base_level as base_eob := base_eob+1.
diff --git a/av1/encoder/encodeframe_utils.c b/av1/encoder/encodeframe_utils.c index 9a60e1f..5d7cc4a 100644 --- a/av1/encoder/encodeframe_utils.c +++ b/av1/encoder/encodeframe_utils.c
@@ -1516,8 +1516,10 @@ LF_BASE_SYMBOLS); AVERAGE_CDF(ctx_left->coeff_base_lf_eob_uv_cdf, ctx_tr->coeff_base_lf_eob_uv_cdf, LF_BASE_SYMBOLS - 1); +#if !CONFIG_COEFF_BR_LF_UV_BYPASS AVERAGE_CDF(ctx_left->coeff_br_lf_uv_cdf, ctx_tr->coeff_br_lf_uv_cdf, BR_CDF_SIZE); +#endif #endif // CONFIG_CHROMA_CODING AVERAGE_CDF(ctx_left->inter_warp_mode_cdf, ctx_tr->inter_warp_mode_cdf, 2); @@ -1896,7 +1898,9 @@ } AVERAGE_CDF(ctx_left->coeff_base_ph_cdf, ctx_tr->coeff_base_ph_cdf, 4); +#if !CONFIG_COEFF_BR_PH_BYPASS AVERAGE_CDF(ctx_left->coeff_br_ph_cdf, ctx_tr->coeff_br_ph_cdf, 4); +#endif AVERAGE_CDF(ctx_left->cctx_type_cdf, ctx_tr->cctx_type_cdf, CCTX_TYPES); } #endif // !CONFIG_ENHANCED_FRAME_CONTEXT_INIT
diff --git a/av1/encoder/encodetxb.c b/av1/encoder/encodetxb.c index ac7563d..40e9ee4 100644 --- a/av1/encoder/encodetxb.c +++ b/av1/encoder/encodetxb.c
@@ -375,6 +375,20 @@ return eob_cost; } +#if CONFIG_COEFF_BR_PH_BYPASS +static AOM_FORCE_INLINE int get_br_ph_cost(tran_low_t level, int hr_ctx, + int *hr_level) { + int cost = 0; + *hr_level = 0; + if (level >= 1 + NUM_BASE_LEVELS) { + const int r = level - NUM_BASE_LEVELS - 1; + *hr_level = r; + cost += av1_cost_literal(get_adaptive_hr_length(r, hr_ctx)); + } + return cost; +} +#endif + #if CONFIG_COEFF_HR_ADAPTIVE static AOM_FORCE_INLINE int get_br_cost(tran_low_t level, const int *coeff_lps, int hr_ctx, int *hr_level) { @@ -390,6 +404,20 @@ return cost; } +#if CONFIG_COEFF_BR_LF_UV_BYPASS +static AOM_FORCE_INLINE int get_br_lf_cost_uv(tran_low_t level, int hr_ctx, + int *hr_level) { + int cost = 0; + *hr_level = 0; + if (level >= 1 + LF_NUM_BASE_LEVELS) { + const int r = level - LF_NUM_BASE_LEVELS - 1; + *hr_level = r; + cost += av1_cost_literal(get_adaptive_hr_length(r, hr_ctx)); + } + return cost; +} +#endif + static AOM_FORCE_INLINE int get_br_lf_cost(tran_low_t level, const int *coeff_lps, int hr_ctx, int *hr_level) { @@ -430,6 +458,24 @@ return cost; } +#if CONFIG_COEFF_BR_LF_UV_BYPASS +static AOM_FORCE_INLINE int get_br_lf_cost_with_diff_uv(tran_low_t level, + int *diff, int hr_ctx, + int *hr_level) { + int cost = 0; + *hr_level = 0; + if (level >= 1 + LF_NUM_BASE_LEVELS) { + const int r = level - LF_NUM_BASE_LEVELS - 1; + *hr_level = r; + int bits, diff_bits; + bits = get_adaptive_hr_length_diff(r, hr_ctx, &diff_bits); + *diff += av1_cost_literal(diff_bits); + cost += av1_cost_literal(bits); + } + return cost; +} +#endif + static AOM_FORCE_INLINE int get_br_lf_cost_with_diff(tran_low_t level, const int *coeff_lps, int *diff, int hr_ctx, @@ -470,6 +516,16 @@ return low; } +#if CONFIG_COEFF_BR_LF_UV_BYPASS +static INLINE int get_high_range_uv(int abs_qc, int lf) { + int base_levels = lf ? 6 : 4; + int parity = abs_qc & 1; + // int br_max = base_levels - 1 - parity; + int high_range = (abs_qc - parity - (base_levels - 1)) >> 1; + return high_range; +} +#endif + static INLINE int get_high_range(int abs_qc, int lf) { int base_levels = lf ? 6 : 4; int low_range = get_low_range(abs_qc, lf); @@ -1042,14 +1098,19 @@ static INLINE void write_coeff_hidden(aom_writer *w, TX_CLASS tx_class, const int16_t *scan, int bwl, uint8_t *levels, const int level, - base_ph_cdf_arr base_cdf_ph, - br_cdf_arr br_cdf_ph) { + base_ph_cdf_arr base_cdf_ph +#if !CONFIG_COEFF_BR_PH_BYPASS + , + br_cdf_arr br_cdf_ph +#endif +) { const int q_index = (level >> 1); const int pos = scan[0]; int ctx_id = get_base_ctx_ph(levels, pos, bwl, tx_class); aom_write_symbol(w, AOMMIN(q_index, 3), base_cdf_ph[ctx_id], 4); +#if !CONFIG_COEFF_BR_PH_BYPASS if (q_index > NUM_BASE_LEVELS) { ctx_id = get_par_br_ctx(levels, pos, bwl, tx_class); aom_cdf_prob *cdf_br = br_cdf_ph[ctx_id]; @@ -1060,6 +1121,7 @@ if (k < BR_CDF_SIZE - 1) break; } } +#endif } static void write_high_range(aom_writer *w, int enable_tcq, int level, int lf @@ -1067,14 +1129,32 @@ , int *hr_avg #endif +#if CONFIG_COEFF_BR_LF_UV_BYPASS + , + int plane +#endif ) { +#if CONFIG_COEFF_BR_LF_UV_BYPASS // code_hr_t + int max = lf ? (plane == 0 ? (COEFF_BASE_RANGE + LF_NUM_BASE_LEVELS) + : LF_NUM_BASE_LEVELS) + : COEFF_BASE_RANGE + NUM_BASE_LEVELS; +#else int max = lf ? COEFF_BASE_RANGE + LF_NUM_BASE_LEVELS : COEFF_BASE_RANGE + NUM_BASE_LEVELS; +#endif max -= enable_tcq ? 1 : 0; if (level > max) { int hr = 0; if (enable_tcq) { +#if CONFIG_COEFF_BR_LF_UV_BYPASS + if (lf && (plane != 0)) { + hr = get_high_range_uv(level, lf); + } else { + hr = get_high_range(level, lf); + } +#else hr = get_high_range(level, lf); +#endif } else { hr = level - max - 1; } @@ -1125,7 +1205,7 @@ const TX_CLASS tx_class = tx_type_to_class[get_primary_tx_type(tx_type)]; #if CONFIG_TCQ - const int tcq_mode = cm->features.tcq_mode; + const int tcq_mode = tcq_enable(cm->features.tcq_mode, plane, tx_class); #else const int tcq_mode = 0; #endif // CONFIG_TCQ @@ -1171,7 +1251,7 @@ #endif // CONFIG_IMPROVEIDTX #if CONFIG_TCQ - int state = tcq_init_state(tcq_mode, plane, tx_class); + int state = tcq_init_state(tcq_mode); #endif // CONFIG_TCQ // Loop to code AC coefficient magnitudes for (int c = eob - 1; c > 0; --c) { @@ -1305,11 +1385,13 @@ #if CONFIG_CHROMA_CODING if (plane > 0) { if (limits) { +#if !CONFIG_COEFF_BR_LF_UV_BYPASS if (level > LF_NUM_BASE_LEVELS) { const int br_ctx = get_br_lf_ctx_chroma(levels, pos, bwl, tx_class); aom_cdf_prob *cdf = ec_ctx->coeff_br_lf_uv_cdf[br_ctx]; write_low_range(w, cdf, level, 1, tcq_mode); } +#endif } else { if (level > NUM_BASE_LEVELS) { const int br_ctx = get_br_ctx_chroma(levels, pos, bwl, tx_class); @@ -1366,8 +1448,13 @@ const int pos = scan[0]; const tran_low_t v = tcoeff[pos]; const tran_low_t level = abs(v); +#if CONFIG_COEFF_BR_PH_BYPASS + write_coeff_hidden(w, tx_class, scan, bwl, levels, level, + ec_ctx->coeff_base_ph_cdf); +#else write_coeff_hidden(w, tx_class, scan, bwl, levels, level, ec_ctx->coeff_base_ph_cdf, ec_ctx->coeff_br_ph_cdf); +#endif } else { const int c = 0; const int pos = scan[c]; @@ -1503,11 +1590,13 @@ #if CONFIG_CHROMA_CODING if (plane > 0) { if (limits) { +#if !CONFIG_COEFF_BR_LF_UV_BYPASS if (level > LF_NUM_BASE_LEVELS) { const int br_ctx = get_br_lf_ctx_chroma(levels, pos, bwl, tx_class); aom_cdf_prob *cdf = ec_ctx->coeff_br_lf_uv_cdf[br_ctx]; write_low_range(w, cdf, level, 1, tcq_mode); } +#endif } else { if (level > NUM_BASE_LEVELS) { const int br_ctx = get_br_ctx_chroma(levels, pos, bwl, tx_class); @@ -1632,6 +1721,13 @@ } if (is_hidden && c == 0) { int q_index = level >> 1; +#if CONFIG_COEFF_BR_PH_BYPASS + if (q_index > NUM_BASE_LEVELS) { + int hr_level = q_index - 1 - NUM_BASE_LEVELS; + write_adaptive_hr(w, hr_level, hr_level_avg >> 1); + hr_level_avg = (hr_level_avg + hr_level) >> 1; + } +#else if (q_index > COEFF_BASE_RANGE + NUM_BASE_LEVELS) { #if CONFIG_COEFF_HR_ADAPTIVE int hr_level = q_index - COEFF_BASE_RANGE - 1 - NUM_BASE_LEVELS; @@ -1642,6 +1738,7 @@ 0); #endif // CONFIG_COEFF_HR_ADAPTIVE } +#endif } else { #if !CONFIG_IMPROVEIDTX const int pos = scan[c]; @@ -1679,6 +1776,10 @@ , &hr_level_avg #endif +#if CONFIG_COEFF_BR_LF_UV_BYPASS + , + plane +#endif ); #endif } @@ -2311,8 +2412,10 @@ #if CONFIG_CHROMA_CODING const int(*lps_cost_uv)[COEFF_BASE_RANGE + 1 + COEFF_BASE_RANGE + 1] = coeff_costs->lps_cost_uv; +#if !CONFIG_COEFF_BR_LF_UV_BYPASS const int(*lps_lf_cost_uv)[COEFF_BASE_RANGE + 1 + COEFF_BASE_RANGE + 1] = coeff_costs->lps_lf_cost_uv; +#endif #endif // CONFIG_CHROMA_CODING #if CONFIG_COEFF_HR_ADAPTIVE int hr_level = 0; @@ -2362,11 +2465,21 @@ if (plane > 0) { if (limits) { if (level > LF_NUM_BASE_LEVELS) { +#if !CONFIG_COEFF_BR_LF_UV_BYPASS const int ctx = get_br_ctx_lf_eob_chroma(pos, tx_class); +#endif #if CONFIG_COEFF_HR_ADAPTIVE - int hr_ctx = 0; /* eob */ - cost += - get_br_lf_cost(level, lps_lf_cost_uv[ctx], hr_ctx, &hr_level); + int hr_ctx = 0; /* eob */ +#if CONFIG_COEFF_BR_LF_UV_BYPASS // cost + cost += get_br_lf_cost_uv(level, hr_ctx, &hr_level); +#else + cost += get_br_lf_cost(level, lps_lf_cost_uv[ctx], hr_ctx, &hr_level +#if CONFIG_COEFF_BR_LF_UV_BYPASS + , + plane, 1 +#endif + ); +#endif #else cost += get_br_lf_cost(level, lps_lf_cost_uv[ctx]); #endif // CONFIG_COEFF_HR_ADAPTIVE @@ -2594,14 +2707,24 @@ if (plane > 0) { if (limits) { if (level > LF_NUM_BASE_LEVELS) { +#if CONFIG_COEFF_BR_LF_UV_BYPASS // cost + cost += get_br_lf_cost_uv(level, hr_level_avg, &hr_level); + hr_level_avg = (hr_level_avg + hr_level) >> 1; +#else const int ctx = get_br_lf_ctx_chroma(levels, pos, bwl, tx_class); #if CONFIG_COEFF_HR_ADAPTIVE cost += get_br_lf_cost(level, lps_lf_cost_uv[ctx], hr_level_avg, - &hr_level); + &hr_level +#if CONFIG_COEFF_BR_LF_UV_BYPASS + , + plane, 0 +#endif + ); hr_level_avg = (hr_level_avg + hr_level) >> 1; #else cost += get_br_lf_cost(level, lps_lf_cost_uv[ctx]); #endif // CONFIG_COEFF_HR_ADAPTIVE +#endif } } else { if (level > NUM_BASE_LEVELS) { @@ -2694,6 +2817,9 @@ #endif // CONFIG_IMPROVEIDTX if (q_index > NUM_BASE_LEVELS) { +#if CONFIG_COEFF_BR_PH_BYPASS // cost + cost += get_br_ph_cost(q_index, hr_level_avg >> 1, &hr_level); +#else const int ctx = get_par_br_ctx(levels, pos, bwl, tx_class); #if CONFIG_COEFF_HR_ADAPTIVE // Use context divided by 2 since the coefficient is also divided by @@ -2703,6 +2829,7 @@ #else cost += get_br_cost(q_index, coeff_costs_ph->lps_ph_cost[ctx]); #endif // CONFIG_COEFF_HR_ADAPTIVE +#endif } } return cost; @@ -2785,13 +2912,22 @@ if (plane > 0) { if (limits) { if (level > LF_NUM_BASE_LEVELS) { +#if CONFIG_COEFF_BR_LF_UV_BYPASS // cost + cost += get_br_lf_cost_uv(level, hr_level_avg, &hr_level); +#else const int ctx = get_br_lf_ctx_chroma(levels, pos, bwl, tx_class); #if CONFIG_COEFF_HR_ADAPTIVE cost += get_br_lf_cost(level, lps_lf_cost_uv[ctx], hr_level_avg, - &hr_level); + &hr_level +#if CONFIG_COEFF_BR_LF_UV_BYPASS + , + plane, 0 +#endif + ); #else cost += get_br_lf_cost(level, lps_lf_cost_uv[ctx]); #endif // CONFIG_COEFF_HR_ADAPTIVE +#endif } } else { if (level > NUM_BASE_LEVELS) { @@ -3226,6 +3362,12 @@ if (plane > 0) { if (limits) { if (abs_qc > LF_NUM_BASE_LEVELS) { +#if CONFIG_COEFF_BR_LF_UV_BYPASS // cost + int brcost_diff = 0; + cost += get_br_lf_cost_with_diff_uv(abs_qc, &brcost_diff, + hr_level_avg, hr_level); + diff += brcost_diff; +#else const int br_ctx = get_br_lf_ctx_chroma(levels, ci, bwl, tx_class); int brcost_diff = 0; #if CONFIG_COEFF_HR_ADAPTIVE @@ -3237,6 +3379,7 @@ abs_qc, txb_costs->lps_lf_cost_uv[br_ctx], &brcost_diff); #endif // CONFIG_COEFF_HR_ADAPTIVE diff += brcost_diff; +#endif } } else { if (abs_qc > NUM_BASE_LEVELS) { @@ -3458,15 +3601,26 @@ if (plane > 0) { if (limits) { if (abs_qc > LF_NUM_BASE_LEVELS) { +#if CONFIG_COEFF_BR_LF_UV_BYPASS // cost + int hr_level_avg = 0; + int dummy_hr_level; + cost += get_br_lf_cost_uv(abs_qc, hr_level_avg, &dummy_hr_level); +#else int br_ctx = get_br_ctx_lf_eob_chroma(ci, tx_class); #if CONFIG_COEFF_HR_ADAPTIVE int hr_level_avg = 0; int dummy_hr_level; cost += get_br_lf_cost(abs_qc, txb_costs->lps_lf_cost_uv[br_ctx], - hr_level_avg, &dummy_hr_level); + hr_level_avg, &dummy_hr_level +#if CONFIG_COEFF_BR_LF_UV_BYPASS + , + plane, 1 +#endif + ); #else cost += get_br_lf_cost(abs_qc, txb_costs->lps_lf_cost_uv[br_ctx]); #endif // CONFIG_COEFF_HR_ADAPTIVE +#endif } } else { if (abs_qc > NUM_BASE_LEVELS) { @@ -3651,6 +3805,9 @@ if (plane > 0) { if (limits) { if (abs_qc > LF_NUM_BASE_LEVELS) { +#if CONFIG_COEFF_BR_LF_UV_BYPASS // cost + cost += get_br_lf_cost_uv(abs_qc, hr_level_avg, hr_level); +#else int br_ctx; if (is_last) br_ctx = get_br_ctx_lf_eob_chroma(ci, tx_class); @@ -3658,10 +3815,16 @@ br_ctx = get_br_lf_ctx_chroma(levels, ci, bwl, tx_class); #if CONFIG_COEFF_HR_ADAPTIVE cost += get_br_lf_cost(abs_qc, txb_costs->lps_lf_cost_uv[br_ctx], - hr_level_avg, hr_level); + hr_level_avg, hr_level +#if CONFIG_COEFF_BR_LF_UV_BYPASS + , + plane, is_last +#endif + ); #else cost += get_br_lf_cost(abs_qc, txb_costs->lps_lf_cost_uv[br_ctx]); #endif // CONFIG_COEFF_HR_ADAPTIVE +#endif } } else { if (abs_qc > NUM_BASE_LEVELS) { @@ -4729,6 +4892,9 @@ const int base_ctx_ph = get_base_ctx_ph(levels, pos, bwl, tx_class); int rate_ph = txb_costs_ph->base_ph_cost[base_ctx_ph][AOMMIN(q_index, 3)]; if (q_index > NUM_BASE_LEVELS) { +#if CONFIG_COEFF_BR_PH_BYPASS // cost + rate_ph += get_br_ph_cost(q_index, hr_level_avg, &dummy_hr_level); +#else int br_ctx = get_par_br_ctx(levels, pos, bwl, tx_class); #if CONFIG_COEFF_HR_ADAPTIVE rate_ph += get_br_cost(q_index, txb_costs_ph->lps_ph_cost[br_ctx], @@ -4736,6 +4902,7 @@ #else rate_ph += get_br_cost(q_index, txb_costs_ph->lps_ph_cost[br_ctx]); #endif // CONFIG_COEFF_HR_ADAPTIVE +#endif } #if CONFIG_IMPROVEIDTX const int dc_ph_group = 1; // PH enabled @@ -4792,6 +4959,10 @@ rate_cand += txb_costs->dc_sign_cost[dc_sign_ctx][tcoeff < 0]; #endif // CONFIG_IMPROVEIDTX if (q_index > NUM_BASE_LEVELS) { +#if CONFIG_COEFF_BR_PH_BYPASS // cost + int dummy_hr_level; + rate_cand += get_br_ph_cost(q_index, hr_level_avg, &dummy_hr_level); +#else int br_ctx = get_par_br_ctx(levels, pos, bwl, tx_class); #if CONFIG_COEFF_HR_ADAPTIVE int dummy_hr_level; @@ -4800,6 +4971,7 @@ #else rate_cand += get_br_cost(q_index, txb_costs_ph->lps_ph_cost[br_ctx]); #endif // CONFIG_COEFF_HR_ADAPTIVE +#endif } } int64_t cost_cand = RDCOST(rdmult, rate_cand, dist_cand); @@ -5937,7 +6109,11 @@ void update_coeff_ctx_hiden(TX_CLASS tx_class, const int16_t *scan, int bwl, uint8_t *levels, int level, - base_ph_cdf_arr base_cdf_ph, br_cdf_arr br_cdf_ph + base_ph_cdf_arr base_cdf_ph +#if !CONFIG_COEFF_BR_PH_BYPASS + , + br_cdf_arr br_cdf_ph +#endif #if CONFIG_ENTROPY_STATS , ThreadData *const td, int cdf_idx @@ -5951,6 +6127,7 @@ ++td->counts->coeff_base_ph_multi[cdf_idx][coeff_ctx][AOMMIN(level, 3)]; #endif // CONFIG_ENTROPY_STATS +#if !CONFIG_COEFF_BR_PH_BYPASS if (q_index > NUM_BASE_LEVELS) { int br_ctx = get_par_br_ctx(levels, pos, bwl, tx_class); aom_cdf_prob *cdf_br = br_cdf_ph[br_ctx]; @@ -5970,6 +6147,7 @@ if (k < BR_CDF_SIZE - 1) break; } } +#endif } void av1_update_and_record_txb_context(int plane, int block, int blk_row, int blk_col, BLOCK_SIZE plane_bsize, @@ -6144,7 +6322,8 @@ get_primary_tx_type(tx_type) < IDTX; #endif // CONFIG_IMPROVEIDTX #if CONFIG_TCQ - int state = tcq_init_state(cm->features.tcq_mode, plane, tx_class); + int tcq_mode = tcq_enable(cm->features.tcq_mode, plane, tx_class); + int state = tcq_init_state(tcq_mode); #endif // CONFIG_TCQ for (int c = eob - 1; c > 0; --c) { @@ -6371,6 +6550,7 @@ #if CONFIG_CHROMA_CODING if (plane > 0) { if (limits) { +#if !CONFIG_COEFF_BR_LF_UV_BYPASS if (level > LF_NUM_BASE_LEVELS) { const int base_range = level - 1 - LF_NUM_BASE_LEVELS; const int br_ctx = get_br_lf_ctx_chroma(levels, pos, bwl, tx_class); @@ -6391,6 +6571,7 @@ if (k < BR_CDF_SIZE - 1) break; } } +#endif } else { if (level > NUM_BASE_LEVELS) { const int base_range = level - 1 - NUM_BASE_LEVELS; @@ -6524,8 +6705,11 @@ if (allow_update_cdf) { const int level = abs(qcoeff[scan[0]]); update_coeff_ctx_hiden(tx_class, scan, bwl, levels, level, - ec_ctx->coeff_base_ph_cdf, + ec_ctx->coeff_base_ph_cdf +#if !CONFIG_COEFF_BR_PH_BYPASS + , ec_ctx->coeff_br_ph_cdf +#endif #if CONFIG_ENTROPY_STATS , td, cdf_idx @@ -6758,6 +6942,7 @@ #if CONFIG_CHROMA_CODING if (plane > 0) { if (limits) { +#if !CONFIG_COEFF_BR_LF_UV_BYPASS if (level > LF_NUM_BASE_LEVELS) { const int base_range = level - 1 - LF_NUM_BASE_LEVELS; const int br_ctx = get_br_lf_ctx_chroma(levels, pos, bwl, tx_class); @@ -6778,6 +6963,7 @@ if (k < BR_CDF_SIZE - 1) break; } } +#endif } else { if (level > NUM_BASE_LEVELS) { const int base_range = level - 1 - NUM_BASE_LEVELS;
diff --git a/av1/encoder/rd.c b/av1/encoder/rd.c index 8e57dfe..3d0d244 100644 --- a/av1/encoder/rd.c +++ b/av1/encoder/rd.c
@@ -1430,12 +1430,15 @@ #endif // CONFIG_CONTEXT_DERIVATION #if CONFIG_CHROMA_CODING +#if !CONFIG_COEFF_BR_LF_UV_BYPASS for (int ctx = 0; ctx < LF_LEVEL_CONTEXTS_UV; ++ctx) { int br_lf_cctx_rate[BR_CDF_SIZE]; int prev_cost_lf_cctx = 0; int i, j; +#if !CONFIG_COEFF_BR_LF_UV_BYPASS // cost av1_cost_tokens_from_cdf(br_lf_cctx_rate, fc->coeff_br_lf_uv_cdf[ctx], NULL); +#endif for (i = 0; i < COEFF_BASE_RANGE; i += BR_CDF_SIZE - 1) { for (j = 0; j < BR_CDF_SIZE - 1; j++) { pcost->lps_lf_cost_uv[ctx][i + j] = @@ -1453,6 +1456,7 @@ pcost->lps_lf_cost_uv[ctx][i] - pcost->lps_lf_cost_uv[ctx][i - 1]; } } +#endif for (int ctx = 0; ctx < LEVEL_CONTEXTS_UV; ++ctx) { int br_rate_cctx[BR_CDF_SIZE]; @@ -1647,6 +1651,7 @@ fc->coeff_base_ph_cdf[ctx], NULL); } +#if !CONFIG_COEFF_BR_PH_BYPASS // cost for (int ctx = 0; ctx < COEFF_BR_PH_CONTEXTS; ++ctx) { int br_ph_rate[BR_CDF_SIZE]; int prev_cost = 0; @@ -1668,6 +1673,7 @@ pcost->lps_ph_cost[ctx][i] - pcost->lps_ph_cost[ctx][i - 1]; } } +#endif } #if CONFIG_IBC_SUBPEL_PRECISION
diff --git a/av1/encoder/trellis_quant.c b/av1/encoder/trellis_quant.c index ad29864..249dfe7 100644 --- a/av1/encoder/trellis_quant.c +++ b/av1/encoder/trellis_quant.c
@@ -186,8 +186,12 @@ if (plane > 0) { if (limits) { if (abs_qc > LF_NUM_BASE_LEVELS) { +#if CONFIG_COEFF_BR_LF_UV_BYPASS // cost + cost += get_br_lf_cost_tcq_uv(abs_qc); +#else int br_ctx = get_br_ctx_lf_eob_chroma(ci, tx_class); cost += get_br_lf_cost_tcq(abs_qc, txb_costs->lps_lf_cost_uv[br_ctx]); +#endif } } else { if (abs_qc > NUM_BASE_LEVELS) { @@ -298,8 +302,12 @@ if (plane > 0) { if (limits) { if (abs_qc > LF_NUM_BASE_LEVELS) { +#if CONFIG_COEFF_BR_LF_UV_BYPASS // cost + cost += get_br_lf_cost_tcq_uv(abs_qc); +#else cost += get_br_lf_cost_tcq(abs_qc, txb_costs->lps_lf_cost_uv[mid_ctx]); +#endif } } else { if (abs_qc > NUM_BASE_LEVELS) { @@ -1132,9 +1140,13 @@ for (int i = 0; i < TCQ_N_STATES; i++) { int base_ctx = get_lower_levels_lf_ctx_chroma(prev_levels[i], blk_pos, bwl, tx_class, plane); +#if CONFIG_COEFF_BR_LF_UV_BYPASS + coeff_ctx.coef[i] = base_ctx - diag_ctx; +#else int br_ctx = get_br_lf_ctx_chroma(prev_levels[i], blk_pos, bwl, tx_class); coeff_ctx.coef[i] = base_ctx - diag_ctx + (br_ctx << 4); +#endif } av1_get_rate_dist_lf_chroma(txb_costs, &pqData, &coeff_ctx, blk_pos, diag_ctx, eob_rate, txb_ctx->dc_sign_ctx,
diff --git a/av1/encoder/trellis_quant.h b/av1/encoder/trellis_quant.h index 11b800c..6498e48 100644 --- a/av1/encoder/trellis_quant.h +++ b/av1/encoder/trellis_quant.h
@@ -99,6 +99,15 @@ return low; } +#if CONFIG_COEFF_BR_LF_UV_BYPASS +// Get the high range part of a coeff +static AOM_FORCE_INLINE int get_high_range_uv(int abs_qc, int lf) { + int base_levels = lf ? 6 : 4; + int high_range = (abs_qc - (base_levels - 1)) >> 1; + return high_range; +} +#endif + // Get the high range part of a coeff static AOM_FORCE_INLINE int get_high_range(int abs_qc, int lf) { int base_levels = lf ? 6 : 4; @@ -115,6 +124,15 @@ return 0; } +#if CONFIG_COEFF_BR_LF_UV_BYPASS +// Calculate the cost of low range of a coeff in low-freq region +static AOM_FORCE_INLINE int get_br_lf_cost_tcq_uv(tran_low_t level) { + const int r = 1 + get_high_range_uv(level, 1); + const int length = get_msb(r) + 1; + return av1_cost_literal(2 * length - 1); +} +#endif + // Calculate the cost of low range of a coeff in low-freq region static AOM_FORCE_INLINE int get_br_lf_cost_tcq(tran_low_t level, const int *coeff_lps) {
diff --git a/av1/encoder/x86/trellis_quant_avx2.c b/av1/encoder/x86/trellis_quant_avx2.c index c7e1b34..7db1dbd 100644 --- a/av1/encoder/x86/trellis_quant_avx2.c +++ b/av1/encoder/x86/trellis_quant_avx2.c
@@ -364,8 +364,12 @@ } if (plane > 0) { if (abs_qc > LF_NUM_BASE_LEVELS) { +#if CONFIG_COEFF_BR_LF_UV_BYPASS // cost + cost += get_br_lf_cost_tcq_uv(abs_qc); +#else int br_ctx = get_br_ctx_lf_eob_chroma(ci, tx_class); cost += get_br_lf_cost_tcq(abs_qc, txb_costs->lps_lf_cost_uv[br_ctx]); +#endif } } else { if (abs_qc > LF_NUM_BASE_LEVELS) { @@ -409,9 +413,13 @@ else cost += txb_costs->dc_sign_cost[dc_ph_group][dc_sign_ctx][sign]; if (plane > 0) { +#if CONFIG_COEFF_BR_LF_UV_BYPASS // cost + cost += get_br_lf_cost_tcq_uv(abs_qc); +#else if (abs_qc > LF_NUM_BASE_LEVELS) { cost += get_br_lf_cost_tcq(abs_qc, txb_costs->lps_lf_cost_uv[mid_ctx]); } +#endif } else { if (abs_qc > LF_NUM_BASE_LEVELS) { cost += get_br_lf_cost_tcq(abs_qc, txb_costs->lps_lf_cost[mid_ctx]);
diff --git a/build/cmake/aom_config_defaults.cmake b/build/cmake/aom_config_defaults.cmake index 74d2605..89287c2 100644 --- a/build/cmake/aom_config_defaults.cmake +++ b/build/cmake/aom_config_defaults.cmake
@@ -223,6 +223,12 @@ CONFIG_CONTEXT_DERIVATION 1 "AV2 experiment flag to enable modified context derivation : CWG-B065.") +set_aom_config_var(CONFIG_COEFF_BR_LF_UV_BYPASS 1 + "AV2 experiment flag to bypass UV LF syntax. FG8-Test9.") + +set_aom_config_var(CONFIG_COEFF_BR_PH_BYPASS 1 + "AV2 experiment flag to bypass BR PH syntax. FG8-Test10.") + set_aom_config_var(CONFIG_EXTENDED_SDP 1 "Enable SDP for intra blocks in inter frame") set_aom_config_var(