| 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 12 matching lines...) Expand all Loading... |
| 23 #include "vp9/common/vp9_filter.h" | 23 #include "vp9/common/vp9_filter.h" |
| 24 #include "vp9/common/vp9_mv.h" | 24 #include "vp9/common/vp9_mv.h" |
| 25 #include "vp9/common/vp9_scale.h" | 25 #include "vp9/common/vp9_scale.h" |
| 26 #include "vp9/common/vp9_seg_common.h" | 26 #include "vp9/common/vp9_seg_common.h" |
| 27 | 27 |
| 28 #ifdef __cplusplus | 28 #ifdef __cplusplus |
| 29 extern "C" { | 29 extern "C" { |
| 30 #endif | 30 #endif |
| 31 | 31 |
| 32 #define BLOCK_SIZE_GROUPS 4 | 32 #define BLOCK_SIZE_GROUPS 4 |
| 33 #define MBSKIP_CONTEXTS 3 | 33 #define SKIP_CONTEXTS 3 |
| 34 #define INTER_MODE_CONTEXTS 7 | 34 #define INTER_MODE_CONTEXTS 7 |
| 35 | 35 |
| 36 /* Segment Feature Masks */ | 36 /* Segment Feature Masks */ |
| 37 #define MAX_MV_REF_CANDIDATES 2 | 37 #define MAX_MV_REF_CANDIDATES 2 |
| 38 | 38 |
| 39 #define INTRA_INTER_CONTEXTS 4 | 39 #define INTRA_INTER_CONTEXTS 4 |
| 40 #define COMP_INTER_CONTEXTS 5 | 40 #define COMP_INTER_CONTEXTS 5 |
| 41 #define REF_CONTEXTS 5 | 41 #define REF_CONTEXTS 5 |
| 42 | 42 |
| 43 typedef enum { | 43 typedef enum { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 static INLINE int is_inter_mode(MB_PREDICTION_MODE mode) { | 82 static INLINE int is_inter_mode(MB_PREDICTION_MODE mode) { |
| 83 return mode >= NEARESTMV && mode <= NEWMV; | 83 return mode >= NEARESTMV && mode <= NEWMV; |
| 84 } | 84 } |
| 85 | 85 |
| 86 #define INTRA_MODES (TM_PRED + 1) | 86 #define INTRA_MODES (TM_PRED + 1) |
| 87 | 87 |
| 88 #define INTER_MODES (1 + NEWMV - NEARESTMV) | 88 #define INTER_MODES (1 + NEWMV - NEARESTMV) |
| 89 | 89 |
| 90 #define INTER_OFFSET(mode) ((mode) - NEARESTMV) | 90 #define INTER_OFFSET(mode) ((mode) - NEARESTMV) |
| 91 | 91 |
| 92 | |
| 93 /* For keyframes, intra block modes are predicted by the (already decoded) | 92 /* For keyframes, intra block modes are predicted by the (already decoded) |
| 94 modes for the Y blocks to the left and above us; for interframes, there | 93 modes for the Y blocks to the left and above us; for interframes, there |
| 95 is a single probability table. */ | 94 is a single probability table. */ |
| 96 | 95 |
| 97 typedef struct { | 96 typedef struct { |
| 98 MB_PREDICTION_MODE as_mode; | 97 MB_PREDICTION_MODE as_mode; |
| 99 int_mv as_mv[2]; // first, second inter predictor motion vectors | 98 int_mv as_mv[2]; // first, second inter predictor motion vectors |
| 100 } b_mode_info; | 99 } b_mode_info; |
| 101 | 100 |
| 102 typedef enum { | 101 typedef enum { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 122 // This structure now relates to 8x8 block regions. | 121 // This structure now relates to 8x8 block regions. |
| 123 typedef struct { | 122 typedef struct { |
| 124 MB_PREDICTION_MODE mode, uv_mode; | 123 MB_PREDICTION_MODE mode, uv_mode; |
| 125 MV_REFERENCE_FRAME ref_frame[2]; | 124 MV_REFERENCE_FRAME ref_frame[2]; |
| 126 TX_SIZE tx_size; | 125 TX_SIZE tx_size; |
| 127 int_mv mv[2]; // for each reference frame used | 126 int_mv mv[2]; // for each reference frame used |
| 128 int_mv ref_mvs[MAX_REF_FRAMES][MAX_MV_REF_CANDIDATES]; | 127 int_mv ref_mvs[MAX_REF_FRAMES][MAX_MV_REF_CANDIDATES]; |
| 129 | 128 |
| 130 uint8_t mode_context[MAX_REF_FRAMES]; | 129 uint8_t mode_context[MAX_REF_FRAMES]; |
| 131 | 130 |
| 132 unsigned char skip_coeff; // 0=need to decode coeffs, 1=no coefficients | 131 unsigned char skip; // 0=need to decode coeffs, 1=no coefficients |
| 133 unsigned char segment_id; // Segment id for this block. | 132 unsigned char segment_id; // Segment id for this block. |
| 134 | 133 |
| 135 // Flags used for prediction status of various bit-stream signals | 134 // Flags used for prediction status of various bit-stream signals |
| 136 unsigned char seg_id_predicted; | 135 unsigned char seg_id_predicted; |
| 137 | 136 |
| 138 INTERP_FILTER interp_filter; | 137 INTERP_FILTER interp_filter; |
| 139 | 138 |
| 140 BLOCK_SIZE sb_type; | 139 BLOCK_SIZE sb_type; |
| 141 } MB_MODE_INFO; | 140 } MB_MODE_INFO; |
| 142 | 141 |
| 143 typedef struct { | 142 typedef struct { |
| 144 MB_MODE_INFO mbmi; | 143 MB_MODE_INFO mbmi; |
| 145 b_mode_info bmi[4]; | 144 b_mode_info bmi[4]; |
| 146 } MODE_INFO; | 145 } MODE_INFO; |
| 147 | 146 |
| 148 static INLINE int is_inter_block(const MB_MODE_INFO *mbmi) { | 147 static INLINE int is_inter_block(const MB_MODE_INFO *mbmi) { |
| 149 return mbmi->ref_frame[0] > INTRA_FRAME; | 148 return mbmi->ref_frame[0] > INTRA_FRAME; |
| 150 } | 149 } |
| 151 | 150 |
| 152 static INLINE int has_second_ref(const MB_MODE_INFO *mbmi) { | 151 static INLINE int has_second_ref(const MB_MODE_INFO *mbmi) { |
| 153 return mbmi->ref_frame[1] > INTRA_FRAME; | 152 return mbmi->ref_frame[1] > INTRA_FRAME; |
| 154 } | 153 } |
| 155 | 154 |
| 156 static MB_PREDICTION_MODE left_block_mode(const MODE_INFO *cur_mi, | 155 MB_PREDICTION_MODE vp9_left_block_mode(const MODE_INFO *cur_mi, |
| 157 const MODE_INFO *left_mi, int b) { | 156 const MODE_INFO *left_mi, int b); |
| 158 if (b == 0 || b == 2) { | |
| 159 if (!left_mi || is_inter_block(&left_mi->mbmi)) | |
| 160 return DC_PRED; | |
| 161 | 157 |
| 162 return left_mi->mbmi.sb_type < BLOCK_8X8 ? left_mi->bmi[b + 1].as_mode | 158 MB_PREDICTION_MODE vp9_above_block_mode(const MODE_INFO *cur_mi, |
| 163 : left_mi->mbmi.mode; | 159 const MODE_INFO *above_mi, int b); |
| 164 } else { | |
| 165 assert(b == 1 || b == 3); | |
| 166 return cur_mi->bmi[b - 1].as_mode; | |
| 167 } | |
| 168 } | |
| 169 | |
| 170 static MB_PREDICTION_MODE above_block_mode(const MODE_INFO *cur_mi, | |
| 171 const MODE_INFO *above_mi, int b) { | |
| 172 if (b == 0 || b == 1) { | |
| 173 if (!above_mi || is_inter_block(&above_mi->mbmi)) | |
| 174 return DC_PRED; | |
| 175 | |
| 176 return above_mi->mbmi.sb_type < BLOCK_8X8 ? above_mi->bmi[b + 2].as_mode | |
| 177 : above_mi->mbmi.mode; | |
| 178 } else { | |
| 179 assert(b == 2 || b == 3); | |
| 180 return cur_mi->bmi[b - 2].as_mode; | |
| 181 } | |
| 182 } | |
| 183 | 160 |
| 184 enum mv_precision { | 161 enum mv_precision { |
| 185 MV_PRECISION_Q3, | 162 MV_PRECISION_Q3, |
| 186 MV_PRECISION_Q4 | 163 MV_PRECISION_Q4 |
| 187 }; | 164 }; |
| 188 | 165 |
| 189 #if CONFIG_ALPHA | 166 #if CONFIG_ALPHA |
| 190 enum { MAX_MB_PLANE = 4 }; | 167 enum { MAX_MB_PLANE = 4 }; |
| 191 #else | 168 #else |
| 192 enum { MAX_MB_PLANE = 3 }; | 169 enum { MAX_MB_PLANE = 3 }; |
| 193 #endif | 170 #endif |
| 194 | 171 |
| 195 struct buf_2d { | 172 struct buf_2d { |
| 196 uint8_t *buf; | 173 uint8_t *buf; |
| 197 int stride; | 174 int stride; |
| 198 }; | 175 }; |
| 199 | 176 |
| 200 struct macroblockd_plane { | 177 struct macroblockd_plane { |
| 201 int16_t *dqcoeff; | 178 int16_t *dqcoeff; |
| 202 PLANE_TYPE plane_type; | 179 PLANE_TYPE plane_type; |
| 203 int subsampling_x; | 180 int subsampling_x; |
| 204 int subsampling_y; | 181 int subsampling_y; |
| 205 struct buf_2d dst; | 182 struct buf_2d dst; |
| 206 struct buf_2d pre[2]; | 183 struct buf_2d pre[2]; |
| 207 int16_t *dequant; | 184 const int16_t *dequant; |
| 208 ENTROPY_CONTEXT *above_context; | 185 ENTROPY_CONTEXT *above_context; |
| 209 ENTROPY_CONTEXT *left_context; | 186 ENTROPY_CONTEXT *left_context; |
| 210 }; | 187 }; |
| 211 | 188 |
| 212 #define BLOCK_OFFSET(x, i) ((x) + (i) * 16) | 189 #define BLOCK_OFFSET(x, i) ((x) + (i) * 16) |
| 213 | 190 |
| 214 typedef struct RefBuffer { | 191 typedef struct RefBuffer { |
| 215 // TODO(dkovalev): idx is not really required and should be removed, now it | 192 // TODO(dkovalev): idx is not really required and should be removed, now it |
| 216 // is used in vp9_onyxd_if.c | 193 // is used in vp9_onyxd_if.c |
| 217 int idx; | 194 int idx; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 245 /* pointer to current frame */ | 222 /* pointer to current frame */ |
| 246 const YV12_BUFFER_CONFIG *cur_buf; | 223 const YV12_BUFFER_CONFIG *cur_buf; |
| 247 | 224 |
| 248 /* mc buffer */ | 225 /* mc buffer */ |
| 249 DECLARE_ALIGNED(16, uint8_t, mc_buf[80 * 2 * 80 * 2]); | 226 DECLARE_ALIGNED(16, uint8_t, mc_buf[80 * 2 * 80 * 2]); |
| 250 | 227 |
| 251 int lossless; | 228 int lossless; |
| 252 /* Inverse transform function pointers. */ | 229 /* Inverse transform function pointers. */ |
| 253 void (*itxm_add)(const int16_t *input, uint8_t *dest, int stride, int eob); | 230 void (*itxm_add)(const int16_t *input, uint8_t *dest, int stride, int eob); |
| 254 | 231 |
| 255 const interp_kernel *interp_kernel; | 232 const InterpKernel *interp_kernel; |
| 256 | 233 |
| 257 int corrupted; | 234 int corrupted; |
| 258 | 235 |
| 259 /* Y,U,V,(A) */ | 236 /* Y,U,V,(A) */ |
| 260 ENTROPY_CONTEXT *above_context[MAX_MB_PLANE]; | 237 ENTROPY_CONTEXT *above_context[MAX_MB_PLANE]; |
| 261 ENTROPY_CONTEXT left_context[MAX_MB_PLANE][16]; | 238 ENTROPY_CONTEXT left_context[MAX_MB_PLANE][16]; |
| 262 | 239 |
| 263 PARTITION_CONTEXT *above_seg_context; | 240 PARTITION_CONTEXT *above_seg_context; |
| 264 PARTITION_CONTEXT left_seg_context[8]; | 241 PARTITION_CONTEXT left_seg_context[8]; |
| 265 } MACROBLOCKD; | 242 } MACROBLOCKD; |
| 266 | 243 |
| 267 | 244 |
| 268 | 245 |
| 269 static BLOCK_SIZE get_subsize(BLOCK_SIZE bsize, PARTITION_TYPE partition) { | 246 static INLINE BLOCK_SIZE get_subsize(BLOCK_SIZE bsize, |
| 247 PARTITION_TYPE partition) { |
| 270 const BLOCK_SIZE subsize = subsize_lookup[partition][bsize]; | 248 const BLOCK_SIZE subsize = subsize_lookup[partition][bsize]; |
| 271 assert(subsize < BLOCK_SIZES); | 249 assert(subsize < BLOCK_SIZES); |
| 272 return subsize; | 250 return subsize; |
| 273 } | 251 } |
| 274 | 252 |
| 275 extern const TX_TYPE mode2txfm_map[MB_MODE_COUNT]; | 253 extern const TX_TYPE mode2txfm_map[MB_MODE_COUNT]; |
| 276 | 254 |
| 277 static INLINE TX_TYPE get_tx_type_4x4(PLANE_TYPE plane_type, | 255 static INLINE TX_TYPE get_tx_type_4x4(PLANE_TYPE plane_type, |
| 278 const MACROBLOCKD *xd, int ib) { | 256 const MACROBLOCKD *xd, int ib) { |
| 279 const MODE_INFO *const mi = xd->mi_8x8[0]; | 257 const MODE_INFO *const mi = xd->mi_8x8[0]; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 291 return plane_type == PLANE_TYPE_Y ? mode2txfm_map[xd->mi_8x8[0]->mbmi.mode] | 269 return plane_type == PLANE_TYPE_Y ? mode2txfm_map[xd->mi_8x8[0]->mbmi.mode] |
| 292 : DCT_DCT; | 270 : DCT_DCT; |
| 293 } | 271 } |
| 294 | 272 |
| 295 static INLINE TX_TYPE get_tx_type_16x16(PLANE_TYPE plane_type, | 273 static INLINE TX_TYPE get_tx_type_16x16(PLANE_TYPE plane_type, |
| 296 const MACROBLOCKD *xd) { | 274 const MACROBLOCKD *xd) { |
| 297 return plane_type == PLANE_TYPE_Y ? mode2txfm_map[xd->mi_8x8[0]->mbmi.mode] | 275 return plane_type == PLANE_TYPE_Y ? mode2txfm_map[xd->mi_8x8[0]->mbmi.mode] |
| 298 : DCT_DCT; | 276 : DCT_DCT; |
| 299 } | 277 } |
| 300 | 278 |
| 301 static void setup_block_dptrs(MACROBLOCKD *xd, int ss_x, int ss_y) { | 279 void vp9_setup_block_planes(MACROBLOCKD *xd, int ss_x, int ss_y); |
| 302 int i; | |
| 303 | 280 |
| 304 for (i = 0; i < MAX_MB_PLANE; i++) { | 281 static INLINE TX_SIZE get_uv_tx_size_impl(TX_SIZE y_tx_size, BLOCK_SIZE bsize) { |
| 305 xd->plane[i].plane_type = i ? PLANE_TYPE_UV : PLANE_TYPE_Y; | |
| 306 xd->plane[i].subsampling_x = i ? ss_x : 0; | |
| 307 xd->plane[i].subsampling_y = i ? ss_y : 0; | |
| 308 } | |
| 309 #if CONFIG_ALPHA | |
| 310 // TODO(jkoleszar): Using the Y w/h for now | |
| 311 xd->plane[3].plane_type = PLANE_TYPE_Y; | |
| 312 xd->plane[3].subsampling_x = 0; | |
| 313 xd->plane[3].subsampling_y = 0; | |
| 314 #endif | |
| 315 } | |
| 316 | |
| 317 static TX_SIZE get_uv_tx_size_impl(TX_SIZE y_tx_size, BLOCK_SIZE bsize) { | |
| 318 if (bsize < BLOCK_8X8) { | 282 if (bsize < BLOCK_8X8) { |
| 319 return TX_4X4; | 283 return TX_4X4; |
| 320 } else { | 284 } else { |
| 321 // TODO(dkovalev): Assuming YUV420 (ss_x == 1, ss_y == 1) | 285 // TODO(dkovalev): Assuming YUV420 (ss_x == 1, ss_y == 1) |
| 322 const BLOCK_SIZE plane_bsize = ss_size_lookup[bsize][1][1]; | 286 const BLOCK_SIZE plane_bsize = ss_size_lookup[bsize][1][1]; |
| 323 return MIN(y_tx_size, max_txsize_lookup[plane_bsize]); | 287 return MIN(y_tx_size, max_txsize_lookup[plane_bsize]); |
| 324 } | 288 } |
| 325 } | 289 } |
| 326 | 290 |
| 327 static TX_SIZE get_uv_tx_size(const MB_MODE_INFO *mbmi) { | 291 static INLINE TX_SIZE get_uv_tx_size(const MB_MODE_INFO *mbmi) { |
| 328 return get_uv_tx_size_impl(mbmi->tx_size, mbmi->sb_type); | 292 return get_uv_tx_size_impl(mbmi->tx_size, mbmi->sb_type); |
| 329 } | 293 } |
| 330 | 294 |
| 331 static BLOCK_SIZE get_plane_block_size(BLOCK_SIZE bsize, | 295 static INLINE BLOCK_SIZE get_plane_block_size(BLOCK_SIZE bsize, |
| 332 const struct macroblockd_plane *pd) { | 296 const struct macroblockd_plane *pd) { |
| 333 BLOCK_SIZE bs = ss_size_lookup[bsize][pd->subsampling_x][pd->subsampling_y]; | 297 BLOCK_SIZE bs = ss_size_lookup[bsize][pd->subsampling_x][pd->subsampling_y]; |
| 334 assert(bs < BLOCK_SIZES); | 298 assert(bs < BLOCK_SIZES); |
| 335 return bs; | 299 return bs; |
| 336 } | 300 } |
| 337 | 301 |
| 338 typedef void (*foreach_transformed_block_visitor)(int plane, int block, | 302 typedef void (*foreach_transformed_block_visitor)(int plane, int block, |
| 339 BLOCK_SIZE plane_bsize, | 303 BLOCK_SIZE plane_bsize, |
| 340 TX_SIZE tx_size, | 304 TX_SIZE tx_size, |
| 341 void *arg); | 305 void *arg); |
| 342 | 306 |
| 343 static INLINE void foreach_transformed_block_in_plane( | 307 void vp9_foreach_transformed_block_in_plane( |
| 344 const MACROBLOCKD *const xd, BLOCK_SIZE bsize, int plane, | 308 const MACROBLOCKD *const xd, BLOCK_SIZE bsize, int plane, |
| 345 foreach_transformed_block_visitor visit, void *arg) { | 309 foreach_transformed_block_visitor visit, void *arg); |
| 346 const struct macroblockd_plane *const pd = &xd->plane[plane]; | |
| 347 const MB_MODE_INFO* mbmi = &xd->mi_8x8[0]->mbmi; | |
| 348 // block and transform sizes, in number of 4x4 blocks log 2 ("*_b") | |
| 349 // 4x4=0, 8x8=2, 16x16=4, 32x32=6, 64x64=8 | |
| 350 // transform size varies per plane, look it up in a common way. | |
| 351 const TX_SIZE tx_size = plane ? get_uv_tx_size(mbmi) | |
| 352 : mbmi->tx_size; | |
| 353 const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd); | |
| 354 const int num_4x4_w = num_4x4_blocks_wide_lookup[plane_bsize]; | |
| 355 const int num_4x4_h = num_4x4_blocks_high_lookup[plane_bsize]; | |
| 356 const int step = 1 << (tx_size << 1); | |
| 357 int i; | |
| 358 | 310 |
| 359 // If mb_to_right_edge is < 0 we are in a situation in which | |
| 360 // the current block size extends into the UMV and we won't | |
| 361 // visit the sub blocks that are wholly within the UMV. | |
| 362 if (xd->mb_to_right_edge < 0 || xd->mb_to_bottom_edge < 0) { | |
| 363 int r, c; | |
| 364 | 311 |
| 365 int max_blocks_wide = num_4x4_w; | 312 void vp9_foreach_transformed_block( |
| 366 int max_blocks_high = num_4x4_h; | 313 const MACROBLOCKD* const xd, BLOCK_SIZE bsize, |
| 314 foreach_transformed_block_visitor visit, void *arg); |
| 367 | 315 |
| 368 // xd->mb_to_right_edge is in units of pixels * 8. This converts | 316 static INLINE void txfrm_block_to_raster_xy(BLOCK_SIZE plane_bsize, |
| 369 // it to 4x4 block sizes. | 317 TX_SIZE tx_size, int block, |
| 370 if (xd->mb_to_right_edge < 0) | 318 int *x, int *y) { |
| 371 max_blocks_wide += (xd->mb_to_right_edge >> (5 + pd->subsampling_x)); | |
| 372 | |
| 373 if (xd->mb_to_bottom_edge < 0) | |
| 374 max_blocks_high += (xd->mb_to_bottom_edge >> (5 + pd->subsampling_y)); | |
| 375 | |
| 376 i = 0; | |
| 377 // Unlike the normal case - in here we have to keep track of the | |
| 378 // row and column of the blocks we use so that we know if we are in | |
| 379 // the unrestricted motion border. | |
| 380 for (r = 0; r < num_4x4_h; r += (1 << tx_size)) { | |
| 381 for (c = 0; c < num_4x4_w; c += (1 << tx_size)) { | |
| 382 if (r < max_blocks_high && c < max_blocks_wide) | |
| 383 visit(plane, i, plane_bsize, tx_size, arg); | |
| 384 i += step; | |
| 385 } | |
| 386 } | |
| 387 } else { | |
| 388 for (i = 0; i < num_4x4_w * num_4x4_h; i += step) | |
| 389 visit(plane, i, plane_bsize, tx_size, arg); | |
| 390 } | |
| 391 } | |
| 392 | |
| 393 static INLINE void foreach_transformed_block( | |
| 394 const MACROBLOCKD* const xd, BLOCK_SIZE bsize, | |
| 395 foreach_transformed_block_visitor visit, void *arg) { | |
| 396 int plane; | |
| 397 | |
| 398 for (plane = 0; plane < MAX_MB_PLANE; plane++) | |
| 399 foreach_transformed_block_in_plane(xd, bsize, plane, visit, arg); | |
| 400 } | |
| 401 | |
| 402 static INLINE void foreach_transformed_block_uv( | |
| 403 const MACROBLOCKD* const xd, BLOCK_SIZE bsize, | |
| 404 foreach_transformed_block_visitor visit, void *arg) { | |
| 405 int plane; | |
| 406 | |
| 407 for (plane = 1; plane < MAX_MB_PLANE; plane++) | |
| 408 foreach_transformed_block_in_plane(xd, bsize, plane, visit, arg); | |
| 409 } | |
| 410 | |
| 411 static void txfrm_block_to_raster_xy(BLOCK_SIZE plane_bsize, | |
| 412 TX_SIZE tx_size, int block, | |
| 413 int *x, int *y) { | |
| 414 const int bwl = b_width_log2(plane_bsize); | 319 const int bwl = b_width_log2(plane_bsize); |
| 415 const int tx_cols_log2 = bwl - tx_size; | 320 const int tx_cols_log2 = bwl - tx_size; |
| 416 const int tx_cols = 1 << tx_cols_log2; | 321 const int tx_cols = 1 << tx_cols_log2; |
| 417 const int raster_mb = block >> (tx_size << 1); | 322 const int raster_mb = block >> (tx_size << 1); |
| 418 *x = (raster_mb & (tx_cols - 1)) << tx_size; | 323 *x = (raster_mb & (tx_cols - 1)) << tx_size; |
| 419 *y = (raster_mb >> tx_cols_log2) << tx_size; | 324 *y = (raster_mb >> tx_cols_log2) << tx_size; |
| 420 } | 325 } |
| 421 | 326 |
| 422 static void set_contexts(const MACROBLOCKD *xd, struct macroblockd_plane *pd, | 327 void vp9_set_contexts(const MACROBLOCKD *xd, struct macroblockd_plane *pd, |
| 423 BLOCK_SIZE plane_bsize, TX_SIZE tx_size, | 328 BLOCK_SIZE plane_bsize, TX_SIZE tx_size, int has_eob, |
| 424 int has_eob, int aoff, int loff) { | 329 int aoff, int loff); |
| 425 ENTROPY_CONTEXT *const a = pd->above_context + aoff; | |
| 426 ENTROPY_CONTEXT *const l = pd->left_context + loff; | |
| 427 const int tx_size_in_blocks = 1 << tx_size; | |
| 428 | 330 |
| 429 // above | |
| 430 if (has_eob && xd->mb_to_right_edge < 0) { | |
| 431 int i; | |
| 432 const int blocks_wide = num_4x4_blocks_wide_lookup[plane_bsize] + | |
| 433 (xd->mb_to_right_edge >> (5 + pd->subsampling_x)); | |
| 434 int above_contexts = tx_size_in_blocks; | |
| 435 if (above_contexts + aoff > blocks_wide) | |
| 436 above_contexts = blocks_wide - aoff; | |
| 437 | 331 |
| 438 for (i = 0; i < above_contexts; ++i) | 332 static INLINE int get_tx_eob(const struct segmentation *seg, int segment_id, |
| 439 a[i] = has_eob; | 333 TX_SIZE tx_size) { |
| 440 for (i = above_contexts; i < tx_size_in_blocks; ++i) | |
| 441 a[i] = 0; | |
| 442 } else { | |
| 443 vpx_memset(a, has_eob, sizeof(ENTROPY_CONTEXT) * tx_size_in_blocks); | |
| 444 } | |
| 445 | |
| 446 // left | |
| 447 if (has_eob && xd->mb_to_bottom_edge < 0) { | |
| 448 int i; | |
| 449 const int blocks_high = num_4x4_blocks_high_lookup[plane_bsize] + | |
| 450 (xd->mb_to_bottom_edge >> (5 + pd->subsampling_y)); | |
| 451 int left_contexts = tx_size_in_blocks; | |
| 452 if (left_contexts + loff > blocks_high) | |
| 453 left_contexts = blocks_high - loff; | |
| 454 | |
| 455 for (i = 0; i < left_contexts; ++i) | |
| 456 l[i] = has_eob; | |
| 457 for (i = left_contexts; i < tx_size_in_blocks; ++i) | |
| 458 l[i] = 0; | |
| 459 } else { | |
| 460 vpx_memset(l, has_eob, sizeof(ENTROPY_CONTEXT) * tx_size_in_blocks); | |
| 461 } | |
| 462 } | |
| 463 | |
| 464 static int get_tx_eob(const struct segmentation *seg, int segment_id, | |
| 465 TX_SIZE tx_size) { | |
| 466 const int eob_max = 16 << (tx_size << 1); | 334 const int eob_max = 16 << (tx_size << 1); |
| 467 return vp9_segfeature_active(seg, segment_id, SEG_LVL_SKIP) ? 0 : eob_max; | 335 return vp9_segfeature_active(seg, segment_id, SEG_LVL_SKIP) ? 0 : eob_max; |
| 468 } | 336 } |
| 469 | 337 |
| 470 #ifdef __cplusplus | 338 #ifdef __cplusplus |
| 471 } // extern "C" | 339 } // extern "C" |
| 472 #endif | 340 #endif |
| 473 | 341 |
| 474 #endif // VP9_COMMON_VP9_BLOCKD_H_ | 342 #endif // VP9_COMMON_VP9_BLOCKD_H_ |
| OLD | NEW |