1 /* 2 * Copyright (C) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef SBC_CONSTANT_H 17 #define SBC_CONSTANT_H 18 19 #include <cstddef> 20 #include <cstdint> 21 22 namespace sbc { 23 #define SBC_MAX_NUM_OF_BLOCKS 16 24 #define SBC_MAX_NUM_OF_CHANNELS 2 25 #define SBC_MAX_NUM_OF_SUBBANDS 8 26 27 #define SBC_MAX_PCM_BUFFER_SIZE \ 28 (SBC_MAX_NUM_OF_BLOCKS * SBC_MAX_NUM_OF_SUBBANDS * SBC_MAX_NUM_OF_CHANNELS) 29 30 // Codec param 31 typedef struct { 32 uint8_t frequency; 33 uint8_t blocks; 34 uint8_t subbands; 35 uint8_t channelMode; 36 uint8_t allocation; 37 uint8_t bitpool; 38 uint8_t endian; 39 } CodecParam; 40 41 // Errors 42 enum SbcErrors { 43 SBC_ERROR_INVALID_ARG = -1, 44 SBC_ERROR_NO_ENOUGH_BITSTREAM = -2, 45 SBC_ERROR_INVALID_FRAME = -3, 46 SBC_ERROR_INVALID_CRC = -4, 47 SBC_ERROR_BITPOOL_OUT = -5, 48 }; 49 50 // SyncWord declaration 51 enum SbcSyncWord { 52 SBC_SYNCWORD = 0x9C, 53 MSBC_SYNCWORD = 0xAD, 54 }; 55 56 // Sampling frequency 57 enum SbcSamplingFrequency { 58 SBC_FREQ_16000 = 0x00, 59 SBC_FREQ_32000 = 0x01, 60 SBC_FREQ_44100 = 0x02, 61 SBC_FREQ_48000 = 0x03, 62 }; 63 64 // Blocks 65 enum SbcBlockMode { 66 SBC_BLOCK4 = 0x00, 67 SBC_BLOCK8 = 0x01, 68 SBC_BLOCK12 = 0x02, 69 SBC_BLOCK16 = 0x03, 70 }; 71 72 // Channel Mode 73 enum SbcChannelMode { 74 SBC_CHANNEL_MODE_MONO = 0x00, 75 SBC_CHANNEL_MODE_DUAL_CHANNEL = 0x01, 76 SBC_CHANNEL_MODE_STEREO = 0x02, 77 SBC_CHANNEL_MODE_JOINT_STEREO = 0x3, 78 }; 79 80 // Subbands declaration 81 enum SbcSubband { 82 SBC_SUBBAND4 = 0x00, 83 SBC_SUBBAND8 = 0x01, 84 }; 85 86 // Sbc data endianness 87 enum SbcEndianess { 88 SBC_ENDIANESS_LE = 0x00, 89 SBC_ENDIANESS_BE = 0x01, 90 }; 91 92 // Sbc allocation method 93 enum SbcAllocation { 94 SBC_ALLOCATION_LOUDNESS = 0x00, 95 SBC_ALLOCATION_SNR = 0x01, 96 }; 97 } // namespace sbc 98 #endif // SBC_CONSTANT_H 99