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_DECODER_H 17 #define SBC_DECODER_H 18 19 #include <cstddef> 20 #include <cstdint> 21 #include <sys/types.h> 22 #include "sbc_codec.h" 23 #include "sbc_constant.h" 24 #include "sbc_frame.h" 25 26 namespace sbc { 27 class Decoder: public IDecoderBase { 28 public: 29 explicit Decoder(); 30 ~Decoder() override = default; 31 ssize_t SBCDecode(const CodecParam& codecParam, const uint8_t* in, size_t iLength, 32 uint8_t* out, size_t oLength, size_t* written) override; 33 private: 34 void Init(const Frame& frame); 35 int Synthesize(const Frame& frame); 36 void Synthesize4(const Frame &frame, int ch, int blk); 37 void Synthesize8(const Frame &frame, int ch, int blk); 38 39 int32_t v_[2][170] {}; 40 int offset_[2][16] {}; 41 int16_t pcmSamples_[2][16 * 8] {}; 42 bool initialized_ {}; 43 Frame frame_ {}; 44 }; 45 } // namespace sbc 46 #endif // SBC_DECODER_H 47