\hypertarget{a00848_source}{}\doxysection{AAX\+\_\+\+Fast\+Interpolated\+Table\+Lookup.\+hpp}
\label{a00848_source}\index{AAX\_FastInterpolatedTableLookup.hpp@{AAX\_FastInterpolatedTableLookup.hpp}}
\mbox{\hyperlink{a00848}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ \textcolor{comment}{/*================================================================================================*/}}
\DoxyCodeLine{00002\ \textcolor{comment}{/*}}
\DoxyCodeLine{00003\ \textcolor{comment}{\ *\ \ Copyright\ 2009-\/2015,\ 2023-\/2024\ Avid\ Technology,\ Inc.}}
\DoxyCodeLine{00004\ \textcolor{comment}{\ *\ \ All\ rights\ reserved.}}
\DoxyCodeLine{00005\ \textcolor{comment}{\ *\ \ }}
\DoxyCodeLine{00006\ \textcolor{comment}{\ *\ \ This\ file\ is\ part\ of\ the\ Avid\ AAX\ SDK.}}
\DoxyCodeLine{00007\ \textcolor{comment}{\ *\ \ }}
\DoxyCodeLine{00008\ \textcolor{comment}{\ *\ \ The\ AAX\ SDK\ is\ subject\ to\ commercial\ or\ open-\/source\ licensing.}}
\DoxyCodeLine{00009\ \textcolor{comment}{\ *\ \ }}
\DoxyCodeLine{00010\ \textcolor{comment}{\ *\ \ By\ using\ the\ AAX\ SDK,\ you\ agree\ to\ the\ terms\ of\ both\ the\ Avid\ AAX\ SDK\ License}}
\DoxyCodeLine{00011\ \textcolor{comment}{\ *\ \ Agreement\ and\ Avid\ Privacy\ Policy.}}
\DoxyCodeLine{00012\ \textcolor{comment}{\ *\ \ }}
\DoxyCodeLine{00013\ \textcolor{comment}{\ *\ \ AAX\ SDK\ License:\ https://developer.avid.com/aax}}
\DoxyCodeLine{00014\ \textcolor{comment}{\ *\ \ Privacy\ Policy:\ https://www.avid.com/legal/privacy-\/policy-\/statement}}
\DoxyCodeLine{00015\ \textcolor{comment}{\ *\ \ }}
\DoxyCodeLine{00016\ \textcolor{comment}{\ *\ \ Or:\ You\ may\ also\ use\ this\ code\ under\ the\ terms\ of\ the\ GPL\ v3\ (see}}
\DoxyCodeLine{00017\ \textcolor{comment}{\ *\ \ www.gnu.org/licenses).}}
\DoxyCodeLine{00018\ \textcolor{comment}{\ *\ \ }}
\DoxyCodeLine{00019\ \textcolor{comment}{\ *\ \ THE\ AAX\ SDK\ IS\ PROVIDED\ "{}AS\ IS"{}\ WITHOUT\ ANY\ WARRANTY,\ AND\ ALL\ WARRANTIES,\ WHETHER}}
\DoxyCodeLine{00020\ \textcolor{comment}{\ *\ \ EXPRESSED\ OR\ IMPLIED,\ INCLUDING\ MERCHANTABILITY\ AND\ FITNESS\ FOR\ PURPOSE,\ ARE}}
\DoxyCodeLine{00021\ \textcolor{comment}{\ *\ \ DISCLAIMED.}}
\DoxyCodeLine{00022\ \textcolor{comment}{\ */}}
\DoxyCodeLine{00023\ \textcolor{comment}{/*================================================================================================*/}}
\DoxyCodeLine{00024\ }
\DoxyCodeLine{00025\ \textcolor{preprocessor}{\#ifndef\ AAX\_FASTINTERPOLATEDTABLELOOKUP\_HPP}}
\DoxyCodeLine{00026\ \textcolor{preprocessor}{\#define\ AAX\_FASTINTERPOLATEDTABLELOOKUP\_HPP}}
\DoxyCodeLine{00027\ }
\DoxyCodeLine{00028\ \textcolor{preprocessor}{\#include\ "{}\mbox{\hyperlink{a00866}{AAX\_Quantize.h}}"{}}}
\DoxyCodeLine{00029\ }
\DoxyCodeLine{00030\ \textcolor{comment}{//This\ version\ requires\ that\ the\ lookup\ table\ is\ padded\ with\ one\ extra\ location\ so\ we\ }}
\DoxyCodeLine{00031\ \textcolor{comment}{//can\ avoid\ one\ of\ the\ checks\ to\ see\ if\ ours\ pointers\ are\ out\ of\ bounds.}}
\DoxyCodeLine{00032\ \textcolor{keyword}{template}<\textcolor{keyword}{class}\ TFLOAT,\ \textcolor{keyword}{class}\ DFLOAT>}
\DoxyCodeLine{00033\ \textcolor{keyword}{inline}\ DFLOAT\ \mbox{\hyperlink{a02470_aaad992e09c837d96ad715092fbefd91d}{AAX\_FastInterpolatedTableLookup<TFLOAT,DFLOAT>::DoTableLookupExtraFast}}(\textcolor{keyword}{const}\ TFLOAT*\ iTable,\ DFLOAT\ iValue)\textcolor{keyword}{\ const}}
\DoxyCodeLine{00034\ \textcolor{keyword}{}\{}
\DoxyCodeLine{00035\ \ \ \ \ \textcolor{keyword}{const}\ TFLOAT\ aScaledValue=(iValue\ -\/\ mMin)*mTableSizeM1DivMaxMinusMin;}
\DoxyCodeLine{00036\ }
\DoxyCodeLine{00037\ \ \ \ \ \textcolor{comment}{//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\ }}
\DoxyCodeLine{00038\ \ \ \ \ \textcolor{comment}{//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.;}}
\DoxyCodeLine{00039\ \ \ \ \ \textcolor{keyword}{const}\ TFLOAT\ aScaledValueLimited\ =\ aScaledValue\ >\ mTableSizeM1\ ?\ mTableSizeM1\ :\ (aScaledValue\ >\ 0.0f\ ?\ aScaledValue\ :\ 0.0f);}
\DoxyCodeLine{00040\ }
\DoxyCodeLine{00041\ \ \ \ \ \textcolor{keywordtype}{int}\ aTableIndex=\mbox{\hyperlink{a00948_ad2b2872b49146cf0859c403fea702a39}{AAX::FastTrunc2Int32}}(aScaledValueLimited);}
\DoxyCodeLine{00042\ }
\DoxyCodeLine{00043\ \ \ \ \ TFLOAT\ aFracIndex=aScaledValueLimited\ -\/\ TFLOAT(aTableIndex);}
\DoxyCodeLine{00044\ \ \ \ \ TFLOAT\ aFracIndexM1=1.0f-\/aFracIndex;}
\DoxyCodeLine{00045\ }
\DoxyCodeLine{00046\ \ \ \ \ \textcolor{keywordflow}{return}\ (DFLOAT)(iTable[aTableIndex]*aFracIndexM1\ +\ iTable[aTableIndex+1]*aFracIndex);}
\DoxyCodeLine{00047\ \}}
\DoxyCodeLine{00048\ }
\DoxyCodeLine{00049\ \textcolor{comment}{//This\ version\ requires\ that\ the\ lookup\ table\ is\ padded\ with\ one\ extra\ location\ so\ we}}
\DoxyCodeLine{00050\ \textcolor{comment}{//can\ avoid\ one\ of\ the\ checks\ to\ see\ if\ ours\ pointers\ are\ out\ of\ bounds.}}
\DoxyCodeLine{00051\ \textcolor{keyword}{template}<\textcolor{keyword}{class}\ TFLOAT,\ \textcolor{keyword}{class}\ DFLOAT>}
\DoxyCodeLine{00052\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{void}\ \mbox{\hyperlink{a02470_a60e89d13066ca0606c8f71cf5313f0e3}{AAX\_FastInterpolatedTableLookup<TFLOAT,DFLOAT>::DoTableLookupExtraFastMulti}}(\textcolor{keyword}{const}\ TFLOAT*\ iTable,\ DFLOAT\ iValue,\ DFLOAT*\ oValues)\textcolor{keyword}{\ const}}
\DoxyCodeLine{00053\ \textcolor{keyword}{}\{}
\DoxyCodeLine{00054\ \ \ \ \ TFLOAT\ aScaledValue=(iValue\ -\/\ mMin)*mTableSizeM1DivMaxMinusMin;}
\DoxyCodeLine{00055\ \ \ \ \ }
\DoxyCodeLine{00056\ \ \ \ \ \textcolor{comment}{//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}}
\DoxyCodeLine{00057\ \ \ \ \ \textcolor{comment}{//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.}}
\DoxyCodeLine{00058\ \ \ \ \ \textcolor{keyword}{const}\ TFLOAT\ aScaledValueLimited\ =\ aScaledValue\ >\ mTableSizeM1\ ?\ mTableSizeM1\ :\ (aScaledValue\ >\ 0.0f\ ?\ aScaledValue\ :\ 0.0f);}
\DoxyCodeLine{00059\ \ \ \ \ }
\DoxyCodeLine{00060\ \ \ \ \ \textcolor{keywordtype}{int}\ aTableIndex=\mbox{\hyperlink{a00948_ad2b2872b49146cf0859c403fea702a39}{AAX::FastTrunc2Int32}}(aScaledValueLimited);}
\DoxyCodeLine{00061\ \ \ \ \ }
\DoxyCodeLine{00062\ \ \ \ \ TFLOAT\ aFracIndex=aScaledValueLimited\ -\/\ TFLOAT(aTableIndex);}
\DoxyCodeLine{00063\ \ \ \ \ TFLOAT\ aFracIndexM1=1.0f-\/aFracIndex;}
\DoxyCodeLine{00064\ \ \ \ \ }
\DoxyCodeLine{00065\ \ \ \ \ aTableIndex=aTableIndex*mNumTables;}
\DoxyCodeLine{00066\ \ \ \ \ \textcolor{keywordtype}{int}\ aTableIndexPlus1=aTableIndex+mNumTables;}
\DoxyCodeLine{00067\ \ \ \ \ }
\DoxyCodeLine{00068\ \ \ \ \ \textcolor{keywordflow}{for}(\textcolor{keywordtype}{int}\ i=0;\ i<mNumTables;\ i++)}
\DoxyCodeLine{00069\ \ \ \ \ \{}
\DoxyCodeLine{00070\ \ \ \ \ \ \ \ \ oValues[i]=(DFLOAT)(iTable[aTableIndex++]*aFracIndexM1\ +\ iTable[aTableIndexPlus1++]*aFracIndex);}
\DoxyCodeLine{00071\ \ \ \ \ \}}
\DoxyCodeLine{00072\ \}}
\DoxyCodeLine{00073\ }
\DoxyCodeLine{00074\ \textcolor{comment}{//Block\ version\ of\ table\ lookup}}
\DoxyCodeLine{00075\ \textcolor{keyword}{template}<\textcolor{keyword}{class}\ TFLOAT,\ \textcolor{keyword}{class}\ DFLOAT>}
\DoxyCodeLine{00076\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{void}\ \mbox{\hyperlink{a02470_aaad992e09c837d96ad715092fbefd91d}{AAX\_FastInterpolatedTableLookup<TFLOAT,DFLOAT>::DoTableLookupExtraFast}}(\textcolor{keyword}{const}\ TFLOAT*\ \textcolor{keyword}{const}\ iTable,\ \textcolor{keyword}{const}\ TFLOAT*\ \textcolor{keyword}{const}\ inpBuf,\ DFLOAT*\ \textcolor{keyword}{const}\ outBuf,\ \textcolor{keywordtype}{int}\ blockSize)}
\DoxyCodeLine{00077\ \{}
\DoxyCodeLine{00078\ \textcolor{preprocessor}{\#if\ defined(\ \_TMS320C6700\ )}}
\DoxyCodeLine{00079\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{int}\ r\ =\ 16;}
\DoxyCodeLine{00080\ \textcolor{preprocessor}{\ \ \ \ \#pragma\ MUST\_ITERATE(r,\ ,\ r);}}
\DoxyCodeLine{00081\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00082\ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{int}\ i\ =\ 0;\ i\ <\ blockSize;\ i++)}
\DoxyCodeLine{00083\ \ \ \ \ \{}
\DoxyCodeLine{00084\ \ \ \ \ \ \ \ \ outBuf[i]\ =\ DoTableLookupExtraFast(iTable,\ inpBuf[i]);}
\DoxyCodeLine{00085\ \ \ \ \ \}}
\DoxyCodeLine{00086\ \ \ \ \ \textcolor{keywordflow}{return};}
\DoxyCodeLine{00087\ \}}
\DoxyCodeLine{00088\ }
\DoxyCodeLine{00089\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//\ AAX\_FASTINTERPOLATEDTABLELOOKUP\_HPP}}

\end{DoxyCode}
