0 LR for LF and 1 LR for default ctx 3 clean
diff --git a/av1/common/entropy.c b/av1/common/entropy.c
index c607734..f0f6d01 100644
--- a/av1/common/entropy.c
+++ b/av1/common/entropy.c
@@ -65,16 +65,14 @@
av1_default_coeff_base_lf_eob_multi_cdfs[index]);
#if !CONFIG_ADAPTIVE_HR
av1_copy(cm->fc->coeff_br_lf_cdf, av1_default_coeff_lps_lf_multi_cdfs[index]);
- av1_copy(cm->fc->coeff_br_cdf, av1_default_coeff_lps_multi_cdfs[index]);
#endif // !CONFIG_ADAPTIVE_HR
+ av1_copy(cm->fc->coeff_br_cdf, av1_default_coeff_lps_multi_cdfs[index]);
av1_copy(cm->fc->coeff_base_cdf, av1_default_coeff_base_multi_cdfs[index]);
av1_copy(cm->fc->idtx_sign_cdf, av1_default_idtx_sign_cdfs[index]);
av1_copy(cm->fc->coeff_base_cdf_idtx,
av1_default_coeff_base_multi_cdfs_idtx[index]);
-#if !CONFIG_ADAPTIVE_HR
av1_copy(cm->fc->coeff_br_cdf_idtx,
av1_default_coeff_lps_multi_cdfs_idtx[index]);
-#endif // !CONFIG_ADAPTIVE_HR
av1_copy(cm->fc->coeff_base_eob_cdf,
av1_default_coeff_base_eob_multi_cdfs[index]);
av1_copy(cm->fc->eob_flag_cdf16, av1_default_eob_multi16_cdfs[index]);
@@ -85,9 +83,7 @@
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_ADAPTIVE_HR
av1_copy(cm->fc->coeff_br_ph_cdf, av1_default_coeff_br_ph_cdfs[index]);
-#endif // !CONFIG_ADAPTIVE_HR
av1_copy(cm->fc->coeff_base_bob_cdf,
av1_default_coeff_base_bob_multi_cdfs[index]);
}
@@ -161,10 +157,8 @@
RESET_CDF_COUNTER(fc->coeff_base_cdf, 4);
RESET_CDF_COUNTER(fc->idtx_sign_cdf, 2);
RESET_CDF_COUNTER(fc->coeff_base_cdf_idtx, 4);
-#if !CONFIG_ADAPTIVE_HR
RESET_CDF_COUNTER(fc->coeff_br_cdf_idtx, BR_CDF_SIZE);
RESET_CDF_COUNTER(fc->coeff_br_cdf, BR_CDF_SIZE);
-#endif // !CONFIG_ADAPTIVE_HR
RESET_CDF_COUNTER(fc->inter_single_mode_cdf, INTER_SINGLE_MODES);
#if CONFIG_EXTENDED_WARP_PREDICTION
RESET_CDF_COUNTER(fc->inter_warp_mode_cdf, 2);
@@ -446,8 +440,6 @@
}
RESET_CDF_COUNTER(fc->coeff_base_ph_cdf, NUM_BASE_LEVELS + 2);
-#if !CONFIG_ADAPTIVE_HR
RESET_CDF_COUNTER(fc->coeff_br_ph_cdf, BR_CDF_SIZE);
-#endif // !CONFIG_ADAPTIVE_HR
RESET_CDF_COUNTER(fc->cctx_type_cdf, CCTX_TYPES);
}
diff --git a/av1/common/entropy.h b/av1/common/entropy.h
index 0efcca2..5e7cb61 100644
--- a/av1/common/entropy.h
+++ b/av1/common/entropy.h
@@ -66,7 +66,8 @@
// Number of symbols for base range coding in low-frequency region
#define LF_BASE_SYMBOLS 6
#define LF_NUM_BASE_LEVELS (LF_BASE_SYMBOLS - 2)
-#define LF_MAX_BASE_BR_RANGE (COEFF_BASE_RANGE + LF_NUM_BASE_LEVELS + 1)
+#define LF_COEFF_BASE_RANGE (0 * (BR_CDF_SIZE - 1))
+#define LF_MAX_BASE_BR_RANGE (LF_COEFF_BASE_RANGE + LF_NUM_BASE_LEVELS + 1)
// Limits to determine the low-frequency region for coefficient coding.
#define LF_2D_LIM 4 // row + column limit
@@ -82,14 +83,8 @@
#define NUM_BASE_LEVELS 2
-#if CONFIG_ADAPTIVE_HR
-#define BR_NUM_ITERATIONS 0
-#else
-#define BR_NUM_ITERATIONS 4
-#endif // CONFIG_ADAPTIVE_HR
-
#define BR_CDF_SIZE (4)
-#define COEFF_BASE_RANGE (BR_NUM_ITERATIONS * (BR_CDF_SIZE - 1))
+#define COEFF_BASE_RANGE (1 * (BR_CDF_SIZE - 1))
#define COEFF_CONTEXT_BITS 3
#define COEFF_CONTEXT_MASK ((1 << COEFF_CONTEXT_BITS) - 1)
#define MAX_BASE_BR_RANGE (COEFF_BASE_RANGE + NUM_BASE_LEVELS + 1)
diff --git a/av1/common/entropymode.h b/av1/common/entropymode.h
index d8497b4..ec773b5 100644
--- a/av1/common/entropymode.h
+++ b/av1/common/entropymode.h
@@ -199,9 +199,7 @@
[CDF_SIZE(4)];
aom_cdf_prob idtx_sign_cdf[IDTX_SIGN_CONTEXTS][CDF_SIZE(2)];
aom_cdf_prob coeff_base_cdf_idtx[IDTX_SIG_COEF_CONTEXTS][CDF_SIZE(4)];
-#if !CONFIG_ADAPTIVE_HR
aom_cdf_prob coeff_br_cdf_idtx[IDTX_LEVEL_CONTEXTS][CDF_SIZE(BR_CDF_SIZE)];
-#endif // !CONFIG_ADAPTIVE_HR
aom_cdf_prob coeff_base_lf_cdf[TX_SIZES][PLANE_TYPES][LF_SIG_COEF_CONTEXTS]
[CDF_SIZE(LF_BASE_SYMBOLS)];
aom_cdf_prob coeff_base_lf_eob_cdf[TX_SIZES][PLANE_TYPES]
@@ -210,13 +208,12 @@
#if !CONFIG_ADAPTIVE_HR
aom_cdf_prob coeff_br_lf_cdf[PLANE_TYPES][LF_LEVEL_CONTEXTS]
[CDF_SIZE(BR_CDF_SIZE)];
- aom_cdf_prob coeff_br_cdf[PLANE_TYPES][LEVEL_CONTEXTS][CDF_SIZE(BR_CDF_SIZE)];
#endif // !CONFIG_ADAPTIVE_HR
+ aom_cdf_prob coeff_br_cdf[PLANE_TYPES][LEVEL_CONTEXTS][CDF_SIZE(BR_CDF_SIZE)];
+
aom_cdf_prob coeff_base_ph_cdf[COEFF_BASE_PH_CONTEXTS]
[CDF_SIZE(NUM_BASE_LEVELS + 2)];
-#if !CONFIG_ADAPTIVE_HR
aom_cdf_prob coeff_br_ph_cdf[COEFF_BR_PH_CONTEXTS][CDF_SIZE(BR_CDF_SIZE)];
-#endif // !CONFIG_ADAPTIVE_HR
aom_cdf_prob inter_single_mode_cdf[INTER_SINGLE_MODE_CONTEXTS]
[CDF_SIZE(INTER_SINGLE_MODES)];
diff --git a/av1/common/hr_coding.c b/av1/common/hr_coding.c
index 4279c6a..2ed2b06 100644
--- a/av1/common/hr_coding.c
+++ b/av1/common/hr_coding.c
@@ -64,13 +64,13 @@
#if CONFIG_ADAPTIVE_HR
-static const int adaptive_table[] = { 5, 10, 15, 35, 70, 135 };
+static const int adaptive_table[] = { 10, 15, 35, 70, 135 };
static const int table_size = sizeof(adaptive_table) / sizeof(int);
static int get_adaptive_param(int ctx) {
int m = 0;
while (m < table_size && ctx > adaptive_table[m]) ++m;
- return m;
+ return m + 1;
}
void write_truncated_rice(aom_writer *w, int level, int m, int k, int cmax) {
diff --git a/av1/common/txb_common.h b/av1/common/txb_common.h
index 92c2a16..2695725 100644
--- a/av1/common/txb_common.h
+++ b/av1/common/txb_common.h
@@ -131,9 +131,9 @@
const int col = c - (row << bwl);
const int stride = (1 << bwl) + TX_PAD_HOR;
const int pos = row * stride + col;
- int mag = AOMMIN(levels[pos + 1], MAX_BASE_BR_RANGE) +
- AOMMIN(levels[pos + stride], MAX_BASE_BR_RANGE) +
- AOMMIN(levels[pos + 1 + stride], MAX_BASE_BR_RANGE);
+ int mag = AOMMIN(levels[pos + 1], LF_MAX_BASE_BR_RANGE) +
+ AOMMIN(levels[pos + stride], LF_MAX_BASE_BR_RANGE) +
+ AOMMIN(levels[pos + 1 + stride], LF_MAX_BASE_BR_RANGE);
mag = AOMMIN((mag + 1) >> 1, 6);
return mag + 7;
}
@@ -149,22 +149,22 @@
const int col = c - (row << bwl);
const int stride = (1 << bwl) + TX_PAD_HOR;
const int pos = row * stride + col;
- int mag = AOMMIN(levels[pos + 1], MAX_BASE_BR_RANGE);
- mag += AOMMIN(levels[pos + stride], MAX_BASE_BR_RANGE);
+ int mag = AOMMIN(levels[pos + 1], LF_MAX_BASE_BR_RANGE);
+ mag += AOMMIN(levels[pos + stride], LF_MAX_BASE_BR_RANGE);
switch (tx_class) {
case TX_CLASS_2D:
- mag += AOMMIN(levels[pos + stride + 1], MAX_BASE_BR_RANGE);
+ mag += AOMMIN(levels[pos + stride + 1], LF_MAX_BASE_BR_RANGE);
mag = AOMMIN((mag + 1) >> 1, 6);
if (c == 0) return mag;
if ((row < 2) && (col < 2)) return mag + 7;
break;
case TX_CLASS_HORIZ:
- mag += AOMMIN(levels[pos + 2], MAX_BASE_BR_RANGE);
+ mag += AOMMIN(levels[pos + 2], LF_MAX_BASE_BR_RANGE);
mag = AOMMIN((mag + 1) >> 1, 6);
if (col == 0) return mag + 7;
break;
case TX_CLASS_VERT:
- mag += AOMMIN(levels[pos + (stride << 1)], MAX_BASE_BR_RANGE);
+ mag += AOMMIN(levels[pos + (stride << 1)], LF_MAX_BASE_BR_RANGE);
mag = AOMMIN((mag + 1) >> 1, 6);
if (row == 0) return mag + 7;
break;
@@ -270,12 +270,12 @@
int mag;
// Note: AOMMIN(level, 5) is useless for decoder since level < 5.
- mag = clip_max3[levels[1]]; // { 0, 1 }
- mag += clip_max3[levels[(1 << bwl) + TX_PAD_HOR]]; // { 1, 0 }
+ mag = clip_max5[levels[1]]; // { 0, 1 }
+ mag += clip_max5[levels[(1 << bwl) + TX_PAD_HOR]]; // { 1, 0 }
if (tx_class == TX_CLASS_2D) {
- mag += clip_max3[levels[(1 << bwl) + TX_PAD_HOR + 1]]; // { 1, 1 }
- mag += clip_max3[levels[2]]; // { 0, 2 }
- mag += clip_max3[levels[(2 << bwl) + (2 << TX_PAD_HOR_LOG2)]]; // { 2, 0 }
+ mag += clip_max5[levels[(1 << bwl) + TX_PAD_HOR + 1]]; // { 1, 1 }
+ mag += clip_max5[levels[2]]; // { 0, 2 }
+ mag += clip_max5[levels[(2 << bwl) + (2 << TX_PAD_HOR_LOG2)]]; // { 2, 0 }
} else if (tx_class == TX_CLASS_VERT) {
mag += clip_max3[levels[(2 << bwl) + (2 << TX_PAD_HOR_LOG2)]]; // { 2, 0 }
mag += clip_max3[levels[(3 << bwl) + (3 << TX_PAD_HOR_LOG2)]]; // { 3, 0 }
@@ -469,19 +469,19 @@
const int col = c - (row << bwl);
const int stride = (1 << bwl) + TX_PAD_HOR;
const int pos = row * stride + col;
- int mag = AOMMIN(levels[pos + 1], MAX_BASE_BR_RANGE);
- mag += AOMMIN(levels[pos + stride], MAX_BASE_BR_RANGE);
+ int mag = AOMMIN(levels[pos + 1], LF_MAX_BASE_BR_RANGE);
+ mag += AOMMIN(levels[pos + stride], LF_MAX_BASE_BR_RANGE);
switch (tx_class) {
case TX_CLASS_2D:
- mag += AOMMIN(levels[pos + stride + 1], MAX_BASE_BR_RANGE);
+ mag += AOMMIN(levels[pos + stride + 1], LF_MAX_BASE_BR_RANGE);
mag = AOMMIN((mag + 1) >> 1, (COEFF_BR_PH_CONTEXTS - 1));
break;
case TX_CLASS_HORIZ:
- mag += AOMMIN(levels[pos + 2], MAX_BASE_BR_RANGE);
+ mag += AOMMIN(levels[pos + 2], LF_MAX_BASE_BR_RANGE);
mag = AOMMIN((mag + 1) >> 1, (COEFF_BR_PH_CONTEXTS - 1));
break;
case TX_CLASS_VERT:
- mag += AOMMIN(levels[pos + (stride << 1)], MAX_BASE_BR_RANGE);
+ mag += AOMMIN(levels[pos + (stride << 1)], LF_MAX_BASE_BR_RANGE);
mag = AOMMIN((mag + 1) >> 1, (COEFF_BR_PH_CONTEXTS - 1));
break;
default: break;
@@ -524,11 +524,11 @@
int mag;
// Note: AOMMIN(level, 3) is useless for decoder since level < 5.
levels = levels + get_padded_idx(coeff_idx, bwl);
- mag = AOMMIN(levels[1], 3); // { 0, 1 }
- mag += AOMMIN(levels[(1 << bwl) + TX_PAD_HOR], 3); // { 1, 0 }
- mag += AOMMIN(levels[(1 << bwl) + TX_PAD_HOR + 1], 3); // { 1, 1 }
- mag += AOMMIN(levels[2], 3); // { 0, 2 }
- mag += AOMMIN(levels[(2 << bwl) + (2 << TX_PAD_HOR_LOG2)], 3); // { 2, 0 }
+ mag = AOMMIN(levels[1], 5); // { 0, 1 }
+ mag += AOMMIN(levels[(1 << bwl) + TX_PAD_HOR], 5); // { 1, 0 }
+ mag += AOMMIN(levels[(1 << bwl) + TX_PAD_HOR + 1], 5); // { 1, 1 }
+ mag += AOMMIN(levels[2], 5); // { 0, 2 }
+ mag += AOMMIN(levels[(2 << bwl) + (2 << TX_PAD_HOR_LOG2)], 5); // { 2, 0 }
int ctx = (mag + 1) >> 1;
const int row = coeff_idx >> bwl;
const int col = coeff_idx - (row << bwl);
diff --git a/av1/decoder/decodetxb.c b/av1/decoder/decodetxb.c
index 19974d6..64cc045 100644
--- a/av1/decoder/decodetxb.c
+++ b/av1/decoder/decodetxb.c
@@ -57,7 +57,7 @@
if (level > LF_NUM_BASE_LEVELS) {
const int br_ctx = get_br_lf_ctx_2d(levels, pos, bwl);
aom_cdf_prob *cdf = br_lf_cdf[br_ctx];
- for (int idx = 0; idx < COEFF_BASE_RANGE; idx += BR_CDF_SIZE - 1) {
+ for (int idx = 0; idx < LF_COEFF_BASE_RANGE; idx += BR_CDF_SIZE - 1) {
const int k =
aom_read_symbol(r, cdf, BR_CDF_SIZE, ACCT_INFO("k", "br_lf_cdf"));
level += k;
@@ -75,7 +75,6 @@
level += aom_read_symbol(r, base_cdf[coeff_ctx], 4,
ACCT_INFO("level", "base_cdf"));
-#if !CONFIG_ADAPTIVE_HR
if (level > NUM_BASE_LEVELS) {
const int br_ctx = get_br_ctx_2d(levels, pos, bwl);
aom_cdf_prob *cdf = br_cdf[br_ctx];
@@ -86,7 +85,6 @@
if (k < BR_CDF_SIZE - 1) break;
}
}
-#endif // !CONFIG_ADAPTIVE_HR
}
levels[get_padded_idx(pos, bwl)] = level;
}
@@ -111,7 +109,7 @@
if (level > LF_NUM_BASE_LEVELS) {
const int br_ctx = get_br_lf_ctx(levels, pos, bwl, tx_class);
aom_cdf_prob *cdf = br_lf_cdf[br_ctx];
- for (int idx = 0; idx < COEFF_BASE_RANGE; idx += BR_CDF_SIZE - 1) {
+ for (int idx = 0; idx < LF_COEFF_BASE_RANGE; idx += BR_CDF_SIZE - 1) {
const int k =
aom_read_symbol(r, cdf, BR_CDF_SIZE, ACCT_INFO("k", "br_lf_cdf"));
level += k;
@@ -129,7 +127,6 @@
level += aom_read_symbol(r, base_cdf[coeff_ctx], 4,
ACCT_INFO("level", "base_cdf"));
-#if !CONFIG_ADAPTIVE_HR
if (level > NUM_BASE_LEVELS) {
const int br_ctx = get_br_ctx(levels, pos, bwl, tx_class);
aom_cdf_prob *cdf = br_cdf[br_ctx];
@@ -140,7 +137,6 @@
if (k < BR_CDF_SIZE - 1) break;
}
}
-#endif // !CONFIG_ADAPTIVE_HR
}
levels[get_padded_idx(pos, bwl)] = level;
}
@@ -158,7 +154,6 @@
int level = aom_read_symbol(r, base_cdf[coeff_ctx], nsymbs,
ACCT_INFO("level", "base_cdf"));
-#if !CONFIG_ADAPTIVE_HR
if (level > NUM_BASE_LEVELS) {
const int br_ctx = get_br_ctx_skip(levels, pos, bwl);
aom_cdf_prob *cdf = br_cdf[br_ctx];
@@ -169,7 +164,6 @@
if (k < BR_CDF_SIZE - 1) break;
}
}
-#endif // !CONFIG_ADAPTIVE_HR
levels[get_padded_idx_left(pos, bwl)] = level;
}
}
@@ -432,11 +426,8 @@
memset(levels_buf, 0, sizeof(*levels_buf) * TX_PAD_2D);
memset(signs_buf, 0, sizeof(*signs_buf) * TX_PAD_2D);
base_cdf_arr base_cdf = ec_ctx->coeff_base_cdf_idtx;
-#if !CONFIG_ADAPTIVE_HR
br_cdf_arr br_cdf = ec_ctx->coeff_br_cdf_idtx;
-#else
- br_cdf_arr br_cdf;
-#endif // !CONFIG_ADAPTIVE_HR
+
const int bob = av1_get_max_eob(tx_size) - bob_data->eob;
{
const int pos = scan[bob];
@@ -446,8 +437,6 @@
int level = aom_read_symbol(r, cdf_bob, nsymbs_bob,
ACCT_INFO("level", "cdf_bob")) +
1;
-
-#if !CONFIG_ADAPTIVE_HR
if (level > NUM_BASE_LEVELS) {
const int br_ctx = get_br_ctx_skip(levels, pos, bwl);
aom_cdf_prob *cdf = br_cdf[br_ctx];
@@ -458,7 +447,6 @@
if (k < BR_CDF_SIZE - 1) break;
}
}
-#endif // !CONFIG_ADAPTIVE_HR
levels[get_padded_idx_left(pos, bwl)] = level;
}
read_coeffs_forward_2d(r, bob + 1, eob_data->eob - 1, scan, bwl, levels,
@@ -527,7 +515,6 @@
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_ADAPTIVE_HR
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];
@@ -539,7 +526,6 @@
}
}
-#endif // !CONFIG_ADAPTIVE_HR
assert(q_index <= MAX_BASE_BR_RANGE);
uint8_t level = (q_index << 1) + parity;
levels[get_padded_idx(pos, bwl)] = level;
@@ -641,7 +627,7 @@
if (level > LF_NUM_BASE_LEVELS) {
const int br_ctx = get_br_ctx_lf_eob(pos, tx_class);
cdf = ec_ctx->coeff_br_lf_cdf[plane_type][br_ctx];
- for (int idx = 0; idx < COEFF_BASE_RANGE; idx += BR_CDF_SIZE - 1) {
+ for (int idx = 0; idx < LF_COEFF_BASE_RANGE; idx += BR_CDF_SIZE - 1) {
const int k = aom_read_symbol(r, cdf, BR_CDF_SIZE,
ACCT_INFO("k", "coeff_br_lf_cdf"));
level += k;
@@ -656,7 +642,6 @@
aom_read_symbol(r, cdf, 3, ACCT_INFO("level", "coeff_base_eob_cdf")) +
1;
-#if !CONFIG_ADAPTIVE_HR
if (level > NUM_BASE_LEVELS) {
const int br_ctx = 0; /* get_lf_ctx_eob */
cdf = ec_ctx->coeff_br_cdf[plane_type][br_ctx];
@@ -667,7 +652,6 @@
if (k < BR_CDF_SIZE - 1) break;
}
}
-#endif // !CONFIG_ADAPTIVE_HR
}
levels[get_padded_idx(pos, bwl)] = level;
}
@@ -680,12 +664,11 @@
base_lf_cdf_arr base_lf_cdf =
ec_ctx->coeff_base_lf_cdf[txs_ctx][plane_type];
base_cdf_arr base_cdf = ec_ctx->coeff_base_cdf[txs_ctx][plane_type];
+ br_cdf_arr br_cdf = ec_ctx->coeff_br_cdf[plane_type];
#if !CONFIG_ADAPTIVE_HR
br_cdf_arr br_lf_cdf = ec_ctx->coeff_br_lf_cdf[plane_type];
- br_cdf_arr br_cdf = ec_ctx->coeff_br_cdf[plane_type];
#else
br_cdf_arr br_lf_cdf = NULL;
- br_cdf_arr br_cdf = NULL;
#endif // !CONFIG_ADAPTIVE_HR
if (tx_class == TX_CLASS_2D) {
@@ -695,7 +678,7 @@
for (int si = *eob - 1; si > 0; --si) {
int pos = scan[si];
int level =
- AOMMIN(levels[get_padded_idx(pos, bwl)], MAX_BASE_BR_RANGE);
+ AOMMIN(levels[get_padded_idx(pos, bwl)], LF_MAX_BASE_BR_RANGE);
if (level) {
++num_nz;
sum_abs1 += level;
@@ -705,13 +688,7 @@
}
if (is_hidden) {
read_coeff_hidden(r, tx_class, scan, bwl, levels, (sum_abs1 & 1),
- ec_ctx->coeff_base_ph_cdf
-#if !CONFIG_ADAPTIVE_HR
- , ec_ctx->coeff_br_ph_cdf
-#else
- , NULL
-#endif // !CONFIG_ADAPTIVE_HR
- );
+ ec_ctx->coeff_base_ph_cdf, ec_ctx->coeff_br_ph_cdf);
} else {
read_coeffs_reverse(r, tx_class, 0, 0, scan, bwl, levels, base_lf_cdf,
br_lf_cdf, plane, base_cdf, br_cdf);
@@ -723,7 +700,7 @@
for (int si = *eob - 1; si > 0; --si) {
int pos = scan[si];
int level =
- AOMMIN(levels[get_padded_idx(pos, bwl)], MAX_BASE_BR_RANGE);
+ AOMMIN(levels[get_padded_idx(pos, bwl)], LF_MAX_BASE_BR_RANGE);
if (level) {
++num_nz;
sum_abs1 += level;
@@ -733,13 +710,7 @@
}
if (is_hidden) {
read_coeff_hidden(r, tx_class, scan, bwl, levels, (sum_abs1 & 1),
- ec_ctx->coeff_base_ph_cdf
-#if !CONFIG_ADAPTIVE_HR
- , ec_ctx->coeff_br_ph_cdf
-#else
- , NULL
-#endif // !CONFIG_ADAPTIVE_HR
- );
+ ec_ctx->coeff_base_ph_cdf, ec_ctx->coeff_br_ph_cdf);
} else {
read_coeffs_reverse(r, tx_class, 0, 0, scan, bwl, levels, base_lf_cdf,
br_lf_cdf, plane, base_cdf, br_cdf);
diff --git a/av1/encoder/block.h b/av1/encoder/block.h
index baf8306..dff2c94 100644
--- a/av1/encoder/block.h
+++ b/av1/encoder/block.h
@@ -166,7 +166,7 @@
int base_lf_cost[LF_SIG_COEF_CONTEXTS][LF_BASE_SYMBOLS * 2];
//! Cost for encoding an increment to the low-frequency coefficient
int lps_lf_cost[LF_LEVEL_CONTEXTS]
- [COEFF_BASE_RANGE + 1 + COEFF_BASE_RANGE + 1];
+ [LF_COEFF_BASE_RANGE + 1 + LF_COEFF_BASE_RANGE + 1];
//! 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
diff --git a/av1/encoder/encodemb.c b/av1/encoder/encodemb.c
index cfbacc4..3dfc385 100644
--- a/av1/encoder/encodemb.c
+++ b/av1/encoder/encodemb.c
@@ -138,7 +138,7 @@
for (int si = eob - 1; si > 0; si--) {
const int pos = scan[si];
nz += !!(qcoeff[pos]);
- sum_abs1 += AOMMIN(abs(qcoeff[pos]), MAX_BASE_BR_RANGE);
+ sum_abs1 += AOMMIN(abs(qcoeff[pos]), LF_MAX_BASE_BR_RANGE);
}
if (nz >= PHTHRESH && ((qcoeff[0] & 1) != (sum_abs1 & 1))) {
int tune_pos = scan[0];
@@ -160,8 +160,8 @@
absdqcoeff = abs(dqcoeff[pos]);
absqcoeff = abs(qcoeff[pos]);
bool tunable =
- (absqcoeff < MAX_BASE_BR_RANGE) ||
- ((absqcoeff == MAX_BASE_BR_RANGE) && (abstcoeff < absdqcoeff));
+ (absqcoeff < LF_MAX_BASE_BR_RANGE) ||
+ ((absqcoeff == LF_MAX_BASE_BR_RANGE) && (abstcoeff < absdqcoeff));
absqcoeff += ((abstcoeff < absdqcoeff) ? -1 : 1);
absdqcoeff = (tran_low_t)(ROUND_POWER_OF_TWO_64(
(tran_high_t)absqcoeff *
diff --git a/av1/encoder/encodetxb.c b/av1/encoder/encodetxb.c
index 653fbea..6505ebc 100644
--- a/av1/encoder/encodetxb.c
+++ b/av1/encoder/encodetxb.c
@@ -53,8 +53,8 @@
}
coef_info[scan_idx].tunable =
- (abs(coef_info[scan_idx].qc) < MAX_BASE_BR_RANGE) ||
- ((abs(qc_up) == MAX_BASE_BR_RANGE) && upround);
+ (abs(coef_info[scan_idx].qc) < LF_MAX_BASE_BR_RANGE) ||
+ ((abs(qc_up) == LF_MAX_BASE_BR_RANGE) && upround);
if (coef_info[scan_idx].tunable) {
if (upround) {
coef_info[scan_idx].delta_cost = (cost_low - cost_up);
@@ -292,11 +292,11 @@
static INLINE int get_br_lf_cost(tran_low_t level, const int *coeff_lps,
int hr_ctx) {
const int base_range =
- AOMMIN(level - 1 - LF_NUM_BASE_LEVELS, COEFF_BASE_RANGE);
+ AOMMIN(level - 1 - LF_NUM_BASE_LEVELS, LF_COEFF_BASE_RANGE);
int cost = coeff_lps[base_range];
- if (level >= 1 + LF_NUM_BASE_LEVELS + COEFF_BASE_RANGE) {
- const int r = level - COEFF_BASE_RANGE - LF_NUM_BASE_LEVELS - 1;
+ if (level >= 1 + LF_NUM_BASE_LEVELS + LF_COEFF_BASE_RANGE) {
+ const int r = level - LF_COEFF_BASE_RANGE - LF_NUM_BASE_LEVELS - 1;
cost += av1_cost_literal(get_adaptive_hr_length(r, hr_ctx));
}
return cost;
@@ -325,14 +325,14 @@
const int *coeff_lps, int *diff,
int hr_ctx) {
const int base_range =
- AOMMIN(level - 1 - LF_NUM_BASE_LEVELS, COEFF_BASE_RANGE);
+ AOMMIN(level - 1 - LF_NUM_BASE_LEVELS, LF_COEFF_BASE_RANGE);
int cost = coeff_lps[base_range];
- if (level <= COEFF_BASE_RANGE + 1 + LF_NUM_BASE_LEVELS)
- *diff += coeff_lps[base_range + COEFF_BASE_RANGE + 1];
+ if (level <= LF_COEFF_BASE_RANGE + 1 + LF_NUM_BASE_LEVELS)
+ *diff += coeff_lps[base_range + LF_COEFF_BASE_RANGE + 1];
- if (level >= COEFF_BASE_RANGE + 1 + LF_NUM_BASE_LEVELS) {
- const int r = level - COEFF_BASE_RANGE - LF_NUM_BASE_LEVELS - 1;
+ if (level >= LF_COEFF_BASE_RANGE + 1 + LF_NUM_BASE_LEVELS) {
+ const int r = level - LF_COEFF_BASE_RANGE - LF_NUM_BASE_LEVELS - 1;
int bits, diff_bits;
bits = get_adaptive_hr_length_diff(r, hr_ctx, &diff_bits);
*diff += av1_cost_literal(diff_bits);
@@ -772,7 +772,6 @@
ec_ctx->coeff_base_cdf_idtx[coeff_ctx], 4);
}
-#if !CONFIG_ADAPTIVE_HR
if (level > NUM_BASE_LEVELS) {
// level is above 1.
const int base_range = level - 1 - NUM_BASE_LEVELS;
@@ -784,7 +783,6 @@
if (k < BR_CDF_SIZE - 1) break;
}
}
-#endif // !CONFIG_ADAPTIVE_HR
}
// Loop to code all signs, bypass levels in the transform block
for (int c = eob - 1; c >= 0; --c) {
@@ -820,7 +818,6 @@
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_ADAPTIVE_HR
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];
@@ -831,7 +828,6 @@
if (k < BR_CDF_SIZE - 1) break;
}
}
-#endif // !CONFIG_ADAPTIVE_HR
}
void av1_write_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCK *const x,
@@ -943,20 +939,22 @@
const int row = pos >> bwl;
const int col = pos - (row << bwl);
int limits = get_lf_limits(row, col, tx_class, plane);
-#if !CONFIG_ADAPTIVE_HR
if (limits) {
+#if !CONFIG_ADAPTIVE_HR
if (level > LF_NUM_BASE_LEVELS) {
const int base_range =
level - 1 - LF_NUM_BASE_LEVELS; // level is above 1.
const int br_ctx = get_br_lf_ctx(levels, pos, bwl, tx_class);
aom_cdf_prob *cdf = ec_ctx->coeff_br_lf_cdf[plane_type][br_ctx];
- for (int idx = 0; idx < COEFF_BASE_RANGE; idx += BR_CDF_SIZE - 1) {
+ for (int idx = 0; idx < LF_COEFF_BASE_RANGE; idx += BR_CDF_SIZE - 1) {
const int k = AOMMIN(base_range - idx, BR_CDF_SIZE - 1);
aom_write_symbol(w, k, cdf, BR_CDF_SIZE);
if (k < BR_CDF_SIZE - 1) break;
}
}
+#endif // !CONFIG_ADAPTIVE_HR
} else {
+
if (level > NUM_BASE_LEVELS) {
const int base_range = level - 1 - NUM_BASE_LEVELS;
const int br_ctx = get_br_ctx(levels, pos, bwl, tx_class);
@@ -968,7 +966,6 @@
}
}
}
-#endif // !CONFIG_ADAPTIVE_HR
}
int num_nz = 0;
@@ -984,14 +981,9 @@
const int pos = scan[0];
const tran_low_t v = tcoeff[pos];
const tran_low_t level = abs(v);
+
write_coeff_hidden(w, tx_class, scan, bwl, levels, level,
- ec_ctx->coeff_base_ph_cdf
-#if !CONFIG_ADAPTIVE_HR
- , ec_ctx->coeff_br_ph_cdf
- #else
- , NULL
- #endif // !CONFIG_ADAPTIVE_HR
- );
+ ec_ctx->coeff_base_ph_cdf, ec_ctx->coeff_br_ph_cdf);
} else {
const int c = 0;
const int pos = scan[c];
@@ -1032,19 +1024,20 @@
const int row = pos >> bwl;
const int col = pos - (row << bwl);
int limits = get_lf_limits(row, col, tx_class, plane);
-#if !CONFIG_ADAPTIVE_HR
if (limits) {
+ #if !CONFIG_ADAPTIVE_HR
if (level > LF_NUM_BASE_LEVELS) {
const int base_range =
level - 1 - LF_NUM_BASE_LEVELS; // level is above 1.
const int br_ctx = get_br_lf_ctx(levels, pos, bwl, tx_class);
aom_cdf_prob *cdf = ec_ctx->coeff_br_lf_cdf[plane_type][br_ctx];
- for (int idx = 0; idx < COEFF_BASE_RANGE; idx += BR_CDF_SIZE - 1) {
+ for (int idx = 0; idx < LF_COEFF_BASE_RANGE; idx += BR_CDF_SIZE - 1) {
const int k = AOMMIN(base_range - idx, BR_CDF_SIZE - 1);
aom_write_symbol(w, k, cdf, BR_CDF_SIZE);
if (k < BR_CDF_SIZE - 1) break;
}
}
+#endif // !CONFIG_ADAPTIVE_HR
} else {
if (level > NUM_BASE_LEVELS) {
const int base_range = level - 1 - NUM_BASE_LEVELS;
@@ -1057,7 +1050,6 @@
}
}
}
-#endif // !CONFIG_ADAPTIVE_HR
}
#if DEBUG_EXTQUANT
@@ -1124,12 +1116,12 @@
const int col = pos - (row << bwl);
int limits = get_lf_limits(row, col, tx_class, plane);
if (limits) {
- if (level > COEFF_BASE_RANGE + LF_NUM_BASE_LEVELS) {
+ if (level > LF_COEFF_BASE_RANGE + LF_NUM_BASE_LEVELS) {
#if CONFIG_ADAPTIVE_HR
bool is_eob = c == (eob - 1);
int hr_ctx = get_hr_ctx(levels, pos, bwl, is_eob, tx_class);
write_adaptive_hr(
- w, level - COEFF_BASE_RANGE - 1 - LF_NUM_BASE_LEVELS, hr_ctx);
+ w, level - LF_COEFF_BASE_RANGE - 1 - LF_NUM_BASE_LEVELS, hr_ctx);
#else
write_exp_golomb(
w, level - COEFF_BASE_RANGE - 1 - LF_NUM_BASE_LEVELS, 0);
@@ -1544,7 +1536,7 @@
const int(*lps_cost)[COEFF_BASE_RANGE + 1 + COEFF_BASE_RANGE + 1] =
coeff_costs->lps_cost;
- const int(*lps_lf_cost)[COEFF_BASE_RANGE + 1 + COEFF_BASE_RANGE + 1] =
+ const int(*lps_lf_cost)[LF_COEFF_BASE_RANGE + 1 + LF_COEFF_BASE_RANGE + 1] =
coeff_costs->lps_lf_cost;
int c = eob - 1;
{
@@ -2917,7 +2909,7 @@
const int blkpos = scan[scan_idx];
if (qcoeff[blkpos]) {
++nzsbb;
- sum_abs1 += AOMMIN(abs(qcoeff[blkpos]), MAX_BASE_BR_RANGE);
+ sum_abs1 += AOMMIN(abs(qcoeff[blkpos]), LF_MAX_BASE_BR_RANGE);
}
}
int hidepos = scan[0], rate_cur = 0;
@@ -3833,12 +3825,12 @@
const int row = pos >> bwl;
const int col = pos - (row << bwl);
int limits = get_lf_limits(row, col, tx_class, plane);
-#if !CONFIG_ADAPTIVE_HR
if (limits) {
+#if !CONFIG_ADAPTIVE_HR
if (level > LF_NUM_BASE_LEVELS) {
const int base_range = level - 1 - LF_NUM_BASE_LEVELS;
const int br_ctx = get_br_lf_ctx(levels, pos, bwl, tx_class);
- for (int idx = 0; idx < COEFF_BASE_RANGE; idx += BR_CDF_SIZE - 1) {
+ for (int idx = 0; idx < LF_COEFF_BASE_RANGE; idx += BR_CDF_SIZE - 1) {
const int k = AOMMIN(base_range - idx, BR_CDF_SIZE - 1);
if (allow_update_cdf) {
update_cdf(ec_ctx->coeff_br_lf_cdf[plane_type][br_ctx], k,
@@ -3856,6 +3848,7 @@
if (k < BR_CDF_SIZE - 1) break;
}
}
+#endif // !CONFIG_ADAPTIVE_HR
} else {
if (level > NUM_BASE_LEVELS) {
const int base_range = level - 1 - NUM_BASE_LEVELS;
@@ -3880,7 +3873,6 @@
}
}
}
-#endif // !CONFIG_ADAPTIVE_HR
}
bool is_hidden = false;
@@ -3894,12 +3886,7 @@
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,
-#if !CONFIG_ADAPTIVE_HR
- ec_ctx->coeff_br_ph_cdf
-#else
- NULL
-#endif // !CONFIG_ADAPTIVE_HR
+ ec_ctx->coeff_base_ph_cdf, ec_ctx->coeff_br_ph_cdf
#if CONFIG_ENTROPY_STATS
,
td, cdf_idx
@@ -3975,12 +3962,12 @@
const int row = pos >> bwl;
const int col = pos - (row << bwl);
int limits = get_lf_limits(row, col, tx_class, plane);
-#if !CONFIG_ADAPTIVE_HR
if (limits) {
+#if !CONFIG_ADAPTIVE_HR
if (level > LF_NUM_BASE_LEVELS) {
const int base_range = level - 1 - LF_NUM_BASE_LEVELS;
const int br_ctx = get_br_lf_ctx(levels, pos, bwl, tx_class);
- for (int idx = 0; idx < COEFF_BASE_RANGE; idx += BR_CDF_SIZE - 1) {
+ for (int idx = 0; idx < LF_COEFF_BASE_RANGE; idx += BR_CDF_SIZE - 1) {
const int k = AOMMIN(base_range - idx, BR_CDF_SIZE - 1);
if (allow_update_cdf) {
update_cdf(ec_ctx->coeff_br_lf_cdf[plane_type][br_ctx], k,
@@ -3998,6 +3985,7 @@
if (k < BR_CDF_SIZE - 1) break;
}
}
+#endif // !CONFIG_ADAPTIVE_HR
} else {
if (level > NUM_BASE_LEVELS) {
const int base_range = level - 1 - NUM_BASE_LEVELS;
@@ -4022,7 +4010,6 @@
}
}
}
-#endif // !CONFIG_ADAPTIVE_HR
}
// Update the context needed to code the DC sign (if applicable)
diff --git a/av1/encoder/rd.c b/av1/encoder/rd.c
index e3f114e..ee876a5 100644
--- a/av1/encoder/rd.c
+++ b/av1/encoder/rd.c
@@ -1110,7 +1110,7 @@
av1_cost_tokens_from_cdf(br_lf_rate, fc->coeff_br_lf_cdf[plane][ctx],
NULL);
#endif // !CONFIG_ADAPTIVE_HR
- for (i = 0; i < COEFF_BASE_RANGE; i += BR_CDF_SIZE - 1) {
+ for (i = 0; i < LF_COEFF_BASE_RANGE; i += BR_CDF_SIZE - 1) {
for (j = 0; j < BR_CDF_SIZE - 1; j++) {
pcost->lps_lf_cost[ctx][i + j] = prev_cost_lf + br_lf_rate[j];
}
@@ -1119,10 +1119,10 @@
pcost->lps_lf_cost[ctx][i] = prev_cost_lf;
}
for (int ctx = 0; ctx < LF_LEVEL_CONTEXTS; ++ctx) {
- pcost->lps_lf_cost[ctx][0 + COEFF_BASE_RANGE + 1] =
+ pcost->lps_lf_cost[ctx][0 + LF_COEFF_BASE_RANGE + 1] =
pcost->lps_lf_cost[ctx][0];
- for (int i = 1; i <= COEFF_BASE_RANGE; ++i) {
- pcost->lps_lf_cost[ctx][i + COEFF_BASE_RANGE + 1] =
+ for (int i = 1; i <= LF_COEFF_BASE_RANGE; ++i) {
+ pcost->lps_lf_cost[ctx][i + LF_COEFF_BASE_RANGE + 1] =
pcost->lps_lf_cost[ctx][i] - pcost->lps_lf_cost[ctx][i - 1];
}
}
@@ -1130,9 +1130,7 @@
int br_rate[BR_CDF_SIZE];
int prev_cost = 0;
int i, j;
-#if !CONFIG_ADAPTIVE_HR
av1_cost_tokens_from_cdf(br_rate, fc->coeff_br_cdf[plane][ctx], NULL);
-#endif // !CONFIG_ADAPTIVE_HR
// printf("br_rate: ");
// for(j = 0; j < BR_CDF_SIZE; j++)
// printf("%4d ", br_rate[j]);
@@ -1183,9 +1181,7 @@
int br_rate_skip[BR_CDF_SIZE];
int prev_cost_skip = 0;
int i, j;
-#if !CONFIG_ADAPTIVE_HR
av1_cost_tokens_from_cdf(br_rate_skip, fc->coeff_br_cdf_idtx[ctx], NULL);
-#endif // !CONFIG_ADAPTIVE_HR
for (i = 0; i < COEFF_BASE_RANGE; i += BR_CDF_SIZE - 1) {
for (j = 0; j < BR_CDF_SIZE - 1; j++) {
pcost->lps_cost_skip[ctx][i + j] = prev_cost_skip + br_rate_skip[j];
@@ -1216,9 +1212,7 @@
int br_ph_rate[BR_CDF_SIZE];
int prev_cost = 0;
int i, j;
-#if !CONFIG_ADAPTIVE_HR
av1_cost_tokens_from_cdf(br_ph_rate, fc->coeff_br_ph_cdf[ctx], NULL);
-#endif // !CONFIG_ADAPTIVE_HR
for (i = 0; i < COEFF_BASE_RANGE; i += BR_CDF_SIZE - 1) {
for (j = 0; j < BR_CDF_SIZE - 1; j++) {
pcost->lps_ph_cost[ctx][i + j] = prev_cost + br_ph_rate[j];
diff --git a/tools/aom_entropy_optimizer.c b/tools/aom_entropy_optimizer.c
index 7b7bf2c..3eb1135 100644
--- a/tools/aom_entropy_optimizer.c
+++ b/tools/aom_entropy_optimizer.c
@@ -1901,7 +1901,6 @@
"BASE_PH_CONTEXTS][CDF_SIZE(NUM_BASE_LEVELS + 2)]",
1, &total_count, 0, mem_wanted, "Coefficients");
-#if !CONFIG_ADAPTIVE_HR
cts_each_dim[0] = TOKEN_CDF_Q_CTXS;
cts_each_dim[1] = COEFF_BR_PH_CONTEXTS;
cts_each_dim[2] = BR_CDF_SIZE;
@@ -1911,7 +1910,6 @@
"av1_default_coeff_br_ph_cdfs[TOKEN_CDF_Q_CTXS][COEFF_BR_"
"PH_CONTEXTS][CDF_SIZE(BR_CDF_SIZE)]",
1, &total_count, 0, mem_wanted, "Coefficients");
-#endif // !CONFIG_ADAPTIVE_HR
cts_each_dim[0] = TOKEN_CDF_Q_CTXS;
cts_each_dim[1] = TX_SIZES;
@@ -1950,6 +1948,7 @@
"[PLANE_TYPES][LF_LEVEL_CONTEXTS]"
"[CDF_SIZE(BR_CDF_SIZE)]",
1, &total_count, 0, mem_wanted, "Coefficients");
+#endif // !CONFIG_ADAPTIVE_HR
cts_each_dim[0] = TOKEN_CDF_Q_CTXS;
cts_each_dim[1] = PLANE_TYPES;
@@ -1962,7 +1961,6 @@
"[PLANE_TYPES][LEVEL_CONTEXTS]"
"[CDF_SIZE(BR_CDF_SIZE)]",
1, &total_count, 0, mem_wanted, "Coefficients");
-#endif // !CONFIG_ADAPTIVE_HR
cts_each_dim[0] = TOKEN_CDF_Q_CTXS;
cts_each_dim[1] = TX_SIZES;
@@ -1976,7 +1974,6 @@
"[CDF_SIZE(NUM_BASE_LEVELS + 2)]",
1, &total_count, 0, mem_wanted, "Coefficients");
-#if !CONFIG_ADAPTIVE_HR
cts_each_dim[0] = TOKEN_CDF_Q_CTXS;
cts_each_dim[1] = IDTX_LEVEL_CONTEXTS;
cts_each_dim[2] = BR_CDF_SIZE;
@@ -1987,7 +1984,6 @@
"[TOKEN_CDF_Q_CTXS][IDTX_LEVEL_CONTEXTS]"
"[CDF_SIZE(BR_CDF_SIZE)]",
1, &total_count, 0, mem_wanted, "Coefficients");
-#endif // !CONFIG_ADAPTIVE_HR
cts_each_dim[0] = TOKEN_CDF_Q_CTXS;
cts_each_dim[1] = IDTX_SIG_COEF_CONTEXTS;