| Index: libvpx/source/libvpx/vp8/encoder/picklpf.c
|
| diff --git a/libvpx/source/libvpx/vp8/encoder/picklpf.c b/libvpx/source/libvpx/vp8/encoder/picklpf.c
|
| index beefe8d8ea0e9b98ba94d73a07f4db38911f0f34..d294af6c06429f45fea9e1c3f9c4d388112bda4b 100644
|
| --- a/libvpx/source/libvpx/vp8/encoder/picklpf.c
|
| +++ b/libvpx/source/libvpx/vp8/encoder/picklpf.c
|
| @@ -16,11 +16,12 @@
|
| #include "vpx_scale/yv12extend.h"
|
| #include "vpx_scale/vpxscale.h"
|
| #include "vp8/common/alloccommon.h"
|
| -#include "vp8/common/loopfilter.h"
|
| #if ARCH_ARM
|
| #include "vpx_ports/arm.h"
|
| #endif
|
|
|
| +extern void vp8_loop_filter_frame(VP8_COMMON *cm, MACROBLOCKD *mbd, int filt_val);
|
| +extern void vp8_loop_filter_frame_yonly(VP8_COMMON *cm, MACROBLOCKD *mbd, int filt_val, int sharpness_lvl);
|
| extern int vp8_calc_ss_err(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *dest, const vp8_variance_rtcd_vtable_t *rtcd);
|
| #if HAVE_ARMV7
|
| extern void vp8_yv12_copy_frame_yonly_no_extend_frame_borders_neon(YV12_BUFFER_CONFIG *src_ybc, YV12_BUFFER_CONFIG *dst_ybc);
|
| @@ -103,6 +104,15 @@ static int vp8_calc_partial_ssl_err(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONF
|
| return Total;
|
| }
|
|
|
| +extern void vp8_loop_filter_partial_frame
|
| +(
|
| + VP8_COMMON *cm,
|
| + MACROBLOCKD *mbd,
|
| + int default_filt_lvl,
|
| + int sharpness_lvl,
|
| + int Fraction
|
| +);
|
| +
|
| // Enforce a minimum filter level based upon baseline Q
|
| static int get_min_filter_level(VP8_COMP *cpi, int base_qindex)
|
| {
|
| @@ -131,11 +141,13 @@ static int get_max_filter_level(VP8_COMP *cpi, int base_qindex)
|
| // jbb chg: 20100118 - not so any more with this overquant stuff allow high values
|
| // with lots of intra coming in.
|
| int max_filter_level = MAX_LOOP_FILTER ;//* 3 / 4;
|
| - (void)base_qindex;
|
|
|
| - if (cpi->twopass.section_intra_rating > 8)
|
| + if (cpi->section_intra_rating > 8)
|
| max_filter_level = MAX_LOOP_FILTER * 3 / 4;
|
|
|
| + (void) cpi;
|
| + (void) base_qindex;
|
| +
|
| return max_filter_level;
|
| }
|
|
|
| @@ -145,12 +157,13 @@ void vp8cx_pick_filter_level_fast(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi)
|
|
|
| int best_err = 0;
|
| int filt_err = 0;
|
| - int min_filter_level = get_min_filter_level(cpi, cm->base_qindex);
|
| - int max_filter_level = get_max_filter_level(cpi, cm->base_qindex);
|
| + int min_filter_level = 0;
|
| + int max_filter_level = MAX_LOOP_FILTER * 3 / 4; // PGW August 2006: Highest filter values almost always a bad idea
|
| int filt_val;
|
| int best_filt_val = cm->filter_level;
|
|
|
| // Make a copy of the unfiltered / processed recon buffer
|
| + //vp8_yv12_copy_frame_ptr( cm->frame_to_show, &cpi->last_frame_uf );
|
| vp8_yv12_copy_partial_frame_ptr(cm->frame_to_show, &cpi->last_frame_uf, 3);
|
|
|
| if (cm->frame_type == KEY_FRAME)
|
| @@ -158,11 +171,9 @@ void vp8cx_pick_filter_level_fast(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi)
|
| else
|
| cm->sharpness_level = cpi->oxcf.Sharpness;
|
|
|
| - if (cm->sharpness_level != cm->last_sharpness_level)
|
| - {
|
| - vp8_loop_filter_update_sharpness(&cm->lf_info, cm->sharpness_level);
|
| - cm->last_sharpness_level = cm->sharpness_level;
|
| - }
|
| + // Enforce a minimum filter level based upon Q
|
| + min_filter_level = get_min_filter_level(cpi, cm->base_qindex);
|
| + max_filter_level = get_max_filter_level(cpi, cm->base_qindex);
|
|
|
| // Start the search at the previous frame filter level unless it is now out of range.
|
| if (cm->filter_level < min_filter_level)
|
| @@ -173,8 +184,13 @@ void vp8cx_pick_filter_level_fast(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi)
|
| filt_val = cm->filter_level;
|
| best_filt_val = filt_val;
|
|
|
| + // Set up alternate filter values
|
| +
|
| // Get the err using the previous frame's filter value.
|
| - vp8_loop_filter_partial_frame(cm, &cpi->mb.e_mbd, filt_val);
|
| + vp8_loop_filter_partial_frame(cm, &cpi->mb.e_mbd, filt_val, 0 , 3);
|
| + cm->last_frame_type = cm->frame_type;
|
| + cm->last_filter_type = cm->filter_type;
|
| + cm->last_sharpness_level = cm->sharpness_level;
|
|
|
| best_err = vp8_calc_partial_ssl_err(sd, cm->frame_to_show, 3, IF_RTCD(&cpi->rtcd.variance));
|
|
|
| @@ -187,11 +203,15 @@ void vp8cx_pick_filter_level_fast(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi)
|
| while (filt_val >= min_filter_level)
|
| {
|
| // Apply the loop filter
|
| - vp8_loop_filter_partial_frame(cm, &cpi->mb.e_mbd, filt_val);
|
| + vp8_loop_filter_partial_frame(cm, &cpi->mb.e_mbd, filt_val, 0, 3);
|
| + cm->last_frame_type = cm->frame_type;
|
| + cm->last_filter_type = cm->filter_type;
|
| + cm->last_sharpness_level = cm->sharpness_level;
|
|
|
| // Get the err for filtered frame
|
| filt_err = vp8_calc_partial_ssl_err(sd, cm->frame_to_show, 3, IF_RTCD(&cpi->rtcd.variance));
|
|
|
| +
|
| // Re-instate the unfiltered frame
|
| vp8_yv12_copy_partial_frame_ptr(&cpi->last_frame_uf, cm->frame_to_show, 3);
|
|
|
| @@ -220,7 +240,10 @@ void vp8cx_pick_filter_level_fast(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi)
|
| while (filt_val < max_filter_level)
|
| {
|
| // Apply the loop filter
|
| - vp8_loop_filter_partial_frame(cm, &cpi->mb.e_mbd, filt_val);
|
| + vp8_loop_filter_partial_frame(cm, &cpi->mb.e_mbd, filt_val, 0, 3);
|
| + cm->last_frame_type = cm->frame_type;
|
| + cm->last_filter_type = cm->filter_type;
|
| + cm->last_sharpness_level = cm->sharpness_level;
|
|
|
| // Get the err for filtered frame
|
| filt_err = vp8_calc_partial_ssl_err(sd, cm->frame_to_show, 3, IF_RTCD(&cpi->rtcd.variance));
|
| @@ -271,8 +294,8 @@ void vp8cx_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi)
|
|
|
| int best_err = 0;
|
| int filt_err = 0;
|
| - int min_filter_level = get_min_filter_level(cpi, cm->base_qindex);
|
| - int max_filter_level = get_max_filter_level(cpi, cm->base_qindex);
|
| + int min_filter_level;
|
| + int max_filter_level;
|
|
|
| int filter_step;
|
| int filt_high = 0;
|
| @@ -306,6 +329,10 @@ void vp8cx_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi)
|
| else
|
| cm->sharpness_level = cpi->oxcf.Sharpness;
|
|
|
| + // Enforce a minimum filter level based upon Q
|
| + min_filter_level = get_min_filter_level(cpi, cm->base_qindex);
|
| + max_filter_level = get_max_filter_level(cpi, cm->base_qindex);
|
| +
|
| // Start the search at the previous frame filter level unless it is now out of range.
|
| filt_mid = cm->filter_level;
|
|
|
| @@ -319,7 +346,10 @@ void vp8cx_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi)
|
|
|
| // Get baseline error score
|
| vp8cx_set_alt_lf_level(cpi, filt_mid);
|
| - vp8_loop_filter_frame_yonly(cm, &cpi->mb.e_mbd, filt_mid);
|
| + vp8_loop_filter_frame_yonly(cm, &cpi->mb.e_mbd, filt_mid, 0);
|
| + cm->last_frame_type = cm->frame_type;
|
| + cm->last_filter_type = cm->filter_type;
|
| + cm->last_sharpness_level = cm->sharpness_level;
|
|
|
| best_err = vp8_calc_ss_err(sd, cm->frame_to_show, IF_RTCD(&cpi->rtcd.variance));
|
| filt_best = filt_mid;
|
| @@ -347,8 +377,8 @@ void vp8cx_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi)
|
| Bias = (best_err >> (15 - (filt_mid / 8))) * filter_step; //PGW change 12/12/06 for small images
|
|
|
| // jbb chg: 20100118 - in sections with lots of new material coming in don't bias as much to a low filter value
|
| - if (cpi->twopass.section_intra_rating < 20)
|
| - Bias = Bias * cpi->twopass.section_intra_rating / 20;
|
| + if (cpi->section_intra_rating < 20)
|
| + Bias = Bias * cpi->section_intra_rating / 20;
|
|
|
| filt_high = ((filt_mid + filter_step) > max_filter_level) ? max_filter_level : (filt_mid + filter_step);
|
| filt_low = ((filt_mid - filter_step) < min_filter_level) ? min_filter_level : (filt_mid - filter_step);
|
| @@ -357,7 +387,10 @@ void vp8cx_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi)
|
| {
|
| // Get Low filter error score
|
| vp8cx_set_alt_lf_level(cpi, filt_low);
|
| - vp8_loop_filter_frame_yonly(cm, &cpi->mb.e_mbd, filt_low);
|
| + vp8_loop_filter_frame_yonly(cm, &cpi->mb.e_mbd, filt_low, 0);
|
| + cm->last_frame_type = cm->frame_type;
|
| + cm->last_filter_type = cm->filter_type;
|
| + cm->last_sharpness_level = cm->sharpness_level;
|
|
|
| filt_err = vp8_calc_ss_err(sd, cm->frame_to_show, IF_RTCD(&cpi->rtcd.variance));
|
|
|
| @@ -394,7 +427,10 @@ void vp8cx_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi)
|
| if ((filt_direction >= 0) && (filt_high != filt_mid))
|
| {
|
| vp8cx_set_alt_lf_level(cpi, filt_high);
|
| - vp8_loop_filter_frame_yonly(cm, &cpi->mb.e_mbd, filt_high);
|
| + vp8_loop_filter_frame_yonly(cm, &cpi->mb.e_mbd, filt_high, 0);
|
| + cm->last_frame_type = cm->frame_type;
|
| + cm->last_filter_type = cm->filter_type;
|
| + cm->last_sharpness_level = cm->sharpness_level;
|
|
|
| filt_err = vp8_calc_ss_err(sd, cm->frame_to_show, IF_RTCD(&cpi->rtcd.variance));
|
|
|
| @@ -438,4 +474,8 @@ void vp8cx_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi)
|
| }
|
|
|
| cm->filter_level = filt_best;
|
| + cpi->last_auto_filt_val = filt_best;
|
| + cpi->last_auto_filt_q = cm->base_qindex;
|
| +
|
| + cpi->frames_since_auto_filter = 0;
|
| }
|
|
|