linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] a2dp-codecs: Remove wrong definition of SBC_MAX_BITPOOL
@ 2019-01-26 10:45 Pali Rohár
  2019-01-26 15:25 ` Luiz Augusto von Dentz
  2019-01-28 23:10 ` [PATCH v2] a2dp-codecs: Fix SBC_MAX_BITPOOL and add SBC quality modes Pali Rohár
  0 siblings, 2 replies; 8+ messages in thread
From: Pali Rohár @ 2019-01-26 10:45 UTC (permalink / raw)
  To: linux-bluetooth

According to A2DP specification; section SBC; Codec Specific Information
Elements; Minimum / Maximum Bitpool Value, range for Bitpool value is from
2 to 250. Decoder shell support 2 as Minimum Bitpool Value and High Quality
Bitpool value as the Maximum Bitpool Value at a minimum. A2DP defines
maximal High Quality Bitpool value as 53.

Therefore instead of SBC_MAX_BITPOOL macro, defines two macros, one for
minimal value of "Maximum Bitpool Value" and maximal value of "Maximum
Bitpool Value".

I have no idea what is origin of value 64 as it does not match minimum nor
maximum bitpool value. Lot of headsets declares maximum value to 53, so use
this value also in android/hal-audio-sbc.c
---
 android/hal-audio-sbc.c      | 6 +++---
 profiles/audio/a2dp-codecs.h | 3 ++-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/android/hal-audio-sbc.c b/android/hal-audio-sbc.c
index 80e271ed6..541b2d6a7 100644
--- a/android/hal-audio-sbc.c
+++ b/android/hal-audio-sbc.c
@@ -92,7 +92,7 @@ static const a2dp_sbc_t sbc_presets[] = {
 		.block_length = SBC_BLOCK_LENGTH_4 | SBC_BLOCK_LENGTH_8 |
 				SBC_BLOCK_LENGTH_12 | SBC_BLOCK_LENGTH_16,
 		.min_bitpool = SBC_MIN_BITPOOL,
-		.max_bitpool = SBC_MAX_BITPOOL
+		.max_bitpool = SBC_MAX_BITPOOL_MIN,
 	},
 	{
 		.frequency = SBC_SAMPLING_FREQ_44100,
@@ -101,7 +101,7 @@ static const a2dp_sbc_t sbc_presets[] = {
 		.allocation_method = SBC_ALLOCATION_LOUDNESS,
 		.block_length = SBC_BLOCK_LENGTH_16,
 		.min_bitpool = SBC_MIN_BITPOOL,
-		.max_bitpool = SBC_MAX_BITPOOL
+		.max_bitpool = SBC_MAX_BITPOOL_MIN,
 	},
 	{
 		.frequency = SBC_SAMPLING_FREQ_48000,
@@ -110,7 +110,7 @@ static const a2dp_sbc_t sbc_presets[] = {
 		.allocation_method = SBC_ALLOCATION_LOUDNESS,
 		.block_length = SBC_BLOCK_LENGTH_16,
 		.min_bitpool = SBC_MIN_BITPOOL,
-		.max_bitpool = SBC_MAX_BITPOOL
+		.max_bitpool = SBC_MAX_BITPOOL_MIN,
 	},
 };
 
diff --git a/profiles/audio/a2dp-codecs.h b/profiles/audio/a2dp-codecs.h
index 0bdd29110..f31f3a311 100644
--- a/profiles/audio/a2dp-codecs.h
+++ b/profiles/audio/a2dp-codecs.h
@@ -53,8 +53,9 @@
 #define SBC_ALLOCATION_SNR		(1 << 1)
 #define SBC_ALLOCATION_LOUDNESS		1
 
-#define SBC_MAX_BITPOOL			64
 #define SBC_MIN_BITPOOL			2
+#define SBC_MAX_BITPOOL_MIN		53
+#define SBC_MAX_BITPOOL_MAX		250
 
 #define MPEG_CHANNEL_MODE_MONO		(1 << 3)
 #define MPEG_CHANNEL_MODE_DUAL_CHANNEL	(1 << 2)
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] a2dp-codecs: Remove wrong definition of SBC_MAX_BITPOOL
  2019-01-26 10:45 [PATCH] a2dp-codecs: Remove wrong definition of SBC_MAX_BITPOOL Pali Rohár
@ 2019-01-26 15:25 ` Luiz Augusto von Dentz
  2019-01-27 10:07   ` Pali Rohár
  2019-01-28 23:10 ` [PATCH v2] a2dp-codecs: Fix SBC_MAX_BITPOOL and add SBC quality modes Pali Rohár
  1 sibling, 1 reply; 8+ messages in thread
From: Luiz Augusto von Dentz @ 2019-01-26 15:25 UTC (permalink / raw)
  To: Pali Rohár; +Cc: linux-bluetooth

Hi Pali,

On Sat, Jan 26, 2019 at 12:47 PM Pali Rohár <pali.rohar@gmail.com> wrote:
>
> According to A2DP specification; section SBC; Codec Specific Information
> Elements; Minimum / Maximum Bitpool Value, range for Bitpool value is from
> 2 to 250. Decoder shell support 2 as Minimum Bitpool Value and High Quality
> Bitpool value as the Maximum Bitpool Value at a minimum. A2DP defines
> maximal High Quality Bitpool value as 53.

A2DP recommends 53 bitpool for high quality, 64 was used as upper
bound to limit bandwidth so it had nothing to do with A2DP more like a
interval detail.

> Therefore instead of SBC_MAX_BITPOOL macro, defines two macros, one for
> minimal value of "Maximum Bitpool Value" and maximal value of "Maximum
> Bitpool Value".

We could define the recommended bitpools by quality, like the A2DP do,
and then the MAX to 250, that should make it a bit more clearer.

> I have no idea what is origin of value 64 as it does not match minimum nor
> maximum bitpool value. Lot of headsets declares maximum value to 53, so use
> this value also in android/hal-audio-sbc.c

We could define 64 as ultra high quality for those that wish a better
quality than 53, past that there a very limited return in terms of
quality.

> ---
>  android/hal-audio-sbc.c      | 6 +++---
>  profiles/audio/a2dp-codecs.h | 3 ++-
>  2 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/android/hal-audio-sbc.c b/android/hal-audio-sbc.c
> index 80e271ed6..541b2d6a7 100644
> --- a/android/hal-audio-sbc.c
> +++ b/android/hal-audio-sbc.c
> @@ -92,7 +92,7 @@ static const a2dp_sbc_t sbc_presets[] = {
>                 .block_length = SBC_BLOCK_LENGTH_4 | SBC_BLOCK_LENGTH_8 |
>                                 SBC_BLOCK_LENGTH_12 | SBC_BLOCK_LENGTH_16,
>                 .min_bitpool = SBC_MIN_BITPOOL,
> -               .max_bitpool = SBC_MAX_BITPOOL
> +               .max_bitpool = SBC_MAX_BITPOOL_MIN,
>         },
>         {
>                 .frequency = SBC_SAMPLING_FREQ_44100,
> @@ -101,7 +101,7 @@ static const a2dp_sbc_t sbc_presets[] = {
>                 .allocation_method = SBC_ALLOCATION_LOUDNESS,
>                 .block_length = SBC_BLOCK_LENGTH_16,
>                 .min_bitpool = SBC_MIN_BITPOOL,
> -               .max_bitpool = SBC_MAX_BITPOOL
> +               .max_bitpool = SBC_MAX_BITPOOL_MIN,
>         },
>         {
>                 .frequency = SBC_SAMPLING_FREQ_48000,
> @@ -110,7 +110,7 @@ static const a2dp_sbc_t sbc_presets[] = {
>                 .allocation_method = SBC_ALLOCATION_LOUDNESS,
>                 .block_length = SBC_BLOCK_LENGTH_16,
>                 .min_bitpool = SBC_MIN_BITPOOL,
> -               .max_bitpool = SBC_MAX_BITPOOL
> +               .max_bitpool = SBC_MAX_BITPOOL_MIN,
>         },
>  };
>
> diff --git a/profiles/audio/a2dp-codecs.h b/profiles/audio/a2dp-codecs.h
> index 0bdd29110..f31f3a311 100644
> --- a/profiles/audio/a2dp-codecs.h
> +++ b/profiles/audio/a2dp-codecs.h
> @@ -53,8 +53,9 @@
>  #define SBC_ALLOCATION_SNR             (1 << 1)
>  #define SBC_ALLOCATION_LOUDNESS                1
>
> -#define SBC_MAX_BITPOOL                        64
>  #define SBC_MIN_BITPOOL                        2
> +#define SBC_MAX_BITPOOL_MIN            53
> +#define SBC_MAX_BITPOOL_MAX            250
>
>  #define MPEG_CHANNEL_MODE_MONO         (1 << 3)
>  #define MPEG_CHANNEL_MODE_DUAL_CHANNEL (1 << 2)
> --
> 2.11.0
>


-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] a2dp-codecs: Remove wrong definition of SBC_MAX_BITPOOL
  2019-01-26 15:25 ` Luiz Augusto von Dentz
@ 2019-01-27 10:07   ` Pali Rohár
  0 siblings, 0 replies; 8+ messages in thread
From: Pali Rohár @ 2019-01-27 10:07 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

[-- Attachment #1: Type: text/plain, Size: 4528 bytes --]

On Saturday 26 January 2019 17:25:18 Luiz Augusto von Dentz wrote:
> Hi Pali,
> 
> On Sat, Jan 26, 2019 at 12:47 PM Pali Rohár <pali.rohar@gmail.com> wrote:
> >
> > According to A2DP specification; section SBC; Codec Specific Information
> > Elements; Minimum / Maximum Bitpool Value, range for Bitpool value is from
> > 2 to 250. Decoder shell support 2 as Minimum Bitpool Value and High Quality
> > Bitpool value as the Maximum Bitpool Value at a minimum. A2DP defines
> > maximal High Quality Bitpool value as 53.
> 
> A2DP recommends 53 bitpool for high quality, 64 was used as upper
> bound to limit bandwidth so it had nothing to do with A2DP more like a
> interval detail.

I though that all values in a2dp-codecs.h files matches specifications.
So this value not.

> > Therefore instead of SBC_MAX_BITPOOL macro, defines two macros, one for
> > minimal value of "Maximum Bitpool Value" and maximal value of "Maximum
> > Bitpool Value".
> 
> We could define the recommended bitpools by quality, like the A2DP do,
> and then the MAX to 250, that should make it a bit more clearer.

There are eight recommended bitpool values in A2DP (2x quality; 2x mode;
2x frequency). Do you think that it is useful?

Currently I defined these values in pulseaudio sbc codec in "quality"
structure...

... but seems that a2dp-codecs.h is the place where it should be
defined. So should I put all these recommended values into this file? Or
have it only in pulseaudio?

> > I have no idea what is origin of value 64 as it does not match minimum nor
> > maximum bitpool value. Lot of headsets declares maximum value to 53, so use
> > this value also in android/hal-audio-sbc.c
> 
> We could define 64 as ultra high quality for those that wish a better
> quality than 53, past that there a very limited return in terms of
> quality.

I'm experimenting with value 76 for ultra high quality mode. It has
bitrate 454.8 kbps and minimize unused bytes in A2DP transfer.

But question is, what value do you want to have in file
android/hal-audio-sbc.c? This file is not used on Linux desktop, so I
cannot test this module...

> > ---
> >  android/hal-audio-sbc.c      | 6 +++---
> >  profiles/audio/a2dp-codecs.h | 3 ++-
> >  2 files changed, 5 insertions(+), 4 deletions(-)
> >
> > diff --git a/android/hal-audio-sbc.c b/android/hal-audio-sbc.c
> > index 80e271ed6..541b2d6a7 100644
> > --- a/android/hal-audio-sbc.c
> > +++ b/android/hal-audio-sbc.c
> > @@ -92,7 +92,7 @@ static const a2dp_sbc_t sbc_presets[] = {
> >                 .block_length = SBC_BLOCK_LENGTH_4 | SBC_BLOCK_LENGTH_8 |
> >                                 SBC_BLOCK_LENGTH_12 | SBC_BLOCK_LENGTH_16,
> >                 .min_bitpool = SBC_MIN_BITPOOL,
> > -               .max_bitpool = SBC_MAX_BITPOOL
> > +               .max_bitpool = SBC_MAX_BITPOOL_MIN,
> >         },
> >         {
> >                 .frequency = SBC_SAMPLING_FREQ_44100,
> > @@ -101,7 +101,7 @@ static const a2dp_sbc_t sbc_presets[] = {
> >                 .allocation_method = SBC_ALLOCATION_LOUDNESS,
> >                 .block_length = SBC_BLOCK_LENGTH_16,
> >                 .min_bitpool = SBC_MIN_BITPOOL,
> > -               .max_bitpool = SBC_MAX_BITPOOL
> > +               .max_bitpool = SBC_MAX_BITPOOL_MIN,
> >         },
> >         {
> >                 .frequency = SBC_SAMPLING_FREQ_48000,
> > @@ -110,7 +110,7 @@ static const a2dp_sbc_t sbc_presets[] = {
> >                 .allocation_method = SBC_ALLOCATION_LOUDNESS,
> >                 .block_length = SBC_BLOCK_LENGTH_16,
> >                 .min_bitpool = SBC_MIN_BITPOOL,
> > -               .max_bitpool = SBC_MAX_BITPOOL
> > +               .max_bitpool = SBC_MAX_BITPOOL_MIN,
> >         },
> >  };
> >
> > diff --git a/profiles/audio/a2dp-codecs.h b/profiles/audio/a2dp-codecs.h
> > index 0bdd29110..f31f3a311 100644
> > --- a/profiles/audio/a2dp-codecs.h
> > +++ b/profiles/audio/a2dp-codecs.h
> > @@ -53,8 +53,9 @@
> >  #define SBC_ALLOCATION_SNR             (1 << 1)
> >  #define SBC_ALLOCATION_LOUDNESS                1
> >
> > -#define SBC_MAX_BITPOOL                        64
> >  #define SBC_MIN_BITPOOL                        2
> > +#define SBC_MAX_BITPOOL_MIN            53
> > +#define SBC_MAX_BITPOOL_MAX            250
> >
> >  #define MPEG_CHANNEL_MODE_MONO         (1 << 3)
> >  #define MPEG_CHANNEL_MODE_DUAL_CHANNEL (1 << 2)
> > --
> > 2.11.0
> >
> 
> 

-- 
Pali Rohár
pali.rohar@gmail.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2] a2dp-codecs: Fix SBC_MAX_BITPOOL and add SBC quality modes
  2019-01-26 10:45 [PATCH] a2dp-codecs: Remove wrong definition of SBC_MAX_BITPOOL Pali Rohár
  2019-01-26 15:25 ` Luiz Augusto von Dentz
@ 2019-01-28 23:10 ` Pali Rohár
  2019-01-29 11:46   ` Luiz Augusto von Dentz
  1 sibling, 1 reply; 8+ messages in thread
From: Pali Rohár @ 2019-01-28 23:10 UTC (permalink / raw)
  To: linux-bluetooth

According to A2DP specification; section SBC; Codec Specific Information
Elements; Minimum / Maximum Bitpool Value, range for Bitpool value is from
2 to 250.

A2DP specification also defines bitpool values for two SBC modes: Middle
Quality and High Quality. They depends on channel mode and frequency. So
add definitions for them into a2dp-codecs file too.

File android/hal-audio-sbc.c was updated to use High Quality mode for
chosen frequency.
---
 android/hal-audio-sbc.c      |  6 +++---
 profiles/audio/a2dp-codecs.h | 12 +++++++++++-
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/android/hal-audio-sbc.c b/android/hal-audio-sbc.c
index 80e271ed6..f11f40108 100644
--- a/android/hal-audio-sbc.c
+++ b/android/hal-audio-sbc.c
@@ -92,7 +92,7 @@ static const a2dp_sbc_t sbc_presets[] = {
 		.block_length = SBC_BLOCK_LENGTH_4 | SBC_BLOCK_LENGTH_8 |
 				SBC_BLOCK_LENGTH_12 | SBC_BLOCK_LENGTH_16,
 		.min_bitpool = SBC_MIN_BITPOOL,
-		.max_bitpool = SBC_MAX_BITPOOL
+		.max_bitpool = SBC_BITPOOL_HIGH_QUALITY_JOINT_STEREO_44100,
 	},
 	{
 		.frequency = SBC_SAMPLING_FREQ_44100,
@@ -101,7 +101,7 @@ static const a2dp_sbc_t sbc_presets[] = {
 		.allocation_method = SBC_ALLOCATION_LOUDNESS,
 		.block_length = SBC_BLOCK_LENGTH_16,
 		.min_bitpool = SBC_MIN_BITPOOL,
-		.max_bitpool = SBC_MAX_BITPOOL
+		.max_bitpool = SBC_BITPOOL_HIGH_QUALITY_JOINT_STEREO_44100,
 	},
 	{
 		.frequency = SBC_SAMPLING_FREQ_48000,
@@ -110,7 +110,7 @@ static const a2dp_sbc_t sbc_presets[] = {
 		.allocation_method = SBC_ALLOCATION_LOUDNESS,
 		.block_length = SBC_BLOCK_LENGTH_16,
 		.min_bitpool = SBC_MIN_BITPOOL,
-		.max_bitpool = SBC_MAX_BITPOOL
+		.max_bitpool = SBC_BITPOOL_HIGH_QUALITY_JOINT_STEREO_48000,
 	},
 };
 
diff --git a/profiles/audio/a2dp-codecs.h b/profiles/audio/a2dp-codecs.h
index 16088dc26..9bdd0f0b8 100644
--- a/profiles/audio/a2dp-codecs.h
+++ b/profiles/audio/a2dp-codecs.h
@@ -53,8 +53,18 @@
 #define SBC_ALLOCATION_SNR		(1 << 1)
 #define SBC_ALLOCATION_LOUDNESS		1
 
-#define SBC_MAX_BITPOOL			64
 #define SBC_MIN_BITPOOL			2
+#define SBC_MAX_BITPOOL			250
+
+/* Other settings: Block length = 16, Allocation method = Loudness, Subbands = 8 */
+#define SBC_BITPOOL_MIDDLE_QUALITY_MONO_44100		19
+#define SBC_BITPOOL_MIDDLE_QUALITY_MONO_48000		18
+#define SBC_BITPOOL_MIDDLE_QUALITY_JOINT_STEREO_44100	35
+#define SBC_BITPOOL_MIDDLE_QUALITY_JOINT_STEREO_48000	33
+#define SBC_BITPOOL_HIGH_QUALITY_MONO_44100		31
+#define SBC_BITPOOL_HIGH_QUALITY_MONO_48000		29
+#define SBC_BITPOOL_HIGH_QUALITY_JOINT_STEREO_44100	53
+#define SBC_BITPOOL_HIGH_QUALITY_JOINT_STEREO_48000	51
 
 #define MPEG_CHANNEL_MODE_MONO		(1 << 3)
 #define MPEG_CHANNEL_MODE_DUAL_CHANNEL	(1 << 2)
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] a2dp-codecs: Fix SBC_MAX_BITPOOL and add SBC quality modes
  2019-01-28 23:10 ` [PATCH v2] a2dp-codecs: Fix SBC_MAX_BITPOOL and add SBC quality modes Pali Rohár
@ 2019-01-29 11:46   ` Luiz Augusto von Dentz
  2019-01-29 17:12     ` [PATCH v3] " Pali Rohár
  0 siblings, 1 reply; 8+ messages in thread
From: Luiz Augusto von Dentz @ 2019-01-29 11:46 UTC (permalink / raw)
  To: Pali Rohár; +Cc: linux-bluetooth

Hi Pali,
On Tue, Jan 29, 2019 at 1:12 AM Pali Rohár <pali.rohar@gmail.com> wrote:
>
> According to A2DP specification; section SBC; Codec Specific Information
> Elements; Minimum / Maximum Bitpool Value, range for Bitpool value is from
> 2 to 250.
>
> A2DP specification also defines bitpool values for two SBC modes: Middle
> Quality and High Quality. They depends on channel mode and frequency. So
> add definitions for them into a2dp-codecs file too.
>
> File android/hal-audio-sbc.c was updated to use High Quality mode for
> chosen frequency.
> ---
>  android/hal-audio-sbc.c      |  6 +++---
>  profiles/audio/a2dp-codecs.h | 12 +++++++++++-
>  2 files changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/android/hal-audio-sbc.c b/android/hal-audio-sbc.c
> index 80e271ed6..f11f40108 100644
> --- a/android/hal-audio-sbc.c
> +++ b/android/hal-audio-sbc.c
> @@ -92,7 +92,7 @@ static const a2dp_sbc_t sbc_presets[] = {
>                 .block_length = SBC_BLOCK_LENGTH_4 | SBC_BLOCK_LENGTH_8 |
>                                 SBC_BLOCK_LENGTH_12 | SBC_BLOCK_LENGTH_16,
>                 .min_bitpool = SBC_MIN_BITPOOL,
> -               .max_bitpool = SBC_MAX_BITPOOL
> +               .max_bitpool = SBC_BITPOOL_HIGH_QUALITY_JOINT_STEREO_44100,
>         },
>         {
>                 .frequency = SBC_SAMPLING_FREQ_44100,
> @@ -101,7 +101,7 @@ static const a2dp_sbc_t sbc_presets[] = {
>                 .allocation_method = SBC_ALLOCATION_LOUDNESS,
>                 .block_length = SBC_BLOCK_LENGTH_16,
>                 .min_bitpool = SBC_MIN_BITPOOL,
> -               .max_bitpool = SBC_MAX_BITPOOL
> +               .max_bitpool = SBC_BITPOOL_HIGH_QUALITY_JOINT_STEREO_44100,
>         },
>         {
>                 .frequency = SBC_SAMPLING_FREQ_48000,
> @@ -110,7 +110,7 @@ static const a2dp_sbc_t sbc_presets[] = {
>                 .allocation_method = SBC_ALLOCATION_LOUDNESS,
>                 .block_length = SBC_BLOCK_LENGTH_16,
>                 .min_bitpool = SBC_MIN_BITPOOL,
> -               .max_bitpool = SBC_MAX_BITPOOL
> +               .max_bitpool = SBC_BITPOOL_HIGH_QUALITY_JOINT_STEREO_48000,
>         },
>  };
>
> diff --git a/profiles/audio/a2dp-codecs.h b/profiles/audio/a2dp-codecs.h
> index 16088dc26..9bdd0f0b8 100644
> --- a/profiles/audio/a2dp-codecs.h
> +++ b/profiles/audio/a2dp-codecs.h
> @@ -53,8 +53,18 @@
>  #define SBC_ALLOCATION_SNR             (1 << 1)
>  #define SBC_ALLOCATION_LOUDNESS                1
>
> -#define SBC_MAX_BITPOOL                        64
>  #define SBC_MIN_BITPOOL                        2
> +#define SBC_MAX_BITPOOL                        250
> +
> +/* Other settings: Block length = 16, Allocation method = Loudness, Subbands = 8 */
> +#define SBC_BITPOOL_MIDDLE_QUALITY_MONO_44100          19
> +#define SBC_BITPOOL_MIDDLE_QUALITY_MONO_48000          18
> +#define SBC_BITPOOL_MIDDLE_QUALITY_JOINT_STEREO_44100  35
> +#define SBC_BITPOOL_MIDDLE_QUALITY_JOINT_STEREO_48000  33
> +#define SBC_BITPOOL_HIGH_QUALITY_MONO_44100            31
> +#define SBC_BITPOOL_HIGH_QUALITY_MONO_48000            29
> +#define SBC_BITPOOL_HIGH_QUALITY_JOINT_STEREO_44100    53
> +#define SBC_BITPOOL_HIGH_QUALITY_JOINT_STEREO_48000    51

Im quite fine with the new defines just their names could be a bit
shorter, perhaps use MQ and HQ for middle and high quality.

>  #define MPEG_CHANNEL_MODE_MONO         (1 << 3)
>  #define MPEG_CHANNEL_MODE_DUAL_CHANNEL (1 << 2)
> --
> 2.11.0
>


-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v3] a2dp-codecs: Fix SBC_MAX_BITPOOL and add SBC quality modes
  2019-01-29 11:46   ` Luiz Augusto von Dentz
@ 2019-01-29 17:12     ` Pali Rohár
  2019-01-31 10:52       ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 8+ messages in thread
From: Pali Rohár @ 2019-01-29 17:12 UTC (permalink / raw)
  To: linux-bluetooth

According to A2DP specification; section SBC; Codec Specific Information
Elements; Minimum / Maximum Bitpool Value, range for Bitpool value is from
2 to 250.

A2DP specification also defines bitpool values for two SBC modes: Middle
Quality and High Quality. They depends on channel mode and frequency. So
add definitions for them into a2dp-codecs file too.

File android/hal-audio-sbc.c was updated to use High Quality mode for
chosen frequency.
---
 android/hal-audio-sbc.c      |  6 +++---
 profiles/audio/a2dp-codecs.h | 12 +++++++++++-
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/android/hal-audio-sbc.c b/android/hal-audio-sbc.c
index 80e271ed6..b06cafb7b 100644
--- a/android/hal-audio-sbc.c
+++ b/android/hal-audio-sbc.c
@@ -92,7 +92,7 @@ static const a2dp_sbc_t sbc_presets[] = {
 		.block_length = SBC_BLOCK_LENGTH_4 | SBC_BLOCK_LENGTH_8 |
 				SBC_BLOCK_LENGTH_12 | SBC_BLOCK_LENGTH_16,
 		.min_bitpool = SBC_MIN_BITPOOL,
-		.max_bitpool = SBC_MAX_BITPOOL
+		.max_bitpool = SBC_BITPOOL_HQ_JOINT_STEREO_44100,
 	},
 	{
 		.frequency = SBC_SAMPLING_FREQ_44100,
@@ -101,7 +101,7 @@ static const a2dp_sbc_t sbc_presets[] = {
 		.allocation_method = SBC_ALLOCATION_LOUDNESS,
 		.block_length = SBC_BLOCK_LENGTH_16,
 		.min_bitpool = SBC_MIN_BITPOOL,
-		.max_bitpool = SBC_MAX_BITPOOL
+		.max_bitpool = SBC_BITPOOL_HQ_JOINT_STEREO_44100,
 	},
 	{
 		.frequency = SBC_SAMPLING_FREQ_48000,
@@ -110,7 +110,7 @@ static const a2dp_sbc_t sbc_presets[] = {
 		.allocation_method = SBC_ALLOCATION_LOUDNESS,
 		.block_length = SBC_BLOCK_LENGTH_16,
 		.min_bitpool = SBC_MIN_BITPOOL,
-		.max_bitpool = SBC_MAX_BITPOOL
+		.max_bitpool = SBC_BITPOOL_HQ_JOINT_STEREO_48000,
 	},
 };
 
diff --git a/profiles/audio/a2dp-codecs.h b/profiles/audio/a2dp-codecs.h
index 16088dc26..0d2cc155b 100644
--- a/profiles/audio/a2dp-codecs.h
+++ b/profiles/audio/a2dp-codecs.h
@@ -53,8 +53,18 @@
 #define SBC_ALLOCATION_SNR		(1 << 1)
 #define SBC_ALLOCATION_LOUDNESS		1
 
-#define SBC_MAX_BITPOOL			64
 #define SBC_MIN_BITPOOL			2
+#define SBC_MAX_BITPOOL			250
+
+/* Other settings: Block length = 16, Allocation method = Loudness, Subbands = 8 */
+#define SBC_BITPOOL_MQ_MONO_44100		19
+#define SBC_BITPOOL_MQ_MONO_48000		18
+#define SBC_BITPOOL_MQ_JOINT_STEREO_44100	35
+#define SBC_BITPOOL_MQ_JOINT_STEREO_48000	33
+#define SBC_BITPOOL_HQ_MONO_44100		31
+#define SBC_BITPOOL_HQ_MONO_48000		29
+#define SBC_BITPOOL_HQ_JOINT_STEREO_44100	53
+#define SBC_BITPOOL_HQ_JOINT_STEREO_48000	51
 
 #define MPEG_CHANNEL_MODE_MONO		(1 << 3)
 #define MPEG_CHANNEL_MODE_DUAL_CHANNEL	(1 << 2)
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v3] a2dp-codecs: Fix SBC_MAX_BITPOOL and add SBC quality modes
  2019-01-29 17:12     ` [PATCH v3] " Pali Rohár
@ 2019-01-31 10:52       ` Luiz Augusto von Dentz
  2019-01-31 11:13         ` Pali Rohár
  0 siblings, 1 reply; 8+ messages in thread
From: Luiz Augusto von Dentz @ 2019-01-31 10:52 UTC (permalink / raw)
  To: Pali Rohár; +Cc: linux-bluetooth

Hi Pali,

On Tue, Jan 29, 2019 at 7:14 PM Pali Rohár <pali.rohar@gmail.com> wrote:
>
> According to A2DP specification; section SBC; Codec Specific Information
> Elements; Minimum / Maximum Bitpool Value, range for Bitpool value is from
> 2 to 250.
>
> A2DP specification also defines bitpool values for two SBC modes: Middle
> Quality and High Quality. They depends on channel mode and frequency. So
> add definitions for them into a2dp-codecs file too.
>
> File android/hal-audio-sbc.c was updated to use High Quality mode for
> chosen frequency.
> ---
>  android/hal-audio-sbc.c      |  6 +++---
>  profiles/audio/a2dp-codecs.h | 12 +++++++++++-
>  2 files changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/android/hal-audio-sbc.c b/android/hal-audio-sbc.c
> index 80e271ed6..b06cafb7b 100644
> --- a/android/hal-audio-sbc.c
> +++ b/android/hal-audio-sbc.c
> @@ -92,7 +92,7 @@ static const a2dp_sbc_t sbc_presets[] = {
>                 .block_length = SBC_BLOCK_LENGTH_4 | SBC_BLOCK_LENGTH_8 |
>                                 SBC_BLOCK_LENGTH_12 | SBC_BLOCK_LENGTH_16,
>                 .min_bitpool = SBC_MIN_BITPOOL,
> -               .max_bitpool = SBC_MAX_BITPOOL
> +               .max_bitpool = SBC_BITPOOL_HQ_JOINT_STEREO_44100,
>         },
>         {
>                 .frequency = SBC_SAMPLING_FREQ_44100,
> @@ -101,7 +101,7 @@ static const a2dp_sbc_t sbc_presets[] = {
>                 .allocation_method = SBC_ALLOCATION_LOUDNESS,
>                 .block_length = SBC_BLOCK_LENGTH_16,
>                 .min_bitpool = SBC_MIN_BITPOOL,
> -               .max_bitpool = SBC_MAX_BITPOOL
> +               .max_bitpool = SBC_BITPOOL_HQ_JOINT_STEREO_44100,
>         },
>         {
>                 .frequency = SBC_SAMPLING_FREQ_48000,
> @@ -110,7 +110,7 @@ static const a2dp_sbc_t sbc_presets[] = {
>                 .allocation_method = SBC_ALLOCATION_LOUDNESS,
>                 .block_length = SBC_BLOCK_LENGTH_16,
>                 .min_bitpool = SBC_MIN_BITPOOL,
> -               .max_bitpool = SBC_MAX_BITPOOL
> +               .max_bitpool = SBC_BITPOOL_HQ_JOINT_STEREO_48000,
>         },
>  };
>
> diff --git a/profiles/audio/a2dp-codecs.h b/profiles/audio/a2dp-codecs.h
> index 16088dc26..0d2cc155b 100644
> --- a/profiles/audio/a2dp-codecs.h
> +++ b/profiles/audio/a2dp-codecs.h
> @@ -53,8 +53,18 @@
>  #define SBC_ALLOCATION_SNR             (1 << 1)
>  #define SBC_ALLOCATION_LOUDNESS                1
>
> -#define SBC_MAX_BITPOOL                        64
>  #define SBC_MIN_BITPOOL                        2
> +#define SBC_MAX_BITPOOL                        250
> +
> +/* Other settings: Block length = 16, Allocation method = Loudness, Subbands = 8 */
> +#define SBC_BITPOOL_MQ_MONO_44100              19
> +#define SBC_BITPOOL_MQ_MONO_48000              18
> +#define SBC_BITPOOL_MQ_JOINT_STEREO_44100      35
> +#define SBC_BITPOOL_MQ_JOINT_STEREO_48000      33
> +#define SBC_BITPOOL_HQ_MONO_44100              31
> +#define SBC_BITPOOL_HQ_MONO_48000              29
> +#define SBC_BITPOOL_HQ_JOINT_STEREO_44100      53
> +#define SBC_BITPOOL_HQ_JOINT_STEREO_48000      51
>
>  #define MPEG_CHANNEL_MODE_MONO         (1 << 3)
>  #define MPEG_CHANNEL_MODE_DUAL_CHANNEL (1 << 2)
> --
> 2.11.0

Applied, thanks. Note that I did have to change some comments which
had line going over 80 columns.


-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3] a2dp-codecs: Fix SBC_MAX_BITPOOL and add SBC quality modes
  2019-01-31 10:52       ` Luiz Augusto von Dentz
@ 2019-01-31 11:13         ` Pali Rohár
  0 siblings, 0 replies; 8+ messages in thread
From: Pali Rohár @ 2019-01-31 11:13 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

On Thursday 31 January 2019 12:52:09 Luiz Augusto von Dentz wrote:
> Applied, thanks. Note that I did have to change some comments which
> had line going over 80 columns.

Ok, no problem.

-- 
Pali Rohár
pali.rohar@gmail.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-01-31 11:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-26 10:45 [PATCH] a2dp-codecs: Remove wrong definition of SBC_MAX_BITPOOL Pali Rohár
2019-01-26 15:25 ` Luiz Augusto von Dentz
2019-01-27 10:07   ` Pali Rohár
2019-01-28 23:10 ` [PATCH v2] a2dp-codecs: Fix SBC_MAX_BITPOOL and add SBC quality modes Pali Rohár
2019-01-29 11:46   ` Luiz Augusto von Dentz
2019-01-29 17:12     ` [PATCH v3] " Pali Rohár
2019-01-31 10:52       ` Luiz Augusto von Dentz
2019-01-31 11:13         ` Pali Rohár

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).