From: Yaowu Xu Date: Wed, 7 Aug 2013 19:29:45 +0000 (-0700) Subject: Added lpf level picking using partial frame X-Git-Tag: v1.3.0~642 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6ec2b85badc7b5e9e19e9da623b05cbdba197f1b;p=libvpx Added lpf level picking using partial frame Change-Id: I599ab1bd22b5f3f10d5962c609952abdef8ff67a --- diff --git a/vp9/common/vp9_loopfilter.c b/vp9/common/vp9_loopfilter.c index 66df62753..949d74d0d 100644 --- a/vp9/common/vp9_loopfilter.c +++ b/vp9/common/vp9_loopfilter.c @@ -377,11 +377,23 @@ void vp9_loop_filter_rows(const YV12_BUFFER_CONFIG *frame_buffer, } void vp9_loop_filter_frame(VP9_COMMON *cm, MACROBLOCKD *xd, - int frame_filter_level, int y_only) { + int frame_filter_level, + int y_only, int partial) { + int start_mi_row, end_mi_row, mi_rows_to_filter; if (!frame_filter_level) return; + + start_mi_row = 0; + mi_rows_to_filter = cm->mi_rows; + if (partial && cm->mi_rows > 8) { + start_mi_row = cm->mi_rows >> 1; + start_mi_row &= 0xfffffff8; + mi_rows_to_filter = MAX(cm->mi_rows / 8, 8); + } + end_mi_row = start_mi_row + mi_rows_to_filter; vp9_loop_filter_frame_init(cm, xd, frame_filter_level); vp9_loop_filter_rows(cm->frame_to_show, cm, xd, - 0, cm->mi_rows, y_only); + start_mi_row, end_mi_row, + y_only); } int vp9_loop_filter_worker(void *arg1, void *arg2) { diff --git a/vp9/common/vp9_loopfilter.h b/vp9/common/vp9_loopfilter.h index 5fc909495..181afd5cc 100644 --- a/vp9/common/vp9_loopfilter.h +++ b/vp9/common/vp9_loopfilter.h @@ -51,7 +51,7 @@ void vp9_loop_filter_frame_init(struct VP9Common *const cm, void vp9_loop_filter_frame(struct VP9Common *cm, struct macroblockd *mbd, int filter_level, - int y_only); + int y_only, int partial); // Apply the loop filter to [start, stop) macro block rows in frame_buffer. void vp9_loop_filter_rows(const YV12_BUFFER_CONFIG *frame_buffer, diff --git a/vp9/decoder/vp9_onyxd_if.c b/vp9/decoder/vp9_onyxd_if.c index b701fae23..91e26ec3e 100644 --- a/vp9/decoder/vp9_onyxd_if.c +++ b/vp9/decoder/vp9_onyxd_if.c @@ -359,7 +359,7 @@ int vp9_receive_compressed_data(VP9D_PTR ptr, if (!pbi->do_loopfilter_inline) { /* Apply the loop filter if appropriate. */ - vp9_loop_filter_frame(cm, &pbi->mb, pbi->mb.lf.filter_level, 0); + vp9_loop_filter_frame(cm, &pbi->mb, pbi->mb.lf.filter_level, 0, 0); } #if WRITE_RECON_BUFFER == 2 diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c index aff93fb88..494247327 100644 --- a/vp9/encoder/vp9_onyx_if.c +++ b/vp9/encoder/vp9_onyx_if.c @@ -2436,10 +2436,7 @@ static void loopfilter_frame(VP9_COMP *cpi, VP9_COMMON *cm) { vpx_usec_timer_start(&timer); - if (cpi->sf.use_fast_lpf_pick == 0) - vp9_pick_filter_level(cpi->Source, cpi); - else - vp9_pick_filter_level_fast(cpi->Source, cpi); + vp9_pick_filter_level(cpi->Source, cpi, cpi->sf.use_fast_lpf_pick); vpx_usec_timer_mark(&timer); cpi->time_pick_lpf += vpx_usec_timer_elapsed(&timer); @@ -2447,7 +2444,7 @@ static void loopfilter_frame(VP9_COMP *cpi, VP9_COMMON *cm) { if (lf->filter_level > 0) { vp9_set_alt_lf_level(cpi, lf->filter_level); - vp9_loop_filter_frame(cm, xd, lf->filter_level, 0); + vp9_loop_filter_frame(cm, xd, lf->filter_level, 0, 0); } vp9_extend_frame_inner_borders(cm->frame_to_show, diff --git a/vp9/encoder/vp9_picklpf.c b/vp9/encoder/vp9_picklpf.c index 74abec6bd..b7a626cb3 100644 --- a/vp9/encoder/vp9_picklpf.c +++ b/vp9/encoder/vp9_picklpf.c @@ -125,11 +125,7 @@ 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_fast(YV12_BUFFER_CONFIG *sd, VP9_COMP *cpi) { - struct loopfilter *lf = &cpi->mb.e_mbd.lf; - lf->filter_level = 0; -} -void vp9_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP9_COMP *cpi) { +void vp9_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP9_COMP *cpi, int partial) { VP9_COMMON *cm = &cpi->common; struct loopfilter *lf = &cpi->mb.e_mbd.lf; @@ -169,7 +165,7 @@ void vp9_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP9_COMP *cpi) { // Get baseline error score vp9_set_alt_lf_level(cpi, filt_mid); - vp9_loop_filter_frame(cm, &cpi->mb.e_mbd, filt_mid, 1); + vp9_loop_filter_frame(cm, &cpi->mb.e_mbd, filt_mid, 1, partial); best_err = vp9_calc_ss_err(sd, cm->frame_to_show); filt_best = filt_mid; @@ -194,7 +190,7 @@ void vp9_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP9_COMP *cpi) { if ((filt_direction <= 0) && (filt_low != filt_mid)) { // Get Low filter error score vp9_set_alt_lf_level(cpi, filt_low); - vp9_loop_filter_frame(cm, &cpi->mb.e_mbd, filt_low, 1); + vp9_loop_filter_frame(cm, &cpi->mb.e_mbd, filt_low, 1, partial); filt_err = vp9_calc_ss_err(sd, cm->frame_to_show); @@ -214,7 +210,7 @@ void vp9_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP9_COMP *cpi) { // Now look at filt_high if ((filt_direction >= 0) && (filt_high != filt_mid)) { vp9_set_alt_lf_level(cpi, filt_high); - vp9_loop_filter_frame(cm, &cpi->mb.e_mbd, filt_high, 1); + vp9_loop_filter_frame(cm, &cpi->mb.e_mbd, filt_high, 1, partial); filt_err = vp9_calc_ss_err(sd, cm->frame_to_show); @@ -240,3 +236,4 @@ void vp9_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP9_COMP *cpi) { lf->filter_level = filt_best; } + diff --git a/vp9/encoder/vp9_picklpf.h b/vp9/encoder/vp9_picklpf.h index da393525f..9de4cf849 100644 --- a/vp9/encoder/vp9_picklpf.h +++ b/vp9/encoder/vp9_picklpf.h @@ -18,8 +18,5 @@ 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); - -void vp9_pick_filter_level_fast(struct yv12_buffer_config *sd, - struct VP9_COMP *cpi); + struct VP9_COMP *cpi, int partial); #endif // VP9_ENCODER_VP9_PICKLPF_H_