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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 static INLINE int b_height_log2(BLOCK_SIZE sb_type) { | 113 static INLINE int b_height_log2(BLOCK_SIZE sb_type) { |
114 return b_height_log2_lookup[sb_type]; | 114 return b_height_log2_lookup[sb_type]; |
115 } | 115 } |
116 | 116 |
117 static INLINE int mi_width_log2(BLOCK_SIZE sb_type) { | 117 static INLINE int mi_width_log2(BLOCK_SIZE sb_type) { |
118 return mi_width_log2_lookup[sb_type]; | 118 return mi_width_log2_lookup[sb_type]; |
119 } | 119 } |
120 | 120 |
121 // This structure now relates to 8x8 block regions. | 121 // This structure now relates to 8x8 block regions. |
122 typedef struct { | 122 typedef struct { |
123 MB_PREDICTION_MODE mode, uv_mode; | 123 // Common for both INTER and INTRA blocks |
| 124 BLOCK_SIZE sb_type; |
| 125 MB_PREDICTION_MODE mode; |
| 126 TX_SIZE tx_size; |
| 127 uint8_t skip; |
| 128 uint8_t segment_id; |
| 129 uint8_t seg_id_predicted; // valid only when temporal_update is enabled |
| 130 |
| 131 // Only for INTRA blocks |
| 132 MB_PREDICTION_MODE uv_mode; |
| 133 |
| 134 // Only for INTER blocks |
124 MV_REFERENCE_FRAME ref_frame[2]; | 135 MV_REFERENCE_FRAME ref_frame[2]; |
125 TX_SIZE tx_size; | 136 int_mv mv[2]; |
126 int_mv mv[2]; // for each reference frame used | |
127 int_mv ref_mvs[MAX_REF_FRAMES][MAX_MV_REF_CANDIDATES]; | 137 int_mv ref_mvs[MAX_REF_FRAMES][MAX_MV_REF_CANDIDATES]; |
128 | |
129 uint8_t mode_context[MAX_REF_FRAMES]; | 138 uint8_t mode_context[MAX_REF_FRAMES]; |
130 | |
131 unsigned char skip; // 0=need to decode coeffs, 1=no coefficients | |
132 unsigned char segment_id; // Segment id for this block. | |
133 | |
134 // Flags used for prediction status of various bit-stream signals | |
135 unsigned char seg_id_predicted; | |
136 | |
137 INTERP_FILTER interp_filter; | 139 INTERP_FILTER interp_filter; |
138 | |
139 BLOCK_SIZE sb_type; | |
140 } MB_MODE_INFO; | 140 } MB_MODE_INFO; |
141 | 141 |
142 typedef struct { | 142 typedef struct { |
143 MB_MODE_INFO mbmi; | 143 MB_MODE_INFO mbmi; |
144 b_mode_info bmi[4]; | 144 b_mode_info bmi[4]; |
145 } MODE_INFO; | 145 } MODE_INFO; |
146 | 146 |
147 static INLINE MB_PREDICTION_MODE get_y_mode(const MODE_INFO *mi, int block) { | 147 static INLINE MB_PREDICTION_MODE get_y_mode(const MODE_INFO *mi, int block) { |
148 return mi->mbmi.sb_type < BLOCK_8X8 ? mi->bmi[block].as_mode | 148 return mi->mbmi.sb_type < BLOCK_8X8 ? mi->bmi[block].as_mode |
149 : mi->mbmi.mode; | 149 : mi->mbmi.mode; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 // TODO(dkovalev): idx is not really required and should be removed, now it | 197 // TODO(dkovalev): idx is not really required and should be removed, now it |
198 // is used in vp9_onyxd_if.c | 198 // is used in vp9_onyxd_if.c |
199 int idx; | 199 int idx; |
200 YV12_BUFFER_CONFIG *buf; | 200 YV12_BUFFER_CONFIG *buf; |
201 struct scale_factors sf; | 201 struct scale_factors sf; |
202 } RefBuffer; | 202 } RefBuffer; |
203 | 203 |
204 typedef struct macroblockd { | 204 typedef struct macroblockd { |
205 struct macroblockd_plane plane[MAX_MB_PLANE]; | 205 struct macroblockd_plane plane[MAX_MB_PLANE]; |
206 | 206 |
207 MODE_INFO *last_mi; | 207 int mi_stride; |
208 int mode_info_stride; | |
209 | 208 |
210 // A NULL indicates that the 8x8 is not part of the image | 209 // A NULL indicates that the 8x8 is not part of the image |
211 MODE_INFO **mi_8x8; | 210 MODE_INFO **mi; |
212 MODE_INFO **prev_mi_8x8; | |
213 MODE_INFO *mi_stream; | |
214 | 211 |
215 int up_available; | 212 int up_available; |
216 int left_available; | 213 int left_available; |
217 | 214 |
218 /* Distance of MB away from frame edges */ | 215 /* Distance of MB away from frame edges */ |
219 int mb_to_left_edge; | 216 int mb_to_left_edge; |
220 int mb_to_right_edge; | 217 int mb_to_right_edge; |
221 int mb_to_top_edge; | 218 int mb_to_top_edge; |
222 int mb_to_bottom_edge; | 219 int mb_to_bottom_edge; |
223 | 220 |
224 /* pointers to reference frames */ | 221 /* pointers to reference frames */ |
225 RefBuffer *block_refs[2]; | 222 RefBuffer *block_refs[2]; |
226 | 223 |
227 /* pointer to current frame */ | 224 /* pointer to current frame */ |
228 const YV12_BUFFER_CONFIG *cur_buf; | 225 const YV12_BUFFER_CONFIG *cur_buf; |
229 | 226 |
230 /* mc buffer */ | 227 /* mc buffer */ |
231 DECLARE_ALIGNED(16, uint8_t, mc_buf[80 * 2 * 80 * 2]); | 228 DECLARE_ALIGNED(16, uint8_t, mc_buf[80 * 2 * 80 * 2]); |
232 | 229 |
233 int lossless; | 230 int lossless; |
234 /* Inverse transform function pointers. */ | 231 /* Inverse transform function pointers. */ |
235 void (*itxm_add)(const int16_t *input, uint8_t *dest, int stride, int eob); | 232 void (*itxm_add)(const int16_t *input, uint8_t *dest, int stride, int eob); |
236 | 233 |
237 const InterpKernel *interp_kernel; | |
238 | |
239 int corrupted; | 234 int corrupted; |
240 | 235 |
241 /* Y,U,V,(A) */ | 236 DECLARE_ALIGNED(16, int16_t, dqcoeff[MAX_MB_PLANE][64 * 64]); |
| 237 |
242 ENTROPY_CONTEXT *above_context[MAX_MB_PLANE]; | 238 ENTROPY_CONTEXT *above_context[MAX_MB_PLANE]; |
243 ENTROPY_CONTEXT left_context[MAX_MB_PLANE][16]; | 239 ENTROPY_CONTEXT left_context[MAX_MB_PLANE][16]; |
244 | 240 |
245 PARTITION_CONTEXT *above_seg_context; | 241 PARTITION_CONTEXT *above_seg_context; |
246 PARTITION_CONTEXT left_seg_context[8]; | 242 PARTITION_CONTEXT left_seg_context[8]; |
247 } MACROBLOCKD; | 243 } MACROBLOCKD; |
248 | 244 |
249 | |
250 | |
251 static INLINE BLOCK_SIZE get_subsize(BLOCK_SIZE bsize, | 245 static INLINE BLOCK_SIZE get_subsize(BLOCK_SIZE bsize, |
252 PARTITION_TYPE partition) { | 246 PARTITION_TYPE partition) { |
253 const BLOCK_SIZE subsize = subsize_lookup[partition][bsize]; | 247 const BLOCK_SIZE subsize = subsize_lookup[partition][bsize]; |
254 assert(subsize < BLOCK_SIZES); | 248 assert(subsize < BLOCK_SIZES); |
255 return subsize; | 249 return subsize; |
256 } | 250 } |
257 | 251 |
258 extern const TX_TYPE mode2txfm_map[MB_MODE_COUNT]; | 252 extern const TX_TYPE intra_mode_to_tx_type_lookup[INTRA_MODES]; |
| 253 |
| 254 static INLINE TX_TYPE get_tx_type(PLANE_TYPE plane_type, |
| 255 const MACROBLOCKD *xd) { |
| 256 const MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; |
| 257 |
| 258 if (plane_type != PLANE_TYPE_Y || is_inter_block(mbmi)) |
| 259 return DCT_DCT; |
| 260 return intra_mode_to_tx_type_lookup[mbmi->mode]; |
| 261 } |
259 | 262 |
260 static INLINE TX_TYPE get_tx_type_4x4(PLANE_TYPE plane_type, | 263 static INLINE TX_TYPE get_tx_type_4x4(PLANE_TYPE plane_type, |
261 const MACROBLOCKD *xd, int ib) { | 264 const MACROBLOCKD *xd, int ib) { |
262 const MODE_INFO *const mi = xd->mi_8x8[0]; | 265 const MODE_INFO *const mi = xd->mi[0]; |
263 | 266 |
264 if (plane_type != PLANE_TYPE_Y || xd->lossless || is_inter_block(&mi->mbmi)) | 267 if (plane_type != PLANE_TYPE_Y || xd->lossless || is_inter_block(&mi->mbmi)) |
265 return DCT_DCT; | 268 return DCT_DCT; |
266 | 269 |
267 return mode2txfm_map[get_y_mode(mi, ib)]; | 270 return intra_mode_to_tx_type_lookup[get_y_mode(mi, ib)]; |
268 } | |
269 | |
270 static INLINE TX_TYPE get_tx_type_8x8(PLANE_TYPE plane_type, | |
271 const MACROBLOCKD *xd) { | |
272 return plane_type == PLANE_TYPE_Y ? mode2txfm_map[xd->mi_8x8[0]->mbmi.mode] | |
273 : DCT_DCT; | |
274 } | |
275 | |
276 static INLINE TX_TYPE get_tx_type_16x16(PLANE_TYPE plane_type, | |
277 const MACROBLOCKD *xd) { | |
278 return plane_type == PLANE_TYPE_Y ? mode2txfm_map[xd->mi_8x8[0]->mbmi.mode] | |
279 : DCT_DCT; | |
280 } | 271 } |
281 | 272 |
282 void vp9_setup_block_planes(MACROBLOCKD *xd, int ss_x, int ss_y); | 273 void vp9_setup_block_planes(MACROBLOCKD *xd, int ss_x, int ss_y); |
283 | 274 |
284 static INLINE TX_SIZE get_uv_tx_size_impl(TX_SIZE y_tx_size, BLOCK_SIZE bsize) { | 275 static INLINE TX_SIZE get_uv_tx_size_impl(TX_SIZE y_tx_size, BLOCK_SIZE bsize) { |
285 if (bsize < BLOCK_8X8) { | 276 if (bsize < BLOCK_8X8) { |
286 return TX_4X4; | 277 return TX_4X4; |
287 } else { | 278 } else { |
288 // TODO(dkovalev): Assuming YUV420 (ss_x == 1, ss_y == 1) | 279 // TODO(dkovalev): Assuming YUV420 (ss_x == 1, ss_y == 1) |
289 const BLOCK_SIZE plane_bsize = ss_size_lookup[bsize][1][1]; | 280 const BLOCK_SIZE plane_bsize = ss_size_lookup[bsize][1][1]; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 | 320 |
330 void vp9_set_contexts(const MACROBLOCKD *xd, struct macroblockd_plane *pd, | 321 void vp9_set_contexts(const MACROBLOCKD *xd, struct macroblockd_plane *pd, |
331 BLOCK_SIZE plane_bsize, TX_SIZE tx_size, int has_eob, | 322 BLOCK_SIZE plane_bsize, TX_SIZE tx_size, int has_eob, |
332 int aoff, int loff); | 323 int aoff, int loff); |
333 | 324 |
334 #ifdef __cplusplus | 325 #ifdef __cplusplus |
335 } // extern "C" | 326 } // extern "C" |
336 #endif | 327 #endif |
337 | 328 |
338 #endif // VP9_COMMON_VP9_BLOCKD_H_ | 329 #endif // VP9_COMMON_VP9_BLOCKD_H_ |
OLD | NEW |