From 4f3398a26a18719c5a8866aae36a437d22737174 Mon Sep 17 00:00:00 2001 From: Yunqing Wang Date: Fri, 12 Oct 2018 17:21:23 -0700 Subject: [PATCH] Optimize vp9_highbd_temporal_filter_apply_c Following the previous patch: (https://chromium-review.googlesource.com/c/webm/libvpx/+/1277913), this patch modified the highbd version of applying temporal filter in the similar way. Change-Id: I2bb6f1fff6e32bca86f7139a497181d34aa9f3ec --- vp9/encoder/vp9_temporal_filter.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/vp9/encoder/vp9_temporal_filter.c b/vp9/encoder/vp9_temporal_filter.c index b94f30189..f9a1af5f4 100644 --- a/vp9/encoder/vp9_temporal_filter.c +++ b/vp9/encoder/vp9_temporal_filter.c @@ -327,13 +327,23 @@ void vp9_highbd_temporal_filter_apply_c( const uint16_t *frame2 = CONVERT_TO_SHORTPTR(frame2_8); unsigned int i, j, k; int modifier; - int byte = 0; const int rounding = strength > 0 ? 1 << (strength - 1) : 0; + int diff_sse[256] = { 0 }; + int this_idx = 0; + + for (i = 0; i < block_height; i++) { + for (j = 0; j < block_width; j++) { + const int diff = + frame1[i * (int)stride + j] - frame2[i * (int)block_width + j]; + diff_sse[this_idx++] = diff * diff; + } + } + + modifier = 0; for (i = 0, k = 0; i < block_height; i++) { for (j = 0; j < block_width; j++, k++) { - int pixel_value = *frame2; - int diff_sse[9] = { 0 }; + int pixel_value = frame2[i * (int)block_width + j]; int idx, idy, index = 0; for (idy = -1; idy <= 1; ++idy) { @@ -343,22 +353,16 @@ void vp9_highbd_temporal_filter_apply_c( if (row >= 0 && row < (int)block_height && col >= 0 && col < (int)block_width) { - int diff = frame1[byte + idy * (int)stride + idx] - - frame2[idy * (int)block_width + idx]; - diff_sse[index] = diff * diff; + modifier += diff_sse[row * (int)block_width + col]; ++index; } } } assert(index > 0); - modifier = 0; - for (idx = 0; idx < 9; ++idx) modifier += diff_sse[idx]; - modifier *= 3; modifier /= index; - ++frame2; modifier += rounding; modifier >>= strength; @@ -369,11 +373,7 @@ void vp9_highbd_temporal_filter_apply_c( count[k] += modifier; accumulator[k] += modifier * pixel_value; - - byte++; } - - byte += stride - block_width; } } #endif // CONFIG_VP9_HIGHBITDEPTH -- 2.40.0