Commit c0386e86 authored by hui su's avatar hui su Committed by Hui Su

ext-intra: squeeze the derivative table

Reduce its size from 270x2 to 90.

Change-Id: Ib6ea59344d7df4cefd2631aa73a1d5e599c212cc
parent 7c1c078d
......@@ -216,67 +216,14 @@ static void av1_init_intra_predictors_internal(void) {
}
#if CONFIG_EXT_INTRA
// 2-D array to store dx and dy used for directional intra prediction.
// First index is angle in range of [0, 269].
// t is the value of tangent(angle).
// If angle > 0 && angle < 90, dx = -((int)(256 / t)), dy = 1;
// If angle > 90 && angle < 180, dx = (int)(256 / t), dy = (int)(256 * t);
// If angle > 180 && angle < 270, dx = 1, dy = -((int)(256 * t));
const int16_t dr_intra_derivative[270][2] = {
{ 1, 1 }, { -14666, 1 }, { -7330, 1 }, { -4884, 1 }, { -3660, 1 },
{ -2926, 1 }, { -2435, 1 }, { -2084, 1 }, { -1821, 1 }, { -1616, 1 },
{ -1451, 1 }, { -1317, 1 }, { -1204, 1 }, { -1108, 1 }, { -1026, 1 },
{ -955, 1 }, { -892, 1 }, { -837, 1 }, { -787, 1 }, { -743, 1 },
{ -703, 1 }, { -666, 1 }, { -633, 1 }, { -603, 1 }, { -574, 1 },
{ -548, 1 }, { -524, 1 }, { -502, 1 }, { -481, 1 }, { -461, 1 },
{ -443, 1 }, { -426, 1 }, { -409, 1 }, { -394, 1 }, { -379, 1 },
{ -365, 1 }, { -352, 1 }, { -339, 1 }, { -327, 1 }, { -316, 1 },
{ -305, 1 }, { -294, 1 }, { -284, 1 }, { -274, 1 }, { -265, 1 },
{ -256, 1 }, { -247, 1 }, { -238, 1 }, { -230, 1 }, { -222, 1 },
{ -214, 1 }, { -207, 1 }, { -200, 1 }, { -192, 1 }, { -185, 1 },
{ -179, 1 }, { -172, 1 }, { -166, 1 }, { -159, 1 }, { -153, 1 },
{ -147, 1 }, { -141, 1 }, { -136, 1 }, { -130, 1 }, { -124, 1 },
{ -119, 1 }, { -113, 1 }, { -108, 1 }, { -103, 1 }, { -98, 1 },
{ -93, 1 }, { -88, 1 }, { -83, 1 }, { -78, 1 }, { -73, 1 },
{ -68, 1 }, { -63, 1 }, { -59, 1 }, { -54, 1 }, { -49, 1 },
{ -45, 1 }, { -40, 1 }, { -35, 1 }, { -31, 1 }, { -26, 1 },
{ -22, 1 }, { -17, 1 }, { -13, 1 }, { -8, 1 }, { -4, 1 },
{ 1, 1 }, { 4, 14666 }, { 8, 7330 }, { 13, 4884 }, { 17, 3660 },
{ 22, 2926 }, { 26, 2435 }, { 31, 2084 }, { 35, 1821 }, { 40, 1616 },
{ 45, 1451 }, { 49, 1317 }, { 54, 1204 }, { 59, 1108 }, { 63, 1026 },
{ 68, 955 }, { 73, 892 }, { 78, 837 }, { 83, 787 }, { 88, 743 },
{ 93, 703 }, { 98, 666 }, { 103, 633 }, { 108, 603 }, { 113, 574 },
{ 119, 548 }, { 124, 524 }, { 130, 502 }, { 136, 481 }, { 141, 461 },
{ 147, 443 }, { 153, 426 }, { 159, 409 }, { 166, 394 }, { 172, 379 },
{ 179, 365 }, { 185, 352 }, { 192, 339 }, { 200, 327 }, { 207, 316 },
{ 214, 305 }, { 222, 294 }, { 230, 284 }, { 238, 274 }, { 247, 265 },
{ 255, 256 }, { 265, 247 }, { 274, 238 }, { 284, 230 }, { 294, 222 },
{ 305, 214 }, { 316, 207 }, { 327, 200 }, { 339, 192 }, { 352, 185 },
{ 365, 179 }, { 379, 172 }, { 394, 166 }, { 409, 159 }, { 426, 153 },
{ 443, 147 }, { 461, 141 }, { 481, 136 }, { 502, 130 }, { 524, 124 },
{ 548, 119 }, { 574, 113 }, { 603, 108 }, { 633, 103 }, { 666, 98 },
{ 703, 93 }, { 743, 88 }, { 787, 83 }, { 837, 78 }, { 892, 73 },
{ 955, 68 }, { 1026, 63 }, { 1108, 59 }, { 1204, 54 }, { 1317, 49 },
{ 1451, 45 }, { 1616, 40 }, { 1821, 35 }, { 2084, 31 }, { 2435, 26 },
{ 2926, 22 }, { 3660, 17 }, { 4884, 13 }, { 7330, 8 }, { 14666, 4 },
{ 1, 1 }, { 1, -4 }, { 1, -8 }, { 1, -13 }, { 1, -17 },
{ 1, -22 }, { 1, -26 }, { 1, -31 }, { 1, -35 }, { 1, -40 },
{ 1, -45 }, { 1, -49 }, { 1, -54 }, { 1, -59 }, { 1, -63 },
{ 1, -68 }, { 1, -73 }, { 1, -78 }, { 1, -83 }, { 1, -88 },
{ 1, -93 }, { 1, -98 }, { 1, -103 }, { 1, -108 }, { 1, -113 },
{ 1, -119 }, { 1, -124 }, { 1, -130 }, { 1, -136 }, { 1, -141 },
{ 1, -147 }, { 1, -153 }, { 1, -159 }, { 1, -166 }, { 1, -172 },
{ 1, -179 }, { 1, -185 }, { 1, -192 }, { 1, -200 }, { 1, -207 },
{ 1, -214 }, { 1, -222 }, { 1, -230 }, { 1, -238 }, { 1, -247 },
{ 1, -255 }, { 1, -265 }, { 1, -274 }, { 1, -284 }, { 1, -294 },
{ 1, -305 }, { 1, -316 }, { 1, -327 }, { 1, -339 }, { 1, -352 },
{ 1, -365 }, { 1, -379 }, { 1, -394 }, { 1, -409 }, { 1, -426 },
{ 1, -443 }, { 1, -461 }, { 1, -481 }, { 1, -502 }, { 1, -524 },
{ 1, -548 }, { 1, -574 }, { 1, -603 }, { 1, -633 }, { 1, -666 },
{ 1, -703 }, { 1, -743 }, { 1, -787 }, { 1, -837 }, { 1, -892 },
{ 1, -955 }, { 1, -1026 }, { 1, -1108 }, { 1, -1204 }, { 1, -1317 },
{ 1, -1451 }, { 1, -1616 }, { 1, -1821 }, { 1, -2084 }, { 1, -2435 },
{ 1, -2926 }, { 1, -3660 }, { 1, -4884 }, { 1, -7330 }, { 1, -14666 },
const int16_t dr_intra_derivative[90] = {
1, 14666, 7330, 4884, 3660, 2926, 2435, 2084, 1821, 1616, 1451, 1317, 1204,
1108, 1026, 955, 892, 837, 787, 743, 703, 666, 633, 603, 574, 548,
524, 502, 481, 461, 443, 426, 409, 394, 379, 365, 352, 339, 327,
316, 305, 294, 284, 274, 265, 256, 247, 238, 230, 222, 214, 207,
200, 192, 185, 179, 172, 166, 159, 153, 147, 141, 136, 130, 124,
119, 113, 108, 103, 98, 93, 88, 83, 78, 73, 68, 63, 59,
54, 49, 45, 40, 35, 31, 26, 22, 17, 13, 8, 4,
};
// Directional prediction, zone 1: 0 < angle < 90
......@@ -378,11 +325,41 @@ static void dr_prediction_z3(uint8_t *dst, ptrdiff_t stride, int bs,
}
}
// Get the shift (up-scaled by 256) in X w.r.t a unit change in Y.
// If angle > 0 && angle < 90, dx = -((int)(256 / t));
// If angle > 90 && angle < 180, dx = (int)(256 / t);
// If angle > 180 && angle < 270, dx = 1;
static inline int get_dx(int angle) {
if (angle > 0 && angle < 90) {
return -dr_intra_derivative[angle];
} else if (angle > 90 && angle < 180) {
return dr_intra_derivative[180 - angle];
} else {
// In this case, we are not really going to use dx. We may return any value.
return 1;
}
}
// Get the shift (up-scaled by 256) in Y w.r.t a unit change in X.
// If angle > 0 && angle < 90, dy = 1;
// If angle > 90 && angle < 180, dy = (int)(256 * t);
// If angle > 180 && angle < 270, dy = -((int)(256 * t));
static inline int get_dy(int angle) {
if (angle > 90 && angle < 180) {
return dr_intra_derivative[angle - 90];
} else if (angle > 180 && angle < 270) {
return -dr_intra_derivative[270 - angle];
} else {
// In this case, we are not really going to use dy. We may return any value.
return 1;
}
}
static void dr_predictor(uint8_t *dst, ptrdiff_t stride, TX_SIZE tx_size,
const uint8_t *const above, const uint8_t *const left,
int angle) {
const int dx = (int)dr_intra_derivative[angle][0];
const int dy = (int)dr_intra_derivative[angle][1];
const int dx = get_dx(angle);
const int dy = get_dy(angle);
const int bs = 4 << tx_size;
assert(angle > 0 && angle < 270);
......@@ -515,8 +492,8 @@ static void dr_prediction_z3_high(uint16_t *dst, ptrdiff_t stride, int bs,
static void dr_predictor_high(uint16_t *dst, ptrdiff_t stride, TX_SIZE tx_size,
const uint16_t *above, const uint16_t *left,
int angle, int bd) {
const int dx = (int)dr_intra_derivative[angle][0];
const int dy = (int)dr_intra_derivative[angle][1];
const int dx = get_dx(angle);
const int dy = get_dy(angle);
const int bs = 4 << tx_size;
assert(angle > 0 && angle < 270);
......
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