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