2016-11-02 05:42:26 -04:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Copyright (C) 2000-2012 Broadcom Corporation
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at:
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* nterface to low complexity subband codec (SBC)
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
#ifndef A2D_SBC_H
|
|
|
|
#define A2D_SBC_H
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
** Constants
|
|
|
|
*****************************************************************************/
|
|
|
|
/* the length of the SBC Media Payload header. */
|
|
|
|
#define A2D_SBC_MPL_HDR_LEN 1
|
|
|
|
|
|
|
|
/* the LOSC of SBC media codec capabilitiy */
|
|
|
|
#define A2D_SBC_INFO_LEN 6
|
|
|
|
|
|
|
|
/* for Codec Specific Information Element */
|
|
|
|
#define A2D_SBC_IE_SAMP_FREQ_MSK 0xF0 /* b7-b4 sampling frequency */
|
|
|
|
#define A2D_SBC_IE_SAMP_FREQ_16 0x80 /* b7:16 kHz */
|
|
|
|
#define A2D_SBC_IE_SAMP_FREQ_32 0x40 /* b6:32 kHz */
|
|
|
|
#define A2D_SBC_IE_SAMP_FREQ_44 0x20 /* b5:44.1kHz */
|
|
|
|
#define A2D_SBC_IE_SAMP_FREQ_48 0x10 /* b4:48 kHz */
|
|
|
|
|
|
|
|
#define A2D_SBC_IE_CH_MD_MSK 0x0F /* b3-b0 channel mode */
|
|
|
|
#define A2D_SBC_IE_CH_MD_MONO 0x08 /* b3: mono */
|
|
|
|
#define A2D_SBC_IE_CH_MD_DUAL 0x04 /* b2: dual */
|
|
|
|
#define A2D_SBC_IE_CH_MD_STEREO 0x02 /* b1: stereo */
|
|
|
|
#define A2D_SBC_IE_CH_MD_JOINT 0x01 /* b0: joint stereo */
|
|
|
|
|
|
|
|
#define A2D_SBC_IE_BLOCKS_MSK 0xF0 /* b7-b4 number of blocks */
|
|
|
|
#define A2D_SBC_IE_BLOCKS_4 0x80 /* 4 blocks */
|
|
|
|
#define A2D_SBC_IE_BLOCKS_8 0x40 /* 8 blocks */
|
|
|
|
#define A2D_SBC_IE_BLOCKS_12 0x20 /* 12blocks */
|
|
|
|
#define A2D_SBC_IE_BLOCKS_16 0x10 /* 16blocks */
|
|
|
|
|
|
|
|
#define A2D_SBC_IE_SUBBAND_MSK 0x0C /* b3-b2 number of subbands */
|
|
|
|
#define A2D_SBC_IE_SUBBAND_4 0x08 /* b3: 4 */
|
|
|
|
#define A2D_SBC_IE_SUBBAND_8 0x04 /* b2: 8 */
|
|
|
|
|
|
|
|
#define A2D_SBC_IE_ALLOC_MD_MSK 0x03 /* b1-b0 allocation mode */
|
|
|
|
#define A2D_SBC_IE_ALLOC_MD_S 0x02 /* b1: SNR */
|
|
|
|
#define A2D_SBC_IE_ALLOC_MD_L 0x01 /* b0: loundess */
|
|
|
|
|
|
|
|
#define A2D_SBC_IE_MIN_BITPOOL 2
|
|
|
|
#define A2D_SBC_IE_MAX_BITPOOL 250
|
|
|
|
|
|
|
|
/* for media payload header */
|
|
|
|
#define A2D_SBC_HDR_F_MSK 0x80
|
|
|
|
#define A2D_SBC_HDR_S_MSK 0x40
|
|
|
|
#define A2D_SBC_HDR_L_MSK 0x20
|
|
|
|
#define A2D_SBC_HDR_NUM_MSK 0x0F
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
** Type Definitions
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/* data type for the SBC Codec Information Element*/
|
2017-03-17 10:46:49 -04:00
|
|
|
typedef struct {
|
2016-11-02 05:42:26 -04:00
|
|
|
UINT8 samp_freq; /* Sampling frequency */
|
|
|
|
UINT8 ch_mode; /* Channel mode */
|
|
|
|
UINT8 block_len; /* Block length */
|
|
|
|
UINT8 num_subbands; /* Number of subbands */
|
|
|
|
UINT8 alloc_mthd; /* Allocation method */
|
|
|
|
UINT8 max_bitpool; /* Maximum bitpool */
|
|
|
|
UINT8 min_bitpool; /* Minimum bitpool */
|
|
|
|
} tA2D_SBC_CIE;
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
** External Function Declarations
|
|
|
|
*****************************************************************************/
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#endif
|
|
|
|
/******************************************************************************
|
|
|
|
**
|
|
|
|
** Function A2D_SbcChkFrInit
|
|
|
|
**
|
|
|
|
** Description check if need to init the descramble control block.
|
|
|
|
**
|
|
|
|
** Returns nothing.
|
|
|
|
******************************************************************************/
|
|
|
|
extern void A2D_SbcChkFrInit(UINT8 *p_pkt);
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
**
|
|
|
|
** Function A2D_SbcDescramble
|
|
|
|
**
|
|
|
|
** Description descramble the packet.
|
|
|
|
**
|
|
|
|
** Returns nothing.
|
|
|
|
******************************************************************************/
|
|
|
|
extern void A2D_SbcDescramble(UINT8 *p_pkt, UINT16 len);
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
**
|
|
|
|
** Function A2D_BldSbcInfo
|
|
|
|
**
|
|
|
|
** Description This function is called by an application to build
|
|
|
|
** the SBC Media Codec Capabilities byte sequence
|
|
|
|
** beginning from the LOSC octet.
|
|
|
|
** Input Parameters:
|
|
|
|
** media_type: Indicates Audio, or Multimedia.
|
|
|
|
**
|
|
|
|
** p_ie: The SBC Codec Information Element information.
|
|
|
|
**
|
|
|
|
** Output Parameters:
|
|
|
|
** p_result: the resulting codec info byte sequence.
|
|
|
|
**
|
|
|
|
** Returns A2D_SUCCESS if function execution succeeded.
|
|
|
|
** Error status code, otherwise.
|
|
|
|
******************************************************************************/
|
|
|
|
extern tA2D_STATUS A2D_BldSbcInfo(UINT8 media_type, tA2D_SBC_CIE *p_ie,
|
|
|
|
UINT8 *p_result);
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
**
|
|
|
|
** Function A2D_ParsSbcInfo
|
|
|
|
**
|
|
|
|
** Description This function is called by an application to parse
|
|
|
|
** the SBC Media Codec Capabilities byte sequence
|
|
|
|
** beginning from the LOSC octet.
|
|
|
|
** Input Parameters:
|
|
|
|
** p_info: the byte sequence to parse.
|
|
|
|
**
|
|
|
|
** for_caps: TRUE, if the byte sequence is for get capabilities response.
|
|
|
|
**
|
|
|
|
** Output Parameters:
|
|
|
|
** p_ie: The SBC Codec Information Element information.
|
|
|
|
**
|
|
|
|
** Returns A2D_SUCCESS if function execution succeeded.
|
|
|
|
** Error status code, otherwise.
|
|
|
|
******************************************************************************/
|
|
|
|
extern tA2D_STATUS A2D_ParsSbcInfo(tA2D_SBC_CIE *p_ie, UINT8 *p_info,
|
|
|
|
BOOLEAN for_caps);
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
**
|
|
|
|
** Function A2D_BldSbcMplHdr
|
|
|
|
**
|
|
|
|
** Description This function is called by an application to parse
|
|
|
|
** the SBC Media Payload header.
|
|
|
|
** Input Parameters:
|
|
|
|
** frag: 1, if fragmented. 0, otherwise.
|
|
|
|
**
|
|
|
|
** start: 1, if the starting packet of a fragmented frame.
|
|
|
|
**
|
|
|
|
** last: 1, if the last packet of a fragmented frame.
|
|
|
|
**
|
|
|
|
** num: If frag is 1, this is the number of remaining fragments
|
|
|
|
** (including this fragment) of this frame.
|
|
|
|
** If frag is 0, this is the number of frames in this packet.
|
|
|
|
**
|
|
|
|
** Output Parameters:
|
|
|
|
** p_dst: the resulting media payload header byte sequence.
|
|
|
|
**
|
|
|
|
** Returns void.
|
|
|
|
******************************************************************************/
|
|
|
|
extern void A2D_BldSbcMplHdr(UINT8 *p_dst, BOOLEAN frag, BOOLEAN start,
|
|
|
|
BOOLEAN last, UINT8 num);
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
**
|
|
|
|
** Function A2D_ParsSbcMplHdr
|
|
|
|
**
|
|
|
|
** Description This function is called by an application to parse
|
|
|
|
** the SBC Media Payload header.
|
|
|
|
** Input Parameters:
|
|
|
|
** p_src: the byte sequence to parse..
|
|
|
|
**
|
|
|
|
** Output Parameters:
|
|
|
|
** frag: 1, if fragmented. 0, otherwise.
|
|
|
|
**
|
|
|
|
** start: 1, if the starting packet of a fragmented frame.
|
|
|
|
**
|
|
|
|
** last: 1, if the last packet of a fragmented frame.
|
|
|
|
**
|
|
|
|
** num: If frag is 1, this is the number of remaining fragments
|
|
|
|
** (including this fragment) of this frame.
|
|
|
|
** If frag is 0, this is the number of frames in this packet.
|
|
|
|
**
|
|
|
|
** Returns void.
|
|
|
|
******************************************************************************/
|
|
|
|
extern void A2D_ParsSbcMplHdr(UINT8 *p_src, BOOLEAN *p_frag,
|
|
|
|
BOOLEAN *p_start, BOOLEAN *p_last,
|
|
|
|
UINT8 *p_num);
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* A2D_SBC_H */
|