📄 g723_func.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) 2001-02 Intel Corporation. All Rights Reserved.//// Filename:// g723_aux.c //// Description:// Intel Integrated Performance Primitives (IPP)// appSC.lib "helper" functions for the G.723.1 codec //// Revision:// 1.0//// References:// [1] ITU-T Rec. G.723.1, "Dual Rate Speech Coder for Multimedia// Communications Transmitting at 5.3 and 6.3 kbit/s," // Telecommunications Standardization Sector of ITU,// March, 1996. // [2] ITU-T Rec. G.723.1 fixed-point C reference code ("96_03"),// March, 1996.******************************************************************************//******************************** IPP G.723.1 codec definitions ********************************/#include <g723_def.h>#include <g723_codec.h>#include <g723_func.h>/******************************** OS adaptation layer ********************************/#include <g723_api.h>/****************************** g723_aux internal definitions ******************************/#define _G723_STREAM_BYTES_53KBPS 20 /* #bytes in 1 frame of the compressed 5.3 kbps bitstream */#define _G723_STREAM_BYTES_63KBPS 24 /* #bytes in 1 frame of the compressed 6.3 kbps bitstream */#define _G723_Q8 0x0100#define _G723_Q9 0x0200#define _G723_Q10 0x0400#define _G723_Q12 0x1000#define _G723_Q13 0x2000#define _G723_Q14 0x4000#define _G723_Q15 0x8000#define _G723_Q15_025 8192#define _G723_Q15_075 24576#define _G723_Q15_1_30 1092#define _G723_Q15_071875 23552#define _G723_Q15_0375 12288#define _G723_PITCHMULT 8 /* multiple border of pitch */#define _G723_Q15_8_90 2913#define _G723_Q15_1_120 273#define _G723_Q15_1_11 2979#define _G723_Q15_021362 7000#define _G723_Q15_0125 4096 #define _G723_Q15_0875 28672#define _G723_ACB1SZ 85 /* size of adaptive gain codebook 1 */#define _G723_ACB2SZ 170 /* size of adaptive gain codebook 2 */#define _G723_ACGBSZ 170 /* size of adaptive gain book */#define _G723_ACBLEN 20 /* vector length of adaptive gain codebook */#define _G723_CB1START 0 /* start point of codebook 1 */#define _G723_CB1NUMBE 3 /* band size of codebook 1 */#define _G723_CB2START 3 /* start point of codebook 2 */#define _G723_CB2NUMBE 3 /* band size of codebook 2 */#define _G723_CB3START 6 /* start point of codebook 3 */#define _G723_CB3NUMBE 4 /* band size of codebook 3 */#define _G723_STBMIN 384 /* low stability bound of LSF coefficients */#define _G723_STBMAX 32256 /* high stability bound of LSF coefficients */#define _G723_MAXPOS1 0x00090f6f /* odd subframe combined position maximum */ #define _G723_MAXPOS2 0x00022caa /* even subframe combined position maximum */#define _G723_NOISELOW 0x80 /* low border of noise level */#define _G723_NOISEHIGH 0x1ffff /* high border of noise level */ #define IPP_STATUS_OK ippStsNoErr/* g723_aux internal functions */IppStatus _ippsPerceptualWeighting_G723_16s (const Ipp16s *pSrcSpch, const Ipp16s *pSrcWgtLpc, Ipp16s *pSrcZn, Ipp16s *pSrcZd, Ipp16s *pDstWgtSpch);void UpdateErasureFrameParameters(Ipp16s InvalidFrame, Ipp16s *ConsecutiveFrameErasures, Ipp16s *FixedCBQGainIndex, Ipp16s *InterpolationGain);/* g723_aux internal tables *//* Formant postfilter exponential weighting series (numerator) affects radial shift towards unit circle center for postfilter zeros [1]. */Ipp16s lambda1[] ={(Ipp16s) 21299, 13844, 8999, 5849, 3802, (Ipp16s) 2471, 1606, 1044, 679, 441};/* Formant postfilter exponential weighting series (denominator) affects radial shift towards unit circle center for postfilter poles [1]. */Ipp16s lambda2[] = {(Ipp16s) 24576, 18432, 13824, 10368, 7776,(Ipp16s) 5832, 4374, 3281, 2460, 1845};/* Perceptual weighting filter exponential weighting series (numerator) affects radial shift towards unit circle center for PWF zeros [1]. */Ipp16s gamma1[] = {(Ipp16s) 29491, 26542, 23888, 21499, 19349, (Ipp16s) 17414, 15673, 14106, 12695, 11425};/* Perceptual weighting filter exponential weighting series (denominator) affects radial shift towards unit circle center for PWF poles [1]. */Ipp16s gamma2[] = {(Ipp16s) 16384, 8192, 4096, 2048, 1024,(Ipp16s) 512, 256, 128, 64, 32}; /* Pitch synchronous filer lag table for ACELP codebook search [2]. */Ipp16s pitchSyncFiltLagTable[] ={(Ipp16s) 60, 0, 60, 0, 1, 0, 0, 1, (Ipp16s) -1, 1, 0, -1, 2, -2, 0, 1, (Ipp16s) 0, 0, -1, 0, 0, 0, 1, 0, (Ipp16s) -1, -1, 1, -1, 1, -2, 1, -1,(Ipp16s) 60, 0, 0, 1, 1, 0, 1, 1, (Ipp16s) -1, 1, -1, -1, -1, 0, 60, -2, (Ipp16s) 0, 1, 0, -1, 1, 1, 0, 1, (Ipp16s) 2, -1, 0, 1, 0, 0, 0, 60, (Ipp16s) -1, 1, 1, 2, -1, 1, -1, 60,(Ipp16s) -1, 0, 1, 0, -1, 0, 0, 0, (Ipp16s) 1, -1, 0, 1, -1, 0, -1, 0, (Ipp16s) 1, 60, 0, 0, 1, 1, 0, 2, (Ipp16s) 1, 0, 1, -2, 0, -1, 1, 0, (Ipp16s) -1, 1, 0, 0, 1, 0, 0, 0, (Ipp16s) 60, 1, 1, -1, -1, 2, -2, 0,(Ipp16s) -1, -1, 60, 2, 60, 0, 0, 60, (Ipp16s) 0, 0, 0, -2, 60, -1, 0, 60,(Ipp16s) 0, 2, 0, 0, -1, 0, 1, 2,(Ipp16s) 60, 1, 1, 1, 0, 0, 60, 0,(Ipp16s) 60, 0, 0, 60, 60, -1, 0, 0,(Ipp16s) 60, 60, 1, 0, 60, 2, 60, -2,(Ipp16s) -2, 0};/* Pitch synchronous filer gain table for ACELP codebook search [2]. */Ipp16s pitchSyncFiltGainTable[] ={(Ipp16s) 0, 2489, 0, 5217, 6171, 3953, 10364, 9357,(Ipp16s) 8843, 9396, 5794, 10816, 11606, 12072, 8616, 12170,(Ipp16s) 14440, 7787, 13721, 18205, 14471, 15807, 15275, 13480,(Ipp16s) 18375, 0, 11194, 13010, 18836, 20354, 16233, 0,(Ipp16s) 0, 12130, 13385, 17834, 20875, 21996, 0, 18277,(Ipp16s) 21321, 13738, 19094, 20387, 0, 21008, 0, 22807,(Ipp16s) 15900, 0, 17989, 22259, 24395, 23138, 23948, 22997,(Ipp16s) 22604, 25942, 26246, 25321, 26423, 24061, 27247, 0,(Ipp16s) 25572, 23918, 25930, 26408, 19049, 27357, 24538, 0,(Ipp16s) 25093, 28549, 0, 22793, 25659, 29377, 30276, 26198,(Ipp16s) 22521, 28919, 27384, 30162, 0, 24237, 30062, 21763,(Ipp16s) 30917, 0, 31284, 29433, 26821, 28655, 31327, 30799,(Ipp16s) 31389, 32322, 31760, 31830, 26936, 31180, 30875, 27873,(Ipp16s) 30429, 31050, 0, 31912, 31611, 31565, 25557, 31357,(Ipp16s) 0, 29536, 28985, 26984, 31587, 30836, 31133, 30243,(Ipp16s) 30742, 32090, 0, 30902, 0, 30027, 29042, 0,(Ipp16s) 31756, 24553, 25636, 30501, 0, 29617, 30649, 0,(Ipp16s) 29274, 30415, 27480, 31213, 28147, 30600, 31652, 29068,(Ipp16s) 0, 28571, 28730, 31422, 28257, 24797, 0, 0,(Ipp16s) 0, 22105, 27852, 0, 0, 24214, 24642, 23305,(Ipp16s) 0, 0, 22883, 21601, 0, 25650, 0, 31253,(Ipp16s) 25144, 17998 };/* Error taming adaptive codebook gain bounding table, 6.3 kbps with short pitch lags */Ipp16s errorTamingGainTable1[] = {(Ipp16s) 1024, 1308, 1906, 2291, 2511, 2736, 3298, 3489,(Ipp16s) 3531, 3844, 4360, 4541, 4684, 4813, 5069, 5528,(Ipp16s) 5577, 5713, 5923, 5958, 5958, 6064, 6132, 6331,(Ipp16s) 6370, 6527, 6533, 6575, 6633, 6671, 6832, 6832,(Ipp16s) 6972, 6996, 7199, 7205, 7414, 7529, 7543, 7543,(Ipp16s) 7692, 7758, 7839, 7839, 7869, 7992, 8000, 8016,(Ipp16s) 8055, 8079, 8119, 8208, 8250, 8266, 8291, 8300,(Ipp16s) 8325, 8402, 8445, 8605, 8623, 8687, 8752, 8837,(Ipp16s) 8847, 8973, 9002, 9012, 9184, 9593, 9672, 9752,(Ipp16s) 9846, 9978, 10139, 10202, 10317, 10476, 10598, 10598,(Ipp16s) 10695, 11425, 11670, 14629, 15255 };/* Error taming adaptive codebook gain bounding table, 5.3 kbps + 6.3 kbps with long pitch lags */Ipp16s errorTamingGainTable2[] ={(Ipp16s) 1024, 1591, 1678, 1891, 2120, 2399, 2966, 3049,(Ipp16s) 3185, 3317, 3433, 3523, 3729, 3779, 3789, 4262,(Ipp16s) 4450, 4469, 4713, 4944, 4950, 4980, 5010, 5032,(Ipp16s) 5299, 5389, 5389, 5389, 5646, 5701, 5733, 5765,(Ipp16s) 5997, 5997, 6150, 6211, 6336, 6360, 6415, 6415,(Ipp16s) 6430, 6440, 6461, 6461, 6512, 6601, 6787, 6872,(Ipp16s) 6931, 6972, 6984, 7056, 7056, 7105, 7117, 7123,(Ipp16s) 7136, 7161, 7167, 7180, 7180, 7262, 7308, 7334,(Ipp16s) 7334, 7387, 7407, 7434, 7441, 7441, 7481, 7536,(Ipp16s) 7564, 7592, 7685, 7714, 7758, 7772, 7794, 7802,(Ipp16s) 7817, 7839, 7869, 7885, 7907, 7946, 7992, 8039,(Ipp16s) 8063, 8087, 8087, 8167, 8184, 8200, 8200, 8241,(Ipp16s) 8266, 8283, 8308, 8308, 8334, 8376, 8402, 8463,(Ipp16s) 8516, 8524, 8533, 8641, 8669, 8696, 8752, 8761,(Ipp16s) 8799, 8828, 8943, 9112, 9122, 9133, 9153, 9288,(Ipp16s) 9299, 9373, 9384, 9384, 9405, 9416, 9471, 9503,(Ipp16s) 9559, 9581, 9660, 9660, 9718, 9799, 9823, 9846,(Ipp16s) 9846, 9930, 10039, 10164, 10227, 10291, 10436, 10503,(Ipp16s) 10516, 10530, 10598, 10611, 10625, 11040, 11070, 11100,(Ipp16s) 11115, 11315, 11331, 11804, 12100, 12263, 12263, 12300,(Ipp16s) 12337, 12431, 12800, 12962, 13065, 13496, 13815, 14100,(Ipp16s) 14198, 18409 };/* LSF split VQ, codebook 1 (LSF0,1,2) Codebook dimension is 256 x 3, i.e. 3 elements x 8-bits */Ipp16s lsfSplitVQ_Cb012[] ={(Ipp16s) 0, 0, 0, -270, -1372, -1032, -541, -1650, -1382,(Ipp16s) -723, -2011, -2213, -941, -1122, -1942, -780, -1145, -2454,(Ipp16s) -884, -1309, -1373, -1051, -1523, -1766, -1083, -1622, -2300,(Ipp16s) -777, -1377, -2147, -935, -1467, -2763, -802, -1327, -3471,(Ipp16s) -935, -1959, -3999, -240, -89, 222, -661, -257, -160,(Ipp16s) -994, -466, -419, -188, -164, -278, -342, -512, -415,(Ipp16s) -607, -511, -797, 16, 19, -716, 374, 425, -972,(Ipp16s) -346, 245, -282, -265, 506, -754, -620, -147, 1955,(Ipp16s) -742, -860, 2597, -150, -352, 2704, 305, 880, 1954,(Ipp16s) 123, 731, 2766, -348, 765, 3327, 618, 221, 3258,(Ipp16s) -178, -47, 4219, 393, 1304, 3842, 698, 1702, 4801,(Ipp16s) 63, -584, 1229, -215, -732, 1704, 172, -335, 1909,(Ipp16s) -2, 216, 1797, 353, 127, 2205, -1208, 188, 11,(Ipp16s) -513, -75, -683, -973, 222, -646, -616, -843, -388,(Ipp16s) -950, -1113, -359, -1431, -623, -705, -1398, -1063, -178,(Ipp16s) -45, -461, 35, -9, -657, -216, 127, -1078, 95,(Ipp16s) -950, -1156, 584, -1480, -1494, 449, -120, -705, 516,(Ipp16s) -368, -961, 727, -378, -526, 973, -793, -614, 676,(Ipp16s) -801, -755, 1287, -1476, -340, 1636, -505, -1254, 1543,(Ipp16s) -1243, -1622, 1532, -776, -1477, -655, -1151, -1296, -823,(Ipp16s) -1153, -1672, -1124, -1291, -2003, -1702, -622, -1283, 57,(Ipp16s) -471, -1611, 509, -1060, -1570, -139, -873, -2156, -536,(Ipp16s) -1716, -2021, -364, -2150, -3218, -1291, -1248, -1945, -2904,(Ipp16s) -1215, -2633, -2855, 167, -244, 84, 349, -412, -217,(Ipp16s) -40, -352, 632, 227, -529, 405, 68, -383, -443,(Ipp16s) 167, -558, -706, -275, -854, -14, -351, -1089, -449,(Ipp16s) 341, -72, -289, 603, -106, -474, 322, -219, -649,(Ipp16s) 179, -317, -998, 450, -291, -996, 555, 195, -525,(Ipp16s) 784, 272, -831, -148, -384, -849, 82, -536, -1357,(Ipp16s) 238, -172, -1354, 422, -268, -1841, 297, -737, -2079,(Ipp16s) -111, -801, -598, 1, -668, -984, -131, -818, -1299,(Ipp16s) -329, -521, -1310, -151, -778, -1834, -93, -352, -1746,(Ipp16s) -568, -640, -1821, -509, -941, -2183, 464, -815, -1250,(Ipp16s) 79, -1133, -1597, -184, -1353, -2123, -196, -410, -2427,(Ipp16s) -192, -833, -2810, -259, -1382, -3045, -217, 4, -1166,(Ipp16s) -800, -325, -1219, -363, -830, -898, -661, -1134, -960,(Ipp16s) -386, -980, -1501, -627, -1159, -1722, -903, -829, -855,(Ipp16s) -685, -829, -1313, -1065, -959, -1405, 441, 25, -847,(Ipp16s) 655, -27, -1181, 1159, -110, -705, 856, 253, -1671,(Ipp16s) 415, 404, -1, 322, 903, -398, 670, 499, -292,(Ipp16s) 803, 591, -610, 1144, 591, -814, 717, 183, 393,(Ipp16s) 857, 381, 106, 609, 62, -27, 792, 198, -325,(Ipp16s) 735, 805, 88, 1142, 812, 78, 1028, 366, -292,(Ipp16s) 1309, 743, -237, 1615, 589, -79, 1010, 639, -243,(Ipp16s) 999, 964, -311, 1500, 1137, -615, 988, 357, 646,(Ipp16s) 1227, 667, 683, 1164, 1565, 894, 1392, 2015, 477,(Ipp16s) 1138, 533, 250, 1437, 896, 391, 1765, 1118, 99,(Ipp16s) 1112, 1090, 802, 1596, 846, 1134, 937, 1161, 279,(Ipp16s) 1719, 1254, 683, 1338, 1086, 35, 1419, 1324, 428,(Ipp16s) 1428, 1524, 40, 2108, 1594, 89, 1015, 544, 1222,(Ipp16s) 1121, 925, 1263, 1030, 1318, 1485, 1295, 789, 1817,(Ipp16s) 1323, 1272, 1909, 1724, 1237, 1803, 1797, 1689, 858,(Ipp16s) 2149, 1367, 1301, 2302, 1867, 761, 2863, 2351, 1053,(Ipp16s) 52, 163, -76, 230, 309, -492, -71, 619, 39,(Ipp16s) -218, 856, 499, -654, 736, -207, -535, 1259, 155,(Ipp16s) -480, 1476, 643, 262, 1081, 102, 309, 1592, -182,(Ipp16s) 627, 1629, 534, 337, 643, 456, 758, 670, 713,(Ipp16s) 202, 1126, 658, 612, 1131, 666, 686, 1223, 1136,(Ipp16s) -131, 377, 525, 42, 708, 907, 87, 1488, 1035,(Ipp16s) 432, 2117, 904, 137, 981, 1332, -447, 1014, 1136,(Ipp16s) -839, 1793, 1246, -559, 297, 198, -850, 685, 446,(Ipp16s) -1273, 632, 826, -401, -544, 173, -753, -793, 144,(Ipp16s) -436, -9, 772, -115, -243, 1310, -670, -269, 374,(Ipp16s) -1027, -13, 639, -887, -81, 1137, -1277, -455, 158,(Ipp16s) -1411, -720, 736, 172, 88, 403, 386, 255, 756,(Ipp16s) -500, 522, 910, -958, 659, 1388, -395, 301, 1344,(Ipp16s) -356, 768, 1813, -613, 841, 2419, 445, -122, 252,(Ipp16s) 629, -87, 723, 283, -253, 870, 456, -116, 1381,(Ipp16s) 757, 180, 1059, 532, 408, 1509, 947, 288, 1806,(Ipp16s) 1325, 994, 2524, 892, 1219, 3023, 1397, 1596, 3406,(Ipp16s) 1143, 1552, 2546, 1850, 1433, 2710, -10, 134, 1002,(Ipp16s) 154, 499, 1323, 508, 792, 1117, 509, 1340, 1616,(Ipp16s) 762, 862, 1608, 787, 740, 2320, 794, 1727, 1283,(Ipp16s) 465, 2108, 1660, -120, 1451, 1613, -386, 2016, 2169,(Ipp16s) 891, 1225, 2050, 456, 1480, 2185, 1493, 1283, 1209,(Ipp16s) 1397, 1636, 1518, 1776, 1738, 1552, 1572, 1698, 2141,(Ipp16s) 1389, 2126, 1271, 1959, 2413, 1119, 1365, 2892, 1505,(Ipp16s) 2206, 1971, 1623, 2076, 1950, 2280, 1717, 2291, 1867,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -