mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	math: improve denormal check
Use isnormal() when we can
This commit is contained in:
		
							parent
							
								
									73e11eea46
								
							
						
					
					
						commit
						0868ff1ada
					
				
					 4 changed files with 12 additions and 10 deletions
				
			
		| 
						 | 
				
			
			@ -3,6 +3,7 @@
 | 
			
		|||
/* SPDX-License-Identifier: MIT */
 | 
			
		||||
 | 
			
		||||
#include <float.h>
 | 
			
		||||
#include <math.h>
 | 
			
		||||
 | 
			
		||||
#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);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,6 +6,7 @@
 | 
			
		|||
 | 
			
		||||
#include <xmmintrin.h>
 | 
			
		||||
#include <float.h>
 | 
			
		||||
#include <math.h>
 | 
			
		||||
 | 
			
		||||
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]);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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]);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue