mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	Update of a2dp-codec-sbc.c to achieve SBC XQ quality in dual channel, with fall back to standard Joint Stereo mode
This commit is contained in:
		
							parent
							
								
									a81158f3d5
								
							
						
					
					
						commit
						4e1cbef687
					
				
					 1 changed files with 9 additions and 8 deletions
				
			
		| 
						 | 
					@ -85,7 +85,8 @@ static int codec_fill_caps(const struct a2dp_codec *codec, uint32_t flags,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static uint8_t default_bitpool(uint8_t freq, uint8_t mode)
 | 
					static uint8_t default_bitpool(uint8_t freq, uint8_t mode)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	/* These bitpool values were chosen based on the A2DP spec recommendation */
 | 
						/* A2DP spec v1.2 states that all SNK implementation shall handle bitrates
 | 
				
			||||||
 | 
						   of up to 512 kbps (~ bitpool = 76 stereo, or 2x38 dual channel). */
 | 
				
			||||||
	switch (freq) {
 | 
						switch (freq) {
 | 
				
			||||||
	case SBC_SAMPLING_FREQ_16000:
 | 
						case SBC_SAMPLING_FREQ_16000:
 | 
				
			||||||
        case SBC_SAMPLING_FREQ_32000:
 | 
					        case SBC_SAMPLING_FREQ_32000:
 | 
				
			||||||
| 
						 | 
					@ -95,22 +96,22 @@ static uint8_t default_bitpool(uint8_t freq, uint8_t mode)
 | 
				
			||||||
		switch (mode) {
 | 
							switch (mode) {
 | 
				
			||||||
		case SBC_CHANNEL_MODE_MONO:
 | 
							case SBC_CHANNEL_MODE_MONO:
 | 
				
			||||||
		case SBC_CHANNEL_MODE_DUAL_CHANNEL:
 | 
							case SBC_CHANNEL_MODE_DUAL_CHANNEL:
 | 
				
			||||||
			return 31;
 | 
								return 38;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		case SBC_CHANNEL_MODE_STEREO:
 | 
							case SBC_CHANNEL_MODE_STEREO:
 | 
				
			||||||
		case SBC_CHANNEL_MODE_JOINT_STEREO:
 | 
							case SBC_CHANNEL_MODE_JOINT_STEREO:
 | 
				
			||||||
			return 53;
 | 
								return 64;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return 53;
 | 
							return 53;
 | 
				
			||||||
	case SBC_SAMPLING_FREQ_48000:
 | 
						case SBC_SAMPLING_FREQ_48000:
 | 
				
			||||||
		switch (mode) {
 | 
							switch (mode) {
 | 
				
			||||||
		case SBC_CHANNEL_MODE_MONO:
 | 
							case SBC_CHANNEL_MODE_MONO:
 | 
				
			||||||
		case SBC_CHANNEL_MODE_DUAL_CHANNEL:
 | 
							case SBC_CHANNEL_MODE_DUAL_CHANNEL:
 | 
				
			||||||
			return 29;
 | 
								return 35;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		case SBC_CHANNEL_MODE_STEREO:
 | 
							case SBC_CHANNEL_MODE_STEREO:
 | 
				
			||||||
		case SBC_CHANNEL_MODE_JOINT_STEREO:
 | 
							case SBC_CHANNEL_MODE_JOINT_STEREO:
 | 
				
			||||||
			return 51;
 | 
								return 62;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return 51;
 | 
							return 51;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -140,12 +141,12 @@ static int codec_select_config(const struct a2dp_codec *codec, uint32_t flags,
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		return -ENOTSUP;
 | 
							return -ENOTSUP;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (conf.channel_mode & SBC_CHANNEL_MODE_JOINT_STEREO)
 | 
						if (conf.channel_mode & SBC_CHANNEL_MODE_DUAL_CHANNEL)
 | 
				
			||||||
 | 
							conf.channel_mode = SBC_CHANNEL_MODE_DUAL_CHANNEL;
 | 
				
			||||||
 | 
						else if (conf.channel_mode & SBC_CHANNEL_MODE_JOINT_STEREO)
 | 
				
			||||||
		conf.channel_mode = SBC_CHANNEL_MODE_JOINT_STEREO;
 | 
							conf.channel_mode = SBC_CHANNEL_MODE_JOINT_STEREO;
 | 
				
			||||||
	else if (conf.channel_mode & SBC_CHANNEL_MODE_STEREO)
 | 
						else if (conf.channel_mode & SBC_CHANNEL_MODE_STEREO)
 | 
				
			||||||
		conf.channel_mode = SBC_CHANNEL_MODE_STEREO;
 | 
							conf.channel_mode = SBC_CHANNEL_MODE_STEREO;
 | 
				
			||||||
	else if (conf.channel_mode & SBC_CHANNEL_MODE_DUAL_CHANNEL)
 | 
					 | 
				
			||||||
		conf.channel_mode = SBC_CHANNEL_MODE_DUAL_CHANNEL;
 | 
					 | 
				
			||||||
	else if (conf.channel_mode & SBC_CHANNEL_MODE_MONO)
 | 
						else if (conf.channel_mode & SBC_CHANNEL_MODE_MONO)
 | 
				
			||||||
		conf.channel_mode = SBC_CHANNEL_MODE_MONO;
 | 
							conf.channel_mode = SBC_CHANNEL_MODE_MONO;
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue