]> granicus.if.org Git - esp-idf/commitdiff
component/bt: modify the SBC decoder to support mSBC mode
authorbaohongde <baohongde@espressif.com>
Mon, 15 Apr 2019 06:54:29 +0000 (14:54 +0800)
committerbaohongde <baohongde@espressif.com>
Fri, 24 May 2019 09:33:52 +0000 (17:33 +0800)
components/bt/bluedroid/external/sbc/decoder/include/oi_codec_sbc.h
components/bt/bluedroid/external/sbc/decoder/srce/decoder-private.c
components/bt/bluedroid/external/sbc/decoder/srce/decoder-sbc.c

index a3f7d875164a7f25aada69067f6ce1f9c71e48dd..6f31348957dc8dcc81f1bdd9d9d2f73ec8e41387 100644 (file)
@@ -76,6 +76,7 @@ Declarations of codec functions, data types, and macros.
 
 #define OI_SBC_SYNCWORD 0x9c
 #define OI_SBC_ENHANCED_SYNCWORD 0x9d
+#define OI_mSBC_SYNCWORD 0xad
 
 /**@name Sampling frequencies */
 /**@{*/
index 86c4fdf5963add7bab4e01cf0af1bb75a7e090d1..1e4d73995eb7d1b521ddf81128f9398e653b5582 100644 (file)
@@ -81,9 +81,6 @@ INLINE OI_STATUS internal_DecoderReset(OI_CODEC_SBC_DECODER_CONTEXT *context,
     return OI_OK;
 }
 
-
-
-
 /**
  * Read the SBC header up to but not including the joint stereo mask.  The syncword has already been
  * examined, and the enhanced mode flag set, by FindSyncword.
@@ -94,7 +91,33 @@ INLINE void OI_SBC_ReadHeader(OI_CODEC_SBC_COMMON_CONTEXT *common, const OI_BYTE
     OI_UINT8 d1;
 
 
-    OI_ASSERT(data[0] == OI_SBC_SYNCWORD || data[0] == OI_SBC_ENHANCED_SYNCWORD);
+    OI_ASSERT(data[0] == OI_SBC_SYNCWORD || data[0] == OI_SBC_ENHANCED_SYNCWORD
+                || data[0] == OI_mSBC_SYNCWORD);
+
+    /**
+     * For mSBC, just set those parameters
+     */
+    if (data[0] == OI_mSBC_SYNCWORD){
+        frame->freqIndex = 0;
+        frame->frequency = 16000;
+
+        frame->blocks = 4;
+        frame->nrof_blocks = 15;
+
+        frame->mode = 0;
+        frame->nrof_channels = 1;
+
+        frame->alloc = SBC_LOUDNESS;
+
+        frame->subbands = 1;
+        frame->nrof_subbands = 8;
+
+        frame->cachedInfo = 0;
+
+        frame->bitpool = 26;
+        frame->crc = data[3];
+        return;
+    }
 
     /* Avoid filling out all these strucutures if we already remember the values
      * from last time. Just in case we get a stream corresponding to data[1] ==
index 80a1f33546764b74eaa6afb320aa5667411e866a..b2cd75cec926fb53f8129c4bcecbcc67f797cbe2 100644 (file)
@@ -79,7 +79,9 @@ PRIVATE OI_STATUS FindSyncword(OI_CODEC_SBC_DECODER_CONTEXT *context,
         return OI_CODEC_SBC_NO_SYNCWORD;
     }
 #else  // SBC_ENHANCED
-    while (*frameBytes && (**frameData != OI_SBC_SYNCWORD)) {
+
+    while (*frameBytes && (**frameData != OI_SBC_SYNCWORD)
+            && (**frameData != OI_mSBC_SYNCWORD)) {
         (*frameBytes)--;
         (*frameData)++;
     }