Commit bf7e741e authored by Yaowu Xu's avatar Yaowu Xu

misc-fix: use fixed intra prediction modes

This commit merges the fix of oddities in several intra prediction
modes.

Related tracking issue:
https://bugs.chromium.org/p/webm/issues/detail?id=1043
Original libvpx commit:
c7dc1d78

Change-Id: I4e2d0c2514a34b498453dcd4be2e6e4430d7373a
parent c2b82128
This diff is collapsed.
......@@ -19,31 +19,6 @@
#define AVG3(a, b, c) (((a) + 2 * (b) + (c) + 2) >> 2)
#define AVG2(a, b) (((a) + (b) + 1) >> 1)
static INLINE void d207_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
const uint8_t *above, const uint8_t *left) {
int r, c;
(void)above;
// first column
for (r = 0; r < bs - 1; ++r) dst[r * stride] = AVG2(left[r], left[r + 1]);
dst[(bs - 1) * stride] = left[bs - 1];
dst++;
// second column
for (r = 0; r < bs - 2; ++r)
dst[r * stride] = AVG3(left[r], left[r + 1], left[r + 2]);
dst[(bs - 2) * stride] = AVG3(left[bs - 2], left[bs - 1], left[bs - 1]);
dst[(bs - 1) * stride] = left[bs - 1];
dst++;
// rest of last row
for (c = 0; c < bs - 2; ++c) dst[(bs - 1) * stride + c] = left[bs - 1];
for (r = bs - 2; r >= 0; --r)
for (c = 0; c < bs - 2; ++c)
dst[r * stride + c] = dst[(r + 1) * stride + c - 2];
}
#if CONFIG_MISC_FIXES
static INLINE void d207e_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
const uint8_t *above, const uint8_t *left) {
int r, c;
......@@ -58,26 +33,7 @@ static INLINE void d207e_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
dst += stride;
}
}
#endif // CONFIG_MISC_FIXES
static INLINE void d63_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
const uint8_t *above, const uint8_t *left) {
int r, c;
int size;
(void)left;
for (c = 0; c < bs; ++c) {
dst[c] = AVG2(above[c], above[c + 1]);
dst[stride + c] = AVG3(above[c], above[c + 1], above[c + 2]);
}
for (r = 2, size = bs - 2; r < bs; r += 2, --size) {
memcpy(dst + (r + 0) * stride, dst + (r >> 1), size);
memset(dst + (r + 0) * stride + size, above[bs - 1], bs - size);
memcpy(dst + (r + 1) * stride, dst + stride + (r >> 1), size);
memset(dst + (r + 1) * stride + size, above[bs - 1], bs - size);
}
}
#if CONFIG_MISC_FIXES
static INLINE void d63e_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
const uint8_t *above, const uint8_t *left) {
int r, c;
......@@ -91,28 +47,7 @@ static INLINE void d63e_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
dst += stride;
}
}
#endif // CONFIG_MISC_FIXES
static INLINE void d45_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
const uint8_t *above, const uint8_t *left) {
const uint8_t above_right = above[bs - 1];
const uint8_t *const dst_row0 = dst;
int x, size;
(void)left;
for (x = 0; x < bs - 1; ++x) {
dst[x] = AVG3(above[x], above[x + 1], above[x + 2]);
}
dst[bs - 1] = above_right;
dst += stride;
for (x = 1, size = bs - 2; x < bs; ++x, --size) {
memcpy(dst, dst_row0 + x, size);
memset(dst + size, above_right, x + 1);
dst += stride;
}
}
#if CONFIG_MISC_FIXES
static INLINE void d45e_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
const uint8_t *above, const uint8_t *left) {
int r, c;
......@@ -125,7 +60,6 @@ static INLINE void d45e_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
dst += stride;
}
}
#endif // CONFIG_MISC_FIXES
static INLINE void d117_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
const uint8_t *above, const uint8_t *left) {
......@@ -621,38 +555,6 @@ void aom_d153_predictor_4x4_c(uint8_t *dst, ptrdiff_t stride,
}
#if CONFIG_AOM_HIGHBITDEPTH
static INLINE void highbd_d207_predictor(uint16_t *dst, ptrdiff_t stride,
int bs, const uint16_t *above,
const uint16_t *left, int bd) {
int r, c;
(void)above;
(void)bd;
// First column.
for (r = 0; r < bs - 1; ++r) {
dst[r * stride] = AVG2(left[r], left[r + 1]);
}
dst[(bs - 1) * stride] = left[bs - 1];
dst++;
// Second column.
for (r = 0; r < bs - 2; ++r) {
dst[r * stride] = AVG3(left[r], left[r + 1], left[r + 2]);
}
dst[(bs - 2) * stride] = AVG3(left[bs - 2], left[bs - 1], left[bs - 1]);
dst[(bs - 1) * stride] = left[bs - 1];
dst++;
// Rest of last row.
for (c = 0; c < bs - 2; ++c) dst[(bs - 1) * stride + c] = left[bs - 1];
for (r = bs - 2; r >= 0; --r) {
for (c = 0; c < bs - 2; ++c)
dst[r * stride + c] = dst[(r + 1) * stride + c - 2];
}
}
#if CONFIG_MISC_FIXES
static INLINE void highbd_d207e_predictor(uint16_t *dst, ptrdiff_t stride,
int bs, const uint16_t *above,
const uint16_t *left, int bd) {
......@@ -669,11 +571,10 @@ static INLINE void highbd_d207e_predictor(uint16_t *dst, ptrdiff_t stride,
dst += stride;
}
}
#endif // CONFIG_MISC_FIXES
static INLINE void highbd_d63_predictor(uint16_t *dst, ptrdiff_t stride, int bs,
const uint16_t *above,
const uint16_t *left, int bd) {
static INLINE void highbd_d63e_predictor(uint16_t *dst, ptrdiff_t stride,
int bs, const uint16_t *above,
const uint16_t *left, int bd) {
int r, c;
(void)left;
(void)bd;
......@@ -687,25 +588,6 @@ static INLINE void highbd_d63_predictor(uint16_t *dst, ptrdiff_t stride, int bs,
}
}
#define highbd_d63e_predictor highbd_d63_predictor
static INLINE void highbd_d45_predictor(uint16_t *dst, ptrdiff_t stride, int bs,
const uint16_t *above,
const uint16_t *left, int bd) {
int r, c;
(void)left;
(void)bd;
for (r = 0; r < bs; ++r) {
for (c = 0; c < bs; ++c) {
dst[c] = r + c + 2 < bs * 2
? AVG3(above[r + c], above[r + c + 1], above[r + c + 2])
: above[bs * 2 - 1];
}
dst += stride;
}
}
#if CONFIG_MISC_FIXES
static INLINE void highbd_d45e_predictor(uint16_t *dst, ptrdiff_t stride,
int bs, const uint16_t *above,
const uint16_t *left, int bd) {
......@@ -720,7 +602,6 @@ static INLINE void highbd_d45e_predictor(uint16_t *dst, ptrdiff_t stride,
dst += stride;
}
}
#endif // CONFIG_MISC_FIXES
static INLINE void highbd_d117_predictor(uint16_t *dst, ptrdiff_t stride,
int bs, const uint16_t *above,
......@@ -938,14 +819,9 @@ static INLINE void highbd_dc_predictor(uint16_t *dst, ptrdiff_t stride, int bs,
#endif // CONFIG_AOM_HIGHBITDEPTH
/* clang-format off */
intra_pred_above_4x4(d207) // NOLINT
intra_pred_above_4x4(d63) // NOLINT
intra_pred_above_4x4(d45) // NOLINT
#if CONFIG_MISC_FIXES
intra_pred_allsizes(d207e) // NOLINT
intra_pred_allsizes(d63e) // NOLINT
intra_pred_above_4x4(d45e) // NOLINT
#endif
intra_pred_above_4x4(d117) // NOLINT
intra_pred_above_4x4(d135) // NOLINT
intra_pred_above_4x4(d153) // NOLINT
......
......@@ -178,15 +178,9 @@ static void av1_init_intra_predictors_internal(void) {
INIT_ALL_SIZES(pred[V_PRED], v);
INIT_ALL_SIZES(pred[H_PRED], h);
#if CONFIG_MISC_FIXES
INIT_ALL_SIZES(pred[D207_PRED], d207e);
INIT_ALL_SIZES(pred[D45_PRED], d45e);
INIT_ALL_SIZES(pred[D63_PRED], d63e);
#else
INIT_ALL_SIZES(pred[D207_PRED], d207);
INIT_ALL_SIZES(pred[D45_PRED], d45);
INIT_ALL_SIZES(pred[D63_PRED], d63);
#endif
INIT_ALL_SIZES(pred[D117_PRED], d117);
INIT_ALL_SIZES(pred[D135_PRED], d135);
INIT_ALL_SIZES(pred[D153_PRED], d153);
......@@ -200,15 +194,9 @@ static void av1_init_intra_predictors_internal(void) {
#if CONFIG_AOM_HIGHBITDEPTH
INIT_ALL_SIZES(pred_high[V_PRED], highbd_v);
INIT_ALL_SIZES(pred_high[H_PRED], highbd_h);
#if CONFIG_MISC_FIXES
INIT_ALL_SIZES(pred_high[D207_PRED], highbd_d207e);
INIT_ALL_SIZES(pred_high[D45_PRED], highbd_d45e);
INIT_ALL_SIZES(pred_high[D63_PRED], highbd_d63);
#else
INIT_ALL_SIZES(pred_high[D207_PRED], highbd_d207);
INIT_ALL_SIZES(pred_high[D45_PRED], highbd_d45);
INIT_ALL_SIZES(pred_high[D63_PRED], highbd_d63);
#endif
INIT_ALL_SIZES(pred_high[D63_PRED], highbd_d63e);
INIT_ALL_SIZES(pred_high[D117_PRED], highbd_d117);
INIT_ALL_SIZES(pred_high[D135_PRED], highbd_d135);
INIT_ALL_SIZES(pred_high[D153_PRED], highbd_d153);
......
......@@ -47,12 +47,12 @@ void TestIntraPred(const char name[], AvxPredFunc const *pred_funcs,
const int kTotalPixels = 32 * kBPS;
DECLARE_ALIGNED(16, uint8_t, src[kTotalPixels]);
DECLARE_ALIGNED(16, uint8_t, ref_src[kTotalPixels]);
DECLARE_ALIGNED(16, uint8_t, left[kBPS]);
DECLARE_ALIGNED(16, uint8_t, left[kBPS * 2]);
DECLARE_ALIGNED(16, uint8_t, above_mem[2 * kBPS + 16]);
uint8_t *const above = above_mem + 16;
for (int i = 0; i < kTotalPixels; ++i) ref_src[i] = rnd.Rand8();
for (int i = 0; i < kBPS; ++i) left[i] = rnd.Rand8();
for (int i = -1; i < kBPS; ++i) above[i] = rnd.Rand8();
for (int i = 0; i < kBPS * 2; ++i) left[i] = rnd.Rand8();
for (int i = -1; i < kBPS * 2; ++i) above[i] = rnd.Rand8();
const int kNumTests = static_cast<int>(2.e10 / num_pixels_per_test);
// some code assumes the top row has been extended:
......@@ -160,24 +160,22 @@ void TestIntraPred32(AvxPredFunc const *pred_funcs) {
INTRA_PRED_TEST(C, TestIntraPred4, aom_dc_predictor_4x4_c,
aom_dc_left_predictor_4x4_c, aom_dc_top_predictor_4x4_c,
aom_dc_128_predictor_4x4_c, aom_v_predictor_4x4_c,
aom_h_predictor_4x4_c, aom_d45_predictor_4x4_c,
aom_h_predictor_4x4_c, aom_d45e_predictor_4x4_c,
aom_d135_predictor_4x4_c, aom_d117_predictor_4x4_c,
aom_d153_predictor_4x4_c, aom_d207_predictor_4x4_c,
aom_d63_predictor_4x4_c, aom_tm_predictor_4x4_c)
aom_d153_predictor_4x4_c, aom_d207e_predictor_4x4_c,
aom_d63e_predictor_4x4_c, aom_tm_predictor_4x4_c)
#if HAVE_SSE2 && CONFIG_USE_X86INC
INTRA_PRED_TEST(SSE2, TestIntraPred4, aom_dc_predictor_4x4_sse2,
aom_dc_left_predictor_4x4_sse2, aom_dc_top_predictor_4x4_sse2,
aom_dc_128_predictor_4x4_sse2, aom_v_predictor_4x4_sse2,
aom_h_predictor_4x4_sse2, aom_d45_predictor_4x4_sse2, NULL,
NULL, NULL, aom_d207_predictor_4x4_sse2, NULL,
aom_h_predictor_4x4_sse2, NULL, NULL, NULL, NULL, NULL, NULL,
aom_tm_predictor_4x4_sse2)
#endif // HAVE_SSE2 && CONFIG_USE_X86INC
#if HAVE_SSSE3 && CONFIG_USE_X86INC
INTRA_PRED_TEST(SSSE3, TestIntraPred4, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, aom_d153_predictor_4x4_ssse3, NULL,
aom_d63_predictor_4x4_ssse3, NULL)
NULL, NULL, aom_d153_predictor_4x4_ssse3, NULL, NULL, NULL)
#endif // HAVE_SSSE3 && CONFIG_USE_X86INC
#if HAVE_DSPR2
......@@ -190,9 +188,8 @@ INTRA_PRED_TEST(DSPR2, TestIntraPred4, aom_dc_predictor_4x4_dspr2, NULL, NULL,
INTRA_PRED_TEST(NEON, TestIntraPred4, aom_dc_predictor_4x4_neon,
aom_dc_left_predictor_4x4_neon, aom_dc_top_predictor_4x4_neon,
aom_dc_128_predictor_4x4_neon, aom_v_predictor_4x4_neon,
aom_h_predictor_4x4_neon, aom_d45_predictor_4x4_neon,
aom_d135_predictor_4x4_neon, NULL, NULL, NULL, NULL,
aom_tm_predictor_4x4_neon)
aom_h_predictor_4x4_neon, NULL, aom_d135_predictor_4x4_neon,
NULL, NULL, NULL, NULL, aom_tm_predictor_4x4_neon)
#endif // HAVE_NEON
#if HAVE_MSA
......@@ -209,23 +206,22 @@ INTRA_PRED_TEST(MSA, TestIntraPred4, aom_dc_predictor_4x4_msa,
INTRA_PRED_TEST(C, TestIntraPred8, aom_dc_predictor_8x8_c,
aom_dc_left_predictor_8x8_c, aom_dc_top_predictor_8x8_c,
aom_dc_128_predictor_8x8_c, aom_v_predictor_8x8_c,
aom_h_predictor_8x8_c, aom_d45_predictor_8x8_c,
aom_h_predictor_8x8_c, aom_d45e_predictor_8x8_c,
aom_d135_predictor_8x8_c, aom_d117_predictor_8x8_c,
aom_d153_predictor_8x8_c, aom_d207_predictor_8x8_c,
aom_d63_predictor_8x8_c, aom_tm_predictor_8x8_c)
aom_d153_predictor_8x8_c, aom_d207e_predictor_8x8_c,
aom_d63e_predictor_8x8_c, aom_tm_predictor_8x8_c)
#if HAVE_SSE2 && CONFIG_USE_X86INC
INTRA_PRED_TEST(SSE2, TestIntraPred8, aom_dc_predictor_8x8_sse2,
aom_dc_left_predictor_8x8_sse2, aom_dc_top_predictor_8x8_sse2,
aom_dc_128_predictor_8x8_sse2, aom_v_predictor_8x8_sse2,
aom_h_predictor_8x8_sse2, aom_d45_predictor_8x8_sse2, NULL,
NULL, NULL, NULL, NULL, aom_tm_predictor_8x8_sse2)
aom_h_predictor_8x8_sse2, NULL, NULL, NULL, NULL, NULL, NULL,
aom_tm_predictor_8x8_sse2)
#endif // HAVE_SSE2 && CONFIG_USE_X86INC
#if HAVE_SSSE3 && CONFIG_USE_X86INC
INTRA_PRED_TEST(SSSE3, TestIntraPred8, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, aom_d153_predictor_8x8_ssse3,
aom_d207_predictor_8x8_ssse3, aom_d63_predictor_8x8_ssse3, NULL)
NULL, NULL, aom_d153_predictor_8x8_ssse3, NULL, NULL, NULL)
#endif // HAVE_SSSE3 && CONFIG_USE_X86INC
#if HAVE_DSPR2
......@@ -238,8 +234,8 @@ INTRA_PRED_TEST(DSPR2, TestIntraPred8, aom_dc_predictor_8x8_dspr2, NULL, NULL,
INTRA_PRED_TEST(NEON, TestIntraPred8, aom_dc_predictor_8x8_neon,
aom_dc_left_predictor_8x8_neon, aom_dc_top_predictor_8x8_neon,
aom_dc_128_predictor_8x8_neon, aom_v_predictor_8x8_neon,
aom_h_predictor_8x8_neon, aom_d45_predictor_8x8_neon, NULL,
NULL, NULL, NULL, NULL, aom_tm_predictor_8x8_neon)
aom_h_predictor_8x8_neon, NULL, NULL, NULL, NULL, NULL, NULL,
aom_tm_predictor_8x8_neon)
#endif // HAVE_NEON
......@@ -257,10 +253,10 @@ INTRA_PRED_TEST(MSA, TestIntraPred8, aom_dc_predictor_8x8_msa,
INTRA_PRED_TEST(C, TestIntraPred16, aom_dc_predictor_16x16_c,
aom_dc_left_predictor_16x16_c, aom_dc_top_predictor_16x16_c,
aom_dc_128_predictor_16x16_c, aom_v_predictor_16x16_c,
aom_h_predictor_16x16_c, aom_d45_predictor_16x16_c,
aom_h_predictor_16x16_c, aom_d45e_predictor_16x16_c,
aom_d135_predictor_16x16_c, aom_d117_predictor_16x16_c,
aom_d153_predictor_16x16_c, aom_d207_predictor_16x16_c,
aom_d63_predictor_16x16_c, aom_tm_predictor_16x16_c)
aom_d153_predictor_16x16_c, aom_d207e_predictor_16x16_c,
aom_d63e_predictor_16x16_c, aom_tm_predictor_16x16_c)
#if HAVE_SSE2 && CONFIG_USE_X86INC
INTRA_PRED_TEST(SSE2, TestIntraPred16, aom_dc_predictor_16x16_sse2,
......@@ -273,9 +269,8 @@ INTRA_PRED_TEST(SSE2, TestIntraPred16, aom_dc_predictor_16x16_sse2,
#if HAVE_SSSE3 && CONFIG_USE_X86INC
INTRA_PRED_TEST(SSSE3, TestIntraPred16, NULL, NULL, NULL, NULL, NULL, NULL,
aom_d45_predictor_16x16_ssse3, NULL, NULL,
aom_d153_predictor_16x16_ssse3, aom_d207_predictor_16x16_ssse3,
aom_d63_predictor_16x16_ssse3, NULL)
NULL, NULL, NULL, aom_d153_predictor_16x16_ssse3, NULL, NULL,
NULL)
#endif // HAVE_SSSE3 && CONFIG_USE_X86INC
#if HAVE_DSPR2
......@@ -289,8 +284,8 @@ INTRA_PRED_TEST(NEON, TestIntraPred16, aom_dc_predictor_16x16_neon,
aom_dc_left_predictor_16x16_neon,
aom_dc_top_predictor_16x16_neon,
aom_dc_128_predictor_16x16_neon, aom_v_predictor_16x16_neon,
aom_h_predictor_16x16_neon, aom_d45_predictor_16x16_neon, NULL,
NULL, NULL, NULL, NULL, aom_tm_predictor_16x16_neon)
aom_h_predictor_16x16_neon, NULL, NULL, NULL, NULL, NULL, NULL,
aom_tm_predictor_16x16_neon)
#endif // HAVE_NEON
#if HAVE_MSA
......@@ -307,10 +302,10 @@ INTRA_PRED_TEST(MSA, TestIntraPred16, aom_dc_predictor_16x16_msa,
INTRA_PRED_TEST(C, TestIntraPred32, aom_dc_predictor_32x32_c,
aom_dc_left_predictor_32x32_c, aom_dc_top_predictor_32x32_c,
aom_dc_128_predictor_32x32_c, aom_v_predictor_32x32_c,
aom_h_predictor_32x32_c, aom_d45_predictor_32x32_c,
aom_h_predictor_32x32_c, aom_d45e_predictor_32x32_c,
aom_d135_predictor_32x32_c, aom_d117_predictor_32x32_c,
aom_d153_predictor_32x32_c, aom_d207_predictor_32x32_c,
aom_d63_predictor_32x32_c, aom_tm_predictor_32x32_c)
aom_d153_predictor_32x32_c, aom_d207e_predictor_32x32_c,
aom_d63e_predictor_32x32_c, aom_tm_predictor_32x32_c)
#if HAVE_SSE2 && CONFIG_USE_X86INC
INTRA_PRED_TEST(SSE2, TestIntraPred32, aom_dc_predictor_32x32_sse2,
......@@ -323,9 +318,8 @@ INTRA_PRED_TEST(SSE2, TestIntraPred32, aom_dc_predictor_32x32_sse2,
#if HAVE_SSSE3 && CONFIG_USE_X86INC
INTRA_PRED_TEST(SSSE3, TestIntraPred32, NULL, NULL, NULL, NULL, NULL, NULL,
aom_d45_predictor_32x32_ssse3, NULL, NULL,
aom_d153_predictor_32x32_ssse3, aom_d207_predictor_32x32_ssse3,
aom_d63_predictor_32x32_ssse3, NULL)
NULL, NULL, NULL, aom_d153_predictor_32x32_ssse3, NULL, NULL,
NULL)
#endif // HAVE_SSSE3 && CONFIG_USE_X86INC
#if HAVE_NEON
......
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