📄 g726.c
字号:
Return value: none. ~~~~~~~~~~~~~ Prototype: in g726.h ~~~~~~~~~~ History: ~~~~~~~~ 31.Jan.91 v1.0f Release of 1st Fortran version to UGST. <tdsindi@venus.cpqd.ansp.br> 13.Feb.92 v1.0c 1st version in C translated from Fortran (f2c) <tdsimao@venus.cpqd.ansp.br> ----------------------------------------------------------------------*/void G726_accum(wa1, wa2, wb1, wb2, wb3, wb4, wb5, wb6, se, sez) short *wa1, *wa2, *wb1, *wb2, *wb3, *wb4, *wb5, *wb6, *se, *sez;{ unsigned long sezi; unsigned long wa11, wa21, wb11, wb21, wb31, wb41, wb51, wb61, sei; /* Preamble */ wa11 = *wa1; wa21 = *wa2; wb11 = *wb1; wb21 = *wb2; wb31 = *wb3; wb41 = *wb4; wb51 = *wb5; wb61 = *wb6; /* Sum of partial signal estimate */ sezi = (((((((((wb11 + wb21) & 65535) + wb31) & 65535) + wb41) & 65535) + wb51) & 65535) + wb61) & 65535; /* Complete sum for signal estimate */ sei = (((sezi + wa21) & 65535) + wa11) & 65535; *sez = (short) (sezi >> 1); *se = (short) (sei >> 1);}/* ....................... end of G726_accum() ....................... *//* ---------------------------------------------------------------------- void G726_addb (short *dq, short *se, short *sr); ~~~~~~~~~~~~~~ Description: ~~~~~~~~~~~~ Addition of quantized difference signal and signal estimate to form reconstructed signal. Inputs: dq, se Output: sr Return value: none. ~~~~~~~~~~~~~ Prototype: in g726.h ~~~~~~~~~~ History: ~~~~~~~~ 31.Jan.91 v1.0f Release of 1st Fortran version to UGST. <tdsindi@venus.cpqd.ansp.br> 13.Feb.92 v1.0c 1st version in C translated from Fortran (f2c) <tdsimao@venus.cpqd.ansp.br> ----------------------------------------------------------------------*/void G726_addb(dq, se, sr) short *dq, *se, *sr;{ unsigned long dq1, se1; unsigned long dqi, sei; short dqs, ses; /* Preamble */ dq1 = *dq & 65535; se1 = *se; /* Sign */ dqs = (*dq >> 15) & 1; /* Convert signed magnitude to 2's complement */ dqi = (dqs == 0) ? dq1 : ((65536 - (dq1 & 32767)) & 65535); ses = (*se >> 14); /* Sign extension */ sei = (ses == 0) ? se1 : ((1 << 15) + se1); *sr = (short) ((dqi + sei) & 65535);}/* ....................... end of G726_addb() ....................... *//* ---------------------------------------------------------------------- void G726_addc (short *dq, short *sez, short *pk0, ~~~~~~~~~~~~~~ short *sigpk); Description: ~~~~~~~~~~~~ Obtain sign of addition of quantized difference signal and partial signal estimate. Inputs: dq, sez Outputs: pk0, sigpk Return value: none. ~~~~~~~~~~~~~ Prototype: in g726.h ~~~~~~~~~~ History: ~~~~~~~~ 31.Jan.91 v1.0f Release of 1st Fortran version to UGST. <tdsindi@venus.cpqd.ansp.br> 13.Feb.92 v1.0c 1st version in C translated from Fortran (f2c) <tdsimao@venus.cpqd.ansp.br> ----------------------------------------------------------------------*/void G726_addc(dq, sez, pk0, sigpk) short *dq, *sez, *pk0, *sigpk;{ unsigned long sezi; short sezs; unsigned long dqsez, dq1; unsigned long dqi; short dqs; unsigned long sez1; /* Preamble */ dq1 = *dq & 65535; sez1 = *sez; /* Get sign */ dqs = (*dq >> 15) & 1; /* Convert signed magnitude to 2's compelemnent */ dqi = (dqs == 0) ? dq1 : ((65536 - (dq1 & 32767)) & 65535); sezs = (*sez >> 14); /* Sign extension */ sezi = (sezs == 0) ? sez1 : (sez1 + 32768); dqsez = (dqi + sezi) & 65535; *pk0 = (short) (dqsez >> 15); *sigpk = (dqsez == 0) ? 1 : 0;}/* ....................... end of G726_addc() ....................... *//* ---------------------------------------------------------------------- void G726_floata (short *dq, short *dq0); ~~~~~~~~~~~~~~~~ Description: ~~~~~~~~~~~~ Convert 16-bit signed magnitude to floating point. Inputs: dq Output: dq0 Return value: none. ~~~~~~~~~~~~~ Prototype: in g726.h ~~~~~~~~~~ History: ~~~~~~~~ 31.Jan.91 v1.0f Release of 1st Fortran version to UGST. <tdsindi@venus.cpqd.ansp.br> 13.Feb.92 v1.0c 1st version in C translated from Fortran (f2c) <tdsimao@venus.cpqd.ansp.br> ----------------------------------------------------------------------*/void G726_floata(dq, dq0) short *dq, *dq0;{ long mant; long mag, exp_; long dqs; dqs = (*dq >> 15) & 1; /* Compute magnitude */ mag = *dq & 32767; /* Exponent */ if (mag >= 16384) exp_ = 15; else if (mag >= 8192) exp_ = 14; else if (mag >= 4096) exp_ = 13; else if (mag >= 2048) exp_ = 12; else if (mag >= 1024) exp_ = 11; else if (mag >= 512) exp_ = 10; else if (mag >= 256) exp_ = 9; else if (mag >= 128) exp_ = 8; else if (mag >= 64) exp_ = 7; else if (mag >= 32) exp_ = 6; else if (mag >= 16) exp_ = 5; else if (mag >= 8) exp_ = 4; else if (mag >= 4) exp_ = 3; else if (mag >= 2) exp_ = 2; else if (mag == 1) exp_ = 1; else exp_ = 0; /* Compute mantissa w/a 1 in the most sig. bit */ mant = (mag == 0) ? (1 << 5) : ((mag << 6) >> exp_); /* Combine sign, exponent and mantissa (1,4,6) bits in a word */ *dq0 = (short) ((dqs << 10) + (exp_ << 6) + mant);}/* ....................... end of G726_floata() ....................... *//* ---------------------------------------------------------------------- void G726_floatb (short *sr, short *sr0); ~~~~~~~~~~~~~~~~ Description: ~~~~~~~~~~~~ Convert 16-bit two's complement to floating point. Inputs: sr Output: sr0 Return value: none. ~~~~~~~~~~~~~ Prototype: in g726.h ~~~~~~~~~~ History: ~~~~~~~~ 31.Jan.91 v1.0f Release of 1st Fortran version to UGST. <tdsindi@venus.cpqd.ansp.br> 13.Feb.92 v1.0c 1st version in C translated from Fortran (f2c) <tdsimao@venus.cpqd.ansp.br> ----------------------------------------------------------------------*/void G726_floatb(sr, sr0) short *sr, *sr0;{ long mant; long mag, exp_, srr, srs; /* Preamble */ srr = *sr & 65535; /* Sign */ srs = (srr >> 15); /* Compute magnitude */ mag = (srs == 0) ? srr : ((65536 - srr) & 32767); /* Exponent */ if (mag >= 16384) exp_ = 15; else if (mag >= 8192) exp_ = 14; else if (mag >= 4096) exp_ = 13; else if (mag >= 2048) exp_ = 12; else if (mag >= 1024) exp_ = 11; else if (mag >= 512) exp_ = 10; else if (mag >= 256) exp_ = 9; else if (mag >= 128) exp_ = 8; else if (mag >= 64) exp_ = 7; else if (mag >= 32) exp_ = 6; else if (mag >= 16) exp_ = 5; else if (mag >= 8) exp_ = 4; else if (mag >= 4) exp_ = 3; else if (mag >= 2) exp_ = 2; else if (mag == 1) exp_ = 1; else exp_ = 0; /* Compute mantissa w/a 1 in the most sig. bit */ mant = (mag == 0) ? (1 << 5) : ((mag << 6) >> exp_); /* Combine sign, exponent and mantissa (1,4,6) bits in a word */ *sr0 = (short) ((srs << 10) + (exp_ << 6) + mant);}/* ....................... end of G726_floatb() ....................... *//* ---------------------------------------------------------------------- void G726_fmult (short *a, short *srn, short *wa); ~~~~~~~~~~~~~~~ Description: ~~~~~~~~~~~~ Multiply predictor coefficients with corresponding quantized difference signal or reconstructed signal. multiplication is done in floating piont format Inputs: a (or b), srn (or dqn) Outputs: wa (or wb) Return value: none. ~~~~~~~~~~~~~ Prototype: in g726.h ~~~~~~~~~~ History: ~~~~~~~~ 31.Jan.91 v1.0f Release of 1st Fortran version to UGST. <tdsindi@venus.cpqd.ansp.br> 13.Feb.92 v1.0c 1st version in C translated from Fortran (f2c) <tdsimao@venus.cpqd.ansp.br> ----------------------------------------------------------------------*/void G726_fmult(An, SRn, WAn) short *An, *SRn, *WAn;{ long anmag, anexp, wanmag, anmant; long wanexp, srnexp, an, ans, wanmant, srnmant; long wan, wans, srns, srn1; /* Preamble */ an = *An & 65535; srn1 = *SRn & 65535; /* Sign */ ans = an & 32768; ans = (ans >> 15); /* Convert 2's complement to signed magnitude */ anmag = (ans == 0) ? (an >> 2) : ((16384 - (an >> 2)) & 8191); /* Exponent */ if (anmag >= 4096) anexp = 13; else if (anmag >= 2048) anexp = 12; else if (anmag >= 1024) anexp = 11; else if (anmag >= 512) anexp = 10; else if (anmag >= 256) anexp = 9; else if (anmag >= 128) anexp = 8; else if (anmag >= 64) anexp = 7; else if (anmag >= 32) anexp = 6; else if (anmag >= 16) anexp = 5; else if (anmag >= 8) anexp = 4; else if (anmag >= 4) anexp = 3; else if (anmag >= 2) anexp = 2; else if (anmag == 1) anexp = 1; else anexp = 0; /* Compute mantissa w/a 1 in the most sig. bit */ anmant = (anmag == 0) ? (1 << 5) : ((anmag << 6) >> anexp); /* Split floating point word into sign, exponent and mantissa */ srns = (srn1 >> 10); srnexp = (srn1 >> 6) & 15; srnmant = srn1 & 63; /* Floating point multiplication */ wans = srns ^ ans; wanexp = srnexp + anexp; wanmant = ((srnmant * anmant) + 48) >> 4; /* Convert floating point to magnitude */ wanmag = (wanexp <= 26) ? (wanmant << 7) >> (26 - wanexp) : ((wanmant << 7) << (wanexp - 26)) & 32767; /* Convert mag. to 2's complement */ wan = (wans == 0) ? wanmag : ((65536 - wanmag) & 65535); *WAn = (short) wan;}/* ....................... end of G726_fmult() ....................... *//* ---------------------------------------------------------------------- void G726_limc (short *a2t, short *a2p); ~~~~~~~~~~~~~~ Description: ~~~~~~~~~~~~ Limits on a2 coefficient of second order predictor. Inputs: a2t Output: a2p Return value: none. ~~~~~~~~~~~~~ Prototype: in g726.h ~~~~~~~~~~ History: ~~~~~~~~ 31.Jan.91 v1.0f Release of 1st Fortran version to UGST. <tdsindi@venus.cpqd.ansp.br> 13.Feb.92 v1.0c 1st version in C translated from Fortran (f2c) <tdsimao@venus.cpqd.ansp.br> ----------------------------------------------------------------------*/void G726_limc(a2t, a2p) short *a2t, *a2p;{ long a2p1, a2t1, a2ll, a2ul; a2t1 = *a2t & 65535; a2ul = 12288; /* Upper limit of +.75 */ a2ll = 53248; /* Lower limit of -.75 */ if (a2t1 >= 32768 && a2t1 <= a2ll) a2p1 = a2ll; else if (a2t1 >= a2ul && a2t1 <= 32767) a2p1 = a2ul; else a2p1 = a2t1; *a2p = (short) a2p1;}/* ....................... end of G726_limc() ....................... *//* ---------------------------------------------------------------------- void G726_limd (short *a1t, short *a2p, short *a1p); ~~~~~~~~~~~~~~ Description: ~~~~~~~~~~~~ Limits on a1 coefficient of second order predictor. Inputs: a1t, a2p Output: a1p Return value: none. ~~~~~~~~~~~~~ Prototype: in g726.h ~~~~~~~~~~ History: ~~~~~~~~ 31.Jan.91 v1.0f Release o
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -