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