a2d_sbc.h 8.6 KB

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