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

Side by Side Diff: source/libvpx/vp9/common/vp9_loopfilter.c

Issue 668403002: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 6 years, 2 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/vp9/common/vp9_idct.c ('k') | source/libvpx/vp9/common/vp9_loopfilter_filters.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) 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 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 mask_8x8_0 >>= 1; 385 mask_8x8_0 >>= 1;
386 mask_4x4_0 >>= 1; 386 mask_4x4_0 >>= 1;
387 mask_4x4_int_0 >>= 1; 387 mask_4x4_int_0 >>= 1;
388 mask_16x16_1 >>= 1; 388 mask_16x16_1 >>= 1;
389 mask_8x8_1 >>= 1; 389 mask_8x8_1 >>= 1;
390 mask_4x4_1 >>= 1; 390 mask_4x4_1 >>= 1;
391 mask_4x4_int_1 >>= 1; 391 mask_4x4_int_1 >>= 1;
392 } 392 }
393 } 393 }
394 394
395 #if CONFIG_VP9_HIGHBITDEPTH
396 static void highbd_filter_selectively_vert_row2(PLANE_TYPE plane_type,
397 uint16_t *s, int pitch,
398 unsigned int mask_16x16_l,
399 unsigned int mask_8x8_l,
400 unsigned int mask_4x4_l,
401 unsigned int mask_4x4_int_l,
402 const loop_filter_info_n *lfi_n,
403 const uint8_t *lfl, int bd) {
404 const int mask_shift = plane_type ? 4 : 8;
405 const int mask_cutoff = plane_type ? 0xf : 0xff;
406 const int lfl_forward = plane_type ? 4 : 8;
407
408 unsigned int mask_16x16_0 = mask_16x16_l & mask_cutoff;
409 unsigned int mask_8x8_0 = mask_8x8_l & mask_cutoff;
410 unsigned int mask_4x4_0 = mask_4x4_l & mask_cutoff;
411 unsigned int mask_4x4_int_0 = mask_4x4_int_l & mask_cutoff;
412 unsigned int mask_16x16_1 = (mask_16x16_l >> mask_shift) & mask_cutoff;
413 unsigned int mask_8x8_1 = (mask_8x8_l >> mask_shift) & mask_cutoff;
414 unsigned int mask_4x4_1 = (mask_4x4_l >> mask_shift) & mask_cutoff;
415 unsigned int mask_4x4_int_1 = (mask_4x4_int_l >> mask_shift) & mask_cutoff;
416 unsigned int mask;
417
418 for (mask = mask_16x16_0 | mask_8x8_0 | mask_4x4_0 | mask_4x4_int_0 |
419 mask_16x16_1 | mask_8x8_1 | mask_4x4_1 | mask_4x4_int_1;
420 mask; mask >>= 1) {
421 const loop_filter_thresh *lfi0 = lfi_n->lfthr + *lfl;
422 const loop_filter_thresh *lfi1 = lfi_n->lfthr + *(lfl + lfl_forward);
423
424 // TODO(yunqingwang): count in loopfilter functions should be removed.
425 if (mask & 1) {
426 if ((mask_16x16_0 | mask_16x16_1) & 1) {
427 if ((mask_16x16_0 & mask_16x16_1) & 1) {
428 vp9_highbd_lpf_vertical_16_dual(s, pitch, lfi0->mblim, lfi0->lim,
429 lfi0->hev_thr, bd);
430 } else if (mask_16x16_0 & 1) {
431 vp9_highbd_lpf_vertical_16(s, pitch, lfi0->mblim, lfi0->lim,
432 lfi0->hev_thr, bd);
433 } else {
434 vp9_highbd_lpf_vertical_16(s + 8 *pitch, pitch, lfi1->mblim,
435 lfi1->lim, lfi1->hev_thr, bd);
436 }
437 }
438
439 if ((mask_8x8_0 | mask_8x8_1) & 1) {
440 if ((mask_8x8_0 & mask_8x8_1) & 1) {
441 vp9_highbd_lpf_vertical_8_dual(s, pitch, lfi0->mblim, lfi0->lim,
442 lfi0->hev_thr, lfi1->mblim, lfi1->lim,
443 lfi1->hev_thr, bd);
444 } else if (mask_8x8_0 & 1) {
445 vp9_highbd_lpf_vertical_8(s, pitch, lfi0->mblim, lfi0->lim,
446 lfi0->hev_thr, 1, bd);
447 } else {
448 vp9_highbd_lpf_vertical_8(s + 8 * pitch, pitch, lfi1->mblim,
449 lfi1->lim, lfi1->hev_thr, 1, bd);
450 }
451 }
452
453 if ((mask_4x4_0 | mask_4x4_1) & 1) {
454 if ((mask_4x4_0 & mask_4x4_1) & 1) {
455 vp9_highbd_lpf_vertical_4_dual(s, pitch, lfi0->mblim, lfi0->lim,
456 lfi0->hev_thr, lfi1->mblim, lfi1->lim,
457 lfi1->hev_thr, bd);
458 } else if (mask_4x4_0 & 1) {
459 vp9_highbd_lpf_vertical_4(s, pitch, lfi0->mblim, lfi0->lim,
460 lfi0->hev_thr, 1, bd);
461 } else {
462 vp9_highbd_lpf_vertical_4(s + 8 * pitch, pitch, lfi1->mblim,
463 lfi1->lim, lfi1->hev_thr, 1, bd);
464 }
465 }
466
467 if ((mask_4x4_int_0 | mask_4x4_int_1) & 1) {
468 if ((mask_4x4_int_0 & mask_4x4_int_1) & 1) {
469 vp9_highbd_lpf_vertical_4_dual(s + 4, pitch, lfi0->mblim, lfi0->lim,
470 lfi0->hev_thr, lfi1->mblim, lfi1->lim,
471 lfi1->hev_thr, bd);
472 } else if (mask_4x4_int_0 & 1) {
473 vp9_highbd_lpf_vertical_4(s + 4, pitch, lfi0->mblim, lfi0->lim,
474 lfi0->hev_thr, 1, bd);
475 } else {
476 vp9_highbd_lpf_vertical_4(s + 8 * pitch + 4, pitch, lfi1->mblim,
477 lfi1->lim, lfi1->hev_thr, 1, bd);
478 }
479 }
480 }
481
482 s += 8;
483 lfl += 1;
484 mask_16x16_0 >>= 1;
485 mask_8x8_0 >>= 1;
486 mask_4x4_0 >>= 1;
487 mask_4x4_int_0 >>= 1;
488 mask_16x16_1 >>= 1;
489 mask_8x8_1 >>= 1;
490 mask_4x4_1 >>= 1;
491 mask_4x4_int_1 >>= 1;
492 }
493 }
494 #endif // CONFIG_VP9_HIGHBITDEPTH
495
395 static void filter_selectively_horiz(uint8_t *s, int pitch, 496 static void filter_selectively_horiz(uint8_t *s, int pitch,
396 unsigned int mask_16x16, 497 unsigned int mask_16x16,
397 unsigned int mask_8x8, 498 unsigned int mask_8x8,
398 unsigned int mask_4x4, 499 unsigned int mask_4x4,
399 unsigned int mask_4x4_int, 500 unsigned int mask_4x4_int,
400 const loop_filter_info_n *lfi_n, 501 const loop_filter_info_n *lfi_n,
401 const uint8_t *lfl) { 502 const uint8_t *lfl) {
402 unsigned int mask; 503 unsigned int mask;
403 int count; 504 int count;
404 505
405 for (mask = mask_16x16 | mask_8x8 | mask_4x4 | mask_4x4_int; 506 for (mask = mask_16x16 | mask_8x8 | mask_4x4 | mask_4x4_int;
406 mask; mask >>= count) { 507 mask; mask >>= count) {
407 const loop_filter_thresh *lfi = lfi_n->lfthr + *lfl; 508 const loop_filter_thresh *lfi = lfi_n->lfthr + *lfl;
408 509
409 count = 1; 510 count = 1;
410 if (mask & 1) { 511 if (mask & 1) {
411 if (mask_16x16 & 1) { 512 if (mask_16x16 & 1) {
412 if ((mask_16x16 & 3) == 3) { 513 if ((mask_16x16 & 3) == 3) {
413 vp9_lpf_horizontal_16(s, pitch, lfi->mblim, lfi->lim, 514 vp9_lpf_horizontal_16(s, pitch, lfi->mblim, lfi->lim,
414 lfi->hev_thr, 2); 515 lfi->hev_thr, 2);
415 count = 2; 516 count = 2;
416 } else { 517 } else {
417 vp9_lpf_horizontal_16(s, pitch, lfi->mblim, lfi->lim, 518 vp9_lpf_horizontal_16(s, pitch, lfi->mblim, lfi->lim,
418 lfi->hev_thr, 1); 519 lfi->hev_thr, 1);
419 } 520 }
420 } else if (mask_8x8 & 1) { 521 } else if (mask_8x8 & 1) {
421 if ((mask_8x8 & 3) == 3) { 522 if ((mask_8x8 & 3) == 3) {
422 // Next block's thresholds 523 // Next block's thresholds.
423 const loop_filter_thresh *lfin = lfi_n->lfthr + *(lfl + 1); 524 const loop_filter_thresh *lfin = lfi_n->lfthr + *(lfl + 1);
424 525
425 vp9_lpf_horizontal_8_dual(s, pitch, lfi->mblim, lfi->lim, 526 vp9_lpf_horizontal_8_dual(s, pitch, lfi->mblim, lfi->lim,
426 lfi->hev_thr, lfin->mblim, lfin->lim, 527 lfi->hev_thr, lfin->mblim, lfin->lim,
427 lfin->hev_thr); 528 lfin->hev_thr);
428 529
429 if ((mask_4x4_int & 3) == 3) { 530 if ((mask_4x4_int & 3) == 3) {
430 vp9_lpf_horizontal_4_dual(s + 4 * pitch, pitch, lfi->mblim, 531 vp9_lpf_horizontal_4_dual(s + 4 * pitch, pitch, lfi->mblim,
431 lfi->lim, lfi->hev_thr, lfin->mblim, 532 lfi->lim, lfi->hev_thr, lfin->mblim,
432 lfin->lim, lfin->hev_thr); 533 lfin->lim, lfin->hev_thr);
433 } else { 534 } else {
434 if (mask_4x4_int & 1) 535 if (mask_4x4_int & 1)
435 vp9_lpf_horizontal_4(s + 4 * pitch, pitch, lfi->mblim, lfi->lim, 536 vp9_lpf_horizontal_4(s + 4 * pitch, pitch, lfi->mblim, lfi->lim,
436 lfi->hev_thr, 1); 537 lfi->hev_thr, 1);
437 else if (mask_4x4_int & 2) 538 else if (mask_4x4_int & 2)
438 vp9_lpf_horizontal_4(s + 8 + 4 * pitch, pitch, lfin->mblim, 539 vp9_lpf_horizontal_4(s + 8 + 4 * pitch, pitch, lfin->mblim,
439 lfin->lim, lfin->hev_thr, 1); 540 lfin->lim, lfin->hev_thr, 1);
440 } 541 }
441 count = 2; 542 count = 2;
442 } else { 543 } else {
443 vp9_lpf_horizontal_8(s, pitch, lfi->mblim, lfi->lim, lfi->hev_thr, 1); 544 vp9_lpf_horizontal_8(s, pitch, lfi->mblim, lfi->lim, lfi->hev_thr, 1);
444 545
445 if (mask_4x4_int & 1) 546 if (mask_4x4_int & 1)
446 vp9_lpf_horizontal_4(s + 4 * pitch, pitch, lfi->mblim, lfi->lim, 547 vp9_lpf_horizontal_4(s + 4 * pitch, pitch, lfi->mblim, lfi->lim,
447 lfi->hev_thr, 1); 548 lfi->hev_thr, 1);
448 } 549 }
449 } else if (mask_4x4 & 1) { 550 } else if (mask_4x4 & 1) {
450 if ((mask_4x4 & 3) == 3) { 551 if ((mask_4x4 & 3) == 3) {
451 // Next block's thresholds 552 // Next block's thresholds.
452 const loop_filter_thresh *lfin = lfi_n->lfthr + *(lfl + 1); 553 const loop_filter_thresh *lfin = lfi_n->lfthr + *(lfl + 1);
453 554
454 vp9_lpf_horizontal_4_dual(s, pitch, lfi->mblim, lfi->lim, 555 vp9_lpf_horizontal_4_dual(s, pitch, lfi->mblim, lfi->lim,
455 lfi->hev_thr, lfin->mblim, lfin->lim, 556 lfi->hev_thr, lfin->mblim, lfin->lim,
456 lfin->hev_thr); 557 lfin->hev_thr);
457 if ((mask_4x4_int & 3) == 3) { 558 if ((mask_4x4_int & 3) == 3) {
458 vp9_lpf_horizontal_4_dual(s + 4 * pitch, pitch, lfi->mblim, 559 vp9_lpf_horizontal_4_dual(s + 4 * pitch, pitch, lfi->mblim,
459 lfi->lim, lfi->hev_thr, lfin->mblim, 560 lfi->lim, lfi->hev_thr, lfin->mblim,
460 lfin->lim, lfin->hev_thr); 561 lfin->lim, lfin->hev_thr);
461 } else { 562 } else {
(...skipping 19 matching lines...) Expand all
481 } 582 }
482 s += 8 * count; 583 s += 8 * count;
483 lfl += count; 584 lfl += count;
484 mask_16x16 >>= count; 585 mask_16x16 >>= count;
485 mask_8x8 >>= count; 586 mask_8x8 >>= count;
486 mask_4x4 >>= count; 587 mask_4x4 >>= count;
487 mask_4x4_int >>= count; 588 mask_4x4_int >>= count;
488 } 589 }
489 } 590 }
490 591
592 #if CONFIG_VP9_HIGHBITDEPTH
593 static void highbd_filter_selectively_horiz(uint16_t *s, int pitch,
594 unsigned int mask_16x16,
595 unsigned int mask_8x8,
596 unsigned int mask_4x4,
597 unsigned int mask_4x4_int,
598 const loop_filter_info_n *lfi_n,
599 const uint8_t *lfl, int bd) {
600 unsigned int mask;
601 int count;
602
603 for (mask = mask_16x16 | mask_8x8 | mask_4x4 | mask_4x4_int;
604 mask; mask >>= count) {
605 const loop_filter_thresh *lfi = lfi_n->lfthr + *lfl;
606
607 count = 1;
608 if (mask & 1) {
609 if (mask_16x16 & 1) {
610 if ((mask_16x16 & 3) == 3) {
611 vp9_highbd_lpf_horizontal_16(s, pitch, lfi->mblim, lfi->lim,
612 lfi->hev_thr, 2, bd);
613 count = 2;
614 } else {
615 vp9_highbd_lpf_horizontal_16(s, pitch, lfi->mblim, lfi->lim,
616 lfi->hev_thr, 1, bd);
617 }
618 } else if (mask_8x8 & 1) {
619 if ((mask_8x8 & 3) == 3) {
620 // Next block's thresholds.
621 const loop_filter_thresh *lfin = lfi_n->lfthr + *(lfl + 1);
622
623 vp9_highbd_lpf_horizontal_8_dual(s, pitch, lfi->mblim, lfi->lim,
624 lfi->hev_thr, lfin->mblim, lfin->lim,
625 lfin->hev_thr, bd);
626
627 if ((mask_4x4_int & 3) == 3) {
628 vp9_highbd_lpf_horizontal_4_dual(s + 4 * pitch, pitch, lfi->mblim,
629 lfi->lim, lfi->hev_thr,
630 lfin->mblim, lfin->lim,
631 lfin->hev_thr, bd);
632 } else {
633 if (mask_4x4_int & 1) {
634 vp9_highbd_lpf_horizontal_4(s + 4 * pitch, pitch, lfi->mblim,
635 lfi->lim, lfi->hev_thr, 1, bd);
636 } else if (mask_4x4_int & 2) {
637 vp9_highbd_lpf_horizontal_4(s + 8 + 4 * pitch, pitch, lfin->mblim,
638 lfin->lim, lfin->hev_thr, 1, bd);
639 }
640 }
641 count = 2;
642 } else {
643 vp9_highbd_lpf_horizontal_8(s, pitch, lfi->mblim, lfi->lim,
644 lfi->hev_thr, 1, bd);
645
646 if (mask_4x4_int & 1) {
647 vp9_highbd_lpf_horizontal_4(s + 4 * pitch, pitch, lfi->mblim,
648 lfi->lim, lfi->hev_thr, 1, bd);
649 }
650 }
651 } else if (mask_4x4 & 1) {
652 if ((mask_4x4 & 3) == 3) {
653 // Next block's thresholds.
654 const loop_filter_thresh *lfin = lfi_n->lfthr + *(lfl + 1);
655
656 vp9_highbd_lpf_horizontal_4_dual(s, pitch, lfi->mblim, lfi->lim,
657 lfi->hev_thr, lfin->mblim, lfin->lim,
658 lfin->hev_thr, bd);
659 if ((mask_4x4_int & 3) == 3) {
660 vp9_highbd_lpf_horizontal_4_dual(s + 4 * pitch, pitch, lfi->mblim,
661 lfi->lim, lfi->hev_thr,
662 lfin->mblim, lfin->lim,
663 lfin->hev_thr, bd);
664 } else {
665 if (mask_4x4_int & 1) {
666 vp9_highbd_lpf_horizontal_4(s + 4 * pitch, pitch, lfi->mblim,
667 lfi->lim, lfi->hev_thr, 1, bd);
668 } else if (mask_4x4_int & 2) {
669 vp9_highbd_lpf_horizontal_4(s + 8 + 4 * pitch, pitch, lfin->mblim,
670 lfin->lim, lfin->hev_thr, 1, bd);
671 }
672 }
673 count = 2;
674 } else {
675 vp9_highbd_lpf_horizontal_4(s, pitch, lfi->mblim, lfi->lim,
676 lfi->hev_thr, 1, bd);
677
678 if (mask_4x4_int & 1) {
679 vp9_highbd_lpf_horizontal_4(s + 4 * pitch, pitch, lfi->mblim,
680 lfi->lim, lfi->hev_thr, 1, bd);
681 }
682 }
683 } else if (mask_4x4_int & 1) {
684 vp9_highbd_lpf_horizontal_4(s + 4 * pitch, pitch, lfi->mblim, lfi->lim,
685 lfi->hev_thr, 1, bd);
686 }
687 }
688 s += 8 * count;
689 lfl += count;
690 mask_16x16 >>= count;
691 mask_8x8 >>= count;
692 mask_4x4 >>= count;
693 mask_4x4_int >>= count;
694 }
695 }
696 #endif // CONFIG_VP9_HIGHBITDEPTH
697
491 // This function ors into the current lfm structure, where to do loop 698 // This function ors into the current lfm structure, where to do loop
492 // filters for the specific mi we are looking at. It uses information 699 // filters for the specific mi we are looking at. It uses information
493 // including the block_size_type (32x16, 32x32, etc.), the transform size, 700 // including the block_size_type (32x16, 32x32, etc.), the transform size,
494 // whether there were any coefficients encoded, and the loop filter strength 701 // whether there were any coefficients encoded, and the loop filter strength
495 // block we are currently looking at. Shift is used to position the 702 // block we are currently looking at. Shift is used to position the
496 // 1's we produce. 703 // 1's we produce.
497 // TODO(JBB) Need another function for different resolution color.. 704 // TODO(JBB) Need another function for different resolution color..
498 static void build_masks(const loop_filter_info_n *const lfi_n, 705 static void build_masks(const loop_filter_info_n *const lfi_n,
499 const MODE_INFO *mi, const int shift_y, 706 const MODE_INFO *mi, const int shift_y,
500 const int shift_uv, 707 const int shift_uv,
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 vp9_lpf_vertical_4(s + 4, pitch, lfi->mblim, lfi->lim, lfi->hev_thr, 1); 1103 vp9_lpf_vertical_4(s + 4, pitch, lfi->mblim, lfi->lim, lfi->hev_thr, 1);
897 s += 8; 1104 s += 8;
898 lfl += 1; 1105 lfl += 1;
899 mask_16x16 >>= 1; 1106 mask_16x16 >>= 1;
900 mask_8x8 >>= 1; 1107 mask_8x8 >>= 1;
901 mask_4x4 >>= 1; 1108 mask_4x4 >>= 1;
902 mask_4x4_int >>= 1; 1109 mask_4x4_int >>= 1;
903 } 1110 }
904 } 1111 }
905 1112
1113 #if CONFIG_VP9_HIGHBITDEPTH
1114 static void highbd_filter_selectively_vert(uint16_t *s, int pitch,
1115 unsigned int mask_16x16,
1116 unsigned int mask_8x8,
1117 unsigned int mask_4x4,
1118 unsigned int mask_4x4_int,
1119 const loop_filter_info_n *lfi_n,
1120 const uint8_t *lfl, int bd) {
1121 unsigned int mask;
1122
1123 for (mask = mask_16x16 | mask_8x8 | mask_4x4 | mask_4x4_int;
1124 mask; mask >>= 1) {
1125 const loop_filter_thresh *lfi = lfi_n->lfthr + *lfl;
1126
1127 if (mask & 1) {
1128 if (mask_16x16 & 1) {
1129 vp9_highbd_lpf_vertical_16(s, pitch, lfi->mblim, lfi->lim,
1130 lfi->hev_thr, bd);
1131 } else if (mask_8x8 & 1) {
1132 vp9_highbd_lpf_vertical_8(s, pitch, lfi->mblim, lfi->lim,
1133 lfi->hev_thr, 1, bd);
1134 } else if (mask_4x4 & 1) {
1135 vp9_highbd_lpf_vertical_4(s, pitch, lfi->mblim, lfi->lim,
1136 lfi->hev_thr, 1, bd);
1137 }
1138 }
1139 if (mask_4x4_int & 1)
1140 vp9_highbd_lpf_vertical_4(s + 4, pitch, lfi->mblim, lfi->lim,
1141 lfi->hev_thr, 1, bd);
1142 s += 8;
1143 lfl += 1;
1144 mask_16x16 >>= 1;
1145 mask_8x8 >>= 1;
1146 mask_4x4 >>= 1;
1147 mask_4x4_int >>= 1;
1148 }
1149 }
1150 #endif // CONFIG_VP9_HIGHBITDEPTH
1151
906 static void filter_block_plane_non420(VP9_COMMON *cm, 1152 static void filter_block_plane_non420(VP9_COMMON *cm,
907 struct macroblockd_plane *plane, 1153 struct macroblockd_plane *plane,
908 MODE_INFO *mi_8x8, 1154 MODE_INFO *mi_8x8,
909 int mi_row, int mi_col) { 1155 int mi_row, int mi_col) {
910 const int ss_x = plane->subsampling_x; 1156 const int ss_x = plane->subsampling_x;
911 const int ss_y = plane->subsampling_y; 1157 const int ss_y = plane->subsampling_y;
912 const int row_step = 1 << ss_x; 1158 const int row_step = 1 << ss_y;
913 const int col_step = 1 << ss_y; 1159 const int col_step = 1 << ss_x;
914 const int row_step_stride = cm->mi_stride * row_step; 1160 const int row_step_stride = cm->mi_stride * row_step;
915 struct buf_2d *const dst = &plane->dst; 1161 struct buf_2d *const dst = &plane->dst;
916 uint8_t* const dst0 = dst->buf; 1162 uint8_t* const dst0 = dst->buf;
917 unsigned int mask_16x16[MI_BLOCK_SIZE] = {0}; 1163 unsigned int mask_16x16[MI_BLOCK_SIZE] = {0};
918 unsigned int mask_8x8[MI_BLOCK_SIZE] = {0}; 1164 unsigned int mask_8x8[MI_BLOCK_SIZE] = {0};
919 unsigned int mask_4x4[MI_BLOCK_SIZE] = {0}; 1165 unsigned int mask_4x4[MI_BLOCK_SIZE] = {0};
920 unsigned int mask_4x4_int[MI_BLOCK_SIZE] = {0}; 1166 unsigned int mask_4x4_int[MI_BLOCK_SIZE] = {0};
921 uint8_t lfl[MI_BLOCK_SIZE * MI_BLOCK_SIZE]; 1167 uint8_t lfl[MI_BLOCK_SIZE * MI_BLOCK_SIZE];
922 int r, c; 1168 int r, c;
923 1169
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 mask_4x4[r] |= 1 << (c >> ss_x); 1240 mask_4x4[r] |= 1 << (c >> ss_x);
995 } 1241 }
996 1242
997 if (!skip_this && tx_size < TX_8X8 && !skip_border_4x4_c) 1243 if (!skip_this && tx_size < TX_8X8 && !skip_border_4x4_c)
998 mask_4x4_int[r] |= 1 << (c >> ss_x); 1244 mask_4x4_int[r] |= 1 << (c >> ss_x);
999 } 1245 }
1000 } 1246 }
1001 1247
1002 // Disable filtering on the leftmost column 1248 // Disable filtering on the leftmost column
1003 border_mask = ~(mi_col == 0); 1249 border_mask = ~(mi_col == 0);
1250 #if CONFIG_VP9_HIGHBITDEPTH
1251 if (cm->use_highbitdepth) {
1252 highbd_filter_selectively_vert(CONVERT_TO_SHORTPTR(dst->buf),
1253 dst->stride,
1254 mask_16x16_c & border_mask,
1255 mask_8x8_c & border_mask,
1256 mask_4x4_c & border_mask,
1257 mask_4x4_int[r],
1258 &cm->lf_info, &lfl[r << 3],
1259 (int)cm->bit_depth);
1260 } else {
1261 filter_selectively_vert(dst->buf, dst->stride,
1262 mask_16x16_c & border_mask,
1263 mask_8x8_c & border_mask,
1264 mask_4x4_c & border_mask,
1265 mask_4x4_int[r],
1266 &cm->lf_info, &lfl[r << 3]);
1267 }
1268 #else
1004 filter_selectively_vert(dst->buf, dst->stride, 1269 filter_selectively_vert(dst->buf, dst->stride,
1005 mask_16x16_c & border_mask, 1270 mask_16x16_c & border_mask,
1006 mask_8x8_c & border_mask, 1271 mask_8x8_c & border_mask,
1007 mask_4x4_c & border_mask, 1272 mask_4x4_c & border_mask,
1008 mask_4x4_int[r], 1273 mask_4x4_int[r],
1009 &cm->lf_info, &lfl[r << 3]); 1274 &cm->lf_info, &lfl[r << 3]);
1275 #endif // CONFIG_VP9_HIGHBITDEPTH
1010 dst->buf += 8 * dst->stride; 1276 dst->buf += 8 * dst->stride;
1011 mi_8x8 += row_step_stride; 1277 mi_8x8 += row_step_stride;
1012 } 1278 }
1013 1279
1014 // Now do horizontal pass 1280 // Now do horizontal pass
1015 dst->buf = dst0; 1281 dst->buf = dst0;
1016 for (r = 0; r < MI_BLOCK_SIZE && mi_row + r < cm->mi_rows; r += row_step) { 1282 for (r = 0; r < MI_BLOCK_SIZE && mi_row + r < cm->mi_rows; r += row_step) {
1017 const int skip_border_4x4_r = ss_y && mi_row + r == cm->mi_rows - 1; 1283 const int skip_border_4x4_r = ss_y && mi_row + r == cm->mi_rows - 1;
1018 const unsigned int mask_4x4_int_r = skip_border_4x4_r ? 0 : mask_4x4_int[r]; 1284 const unsigned int mask_4x4_int_r = skip_border_4x4_r ? 0 : mask_4x4_int[r];
1019 1285
1020 unsigned int mask_16x16_r; 1286 unsigned int mask_16x16_r;
1021 unsigned int mask_8x8_r; 1287 unsigned int mask_8x8_r;
1022 unsigned int mask_4x4_r; 1288 unsigned int mask_4x4_r;
1023 1289
1024 if (mi_row + r == 0) { 1290 if (mi_row + r == 0) {
1025 mask_16x16_r = 0; 1291 mask_16x16_r = 0;
1026 mask_8x8_r = 0; 1292 mask_8x8_r = 0;
1027 mask_4x4_r = 0; 1293 mask_4x4_r = 0;
1028 } else { 1294 } else {
1029 mask_16x16_r = mask_16x16[r]; 1295 mask_16x16_r = mask_16x16[r];
1030 mask_8x8_r = mask_8x8[r]; 1296 mask_8x8_r = mask_8x8[r];
1031 mask_4x4_r = mask_4x4[r]; 1297 mask_4x4_r = mask_4x4[r];
1032 } 1298 }
1033 1299 #if CONFIG_VP9_HIGHBITDEPTH
1300 if (cm->use_highbitdepth) {
1301 highbd_filter_selectively_horiz(CONVERT_TO_SHORTPTR(dst->buf),
1302 dst->stride,
1303 mask_16x16_r,
1304 mask_8x8_r,
1305 mask_4x4_r,
1306 mask_4x4_int_r,
1307 &cm->lf_info, &lfl[r << 3],
1308 (int)cm->bit_depth);
1309 } else {
1310 filter_selectively_horiz(dst->buf, dst->stride,
1311 mask_16x16_r,
1312 mask_8x8_r,
1313 mask_4x4_r,
1314 mask_4x4_int_r,
1315 &cm->lf_info, &lfl[r << 3]);
1316 }
1317 #else
1034 filter_selectively_horiz(dst->buf, dst->stride, 1318 filter_selectively_horiz(dst->buf, dst->stride,
1035 mask_16x16_r, 1319 mask_16x16_r,
1036 mask_8x8_r, 1320 mask_8x8_r,
1037 mask_4x4_r, 1321 mask_4x4_r,
1038 mask_4x4_int_r, 1322 mask_4x4_int_r,
1039 &cm->lf_info, &lfl[r << 3]); 1323 &cm->lf_info, &lfl[r << 3]);
1324 #endif // CONFIG_VP9_HIGHBITDEPTH
1040 dst->buf += 8 * dst->stride; 1325 dst->buf += 8 * dst->stride;
1041 } 1326 }
1042 } 1327 }
1043 1328
1044 void vp9_filter_block_plane(VP9_COMMON *const cm, 1329 void vp9_filter_block_plane(VP9_COMMON *const cm,
1045 struct macroblockd_plane *const plane, 1330 struct macroblockd_plane *const plane,
1046 int mi_row, 1331 int mi_row,
1047 LOOP_FILTER_MASK *lfm) { 1332 LOOP_FILTER_MASK *lfm) {
1048 struct buf_2d *const dst = &plane->dst; 1333 struct buf_2d *const dst = &plane->dst;
1049 uint8_t* const dst0 = dst->buf; 1334 uint8_t* const dst0 = dst->buf;
1050 int r, c; 1335 int r, c;
1051 1336
1052 if (!plane->plane_type) { 1337 if (!plane->plane_type) {
1053 uint64_t mask_16x16 = lfm->left_y[TX_16X16]; 1338 uint64_t mask_16x16 = lfm->left_y[TX_16X16];
1054 uint64_t mask_8x8 = lfm->left_y[TX_8X8]; 1339 uint64_t mask_8x8 = lfm->left_y[TX_8X8];
1055 uint64_t mask_4x4 = lfm->left_y[TX_4X4]; 1340 uint64_t mask_4x4 = lfm->left_y[TX_4X4];
1056 uint64_t mask_4x4_int = lfm->int_4x4_y; 1341 uint64_t mask_4x4_int = lfm->int_4x4_y;
1057 1342
1058 // Vertical pass: do 2 rows at one time 1343 // Vertical pass: do 2 rows at one time
1059 for (r = 0; r < MI_BLOCK_SIZE && mi_row + r < cm->mi_rows; r += 2) { 1344 for (r = 0; r < MI_BLOCK_SIZE && mi_row + r < cm->mi_rows; r += 2) {
1060 unsigned int mask_16x16_l = mask_16x16 & 0xffff; 1345 unsigned int mask_16x16_l = mask_16x16 & 0xffff;
1061 unsigned int mask_8x8_l = mask_8x8 & 0xffff; 1346 unsigned int mask_8x8_l = mask_8x8 & 0xffff;
1062 unsigned int mask_4x4_l = mask_4x4 & 0xffff; 1347 unsigned int mask_4x4_l = mask_4x4 & 0xffff;
1063 unsigned int mask_4x4_int_l = mask_4x4_int & 0xffff; 1348 unsigned int mask_4x4_int_l = mask_4x4_int & 0xffff;
1064 1349
1065 // Disable filtering on the leftmost column 1350 // Disable filtering on the leftmost column.
1351 #if CONFIG_VP9_HIGHBITDEPTH
1352 if (cm->use_highbitdepth) {
1353 highbd_filter_selectively_vert_row2(plane->plane_type,
1354 CONVERT_TO_SHORTPTR(dst->buf),
1355 dst->stride,
1356 mask_16x16_l,
1357 mask_8x8_l,
1358 mask_4x4_l,
1359 mask_4x4_int_l,
1360 &cm->lf_info, &lfm->lfl_y[r << 3],
1361 (int)cm->bit_depth);
1362 } else {
1363 filter_selectively_vert_row2(plane->plane_type,
1364 dst->buf, dst->stride,
1365 mask_16x16_l,
1366 mask_8x8_l,
1367 mask_4x4_l,
1368 mask_4x4_int_l,
1369 &cm->lf_info,
1370 &lfm->lfl_y[r << 3]);
1371 }
1372 #else
1066 filter_selectively_vert_row2(plane->plane_type, 1373 filter_selectively_vert_row2(plane->plane_type,
1067 dst->buf, dst->stride, 1374 dst->buf, dst->stride,
1068 mask_16x16_l, 1375 mask_16x16_l,
1069 mask_8x8_l, 1376 mask_8x8_l,
1070 mask_4x4_l, 1377 mask_4x4_l,
1071 mask_4x4_int_l, 1378 mask_4x4_int_l,
1072 &cm->lf_info, &lfm->lfl_y[r << 3]); 1379 &cm->lf_info, &lfm->lfl_y[r << 3]);
1073 1380 #endif // CONFIG_VP9_HIGHBITDEPTH
1074 dst->buf += 16 * dst->stride; 1381 dst->buf += 16 * dst->stride;
1075 mask_16x16 >>= 16; 1382 mask_16x16 >>= 16;
1076 mask_8x8 >>= 16; 1383 mask_8x8 >>= 16;
1077 mask_4x4 >>= 16; 1384 mask_4x4 >>= 16;
1078 mask_4x4_int >>= 16; 1385 mask_4x4_int >>= 16;
1079 } 1386 }
1080 1387
1081 // Horizontal pass 1388 // Horizontal pass
1082 dst->buf = dst0; 1389 dst->buf = dst0;
1083 mask_16x16 = lfm->above_y[TX_16X16]; 1390 mask_16x16 = lfm->above_y[TX_16X16];
1084 mask_8x8 = lfm->above_y[TX_8X8]; 1391 mask_8x8 = lfm->above_y[TX_8X8];
1085 mask_4x4 = lfm->above_y[TX_4X4]; 1392 mask_4x4 = lfm->above_y[TX_4X4];
1086 mask_4x4_int = lfm->int_4x4_y; 1393 mask_4x4_int = lfm->int_4x4_y;
1087 1394
1088 for (r = 0; r < MI_BLOCK_SIZE && mi_row + r < cm->mi_rows; r++) { 1395 for (r = 0; r < MI_BLOCK_SIZE && mi_row + r < cm->mi_rows; r++) {
1089 unsigned int mask_16x16_r; 1396 unsigned int mask_16x16_r;
1090 unsigned int mask_8x8_r; 1397 unsigned int mask_8x8_r;
1091 unsigned int mask_4x4_r; 1398 unsigned int mask_4x4_r;
1092 1399
1093 if (mi_row + r == 0) { 1400 if (mi_row + r == 0) {
1094 mask_16x16_r = 0; 1401 mask_16x16_r = 0;
1095 mask_8x8_r = 0; 1402 mask_8x8_r = 0;
1096 mask_4x4_r = 0; 1403 mask_4x4_r = 0;
1097 } else { 1404 } else {
1098 mask_16x16_r = mask_16x16 & 0xff; 1405 mask_16x16_r = mask_16x16 & 0xff;
1099 mask_8x8_r = mask_8x8 & 0xff; 1406 mask_8x8_r = mask_8x8 & 0xff;
1100 mask_4x4_r = mask_4x4 & 0xff; 1407 mask_4x4_r = mask_4x4 & 0xff;
1101 } 1408 }
1102 1409
1410 #if CONFIG_VP9_HIGHBITDEPTH
1411 if (cm->use_highbitdepth) {
1412 highbd_filter_selectively_horiz(CONVERT_TO_SHORTPTR(dst->buf),
1413 dst->stride,
1414 mask_16x16_r,
1415 mask_8x8_r,
1416 mask_4x4_r,
1417 mask_4x4_int & 0xff,
1418 &cm->lf_info,
1419 &lfm->lfl_y[r << 3],
1420 (int)cm->bit_depth);
1421 } else {
1422 filter_selectively_horiz(dst->buf, dst->stride,
1423 mask_16x16_r,
1424 mask_8x8_r,
1425 mask_4x4_r,
1426 mask_4x4_int & 0xff,
1427 &cm->lf_info,
1428 &lfm->lfl_y[r << 3]);
1429 }
1430 #else
1103 filter_selectively_horiz(dst->buf, dst->stride, 1431 filter_selectively_horiz(dst->buf, dst->stride,
1104 mask_16x16_r, 1432 mask_16x16_r,
1105 mask_8x8_r, 1433 mask_8x8_r,
1106 mask_4x4_r, 1434 mask_4x4_r,
1107 mask_4x4_int & 0xff, 1435 mask_4x4_int & 0xff,
1108 &cm->lf_info, &lfm->lfl_y[r << 3]); 1436 &cm->lf_info,
1437 &lfm->lfl_y[r << 3]);
1438 #endif // CONFIG_VP9_HIGHBITDEPTH
1109 1439
1110 dst->buf += 8 * dst->stride; 1440 dst->buf += 8 * dst->stride;
1111 mask_16x16 >>= 8; 1441 mask_16x16 >>= 8;
1112 mask_8x8 >>= 8; 1442 mask_8x8 >>= 8;
1113 mask_4x4 >>= 8; 1443 mask_4x4 >>= 8;
1114 mask_4x4_int >>= 8; 1444 mask_4x4_int >>= 8;
1115 } 1445 }
1116 } else { 1446 } else {
1117 uint16_t mask_16x16 = lfm->left_uv[TX_16X16]; 1447 uint16_t mask_16x16 = lfm->left_uv[TX_16X16];
1118 uint16_t mask_8x8 = lfm->left_uv[TX_8X8]; 1448 uint16_t mask_8x8 = lfm->left_uv[TX_8X8];
1119 uint16_t mask_4x4 = lfm->left_uv[TX_4X4]; 1449 uint16_t mask_4x4 = lfm->left_uv[TX_4X4];
1120 uint16_t mask_4x4_int = lfm->int_4x4_uv; 1450 uint16_t mask_4x4_int = lfm->int_4x4_uv;
1121 1451
1122 // Vertical pass: do 2 rows at one time 1452 // Vertical pass: do 2 rows at one time
1123 for (r = 0; r < MI_BLOCK_SIZE && mi_row + r < cm->mi_rows; r += 4) { 1453 for (r = 0; r < MI_BLOCK_SIZE && mi_row + r < cm->mi_rows; r += 4) {
1124 if (plane->plane_type == 1) { 1454 if (plane->plane_type == 1) {
1125 for (c = 0; c < (MI_BLOCK_SIZE >> 1); c++) { 1455 for (c = 0; c < (MI_BLOCK_SIZE >> 1); c++) {
1126 lfm->lfl_uv[(r << 1) + c] = lfm->lfl_y[(r << 3) + (c << 1)]; 1456 lfm->lfl_uv[(r << 1) + c] = lfm->lfl_y[(r << 3) + (c << 1)];
1127 lfm->lfl_uv[((r + 2) << 1) + c] = lfm->lfl_y[((r + 2) << 3) + 1457 lfm->lfl_uv[((r + 2) << 1) + c] = lfm->lfl_y[((r + 2) << 3) +
1128 (c << 1)]; 1458 (c << 1)];
1129 } 1459 }
1130 } 1460 }
1131 1461
1132 { 1462 {
1133 unsigned int mask_16x16_l = mask_16x16 & 0xff; 1463 unsigned int mask_16x16_l = mask_16x16 & 0xff;
1134 unsigned int mask_8x8_l = mask_8x8 & 0xff; 1464 unsigned int mask_8x8_l = mask_8x8 & 0xff;
1135 unsigned int mask_4x4_l = mask_4x4 & 0xff; 1465 unsigned int mask_4x4_l = mask_4x4 & 0xff;
1136 unsigned int mask_4x4_int_l = mask_4x4_int & 0xff; 1466 unsigned int mask_4x4_int_l = mask_4x4_int & 0xff;
1137 1467
1138 // Disable filtering on the leftmost column 1468 // Disable filtering on the leftmost column.
1469 #if CONFIG_VP9_HIGHBITDEPTH
1470 if (cm->use_highbitdepth) {
1471 highbd_filter_selectively_vert_row2(plane->plane_type,
1472 CONVERT_TO_SHORTPTR(dst->buf),
1473 dst->stride,
1474 mask_16x16_l,
1475 mask_8x8_l,
1476 mask_4x4_l,
1477 mask_4x4_int_l,
1478 &cm->lf_info,
1479 &lfm->lfl_uv[r << 1],
1480 (int)cm->bit_depth);
1481 } else {
1482 filter_selectively_vert_row2(plane->plane_type,
1483 dst->buf, dst->stride,
1484 mask_16x16_l,
1485 mask_8x8_l,
1486 mask_4x4_l,
1487 mask_4x4_int_l,
1488 &cm->lf_info,
1489 &lfm->lfl_uv[r << 1]);
1490 }
1491 #else
1139 filter_selectively_vert_row2(plane->plane_type, 1492 filter_selectively_vert_row2(plane->plane_type,
1140 dst->buf, dst->stride, 1493 dst->buf, dst->stride,
1141 mask_16x16_l, 1494 mask_16x16_l,
1142 mask_8x8_l, 1495 mask_8x8_l,
1143 mask_4x4_l, 1496 mask_4x4_l,
1144 mask_4x4_int_l, 1497 mask_4x4_int_l,
1145 &cm->lf_info, &lfm->lfl_uv[r << 1]); 1498 &cm->lf_info,
1499 &lfm->lfl_uv[r << 1]);
1500 #endif // CONFIG_VP9_HIGHBITDEPTH
1146 1501
1147 dst->buf += 16 * dst->stride; 1502 dst->buf += 16 * dst->stride;
1148 mask_16x16 >>= 8; 1503 mask_16x16 >>= 8;
1149 mask_8x8 >>= 8; 1504 mask_8x8 >>= 8;
1150 mask_4x4 >>= 8; 1505 mask_4x4 >>= 8;
1151 mask_4x4_int >>= 8; 1506 mask_4x4_int >>= 8;
1152 } 1507 }
1153 } 1508 }
1154 1509
1155 // Horizontal pass 1510 // Horizontal pass
(...skipping 14 matching lines...) Expand all
1170 if (mi_row + r == 0) { 1525 if (mi_row + r == 0) {
1171 mask_16x16_r = 0; 1526 mask_16x16_r = 0;
1172 mask_8x8_r = 0; 1527 mask_8x8_r = 0;
1173 mask_4x4_r = 0; 1528 mask_4x4_r = 0;
1174 } else { 1529 } else {
1175 mask_16x16_r = mask_16x16 & 0xf; 1530 mask_16x16_r = mask_16x16 & 0xf;
1176 mask_8x8_r = mask_8x8 & 0xf; 1531 mask_8x8_r = mask_8x8 & 0xf;
1177 mask_4x4_r = mask_4x4 & 0xf; 1532 mask_4x4_r = mask_4x4 & 0xf;
1178 } 1533 }
1179 1534
1535 #if CONFIG_VP9_HIGHBITDEPTH
1536 if (cm->use_highbitdepth) {
1537 highbd_filter_selectively_horiz(CONVERT_TO_SHORTPTR(dst->buf),
1538 dst->stride,
1539 mask_16x16_r,
1540 mask_8x8_r,
1541 mask_4x4_r,
1542 mask_4x4_int_r,
1543 &cm->lf_info,
1544 &lfm->lfl_uv[r << 1],
1545 (int)cm->bit_depth);
1546 } else {
1547 filter_selectively_horiz(dst->buf, dst->stride,
1548 mask_16x16_r,
1549 mask_8x8_r,
1550 mask_4x4_r,
1551 mask_4x4_int_r,
1552 &cm->lf_info,
1553 &lfm->lfl_uv[r << 1]);
1554 }
1555 #else
1180 filter_selectively_horiz(dst->buf, dst->stride, 1556 filter_selectively_horiz(dst->buf, dst->stride,
1181 mask_16x16_r, 1557 mask_16x16_r,
1182 mask_8x8_r, 1558 mask_8x8_r,
1183 mask_4x4_r, 1559 mask_4x4_r,
1184 mask_4x4_int_r, 1560 mask_4x4_int_r,
1185 &cm->lf_info, &lfm->lfl_uv[r << 1]); 1561 &cm->lf_info,
1562 &lfm->lfl_uv[r << 1]);
1563 #endif // CONFIG_VP9_HIGHBITDEPTH
1186 1564
1187 dst->buf += 8 * dst->stride; 1565 dst->buf += 8 * dst->stride;
1188 mask_16x16 >>= 4; 1566 mask_16x16 >>= 4;
1189 mask_8x8 >>= 4; 1567 mask_8x8 >>= 4;
1190 mask_4x4 >>= 4; 1568 mask_4x4 >>= 4;
1191 mask_4x4_int >>= 4; 1569 mask_4x4_int >>= 4;
1192 } 1570 }
1193 } 1571 }
1194 } 1572 }
1195 1573
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 start_mi_row, end_mi_row, 1624 start_mi_row, end_mi_row,
1247 y_only); 1625 y_only);
1248 } 1626 }
1249 1627
1250 int vp9_loop_filter_worker(LFWorkerData *const lf_data, void *unused) { 1628 int vp9_loop_filter_worker(LFWorkerData *const lf_data, void *unused) {
1251 (void)unused; 1629 (void)unused;
1252 vp9_loop_filter_rows(lf_data->frame_buffer, lf_data->cm, lf_data->planes, 1630 vp9_loop_filter_rows(lf_data->frame_buffer, lf_data->cm, lf_data->planes,
1253 lf_data->start, lf_data->stop, lf_data->y_only); 1631 lf_data->start, lf_data->stop, lf_data->y_only);
1254 return 1; 1632 return 1;
1255 } 1633 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/common/vp9_idct.c ('k') | source/libvpx/vp9/common/vp9_loopfilter_filters.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698