Loading lib_dec/jbm_pcmdsp_similarityestimation.c +156 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ #include <stdint.h> #include "options.h" #include "wmc_auto.h" #include "basop_util.h" /* local headers */ #include "jbm_pcmdsp_similarityestimation.h" Loading Loading @@ -153,3 +154,158 @@ bool isSilence( return true; } Word16 normalized_cross_correlation_self_fx(const Word16 * signal, Word16 x, Word16 y, Word16 corr_len, Word16 subsampling, Word32 *energy) { const Word16 *signalX, *signalY; Word32 sumXY, sumXX, sumYY, product; Word16 sqrtXY, cc; Word16 i, normX, normY, normXY, normCC; signalX = &signal[x]; signalY = &signal[y]; sumXY = L_deposit_l(0); sumXX = L_deposit_l(0); sumYY = L_deposit_l(0); FOR(i = 0; i < corr_len; i += subsampling) { sumXY = L_mac0(sumXY, signalX[i], signalY[i]); sumXX = L_mac0(sumXX, signalX[i], signalX[i]); sumYY = L_mac0(sumYY, signalY[i], signalY[i]); } normX = norm_l(sumXX); sumXX = L_shl(sumXX, normX); normY = norm_l(sumYY); sumYY = L_shl(sumYY, normY); product = L_mult0(extract_h(sumXX), extract_h(sumYY)); normXY = add(normX, normY); normXY = sub(normXY, 32); /* change norm to factor of 2 */ IF( s_and(normXY, 0x1) != 0 ) { product = L_shr(product, 1); normXY = sub(normXY, 1); } sqrtXY = getSqrtWord32(product); normXY = shr(normXY, 1); IF(sqrtXY != 0) { normCC = 0; move16(); cc = BASOP_Util_Divide3216_Scale(sumXY, sqrtXY, &normCC); normCC = add(normCC, 16); /* scale to Q15 with saturation */ BASOP_SATURATE_WARNING_OFF cc = shl_r(cc, add(normXY, normCC)); BASOP_SATURATE_WARNING_ON *energy = L_shr_r(L_deposit_l(sqrtXY), normXY); } ELSE /* conceal silent frames */ { cc = 0; move16(); *energy = L_deposit_l(1); } return cc; /* Q15 */ } #ifdef IVAS_FLOAT_FIXED Word32 cross_correlation_self_fx(const Word16 * signal, Word16 x, Word16 y, Word16 corr_len) { Word32 sum; Word16 i; sum = L_deposit_l(0); FOR(i = 0; i < corr_len; i++) { sum = L_mac0(sum, signal[x + i], signal[y + i]); } return sum; } Word16 getSignalScaleForCorrelation(Word32 sampleRate) { Word16 ret; IF( LT_32(sampleRate, 16000)) { ret = 2; move16(); } ELSE IF( GE_32(sampleRate, 32000)) { ret = 4; move16(); } ELSE { ret = 3; move16(); } return ret; } Word8 isSilence_fx(const Word16 * signal, Word16 len, Word16 segments) { Word16 i, j, samplesPerSegment; Word32 energy, maxEnergy; Word8 ret; assert(len > 0); assert(segments > 0); /* Every segment is checked using the following formula: * 10 * log10(sum_i(signal[i]*signal[i]))) > -65 * For simplification/complexity, this is replaced by: * 20 * log10(sum_i(abs(signal[i]))) > -65 */ ret = 1; move16(); energy = L_deposit_l(0); samplesPerSegment = idiv1616U(len, segments); /* calculate maxEnergy with factor 2 to reduce rounding error */ maxEnergy = L_mult0(samplesPerSegment, 37); /* 37 = 2 * exp10(-65.0 / 20) * 32768 */ maxEnergy = L_shr(maxEnergy, 1); j = samplesPerSegment; move16(); /* check all but last segment */ FOR(i = 0; i < len; i++) { /* division by 32768 is done later */ energy = L_add(energy, L_abs(L_deposit_l(signal[i]))); IF( EQ_16(i, j)) { /* check energy of current segment */ /* 20 * log10(energy / 32768 / samplesPerSegment) > -65 * => energy > samplesPerSegment * 10 ^ (-65 / 20) * 32768 */ IF( GT_32(energy, maxEnergy)) { ret = 0; move16(); BREAK; } energy = L_deposit_l(0); j = add(j, samplesPerSegment); } } /* check last segment */ if( GT_32(energy, maxEnergy)) { ret = 0; move16(); } return ret; } #endif lib_dec/jbm_pcmdsp_similarityestimation.h +22 −0 Original line number Diff line number Diff line Loading @@ -155,4 +155,26 @@ bool isSilence( uint32_t len, uint32_t segments ); #ifdef IVAS_FLOAT_FIXED void scaleSignal16(const Word16 *src, Word16 *dst, Word16 n, Word16 rightShift); Word32 cross_correlation_subsampled_self_fx(const Word16 * signal, Word16 x, Word16 y, Word16 corr_len, Word16 subsampling); Word16 normalized_cross_correlation_self_fx(const Word16 * signal, Word16 x, Word16 y, Word16 corr_len, Word16 subsampling, Word32 * energy ); Word32 cross_correlation_self_fx(const Word16 * signal, Word16 x, Word16 y, Word16 corr_len); Word16 getSignalScaleForCorrelation(Word32 sampleRate); Word8 isSilence_fx(const Word16 * signal, Word16 len, Word16 segments); #endif /* IVAS_FLOAT_FIXED */ #endif /* JBM_PCMDSP_SIMILARITYESTIMATION_H */ lib_dec/jbm_pcmdsp_window.c +65 −0 Original line number Diff line number Diff line Loading @@ -154,3 +154,68 @@ void overlapAddEvs( return; } #ifdef IVAS_FLOAT_FIXED void overlapAdd_fx(const Word16 *fadeOut, const Word16 *fadeIn, Word16 *out, Word16 n, Word16 nChannels, const Word16 *fadeOutWin, const Word16 *fadeInWin ) { Word32 fdOutVal, fdInVal; Word16 i, j, hannIter, combinedVal; FOR(j = 0; j < nChannels; j++) { /* reset Hann window iterator to beginning (both channels use same window) */ hannIter = 0; move16(); FOR( i = j; i < n; i += nChannels ) { fdOutVal = L_mult( fadeOut[i], fadeOutWin[hannIter] ); fdInVal = L_mult( fadeIn[i], fadeInWin[hannIter] ); /* round to 16bit value and saturate (L_add already applies saturation) */ combinedVal = round_fx( L_add( fdOutVal, fdInVal ) ); out[i] = combinedVal; move16(); /* advance the Hann window iterator by incrementor (dependent on sample rate). */ hannIter = add( hannIter, 1 ); } } } void overlapAddEvs_fx( const Word16 *fadeOut, const Word16 *fadeIn, Word16 *out, UWord16 n, UWord16 nChannels, const Word16 *fadeOutWin, const Word16 *fadeInWin ) { Word32 fdOutVal, fdInVal; Word16 i, j, hannIter, combinedVal; FOR ( j = 0; j < nChannels; j++ ) { /* reset Hann window iterator to beginning (both channels use same window) */ hannIter = 0; FOR ( i = j; i < n; i += nChannels ) { fdOutVal = L_mult( fadeOut[i], fadeOutWin[hannIter] ); fdInVal = L_mult( fadeIn[i], fadeInWin[hannIter] ); /* round combinedVal value (taking care of sign) */ combinedVal = round_fx(L_add(fdOutVal, fdInVal)); IF ( L_add( fdInVal, fdOutVal ) < 0 ) { combinedVal = round_fx(L_add(fdOutVal, fdInVal)); } out[i] = combinedVal; hannIter = add( hannIter, 1 ); } } return; } #endif No newline at end of file lib_dec/jbm_pcmdsp_window.h +8 −0 Original line number Diff line number Diff line Loading @@ -63,4 +63,12 @@ void hannWindow( uint16_t n, float *w ); * @param[in] fadeInWin window for fade in */ void overlapAdd( const float *fadeOut, const float *fadeIn, float *out, uint16_t n, uint16_t nChannels, const float *fadeOutWin, const float *fadeInWin ); void overlapAddEvs( const float *fadeOut, const float *fadeIn, float *out, uint16_t n, uint16_t nChannels, const float *fadeOutWin, const float *fadeInWin ); #ifdef IVAS_FLOAT_FIXED void overlapAdd_fx(const Word16 *fadeOut, const Word16 *fadeIn, Word16 *out, Word16 n, Word16 nChannels, const Word16 *fadeOutWin, const Word16 *fadeInWin ); void overlapAdd_fx(const Word16 *fadeOut, const Word16 *fadeIn, Word16 *out, Word16 n, Word16 nChannels, const Word16 *fadeOutWin, const Word16 *fadeInWin ); #endif /* IVAS_FLOAT_FIXED */ #endif /* JBM_PCMDSP_WINDOW_H */ lib_dec/rom_dec.c +118 −0 Original line number Diff line number Diff line Loading @@ -479,3 +479,121 @@ const Word16 T_256DIV_L_Frame[] = ,26214 /*L_Frame 160*/ }; /* clang-format on */ /* Word16 (Q15) Hann window ranging from 0 to 32767/32768 (~0.999969) */ const Word16 pcmdsp_window_hann_960[960] = { 0, 0, 1, 3, 6, 9, 13, 17, 22, 28, 35, 42, 51, 59, 69, 79, 90, 101, 114, 127, 140, 155, 170, 185, 202, 219, 237, 255, 274, 294, 315, 336, 358, 381, 404, 428, 453, 478, 504, 531, 558, 586, 615, 645, 675, 705, 737, 769, 802, 835, 869, 904, 940, 976, 1013, 1050, 1088, 1127, 1166, 1206, 1247, 1289, 1331, 1373, 1416, 1460, 1505, 1550, 1596, 1643, 1690, 1737, 1786, 1835, 1884, 1935, 1985, 2037, 2089, 2142, 2195, 2249, 2303, 2359, 2414, 2471, 2528, 2585, 2643, 2702, 2761, 2821, 2882, 2943, 3004, 3066, 3129, 3192, 3256, 3321, 3386, 3451, 3517, 3584, 3651, 3719, 3787, 3856, 3926, 3995, 4066, 4137, 4208, 4280, 4353, 4426, 4499, 4574, 4648, 4723, 4799, 4875, 4951, 5028, 5106, 5184, 5263, 5342, 5421, 5501, 5581, 5662, 5743, 5825, 5907, 5990, 6073, 6157, 6241, 6325, 6410, 6495, 6581, 6667, 6754, 6841, 6928, 7016, 7104, 7193, 7282, 7371, 7461, 7551, 7641, 7732, 7823, 7915, 8007, 8099, 8192, 8285, 8378, 8472, 8566, 8661, 8755, 8850, 8946, 9042, 9138, 9234, 9331, 9427, 9525, 9622, 9720, 9818, 9917,10015, 10114,10213,10313,10413,10512,10613,10713,10814,10915,11016,11118,11219,11321,11423,11525, 11628,11731,11834,11937,12040,12144,12247,12351,12455,12559,12664,12768,12873,12978,13083, 13188,13293,13398,13504,13609,13715,13821,13927,14033,14139,14245,14352,14458,14565,14671, 14778,14885,14992,15099,15205,15312,15419,15527,15634,15741,15848,15955,16062,16170,16277, 16384,16491,16598,16706,16813,16920,17027,17134,17241,17349,17456,17563,17669,17776,17883, 17990,18097,18203,18310,18416,18523,18629,18735,18841,18947,19053,19159,19264,19370,19475, 19580,19685,19790,19895,20000,20104,20209,20313,20417,20521,20624,20728,20831,20934,21037, 21140,21243,21345,21447,21549,21650,21752,21853,21954,22055,22155,22256,22355,22455,22555, 22654,22753,22851,22950,23048,23146,23243,23341,23437,23534,23630,23726,23822,23918,24013, 24107,24202,24296,24390,24483,24576,24669,24761,24853,24945,25036,25127,25217,25307,25397, 25486,25575,25664,25752,25840,25927,26014,26101,26187,26273,26358,26443,26527,26611,26695, 26778,26861,26943,27025,27106,27187,27267,27347,27426,27505,27584,27662,27740,27817,27893, 27969,28045,28120,28194,28269,28342,28415,28488,28560,28631,28702,28773,28842,28912,28981, 29049,29117,29184,29251,29317,29382,29447,29512,29576,29639,29702,29764,29825,29886,29947, 30007,30066,30125,30183,30240,30297,30354,30409,30465,30519,30573,30626,30679,30731,30783, 30833,30884,30933,30982,31031,31078,31125,31172,31218,31263,31308,31352,31395,31437,31479, 31521,31562,31602,31641,31680,31718,31755,31792,31828,31864,31899,31933,31966,31999,32031, 32063,32093,32123,32153,32182,32210,32237,32264,32290,32315,32340,32364,32387,32410,32432, 32453,32474,32494,32513,32531,32549,32566,32583,32598,32613,32628,32641,32654,32667,32678, 32689,32699,32709,32717,32726,32733,32740,32746,32751,32755,32759,32762,32765,32767,32767, 32767,32767,32766,32764,32761,32758,32754,32750,32745,32739,32732,32725,32716,32708,32698, 32688,32677,32666,32653,32640,32627,32612,32597,32582,32565,32548,32530,32512,32493,32473, 32452,32431,32409,32386,32363,32339,32314,32289,32263,32236,32209,32181,32152,32122,32092, 32062,32030,31998,31965,31932,31898,31863,31827,31791,31754,31717,31679,31640,31601,31561, 31520,31478,31436,31394,31351,31307,31262,31217,31171,31124,31077,31030,30981,30932,30883, 30832,30782,30730,30678,30625,30572,30518,30464,30408,30353,30296,30239,30182,30124,30065, 30006,29946,29885,29824,29763,29701,29638,29575,29511,29446,29381,29316,29250,29183,29116, 29048,28980,28911,28841,28772,28701,28630,28559,28487,28414,28341,28268,28193,28119,28044, 27968,27892,27816,27739,27661,27583,27504,27425,27346,27266,27186,27105,27024,26942,26860, 26777,26694,26610,26526,26442,26357,26272,26186,26100,26013,25926,25839,25751,25663,25574, 25485,25396,25306,25216,25126,25035,24944,24852,24760,24668,24575,24482,24389,24295,24201, 24106,24012,23917,23821,23725,23629,23533,23436,23340,23242,23145,23047,22949,22850,22752, 22653,22554,22454,22354,22255,22154,22054,21953,21852,21751,21649,21548,21446,21344,21242, 21139,21036,20933,20830,20727,20623,20520,20416,20312,20208,20103,19999,19894,19789,19684, 19579,19474,19369,19263,19158,19052,18946,18840,18734,18628,18522,18415,18309,18202,18096, 17989,17882,17775,17668,17562,17455,17348,17240,17133,17026,16919,16812,16705,16597,16490, 16383,16276,16169,16061,15954,15847,15740,15633,15526,15418,15311,15204,15098,14991,14884, 14777,14670,14564,14457,14351,14244,14138,14032,13926,13820,13714,13608,13503,13397,13292, 13187,13082,12977,12872,12767,12663,12558,12454,12350,12246,12143,12039,11936,11833,11730, 11627,11524,11422,11320,11218,11117,11015,10914,10813,10712,10612,10511,10412,10312,10212, 10113,10014,9916, 9817, 9719, 9621, 9524, 9426, 9330, 9233, 9137, 9041, 8945, 8849, 8754, 8660, 8565, 8471, 8377, 8284, 8191, 8098, 8006, 7914, 7822, 7731, 7640, 7550, 7460, 7370, 7281, 7192, 7103, 7015, 6927, 6840, 6753, 6666, 6580, 6494, 6409, 6324, 6240, 6156, 6072, 5989, 5906, 5824, 5742, 5661, 5580, 5500, 5420, 5341, 5262, 5183, 5105, 5027, 4950, 4874, 4798, 4722, 4647, 4573, 4498, 4425, 4352, 4279, 4207, 4136, 4065, 3994, 3925, 3855, 3786, 3718, 3650, 3583, 3516, 3450, 3385, 3320, 3255, 3191, 3128, 3065, 3003, 2942, 2881, 2820, 2760, 2701, 2642, 2584, 2527, 2470, 2413, 2358, 2302, 2248, 2194, 2141, 2088, 2036, 1984, 1934, 1883, 1834, 1785, 1736, 1689, 1642, 1595, 1549, 1504, 1459, 1415, 1372, 1330, 1288, 1246, 1205, 1165, 1126, 1087, 1049, 1012, 975, 939, 903, 868, 834, 801, 768, 736, 704, 674, 644, 614, 585, 557, 530, 503, 477, 452, 427, 403, 380, 357, 335, 314, 293, 273, 254, 236, 218, 201, 184, 169, 154, 139, 126, 113, 100, 89, 78, 68, 58, 50, 41, 34, 27, 21, 16, 12, 8, 5, 2, 0, 0 }; /* Word16 (Q15) Hann window ranging from 0 to 32767/32768 (~0.999969) */ const Word16 pcmdsp_window_hann_640[640] = { 0, 1, 3, 7, 13, 20, 28, 39, 51, 64, 79, 95, 114, 133, 155, 177, 202, 228, 255, 284, 315, 347, 381, 416, 453, 491, 531, 572, 615, 660, 705, 753, 802, 852, 904, 958, 1013, 1069, 1127, 1186, 1247, 1309, 1373, 1438, 1505, 1573, 1643, 1713, 1786, 1859, 1935, 2011, 2089, 2168, 2249, 2331, 2414, 2499, 2585, 2672, 2761, 2851, 2943, 3035, 3129, 3224, 3321, 3418, 3517, 3618, 3719, 3822, 3926, 4031, 4137, 4244, 4353, 4463, 4574, 4686, 4799, 4913, 5028, 5145, 5263, 5381, 5501, 5622, 5743, 5866, 5990, 6115, 6241, 6368, 6495, 6624, 6754, 6884, 7016, 7148, 7282, 7416, 7551, 7687, 7823, 7961, 8099, 8238, 8378, 8519, 8661, 8803, 8946, 9089, 9234, 9379, 9525, 9671, 9818, 9966, 10114,10263,10413,10563,10713,10864,11016,11168,11321,11474,11628,11782,11937,12092,12247, 12403,12559,12716,12873,13030,13188,13346,13504,13662,13821,13980,14139,14299,14458,14618, 14778,14938,15099,15259,15419,15580,15741,15902,16062,16223,16384,16545,16706,16866,17027, 17188,17349,17509,17669,17830,17990,18150,18310,18469,18629,18788,18947,19106,19264,19422, 19580,19738,19895,20052,20209,20365,20521,20676,20831,20986,21140,21294,21447,21600,21752, 21904,22055,22205,22355,22505,22654,22802,22950,23097,23243,23389,23534,23679,23822,23965, 24107,24249,24390,24530,24669,24807,24945,25081,25217,25352,25486,25620,25752,25884,26014, 26144,26273,26400,26527,26653,26778,26902,27025,27146,27267,27387,27505,27623,27740,27855, 27969,28082,28194,28305,28415,28524,28631,28737,28842,28946,29049,29150,29251,29350,29447, 29544,29639,29733,29825,29917,30007,30096,30183,30269,30354,30437,30519,30600,30679,30757, 30833,30909,30982,31055,31125,31195,31263,31330,31395,31459,31521,31582,31641,31699,31755, 31810,31864,31916,31966,32015,32063,32108,32153,32196,32237,32277,32315,32352,32387,32421, 32453,32484,32513,32540,32566,32591,32613,32635,32654,32673,32689,32704,32717,32729,32740, 32748,32755,32761,32765,32767,32767,32766,32764,32760,32754,32747,32739,32728,32716,32703, 32688,32672,32653,32634,32612,32590,32565,32539,32512,32483,32452,32420,32386,32351,32314, 32276,32236,32195,32152,32107,32062,32014,31965,31915,31863,31809,31754,31698,31640,31581, 31520,31458,31394,31329,31262,31194,31124,31054,30981,30908,30832,30756,30678,30599,30518, 30436,30353,30268,30182,30095,30006,29916,29824,29732,29638,29543,29446,29349,29250,29149, 29048,28945,28841,28736,28630,28523,28414,28304,28193,28081,27968,27854,27739,27622,27504, 27386,27266,27145,27024,26901,26777,26652,26526,26399,26272,26143,26013,25883,25751,25619, 25485,25351,25216,25080,24944,24806,24668,24529,24389,24248,24106,23964,23821,23678,23533, 23388,23242,23096,22949,22801,22653,22504,22354,22204,22054,21903,21751,21599,21446,21293, 21139,20985,20830,20675,20520,20364,20208,20051,19894,19737,19579,19421,19263,19105,18946, 18787,18628,18468,18309,18149,17989,17829,17668,17508,17348,17187,17026,16865,16705,16544, 16383,16222,16061,15901,15740,15579,15418,15258,15098,14937,14777,14617,14457,14298,14138, 13979,13820,13661,13503,13345,13187,13029,12872,12715,12558,12402,12246,12091,11936,11781, 11627,11473,11320,11167,11015,10863,10712,10562,10412,10262,10113, 9965, 9817, 9670, 9524, 9378, 9233, 9088, 8945, 8802, 8660, 8518, 8377, 8237, 8098, 7960, 7822, 7686, 7550, 7415, 7281, 7147, 7015, 6883, 6753, 6623, 6494, 6367, 6240, 6114, 5989, 5865, 5742, 5621, 5500, 5380, 5262, 5144, 5027, 4912, 4798, 4685, 4573, 4462, 4352, 4243, 4136, 4030, 3925, 3821, 3718, 3617, 3516, 3417, 3320, 3223, 3128, 3034, 2942, 2850, 2760, 2671, 2584, 2498, 2413, 2330, 2248, 2167, 2088, 2010, 1934, 1858, 1785, 1712, 1642, 1572, 1504, 1437, 1372, 1308, 1246, 1185, 1126, 1068, 1012, 957, 903, 851, 801, 752, 704, 659, 614, 571, 530, 490, 452, 415, 380, 346, 314, 283, 254, 227, 201, 176, 154, 132, 113, 94, 78, 63, 50, 38, 27, 19, 12, 6, 2, 0 }; Loading
lib_dec/jbm_pcmdsp_similarityestimation.c +156 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ #include <stdint.h> #include "options.h" #include "wmc_auto.h" #include "basop_util.h" /* local headers */ #include "jbm_pcmdsp_similarityestimation.h" Loading Loading @@ -153,3 +154,158 @@ bool isSilence( return true; } Word16 normalized_cross_correlation_self_fx(const Word16 * signal, Word16 x, Word16 y, Word16 corr_len, Word16 subsampling, Word32 *energy) { const Word16 *signalX, *signalY; Word32 sumXY, sumXX, sumYY, product; Word16 sqrtXY, cc; Word16 i, normX, normY, normXY, normCC; signalX = &signal[x]; signalY = &signal[y]; sumXY = L_deposit_l(0); sumXX = L_deposit_l(0); sumYY = L_deposit_l(0); FOR(i = 0; i < corr_len; i += subsampling) { sumXY = L_mac0(sumXY, signalX[i], signalY[i]); sumXX = L_mac0(sumXX, signalX[i], signalX[i]); sumYY = L_mac0(sumYY, signalY[i], signalY[i]); } normX = norm_l(sumXX); sumXX = L_shl(sumXX, normX); normY = norm_l(sumYY); sumYY = L_shl(sumYY, normY); product = L_mult0(extract_h(sumXX), extract_h(sumYY)); normXY = add(normX, normY); normXY = sub(normXY, 32); /* change norm to factor of 2 */ IF( s_and(normXY, 0x1) != 0 ) { product = L_shr(product, 1); normXY = sub(normXY, 1); } sqrtXY = getSqrtWord32(product); normXY = shr(normXY, 1); IF(sqrtXY != 0) { normCC = 0; move16(); cc = BASOP_Util_Divide3216_Scale(sumXY, sqrtXY, &normCC); normCC = add(normCC, 16); /* scale to Q15 with saturation */ BASOP_SATURATE_WARNING_OFF cc = shl_r(cc, add(normXY, normCC)); BASOP_SATURATE_WARNING_ON *energy = L_shr_r(L_deposit_l(sqrtXY), normXY); } ELSE /* conceal silent frames */ { cc = 0; move16(); *energy = L_deposit_l(1); } return cc; /* Q15 */ } #ifdef IVAS_FLOAT_FIXED Word32 cross_correlation_self_fx(const Word16 * signal, Word16 x, Word16 y, Word16 corr_len) { Word32 sum; Word16 i; sum = L_deposit_l(0); FOR(i = 0; i < corr_len; i++) { sum = L_mac0(sum, signal[x + i], signal[y + i]); } return sum; } Word16 getSignalScaleForCorrelation(Word32 sampleRate) { Word16 ret; IF( LT_32(sampleRate, 16000)) { ret = 2; move16(); } ELSE IF( GE_32(sampleRate, 32000)) { ret = 4; move16(); } ELSE { ret = 3; move16(); } return ret; } Word8 isSilence_fx(const Word16 * signal, Word16 len, Word16 segments) { Word16 i, j, samplesPerSegment; Word32 energy, maxEnergy; Word8 ret; assert(len > 0); assert(segments > 0); /* Every segment is checked using the following formula: * 10 * log10(sum_i(signal[i]*signal[i]))) > -65 * For simplification/complexity, this is replaced by: * 20 * log10(sum_i(abs(signal[i]))) > -65 */ ret = 1; move16(); energy = L_deposit_l(0); samplesPerSegment = idiv1616U(len, segments); /* calculate maxEnergy with factor 2 to reduce rounding error */ maxEnergy = L_mult0(samplesPerSegment, 37); /* 37 = 2 * exp10(-65.0 / 20) * 32768 */ maxEnergy = L_shr(maxEnergy, 1); j = samplesPerSegment; move16(); /* check all but last segment */ FOR(i = 0; i < len; i++) { /* division by 32768 is done later */ energy = L_add(energy, L_abs(L_deposit_l(signal[i]))); IF( EQ_16(i, j)) { /* check energy of current segment */ /* 20 * log10(energy / 32768 / samplesPerSegment) > -65 * => energy > samplesPerSegment * 10 ^ (-65 / 20) * 32768 */ IF( GT_32(energy, maxEnergy)) { ret = 0; move16(); BREAK; } energy = L_deposit_l(0); j = add(j, samplesPerSegment); } } /* check last segment */ if( GT_32(energy, maxEnergy)) { ret = 0; move16(); } return ret; } #endif
lib_dec/jbm_pcmdsp_similarityestimation.h +22 −0 Original line number Diff line number Diff line Loading @@ -155,4 +155,26 @@ bool isSilence( uint32_t len, uint32_t segments ); #ifdef IVAS_FLOAT_FIXED void scaleSignal16(const Word16 *src, Word16 *dst, Word16 n, Word16 rightShift); Word32 cross_correlation_subsampled_self_fx(const Word16 * signal, Word16 x, Word16 y, Word16 corr_len, Word16 subsampling); Word16 normalized_cross_correlation_self_fx(const Word16 * signal, Word16 x, Word16 y, Word16 corr_len, Word16 subsampling, Word32 * energy ); Word32 cross_correlation_self_fx(const Word16 * signal, Word16 x, Word16 y, Word16 corr_len); Word16 getSignalScaleForCorrelation(Word32 sampleRate); Word8 isSilence_fx(const Word16 * signal, Word16 len, Word16 segments); #endif /* IVAS_FLOAT_FIXED */ #endif /* JBM_PCMDSP_SIMILARITYESTIMATION_H */
lib_dec/jbm_pcmdsp_window.c +65 −0 Original line number Diff line number Diff line Loading @@ -154,3 +154,68 @@ void overlapAddEvs( return; } #ifdef IVAS_FLOAT_FIXED void overlapAdd_fx(const Word16 *fadeOut, const Word16 *fadeIn, Word16 *out, Word16 n, Word16 nChannels, const Word16 *fadeOutWin, const Word16 *fadeInWin ) { Word32 fdOutVal, fdInVal; Word16 i, j, hannIter, combinedVal; FOR(j = 0; j < nChannels; j++) { /* reset Hann window iterator to beginning (both channels use same window) */ hannIter = 0; move16(); FOR( i = j; i < n; i += nChannels ) { fdOutVal = L_mult( fadeOut[i], fadeOutWin[hannIter] ); fdInVal = L_mult( fadeIn[i], fadeInWin[hannIter] ); /* round to 16bit value and saturate (L_add already applies saturation) */ combinedVal = round_fx( L_add( fdOutVal, fdInVal ) ); out[i] = combinedVal; move16(); /* advance the Hann window iterator by incrementor (dependent on sample rate). */ hannIter = add( hannIter, 1 ); } } } void overlapAddEvs_fx( const Word16 *fadeOut, const Word16 *fadeIn, Word16 *out, UWord16 n, UWord16 nChannels, const Word16 *fadeOutWin, const Word16 *fadeInWin ) { Word32 fdOutVal, fdInVal; Word16 i, j, hannIter, combinedVal; FOR ( j = 0; j < nChannels; j++ ) { /* reset Hann window iterator to beginning (both channels use same window) */ hannIter = 0; FOR ( i = j; i < n; i += nChannels ) { fdOutVal = L_mult( fadeOut[i], fadeOutWin[hannIter] ); fdInVal = L_mult( fadeIn[i], fadeInWin[hannIter] ); /* round combinedVal value (taking care of sign) */ combinedVal = round_fx(L_add(fdOutVal, fdInVal)); IF ( L_add( fdInVal, fdOutVal ) < 0 ) { combinedVal = round_fx(L_add(fdOutVal, fdInVal)); } out[i] = combinedVal; hannIter = add( hannIter, 1 ); } } return; } #endif No newline at end of file
lib_dec/jbm_pcmdsp_window.h +8 −0 Original line number Diff line number Diff line Loading @@ -63,4 +63,12 @@ void hannWindow( uint16_t n, float *w ); * @param[in] fadeInWin window for fade in */ void overlapAdd( const float *fadeOut, const float *fadeIn, float *out, uint16_t n, uint16_t nChannels, const float *fadeOutWin, const float *fadeInWin ); void overlapAddEvs( const float *fadeOut, const float *fadeIn, float *out, uint16_t n, uint16_t nChannels, const float *fadeOutWin, const float *fadeInWin ); #ifdef IVAS_FLOAT_FIXED void overlapAdd_fx(const Word16 *fadeOut, const Word16 *fadeIn, Word16 *out, Word16 n, Word16 nChannels, const Word16 *fadeOutWin, const Word16 *fadeInWin ); void overlapAdd_fx(const Word16 *fadeOut, const Word16 *fadeIn, Word16 *out, Word16 n, Word16 nChannels, const Word16 *fadeOutWin, const Word16 *fadeInWin ); #endif /* IVAS_FLOAT_FIXED */ #endif /* JBM_PCMDSP_WINDOW_H */
lib_dec/rom_dec.c +118 −0 Original line number Diff line number Diff line Loading @@ -479,3 +479,121 @@ const Word16 T_256DIV_L_Frame[] = ,26214 /*L_Frame 160*/ }; /* clang-format on */ /* Word16 (Q15) Hann window ranging from 0 to 32767/32768 (~0.999969) */ const Word16 pcmdsp_window_hann_960[960] = { 0, 0, 1, 3, 6, 9, 13, 17, 22, 28, 35, 42, 51, 59, 69, 79, 90, 101, 114, 127, 140, 155, 170, 185, 202, 219, 237, 255, 274, 294, 315, 336, 358, 381, 404, 428, 453, 478, 504, 531, 558, 586, 615, 645, 675, 705, 737, 769, 802, 835, 869, 904, 940, 976, 1013, 1050, 1088, 1127, 1166, 1206, 1247, 1289, 1331, 1373, 1416, 1460, 1505, 1550, 1596, 1643, 1690, 1737, 1786, 1835, 1884, 1935, 1985, 2037, 2089, 2142, 2195, 2249, 2303, 2359, 2414, 2471, 2528, 2585, 2643, 2702, 2761, 2821, 2882, 2943, 3004, 3066, 3129, 3192, 3256, 3321, 3386, 3451, 3517, 3584, 3651, 3719, 3787, 3856, 3926, 3995, 4066, 4137, 4208, 4280, 4353, 4426, 4499, 4574, 4648, 4723, 4799, 4875, 4951, 5028, 5106, 5184, 5263, 5342, 5421, 5501, 5581, 5662, 5743, 5825, 5907, 5990, 6073, 6157, 6241, 6325, 6410, 6495, 6581, 6667, 6754, 6841, 6928, 7016, 7104, 7193, 7282, 7371, 7461, 7551, 7641, 7732, 7823, 7915, 8007, 8099, 8192, 8285, 8378, 8472, 8566, 8661, 8755, 8850, 8946, 9042, 9138, 9234, 9331, 9427, 9525, 9622, 9720, 9818, 9917,10015, 10114,10213,10313,10413,10512,10613,10713,10814,10915,11016,11118,11219,11321,11423,11525, 11628,11731,11834,11937,12040,12144,12247,12351,12455,12559,12664,12768,12873,12978,13083, 13188,13293,13398,13504,13609,13715,13821,13927,14033,14139,14245,14352,14458,14565,14671, 14778,14885,14992,15099,15205,15312,15419,15527,15634,15741,15848,15955,16062,16170,16277, 16384,16491,16598,16706,16813,16920,17027,17134,17241,17349,17456,17563,17669,17776,17883, 17990,18097,18203,18310,18416,18523,18629,18735,18841,18947,19053,19159,19264,19370,19475, 19580,19685,19790,19895,20000,20104,20209,20313,20417,20521,20624,20728,20831,20934,21037, 21140,21243,21345,21447,21549,21650,21752,21853,21954,22055,22155,22256,22355,22455,22555, 22654,22753,22851,22950,23048,23146,23243,23341,23437,23534,23630,23726,23822,23918,24013, 24107,24202,24296,24390,24483,24576,24669,24761,24853,24945,25036,25127,25217,25307,25397, 25486,25575,25664,25752,25840,25927,26014,26101,26187,26273,26358,26443,26527,26611,26695, 26778,26861,26943,27025,27106,27187,27267,27347,27426,27505,27584,27662,27740,27817,27893, 27969,28045,28120,28194,28269,28342,28415,28488,28560,28631,28702,28773,28842,28912,28981, 29049,29117,29184,29251,29317,29382,29447,29512,29576,29639,29702,29764,29825,29886,29947, 30007,30066,30125,30183,30240,30297,30354,30409,30465,30519,30573,30626,30679,30731,30783, 30833,30884,30933,30982,31031,31078,31125,31172,31218,31263,31308,31352,31395,31437,31479, 31521,31562,31602,31641,31680,31718,31755,31792,31828,31864,31899,31933,31966,31999,32031, 32063,32093,32123,32153,32182,32210,32237,32264,32290,32315,32340,32364,32387,32410,32432, 32453,32474,32494,32513,32531,32549,32566,32583,32598,32613,32628,32641,32654,32667,32678, 32689,32699,32709,32717,32726,32733,32740,32746,32751,32755,32759,32762,32765,32767,32767, 32767,32767,32766,32764,32761,32758,32754,32750,32745,32739,32732,32725,32716,32708,32698, 32688,32677,32666,32653,32640,32627,32612,32597,32582,32565,32548,32530,32512,32493,32473, 32452,32431,32409,32386,32363,32339,32314,32289,32263,32236,32209,32181,32152,32122,32092, 32062,32030,31998,31965,31932,31898,31863,31827,31791,31754,31717,31679,31640,31601,31561, 31520,31478,31436,31394,31351,31307,31262,31217,31171,31124,31077,31030,30981,30932,30883, 30832,30782,30730,30678,30625,30572,30518,30464,30408,30353,30296,30239,30182,30124,30065, 30006,29946,29885,29824,29763,29701,29638,29575,29511,29446,29381,29316,29250,29183,29116, 29048,28980,28911,28841,28772,28701,28630,28559,28487,28414,28341,28268,28193,28119,28044, 27968,27892,27816,27739,27661,27583,27504,27425,27346,27266,27186,27105,27024,26942,26860, 26777,26694,26610,26526,26442,26357,26272,26186,26100,26013,25926,25839,25751,25663,25574, 25485,25396,25306,25216,25126,25035,24944,24852,24760,24668,24575,24482,24389,24295,24201, 24106,24012,23917,23821,23725,23629,23533,23436,23340,23242,23145,23047,22949,22850,22752, 22653,22554,22454,22354,22255,22154,22054,21953,21852,21751,21649,21548,21446,21344,21242, 21139,21036,20933,20830,20727,20623,20520,20416,20312,20208,20103,19999,19894,19789,19684, 19579,19474,19369,19263,19158,19052,18946,18840,18734,18628,18522,18415,18309,18202,18096, 17989,17882,17775,17668,17562,17455,17348,17240,17133,17026,16919,16812,16705,16597,16490, 16383,16276,16169,16061,15954,15847,15740,15633,15526,15418,15311,15204,15098,14991,14884, 14777,14670,14564,14457,14351,14244,14138,14032,13926,13820,13714,13608,13503,13397,13292, 13187,13082,12977,12872,12767,12663,12558,12454,12350,12246,12143,12039,11936,11833,11730, 11627,11524,11422,11320,11218,11117,11015,10914,10813,10712,10612,10511,10412,10312,10212, 10113,10014,9916, 9817, 9719, 9621, 9524, 9426, 9330, 9233, 9137, 9041, 8945, 8849, 8754, 8660, 8565, 8471, 8377, 8284, 8191, 8098, 8006, 7914, 7822, 7731, 7640, 7550, 7460, 7370, 7281, 7192, 7103, 7015, 6927, 6840, 6753, 6666, 6580, 6494, 6409, 6324, 6240, 6156, 6072, 5989, 5906, 5824, 5742, 5661, 5580, 5500, 5420, 5341, 5262, 5183, 5105, 5027, 4950, 4874, 4798, 4722, 4647, 4573, 4498, 4425, 4352, 4279, 4207, 4136, 4065, 3994, 3925, 3855, 3786, 3718, 3650, 3583, 3516, 3450, 3385, 3320, 3255, 3191, 3128, 3065, 3003, 2942, 2881, 2820, 2760, 2701, 2642, 2584, 2527, 2470, 2413, 2358, 2302, 2248, 2194, 2141, 2088, 2036, 1984, 1934, 1883, 1834, 1785, 1736, 1689, 1642, 1595, 1549, 1504, 1459, 1415, 1372, 1330, 1288, 1246, 1205, 1165, 1126, 1087, 1049, 1012, 975, 939, 903, 868, 834, 801, 768, 736, 704, 674, 644, 614, 585, 557, 530, 503, 477, 452, 427, 403, 380, 357, 335, 314, 293, 273, 254, 236, 218, 201, 184, 169, 154, 139, 126, 113, 100, 89, 78, 68, 58, 50, 41, 34, 27, 21, 16, 12, 8, 5, 2, 0, 0 }; /* Word16 (Q15) Hann window ranging from 0 to 32767/32768 (~0.999969) */ const Word16 pcmdsp_window_hann_640[640] = { 0, 1, 3, 7, 13, 20, 28, 39, 51, 64, 79, 95, 114, 133, 155, 177, 202, 228, 255, 284, 315, 347, 381, 416, 453, 491, 531, 572, 615, 660, 705, 753, 802, 852, 904, 958, 1013, 1069, 1127, 1186, 1247, 1309, 1373, 1438, 1505, 1573, 1643, 1713, 1786, 1859, 1935, 2011, 2089, 2168, 2249, 2331, 2414, 2499, 2585, 2672, 2761, 2851, 2943, 3035, 3129, 3224, 3321, 3418, 3517, 3618, 3719, 3822, 3926, 4031, 4137, 4244, 4353, 4463, 4574, 4686, 4799, 4913, 5028, 5145, 5263, 5381, 5501, 5622, 5743, 5866, 5990, 6115, 6241, 6368, 6495, 6624, 6754, 6884, 7016, 7148, 7282, 7416, 7551, 7687, 7823, 7961, 8099, 8238, 8378, 8519, 8661, 8803, 8946, 9089, 9234, 9379, 9525, 9671, 9818, 9966, 10114,10263,10413,10563,10713,10864,11016,11168,11321,11474,11628,11782,11937,12092,12247, 12403,12559,12716,12873,13030,13188,13346,13504,13662,13821,13980,14139,14299,14458,14618, 14778,14938,15099,15259,15419,15580,15741,15902,16062,16223,16384,16545,16706,16866,17027, 17188,17349,17509,17669,17830,17990,18150,18310,18469,18629,18788,18947,19106,19264,19422, 19580,19738,19895,20052,20209,20365,20521,20676,20831,20986,21140,21294,21447,21600,21752, 21904,22055,22205,22355,22505,22654,22802,22950,23097,23243,23389,23534,23679,23822,23965, 24107,24249,24390,24530,24669,24807,24945,25081,25217,25352,25486,25620,25752,25884,26014, 26144,26273,26400,26527,26653,26778,26902,27025,27146,27267,27387,27505,27623,27740,27855, 27969,28082,28194,28305,28415,28524,28631,28737,28842,28946,29049,29150,29251,29350,29447, 29544,29639,29733,29825,29917,30007,30096,30183,30269,30354,30437,30519,30600,30679,30757, 30833,30909,30982,31055,31125,31195,31263,31330,31395,31459,31521,31582,31641,31699,31755, 31810,31864,31916,31966,32015,32063,32108,32153,32196,32237,32277,32315,32352,32387,32421, 32453,32484,32513,32540,32566,32591,32613,32635,32654,32673,32689,32704,32717,32729,32740, 32748,32755,32761,32765,32767,32767,32766,32764,32760,32754,32747,32739,32728,32716,32703, 32688,32672,32653,32634,32612,32590,32565,32539,32512,32483,32452,32420,32386,32351,32314, 32276,32236,32195,32152,32107,32062,32014,31965,31915,31863,31809,31754,31698,31640,31581, 31520,31458,31394,31329,31262,31194,31124,31054,30981,30908,30832,30756,30678,30599,30518, 30436,30353,30268,30182,30095,30006,29916,29824,29732,29638,29543,29446,29349,29250,29149, 29048,28945,28841,28736,28630,28523,28414,28304,28193,28081,27968,27854,27739,27622,27504, 27386,27266,27145,27024,26901,26777,26652,26526,26399,26272,26143,26013,25883,25751,25619, 25485,25351,25216,25080,24944,24806,24668,24529,24389,24248,24106,23964,23821,23678,23533, 23388,23242,23096,22949,22801,22653,22504,22354,22204,22054,21903,21751,21599,21446,21293, 21139,20985,20830,20675,20520,20364,20208,20051,19894,19737,19579,19421,19263,19105,18946, 18787,18628,18468,18309,18149,17989,17829,17668,17508,17348,17187,17026,16865,16705,16544, 16383,16222,16061,15901,15740,15579,15418,15258,15098,14937,14777,14617,14457,14298,14138, 13979,13820,13661,13503,13345,13187,13029,12872,12715,12558,12402,12246,12091,11936,11781, 11627,11473,11320,11167,11015,10863,10712,10562,10412,10262,10113, 9965, 9817, 9670, 9524, 9378, 9233, 9088, 8945, 8802, 8660, 8518, 8377, 8237, 8098, 7960, 7822, 7686, 7550, 7415, 7281, 7147, 7015, 6883, 6753, 6623, 6494, 6367, 6240, 6114, 5989, 5865, 5742, 5621, 5500, 5380, 5262, 5144, 5027, 4912, 4798, 4685, 4573, 4462, 4352, 4243, 4136, 4030, 3925, 3821, 3718, 3617, 3516, 3417, 3320, 3223, 3128, 3034, 2942, 2850, 2760, 2671, 2584, 2498, 2413, 2330, 2248, 2167, 2088, 2010, 1934, 1858, 1785, 1712, 1642, 1572, 1504, 1437, 1372, 1308, 1246, 1185, 1126, 1068, 1012, 957, 903, 851, 801, 752, 704, 659, 614, 571, 530, 490, 452, 415, 380, 346, 314, 283, 254, 227, 201, 176, 154, 132, 113, 94, 78, 63, 50, 38, 27, 19, 12, 6, 2, 0 };