Commit 389efb28 authored by Debargha Mukherjee's avatar Debargha Mukherjee

Adds an utility macro ROUNDZ_POWER_OF_TWO

This macro works for the shift parameter being 0.
The ROUND_POWER_OF_TWO macro does not.

Change-Id: I8434d2933892e09bbc0d2dafc934d0c3637df347
parent aa703adb
......@@ -768,8 +768,8 @@ static void block_rd_txfm(int plane, int block, int blk_row, int blk_col,
sse = vpx_sum_squares_2d_i16(diff, diff_stride, bs);
#if CONFIG_VP9_HIGHBITDEPTH
if ((xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) && (xd->bd > 8))
sse = ROUND_POWER_OF_TWO(sse, (xd->bd - 8) * 2);
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH)
sse = ROUNDZ_POWER_OF_TWO(sse, (xd->bd - 8) * 2);
#endif // CONFIG_VP9_HIGHBITDEPTH
sse = (int64_t)sse * 16;
......@@ -2458,8 +2458,8 @@ void vp10_tx_block_rd_b(const VP10_COMP *cpi, MACROBLOCK *x, TX_SIZE tx_size,
}
#if CONFIG_VP9_HIGHBITDEPTH
if ((xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) && (xd->bd > 8))
tmp = ROUND_POWER_OF_TWO(tmp, (xd->bd - 8) * 2);
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH)
tmp = ROUNDZ_POWER_OF_TWO(tmp, (xd->bd - 8) * 2);
#endif // CONFIG_VP9_HIGHBITDEPTH
*bsse += (int64_t)tmp * 16;
......
......@@ -38,10 +38,14 @@
#define __builtin_prefetch(x)
#endif
/* Shift down with rounding */
/* Shift down with rounding for use when n > 0 */
#define ROUND_POWER_OF_TWO(value, n) \
(((value) + (1 << ((n) - 1))) >> (n))
/* Shift down with rounding for use when n >= 0 */
#define ROUNDZ_POWER_OF_TWO(value, n) \
((n) ? (((value) + (1 << ((n) - 1))) >> (n)) : (value))
#define ALIGN_POWER_OF_TWO(value, n) \
(((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