// Copy data over into macro block data structures.
x->src = *cpi->Source;
- xd->pre = cm->yv12_fb[cm->active_ref_idx[cpi->lst_fb_idx]];
+ xd->pre = cm->yv12_fb[cm->ref_frame_map[cpi->lst_fb_idx]];
xd->dst = cm->yv12_fb[cm->new_fb_idx];
// set up frame for intra coded blocks
assert(cm->frame_type != KEY_FRAME);
if (mbmi->ref_frame == LAST_FRAME)
- ref_fb_idx = cpi->common.active_ref_idx[cpi->lst_fb_idx];
+ ref_fb_idx = cpi->common.ref_frame_map[cpi->lst_fb_idx];
else if (mbmi->ref_frame == GOLDEN_FRAME)
- ref_fb_idx = cpi->common.active_ref_idx[cpi->gld_fb_idx];
+ ref_fb_idx = cpi->common.ref_frame_map[cpi->gld_fb_idx];
else
- ref_fb_idx = cpi->common.active_ref_idx[cpi->alt_fb_idx];
+ ref_fb_idx = cpi->common.ref_frame_map[cpi->alt_fb_idx];
setup_pred_block(&xd->pre,
&cpi->common.yv12_fb[ref_fb_idx],
int second_ref_fb_idx;
if (mbmi->second_ref_frame == LAST_FRAME)
- second_ref_fb_idx = cpi->common.active_ref_idx[cpi->lst_fb_idx];
+ second_ref_fb_idx = cpi->common.ref_frame_map[cpi->lst_fb_idx];
else if (mbmi->second_ref_frame == GOLDEN_FRAME)
- second_ref_fb_idx = cpi->common.active_ref_idx[cpi->gld_fb_idx];
+ second_ref_fb_idx = cpi->common.ref_frame_map[cpi->gld_fb_idx];
else
- second_ref_fb_idx = cpi->common.active_ref_idx[cpi->alt_fb_idx];
+ second_ref_fb_idx = cpi->common.ref_frame_map[cpi->alt_fb_idx];
setup_pred_block(&xd->second_pre,
&cpi->common.yv12_fb[second_ref_fb_idx],
assert(cm->frame_type != KEY_FRAME);
if (xd->mode_info_context->mbmi.ref_frame == LAST_FRAME)
- ref_fb_idx = cpi->common.active_ref_idx[cpi->lst_fb_idx];
+ ref_fb_idx = cpi->common.ref_frame_map[cpi->lst_fb_idx];
else if (xd->mode_info_context->mbmi.ref_frame == GOLDEN_FRAME)
- ref_fb_idx = cpi->common.active_ref_idx[cpi->gld_fb_idx];
+ ref_fb_idx = cpi->common.ref_frame_map[cpi->gld_fb_idx];
else
- ref_fb_idx = cpi->common.active_ref_idx[cpi->alt_fb_idx];
+ ref_fb_idx = cpi->common.ref_frame_map[cpi->alt_fb_idx];
setup_pred_block(&xd->pre,
&cpi->common.yv12_fb[ref_fb_idx],
int second_ref_fb_idx;
if (xd->mode_info_context->mbmi.second_ref_frame == LAST_FRAME)
- second_ref_fb_idx = cpi->common.active_ref_idx[cpi->lst_fb_idx];
+ second_ref_fb_idx = cpi->common.ref_frame_map[cpi->lst_fb_idx];
else if (xd->mode_info_context->mbmi.second_ref_frame == GOLDEN_FRAME)
- second_ref_fb_idx = cpi->common.active_ref_idx[cpi->gld_fb_idx];
+ second_ref_fb_idx = cpi->common.ref_frame_map[cpi->gld_fb_idx];
else
- second_ref_fb_idx = cpi->common.active_ref_idx[cpi->alt_fb_idx];
+ second_ref_fb_idx = cpi->common.ref_frame_map[cpi->alt_fb_idx];
setup_pred_block(&xd->second_pre,
&cpi->common.yv12_fb[second_ref_fb_idx],
assert(cm->frame_type != KEY_FRAME);
if (xd->mode_info_context->mbmi.ref_frame == LAST_FRAME)
- ref_fb_idx = cpi->common.active_ref_idx[cpi->lst_fb_idx];
+ ref_fb_idx = cpi->common.ref_frame_map[cpi->lst_fb_idx];
else if (xd->mode_info_context->mbmi.ref_frame == GOLDEN_FRAME)
- ref_fb_idx = cpi->common.active_ref_idx[cpi->gld_fb_idx];
+ ref_fb_idx = cpi->common.ref_frame_map[cpi->gld_fb_idx];
else
- ref_fb_idx = cpi->common.active_ref_idx[cpi->alt_fb_idx];
+ ref_fb_idx = cpi->common.ref_frame_map[cpi->alt_fb_idx];
setup_pred_block(&xd->pre,
&cpi->common.yv12_fb[ref_fb_idx],
int second_ref_fb_idx;
if (xd->mode_info_context->mbmi.second_ref_frame == LAST_FRAME)
- second_ref_fb_idx = cpi->common.active_ref_idx[cpi->lst_fb_idx];
+ second_ref_fb_idx = cpi->common.ref_frame_map[cpi->lst_fb_idx];
else if (xd->mode_info_context->mbmi.second_ref_frame == GOLDEN_FRAME)
- second_ref_fb_idx = cpi->common.active_ref_idx[cpi->gld_fb_idx];
+ second_ref_fb_idx = cpi->common.ref_frame_map[cpi->gld_fb_idx];
else
- second_ref_fb_idx = cpi->common.active_ref_idx[cpi->alt_fb_idx];
+ second_ref_fb_idx = cpi->common.ref_frame_map[cpi->alt_fb_idx];
setup_pred_block(&xd->second_pre,
&cpi->common.yv12_fb[second_ref_fb_idx],
int recon_yoffset, recon_uvoffset;
YV12_BUFFER_CONFIG *lst_yv12 =
- &cm->yv12_fb[cm->active_ref_idx[cpi->lst_fb_idx]];
+ &cm->yv12_fb[cm->ref_frame_map[cpi->lst_fb_idx]];
YV12_BUFFER_CONFIG *new_yv12 = &cm->yv12_fb[cm->new_fb_idx];
YV12_BUFFER_CONFIG *gld_yv12 =
- &cm->yv12_fb[cm->active_ref_idx[cpi->gld_fb_idx]];
+ &cm->yv12_fb[cm->ref_frame_map[cpi->gld_fb_idx]];
int recon_y_stride = lst_yv12->y_stride;
int recon_uv_stride = lst_yv12->uv_stride;
int64_t intra_error = 0;
VP9_COMMON *const cm = &cpi->common;
int i, n_frames = vp9_lookahead_depth(cpi->lookahead);
YV12_BUFFER_CONFIG *golden_ref =
- &cm->yv12_fb[cm->active_ref_idx[cpi->gld_fb_idx]];
+ &cm->yv12_fb[cm->ref_frame_map[cpi->gld_fb_idx]];
// we need to look ahead beyond where the ARF transitions into
// being a GF - so exit if we don't look ahead beyond that
}
{
- int y_stride = cm->yv12_fb[cm->active_ref_idx[cpi->lst_fb_idx]].y_stride;
+ int y_stride = cm->yv12_fb[cm->ref_frame_map[cpi->lst_fb_idx]].y_stride;
if (cpi->sf.search_method == NSTEP) {
vp9_init3smotion_compensation(&cpi->mb, y_stride);
#endif
if (cpi->b_calculate_psnr) {
YV12_BUFFER_CONFIG *lst_yv12 =
- &cpi->common.yv12_fb[cpi->common.active_ref_idx[cpi->lst_fb_idx]];
+ &cpi->common.yv12_fb[cpi->common.ref_frame_map[cpi->lst_fb_idx]];
double samples = 3.0 / 2 * cpi->count * lst_yv12->y_width * lst_yv12->y_height;
double total_psnr = vp9_mse2psnr(samples, 255.0, cpi->total_sq_error);
double total_psnr2 = vp9_mse2psnr(samples, 255.0, cpi->total_sq_error2);
int ref_fb_idx;
if (ref_frame_flag == VP9_LAST_FLAG)
- ref_fb_idx = cm->active_ref_idx[cpi->lst_fb_idx];
+ ref_fb_idx = cm->ref_frame_map[cpi->lst_fb_idx];
else if (ref_frame_flag == VP9_GOLD_FLAG)
- ref_fb_idx = cm->active_ref_idx[cpi->gld_fb_idx];
+ ref_fb_idx = cm->ref_frame_map[cpi->gld_fb_idx];
else if (ref_frame_flag == VP9_ALT_FLAG)
- ref_fb_idx = cm->active_ref_idx[cpi->alt_fb_idx];
+ ref_fb_idx = cm->ref_frame_map[cpi->alt_fb_idx];
else
return -1;
int ref_fb_idx;
if (ref_frame_flag == VP9_LAST_FLAG)
- ref_fb_idx = cm->active_ref_idx[cpi->lst_fb_idx];
+ ref_fb_idx = cm->ref_frame_map[cpi->lst_fb_idx];
else if (ref_frame_flag == VP9_GOLD_FLAG)
- ref_fb_idx = cm->active_ref_idx[cpi->gld_fb_idx];
+ ref_fb_idx = cm->ref_frame_map[cpi->gld_fb_idx];
else if (ref_frame_flag == VP9_ALT_FLAG)
- ref_fb_idx = cm->active_ref_idx[cpi->alt_fb_idx];
+ ref_fb_idx = cm->ref_frame_map[cpi->alt_fb_idx];
else
return -1;
// If any buffer copy / swapping is signaled it should be done here.
if (cm->frame_type == KEY_FRAME) {
ref_cnt_fb(cm->fb_idx_ref_cnt,
- &cm->active_ref_idx[cpi->gld_fb_idx], cm->new_fb_idx);
+ &cm->ref_frame_map[cpi->gld_fb_idx], cm->new_fb_idx);
ref_cnt_fb(cm->fb_idx_ref_cnt,
- &cm->active_ref_idx[cpi->alt_fb_idx], cm->new_fb_idx);
+ &cm->ref_frame_map[cpi->alt_fb_idx], cm->new_fb_idx);
} else if (cpi->refresh_golden_frame && !cpi->refresh_alt_ref_frame) {
/* Preserve the previously existing golden frame and update the frame in
* the alt ref slot instead. This is highly specific to the current use of
int tmp;
ref_cnt_fb(cm->fb_idx_ref_cnt,
- &cm->active_ref_idx[cpi->alt_fb_idx], cm->new_fb_idx);
+ &cm->ref_frame_map[cpi->alt_fb_idx], cm->new_fb_idx);
tmp = cpi->alt_fb_idx;
cpi->alt_fb_idx = cpi->gld_fb_idx;
} else { /* For non key/golden frames */
if (cpi->refresh_alt_ref_frame) {
ref_cnt_fb(cm->fb_idx_ref_cnt,
- &cm->active_ref_idx[cpi->alt_fb_idx], cm->new_fb_idx);
+ &cm->ref_frame_map[cpi->alt_fb_idx], cm->new_fb_idx);
}
if (cpi->refresh_golden_frame) {
ref_cnt_fb(cm->fb_idx_ref_cnt,
- &cm->active_ref_idx[cpi->gld_fb_idx], cm->new_fb_idx);
+ &cm->ref_frame_map[cpi->gld_fb_idx], cm->new_fb_idx);
}
}
if (cpi->refresh_last_frame) {
ref_cnt_fb(cm->fb_idx_ref_cnt,
- &cm->active_ref_idx[cpi->lst_fb_idx], cm->new_fb_idx);
+ &cm->ref_frame_map[cpi->lst_fb_idx], cm->new_fb_idx);
}
}
int i;
for (i = 0; i < 3; i++) {
- YV12_BUFFER_CONFIG *ref = &cm->yv12_fb[cm->active_ref_idx[i]];
+ YV12_BUFFER_CONFIG *ref = &cm->yv12_fb[cm->ref_frame_map[i]];
if (ref->y_width != cm->Width || ref->y_height != cm->Height) {
int new_fb = get_free_fb(cm);
scale_and_extend_frame(ref, &cm->yv12_fb[new_fb]);
cpi->scaled_ref_idx[i] = new_fb;
} else {
- cpi->scaled_ref_idx[i] = cm->active_ref_idx[i];
- cm->fb_idx_ref_cnt[cm->active_ref_idx[i]]++;
+ cpi->scaled_ref_idx[i] = cm->ref_frame_map[i];
+ cm->fb_idx_ref_cnt[cm->ref_frame_map[i]]++;
}
}
}
FILE *recon_file;
sprintf(filename, "enc%04d.yuv", (int) cm->current_video_frame);
recon_file = fopen(filename, "wb");
- fwrite(cm->yv12_fb[cm->active_ref_idx[cpi->lst_fb_idx]].buffer_alloc,
- cm->yv12_fb[cm->active_ref_idx[cpi->lst_fb_idx]].frame_size,
+ fwrite(cm->yv12_fb[cm->ref_frame_map[cpi->lst_fb_idx]].buffer_alloc,
+ cm->yv12_fb[cm->ref_frame_map[cpi->lst_fb_idx]].frame_size,
1, recon_file);
fclose(recon_file);
}
cm->fb_idx_ref_cnt[cm->new_fb_idx]--;
cm->new_fb_idx = get_free_fb(cm);
+ /* Get the mapping of L/G/A to the reference buffer pool */
+ cm->active_ref_idx[0] = cm->ref_frame_map[cpi->lst_fb_idx];
+ cm->active_ref_idx[1] = cm->ref_frame_map[cpi->gld_fb_idx];
+ cm->active_ref_idx[2] = cm->ref_frame_map[cpi->alt_fb_idx];
+
/* Reset the frame pointers to the current frame size */
vp8_yv12_realloc_frame_buffer(&cm->yv12_fb[cm->new_fb_idx],
cm->mb_cols * 16, cm->mb_rows * 16,
YV12_BUFFER_CONFIG yv12_mb[4],
struct scale_factors scale[MAX_REF_FRAMES]) {
VP9_COMMON *cm = &cpi->common;
- YV12_BUFFER_CONFIG *yv12 = &cm->yv12_fb[cpi->common.active_ref_idx[idx]];
+ YV12_BUFFER_CONFIG *yv12 = &cm->yv12_fb[cpi->common.ref_frame_map[idx]];
MACROBLOCKD *const xd = &x->e_mbd;
MB_MODE_INFO *const mbmi = &xd->mode_info_context->mbmi;
int use_prev_in_find_mv_refs, use_prev_in_find_best_ref;
fb = cpi->alt_fb_idx;
}
- if (cpi->scaled_ref_idx[fb] != cm->active_ref_idx[fb])
+ if (cpi->scaled_ref_idx[fb] != cm->ref_frame_map[fb])
scaled_ref_frame = &cm->yv12_fb[cpi->scaled_ref_idx[fb]];
}
fb = cpi->alt_fb_idx;
}
- if (cpi->scaled_ref_idx[fb] != cm->active_ref_idx[fb])
+ if (cpi->scaled_ref_idx[fb] != cm->ref_frame_map[fb])
scaled_ref_frame = &cm->yv12_fb[cpi->scaled_ref_idx[fb]];
#if CONFIG_COMP_INTERINTRA_PRED