From ced70f9bfeafe291ec597a3a9cc862e39e0da3ce Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Mon, 27 Nov 2023 17:25:01 +0100 Subject: [PATCH] bluedroid/encoder: delete commented sbc scramble code --- .../bluedroid/encoder/srce/sbc_encoder.c | 88 ------------------- 1 file changed, 88 deletions(-) diff --git a/3rd-party/bluedroid/encoder/srce/sbc_encoder.c b/3rd-party/bluedroid/encoder/srce/sbc_encoder.c index 843dae6bb..dc1d476ca 100644 --- a/3rd-party/bluedroid/encoder/srce/sbc_encoder.c +++ b/3rd-party/bluedroid/encoder/srce/sbc_encoder.c @@ -28,86 +28,6 @@ SINT16 EncMaxShiftCounter; -/************************************************************************************************* - * SBC encoder scramble code - * Purpose: to tie the SBC code with BTE/mobile stack code, - * especially for the case when the SBC is ported into a third-party Multimedia chip - * - * Algorithm: - * init process: all counters reset to 0, - * calculate base_index: (6 + s16NumOfChannels*s16NumOfSubBands/2) - * scramble side: the init process happens every time SBC_Encoder_Init() is called. - * descramble side: it would be nice to know if he "init" process has happened. - * alter the SBC SYNC word 0x9C (1001 1100) to 0x8C (1000 1100). - * - * scramble process: - * The CRC byte: - * Every SBC frame has a frame header. - * The 1st byte is the sync word and the following 2 bytes are about the stream format. - * They are supposed to be "constant" within a "song" - * The 4th byte is the CRC byte. The CRC byte is bound to be random. - * Derive 2 items from the CRC byte; one is the "use" bit, the other is the "index". - * - * SBC keeps 2 sets of "use" & "index"; derived the current and the previous frame. - * - * The "use" bit is any bit in SBC_PRTC_USE_MASK is set. - * If set, SBC uses the "index" from the current frame. - * If not set, SBC uses the "index" from the previous frame or 0. - * - * index = (CRC & 0x3) + ((CRC & 0x30) >> 2) // 8 is the max index - * - * if(index > 0) - * { - * p = &u8frame[base_index]; - * if((index&1)&&(u16PacketLength > (base_index+index*2))) - * { - * // odd index: swap 2 bytes - * tmp = p[index]; - * p[index] = p[index*2]; - * p[index*2] = tmp; - * } - * else - * { - * // even index: shift by 3 - * tmp = (p[index] >> 5) + (p[index] << 3); - * p[index] = tmp; - * } - * } - * //else index is 0. The frame stays unaltered - * - */ - -#define SBC_PRTC_CRC_IDX 3 -#define SBC_PRTC_USE_MASK 0x64 -#define SBC_PRTC_SYNC_MASK 0x10 -#define SBC_PRTC_CIDX 0 -#define SBC_PRTC_LIDX 1 -typedef struct -{ - UINT8 use; - UINT8 idx; -} tSBC_FR_CB; - -typedef struct -{ - tSBC_FR_CB fr[2]; - UINT8 init; - UINT8 index; - UINT8 base; -} tSBC_PRTC_CB; -tSBC_PRTC_CB sbc_prtc_cb; - -#define SBC_PRTC_IDX(sc) (((sc) & 0x3) + (((sc) & 0x30) >> 2)) -#define SBC_PRTC_CHK_INIT(ar) {if(sbc_prtc_cb.init == 0){sbc_prtc_cb.init=1; ar[0] &= ~SBC_PRTC_SYNC_MASK;}} -#define SBC_PRTC_C2L() {p_last=&sbc_prtc_cb.fr[SBC_PRTC_LIDX]; p_cur=&sbc_prtc_cb.fr[SBC_PRTC_CIDX]; \ - p_last->idx = p_cur->idx; p_last->use = p_cur->use;} -#define SBC_PRTC_GETC(ar) {p_cur->use = ar[SBC_PRTC_CRC_IDX] & SBC_PRTC_USE_MASK; \ - p_cur->idx = SBC_PRTC_IDX(ar[SBC_PRTC_CRC_IDX]);} -#define SBC_PRTC_CHK_CRC(ar) {SBC_PRTC_C2L();SBC_PRTC_GETC(ar);sbc_prtc_cb.index = (p_cur->use)?SBC_PRTC_CIDX:SBC_PRTC_LIDX;} -#define SBC_PRTC_SCRMB(ar) {idx = sbc_prtc_cb.fr[sbc_prtc_cb.index].idx; \ - if(idx > 0){if((idx&1)&&(pstrEncParams->u16PacketLength > (sbc_prtc_cb.base+(idx<<1)))) {tmp2=idx<<1; tmp=ar[idx];ar[idx]=ar[tmp2];ar[tmp2]=tmp;} \ - else{tmp2=ar[idx]; tmp=(tmp2>>5)+(tmp2<<3);ar[idx]=(UINT8)tmp;}}} - #if (SBC_JOINT_STE_INCLUDED == TRUE) SINT32 s32LRDiff[SBC_MAX_NUM_OF_BLOCKS] = {0}; SINT32 s32LRSum[SBC_MAX_NUM_OF_BLOCKS] = {0}; @@ -129,11 +49,6 @@ void SBC_Encoder(SBC_ENC_PARAMS *pstrEncParams) UINT32 u32CountSum,u32CountDiff; SINT32 *pSum, *pDiff; #endif - /* BK4BTSTACK_CHANGE START */ - // UINT8 *pu8; - // tSBC_FR_CB *p_cur, *p_last; - // UINT32 idx, tmp, tmp2; - /* BK4BTSTACK_CHANGE STOP */ register SINT32 s32NumOfSubBands = pstrEncParams->s16NumOfSubBands; pstrEncParams->pu8NextPacket = pstrEncParams->pu8Packet; @@ -395,7 +310,4 @@ void SBC_Encoder_Init(SBC_ENC_PARAMS *pstrEncParams) // pstrEncParams->u16BitRate, pstrEncParams->s16BitPool); SbcAnalysisInit(); - - memset(&sbc_prtc_cb, 0, sizeof(tSBC_PRTC_CB)); - sbc_prtc_cb.base = 6 + (pstrEncParams->s16NumOfChannels*pstrEncParams->s16NumOfSubBands/2); }