mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
audioconvert: tweak conversion constants
Tweak the conversion constants a bit so that they handle the extreme ranges a bit better. Align the C and vector instructions. Reactivate the unit test asserts when a conversion fails.
This commit is contained in:
parent
e3951cc1f1
commit
22317da685
4 changed files with 237 additions and 227 deletions
|
|
@ -353,7 +353,7 @@ conv_s32_to_f32d_4s_avx2(void *data, void * SPA_RESTRICT dst[], const void * SPA
|
|||
float *d0 = dst[0], *d1 = dst[1], *d2 = dst[2], *d3 = dst[3];
|
||||
uint32_t n, unrolled;
|
||||
__m256i in[4], t[4];
|
||||
__m256 out[4], factor = _mm256_set1_ps(1.0f / S24_SCALE);
|
||||
__m256 out[4], factor = _mm256_set1_ps(1.0f / S32_SCALE);
|
||||
__m256i mask1 = _mm256_setr_epi64x(0*n_channels, 0*n_channels+2, 4*n_channels, 4*n_channels+2);
|
||||
__m256i mask2 = _mm256_setr_epi64x(1*n_channels, 1*n_channels+2, 5*n_channels, 5*n_channels+2);
|
||||
__m256i mask3 = _mm256_setr_epi64x(2*n_channels, 2*n_channels+2, 6*n_channels, 6*n_channels+2);
|
||||
|
|
@ -373,11 +373,6 @@ conv_s32_to_f32d_4s_avx2(void *data, void * SPA_RESTRICT dst[], const void * SPA
|
|||
in[2] = _mm256_i64gather_epi64((long long int *)&s[0*n_channels], mask3, 4);
|
||||
in[3] = _mm256_i64gather_epi64((long long int *)&s[0*n_channels], mask4, 4);
|
||||
|
||||
in[0] = _mm256_srai_epi32(in[0], 8); /* a0 b0 c0 d0 a4 b4 c4 d4 */
|
||||
in[1] = _mm256_srai_epi32(in[1], 8); /* a1 b1 c1 d1 a5 b5 c5 d5 */
|
||||
in[2] = _mm256_srai_epi32(in[2], 8); /* a2 b2 c2 d2 a6 b6 c6 d6 */
|
||||
in[3] = _mm256_srai_epi32(in[3], 8); /* a3 b3 c3 d3 a7 b7 c7 d7 */
|
||||
|
||||
t[0] = _mm256_unpacklo_epi32(in[0], in[1]); /* a0 a1 b0 b1 a4 a5 b4 b5 */
|
||||
t[1] = _mm256_unpackhi_epi32(in[0], in[1]); /* c0 c1 d0 d1 c4 c5 d4 d5 */
|
||||
t[2] = _mm256_unpacklo_epi32(in[2], in[3]); /* a2 a3 b2 b3 a6 a7 b6 b7 */
|
||||
|
|
@ -405,11 +400,11 @@ conv_s32_to_f32d_4s_avx2(void *data, void * SPA_RESTRICT dst[], const void * SPA
|
|||
s += 8*n_channels;
|
||||
}
|
||||
for(; n < n_samples; n++) {
|
||||
__m128 out[4], factor = _mm_set1_ps(1.0f / S24_SCALE);
|
||||
out[0] = _mm_cvtsi32_ss(factor, s[0]>>8);
|
||||
out[1] = _mm_cvtsi32_ss(factor, s[1]>>8);
|
||||
out[2] = _mm_cvtsi32_ss(factor, s[2]>>8);
|
||||
out[3] = _mm_cvtsi32_ss(factor, s[3]>>8);
|
||||
__m128 out[4], factor = _mm_set1_ps(1.0f / S32_SCALE);
|
||||
out[0] = _mm_cvtsi32_ss(factor, s[0]);
|
||||
out[1] = _mm_cvtsi32_ss(factor, s[1]);
|
||||
out[2] = _mm_cvtsi32_ss(factor, s[2]);
|
||||
out[3] = _mm_cvtsi32_ss(factor, s[3]);
|
||||
out[0] = _mm_mul_ss(out[0], factor);
|
||||
out[1] = _mm_mul_ss(out[1], factor);
|
||||
out[2] = _mm_mul_ss(out[2], factor);
|
||||
|
|
@ -430,7 +425,7 @@ conv_s32_to_f32d_2s_avx2(void *data, void * SPA_RESTRICT dst[], const void * SPA
|
|||
float *d0 = dst[0], *d1 = dst[1];
|
||||
uint32_t n, unrolled;
|
||||
__m256i in[4], t[4];
|
||||
__m256 out[4], factor = _mm256_set1_ps(1.0f / S24_SCALE);
|
||||
__m256 out[4], factor = _mm256_set1_ps(1.0f / S32_SCALE);
|
||||
__m256i perm = _mm256_setr_epi32(0, 2, 4, 6, 1, 3, 5, 7);
|
||||
__m256i mask1 = _mm256_setr_epi64x(0*n_channels, 1*n_channels, 2*n_channels, 3*n_channels);
|
||||
__m256i mask2 = _mm256_setr_epi64x(4*n_channels, 5*n_channels, 6*n_channels, 7*n_channels);
|
||||
|
|
@ -445,9 +440,6 @@ conv_s32_to_f32d_2s_avx2(void *data, void * SPA_RESTRICT dst[], const void * SPA
|
|||
in[0] = _mm256_i64gather_epi64((long long int *)s, mask1, 4);
|
||||
in[1] = _mm256_i64gather_epi64((long long int *)s, mask2, 4);
|
||||
|
||||
in[0] = _mm256_srai_epi32(in[0], 8);
|
||||
in[1] = _mm256_srai_epi32(in[1], 8);
|
||||
|
||||
t[0] = _mm256_permutevar8x32_epi32(in[0], perm);
|
||||
t[1] = _mm256_permutevar8x32_epi32(in[1], perm);
|
||||
|
||||
|
|
@ -466,9 +458,9 @@ conv_s32_to_f32d_2s_avx2(void *data, void * SPA_RESTRICT dst[], const void * SPA
|
|||
s += 8*n_channels;
|
||||
}
|
||||
for(; n < n_samples; n++) {
|
||||
__m128 out[2], factor = _mm_set1_ps(1.0f / S24_SCALE);
|
||||
out[0] = _mm_cvtsi32_ss(factor, s[0]>>8);
|
||||
out[1] = _mm_cvtsi32_ss(factor, s[1]>>8);
|
||||
__m128 out[2], factor = _mm_set1_ps(1.0f / S32_SCALE);
|
||||
out[0] = _mm_cvtsi32_ss(factor, s[0]);
|
||||
out[1] = _mm_cvtsi32_ss(factor, s[1]);
|
||||
out[0] = _mm_mul_ss(out[0], factor);
|
||||
out[1] = _mm_mul_ss(out[1], factor);
|
||||
_mm_store_ss(&d0[n], out[0]);
|
||||
|
|
@ -485,7 +477,7 @@ conv_s32_to_f32d_1s_avx2(void *data, void * SPA_RESTRICT dst[], const void * SPA
|
|||
float *d0 = dst[0];
|
||||
uint32_t n, unrolled;
|
||||
__m256i in[2];
|
||||
__m256 out[2], factor = _mm256_set1_ps(1.0f / S24_SCALE);
|
||||
__m256 out[2], factor = _mm256_set1_ps(1.0f / S32_SCALE);
|
||||
__m256i mask1 = _mm256_setr_epi64x(0*n_channels, 1*n_channels, 2*n_channels, 3*n_channels);
|
||||
__m256i mask2 = _mm256_setr_epi64x(4*n_channels, 5*n_channels, 6*n_channels, 7*n_channels);
|
||||
|
||||
|
|
@ -502,9 +494,6 @@ conv_s32_to_f32d_1s_avx2(void *data, void * SPA_RESTRICT dst[], const void * SPA
|
|||
_mm256_i64gather_epi32(&s[ 8*n_channels], mask1, 4),
|
||||
_mm256_i64gather_epi32(&s[ 8*n_channels], mask2, 4));
|
||||
|
||||
in[0] = _mm256_srai_epi32(in[0], 8);
|
||||
in[1] = _mm256_srai_epi32(in[1], 8);
|
||||
|
||||
out[0] = _mm256_cvtepi32_ps(in[0]);
|
||||
out[1] = _mm256_cvtepi32_ps(in[1]);
|
||||
|
||||
|
|
@ -517,8 +506,8 @@ conv_s32_to_f32d_1s_avx2(void *data, void * SPA_RESTRICT dst[], const void * SPA
|
|||
s += 16*n_channels;
|
||||
}
|
||||
for(; n < n_samples; n++) {
|
||||
__m128 out, factor = _mm_set1_ps(1.0f / S24_SCALE);
|
||||
out = _mm_cvtsi32_ss(factor, s[0]>>8);
|
||||
__m128 out, factor = _mm_set1_ps(1.0f / S32_SCALE);
|
||||
out = _mm_cvtsi32_ss(factor, s[0]);
|
||||
out = _mm_mul_ss(out, factor);
|
||||
_mm_store_ss(&d0[n], out);
|
||||
s += n_channels;
|
||||
|
|
@ -560,7 +549,7 @@ conv_f32d_to_s32_1s_avx2(void *data, void * SPA_RESTRICT dst, const void * SPA_R
|
|||
for(n = 0; n < unrolled; n += 4) {
|
||||
in[0] = _mm_mul_ps(_mm_load_ps(&s0[n]), scale);
|
||||
in[0] = _mm_min_ps(in[0], int_max);
|
||||
out[0] = _mm_cvtps_epi32(in[0]);
|
||||
out[0] = _mm_cvttps_epi32(in[0]);
|
||||
out[1] = _mm_shuffle_epi32(out[0], _MM_SHUFFLE(0, 3, 2, 1));
|
||||
out[2] = _mm_shuffle_epi32(out[0], _MM_SHUFFLE(1, 0, 3, 2));
|
||||
out[3] = _mm_shuffle_epi32(out[0], _MM_SHUFFLE(2, 1, 0, 3));
|
||||
|
|
@ -605,8 +594,8 @@ conv_f32d_to_s32_2s_avx2(void *data, void * SPA_RESTRICT dst, const void * SPA_R
|
|||
in[0] = _mm256_min_ps(in[0], int_max);
|
||||
in[1] = _mm256_min_ps(in[1], int_max);
|
||||
|
||||
out[0] = _mm256_cvtps_epi32(in[0]); /* a0 a1 a2 a3 a4 a5 a6 a7 */
|
||||
out[1] = _mm256_cvtps_epi32(in[1]); /* b0 b1 b2 b3 b4 b5 b6 b7 */
|
||||
out[0] = _mm256_cvttps_epi32(in[0]); /* a0 a1 a2 a3 a4 a5 a6 a7 */
|
||||
out[1] = _mm256_cvttps_epi32(in[1]); /* b0 b1 b2 b3 b4 b5 b6 b7 */
|
||||
|
||||
t[0] = _mm256_unpacklo_epi32(out[0], out[1]); /* a0 b0 a1 b1 a4 b4 a5 b5 */
|
||||
t[1] = _mm256_unpackhi_epi32(out[0], out[1]); /* a2 b2 a3 b3 a6 b6 a7 b7 */
|
||||
|
|
@ -645,7 +634,7 @@ conv_f32d_to_s32_2s_avx2(void *data, void * SPA_RESTRICT dst, const void * SPA_R
|
|||
|
||||
in[0] = _mm_mul_ps(in[0], scale);
|
||||
in[0] = _mm_min_ps(in[0], int_max);
|
||||
out[0] = _mm_cvtps_epi32(in[0]);
|
||||
out[0] = _mm_cvttps_epi32(in[0]);
|
||||
_mm_storel_epi64((__m128i*)d, out[0]);
|
||||
d += n_channels;
|
||||
}
|
||||
|
|
@ -682,10 +671,10 @@ conv_f32d_to_s32_4s_avx2(void *data, void * SPA_RESTRICT dst, const void * SPA_R
|
|||
in[2] = _mm256_min_ps(in[2], int_max);
|
||||
in[3] = _mm256_min_ps(in[3], int_max);
|
||||
|
||||
out[0] = _mm256_cvtps_epi32(in[0]); /* a0 a1 a2 a3 a4 a5 a6 a7 */
|
||||
out[1] = _mm256_cvtps_epi32(in[1]); /* b0 b1 b2 b3 b4 b5 b6 b7 */
|
||||
out[2] = _mm256_cvtps_epi32(in[2]); /* c0 c1 c2 c3 c4 c5 c6 c7 */
|
||||
out[3] = _mm256_cvtps_epi32(in[3]); /* d0 d1 d2 d3 d4 d5 d6 d7 */
|
||||
out[0] = _mm256_cvttps_epi32(in[0]); /* a0 a1 a2 a3 a4 a5 a6 a7 */
|
||||
out[1] = _mm256_cvttps_epi32(in[1]); /* b0 b1 b2 b3 b4 b5 b6 b7 */
|
||||
out[2] = _mm256_cvttps_epi32(in[2]); /* c0 c1 c2 c3 c4 c5 c6 c7 */
|
||||
out[3] = _mm256_cvttps_epi32(in[3]); /* d0 d1 d2 d3 d4 d5 d6 d7 */
|
||||
|
||||
t[0] = _mm256_unpacklo_epi32(out[0], out[1]); /* a0 b0 a1 b1 a4 b4 a5 b5 */
|
||||
t[1] = _mm256_unpackhi_epi32(out[0], out[1]); /* a2 b2 a3 b3 a6 b6 a7 b7 */
|
||||
|
|
@ -724,7 +713,7 @@ conv_f32d_to_s32_4s_avx2(void *data, void * SPA_RESTRICT dst, const void * SPA_R
|
|||
|
||||
in[0] = _mm_mul_ps(in[0], scale);
|
||||
in[0] = _mm_min_ps(in[0], int_max);
|
||||
out[0] = _mm_cvtps_epi32(in[0]);
|
||||
out[0] = _mm_cvttps_epi32(in[0]);
|
||||
_mm_storeu_si128((__m128i*)d, out[0]);
|
||||
d += n_channels;
|
||||
}
|
||||
|
|
@ -754,8 +743,9 @@ conv_f32d_to_s16_1s_avx2(void *data, void * SPA_RESTRICT dst, const void * SPA_R
|
|||
uint32_t n, unrolled;
|
||||
__m128 in[2];
|
||||
__m128i out[2];
|
||||
__m128 int_max = _mm_set1_ps(S16_MAX_F);
|
||||
__m128 int_min = _mm_sub_ps(_mm_setzero_ps(), int_max);
|
||||
__m128 int_scale = _mm_set1_ps(S16_SCALE);
|
||||
__m128 int_max = _mm_set1_ps(S16_MAX);
|
||||
__m128 int_min = _mm_set1_ps(S16_MIN);
|
||||
|
||||
if (SPA_IS_ALIGNED(s0, 16))
|
||||
unrolled = n_samples & ~7;
|
||||
|
|
@ -763,10 +753,10 @@ conv_f32d_to_s16_1s_avx2(void *data, void * SPA_RESTRICT dst, const void * SPA_R
|
|||
unrolled = 0;
|
||||
|
||||
for(n = 0; n < unrolled; n += 8) {
|
||||
in[0] = _mm_mul_ps(_mm_load_ps(&s0[n]), int_max);
|
||||
in[1] = _mm_mul_ps(_mm_load_ps(&s0[n+4]), int_max);
|
||||
out[0] = _mm_cvtps_epi32(in[0]);
|
||||
out[1] = _mm_cvtps_epi32(in[1]);
|
||||
in[0] = _mm_mul_ps(_mm_load_ps(&s0[n]), int_scale);
|
||||
in[1] = _mm_mul_ps(_mm_load_ps(&s0[n+4]), int_scale);
|
||||
out[0] = _mm_cvttps_epi32(in[0]);
|
||||
out[1] = _mm_cvttps_epi32(in[1]);
|
||||
out[0] = _mm_packs_epi32(out[0], out[1]);
|
||||
|
||||
d[0*n_channels] = _mm_extract_epi16(out[0], 0);
|
||||
|
|
@ -780,7 +770,7 @@ conv_f32d_to_s16_1s_avx2(void *data, void * SPA_RESTRICT dst, const void * SPA_R
|
|||
d += 8*n_channels;
|
||||
}
|
||||
for(; n < n_samples; n++) {
|
||||
in[0] = _mm_mul_ss(_mm_load_ss(&s0[n]), int_max);
|
||||
in[0] = _mm_mul_ss(_mm_load_ss(&s0[n]), int_scale);
|
||||
in[0] = _mm_min_ss(int_max, _mm_max_ss(in[0], int_min));
|
||||
*d = _mm_cvtss_si32(in[0]);
|
||||
d += n_channels;
|
||||
|
|
@ -796,7 +786,7 @@ conv_f32d_to_s16_2s_avx2(void *data, void * SPA_RESTRICT dst, const void * SPA_R
|
|||
uint32_t n, unrolled;
|
||||
__m256 in[2];
|
||||
__m256i out[4], t[2];
|
||||
__m256 int_max = _mm256_set1_ps(S16_MAX_F);
|
||||
__m256 int_scale = _mm256_set1_ps(S16_SCALE);
|
||||
|
||||
if (SPA_IS_ALIGNED(s0, 32) &&
|
||||
SPA_IS_ALIGNED(s1, 32))
|
||||
|
|
@ -805,11 +795,11 @@ conv_f32d_to_s16_2s_avx2(void *data, void * SPA_RESTRICT dst, const void * SPA_R
|
|||
unrolled = 0;
|
||||
|
||||
for(n = 0; n < unrolled; n += 8) {
|
||||
in[0] = _mm256_mul_ps(_mm256_load_ps(&s0[n+0]), int_max);
|
||||
in[1] = _mm256_mul_ps(_mm256_load_ps(&s1[n+0]), int_max);
|
||||
in[0] = _mm256_mul_ps(_mm256_load_ps(&s0[n+0]), int_scale);
|
||||
in[1] = _mm256_mul_ps(_mm256_load_ps(&s1[n+0]), int_scale);
|
||||
|
||||
out[0] = _mm256_cvtps_epi32(in[0]); /* a0 a1 a2 a3 a4 a5 a6 a7 */
|
||||
out[1] = _mm256_cvtps_epi32(in[1]); /* b0 b1 b2 b3 b4 b5 b6 b7 */
|
||||
out[0] = _mm256_cvttps_epi32(in[0]); /* a0 a1 a2 a3 a4 a5 a6 a7 */
|
||||
out[1] = _mm256_cvttps_epi32(in[1]); /* b0 b1 b2 b3 b4 b5 b6 b7 */
|
||||
|
||||
t[0] = _mm256_unpacklo_epi32(out[0], out[1]); /* a0 b0 a1 b1 a4 b4 a5 b5 */
|
||||
t[1] = _mm256_unpackhi_epi32(out[0], out[1]); /* a2 b2 a3 b3 a6 b6 a7 b7 */
|
||||
|
|
@ -829,11 +819,12 @@ conv_f32d_to_s16_2s_avx2(void *data, void * SPA_RESTRICT dst, const void * SPA_R
|
|||
}
|
||||
for(; n < n_samples; n++) {
|
||||
__m128 in[2];
|
||||
__m128 int_max = _mm_set1_ps(S16_MAX_F);
|
||||
__m128 int_min = _mm_sub_ps(_mm_setzero_ps(), int_max);
|
||||
__m128 int_scale = _mm_set1_ps(S16_SCALE);
|
||||
__m128 int_max = _mm_set1_ps(S16_MAX);
|
||||
__m128 int_min = _mm_set1_ps(S16_MIN);
|
||||
|
||||
in[0] = _mm_mul_ss(_mm_load_ss(&s0[n]), int_max);
|
||||
in[1] = _mm_mul_ss(_mm_load_ss(&s1[n]), int_max);
|
||||
in[0] = _mm_mul_ss(_mm_load_ss(&s0[n]), int_scale);
|
||||
in[1] = _mm_mul_ss(_mm_load_ss(&s1[n]), int_scale);
|
||||
in[0] = _mm_min_ss(int_max, _mm_max_ss(in[0], int_min));
|
||||
in[1] = _mm_min_ss(int_max, _mm_max_ss(in[1], int_min));
|
||||
d[0] = _mm_cvtss_si32(in[0]);
|
||||
|
|
@ -851,7 +842,7 @@ conv_f32d_to_s16_4s_avx2(void *data, void * SPA_RESTRICT dst, const void * SPA_R
|
|||
uint32_t n, unrolled;
|
||||
__m256 in[4];
|
||||
__m256i out[4], t[4];
|
||||
__m256 int_max = _mm256_set1_ps(S16_MAX_F);
|
||||
__m256 int_scale = _mm256_set1_ps(S16_SCALE);
|
||||
|
||||
if (SPA_IS_ALIGNED(s0, 32) &&
|
||||
SPA_IS_ALIGNED(s1, 32) &&
|
||||
|
|
@ -862,15 +853,15 @@ conv_f32d_to_s16_4s_avx2(void *data, void * SPA_RESTRICT dst, const void * SPA_R
|
|||
unrolled = 0;
|
||||
|
||||
for(n = 0; n < unrolled; n += 8) {
|
||||
in[0] = _mm256_mul_ps(_mm256_load_ps(&s0[n]), int_max);
|
||||
in[1] = _mm256_mul_ps(_mm256_load_ps(&s1[n]), int_max);
|
||||
in[2] = _mm256_mul_ps(_mm256_load_ps(&s2[n]), int_max);
|
||||
in[3] = _mm256_mul_ps(_mm256_load_ps(&s3[n]), int_max);
|
||||
in[0] = _mm256_mul_ps(_mm256_load_ps(&s0[n]), int_scale);
|
||||
in[1] = _mm256_mul_ps(_mm256_load_ps(&s1[n]), int_scale);
|
||||
in[2] = _mm256_mul_ps(_mm256_load_ps(&s2[n]), int_scale);
|
||||
in[3] = _mm256_mul_ps(_mm256_load_ps(&s3[n]), int_scale);
|
||||
|
||||
t[0] = _mm256_cvtps_epi32(in[0]); /* a0 a1 a2 a3 a4 a5 a6 a7 */
|
||||
t[1] = _mm256_cvtps_epi32(in[1]); /* b0 b1 b2 b3 b4 b5 b6 b7 */
|
||||
t[2] = _mm256_cvtps_epi32(in[2]); /* c0 c1 c2 c3 c4 c5 c6 c7 */
|
||||
t[3] = _mm256_cvtps_epi32(in[3]); /* d0 d1 d2 d3 d4 d5 d6 d7 */
|
||||
t[0] = _mm256_cvttps_epi32(in[0]); /* a0 a1 a2 a3 a4 a5 a6 a7 */
|
||||
t[1] = _mm256_cvttps_epi32(in[1]); /* b0 b1 b2 b3 b4 b5 b6 b7 */
|
||||
t[2] = _mm256_cvttps_epi32(in[2]); /* c0 c1 c2 c3 c4 c5 c6 c7 */
|
||||
t[3] = _mm256_cvttps_epi32(in[3]); /* d0 d1 d2 d3 d4 d5 d6 d7 */
|
||||
|
||||
t[0] = _mm256_packs_epi32(t[0], t[2]); /* a0 a1 a2 a3 c0 c1 c2 c3 a4 a5 a6 a7 c4 c5 c6 c7 */
|
||||
t[1] = _mm256_packs_epi32(t[1], t[3]); /* b0 b1 b2 b3 d0 d1 d2 d3 b4 b5 b6 b7 d4 d5 d6 d7 */
|
||||
|
|
@ -905,13 +896,14 @@ conv_f32d_to_s16_4s_avx2(void *data, void * SPA_RESTRICT dst, const void * SPA_R
|
|||
}
|
||||
for(; n < n_samples; n++) {
|
||||
__m128 in[4];
|
||||
__m128 int_max = _mm_set1_ps(S16_MAX_F);
|
||||
__m128 int_min = _mm_sub_ps(_mm_setzero_ps(), int_max);
|
||||
__m128 int_scale = _mm_set1_ps(S16_SCALE);
|
||||
__m128 int_max = _mm_set1_ps(S16_MAX);
|
||||
__m128 int_min = _mm_set1_ps(S16_MIN);
|
||||
|
||||
in[0] = _mm_mul_ss(_mm_load_ss(&s0[n]), int_max);
|
||||
in[1] = _mm_mul_ss(_mm_load_ss(&s1[n]), int_max);
|
||||
in[2] = _mm_mul_ss(_mm_load_ss(&s2[n]), int_max);
|
||||
in[3] = _mm_mul_ss(_mm_load_ss(&s3[n]), int_max);
|
||||
in[0] = _mm_mul_ss(_mm_load_ss(&s0[n]), int_scale);
|
||||
in[1] = _mm_mul_ss(_mm_load_ss(&s1[n]), int_scale);
|
||||
in[2] = _mm_mul_ss(_mm_load_ss(&s2[n]), int_scale);
|
||||
in[3] = _mm_mul_ss(_mm_load_ss(&s3[n]), int_scale);
|
||||
in[0] = _mm_min_ss(int_max, _mm_max_ss(in[0], int_min));
|
||||
in[1] = _mm_min_ss(int_max, _mm_max_ss(in[1], int_min));
|
||||
in[2] = _mm_min_ss(int_max, _mm_max_ss(in[2], int_min));
|
||||
|
|
@ -948,7 +940,7 @@ conv_f32d_to_s16_4_avx2(struct convert *conv, void * SPA_RESTRICT dst[], const v
|
|||
uint32_t n, unrolled;
|
||||
__m256 in[4];
|
||||
__m256i out[4], t[4];
|
||||
__m256 int_max = _mm256_set1_ps(S16_MAX_F);
|
||||
__m256 int_scale = _mm256_set1_ps(S16_SCALE);
|
||||
|
||||
if (SPA_IS_ALIGNED(s0, 32) &&
|
||||
SPA_IS_ALIGNED(s1, 32) &&
|
||||
|
|
@ -959,15 +951,15 @@ conv_f32d_to_s16_4_avx2(struct convert *conv, void * SPA_RESTRICT dst[], const v
|
|||
unrolled = 0;
|
||||
|
||||
for(n = 0; n < unrolled; n += 8) {
|
||||
in[0] = _mm256_mul_ps(_mm256_load_ps(&s0[n]), int_max);
|
||||
in[1] = _mm256_mul_ps(_mm256_load_ps(&s1[n]), int_max);
|
||||
in[2] = _mm256_mul_ps(_mm256_load_ps(&s2[n]), int_max);
|
||||
in[3] = _mm256_mul_ps(_mm256_load_ps(&s3[n]), int_max);
|
||||
in[0] = _mm256_mul_ps(_mm256_load_ps(&s0[n]), int_scale);
|
||||
in[1] = _mm256_mul_ps(_mm256_load_ps(&s1[n]), int_scale);
|
||||
in[2] = _mm256_mul_ps(_mm256_load_ps(&s2[n]), int_scale);
|
||||
in[3] = _mm256_mul_ps(_mm256_load_ps(&s3[n]), int_scale);
|
||||
|
||||
t[0] = _mm256_cvtps_epi32(in[0]); /* a0 a1 a2 a3 a4 a5 a6 a7 */
|
||||
t[1] = _mm256_cvtps_epi32(in[1]); /* b0 b1 b2 b3 b4 b5 b6 b7 */
|
||||
t[2] = _mm256_cvtps_epi32(in[2]); /* c0 c1 c2 c3 c4 c5 c6 c7 */
|
||||
t[3] = _mm256_cvtps_epi32(in[3]); /* d0 d1 d2 d3 d4 d5 d6 d7 */
|
||||
t[0] = _mm256_cvttps_epi32(in[0]); /* a0 a1 a2 a3 a4 a5 a6 a7 */
|
||||
t[1] = _mm256_cvttps_epi32(in[1]); /* b0 b1 b2 b3 b4 b5 b6 b7 */
|
||||
t[2] = _mm256_cvttps_epi32(in[2]); /* c0 c1 c2 c3 c4 c5 c6 c7 */
|
||||
t[3] = _mm256_cvttps_epi32(in[3]); /* d0 d1 d2 d3 d4 d5 d6 d7 */
|
||||
|
||||
t[0] = _mm256_packs_epi32(t[0], t[2]); /* a0 a1 a2 a3 c0 c1 c2 c3 a4 a5 a6 a7 c4 c5 c6 c7 */
|
||||
t[1] = _mm256_packs_epi32(t[1], t[3]); /* b0 b1 b2 b3 d0 d1 d2 d3 b4 b5 b6 b7 d4 d5 d6 d7 */
|
||||
|
|
@ -987,13 +979,14 @@ conv_f32d_to_s16_4_avx2(struct convert *conv, void * SPA_RESTRICT dst[], const v
|
|||
}
|
||||
for(; n < n_samples; n++) {
|
||||
__m128 in[4];
|
||||
__m128 int_max = _mm_set1_ps(S16_MAX_F);
|
||||
__m128 int_min = _mm_sub_ps(_mm_setzero_ps(), int_max);
|
||||
__m128 int_scale = _mm_set1_ps(S16_SCALE);
|
||||
__m128 int_max = _mm_set1_ps(S16_MAX);
|
||||
__m128 int_min = _mm_set1_ps(S16_MIN);
|
||||
|
||||
in[0] = _mm_mul_ss(_mm_load_ss(&s0[n]), int_max);
|
||||
in[1] = _mm_mul_ss(_mm_load_ss(&s1[n]), int_max);
|
||||
in[2] = _mm_mul_ss(_mm_load_ss(&s2[n]), int_max);
|
||||
in[3] = _mm_mul_ss(_mm_load_ss(&s3[n]), int_max);
|
||||
in[0] = _mm_mul_ss(_mm_load_ss(&s0[n]), int_scale);
|
||||
in[1] = _mm_mul_ss(_mm_load_ss(&s1[n]), int_scale);
|
||||
in[2] = _mm_mul_ss(_mm_load_ss(&s2[n]), int_scale);
|
||||
in[3] = _mm_mul_ss(_mm_load_ss(&s3[n]), int_scale);
|
||||
in[0] = _mm_min_ss(int_max, _mm_max_ss(in[0], int_min));
|
||||
in[1] = _mm_min_ss(int_max, _mm_max_ss(in[1], int_min));
|
||||
in[2] = _mm_min_ss(int_max, _mm_max_ss(in[2], int_min));
|
||||
|
|
@ -1014,7 +1007,7 @@ conv_f32d_to_s16_2_avx2(struct convert *conv, void * SPA_RESTRICT dst[], const v
|
|||
uint32_t n, unrolled;
|
||||
__m256 in[4];
|
||||
__m256i out[4], t[4];
|
||||
__m256 int_max = _mm256_set1_ps(S16_MAX_F);
|
||||
__m256 int_scale = _mm256_set1_ps(S16_SCALE);
|
||||
|
||||
if (SPA_IS_ALIGNED(s0, 32) &&
|
||||
SPA_IS_ALIGNED(s1, 32))
|
||||
|
|
@ -1023,15 +1016,15 @@ conv_f32d_to_s16_2_avx2(struct convert *conv, void * SPA_RESTRICT dst[], const v
|
|||
unrolled = 0;
|
||||
|
||||
for(n = 0; n < unrolled; n += 16) {
|
||||
in[0] = _mm256_mul_ps(_mm256_load_ps(&s0[n+0]), int_max);
|
||||
in[1] = _mm256_mul_ps(_mm256_load_ps(&s1[n+0]), int_max);
|
||||
in[2] = _mm256_mul_ps(_mm256_load_ps(&s0[n+8]), int_max);
|
||||
in[3] = _mm256_mul_ps(_mm256_load_ps(&s1[n+8]), int_max);
|
||||
in[0] = _mm256_mul_ps(_mm256_load_ps(&s0[n+0]), int_scale);
|
||||
in[1] = _mm256_mul_ps(_mm256_load_ps(&s1[n+0]), int_scale);
|
||||
in[2] = _mm256_mul_ps(_mm256_load_ps(&s0[n+8]), int_scale);
|
||||
in[3] = _mm256_mul_ps(_mm256_load_ps(&s1[n+8]), int_scale);
|
||||
|
||||
out[0] = _mm256_cvtps_epi32(in[0]); /* a0 a1 a2 a3 a4 a5 a6 a7 */
|
||||
out[1] = _mm256_cvtps_epi32(in[1]); /* b0 b1 b2 b3 b4 b5 b6 b7 */
|
||||
out[2] = _mm256_cvtps_epi32(in[2]); /* a0 a1 a2 a3 a4 a5 a6 a7 */
|
||||
out[3] = _mm256_cvtps_epi32(in[3]); /* b0 b1 b2 b3 b4 b5 b6 b7 */
|
||||
out[0] = _mm256_cvttps_epi32(in[0]); /* a0 a1 a2 a3 a4 a5 a6 a7 */
|
||||
out[1] = _mm256_cvttps_epi32(in[1]); /* b0 b1 b2 b3 b4 b5 b6 b7 */
|
||||
out[2] = _mm256_cvttps_epi32(in[2]); /* a0 a1 a2 a3 a4 a5 a6 a7 */
|
||||
out[3] = _mm256_cvttps_epi32(in[3]); /* b0 b1 b2 b3 b4 b5 b6 b7 */
|
||||
|
||||
t[0] = _mm256_unpacklo_epi32(out[0], out[1]); /* a0 b0 a1 b1 a4 b4 a5 b5 */
|
||||
t[1] = _mm256_unpackhi_epi32(out[0], out[1]); /* a2 b2 a3 b3 a6 b6 a7 b7 */
|
||||
|
|
@ -1048,11 +1041,12 @@ conv_f32d_to_s16_2_avx2(struct convert *conv, void * SPA_RESTRICT dst[], const v
|
|||
}
|
||||
for(; n < n_samples; n++) {
|
||||
__m128 in[4];
|
||||
__m128 int_max = _mm_set1_ps(S16_MAX_F);
|
||||
__m128 int_min = _mm_sub_ps(_mm_setzero_ps(), int_max);
|
||||
__m128 int_scale = _mm_set1_ps(S16_SCALE);
|
||||
__m128 int_max = _mm_set1_ps(S16_MAX);
|
||||
__m128 int_min = _mm_set1_ps(S16_MIN);
|
||||
|
||||
in[0] = _mm_mul_ss(_mm_load_ss(&s0[n]), int_max);
|
||||
in[1] = _mm_mul_ss(_mm_load_ss(&s1[n]), int_max);
|
||||
in[0] = _mm_mul_ss(_mm_load_ss(&s0[n]), int_scale);
|
||||
in[1] = _mm_mul_ss(_mm_load_ss(&s1[n]), int_scale);
|
||||
in[0] = _mm_min_ss(int_max, _mm_max_ss(in[0], int_min));
|
||||
in[1] = _mm_min_ss(int_max, _mm_max_ss(in[1], int_min));
|
||||
d[0] = _mm_cvtss_si32(in[0]);
|
||||
|
|
|
|||
|
|
@ -338,7 +338,7 @@ conv_s32_to_f32d_1s_sse2(void *data, void * SPA_RESTRICT dst[], const void * SPA
|
|||
float *d0 = dst[0];
|
||||
uint32_t n, unrolled;
|
||||
__m128i in;
|
||||
__m128 out, factor = _mm_set1_ps(1.0f / S24_SCALE);
|
||||
__m128 out, factor = _mm_set1_ps(1.0f / S32_SCALE);
|
||||
|
||||
if (SPA_IS_ALIGNED(d0, 16))
|
||||
unrolled = n_samples & ~3;
|
||||
|
|
@ -350,14 +350,13 @@ conv_s32_to_f32d_1s_sse2(void *data, void * SPA_RESTRICT dst[], const void * SPA
|
|||
s[1*n_channels],
|
||||
s[2*n_channels],
|
||||
s[3*n_channels]);
|
||||
in = _mm_srai_epi32(in, 8);
|
||||
out = _mm_cvtepi32_ps(in);
|
||||
out = _mm_mul_ps(out, factor);
|
||||
_mm_store_ps(&d0[n], out);
|
||||
s += 4*n_channels;
|
||||
}
|
||||
for(; n < n_samples; n++) {
|
||||
out = _mm_cvtsi32_ss(factor, s[0]>>8);
|
||||
out = _mm_cvtsi32_ss(factor, s[0]);
|
||||
out = _mm_mul_ss(out, factor);
|
||||
_mm_store_ss(&d0[n], out);
|
||||
s += n_channels;
|
||||
|
|
@ -395,7 +394,7 @@ conv_f32d_to_s32_1s_sse2(void *data, void * SPA_RESTRICT dst, const void * SPA_R
|
|||
for(n = 0; n < unrolled; n += 4) {
|
||||
in[0] = _mm_mul_ps(_mm_load_ps(&s0[n]), scale);
|
||||
in[0] = _mm_min_ps(in[0], int_max);
|
||||
out[0] = _mm_cvtps_epi32(in[0]);
|
||||
out[0] = _mm_cvttps_epi32(in[0]);
|
||||
out[1] = _mm_shuffle_epi32(out[0], _MM_SHUFFLE(0, 3, 2, 1));
|
||||
out[2] = _mm_shuffle_epi32(out[0], _MM_SHUFFLE(1, 0, 3, 2));
|
||||
out[3] = _mm_shuffle_epi32(out[0], _MM_SHUFFLE(2, 1, 0, 3));
|
||||
|
|
@ -440,8 +439,8 @@ conv_f32d_to_s32_2s_sse2(void *data, void * SPA_RESTRICT dst, const void * SPA_R
|
|||
in[0] = _mm_min_ps(in[0], int_max);
|
||||
in[1] = _mm_min_ps(in[1], int_max);
|
||||
|
||||
out[0] = _mm_cvtps_epi32(in[0]);
|
||||
out[1] = _mm_cvtps_epi32(in[1]);
|
||||
out[0] = _mm_cvttps_epi32(in[0]);
|
||||
out[1] = _mm_cvttps_epi32(in[1]);
|
||||
|
||||
t[0] = _mm_unpacklo_epi32(out[0], out[1]);
|
||||
t[1] = _mm_unpackhi_epi32(out[0], out[1]);
|
||||
|
|
@ -460,7 +459,7 @@ conv_f32d_to_s32_2s_sse2(void *data, void * SPA_RESTRICT dst, const void * SPA_R
|
|||
|
||||
in[0] = _mm_mul_ps(in[0], scale);
|
||||
in[0] = _mm_min_ps(in[0], int_max);
|
||||
out[0] = _mm_cvtps_epi32(in[0]);
|
||||
out[0] = _mm_cvttps_epi32(in[0]);
|
||||
_mm_storel_epi64((__m128i*)d, out[0]);
|
||||
d += n_channels;
|
||||
}
|
||||
|
|
@ -499,10 +498,10 @@ conv_f32d_to_s32_4s_sse2(void *data, void * SPA_RESTRICT dst, const void * SPA_R
|
|||
|
||||
_MM_TRANSPOSE4_PS(in[0], in[1], in[2], in[3]);
|
||||
|
||||
out[0] = _mm_cvtps_epi32(in[0]);
|
||||
out[1] = _mm_cvtps_epi32(in[1]);
|
||||
out[2] = _mm_cvtps_epi32(in[2]);
|
||||
out[3] = _mm_cvtps_epi32(in[3]);
|
||||
out[0] = _mm_cvttps_epi32(in[0]);
|
||||
out[1] = _mm_cvttps_epi32(in[1]);
|
||||
out[2] = _mm_cvttps_epi32(in[2]);
|
||||
out[3] = _mm_cvttps_epi32(in[3]);
|
||||
|
||||
_mm_storeu_si128((__m128i*)(d + 0*n_channels), out[0]);
|
||||
_mm_storeu_si128((__m128i*)(d + 1*n_channels), out[1]);
|
||||
|
|
@ -522,7 +521,7 @@ conv_f32d_to_s32_4s_sse2(void *data, void * SPA_RESTRICT dst, const void * SPA_R
|
|||
|
||||
in[0] = _mm_mul_ps(in[0], scale);
|
||||
in[0] = _mm_min_ps(in[0], int_max);
|
||||
out[0] = _mm_cvtps_epi32(in[0]);
|
||||
out[0] = _mm_cvttps_epi32(in[0]);
|
||||
_mm_storeu_si128((__m128i*)d, out[0]);
|
||||
d += n_channels;
|
||||
}
|
||||
|
|
@ -590,7 +589,7 @@ conv_f32d_to_s32_1s_dither_sse2(struct convert *conv, void * SPA_RESTRICT dst, c
|
|||
in[0] = _mm_mul_ps(_mm_load_ps(&s[n]), scale);
|
||||
in[0] = _mm_add_ps(in[0], _mm_load_ps(&dither[n]));
|
||||
in[0] = _mm_min_ps(in[0], int_max);
|
||||
out[0] = _mm_cvtps_epi32(in[0]);
|
||||
out[0] = _mm_cvttps_epi32(in[0]);
|
||||
out[1] = _mm_shuffle_epi32(out[0], _MM_SHUFFLE(0, 3, 2, 1));
|
||||
out[2] = _mm_shuffle_epi32(out[0], _MM_SHUFFLE(1, 0, 3, 2));
|
||||
out[3] = _mm_shuffle_epi32(out[0], _MM_SHUFFLE(2, 1, 0, 3));
|
||||
|
|
@ -986,8 +985,9 @@ conv_f32_to_s16_1_sse2(void *data, void * SPA_RESTRICT dst, const void * SPA_RES
|
|||
uint32_t n, unrolled;
|
||||
__m128 in[2];
|
||||
__m128i out[2];
|
||||
__m128 int_max = _mm_set1_ps(S16_MAX_F);
|
||||
__m128 int_min = _mm_sub_ps(_mm_setzero_ps(), int_max);
|
||||
__m128 int_scale = _mm_set1_ps(S16_SCALE);
|
||||
__m128 int_max = _mm_set1_ps(S16_MAX);
|
||||
__m128 int_min = _mm_set1_ps(S16_MIN);
|
||||
|
||||
if (SPA_IS_ALIGNED(s, 16))
|
||||
unrolled = n_samples & ~7;
|
||||
|
|
@ -995,16 +995,16 @@ conv_f32_to_s16_1_sse2(void *data, void * SPA_RESTRICT dst, const void * SPA_RES
|
|||
unrolled = 0;
|
||||
|
||||
for(n = 0; n < unrolled; n += 8) {
|
||||
in[0] = _mm_mul_ps(_mm_load_ps(&s[n]), int_max);
|
||||
in[1] = _mm_mul_ps(_mm_load_ps(&s[n+4]), int_max);
|
||||
out[0] = _mm_cvtps_epi32(in[0]);
|
||||
out[1] = _mm_cvtps_epi32(in[1]);
|
||||
in[0] = _mm_mul_ps(_mm_load_ps(&s[n]), int_scale);
|
||||
in[1] = _mm_mul_ps(_mm_load_ps(&s[n+4]), int_scale);
|
||||
out[0] = _mm_cvttps_epi32(in[0]);
|
||||
out[1] = _mm_cvttps_epi32(in[1]);
|
||||
out[0] = _mm_packs_epi32(out[0], out[1]);
|
||||
_mm_storeu_si128((__m128i*)(d+0), out[0]);
|
||||
d += 8;
|
||||
}
|
||||
for(; n < n_samples; n++) {
|
||||
in[0] = _mm_mul_ss(_mm_load_ss(&s[n]), int_max);
|
||||
in[0] = _mm_mul_ss(_mm_load_ss(&s[n]), int_scale);
|
||||
in[0] = _mm_min_ss(int_max, _mm_max_ss(in[0], int_min));
|
||||
*d++ = _mm_cvtss_si32(in[0]);
|
||||
}
|
||||
|
|
@ -1035,8 +1035,9 @@ conv_f32d_to_s16_1s_sse2(void *data, void * SPA_RESTRICT dst, const void * SPA_R
|
|||
uint32_t n, unrolled;
|
||||
__m128 in[2];
|
||||
__m128i out[2];
|
||||
__m128 int_max = _mm_set1_ps(S16_MAX_F);
|
||||
__m128 int_min = _mm_sub_ps(_mm_setzero_ps(), int_max);
|
||||
__m128 int_scale = _mm_set1_ps(S16_SCALE);
|
||||
__m128 int_max = _mm_set1_ps(S16_MAX);
|
||||
__m128 int_min = _mm_set1_ps(S16_MIN);
|
||||
|
||||
if (SPA_IS_ALIGNED(s0, 16))
|
||||
unrolled = n_samples & ~7;
|
||||
|
|
@ -1044,10 +1045,10 @@ conv_f32d_to_s16_1s_sse2(void *data, void * SPA_RESTRICT dst, const void * SPA_R
|
|||
unrolled = 0;
|
||||
|
||||
for(n = 0; n < unrolled; n += 8) {
|
||||
in[0] = _mm_mul_ps(_mm_load_ps(&s0[n]), int_max);
|
||||
in[1] = _mm_mul_ps(_mm_load_ps(&s0[n+4]), int_max);
|
||||
out[0] = _mm_cvtps_epi32(in[0]);
|
||||
out[1] = _mm_cvtps_epi32(in[1]);
|
||||
in[0] = _mm_mul_ps(_mm_load_ps(&s0[n]), int_scale);
|
||||
in[1] = _mm_mul_ps(_mm_load_ps(&s0[n+4]), int_scale);
|
||||
out[0] = _mm_cvttps_epi32(in[0]);
|
||||
out[1] = _mm_cvttps_epi32(in[1]);
|
||||
out[0] = _mm_packs_epi32(out[0], out[1]);
|
||||
|
||||
d[0*n_channels] = _mm_extract_epi16(out[0], 0);
|
||||
|
|
@ -1061,9 +1062,9 @@ conv_f32d_to_s16_1s_sse2(void *data, void * SPA_RESTRICT dst, const void * SPA_R
|
|||
d += 8*n_channels;
|
||||
}
|
||||
for(; n < n_samples; n++) {
|
||||
in[0] = _mm_mul_ss(_mm_load_ss(&s0[n]), int_max);
|
||||
in[0] = _mm_mul_ss(_mm_load_ss(&s0[n]), int_scale);
|
||||
in[0] = _mm_min_ss(int_max, _mm_max_ss(in[0], int_min));
|
||||
*d = _mm_cvtss_si32(in[0]);
|
||||
*d = _mm_cvttss_si32(in[0]);
|
||||
d += n_channels;
|
||||
}
|
||||
}
|
||||
|
|
@ -1077,8 +1078,9 @@ conv_f32d_to_s16_2s_sse2(void *data, void * SPA_RESTRICT dst, const void * SPA_R
|
|||
uint32_t n, unrolled;
|
||||
__m128 in[2];
|
||||
__m128i out[4], t[2];
|
||||
__m128 int_max = _mm_set1_ps(S16_MAX_F);
|
||||
__m128 int_min = _mm_sub_ps(_mm_setzero_ps(), int_max);
|
||||
__m128 int_scale = _mm_set1_ps(S16_SCALE);
|
||||
__m128 int_max = _mm_set1_ps(S16_MAX);
|
||||
__m128 int_min = _mm_set1_ps(S16_MIN);
|
||||
|
||||
if (SPA_IS_ALIGNED(s0, 16) &&
|
||||
SPA_IS_ALIGNED(s1, 16))
|
||||
|
|
@ -1087,11 +1089,11 @@ conv_f32d_to_s16_2s_sse2(void *data, void * SPA_RESTRICT dst, const void * SPA_R
|
|||
unrolled = 0;
|
||||
|
||||
for(n = 0; n < unrolled; n += 4) {
|
||||
in[0] = _mm_mul_ps(_mm_load_ps(&s0[n]), int_max);
|
||||
in[1] = _mm_mul_ps(_mm_load_ps(&s1[n]), int_max);
|
||||
in[0] = _mm_mul_ps(_mm_load_ps(&s0[n]), int_scale);
|
||||
in[1] = _mm_mul_ps(_mm_load_ps(&s1[n]), int_scale);
|
||||
|
||||
t[0] = _mm_cvtps_epi32(in[0]);
|
||||
t[1] = _mm_cvtps_epi32(in[1]);
|
||||
t[0] = _mm_cvttps_epi32(in[0]);
|
||||
t[1] = _mm_cvttps_epi32(in[1]);
|
||||
|
||||
t[0] = _mm_packs_epi32(t[0], t[0]);
|
||||
t[1] = _mm_packs_epi32(t[1], t[1]);
|
||||
|
|
@ -1108,8 +1110,8 @@ conv_f32d_to_s16_2s_sse2(void *data, void * SPA_RESTRICT dst, const void * SPA_R
|
|||
d += 4*n_channels;
|
||||
}
|
||||
for(; n < n_samples; n++) {
|
||||
in[0] = _mm_mul_ss(_mm_load_ss(&s0[n]), int_max);
|
||||
in[1] = _mm_mul_ss(_mm_load_ss(&s1[n]), int_max);
|
||||
in[0] = _mm_mul_ss(_mm_load_ss(&s0[n]), int_scale);
|
||||
in[1] = _mm_mul_ss(_mm_load_ss(&s1[n]), int_scale);
|
||||
in[0] = _mm_min_ss(int_max, _mm_max_ss(in[0], int_min));
|
||||
in[1] = _mm_min_ss(int_max, _mm_max_ss(in[1], int_min));
|
||||
d[0] = _mm_cvtss_si32(in[0]);
|
||||
|
|
@ -1127,8 +1129,9 @@ conv_f32d_to_s16_4s_sse2(void *data, void * SPA_RESTRICT dst, const void * SPA_R
|
|||
uint32_t n, unrolled;
|
||||
__m128 in[4];
|
||||
__m128i out[4], t[4];
|
||||
__m128 int_max = _mm_set1_ps(S16_MAX_F);
|
||||
__m128 int_min = _mm_sub_ps(_mm_setzero_ps(), int_max);
|
||||
__m128 int_scale = _mm_set1_ps(S16_SCALE);
|
||||
__m128 int_max = _mm_set1_ps(S16_MAX);
|
||||
__m128 int_min = _mm_set1_ps(S16_MIN);
|
||||
|
||||
if (SPA_IS_ALIGNED(s0, 16) &&
|
||||
SPA_IS_ALIGNED(s1, 16) &&
|
||||
|
|
@ -1139,15 +1142,15 @@ conv_f32d_to_s16_4s_sse2(void *data, void * SPA_RESTRICT dst, const void * SPA_R
|
|||
unrolled = 0;
|
||||
|
||||
for(n = 0; n < unrolled; n += 4) {
|
||||
in[0] = _mm_mul_ps(_mm_load_ps(&s0[n]), int_max);
|
||||
in[1] = _mm_mul_ps(_mm_load_ps(&s1[n]), int_max);
|
||||
in[2] = _mm_mul_ps(_mm_load_ps(&s2[n]), int_max);
|
||||
in[3] = _mm_mul_ps(_mm_load_ps(&s3[n]), int_max);
|
||||
in[0] = _mm_mul_ps(_mm_load_ps(&s0[n]), int_scale);
|
||||
in[1] = _mm_mul_ps(_mm_load_ps(&s1[n]), int_scale);
|
||||
in[2] = _mm_mul_ps(_mm_load_ps(&s2[n]), int_scale);
|
||||
in[3] = _mm_mul_ps(_mm_load_ps(&s3[n]), int_scale);
|
||||
|
||||
t[0] = _mm_cvtps_epi32(in[0]);
|
||||
t[1] = _mm_cvtps_epi32(in[1]);
|
||||
t[2] = _mm_cvtps_epi32(in[2]);
|
||||
t[3] = _mm_cvtps_epi32(in[3]);
|
||||
t[0] = _mm_cvttps_epi32(in[0]);
|
||||
t[1] = _mm_cvttps_epi32(in[1]);
|
||||
t[2] = _mm_cvttps_epi32(in[2]);
|
||||
t[3] = _mm_cvttps_epi32(in[3]);
|
||||
|
||||
t[0] = _mm_packs_epi32(t[0], t[2]);
|
||||
t[1] = _mm_packs_epi32(t[1], t[3]);
|
||||
|
|
@ -1165,10 +1168,10 @@ conv_f32d_to_s16_4s_sse2(void *data, void * SPA_RESTRICT dst, const void * SPA_R
|
|||
d += 4*n_channels;
|
||||
}
|
||||
for(; n < n_samples; n++) {
|
||||
in[0] = _mm_mul_ss(_mm_load_ss(&s0[n]), int_max);
|
||||
in[1] = _mm_mul_ss(_mm_load_ss(&s1[n]), int_max);
|
||||
in[2] = _mm_mul_ss(_mm_load_ss(&s2[n]), int_max);
|
||||
in[3] = _mm_mul_ss(_mm_load_ss(&s3[n]), int_max);
|
||||
in[0] = _mm_mul_ss(_mm_load_ss(&s0[n]), int_scale);
|
||||
in[1] = _mm_mul_ss(_mm_load_ss(&s1[n]), int_scale);
|
||||
in[2] = _mm_mul_ss(_mm_load_ss(&s2[n]), int_scale);
|
||||
in[3] = _mm_mul_ss(_mm_load_ss(&s3[n]), int_scale);
|
||||
in[0] = _mm_min_ss(int_max, _mm_max_ss(in[0], int_min));
|
||||
in[1] = _mm_min_ss(int_max, _mm_max_ss(in[1], int_min));
|
||||
in[2] = _mm_min_ss(int_max, _mm_max_ss(in[2], int_min));
|
||||
|
|
@ -1205,8 +1208,9 @@ conv_f32d_to_s16_2_sse2(struct convert *conv, void * SPA_RESTRICT dst[], const v
|
|||
uint32_t n, unrolled;
|
||||
__m128 in[4];
|
||||
__m128i out[4];
|
||||
__m128 int_max = _mm_set1_ps(S16_MAX_F);
|
||||
__m128 int_min = _mm_sub_ps(_mm_setzero_ps(), int_max);
|
||||
__m128 int_scale = _mm_set1_ps(S16_SCALE);
|
||||
__m128 int_max = _mm_set1_ps(S16_MAX);
|
||||
__m128 int_min = _mm_set1_ps(S16_MIN);
|
||||
|
||||
if (SPA_IS_ALIGNED(s0, 16) &&
|
||||
SPA_IS_ALIGNED(s1, 16))
|
||||
|
|
@ -1215,15 +1219,15 @@ conv_f32d_to_s16_2_sse2(struct convert *conv, void * SPA_RESTRICT dst[], const v
|
|||
unrolled = 0;
|
||||
|
||||
for(n = 0; n < unrolled; n += 8) {
|
||||
in[0] = _mm_mul_ps(_mm_load_ps(&s0[n+0]), int_max);
|
||||
in[1] = _mm_mul_ps(_mm_load_ps(&s1[n+0]), int_max);
|
||||
in[2] = _mm_mul_ps(_mm_load_ps(&s0[n+4]), int_max);
|
||||
in[3] = _mm_mul_ps(_mm_load_ps(&s1[n+4]), int_max);
|
||||
in[0] = _mm_mul_ps(_mm_load_ps(&s0[n+0]), int_scale);
|
||||
in[1] = _mm_mul_ps(_mm_load_ps(&s1[n+0]), int_scale);
|
||||
in[2] = _mm_mul_ps(_mm_load_ps(&s0[n+4]), int_scale);
|
||||
in[3] = _mm_mul_ps(_mm_load_ps(&s1[n+4]), int_scale);
|
||||
|
||||
out[0] = _mm_cvtps_epi32(in[0]);
|
||||
out[1] = _mm_cvtps_epi32(in[1]);
|
||||
out[2] = _mm_cvtps_epi32(in[2]);
|
||||
out[3] = _mm_cvtps_epi32(in[3]);
|
||||
out[0] = _mm_cvttps_epi32(in[0]);
|
||||
out[1] = _mm_cvttps_epi32(in[1]);
|
||||
out[2] = _mm_cvttps_epi32(in[2]);
|
||||
out[3] = _mm_cvttps_epi32(in[3]);
|
||||
|
||||
out[0] = _mm_packs_epi32(out[0], out[2]);
|
||||
out[1] = _mm_packs_epi32(out[1], out[3]);
|
||||
|
|
@ -1237,8 +1241,8 @@ conv_f32d_to_s16_2_sse2(struct convert *conv, void * SPA_RESTRICT dst[], const v
|
|||
d += 16;
|
||||
}
|
||||
for(; n < n_samples; n++) {
|
||||
in[0] = _mm_mul_ss(_mm_load_ss(&s0[n]), int_max);
|
||||
in[1] = _mm_mul_ss(_mm_load_ss(&s1[n]), int_max);
|
||||
in[0] = _mm_mul_ss(_mm_load_ss(&s0[n]), int_scale);
|
||||
in[1] = _mm_mul_ss(_mm_load_ss(&s1[n]), int_scale);
|
||||
in[0] = _mm_min_ss(int_max, _mm_max_ss(in[0], int_min));
|
||||
in[1] = _mm_min_ss(int_max, _mm_max_ss(in[1], int_min));
|
||||
d[0] = _mm_cvtss_si32(in[0]);
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@
|
|||
|
||||
#define S8_MIN -127
|
||||
#define S8_MAX 127
|
||||
#define S8_MAX_F 127.0f
|
||||
#define S8_SCALE 127.0f
|
||||
#define S8_TO_F32(v) (((int8_t)(v)) * (1.0f / S8_SCALE))
|
||||
#define F32_TO_S8(v) (int8_t)SPA_CLAMP((v) * S8_SCALE, S8_MIN, S8_MAX)
|
||||
|
|
@ -57,17 +56,16 @@
|
|||
#define U16_MAX 65535u
|
||||
#define U16_SCALE 32767.5f
|
||||
#define U16_OFFS 32768.f
|
||||
#define U16_TO_F32(v) ((((uint16_t)(v)) * (1.0f / U16_OFFS)) - 1.0)
|
||||
#define U16S_TO_F32(v) (((uint16_t)bswap_16((uint16_t)(v)) * (1.0f / U16_OFFS)) - 1.0)
|
||||
#define U16_TO_F32(v) ((((uint16_t)(v)) * (1.0f / U16_OFFS)) - 1.0f)
|
||||
#define U16S_TO_F32(v) (((uint16_t)bswap_16((uint16_t)(v)) * (1.0f / U16_OFFS)) - 1.0f)
|
||||
#define F32_TO_U16(v) (uint16_t)SPA_CLAMP((v) * U16_SCALE + U16_OFFS, U16_MIN, U16_MAX)
|
||||
#define F32_TO_U16_D(v,d) (uint16_t)SPA_CLAMP((v) * U16_SCALE + U16_OFFS + (d), U16_MIN, U16_MAX)
|
||||
#define F32_TO_U16S(v) bswap_16(F32_TO_U16(v))
|
||||
#define F32_TO_U16S_D(v,d) bswap_16(F32_TO_U16_D(v,d))
|
||||
|
||||
#define S16_MIN -32767
|
||||
#define S16_MIN -32768
|
||||
#define S16_MAX 32767
|
||||
#define S16_MAX_F 32767.0f
|
||||
#define S16_SCALE 32767.0f
|
||||
#define S16_SCALE 32768.0f
|
||||
#define S16_TO_F32(v) (((int16_t)(v)) * (1.0f / S16_SCALE))
|
||||
#define S16S_TO_F32(v) (((int16_t)bswap_16(v)) * (1.0f / S16_SCALE))
|
||||
#define F32_TO_S16(v) (int16_t)SPA_CLAMP((v) * S16_SCALE, S16_MIN, S16_MAX)
|
||||
|
|
@ -79,14 +77,13 @@
|
|||
#define U24_MAX 16777215u
|
||||
#define U24_SCALE 8388607.5f
|
||||
#define U24_OFFS 8388608.f
|
||||
#define U24_TO_F32(v) ((u24_to_u32(v) * (1.0f / U24_OFFS)) - 1.0)
|
||||
#define U24_TO_F32(v) ((u24_to_u32(v) * (1.0f / U24_OFFS)) - 1.0f)
|
||||
#define F32_TO_U24(v) u32_to_u24(SPA_CLAMP((v) * U24_SCALE + U24_OFFS, U24_MIN, U24_MAX))
|
||||
#define F32_TO_U24_D(v,d) u32_to_u24(SPA_CLAMP((v) * U24_SCALE + U24_OFFS + (d), U24_MIN, U24_MAX))
|
||||
|
||||
#define S24_MIN -8388607
|
||||
#define S24_MIN -8388608
|
||||
#define S24_MAX 8388607
|
||||
#define S24_MAX_F 8388607.0f
|
||||
#define S24_SCALE 8388607.0f
|
||||
#define S24_SCALE 8388608.0f
|
||||
#define S24_TO_F32(v) (s24_to_s32(v) * (1.0f / S24_SCALE))
|
||||
#define S24S_TO_F32(v) (s24_to_s32(bswap_s24(v)) * (1.0f / S24_SCALE))
|
||||
#define F32_TO_S24(v) s32_to_s24(SPA_CLAMP((v) * S24_SCALE, S24_MIN, S24_MAX))
|
||||
|
|
@ -94,16 +91,15 @@
|
|||
#define F32_TO_S24_D(v,d) s32_to_s24(SPA_CLAMP((v) * S24_SCALE + (d), S24_MIN, S24_MAX))
|
||||
|
||||
#define U32_MIN 0u
|
||||
#define U32_MAX 4294967040u
|
||||
#define U32_SCALE 2147483520.f
|
||||
#define U32_OFFS 2147483520.f
|
||||
#define U32_TO_F32(v) ((((uint32_t)(v)) * (1.0f / U32_OFFS)) - 1.0)
|
||||
#define U32_MAX 4294967295
|
||||
#define U32_SCALE 2147483647.5f
|
||||
#define U32_OFFS 2147483648.f
|
||||
#define U32_TO_F32(v) ((((uint32_t)(v)) * (1.0f / U32_OFFS)) - 1.0f)
|
||||
#define F32_TO_U32(v) (uint32_t)SPA_CLAMP((v) * U32_SCALE + U32_OFFS, U32_MIN, U32_MAX)
|
||||
#define F32_TO_U32_D(v,d) (uint32_t)SPA_CLAMP((v) * U32_SCALE + U32_OFFS + (d), U32_MIN, U32_MAX)
|
||||
|
||||
#define S32_MIN -2147483520
|
||||
#define S32_MIN -2147483648
|
||||
#define S32_MAX 2147483520
|
||||
#define S32_MAX_F 2147483520.f
|
||||
#define S32_SCALE 2147483648.f
|
||||
#define S32_TO_F32(v) (((int32_t)(v)) * (1.0f / S32_SCALE))
|
||||
#define S32S_TO_F32(v) (((int32_t)bswap_32(v)) * (1.0f / S32_SCALE))
|
||||
|
|
|
|||
|
|
@ -50,11 +50,11 @@ static void compare_mem(int i, int j, const void *m1, const void *m2, size_t siz
|
|||
{
|
||||
int res = memcmp(m1, m2, size);
|
||||
if (res != 0) {
|
||||
fprintf(stderr, "%d %d:\n", i, j);
|
||||
fprintf(stderr, "%d %d %zd:\n", i, j, size);
|
||||
spa_debug_mem(0, m1, size);
|
||||
spa_debug_mem(0, m2, size);
|
||||
}
|
||||
// spa_assert_se(res == 0);
|
||||
spa_assert_se(res == 0);
|
||||
}
|
||||
|
||||
static void run_test(const char *name,
|
||||
|
|
@ -158,7 +158,7 @@ static void test_u8_f32(void)
|
|||
static void test_f32_u16(void)
|
||||
{
|
||||
static const float in[] = { 0.0f, 1.0f, -1.0f, 0.5f, -0.5f, 1.1f, -1.1f };
|
||||
static const uint16_t out[] = { 32767, 65535, 0, 49150, 16383, 65535, 0 };
|
||||
static const uint16_t out[] = { 32768, 65535, 0, 49151, 16384, 65535, 0 };
|
||||
|
||||
run_test("test_f32_u16", in, sizeof(in[0]), out, sizeof(out[0]), SPA_N_ELEMENTS(out),
|
||||
true, true, conv_f32_to_u16_c);
|
||||
|
|
@ -168,8 +168,8 @@ static void test_f32_u16(void)
|
|||
|
||||
static void test_u16_f32(void)
|
||||
{
|
||||
static const uint16_t in[] = { 32767, 65535, 0, 49150, 16383, };
|
||||
static const float out[] = { 0.0f, 1.0f, -1.0f, 0.4999847412f, -0.4999847412f };
|
||||
static const uint16_t in[] = { 32768, 65535, 0, 49152, 16384, };
|
||||
static const float out[] = { 0.0f, 0.999969482422f, -1.0f, 0.5f, -0.5f };
|
||||
|
||||
run_test("test_u16_f32d", in, sizeof(in[0]), out, sizeof(out[0]), SPA_N_ELEMENTS(out),
|
||||
true, false, conv_u16_to_f32d_c);
|
||||
|
|
@ -180,7 +180,7 @@ static void test_u16_f32(void)
|
|||
static void test_f32_s16(void)
|
||||
{
|
||||
static const float in[] = { 0.0f, 1.0f, -1.0f, 0.5f, -0.5f, 1.1f, -1.1f };
|
||||
static const int16_t out[] = { 0, 32767, -32767, 16383, -16383, 32767, -32767 };
|
||||
static const int16_t out[] = { 0, 32767, -32768, 16384, -16384, 32767, -32768 };
|
||||
|
||||
run_test("test_f32_s16", in, sizeof(in[0]), out, sizeof(out[0]), SPA_N_ELEMENTS(out),
|
||||
true, true, conv_f32_to_s16_c);
|
||||
|
|
@ -192,16 +192,26 @@ static void test_f32_s16(void)
|
|||
false, false, conv_f32d_to_s16d_c);
|
||||
#if defined(HAVE_SSE2)
|
||||
if (cpu_flags & SPA_CPU_FLAG_SSE2) {
|
||||
run_test("test_f32_s16_sse2", in, sizeof(in[0]), out, sizeof(out[0]), SPA_N_ELEMENTS(out),
|
||||
true, true, conv_f32_to_s16_sse2);
|
||||
run_test("test_f32d_s16_sse2", in, sizeof(in[0]), out, sizeof(out[0]), SPA_N_ELEMENTS(out),
|
||||
false, true, conv_f32d_to_s16_sse2);
|
||||
run_test("test_f32d_s16d_sse2", in, sizeof(in[0]), out, sizeof(out[0]), SPA_N_ELEMENTS(out),
|
||||
false, false, conv_f32d_to_s16d_sse2);
|
||||
}
|
||||
#endif
|
||||
#if defined(HAVE_AVX2)
|
||||
if (cpu_flags & SPA_CPU_FLAG_AVX2) {
|
||||
run_test("test_f32d_s16_avx2", in, sizeof(in[0]), out, sizeof(out[0]), SPA_N_ELEMENTS(out),
|
||||
false, true, conv_f32d_to_s16_avx2);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void test_s16_f32(void)
|
||||
{
|
||||
static const int16_t in[] = { 0, 32767, -32767, 16383, -16383, };
|
||||
static const float out[] = { 0.0f, 1.0f, -1.0f, 0.4999847412f, -0.4999847412f };
|
||||
static const int16_t in[] = { 0, 32767, -32768, 16384, -16384, };
|
||||
static const float out[] = { 0.0f, 0.999969482422f, -1.0f, 0.5f, -0.5f };
|
||||
|
||||
run_test("test_s16_f32d", in, sizeof(in[0]), out, sizeof(out[0]), SPA_N_ELEMENTS(out),
|
||||
true, false, conv_s16_to_f32d_c);
|
||||
|
|
@ -217,13 +227,19 @@ static void test_s16_f32(void)
|
|||
true, false, conv_s16_to_f32d_sse2);
|
||||
}
|
||||
#endif
|
||||
#if defined(HAVE_AVX2)
|
||||
if (cpu_flags & SPA_CPU_FLAG_AVX2) {
|
||||
run_test("test_s16_f32d_avx2", in, sizeof(in[0]), out, sizeof(out[0]), SPA_N_ELEMENTS(out),
|
||||
true, false, conv_s16_to_f32d_avx2);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void test_f32_u32(void)
|
||||
{
|
||||
static const float in[] = { 0.0f, 1.0f, -1.0f, 0.5f, -0.5f, 1.1f, -1.1f };
|
||||
static const uint32_t out[] = { 0, 0x7fffff00, 0x80000100, 0x3fffff00, 0xc0000100,
|
||||
0x7fffff00, 0x80000100 };
|
||||
static const uint32_t out[] = { 0x80000000, 0xffffffff, 0x0, 0xc0000000, 0x40000000,
|
||||
0xffffffff, 0x0 };
|
||||
|
||||
run_test("test_f32_u32", in, sizeof(in[0]), out, sizeof(out[0]), SPA_N_ELEMENTS(out),
|
||||
true, true, conv_f32_to_u32_c);
|
||||
|
|
@ -233,8 +249,8 @@ static void test_f32_u32(void)
|
|||
|
||||
static void test_u32_f32(void)
|
||||
{
|
||||
static const uint32_t in[] = { 0, 0x7fffff00, 0x80000100, 0x3fffff00, 0xc0000100 };
|
||||
static const float out[] = { 0.0f, 1.0f, -1.0f, 0.4999999404f, -0.4999999404f, };
|
||||
static const uint32_t in[] = { 0x80000000, 0xffffffff, 0x0, 0xc0000000, 0x40000000 };
|
||||
static const float out[] = { 0.0f, 1.0f, -1.0f, 0.5f, -0.5f, };
|
||||
|
||||
run_test("test_u32_f32d", in, sizeof(in[0]), out, sizeof(out[0]), SPA_N_ELEMENTS(out),
|
||||
true, false, conv_u32_to_f32d_c);
|
||||
|
|
@ -245,8 +261,8 @@ static void test_u32_f32(void)
|
|||
static void test_f32_s32(void)
|
||||
{
|
||||
static const float in[] = { 0.0f, 1.0f, -1.0f, 0.5f, -0.5f, 1.1f, -1.1f };
|
||||
static const int32_t out[] = { 0, 0x7fffff00, 0x80000100, 0x3fffff00, 0xc0000100,
|
||||
0x7fffff00, 0x80000100 };
|
||||
static const int32_t out[] = { 0, 0x7fffff80, 0x80000000, 0x40000000, 0xc0000000,
|
||||
0x7fffff80, 0x80000000 };
|
||||
|
||||
run_test("test_f32_s32", in, sizeof(in[0]), out, sizeof(out[0]), SPA_N_ELEMENTS(out),
|
||||
true, true, conv_f32_to_s32_c);
|
||||
|
|
@ -262,12 +278,18 @@ static void test_f32_s32(void)
|
|||
false, true, conv_f32d_to_s32_sse2);
|
||||
}
|
||||
#endif
|
||||
#if defined(HAVE_AVX2)
|
||||
if (cpu_flags & SPA_CPU_FLAG_AVX2) {
|
||||
run_test("test_f32d_s32_avx2", in, sizeof(in[0]), out, sizeof(out[0]), SPA_N_ELEMENTS(out),
|
||||
false, true, conv_f32d_to_s32_avx2);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void test_s32_f32(void)
|
||||
{
|
||||
static const int32_t in[] = { 0, 0x7fffff00, 0x80000100, 0x3fffff00, 0xc0000100 };
|
||||
static const float out[] = { 0.0f, 1.0f, -1.0f, 0.4999999404f, -0.4999999404f, };
|
||||
static const int32_t in[] = { 0, 0x7fffff80, 0x80000000, 0x40000000, 0xc0000000 };
|
||||
static const float out[] = { 0.0f, 0.999999940395f, -1.0f, 0.5, -0.5, };
|
||||
|
||||
run_test("test_s32_f32d", in, sizeof(in[0]), out, sizeof(out[0]), SPA_N_ELEMENTS(out),
|
||||
true, false, conv_s32_to_f32d_c);
|
||||
|
|
@ -283,18 +305,20 @@ static void test_s32_f32(void)
|
|||
true, false, conv_s32_to_f32d_sse2);
|
||||
}
|
||||
#endif
|
||||
#if defined(HAVE_AVX2)
|
||||
if (cpu_flags & SPA_CPU_FLAG_AVX2) {
|
||||
run_test("test_s32_f32d_avx2", in, sizeof(in[0]), out, sizeof(out[0]), SPA_N_ELEMENTS(out),
|
||||
true, false, conv_s32_to_f32d_avx2);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void test_f32_u24(void)
|
||||
{
|
||||
static const float in[] = { 0.0f, 1.0f, -1.0f, 0.5f, -0.5f, 1.1f, -1.1f };
|
||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
static const uint8_t out[] = { 0x00, 0x00, 0x00, 0xff, 0xff, 0x7f, 0x01, 0x00, 0x80,
|
||||
0xff, 0xff, 0x3f, 0x01, 0x00, 0xc0, 0xff, 0xff, 0x7f, 0x01, 0x00, 0x80 };
|
||||
#else
|
||||
static const uint8_t out[] = { 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0x80, 0x00, 0x01,
|
||||
0x3f, 0xff, 0xff, 0xc0, 0x00, 0x01, 0x7f, 0xff, 0xff, 0x80, 0x00, 0x01 };
|
||||
#endif
|
||||
static const uint24_t out[] = { U32_TO_U24(0x00800000), U32_TO_U24(0xffffff),
|
||||
U32_TO_U24(0x000000), U32_TO_U24(0xc00000), U32_TO_U24(0x400000),
|
||||
U32_TO_U24(0xffffff), U32_TO_U24(0x000000) };
|
||||
|
||||
run_test("test_f32_u24", in, sizeof(in[0]), out, 3, SPA_N_ELEMENTS(in),
|
||||
true, true, conv_f32_to_u24_c);
|
||||
|
|
@ -304,14 +328,9 @@ static void test_f32_u24(void)
|
|||
|
||||
static void test_u24_f32(void)
|
||||
{
|
||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
static const uint8_t in[] = { 0x00, 0x00, 0x00, 0xff, 0xff, 0x7f, 0x01, 0x00, 0x80,
|
||||
0xff, 0xff, 0x3f, 0x01, 0x00, 0xc0, };
|
||||
#else
|
||||
static const uint8_t in[] = { 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0x80, 0x00, 0x01,
|
||||
0x3f, 0xff, 0xff, 0xc0, 0x00, 0x01, };
|
||||
#endif
|
||||
static const float out[] = { 0.0f, 1.0f, -1.0f, 0.4999999404f, -0.4999999404f, };
|
||||
static const uint24_t in[] = { U32_TO_U24(0x00800000), U32_TO_U24(0xffffff),
|
||||
U32_TO_U24(0x000000), U32_TO_U24(0xc00000), U32_TO_U24(0x400000) };
|
||||
static const float out[] = { 0.0f, 0.999999880791f, -1.0f, 0.5, -0.5, };
|
||||
|
||||
run_test("test_u24_f32d", in, 3, out, sizeof(out[0]), SPA_N_ELEMENTS(out),
|
||||
true, false, conv_u24_to_f32d_c);
|
||||
|
|
@ -322,13 +341,9 @@ static void test_u24_f32(void)
|
|||
static void test_f32_s24(void)
|
||||
{
|
||||
static const float in[] = { 0.0f, 1.0f, -1.0f, 0.5f, -0.5f, 1.1f, -1.1f };
|
||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
static const uint8_t out[] = { 0x00, 0x00, 0x00, 0xff, 0xff, 0x7f, 0x01, 0x00, 0x80,
|
||||
0xff, 0xff, 0x3f, 0x01, 0x00, 0xc0, 0xff, 0xff, 0x7f, 0x01, 0x00, 0x80 };
|
||||
#else
|
||||
static const uint8_t out[] = { 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0x80, 0x00, 0x01,
|
||||
0x3f, 0xff, 0xff, 0xc0, 0x00, 0x01, 0x7f, 0xff, 0xff, 0x80, 0x00, 0x01 };
|
||||
#endif
|
||||
static const int24_t out[] = { S32_TO_S24(0), S32_TO_S24(0x7fffff),
|
||||
S32_TO_S24(0xff800000), S32_TO_S24(0x400000), S32_TO_S24(0xc00000),
|
||||
S32_TO_S24(0x7fffff), S32_TO_S24(0xff800000) };
|
||||
|
||||
run_test("test_f32_s24", in, sizeof(in[0]), out, 3, SPA_N_ELEMENTS(in),
|
||||
true, true, conv_f32_to_s24_c);
|
||||
|
|
@ -342,14 +357,9 @@ static void test_f32_s24(void)
|
|||
|
||||
static void test_s24_f32(void)
|
||||
{
|
||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
static const uint8_t in[] = { 0x00, 0x00, 0x00, 0xff, 0xff, 0x7f, 0x01, 0x00, 0x80,
|
||||
0xff, 0xff, 0x3f, 0x01, 0x00, 0xc0, };
|
||||
#else
|
||||
static const uint8_t in[] = { 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0x80, 0x00, 0x01,
|
||||
0x3f, 0xff, 0xff, 0xc0, 0x00, 0x01, };
|
||||
#endif
|
||||
static const float out[] = { 0.0f, 1.0f, -1.0f, 0.4999999404f, -0.4999999404f, };
|
||||
static const int24_t in[] = { S32_TO_S24(0), S32_TO_S24(0x7fffff),
|
||||
S32_TO_S24(0xff800000), S32_TO_S24(0x400000), S32_TO_S24(0xc00000) };
|
||||
static const float out[] = { 0.0f, 0.999999880791f, -1.0f, 0.5f, -0.5f, };
|
||||
|
||||
run_test("test_s24_f32d", in, 3, out, sizeof(out[0]), SPA_N_ELEMENTS(out),
|
||||
true, false, conv_s24_to_f32d_c);
|
||||
|
|
@ -377,13 +387,19 @@ static void test_s24_f32(void)
|
|||
true, false, conv_s24_to_f32d_sse41);
|
||||
}
|
||||
#endif
|
||||
#if defined(HAVE_AVX2)
|
||||
if (cpu_flags & SPA_CPU_FLAG_AVX2) {
|
||||
run_test("test_s24_f32d_avx2", in, 3, out, sizeof(out[0]), SPA_N_ELEMENTS(out),
|
||||
true, false, conv_s24_to_f32d_avx2);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void test_f32_u24_32(void)
|
||||
{
|
||||
static const float in[] = { 0.0f, 1.0f, -1.0f, 0.5f, -0.5f, 1.1f, -1.1f };
|
||||
static const uint32_t out[] = { 0, 0x7fffff, 0xff800001, 0x3fffff, 0xffc00001,
|
||||
0x7fffff, 0xff800001 };
|
||||
static const uint32_t out[] = { 0x800000, 0xffffff, 0x0, 0xc00000, 0x400000,
|
||||
0xffffff, 0x000000 };
|
||||
|
||||
run_test("test_f32_u24_32", in, sizeof(in[0]), out, sizeof(out[0]), SPA_N_ELEMENTS(out),
|
||||
true, true, conv_f32_to_u24_32_c);
|
||||
|
|
@ -393,8 +409,8 @@ static void test_f32_u24_32(void)
|
|||
|
||||
static void test_u24_32_f32(void)
|
||||
{
|
||||
static const uint32_t in[] = { 0, 0x7fffff, 0xff800001, 0x3fffff, 0xffc00001 };
|
||||
static const float out[] = { 0.0f, 1.0f, -1.0f, 0.4999999404f, -0.4999999404f, };
|
||||
static const uint32_t in[] = { 0x800000, 0xffffff, 0x0, 0xc00000, 0x400000 };
|
||||
static const float out[] = { 0.0f, 0.999999880791f, -1.0f, 0.5f, -0.5f, };
|
||||
|
||||
run_test("test_u24_32_f32d", in, sizeof(in[0]), out, sizeof(out[0]), SPA_N_ELEMENTS(out),
|
||||
true, false, conv_u24_32_to_f32d_c);
|
||||
|
|
@ -405,8 +421,8 @@ static void test_u24_32_f32(void)
|
|||
static void test_f32_s24_32(void)
|
||||
{
|
||||
static const float in[] = { 0.0f, 1.0f, -1.0f, 0.5f, -0.5f, 1.1f, -1.1f };
|
||||
static const int32_t out[] = { 0, 0x7fffff, 0xff800001, 0x3fffff, 0xffc00001,
|
||||
0x7fffff, 0xff800001 };
|
||||
static const int32_t out[] = { 0, 0x7fffff, 0xff800000, 0x400000, 0xffc00000,
|
||||
0x7fffff, 0xff800000 };
|
||||
|
||||
run_test("test_f32_s24_32", in, sizeof(in[0]), out, sizeof(out[0]), SPA_N_ELEMENTS(out),
|
||||
true, true, conv_f32_to_s24_32_c);
|
||||
|
|
@ -420,8 +436,8 @@ static void test_f32_s24_32(void)
|
|||
|
||||
static void test_s24_32_f32(void)
|
||||
{
|
||||
static const int32_t in[] = { 0, 0x7fffff, 0xff800001, 0x3fffff, 0xffc00001 };
|
||||
static const float out[] = { 0.0f, 1.0f, -1.0f, 0.4999999404f, -0.4999999404f, };
|
||||
static const int32_t in[] = { 0, 0x7fffff, 0xff800000, 0x400000, 0xffc00000 };
|
||||
static const float out[] = { 0.0f, 0.999999880791f, -1.0f, 0.5f, -0.5f, };
|
||||
|
||||
run_test("test_s24_32_f32d", in, sizeof(in[0]), out, sizeof(out[0]), SPA_N_ELEMENTS(out),
|
||||
true, false, conv_s24_32_to_f32d_c);
|
||||
|
|
@ -435,8 +451,8 @@ static void test_s24_32_f32(void)
|
|||
|
||||
static void test_f64_f32(void)
|
||||
{
|
||||
static const double in[] = { 0.0, 1.0, -1.0, 0.4999999404, -0.4999999404, };
|
||||
static const float out[] = { 0.0f, 1.0f, -1.0f, 0.4999999404f, -0.4999999404f, };
|
||||
static const double in[] = { 0.0, 1.0, -1.0, 0.5, -0.5, };
|
||||
static const float out[] = { 0.0, 1.0, -1.0, 0.5, -0.5, };
|
||||
|
||||
run_test("test_f64_f32d", in, sizeof(in[0]), out, sizeof(out[0]), SPA_N_ELEMENTS(out),
|
||||
true, false, conv_f64_to_f32d_c);
|
||||
|
|
@ -451,7 +467,7 @@ static void test_f64_f32(void)
|
|||
static void test_f32_f64(void)
|
||||
{
|
||||
static const float in[] = { 0.0f, 1.0f, -1.0f, 0.5f, -0.5f, 1.1f, -1.1f };
|
||||
static const double out[] = { 0.0, 1.0, -1.0, 0.5, -0.5, 1.1, -1.1 };
|
||||
static const double out[] = { 0.0f, 1.0f, -1.0f, 0.5f, -0.5f, 1.1f, -1.1f };
|
||||
|
||||
run_test("test_f32_f64", in, sizeof(in[0]), out, sizeof(out[0]), SPA_N_ELEMENTS(out),
|
||||
true, true, conv_f32_to_f64_c);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue