Commit 5ebd8704 authored by Hui Su's avatar Hui Su

Add an identity scale factor in AV1_COMMON

Set up the identity scale factor once per frame, instead of per joint
motion search.

Change-Id: I5edd264655254f4b6a0a923d8ab43adbca044228
parent ab3a7706
......@@ -591,11 +591,6 @@ 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];
......
......@@ -248,6 +248,9 @@ typedef struct AV1Common {
int subsampling_y;
int largest_tile_id;
// Scale of the current frame with respect to itself.
struct scale_factors sf_identity;
// Marks if we need to use 16bit frame buffers (1: yes, 0: no).
int use_highbitdepth;
YV12_BUFFER_CONFIG *frame_to_show;
......
......@@ -1019,7 +1019,7 @@ static INLINE void build_inter_predictors(const AV1_COMMON *cm, MACROBLOCKD *xd,
#if CONFIG_INTRABC
const struct scale_factors *const sf =
is_intrabc ? &xd->sf_identity : &ref_buf->sf;
is_intrabc ? &cm->sf_identity : &ref_buf->sf;
struct buf_2d *const pre_buf = is_intrabc ? dst_buf : &pd->pre[ref];
#else
const struct scale_factors *const sf = &ref_buf->sf;
......@@ -1127,7 +1127,7 @@ static INLINE void build_inter_predictors(const AV1_COMMON *cm, MACROBLOCKD *xd,
for (ref = 0; ref < 1 + is_compound; ++ref) {
#if CONFIG_INTRABC
const struct scale_factors *const sf =
is_intrabc ? &xd->sf_identity : &xd->block_refs[ref]->sf;
is_intrabc ? &cm->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;
......@@ -1198,7 +1198,7 @@ static INLINE void build_inter_predictors(const AV1_COMMON *cm, MACROBLOCKD *xd,
for (ref = 0; ref < 1 + is_compound; ++ref) {
#if CONFIG_INTRABC
const struct scale_factors *const sf =
is_intrabc ? &xd->sf_identity : &xd->block_refs[ref]->sf;
is_intrabc ? &cm->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;
......
......@@ -3291,10 +3291,12 @@ size_t av1_decode_frame_headers_and_setup(AV1Decoder *pbi, const uint8_t *data,
YV12_BUFFER_CONFIG *new_fb = get_frame_new_buffer(cm);
xd->cur_buf = new_fb;
#if CONFIG_INTRABC
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);
if (frame_is_intra_only(cm) && av1_allow_intrabc(cm)) {
av1_setup_scale_factors_for_frame(
&cm->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);
}
#endif // CONFIG_INTRABC
if (cm->show_existing_frame) {
......
......@@ -4967,11 +4967,9 @@ static void set_frame_size(AV1_COMP *cpi, int width, int height) {
}
}
#if CONFIG_INTRABC
av1_setup_scale_factors_for_frame(&xd->sf_identity, cm->width, cm->height,
av1_setup_scale_factors_for_frame(&cm->sf_identity, cm->width, cm->height,
cm->width, cm->height,
cm->use_highbitdepth);
#endif // CONFIG_INTRABC
set_ref_ptrs(cm, xd, LAST_FRAME, LAST_FRAME);
}
......
......@@ -5597,7 +5597,6 @@ static void joint_motion_search(const AV1_COMP *cpi, MACROBLOCK *x,
const int refs[2] = { mbmi->ref_frame[0], mbmi->ref_frame[1] };
int_mv ref_mv[2];
int ite, ref;
struct scale_factors sf;
// ic and ir are the 4x4 coordinates of the sub8x8 at index "block"
const int ic = block & 1;
const int ir = (block - ic) >> 1;
......@@ -5639,16 +5638,12 @@ static void joint_motion_search(const AV1_COMP *cpi, MACROBLOCK *x,
}
}
// Since we have scaled the reference frames to match the size of the current
// frame we must use a unit scaling factor during mode selection.
assert(IMPLIES(scaled_ref_frame[0] != NULL,
cm->width == scaled_ref_frame[0]->y_crop_width &&
cm->height == scaled_ref_frame[0]->y_crop_height));
assert(IMPLIES(scaled_ref_frame[1] != NULL,
cm->width == scaled_ref_frame[1]->y_crop_width &&
cm->height == scaled_ref_frame[1]->y_crop_height));
av1_setup_scale_factors_for_frame(&sf, cm->width, cm->height, cm->width,
cm->height, cm->use_highbitdepth);
// Allow joint search multiple times iteratively for each reference frame
// and break out of the search loop if it couldn't find a better mv.
......@@ -5681,30 +5676,32 @@ static void joint_motion_search(const AV1_COMP *cpi, MACROBLOCK *x,
InterpFilters interp_filters = EIGHTTAP_REGULAR;
#endif // CONFIG_JNT_COMP
// Since we have scaled the reference frames to match the size of the
// current frame we must use a unit scaling factor during mode selection.
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
second_pred = CONVERT_TO_BYTEPTR(second_pred_alloc_16);
av1_highbd_build_inter_predictor(
ref_yv12[!id].buf, ref_yv12[!id].stride, second_pred, pw,
&frame_mv[refs[!id]].as_mv,
#if CONFIG_JNT_COMP
&sf, pw, ph, 0, interp_filters,
&cm->sf_identity, pw, ph, 0, interp_filters,
#else
&sf, pw, ph, 0, mbmi->interp_filters,
&cm->sf_identity, pw, ph, 0, mbmi->interp_filters,
#endif // CONFIG_JNT_COMP
&warp_types, p_col, p_row, plane, MV_PRECISION_Q3, mi_col * MI_SIZE,
mi_row * MI_SIZE, xd);
} else {
second_pred = (uint8_t *)second_pred_alloc_16;
av1_build_inter_predictor(ref_yv12[!id].buf, ref_yv12[!id].stride,
second_pred, pw, &frame_mv[refs[!id]].as_mv,
av1_build_inter_predictor(
ref_yv12[!id].buf, ref_yv12[!id].stride, second_pred, pw,
&frame_mv[refs[!id]].as_mv,
#if CONFIG_JNT_COMP
&sf, pw, ph, &conv_params, interp_filters,
&cm->sf_identity, pw, ph, &conv_params, interp_filters,
#else
&sf, pw, ph, &conv_params, mbmi->interp_filters,
&cm->sf_identity, pw, ph, &conv_params, mbmi->interp_filters,
#endif // CONFIG_JNT_COMP
&warp_types, p_col, p_row, plane, !id,
MV_PRECISION_Q3, mi_col * MI_SIZE,
mi_row * MI_SIZE, xd);
&warp_types, p_col, p_row, plane, !id, MV_PRECISION_Q3,
mi_col * MI_SIZE, mi_row * MI_SIZE, xd);
}
#if CONFIG_JNT_COMP
......
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