ref: 29ade0d3cf4f8ad40e686cadbd2e46c245db817e
parent: 0bd84571e45d10abb5bf051fc43ba5aa9e0bd546
parent: 1a53c0c9e192f59786c6f9a2d3d9065d7f2b89d4
author: Jacky Chen <[email protected]>
date: Tue Apr 26 13:43:48 EDT 2016
Merge "vp9: Simplify the logic in denoiser SSE2 code."
--- a/examples/vpx_temporal_svc_encoder.c
+++ b/examples/vpx_temporal_svc_encoder.c
@@ -715,7 +715,7 @@
vpx_codec_control(&codec, VP8E_SET_CPUUSED, speed);
vpx_codec_control(&codec, VP9E_SET_AQ_MODE, 3);
vpx_codec_control(&codec, VP9E_SET_FRAME_PERIODIC_BOOST, 0);
- vpx_codec_control(&codec, VP9E_SET_NOISE_SENSITIVITY, 0);
+ vpx_codec_control(&codec, VP9E_SET_NOISE_SENSITIVITY, kDenoiserOff);
vpx_codec_control(&codec, VP8E_SET_STATIC_THRESHOLD, 1);
vpx_codec_control(&codec, VP9E_SET_TUNE_CONTENT, 0);
vpx_codec_control(&codec, VP9E_SET_TILE_COLUMNS, (cfg.g_threads >> 1));
--- a/test/vp9_denoiser_sse2_test.cc
+++ b/test/vp9_denoiser_sse2_test.cc
@@ -94,8 +94,7 @@
// Test for all block size.
INSTANTIATE_TEST_CASE_P(
SSE2, VP9DenoiserTest,
- ::testing::Values(BLOCK_4X4, BLOCK_4X8, BLOCK_8X4, BLOCK_8X8,
- BLOCK_8X16, BLOCK_16X8, BLOCK_16X16, BLOCK_16X32,
- BLOCK_32X16, BLOCK_32X32, BLOCK_32X64, BLOCK_64X32,
- BLOCK_64X64));
+ ::testing::Values(BLOCK_8X8, BLOCK_8X16, BLOCK_16X8, BLOCK_16X16,
+ BLOCK_16X32, BLOCK_32X16, BLOCK_32X32, BLOCK_32X64,
+ BLOCK_64X32, BLOCK_64X64));
} // namespace
--- a/vp9/encoder/x86/vp9_denoiser_sse2.c
+++ b/vp9/encoder/x86/vp9_denoiser_sse2.c
@@ -125,7 +125,7 @@
return acc_diff;
}
-// Denoiser for 4xM and 8xM blocks.
+// Denoise 8x8 and 8x16 blocks.
static int vp9_denoiser_NxM_sse2_small(
const uint8_t *sig, int sig_stride, const uint8_t *mc_running_avg_y,
int mc_avg_y_stride, uint8_t *running_avg_y, int avg_y_stride,
@@ -147,9 +147,8 @@
const __m128i l32 = _mm_set1_epi8(2);
// Difference between level 2 and level 1 is 1.
const __m128i l21 = _mm_set1_epi8(1);
- const uint8_t shift = (width == 4) ? 2 : 1;
- for (r = 0; r < ((4 << b_height_log2_lookup[bs]) >> shift); ++r) {
+ for (r = 0; r < ((4 << b_height_log2_lookup[bs]) >> 1); ++r) {
memcpy(sig_buffer[r], sig, width);
memcpy(sig_buffer[r] + width, sig + sig_stride, width);
memcpy(mc_running_buffer[r], mc_running_avg_y, width);
@@ -157,18 +156,6 @@
mc_running_avg_y + mc_avg_y_stride, width);
memcpy(running_buffer[r], running_avg_y, width);
memcpy(running_buffer[r] + width, running_avg_y + avg_y_stride, width);
- if (width == 4) {
- memcpy(sig_buffer[r] + width * 2, sig + sig_stride * 2, width);
- memcpy(sig_buffer[r] + width * 3, sig + sig_stride * 3, width);
- memcpy(mc_running_buffer[r] + width * 2,
- mc_running_avg_y + mc_avg_y_stride * 2, width);
- memcpy(mc_running_buffer[r] + width * 3,
- mc_running_avg_y + mc_avg_y_stride * 3, width);
- memcpy(running_buffer[r] + width * 2,
- running_avg_y + avg_y_stride * 2, width);
- memcpy(running_buffer[r] + width * 3,
- running_avg_y + avg_y_stride * 3, width);
- }
acc_diff = vp9_denoiser_16x1_sse2(sig_buffer[r],
mc_running_buffer[r],
running_buffer[r],
@@ -176,16 +163,10 @@
&l3, &l32, &l21, acc_diff);
memcpy(running_avg_y, running_buffer[r], width);
memcpy(running_avg_y + avg_y_stride, running_buffer[r] + width, width);
- if (width == 4) {
- memcpy(running_avg_y + avg_y_stride * 2,
- running_buffer[r] + width * 2, width);
- memcpy(running_avg_y + avg_y_stride * 3,
- running_buffer[r] + width * 3, width);
- }
// Update pointers for next iteration.
- sig += (sig_stride << shift);
- mc_running_avg_y += (mc_avg_y_stride << shift);
- running_avg_y += (avg_y_stride << shift);
+ sig += (sig_stride << 1);
+ mc_running_avg_y += (mc_avg_y_stride << 1);
+ running_avg_y += (avg_y_stride << 1);
}
{
@@ -208,7 +189,7 @@
if (delta < 4) {
const __m128i k_delta = _mm_set1_epi8(delta);
running_avg_y -= avg_y_stride * (4 << b_height_log2_lookup[bs]);
- for (r = 0; r < ((4 << b_height_log2_lookup[bs]) >> shift); ++r) {
+ for (r = 0; r < ((4 << b_height_log2_lookup[bs]) >> 1); ++r) {
acc_diff = vp9_denoiser_adj_16x1_sse2(
sig_buffer[r], mc_running_buffer[r], running_buffer[r],
k_0, k_delta, acc_diff);
@@ -215,14 +196,8 @@
memcpy(running_avg_y, running_buffer[r], width);
memcpy(running_avg_y + avg_y_stride,
running_buffer[r] + width, width);
- if (width == 4) {
- memcpy(running_avg_y + avg_y_stride * 2,
- running_buffer[r] + width * 2, width);
- memcpy(running_avg_y + avg_y_stride * 3,
- running_buffer[r] + width * 3, width);
- }
// Update pointers for next iteration.
- running_avg_y += (avg_y_stride << shift);
+ running_avg_y += (avg_y_stride << 1);
}
sum_diff = sum_diff_16x1(acc_diff);
if (abs(sum_diff) > sum_diff_thresh) {
@@ -236,7 +211,7 @@
return FILTER_BLOCK;
}
-// Denoiser for 16xM, 32xM and 64xM blocks
+// Denoise 16x16, 16x32, 32x16, 32x32, 32x64, 64x32 and 64x64 blocks.
static int vp9_denoiser_NxM_sse2_big(const uint8_t *sig, int sig_stride,
const uint8_t *mc_running_avg_y,
int mc_avg_y_stride,
@@ -349,26 +324,21 @@
int increase_denoising,
BLOCK_SIZE bs,
int motion_magnitude) {
- if (bs == BLOCK_4X4 || bs == BLOCK_4X8) {
- return vp9_denoiser_NxM_sse2_small(sig, sig_stride,
- mc_avg, mc_avg_stride,
- avg, avg_stride,
- increase_denoising,
- bs, motion_magnitude, 4);
- } else if (bs == BLOCK_8X4 || bs == BLOCK_8X8 || bs == BLOCK_8X16) {
- return vp9_denoiser_NxM_sse2_small(sig, sig_stride,
- mc_avg, mc_avg_stride,
- avg, avg_stride,
- increase_denoising,
- bs, motion_magnitude, 8);
- } else if (bs == BLOCK_16X8 || bs == BLOCK_16X16 || bs == BLOCK_16X32 ||
- bs == BLOCK_32X16|| bs == BLOCK_32X32 || bs == BLOCK_32X64 ||
- bs == BLOCK_64X32 || bs == BLOCK_64X64) {
+ // Rank by frequency of the block type to have an early termination.
+ if (bs == BLOCK_16X16 || bs == BLOCK_32X32 || bs == BLOCK_64X64 ||
+ bs == BLOCK_16X32 || bs == BLOCK_16X8 || bs == BLOCK_32X16 ||
+ bs == BLOCK_32X64 || bs == BLOCK_64X32) {
return vp9_denoiser_NxM_sse2_big(sig, sig_stride,
mc_avg, mc_avg_stride,
avg, avg_stride,
increase_denoising,
bs, motion_magnitude);
+ } else if (bs == BLOCK_8X8 || bs == BLOCK_8X16) {
+ return vp9_denoiser_NxM_sse2_small(sig, sig_stride,
+ mc_avg, mc_avg_stride,
+ avg, avg_stride,
+ increase_denoising,
+ bs, motion_magnitude, 8);
} else {
return COPY_BLOCK;
}