Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1045)

Side by Side Diff: source/libvpx/vp8/encoder/x86/denoising_sse2.c

Issue 341293003: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « source/libvpx/vp8/encoder/rdopt.c ('k') | source/libvpx/vp8/encoder/x86/quantize_sse2.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 /* Compute the sum of all pixel differences of this MB. */ 105 /* Compute the sum of all pixel differences of this MB. */
106 union sum_union s; 106 union sum_union s;
107 int sum_diff = 0; 107 int sum_diff = 0;
108 s.v = acc_diff; 108 s.v = acc_diff;
109 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]
110 + 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]
111 + 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];
112 112
113 sum_diff_thresh = SUM_DIFF_THRESHOLD; 113 sum_diff_thresh = SUM_DIFF_THRESHOLD;
114 if (increase_denoising) sum_diff_thresh = SUM_DIFF_THRESHOLD_HIGH; 114 if (increase_denoising) sum_diff_thresh = SUM_DIFF_THRESHOLD_HIGH;
115 if (abs(sum_diff) > sum_diff_thresh) 115 if (abs(sum_diff) > sum_diff_thresh) {
116 { 116 // Before returning to copy the block (i.e., apply no denoising),
117 // checK if we can still apply some (weaker) temporal filtering to
118 // this block, that would otherwise not be denoised at all. Simplest
119 // is to apply an additional adjustment to running_avg_y to bring it
120 // closer to sig. The adjustment is capped by a maximum delta, and
121 // chosen such that in most cases the resulting sum_diff will be
122 // within the accceptable range given by sum_diff_thresh.
123
124 // The delta is set by the excess of absolute pixel diff over the
125 // threshold.
126 int delta = ((abs(sum_diff) - sum_diff_thresh) >> 8) + 1;
127 // Only apply the adjustment for max delta up to 3.
128 if (delta < 4) {
129 const __m128i k_delta = _mm_set1_epi8(delta);
130 sig -= sig_stride * 16;
131 mc_running_avg_y -= mc_avg_y_stride * 16;
132 running_avg_y -= avg_y_stride * 16;
133 for (r = 0; r < 16; ++r) {
134 __m128i v_running_avg_y =
135 _mm_loadu_si128((__m128i *)(&running_avg_y[0]));
136 // Calculate differences.
137 const __m128i v_sig = _mm_loadu_si128((__m128i *)(&sig[0]));
138 const __m128i v_mc_running_avg_y =
139 _mm_loadu_si128((__m128i *)(&mc_running_avg_y[0]));
140 const __m128i pdiff = _mm_subs_epu8(v_mc_running_avg_y, v_sig);
141 const __m128i ndiff = _mm_subs_epu8(v_sig, v_mc_running_avg_y);
142 // Obtain the sign. FF if diff is negative.
143 const __m128i diff_sign = _mm_cmpeq_epi8(pdiff, k_0);
144 // Clamp absolute difference to delta to get the adjustment.
145 const __m128i adj =
146 _mm_min_epu8(_mm_or_si128(pdiff, ndiff), k_delta);
147 // Restore the sign and get positive and negative adjustments.
148 __m128i padj, nadj;
149 padj = _mm_andnot_si128(diff_sign, adj);
150 nadj = _mm_and_si128(diff_sign, adj);
151 // Calculate filtered value.
152 v_running_avg_y = _mm_subs_epu8(v_running_avg_y, padj);
153 v_running_avg_y = _mm_adds_epu8(v_running_avg_y, nadj);
154 _mm_storeu_si128((__m128i *)running_avg_y, v_running_avg_y);
155
156 // Accumulate the adjustments.
157 acc_diff = _mm_subs_epi8(acc_diff, padj);
158 acc_diff = _mm_adds_epi8(acc_diff, nadj);
159
160 // Update pointers for next iteration.
161 sig += sig_stride;
162 mc_running_avg_y += mc_avg_y_stride;
163 running_avg_y += avg_y_stride;
164 }
165 {
166 // Update the sum of all pixel differences of this MB.
167 union sum_union s;
168 s.v = acc_diff;
169 sum_diff = s.e[0] + s.e[1] + s.e[2] + s.e[3] + s.e[4] + s.e[5]
170 + s.e[6] + s.e[7] + s.e[8] + s.e[9] + s.e[10] + s.e[11]
171 + s.e[12] + s.e[13] + s.e[14] + s.e[15];
172 if (abs(sum_diff) > sum_diff_thresh) {
173 return COPY_BLOCK;
174 }
175 }
176 } else {
117 return COPY_BLOCK; 177 return COPY_BLOCK;
178 }
118 } 179 }
119 } 180 }
120 181
121 vp8_copy_mem16x16(running_avg_y_start, avg_y_stride, sig_start, sig_stride); 182 vp8_copy_mem16x16(running_avg_y_start, avg_y_stride, sig_start, sig_stride);
122 return FILTER_BLOCK; 183 return FILTER_BLOCK;
123 } 184 }
OLDNEW
« no previous file with comments | « source/libvpx/vp8/encoder/rdopt.c ('k') | source/libvpx/vp8/encoder/x86/quantize_sse2.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698