a2d_sbc.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /******************************************************************************
  2. *
  3. * Copyright (C) 2000-2012 Broadcom Corporation
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at:
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. *
  17. ******************************************************************************/
  18. /******************************************************************************
  19. *
  20. * nterface to low complexity subband codec (SBC)
  21. *
  22. ******************************************************************************/
  23. #ifndef A2D_SBC_H
  24. #define A2D_SBC_H
  25. #if (A2D_INCLUDED == TRUE)
  26. /*****************************************************************************
  27. ** Constants
  28. *****************************************************************************/
  29. /* the length of the SBC Media Payload header. */
  30. #define A2D_SBC_MPL_HDR_LEN 1
  31. /* the LOSC of SBC media codec capabilitiy */
  32. #define A2D_SBC_INFO_LEN 6
  33. /* for Codec Specific Information Element */
  34. #define A2D_SBC_IE_SAMP_FREQ_MSK 0xF0 /* b7-b4 sampling frequency */
  35. #define A2D_SBC_IE_SAMP_FREQ_16 0x80 /* b7:16 kHz */
  36. #define A2D_SBC_IE_SAMP_FREQ_32 0x40 /* b6:32 kHz */
  37. #define A2D_SBC_IE_SAMP_FREQ_44 0x20 /* b5:44.1kHz */
  38. #define A2D_SBC_IE_SAMP_FREQ_48 0x10 /* b4:48 kHz */
  39. #define A2D_SBC_IE_CH_MD_MSK 0x0F /* b3-b0 channel mode */
  40. #define A2D_SBC_IE_CH_MD_MONO 0x08 /* b3: mono */
  41. #define A2D_SBC_IE_CH_MD_DUAL 0x04 /* b2: dual */
  42. #define A2D_SBC_IE_CH_MD_STEREO 0x02 /* b1: stereo */
  43. #define A2D_SBC_IE_CH_MD_JOINT 0x01 /* b0: joint stereo */
  44. #define A2D_SBC_IE_BLOCKS_MSK 0xF0 /* b7-b4 number of blocks */
  45. #define A2D_SBC_IE_BLOCKS_4 0x80 /* 4 blocks */
  46. #define A2D_SBC_IE_BLOCKS_8 0x40 /* 8 blocks */
  47. #define A2D_SBC_IE_BLOCKS_12 0x20 /* 12blocks */
  48. #define A2D_SBC_IE_BLOCKS_16 0x10 /* 16blocks */
  49. #define A2D_SBC_IE_SUBBAND_MSK 0x0C /* b3-b2 number of subbands */
  50. #define A2D_SBC_IE_SUBBAND_4 0x08 /* b3: 4 */
  51. #define A2D_SBC_IE_SUBBAND_8 0x04 /* b2: 8 */
  52. #define A2D_SBC_IE_ALLOC_MD_MSK 0x03 /* b1-b0 allocation mode */
  53. #define A2D_SBC_IE_ALLOC_MD_S 0x02 /* b1: SNR */
  54. #define A2D_SBC_IE_ALLOC_MD_L 0x01 /* b0: loundess */
  55. #define A2D_SBC_IE_MIN_BITPOOL 2
  56. #define A2D_SBC_IE_MAX_BITPOOL 250
  57. /* for media payload header */
  58. #define A2D_SBC_HDR_F_MSK 0x80
  59. #define A2D_SBC_HDR_S_MSK 0x40
  60. #define A2D_SBC_HDR_L_MSK 0x20
  61. #define A2D_SBC_HDR_NUM_MSK 0x0F
  62. /*****************************************************************************
  63. ** Type Definitions
  64. *****************************************************************************/
  65. /* data type for the SBC Codec Information Element*/
  66. typedef struct {
  67. UINT8 samp_freq; /* Sampling frequency */
  68. UINT8 ch_mode; /* Channel mode */
  69. UINT8 block_len; /* Block length */
  70. UINT8 num_subbands; /* Number of subbands */
  71. UINT8 alloc_mthd; /* Allocation method */
  72. UINT8 max_bitpool; /* Maximum bitpool */
  73. UINT8 min_bitpool; /* Minimum bitpool */
  74. } tA2D_SBC_CIE;
  75. /*****************************************************************************
  76. ** External Function Declarations
  77. *****************************************************************************/
  78. #ifdef __cplusplus
  79. extern "C"
  80. {
  81. #endif
  82. /******************************************************************************
  83. **
  84. ** Function A2D_SbcChkFrInit
  85. **
  86. ** Description check if need to init the descramble control block.
  87. **
  88. ** Returns nothing.
  89. ******************************************************************************/
  90. extern void A2D_SbcChkFrInit(UINT8 *p_pkt);
  91. /******************************************************************************
  92. **
  93. ** Function A2D_SbcDescramble
  94. **
  95. ** Description descramble the packet.
  96. **
  97. ** Returns nothing.
  98. ******************************************************************************/
  99. extern void A2D_SbcDescramble(UINT8 *p_pkt, UINT16 len);
  100. /******************************************************************************
  101. **
  102. ** Function A2D_BldSbcInfo
  103. **
  104. ** Description This function is called by an application to build
  105. ** the SBC Media Codec Capabilities byte sequence
  106. ** beginning from the LOSC octet.
  107. ** Input Parameters:
  108. ** media_type: Indicates Audio, or Multimedia.
  109. **
  110. ** p_ie: The SBC Codec Information Element information.
  111. **
  112. ** Output Parameters:
  113. ** p_result: the resulting codec info byte sequence.
  114. **
  115. ** Returns A2D_SUCCESS if function execution succeeded.
  116. ** Error status code, otherwise.
  117. ******************************************************************************/
  118. extern tA2D_STATUS A2D_BldSbcInfo(UINT8 media_type, tA2D_SBC_CIE *p_ie,
  119. UINT8 *p_result);
  120. /******************************************************************************
  121. **
  122. ** Function A2D_ParsSbcInfo
  123. **
  124. ** Description This function is called by an application to parse
  125. ** the SBC Media Codec Capabilities byte sequence
  126. ** beginning from the LOSC octet.
  127. ** Input Parameters:
  128. ** p_info: the byte sequence to parse.
  129. **
  130. ** for_caps: TRUE, if the byte sequence is for get capabilities response.
  131. **
  132. ** Output Parameters:
  133. ** p_ie: The SBC Codec Information Element information.
  134. **
  135. ** Returns A2D_SUCCESS if function execution succeeded.
  136. ** Error status code, otherwise.
  137. ******************************************************************************/
  138. extern tA2D_STATUS A2D_ParsSbcInfo(tA2D_SBC_CIE *p_ie, UINT8 *p_info,
  139. BOOLEAN for_caps);
  140. /******************************************************************************
  141. **
  142. ** Function A2D_BldSbcMplHdr
  143. **
  144. ** Description This function is called by an application to parse
  145. ** the SBC Media Payload header.
  146. ** Input Parameters:
  147. ** frag: 1, if fragmented. 0, otherwise.
  148. **
  149. ** start: 1, if the starting packet of a fragmented frame.
  150. **
  151. ** last: 1, if the last packet of a fragmented frame.
  152. **
  153. ** num: If frag is 1, this is the number of remaining fragments
  154. ** (including this fragment) of this frame.
  155. ** If frag is 0, this is the number of frames in this packet.
  156. **
  157. ** Output Parameters:
  158. ** p_dst: the resulting media payload header byte sequence.
  159. **
  160. ** Returns void.
  161. ******************************************************************************/
  162. extern void A2D_BldSbcMplHdr(UINT8 *p_dst, BOOLEAN frag, BOOLEAN start,
  163. BOOLEAN last, UINT8 num);
  164. /******************************************************************************
  165. **
  166. ** Function A2D_ParsSbcMplHdr
  167. **
  168. ** Description This function is called by an application to parse
  169. ** the SBC Media Payload header.
  170. ** Input Parameters:
  171. ** p_src: the byte sequence to parse..
  172. **
  173. ** Output Parameters:
  174. ** frag: 1, if fragmented. 0, otherwise.
  175. **
  176. ** start: 1, if the starting packet of a fragmented frame.
  177. **
  178. ** last: 1, if the last packet of a fragmented frame.
  179. **
  180. ** num: If frag is 1, this is the number of remaining fragments
  181. ** (including this fragment) of this frame.
  182. ** If frag is 0, this is the number of frames in this packet.
  183. **
  184. ** Returns void.
  185. ******************************************************************************/
  186. extern void A2D_ParsSbcMplHdr(UINT8 *p_src, BOOLEAN *p_frag,
  187. BOOLEAN *p_start, BOOLEAN *p_last,
  188. UINT8 *p_num);
  189. #ifdef __cplusplus
  190. }
  191. #endif
  192. #endif ///A2D_INCLUDED == TRUE
  193. #endif /* A2D_SBC_H */