Commit b54eacee authored by Angie Chiang's avatar Angie Chiang

Change interface of inter_predictor

This is for facilatating ext_interp experiment

Change-Id: I22aebfd4a80c7033c38f00b7c71e33a13450633a
parent 400c606a
......@@ -13,8 +13,8 @@
#include "av1/common/filter.h"
DECLARE_ALIGNED(256, static const InterpKernel,
bilinear_filters[SUBPEL_SHIFTS]) = {
DECLARE_ALIGNED(256, static const int16_t,
bilinear_filters[SUBPEL_SHIFTS][8]) = {
{ 0, 0, 0, 128, 0, 0, 0, 0 }, { 0, 0, 0, 120, 8, 0, 0, 0 },
{ 0, 0, 0, 112, 16, 0, 0, 0 }, { 0, 0, 0, 104, 24, 0, 0, 0 },
{ 0, 0, 0, 96, 32, 0, 0, 0 }, { 0, 0, 0, 88, 40, 0, 0, 0 },
......@@ -26,8 +26,8 @@ DECLARE_ALIGNED(256, static const InterpKernel,
};
// Lagrangian interpolation filter
DECLARE_ALIGNED(256, static const InterpKernel,
sub_pel_filters_8[SUBPEL_SHIFTS]) = {
DECLARE_ALIGNED(256, static const int16_t,
sub_pel_filters_8[SUBPEL_SHIFTS][8]) = {
{ 0, 0, 0, 128, 0, 0, 0, 0 }, { 0, 1, -5, 126, 8, -3, 1, 0 },
{ -1, 3, -10, 122, 18, -6, 2, 0 }, { -1, 4, -13, 118, 27, -9, 3, -1 },
{ -1, 4, -16, 112, 37, -11, 4, -1 }, { -1, 5, -18, 105, 48, -14, 4, -1 },
......@@ -39,8 +39,8 @@ DECLARE_ALIGNED(256, static const InterpKernel,
};
// DCT based filter
DECLARE_ALIGNED(256, static const InterpKernel,
sub_pel_filters_8s[SUBPEL_SHIFTS]) = {
DECLARE_ALIGNED(256, static const int16_t,
sub_pel_filters_8sharp[SUBPEL_SHIFTS][8]) = {
{ 0, 0, 0, 128, 0, 0, 0, 0 }, { -1, 3, -7, 127, 8, -3, 1, 0 },
{ -2, 5, -13, 125, 17, -6, 3, -1 }, { -3, 7, -17, 121, 27, -10, 5, -2 },
{ -4, 9, -20, 115, 37, -13, 6, -2 }, { -4, 10, -23, 108, 48, -16, 8, -3 },
......@@ -52,8 +52,8 @@ DECLARE_ALIGNED(256, static const InterpKernel,
};
// freqmultiplier = 0.5
DECLARE_ALIGNED(256, static const InterpKernel,
sub_pel_filters_8lp[SUBPEL_SHIFTS]) = {
DECLARE_ALIGNED(256, static const int16_t,
sub_pel_filters_8smooth[SUBPEL_SHIFTS][8]) = {
{ 0, 0, 0, 128, 0, 0, 0, 0 }, { -3, -1, 32, 64, 38, 1, -3, 0 },
{ -2, -2, 29, 63, 41, 2, -3, 0 }, { -2, -2, 26, 63, 43, 4, -4, 0 },
{ -2, -3, 24, 62, 46, 5, -4, 0 }, { -2, -3, 21, 60, 49, 7, -4, 0 },
......@@ -64,6 +64,18 @@ DECLARE_ALIGNED(256, static const InterpKernel,
{ 0, -3, 2, 41, 63, 29, -2, -2 }, { 0, -3, 1, 38, 64, 32, -1, -3 }
};
const InterpKernel *av1_filter_kernels[4] = {
sub_pel_filters_8, sub_pel_filters_8lp, sub_pel_filters_8s, bilinear_filters
};
const InterpKernel *av1_filter_kernels[4] = { sub_pel_filters_8,
sub_pel_filters_8smooth,
sub_pel_filters_8sharp,
bilinear_filters };
static const InterpFilterParams
interp_filter_params_list[SWITCHABLE_FILTERS + 1] = {
{ (const int16_t *)sub_pel_filters_8, SUBPEL_TAPS, SUBPEL_SHIFTS },
{ (const int16_t *)sub_pel_filters_8smooth, SUBPEL_TAPS, SUBPEL_SHIFTS },
{ (const int16_t *)sub_pel_filters_8sharp, SUBPEL_TAPS, SUBPEL_SHIFTS },
{ (const int16_t *)bilinear_filters, SUBPEL_TAPS, SUBPEL_SHIFTS }
};
InterpFilterParams get_interp_filter_params(InterpFilter interp_filter) {
return interp_filter_params_list[interp_filter];
}
......@@ -33,7 +33,18 @@ extern "C" {
typedef uint8_t InterpFilter;
extern const InterpKernel *av1_filter_kernels[4];
extern const InterpKernel* av1_filter_kernels[4];
typedef struct InterpFilterParams {
const int16_t* filter_ptr;
uint16_t taps;
uint16_t subpel_shifts;
} InterpFilterParams;
static INLINE const int16_t* get_interp_filter_subpel_kernel(
const InterpFilterParams filter_params, const int subpel) {
return filter_params.filter_ptr + filter_params.taps * subpel;
}
InterpFilterParams get_interp_filter_params(InterpFilter interp_filter);
#ifdef __cplusplus
} // extern "C"
......
......@@ -24,8 +24,8 @@
void av1_highbd_build_inter_predictor(
const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride,
const MV *src_mv, const struct scale_factors *sf, int w, int h, int ref,
const InterpKernel *kernel, enum mv_precision precision, int x, int y,
int bd) {
const InterpFilter *interp_filter, enum mv_precision precision, int x,
int y, int bd) {
const int is_q4 = precision == MV_PRECISION_Q4;
const MV mv_q4 = { is_q4 ? src_mv->row : src_mv->row * 2,
is_q4 ? src_mv->col : src_mv->col * 2 };
......@@ -36,14 +36,15 @@ void av1_highbd_build_inter_predictor(
src += (mv.row >> SUBPEL_BITS) * src_stride + (mv.col >> SUBPEL_BITS);
high_inter_predictor(src, src_stride, dst, dst_stride, subpel_x, subpel_y, sf,
w, h, ref, kernel, sf->x_step_q4, sf->y_step_q4, bd);
w, h, ref, interp_filter, sf->x_step_q4, sf->y_step_q4,
bd);
}
#endif // CONFIG_AOM_HIGHBITDEPTH
void av1_build_inter_predictor(const uint8_t *src, int src_stride, uint8_t *dst,
int dst_stride, const MV *src_mv,
const struct scale_factors *sf, int w, int h,
int ref, const InterpKernel *kernel,
int ref, const InterpFilter *interp_filter,
enum mv_precision precision, int x, int y) {
const int is_q4 = precision == MV_PRECISION_Q4;
const MV mv_q4 = { is_q4 ? src_mv->row : src_mv->row * 2,
......@@ -55,7 +56,7 @@ void av1_build_inter_predictor(const uint8_t *src, int src_stride, uint8_t *dst,
src += (mv.row >> SUBPEL_BITS) * src_stride + (mv.col >> SUBPEL_BITS);
inter_predictor(src, src_stride, dst, dst_stride, subpel_x, subpel_y, sf, w,
h, ref, kernel, sf->x_step_q4, sf->y_step_q4);
h, ref, interp_filter, sf->x_step_q4, sf->y_step_q4);
}
void build_inter_predictors(MACROBLOCKD *xd, int plane, int block, int bw,
......@@ -64,7 +65,6 @@ void build_inter_predictors(MACROBLOCKD *xd, int plane, int block, int bw,
struct macroblockd_plane *const pd = &xd->plane[plane];
const MODE_INFO *mi = xd->mi[0];
const int is_compound = has_second_ref(&mi->mbmi);
const InterpKernel *kernel = av1_filter_kernels[mi->mbmi.interp_filter];
int ref;
for (ref = 0; ref < 1 + is_compound; ++ref) {
......@@ -108,14 +108,15 @@ void build_inter_predictors(MACROBLOCKD *xd, int plane, int block, int bw,
#if CONFIG_AOM_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
high_inter_predictor(pre, pre_buf->stride, dst, dst_buf->stride, subpel_x,
subpel_y, sf, w, h, ref, kernel, xs, ys, xd->bd);
subpel_y, sf, w, h, ref, &mi->mbmi.interp_filter, xs,
ys, xd->bd);
} else {
inter_predictor(pre, pre_buf->stride, dst, dst_buf->stride, subpel_x,
subpel_y, sf, w, h, ref, kernel, xs, ys);
subpel_y, sf, w, h, ref, &mi->mbmi.interp_filter, xs, ys);
}
#else
inter_predictor(pre, pre_buf->stride, dst, dst_buf->stride, subpel_x,
subpel_y, sf, w, h, ref, kernel, xs, ys);
subpel_y, sf, w, h, ref, &mi->mbmi.interp_filter, xs, ys);
#endif // CONFIG_AOM_HIGHBITDEPTH
}
}
......@@ -131,7 +132,6 @@ void av1_build_inter_predictor_sub8x8(MACROBLOCKD *xd, int plane, int i, int ir,
uint8_t *const dst = &pd->dst.buf[(ir * pd->dst.stride + ic) << 2];
int ref;
const int is_compound = has_second_ref(&mi->mbmi);
const InterpKernel *kernel = av1_filter_kernels[mi->mbmi.interp_filter];
for (ref = 0; ref < 1 + is_compound; ++ref) {
const uint8_t *pre =
......@@ -141,21 +141,21 @@ void av1_build_inter_predictor_sub8x8(MACROBLOCKD *xd, int plane, int i, int ir,
av1_highbd_build_inter_predictor(
pre, pd->pre[ref].stride, dst, pd->dst.stride,
&mi->bmi[i].as_mv[ref].as_mv, &xd->block_refs[ref]->sf, width, height,
ref, kernel, MV_PRECISION_Q3, mi_col * MI_SIZE + 4 * ic,
mi_row * MI_SIZE + 4 * ir, xd->bd);
ref, &mi->mbmi.interp_filter, MV_PRECISION_Q3,
mi_col * MI_SIZE + 4 * ic, mi_row * MI_SIZE + 4 * ir, xd->bd);
} else {
av1_build_inter_predictor(
pre, pd->pre[ref].stride, dst, pd->dst.stride,
&mi->bmi[i].as_mv[ref].as_mv, &xd->block_refs[ref]->sf, width, height,
ref, kernel, MV_PRECISION_Q3, mi_col * MI_SIZE + 4 * ic,
mi_row * MI_SIZE + 4 * ir);
ref, &mi->mbmi.interp_filter, MV_PRECISION_Q3,
mi_col * MI_SIZE + 4 * ic, mi_row * MI_SIZE + 4 * ir);
}
#else
av1_build_inter_predictor(
pre, pd->pre[ref].stride, dst, pd->dst.stride,
&mi->bmi[i].as_mv[ref].as_mv, &xd->block_refs[ref]->sf, width, height,
ref, kernel, MV_PRECISION_Q3, mi_col * MI_SIZE + 4 * ic,
mi_row * MI_SIZE + 4 * ir);
ref, &mi->mbmi.interp_filter, MV_PRECISION_Q3,
mi_col * MI_SIZE + 4 * ic, mi_row * MI_SIZE + 4 * ir);
#endif // CONFIG_AOM_HIGHBITDEPTH
}
}
......
......@@ -25,21 +25,36 @@ static INLINE void inter_predictor(const uint8_t *src, int src_stride,
uint8_t *dst, int dst_stride,
const int subpel_x, const int subpel_y,
const struct scale_factors *sf, int w, int h,
int ref, const InterpKernel *kernel, int xs,
int ys) {
int ref, const InterpFilter *interp_filter,
int xs, int ys) {
InterpFilterParams interp_filter_params =
get_interp_filter_params(*interp_filter);
const int16_t *filter_x =
get_interp_filter_subpel_kernel(interp_filter_params, subpel_x);
const int16_t *filter_y =
get_interp_filter_subpel_kernel(interp_filter_params, subpel_y);
sf->predict[subpel_x != 0][subpel_y != 0][ref](
src, src_stride, dst, dst_stride, kernel[subpel_x], xs, kernel[subpel_y],
ys, w, h);
src, src_stride, dst, dst_stride, filter_x, xs, filter_y, ys, w, h);
}
#if CONFIG_AOM_HIGHBITDEPTH
static INLINE void high_inter_predictor(
const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride,
const int subpel_x, const int subpel_y, const struct scale_factors *sf,
int w, int h, int ref, const InterpKernel *kernel, int xs, int ys, int bd) {
static INLINE void high_inter_predictor(const uint8_t *src, int src_stride,
uint8_t *dst, int dst_stride,
const int subpel_x, const int subpel_y,
const struct scale_factors *sf, int w,
int h, int ref,
const InterpFilter *interp_filter,
int xs, int ys, int bd) {
InterpFilterParams interp_filter_params =
get_interp_filter_params(*interp_filter);
const int16_t *filter_x =
get_interp_filter_subpel_kernel(interp_filter_params, subpel_x);
const int16_t *filter_y =
get_interp_filter_subpel_kernel(interp_filter_params, subpel_y);
sf->highbd_predict[subpel_x != 0][subpel_y != 0][ref](
src, src_stride, dst, dst_stride, kernel[subpel_x], xs, kernel[subpel_y],
ys, w, h, bd);
src, src_stride, dst, dst_stride, filter_x, xs, filter_y, ys, w, h, bd);
}
#endif // CONFIG_AOM_HIGHBITDEPTH
......@@ -131,15 +146,15 @@ void av1_build_inter_predictors_sb(MACROBLOCKD *xd, int mi_row, int mi_col,
void av1_build_inter_predictor(const uint8_t *src, int src_stride, uint8_t *dst,
int dst_stride, const MV *mv_q3,
const struct scale_factors *sf, int w, int h,
int do_avg, const InterpKernel *kernel,
int do_avg, const InterpFilter *interp_filter,
enum mv_precision precision, int x, int y);
#if CONFIG_AOM_HIGHBITDEPTH
void av1_highbd_build_inter_predictor(
const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride,
const MV *mv_q3, const struct scale_factors *sf, int w, int h, int do_avg,
const InterpKernel *kernel, enum mv_precision precision, int x, int y,
int bd);
const InterpFilter *interp_filter, enum mv_precision precision, int x,
int y, int bd);
#endif
static INLINE int scaled_buffer_offset(int x_offset, int y_offset, int stride,
......
......@@ -2077,7 +2077,7 @@ static void scale_and_extend_frame(const YV12_BUFFER_CONFIG *src,
const int src_strides[3] = { src->y_stride, src->uv_stride, src->uv_stride };
uint8_t *const dsts[3] = { dst->y_buffer, dst->u_buffer, dst->v_buffer };
const int dst_strides[3] = { dst->y_stride, dst->uv_stride, dst->uv_stride };
const InterpKernel *const kernel = av1_filter_kernels[EIGHTTAP];
InterpFilterParams interp_filter_params = get_interp_filter_params(EIGHTTAP);
int x, y, i;
for (y = 0; y < dst_h; y += 16) {
......@@ -2086,30 +2086,34 @@ static void scale_and_extend_frame(const YV12_BUFFER_CONFIG *src,
const int factor = (i == 0 || i == 3 ? 1 : 2);
const int x_q4 = x * (16 / factor) * src_w / dst_w;
const int y_q4 = y * (16 / factor) * src_h / dst_h;
const int subpel_x = x_q4 & 0xf;
const int subpel_y = y_q4 & 0xf;
const int src_stride = src_strides[i];
const int dst_stride = dst_strides[i];
const uint8_t *src_ptr = srcs[i] +
(y / factor) * src_h / dst_h * src_stride +
(x / factor) * src_w / dst_w;
uint8_t *dst_ptr = dsts[i] + (y / factor) * dst_stride + (x / factor);
const int16_t *filter_x =
get_interp_filter_subpel_kernel(interp_filter_params, subpel_x);
const int16_t *filter_y =
get_interp_filter_subpel_kernel(interp_filter_params, subpel_y);
#if CONFIG_AOM_HIGHBITDEPTH
if (src->flags & YV12_FLAG_HIGHBITDEPTH) {
aom_highbd_convolve8(src_ptr, src_stride, dst_ptr, dst_stride,
kernel[x_q4 & 0xf], 16 * src_w / dst_w,
kernel[y_q4 & 0xf], 16 * src_h / dst_h,
16 / factor, 16 / factor, bd);
filter_x, 16 * src_w / dst_w, filter_y,
16 * src_h / dst_h, 16 / factor, 16 / factor,
bd);
} else {
aom_convolve8(src_ptr, src_stride, dst_ptr, dst_stride,
kernel[x_q4 & 0xf], 16 * src_w / dst_w,
kernel[y_q4 & 0xf], 16 * src_h / dst_h, 16 / factor,
16 / factor);
aom_convolve8(src_ptr, src_stride, dst_ptr, dst_stride, filter_x,
16 * src_w / dst_w, filter_y, 16 * src_h / dst_h,
16 / factor, 16 / factor);
}
#else
aom_convolve8(src_ptr, src_stride, dst_ptr, dst_stride,
kernel[x_q4 & 0xf], 16 * src_w / dst_w,
kernel[y_q4 & 0xf], 16 * src_h / dst_h, 16 / factor,
16 / factor);
aom_convolve8(src_ptr, src_stride, dst_ptr, dst_stride, filter_x,
16 * src_w / dst_w, filter_y, 16 * src_h / dst_h,
16 / factor, 16 / factor);
#endif // CONFIG_AOM_HIGHBITDEPTH
}
}
......
......@@ -1558,7 +1558,6 @@ static void joint_motion_search(AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize,
mbmi->ref_frame[1] < 0 ? 0 : mbmi->ref_frame[1] };
int_mv ref_mv[2];
int ite, ref;
const InterpKernel *kernel = av1_filter_kernels[mbmi->interp_filter];
struct scale_factors sf;
// Do joint motion search in compound mode to get more accurate mv.
......@@ -1631,19 +1630,19 @@ static void joint_motion_search(AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize,
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, &sf, pw, ph, 0, kernel, MV_PRECISION_Q3,
mi_col * MI_SIZE, mi_row * MI_SIZE, xd->bd);
&frame_mv[refs[!id]].as_mv, &sf, pw, ph, 0, &mbmi->interp_filter,
MV_PRECISION_Q3, mi_col * MI_SIZE, mi_row * MI_SIZE, xd->bd);
} 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,
&sf, pw, ph, 0, kernel, MV_PRECISION_Q3,
mi_col * MI_SIZE, mi_row * MI_SIZE);
av1_build_inter_predictor(
ref_yv12[!id].buf, ref_yv12[!id].stride, second_pred, pw,
&frame_mv[refs[!id]].as_mv, &sf, pw, ph, 0, &mbmi->interp_filter,
MV_PRECISION_Q3, mi_col * MI_SIZE, mi_row * MI_SIZE);
}
#else
av1_build_inter_predictor(ref_yv12[!id].buf, ref_yv12[!id].stride,
second_pred, pw, &frame_mv[refs[!id]].as_mv, &sf,
pw, ph, 0, kernel, MV_PRECISION_Q3,
pw, ph, 0, &mbmi->interp_filter, MV_PRECISION_Q3,
mi_col * MI_SIZE, mi_row * MI_SIZE);
#endif // CONFIG_AOM_HIGHBITDEPTH
......
......@@ -37,11 +37,9 @@ static void temporal_filter_predictors_mb_c(
uint8_t *pred, struct scale_factors *scale, int x, int y) {
const int which_mv = 0;
const MV mv = { mv_row, mv_col };
const InterpKernel *const kernel =
av1_filter_kernels[xd->mi[0]->mbmi.interp_filter];
enum mv_precision mv_precision_uv;
int uv_stride;
InterpFilter *interp_filter = &xd->mi[0]->mbmi.interp_filter;
if (uv_block_width == 8) {
uv_stride = (stride + 1) >> 1;
mv_precision_uv = MV_PRECISION_Q4;
......@@ -53,31 +51,31 @@ static void temporal_filter_predictors_mb_c(
#if CONFIG_AOM_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
av1_highbd_build_inter_predictor(y_mb_ptr, stride, &pred[0], 16, &mv, scale,
16, 16, which_mv, kernel, MV_PRECISION_Q3,
x, y, xd->bd);
16, 16, which_mv, interp_filter,
MV_PRECISION_Q3, x, y, xd->bd);
av1_highbd_build_inter_predictor(u_mb_ptr, uv_stride, &pred[256],
uv_block_width, &mv, scale, uv_block_width,
uv_block_height, which_mv, kernel,
uv_block_height, which_mv, interp_filter,
mv_precision_uv, x, y, xd->bd);
av1_highbd_build_inter_predictor(v_mb_ptr, uv_stride, &pred[512],
uv_block_width, &mv, scale, uv_block_width,
uv_block_height, which_mv, kernel,
uv_block_height, which_mv, interp_filter,
mv_precision_uv, x, y, xd->bd);
return;
}
#endif // CONFIG_AOM_HIGHBITDEPTH
av1_build_inter_predictor(y_mb_ptr, stride, &pred[0], 16, &mv, scale, 16, 16,
which_mv, kernel, MV_PRECISION_Q3, x, y);
which_mv, interp_filter, MV_PRECISION_Q3, x, y);
av1_build_inter_predictor(u_mb_ptr, uv_stride, &pred[256], uv_block_width,
&mv, scale, uv_block_width, uv_block_height,
which_mv, kernel, mv_precision_uv, x, y);
which_mv, interp_filter, mv_precision_uv, x, y);
av1_build_inter_predictor(v_mb_ptr, uv_stride, &pred[512], uv_block_width,
&mv, scale, uv_block_width, uv_block_height,
which_mv, kernel, mv_precision_uv, x, y);
which_mv, interp_filter, mv_precision_uv, x, y);
}
void av1_temporal_filter_apply_c(uint8_t *frame1, unsigned int stride,
......
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