1 /******************************************************************************
2 *
3 * Copyright (C) 2018 The Android Open Source Project
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *****************************************************************************
18 * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
19 */
20 #include <string.h>
21 #include <stdlib.h>
22
23 #include "impd_type_def.h"
24 #include "impd_error_standards.h"
25 #include "impd_apicmd_standards.h"
26 #include "impd_memory_standards.h"
27
28 #include "impd_drc_bitbuffer.h"
29 #include "impd_drc_extr_delta_coded_info.h"
30 #include "impd_drc_common.h"
31 #include "impd_drc_struct.h"
32 #include "impd_drc_interface.h"
33 #include "impd_parametric_drc_dec.h"
34 #include "impd_drc_gain_dec.h"
35 #include "impd_drc_filter_bank.h"
36 #include "impd_drc_multi_band.h"
37 #include "impd_drc_process_audio.h"
38 #include "impd_drc_eq.h"
39 #include "impd_drc_gain_decoder.h"
40 #include "impd_drc_config_params.h"
41 #include "impd_drc_api_defs.h"
42 #include "impd_drc_definitions.h"
43 #include "impd_drc_hashdefines.h"
44 #include "impd_drc_peak_limiter.h"
45
46 #include "impd_drc_selection_process.h"
47 #include "impd_drc_api_struct_def.h"
48 #include "impd_drc_error_codes.h"
49
50 WORD32 impd_init_process_audio_main_qmf(ia_drc_api_struct *p_obj_drc);
51 WORD32 impd_init_process_audio_main_stft(ia_drc_api_struct *p_obj_drc);
52 WORD32 impd_init_process_audio_main_td_qmf(ia_drc_api_struct *p_obj_drc);
53
54 IA_ERRORCODE impd_drc_mem_api(ia_drc_api_struct *p_obj_drc, WORD32 i_cmd,
55 WORD32 i_idx, pVOID pv_value);
56
57 IA_ERRORCODE impd_drc_fill_mem_tables(ia_drc_api_struct *p_obj_drc);
58
59 VOID impd_drc_set_default_config_params(ia_drc_config_struct *ptr_config);
60
61 IA_ERRORCODE impd_drc_process_frame(ia_drc_api_struct *p_obj_drc);
62 IA_ERRORCODE impd_drc_init(ia_drc_api_struct *p_obj_drc);
63 IA_ERRORCODE impd_drc_set_default_config(ia_drc_api_struct *p_obj_drc);
64 IA_ERRORCODE impd_drc_set_struct_pointer(ia_drc_api_struct *p_obj_drc);
65 IA_ERRORCODE impd_process_time_domain(ia_drc_api_struct *p_obj_drc);
66
67 #define SUBBAND_BUF_SIZE \
68 NUM_ELE_IN_CPLX_NUM *MAX_CHANNEL_COUNT * sizeof(FLOAT32 *) + \
69 (MAX_SUBBAND_DELAY + MAX_DRC_FRAME_SIZE) * MAX_CHANNEL_COUNT * \
70 sizeof(FLOAT32) * NUM_ELE_IN_CPLX_NUM
71
72 #define NUM_DRC_TABLES 4
73 #define SCRATCH_MEM_SIZE \
74 (AUDIO_CODEC_FRAME_SIZE_MAX * MAX_CHANNEL_COUNT * sizeof(FLOAT32) * \
75 NUM_ELE_IN_CPLX_NUM)
76
77 #define PERSIST_MEM_SIZE \
78 (sizeof(ia_drc_state_struct) + sizeof(ia_drc_bits_dec_struct) + \
79 sizeof(ia_drc_gain_dec_struct) * 2 + \
80 sizeof(ia_drc_loudness_info_set_struct) + sizeof(ia_drc_gain_struct) + \
81 sizeof(ia_drc_interface_struct) + sizeof(ia_drc_config) + \
82 sizeof(ia_drc_sel_pro_struct) + sizeof(ia_drc_sel_proc_params_struct) + \
83 sizeof(ia_drc_sel_proc_output_struct) + \
84 sizeof(ia_drc_peak_limiter_struct) + sizeof(ia_drc_peak_limiter_struct) + \
85 sizeof(ia_drc_qmf_filt_struct) + ANALY_BUF_SIZE + SYNTH_BUF_SIZE + \
86 PEAK_LIM_BUF_SIZE + MAX_BS_BUF_SIZE + /*DRC Config Bitstream*/ \
87 MAX_DRC_CONFG_BUF_SIZE + /*DRC loudness info Bitstream*/ \
88 MAX_LOUD_INFO_BUF_SIZE + /*DRC interface Bitstream*/ \
89 MAX_INTERFACE_BUF_SIZE + \
90 NUM_GAIN_DEC_INSTANCES * \
91 (SEL_DRC_COUNT * sizeof(ia_interp_buf_struct) * MAX_GAIN_ELE_COUNT + \
92 sizeof(ia_eq_set_struct) + /*non_interleaved_audio*/ \
93 MAX_CHANNEL_COUNT * sizeof(FLOAT32 *) + \
94 MAX_DRC_FRAME_SIZE * sizeof(FLOAT32) * \
95 MAX_CHANNEL_COUNT + /*audio_in_out_buf ptr*/ \
96 MAX_CHANNEL_COUNT * sizeof(FLOAT32 *) + /*audio_io_buffer_delayed*/ \
97 MAX_CHANNEL_COUNT * sizeof(FLOAT32 *) + \
98 MAX_DRC_FRAME_SIZE * sizeof(FLOAT32) * \
99 MAX_CHANNEL_COUNT + /*subband band buffer ptr*/ \
100 NUM_ELE_IN_CPLX_NUM * MAX_CHANNEL_COUNT * sizeof(FLOAT32 *) + \
101 SUBBAND_BUF_SIZE + (PARAM_DRC_MAX_BUF_SZ * MAX_CHANNEL_COUNT)))
102
ia_drc_dec_api(pVOID p_ia_drc_dec_obj,WORD32 i_cmd,WORD32 i_idx,pVOID pv_value)103 IA_ERRORCODE ia_drc_dec_api(pVOID p_ia_drc_dec_obj, WORD32 i_cmd, WORD32 i_idx,
104 pVOID pv_value) {
105 ia_drc_api_struct *p_obj_drc = p_ia_drc_dec_obj;
106 IA_ERRORCODE error_code = IA_NO_ERROR;
107 LOOPIDX i;
108
109 pUWORD32 pui_value = pv_value;
110 pUWORD32 pus_value = pv_value;
111 pWORD8 pb_value = pv_value;
112 SIZE_T *ps_value = pv_value;
113
114 switch (i_cmd) {
115 case IA_API_CMD_GET_MEM_INFO_SIZE:
116 case IA_API_CMD_GET_MEM_INFO_ALIGNMENT:
117 case IA_API_CMD_GET_MEM_INFO_TYPE:
118 case IA_API_CMD_GET_MEM_INFO_PLACEMENT:
119 case IA_API_CMD_GET_MEM_INFO_PRIORITY:
120 case IA_API_CMD_SET_MEM_PTR:
121 case IA_API_CMD_SET_MEM_PLACEMENT: {
122 return impd_drc_mem_api(p_ia_drc_dec_obj, i_cmd, i_idx, pv_value);
123 }
124 };
125
126 switch (i_cmd) {
127 case IA_API_CMD_GET_LIB_ID_STRINGS: {
128 switch (i_idx) {
129 case IA_CMD_TYPE_LIB_NAME: {
130 WORD8 lib_name[] = LIBNAME;
131 for (i = 0; i < IA_API_STR_LEN && lib_name[i - 1] != 0; i++) {
132 pb_value[i] = lib_name[i];
133 }
134 break;
135 }
136 case IA_CMD_TYPE_LIB_VERSION: {
137 break;
138 }
139
140 case IA_CMD_TYPE_API_VERSION: {
141 }
142 default: { return -1; }
143 };
144 break;
145 }
146 case IA_API_CMD_GET_API_SIZE: {
147 *pui_value = sizeof(ia_drc_api_struct);
148
149 break;
150 }
151 case IA_API_CMD_INIT: {
152 switch (i_idx) {
153 case IA_CMD_TYPE_INIT_SET_BUFF_PTR: {
154 p_obj_drc->p_state->persistant_ptr =
155 (UWORD8 *)p_obj_drc->pp_mem[IA_DRC_PERSIST_IDX] +
156 sizeof(ia_drc_state_struct);
157 impd_drc_set_struct_pointer(p_obj_drc);
158
159 break;
160 }
161 case IA_CMD_TYPE_INIT_API_PRE_CONFIG_PARAMS: {
162 impd_drc_set_default_config(p_obj_drc);
163 break;
164 }
165 case IA_CMD_TYPE_INIT_API_POST_CONFIG_PARAMS: {
166 impd_drc_fill_mem_tables(p_obj_drc);
167 break;
168 }
169 case IA_CMD_TYPE_INIT_PROCESS: {
170 IA_ERRORCODE Error = 0;
171
172 if (p_obj_drc->pp_mem[IA_DRC_PERSIST_IDX] == 0) {
173 return (-1);
174 }
175
176 Error = impd_drc_init(p_obj_drc);
177 if (Error) return Error;
178 p_obj_drc->p_state->ui_init_done = 1;
179 return Error;
180 break;
181 }
182 case IA_CMD_TYPE_INIT_DONE_QUERY: {
183 if (p_obj_drc->p_state->ui_init_done == 1) {
184 *pui_value = 1;
185 } else {
186 *pui_value = 0;
187 }
188 break;
189 }
190
191 case IA_CMD_TYPE_INIT_CPY_BSF_BUFF_OVER_QUERY: {
192 *pui_value = p_obj_drc->str_bit_handler.cpy_over;
193 break;
194 }
195 case IA_CMD_TYPE_INIT_CPY_IC_BSF_BUFF_OVER_QUERY: {
196 *pui_value = p_obj_drc->str_bit_handler.cpy_over_ic;
197 break;
198 }
199
200 case IA_CMD_TYPE_INIT_CPY_IL_BSF_BUFF_OVER_QUERY: {
201 *pui_value = p_obj_drc->str_bit_handler.cpy_over_il;
202 break;
203 }
204 case IA_CMD_TYPE_INIT_CPY_IN_BSF_BUFF_OVER_QUERY: {
205 *pui_value = p_obj_drc->str_bit_handler.cpy_over_in;
206 break;
207 }
208 case IA_CMD_TYPE_INIT_CPY_BSF_BUFF: {
209 memcpy(p_obj_drc->str_bit_handler.it_bit_buf +
210 p_obj_drc->str_bit_handler.num_bytes_bs,
211 p_obj_drc->pp_mem[2], p_obj_drc->str_bit_handler.num_byts_cur);
212 p_obj_drc->str_bit_handler.num_bytes_bs =
213 p_obj_drc->str_bit_handler.num_bytes_bs +
214 p_obj_drc->str_bit_handler.num_byts_cur;
215 break;
216 }
217 case IA_CMD_TYPE_INIT_CPY_IC_BSF_BUFF: {
218 memcpy(p_obj_drc->str_bit_handler.bitstream_drc_config +
219 p_obj_drc->str_bit_handler.num_bytes_bs_drc_config,
220 p_obj_drc->pp_mem[2],
221 p_obj_drc->str_bit_handler.num_byts_cur_ic);
222 p_obj_drc->str_bit_handler.num_bytes_bs_drc_config =
223 p_obj_drc->str_bit_handler.num_bytes_bs_drc_config +
224 p_obj_drc->str_bit_handler.num_byts_cur_ic;
225 break;
226 }
227 case IA_CMD_TYPE_INIT_CPY_IL_BSF_BUFF: {
228 memcpy(p_obj_drc->str_bit_handler.bitstream_loudness_info +
229 p_obj_drc->str_bit_handler.num_bytes_bs_loudness_info,
230 p_obj_drc->pp_mem[2],
231 p_obj_drc->str_bit_handler.num_byts_cur_il);
232 p_obj_drc->str_bit_handler.num_bytes_bs_loudness_info =
233 p_obj_drc->str_bit_handler.num_bytes_bs_loudness_info +
234 p_obj_drc->str_bit_handler.num_byts_cur_il;
235 break;
236 }
237 case IA_CMD_TYPE_INIT_CPY_IN_BSF_BUFF: {
238 memcpy(p_obj_drc->str_bit_handler.bitstream_unidrc_interface +
239 p_obj_drc->str_bit_handler.num_bytes_bs_unidrc_interface,
240 p_obj_drc->pp_mem[2],
241 p_obj_drc->str_bit_handler.num_byts_cur_in);
242 p_obj_drc->str_bit_handler.num_bytes_bs_unidrc_interface =
243 p_obj_drc->str_bit_handler.num_bytes_bs_unidrc_interface +
244 p_obj_drc->str_bit_handler.num_byts_cur_in;
245 break;
246 }
247 default: { return -1; }
248 };
249 break;
250 }
251 case IA_API_CMD_GET_CONFIG_PARAM: {
252 switch (i_idx) {
253 case IA_DRC_DEC_CONFIG_PARAM_SAMP_FREQ: {
254 *pus_value = p_obj_drc->str_config.sampling_rate;
255 break;
256 }
257
258 case IA_DRC_DEC_CONFIG_PARAM_NUM_CHANNELS: {
259 *pus_value = p_obj_drc->str_config.num_ch_out;
260 break;
261 }
262 case IA_DRC_DEC_CONFIG_PROC_OUT_PTR: {
263 *ps_value = (SIZE_T)p_obj_drc->str_payload.pstr_drc_sel_proc_output;
264 break;
265 }
266 }
267 break;
268 }
269 case IA_API_CMD_SET_CONFIG_PARAM: {
270 switch (i_idx) {
271 case IA_DRC_DEC_CONFIG_PARAM_DEC_TYPE: {
272 if (*pus_value == 1) {
273 p_obj_drc->str_config.dec_type = DEC_TYPE_TD_QMF64;
274 p_obj_drc->str_config.sub_band_domain_mode =
275 SUBBAND_DOMAIN_MODE_QMF64;
276 p_obj_drc->str_config.sub_band_down_sampling_factor =
277 AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_QMF64;
278 p_obj_drc->str_config.sub_band_count =
279 AUDIO_CODEC_SUBBAND_COUNT_QMF64;
280 } else if (*pus_value == 2) {
281 p_obj_drc->str_config.dec_type = DEC_TYPE_QMF64;
282 p_obj_drc->str_config.sub_band_domain_mode =
283 SUBBAND_DOMAIN_MODE_QMF64;
284 p_obj_drc->str_config.sub_band_down_sampling_factor =
285 AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_QMF64;
286 p_obj_drc->str_config.sub_band_count =
287 AUDIO_CODEC_SUBBAND_COUNT_QMF64;
288 } else if (*pus_value == 3) {
289 p_obj_drc->str_config.dec_type = DEC_TYPE_STFT256;
290 p_obj_drc->str_config.sub_band_domain_mode =
291 SUBBAND_DOMAIN_MODE_STFT256;
292 p_obj_drc->str_config.sub_band_down_sampling_factor =
293 AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_STFT256;
294 p_obj_drc->str_config.sub_band_count =
295 AUDIO_CODEC_SUBBAND_COUNT_STFT256;
296 } else {
297 p_obj_drc->str_config.dec_type = DEC_TYPE_TD;
298 p_obj_drc->str_config.sub_band_domain_mode =
299 SUBBAND_DOMAIN_MODE_OFF;
300 }
301
302 if (*pus_value < 0 || *pus_value > 3) {
303 return IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_DECODE_TYPE;
304 }
305 break;
306 }
307 case IA_DRC_DEC_CONFIG_PARAM_CTRL_PARAM: {
308 if (*pus_value < 1 || *pus_value > 39) {
309 return IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_CTRL_PARAM_IDX;
310 }
311 p_obj_drc->str_config.control_parameter_index = *pus_value;
312 break;
313 }
314 case IA_DRC_DEC_CONFIG_PARAM_PEAK_LIMITER: {
315 if (*pus_value < 0 || *pus_value > 1) {
316 return IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_PEAK_LIM_FLAG;
317 }
318 p_obj_drc->str_config.peak_limiter = *pus_value;
319 break;
320 }
321
322 case IA_DRC_DEC_CONFIG_PARAM_VER_MODE: {
323 break;
324 }
325 case IA_DRC_DEC_CONFIG_PARAM_SAMP_FREQ: {
326 if (*pus_value < 8000 || *pus_value > 96000) {
327 return IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_SAMP_FREQ;
328 }
329 p_obj_drc->str_config.sampling_rate = *pus_value;
330 break;
331 }
332 case IA_DRC_DEC_CONFIG_PARAM_NUM_CHANNELS: {
333 p_obj_drc->str_config.num_ch_in = *pus_value;
334 if (*pus_value < 1 || *pus_value > MAX_CHANNEL_COUNT) {
335 return IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_NUM_OF_CHANNELS;
336 }
337 break;
338 }
339
340 case IA_DRC_DEC_CONFIG_PARAM_PCM_WDSZ: {
341 if ((*pus_value != 16) && (*pus_value != 32)) {
342 return IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_PCM_SIZE;
343 }
344
345 p_obj_drc->str_config.pcm_size = *pus_value;
346
347 break;
348 }
349
350 case IA_DRC_DEC_CONFIG_PARAM_BITS_FORMAT: {
351 if ((*pus_value != 1) && (*pus_value != 0)) {
352 return -1;
353 }
354 p_obj_drc->str_config.bitstream_file_format = *pus_value;
355
356 break;
357 }
358 case IA_DRC_DEC_CONFIG_PARAM_INT_PRESENT: {
359 if ((*pus_value != 1) && (*pus_value != 0)) {
360 return -1;
361 }
362 p_obj_drc->str_config.interface_bitstream_present = *pus_value;
363
364 break;
365 }
366 case IA_DRC_DEC_CONFIG_PARAM_DELAY_MODE: {
367 if ((*pus_value != 1) && (*pus_value != 0)) {
368 return IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_DELAY_MODE;
369 }
370 p_obj_drc->str_config.delay_mode = *pus_value;
371
372 break;
373 }
374 case IA_DRC_DEC_CONFIG_PARAM_GAIN_DELAY: {
375 if ((*pus_value > MAX_SIGNAL_DELAY) || (*pus_value < 0)) {
376 return IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_GAIN_DELAY;
377 }
378
379 p_obj_drc->str_config.gain_delay_samples = *pus_value;
380
381 break;
382 }
383
384 /*Sujith: introduce error*/
385 case IA_DRC_DEC_CONFIG_PARAM_AUDIO_DELAY: {
386 break;
387 }
388 case IA_DRC_DEC_CONFIG_PARAM_CON_DELAY_MODE: {
389 if (*pus_value < 0 || *pus_value > 1) {
390 return IA_DRC_DEC_CONFIG_PARAM_CON_DELAY_MODE;
391 }
392 p_obj_drc->str_config.constant_delay_on = *pus_value;
393
394 break;
395 }
396 case IA_DRC_DEC_CONFIG_PARAM_ABSO_DELAY_OFF: {
397 p_obj_drc->str_config.absorb_delay_on = *pus_value;
398
399 break;
400 }
401 case IA_DRC_DEC_CONFIG_PARAM_FRAME_SIZE: {
402 if (*pus_value < 1 || *pus_value > 4096) {
403 return IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_FRAME_SIZE;
404 }
405
406 p_obj_drc->str_config.frame_size = *pus_value;
407
408 break;
409 }
410 case IA_DRC_DEC_CONFIG_GAIN_STREAM_FLAG: {
411 p_obj_drc->str_bit_handler.gain_stream_flag = *pus_value;
412 break;
413 }
414
415 case IA_DRC_DEC_CONFIG_DRC_EFFECT_TYPE: {
416 p_obj_drc->str_config.effect_type = *pus_value;
417 break;
418 }
419 case IA_DRC_DEC_CONFIG_DRC_TARGET_LOUDNESS: {
420 p_obj_drc->str_config.target_loudness = *pus_value;
421 break;
422 }
423 case IA_DRC_DEC_CONFIG_DRC_LOUD_NORM: {
424 p_obj_drc->str_config.loud_norm_flag = *pus_value;
425 break;
426 }
427
428 default: { return -1; }
429 }
430 break;
431 }
432 case IA_API_CMD_GET_MEMTABS_SIZE: {
433 *pui_value =
434 (sizeof(ia_mem_info_struct) + sizeof(pVOID *)) * (NUM_DRC_TABLES);
435 break;
436 }
437 case IA_API_CMD_SET_MEMTABS_PTR: {
438 if (ps_value == NULL) return IA_DRC_DEC_API_FATAL_MEM_ALLOC;
439 memset(ps_value, 0,
440 (sizeof(ia_mem_info_struct) + sizeof(pVOID *)) * (NUM_DRC_TABLES));
441 p_obj_drc->p_mem_info = (ia_mem_info_struct *)(ps_value);
442 p_obj_drc->pp_mem =
443 (pVOID)((SIZE_T)p_obj_drc->p_mem_info +
444 (NUM_DRC_TABLES * sizeof(*(p_obj_drc->p_mem_info))));
445 break;
446 }
447 case IA_API_CMD_GET_N_MEMTABS: {
448 *pui_value = NUM_DRC_TABLES;
449 break;
450 }
451 case IA_API_CMD_GET_N_TABLES: {
452 break;
453 }
454
455 case IA_API_CMD_EXECUTE: {
456 switch (i_idx) {
457 case IA_CMD_TYPE_DO_EXECUTE: {
458 if (!p_obj_drc->p_state->ui_init_done) {
459 error_code = IA_FATAL_ERROR;
460 } else if (p_obj_drc->str_config.dec_type == DEC_TYPE_TD) {
461 error_code = impd_process_time_domain(p_obj_drc);
462 } else if (p_obj_drc->str_config.dec_type == DEC_TYPE_QMF64) {
463 error_code = impd_init_process_audio_main_qmf(p_obj_drc);
464 } else if (p_obj_drc->str_config.dec_type == DEC_TYPE_STFT256) {
465 error_code = impd_init_process_audio_main_stft(p_obj_drc);
466 } else if (p_obj_drc->str_config.dec_type == DEC_TYPE_TD_QMF64) {
467 error_code = impd_init_process_audio_main_td_qmf(p_obj_drc);
468 }
469 break;
470 }
471 case IA_CMD_TYPE_DONE_QUERY: {
472 *pui_value = p_obj_drc->p_state->ui_exe_done;
473 break;
474 }
475 default: { return -1; }
476 };
477 break;
478 }
479 case IA_API_CMD_PUT_INPUT_QUERY: {
480 *pui_value = 1;
481 break;
482 }
483 case IA_API_CMD_GET_CURIDX_INPUT_BUF: {
484 UWORD32 ui_in_buf_size = p_obj_drc->p_mem_info[IA_DRC_INPUT_IDX].ui_size;
485 UWORD32 ui_in_bytes = p_obj_drc->p_state->ui_in_bytes;
486 *pui_value = ui_in_buf_size > ui_in_bytes ? ui_in_bytes : ui_in_buf_size;
487 break;
488 }
489 case IA_API_CMD_SET_INPUT_BYTES: {
490 p_obj_drc->p_state->ui_in_bytes = *pui_value;
491 break;
492 }
493
494 case IA_API_CMD_GET_OUTPUT_BYTES: {
495 *pui_value = p_obj_drc->p_state->ui_out_bytes;
496 break;
497 }
498 case IA_API_CMD_INPUT_OVER: {
499 p_obj_drc->p_state->ui_exe_done = 1;
500 break;
501 }
502 case IA_API_CMD_INPUT_OVER_BS: {
503 p_obj_drc->str_bit_handler.cpy_over = 1;
504 break;
505 }
506 case IA_API_CMD_INPUT_OVER_IC_BS: {
507 p_obj_drc->str_bit_handler.cpy_over_ic = 1;
508 break;
509 }
510 case IA_API_CMD_INPUT_OVER_IL_BS: {
511 p_obj_drc->str_bit_handler.cpy_over_il = 1;
512 break;
513 }
514 case IA_API_CMD_INPUT_OVER_IN_BS: {
515 p_obj_drc->str_bit_handler.cpy_over_in = 1;
516 break;
517 }
518 case IA_API_CMD_SET_INPUT_BYTES_BS: {
519 p_obj_drc->str_bit_handler.num_byts_cur = *pus_value;
520 break;
521 }
522 case IA_API_CMD_SET_INPUT_BYTES_IC_BS: {
523 p_obj_drc->str_bit_handler.num_byts_cur_ic = *pus_value;
524 break;
525 }
526 case IA_API_CMD_SET_INPUT_BYTES_IL_BS: {
527 p_obj_drc->str_bit_handler.num_byts_cur_il = *pus_value;
528 break;
529 }
530 case IA_API_CMD_SET_INPUT_BYTES_IN_BS: {
531 p_obj_drc->str_bit_handler.num_byts_cur_in = *pus_value;
532 break;
533 }
534 default: { return -1; }
535 };
536 return error_code;
537 }
538
impd_drc_mem_api(ia_drc_api_struct * p_obj_drc,WORD32 i_cmd,WORD32 i_idx,pVOID pv_value)539 IA_ERRORCODE impd_drc_mem_api(ia_drc_api_struct *p_obj_drc, WORD32 i_cmd,
540 WORD32 i_idx, pVOID pv_value) {
541 pUWORD32 pui_value = pv_value;
542
543 switch (i_cmd) {
544 case IA_API_CMD_GET_MEM_INFO_SIZE: {
545 *pui_value = p_obj_drc->p_mem_info[i_idx].ui_size;
546 break;
547 }
548 case IA_API_CMD_GET_MEM_INFO_ALIGNMENT: {
549 *pui_value = p_obj_drc->p_mem_info[i_idx].ui_alignment;
550 break;
551 }
552 case IA_API_CMD_GET_MEM_INFO_TYPE: {
553 *pui_value = p_obj_drc->p_mem_info[i_idx].ui_type;
554 break;
555 }
556 case IA_API_CMD_GET_MEM_INFO_PLACEMENT: {
557 *pui_value = p_obj_drc->p_mem_info[i_idx].ui_placement[0];
558 *(pui_value + 1) = p_obj_drc->p_mem_info[i_idx].ui_placement[1];
559 break;
560 }
561 case IA_API_CMD_GET_MEM_INFO_PRIORITY: {
562 *pui_value = p_obj_drc->p_mem_info[i_idx].ui_priority;
563 break;
564 }
565 case IA_API_CMD_SET_MEM_PTR: {
566 if (pv_value == 0) {
567 return (-1);
568 }
569 if (((SIZE_T)pv_value % p_obj_drc->p_mem_info[i_idx].ui_alignment) != 0) {
570 return (-1);
571 }
572 p_obj_drc->pp_mem[i_idx] = pv_value;
573 memset(p_obj_drc->pp_mem[i_idx], 0, p_obj_drc->p_mem_info[i_idx].ui_size);
574 if (IA_MEMTYPE_PERSIST == i_idx) {
575 p_obj_drc->p_state = pv_value;
576 }
577 break;
578 }
579 case IA_API_CMD_SET_MEM_PLACEMENT: {
580 }
581 };
582 return IA_NO_ERROR;
583 }
584
impd_drc_fill_mem_tables(ia_drc_api_struct * p_obj_drc)585 IA_ERRORCODE impd_drc_fill_mem_tables(ia_drc_api_struct *p_obj_drc) {
586 ia_mem_info_struct *p_mem_info;
587 {
588 p_mem_info = &p_obj_drc->p_mem_info[IA_DRC_PERSIST_IDX];
589 memset(p_mem_info, 0, sizeof(*p_mem_info));
590 p_mem_info->ui_size = PERSIST_MEM_SIZE;
591 p_mem_info->ui_alignment = 8;
592 p_mem_info->ui_type = IA_MEMTYPE_PERSIST;
593 p_mem_info->ui_placement[0] = 0;
594 p_mem_info->ui_placement[1] = 0;
595 p_mem_info->ui_priority = IA_MEMPRIORITY_ANYWHERE;
596 p_mem_info->ui_placed[0] = 0;
597 p_mem_info->ui_placed[1] = 0;
598 }
599 {
600 p_mem_info = &p_obj_drc->p_mem_info[IA_DRC_INPUT_IDX];
601 memset(p_mem_info, 0, sizeof(*p_mem_info));
602 p_mem_info->ui_size = p_obj_drc->str_config.frame_size *
603 (p_obj_drc->str_config.pcm_size >> 3) *
604 p_obj_drc->str_config.num_ch_in;
605 p_mem_info->ui_alignment = 4;
606 p_mem_info->ui_type = IA_MEMTYPE_INPUT;
607 p_mem_info->ui_placement[0] = 0;
608 p_mem_info->ui_placement[1] = 0;
609 p_mem_info->ui_priority = IA_MEMPRIORITY_ANYWHERE;
610 p_mem_info->ui_placed[0] = 0;
611 p_mem_info->ui_placed[1] = 0;
612 }
613 {
614 p_mem_info = &p_obj_drc->p_mem_info[IA_DRC_OUTPUT_IDX];
615 memset(p_mem_info, 0, sizeof(*p_mem_info));
616 p_mem_info->ui_size = p_obj_drc->str_config.frame_size *
617 (p_obj_drc->str_config.pcm_size >> 3) *
618 p_obj_drc->str_config.num_ch_in;
619 p_mem_info->ui_alignment = 4;
620 p_mem_info->ui_type = IA_MEMTYPE_OUTPUT;
621 p_mem_info->ui_placement[0] = 0;
622 p_mem_info->ui_placement[1] = 0;
623 p_mem_info->ui_priority = IA_MEMPRIORITY_ANYWHERE;
624 p_mem_info->ui_placed[0] = 0;
625 p_mem_info->ui_placed[1] = 0;
626 }
627 {
628 p_mem_info = &p_obj_drc->p_mem_info[IA_DRC_SCRATCH_IDX];
629 memset(p_mem_info, 0, sizeof(*p_mem_info));
630 p_mem_info->ui_size = SCRATCH_MEM_SIZE;
631 p_mem_info->ui_alignment = 8;
632 p_mem_info->ui_type = IA_MEMTYPE_SCRATCH;
633 p_mem_info->ui_placement[0] = 0;
634 p_mem_info->ui_placement[1] = 0;
635 p_mem_info->ui_priority = IA_MEMPRIORITY_ANYWHERE;
636 p_mem_info->ui_placed[0] = 0;
637 p_mem_info->ui_placed[1] = 0;
638 }
639 return IA_NO_ERROR;
640 }
641