Handling frame references and scale factors in one for loop.
Using ALLOWED_REFS_PER_FRAME constants instead of hard coded 3, replacing memcpy with plain struct assignment. Change-Id: Ibc86f5d175fcb3f3a3eddacf593525370f1f854c
This commit is contained in:
parent
ff2b8aa2c9
commit
994c79cccf
@ -181,12 +181,14 @@ typedef struct VP9Common {
|
|||||||
int fb_idx_ref_cnt[NUM_YV12_BUFFERS]; /* reference counts */
|
int fb_idx_ref_cnt[NUM_YV12_BUFFERS]; /* reference counts */
|
||||||
int ref_frame_map[NUM_REF_FRAMES]; /* maps fb_idx to reference slot */
|
int ref_frame_map[NUM_REF_FRAMES]; /* maps fb_idx to reference slot */
|
||||||
|
|
||||||
/* TODO(jkoleszar): could expand active_ref_idx to 4, with 0 as intra, and
|
// TODO(jkoleszar): could expand active_ref_idx to 4, with 0 as intra, and
|
||||||
* roll new_fb_idx into it.
|
// roll new_fb_idx into it.
|
||||||
*/
|
|
||||||
int active_ref_idx[3]; /* each frame can reference 3 buffers */
|
// Each frame can reference ALLOWED_REFS_PER_FRAME buffers
|
||||||
|
int active_ref_idx[ALLOWED_REFS_PER_FRAME];
|
||||||
|
struct scale_factors active_ref_scale[ALLOWED_REFS_PER_FRAME];
|
||||||
int new_fb_idx;
|
int new_fb_idx;
|
||||||
struct scale_factors active_ref_scale[3];
|
|
||||||
|
|
||||||
YV12_BUFFER_CONFIG post_proc_buffer;
|
YV12_BUFFER_CONFIG post_proc_buffer;
|
||||||
YV12_BUFFER_CONFIG temp_scale_frame;
|
YV12_BUFFER_CONFIG temp_scale_frame;
|
||||||
|
@ -1517,10 +1517,18 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
|
|||||||
// Should the GF or ARF be updated from the current frame
|
// Should the GF or ARF be updated from the current frame
|
||||||
pbi->refresh_frame_flags = vp9_read_literal(&header_bc, NUM_REF_FRAMES);
|
pbi->refresh_frame_flags = vp9_read_literal(&header_bc, NUM_REF_FRAMES);
|
||||||
|
|
||||||
// Select active reference frames
|
// Select active reference frames and calculate scaling factors
|
||||||
for (i = 0; i < ALLOWED_REFS_PER_FRAME; ++i) {
|
for (i = 0; i < ALLOWED_REFS_PER_FRAME; ++i) {
|
||||||
int ref_frame_num = vp9_read_literal(&header_bc, NUM_REF_FRAMES_LG2);
|
const int ref = vp9_read_literal(&header_bc, NUM_REF_FRAMES_LG2);
|
||||||
pc->active_ref_idx[i] = pc->ref_frame_map[ref_frame_num];
|
const int mapped_ref = pc->ref_frame_map[ref];
|
||||||
|
YV12_BUFFER_CONFIG *const fb = &pc->yv12_fb[mapped_ref];
|
||||||
|
struct scale_factors *const sf = &pc->active_ref_scale[i];
|
||||||
|
|
||||||
|
pc->active_ref_idx[i] = mapped_ref;
|
||||||
|
if (mapped_ref >= NUM_YV12_BUFFERS)
|
||||||
|
memset(sf, 0, sizeof(*sf));
|
||||||
|
else
|
||||||
|
vp9_setup_scale_factors_for_frame(sf, fb, pc->width, pc->height);
|
||||||
}
|
}
|
||||||
|
|
||||||
pc->ref_frame_sign_bias[GOLDEN_FRAME] = vp9_read_bit(&header_bc);
|
pc->ref_frame_sign_bias[GOLDEN_FRAME] = vp9_read_bit(&header_bc);
|
||||||
@ -1532,17 +1540,6 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
|
|||||||
pc->use_interintra = vp9_read_bit(&header_bc);
|
pc->use_interintra = vp9_read_bit(&header_bc);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Calculate scaling factors for each of the 3 available references
|
|
||||||
for (i = 0; i < ALLOWED_REFS_PER_FRAME; ++i) {
|
|
||||||
const int idx = pc->active_ref_idx[i];
|
|
||||||
struct scale_factors *sf = &pc->active_ref_scale[i];
|
|
||||||
if (idx >= NUM_YV12_BUFFERS)
|
|
||||||
memset(sf, 0, sizeof(*sf));
|
|
||||||
else
|
|
||||||
vp9_setup_scale_factors_for_frame(sf, &pc->yv12_fb[idx],
|
|
||||||
pc->width, pc->height);
|
|
||||||
}
|
|
||||||
|
|
||||||
// To enable choice of different interpolation filters
|
// To enable choice of different interpolation filters
|
||||||
vp9_setup_interp_filters(xd, pc->mcomp_filter_type, pc);
|
vp9_setup_interp_filters(xd, pc->mcomp_filter_type, pc);
|
||||||
}
|
}
|
||||||
@ -1556,8 +1553,7 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pc->frame_context_idx = vp9_read_literal(&header_bc, NUM_FRAME_CONTEXTS_LG2);
|
pc->frame_context_idx = vp9_read_literal(&header_bc, NUM_FRAME_CONTEXTS_LG2);
|
||||||
vpx_memcpy(&pc->fc, &pc->frame_contexts[pc->frame_context_idx],
|
pc->fc = pc->frame_contexts[pc->frame_context_idx];
|
||||||
sizeof(pc->fc));
|
|
||||||
|
|
||||||
setup_segmentation(pc, xd, &header_bc);
|
setup_segmentation(pc, xd, &header_bc);
|
||||||
|
|
||||||
@ -1645,10 +1641,8 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (pc->refresh_entropy_probs) {
|
if (pc->refresh_entropy_probs)
|
||||||
vpx_memcpy(&pc->frame_contexts[pc->frame_context_idx], &pc->fc,
|
pc->frame_contexts[pc->frame_context_idx] = pc->fc;
|
||||||
sizeof(pc->fc));
|
|
||||||
}
|
|
||||||
|
|
||||||
*p_data_end = vp9_reader_find_end(&residual_bc);
|
*p_data_end = vp9_reader_find_end(&residual_bc);
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user