Unified · Split
| @@ -0,0 +1,167 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2014 The WebM project authors. All Rights Reserved. | |
| 3 | + * | |
| 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 | |
| 6 | + * tree. An additional intellectual property rights grant can be found | |
| 7 | + * in the file PATENTS. All contributing project authors may | |
| 8 | + * be found in the AUTHORS file in the root of the source tree. | |
| 9 | + */ | |
| 10 | + | |
| 11 | +#include "vp9/common/vp9_blockd.h" | |
| 12 | + | |
| 13 | +MB_PREDICTION_MODE vp9_left_block_mode(const MODE_INFO *cur_mi, | |
| 14 | + const MODE_INFO *left_mi, int b) { | |
| 15 | + if (b == 0 || b == 2) { | |
| 16 | + if (!left_mi || is_inter_block(&left_mi->mbmi)) | |
| 17 | + return DC_PRED; | |
| 18 | + | |
| 19 | + return left_mi->mbmi.sb_type < BLOCK_8X8 ? left_mi->bmi[b + 1].as_mode | |
| 20 | + : left_mi->mbmi.mode; | |
| 21 | + } else { | |
| 22 | + assert(b == 1 || b == 3); | |
| 23 | + return cur_mi->bmi[b - 1].as_mode; | |
| 24 | + } | |
| 25 | +} | |
| 26 | + | |
| 27 | +MB_PREDICTION_MODE vp9_above_block_mode(const MODE_INFO *cur_mi, | |
| 28 | + const MODE_INFO *above_mi, int b) { | |
| 29 | + if (b == 0 || b == 1) { | |
| 30 | + if (!above_mi || is_inter_block(&above_mi->mbmi)) | |
| 31 | + return DC_PRED; | |
| 32 | + | |
| 33 | + return above_mi->mbmi.sb_type < BLOCK_8X8 ? above_mi->bmi[b + 2].as_mode | |
| 34 | + : above_mi->mbmi.mode; | |
| 35 | + } else { | |
| 36 | + assert(b == 2 || b == 3); | |
| 37 | + return cur_mi->bmi[b - 2].as_mode; | |
| 38 | + } | |
| 39 | +} | |
| 40 | + | |
| 41 | +void vp9_foreach_transformed_block_in_plane( | |
| 42 | + const MACROBLOCKD *const xd, BLOCK_SIZE bsize, int plane, | |
| 43 | + foreach_transformed_block_visitor visit, void *arg) { | |
| 44 | + const struct macroblockd_plane *const pd = &xd->plane[plane]; | |
| 45 | + const MB_MODE_INFO* mbmi = &xd->mi_8x8[0]->mbmi; | |
| 46 | + // block and transform sizes, in number of 4x4 blocks log 2 ("*_b") | |
| 47 | + // 4x4=0, 8x8=2, 16x16=4, 32x32=6, 64x64=8 | |
| 48 | + // transform size varies per plane, look it up in a common way. | |
| 49 | + const TX_SIZE tx_size = plane ? get_uv_tx_size(mbmi) | |
| 50 | + : mbmi->tx_size; | |
| 51 | + const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd); | |
| 52 | + const int num_4x4_w = num_4x4_blocks_wide_lookup[plane_bsize]; | |
| 53 | + const int num_4x4_h = num_4x4_blocks_high_lookup[plane_bsize]; | |
| 54 | + const int step = 1 << (tx_size << 1); | |
| 55 | + int i; | |
| 56 | + | |
| 57 | + // If mb_to_right_edge is < 0 we are in a situation in which | |
| 58 | + // the current block size extends into the UMV and we won't | |
| 59 | + // visit the sub blocks that are wholly within the UMV. | |
| 60 | + if (xd->mb_to_right_edge < 0 || xd->mb_to_bottom_edge < 0) { | |
| 61 | + int r, c; | |
| 62 | + | |
| 63 | + int max_blocks_wide = num_4x4_w; | |
| 64 | + int max_blocks_high = num_4x4_h; | |
| 65 | + | |
| 66 | + // xd->mb_to_right_edge is in units of pixels * 8. This converts | |
| 67 | + // it to 4x4 block sizes. | |
| 68 | + if (xd->mb_to_right_edge < 0) | |
| 69 | + max_blocks_wide += (xd->mb_to_right_edge >> (5 + pd->subsampling_x)); | |
| 70 | + | |
| 71 | + if (xd->mb_to_bottom_edge < 0) | |
| 72 | + max_blocks_high += (xd->mb_to_bottom_edge >> (5 + pd->subsampling_y)); | |
| 73 | + | |
| 74 | + i = 0; | |
| 75 | + // Unlike the normal case - in here we have to keep track of the | |
| 76 | + // row and column of the blocks we use so that we know if we are in | |
| 77 | + // the unrestricted motion border. | |
| 78 | + for (r = 0; r < num_4x4_h; r += (1 << tx_size)) { | |
| 79 | + for (c = 0; c < num_4x4_w; c += (1 << tx_size)) { | |
| 80 | + if (r < max_blocks_high && c < max_blocks_wide) | |
| 81 | + visit(plane, i, plane_bsize, tx_size, arg); | |
| 82 | + i += step; | |
| 83 | + } | |
| 84 | + } | |
| 85 | + } else { | |
| 86 | + for (i = 0; i < num_4x4_w * num_4x4_h; i += step) | |
| 87 | + visit(plane, i, plane_bsize, tx_size, arg); | |
| 88 | + } | |
| 89 | +} | |
| 90 | + | |
| 91 | +void vp9_foreach_transformed_block(const MACROBLOCKD* const xd, | |
| 92 | + BLOCK_SIZE bsize, | |
| 93 | + foreach_transformed_block_visitor visit, | |
| 94 | + void *arg) { | |
| 95 | + int plane; | |
| 96 | + | |
| 97 | + for (plane = 0; plane < MAX_MB_PLANE; plane++) | |
| 98 | + vp9_foreach_transformed_block_in_plane(xd, bsize, plane, visit, arg); | |
| 99 | +} | |
| 100 | + | |
| 101 | +void vp9_foreach_transformed_block_uv(const MACROBLOCKD* const xd, | |
| 102 | + BLOCK_SIZE bsize, | |
| 103 | + foreach_transformed_block_visitor visit, | |
| 104 | + void *arg) { | |
| 105 | + int plane; | |
| 106 | + | |
| 107 | + for (plane = 1; plane < MAX_MB_PLANE; plane++) | |
| 108 | + vp9_foreach_transformed_block_in_plane(xd, bsize, plane, visit, arg); | |
| 109 | +} | |
| 110 | + | |
| 111 | +void vp9_set_contexts(const MACROBLOCKD *xd, struct macroblockd_plane *pd, | |
| 112 | + BLOCK_SIZE plane_bsize, TX_SIZE tx_size, int has_eob, | |
| 113 | + int aoff, int loff) { | |
| 114 | + ENTROPY_CONTEXT *const a = pd->above_context + aoff; | |
| 115 | + ENTROPY_CONTEXT *const l = pd->left_context + loff; | |
| 116 | + const int tx_size_in_blocks = 1 << tx_size; | |
| 117 | + | |
| 118 | + // above | |
| 119 | + if (has_eob && xd->mb_to_right_edge < 0) { | |
| 120 | + int i; | |
| 121 | + const int blocks_wide = num_4x4_blocks_wide_lookup[plane_bsize] + | |
| 122 | + (xd->mb_to_right_edge >> (5 + pd->subsampling_x)); | |
| 123 | + int above_contexts = tx_size_in_blocks; | |
| 124 | + if (above_contexts + aoff > blocks_wide) | |
| 125 | + above_contexts = blocks_wide - aoff; | |
| 126 | + | |
| 127 | + for (i = 0; i < above_contexts; ++i) | |
| 128 | + a[i] = has_eob; | |
| 129 | + for (i = above_contexts; i < tx_size_in_blocks; ++i) | |
| 130 | + a[i] = 0; | |
| 131 | + } else { | |
| 132 | + vpx_memset(a, has_eob, sizeof(ENTROPY_CONTEXT) * tx_size_in_blocks); | |
| 133 | + } | |
| 134 | + | |
| 135 | + // left | |
| 136 | + if (has_eob && xd->mb_to_bottom_edge < 0) { | |
| 137 | + int i; | |
| 138 | + const int blocks_high = num_4x4_blocks_high_lookup[plane_bsize] + | |
| 139 | + (xd->mb_to_bottom_edge >> (5 + pd->subsampling_y)); | |
| 140 | + int left_contexts = tx_size_in_blocks; | |
| 141 | + if (left_contexts + loff > blocks_high) | |
| 142 | + left_contexts = blocks_high - loff; | |
| 143 | + | |
| 144 | + for (i = 0; i < left_contexts; ++i) | |
| 145 | + l[i] = has_eob; | |
| 146 | + for (i = left_contexts; i < tx_size_in_blocks; ++i) | |
| 147 | + l[i] = 0; | |
| 148 | + } else { | |
| 149 | + vpx_memset(l, has_eob, sizeof(ENTROPY_CONTEXT) * tx_size_in_blocks); | |
| 150 | + } | |
| 151 | +} | |
| 152 | + | |
| 153 | +void vp9_setup_block_planes(MACROBLOCKD *xd, int ss_x, int ss_y) { | |
| 154 | + int i; | |
| 155 | + | |
| 156 | + for (i = 0; i < MAX_MB_PLANE; i++) { | |
| 157 | + xd->plane[i].plane_type = i ? PLANE_TYPE_UV : PLANE_TYPE_Y; | |
| 158 | + xd->plane[i].subsampling_x = i ? ss_x : 0; | |
| 159 | + xd->plane[i].subsampling_y = i ? ss_y : 0; | |
| 160 | + } | |
| 161 | +#if CONFIG_ALPHA | |
| 162 | + // TODO(jkoleszar): Using the Y w/h for now | |
| 163 | + xd->plane[3].plane_type = PLANE_TYPE_Y; | |
| 164 | + xd->plane[3].subsampling_x = 0; | |
| 165 | + xd->plane[3].subsampling_y = 0; | |
| 166 | +#endif | |
| 167 | +} | |
| @@ -153,33 +153,11 @@ static INLINE int has_second_ref(const MB_MODE_INFO *mbmi) { · 152 unmodified lines | ||
| 153 | 153 | return mbmi->ref_frame[1] > INTRA_FRAME; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | −static MB_PREDICTION_MODE left_block_mode(const MODE_INFO *cur_mi, | |
| 157 | − 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 | − | |
| 162 | − return left_mi->mbmi.sb_type < BLOCK_8X8 ? left_mi->bmi[b + 1].as_mode | |
| 163 | − : left_mi->mbmi.mode; | |
| 164 | − } else { | |
| 165 | − assert(b == 1 || b == 3); | |
| 166 | − return cur_mi->bmi[b - 1].as_mode; | |
| 167 | − } | |
| 168 | −} | |
| 156 | +MB_PREDICTION_MODE vp9_left_block_mode(const MODE_INFO *cur_mi, | |
| 157 | + const MODE_INFO *left_mi, int b); | |
| 169 | 158 | |
| 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 | −} | |
| 159 | +MB_PREDICTION_MODE vp9_above_block_mode(const MODE_INFO *cur_mi, | |
| 160 | + const MODE_INFO *above_mi, int b); | |
| 183 | 161 | |
| 184 | 162 | enum mv_precision { |
| 185 | 163 | MV_PRECISION_Q3, |
| @@ -266,7 +244,8 @@ typedef struct macroblockd { · 80 unmodified lines | ||
| 266 | 244 | |
| 267 | 245 | |
| 268 | 246 | |
| 269 | −static BLOCK_SIZE get_subsize(BLOCK_SIZE bsize, PARTITION_TYPE partition) { | |
| 247 | +static INLINE BLOCK_SIZE get_subsize(BLOCK_SIZE bsize, | |
| 248 | + PARTITION_TYPE partition) { | |
| 270 | 249 | const BLOCK_SIZE subsize = subsize_lookup[partition][bsize]; |
| 271 | 250 | assert(subsize < BLOCK_SIZES); |
| 272 | 251 | return subsize; |
| @@ -298,23 +277,9 @@ static INLINE TX_TYPE get_tx_type_16x16(PLANE_TYPE plane_type, · 25 unmodified lines | ||
| 298 | 277 | : DCT_DCT; |
| 299 | 278 | } |
| 300 | 279 | |
| 301 | −static void setup_block_dptrs(MACROBLOCKD *xd, int ss_x, int ss_y) { | |
| 302 | − int i; | |
| 303 | − | |
| 304 | − for (i = 0; i < MAX_MB_PLANE; i++) { | |
| 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 | −} | |
| 280 | +void vp9_setup_block_planes(MACROBLOCKD *xd, int ss_x, int ss_y); | |
| 316 | 281 | |
| 317 | −static TX_SIZE get_uv_tx_size_impl(TX_SIZE y_tx_size, BLOCK_SIZE bsize) { | |
| 282 | +static INLINE TX_SIZE get_uv_tx_size_impl(TX_SIZE y_tx_size, BLOCK_SIZE bsize) { | |
| 318 | 283 | if (bsize < BLOCK_8X8) { |
| 319 | 284 | return TX_4X4; |
| 320 | 285 | } else { |
| @@ -324,12 +289,12 @@ static TX_SIZE get_uv_tx_size_impl(TX_SIZE y_tx_size, BLOCK_SIZE bsize) { · 3 unmodified lines | ||
| 324 | 289 | } |
| 325 | 290 | } |
| 326 | 291 | |
| 327 | −static TX_SIZE get_uv_tx_size(const MB_MODE_INFO *mbmi) { | |
| 292 | +static INLINE TX_SIZE get_uv_tx_size(const MB_MODE_INFO *mbmi) { | |
| 328 | 293 | return get_uv_tx_size_impl(mbmi->tx_size, mbmi->sb_type); |
| 329 | 294 | } |
| 330 | 295 | |
| 331 | −static BLOCK_SIZE get_plane_block_size(BLOCK_SIZE bsize, | |
| 332 | − const struct macroblockd_plane *pd) { | |
| 296 | +static INLINE BLOCK_SIZE get_plane_block_size(BLOCK_SIZE bsize, | |
| 297 | + const struct macroblockd_plane *pd) { | |
| 333 | 298 | BLOCK_SIZE bs = ss_size_lookup[bsize][pd->subsampling_x][pd->subsampling_y]; |
| 334 | 299 | assert(bs < BLOCK_SIZES); |
| 335 | 300 | return bs; |
| @@ -340,77 +305,23 @@ typedef void (*foreach_transformed_block_visitor)(int plane, int block, · 4 unmodified lines | ||
| 340 | 305 | TX_SIZE tx_size, |
| 341 | 306 | void *arg); |
| 342 | 307 | |
| 343 | −static INLINE void foreach_transformed_block_in_plane( | |
| 308 | +void vp9_foreach_transformed_block_in_plane( | |
| 344 | 309 | const MACROBLOCKD *const xd, BLOCK_SIZE bsize, int plane, |
| 345 | − 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 | − | |
| 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 | − | |
| 365 | − int max_blocks_wide = num_4x4_w; | |
| 366 | − int max_blocks_high = num_4x4_h; | |
| 367 | − | |
| 368 | − // xd->mb_to_right_edge is in units of pixels * 8. This converts | |
| 369 | − // it to 4x4 block sizes. | |
| 370 | − if (xd->mb_to_right_edge < 0) | |
| 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 | −} | |
| 310 | + foreach_transformed_block_visitor visit, void *arg); | |
| 392 | 311 | |
| 393 | −static INLINE void foreach_transformed_block( | |
| 312 | + | |
| 313 | +void vp9_foreach_transformed_block( | |
| 394 | 314 | const MACROBLOCKD* const xd, BLOCK_SIZE bsize, |
| 395 | − foreach_transformed_block_visitor visit, void *arg) { | |
| 396 | − int plane; | |
| 315 | + foreach_transformed_block_visitor visit, void *arg); | |
| 397 | 316 | |
| 398 | − for (plane = 0; plane < MAX_MB_PLANE; plane++) | |
| 399 | − foreach_transformed_block_in_plane(xd, bsize, plane, visit, arg); | |
| 400 | −} | |
| 401 | 317 | |
| 402 | −static INLINE void foreach_transformed_block_uv( | |
| 318 | +void vp9_foreach_transformed_block_uv( | |
| 403 | 319 | 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 | −} | |
| 320 | + foreach_transformed_block_visitor visit, void *arg); | |
| 410 | 321 | |
| 411 | −static void txfrm_block_to_raster_xy(BLOCK_SIZE plane_bsize, | |
| 412 | − TX_SIZE tx_size, int block, | |
| 413 | − int *x, int *y) { | |
| 322 | +static INLINE void txfrm_block_to_raster_xy(BLOCK_SIZE plane_bsize, | |
| 323 | + TX_SIZE tx_size, int block, | |
| 324 | + int *x, int *y) { | |
| 414 | 325 | const int bwl = b_width_log2(plane_bsize); |
| 415 | 326 | const int tx_cols_log2 = bwl - tx_size; |
| 416 | 327 | const int tx_cols = 1 << tx_cols_log2; |
| @@ -419,50 +330,13 @@ static void txfrm_block_to_raster_xy(BLOCK_SIZE plane_bsize, · 2 unmodified lines | ||
| 419 | 330 | *y = (raster_mb >> tx_cols_log2) << tx_size; |
| 420 | 331 | } |
| 421 | 332 | |
| 422 | −static void set_contexts(const MACROBLOCKD *xd, struct macroblockd_plane *pd, | |
| 423 | − BLOCK_SIZE plane_bsize, TX_SIZE tx_size, | |
| 424 | − int has_eob, 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 | − | |
| 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 | − | |
| 438 | − for (i = 0; i < above_contexts; ++i) | |
| 439 | − a[i] = has_eob; | |
| 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 | − } | |
| 333 | +void vp9_set_contexts(const MACROBLOCKD *xd, struct macroblockd_plane *pd, | |
| 334 | + BLOCK_SIZE plane_bsize, TX_SIZE tx_size, int has_eob, | |
| 335 | + int aoff, int loff); | |
| 445 | 336 | |
| 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 | 337 | |
| 464 | −static int get_tx_eob(const struct segmentation *seg, int segment_id, | |
| 465 | − TX_SIZE tx_size) { | |
| 338 | +static INLINE int get_tx_eob(const struct segmentation *seg, int segment_id, | |
| 339 | + TX_SIZE tx_size) { | |
| 466 | 340 | const int eob_max = 16 << (tx_size << 1); |
| 467 | 341 | return vp9_segfeature_active(seg, segment_id, SEG_LVL_SKIP) ? 0 : eob_max; |
| 468 | 342 | } |
| @@ -407,8 +407,8 @@ static void decode_modes_b(VP9_COMMON *const cm, MACROBLOCKD *const xd, · 406 unmodified lines | ||
| 407 | 407 | |
| 408 | 408 | if (!is_inter_block(mbmi)) { |
| 409 | 409 | struct intra_args arg = { cm, xd, r }; |
| 410 | − foreach_transformed_block(xd, bsize, predict_and_reconstruct_intra_block, | |
| 411 | − &arg); | |
| 410 | + vp9_foreach_transformed_block(xd, bsize, | |
| 411 | + predict_and_reconstruct_intra_block, &arg); | |
| 412 | 412 | } else { |
| 413 | 413 | // Setup |
| 414 | 414 | set_ref(cm, xd, 0, mi_row, mi_col); |
| @@ -424,7 +424,7 @@ static void decode_modes_b(VP9_COMMON *const cm, MACROBLOCKD *const xd, · 9 unmodified lines | ||
| 424 | 424 | if (!mbmi->skip_coeff) { |
| 425 | 425 | int eobtotal = 0; |
| 426 | 426 | struct inter_args arg = { cm, xd, r, &eobtotal }; |
| 427 | − foreach_transformed_block(xd, bsize, reconstruct_inter_block, &arg); | |
| 427 | + vp9_foreach_transformed_block(xd, bsize, reconstruct_inter_block, &arg); | |
| 428 | 428 | if (!less8x8 && eobtotal == 0) |
| 429 | 429 | mbmi->skip_coeff = 1; // skip loopfilter |
| 430 | 430 | } |
| @@ -1371,7 +1371,7 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) { · 940 unmodified lines | ||
| 1371 | 1371 | set_prev_mi(cm); |
| 1372 | 1372 | |
| 1373 | 1373 | setup_plane_dequants(cm, xd, cm->base_qindex); |
| 1374 | − setup_block_dptrs(xd, cm->subsampling_x, cm->subsampling_y); | |
| 1374 | + vp9_setup_block_planes(xd, cm->subsampling_x, cm->subsampling_y); | |
| 1375 | 1375 | |
| 1376 | 1376 | cm->fc = cm->frame_contexts[cm->frame_context_idx]; |
| 1377 | 1377 | vp9_zero(cm->counts); |
| @@ -175,8 +175,8 @@ static void read_intra_frame_mode_info(VP9_COMMON *const cm, · 174 unmodified lines | ||
| 175 | 175 | mbmi->ref_frame[1] = NONE; |
| 176 | 176 | |
| 177 | 177 | if (bsize >= BLOCK_8X8) { |
| 178 | − const MB_PREDICTION_MODE A = above_block_mode(mi, above_mi, 0); | |
| 179 | − const MB_PREDICTION_MODE L = left_block_mode(mi, left_mi, 0); | |
| 178 | + const MB_PREDICTION_MODE A = vp9_above_block_mode(mi, above_mi, 0); | |
| 179 | + const MB_PREDICTION_MODE L = vp9_left_block_mode(mi, left_mi, 0); | |
| 180 | 180 | mbmi->mode = read_intra_mode(r, vp9_kf_y_mode_prob[A][L]); |
| 181 | 181 | } else { |
| 182 | 182 | // Only 4x4, 4x8, 8x4 blocks |
| @@ -187,8 +187,8 @@ static void read_intra_frame_mode_info(VP9_COMMON *const cm, · 4 unmodified lines | ||
| 187 | 187 | for (idy = 0; idy < 2; idy += num_4x4_h) { |
| 188 | 188 | for (idx = 0; idx < 2; idx += num_4x4_w) { |
| 189 | 189 | const int ib = idy * 2 + idx; |
| 190 | − const MB_PREDICTION_MODE A = above_block_mode(mi, above_mi, ib); | |
| 191 | − const MB_PREDICTION_MODE L = left_block_mode(mi, left_mi, ib); | |
| 190 | + const MB_PREDICTION_MODE A = vp9_above_block_mode(mi, above_mi, ib); | |
| 191 | + const MB_PREDICTION_MODE L = vp9_left_block_mode(mi, left_mi, ib); | |
| 192 | 192 | const MB_PREDICTION_MODE b_mode = read_intra_mode(r, |
| 193 | 193 | vp9_kf_y_mode_prob[A][L]); |
| 194 | 194 | mi->bmi[ib].as_mode = b_mode; |
| @@ -204,7 +204,7 @@ int vp9_decode_block_tokens(VP9_COMMON *cm, MACROBLOCKD *xd, · 203 unmodified lines | ||
| 204 | 204 | const int eob = decode_coefs(cm, xd, pd->plane_type, |
| 205 | 205 | BLOCK_OFFSET(pd->dqcoeff, block), tx_size, |
| 206 | 206 | pd->dequant, ctx, so->scan, so->neighbors, r); |
| 207 | − set_contexts(xd, pd, plane_bsize, tx_size, eob > 0, x, y); | |
| 207 | + vp9_set_contexts(xd, pd, plane_bsize, tx_size, eob > 0, x, y); | |
| 208 | 208 | return eob; |
| 209 | 209 | } |
| 210 | 210 | |
| @@ -393,8 +393,8 @@ static void write_mb_modes_kf(const VP9_COMP *cpi, MODE_INFO **mi_8x8, · 392 unmodified lines | ||
| 393 | 393 | write_selected_tx_size(cpi, m, m->mbmi.tx_size, m->mbmi.sb_type, bc); |
| 394 | 394 | |
| 395 | 395 | if (m->mbmi.sb_type >= BLOCK_8X8) { |
| 396 | − const MB_PREDICTION_MODE A = above_block_mode(m, above_mi, 0); | |
| 397 | − const MB_PREDICTION_MODE L = left_block_mode(m, left_mi, 0); | |
| 396 | + const MB_PREDICTION_MODE A = vp9_above_block_mode(m, above_mi, 0); | |
| 397 | + const MB_PREDICTION_MODE L = vp9_left_block_mode(m, left_mi, 0); | |
| 398 | 398 | write_intra_mode(bc, ym, vp9_kf_y_mode_prob[A][L]); |
| 399 | 399 | } else { |
| 400 | 400 | int idx, idy; |
| @@ -403,8 +403,8 @@ static void write_mb_modes_kf(const VP9_COMP *cpi, MODE_INFO **mi_8x8, · 2 unmodified lines | ||
| 403 | 403 | for (idy = 0; idy < 2; idy += num_4x4_blocks_high) { |
| 404 | 404 | for (idx = 0; idx < 2; idx += num_4x4_blocks_wide) { |
| 405 | 405 | int i = idy * 2 + idx; |
| 406 | − const MB_PREDICTION_MODE A = above_block_mode(m, above_mi, i); | |
| 407 | − const MB_PREDICTION_MODE L = left_block_mode(m, left_mi, i); | |
| 406 | + const MB_PREDICTION_MODE A = vp9_above_block_mode(m, above_mi, i); | |
| 407 | + const MB_PREDICTION_MODE L = vp9_left_block_mode(m, left_mi, i); | |
| 408 | 408 | const int bm = m->bmi[i].as_mode; |
| 409 | 409 | write_intra_mode(bc, bm, vp9_kf_y_mode_prob[A][L]); |
| 410 | 410 | } |
| @@ -2142,7 +2142,7 @@ static void init_encode_frame_mb_context(VP9_COMP *cpi) { · 2141 unmodified lines | ||
| 2142 | 2142 | setup_pre_planes(xd, 0, get_ref_frame_buffer(cpi, LAST_FRAME), 0, 0, NULL); |
| 2143 | 2143 | setup_dst_planes(xd, get_frame_new_buffer(cm), 0, 0); |
| 2144 | 2144 | |
| 2145 | − setup_block_dptrs(&x->e_mbd, cm->subsampling_x, cm->subsampling_y); | |
| 2145 | + vp9_setup_block_planes(&x->e_mbd, cm->subsampling_x, cm->subsampling_y); | |
| 2146 | 2146 | |
| 2147 | 2147 | xd->mi_8x8[0]->mbmi.mode = DC_PRED; |
| 2148 | 2148 | xd->mi_8x8[0]->mbmi.uv_mode = DC_PRED; |
| @@ -487,7 +487,8 @@ void vp9_encode_sby(MACROBLOCK *x, BLOCK_SIZE bsize) { · 486 unmodified lines | ||
| 487 | 487 | if (x->optimize) |
| 488 | 488 | optimize_init_b(0, bsize, &arg); |
| 489 | 489 | |
| 490 | − foreach_transformed_block_in_plane(xd, bsize, 0, encode_block_pass1, &arg); | |
| 490 | + vp9_foreach_transformed_block_in_plane(xd, bsize, 0, encode_block_pass1, | |
| 491 | + &arg); | |
| 491 | 492 | } |
| 492 | 493 | |
| 493 | 494 | void vp9_encode_sb(MACROBLOCK *x, BLOCK_SIZE bsize) { |
| @@ -505,7 +506,7 @@ void vp9_encode_sb(MACROBLOCK *x, BLOCK_SIZE bsize) { · 11 unmodified lines | ||
| 505 | 506 | optimize_init_b(i, bsize, &arg); |
| 506 | 507 | } |
| 507 | 508 | |
| 508 | − foreach_transformed_block(xd, bsize, encode_block, &arg); | |
| 509 | + vp9_foreach_transformed_block(xd, bsize, encode_block, &arg); | |
| 509 | 510 | } |
| 510 | 511 | |
| 511 | 512 | void vp9_encode_block_intra(int plane, int block, BLOCK_SIZE plane_bsize, |
| @@ -648,7 +649,7 @@ void vp9_encode_intra_block_y(MACROBLOCK *x, BLOCK_SIZE bsize) { · 136 unmodified lines | ||
| 648 | 649 | MB_MODE_INFO *mbmi = &xd->mi_8x8[0]->mbmi; |
| 649 | 650 | struct encode_b_args arg = {x, &ctx, &mbmi->skip_coeff}; |
| 650 | 651 | |
| 651 | − foreach_transformed_block_in_plane(xd, bsize, 0, vp9_encode_block_intra, | |
| 652 | + vp9_foreach_transformed_block_in_plane(xd, bsize, 0, vp9_encode_block_intra, | |
| 652 | 653 | &arg); |
| 653 | 654 | } |
| 654 | 655 | void vp9_encode_intra_block_uv(MACROBLOCK *x, BLOCK_SIZE bsize) { |
| @@ -656,7 +657,7 @@ void vp9_encode_intra_block_uv(MACROBLOCK *x, BLOCK_SIZE bsize) { · 1 unmodified line | ||
| 656 | 657 | struct optimize_ctx ctx; |
| 657 | 658 | MB_MODE_INFO *mbmi = &xd->mi_8x8[0]->mbmi; |
| 658 | 659 | struct encode_b_args arg = {x, &ctx, &mbmi->skip_coeff}; |
| 659 | − foreach_transformed_block_uv(xd, bsize, vp9_encode_block_intra, &arg); | |
| 660 | + vp9_foreach_transformed_block_uv(xd, bsize, vp9_encode_block_intra, &arg); | |
| 660 | 661 | } |
| 661 | 662 | |
| 662 | 663 | int vp9_encode_intra(MACROBLOCK *x, int use_16x16_pred) { |
| @@ -505,7 +505,7 @@ void vp9_first_pass(VP9_COMP *cpi) { · 504 unmodified lines | ||
| 505 | 505 | xd->mi_8x8 = cm->mi_grid_visible; |
| 506 | 506 | xd->mi_8x8[0] = cm->mi; // required for vp9_frame_init_quantizer |
| 507 | 507 | |
| 508 | − setup_block_dptrs(&x->e_mbd, cm->subsampling_x, cm->subsampling_y); | |
| 508 | + vp9_setup_block_planes(&x->e_mbd, cm->subsampling_x, cm->subsampling_y); | |
| 509 | 509 | |
| 510 | 510 | vp9_frame_init_quantizer(cpi); |
| 511 | 511 | |
| @@ -742,8 +742,8 @@ static void txfm_rd_in_plane(MACROBLOCK *x, · 741 unmodified lines | ||
| 742 | 742 | rd_stack.scan = so->scan; |
| 743 | 743 | rd_stack.nb = so->neighbors; |
| 744 | 744 | |
| 745 | − foreach_transformed_block_in_plane(xd, bsize, plane, | |
| 746 | − block_rd_txfm, &rd_stack); | |
| 745 | + vp9_foreach_transformed_block_in_plane(xd, bsize, plane, | |
| 746 | + block_rd_txfm, &rd_stack); | |
| 747 | 747 | if (rd_stack.skip) { |
| 748 | 748 | *rate = INT_MAX; |
| 749 | 749 | *distortion = INT64_MAX; |
| @@ -1150,8 +1150,8 @@ static int64_t rd_pick_intra_sub_8x8_y_mode(VP9_COMP * const cpi, · 400 unmodified lines | ||
| 1150 | 1150 | int64_t d = INT64_MAX, this_rd = INT64_MAX; |
| 1151 | 1151 | i = idy * 2 + idx; |
| 1152 | 1152 | if (cpi->common.frame_type == KEY_FRAME) { |
| 1153 | − const MB_PREDICTION_MODE A = above_block_mode(mic, above_mi, i); | |
| 1154 | − const MB_PREDICTION_MODE L = left_block_mode(mic, left_mi, i); | |
| 1153 | + const MB_PREDICTION_MODE A = vp9_above_block_mode(mic, above_mi, i); | |
| 1154 | + const MB_PREDICTION_MODE L = vp9_left_block_mode(mic, left_mi, i); | |
| 1155 | 1155 | |
| 1156 | 1156 | bmode_costs = mb->y_mode_costs[A][L]; |
| 1157 | 1157 | } |
| @@ -1216,8 +1216,8 @@ static int64_t rd_pick_intra_sby_mode(VP9_COMP *cpi, MACROBLOCK *x, · 58 unmodified lines | ||
| 1216 | 1216 | continue; |
| 1217 | 1217 | |
| 1218 | 1218 | if (cpi->common.frame_type == KEY_FRAME) { |
| 1219 | − const MB_PREDICTION_MODE A = above_block_mode(mic, above_mi, 0); | |
| 1220 | − const MB_PREDICTION_MODE L = left_block_mode(mic, left_mi, 0); | |
| 1219 | + const MB_PREDICTION_MODE A = vp9_above_block_mode(mic, above_mi, 0); | |
| 1220 | + const MB_PREDICTION_MODE L = vp9_left_block_mode(mic, left_mi, 0); | |
| 1221 | 1221 | |
| 1222 | 1222 | bmode_costs = x->y_mode_costs[A][L]; |
| 1223 | 1223 | } |
| @@ -172,7 +172,8 @@ static void set_entropy_context_b(int plane, int block, BLOCK_SIZE plane_bsize, · 171 unmodified lines | ||
| 172 | 172 | struct macroblockd_plane *pd = &xd->plane[plane]; |
| 173 | 173 | int aoff, loff; |
| 174 | 174 | txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &aoff, &loff); |
| 175 | − set_contexts(xd, pd, plane_bsize, tx_size, p->eobs[block] > 0, aoff, loff); | |
| 175 | + vp9_set_contexts(xd, pd, plane_bsize, tx_size, p->eobs[block] > 0, | |
| 176 | + aoff, loff); | |
| 176 | 177 | } |
| 177 | 178 | |
| 178 | 179 | static INLINE void add_token(TOKENEXTRA **t, const vp9_prob *context_tree, |
| @@ -259,7 +260,7 @@ static void tokenize_b(int plane, int block, BLOCK_SIZE plane_bsize, · 80 unmodified lines | ||
| 259 | 260 | |
| 260 | 261 | *tp = t; |
| 261 | 262 | |
| 262 | − set_contexts(xd, pd, plane_bsize, tx_size, c > 0, aoff, loff); | |
| 263 | + vp9_set_contexts(xd, pd, plane_bsize, tx_size, c > 0, aoff, loff); | |
| 263 | 264 | } |
| 264 | 265 | |
| 265 | 266 | struct is_skippable_args { |
| @@ -277,15 +278,15 @@ static void is_skippable(int plane, int block, · 11 unmodified lines | ||
| 277 | 278 | static int sb_is_skippable(MACROBLOCK *x, BLOCK_SIZE bsize) { |
| 278 | 279 | int result = 1; |
| 279 | 280 | struct is_skippable_args args = {x, &result}; |
| 280 | − foreach_transformed_block(&x->e_mbd, bsize, is_skippable, &args); | |
| 281 | + vp9_foreach_transformed_block(&x->e_mbd, bsize, is_skippable, &args); | |
| 281 | 282 | return result; |
| 282 | 283 | } |
| 283 | 284 | |
| 284 | 285 | int vp9_is_skippable_in_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane) { |
| 285 | 286 | int result = 1; |
| 286 | 287 | struct is_skippable_args args = {x, &result}; |
| 287 | − foreach_transformed_block_in_plane(&x->e_mbd, bsize, plane, is_skippable, | |
| 288 | − &args); | |
| 288 | + vp9_foreach_transformed_block_in_plane(&x->e_mbd, bsize, plane, is_skippable, | |
| 289 | + &args); | |
| 289 | 290 | return result; |
| 290 | 291 | } |
| 291 | 292 | |
| @@ -310,9 +311,9 @@ void vp9_tokenize_sb(VP9_COMP *cpi, TOKENEXTRA **t, int dry_run, · 18 unmodified lines | ||
| 310 | 311 | |
| 311 | 312 | if (!dry_run) { |
| 312 | 313 | cm->counts.skip[ctx][0] += skip_inc; |
| 313 | − foreach_transformed_block(xd, bsize, tokenize_b, &arg); | |
| 314 | + vp9_foreach_transformed_block(xd, bsize, tokenize_b, &arg); | |
| 314 | 315 | } else { |
| 315 | − foreach_transformed_block(xd, bsize, set_entropy_context_b, &arg); | |
| 316 | + vp9_foreach_transformed_block(xd, bsize, set_entropy_context_b, &arg); | |
| 316 | 317 | *t = t_backup; |
| 317 | 318 | } |
| 318 | 319 | } |
| @@ -14,6 +14,7 @@ VP9_COMMON_SRCS-yes += common/vp9_pragmas.h · 13 unmodified lines | ||
| 14 | 14 | VP9_COMMON_SRCS-yes += common/vp9_ppflags.h |
| 15 | 15 | VP9_COMMON_SRCS-yes += common/vp9_onyx.h |
| 16 | 16 | VP9_COMMON_SRCS-yes += common/vp9_alloccommon.c |
| 17 | +VP9_COMMON_SRCS-yes += common/vp9_blockd.c | |
| 17 | 18 | VP9_COMMON_SRCS-yes += common/vp9_convolve.c |
| 18 | 19 | VP9_COMMON_SRCS-yes += common/vp9_convolve.h |
| 19 | 20 | VP9_COMMON_SRCS-yes += common/vp9_debugmodes.c |