Commit da832a80 authored by John Koleszar's avatar John Koleszar

Start to anonymize reference frames

Remove lst_fb_idx, gld_fb_idx, alt_fb_idx, refresh_last_frame,
refresh_golden_frame, refresh_alt_ref_frame from common. Gold/Alt are
encode side conventions. From the decoder's perspective, we want to be
dealing with numbered references.

Updates to active_ref 2 signal mode context switches, vestigial from
refresh_alt_ref_frame. This needs some clean up to make sense with
increased numbers of reference frames, as well as reimplementing the
swapping of alt/golden which was previously done using the
buffer-to-buffer copy mechanism removed in an earlier commit.

Change-Id: I7334445158b7666f9295d2a2dd22aa03f4485f58
parent 394b0a6a
......@@ -88,9 +88,8 @@ int vp9_alloc_frame_buffers(VP9_COMMON *oci, int width, int height) {
}
oci->new_fb_idx = 0;
oci->lst_fb_idx = 1;
oci->gld_fb_idx = 2;
oci->alt_fb_idx = 3;
for (i = 0; i < 3; i++)
oci->active_ref_idx[i] = i + 1;
oci->fb_idx_ref_cnt[0] = 1;
oci->fb_idx_ref_cnt[1] = 1;
......
......@@ -37,7 +37,8 @@ void vp9_initialize_common(void);
#define QINDEX_RANGE (MAXQ + 1)
#define NUM_YV12_BUFFERS 4
#define NUM_REF_FRAMES 3
#define NUM_YV12_BUFFERS (NUM_REF_FRAMES + 1)
#define COMP_PRED_CONTEXTS 2
......@@ -142,8 +143,9 @@ typedef struct VP9Common {
YV12_BUFFER_CONFIG *frame_to_show;
YV12_BUFFER_CONFIG yv12_fb[NUM_YV12_BUFFERS];
int fb_idx_ref_cnt[NUM_YV12_BUFFERS];
int new_fb_idx, lst_fb_idx, gld_fb_idx, alt_fb_idx;
int fb_idx_ref_cnt[NUM_YV12_BUFFERS]; /* reference counts */
int active_ref_idx[3]; /* each frame can reference 3 buffers */
int new_fb_idx;
YV12_BUFFER_CONFIG post_proc_buffer;
YV12_BUFFER_CONFIG temp_scale_frame;
......@@ -202,10 +204,6 @@ typedef struct VP9Common {
int last_sharpness_level;
int sharpness_level;
int refresh_last_frame; /* Two state 0 = NO, 1 = YES */
int refresh_golden_frame; /* Two state 0 = NO, 1 = YES */
int refresh_alt_ref_frame; /* Two state 0 = NO, 1 = YES */
int refresh_entropy_probs; /* Two state 0 = NO, 1 = YES */
int ref_frame_sign_bias[MAX_REF_FRAMES]; /* Two state 0, 1 */
......
......@@ -730,12 +730,7 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
int ref_fb_idx;
/* Select the appropriate reference frame for this MB */
if (ref_frame == LAST_FRAME)
ref_fb_idx = cm->lst_fb_idx;
else if (ref_frame == GOLDEN_FRAME)
ref_fb_idx = cm->gld_fb_idx;
else
ref_fb_idx = cm->alt_fb_idx;
ref_fb_idx = cm->active_ref_idx[ref_frame - 1];
recon_y_stride = cm->yv12_fb[ref_fb_idx].y_stride ;
recon_uv_stride = cm->yv12_fb[ref_fb_idx].uv_stride;
......@@ -818,13 +813,7 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
if (mbmi->second_ref_frame > 0) {
int second_ref_fb_idx;
/* Select the appropriate reference frame for this MB */
if (mbmi->second_ref_frame == LAST_FRAME)
second_ref_fb_idx = cm->lst_fb_idx;
else if (mbmi->second_ref_frame ==
GOLDEN_FRAME)
second_ref_fb_idx = cm->gld_fb_idx;
else
second_ref_fb_idx = cm->alt_fb_idx;
second_ref_fb_idx = cm->active_ref_idx[mbmi->second_ref_frame - 1];
xd->second_pre.y_buffer =
cm->yv12_fb[second_ref_fb_idx].y_buffer + recon_yoffset;
......
......@@ -1091,12 +1091,7 @@ static void set_refs(VP9D_COMP *pbi, int block_size,
int ref_fb_idx, ref_yoffset, ref_uvoffset, ref_y_stride, ref_uv_stride;
/* Select the appropriate reference frame for this MB */
if (mbmi->ref_frame == LAST_FRAME)
ref_fb_idx = cm->lst_fb_idx;
else if (mbmi->ref_frame == GOLDEN_FRAME)
ref_fb_idx = cm->gld_fb_idx;
else
ref_fb_idx = cm->alt_fb_idx;
ref_fb_idx = cm->active_ref_idx[mbmi->ref_frame - 1];
ref_y_stride = cm->yv12_fb[ref_fb_idx].y_stride;
ref_yoffset = mb_row * 16 * ref_y_stride + 16 * mb_col;
......@@ -1113,12 +1108,7 @@ static void set_refs(VP9D_COMP *pbi, int block_size,
int second_ref_fb_idx;
/* Select the appropriate reference frame for this MB */
if (mbmi->second_ref_frame == LAST_FRAME)
second_ref_fb_idx = cm->lst_fb_idx;
else if (mbmi->second_ref_frame == GOLDEN_FRAME)
second_ref_fb_idx = cm->gld_fb_idx;
else
second_ref_fb_idx = cm->alt_fb_idx;
second_ref_fb_idx = cm->active_ref_idx[mbmi->second_ref_frame - 1];
xd->second_pre.y_buffer =
cm->yv12_fb[second_ref_fb_idx].y_buffer + ref_yoffset;
......@@ -1288,8 +1278,7 @@ static void init_frame(VP9D_COMP *pbi) {
vpx_memset(xd->mode_lf_deltas, 0, sizeof(xd->mode_lf_deltas));
/* All buffers are implicitly updated on key frames. */
pc->refresh_golden_frame = 1;
pc->refresh_alt_ref_frame = 1;
pbi->refresh_frame_flags = (1 << NUM_REF_FRAMES) - 1;
/* Note that Golden and Altref modes cannot be used on a key frame so
* ref_frame_sign_bias[] is undefined and meaningless
......@@ -1645,10 +1634,10 @@ int vp9_decode_frame(VP9D_COMP *pbi, const unsigned char **p_data_end) {
*/
if (pc->frame_type != KEY_FRAME) {
/* Should the GF or ARF be updated from the current frame */
pc->refresh_golden_frame = vp9_read_bit(&header_bc);
pc->refresh_alt_ref_frame = vp9_read_bit(&header_bc);
pbi->refresh_frame_flags = vp9_read_literal(&header_bc, NUM_REF_FRAMES);
if (pc->refresh_alt_ref_frame) {
/* TODO(jkoleszar): What's the right thing to do here with more refs? */
if (pbi->refresh_frame_flags & 0x4) {
vpx_memcpy(&pc->fc, &pc->lfc_a, sizeof(pc->fc));
} else {
vpx_memcpy(&pc->fc, &pc->lfc, sizeof(pc->fc));
......@@ -1677,9 +1666,6 @@ int vp9_decode_frame(VP9D_COMP *pbi, const unsigned char **p_data_end) {
vpx_memcpy(&pc->lfc, &pc->fc, sizeof(pc->fc));
}
pc->refresh_last_frame = (pc->frame_type == KEY_FRAME)
|| vp9_read_bit(&header_bc);
// Read inter mode probability context updates
if (pc->frame_type != KEY_FRAME) {
int i, j;
......@@ -1722,12 +1708,10 @@ int vp9_decode_frame(VP9D_COMP *pbi, const unsigned char **p_data_end) {
if (0) {
FILE *z = fopen("decodestats.stt", "a");
fprintf(z, "%6d F:%d,G:%d,A:%d,L:%d,Q:%d\n",
fprintf(z, "%6d F:%d,R:%d,Q:%d\n",
pc->current_video_frame,
pc->frame_type,
pc->refresh_golden_frame,
pc->refresh_alt_ref_frame,
pc->refresh_last_frame,
pbi->refresh_frame_flags,
pc->base_qindex);
fclose(z);
}
......@@ -1779,8 +1763,11 @@ int vp9_decode_frame(VP9D_COMP *pbi, const unsigned char **p_data_end) {
read_coef_probs(pbi, &header_bc);
vpx_memcpy(&xd->pre, &pc->yv12_fb[pc->lst_fb_idx], sizeof(YV12_BUFFER_CONFIG));
vpx_memcpy(&xd->dst, &pc->yv12_fb[pc->new_fb_idx], sizeof(YV12_BUFFER_CONFIG));
/* Initialize xd pointers. Any reference should do for xd->pre, so use 0. */
vpx_memcpy(&xd->pre, &pc->yv12_fb[pc->active_ref_idx[0]],
sizeof(YV12_BUFFER_CONFIG));
vpx_memcpy(&xd->dst, &pc->yv12_fb[pc->new_fb_idx],
sizeof(YV12_BUFFER_CONFIG));
// Create the segmentation map structure and set to 0
if (!pc->last_frame_seg_map)
......@@ -1832,13 +1819,9 @@ int vp9_decode_frame(VP9D_COMP *pbi, const unsigned char **p_data_end) {
vp9_update_mode_context(&pbi->common);
}
/* If this was a kf or Gf note the Q used */
if ((pc->frame_type == KEY_FRAME) ||
pc->refresh_golden_frame || pc->refresh_alt_ref_frame) {
pc->last_kf_gf_q = pc->base_qindex;
}
if (pc->refresh_entropy_probs) {
if (pc->refresh_alt_ref_frame)
/* TODO(jkoleszar): What's the right thing to do here with more refs? */
if (pbi->refresh_frame_flags & 0x4)
vpx_memcpy(&pc->lfc_a, &pc->fc, sizeof(pc->fc));
else
vpx_memcpy(&pc->lfc, &pc->fc, sizeof(pc->fc));
......
......@@ -165,12 +165,17 @@ vpx_codec_err_t vp9_get_reference_dec(VP9D_PTR ptr, VP9_REFFRAME ref_frame_flag,
VP9_COMMON *cm = &pbi->common;
int ref_fb_idx;
/* TODO(jkoleszar): The decoder doesn't have any real knowledge of what the
* encoder is using the frame buffers for. This is just a stub to keep the
* vpxenc --test-decode functionality working, and will be replaced in a
* later commit that adds VP9-specific controls for this functionality.
*/
if (ref_frame_flag == VP9_LAST_FLAG)
ref_fb_idx = cm->lst_fb_idx;
ref_fb_idx = pbi->common.active_ref_idx[0];
else if (ref_frame_flag == VP9_GOLD_FLAG)
ref_fb_idx = cm->gld_fb_idx;
ref_fb_idx = pbi->common.active_ref_idx[1];
else if (ref_frame_flag == VP9_ALT_FLAG)
ref_fb_idx = cm->alt_fb_idx;
ref_fb_idx = pbi->common.active_ref_idx[2];
else {
vpx_internal_error(&pbi->common.error, VPX_CODEC_ERROR,
"Invalid reference frame");
......@@ -197,12 +202,17 @@ vpx_codec_err_t vp9_set_reference_dec(VP9D_PTR ptr, VP9_REFFRAME ref_frame_flag,
int *ref_fb_ptr = NULL;
int free_fb;
/* TODO(jkoleszar): The decoder doesn't have any real knowledge of what the
* encoder is using the frame buffers for. This is just a stub to keep the
* vpxenc --test-decode functionality working, and will be replaced in a
* later commit that adds VP9-specific controls for this functionality.
*/
if (ref_frame_flag == VP9_LAST_FLAG)
ref_fb_ptr = &cm->lst_fb_idx;
ref_fb_ptr = &pbi->common.active_ref_idx[0];
else if (ref_frame_flag == VP9_GOLD_FLAG)
ref_fb_ptr = &cm->gld_fb_idx;
ref_fb_ptr = &pbi->common.active_ref_idx[1];
else if (ref_frame_flag == VP9_ALT_FLAG)
ref_fb_ptr = &cm->alt_fb_idx;
ref_fb_ptr = &pbi->common.active_ref_idx[2];
else {
vpx_internal_error(&pbi->common.error, VPX_CODEC_ERROR,
"Invalid reference frame");
......@@ -231,29 +241,21 @@ vpx_codec_err_t vp9_set_reference_dec(VP9D_PTR ptr, VP9_REFFRAME ref_frame_flag,
}
/* If any buffer copy / swapping is signalled it should be done here. */
static int swap_frame_buffers(VP9_COMMON *cm) {
int err = 0;
/* The alternate reference frame or golden frame can be updated
* using the new frame.
*/
if (cm->refresh_golden_frame)
ref_cnt_fb(cm->fb_idx_ref_cnt, &cm->gld_fb_idx, cm->new_fb_idx);
if (cm->refresh_alt_ref_frame)
ref_cnt_fb(cm->fb_idx_ref_cnt, &cm->alt_fb_idx, cm->new_fb_idx);
if (cm->refresh_last_frame) {
ref_cnt_fb(cm->fb_idx_ref_cnt, &cm->lst_fb_idx, cm->new_fb_idx);
/* If any buffer updating is signalled it should be done here. */
static void swap_frame_buffers(VP9D_COMP *pbi) {
int ref_index = 0, mask;
cm->frame_to_show = &cm->yv12_fb[cm->lst_fb_idx];
} else
cm->frame_to_show = &cm->yv12_fb[cm->new_fb_idx];
cm->fb_idx_ref_cnt[cm->new_fb_idx]--;
for (mask = pbi->refresh_frame_flags; mask; mask >>= 1) {
if (mask & 1) {
ref_cnt_fb(pbi->common.fb_idx_ref_cnt,
&pbi->common.active_ref_idx[ref_index],
pbi->common.new_fb_idx);
}
++ref_index;
}
return err;
pbi->common.frame_to_show = &pbi->common.yv12_fb[pbi->common.new_fb_idx];
pbi->common.fb_idx_ref_cnt[pbi->common.new_fb_idx]--;
}
int vp9_receive_compressed_data(VP9D_PTR ptr, unsigned long size,
......@@ -281,8 +283,12 @@ int vp9_receive_compressed_data(VP9D_PTR ptr, unsigned long size,
* We do not know if the missing frame(s) was supposed to update
* any of the reference buffers, but we act conservative and
* mark only the last buffer as corrupted.
*
* TODO(jkoleszar): Error concealment is undefined and non-normative
* at this point, but if it becomes so, [0] may not always be the correct
* thing to do here.
*/
cm->yv12_fb[cm->lst_fb_idx].corrupted = 1;
cm->yv12_fb[cm->active_ref_idx[0]].corrupted = 1;
}
cm->new_fb_idx = get_free_fb(cm);
......@@ -293,8 +299,12 @@ int vp9_receive_compressed_data(VP9D_PTR ptr, unsigned long size,
/* We do not know if the missing frame(s) was supposed to update
* any of the reference buffers, but we act conservative and
* mark only the last buffer as corrupted.
*
* TODO(jkoleszar): Error concealment is undefined and non-normative
* at this point, but if it becomes so, [0] may not always be the correct
* thing to do here.
*/
cm->yv12_fb[cm->lst_fb_idx].corrupted = 1;
cm->yv12_fb[cm->active_ref_idx[0]].corrupted = 1;
if (cm->fb_idx_ref_cnt[cm->new_fb_idx] > 0)
cm->fb_idx_ref_cnt[cm->new_fb_idx]--;
......@@ -314,11 +324,7 @@ int vp9_receive_compressed_data(VP9D_PTR ptr, unsigned long size,
}
{
if (swap_frame_buffers(cm)) {
pbi->common.error.error_code = VPX_CODEC_ERROR;
pbi->common.error.setjmp = 0;
return -1;
}
swap_frame_buffers(pbi);
#if WRITE_RECON_BUFFER == 2
if (cm->show_frame)
......
......@@ -76,6 +76,7 @@ typedef struct VP9Decompressor {
vp9_dequant_idct_add_y_block_fn_t idct_add_y_block;
vp9_dequant_idct_add_uv_block_fn_t idct_add_uv_block;
int refresh_frame_flags;
vp9_prob prob_skip_false;
int decoded_key_frame;
......
......@@ -1773,8 +1773,9 @@ void vp9_pack_bitstream(VP9_COMP *cpi, unsigned char *dest,
// When there is a key frame all reference buffers are updated using the new key frame
if (pc->frame_type != KEY_FRAME) {
// Should the GF or ARF be updated using the transmitted frame or buffer
vp9_write_bit(&header_bc, pc->refresh_golden_frame);
vp9_write_bit(&header_bc, pc->refresh_alt_ref_frame);
vp9_write_bit(&header_bc, cpi->refresh_alt_ref_frame);
vp9_write_bit(&header_bc, cpi->refresh_golden_frame);
vp9_write_bit(&header_bc, cpi->refresh_last_frame);
// Indicate reference frame sign bias for Golden and ARF frames (always 0 for last frame buffer)
vp9_write_bit(&header_bc, pc->ref_frame_sign_bias[GOLDEN_FRAME]);
......@@ -1820,9 +1821,6 @@ void vp9_pack_bitstream(VP9_COMP *cpi, unsigned char *dest,
vp9_write_bit(&header_bc, pc->refresh_entropy_probs);
if (pc->frame_type != KEY_FRAME)
vp9_write_bit(&header_bc, pc->refresh_last_frame);
#ifdef ENTROPY_STATS
if (pc->frame_type == INTER_FRAME)
active_section = 0;
......
......@@ -640,7 +640,7 @@ static void set_offsets(VP9_COMP *cpi,
const int src_uv_stride = x->src.uv_stride;
const int src_yoffset = 16 * mb_row * src_y_stride + 16 * mb_col;
const int src_uvoffset = 8 * mb_row * src_uv_stride + 8 * mb_col;
const int ref_fb_idx = cm->lst_fb_idx;
const int ref_fb_idx = cm->active_ref_idx[cpi->lst_fb_idx];
const int ref_y_stride = cm->yv12_fb[ref_fb_idx].y_stride;
const int ref_uv_stride = cm->yv12_fb[ref_fb_idx].uv_stride;
const int idx_map = mb_row * cm->mb_cols + mb_col;
......@@ -1205,7 +1205,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->lst_fb_idx];
xd->pre = cm->yv12_fb[cm->active_ref_idx[cpi->lst_fb_idx]];
xd->dst = cm->yv12_fb[cm->new_fb_idx];
// set up frame for intra coded blocks
......@@ -1526,9 +1526,9 @@ void vp9_encode_frame(VP9_COMP *cpi) {
*/
if (cpi->common.frame_type == KEY_FRAME)
frame_type = 0;
else if (cpi->is_src_frame_alt_ref && cpi->common.refresh_golden_frame)
else if (cpi->is_src_frame_alt_ref && cpi->refresh_golden_frame)
frame_type = 3;
else if (cpi->common.refresh_golden_frame || cpi->common.refresh_alt_ref_frame)
else if (cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame)
frame_type = 1;
else
frame_type = 2;
......@@ -2086,11 +2086,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.lst_fb_idx;
ref_fb_idx = cpi->common.active_ref_idx[cpi->lst_fb_idx];
else if (mbmi->ref_frame == GOLDEN_FRAME)
ref_fb_idx = cpi->common.gld_fb_idx;
ref_fb_idx = cpi->common.active_ref_idx[cpi->gld_fb_idx];
else
ref_fb_idx = cpi->common.alt_fb_idx;
ref_fb_idx = cpi->common.active_ref_idx[cpi->alt_fb_idx];
xd->pre.y_buffer = cpi->common.yv12_fb[ref_fb_idx].y_buffer + recon_yoffset;
xd->pre.u_buffer = cpi->common.yv12_fb[ref_fb_idx].u_buffer + recon_uvoffset;
......@@ -2100,11 +2100,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.lst_fb_idx;
second_ref_fb_idx = cpi->common.active_ref_idx[cpi->lst_fb_idx];
else if (mbmi->second_ref_frame == GOLDEN_FRAME)
second_ref_fb_idx = cpi->common.gld_fb_idx;
second_ref_fb_idx = cpi->common.active_ref_idx[cpi->gld_fb_idx];
else
second_ref_fb_idx = cpi->common.alt_fb_idx;
second_ref_fb_idx = cpi->common.active_ref_idx[cpi->alt_fb_idx];
xd->second_pre.y_buffer = cpi->common.yv12_fb[second_ref_fb_idx].y_buffer +
recon_yoffset;
......@@ -2326,11 +2326,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.lst_fb_idx;
ref_fb_idx = cpi->common.active_ref_idx[cpi->lst_fb_idx];
else if (xd->mode_info_context->mbmi.ref_frame == GOLDEN_FRAME)
ref_fb_idx = cpi->common.gld_fb_idx;
ref_fb_idx = cpi->common.active_ref_idx[cpi->gld_fb_idx];
else
ref_fb_idx = cpi->common.alt_fb_idx;
ref_fb_idx = cpi->common.active_ref_idx[cpi->alt_fb_idx];
xd->pre.y_buffer = cpi->common.yv12_fb[ref_fb_idx].y_buffer + recon_yoffset;
xd->pre.u_buffer = cpi->common.yv12_fb[ref_fb_idx].u_buffer + recon_uvoffset;
......@@ -2340,11 +2340,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.lst_fb_idx;
second_ref_fb_idx = cpi->common.active_ref_idx[cpi->lst_fb_idx];
else if (xd->mode_info_context->mbmi.second_ref_frame == GOLDEN_FRAME)
second_ref_fb_idx = cpi->common.gld_fb_idx;
second_ref_fb_idx = cpi->common.active_ref_idx[cpi->gld_fb_idx];
else
second_ref_fb_idx = cpi->common.alt_fb_idx;
second_ref_fb_idx = cpi->common.active_ref_idx[cpi->alt_fb_idx];
xd->second_pre.y_buffer = cpi->common.yv12_fb[second_ref_fb_idx].y_buffer +
recon_yoffset;
......@@ -2557,11 +2557,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.lst_fb_idx;
ref_fb_idx = cpi->common.active_ref_idx[cpi->lst_fb_idx];
else if (xd->mode_info_context->mbmi.ref_frame == GOLDEN_FRAME)
ref_fb_idx = cpi->common.gld_fb_idx;
ref_fb_idx = cpi->common.active_ref_idx[cpi->gld_fb_idx];
else
ref_fb_idx = cpi->common.alt_fb_idx;
ref_fb_idx = cpi->common.active_ref_idx[cpi->alt_fb_idx];
xd->pre.y_buffer =
cpi->common.yv12_fb[ref_fb_idx].y_buffer + recon_yoffset;
......@@ -2574,11 +2574,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.lst_fb_idx;
second_ref_fb_idx = cpi->common.active_ref_idx[cpi->lst_fb_idx];
else if (xd->mode_info_context->mbmi.second_ref_frame == GOLDEN_FRAME)
second_ref_fb_idx = cpi->common.gld_fb_idx;
second_ref_fb_idx = cpi->common.active_ref_idx[cpi->gld_fb_idx];
else
second_ref_fb_idx = cpi->common.alt_fb_idx;
second_ref_fb_idx = cpi->common.active_ref_idx[cpi->alt_fb_idx];
xd->second_pre.y_buffer =
cpi->common.yv12_fb[second_ref_fb_idx].y_buffer + recon_yoffset;
......
......@@ -435,9 +435,11 @@ void vp9_first_pass(VP9_COMP *cpi) {
MACROBLOCKD *const xd = &x->e_mbd;
int recon_yoffset, recon_uvoffset;
YV12_BUFFER_CONFIG *lst_yv12 = &cm->yv12_fb[cm->lst_fb_idx];
YV12_BUFFER_CONFIG *lst_yv12 =
&cm->yv12_fb[cm->active_ref_idx[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->gld_fb_idx];
YV12_BUFFER_CONFIG *gld_yv12 =
&cm->yv12_fb[cm->active_ref_idx[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;
......
......@@ -433,7 +433,8 @@ 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->gld_fb_idx];
YV12_BUFFER_CONFIG *golden_ref =
&cm->yv12_fb[cm->active_ref_idx[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
......
This diff is collapsed.
......@@ -357,7 +357,12 @@ typedef struct VP9_COMP {
int alt_is_last; // Alt reference frame same as last ( short circuit altref search)
int gold_is_alt; // don't do both alt and gold search ( just do gold).
// int refresh_alt_ref_frame;
int lst_fb_idx;
int gld_fb_idx;
int alt_fb_idx;
int refresh_last_frame;
int refresh_golden_frame;
int refresh_alt_ref_frame;
YV12_BUFFER_CONFIG last_frame_uf;
TOKENEXTRA *tok;
......
......@@ -258,8 +258,8 @@ void vp9_setup_key_frame(VP9_COMP *cpi) {
// interval before next GF
cpi->frames_till_gf_update_due = cpi->baseline_gf_interval;
cpi->common.refresh_golden_frame = TRUE;
cpi->common.refresh_alt_ref_frame = TRUE;
cpi->refresh_golden_frame = TRUE;
cpi->refresh_alt_ref_frame = TRUE;
vp9_init_mode_contexts(&cpi->common);
vpx_memcpy(&cpi->common.lfc, &cpi->common.fc, sizeof(cpi->common.fc));
......@@ -285,7 +285,7 @@ void vp9_setup_key_frame(VP9_COMP *cpi) {
}
void vp9_setup_inter_frame(VP9_COMP *cpi) {
if (cpi->common.refresh_alt_ref_frame) {
if (cpi->refresh_alt_ref_frame) {
vpx_memcpy(&cpi->common.fc,
&cpi->common.lfc_a,
sizeof(cpi->common.fc));
......@@ -358,7 +358,7 @@ static void calc_pframe_target_size(VP9_COMP *cpi) {
// Special alt reference frame case
if (cpi->common.refresh_alt_ref_frame) {
if (cpi->refresh_alt_ref_frame) {
// Per frame bit target for the alt ref frame
cpi->per_frame_bandwidth = cpi->twopass.gf_bits;
cpi->this_frame_target = cpi->per_frame_bandwidth;
......@@ -377,7 +377,7 @@ static void calc_pframe_target_size(VP9_COMP *cpi) {
if (cpi->this_frame_target < min_frame_target)
cpi->this_frame_target = min_frame_target;
if (!cpi->common.refresh_alt_ref_frame)
if (!cpi->refresh_alt_ref_frame)
// Note the baseline target data rate for this inter frame.
cpi->inter_frame_target = cpi->this_frame_target;
......@@ -386,7 +386,7 @@ static void calc_pframe_target_size(VP9_COMP *cpi) {
// int Boost = 0;
int Q = (cpi->oxcf.fixed_q < 0) ? cpi->last_q[INTER_FRAME] : cpi->oxcf.fixed_q;
cpi->common.refresh_golden_frame = TRUE;
cpi->refresh_golden_frame = TRUE;
calc_gf_params(cpi);
......@@ -431,7 +431,7 @@ void vp9_update_rate_correction_factors(VP9_COMP *cpi, int damp_var) {
if (cpi->common.frame_type == KEY_FRAME) {
rate_correction_factor = cpi->key_frame_rate_correction_factor;
} else {
if (cpi->common.refresh_alt_ref_frame || cpi->common.refresh_golden_frame)
if (cpi->refresh_alt_ref_frame || cpi->refresh_golden_frame)
rate_correction_factor = cpi->gf_rate_correction_factor;
else
rate_correction_factor = cpi->rate_correction_factor;
......@@ -505,7 +505,7 @@ void vp9_update_rate_correction_factors(VP9_COMP *cpi, int damp_var) {
if (cpi->common.frame_type == KEY_FRAME)
cpi->key_frame_rate_correction_factor = rate_correction_factor;
else {
if (cpi->common.refresh_alt_ref_frame || cpi->common.refresh_golden_frame)
if (cpi->refresh_alt_ref_frame || cpi->refresh_golden_frame)
cpi->gf_rate_correction_factor = rate_correction_factor;
else
cpi->rate_correction_factor = rate_correction_factor;
......@@ -529,7 +529,7 @@ int vp9_regulate_q(VP9_COMP *cpi, int target_bits_per_frame) {
if (cpi->common.frame_type == KEY_FRAME)
correction_factor = cpi->key_frame_rate_correction_factor;
else {
if (cpi->common.refresh_alt_ref_frame || cpi->common.refresh_golden_frame)
if (cpi->refresh_alt_ref_frame || cpi->refresh_golden_frame)
correction_factor = cpi->gf_rate_correction_factor;
else
correction_factor = cpi->rate_correction_factor;
......@@ -570,7 +570,8 @@ int vp9_regulate_q(VP9_COMP *cpi, int target_bits_per_frame) {
if (cpi->common.frame_type == KEY_FRAME)
zbin_oqmax = 0; // ZBIN_OQ_MAX/16
else if (cpi->common.refresh_alt_ref_frame || (cpi->common.refresh_golden_frame && !cpi->source_alt_ref_active))
else if (cpi->refresh_alt_ref_frame
|| (cpi->refresh_golden_frame && !cpi->source_alt_ref_active))
zbin_oqmax = 16;
else
zbin_oqmax = ZBIN_OQ_MAX;
......@@ -671,7 +672,7 @@ void vp9_compute_frame_size_bounds(VP9_COMP *cpi, int *frame_under_shoot_limit,
*frame_over_shoot_limit = cpi->this_frame_target * 9 / 8;
*frame_under_shoot_limit = cpi->this_frame_target * 7 / 8;
} else {
if (cpi->common.refresh_alt_ref_frame || cpi->common.refresh_golden_frame) {
if (cpi->refresh_alt_ref_frame || cpi->refresh_golden_frame) {
*frame_over_shoot_limit = cpi->this_frame_target * 9 / 8;
*frame_under_shoot_limit = cpi->this_frame_target * 7 / 8;
} else {
......
......@@ -3592,22 +3592,22 @@ static void rd_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
}
if (cpi->ref_frame_flags & VP9_LAST_FLAG) {
setup_buffer_inter(cpi, x, cpi->common.lst_fb_idx, LAST_FRAME,
BLOCK_16X16, recon_yoffset, recon_uvoffset,
setup_buffer_inter(cpi, x, cpi->common.active_ref_idx[cpi->lst_fb_idx],
LAST_FRAME, BLOCK_16X16, recon_yoffset, recon_uvoffset,
frame_mv[NEARESTMV], frame_mv[NEARMV],
frame_mdcounts, y_buffer, u_buffer, v_buffer);
}
if (cpi->ref_frame_flags & VP9_GOLD_FLAG) {
setup_buffer_inter(cpi, x, cpi->common.gld_fb_idx, GOLDEN_FRAME,
BLOCK_16X16, recon_yoffset, recon_uvoffset,
setup_buffer_inter(cpi, x, cpi->common.active_ref_idx[cpi->gld_fb_idx],
GOLDEN_FRAME, BLOCK_16X16, recon_yoffset, recon_uvoffset,
frame_mv[NEARESTMV], frame_mv[NEARMV],
frame_mdcounts, y_buffer, u_buffer, v_buffer);
}
if (cpi->ref_frame_flags & VP9_ALT_FLAG) {
setup_buffer_inter(cpi, x, cpi->common.alt_fb_idx, ALTREF_FRAME,
BLOCK_16X16, recon_yoffset, recon_uvoffset,
setup_buffer_inter(cpi, x, cpi->common.active_ref_idx[cpi->alt_fb_idx],
ALTREF_FRAME, BLOCK_16X16, recon_yoffset, recon_uvoffset,
frame_mv[NEARESTMV], frame_mv[NEARMV],
frame_mdcounts, y_buffer, u_buffer, v_buffer);
}
......@@ -4476,8 +4476,10 @@ static int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
uint8_t *v_buffer[4];
static const int flag_list[4] = { 0, VP9_LAST_FLAG, VP9_GOLD_FLAG,
VP9_ALT_FLAG };
int idx_list[4] = { 0, cpi->common.lst_fb_idx, cpi->common.gld_fb_idx,
cpi->common.alt_fb_idx };
int idx_list[4] = {0,
cpi->common.active_ref_idx[cpi->lst_fb_idx],
cpi->common.active_ref_idx[cpi->gld_fb_idx],
cpi->common.active_ref_idx[cpi->alt_fb_idx]};
int mdcounts[4];
int near_sadidx[8] = { 0, 1, 2, 3, 4, 5, 6, 7 };
int saddone = 0;
......
......@@ -21,7 +21,7 @@ void vp9_update_gf_useage_maps(VP9_COMP *cpi, VP9_COMMON *cm, MACROBLOCK *x) {
x->gf_active_ptr = (signed char *)cpi->gf_active_flags;
if ((cm->frame_type == KEY_FRAME) || (cm->refresh_golden_frame)) {
if ((cm->frame_type == KEY_FRAME) || (cpi->refresh_golden_frame)) {
// Reset Gf useage monitors
vpx_memset(cpi->gf_active_flags, 1, (cm->mb_rows * cm->mb_cols));
cpi->gf_active_count = cm->mb_rows * cm->mb_cols;
......
......@@ -645,9 +645,7 @@ static vpx_codec_err_t vp8_get_last_ref_updates(vpx_codec_alg_priv_t *ctx,
VP9D_COMP *pbi = (VP9D_COMP *)ctx->pbi;
if (update_info) {
*update_info = pbi->common.refresh_alt_ref_frame * (int) VP8_ALTR_FRAME
+ pbi->common.refresh_golden_frame * (int) VP8_GOLD_FRAME
+ pbi->common.refresh_last_frame * (int) VP8_LAST_FRAME;
*update_info = pbi->refresh_frame_flags;
return VPX_CODEC_OK;
} else
......
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