Refactoring setup_pre_planes function.
Removing set_refs, adding set_ref function. Change-Id: I5635c478b106ae4e57d317f1c83d929644307e63
This commit is contained in:
parent
2ce6b23473
commit
f72e072555
@ -80,31 +80,23 @@ static void setup_dst_planes(MACROBLOCKD *xd,
|
||||
}
|
||||
}
|
||||
|
||||
static void setup_pre_planes(MACROBLOCKD *xd,
|
||||
const YV12_BUFFER_CONFIG *src0,
|
||||
const YV12_BUFFER_CONFIG *src1,
|
||||
static void setup_pre_planes(MACROBLOCKD *xd, int i,
|
||||
const YV12_BUFFER_CONFIG *src,
|
||||
int mi_row, int mi_col,
|
||||
const struct scale_factors *scale,
|
||||
const struct scale_factors *scale_uv) {
|
||||
const YV12_BUFFER_CONFIG *srcs[2] = {src0, src1};
|
||||
int i, j;
|
||||
if (src) {
|
||||
int j;
|
||||
uint8_t* buffers[4] = {src->y_buffer, src->u_buffer, src->v_buffer,
|
||||
src->alpha_buffer};
|
||||
int strides[4] = {src->y_stride, src->uv_stride, src->uv_stride,
|
||||
src->alpha_stride};
|
||||
|
||||
for (i = 0; i < 2; ++i) {
|
||||
const YV12_BUFFER_CONFIG *src = srcs[i];
|
||||
if (src) {
|
||||
uint8_t* buffers[4] = {src->y_buffer, src->u_buffer, src->v_buffer,
|
||||
src->alpha_buffer};
|
||||
int strides[4] = {src->y_stride, src->uv_stride, src->uv_stride,
|
||||
src->alpha_stride};
|
||||
|
||||
for (j = 0; j < MAX_MB_PLANE; ++j) {
|
||||
struct macroblockd_plane *pd = &xd->plane[j];
|
||||
const struct scale_factors *sf = j ? scale_uv : scale;
|
||||
setup_pred_plane(&pd->pre[i],
|
||||
buffers[j], strides[j],
|
||||
mi_row, mi_col, sf ? &sf[i] : NULL,
|
||||
pd->subsampling_x, pd->subsampling_y);
|
||||
}
|
||||
for (j = 0; j < MAX_MB_PLANE; ++j) {
|
||||
struct macroblockd_plane *pd = &xd->plane[j];
|
||||
const struct scale_factors *sf = j ? scale_uv : scale;
|
||||
setup_pred_plane(&pd->pre[i], buffers[j], strides[j],
|
||||
mi_row, mi_col, sf, pd->subsampling_x, pd->subsampling_y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -216,30 +216,18 @@ static void set_offsets(VP9D_COMP *pbi, BLOCK_SIZE_TYPE bsize,
|
||||
setup_dst_planes(xd, &cm->yv12_fb[cm->new_fb_idx], mi_row, mi_col);
|
||||
}
|
||||
|
||||
static void set_refs(VP9D_COMP *pbi, int mi_row, int mi_col) {
|
||||
static void set_ref(VP9D_COMP *pbi, int i, int mi_row, int mi_col) {
|
||||
VP9_COMMON *const cm = &pbi->common;
|
||||
MACROBLOCKD *const xd = &pbi->mb;
|
||||
MB_MODE_INFO *const mbmi = &xd->mode_info_context->mbmi;
|
||||
const int ref = mbmi->ref_frame[i] - 1;
|
||||
|
||||
// Select the appropriate reference frame for this MB
|
||||
const int fb_idx = cm->active_ref_idx[mbmi->ref_frame[0] - 1];
|
||||
const YV12_BUFFER_CONFIG *cfg = &cm->yv12_fb[fb_idx];
|
||||
xd->scale_factor[0] = cm->active_ref_scale[mbmi->ref_frame[0] - 1];
|
||||
xd->scale_factor_uv[0] = cm->active_ref_scale[mbmi->ref_frame[0] - 1];
|
||||
setup_pre_planes(xd, cfg, NULL, mi_row, mi_col, xd->scale_factor,
|
||||
xd->scale_factor_uv);
|
||||
const YV12_BUFFER_CONFIG *cfg = &cm->yv12_fb[cm->active_ref_idx[ref]];
|
||||
xd->scale_factor[i] = cm->active_ref_scale[ref];
|
||||
xd->scale_factor_uv[i] = cm->active_ref_scale[ref];
|
||||
setup_pre_planes(xd, i, cfg, mi_row, mi_col,
|
||||
&xd->scale_factor[i], &xd->scale_factor_uv[i]);
|
||||
xd->corrupted |= cfg->corrupted;
|
||||
|
||||
if (mbmi->ref_frame[1] > INTRA_FRAME) {
|
||||
// Select the appropriate reference frame for this MB
|
||||
const int second_fb_idx = cm->active_ref_idx[mbmi->ref_frame[1] - 1];
|
||||
const YV12_BUFFER_CONFIG *second_cfg = &cm->yv12_fb[second_fb_idx];
|
||||
xd->scale_factor[1] = cm->active_ref_scale[mbmi->ref_frame[1] - 1];
|
||||
xd->scale_factor_uv[1] = cm->active_ref_scale[mbmi->ref_frame[1] - 1];
|
||||
setup_pre_planes(xd, NULL, second_cfg, mi_row, mi_col, xd->scale_factor,
|
||||
xd->scale_factor_uv);
|
||||
xd->corrupted |= second_cfg->corrupted;
|
||||
}
|
||||
}
|
||||
|
||||
static void decode_modes_b(VP9D_COMP *pbi, int mi_row, int mi_col,
|
||||
@ -269,7 +257,11 @@ static void decode_modes_b(VP9D_COMP *pbi, int mi_row, int mi_col,
|
||||
} else {
|
||||
// Inter reconstruction
|
||||
int eobtotal;
|
||||
set_refs(pbi, mi_row, mi_col);
|
||||
|
||||
set_ref(pbi, 0, mi_row, mi_col);
|
||||
if (mbmi->ref_frame[1] > INTRA_FRAME)
|
||||
set_ref(pbi, 1, mi_row, mi_col);
|
||||
|
||||
vp9_setup_interp_filters(xd, mbmi->interp_filter, cm);
|
||||
vp9_build_inter_predictors_sb(xd, mi_row, mi_col, bsize);
|
||||
eobtotal = decode_tokens(pbi, bsize, r);
|
||||
@ -1000,8 +992,8 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
|
||||
read_coef_probs(pbi, &header_bc);
|
||||
|
||||
// Initialize xd pointers. Any reference should do for xd->pre, so use 0.
|
||||
setup_pre_planes(xd, &pc->yv12_fb[pc->active_ref_idx[0]], NULL,
|
||||
0, 0, NULL, NULL);
|
||||
setup_pre_planes(xd, 0, &pc->yv12_fb[pc->active_ref_idx[0]], 0, 0,
|
||||
NULL, NULL);
|
||||
setup_dst_planes(xd, new_fb, 0, 0);
|
||||
|
||||
// Create the segmentation map structure and set to 0
|
||||
|
@ -1076,8 +1076,10 @@ static void choose_partitioning(VP9_COMP *cpi, MODE_INFO *m, int mi_row,
|
||||
YV12_BUFFER_CONFIG *ref_fb = &cm->yv12_fb[0];
|
||||
YV12_BUFFER_CONFIG *second_ref_fb = NULL;
|
||||
|
||||
setup_pre_planes(xd, ref_fb, second_ref_fb, mi_row, mi_col,
|
||||
xd->scale_factor, xd->scale_factor_uv);
|
||||
setup_pre_planes(xd, 0, ref_fb, mi_row, mi_col,
|
||||
&xd->scale_factor[0], &xd->scale_factor_uv[0]);
|
||||
setup_pre_planes(xd, 1, second_ref_fb, mi_row, mi_col,
|
||||
&xd->scale_factor[1], &xd->scale_factor_uv[1]);
|
||||
xd->mode_info_context->mbmi.ref_frame[0] = LAST_FRAME;
|
||||
xd->mode_info_context->mbmi.sb_type = BLOCK_SIZE_SB64X64;
|
||||
vp9_find_best_ref_mvs(xd, m->mbmi.ref_mvs[m->mbmi.ref_frame[0]],
|
||||
@ -1711,8 +1713,8 @@ static void init_encode_frame_mb_context(VP9_COMP *cpi) {
|
||||
vp9_setup_src_planes(x, cpi->Source, 0, 0);
|
||||
|
||||
// TODO(jkoleszar): are these initializations required?
|
||||
setup_pre_planes(xd, &cm->yv12_fb[cm->ref_frame_map[cpi->lst_fb_idx]], NULL,
|
||||
0, 0, NULL, NULL );
|
||||
setup_pre_planes(xd, 0, &cm->yv12_fb[cm->ref_frame_map[cpi->lst_fb_idx]],
|
||||
0, 0, NULL, NULL);
|
||||
setup_dst_planes(xd, &cm->yv12_fb[cm->new_fb_idx], 0, 0);
|
||||
|
||||
setup_block_dptrs(&x->e_mbd, cm->subsampling_x, cm->subsampling_y);
|
||||
@ -2302,8 +2304,11 @@ static void encode_superblock(VP9_COMP *cpi, TOKENEXTRA **t, int output_enabled,
|
||||
|
||||
assert(cm->frame_type != KEY_FRAME);
|
||||
|
||||
setup_pre_planes(xd, ref_fb, second_ref_fb, mi_row, mi_col,
|
||||
xd->scale_factor, xd->scale_factor_uv);
|
||||
setup_pre_planes(xd, 0, ref_fb, mi_row, mi_col,
|
||||
&xd->scale_factor[0], &xd->scale_factor_uv[0]);
|
||||
setup_pre_planes(xd, 1, second_ref_fb, mi_row, mi_col,
|
||||
&xd->scale_factor[1], &xd->scale_factor_uv[1]);
|
||||
|
||||
|
||||
vp9_build_inter_predictors_sb(
|
||||
xd, mi_row, mi_col,
|
||||
|
@ -514,7 +514,7 @@ void vp9_first_pass(VP9_COMP *cpi) {
|
||||
vp9_clear_system_state(); // __asm emms;
|
||||
|
||||
vp9_setup_src_planes(x, cpi->Source, 0, 0);
|
||||
setup_pre_planes(xd, lst_yv12, NULL, 0, 0, NULL, NULL);
|
||||
setup_pre_planes(xd, 0, lst_yv12, 0, 0, NULL, NULL);
|
||||
setup_dst_planes(xd, new_yv12, 0, 0);
|
||||
|
||||
x->partition_info = x->pi;
|
||||
|
@ -2327,8 +2327,7 @@ static void single_motion_search(VP9_COMP *cpi, MACROBLOCK *x,
|
||||
for (i = 0; i < MAX_MB_PLANE; i++)
|
||||
backup_yv12[i] = xd->plane[i].pre[0];
|
||||
|
||||
setup_pre_planes(xd, scaled_ref_frame, NULL, mi_row, mi_col,
|
||||
NULL, NULL);
|
||||
setup_pre_planes(xd, 0, scaled_ref_frame, mi_row, mi_col, NULL, NULL);
|
||||
}
|
||||
|
||||
vp9_clamp_mv_min_max(x, &ref_mv);
|
||||
@ -2417,8 +2416,7 @@ static void joint_motion_search(VP9_COMP *cpi, MACROBLOCK *x,
|
||||
// motion search code to be used without additional modifications.
|
||||
for (i = 0; i < MAX_MB_PLANE; i++)
|
||||
backup_yv12[i] = xd->plane[i].pre[0];
|
||||
setup_pre_planes(xd, scaled_ref_frame[0], NULL, mi_row, mi_col,
|
||||
NULL, NULL);
|
||||
setup_pre_planes(xd, 0, scaled_ref_frame[0], mi_row, mi_col, NULL, NULL);
|
||||
}
|
||||
|
||||
if (scaled_ref_frame[1]) {
|
||||
@ -2426,8 +2424,7 @@ static void joint_motion_search(VP9_COMP *cpi, MACROBLOCK *x,
|
||||
for (i = 0; i < MAX_MB_PLANE; i++)
|
||||
backup_second_yv12[i] = xd->plane[i].pre[1];
|
||||
|
||||
setup_pre_planes(xd, scaled_ref_frame[1], NULL, mi_row, mi_col,
|
||||
NULL, NULL);
|
||||
setup_pre_planes(xd, 0, scaled_ref_frame[1], mi_row, mi_col, NULL, NULL);
|
||||
}
|
||||
|
||||
xd->scale_factor[0].set_scaled_offsets(&xd->scale_factor[0],
|
||||
|
Loading…
x
Reference in New Issue
Block a user