Merge eob-first into lv-map
Change-Id: Ib36a8df1a3ebddbf4320fb7b9b5537041bddc3a3
diff --git a/av1/common/entropy.c b/av1/common/entropy.c
index de2d3f1..5f90c94 100644
--- a/av1/common/entropy.c
+++ b/av1/common/entropy.c
@@ -2196,9 +2196,7 @@
AVERAGE_TILE_CDFS(txb_skip_cdf)
AVERAGE_TILE_CDFS(nz_map_cdf)
AVERAGE_TILE_CDFS(eob_flag_cdf)
-#if CONFIG_EOB_FIRST
AVERAGE_TILE_CDFS(eob_extra_cdf)
-#endif
AVERAGE_TILE_CDFS(dc_sign_cdf)
AVERAGE_TILE_CDFS(coeff_base_cdf)
AVERAGE_TILE_CDFS(coeff_lps_cdf)
diff --git a/av1/common/entropymode.c b/av1/common/entropymode.c
index 52857af..f30728d 100644
--- a/av1/common/entropymode.c
+++ b/av1/common/entropymode.c
@@ -144,9 +144,7 @@
};
const aom_prob default_nz_map[TX_SIZES][PLANE_TYPES][SIG_COEF_CONTEXTS] =
- {
-#if CONFIG_EOB_FIRST
- { { 42, 58, 129, 82, 37, 16, 117, 117, 66, 31, 17, 63,
+ { { { 42, 58, 129, 82, 37, 16, 117, 117, 66, 31, 17, 63,
98, 40, 128, 128, 136, 130, 95, 43, 128, 154, 143, 98,
41, 128, 103, 141, 69, 128, 128, 128, 130, 131, 95, 39,
128, 147, 146, 94, 38, 128, 102, 143, 63, 128, 128, 128 },
@@ -177,123 +175,7 @@
{ 72, 215, 186, 137, 72, 43, 239, 209, 164, 136, 64, 251,
215, 173, 130, 17, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
- 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 } }
-#else
-#if CONFIG_EXT_TX
- { { 56, 137, 82, 136, 83, 187, 124, 65,
- 215, 118, 155, 97, 160, 111, 71, 55,
-
- 142, 156, 91, 226, 107, 231, 146, 65,
- 105, 91, 232, 97, 185, 121, 90, 74,
-
- 153, 195, 123, 154, 106, 196, 143, 67,
- 232, 125, 121, 105, 159, 113, 88, 66 },
- { 50, 124, 89, 135, 116, 189, 150, 81,
- 202, 126, 130, 107, 149, 110, 85, 67,
-
- 139, 174, 112, 200, 94, 206, 146, 71,
- 163, 164, 212, 99, 177, 143, 125, 85,
-
- 151, 181, 126, 168, 135, 186, 143, 94,
- 207, 129, 142, 135, 145, 112, 98, 81 } },
- { { 57, 156, 91, 162, 99, 212, 149, 81,
- 223, 128, 182, 121, 216, 163, 119, 94,
-
- 139, 183, 100, 206, 98, 242, 163, 79,
- 200, 127, 234, 112, 230, 169, 115, 90,
-
- 156, 190, 130, 172, 117, 209, 163, 80,
- 217, 145, 182, 135, 204, 163, 120, 88 },
- { 48, 133, 102, 143, 119, 190, 170, 109,
- 197, 127, 176, 137, 214, 168, 130, 119,
-
- 139, 185, 129, 210, 84, 237, 177, 75,
- 182, 165, 216, 121, 206, 177, 147, 102,
-
- 159, 192, 153, 182, 139, 203, 160, 125,
- 193, 161, 176, 142, 173, 145, 131, 114 } },
- { { 33, 148, 81, 149, 84, 219, 152, 76,
- 229, 127, 205, 120, 234, 170, 123, 88,
-
- 134, 197, 101, 213, 91, 244, 169, 85,
- 220, 141, 234, 123, 242, 183, 130, 94,
-
- 141, 184, 121, 173, 98, 213, 156, 85,
- 204, 156, 197, 119, 212, 174, 127, 92 },
- { 14, 75, 45, 98, 83, 197, 150, 90,
- 235, 124, 242, 155, 246, 187, 143, 103,
-
- 78, 185, 111, 255, 116, 255, 224, 171,
- 185, 157, 255, 85, 219, 122, 128, 128,
-
- 117, 187, 102, 181, 132, 233, 197, 93,
- 207, 135, 191, 107, 222, 175, 130, 47 } },
- {
- { 14, 79, 44, 86, 59, 178, 124, 63,
- 244, 106, 233, 117, 252, 185, 132, 92,
-
- 85, 225, 47, 236, 103, 255, 190, 116,
- 235, 114, 247, 123, 250, 174, 122, 110,
-
- 109, 197, 78, 177, 76, 242, 148, 68,
- 236, 123, 231, 103, 247, 171, 122, 91 },
- { 11, 40, 27, 92, 78, 183, 171, 70,
- 216, 74, 251, 146, 252, 213, 171, 148,
-
- 85, 225, 47, 236, 103, 255, 190, 116,
- 235, 114, 247, 123, 250, 174, 122, 110,
-
- 109, 197, 78, 177, 76, 242, 148, 68,
- 236, 123, 231, 103, 247, 171, 122, 91 },
- },
-#else // CONFIG_EXT_TX
- {
- {
- 34, 103, 61, 106, 62, 160, 112, 54, 173, 121, 157, 92, 157, 129,
- 94, 65,
- },
-
- {
- 52, 124, 84, 136, 107, 197, 161, 82, 183, 151, 153, 140, 152, 134,
- 109, 81,
- },
- },
- {
- {
- 34, 127, 74, 124, 74, 204, 153, 76, 226, 162, 207, 126, 227, 192,
- 149, 108,
- },
-
- {
- 43, 136, 115, 158, 130, 212, 187, 112, 231, 180, 202, 164, 236,
- 204, 168, 139,
- },
- },
- {
- {
- 25, 117, 70, 120, 77, 215, 171, 102, 234, 156, 235, 155, 247, 220,
- 176, 127,
- },
-
- {
- 24, 88, 49, 100, 62, 202, 148, 62, 237, 178, 233, 168, 244, 198,
- 162, 127,
- },
- },
- {
- {
- 11, 54, 17, 69, 26, 128, 125, 56, 232, 130, 237, 121, 250, 168,
- 134, 114,
- },
-
- {
- 21, 52, 32, 95, 64, 171, 152, 70, 247, 159, 252, 177, 252, 221,
- 192, 143,
- },
- },
-#endif // CONFIG_EXT_TX
-#endif // CONFIG_EOB_FIRST
- };
+ 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 } } };
#if CONFIG_CTX1D
const aom_prob default_eob_flag[TX_SIZES][PLANE_TYPES][EOB_COEF_CONTEXTS] = {
@@ -366,8 +248,7 @@
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 } },
};
-#else // CONFIG_CTX1D
-#if CONFIG_EOB_FIRST
+#else // CONFIG_CTX1D
static const aom_prob
default_eob_flag[TX_SIZES][PLANE_TYPES][EOB_COEF_CONTEXTS] = {
{ { 221, 233, 232, 221, 231, 233, 216, 196, 233, 226, 200, 133, 227,
@@ -387,7 +268,7 @@
{ 92, 181, 200, 233, 232, 235, 249, 253, 253, 255, 254, 238, 228,
255, 251, 240, 128, 242, 233, 211, 171, 214, 179, 46, 128 } }
};
-#if CONFIG_EOB_FIRST
+
static const aom_prob
default_eob_extra[TX_SIZES][PLANE_TYPES][EOB_COEF_CONTEXTS] = {
{ {
@@ -423,35 +304,6 @@
145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145,
} }
};
-#endif
-#else
-const aom_prob default_eob_flag[TX_SIZES][PLANE_TYPES][EOB_COEF_CONTEXTS] = {
- {
- { 229, 236, 231, 222, 239, 236, 214, 201, 236, 226, 195, 134, 228,
- 210, 150, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 182, 186, 172, 176, 207, 213, 152, 122, 187, 171, 131, 65, 170,
- 134, 101, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
- },
- {
- { 225, 234, 244, 236, 205, 242, 246, 247, 246, 234, 191, 242, 237,
- 215, 142, 224, 206, 142, 73, 128, 128, 128, 128, 128, 128 },
- { 154, 171, 187, 175, 62, 199, 202, 206, 215, 200, 111, 197, 199,
- 174, 100, 135, 105, 104, 45, 128, 128, 128, 128, 128, 128 },
- },
- {
- { 180, 213, 216, 229, 233, 232, 240, 235, 220, 178, 239, 238, 225,
- 187, 229, 214, 226, 200, 183, 141, 158, 179, 128, 128, 128 },
- { 190, 225, 234, 248, 249, 248, 253, 251, 232, 110, 254, 252, 236,
- 57, 253, 248, 232, 85, 244, 189, 112, 64, 128, 128, 128 },
- },
- {
- { 248, 224, 246, 244, 239, 245, 251, 246, 251, 255, 255, 255, 249,
- 255, 255, 255, 229, 255, 255, 255, 228, 255, 255, 247, 137 },
- { 204, 207, 233, 215, 193, 228, 239, 221, 227, 250, 236, 207, 135,
- 236, 186, 182, 57, 209, 140, 128, 85, 184, 110, 128, 128 },
- },
-};
-#endif
#endif // CONFIG_CTX1D
const aom_prob default_coeff_lps[TX_SIZES][PLANE_TYPES][LEVEL_CONTEXTS] = {
@@ -6336,7 +6188,7 @@
av1_copy(fc->txb_skip, default_txb_skip);
av1_copy(fc->nz_map, default_nz_map);
av1_copy(fc->eob_flag, default_eob_flag);
-#if CONFIG_EOB_FIRST
+#if !CONFIG_CTX1D
av1_copy(fc->eob_extra, default_eob_extra);
#endif
av1_copy(fc->dc_sign, default_dc_sign);
diff --git a/av1/common/entropymode.h b/av1/common/entropymode.h
index a3388c8..bc4b5b9 100644
--- a/av1/common/entropymode.h
+++ b/av1/common/entropymode.h
@@ -149,9 +149,7 @@
aom_prob txb_skip[TX_SIZES][TXB_SKIP_CONTEXTS];
aom_prob nz_map[TX_SIZES][PLANE_TYPES][SIG_COEF_CONTEXTS];
aom_prob eob_flag[TX_SIZES][PLANE_TYPES][EOB_COEF_CONTEXTS];
-#if CONFIG_EOB_FIRST
aom_prob eob_extra[TX_SIZES][PLANE_TYPES][EOB_COEF_CONTEXTS];
-#endif
aom_prob dc_sign[PLANE_TYPES][DC_SIGN_CONTEXTS];
aom_prob coeff_base[TX_SIZES][PLANE_TYPES][NUM_BASE_LEVELS]
[COEFF_BASE_CONTEXTS];
@@ -168,10 +166,8 @@
[CDF_SIZE(2)];
aom_cdf_prob eob_flag_cdf[TX_SIZES][PLANE_TYPES][EOB_COEF_CONTEXTS]
[CDF_SIZE(2)];
-#if CONFIG_EOB_FIRST
aom_cdf_prob eob_extra_cdf[TX_SIZES][PLANE_TYPES][EOB_COEF_CONTEXTS]
[CDF_SIZE(2)];
-#endif
aom_cdf_prob dc_sign_cdf[PLANE_TYPES][DC_SIGN_CONTEXTS][CDF_SIZE(2)];
aom_cdf_prob coeff_base_cdf[TX_SIZES][PLANE_TYPES][NUM_BASE_LEVELS]
[COEFF_BASE_CONTEXTS][CDF_SIZE(2)];
@@ -414,9 +410,7 @@
unsigned int txb_skip[TX_SIZES][TXB_SKIP_CONTEXTS][2];
unsigned int nz_map[TX_SIZES][PLANE_TYPES][SIG_COEF_CONTEXTS][2];
unsigned int eob_flag[TX_SIZES][PLANE_TYPES][EOB_COEF_CONTEXTS][2];
-#if CONFIG_EOB_FIRST
unsigned int eob_extra[TX_SIZES][PLANE_TYPES][EOB_COEF_CONTEXTS][2];
-#endif
unsigned int dc_sign[PLANE_TYPES][DC_SIGN_CONTEXTS][2];
unsigned int coeff_base[TX_SIZES][PLANE_TYPES][NUM_BASE_LEVELS]
[COEFF_BASE_CONTEXTS][2];
diff --git a/av1/common/txb_common.c b/av1/common/txb_common.c
index c92bc48..42ebd55 100644
--- a/av1/common/txb_common.c
+++ b/av1/common/txb_common.c
@@ -149,14 +149,12 @@
fc->eob_flag_cdf[tx_size][plane][ctx][2] = 0;
}
-#if CONFIG_EOB_FIRST
for (ctx = 0; ctx < EOB_COEF_CONTEXTS; ++ctx) {
fc->eob_extra_cdf[tx_size][plane][ctx][0] =
AOM_ICDF(128 * (aom_cdf_prob)fc->eob_extra[tx_size][plane][ctx]);
fc->eob_extra_cdf[tx_size][plane][ctx][1] = AOM_ICDF(32768);
fc->eob_extra_cdf[tx_size][plane][ctx][2] = 0;
}
-#endif
}
}
@@ -233,7 +231,6 @@
}
}
-#if CONFIG_EOB_FIRST
const int16_t k_eob_group_start[12] = { 0, 1, 2, 3, 5, 9,
17, 33, 65, 129, 257, 513 };
const int16_t k_eob_offset_bits[12] = { 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
@@ -276,5 +273,3 @@
return t;
}
-
-#endif
diff --git a/av1/common/txb_common.h b/av1/common/txb_common.h
index 6d487c4..5441b9d 100644
--- a/av1/common/txb_common.h
+++ b/av1/common/txb_common.h
@@ -15,12 +15,10 @@
#define REDUCE_CONTEXT_DEPENDENCY 0
#define MIN_SCAN_IDX_REDUCE_CONTEXT_DEPENDENCY 0
-#if CONFIG_EOB_FIRST
extern const int16_t k_eob_group_start[12];
extern const int16_t k_eob_offset_bits[12];
int16_t get_eob_pos_token(int eob, int16_t *extra);
int get_eob_pos_ctx(int eob_token);
-#endif
extern const int16_t av1_coeff_band_4x4[16];
@@ -159,21 +157,12 @@
}
#define BR_CONTEXT_POSITION_NUM 8 // Base range coefficient context
-#if CONFIG_EOB_FIRST
static const int br_ref_offset[BR_CONTEXT_POSITION_NUM][2] = {
/* clang-format off*/
{ -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 },
{ 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 },
/* clang-format on*/
};
-#else
-static const int br_ref_offset[BR_CONTEXT_POSITION_NUM][2] = {
- /* clang-format off*/
- { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 },
- { 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 },
- /* clang-format on*/
-};
-#endif
static const int br_level_map[9] = {
0, 0, 1, 1, 2, 2, 3, 3, 3,
@@ -278,7 +267,7 @@
}
#define SIG_REF_OFFSET_NUM 7
-#if CONFIG_EOB_FIRST
+
static const int sig_ref_offset[SIG_REF_OFFSET_NUM][2] = {
{ 2, 1 }, { 2, 0 }, { 1, 2 }, { 1, 1 }, { 1, 0 }, { 0, 2 }, { 0, 1 },
};
@@ -316,52 +305,6 @@
}
return count;
}
-#else
-static const int sig_ref_offset[SIG_REF_OFFSET_NUM][2] = {
- { -2, -1 }, { -2, 0 }, { -1, -2 }, { -1, -1 },
- { -1, 0 }, { 0, -2 }, { 0, -1 },
-};
-
-#if REDUCE_CONTEXT_DEPENDENCY
-static INLINE int get_nz_count(const void *const tcoeffs, const int bwl,
- const int height, const int row, const int col,
- const int coeff_is_byte_flag, const int prev_row,
- const int prev_col) {
- int count = 0;
- for (int idx = 0; idx < SIG_REF_OFFSET_NUM; ++idx) {
- const int ref_row = row + sig_ref_offset[idx][0];
- const int ref_col = col + sig_ref_offset[idx][1];
- if (ref_row < 0 || ref_col < 0 || ref_row >= height ||
- ref_col >= (1 << bwl) || (prev_row == ref_row && prev_col == ref_col))
- continue;
- const int nb_pos = (ref_row << bwl) + ref_col;
- count +=
- ((coeff_is_byte_flag ? ((const uint8_t *)tcoeffs)[nb_pos]
- : ((const tran_low_t *)tcoeffs)[nb_pos]) != 0);
- }
- return count;
-}
-#else
-static INLINE int get_nz_count(const void *const tcoeffs, const int bwl,
- const int height, const int row, const int col,
- const int coeff_is_byte_flag) {
- int count = 0;
- for (int idx = 0; idx < SIG_REF_OFFSET_NUM; ++idx) {
- const int ref_row = row + sig_ref_offset[idx][0];
- const int ref_col = col + sig_ref_offset[idx][1];
- if (ref_row < 0 || ref_col < 0 || ref_row >= height ||
- ref_col >= (1 << bwl))
- continue;
- const int nb_pos = (ref_row << bwl) + ref_col;
- count +=
- ((coeff_is_byte_flag ? ((const uint8_t *)tcoeffs)[nb_pos]
- : ((const tran_low_t *)tcoeffs)[nb_pos]) != 0);
- }
- return count;
-}
-#endif
-
-#endif
static INLINE TX_CLASS get_tx_class(TX_TYPE tx_type) {
switch (tx_type) {
@@ -381,10 +324,7 @@
// count to ctx
static INLINE int get_nz_map_ctx_from_count(int count,
int coeff_idx, // raster order
- int bwl,
-#if CONFIG_EOB_FIRST
- int height,
-#endif
+ int bwl, int height,
TX_TYPE tx_type) {
(void)tx_type;
const int row = coeff_idx >> bwl;
@@ -403,7 +343,6 @@
int offset = 0;
#endif
-#if CONFIG_EOB_FIRST
(void)height;
ctx = (count + 1) >> 1;
@@ -428,41 +367,6 @@
return offset + 10 + ctx;
}
}
-#else
- if (row == 0 && col == 0) return offset + 0;
-
- if (row == 0 && col == 1) return offset + 1 + count;
-
- if (row == 1 && col == 0) return offset + 3 + count;
-
- if (row == 1 && col == 1) {
- ctx = (count + 1) >> 1;
-
- assert(5 + ctx <= 7);
-
- return offset + 5 + ctx;
- }
-
- if (row == 0) {
- ctx = (count + 1) >> 1;
-
- assert(ctx < 2);
- return offset + 8 + ctx;
- }
-
- if (col == 0) {
- ctx = (count + 1) >> 1;
-
- assert(ctx < 2);
- return offset + 10 + ctx;
- }
-
- ctx = count >> 1;
-
- assert(12 + ctx < 16);
-
- return offset + 12 + ctx;
-#endif
}
static INLINE int get_nz_map_ctx(const void *const tcoeffs, const int scan_idx,
@@ -472,35 +376,11 @@
const int coeff_idx = scan[scan_idx];
const int row = coeff_idx >> bwl;
const int col = coeff_idx - (row << bwl);
-#if REDUCE_CONTEXT_DEPENDENCY
- int prev_coeff_idx;
- int prev_row;
- int prev_col;
- if (scan_idx > MIN_SCAN_IDX_REDUCE_CONTEXT_DEPENDENCY) {
- prev_coeff_idx = scan[scan_idx - 1]; // raster order
- prev_row = prev_coeff_idx >> bwl;
- prev_col = prev_coeff_idx - (prev_row << bwl);
- } else {
- prev_coeff_idx = -1;
- prev_row = -1;
- prev_col = -1;
- }
- const int count = get_nz_count(tcoeffs, bwl, height, row, col,
- coeff_is_byte_flag, prev_row, prev_col);
-#else
-#if CONFIG_EOB_FIRST
+
int tx_class = get_tx_class(tx_type);
int count = get_nz_count(tcoeffs, bwl, height, row, col, tx_class,
coeff_is_byte_flag);
-#else
- int count = get_nz_count(tcoeffs, bwl, height, row, col, coeff_is_byte_flag);
-#endif
-#endif
- return get_nz_map_ctx_from_count(count, coeff_idx, bwl,
-#if CONFIG_EOB_FIRST
- height,
-#endif
- tx_type);
+ return get_nz_map_ctx_from_count(count, coeff_idx, bwl, height, tx_type);
}
static INLINE int get_eob_ctx(const int coeff_idx, // raster order
diff --git a/av1/decoder/decodetxb.c b/av1/decoder/decodetxb.c
index 625767a..4d5edd7 100644
--- a/av1/decoder/decodetxb.c
+++ b/av1/decoder/decodetxb.c
@@ -255,7 +255,6 @@
}
#endif
-#if CONFIG_EOB_FIRST
static INLINE int rec_eob_pos(int16_t eob_token, int16_t extra) {
int eob = k_eob_group_start[eob_token];
if (eob > 2) {
@@ -263,7 +262,6 @@
}
return eob;
}
-#endif
uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
aom_reader *r, int blk_row, int blk_col, int block,
@@ -316,8 +314,6 @@
const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, mbmi);
const int16_t *scan = scan_order->scan;
-#if CONFIG_EOB_FIRST
-
unsigned int(*nz_map_count)[SIG_COEF_CONTEXTS][2] =
(counts) ? &counts->nz_map[txs_ctx][plane_type] : NULL;
int16_t dummy;
@@ -389,42 +385,7 @@
if (counts) ++(*nz_map_count)[coeff_ctx][is_nz];
}
-#else
-#if CONFIG_CTX1D
- const int16_t *iscan = scan_order->iscan;
- TX_CLASS tx_class = get_tx_class(tx_type);
- if (tx_class == TX_CLASS_2D) {
- *eob =
- read_nz_map(r, levels, plane, scan, tx_size, tx_type, ec_ctx, counts);
- } else {
-#if LV_MAP_PROB
- const int eob_mode = av1_read_record_bin(
- counts, r, ec_ctx->eob_mode_cdf[txs_ctx][plane_type][tx_class], 2,
- ACCT_STR);
-#else
- const int eob_mode =
- aom_read(r, ec_ctx->eob_mode[txs_ctx][plane_type][tx_class], ACCT_STR);
-#endif
- if (counts) ++counts->eob_mode[txs_ctx][plane_type][tx_class][eob_mode];
- if (eob_mode == 0) {
- *eob =
- read_nz_map(r, levels, plane, scan, tx_size, tx_type, ec_ctx, counts);
- } else {
- assert(tx_class == TX_CLASS_VERT || tx_class == TX_CLASS_HORIZ);
- if (tx_class == TX_CLASS_VERT)
- *eob = read_nz_map_vert(r, levels, plane, scan, iscan, tx_size, tx_type,
- ec_ctx, counts);
- else
- *eob = read_nz_map_horiz(r, levels, plane, scan, iscan, tx_size,
- tx_type, ec_ctx, counts);
- }
- }
-#else
- *eob = read_nz_map(r, levels, plane, scan, tx_size, tx_type, ec_ctx, counts);
-#endif
-
-#endif
*max_scan_line = *eob;
int i;
diff --git a/av1/encoder/block.h b/av1/encoder/block.h
index 611bad3..049fa83 100644
--- a/av1/encoder/block.h
+++ b/av1/encoder/block.h
@@ -60,9 +60,7 @@
int txb_skip_cost[TXB_SKIP_CONTEXTS][2];
int nz_map_cost[SIG_COEF_CONTEXTS][2];
int eob_cost[EOB_COEF_CONTEXTS][2];
-#if CONFIG_EOB_FIRST
int eob_extra_cost[EOB_COEF_CONTEXTS][2];
-#endif
int dc_sign_cost[DC_SIGN_CONTEXTS][2];
int base_cost[NUM_BASE_LEVELS][COEFF_BASE_CONTEXTS][2];
int lps_cost[LEVEL_CONTEXTS][COEFF_BASE_RANGE + 1];
diff --git a/av1/encoder/encodetxb.c b/av1/encoder/encodetxb.c
index 33c14c8..e567dd7 100644
--- a/av1/encoder/encodetxb.c
+++ b/av1/encoder/encodetxb.c
@@ -27,7 +27,6 @@
int update;
tran_low_t low_qc;
tran_low_t low_dqc;
-#if CONFIG_EOB_FIRST
int64_t dist0;
int rate;
int rate_low;
@@ -36,7 +35,6 @@
int64_t rd;
int64_t rd_low;
int nz_rate; // for eob
-#endif
int64_t rd_diff;
int cost_diff;
int64_t dist_diff;
@@ -132,7 +130,6 @@
return error;
}
-#if CONFIG_EOB_FIRST
void av1_update_eob_context(int eob, int seg_eob, TX_SIZE txsize,
PLANE_TYPE plane, FRAME_CONTEXT *ec_ctx,
FRAME_COUNTS *counts) {
@@ -246,43 +243,6 @@
txb_info->dqcoeff[coeff_idx] = qcoeff_to_dqcoeff(qc, dqv, txb_info->shift);
}
-#endif
-
-static INLINE void write_nz_map(aom_writer *w, const tran_low_t *tcoeff,
- uint16_t eob, int plane, const int16_t *scan,
- TX_SIZE tx_size, TX_TYPE tx_type,
- FRAME_CONTEXT *fc) {
- const PLANE_TYPE plane_type = get_plane_type(plane);
- const TX_SIZE txs_ctx = get_txsize_context(tx_size);
- const int bwl = b_width_log2_lookup[txsize_to_bsize[tx_size]] + 2;
- const int height = tx_size_high[tx_size];
-#if CONFIG_CTX1D
- const int width = tx_size_wide[tx_size];
- const int eob_offset = width + height;
- const TX_CLASS tx_class = get_tx_class(tx_type);
- const int seg_eob =
- (tx_class == TX_CLASS_2D) ? tx_size_2d[tx_size] : eob_offset;
-#else
- const int seg_eob = tx_size_2d[tx_size];
-#endif
-
- for (int c = 0; c < eob; ++c) {
- int coeff_ctx = get_nz_map_ctx(tcoeff, c, scan, bwl, height, tx_type, 0);
- int eob_ctx = get_eob_ctx(scan[c], txs_ctx, tx_type);
-
- tran_low_t v = tcoeff[scan[c]];
- int is_nz = (v != 0);
-
- if (c == seg_eob - 1) break;
-
- aom_write_bin(w, is_nz, fc->nz_map_cdf[txs_ctx][plane_type][coeff_ctx], 2);
-
- if (is_nz)
- aom_write_bin(w, c == (eob - 1),
- fc->eob_flag_cdf[txs_ctx][plane_type][eob_ctx], 2);
- }
-}
-
#if CONFIG_CTX1D
static INLINE void write_nz_map_vert(aom_writer *w, const tran_low_t *tcoeff,
uint16_t eob, int plane,
@@ -441,7 +401,6 @@
get_min_tx_size(tx_size), w);
#endif
-#if CONFIG_EOB_FIRST
int16_t eob_extra;
int16_t eob_pt = get_eob_pos_token(eob, &eob_extra);
int16_t dummy;
@@ -484,41 +443,6 @@
2);
}
-#else // CONFIG_EOB_FIRST
-
-#if CONFIG_CTX1D
- TX_CLASS tx_class = get_tx_class(tx_type);
- if (tx_class == TX_CLASS_2D) {
- write_nz_map(w, tcoeff, eob, plane, scan, tx_size, tx_type, ec_ctx);
- } else {
- const int width = tx_size_wide[tx_size];
- const int eob_offset = width + height;
- const int eob_mode = eob > eob_offset;
-#if LV_MAP_PROB
- aom_write_bin(w, eob_mode,
- ec_ctx->eob_mode_cdf[txs_ctx][plane_type][tx_class], 2);
-#else
- aom_write(w, eob_mode, ec_ctx->eob_mode[txs_ctx][plane_type][tx_class]);
-#endif
- if (eob_mode == 0) {
- write_nz_map(w, tcoeff, eob, plane, scan, tx_size, tx_type, ec_ctx);
- } else {
- const int16_t *iscan = scan_order->iscan;
- assert(tx_class == TX_CLASS_VERT || tx_class == TX_CLASS_HORIZ);
- if (tx_class == TX_CLASS_VERT)
- write_nz_map_vert(w, tcoeff, eob, plane, scan, iscan, tx_size, tx_type,
- ec_ctx);
- else
- write_nz_map_horiz(w, tcoeff, eob, plane, scan, iscan, tx_size, tx_type,
- ec_ctx);
- }
- }
-#else
- write_nz_map(w, tcoeff, eob, plane, scan, tx_size, tx_type, ec_ctx);
-#endif // CONFIG_CTX1D
-
-#endif // CONFIG_EOB_FIRST
-
for (int i = 0; i < NUM_BASE_LEVELS; ++i) {
update_eob = 0;
for (c = eob - 1; c >= 0; --c) {
@@ -846,7 +770,6 @@
cost += av1_tx_type_cost(cm, x, xd, mbmi->sb_type, plane, tx_size, tx_type);
#endif
-#if CONFIG_EOB_FIRST
const int seg_eob = tx_size_2d[tx_size];
int eob_cost = get_eob_cost(eob, seg_eob, coeff_costs);
@@ -915,107 +838,6 @@
}
}
}
-
-#else // CONFIG_EOB_FIRST
-
-#if CONFIG_CTX1D
- TX_CLASS tx_class = get_tx_class(tx_type);
- if (tx_class == TX_CLASS_2D) {
- cost += get_nz_eob_map_cost(coeff_costs, qcoeff, eob, plane, scan, tx_size,
- tx_type);
- } else {
- const int width = tx_size_wide[tx_size];
- const int eob_offset = width + height;
- const int eob_mode = eob > eob_offset;
- cost += coeff_costs->eob_mode_cost[tx_class][eob_mode];
- if (eob_mode == 0) {
- cost += get_nz_eob_map_cost(coeff_costs, qcoeff, eob, plane, scan,
- tx_size, tx_type);
- } else {
- const int16_t *iscan = scan_order->iscan;
- assert(tx_class == TX_CLASS_VERT || tx_class == TX_CLASS_HORIZ);
- if (tx_class == TX_CLASS_VERT)
- cost += get_nz_eob_map_cost_vert(coeff_costs, qcoeff, eob, plane, scan,
- iscan, tx_size, tx_type);
- else
- cost += get_nz_eob_map_cost_horiz(coeff_costs, qcoeff, eob, plane, scan,
- iscan, tx_size, tx_type);
- }
- }
-#else // CONFIG_CTX1D
- cost += get_nz_eob_map_cost(coeff_costs, qcoeff, eob, plane, scan, tx_size,
- tx_type);
-#endif // CONFIG_CTX1D
- for (c = 0; c < eob; ++c) {
- tran_low_t v = qcoeff[scan[c]];
- int is_nz = (v != 0);
- int level = abs(v);
-
- if (is_nz) {
- int ctx_ls[NUM_BASE_LEVELS] = { 0 };
- int sign = (v < 0) ? 1 : 0;
-
- // sign bit cost
- if (c == 0) {
- int dc_sign_ctx = txb_ctx->dc_sign_ctx;
- cost += coeff_costs->dc_sign_cost[dc_sign_ctx][sign];
- } else {
- cost += av1_cost_bit(128, sign);
- }
-
- get_base_ctx_set(qcoeff, scan[c], bwl, height, ctx_ls);
-
- int i;
- for (i = 0; i < NUM_BASE_LEVELS; ++i) {
- if (level <= i) continue;
-
- if (level == i + 1) {
- cost += coeff_costs->base_cost[i][ctx_ls[i]][1];
- continue;
- }
- cost += coeff_costs->base_cost[i][ctx_ls[i]][0];
- }
-
- if (level > NUM_BASE_LEVELS) {
- int ctx;
- ctx = get_br_ctx_coeff(qcoeff, scan[c], bwl, height);
-#if BR_NODE
- int base_range = level - 1 - NUM_BASE_LEVELS;
- if (base_range < COEFF_BASE_RANGE) {
- cost += coeff_costs->lps_cost[ctx][base_range];
- } else {
- cost += coeff_costs->lps_cost[ctx][COEFF_BASE_RANGE];
- }
-
-#else
- for (int idx = 0; idx < COEFF_BASE_RANGE; ++idx) {
- if (level == (idx + 1 + NUM_BASE_LEVELS)) {
- cost += coeff_costs->lps_cost[ctx][1];
- break;
- }
- cost += coeff_costs->lps_cost[ctx][0];
- }
-#endif
- if (level >= 1 + NUM_BASE_LEVELS + COEFF_BASE_RANGE) {
- // residual cost
- int r = level - COEFF_BASE_RANGE - NUM_BASE_LEVELS;
- int ri = r;
- int length = 0;
-
- while (ri) {
- ri >>= 1;
- ++length;
- }
-
- for (ri = 0; ri < length - 1; ++ri) cost += av1_cost_bit(128, 0);
-
- for (ri = length - 1; ri >= 0; --ri)
- cost += av1_cost_bit(128, (r >> ri) & 0x01);
- }
- }
- }
- }
-#endif
return cost;
}
@@ -1069,39 +891,13 @@
const int coeff_idx = scan[c]; // raster order
const int row = coeff_idx >> bwl;
const int col = coeff_idx - (row << bwl);
-#if REDUCE_CONTEXT_DEPENDENCY
- int prev_coeff_idx;
- int prev_row;
- int prev_col;
- if (c > MIN_SCAN_IDX_REDUCE_CONTEXT_DEPENDENCY) {
- prev_coeff_idx = scan[c - 1]; // raster order
- prev_row = prev_coeff_idx >> bwl;
- prev_col = prev_coeff_idx - (prev_row << bwl);
- } else {
- prev_coeff_idx = -1;
- prev_row = -1;
- prev_col = -1;
- }
- txb_cache->nz_count_arr[coeff_idx] =
- get_nz_count(qcoeff, bwl, height, row, col, 0, prev_row, prev_col);
-#else
- txb_cache->nz_count_arr[coeff_idx] =
- get_nz_count(qcoeff, bwl, height, row, col
-#if CONFIG_EOB_FIRST
- ,
- get_tx_class(txb_info->tx_type)
-#endif
- ,
- 0);
-#endif
+
+ txb_cache->nz_count_arr[coeff_idx] = get_nz_count(
+ qcoeff, bwl, height, row, col, get_tx_class(txb_info->tx_type), 0);
const int nz_count = txb_cache->nz_count_arr[coeff_idx];
- txb_cache->nz_ctx_arr[coeff_idx] =
- get_nz_map_ctx_from_count(nz_count, coeff_idx, bwl,
-#if CONFIG_EOB_FIRST
- height,
-#endif
- txb_info->tx_type);
+ txb_cache->nz_ctx_arr[coeff_idx] = get_nz_map_ctx_from_count(
+ nz_count, coeff_idx, bwl, height, txb_info->tx_type);
// gen_base_count_mag_arr
if (!has_base(qcoeff[coeff_idx], 0)) continue;
@@ -1302,10 +1098,7 @@
txb_info->qcoeff[nb_coeff_idx] = get_lower_coeff(nb_coeff);
const int new_ctx =
get_nz_map_ctx_from_count(count - 1, coeff_idx, txb_info->bwl,
-#if CONFIG_EOB_FIRST
- txb_info->height,
-#endif
- txb_info->tx_type);
+ txb_info->height, txb_info->tx_type);
txb_info->qcoeff[nb_coeff_idx] = nb_coeff;
const int ctx = txb_cache->nz_ctx_arr[coeff_idx];
const int is_nz = abs_qc > 0;
@@ -1336,11 +1129,8 @@
get_level_prob(abs_qc, coeff_idx, txb_cache, txb_costs);
const int *low_level_cost =
get_level_prob(abs(*low_coeff), coeff_idx, txb_cache, txb_costs);
-#if CONFIG_EOB_FIRST
+
if (scan_idx < txb_info->eob - 1) {
-#else
- if (scan_idx < txb_info->seg_eob) {
-#endif
// When level-0, we code the binary of abs_qc > level
// but when level-k k > 0 we code the binary of abs_qc == level
// That's why wee need this special treatment for level-0 map
@@ -1350,15 +1140,6 @@
cost_diff = -level_cost[1];
}
-#if !CONFIG_EOB_FIRST
- if (scan_idx < txb_info->seg_eob) {
- const int eob_ctx =
- get_eob_ctx(coeff_idx, txb_info->txs_ctx, txb_info->tx_type);
- cost_diff -=
- txb_costs->eob_cost[eob_ctx][scan_idx == (txb_info->eob - 1)];
- }
-#endif
-
const int sign_cost = get_sign_bit_cost(
qc, coeff_idx, txb_costs->dc_sign_cost, txb_info->txb_ctx->dc_sign_ctx);
cost_diff -= sign_cost;
@@ -1569,11 +1350,8 @@
assert(abs_qc <= 1);
int cost = 0;
const int scan_idx = txb_info->scan_order->iscan[coeff_idx];
-#if CONFIG_EOB_FIRST
+
if (scan_idx < txb_info->eob - 1) {
-#else
- if (scan_idx < txb_info->seg_eob) {
-#endif
const int *level_cost = get_level_prob(0, coeff_idx, txb_cache, txb_costs);
cost += level_cost[qc != 0];
}
@@ -1583,13 +1361,6 @@
const int ctx = txb_cache->base_ctx_arr[base_idx][coeff_idx];
cost += get_base_cost(abs_qc, ctx, txb_costs->base_cost[base_idx][ctx],
base_idx);
-#if !CONFIG_EOB_FIRST
- if (scan_idx < txb_info->seg_eob) {
- const int eob_ctx =
- get_eob_ctx(coeff_idx, txb_info->txs_ctx, txb_info->tx_type);
- cost += txb_costs->eob_cost[eob_ctx][scan_idx == (txb_info->eob - 1)];
- }
-#endif
cost += get_sign_bit_cost(qc, coeff_idx, txb_costs->dc_sign_cost,
txb_info->txb_ctx->dc_sign_ctx);
}
@@ -1598,11 +1369,7 @@
static INLINE void set_eob(TxbInfo *txb_info, int eob) {
txb_info->eob = eob;
-#if CONFIG_EOB_FIRST
txb_info->seg_eob = tx_size_2d[txb_info->tx_size];
-#else
- txb_info->seg_eob = AOMMIN(eob, tx_size_2d[txb_info->tx_size] - 1);
-#endif
}
// TODO(angiebird): add static to this function once it's called
@@ -1696,10 +1463,7 @@
const int count = txb_cache->nz_count_arr[nb_coeff_idx];
txb_cache->nz_ctx_arr[nb_coeff_idx] =
get_nz_map_ctx_from_count(count, nb_coeff_idx, txb_info->bwl,
-#if CONFIG_EOB_FIRST
- txb_info->height,
-#endif
- txb_info->tx_type);
+ txb_info->height, txb_info->tx_type);
// int ref_ctx = get_nz_map_ctx(txb_info->qcoeff, nb_coeff_idx,
// txb_info->bwl, tx_type, 0);
// if (ref_ctx != txb_cache->nz_ctx_arr[nb_coeff_idx])
@@ -1789,11 +1553,7 @@
const tran_low_t abs_qc = abs(qc);
int cost = 0;
const int16_t *scan = txb_info->scan_order->scan;
-#if CONFIG_EOB_FIRST
if (scan_idx < txb_info->eob - 1) {
-#else
- if (scan_idx < txb_info->seg_eob) {
-#endif
int coeff_ctx =
get_nz_map_ctx(txb_info->qcoeff, scan_idx, scan, txb_info->bwl,
txb_info->height, txb_info->tx_type, 0);
@@ -1820,13 +1580,6 @@
cost += get_br_cost(abs_qc, ctx, txb_costs->lps_cost[ctx]);
cost += get_golomb_cost(abs_qc);
}
-#if !CONFIG_EOB_FIRST
- if (scan_idx < txb_info->seg_eob) {
- int eob_ctx =
- get_eob_ctx(scan[scan_idx], txb_info->txs_ctx, txb_info->tx_type);
- cost += txb_costs->eob_cost[eob_ctx][scan_idx == (txb_info->eob - 1)];
- }
-#endif
}
return cost;
}
@@ -2003,7 +1756,7 @@
return;
}
-#if CONFIG_EOB_FIRST
+#if 1
static int optimize_txb(TxbInfo *txb_info, const LV_MAP_COEFF_COST *txb_costs,
TxbCache *txb_cache, int dry_run, int fast_mode) {
(void)fast_mode;
@@ -2260,11 +2013,7 @@
tran_low_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
const tran_low_t *tcoeff = BLOCK_OFFSET(p->coeff, block);
const int16_t *dequant = pd->dequant;
-#if CONFIG_EOB_FIRST
const int seg_eob = tx_size_2d[tx_size];
-#else
- const int seg_eob = AOMMIN(eob, tx_size_2d[tx_size] - 1);
-#endif
const int bwl = b_width_log2_lookup[txsize_to_bsize[tx_size]] + 2;
const int stride = 1 << bwl;
const int height = tx_size_high[tx_size];
@@ -2294,15 +2043,8 @@
rdmult,
&cm->coeff_ctx_table };
-#if CONFIG_EOB_FIRST
const int update = optimize_txb(&txb_info, &txb_costs, NULL, 0, fast_mode);
-#else
- TxbCache txb_cache;
- gen_txb_cache(&txb_cache, &txb_info);
- const int update =
- optimize_txb(&txb_info, &txb_costs, &txb_cache, 0, fast_mode);
-#endif
if (update) p->eobs[block] = txb_info.eob;
return txb_info.eob;
}
@@ -2548,7 +2290,6 @@
mbmi->sb_type, get_min_tx_size(tx_size), td->counts);
#endif
-#if CONFIG_EOB_FIRST
unsigned int(*nz_map_count)[SIG_COEF_CONTEXTS][2] =
&(td->counts->nz_map[txsize_ctx][plane_type]);
av1_update_eob_context(eob, seg_eob, txsize_ctx, plane_type, ec_ctx,
@@ -2563,42 +2304,6 @@
++(*nz_map_count)[coeff_ctx][is_nz];
update_cdf(ec_ctx->nz_map_cdf[txsize_ctx][plane_type][coeff_ctx], is_nz, 2);
}
-#else // CONFIG_EOB_FIRST
-#if CONFIG_CTX1D
- TX_CLASS tx_class = get_tx_class(tx_type);
- if (tx_class == TX_CLASS_2D) {
- av1_update_nz_eob_counts(ec_ctx, td->counts, eob, tcoeff, plane, tx_size,
- tx_type, scan);
- } else {
- const int width = tx_size_wide[tx_size];
- const int eob_offset = width + height;
- const int eob_mode = eob > eob_offset;
- const TX_SIZE txs_ctx = get_txsize_context(tx_size);
- ++td->counts->eob_mode[txs_ctx][plane_type][tx_class][eob_mode];
-#if LV_MAP_PROB
- update_bin(ec_ctx->eob_mode_cdf[txs_ctx][plane_type][tx_class], eob_mode,
- 2);
-#endif
- if (eob_mode == 0) {
- av1_update_nz_eob_counts(ec_ctx, td->counts, eob, tcoeff, plane, tx_size,
- tx_type, scan);
- } else {
- const int16_t *iscan = scan_order->iscan;
- assert(tx_class == TX_CLASS_VERT || tx_class == TX_CLASS_HORIZ);
- if (tx_class == TX_CLASS_VERT)
- av1_update_nz_eob_counts_vert(ec_ctx, td->counts, eob, tcoeff, plane,
- tx_size, tx_type, scan, iscan);
- else
- av1_update_nz_eob_counts_horiz(ec_ctx, td->counts, eob, tcoeff, plane,
- tx_size, tx_type, scan, iscan);
- }
- }
-#else // CONFIG_CTX1D
- av1_update_nz_eob_counts(ec_ctx, td->counts, eob, tcoeff, plane, tx_size,
- tx_type, scan);
-#endif // CONFIG_CTX1D
-
-#endif // CONFIG_EOB_FIRST
// Reverse process order to handle coefficient level and sign.
for (i = 0; i < NUM_BASE_LEVELS; ++i) {
diff --git a/av1/encoder/rd.c b/av1/encoder/rd.c
index a6fc108..622a36a 100644
--- a/av1/encoder/rd.c
+++ b/av1/encoder/rd.c
@@ -595,11 +595,9 @@
av1_cost_tokens_from_cdf(pcost->eob_cost[ctx],
fc->eob_flag_cdf[tx_size][plane][ctx], NULL);
-#if CONFIG_EOB_FIRST
for (int ctx = 0; ctx < EOB_COEF_CONTEXTS; ++ctx)
av1_cost_tokens_from_cdf(pcost->eob_extra_cost[ctx],
fc->eob_extra_cdf[tx_size][plane][ctx], NULL);
-#endif
for (int ctx = 0; ctx < DC_SIGN_CONTEXTS; ++ctx)
av1_cost_tokens_from_cdf(pcost->dc_sign_cost[ctx],