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

Side by Side Diff: source/libvpx/vp9/encoder/vp9_quantize.c

Issue 958693004: libvpx: Pull from upstream (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libvpx.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_pickmode.c ('k') | source/libvpx/vp9/encoder/vp9_ratectrl.h » ('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 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 qrounding_factor_fp = 64; 584 qrounding_factor_fp = 64;
585 585
586 // y 586 // y
587 quant = i == 0 ? vp9_dc_quant(q, cm->y_dc_delta_q, cm->bit_depth) 587 quant = i == 0 ? vp9_dc_quant(q, cm->y_dc_delta_q, cm->bit_depth)
588 : vp9_ac_quant(q, 0, cm->bit_depth); 588 : vp9_ac_quant(q, 0, cm->bit_depth);
589 invert_quant(&quants->y_quant[q][i], &quants->y_quant_shift[q][i], quant); 589 invert_quant(&quants->y_quant[q][i], &quants->y_quant_shift[q][i], quant);
590 quants->y_quant_fp[q][i] = (1 << 16) / quant; 590 quants->y_quant_fp[q][i] = (1 << 16) / quant;
591 quants->y_round_fp[q][i] = (qrounding_factor_fp * quant) >> 7; 591 quants->y_round_fp[q][i] = (qrounding_factor_fp * quant) >> 7;
592 quants->y_zbin[q][i] = ROUND_POWER_OF_TWO(qzbin_factor * quant, 7); 592 quants->y_zbin[q][i] = ROUND_POWER_OF_TWO(qzbin_factor * quant, 7);
593 quants->y_round[q][i] = (qrounding_factor * quant) >> 7; 593 quants->y_round[q][i] = (qrounding_factor * quant) >> 7;
594 cm->y_dequant[q][i] = quant; 594 cpi->y_dequant[q][i] = quant;
595 595
596 // uv 596 // uv
597 quant = i == 0 ? vp9_dc_quant(q, cm->uv_dc_delta_q, cm->bit_depth) 597 quant = i == 0 ? vp9_dc_quant(q, cm->uv_dc_delta_q, cm->bit_depth)
598 : vp9_ac_quant(q, cm->uv_ac_delta_q, cm->bit_depth); 598 : vp9_ac_quant(q, cm->uv_ac_delta_q, cm->bit_depth);
599 invert_quant(&quants->uv_quant[q][i], 599 invert_quant(&quants->uv_quant[q][i],
600 &quants->uv_quant_shift[q][i], quant); 600 &quants->uv_quant_shift[q][i], quant);
601 quants->uv_quant_fp[q][i] = (1 << 16) / quant; 601 quants->uv_quant_fp[q][i] = (1 << 16) / quant;
602 quants->uv_round_fp[q][i] = (qrounding_factor_fp * quant) >> 7; 602 quants->uv_round_fp[q][i] = (qrounding_factor_fp * quant) >> 7;
603 quants->uv_zbin[q][i] = ROUND_POWER_OF_TWO(qzbin_factor * quant, 7); 603 quants->uv_zbin[q][i] = ROUND_POWER_OF_TWO(qzbin_factor * quant, 7);
604 quants->uv_round[q][i] = (qrounding_factor * quant) >> 7; 604 quants->uv_round[q][i] = (qrounding_factor * quant) >> 7;
605 cm->uv_dequant[q][i] = quant; 605 cpi->uv_dequant[q][i] = quant;
606 } 606 }
607 607
608 for (i = 2; i < 8; i++) { 608 for (i = 2; i < 8; i++) {
609 quants->y_quant[q][i] = quants->y_quant[q][1]; 609 quants->y_quant[q][i] = quants->y_quant[q][1];
610 quants->y_quant_fp[q][i] = quants->y_quant_fp[q][1]; 610 quants->y_quant_fp[q][i] = quants->y_quant_fp[q][1];
611 quants->y_round_fp[q][i] = quants->y_round_fp[q][1]; 611 quants->y_round_fp[q][i] = quants->y_round_fp[q][1];
612 quants->y_quant_shift[q][i] = quants->y_quant_shift[q][1]; 612 quants->y_quant_shift[q][i] = quants->y_quant_shift[q][1];
613 quants->y_zbin[q][i] = quants->y_zbin[q][1]; 613 quants->y_zbin[q][i] = quants->y_zbin[q][1];
614 quants->y_round[q][i] = quants->y_round[q][1]; 614 quants->y_round[q][i] = quants->y_round[q][1];
615 cm->y_dequant[q][i] = cm->y_dequant[q][1]; 615 cpi->y_dequant[q][i] = cpi->y_dequant[q][1];
616 616
617 quants->uv_quant[q][i] = quants->uv_quant[q][1]; 617 quants->uv_quant[q][i] = quants->uv_quant[q][1];
618 quants->uv_quant_fp[q][i] = quants->uv_quant_fp[q][1]; 618 quants->uv_quant_fp[q][i] = quants->uv_quant_fp[q][1];
619 quants->uv_round_fp[q][i] = quants->uv_round_fp[q][1]; 619 quants->uv_round_fp[q][i] = quants->uv_round_fp[q][1];
620 quants->uv_quant_shift[q][i] = quants->uv_quant_shift[q][1]; 620 quants->uv_quant_shift[q][i] = quants->uv_quant_shift[q][1];
621 quants->uv_zbin[q][i] = quants->uv_zbin[q][1]; 621 quants->uv_zbin[q][i] = quants->uv_zbin[q][1];
622 quants->uv_round[q][i] = quants->uv_round[q][1]; 622 quants->uv_round[q][i] = quants->uv_round[q][1];
623 cm->uv_dequant[q][i] = cm->uv_dequant[q][1]; 623 cpi->uv_dequant[q][i] = cpi->uv_dequant[q][1];
624 } 624 }
625 } 625 }
626 } 626 }
627 627
628 void vp9_init_plane_quantizers(VP9_COMP *cpi, MACROBLOCK *x) { 628 void vp9_init_plane_quantizers(VP9_COMP *cpi, MACROBLOCK *x) {
629 const VP9_COMMON *const cm = &cpi->common; 629 const VP9_COMMON *const cm = &cpi->common;
630 MACROBLOCKD *const xd = &x->e_mbd; 630 MACROBLOCKD *const xd = &x->e_mbd;
631 QUANTS *const quants = &cpi->quants; 631 QUANTS *const quants = &cpi->quants;
632 const int segment_id = xd->mi[0].src_mi->mbmi.segment_id; 632 const int segment_id = xd->mi[0].src_mi->mbmi.segment_id;
633 const int qindex = vp9_get_qindex(&cm->seg, segment_id, cm->base_qindex); 633 const int qindex = vp9_get_qindex(&cm->seg, segment_id, cm->base_qindex);
634 const int rdmult = vp9_compute_rd_mult(cpi, qindex + cm->y_dc_delta_q); 634 const int rdmult = vp9_compute_rd_mult(cpi, qindex + cm->y_dc_delta_q);
635 int i; 635 int i;
636 636
637 // Y 637 // Y
638 x->plane[0].quant = quants->y_quant[qindex]; 638 x->plane[0].quant = quants->y_quant[qindex];
639 x->plane[0].quant_fp = quants->y_quant_fp[qindex]; 639 x->plane[0].quant_fp = quants->y_quant_fp[qindex];
640 x->plane[0].round_fp = quants->y_round_fp[qindex]; 640 x->plane[0].round_fp = quants->y_round_fp[qindex];
641 x->plane[0].quant_shift = quants->y_quant_shift[qindex]; 641 x->plane[0].quant_shift = quants->y_quant_shift[qindex];
642 x->plane[0].zbin = quants->y_zbin[qindex]; 642 x->plane[0].zbin = quants->y_zbin[qindex];
643 x->plane[0].round = quants->y_round[qindex]; 643 x->plane[0].round = quants->y_round[qindex];
644 xd->plane[0].dequant = cm->y_dequant[qindex]; 644 xd->plane[0].dequant = cpi->y_dequant[qindex];
645 645
646 x->plane[0].quant_thred[0] = x->plane[0].zbin[0] * x->plane[0].zbin[0]; 646 x->plane[0].quant_thred[0] = x->plane[0].zbin[0] * x->plane[0].zbin[0];
647 x->plane[0].quant_thred[1] = x->plane[0].zbin[1] * x->plane[0].zbin[1]; 647 x->plane[0].quant_thred[1] = x->plane[0].zbin[1] * x->plane[0].zbin[1];
648 648
649 // UV 649 // UV
650 for (i = 1; i < 3; i++) { 650 for (i = 1; i < 3; i++) {
651 x->plane[i].quant = quants->uv_quant[qindex]; 651 x->plane[i].quant = quants->uv_quant[qindex];
652 x->plane[i].quant_fp = quants->uv_quant_fp[qindex]; 652 x->plane[i].quant_fp = quants->uv_quant_fp[qindex];
653 x->plane[i].round_fp = quants->uv_round_fp[qindex]; 653 x->plane[i].round_fp = quants->uv_round_fp[qindex];
654 x->plane[i].quant_shift = quants->uv_quant_shift[qindex]; 654 x->plane[i].quant_shift = quants->uv_quant_shift[qindex];
655 x->plane[i].zbin = quants->uv_zbin[qindex]; 655 x->plane[i].zbin = quants->uv_zbin[qindex];
656 x->plane[i].round = quants->uv_round[qindex]; 656 x->plane[i].round = quants->uv_round[qindex];
657 xd->plane[i].dequant = cm->uv_dequant[qindex]; 657 xd->plane[i].dequant = cpi->uv_dequant[qindex];
658 658
659 x->plane[i].quant_thred[0] = x->plane[i].zbin[0] * x->plane[i].zbin[0]; 659 x->plane[i].quant_thred[0] = x->plane[i].zbin[0] * x->plane[i].zbin[0];
660 x->plane[i].quant_thred[1] = x->plane[i].zbin[1] * x->plane[i].zbin[1]; 660 x->plane[i].quant_thred[1] = x->plane[i].zbin[1] * x->plane[i].zbin[1];
661 } 661 }
662 662
663 x->skip_block = vp9_segfeature_active(&cm->seg, segment_id, SEG_LVL_SKIP); 663 x->skip_block = vp9_segfeature_active(&cm->seg, segment_id, SEG_LVL_SKIP);
664 x->q_index = qindex; 664 x->q_index = qindex;
665 665
666 x->errorperbit = rdmult >> 6; 666 x->errorperbit = rdmult >> 6;
667 x->errorperbit += (x->errorperbit == 0); 667 x->errorperbit += (x->errorperbit == 0);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 701
702 int vp9_qindex_to_quantizer(int qindex) { 702 int vp9_qindex_to_quantizer(int qindex) {
703 int quantizer; 703 int quantizer;
704 704
705 for (quantizer = 0; quantizer < 64; ++quantizer) 705 for (quantizer = 0; quantizer < 64; ++quantizer)
706 if (quantizer_to_qindex[quantizer] >= qindex) 706 if (quantizer_to_qindex[quantizer] >= qindex)
707 return quantizer; 707 return quantizer;
708 708
709 return 63; 709 return 63;
710 } 710 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_pickmode.c ('k') | source/libvpx/vp9/encoder/vp9_ratectrl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698