mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	resample: cleanup the resampler core functions
Move the increment function to a macro. Don't use extra local variables, we can just as well call the resample functipon with them.
This commit is contained in:
		
							parent
							
								
									bb558b7d95
								
							
						
					
					
						commit
						4c3f56fca1
					
				
					 1 changed files with 19 additions and 29 deletions
				
			
		| 
						 | 
					@ -94,6 +94,14 @@ DEFINE_RESAMPLER(copy,arch)							\
 | 
				
			||||||
	*out_len = ooffs;							\
 | 
						*out_len = ooffs;							\
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define INC(index,phase,n_phases) \
 | 
				
			||||||
 | 
						index += inc;						\
 | 
				
			||||||
 | 
						phase += frac;						\
 | 
				
			||||||
 | 
						if (phase >= n_phases) {				\
 | 
				
			||||||
 | 
							phase -= n_phases;				\
 | 
				
			||||||
 | 
							index += 1;					\
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define MAKE_RESAMPLER_FULL(arch)						\
 | 
					#define MAKE_RESAMPLER_FULL(arch)						\
 | 
				
			||||||
DEFINE_RESAMPLER(full,arch)							\
 | 
					DEFINE_RESAMPLER(full,arch)							\
 | 
				
			||||||
{										\
 | 
					{										\
 | 
				
			||||||
| 
						 | 
					@ -114,17 +122,10 @@ DEFINE_RESAMPLER(full,arch)							\
 | 
				
			||||||
		phase = data->phase;						\
 | 
							phase = data->phase;						\
 | 
				
			||||||
										\
 | 
															\
 | 
				
			||||||
		for (o = ooffs; o < olen && index + n_taps <= ilen; o++) {	\
 | 
							for (o = ooffs; o < olen && index + n_taps <= ilen; o++) {	\
 | 
				
			||||||
			const float *ip, *taps;					\
 | 
								inner_product_##arch(&d[o], &s[index],			\
 | 
				
			||||||
										\
 | 
										&data->filter[phase * stride],		\
 | 
				
			||||||
			ip = &s[index];						\
 | 
										n_taps);				\
 | 
				
			||||||
			taps = &data->filter[phase * stride];			\
 | 
								INC(index, phase, n_phases);				\
 | 
				
			||||||
			index += inc;						\
 | 
					 | 
				
			||||||
			phase += frac;						\
 | 
					 | 
				
			||||||
			if (phase >= n_phases) {				\
 | 
					 | 
				
			||||||
				phase -= n_phases;				\
 | 
					 | 
				
			||||||
				index += 1;					\
 | 
					 | 
				
			||||||
			}							\
 | 
					 | 
				
			||||||
			inner_product_##arch(&d[o], ip, taps, n_taps);		\
 | 
					 | 
				
			||||||
		}								\
 | 
							}								\
 | 
				
			||||||
	}									\
 | 
						}									\
 | 
				
			||||||
	*in_len = index;							\
 | 
						*in_len = index;							\
 | 
				
			||||||
| 
						 | 
					@ -153,24 +154,13 @@ DEFINE_RESAMPLER(inter,arch)							\
 | 
				
			||||||
		phase = data->phase;						\
 | 
							phase = data->phase;						\
 | 
				
			||||||
										\
 | 
															\
 | 
				
			||||||
		for (o = ooffs; o < olen && index + n_taps <= ilen; o++) {	\
 | 
							for (o = ooffs; o < olen && index + n_taps <= ilen; o++) {	\
 | 
				
			||||||
			const float *ip, *t0, *t1;				\
 | 
								float ph = (float)phase * n_phases / out_rate;		\
 | 
				
			||||||
			float ph, x;						\
 | 
								uint32_t offset = floorf(ph);				\
 | 
				
			||||||
			uint32_t offset;					\
 | 
								inner_product_ip_##arch(&d[o], &s[index],		\
 | 
				
			||||||
										\
 | 
										&data->filter[(offset + 0) * stride],	\
 | 
				
			||||||
			ip = &s[index];						\
 | 
										&data->filter[(offset + 1) * stride],	\
 | 
				
			||||||
			ph = (float)phase * n_phases / out_rate;		\
 | 
										ph - offset, n_taps);			\
 | 
				
			||||||
			offset = floor(ph);					\
 | 
								INC(index, phase, out_rate);				\
 | 
				
			||||||
			x = ph - (float)offset;					\
 | 
					 | 
				
			||||||
										\
 | 
					 | 
				
			||||||
			t0 = &data->filter[(offset + 0) * stride];		\
 | 
					 | 
				
			||||||
			t1 = &data->filter[(offset + 1) * stride];		\
 | 
					 | 
				
			||||||
			index += inc;						\
 | 
					 | 
				
			||||||
			phase += frac;						\
 | 
					 | 
				
			||||||
			if (phase >= out_rate) {				\
 | 
					 | 
				
			||||||
				phase -= out_rate;				\
 | 
					 | 
				
			||||||
				index += 1;					\
 | 
					 | 
				
			||||||
			}							\
 | 
					 | 
				
			||||||
			inner_product_ip_##arch(&d[o], ip, t0, t1, x, n_taps);	\
 | 
					 | 
				
			||||||
		}								\
 | 
							}								\
 | 
				
			||||||
	}									\
 | 
						}									\
 | 
				
			||||||
	*in_len = index;							\
 | 
						*in_len = index;							\
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue