Commit 819f45a3 authored by Jingning Han's avatar Jingning Han

Reduce the context model size for base level

Further reduce the context model size needed for base levels down
to 25 per transform size.

Change-Id: I9df4870d2b027cdb1356de0fc4d5bcc22155319e
parent e775b8bc
......@@ -79,7 +79,7 @@ extern "C" {
#define SIG_COEF_CONTEXTS_2D 16
#define SIG_COEF_CONTEXTS 16
#endif // CONFIG_EXT_TX
#define COEFF_BASE_CONTEXTS 42
#define COEFF_BASE_CONTEXTS 25
#define DC_SIGN_CONTEXTS 3
#define BR_TMP_OFFSET 12
......
......@@ -32,77 +32,74 @@ const aom_prob default_dc_sign[PLANE_TYPES][DC_SIGN_CONTEXTS] = {
};
const aom_prob default_coeff_base
[TX_SIZES][PLANE_TYPES][NUM_BASE_LEVELS][COEFF_BASE_CONTEXTS] =
{
[TX_SIZES][PLANE_TYPES][NUM_BASE_LEVELS][COEFF_BASE_CONTEXTS] = {
{ { {
230, 199, 168, 74, 128, 169, 213, 173, 87, 21, 60, 117, 213,
177, 126, 22, 64, 121, 206, 168, 67, 10, 33, 96, 140,
},
{
236, 218, 201, 124, 185, 219, 223, 196, 128, 65, 127, 176, 224,
199, 151, 75, 131, 177, 217, 190, 102, 38, 93, 161, 192,
} },
{ {
219, 188, 161, 46, 114, 163, 198, 154, 73, 10, 43, 101, 199,
160, 89, 12, 49, 111, 186, 136, 62, 2, 15, 66, 123,
},
{
228, 210, 191, 108, 177, 215, 213, 183, 125, 58, 112, 169, 212,
183, 134, 65, 120, 171, 206, 166, 90, 27, 73, 140, 173,
} } },
{ { {
232, 198, 164, 85, 124, 169, 207, 156, 49, 9, 42, 97, 208,
160, 90, 11, 45, 101, 198, 145, 50, 2, 15, 66, 120,
},
{
237, 218, 199, 123, 187, 222, 219, 187, 101, 54, 117, 167, 221,
189, 125, 61, 121, 171, 212, 175, 81, 27, 78, 147, 185,
} },
{ {
204, 165, 154, 39, 100, 144, 173, 117, 42, 7, 27, 71, 156,
108, 52, 9, 32, 78, 165, 117, 46, 2, 12, 55, 102,
},
{
225, 204, 183, 99, 173, 149, 205, 167, 88, 47, 99, 160, 186,
149, 88, 48, 98, 157, 183, 148, 76, 34, 75, 133, 187,
} } },
{ { { 222, 195, 160, 87, 108, 167, 209, 179, 60, 35, 31,
83, 120, 154, 208, 181, 140, 45, 28, 85, 117, 148,
201, 168, 86, 28, 19, 47, 81, 123, 129, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128 },
{ 230, 211, 198, 122, 175, 219, 221, 202, 106, 58, 95,
152, 178, 198, 221, 201, 160, 97, 96, 151, 171, 199,
214, 192, 124, 52, 67, 123, 150, 182, 170, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128 } },
{ { 206, 185, 149, 41, 87, 142, 188, 157, 50, 12, 20,
60, 101, 141, 191, 161, 98, 15, 20, 69, 106, 138,
176, 134, 50, 4, 6, 23, 51, 101, 116, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128 },
{ 218, 204, 187, 100, 161, 205, 211, 189, 106, 47, 83,
138, 168, 165, 206, 185, 133, 62, 86, 143, 165, 182,
201, 168, 95, 28, 47, 101, 126, 176, 174, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128 } } },
{ { { 221, 188, 156, 103, 104, 162, 203, 160, 29, 15, 18,
56, 93, 133, 203, 162, 108, 21, 17, 61, 94, 128,
194, 142, 63, 5, 6, 21, 48, 90, 114, 134, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128 },
{ 230, 207, 196, 123, 177, 222, 218, 192, 82, 50, 83,
141, 169, 195, 219, 192, 136, 75, 83, 142, 165, 181,
209, 175, 99, 33, 53, 103, 134, 171, 175, 180, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128 } },
{ { 183, 158, 145, 45, 83, 123, 167, 125, 34, 11, 14,
43, 70, 120, 143, 107, 65, 14, 12, 48, 69, 111,
152, 111, 59, 3, 6, 22, 41, 84, 99, 123, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128 },
{ 217, 197, 177, 99, 158, 213, 201, 173, 73, 39, 72,
128, 158, 189, 193, 157, 96, 49, 62, 120, 138, 166,
169, 148, 114, 32, 54, 100, 117, 163, 140, 154, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128 } } },
{ { { 219, 189, 180, 134, 131, 173, 197, 157, 40, 13, 18,
51, 88, 128, 200, 155, 91, 17, 14, 55, 84, 122,
181, 125, 49, 3, 4, 13, 30, 68, 97, 126, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128 },
{ 228, 207, 206, 136, 186, 220, 207, 188, 81, 44, 84,
136, 167, 189, 217, 187, 131, 65, 76, 136, 164, 191,
198, 161, 80, 25, 49, 92, 119, 159, 167, 180, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128 } },
{ { 206, 191, 210, 67, 109, 142, 145, 129, 39, 10, 15,
35, 55, 88, 147, 118, 64, 9, 10, 39, 60, 115,
142, 88, 7, 3, 6, 25, 45, 94, 108, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128 },
{ 211, 207, 224, 109, 181, 199, 171, 194, 96, 25, 77,
125, 102, 128, 205, 166, 110, 32, 60, 132, 171, 128,
171, 130, 13, 33, 61, 116, 142, 228, 213, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128 } } },
{ { { 220, 198, 201, 139, 137, 187, 197, 166, 43, 20, 28,
65, 94, 124, 191, 147, 90, 17, 18, 63, 84, 116,
175, 117, 46, 2, 4, 16, 27, 63, 91, 119, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128 },
{ 232, 218, 219, 140, 212, 229, 203, 197, 125, 40, 92,
142, 168, 168, 210, 182, 126, 68, 86, 133, 163, 180,
197, 160, 89, 21, 42, 93, 113, 161, 171, 169, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128 } },
{ { 218, 229, 245, 77, 120, 171, 183, 181, 128, 4, 15,
41, 94, 171, 67, 101, 57, 4, 7, 19, 50, 64,
146, 109, 15, 1, 6, 35, 61, 143, 148, 205, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128 },
{ 217, 217, 213, 86, 199, 171, 146, 197, 128, 47, 92,
116, 171, 128, 171, 158, 64, 16, 54, 57, 128, 128,
186, 155, 9, 41, 48, 135, 141, 253, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128 } } }
};
{ { {
231, 199, 182, 107, 136, 172, 200, 148, 55, 8, 35, 87, 204,
150, 72, 10, 37, 89, 184, 127, 36, 1, 9, 47, 103,
},
{
236, 217, 206, 128, 188, 222, 213, 180, 98, 51, 113, 166, 218,
182, 115, 55, 115, 167, 200, 162, 66, 22, 70, 135, 178,
} },
{ {
229, 200, 220, 56, 123, 179, 184, 123, 64, 8, 24, 62, 177,
118, 55, 8, 27, 70, 158, 101, 8, 1, 12, 54, 107,
},
{
232, 222, 223, 108, 195, 154, 213, 184, 71, 41, 101, 154, 206,
164, 109, 42, 96, 162, 182, 137, 5, 33, 81, 146, 177,
} } },
{ { {
232, 208, 213, 120, 151, 192, 200, 152, 57, 13, 44, 94, 200,
148, 87, 13, 42, 94, 181, 124, 45, 1, 9, 46, 99,
},
{
241, 226, 222, 129, 197, 179, 213, 184, 133, 57, 119, 168, 214,
178, 116, 64, 119, 162, 199, 157, 64, 24, 70, 130, 176,
} },
{ {
233, 223, 202, 65, 131, 128, 178, 138, 128, 2, 24, 59, 99,
111, 73, 3, 17, 52, 149, 99, 19, 2, 18, 72, 140,
},
{
240, 199, 230, 79, 181, 128, 192, 198, 128, 64, 121, 171, 192,
148, 37, 26, 83, 85, 183, 149, 8, 33, 101, 168, 128,
} } }
};
static const aom_prob default_nz_map[TX_SIZES][PLANE_TYPES][SIG_COEF_CONTEXTS] =
{ { { 40, 157, 108, 70, 34, 19, 168, 98, 60, 32, 20, 128,
......
......@@ -37,6 +37,10 @@ static INLINE TX_SIZE get_txsize_context(TX_SIZE tx_size) {
return txsize_sqr_up_map[tx_size];
}
static const int base_level_count_to_index[13] = {
0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3,
};
static const int base_ref_offset[BASE_CONTEXT_POSITION_NUM][2] = {
/* clang-format off*/
{ -2, 0 }, { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -2 }, { 0, -1 }, { 0, 1 },
......@@ -122,7 +126,7 @@ static INLINE int get_level_count_mag_coeff(
static INLINE int get_base_ctx_from_count_mag(int row, int col, int count,
int sig_mag) {
const int ctx = (count + 1) >> 1;
const int ctx = base_level_count_to_index[count];
int ctx_idx = -1;
if (row == 0 && col == 0) {
......@@ -138,7 +142,6 @@ static INLINE int get_base_ctx_from_count_mag(int row, int col, int count,
ctx_idx = 3 + ctx;
assert(ctx_idx <= 6);
return ctx_idx;
} else if (row == 0) {
if (sig_mag >= 2) return ctx_idx = 6;
......@@ -151,39 +154,36 @@ static INLINE int get_base_ctx_from_count_mag(int row, int col, int count,
}
ctx_idx = 9 + ctx;
assert(ctx_idx <= 13);
assert(ctx_idx <= 11);
return ctx_idx;
} else if (col == 0) {
if (sig_mag >= 2) return ctx_idx = 14;
if (sig_mag >= 2) return ctx_idx = 12;
if (sig_mag == 1) {
if (count >= 2)
ctx_idx = 15;
ctx_idx = 13;
else
ctx_idx = 16;
ctx_idx = 14;
return ctx_idx;
}
ctx_idx = 17 + ctx;
assert(ctx_idx <= 21);
ctx_idx = 15 + ctx;
assert(ctx_idx <= 17);
// TODO(angiebird): turn this on once the optimization is finalized
// assert(ctx_idx < 28);
} else {
if (sig_mag >= 2) return ctx_idx = 22;
if (sig_mag >= 2) return ctx_idx = 18;
if (sig_mag == 1) {
if (count >= 2)
ctx_idx = 23;
ctx_idx = 19;
else
ctx_idx = 24;
ctx_idx = 20;
return ctx_idx;
}
ctx_idx = 25 + ctx;
ctx_idx = 21 + ctx;
assert(ctx_idx <= 31);
assert(ctx_idx <= 24);
}
return ctx_idx;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment