15738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/****************************************************************************** 25738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 35b790feeeb211c42bf78ca3ae9c26aa30e516765Jakub Pawlowski * Copyright 2004-2012 Broadcom Corporation 45738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 55738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License"); 65738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * you may not use this file except in compliance with the License. 75738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * You may obtain a copy of the License at: 85738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 95738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * http://www.apache.org/licenses/LICENSE-2.0 105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * Unless required by applicable law or agreed to in writing, software 125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS, 135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * See the License for the specific language governing permissions and 155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * limitations under the License. 165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ******************************************************************************/ 185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/****************************************************************************** 205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * This is the interface to utility functions for dealing with SBC data 225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * frames and codec capabilities. 235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ******************************************************************************/ 25f66f4e95f2b4bc8d36033f2d65b387e32601fcd8Pavlin Radoslavov#ifndef A2DP_SBC_UP_SAMPLE_H 26f66f4e95f2b4bc8d36033f2d65b387e32601fcd8Pavlin Radoslavov#define A2DP_SBC_UP_SAMPLE_H 271394c197027c0907932a814a786cc033870eb1c9Pavlin Radoslavov 281394c197027c0907932a814a786cc033870eb1c9Pavlin Radoslavov#include <stdint.h> 295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 31ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * 32ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * Function a2dp_sbc_init_up_sample 33ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * 34ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * Description initialize the up sample 35ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * 36ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * src_sps: samples per second (source audio data) 37ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * dst_sps: samples per second (converted audio data) 38ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * bits: number of bits per pcm sample 39ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * n_channels: number of channels (i.e. mono(1), stereo(2)...) 40ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * 41ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * Returns none 42ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * 43ee96a3c60fca590d38025925c072d264e06493c4Myles Watson ******************************************************************************/ 44f66f4e95f2b4bc8d36033f2d65b387e32601fcd8Pavlin Radoslavovvoid a2dp_sbc_init_up_sample(uint32_t src_sps, uint32_t dst_sps, uint8_t bits, 45397e5a5d6a6e14779af8431734ff605ccc49b2a7Pavlin Radoslavov uint8_t n_channels); 465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 48ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * 49ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * Function a2dp_sbc_up_sample 50ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * 51ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * Description Given the source (p_src) audio data and 52ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * source speed (src_sps, samples per second), 53ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * This function converts it to audio data in the desired 54ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * format 55ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * 56ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * p_src: the data buffer that holds the source audio data 57ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * p_dst: the data buffer to hold the converted audio data 58ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * src_samples: The number of source samples (number of bytes) 59ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * dst_samples: The size of p_dst (number of bytes) 60ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * 61ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * Note: An AE reported an issue with this function. 62ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * When called with a2dp_sbc_up_sample(src, uint8_array_dst..) 63ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * the byte before uint8_array_dst may get overwritten. 64ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * Using uint16_array_dst avoids the problem. 65ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * This issue is related to endian-ness and is hard to resolve 66ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * in a generic manner. 67ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * **************** Please use uint16 array as dst. 68ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * 69ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * Returns The number of bytes used in p_dst 70ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * The number of bytes used in p_src (in *p_ret) 71ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * 72ee96a3c60fca590d38025925c072d264e06493c4Myles Watson ******************************************************************************/ 73397e5a5d6a6e14779af8431734ff605ccc49b2a7Pavlin Radoslavovint a2dp_sbc_up_sample(void* p_src, void* p_dst, uint32_t src_samples, 74397e5a5d6a6e14779af8431734ff605ccc49b2a7Pavlin Radoslavov uint32_t dst_samples, uint32_t* p_ret); 755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 77ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * 78ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * Function a2dp_sbc_up_sample_16s (16bits-stereo) 79ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * 80ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * Description Given the source (p_src) audio data and 81ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * source speed (src_sps, samples per second), 82ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * This function converts it to audio data in the desired 83ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * format 84ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * 85ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * p_src: the data buffer that holds the source audio data 86ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * p_dst: the data buffer to hold the converted audio data 87ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * src_samples: The number of source samples (in uint of 4 88ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * bytes) 89ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * dst_samples: The size of p_dst (in uint of 4 bytes) 90ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * 91ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * Returns The number of bytes used in p_dst 92ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * The number of bytes used in p_src (in *p_ret) 93ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * 94ee96a3c60fca590d38025925c072d264e06493c4Myles Watson ******************************************************************************/ 95397e5a5d6a6e14779af8431734ff605ccc49b2a7Pavlin Radoslavovint a2dp_sbc_up_sample_16s(void* p_src, void* p_dst, uint32_t src_samples, 96397e5a5d6a6e14779af8431734ff605ccc49b2a7Pavlin Radoslavov uint32_t dst_samples, uint32_t* p_ret); 975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 99ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * 100ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * Function a2dp_sbc_up_sample_16m (16bits-mono) 101ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * 102ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * Description Given the source (p_src) audio data and 103ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * source speed (src_sps, samples per second), 104ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * This function converts it to audio data in the desired 105ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * format 106ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * 107ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * p_src: the data buffer that holds the source audio data 108ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * p_dst: the data buffer to hold the converted audio data 109ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * src_samples: The number of source samples (in uint of 2 110ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * bytes) 111ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * dst_samples: The size of p_dst (in uint of 2 bytes) 112ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * 113ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * Returns The number of bytes used in p_dst 114ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * The number of bytes used in p_src (in *p_ret) 115ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * 116ee96a3c60fca590d38025925c072d264e06493c4Myles Watson ******************************************************************************/ 117397e5a5d6a6e14779af8431734ff605ccc49b2a7Pavlin Radoslavovint a2dp_sbc_up_sample_16m(void* p_src, void* p_dst, uint32_t src_samples, 118397e5a5d6a6e14779af8431734ff605ccc49b2a7Pavlin Radoslavov uint32_t dst_samples, uint32_t* p_ret); 1195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 121ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * 122ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * Function a2dp_sbc_up_sample_8s (8bits-stereo) 123ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * 124ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * Description Given the source (p_src) audio data and 125ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * source speed (src_sps, samples per second), 126ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * This function converts it to audio data in the desired 127ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * format 128ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * 129ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * p_src: the data buffer that holds the source audio data 130ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * p_dst: the data buffer to hold the converted audio data 131ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * src_samples: The number of source samples (in uint of 2 132ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * bytes) 133ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * dst_samples: The size of p_dst (in uint of 2 bytes) 134ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * 135ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * Returns The number of bytes used in p_dst 136ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * The number of bytes used in p_src (in *p_ret) 137ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * 138ee96a3c60fca590d38025925c072d264e06493c4Myles Watson ******************************************************************************/ 139397e5a5d6a6e14779af8431734ff605ccc49b2a7Pavlin Radoslavovint a2dp_sbc_up_sample_8s(void* p_src, void* p_dst, uint32_t src_samples, 140397e5a5d6a6e14779af8431734ff605ccc49b2a7Pavlin Radoslavov uint32_t dst_samples, uint32_t* p_ret); 1415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 143ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * 144ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * Function a2dp_sbc_up_sample_8m (8bits-mono) 145ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * 146ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * Description Given the source (p_src) audio data and 147ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * source speed (src_sps, samples per second), 148ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * This function converts it to audio data in the desired 149ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * format 150ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * 151ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * p_src: the data buffer that holds the source audio data 152ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * p_dst: the data buffer to hold the converted audio data 153ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * src_samples: The number of source samples (number of bytes) 154ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * dst_samples: The size of p_dst (number of bytes) 155ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * 156ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * Returns The number of bytes used in p_dst 157ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * The number of bytes used in p_src (in *p_ret) 158ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * 159ee96a3c60fca590d38025925c072d264e06493c4Myles Watson ******************************************************************************/ 160397e5a5d6a6e14779af8431734ff605ccc49b2a7Pavlin Radoslavovint a2dp_sbc_up_sample_8m(void* p_src, void* p_dst, uint32_t src_samples, 161397e5a5d6a6e14779af8431734ff605ccc49b2a7Pavlin Radoslavov uint32_t dst_samples, uint32_t* p_ret); 1625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1635ce0116fbf5b530d5b93f11312096eade1021c1ePavlin Radoslavov#endif // A2DP_SBC_UP_SAMPLE_H 164