Merge "Clean code a bit and fix a couple of small bugs in ext-refs" into nextgenv2

This commit is contained in:
Zoe Liu
2016-10-13 16:47:03 +00:00
committed by Gerrit Code Review
2 changed files with 28 additions and 42 deletions

View File

@@ -3086,15 +3086,15 @@ static INLINE void shift_last_ref_frames(AV1_COMP *cpi) {
cpi->lst_fb_idxes[ref_frame] = cpi->lst_fb_idxes[ref_frame - 1]; cpi->lst_fb_idxes[ref_frame] = cpi->lst_fb_idxes[ref_frame - 1];
// [0] is allocated to the current coded frame. The statistics for the // [0] is allocated to the current coded frame. The statistics for the
// reference frames start at [1]. // reference frames start at [LAST_FRAME], i.e. [1].
if (!cpi->rc.is_src_frame_alt_ref) { if (!cpi->rc.is_src_frame_alt_ref) {
memcpy(cpi->interp_filter_selected[ref_frame + 1], memcpy(cpi->interp_filter_selected[ref_frame + LAST_FRAME],
cpi->interp_filter_selected[ref_frame], cpi->interp_filter_selected[ref_frame - 1 + LAST_FRAME],
sizeof(cpi->interp_filter_selected[ref_frame])); sizeof(cpi->interp_filter_selected[ref_frame - 1 + LAST_FRAME]));
} }
} }
} }
#endif #endif // CONFIG_EXT_REFS
void av1_update_reference_frames(AV1_COMP *cpi) { void av1_update_reference_frames(AV1_COMP *cpi) {
AV1_COMMON *const cm = &cpi->common; AV1_COMMON *const cm = &cpi->common;
@@ -3181,14 +3181,12 @@ void av1_update_reference_frames(AV1_COMP *cpi) {
int tmp = cpi->lst_fb_idxes[LAST_REF_FRAMES - 1]; int tmp = cpi->lst_fb_idxes[LAST_REF_FRAMES - 1];
shift_last_ref_frames(cpi); shift_last_ref_frames(cpi);
cpi->lst_fb_idxes[0] = cpi->bwd_fb_idx; cpi->lst_fb_idxes[0] = cpi->bwd_fb_idx;
if (!cpi->rc.is_src_frame_alt_ref) { cpi->bwd_fb_idx = tmp;
memcpy(cpi->interp_filter_selected[0],
memcpy(cpi->interp_filter_selected[LAST_FRAME],
cpi->interp_filter_selected[BWDREF_FRAME], cpi->interp_filter_selected[BWDREF_FRAME],
sizeof(cpi->interp_filter_selected[BWDREF_FRAME])); sizeof(cpi->interp_filter_selected[BWDREF_FRAME]));
}
cpi->bwd_fb_idx = tmp;
} else if (cpi->rc.is_src_frame_ext_arf && cm->show_existing_frame) { } else if (cpi->rc.is_src_frame_ext_arf && cm->show_existing_frame) {
// Deal with the special case for showing existing internal ALTREF_FRAME // Deal with the special case for showing existing internal ALTREF_FRAME
// Refresh the LAST_FRAME with the ALTREF_FRAME and retire the LAST3_FRAME // Refresh the LAST_FRAME with the ALTREF_FRAME and retire the LAST3_FRAME
@@ -3198,15 +3196,15 @@ void av1_update_reference_frames(AV1_COMP *cpi) {
int tmp = cpi->lst_fb_idxes[LAST_REF_FRAMES - 1]; int tmp = cpi->lst_fb_idxes[LAST_REF_FRAMES - 1];
shift_last_ref_frames(cpi); shift_last_ref_frames(cpi);
cpi->lst_fb_idxes[0] = cpi->alt_fb_idx; cpi->lst_fb_idxes[0] = cpi->alt_fb_idx;
cpi->alt_fb_idx = tmp;
// We need to modify the mapping accordingly
cpi->arf_map[which_arf] = cpi->alt_fb_idx;
memcpy(cpi->interp_filter_selected[LAST_FRAME], memcpy(cpi->interp_filter_selected[LAST_FRAME],
cpi->interp_filter_selected[ALTREF_FRAME + which_arf], cpi->interp_filter_selected[ALTREF_FRAME + which_arf],
sizeof(cpi->interp_filter_selected[ALTREF_FRAME + which_arf])); sizeof(cpi->interp_filter_selected[ALTREF_FRAME + which_arf]));
cpi->alt_fb_idx = tmp;
// We need to modify the mapping accordingly
cpi->arf_map[which_arf] = cpi->alt_fb_idx;
#endif // CONFIG_EXT_REFS #endif // CONFIG_EXT_REFS
} else { /* For non key/golden frames */ } else { /* For non key/golden frames */
if (cpi->refresh_alt_ref_frame) { if (cpi->refresh_alt_ref_frame) {
@@ -3241,22 +3239,12 @@ void av1_update_reference_frames(AV1_COMP *cpi) {
uref_cnt_fb(cpi->upsampled_ref_bufs, uref_cnt_fb(cpi->upsampled_ref_bufs,
&cpi->upsampled_ref_idx[cpi->gld_fb_idx], new_uidx); &cpi->upsampled_ref_idx[cpi->gld_fb_idx], new_uidx);
if (!cpi->rc.is_src_frame_alt_ref) { #if !CONFIG_EXT_REFS
if (!cpi->rc.is_src_frame_alt_ref)
#endif // !CONFIG_EXT_REFS
memcpy(cpi->interp_filter_selected[GOLDEN_FRAME], memcpy(cpi->interp_filter_selected[GOLDEN_FRAME],
cpi->interp_filter_selected[0], cpi->interp_filter_selected[0],
sizeof(cpi->interp_filter_selected[0])); sizeof(cpi->interp_filter_selected[0]));
} else {
int which_arf = 0;
#if CONFIG_EXT_REFS
if (cpi->oxcf.pass == 2) {
const GF_GROUP *const gf_group = &cpi->twopass.gf_group;
which_arf = gf_group->arf_update_idx[gf_group->index];
}
#endif // CONFIG_EXT_REFS
memcpy(cpi->interp_filter_selected[GOLDEN_FRAME],
cpi->interp_filter_selected[ALTREF_FRAME + which_arf],
sizeof(cpi->interp_filter_selected[ALTREF_FRAME + which_arf]));
}
} }
#if CONFIG_EXT_REFS #if CONFIG_EXT_REFS
@@ -3271,6 +3259,7 @@ void av1_update_reference_frames(AV1_COMP *cpi) {
cpi->alt_fb_idx = cpi->bwd_fb_idx; cpi->alt_fb_idx = cpi->bwd_fb_idx;
cpi->bwd_fb_idx = tmp; cpi->bwd_fb_idx = tmp;
} }
ref_cnt_fb(pool->frame_bufs, &cm->ref_frame_map[cpi->bwd_fb_idx], ref_cnt_fb(pool->frame_bufs, &cm->ref_frame_map[cpi->bwd_fb_idx],
cm->new_fb_idx); cm->new_fb_idx);
if (use_upsampled_ref) if (use_upsampled_ref)
@@ -3354,21 +3343,15 @@ void av1_update_reference_frames(AV1_COMP *cpi) {
tmp = cpi->lst_fb_idxes[LAST_REF_FRAMES - 1]; tmp = cpi->lst_fb_idxes[LAST_REF_FRAMES - 1];
shift_last_ref_frames(cpi); shift_last_ref_frames(cpi);
cpi->lst_fb_idxes[0] = tmp; cpi->lst_fb_idxes[0] = tmp;
if (!cpi->rc.is_src_frame_alt_ref) { assert(cm->show_existing_frame == 0);
if (cm->show_existing_frame) { // NOTE: Currently only LF_UPDATE and INTNL_OVERLAY_UPDATE frames are to
memcpy(cpi->interp_filter_selected[LAST_FRAME], // refresh the LAST_FRAME.
cpi->interp_filter_selected[BWDREF_FRAME],
sizeof(cpi->interp_filter_selected[BWDREF_FRAME]));
} else {
memcpy(cpi->interp_filter_selected[LAST_FRAME], memcpy(cpi->interp_filter_selected[LAST_FRAME],
cpi->interp_filter_selected[0], cpi->interp_filter_selected[0],
sizeof(cpi->interp_filter_selected[0])); sizeof(cpi->interp_filter_selected[0]));
} }
}
}
#else #else
ref_cnt_fb(pool->frame_bufs, &cm->ref_frame_map[cpi->lst_fb_idx], ref_cnt_fb(pool->frame_bufs, &cm->ref_frame_map[cpi->lst_fb_idx],
cm->new_fb_idx); cm->new_fb_idx);

View File

@@ -2585,10 +2585,11 @@ static void configure_buffer_updates(AV1_COMP *cpi) {
if (cpi->num_extra_arfs) { if (cpi->num_extra_arfs) {
int tmp = cpi->bwd_fb_idx; int tmp = cpi->bwd_fb_idx;
cpi->rc.is_bwd_ref_frame = 1;
cpi->bwd_fb_idx = cpi->alt_fb_idx; cpi->bwd_fb_idx = cpi->alt_fb_idx;
cpi->alt_fb_idx = cpi->arf_map[0]; cpi->alt_fb_idx = cpi->arf_map[0];
cpi->arf_map[0] = tmp; cpi->arf_map[0] = tmp;
cpi->rc.is_bwd_ref_frame = 1;
} else { } else {
cpi->rc.is_bwd_ref_frame = 0; cpi->rc.is_bwd_ref_frame = 0;
} }
@@ -2639,11 +2640,13 @@ static void configure_buffer_updates(AV1_COMP *cpi) {
// NOTE: The indices will be swapped back after this frame is encoded // NOTE: The indices will be swapped back after this frame is encoded
// (in av1_update_reference_frames()). // (in av1_update_reference_frames()).
int tmp = cpi->bwd_fb_idx; int tmp = cpi->bwd_fb_idx;
cpi->bwd_fb_idx = cpi->alt_fb_idx; cpi->bwd_fb_idx = cpi->alt_fb_idx;
cpi->alt_fb_idx = cpi->arf_map[0]; cpi->alt_fb_idx = cpi->arf_map[0];
cpi->arf_map[0] = tmp; cpi->arf_map[0] = tmp;
} }
break; break;
case LAST_BIPRED_UPDATE: case LAST_BIPRED_UPDATE:
cpi->refresh_last_frame = 0; cpi->refresh_last_frame = 0;
cpi->refresh_golden_frame = 0; cpi->refresh_golden_frame = 0;