xa_lc3_codec_api.h
10.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
/*
* Copyright (c) 2019-2020 by Cadence Design Systems, Inc. ALL RIGHTS RESERVED.
* These coded instructions, statements, and computer programs are the
* copyrighted works and confidential proprietary information of
* Cadence Design Systems Inc. They may be adapted and modified by bona fide
* purchasers for internal use, but neither the original nor any adapted
* or modified version may be disclosed or distributed to third parties
* in any manner, medium, or form, in whole or in part, without the prior
* written consent of Cadence Design Systems Inc. This software and its
* derivatives are to be executed solely on products incorporating a Cadence
* Design Systems processor.
*/
#ifndef __XA_LC3_CODEC_API_H__
#define __XA_LC3_CODEC_API_H__
#include "tx_port.h"
#include "xa_error_standards.h"
#include "xa_type_def.h"
/*Maximum number of supported channels.*/
#define XA_LC3_MAX_CHANNELS 2
/*No channels define.*/
#define XA_LC3_NO_CHANNELS 0
/*One channel define.*/
#define XA_LC3_ONE_CHANNEL 1
/*Two channels define.*/
#define XA_LC3_TWO_CHANNELS 2
/*Maximum number of samples per channel that can be stored in one LC3 frame*/
#define XA_LC3_MAX_SAMPLES 360
/* Maximum number of bytes of one LC3 frame. */
#define XA_LC3_MAX_BYTES 870
/* PLC methods values */
#define XA_LC3_PLCMETH_0 0
#define XA_LC3_MAX_PLCMETH 1
/* Bits per sample values */
#define XA_LC3_BIPS_VAL_16 16
#define XA_LC3_BIPS_VAL_24 24
#define XA_LC3_BIPS_VAL_32 32
#define XA_LC3_BIPS_VAL_48 32
/* Sample rates supported values */
#define XA_LC3_SAMPLE_RATE_8KHZ 8000
#define XA_LC3_SAMPLE_RATE_16KHZ 16000
#define XA_LC3_SAMPLE_RATE_24KHZ 24000
#define XA_LC3_SAMPLE_RATE_32KHZ 32000
#define XA_LC3_SAMPLE_RATE_44_1KHZ 44100
#define XA_LC3_SAMPLE_RATE_48KHZ 48000
/* Default bits per sample value for decoder output*/
#define XA_LC3_BIPS_OUT_DEF_VAL XA_LC3_BIPS_VAL_16
/* Default bits per sample value for encoder input*/
#define XA_LC3_BIPS_IN_DEF_VAL XA_LC3_BIPS_VAL_16
/* Default PLC method value*/
#define XA_LC3_PLC_METH_DEF_VAL XA_LC3_PLCMETH_0
/* Default PLC method value*/
//#define XA_LC3_SAMPLE_RATE_DEF_VAL XA_LC3_SAMPLE_RATE_8KHZ
#define XA_LC3_SAMPLE_RATE_DEF_VAL XA_LC3_SAMPLE_RATE_48KHZ
//#define XA_LC3_SAMPLE_RATE_DEF_VAL XA_LC3_SAMPLE_RATE_44_1KHZ
/* Default number of channel value*/
#define XA_LC3_NUM_OF_CH_DEF_VAL XA_LC3_ONE_CHANNEL
//#define XA_LC3_NUM_OF_CH_DEF_VAL XA_LC3_TWO_CHANNELS
/* Default bitrate value*/
//#define XA_LC3_BITRATE_DEF_VAL 32000
//#define XA_LC3_BITRATE_DEF_VAL 96000
#define XA_LC3_BITRATE_DEF_VAL 80000
#define XA_CODEC_LC3 6
//#define XA_LC3_FRAME_MS 10 //10ms
//#define XA_LC3_FRAME_MS 7.5 //10ms
#define XA_LC3_FRAME_MS 5 //5ms
/*
Commands for encoder:
XA_LC3_ENC_PARAM_FRAME_LENGTH - get frame length from encoder
XA_LC3_ENC_PARAM_BITRATE - set encoder bit rate
XA_LC3_ENC_PARAM_REAL_BITRATE - get real bit rate from encoder
*/
typedef enum
{
XA_LC3_ENC_PARAM_FRAME_LENGTH = 0,
XA_LC3_ENC_PARAM_BITRATE = 1,
XA_LC3_ENC_PARAM_REAL_BITRATE = 2,
XA_LC3_ENC_PARAM_FRAME_DMS = 3,
XA_LC3_ENC_PARAM_DELAY_COMPENSATION = 4
}xa_lc3_enc_param_id_t;
/*
Commands for decoder:
XA_LC3_DEC_PARAM_FRAME_LENGTH - get frame length from decoder
*/
typedef enum
{
XA_LC3_DEC_PARAM_FRAME_LENGTH = 0,
XA_LC3_DEC_PARAM_FRAME_DMS = 1,
XA_LC3_DEC_PARAM_DELAY_COMPENSATION = 2
}xa_lc3_dec_param_id_t;
/*****************************************************************************/
/* Class 1: Configuration Errors */
/*****************************************************************************/
/* Nonfatal Errors */
enum xa_error_nonfatal_config_lc3_codec
{
XA_LC3_CONFIG_NONFATAL_INVALID_PARAM = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_config, XA_CODEC_LC3, 0),
XA_LC3_CONFIG_NONFATAL_DEC_PLC_MODE_NOT_SUPPORTED = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_config, XA_CODEC_LC3, 1)
};
/* Fatal Errors */
enum xa_error_fatal_config_lc3_codec
{
XA_LC3_CONFIG_FATAL_SAMP_FREQ_NOT_SUPPORTED = XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_LC3, 0),
XA_LC3_CONFIG_FATAL_NUM_CHANNEL_NOT_SUPPORTED = XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_LC3, 1),
XA_LC3_CONFIG_FATAL_ENC_BITRATE_NOT_SUPPORTED = XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_LC3, 2),
XA_LC3_CONFIG_FATAL_BITDEPTH_NOT_SUPPORTED = XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_LC3, 3),
XA_LC3_FRAMEMS_NOT_SUPPORTED = XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_LC3, 4)
};
/*****************************************************************************/
/* Class 2: Execution Class Errors */
/*****************************************************************************/
/* Nonfatal Errors */
enum xa_error_nonfatal_execute_lc3_codec
{
XA_LC3_EXECUTE_NONFATAL_DECODE_ERROR = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_LC3, 0)
};
/* Fatal Errors */
enum xa_error_fatal_execute_lc3_codec
{
XA_LC3_EXECUTE_FATAL_DEC_NUMBYTES_ERROR = XA_ERROR_CODE(xa_severity_fatal, xa_class_execute, XA_CODEC_LC3, 0),
XA_LC3_EXECUTE_FATAL_NOT_INITIALIZED = XA_ERROR_CODE(xa_severity_fatal, xa_class_execute, XA_CODEC_LC3, 1)
};
/***********************************************/
/* Structure for controlling encoder operation */
/***********************************************/
typedef struct
{
/* I: Output signal sampling rate, Hertz; 8000/16000/24000/32000/44100/48000 */
UWORD32 sampleRate;
/* I: Number of channels of output signal; 1/2 */
WORD16 nChannels;
/* I: Target bitrate, kbps; (16-320) */
WORD32 bitrate;
/* I: Bits per sample of input signal; 16/24 */
WORD16 bipsIn;
} xa_lc3_enc_init_cfg_t;
/***********************************************/
/* Structure for controlling decoder operation */
/***********************************************/
typedef struct
{
/* I: Output signal sampling rate in Hertz; 8000/16000/24000/32000/44100/48000 */
UWORD32 sampleRate;
/* I: Number of channels of output signal; 1/2 */
WORD16 nChannels;
/* I: Packet loss concealment(PLC) method; 0/1 */
#ifndef DISABLE_PLC_API
WORD32 plcMeth;
#endif /* #ifdef DISABLE_PLC_API */
/* I: Bits per sample of output signal; 16/24 */
WORD32 bipsOut;
} xa_lc3_dec_init_cfg_t;
/****************************************************************
* Common API calls
****************************************************************/
#if defined(__cplusplus)
extern "C" {
#endif
/****************************************************************************
* Common API calls *
*****************************************************************************/
const char * xa_lc3_get_lib_name_string();
const char * xa_lc3_get_lib_version_string();
const char * xa_lc3_get_lib_api_version_string();
/****************************************************************************
* Encoder function *
*****************************************************************************/
WORD32 xa_lc3_enc_get_handle_byte_size(
xa_lc3_enc_init_cfg_t *p_cfg /* I: Initial configuration parameters.*/
);
WORD32 xa_lc3_enc_get_scratch_byte_size(
xa_lc3_enc_init_cfg_t *p_cfg /* I: Initial configuration parameters.*/
);
XA_ERRORCODE xa_lc3_enc_init(
xa_codec_handle_t handle, /* I/O: State handle. */
pWORD32 scratch, /* I: Scratch memory. */
xa_lc3_enc_init_cfg_t *p_cfg /* I: Initial configuration parameters. */
);
XA_ERRORCODE xa_lc3_enc_process(
xa_codec_handle_t handle, /* I/O: State handle. */
pVOID p_in_data, /* I: Input buffer. */
pVOID p_out_data, /* O: Output buffer. */
pUWORD32 p_in_samples, /* I/O: Number of input samples. */
pUWORD32 p_out_bytes /* I/O: Number of output bytes. */
);
XA_ERRORCODE xa_lc3_enc_get_param(
xa_codec_handle_t handle, /* I/O: State handle. */
xa_lc3_enc_param_id_t param_id, /* I: Parameter to be read. */
pVOID p_param_value /* O: Parameter value. */
);
XA_ERRORCODE xa_lc3_enc_set_param(
xa_codec_handle_t handle, /* I/O: State handle. */
xa_lc3_enc_param_id_t param_id, /* I: Parameter to be written. */
pVOID p_param_value /* I: Parameter value. */
);
/*****************************************************************************
* Decoder function *
*****************************************************************************/
WORD32 xa_lc3_dec_get_handle_byte_size(
xa_lc3_dec_init_cfg_t *p_cfg /* I: Initial configuration parameters.*/
);
WORD32 xa_lc3_dec_get_scratch_byte_size(
xa_lc3_dec_init_cfg_t *p_cfg /* I: Initial configuration parameters.*/
);
XA_ERRORCODE xa_lc3_dec_init(
xa_codec_handle_t handle, /* I/O: State handle. */
pWORD32 scratch, /* I: Scratch memory. */
xa_lc3_dec_init_cfg_t *p_cfg /* I: Initial configuration parameters. */
);
XA_ERRORCODE xa_lc3_dec_process(
xa_codec_handle_t handle, /* I/O: State handle. */
pVOID p_in_data, /* I: Input buffer. */
pVOID p_out_data, /* O: Output buffer. */
pUWORD32 p_in_bytes, /* I/O: Number of input bytes. */
pUWORD32 p_out_samples /* I/O: Number of output samples. */
);
XA_ERRORCODE xa_lc3_dec_get_param(
xa_codec_handle_t handle, /* I/O: State handle. */
xa_lc3_dec_param_id_t param_id, /* I: Parameter to be read. */
pVOID p_param_value /* O: Parameter value. */
);
XA_ERRORCODE xa_lc3_dec_set_param(
xa_codec_handle_t handle, /* I/O: State handle. */
xa_lc3_dec_param_id_t param_id, /* I: Parameter to be written. */
pVOID p_param_value /* I: Parameter value. */
);
#if defined(__cplusplus)
}
#endif
#endif /* __XA_LC3_CODEC_API_H__ */