📄 owng729.c
字号:
/*/////////////////////////////////////////////////////////////////////////////
//
// INTEL CORPORATION PROPRIETARY INFORMATION
// This software is supplied under the terms of a license agreement or
// nondisclosure agreement with Intel Corporation and may not be copied
// or disclosed except in accordance with the terms of that agreement.
// Copyright(c) 2005 Intel Corporation. All Rights Reserved.
//
// Intel(R) Integrated Performance Primitives
// USC - Unified Speech Codec interface library
//
// By downloading and installing USC codec, you hereby agree that the
// accompanying Materials are being provided to you under the terms and
// conditions of the End User License Agreement for the Intel(R) Integrated
// Performance Primitives product previously accepted by you. Please refer
// to the file ipplic.htm located in the root directory of your Intel(R) IPP
// product installation for more information.
//
// A speech coding standards promoted by ITU, ETSI, 3GPP and other
// organizations. Implementations of these standards, or the standard enabled
// platforms may require licenses from various entities, including
// Intel Corporation.
//
//
// Purpose: G.729/A/B/D/E speech codec: Miscellaneous.
//
*/
#include <ipps.h>
#include <stdio.h>
#include <stdlib.h>
#include "owng729.h"
#include "ippdefs.h"
#if defined(__ICL ) && defined(_IPP_A6)
#include <xmmintrin.h>
#endif
__ALIGN32 CONST short NormTG729i[256] = {
7,6,5,5,4,4,4,4,
3,3,3,3,3,3,3,3,
2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,
1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,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ALIGN32 CONST short t[GAIN_NUM+1] = {820,26<<1,26};
static __ALIGN32 CONST short t1[GAIN_NUM+1] = {0,0,1};
static __ALIGN32 CONST short energyLogTable[17] = { 2000+466, 2000+520, 2000+571, 2000+619, 2000+665, 2000+708, 2000+749,
2789, 2000+827, 2000+863, 2000+898, 2000+931, 2000+964, 2000+995, 3000+25, 3000+54, 3000+83};
static __ALIGN32 CONST int wlag_bwd[BWLPCF_DIM]={
2100000000+47252352, 2100000000+47202688, 2100000000+47120000, 2100000000+47004032, 2100000000+46855040,
2100000000+46673024, 2100000000+46457728, 2100000000+46209536, 2100000000+45928192, 2100000000+45613952,
2100000000+45266432, 2100000000+44886016, 2100000000+44472704, 2100000000+44026240, 2100000000+43546880,
2100000000+43034624, 2100000000+42489344, 2100000000+41911296, 2100000000+41300224, 2100000000+40656512,
2100000000+39979776, 2100000000+39270400, 2100000000+38528128, 2100000000+37753344, 2100000000+36945920,
2100000000+36105600, 2100000000+35232896, 2100000000+34327552, 2100000000+33389696, 2100000000+32419328
};
__ALIGN32 CONST short presetOldA[LPF_DIM+1]={ (1<<12), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
__ALIGN32 CONST short presetLSP[LPF_DIM]={ 3*10000, 26*1000,21*1000, 15*1000, 8*1000, 0*1000,
-8*1000,-15*1000,-21*1000,-26*1000};
__ALIGN32 CONST short resetPrevLSP[LPF_DIM] = { 2000+339, 4000+679,7000+18, 9000+358, 11000+698,
14000+37, 16000+377,18000+717, 21000+56, 23000+396};
__ALIGN32 CONST short SIDgain[32] = {
(1<<1), (1<<2)+1, (1<<3), (1<<3)+5,
(1<<4)+(1<<2), (1<<5), 5*10, (1<<6),
8*10, 100+1, 100+27, 100+60,
200+01, 200+53, 300+18, 400+1,
500+5, 600+35, 800, 1000+7,
1000+268, 1000+596, 2000+10, 2000+530,
3000+185, 4000+9, 5000+48, 6000+355,
8*1000,10000+71,12000+679,15000+962
};
__ALIGN32 CONST short areas[L_prevExcitat-1+3] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
3,3,3,3,3,3,3,3,3,3,3,3,3,0,0,0
};
__ALIGN32 CONST short LUT1[CDBK1_DIM]={
5,
1,
4,
7,
3,
0,
6,
2
};
__ALIGN32 CONST short LUT2[CDBK2_DIM]={
4,
6,
0,
2,
12,
14,
8,
10,
15,
11,
9,
13,
7,
3,
1,
5
};
static __ALIGN32 CONST short logTable[33]={
0,1455,2866,4236,5568,6863,
8124,9352,10549,11716,12855,13967,
15054,16117,17156,18172,19167,20142,
21097,22033,22951,23852,24735,25603,
26455,27291,28113,28922,29716,30497,
31266,32023, IPP_MAX_16S};
__ALIGN32 CONST short cngCache[CNG_STACK_SIZE][LP_SUBFRAME_DIM]={
{/* 0 */
86,-609,391,173,-80,-718,-47,559,235,676,
-4,-110,5,-521,-506,-300,256,-727,-527,-9,
-38,60,-69,-263,661,-722,-154,1500,303,-511,
-272,-866,938,179,91,833,4,-698,933,-573*1
},
{/* 1 */
225,547,-292,-470,302,264,728,-578,-294,332,
1589,-845,487,241,241,775,83,-523,-242,188,
-992,602,650,-48,332,542,-153,581,-39,323,
931,25,-59,-569,-192,-178,-238,-596,60,482*1
},
{/*2*/
-57,-821,254,-1,365,-278,21,-371,-12,-536,
11,1020,-166,455,-798,74,-95,133,152,-647,
199,-476,-209,-633,-306,-350,-859,118,436,-511,
-260,68,379,63,50,755,33,-674,585,-383*1
},
{/*3*/
1140,589,364,-527,-516,-83,-220,1154,-27,878,
-707,-1166,557,-626,437,-317,-810,15,654,115,
-34,-273,-570,-380,-185,-464,863,-268,271,464,
-169,-571,312,-47,-592,-779,-64,49,616,646*1
},
{/*4*/
259,-1109,-623,852,406,757,-493,911,1032,-480,
630,937,-421,-214,184,-92,-883,-491,-293,382,
-864,735,221,-1223,-878,394,192,723,101,-1004,
130,-434,535,127,549,-88,-86,201,935,739*1
},
{/*5*/
-937,-304,-546,-350,572,460,626,-690,-128,-471,
103,347,549,-539,443,199,41,1282,-400,404,
-114,-642,644,-576,1106,-677,505,333,119,151,
-307,-455,-517,-204,-254,-378,-800,-208,150,-462*1
},
{/*6*/
-497,770,-829,-271,-722,281,1105,-392,-212,15,
192,-290,523,486,-1010,37,-55,-356,1085,75,
-408,51,331,338,486,169,1338,312,-443,512,
-1016,-1,387,-970,-73,-91,-94,-691,-443,44*1
},
{/*7*/
993,-320,-251,208,577,376,150,-71,-254,657,
-890,-255,-478,9,215,-342,-93,482,391,-334,
387,-486,152,-229,452,179,8,-29,100,-1109,
-39,780,-155,-252,9,-364,709,188,-358,-387*1
},
{/*8*/
-49,-395,248,506,25,-9,-461,-148,68,-166,
-179,-BW_EXP_FACT ,-434,156,72,1009,-455,-65,-1246,772,
-509,-319,477,-1034,942,420,-393,201,-200,102,
242,-133,-1885,777,-692,-498,-531,-117,-121,128*1
},
{/*9*/
-828,402,-490,-144,1216,806,-62,-588,-483,539,
-305,345,217,111,315,-419,-266,-476,-760,194,
-910,-200,52,646,-177,429,705,-597,-629,-127,
685,47,-216,182,-518,20,-476,-182,-858,344*1
},
{/*10*/
-250,903,-395,-654,-483,-491,-260,-400,-493,-636,
-414,79,-278,-46,1193,781,160,-255,-561,172,
311,-753,470,-214,173,1022,-324,-375,772,-52,
131,711,1082,635,297,486,81,521,688,484*1
},
{/*11*/
-492,537,420,213,-1076,170,-115,-362,485,-102,
469,-330,605,235,126,-201,-202,667,-122,-1001,
-914,-340,-273,-168,-505,284,-329,-264,-1,1005,
-288,761,-424,-227,360,-679,272,-338,-431,26*1
},
{/*12*/
345,156,94,317,-549,-809,208,-1432,574,-783,
803,-654,640,748,341,1117,-349,-314,360,807,
165,-383,-1190,-558,648,-485,-211,604,-950,-106,
223,-313,493,-272,-910,273,-145,43,-28,316*1
},
{/*13*/
838,-630,164,-588,-38,566,-24,-495,-49,67,
653,-563,291,431,145,234,984,636,-10,358,
492,-856,-326,835,-159,53,-289,-897,-459,-223,
-925,-228,-406,-146,-696,-232,-2,-230,396,117*1
},
{/*14*/
75,505,-74,-735,473,-128,-588,23,584,486,
-365,494,406,-211,81,-348,-571,339,240,571,
723,602,-402,-847,-830,-448,205,1032,-112,263,
-1013,62,-193,685,554,-683,973,-1228,808,843*1
},
{/*15*/
301,-392,-151,1056,702,-671,-470,-199,174,-343,
-694,-847,-769,82,-821,138,-593,602,683,-318,
192,195,748,-677,48,395,-116,-429,-511,-332,
-371,-84,-463,-452,493,356,-830,1061,-594,381*1
},
{/*16*/
64,-830,609,447,379,-460,1164,-222,149,-633,
-362,100,-624,-327,129,391,106,-52,75,-375,
-219,190,1014,-148,447,-623,-128,1070,570,67,
747,-815,-364,-298,-459,-1197,207,328,352,-74*1
},
{/*17*/
-258,-552,-344,654,-342,540,517,-125,439,-63,
-319,-41,-477,-315,222,-628,-528,810,-422,-352,
-228,-274,311,277,425,-493,-141,745,-107,151,
-240,30,226,636,524,690,-114,-64,105,167*1
},
{/*18*/
381,506,-475,-1123,4,-264,539,780,362,215,
242,346,433,-619,-344,137,215,-204,-705,-361,
-290,-1102,-331,-634,964,-239,268,-172,-629,335,
-446,515,-463,622,89,-111,-584,620,335,0*1
},
{/*19*/
-692,-1027,628,210,309,446,-371,450,-643,478,
261,-237,550,607,-1058,707,302,319,-234,-300,
-361,128,-337,-188,-417,32,679,-491,136,545,
256,837,272,129,-72,726,-519,-190,-303,-314*1
},
{/*20*/
-1242,-123,-605,31,408,-336,-1018,57,491,442,
-440,-460,29,165,107,14,48,-145,621,-55,
34,26,80,-157,-11,-348,-494,222,-89,-241,
-75,-456,-198,-167,311,-141,-340,-124,154,141*1
},
{/*21*/
780,-100,322,286,592,505,-201,-213,-779,437,
139,-873,-263,-302,-192,356,94,846,-172,-112,
-222,811,201,285,327,-409,-99,9,203,-1276,
-46,86,944,768,870,2,-12,605,-421,271*1
},
{/*22*/
-962,-727,353,-376,-452,-993,-48,238,-229,502,
286,53,217,684,-179,-421,1400,67,-421,-158,
-266,697,74,840,341,528,-232,15,-365,-442,
-313,-587,690,-163,341,60,-80,-173,196,-94*1
},
{/*23*/
145,200,230,265,338,-543,726,81,1138,-167,
295,-518,-13,-206,-553,2,-557,-1174,-792,-405,
-492,515,88,-1229,-332,763,-983,92,949,-428,
89,484,-235,12,234,461,214,549,-38,533*1
},
{/*24*/
-343,-121,-317,252,724,234,-35,591,734,556,
-296,385,-311,335,434,148,-365,81,-403,390,
-450,308,-1273,89,-568,-10,898,267,307,-359,
-36,-98,637,-229,1047,-496,424,-130,561,-413*1
},
{/*25*/
144,-10,402,-892,-531,235,-353,-471,169,-705,
267,-211,-314,244,216,-110,66,8,1028,-170,
-225,125,145,-389,-677,-431,-899,255,760,-122,
-54,740,-12,1050,630,40,-943,-497,131,-307*1
},
{/*26*/
557,805,-1268,-640,-477,660,-910,351,762,738,
-839,29,-336,17,-33,-68,839,-993,998,-966,
189,-242,-308,409,-236,220,147,471,74,-117,
-199,246,97,-231,-832,756,343,-1144,294,467*1
},
{/*27*/
284,762,-803,-282,309,-22,293,262,429,827,
462,-121,-890,-1301,214,103,-1090,252,-961,424,
-681,-148,7,328,335,-451,-464,-183,-600,365,
184,-87,-416,254,417,106,-135,-786,233,-118*1
},
{/*28*/
-149,359,96,-264,974,-639,179,2,16,380,
229,237,563,342,-776,-73,53,-239,-278,98,
24,171,701,-276,-38,-474,-401,343,-131,-128,
-1022,-95,255,-837,-140,-52,610,-555,199,-42*1
},
{/*29*/
682,6,184,-31,671,19,-675,413,-525,-129,
353,-326,-856,-436,198,822,188,-392,394,787,
49,517,-593,591,-251,-783,307,236,826,-194,
536,-280,206,746,-932,69,451,-521,1,257*1
},
{/*30*/
233,912,-316,-473,856,-10,419,510,-346,-707,
-159,-1356,-299,355,0,75,-541,106,-130,193,
-46,-432,-547,24,160,-233,283,590,-433,-835,
-1222,869,733,836,568,347,-436,-342,535,-462*1
},
{/*31*/
-754,1201,-390,137,254,505,-102,-511,-689,418,
-229,474,-1,938,251,-494,-752,19,-196,171,
-384,-805,-36,419,81,-508,221,252,-383,-116,
61,-332,274,373,510,-819,-510,-67,542,325*1
},
};
__ALIGN32 CONST short cngSeedOut[CNG_STACK_SIZE]={
-26766, 5273, -20980, 12987, 20566, 2637, -17200, -25649,
24058, -31807, 27220, 6819, -31650, -27403, 23192, 9015,
18306, 4585, -3684, -5749, -5274, -29027, 21344, 24991,
29706, 24337, 25572, 16243, -23186, -26811, -14552, -2297
};
__ALIGN32 CONST int cngInvSqrt[CNG_STACK_SIZE]={
320863, 323781, 388729, 303149, 269026, 324406, 304813, 391279,
300993, 335038, 312683, 356481, 286752, 349341, 292467, 315662,
323859, 418904, 340163, 350720, 452932, 342818, 349410, 315175,
357434, 352913, 286583, 332201, 413044, 346627, 309243, 358885
};
__ALIGN32 CONST short gammaFac1[2*(LPF_DIM+1)]={
IPP_MAX_16S,24000+576,18000+432,13000+824,10000+368,7000+776,5000+832,4000+374,3000+281,2000+461,1000+846,
IPP_MAX_16S,24000+576,18000+432,13000+824,10000+368,7000+776,5000+832,4000+374,3000+281,2000+461,1000+846
};
__ALIGN32 CONST short g729gammaFac2_pst[LPF_DIM+1] = {
IPP_MAX_16S, BWF2_PST, 9000+912, 5000+451, 2000+998, 1000+649, 900+7, 400+99, 200+74, 100+51, 83
};
__ALIGN32 CONST short g729gammaFac1_pst[LPF_DIM+1] = {
IPP_MAX_16S, BWF2, 16000+57, 11200+40, 7800+68, 5500+8, 3800+56, 2600+99, 1800+89, 1300+22, 900+25
};
static __ALIGN32 CONST short lbfCorr[VAD_LPC_DIM +1] = { 7869, 7011, 4838, 2299, 321,
-660, -782, -484, -164, 3, 39, 21, 4};
static __ALIGN32 CONST short ifactor[33] = { IPP_MAX_16S, 16913, 17476, 18079,
18725, 19418, 20165, 20972, 21845, 22795, 23831, 24966,
26214, 27594,
29127, 30840, IPP_MAX_16S, 17476, 18725, 20165, 21845, 23831, 26214, 29127,
IPP_MAX_16S, 18725, 21845, 26214, IPP_MAX_16S, 21845, IPP_MAX_16S, IPP_MAX_16S, 0
};
static __ALIGN32 CONST short ishift[33] = { 15, (7<<1), (7<<1), (7<<1), (7<<1), (7<<1), (7<<1), (7<<1),
(7<<1), (7<<1), (7<<1), (7<<1), (7<<1), (7<<1), (7<<1), (7<<1), (7<<1), 13, 13, 13, 13, 13, 13, 13, 13, 12, 12,
12, 12, 11, 11, 10, 15
};
static __ALIGN32 CONST short vadTable[6][6]={
{24576, BWF_HARMONIC_E,26214, 6554,19661,PITCH_SHARP_MAX},
{31130, 1638,30147, 2621,21299,11469},
{31785, 983,30802, 1966,BWF2, 9830},
{32440, 328,31457, 1311,24576, BWF_HARMONIC_E},
{32604, 164,32440, 328,24576, BWF_HARMONIC_E},
{32604, 164,32702, 66,24576, BWF_HARMONIC_E},
};
static __ALIGN32 CONST short gStats[6] ={400<<4,400<<3,400*6,400<<2,400<<1,400};
static __ALIGN32 CONST short gThrs[6] ={955,819,614,410,205,0};
static __ALIGN32 CONST short gStats1[6]={400<<4,400<<3,400<<2,400<<1,400};
/* ///////////////////////////////////////////////////////////////////////////////////////
// Name: updateExcErr_G729
// Purpose: update excitation error
// Parameters:
// pSrcDst - coder error
*/
void updateExcErr_G729( short val, int indx, int *pSrcDst) {
int i, area1, area2, L_tmp, L_tmp1=0, tmp = 0;
short high, low;
L_tmp = -1;
if(indx < LP_SUBFRAME_DIM) {
high = (short)(pSrcDst[0] >> 16);
low = (pSrcDst[0]>>1) & IPP_MAX_16S;
tmp = high*val + ((low*val)>>15);
tmp = (tmp << 2) + (int)BWF_HARMONIC;
L_tmp = IPP_MAX(L_tmp,tmp);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -