2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
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.
12 #ifndef VP9_COMMON_VP9_BLOCKD_H_
13 #define VP9_COMMON_VP9_BLOCKD_H_
15 #include "./vpx_config.h"
17 #include "vpx_ports/mem.h"
18 #include "vpx_scale/yv12config.h"
20 #include "vp9/common/vp9_common.h"
21 #include "vp9/common/vp9_common_data.h"
22 #include "vp9/common/vp9_convolve.h"
23 #include "vp9/common/vp9_enums.h"
24 #include "vp9/common/vp9_mv.h"
25 #include "vp9/common/vp9_seg_common.h"
26 #include "vp9/common/vp9_treecoder.h"
28 #define BLOCK_SIZE_GROUPS 4
30 #define PREDICTION_PROBS 3
32 #define MBSKIP_CONTEXTS 3
34 #define MAX_REF_LF_DELTAS 4
35 #define MAX_MODE_LF_DELTAS 2
37 /* Segment Feature Masks */
38 #define MAX_MV_REF_CANDIDATES 2
40 #define INTRA_INTER_CONTEXTS 4
41 #define COMP_INTER_CONTEXTS 5
42 #define REF_CONTEXTS 5
49 typedef char ENTROPY_CONTEXT;
51 typedef char PARTITION_CONTEXT;
53 static INLINE int combine_entropy_contexts(ENTROPY_CONTEXT a,
55 return (a != 0) + (b != 0);
69 SWITCHABLE /* should be the last one */
70 } INTERPOLATIONFILTERTYPE;
73 DC_PRED, // Average of above and left pixels
76 D45_PRED, // Directional 45 deg = round(arctan(1/1) * 180/pi)
77 D135_PRED, // Directional 135 deg = 180 - 45
78 D117_PRED, // Directional 117 deg = 180 - 63
79 D153_PRED, // Directional 153 deg = 180 - 27
80 D27_PRED, // Directional 27 deg = round(arctan(1/2) * 180/pi)
81 D63_PRED, // Directional 63 deg = round(arctan(2/1) * 180/pi)
82 TM_PRED, // True-motion
90 static INLINE int is_intra_mode(MB_PREDICTION_MODE mode) {
91 return mode <= TM_PRED;
94 static INLINE int is_inter_mode(MB_PREDICTION_MODE mode) {
95 return mode >= NEARESTMV && mode <= NEWMV;
98 #define VP9_INTRA_MODES (TM_PRED + 1)
100 #define VP9_INTER_MODES (1 + NEWMV - NEARESTMV)
102 /* For keyframes, intra block modes are predicted by the (already decoded)
103 modes for the Y blocks to the left and above us; for interframes, there
104 is a single probability table. */
107 MB_PREDICTION_MODE as_mode;
108 int_mv as_mv[2]; // first, second inter predictor motion vectors
118 } MV_REFERENCE_FRAME;
120 static INLINE int b_width_log2(BLOCK_SIZE_TYPE sb_type) {
121 return b_width_log2_lookup[sb_type];
123 static INLINE int b_height_log2(BLOCK_SIZE_TYPE sb_type) {
124 return b_height_log2_lookup[sb_type];
127 static INLINE int mi_width_log2(BLOCK_SIZE_TYPE sb_type) {
128 return mi_width_log2_lookup[sb_type];
131 static INLINE int mi_height_log2(BLOCK_SIZE_TYPE sb_type) {
132 return mi_height_log2_lookup[sb_type];
136 MB_PREDICTION_MODE mode, uv_mode;
137 MV_REFERENCE_FRAME ref_frame[2];
139 int_mv mv[2]; // for each reference frame used
140 int_mv ref_mvs[MAX_REF_FRAMES][MAX_MV_REF_CANDIDATES];
141 int_mv best_mv, best_second_mv;
143 uint8_t mb_mode_context[MAX_REF_FRAMES];
145 unsigned char mb_skip_coeff; /* does this mb has coefficients at all, 1=no coefficients, 0=need decode tokens */
146 unsigned char segment_id; // Segment id for current frame
148 // Flags used for prediction status of various bistream signals
149 unsigned char seg_id_predicted;
151 // Indicates if the mb is part of the image (1) vs border (0)
152 // This can be useful in determining whether the MB provides
154 unsigned char mb_in_image;
156 INTERPOLATIONFILTERTYPE interp_filter;
158 BLOCK_SIZE_TYPE sb_type;
163 union b_mode_info bmi[4];
171 #define VP9_REF_SCALE_SHIFT 14
172 #define VP9_REF_NO_SCALE 16384
174 struct scale_factors {
175 int x_scale_fp; // horizontal fixed point scale factor
176 int y_scale_fp; // vertical fixed point scale factor
182 int (*scale_value_x)(int val, const struct scale_factors *scale);
183 int (*scale_value_y)(int val, const struct scale_factors *scale);
184 void (*set_scaled_offsets)(struct scale_factors *scale, int row, int col);
185 MV32 (*scale_mv_q3_to_q4)(const MV *mv, const struct scale_factors *scale);
186 MV32 (*scale_mv_q4)(const MV *mv, const struct scale_factors *scale);
188 convolve_fn_t predict[2][2][2]; // horiz, vert, avg
192 enum { MAX_MB_PLANE = 4 };
194 enum { MAX_MB_PLANE = 3 };
202 struct macroblockd_plane {
203 DECLARE_ALIGNED(16, int16_t, qcoeff[64 * 64]);
204 DECLARE_ALIGNED(16, int16_t, dqcoeff[64 * 64]);
205 DECLARE_ALIGNED(16, uint16_t, eobs[256]);
206 PLANE_TYPE plane_type;
210 struct buf_2d pre[2];
212 ENTROPY_CONTEXT *above_context;
213 ENTROPY_CONTEXT *left_context;
216 #define BLOCK_OFFSET(x, i, n) ((x) + (i) * (n))
218 typedef struct macroblockd {
219 struct macroblockd_plane plane[MAX_MB_PLANE];
221 struct scale_factors scale_factor[2];
222 struct scale_factors scale_factor_uv[2];
224 MODE_INFO *prev_mode_info_context;
225 MODE_INFO *mode_info_context;
226 int mode_info_stride;
228 FRAME_TYPE frame_type;
234 struct segmentation seg;
236 // partition contexts
237 PARTITION_CONTEXT *above_seg_context;
238 PARTITION_CONTEXT *left_seg_context;
240 /* mode_based Loop filter adjustment */
241 unsigned char mode_ref_lf_delta_enabled;
242 unsigned char mode_ref_lf_delta_update;
244 /* Delta values have the range +/- MAX_LOOP_FILTER */
245 /* 0 = Intra, Last, GF, ARF */
246 signed char last_ref_lf_deltas[MAX_REF_LF_DELTAS];
247 /* 0 = Intra, Last, GF, ARF */
248 signed char ref_lf_deltas[MAX_REF_LF_DELTAS];
250 /* 0 = ZERO_MV, MV */
251 signed char last_mode_lf_deltas[MAX_MODE_LF_DELTAS];
252 /* 0 = ZERO_MV, MV */
253 signed char mode_lf_deltas[MAX_MODE_LF_DELTAS];
255 /* Distance of MB away from frame edges */
257 int mb_to_right_edge;
259 int mb_to_bottom_edge;
261 unsigned int frames_since_golden;
262 unsigned int frames_till_alt_ref_frame;
265 /* Inverse transform function pointers. */
266 void (*inv_txm4x4_1_add)(int16_t *input, uint8_t *dest, int stride);
267 void (*inv_txm4x4_add)(int16_t *input, uint8_t *dest, int stride);
268 void (*itxm_add)(int16_t *input, uint8_t *dest, int stride, int eob);
270 struct subpix_fn_table subpix;
272 int allow_high_precision_mv;
276 int sb_index; // index of 32x32 block inside the 64x64 block
277 int mb_index; // index of 16x16 block inside the 32x32 block
278 int b_index; // index of 8x8 block inside the 16x16 block
279 int ab_index; // index of 4x4 block inside the 8x8 block
284 static INLINE int *get_sb_index(MACROBLOCKD *xd, BLOCK_SIZE_TYPE subsize) {
286 case BLOCK_SIZE_SB64X64:
287 case BLOCK_SIZE_SB64X32:
288 case BLOCK_SIZE_SB32X64:
289 case BLOCK_SIZE_SB32X32:
290 return &xd->sb_index;
291 case BLOCK_SIZE_SB32X16:
292 case BLOCK_SIZE_SB16X32:
293 case BLOCK_SIZE_MB16X16:
294 return &xd->mb_index;
295 case BLOCK_SIZE_SB16X8:
296 case BLOCK_SIZE_SB8X16:
297 case BLOCK_SIZE_SB8X8:
299 case BLOCK_SIZE_SB8X4:
300 case BLOCK_SIZE_SB4X8:
301 case BLOCK_SIZE_AB4X4:
302 return &xd->ab_index;
309 static INLINE void update_partition_context(MACROBLOCKD *xd,
310 BLOCK_SIZE_TYPE sb_type,
311 BLOCK_SIZE_TYPE sb_size) {
312 const int bsl = b_width_log2(sb_size), bs = (1 << bsl) / 2;
313 const int bwl = b_width_log2(sb_type);
314 const int bhl = b_height_log2(sb_type);
315 const int boffset = b_width_log2(BLOCK_SIZE_SB64X64) - bsl;
316 const char pcval0 = ~(0xe << boffset);
317 const char pcval1 = ~(0xf << boffset);
318 const char pcvalue[2] = {pcval0, pcval1};
320 assert(MAX(bwl, bhl) <= bsl);
322 // update the partition context at the end notes. set partition bits
323 // of block sizes larger than the current one to be one, and partition
324 // bits of smaller block sizes to be zero.
325 vpx_memset(xd->above_seg_context, pcvalue[bwl == bsl], bs);
326 vpx_memset(xd->left_seg_context, pcvalue[bhl == bsl], bs);
329 static INLINE int partition_plane_context(MACROBLOCKD *xd,
330 BLOCK_SIZE_TYPE sb_type) {
331 int bsl = mi_width_log2(sb_type), bs = 1 << bsl;
332 int above = 0, left = 0, i;
333 int boffset = mi_width_log2(BLOCK_SIZE_SB64X64) - bsl;
335 assert(mi_width_log2(sb_type) == mi_height_log2(sb_type));
337 assert(boffset >= 0);
339 for (i = 0; i < bs; i++)
340 above |= (xd->above_seg_context[i] & (1 << boffset));
341 for (i = 0; i < bs; i++)
342 left |= (xd->left_seg_context[i] & (1 << boffset));
347 return (left * 2 + above) + bsl * PARTITION_PLOFFSET;
350 static BLOCK_SIZE_TYPE get_subsize(BLOCK_SIZE_TYPE bsize,
351 PARTITION_TYPE partition) {
352 BLOCK_SIZE_TYPE subsize = subsize_lookup[partition][bsize];
353 assert(subsize != BLOCK_SIZE_TYPES);
357 extern const TX_TYPE mode2txfm_map[MB_MODE_COUNT];
359 static INLINE TX_TYPE get_tx_type_4x4(const MACROBLOCKD *xd, int ib) {
360 MODE_INFO *const mi = xd->mode_info_context;
361 MB_MODE_INFO *const mbmi = &mi->mbmi;
363 if (xd->lossless || mbmi->ref_frame[0] != INTRA_FRAME)
366 return mode2txfm_map[mbmi->sb_type < BLOCK_SIZE_SB8X8 ?
367 mi->bmi[ib].as_mode : mbmi->mode];
370 static INLINE TX_TYPE get_tx_type_8x8(const MACROBLOCKD *xd) {
371 return mode2txfm_map[xd->mode_info_context->mbmi.mode];
374 static INLINE TX_TYPE get_tx_type_16x16(const MACROBLOCKD *xd) {
375 return mode2txfm_map[xd->mode_info_context->mbmi.mode];
378 static void setup_block_dptrs(MACROBLOCKD *xd, int ss_x, int ss_y) {
381 for (i = 0; i < MAX_MB_PLANE; i++) {
382 xd->plane[i].plane_type = i ? PLANE_TYPE_UV : PLANE_TYPE_Y_WITH_DC;
383 xd->plane[i].subsampling_x = i ? ss_x : 0;
384 xd->plane[i].subsampling_y = i ? ss_y : 0;
387 // TODO(jkoleszar): Using the Y w/h for now
388 xd->plane[3].subsampling_x = 0;
389 xd->plane[3].subsampling_y = 0;
394 static INLINE TX_SIZE get_uv_tx_size(const MB_MODE_INFO *mbmi) {
395 const TX_SIZE size = mbmi->txfm_size;
396 const TX_SIZE max_size = max_uv_txsize_lookup[mbmi->sb_type];
397 return (size > max_size ? max_size : size);
400 struct plane_block_idx {
405 // TODO(jkoleszar): returning a struct so it can be used in a const context,
406 // expect to refactor this further later.
407 static INLINE struct plane_block_idx plane_block_idx(int y_blocks,
409 const int v_offset = y_blocks * 5 / 4;
410 struct plane_block_idx res;
412 if (b_idx < y_blocks) {
415 } else if (b_idx < v_offset) {
417 res.block = b_idx - y_blocks;
419 assert(b_idx < y_blocks * 3 / 2);
421 res.block = b_idx - v_offset;
426 static INLINE int plane_block_width(BLOCK_SIZE_TYPE bsize,
427 const struct macroblockd_plane* plane) {
428 return 4 << (b_width_log2(bsize) - plane->subsampling_x);
431 static INLINE int plane_block_height(BLOCK_SIZE_TYPE bsize,
432 const struct macroblockd_plane* plane) {
433 return 4 << (b_height_log2(bsize) - plane->subsampling_y);
436 static INLINE int plane_block_width_log2by4(
437 BLOCK_SIZE_TYPE bsize, const struct macroblockd_plane* plane) {
438 return (b_width_log2(bsize) - plane->subsampling_x);
441 static INLINE int plane_block_height_log2by4(
442 BLOCK_SIZE_TYPE bsize, const struct macroblockd_plane* plane) {
443 return (b_height_log2(bsize) - plane->subsampling_y);
446 typedef void (*foreach_transformed_block_visitor)(int plane, int block,
447 BLOCK_SIZE_TYPE bsize,
451 static INLINE void foreach_transformed_block_in_plane(
452 const MACROBLOCKD* const xd, BLOCK_SIZE_TYPE bsize, int plane,
453 foreach_transformed_block_visitor visit, void *arg) {
454 const int bw = b_width_log2(bsize), bh = b_height_log2(bsize);
456 // block and transform sizes, in number of 4x4 blocks log 2 ("*_b")
457 // 4x4=0, 8x8=2, 16x16=4, 32x32=6, 64x64=8
458 // transform size varies per plane, look it up in a common way.
459 const MB_MODE_INFO* mbmi = &xd->mode_info_context->mbmi;
460 const TX_SIZE tx_size = plane ? get_uv_tx_size(mbmi)
462 const int block_size_b = bw + bh;
463 const int txfrm_size_b = tx_size * 2;
465 // subsampled size of the block
466 const int ss_sum = xd->plane[plane].subsampling_x
467 + xd->plane[plane].subsampling_y;
468 const int ss_block_size = block_size_b - ss_sum;
470 const int step = 1 << txfrm_size_b;
474 assert(txfrm_size_b <= block_size_b);
475 assert(txfrm_size_b <= ss_block_size);
477 // If mb_to_right_edge is < 0 we are in a situation in which
478 // the current block size extends into the UMV and we won't
479 // visit the sub blocks that are wholly within the UMV.
480 if (xd->mb_to_right_edge < 0 || xd->mb_to_bottom_edge < 0) {
482 const int sw = bw - xd->plane[plane].subsampling_x;
483 const int sh = bh - xd->plane[plane].subsampling_y;
484 int max_blocks_wide = 1 << sw;
485 int max_blocks_high = 1 << sh;
487 // xd->mb_to_right_edge is in units of pixels * 8. This converts
488 // it to 4x4 block sizes.
489 if (xd->mb_to_right_edge < 0)
491 + (xd->mb_to_right_edge >> (5 + xd->plane[plane].subsampling_x));
493 if (xd->mb_to_bottom_edge < 0)
495 + (xd->mb_to_bottom_edge >> (5 + xd->plane[plane].subsampling_y));
498 // Unlike the normal case - in here we have to keep track of the
499 // row and column of the blocks we use so that we know if we are in
500 // the unrestricted motion border..
501 for (r = 0; r < (1 << sh); r += (1 << tx_size)) {
502 for (c = 0; c < (1 << sw); c += (1 << tx_size)) {
503 if (r < max_blocks_high && c < max_blocks_wide)
504 visit(plane, i, bsize, txfrm_size_b, arg);
509 for (i = 0; i < (1 << ss_block_size); i += step) {
510 visit(plane, i, bsize, txfrm_size_b, arg);
515 static INLINE void foreach_transformed_block(
516 const MACROBLOCKD* const xd, BLOCK_SIZE_TYPE bsize,
517 foreach_transformed_block_visitor visit, void *arg) {
520 for (plane = 0; plane < MAX_MB_PLANE; plane++) {
521 foreach_transformed_block_in_plane(xd, bsize, plane,
526 static INLINE void foreach_transformed_block_uv(
527 const MACROBLOCKD* const xd, BLOCK_SIZE_TYPE bsize,
528 foreach_transformed_block_visitor visit, void *arg) {
531 for (plane = 1; plane < MAX_MB_PLANE; plane++) {
532 foreach_transformed_block_in_plane(xd, bsize, plane,
537 // TODO(jkoleszar): In principle, pred_w, pred_h are unnecessary, as we could
538 // calculate the subsampled BLOCK_SIZE_TYPE, but that type isn't defined for
539 // sizes smaller than 16x16 yet.
540 typedef void (*foreach_predicted_block_visitor)(int plane, int block,
541 BLOCK_SIZE_TYPE bsize,
542 int pred_w, int pred_h,
544 static INLINE void foreach_predicted_block_in_plane(
545 const MACROBLOCKD* const xd, BLOCK_SIZE_TYPE bsize, int plane,
546 foreach_predicted_block_visitor visit, void *arg) {
549 // block sizes in number of 4x4 blocks log 2 ("*_b")
550 // 4x4=0, 8x8=2, 16x16=4, 32x32=6, 64x64=8
551 // subsampled size of the block
552 const int bwl = b_width_log2(bsize) - xd->plane[plane].subsampling_x;
553 const int bhl = b_height_log2(bsize) - xd->plane[plane].subsampling_y;
555 // size of the predictor to use.
558 if (xd->mode_info_context->mbmi.sb_type < BLOCK_SIZE_SB8X8) {
559 assert(bsize == BLOCK_SIZE_SB8X8);
566 assert(pred_w <= bwl);
567 assert(pred_h <= bhl);
569 // visit each subblock in raster order
571 for (y = 0; y < 1 << bhl; y += 1 << pred_h) {
572 for (x = 0; x < 1 << bwl; x += 1 << pred_w) {
573 visit(plane, i, bsize, pred_w, pred_h, arg);
576 i += (1 << (bwl + pred_h)) - (1 << bwl);
579 static INLINE void foreach_predicted_block(
580 const MACROBLOCKD* const xd, BLOCK_SIZE_TYPE bsize,
581 foreach_predicted_block_visitor visit, void *arg) {
584 for (plane = 0; plane < MAX_MB_PLANE; plane++) {
585 foreach_predicted_block_in_plane(xd, bsize, plane, visit, arg);
588 static INLINE void foreach_predicted_block_uv(
589 const MACROBLOCKD* const xd, BLOCK_SIZE_TYPE bsize,
590 foreach_predicted_block_visitor visit, void *arg) {
593 for (plane = 1; plane < MAX_MB_PLANE; plane++) {
594 foreach_predicted_block_in_plane(xd, bsize, plane, visit, arg);
597 static int raster_block_offset(MACROBLOCKD *xd, BLOCK_SIZE_TYPE bsize,
598 int plane, int block, int stride) {
599 const int bw = b_width_log2(bsize) - xd->plane[plane].subsampling_x;
600 const int y = 4 * (block >> bw), x = 4 * (block & ((1 << bw) - 1));
601 return y * stride + x;
603 static int16_t* raster_block_offset_int16(MACROBLOCKD *xd,
604 BLOCK_SIZE_TYPE bsize,
605 int plane, int block, int16_t *base) {
606 const int stride = plane_block_width(bsize, &xd->plane[plane]);
607 return base + raster_block_offset(xd, bsize, plane, block, stride);
609 static uint8_t* raster_block_offset_uint8(MACROBLOCKD *xd,
610 BLOCK_SIZE_TYPE bsize,
611 int plane, int block,
612 uint8_t *base, int stride) {
613 return base + raster_block_offset(xd, bsize, plane, block, stride);
616 static int txfrm_block_to_raster_block(MACROBLOCKD *xd,
617 BLOCK_SIZE_TYPE bsize,
618 int plane, int block,
620 const int bwl = b_width_log2(bsize) - xd->plane[plane].subsampling_x;
621 const int txwl = ss_txfrm_size / 2;
622 const int tx_cols_log2 = bwl - txwl;
623 const int tx_cols = 1 << tx_cols_log2;
624 const int raster_mb = block >> ss_txfrm_size;
625 const int x = (raster_mb & (tx_cols - 1)) << (txwl);
626 const int y = raster_mb >> tx_cols_log2 << (txwl);
627 return x + (y << bwl);
630 static void txfrm_block_to_raster_xy(MACROBLOCKD *xd,
631 BLOCK_SIZE_TYPE bsize,
632 int plane, int block,
635 const int bwl = b_width_log2(bsize) - xd->plane[plane].subsampling_x;
636 const int txwl = ss_txfrm_size / 2;
637 const int tx_cols_log2 = bwl - txwl;
638 const int tx_cols = 1 << tx_cols_log2;
639 const int raster_mb = block >> ss_txfrm_size;
640 *x = (raster_mb & (tx_cols - 1)) << (txwl);
641 *y = raster_mb >> tx_cols_log2 << (txwl);
644 static void extend_for_intra(MACROBLOCKD* const xd, int plane, int block,
645 BLOCK_SIZE_TYPE bsize, int ss_txfrm_size) {
646 const int bw = plane_block_width(bsize, &xd->plane[plane]);
647 const int bh = plane_block_height(bsize, &xd->plane[plane]);
649 txfrm_block_to_raster_xy(xd, bsize, plane, block, ss_txfrm_size, &x, &y);
652 // Copy a pixel into the umv if we are in a situation where the block size
653 // extends into the UMV.
654 // TODO(JBB): Should be able to do the full extend in place so we don't have
655 // to do this multiple times.
656 if (xd->mb_to_right_edge < 0) {
657 int umv_border_start = bw
658 + (xd->mb_to_right_edge >> (3 + xd->plane[plane].subsampling_x));
660 if (x + bw > umv_border_start)
662 xd->plane[plane].dst.buf + y * xd->plane[plane].dst.stride
664 *(xd->plane[plane].dst.buf + y * xd->plane[plane].dst.stride
665 + umv_border_start - 1),
668 if (xd->mb_to_bottom_edge < 0) {
669 int umv_border_start = bh
670 + (xd->mb_to_bottom_edge >> (3 + xd->plane[plane].subsampling_y));
672 uint8_t c = *(xd->plane[plane].dst.buf
673 + (umv_border_start - 1) * xd->plane[plane].dst.stride + x);
675 uint8_t *d = xd->plane[plane].dst.buf
676 + umv_border_start * xd->plane[plane].dst.stride + x;
678 if (y + bh > umv_border_start)
679 for (i = 0; i < bh; i++, d += xd->plane[plane].dst.stride)
683 static void set_contexts_on_border(MACROBLOCKD *xd, BLOCK_SIZE_TYPE bsize,
684 int plane, int ss_tx_size, int eob, int aoff,
685 int loff, ENTROPY_CONTEXT *A,
686 ENTROPY_CONTEXT *L) {
687 const int bw = b_width_log2(bsize), bh = b_height_log2(bsize);
688 const int sw = bw - xd->plane[plane].subsampling_x;
689 const int sh = bh - xd->plane[plane].subsampling_y;
690 int mi_blocks_wide = 1 << sw;
691 int mi_blocks_high = 1 << sh;
692 int tx_size_in_blocks = (1 << ss_tx_size);
693 int above_contexts = tx_size_in_blocks;
694 int left_contexts = tx_size_in_blocks;
697 // xd->mb_to_right_edge is in units of pixels * 8. This converts
698 // it to 4x4 block sizes.
699 if (xd->mb_to_right_edge < 0) {
700 mi_blocks_wide += (xd->mb_to_right_edge
701 >> (5 + xd->plane[plane].subsampling_x));
704 // this code attempts to avoid copying into contexts that are outside
705 // our border. Any blocks that do are set to 0...
706 if (above_contexts + aoff > mi_blocks_wide)
707 above_contexts = mi_blocks_wide - aoff;
709 if (xd->mb_to_bottom_edge < 0) {
710 mi_blocks_high += (xd->mb_to_bottom_edge
711 >> (5 + xd->plane[plane].subsampling_y));
713 if (left_contexts + loff > mi_blocks_high) {
714 left_contexts = mi_blocks_high - loff;
717 for (pt = 0; pt < above_contexts; pt++)
719 for (pt = above_contexts; pt < (1 << ss_tx_size); pt++)
721 for (pt = 0; pt < left_contexts; pt++)
723 for (pt = left_contexts; pt < (1 << ss_tx_size); pt++)
728 #endif // VP9_COMMON_VP9_BLOCKD_H_