diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c index eaed1a964bb766ea7f92341986545eb2a1438bf5..c0fe5ac767bb040d5df77b92c68239b35f4a0c78 100644 --- a/vp9/encoder/vp9_encodeframe.c +++ b/vp9/encoder/vp9_encodeframe.c @@ -1187,7 +1187,7 @@ static void init_encode_frame_mb_context(VP9_COMP *cpi) { // 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 @@ -2089,11 +2089,11 @@ static void encode_macroblock(VP9_COMP *cpi, TOKENEXTRA **t, 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], @@ -2104,11 +2104,11 @@ static void encode_macroblock(VP9_COMP *cpi, TOKENEXTRA **t, 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], @@ -2319,11 +2319,11 @@ static void encode_superblock32(VP9_COMP *cpi, TOKENEXTRA **t, 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], @@ -2334,11 +2334,11 @@ static void encode_superblock32(VP9_COMP *cpi, TOKENEXTRA **t, 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], @@ -2548,11 +2548,11 @@ static void encode_superblock64(VP9_COMP *cpi, TOKENEXTRA **t, 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], @@ -2563,11 +2563,11 @@ static void encode_superblock64(VP9_COMP *cpi, TOKENEXTRA **t, 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], diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c index 05a0f6f04febf740e9f1db95e0170cf339a99048..4d0a299e8437325d20aec04dae42e077d3091ce4 100644 --- a/vp9/encoder/vp9_firstpass.c +++ b/vp9/encoder/vp9_firstpass.c @@ -436,10 +436,10 @@ void vp9_first_pass(VP9_COMP *cpi) { 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; diff --git a/vp9/encoder/vp9_mbgraph.c b/vp9/encoder/vp9_mbgraph.c index bc06c9458db49b19d9d423fe5bbeec27c44eb1ee..d6644c2aae033df17f31a74e198fe4afd354dac9 100644 --- a/vp9/encoder/vp9_mbgraph.c +++ b/vp9/encoder/vp9_mbgraph.c @@ -445,7 +445,7 @@ void vp9_update_mbgraph_stats 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 diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c index 45ab6cd8c8900fc447fcbf090e395ff7c0099ff0..ced6eddcac9f4516caddbc6ff0be89d5f32fbd5f 100644 --- a/vp9/encoder/vp9_onyx_if.c +++ b/vp9/encoder/vp9_onyx_if.c @@ -833,7 +833,7 @@ void vp9_set_speed_features(VP9_COMP *cpi) { } { - 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); @@ -1754,7 +1754,7 @@ void vp9_remove_compressor(VP9_PTR *ptr) { #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); @@ -2099,11 +2099,11 @@ int vp9_get_reference_enc(VP9_PTR ptr, VP9_REFFRAME ref_frame_flag, 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; @@ -2120,11 +2120,11 @@ int vp9_set_reference_enc(VP9_PTR ptr, VP9_REFFRAME ref_frame_flag, 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; @@ -2480,9 +2480,9 @@ static void update_reference_frames(VP9_COMP * const cpi) { // 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 @@ -2496,7 +2496,7 @@ static void update_reference_frames(VP9_COMP * const cpi) { 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; @@ -2504,18 +2504,18 @@ static void update_reference_frames(VP9_COMP * const cpi) { } 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); } } @@ -2604,7 +2604,7 @@ static void scale_references(VP9_COMP *cpi) { 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); @@ -2616,8 +2616,8 @@ static void scale_references(VP9_COMP *cpi) { 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]]++; } } } @@ -3644,8 +3644,8 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi, 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); } @@ -3867,6 +3867,11 @@ int vp9_get_compressed_data(VP9_PTR ptr, unsigned int *frame_flags, 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, diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c index bc075d9be471920ff3907b4c20445215bab8aca3..4f843005a2a5672a5e6d193aca8cba0d35c5dc1a 100644 --- a/vp9/encoder/vp9_rdopt.c +++ b/vp9/encoder/vp9_rdopt.c @@ -3112,7 +3112,7 @@ static void setup_buffer_inter(VP9_COMP *cpi, MACROBLOCK *x, 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; @@ -4084,7 +4084,7 @@ static void rd_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, 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]]; } @@ -5177,7 +5177,7 @@ static int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x, 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