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 |
11 #ifndef VP9_COMMON_VP9_ENTROPY_H_ | 11 #ifndef VP9_COMMON_VP9_ENTROPY_H_ |
12 #define VP9_COMMON_VP9_ENTROPY_H_ | 12 #define VP9_COMMON_VP9_ENTROPY_H_ |
13 | 13 |
14 #include "vpx/vpx_integer.h" | 14 #include "vpx/vpx_integer.h" |
15 | 15 |
16 #include "vp9/common/vp9_common.h" | 16 #include "vp9/common/vp9_common.h" |
| 17 #include "vp9/common/vp9_enums.h" |
17 #include "vp9/common/vp9_prob.h" | 18 #include "vp9/common/vp9_prob.h" |
18 #include "vp9/common/vp9_scan.h" | |
19 | 19 |
20 #ifdef __cplusplus | 20 #ifdef __cplusplus |
21 extern "C" { | 21 extern "C" { |
22 #endif | 22 #endif |
23 | 23 |
24 #define DIFF_UPDATE_PROB 252 | 24 #define DIFF_UPDATE_PROB 252 |
25 | 25 |
26 // Coefficient token alphabet | 26 // Coefficient token alphabet |
27 #define ZERO_TOKEN 0 // 0 Extra Bits 0+0 | 27 #define ZERO_TOKEN 0 // 0 Extra Bits 0+0 |
28 #define ONE_TOKEN 1 // 1 Extra Bits 0+1 | 28 #define ONE_TOKEN 1 // 1 Extra Bits 0+1 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 typedef unsigned int vp9_coeff_stats[REF_TYPES][COEF_BANDS][COEFF_CONTEXTS] | 130 typedef unsigned int vp9_coeff_stats[REF_TYPES][COEF_BANDS][COEFF_CONTEXTS] |
131 [ENTROPY_NODES][2]; | 131 [ENTROPY_NODES][2]; |
132 | 132 |
133 #define SUBEXP_PARAM 4 /* Subexponential code parameter */ | 133 #define SUBEXP_PARAM 4 /* Subexponential code parameter */ |
134 #define MODULUS_PARAM 13 /* Modulus parameter */ | 134 #define MODULUS_PARAM 13 /* Modulus parameter */ |
135 | 135 |
136 struct VP9Common; | 136 struct VP9Common; |
137 void vp9_default_coef_probs(struct VP9Common *cm); | 137 void vp9_default_coef_probs(struct VP9Common *cm); |
138 void vp9_adapt_coef_probs(struct VP9Common *cm); | 138 void vp9_adapt_coef_probs(struct VP9Common *cm); |
139 | 139 |
140 static INLINE void reset_skip_context(MACROBLOCKD *xd, BLOCK_SIZE bsize) { | |
141 int i; | |
142 for (i = 0; i < MAX_MB_PLANE; i++) { | |
143 struct macroblockd_plane *const pd = &xd->plane[i]; | |
144 const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd); | |
145 memset(pd->above_context, 0, | |
146 sizeof(ENTROPY_CONTEXT) * num_4x4_blocks_wide_lookup[plane_bsize]); | |
147 memset(pd->left_context, 0, | |
148 sizeof(ENTROPY_CONTEXT) * num_4x4_blocks_high_lookup[plane_bsize]); | |
149 } | |
150 } | |
151 | |
152 // This is the index in the scan order beyond which all coefficients for | 140 // This is the index in the scan order beyond which all coefficients for |
153 // 8x8 transform and above are in the top band. | 141 // 8x8 transform and above are in the top band. |
154 // This macro is currently unused but may be used by certain implementations | 142 // This macro is currently unused but may be used by certain implementations |
155 #define MAXBAND_INDEX 21 | 143 #define MAXBAND_INDEX 21 |
156 | 144 |
157 DECLARE_ALIGNED(16, extern const uint8_t, vp9_coefband_trans_8x8plus[1024]); | 145 DECLARE_ALIGNED(16, extern const uint8_t, vp9_coefband_trans_8x8plus[1024]); |
158 DECLARE_ALIGNED(16, extern const uint8_t, vp9_coefband_trans_4x4[16]); | 146 DECLARE_ALIGNED(16, extern const uint8_t, vp9_coefband_trans_4x4[16]); |
159 | 147 |
160 static INLINE const uint8_t *get_band_translate(TX_SIZE tx_size) { | 148 static INLINE const uint8_t *get_band_translate(TX_SIZE tx_size) { |
161 return tx_size == TX_4X4 ? vp9_coefband_trans_4x4 | 149 return tx_size == TX_4X4 ? vp9_coefband_trans_4x4 |
(...skipping 16 matching lines...) Expand all Loading... |
178 | 166 |
179 typedef vp9_prob vp9_coeff_probs_model[REF_TYPES][COEF_BANDS] | 167 typedef vp9_prob vp9_coeff_probs_model[REF_TYPES][COEF_BANDS] |
180 [COEFF_CONTEXTS][UNCONSTRAINED_NODES]; | 168 [COEFF_CONTEXTS][UNCONSTRAINED_NODES]; |
181 | 169 |
182 typedef unsigned int vp9_coeff_count_model[REF_TYPES][COEF_BANDS] | 170 typedef unsigned int vp9_coeff_count_model[REF_TYPES][COEF_BANDS] |
183 [COEFF_CONTEXTS] | 171 [COEFF_CONTEXTS] |
184 [UNCONSTRAINED_NODES + 1]; | 172 [UNCONSTRAINED_NODES + 1]; |
185 | 173 |
186 void vp9_model_to_full_probs(const vp9_prob *model, vp9_prob *full); | 174 void vp9_model_to_full_probs(const vp9_prob *model, vp9_prob *full); |
187 | 175 |
| 176 typedef char ENTROPY_CONTEXT; |
| 177 |
| 178 static INLINE int combine_entropy_contexts(ENTROPY_CONTEXT a, |
| 179 ENTROPY_CONTEXT b) { |
| 180 return (a != 0) + (b != 0); |
| 181 } |
| 182 |
188 static INLINE int get_entropy_context(TX_SIZE tx_size, const ENTROPY_CONTEXT *a, | 183 static INLINE int get_entropy_context(TX_SIZE tx_size, const ENTROPY_CONTEXT *a, |
189 const ENTROPY_CONTEXT *l) { | 184 const ENTROPY_CONTEXT *l) { |
190 ENTROPY_CONTEXT above_ec = 0, left_ec = 0; | 185 ENTROPY_CONTEXT above_ec = 0, left_ec = 0; |
191 | 186 |
192 switch (tx_size) { | 187 switch (tx_size) { |
193 case TX_4X4: | 188 case TX_4X4: |
194 above_ec = a[0] != 0; | 189 above_ec = a[0] != 0; |
195 left_ec = l[0] != 0; | 190 left_ec = l[0] != 0; |
196 break; | 191 break; |
197 case TX_8X8: | 192 case TX_8X8: |
198 above_ec = !!*(const uint16_t *)a; | 193 above_ec = !!*(const uint16_t *)a; |
199 left_ec = !!*(const uint16_t *)l; | 194 left_ec = !!*(const uint16_t *)l; |
200 break; | 195 break; |
201 case TX_16X16: | 196 case TX_16X16: |
202 above_ec = !!*(const uint32_t *)a; | 197 above_ec = !!*(const uint32_t *)a; |
203 left_ec = !!*(const uint32_t *)l; | 198 left_ec = !!*(const uint32_t *)l; |
204 break; | 199 break; |
205 case TX_32X32: | 200 case TX_32X32: |
206 above_ec = !!*(const uint64_t *)a; | 201 above_ec = !!*(const uint64_t *)a; |
207 left_ec = !!*(const uint64_t *)l; | 202 left_ec = !!*(const uint64_t *)l; |
208 break; | 203 break; |
209 default: | 204 default: |
210 assert(0 && "Invalid transform size."); | 205 assert(0 && "Invalid transform size."); |
211 break; | 206 break; |
212 } | 207 } |
213 | 208 |
214 return combine_entropy_contexts(above_ec, left_ec); | 209 return combine_entropy_contexts(above_ec, left_ec); |
215 } | 210 } |
216 | 211 |
217 static INLINE const scan_order *get_scan(const MACROBLOCKD *xd, TX_SIZE tx_size, | |
218 PLANE_TYPE type, int block_idx) { | |
219 const MODE_INFO *const mi = xd->mi[0]; | |
220 | |
221 if (is_inter_block(&mi->mbmi) || type != PLANE_TYPE_Y || xd->lossless) { | |
222 return &vp9_default_scan_orders[tx_size]; | |
223 } else { | |
224 const PREDICTION_MODE mode = get_y_mode(mi, block_idx); | |
225 return &vp9_scan_orders[tx_size][intra_mode_to_tx_type_lookup[mode]]; | |
226 } | |
227 } | |
228 | |
229 #ifdef __cplusplus | 212 #ifdef __cplusplus |
230 } // extern "C" | 213 } // extern "C" |
231 #endif | 214 #endif |
232 | 215 |
233 #endif // VP9_COMMON_VP9_ENTROPY_H_ | 216 #endif // VP9_COMMON_VP9_ENTROPY_H_ |
OLD | NEW |