OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2010 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 } | 207 } |
208 } | 208 } |
209 | 209 |
210 static int q2mbl(int x) | 210 static int q2mbl(int x) |
211 { | 211 { |
212 if (x < 20) x = 20; | 212 if (x < 20) x = 20; |
213 | 213 |
214 x = 50 + (x - 50) * 10 / 8; | 214 x = 50 + (x - 50) * 10 / 8; |
215 return x * x / 3; | 215 return x * x / 3; |
216 } | 216 } |
| 217 |
217 void vp8_mbpost_proc_across_ip_c(unsigned char *src, int pitch, int rows, int co
ls, int flimit) | 218 void vp8_mbpost_proc_across_ip_c(unsigned char *src, int pitch, int rows, int co
ls, int flimit) |
218 { | 219 { |
219 int r, c, i; | 220 int r, c, i; |
220 | 221 |
221 unsigned char *s = src; | 222 unsigned char *s = src; |
222 unsigned char d[16]; | 223 unsigned char d[16]; |
223 | 224 |
224 for (r = 0; r < rows; r++) | 225 for (r = 0; r < rows; r++) |
225 { | 226 { |
226 int sumsq = 0; | 227 int sumsq = 0; |
227 int sum = 0; | 228 int sum = 0; |
228 | 229 |
229 for (i = -8; i<0; i++) | 230 for (i = -8; i < 0; i++) |
230 s[i]=s[0]; | 231 s[i]=s[0]; |
231 | 232 |
232 /* 17 avoids valgrind warning - we buffer values in c in d | 233 /* 17 avoids valgrind warning - we buffer values in c in d |
233 * and only write them when we've read 8 ahead... | 234 * and only write them when we've read 8 ahead... |
234 */ | 235 */ |
235 for (i = cols; i<cols+17; i++) | 236 for (i = 0; i < 17; i++) |
236 s[i]=s[cols-1]; | 237 s[i+cols]=s[cols-1]; |
237 | 238 |
238 for (i = -8; i <= 6; i++) | 239 for (i = -8; i <= 6; i++) |
239 { | 240 { |
240 sumsq += s[i] * s[i]; | 241 sumsq += s[i] * s[i]; |
241 sum += s[i]; | 242 sum += s[i]; |
242 d[i+8] = 0; | 243 d[i+8] = 0; |
243 } | 244 } |
244 | 245 |
245 for (c = 0; c < cols + 8; c++) | 246 for (c = 0; c < cols + 8; c++) |
246 { | 247 { |
(...skipping 10 matching lines...) Expand all Loading... |
257 d[c&15] = (8 + sum + s[c]) >> 4; | 258 d[c&15] = (8 + sum + s[c]) >> 4; |
258 } | 259 } |
259 | 260 |
260 s[c-8] = d[(c-8)&15]; | 261 s[c-8] = d[(c-8)&15]; |
261 } | 262 } |
262 | 263 |
263 s += pitch; | 264 s += pitch; |
264 } | 265 } |
265 } | 266 } |
266 | 267 |
267 | |
268 void vp8_mbpost_proc_down_c(unsigned char *dst, int pitch, int rows, int cols, i
nt flimit) | 268 void vp8_mbpost_proc_down_c(unsigned char *dst, int pitch, int rows, int cols, i
nt flimit) |
269 { | 269 { |
270 int r, c, i; | 270 int r, c, i; |
271 const short *rv3 = &vp8_rv[63&rand()]; | 271 const short *rv3 = &vp8_rv[63&rand()]; |
272 | 272 |
273 for (c = 0; c < cols; c++ ) | 273 for (c = 0; c < cols; c++ ) |
274 { | 274 { |
275 unsigned char *s = &dst[c]; | 275 unsigned char *s = &dst[c]; |
276 int sumsq = 0; | 276 int sumsq = 0; |
277 int sum = 0; | 277 int sum = 0; |
278 unsigned char d[16]; | 278 unsigned char d[16]; |
279 const short *rv2 = rv3 + ((c * 17) & 127); | 279 const short *rv2 = rv3 + ((c * 17) & 127); |
280 | 280 |
281 for (i = -8; i < 0; i++) | 281 for (i = -8; i < 0; i++) |
282 s[i*pitch]=s[0]; | 282 s[i*pitch]=s[0]; |
283 | 283 |
284 /* 17 avoids valgrind warning - we buffer values in c in d | 284 /* 17 avoids valgrind warning - we buffer values in c in d |
285 * and only write them when we've read 8 ahead... | 285 * and only write them when we've read 8 ahead... |
286 */ | 286 */ |
287 for (i = rows; i < rows+17; i++) | 287 for (i = 0; i < 17; i++) |
288 s[i*pitch]=s[(rows-1)*pitch]; | 288 s[(i+rows)*pitch]=s[(rows-1)*pitch]; |
289 | 289 |
290 for (i = -8; i <= 6; i++) | 290 for (i = -8; i <= 6; i++) |
291 { | 291 { |
292 sumsq += s[i*pitch] * s[i*pitch]; | 292 sumsq += s[i*pitch] * s[i*pitch]; |
293 sum += s[i*pitch]; | 293 sum += s[i*pitch]; |
294 } | 294 } |
295 | 295 |
296 for (r = 0; r < rows + 8; r++) | 296 for (r = 0; r < rows + 8; r++) |
297 { | 297 { |
298 sumsq += s[7*pitch] * s[ 7*pitch] - s[-8*pitch] * s[-8*pitch]; | 298 sumsq += s[7*pitch] * s[ 7*pitch] - s[-8*pitch] * s[-8*pitch]; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 post->v_buffer + 8 * mbr * post->uv_stride, source->uv_stride, | 378 post->v_buffer + 8 * mbr * post->uv_stride, source->uv_stride, |
379 post->uv_stride, source->uv_width, uvlimits, 8); | 379 post->uv_stride, source->uv_width, uvlimits, 8); |
380 } | 380 } |
381 } else | 381 } else |
382 { | 382 { |
383 vp8_yv12_copy_frame(source, post); | 383 vp8_yv12_copy_frame(source, post); |
384 } | 384 } |
385 } | 385 } |
386 #endif | 386 #endif |
387 | 387 |
388 #if !(CONFIG_TEMPORAL_DENOISING) | |
389 void vp8_de_noise(VP8_COMMON *cm, | 388 void vp8_de_noise(VP8_COMMON *cm, |
390 YV12_BUFFER_CONFIG *source, | 389 YV12_BUFFER_CONFIG *source, |
391 YV12_BUFFER_CONFIG *post, | 390 YV12_BUFFER_CONFIG *post, |
392 int q, | 391 int q, |
393 int low_var_thresh, | 392 int low_var_thresh, |
394 int flag) | 393 int flag, |
| 394 int uvfilter) |
395 { | 395 { |
396 int mbr; | 396 int mbr; |
397 double level = 6.0e-05 * q * q * q - .0067 * q * q + .306 * q + .0065; | 397 double level = 6.0e-05 * q * q * q - .0067 * q * q + .306 * q + .0065; |
398 int ppl = (int)(level + .5); | 398 int ppl = (int)(level + .5); |
399 int mb_rows = cm->mb_rows; | 399 int mb_rows = cm->mb_rows; |
400 int mb_cols = cm->mb_cols; | 400 int mb_cols = cm->mb_cols; |
401 unsigned char *limits = cm->pp_limits_buffer;; | 401 unsigned char *limits = cm->pp_limits_buffer;; |
402 (void) post; | 402 (void) post; |
403 (void) low_var_thresh; | 403 (void) low_var_thresh; |
404 (void) flag; | 404 (void) flag; |
405 | 405 |
406 vpx_memset(limits, (unsigned char)ppl, 16 * mb_cols); | 406 vpx_memset(limits, (unsigned char)ppl, 16 * mb_cols); |
407 | 407 |
408 /* TODO: The original code don't filter the 2 outer rows and columns. */ | 408 /* TODO: The original code don't filter the 2 outer rows and columns. */ |
409 for (mbr = 0; mbr < mb_rows; mbr++) | 409 for (mbr = 0; mbr < mb_rows; mbr++) |
410 { | 410 { |
411 vp8_post_proc_down_and_across_mb_row( | 411 vp8_post_proc_down_and_across_mb_row( |
412 source->y_buffer + 16 * mbr * source->y_stride, | 412 source->y_buffer + 16 * mbr * source->y_stride, |
413 source->y_buffer + 16 * mbr * source->y_stride, | 413 source->y_buffer + 16 * mbr * source->y_stride, |
414 source->y_stride, source->y_stride, source->y_width, limits, 16); | 414 source->y_stride, source->y_stride, source->y_width, limits, 16); |
415 | 415 if (uvfilter == 1) { |
416 vp8_post_proc_down_and_across_mb_row( | 416 vp8_post_proc_down_and_across_mb_row( |
417 source->u_buffer + 8 * mbr * source->uv_stride, | 417 source->u_buffer + 8 * mbr * source->uv_stride, |
418 source->u_buffer + 8 * mbr * source->uv_stride, | 418 source->u_buffer + 8 * mbr * source->uv_stride, |
419 source->uv_stride, source->uv_stride, source->uv_width, limits, 8); | 419 source->uv_stride, source->uv_stride, source->uv_width, limits, |
420 vp8_post_proc_down_and_across_mb_row( | 420 8); |
421 source->v_buffer + 8 * mbr * source->uv_stride, | 421 vp8_post_proc_down_and_across_mb_row( |
422 source->v_buffer + 8 * mbr * source->uv_stride, | 422 source->v_buffer + 8 * mbr * source->uv_stride, |
423 source->uv_stride, source->uv_stride, source->uv_width, limits, 8); | 423 source->v_buffer + 8 * mbr * source->uv_stride, |
| 424 source->uv_stride, source->uv_stride, source->uv_width, limits, |
| 425 8); |
| 426 } |
424 } | 427 } |
425 } | 428 } |
426 #endif | |
427 | 429 |
428 double vp8_gaussian(double sigma, double mu, double x) | 430 double vp8_gaussian(double sigma, double mu, double x) |
429 { | 431 { |
430 return 1 / (sigma * sqrt(2.0 * 3.14159265)) * | 432 return 1 / (sigma * sqrt(2.0 * 3.14159265)) * |
431 (exp(-(x - mu) * (x - mu) / (2 * sigma * sigma))); | 433 (exp(-(x - mu) * (x - mu) / (2 * sigma * sigma))); |
432 } | 434 } |
433 | 435 |
434 static void fillrd(struct postproc_state *state, int q, int a) | 436 static void fillrd(struct postproc_state *state, int q, int a) |
435 { | 437 { |
436 char char_dist[300]; | 438 char char_dist[300]; |
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1194 | 1196 |
1195 *dest = oci->post_proc_buffer; | 1197 *dest = oci->post_proc_buffer; |
1196 | 1198 |
1197 /* handle problem with extending borders */ | 1199 /* handle problem with extending borders */ |
1198 dest->y_width = oci->Width; | 1200 dest->y_width = oci->Width; |
1199 dest->y_height = oci->Height; | 1201 dest->y_height = oci->Height; |
1200 dest->uv_height = dest->y_height / 2; | 1202 dest->uv_height = dest->y_height / 2; |
1201 return 0; | 1203 return 0; |
1202 } | 1204 } |
1203 #endif | 1205 #endif |
OLD | NEW |