Commit e816b31a authored by Alex Converse's avatar Alex Converse
Browse files

intrabc: Call setup intrabc scale factors once per frame

Reduces av1_setup_scale_factors_for_frame profile from 1.85% to noise.

Change-Id: I6a7ad892824aac537992eb9109210b0a839136e9
parent 0e58be02
......@@ -606,6 +606,11 @@ typedef struct macroblockd {
/* pointer to current frame */
const YV12_BUFFER_CONFIG *cur_buf;
#if CONFIG_INTRABC
/* Scale of the current frame with respect to itself */
struct scale_factors sf_identity;
#endif
ENTROPY_CONTEXT *above_context[MAX_MB_PLANE];
ENTROPY_CONTEXT left_context[MAX_MB_PLANE][2 * MAX_MIB_SIZE];
......
......@@ -903,14 +903,6 @@ void build_inter_predictors(MACROBLOCKD *xd, int plane,
int ref;
#if CONFIG_INTRABC
const int is_intrabc = is_intrabc_block(&mi->mbmi);
struct scale_factors sf_identity;
#if CONFIG_HIGHBITDEPTH
av1_setup_scale_factors_for_frame(
&sf_identity, 64, 64, 64, 64,
xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH);
#else
av1_setup_scale_factors_for_frame(&sf_identity, 64, 64, 64, 64);
#endif // CONFIG_HIGHBITDEPTH
assert(IMPLIES(is_intrabc, !is_compound));
#endif // CONFIG_INTRABC
#if CONFIG_GLOBAL_MOTION
......@@ -956,7 +948,7 @@ void build_inter_predictors(MACROBLOCKD *xd, int plane,
struct buf_2d *const dst_buf = &pd->dst;
#if CONFIG_INTRABC
const struct scale_factors *const sf =
is_intrabc ? &sf_identity : &xd->block_refs[ref]->sf;
is_intrabc ? &xd->sf_identity : &xd->block_refs[ref]->sf;
struct buf_2d *const pre_buf = is_intrabc ? dst_buf : &pd->pre[ref];
#else
const struct scale_factors *const sf = &xd->block_refs[ref]->sf;
......@@ -1052,7 +1044,7 @@ void build_inter_predictors(MACROBLOCKD *xd, int plane,
for (ref = 0; ref < 1 + is_compound; ++ref) {
#if CONFIG_INTRABC
const struct scale_factors *const sf =
is_intrabc ? &sf_identity : &xd->block_refs[ref]->sf;
is_intrabc ? &xd->sf_identity : &xd->block_refs[ref]->sf;
struct buf_2d *const pre_buf = is_intrabc ? dst_buf : &pd->pre[ref];
#else
const struct scale_factors *const sf = &xd->block_refs[ref]->sf;
......@@ -1110,7 +1102,7 @@ void build_inter_predictors(MACROBLOCKD *xd, int plane,
for (ref = 0; ref < 1 + is_compound; ++ref) {
#if CONFIG_INTRABC
const struct scale_factors *const sf =
is_intrabc ? &sf_identity : &xd->block_refs[ref]->sf;
is_intrabc ? &xd->sf_identity : &xd->block_refs[ref]->sf;
struct buf_2d *const pre_buf = is_intrabc ? dst_buf : &pd->pre[ref];
#else
const struct scale_factors *const sf = &xd->block_refs[ref]->sf;
......
......@@ -4958,6 +4958,18 @@ void av1_decode_frame(AV1Decoder *pbi, const uint8_t *data,
#endif
new_fb = get_frame_new_buffer(cm);
xd->cur_buf = new_fb;
#if CONFIG_INTRABC
#if CONFIG_HIGHBITDEPTH
av1_setup_scale_factors_for_frame(
&xd->sf_identity, xd->cur_buf->y_crop_width, xd->cur_buf->y_crop_height,
xd->cur_buf->y_crop_width, xd->cur_buf->y_crop_height,
cm->use_highbitdepth);
#else
av1_setup_scale_factors_for_frame(
&xd->sf_identity, xd->cur_buf->y_crop_width, xd->cur_buf->y_crop_height,
xd->cur_buf->y_crop_width, xd->cur_buf->y_crop_height);
#endif // CONFIG_HIGHBITDEPTH
#endif // CONFIG_INTRABC
#if CONFIG_GLOBAL_MOTION
int i;
for (i = LAST_FRAME; i <= ALTREF_FRAME; ++i) {
......
......@@ -4012,6 +4012,16 @@ static void set_frame_size(AV1_COMP *cpi) {
ref_buf->buf = NULL;
}
}
#if CONFIG_INTRABC
#if CONFIG_HIGHBITDEPTH
av1_setup_scale_factors_for_frame(
&xd->sf_identity, cm->width, cm->height, cm->width, cm->height,
(buf->flags & YV12_FLAG_HIGHBITDEPTH) ? 1 : 0);
#else
av1_setup_scale_factors_for_frame(&xd->sf_identity, cm->width, cm->height,
cm->width, cm->height);
#endif // CONFIG_HIGHBITDEPTH
#endif // CONFIG_INTRABC
set_ref_ptrs(cm, xd, LAST_FRAME, LAST_FRAME);
}
......
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