Commit 85d0e790 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

ivas_binRenderer_internal.c float to fix conversion

[x] Few of functions and subfunctions in ivas_binRenderer_internal.c converted to fixed.
parent b4dfdc3a
Loading
Loading
Loading
Loading
Loading
+21 −1
Original line number Diff line number Diff line
@@ -1237,7 +1237,6 @@ Word16 getCosWord16(Word16 theta)
  return result;
}


Word16 getCosWord16R2(
    Word16 theta )
{
@@ -1254,6 +1253,27 @@ Word16 getCosWord16R2(
    return result;
}


Word16 getSineWord16R2( Word16 theta )
{
    IF ( theta == 0 )
    {
        return 0;
    }
    Word16 cosine = getCosWord16R2( theta );
    Word16 result = 32767 - ( mult_r( cosine, cosine ) );
    Word16 exp = 0;
    Word16 sine = Sqrt16( result, &exp );
    sine = shl( sine, exp );

    IF ( ( ( theta >= 16384 ) && ( theta <= 32767 ) ) || ( ( theta < 0 ) && ( theta >= -16384 ) ) )
    {
        sine = negate( sine );
    }

    return sine;
}

/*
 * Calculate Integer Square Root of 'val'. This is the equivalent of (int)sqrt(val);
 * The return value will be truncated to the lowest integer (throwing away the fractionnal part.
+2 −1
Original line number Diff line number Diff line
@@ -460,6 +460,7 @@ Word32 getCosWord32(Word32 theta);
 * \return result with exponent 0.
 */
Word16 getCosWord16R2( Word16 theta );
Word16 getSineWord16R2( Word16 theta );
/****************************************************************************/
/*!
  \brief Sets Array Word16 arg1 to value Word16 arg2 for Word16 arg3 elements
+1 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@
#define _180_OVER_PI                            ( 180.0f / EVS_PI )

#define SQRT2                                   1.414213562373095f
#define SQRT2_FIXED                             1518500250 // Q30
#define SQRT2_OVER_2                            (SQRT2 / 2.0f)

#define INV_SQRT2                               7.071067811865475e-1f /* 1/sqrt(2) */
+15 −1
Original line number Diff line number Diff line
@@ -3742,6 +3742,13 @@ void ivas_dirac_dec_get_response(
    float *response,
    const int16_t ambisonics_order
);
#ifdef IVAS_FLOAT_FIXED
void ivas_dirac_dec_get_response_fixed(
    const Word16 azimuth,
    const Word16 elevation,
    Word32 *response,
    const Word16 ambisonics_order );
#endif

void calculate_hodirac_sector_parameters(
    DIRAC_ENC_HANDLE hDirAC,
@@ -5295,7 +5302,14 @@ void panning_wrap_angles(
    float *azi_wrapped,                                         /* o  : wrapped azimuth component                                */
    float *ele_wrapped                                          /* o  : wrapped elevation component                              */
);

#ifdef IVAS_FLOAT_FIXED
void panning_wrap_angles_fixed(
    const Word32 azi_deg, /* i  : azimuth in degrees for panning direction (positive left) */
    const Word32 ele_deg, /* i  : elevation in degrees for panning direction (positive up) */
    Word32 *azi_wrapped,  /* o  : wrapped azimuth component                                */
    Word32 *ele_wrapped   /* o  : wrapped elevation component                              */
);
#endif
void v_sort_ind(
    float *x,                                                   /* i/o: Vector to be sorted                                      */
    int16_t *idx,                                               /* o  : Original index positions                                 */
+289 −3
Original line number Diff line number Diff line
@@ -4240,7 +4240,13 @@ const float dirac_gains_norm_term[9] =
{
    1.000000e+00f,  7.071068e-01f,  1.000000e+00f,  4.082483e-01f,    2.041242e-01f,    1.000000e+00f,  2.886751e-01f,  9.128709e-02f,    3.726780e-02f
};
#ifdef IVAS_FLOAT_FIXED
const Word32 dirac_gains_norm_term_int[9] = //Q30
{
    1073741824,  759250176,  1073741824,  438353280,  219176688,  1073741824,  309962528,  98018768,  
    40015996
};
#endif
const float dirac_gains_Pnm[91][9] = 
{
    {-1.000000e+00f,-0.000000e+00f,1.000000e+00f,-0.000000e+00f,0.000000e+00f,-1.000000e+00f,-0.000000e+00f,0.000000e+00f,-0.000000e+00f},
@@ -4335,7 +4341,102 @@ const float dirac_gains_Pnm[91][9] =
    {-1.745235e-02f,9.998478e-01f,-4.995431e-01f,-5.234908e-02f,2.999086e+00f,2.616524e-02f,-1.497488e+00f,-2.617055e-01f,1.499315e+01f},
    {-4.371139e-08f,1.000000e+00f,-5.000000e-01f,-1.311342e-07f,3.000000e+00f,6.556709e-08f,-1.500000e+00f,-6.556709e-07f,1.500000e+01f}
};
#ifdef IVAS_FLOAT_FIXED
const Word32 dirac_gains_Pnm_int[91][9] = //Q27
{
    {-134217728,  0,  134217728,  0,  0,  -134217728,  0,  0,  0},
    {-134197288,  2342396,  134156400,  -7026119,  122639,  -134095104,  14049026,  -613106,  10701},
    {-134135976,  4684105,  133972536,  -14043751,  490416,  -133727536,  28061840,  -2450586,  85575},
    {-134033784,  7024438,  133666264,  -21044428,  1102895,  -133115936,  42002312,  -5506921,  288606},
    {-133890784,  9362478,  133238096,  -28019012,  1959264,  -132262040,  55833192,  -9772457,  683351},
    {-133706992,  11697809,  132688440,  -34959892,  3058584,  -131167848,  69520408,  -15234719,  1332861},
    {-133482480,  14029564,  132017976,  -41858120,  4399464,  -129836328,  83027720,  -21876818,  2299344},
    {-133217280,  16357047,  131227600,  -48705360,  5980272,  -128270864,  96320208,  -29678480,  3644062},
    {-132911536,  18679510,  130318176,  -55493180,  7799064,  -126475552,  109363520,  -38615824,  5427104},
    {-132565296,  20996256,  129290928,  -62213284,  9853607,  -124455056,  122123976,  -48661468,  7707213},
    {-132178656,  23306694,  128146968,  -68857816,  12141505,  -122214432,  134569248,  -59785232,  10541761},
    {-131751776,  25609964,  126887800,  -75418320,  14659851,  -119759704,  146666688,  -71952528,  13986158},
    {-131284736,  27905410,  125514928,  -81886824,  17405570,  -117097048,  158385376,  -85126080,  18094094},
    {-130777744,  30192412,  124030024,  -88255768,  20375446,  -114233392,  169695776,  -99266128,  22917396},
    {-130230888,  32470208,  122434848,  -94517128,  23565774,  -111176104,  180568608,  -114328832,  28505376},
    {-129644368,  34738112,  120731408,  -100663320,  26972664,  -107933048,  190976128,  -130267952,  34905200},
    {-129018344,  36995424,  118921736,  -106686840,  30591964,  -104512608,  200891728,  -147034448,  42161440},
    {-128353056,  39241452,  117008088,  -112580368,  34419264,  -100923608,  210290720,  -164576576,  50316080},
    {-127648640,  41475572,  114992728,  -118336848,  38449984,  -97175216,  219149232,  -182840512,  59408524},
    {-126905360,  43697012,  112878208,  -123949000,  42679048,  -93277184,  227444688,  -201769248,  69474696},
    {-126123408,  45905176,  110666976,  -129410248,  47101484,  -89239304,  235156848,  -221304640,  80548296},
    {-125303040,  48099312,  108361848,  -134713792,  51711740,  -85072152,  242266352,  -241385344,  92659128},
    {-124444528,  50278820,  105965584,  -139853120,  56504308,  -80786280,  248755776,  -261949392,  105834368},
    {-123548080,  52443040,  103481048,  -144822272,  61473384,  -76392608,  254609280,  -282932704,  120097808},
    {-122614016,  54591264,  100911328,  -149614784,  66612780,  -71902504,  259812912,  -304269024,  135469312},
    {-121642584,  56722880,  98259536,  -154225168,  71916384,  -67327280,  264354304,  -325891904,  151965872},
    {-120634104,  58837188,  95528944,  -158647504,  77377552,  -62678672,  268222720,  -347732352,  169600480},
    {-119588872,  60933588,  92722800,  -162876704,  82989840,  -57968464,  271409984,  -369722464,  188383040},
    {-118507224,  63011412,  89844624,  -166907264,  88746208,  -53208660,  273908992,  -391791360,  208319200},
    {-117389480,  65070028,  86897888,  -170734608,  94639696,  -48411356,  275714624,  -413868832,  229411120},
    {-116235952,  67108864,  83886096,  -174353936,  100663296,  -43588484,  276824064,  -435884832,  251658240},
    {-115047032,  69127240,  80812992,  -177760784,  106809472,  -38752388,  277236128,  -457767936,  275054816},
    {-113823072,  71124576,  77682296,  -180951136,  113070880,  -33915128,  276951296,  -479447744,  299592224},
    {-112564464,  73100224,  74497888,  -183920976,  119439696,  -29088994,  275972448,  -500852768,  325257600},
    {-111271560,  75053584,  71263600,  -186666800,  125908272,  -24285974,  274304128,  -521913568,  352034976},
    {-109944736,  76984136,  67983320,  -189185120,  132468856,  -19517968,  271952224,  -542560640,  379905024},
    {-108584440,  78891192,  64661120,  -191472992,  139113184,  -14796968,  268925472,  -562724864,  408843424},
    {-107191040,  80774240,  61300996,  -193527600,  145833472,  -10134552,  265233552,  -582338944,  438823936},
    {-105765016,  82632672,  57907084,  -195346384,  152621264,  -5542341,  260888528,  -601335936,  469815200},
    {-104306760,  84465968,  54483472,  -196927072,  159468512,  -1031517,  255903808,  -619651456,  501783968},
    {-102816736,  86273488,  51034412,  -198267904,  166366624,  3386773,  250294992,  -637221056,  534692032},
    {-101295408,  88054736,  47564080,  -199367280,  173307296,  7701825,  244078832,  -653983232,  568498944},
    {-99743224,  89809192,  44076620,  -200223728,  180282192,  11903295,  237274256,  -669879040,  603161856},
    {-98160648,  91536272,  40576356,  -200836160,  187282720,  15980983,  229901280,  -684849728,  638632640},
    {-96548144,  93235488,  37067500,  -201203920,  194300432,  19925212,  221981760,  -698840192,  674862144},
    {-94906272,  94906272,  33554432,  -201326592,  201326592,  23726568,  213539056,  -711796992,  711796992},
    {-93235488,  96548144,  30041364,  -201203920,  208352752,  27376188,  204597888,  -723670016,  749382016},
    {-91536272,  98160648,  26532496,  -200836160,  215370464,  30865648,  195183856,  -734411520,  787559936},
    {-89809200,  99743208,  23032272,  -200223728,  222370864,  34186800,  185324752,  -743976000,  826268864},
    {-88054736,  101295408,  19544786,  -199367280,  229345888,  37332284,  175048640,  -752322176,  865447872},
    {-86273488,  102816736,  16074439,  -198268032,  236286560,  40294912,  164385440,  -759410496,  905030144},
    {-84465944,  104306784,  12625336,  -196927072,  243184800,  43068320,  153365504,  -765205632,  944950528},
    {-82632672,  105765016,  9201773,  -195346384,  250031920,  45646496,  142020480,  -769675200,  985139200},
    {-80774256,  107191032,  5807891,  -193527600,  256819584,  48024044,  130382952,  -772789696,  1025526400},
    {-78891192,  108584440,  2447739,  -191472992,  263540000,  50196224,  118485736,  -774524480,  1066041600},
    {-76984120,  109944720,  -874438,  -189185120,  270184320,  52158672,  106363224,  -774856768,  1106610176},
    {-75053584,  111271544,  -4154720,  -186666800,  276744864,  53907864,  94049432,  -773768704,  1147159552},
    {-73100224,  112564464,  -7389016,  -183920976,  283213504,  55440728,  81579720,  -771245696,  1187614080},
    {-71124568,  113823072,  -10573435,  -180951136,  289582400,  56754824,  68989160,  -767276288,  1227898496},
    {-69127232,  115047064,  -13704140,  -177760784,  295843776,  57848416,  56313356,  -761853888,  1267938048},
    {-67108880,  116235952,  -16777203,  -174353936,  301989888,  58720256,  43588536,  -754974720,  1307654528},
    {-65070028,  117389472,  -19788994,  -170734608,  308013440,  59369844,  30850226,  -746639232,  1346972928},
    {-63011400,  118507224,  -22735772,  -166907264,  313906944,  59797272,  18134762,  -736851968,  1385816832},
    {-60933588,  119588872,  -25613950,  -162876704,  319663424,  60003204,  5477891,  -725620736,  1424110464},
    {-58837172,  120634088,  -28420080,  -158647504,  325275584,  59989016,  -7084927,  -712957184,  1461778688},
    {-56722868,  121642576,  -31150674,  -154225168,  330736768,  59756660,  -19517928,  -698877184,  1498746240},
    {-54591276,  122613992,  -33802452,  -149614784,  336040384,  59308680,  -31786382,  -683399744,  1534940800},
    {-52443040,  123548064,  -36372160,  -144822272,  341179712,  58648260,  -43855684,  -666547776,  1570288384},
    {-50278848,  124444520,  -38856688,  -139853264,  346148864,  57779188,  -55691916,  -648348160,  1604717952},
    {-48099324,  125303040,  -41252988,  -134713792,  350941376,  56705796,  -67261816,  -628830848,  1638160896},
    {-45905160,  126123416,  -43558124,  -129410240,  355551744,  55433036,  -78532848,  -608029120,  1670546304},
    {-43697012,  126905360,  -45769332,  -123949000,  359974080,  53966400,  -89473440,  -585980480,  1701810944},
    {-41475560,  127648632,  -47883864,  -118336808,  364203168,  52311936,  -100052728,  -562724992,  1731889152},
    {-39241464,  128353048,  -49899212,  -112580408,  368233856,  50476188,  -110241232,  -538305984,  1760719104},
    {-36995424,  129018360,  -51812888,  -106686856,  372061216,  48466224,  -120010336,  -512769824,  1788240512},
    {-34738100,  129644368,  -53622532,  -100663280,  375680512,  46289628,  -129332608,  -486166400,  1814398208},
    {-32470208,  130230888,  -55325984,  -94517088,  379087360,  43954400,  -138181984,  -458547616,  1839134464},
    {-30192412,  130777744,  -56921148,  -88255752,  382277728,  41469052,  -146533552,  -429968768,  1862399872},
    {-27905450,  131284752,  -58406064,  -81886920,  385247552,  38842476,  -154363936,  -400487584,  1884144384},
    {-25609950,  131751776,  -59778952,  -75418272,  387993376,  36083912,  -161651424,  -370163232,  1904324096},
    {-23306666,  132178656,  -61038128,  -68857760,  390511712,  33203050,  -168375472,  -339058272,  1922894464},
    {-20996270,  132565280,  -62182040,  -62213328,  392799456,  30209874,  -174517136,  -307236864,  1939817984},
    {-18679498,  132911536,  -63209344,  -55493124,  394854208,  27114732,  -180059392,  -274765312,  1955057024},
    {-16357021,  133217280,  -64118736,  -48705292,  396672992,  23928188,  -184986656,  -241711232,  1968580864},
    {-14029578,  133482472,  -64909128,  -41858176,  398253664,  20661142,  -189285248,  -208144320,  1980359808},
    {-11697849,  133706992,  -65579560,  -34960012,  399594624,  17324636,  -192943088,  -174134880,  1990369664},
    {-9362556,  133890784,  -66129224,  -28019252,  400693888,  13929935,  -195949824,  -139755008,  1998589184},
    {-7024411,  134033784,  -66557432,  -21044346,  401550304,  10488515,  -198297168,  -105077560,  2004999424},
    {-4684126,  134135976,  -66863648,  -14043818,  402162752,  7011926,  -199978640,  -70176320,  2009588352},
    {-2342414,  134197304,  -67047540,  -7026174,  402530496,  3511839,  -200989440,  -35125516,  2012346496},
    {-5,  134217728,  -67108864,  -17,  402653184,  8,  -201326592,  -88,  2013265920}
};
#endif
const float dirac_gains_trg_term[181][2] = 
{
    {-1.000000e+00f,8.742278e-08f},
@@ -4520,7 +4621,192 @@ const float dirac_gains_trg_term[181][2] =
    {9.998477e-01f,-1.745241e-02f},
    {1.000000e+00f,0.000000e+00f}
};
#ifdef IVAS_FLOAT_FIXED
const Word32 dirac_gains_trg_term_int[181][2] = //Q30
{
    {-1073741824,  93},
    {-1073578304,  -18739436},
    {-1073087680,  -37473000},
    {-1072270272,  -56195404},
    {-1071126272,  -74900440},
    {-1069655936,  -93582656},
    {-1067859776,  -112236624},
    {-1065738240,  -130856168},
    {-1063292288,  -149436080},
    {-1060522368,  -167970160},
    {-1057429248,  -186453440},
    {-1054014208,  -204879600},
    {-1050278016,  -223243376},
    {-1046221952,  -241539408},
    {-1041847104,  -259761664},
    {-1037154944,  -277904896},
    {-1032146880,  -295963392},
    {-1026824448,  -313931616},
    {-1021189120,  -331804480},
    {-1015242880,  -349576096},
    {-1008987264,  -367241408},
    {-1002424448,  -384794592},
    {-995556160,  -402230656},
    {-988384640,  -419544416},
    {-980912000,  -436730112},
    {-973140608,  -453782944},
    {-965072832,  -470697376},
    {-956710976,  -487468704},
    {-948057792,  -504091296},
    {-939115840,  -520560224},
    {-929887680,  -536871040},
    {-920376384,  -553017856},
    {-910584576,  -568996544},
    {-900515712,  -584801664},
    {-890172480,  -600428672},
    {-879557888,  -615873088},
    {-868675520,  -631129536},
    {-857528320,  -646194048},
    {-846120128,  -661061376},
    {-834454080,  -675727744},
    {-822533888,  -690187904},
    {-810363392,  -704438016},
    {-797945664,  -718473536},
    {-785285056,  -732290112},
    {-772385152,  -745883904},
    {-759250176,  -759250176},
    {-745883904,  -772385152},
    {-732290112,  -785285056},
    {-718473600,  -797945664},
    {-704438016,  -810363392},
    {-690187904,  -822533888},
    {-675727552,  -834454144},
    {-661061376,  -846120128},
    {-646194048,  -857528320},
    {-631129536,  -868675392},
    {-615873088,  -879557760},
    {-600428672,  -890172352},
    {-584801792,  -900515712},
    {-568996544,  -910584576},
    {-553017856,  -920376384},
    {-536871040,  -929887680},
    {-520560224,  -939115776},
    {-504091296,  -948057792},
    {-487468704,  -956710976},
    {-470697376,  -965072832},
    {-453782944,  -973140608},
    {-436730208,  -980911936},
    {-419544416,  -988384640},
    {-402230784,  -995556160},
    {-384794592,  -1002424448},
    {-367241280,  -1008987264},
    {-349576096,  -1015242880},
    {-331804480,  -1021189120},
    {-313931712,  -1026824384},
    {-295963392,  -1032146880},
    {-277904800,  -1037154944},
    {-259761664,  -1041847104},
    {-241539296,  -1046221952},
    {-223243488,  -1050278016},
    {-204879600,  -1054014208},
    {-186453328,  -1057429248},
    {-167970160,  -1060522368},
    {-149435984,  -1063292288},
    {-130856168,  -1065738240},
    {-112236624,  -1067859776},
    {-93582792,  -1069655936},
    {-74900448,  -1071126272},
    {-56195288,  -1072270272},
    {-37473008,  -1073087680},
    {-18739318,  -1073578304},
    {-46,  -1073741824},
    {18739350,  -1073578304},
    {37473052,  -1073087680},
    {56195320,  -1072270272},
    {74900480,  -1071126272},
    {93582824,  -1069655936},
    {112236512,  -1067859776},
    {130856168,  -1065738240},
    {149435984,  -1063292288},
    {167970272,  -1060522368},
    {186453328,  -1057429248},
    {204879504,  -1054014208},
    {223243488,  -1050278016},
    {241539296,  -1046221952},
    {259761664,  -1041847104},
    {277904896,  -1037154944},
    {295963392,  -1032146880},
    {313931712,  -1026824448},
    {331804480,  -1021189120},
    {349576096,  -1015242880},
    {367241408,  -1008987264},
    {384794720,  -1002424320},
    {402230784,  -995556160},
    {419544320,  -988384640},
    {436730112,  -980912000},
    {453782848,  -973140608},
    {470697504,  -965072832},
    {487468576,  -956710976},
    {504091296,  -948057792},
    {520560352,  -939115776},
    {536870912,  -929887680},
    {553017920,  -920376384},
    {568996544,  -910584704},
    {584801664,  -900515712},
    {600428800,  -890172224},
    {615873088,  -879557888},
    {631129536,  -868675392},
    {646193920,  -857528320},
    {661061504,  -846120064},
    {675727616,  -834454144},
    {690187904,  -822533888},
    {704438016,  -810363136},
    {718473536,  -797945792},
    {732290176,  -785285056},
    {745883776,  -772385216},
    {759250176,  -759250176},
    {772385216,  -745883776},
    {785285056,  -732290112},
    {797945664,  -718473536},
    {810363264,  -704438016},
    {822533888,  -690187904},
    {834454144,  -675727616},
    {846120128,  -661061504},
    {857528320,  -646193920},
    {868675392,  -631129536},
    {879557888,  -615873088},
    {890172352,  -600428800},
    {900515712,  -584801792},
    {910584704,  -568996544},
    {920376384,  -553017920},
    {929887680,  -536870912},
    {939115776,  -520560352},
    {948057792,  -504091296},
    {956710976,  -487468576},
    {965072832,  -470697504},
    {973140608,  -453782944},
    {980911936,  -436730112},
    {988384640,  -419544320},
    {995556160,  -402230784},
    {1002424320,  -384794592},
    {1008987264,  -367241280},
    {1015242880,  -349576096},
    {1021189120,  -331804480},
    {1026824448,  -313931712},
    {1032146880,  -295963392},
    {1037154944,  -277904800},
    {1041847104,  -259761664},
    {1046221952,  -241539296},
    {1050278016,  -223243488},
    {1054014208,  -204879600},
    {1057429248,  -186453328},
    {1060522368,  -167970272},
    {1063292288,  -149435984},
    {1065738240,  -130856168},
    {1067859776,  -112236624},
    {1069655936,  -93582760},
    {1071126272,  -74900440},
    {1072270272,  -56195308},
    {1073087680,  -37473052},
    {1073578304,  -18739382},
    {1073741824,  0}
};
#endif
/*----------------------------------------------------------------------------------*
 * FB ROM tables
 *----------------------------------------------------------------------------------*/
Loading