From: hui su Date: Wed, 3 Feb 2016 19:32:25 +0000 (-0800) Subject: Add a speed feature for intra filter search X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5b618b7caefc1d5e07c9699989944d9cfd509421;p=libvpx Add a speed feature for intra filter search Seperate the prediction angle search and fitler search. It can reduce the computation overhead of filter search by as much as 85%, while keeping more than 50% of the coding gain. Change-Id: Id152f71e20ebcaca8b429bdd4ca1fbeb646fc6bf --- diff --git a/vp10/common/blockd.h b/vp10/common/blockd.h index 24e43ab33..af62fb05e 100644 --- a/vp10/common/blockd.h +++ b/vp10/common/blockd.h @@ -398,6 +398,7 @@ static const int ext_tx_used_inter[EXT_TX_SETS_INTER][TX_TYPES] = { #define MAX_ANGLE_DELTAS 3 #define ANGLE_FAST_SEARCH 1 #define ANGLE_SKIP_THRESH 0.10 +#define FILTER_FAST_SEARCH 1 static uint8_t mode_to_angle_map[INTRA_MODES] = { 0, 90, 180, 45, 135, 111, 157, 203, 67, 0, diff --git a/vp10/encoder/rdopt.c b/vp10/encoder/rdopt.c index 58d72d402..19f6598be 100644 --- a/vp10/encoder/rdopt.c +++ b/vp10/encoder/rdopt.c @@ -1837,7 +1837,8 @@ static int64_t rd_pick_intra_angle_sby(VP10_COMP *cpi, MACROBLOCK *x, p_angle = mode_to_angle_map[mbmi->mode] + mbmi->angle_delta[0] * ANGLE_STEP; for (filter = INTRA_FILTER_LINEAR; filter < INTRA_FILTERS; ++filter) { - if (!pick_intra_filter(p_angle) && filter != INTRA_FILTER_LINEAR) + if ((FILTER_FAST_SEARCH || !pick_intra_filter(p_angle)) && + filter != INTRA_FILTER_LINEAR) continue; mic->mbmi.intra_filter = filter; super_block_yrd(cpi, x, &this_rate_tokenonly, &this_distortion, @@ -1878,7 +1879,8 @@ static int64_t rd_pick_intra_angle_sby(VP10_COMP *cpi, MACROBLOCK *x, mbmi->angle_delta[0] * ANGLE_STEP; for (filter = INTRA_FILTER_LINEAR; filter < INTRA_FILTERS; ++filter) { mic->mbmi.intra_filter = filter; - if (!pick_intra_filter(p_angle) && filter != INTRA_FILTER_LINEAR) + if ((FILTER_FAST_SEARCH || !pick_intra_filter(p_angle)) && + filter != INTRA_FILTER_LINEAR) continue; super_block_yrd(cpi, x, &this_rate_tokenonly, &this_distortion, &s, NULL, bsize, best_rd); @@ -1909,7 +1911,8 @@ static int64_t rd_pick_intra_angle_sby(VP10_COMP *cpi, MACROBLOCK *x, mbmi->angle_delta[0] * ANGLE_STEP; for (filter = INTRA_FILTER_LINEAR; filter < INTRA_FILTERS; ++filter) { mic->mbmi.intra_filter = filter; - if (!pick_intra_filter(p_angle) && filter != INTRA_FILTER_LINEAR) + if ((FILTER_FAST_SEARCH || !pick_intra_filter(p_angle)) && + filter != INTRA_FILTER_LINEAR) continue; super_block_yrd(cpi, x, &this_rate_tokenonly, &this_distortion, &s, NULL, bsize, best_rd); @@ -1935,6 +1938,37 @@ static int64_t rd_pick_intra_angle_sby(VP10_COMP *cpi, MACROBLOCK *x, } } + if (FILTER_FAST_SEARCH && *rate_tokenonly < INT_MAX) { + mbmi->angle_delta[0] = best_angle_delta; + p_angle = mode_to_angle_map[mbmi->mode] + + mbmi->angle_delta[0] * ANGLE_STEP; + if (pick_intra_filter(p_angle)) { + for (filter = INTRA_FILTER_LINEAR + 1; filter < INTRA_FILTERS; ++filter) { + mic->mbmi.intra_filter = filter; + super_block_yrd(cpi, x, &this_rate_tokenonly, &this_distortion, + &s, NULL, bsize, best_rd); + if (this_rate_tokenonly == INT_MAX) + continue; + + this_rate = this_rate_tokenonly + rate_overhead + + cpi->intra_filter_cost[intra_filter_ctx][filter]; + this_rd = RDCOST(x->rdmult, x->rddiv, this_rate, this_distortion); + + if (this_rd < best_rd) { + best_rd = this_rd; + best_angle_delta = mbmi->angle_delta[0]; + best_tx_size = mbmi->tx_size; + best_filter = mbmi->intra_filter; + best_tx_type = mbmi->tx_type; + *rate = this_rate; + *rate_tokenonly = this_rate_tokenonly; + *distortion = this_distortion; + *skippable = s; + } + } + } + } + mbmi->tx_size = best_tx_size; mbmi->angle_delta[0] = best_angle_delta; mic->mbmi.intra_filter = best_filter;