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 |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 | 389 |
390 void vp8_denoiser_denoise_mb(VP8_DENOISER *denoiser, | 390 void vp8_denoiser_denoise_mb(VP8_DENOISER *denoiser, |
391 MACROBLOCK *x, | 391 MACROBLOCK *x, |
392 unsigned int best_sse, | 392 unsigned int best_sse, |
393 unsigned int zero_mv_sse, | 393 unsigned int zero_mv_sse, |
394 int recon_yoffset, | 394 int recon_yoffset, |
395 int recon_uvoffset, | 395 int recon_uvoffset, |
396 loop_filter_info_n *lfi_n, | 396 loop_filter_info_n *lfi_n, |
397 int mb_row, | 397 int mb_row, |
398 int mb_col, | 398 int mb_col, |
399 int block_index) | 399 int block_index, |
| 400 int uv_denoise) |
400 { | 401 { |
401 int mv_row; | 402 int mv_row; |
402 int mv_col; | 403 int mv_col; |
403 unsigned int motion_magnitude2; | 404 unsigned int motion_magnitude2; |
404 unsigned int sse_thresh; | 405 unsigned int sse_thresh; |
405 int sse_diff_thresh = 0; | 406 int sse_diff_thresh = 0; |
406 // Denoise the UV channel. | |
407 int apply_color_denoise = 0; | |
408 // Spatial loop filter: only applied selectively based on | 407 // Spatial loop filter: only applied selectively based on |
409 // temporal filter state of block relative to top/left neighbors. | 408 // temporal filter state of block relative to top/left neighbors. |
410 int apply_spatial_loop_filter = 1; | 409 int apply_spatial_loop_filter = 1; |
411 MV_REFERENCE_FRAME frame = x->best_reference_frame; | 410 MV_REFERENCE_FRAME frame = x->best_reference_frame; |
412 MV_REFERENCE_FRAME zero_frame = x->best_zeromv_reference_frame; | 411 MV_REFERENCE_FRAME zero_frame = x->best_zeromv_reference_frame; |
413 | 412 |
414 enum vp8_denoiser_decision decision = FILTER_BLOCK; | 413 enum vp8_denoiser_decision decision = FILTER_BLOCK; |
415 enum vp8_denoiser_decision decision_u = FILTER_BLOCK; | 414 enum vp8_denoiser_decision decision_u = FILTER_BLOCK; |
416 enum vp8_denoiser_decision decision_v = FILTER_BLOCK; | 415 enum vp8_denoiser_decision decision_v = FILTER_BLOCK; |
417 | 416 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 int avg_y_stride = denoiser->yv12_running_avg[INTRA_FRAME].y_stride; | 521 int avg_y_stride = denoiser->yv12_running_avg[INTRA_FRAME].y_stride; |
523 | 522 |
524 /* Filter. */ | 523 /* Filter. */ |
525 decision = vp8_denoiser_filter(mc_running_avg_y, mc_avg_y_stride, | 524 decision = vp8_denoiser_filter(mc_running_avg_y, mc_avg_y_stride, |
526 running_avg_y, avg_y_stride, | 525 running_avg_y, avg_y_stride, |
527 x->thismb, 16, motion_magnitude2, | 526 x->thismb, 16, motion_magnitude2, |
528 x->increase_denoising); | 527 x->increase_denoising); |
529 denoiser->denoise_state[block_index] = motion_magnitude2 > 0 ? | 528 denoiser->denoise_state[block_index] = motion_magnitude2 > 0 ? |
530 kFilterNonZeroMV : kFilterZeroMV; | 529 kFilterNonZeroMV : kFilterZeroMV; |
531 // Only denoise UV for zero motion, and if y channel was denoised. | 530 // Only denoise UV for zero motion, and if y channel was denoised. |
532 if (apply_color_denoise && | 531 if (uv_denoise && |
533 motion_magnitude2 == 0 && | 532 motion_magnitude2 == 0 && |
534 decision == FILTER_BLOCK) { | 533 decision == FILTER_BLOCK) { |
535 unsigned char *mc_running_avg_u = | 534 unsigned char *mc_running_avg_u = |
536 denoiser->yv12_mc_running_avg.u_buffer + recon_uvoffset; | 535 denoiser->yv12_mc_running_avg.u_buffer + recon_uvoffset; |
537 unsigned char *running_avg_u = | 536 unsigned char *running_avg_u = |
538 denoiser->yv12_running_avg[INTRA_FRAME].u_buffer + recon_uvoffset; | 537 denoiser->yv12_running_avg[INTRA_FRAME].u_buffer + recon_uvoffset; |
539 unsigned char *mc_running_avg_v = | 538 unsigned char *mc_running_avg_v = |
540 denoiser->yv12_mc_running_avg.v_buffer + recon_uvoffset; | 539 denoiser->yv12_mc_running_avg.v_buffer + recon_uvoffset; |
541 unsigned char *running_avg_v = | 540 unsigned char *running_avg_v = |
542 denoiser->yv12_running_avg[INTRA_FRAME].v_buffer + recon_uvoffset; | 541 denoiser->yv12_running_avg[INTRA_FRAME].v_buffer + recon_uvoffset; |
(...skipping 16 matching lines...) Expand all Loading... |
559 { | 558 { |
560 /* No filtering of this block; it differs too much from the predictor, | 559 /* No filtering of this block; it differs too much from the predictor, |
561 * or the motion vector magnitude is considered too big. | 560 * or the motion vector magnitude is considered too big. |
562 */ | 561 */ |
563 vp8_copy_mem16x16( | 562 vp8_copy_mem16x16( |
564 x->thismb, 16, | 563 x->thismb, 16, |
565 denoiser->yv12_running_avg[INTRA_FRAME].y_buffer + recon_yoffset
, | 564 denoiser->yv12_running_avg[INTRA_FRAME].y_buffer + recon_yoffset
, |
566 denoiser->yv12_running_avg[INTRA_FRAME].y_stride); | 565 denoiser->yv12_running_avg[INTRA_FRAME].y_stride); |
567 denoiser->denoise_state[block_index] = kNoFilter; | 566 denoiser->denoise_state[block_index] = kNoFilter; |
568 } | 567 } |
569 if (apply_color_denoise) { | 568 if (uv_denoise) { |
570 if (decision_u == COPY_BLOCK) { | 569 if (decision_u == COPY_BLOCK) { |
571 vp8_copy_mem8x8( | 570 vp8_copy_mem8x8( |
572 x->block[16].src + *x->block[16].base_src, x->block[16].src_stride, | 571 x->block[16].src + *x->block[16].base_src, x->block[16].src_stride, |
573 denoiser->yv12_running_avg[INTRA_FRAME].u_buffer + recon_uvoffset, | 572 denoiser->yv12_running_avg[INTRA_FRAME].u_buffer + recon_uvoffset, |
574 denoiser->yv12_running_avg[INTRA_FRAME].uv_stride); | 573 denoiser->yv12_running_avg[INTRA_FRAME].uv_stride); |
575 } | 574 } |
576 if (decision_v == COPY_BLOCK) { | 575 if (decision_v == COPY_BLOCK) { |
577 vp8_copy_mem8x8( | 576 vp8_copy_mem8x8( |
578 x->block[20].src + *x->block[20].base_src, x->block[16].src_stride, | 577 x->block[20].src + *x->block[20].base_src, x->block[16].src_stride, |
579 denoiser->yv12_running_avg[INTRA_FRAME].v_buffer + recon_uvoffset, | 578 denoiser->yv12_running_avg[INTRA_FRAME].v_buffer + recon_uvoffset, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 } | 626 } |
628 if (apply_filter) { | 627 if (apply_filter) { |
629 // Update the signal block |x|. Pixel changes are only to top and/or | 628 // Update the signal block |x|. Pixel changes are only to top and/or |
630 // left boundary pixels: can we avoid full block copy here. | 629 // left boundary pixels: can we avoid full block copy here. |
631 vp8_copy_mem16x16( | 630 vp8_copy_mem16x16( |
632 denoiser->yv12_running_avg[INTRA_FRAME].y_buffer + recon_yoffset, | 631 denoiser->yv12_running_avg[INTRA_FRAME].y_buffer + recon_yoffset, |
633 y_stride, x->thismb, 16); | 632 y_stride, x->thismb, 16); |
634 } | 633 } |
635 } | 634 } |
636 } | 635 } |
OLD | NEW |