From 8575709f977f8abc9a53907693ed65c0e45aa73f Mon Sep 17 00:00:00 2001 From: Aamir Anis Date: Fri, 8 Jul 2016 14:36:36 -0700 Subject: [PATCH] Fix for loop filter selection procedure Fixed best error reported by loop filter selection, this value is used during loop restoration to pick best mode. Baseline remains unchanged, change in BDRate for loop restoration experiment: -0.628 -> -0.625 for lowres, -1.262 -> -1.283 for highres. Change-Id: I69ef1608bc232b250ac46f59e31fdbed1a999dcd --- vp10/encoder/picklpf.c | 13 +++++++++---- vp10/encoder/pickrst.c | 14 +++++++++----- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/vp10/encoder/picklpf.c b/vp10/encoder/picklpf.c index f491006cf..9e0e72a85 100644 --- a/vp10/encoder/picklpf.c +++ b/vp10/encoder/picklpf.c @@ -120,11 +120,11 @@ int vp10_search_filter_level(const YV12_BUFFER_CONFIG *sd, VP10_COMP *cpi, } // If value is close to the best so far then bias towards a lower loop // filter value. - if ((ss_err[filt_low] - bias) < best_err) { + if (ss_err[filt_low] < (best_err + bias)) { // Was it actually better than the previous best? - if (ss_err[filt_low] < best_err) + if (ss_err[filt_low] < best_err) { best_err = ss_err[filt_low]; - + } filt_best = filt_low; } } @@ -134,7 +134,8 @@ int vp10_search_filter_level(const YV12_BUFFER_CONFIG *sd, VP10_COMP *cpi, if (ss_err[filt_high] < 0) { ss_err[filt_high] = try_filter_frame(sd, cpi, filt_high, partial_frame); } - // Was it better than the previous best? + // If value is significantly better than previous best, bias added against + // raising filter value if (ss_err[filt_high] < (best_err - bias)) { best_err = ss_err[filt_high]; filt_best = filt_high; @@ -150,6 +151,10 @@ int vp10_search_filter_level(const YV12_BUFFER_CONFIG *sd, VP10_COMP *cpi, filt_mid = filt_best; } } + + // Update best error + best_err = ss_err[filt_best]; + if (best_cost_ret) *best_cost_ret = RDCOST_DBL(x->rdmult, x->rddiv, 0, best_err); return filt_best; diff --git a/vp10/encoder/pickrst.c b/vp10/encoder/pickrst.c index 6e4f59074..fa0106245 100644 --- a/vp10/encoder/pickrst.c +++ b/vp10/encoder/pickrst.c @@ -146,17 +146,16 @@ static int search_filter_bilateral_level(const YV12_BUFFER_CONFIG *sd, if (filt_direction <= 0 && filt_low != filt_mid) { // Get Low filter error score if (ss_err[filt_low] < 0) { - bilateral_lev = search_bilateral_level(sd, cpi, filt_low, - partial_frame, &ss_err[filt_low]); + bilateral_lev = search_bilateral_level( + sd, cpi, filt_low, partial_frame, &ss_err[filt_low]); } // If value is close to the best so far then bias towards a lower loop // filter value. - if ((ss_err[filt_low] - bias) < best_err) { + if (ss_err[filt_low] < (best_err + bias)) { // Was it actually better than the previous best? if (ss_err[filt_low] < best_err) { best_err = ss_err[filt_low]; } - filt_best = filt_low; restoration_best = bilateral_lev; } @@ -168,7 +167,8 @@ static int search_filter_bilateral_level(const YV12_BUFFER_CONFIG *sd, bilateral_lev = search_bilateral_level( sd, cpi, filt_high, partial_frame, &ss_err[filt_high]); } - // Was it better than the previous best? + // If value is significantly better than previous best, bias added against + // raising filter value if (ss_err[filt_high] < (best_err - bias)) { best_err = ss_err[filt_high]; filt_best = filt_high; @@ -185,6 +185,10 @@ static int search_filter_bilateral_level(const YV12_BUFFER_CONFIG *sd, filt_mid = filt_best; } } + + // Update best error + best_err = ss_err[filt_best]; + *restoration_level = restoration_best; if (best_cost_ret) *best_cost_ret = best_err; return filt_best;