Commit 3422ac17 authored by Jingning Han's avatar Jingning Han
Browse files

Merge eob-first into lv-map

Change-Id: Ib36a8df1a3ebddbf4320fb7b9b5537041bddc3a3
parent 36773c7a
...@@ -2196,9 +2196,7 @@ void av1_average_tile_coef_cdfs(FRAME_CONTEXT *fc, FRAME_CONTEXT *ec_ctxs[], ...@@ -2196,9 +2196,7 @@ void av1_average_tile_coef_cdfs(FRAME_CONTEXT *fc, FRAME_CONTEXT *ec_ctxs[],
AVERAGE_TILE_CDFS(txb_skip_cdf) AVERAGE_TILE_CDFS(txb_skip_cdf)
AVERAGE_TILE_CDFS(nz_map_cdf) AVERAGE_TILE_CDFS(nz_map_cdf)
AVERAGE_TILE_CDFS(eob_flag_cdf) AVERAGE_TILE_CDFS(eob_flag_cdf)
#if CONFIG_EOB_FIRST
AVERAGE_TILE_CDFS(eob_extra_cdf) AVERAGE_TILE_CDFS(eob_extra_cdf)
#endif
AVERAGE_TILE_CDFS(dc_sign_cdf) AVERAGE_TILE_CDFS(dc_sign_cdf)
AVERAGE_TILE_CDFS(coeff_base_cdf) AVERAGE_TILE_CDFS(coeff_base_cdf)
AVERAGE_TILE_CDFS(coeff_lps_cdf) AVERAGE_TILE_CDFS(coeff_lps_cdf)
......
...@@ -144,9 +144,7 @@ const aom_prob default_coeff_base ...@@ -144,9 +144,7 @@ const aom_prob default_coeff_base
}; };
const aom_prob default_nz_map[TX_SIZES][PLANE_TYPES][SIG_COEF_CONTEXTS] = const aom_prob default_nz_map[TX_SIZES][PLANE_TYPES][SIG_COEF_CONTEXTS] =
{ { { { 42, 58, 129, 82, 37, 16, 117, 117, 66, 31, 17, 63,
#if CONFIG_EOB_FIRST
{ { 42, 58, 129, 82, 37, 16, 117, 117, 66, 31, 17, 63,
98, 40, 128, 128, 136, 130, 95, 43, 128, 154, 143, 98, 98, 40, 128, 128, 136, 130, 95, 43, 128, 154, 143, 98,
41, 128, 103, 141, 69, 128, 128, 128, 130, 131, 95, 39, 41, 128, 103, 141, 69, 128, 128, 128, 130, 131, 95, 39,
128, 147, 146, 94, 38, 128, 102, 143, 63, 128, 128, 128 }, 128, 147, 146, 94, 38, 128, 102, 143, 63, 128, 128, 128 },
...@@ -177,123 +175,7 @@ const aom_prob default_nz_map[TX_SIZES][PLANE_TYPES][SIG_COEF_CONTEXTS] = ...@@ -177,123 +175,7 @@ const aom_prob default_nz_map[TX_SIZES][PLANE_TYPES][SIG_COEF_CONTEXTS] =
{ 72, 215, 186, 137, 72, 43, 239, 209, 164, 136, 64, 251, { 72, 215, 186, 137, 72, 43, 239, 209, 164, 136, 64, 251,
215, 173, 130, 17, 128, 128, 128, 128, 128, 128, 128, 128, 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,
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
};
#if CONFIG_CTX1D #if CONFIG_CTX1D
const aom_prob default_eob_flag[TX_SIZES][PLANE_TYPES][EOB_COEF_CONTEXTS] = { const aom_prob default_eob_flag[TX_SIZES][PLANE_TYPES][EOB_COEF_CONTEXTS] = {
...@@ -366,8 +248,7 @@ const aom_prob default_eob_flag[TX_SIZES][PLANE_TYPES][EOB_COEF_CONTEXTS] = { ...@@ -366,8 +248,7 @@ const aom_prob default_eob_flag[TX_SIZES][PLANE_TYPES][EOB_COEF_CONTEXTS] = {
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, 128, 128, 128, 128, 128, 128 } }, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 } },
}; };
#else // CONFIG_CTX1D #else // CONFIG_CTX1D
#if CONFIG_EOB_FIRST
static const aom_prob static const aom_prob
default_eob_flag[TX_SIZES][PLANE_TYPES][EOB_COEF_CONTEXTS] = { default_eob_flag[TX_SIZES][PLANE_TYPES][EOB_COEF_CONTEXTS] = {
{ { 221, 233, 232, 221, 231, 233, 216, 196, 233, 226, 200, 133, 227, { { 221, 233, 232, 221, 231, 233, 216, 196, 233, 226, 200, 133, 227,
...@@ -387,7 +268,7 @@ static const aom_prob ...@@ -387,7 +268,7 @@ static const aom_prob
{ 92, 181, 200, 233, 232, 235, 249, 253, 253, 255, 254, 238, 228, { 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 } } 255, 251, 240, 128, 242, 233, 211, 171, 214, 179, 46, 128 } }
}; };
#if CONFIG_EOB_FIRST
static const aom_prob static const aom_prob
default_eob_extra[TX_SIZES][PLANE_TYPES][EOB_COEF_CONTEXTS] = { default_eob_extra[TX_SIZES][PLANE_TYPES][EOB_COEF_CONTEXTS] = {
{ { { {
...@@ -423,35 +304,6 @@ static const aom_prob ...@@ -423,35 +304,6 @@ static const aom_prob
145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 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 #endif // CONFIG_CTX1D
const aom_prob default_coeff_lps[TX_SIZES][PLANE_TYPES][LEVEL_CONTEXTS] = { const aom_prob default_coeff_lps[TX_SIZES][PLANE_TYPES][LEVEL_CONTEXTS] = {
...@@ -6336,7 +6188,7 @@ static void init_mode_probs(FRAME_CONTEXT *fc) { ...@@ -6336,7 +6188,7 @@ static void init_mode_probs(FRAME_CONTEXT *fc) {
av1_copy(fc->txb_skip, default_txb_skip); av1_copy(fc->txb_skip, default_txb_skip);
av1_copy(fc->nz_map, default_nz_map); av1_copy(fc->nz_map, default_nz_map);
av1_copy(fc->eob_flag, default_eob_flag); av1_copy(fc->eob_flag, default_eob_flag);
#if CONFIG_EOB_FIRST #if !CONFIG_CTX1D
av1_copy(fc->eob_extra, default_eob_extra); av1_copy(fc->eob_extra, default_eob_extra);
#endif #endif
av1_copy(fc->dc_sign, default_dc_sign); av1_copy(fc->dc_sign, default_dc_sign);
......
...@@ -149,9 +149,7 @@ typedef struct frame_contexts { ...@@ -149,9 +149,7 @@ typedef struct frame_contexts {
aom_prob txb_skip[TX_SIZES][TXB_SKIP_CONTEXTS]; aom_prob txb_skip[TX_SIZES][TXB_SKIP_CONTEXTS];
aom_prob nz_map[TX_SIZES][PLANE_TYPES][SIG_COEF_CONTEXTS]; aom_prob nz_map[TX_SIZES][PLANE_TYPES][SIG_COEF_CONTEXTS];
aom_prob eob_flag[TX_SIZES][PLANE_TYPES][EOB_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]; aom_prob eob_extra[TX_SIZES][PLANE_TYPES][EOB_COEF_CONTEXTS];
#endif
aom_prob dc_sign[PLANE_TYPES][DC_SIGN_CONTEXTS]; aom_prob dc_sign[PLANE_TYPES][DC_SIGN_CONTEXTS];
aom_prob coeff_base[TX_SIZES][PLANE_TYPES][NUM_BASE_LEVELS] aom_prob coeff_base[TX_SIZES][PLANE_TYPES][NUM_BASE_LEVELS]
[COEFF_BASE_CONTEXTS]; [COEFF_BASE_CONTEXTS];
...@@ -168,10 +166,8 @@ typedef struct frame_contexts { ...@@ -168,10 +166,8 @@ typedef struct frame_contexts {
[CDF_SIZE(2)]; [CDF_SIZE(2)];
aom_cdf_prob eob_flag_cdf[TX_SIZES][PLANE_TYPES][EOB_COEF_CONTEXTS] aom_cdf_prob eob_flag_cdf[TX_SIZES][PLANE_TYPES][EOB_COEF_CONTEXTS]
[CDF_SIZE(2)]; [CDF_SIZE(2)];
#if CONFIG_EOB_FIRST
aom_cdf_prob eob_extra_cdf[TX_SIZES][PLANE_TYPES][EOB_COEF_CONTEXTS] aom_cdf_prob eob_extra_cdf[TX_SIZES][PLANE_TYPES][EOB_COEF_CONTEXTS]
[CDF_SIZE(2)]; [CDF_SIZE(2)];
#endif
aom_cdf_prob dc_sign_cdf[PLANE_TYPES][DC_SIGN_CONTEXTS][CDF_SIZE(2)]; 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] aom_cdf_prob coeff_base_cdf[TX_SIZES][PLANE_TYPES][NUM_BASE_LEVELS]
[COEFF_BASE_CONTEXTS][CDF_SIZE(2)]; [COEFF_BASE_CONTEXTS][CDF_SIZE(2)];
...@@ -414,9 +410,7 @@ typedef struct FRAME_COUNTS { ...@@ -414,9 +410,7 @@ typedef struct FRAME_COUNTS {
unsigned int txb_skip[TX_SIZES][TXB_SKIP_CONTEXTS][2]; unsigned int txb_skip[TX_SIZES][TXB_SKIP_CONTEXTS][2];
unsigned int nz_map[TX_SIZES][PLANE_TYPES][SIG_COEF_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]; 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]; 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 dc_sign[PLANE_TYPES][DC_SIGN_CONTEXTS][2];
unsigned int coeff_base[TX_SIZES][PLANE_TYPES][NUM_BASE_LEVELS] unsigned int coeff_base[TX_SIZES][PLANE_TYPES][NUM_BASE_LEVELS]
[COEFF_BASE_CONTEXTS][2]; [COEFF_BASE_CONTEXTS][2];
......
...@@ -149,14 +149,12 @@ void av1_init_txb_probs(FRAME_CONTEXT *fc) { ...@@ -149,14 +149,12 @@ void av1_init_txb_probs(FRAME_CONTEXT *fc) {
fc->eob_flag_cdf[tx_size][plane][ctx][2] = 0; fc->eob_flag_cdf[tx_size][plane][ctx][2] = 0;
} }
#if CONFIG_EOB_FIRST
for (ctx = 0; ctx < EOB_COEF_CONTEXTS; ++ctx) { for (ctx = 0; ctx < EOB_COEF_CONTEXTS; ++ctx) {
fc->eob_extra_cdf[tx_size][plane][ctx][0] = fc->eob_extra_cdf[tx_size][plane][ctx][0] =
AOM_ICDF(128 * (aom_cdf_prob)fc->eob_extra[tx_size][plane][ctx]); 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][1] = AOM_ICDF(32768);
fc->eob_extra_cdf[tx_size][plane][ctx][2] = 0; fc->eob_extra_cdf[tx_size][plane][ctx][2] = 0;
} }
#endif
} }
} }
...@@ -233,7 +231,6 @@ void av1_init_lv_map(AV1_COMMON *cm) { ...@@ -233,7 +231,6 @@ void av1_init_lv_map(AV1_COMMON *cm) {
} }
} }
#if CONFIG_EOB_FIRST
const int16_t k_eob_group_start[12] = { 0, 1, 2, 3, 5, 9, const int16_t k_eob_group_start[12] = { 0, 1, 2, 3, 5, 9,
17, 33, 65, 129, 257, 513 }; 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 }; const int16_t k_eob_offset_bits[12] = { 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
...@@ -276,5 +273,3 @@ int16_t get_eob_pos_token(int eob, int16_t *extra) { ...@@ -276,5 +273,3 @@ int16_t get_eob_pos_token(int eob, int16_t *extra) {
return t; return t;
} }
#endif
...@@ -15,12 +15,10 @@ ...@@ -15,12 +15,10 @@
#define REDUCE_CONTEXT_DEPENDENCY 0 #define REDUCE_CONTEXT_DEPENDENCY 0
#define MIN_SCAN_IDX_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_group_start[12];
extern const int16_t k_eob_offset_bits[12]; extern const int16_t k_eob_offset_bits[12];
int16_t get_eob_pos_token(int eob, int16_t *extra); int16_t get_eob_pos_token(int eob, int16_t *extra);
int get_eob_pos_ctx(int eob_token); int get_eob_pos_ctx(int eob_token);
#endif
extern const int16_t av1_coeff_band_4x4[16]; extern const int16_t av1_coeff_band_4x4[16];
...@@ -159,21 +157,12 @@ static INLINE int get_base_ctx(const uint8_t *const levels, ...@@ -159,21 +157,12 @@ static INLINE int get_base_ctx(const uint8_t *const levels,
} }
#define BR_CONTEXT_POSITION_NUM 8 // Base range coefficient context #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] = { static const int br_ref_offset[BR_CONTEXT_POSITION_NUM][2] = {
/* clang-format off*/ /* clang-format off*/
{ -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 }, { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 },
{ 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 }, { 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 },
/* clang-format on*/ /* 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] = { static const int br_level_map[9] = {
0, 0, 1, 1, 2, 2, 3, 3, 3, 0, 0, 1, 1, 2, 2, 3, 3, 3,
...@@ -278,7 +267,7 @@ static INLINE int get_br_ctx_coeff(const tran_low_t *const tcoeffs, ...@@ -278,7 +267,7 @@ static INLINE int get_br_ctx_coeff(const tran_low_t *const tcoeffs,
} }
#define SIG_REF_OFFSET_NUM 7 #define SIG_REF_OFFSET_NUM 7
#if CONFIG_EOB_FIRST
static const int sig_ref_offset[SIG_REF_OFFSET_NUM][2] = { 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 }, { 2, 1 }, { 2, 0 }, { 1, 2 }, { 1, 1 }, { 1, 0 }, { 0, 2 }, { 0, 1 },
}; };
...@@ -316,52 +305,6 @@ static INLINE int get_nz_count(const tran_low_t *tcoeffs, int bwl, int height, ...@@ -316,52 +305,6 @@ static INLINE int get_nz_count(const tran_low_t *tcoeffs, int bwl, int height,
} }
return count; 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) { static INLINE TX_CLASS get_tx_class(TX_TYPE tx_type) {
switch (tx_type) { switch (tx_type) {
...@@ -381,10 +324,7 @@ static INLINE TX_CLASS get_tx_class(TX_TYPE tx_type) { ...@@ -381,10 +324,7 @@ static INLINE TX_CLASS get_tx_class(TX_TYPE tx_type) {
// count to ctx // count to ctx
static INLINE int get_nz_map_ctx_from_count(int count, static INLINE int get_nz_map_ctx_from_count(int count,
int coeff_idx, // raster order int coeff_idx, // raster order
int bwl, int bwl, int height,
#if CONFIG_EOB_FIRST
int height,
#endif
TX_TYPE tx_type) { TX_TYPE tx_type) {
(void)tx_type; (void)tx_type;
const int row = coeff_idx >> bwl; const int row = coeff_idx >> bwl;
...@@ -403,7 +343,6 @@ static INLINE int get_nz_map_ctx_from_count(int count, ...@@ -403,7 +343,6 @@ static INLINE int get_nz_map_ctx_from_count(int count,
int offset = 0; int offset = 0;
#endif #endif
#if CONFIG_EOB_FIRST
(void)height; (void)height;
ctx = (count + 1) >> 1; ctx = (count + 1) >> 1;
...@@ -428,41 +367,6 @@ static INLINE int get_nz_map_ctx_from_count(int count, ...@@ -428,41 +367,6 @@ static INLINE int get_nz_map_ctx_from_count(int count,
return offset + 10 + ctx; 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, static INLINE int get_nz_map_ctx(const void *const tcoeffs, const int scan_idx,
...@@ -472,35 +376,11 @@ static INLINE int get_nz_map_ctx(const void *const tcoeffs, const int scan_idx, ...@@ -472,35 +376,11 @@ static INLINE int get_nz_map_ctx(const void *const tcoeffs, const int scan_idx,
const int coeff_idx = scan[scan_idx]; const int coeff_idx = scan[scan_idx];
const int row = coeff_idx >> bwl; const int row = coeff_idx >> bwl;
const int col = coeff_idx - (row << 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 tx_class = get_tx_class(tx_type);
int count = get_nz_count(tcoeffs, bwl, height, row, col, tx_class, int count = get_nz_count(tcoeffs, bwl, height, row, col, tx_class,
coeff_is_byte_flag); coeff_is_byte_flag);
#else return get_nz_map_ctx_from_count(count, coeff_idx, bwl, height, tx_type);
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);
} }
static INLINE int get_eob_ctx(const int coeff_idx, // raster order static INLINE int get_eob_ctx(const int coeff_idx, // raster order
......
...@@ -255,7 +255,6 @@ static INLINE int read_nz_map_horiz(aom_reader *r, uint8_t *levels, int plane, ...@@ -255,7 +255,6 @@ static INLINE int read_nz_map_horiz(aom_reader *r, uint8_t *levels, int plane,
} }
#endif #endif
#if CONFIG_EOB_FIRST
static INLINE int rec_eob_pos(int16_t eob_token, int16_t extra) { static INLINE int rec_eob_pos(int16_t eob_token, int16_t extra) {
int eob = k_eob_group_start[eob_token]; int eob = k_eob_group_start[eob_token];
if (eob > 2) { if (eob > 2) {
...@@ -263,7 +262,6 @@ static INLINE int rec_eob_pos(int16_t eob_token, int16_t extra) { ...@@ -263,7 +262,6 @@ static INLINE int rec_eob_pos(int16_t eob_token, int16_t extra) {
} }
return eob; return eob;
} }
#endif
uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd, uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
aom_reader *r, int blk_row, int blk_col, int block, aom_reader *r, int blk_row, int blk_col, int block,
...@@ -316,8 +314,6 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd, ...@@ -316,8 +314,6 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, mbmi); const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, mbmi);
const int16_t *scan = scan_order->scan; const int16_t *scan = scan_order->scan;
#if CONFIG_EOB_FIRST
unsigned int(*nz_map_count)[SIG_COEF_CONTEXTS][2] = unsigned int(*nz_map_count)[SIG_COEF_CONTEXTS][2] =
(counts) ? &counts->nz_map[txs_ctx][plane_type] : NULL; (counts) ? &counts->nz_map[txs_ctx][plane_type] : NULL;
int16_t dummy; int16_t dummy;
...@@ -389,42 +385,7 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd, ...@@ -389,42 +385,7 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
if (counts) ++(*nz_map_count)[coeff_ctx][is_nz]; if (counts) ++(*nz_map_count)[coeff_ctx][is_nz];
}