📄 g729ev_main_oper_32b.c
字号:
| denom_hi is a normalize number. | | The result is in Q30. | | | | Inputs : | | | | L_num | | 32 bit long signed integer (Word32) whose value falls in the | | range : 0x0000 0000 < L_num < L_denom | | | | L_denom = denom_hi<<16 + denom_lo<<1 (DPF) | | | | denom_hi | | 16 bit positive normalized integer whose value falls in the | | range : 0x4000 < hi < 0x7fff | | denom_lo | | 16 bit positive integer whose value falls in the | | range : 0 < lo < 0x7fff | | | | Return Value : | | | | L_div | | 32 bit long signed integer (Word32) whose value falls in the | | range : 0x0000 0000 <= L_div <= 0x7fff ffff. | | It's a Q31 value | | | | Algorithm: | | | | - find = 1/L_denom. | | First approximation: approx = 1 / denom_hi | | 1/L_denom = approx * (2.0 - L_denom * approx ) | | | | - result = L_num * (1/L_denom) | |___________________________________________________________________________|*/Word32 Div_32(Word32 L_num, Word16 denom_hi, Word16 denom_lo){ Word16 approx, hi, lo, n_hi, n_lo; Word32 L_32; /* First approximation: 1 / L_denom = 1/denom_hi */ approx = div_s((Word16) 0x3fff, denom_hi); /* result in Q14 */ /* Note: 3fff = 0.5 in Q15 */ /* 1/L_denom = approx * (2.0 - L_denom * approx) */ L_32 = Mpy_32_16(denom_hi, denom_lo, approx); /* result in Q30 */ L_32 = L_sub((Word32) 0x7fffffffL, L_32); /* result in Q30 */ L_Extract(L_32, &hi, &lo); L_32 = Mpy_32_16(hi, lo, approx); /* = 1/L_denom in Q29 */ /* L_num * (1/L_denom) */ L_Extract(L_32, &hi, &lo); L_Extract(L_num, &n_hi, &n_lo); L_32 = Mpy_32(n_hi, n_lo, hi, lo); /* result in Q29 */ L_32 = L_shl(L_32, 2); /* From Q29 to Q31 */ return (L_32);}/*___________________________________________________________________________ | | | Function Name : UL_add | | | | Purpose : | | | | 32 bits addition of the two unsigned 32 bits variables (L_var1+L_var2) | | with overflow control and saturation | |___________________________________________________________________________|*/UWord32 UL_add(UWord32 a, UWord32 b){ UWord32 UL_var_out; UL_var_out = a + b; if ((a + b) > (UWord32) 0XffffffffL) { UL_var_out = (UWord32) 0XffffffffL; Overflow = 1; }#if (WMOPS) multiCounter[currCounter].L_add++;#endif return (UL_var_out);}/*___________________________________________________________________________ | | | Function Name : UL_sub | | | | Purpose : | | | | 32 bits substration of the two unsigned 32 bits variables | | (L_var1-L_var2) with overflow control and saturation | |___________________________________________________________________________|*/void UL_sub(UWord32 a, UWord32 b, UWord32 * c, UWord16 * sgn){ /* the current carry is not used, nor updated... */ if (a >= b) { *c = a - b; *sgn = 0; } else { *c = b - a; *sgn = 1; }#ifdef WMOPS multiCounter[currCounter].L_sub++;#endif}/*___________________________________________________________________________ | | | Function Name : UL_shl | | | | Purpose : | | | | Arithmetically shift the unsigned 32 bit input L_var1 left | | var2 positions. Zero fill the var2 LSB of the result. | |___________________________________________________________________________|*/UWord32 UL_shl(UWord32 a, Word16 b){ UWord32 UL_var_out = 0; FOR(; b > 0; b--) { if (a > (UWord32) 0X7fffffffL) { Overflow = 1; UL_var_out = 0XffffffffL; break; } a *= 2; UL_var_out = a; }#if (WMOPS) multiCounter[currCounter].L_shl++;#endif return (UL_var_out);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -