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, uint8_t n_channels); 45 46 /******************************************************************************* 47 * 48 * Function a2dp_sbc_up_sample 49 * 50 * Description Given the source (p_src) audio data and 51 * source speed (src_sps, samples per second), 52 * This function converts it to audio data in the desired 53 * format 54 * 55 * p_src: the data buffer that holds the source audio data 56 * p_dst: the data buffer to hold the converted audio data 57 * src_samples: The number of source samples (number of bytes) 58 * dst_samples: The size of p_dst (number of bytes) 59 * 60 * Note: An AE reported an issue with this function. 61 * When called with a2dp_sbc_up_sample(src, uint8_array_dst..) 62 * the byte before uint8_array_dst may get overwritten. 63 * Using uint16_array_dst avoids the problem. 64 * This issue is related to endian-ness and is hard to resolve 65 * in a generic manner. 66 * **************** Please use uint16 array as dst. 67 * 68 * Returns The number of bytes used in p_dst 69 * The number of bytes used in p_src (in *p_ret) 70 * 71 ******************************************************************************/ 72 int a2dp_sbc_up_sample(void* p_src, void* p_dst, uint32_t src_samples, uint32_t dst_samples, 73 uint32_t* p_ret); 74 75 /******************************************************************************* 76 * 77 * Function a2dp_sbc_up_sample_16s (16bits-stereo) 78 * 79 * Description Given the source (p_src) audio data and 80 * source speed (src_sps, samples per second), 81 * This function converts it to audio data in the desired 82 * format 83 * 84 * p_src: the data buffer that holds the source audio data 85 * p_dst: the data buffer to hold the converted audio data 86 * src_samples: The number of source samples (in uint of 4 87 * bytes) 88 * dst_samples: The size of p_dst (in uint of 4 bytes) 89 * 90 * Returns The number of bytes used in p_dst 91 * The number of bytes used in p_src (in *p_ret) 92 * 93 ******************************************************************************/ 94 int a2dp_sbc_up_sample_16s(void* p_src, void* p_dst, uint32_t src_samples, uint32_t dst_samples, 95 uint32_t* p_ret); 96 97 /******************************************************************************* 98 * 99 * Function a2dp_sbc_up_sample_16m (16bits-mono) 100 * 101 * Description Given the source (p_src) audio data and 102 * source speed (src_sps, samples per second), 103 * This function converts it to audio data in the desired 104 * format 105 * 106 * p_src: the data buffer that holds the source audio data 107 * p_dst: the data buffer to hold the converted audio data 108 * src_samples: The number of source samples (in uint of 2 109 * bytes) 110 * dst_samples: The size of p_dst (in uint of 2 bytes) 111 * 112 * Returns The number of bytes used in p_dst 113 * The number of bytes used in p_src (in *p_ret) 114 * 115 ******************************************************************************/ 116 int a2dp_sbc_up_sample_16m(void* p_src, void* p_dst, uint32_t src_samples, uint32_t dst_samples, 117 uint32_t* p_ret); 118 119 /******************************************************************************* 120 * 121 * Function a2dp_sbc_up_sample_8s (8bits-stereo) 122 * 123 * Description Given the source (p_src) audio data and 124 * source speed (src_sps, samples per second), 125 * This function converts it to audio data in the desired 126 * format 127 * 128 * p_src: the data buffer that holds the source audio data 129 * p_dst: the data buffer to hold the converted audio data 130 * src_samples: The number of source samples (in uint of 2 131 * bytes) 132 * dst_samples: The size of p_dst (in uint of 2 bytes) 133 * 134 * Returns The number of bytes used in p_dst 135 * The number of bytes used in p_src (in *p_ret) 136 * 137 ******************************************************************************/ 138 int a2dp_sbc_up_sample_8s(void* p_src, void* p_dst, uint32_t src_samples, uint32_t dst_samples, 139 uint32_t* p_ret); 140 141 /******************************************************************************* 142 * 143 * Function a2dp_sbc_up_sample_8m (8bits-mono) 144 * 145 * Description Given the source (p_src) audio data and 146 * source speed (src_sps, samples per second), 147 * This function converts it to audio data in the desired 148 * format 149 * 150 * p_src: the data buffer that holds the source audio data 151 * p_dst: the data buffer to hold the converted audio data 152 * src_samples: The number of source samples (number of bytes) 153 * dst_samples: The size of p_dst (number of bytes) 154 * 155 * Returns The number of bytes used in p_dst 156 * The number of bytes used in p_src (in *p_ret) 157 * 158 ******************************************************************************/ 159 int a2dp_sbc_up_sample_8m(void* p_src, void* p_dst, uint32_t src_samples, uint32_t dst_samples, 160 uint32_t* p_ret); 161 162 #endif // A2DP_SBC_UP_SAMPLE_H 163