| AAX SDK 2.6.1 Avid Audio Extensions Development Kit

- Welcome
- Manual
- Classes
- Files
- Lists
- Support

- File List
- File Members

Loading...
Searching...
No Matches
AAX_FastInterpolatedTableLookup.hpp
Go to the documentation of this file.
1/*================================================================================================*/
2/*
3 * Copyright 2009-2015, 2023 Avid Technology, Inc.
4 * All rights reserved.
5 *
6 * CONFIDENTIAL: this document contains confidential information of Avid. Do
7 * not disclose to any third party. Use of the information contained in this
8 * document is subject to an Avid SDK license.
9 */
10/*================================================================================================*/
11
12#ifndef AAX_FASTINTERPOLATEDTABLELOOKUP_HPP
13#define AAX_FASTINTERPOLATEDTABLELOOKUP_HPP
14
15#include "AAX_Quantize.h"
16
17//This version requires that the lookup table is padded with one extra location so we
18//can avoid one of the checks to see if ours pointers are out of bounds.
19 template<class TFLOAT, class DFLOAT>
20 inline DFLOAT AAX_FastInterpolatedTableLookup<TFLOAT,DFLOAT>::DoTableLookupExtraFast(const TFLOAT* iTable, DFLOAT iValue) const
21{
22 const TFLOAT aScaledValue=(iValue - mMin)*mTableSizeM1DivMaxMinusMin;
23
24 //Clamp between 0.0 and table size, so we don't go out of the table bounds. One thing that's not obvious is this clamp was written
25 //so that it will return 0.0 if a NaN is given as the table input. This keeps us within bounds even if we're feed garbage.;
26 const TFLOAT aScaledValueLimited = aScaledValue > mTableSizeM1 ? mTableSizeM1 : (aScaledValue > 0.0f ? aScaledValue : 0.0f);
27
28 int aTableIndex=AAX::FastTrunc2Int32(aScaledValueLimited);
29
30 TFLOAT aFracIndex=aScaledValueLimited - TFLOAT(aTableIndex);
31 TFLOAT aFracIndexM1=1.0f-aFracIndex;
32
33 return (DFLOAT)(iTable[aTableIndex]*aFracIndexM1 + iTable[aTableIndex+1]*aFracIndex);
34}
35
36//This version requires that the lookup table is padded with one extra location so we
37//can avoid one of the checks to see if ours pointers are out of bounds.
38 template<class TFLOAT, class DFLOAT>
39 inline void AAX_FastInterpolatedTableLookup<TFLOAT,DFLOAT>::DoTableLookupExtraFastMulti(const TFLOAT* iTable, DFLOAT iValue, DFLOAT* oValues) const
40{
41 TFLOAT aScaledValue=(iValue - mMin)*mTableSizeM1DivMaxMinusMin;
42
43 //Clamp between 0.0 and table size, so we don't go out of the table bounds. One thing that's not obvious is this clamp was written
44 //so that it will return 0.0 if a NaN is given as the table input. This keeps us within bounds even if we're feed garbage.
45 const TFLOAT aScaledValueLimited = aScaledValue > mTableSizeM1 ? mTableSizeM1 : (aScaledValue > 0.0f ? aScaledValue : 0.0f);
46
47 int aTableIndex=AAX::FastTrunc2Int32(aScaledValueLimited);
48
49 TFLOAT aFracIndex=aScaledValueLimited - TFLOAT(aTableIndex);
50 TFLOAT aFracIndexM1=1.0f-aFracIndex;
51
52 aTableIndex=aTableIndex*mNumTables;
53 int aTableIndexPlus1=aTableIndex+mNumTables;
54
55 for(int i=0; i<mNumTables; i++)
56 {
57 oValues[i]=(DFLOAT)(iTable[aTableIndex++]*aFracIndexM1 + iTable[aTableIndexPlus1++]*aFracIndex);
58 }
59}
60
61//Block version of table lookup
62 template<class TFLOAT, class DFLOAT>
63 inline void AAX_FastInterpolatedTableLookup<TFLOAT,DFLOAT>::DoTableLookupExtraFast(const TFLOAT* const iTable, const TFLOAT* const inpBuf, DFLOAT* const outBuf, int blockSize)
64{
65#if defined( _TMS320C6700 )
66 const int r = 16;
67 #pragma MUST_ITERATE(r, , r);
68#endif
69 for (int i = 0; i < blockSize; i++)
70 {
71 outBuf[i] = DoTableLookupExtraFast(iTable, inpBuf[i]);
72 }
73 return;
74}
75
76#endif // AAX_FASTINTERPOLATEDTABLELOOKUP_HPP
AAX_Quantize.h
Quantization utilities.
AAX::FastTrunc2Int32
int32_t FastTrunc2Int32(double iVal)
Float to Int conversion with truncation.
Definition: AAX_Quantize.h:124
AAX_FastInterpolatedTableLookup::DoTableLookupExtraFastMulti
void DoTableLookupExtraFastMulti(const TFLOAT *iTable, DFLOAT iValue, DFLOAT *oValues) const
Definition: AAX_FastInterpolatedTableLookup.hpp:39
AAX_FastInterpolatedTableLookup::DoTableLookupExtraFast
DFLOAT DoTableLookupExtraFast(const TFLOAT *const iTable, DFLOAT iValue) const
Perform an extra fast table lookup :)
Definition: AAX_FastInterpolatedTableLookup.hpp:20