Commit 91b235f1 authored by Debargha Mukherjee's avatar Debargha Mukherjee

Some minor clean-ups on convolve functions

Some fixes and additions of asserts.

Change-Id: Ib5f706baf48acb2853f7fe55991efa95e6a848de
parent cad7f067
......@@ -1169,7 +1169,8 @@ void av1_highbd_convolve_2d_facade(const uint8_t *src8, int src_stride,
#endif
const uint16_t *src = CONVERT_TO_SHORTPTR(src8);
if (conv_params->dst) {
if (conv_params->is_compound) {
assert(conv_params->dst != NULL);
if (filter_params_y.taps < filter_params_x.taps) {
uint16_t tr_src[(MAX_SB_SIZE + MAX_FILTER_TAP - 1) *
(MAX_SB_SIZE + MAX_FILTER_TAP - 1)];
......@@ -1262,8 +1263,10 @@ void av1_highbd_convolve_2d_facade(const uint8_t *src8, int src_stride,
subpel_y_q4, conv_params, bd);
#endif // CONFIG_JNT_COMP
// 0-bit rounding just to convert from int32 to uint16
const int rbits =
2 * FILTER_BITS - conv_params->round_0 - conv_params->round_1;
av1_highbd_convolve_rounding(tmp_dst, tmp_dst_stride, dst, dst_stride, w, h,
0, bd);
rbits, bd);
}
}
......
......@@ -122,6 +122,7 @@ static INLINE ConvolveParams get_conv_params_no_round(int ref, int do_average,
ConvolveParams conv_params;
conv_params.ref = ref;
conv_params.do_average = do_average;
assert(IMPLIES(do_average, is_compound));
conv_params.round = CONVOLVE_OPT_NO_ROUND;
conv_params.is_compound = is_compound;
conv_params.round_0 = ROUND0_BITS;
......
......@@ -86,13 +86,19 @@ static INLINE void av1_make_inter_predictor(
pre_buf->buf0, pre_buf->width, pre_buf->height,
pre_buf->stride, dst, p_col, p_row, w, h, dst_stride,
pd->subsampling_x, pd->subsampling_y, conv_params);
assert(IMPLIES(conv_params->dst != NULL, conv_params->do_post_rounding));
assert(IMPLIES(conv_params->dst == NULL, !conv_params->do_post_rounding));
} else if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
highbd_inter_predictor(src, src_stride, dst, dst_stride, subpel_x, subpel_y,
sf, w, h, conv_params, interp_filters, xs, ys,
xd->bd);
assert(IMPLIES(conv_params->is_compound, conv_params->do_post_rounding));
assert(!(conv_params->is_compound && conv_params->dst == NULL));
} else {
inter_predictor(src, src_stride, dst, dst_stride, subpel_x, subpel_y, sf, w,
h, conv_params, interp_filters, xs, ys);
assert(IMPLIES(conv_params->is_compound, conv_params->do_post_rounding));
assert(!(conv_params->is_compound && conv_params->dst == NULL));
}
}
......@@ -974,6 +980,7 @@ static INLINE void build_inter_predictors(const AV1_COMMON *cm, MACROBLOCKD *xd,
const int b8_w = block_size_wide[plane_bsize] >> ss_x;
const int b8_h = block_size_high[plane_bsize] >> ss_y;
int idx, idy;
assert(!is_compound);
const int x_base = x;
const int y_base = y;
......@@ -1095,7 +1102,10 @@ static INLINE void build_inter_predictors(const AV1_COMMON *cm, MACROBLOCKD *xd,
(mi_y >> pd->subsampling_y) + y, plane, ref, mi, build_for_obmc,
xs, ys, xd);
} // for (ref = 0; ref < 1 + is_compound; ++ref)
if (conv_params.do_post_rounding) {
assert(!is_masked_compound_type(mi->mbmi.interinter_compound_type));
assert(conv_params.dst != NULL);
int round_bits = FILTER_BITS * 2 + is_compound - conv_params.round_0 -
conv_params.round_1;
#if CONFIG_JNT_COMP
......@@ -1190,7 +1200,7 @@ static INLINE void build_inter_predictors(const AV1_COMMON *cm, MACROBLOCKD *xd,
}
ConvolveParams conv_params = get_conv_params_no_round(
ref, ref, plane, tmp_dst, MAX_SB_SIZE, is_compound, xd->bd);
0, 0, plane, tmp_dst, MAX_SB_SIZE, is_compound, xd->bd);
#if CONFIG_JNT_COMP
av1_jnt_comp_weight_assign(cm, &mi->mbmi, 0, &conv_params.fwd_offset,
&conv_params.bck_offset,
......@@ -1234,8 +1244,12 @@ static INLINE void build_inter_predictors(const AV1_COMMON *cm, MACROBLOCKD *xd,
subpel_params[ref].ys, xd);
}
// if (!is_masked_compound_type(mi->mbmi.interinter_compound_type))
// assert(conv_params.do_post_rounding);
// TODO(angiebird): This part needs optimization
if (conv_params.do_post_rounding) {
assert(!is_masked_compound_type(mi->mbmi.interinter_compound_type));
assert(conv_params.dst != NULL);
int round_bits = FILTER_BITS * 2 + is_compound - conv_params.round_0 -
conv_params.round_1;
#if CONFIG_JNT_COMP
......
......@@ -148,7 +148,10 @@ static INLINE void highbd_inter_predictor(const uint8_t *src, int src_stride,
av1_highbd_convolve_2d_facade(src, src_stride, dst, dst_stride, w, h,
interp_filters, subpel_x, xs, subpel_y, ys,
0, conv_params, bd);
conv_params->do_post_rounding = 1;
if (conv_params->is_compound)
conv_params->do_post_rounding = 1;
else
conv_params->do_post_rounding = 0;
} else {
InterpFilterParams filter_params_x, filter_params_y;
#if CONFIG_SHORT_FILTER
......
......@@ -35,8 +35,8 @@ void av1_highbd_convolve_2d_avx2(const uint16_t *src, int src_stride,
const uint16_t *const src_ptr = src - fo_vert * src_stride - fo_horiz;
// Check that, even with 12-bit input, the intermediate values will fit
// into an unsigned 15-bit intermediate array.
assert(conv_params->round_0 >= 5);
// into an unsigned 16-bit intermediate array.
assert(bd + FILTER_BITS + 2 - conv_params->round_0 <= 16);
/* Horizontal filter */
{
......
......@@ -41,8 +41,8 @@ void av1_highbd_jnt_convolve_2d_sse4_1(
const __m128i wt1 = _mm_set1_epi32(w1);
// Check that, even with 12-bit input, the intermediate values will fit
// into an unsigned 15-bit intermediate array.
assert(conv_params->round_0 >= 5);
// into an unsigned 16-bit intermediate array.
assert(bd + FILTER_BITS + 2 - conv_params->round_0 <= 16);
/* Horizontal filter */
{
......
......@@ -35,8 +35,8 @@ void av1_highbd_convolve_2d_ssse3(const uint16_t *src, int src_stride,
const uint16_t *const src_ptr = src - fo_vert * src_stride - fo_horiz;
// Check that, even with 12-bit input, the intermediate values will fit
// into an unsigned 15-bit intermediate array.
assert(conv_params->round_0 >= 5);
// into an unsigned 16-bit intermediate array.
assert(bd + FILTER_BITS + 2 - conv_params->round_0 <= 16);
/* Horizontal filter */
{
......
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