From 6c9fb22e13be7996e784038d7580444895c89895 Mon Sep 17 00:00:00 2001 From: Yaowu Xu Date: Thu, 10 Jan 2013 10:55:07 -0800 Subject: [PATCH] Reduce the usage of widerlpf The commit changed to not to use wider lpf within a superblock when 32x32 transform is used for the block. The commit also changed to use the shorter version of loop filtering: for UV planes. Change-Id: I344c1fb9a3be9d1200782a788bcb0b001fedcff8 --- vp9/common/vp9_loopfilter.c | 36 ++++++++++++++++++++--------- vp9/common/vp9_loopfilter_filters.c | 8 +++---- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/vp9/common/vp9_loopfilter.c b/vp9/common/vp9_loopfilter.c index 0badd276c..a7973bea6 100644 --- a/vp9/common/vp9_loopfilter.c +++ b/vp9/common/vp9_loopfilter.c @@ -176,19 +176,31 @@ void vp9_loop_filter_frame_init(VP9_COMMON *cm, } } +// Determine if we should skip inner-MB loop filtering within a MB +// The current condition is that the loop filtering is skipped only +// the MB uses a prediction size of 16x16 and either 16x16 transform +// is used or there is no residue at all. static int mb_lf_skip(const MB_MODE_INFO *const mbmi) { const MB_PREDICTION_MODE mode = mbmi->mode; const int skip_coef = mbmi->mb_skip_coeff; const int tx_size = mbmi->txfm_size; return mode != B_PRED && mode != I8X8_PRED && mode != SPLITMV && - tx_size >= TX_16X16 && skip_coef; + (tx_size >= TX_16X16 || skip_coef); } + +// Determine if we should skip MB loop filtering on a MB edge within +// a superblock, the current condition is that MB loop filtering is +// skipped only when both MBs do not use inner MB loop filtering, and +// same motion vector with same reference frame static int sb_mb_lf_skip(const MODE_INFO *const mip0, const MODE_INFO *const mip1) { - return mb_lf_skip(&mip0->mbmi) && - mb_lf_skip(&mip1->mbmi) && - mip0->mbmi.txfm_size >= TX_32X32 && - mip0->mbmi.ref_frame; + const MB_MODE_INFO *mbmi0 = &mip0->mbmi; + const MB_MODE_INFO *mbmi1 = &mip0->mbmi; + return mb_lf_skip(mbmi0) && mb_lf_skip(mbmi1) && + (mbmi0->ref_frame == mbmi1->ref_frame) && + (mbmi0->mv[mbmi0->ref_frame].as_int == + mbmi1->mv[mbmi1->ref_frame].as_int) && + mbmi0->ref_frame != INTRA_FRAME; } void vp9_loop_filter_frame(VP9_COMMON *cm, MACROBLOCKD *xd, @@ -235,9 +247,10 @@ void vp9_loop_filter_frame(VP9_COMMON *cm, lfi.lim = lfi_n->lim[filter_level]; lfi.hev_thr = lfi_n->hev_thr[hev_index]; - if (mb_col > 0 - && !((mb_col & 1) && mode_info_context->mbmi.sb_type && - sb_mb_lf_skip(mode_info_context - 1, mode_info_context)) + if (mb_col > 0 && + !((mb_col & 1) && mode_info_context->mbmi.sb_type && + (sb_mb_lf_skip(mode_info_context - 1, mode_info_context) || + tx_size >= TX_32X32)) ) { #if CONFIG_WIDERLPF if (tx_size >= TX_16X16) @@ -258,9 +271,10 @@ void vp9_loop_filter_frame(VP9_COMMON *cm, } /* don't apply across umv border */ - if (mb_row > 0 - && !((mb_row & 1) && mode_info_context->mbmi.sb_type && - sb_mb_lf_skip(mode_info_context - mis, mode_info_context)) + if (mb_row > 0 && + !((mb_row & 1) && mode_info_context->mbmi.sb_type && + (sb_mb_lf_skip(mode_info_context - mis, mode_info_context) || + tx_size >= TX_32X32)) ) { #if CONFIG_WIDERLPF if (tx_size >= TX_16X16) diff --git a/vp9/common/vp9_loopfilter_filters.c b/vp9/common/vp9_loopfilter_filters.c index c73e37ba3..18438270f 100644 --- a/vp9/common/vp9_loopfilter_filters.c +++ b/vp9/common/vp9_loopfilter_filters.c @@ -682,11 +682,11 @@ void vp9_lpf_mbv_w(unsigned char *y_ptr, unsigned char *u_ptr, lfi->mblim, lfi->lim, lfi->hev_thr, 2); if (u_ptr) - vp9_mb_lpf_vertical_edge_w(u_ptr, uv_stride, + vp9_mbloop_filter_vertical_edge_c(u_ptr, uv_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 1); if (v_ptr) - vp9_mb_lpf_vertical_edge_w(v_ptr, uv_stride, + vp9_mbloop_filter_vertical_edge_c(v_ptr, uv_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 1); } void vp9_lpf_mbh_w(unsigned char *y_ptr, unsigned char *u_ptr, @@ -696,11 +696,11 @@ void vp9_lpf_mbh_w(unsigned char *y_ptr, unsigned char *u_ptr, lfi->mblim, lfi->lim, lfi->hev_thr, 2); if (u_ptr) - vp9_mb_lpf_horizontal_edge_w(u_ptr, uv_stride, + vp9_mbloop_filter_horizontal_edge_c(u_ptr, uv_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 1); if (v_ptr) - vp9_mb_lpf_horizontal_edge_w(v_ptr, uv_stride, + vp9_mbloop_filter_horizontal_edge_c(v_ptr, uv_stride, lfi->mblim, lfi->lim, lfi->hev_thr, 1); } -- 2.40.0