| Index: source/libvpx/vp8/encoder/picklpf.c | 
| =================================================================== | 
| --- source/libvpx/vp8/encoder/picklpf.c	(revision 96967) | 
| +++ source/libvpx/vp8/encoder/picklpf.c	(working copy) | 
| @@ -16,12 +16,11 @@ | 
| #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); | 
| @@ -104,15 +103,6 @@ | 
| 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) | 
| { | 
| @@ -141,13 +131,11 @@ | 
| // 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->section_intra_rating > 8) | 
| +    if (cpi->twopass.section_intra_rating > 8) | 
| max_filter_level = MAX_LOOP_FILTER * 3 / 4; | 
|  | 
| -    (void) cpi; | 
| -    (void) base_qindex; | 
| - | 
| return max_filter_level; | 
| } | 
|  | 
| @@ -157,13 +145,12 @@ | 
|  | 
| int best_err = 0; | 
| int filt_err = 0; | 
| -    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 min_filter_level = get_min_filter_level(cpi, cm->base_qindex); | 
| +    int max_filter_level = get_max_filter_level(cpi, cm->base_qindex); | 
| 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) | 
| @@ -171,9 +158,11 @@ | 
| 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); | 
| +    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; | 
| +    } | 
|  | 
| // Start the search at the previous frame filter level unless it is now out of range. | 
| if (cm->filter_level < min_filter_level) | 
| @@ -184,13 +173,8 @@ | 
| 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, 0  , 3); | 
| -    cm->last_frame_type = cm->frame_type; | 
| -    cm->last_filter_type = cm->filter_type; | 
| -    cm->last_sharpness_level = cm->sharpness_level; | 
| +    vp8_loop_filter_partial_frame(cm, &cpi->mb.e_mbd, filt_val); | 
|  | 
| best_err = vp8_calc_partial_ssl_err(sd, cm->frame_to_show, 3, IF_RTCD(&cpi->rtcd.variance)); | 
|  | 
| @@ -203,15 +187,11 @@ | 
| while (filt_val >= min_filter_level) | 
| { | 
| // Apply the loop filter | 
| -        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; | 
| +        vp8_loop_filter_partial_frame(cm, &cpi->mb.e_mbd, filt_val); | 
|  | 
| // 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); | 
|  | 
| @@ -240,10 +220,7 @@ | 
| while (filt_val < max_filter_level) | 
| { | 
| // Apply the loop filter | 
| -            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; | 
| +            vp8_loop_filter_partial_frame(cm, &cpi->mb.e_mbd, filt_val); | 
|  | 
| // Get the err for filtered frame | 
| filt_err = vp8_calc_partial_ssl_err(sd, cm->frame_to_show, 3, IF_RTCD(&cpi->rtcd.variance)); | 
| @@ -294,8 +271,8 @@ | 
|  | 
| int best_err = 0; | 
| int filt_err = 0; | 
| -    int min_filter_level; | 
| -    int max_filter_level; | 
| +    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 filter_step; | 
| int filt_high = 0; | 
| @@ -329,10 +306,6 @@ | 
| 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; | 
|  | 
| @@ -346,10 +319,7 @@ | 
|  | 
| // Get baseline error score | 
| vp8cx_set_alt_lf_level(cpi, 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; | 
| +    vp8_loop_filter_frame_yonly(cm, &cpi->mb.e_mbd, filt_mid); | 
|  | 
| best_err = vp8_calc_ss_err(sd, cm->frame_to_show, IF_RTCD(&cpi->rtcd.variance)); | 
| filt_best = filt_mid; | 
| @@ -377,8 +347,8 @@ | 
| 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->section_intra_rating < 20) | 
| -            Bias = Bias * cpi->section_intra_rating / 20; | 
| +        if (cpi->twopass.section_intra_rating < 20) | 
| +            Bias = Bias * cpi->twopass.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); | 
| @@ -387,10 +357,7 @@ | 
| { | 
| // 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, 0); | 
| -            cm->last_frame_type = cm->frame_type; | 
| -            cm->last_filter_type = cm->filter_type; | 
| -            cm->last_sharpness_level = cm->sharpness_level; | 
| +            vp8_loop_filter_frame_yonly(cm, &cpi->mb.e_mbd, filt_low); | 
|  | 
| filt_err = vp8_calc_ss_err(sd, cm->frame_to_show, IF_RTCD(&cpi->rtcd.variance)); | 
|  | 
| @@ -427,10 +394,7 @@ | 
| 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, 0); | 
| -            cm->last_frame_type = cm->frame_type; | 
| -            cm->last_filter_type = cm->filter_type; | 
| -            cm->last_sharpness_level = cm->sharpness_level; | 
| +            vp8_loop_filter_frame_yonly(cm, &cpi->mb.e_mbd, filt_high); | 
|  | 
| filt_err = vp8_calc_ss_err(sd, cm->frame_to_show, IF_RTCD(&cpi->rtcd.variance)); | 
|  | 
| @@ -474,8 +438,4 @@ | 
| } | 
|  | 
| 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; | 
| } | 
|  |