123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876 |
- #ifndef __AS_AUDIO_CODEC_H__
- #define __AS_AUDIO_CODEC_H__
- #include <stdint.h>
- #include "al_storage_io.h"
- #include "lib_a1_ape_p.h"
- #include "lib_a1_fla_p.h"
- #include "lib_a1_wav_e.h"
- #include "lib_a1_wav_p.h"
- #include "lib_a1_w13_p.h"
- #define MAX_CHANNEL_OUT 2
- typedef struct
- {
-
- void *pcm[MAX_CHANNEL_OUT];
-
- int channels;
-
- int samples;
-
- int sample_bits;
-
- int frac_bits;
- } asout_pcm_t;
- #define MAX_CHANNEL_IN 4
- typedef struct
- {
-
- void *pcm[MAX_CHANNEL_IN];
-
- int channels;
-
- int samples;
-
- int sample_bits;
-
- int frac_bits;
- } asin_pcm_t;
- #if 0
- typedef enum
- {
- UNSUPPORT_TYPE = 0,
- MP3_TYPE,
- WMA_TYPE,
- WAV_TYPE,
- FLAC_TYPE,
- APE_TYPE,
- AAC_TYPE,
- OGG_TYPE,
- ACT_TYPE,
- AMR_TYPE,
- SBC_TYPE,
- MSBC_TYPE,
- OPUS_TYPE,
- AAX_TYPE,
- AA_TYPE,
- CVSD_TYPE,
- SPEEX_TYPE,
-
- PCM_TYPE,
- } as_type_t;
- #endif
- typedef struct
- {
-
- int as_type;
-
- int total_time;
-
- int avg_bitrate;
-
- int sample_rate;
-
- int sample_rate_hz;
-
- int channels;
-
- int bps;
-
- int block_size;
-
- int frame_size;
-
- int sub_format;
-
- unsigned int file_len;
-
- unsigned int file_hdr_len;
-
- void *data_buf_addr;
-
- int data_buf_len;
-
- int drm_flag;
-
- void *key_buf;
-
- void *storage_io;
-
- void *buf;
-
- int decode_mode;
-
- void *global_buf_addr[3];
-
- int global_buf_len[3];
-
- void *share_buf_addr[3];
-
- int share_buf_len[3];
-
- int set_pcm_out_bits;
-
- int seek_mode;
-
- void *param;
- } as_dec_t;
- typedef struct
- {
-
- int global_buf_len[3];
-
- int share_buf_len[3];
-
- void* param;
- } as_mem_info_t;
- typedef struct
- {
-
- int bp_time_offset;
-
- unsigned int bp_file_offset;
-
- int bp_info_ext;
- } as_bp_info_t;
- typedef struct
- {
-
- void *addr;
-
- int len;
-
- int sample_size;
-
- int status;
- } as_dec_frame_info_t;
- typedef struct
- {
-
- int status;
-
- int cur_time;
-
- int cur_bitrate;
-
- int cur_energy;
-
- asout_pcm_t *aout;
-
- unsigned int cur_file_offset;
-
- int bytes_used;
-
- as_bp_info_t as_bp_info;
-
- void *param;
- } as_decode_info_t;
- typedef enum
- {
-
- AD_CMD_OPEN = 0,
-
- AD_CMD_CLOSE,
-
- AD_CMD_MEDIA_INFO,
-
- AD_CMD_CHUNK_RESET,
-
- AD_CMD_FRAME_DECODE,
-
- AD_CMD_CHUNK_SEEK,
-
- AD_CMD_CHANNEL_SET,
-
- AD_CMD_MEM_REQUIRE,
-
- AD_CMD_FRAME_PARSE,
-
- AD_CMD_GET_VERSION,
-
- AD_CMD_GET_ERROR_INFO,
-
- AD_CMD_DRM_INIT,
- } asdec_ex_ops_cmd_t;
- typedef enum
- {
-
- AD_RET_UNEXPECTED = -3,
-
- AD_RET_OUTOFMEMORY,
-
- AD_RET_UNSUPPORTED,
-
- AD_RET_OK,
-
- AD_RET_DATAUNDERFLOW,
- } asdec_ret_t;
- typedef int (*as_decoder_ops_t)(void *hnd, asdec_ex_ops_cmd_t cmd, unsigned int args);
- int as_decoder_format_check(void *storage_io, char extension[8]);
- int as_decoder_ops_aac(void *hnd, asdec_ex_ops_cmd_t cmd, unsigned int args);
- int as_decoder_ops_act(void *hnd, asdec_ex_ops_cmd_t cmd, unsigned int args);
- int as_decoder_ops_ape(void *hnd, asdec_ex_ops_cmd_t cmd, unsigned int args);
- int as_decoder_ops_cvsd(void *hnd, asdec_ex_ops_cmd_t cmd, unsigned int args);
- int as_decoder_ops_flac(void *hnd, asdec_ex_ops_cmd_t cmd, unsigned int args);
- int as_decoder_ops_mp3(void *hnd, asdec_ex_ops_cmd_t cmd, unsigned int args);
- int as_decoder_ops_pcm(void *hnd, asdec_ex_ops_cmd_t cmd, unsigned int args);
- int as_decoder_ops_sbc(void *hnd, asdec_ex_ops_cmd_t cmd, unsigned int args);
- int as_decoder_ops_wav(void *hnd, asdec_ex_ops_cmd_t cmd, unsigned int args);
- int as_decoder_ops_wma(void *hnd, asdec_ex_ops_cmd_t cmd, unsigned int args);
- typedef struct
- {
-
- int sample_rate;
-
- int channels;
-
- int channels_out;
-
- int bitrate;
-
- int audio_format;
-
- int chunk_time;
-
- int block_size;
-
- int block_enc_size_max;
-
- void *global_buf_addr[3];
-
- int global_buf_len[3];
-
- void *share_buf_addr[3];
-
- int share_buf_len[3];
-
- int sample_bits;
-
- void *param;
- } as_enc_t;
- typedef struct
- {
-
- int status;
-
- int cur_time;
-
- int cur_energy;
-
- int silence_flag;
-
- asin_pcm_t *ain;
-
- void *aout;
-
- int bytes_used;
-
- int bytes_remain;
-
- void *param;
- } as_encode_info_t;
- typedef struct
- {
-
- void *hdr_buf;
-
- int hdr_len;
- } as_enc_fhdr_t;
- typedef struct {
-
- int application;
-
- int complexity;
-
- int vbr;
- } as_enc_opus_param_t;
- typedef enum
- {
-
- AE_CMD_OPEN = 0,
-
- AE_CMD_CLOSE,
-
- AE_CMD_FRAME_ENCODE,
-
- AE_CMD_MEM_REQUIRE,
-
- AE_CMD_GET_VERSION,
-
- AE_CMD_GET_FHDR,
- } asenc_ex_ops_cmd_t;
- typedef enum
- {
-
- AE_RET_UNEXPECTED = -7,
-
- AE_RET_LIBLOAD_ERROR,
-
- AE_RET_LIB_ERROR,
-
- AE_RET_ENCODER_ERROR,
-
- AE_RET_FS_ERROR,
-
- AE_RET_OUTOFMEMORY,
-
- AE_RET_UNSUPPORTED,
-
- AE_RET_OK,
-
- AE_RET_DATAOVERFLOW,
-
- AE_RET_OUTOFDATA,
- } asenc_ret_t;
- typedef int (*as_encoder_ops_t)(void *hnd, asenc_ex_ops_cmd_t cmd, unsigned int args);
- int as_encoder_ops_cvsd(void *hnd, asenc_ex_ops_cmd_t cmd, unsigned int args);
- int as_encoder_ops_mp2(void *hnd, asenc_ex_ops_cmd_t cmd, unsigned int args);
- int as_encoder_ops_opus(void *hnd, asenc_ex_ops_cmd_t cmd, unsigned int args);
- int as_encoder_ops_pcm(void *hnd, asenc_ex_ops_cmd_t cmd, unsigned int args);
- int as_encoder_ops_sbc(void *hnd, asenc_ex_ops_cmd_t cmd, unsigned int args);
- int as_encoder_ops_wav(void *hnd, asenc_ex_ops_cmd_t cmd, unsigned int args);
- typedef enum
- {
-
- AP_RET_UNEXPECTED = -3,
-
- AP_RET_OUTOFMEMORY,
-
- AP_RET_UNSUPPORTED,
-
- AP_RET_OK = 0,
-
- AP_RET_ENDFILE
- } asparse_ret_t;
- typedef enum
- {
- AP_CMD_OPEN = 0,
- AP_CMD_CLOSE,
- AP_CMD_PARSER_HEADER,
- AP_CMD_GET_CHUNK,
- AP_CMD_SEEK,
- AP_CMD_EX_OPS,
- AP_CMD_FORCE_ENDFILE,
- } asparse_ex_ops_cmd_t;
- typedef struct
- {
-
- storage_io_t *storage_io;
-
- void *evtbuf;
- } asparse_param_t;
- typedef struct
- {
-
- char extension[8];
-
- int max_chunksize;
-
- int total_time;
-
- int avg_bitrate;
-
- int sample_rate;
-
- int channels;
-
- void *buf;
- int buf_len;
-
- int hdr_len;
-
- int sample_bits;
- } asparse_info_t;
- typedef struct
- {
-
- uint8_t *outbuf;
- uint16_t chunk_bytes;
- int16_t chunk_rest;
-
- int32_t chunk_start_time;
- int32_t chunk_start_offset;
- } asparse_bs_info_t;
- typedef struct
- {
-
- int32_t time_offset;
- int32_t origin;
-
- int32_t chunk_start_time;
-
- int32_t file_offset_for_time_offset;
- } asparse_seek_info_t;
- #define AP_SEEK_SET 0
- #define AP_SEEK_CUR 1
- #define AP_SEEK_END 2
- #define AP_TELL_CUR 0
- #define AP_TELL_END 1
- typedef int (*as_parser_ops_t)(void *hnd, asparse_ex_ops_cmd_t cmd, unsigned int args);
- int as_parser_ops_ape(void *hnd, asparse_ex_ops_cmd_t cmd, unsigned int args);
- int as_parser_ops_flac(void *hnd, asparse_ex_ops_cmd_t cmd, unsigned int args);
- int as_parser_ops_mp3(void *hnd, asparse_ex_ops_cmd_t cmd, unsigned int args);
- int as_parser_ops_wav(void *hnd, asparse_ex_ops_cmd_t cmd, unsigned int args);
- int as_parser_ops_wma(void *hnd, asparse_ex_ops_cmd_t cmd, unsigned int args);
- int as_parser_ops_a13(void *hnd, asparse_ex_ops_cmd_t cmd, unsigned int args);
- #endif
|