1 /* 2 * Copyright (c) 2023, Alliance for Open Media. All rights reserved 3 * 4 * This source code is subject to the terms of the BSD 3-Clause Clear License 5 * and the Alliance for Open Media Patent License 1.0. If the BSD 3-Clause Clear 6 * License was not distributed with this source code in the LICENSE file, you 7 * can obtain it at www.aomedia.org/license/software-license/bsd-3-c-c. If the 8 * Alliance for Open Media Patent License 1.0 was not distributed with this 9 * source code in the PATENTS file, you can obtain it at 10 * www.aomedia.org/license/patent. 11 */ 12 #ifndef CLI_AAC_ENCODER_DECODER_H_ 13 #define CLI_AAC_ENCODER_DECODER_H_ 14 15 #include <cstdint> 16 #include <vector> 17 18 // This symbol conflicts with a macro in fdk_aac. 19 #ifdef IS_LITTLE_ENDIAN 20 #undef IS_LITTLE_ENDIAN 21 #endif 22 23 #include "absl/status/status.h" 24 #include "iamf/cli/codec/decoder_base.h" 25 #include "iamf/obu/codec_config.h" 26 #include "iamf/obu/decoder_config/aac_decoder_config.h" 27 #include "libAACdec/include/aacdecoder_lib.h" 28 29 namespace iamf_tools { 30 31 // TODO(b/277731089): Test all of `aac_encoder_decoder.h`. 32 class AacDecoder : public DecoderBase { 33 public: 34 /*!\brief Constructor. 35 * 36 * \param codec_config_obu Codec Config OBU with initialization settings. 37 * \param num_channels Number of channels for this stream. 38 */ 39 AacDecoder(const CodecConfigObu& codec_config_obu, int num_channels); 40 41 /*!\brief Destructor. 42 */ 43 ~AacDecoder() override; 44 45 /*!\brief Initializes the underlying decoder. 46 * 47 * \return `absl::OkStatus()` on success. A specific status on failure. 48 */ 49 absl::Status Initialize() override; 50 51 /*!\brief Decodes an AAC audio frame. 52 * 53 * \param encoded_frame Frame to decode. 54 * \return `absl::OkStatus()` on success. A specific status on failure. 55 */ 56 absl::Status DecodeAudioFrame( 57 const std::vector<uint8_t>& encoded_frame) override; 58 59 private: 60 const AacDecoderConfig& aac_decoder_config_; 61 AAC_DECODER_INSTANCE* decoder_ = nullptr; 62 }; 63 64 } // namespace iamf_tools 65 66 #endif // CLI_AAC_ENCODER_DECODER_H_ 67