| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebM project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include "vp8/encoder/denoising.h" | 11 #include "vp8/encoder/denoising.h" |
| 12 #include "vp8/common/reconinter.h" | 12 #include "vp8/common/reconinter.h" |
| 13 #include "vpx/vpx_integer.h" | 13 #include "vpx/vpx_integer.h" |
| 14 #include "vpx_mem/vpx_mem.h" | 14 #include "vpx_mem/vpx_mem.h" |
| 15 #include "vp8_rtcd.h" | 15 #include "vp8_rtcd.h" |
| 16 | 16 |
| 17 #include <emmintrin.h> | 17 #include <emmintrin.h> |
| 18 #include "vpx_ports/emmintrin_compat.h" | 18 #include "vpx_ports/emmintrin_compat.h" |
| 19 | 19 |
| 20 union sum_union { | 20 union sum_union { |
| 21 __m128i v; | 21 __m128i v; |
| 22 signed char e[16]; | 22 signed char e[16]; |
| 23 }; | 23 }; |
| 24 | 24 |
| 25 int vp8_denoiser_filter_sse2(unsigned char *mc_running_avg_y, | 25 int vp8_denoiser_filter_sse2(unsigned char *mc_running_avg_y, |
| 26 int mc_avg_y_stride, | 26 int mc_avg_y_stride, |
| 27 unsigned char *running_avg_y, int avg_y_stride, | 27 unsigned char *running_avg_y, int avg_y_stride, |
| 28 unsigned char *sig, int sig_stride, | 28 unsigned char *sig, int sig_stride, |
| 29 unsigned int motion_magnitude) | 29 unsigned int motion_magnitude, |
| 30 int increase_denoising) |
| 30 { | 31 { |
| 31 unsigned char *running_avg_y_start = running_avg_y; | 32 unsigned char *running_avg_y_start = running_avg_y; |
| 32 unsigned char *sig_start = sig; | 33 unsigned char *sig_start = sig; |
| 34 int sum_diff_thresh; |
| 33 int r; | 35 int r; |
| 36 int shift_inc = (increase_denoising && |
| 37 motion_magnitude <= MOTION_MAGNITUDE_THRESHOLD) ? 1 : 0; |
| 34 __m128i acc_diff = _mm_setzero_si128(); | 38 __m128i acc_diff = _mm_setzero_si128(); |
| 35 const __m128i k_0 = _mm_setzero_si128(); | 39 const __m128i k_0 = _mm_setzero_si128(); |
| 36 const __m128i k_4 = _mm_set1_epi8(4); | 40 const __m128i k_4 = _mm_set1_epi8(4 + shift_inc); |
| 37 const __m128i k_8 = _mm_set1_epi8(8); | 41 const __m128i k_8 = _mm_set1_epi8(8); |
| 38 const __m128i k_16 = _mm_set1_epi8(16); | 42 const __m128i k_16 = _mm_set1_epi8(16); |
| 39 /* Modify each level's adjustment according to motion_magnitude. */ | 43 /* Modify each level's adjustment according to motion_magnitude. */ |
| 40 const __m128i l3 = _mm_set1_epi8( | 44 const __m128i l3 = _mm_set1_epi8( |
| 41 (motion_magnitude <= MOTION_MAGNITUDE_THRESHOLD) ? 7 : 6); | 45 (motion_magnitude <= MOTION_MAGNITUDE_THRESHOLD) ? |
| 46 7 + shift_inc : 6); |
| 42 /* Difference between level 3 and level 2 is 2. */ | 47 /* Difference between level 3 and level 2 is 2. */ |
| 43 const __m128i l32 = _mm_set1_epi8(2); | 48 const __m128i l32 = _mm_set1_epi8(2); |
| 44 /* Difference between level 2 and level 1 is 1. */ | 49 /* Difference between level 2 and level 1 is 1. */ |
| 45 const __m128i l21 = _mm_set1_epi8(1); | 50 const __m128i l21 = _mm_set1_epi8(1); |
| 46 | 51 |
| 47 for (r = 0; r < 16; ++r) | 52 for (r = 0; r < 16; ++r) |
| 48 { | 53 { |
| 49 /* Calculate differences */ | 54 /* Calculate differences */ |
| 50 const __m128i v_sig = _mm_loadu_si128((__m128i *)(&sig[0])); | 55 const __m128i v_sig = _mm_loadu_si128((__m128i *)(&sig[0])); |
| 51 const __m128i v_mc_running_avg_y = _mm_loadu_si128( | 56 const __m128i v_mc_running_avg_y = _mm_loadu_si128( |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 | 103 |
| 99 { | 104 { |
| 100 /* Compute the sum of all pixel differences of this MB. */ | 105 /* Compute the sum of all pixel differences of this MB. */ |
| 101 union sum_union s; | 106 union sum_union s; |
| 102 int sum_diff = 0; | 107 int sum_diff = 0; |
| 103 s.v = acc_diff; | 108 s.v = acc_diff; |
| 104 sum_diff = s.e[0] + s.e[1] + s.e[2] + s.e[3] + s.e[4] + s.e[5] | 109 sum_diff = s.e[0] + s.e[1] + s.e[2] + s.e[3] + s.e[4] + s.e[5] |
| 105 + s.e[6] + s.e[7] + s.e[8] + s.e[9] + s.e[10] + s.e[11] | 110 + s.e[6] + s.e[7] + s.e[8] + s.e[9] + s.e[10] + s.e[11] |
| 106 + s.e[12] + s.e[13] + s.e[14] + s.e[15]; | 111 + s.e[12] + s.e[13] + s.e[14] + s.e[15]; |
| 107 | 112 |
| 108 if (abs(sum_diff) > SUM_DIFF_THRESHOLD) | 113 sum_diff_thresh = SUM_DIFF_THRESHOLD; |
| 114 if (increase_denoising) sum_diff_thresh = SUM_DIFF_THRESHOLD_HIGH; |
| 115 if (abs(sum_diff) > sum_diff_thresh) |
| 109 { | 116 { |
| 110 return COPY_BLOCK; | 117 return COPY_BLOCK; |
| 111 } | 118 } |
| 112 } | 119 } |
| 113 | 120 |
| 114 vp8_copy_mem16x16(running_avg_y_start, avg_y_stride, sig_start, sig_stride); | 121 vp8_copy_mem16x16(running_avg_y_start, avg_y_stride, sig_start, sig_stride); |
| 115 return FILTER_BLOCK; | 122 return FILTER_BLOCK; |
| 116 } | 123 } |
| OLD | NEW |