Commit f0e4669e authored by Zoe Liu's avatar Zoe Liu
Browse files

Clean code a bit and fix a couple of small bugs in ext-refs

Currently the patch does not have any impact on the RD performance. The
fix could however potentially help on the next step of work, especially
when the extra altref frames allow non-zero temporal filtering strength
and their corresponding OVERLAY frames, i.e. the INTNL_OVERLAY frames
are being added.

Change-Id: I2e07fb3d0aa547a0b5dd05bb4ba865cd46309076
parent 3265ef3d
......@@ -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];
// [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) {
memcpy(cpi->interp_filter_selected[ref_frame + 1],
cpi->interp_filter_selected[ref_frame],
sizeof(cpi->interp_filter_selected[ref_frame]));
memcpy(cpi->interp_filter_selected[ref_frame + LAST_FRAME],
cpi->interp_filter_selected[ref_frame - 1 + LAST_FRAME],
sizeof(cpi->interp_filter_selected[ref_frame - 1 + LAST_FRAME]));
}
}
}
#endif
#endif // CONFIG_EXT_REFS
void av1_update_reference_frames(AV1_COMP *cpi) {
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];
shift_last_ref_frames(cpi);
cpi->lst_fb_idxes[0] = cpi->bwd_fb_idx;
if (!cpi->rc.is_src_frame_alt_ref) {
memcpy(cpi->interp_filter_selected[0],
cpi->interp_filter_selected[BWDREF_FRAME],
sizeof(cpi->interp_filter_selected[BWDREF_FRAME]));
}
cpi->bwd_fb_idx = tmp;
memcpy(cpi->interp_filter_selected[LAST_FRAME],
cpi->interp_filter_selected[BWDREF_FRAME],
sizeof(cpi->interp_filter_selected[BWDREF_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
// 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];
shift_last_ref_frames(cpi);
cpi->lst_fb_idxes[0] = cpi->alt_fb_idx;
memcpy(cpi->interp_filter_selected[LAST_FRAME],
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;
memcpy(cpi->interp_filter_selected[LAST_FRAME],
cpi->interp_filter_selected[ALTREF_FRAME + which_arf],
sizeof(cpi->interp_filter_selected[ALTREF_FRAME + which_arf]));
#endif // CONFIG_EXT_REFS
} else { /* For non key/golden frames */
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,
&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],
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
......@@ -3271,6 +3259,7 @@ void av1_update_reference_frames(AV1_COMP *cpi) {
cpi->alt_fb_idx = cpi->bwd_fb_idx;
cpi->bwd_fb_idx = tmp;
}
ref_cnt_fb(pool->frame_bufs, &cm->ref_frame_map[cpi->bwd_fb_idx],
cm->new_fb_idx);
if (use_upsampled_ref)
......@@ -3354,20 +3343,14 @@ void av1_update_reference_frames(AV1_COMP *cpi) {
tmp = cpi->lst_fb_idxes[LAST_REF_FRAMES - 1];
shift_last_ref_frames(cpi);
cpi->lst_fb_idxes[0] = tmp;
if (!cpi->rc.is_src_frame_alt_ref) {
if (cm->show_existing_frame) {
memcpy(cpi->interp_filter_selected[LAST_FRAME],
cpi->interp_filter_selected[BWDREF_FRAME],
sizeof(cpi->interp_filter_selected[BWDREF_FRAME]));
} else {
memcpy(cpi->interp_filter_selected[LAST_FRAME],
cpi->interp_filter_selected[0],
sizeof(cpi->interp_filter_selected[0]));
}
}
assert(cm->show_existing_frame == 0);
// NOTE: Currently only LF_UPDATE and INTNL_OVERLAY_UPDATE frames are to
// refresh the LAST_FRAME.
memcpy(cpi->interp_filter_selected[LAST_FRAME],
cpi->interp_filter_selected[0],
sizeof(cpi->interp_filter_selected[0]));
}
#else
ref_cnt_fb(pool->frame_bufs, &cm->ref_frame_map[cpi->lst_fb_idx],
......
......@@ -2585,10 +2585,11 @@ static void configure_buffer_updates(AV1_COMP *cpi) {
if (cpi->num_extra_arfs) {
int tmp = cpi->bwd_fb_idx;
cpi->rc.is_bwd_ref_frame = 1;
cpi->bwd_fb_idx = cpi->alt_fb_idx;
cpi->alt_fb_idx = cpi->arf_map[0];
cpi->arf_map[0] = tmp;
cpi->rc.is_bwd_ref_frame = 1;
} else {
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
// (in av1_update_reference_frames()).
int tmp = cpi->bwd_fb_idx;
cpi->bwd_fb_idx = cpi->alt_fb_idx;
cpi->alt_fb_idx = cpi->arf_map[0];
cpi->arf_map[0] = tmp;
}
break;
case LAST_BIPRED_UPDATE:
cpi->refresh_last_frame = 0;
cpi->refresh_golden_frame = 0;
......
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