• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright 2004-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  *  This is the interface to utility functions for dealing with SBC data
22  *  frames and codec capabilities.
23  *
24  ******************************************************************************/
25 #ifndef A2DP_SBC_UP_SAMPLE_H
26 #define A2DP_SBC_UP_SAMPLE_H
27 
28 #include <stdint.h>
29 
30 /*******************************************************************************
31  *
32  * Function         a2dp_sbc_init_up_sample
33  *
34  * Description      initialize the up sample
35  *
36  *                  src_sps: samples per second (source audio data)
37  *                  dst_sps: samples per second (converted audio data)
38  *                  bits: number of bits per pcm sample
39  *                  n_channels: number of channels (i.e. mono(1), stereo(2)...)
40  *
41  * Returns          none
42  *
43  ******************************************************************************/
44 void a2dp_sbc_init_up_sample(uint32_t src_sps, uint32_t dst_sps, uint8_t bits,
45                              uint8_t n_channels);
46 
47 /*******************************************************************************
48  *
49  * Function         a2dp_sbc_up_sample
50  *
51  * Description      Given the source (p_src) audio data and
52  *                  source speed (src_sps, samples per second),
53  *                  This function converts it to audio data in the desired
54  *                  format
55  *
56  *                  p_src: the data buffer that holds the source audio data
57  *                  p_dst: the data buffer to hold the converted audio data
58  *                  src_samples: The number of source samples (number of bytes)
59  *                  dst_samples: The size of p_dst (number of bytes)
60  *
61  * Note:            An AE reported an issue with this function.
62  *                  When called with a2dp_sbc_up_sample(src, uint8_array_dst..)
63  *                  the byte before uint8_array_dst may get overwritten.
64  *                  Using uint16_array_dst avoids the problem.
65  *                  This issue is related to endian-ness and is hard to resolve
66  *                  in a generic manner.
67  * **************** Please use uint16 array as dst.
68  *
69  * Returns          The number of bytes used in p_dst
70  *                  The number of bytes used in p_src (in *p_ret)
71  *
72  ******************************************************************************/
73 int a2dp_sbc_up_sample(void* p_src, void* p_dst, uint32_t src_samples,
74                        uint32_t dst_samples, uint32_t* p_ret);
75 
76 /*******************************************************************************
77  *
78  * Function         a2dp_sbc_up_sample_16s (16bits-stereo)
79  *
80  * Description      Given the source (p_src) audio data and
81  *                  source speed (src_sps, samples per second),
82  *                  This function converts it to audio data in the desired
83  *                  format
84  *
85  *                  p_src: the data buffer that holds the source audio data
86  *                  p_dst: the data buffer to hold the converted audio data
87  *                  src_samples: The number of source samples (in uint of 4
88  *                               bytes)
89  *                  dst_samples: The size of p_dst (in uint of 4 bytes)
90  *
91  * Returns          The number of bytes used in p_dst
92  *                  The number of bytes used in p_src (in *p_ret)
93  *
94  ******************************************************************************/
95 int a2dp_sbc_up_sample_16s(void* p_src, void* p_dst, uint32_t src_samples,
96                            uint32_t dst_samples, uint32_t* p_ret);
97 
98 /*******************************************************************************
99  *
100  * Function         a2dp_sbc_up_sample_16m (16bits-mono)
101  *
102  * Description      Given the source (p_src) audio data and
103  *                  source speed (src_sps, samples per second),
104  *                  This function converts it to audio data in the desired
105  *                  format
106  *
107  *                  p_src: the data buffer that holds the source audio data
108  *                  p_dst: the data buffer to hold the converted audio data
109  *                  src_samples: The number of source samples (in uint of 2
110  *                               bytes)
111  *                  dst_samples: The size of p_dst (in uint of 2 bytes)
112  *
113  * Returns          The number of bytes used in p_dst
114  *                  The number of bytes used in p_src (in *p_ret)
115  *
116  ******************************************************************************/
117 int a2dp_sbc_up_sample_16m(void* p_src, void* p_dst, uint32_t src_samples,
118                            uint32_t dst_samples, uint32_t* p_ret);
119 
120 /*******************************************************************************
121  *
122  * Function         a2dp_sbc_up_sample_8s (8bits-stereo)
123  *
124  * Description      Given the source (p_src) audio data and
125  *                  source speed (src_sps, samples per second),
126  *                  This function converts it to audio data in the desired
127  *                  format
128  *
129  *                  p_src: the data buffer that holds the source audio data
130  *                  p_dst: the data buffer to hold the converted audio data
131  *                  src_samples: The number of source samples (in uint of 2
132  *                               bytes)
133  *                  dst_samples: The size of p_dst (in uint of 2 bytes)
134  *
135  * Returns          The number of bytes used in p_dst
136  *                  The number of bytes used in p_src (in *p_ret)
137  *
138  ******************************************************************************/
139 int a2dp_sbc_up_sample_8s(void* p_src, void* p_dst, uint32_t src_samples,
140                           uint32_t dst_samples, uint32_t* p_ret);
141 
142 /*******************************************************************************
143  *
144  * Function         a2dp_sbc_up_sample_8m (8bits-mono)
145  *
146  * Description      Given the source (p_src) audio data and
147  *                  source speed (src_sps, samples per second),
148  *                  This function converts it to audio data in the desired
149  *                  format
150  *
151  *                  p_src: the data buffer that holds the source audio data
152  *                  p_dst: the data buffer to hold the converted audio data
153  *                  src_samples: The number of source samples (number of bytes)
154  *                  dst_samples: The size of p_dst (number of bytes)
155  *
156  * Returns          The number of bytes used in p_dst
157  *                  The number of bytes used in p_src (in *p_ret)
158  *
159  ******************************************************************************/
160 int a2dp_sbc_up_sample_8m(void* p_src, void* p_dst, uint32_t src_samples,
161                           uint32_t dst_samples, uint32_t* p_ret);
162 
163 #endif  // A2DP_SBC_UP_SAMPLE_H
164