Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(391)

Side by Side Diff: source/libvpx/vp9/decoder/vp9_detokenize.c

Issue 1169543007: libvpx: Pull from upstream (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libvpx.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 17 matching lines...) Expand all
28 #define TWO_CONTEXT_NODE 1 28 #define TWO_CONTEXT_NODE 1
29 #define THREE_CONTEXT_NODE 2 29 #define THREE_CONTEXT_NODE 2
30 #define HIGH_LOW_CONTEXT_NODE 3 30 #define HIGH_LOW_CONTEXT_NODE 3
31 #define CAT_ONE_CONTEXT_NODE 4 31 #define CAT_ONE_CONTEXT_NODE 4
32 #define CAT_THREEFOUR_CONTEXT_NODE 5 32 #define CAT_THREEFOUR_CONTEXT_NODE 5
33 #define CAT_THREE_CONTEXT_NODE 6 33 #define CAT_THREE_CONTEXT_NODE 6
34 #define CAT_FIVE_CONTEXT_NODE 7 34 #define CAT_FIVE_CONTEXT_NODE 7
35 35
36 #define INCREMENT_COUNT(token) \ 36 #define INCREMENT_COUNT(token) \
37 do { \ 37 do { \
38 if (!cm->frame_parallel_decoding_mode) \ 38 if (counts) \
39 ++coef_counts[band][ctx][token]; \ 39 ++coef_counts[band][ctx][token]; \
40 } while (0) 40 } while (0)
41 41
42 static INLINE int read_coeff(const vp9_prob *probs, int n, vp9_reader *r) { 42 static INLINE int read_coeff(const vp9_prob *probs, int n, vp9_reader *r) {
43 int i, val = 0; 43 int i, val = 0;
44 for (i = 0; i < n; ++i) 44 for (i = 0; i < n; ++i)
45 val = (val << 1) | vp9_read(r, probs[i]); 45 val = (val << 1) | vp9_read(r, probs[i]);
46 return val; 46 return val;
47 } 47 }
48 48
49 static int decode_coefs(VP9_COMMON *cm, const MACROBLOCKD *xd, 49 static int decode_coefs(const MACROBLOCKD *xd,
50 FRAME_COUNTS *counts, PLANE_TYPE type, 50 PLANE_TYPE type,
51 tran_low_t *dqcoeff, TX_SIZE tx_size, const int16_t *dq, 51 tran_low_t *dqcoeff, TX_SIZE tx_size, const int16_t *dq,
52 int ctx, const int16_t *scan, const int16_t *nb, 52 int ctx, const int16_t *scan, const int16_t *nb,
53 vp9_reader *r) { 53 vp9_reader *r) {
54 FRAME_COUNTS *counts = xd->counts;
54 const int max_eob = 16 << (tx_size << 1); 55 const int max_eob = 16 << (tx_size << 1);
55 const FRAME_CONTEXT *const fc = cm->fc; 56 const FRAME_CONTEXT *const fc = xd->fc;
56 const int ref = is_inter_block(&xd->mi[0]->mbmi); 57 const int ref = is_inter_block(&xd->mi[0]->mbmi);
57 int band, c = 0; 58 int band, c = 0;
58 const vp9_prob (*coef_probs)[COEFF_CONTEXTS][UNCONSTRAINED_NODES] = 59 const vp9_prob (*coef_probs)[COEFF_CONTEXTS][UNCONSTRAINED_NODES] =
59 fc->coef_probs[tx_size][type][ref]; 60 fc->coef_probs[tx_size][type][ref];
60 const vp9_prob *prob; 61 const vp9_prob *prob;
61 unsigned int (*coef_counts)[COEFF_CONTEXTS][UNCONSTRAINED_NODES + 1] = 62 unsigned int (*coef_counts)[COEFF_CONTEXTS][UNCONSTRAINED_NODES + 1];
62 counts->coef[tx_size][type][ref]; 63 unsigned int (*eob_branch_count)[COEFF_CONTEXTS];
63 unsigned int (*eob_branch_count)[COEFF_CONTEXTS] =
64 counts->eob_branch[tx_size][type][ref];
65 uint8_t token_cache[32 * 32]; 64 uint8_t token_cache[32 * 32];
66 const uint8_t *band_translate = get_band_translate(tx_size); 65 const uint8_t *band_translate = get_band_translate(tx_size);
67 const int dq_shift = (tx_size == TX_32X32); 66 const int dq_shift = (tx_size == TX_32X32);
68 int v, token; 67 int v, token;
69 int16_t dqv = dq[0]; 68 int16_t dqv = dq[0];
70 const uint8_t *cat1_prob; 69 const uint8_t *cat1_prob;
71 const uint8_t *cat2_prob; 70 const uint8_t *cat2_prob;
72 const uint8_t *cat3_prob; 71 const uint8_t *cat3_prob;
73 const uint8_t *cat4_prob; 72 const uint8_t *cat4_prob;
74 const uint8_t *cat5_prob; 73 const uint8_t *cat5_prob;
75 const uint8_t *cat6_prob; 74 const uint8_t *cat6_prob;
76 75
76 if (counts) {
77 coef_counts = counts->coef[tx_size][type][ref];
78 eob_branch_count = counts->eob_branch[tx_size][type][ref];
79 }
80
77 #if CONFIG_VP9_HIGHBITDEPTH 81 #if CONFIG_VP9_HIGHBITDEPTH
78 if (cm->use_highbitdepth) { 82 if (xd->bd > VPX_BITS_8) {
79 if (cm->bit_depth == VPX_BITS_10) { 83 if (xd->bd == VPX_BITS_10) {
80 cat1_prob = vp9_cat1_prob_high10; 84 cat1_prob = vp9_cat1_prob_high10;
81 cat2_prob = vp9_cat2_prob_high10; 85 cat2_prob = vp9_cat2_prob_high10;
82 cat3_prob = vp9_cat3_prob_high10; 86 cat3_prob = vp9_cat3_prob_high10;
83 cat4_prob = vp9_cat4_prob_high10; 87 cat4_prob = vp9_cat4_prob_high10;
84 cat5_prob = vp9_cat5_prob_high10; 88 cat5_prob = vp9_cat5_prob_high10;
85 cat6_prob = vp9_cat6_prob_high10; 89 cat6_prob = vp9_cat6_prob_high10;
86 } else { 90 } else {
87 cat1_prob = vp9_cat1_prob_high12; 91 cat1_prob = vp9_cat1_prob_high12;
88 cat2_prob = vp9_cat2_prob_high12; 92 cat2_prob = vp9_cat2_prob_high12;
89 cat3_prob = vp9_cat3_prob_high12; 93 cat3_prob = vp9_cat3_prob_high12;
(...skipping 15 matching lines...) Expand all
105 cat3_prob = vp9_cat3_prob; 109 cat3_prob = vp9_cat3_prob;
106 cat4_prob = vp9_cat4_prob; 110 cat4_prob = vp9_cat4_prob;
107 cat5_prob = vp9_cat5_prob; 111 cat5_prob = vp9_cat5_prob;
108 cat6_prob = vp9_cat6_prob; 112 cat6_prob = vp9_cat6_prob;
109 #endif 113 #endif
110 114
111 while (c < max_eob) { 115 while (c < max_eob) {
112 int val = -1; 116 int val = -1;
113 band = *band_translate++; 117 band = *band_translate++;
114 prob = coef_probs[band][ctx]; 118 prob = coef_probs[band][ctx];
115 if (!cm->frame_parallel_decoding_mode) 119 if (counts)
116 ++eob_branch_count[band][ctx]; 120 ++eob_branch_count[band][ctx];
117 if (!vp9_read(r, prob[EOB_CONTEXT_NODE])) { 121 if (!vp9_read(r, prob[EOB_CONTEXT_NODE])) {
118 INCREMENT_COUNT(EOB_MODEL_TOKEN); 122 INCREMENT_COUNT(EOB_MODEL_TOKEN);
119 break; 123 break;
120 } 124 }
121 125
122 while (!vp9_read(r, prob[ZERO_CONTEXT_NODE])) { 126 while (!vp9_read(r, prob[ZERO_CONTEXT_NODE])) {
123 INCREMENT_COUNT(ZERO_TOKEN); 127 INCREMENT_COUNT(ZERO_TOKEN);
124 dqv = dq[1]; 128 dqv = dq[1];
125 token_cache[scan[c]] = 0; 129 token_cache[scan[c]] = 0;
(...skipping 29 matching lines...) Expand all
155 val = CAT3_MIN_VAL + read_coeff(cat3_prob, 3, r); 159 val = CAT3_MIN_VAL + read_coeff(cat3_prob, 3, r);
156 break; 160 break;
157 case CATEGORY4_TOKEN: 161 case CATEGORY4_TOKEN:
158 val = CAT4_MIN_VAL + read_coeff(cat4_prob, 4, r); 162 val = CAT4_MIN_VAL + read_coeff(cat4_prob, 4, r);
159 break; 163 break;
160 case CATEGORY5_TOKEN: 164 case CATEGORY5_TOKEN:
161 val = CAT5_MIN_VAL + read_coeff(cat5_prob, 5, r); 165 val = CAT5_MIN_VAL + read_coeff(cat5_prob, 5, r);
162 break; 166 break;
163 case CATEGORY6_TOKEN: 167 case CATEGORY6_TOKEN:
164 #if CONFIG_VP9_HIGHBITDEPTH 168 #if CONFIG_VP9_HIGHBITDEPTH
165 switch (cm->bit_depth) { 169 switch (xd->bd) {
166 case VPX_BITS_8: 170 case VPX_BITS_8:
167 val = CAT6_MIN_VAL + read_coeff(cat6_prob, 14, r); 171 val = CAT6_MIN_VAL + read_coeff(cat6_prob, 14, r);
168 break; 172 break;
169 case VPX_BITS_10: 173 case VPX_BITS_10:
170 val = CAT6_MIN_VAL + read_coeff(cat6_prob, 16, r); 174 val = CAT6_MIN_VAL + read_coeff(cat6_prob, 16, r);
171 break; 175 break;
172 case VPX_BITS_12: 176 case VPX_BITS_12:
173 val = CAT6_MIN_VAL + read_coeff(cat6_prob, 18, r); 177 val = CAT6_MIN_VAL + read_coeff(cat6_prob, 18, r);
174 break; 178 break;
175 default: 179 default:
176 assert(0); 180 assert(0);
177 return -1; 181 return -1;
178 } 182 }
179 #else 183 #else
180 val = CAT6_MIN_VAL + read_coeff(cat6_prob, 14, r); 184 val = CAT6_MIN_VAL + read_coeff(cat6_prob, 14, r);
181 #endif 185 #endif
182 break; 186 break;
183 } 187 }
184 } 188 }
185 v = (val * dqv) >> dq_shift; 189 v = (val * dqv) >> dq_shift;
186 #if CONFIG_COEFFICIENT_RANGE_CHECKING 190 #if CONFIG_COEFFICIENT_RANGE_CHECKING
187 #if CONFIG_VP9_HIGHBITDEPTH 191 #if CONFIG_VP9_HIGHBITDEPTH
188 dqcoeff[scan[c]] = highbd_check_range((vp9_read_bit(r) ? -v : v), 192 dqcoeff[scan[c]] = highbd_check_range((vp9_read_bit(r) ? -v : v),
189 cm->bit_depth); 193 xd->bd);
190 #else 194 #else
191 dqcoeff[scan[c]] = check_range(vp9_read_bit(r) ? -v : v); 195 dqcoeff[scan[c]] = check_range(vp9_read_bit(r) ? -v : v);
192 #endif // CONFIG_VP9_HIGHBITDEPTH 196 #endif // CONFIG_VP9_HIGHBITDEPTH
193 #else 197 #else
194 dqcoeff[scan[c]] = vp9_read_bit(r) ? -v : v; 198 dqcoeff[scan[c]] = vp9_read_bit(r) ? -v : v;
195 #endif // CONFIG_COEFFICIENT_RANGE_CHECKING 199 #endif // CONFIG_COEFFICIENT_RANGE_CHECKING
196 token_cache[scan[c]] = vp9_pt_energy_class[token]; 200 token_cache[scan[c]] = vp9_pt_energy_class[token];
197 ++c; 201 ++c;
198 ctx = get_coef_context(nb, token_cache, c); 202 ctx = get_coef_context(nb, token_cache, c);
199 dqv = dq[1]; 203 dqv = dq[1];
200 } 204 }
201 205
202 return c; 206 return c;
203 } 207 }
204 208
205 int vp9_decode_block_tokens(VP9_COMMON *cm, MACROBLOCKD *xd, 209 int vp9_decode_block_tokens(MACROBLOCKD *xd,
206 FRAME_COUNTS *counts, int plane, int block, 210 int plane, int block,
207 BLOCK_SIZE plane_bsize, int x, int y, 211 BLOCK_SIZE plane_bsize, int x, int y,
208 TX_SIZE tx_size, vp9_reader *r, 212 TX_SIZE tx_size, vp9_reader *r,
209 int seg_id) { 213 int seg_id) {
210 struct macroblockd_plane *const pd = &xd->plane[plane]; 214 struct macroblockd_plane *const pd = &xd->plane[plane];
211 const int16_t *const dequant = (plane == 0) ? cm->y_dequant[seg_id] 215 const int16_t *const dequant = pd->seg_dequant[seg_id];
212 : cm->uv_dequant[seg_id];
213 const int ctx = get_entropy_context(tx_size, pd->above_context + x, 216 const int ctx = get_entropy_context(tx_size, pd->above_context + x,
214 pd->left_context + y); 217 pd->left_context + y);
215 const scan_order *so = get_scan(xd, tx_size, pd->plane_type, block); 218 const scan_order *so = get_scan(xd, tx_size, pd->plane_type, block);
216 const int eob = decode_coefs(cm, xd, counts, pd->plane_type, 219 const int eob = decode_coefs(xd, pd->plane_type,
217 BLOCK_OFFSET(pd->dqcoeff, block), tx_size, 220 BLOCK_OFFSET(pd->dqcoeff, block), tx_size,
218 dequant, ctx, so->scan, so->neighbors, r); 221 dequant, ctx, so->scan, so->neighbors, r);
219 vp9_set_contexts(xd, pd, plane_bsize, tx_size, eob > 0, x, y); 222 vp9_set_contexts(xd, pd, plane_bsize, tx_size, eob > 0, x, y);
220 return eob; 223 return eob;
221 } 224 }
222 225
223 226
OLDNEW
« no previous file with comments | « source/libvpx/vp9/decoder/vp9_detokenize.h ('k') | source/libvpx/vp9/encoder/arm/neon/vp9_variance_neon.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698