\hypertarget{a00845_source}{}\doxysection{AAX\+\_\+\+Random\+Gen.\+h}
\label{a00845_source}\index{AAX\_RandomGen.h@{AAX\_RandomGen.h}}
\mbox{\hyperlink{a00845}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ \textcolor{comment}{/*================================================================================================*/}}
\DoxyCodeLine{00002\ \textcolor{comment}{/*}}
\DoxyCodeLine{00003\ \textcolor{comment}{\ *\ \ Copyright\ 2013-\/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\ }
\DoxyCodeLine{00017\ \textcolor{comment}{/*================================================================================================*/}}
\DoxyCodeLine{00018\ \textcolor{preprocessor}{\#pragma\ once}}
\DoxyCodeLine{00019\ }
\DoxyCodeLine{00020\ \textcolor{preprocessor}{\#ifndef\ AAX\_RANDOMGEN\_H}}
\DoxyCodeLine{00021\ \textcolor{preprocessor}{\#define\ AAX\_RANDOMGEN\_H}}
\DoxyCodeLine{00022\ }
\DoxyCodeLine{00023\ \textcolor{comment}{//\ Standard\ headers}}
\DoxyCodeLine{00024\ \textcolor{preprocessor}{\#include\ <stdlib.h>}}
\DoxyCodeLine{00025\ \textcolor{preprocessor}{\#include\ <time.h>}}
\DoxyCodeLine{00026\ \textcolor{preprocessor}{\#include\ <stdint.h>}}
\DoxyCodeLine{00027\ }
\DoxyCodeLine{00028\ \textcolor{preprocessor}{\#include\ "{}\mbox{\hyperlink{a00833}{AAX\_PlatformOptimizationConstants.h}}"{}}}
\DoxyCodeLine{00029\ \textcolor{preprocessor}{\#include\ "{}\mbox{\hyperlink{a00830}{AAX\_Constants.h}}"{}}}
\DoxyCodeLine{00030\ }
\DoxyCodeLine{00031\ \textcolor{keyword}{namespace\ }\mbox{\hyperlink{a00935}{AAX}}}
\DoxyCodeLine{00032\ \{}
\DoxyCodeLine{00033\ }
\DoxyCodeLine{00034\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{float}\ \mbox{\hyperlink{a00935_a0c975151f0d47cc80eef9ff5a7c80125}{cSeedDivisor}}\ =\ 1/127773.0f;}
\DoxyCodeLine{00035\ }
\DoxyCodeLine{00036\ \textcolor{keyword}{const}\ int32\_t\ \mbox{\hyperlink{a00935_a143d659ccb62ae0807e9902e751b14cf}{cInitialSeedValue}}=0x00F54321;}
\DoxyCodeLine{00037\ }
\DoxyCodeLine{00038\ \textcolor{comment}{/*===================================================================================================*/}}
\DoxyCodeLine{00039\ \textcolor{keyword}{inline}\ int32\_t\ \mbox{\hyperlink{a00935_af3435129d3c94c5f3d5e671943b9bbe2}{GetInt32RPDF}}(int32\_t*\ iSeed)}
\DoxyCodeLine{00040\ \{}
\DoxyCodeLine{00041\ \ \ \ \ \textcolor{comment}{//\ Requirement:\ iSeed\ param\ must\ be\ a\ static\ in\ the\ calling\ function.}}
\DoxyCodeLine{00042\ \ \ \ \ int64\_t\ seed\ =\ *iSeed;}
\DoxyCodeLine{00043\ \ \ \ \ int64\_t\ k\ =\ \textcolor{keyword}{static\_cast<}int64\_t\textcolor{keyword}{>}(seed*\mbox{\hyperlink{a00935_a0c975151f0d47cc80eef9ff5a7c80125}{cSeedDivisor}});}
\DoxyCodeLine{00044\ \ \ \ \ seed\ =\ 16807\ *\ (seed\ -\/\ k\ *\ 127773LL)\ -\/\ 2836\ *\ k\ +\ 7395;}
\DoxyCodeLine{00045\ \ \ \ \ *iSeed\ =\ \textcolor{keyword}{static\_cast<}int32\_t\textcolor{keyword}{>}(seed);}
\DoxyCodeLine{00046\ \ \ \ \ \textcolor{keywordflow}{if}\ (*iSeed\ <\ 0)\ }
\DoxyCodeLine{00047\ \ \ \ \ \ \ \ \ *iSeed\ +=\ 2147483647;}
\DoxyCodeLine{00048\ \ \ \ \ \textcolor{keywordflow}{return}\ (*iSeed\ -\/\ 1073741824)\ *\ 2;\ \ \ \ \ \ \ \textcolor{comment}{//\ -\/2147483647..+2147483647}}
\DoxyCodeLine{00049\ \}}
\DoxyCodeLine{00050\ }
\DoxyCodeLine{00051\ \textcolor{comment}{/*===================================================================================================*/}}
\DoxyCodeLine{00052\ }
\DoxyCodeLine{00053\ }
\DoxyCodeLine{00066\ \textcolor{keyword}{inline}\ int32\_t\ \mbox{\hyperlink{a00935_ad12251899137d551b9f652b1ffee2f99}{GetFastInt32RPDF}}(int32\_t*\ iSeed)}
\DoxyCodeLine{00067\ \{}
\DoxyCodeLine{00068\ \ \ \ *iSeed\ =\ (*iSeed\ *\ 196314165)\ +\ 907633515;}
\DoxyCodeLine{00069\ \ \ \ \textcolor{keywordflow}{return}\ *iSeed;}
\DoxyCodeLine{00070\ \}}
\DoxyCodeLine{00071\ }
\DoxyCodeLine{00072\ \textcolor{comment}{/*===================================================================================================*/}}
\DoxyCodeLine{00073\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{float}\ \mbox{\hyperlink{a00935_a5a91375167236862abc93ad879639cab}{GetRPDFWithAmplitudeOneHalf}}(int32\_t*\ iSeed)\ \ \ \ \ \textcolor{comment}{//An\ amplitude\ of\ 0.5\ =\ 1\ LSBs}}
\DoxyCodeLine{00074\ \{}
\DoxyCodeLine{00075\ \ \ \ \ \textcolor{comment}{//\ Requirement:\ iSeed\ param\ must\ be\ a\ static\ in\ the\ calling\ function.}}
\DoxyCodeLine{00076\ \ \ \ \ \textcolor{keywordflow}{return}\ float(\mbox{\hyperlink{a00935_a93ce2d3935dc06b1c4c887568df84788}{cNormalizeLongToAmplitudeOneHalf}})\ *\ float(\mbox{\hyperlink{a00935_af3435129d3c94c5f3d5e671943b9bbe2}{GetInt32RPDF}}(iSeed));}
\DoxyCodeLine{00077\ \}}
\DoxyCodeLine{00078\ }
\DoxyCodeLine{00079\ \textcolor{comment}{/*===================================================================================================*/}}
\DoxyCodeLine{00080\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{float}\ \mbox{\hyperlink{a00935_a51d7a263d9053276c6cef1dbd2018ebe}{GetRPDFWithAmplitudeOne}}(int32\_t*\ iSeed)\ \ \ \ \ \ \ \ \ \textcolor{comment}{//An\ amplitude\ of\ 1.0\ =\ 2\ LSBs}}
\DoxyCodeLine{00081\ \{}
\DoxyCodeLine{00082\ \ \ \ \ \textcolor{comment}{//\ Requirement:\ iSeed\ param\ must\ be\ a\ static\ in\ the\ calling\ function.}}
\DoxyCodeLine{00083\ \ \ \ \ \textcolor{keywordflow}{return}\ float(\mbox{\hyperlink{a00935_ad30333177ff94148492a02325045a827}{cNormalizeLongToAmplitudeOne}})\ *\ float(\mbox{\hyperlink{a00935_af3435129d3c94c5f3d5e671943b9bbe2}{GetInt32RPDF}}(iSeed));}
\DoxyCodeLine{00084\ \}}
\DoxyCodeLine{00085\ }
\DoxyCodeLine{00086\ \textcolor{comment}{/*===================================================================================================*/}}
\DoxyCodeLine{00087\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{float}\ \mbox{\hyperlink{a00935_a145cc6d06cd682e2d234d07ce939760e}{GetFastRPDFWithAmplitudeOne}}(int32\_t*\ iSeed)\ \ \ \ \ \ \ \ \ \textcolor{comment}{//An\ amplitude\ of\ 1.0\ =\ 2\ LSBs}}
\DoxyCodeLine{00088\ \{}
\DoxyCodeLine{00089\ \ \ \ \ \textcolor{comment}{//\ Requirement:\ iSeed\ param\ must\ be\ a\ static\ in\ the\ calling\ function.}}
\DoxyCodeLine{00090\ \ \ \ \ \textcolor{keywordflow}{return}\ float(\mbox{\hyperlink{a00935_ad30333177ff94148492a02325045a827}{cNormalizeLongToAmplitudeOne}})\ *\ float(\mbox{\hyperlink{a00935_ad12251899137d551b9f652b1ffee2f99}{GetFastInt32RPDF}}(iSeed));}
\DoxyCodeLine{00091\ \}}
\DoxyCodeLine{00092\ }
\DoxyCodeLine{00093\ \textcolor{comment}{/*===================================================================================================*/}}
\DoxyCodeLine{00094\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{float}\ \mbox{\hyperlink{a00935_a42cc414ea1b868e26c591041a66ad8af}{GetTPDFWithAmplitudeOne}}(int32\_t*\ iSeed)\ \ \ \ \ \ \ \ \ \textcolor{comment}{//An\ amplitude\ of\ 1.0\ =\ 2\ LSBs}}
\DoxyCodeLine{00095\ \{}
\DoxyCodeLine{00096\ \ \ \ \ \textcolor{comment}{//\ Generate\ a\ random\ number\ with\ a\ triangular\ pdf\ (tpdf)\ using\ two\ }}
\DoxyCodeLine{00097\ \ \ \ \ \textcolor{comment}{//\ separate\ rectangular\ pdf\ noise\ sources.}}
\DoxyCodeLine{00098\ }
\DoxyCodeLine{00099\ \ \ \ \ \textcolor{comment}{//\ We\ are\ using\ only\ one\ seed\ input\ for\ both\ rect\ pdf\ noise\ generators,\ }}
\DoxyCodeLine{00100\ \ \ \ \ \textcolor{comment}{//\ but\ because\ they\ are\ of\ course\ executed\ sequentially\ independent\ noise\ }}
\DoxyCodeLine{00101\ \ \ \ \ \textcolor{comment}{//\ will\ be\ produced.}}
\DoxyCodeLine{00102\ }
\DoxyCodeLine{00103\ \ \ \ \ \textcolor{keywordflow}{return}\ float(\mbox{\hyperlink{a00935_ad30333177ff94148492a02325045a827}{cNormalizeLongToAmplitudeOne}})\ *\ (float(\mbox{\hyperlink{a00935_ad12251899137d551b9f652b1ffee2f99}{GetFastInt32RPDF}}(iSeed)\ +\ \textcolor{keywordtype}{float}(\mbox{\hyperlink{a00935_ad12251899137d551b9f652b1ffee2f99}{GetFastInt32RPDF}}(iSeed))));}
\DoxyCodeLine{00104\ \}}
\DoxyCodeLine{00105\ }
\DoxyCodeLine{00106\ \}\ \textcolor{comment}{//\ namespace\ AAX}}
\DoxyCodeLine{00107\ }
\DoxyCodeLine{00108\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//\ AAX\_RANDOMGEN\_H}}
\DoxyCodeLine{00109\ }

\end{DoxyCode}
