[PATCH 04/11] Add msbc encoding and decoding flag

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 sbc/sbc.c |   16 ++++++++++++++++
 sbc/sbc.h |    3 +++
 2 files changed, 19 insertions(+)

diff --git a/sbc/sbc.c b/sbc/sbc.c
index 6fff132..c40aa15 100644
--- a/sbc/sbc.c
+++ b/sbc/sbc.c
@@ -52,6 +52,9 @@
 
 #define SBC_SYNCWORD	0x9C
 
+#define MSBC_SYNCWORD       0xAD
+#define MSBC_BLOCKS         15
+
 /* This structure contains an unpacked SBC frame.
    Yes, there is probably quite some unused space herein */
 struct sbc_frame {
@@ -920,6 +923,7 @@ struct sbc_priv {
 
 static void sbc_set_defaults(sbc_t *sbc, unsigned long flags)
 {
+	sbc->flags = flags;
 	sbc->frequency = SBC_FREQ_44100;
 	sbc->mode = SBC_MODE_STEREO;
 	sbc->subbands = SBC_SB_8;
@@ -982,6 +986,8 @@ SBC_EXPORT ssize_t sbc_decode(sbc_t *sbc, const void *input, size_t input_len,
 		sbc->mode = priv->frame.mode;
 		sbc->subbands = priv->frame.subband_mode;
 		sbc->blocks = priv->frame.block_mode;
+		if (sbc->flags & SBC_MSBC)
+			sbc->blocks = MSBC_BLOCKS;
 		sbc->allocation = priv->frame.allocation;
 		sbc->bitpool = priv->frame.bitpool;
 
@@ -1056,6 +1062,8 @@ SBC_EXPORT ssize_t sbc_encode(sbc_t *sbc, const void *input, size_t input_len,
 		priv->frame.subbands = sbc->subbands ? 8 : 4;
 		priv->frame.block_mode = sbc->blocks;
 		priv->frame.blocks = 4 + (sbc->blocks * 4);
+		if (sbc->flags & SBC_MSBC)
+			priv->frame.blocks = MSBC_BLOCKS;
 		priv->frame.bitpool = sbc->bitpool;
 		priv->frame.codesize = sbc_get_codesize(sbc);
 		priv->frame.length = sbc_get_frame_length(sbc);
@@ -1140,6 +1148,8 @@ SBC_EXPORT size_t sbc_get_frame_length(sbc_t *sbc)
 
 	subbands = sbc->subbands ? 8 : 4;
 	blocks = 4 + (sbc->blocks * 4);
+	if (sbc->flags & SBC_MSBC)
+		blocks = MSBC_BLOCKS;
 	channels = sbc->mode == SBC_MODE_MONO ? 1 : 2;
 	joint = sbc->mode == SBC_MODE_JOINT_STEREO ? 1 : 0;
 	bitpool = sbc->bitpool;
@@ -1169,6 +1179,9 @@ SBC_EXPORT unsigned sbc_get_frame_duration(sbc_t *sbc)
 		blocks = priv->frame.blocks;
 	}
 
+	if (sbc->flags & SBC_MSBC)
+		blocks = MSBC_BLOCKS;
+
 	switch (sbc->frequency) {
 	case SBC_FREQ_16000:
 		frequency = 16000;
@@ -1208,6 +1221,9 @@ SBC_EXPORT size_t sbc_get_codesize(sbc_t *sbc)
 		channels = priv->frame.channels;
 	}
 
+	if (sbc->flags & SBC_MSBC)
+		blocks = MSBC_BLOCKS;
+
 	return subbands * blocks * channels * 2;
 }
 
diff --git a/sbc/sbc.h b/sbc/sbc.h
index bbd45da..3511119 100644
--- a/sbc/sbc.h
+++ b/sbc/sbc.h
@@ -64,6 +64,9 @@ extern "C" {
 #define SBC_LE			0x00
 #define SBC_BE			0x01
 
+/* Additional features */
+#define SBC_MSBC		0x01
+
 struct sbc_struct {
 	unsigned long flags;
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux