ref: 4ce8929b9ea29d698840823349d7adfb5cc46689
parent: c6d537155c0eef7de973a09fdc5755e734f02042
author: Alex Converse <[email protected]>
date: Thu Jan 23 08:24:20 EST 2014
Add a method to estimate loop filter level from quantizer and frame type. Use this method with rt at speed -5. Change-Id: If3bd6fad4c05ddde72131442dad191e4145047e7
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -851,6 +851,7 @@
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;
}
}
--- a/vp9/encoder/vp9_onyx_int.h
+++ b/vp9/encoder/vp9_onyx_int.h
@@ -409,8 +409,10 @@
// 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
--- 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 @@
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 @@
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);
@@ -127,4 +126,27 @@
}
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);
+ }
}
--- a/vp9/encoder/vp9_picklpf.h
+++ b/vp9/encoder/vp9_picklpf.h
@@ -22,7 +22,7 @@
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