summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Converse <aconverse@google.com>2014-01-24 14:10:14 -0800
committerGerrit Code Review <gerrit@gerrit.golo.chromium.org>2014-01-24 14:10:14 -0800
commit6a457ef794224cf2fa1c1be739f1135e441d1662 (patch)
tree80cc653c4ed144f23a80969c2654d07d54f4f958
parent3a05782c6f7193aebc4db8b5fa0aaa62850a91dc (diff)
parent4ce8929b9ea29d698840823349d7adfb5cc46689 (diff)
downloadlibvpx-6a457ef794224cf2fa1c1be739f1135e441d1662.tar
libvpx-6a457ef794224cf2fa1c1be739f1135e441d1662.tar.gz
libvpx-6a457ef794224cf2fa1c1be739f1135e441d1662.tar.bz2
libvpx-6a457ef794224cf2fa1c1be739f1135e441d1662.zip
Merge "Add a method to estimate loop filter level from quantizer and frame type."
-rw-r--r--vp9/encoder/vp9_onyx_if.c1
-rw-r--r--vp9/encoder/vp9_onyx_int.h6
-rw-r--r--vp9/encoder/vp9_picklpf.c30
-rw-r--r--vp9/encoder/vp9_picklpf.h2
4 files changed, 32 insertions, 7 deletions
diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c
index 85baefea1..17df04695 100644
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -851,6 +851,7 @@ static void set_rt_speed_feature(VP9_COMMON *cm,
sf->intra_y_mode_mask[i] = INTRA_DC_H_V;
sf->intra_uv_mode_mask[i] = INTRA_DC_ONLY;
}
+ sf->use_fast_lpf_pick = 2;
}
}
diff --git a/vp9/encoder/vp9_onyx_int.h b/vp9/encoder/vp9_onyx_int.h
index 35f8fac69..061232327 100644
--- a/vp9/encoder/vp9_onyx_int.h
+++ b/vp9/encoder/vp9_onyx_int.h
@@ -409,8 +409,10 @@ typedef struct {
// final encode.
int use_uv_intra_rd_estimate;
- // This picks a loop filter strength by trying a small portion of the image
- // with different values.
+ // This feature controls how the loop filter level is determined:
+ // 0: Try the full image with different values.
+ // 1: Try a small portion of the image with different values.
+ // 2: Estimate the level based on quantizer and frame type
int use_fast_lpf_pick;
// This feature limits the number of coefficients updates we actually do
diff --git a/vp9/encoder/vp9_picklpf.c b/vp9/encoder/vp9_picklpf.c
index a4ceabdf1..075698b31 100644
--- a/vp9/encoder/vp9_picklpf.c
+++ b/vp9/encoder/vp9_picklpf.c
@@ -14,6 +14,7 @@
#include "vp9/encoder/vp9_onyx_int.h"
#include "vp9/encoder/vp9_picklpf.h"
#include "vp9/encoder/vp9_quantize.h"
+#include "vp9/common/vp9_quant_common.h"
#include "vpx_mem/vpx_mem.h"
#include "vpx_scale/vpx_scale.h"
#include "vp9/common/vp9_alloccommon.h"
@@ -33,7 +34,8 @@ static int get_max_filter_level(VP9_COMP *cpi, int base_qindex) {
void vp9_set_alt_lf_level(VP9_COMP *cpi, int filt_val) {
}
-void vp9_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP9_COMP *cpi, int partial) {
+static void search_filter_level(YV12_BUFFER_CONFIG *sd, VP9_COMP *cpi,
+ int partial) {
MACROBLOCKD *const xd = &cpi->mb.e_mbd;
VP9_COMMON *const cm = &cpi->common;
struct loopfilter *const lf = &cm->lf;
@@ -48,9 +50,6 @@ void vp9_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP9_COMP *cpi, int partial) {
int filt_mid = clamp(lf->filter_level, min_filter_level, max_filter_level);
int filter_step = filt_mid < 16 ? 4 : filt_mid / 4;
- lf->sharpness_level = cm->frame_type == KEY_FRAME ? 0
- : cpi->oxcf.sharpness;
-
// Make a copy of the unfiltered / processed recon buffer
vpx_yv12_copy_y(cm->frame_to_show, &cpi->last_frame_uf);
@@ -128,3 +127,26 @@ void vp9_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP9_COMP *cpi, int partial) {
lf->filter_level = filt_best;
}
+
+void vp9_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP9_COMP *cpi, int method) {
+ VP9_COMMON *const cm = &cpi->common;
+ struct loopfilter *const lf = &cm->lf;
+
+ lf->sharpness_level = cm->frame_type == KEY_FRAME ? 0
+ : cpi->oxcf.sharpness;
+
+ if (method == 2) {
+ const int min_filter_level = get_min_filter_level(cpi, cm->base_qindex);
+ const int max_filter_level = get_max_filter_level(cpi, cm->base_qindex);
+ const int q = vp9_ac_quant(cm->base_qindex, 0);
+ // These values were determined by linear fitting the result of the
+ // searched level
+ // filt_guess = q * 0.316206 + 3.87252
+ int filt_guess = (q * 20723 + 1015158 + (1 << 17)) >> 18;
+ if (cm->frame_type == KEY_FRAME)
+ filt_guess -= 4;
+ lf->filter_level = clamp(filt_guess, min_filter_level, max_filter_level);
+ } else {
+ search_filter_level(sd, cpi, method == 1);
+ }
+}
diff --git a/vp9/encoder/vp9_picklpf.h b/vp9/encoder/vp9_picklpf.h
index f9cb14c27..12382fa8d 100644
--- a/vp9/encoder/vp9_picklpf.h
+++ b/vp9/encoder/vp9_picklpf.h
@@ -22,7 +22,7 @@ struct VP9_COMP;
void vp9_set_alt_lf_level(struct VP9_COMP *cpi, int filt_val);
void vp9_pick_filter_level(struct yv12_buffer_config *sd,
- struct VP9_COMP *cpi, int partial);
+ struct VP9_COMP *cpi, int method);
#ifdef __cplusplus
} // extern "C"
#endif