Commit bcf82cf5 authored by Yaowu Xu's avatar Yaowu Xu

Merge two similar functions into one

Function set_mb_row() and set_mb_col() do similar work and are always
called together, this commit merged them into a single function for
clarity and easy maintainence.  This was a TODO item.

Change-Id: I956bd9ed6afb8b2b0469b20fd8bc893b26f8a0f3
parent a2d46434
......@@ -341,24 +341,18 @@ static int mb_cols_aligned_to_sb(VP9_COMMON *cm) {
return (cm->mb_cols + 3) & ~3;
}
// TODO(debargha): merge the two functions
static void set_mb_row(VP9_COMMON *cm, MACROBLOCKD *xd,
int mb_row, int block_size) {
static void set_mb_row_col(VP9_COMMON *cm, MACROBLOCKD *xd,
int mb_row, int bh,
int mb_col, int bw) {
xd->mb_to_top_edge = -((mb_row * 16) << 3);
xd->mb_to_bottom_edge = ((cm->mb_rows - block_size - mb_row) * 16) << 3;
// Are edges available for intra prediction?
xd->up_available = (mb_row != 0);
}
static void set_mb_col(VP9_COMMON *cm, MACROBLOCKD *xd,
int mb_col, int block_size) {
xd->mb_to_bottom_edge = ((cm->mb_rows - bh - mb_row) * 16) << 3;
xd->mb_to_left_edge = -((mb_col * 16) << 3);
xd->mb_to_right_edge = ((cm->mb_cols - block_size - mb_col) * 16) << 3;
xd->mb_to_right_edge = ((cm->mb_cols - bw - mb_col) * 16) << 3;
// Are edges available for intra prediction?
xd->up_available = (mb_row != 0);
xd->left_available = (mb_col > cm->cur_tile_mb_col_start);
xd->right_available = (mb_col + block_size < cm->cur_tile_mb_col_end);
xd->right_available = (mb_col + bw < cm->cur_tile_mb_col_end);
}
static int get_mb_row(const MACROBLOCKD *xd) {
......
......@@ -620,8 +620,7 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
// 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, bh);
set_mb_col(cm, xd, mb_col, bw);
set_mb_row_col(cm, xd, mb_row, bh, 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;
......
......@@ -801,8 +801,7 @@ static void set_offsets(VP9D_COMP *pbi, BLOCK_SIZE_TYPE bsize,
// Distance of Mb to the various image edges. These are specified to 8th pel
// as they are always compared to values that are in 1/8th pel units
set_mb_row(cm, xd, mb_row, bh);
set_mb_col(cm, xd, mb_col, bw);
set_mb_row_col(cm, xd, mb_row, bh, mb_col, bw);
xd->plane[0].dst.buf = dst_fb->y_buffer + recon_yoffset;
xd->plane[1].dst.buf = dst_fb->u_buffer + recon_uvoffset;
......
......@@ -710,8 +710,7 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, MODE_INFO *m,
// 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, bh);
set_mb_col(pc, xd, mb_col, bw);
set_mb_row_col(pc, xd, mb_row, bh, mb_col, bw);
#ifdef ENTROPY_STATS
active_section = 9;
......@@ -1151,8 +1150,9 @@ static void write_modes_b(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc,
MACROBLOCKD *const xd = &cpi->mb.e_mbd;
xd->mode_info_context = m;
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));
set_mb_row_col(&cpi->common, xd, mb_row,
1 << mb_height_log2(m->mbmi.sb_type),
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);
......
......@@ -579,8 +579,7 @@ static void set_offsets(VP9_COMP *cpi,
// Set up distance of MB to edge of frame in 1/8th pel units
assert(!(mb_col & (bw - 1)) && !(mb_row & (bh - 1)));
set_mb_row(cm, xd, mb_row, bh);
set_mb_col(cm, xd, mb_col, bw);
set_mb_row_col(cm, xd, mb_row, bh, mb_col, bw);
/* set up source buffers */
setup_pred_block(&x->src, cpi->Source, mb_row, mb_col, NULL, NULL);
......
......@@ -524,15 +524,15 @@ void vp9_first_pass(VP9_COMP *cpi) {
x->mv_row_max = ((cm->mb_rows - 1 - mb_row) * 16)
+ (VP9BORDERINPIXELS - 16);
set_mb_row(cm, xd, mb_row, 1 << mb_height_log2(BLOCK_SIZE_MB16X16));
// for each macroblock col in image
for (mb_col = 0; mb_col < cm->mb_cols; mb_col++) {
int this_error;
int gf_motion_error = INT_MAX;
int use_dc_pred = (mb_col || mb_row) && (!mb_col || !mb_row);
set_mb_col(cm, xd, mb_col, 1 << mb_height_log2(BLOCK_SIZE_MB16X16));
set_mb_row_col(cm, xd,
mb_row, 1 << mb_height_log2(BLOCK_SIZE_MB16X16),
mb_col, 1 << mb_height_log2(BLOCK_SIZE_MB16X16));
xd->plane[0].dst.buf = new_yv12->y_buffer + recon_yoffset;
xd->plane[1].dst.buf = new_yv12->u_buffer + recon_uvoffset;
xd->plane[2].dst.buf = new_yv12->v_buffer + recon_uvoffset;
......
......@@ -133,8 +133,7 @@ static void count_segs(VP9_COMP *cpi,
const int segment_id = mi->mbmi.segment_id;
xd->mode_info_context = mi;
set_mb_row(cm, xd, mb_row, bh);
set_mb_col(cm, xd, mb_col, bw);
set_mb_row_col(cm, xd, mb_row, bh, mb_col, bw);
// Count the number of hits on each segment with no prediction
no_pred_segcounts[segment_id]++;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment