| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 VP8_COMMON *const x = & cpi->common; | 111 VP8_COMMON *const x = & cpi->common; |
| 112 | 112 |
| 113 vp8_writer *const w = cpi->bc; | 113 vp8_writer *const w = cpi->bc; |
| 114 | 114 |
| 115 { | 115 { |
| 116 vp8_prob Pnew [VP8_YMODES-1]; | 116 vp8_prob Pnew [VP8_YMODES-1]; |
| 117 unsigned int bct [VP8_YMODES-1] [2]; | 117 unsigned int bct [VP8_YMODES-1] [2]; |
| 118 | 118 |
| 119 update_mode( | 119 update_mode( |
| 120 w, VP8_YMODES, vp8_ymode_encodings, vp8_ymode_tree, | 120 w, VP8_YMODES, vp8_ymode_encodings, vp8_ymode_tree, |
| 121 Pnew, x->fc.ymode_prob, bct, (unsigned int *)cpi->mb.ymode_count | 121 Pnew, x->fc.ymode_prob, bct, (unsigned int *)cpi->ymode_count |
| 122 ); | 122 ); |
| 123 } | 123 } |
| 124 { | 124 { |
| 125 vp8_prob Pnew [VP8_UV_MODES-1]; | 125 vp8_prob Pnew [VP8_UV_MODES-1]; |
| 126 unsigned int bct [VP8_UV_MODES-1] [2]; | 126 unsigned int bct [VP8_UV_MODES-1] [2]; |
| 127 | 127 |
| 128 update_mode( | 128 update_mode( |
| 129 w, VP8_UV_MODES, vp8_uv_mode_encodings, vp8_uv_mode_tree, | 129 w, VP8_UV_MODES, vp8_uv_mode_encodings, vp8_uv_mode_tree, |
| 130 Pnew, x->fc.uv_mode_prob, bct, (unsigned int *)cpi->mb.uv_mode_count | 130 Pnew, x->fc.uv_mode_prob, bct, (unsigned int *)cpi->uv_mode_count |
| 131 ); | 131 ); |
| 132 } | 132 } |
| 133 } | 133 } |
| 134 | 134 |
| 135 static void write_ymode(vp8_writer *bc, int m, const vp8_prob *p) | 135 static void write_ymode(vp8_writer *bc, int m, const vp8_prob *p) |
| 136 { | 136 { |
| 137 vp8_write_token(bc, vp8_ymode_tree, p, vp8_ymode_encodings + m); | 137 vp8_write_token(bc, vp8_ymode_tree, p, vp8_ymode_encodings + m); |
| 138 } | 138 } |
| 139 | 139 |
| 140 static void kfwrite_ymode(vp8_writer *bc, int m, const vp8_prob *p) | 140 static void kfwrite_ymode(vp8_writer *bc, int m, const vp8_prob *p) |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 vp8_convert_rfct_to_prob(cpi); | 532 vp8_convert_rfct_to_prob(cpi); |
| 533 | 533 |
| 534 #ifdef ENTROPY_STATS | 534 #ifdef ENTROPY_STATS |
| 535 active_section = 1; | 535 active_section = 1; |
| 536 #endif | 536 #endif |
| 537 | 537 |
| 538 if (pc->mb_no_coeff_skip) | 538 if (pc->mb_no_coeff_skip) |
| 539 { | 539 { |
| 540 int total_mbs = pc->mb_rows * pc->mb_cols; | 540 int total_mbs = pc->mb_rows * pc->mb_cols; |
| 541 | 541 |
| 542 prob_skip_false = (total_mbs - cpi->mb.skip_true_count ) * 256 / total_m
bs; | 542 prob_skip_false = (total_mbs - cpi->skip_true_count ) * 256 / total_mbs; |
| 543 | 543 |
| 544 if (prob_skip_false <= 1) | 544 if (prob_skip_false <= 1) |
| 545 prob_skip_false = 1; | 545 prob_skip_false = 1; |
| 546 | 546 |
| 547 if (prob_skip_false > 255) | 547 if (prob_skip_false > 255) |
| 548 prob_skip_false = 255; | 548 prob_skip_false = 255; |
| 549 | 549 |
| 550 cpi->prob_skip_false = prob_skip_false; | 550 cpi->prob_skip_false = prob_skip_false; |
| 551 vp8_write_literal(w, prob_skip_false, 8); | 551 vp8_write_literal(w, prob_skip_false, 8); |
| 552 } | 552 } |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 /* const */ | 723 /* const */ |
| 724 MODE_INFO *m = c->mi; | 724 MODE_INFO *m = c->mi; |
| 725 | 725 |
| 726 int mb_row = -1; | 726 int mb_row = -1; |
| 727 int prob_skip_false = 0; | 727 int prob_skip_false = 0; |
| 728 | 728 |
| 729 if (c->mb_no_coeff_skip) | 729 if (c->mb_no_coeff_skip) |
| 730 { | 730 { |
| 731 int total_mbs = c->mb_rows * c->mb_cols; | 731 int total_mbs = c->mb_rows * c->mb_cols; |
| 732 | 732 |
| 733 prob_skip_false = (total_mbs - cpi->mb.skip_true_count ) * 256 / total_m
bs; | 733 prob_skip_false = (total_mbs - cpi->skip_true_count ) * 256 / total_mbs; |
| 734 | 734 |
| 735 if (prob_skip_false <= 1) | 735 if (prob_skip_false <= 1) |
| 736 prob_skip_false = 1; | 736 prob_skip_false = 1; |
| 737 | 737 |
| 738 if (prob_skip_false >= 255) | 738 if (prob_skip_false >= 255) |
| 739 prob_skip_false = 255; | 739 prob_skip_false = 255; |
| 740 | 740 |
| 741 cpi->prob_skip_false = prob_skip_false; | 741 cpi->prob_skip_false = prob_skip_false; |
| 742 vp8_write_literal(bc, prob_skip_false, 8); | 742 vp8_write_literal(bc, prob_skip_false, 8); |
| 743 } | 743 } |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 const int old_b = vp8_cost_branch(ct, oldp); | 844 const int old_b = vp8_cost_branch(ct, oldp); |
| 845 const int new_b = vp8_cost_branch(ct, newp); | 845 const int new_b = vp8_cost_branch(ct, newp); |
| 846 const int update_b = 8 + | 846 const int update_b = 8 + |
| 847 ((vp8_cost_one(upd) - vp8_cost_zero(upd)) >> 8); | 847 ((vp8_cost_one(upd) - vp8_cost_zero(upd)) >> 8); |
| 848 | 848 |
| 849 return old_b - new_b - update_b; | 849 return old_b - new_b - update_b; |
| 850 } | 850 } |
| 851 | 851 |
| 852 static int independent_coef_context_savings(VP8_COMP *cpi) | 852 static int independent_coef_context_savings(VP8_COMP *cpi) |
| 853 { | 853 { |
| 854 MACROBLOCK *const x = & cpi->mb; | |
| 855 int savings = 0; | 854 int savings = 0; |
| 856 int i = 0; | 855 int i = 0; |
| 857 do | 856 do |
| 858 { | 857 { |
| 859 int j = 0; | 858 int j = 0; |
| 860 do | 859 do |
| 861 { | 860 { |
| 862 int k = 0; | 861 int k = 0; |
| 863 unsigned int prev_coef_count_sum[MAX_ENTROPY_TOKENS] = {0}; | 862 unsigned int prev_coef_count_sum[MAX_ENTROPY_TOKENS] = {0}; |
| 864 int prev_coef_savings[MAX_ENTROPY_TOKENS] = {0}; | 863 int prev_coef_savings[MAX_ENTROPY_TOKENS] = {0}; |
| 865 const unsigned int (*probs)[MAX_ENTROPY_TOKENS]; | 864 const unsigned int (*probs)[MAX_ENTROPY_TOKENS]; |
| 866 /* Calculate new probabilities given the constraint that | 865 /* Calculate new probabilities given the constraint that |
| 867 * they must be equal over the prev coef contexts | 866 * they must be equal over the prev coef contexts |
| 868 */ | 867 */ |
| 869 | 868 |
| 870 probs = (const unsigned int (*)[MAX_ENTROPY_TOKENS]) | 869 probs = (const unsigned int (*)[MAX_ENTROPY_TOKENS]) |
| 871 x->coef_counts[i][j]; | 870 cpi->coef_counts[i][j]; |
| 872 | 871 |
| 873 /* Reset to default probabilities at key frames */ | 872 /* Reset to default probabilities at key frames */ |
| 874 if (cpi->common.frame_type == KEY_FRAME) | 873 if (cpi->common.frame_type == KEY_FRAME) |
| 875 probs = default_coef_counts[i][j]; | 874 probs = default_coef_counts[i][j]; |
| 876 | 875 |
| 877 sum_probs_over_prev_coef_context(probs, prev_coef_count_sum); | 876 sum_probs_over_prev_coef_context(probs, prev_coef_count_sum); |
| 878 | 877 |
| 879 do | 878 do |
| 880 { | 879 { |
| 881 /* at every context */ | 880 /* at every context */ |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 920 while (++k < ENTROPY_NODES); | 919 while (++k < ENTROPY_NODES); |
| 921 } | 920 } |
| 922 while (++j < COEF_BANDS); | 921 while (++j < COEF_BANDS); |
| 923 } | 922 } |
| 924 while (++i < BLOCK_TYPES); | 923 while (++i < BLOCK_TYPES); |
| 925 return savings; | 924 return savings; |
| 926 } | 925 } |
| 927 | 926 |
| 928 static int default_coef_context_savings(VP8_COMP *cpi) | 927 static int default_coef_context_savings(VP8_COMP *cpi) |
| 929 { | 928 { |
| 930 MACROBLOCK *const x = & cpi->mb; | |
| 931 int savings = 0; | 929 int savings = 0; |
| 932 int i = 0; | 930 int i = 0; |
| 933 do | 931 do |
| 934 { | 932 { |
| 935 int j = 0; | 933 int j = 0; |
| 936 do | 934 do |
| 937 { | 935 { |
| 938 int k = 0; | 936 int k = 0; |
| 939 do | 937 do |
| 940 { | 938 { |
| 941 /* at every context */ | 939 /* at every context */ |
| 942 | 940 |
| 943 /* calc probs and branch cts for this frame only */ | 941 /* calc probs and branch cts for this frame only */ |
| 944 int t = 0; /* token/prob index */ | 942 int t = 0; /* token/prob index */ |
| 945 | 943 |
| 946 vp8_tree_probs_from_distribution( | 944 vp8_tree_probs_from_distribution( |
| 947 MAX_ENTROPY_TOKENS, vp8_coef_encodings, vp8_coef_tree, | 945 MAX_ENTROPY_TOKENS, vp8_coef_encodings, vp8_coef_tree, |
| 948 cpi->frame_coef_probs [i][j][k], | 946 cpi->frame_coef_probs [i][j][k], |
| 949 cpi->frame_branch_ct [i][j][k], | 947 cpi->frame_branch_ct [i][j][k], |
| 950 x->coef_counts [i][j][k], | 948 cpi->coef_counts [i][j][k], |
| 951 256, 1 | 949 256, 1 |
| 952 ); | 950 ); |
| 953 | 951 |
| 954 do | 952 do |
| 955 { | 953 { |
| 956 const unsigned int *ct = cpi->frame_branch_ct [i][j][k][t]; | 954 const unsigned int *ct = cpi->frame_branch_ct [i][j][k][t]; |
| 957 const vp8_prob newp = cpi->frame_coef_probs [i][j][k][t]; | 955 const vp8_prob newp = cpi->frame_coef_probs [i][j][k][t]; |
| 958 const vp8_prob oldp = cpi->common.fc.coef_probs [i][j][k][t]
; | 956 const vp8_prob oldp = cpi->common.fc.coef_probs [i][j][k][t]
; |
| 959 const vp8_prob upd = vp8_coef_update_probs [i][j][k][t]; | 957 const vp8_prob upd = vp8_coef_update_probs [i][j][k][t]; |
| 960 const int s = prob_update_savings(ct, oldp, newp, upd); | 958 const int s = prob_update_savings(ct, oldp, newp, upd); |
| (...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1723 fprintf(f, " },\n"); | 1721 fprintf(f, " },\n"); |
| 1724 } | 1722 } |
| 1725 | 1723 |
| 1726 fprintf(f, " },\n"); | 1724 fprintf(f, " },\n"); |
| 1727 } | 1725 } |
| 1728 | 1726 |
| 1729 fprintf(f, "};\n"); | 1727 fprintf(f, "};\n"); |
| 1730 fclose(f); | 1728 fclose(f); |
| 1731 } | 1729 } |
| 1732 #endif | 1730 #endif |
| OLD | NEW |