Commit fa63b551 authored by Geza Lore's avatar Geza Lore
Browse files

Use standard rounding in intra filters.

Use the same rounding method that is used throughout the codebase,
where the halfway value is rounded up rather than down.

Change-Id: Ie969ed7eb9fcc88a93a90c7e274fd82f336c7e4d
parent 011f0204
...@@ -391,7 +391,6 @@ static void vp10_init_intra_predictors_internal(void) { ...@@ -391,7 +391,6 @@ static void vp10_init_intra_predictors_internal(void) {
#if CONFIG_EXT_INTRA #if CONFIG_EXT_INTRA
#define FILTER_INTRA_PREC_BITS 10 #define FILTER_INTRA_PREC_BITS 10
#define FILTER_INTRA_ROUND_VAL 511
static const uint8_t ext_intra_extend_modes[FILTER_INTRA_MODES] = { static const uint8_t ext_intra_extend_modes[FILTER_INTRA_MODES] = {
NEED_LEFT | NEED_ABOVE, // FILTER_DC NEED_LEFT | NEED_ABOVE, // FILTER_DC
...@@ -774,9 +773,7 @@ static void filter_intra_predictors_4tap(uint8_t *dst, ptrdiff_t stride, int bs, ...@@ -774,9 +773,7 @@ static void filter_intra_predictors_4tap(uint8_t *dst, ptrdiff_t stride, int bs,
for (c = 1; c < 2 * bs + 1 - r; ++c) { for (c = 1; c < 2 * bs + 1 - r; ++c) {
ipred = c0 * pred[r - 1][c] + c1 * pred[r][c - 1] + ipred = c0 * pred[r - 1][c] + c1 * pred[r][c - 1] +
c2 * pred[r - 1][c - 1] + c3 * pred[r - 1][c + 1]; c2 * pred[r - 1][c - 1] + c3 * pred[r - 1][c + 1];
pred[r][c] = ipred < 0 ? pred[r][c] = ROUND_POWER_OF_TWO_SIGNED(ipred, FILTER_INTRA_PREC_BITS);
-((-ipred + FILTER_INTRA_ROUND_VAL) >> FILTER_INTRA_PREC_BITS) :
((ipred + FILTER_INTRA_ROUND_VAL) >> FILTER_INTRA_PREC_BITS);
} }
for (r = 0; r < bs; ++r) { for (r = 0; r < bs; ++r) {
...@@ -1050,9 +1047,7 @@ static void highbd_filter_intra_predictors_4tap(uint16_t *dst, ptrdiff_t stride, ...@@ -1050,9 +1047,7 @@ static void highbd_filter_intra_predictors_4tap(uint16_t *dst, ptrdiff_t stride,
for (c = 1; c < 2 * bs + 1 - r; ++c) { for (c = 1; c < 2 * bs + 1 - r; ++c) {
ipred = c0 * pred[r - 1][c] + c1 * pred[r][c - 1] + ipred = c0 * pred[r - 1][c] + c1 * pred[r][c - 1] +
c2 * pred[r - 1][c - 1] + c3 * pred[r - 1][c + 1]; c2 * pred[r - 1][c - 1] + c3 * pred[r - 1][c + 1];
pred[r][c] = ipred < 0 ? pred[r][c] = ROUND_POWER_OF_TWO_SIGNED(ipred, FILTER_INTRA_PREC_BITS);
-((-ipred + FILTER_INTRA_ROUND_VAL) >> FILTER_INTRA_PREC_BITS) :
((ipred + FILTER_INTRA_ROUND_VAL) >> FILTER_INTRA_PREC_BITS);
} }
for (r = 0; r < bs; ++r) { for (r = 0; r < bs; ++r) {
......
...@@ -46,6 +46,11 @@ ...@@ -46,6 +46,11 @@
#define ROUNDZ_POWER_OF_TWO(value, n) \ #define ROUNDZ_POWER_OF_TWO(value, n) \
((n) ? (((value) + (1 << ((n) - 1))) >> (n)) : (value)) ((n) ? (((value) + (1 << ((n) - 1))) >> (n)) : (value))
/* Shift down with rounding for signed integers, for use when n > 0 */
#define ROUND_POWER_OF_TWO_SIGNED(value, n) \
(((value) < 0) ? -ROUND_POWER_OF_TWO(-(value), (n)) \
: ROUND_POWER_OF_TWO((value), (n)))
#define ALIGN_POWER_OF_TWO(value, n) \ #define ALIGN_POWER_OF_TWO(value, n) \
(((value) + ((1 << (n)) - 1)) & ~((1 << (n)) - 1)) (((value) + ((1 << (n)) - 1)) & ~((1 << (n)) - 1))
......
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