From e10d5aaddc4f1f8bf2aafba2cae35d8233e960a6 Mon Sep 17 00:00:00 2001 From: baohongde Date: Mon, 15 Apr 2019 14:54:29 +0800 Subject: [PATCH] component/bt: modify the SBC decoder to support mSBC mode --- .../sbc/decoder/include/oi_codec_sbc.h | 1 + .../sbc/decoder/srce/decoder-private.c | 31 ++++++++++++++++--- .../external/sbc/decoder/srce/decoder-sbc.c | 4 ++- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/components/bt/bluedroid/external/sbc/decoder/include/oi_codec_sbc.h b/components/bt/bluedroid/external/sbc/decoder/include/oi_codec_sbc.h index a3f7d87516..6f31348957 100644 --- a/components/bt/bluedroid/external/sbc/decoder/include/oi_codec_sbc.h +++ b/components/bt/bluedroid/external/sbc/decoder/include/oi_codec_sbc.h @@ -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 */ /**@{*/ diff --git a/components/bt/bluedroid/external/sbc/decoder/srce/decoder-private.c b/components/bt/bluedroid/external/sbc/decoder/srce/decoder-private.c index 86c4fdf596..1e4d73995e 100644 --- a/components/bt/bluedroid/external/sbc/decoder/srce/decoder-private.c +++ b/components/bt/bluedroid/external/sbc/decoder/srce/decoder-private.c @@ -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] == diff --git a/components/bt/bluedroid/external/sbc/decoder/srce/decoder-sbc.c b/components/bt/bluedroid/external/sbc/decoder/srce/decoder-sbc.c index 80a1f33546..b2cd75cec9 100644 --- a/components/bt/bluedroid/external/sbc/decoder/srce/decoder-sbc.c +++ b/components/bt/bluedroid/external/sbc/decoder/srce/decoder-sbc.c @@ -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)++; }