| 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 27 matching lines...) Expand all Loading... |
| 38 ++coef_counts[band][ctx][token]; \ | 38 ++coef_counts[band][ctx][token]; \ |
| 39 } while (0) | 39 } while (0) |
| 40 | 40 |
| 41 static INLINE int read_coeff(const vp9_prob *probs, int n, vp9_reader *r) { | 41 static INLINE int read_coeff(const vp9_prob *probs, int n, vp9_reader *r) { |
| 42 int i, val = 0; | 42 int i, val = 0; |
| 43 for (i = 0; i < n; ++i) | 43 for (i = 0; i < n; ++i) |
| 44 val = (val << 1) | vp9_read(r, probs[i]); | 44 val = (val << 1) | vp9_read(r, probs[i]); |
| 45 return val; | 45 return val; |
| 46 } | 46 } |
| 47 | 47 |
| 48 static const vp9_tree_index coeff_subtree_high[TREE_SIZE(ENTROPY_TOKENS)] = { | |
| 49 2, 6, /* 0 = LOW_VAL */ | |
| 50 -TWO_TOKEN, 4, /* 1 = TWO */ | |
| 51 -THREE_TOKEN, -FOUR_TOKEN, /* 2 = THREE */ | |
| 52 8, 10, /* 3 = HIGH_LOW */ | |
| 53 -CATEGORY1_TOKEN, -CATEGORY2_TOKEN, /* 4 = CAT_ONE */ | |
| 54 12, 14, /* 5 = CAT_THREEFOUR */ | |
| 55 -CATEGORY3_TOKEN, -CATEGORY4_TOKEN, /* 6 = CAT_THREE */ | |
| 56 -CATEGORY5_TOKEN, -CATEGORY6_TOKEN /* 7 = CAT_FIVE */ | |
| 57 }; | |
| 58 | |
| 59 static int decode_coefs(VP9_COMMON *cm, const MACROBLOCKD *xd, | 48 static int decode_coefs(VP9_COMMON *cm, const MACROBLOCKD *xd, |
| 60 FRAME_COUNTS *counts, PLANE_TYPE type, | 49 FRAME_COUNTS *counts, PLANE_TYPE type, |
| 61 tran_low_t *dqcoeff, TX_SIZE tx_size, const int16_t *dq, | 50 tran_low_t *dqcoeff, TX_SIZE tx_size, const int16_t *dq, |
| 62 int ctx, const int16_t *scan, const int16_t *nb, | 51 int ctx, const int16_t *scan, const int16_t *nb, |
| 63 vp9_reader *r) { | 52 vp9_reader *r) { |
| 64 const int max_eob = 16 << (tx_size << 1); | 53 const int max_eob = 16 << (tx_size << 1); |
| 65 const FRAME_CONTEXT *const fc = cm->fc; | 54 const FRAME_CONTEXT *const fc = cm->fc; |
| 66 const int ref = is_inter_block(&xd->mi[0].src_mi->mbmi); | 55 const int ref = is_inter_block(&xd->mi[0]->mbmi); |
| 67 int band, c = 0; | 56 int band, c = 0; |
| 68 const vp9_prob (*coef_probs)[COEFF_CONTEXTS][UNCONSTRAINED_NODES] = | 57 const vp9_prob (*coef_probs)[COEFF_CONTEXTS][UNCONSTRAINED_NODES] = |
| 69 fc->coef_probs[tx_size][type][ref]; | 58 fc->coef_probs[tx_size][type][ref]; |
| 70 const vp9_prob *prob; | 59 const vp9_prob *prob; |
| 71 unsigned int (*coef_counts)[COEFF_CONTEXTS][UNCONSTRAINED_NODES + 1] = | 60 unsigned int (*coef_counts)[COEFF_CONTEXTS][UNCONSTRAINED_NODES + 1] = |
| 72 counts->coef[tx_size][type][ref]; | 61 counts->coef[tx_size][type][ref]; |
| 73 unsigned int (*eob_branch_count)[COEFF_CONTEXTS] = | 62 unsigned int (*eob_branch_count)[COEFF_CONTEXTS] = |
| 74 counts->eob_branch[tx_size][type][ref]; | 63 counts->eob_branch[tx_size][type][ref]; |
| 75 uint8_t token_cache[32 * 32]; | 64 uint8_t token_cache[32 * 32]; |
| 76 const uint8_t *band_translate = get_band_translate(tx_size); | 65 const uint8_t *band_translate = get_band_translate(tx_size); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 band = *band_translate++; | 129 band = *band_translate++; |
| 141 prob = coef_probs[band][ctx]; | 130 prob = coef_probs[band][ctx]; |
| 142 } | 131 } |
| 143 | 132 |
| 144 if (!vp9_read(r, prob[ONE_CONTEXT_NODE])) { | 133 if (!vp9_read(r, prob[ONE_CONTEXT_NODE])) { |
| 145 INCREMENT_COUNT(ONE_TOKEN); | 134 INCREMENT_COUNT(ONE_TOKEN); |
| 146 token = ONE_TOKEN; | 135 token = ONE_TOKEN; |
| 147 val = 1; | 136 val = 1; |
| 148 } else { | 137 } else { |
| 149 INCREMENT_COUNT(TWO_TOKEN); | 138 INCREMENT_COUNT(TWO_TOKEN); |
| 150 token = vp9_read_tree(r, coeff_subtree_high, | 139 token = vp9_read_tree(r, vp9_coef_con_tree, |
| 151 vp9_pareto8_full[prob[PIVOT_NODE] - 1]); | 140 vp9_pareto8_full[prob[PIVOT_NODE] - 1]); |
| 152 switch (token) { | 141 switch (token) { |
| 153 case TWO_TOKEN: | 142 case TWO_TOKEN: |
| 154 case THREE_TOKEN: | 143 case THREE_TOKEN: |
| 155 case FOUR_TOKEN: | 144 case FOUR_TOKEN: |
| 156 val = token; | 145 val = token; |
| 157 break; | 146 break; |
| 158 case CATEGORY1_TOKEN: | 147 case CATEGORY1_TOKEN: |
| 159 val = CAT1_MIN_VAL + read_coeff(cat1_prob, 1, r); | 148 val = CAT1_MIN_VAL + read_coeff(cat1_prob, 1, r); |
| 160 break; | 149 break; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 dqv = dq[1]; | 198 dqv = dq[1]; |
| 210 } | 199 } |
| 211 | 200 |
| 212 return c; | 201 return c; |
| 213 } | 202 } |
| 214 | 203 |
| 215 int vp9_decode_block_tokens(VP9_COMMON *cm, MACROBLOCKD *xd, | 204 int vp9_decode_block_tokens(VP9_COMMON *cm, MACROBLOCKD *xd, |
| 216 FRAME_COUNTS *counts, int plane, int block, | 205 FRAME_COUNTS *counts, int plane, int block, |
| 217 BLOCK_SIZE plane_bsize, int x, int y, | 206 BLOCK_SIZE plane_bsize, int x, int y, |
| 218 TX_SIZE tx_size, vp9_reader *r, | 207 TX_SIZE tx_size, vp9_reader *r, |
| 219 const int16_t *const dequant) { | 208 int seg_id) { |
| 220 struct macroblockd_plane *const pd = &xd->plane[plane]; | 209 struct macroblockd_plane *const pd = &xd->plane[plane]; |
| 210 const int16_t *const dequant = (plane == 0) ? cm->y_dequant[seg_id] |
| 211 : cm->uv_dequant[seg_id]; |
| 221 const int ctx = get_entropy_context(tx_size, pd->above_context + x, | 212 const int ctx = get_entropy_context(tx_size, pd->above_context + x, |
| 222 pd->left_context + y); | 213 pd->left_context + y); |
| 223 const scan_order *so = get_scan(xd, tx_size, pd->plane_type, block); | 214 const scan_order *so = get_scan(xd, tx_size, pd->plane_type, block); |
| 224 const int eob = decode_coefs(cm, xd, counts, pd->plane_type, | 215 const int eob = decode_coefs(cm, xd, counts, pd->plane_type, |
| 225 BLOCK_OFFSET(pd->dqcoeff, block), tx_size, | 216 BLOCK_OFFSET(pd->dqcoeff, block), tx_size, |
| 226 dequant, ctx, so->scan, so->neighbors, r); | 217 dequant, ctx, so->scan, so->neighbors, r); |
| 227 vp9_set_contexts(xd, pd, plane_bsize, tx_size, eob > 0, x, y); | 218 vp9_set_contexts(xd, pd, plane_bsize, tx_size, eob > 0, x, y); |
| 228 return eob; | 219 return eob; |
| 229 } | 220 } |
| 230 | 221 |
| 231 | 222 |
| OLD | NEW |