\hypertarget{a00836_source}{}\doxysection{AAX\+\_\+\+Fast\+Interpolated\+Table\+Lookup.\+hpp}
\label{a00836_source}\index{AAX\_FastInterpolatedTableLookup.hpp@{AAX\_FastInterpolatedTableLookup.hpp}}
\mbox{\hyperlink{a00836}{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\ Avid\ Technology,\ Inc.}}
\DoxyCodeLine{00004\ \textcolor{comment}{\ *\ \ All\ rights\ reserved.}}
\DoxyCodeLine{00005\ \textcolor{comment}{\ *\ \ }}
\DoxyCodeLine{00006\ \textcolor{comment}{\ *\ \ CONFIDENTIAL:\ this\ document\ contains\ confidential\ information\ of\ Avid.\ Do}}
\DoxyCodeLine{00007\ \textcolor{comment}{\ *\ \ not\ disclose\ to\ any\ third\ party.\ Use\ of\ the\ information\ contained\ in\ this}}
\DoxyCodeLine{00008\ \textcolor{comment}{\ *\ \ document\ is\ subject\ to\ an\ Avid\ SDK\ license.}}
\DoxyCodeLine{00009\ \textcolor{comment}{\ */}}
\DoxyCodeLine{00010\ \textcolor{comment}{/*================================================================================================*/}}
\DoxyCodeLine{00011\ }
\DoxyCodeLine{00012\ \textcolor{preprocessor}{\#ifndef\ AAX\_FASTINTERPOLATEDTABLELOOKUP\_HPP}}
\DoxyCodeLine{00013\ \textcolor{preprocessor}{\#define\ AAX\_FASTINTERPOLATEDTABLELOOKUP\_HPP}}
\DoxyCodeLine{00014\ }
\DoxyCodeLine{00015\ \textcolor{preprocessor}{\#include\ "{}\mbox{\hyperlink{a00854}{AAX\_Quantize.h}}"{}}}
\DoxyCodeLine{00016\ }
\DoxyCodeLine{00017\ \textcolor{comment}{//This\ version\ requires\ that\ the\ lookup\ table\ is\ padded\ with\ one\ extra\ location\ so\ we\ }}
\DoxyCodeLine{00018\ \textcolor{comment}{//can\ avoid\ one\ of\ the\ checks\ to\ see\ if\ ours\ pointers\ are\ out\ of\ bounds.}}
\DoxyCodeLine{00019\ \textcolor{keyword}{template}<\textcolor{keyword}{class}\ TFLOAT,\ \textcolor{keyword}{class}\ DFLOAT>}
\DoxyCodeLine{00020\ \textcolor{keyword}{inline}\ DFLOAT\ \mbox{\hyperlink{a02441_aaad992e09c837d96ad715092fbefd91d}{AAX\_FastInterpolatedTableLookup<TFLOAT,DFLOAT>::DoTableLookupExtraFast}}(\textcolor{keyword}{const}\ TFLOAT*\ iTable,\ DFLOAT\ iValue)\textcolor{keyword}{\ const}}
\DoxyCodeLine{00021\ \textcolor{keyword}{}\{}
\DoxyCodeLine{00022\ \ \ \ \ \textcolor{keyword}{const}\ TFLOAT\ aScaledValue=(iValue\ -\/\ mMin)*mTableSizeM1DivMaxMinusMin;}
\DoxyCodeLine{00023\ }
\DoxyCodeLine{00024\ \ \ \ \ \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{00025\ \ \ \ \ \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{00026\ \ \ \ \ \textcolor{keyword}{const}\ TFLOAT\ aScaledValueLimited\ =\ aScaledValue\ >\ mTableSizeM1\ ?\ mTableSizeM1\ :\ (aScaledValue\ >\ 0.0f\ ?\ aScaledValue\ :\ 0.0f);}
\DoxyCodeLine{00027\ }
\DoxyCodeLine{00028\ \ \ \ \ \textcolor{keywordtype}{int}\ aTableIndex=\mbox{\hyperlink{a00935_ad2b2872b49146cf0859c403fea702a39}{AAX::FastTrunc2Int32}}(aScaledValueLimited);}
\DoxyCodeLine{00029\ }
\DoxyCodeLine{00030\ \ \ \ \ TFLOAT\ aFracIndex=aScaledValueLimited\ -\/\ TFLOAT(aTableIndex);}
\DoxyCodeLine{00031\ \ \ \ \ TFLOAT\ aFracIndexM1=1.0f-\/aFracIndex;}
\DoxyCodeLine{00032\ }
\DoxyCodeLine{00033\ \ \ \ \ \textcolor{keywordflow}{return}\ (DFLOAT)(iTable[aTableIndex]*aFracIndexM1\ +\ iTable[aTableIndex+1]*aFracIndex);}
\DoxyCodeLine{00034\ \}}
\DoxyCodeLine{00035\ }
\DoxyCodeLine{00036\ \textcolor{comment}{//This\ version\ requires\ that\ the\ lookup\ table\ is\ padded\ with\ one\ extra\ location\ so\ we}}
\DoxyCodeLine{00037\ \textcolor{comment}{//can\ avoid\ one\ of\ the\ checks\ to\ see\ if\ ours\ pointers\ are\ out\ of\ bounds.}}
\DoxyCodeLine{00038\ \textcolor{keyword}{template}<\textcolor{keyword}{class}\ TFLOAT,\ \textcolor{keyword}{class}\ DFLOAT>}
\DoxyCodeLine{00039\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{void}\ \mbox{\hyperlink{a02441_a60e89d13066ca0606c8f71cf5313f0e3}{AAX\_FastInterpolatedTableLookup<TFLOAT,DFLOAT>::DoTableLookupExtraFastMulti}}(\textcolor{keyword}{const}\ TFLOAT*\ iTable,\ DFLOAT\ iValue,\ DFLOAT*\ oValues)\textcolor{keyword}{\ const}}
\DoxyCodeLine{00040\ \textcolor{keyword}{}\{}
\DoxyCodeLine{00041\ \ \ \ \ TFLOAT\ aScaledValue=(iValue\ -\/\ mMin)*mTableSizeM1DivMaxMinusMin;}
\DoxyCodeLine{00042\ \ \ \ \ }
\DoxyCodeLine{00043\ \ \ \ \ \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{00044\ \ \ \ \ \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{00045\ \ \ \ \ \textcolor{keyword}{const}\ TFLOAT\ aScaledValueLimited\ =\ aScaledValue\ >\ mTableSizeM1\ ?\ mTableSizeM1\ :\ (aScaledValue\ >\ 0.0f\ ?\ aScaledValue\ :\ 0.0f);}
\DoxyCodeLine{00046\ \ \ \ \ }
\DoxyCodeLine{00047\ \ \ \ \ \textcolor{keywordtype}{int}\ aTableIndex=\mbox{\hyperlink{a00935_ad2b2872b49146cf0859c403fea702a39}{AAX::FastTrunc2Int32}}(aScaledValueLimited);}
\DoxyCodeLine{00048\ \ \ \ \ }
\DoxyCodeLine{00049\ \ \ \ \ TFLOAT\ aFracIndex=aScaledValueLimited\ -\/\ TFLOAT(aTableIndex);}
\DoxyCodeLine{00050\ \ \ \ \ TFLOAT\ aFracIndexM1=1.0f-\/aFracIndex;}
\DoxyCodeLine{00051\ \ \ \ \ }
\DoxyCodeLine{00052\ \ \ \ \ aTableIndex=aTableIndex*mNumTables;}
\DoxyCodeLine{00053\ \ \ \ \ \textcolor{keywordtype}{int}\ aTableIndexPlus1=aTableIndex+mNumTables;}
\DoxyCodeLine{00054\ \ \ \ \ }
\DoxyCodeLine{00055\ \ \ \ \ \textcolor{keywordflow}{for}(\textcolor{keywordtype}{int}\ i=0;\ i<mNumTables;\ i++)}
\DoxyCodeLine{00056\ \ \ \ \ \{}
\DoxyCodeLine{00057\ \ \ \ \ \ \ \ \ oValues[i]=(DFLOAT)(iTable[aTableIndex++]*aFracIndexM1\ +\ iTable[aTableIndexPlus1++]*aFracIndex);}
\DoxyCodeLine{00058\ \ \ \ \ \}}
\DoxyCodeLine{00059\ \}}
\DoxyCodeLine{00060\ }
\DoxyCodeLine{00061\ \textcolor{comment}{//Block\ version\ of\ table\ lookup}}
\DoxyCodeLine{00062\ \textcolor{keyword}{template}<\textcolor{keyword}{class}\ TFLOAT,\ \textcolor{keyword}{class}\ DFLOAT>}
\DoxyCodeLine{00063\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{void}\ \mbox{\hyperlink{a02441_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{00064\ \{}
\DoxyCodeLine{00065\ \textcolor{preprocessor}{\#if\ defined(\ \_TMS320C6700\ )}}
\DoxyCodeLine{00066\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{int}\ r\ =\ 16;}
\DoxyCodeLine{00067\ \textcolor{preprocessor}{\ \ \ \ \#pragma\ MUST\_ITERATE(r,\ ,\ r);}}
\DoxyCodeLine{00068\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00069\ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{int}\ i\ =\ 0;\ i\ <\ blockSize;\ i++)}
\DoxyCodeLine{00070\ \ \ \ \ \{}
\DoxyCodeLine{00071\ \ \ \ \ \ \ \ \ outBuf[i]\ =\ DoTableLookupExtraFast(iTable,\ inpBuf[i]);}
\DoxyCodeLine{00072\ \ \ \ \ \}}
\DoxyCodeLine{00073\ \ \ \ \ \textcolor{keywordflow}{return};}
\DoxyCodeLine{00074\ \}}
\DoxyCodeLine{00075\ }
\DoxyCodeLine{00076\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//\ AAX\_FASTINTERPOLATEDTABLELOOKUP\_HPP}}

\end{DoxyCode}
