ebee5d1eae3a79429a082f041bd1906f75861f1e
[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"
49 // Global debug counter */
50 extern Uint32 gTaskAsipCnt; // debug counter for ASP task
52 struct PAF_ASIT_Params;
53 struct PAF_ASIT_Patchs;
54 struct PAF_ASIT_Config;
56 // Audio Stream Input Task (ASIT) parameters, functions
57 typedef struct PAF_ASIT_Fxns {
58 Int (*initPhase[8]) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *);
59 //Int (*initFrame0) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, Int);
60 //Int (*initFrame1) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, Int, Int);
61 Int (*passProcessing) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, Int);
62 //Int (*passProcessingCopy) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *);
63 Int (*autoProcessing) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, Int, ALG_Handle);
64 Int (*decodeProcessing) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, Int);
65 Int (*decodeCommand) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *);
66 //Int (*encodeCommand) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *);
67 Int (*decodeInit) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, Int);
68 Int (*decodeInfo) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, Int, Int);
69 Int (*decodeInfo1) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, Int, Int);
70 Int (*decodeInfo2) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, Int, Int);
71 //Int (*decodeCont) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, ALG_Handle *, Int, Int);
72 Int (*decodeDecode) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, Int, Int, Int);
73 //Int (*decodeStream) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, Int, Int);
74 //Int (*decodeEncode) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, Int, Int);
75 Int (*decodeFinalTest) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, Int, Int);
76 Int (*decodeComplete) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, ALG_Handle *, Int, Int);
77 Int (*selectDevices) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *);
78 Int (*sourceDecode) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, Int);
79 //Int (*startOutput) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *);
80 //Int (*stopOutput) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *);
81 //Int (*setCheckRateX) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, Int);
82 //Int (*streamChainFunction) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, Int, Int, Int);
83 Int (*deviceAllocate) (SIO_Handle *, int, int, int, Ptr);
84 Int (*deviceSelect) (SIO_Handle *, int, int, Ptr);
85 Int (*computeFrameLength) (Int, Int, Int);
86 Int (*updateInputStatus) (SIO_Handle, PAF_InpBufStatus *, PAF_InpBufConfig *);
87 //Int (*copy) (Uns, PAF_InpBufConfig *, Uns, PAF_OutBufConfig *);
89 // For RAM_report
90 Void (*headerPrint)();
91 Int (*allocPrint)(const PAF_ALG_AllocInit *pInit, Int sizeofInit, PAF_IALG_Config *p);
92 Void (*commonPrint)(IALG_MemRec common[], PAF_IALG_Config *p);
93 Void (*bufMemPrint)(Int z, Int size, Int heapId, Int bufType);
94 Void (*memStatusPrint)(HeapMem_Handle hInternalHeap, HeapMem_Handle hInternal1Heap, HeapMem_Handle hExternalHeap, HeapMem_Handle hInternal1HeapShm);
95 } PAF_ASIT_Fxns;
97 // Audio Stream Input Task (ASIT) parameters
98 typedef struct PAF_ASIT_Params {
99 const PAF_ASIT_Fxns *fxns;
100 struct {
101 SmInt master;
102 SmInt inputs;
103 SmInt input1;
104 SmInt inputN;
105 SmInt decodes;
106 SmInt decode1;
107 SmInt decodeN;
108 SmInt streams;
109 SmInt stream1; /* unused */
110 SmInt streamN; /* unused */
111 SmInt encodes;
112 SmInt encode1;
113 SmInt encodeN;
114 SmInt outputs;
115 SmInt output1;
116 SmInt outputN;
117 } zone;
118 const SmInt *inputsFromDecodes;
119 const SmInt *outputsFromEncodes;
120 struct {
121 int *pHeapIdIntern; //int *pIntern;
122 int *pHeapIdExtern; //int *pExtern;
123 int *pHeapIdInpbuf; //int *pInpbuf;
124 int *pHeapIdOutbuf; //int *pOutbuf;
125 int *pHeapIdFrmbuf; //int *pFrmbuf;
126 int *pHeapIdIntern1; //int *pIntern1;
127 int clear;
128 } heap;
129 struct {
130 const IALG_MemSpace *space;
131 } common;
132 const LgInt *z_rx_bufsiz;
133 const LgInt *z_tx_bufsiz;
134 const SmInt *z_numchan;
135 MdInt framelength;
136 const PAF_AudioFunctions *pAudioFrameFunctions;
137 const struct PAF_ASP_ChainFxns *pChainFxns;
138 const PAF_InpBufStatus *pInpBufStatus;
139 const PAF_DecodeStatus * const *z_pDecodeStatus;
140 const PAF_OutBufStatus *pOutBufStatus;
141 const PAF_EncodeStatus * const *z_pEncodeStatus;
142 const PAF_VolumeStatus *pVolumeStatus;
143 const PAF_ASP_AlgKey *pDecAlgKey;
144 const PAF_ASP_AlgKey *pEncAlgKey;
145 const PAF_ASP_SioMap *pDecSioMap;
146 const SmInt *streamsFromDecodes;
147 const SmInt *streamsFromEncodes;
148 const MdInt maxFramelength;
149 const SmInt *streamOrder;
150 const PAF_ASP_LinkInit * const (*i_inpLinkInit);
151 const PAF_ASP_LinkInit * const (*i_outLinkInit);
152 const PAF_ASP_outNumBufMap * const (*poutNumBufMap);
153 const PAF_MetadataBufStatus *pMetadataBufStatus;
154 const PAF_AudioFrameBufStatus *pAudioFrameBufStatus;
155 } PAF_ASIT_Params;
157 // Audio Stream Input Task (ASIT) patchs
158 typedef struct PAF_ASIT_Patchs {
159 const PAF_SIO_ParamsN * devinp;
160 //const PAF_SIO_ParamsN * devout;
161 //const PAF_ASP_LinkInit * const (*i_decLinkInit);
162 //const PAF_ASP_LinkInit * const (*i_aspLinkInit)[GEARS];
163 //const PAF_ASP_LinkInit * const (*i_encLinkInit);
164 } PAF_ASIT_Patchs;
166 // Audio Stream Input Task (ASIT) configuration
167 typedef struct PAF_ASIT_Config {
168 ACP_Handle acp;
169 PAF_AST_Config *pAstCfg; // ASIT/ASOT/ASDT shared configuration
170 } PAF_ASIT_Config;
173 // Purpose: Audio Stream Input Task Function for initialization of data pointers
174 // by allocation of memory.
175 Int
176 PAF_ASIT_initPhaseMalloc(
177 const PAF_ASIT_Params *pP,
178 const PAF_ASIT_Patchs *pQ,
179 PAF_ASIT_Config *pC
180 );
182 // Purpose: Audio Stream Input Task Function for initialization of data values
183 // from parameters.
184 Int
185 PAF_ASIT_initPhaseConfig(
186 const PAF_ASIT_Params *pP,
187 const PAF_ASIT_Patchs *pQ,
188 PAF_ASIT_Config *pC
189 );
191 // Purpose: Audio Stream Input Task Function for initialization of ACP by
192 // instantiation of the algorithm.
193 Int
194 PAF_ASIT_initPhaseAcpAlg(
195 const PAF_ASIT_Params *pP,
196 const PAF_ASIT_Patchs *pQ,
197 PAF_ASIT_Config *pC
198 );
200 // (***) FL: re-visit this, ASIT/ASOT currently consider common memory independently.
201 // Should simultaneously consider all algs in ASIT/ASOT.
202 // Purpose: Audio Stream Input Task Function for allocation of common memory.
203 Int
204 PAF_ASIT_initPhaseCommon(
205 const PAF_ASIT_Params *pP,
206 const PAF_ASIT_Patchs *pQ,
207 PAF_ASIT_Config *pC
208 );
210 // Purpose: Audio Stream Input Task Function for initialization of ASP algorithms.
211 Int
212 PAF_ASIT_initPhaseAspAlg(
213 const PAF_ASIT_Params *pP,
214 const PAF_ASIT_Patchs *pQ,
215 PAF_ASIT_Config *pC
216 );
218 // Purpose: Audio Stream Input Task Function for initialization of data values
219 // from parameters for Algorithm Keys.
220 Int
221 PAF_ASIT_initPhaseAlgKey(
222 const PAF_ASIT_Params *pP,
223 const PAF_ASIT_Patchs *pQ,
224 PAF_ASIT_Config *pC
225 );
227 // Purpose: Audio Stream Input Task Function for initialization of Decoder Output Circular Buffer.
228 Int
229 PAF_ASIT_initPhaseDecOpCircBuf(
230 const PAF_ASIT_Params *pP,
231 const PAF_ASIT_Patchs *pQ,
232 PAF_ASIT_Config *pC
233 );
235 // Purpose: Audio Stream Input Task Function for initialization of Input Devices.
236 Int
237 PAF_ASIT_initPhaseDevice(
238 const PAF_ASIT_Params *pP,
239 const PAF_ASIT_Patchs *pQ,
240 PAF_ASIT_Config *pC
241 );
243 #if 0
244 // Purpose: Audio Stream Task Function for initialization or reinitiali-
245 // zation of the Audio Frame(s) by loading of data values of a
246 // time-varying nature.
247 Int
248 PAF_AST_initFrame1(
249 const PAF_ASIT_Params *pP,
250 const PAF_ASIT_Patchs *pQ,
251 PAF_AST_Config *pC,
252 Int z,
253 Int apply
254 );
255 #endif
257 // Purpose: Audio Stream Task Function for processing audio data to
258 // determine the input type without output.
259 Int
260 PAF_ASIT_autoProcessing(
261 const PAF_ASIT_Params *pP,
262 const PAF_ASIT_Patchs *pQ,
263 PAF_ASIT_Config *pC,
264 Int inputTypeSelect,
265 ALG_Handle pcmAlgMaster);
267 // Purpose: Audio Stream Input Task Function for processing audio data.
268 //
269 Int
270 PAF_ASIT_decodeProcessing(
271 const PAF_ASIT_Params *pP,
272 const PAF_ASIT_Patchs *pQ,
273 PAF_ASIT_Config *pC,
274 Int sourceSelect
275 );
277 // Purpose: Decoding Function for processing Decode Commands.
278 Int
279 PAF_ASIT_decodeCommand(
280 const PAF_ASIT_Params *pP,
281 const PAF_ASIT_Patchs *pQ,
282 PAF_ASIT_Config *pC
283 );
285 // Purpose: Decoding Function for reinitializing the decoding process.
286 Int
287 PAF_ASIT_decodeInit(
288 const PAF_ASIT_Params *pP,
289 const PAF_ASIT_Patchs *pQ,
290 PAF_ASIT_Config *pC,
291 Int sourceSelect
292 );
294 // Purpose: Decoding Function for processing information in a manner that
295 // is common for both initial and subsequent frames of input data.
296 Int
297 PAF_ASIT_decodeInfo(
298 const PAF_ASIT_Params *pP,
299 const PAF_ASIT_Patchs *pQ,
300 PAF_ASIT_Config *pC,
301 Int frame,
302 Int block
303 );
305 // Purpose: Decoding Function for processing information in a manner that
306 // is unique to initial frames of input data.
307 Int
308 PAF_ASIT_decodeInfo1(
309 const PAF_ASIT_Params *pP,
310 const PAF_ASIT_Patchs *pQ,
311 PAF_ASIT_Config *pC,
312 Int frame,
313 Int block
314 );
316 // Purpose: Decoding Function for processing information in a manner that
317 // is unique to frames of input data other than the initial one.
318 Int
319 PAF_ASIT_decodeInfo2(
320 const PAF_ASIT_Params *pP,
321 const PAF_ASIT_Patchs *pQ,
322 PAF_ASIT_Config *pC,
323 Int frame,
324 Int block
325 );
327 // Purpose: Decoding Function for processing that occurs subsequent to
328 // information processing but antecedent to timing processing
329 // for frames of input data other than the initial one.
330 Int
331 PAF_AST_decodeCont(
332 const PAF_ASIT_Params *pP,
333 const PAF_ASIT_Patchs *pQ,
334 PAF_ASIT_Config *pC,
335 ALG_Handle decAlg[],
336 Int frame,
337 Int block
338 );
340 // Purpose: Decoding Function for processing of input data by the
341 // Decode Algorithm.
342 Int
343 PAF_ASIT_decodeDecode(
344 const PAF_ASIT_Params *pP,
345 const PAF_ASIT_Patchs *pQ,
346 PAF_ASIT_Config *pC,
347 Int sourceSelect,
348 Int frame,
349 Int block
350 );
352 // Purpose: Decoding Function for determining whether processing of the
353 // current frame is complete.
354 Int
355 PAF_ASIT_decodeFinalTest(
356 const PAF_ASIT_Params *pP,
357 const PAF_ASIT_Patchs *pQ,
358 PAF_ASIT_Config *pC,
359 Int frame,
360 Int block
361 );
363 // Purpose: Decoding Function for terminating the decoding process.
364 Int
365 PAF_ASIT_decodeComplete(
366 const PAF_ASIT_Params *pP,
367 const PAF_ASIT_Patchs *pQ,
368 PAF_ASIT_Config *pC,
369 ALG_Handle decAlg[],
370 Int frame,
371 Int block
372 );
374 // Purpose: Audio Stream Input Task Function for selecting the devices used
375 // for input.
376 Int
377 PAF_ASIT_selectDevices(
378 const PAF_ASIT_Params *pP,
379 const PAF_ASIT_Patchs *pQ,
380 PAF_ASIT_Config *pC
381 );
383 // Purpose: Audio Stream Input Task Function for selecting the sources used
384 // for decoding of input to output.
385 Int
386 PAF_ASIT_sourceDecode(
387 const PAF_ASIT_Params *pP,
388 const PAF_ASIT_Patchs *pQ,
389 PAF_ASIT_Config *pC,
390 Int x
391 );
393 // Purpose: Decoding Function for terminating output.
394 Int
395 PAF_AST_stopOutput(
396 const PAF_ASIT_Params *pP,
397 const PAF_ASIT_Patchs *pQ,
398 PAF_ASIT_Config *pC
399 );
401 // Purpose: Common Function for processing algorithm chains.
402 Int
403 PAF_AST_streamChainFunction(
404 const PAF_ASIT_Params *pP,
405 const PAF_ASIT_Patchs *pQ,
406 PAF_ASIT_Config *pC,
407 Int iChainFrameFxns,
408 Int abortOnError,
409 Int logArg
410 );
413 #endif /* _ASIP_H_ */