| 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 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |