[processor-sdk/performance-audio-sr.git] / processor_audio_sdk_1_00_00_00 / pasdk / test_dsp / framework / audioStreamInpProc.h
2 /*
3 Copyright (c) 2016, Texas Instruments Incorporated - http://www.ti.com/
4 All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the
16 * distribution.
17 *
18 * Neither the name of Texas Instruments Incorporated nor the names of
19 * its contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 */
36 /*
37 * ======== audioStreamInpProc.h ========
38 */
40 #ifndef _ASIP_H_
41 #define _ASIP_H_
43 #include <xdc/std.h>
45 #include "audioStreamProc_params.h"
46 #include "audioStreamProc_patchs.h"
47 #include "audioStreamProc_config.h"
48 #include "audioStreamProc_master.h"
50 // Global debug counter */
51 extern Uint32 gTaskAsipCnt; // debug counter for ASP task
53 struct PAF_ASIT_Params;
54 struct PAF_ASIT_Patchs;
55 struct PAF_ASIT_Config;
57 // Audio Stream Input Task (ASIT) parameters, functions
58 typedef struct PAF_ASIT_Fxns {
59 Int (*initPhase[8]) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *);
60 //Int (*initFrame0) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, Int);
61 //Int (*initFrame1) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, Int, Int);
62 Int (*passProcessing) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, Int);
63 //Int (*passProcessingCopy) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *);
64 Int (*autoProcessing) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, Int, ALG_Handle);
65 Int (*decodeProcessing) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, Int);
66 Int (*decodeCommand) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *);
67 //Int (*encodeCommand) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *);
68 Int (*decodeInit) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, Int);
69 Int (*decodeInfo) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, Int, Int);
70 Int (*decodeInfo1) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, Int, Int);
71 Int (*decodeInfo2) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, Int, Int);
72 //Int (*decodeCont) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, ALG_Handle *, Int, Int);
73 Int (*decodeDecode) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, Int, Int, Int);
74 //Int (*decodeStream) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, Int, Int);
75 //Int (*decodeEncode) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, Int, Int);
76 Int (*decodeFinalTest) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, Int, Int);
77 Int (*decodeComplete) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, ALG_Handle *, Int, Int);
78 Int (*selectDevices) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *);
79 Int (*sourceDecode) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, Int);
80 //Int (*startOutput) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *);
81 //Int (*stopOutput) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *);
82 //Int (*setCheckRateX) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, Int);
83 //Int (*streamChainFunction) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, Int, Int, Int);
84 Int (*deviceAllocate) (SIO_Handle *, int, int, int, Ptr);
85 Int (*deviceSelect) (SIO_Handle *, int, int, Ptr);
86 Int (*computeFrameLength) (Int, Int, Int);
87 Int (*updateInputStatus) (SIO_Handle, PAF_InpBufStatus *, PAF_InpBufConfig *);
88 //Int (*copy) (Uns, PAF_InpBufConfig *, Uns, PAF_OutBufConfig *);
90 // For RAM_report
91 Void (*headerPrint)();
92 Int (*allocPrint)(const PAF_ALG_AllocInit *pInit, Int sizeofInit, PAF_IALG_Config *p);
93 Void (*commonPrint)(IALG_MemRec common[], PAF_IALG_Config *p);
94 Void (*bufMemPrint)(Int z, Int size, Int heapId, Int bufType);
95 Void (*memStatusPrint)(HeapMem_Handle hInternalHeap, HeapMem_Handle hInternal1Heap, HeapMem_Handle hExternalHeap, HeapMem_Handle hInternal1HeapShm);
96 } PAF_ASIT_Fxns;
98 // Audio Stream Input Task (ASIT) parameters
99 typedef struct PAF_ASIT_Params {
100 const PAF_ASIT_Fxns *fxns;
101 struct {
102 SmInt master;
103 SmInt inputs;
104 SmInt input1;
105 SmInt inputN;
106 SmInt decodes;
107 SmInt decode1;
108 SmInt decodeN;
109 SmInt streams;
110 SmInt stream1; /* unused */
111 SmInt streamN; /* unused */
112 SmInt encodes;
113 SmInt encode1;
114 SmInt encodeN;
115 SmInt outputs;
116 SmInt output1;
117 SmInt outputN;
118 } zone;
119 const SmInt *inputsFromDecodes;
120 const SmInt *outputsFromEncodes;
121 struct {
122 int *pHeapIdIntern; //int *pIntern;
123 int *pHeapIdExtern; //int *pExtern;
124 int *pHeapIdInpbuf; //int *pInpbuf;
125 int *pHeapIdOutbuf; //int *pOutbuf;
126 int *pHeapIdFrmbuf; //int *pFrmbuf;
127 int *pHeapIdIntern1; //int *pIntern1;
128 int clear;
129 } heap;
130 struct {
131 const IALG_MemSpace *space;
132 } common;
133 const LgInt *z_rx_bufsiz;
134 const LgInt *z_tx_bufsiz;
135 const SmInt *z_numchan;
136 MdInt framelength;
137 const PAF_AudioFunctions *pAudioFrameFunctions;
138 const struct PAF_ASP_ChainFxns *pChainFxns;
139 const PAF_InpBufStatus *pInpBufStatus;
140 const PAF_DecodeStatus * const *z_pDecodeStatus;
141 const PAF_OutBufStatus *pOutBufStatus;
142 const PAF_EncodeStatus * const *z_pEncodeStatus;
143 const PAF_VolumeStatus *pVolumeStatus;
144 const PAF_ASP_AlgKey *pDecAlgKey;
145 const PAF_ASP_AlgKey *pEncAlgKey;
146 const PAF_ASP_SioMap *pDecSioMap;
147 const SmInt *streamsFromDecodes;
148 const SmInt *streamsFromEncodes;
149 const MdInt maxFramelength;
150 const SmInt *streamOrder;
151 const PAF_ASP_LinkInit * const (*i_inpLinkInit);
152 const PAF_ASP_LinkInit * const (*i_outLinkInit);
153 const PAF_ASP_outNumBufMap * const (*poutNumBufMap);
154 const PAF_MetadataBufStatus *pMetadataBufStatus;
155 const PAF_AudioFrameBufStatus *pAudioFrameBufStatus;
156 } PAF_ASIT_Params;
158 // Audio Stream Input Task (ASIT) patchs
159 typedef struct PAF_ASIT_Patchs {
160 const PAF_SIO_ParamsN * devinp;
161 //const PAF_SIO_ParamsN * devout;
162 //const PAF_ASP_LinkInit * const (*i_decLinkInit);
163 //const PAF_ASP_LinkInit * const (*i_aspLinkInit)[GEARS];
164 //const PAF_ASP_LinkInit * const (*i_encLinkInit);
165 } PAF_ASIT_Patchs;
167 // Audio Stream Input Task (ASIT) configuration
168 typedef struct PAF_ASIT_Config {
169 ACP_Handle acp;
170 PAF_ASPM_Config *pAspmCfg; // ASIT/ASOT shared configuration
171 PAF_AST_Config *pAstCfg; // ASIT/ASOT/ASDT shared configuration
172 } PAF_ASIT_Config;
175 // Purpose: Audio Stream Input Task Function for initialization of data pointers
176 // by allocation of memory.
177 Int
178 PAF_ASIT_initPhaseMalloc(
179 const PAF_ASIT_Params *pP,
180 const PAF_ASIT_Patchs *pQ,
181 PAF_ASIT_Config *pC
182 );
184 // Purpose: Audio Stream Input Task Function for initialization of data values
185 // from parameters.
186 Int
187 PAF_ASIT_initPhaseConfig(
188 const PAF_ASIT_Params *pP,
189 const PAF_ASIT_Patchs *pQ,
190 PAF_ASIT_Config *pC
191 );
193 // Purpose: Audio Stream Input Task Function for initialization of ACP by
194 // instantiation of the algorithm.
195 Int
196 PAF_ASIT_initPhaseAcpAlg(
197 const PAF_ASIT_Params *pP,
198 const PAF_ASIT_Patchs *pQ,
199 PAF_ASIT_Config *pC
200 );
202 // (***) FL: re-visit this, ASIT/ASOT currently consider common memory independently.
203 // Should simultaneously consider all algs in ASIT/ASOT.
204 // Purpose: Audio Stream Input Task Function for allocation of common memory.
205 Int
206 PAF_ASIT_initPhaseCommon(
207 const PAF_ASIT_Params *pP,
208 const PAF_ASIT_Patchs *pQ,
209 PAF_ASIT_Config *pC
210 );
212 // Purpose: Audio Stream Input Task Function for initialization of ASP algorithms.
213 Int
214 PAF_ASIT_initPhaseAspAlg(
215 const PAF_ASIT_Params *pP,
216 const PAF_ASIT_Patchs *pQ,
217 PAF_ASIT_Config *pC
218 );
220 // Purpose: Audio Stream Input Task Function for initialization of data values
221 // from parameters for Algorithm Keys.
222 Int
223 PAF_ASIT_initPhaseAlgKey(
224 const PAF_ASIT_Params *pP,
225 const PAF_ASIT_Patchs *pQ,
226 PAF_ASIT_Config *pC
227 );
229 // Purpose: Audio Stream Input Task Function for initialization of Decoder Output Circular Buffer.
230 Int
231 PAF_ASIT_initPhaseDecOpCircBuf(
232 const PAF_ASIT_Params *pP,
233 const PAF_ASIT_Patchs *pQ,
234 PAF_ASIT_Config *pC
235 );
237 // Purpose: Audio Stream Input Task Function for initialization of Input Devices.
238 Int
239 PAF_ASIT_initPhaseDevice(
240 const PAF_ASIT_Params *pP,
241 const PAF_ASIT_Patchs *pQ,
242 PAF_ASIT_Config *pC
243 );
245 #if 0
246 // Purpose: Audio Stream Task Function for initialization or reinitiali-
247 // zation of the Audio Frame(s) by loading of data values of a
248 // time-varying nature.
249 Int
250 PAF_AST_initFrame1(
251 const PAF_ASIT_Params *pP,
252 const PAF_ASIT_Patchs *pQ,
253 PAF_AST_Config *pC,
254 Int z,
255 Int apply
256 );
257 #endif
259 // Purpose: Audio Stream Task Function for processing audio data to
260 // determine the input type without output.
261 Int
262 PAF_ASIT_autoProcessing(
263 const PAF_ASIT_Params *pP,
264 const PAF_ASIT_Patchs *pQ,
265 PAF_ASIT_Config *pC,
266 Int inputTypeSelect,
267 ALG_Handle pcmAlgMaster);
269 // Purpose: Audio Stream Input Task Function for processing audio data.
270 //
271 Int
272 PAF_ASIT_decodeProcessing(
273 const PAF_ASIT_Params *pP,
274 const PAF_ASIT_Patchs *pQ,
275 PAF_ASIT_Config *pC,
276 Int sourceSelect
277 );
279 // Purpose: Decoding Function for processing Decode Commands.
280 Int
281 PAF_ASIT_decodeCommand(
282 const PAF_ASIT_Params *pP,
283 const PAF_ASIT_Patchs *pQ,
284 PAF_ASIT_Config *pC
285 );
287 // Purpose: Decoding Function for reinitializing the decoding process.
288 Int
289 PAF_ASIT_decodeInit(
290 const PAF_ASIT_Params *pP,
291 const PAF_ASIT_Patchs *pQ,
292 PAF_ASIT_Config *pC,
293 Int sourceSelect
294 );
296 // Purpose: Decoding Function for processing information in a manner that
297 // is common for both initial and subsequent frames of input data.
298 Int
299 PAF_ASIT_decodeInfo(
300 const PAF_ASIT_Params *pP,
301 const PAF_ASIT_Patchs *pQ,
302 PAF_ASIT_Config *pC,
303 Int frame,
304 Int block
305 );
307 // Purpose: Decoding Function for processing information in a manner that
308 // is unique to initial frames of input data.
309 Int
310 PAF_ASIT_decodeInfo1(
311 const PAF_ASIT_Params *pP,
312 const PAF_ASIT_Patchs *pQ,
313 PAF_ASIT_Config *pC,
314 Int frame,
315 Int block
316 );
318 // Purpose: Decoding Function for processing information in a manner that
319 // is unique to frames of input data other than the initial one.
320 Int
321 PAF_ASIT_decodeInfo2(
322 const PAF_ASIT_Params *pP,
323 const PAF_ASIT_Patchs *pQ,
324 PAF_ASIT_Config *pC,
325 Int frame,
326 Int block
327 );
329 // Purpose: Decoding Function for processing that occurs subsequent to
330 // information processing but antecedent to timing processing
331 // for frames of input data other than the initial one.
332 Int
333 PAF_AST_decodeCont(
334 const PAF_ASIT_Params *pP,
335 const PAF_ASIT_Patchs *pQ,
336 PAF_ASIT_Config *pC,
337 ALG_Handle decAlg[],
338 Int frame,
339 Int block
340 );
342 // Purpose: Decoding Function for processing of input data by the
343 // Decode Algorithm.
344 Int
345 PAF_ASIT_decodeDecode(
346 const PAF_ASIT_Params *pP,
347 const PAF_ASIT_Patchs *pQ,
348 PAF_ASIT_Config *pC,
349 Int sourceSelect,
350 Int frame,
351 Int block
352 );
354 // Purpose: Decoding Function for determining whether processing of the
355 // current frame is complete.
356 Int
357 PAF_ASIT_decodeFinalTest(
358 const PAF_ASIT_Params *pP,
359 const PAF_ASIT_Patchs *pQ,
360 PAF_ASIT_Config *pC,
361 Int frame,
362 Int block
363 );
365 // Purpose: Decoding Function for terminating the decoding process.
366 Int
367 PAF_ASIT_decodeComplete(
368 const PAF_ASIT_Params *pP,
369 const PAF_ASIT_Patchs *pQ,
370 PAF_ASIT_Config *pC,
371 ALG_Handle decAlg[],
372 Int frame,
373 Int block
374 );
376 // Purpose: Audio Stream Input Task Function for selecting the devices used
377 // for input.
378 Int
379 PAF_ASIT_selectDevices(
380 const PAF_ASIT_Params *pP,
381 const PAF_ASIT_Patchs *pQ,
382 PAF_ASIT_Config *pC
383 );
385 // Purpose: Audio Stream Input Task Function for selecting the sources used
386 // for decoding of input to output.
387 Int
388 PAF_ASIT_sourceDecode(
389 const PAF_ASIT_Params *pP,
390 const PAF_ASIT_Patchs *pQ,
391 PAF_ASIT_Config *pC,
392 Int x
393 );
395 // Purpose: Decoding Function for terminating output.
396 Int
397 PAF_AST_stopOutput(
398 const PAF_ASIT_Params *pP,
399 const PAF_ASIT_Patchs *pQ,
400 PAF_ASIT_Config *pC
401 );
403 // Purpose: Common Function for processing algorithm chains.
404 Int
405 PAF_AST_streamChainFunction(
406 const PAF_ASIT_Params *pP,
407 const PAF_ASIT_Patchs *pQ,
408 PAF_ASIT_Config *pC,
409 Int iChainFrameFxns,
410 Int abortOnError,
411 Int logArg
412 );
415 #endif /* _ASIP_H_ */