11bd4fe43Sopenharmony_ci/* 21bd4fe43Sopenharmony_ci * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED. 31bd4fe43Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 41bd4fe43Sopenharmony_ci * you may not use this file except in compliance with the License. 51bd4fe43Sopenharmony_ci * You may obtain a copy of the License at 61bd4fe43Sopenharmony_ci * 71bd4fe43Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 81bd4fe43Sopenharmony_ci * 91bd4fe43Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 101bd4fe43Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 111bd4fe43Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 121bd4fe43Sopenharmony_ci * See the License for the specific language governing permissions and 131bd4fe43Sopenharmony_ci * limitations under the License. 141bd4fe43Sopenharmony_ci */ 151bd4fe43Sopenharmony_ci 161bd4fe43Sopenharmony_ci#ifndef __HI_COMM_ADEC_H__ 171bd4fe43Sopenharmony_ci#define __HI_COMM_ADEC_H__ 181bd4fe43Sopenharmony_ci 191bd4fe43Sopenharmony_ci 201bd4fe43Sopenharmony_ci#include "hi_type.h" 211bd4fe43Sopenharmony_ci#include "hi_common.h" 221bd4fe43Sopenharmony_ci#include "hi_comm_aio.h" 231bd4fe43Sopenharmony_ci 241bd4fe43Sopenharmony_ci#ifdef __cplusplus 251bd4fe43Sopenharmony_ci#if __cplusplus 261bd4fe43Sopenharmony_ciextern "C" { 271bd4fe43Sopenharmony_ci#endif 281bd4fe43Sopenharmony_ci#endif /* End of #ifdef __cplusplus */ 291bd4fe43Sopenharmony_ci 301bd4fe43Sopenharmony_citypedef struct hiADEC_ATTR_G711_S { 311bd4fe43Sopenharmony_ci HI_U32 resv; 321bd4fe43Sopenharmony_ci} ADEC_ATTR_G711_S; 331bd4fe43Sopenharmony_ci 341bd4fe43Sopenharmony_citypedef struct hiADEC_ATTR_G726_S { 351bd4fe43Sopenharmony_ci G726_BPS_E enG726bps; 361bd4fe43Sopenharmony_ci} ADEC_ATTR_G726_S; 371bd4fe43Sopenharmony_ci 381bd4fe43Sopenharmony_citypedef struct hiADEC_ATTR_ADPCM_S { 391bd4fe43Sopenharmony_ci ADPCM_TYPE_E enADPCMType; 401bd4fe43Sopenharmony_ci} ADEC_ATTR_ADPCM_S; 411bd4fe43Sopenharmony_ci 421bd4fe43Sopenharmony_citypedef struct hiADEC_ATTR_LPCM_S { 431bd4fe43Sopenharmony_ci HI_U32 resv; 441bd4fe43Sopenharmony_ci} ADEC_ATTR_LPCM_S; 451bd4fe43Sopenharmony_ci 461bd4fe43Sopenharmony_citypedef enum hiADEC_MODE_E { 471bd4fe43Sopenharmony_ci ADEC_MODE_PACK = 0, /* require input is valid dec pack(a 481bd4fe43Sopenharmony_ci complete frame encode result), 491bd4fe43Sopenharmony_ci e.g.the stream get from AENC is a 501bd4fe43Sopenharmony_ci valid dec pack, the stream know actually 511bd4fe43Sopenharmony_ci pack len from file is also a dec pack. 521bd4fe43Sopenharmony_ci this mode is high-performative */ 531bd4fe43Sopenharmony_ci ADEC_MODE_STREAM, /* input is stream, low-performative, 541bd4fe43Sopenharmony_ci if you couldn't find out whether a stream is 551bd4fe43Sopenharmony_ci vaild dec pack,you could use 561bd4fe43Sopenharmony_ci this mode */ 571bd4fe43Sopenharmony_ci ADEC_MODE_BUTT 581bd4fe43Sopenharmony_ci} ADEC_MODE_E; 591bd4fe43Sopenharmony_ci 601bd4fe43Sopenharmony_citypedef struct hiADEC_CH_ATTR_S { 611bd4fe43Sopenharmony_ci PAYLOAD_TYPE_E enType; 621bd4fe43Sopenharmony_ci HI_U32 u32BufSize; /* buf size[2~MAX_AUDIO_FRAME_NUM] */ 631bd4fe43Sopenharmony_ci ADEC_MODE_E enMode; /* decode mode */ 641bd4fe43Sopenharmony_ci HI_VOID ATTRIBUTE *pValue; 651bd4fe43Sopenharmony_ci} ADEC_CHN_ATTR_S; 661bd4fe43Sopenharmony_ci 671bd4fe43Sopenharmony_citypedef struct hiADEC_CHN_STATE_S { 681bd4fe43Sopenharmony_ci HI_BOOL bEndOfStream; /* EOS flag */ 691bd4fe43Sopenharmony_ci HI_U32 u32BufferFrmNum; /* total number of channel buffer */ 701bd4fe43Sopenharmony_ci HI_U32 u32BufferFreeNum; /* free number of channel buffer */ 711bd4fe43Sopenharmony_ci HI_U32 u32BufferBusyNum; /* busy number of channel buffer */ 721bd4fe43Sopenharmony_ci} ADEC_CHN_STATE_S; 731bd4fe43Sopenharmony_ci 741bd4fe43Sopenharmony_citypedef struct hiADEC_DECODER_S { 751bd4fe43Sopenharmony_ci PAYLOAD_TYPE_E enType; 761bd4fe43Sopenharmony_ci HI_CHAR aszName[17]; /* 17: name length */ 771bd4fe43Sopenharmony_ci /* struct ppDecoder is packed by user, user malloc and free memory for this struct */ 781bd4fe43Sopenharmony_ci HI_S32 (*pfnOpenDecoder)(HI_VOID *pDecoderAttr, HI_VOID **ppDecoder); 791bd4fe43Sopenharmony_ci HI_S32 (*pfnDecodeFrm)(HI_VOID *pDecoder, HI_U8 **pu8Inbuf, HI_S32 *ps32LeftByte, 801bd4fe43Sopenharmony_ci HI_U16 *pu16Outbuf, HI_U32 *pu32OutLen, HI_U32 *pu32Chns); 811bd4fe43Sopenharmony_ci HI_S32 (*pfnGetFrmInfo)(HI_VOID *pDecoder, HI_VOID *pInfo); 821bd4fe43Sopenharmony_ci HI_S32 (*pfnCloseDecoder)(HI_VOID *pDecoder); 831bd4fe43Sopenharmony_ci HI_S32 (*pfnResetDecoder)(HI_VOID *pDecoder); 841bd4fe43Sopenharmony_ci} ADEC_DECODER_S; 851bd4fe43Sopenharmony_ci 861bd4fe43Sopenharmony_citypedef enum hiEN_ADEC_ERR_CODE_E { 871bd4fe43Sopenharmony_ci ADEC_ERR_DECODER_ERR = 64, 881bd4fe43Sopenharmony_ci ADEC_ERR_BUF_LACK, 891bd4fe43Sopenharmony_ci} EN_ADEC_ERR_CODE_E; 901bd4fe43Sopenharmony_ci 911bd4fe43Sopenharmony_ci 921bd4fe43Sopenharmony_ci/* invalid device ID */ 931bd4fe43Sopenharmony_ci#define HI_ERR_ADEC_INVALID_DEVID HI_DEF_ERR(HI_ID_ADEC, EN_ERR_LEVEL_ERROR, EN_ERR_INVALID_DEVID) 941bd4fe43Sopenharmony_ci/* invalid channel ID */ 951bd4fe43Sopenharmony_ci#define HI_ERR_ADEC_INVALID_CHNID HI_DEF_ERR(HI_ID_ADEC, EN_ERR_LEVEL_ERROR, EN_ERR_INVALID_CHNID) 961bd4fe43Sopenharmony_ci/* at lease one parameter is illagal ,eg, an illegal enumeration value */ 971bd4fe43Sopenharmony_ci#define HI_ERR_ADEC_ILLEGAL_PARAM HI_DEF_ERR(HI_ID_ADEC, EN_ERR_LEVEL_ERROR, EN_ERR_ILLEGAL_PARAM) 981bd4fe43Sopenharmony_ci/* channel exists */ 991bd4fe43Sopenharmony_ci#define HI_ERR_ADEC_EXIST HI_DEF_ERR(HI_ID_ADEC, EN_ERR_LEVEL_ERROR, EN_ERR_EXIST) 1001bd4fe43Sopenharmony_ci/* channel unexists */ 1011bd4fe43Sopenharmony_ci#define HI_ERR_ADEC_UNEXIST HI_DEF_ERR(HI_ID_ADEC, EN_ERR_LEVEL_ERROR, EN_ERR_UNEXIST) 1021bd4fe43Sopenharmony_ci/* using a NULL point */ 1031bd4fe43Sopenharmony_ci#define HI_ERR_ADEC_NULL_PTR HI_DEF_ERR(HI_ID_ADEC, EN_ERR_LEVEL_ERROR, EN_ERR_NULL_PTR) 1041bd4fe43Sopenharmony_ci/* try to enable or initialize system,device or channel, before configing attribute */ 1051bd4fe43Sopenharmony_ci#define HI_ERR_ADEC_NOT_CONFIG HI_DEF_ERR(HI_ID_ADEC, EN_ERR_LEVEL_ERROR, EN_ERR_NOT_CONFIG) 1061bd4fe43Sopenharmony_ci/* operation is not supported by NOW */ 1071bd4fe43Sopenharmony_ci#define HI_ERR_ADEC_NOT_SUPPORT HI_DEF_ERR(HI_ID_ADEC, EN_ERR_LEVEL_ERROR, EN_ERR_NOT_SUPPORT) 1081bd4fe43Sopenharmony_ci/* operation is not permitted ,eg, try to change static attribute */ 1091bd4fe43Sopenharmony_ci#define HI_ERR_ADEC_NOT_PERM HI_DEF_ERR(HI_ID_ADEC, EN_ERR_LEVEL_ERROR, EN_ERR_NOT_PERM) 1101bd4fe43Sopenharmony_ci/* failure caused by malloc memory */ 1111bd4fe43Sopenharmony_ci#define HI_ERR_ADEC_NOMEM HI_DEF_ERR(HI_ID_ADEC, EN_ERR_LEVEL_ERROR, EN_ERR_NOMEM) 1121bd4fe43Sopenharmony_ci/* failure caused by malloc buffer */ 1131bd4fe43Sopenharmony_ci#define HI_ERR_ADEC_NOBUF HI_DEF_ERR(HI_ID_ADEC, EN_ERR_LEVEL_ERROR, EN_ERR_NOBUF) 1141bd4fe43Sopenharmony_ci/* no data in buffer */ 1151bd4fe43Sopenharmony_ci#define HI_ERR_ADEC_BUF_EMPTY HI_DEF_ERR(HI_ID_ADEC, EN_ERR_LEVEL_ERROR, EN_ERR_BUF_EMPTY) 1161bd4fe43Sopenharmony_ci/* no buffer for new data */ 1171bd4fe43Sopenharmony_ci#define HI_ERR_ADEC_BUF_FULL HI_DEF_ERR(HI_ID_ADEC, EN_ERR_LEVEL_ERROR, EN_ERR_BUF_FULL) 1181bd4fe43Sopenharmony_ci/* system is not ready,had not initialed or loaded */ 1191bd4fe43Sopenharmony_ci#define HI_ERR_ADEC_SYS_NOTREADY HI_DEF_ERR(HI_ID_ADEC, EN_ERR_LEVEL_ERROR, EN_ERR_SYS_NOTREADY) 1201bd4fe43Sopenharmony_ci/* decoder internal err */ 1211bd4fe43Sopenharmony_ci#define HI_ERR_ADEC_DECODER_ERR HI_DEF_ERR(HI_ID_ADEC, EN_ERR_LEVEL_ERROR, ADEC_ERR_DECODER_ERR) 1221bd4fe43Sopenharmony_ci/* input buffer not enough to decode one frame */ 1231bd4fe43Sopenharmony_ci#define HI_ERR_ADEC_BUF_LACK HI_DEF_ERR(HI_ID_ADEC, EN_ERR_LEVEL_ERROR, ADEC_ERR_BUF_LACK) 1241bd4fe43Sopenharmony_ci 1251bd4fe43Sopenharmony_ci#ifdef __cplusplus 1261bd4fe43Sopenharmony_ci#if __cplusplus 1271bd4fe43Sopenharmony_ci} 1281bd4fe43Sopenharmony_ci#endif 1291bd4fe43Sopenharmony_ci#endif /* End of #ifdef __cplusplus */ 1301bd4fe43Sopenharmony_ci 1311bd4fe43Sopenharmony_ci#endif /* End of #ifndef __HI_COMM_ADEC_H__ */ 1321bd4fe43Sopenharmony_ci 133