| 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 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 #include "vp9/encoder/vp9_cost.h" | 22 #include "vp9/encoder/vp9_cost.h" |
| 23 #include "vp9/encoder/vp9_encoder.h" | 23 #include "vp9/encoder/vp9_encoder.h" |
| 24 #include "vp9/encoder/vp9_tokenize.h" | 24 #include "vp9/encoder/vp9_tokenize.h" |
| 25 | 25 |
| 26 static TOKENVALUE dct_value_tokens[DCT_MAX_VALUE * 2]; | 26 static TOKENVALUE dct_value_tokens[DCT_MAX_VALUE * 2]; |
| 27 const TOKENVALUE *vp9_dct_value_tokens_ptr; | 27 const TOKENVALUE *vp9_dct_value_tokens_ptr; |
| 28 static int16_t dct_value_cost[DCT_MAX_VALUE * 2]; | 28 static int16_t dct_value_cost[DCT_MAX_VALUE * 2]; |
| 29 const int16_t *vp9_dct_value_cost_ptr; | 29 const int16_t *vp9_dct_value_cost_ptr; |
| 30 | 30 |
| 31 #if CONFIG_VP9_HIGHBITDEPTH |
| 32 static TOKENVALUE dct_value_tokens_high10[DCT_MAX_VALUE_HIGH10 * 2]; |
| 33 const TOKENVALUE *vp9_dct_value_tokens_high10_ptr; |
| 34 static int16_t dct_value_cost_high10[DCT_MAX_VALUE_HIGH10 * 2]; |
| 35 const int16_t *vp9_dct_value_cost_high10_ptr; |
| 36 |
| 37 static TOKENVALUE dct_value_tokens_high12[DCT_MAX_VALUE_HIGH12 * 2]; |
| 38 const TOKENVALUE *vp9_dct_value_tokens_high12_ptr; |
| 39 static int16_t dct_value_cost_high12[DCT_MAX_VALUE_HIGH12 * 2]; |
| 40 const int16_t *vp9_dct_value_cost_high12_ptr; |
| 41 #endif |
| 42 |
| 31 // Array indices are identical to previously-existing CONTEXT_NODE indices | 43 // Array indices are identical to previously-existing CONTEXT_NODE indices |
| 32 const vp9_tree_index vp9_coef_tree[TREE_SIZE(ENTROPY_TOKENS)] = { | 44 const vp9_tree_index vp9_coef_tree[TREE_SIZE(ENTROPY_TOKENS)] = { |
| 33 -EOB_TOKEN, 2, // 0 = EOB | 45 -EOB_TOKEN, 2, // 0 = EOB |
| 34 -ZERO_TOKEN, 4, // 1 = ZERO | 46 -ZERO_TOKEN, 4, // 1 = ZERO |
| 35 -ONE_TOKEN, 6, // 2 = ONE | 47 -ONE_TOKEN, 6, // 2 = ONE |
| 36 8, 12, // 3 = LOW_VAL | 48 8, 12, // 3 = LOW_VAL |
| 37 -TWO_TOKEN, 10, // 4 = TWO | 49 -TWO_TOKEN, 10, // 4 = TWO |
| 38 -THREE_TOKEN, -FOUR_TOKEN, // 5 = THREE | 50 -THREE_TOKEN, -FOUR_TOKEN, // 5 = THREE |
| 39 14, 16, // 6 = HIGH_LOW | 51 14, 16, // 6 = HIGH_LOW |
| 40 -CATEGORY1_TOKEN, -CATEGORY2_TOKEN, // 7 = CAT_ONE | 52 -CATEGORY1_TOKEN, -CATEGORY2_TOKEN, // 7 = CAT_ONE |
| 41 18, 20, // 8 = CAT_THREEFOUR | 53 18, 20, // 8 = CAT_THREEFOUR |
| 42 -CATEGORY3_TOKEN, -CATEGORY4_TOKEN, // 9 = CAT_THREE | 54 -CATEGORY3_TOKEN, -CATEGORY4_TOKEN, // 9 = CAT_THREE |
| 43 -CATEGORY5_TOKEN, -CATEGORY6_TOKEN // 10 = CAT_FIVE | 55 -CATEGORY5_TOKEN, -CATEGORY6_TOKEN // 10 = CAT_FIVE |
| 44 }; | 56 }; |
| 45 | 57 |
| 46 // Unconstrained Node Tree | 58 // Unconstrained Node Tree |
| 47 const vp9_tree_index vp9_coef_con_tree[TREE_SIZE(ENTROPY_TOKENS)] = { | 59 const vp9_tree_index vp9_coef_con_tree[TREE_SIZE(ENTROPY_TOKENS)] = { |
| 48 2, 6, // 0 = LOW_VAL | 60 2, 6, // 0 = LOW_VAL |
| 49 -TWO_TOKEN, 4, // 1 = TWO | 61 -TWO_TOKEN, 4, // 1 = TWO |
| 50 -THREE_TOKEN, -FOUR_TOKEN, // 2 = THREE | 62 -THREE_TOKEN, -FOUR_TOKEN, // 2 = THREE |
| 51 8, 10, // 3 = HIGH_LOW | 63 8, 10, // 3 = HIGH_LOW |
| 52 -CATEGORY1_TOKEN, -CATEGORY2_TOKEN, // 4 = CAT_ONE | 64 -CATEGORY1_TOKEN, -CATEGORY2_TOKEN, // 4 = CAT_ONE |
| 53 12, 14, // 5 = CAT_THREEFOUR | 65 12, 14, // 5 = CAT_THREEFOUR |
| 54 -CATEGORY3_TOKEN, -CATEGORY4_TOKEN, // 6 = CAT_THREE | 66 -CATEGORY3_TOKEN, -CATEGORY4_TOKEN, // 6 = CAT_THREE |
| 55 -CATEGORY5_TOKEN, -CATEGORY6_TOKEN // 7 = CAT_FIVE | 67 -CATEGORY5_TOKEN, -CATEGORY6_TOKEN // 7 = CAT_FIVE |
| 56 }; | 68 }; |
| 57 | 69 |
| 58 static vp9_tree_index cat1[2], cat2[4], cat3[6], cat4[8], cat5[10], cat6[28]; | 70 static vp9_tree_index cat1[2], cat2[4], cat3[6], cat4[8], cat5[10], cat6[28]; |
| 59 | 71 |
| 72 #if CONFIG_VP9_HIGHBITDEPTH |
| 73 static vp9_tree_index cat1_high10[2]; |
| 74 static vp9_tree_index cat2_high10[4]; |
| 75 static vp9_tree_index cat3_high10[6]; |
| 76 static vp9_tree_index cat4_high10[8]; |
| 77 static vp9_tree_index cat5_high10[10]; |
| 78 static vp9_tree_index cat6_high10[32]; |
| 79 static vp9_tree_index cat1_high12[2]; |
| 80 static vp9_tree_index cat2_high12[4]; |
| 81 static vp9_tree_index cat3_high12[6]; |
| 82 static vp9_tree_index cat4_high12[8]; |
| 83 static vp9_tree_index cat5_high12[10]; |
| 84 static vp9_tree_index cat6_high12[36]; |
| 85 #endif |
| 86 |
| 60 static void init_bit_tree(vp9_tree_index *p, int n) { | 87 static void init_bit_tree(vp9_tree_index *p, int n) { |
| 61 int i = 0; | 88 int i = 0; |
| 62 | 89 |
| 63 while (++i < n) { | 90 while (++i < n) { |
| 64 p[0] = p[1] = i << 1; | 91 p[0] = p[1] = i << 1; |
| 65 p += 2; | 92 p += 2; |
| 66 } | 93 } |
| 67 | 94 |
| 68 p[0] = p[1] = 0; | 95 p[0] = p[1] = 0; |
| 69 } | 96 } |
| 70 | 97 |
| 71 static void init_bit_trees() { | 98 static void init_bit_trees() { |
| 72 init_bit_tree(cat1, 1); | 99 init_bit_tree(cat1, 1); |
| 73 init_bit_tree(cat2, 2); | 100 init_bit_tree(cat2, 2); |
| 74 init_bit_tree(cat3, 3); | 101 init_bit_tree(cat3, 3); |
| 75 init_bit_tree(cat4, 4); | 102 init_bit_tree(cat4, 4); |
| 76 init_bit_tree(cat5, 5); | 103 init_bit_tree(cat5, 5); |
| 77 init_bit_tree(cat6, 14); | 104 init_bit_tree(cat6, 14); |
| 105 #if CONFIG_VP9_HIGHBITDEPTH |
| 106 init_bit_tree(cat1_high10, 1); |
| 107 init_bit_tree(cat2_high10, 2); |
| 108 init_bit_tree(cat3_high10, 3); |
| 109 init_bit_tree(cat4_high10, 4); |
| 110 init_bit_tree(cat5_high10, 5); |
| 111 init_bit_tree(cat6_high10, 16); |
| 112 init_bit_tree(cat1_high12, 1); |
| 113 init_bit_tree(cat2_high12, 2); |
| 114 init_bit_tree(cat3_high12, 3); |
| 115 init_bit_tree(cat4_high12, 4); |
| 116 init_bit_tree(cat5_high12, 5); |
| 117 init_bit_tree(cat6_high12, 18); |
| 118 #endif |
| 78 } | 119 } |
| 79 | 120 |
| 80 const vp9_extra_bit vp9_extra_bits[ENTROPY_TOKENS] = { | 121 const vp9_extra_bit vp9_extra_bits[ENTROPY_TOKENS] = { |
| 81 {0, 0, 0, 0}, // ZERO_TOKEN | 122 {0, 0, 0, 0}, // ZERO_TOKEN |
| 82 {0, 0, 0, 1}, // ONE_TOKEN | 123 {0, 0, 0, 1}, // ONE_TOKEN |
| 83 {0, 0, 0, 2}, // TWO_TOKEN | 124 {0, 0, 0, 2}, // TWO_TOKEN |
| 84 {0, 0, 0, 3}, // THREE_TOKEN | 125 {0, 0, 0, 3}, // THREE_TOKEN |
| 85 {0, 0, 0, 4}, // FOUR_TOKEN | 126 {0, 0, 0, 4}, // FOUR_TOKEN |
| 86 {cat1, vp9_cat1_prob, 1, CAT1_MIN_VAL}, // CATEGORY1_TOKEN | 127 {cat1, vp9_cat1_prob, 1, CAT1_MIN_VAL}, // CATEGORY1_TOKEN |
| 87 {cat2, vp9_cat2_prob, 2, CAT2_MIN_VAL}, // CATEGORY2_TOKEN | 128 {cat2, vp9_cat2_prob, 2, CAT2_MIN_VAL}, // CATEGORY2_TOKEN |
| 88 {cat3, vp9_cat3_prob, 3, CAT3_MIN_VAL}, // CATEGORY3_TOKEN | 129 {cat3, vp9_cat3_prob, 3, CAT3_MIN_VAL}, // CATEGORY3_TOKEN |
| 89 {cat4, vp9_cat4_prob, 4, CAT4_MIN_VAL}, // CATEGORY4_TOKEN | 130 {cat4, vp9_cat4_prob, 4, CAT4_MIN_VAL}, // CATEGORY4_TOKEN |
| 90 {cat5, vp9_cat5_prob, 5, CAT5_MIN_VAL}, // CATEGORY5_TOKEN | 131 {cat5, vp9_cat5_prob, 5, CAT5_MIN_VAL}, // CATEGORY5_TOKEN |
| 91 {cat6, vp9_cat6_prob, 14, CAT6_MIN_VAL}, // CATEGORY6_TOKEN | 132 {cat6, vp9_cat6_prob, 14, CAT6_MIN_VAL}, // CATEGORY6_TOKEN |
| 92 {0, 0, 0, 0} // EOB_TOKEN | 133 {0, 0, 0, 0} // EOB_TOKEN |
| 93 }; | 134 }; |
| 94 | 135 |
| 136 #if CONFIG_VP9_HIGHBITDEPTH |
| 137 const vp9_extra_bit vp9_extra_bits_high10[ENTROPY_TOKENS] = { |
| 138 {0, 0, 0, 0}, // ZERO_TOKEN |
| 139 {0, 0, 0, 1}, // ONE_TOKEN |
| 140 {0, 0, 0, 2}, // TWO_TOKEN |
| 141 {0, 0, 0, 3}, // THREE_TOKEN |
| 142 {0, 0, 0, 4}, // FOUR_TOKEN |
| 143 {cat1_high10, vp9_cat1_prob_high10, 1, CAT1_MIN_VAL}, // CATEGORY1_TOKEN |
| 144 {cat2_high10, vp9_cat2_prob_high10, 2, CAT2_MIN_VAL}, // CATEGORY2_TOKEN |
| 145 {cat3_high10, vp9_cat3_prob_high10, 3, CAT3_MIN_VAL}, // CATEGORY3_TOKEN |
| 146 {cat4_high10, vp9_cat4_prob_high10, 4, CAT4_MIN_VAL}, // CATEGORY4_TOKEN |
| 147 {cat5_high10, vp9_cat5_prob_high10, 5, CAT5_MIN_VAL}, // CATEGORY5_TOKEN |
| 148 {cat6_high10, vp9_cat6_prob_high10, 16, CAT6_MIN_VAL}, // CATEGORY6_TOKEN |
| 149 {0, 0, 0, 0} // EOB_TOKEN |
| 150 }; |
| 151 const vp9_extra_bit vp9_extra_bits_high12[ENTROPY_TOKENS] = { |
| 152 {0, 0, 0, 0}, // ZERO_TOKEN |
| 153 {0, 0, 0, 1}, // ONE_TOKEN |
| 154 {0, 0, 0, 2}, // TWO_TOKEN |
| 155 {0, 0, 0, 3}, // THREE_TOKEN |
| 156 {0, 0, 0, 4}, // FOUR_TOKEN |
| 157 {cat1_high12, vp9_cat1_prob_high12, 1, CAT1_MIN_VAL}, // CATEGORY1_TOKEN |
| 158 {cat2_high12, vp9_cat2_prob_high12, 2, CAT2_MIN_VAL}, // CATEGORY2_TOKEN |
| 159 {cat3_high12, vp9_cat3_prob_high12, 3, CAT3_MIN_VAL}, // CATEGORY3_TOKEN |
| 160 {cat4_high12, vp9_cat4_prob_high12, 4, CAT4_MIN_VAL}, // CATEGORY4_TOKEN |
| 161 {cat5_high12, vp9_cat5_prob_high12, 5, CAT5_MIN_VAL}, // CATEGORY5_TOKEN |
| 162 {cat6_high12, vp9_cat6_prob_high12, 18, CAT6_MIN_VAL}, // CATEGORY6_TOKEN |
| 163 {0, 0, 0, 0} // EOB_TOKEN |
| 164 }; |
| 165 #endif |
| 166 |
| 95 struct vp9_token vp9_coef_encodings[ENTROPY_TOKENS]; | 167 struct vp9_token vp9_coef_encodings[ENTROPY_TOKENS]; |
| 96 | 168 |
| 97 void vp9_coef_tree_initialize() { | 169 void vp9_coef_tree_initialize() { |
| 98 init_bit_trees(); | 170 init_bit_trees(); |
| 99 vp9_tokens_from_tree(vp9_coef_encodings, vp9_coef_tree); | 171 vp9_tokens_from_tree(vp9_coef_encodings, vp9_coef_tree); |
| 100 } | 172 } |
| 101 | 173 |
| 102 void vp9_tokenize_initialize() { | 174 static void tokenize_init_one(TOKENVALUE *t, const vp9_extra_bit *const e, |
| 103 TOKENVALUE *const t = dct_value_tokens + DCT_MAX_VALUE; | 175 int16_t *value_cost, int max_value) { |
| 104 const vp9_extra_bit *const e = vp9_extra_bits; | 176 int i = -max_value; |
| 105 | |
| 106 int i = -DCT_MAX_VALUE; | |
| 107 int sign = 1; | 177 int sign = 1; |
| 108 | 178 |
| 109 do { | 179 do { |
| 110 if (!i) | 180 if (!i) |
| 111 sign = 0; | 181 sign = 0; |
| 112 | 182 |
| 113 { | 183 { |
| 114 const int a = sign ? -i : i; | 184 const int a = sign ? -i : i; |
| 115 int eb = sign; | 185 int eb = sign; |
| 116 | 186 |
| 117 if (a > 4) { | 187 if (a > 4) { |
| 118 int j = 4; | 188 int j = 4; |
| 119 | 189 |
| 120 while (++j < 11 && e[j].base_val <= a) {} | 190 while (++j < 11 && e[j].base_val <= a) {} |
| 121 | 191 |
| 122 t[i].token = --j; | 192 t[i].token = --j; |
| 123 eb |= (a - e[j].base_val) << 1; | 193 eb |= (a - e[j].base_val) << 1; |
| 124 } else { | 194 } else { |
| 125 t[i].token = a; | 195 t[i].token = a; |
| 126 } | 196 } |
| 127 t[i].extra = eb; | 197 t[i].extra = eb; |
| 128 } | 198 } |
| 129 | 199 |
| 130 // initialize the cost for extra bits for all possible coefficient value. | 200 // initialize the cost for extra bits for all possible coefficient value. |
| 131 { | 201 { |
| 132 int cost = 0; | 202 int cost = 0; |
| 133 const vp9_extra_bit *p = &vp9_extra_bits[t[i].token]; | 203 const vp9_extra_bit *p = &e[t[i].token]; |
| 134 | 204 |
| 135 if (p->base_val) { | 205 if (p->base_val) { |
| 136 const int extra = t[i].extra; | 206 const int extra = t[i].extra; |
| 137 const int length = p->len; | 207 const int length = p->len; |
| 138 | 208 |
| 139 if (length) | 209 if (length) |
| 140 cost += treed_cost(p->tree, p->prob, extra >> 1, length); | 210 cost += treed_cost(p->tree, p->prob, extra >> 1, length); |
| 141 | 211 |
| 142 cost += vp9_cost_bit(vp9_prob_half, extra & 1); /* sign */ | 212 cost += vp9_cost_bit(vp9_prob_half, extra & 1); /* sign */ |
| 143 dct_value_cost[i + DCT_MAX_VALUE] = cost; | 213 value_cost[i] = cost; |
| 144 } | 214 } |
| 145 } | 215 } |
| 146 } while (++i < DCT_MAX_VALUE); | 216 } while (++i < max_value); |
| 217 } |
| 147 | 218 |
| 219 void vp9_tokenize_initialize() { |
| 148 vp9_dct_value_tokens_ptr = dct_value_tokens + DCT_MAX_VALUE; | 220 vp9_dct_value_tokens_ptr = dct_value_tokens + DCT_MAX_VALUE; |
| 149 vp9_dct_value_cost_ptr = dct_value_cost + DCT_MAX_VALUE; | 221 vp9_dct_value_cost_ptr = dct_value_cost + DCT_MAX_VALUE; |
| 222 |
| 223 tokenize_init_one(dct_value_tokens + DCT_MAX_VALUE, vp9_extra_bits, |
| 224 dct_value_cost + DCT_MAX_VALUE, DCT_MAX_VALUE); |
| 225 #if CONFIG_VP9_HIGHBITDEPTH |
| 226 vp9_dct_value_tokens_high10_ptr = dct_value_tokens_high10 + |
| 227 DCT_MAX_VALUE_HIGH10; |
| 228 vp9_dct_value_cost_high10_ptr = dct_value_cost_high10 + DCT_MAX_VALUE_HIGH10; |
| 229 |
| 230 tokenize_init_one(dct_value_tokens_high10 + DCT_MAX_VALUE_HIGH10, |
| 231 vp9_extra_bits_high10, |
| 232 dct_value_cost_high10 + DCT_MAX_VALUE_HIGH10, |
| 233 DCT_MAX_VALUE_HIGH10); |
| 234 vp9_dct_value_tokens_high12_ptr = dct_value_tokens_high12 + |
| 235 DCT_MAX_VALUE_HIGH12; |
| 236 vp9_dct_value_cost_high12_ptr = dct_value_cost_high12 + DCT_MAX_VALUE_HIGH12; |
| 237 |
| 238 tokenize_init_one(dct_value_tokens_high12 + DCT_MAX_VALUE_HIGH12, |
| 239 vp9_extra_bits_high12, |
| 240 dct_value_cost_high12 + DCT_MAX_VALUE_HIGH12, |
| 241 DCT_MAX_VALUE_HIGH12); |
| 242 #endif |
| 150 } | 243 } |
| 151 | 244 |
| 152 struct tokenize_b_args { | 245 struct tokenize_b_args { |
| 153 VP9_COMP *cpi; | 246 VP9_COMP *cpi; |
| 154 MACROBLOCKD *xd; | 247 MACROBLOCKD *xd; |
| 155 TOKENEXTRA **tp; | 248 TOKENEXTRA **tp; |
| 156 }; | 249 }; |
| 157 | 250 |
| 158 static void set_entropy_context_b(int plane, int block, BLOCK_SIZE plane_bsize, | 251 static void set_entropy_context_b(int plane, int block, BLOCK_SIZE plane_bsize, |
| 159 TX_SIZE tx_size, void *arg) { | 252 TX_SIZE tx_size, void *arg) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 | 292 |
| 200 static void tokenize_b(int plane, int block, BLOCK_SIZE plane_bsize, | 293 static void tokenize_b(int plane, int block, BLOCK_SIZE plane_bsize, |
| 201 TX_SIZE tx_size, void *arg) { | 294 TX_SIZE tx_size, void *arg) { |
| 202 struct tokenize_b_args* const args = arg; | 295 struct tokenize_b_args* const args = arg; |
| 203 VP9_COMP *cpi = args->cpi; | 296 VP9_COMP *cpi = args->cpi; |
| 204 MACROBLOCKD *xd = args->xd; | 297 MACROBLOCKD *xd = args->xd; |
| 205 TOKENEXTRA **tp = args->tp; | 298 TOKENEXTRA **tp = args->tp; |
| 206 uint8_t token_cache[32 * 32]; | 299 uint8_t token_cache[32 * 32]; |
| 207 struct macroblock_plane *p = &cpi->mb.plane[plane]; | 300 struct macroblock_plane *p = &cpi->mb.plane[plane]; |
| 208 struct macroblockd_plane *pd = &xd->plane[plane]; | 301 struct macroblockd_plane *pd = &xd->plane[plane]; |
| 209 MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; | 302 MB_MODE_INFO *mbmi = &xd->mi[0].src_mi->mbmi; |
| 210 int pt; /* near block/prev token context index */ | 303 int pt; /* near block/prev token context index */ |
| 211 int c; | 304 int c; |
| 212 TOKENEXTRA *t = *tp; /* store tokens starting here */ | 305 TOKENEXTRA *t = *tp; /* store tokens starting here */ |
| 213 int eob = p->eobs[block]; | 306 int eob = p->eobs[block]; |
| 214 const PLANE_TYPE type = pd->plane_type; | 307 const PLANE_TYPE type = pd->plane_type; |
| 215 const int16_t *qcoeff = BLOCK_OFFSET(p->qcoeff, block); | 308 const tran_low_t *qcoeff = BLOCK_OFFSET(p->qcoeff, block); |
| 216 const int segment_id = mbmi->segment_id; | 309 const int segment_id = mbmi->segment_id; |
| 217 const int16_t *scan, *nb; | 310 const int16_t *scan, *nb; |
| 218 const scan_order *so; | 311 const scan_order *so; |
| 219 const int ref = is_inter_block(mbmi); | 312 const int ref = is_inter_block(mbmi); |
| 220 unsigned int (*const counts)[COEFF_CONTEXTS][ENTROPY_TOKENS] = | 313 unsigned int (*const counts)[COEFF_CONTEXTS][ENTROPY_TOKENS] = |
| 221 cpi->coef_counts[tx_size][type][ref]; | 314 cpi->coef_counts[tx_size][type][ref]; |
| 222 vp9_prob (*const coef_probs)[COEFF_CONTEXTS][UNCONSTRAINED_NODES] = | 315 vp9_prob (*const coef_probs)[COEFF_CONTEXTS][UNCONSTRAINED_NODES] = |
| 223 cpi->common.fc.coef_probs[tx_size][type][ref]; | 316 cpi->common.fc.coef_probs[tx_size][type][ref]; |
| 224 unsigned int (*const eob_branch)[COEFF_CONTEXTS] = | 317 unsigned int (*const eob_branch)[COEFF_CONTEXTS] = |
| 225 cpi->common.counts.eob_branch[tx_size][type][ref]; | 318 cpi->common.counts.eob_branch[tx_size][type][ref]; |
| 226 const uint8_t *const band = get_band_translate(tx_size); | 319 const uint8_t *const band = get_band_translate(tx_size); |
| 227 const int seg_eob = get_tx_eob(&cpi->common.seg, segment_id, tx_size); | 320 const int seg_eob = get_tx_eob(&cpi->common.seg, segment_id, tx_size); |
| 321 const TOKENVALUE *dct_value_tokens; |
| 228 | 322 |
| 229 int aoff, loff; | 323 int aoff, loff; |
| 230 txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &aoff, &loff); | 324 txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &aoff, &loff); |
| 231 | 325 |
| 232 pt = get_entropy_context(tx_size, pd->above_context + aoff, | 326 pt = get_entropy_context(tx_size, pd->above_context + aoff, |
| 233 pd->left_context + loff); | 327 pd->left_context + loff); |
| 234 so = get_scan(xd, tx_size, type, block); | 328 so = get_scan(xd, tx_size, type, block); |
| 235 scan = so->scan; | 329 scan = so->scan; |
| 236 nb = so->neighbors; | 330 nb = so->neighbors; |
| 237 c = 0; | 331 c = 0; |
| 332 #if CONFIG_VP9_HIGH && CONFIG_HIGH_QUANT |
| 333 if (cpi->common.profile >= PROFILE_2) { |
| 334 dct_value_tokens = (cpi->common.bit_depth == VPX_BITS_10 ? |
| 335 vp9_dct_value_tokens_high10_ptr : |
| 336 vp9_dct_value_tokens_high12_ptr); |
| 337 } else { |
| 338 dct_value_tokens = vp9_dct_value_tokens_ptr; |
| 339 } |
| 340 #else |
| 341 dct_value_tokens = vp9_dct_value_tokens_ptr; |
| 342 #endif |
| 343 |
| 238 while (c < eob) { | 344 while (c < eob) { |
| 239 int v = 0; | 345 int v = 0; |
| 240 int skip_eob = 0; | 346 int skip_eob = 0; |
| 241 v = qcoeff[scan[c]]; | 347 v = qcoeff[scan[c]]; |
| 242 | 348 |
| 243 while (!v) { | 349 while (!v) { |
| 244 add_token_no_extra(&t, coef_probs[band[c]][pt], ZERO_TOKEN, skip_eob, | 350 add_token_no_extra(&t, coef_probs[band[c]][pt], ZERO_TOKEN, skip_eob, |
| 245 counts[band[c]][pt]); | 351 counts[band[c]][pt]); |
| 246 eob_branch[band[c]][pt] += !skip_eob; | 352 eob_branch[band[c]][pt] += !skip_eob; |
| 247 | 353 |
| 248 skip_eob = 1; | 354 skip_eob = 1; |
| 249 token_cache[scan[c]] = 0; | 355 token_cache[scan[c]] = 0; |
| 250 ++c; | 356 ++c; |
| 251 pt = get_coef_context(nb, token_cache, c); | 357 pt = get_coef_context(nb, token_cache, c); |
| 252 v = qcoeff[scan[c]]; | 358 v = qcoeff[scan[c]]; |
| 253 } | 359 } |
| 254 | 360 |
| 255 add_token(&t, coef_probs[band[c]][pt], | 361 add_token(&t, coef_probs[band[c]][pt], |
| 256 vp9_dct_value_tokens_ptr[v].extra, | 362 dct_value_tokens[v].extra, |
| 257 (uint8_t)vp9_dct_value_tokens_ptr[v].token, | 363 (uint8_t)dct_value_tokens[v].token, |
| 258 (uint8_t)skip_eob, | 364 (uint8_t)skip_eob, |
| 259 counts[band[c]][pt]); | 365 counts[band[c]][pt]); |
| 260 eob_branch[band[c]][pt] += !skip_eob; | 366 eob_branch[band[c]][pt] += !skip_eob; |
| 261 | 367 |
| 262 token_cache[scan[c]] = | 368 token_cache[scan[c]] = vp9_pt_energy_class[dct_value_tokens[v].token]; |
| 263 vp9_pt_energy_class[vp9_dct_value_tokens_ptr[v].token]; | |
| 264 ++c; | 369 ++c; |
| 265 pt = get_coef_context(nb, token_cache, c); | 370 pt = get_coef_context(nb, token_cache, c); |
| 266 } | 371 } |
| 267 if (c < seg_eob) { | 372 if (c < seg_eob) { |
| 268 add_token_no_extra(&t, coef_probs[band[c]][pt], EOB_TOKEN, 0, | 373 add_token_no_extra(&t, coef_probs[band[c]][pt], EOB_TOKEN, 0, |
| 269 counts[band[c]][pt]); | 374 counts[band[c]][pt]); |
| 270 ++eob_branch[band[c]][pt]; | 375 ++eob_branch[band[c]][pt]; |
| 271 } | 376 } |
| 272 | 377 |
| 273 *tp = t; | 378 *tp = t; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 295 struct is_skippable_args args = {x, &result}; | 400 struct is_skippable_args args = {x, &result}; |
| 296 vp9_foreach_transformed_block_in_plane(&x->e_mbd, bsize, plane, is_skippable, | 401 vp9_foreach_transformed_block_in_plane(&x->e_mbd, bsize, plane, is_skippable, |
| 297 &args); | 402 &args); |
| 298 return result; | 403 return result; |
| 299 } | 404 } |
| 300 | 405 |
| 301 void vp9_tokenize_sb(VP9_COMP *cpi, TOKENEXTRA **t, int dry_run, | 406 void vp9_tokenize_sb(VP9_COMP *cpi, TOKENEXTRA **t, int dry_run, |
| 302 BLOCK_SIZE bsize) { | 407 BLOCK_SIZE bsize) { |
| 303 VP9_COMMON *const cm = &cpi->common; | 408 VP9_COMMON *const cm = &cpi->common; |
| 304 MACROBLOCKD *const xd = &cpi->mb.e_mbd; | 409 MACROBLOCKD *const xd = &cpi->mb.e_mbd; |
| 305 MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; | 410 MB_MODE_INFO *const mbmi = &xd->mi[0].src_mi->mbmi; |
| 306 TOKENEXTRA *t_backup = *t; | 411 TOKENEXTRA *t_backup = *t; |
| 307 const int ctx = vp9_get_skip_context(xd); | 412 const int ctx = vp9_get_skip_context(xd); |
| 308 const int skip_inc = !vp9_segfeature_active(&cm->seg, mbmi->segment_id, | 413 const int skip_inc = !vp9_segfeature_active(&cm->seg, mbmi->segment_id, |
| 309 SEG_LVL_SKIP); | 414 SEG_LVL_SKIP); |
| 310 struct tokenize_b_args arg = {cpi, xd, t}; | 415 struct tokenize_b_args arg = {cpi, xd, t}; |
| 311 if (mbmi->skip) { | 416 if (mbmi->skip) { |
| 312 if (!dry_run) | 417 if (!dry_run) |
| 313 cm->counts.skip[ctx][1] += skip_inc; | 418 cm->counts.skip[ctx][1] += skip_inc; |
| 314 reset_skip_context(xd, bsize); | 419 reset_skip_context(xd, bsize); |
| 315 if (dry_run) | 420 if (dry_run) |
| 316 *t = t_backup; | 421 *t = t_backup; |
| 317 return; | 422 return; |
| 318 } | 423 } |
| 319 | 424 |
| 320 if (!dry_run) { | 425 if (!dry_run) { |
| 321 cm->counts.skip[ctx][0] += skip_inc; | 426 cm->counts.skip[ctx][0] += skip_inc; |
| 322 vp9_foreach_transformed_block(xd, bsize, tokenize_b, &arg); | 427 vp9_foreach_transformed_block(xd, bsize, tokenize_b, &arg); |
| 323 } else { | 428 } else { |
| 324 vp9_foreach_transformed_block(xd, bsize, set_entropy_context_b, &arg); | 429 vp9_foreach_transformed_block(xd, bsize, set_entropy_context_b, &arg); |
| 325 *t = t_backup; | 430 *t = t_backup; |
| 326 } | 431 } |
| 327 } | 432 } |
| OLD | NEW |