Merge "Add a method to estimate loop filter level from quantizer and frame type."

This commit is contained in:
Alex Converse 2014-01-24 14:10:14 -08:00 committed by Gerrit Code Review
commit 6a457ef794
4 changed files with 32 additions and 7 deletions

View File

@ -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;
}
}

View File

@ -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

View File

@ -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);
}
}

View File

@ -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