Commit d8ffee45 authored by Paul Wilkins's avatar Paul Wilkins
Browse files

Changes to rd error_per_bit calculation.

Specifically changes to retain more precision
especially at low Q through to the point of use.

Change-Id: Ief5f010f2ca4daaabef49520e7edb46c35daf397
parent a5b54d73
...@@ -68,7 +68,7 @@ static int mv_err_cost(int_mv *mv, int_mv *ref, int *mvjcost, int *mvcost[2], ...@@ -68,7 +68,7 @@ static int mv_err_cost(int_mv *mv, int_mv *ref, int *mvjcost, int *mvcost[2],
v.col = mv->as_mv.col - ref->as_mv.col; v.col = mv->as_mv.col - ref->as_mv.col;
return ((mvjcost[vp9_get_mv_joint(v)] + return ((mvjcost[vp9_get_mv_joint(v)] +
mvcost[0][v.row] + mvcost[1][v.col]) * mvcost[0][v.row] + mvcost[1][v.col]) *
error_per_bit + 128) >> 8; error_per_bit + 4096) >> 13;
} }
return 0; return 0;
} }
...@@ -205,7 +205,8 @@ void vp9_init3smotion_compensation(MACROBLOCK *x, int stride) { ...@@ -205,7 +205,8 @@ void vp9_init3smotion_compensation(MACROBLOCK *x, int stride) {
(mvcost ? \ (mvcost ? \
((mvjcost[((r) != rr) * 2 + ((c) != rc)] + \ ((mvjcost[((r) != rr) * 2 + ((c) != rc)] + \
mvcost[0][((r) - rr)] + mvcost[1][((c) - rc)]) * \ mvcost[0][((r) - rr)] + mvcost[1][((c) - rc)]) * \
error_per_bit + 128) >> 8 : 0) error_per_bit + 4096) >> 13 : 0)
#define SP(x) (((x) & 7) << 1) // convert motion vector component to offset #define SP(x) (((x) & 7) << 1) // convert motion vector component to offset
// for svf calc // for svf calc
......
...@@ -254,7 +254,7 @@ void vp9_init_me_luts() { ...@@ -254,7 +254,7 @@ void vp9_init_me_luts() {
static int compute_rd_mult(int qindex) { static int compute_rd_mult(int qindex) {
int q = vp9_dc_quant(qindex, 0); int q = vp9_dc_quant(qindex, 0);
return (11 * q * q) >> 6; return (11 * q * q) >> 2;
} }
void vp9_initialize_me_consts(VP9_COMP *cpi, int qindex) { void vp9_initialize_me_consts(VP9_COMP *cpi, int qindex) {
...@@ -275,7 +275,6 @@ void vp9_initialize_rd_consts(VP9_COMP *cpi, int qindex) { ...@@ -275,7 +275,6 @@ void vp9_initialize_rd_consts(VP9_COMP *cpi, int qindex) {
qindex = (qindex < 0) ? 0 : ((qindex > MAXQ) ? MAXQ : qindex); qindex = (qindex < 0) ? 0 : ((qindex > MAXQ) ? MAXQ : qindex);
cpi->RDMULT = compute_rd_mult(qindex); cpi->RDMULT = compute_rd_mult(qindex);
if (cpi->pass == 2 && (cpi->common.frame_type != KEY_FRAME)) { if (cpi->pass == 2 && (cpi->common.frame_type != KEY_FRAME)) {
if (cpi->twopass.next_iiratio > 31) if (cpi->twopass.next_iiratio > 31)
cpi->RDMULT += (cpi->RDMULT * rd_iifactor[31]) >> 4; cpi->RDMULT += (cpi->RDMULT * rd_iifactor[31]) >> 4;
...@@ -283,16 +282,13 @@ void vp9_initialize_rd_consts(VP9_COMP *cpi, int qindex) { ...@@ -283,16 +282,13 @@ void vp9_initialize_rd_consts(VP9_COMP *cpi, int qindex) {
cpi->RDMULT += cpi->RDMULT +=
(cpi->RDMULT * rd_iifactor[cpi->twopass.next_iiratio]) >> 4; (cpi->RDMULT * rd_iifactor[cpi->twopass.next_iiratio]) >> 4;
} }
cpi->mb.errorperbit = cpi->RDMULT >> 6;
cpi->mb.errorperbit = (cpi->RDMULT / 110);
cpi->mb.errorperbit += (cpi->mb.errorperbit == 0); cpi->mb.errorperbit += (cpi->mb.errorperbit == 0);
vp9_set_speed_features(cpi); vp9_set_speed_features(cpi);
q = (int)pow(vp9_dc_quant(qindex, 0) >> 2, 1.25); q = (int)pow(vp9_dc_quant(qindex, 0) >> 2, 1.25);
q <<= 2; q <<= 2;
cpi->RDMULT = cpi->RDMULT << 4;
if (q < 8) if (q < 8)
q = 8; q = 8;
......
Supports Markdown
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