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 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 cpi->UVround[Q][rc] = (qrounding_factors[Q] * quant_val) >> 7; | 580 cpi->UVround[Q][rc] = (qrounding_factors[Q] * quant_val) >> 7; |
581 cpi->common.UVdequant[Q][rc] = quant_val; | 581 cpi->common.UVdequant[Q][rc] = quant_val; |
582 cpi->zrun_zbin_boost_uv[Q][i] = (quant_val * zbin_boost[i]) >> 7; | 582 cpi->zrun_zbin_boost_uv[Q][i] = (quant_val * zbin_boost[i]) >> 7; |
583 } | 583 } |
584 } | 584 } |
585 } | 585 } |
586 #endif | 586 #endif |
587 | 587 |
588 #define ZBIN_EXTRA_Y \ | 588 #define ZBIN_EXTRA_Y \ |
589 (( cpi->common.Y1dequant[QIndex][1] * \ | 589 (( cpi->common.Y1dequant[QIndex][1] * \ |
590 ( cpi->zbin_over_quant + \ | 590 ( x->zbin_over_quant + \ |
591 cpi->zbin_mode_boost + \ | 591 x->zbin_mode_boost + \ |
592 x->act_zbin_adj ) ) >> 7) | 592 x->act_zbin_adj ) ) >> 7) |
593 | 593 |
594 #define ZBIN_EXTRA_UV \ | 594 #define ZBIN_EXTRA_UV \ |
595 (( cpi->common.UVdequant[QIndex][1] * \ | 595 (( cpi->common.UVdequant[QIndex][1] * \ |
596 ( cpi->zbin_over_quant + \ | 596 ( x->zbin_over_quant + \ |
597 cpi->zbin_mode_boost + \ | 597 x->zbin_mode_boost + \ |
598 x->act_zbin_adj ) ) >> 7) | 598 x->act_zbin_adj ) ) >> 7) |
599 | 599 |
600 #define ZBIN_EXTRA_Y2 \ | 600 #define ZBIN_EXTRA_Y2 \ |
601 (( cpi->common.Y2dequant[QIndex][1] * \ | 601 (( cpi->common.Y2dequant[QIndex][1] * \ |
602 ( (cpi->zbin_over_quant / 2) + \ | 602 ( (x->zbin_over_quant / 2) + \ |
603 cpi->zbin_mode_boost + \ | 603 x->zbin_mode_boost + \ |
604 x->act_zbin_adj ) ) >> 7) | 604 x->act_zbin_adj ) ) >> 7) |
605 | 605 |
606 void vp8cx_mb_init_quantizer(VP8_COMP *cpi, MACROBLOCK *x, int ok_to_skip) | 606 void vp8cx_mb_init_quantizer(VP8_COMP *cpi, MACROBLOCK *x, int ok_to_skip) |
607 { | 607 { |
608 int i; | 608 int i; |
609 int QIndex; | 609 int QIndex; |
610 MACROBLOCKD *xd = &x->e_mbd; | 610 MACROBLOCKD *xd = &x->e_mbd; |
611 int zbin_extra; | 611 int zbin_extra; |
612 | 612 |
613 /* Select the baseline MB Q index. */ | 613 /* Select the baseline MB Q index. */ |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 x->block[24].quant = cpi->Y2quant[QIndex]; | 695 x->block[24].quant = cpi->Y2quant[QIndex]; |
696 x->block[24].quant_shift = cpi->Y2quant_shift[QIndex]; | 696 x->block[24].quant_shift = cpi->Y2quant_shift[QIndex]; |
697 x->block[24].zbin = cpi->Y2zbin[QIndex]; | 697 x->block[24].zbin = cpi->Y2zbin[QIndex]; |
698 x->block[24].round = cpi->Y2round[QIndex]; | 698 x->block[24].round = cpi->Y2round[QIndex]; |
699 x->block[24].zrun_zbin_boost = cpi->zrun_zbin_boost_y2[QIndex]; | 699 x->block[24].zrun_zbin_boost = cpi->zrun_zbin_boost_y2[QIndex]; |
700 x->block[24].zbin_extra = (short)zbin_extra; | 700 x->block[24].zbin_extra = (short)zbin_extra; |
701 | 701 |
702 /* save this macroblock QIndex for vp8_update_zbin_extra() */ | 702 /* save this macroblock QIndex for vp8_update_zbin_extra() */ |
703 x->q_index = QIndex; | 703 x->q_index = QIndex; |
704 | 704 |
705 cpi->last_zbin_over_quant = cpi->zbin_over_quant; | 705 x->last_zbin_over_quant = x->zbin_over_quant; |
706 cpi->last_zbin_mode_boost = cpi->zbin_mode_boost; | 706 x->last_zbin_mode_boost = x->zbin_mode_boost; |
707 x->last_act_zbin_adj = x->act_zbin_adj; | 707 x->last_act_zbin_adj = x->act_zbin_adj; |
708 | 708 |
709 | 709 |
710 | 710 |
711 } | 711 } |
712 else if(cpi->last_zbin_over_quant != cpi->zbin_over_quant | 712 else if(x->last_zbin_over_quant != x->zbin_over_quant |
713 || cpi->last_zbin_mode_boost != cpi->zbin_mode_boost | 713 || x->last_zbin_mode_boost != x->zbin_mode_boost |
714 || x->last_act_zbin_adj != x->act_zbin_adj) | 714 || x->last_act_zbin_adj != x->act_zbin_adj) |
715 { | 715 { |
716 /* Y */ | 716 /* Y */ |
717 zbin_extra = ZBIN_EXTRA_Y; | 717 zbin_extra = ZBIN_EXTRA_Y; |
718 | 718 |
719 for (i = 0; i < 16; i++) | 719 for (i = 0; i < 16; i++) |
720 x->block[i].zbin_extra = (short)zbin_extra; | 720 x->block[i].zbin_extra = (short)zbin_extra; |
721 | 721 |
722 /* UV */ | 722 /* UV */ |
723 zbin_extra = ZBIN_EXTRA_UV; | 723 zbin_extra = ZBIN_EXTRA_UV; |
724 | 724 |
725 for (i = 16; i < 24; i++) | 725 for (i = 16; i < 24; i++) |
726 x->block[i].zbin_extra = (short)zbin_extra; | 726 x->block[i].zbin_extra = (short)zbin_extra; |
727 | 727 |
728 /* Y2 */ | 728 /* Y2 */ |
729 zbin_extra = ZBIN_EXTRA_Y2; | 729 zbin_extra = ZBIN_EXTRA_Y2; |
730 x->block[24].zbin_extra = (short)zbin_extra; | 730 x->block[24].zbin_extra = (short)zbin_extra; |
731 | 731 |
732 cpi->last_zbin_over_quant = cpi->zbin_over_quant; | 732 x->last_zbin_over_quant = x->zbin_over_quant; |
733 cpi->last_zbin_mode_boost = cpi->zbin_mode_boost; | 733 x->last_zbin_mode_boost = x->zbin_mode_boost; |
734 x->last_act_zbin_adj = x->act_zbin_adj; | 734 x->last_act_zbin_adj = x->act_zbin_adj; |
735 } | 735 } |
736 } | 736 } |
737 | 737 |
738 void vp8_update_zbin_extra(VP8_COMP *cpi, MACROBLOCK *x) | 738 void vp8_update_zbin_extra(VP8_COMP *cpi, MACROBLOCK *x) |
739 { | 739 { |
740 int i; | 740 int i; |
741 int QIndex = x->q_index; | 741 int QIndex = x->q_index; |
742 int zbin_extra; | 742 int zbin_extra; |
743 | 743 |
(...skipping 13 matching lines...) Expand all Loading... |
757 zbin_extra = ZBIN_EXTRA_Y2; | 757 zbin_extra = ZBIN_EXTRA_Y2; |
758 x->block[24].zbin_extra = (short)zbin_extra; | 758 x->block[24].zbin_extra = (short)zbin_extra; |
759 } | 759 } |
760 #undef ZBIN_EXTRA_Y | 760 #undef ZBIN_EXTRA_Y |
761 #undef ZBIN_EXTRA_UV | 761 #undef ZBIN_EXTRA_UV |
762 #undef ZBIN_EXTRA_Y2 | 762 #undef ZBIN_EXTRA_Y2 |
763 | 763 |
764 void vp8cx_frame_init_quantizer(VP8_COMP *cpi) | 764 void vp8cx_frame_init_quantizer(VP8_COMP *cpi) |
765 { | 765 { |
766 /* Clear Zbin mode boost for default case */ | 766 /* Clear Zbin mode boost for default case */ |
767 cpi->zbin_mode_boost = 0; | 767 cpi->mb.zbin_mode_boost = 0; |
768 | 768 |
769 /* MB level quantizer setup */ | 769 /* MB level quantizer setup */ |
770 vp8cx_mb_init_quantizer(cpi, &cpi->mb, 0); | 770 vp8cx_mb_init_quantizer(cpi, &cpi->mb, 0); |
771 } | 771 } |
772 | 772 |
773 | 773 |
774 void vp8_set_quantizer(struct VP8_COMP *cpi, int Q) | 774 void vp8_set_quantizer(struct VP8_COMP *cpi, int Q) |
775 { | 775 { |
776 VP8_COMMON *cm = &cpi->common; | 776 VP8_COMMON *cm = &cpi->common; |
777 MACROBLOCKD *mbd = &cpi->mb.e_mbd; | 777 MACROBLOCKD *mbd = &cpi->mb.e_mbd; |
(...skipping 24 matching lines...) Expand all Loading... |
802 mbd->segment_feature_data[MB_LVL_ALT_Q][0] = cpi->segment_feature_data[MB_LV
L_ALT_Q][0]; | 802 mbd->segment_feature_data[MB_LVL_ALT_Q][0] = cpi->segment_feature_data[MB_LV
L_ALT_Q][0]; |
803 mbd->segment_feature_data[MB_LVL_ALT_Q][1] = cpi->segment_feature_data[MB_LV
L_ALT_Q][1]; | 803 mbd->segment_feature_data[MB_LVL_ALT_Q][1] = cpi->segment_feature_data[MB_LV
L_ALT_Q][1]; |
804 mbd->segment_feature_data[MB_LVL_ALT_Q][2] = cpi->segment_feature_data[MB_LV
L_ALT_Q][2]; | 804 mbd->segment_feature_data[MB_LVL_ALT_Q][2] = cpi->segment_feature_data[MB_LV
L_ALT_Q][2]; |
805 mbd->segment_feature_data[MB_LVL_ALT_Q][3] = cpi->segment_feature_data[MB_LV
L_ALT_Q][3]; | 805 mbd->segment_feature_data[MB_LVL_ALT_Q][3] = cpi->segment_feature_data[MB_LV
L_ALT_Q][3]; |
806 | 806 |
807 /* quantizer has to be reinitialized for any delta_q changes */ | 807 /* quantizer has to be reinitialized for any delta_q changes */ |
808 if(update) | 808 if(update) |
809 vp8cx_init_quantizer(cpi); | 809 vp8cx_init_quantizer(cpi); |
810 | 810 |
811 } | 811 } |
OLD | NEW |