1 /* 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #define LOG_TAG "hfp_msbc_encoder" 18 19 #include "hfp_msbc_encoder.h" 20 21 #include <cstring> 22 23 #include "embdrv/sbc/encoder/include/sbc_encoder.h" 24 25 typedef struct { 26 SBC_ENC_PARAMS sbc_encoder_params; 27 } tHFP_MSBC_ENCODER; 28 29 static tHFP_MSBC_ENCODER hfp_msbc_encoder = {}; 30 hfp_msbc_encoder_init(void)31void hfp_msbc_encoder_init(void) { 32 SBC_ENC_PARAMS* p_encoder_params = &hfp_msbc_encoder.sbc_encoder_params; 33 p_encoder_params->s16SamplingFreq = SBC_sf16000; 34 p_encoder_params->s16ChannelMode = SBC_MONO; 35 p_encoder_params->s16NumOfSubBands = 8; 36 p_encoder_params->s16NumOfChannels = 1; 37 p_encoder_params->s16NumOfBlocks = 15; 38 p_encoder_params->s16AllocationMethod = SBC_LOUDNESS; 39 p_encoder_params->s16BitPool = 26; 40 p_encoder_params->Format = SBC_FORMAT_MSBC; 41 } 42 hfp_msbc_encoder_cleanup(void)43void hfp_msbc_encoder_cleanup(void) { hfp_msbc_encoder = {}; } 44 hfp_msbc_encode_frames(int16_t * input,uint8_t * output)45uint32_t hfp_msbc_encode_frames(int16_t* input, uint8_t* output) { 46 return SBC_Encode(&hfp_msbc_encoder.sbc_encoder_params, input, output); 47 } 48