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 | 11 |
12 #ifndef VP9_COMMON_VP9_BLOCKD_H_ | 12 #ifndef VP9_COMMON_VP9_BLOCKD_H_ |
13 #define VP9_COMMON_VP9_BLOCKD_H_ | 13 #define VP9_COMMON_VP9_BLOCKD_H_ |
14 | 14 |
15 #include "./vpx_config.h" | 15 #include "./vpx_config.h" |
16 | 16 |
17 #include "vpx_ports/mem.h" | 17 #include "vpx_ports/mem.h" |
18 #include "vpx_scale/yv12config.h" | 18 #include "vpx_scale/yv12config.h" |
19 | 19 |
20 #include "vp9/common/vp9_common_data.h" | 20 #include "vp9/common/vp9_common_data.h" |
21 #include "vp9/common/vp9_filter.h" | 21 #include "vp9/common/vp9_entropy.h" |
| 22 #include "vp9/common/vp9_entropymode.h" |
22 #include "vp9/common/vp9_mv.h" | 23 #include "vp9/common/vp9_mv.h" |
23 #include "vp9/common/vp9_scale.h" | 24 #include "vp9/common/vp9_scale.h" |
| 25 #include "vp9/common/vp9_seg_common.h" |
24 | 26 |
25 #ifdef __cplusplus | 27 #ifdef __cplusplus |
26 extern "C" { | 28 extern "C" { |
27 #endif | 29 #endif |
28 | 30 |
29 #define BLOCK_SIZE_GROUPS 4 | |
30 #define SKIP_CONTEXTS 3 | |
31 #define INTER_MODE_CONTEXTS 7 | |
32 | |
33 /* Segment Feature Masks */ | |
34 #define MAX_MV_REF_CANDIDATES 2 | |
35 | |
36 #define INTRA_INTER_CONTEXTS 4 | |
37 #define COMP_INTER_CONTEXTS 5 | |
38 #define REF_CONTEXTS 5 | |
39 | |
40 typedef enum { | |
41 PLANE_TYPE_Y = 0, | |
42 PLANE_TYPE_UV = 1, | |
43 PLANE_TYPES | |
44 } PLANE_TYPE; | |
45 | |
46 #define MAX_MB_PLANE 3 | 31 #define MAX_MB_PLANE 3 |
47 | 32 |
48 typedef char ENTROPY_CONTEXT; | |
49 | |
50 static INLINE int combine_entropy_contexts(ENTROPY_CONTEXT a, | |
51 ENTROPY_CONTEXT b) { | |
52 return (a != 0) + (b != 0); | |
53 } | |
54 | |
55 typedef enum { | 33 typedef enum { |
56 KEY_FRAME = 0, | 34 KEY_FRAME = 0, |
57 INTER_FRAME = 1, | 35 INTER_FRAME = 1, |
58 FRAME_TYPES, | 36 FRAME_TYPES, |
59 } FRAME_TYPE; | 37 } FRAME_TYPE; |
60 | 38 |
61 typedef enum { | |
62 DC_PRED, // Average of above and left pixels | |
63 V_PRED, // Vertical | |
64 H_PRED, // Horizontal | |
65 D45_PRED, // Directional 45 deg = round(arctan(1/1) * 180/pi) | |
66 D135_PRED, // Directional 135 deg = 180 - 45 | |
67 D117_PRED, // Directional 117 deg = 180 - 63 | |
68 D153_PRED, // Directional 153 deg = 180 - 27 | |
69 D207_PRED, // Directional 207 deg = 180 + 27 | |
70 D63_PRED, // Directional 63 deg = round(arctan(2/1) * 180/pi) | |
71 TM_PRED, // True-motion | |
72 NEARESTMV, | |
73 NEARMV, | |
74 ZEROMV, | |
75 NEWMV, | |
76 MB_MODE_COUNT | |
77 } PREDICTION_MODE; | |
78 | |
79 static INLINE int is_inter_mode(PREDICTION_MODE mode) { | 39 static INLINE int is_inter_mode(PREDICTION_MODE mode) { |
80 return mode >= NEARESTMV && mode <= NEWMV; | 40 return mode >= NEARESTMV && mode <= NEWMV; |
81 } | 41 } |
82 | 42 |
83 #define INTRA_MODES (TM_PRED + 1) | |
84 | |
85 #define INTER_MODES (1 + NEWMV - NEARESTMV) | |
86 | |
87 #define INTER_OFFSET(mode) ((mode) - NEARESTMV) | |
88 | |
89 /* For keyframes, intra block modes are predicted by the (already decoded) | 43 /* For keyframes, intra block modes are predicted by the (already decoded) |
90 modes for the Y blocks to the left and above us; for interframes, there | 44 modes for the Y blocks to the left and above us; for interframes, there |
91 is a single probability table. */ | 45 is a single probability table. */ |
92 | 46 |
93 typedef struct { | 47 typedef struct { |
94 PREDICTION_MODE as_mode; | 48 PREDICTION_MODE as_mode; |
95 int_mv as_mv[2]; // first, second inter predictor motion vectors | 49 int_mv as_mv[2]; // first, second inter predictor motion vectors |
96 } b_mode_info; | 50 } b_mode_info; |
97 | 51 |
98 // Note that the rate-distortion optimization loop, bit-stream writer, and | 52 // Note that the rate-distortion optimization loop, bit-stream writer, and |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 | 164 |
211 /* pointer to current frame */ | 165 /* pointer to current frame */ |
212 const YV12_BUFFER_CONFIG *cur_buf; | 166 const YV12_BUFFER_CONFIG *cur_buf; |
213 | 167 |
214 ENTROPY_CONTEXT *above_context[MAX_MB_PLANE]; | 168 ENTROPY_CONTEXT *above_context[MAX_MB_PLANE]; |
215 ENTROPY_CONTEXT left_context[MAX_MB_PLANE][16]; | 169 ENTROPY_CONTEXT left_context[MAX_MB_PLANE][16]; |
216 | 170 |
217 PARTITION_CONTEXT *above_seg_context; | 171 PARTITION_CONTEXT *above_seg_context; |
218 PARTITION_CONTEXT left_seg_context[8]; | 172 PARTITION_CONTEXT left_seg_context[8]; |
219 | 173 |
220 /* mc buffer */ | |
221 DECLARE_ALIGNED(16, uint8_t, mc_buf[80 * 2 * 80 * 2]); | |
222 | |
223 #if CONFIG_VP9_HIGHBITDEPTH | 174 #if CONFIG_VP9_HIGHBITDEPTH |
224 /* Bit depth: 8, 10, 12 */ | 175 /* Bit depth: 8, 10, 12 */ |
225 int bd; | 176 int bd; |
226 DECLARE_ALIGNED(16, uint16_t, mc_buf_high[80 * 2 * 80 * 2]); | |
227 #endif | 177 #endif |
228 | 178 |
229 /* dqcoeff are shared by all the planes. So planes must be decoded serially */ | 179 /* dqcoeff are shared by all the planes. So planes must be decoded serially */ |
230 DECLARE_ALIGNED(16, tran_low_t, dqcoeff[64 * 64]); | 180 DECLARE_ALIGNED(16, tran_low_t, dqcoeff[64 * 64]); |
231 | 181 |
232 int lossless; | 182 int lossless; |
233 int corrupted; | 183 int corrupted; |
234 | 184 |
235 struct vpx_internal_error_info *error_info; | 185 struct vpx_internal_error_info *error_info; |
236 } MACROBLOCKD; | 186 } MACROBLOCKD; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 const struct macroblockd_plane *pd) { | 228 const struct macroblockd_plane *pd) { |
279 return get_uv_tx_size_impl(mbmi->tx_size, mbmi->sb_type, pd->subsampling_x, | 229 return get_uv_tx_size_impl(mbmi->tx_size, mbmi->sb_type, pd->subsampling_x, |
280 pd->subsampling_y); | 230 pd->subsampling_y); |
281 } | 231 } |
282 | 232 |
283 static INLINE BLOCK_SIZE get_plane_block_size(BLOCK_SIZE bsize, | 233 static INLINE BLOCK_SIZE get_plane_block_size(BLOCK_SIZE bsize, |
284 const struct macroblockd_plane *pd) { | 234 const struct macroblockd_plane *pd) { |
285 return ss_size_lookup[bsize][pd->subsampling_x][pd->subsampling_y]; | 235 return ss_size_lookup[bsize][pd->subsampling_x][pd->subsampling_y]; |
286 } | 236 } |
287 | 237 |
| 238 static INLINE void reset_skip_context(MACROBLOCKD *xd, BLOCK_SIZE bsize) { |
| 239 int i; |
| 240 for (i = 0; i < MAX_MB_PLANE; i++) { |
| 241 struct macroblockd_plane *const pd = &xd->plane[i]; |
| 242 const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd); |
| 243 memset(pd->above_context, 0, |
| 244 sizeof(ENTROPY_CONTEXT) * num_4x4_blocks_wide_lookup[plane_bsize]); |
| 245 memset(pd->left_context, 0, |
| 246 sizeof(ENTROPY_CONTEXT) * num_4x4_blocks_high_lookup[plane_bsize]); |
| 247 } |
| 248 } |
| 249 |
| 250 static INLINE const vp9_prob *get_y_mode_probs(const MODE_INFO *mi, |
| 251 const MODE_INFO *above_mi, |
| 252 const MODE_INFO *left_mi, |
| 253 int block) { |
| 254 const PREDICTION_MODE above = vp9_above_block_mode(mi, above_mi, block); |
| 255 const PREDICTION_MODE left = vp9_left_block_mode(mi, left_mi, block); |
| 256 return vp9_kf_y_mode_prob[above][left]; |
| 257 } |
| 258 |
288 typedef void (*foreach_transformed_block_visitor)(int plane, int block, | 259 typedef void (*foreach_transformed_block_visitor)(int plane, int block, |
289 BLOCK_SIZE plane_bsize, | 260 BLOCK_SIZE plane_bsize, |
290 TX_SIZE tx_size, | 261 TX_SIZE tx_size, |
291 void *arg); | 262 void *arg); |
292 | 263 |
293 void vp9_foreach_transformed_block_in_plane( | 264 void vp9_foreach_transformed_block_in_plane( |
294 const MACROBLOCKD *const xd, BLOCK_SIZE bsize, int plane, | 265 const MACROBLOCKD *const xd, BLOCK_SIZE bsize, int plane, |
295 foreach_transformed_block_visitor visit, void *arg); | 266 foreach_transformed_block_visitor visit, void *arg); |
296 | 267 |
297 | 268 |
(...skipping 14 matching lines...) Expand all Loading... |
312 | 283 |
313 void vp9_set_contexts(const MACROBLOCKD *xd, struct macroblockd_plane *pd, | 284 void vp9_set_contexts(const MACROBLOCKD *xd, struct macroblockd_plane *pd, |
314 BLOCK_SIZE plane_bsize, TX_SIZE tx_size, int has_eob, | 285 BLOCK_SIZE plane_bsize, TX_SIZE tx_size, int has_eob, |
315 int aoff, int loff); | 286 int aoff, int loff); |
316 | 287 |
317 #ifdef __cplusplus | 288 #ifdef __cplusplus |
318 } // extern "C" | 289 } // extern "C" |
319 #endif | 290 #endif |
320 | 291 |
321 #endif // VP9_COMMON_VP9_BLOCKD_H_ | 292 #endif // VP9_COMMON_VP9_BLOCKD_H_ |
OLD | NEW |