Commit 5c93dca3 authored by Jingning Han's avatar Jingning Han Committed by Gerrit Code Review
Browse files

Merge "Simplify rate-distortion modeling function"

parents 8d558f2c eefe8692
...@@ -249,14 +249,14 @@ static void model_rd_for_sb_y(VP9_COMP *cpi, BLOCK_SIZE bsize, ...@@ -249,14 +249,14 @@ static void model_rd_for_sb_y(VP9_COMP *cpi, BLOCK_SIZE bsize,
#if CONFIG_VP9_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
vp9_model_rd_from_var_lapndz(sse - var, 1 << num_pels_log2_lookup[bsize], vp9_model_rd_from_var_lapndz(sse - var, num_pels_log2_lookup[bsize],
dc_quant >> (xd->bd - 5), &rate, &dist); dc_quant >> (xd->bd - 5), &rate, &dist);
} else { } else {
vp9_model_rd_from_var_lapndz(sse - var, 1 << num_pels_log2_lookup[bsize], vp9_model_rd_from_var_lapndz(sse - var, num_pels_log2_lookup[bsize],
dc_quant >> 3, &rate, &dist); dc_quant >> 3, &rate, &dist);
} }
#else #else
vp9_model_rd_from_var_lapndz(sse - var, 1 << num_pels_log2_lookup[bsize], vp9_model_rd_from_var_lapndz(sse - var, num_pels_log2_lookup[bsize],
dc_quant >> 3, &rate, &dist); dc_quant >> 3, &rate, &dist);
#endif // CONFIG_VP9_HIGHBITDEPTH #endif // CONFIG_VP9_HIGHBITDEPTH
...@@ -265,14 +265,14 @@ static void model_rd_for_sb_y(VP9_COMP *cpi, BLOCK_SIZE bsize, ...@@ -265,14 +265,14 @@ static void model_rd_for_sb_y(VP9_COMP *cpi, BLOCK_SIZE bsize,
#if CONFIG_VP9_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
vp9_model_rd_from_var_lapndz(var, 1 << num_pels_log2_lookup[bsize], vp9_model_rd_from_var_lapndz(var, num_pels_log2_lookup[bsize],
ac_quant >> (xd->bd - 5), &rate, &dist); ac_quant >> (xd->bd - 5), &rate, &dist);
} else { } else {
vp9_model_rd_from_var_lapndz(var, 1 << num_pels_log2_lookup[bsize], vp9_model_rd_from_var_lapndz(var, num_pels_log2_lookup[bsize],
ac_quant >> 3, &rate, &dist); ac_quant >> 3, &rate, &dist);
} }
#else #else
vp9_model_rd_from_var_lapndz(var, 1 << num_pels_log2_lookup[bsize], vp9_model_rd_from_var_lapndz(var, num_pels_log2_lookup[bsize],
ac_quant >> 3, &rate, &dist); ac_quant >> 3, &rate, &dist);
#endif // CONFIG_VP9_HIGHBITDEPTH #endif // CONFIG_VP9_HIGHBITDEPTH
......
...@@ -379,7 +379,7 @@ static void model_rd_norm(int xsq_q10, int *r_q10, int *d_q10) { ...@@ -379,7 +379,7 @@ static void model_rd_norm(int xsq_q10, int *r_q10, int *d_q10) {
*d_q10 = (dist_tab_q10[xq] * b_q10 + dist_tab_q10[xq + 1] * a_q10) >> 10; *d_q10 = (dist_tab_q10[xq] * b_q10 + dist_tab_q10[xq + 1] * a_q10) >> 10;
} }
void vp9_model_rd_from_var_lapndz(unsigned int var, unsigned int n, void vp9_model_rd_from_var_lapndz(unsigned int var, unsigned int n_log2,
unsigned int qstep, int *rate, unsigned int qstep, int *rate,
int64_t *dist) { int64_t *dist) {
// This function models the rate and distortion for a Laplacian // This function models the rate and distortion for a Laplacian
...@@ -395,10 +395,10 @@ void vp9_model_rd_from_var_lapndz(unsigned int var, unsigned int n, ...@@ -395,10 +395,10 @@ void vp9_model_rd_from_var_lapndz(unsigned int var, unsigned int n,
int d_q10, r_q10; int d_q10, r_q10;
static const uint32_t MAX_XSQ_Q10 = 245727; static const uint32_t MAX_XSQ_Q10 = 245727;
const uint64_t xsq_q10_64 = const uint64_t xsq_q10_64 =
((((uint64_t)qstep * qstep * n) << 10) + (var >> 1)) / var; (((uint64_t)qstep * qstep << (n_log2 + 10)) + (var >> 1)) / var;
const int xsq_q10 = (int)MIN(xsq_q10_64, MAX_XSQ_Q10); const int xsq_q10 = (int)MIN(xsq_q10_64, MAX_XSQ_Q10);
model_rd_norm(xsq_q10, &r_q10, &d_q10); model_rd_norm(xsq_q10, &r_q10, &d_q10);
*rate = (n * r_q10 + 2) >> 2; *rate = ((r_q10 << n_log2) + 2) >> 2;
*dist = (var * (int64_t)d_q10 + 512) >> 10; *dist = (var * (int64_t)d_q10 + 512) >> 10;
} }
} }
......
...@@ -265,15 +265,15 @@ static void model_rd_for_sb(VP9_COMP *cpi, BLOCK_SIZE bsize, ...@@ -265,15 +265,15 @@ static void model_rd_for_sb(VP9_COMP *cpi, BLOCK_SIZE bsize,
} else { } else {
#if CONFIG_VP9_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
vp9_model_rd_from_var_lapndz(sum_sse, 1 << num_pels_log2_lookup[bs], vp9_model_rd_from_var_lapndz(sum_sse, num_pels_log2_lookup[bs],
pd->dequant[1] >> (xd->bd - 5), pd->dequant[1] >> (xd->bd - 5),
&rate, &dist); &rate, &dist);
} else { } else {
vp9_model_rd_from_var_lapndz(sum_sse, 1 << num_pels_log2_lookup[bs], vp9_model_rd_from_var_lapndz(sum_sse, num_pels_log2_lookup[bs],
pd->dequant[1] >> 3, &rate, &dist); pd->dequant[1] >> 3, &rate, &dist);
} }
#else #else
vp9_model_rd_from_var_lapndz(sum_sse, 1 << num_pels_log2_lookup[bs], vp9_model_rd_from_var_lapndz(sum_sse, num_pels_log2_lookup[bs],
pd->dequant[1] >> 3, &rate, &dist); pd->dequant[1] >> 3, &rate, &dist);
#endif // CONFIG_VP9_HIGHBITDEPTH #endif // CONFIG_VP9_HIGHBITDEPTH
rate_sum += rate; rate_sum += rate;
......
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