Fix metadata buffer size in ARM/DSP params
[processor-sdk/performance-audio-sr.git] / processor_audio_sdk_1_00_00_00 / pasdk / test_arm / framework / itopo / params.c
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 // PAF_DEVICE_VERSION Symbol Definitions
39 #define PAF_DEVICE_VERSION (PAF_DEVICE & 0xffff)
41 #include <xdc/cfg/global.h>
42 //#include <ti/procsdk_audio/procsdk_audio_typ.h>
43 #include <procsdk_audio_typ.h>
45 #include "paftyp.h"
46 #include <stdasp.h>
47 #include <pafsio_ialg.h>
49 #include "paf_heapMgr.h"
51 #include "asp1.h"
52 #include "audioStreamProc_params.h"
53 #include "audioStreamDecodeProc.h"
55 //
56 // Framework Declarations
57 //
59 //#define PAF_AST_params_fxnsPA PAF_AST_params_fxnsPA17
61 //
62 // Audio Data Representation Definitions
63 //
64 //   External declarations to patched IROM provide standard functionality.
65 //
67 #if 1
68 // FL: extern this, making it look like shared information between ARM/DSP.
69 // FL: Note could just define the same thing in separate file for ARM application (i.e. add "Slave" at end of identifier).
70 /* audio frame "width" in channels */
71 const SmInt PAF_AST_params_numchan[1] =
72 {
73     32,
74 };
75 #else
76 extern const SmInt PAF_AST_params_numchan[];
77 #endif
79 ///
80 // Audio Stream Processing Function Table Definition
81 //
83 const PAF_AudioFunctions PAF_ASDT_params_audioFrameFunctions =
84 {
85     &PAF_ASP_dB2ToLinear,
86     &PAF_ASP_channelMask,
87     &PAF_ASP_programFormat,
88     &PAF_ASP_sampleRateHz,
89     &PAF_ASP_delay,
90 };
92 //
93 // Source Select Array Declarations -- algorithm keys & sio map
94 //
95 //   External declarations to patched IROM provide standard functionality.
96 //
98 #if 1
99 // FL: extern this, making it look like shared information between ARM/DSP.
100 // FL: Note could just define the same thing in separate file for ARM application (i.e. add "Slave" at end of identifier).
101 const PAF_ASP_AlgKey PAF_ASP_params_decAlgKey =
103     PAF_SOURCE_N,                                           // length
104     /* Relies on the fact that ACP_SERIES_* != 0 here */
105     0,                                                      // PAF_SOURCE_UNKNOWN
106     0,                                                      // PAF_SOURCE_NONE
107     0,                                                      // PAF_SOURCE_PASS
108     PAF_ASP_ALPHACODE (STD, SNG),                           // PAF_SOURCE_SNG
109     0,                                                      // PAF_SOURCE_AUTO
110     0,                                                      // PAF_SOURCE_BITSTREAM
111     PAF_ASP_ALPHACODE (STD, DTSHD),                         // PAF_SOURCE_DTSALL
112     PAF_ASP_ALPHACODE (STD, PCM),                           // PAF_SOURCE_PCMAUTO
113     PAF_ASP_ALPHACODE (STD, PCM),                           // PAF_SOURCE_PCM
114     PAF_ASP_ALPHACODE (STD, PCN),                           // PAF_SOURCE_PC8 /* unused */
115     PAF_ASP_ALPHACODE (STD, DDP),                           // PAF_SOURCE_AC3
116     PAF_ASP_ALPHACODE (STD, DTSHD),                         // PAF_SOURCE_DTS
117     PAF_ASP_ALPHACODE (STD, AAC),                           // PAF_SOURCE_AAC
118     PAF_ASP_ALPHACODE (STD, MPG),                           // PAF_SOURCE_MPEG /* unused */
119     PAF_ASP_ALPHACODE (STD, DTSHD),                         // PAF_SOURCE_DTS12
120     PAF_ASP_ALPHACODE (STD, DTSHD),                         // PAF_SOURCE_DTS13
121     PAF_ASP_ALPHACODE (STD, DTSHD),                         // PAF_SOURCE_DTS14
122     PAF_ASP_ALPHACODE (STD, DTSHD),                         // PAF_SOURCE_DTS16
123     0,                                                      // PAF_SOURCE_WMA9PRO
124     0,                                                      // PAF_SOURCE_MP3
125     PAF_ASP_ALPHACODE (STD, DSD),                           // PAF_SOURCE_DSD1
126     PAF_ASP_ALPHACODE (STD, DSD),                           // PAF_SOURCE_DSD2
127     PAF_ASP_ALPHACODE (STD, DSD),                           // PAF_SOURCE_DSD3
128     PAF_ASP_ALPHACODE (STD, DDP),                           // PAF_SOURCE_DDP
129     PAF_ASP_ALPHACODE (STD, DTSHD),                         // PAF_SOURCE_DTSHD
130     PAF_ASP_ALPHACODE (STD, THD),                           // PAF_SOURCE_THD
131     PAF_ASP_ALPHACODE (STD, DXP),                           // PAF_SOURCE_DXP
132 };
133 #else
134 extern const PAF_ASP_AlgKey PAF_ASP_params_decAlgKey;
135 #endif
137 #if 1
138 // FL: This MUST be shared between ARM/DSP.
139 // FL: extern this, making it look like shared information between ARM/DSP.
140 //
141 // Mapping Declarations -- from *coders to *puts
142 //
143 //   External declarations to patched IROM provide standard functionality.
144 //
145 const SmInt PAF_AST_streamsFromDecodes_std[DECODEN_MAX] =
147     0, 1, 2,
148 };
149 #else
150 extern const SmInt PAF_AST_streamsFromDecodes_std[DECODEN_MAX];
151 #endif
153 const SmInt PAF_AST_inputsFromDecodes_std[DECODEN_MAX] =
155     0, 1, 2,
156 };
158 //
159 // Audio Framework Initialization Function Table Declarations
160 //
161 //   External declarations to patched IROM provide standard functionality.
162 //
164 extern const PAF_ASDT_Fxns PAF_ASDT_params_fxns;
166 #if 1
167 // FL: This MUST be shared between ARM/DSP.
168 // FL: extern this, making it look like shared information between ARM/DSP.
169 const PAF_DecodeStatus PAF_AST_params_decodeStatus_primary =
171     sizeof (PAF_DecodeStatus),                              // size
172     1,                                                      // mode
173     0,                                                      // unused1
174     0,                                                      // command.action
175     0,                                                      // command.result
176     PAF_SAMPLERATE_UNKNOWN,                                 // sampleRate
177     PAF_SOURCE_NONE,                                        // sourceSelect
178     PAF_SOURCE_UNKNOWN,                                     // sourceProgram
179     PAF_SOURCE_UNKNOWN,                                     // sourceDecode
180     PAF_SOURCE_DUAL_STEREO,                                 // sourceDual
181     4,                                                      // sourceKaraoke: both
182     0,                                                      // aspGearControl: unused
183     0,                                                      // aspGearStatus: unused
184     0, 0, 0, 0,                                                // Unused
185     0, 0, 0, 0,                                                // Unused
186     0, 0, 0, 0,                                                // Unused
187     0, 0, 0, 0,                                                // Unused
188     0, 0, 0, 0,                                                // Unused
189     0,                                                      // frameCount
190     0x40,                                                   // karaoka: Vocal 1 Level
191     0x40,                                                   // karaoka: Vocal 1 Pan
192     0x40,                                                   // karaoka: Vocal 2 Level
193     0xc0,                                                   // karaoka: Vocal 2 Pan
194     0x40,                                                   // karaoka: Melody Level
195     0x00,                                                   // karaoka: Melody Pan
196     0,                                                      // decBypass
197     0,                                                      // unused
198     0,                                                         // frameLength: reset later
199     1,                                                      // bufferRatio: unity
200     PAF_IEC_PREEMPHASIS_UNKNOWN,                            // emphasis
201     0,                                                        // bufferDrift
202     0, 0,
203     PAF_CC_SAT_SURROUND4, PAF_CC_SUB_ONE, PAF_CC_AUX_SURROUND4_UNKNOWN, 0, 0, 0, 0, 0,    
204     // channelConfigurationRequest.full
205     PAF_CC_SAT_UNKNOWN, PAF_CC_SUB_ZERO, 0, 0, 0, 0, 0, 0,    
206     // channelConfigurationProgram.full
207     PAF_CC_SAT_UNKNOWN, PAF_CC_SUB_ZERO, 0, 0, 0, 0, 0, 0,    
208     // channelConfigurationDecode.full
209     PAF_CC_SAT_UNKNOWN, PAF_CC_SUB_ZERO, 0, 0, 0, 0, 0, 0,    
210     // channelConfigurationDownmix.full
211     PAF_CC_SAT_UNKNOWN, PAF_CC_SUB_ZERO, 0, 0, 0, 0, 0, 0,    
212     // channelConfigurationOverride.full 
213     -3,                                                     // channelMap.from[0]
214     -3,                                                     // channelMap.from[1]
215     -3,                                                     // channelMap.from[2]
216     -3,                                                     // channelMap.from[3]
217     -3,                                                     // channelMap.from[4]
218     -3,                                                     // channelMap.from[5]
219     -3,                                                     // channelMap.from[6]
220     -3,                                                     // channelMap.from[7]
221     -3,                                                     // channelMap.from[8]
222     -3,                                                     // channelMap.from[9]
223     -3,                                                     // channelMap.from[10]
224     -3,                                                     // channelMap.from[11]
225     -3,                                                     // channelMap.from[12]
226     -3,                                                     // channelMap.from[13]
227     -3,                                                     // channelMap.from[14]
228     -3,                                                     // channelMap.from[15]
229     -3,                                                     // channelMap.from[16]
230     -3,                                                     // channelMap.from[17]
231     -3,                                                     // channelMap.from[18]
232     -3,                                                     // channelMap.from[19]
233     -3,                                                     // channelMap.from[20]
234     -3,                                                     // channelMap.from[21]
235     -3,                                                     // channelMap.from[22]
236     -3,                                                     // channelMap.from[23]
237     -3,                                                     // channelMap.from[24]
238     -3,                                                     // channelMap.from[25]
239     -3,                                                     // channelMap.from[26]
240     -3,                                                     // channelMap.from[27]
241     -3,                                                     // channelMap.from[28]
242     -3,                                                     // channelMap.from[29]
243     -3,                                                     // channelMap.from[30]
244     -3,                                                     // channelMap.from[31]
245     -3,                                                     // channelMap.to[0]
246     -3,                                                     // channelMap.to[1]
247     -3,                                                     // channelMap.to[2]
248     -3,                                                     // channelMap.to[3]
249     -3,                                                     // channelMap.to[4]
250     -3,                                                     // channelMap.to[5]
251     -3,                                                     // channelMap.to[6]
252     -3,                                                     // channelMap.to[7]
253     -3,                                                     // channelMap.to[8]
254     -3,                                                     // channelMap.to[9]
255     -3,                                                     // channelMap.to[10]
256     -3,                                                     // channelMap.to[11]
257     -3,                                                     // channelMap.to[12]
258     -3,                                                     // channelMap.to[13]
259     -3,                                                     // channelMap.to[14]
260     -3,                                                     // channelMap.to[15]
261     -3,                                                     // channelMap.to[16]
262     -3,                                                     // channelMap.to[17]
263     -3,                                                     // channelMap.to[18]
264     -3,                                                     // channelMap.to[19]
265     -3,                                                     // channelMap.to[20]
266     -3,                                                     // channelMap.to[21]
267     -3,                                                     // channelMap.to[22]
268     -3,                                                     // channelMap.to[23]
269     -3,                                                     // channelMap.to[24]
270     -3,                                                     // channelMap.to[25]
271     -3,                                                     // channelMap.to[26]
272     -3,                                                     // channelMap.to[27]
273     -3,                                                     // channelMap.to[28]
274     -3,                                                     // channelMap.to[29]
275     -3,                                                     // channelMap.to[30]
276     -3,                                                     // channelMap.to[31]
277     0,                                                      // programFormat.mask
278     0,                                                      // programFormat.form
279    
280 };
281 #else
282 //extern const PAF_DecodeStatus PAF_AST_params_decodeStatus_primary;
283 #endif
285 #if 1
286 // FL: extern this, making it look like shared information between ARM/DSP.
287 // FL: Note could just define the same thing in separate file for ARM application (i.e. add "Slave" at end of identifier).
288 /* audio frame "width" in channels */
289 const PAF_DecodeStatus *const PAF_ASDT_params_decodeStatus[] =
291     &PAF_AST_params_decodeStatus_primary,
292 };
293 #else   
294 //extern const PAF_DecodeStatus *const PAF_AST_params_decodeStatus[];
295 #endif // FL: #if 0
297 //
298 // Common Space Parameter Declarations and Definitions
299 //
300 //   Local definitions in RAM provide non-standard functionality.
301 //   The NULL pointer provides standard functionality.
302 //
304 /* baseline definition - NULL equivalent */
305 /* May be used for overrides of IALG_MemSpace */
307 static const IALG_MemSpace params_memspace_PAi_Slave[] = {
308     PAF_IALG_NONE,                                          // Scratch
309     PAF_IALG_NONE,                                          // Persistant
310     PAF_IALG_NONE,                                          // Write once
311     PAF_IALG_NONE,                                          // Common 1
312     PAF_IALG_NONE,                                          // Common 2
313     PAF_IALG_NONE,                                          // Common 3
314     PAF_IALG_NONE,                                          // Common 4
315     PAF_IALG_NONE,                                          // Common 5
316     PAF_IALG_NONE,                                          // Common 6
317     PAF_IALG_NONE,                                          // Common 7
318     IALG_EXTERNAL,                                          // Common 8
319     PAF_IALG_NONE,                                          // Common 9
320     PAF_IALG_NONE,                                          // Common 10
321     PAF_IALG_NONE,                                          // Common 11
322     PAF_IALG_NONE,                                          // Common 12
323     PAF_IALG_NONE,                                          // Common 13
324     PAF_IALG_NONE,                                          // Common 14
325     PAF_IALG_NONE,                                          // Common 15
326 };
328 //
329 // Heap Declarations
330 //
332 //#include <pafhjt.h>
334 //extern int IRAM;
335 //extern int SDRAM;
336 //extern int L3RAM;
338 // .............................................................................
339 const PAF_MetadataBufStatus PAF_ASDT_params_MetadataBufStatus[] =
341     PAF_MAX_PRIVATE_MD_SZ,  // bufSize
342     PAF_MAX_NUM_PRIVATE_MD, // NumBuf
343     128,                    // alignment
344     &gPafHeapIdExt //&SDRAM // &IRAM,        // pSpace
345 };
347 #if 0 // FL: maybe needed on ARM if there's an audio frame buffer defined for decode (and possible stream)
348 // .............................................................................
349 //
350 // This structure defines the memory allocation of audio frame buffers (channel buffers). Users can customize this structure based
351 // on their requirement. IALG_SARAM specifies the audio frame buffer is allocated in IRAM and IALG_EXTERNAL
352 // specifies the audio frame buffer is allocated in SDRAM. By allocating few channel buffers in SDRAM, users can save internal memory
353 // but trading performance
354 // This structure defined for PAF_MAXNUMCHAN number of channels. But channel buffers will be allocated  for "PAF_AST_params_numchan"
355 // number of channels only.
356 //
358 const PAF_AudioFrameBufStatus    PAF_AST_params_AudioFrameBufStatus[PAF_MAXNUMCHAN] =
360     IALG_SARAM, // 0
361     IALG_SARAM,
362     IALG_SARAM,
363     IALG_SARAM,
364     IALG_SARAM,
365     IALG_SARAM,
366     IALG_SARAM,
367     IALG_SARAM,
368     IALG_SARAM,
369     IALG_SARAM,
370     IALG_SARAM,
371     IALG_SARAM,
372     IALG_SARAM,
373     IALG_SARAM,
374     IALG_SARAM,
375     IALG_SARAM,
376     IALG_SARAM, // 16
377     IALG_SARAM,
378     IALG_SARAM,
379     IALG_SARAM,
380     IALG_SARAM,
381     IALG_SARAM,
382     IALG_SARAM,
383     IALG_SARAM,
384     IALG_SARAM,
385     IALG_SARAM,
386     IALG_SARAM,
387     IALG_SARAM,
388     IALG_SARAM,
389     IALG_SARAM,
390     IALG_SARAM,
391     IALG_SARAM, // 31
392     //IALG_EXTERNAL, // 16
393     //IALG_EXTERNAL,
394     //IALG_EXTERNAL,
395     //IALG_EXTERNAL,
396     //IALG_EXTERNAL,
397     //IALG_EXTERNAL,
398     //IALG_EXTERNAL,
399     //IALG_EXTERNAL,
400     //IALG_EXTERNAL,
401     //IALG_EXTERNAL,
402     //IALG_EXTERNAL,
403     //IALG_EXTERNAL,
404     //IALG_EXTERNAL,
405     //IALG_EXTERNAL,
406     //IALG_EXTERNAL,
407     //IALG_EXTERNAL // 31
408 };
409 #endif // FL: #if 0
411 // .............................................................................
412 //
413 // Audio Stream Parameter Definitions
414 //
415 //   Global definition in RAM provides standard & non-standard functionality.
416 //
418 const PAF_ASDT_Params asdp_params_PAi =
420     &PAF_ASDT_params_fxns,                                     // fxns
421     {                                                          // zone
422         0,                                                     // master
423         1,                                                     // decodes
424         0,                                                     // decode1
425         1,                                                     // decodeN
426         1,                                                     // streams
427     },
428     PAF_AST_inputsFromDecodes_std,
429     {                                                       // heap
430         &gPafHeapIdInt1,    //&IRAM                         // pIntern
431         &gPafHeapIdExt,     //&SDRAM,                       // pExtern
432         &gPafHeapIdInt1,    //&IRAM,                        // pFrmbuf
433         &gPafHeapIdInt1,    //&L3RAM,                       // pIntern1
434         1,                                                  // clear
435     },
436     {                                                       // common
437         params_memspace_PAi_Slave,                          // space
438     },
439     PAF_AST_params_numchan,                                 // z_numchan
440     256,                                                    // framelength
441     &PAF_ASDT_params_audioFrameFunctions,                   // pAudioFrameFunctions
442     &PAF_ASP_chainFxns,                                     // pChainFxns
443     PAF_ASDT_params_decodeStatus,                           // z_pDecodeStatus
444     &PAF_ASP_params_decAlgKey,                              // pDecAlgKey
445     PAF_AST_streamsFromDecodes_std,                         // streamsFromDecodes
446     1536,                                                   // maxFramelength
447     PAF_ASDT_params_MetadataBufStatus,                      //metadata buffer status
448     NULL //PAF_AST_params_AudioFrameBufStatus                      //Audio frame buffer status
449 };
451 // EOF