mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	audioconvert: improve setup of quantization
Use the quantize value to specify how many bits to quantize to.
This commit is contained in:
		
							parent
							
								
									916050aacd
								
							
						
					
					
						commit
						67c2202044
					
				
					 3 changed files with 7 additions and 7 deletions
				
			
		| 
						 | 
				
			
			@ -1396,16 +1396,16 @@ static int setup_out_convert(struct impl *this)
 | 
			
		|||
			this->cpu_flags, out->conv.cpu_flags, out->conv.is_passthrough);
 | 
			
		||||
 | 
			
		||||
	if (this->props.dither_noise > 0) {
 | 
			
		||||
		this->dither.intensity = (calc_width(&dst_info) * 8) - 1;
 | 
			
		||||
		this->dither.intensity -= SPA_MIN(this->dither.intensity, this->props.dither_noise);
 | 
			
		||||
		this->dither.quantize = 32 - (calc_width(&dst_info) * 8);
 | 
			
		||||
		this->dither.quantize += this->props.dither_noise;
 | 
			
		||||
		this->dither.n_channels = dst_info.info.raw.channels;
 | 
			
		||||
		this->dither.cpu_flags = this->cpu_flags;
 | 
			
		||||
 | 
			
		||||
		if ((res = dither_init(&this->dither)) < 0)
 | 
			
		||||
			return res;
 | 
			
		||||
 | 
			
		||||
		spa_log_debug(this->log, "%p: dither noise:%d intensity:%d", this,
 | 
			
		||||
				this->props.dither_noise, this->dither.intensity);
 | 
			
		||||
		spa_log_info(this->log, "%p: dither noise:%d quantize:%d", this,
 | 
			
		||||
				this->props.dither_noise, this->dither.quantize);
 | 
			
		||||
	}
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -79,10 +79,10 @@ int dither_init(struct dither *d)
 | 
			
		|||
	if (info == NULL)
 | 
			
		||||
		return -ENOTSUP;
 | 
			
		||||
 | 
			
		||||
	if (d->intensity >= 32)
 | 
			
		||||
	if (d->quantize >= 32)
 | 
			
		||||
		return -EINVAL;
 | 
			
		||||
 | 
			
		||||
	d->scale = 1.0f / (1ULL << (31 + d->intensity));
 | 
			
		||||
	d->scale = 1.0f / (1ULL << (63 - d->quantize));
 | 
			
		||||
 | 
			
		||||
	d->dither_size = DITHER_SIZE;
 | 
			
		||||
	d->dither = calloc(d->dither_size + DITHER_OPS_MAX_OVERREAD +
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -33,7 +33,7 @@
 | 
			
		|||
#define DITHER_OPS_MAX_OVERREAD	16
 | 
			
		||||
 | 
			
		||||
struct dither {
 | 
			
		||||
	uint32_t intensity;
 | 
			
		||||
	uint32_t quantize;
 | 
			
		||||
#define DITHER_METHOD_NONE 		0
 | 
			
		||||
#define DITHER_METHOD_RECTANGULAR 	2
 | 
			
		||||
#define DITHER_METHOD_TRIANGULAR 	3
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue