#else
if (xd->up_available && xd->left_available) {
#endif
+ const int bwl = mb_width_log2(xd->mode_info_context->mbmi.sb_type);
vp9_sub_pixel_variance16x2(above_ref + offset, ref_y_stride,
SP(this_mv.as_mv.col),
SP(this_mv.as_mv.row),
above_src, xd->dst.y_stride, &sse);
score += sse;
- if (xd->mode_info_context->mbmi.sb_type >= BLOCK_SIZE_SB32X32) {
+ if (bwl >= 1) {
vp9_sub_pixel_variance16x2(above_ref + offset + 16,
ref_y_stride,
SP(this_mv.as_mv.col),
above_src + 16, xd->dst.y_stride, &sse);
score += sse;
}
- if (xd->mode_info_context->mbmi.sb_type >= BLOCK_SIZE_SB64X64) {
+ if (bwl >= 2) {
vp9_sub_pixel_variance16x2(above_ref + offset + 32,
ref_y_stride,
SP(this_mv.as_mv.col),
}
#if !CONFIG_ABOVESPREFMV
if (xd->left_available) {
+ const int bhl = mb_height_log2(xd->mode_info_context->mbmi.sb_type);
vp9_sub_pixel_variance2x16_c(left_ref + offset, ref_y_stride,
SP(this_mv.as_mv.col),
SP(this_mv.as_mv.row),
left_src, xd->dst.y_stride, &sse);
score += sse;
- if (xd->mode_info_context->mbmi.sb_type >= BLOCK_SIZE_SB32X32) {
+ if (bhl >= 1) {
vp9_sub_pixel_variance2x16_c(left_ref + offset + ref_y_stride * 16,
ref_y_stride,
SP(this_mv.as_mv.col),
xd->dst.y_stride, &sse);
score += sse;
}
- if (xd->mode_info_context->mbmi.sb_type >= BLOCK_SIZE_SB64X64) {
+ if (bhl >= 2) {
vp9_sub_pixel_variance2x16_c(left_ref + offset + ref_y_stride * 32,
ref_y_stride,
SP(this_mv.as_mv.col),
if (mbmi->sb_type == BLOCK_SIZE_SB64X64) {
mv_ref_search = sb64_mv_ref_search;
ref_distance_weight = sb64_ref_distance_weight;
- } else if (mbmi->sb_type == BLOCK_SIZE_SB32X32) {
+ } else if (mbmi->sb_type >= BLOCK_SIZE_SB32X32) {
mv_ref_search = sb_mv_ref_search;
ref_distance_weight = sb_ref_distance_weight;
} else {
PRED_ID pred_id,
unsigned char pred_flag) {
const int mis = xd->mode_info_stride;
+ BLOCK_SIZE_TYPE bsize = xd->mode_info_context->mbmi.sb_type;
+ const int bh = 1 << mb_height_log2(bsize);
+ const int bw = 1 << mb_width_log2(bsize);
+#define sub(a, b) (b) < 0 ? (a) + (b) : (a)
+ const int x_mbs = sub(bw, xd->mb_to_right_edge >> 7);
+ const int y_mbs = sub(bh, xd->mb_to_bottom_edge >> 7);
+#undef sub
+ int x, y;
switch (pred_id) {
case PRED_SEG_ID:
- xd->mode_info_context->mbmi.seg_id_predicted = pred_flag;
- if (xd->mode_info_context->mbmi.sb_type) {
-#define sub(a, b) (b) < 0 ? (a) + (b) : (a)
- const int n_mbs = 1 << xd->mode_info_context->mbmi.sb_type;
- const int x_mbs = sub(n_mbs, xd->mb_to_right_edge >> 7);
- const int y_mbs = sub(n_mbs, xd->mb_to_bottom_edge >> 7);
- int x, y;
-
- for (y = 0; y < y_mbs; y++) {
- for (x = !y; x < x_mbs; x++) {
- xd->mode_info_context[y * mis + x].mbmi.seg_id_predicted =
- pred_flag;
- }
+ for (y = 0; y < y_mbs; y++) {
+ for (x = 0; x < x_mbs; x++) {
+ xd->mode_info_context[y * mis + x].mbmi.seg_id_predicted =
+ pred_flag;
}
}
break;
case PRED_REF:
- xd->mode_info_context->mbmi.ref_predicted = pred_flag;
- if (xd->mode_info_context->mbmi.sb_type) {
- const int n_mbs = 1 << xd->mode_info_context->mbmi.sb_type;
- const int x_mbs = sub(n_mbs, xd->mb_to_right_edge >> 7);
- const int y_mbs = sub(n_mbs, xd->mb_to_bottom_edge >> 7);
- int x, y;
-
- for (y = 0; y < y_mbs; y++) {
- for (x = !y; x < x_mbs; x++) {
- xd->mode_info_context[y * mis + x].mbmi.ref_predicted = pred_flag;
- }
+ for (y = 0; y < y_mbs; y++) {
+ for (x = 0; x < x_mbs; x++) {
+ xd->mode_info_context[y * mis + x].mbmi.ref_predicted = pred_flag;
}
}
break;
case PRED_MBSKIP:
- xd->mode_info_context->mbmi.mb_skip_coeff = pred_flag;
- if (xd->mode_info_context->mbmi.sb_type) {
- const int n_mbs = 1 << xd->mode_info_context->mbmi.sb_type;
- const int x_mbs = sub(n_mbs, xd->mb_to_right_edge >> 7);
- const int y_mbs = sub(n_mbs, xd->mb_to_bottom_edge >> 7);
- int x, y;
-
- for (y = 0; y < y_mbs; y++) {
- for (x = !y; x < x_mbs; x++) {
- xd->mode_info_context[y * mis + x].mbmi.mb_skip_coeff = pred_flag;
- }
+ for (y = 0; y < y_mbs; y++) {
+ for (x = 0; x < x_mbs; x++) {
+ xd->mode_info_context[y * mis + x].mbmi.mb_skip_coeff = pred_flag;
}
}
break;
if (!xd->mode_info_context->mbmi.sb_type) {
return cm->last_frame_seg_map[MbIndex];
} else {
- const int n_mbs = 1 << xd->mode_info_context->mbmi.sb_type;
+ BLOCK_SIZE_TYPE bsize = xd->mode_info_context->mbmi.sb_type;
+ const int bh = 1 << mb_height_log2(bsize);
+ const int bw = 1 << mb_width_log2(bsize);
const int mb_col = MbIndex % cm->mb_cols;
const int mb_row = MbIndex / cm->mb_cols;
- const int x_mbs = MIN(n_mbs, cm->mb_cols - mb_col);
- const int y_mbs = MIN(n_mbs, cm->mb_rows - mb_row);
+ const int x_mbs = MIN(bw, cm->mb_cols - mb_col);
+ const int y_mbs = MIN(bh, cm->mb_rows - mb_row);
int x, y;
unsigned seg_id = -1;
if (pbi->mb.update_mb_segmentation_map) {
read_mb_segid(bc, &m->mbmi, &pbi->mb);
if (m->mbmi.sb_type) {
- const int nmbs = 1 << m->mbmi.sb_type;
- const int ymbs = MIN(cm->mb_rows - mb_row, nmbs);
- const int xmbs = MIN(cm->mb_cols - mb_col, nmbs);
+ const int bw = 1 << mb_width_log2(m->mbmi.sb_type);
+ const int bh = 1 << mb_height_log2(m->mbmi.sb_type);
+ const int ymbs = MIN(cm->mb_rows - mb_row, bh);
+ const int xmbs = MIN(cm->mb_cols - mb_col, bw);
int x, y;
for (y = 0; y < ymbs; y++) {
m->mbmi.txfm_size = vp9_read(bc, cm->prob_tx[0]);
if (m->mbmi.txfm_size != TX_4X4 && m->mbmi.mode != I8X8_PRED) {
m->mbmi.txfm_size += vp9_read(bc, cm->prob_tx[1]);
- if (m->mbmi.txfm_size != TX_8X8 && m->mbmi.sb_type)
+ if (m->mbmi.txfm_size != TX_8X8 && m->mbmi.sb_type >= BLOCK_SIZE_SB32X32)
m->mbmi.txfm_size += vp9_read(bc, cm->prob_tx[2]);
}
- } else if (cm->txfm_mode >= ALLOW_32X32 && m->mbmi.sb_type) {
+ } else if (cm->txfm_mode >= ALLOW_32X32 &&
+ m->mbmi.sb_type >= BLOCK_SIZE_SB32X32) {
m->mbmi.txfm_size = TX_32X32;
} else if (cm->txfm_mode >= ALLOW_16X16 && m->mbmi.mode <= TM_PRED) {
m->mbmi.txfm_size = TX_16X16;
}
if (mbmi->sb_type) {
- const int nmbs = 1 << mbmi->sb_type;
- const int ymbs = MIN(cm->mb_rows - mb_row, nmbs);
- const int xmbs = MIN(cm->mb_cols - mb_col, nmbs);
+ const int bw = 1 << mb_width_log2(mbmi->sb_type);
+ const int bh = 1 << mb_height_log2(mbmi->sb_type);
+ const int ymbs = MIN(cm->mb_rows - mb_row, bh);
+ const int xmbs = MIN(cm->mb_cols - mb_col, bw);
int x, y;
for (y = 0; y < ymbs; y++) {
}
} else {
if (mbmi->sb_type) {
- const int nmbs = 1 << mbmi->sb_type;
- const int ymbs = MIN(cm->mb_rows - mb_row, nmbs);
- const int xmbs = MIN(cm->mb_cols - mb_col, nmbs);
+ const int bw = 1 << mb_width_log2(mbmi->sb_type);
+ const int bh = 1 << mb_height_log2(mbmi->sb_type);
+ const int ymbs = MIN(cm->mb_rows - mb_row, bh);
+ const int xmbs = MIN(cm->mb_cols - mb_col, bw);
unsigned segment_id = -1;
int x, y;
MACROBLOCKD *const xd = &pbi->mb;
int_mv *const mv = &mbmi->mv[0];
- const int mb_size = 1 << mi->mbmi.sb_type;
+ const int bw = 1 << mb_width_log2(mi->mbmi.sb_type);
+ const int bh = 1 << mb_height_log2(mi->mbmi.sb_type);
const int use_prev_in_find_mv_refs = cm->width == cm->last_width &&
cm->height == cm->last_height &&
// Distance of Mb to the various image edges.
// These specified to 8th pel as they are always compared to MV values
// that are in 1/8th pel units
- set_mb_row(cm, xd, mb_row, mb_size);
- set_mb_col(cm, xd, mb_col, mb_size);
+ set_mb_row(cm, xd, mb_row, bh);
+ set_mb_col(cm, xd, mb_col, bw);
mb_to_top_edge = xd->mb_to_top_edge - LEFT_TOP_MARGIN;
mb_to_bottom_edge = xd->mb_to_bottom_edge + RIGHT_BOTTOM_MARGIN;
if (mbmi->txfm_size != TX_4X4 && mbmi->mode != I8X8_PRED &&
mbmi->mode != SPLITMV) {
mbmi->txfm_size += vp9_read(bc, cm->prob_tx[1]);
- if (mbmi->sb_type && mbmi->txfm_size != TX_8X8)
+ if (mbmi->sb_type >= BLOCK_SIZE_SB32X32 && mbmi->txfm_size != TX_8X8)
mbmi->txfm_size += vp9_read(bc, cm->prob_tx[2]);
}
- } else if (mbmi->sb_type && cm->txfm_mode >= ALLOW_32X32) {
+ } else if (mbmi->sb_type >= BLOCK_SIZE_SB32X32 &&
+ cm->txfm_mode >= ALLOW_32X32) {
mbmi->txfm_size = TX_32X32;
} else if (cm->txfm_mode >= ALLOW_16X16 &&
((mbmi->ref_frame == INTRA_FRAME && mbmi->mode <= TM_PRED) ||
#endif // CONFIG_CODE_NONZEROCOUNT
if (mbmi->sb_type) {
- const int n_mbs = 1 << mbmi->sb_type;
- const int y_mbs = MIN(n_mbs, cm->mb_rows - mb_row);
- const int x_mbs = MIN(n_mbs, cm->mb_cols - mb_col);
+ const int bw = 1 << mb_width_log2(mbmi->sb_type);
+ const int bh = 1 << mb_height_log2(mbmi->sb_type);
+ const int y_mbs = MIN(bh, cm->mb_rows - mb_row);
+ const int x_mbs = MIN(bw, cm->mb_cols - mb_col);
const int mis = cm->mode_info_stride;
int x, y;
}
case TX_8X8: {
const BLOCK_SIZE_TYPE sb_type = xd->mode_info_context->mbmi.sb_type;
- const int sz = 3 + sb_type, x = block_idx & ((1 << sz) - 1);
+ const int sz = 3 + mb_width_log2(sb_type);
+ const int x = block_idx & ((1 << sz) - 1);
const int y = block_idx - x;
const TX_TYPE tx_type = (type == PLANE_TYPE_Y_WITH_DC) ?
get_tx_type_8x8(xd, y + (x >> 1)) : DCT_DCT;
}
case TX_16X16: {
const BLOCK_SIZE_TYPE sb_type = xd->mode_info_context->mbmi.sb_type;
- const int sz = 4 + sb_type, x = block_idx & ((1 << sz) - 1);
+ const int sz = 4 + mb_width_log2(sb_type);
+ const int x = block_idx & ((1 << sz) - 1);
const int y = block_idx - x;
const TX_TYPE tx_type = (type == PLANE_TYPE_Y_WITH_DC) ?
get_tx_type_16x16(xd, y + (x >> 2)) : DCT_DCT;
const MV_REFERENCE_FRAME rf = mi->ref_frame;
const MB_PREDICTION_MODE mode = mi->mode;
const int segment_id = mi->segment_id;
- const int mb_size = 1 << mi->sb_type;
+ const int bw = 1 << mb_width_log2(mi->sb_type);
+ const int bh = 1 << mb_height_log2(mi->sb_type);
int skip_coeff;
int mb_row = pc->mb_rows - mb_rows_left;
// These specified to 8th pel as they are always compared to MV
// values that are in 1/8th pel units
- set_mb_row(pc, xd, mb_row, mb_size);
- set_mb_col(pc, xd, mb_col, mb_size);
+ set_mb_row(pc, xd, mb_row, bh);
+ set_mb_col(pc, xd, mb_col, bw);
#ifdef ENTROPY_STATS
active_section = 9;
vp9_write(bc, sz != TX_4X4, pc->prob_tx[0]);
if (sz != TX_4X4 && mode != I8X8_PRED && mode != SPLITMV) {
vp9_write(bc, sz != TX_8X8, pc->prob_tx[1]);
- if (mi->sb_type && sz != TX_8X8)
+ if (mi->sb_type >= BLOCK_SIZE_SB32X32 && sz != TX_8X8)
vp9_write(bc, sz != TX_16X16, pc->prob_tx[2]);
}
}
vp9_write(bc, sz != TX_4X4, c->prob_tx[0]);
if (sz != TX_4X4 && ym <= TM_PRED) {
vp9_write(bc, sz != TX_8X8, c->prob_tx[1]);
- if (m->mbmi.sb_type && sz != TX_8X8)
+ if (m->mbmi.sb_type >= BLOCK_SIZE_SB32X32 && sz != TX_8X8)
vp9_write(bc, sz != TX_16X16, c->prob_tx[2]);
}
}
MACROBLOCKD *const xd = &cpi->mb.e_mbd;
xd->mode_info_context = m;
- set_mb_row(&cpi->common, xd, mb_row, (1 << m->mbmi.sb_type));
- set_mb_col(&cpi->common, xd, mb_col, (1 << m->mbmi.sb_type));
+ set_mb_row(&cpi->common, xd, mb_row, 1 << mb_height_log2(m->mbmi.sb_type));
+ set_mb_col(&cpi->common, xd, mb_col, 1 << mb_width_log2(m->mbmi.sb_type));
if (cm->frame_type == KEY_FRAME) {
write_mb_modes_kf(cpi, m, bc,
cm->mb_rows - mb_row, cm->mb_cols - mb_col);
}
case TX_8X8: {
const BLOCK_SIZE_TYPE sb_type = xd->mode_info_context->mbmi.sb_type;
- const int sz = 3 + sb_type, x = ib & ((1 << sz) - 1), y = ib - x;
+ const int sz = 3 + mb_width_log2(sb_type);
+ const int x = ib & ((1 << sz) - 1), y = ib - x;
const TX_TYPE tx_type = get_tx_type_8x8(xd, y + (x >> 1));
if (tx_type == DCT_ADST) {
scan = vp9_col_scan_8x8;
}
case TX_16X16: {
const BLOCK_SIZE_TYPE sb_type = xd->mode_info_context->mbmi.sb_type;
- const int sz = 4 + sb_type, x = ib & ((1 << sz) - 1), y = ib - x;
+ const int sz = 4 + mb_width_log2(sb_type);
+ const int x = ib & ((1 << sz) - 1), y = ib - x;
const TX_TYPE tx_type = get_tx_type_16x16(xd, y + (x >> 2));
if (tx_type == DCT_ADST) {
scan = vp9_col_scan_16x16;
}
case TX_8X8: {
const BLOCK_SIZE_TYPE sb_type = xd->mode_info_context->mbmi.sb_type;
- const int sz = 3 + sb_type, x = ib & ((1 << sz) - 1), y = ib - x;
+ const int sz = 3 + mb_width_log2(sb_type);
+ const int x = ib & ((1 << sz) - 1), y = ib - x;
const TX_TYPE tx_type = (type == PLANE_TYPE_Y_WITH_DC) ?
get_tx_type_8x8(xd, y + (x >> 1)) : DCT_DCT;
a_ec = (a[0] + a[1]) != 0;
}
case TX_16X16: {
const BLOCK_SIZE_TYPE sb_type = xd->mode_info_context->mbmi.sb_type;
- const int sz = 4 + sb_type, x = ib & ((1 << sz) - 1), y = ib - x;
+ const int sz = 4 + mb_width_log2(sb_type);
+ const int x = ib & ((1 << sz) - 1), y = ib - x;
const TX_TYPE tx_type = (type == PLANE_TYPE_Y_WITH_DC) ?
get_tx_type_16x16(xd, y + (x >> 2)) : DCT_DCT;
if (tx_type == ADST_DCT) {
break;
}
case TX_8X8: {
- const int sz = 3 + sb_type, x = ib & ((1 << sz) - 1), y = ib - x;
+ const int sz = 3 + mb_width_log2(sb_type);
+ const int x = ib & ((1 << sz) - 1), y = ib - x;
const TX_TYPE tx_type = (type == PLANE_TYPE_Y_WITH_DC) ?
get_tx_type_8x8(xd, y + (x >> 1)) : DCT_DCT;
a_ec = (a[0] + a[1]) != 0;
break;
}
case TX_16X16: {
- const int sz = 4 + sb_type, x = ib & ((1 << sz) - 1), y = ib - x;
+ const int sz = 4 + mb_width_log2(sb_type);
+ const int x = ib & ((1 << sz) - 1), y = ib - x;
const TX_TYPE tx_type = (type == PLANE_TYPE_Y_WITH_DC) ?
get_tx_type_16x16(xd, y + (x >> 2)) : DCT_DCT;
if (type != PLANE_TYPE_UV) {
const int nzc_used = get_nzc_used(tx_size);
#endif
- if (sb_type == BLOCK_SIZE_SB32X32) {
+ if (sb_type == BLOCK_SIZE_SB64X64) {
a = (ENTROPY_CONTEXT *)xd->above_context +
vp9_block2above_sb64[tx_size][ib];
l = (ENTROPY_CONTEXT *)xd->left_context + vp9_block2left_sb64[tx_size][ib];