Introduce a custom cospi array for highbd_fwd_txfm_neon.c Similar to the existing 16-bit array for lowbd, we want to make sure that symmetric constants in the cospi array are stored together in memory so we can load them together and make use of lane-indexed instructions. There doesn't seem to be any immediate benefit to also storing the negated versions of the constants like we do for the 16-bit version so this is left for now. Benchmarking this on a Neoverse N2 machine with Clang 16 and GCC 12, the highbd txfm2d speed tests report a geomean 0.5% reduction in runtime as a result of this change. Change-Id: I3def770fbb96e4da4e0b6f20bd67cf837b1ac000
diff --git a/av1/common/av1_txfm.c b/av1/common/av1_txfm.c index 5add3ab..011403b 100644 --- a/av1/common/av1_txfm.c +++ b/av1/common/av1_txfm.c
@@ -142,6 +142,47 @@ { 2640, 4964, 6688, 7604 }, { 2642, 4964, 6688, 7606 }, { 2642, 4964, 6689, 7606 } }; + +// Constants are stored in pairs, where symmetrical constants in the +// cospi array are stored adjacent in memory, i.e.: +// f(i,j) = (int)round(cos(PI*j/128) * (1<<(cos_bit_min+i))) +// and then in memory we store 4-tuples of constants together as: +// f2(i,j) = [ f(i,j), f(i,64-j) ] +const int32_t av1_cospi_arr_s32_data[4][66] = { + { + 1024, 0, 1024, 25, 1023, 50, 1021, 75, 1019, 100, 1016, + 125, 1013, 150, 1009, 175, 1004, 200, 999, 224, 993, 249, + 987, 273, 980, 297, 972, 321, 964, 345, 955, 369, 946, + 392, 936, 415, 926, 438, 915, 460, 903, 483, 891, 505, + 878, 526, 865, 548, 851, 569, 837, 590, 822, 610, 807, + 630, 792, 650, 775, 669, 759, 688, 742, 706, 724, 724, + }, + { + 2048, 0, 2047, 50, 2046, 100, 2042, 151, 2038, 201, 2033, + 251, 2026, 301, 2018, 350, 2009, 400, 1998, 449, 1987, 498, + 1974, 546, 1960, 595, 1945, 642, 1928, 690, 1911, 737, 1892, + 784, 1872, 830, 1851, 876, 1829, 921, 1806, 965, 1782, 1009, + 1757, 1053, 1730, 1096, 1703, 1138, 1674, 1179, 1645, 1220, 1615, + 1260, 1583, 1299, 1551, 1338, 1517, 1375, 1483, 1412, 1448, 1448, + }, + { + 4096, 0, 4095, 101, 4091, 201, 4085, 301, 4076, 401, 4065, + 501, 4052, 601, 4036, 700, 4017, 799, 3996, 897, 3973, 995, + 3948, 1092, 3920, 1189, 3889, 1285, 3857, 1380, 3822, 1474, 3784, + 1567, 3745, 1660, 3703, 1751, 3659, 1842, 3612, 1931, 3564, 2019, + 3513, 2106, 3461, 2191, 3406, 2276, 3349, 2359, 3290, 2440, 3229, + 2520, 3166, 2598, 3102, 2675, 3035, 2751, 2967, 2824, 2896, 2896, + }, + { + 8192, 0, 8190, 201, 8182, 402, 8170, 603, 8153, 803, 8130, + 1003, 8103, 1202, 8071, 1401, 8035, 1598, 7993, 1795, 7946, 1990, + 7895, 2185, 7839, 2378, 7779, 2570, 7713, 2760, 7643, 2948, 7568, + 3135, 7489, 3320, 7405, 3503, 7317, 3683, 7225, 3862, 7128, 4038, + 7027, 4212, 6921, 4383, 6811, 4551, 6698, 4717, 6580, 4880, 6458, + 5040, 6333, 5197, 6203, 5351, 6070, 5501, 5933, 5649, 5793, 5793, + } +}; + #endif // HAVE_NEON void av1_round_shift_array_c(int32_t *arr, int size, int bit) {
diff --git a/av1/common/av1_txfm.h b/av1/common/av1_txfm.h index 8b7e174..7ad70af 100644 --- a/av1/common/av1_txfm.h +++ b/av1/common/av1_txfm.h
@@ -52,14 +52,16 @@ return av1_sinpi_arr_data[n - cos_bit_min]; } -// The reduced bit-width arrays are only used in the Arm Neon implementations -// in av1_fwd_txfm2d_neon.c for now. +// The reduced bit-width and permuted arrays are only used in the Arm Neon +// implementations in av1_fwd_txfm2d_neon.c and highbd_fwd_txfm_neon.c for now. #if HAVE_NEON // Store cospi/sinpi costants in Q2.13 format. // See: https://en.wikipedia.org/wiki/Q_(number_format) extern const int16_t av1_cospi_arr_q13_data[4][128]; extern const int16_t av1_sinpi_arr_q13_data[4][4]; +extern const int32_t av1_cospi_arr_s32_data[4][66]; + static INLINE const int16_t *cospi_arr_q13(int n) { return av1_cospi_arr_q13_data[n - cos_bit_min]; } @@ -67,6 +69,10 @@ static INLINE const int16_t *sinpi_arr_q13(int n) { return av1_sinpi_arr_q13_data[n - cos_bit_min]; } + +static INLINE const int32_t *cospi_arr_s32(int n) { + return av1_cospi_arr_s32_data[n - cos_bit_min]; +} #endif // HAVE_NEON static INLINE int32_t range_check_value(int32_t value, int8_t bit) {
diff --git a/av1/encoder/arm/neon/highbd_fwd_txfm_neon.c b/av1/encoder/arm/neon/highbd_fwd_txfm_neon.c index 6898b74..9190648 100644 --- a/av1/encoder/arm/neon/highbd_fwd_txfm_neon.c +++ b/av1/encoder/arm/neon/highbd_fwd_txfm_neon.c
@@ -58,54 +58,48 @@ // out0 | (lane 0) (lane 3) ==> out0 = in0 * w0 + in1 * (w0-1) // out1 | (lane 2) (lane 1) ==> out1 = in0 * -w0 + in1 * (1-w0) -static INLINE int32x4_t butterfly_half_neon(const int32_t w0, - const int32x4_t n0, - const int32_t w1, - const int32x4_t n1, - const int32x4_t v_bit) { - int32x4_t x = vmulq_n_s32(n0, w0); - x = vmlaq_n_s32(x, n1, w1); - return vrshlq_s32(x, v_bit); -} +#define butterfly_half_neon(wvec, lane0, lane1, in0, in1, out, v_bit) \ + do { \ + int32x2x2_t wvecs = { { wvec, vneg_s32(wvec) } }; \ + int32x4_t x = vmulq_lane_s32(n0, wvecs.val[lane0 / 2], lane0 % 2); \ + x = vmlaq_lane_s32(x, n1, wvecs.val[lane1 / 2], lane1 % 2); \ + *out = vrshlq_s32(x, v_bit); \ + } while (false) static INLINE void butterfly_0112_neon(const int32_t *cospi, const int widx0, const int32x4_t n0, const int32x4_t n1, int32x4_t *out0, int32x4_t *out1, const int32x4_t v_bit) { - int32_t w0 = cospi[widx0]; - int32_t w1 = cospi[64 - widx0]; - *out0 = butterfly_half_neon(w0, n0, w1, n1, v_bit); - *out1 = butterfly_half_neon(w1, n0, -w0, n1, v_bit); + int32x2_t w01 = vld1_s32(cospi + 2 * widx0); + butterfly_half_neon(w01, 0, 1, n0, n1, out0, v_bit); + butterfly_half_neon(w01, 1, 2, n0, n1, out1, v_bit); } static INLINE void butterfly_2312_neon(const int32_t *cospi, const int widx0, const int32x4_t n0, const int32x4_t n1, int32x4_t *out0, int32x4_t *out1, const int32x4_t v_bit) { - int32_t w0 = cospi[widx0]; - int32_t w1 = cospi[64 - widx0]; - *out0 = butterfly_half_neon(-w0, n0, -w1, n1, v_bit); - *out1 = butterfly_half_neon(w1, n0, -w0, n1, v_bit); + int32x2_t w01 = vld1_s32(cospi + 2 * widx0); + butterfly_half_neon(w01, 2, 3, n0, n1, out0, v_bit); + butterfly_half_neon(w01, 1, 2, n0, n1, out1, v_bit); } static INLINE void butterfly_2330_neon(const int32_t *cospi, const int widx0, const int32x4_t n0, const int32x4_t n1, int32x4_t *out0, int32x4_t *out1, const int32x4_t v_bit) { - int32_t w0 = cospi[widx0]; - int32_t w1 = cospi[64 - widx0]; - *out0 = butterfly_half_neon(-w0, n0, -w1, n1, v_bit); - *out1 = butterfly_half_neon(-w1, n0, w0, n1, v_bit); + int32x2_t w01 = vld1_s32(cospi + 2 * widx0); + butterfly_half_neon(w01, 2, 3, n0, n1, out0, v_bit); + butterfly_half_neon(w01, 3, 0, n0, n1, out1, v_bit); } static INLINE void butterfly_0130_neon(const int32_t *cospi, const int widx0, const int32x4_t n0, const int32x4_t n1, int32x4_t *out0, int32x4_t *out1, const int32x4_t v_bit) { - int32_t w0 = cospi[widx0]; - int32_t w1 = cospi[64 - widx0]; - *out0 = butterfly_half_neon(w0, n0, w1, n1, v_bit); - *out1 = butterfly_half_neon(-w1, n0, w0, n1, v_bit); + int32x2_t w01 = vld1_s32(cospi + 2 * widx0); + butterfly_half_neon(w01, 0, 1, n0, n1, out0, v_bit); + butterfly_half_neon(w01, 3, 0, n0, n1, out1, v_bit); } static INLINE void av1_round_shift_rect_array_32_neon(const int32x4_t *input, @@ -239,10 +233,9 @@ #endif // !CONFIG_REALTIME_ONLY static void fdct4x4_neon(int32x4_t *in, int32x4_t *out, int bit) { - const int32_t *const cospi = cospi_arr(bit); - const int32x4_t cospi32 = vdupq_n_s32(cospi[32]); - const int32x4_t cospi48 = vdupq_n_s32(cospi[48]); - const int32x4_t cospi16 = vdupq_n_s32(cospi[16]); + const int32_t *const cospi = cospi_arr_s32(bit); + const int32x4_t cospi32 = vdupq_n_s32(cospi[2 * 32]); + const int32x2_t cospi16_48 = vld1_s32(&cospi[2 * 16]); const int32x4_t a0 = vaddq_s32(in[0], in[3]); const int32x4_t a1 = vsubq_s32(in[0], in[3]); @@ -250,14 +243,14 @@ const int32x4_t a3 = vsubq_s32(in[1], in[2]); const int32x4_t b0 = vmulq_s32(a0, cospi32); - const int32x4_t b1 = vmulq_s32(a1, cospi48); + const int32x4_t b1 = vmulq_lane_s32(a1, cospi16_48, 1); const int32x4_t b2 = vmulq_s32(a2, cospi32); - const int32x4_t b3 = vmulq_s32(a3, cospi48); + const int32x4_t b3 = vmulq_lane_s32(a3, cospi16_48, 1); const int32x4_t c0 = vaddq_s32(b0, b2); const int32x4_t c1 = vsubq_s32(b0, b2); - const int32x4_t c2 = vmlaq_s32(b3, a1, cospi16); - const int32x4_t c3 = vmlsq_s32(b1, a3, cospi16); + const int32x4_t c2 = vmlaq_lane_s32(b3, a1, cospi16_48, 0); + const int32x4_t c3 = vmlsq_lane_s32(b1, a3, cospi16_48, 0); const int32x4_t v_bit = vdupq_n_s32(-bit); const int32x4_t d0 = vrshlq_s32(c0, v_bit); @@ -440,7 +433,13 @@ } static void fdct4x8_neon(int32x4_t *in, int32x4_t *out, int bit) { - const int32_t *const cospi = cospi_arr(bit); + const int32_t *const cospi = cospi_arr_s32(bit); + const int32x4_t cospi32 = vdupq_n_s32(cospi[2 * 32]); + + const int32x2_t cospi8_56 = vld1_s32(&cospi[2 * 8]); + const int32x2_t cospi16_48 = vld1_s32(&cospi[2 * 16]); + const int32x2_t cospi24_40 = vld1_s32(&cospi[2 * 24]); + const int32x4_t v_bit = vdupq_n_s32(-bit); int32x4_t u[8], v[8]; @@ -460,18 +459,18 @@ v[1] = vaddq_s32(u[1], u[2]); v[2] = vsubq_s32(u[1], u[2]); - v[5] = vmulq_n_s32(u[6], cospi[32]); - v[5] = vmlsq_n_s32(v[5], u[5], cospi[32]); + v[5] = vmulq_s32(u[6], cospi32); + v[5] = vmlsq_s32(v[5], u[5], cospi32); v[5] = vrshlq_s32(v[5], v_bit); - u[0] = vmulq_n_s32(u[5], cospi[32]); - v[6] = vmlaq_n_s32(u[0], u[6], cospi[32]); + u[0] = vmulq_s32(u[5], cospi32); + v[6] = vmlaq_s32(u[0], u[6], cospi32); v[6] = vrshlq_s32(v[6], v_bit); // stage 3 // type 0 - v[0] = vmulq_n_s32(v[0], cospi[32]); - v[1] = vmulq_n_s32(v[1], cospi[32]); + v[0] = vmulq_s32(v[0], cospi32); + v[1] = vmulq_s32(v[1], cospi32); u[0] = vaddq_s32(v[0], v[1]); u[0] = vrshlq_s32(u[0], v_bit); @@ -479,12 +478,12 @@ u[1] = vrshlq_s32(u[1], v_bit); // type 1 - v[0] = vmulq_n_s32(v[2], cospi[48]); - u[2] = vmlaq_n_s32(v[0], v[3], cospi[16]); + v[0] = vmulq_lane_s32(v[2], cospi16_48, 1); + u[2] = vmlaq_lane_s32(v[0], v[3], cospi16_48, 0); u[2] = vrshlq_s32(u[2], v_bit); - v[1] = vmulq_n_s32(v[3], cospi[48]); - u[3] = vmlsq_n_s32(v[1], v[2], cospi[16]); + v[1] = vmulq_lane_s32(v[3], cospi16_48, 1); + u[3] = vmlsq_lane_s32(v[1], v[2], cospi16_48, 0); u[3] = vrshlq_s32(u[3], v_bit); u[4] = vaddq_s32(v[4], v[5]); @@ -493,20 +492,20 @@ u[7] = vaddq_s32(v[7], v[6]); // stage 4-5 - v[0] = vmulq_n_s32(u[4], cospi[56]); - v[0] = vmlaq_n_s32(v[0], u[7], cospi[8]); + v[0] = vmulq_lane_s32(u[4], cospi8_56, 1); + v[0] = vmlaq_lane_s32(v[0], u[7], cospi8_56, 0); out[1] = vrshlq_s32(v[0], v_bit); - v[1] = vmulq_n_s32(u[7], cospi[56]); - v[0] = vmlsq_n_s32(v[1], u[4], cospi[8]); + v[1] = vmulq_lane_s32(u[7], cospi8_56, 1); + v[0] = vmlsq_lane_s32(v[1], u[4], cospi8_56, 0); out[7] = vrshlq_s32(v[0], v_bit); - v[0] = vmulq_n_s32(u[5], cospi[24]); - v[0] = vmlaq_n_s32(v[0], u[6], cospi[40]); + v[0] = vmulq_lane_s32(u[5], cospi24_40, 0); + v[0] = vmlaq_lane_s32(v[0], u[6], cospi24_40, 1); out[5] = vrshlq_s32(v[0], v_bit); - v[1] = vmulq_n_s32(u[6], cospi[24]); - v[0] = vmlsq_n_s32(v[1], u[5], cospi[40]); + v[1] = vmulq_lane_s32(u[6], cospi24_40, 0); + v[0] = vmlsq_lane_s32(v[1], u[5], cospi24_40, 1); out[3] = vrshlq_s32(v[0], v_bit); out[0] = u[0]; @@ -516,7 +515,14 @@ } static void fadst4x8_neon(int32x4_t *in, int32x4_t *out, int bit) { - const int32_t *const cospi = cospi_arr(bit); + const int32_t *const cospi = cospi_arr_s32(bit); + const int32x4_t cospi32 = vdupq_n_s32(cospi[2 * 32]); + + const int32x2_t cospi4_60 = vld1_s32(&cospi[2 * 4]); + const int32x2_t cospi12_52 = vld1_s32(&cospi[2 * 12]); + const int32x2_t cospi16_48 = vld1_s32(&cospi[2 * 16]); + const int32x2_t cospi20_44 = vld1_s32(&cospi[2 * 20]); + const int32x2_t cospi28_36 = vld1_s32(&cospi[2 * 28]); const int32x4_t v_bit = vdupq_n_s32(-bit); int32x4_t u0, u1, u2, u3, u4, u5, u6, u7; @@ -537,8 +543,8 @@ v0 = u0; v1 = u1; - x = vmulq_n_s32(u2, cospi[32]); - y = vmulq_n_s32(u3, cospi[32]); + x = vmulq_s32(u2, cospi32); + y = vmulq_s32(u3, cospi32); v2 = vaddq_s32(x, y); v2 = vrshlq_s32(v2, v_bit); @@ -548,8 +554,8 @@ v4 = u4; v5 = u5; - x = vmulq_n_s32(u6, cospi[32]); - y = vmulq_n_s32(u7, cospi[32]); + x = vmulq_s32(u6, cospi32); + y = vmulq_s32(u7, cospi32); v6 = vaddq_s32(x, y); v6 = vrshlq_s32(v6, v_bit); @@ -572,20 +578,20 @@ v2 = u2; v3 = u3; - v4 = vmulq_n_s32(u4, cospi[16]); - v4 = vmlaq_n_s32(v4, u5, cospi[48]); + v4 = vmulq_lane_s32(u4, cospi16_48, 0); + v4 = vmlaq_lane_s32(v4, u5, cospi16_48, 1); v4 = vrshlq_s32(v4, v_bit); - v5 = vmulq_n_s32(u4, cospi[48]); - v5 = vmlsq_n_s32(v5, u5, cospi[16]); + v5 = vmulq_lane_s32(u4, cospi16_48, 1); + v5 = vmlsq_lane_s32(v5, u5, cospi16_48, 0); v5 = vrshlq_s32(v5, v_bit); - v6 = vmulq_n_s32(u7, cospi[16]); - v6 = vmlsq_n_s32(v6, u6, cospi[48]); + v6 = vmulq_lane_s32(u7, cospi16_48, 0); + v6 = vmlsq_lane_s32(v6, u6, cospi16_48, 1); v6 = vrshlq_s32(v6, v_bit); - v7 = vmulq_n_s32(u6, cospi[16]); - v7 = vmlaq_n_s32(v7, u7, cospi[48]); + v7 = vmulq_lane_s32(u6, cospi16_48, 0); + v7 = vmlaq_lane_s32(v7, u7, cospi16_48, 1); v7 = vrshlq_s32(v7, v_bit); // stage 5 @@ -599,36 +605,36 @@ u7 = vsubq_s32(v3, v7); // stage 6 - v0 = vmulq_n_s32(u0, cospi[4]); - v0 = vmlaq_n_s32(v0, u1, cospi[60]); + v0 = vmulq_lane_s32(u0, cospi4_60, 0); + v0 = vmlaq_lane_s32(v0, u1, cospi4_60, 1); v0 = vrshlq_s32(v0, v_bit); - v1 = vmulq_n_s32(u0, cospi[60]); - v1 = vmlsq_n_s32(v1, u1, cospi[4]); + v1 = vmulq_lane_s32(u0, cospi4_60, 1); + v1 = vmlsq_lane_s32(v1, u1, cospi4_60, 0); v1 = vrshlq_s32(v1, v_bit); - v2 = vmulq_n_s32(u2, cospi[20]); - v2 = vmlaq_n_s32(v2, u3, cospi[44]); + v2 = vmulq_lane_s32(u2, cospi20_44, 0); + v2 = vmlaq_lane_s32(v2, u3, cospi20_44, 1); v2 = vrshlq_s32(v2, v_bit); - v3 = vmulq_n_s32(u2, cospi[44]); - v3 = vmlsq_n_s32(v3, u3, cospi[20]); + v3 = vmulq_lane_s32(u2, cospi20_44, 1); + v3 = vmlsq_lane_s32(v3, u3, cospi20_44, 0); v3 = vrshlq_s32(v3, v_bit); - v4 = vmulq_n_s32(u4, cospi[36]); - v4 = vmlaq_n_s32(v4, u5, cospi[28]); + v4 = vmulq_lane_s32(u4, cospi28_36, 1); + v4 = vmlaq_lane_s32(v4, u5, cospi28_36, 0); v4 = vrshlq_s32(v4, v_bit); - v5 = vmulq_n_s32(u4, cospi[28]); - v5 = vmlsq_n_s32(v5, u5, cospi[36]); + v5 = vmulq_lane_s32(u4, cospi28_36, 0); + v5 = vmlsq_lane_s32(v5, u5, cospi28_36, 1); v5 = vrshlq_s32(v5, v_bit); - x = vmulq_n_s32(u6, cospi[52]); - v6 = vmlaq_n_s32(x, u7, cospi[12]); + x = vmulq_lane_s32(u6, cospi12_52, 1); + v6 = vmlaq_lane_s32(x, u7, cospi12_52, 0); v6 = vrshlq_s32(v6, v_bit); - v7 = vmulq_n_s32(u6, cospi[12]); - v7 = vmlsq_n_s32(v7, u7, cospi[52]); + v7 = vmulq_lane_s32(u6, cospi12_52, 0); + v7 = vmlsq_lane_s32(v7, u7, cospi12_52, 1); v7 = vrshlq_s32(v7, v_bit); // stage 7 @@ -822,7 +828,17 @@ static void fdct16x16_neon(int32x4_t *in, int32x4_t *out, int bit, const int howmany) { - const int32_t *const cospi = cospi_arr(bit); + const int32_t *const cospi = cospi_arr_s32(bit); + const int32x4_t cospi32 = vdupq_n_s32(cospi[2 * 32]); + + const int32x2_t cospi4_60 = vld1_s32(&cospi[2 * 4]); + const int32x2_t cospi8_56 = vld1_s32(&cospi[2 * 8]); + const int32x2_t cospi12_52 = vld1_s32(&cospi[2 * 12]); + const int32x2_t cospi16_48 = vld1_s32(&cospi[2 * 16]); + const int32x2_t cospi20_44 = vld1_s32(&cospi[2 * 20]); + const int32x2_t cospi24_40 = vld1_s32(&cospi[2 * 24]); + const int32x2_t cospi28_36 = vld1_s32(&cospi[2 * 28]); + const int32x4_t v_bit = vdupq_n_s32(-bit); int32x4_t u[16], v[16]; @@ -860,20 +876,20 @@ v[8] = u[8]; v[9] = u[9]; - v[10] = vmulq_n_s32(u[13], cospi[32]); - v[10] = vmlsq_n_s32(v[10], u[10], cospi[32]); + v[10] = vmulq_s32(u[13], cospi32); + v[10] = vmlsq_s32(v[10], u[10], cospi32); v[10] = vrshlq_s32(v[10], v_bit); - v[13] = vmulq_n_s32(u[10], cospi[32]); - v[13] = vmlaq_n_s32(v[13], u[13], cospi[32]); + v[13] = vmulq_s32(u[10], cospi32); + v[13] = vmlaq_s32(v[13], u[13], cospi32); v[13] = vrshlq_s32(v[13], v_bit); - v[11] = vmulq_n_s32(u[12], cospi[32]); - v[11] = vmlsq_n_s32(v[11], u[11], cospi[32]); + v[11] = vmulq_s32(u[12], cospi32); + v[11] = vmlsq_s32(v[11], u[11], cospi32); v[11] = vrshlq_s32(v[11], v_bit); - v[12] = vmulq_n_s32(u[11], cospi[32]); - v[12] = vmlaq_n_s32(v[12], u[12], cospi[32]); + v[12] = vmulq_s32(u[11], cospi32); + v[12] = vmlaq_s32(v[12], u[12], cospi32); v[12] = vrshlq_s32(v[12], v_bit); v[14] = u[14]; v[15] = u[15]; @@ -885,12 +901,12 @@ u[2] = vsubq_s32(v[1], v[2]); u[4] = v[4]; - u[5] = vmulq_n_s32(v[6], cospi[32]); - u[5] = vmlsq_n_s32(u[5], v[5], cospi[32]); + u[5] = vmulq_s32(v[6], cospi32); + u[5] = vmlsq_s32(u[5], v[5], cospi32); u[5] = vrshlq_s32(u[5], v_bit); - u[6] = vmulq_n_s32(v[5], cospi[32]); - u[6] = vmlaq_n_s32(u[6], v[6], cospi[32]); + u[6] = vmulq_s32(v[5], cospi32); + u[6] = vmlaq_s32(u[6], v[6], cospi32); u[6] = vrshlq_s32(u[6], v_bit); u[7] = v[7]; @@ -904,20 +920,20 @@ u[14] = vaddq_s32(v[14], v[13]); // stage 4 - u[0] = vmulq_n_s32(u[0], cospi[32]); - u[1] = vmulq_n_s32(u[1], cospi[32]); + u[0] = vmulq_s32(u[0], cospi32); + u[1] = vmulq_s32(u[1], cospi32); v[0] = vaddq_s32(u[0], u[1]); v[0] = vrshlq_s32(v[0], v_bit); v[1] = vsubq_s32(u[0], u[1]); v[1] = vrshlq_s32(v[1], v_bit); - v[2] = vmulq_n_s32(u[2], cospi[48]); - v[2] = vmlaq_n_s32(v[2], u[3], cospi[16]); + v[2] = vmulq_lane_s32(u[2], cospi16_48, 1); + v[2] = vmlaq_lane_s32(v[2], u[3], cospi16_48, 0); v[2] = vrshlq_s32(v[2], v_bit); - v[3] = vmulq_n_s32(u[3], cospi[48]); - v[3] = vmlsq_n_s32(v[3], u[2], cospi[16]); + v[3] = vmulq_lane_s32(u[3], cospi16_48, 1); + v[3] = vmlsq_lane_s32(v[3], u[2], cospi16_48, 0); v[3] = vrshlq_s32(v[3], v_bit); v[4] = vaddq_s32(u[4], u[5]); @@ -926,20 +942,20 @@ v[7] = vaddq_s32(u[7], u[6]); v[8] = u[8]; - v[9] = vmulq_n_s32(u[14], cospi[48]); - v[9] = vmlsq_n_s32(v[9], u[9], cospi[16]); + v[9] = vmulq_lane_s32(u[14], cospi16_48, 1); + v[9] = vmlsq_lane_s32(v[9], u[9], cospi16_48, 0); v[9] = vrshlq_s32(v[9], v_bit); - v[14] = vmulq_n_s32(u[9], cospi[48]); - v[14] = vmlaq_n_s32(v[14], u[14], cospi[16]); + v[14] = vmulq_lane_s32(u[9], cospi16_48, 1); + v[14] = vmlaq_lane_s32(v[14], u[14], cospi16_48, 0); v[14] = vrshlq_s32(v[14], v_bit); - v[10] = vmulq_n_s32(u[13], -cospi[16]); - v[10] = vmlsq_n_s32(v[10], u[10], cospi[48]); + v[10] = vmulq_lane_s32(u[13], vneg_s32(cospi16_48), 0); + v[10] = vmlsq_lane_s32(v[10], u[10], cospi16_48, 1); v[10] = vrshlq_s32(v[10], v_bit); - v[13] = vmulq_n_s32(u[10], -cospi[16]); - v[13] = vmlaq_n_s32(v[13], u[13], cospi[48]); + v[13] = vmulq_lane_s32(u[10], vneg_s32(cospi16_48), 0); + v[13] = vmlaq_lane_s32(v[13], u[13], cospi16_48, 1); v[13] = vrshlq_s32(v[13], v_bit); v[11] = u[11]; @@ -952,20 +968,20 @@ u[2] = v[2]; u[3] = v[3]; - u[4] = vmulq_n_s32(v[4], cospi[56]); - u[4] = vmlaq_n_s32(u[4], v[7], cospi[8]); + u[4] = vmulq_lane_s32(v[4], cospi8_56, 1); + u[4] = vmlaq_lane_s32(u[4], v[7], cospi8_56, 0); u[4] = vrshlq_s32(u[4], v_bit); - u[7] = vmulq_n_s32(v[7], cospi[56]); - u[7] = vmlsq_n_s32(u[7], v[4], cospi[8]); + u[7] = vmulq_lane_s32(v[7], cospi8_56, 1); + u[7] = vmlsq_lane_s32(u[7], v[4], cospi8_56, 0); u[7] = vrshlq_s32(u[7], v_bit); - u[5] = vmulq_n_s32(v[5], cospi[24]); - u[5] = vmlaq_n_s32(u[5], v[6], cospi[40]); + u[5] = vmulq_lane_s32(v[5], cospi24_40, 0); + u[5] = vmlaq_lane_s32(u[5], v[6], cospi24_40, 1); u[5] = vrshlq_s32(u[5], v_bit); - u[6] = vmulq_n_s32(v[6], cospi[24]); - u[6] = vmlsq_n_s32(u[6], v[5], cospi[40]); + u[6] = vmulq_lane_s32(v[6], cospi24_40, 0); + u[6] = vmlsq_lane_s32(u[6], v[5], cospi24_40, 1); u[6] = vrshlq_s32(u[6], v_bit); u[8] = vaddq_s32(v[8], v[9]); @@ -987,36 +1003,36 @@ v[6] = u[6]; v[7] = u[7]; - v[8] = vmulq_n_s32(u[8], cospi[60]); - v[8] = vmlaq_n_s32(v[8], u[15], cospi[4]); + v[8] = vmulq_lane_s32(u[8], cospi4_60, 1); + v[8] = vmlaq_lane_s32(v[8], u[15], cospi4_60, 0); v[8] = vrshlq_s32(v[8], v_bit); - v[15] = vmulq_n_s32(u[15], cospi[60]); - v[15] = vmlsq_n_s32(v[15], u[8], cospi[4]); + v[15] = vmulq_lane_s32(u[15], cospi4_60, 1); + v[15] = vmlsq_lane_s32(v[15], u[8], cospi4_60, 0); v[15] = vrshlq_s32(v[15], v_bit); - v[9] = vmulq_n_s32(u[9], cospi[28]); - v[9] = vmlaq_n_s32(v[9], u[14], cospi[36]); + v[9] = vmulq_lane_s32(u[9], cospi28_36, 0); + v[9] = vmlaq_lane_s32(v[9], u[14], cospi28_36, 1); v[9] = vrshlq_s32(v[9], v_bit); - v[14] = vmulq_n_s32(u[14], cospi[28]); - v[14] = vmlsq_n_s32(v[14], u[9], cospi[36]); + v[14] = vmulq_lane_s32(u[14], cospi28_36, 0); + v[14] = vmlsq_lane_s32(v[14], u[9], cospi28_36, 1); v[14] = vrshlq_s32(v[14], v_bit); - v[10] = vmulq_n_s32(u[10], cospi[44]); - v[10] = vmlaq_n_s32(v[10], u[13], cospi[20]); + v[10] = vmulq_lane_s32(u[10], cospi20_44, 1); + v[10] = vmlaq_lane_s32(v[10], u[13], cospi20_44, 0); v[10] = vrshlq_s32(v[10], v_bit); - v[13] = vmulq_n_s32(u[13], cospi[44]); - v[13] = vmlsq_n_s32(v[13], u[10], cospi[20]); + v[13] = vmulq_lane_s32(u[13], cospi20_44, 1); + v[13] = vmlsq_lane_s32(v[13], u[10], cospi20_44, 0); v[13] = vrshlq_s32(v[13], v_bit); - v[11] = vmulq_n_s32(u[11], cospi[12]); - v[11] = vmlaq_n_s32(v[11], u[12], cospi[52]); + v[11] = vmulq_lane_s32(u[11], cospi12_52, 0); + v[11] = vmlaq_lane_s32(v[11], u[12], cospi12_52, 1); v[11] = vrshlq_s32(v[11], v_bit); - v[12] = vmulq_n_s32(u[12], cospi[12]); - v[12] = vmlsq_n_s32(v[12], u[11], cospi[52]); + v[12] = vmulq_lane_s32(u[12], cospi12_52, 0); + v[12] = vmlsq_lane_s32(v[12], u[11], cospi12_52, 1); v[12] = vrshlq_s32(v[12], v_bit); out[0 + col * stride] = v[0]; @@ -1040,7 +1056,9 @@ static void fadst16x16_neon(int32x4_t *in, int32x4_t *out, int bit, int howmany) { - const int32_t *const cospi = cospi_arr(bit); + const int32_t *const cospi = cospi_arr_s32(bit); + const int32x4_t cospi32 = vdupq_n_s32(cospi[2 * 32]); + const int32x4_t v_bit = vdupq_n_s32(-bit); int32x4_t u[16], v[16], x, y; @@ -1068,8 +1086,8 @@ v[0] = u[0]; v[1] = u[1]; - x = vmulq_n_s32(u[2], cospi[32]); - y = vmulq_n_s32(u[3], cospi[32]); + x = vmulq_s32(u[2], cospi32); + y = vmulq_s32(u[3], cospi32); v[2] = vaddq_s32(x, y); v[2] = vrshlq_s32(v[2], v_bit); @@ -1079,8 +1097,8 @@ v[4] = u[4]; v[5] = u[5]; - x = vmulq_n_s32(u[6], cospi[32]); - y = vmulq_n_s32(u[7], cospi[32]); + x = vmulq_s32(u[6], cospi32); + y = vmulq_s32(u[7], cospi32); v[6] = vaddq_s32(x, y); v[6] = vrshlq_s32(v[6], v_bit); @@ -1090,8 +1108,8 @@ v[8] = u[8]; v[9] = u[9]; - x = vmulq_n_s32(u[10], cospi[32]); - y = vmulq_n_s32(u[11], cospi[32]); + x = vmulq_s32(u[10], cospi32); + y = vmulq_s32(u[11], cospi32); v[10] = vaddq_s32(x, y); v[10] = vrshlq_s32(v[10], v_bit); @@ -1101,8 +1119,8 @@ v[12] = u[12]; v[13] = u[13]; - x = vmulq_n_s32(u[14], cospi[32]); - y = vmulq_n_s32(u[15], cospi[32]); + x = vmulq_s32(u[14], cospi32); + y = vmulq_s32(u[15], cospi32); v[14] = vaddq_s32(x, y); v[14] = vrshlq_s32(v[14], v_bit); @@ -1560,7 +1578,7 @@ }; void av1_fdct32_new_neon(int32x4_t *input, int32x4_t *output, int cos_bit) { - const int32_t *const cospi = cospi_arr(cos_bit); + const int32_t *const cospi = cospi_arr_s32(cos_bit); const int32x4_t v_cos_bit = vdupq_n_s32(-cos_bit); // Workspaces for intermediate transform steps. @@ -2198,7 +2216,7 @@ static void av1_fdct64_new_neon(int32x4_t *input, int32x4_t *output, int8_t cos_bit) { - const int32_t *const cospi = cospi_arr(cos_bit); + const int32_t *const cospi = cospi_arr_s32(cos_bit); const int32x4_t v_cos_bit = vdupq_n_s32(-cos_bit); // stage 1-2-3-4-5