diff --git a/spa/plugins/audioconvert/channelmix-ops-c.c b/spa/plugins/audioconvert/channelmix-ops-c.c index 43da8823e..2f03df84e 100644 --- a/spa/plugins/audioconvert/channelmix-ops-c.c +++ b/spa/plugins/audioconvert/channelmix-ops-c.c @@ -3,6 +3,7 @@ /* SPDX-License-Identifier: MIT */ #include +#include #include "channelmix-ops.h" @@ -94,7 +95,7 @@ static void lr4_process_c(struct lr4 *lr4, float *dst, const float *src, const f y2 = b2 * y - a2 * z; dst[i] = z * vol; } -#define F(x) (-FLT_MIN < (x) && (x) < FLT_MIN ? 0.0f : (x)) +#define F(x) (isnormal(x) ? (x) : 0.0f) lr4->x1 = F(x1); lr4->x2 = F(x2); lr4->y1 = F(y1); diff --git a/spa/plugins/audioconvert/channelmix-ops-sse.c b/spa/plugins/audioconvert/channelmix-ops-sse.c index 9a128177f..1058959c7 100644 --- a/spa/plugins/audioconvert/channelmix-ops-sse.c +++ b/spa/plugins/audioconvert/channelmix-ops-sse.c @@ -6,6 +6,7 @@ #include #include +#include static inline void clear_sse(float *d, uint32_t n_samples) { @@ -189,7 +190,7 @@ static void lr4_process_sse(struct lr4 *lr4, float *dst, const float *src, const x = _mm_mul_ps(x, v); _mm_store_ss(&dst[i], x); } -#define F(x) (-FLT_MIN < (x) && (x) < FLT_MIN ? 0.0f : (x)) +#define F(x) (isnormal(x) ? (x) : 0.0f) lr4->x1 = F(x12[0]); lr4->x2 = F(x12[1]); lr4->y1 = F(y12[0]); @@ -245,7 +246,7 @@ static void lr4_process_2_sse(struct lr4 *lr40, struct lr4 *lr41, float *dst0, f dst0[i] = x[0]; dst1[i] = x[1]; } -#define F(x) (-FLT_MIN < (x) && (x) < FLT_MIN ? 0.0f : (x)) +#define F(x) (isnormal(x) ? (x) : 0.0f) lr40->x1 = F(x1[0]); lr40->x2 = F(x2[0]); lr40->y1 = F(y1[0]); diff --git a/spa/plugins/filter-graph/audio-dsp-c.c b/spa/plugins/filter-graph/audio-dsp-c.c index cd6a8b5a6..f2a509a76 100644 --- a/spa/plugins/filter-graph/audio-dsp-c.c +++ b/spa/plugins/filter-graph/audio-dsp-c.c @@ -148,7 +148,7 @@ static void biquad_run_c(void *obj, struct biquad *bq, x2 = b2 * x - a2 * y; out[i] = y; } -#define F(x) (-FLT_MIN < (x) && (x) < FLT_MIN ? 0.0f : (x)) +#define F(x) (isnormal(x) ? (x) : 0.0f) bq->x1 = F(x1); bq->x2 = F(x2); #undef F diff --git a/spa/plugins/filter-graph/audio-dsp-sse.c b/spa/plugins/filter-graph/audio-dsp-sse.c index 35748c1a2..8c2ffa8e6 100644 --- a/spa/plugins/filter-graph/audio-dsp-sse.c +++ b/spa/plugins/filter-graph/audio-dsp-sse.c @@ -256,7 +256,7 @@ static void dsp_biquad_run1_sse(void *obj, struct biquad *bq, y = _mm_sub_ps(z, y); /* y x1 x2 0 */ x12 = _mm_shuffle_ps(y, y, _MM_SHUFFLE(3,3,2,1)); /* x1 x2 0 0*/ } -#define F(x) (-FLT_MIN < (x) && (x) < FLT_MIN ? 0.0f : (x)) +#define F(x) (isnormal(x) ? (x) : 0.0f) bq->x1 = F(x12[0]); bq->x2 = F(x12[1]); #undef F @@ -298,7 +298,7 @@ static void dsp_biquad2_run_sse(void *obj, struct biquad *bq, _mm_store_ss(&out[i], x); /* out[i] = b0*x+x1 */ } -#define F(x) (-FLT_MIN < (x) && (x) < FLT_MIN ? 0.0f : (x)) +#define F(x) (isnormal(x) ? (x) : 0.0f) bq[0].x1 = F(x0[0]); bq[0].x2 = F(x0[1]); bq[1].x1 = F(x1[0]); @@ -339,7 +339,7 @@ static void dsp_biquad_run2_sse(void *obj, struct biquad *bq, uint32_t bq_stride out[0][i] = y[0]; out[1][i] = y[1]; } -#define F(x) (-FLT_MIN < (x) && (x) < FLT_MIN ? 0.0f : (x)) +#define F(x) (isnormal(x) ? (x) : 0.0f) bq[0*bq_stride].x1 = F(x1[0]); bq[0*bq_stride].x2 = F(x2[0]); bq[1*bq_stride].x1 = F(x1[1]); @@ -401,7 +401,7 @@ static void dsp_biquad2_run2_sse(void *obj, struct biquad *bq, uint32_t bq_strid out[0][i] = y[0]; out[1][i] = y[1]; } -#define F(x) (-FLT_MIN < (x) && (x) < FLT_MIN ? 0.0f : (x)) +#define F(x) (isnormal(x) ? (x) : 0.0f) bq[0*bq_stride+0].x1 = F(x01[0]); bq[0*bq_stride+0].x2 = F(x02[0]); bq[1*bq_stride+0].x1 = F(x01[1]); @@ -449,7 +449,7 @@ static void dsp_biquad_run4_sse(void *obj, struct biquad *bq, uint32_t bq_stride out[2][i] = y[2]; out[3][i] = y[3]; } -#define F(x) (-FLT_MIN < (x) && (x) < FLT_MIN ? 0.0f : (x)) +#define F(x) (isnormal(x) ? (x) : 0.0f) bq[0*bq_stride].x1 = F(x1[0]); bq[0*bq_stride].x2 = F(x2[0]); bq[1*bq_stride].x1 = F(x1[1]); @@ -516,7 +516,7 @@ static void dsp_biquad2_run4_sse(void *obj, struct biquad *bq, uint32_t bq_strid out[2][i] = y[2]; out[3][i] = y[3]; } -#define F(x) (-FLT_MIN < (x) && (x) < FLT_MIN ? 0.0f : (x)) +#define F(x) (isnormal(x) ? (x) : 0.0f) bq[0*bq_stride+0].x1 = F(x01[0]); bq[0*bq_stride+0].x2 = F(x02[0]); bq[1*bq_stride+0].x1 = F(x01[1]);