mirror of
				https://github.com/libsdl-org/SDL.git
				synced 2025-10-26 12:27:44 +00:00 
			
		
		
		
	resampler: Work at double precision on x86-64 machines.
We get audio artifacts if we don't work at the higher precision, but
this is painful on CPUs that have to use a software fallback for this,
so for now (that is, until we have a better solution), get better output
on amd64 chips, where the cost is less painful.
(cherry picked from commit 1e5e8e2fda)
			
			
This commit is contained in:
		| @@ -198,10 +198,18 @@ static int SDL_ResampleAudio(const int chans, const int inrate, const int outrat | |||||||
|                              const float *inbuf, const int inbuflen, |                              const float *inbuf, const int inbuflen, | ||||||
|                              float *outbuf, const int outbuflen) |                              float *outbuf, const int outbuflen) | ||||||
| { | { | ||||||
|  |     /* !!! FIXME: this produces artifacts if we don't work at double precision, but this turns out to | ||||||
|  |                   be a big performance hit. Until we can resolve this better, we force this to double | ||||||
|  |                   for amd64 CPUs, which should be able to take the hit for now, vs small embedded | ||||||
|  |                   things that might end up in a software fallback here. */ | ||||||
|     /* Note that this used to be double, but it looks like we can get by with float in most cases at |     /* Note that this used to be double, but it looks like we can get by with float in most cases at | ||||||
|        almost twice the speed on Intel processors, and orders of magnitude more |        almost twice the speed on Intel processors, and orders of magnitude more | ||||||
|        on CPUs that need a software fallback for double calculations. */ |        on CPUs that need a software fallback for double calculations. */ | ||||||
|  |     #if defined(_M_X64) || defined(__x86_64__) | ||||||
|  |     typedef double ResampleFloatType; | ||||||
|  |     #else | ||||||
|     typedef float ResampleFloatType; |     typedef float ResampleFloatType; | ||||||
|  |     #endif | ||||||
|  |  | ||||||
|     const ResampleFloatType finrate = (ResampleFloatType)inrate; |     const ResampleFloatType finrate = (ResampleFloatType)inrate; | ||||||
|     const ResampleFloatType ratio = ((float)outrate) / ((float)inrate); |     const ResampleFloatType ratio = ((float)outrate) / ((float)inrate); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Ryan C. Gordon
					Ryan C. Gordon