1 /* 2 * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED. 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 #ifndef AUDIO_AAC_ADP_H 16 #define AUDIO_AAC_ADP_H 17 18 #include <stdio.h> 19 20 #include "mpi_audio.h" 21 #include "hi_comm_aenc.h" 22 #include "hi_comm_adec.h" 23 #include "hi_comm_aio.h" 24 #include "aacenc.h" 25 #include "aacdec.h" 26 27 /* samples per frame for AACLC and aacPlus */ 28 #define AACLD_SAMPLES_PER_FRAME 512 29 #define AACLC_SAMPLES_PER_FRAME 1024 30 #define AACPLUS_SAMPLES_PER_FRAME 2048 31 32 /* max length of AAC stream by bytes */ 33 #define MAX_AAC_MAINBUF_SIZE (768 * 2) 34 35 typedef enum hiAAC_TYPE_E { 36 AAC_TYPE_AACLC, /* AAC LC */ 37 AAC_TYPE_EAAC, /* eAAC (HEAAC or AAC+ or aacPlusV1) */ 38 AAC_TYPE_EAACPLUS, /* eAAC + (AAC++ or aacPlusV2) */ 39 AAC_TYPE_AACLD, 40 AAC_TYPE_AACELD, 41 AAC_TYPE_BUTT, 42 } AAC_TYPE_E; 43 44 typedef enum hiAAC_BPS_E { 45 AAC_BPS_8K = 8000, 46 AAC_BPS_16K = 16000, 47 AAC_BPS_22K = 22000, 48 AAC_BPS_24K = 24000, 49 AAC_BPS_32K = 32000, 50 AAC_BPS_48K = 48000, 51 AAC_BPS_64K = 64000, 52 AAC_BPS_96K = 96000, 53 AAC_BPS_128K = 128000, 54 AAC_BPS_256K = 256000, 55 AAC_BPS_320K = 320000, 56 AAC_BPS_BUTT 57 } AAC_BPS_E; 58 59 typedef enum hiAAC_TRANS_TYPE_E { 60 AAC_TRANS_TYPE_ADTS, 61 AAC_TRANS_TYPE_LOAS, 62 AAC_TRANS_TYPE_LATM_MCP1, 63 AAC_TRANS_TYPE_BUTT 64 } AAC_TRANS_TYPE_E; 65 66 typedef struct hiAAC_FRAME_INFO_S { 67 HI_S32 s32Samplerate; /* sample rate */ 68 HI_S32 s32BitRate; /* bitrate */ 69 HI_S32 s32Profile; /* profile */ 70 HI_S32 s32TnsUsed; /* TNS Tools */ 71 HI_S32 s32PnsUsed; /* PNS Tools */ 72 HI_S32 s32ChnNum; /* channel num */ 73 } AAC_FRAME_INFO_S; 74 75 /* 76 AAC Commendatory Parameter: 77 Sampling Rate(HZ) LC BitRate(Kbit/s) EAAC BitRate (Kbit/s) EAAC+ BitRate (Kbit/s) 78 48000 128 48 32,24 79 44100 128 48 32,24 80 32000 96 22 16 81 24000 64 82 22050 64 83 16000 48 84 */ 85 typedef struct hiAENC_ATTR_AAC_S { 86 AAC_TYPE_E enAACType; /* AAC profile type */ 87 AAC_BPS_E enBitRate; /* AAC bitrate (LC:16~320, EAAC:24~128, EAAC+:16~64, AACLD:16~320, AACELD:32~320) */ 88 AUDIO_SAMPLE_RATE_E enSmpRate; /* AAC sample rate (LC:8~48, EAAC:16~48, EAAC+:16~48, AACLD:8~48, AACELD:8~48) */ 89 AUDIO_BIT_WIDTH_E enBitWidth; /* AAC bit width (only support 16bit) */ 90 AUDIO_SOUND_MODE_E enSoundMode; /* sound mode of inferent audio frame */ 91 AAC_TRANS_TYPE_E enTransType; 92 93 HI_S16 s16BandWidth; /* targeted audio bandwidth in Hz (0 or 1000~enSmpRate/2), the default is 0 */ 94 } AENC_ATTR_AAC_S; 95 96 typedef struct hiAENC_AAC_ENCODER_S { 97 AAC_ENCODER_S *pstAACState; 98 AENC_ATTR_AAC_S stAACAttr; 99 } AENC_AAC_ENCODER_S; 100 101 typedef struct hiADEC_ATTR_AAC_S { 102 AAC_TRANS_TYPE_E enTransType; 103 } ADEC_ATTR_AAC_S; 104 105 typedef struct hiADEC_AAC_DECODER_S { 106 HAACDecoder pstAACState; 107 ADEC_ATTR_AAC_S stAACAttr; 108 } ADEC_AAC_DECODER_S; 109 110 HI_S32 HI_MPI_AENC_AacInit(HI_VOID); 111 112 HI_S32 HI_MPI_AENC_AacDeInit(HI_VOID); 113 114 HI_S32 HI_MPI_ADEC_AacInit(HI_VOID); 115 116 HI_S32 HI_MPI_ADEC_AacDeInit(HI_VOID); 117 118 #endif 119