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

Side by Side Diff: source/libvpx/vp8/encoder/denoising.c

Issue 290653003: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 6 years, 7 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
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 * diff adjustment w/o motion correction adjustment w/ motion correction 44 * diff adjustment w/o motion correction adjustment w/ motion correction
45 * [-255, -16] -6 -7 45 * [-255, -16] -6 -7
46 * [-15, -8] -4 -5 46 * [-15, -8] -4 -5
47 * [-7, -4] -3 -4 47 * [-7, -4] -3 -4
48 * [-3, 3] diff diff 48 * [-3, 3] diff diff
49 * [4, 7] 3 4 49 * [4, 7] 3 4
50 * [8, 15] 4 5 50 * [8, 15] 4 5
51 * [16, 255] 6 7 51 * [16, 255] 6 7
52 */ 52 */
53 53
54 int vp8_denoiser_filter_c(YV12_BUFFER_CONFIG *mc_running_avg, 54 int vp8_denoiser_filter_c(unsigned char *mc_running_avg_y, int mc_avg_y_stride,
55 YV12_BUFFER_CONFIG *running_avg, MACROBLOCK *signal, 55 unsigned char *running_avg_y, int avg_y_stride,
56 unsigned int motion_magnitude, int y_offset, 56 unsigned char *sig, int sig_stride,
57 int uv_offset) 57 unsigned int motion_magnitude)
58 { 58 {
59 unsigned char *sig = signal->thismb; 59 unsigned char *running_avg_y_start = running_avg_y;
60 int sig_stride = 16; 60 unsigned char *sig_start = sig;
61 unsigned char *mc_running_avg_y = mc_running_avg->y_buffer + y_offset;
62 int mc_avg_y_stride = mc_running_avg->y_stride;
63 unsigned char *running_avg_y = running_avg->y_buffer + y_offset;
64 int avg_y_stride = running_avg->y_stride;
65 int r, c, i; 61 int r, c, i;
66 int sum_diff = 0; 62 int sum_diff = 0;
67 int adj_val[3] = {3, 4, 6}; 63 int adj_val[3] = {3, 4, 6};
68 64
69 /* If motion_magnitude is small, making the denoiser more aggressive by 65 /* If motion_magnitude is small, making the denoiser more aggressive by
70 * increasing the adjustment for each level. */ 66 * increasing the adjustment for each level. */
71 if (motion_magnitude <= MOTION_MAGNITUDE_THRESHOLD) 67 if (motion_magnitude <= MOTION_MAGNITUDE_THRESHOLD)
72 { 68 {
73 for (i = 0; i < 3; i++) 69 for (i = 0; i < 3; i++)
74 adj_val[i] += 1; 70 adj_val[i] += 1;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 119
124 /* Update pointers for next iteration. */ 120 /* Update pointers for next iteration. */
125 sig += sig_stride; 121 sig += sig_stride;
126 mc_running_avg_y += mc_avg_y_stride; 122 mc_running_avg_y += mc_avg_y_stride;
127 running_avg_y += avg_y_stride; 123 running_avg_y += avg_y_stride;
128 } 124 }
129 125
130 if (abs(sum_diff) > SUM_DIFF_THRESHOLD) 126 if (abs(sum_diff) > SUM_DIFF_THRESHOLD)
131 return COPY_BLOCK; 127 return COPY_BLOCK;
132 128
133 vp8_copy_mem16x16(running_avg->y_buffer + y_offset, avg_y_stride, 129 vp8_copy_mem16x16(running_avg_y_start, avg_y_stride, sig_start, sig_stride);
134 signal->thismb, sig_stride);
135 return FILTER_BLOCK; 130 return FILTER_BLOCK;
136 } 131 }
137 132
138 int vp8_denoiser_allocate(VP8_DENOISER *denoiser, int width, int height) 133 int vp8_denoiser_allocate(VP8_DENOISER *denoiser, int width, int height)
139 { 134 {
140 int i; 135 int i;
141 assert(denoiser); 136 assert(denoiser);
142 137
143 for (i = 0; i < MAX_REF_FRAMES; i++) 138 for (i = 0; i < MAX_REF_FRAMES; i++)
144 { 139 {
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 mv_col = x->best_sse_mv.as_mv.col; 273 mv_col = x->best_sse_mv.as_mv.col;
279 motion_magnitude2 = mv_row * mv_row + mv_col * mv_col; 274 motion_magnitude2 = mv_row * mv_row + mv_col * mv_col;
280 if (best_sse > SSE_THRESHOLD || motion_magnitude2 275 if (best_sse > SSE_THRESHOLD || motion_magnitude2
281 > 8 * NOISE_MOTION_THRESHOLD) 276 > 8 * NOISE_MOTION_THRESHOLD)
282 { 277 {
283 decision = COPY_BLOCK; 278 decision = COPY_BLOCK;
284 } 279 }
285 280
286 if (decision == FILTER_BLOCK) 281 if (decision == FILTER_BLOCK)
287 { 282 {
283 unsigned char *mc_running_avg_y =
284 denoiser->yv12_mc_running_avg.y_buffer + recon_yoffset;
285 int mc_avg_y_stride = denoiser->yv12_mc_running_avg.y_stride;
286 unsigned char *running_avg_y =
287 denoiser->yv12_running_avg[INTRA_FRAME].y_buffer + recon_yoffset;
288 int avg_y_stride = denoiser->yv12_running_avg[INTRA_FRAME].y_stride;
289
288 /* Filter. */ 290 /* Filter. */
289 decision = vp8_denoiser_filter(&denoiser->yv12_mc_running_avg, 291 decision = vp8_denoiser_filter(mc_running_avg_y, mc_avg_y_stride,
290 &denoiser->yv12_running_avg[INTRA_FRAME], 292 running_avg_y, avg_y_stride,
291 x, 293 x->thismb, 16, motion_magnitude2);
292 motion_magnitude2,
293 recon_yoffset, recon_uvoffset);
294 } 294 }
295 if (decision == COPY_BLOCK) 295 if (decision == COPY_BLOCK)
296 { 296 {
297 /* No filtering of this block; it differs too much from the predictor, 297 /* No filtering of this block; it differs too much from the predictor,
298 * or the motion vector magnitude is considered too big. 298 * or the motion vector magnitude is considered too big.
299 */ 299 */
300 vp8_copy_mem16x16( 300 vp8_copy_mem16x16(
301 x->thismb, 16, 301 x->thismb, 16,
302 denoiser->yv12_running_avg[INTRA_FRAME].y_buffer + recon_yoffset , 302 denoiser->yv12_running_avg[INTRA_FRAME].y_buffer + recon_yoffset ,
303 denoiser->yv12_running_avg[INTRA_FRAME].y_stride); 303 denoiser->yv12_running_avg[INTRA_FRAME].y_stride);
304 } 304 }
305 } 305 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698