diff --git a/.gitignore b/.gitignore index caff0562653d7839fd8e003ba34579a9edad4fc4..f1a7c518a48e712d96a84f42ee9ffdd46307a45e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,8 +4,6 @@ /build /COMPLEXITY -/scripts/my_config -/scripts/wmops/logs /Workspace_msvc/.vs/Workspace_msvc/v16/ipch/AutoPCH /Workspace_msvc/.vs/Workspace_msvc/v16 /Workspace_msvc/Debug @@ -16,6 +14,3 @@ *.user /EVS_cod.exe /EVS_dec.exe -/IvasBuilder.txt -*.xlsx -/scripts/c-code_instrument diff --git a/README.md b/README.md index 8e535e326c5f1a85b224cc6b958caffda77a6a2c..764f28311e5295528a72a0ea4a4af7f55b629383 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -This is a modified version of the EVS BASOP reference code 26.442 V16.4.0 (2021-04). The source code has been adjusted to enable the WMC tool for complexity and memory instrumentation. +This is a modified version of the EVS BASOP ALT reference code 26.452 V18.0.0 (2024-05-16). The source code has been adjusted to enable the WMC tool for complexity and memory instrumentation. To estimate complexity and memory usage, navigate to the root folder and run these commands (Linux): diff --git a/basic_math/log2.c b/basic_math/log2.c index bc1a75724d7783b84de3fe29182d5e3ef03f1cf8..57abb3352b34e9bb9fd50235cc1a805c41e4b313 100644 --- a/basic_math/log2.c +++ b/basic_math/log2.c @@ -12,8 +12,6 @@ ******************************************************************************** */ #include "stl.h" -#include "wmc_auto.h" - #include "math_op.h" #include #include "rom_basic_math.h" diff --git a/basic_math/math_32.c b/basic_math/math_32.c deleted file mode 100644 index 0d8b16fc43bcca882887b4a7b3f5ec14ed67b54e..0000000000000000000000000000000000000000 --- a/basic_math/math_32.c +++ /dev/null @@ -1,79 +0,0 @@ -/*#include "options.h" */ -#include "stl.h" -#include "wmc_auto.h" - -#ifdef ALLOW_40bits -#include "enh40.h" -#endif -#include "oper_32b.h" - -/* 32x16 multiply: */ -Word32 Mult_32_16(Word32 a, Word16 b) -{ - Word32 result; -#ifdef ALLOW_40bits /* if activated; need 40 bits basic-op files */ - UWord16 lo; - /* use Mpy_32_16_ss(): */ - Mpy_32_16_ss(a, b, &result, &lo); -#else - Word16 lo, hi; - /* do things by hand: */ - lo = L_Extract_lc(a, &hi); - result = Mpy_32_16(hi, lo, b); -#endif - return result; -} -/* 32x32 multiply: */ -Word32 Mult_32_32(Word32 a, Word32 b) -{ - Word32 result; -#ifdef ALLOW_40bits /* if activated; need 40 bits basic-op files */ - UWord32 lo; - /* use Mpy_32_32_ss(): */ - Mpy_32_32_ss(a, b, &result, &lo); -#else - Word16 hi, lo, b_hi, b_lo; - /* do things by hand: */ - lo = L_Extract_lc(a, &hi); - b_lo = L_Extract_lc(b, &b_hi); - result = Mpy_32(hi, lo, b_hi, b_lo); -#endif - return result; -} - -/* 32x16 multiply-accumulate: */ -Word32 Madd_32_16(Word32 L_num, Word32 a, Word16 b) -{ - Word32 result; -#ifdef ALLOW_40bits /* if activated; need 40 bits basic-op files */ - UWord16 lo; - /* use Mpy_32_16_ss(): */ - Mpy_32_16_ss(a, b, &result, &lo); - result = L_add(L_num, result); -#else - Word16 lo, hi; - /* do things by hand: */ - lo = L_Extract_lc(a, &hi); - result = Mac_32_16(L_num, hi, lo, b); -#endif - return result; -} - -/* 32x16 multiply-substract: */ -Word32 Msub_32_16(Word32 L_num, Word32 a, Word16 b) -{ - Word32 result; -#ifdef ALLOW_40bits /* if activated; need 40 bits basic-op files */ - UWord16 lo; - /* use Mpy_32_16_ss(): */ - Mpy_32_16_ss(a, b, &result, &lo); - result = L_sub(L_num, result); -#else - Word16 lo, hi; - /* do things by hand: */ - lo = L_Extract_lc(a, &hi); - result = Msu_32_16(L_num, hi, lo, b); -#endif - return result; -} - diff --git a/basic_math/math_32.h b/basic_math/math_32.h index 0a2c1247fd2b340ae1c753340f2cfb859bbe7696..539284d5a28e25aee9cb74576ca9c14c35b7593c 100644 --- a/basic_math/math_32.h +++ b/basic_math/math_32.h @@ -3,10 +3,8 @@ #include "typedef.h" #include "basop32.h" +#include "enh32.h" -extern Word32 Mult_32_16(Word32 a, Word16 b); -extern Word32 Madd_32_16(Word32 L_num, Word32 a, Word16 b); -extern Word32 Msub_32_16(Word32 L_num, Word32 a, Word16 b); -extern Word32 Mult_32_32(Word32 a, Word32 b); - -#endif +#define Mult_32_16(A,B) Mpy_32_16_1(A,B) +#define Mult_32_32(A,B) Mpy_32_32(A,B) +#endif /* #ifndef _MATH_32_H_ */ diff --git a/basic_math/math_op.c b/basic_math/math_op.c index 6b16a7bfe57be05b672822218b83381639040393..a5256a2af9156d59267cbf43509f2e4044f8a175 100644 --- a/basic_math/math_op.c +++ b/basic_math/math_op.c @@ -17,8 +17,6 @@ */ #include "stl.h" -#include "wmc_auto.h" - #include "math_op.h" #include "rom_basic_math.h" diff --git a/basic_math/oper_32b.c b/basic_math/oper_32b.c index 5e2e94a538ccdb0abefbea0f1350062b11974b5a..1904cdd882a56674be5451ef68035e8cf1287aac 100644 --- a/basic_math/oper_32b.c +++ b/basic_math/oper_32b.c @@ -23,8 +23,6 @@ */ #include "stl.h" -#include "wmc_auto.h" - #include "math_op.h" /***************************************************************************** diff --git a/basic_math/rom_basic_math.c b/basic_math/rom_basic_math.c index 293260e5f8aa9a8571f15db265a607327b79f5a4..8c81378209d0a5f2b20c04eea2460d328b4fb2ce 100644 --- a/basic_math/rom_basic_math.c +++ b/basic_math/rom_basic_math.c @@ -1,9 +1,6 @@ #include "options.h" /* Compilation switches */ -#include "stl.h" -#include "wmc_auto.h" - - #include "cnst_fx.h" /* Decoder static structure */ +#include "stl.h" /* math_op.c */ const Word32 L_table_isqrt[48] = diff --git a/basic_op/README.md b/basic_op/README.md new file mode 100644 index 0000000000000000000000000000000000000000..47ff87ced765c8312fd0e96da124070d0bd841d8 --- /dev/null +++ b/basic_op/README.md @@ -0,0 +1,101 @@ + + Read-me for ITU-T/UGST Basic Operator Module V.2.3 + (30.Nov.2009) + + ============================================================= + COPYRIGHT NOTE: This source code, and all of its derivations, + is subject to the "ITU-T General Public License". Please have + it read in the distribution disk, or in the ITU-T + Recommendation G.191 on "SOFTWARE TOOLS FOR SPEECH AND AUDIO + CODING STANDARDS". + ============================================================= + +# Changes v.2.2 --> v.2.3 + +Modifications in `basop32.c` and `basop32.h` +- Function `round()` is now named `round_fx()`, to avoid clashes with +standard C library. +- Function `saturate()` is made unreferencable from outside application. + +Added new functionalities: +- Basic operator counter utility: `basop_cnt.c` +- Complexity evaluation tool for floating-point: `flc.h`, `flc.c` + +# Changes v.2.1 --> v.2.2 + +New functions in `count.c`: +- `void setFrameRate(int samplingFreq, int frameLength);` + + This function can overwrite the value of the frameRate variable + that is initialized by the `FRAME_RATE` constant. + +- `void WMOPS_output_avg (Word16 dtx_mode, Word32 *tot_wm, Word16 *num_frames);` + + Same as `WMOPS_output` + returns the total wmops counter and the number of frames + to support the computation of advanced complexity results as the global average. + +An example of the use of `WMOPS_output_avg` is given below: + +In a decoder, the `spe1Id` was used for valid frames while the `spe2Id` counter was used for erased frames. +Using the `WMOPS_output_avg` the global average complexity can be also displayed : + + short spe1Id = getCounterId("Valid frames"); + short spe2Id = getCounterId("Bad frames"); + long tot_wm1; + short num_frames1; + long tot_wm2; + short num_frames2; + + ... + + setCounter(spe1Id); + fwc(); + WMOPS_output_avg(0, &tot_wm1, &num_frames1); + setCounter(spe2Id); + fwc(); + WMOPS_output_avg(0, &tot_wm2, &num_frames2); + printf("Global average %f WMOPS\n", (tot_wm1 + tot_wm2)/(float)(num_frames1 + num_frames2)); + + Modifications in count.c: + - L_mls() is weighted 5. + - div_l() is weighted 32. + - i_mult() is weighted 3. + +# Changes v.2.0 --> v.2.1 + +Improved portability: +- in header files `__inline` was changed to `static __inline` +- `//` style comments were changed to `/* */` +- Cygwin added in the supported compiler list (`typedef.h`) +- Word40 definition was added for Sun and Unix (`typedef.h`) + +Corrections: +- missing incrementations were added for `s_and`, `s_or` and `s_xor` (`enh1632.h`) + +# Original version: v.2.0 + +The ITU-T/UGST Basic Operator module contains the following files: + +## C code: (`model` directory) + + basop32.c: ....... 16/32 bit basic operators + basop32.h: ....... Prototypes for basop32.c + count.c: ......... Functions for WMOPS computation + count.h: ......... Prototypes for count.c + typedef.h: ....... Data type definitions + typedefs.h: ...... New data type definitions + move.h: .......... Move & miscellaneous legacy operators + control.c: ....... Control operator internal variable decl. + control.h: ....... Control operators + enh1632.c: ....... Enhanced 16/32 bit basic operators + enh1632.h: ....... Prototypes for enh1632.c + enh40.c: ......... 40 bit basic operators + enh40.h: ......... Prototypes for enh40.c + patch.h: ......... Backward compatibility for operator names + stl.h: ........... Main header file + +## Demos: + +Demo programs are not available for this module. + +-- diff --git a/basic_op/basop.rme b/basic_op/basop.rme index 8ae3dc466bd4a83cb2a02cf08787e4ac4aefa903..361ebc40393e28697f5c385c722ca1b2fb36f9ce 100644 --- a/basic_op/basop.rme +++ b/basic_op/basop.rme @@ -1,6 +1,6 @@ - Read-me for ITU-T/UGST Basic Operator Module - (12.November.2004) + Read-me for ITU-T/UGST Basic Operator Module V.2.3 + (30.Nov.2009) ============================================================= COPYRIGHT NOTE: This source code, and all of its derivations, @@ -10,15 +10,78 @@ CODING STANDARDS". ============================================================= +Changes v.2.2 --> v.2.3 +*********************** -The ITU-T/UGST Basic Operator module contails the following files: +Modifications in basop32.c and basop32.h + - Function round() is now named round_fx(), to avoid clashes with + standard C library. + - Function saturate() is made unreferencable from outside application. + +Added new functionalities: + - Basic operator counter utility: basop_cnt.c + - Complexity evaluation tool for floating-point: flc.h, flc.c + +Changes v.2.1 --> v.2.2 +*********************** + +New functions in count.c: + - void setFrameRate(int samplingFreq, int frameLength); + This function can overwrite the value of the frameRate variable + that is initialized by the FRAME_RATE constant. + - void WMOPS_output_avg (Word16 dtx_mode, Word32 *tot_wm, Word16 *num_frames); + same as WMOPS_output + returns the total wmops counter and the number of frames + to support the computation of advanced complexity results as the global average. + +An example of the use of WMOPS_output_avg is given below: + +In a decoder, the spe1Id was used for valid frames while the spe2Id counter was used for erased frames. +Using the WMOPS_output_avg the global average complexity can be also displayed : + +short spe1Id = getCounterId("Valid frames"); +short spe2Id = getCounterId("Bad frames"); +long tot_wm1; +short num_frames1; +long tot_wm2; +short num_frames2; + +... + +setCounter(spe1Id); +fwc(); +WMOPS_output_avg(0, &tot_wm1, &num_frames1); +setCounter(spe2Id); +fwc(); +WMOPS_output_avg(0, &tot_wm2, &num_frames2); +printf("Global average %f WMOPS\n", (tot_wm1 + tot_wm2)/(float)(num_frames1 + num_frames2)); +Modifications in count.c: + - L_mls() is weighted 5. + - div_l() is weighted 32. + - i_mult() is weighted 3. + +Changes v.2.0 --> v.2.1 +*********************** + +Improved portability: + - in header files "__inline" was changed to "static __inline" + - // style comments were changed to /* */ + - Cygwin added in the supported compiler list (typedef.h) + - Word40 definition was added for Sun and Unix (typedef.h) +Corrections: + - missing incrementations were added for s_and, s_or and s_xor (enh1632.h) + + + +Original version: v.2.0 +*********************** + +The ITU-T/UGST Basic Operator module contails the following files: General: ~~~~~~~~ basop.rme: ....... Read-me file for Basic Operator module (this file) - - + C code: ('model' directory) ~~~~~~~~~~~~~~~~~~~~~~~~~~~ basop32.c: ....... 16/32 bit basic operators @@ -36,7 +99,13 @@ C code: ('model' directory) enh40.h: ......... Prototypes for enh40.c patch.h: ......... Backward compatibility for operator names stl.h: ........... Main header file - + enh64.c: ......... 64 bit basic operators + enh64.h: ......... Prototypes for enh64.c + enh32.c: ......... Extension to enhanced 32 bit operators + enh32.h: ......... Prototypes for enh32.c + complex_basop.c: ... 32/16 complex basic operators + complex_basop.h: ... Prototypes for complex_basop.c + Demos: ~~~~~~ Demo programs are not available for this module. diff --git a/basic_op/basop32.c b/basic_op/basop32.c index 870f4d1b403743a25034f3bc1400fd753ea3013d..b83cd21ab78eaee7c66e6c884b6d3b2deeb79cf5 100644 --- a/basic_op/basop32.c +++ b/basic_op/basop32.c @@ -22,7 +22,7 @@ MODULE: BASOP32, BASIC OPERATORS ORIGINAL BY: - Incorporated from anonymous contributions for + Incorporated from anonymous contributions for ETSI Standards as well as G.723.1, G.729, and G.722.1 DESCRIPTION: @@ -42,16 +42,16 @@ FUNCTIONS: Defined in basop32.h. Self-documentation within each function. HISTORY: - 26.Jan.00 v1.0 Incorporated to the STL from updated G.723.1/G.729 - basic operator library (based on basicop2.c) and + 26.Jan.00 v1.0 Incorporated to the STL from updated G.723.1/G.729 + basic operator library (based on basicop2.c) and G.723.1's basop.c [L_mls(), div_l(), i_mult()] - 05.Jul.00 v1.1 Added 32-bit shiftless accumulation basic + 05.Jul.00 v1.1 Added 32-bit shiftless accumulation basic operators (L_msu0, L_mac0, L_mult0). Improved documentation for i_mult(). 03 Nov 04 v2.0 Incorporation of new 32-bit / 40-bit / control - operators for the ITU-T Standard Tool Library as + operators for the ITU-T Standard Tool Library as described in Geneva, 20-30 January 2004 WP 3/16 Q10/16 TD 11 document and subsequent discussions on the wp3audio@yahoogroups.com email reflector. @@ -82,7 +82,7 @@ HISTORY: | | | Basic arithmetic operators. | | | - | | + | $Id $ | | | | saturate() | | add() | @@ -121,16 +121,12 @@ HISTORY: | Include-Files | |___________________________________________________________________________| */ - #include #include #include "stl.h" -#include "wmc_auto.h" - - -#ifdef WMOPS +#if (WMOPS) extern BASIC_OP multiCounter[MAXCOUNTERS]; extern int currCounter; #endif @@ -159,10 +155,6 @@ Flag Carry = 0; |___________________________________________________________________________| */ -#define PRINT_STACK_ID_ALL "*" - - - /*___________________________________________________________________________ | | | Function Name : saturate | @@ -189,31 +181,23 @@ Flag Carry = 0; | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ -static Word16 saturate (Word32 L_var1) -{ - Word16 var_out; - - if (L_var1 > 0X00007fffL) - { - Overflow = 1; - var_out = MAX_16; - } - else if (L_var1 < (Word32) 0xffff8000L) - { - Overflow = 1; - var_out = MIN_16; - } - else - { - var_out = extract_l (L_var1); -#ifdef WMOPS - multiCounter[currCounter].extract_l--; +static Word16 saturate (Word32 L_var1) { + Word16 var_out; + + if (L_var1 > 0X00007fffL) { + Overflow = 1; + var_out = MAX_16; + } else if (L_var1 < (Word32) 0xffff8000L) { + Overflow = 1; + var_out = MIN_16; + } else { + var_out = extract_l (L_var1); +#if (WMOPS) + multiCounter[currCounter].extract_l--; #endif - } + } - BASOP_CHECK(); - - return (var_out); + return (var_out); } @@ -250,18 +234,17 @@ static Word16 saturate (Word32 L_var1) | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ -Word16 add (Word16 var1, Word16 var2) -{ - Word16 var_out; - Word32 L_sum; +Word16 add (Word16 var1, Word16 var2) { + Word16 var_out; + Word32 L_sum; - L_sum = (Word32) var1 + var2; - var_out = saturate (L_sum); + L_sum = (Word32) var1 + var2; + var_out = saturate (L_sum); -#ifdef WMOPS - multiCounter[currCounter].add++; +#if (WMOPS) + multiCounter[currCounter].add++; #endif - return (var_out); + return (var_out); } @@ -298,18 +281,17 @@ Word16 add (Word16 var1, Word16 var2) | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ -Word16 sub (Word16 var1, Word16 var2) -{ - Word16 var_out; - Word32 L_diff; +Word16 sub (Word16 var1, Word16 var2) { + Word16 var_out; + Word32 L_diff; - L_diff = (Word32) var1 - var2; - var_out = saturate (L_diff); + L_diff = (Word32) var1 - var2; + var_out = saturate (L_diff); -#ifdef WMOPS - multiCounter[currCounter].sub++; +#if (WMOPS) + multiCounter[currCounter].sub++; #endif - return (var_out); + return (var_out); } @@ -340,33 +322,23 @@ Word16 sub (Word16 var1, Word16 var2) | range : 0x0000 0000 <= var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ -Word16 abs_s (Word16 var1) -{ - Word16 var_out; - - if (var1 == (Word16) MIN_16) - { - var_out = MAX_16; - } - else - { - if (var1 < 0) - { - var_out = -var1; - } - else - { - var_out = var1; - } +Word16 abs_s (Word16 var1) { + Word16 var_out; + + if (var1 == (Word16) MIN_16) { + var_out = MAX_16; + } else { + if (var1 < 0) { + var_out = -var1; + } else { + var_out = var1; } + } -#ifdef WMOPS - multiCounter[currCounter].abs_s++; +#if (WMOPS) + multiCounter[currCounter].abs_s++; #endif - - BASOP_CHECK(); - - return (var_out); + return (var_out); } @@ -404,48 +376,38 @@ Word16 abs_s (Word16 var1) | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ -Word16 shl (Word16 var1, Word16 var2) -{ - Word16 var_out; - Word32 result; - - if (var2 < 0) - { - if (var2 < -16) - var2 = -16; - var2 = -var2; - var_out = shr (var1, var2); - -#ifdef WMOPS - multiCounter[currCounter].shr--; +Word16 shl (Word16 var1, Word16 var2) { + Word16 var_out; + Word32 result; + + if (var2 < 0) { + if (var2 < -16) + var2 = -16; + var2 = -var2; + var_out = shr (var1, var2); + +#if (WMOPS) + multiCounter[currCounter].shr--; #endif - } - else - { - result = (Word32) var1 *((Word32) 1 << var2); - - if ((var2 > 15 && var1 != 0) || (result != (Word32) ((Word16) result))) - { - Overflow = 1; - var_out = (var1 > 0) ? MAX_16 : MIN_16; - } - else - { - var_out = extract_l (result); + } else { + result = (Word32) var1 *((Word32) 1 << var2); + + if ((var2 > 15 && var1 != 0) || (result != (Word32) ((Word16) result))) { + Overflow = 1; + var_out = (var1 > 0) ? MAX_16 : MIN_16; + } else { + var_out = extract_l (result); -#ifdef WMOPS - multiCounter[currCounter].extract_l--; +#if (WMOPS) + multiCounter[currCounter].extract_l--; #endif - } } + } -#ifdef WMOPS - multiCounter[currCounter].shl++; +#if (WMOPS) + multiCounter[currCounter].shl++; #endif - - BASOP_CHECK(); - - return (var_out); + return (var_out); } @@ -483,47 +445,34 @@ Word16 shl (Word16 var1, Word16 var2) | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ -Word16 shr (Word16 var1, Word16 var2) -{ - Word16 var_out; - - if (var2 < 0) - { - if (var2 < -16) - var2 = -16; - var2 = -var2; - var_out = shl (var1, var2); - -#ifdef WMOPS - multiCounter[currCounter].shl--; +Word16 shr (Word16 var1, Word16 var2) { + Word16 var_out; + + if (var2 < 0) { + if (var2 < -16) + var2 = -16; + var2 = -var2; + var_out = shl (var1, var2); + +#if (WMOPS) + multiCounter[currCounter].shl--; #endif + } else { + if (var2 >= 15) { + var_out = (var1 < 0) ? -1 : 0; + } else { + if (var1 < 0) { + var_out = ~((~var1) >> var2); + } else { + var_out = var1 >> var2; + } } - else - { - if (var2 >= 15) - { - var_out = (var1 < 0) ? -1 : 0; - } - else - { - if (var1 < 0) - { - var_out = ~((~var1) >> var2); - } - else - { - var_out = var1 >> var2; - } - } - } + } -#ifdef WMOPS - multiCounter[currCounter].shr++; +#if (WMOPS) + multiCounter[currCounter].shr++; #endif - - BASOP_CHECK(); - - return (var_out); + return (var_out); } @@ -561,24 +510,23 @@ Word16 shr (Word16 var1, Word16 var2) | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ -Word16 mult (Word16 var1, Word16 var2) -{ - Word16 var_out; - Word32 L_product; +Word16 mult (Word16 var1, Word16 var2) { + Word16 var_out; + Word32 L_product; - L_product = (Word32) var1 *(Word32) var2; + L_product = (Word32) var1 *(Word32) var2; - L_product = (L_product & (Word32) 0xffff8000L) >> 15; + L_product = (L_product & (Word32) 0xffff8000L) >> 15; - if (L_product & (Word32) 0x00010000L) - L_product = L_product | (Word32) 0xffff0000L; + if (L_product & (Word32) 0x00010000L) + L_product = L_product | (Word32) 0xffff0000L; - var_out = saturate (L_product); + var_out = saturate (L_product); -#ifdef WMOPS - multiCounter[currCounter].mult++; +#if (WMOPS) + multiCounter[currCounter].mult++; #endif - return (var_out); + return (var_out); } @@ -616,29 +564,22 @@ Word16 mult (Word16 var1, Word16 var2) | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |___________________________________________________________________________| */ -Word32 L_mult (Word16 var1, Word16 var2) -{ - Word32 L_var_out; +Word32 L_mult (Word16 var1, Word16 var2) { + Word32 L_var_out; - L_var_out = (Word32) var1 *(Word32) var2; + L_var_out = (Word32) var1 *(Word32) var2; - if (L_var_out != (Word32) 0x40000000L) - { - L_var_out *= 2; - } - else - { - Overflow = 1; - L_var_out = MAX_32; - } + if (L_var_out != (Word32) 0x40000000L) { + L_var_out *= 2; + } else { + Overflow = 1; + L_var_out = MAX_32; + } -#ifdef WMOPS - multiCounter[currCounter].L_mult++; +#if (WMOPS) + multiCounter[currCounter].L_mult++; #endif - - BASOP_CHECK(); - - return (L_var_out); + return (L_var_out); } @@ -670,20 +611,15 @@ Word32 L_mult (Word16 var1, Word16 var2) | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ -Word16 negate (Word16 var1) -{ - Word16 var_out; - - var_out = (var1 == MIN_16) ? MAX_16 : -var1; +Word16 negate (Word16 var1) { + Word16 var_out; + var_out = (var1 == MIN_16) ? MAX_16 : -var1; -#ifdef WMOPS - multiCounter[currCounter].negate++; +#if (WMOPS) + multiCounter[currCounter].negate++; #endif - - BASOP_CHECK(); - - return (var_out); + return (var_out); } @@ -714,19 +650,15 @@ Word16 negate (Word16 var1) | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ -Word16 extract_h (Word32 L_var1) -{ - Word16 var_out; +Word16 extract_h (Word32 L_var1) { + Word16 var_out; - var_out = (Word16) (L_var1 >> 16); + var_out = (Word16) (L_var1 >> 16); -#ifdef WMOPS - multiCounter[currCounter].extract_h++; +#if (WMOPS) + multiCounter[currCounter].extract_h++; #endif - - BASOP_CHECK(); - - return (var_out); + return (var_out); } @@ -757,19 +689,15 @@ Word16 extract_h (Word32 L_var1) | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ -Word16 extract_l (Word32 L_var1) -{ - Word16 var_out; +Word16 extract_l (Word32 L_var1) { + Word16 var_out; - var_out = (Word16) L_var1; + var_out = (Word16) L_var1; -#ifdef WMOPS - multiCounter[currCounter].extract_l++; +#if (WMOPS) + multiCounter[currCounter].extract_l++; #endif - - BASOP_CHECK(); - - return (var_out); + return (var_out); } @@ -803,25 +731,19 @@ Word16 extract_l (Word32 L_var1) | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ -Word16 round_fx (Word32 L_var1) -{ - Word16 var_out; - Word32 L_rounded; - -BASOP_SATURATE_WARNING_ON; - L_rounded = L_add (L_var1, (Word32) 0x00008000L); -BASOP_SATURATE_WARNING_ON; - var_out = extract_h (L_rounded); - -#ifdef WMOPS - multiCounter[currCounter].L_add--; - multiCounter[currCounter].extract_h--; - multiCounter[currCounter].round++; -#endif +Word16 round_fx (Word32 L_var1) { + Word16 var_out; + Word32 L_rounded; - BASOP_CHECK(); + L_rounded = L_add (L_var1, (Word32) 0x00008000L); + var_out = extract_h (L_rounded); - return (var_out); +#if (WMOPS) + multiCounter[currCounter].L_add--; + multiCounter[currCounter].extract_h--; + multiCounter[currCounter].round++; +#endif + return (var_out); } @@ -861,23 +783,19 @@ BASOP_SATURATE_WARNING_ON; | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |___________________________________________________________________________| */ -Word32 L_mac (Word32 L_var3, Word16 var1, Word16 var2) -{ - Word32 L_var_out; - Word32 L_product; - - L_product = L_mult (var1, var2); - L_var_out = L_add (L_var3, L_product); - -#ifdef WMOPS - multiCounter[currCounter].L_mult--; - multiCounter[currCounter].L_add--; - multiCounter[currCounter].L_mac++; -#endif +Word32 L_mac (Word32 L_var3, Word16 var1, Word16 var2) { + Word32 L_var_out; + Word32 L_product; - BASOP_CHECK(); + L_product = L_mult (var1, var2); + L_var_out = L_add (L_var3, L_product); - return (L_var_out); +#if (WMOPS) + multiCounter[currCounter].L_mult--; + multiCounter[currCounter].L_add--; + multiCounter[currCounter].L_mac++; +#endif + return (L_var_out); } @@ -917,23 +835,19 @@ Word32 L_mac (Word32 L_var3, Word16 var1, Word16 var2) | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |___________________________________________________________________________| */ -Word32 L_msu (Word32 L_var3, Word16 var1, Word16 var2) -{ - Word32 L_var_out; - Word32 L_product; - - L_product = L_mult (var1, var2); - L_var_out = L_sub (L_var3, L_product); - -#ifdef WMOPS - multiCounter[currCounter].L_mult--; - multiCounter[currCounter].L_sub--; - multiCounter[currCounter].L_msu++; -#endif +Word32 L_msu (Word32 L_var3, Word16 var1, Word16 var2) { + Word32 L_var_out; + Word32 L_product; - BASOP_CHECK(); + L_product = L_mult (var1, var2); + L_var_out = L_sub (L_var3, L_product); - return (L_var_out); +#if (WMOPS) + multiCounter[currCounter].L_mult--; + multiCounter[currCounter].L_sub--; + multiCounter[currCounter].L_msu++; +#endif + return (L_var_out); } @@ -979,23 +893,18 @@ Word32 L_msu (Word32 L_var3, Word16 var1, Word16 var2) | operators which take into account its value. | |___________________________________________________________________________| */ -Word32 L_macNs (Word32 L_var3, Word16 var1, Word16 var2) -{ - Word32 L_var_out; +Word32 L_macNs (Word32 L_var3, Word16 var1, Word16 var2) { + Word32 L_var_out; - L_var_out = L_mult (var1, var2); - L_var_out = L_add_c (L_var3, L_var_out); + L_var_out = L_mult (var1, var2); + L_var_out = L_add_c (L_var3, L_var_out); -#ifdef WMOPS - multiCounter[currCounter].L_mult--; - multiCounter[currCounter].L_add_c--; - multiCounter[currCounter].L_macNs++; +#if (WMOPS) + multiCounter[currCounter].L_mult--; + multiCounter[currCounter].L_add_c--; + multiCounter[currCounter].L_macNs++; #endif - - /* BASOP_CHECK(); Do not check for overflow here, function produces the carry bit instead */ - - - return (L_var_out); + return (L_var_out); } @@ -1041,23 +950,19 @@ Word32 L_macNs (Word32 L_var3, Word16 var1, Word16 var2) | operators which take into account its value. | |___________________________________________________________________________| */ -Word32 L_msuNs (Word32 L_var3, Word16 var1, Word16 var2) -{ - Word32 L_var_out; +Word32 L_msuNs (Word32 L_var3, Word16 var1, Word16 var2) { + Word32 L_var_out; - L_var_out = L_mult (var1, var2); - L_var_out = L_sub_c (L_var3, L_var_out); + L_var_out = L_mult (var1, var2); + L_var_out = L_sub_c (L_var3, L_var_out); -#ifdef WMOPS - multiCounter[currCounter].L_mult--; - multiCounter[currCounter].L_sub_c--; - multiCounter[currCounter].L_msuNs++; +#if (WMOPS) + multiCounter[currCounter].L_mult--; + multiCounter[currCounter].L_sub_c--; + multiCounter[currCounter].L_msuNs++; #endif - - /* BASOP_CHECK(); Do not check for overflow here, function produces the carry bit instead */ - - return (L_var_out); + return (L_var_out); } @@ -1092,28 +997,21 @@ Word32 L_msuNs (Word32 L_var3, Word16 var1, Word16 var2) | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |___________________________________________________________________________| */ -Word32 L_add (Word32 L_var1, Word32 L_var2) -{ - Word32 L_var_out; - - L_var_out = L_var1 + L_var2; - - if (((L_var1 ^ L_var2) & MIN_32) == 0) - { - if ((L_var_out ^ L_var1) & MIN_32) - { - L_var_out = (L_var1 < 0) ? MIN_32 : MAX_32; - Overflow = 1; - } - } - -#ifdef WMOPS - multiCounter[currCounter].L_add++; -#endif +Word32 L_add (Word32 L_var1, Word32 L_var2) { + Word32 L_var_out; - BASOP_CHECK(); + L_var_out = L_var1 + L_var2; - return (L_var_out); + if (((L_var1 ^ L_var2) & MIN_32) == 0) { + if ((L_var_out ^ L_var1) & MIN_32) { + L_var_out = (L_var1 < 0) ? MIN_32 : MAX_32; + Overflow = 1; + } + } +#if (WMOPS) + multiCounter[currCounter].L_add++; +#endif + return (L_var_out); } @@ -1148,28 +1046,21 @@ Word32 L_add (Word32 L_var1, Word32 L_var2) | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |___________________________________________________________________________| */ -Word32 L_sub (Word32 L_var1, Word32 L_var2) -{ - Word32 L_var_out; - - L_var_out = L_var1 - L_var2; - - if (((L_var1 ^ L_var2) & MIN_32) != 0) - { - if ((L_var_out ^ L_var1) & MIN_32) - { - L_var_out = (L_var1 < 0L) ? MIN_32 : MAX_32; - Overflow = 1; - } - } - -#ifdef WMOPS - multiCounter[currCounter].L_sub++; -#endif +Word32 L_sub (Word32 L_var1, Word32 L_var2) { + Word32 L_var_out; - BASOP_CHECK(); + L_var_out = L_var1 - L_var2; - return (L_var_out); + if (((L_var1 ^ L_var2) & MIN_32) != 0) { + if ((L_var_out ^ L_var1) & MIN_32) { + L_var_out = (L_var1 < 0L) ? MIN_32 : MAX_32; + Overflow = 1; + } + } +#if (WMOPS) + multiCounter[currCounter].L_sub++; +#endif + return (L_var_out); } @@ -1210,82 +1101,57 @@ Word32 L_sub (Word32 L_var1, Word32 L_var2) | operators which take into account its value. | |___________________________________________________________________________| */ -Word32 L_add_c (Word32 L_var1, Word32 L_var2) -{ - Word32 L_var_out; - Word32 L_test; - Flag carry_int = 0; +Word32 L_add_c (Word32 L_var1, Word32 L_var2) { + Word32 L_var_out; + Word32 L_test; + Flag carry_int = 0; - L_var_out = L_var1 + L_var2 + Carry; + L_var_out = L_var1 + L_var2 + Carry; - L_test = L_var1 + L_var2; + L_test = L_var1 + L_var2; - if ((L_var1 > 0) && (L_var2 > 0) && (L_test < 0)) - { + if ((L_var1 > 0) && (L_var2 > 0) && (L_test < 0)) { + Overflow = 1; + carry_int = 0; + } else { + if ((L_var1 < 0) && (L_var2 < 0)) { + if (L_test >= 0) { Overflow = 1; + carry_int = 1; + } else { + Overflow = 0; + carry_int = 1; + } + } else { + if (((L_var1 ^ L_var2) < 0) && (L_test >= 0)) { + Overflow = 0; + carry_int = 1; + } else { + Overflow = 0; carry_int = 0; + } } - else - { - if ((L_var1 < 0) && (L_var2 < 0)) - { - if (L_test >= 0) - { - Overflow = 1; - carry_int = 1; - } - else - { - Overflow = 0; - carry_int = 1; - } - } - else - { - if (((L_var1 ^ L_var2) < 0) && (L_test >= 0)) - { - Overflow = 0; - carry_int = 1; - } - else - { - Overflow = 0; - carry_int = 0; - } - } - } - - if (Carry) - { - if (L_test == MAX_32) - { - Overflow = 1; - Carry = carry_int; - } - else - { - if (L_test == (Word32) 0xFFFFFFFFL) - { - Carry = 1; - } - else - { - Carry = carry_int; - } - } - } - else - { + } + + if (Carry) { + if (L_test == MAX_32) { + Overflow = 1; + Carry = carry_int; + } else { + if (L_test == (Word32) 0xFFFFFFFFL) { + Carry = 1; + } else { Carry = carry_int; + } } + } else { + Carry = carry_int; + } -#ifdef WMOPS - multiCounter[currCounter].L_add_c++; +#if (WMOPS) + multiCounter[currCounter].L_add_c++; #endif - - /* BASOP_CHECK(); Do not check for overflow here, function produces the carry bit instead */ - - return (L_var_out); + return (L_var_out); } @@ -1326,70 +1192,51 @@ Word32 L_add_c (Word32 L_var1, Word32 L_var2) | operators which take into account its value. | |___________________________________________________________________________| */ -Word32 L_sub_c (Word32 L_var1, Word32 L_var2) -{ - Word32 L_var_out; - Word32 L_test; - Flag carry_int = 0; - - if (Carry) - { - Carry = 0; - if (L_var2 != MIN_32) - { - L_var_out = L_add_c (L_var1, -L_var2); -#ifdef WMOPS - multiCounter[currCounter].L_add_c--; +Word32 L_sub_c (Word32 L_var1, Word32 L_var2) { + Word32 L_var_out; + Word32 L_test; + Flag carry_int = 0; + + if (Carry) { + Carry = 0; + if (L_var2 != MIN_32) { + L_var_out = L_add_c (L_var1, -L_var2); +#if (WMOPS) + multiCounter[currCounter].L_add_c--; #endif - } - else - { - L_var_out = L_var1 - L_var2; - if (L_var1 > 0L) - { - Overflow = 1; - Carry = 0; - } - } + } else { + L_var_out = L_var1 - L_var2; + if (L_var1 > 0L) { + Overflow = 1; + Carry = 0; + } } - else - { - L_var_out = L_var1 - L_var2 - (Word32) 0X00000001L; - L_test = L_var1 - L_var2; - - if ((L_test < 0) && (L_var1 > 0) && (L_var2 < 0)) - { - Overflow = 1; - carry_int = 0; - } - else if ((L_test > 0) && (L_var1 < 0) && (L_var2 > 0)) - { - Overflow = 1; - carry_int = 1; - } - else if ((L_test > 0) && ((L_var1 ^ L_var2) > 0)) - { - Overflow = 0; - carry_int = 1; - } - if (L_test == MIN_32) - { - Overflow = 1; - Carry = carry_int; - } - else - { - Carry = carry_int; - } + } else { + L_var_out = L_var1 - L_var2 - (Word32) 0X00000001L; + L_test = L_var1 - L_var2; + + if ((L_test < 0) && (L_var1 > 0) && (L_var2 < 0)) { + Overflow = 1; + carry_int = 0; + } else if ((L_test > 0) && (L_var1 < 0) && (L_var2 > 0)) { + Overflow = 1; + carry_int = 1; + } else if ((L_test > 0) && ((L_var1 ^ L_var2) > 0)) { + Overflow = 0; + carry_int = 1; } + if (L_test == MIN_32) { + Overflow = 1; + Carry = carry_int; + } else { + Carry = carry_int; + } + } -#ifdef WMOPS - multiCounter[currCounter].L_sub_c++; +#if (WMOPS) + multiCounter[currCounter].L_sub_c++; #endif - - /* BASOP_CHECK(); Do not check for overflow here, function produces the carry bit instead */ - - return (L_var_out); + return (L_var_out); } @@ -1420,20 +1267,15 @@ Word32 L_sub_c (Word32 L_var1, Word32 L_var2) | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |___________________________________________________________________________| */ -Word32 L_negate (Word32 L_var1) -{ - Word32 L_var_out; - - L_var_out = (L_var1 == MIN_32) ? MAX_32 : -L_var1; +Word32 L_negate (Word32 L_var1) { + Word32 L_var_out; + L_var_out = (L_var1 == MIN_32) ? MAX_32 : -L_var1; -#ifdef WMOPS - multiCounter[currCounter].L_negate++; +#if (WMOPS) + multiCounter[currCounter].L_negate++; #endif - - BASOP_CHECK(); - - return (L_var_out); + return (L_var_out); } @@ -1470,26 +1312,24 @@ Word32 L_negate (Word32 L_var1) | range : 0x8000 <= var_out <= 0x7fff. | |___________________________________________________________________________| */ -Word16 mult_r (Word16 var1, Word16 var2) -{ - Word16 var_out; - Word32 L_product_arr; - - L_product_arr = (Word32) var1 *(Word32) var2; /* product */ - L_product_arr += (Word32) 0x00004000L; /* round */ - L_product_arr &= (Word32) 0xffff8000L; - L_product_arr >>= 15; /* shift */ - - if (L_product_arr & (Word32) 0x00010000L) /* sign extend when necessary */ - { - L_product_arr |= (Word32) 0xffff0000L; - } - var_out = saturate (L_product_arr); - -#ifdef WMOPS - multiCounter[currCounter].mult_r++; +Word16 mult_r (Word16 var1, Word16 var2) { + Word16 var_out; + Word32 L_product_arr; + + L_product_arr = (Word32) var1 *(Word32) var2; /* product */ + L_product_arr += (Word32) 0x00004000L; /* round */ + L_product_arr &= (Word32) 0xffff8000L; + L_product_arr >>= 15; /* shift */ + + if (L_product_arr & (Word32) 0x00010000L) { /* sign extend when necessary */ + L_product_arr |= (Word32) 0xffff0000L; + } + var_out = saturate (L_product_arr); + +#if (WMOPS) + multiCounter[currCounter].mult_r++; #endif - return (var_out); + return (var_out); } @@ -1526,51 +1366,39 @@ Word16 mult_r (Word16 var1, Word16 var2) | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |___________________________________________________________________________| */ -Word32 L_shl (Word32 L_var1, Word16 var2) -{ - - Word32 L_var_out = 0L; - - if (var2 <= 0) - { - if (var2 < -32) - var2 = -32; - var2 = -var2; - L_var_out = L_shr (L_var1, var2); -#ifdef WMOPS - multiCounter[currCounter].L_shr--; +Word32 L_shl (Word32 L_var1, Word16 var2) { + + Word32 L_var_out = 0L; + + if (var2 <= 0) { + if (var2 < -32) + var2 = -32; + var2 = -var2; + L_var_out = L_shr (L_var1, var2); +#if (WMOPS) + multiCounter[currCounter].L_shr--; #endif - } - else - { - for (; var2 > 0; var2--) - { - if (L_var1 > (Word32) 0X3fffffffL) - { - Overflow = 1; - L_var_out = MAX_32; - break; - } - else - { - if (L_var1 < (Word32) 0xc0000000L) - { - Overflow = 1; - L_var_out = MIN_32; - break; - } - } - L_var1 *= 2; - L_var_out = L_var1; + } else { + for (; var2 > 0; var2--) { + if (L_var1 > (Word32) 0X3fffffffL) { + Overflow = 1; + L_var_out = MAX_32; + break; + } else { + if (L_var1 < (Word32) 0xc0000000L) { + Overflow = 1; + L_var_out = MIN_32; + break; } + } + L_var1 *= 2; + L_var_out = L_var1; } - #ifdef WMOPS - multiCounter[currCounter].L_shl++; - #endif - - BASOP_CHECK(); - - return (L_var_out); + } +#if (WMOPS) + multiCounter[currCounter].L_shl++; +#endif + return (L_var_out); } @@ -1607,45 +1435,32 @@ Word32 L_shl (Word32 L_var1, Word16 var2) | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |___________________________________________________________________________| */ -Word32 L_shr (Word32 L_var1, Word16 var2) -{ - Word32 L_var_out; - - if (var2 < 0) - { - if (var2 < -32) - var2 = -32; - var2 = -var2; - L_var_out = L_shl (L_var1, var2); -#ifdef WMOPS - multiCounter[currCounter].L_shl--; +Word32 L_shr (Word32 L_var1, Word16 var2) { + Word32 L_var_out; + + if (var2 < 0) { + if (var2 < -32) + var2 = -32; + var2 = -var2; + L_var_out = L_shl (L_var1, var2); +#if (WMOPS) + multiCounter[currCounter].L_shl--; #endif + } else { + if (var2 >= 31) { + L_var_out = (L_var1 < 0L) ? -1 : 0; + } else { + if (L_var1 < 0) { + L_var_out = ~((~L_var1) >> var2); + } else { + L_var_out = L_var1 >> var2; + } } - else - { - if (var2 >= 31) - { - L_var_out = (L_var1 < 0L) ? -1 : 0; - } - else - { - if (L_var1 < 0) - { - L_var_out = ~((~L_var1) >> var2); - } - else - { - L_var_out = L_var1 >> var2; - } - } - } - #ifdef WMOPS - multiCounter[currCounter].L_shr++; - #endif - - BASOP_CHECK(); - - return (L_var_out); + } +#if (WMOPS) + multiCounter[currCounter].L_shr++; +#endif + return (L_var_out); } @@ -1690,38 +1505,29 @@ Word32 L_shr (Word32 L_var1, Word16 var2) | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ -Word16 shr_r (Word16 var1, Word16 var2) -{ - Word16 var_out; +Word16 shr_r (Word16 var1, Word16 var2) { + Word16 var_out; - if (var2 > 15) - { - var_out = 0; - } - else - { - var_out = shr (var1, var2); + if (var2 > 15) { + var_out = 0; + } else { + var_out = shr (var1, var2); -#ifdef WMOPS - multiCounter[currCounter].shr--; +#if (WMOPS) + multiCounter[currCounter].shr--; #endif - if (var2 > 0) - { - if ((var1 & ((Word16) 1 << (var2 - 1))) != 0) - { - var_out++; - } - } + if (var2 > 0) { + if ((var1 & ((Word16) 1 << (var2 - 1))) != 0) { + var_out++; + } } + } -#ifdef WMOPS - multiCounter[currCounter].shr_r++; +#if (WMOPS) + multiCounter[currCounter].shr_r++; #endif - - BASOP_CHECK(); - - return (var_out); + return (var_out); } @@ -1763,24 +1569,20 @@ Word16 shr_r (Word16 var1, Word16 var2) | range : 0x0000 8000 <= L_var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ -Word16 mac_r (Word32 L_var3, Word16 var1, Word16 var2) -{ - Word16 var_out; - - L_var3 = L_mac (L_var3, var1, var2); - L_var3 = L_add (L_var3, (Word32) 0x00008000L); - var_out = extract_h (L_var3); - -#ifdef WMOPS - multiCounter[currCounter].L_mac--; - multiCounter[currCounter].L_add--; - multiCounter[currCounter].extract_h--; - multiCounter[currCounter].mac_r++; +Word16 mac_r (Word32 L_var3, Word16 var1, Word16 var2) { + Word16 var_out; + + L_var3 = L_mac (L_var3, var1, var2); + L_var3 = L_add (L_var3, (Word32) 0x00008000L); + var_out = extract_h (L_var3); + +#if (WMOPS) + multiCounter[currCounter].L_mac--; + multiCounter[currCounter].L_add--; + multiCounter[currCounter].extract_h--; + multiCounter[currCounter].mac_r++; #endif - - BASOP_CHECK(); - - return (var_out); + return (var_out); } @@ -1822,24 +1624,20 @@ Word16 mac_r (Word32 L_var3, Word16 var1, Word16 var2) | range : 0x0000 8000 <= L_var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ -Word16 msu_r (Word32 L_var3, Word16 var1, Word16 var2) -{ - Word16 var_out; - - L_var3 = L_msu (L_var3, var1, var2); - L_var3 = L_add (L_var3, (Word32) 0x00008000L); - var_out = extract_h (L_var3); - -#ifdef WMOPS - multiCounter[currCounter].L_msu--; - multiCounter[currCounter].L_add--; - multiCounter[currCounter].extract_h--; - multiCounter[currCounter].msu_r++; +Word16 msu_r (Word32 L_var3, Word16 var1, Word16 var2) { + Word16 var_out; + + L_var3 = L_msu (L_var3, var1, var2); + L_var3 = L_add (L_var3, (Word32) 0x00008000L); + var_out = extract_h (L_var3); + +#if (WMOPS) + multiCounter[currCounter].L_msu--; + multiCounter[currCounter].L_add--; + multiCounter[currCounter].extract_h--; + multiCounter[currCounter].msu_r++; #endif - - BASOP_CHECK(); - - return (var_out); + return (var_out); } @@ -1871,19 +1669,15 @@ Word16 msu_r (Word32 L_var3, Word16 var1, Word16 var2) | range : 0x8000 0000 <= var_out <= 0x7fff 0000. | |___________________________________________________________________________| */ -Word32 L_deposit_h (Word16 var1) -{ - Word32 L_var_out; +Word32 L_deposit_h (Word16 var1) { + Word32 L_var_out; - L_var_out = (Word32) var1 << 16; + L_var_out = (Word32) var1 << 16; -#ifdef WMOPS - multiCounter[currCounter].L_deposit_h++; +#if (WMOPS) + multiCounter[currCounter].L_deposit_h++; #endif - - BASOP_CHECK(); - - return (L_var_out); + return (L_var_out); } @@ -1915,19 +1709,15 @@ Word32 L_deposit_h (Word16 var1) | range : 0xFFFF 8000 <= var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ -Word32 L_deposit_l (Word16 var1) -{ - Word32 L_var_out; +Word32 L_deposit_l (Word16 var1) { + Word32 L_var_out; - L_var_out = (Word32) var1; + L_var_out = (Word32) var1; -#ifdef WMOPS - multiCounter[currCounter].L_deposit_l++; +#if (WMOPS) + multiCounter[currCounter].L_deposit_l++; #endif - - BASOP_CHECK(); - - return (L_var_out); + return (L_var_out); } @@ -1972,37 +1762,28 @@ Word32 L_deposit_l (Word16 var1) | range : 0x8000 0000 <= var_out <= 0x7fff ffff. | |___________________________________________________________________________| */ -Word32 L_shr_r (Word32 L_var1, Word16 var2) -{ - Word32 L_var_out; +Word32 L_shr_r (Word32 L_var1, Word16 var2) { + Word32 L_var_out; - if (var2 > 31) - { - L_var_out = 0; - } - else - { - L_var_out = L_shr (L_var1, var2); + if (var2 > 31) { + L_var_out = 0; + } else { + L_var_out = L_shr (L_var1, var2); -#ifdef WMOPS - multiCounter[currCounter].L_shr--; +#if (WMOPS) + multiCounter[currCounter].L_shr--; #endif - if (var2 > 0) - { - if ((L_var1 & ((Word32) 1 << (var2 - 1))) != 0) - { - L_var_out++; - } - } + if (var2 > 0) { + if ((L_var1 & ((Word32) 1 << (var2 - 1))) != 0) { + L_var_out++; + } } + } -#ifdef WMOPS - multiCounter[currCounter].L_shr_r++; +#if (WMOPS) + multiCounter[currCounter].L_shr_r++; #endif - - BASOP_CHECK(); - - return (L_var_out); + return (L_var_out); } @@ -2034,33 +1815,23 @@ Word32 L_shr_r (Word32 L_var1, Word16 var2) | range : 0x0000 0000 <= var_out <= 0x7fff ffff. | |___________________________________________________________________________| */ -Word32 L_abs (Word32 L_var1) -{ - Word32 L_var_out; +Word32 L_abs (Word32 L_var1) { + Word32 L_var_out; - if (L_var1 == MIN_32) - { - L_var_out = MAX_32; - } - else - { - if (L_var1 < 0) - { - L_var_out = -L_var1; - } - else - { - L_var_out = L_var1; - } + if (L_var1 == MIN_32) { + L_var_out = MAX_32; + } else { + if (L_var1 < 0) { + L_var_out = -L_var1; + } else { + L_var_out = L_var1; } + } -#ifdef WMOPS - multiCounter[currCounter].L_abs++; +#if (WMOPS) + multiCounter[currCounter].L_abs++; #endif - - BASOP_CHECK(); - - return (L_var_out); + return (L_var_out); } @@ -2094,35 +1865,26 @@ Word32 L_abs (Word32 L_var1) | range : 0x8000 0000 <= var_out <= 0x7fff ffff. | |___________________________________________________________________________| */ -Word32 L_sat (Word32 L_var1) -{ - Word32 L_var_out; - - L_var_out = L_var1; +Word32 L_sat (Word32 L_var1) { + Word32 L_var_out; - if (Overflow) - { + L_var_out = L_var1; - if (Carry) - { - L_var_out = MIN_32; - } - else - { - L_var_out = MAX_32; - } + if (Overflow) { - Carry = 0; - Overflow = 0; + if (Carry) { + L_var_out = MIN_32; + } else { + L_var_out = MAX_32; } -#ifdef WMOPS - multiCounter[currCounter].L_sat++; + Carry = 0; + Overflow = 0; + } +#if (WMOPS) + multiCounter[currCounter].L_sat++; #endif - - BASOP_CHECK(); - - return (L_var_out); + return (L_var_out); } @@ -2158,40 +1920,28 @@ Word32 L_sat (Word32 L_var1) | range : 0x0000 0000 <= var_out <= 0x0000 000f. | |___________________________________________________________________________| */ -Word16 norm_s (Word16 var1) -{ - Word16 var_out; - - if (var1 == 0) - { - var_out = 0; - } - else - { - if (var1 == (Word16) 0xffff) - { - var_out = 15; - } - else - { - if (var1 < 0) - { - var1 = ~var1; - } - for (var_out = 0; var1 < 0x4000; var_out++) - { - var1 <<= 1; - } - } +Word16 norm_s (Word16 var1) { + Word16 var_out; + + if (var1 == 0) { + var_out = 0; + } else { + if (var1 == (Word16) 0xffff) { + var_out = 15; + } else { + if (var1 < 0) { + var1 = ~var1; + } + for (var_out = 0; var1 < 0x4000; var_out++) { + var1 <<= 1; + } } + } -#ifdef WMOPS - multiCounter[currCounter].norm_s++; +#if (WMOPS) + multiCounter[currCounter].norm_s++; #endif - - BASOP_CHECK(); - - return (var_out); + return (var_out); } @@ -2231,70 +1981,54 @@ Word16 norm_s (Word16 var1) | It's a Q15 value (point between b15 and b14). | |___________________________________________________________________________| */ -Word16 div_s (Word16 var1, Word16 var2) -{ - Word16 var_out = 0; - Word16 iteration; - Word32 L_num; - Word32 L_denom; - - if ((var1 > var2) || (var1 < 0) || (var2 < 0)) - { - /* printf ("Division Error var1=%d var2=%d in ", var1, var2); printStack(); */ - char text[60]; - sprintf (text, "\nDivision Error var1=%d var2=%d in ", var1, var2); - abort(); /* exit (0); */ - } - if (var2 == 0) - { - /* printf ("Division by 0, Fatal error in "); printStack(); */ - abort(); /* exit (0); */ - } - if (var1 == 0) - { - var_out = 0; - } - else - { - if (var1 == var2) - { - var_out = MAX_16; - } - else - { - L_num = L_deposit_l (var1); - L_denom = L_deposit_l (var2); - -#ifdef WMOPS - multiCounter[currCounter].L_deposit_l--; - multiCounter[currCounter].L_deposit_l--; +Word16 div_s (Word16 var1, Word16 var2) { + Word16 var_out = 0; + Word16 iteration; + Word32 L_num; + Word32 L_denom; + + if ((var1 > var2) || (var1 < 0) || (var2 < 0)) { + printf ("Division Error var1=%d var2=%d\n", var1, var2); + abort (); /* exit (0); */ + } + if (var2 == 0) { + printf ("Division by 0, Fatal error \n"); + abort (); /* exit (0); */ + } + if (var1 == 0) { + var_out = 0; + } else { + if (var1 == var2) { + var_out = MAX_16; + } else { + L_num = L_deposit_l (var1); + L_denom = L_deposit_l (var2); + +#if (WMOPS) + multiCounter[currCounter].L_deposit_l--; + multiCounter[currCounter].L_deposit_l--; #endif - for (iteration = 0; iteration < 15; iteration++) - { - var_out <<= 1; - L_num <<= 1; - - if (L_num >= L_denom) - { - L_num = L_sub (L_num, L_denom); - var_out = add (var_out, 1); -#ifdef WMOPS - multiCounter[currCounter].L_sub--; - multiCounter[currCounter].add--; + for (iteration = 0; iteration < 15; iteration++) { + var_out <<= 1; + L_num <<= 1; + + if (L_num >= L_denom) { + L_num = L_sub (L_num, L_denom); + var_out = add (var_out, 1); +#if (WMOPS) + multiCounter[currCounter].L_sub--; + multiCounter[currCounter].add--; #endif - } - } } + } } + } -#ifdef WMOPS - multiCounter[currCounter].div_s++; +#if (WMOPS) + multiCounter[currCounter].div_s++; #endif - - BASOP_CHECK(); - - return (var_out); + return (var_out); } @@ -2330,40 +2064,28 @@ Word16 div_s (Word16 var1, Word16 var2) | range : 0x0000 0000 <= var_out <= 0x0000 001f. | |___________________________________________________________________________| */ -Word16 norm_l (Word32 L_var1) -{ - Word16 var_out; - - if (L_var1 == 0) - { - var_out = 0; - } - else - { - if (L_var1 == (Word32) 0xffffffffL) - { - var_out = 31; - } - else - { - if (L_var1 < 0) - { - L_var1 = ~L_var1; - } - for (var_out = 0; L_var1 < (Word32) 0x40000000L; var_out++) - { - L_var1 <<= 1; - } - } +Word16 norm_l (Word32 L_var1) { + Word16 var_out; + + if (L_var1 == 0) { + var_out = 0; + } else { + if (L_var1 == (Word32) 0xffffffffL) { + var_out = 31; + } else { + if (L_var1 < 0) { + L_var1 = ~L_var1; + } + for (var_out = 0; L_var1 < (Word32) 0x40000000L; var_out++) { + L_var1 <<= 1; + } } + } -#ifdef WMOPS - multiCounter[currCounter].norm_l++; +#if (WMOPS) + multiCounter[currCounter].norm_l++; #endif - - BASOP_CHECK(); - - return (var_out); + return (var_out); } /* @@ -2412,26 +2134,22 @@ Word16 norm_l (Word32 L_var1) | | |___________________________________________________________________________| */ -Word32 L_mls (Word32 Lv, Word16 v) -{ - Word32 Temp ; - - Temp = Lv & (Word32) 0x0000ffff ; - Temp = Temp * (Word32) v ; - Temp = L_shr( Temp, (Word16) 15 ) ; - Temp = L_mac( Temp, v, extract_h(Lv) ) ; - -#ifdef WMOPS - multiCounter[currCounter].L_shr--; - multiCounter[currCounter].L_mac--; - multiCounter[currCounter].extract_h--; - multiCounter[currCounter].L_mls++; +Word32 L_mls (Word32 Lv, Word16 v) { + Word32 Temp; + + Temp = Lv & (Word32) 0x0000ffff; + Temp = Temp * (Word32) v; + Temp = L_shr (Temp, (Word16) 15); + Temp = L_mac (Temp, v, extract_h (Lv)); + +#if (WMOPS) + multiCounter[currCounter].L_shr--; + multiCounter[currCounter].L_mac--; + multiCounter[currCounter].extract_h--; + multiCounter[currCounter].L_mls++; #endif - - BASOP_CHECK(); - - return Temp ; + return Temp; } @@ -2473,65 +2191,57 @@ Word32 L_mls (Word32 Lv, Word16 v) | It's a Q15 value (point between b15 and b14). | |___________________________________________________________________________| */ -Word16 div_l (Word32 L_num, Word16 den) -{ - Word16 var_out = (Word16)0; - Word32 L_den; - Word16 iteration; - -#ifdef WMOPS - multiCounter[currCounter].div_l++; -#endif - - if ( den == (Word16) 0 ) { - /* printf("Division by 0 in div_l, Fatal error in "); printStack(); */ - exit(-1); - } +Word16 div_l (Word32 L_num, Word16 den) { + Word16 var_out = (Word16) 0; + Word32 L_den; + Word16 iteration; - if ( (L_num < (Word32) 0) || (den < (Word16) 0) ) { - /* printf("Division Error in div_l, Fatal error in "); printStack(); */ - exit(-1); - } - - L_den = L_deposit_h( den ) ; -#ifdef WMOPS - multiCounter[currCounter].L_deposit_h--; +#if (WMOPS) + multiCounter[currCounter].div_l++; #endif - if ( L_num >= L_den ){ + if (den == (Word16) 0) { + printf ("Division by 0 in div_l, Fatal error \n"); + exit (0); + } + if ((L_num < (Word32) 0) || (den < (Word16) 0)) { + printf ("Division Error in div_l, Fatal error \n"); + exit (0); + } - BASOP_CHECK(); + L_den = L_deposit_h (den); +#if (WMOPS) + multiCounter[currCounter].L_deposit_h--; +#endif - return MAX_16 ; - } - else { - L_num = L_shr(L_num, (Word16)1) ; - L_den = L_shr(L_den, (Word16)1); -#ifdef WMOPS - multiCounter[currCounter].L_shr-=2; + if (L_num >= L_den) { + return MAX_16; + } else { + L_num = L_shr (L_num, (Word16) 1); + L_den = L_shr (L_den, (Word16) 1); +#if (WMOPS) + multiCounter[currCounter].L_shr -= 2; #endif - for(iteration=(Word16)0; iteration< (Word16)15;iteration++) { - var_out = shl( var_out, (Word16)1); - L_num = L_shl( L_num, (Word16)1); -#ifdef WMOPS - multiCounter[currCounter].shl--; - multiCounter[currCounter].L_shl--; + for (iteration = (Word16) 0; iteration < (Word16) 15; iteration++) { + var_out = shl (var_out, (Word16) 1); + L_num = L_shl (L_num, (Word16) 1); +#if (WMOPS) + multiCounter[currCounter].shl--; + multiCounter[currCounter].L_shl--; #endif - if (L_num >= L_den) { - L_num = L_sub(L_num,L_den); - var_out = add(var_out, (Word16)1); -#ifdef WMOPS - multiCounter[currCounter].L_sub--; - multiCounter[currCounter].add--; + if (L_num >= L_den) { + L_num = L_sub (L_num, L_den); + var_out = add (var_out, (Word16) 1); +#if (WMOPS) + multiCounter[currCounter].L_sub--; + multiCounter[currCounter].add--; #endif - } - } - - BASOP_CHECK(); - - return var_out; + } } + + return var_out; + } } @@ -2565,23 +2275,22 @@ Word16 div_l (Word32 L_num, Word16 den) | are performed if ORIGINAL_G7231 is defined. | |___________________________________________________________________________| */ -Word16 i_mult (Word16 a, Word16 b) -{ +Word16 i_mult (Word16 a, Word16 b) { #ifdef ORIGINAL_G7231 - return a*b ; + return a * b; #else - Word32 /*register*/ c=a*b; -#ifdef WMOPS - multiCounter[currCounter].i_mult++; + Word32 /*register*/ c = a * b; +#if (WMOPS) + multiCounter[currCounter].i_mult++; #endif - return saturate(c) ; + return saturate (c); #endif } /* ****************************************************************************** - * The following three operators are not part of the original + * The following three operators are not part of the original * G.729/G.723.1 set of basic operators and implement shiftless * accumulation operation. ****************************************************************************** @@ -2613,19 +2322,15 @@ Word16 i_mult (Word16 a, Word16 b) | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. |___________________________________________________________________________ */ -Word32 L_mult0 (Word16 var1,Word16 var2) -{ +Word32 L_mult0 (Word16 var1, Word16 var2) { Word32 L_var_out; - L_var_out = (Word32)var1 * (Word32)var2; + L_var_out = (Word32) var1 *(Word32) var2; -#ifdef WMOPS - multiCounter[currCounter].L_mult0++; +#if (WMOPS) + multiCounter[currCounter].L_mult0++; #endif - - BASOP_CHECK(); - - return(L_var_out); + return (L_var_out); } @@ -2659,23 +2364,19 @@ Word32 L_mult0 (Word16 var1,Word16 var2) | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. |___________________________________________________________________________ */ -Word32 L_mac0 (Word32 L_var3, Word16 var1, Word16 var2) -{ +Word32 L_mac0 (Word32 L_var3, Word16 var1, Word16 var2) { Word32 L_var_out; Word32 L_product; - L_product = L_mult0(var1,var2); - L_var_out = L_add(L_var3,L_product); + L_product = L_mult0 (var1, var2); + L_var_out = L_add (L_var3, L_product); -#ifdef WMOPS - multiCounter[currCounter].L_mac0++; - multiCounter[currCounter].L_mult0--; - multiCounter[currCounter].L_add--; +#if (WMOPS) + multiCounter[currCounter].L_mac0++; + multiCounter[currCounter].L_mult0--; + multiCounter[currCounter].L_add--; #endif - - BASOP_CHECK(); - - return(L_var_out); + return (L_var_out); } @@ -2709,25 +2410,20 @@ Word32 L_mac0 (Word32 L_var3, Word16 var1, Word16 var2) | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. |___________________________________________________________________________ */ -Word32 L_msu0 (Word32 L_var3, Word16 var1, Word16 var2) -{ +Word32 L_msu0 (Word32 L_var3, Word16 var1, Word16 var2) { Word32 L_var_out; Word32 L_product; - L_product = L_mult0(var1,var2); - L_var_out = L_sub(L_var3,L_product); + L_product = L_mult0 (var1, var2); + L_var_out = L_sub (L_var3, L_product); -#ifdef WMOPS - multiCounter[currCounter].L_msu0++; - multiCounter[currCounter].L_mult0--; - multiCounter[currCounter].L_sub--; +#if (WMOPS) + multiCounter[currCounter].L_msu0++; + multiCounter[currCounter].L_mult0--; + multiCounter[currCounter].L_sub--; #endif - - BASOP_CHECK(); - - return(L_var_out); + return (L_var_out); } /* end of file */ - diff --git a/basic_op/basop32.h b/basic_op/basop32.h index 4348821ae348037b7b37c0cbfdef58bf3c34bddf..a9d63775bd1251c0747e150e117923c47bd42880 100644 --- a/basic_op/basop32.h +++ b/basic_op/basop32.h @@ -37,8 +37,6 @@ 30 Nov 09 v2.3 round() function is now round_fx(). saturate() is not referencable from outside application - - 13 Mar 12 Add Overflow2 flag for additional overflow checking. ============================================================================ */ @@ -46,14 +44,14 @@ #ifndef _BASIC_OP_H #define _BASIC_OP_H -/* #define BASOP_OVERFLOW2 */ /*___________________________________________________________________________ | | | Constants and Globals | + | $Id $ |___________________________________________________________________________| */ -extern Flag Overflow, Overflow2; +extern Flag Overflow; extern Flag Carry; #define BASOP_SATURATE_WARNING_ON @@ -62,7 +60,6 @@ extern Flag Carry; #define BASOP_SATURATE_ERROR_OFF #define BASOP_CHECK() - #define MAX_32 (Word32)0x7fffffffL #define MIN_32 (Word32)0x80000000L @@ -75,62 +72,56 @@ extern Flag Carry; |___________________________________________________________________________| */ -Word16 add (Word16 var1, Word16 var2); /* Short add, 1 */ -Word16 sub (Word16 var1, Word16 var2); /* Short sub, 1 */ -Word16 abs_s (Word16 var1); /* Short abs, 1 */ -Word16 shl (Word16 var1, Word16 var2); /* Short shift left, 1 */ -Word16 shr (Word16 var1, Word16 var2); /* Short shift right, 1 */ -Word16 mult (Word16 var1, Word16 var2); /* Short mult, 1 */ -Word32 L_mult (Word16 var1, Word16 var2); /* Long mult, 1 */ -Word16 negate (Word16 var1); /* Short negate, 1 */ -Word16 extract_h (Word32 L_var1); /* Extract high, 1 */ -Word16 extract_l (Word32 L_var1); /* Extract low, 1 */ -Word16 round_fx (Word32 L_var1); /* Round, 1 */ -Word32 L_mac (Word32 L_var3, Word16 var1, Word16 var2); /* Mac, 1 */ -Word32 L_msu (Word32 L_var3, Word16 var1, Word16 var2); /* Msu, 1 */ -Word32 L_macNs (Word32 L_var3, Word16 var1, Word16 var2); /* Mac without - sat, 1 */ -Word32 L_msuNs (Word32 L_var3, Word16 var1, Word16 var2); /* Msu without - sat, 1 */ -Word32 L_add (Word32 L_var1, Word32 L_var2); /* Long add, 1 */ -Word32 L_sub (Word32 L_var1, Word32 L_var2); /* Long sub, 1 */ -Word32 L_add_c (Word32 L_var1, Word32 L_var2); /* Long add with c, 2 */ -Word32 L_sub_c (Word32 L_var1, Word32 L_var2); /* Long sub with c, 2 */ -Word32 L_negate (Word32 L_var1); /* Long negate, 1 */ -Word16 mult_r (Word16 var1, Word16 var2); /* Mult with round, 1 */ -Word32 L_shl (Word32 L_var1, Word16 var2); /* Long shift left, 1 */ -Word32 L_shr (Word32 L_var1, Word16 var2); /* Long shift right, 1 */ -Word16 shr_r (Word16 var1, Word16 var2); /* Shift right with - round, 2 */ -Word16 mac_r (Word32 L_var3, Word16 var1, Word16 var2); /* Mac with - rounding, 1 */ -Word16 msu_r (Word32 L_var3, Word16 var1, Word16 var2); /* Msu with - rounding, 1 */ -Word32 L_deposit_h (Word16 var1); /* 16 bit var1 -> MSB, 1 */ -Word32 L_deposit_l (Word16 var1); /* 16 bit var1 -> LSB, 1 */ - -Word32 L_shr_r (Word32 L_var1, Word16 var2); /* Long shift right with - round, 3 */ -Word32 L_abs (Word32 L_var1); /* Long abs, 1 */ -Word32 L_sat (Word32 L_var1); /* Long saturation, 4 */ -Word16 norm_s (Word16 var1); /* Short norm, 1 */ -Word16 div_s (Word16 var1, Word16 var2); /* Short division, 18 */ -Word16 norm_l (Word32 L_var1); /* Long norm, 1 */ +Word16 add (Word16 var1, Word16 var2); /* Short add, 1 */ +Word16 sub (Word16 var1, Word16 var2); /* Short sub, 1 */ +Word16 abs_s (Word16 var1); /* Short abs, 1 */ +Word16 shl (Word16 var1, Word16 var2); /* Short shift left, 1 */ +Word16 shr (Word16 var1, Word16 var2); /* Short shift right, 1 */ +Word16 mult (Word16 var1, Word16 var2); /* Short mult, 1 */ +Word32 L_mult (Word16 var1, Word16 var2); /* Long mult, 1 */ +Word16 negate (Word16 var1); /* Short negate, 1 */ +Word16 extract_h (Word32 L_var1); /* Extract high, 1 */ +Word16 extract_l (Word32 L_var1); /* Extract low, 1 */ +Word16 round_fx (Word32 L_var1); /* Round, 1 */ +Word32 L_mac (Word32 L_var3, Word16 var1, Word16 var2); /* Mac, 1 */ +Word32 L_msu (Word32 L_var3, Word16 var1, Word16 var2); /* Msu, 1 */ +Word32 L_macNs (Word32 L_var3, Word16 var1, Word16 var2); /* Mac without sat, 1 */ +Word32 L_msuNs (Word32 L_var3, Word16 var1, Word16 var2); /* Msu without sat, 1 */ +Word32 L_add (Word32 L_var1, Word32 L_var2); /* Long add, 1 */ +Word32 L_sub (Word32 L_var1, Word32 L_var2); /* Long sub, 1 */ +Word32 L_add_c (Word32 L_var1, Word32 L_var2); /* Long add with c, 2 */ +Word32 L_sub_c (Word32 L_var1, Word32 L_var2); /* Long sub with c, 2 */ +Word32 L_negate (Word32 L_var1); /* Long negate, 1 */ +Word16 mult_r (Word16 var1, Word16 var2); /* Mult with round, 1 */ +Word32 L_shl (Word32 L_var1, Word16 var2); /* Long shift left, 1 */ +Word32 L_shr (Word32 L_var1, Word16 var2); /* Long shift right, 1 */ +Word16 shr_r (Word16 var1, Word16 var2); /* Shift right with round, 2 */ +Word16 mac_r (Word32 L_var3, Word16 var1, Word16 var2); /* Mac with rounding, 1 */ +Word16 msu_r (Word32 L_var3, Word16 var1, Word16 var2); /* Msu with rounding, 1 */ +Word32 L_deposit_h (Word16 var1); /* 16 bit var1 -> MSB, 1 */ +Word32 L_deposit_l (Word16 var1); /* 16 bit var1 -> LSB, 1 */ + +Word32 L_shr_r (Word32 L_var1, Word16 var2); /* Long shift right with round, 3 */ +Word32 L_abs (Word32 L_var1); /* Long abs, 1 */ +Word32 L_sat (Word32 L_var1); /* Long saturation, 4 */ +Word16 norm_s (Word16 var1); /* Short norm, 1 */ +Word16 div_s (Word16 var1, Word16 var2); /* Short division, 18 */ +Word16 norm_l (Word32 L_var1); /* Long norm, 1 */ /* * Additional G.723.1 operators */ -Word32 L_mls( Word32, Word16 ) ; /* Weight FFS; currently assigned 5 */ -Word16 div_l( Word32, Word16 ) ; /* Weight FFS; currently assigned 32 */ -Word16 i_mult(Word16 a, Word16 b); /* Weight FFS; currently assigned 3 */ +Word32 L_mls (Word32, Word16); /* Weight FFS; currently assigned 5 */ +Word16 div_l (Word32, Word16); /* Weight FFS; currently assigned 32 */ +Word16 i_mult (Word16 a, Word16 b); /* Weight FFS; currently assigned 3 */ /* * New shiftless operators, not used in G.729/G.723.1 */ -Word32 L_mult0(Word16 v1, Word16 v2); /* 32-bit Multiply w/o shift 1 */ -Word32 L_mac0(Word32 L_v3, Word16 v1, Word16 v2); /* 32-bit Mac w/o shift 1 */ -Word32 L_msu0(Word32 L_v3, Word16 v1, Word16 v2); /* 32-bit Msu w/o shift 1 */ +Word32 L_mult0 (Word16 v1, Word16 v2); /* 32-bit Multiply w/o shift e 1 */ +Word32 L_mac0 (Word32 L_v3, Word16 v1, Word16 v2); /* 32-bit Mac w/o shift 1 */ +Word32 L_msu0 (Word32 L_v3, Word16 v1, Word16 v2); /* 32-bit Msu w/o shift 1 */ #endif /* ifndef _BASIC_OP_H */ diff --git a/basic_op/complex_basop.c b/basic_op/complex_basop.c new file mode 100644 index 0000000000000000000000000000000000000000..3a65d65a6eaeac6a9ce75edbea4d3544a6a82e3a --- /dev/null +++ b/basic_op/complex_basop.c @@ -0,0 +1,457 @@ +/***************************************************************************** + +* + +* Complex arithmetic operators + +* + +*****************************************************************************/ + + +#include "typedef.h" +#include "basop32.h" + +#include "complex_basop.h" + +#include "stl.h" + + + +#if (WMOPS) + +extern BASIC_OP multiCounter[MAXCOUNTERS]; + +extern int currCounter; + +#endif /* if WMOPS */ + + + +#ifdef COMPLEX_OPERATOR + +/* ================================ New Complex Basops ========================= */ + +cmplx CL_shr (cmplx inp, Word32 shift_val) { + cmplx out; + out.re = L_shr (inp.re, shift_val); + out.im = L_shr (inp.im, shift_val); +#if (WMOPS) + multiCounter[currCounter].CL_shr++; + multiCounter[currCounter].L_shr--; + multiCounter[currCounter].L_shr--; +#endif + return out; +} + +cmplx CL_shl (cmplx inp, Word32 shift_val) { + cmplx out; + out.re = L_shl (inp.re, shift_val); + out.im = L_shl (inp.im, shift_val); +#if (WMOPS) + multiCounter[currCounter].CL_shl++; + multiCounter[currCounter].L_shl--; + multiCounter[currCounter].L_shl--; +#endif + return out; +} + +cmplx CL_add (cmplx inp1, cmplx inp2) { + cmplx out; + out.re = L_add (inp1.re, inp2.re); + out.im = L_add (inp1.im, inp2.im); +#if (WMOPS) + multiCounter[currCounter].CL_add++; + multiCounter[currCounter].L_add--; + multiCounter[currCounter].L_add--; +#endif + return out; +} + +cmplx CL_sub (cmplx inp1, cmplx inp2) { + cmplx out; + out.re = L_sub (inp1.re, inp2.re); + out.im = L_sub (inp1.im, inp2.im); +#if (WMOPS) + multiCounter[currCounter].CL_sub++; + multiCounter[currCounter].L_sub--; + multiCounter[currCounter].L_sub--; +#endif + return out; +} + +cmplx CL_scale(cmplx x, Word16 y) { + cmplx result; + result.re = Mpy_32_16_r (x.re, y); + result.im = Mpy_32_16_r (x.im, y); +#if (WMOPS) + multiCounter[currCounter].Mpy_32_16_r--; + multiCounter[currCounter].Mpy_32_16_r--; + multiCounter[currCounter].CL_scale++; +#endif/* #if (WMOPS) */ + return (result); +} + +cmplx CL_dscale (cmplx x, Word16 y1, Word16 y2) { + cmplx result; + result.re = Mpy_32_16_r (x.re, y1); + result.im = Mpy_32_16_r (x.im, y2); +#if (WMOPS) + multiCounter[currCounter].Mpy_32_16_r--; + multiCounter[currCounter].Mpy_32_16_r--; + multiCounter[currCounter].CL_dscale++; +#endif/* #if (WMOPS) */ + return (result); +} + +cmplx CL_msu_j (cmplx x, cmplx y) { + cmplx result; + result.re = L_add (x.re, y.im); + result.im = L_sub (x.im, y.re); +#if (WMOPS) + multiCounter[currCounter].CL_msu_j++; + multiCounter[currCounter].L_add--; + multiCounter[currCounter].L_sub--; +#endif + return result; +} + +cmplx CL_mac_j (cmplx x, cmplx y) { + cmplx result; + result.re = L_sub (x.re, y.im ); + result.im = L_add (x.im, y.re ); +#if (WMOPS) + multiCounter[currCounter].CL_mac_j++; + multiCounter[currCounter].L_add--; + multiCounter[currCounter].L_sub--; +#endif + return result; +} + +cmplx CL_move (cmplx x) { +#if (WMOPS) + multiCounter[currCounter].CL_move++; +#endif + return x; +} + +Word32 CL_Extract_real (cmplx x) { +#if (WMOPS) + multiCounter[currCounter].CL_Extract_real++; +#endif + return x.re; +} + +Word32 CL_Extract_imag (cmplx x) { +#if (WMOPS) + multiCounter[currCounter].CL_Extract_imag++; +#endif + return x.im; +} + +cmplx CL_form (Word32 re, Word32 im) { + cmplx result; + result.re = re; + result.im = im; +#if (WMOPS) + multiCounter[currCounter].CL_form++; +#endif + return result; +} + +cmplx CL_multr_32x16 (cmplx input, cmplx_s coeff) { + cmplx result; + result.re = W_round48_L (W_sub_nosat (W_mult_32_16 (input.re, coeff.re), W_mult_32_16 (input.im, coeff.im) ) ); + result.im = W_round48_L (W_add_nosat (W_mult_32_16 (input.re, coeff.im), W_mult_32_16 (input.im, coeff.re) ) ); +#if (WMOPS) + multiCounter[currCounter].CL_multr_32x16++; + multiCounter[currCounter].W_mult_32_16--; + multiCounter[currCounter].W_mult_32_16--; + multiCounter[currCounter].W_mult_32_16--; + multiCounter[currCounter].W_mult_32_16--; + multiCounter[currCounter].W_sub_nosat--; + multiCounter[currCounter].W_add_nosat--; + multiCounter[currCounter].W_round48_L--; + multiCounter[currCounter].W_round48_L--; +#endif + return result; +} + +cmplx CL_negate(cmplx x) { + cmplx result; + result.re = L_negate (x.re); + result.im = L_negate (x.im); +#if (WMOPS) + multiCounter[currCounter].CL_negate++; + multiCounter[currCounter].L_negate--; + multiCounter[currCounter].L_negate--; +#endif + return result; +} + +cmplx CL_conjugate (cmplx x) { + cmplx result; + result.re = x.re; + result.im = L_negate (x.im); +#if (WMOPS) + multiCounter[currCounter].CL_conjugate++; + multiCounter[currCounter].L_negate--; +#endif + return result; +} + + +cmplx CL_mul_j (cmplx input) { + cmplx temp, result; + temp = CL_negate (input); + result.re = temp.im; + result.im = input.re; +#if (WMOPS) + multiCounter[currCounter].CL_mul_j++; + multiCounter[currCounter].CL_negate--; +#endif + return result; +} + +cmplx CL_swap_real_imag (cmplx input) { + cmplx result; + result.re = input.im; + result.im = input.re; +#if (WMOPS) + multiCounter[currCounter].CL_swap_real_imag++; +#endif + return result; +} + +cmplx_s C_add (cmplx_s inp1, cmplx_s inp2) { + cmplx_s out; + out.re = add (inp1.re, inp2.re); + out.im = add (inp1.im, inp2.im); + +#if (WMOPS) + multiCounter[currCounter].C_add++; + multiCounter[currCounter].add--; + multiCounter[currCounter].add--; +#endif + return out; +} + +cmplx_s C_sub (cmplx_s inp1, cmplx_s inp2) { + cmplx_s out; + out.re = sub (inp1.re, inp2.re); + out.im = sub (inp1.im, inp2.im); + +#if (WMOPS) + multiCounter[currCounter].C_sub++; + multiCounter[currCounter].sub--; + multiCounter[currCounter].sub--; +#endif + return out; +} + +cmplx_s C_mul_j (cmplx_s input) { + cmplx_s result; + Word16 temp; + temp = negate(input.im); + result.re = temp; + result.im = input.re; + +#if (WMOPS) + multiCounter[currCounter].C_mul_j++; + multiCounter[currCounter].negate--; +#endif + return result; +} + +cmplx_s C_multr (cmplx_s x, cmplx_s c) { + cmplx_s result; + result.re = round_fx (W_sat_l (W_sub_nosat (W_mult_16_16 (x.re, c.re), W_mult_16_16 (x.im, c.im) ) ) ); + result.im = round_fx (W_sat_l (W_add_nosat (W_mult_16_16 (x.im, c.re), W_mult_16_16 (x.re, c.im) ) ) ); + +#if (WMOPS) + multiCounter[currCounter].C_multr++; + multiCounter[currCounter].W_mult_16_16--; + multiCounter[currCounter].W_mult_16_16--; + multiCounter[currCounter].W_mult_16_16--; + multiCounter[currCounter].W_mult_16_16--; + multiCounter[currCounter].W_sub_nosat--; + multiCounter[currCounter].W_add_nosat--; + multiCounter[currCounter].W_sat_l--; + multiCounter[currCounter].W_sat_l--; + multiCounter[currCounter].round--; + multiCounter[currCounter].round--; +#endif + return result; +} + +cmplx_s C_form ( Word16 re, Word16 im) { + cmplx_s result; + result.re = re; + result.im = im; +#if (WMOPS) + multiCounter[currCounter].C_form++; +#endif + return result; +} + +cmplx C_scale(cmplx_s x, Word16 y) { + cmplx result; + result.re = L_mult(x.re, y); + result.im = L_mult(x.im, y); +#if (WMOPS) + multiCounter[currCounter].L_mult--; + multiCounter[currCounter].L_mult--; + multiCounter[currCounter].C_scale++; +#endif/* #if (WMOPS) */ + return (result); +} + +cmplx_s CL_round32_16 (cmplx x) { + cmplx_s result; + result.re = round_fx (x.re); + result.im = round_fx (x.im); + +#if (WMOPS) + multiCounter[currCounter].CL_round32_16++; + multiCounter[currCounter].round--; + multiCounter[currCounter].round--; +#endif + return result; +} + +cmplx CL_scale_32 (cmplx x, Word32 y) { + cmplx result; + result.re = Mpy_32_32_r (x.re, y); + result.im = Mpy_32_32_r (x.im, y); +#if (WMOPS) + multiCounter[currCounter].Mpy_32_32_r--; + multiCounter[currCounter].Mpy_32_32_r--; + multiCounter[currCounter].CL_scale_32++; +#endif/* #if (WMOPS) */ + return (result); +} + +cmplx CL_dscale_32 (cmplx x, Word32 y1, Word32 y2) { + cmplx result; + result.re = Mpy_32_32_r (x.re, y1); + result.im = Mpy_32_32_r (x.im, y2); +#if (WMOPS) + multiCounter[currCounter].Mpy_32_32_r--; + multiCounter[currCounter].Mpy_32_32_r--; + multiCounter[currCounter].CL_dscale_32++; +#endif/* #if (WMOPS) */ + return (result); +} + +cmplx CL_multr_32x32 (cmplx x, cmplx y) { + cmplx result; + result.re = W_round64_L (W_sub (W_mult_32_32 (x.re, y.re), W_mult_32_32(x.im, y.im) ) ) ; + result.im = W_round64_L (W_add (W_mult_32_32 (x.im, y.re), W_mult_32_32(x.re, y.im) ) ) ; + +#if (WMOPS) + multiCounter[currCounter].CL_multr_32x32++; + multiCounter[currCounter].W_mult_32_32--; + multiCounter[currCounter].W_mult_32_32--; + multiCounter[currCounter].W_mult_32_32--; + multiCounter[currCounter].W_mult_32_32--; + multiCounter[currCounter].W_round64_L--; + multiCounter[currCounter].W_round64_L--; + multiCounter[currCounter].W_sub--; + multiCounter[currCounter].W_add--; +#endif + return result; +} + +cmplx_s C_mac_r (cmplx x, cmplx_s y, Word16 c) { + cmplx_s result; + cmplx temp = CL_add (x, C_scale (y, c) ); + result = CL_round32_16 (temp); + +#if (WMOPS) + multiCounter[currCounter].C_mac_r++; + multiCounter[currCounter].CL_add--; + multiCounter[currCounter].C_scale--; + multiCounter[currCounter].CL_round32_16--; +#endif + return result; +} + +cmplx_s C_msu_r (cmplx x, cmplx_s y, Word16 c) { + cmplx_s result; + cmplx temp = CL_sub (x, C_scale (y, c) ); + result = CL_round32_16 (temp); + +#if (WMOPS) + multiCounter[currCounter].C_msu_r++; + multiCounter[currCounter].CL_sub--; + multiCounter[currCounter].C_scale--; + multiCounter[currCounter].CL_round32_16--; +#endif + return result; +} + +Word16 C_Extract_real (cmplx_s x) { +#if (WMOPS) + multiCounter[currCounter].C_Extract_real++; +#endif + return x.re; +} + +Word16 C_Extract_imag (cmplx_s x) { +#if (WMOPS) + multiCounter[currCounter].C_Extract_imag++; +#endif + return x.im; +} + +cmplx_s C_negate (cmplx_s x) { + cmplx_s result; + result.re = negate (x.re); + result.im = negate (x.im); +#if (WMOPS) + multiCounter[currCounter].C_negate++; + multiCounter[currCounter].negate--; + multiCounter[currCounter].negate--; +#endif + return result; +} + +cmplx_s C_conjugate (cmplx_s x) { + cmplx_s result; + result.re = x.re; + result.im = negate (x.im); +#if (WMOPS) + multiCounter[currCounter].C_conjugate++; + multiCounter[currCounter].negate--; +#endif + return result; +} + +cmplx_s C_shr (cmplx_s inp, Word16 shift_val) { + cmplx_s out; + out.re = shr (inp.re, shift_val); + out.im = shr (inp.im, shift_val); +#if (WMOPS) + multiCounter[currCounter].C_shr++; + multiCounter[currCounter].shr--; + multiCounter[currCounter].shr--; +#endif + return out; +} + +cmplx_s C_shl (cmplx_s inp, Word16 shift_val) { + cmplx_s out; + out.re = shl (inp.re, shift_val); + out.im = shl (inp.im, shift_val); +#if (WMOPS) + multiCounter[currCounter].C_shl++; + multiCounter[currCounter].shl--; + multiCounter[currCounter].shl--; +#endif + return out; +} + +#endif /* #ifdef COMPLEX_OPERATOR */ + +/* end of file */ + diff --git a/basic_op/complex_basop.h b/basic_op/complex_basop.h new file mode 100644 index 0000000000000000000000000000000000000000..c3deb1455737a515e47b18c2c1e76c51573646ff --- /dev/null +++ b/basic_op/complex_basop.h @@ -0,0 +1,77 @@ + /***************************************************************************** + + * + + * Complex arithmetic operators + + * + + *****************************************************************************/ +#ifndef _COMPLEX_BASIC_OP_H +#define _COMPLEX_BASIC_OP_H + +#include "typedef.h" +#include "basop32.h" +#include "stl.h" + +#ifdef COMPLEX_OPERATOR + +typedef struct +{ + Word32 re; + Word32 im; +}cmplx; + +typedef struct +{ + Word16 re; + Word16 im; +}cmplx_s; + +/*___________________________________________________________________________ + | | + | Prototypes for complex arithmetic operators | + |___________________________________________________________________________| +*/ + +cmplx CL_shr (cmplx inp, Word32 shift_val); +cmplx CL_shl (cmplx inp, Word32 shift_val); +cmplx CL_add (cmplx inp1, cmplx inp2); +cmplx CL_sub (cmplx inp1, cmplx inp2); +cmplx CL_scale (cmplx x, Word16 y); +cmplx CL_dscale (cmplx x, Word16 y1, Word16 y2); +cmplx CL_msu_j (cmplx x, cmplx y); +cmplx CL_mac_j (cmplx x, cmplx y); +cmplx CL_move (cmplx x); +Word32 CL_Extract_real (cmplx x); +Word32 CL_Extract_imag (cmplx x); +cmplx CL_form (Word32 re, Word32 im); +cmplx CL_multr_32x16 (cmplx input, cmplx_s coeff); +cmplx CL_negate (cmplx x); +cmplx CL_conjugate (cmplx x); +cmplx CL_mul_j (cmplx input); +cmplx CL_swap_real_imag (cmplx input); +cmplx_s C_add (cmplx_s inp1, cmplx_s inp2); +cmplx_s C_sub (cmplx_s inp1, cmplx_s inp2); +cmplx_s C_mul_j (cmplx_s input); +cmplx_s C_multr (cmplx_s x, cmplx_s c); +cmplx_s C_form (Word16 re, Word16 im ); + +cmplx C_scale (cmplx_s x, Word16 y); +cmplx_s CL_round32_16 (cmplx x); +cmplx CL_scale_32 (cmplx x, Word32 y); +cmplx CL_dscale_32 (cmplx x, Word32 y1, Word32 y2); +cmplx CL_multr_32x32 (cmplx x, cmplx y); +cmplx_s C_mac_r (cmplx x, cmplx_s y, Word16 c); +cmplx_s C_msu_r (cmplx x, cmplx_s y, Word16 c); +Word16 C_Extract_real (cmplx_s x ); +Word16 C_Extract_imag (cmplx_s x ); +cmplx_s C_negate (cmplx_s x); +cmplx_s C_conjugate (cmplx_s x); +cmplx_s C_shr (cmplx_s inp, Word16 shift_val); +cmplx_s C_shl (cmplx_s inp, Word16 shift_val); + +#endif /* #ifdef COMPLEX_OPERATOR */ + +#endif /* ifndef _COMPLEX_BASIC_OP_H */ + diff --git a/basic_op/control.c b/basic_op/control.c index 18ae3986929e2177b57c98498dceef382d014a9c..2d0a46c25a507116919306e55deb85c40e3772fe 100644 --- a/basic_op/control.c +++ b/basic_op/control.c @@ -3,23 +3,22 @@ File: CONTROL.C v.2.3 - 30.Nov.2009 =========================================================================== - ITU-T STL BASIC OPERATORS + ITU-T STL BASIC OPERATORS - CONTROL FLOW OPERATOR INTERNAL VARIABLE DECLARATIONS + CONTROL FLOW OPERATOR INTERNAL VARIABLE DECLARATIONS History: - 07 Nov 04 v2.0 Incorporation of new 32-bit / 40-bit / control + 07 Nov 04 v2.0 Incorporation of new 32-bit / 40-bit / control operators for the ITU-T Standard Tool Library as described in Geneva, 20-30 January 2004 WP 3/16 Q10/16 TD 11 document and subsequent discussions on the wp3audio@yahoogroups.com email reflector. - March 06 v2.1 Changed to improve portability. + March 06 v2.1 Changed to improve portability. ============================================================================ */ #include "stl.h" -#include "options.h" #ifdef WMOPS int funcId_where_last_call_to_else_occurred; @@ -27,5 +26,225 @@ long funcid_total_wmops_at_last_call_to_else; int call_occurred = 1; #endif +#ifdef CONTROL_CODE_OPS + +Flag LT_16 (Word16 var1, Word16 var2) { + Flag F_ret = 0; + + if( var1 < var2 ) + { + F_ret = 1; + } +#if (WMOPS) + multiCounter[currCounter].LT_16++; +#endif + return F_ret; +} + +Flag GT_16 (Word16 var1, Word16 var2) { + Flag F_ret = 0; + + if( var1 > var2 ) + { + F_ret = 1; + } +#if (WMOPS) + multiCounter[currCounter].GT_16++; +#endif + return F_ret; +} + +Flag LE_16 (Word16 var1, Word16 var2) { + Flag F_ret = 0; + + if (var1 <= var2) { + F_ret = 1; + } +#if (WMOPS) + multiCounter[currCounter].LE_16++; +#endif + return F_ret; +} + +Flag GE_16 (Word16 var1, Word16 var2) { + Flag F_ret = 0; + + if (var1 >= var2) { + F_ret = 1; + } +#if (WMOPS) + multiCounter[currCounter].GE_16++; +#endif + return F_ret; +} + +Flag EQ_16 (Word16 var1, Word16 var2) { + Flag F_ret = 0; + + if (var1 == var2) { + F_ret = 1; + } +#if (WMOPS) + multiCounter[currCounter].EQ_16++; +#endif + return F_ret; +} + +Flag NE_16 (Word16 var1, Word16 var2) { + Flag F_ret = 0; + + if (var1 != var2) { + F_ret = 1; + } +#if (WMOPS) + multiCounter[currCounter].NE_16++; +#endif + return F_ret; +} + +Flag LT_32 (Word32 L_var1, Word32 L_var2) { + Flag F_ret = 0; + + if (L_var1 < L_var2) { + F_ret = 1; + } +#if (WMOPS) + multiCounter[currCounter].LT_32++; +#endif + return F_ret; +} + +Flag GT_32 (Word32 L_var1, Word32 L_var2) { + Flag F_ret = 0; + + if (L_var1 > L_var2) { + F_ret = 1; + } +#if (WMOPS) + multiCounter[currCounter].GT_32++; +#endif + return F_ret; +} + +Flag LE_32 (Word32 L_var1, Word32 L_var2) { + Flag F_ret = 0; + + if (L_var1 <= L_var2) { + F_ret = 1; + } +#if (WMOPS) + multiCounter[currCounter].LE_32++; +#endif + return F_ret; +} + +Flag GE_32 (Word32 L_var1, Word32 L_var2) { + Flag F_ret = 0; + + if (L_var1 >= L_var2) { + F_ret = 1; + } +#if (WMOPS) + multiCounter[currCounter].GE_32++; +#endif + return F_ret; +} + +Flag EQ_32 (Word32 L_var1, Word32 L_var2) { + Flag F_ret = 0; + + if (L_var1 == L_var2) { + F_ret = 1; + } +#if (WMOPS) + multiCounter[currCounter].EQ_32++; +#endif + return F_ret; +} + +Flag NE_32 (Word32 L_var1, Word32 L_var2) { + Flag F_ret = 0; + + if (L_var1 != L_var2) { + F_ret = 1; + } +#if (WMOPS) + multiCounter[currCounter].NE_32++; +#endif + return F_ret; +} + +Flag LT_64 (Word64 L64_var1, Word64 L64_var2) { + Flag F_ret = 0; + + if (L64_var1 < L64_var2) { + F_ret = 1; + } +#if (WMOPS) + multiCounter[currCounter].LT_64++; +#endif + return F_ret; +} + +Flag GT_64 (Word64 L64_var1, Word64 L64_var2) { + Flag F_ret = 0; + + if (L64_var1 > L64_var2) { + F_ret = 1; + } +#if (WMOPS) + multiCounter[currCounter].GT_64++; +#endif + return F_ret; +} + +Flag LE_64 (Word64 L64_var1, Word64 L64_var2) { + Flag F_ret = 0; + + if (L64_var1 <= L64_var2) { + F_ret = 1; + } +#if (WMOPS) + multiCounter[currCounter].LE_64++; +#endif + return F_ret; +} +Flag GE_64 (Word64 L64_var1, Word64 L64_var2) { + Flag F_ret = 0; + + if (L64_var1 >= L64_var2) { + F_ret = 1; + } +#if (WMOPS) + multiCounter[currCounter].GE_64++; +#endif + return F_ret; +} + +Flag EQ_64 (Word64 L64_var1, Word64 L64_var2) { + Flag F_ret = 0; + + if (L64_var1 == L64_var2) { + F_ret = 1; + } +#if (WMOPS) + multiCounter[currCounter].EQ_64++; +#endif + return F_ret; +} +Flag NE_64 (Word64 L64_var1, Word64 L64_var2) { + Flag F_ret = 0; + + if (L64_var1 != L64_var2) { + F_ret = 1; + } +#if (WMOPS) + multiCounter[currCounter].NE_64++; +#endif + return F_ret; +} + +#endif /* #ifdef CONTROL_CODE_OPS */ + /* end of file */ diff --git a/basic_op/control.h b/basic_op/control.h index 1ca659486b6bba26b8b1475f7f4da42e6ece259e..4f406e25ba9a9158328f127e6a970c4aa226324d 100644 --- a/basic_op/control.h +++ b/basic_op/control.h @@ -9,28 +9,27 @@ History: 07 Nov 04 v2.0 Incorporation of new 32-bit / 40-bit / control - operators for the ITU-T Standard Tool Library as + operators for the ITU-T Standard Tool Library as described in Geneva, 20-30 January 2004 WP 3/16 Q10/16 TD 11 document and subsequent discussions on the wp3audio@yahoogroups.com email reflector. - March 06 v2.1 Changed to improve portability. + March 06 v2.1 Changed to improve portability. ============================================================================ */ - #ifndef _CONTROL_H #define _CONTROL_H #include "stl.h" -#include "options.h" + /***************************************************************************** * * Constants and Globals * *****************************************************************************/ -#ifdef WMOPS +#if (WMOPS) extern BASIC_OP multiCounter[MAXCOUNTERS]; extern int currCounter; @@ -49,10 +48,10 @@ extern int currCounter; * ... * } */ -extern int funcId_where_last_call_to_else_occurred; +extern int funcId_where_last_call_to_else_occurred; extern long funcid_total_wmops_at_last_call_to_else; -extern int call_occurred; -#endif /* if WMOPS */ +extern int call_occurred; +#endif /* ifdef WMOPS */ /***************************************************************************** @@ -77,13 +76,13 @@ extern int call_occurred; #ifndef WMOPS #define FOR( a) for( a) -#else /* if !(WMOPS) */ +#else /* ifndef WMOPS */ #define FOR( a) if( incrFor(), 0); else for( a) -static __inline void incrFor( void) { - multiCounter[currCounter].For++; +static __inline void incrFor (void) { + multiCounter[currCounter].For++; } -#endif /* if !(WMOPS) */ +#endif /* ifndef WMOPS */ /***************************************************************************** @@ -100,15 +99,15 @@ static __inline void incrFor( void) { * *****************************************************************************/ #ifndef WMOPS -#define WHILE( a) while( a) +#define WHILE(a) while (a) -#else /* if !(WMOPS) */ -#define WHILE( a) while( incrWhile(), a) +#else /* ifndef WMOPS */ +#define WHILE(a) while (incrWhile(), a) -static __inline void incrWhile( void) { - multiCounter[currCounter].While++; +static __inline void incrWhile (void) { + multiCounter[currCounter].While++; } -#endif /* if !(WMOPS) */ +#endif /* ifndef WMOPS */ /***************************************************************************** @@ -125,10 +124,10 @@ static __inline void incrWhile( void) { #ifndef WMOPS #define DO do -#else /* if !(WMOPS) */ +#else /* ifndef WMOPS */ #define DO do -#endif /* if !(WMOPS) */ +#endif /* ifndef WMOPS */ /***************************************************************************** @@ -152,25 +151,25 @@ static __inline void incrWhile( void) { * *****************************************************************************/ #ifndef WMOPS -#define IF( a) if( a) +#define IF(a) if (a) -#else /* if !(WMOPS) */ -#define IF( a) if( incrIf(), a) +#else /* ifndef WMOPS */ +#define IF(a) if (incrIf (), a) -static __inline void incrIf( void) { +static __inline void incrIf (void) { /* Technical note : * If the "IF" operator comes just after an "ELSE", its counter * must not be incremented. */ - if ( (currCounter != funcId_where_last_call_to_else_occurred) - || (TotalWeightedOperation() != funcid_total_wmops_at_last_call_to_else) - || (call_occurred == 1)) - multiCounter[currCounter].If++; + if ((currCounter != funcId_where_last_call_to_else_occurred) + || (TotalWeightedOperation () != funcid_total_wmops_at_last_call_to_else) + || (call_occurred == 1)) + multiCounter[currCounter].If++; - call_occurred = 0; - funcId_where_last_call_to_else_occurred = MAXCOUNTERS; + call_occurred = 0; + funcId_where_last_call_to_else_occurred = MAXCOUNTERS; } -#endif /* if !(WMOPS) */ +#endif /* ifndef WMOPS */ /***************************************************************************** @@ -187,27 +186,22 @@ static __inline void incrIf( void) { #ifndef WMOPS #define ELSE else -#else /* if !(WMOPS) */ -#define ELSE else if( incrElse(), 0) ; else +#else /* ifndef WMOPS */ +#define ELSE else if (incrElse (), 0) ; else -static __inline void incrElse( void) { - multiCounter[currCounter].If++; +static __inline void incrElse (void) { + multiCounter[currCounter].If++; - /* We keep track of the funcId of the last function - * which used ELSE {...} structure. - */ - funcId_where_last_call_to_else_occurred = currCounter; + /* We keep track of the funcId of the last function which used ELSE {...} structure. */ + funcId_where_last_call_to_else_occurred = currCounter; - /* We keep track of the number of WMOPS of this funcId - * when the ELSE macro was called. - */ - funcid_total_wmops_at_last_call_to_else = TotalWeightedOperation(); + /* We keep track of the number of WMOPS of this funcId when the ELSE macro was called. */ + funcid_total_wmops_at_last_call_to_else = TotalWeightedOperation (); - /* call_occurred is set to 0, in order to count the next IF (if necessary) - */ - call_occurred=0; + /* call_occurred is set to 0, in order to count the next IF (if necessary) */ + call_occurred = 0; } -#endif /* if !(WMOPS) */ +#endif /* ifndef WMOPS */ /***************************************************************************** @@ -222,15 +216,15 @@ static __inline void incrElse( void) { * *****************************************************************************/ #ifndef WMOPS -#define SWITCH( a) switch( a) +#define SWITCH(a) switch (a) -#else /* if !(WMOPS) */ -#define SWITCH( a) switch( incrSwitch(), a) +#else /* ifndef WMOPS */ +#define SWITCH(a) switch (incrSwitch (), a) -static __inline void incrSwitch( void) { - multiCounter[currCounter].Switch++; +static __inline void incrSwitch (void) { + multiCounter[currCounter].Switch++; } -#endif /* if !(WMOPS) */ +#endif /* ifndef WMOPS */ /***************************************************************************** @@ -247,13 +241,13 @@ static __inline void incrSwitch( void) { #ifndef WMOPS #define CONTINUE continue -#else /* if !(WMOPS) */ -#define CONTINUE if( incrContinue(), 0); else continue +#else /* ifndef WMOPS */ +#define CONTINUE if (incrContinue (), 0); else continue -static __inline void incrContinue( void) { - multiCounter[currCounter].Continue++; +static __inline void incrContinue (void) { + multiCounter[currCounter].Continue++; } -#endif /* if !(WMOPS) */ +#endif /* ifndef WMOPS */ /***************************************************************************** @@ -270,13 +264,13 @@ static __inline void incrContinue( void) { #ifndef WMOPS #define BREAK break -#else /* if !(WMOPS) */ -#define BREAK if( incrBreak(), 0) break; else break +#else /* ifndef WMOPS */ +#define BREAK if (incrBreak (), 0); else break -static __inline void incrBreak( void) { - multiCounter[currCounter].Break++; +static __inline void incrBreak (void) { + multiCounter[currCounter].Break++; } -#endif /* if !(WMOPS) */ +#endif /* ifndef WMOPS */ /***************************************************************************** @@ -293,15 +287,45 @@ static __inline void incrBreak( void) { #ifndef WMOPS #define GOTO goto -#else /* if !(WMOPS) */ -#define GOTO if( incrGoto(), 0); else goto +#else /* ifndef WMOPS */ +#define GOTO if (incrGoto (), 0); else goto -static __inline void incrGoto( void) { - multiCounter[currCounter].Goto++; +static __inline void incrGoto (void) { + multiCounter[currCounter].Goto++; } -#endif /* if !(WMOPS) */ +#endif /* ifndef WMOPS */ + +/* + * New control code basops +*/ +#ifdef CONTROL_CODE_OPS + +Flag LT_16 (Word16 var1, Word16 var2); +Flag GT_16 (Word16 var1, Word16 var2); +Flag LE_16 (Word16 var1, Word16 var2); +Flag GE_16 (Word16 var1, Word16 var2); +Flag EQ_16 (Word16 var1, Word16 var2); +Flag NE_16 (Word16 var1, Word16 var2); + +Flag LT_32 (Word32 L_var1, Word32 L_var2); +Flag GT_32 (Word32 L_var1, Word32 L_var2); +Flag LE_32 (Word32 L_var1, Word32 L_var2); +Flag GE_32 (Word32 L_var1, Word32 L_var2); +Flag EQ_32 (Word32 L_var1, Word32 L_var2); +Flag NE_32 (Word32 L_var1, Word32 L_var2); + +Flag LT_64 (Word64 L64_var1, Word64 L64_var2); +Flag GT_64 (Word64 L64_var1, Word64 L64_var2); +Flag LE_64 (Word64 L64_var1, Word64 L64_var2); +Flag GE_64 (Word64 L64_var1, Word64 L64_var2); +Flag EQ_64 (Word64 L64_var1, Word64 L64_var2); +Flag NE_64 (Word64 L64_var1, Word64 L64_var2); + + +#endif /* #ifdef CONTROL_CODE_OPS */ + #endif /* _CONTROL_H */ diff --git a/basic_op/count.c b/basic_op/count.c index 258894cd2d7a7b2ff710a495620352bad3823695..1fc839b6249b5100f4fcca179f4063bc0291cd0d 100644 --- a/basic_op/count.c +++ b/basic_op/count.c @@ -9,7 +9,7 @@ History: 03 Nov 04 v2.0 Incorporation of new 32-bit / 40-bit / control - operators for the ITU-T Standard Tool Library as + operators for the ITU-T Standard Tool Library as described in Geneva, 20-30 January 2004 WP 3/16 Q10/16 TD 11 document and subsequent discussions on the wp3audio@yahoogroups.com email reflector. @@ -46,65 +46,29 @@ #include #include #include -#include #include "stl.h" -#include "options.h" -#include "wmc_auto.h" - -#ifndef WMOPS -#include "options_warnings.h" -#endif - -#define WMC_TOOL_SKIP #ifdef WMOPS -static double frameRate = FRAME_RATE; /* default value : 10 ms */ - -#define MAX_RECORDS 1024 -#define MAX_STACK 64 -#define MAX_CHAR 64 - -// struct wmops_record -//{ -// char label[MAX_CHAR]; -// long call_number; -// long update_cnt; -// int call_tree[MAX_RECORDS]; -// double start_selfcnt; -// double current_selfcnt; -// double max_selfcnt; -// double min_selfcnt; -// double tot_selfcnt; -// double start_cnt; /* The following take into account the decendants */ -// double current_cnt; -// double max_cnt; -// double min_cnt; -// double tot_cnt; -// }; -// -// static struct wmops_record wmops[MAX_RECORDS]; - -static int stack[MAX_STACK]; -static int sptr; -static int sum_stack[MAX_STACK]; +static double frameRate = FRAME_RATE; /* default value : 10 ms */ +#endif /* ifdef WMOPS */ +#ifdef WMOPS /* Global counter variable for calculation of complexity weight */ -/* Some enhancement written by Vail., GJR and M.Mul. during EVS time */ - BASIC_OP multiCounter[MAXCOUNTERS]; -BASIC_OP glob_multiCounter; -int currCounter = 0; /* Zero equals global counter */ - -void setFrameRate( int samplingFreq, int frameLength ) -{ - if ( frameLength > 0 ) - { - frameRate = samplingFreq / 1000000.0 / frameLength; - } - return; +int currCounter = 0; /* Zero equals global counter */ +#endif /* ifdef WMOPS */ + +#ifdef WMOPS +void setFrameRate (int samplingFreq, int frameLength) { + if (frameLength > 0) { + frameRate = samplingFreq / 1000000.0 / frameLength; + } + return; } +#endif /* ifdef WMOPS */ +#ifdef WMOPS /* * Below list is used for displaying the code profiling information in * the file which name is defined by CODE_PROFILE_FILENAME. @@ -113,142 +77,249 @@ void setFrameRate( int samplingFreq, int frameLength ) * with the structure definition BASIC_OP. */ char *BasicOperationList[] = { - "add", "sub", "abs_s", "shl", "shr", - "extract_h", "extract_l", "mult", "L_mult", "negate", - "round", "L_mac", "L_msu", "L_macNs", "L_msuNs", - "L_add", "L_sub", "L_add_c", "L_sub_c", "L_negate", - "L_shl", "L_shr", "mult_r", "shr_r", "mac_r", - - "msu_r", "L_deposit_h", "L_deposit_l", "L_shr_r", "L_abs", - "L_sat", "norm_s", "div_s", "norm_l", "move16", - "move32", "Logic16", "Logic32", "Test", "s_max", - "s_min", "L_max", "L_min", "L40_max", "L40_min", - "shl_r", "L_shl_r", "L40_shr_r", "L40_shl_r", "norm_L40", - - "L40_shl", "L40_shr", "L40_negate", "L40_add", "L40_sub", - "L40_abs", "L40_mult", "L40_mac", "mac_r40", - "L40_msu", "msu_r40", "Mpy_32_16_ss", "Mpy_32_32_ss", "L_mult0", - "L_mac0", "L_msu0", "lshl", "lshr", "L_lshl", - "L_lshr", "L40_lshl", "L40_lshr", "s_and", "s_or", - - "s_xor", "L_and", "L_or", "L_xor", "rotl", - "rotr", "L_rotl", "L_rotr", "L40_set", "L40_deposit_h", - "L40_deposit_l", "L40_deposit32", "Extract40_H", "Extract40_L", "L_Extract40", - "L40_round", "L_saturate40", "round40", "IF", "GOTO", - "BREAK", "SWITCH", "FOR", "WHILE", "CONTINUE", - - "L_mls", "div_l", "i_mult" - -/* New complex basops */ -#ifdef COMPLEX_OPERATOR - , - "CL_shr", "CL_shl", "CL_add", "CL_sub", "CL_scale", "CL_dscale", "CL_msu_j", "CL_mac_j", "CL_move", "CL_Extract_real", "CL_Extract_imag", "CL_form", "CL_multr_32x16", "CL_negate", "CL_conjugate", "CL_mul_j", "CL_swap_real_imag", "C_add", "C_sub", "C_mul_j", "C_multr", "C_form" - - , - "C_scale", "CL_round32_16", "CL_scale_32", "CL_dscale_32", "CL_multr_32x32", "C_mac_r", "C_msu_r", "C_Extract_real", "C_Extract_imag", "C_negate", "C_conjugate", "C_shr", "C_shl" + "add", "sub", "abs_s", "shl", "shr", + "extract_h", "extract_l", "mult", "L_mult", "negate", + "round", "L_mac", "L_msu", "L_macNs", "L_msuNs", + "L_add", "L_sub", "L_add_c", "L_sub_c", "L_negate", + "L_shl", "L_shr", "mult_r", "shr_r", "mac_r", + + "msu_r", "L_deposit_h", "L_deposit_l", "L_shr_r", "L_abs", + "L_sat", "norm_s", "div_s", "norm_l", "move16", + "move32", "Logic16", "Logic32", "Test", "s_max", + "s_min", "L_max", "L_min", "L40_max", "L40_min", + "shl_r", "L_shl_r", "L40_shr_r", "L40_shl_r", "norm_L40", + + "L40_shl", "L40_shr", "L40_negate", "L40_add", "L40_sub", + "L40_abs", "L40_mult", "L40_mac", "mac_r40", + "L40_msu", "msu_r40", "Mpy_32_16_ss", "Mpy_32_32_ss", "L_mult0", + "L_mac0", "L_msu0", "lshl", "lshr", "L_lshl", + "L_lshr", "L40_lshl", "L40_lshr", "s_and", "s_or", + + "s_xor", "L_and", "L_or", "L_xor", "rotl", + "rotr", "L_rotl", "L_rotr", "L40_set", "L40_deposit_h", + "L40_deposit_l", "L40_deposit32", "Extract40_H", "Extract40_L", "L_Extract40", + "L40_round", "L_saturate40", "round40", "IF", "GOTO", + "BREAK", "SWITCH", "FOR", "WHILE", "CONTINUE", + + "L_mls", "div_l", "i_mult" + + /* New complex basops */ + #ifdef COMPLEX_OPERATOR + , "CL_shr", "CL_shl", "CL_add" + , "CL_sub", "CL_scale", "CL_dscale" + , "CL_msu_j", "CL_mac_j", "CL_move" + , "CL_Extract_real", "CL_Extract_imag", "CL_form" + , "CL_multr_32x16", "CL_negate", "CL_conjugate" + , "CL_mul_j" + , "CL_swap_real_imag" + , "C_add" + , "C_sub" + , "C_mul_j" + , "C_multr" + , "C_form" + + , "C_scale" + , "CL_round32_16", "CL_scale_32", "CL_dscale_32", "CL_multr_32x32" + , "C_mac_r", "C_msu_r", "C_Extract_real", "C_Extract_imag" + , "C_negate", "C_conjugate" + , "C_shr", "C_shl" #endif /* #ifdef COMPLEX_OPERATOR */ -/* New 64 bit basops */ + /* New 64 bit basops */ #ifdef ENH_64_BIT_OPERATOR - , - "move64", "W_add_nosat", "W_sub_nosat", "W_shl", "W_shr", "W_shl_nosat", "W_shr_nosat", "W_mac_32_16", "W_msu_32_16", "W_mult_32_16", "W_mult0_16_16", "W_mac0_16_16", "W_msu0_16_16", "W_mult_16_16", "W_mac_16_16", "W_msu_16_16", "W_shl_sat_l", "W_sat_l", "W_sat_m", "W_deposit32_l", "W_deposit32_h", "W_extract_l", "W_extract_h", "W_round48_L", "W_round32_s", "W_norm", "W_add", "W_sub", "W_neg", "W_abs", "W_mult_32_32", "W_mult0_32_32", "W_lshl", "W_lshr", "W_round64_L" + , "move64" , "W_add_nosat" ,"W_sub_nosat" + , "W_shl" , "W_shr" + , "W_shl_nosat" , "W_shr_nosat" + , "W_mac_32_16" , "W_msu_32_16" , "W_mult_32_16" + , "W_mult0_16_16" , "W_mac0_16_16" , "W_msu0_16_16" + , "W_mult_16_16" , "W_mac_16_16" , "W_msu_16_16" + , "W_shl_sat_l" , "W_sat_l" + , "W_sat_m" , "W_deposit32_l" ,"W_deposit32_h" + , "W_extract_l" , "W_extract_h" + , "W_round48_L" , "W_round32_s" + , "W_norm" + , "W_add" , "W_sub" ,"W_neg" ,"W_abs" + , "W_mult_32_32" , "W_mult0_32_32" + , "W_lshl" , "W_lshr" ,"W_round64_L" #endif /* #ifdef ENH_64_BIT_OPERATOR */ #ifdef ENH_32_BIT_OPERATOR - , - "Mpy_32_16_1", "Mpy_32_16_r", "Mpy_32_32", "Mpy_32_32_r", "Madd_32_16", "Madd_32_16_r", "Msub_32_16", "Msub_32_16_r", "Madd_32_32", "Madd_32_32_r", "Msub_32_32", "Msub_32_32_r" + , "Mpy_32_16_1" + , "Mpy_32_16_r" + , "Mpy_32_32" + , "Mpy_32_32_r" + , "Madd_32_16" + , "Madd_32_16_r" + , "Msub_32_16" + , "Msub_32_16_r" + , "Madd_32_32" + , "Madd_32_32_r" + , "Msub_32_32" + , "Msub_32_32_r" #endif /* #ifdef ENH_32_BIT_OPERATOR */ #ifdef ENH_U_32_BIT_OPERATOR - , - "UL_addNs", "UL_subNs", "UL_Mpy_32_32", "Mpy_32_32_uu", "Mpy_32_16_uu", "norm_ul_float", "UL_deposit_l" + , "UL_addNs" + , "UL_subNs" + , "UL_Mpy_32_32" + , "Mpy_32_32_uu" + , "Mpy_32_16_uu" + , "norm_ul" + , "UL_deposit_l" #endif /* #ifdef ENH_U_32_BIT_OPERATOR */ #ifdef CONTROL_CODE_OPS - , - "LT_16", "GT_16", "LE_16", "GE_16", "EQ_16", "NE_16", "LT_32", "GT_32", "LE_32", "GE_32", "EQ_32", "NE_32", "LT_64", "GT_64", "LE_64", "GE_64", "EQ_64", "NE_64" + , "LT_16" + , "GT_16" + , "LE_16" + , "GE_16" + , "EQ_16" + , "NE_16" + , "LT_32" + , "GT_32" + , "LE_32" + , "GE_32" + , "EQ_32" + , "NE_32" + , "LT_64" + , "GT_64" + , "LE_64" + , "GE_64" + , "EQ_64" + , "NE_64" #endif /* #ifdef CONTROL_CODE_OPS */ }; +#endif /* ifdef WMOPS */ +#ifdef WMOPS const BASIC_OP op_weight = { - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - 1, 1, 2, 2, 1, - 1, 1, 1, 2, 1, - - 1, 1, 1, 2, 1, - 1, 1, 18, 1, 1, - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - 2, 2, 2, 2, 1, - - 1, 1, 1, 1, 1, - 1, 1, 1, 2, - 1, 2, 2, 2, 1, - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 3, - 3, 3, 3, 1, 1, - 1, 1, 1, 1, 1, - 1, 1, 1, 3, 2, - 2, 6, 3, 3, 2, - - 1, 32, 1 + 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, + 1, 1, 2, 2, 1, + 1, 1, 1, 2, 1, + + 1, 1, 1, 2, 1, + 1, 1, 18, 1, 1, + 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, + 2, 2, 2, 2, 1, + + 1, 1, 1, 1, 1, + 1, 1, 1, 2, + 1, 2, 2, 2, 1, + 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 3, + 3, 3, 3, 1, 1, + 1, 1, 1, 1, 1, + 1, 1, 1, 3, 2, + 2, 6, 3, 3, 2, + + 1, 32, 1 /* New complex basops */ -#ifdef COMPLEX_OPERATOR - , - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1 - - , - 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1 + #ifdef COMPLEX_OPERATOR + , 1, 1, 1 + , 1, 1, 1 + , 1, 1, 1 + , 1, 1, 1 + , 2, 1, 1 + , 1 + , 1 + , 1 + , 1 + , 1 + , 2 + , 1 + + , 1 + , 1, 1, 1, 2 + , 2, 2, 1, 1 + , 1, 1 + , 1, 1 #endif /* #ifdef COMPLEX_OPERATOR */ #ifdef ENH_64_BIT_OPERATOR - /* Weights of new 64 bit basops */ - , - 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 + /* Weights of new 64 bit basops */ + , 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 #endif /* #ifdef ENH_64_BIT_OPERATOR */ #ifdef ENH_32_BIT_OPERATOR - , - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 + , 1 + , 1 + , 1 + , 1 + , 1 + , 1 + , 1 + , 1 + , 1 + , 1 + , 1 + , 1 #endif /* #ifdef ENH_32_BIT_OPERATOR */ #ifdef ENH_U_32_BIT_OPERATOR - , - 1, 1, 1, 2, 2, 1, 1 + , 1 + , 1 + , 1 + , 2 + , 2 + , 1 + , 1 #endif /* #ifdef ENH_U_32_BIT_OPERATOR */ #ifdef CONTROL_CODE_OPS - , - 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 #endif /* #ifdef CONTROL_CODE_OPS */ }; #endif /* ifdef WMOPS */ -Word32 TotalWeightedOperation( void ); -Word32 DeltaWeightedOperation( void ); +Word32 TotalWeightedOperation (void); +Word32 DeltaWeightedOperation (void); #ifdef WMOPS /* Counters for separating counting for different objects */ -/* FROM_EVS_DEV */ -/** -maxCounter: current number of counters. Each scope initialized with BASOP_sub_start() gets a own counter assigned. -objectName: Name of each counter passed to BASOP_sub_start(). -fwc_corr: -nbTimeObjectIsCalled: number of times a counter (object) is referenced in the current frame. -*/ static int maxCounter = 0; static char *objectName[MAXCOUNTERS + 1]; @@ -256,1138 +327,446 @@ static char *objectName[MAXCOUNTERS + 1]; static Word16 fwc_corr[MAXCOUNTERS + 1]; static long int nbTimeObjectIsCalled[MAXCOUNTERS + 1]; +#define NbFuncMax 1024 -#define NbFuncMax ( 4096 ) - - -/** - funcid: current function call for each counter - bc : best case for each counter and function call - wc : worst case for each counter and function call - nbframe: number of frames for each counter. - glob_bc: global best case self time for each counter for current frame. - glob_wc: global worst case self time for each counter for current frame. - glob_sum_curr: global cummulative time for each counter for current frame. - glob_sum_bc: global best case cummulative time for each counter for current frame. - glob_sum_wc: global worst case cummulative time for each counter for current frame. - - total_wmops: total wmops self time for each counter for current frame. - total_sum: total wmops cummulative time for each counter for current frame. - LastWOper: values used for WMOPS deltas - */ - -static Word32 funcid[MAXCOUNTERS], nbframe[MAXCOUNTERS], nbcalls[MAXCOUNTERS]; -static Word32 glob_bc[MAXCOUNTERS], glob_wc[MAXCOUNTERS], bc[MAXCOUNTERS][NbFuncMax], wc[MAXCOUNTERS][NbFuncMax]; +static Word16 funcid[MAXCOUNTERS], nbframe[MAXCOUNTERS]; +static Word32 glob_wc[MAXCOUNTERS], wc[MAXCOUNTERS][NbFuncMax]; static float total_wmops[MAXCOUNTERS]; -static Word32 LastWOper[MAXCOUNTERS]; -/* FROM_EVS_DEV */ -static float total_sum[MAXCOUNTERS]; -static Word16 call_tree[MAXCOUNTERS][MAXCOUNTERS]; -static int sum_curr[MAXCOUNTERS + 1]; -static int sum_bc[MAXCOUNTERS + 1]; -static int sum_wc[MAXCOUNTERS + 1]; -static int glob_sum_curr[MAXCOUNTERS + 1]; -static int glob_sum_bc[MAXCOUNTERS + 1]; -static int glob_sum_wc[MAXCOUNTERS + 1]; -#if MAX_CALLERS_SAVED_FRAMES -#define MAX_CALLERS_PRINT 20 -static float callers_frames[MAX_CALLERS_SAVED_FRAMES + 1][MAXCOUNTERS + 1]; -static int callers_frames_nos[MAX_CALLERS_SAVED_FRAMES]; -static float callers_totals[MAX_CALLERS_SAVED_FRAMES]; -#endif +static Word32 LastWOper[MAXCOUNTERS]; #endif /* ifdef WMOPS */ #ifdef WMOPS -static char *my_strdup( const char *s ) -{ - /* - * duplicates UNIX function strdup() which is not ANSI standard: - * -- malloc() memory area big enough to hold the string s - * -- copy string into new area - * -- return pointer to new area - * - * returns NULL if either s==NULL or malloc() fails - */ - char *dup; - - if ( s == NULL ) - return NULL; - - /* allocate memory for copy of ID string (including string terminator) */ - /* NOTE: the ID strings will never be deallocated because there is no way to "destroy" a counter that is not longer needed */ - if ( ( dup = (char *) malloc( strlen( s ) + 1 ) ) == NULL ) - return NULL; - - return strcpy( dup, s ); +static char *my_strdup (const char *s) { + /* + * duplicates UNIX function strdup() which is not ANSI standard: + * -- malloc() memory area big enough to hold the string s + * -- copy string into new area + * -- return pointer to new area + * + * returns NULL if either s==NULL or malloc() fails + */ + char *dup; + + if (s == NULL) + return NULL; + + /* allocate memory for copy of ID string (including string terminator) */ + /* NOTE: the ID strings will never be deallocated because there is no way to "destroy" a counter that is not longer needed */ + if ((dup = (char *) malloc (strlen (s) + 1)) == NULL) + return NULL; + + return strcpy (dup, s); } #endif /* ifdef WMOPS */ -int getCounterId( const char *objectNameArg ) -{ -#ifdef WMOPS - if ( maxCounter >= MAXCOUNTERS - 1 ) - return 0; - objectName[++maxCounter] = my_strdup( objectNameArg ); - return maxCounter; +int getCounterId (char *objectNameArg) { +#if WMOPS + if (maxCounter >= MAXCOUNTERS - 1) + return 0; + objectName[++maxCounter] = my_strdup (objectNameArg); + return maxCounter; #else /* ifdef WMOPS */ - (void) objectNameArg; - return 0; /* Dummy */ + (void)objectNameArg; + return 0; /* Dummy */ #endif /* ifdef WMOPS */ } -#ifdef WMOPS -int readCounterId() -{ - return currCounter; +#if WMOPS +int readCounterId () { + return currCounter; } #endif /* ifdef WMOPS */ #ifdef WMOPS -char *readCounterIdName() -{ - return objectName[currCounter]; +char *readCounterIdName () { + return objectName[currCounter]; } #endif /* ifdef WMOPS */ -void setCounter( int counterId ) -{ -#ifdef WMOPS - if ( ( counterId > maxCounter ) || ( counterId < 0 ) ) - { - currCounter = 0; - return; - } - currCounter = counterId; - call_occurred = 1; +void setCounter (int counterId) { +#if WMOPS + if ((counterId > maxCounter) + || (counterId < 0)) { + currCounter = 0; + return; + } + currCounter = counterId; + call_occurred = 1; #else - (void) counterId; + (void)counterId; #endif /* ifdef WMOPS */ } -void incrementNbTimeObjectIsCalled( int counterId ) -{ -#ifdef WMOPS - if ( ( counterId > maxCounter ) || ( counterId < 0 ) ) - { - nbTimeObjectIsCalled[0]++; - return; - } - nbTimeObjectIsCalled[counterId]++; +void incrementNbTimeObjectIsCalled (int counterId) { +#if WMOPS + if ((counterId > maxCounter) + || (counterId < 0)) { + nbTimeObjectIsCalled[0]++; + return; + } + nbTimeObjectIsCalled[counterId]++; #else - (void) counterId; + (void)counterId; #endif /* ifdef WMOPS */ } -#ifdef WMOPS -static Word32 WMOPS_frameStat( void ) -{ - /* calculate the WMOPS seen so far and update the global - per-frame maximum (glob_wc) - */ - Word32 tot; - - tot = TotalWeightedOperation(); - if ( tot > glob_wc[currCounter] ) - { - glob_wc[currCounter] = tot; - } +#if WMOPS +static Word32 WMOPS_frameStat (void) { +/* calculate the WMOPS seen so far and update the global + per-frame maximum (glob_wc) + */ + Word32 tot; - if ( tot < glob_bc[currCounter] ) - { - glob_bc[currCounter] = tot; - } - /* check if fwc() was forgotten at end of last frame */ - if ( tot > LastWOper[currCounter] ) - { - if ( !fwc_corr[currCounter] ) - { - fprintf( stderr, - "count: operations counted after last fwc() for '%s'; " - "-> fwc() called\n", - objectName[currCounter] ? objectName[currCounter] : "" ); - } - fwc(); + tot = TotalWeightedOperation (); + if (tot > glob_wc[currCounter]) + glob_wc[currCounter] = tot; + + /* check if fwc() was forgotten at end of last frame */ + if (tot > LastWOper[currCounter]) { + if (!fwc_corr[currCounter]) { + fprintf (stderr, + "count: operations counted after last fwc() for '%s'; " "-> fwc() called\n", + objectName[currCounter] ? objectName[currCounter] : ""); } + fwc (); + } - return tot; + return tot; } #endif /* ifdef WMOPS */ #ifdef WMOPS -static void WMOPS_clearMultiCounter( void ) -{ - Word16 i; - - Word32 *ptr = (Word32 *) &multiCounter[currCounter]; - for ( i = 0; i < (Word16) ( sizeof( multiCounter[currCounter] ) / sizeof( Word32 ) ); i++ ) - { - *ptr++ = 0; - } +static void WMOPS_clearMultiCounter (void) { + Word16 i; + + Word32 *ptr = (Word32 *) & multiCounter[currCounter]; + for (i = 0; i < (Word16)(sizeof (multiCounter[currCounter]) / sizeof (Word32)); i++) { + *ptr++ = 0; + } } #endif /* ifdef WMOPS */ -void ClearNbTimeObjectsAreCalled() -{ -#ifdef WMOPS - Word16 i; +void ClearNbTimeObjectsAreCalled () { +#if WMOPS + Word16 i; - for ( i = 0; i < (Word16) ( sizeof( multiCounter[currCounter] ) / sizeof( Word32 ) ); i++ ) - { - nbTimeObjectIsCalled[i] = 0; - } + for (i = 0; i < (Word16)(sizeof (multiCounter[currCounter]) / sizeof (Word32)); i++) { + nbTimeObjectIsCalled[i] = 0; + } #endif /* ifdef WMOPS */ } -Word32 TotalWeightedOperation() -{ -#ifdef WMOPS - Word16 i; - Word32 tot, *ptr; - const Word32 *ptr2; - - tot = 0; - ptr = (Word32 *) &multiCounter[currCounter]; - ptr2 = (const Word32 *) &op_weight; - for ( i = 0; i < (Word16) ( sizeof( multiCounter[currCounter] ) / sizeof( Word32 ) ); i++ ) - { - tot += ( ( *ptr++ ) * ( *ptr2++ ) ); - } +Word32 TotalWeightedOperation () { +#if WMOPS + Word16 i; + Word32 tot, *ptr, *ptr2; - return ( (Word32) tot ); + tot = 0; + ptr = (Word32 *) & multiCounter[currCounter]; + ptr2 = (Word32 *) & op_weight; + for (i = 0; i < (Word16)(sizeof (multiCounter[currCounter]) / sizeof (Word32)); i++) { + tot += ((*ptr++) * (*ptr2++)); + } + + return ((Word32) tot); #else /* ifdef WMOPS */ - return 0; /* Dummy */ + return 0; /* Dummy */ #endif /* ifdef WMOPS */ + } -Word32 DeltaWeightedOperation() -{ -#ifdef WMOPS - Word32 NewWOper, delta; +Word32 DeltaWeightedOperation () { +#if WMOPS + Word32 NewWOper, delta; - NewWOper = TotalWeightedOperation(); - delta = NewWOper - LastWOper[currCounter]; - LastWOper[currCounter] = NewWOper; - return ( delta ); + NewWOper = TotalWeightedOperation (); + delta = NewWOper - LastWOper[currCounter]; + LastWOper[currCounter] = NewWOper; + return (delta); #else /* ifdef WMOPS */ - return 0; /* Dummy */ + return 0; /* Dummy */ #endif /* ifdef WMOPS */ } -void Init_WMOPS_counter( void ) -{ -#ifdef WMOPS - Word16 i; - - /* reset function weight operation counter variable */ - - for ( i = 0; i < NbFuncMax; i++ ) - wc[currCounter][i] = (Word32) 0; - glob_wc[currCounter] = 0; - nbframe[currCounter] = 0; - total_wmops[currCounter] = 0.0; - for ( i = 0; i < NbFuncMax; i++ ) - { - bc[currCounter][i] = (Word32) MAX_32; - } - glob_bc[currCounter] = MAX_32; - nbcalls[currCounter] = 0; - total_sum[currCounter] = 0.0; - - /* initially clear all counters */ - WMOPS_clearMultiCounter(); - LastWOper[currCounter] = 0; - funcid[currCounter] = 0; - - /* Following line is useful for incrIf(), see control.h */ - call_occurred = 1; - funcId_where_last_call_to_else_occurred = MAXCOUNTERS; - - sum_bc[currCounter] = MAX_32; - sum_wc[currCounter] = 0; - sum_curr[currCounter] = 0; - for ( i = 0; i < MAXCOUNTERS; i++ ) - { - call_tree[currCounter][i] = -1; - } +void Init_WMOPS_counter (void) { +#if WMOPS + Word16 i; - glob_sum_curr[currCounter] = 0; - glob_sum_wc[currCounter] = 0; - glob_sum_bc[currCounter] = MAX_32; + /* reset function weight operation counter variable */ -#endif /* ifdef WMOPS */ -} + for (i = 0; i < NbFuncMax; i++) + wc[currCounter][i] = (Word32) 0; + glob_wc[currCounter] = 0; + nbframe[currCounter] = 0; + total_wmops[currCounter] = 0.0; + /* initially clear all counters */ + WMOPS_clearMultiCounter (); + LastWOper[currCounter] = 0; + funcid[currCounter] = 0; -Word32 Reset_WMOPS_counter( void ) -{ -#ifdef WMOPS - Word32 tot = WMOPS_frameStat(); - - /* increase the frame counter --> a frame is counted WHEN IT BEGINS */ - nbframe[currCounter]++; - /* Call counter */ - nbcalls[currCounter] += funcid[currCounter]; - /* add wmops used in last frame to count, then reset counter (in first frame, this is a no-op */ - total_wmops[currCounter] += (float) ( tot * frameRate ); - total_sum[currCounter] += (float) ( ( glob_sum_curr[currCounter] ) * frameRate ); - - /* clear counter before new frame starts */ - WMOPS_clearMultiCounter(); - LastWOper[currCounter] = 0; - funcid[currCounter] = 0; /* new frame, set function id to zero */ - - glob_sum_curr[currCounter] = 0; - sum_curr[currCounter] = 0; - return tot; -#else - return 0; + /* Following line is useful for incrIf(), see control.h */ + call_occurred = 1; + funcId_where_last_call_to_else_occurred = MAXCOUNTERS; #endif /* ifdef WMOPS */ } -Word32 fwc( void ) -{ -/* function worst case */ -#ifdef WMOPS - Word32 tot; - - tot = DeltaWeightedOperation(); - if ( tot > wc[currCounter][funcid[currCounter]] ) - wc[currCounter][funcid[currCounter]] = tot; +void Reset_WMOPS_counter (void) { +#if WMOPS + Word32 tot = WMOPS_frameStat (); - if ( tot < bc[currCounter][funcid[currCounter]] ) - bc[currCounter][funcid[currCounter]] = tot; + /* increase the frame counter --> a frame is counted WHEN IT BEGINS */ + nbframe[currCounter]++; + + /* add wmops used in last frame to count, then reset counter (in first frame, this is a no-op */ + total_wmops[currCounter] += (float) (tot * frameRate); - funcid[currCounter]++; - - /*make sure that BASOP_frame_update(); is put at the end of the main loop*/ - if ( funcid[currCounter] >= NbFuncMax ) - { - printf( "to many function calls\n" ); - } - assert( funcid[currCounter] < NbFuncMax ); - return ( tot ); -#else - return 0; + /* clear counter before new frame starts */ + WMOPS_clearMultiCounter (); + LastWOper[currCounter] = 0; + funcid[currCounter] = 0; /* new frame, set function id to zero */ #endif /* ifdef WMOPS */ } -void WMOPS_output( Word16 dtx_mode ) -{ -#ifdef WMOPS - Word16 i; - Word32 tot, tot_wm, tot_wc; - /* get operations since last reset (or init), but do not update the counters (except the glob_wc[] maximum) - so output CAN be called in each frame without problems. The frame counter is NOT updated! */ - tot = WMOPS_frameStat(); - tot_wm = (Word32) ( total_wmops[currCounter] + ( (float) tot ) * frameRate ); +Word32 fwc (void) { +/* function worst case */ +#if WMOPS + Word32 tot; - fprintf( stdout, - "%10s:WMOPS=%.3f", objectName[currCounter] ? objectName[currCounter] : "", - ( (float) tot ) * frameRate ); + tot = DeltaWeightedOperation (); + if (tot > wc[currCounter][funcid[currCounter]]) + wc[currCounter][funcid[currCounter]] = tot; - if ( nbframe[currCounter] != 0 ) - { - fprintf( stdout, " Average=%.3f", tot_wm / (float) nbframe[currCounter] ); - } - fprintf( stdout, " WorstCase=%.3f", ( (float) glob_wc[currCounter] ) * frameRate ); + funcid[currCounter]++; + return (tot); + +#else /* ifdef WMOPS */ + return 0; /* Dummy */ - /* Worst worst case printed only when not in DTX mode */ - if ( dtx_mode == 0 ) - { - tot_wc = 0L; - for ( i = 0; i < funcid[currCounter]; i++ ) - tot_wc += wc[currCounter][i]; - fprintf( stdout, " WorstWC=%.3f", ( (float) tot_wc ) * frameRate ); - } - fprintf( stdout, " (%d frames)\n", nbframe[currCounter] ); -#else - (void) dtx_mode; #endif /* ifdef WMOPS */ } -void WMOPS_output_avg( Word16 dtx_mode, Word32 *tot_wm, Word32 *num_frames ) -{ -#ifdef WMOPS - Word16 i; - Word32 tot, tot_wc; - - /* get operations since last reset (or init), but do not update the counters (except the glob_wc[] maximum) - so output CAN be called in each frame without problems. The frame counter is NOT updated! */ - tot = WMOPS_frameStat(); - *tot_wm = (Word32) ( total_wmops[currCounter] + ( (float) tot ) * frameRate ); - *num_frames = nbframe[currCounter]; +void WMOPS_output (Word16 dtx_mode) { +#if WMOPS + Word16 i; + Word32 tot, tot_wm, tot_wc; - fprintf( stdout, "%10s:WMOPS=%.3f", objectName[currCounter] ? objectName[currCounter] : "", ( (float) tot ) * frameRate ); + /* get operations since last reset (or init), but do not update the counters (except the glob_wc[] maximum) + so output CAN be called in each frame without problems. The frame counter is NOT updated! */ + tot = WMOPS_frameStat (); + tot_wm = (Word32) (total_wmops[currCounter] + ((float) tot) * frameRate); - if ( nbframe[currCounter] != 0 ) - { - fprintf( stdout, " Average=%.3f", *tot_wm / (float) nbframe[currCounter] ); - } - fprintf( stdout, " WorstCase=%.3f", ( (float) glob_wc[currCounter] ) * frameRate ); + fprintf (stdout, + "%10s:WMOPS=%.3f", objectName[currCounter] ? objectName[currCounter] : "", + ((float) tot) * frameRate); - /* Worst worst case printed only when not in DTX mode */ - if ( dtx_mode == 0 ) - { - tot_wc = 0L; - for ( i = 0; i < funcid[currCounter]; i++ ) - tot_wc += wc[currCounter][i]; - fprintf( stdout, " WorstWC=%.3f", ( (float) tot_wc ) * frameRate ); - } - fprintf( stdout, " (%d frames)\n", nbframe[currCounter] ); + if (nbframe[currCounter] != 0) { + fprintf (stdout, " Average=%.3f", tot_wm / (float) nbframe[currCounter]); + } + fprintf (stdout, " WorstCase=%.3f", ((float) glob_wc[currCounter]) * frameRate); + + /* Worst worst case printed only when not in DTX mode */ + if (dtx_mode == 0) { + tot_wc = 0L; + for (i = 0; i < funcid[currCounter]; i++) + tot_wc += wc[currCounter][i]; + fprintf (stdout, " WorstWC=%.3f", ((float) tot_wc) * frameRate); + } + fprintf (stdout, " (%d frames)\n", nbframe[currCounter]); #else - (void) dtx_mode; - (void) tot_wm; - (void) num_frames; + (void)dtx_mode; #endif /* ifdef WMOPS */ } -void generic_WMOPS_output( Word16 dtx_mode, char *test_file_name ) -{ -#ifdef WMOPS - int saved_value; - Word16 i; - Word32 tot, tot_wm, tot_wc, *ptr; - const Word32 *ptr2; - Word40 grand_total; - FILE *WMOPS_file; - - saved_value = currCounter; - - /* Count the grand_total WMOPS so that % ratio per function group can be displayed. */ - grand_total = 0; - for ( currCounter = 0; currCounter <= maxCounter; currCounter++ ) - { - tot = WMOPS_frameStat(); - grand_total += tot; - } - - if ( ( WMOPS_file = fopen( WMOPS_DATA_FILENAME, "a" ) ) != NULL ) - { +void WMOPS_output_avg (Word16 dtx_mode, Word32 * tot_wm, Word16 * num_frames) { +#if WMOPS + Word16 i; + Word32 tot, tot_wc; - printf( "opened file %s in order to print WMOPS for each function group.\n", WMOPS_DATA_FILENAME ); + /* get operations since last reset (or init), but do not update the counters (except the glob_wc[] maximum) + so output CAN be called in each frame without problems. The frame counter is NOT updated! */ + tot = WMOPS_frameStat (); + *tot_wm = (Word32) (total_wmops[currCounter] + ((float) tot) * frameRate); + *num_frames = nbframe[currCounter]; - /* Print the file header line. */ - fprintf( WMOPS_file, "Test file name\tFunction Name \tFrame\tNb Times Called\tWMOPS\t%% versus grand total" ); - - if ( nbframe[saved_value] != 0 ) - fprintf( WMOPS_file, "\tAverage" ); - - fprintf( WMOPS_file, "\tWorstCase" ); - - /* Worst worst case printed only when not in DTX mode */ - if ( dtx_mode == 0 ) - fprintf( WMOPS_file, "\tWorstWC" ); - - fprintf( WMOPS_file, "\n" ); - - /* Print the WMOPS for each Function Group by scanning all the function groups with currCounter index. */ - for ( currCounter = 0; currCounter <= maxCounter; currCounter++ ) - { - - fprintf( WMOPS_file, "%s", test_file_name ); - fprintf( WMOPS_file, "\t%s", objectName[currCounter] ? objectName[currCounter] : "" ); - fprintf( WMOPS_file, "\t%d", nbframe[currCounter] ); - - tot = WMOPS_frameStat(); - tot_wm = (Word32) ( total_wmops[currCounter] + ( (float) tot ) * frameRate ); - - fprintf( WMOPS_file, "\t\t%ld", nbTimeObjectIsCalled[currCounter] ); - fprintf( WMOPS_file, "\t%.6f", ( (float) tot ) * frameRate ); - fprintf( WMOPS_file, "\t%.3f", ( (float) tot ) / grand_total * 100 ); - - if ( nbframe[currCounter] != 0 ) - fprintf( WMOPS_file, "\t%.3f", tot_wm / (float) nbframe[currCounter] ); - - fprintf( WMOPS_file, "\t%.3f", ( (float) glob_wc[currCounter] ) * frameRate ); - - /* Worst worst case printed only when not in DTX mode */ - if ( dtx_mode == 0 ) - { - tot_wc = 0L; - for ( i = 0; i < funcid[currCounter]; i++ ) - tot_wc += wc[currCounter][i]; - fprintf( WMOPS_file, "\t%.3f", ( (float) tot_wc ) * frameRate ); - } - fprintf( WMOPS_file, "\n" ); - } - - /* Print the file Grand Total line */ - fprintf( WMOPS_file, "%s", test_file_name ); - fprintf( WMOPS_file, "\tGrand Total" ); - fprintf( WMOPS_file, "\t%d", nbframe[saved_value] ); - fprintf( WMOPS_file, "\t\t%.6f", ( (float) grand_total ) * frameRate ); - fprintf( WMOPS_file, "\t100.000" ); - fprintf( WMOPS_file, "\n" ); - fclose( WMOPS_file ); - } - else - printf( "Can not open file %s for WMOPS editing\n", WMOPS_DATA_FILENAME ); - - - if ( ( WMOPS_file = fopen( WMOPS_TOTAL_FILENAME, "a" ) ) != NULL ) - { - printf( "opened file %s in order to print application's total WMOPS.\n", WMOPS_TOTAL_FILENAME ); - fprintf( WMOPS_file, "%s", test_file_name ); - fprintf( WMOPS_file, "\tframe=%d", nbframe[currCounter] ); - fprintf( WMOPS_file, "\tWMOPS=%.6f", ( (float) grand_total ) * frameRate ); - fprintf( WMOPS_file, "\n" ); - fclose( WMOPS_file ); - } - else - printf( "Can not open file %s for WMOPS editing.\n", WMOPS_TOTAL_FILENAME ); - - - if ( ( WMOPS_file = fopen( CODE_PROFILE_FILENAME, "a" ) ) != NULL ) - { - - printf( "opened file %s in order to print basic operation distribution statistics.\n", CODE_PROFILE_FILENAME ); - - /* Print the file header line. */ - fprintf( WMOPS_file, "Test file name\tBasic Operation Name\tframe\tWMOPS\t\t%% versus grand total\n" ); - - /* Print the WMOPS for each Basic Operation across all the defined */ - /* Function Groups. */ - for ( i = 0; i < (Word16) ( sizeof( op_weight ) / sizeof( Word32 ) ); i++ ) - { - fprintf( WMOPS_file, "%-16s", test_file_name ); - fprintf( WMOPS_file, "\t%s", BasicOperationList[i] ); - fprintf( WMOPS_file, "\t%d", nbframe[0] ); - - tot = 0; - ptr = (Word32 *) &multiCounter[0] + i; - ptr2 = (const Word32 *) &op_weight + i; - for ( currCounter = 0; currCounter <= maxCounter; currCounter++ ) - { - tot += ( ( *ptr ) * ( *ptr2 ) ); - ptr += ( sizeof( op_weight ) / sizeof( Word32 ) ); - } - - fprintf( WMOPS_file, "\t%.6f", ( (float) tot ) * frameRate ); - fprintf( WMOPS_file, "\t%.3f", ( (float) tot ) / grand_total * 100 ); - fprintf( WMOPS_file, "\n" ); - } - - /* Print the file Grand Total line */ - fprintf( WMOPS_file, "%s", test_file_name ); - fprintf( WMOPS_file, "\tGrand Total" ); - fprintf( WMOPS_file, "\t%d", nbframe[saved_value] ); - fprintf( WMOPS_file, "\t%.6f", ( (float) grand_total ) * frameRate ); - fprintf( WMOPS_file, "\t100.000" ); - fprintf( WMOPS_file, "\n" ); - fclose( WMOPS_file ); - } - else - printf( "Can not open file %s for basic operations distribution statistic editing\n", CODE_PROFILE_FILENAME ); - - currCounter = saved_value; + fprintf (stdout, "%10s:WMOPS=%.3f", objectName[currCounter] ? objectName[currCounter] : "", ((float) tot) * frameRate); + if (nbframe[currCounter] != 0) { + fprintf (stdout, " Average=%.3f", *tot_wm / (float) nbframe[currCounter]); + } + fprintf (stdout, " WorstCase=%.3f", ((float) glob_wc[currCounter]) * frameRate); + + /* Worst worst case printed only when not in DTX mode */ + if (dtx_mode == 0) { + tot_wc = 0L; + for (i = 0; i < funcid[currCounter]; i++) + tot_wc += wc[currCounter][i]; + fprintf (stdout, " WorstWC=%.3f", ((float) tot_wc) * frameRate); + } + fprintf (stdout, " (%d frames)\n", nbframe[currCounter]); #else - (void) dtx_mode; - (void) test_file_name; + (void)dtx_mode; + (void)tot_wm; + (void)num_frames; #endif /* ifdef WMOPS */ } -/* FROM_EVS_DEV */ - - -/* jdr 20120117: add FLC similar functions */ -void BASOP_frame_update( void ) -{ -#ifdef WMOPS - int i, current; -#if MAX_CALLERS_SAVED_FRAMES - int k; -#endif - float total = 0.0f; - -#ifdef DEBUG - { - static int sptr_target = -2; - - if ( sptr_target == -2 ) - { - sptr_target = sptr; - } - else - { - if ( sptr_target != sptr ) - { - fprintf( stderr, "BASOP_sub_start/BASOP_sub_end imbalance detected!!!\n" ); - sptr_target = sptr; - } - } - } -#endif - - /* Get current counter */ - current = readCounterId(); - /* Update global operation counters */ - for ( i = 1; i <= maxCounter; i++ ) - { - int j; - - for ( j = 0; j < (int) ( sizeof( BASIC_OP ) / sizeof( UWord32 ) ); j++ ) - { - ( (UWord32 *) &glob_multiCounter )[j] += ( (UWord32 *) &multiCounter[i] )[j]; - } - } - -#if MAX_CALLERS_SAVED_FRAMES - /* Reset all counters */ - for ( i = 1; i <= maxCounter; i++ ) - { - callers_frames[0][i] = 0.0f; - } -#endif - /* Reset all counters */ - for ( i = 1; i <= maxCounter; i++ ) - { - if ( current != i && funcid[i] > 0 ) - { - setCounter( i ); - - glob_sum_curr[currCounter] += sum_curr[currCounter]; - - if ( glob_sum_curr[currCounter] > glob_sum_wc[currCounter] ) - { - glob_sum_wc[currCounter] = glob_sum_curr[currCounter]; - } - if ( glob_sum_curr[currCounter] < glob_sum_bc[currCounter] ) - { - glob_sum_bc[currCounter] = glob_sum_curr[currCounter]; - } -#if MAX_CALLERS_SAVED_FRAMES - /* Keep a Copy before it is Reset */ - callers_frames[0][currCounter] = (float) Reset_WMOPS_counter(); - total += callers_frames[0][currCounter]; -#else - total += (float) Reset_WMOPS_counter(); -#endif - } - } - -#if MAX_CALLERS_SAVED_FRAMES - /* Keep Callers for this Worst Case Frame */ - /* Select Slot to Use (Slot 0 is the Current) */ - k = 0; - for ( i = k + 1; i < MAX_CALLERS_SAVED_FRAMES; i++ ) - { - /* Is it the Min? */ - if ( callers_totals[i] < callers_totals[k] ) - { /* Yes */ - k = i; - } - } - /* Current Greater than the Min? */ - if ( total > callers_totals[k] ) - { - k += 1; - /* Save Info of Callers */ - for ( i = 1; i <= maxCounter; i++ ) - { - callers_frames[k][i] = callers_frames[0][i]; - } - if ( i < MAXCOUNTERS ) - callers_frames[k][i] = -1; - /* Save Total */ - callers_totals[k - 1] = total; - /* Save Frame Number */ - callers_frames_nos[k - 1] = nbframe[0]; - } -#endif - if ( total < glob_bc[0] ) - { - glob_bc[0] = (Word32) total; - } - if ( total > glob_wc[0] ) - { - glob_wc[0] = (Word32) total; - } - /* Restore current counter */ - setCounter( current ); +void generic_WMOPS_output (Word16 dtx_mode, char *test_file_name) { +#if WMOPS + int saved_value; + Word16 i; + Word32 tot, tot_wm, tot_wc, *ptr, *ptr2; + Word40 grand_total; + FILE *WMOPS_file; + + saved_value = currCounter; + + /* Count the grand_total WMOPS so that % ratio per function group can be displayed. */ + grand_total = 0; + for (currCounter = 0; currCounter <= maxCounter; currCounter++) { + tot = WMOPS_frameStat (); + grand_total += tot; + } - nbframe[0]++; -#endif /* if WMOPS */ -} -void printStack( char *text, char *Id ) -{ -#ifdef WMOPS - int i; - if ( !Id ) - return; - if ( !strcmp( "*", Id ) || ( !strcmp( Id, objectName[currCounter] ) ) ) - { - printf( "%s %s", text, objectName[currCounter] ); - for ( i = sptr - 1; i > 0; i-- ) - { - printf( " <- %s", objectName[stack[i]] ); - } - printf( "\n" ); - } -#else - printf( "%s %s\n", text, Id ? Id : "(no name)" ); -#endif -} + if ((WMOPS_file = fopen (WMOPS_DATA_FILENAME, "a")) != NULL) { -#ifdef WMOPS -void BASOP_push_wmops( const char *label ) -{ - int new_flag, prev_counter; - int i, j; - - /* Check if new counter label */ - new_flag = 1; - for ( i = 1; i <= maxCounter; i++ ) - { - if ( strcmp( objectName[i], label ) == 0 ) - { - new_flag = 0; - break; - } - } - - prev_counter = readCounterId(); + printf ("opened file %s in order to print WMOPS for each function group.\n", WMOPS_DATA_FILENAME); - /* Configure new record */ - if ( new_flag ) - { - i = (int) getCounterId( label ); - setCounter( i ); - Init_WMOPS_counter(); - } - else - { - setCounter( i ); - } + /* Print the file header line. */ + fprintf (WMOPS_file, "Test file name\tFunction Name \tFrame\tNb Times Called\tWMOPS\t%% versus grand total"); + if (nbframe[saved_value] != 0) + fprintf (WMOPS_file, "\tAverage"); - /* Push current context onto stack */ - if ( currCounter >= 0 ) - { - if ( sptr >= MAX_STACK ) - { - fprintf( stderr, "\r push_wmops(): stack exceeded, try inreasing MAX_STACK\n" ); - exit( -1 ); - } - stack[sptr++] = prev_counter; - - /* Reset accumulated WMOPS */ - sum_stack[sptr] = 0; - - /* update call tree */ - for ( j = 0; j < MAXCOUNTERS; j++ ) - { - if ( call_tree[i][j] == prev_counter ) - { - break; - } - else if ( call_tree[i][j] == -1 ) - { - call_tree[i][j] = (Word16) prev_counter; - break; - } - } - } + fprintf (WMOPS_file, "\tWorstCase"); - /*wmops[currCounter].start_selfcnt = ops_cnt; - wmops[currCounter].start_cnt = ops_cnt; - nbTimeObjectIsCalled[currCounter]++;*/ + /* Worst worst case printed only when not in DTX mode */ + if (dtx_mode == 0) + fprintf (WMOPS_file, "\tWorstWC"); - incrementNbTimeObjectIsCalled( currCounter ); + fprintf (WMOPS_file, "\n"); - sum_curr[currCounter] = 0; + /* Print the WMOPS for each Function Group by scanning all the function groups with currCounter index. */ + for (currCounter = 0; currCounter <= maxCounter; currCounter++) { -#ifdef DEBUG_COUNTER - printf( "Entering: %s\n", readCounterIdName() ); -#endif -} -#endif + fprintf (WMOPS_file, "%s", test_file_name); + fprintf (WMOPS_file, "\t%s", objectName[currCounter] ? objectName[currCounter] : ""); + fprintf (WMOPS_file, "\t%d", nbframe[currCounter]); -Word32 BASOP_pop_wmops( void ) -{ -#ifdef WMOPS - Word32 ops_cnt; + tot = WMOPS_frameStat (); + tot_wm = (Word32) (total_wmops[currCounter] + ((float) tot) * frameRate); -#ifdef DEBUG_COUNTER - printf( "Exiting: %s\n", readCounterIdName() ); -#endif + fprintf (WMOPS_file, "\t\t%ld", nbTimeObjectIsCalled[currCounter]); + fprintf (WMOPS_file, "\t%.6f", ((float) tot) * frameRate); + fprintf (WMOPS_file, "\t%.3f", ((float) tot) / grand_total * 100); - ops_cnt = fwc(); + if (nbframe[currCounter] != 0) + fprintf (WMOPS_file, "\t%.3f", tot_wm / (float) nbframe[currCounter]); - /* Get back previous context from stack */ - if ( sptr > 0 ) - { - int prevCounter; + fprintf (WMOPS_file, "\t%.3f", ((float) glob_wc[currCounter]) * frameRate); - sum_stack[sptr] += ops_cnt; - prevCounter = currCounter; - setCounter( stack[--sptr] ); - sum_stack[sptr] += sum_stack[sptr + 1]; - sum_curr[prevCounter] += sum_stack[sptr + 1]; - } - else - { - /* current_record = -1; */ - setCounter( 0 ); - } + /* Worst worst case printed only when not in DTX mode */ + if (dtx_mode == 0) { + tot_wc = 0L; + for (i = 0; i < funcid[currCounter]; i++) + tot_wc += wc[currCounter][i]; + fprintf (WMOPS_file, "\t%.3f", ((float) tot_wc) * frameRate); + } + fprintf (WMOPS_file, "\n"); - if ( sum_curr[currCounter] > sum_wc[currCounter] ) - { - sum_wc[currCounter] = sum_curr[currCounter]; - } - if ( sum_curr[currCounter] < sum_bc[currCounter] ) - { - sum_bc[currCounter] = sum_curr[currCounter]; } - return ops_cnt; -#else /* if WMOPS */ - return 0; -#endif /* if WMOPS */ -} + /* Print the file Grand Total line */ + fprintf (WMOPS_file, "%s", test_file_name); + fprintf (WMOPS_file, "\tGrand Total"); + fprintf (WMOPS_file, "\t%d", nbframe[saved_value]); + fprintf (WMOPS_file, "\t\t%.6f", ((float) grand_total) * frameRate); + fprintf (WMOPS_file, "\t100.000"); + fprintf (WMOPS_file, "\n"); + fclose (WMOPS_file); -Word32 BASOP_get_wops( void ) -{ - return BASOP_pop_wmops(); -} + } else + printf ("Can not open file %s for WMOPS editing\n", WMOPS_DATA_FILENAME); -void WMOPS_destroy( void ) -{ -#ifdef WMOPS - int i; - - /* release the memory allocated for the objectName array */ - for ( i = 0; i < MAXCOUNTERS + 1; i++ ) - { - if ( NULL != objectName[i] ) - { - free( objectName[i] ); - objectName[i] = NULL; - } - } + if ((WMOPS_file = fopen (WMOPS_TOTAL_FILENAME, "a")) != NULL) { + printf ("opened file %s in order to print application's total WMOPS.\n", WMOPS_TOTAL_FILENAME); + fprintf (WMOPS_file, "%s", test_file_name); + fprintf (WMOPS_file, "\tframe=%d", nbframe[currCounter]); + fprintf (WMOPS_file, "\tWMOPS=%.6f", ((float) grand_total) * frameRate); + fprintf (WMOPS_file, "\n"); + fclose (WMOPS_file); - maxCounter = 0; -#endif + } else + printf ("Can not open file %s for WMOPS editing.\n", WMOPS_TOTAL_FILENAME); - return; -} + if ((WMOPS_file = fopen (CODE_PROFILE_FILENAME, "a")) != NULL) { -void WMOPS_output_all( Word16 dtx_mode ) -{ -#ifdef WMOPS - float ops_cnt = 0.0f; - int i; - - char *sfmts = "%-40s %8s %8s %7s %7s\n"; - char *dfmts = "%-40s %8.2f %8.3f %7.3f %7.3f\n"; - char *sfmt = "%-40s %8s %8s %7s %7s %7s %7s %7s\n"; - char *dfmt = "%-40s %8.2f %8.3f %7.3f %7.3f %7.3f %7.3f %7.3f\n"; - - /*fprintf (stderr, "\nInstruction Type Analysis (for worst case frame):\n\n");*/ - fprintf( stderr, "\nInstruction Type Analysis (for worst case frame number %ld):\n\n", (long int) nbframe[0] ); /* added -- JPA */ - for ( i = 0; i < (int) ( sizeof( BasicOperationList ) / sizeof( char * ) ); i++ ) - { - if ( ( (UWord32 *) &glob_multiCounter )[i] > 0 ) - fprintf( stderr, "\t%16s: %12d\n", BasicOperationList[i], ( (UWord32 *) &glob_multiCounter )[i] ); - } + printf ("opened file %s in order to print basic operation distribution statistics.\n", CODE_PROFILE_FILENAME); - fprintf( stderr, "\n\nWeighted MOPS Analysis:\n" ); - fprintf( stderr, "%74s %23s\n", "|------ SELF ------|", "|--- CUMULATIVE ---|" ); - fprintf( stderr, sfmt, " routine", " calls", " min ", " max ", " avg ", " min ", " max ", " avg " ); - fprintf( stderr, sfmt, " ------------------------", " ------", "------", "------", "------", "------", "------", "------" ); - for ( i = 1; i <= maxCounter; i++ ) - { - if ( nbcalls[i] > 0 ) - { - fprintf( stderr, dfmt, - objectName[i], - ( nbframe[i] == 0 ) ? 0 : (float) nbcalls[i] / (float) nbframe[0], - ( glob_bc[i] == 0 ) ? 0 : frameRate * (float) glob_bc[i], - ( glob_wc[i] == 0 ) ? 0 : frameRate * (float) glob_wc[i], - ( nbframe[i] == 0 ) ? 0 : (float) total_wmops[i] / (float) nbframe[i], - frameRate * ( glob_sum_bc[i] ), - frameRate * ( glob_sum_wc[i] ), - ( nbframe[i] == 0 ) ? 0 : (float) ( total_sum[i] / (float) nbframe[i] ) ); - /* frameRate*(glob_bc[i]+wmops_children_bc[i]), */ - /* frameRate*(glob_wc[i]+wmops_children_wc[i]), */ - /* (nbframe[i] == 0) ? 0 : (float)((total_wmops[i] + total_wmops_children[i]) /(float)nbframe[i])); */ - } - ops_cnt += total_wmops[i]; - } + /* Print the file header line. */ + fprintf (WMOPS_file, "Test file name\tBasic Operation Name\tframe\tWMOPS\t\t%% versus grand total\n"); - fprintf( stderr, sfmts, " -----------------", " ------", "------", "------", "------" ); - if ( nbframe[i] > 0 ) - { - fprintf( stderr, dfmts, - "total", - (double) nbframe[0], - frameRate * glob_bc[0], - frameRate * glob_wc[0], - ( nbframe[0] == 0 ) ? 0 : ops_cnt / nbframe[0] ); - } -#if 0 - { - char *sfmtt = "%20s %4s %15s\n"; - char *dfmtt = "%20s %4d "; - - fprintf (stderr, "\nCall Tree:\n\n"); - fprintf (stderr, sfmtt, " function", "num", "called by: "); - fprintf (stderr, sfmtt, "---------------", "---", "--------------"); - - for (i = 1; i <= maxCounter; i++) - { - int j; - - fprintf (stderr, dfmtt, objectName[i], i); - for (j = 0; call_tree[i][j] != -1; j++) - { - if (j != 0) - { - fprintf (stderr, ", "); - } - fprintf (stderr, "%s", objectName[call_tree[i][j]]); - } - fprintf (stderr, "\n"); + /* Print the WMOPS for each Basic Operation across all the defined */ + /* Function Groups. */ + for (i = 0; i < (Word16)(sizeof (op_weight) / sizeof (Word32)); i++) { + fprintf (WMOPS_file, "%-16s", test_file_name); + fprintf (WMOPS_file, "\t%s", BasicOperationList[i]); + fprintf (WMOPS_file, "\t%d", nbframe[0]); + tot = 0; + ptr = (Word32 *) & multiCounter[0] + i; + ptr2 = (Word32 *) & op_weight + i; + for (currCounter = 0; currCounter <= maxCounter; currCounter++) { + tot += ((*ptr) * (*ptr2)); + ptr += (sizeof (op_weight) / sizeof (Word32)); } - fprintf (stderr, sfmtt, "---------------", "---", "--------------"); - fprintf (stderr, "\n\n"); - } -#endif - -#if 0 - fprintf (stderr, "\n\n"); - for (i=1; i<=maxCounter; i++) - { - setCounter(i); - WMOPS_output(dtx_mode); - } -#else - (void) dtx_mode; -#endif - -#if MAX_CALLERS_SAVED_FRAMES - for ( i = 1; i <= MAX_CALLERS_SAVED_FRAMES; i++ ) - { - int j, k, l, m; - const char *frame_rank[] = { "st", "nd", "rd", "th" }; - float current; - - k = 0; - for ( j = k + 1; j < MAX_CALLERS_SAVED_FRAMES; j++ ) - { - /* Is it the Max? */ - if ( callers_totals[j] > callers_totals[k] ) - { /* Yes */ - k = j; - } - } - k += 1; - - fprintf( stderr, "\nActive Callers Report for %i%s Worst Case Frame #: %i\n", - i, i <= 3 ? frame_rank[i - 1] : frame_rank[3], - callers_frames_nos[k - 1] ); - /* Print up to 'MAX_CALLERS_PRINT' Callers */ - current = 0.0f; - for ( l = 0; l < MAX_CALLERS_PRINT; l++ ) - { - /* Find Highest Complexity */ - m = 1; - for ( j = m + 1; j <= maxCounter; j++ ) - { - if ( callers_frames[k][j] < 0 ) - break; - if ( callers_frames[k][j] > callers_frames[k][m] ) - m = j; - } - /* Done ? */ - if ( callers_frames[k][m] == 0 ) - break; - fprintf( stderr, " %-52s %10.3f\n", objectName[m], callers_frames[k][m] * frameRate ); - /* Count it */ - current += callers_frames[k][m]; - /* Mark as Done */ - callers_frames[k][m] = 0.0f; - } - /* Check if All Printed */ - if ( current + 0.001f < callers_totals[k - 1] ) - { - fprintf( stderr, " Only first %i Callers have been Printed!\n", MAX_CALLERS_PRINT ); - fprintf( stderr, " %-52s %10.3f\n", "Total for non Printed", ( callers_totals[k - 1] - current ) * frameRate ); - } - fprintf( stderr, " %-52s %10.3f\n", "Total", callers_totals[k - 1] * frameRate ); - /* Mark as Done */ - callers_totals[k - 1] = 0.0f; - } -#endif - WMOPS_destroy(); -#else - UNUSED_PARAM( dtx_mode ); -#endif /* if WMOPS */ -} -void WMOPS_output_all_std( Word16 dtx_mode ) -{ -#ifdef WMOPS - float ops_cnt = 0.0f; - int i; - - char *sfmts = "%-40s %8s %8s %7s %7s\n"; - char *dfmts = "%-40s %8.2f %8.3f %7.3f %7.3f\n"; - char *sfmt = "%-40s %8s %8s %7s %7s %7s %7s %7s\n"; - char *dfmt = "%-40s %8.2f %8.3f %7.3f %7.3f %7.3f %7.3f %7.3f\n"; - - /*fprintf (stdout, "\nInstruction Type Analysis (for worst case frame):\n\n");*/ - fprintf( stdout, "\nInstruction Type Analysis (for worst case frame number %ld):\n\n", (long int) nbframe[0] ); /* added -- JPA */ - if ( nbframe[0] > 0 ) - { - for ( i = 0; i < (int) ( sizeof( BasicOperationList ) / sizeof( char * ) ); i++ ) - { - if ( ( (UWord32 *) &glob_multiCounter )[i] > 0 ) - fprintf( stdout, "\t%16s: %12d\n", BasicOperationList[i], ( (UWord32 *) &glob_multiCounter )[i] ); - } - } - fprintf( stdout, "\n\nWeighted MOPS Analysis:\n" ); - fprintf( stdout, "%74s %23s\n", "|------ SELF ------|", "|--- CUMULATIVE ---|" ); - fprintf( stdout, sfmt, " routine", "calls/fr", " min ", " max ", " avg ", " min ", " max ", " avg " ); - fprintf( stdout, sfmt, " ------------------------", " ------", "------", "------", "------", "------", "------", "------" ); - for ( i = 1; i <= maxCounter; i++ ) - { - fprintf( stdout, dfmt, - objectName[i], - ( nbframe[i] == 0 ) ? 0 : (float) nbcalls[i] / (float) nbframe[0], - ( glob_bc[i] == MAX_32 ) ? 0 : frameRate * (float) glob_bc[i], - ( glob_wc[i] == 0 ) ? 0 : frameRate * (float) glob_wc[i], - ( nbframe[i] == 0 ) ? 0 : (float) total_wmops[i] / (float) nbframe[i], - frameRate * ( glob_sum_bc[i] ), - frameRate * ( glob_sum_wc[i] ), - ( nbframe[i] == 0 ) ? 0 : (float) ( ( total_sum[i] ) / (float) nbframe[i] ) ); - /* frameRate*(glob_bc[i]+wmops_children_bc[i]), */ - /* frameRate*(glob_wc[i]+wmops_children_wc[i]), */ - /* (nbframe[i] == 0) ? 0 : (float)((total_sum[i]) /(float)nbframe[i])); */ - ops_cnt += total_wmops[i]; - } - fprintf( stdout, sfmts, " -----------------", " ------", "------", "------", "------" ); - if ( nbframe[0] > 0 ) - { - fprintf( stdout, dfmts, - "total", - (double) nbframe[0], - frameRate * glob_bc[0], - frameRate * glob_wc[0], - ( nbframe[0] == 0 ) ? 0 : ops_cnt / nbframe[0] ); + fprintf (WMOPS_file, "\t%.6f", ((float) tot) * frameRate); + fprintf (WMOPS_file, "\t%.3f", ((float) tot) / grand_total * 100); + fprintf (WMOPS_file, "\n"); } -#if 0 - { - char *sfmtt = "%20s %4s %15s\n"; - char *dfmtt = "%20s %4d "; - - fprintf (stdout, "\nCall Tree:\n\n"); - fprintf (stdout, sfmtt, " function", "num", "called by: "); - fprintf (stdout, sfmtt, "---------------", "---", "--------------"); - - for (i = 1; i <= maxCounter; i++) - { - int j; - - fprintf (stdout, dfmtt, objectName[i], i); - for (j = 0; call_tree[i][j] != -1; j++) - { - if (j != 0) - { - fprintf (stdout, ", "); - } - fprintf (stdout, "%s", objectName[call_tree[i][j]]); - } - fprintf (stdout, "\n"); - } - fprintf (stdout, sfmtt, "---------------", "---", "--------------"); - fprintf (stdout, "\n\n"); - } -#endif - -#if 0 - fprintf (stdout, "\n\n"); - for (i=1; i<=maxCounter; i++) - { - setCounter(i); - WMOPS_output(dtx_mode); - } -#else - (void) dtx_mode; -#endif + /* Print the file Grand Total line */ + fprintf (WMOPS_file, "%s", test_file_name); + fprintf (WMOPS_file, "\tGrand Total"); + fprintf (WMOPS_file, "\t%d", nbframe[saved_value]); + fprintf (WMOPS_file, "\t%.6f", ((float) grand_total) * frameRate); + fprintf (WMOPS_file, "\t100.000"); + fprintf (WMOPS_file, "\n"); + fclose (WMOPS_file); + } else + printf ("Can not open file %s for basic operations distribution statistic editing\n", CODE_PROFILE_FILENAME); - WMOPS_destroy(); + currCounter = saved_value; #else - UNUSED_PARAM( dtx_mode ); -#endif /* if WMOPS */ + (void)dtx_mode; + (void)test_file_name; +#endif /* ifdef WMOPS */ } -void Reset_all_WMOPS_counter( void ) -{ -#ifdef WMOPS - int i; - int currCounterSave; - - currCounterSave = currCounter; - - for ( i = 2; i <= maxCounter; i++ ) - { - setCounter( i ); - Init_WMOPS_counter(); - objectName[i] = 0; - } - - currCounter = currCounterSave; - maxCounter = 1; -#endif /* if WMOPS */ -} - -/* Returns the total min/max/avg WMOPS values like printed in BASOP_end(). */ -void BASOP_get_total_wmops( double *min, double *max, double *avg ) -{ -#ifdef WMOPS - if ( min != NULL ) - *min = frameRate * glob_bc[0]; - if ( max != NULL ) - *max = frameRate * glob_wc[0]; - if ( avg != NULL ) - { - int i; - double ops_cnt = 0; - for ( i = 1; i <= maxCounter; i++ ) - ops_cnt += total_wmops[i]; - *avg = ( nbframe[0] == 0 ) ? 0 : ops_cnt / nbframe[0]; - } -#else - UNUSED_PARAM( min ); - UNUSED_PARAM( max ); - UNUSED_PARAM( avg ); -#endif /* if WMOPS */ -} +/* end of file */ diff --git a/basic_op/count.h b/basic_op/count.h index 10e96e44fad77b519fa544389b64623cad14b4be..e173de624f8db442f68d729c1db3713e591f471b 100644 --- a/basic_op/count.h +++ b/basic_op/count.h @@ -54,19 +54,29 @@ * In the end of this file, there is a piece of code illustrating how the * functions can be used. * - ******************************************************************************/ +******************************************************************************/ #ifndef _COUNT_H #define _COUNT_H "$Id$" +#if 0 +#define WMOPS 1 /* enable WMOPS profiling features */ +#undef WMOPS /* disable WMOPS profiling features */ +#endif +#define MAXCOUNTERS (256) -#include - - -#define MAXCOUNTERS ( 512 ) -#define MAX_CALLERS_SAVED_FRAMES 5 /* # of Frame for which WMOPS Complexity Details will be saved, 0 = Disabled */ -int getCounterId( const char *objectName ); +#define BASOP_sub_start(label) +#define BASOP_sub_end() +#define SUB_WMOPS_INIT(label) BASOP_sub_start(label) +#define END_SUB_WMOPS BASOP_sub_end() +#define BASOP_push_wmops(label) +#define BASOP_pop_wmops() +#define BASOP_end_noprint +#define BASOP_end +#define BASOP_init + +int getCounterId (char *objectName); /* * Create a counter group, the "objectname" will be used when printing * statistics for this counter group. @@ -75,32 +85,25 @@ int getCounterId( const char *objectName ); */ -int readCounterId( void ); +int readCounterId (void); /* * Returns the current CounterId. */ -void setCounter( int counterId ); +void setCounter (int counterId); /* * Defines which counter group to use, default is zero. */ -char *readCounterIdName( void ); +char *readCounterIdName (void); /* * Returns the current CounterId name. */ -void printStack( char *text, char *Id ); -/* - * print stack - * text: Any text to print initially - * Id: NULL, if no prints are wanted - * "*", if all prints are wanted (default) - * "pitch_ol" or any other function name - */ -void incrementNbTimeObjectIsCalled( int counterId ); + +void incrementNbTimeObjectIsCalled (int counterId); /* * This function enables to increment by 1 a counter * tracking the number of times the application enters a groups of functions. @@ -110,26 +113,26 @@ void incrementNbTimeObjectIsCalled( int counterId ); */ -void ClearNbTimeObjectsAreCalled( void ); +void ClearNbTimeObjectsAreCalled (void); /* * This function enables to clear to 0 all the counters enabling to * track the number of times the application enters any groups of functions. */ -void Init_WMOPS_counter( void ); +void Init_WMOPS_counter (void); /* * Initiates the current counter group. */ -Word32 Reset_WMOPS_counter( void ); +void Reset_WMOPS_counter (void); /* * Resets the current counter group. */ -void WMOPS_output( Word16 notPrintWorstWorstCase ); +void WMOPS_output (Word16 notPrintWorstWorstCase); /* * Prints the statistics to the screen, if the argument is non zero * the statistics for worst worst case will not be printed. This is typically @@ -137,7 +140,7 @@ void WMOPS_output( Word16 notPrintWorstWorstCase ); * */ -void WMOPS_output_avg( Word16 dtx_mode, Word32 *tot_wm, Word32 *num_frames ); +void WMOPS_output_avg (Word16 dtx_mode, Word32 * tot_wm, Word16 * num_frames); /* * same as WMOPS_output + returns the total wmops counter and the number of frames * to support the computation of global average. @@ -145,7 +148,7 @@ void WMOPS_output_avg( Word16 dtx_mode, Word32 *tot_wm, Word32 *num_frames ); */ -Word32 fwc( void ); +Word32 fwc (void); /* * worst worst case counter. * @@ -157,7 +160,7 @@ Word32 fwc( void ); * The WMOPS_output function add together all parts and presents the sum. */ -void setFrameRate( int samplingFreq, int frameLength ); +void setFrameRate (int samplingFreq, int frameLength); /* * This function can overwrite the value of the frameRate variable that is * initialized by the FRAME_RATE constant. @@ -169,7 +172,7 @@ void setFrameRate( int samplingFreq, int frameLength ); * WMOPS_DATA_FILENAME is the macro defining the name of the file * where the Weighted Million of Operations per Second (wMOPS) * are appended, function group by function group. - */ +*/ #define CODE_PROFILE_FILENAME "code_profile.txt" @@ -177,7 +180,7 @@ void setFrameRate( int samplingFreq, int frameLength ); * CODE_PROFILE_FILENAME is the macro defining the name of the file * where the Weighted Million of Operations per Second (WMOPS) * are appended, basic operation by basic operation. - */ +*/ #define WMOPS_TOTAL_FILENAME "wmops_total.txt" @@ -185,281 +188,280 @@ void setFrameRate( int samplingFreq, int frameLength ); * WMOPS_TOTAL_FILENAME is the macro defining the name of the file * where the Weighted Million of Operations per Second (WMOPS) * are printed, globally for the application. - */ +*/ -#define FRAME_RATE ( 0.0001F ) /* in this version frame_rate can be overwriten online by the new setFrameRate function */ +#define FRAME_RATE (0.0001F) /* in this version frame_rate can be overwriten online by the new setFrameRate function */ /* FRAME_RATE of 0.000025 is corresponding to 40ms frame.*/ /* FRAME_RATE of 0.00005 is corresponding to 20ms frame.*/ /* FRAME_RATE of 0.0001 is corresponding to 10ms frame.*/ /* * FRAME_RATE is the macro defining the calling rate of the * application to benchmark. - */ +*/ /* Global counter variable for calculation of complexity weight */ -typedef struct -{ - UWord32 add; /* Complexity Weight of 1 */ - UWord32 sub; /* Complexity Weight of 1 */ - UWord32 abs_s; /* Complexity Weight of 1 */ - UWord32 shl; /* Complexity Weight of 1 */ - UWord32 shr; /* Complexity Weight of 1 */ - - UWord32 extract_h; /* Complexity Weight of 1 */ - UWord32 extract_l; /* Complexity Weight of 1 */ - UWord32 mult; /* Complexity Weight of 1 */ - UWord32 L_mult; /* Complexity Weight of 1 */ - UWord32 negate; /* Complexity Weight of 1 */ - - UWord32 round; /* Complexity Weight of 1 */ - UWord32 L_mac; /* Complexity Weight of 1 */ - UWord32 L_msu; /* Complexity Weight of 1 */ - UWord32 L_macNs; /* Complexity Weight of 1 */ - UWord32 L_msuNs; /* Complexity Weight of 1 */ - - UWord32 L_add; /* Complexity Weight of 1 */ - UWord32 L_sub; /* Complexity Weight of 1 */ - UWord32 L_add_c; /* Complexity Weight of 2 */ - UWord32 L_sub_c; /* Complexity Weight of 2 */ - UWord32 L_negate; /* Complexity Weight of 1 */ - - UWord32 L_shl; /* Complexity Weight of 1 */ - UWord32 L_shr; /* Complexity Weight of 1 */ - UWord32 mult_r; /* Complexity Weight of 1 */ - UWord32 shr_r; /* Complexity Weight of 3 */ - UWord32 mac_r; /* Complexity Weight of 1 */ - - UWord32 msu_r; /* Complexity Weight of 1 */ - UWord32 L_deposit_h; /* Complexity Weight of 1 */ - UWord32 L_deposit_l; /* Complexity Weight of 1 */ - UWord32 L_shr_r; /* Complexity Weight of 3 */ - UWord32 L_abs; /* Complexity Weight of 1 */ - - UWord32 L_sat; /* Complexity Weight of 4 */ - UWord32 norm_s; /* Complexity Weight of 1 */ - UWord32 div_s; /* Complexity Weight of 18 */ - UWord32 norm_l; /* Complexity Weight of 1 */ - UWord32 move16; /* Complexity Weight of 1 */ - - UWord32 move32; /* Complexity Weight of 2 */ - UWord32 Logic16; /* Complexity Weight of 1 */ - UWord32 Logic32; /* Complexity Weight of 2 */ - UWord32 Test; /* Complexity Weight of 2 */ - UWord32 s_max; /* Complexity Weight of 1 */ - - UWord32 s_min; /* Complexity Weight of 1 */ - UWord32 L_max; /* Complexity Weight of 1 */ - UWord32 L_min; /* Complexity Weight of 1 */ - UWord32 L40_max; /* Complexity Weight of 1 */ - UWord32 L40_min; /* Complexity Weight of 1 */ - - UWord32 shl_r; /* Complexity Weight of 2 */ - UWord32 L_shl_r; /* Complexity Weight of 2 */ - UWord32 L40_shr_r; /* Complexity Weight of 2 */ - UWord32 L40_shl_r; /* Complexity Weight of 2 */ - UWord32 norm_L40; /* Complexity Weight of 1 */ - - UWord32 L40_shl; /* Complexity Weight of 1 */ - UWord32 L40_shr; /* Complexity Weight of 1 */ - UWord32 L40_negate; /* Complexity Weight of 1 */ - UWord32 L40_add; /* Complexity Weight of 1 */ - UWord32 L40_sub; /* Complexity Weight of 1 */ - - UWord32 L40_abs; /* Complexity Weight of 1 */ - UWord32 L40_mult; /* Complexity Weight of 1 */ - UWord32 L40_mac; /* Complexity Weight of 1 */ - UWord32 mac_r40; /* Complexity Weight of 2 */ - - UWord32 L40_msu; /* Complexity Weight of 1 */ - UWord32 msu_r40; /* Complexity Weight of 2 */ - UWord32 Mpy_32_16_ss; /* Complexity Weight of 2 */ - UWord32 Mpy_32_32_ss; /* Complexity Weight of 2 */ - UWord32 L_mult0; /* Complexity Weight of 1 */ - - UWord32 L_mac0; /* Complexity Weight of 1 */ - UWord32 L_msu0; /* Complexity Weight of 1 */ - UWord32 lshl; /* Complexity Weight of 1 */ - UWord32 lshr; /* Complexity Weight of 1 */ - UWord32 L_lshl; /* Complexity Weight of 1 */ - - UWord32 L_lshr; /* Complexity Weight of 1 */ - UWord32 L40_lshl; /* Complexity Weight of 1 */ - UWord32 L40_lshr; /* Complexity Weight of 1 */ - UWord32 s_and; /* Complexity Weight of 1 */ - UWord32 s_or; /* Complexity Weight of 1 */ - - UWord32 s_xor; /* Complexity Weight of 1 */ - UWord32 L_and; /* Complexity Weight of 1 */ - UWord32 L_or; /* Complexity Weight of 1 */ - UWord32 L_xor; /* Complexity Weight of 1 */ - UWord32 rotl; /* Complexity Weight of 3 */ - - UWord32 rotr; /* Complexity Weight of 3 */ - UWord32 L_rotl; /* Complexity Weight of 3 */ - UWord32 L_rotr; /* Complexity Weight of 3 */ - UWord32 L40_set; /* Complexity Weight of 1 */ - UWord32 L40_deposit_h; /* Complexity Weight of 1 */ - - UWord32 L40_deposit_l; /* Complexity Weight of 1 */ - UWord32 L40_deposit32; /* Complexity Weight of 1 */ - UWord32 Extract40_H; /* Complexity Weight of 1 */ - UWord32 Extract40_L; /* Complexity Weight of 1 */ - UWord32 L_Extract40; /* Complexity Weight of 1 */ - - UWord32 L40_round; /* Complexity Weight of 1 */ - UWord32 L_saturate40; /* Complexity Weight of 1 */ - UWord32 round40; /* Complexity Weight of 1 */ - UWord32 If; /* Complexity Weight of 3 */ - UWord32 Goto; /* Complexity Weight of 2 */ - - UWord32 Break; /* Complexity Weight of 2 */ - UWord32 Switch; /* Complexity Weight of 6 */ - UWord32 For; /* Complexity Weight of 3 */ - UWord32 While; /* Complexity Weight of 3 */ - UWord32 Continue; /* Complexity Weight of 2 */ - - UWord32 L_mls; /* Complexity Weight of 1 */ - UWord32 div_l; /* Complexity Weight of 32 */ - UWord32 i_mult; /* Complexity Weight of 1 */ +typedef struct { + UWord32 add; /* Complexity Weight of 1 */ + UWord32 sub; /* Complexity Weight of 1 */ + UWord32 abs_s; /* Complexity Weight of 1 */ + UWord32 shl; /* Complexity Weight of 1 */ + UWord32 shr; /* Complexity Weight of 1 */ + + UWord32 extract_h; /* Complexity Weight of 1 */ + UWord32 extract_l; /* Complexity Weight of 1 */ + UWord32 mult; /* Complexity Weight of 1 */ + UWord32 L_mult; /* Complexity Weight of 1 */ + UWord32 negate; /* Complexity Weight of 1 */ + + UWord32 round; /* Complexity Weight of 1 */ + UWord32 L_mac; /* Complexity Weight of 1 */ + UWord32 L_msu; /* Complexity Weight of 1 */ + UWord32 L_macNs; /* Complexity Weight of 1 */ + UWord32 L_msuNs; /* Complexity Weight of 1 */ + + UWord32 L_add; /* Complexity Weight of 1 */ + UWord32 L_sub; /* Complexity Weight of 1 */ + UWord32 L_add_c; /* Complexity Weight of 2 */ + UWord32 L_sub_c; /* Complexity Weight of 2 */ + UWord32 L_negate; /* Complexity Weight of 1 */ + + UWord32 L_shl; /* Complexity Weight of 1 */ + UWord32 L_shr; /* Complexity Weight of 1 */ + UWord32 mult_r; /* Complexity Weight of 1 */ + UWord32 shr_r; /* Complexity Weight of 3 */ + UWord32 mac_r; /* Complexity Weight of 1 */ + + UWord32 msu_r; /* Complexity Weight of 1 */ + UWord32 L_deposit_h; /* Complexity Weight of 1 */ + UWord32 L_deposit_l; /* Complexity Weight of 1 */ + UWord32 L_shr_r; /* Complexity Weight of 3 */ + UWord32 L_abs; /* Complexity Weight of 1 */ + + UWord32 L_sat; /* Complexity Weight of 4 */ + UWord32 norm_s; /* Complexity Weight of 1 */ + UWord32 div_s; /* Complexity Weight of 18 */ + UWord32 norm_l; /* Complexity Weight of 1 */ + UWord32 move16; /* Complexity Weight of 1 */ + + UWord32 move32; /* Complexity Weight of 2 */ + UWord32 Logic16; /* Complexity Weight of 1 */ + UWord32 Logic32; /* Complexity Weight of 2 */ + UWord32 Test; /* Complexity Weight of 2 */ + UWord32 s_max; /* Complexity Weight of 1 */ + + UWord32 s_min; /* Complexity Weight of 1 */ + UWord32 L_max; /* Complexity Weight of 1 */ + UWord32 L_min; /* Complexity Weight of 1 */ + UWord32 L40_max; /* Complexity Weight of 1 */ + UWord32 L40_min; /* Complexity Weight of 1 */ + + UWord32 shl_r; /* Complexity Weight of 2 */ + UWord32 L_shl_r; /* Complexity Weight of 2 */ + UWord32 L40_shr_r; /* Complexity Weight of 2 */ + UWord32 L40_shl_r; /* Complexity Weight of 2 */ + UWord32 norm_L40; /* Complexity Weight of 1 */ + + UWord32 L40_shl; /* Complexity Weight of 1 */ + UWord32 L40_shr; /* Complexity Weight of 1 */ + UWord32 L40_negate; /* Complexity Weight of 1 */ + UWord32 L40_add; /* Complexity Weight of 1 */ + UWord32 L40_sub; /* Complexity Weight of 1 */ + + UWord32 L40_abs; /* Complexity Weight of 1 */ + UWord32 L40_mult; /* Complexity Weight of 1 */ + UWord32 L40_mac; /* Complexity Weight of 1 */ + UWord32 mac_r40; /* Complexity Weight of 2 */ + + UWord32 L40_msu; /* Complexity Weight of 1 */ + UWord32 msu_r40; /* Complexity Weight of 2 */ + UWord32 Mpy_32_16_ss; /* Complexity Weight of 2 */ + UWord32 Mpy_32_32_ss; /* Complexity Weight of 2 */ + UWord32 L_mult0; /* Complexity Weight of 1 */ + + UWord32 L_mac0; /* Complexity Weight of 1 */ + UWord32 L_msu0; /* Complexity Weight of 1 */ + UWord32 lshl; /* Complexity Weight of 1 */ + UWord32 lshr; /* Complexity Weight of 1 */ + UWord32 L_lshl; /* Complexity Weight of 1 */ + + UWord32 L_lshr; /* Complexity Weight of 1 */ + UWord32 L40_lshl; /* Complexity Weight of 1 */ + UWord32 L40_lshr; /* Complexity Weight of 1 */ + UWord32 s_and; /* Complexity Weight of 1 */ + UWord32 s_or; /* Complexity Weight of 1 */ + + UWord32 s_xor; /* Complexity Weight of 1 */ + UWord32 L_and; /* Complexity Weight of 1 */ + UWord32 L_or; /* Complexity Weight of 1 */ + UWord32 L_xor; /* Complexity Weight of 1 */ + UWord32 rotl; /* Complexity Weight of 3 */ + + UWord32 rotr; /* Complexity Weight of 3 */ + UWord32 L_rotl; /* Complexity Weight of 3 */ + UWord32 L_rotr; /* Complexity Weight of 3 */ + UWord32 L40_set; /* Complexity Weight of 1 */ + UWord32 L40_deposit_h; /* Complexity Weight of 1 */ + + UWord32 L40_deposit_l; /* Complexity Weight of 1 */ + UWord32 L40_deposit32; /* Complexity Weight of 1 */ + UWord32 Extract40_H; /* Complexity Weight of 1 */ + UWord32 Extract40_L; /* Complexity Weight of 1 */ + UWord32 L_Extract40; /* Complexity Weight of 1 */ + + UWord32 L40_round; /* Complexity Weight of 1 */ + UWord32 L_saturate40; /* Complexity Weight of 1 */ + UWord32 round40; /* Complexity Weight of 1 */ + UWord32 If; /* Complexity Weight of 3 */ + UWord32 Goto; /* Complexity Weight of 2 */ + + UWord32 Break; /* Complexity Weight of 2 */ + UWord32 Switch; /* Complexity Weight of 6 */ + UWord32 For; /* Complexity Weight of 3 */ + UWord32 While; /* Complexity Weight of 3 */ + UWord32 Continue; /* Complexity Weight of 2 */ + + UWord32 L_mls; /* Complexity Weight of 1 */ + UWord32 div_l; /* Complexity Weight of 32 */ + UWord32 i_mult; /* Complexity Weight of 1 */ /* New complex basic operators */ #ifdef COMPLEX_OPERATOR - UWord32 CL_shr; /* Complexity Weight of 1 */ - UWord32 CL_shl; /* Complexity Weight of 1 */ - UWord32 CL_add; /* Complexity Weight of 1 */ - UWord32 CL_sub; /* Complexity Weight of 1 */ - UWord32 CL_scale; /* Complexity Weight of 1 */ - UWord32 CL_dscale; /* Complexity Weight of 1 */ - UWord32 CL_msu_j; /* Complexity Weight of 1 */ - UWord32 CL_mac_j; /* Complexity Weight of 1 */ - UWord32 CL_move; /* Complexity Weight of 1 */ - UWord32 CL_Extract_real; /* Complexity Weight of 1 */ - UWord32 CL_Extract_imag; /* Complexity Weight of 1 */ - UWord32 CL_form; /* Complexity Weight of 1 */ - UWord32 CL_multr_32x16; /* Complexity Weight of 2 */ - UWord32 CL_negate; /* Complexity Weight of 1 */ - UWord32 CL_conjugate; /* Complexity Weight of 1 */ - UWord32 CL_mul_j; /* Complexity Weight of 1 */ - UWord32 CL_swap_real_imag; /* Complexity Weight of 1 */ - UWord32 C_add; /* Complexity Weight of 1 */ - UWord32 C_sub; /* Complexity Weight of 1 */ - UWord32 C_mul_j; /* Complexity Weight of 1 */ - UWord32 C_multr; /* Complexity Weight of 2 */ - UWord32 C_form; /* Complexity Weight of 1 */ - - UWord32 C_scale; /* Complexity Weight of 1 */ - UWord32 CL_round32_16; /* Complexity Weight of 1 */ - UWord32 CL_scale_32; /* Complexity Weight of 1 */ - UWord32 CL_dscale_32; /* Complexity Weight of 1 */ - UWord32 CL_multr_32x32; /* Complexity Weight of 2 */ - UWord32 C_mac_r; /* Complexity Weight of 2 */ - UWord32 C_msu_r; /* Complexity Weight of 2 */ - UWord32 C_Extract_real; /* Complexity Weight of 1 */ - UWord32 C_Extract_imag; /* Complexity Weight of 1 */ - UWord32 C_negate; /* Complexity Weight of 1 */ - UWord32 C_conjugate; /* Complexity Weight of 1 */ - UWord32 C_shr; /* Complexity Weight of 1 */ - UWord32 C_shl; /* Complexity Weight of 1 */ + UWord32 CL_shr; /* Complexity Weight of 1 */ + UWord32 CL_shl; /* Complexity Weight of 1 */ + UWord32 CL_add; /* Complexity Weight of 1 */ + UWord32 CL_sub; /* Complexity Weight of 1 */ + UWord32 CL_scale; /* Complexity Weight of 1 */ + UWord32 CL_dscale; /* Complexity Weight of 1 */ + UWord32 CL_msu_j; /* Complexity Weight of 1 */ + UWord32 CL_mac_j; /* Complexity Weight of 1 */ + UWord32 CL_move; /* Complexity Weight of 1 */ + UWord32 CL_Extract_real; /* Complexity Weight of 1 */ + UWord32 CL_Extract_imag; /* Complexity Weight of 1 */ + UWord32 CL_form; /* Complexity Weight of 1 */ + UWord32 CL_multr_32x16; /* Complexity Weight of 2 */ + UWord32 CL_negate; /* Complexity Weight of 1 */ + UWord32 CL_conjugate; /* Complexity Weight of 1 */ + UWord32 CL_mul_j; /* Complexity Weight of 1 */ + UWord32 CL_swap_real_imag; /* Complexity Weight of 1 */ + UWord32 C_add; /* Complexity Weight of 1 */ + UWord32 C_sub; /* Complexity Weight of 1 */ + UWord32 C_mul_j; /* Complexity Weight of 1 */ + UWord32 C_multr; /* Complexity Weight of 2 */ + UWord32 C_form; /* Complexity Weight of 1 */ + + UWord32 C_scale; /* Complexity Weight of 1 */ + UWord32 CL_round32_16; /* Complexity Weight of 1 */ + UWord32 CL_scale_32; /* Complexity Weight of 1 */ + UWord32 CL_dscale_32; /* Complexity Weight of 1 */ + UWord32 CL_multr_32x32; /* Complexity Weight of 2 */ + UWord32 C_mac_r; /* Complexity Weight of 2 */ + UWord32 C_msu_r; /* Complexity Weight of 2 */ + UWord32 C_Extract_real; /* Complexity Weight of 1 */ + UWord32 C_Extract_imag; /* Complexity Weight of 1 */ + UWord32 C_negate; /* Complexity Weight of 1 */ + UWord32 C_conjugate; /* Complexity Weight of 1 */ + UWord32 C_shr; /* Complexity Weight of 1 */ + UWord32 C_shl; /* Complexity Weight of 1 */ #endif /* #ifdef COMPLEX_OPERATOR */ /* New 64 bit basops */ #ifdef ENH_64_BIT_OPERATOR - UWord32 move64; /* Complexity Weight of 1 */ - UWord32 W_add_nosat; /* Complexity Weight of 1 */ - UWord32 W_sub_nosat; /* Complexity Weight of 1 */ - UWord32 W_shl; /* Complexity Weight of 1 */ - UWord32 W_shr; /* Complexity Weight of 1 */ - UWord32 W_shl_nosat; /* Complexity Weight of 1 */ - UWord32 W_shr_nosat; /* Complexity Weight of 1 */ - UWord32 W_mac_32_16; /* Complexity Weight of 1 */ - UWord32 W_msu_32_16; /* Complexity Weight of 1 */ - UWord32 W_mult_32_16; /* Complexity Weight of 1 */ - UWord32 W_mult0_16_16; /* Complexity Weight of 1 */ - UWord32 W_mac0_16_16; /* Complexity Weight of 1 */ - UWord32 W_msu0_16_16; /* Complexity Weight of 1 */ - UWord32 W_mult_16_16; /* Complexity Weight of 1 */ - UWord32 W_mac_16_16; /* Complexity Weight of 1 */ - UWord32 W_msu_16_16; /* Complexity Weight of 1 */ - UWord32 W_shl_sat_l; /* Complexity Weight of 1 */ - UWord32 W_sat_l; /* Complexity Weight of 1 */ - UWord32 W_sat_m; /* Complexity Weight of 1 */ - UWord32 W_deposit32_l; /* Complexity Weight of 1 */ - UWord32 W_deposit32_h; /* Complexity Weight of 1 */ - UWord32 W_extract_l; /* Complexity Weight of 1 */ - UWord32 W_extract_h; /* Complexity Weight of 1 */ - UWord32 W_round48_L; /* Complexity Weight of 1 */ - UWord32 W_round32_s; /* Complexity Weight of 1 */ - UWord32 W_norm; /* Complexity Weight of 1 */ - - UWord32 W_add; /* Complexity Weight of 1 */ - UWord32 W_sub; /* Complexity Weight of 1 */ - UWord32 W_neg; /* Complexity Weight of 1 */ - UWord32 W_abs; /* Complexity Weight of 1 */ - UWord32 W_mult_32_32; /* Complexity Weight of 1 */ - UWord32 W_mult0_32_32; /* Complexity Weight of 1 */ - UWord32 W_lshl; /* Complexity Weight of 1 */ - UWord32 W_lshr; /* Complexity Weight of 1 */ - UWord32 W_round64_L; /* Complexity Weight of 1 */ + UWord32 move64; /* Complexity Weight of 1 */ + UWord32 W_add_nosat; /* Complexity Weight of 1 */ + UWord32 W_sub_nosat; /* Complexity Weight of 1 */ + UWord32 W_shl; /* Complexity Weight of 1 */ + UWord32 W_shr; /* Complexity Weight of 1 */ + UWord32 W_shl_nosat; /* Complexity Weight of 1 */ + UWord32 W_shr_nosat; /* Complexity Weight of 1 */ + UWord32 W_mac_32_16; /* Complexity Weight of 1 */ + UWord32 W_msu_32_16; /* Complexity Weight of 1 */ + UWord32 W_mult_32_16; /* Complexity Weight of 1 */ + UWord32 W_mult0_16_16; /* Complexity Weight of 1 */ + UWord32 W_mac0_16_16; /* Complexity Weight of 1 */ + UWord32 W_msu0_16_16; /* Complexity Weight of 1 */ + UWord32 W_mult_16_16; /* Complexity Weight of 1 */ + UWord32 W_mac_16_16; /* Complexity Weight of 1 */ + UWord32 W_msu_16_16; /* Complexity Weight of 1 */ + UWord32 W_shl_sat_l; /* Complexity Weight of 1 */ + UWord32 W_sat_l; /* Complexity Weight of 1 */ + UWord32 W_sat_m; /* Complexity Weight of 1 */ + UWord32 W_deposit32_l; /* Complexity Weight of 1 */ + UWord32 W_deposit32_h; /* Complexity Weight of 1 */ + UWord32 W_extract_l; /* Complexity Weight of 1 */ + UWord32 W_extract_h; /* Complexity Weight of 1 */ + UWord32 W_round48_L; /* Complexity Weight of 1 */ + UWord32 W_round32_s; /* Complexity Weight of 1 */ + UWord32 W_norm; /* Complexity Weight of 1 */ + + UWord32 W_add; /* Complexity Weight of 1 */ + UWord32 W_sub; /* Complexity Weight of 1 */ + UWord32 W_neg; /* Complexity Weight of 1 */ + UWord32 W_abs; /* Complexity Weight of 1 */ + UWord32 W_mult_32_32; /* Complexity Weight of 1 */ + UWord32 W_mult0_32_32; /* Complexity Weight of 1 */ + UWord32 W_lshl; /* Complexity Weight of 1 */ + UWord32 W_lshr; /* Complexity Weight of 1 */ + UWord32 W_round64_L; /* Complexity Weight of 1 */ #endif /* #ifdef ENH_64_BIT_OPERATOR */ #ifdef ENH_32_BIT_OPERATOR - UWord32 Mpy_32_16_1; /* Complexity Weight of 1 */ - UWord32 Mpy_32_16_r; /* Complexity Weight of 1 */ - UWord32 Mpy_32_32; /* Complexity Weight of 1 */ - UWord32 Mpy_32_32_r; /* Complexity Weight of 1 */ - UWord32 Madd_32_16; /* Complexity Weight of 1 */ - UWord32 Madd_32_16_r; /* Complexity Weight of 1 */ - UWord32 Msub_32_16; /* Complexity Weight of 1 */ - UWord32 Msub_32_16_r; /* Complexity Weight of 1 */ - UWord32 Madd_32_32; /* Complexity Weight of 1 */ - UWord32 Madd_32_32_r; /* Complexity Weight of 1 */ - UWord32 Msub_32_32; /* Complexity Weight of 1 */ - UWord32 Msub_32_32_r; /* Complexity Weight of 1 */ -#endif /* #ifdef ENH_32_BIT_OPERATOR */ + UWord32 Mpy_32_16_1; /* Complexity Weight of 1 */ + UWord32 Mpy_32_16_r; /* Complexity Weight of 1 */ + UWord32 Mpy_32_32; /* Complexity Weight of 1 */ + UWord32 Mpy_32_32_r; /* Complexity Weight of 1 */ + UWord32 Madd_32_16; /* Complexity Weight of 1 */ + UWord32 Madd_32_16_r; /* Complexity Weight of 1 */ + UWord32 Msub_32_16; /* Complexity Weight of 1 */ + UWord32 Msub_32_16_r; /* Complexity Weight of 1 */ + UWord32 Madd_32_32; /* Complexity Weight of 1 */ + UWord32 Madd_32_32_r; /* Complexity Weight of 1 */ + UWord32 Msub_32_32; /* Complexity Weight of 1 */ + UWord32 Msub_32_32_r; /* Complexity Weight of 1 */ +#endif /* #ifdef ENH_32_BIT_OPERATOR */ #ifdef ENH_U_32_BIT_OPERATOR - UWord32 UL_addNs; /* Complexity Weight of 1 */ - UWord32 UL_subNs; /* Complexity Weight of 1 */ - UWord32 UL_Mpy_32_32; /* Complexity Weight of 1 */ - UWord32 Mpy_32_32_uu; /* Complexity Weight of 2 */ - UWord32 Mpy_32_16_uu; /* Complexity Weight of 2 */ - UWord32 norm_ul_float; /* Complexity Weight of 1 */ - UWord32 UL_deposit_l; /* Complexity Weight of 1 */ -#endif /* #ifdef ENH_U_32_BIT_OPERATOR */ + UWord32 UL_addNs; /* Complexity Weight of 1 */ + UWord32 UL_subNs; /* Complexity Weight of 1 */ + UWord32 UL_Mpy_32_32; /* Complexity Weight of 1 */ + UWord32 Mpy_32_32_uu; /* Complexity Weight of 2 */ + UWord32 Mpy_32_16_uu; /* Complexity Weight of 2 */ + UWord32 norm_ul; /* Complexity Weight of 1 */ + UWord32 UL_deposit_l; /* Complexity Weight of 1 */ +#endif /* #ifdef ENH_U_32_BIT_OPERATOR */ #ifdef CONTROL_CODE_OPS - UWord32 LT_16; /* Complexity Weight of 1 */ - UWord32 GT_16; /* Complexity Weight of 1 */ - UWord32 LE_16; /* Complexity Weight of 1 */ - UWord32 GE_16; /* Complexity Weight of 1 */ - UWord32 EQ_16; /* Complexity Weight of 1 */ - UWord32 NE_16; /* Complexity Weight of 1 */ - UWord32 LT_32; /* Complexity Weight of 1 */ - UWord32 GT_32; /* Complexity Weight of 1 */ - UWord32 LE_32; /* Complexity Weight of 1 */ - UWord32 GE_32; /* Complexity Weight of 1 */ - UWord32 EQ_32; /* Complexity Weight of 1 */ - UWord32 NE_32; /* Complexity Weight of 1 */ - UWord32 LT_64; /* Complexity Weight of 1 */ - UWord32 GT_64; /* Complexity Weight of 1 */ - UWord32 LE_64; /* Complexity Weight of 1 */ - UWord32 GE_64; /* Complexity Weight of 1 */ - UWord32 EQ_64; /* Complexity Weight of 1 */ - UWord32 NE_64; /* Complexity Weight of 1 */ - + UWord32 LT_16; /* Complexity Weight of 1 */ + UWord32 GT_16; /* Complexity Weight of 1 */ + UWord32 LE_16; /* Complexity Weight of 1 */ + UWord32 GE_16; /* Complexity Weight of 1 */ + UWord32 EQ_16; /* Complexity Weight of 1 */ + UWord32 NE_16; /* Complexity Weight of 1 */ + UWord32 LT_32; /* Complexity Weight of 1 */ + UWord32 GT_32; /* Complexity Weight of 1 */ + UWord32 LE_32; /* Complexity Weight of 1 */ + UWord32 GE_32; /* Complexity Weight of 1 */ + UWord32 EQ_32; /* Complexity Weight of 1 */ + UWord32 NE_32; /* Complexity Weight of 1 */ + UWord32 LT_64; /* Complexity Weight of 1 */ + UWord32 GT_64; /* Complexity Weight of 1 */ + UWord32 LE_64; /* Complexity Weight of 1 */ + UWord32 GE_64; /* Complexity Weight of 1 */ + UWord32 EQ_64; /* Complexity Weight of 1 */ + UWord32 NE_64; /* Complexity Weight of 1 */ + #endif /* #ifdef CONTROL_CODE_OPS */ } BASIC_OP; -Word32 TotalWeightedOperation( void ); -Word32 DeltaWeightedOperation( void ); +Word32 TotalWeightedOperation (void); +Word32 DeltaWeightedOperation (void); -void generic_WMOPS_output( Word16 notPrintWorstWorstCase, char *test_file_name ); +void generic_WMOPS_output (Word16 notPrintWorstWorstCase, char *test_file_name); /* * This function enable to append : * - to WMOPS_DATA_FILENAME file, the WMOPS information related @@ -480,13 +482,8 @@ void generic_WMOPS_output( Word16 notPrintWorstWorstCase, char *test_file_name ) * * notPrintWorstWorstCase : Same usage as in WMOPS_output(). */ -void WMOPS_output_all( Word16 dtx_mode ); -void WMOPS_output_all_std( Word16 dtx_mode ); -/* - * free all allocated counter memory - */ -void WMOPS_destroy( void ); + #if 0 /* * Example of how count.h could be used. @@ -538,54 +535,6 @@ int main () { } #endif /* #if 0 */ -/* jdr 20120117: add FLC similar functions */ -/* mul 20130729: set BASOP_COUNT_SUBROUTINES to count on a per-BASOP_sub_start()/BASOP_sub_end() base; - otherwise, count only between BASOP_push_wmops(), BASOP_push_wmops() */ -#define BASOP_COUNT_SUBROUTINES -void BASOP_push_wmops( const char *label ); -Word32 BASOP_pop_wmops( void ); - -#define BASOP_init \ - { \ - setFrameRate( 32000, 640 ); \ - Init_WMOPS_counter(); /* 20ms frames */ \ - } -#define BASOP_end \ - { \ - WMOPS_output_all_std( 0 ); \ - } -/*#define BASOP_end { WMOPS_output_all(0); }*/ -#define BASOP_end_noprint \ - { \ - WMOPS_destroy(); \ - } - -#ifdef BASOP_COUNT_SUBROUTINES -#define BASOP_sub_start( label ) \ - { \ - BASOP_push_wmops( label ); \ - } -#define BASOP_sub_end() \ - { \ - BASOP_pop_wmops(); \ - } -#else -#define BASOP_sub_start( label ) -#define BASOP_sub_end() -#endif - -void BASOP_frame_update( void ); -void Reset_all_WMOPS_counter( void ); - -Word32 BASOP_get_wops( void ); - -/*! Returns the total min/max/avg WMOPS values like printed in BASOP_end(). */ -void BASOP_get_total_wmops( double *min, double *max, double *avg ); - - -#define SUB_WMOPS_INIT( label ) BASOP_sub_start( label ) -#define END_SUB_WMOPS BASOP_sub_end() - #endif /* _COUNT_H */ diff --git a/basic_op/enh1632.c b/basic_op/enh1632.c index 7bbff084abd0e2f751b76ee802d73f8154b26699..aa3d16b2f2316d81a3923eab730bc69d53c3678e 100644 --- a/basic_op/enh1632.c +++ b/basic_op/enh1632.c @@ -55,13 +55,11 @@ #include #include #include "stl.h" -#include "wmc_auto.h" - -#ifdef WMOPS +#if (WMOPS) extern BASIC_OP multiCounter[MAXCOUNTERS]; extern int currCounter; -#endif /* if WMOPS */ +#endif /* ifdef WMOPS */ @@ -111,33 +109,31 @@ extern int currCounter; * the range 0xffff 8000 <= var_out <= 0x0000 7fff. * *****************************************************************************/ -Word16 lshl( Word16 var1, Word16 var2) { - Word16 var_out=0; - - if( var2 < 0) { - var2 = -var2; - var_out = lshr( var1, var2); - - #ifdef WMOPS - multiCounter[currCounter].lshr--; - #endif /* if WMOPS */ - - } else { - if( var2 == 0 || var1 == 0) { - var_out = var1; - } else if( var2 >= 16) { - var_out = 0; - } else { - var_out = var1 << var2; - } - } - #ifdef WMOPS - multiCounter[currCounter].lshl++; - #endif /* if WMOPS */ - - BASOP_CHECK(); - - return( var_out); +Word16 lshl (Word16 var1, Word16 var2) { + Word16 var_out = 0; + + if (var2 < 0) { + var2 = -var2; + var_out = lshr (var1, var2); + +#if (WMOPS) + multiCounter[currCounter].lshr--; +#endif /* ifdef WMOPS */ + + } else { + if (var2 == 0 || var1 == 0) { + var_out = var1; + } else if (var2 >= 16) { + var_out = 0; + } else { + var_out = var1 << var2; + } + } +#if (WMOPS) + multiCounter[currCounter].lshl++; +#endif /* ifdef WMOPS */ + + return (var_out); } /***************************************************************************** @@ -172,35 +168,33 @@ Word16 lshl( Word16 var1, Word16 var2) { * the range 0xffff 8000 <= var_out <= 0x0000 7fff. * *****************************************************************************/ -Word16 lshr( Word16 var1, Word16 var2) { - Word16 var_out; - - if( var2 < 0) { - var2 = -var2; - var_out = lshl( var1, var2); - - #ifdef WMOPS - multiCounter[currCounter].lshl--; - #endif /* if WMOPS */ - - } else { - if( var2 == 0 || var1 == 0) { - var_out = var1; - } else if( var2 >= 16) { - var_out = 0; - } else { - var_out = var1 >> 1; - var_out = var_out & 0x7fff; - var_out = var_out >> ( var2-1); - } - } - #ifdef WMOPS - multiCounter[currCounter].lshr++; - #endif /* if WMOPS */ - - BASOP_CHECK(); - - return( var_out); +Word16 lshr (Word16 var1, Word16 var2) { + Word16 var_out; + + if (var2 < 0) { + var2 = -var2; + var_out = lshl (var1, var2); + +#if (WMOPS) + multiCounter[currCounter].lshl--; +#endif /* ifdef WMOPS */ + + } else { + if (var2 == 0 || var1 == 0) { + var_out = var1; + } else if (var2 >= 16) { + var_out = 0; + } else { + var_out = var1 >> 1; + var_out = var_out & 0x7fff; + var_out = var_out >> (var2 - 1); + } + } +#if (WMOPS) + multiCounter[currCounter].lshr++; +#endif /* ifdef WMOPS */ + + return (var_out); } @@ -236,33 +230,31 @@ Word16 lshr( Word16 var1, Word16 var2) { * the range 0x8000 0000 <= L_var_out <= 0x7fff ffff. * *****************************************************************************/ -Word32 L_lshl( Word32 L_var1, Word16 var2) { - Word32 L_var_out=0; - - if( var2 < 0) { - var2 = -var2; - L_var_out = L_lshr( L_var1, var2); - - #ifdef WMOPS - multiCounter[currCounter].L_lshr--; - #endif /* if WMOPS */ - - } else { - if( var2 == 0 || L_var1 == 0) { - L_var_out = L_var1; - } else if( var2 >= 32) { - L_var_out = 0; - } else { - L_var_out = L_var1 << var2; - } - } - #ifdef WMOPS - multiCounter[currCounter].L_lshl++; - #endif /* if WMOPS */ - - BASOP_CHECK(); - - return( L_var_out); +Word32 L_lshl (Word32 L_var1, Word16 var2) { + Word32 L_var_out = 0; + + if (var2 < 0) { + var2 = -var2; + L_var_out = L_lshr (L_var1, var2); + +#if (WMOPS) + multiCounter[currCounter].L_lshr--; +#endif /* ifdef WMOPS */ + + } else { + if (var2 == 0 || L_var1 == 0) { + L_var_out = L_var1; + } else if (var2 >= 32) { + L_var_out = 0; + } else { + L_var_out = L_var1 << var2; + } + } +#if (WMOPS) + multiCounter[currCounter].L_lshl++; +#endif /* ifdef WMOPS */ + + return (L_var_out); } @@ -298,35 +290,33 @@ Word32 L_lshl( Word32 L_var1, Word16 var2) { * the range 0x8000 0000 <= L_var_out <= 0x7fff ffff. * *****************************************************************************/ -Word32 L_lshr( Word32 L_var1, Word16 var2) { - Word32 L_var_out; - - if( var2 < 0) { - var2 = -var2; - L_var_out = L_lshl( L_var1, var2); - - #ifdef WMOPS - multiCounter[currCounter].L_lshl--; - #endif /* if WMOPS */ - - } else { - if( var2 == 0 || L_var1 == 0) { - L_var_out = L_var1; - } else if( var2 >= 32) { - L_var_out = 0; - } else { - L_var_out = L_var1 >> 1; - L_var_out = L_var_out & 0x7fffffff; - L_var_out = L_var_out >> (var2 - 1); - } - } - #ifdef WMOPS - multiCounter[currCounter].L_lshr++; - #endif /* if WMOPS */ - - BASOP_CHECK(); - - return( L_var_out); +Word32 L_lshr (Word32 L_var1, Word16 var2) { + Word32 L_var_out; + + if (var2 < 0) { + var2 = -var2; + L_var_out = L_lshl (L_var1, var2); + +#if (WMOPS) + multiCounter[currCounter].L_lshl--; +#endif /* ifdef WMOPS */ + + } else { + if (var2 == 0 || L_var1 == 0) { + L_var_out = L_var1; + } else if (var2 >= 32) { + L_var_out = 0; + } else { + L_var_out = L_var1 >> 1; + L_var_out = L_var_out & 0x7fffffff; + L_var_out = L_var_out >> (var2 - 1); + } + } +#if (WMOPS) + multiCounter[currCounter].L_lshr++; +#endif /* ifdef WMOPS */ + + return (L_var_out); } @@ -359,30 +349,30 @@ Word32 L_lshr( Word32 L_var1, Word16 var2) { * the range : 0xffff 8000 <= var_out <= 0x0000 7fff. * *****************************************************************************/ -Word16 shl_r( Word16 var1, Word16 var2){ - Word16 var_out; +Word16 shl_r (Word16 var1, Word16 var2) { + Word16 var_out; - if( var2 >= 0) { - var_out = shl( var1, var2); + if (var2 >= 0) { + var_out = shl (var1, var2); - #ifdef WMOPS - multiCounter[currCounter].shl--; - #endif /* if WMOPS */ +#if (WMOPS) + multiCounter[currCounter].shl--; +#endif /* ifdef WMOPS */ - } else { - var2 = -var2; - var_out = shr_r( var1, var2); + } else { + var2 = -var2; + var_out = shr_r (var1, var2); - #ifdef WMOPS - multiCounter[currCounter].shr_r--; - #endif /* if WMOPS */ - } +#if (WMOPS) + multiCounter[currCounter].shr_r--; +#endif /* ifdef WMOPS */ + } - #ifdef WMOPS - multiCounter[currCounter].shl_r++; - #endif /* if WMOPS */ +#if (WMOPS) + multiCounter[currCounter].shl_r++; +#endif /* ifdef WMOPS */ - return( var_out); + return (var_out); } @@ -415,30 +405,30 @@ Word16 shl_r( Word16 var1, Word16 var2){ * the range : 0x8000 0000 <= var_out <= 0x7fff ffff. * *****************************************************************************/ -Word32 L_shl_r( Word32 L_var1, Word16 var2) { - Word32 var_out; +Word32 L_shl_r (Word32 L_var1, Word16 var2) { + Word32 var_out; - if( var2 >= 0) { - var_out = L_shl( L_var1, var2); + if (var2 >= 0) { + var_out = L_shl (L_var1, var2); - #ifdef WMOPS - multiCounter[currCounter].L_shl--; - #endif /* if WMOPS */ +#if (WMOPS) + multiCounter[currCounter].L_shl--; +#endif /* ifdef WMOPS */ - } else { - var2 = -var2; - var_out = L_shr_r( L_var1, var2); + } else { + var2 = -var2; + var_out = L_shr_r (L_var1, var2); - #ifdef WMOPS - multiCounter[currCounter].L_shr_r--; - #endif /* if WMOPS */ - } +#if (WMOPS) + multiCounter[currCounter].L_shr_r--; +#endif /* ifdef WMOPS */ + } - #ifdef WMOPS - multiCounter[currCounter].L_shl_r++; - #endif /* if WMOPS */ +#if (WMOPS) + multiCounter[currCounter].L_shl_r++; +#endif /* ifdef WMOPS */ - return( var_out); + return (var_out); } @@ -472,22 +462,21 @@ Word32 L_shl_r( Word32 L_var1, Word16 var2) { * the range : 0xffff 8000 <= var_out <= 0x0000 7fff. * *****************************************************************************/ -Word16 rotr( Word16 var1, Word16 var2, Word16 *var3) { - Word16 var_out; - - *var3 = s_and( var1, 0x1); - var_out = s_or( lshr( var1, 1), - lshl( var2, 15)); - - #ifdef WMOPS - multiCounter[currCounter].s_and--; - multiCounter[currCounter].lshl--; - multiCounter[currCounter].lshr--; - multiCounter[currCounter].s_or--; - multiCounter[currCounter].rotr++; - #endif /* if WMOPS */ - - return( var_out); +Word16 rotr (Word16 var1, Word16 var2, Word16 * var3) { + Word16 var_out; + + *var3 = s_and (var1, 0x1); + var_out = s_or (lshr (var1, 1), lshl (var2, 15)); + +#if (WMOPS) + multiCounter[currCounter].s_and--; + multiCounter[currCounter].lshl--; + multiCounter[currCounter].lshr--; + multiCounter[currCounter].s_or--; + multiCounter[currCounter].rotr++; +#endif /* ifdef WMOPS */ + + return (var_out); } @@ -521,23 +510,22 @@ Word16 rotr( Word16 var1, Word16 var2, Word16 *var3) { * the range : 0xffff 8000 <= var_out <= 0x0000 7fff. * *****************************************************************************/ -Word16 rotl( Word16 var1, Word16 var2, Word16 *var3) { - Word16 var_out; +Word16 rotl (Word16 var1, Word16 var2, Word16 * var3) { + Word16 var_out; - *var3 = lshr( var1, 15); + *var3 = lshr (var1, 15); - var_out = s_or( lshl( var1, 1), - s_and( var2, 0x1)); + var_out = s_or (lshl (var1, 1), s_and (var2, 0x1)); - #ifdef WMOPS - multiCounter[currCounter].lshr--; - multiCounter[currCounter].s_and--; - multiCounter[currCounter].lshl--; - multiCounter[currCounter].s_or--; - multiCounter[currCounter].rotl++; - #endif /* if WMOPS */ +#if (WMOPS) + multiCounter[currCounter].lshr--; + multiCounter[currCounter].s_and--; + multiCounter[currCounter].lshl--; + multiCounter[currCounter].s_or--; + multiCounter[currCounter].rotl++; +#endif /* ifdef WMOPS */ - return( var_out); + return (var_out); } @@ -571,25 +559,24 @@ Word16 rotl( Word16 var1, Word16 var2, Word16 *var3) { * the range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. * *****************************************************************************/ -Word32 L_rotr( Word32 L_var1, Word16 var2, Word16 *var3) { - Word32 L_var_out; +Word32 L_rotr (Word32 L_var1, Word16 var2, Word16 * var3) { + Word32 L_var_out; - *var3 = s_and( extract_l( L_var1), 0x1); + *var3 = s_and (extract_l (L_var1), 0x1); - L_var_out = L_or( L_lshr( L_var1, 1), - L_lshl( L_deposit_l( var2), 31)); + L_var_out = L_or (L_lshr (L_var1, 1), L_lshl (L_deposit_l (var2), 31)); - #ifdef WMOPS - multiCounter[currCounter].extract_l--; - multiCounter[currCounter].s_and--; - multiCounter[currCounter].L_deposit_l--; - multiCounter[currCounter].L_lshl--; - multiCounter[currCounter].L_lshr--; - multiCounter[currCounter].L_or--; - multiCounter[currCounter].L_rotr++; - #endif /* if WMOPS */ +#if (WMOPS) + multiCounter[currCounter].extract_l--; + multiCounter[currCounter].s_and--; + multiCounter[currCounter].L_deposit_l--; + multiCounter[currCounter].L_lshl--; + multiCounter[currCounter].L_lshr--; + multiCounter[currCounter].L_or--; + multiCounter[currCounter].L_rotr++; +#endif /* ifdef WMOPS */ - return( L_var_out); + return (L_var_out); } @@ -623,25 +610,24 @@ Word32 L_rotr( Word32 L_var1, Word16 var2, Word16 *var3) { * the range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. * *****************************************************************************/ -Word32 L_rotl( Word32 L_var1, Word16 var2, Word16 *var3) { - Word32 L_var_out; +Word32 L_rotl (Word32 L_var1, Word16 var2, Word16 * var3) { + Word32 L_var_out; - *var3 = extract_l( L_lshr( L_var1, 31)); + *var3 = extract_l (L_lshr (L_var1, 31)); - L_var_out = L_or( L_lshl( L_var1, 1), - L_deposit_l( s_and( var2, 0x1))); + L_var_out = L_or (L_lshl (L_var1, 1), L_deposit_l (s_and (var2, 0x1))); - #ifdef WMOPS - multiCounter[currCounter].L_lshr--; - multiCounter[currCounter].extract_l--; - multiCounter[currCounter].s_and--; - multiCounter[currCounter].L_deposit_l--; - multiCounter[currCounter].L_lshl--; - multiCounter[currCounter].L_or--; - multiCounter[currCounter].L_rotl++; - #endif /* if WMOPS */ +#if (WMOPS) + multiCounter[currCounter].L_lshr--; + multiCounter[currCounter].extract_l--; + multiCounter[currCounter].s_and--; + multiCounter[currCounter].L_deposit_l--; + multiCounter[currCounter].L_lshl--; + multiCounter[currCounter].L_or--; + multiCounter[currCounter].L_rotl++; +#endif /* ifdef WMOPS */ - return( L_var_out); + return (L_var_out); } diff --git a/basic_op/enh1632.h b/basic_op/enh1632.h index add93fbac4303f3b7504e0c2c4c08aa1b3dd6d70..1aee12b6430079becbe4f3602d738708c7d951bf 100644 --- a/basic_op/enh1632.h +++ b/basic_op/enh1632.h @@ -36,11 +36,11 @@ #include "stl.h" -#ifdef WMOPS +#if (WMOPS) #include "count.h" extern BASIC_OP multiCounter[MAXCOUNTERS]; extern int currCounter; -#endif /* if WMOPS */ +#endif /* ifdef WMOPS */ /***************************************************************************** @@ -48,19 +48,19 @@ extern int currCounter; * Prototypes for enhanced 16/32 bit arithmetic operators * *****************************************************************************/ -Word16 shl_r( Word16 var1, Word16 var2); -Word32 L_shl_r( Word32 L_var1, Word16 var2); +Word16 shl_r (Word16 var1, Word16 var2); +Word32 L_shl_r (Word32 L_var1, Word16 var2); -Word16 lshl( Word16 var1, Word16 var2); -Word16 lshr( Word16 var1, Word16 var2); -Word32 L_lshl( Word32 L_var1, Word16 var2); -Word32 L_lshr( Word32 L_var1, Word16 var2); +Word16 lshl (Word16 var1, Word16 var2); +Word16 lshr (Word16 var1, Word16 var2); +Word32 L_lshl (Word32 L_var1, Word16 var2); +Word32 L_lshr (Word32 L_var1, Word16 var2); -Word16 rotr( Word16 var1, Word16 var2, Word16 *var3); -Word16 rotl( Word16 var1, Word16 var2, Word16 *var3); -Word32 L_rotr( Word32 var1, Word16 var2, Word16 *var3); -Word32 L_rotl( Word32 var1, Word16 var2, Word16 *var3); +Word16 rotr (Word16 var1, Word16 var2, Word16 * var3); +Word16 rotl (Word16 var1, Word16 var2, Word16 * var3); +Word32 L_rotr (Word32 var1, Word16 var2, Word16 * var3); +Word32 L_rotl (Word32 var1, Word16 var2, Word16 * var3); @@ -98,19 +98,19 @@ Word32 L_rotl( Word32 var1, Word16 var2, Word16 *var3); * the range : 0x8000 <= L_var_out <= 0x7fff. * *****************************************************************************/ -static __inline Word16 s_max( Word16 var1, Word16 var2) { - Word16 var_out; +static __inline Word16 s_max (Word16 var1, Word16 var2) { + Word16 var_out; - if( var1 >= var2) - var_out = var1; - else - var_out = var2; + if (var1 >= var2) + var_out = var1; + else + var_out = var2; - #ifdef WMOPS - multiCounter[currCounter].s_max++; - #endif /* if WMOPS */ +#if (WMOPS) + multiCounter[currCounter].s_max++; +#endif /* ifdef WMOPS */ - return( var_out); + return (var_out); } @@ -142,19 +142,19 @@ static __inline Word16 s_max( Word16 var1, Word16 var2) { * the range : 0x8000 <= var_out <= 0x7fff. * *****************************************************************************/ -static __inline Word16 s_min( Word16 var1, Word16 var2) { - Word16 var_out; +static __inline Word16 s_min (Word16 var1, Word16 var2) { + Word16 var_out; - if( var1 <= var2) - var_out = var1; - else - var_out = var2; + if (var1 <= var2) + var_out = var1; + else + var_out = var2; - #ifdef WMOPS - multiCounter[currCounter].s_min++; - #endif /* if WMOPS */ +#if (WMOPS) + multiCounter[currCounter].s_min++; +#endif /* ifdef WMOPS */ - return( var_out); + return (var_out); } @@ -186,19 +186,19 @@ static __inline Word16 s_min( Word16 var1, Word16 var2) { * range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. * *****************************************************************************/ -static __inline Word32 L_max( Word32 L_var1, Word32 L_var2) { - Word32 L_var_out; +static __inline Word32 L_max (Word32 L_var1, Word32 L_var2) { + Word32 L_var_out; - if( L_var1 >= L_var2) - L_var_out = L_var1; - else - L_var_out = L_var2; + if (L_var1 >= L_var2) + L_var_out = L_var1; + else + L_var_out = L_var2; - #ifdef WMOPS - multiCounter[currCounter].L_max++; - #endif /* if WMOPS */ +#if (WMOPS) + multiCounter[currCounter].L_max++; +#endif /* ifdef WMOPS */ - return( L_var_out); + return (L_var_out); } @@ -230,19 +230,19 @@ static __inline Word32 L_max( Word32 L_var1, Word32 L_var2) { * range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. * *****************************************************************************/ -static __inline Word32 L_min( Word32 L_var1, Word32 L_var2) { - Word32 L_var_out; +static __inline Word32 L_min (Word32 L_var1, Word32 L_var2) { + Word32 L_var_out; - if( L_var1 <= L_var2) - L_var_out = L_var1; - else - L_var_out = L_var2; + if (L_var1 <= L_var2) + L_var_out = L_var1; + else + L_var_out = L_var2; - #ifdef WMOPS - multiCounter[currCounter].L_min++; - #endif /* if WMOPS */ +#if (WMOPS) + multiCounter[currCounter].L_min++; +#endif /* ifdef WMOPS */ - return( L_var_out); + return (L_var_out); } @@ -283,16 +283,16 @@ static __inline Word32 L_min( Word32 L_var1, Word32 L_var2) { * falls in the range 0xffff 8000 <= var_out <= 0x0000 7fff. * *****************************************************************************/ -static __inline Word16 s_and( Word16 var1, Word16 var2) { - Word16 var_out; +static __inline Word16 s_and (Word16 var1, Word16 var2) { + Word16 var_out; - var_out = var1 & var2; + var_out = var1 & var2; - #ifdef WMOPS - multiCounter[currCounter].s_and++; - #endif /* if WMOPS */ +#if (WMOPS) + multiCounter[currCounter].s_and++; +#endif /* ifdef WMOPS */ - return( var_out); + return (var_out); } @@ -325,16 +325,16 @@ static __inline Word16 s_and( Word16 var1, Word16 var2) { * falls in the range 0x8000 0000 <= L_var_out <= 0x7fff ffff. * *****************************************************************************/ -static __inline Word32 L_and( Word32 L_var1, Word32 L_var2) { - Word32 L_var_out; +static __inline Word32 L_and (Word32 L_var1, Word32 L_var2) { + Word32 L_var_out; - L_var_out = L_var1 & L_var2; + L_var_out = L_var1 & L_var2; - #ifdef WMOPS - multiCounter[currCounter].L_and++; - #endif /* if WMOPS */ +#if (WMOPS) + multiCounter[currCounter].L_and++; +#endif /* ifdef WMOPS */ - return( L_var_out); + return (L_var_out); } @@ -367,16 +367,16 @@ static __inline Word32 L_and( Word32 L_var1, Word32 L_var2) { * falls in the range 0xffff 8000 <= var_out <= 0x0000 7fff. * *****************************************************************************/ -static __inline Word16 s_or( Word16 var1, Word16 var2) { - Word16 var_out; +static __inline Word16 s_or (Word16 var1, Word16 var2) { + Word16 var_out; - var_out = var1 | var2; + var_out = var1 | var2; - #ifdef WMOPS - multiCounter[currCounter].s_or++; - #endif /* if WMOPS */ +#if (WMOPS) + multiCounter[currCounter].s_or++; +#endif /* ifdef WMOPS */ - return( var_out); + return (var_out); } @@ -409,17 +409,17 @@ static __inline Word16 s_or( Word16 var1, Word16 var2) { * falls in the range 0x8000 0000 <= L_var_out <= 0x7fff ffff. * *****************************************************************************/ -static __inline Word32 L_or( Word32 L_var1, Word32 L_var2) { +static __inline Word32 L_or (Word32 L_var1, Word32 L_var2) { - Word32 L_var_out; + Word32 L_var_out; - L_var_out = L_var1 | L_var2; + L_var_out = L_var1 | L_var2; - #ifdef WMOPS - multiCounter[currCounter].L_or++; - #endif /* if WMOPS */ +#if (WMOPS) + multiCounter[currCounter].L_or++; +#endif /* ifdef WMOPS */ - return( L_var_out); + return (L_var_out); } @@ -452,16 +452,16 @@ static __inline Word32 L_or( Word32 L_var1, Word32 L_var2) { * falls in the range 0xffff 8000 <= var_out <= 0x0000 7fff. * *****************************************************************************/ -static __inline Word16 s_xor( Word16 var1, Word16 var2) { - Word16 var_out; +static __inline Word16 s_xor (Word16 var1, Word16 var2) { + Word16 var_out; - var_out = var1 ^ var2; + var_out = var1 ^ var2; - #ifdef WMOPS - multiCounter[currCounter].s_xor++; - #endif /* if WMOPS */ +#if (WMOPS) + multiCounter[currCounter].s_xor++; +#endif /* ifdef WMOPS */ - return( var_out); + return (var_out); } @@ -494,16 +494,16 @@ static __inline Word16 s_xor( Word16 var1, Word16 var2) { * falls in the range 0x8000 0000 <= L_var_out <= 0x7fff ffff. * *****************************************************************************/ -static __inline Word32 L_xor( Word32 L_var1, Word32 L_var2) { - Word32 L_var_out; +static __inline Word32 L_xor (Word32 L_var1, Word32 L_var2) { + Word32 L_var_out; - L_var_out = L_var1 ^ L_var2; + L_var_out = L_var1 ^ L_var2; - #ifdef WMOPS - multiCounter[currCounter].L_xor++; - #endif /* if WMOPS */ +#if (WMOPS) + multiCounter[currCounter].L_xor++; +#endif /* ifdef WMOPS */ - return( L_var_out); + return (L_var_out); } diff --git a/basic_op/enh32.c b/basic_op/enh32.c new file mode 100644 index 0000000000000000000000000000000000000000..1f8a6f83cc5c53183b6207ed753c1f7779b8a131 --- /dev/null +++ b/basic_op/enh32.c @@ -0,0 +1,215 @@ +/***************************************************************************** + * + * Enhanced 32 bit operators : + * + * Mpy_32_16_1() + * Mpy_32_16_r() + * Mpy_32_32() + * Mpy_32_32_r() + * Madd_32_16() + * Msub_32_16() + * Madd_32_32() + * Msub_32_32() + * + *****************************************************************************/ + + +/***************************************************************************** + * + * Include-Files + * + *****************************************************************************/ +#include +#include +#include "enh32.h" + +#if (WMOPS) +extern BASIC_OP multiCounter[MAXCOUNTERS]; +extern int currCounter; +#endif /* if WMOPS */ + +#ifdef ENH_32_BIT_OPERATOR +/***************************************************************************** + * + * Local Functions + * + *****************************************************************************/ + +/***************************************************************************** + * + * Constants and Globals + * + *****************************************************************************/ + + +/***************************************************************************** + * + * Functions + * + *****************************************************************************/ + +Word32 Mpy_32_16_1 (Word32 L_var1, Word16 var2) { + Word32 L_var_out = W_sat_m (W_mult_32_16 (L_var1, var2) ); +#if (WMOPS) + multiCounter[currCounter].Mpy_32_16_1++; + multiCounter[currCounter].W_mult_32_16--; + multiCounter[currCounter].W_sat_m--; +#endif /* if WMOPS */ + return L_var_out; +} + +Word32 Mpy_32_16_r (Word32 L_var1, Word16 var2) { + Word32 L_var_out = W_round48_L (W_mult_32_16 (L_var1, var2 ) ); +#if (WMOPS) + multiCounter[currCounter].Mpy_32_16_r++; + multiCounter[currCounter].W_mult_32_16--; + multiCounter[currCounter].W_round48_L--; +#endif /* if WMOPS */ + return L_var_out; +} + +Word32 Mpy_32_32 (Word32 L_var1, Word32 L_var2) { + Word32 L_var_out; + Word64 L64_var1; + + L64_var1 = ((Word64)L_var1 * L_var2); + L64_var1 = W_shl (L64_var1, 1); + L_var_out = W_extract_h (L64_var1 ); +#if (WMOPS) + multiCounter[currCounter].Mpy_32_32++; + multiCounter[currCounter].W_shl--; + multiCounter[currCounter].W_extract_h--; +#endif /* if WMOPS */ + return L_var_out; +} + +Word32 Mpy_32_32_r (Word32 L_var1, Word32 L_var2) { + Word32 L_var_out; + Word64 L64_var1; + + L64_var1 = ((Word64) L_var1 * L_var2); + L64_var1 = W_shr (L64_var1, 15); + L_var_out = W_round48_L (L64_var1 ); +#if (WMOPS) + multiCounter[currCounter].Mpy_32_32_r++; + multiCounter[currCounter].W_shr--; + multiCounter[currCounter].W_round48_L--; +#endif /* if WMOPS */ + return L_var_out; +} + +Word32 Madd_32_16 (Word32 L_var3, Word32 L_var1, Word16 var2) { + Word32 L_var_out; + + L_var_out = Mpy_32_16_1 (L_var1, var2); + L_var_out = L_add (L_var3, L_var_out); + +#if (WMOPS) + multiCounter[currCounter].Mpy_32_16_1--; + multiCounter[currCounter].L_add--; + multiCounter[currCounter].Madd_32_16++; +#endif /* if WMOPS */ + return L_var_out; +} + +Word32 Madd_32_16_r (Word32 L_var3, Word32 L_var1, Word16 var2) { + Word32 L_var_out; + + L_var_out = Mpy_32_16_r (L_var1, var2); + L_var_out = L_add (L_var3, L_var_out); + +#if (WMOPS) + multiCounter[currCounter].Mpy_32_16_r--; + multiCounter[currCounter].L_add--; + multiCounter[currCounter].Madd_32_16_r++; +#endif /* if WMOPS */ + return L_var_out; +} + +Word32 Msub_32_16 (Word32 L_var3, Word32 L_var1, Word16 var2) { + Word32 L_var_out; + + L_var_out = Mpy_32_16_1 (L_var1, var2); + L_var_out = L_sub(L_var3, L_var_out); + +#if (WMOPS) + multiCounter[currCounter].Mpy_32_16_1--; + multiCounter[currCounter].L_sub--; + multiCounter[currCounter].Msub_32_16++; +#endif /* if WMOPS */ + return L_var_out; +} + +Word32 Msub_32_16_r (Word32 L_var3, Word32 L_var1, Word16 var2) { + Word32 L_var_out; + + L_var_out = Mpy_32_16_r (L_var1, var2); + L_var_out = L_sub (L_var3, L_var_out); + +#if (WMOPS) + multiCounter[currCounter].Mpy_32_16_r--; + multiCounter[currCounter].L_sub--; + multiCounter[currCounter].Msub_32_16_r++; +#endif /* if WMOPS */ + return L_var_out; +} + +Word32 Madd_32_32 (Word32 L_var3, Word32 L_var1, Word32 L_var2) { + Word32 L_var_out; + + L_var_out = Mpy_32_32 (L_var1, L_var2); + L_var_out = L_add (L_var3, L_var_out); + +#if (WMOPS) + multiCounter[currCounter].Mpy_32_32--; + multiCounter[currCounter].L_add--; + multiCounter[currCounter].Madd_32_32++; +#endif /* if WMOPS */ + return L_var_out; +} + +Word32 Madd_32_32_r (Word32 L_var3, Word32 L_var1, Word32 L_var2) { + Word32 L_var_out; + + L_var_out = Mpy_32_32_r (L_var1, L_var2); + L_var_out = L_add (L_var3, L_var_out); + +#if (WMOPS) + multiCounter[currCounter].Mpy_32_32_r--; + multiCounter[currCounter].L_add--; + multiCounter[currCounter].Madd_32_32_r++; +#endif /* if WMOPS */ + return L_var_out; +} + +Word32 Msub_32_32 (Word32 L_var3, Word32 L_var1, Word32 L_var2) { + Word32 L_var_out; + + L_var_out = Mpy_32_32 (L_var1, L_var2); + L_var_out = L_sub (L_var3, L_var_out); + +#if (WMOPS) + multiCounter[currCounter].Mpy_32_32--; + multiCounter[currCounter].L_sub--; + multiCounter[currCounter].Msub_32_32++; +#endif /* if WMOPS */ + return L_var_out; +} + +Word32 Msub_32_32_r (Word32 L_var3, Word32 L_var1, Word32 L_var2) { + Word32 L_var_out; + + L_var_out = Mpy_32_32_r (L_var1, L_var2); + L_var_out = L_sub (L_var3, L_var_out); + +#if (WMOPS) + multiCounter[currCounter].Mpy_32_32_r--; + multiCounter[currCounter].L_sub--; + multiCounter[currCounter].Msub_32_32_r++; +#endif /* if WMOPS */ + return L_var_out; +} + +#endif /* #ifdef ENH_32_BIT_OPERATOR */ + +/* end of file */ diff --git a/basic_op/enh32.h b/basic_op/enh32.h new file mode 100644 index 0000000000000000000000000000000000000000..a6e220c9512838e797b6add6dbe4d44e3c029d69 --- /dev/null +++ b/basic_op/enh32.h @@ -0,0 +1,38 @@ + +#ifndef _ENH32_H +#define _ENH32_H + +#include "stl.h" + +#ifndef Word64 +#define Word64 long long int +#endif + + /***************************************************************************** + * + * Prototypes for enhanced 32 bit arithmetic operators + * + *****************************************************************************/ +#ifdef ENH_32_BIT_OPERATOR + +Word32 Mpy_32_16_1 (Word32 L_var1, Word16 var2); +Word32 Mpy_32_16_r (Word32 L_var1, Word16 var2); +Word32 Mpy_32_32 (Word32 L_var1, Word32 L_var2); +Word32 Mpy_32_32_r (Word32 L_var1, Word32 L_var2); +Word32 Madd_32_16 (Word32 L_var3, Word32 L_var1, Word16 var2); +Word32 Madd_32_16_r (Word32 L_var3, Word32 L_var1, Word16 var2); +Word32 Msub_32_16 (Word32 L_var3, Word32 L_var1, Word16 var2); +Word32 Msub_32_16_r (Word32 L_var3, Word32 L_var1, Word16 var2); +Word32 Madd_32_32 (Word32 L_var3, Word32 L_var1, Word32 L_var2); +Word32 Madd_32_32_r (Word32 L_var3, Word32 L_var1, Word32 L_var2); +Word32 Msub_32_32 (Word32 L_var3, Word32 L_var1, Word32 L_var2); +Word32 Msub_32_32_r (Word32 L_var3, Word32 L_var1, Word32 L_var2); + +#endif /* #ifdef ENH_32_BIT_OPERATOR */ + +#endif /*_ENH32_H*/ + + +/* end of file */ + + diff --git a/basic_op/enh40.c b/basic_op/enh40.c index 816630ab56de5d7c913b0f27f1058f62e7a33eac..a72a243b25fb9f356eb2328aeeaa9cca5d6ae1a9 100644 --- a/basic_op/enh40.c +++ b/basic_op/enh40.c @@ -14,8 +14,6 @@ TD 11 document and subsequent discussions on the wp3audio@yahoogroups.com email reflector. - 31 Mar 15 v2.1E Removal of operators not used in the EVS codec. - ============================================================================ */ @@ -24,8 +22,35 @@ * * Enhanced 40 bit operators : * + * L40_add() + * L40_sub() + * L40_abs() + * L40_negate() + * L40_max() + * L40_min() + * L40_shr() + * L40_shr_r() + * L40_shl() + * L40_shl_r() + * norm_L40() + * L40_mult() + * L40_mac() + * L40_msu() + * mac_r40() + * msu_r40() * Mpy_32_16_ss() * Mpy_32_32_ss() + * L40_lshl() + * L40_lshr() + * L40_round() + * L_saturate40() + * L40_set() + * Extract40_H() + * Extract40_L() + * L_Extract40() + * L40_deposit_h() + * L40_deposit_l() + * L40_deposit32() * *****************************************************************************/ @@ -38,13 +63,11 @@ #include #include #include "stl.h" -#include "wmc_auto.h" - -#ifdef WMOPS +#if (WMOPS) extern BASIC_OP multiCounter[MAXCOUNTERS]; extern int currCounter; -#endif /* if WMOPS */ +#endif /* ifdef WMOPS */ /***************************************************************************** @@ -52,24 +75,7 @@ extern int currCounter; * Local Functions * *****************************************************************************/ -static __inline Word40 L40_shr( Word40 L40_var1, Word16 var2); -static __inline Word40 L40_shl( Word40 L40_var1, Word16 var2); -static __inline Word40 L40_set( Word40 L40_var1); -static __inline UWord16 Extract40_L( Word40 L40_var1); -static __inline Word40 L40_mult( Word16 var1, Word16 var2); -static __inline Word40 L40_add( Word40 L40_var1, Word40 L40_var2); -static __inline Word40 L40_mac( Word40 L40_var1, Word16 var2, Word16 var3); -static __inline UWord32 L_Extract40( Word40 L40_var1) ; -/***************************************************************************** - * - * Macros for 40 bit arithmetic overflow management : - * Upon 40-bit overflow beyond MAX_40 or underflow beyond MIN_40, - * the application will exit. - * - *****************************************************************************/ -#define L40_OVERFLOW_OCCURED( L40_var1) (Overflow = 1, exit(1), L40_var1) -#define L40_UNDERFLOW_OCCURED( L40_var1) (Overflow = 1, exit(2), L40_var1) /***************************************************************************** * @@ -84,182 +90,151 @@ static __inline UWord32 L_Extract40( Word40 L40_var1) ; * *****************************************************************************/ - /***************************************************************************** * - * Function Name : Mpy_32_16_ss + * Function Name : L40_shl * * Purpose : * - * Multiplies the 2 signed values L_var1 and var2 with saturation control - * on 48-bit. The operation is performed in fractional mode : - * - L_var1 is supposed to be in 1Q31 format. - * - var2 is supposed to be in 1Q15 format. - * - The result is produced in 1Q47 format : L_varout_h points to the - * 32 MSBits while varout_l points to the 16 LSBits. + * Arithmetically shifts left L40_var1 by var2 positions. + * - If var2 is negative, L40_var1 is shifted to the LSBits by (-var2) + * positions with extension of the sign bit. + * - If var2 is positive, L40_var1 is shifted to the MSBits by (var2) + * positions. + * Calls the macro L40_UNDERFLOW_OCCURED() in case of underflow on 40-bit. + * Calls the macro L40_OVERFLOW_OCCURED() in case of overflow on 40-bit. * - * Complexity weight : 2 + * Complexity weight : 1 * * Inputs : * - * L_var1 32 bit long signed integer (Word32) whose value falls in - * the range : 0x8000 0000 <= L_var1 <= 0x7fff ffff. + * L40_var1 40 bit long signed integer (Word40) whose value falls in the + * range : MIN_40 <= L40_var1 <= MAX_40. * * var2 16 bit short signed integer (Word16) whose value falls in - * the range : 0xffff 8000 <= var2 <= 0x0000 7fff. + * the range : MIN_16 <= var2 <= MAX_16. * * Outputs : * - * *L_varout_h 32 bit long signed integer (Word32) whose value falls in - * the range : 0x8000 0000 <= L_varout_h <= 0x7fff ffff. - * - * *varout_l 16 bit short unsigned integer (UWord16) whose value falls in - * the range : 0x0000 0000 <= varout_l <= 0x0000 ffff. + * none * * Return Value : * - * none + * L40_var_out 40 bit long signed integer (Word40) whose value falls in + * the range : MIN_40 <= L40_var_out <= MAX_40. * *****************************************************************************/ -void Mpy_32_16_ss( Word32 L_var1, Word16 var2, Word32 *L_varout_h, UWord16 *varout_l) { - Word16 var1_h; - UWord16 uvar1_l; - Word40 L40_var1; +Word40 L40_shl (Word40 L40_var1, Word16 var2) { - if( (L_var1 == ( Word32) 0x80000000) - && (var2 == ( Word16) 0x8000)) { - *L_varout_h = 0x7fffffff; - *varout_l = ( UWord16) 0xffff; + Word40 L40_var_out; + Word40 L40_constant = L40_set (0xc000000000); - } else { - uvar1_l = extract_l( L_var1); - var1_h = extract_h( L_var1); + if (var2 < 0) { + var2 = -var2; + L40_var_out = L40_shr (L40_var1, var2); - /* Below line can not overflow, so we can use << instead of L40_shl. */ - L40_var1 = (( Word40) (( Word32) var2 * ( Word32) uvar1_l)) << 1; +#if (WMOPS) + multiCounter[currCounter].L40_shr--; +#endif /* ifdef WMOPS */ + } - *varout_l = Extract40_L( L40_var1); + else { + L40_var_out = L40_var1; - L40_var1 = L40_shr( L40_var1, 16); - L40_var1 = L40_mac( L40_var1, var2, var1_h); + for (; var2 > 0; var2--) { + if (L40_var_out > 0x003fffffffff) { + L40_var_out = L40_OVERFLOW_OCCURED (L40_var_out); + break; + } - *L_varout_h = L_Extract40( L40_var1); + else if (L40_var_out < L40_constant) { + L40_var_out = L40_UNDERFLOW_OCCURED (L40_var_out); + break; + } - #ifdef WMOPS - multiCounter[currCounter].extract_l--; - multiCounter[currCounter].extract_h--; - multiCounter[currCounter].Extract40_L--; - multiCounter[currCounter].L40_shr--; - multiCounter[currCounter].L40_mac--; - multiCounter[currCounter].L_Extract40--; - #endif /* if WMOPS */ - } + else { + L40_var_out = L40_var_out << 1; + } + } + } - #ifdef WMOPS - multiCounter[currCounter].Mpy_32_16_ss++; - #endif /* if WMOPS */ +#if (WMOPS) + multiCounter[currCounter].L40_set--; + multiCounter[currCounter].L40_shl++; +#endif /* ifdef WMOPS */ - return; + return (L40_var_out); } /***************************************************************************** * - * Function Name : Mpy_32_32_ss + * Function Name : L40_shr * * Purpose : * - * Multiplies the 2 signed values L_var1 and L_var2 with saturation control - * on 64-bit. The operation is performed in fractional mode : - * - L_var1 and L_var2 are supposed to be in 1Q31 format. - * - The result is produced in 1Q63 format : L_varout_h points to the - * 32 MSBits while L_varout_l points to the 32 LSBits. + * Arithmetically shifts right L40_var1 by var2 positions. + * - If var2 is positive, L40_var1 is shifted to the LSBits by (var2) + * positions with extension of the sign bit. + * - If var2 is negative, L40_var1 is shifted to the MSBits by (-var2) + * positions. + * Calls the macro L40_UNDERFLOW_OCCURED() in case of underflow on 40-bit. + * Calls the macro L40_OVERFLOW_OCCURED() in case of overflow on 40-bit. * - * Complexity weight : 4 + * Complexity weight : 1 * * Inputs : * - * L_var1 32 bit long signed integer (Word32) whose value falls in the - * range : 0x8000 0000 <= L_var1 <= 0x7fff ffff. + * L40_var1 40 bit long signed integer (Word40) whose value falls in the + * range : MIN_40 <= L40_var1 <= MAX_40. * - * L_var2 32 bit long signed integer (Word32) whose value falls in the - * range : 0x8000 0000 <= L_var2 <= 0x7fff ffff. + * var2 16 bit short signed integer (Word16) whose value falls in + * the range : MIN_16 <= var2 <= MAX_16. * * Outputs : * - * *L_varout_h 32 bit long signed integer (Word32) whose value falls in - * the range : 0x8000 0000 <= L_varout_h <= 0x7fff ffff. - * - * *L_varout_l 32 bit short unsigned integer (UWord32) whose value falls in - * the range : 0x0000 0000 <= L_varout_l <= 0xffff ffff. - * + * none * * Return Value : * - * none + * L40_var_out 40 bit long signed integer (Word40) whose value falls in + * the range : MIN_40 <= L40_var_out <= MAX_40. * *****************************************************************************/ -void Mpy_32_32_ss( Word32 L_var1, Word32 L_var2, Word32 *L_varout_h, UWord32 *L_varout_l) { - UWord16 uvar1_l, uvar2_l; - Word16 var1_h, var2_h; - Word40 L40_var1; - - if( (L_var1 == ( Word32)0x80000000) - && (L_var2 == ( Word32)0x80000000)) { - *L_varout_h = 0x7fffffff; - *L_varout_l = ( UWord32)0xffffffff; +Word40 L40_shr (Word40 L40_var1, Word16 var2) { + Word40 L40_var_out; - } else { + if (var2 < 0) { + var2 = -var2; + L40_var_out = L40_shl (L40_var1, var2); - uvar1_l = extract_l( L_var1); - var1_h = extract_h( L_var1); - uvar2_l = extract_l( L_var2); - var2_h = extract_h( L_var2); +#if (WMOPS) + multiCounter[currCounter].L40_shl--; +#endif /* ifdef WMOPS */ - /* Below line can not overflow, so we can use << instead of L40_shl. */ - L40_var1 = (( Word40) (( UWord32) uvar2_l * ( UWord32) uvar1_l)) << 1; + } else { + L40_var_out = L40_var1 >> var2; + } - *L_varout_l = 0x0000ffff & L_Extract40( L40_var1); +#if (WMOPS) + multiCounter[currCounter].L40_shr++; +#endif /* ifdef WMOPS */ - L40_var1 = L40_shr( L40_var1, 16); - L40_var1 = L40_add( L40_var1, (( Word40) (( Word32) var2_h * ( Word32) uvar1_l)) << 1); - L40_var1 = L40_add( L40_var1, (( Word40) (( Word32) var1_h * ( Word32) uvar2_l)) << 1); - *L_varout_l |= (L_Extract40( L40_var1)) << 16; - - L40_var1 = L40_shr( L40_var1, 16); - L40_var1 = L40_mac( L40_var1, var1_h, var2_h); - - *L_varout_h = L_Extract40( L40_var1); - - #ifdef WMOPS - multiCounter[currCounter].extract_l-=2; - multiCounter[currCounter].extract_h-=2; - multiCounter[currCounter].L_Extract40-=3; - multiCounter[currCounter].L40_shr-=2; - multiCounter[currCounter].L40_add-=2; - multiCounter[currCounter].L40_mac--; - #endif /* if WMOPS */ - } - - #ifdef WMOPS - multiCounter[currCounter].Mpy_32_32_ss++; - #endif /* if WMOPS */ - - return; + return (L40_var_out); } /***************************************************************************** * - * Function Name : L40_set + * Function Name : L40_negate * * Purpose : * - * Assigns a 40 constant to a Word40 with adequate initialization depending - * on underlying architecture constraints (for example to keep consistency - * of sign bits). Current implementation only validated on MSVC++6.0. + * Negates L40_var1. + * Calls the macro L40_UNDERFLOW_OCCURED() in case of underflow on 40-bit. + * Calls the macro L40_OVERFLOW_OCCURED() in case of overflow on 40-bit. * - * Complexity weight : 3 + * Complexity weight : 1 * * Inputs : * @@ -276,38 +251,29 @@ void Mpy_32_32_ss( Word32 L_var1, Word32 L_var2, Word32 *L_varout_h, UWord32 *L_ * the range : MIN_40 <= L40_var_out <= MAX_40. * *****************************************************************************/ -/*#ifdef _MSC_VER*/ -static __inline Word40 L40_set( Word40 L40_var1) { - Word40 L40_var_out; +Word40 L40_negate (Word40 L40_var1) { + Word40 L40_var_out; -#if defined(_MSC_VER) && (_MSC_VER <= 1200) - L40_var_out = L40_var1 & 0x000000ffffffffff; + L40_var_out = L40_add (~L40_var1, 0x01); - if( L40_var1 & 0x8000000000) - L40_var_out = L40_var_out | 0xffffff0000000000; -#else - L40_var_out = L40_var1 & 0x000000ffffffffffLL; +#if (WMOPS) + multiCounter[currCounter].L40_add--; + multiCounter[currCounter].L40_negate++; +#endif /* ifdef WMOPS */ - if( L40_var1 & 0x8000000000LL) - L40_var_out = L40_var_out | 0xffffff0000000000LL; -#endif - - #ifdef WMOPS - multiCounter[currCounter].L40_set++; - #endif /* if WMOPS */ - - return( L40_var_out); + return (L40_var_out); } -/*#endif*/ /* ifdef _MSC_VER */ /***************************************************************************** * - * Function Name : Extract40_L + * Function Name : L40_add * * Purpose : * - * Returns the bits [15-0] of L40_var1. + * Adds L40_var1 and L40_var2 and returns the 40-bit result. + * Calls the macro L40_UNDERFLOW_OCCURED() in case of underflow on 40-bit. + * Calls the macro L40_OVERFLOW_OCCURED() in case of overflow on 40-bit. * * Complexity weight : 1 * @@ -316,48 +282,61 @@ static __inline Word40 L40_set( Word40 L40_var1) { * L40_var1 40 bit long signed integer (Word40) whose value falls in the * range : MIN_40 <= L40_var1 <= MAX_40. * + * L40_var2 40 bit long signed integer (Word40) whose value falls in the + * range : MIN_40 <= L40_var2 <= MAX_40. + * * Outputs : * * none * * Return Value : * - * var_out 16 bit short unsigned integer (UWord16) whose value falls in - * the range : MIN_U_16 <= var_out <= MAX_U_16. + * L40_var_out 40 bit long signed integer (Word40) whose value falls in + * the range : MIN_40 <= L40_var_out <= MAX_40. * *****************************************************************************/ -static __inline UWord16 Extract40_L( Word40 L40_var1) { - UWord16 var_out; - - var_out = ( UWord16)( L40_var1); - - #ifdef WMOPS - multiCounter[currCounter].Extract40_L++; - #endif /* if WMOPS */ - - return( var_out); +Word40 L40_add (Word40 L40_var1, Word40 L40_var2) { + Word40 L40_var_out; + + L40_var_out = L40_var1 + L40_var2; + + if ((((L40_var1 & 0x8000000000) >> 39) != 0) + && (((L40_var2 & 0x8000000000) >> 39) != 0) + && (((L40_var_out & 0x8000000000) >> 39) == 0)) { + L40_var_out = L40_UNDERFLOW_OCCURED (L40_var_out); + + } else if ((((L40_var1 & 0x8000000000) >> 39) == 0) + && (((L40_var2 & 0x8000000000) >> 39) == 0) + && (((L40_var_out & 0x8000000000) >> 39) != 0)) { + L40_var_out = L40_OVERFLOW_OCCURED (L40_var_out); + } +#if (WMOPS) + multiCounter[currCounter].L40_add++; +#endif /* ifdef WMOPS */ + + return (L40_var_out); } /***************************************************************************** * - * Function Name : L40_mult + * Function Name : L40_sub * * Purpose : * - * Multiplies var1 by var2 and shifts the result left by 1. Returns the - * full precision result on 40-bit. - * L40_mult( var1, var2) = shiftleft(( var1 times var2), 1) + * Subtracts L40_var2 from L40_var1. + * Calls the macro L40_UNDERFLOW_OCCURED() in case of underflow on 40-bit. + * Calls the macro L40_OVERFLOW_OCCURED() in case of overflow on 40-bit. * * Complexity weight : 1 * * Inputs : * - * var1 16 bit short signed integer (Word16) whose value falls in - * the range : MIN_16 <= var1 <= MAX_16. + * L40_var1 40 bit long signed integer (Word40) whose value falls in the + * range : MIN_40 <= L40_var1 <= MAX_40. * - * var2 16 bit short signed integer (Word16) whose value falls in - * the range : MIN_16 <= var2 <= MAX_16. + * L40_var2 40 bit long signed integer (Word40) whose value falls in the + * range : MIN_40 <= L40_var2 <= MAX_40. * * Outputs : * @@ -369,32 +348,86 @@ static __inline UWord16 Extract40_L( Word40 L40_var1) { * the range : MIN_40 <= L40_var_out <= MAX_40. * *****************************************************************************/ -static __inline Word40 L40_mult( Word16 var1, Word16 var2) { - Word32 L_var_out; - Word40 L40_var_out; +Word40 L40_sub (Word40 L40_var1, Word40 L40_var2) { + Word40 L40_var_out; + + L40_var_out = L40_var1 - L40_var2; + + if ((((L40_var1 & 0x8000000000) >> 39) != 0) + && (((L40_var2 & 0x8000000000) >> 39) == 0) + && (((L40_var_out & 0x8000000000) >> 39) == 0)) { + L40_var_out = L40_UNDERFLOW_OCCURED (L40_var_out); + + } else if ((((L40_var1 & 0x8000000000) >> 39) == 0) + && (((L40_var2 & 0x8000000000) >> 39) != 0) + && (((L40_var_out & 0x8000000000) >> 39) != 0)) { + L40_var_out = L40_OVERFLOW_OCCURED (L40_var_out); + } +#if (WMOPS) + multiCounter[currCounter].L40_sub++; +#endif /* ifdef WMOPS */ + + return (L40_var_out); +} + + +/***************************************************************************** + * + * Function Name : L40_abs + * + * Purpose : + * + * Returns the absolute value of L40_var1. + * Calls the macro L40_UNDERFLOW_OCCURED() in case of underflow on 40-bit. + * Calls the macro L40_OVERFLOW_OCCURED() in case of overflow on 40-bit. + * + * Complexity weight : 1 + * + * Inputs : + * + * L40_var1 40 bit long signed integer (Word40) whose value falls in the + * range : MIN_40 <= L40_var1 <= MAX_40. + * + * Outputs : + * + * none + * + * Return Value : + * + * L40_var_out 40 bit long signed integer (Word40) whose value falls in + * the range : 0x00 0000 0000 <= L40_var_out <= MAX_40. + * + *****************************************************************************/ +Word40 L40_abs (Word40 L40_var1) { + Word40 L40_var_out; + + if (L40_var1 < 0) { + L40_var_out = L40_negate (L40_var1); - L_var_out = ( Word32) var1 * ( Word32) var2; - L40_var_out = ( Word40) L_var_out; +#if (WMOPS) + multiCounter[currCounter].L40_negate--; +#endif /* ifdef WMOPS */ - /* Below line can not overflow, so we can use << instead of L40_shl. */ - L40_var_out = L40_var_out << 1; + } else { + L40_var_out = L40_var1; + } - #ifdef WMOPS - multiCounter[currCounter].L40_mult++; - #endif /* if WMOPS */ +#if (WMOPS) + multiCounter[currCounter].L40_abs++; +#endif /* ifdef WMOPS */ - return( L40_var_out); + return (L40_var_out); } + /***************************************************************************** * - * Function Name : L40_add + * Function Name : L40_max * * Purpose : * - * Adds L40_var1 and L40_var2 and returns the 40-bit result. - * Calls the macro L40_UNDERFLOW_OCCURED() in case of underflow on 40-bit. - * Calls the macro L40_OVERFLOW_OCCURED() in case of overflow on 40-bit. + * Compares L40_var1 and L40_var2 and returns the maximum value. + * * * Complexity weight : 1 * @@ -416,56 +449,30 @@ static __inline Word40 L40_mult( Word16 var1, Word16 var2) { * the range : MIN_40 <= L40_var_out <= MAX_40. * *****************************************************************************/ -static __inline Word40 L40_add( Word40 L40_var1, Word40 L40_var2) { - Word40 L40_var_out; - - L40_var_out = L40_var1 + L40_var2; - -#if defined(_MSC_VER) && (_MSC_VER <= 1200) - if( ((( L40_var1 & 0x8000000000) >> 39) != 0) - && ((( L40_var2 & 0x8000000000) >> 39) != 0) - && ((( L40_var_out & 0x8000000000) >> 39) == 0)) { - L40_var_out = L40_UNDERFLOW_OCCURED( L40_var_out); - - } else if( (((L40_var1 & 0x8000000000) >> 39) == 0) - && (((L40_var2 & 0x8000000000) >> 39) == 0) - && (((L40_var_out & 0x8000000000) >> 39) != 0)) { - L40_var_out = L40_OVERFLOW_OCCURED( L40_var_out); - } -#else - if( ((( L40_var1 & 0x8000000000LL) >> 39) != 0) - && ((( L40_var2 & 0x8000000000LL) >> 39) != 0) - && ((( L40_var_out & 0x8000000000LL) >> 39) == 0)) { - L40_var_out = L40_UNDERFLOW_OCCURED( L40_var_out); - - } else if( (((L40_var1 & 0x8000000000LL) >> 39) == 0) - && (((L40_var2 & 0x8000000000LL) >> 39) == 0) - && (((L40_var_out & 0x8000000000LL) >> 39) != 0)) { - L40_var_out = L40_OVERFLOW_OCCURED( L40_var_out); - } -#endif - - #ifdef WMOPS - multiCounter[currCounter].L40_add++; - #endif /* if WMOPS */ - - BASOP_CHECK(); - - return( L40_var_out); +Word40 L40_max (Word40 L40_var1, Word40 L40_var2) { + Word40 L40_var_out; + + if (L40_var1 < L40_var2) + L40_var_out = L40_var2; + else + L40_var_out = L40_var1; + +#if (WMOPS) + multiCounter[currCounter].L40_max++; +#endif /* ifdef WMOPS */ + + return (L40_var_out); } + /***************************************************************************** * - * Function Name : L40_mac + * Function Name : L40_min * * Purpose : * - * Multiplies var2 by var3. Shifts left the 40-bit result by 1 and adds - * the result to L40_var1. Returns a 40 bit result. - * L40_mac( L40_var1, var2, var3) - * = L40_add( L40_var1, L40_mult( var2, var3)) - * Calls the macro L40_UNDERFLOW_OCCURED() in case of underflow on 40-bit. - * Calls the macro L40_OVERFLOW_OCCURED() in case of overflow on 40-bit. + * Compares L40_var1 and L40_var2 and returns the minimum value. + * * * Complexity weight : 1 * @@ -474,11 +481,8 @@ static __inline Word40 L40_add( Word40 L40_var1, Word40 L40_var2) { * L40_var1 40 bit long signed integer (Word40) whose value falls in the * range : MIN_40 <= L40_var1 <= MAX_40. * - * var2 16 bit short signed integer (Word16) whose value falls in - * the range : MIN_16 <= var2 <= MAX_16. - * - * var3 16 bit short signed integer (Word16) whose value falls in - * the range : MIN_16 <= var3 <= MAX_16. + * L40_var2 40 bit long signed integer (Word40) whose value falls in the + * range : MIN_40 <= L40_var2 <= MAX_40. * * Outputs : * @@ -490,28 +494,31 @@ static __inline Word40 L40_add( Word40 L40_var1, Word40 L40_var2) { * the range : MIN_40 <= L40_var_out <= MAX_40. * *****************************************************************************/ -static __inline Word40 L40_mac( Word40 L40_var1, Word16 var2, Word16 var3) { - Word40 L40_var_out; +Word40 L40_min (Word40 L40_var1, Word40 L40_var2) { + Word40 L40_var_out; - L40_var_out = L40_mult( var2, var3); - L40_var_out = L40_add( L40_var1, L40_var_out); + if (L40_var1 < L40_var2) + L40_var_out = L40_var1; + else + L40_var_out = L40_var2; - #ifdef WMOPS - multiCounter[currCounter].L40_mult--; - multiCounter[currCounter].L40_add--; - multiCounter[currCounter].L40_mac++; - #endif /* if WMOPS */ +#if (WMOPS) + multiCounter[currCounter].L40_min++; +#endif /* ifdef WMOPS */ - return( L40_var_out); + return (L40_var_out); } + /***************************************************************************** * - * Function Name : L_Extract40 + * Function Name : L_saturate40 * * Purpose : * - * Returns the bits [31-0] of L40_var1. + * If L40_var1 is greater than MAX_32, returns MAX_32. + * If L40_var1 is lower than MIN_32, returns MIN_32. + * If not, returns L_Extract40( L40_var1). * * Complexity weight : 1 * @@ -526,36 +533,212 @@ static __inline Word40 L40_mac( Word40 L40_var1, Word16 var2, Word16 var3) { * * Return Value : * - * L_var_out 32 bit long unsigned integer (UWord32) whose value falls in - * range : MIN_U_32 <= L_var_out <= MAX_U_32. + * L_var_out 32 bit long signed integer (Word32) whose value falls in + * the range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. * *****************************************************************************/ -static __inline UWord32 L_Extract40( Word40 L40_var1) { - UWord32 L_var_out; +Word32 L_saturate40 (Word40 L40_var1) { + Word32 L_var_out; + + Word40 UNDER_L40_var2 = (Word40) ~ ((((Word40) 1) << 31) - (Word40) 1); + Word40 OVER_L40_var2 = (Word40) ((((Word40) 1) << 31) - (Word40) 1); + + if (L40_var1 < UNDER_L40_var2) { + L40_var1 = UNDER_L40_var2; + Overflow = 1; + } - L_var_out = ( UWord32) L40_var1; + if (L40_var1 > OVER_L40_var2) { + L40_var1 = OVER_L40_var2; + Overflow = 1; + } - #ifdef WMOPS - multiCounter[currCounter].L_Extract40++; - #endif /* if WMOPS */ + L_var_out = L_Extract40 (L40_var1); - return(L_var_out); +#if (WMOPS) + multiCounter[currCounter].L_Extract40--; + multiCounter[currCounter].L_saturate40++; +#endif /* ifdef WMOPS */ + + return (L_var_out); } /***************************************************************************** * - * Function Name : L40_shl + * Function Name : Mpy_32_16_ss * * Purpose : * - * Arithmetically shifts left L40_var1 by var2 positions. + * Multiplies the 2 signed values L_var1 and var2 with saturation control + * on 48-bit. The operation is performed in fractional mode : + * - L_var1 is supposed to be in 1Q31 format. + * - var2 is supposed to be in 1Q15 format. + * - The result is produced in 1Q47 format : L_varout_h points to the + * 32 MSBits while varout_l points to the 16 LSBits. + * + * Complexity weight : 2 + * + * Inputs : + * + * L_var1 32 bit long signed integer (Word32) whose value falls in + * the range : 0x8000 0000 <= L_var1 <= 0x7fff ffff. + * + * var2 16 bit short signed integer (Word16) whose value falls in + * the range : 0xffff 8000 <= var2 <= 0x0000 7fff. + * + * Outputs : + * + * *L_varout_h 32 bit long signed integer (Word32) whose value falls in + * the range : 0x8000 0000 <= L_varout_h <= 0x7fff ffff. + * + * *varout_l 16 bit short unsigned integer (UWord16) whose value falls in + * the range : 0x0000 0000 <= varout_l <= 0x0000 ffff. + * + * Return Value : + * + * none + * + *****************************************************************************/ +void Mpy_32_16_ss (Word32 L_var1, Word16 var2, Word32 * L_varout_h, UWord16 * varout_l) { + Word16 var1_h; + UWord16 uvar1_l; + Word40 L40_var1; + + if ((L_var1 == (Word32) 0x80000000) + && (var2 == (Word16) 0x8000)) { + *L_varout_h = 0x7fffffff; + *varout_l = (UWord16) 0xffff; + + } else { + uvar1_l = extract_l (L_var1); + var1_h = extract_h (L_var1); + + /* Below line can not overflow, so we can use << instead of L40_shl. */ + L40_var1 = ((Word40) ((Word32) var2 * (Word32) uvar1_l)) << 1; + + *varout_l = Extract40_L (L40_var1); + + L40_var1 = L40_shr (L40_var1, 16); + L40_var1 = L40_mac (L40_var1, var2, var1_h); + + *L_varout_h = L_Extract40 (L40_var1); + +#if(WMOPS) + multiCounter[currCounter].extract_l--; + multiCounter[currCounter].extract_h--; + multiCounter[currCounter].Extract40_L--; + multiCounter[currCounter].L40_shr--; + multiCounter[currCounter].L40_mac--; + multiCounter[currCounter].L_Extract40--; +#endif /* ifdef WMOPS */ + } + +#if (WMOPS) + multiCounter[currCounter].Mpy_32_16_ss++; +#endif /* ifdef WMOPS */ + + return; +} + + +/***************************************************************************** + * + * Function Name : Mpy_32_32_ss + * + * Purpose : + * + * Multiplies the 2 signed values L_var1 and L_var2 with saturation control + * on 64-bit. The operation is performed in fractional mode : + * - L_var1 and L_var2 are supposed to be in 1Q31 format. + * - The result is produced in 1Q63 format : L_varout_h points to the + * 32 MSBits while L_varout_l points to the 32 LSBits. + * + * Complexity weight : 4 + * + * Inputs : + * + * L_var1 32 bit long signed integer (Word32) whose value falls in the + * range : 0x8000 0000 <= L_var1 <= 0x7fff ffff. + * + * L_var2 32 bit long signed integer (Word32) whose value falls in the + * range : 0x8000 0000 <= L_var2 <= 0x7fff ffff. + * + * Outputs : + * + * *L_varout_h 32 bit long signed integer (Word32) whose value falls in + * the range : 0x8000 0000 <= L_varout_h <= 0x7fff ffff. + * + * *L_varout_l 32 bit short unsigned integer (UWord32) whose value falls in + * the range : 0x0000 0000 <= L_varout_l <= 0xffff ffff. + * + * + * Return Value : + * + * none + * + *****************************************************************************/ +void Mpy_32_32_ss (Word32 L_var1, Word32 L_var2, Word32 * L_varout_h, UWord32 * L_varout_l) { + UWord16 uvar1_l, uvar2_l; + Word16 var1_h, var2_h; + Word40 L40_var1; + + if ((L_var1 == (Word32) 0x80000000) + && (L_var2 == (Word32) 0x80000000)) { + *L_varout_h = 0x7fffffff; + *L_varout_l = (UWord32) 0xffffffff; + + } else { + + uvar1_l = extract_l (L_var1); + var1_h = extract_h (L_var1); + uvar2_l = extract_l (L_var2); + var2_h = extract_h (L_var2); + + /* Below line can not overflow, so we can use << instead of L40_shl. */ + L40_var1 = ((Word40) ((UWord32) uvar2_l * (UWord32) uvar1_l)) << 1; + + *L_varout_l = 0x0000ffff & L_Extract40 (L40_var1); + + L40_var1 = L40_shr (L40_var1, 16); + L40_var1 = L40_add (L40_var1, ((Word40) ((Word32) var2_h * (Word32) uvar1_l)) << 1); + L40_var1 = L40_add (L40_var1, ((Word40) ((Word32) var1_h * (Word32) uvar2_l)) << 1); + *L_varout_l |= (L_Extract40 (L40_var1)) << 16; + + L40_var1 = L40_shr (L40_var1, 16); + L40_var1 = L40_mac (L40_var1, var1_h, var2_h); + + *L_varout_h = L_Extract40 (L40_var1); + +#if (WMOPS) + multiCounter[currCounter].extract_l -= 2; + multiCounter[currCounter].extract_h -= 2; + multiCounter[currCounter].L_Extract40 -= 3; + multiCounter[currCounter].L40_shr -= 2; + multiCounter[currCounter].L40_add -= 2; + multiCounter[currCounter].L40_mac--; +#endif /* ifdef WMOPS */ + } + +#if (WMOPS) + multiCounter[currCounter].Mpy_32_32_ss++; +#endif /* ifdef WMOPS */ + + return; +} + + +/***************************************************************************** + * + * Function Name : L40_lshl + * + * Purpose : + * + * Logically shifts left L40_var1 by var2 positions. * - If var2 is negative, L40_var1 is shifted to the LSBits by (-var2) - * positions with extension of the sign bit. + * positions with insertion of 0 at the MSBit. * - If var2 is positive, L40_var1 is shifted to the MSBits by (var2) * positions. - * Calls the macro L40_UNDERFLOW_OCCURED() in case of underflow on 40-bit. - * Calls the macro L40_OVERFLOW_OCCURED() in case of overflow on 40-bit. * * Complexity weight : 1 * @@ -577,72 +760,49 @@ static __inline UWord32 L_Extract40( Word40 L40_var1) { * the range : MIN_40 <= L40_var_out <= MAX_40. * *****************************************************************************/ -static __inline Word40 L40_shl( Word40 L40_var1, Word16 var2) { - - Word40 L40_var_out; -#if defined(_MSC_VER) && (_MSC_VER <= 1200) - Word40 L40_constant = L40_set( 0xc000000000); -#else - Word40 L40_constant = L40_set( 0xc000000000LL); -#endif - - if( var2 < 0) { - var2 = -var2; - L40_var_out = L40_shr( L40_var1, var2); - - #ifdef WMOPS - multiCounter[currCounter].L40_shr--; - #endif /* if WMOPS */ - } - - else { - L40_var_out = L40_var1; - - for ( ; var2 > 0; var2--) { -#if defined(_MSC_VER) && (_MSC_VER <= 1200) - if( L40_var_out > 0x003fffffffff) { -#else - if( L40_var_out > 0x003fffffffffLL) { -#endif - L40_var_out = L40_OVERFLOW_OCCURED( L40_var_out); - break; - } - - else if ( L40_var_out < L40_constant) { - L40_var_out = L40_UNDERFLOW_OCCURED( L40_var_out); - break; - } - - else { - L40_var_out = L40_var_out << 1; - } - } - } +Word40 L40_lshl (Word40 L40_var1, Word16 var2) { + Word40 L40_var_out; - #ifdef WMOPS - multiCounter[currCounter].L40_set--; - multiCounter[currCounter].L40_shl++; - #endif /* if WMOPS */ + if (var2 <= 0) { + var2 = -var2; + L40_var_out = L40_lshr (L40_var1, var2); - BASOP_CHECK(); +#if (WMOPS) + multiCounter[currCounter].L40_lshr--; +#endif /* ifdef WMOPS */ - return( L40_var_out); + } else { + if (var2 >= 40) + L40_var_out = 0x0000000000; + else + L40_var_out = L40_var1 << var2; + + L40_var_out = L40_set (L40_var_out); + +#if (WMOPS) + multiCounter[currCounter].L40_set--; +#endif /* ifdef WMOPS */ + } + +#if (WMOPS) + multiCounter[currCounter].L40_lshl++; +#endif /* ifdef WMOPS */ + + return (L40_var_out); } /***************************************************************************** * - * Function Name : L40_shr + * Function Name : L40_lshr * * Purpose : * - * Arithmetically shifts right L40_var1 by var2 positions. + * Logically shifts right L40_var1 by var2 positions. * - If var2 is positive, L40_var1 is shifted to the LSBits by (var2) - * positions with extension of the sign bit. + * positions with insertion of 0 at the MSBit. * - If var2 is negative, L40_var1 is shifted to the MSBits by (-var2) * positions. - * Calls the macro L40_UNDERFLOW_OCCURED() in case of underflow on 40-bit. - * Calls the macro L40_OVERFLOW_OCCURED() in case of overflow on 40-bit. * * Complexity weight : 1 * @@ -653,7 +813,7 @@ static __inline Word40 L40_shl( Word40 L40_var1, Word16 var2) { * * var2 16 bit short signed integer (Word16) whose value falls in * the range : MIN_16 <= var2 <= MAX_16. - * +* * Outputs : * * none @@ -664,27 +824,222 @@ static __inline Word40 L40_shl( Word40 L40_var1, Word16 var2) { * the range : MIN_40 <= L40_var_out <= MAX_40. * *****************************************************************************/ -static __inline Word40 L40_shr( Word40 L40_var1, Word16 var2) { - Word40 L40_var_out; +Word40 L40_lshr (Word40 L40_var1, Word16 var2) { + Word40 L40_var_out; + + if (var2 < 0) { + var2 = -var2; + L40_var_out = L40_lshl (L40_var1, var2); + +#if (WMOPS) + multiCounter[currCounter].L40_lshl--; +#endif /* ifdef WMOPS */ + } else { + if (var2 >= 40) + L40_var_out = 0x0000000000; + else + L40_var_out = (L40_var1 & 0xffffffffff) >> var2; + } + +#if (WMOPS) + multiCounter[currCounter].L40_lshr++; +#endif /* ifdef WMOPS */ + + return (L40_var_out); +} - if( var2 < 0) { - var2 = -var2; - L40_var_out = L40_shl ( L40_var1, var2); - #ifdef WMOPS +/***************************************************************************** + * + * Function Name : norm_L40 + * + * Purpose : + * + * Produces the number of left shifts needed to normalize in 32 bit format + * the 40 bit variable L40_var1. This returned value can be used to scale + * L_40_var1 into the following intervals : + * - [(MAX_32+1)/2 .. MAX_32 ] for positive values. + * - [ MIN_32 .. (MIN_32/2)+1 ] for negative values. + * - [ 0 .. 0 ] for null values. + * In order to normalize the result, the following operation must be done : + * normelized_L40_var1 = L40_shl( L40_var1, norm_L40( L40_var1)) + * + * Complexity weight : 1 + * + * Inputs : + * + * L40_var1 40 bit long signed integer (Word40) whose value falls in the + * range : MIN_40 <= L40_var1 <= MAX_40. + * + * Outputs : + * + * none + * + * Return Value : + * + * var_out 16 bit short signed integer (Word16) whose value falls in + * the range : -8 <= var_out <= 31. + * + *****************************************************************************/ +Word16 norm_L40 (Word40 L40_var1) { + Word16 var_out; + + var_out = 0; + + if (L40_var1 != 0) { + while ((L40_var1 > (Word32) 0x80000000L) + && (L40_var1 < (Word32) 0x7fffffffL)) { + + L40_var1 = L40_shl (L40_var1, 1); + var_out++; + +#ifdef WMOPS + multiCounter[currCounter].L40_shl--; +#endif /* ifdef WMOPS */ + } + + while ((L40_var1 < (Word32) 0x80000000L) + || (L40_var1 > (Word32) 0x7fffffffL)) { + + L40_var1 = L40_shl (L40_var1, -1); + var_out--; + +#ifdef WMOPS multiCounter[currCounter].L40_shl--; - #endif /* if WMOPS */ +#endif /* ifdef WMOPS */ + } + } +#ifdef WMOPS + multiCounter[currCounter].norm_L40++; +#endif /* ifdef WMOPS */ + + return (var_out); +} + + + + + + +/***************************************************************************** + * + * Function Name : L40_shr_r + * + * Purpose : + * + * Arithmetically shifts right L40_var1 by var2 positions and rounds the + * result. It is equivalent to L40_shr( L40_var1, var2) except that if the + * last bit shifted out to the LSBit is 1, then the shifted result is + * incremented by 1. + * Calls the macro L40_UNDERFLOW_OCCURED() in case of underflow on 40-bit. + * Calls the macro L40_OVERFLOW_OCCURED() in case of overflow on 40-bit. + * + * Complexity weight : 3 + * + * Inputs : + * + * L40_var1 40 bit long signed integer (Word40) whose value falls in the + * range : MIN_40 <= L40_var1 <= MAX_40. + * + * var2 16 bit short signed integer (Word16) whose value falls in + * the range : 0xffff 8000 <= var2 <= 0x0000 7fff. + * + * Outputs : + * + * none + * + * Return Value : + * + * L40_var_out 40 bit long signed integer (Word40) whose value falls in + * the range : MIN_40 <= L40_var_out <= MAX_40. + * + *****************************************************************************/ +Word40 L40_shr_r (Word40 L40_var1, Word16 var2) { + Word40 L40_var_out; + + if (var2 > 39) { + L40_var_out = 0; - } else { - L40_var_out = L40_var1 >> var2; + } else { + L40_var_out = L40_shr (L40_var1, var2); - } +#if (WMOPS) + multiCounter[currCounter].L40_shr--; +#endif /* ifdef WMOPS */ - #ifdef WMOPS - multiCounter[currCounter].L40_shr++; - #endif /* if WMOPS */ + if (var2 > 0) { + if ((L40_var1 & ((Word40) 1 << (var2 - 1))) != 0) { + /* below line can not generate overflows on 40-bit */ + L40_var_out++; + } + } + } + +#if (WMOPS) + multiCounter[currCounter].L40_shr_r++; +#endif /* ifdef WMOPS */ - return( L40_var_out); + return (L40_var_out); } + +/***************************************************************************** + * + * Function Name : L40_shl_r + * + * Purpose : + * + * Arithmetically shifts left L40_var1 by var2 positions and rounds the + * result. It is equivalent to L40_shl( L40_var1, var2) except if var2 is + * negative. In that case, it does the same as + * L40_shr_r( L40_var1, (-var2)). + * Calls the macro L40_UNDERFLOW_OCCURED() in case of underflow on 40-bit. + * Calls the macro L40_OVERFLOW_OCCURED() in case of overflow on 40-bit. + * + * Complexity weight : 3 + * + * Inputs : + * + * L40_var1 40 bit long signed integer (Word40) whose value falls in the + * range : MIN_40 <= L40_var1 <= MAX_40. + * + * var2 16 bit short signed integer (Word16) whose value falls in + * the range : 0xffff 8000 <= var2 <= 0x0000 7fff. + * + * Outputs : + * + * none + * + * Return Value : + * + * L40_var_out 40 bit long signed integer (Word40) whose value falls in + * the range : MIN_40 <= L40_var_out <= MAX_40. + * + *****************************************************************************/ +Word40 L40_shl_r (Word40 L40_var1, Word16 var2) { + Word40 L40_var_out; + + if (var2 >= 0) { + L40_var_out = L40_shl (L40_var1, var2); + +#if (WMOPS) + multiCounter[currCounter].L40_shl--; +#endif /* ifdef WMOPS */ + + } else { + var2 = -var2; + L40_var_out = L40_shr_r (L40_var1, var2); + +#if (WMOPS) + multiCounter[currCounter].L40_shr_r--; +#endif /* ifdef WMOPS */ + } +#if (WMOPS) + multiCounter[currCounter].L40_shl_r++; +#endif /* ifdef WMOPS */ + + return (L40_var_out); +} + + /* end of file */ diff --git a/basic_op/enh40.h b/basic_op/enh40.h index b3520e84c1dd8fd0e33828f6f1619e7bcfa5ea1f..69ab7fc58a837548055b4fabae01236c8bc605b9 100644 --- a/basic_op/enh40.h +++ b/basic_op/enh40.h @@ -9,14 +9,11 @@ History: 07 Nov 04 v2.0 Incorporation of new 32-bit / 40-bit / control - operators for the ITU-T Standard Tool Library as + operators for the ITU-T Standard Tool Library as described in Geneva, 20-30 January 2004 WP 3/16 Q10/16 TD 11 document and subsequent discussions on the wp3audio@yahoogroups.com email reflector. - - March 06 v2.1 Changed to improve portability. - - 31 Mar 15 v2.1E Removal of operators not used in the EVS codec. + March 06 v2.1 Changed to improve portability. ============================================================================ */ @@ -25,20 +22,818 @@ #ifndef _ENH40_H #define _ENH40_H + #include "stl.h" - + + +#ifdef WMOPS +extern BASIC_OP multiCounter[MAXCOUNTERS]; +extern int currCounter; +#endif /* ifdef WMOPS */ + + +/***************************************************************************** + * + * Constants and Globals + * + *****************************************************************************/ +#ifdef _MSC_VER +#define MAX_40 (0x0000007fffffffff) +#define MIN_40 (0xffffff8000000000) +#endif /* ifdef _MSC_VER */ + + + +/***************************************************************************** + * + * Macros for 40 bit arithmetic overflow management : + * Upon 40-bit overflow beyond MAX_40 or underflow beyond MIN_40, + * the application will exit. + * + *****************************************************************************/ +#define L40_OVERFLOW_OCCURED( L40_var1) (Overflow = 1, exit(1), L40_var1) +#define L40_UNDERFLOW_OCCURED( L40_var1) (Overflow = 1, exit(2), L40_var1) + + + /***************************************************************************** * * Prototypes for enhanced 40 bit arithmetic operators * *****************************************************************************/ +Word40 L40_shr (Word40 L40_var1, Word16 var2); +Word40 L40_shr_r (Word40 L40_var1, Word16 var2); +Word40 L40_shl (Word40 L40_var1, Word16 var2); +Word40 L40_shl_r (Word40 L40_var1, Word16 var2); -void Mpy_32_16_ss( Word32 L_var1, Word16 var2, Word32 *L_varout_h, UWord16 *varout_l); -void Mpy_32_32_ss( Word32 L_var1, Word32 L_var2, Word32 *L_varout_h, UWord32 *L_varout_l); +static __inline Word40 L40_mult (Word16 var1, Word16 var2); -#endif /*_ENH40_H*/ +static __inline Word40 L40_mac (Word40 L40_var1, Word16 var1, Word16 var2); +static __inline Word16 mac_r40 (Word40 L40_var1, Word16 var1, Word16 var2); +static __inline Word40 L40_msu (Word40 L40_var1, Word16 var1, Word16 var2); +static __inline Word16 msu_r40 (Word40 L40_var1, Word16 var1, Word16 var2); -/* end of file */ +void Mpy_32_16_ss (Word32 L_var1, Word16 var2, Word32 * L_varout_h, UWord16 * varout_l); +void Mpy_32_32_ss (Word32 L_var1, Word32 L_var2, Word32 * L_varout_h, UWord32 * L_varout_l); + + +Word40 L40_lshl (Word40 L40_var1, Word16 var2); +Word40 L40_lshr (Word40 L40_var1, Word16 var2); + +static __inline Word40 L40_set (Word40 L40_var1); +static __inline UWord16 Extract40_H (Word40 L40_var1); +static __inline UWord16 Extract40_L (Word40 L40_var1); +static __inline UWord32 L_Extract40 (Word40 L40_var1); + +static __inline Word40 L40_deposit_h (Word16 var1); +static __inline Word40 L40_deposit_l (Word16 var1); +static __inline Word40 L40_deposit32 (Word32 L_var1); + +static __inline Word40 L40_round (Word40 L40_var1); +static __inline Word16 round40 (Word40 L40_var1); + + +Word40 L40_add (Word40 L40_var1, Word40 L40_var2); +Word40 L40_sub (Word40 L40_var1, Word40 L40_var2); +Word40 L40_abs (Word40 L40_var1); +Word40 L40_negate (Word40 L40_var1); +Word40 L40_max (Word40 L40_var1, Word40 L40_var2); +Word40 L40_min (Word40 L40_var1, Word40 L40_var2); +Word32 L_saturate40 (Word40 L40_var1); +Word16 norm_L40 (Word40 L40_var1); + + +/***************************************************************************** + * + * Functions + * + *****************************************************************************/ + +/***************************************************************************** + * + * Function Name : L40_set + * + * Purpose : + * + * Assigns a 40 constant to a Word40 with adequate initialization depending + * on underlying architecture constraints (for example to keep consistency + * of sign bits). Current implementation only validated on MSVC++6.0. + * + * Complexity weight : 3 + * + * Inputs : + * + * L40_var1 40 bit long signed integer (Word40) whose value falls in the + * range : MIN_40 <= L40_var1 <= MAX_40. + * + * Outputs : + * + * none + * + * Return Value : + * + * L40_var_out 40 bit long signed integer (Word40) whose value falls in + * the range : MIN_40 <= L40_var_out <= MAX_40. + * + *****************************************************************************/ +/*#ifdef _MSC_VER*/ +static __inline Word40 L40_set (Word40 L40_var1) { + Word40 L40_var_out; + + L40_var_out = L40_var1 & 0x000000ffffffffff; + + if (L40_var1 & 0x8000000000) + L40_var_out = L40_var_out | 0xffffff0000000000; + +#ifdef WMOPS + multiCounter[currCounter].L40_set++; +#endif /* ifdef WMOPS */ + + return (L40_var_out); +} + +/* #endif */ /* ifdef _MSC_VER */ + + +/***************************************************************************** + * + * Function Name : Extract40_H + * + * Purpose : + * + * Returns the bits [31-16] of L40_var1. + * + * Complexity weight : 1 + * + * Inputs : + * + * L40_var1 40 bit long signed integer (Word40) whose value falls in the + * range : MIN_40 <= L40_var1 <= MAX_40. + * + * Outputs : + * + * none + * + * Return Value : + * + * var_out 16 bit short unsigned integer (UWord16) whose value falls in + * the range : MIN_U_16 <= var_out <= MAX_U_16. + * + *****************************************************************************/ +static __inline UWord16 Extract40_H (Word40 L40_var1) { + UWord16 var_out; + + var_out = (UWord16) (L40_var1 >> 16); + +#if (WMOPS) + multiCounter[currCounter].Extract40_H++; +#endif /* ifdef WMOPS */ + + return (var_out); +} + + +/***************************************************************************** + * + * Function Name : Extract40_L + * + * Purpose : + * + * Returns the bits [15-0] of L40_var1. + * + * Complexity weight : 1 + * + * Inputs : + * + * L40_var1 40 bit long signed integer (Word40) whose value falls in the + * range : MIN_40 <= L40_var1 <= MAX_40. + * + * Outputs : + * + * none + * + * Return Value : + * + * var_out 16 bit short unsigned integer (UWord16) whose value falls in + * the range : MIN_U_16 <= var_out <= MAX_U_16. + * + *****************************************************************************/ +static __inline UWord16 Extract40_L (Word40 L40_var1) { + UWord16 var_out; + + var_out = (UWord16) (L40_var1); + +#if (WMOPS) + multiCounter[currCounter].Extract40_L++; +#endif /* ifdef WMOPS */ + + return (var_out); +} + + +/***************************************************************************** + * + * Function Name : L_Extract40 + * + * Purpose : + * + * Returns the bits [31-0] of L40_var1. + * + * Complexity weight : 1 + * + * Inputs : + * + * L40_var1 40 bit long signed integer (Word40) whose value falls in the + * range : MIN_40 <= L40_var1 <= MAX_40. + * + * Outputs : + * + * none + * + * Return Value : + * + * L_var_out 32 bit long unsigned integer (UWord32) whose value falls in + * range : MIN_U_32 <= L_var_out <= MAX_U_32. + * + *****************************************************************************/ +static __inline UWord32 L_Extract40 (Word40 L40_var1) { + UWord32 L_var_out; + + L_var_out = (UWord32) L40_var1; + +#if (WMOPS) + multiCounter[currCounter].L_Extract40++; +#endif /* ifdef WMOPS */ + + return (L_var_out); +} + + +/***************************************************************************** + * + * Function Name : L40_deposit_h + * + * Purpose : + * + * Deposits var1 in the bits [31-16] in a 40-bit number. The 16 LSBits of + * the output are zeroed and the 8 MSBits sign extend var1 sign bit. + * + * Complexity weight : 1 + * + * Inputs : + * + * var1 16 bit short signed integer (Word16) whose value falls in + * the range : MIN_16 <= var1 <= MAX_16. + * + * Outputs : + * + * none + * + * Return Value : + * + * L40_var_out 40 bit long signed integer (Word40) whose value falls in + * the range : MIN_40 <= L40_var_out <= MAX_40. + * + *****************************************************************************/ +static __inline Word40 L40_deposit_h (Word16 var1) { + Word40 L40_var_out; + + L40_var_out = ((Word40) var1) << 16; + + if (var1 & 0x8000) { + L40_var_out = L40_set (L40_var_out | 0xff00000000); + +#if (WMOPS) + multiCounter[currCounter].L40_set--; +#endif /* ifdef WMOPS */ + } +#if (WMOPS) + multiCounter[currCounter].L40_deposit_h++; +#endif /* ifdef WMOPS */ + + return (L40_var_out); +} + + +/***************************************************************************** + * + * Function Name : L40_deposit_l + * + * Purpose : + * + * Deposits var1 in the bits [15-0] in a 40-bit number. The 24 MSBits sign + * extend var1 sign bit. + * + * Complexity weight : 1 + * + * Inputs : + * + * var1 16 bit short signed integer (Word16) whose value falls in + * the range : MIN_16 <= var1 <= MAX_16. + * + * Outputs : + * + * none + * + * Return Value : + * + * L40_var_out 40 bit long signed integer (Word40) whose value falls in + * the range : MIN_40 <= L40_var_out <= MAX_40. + * + *****************************************************************************/ +static __inline Word40 L40_deposit_l (Word16 var1) { + Word40 L40_var_out; + + L40_var_out = var1; + + if (var1 & 0x8000) { + L40_var_out = L40_set (L40_var_out | 0xffffff0000); + +#if (WMOPS) + multiCounter[currCounter].L40_set--; +#endif /* ifdef WMOPS */ + } +#if (WMOPS) + multiCounter[currCounter].L40_deposit_l++; +#endif /* ifdef WMOPS */ + + return (L40_var_out); +} + + +/***************************************************************************** + * + * Function Name : L40_deposit32 + * + * Purpose : + * + * Deposits L_var1 in the bits [31-0] in a 40-bit number. The 8 MSBits sign + * extend L_var1 sign bit. + * + * Complexity weight : 1 + * + * Inputs : + * + * L_var1 32 bit long signed integer (Word32) whose value falls in the + * range : 0x8000 0000 <= L_var1 <= 0x7fff ffff. + * + * Outputs : + * + * none + * + * Return Value : + * + * L40_var_out 40 bit long signed integer (Word40) whose value falls in + * the range : MIN_40 <= L40_var_out <= MAX_40. + * + *****************************************************************************/ +static __inline Word40 L40_deposit32 (Word32 L_var1) { + Word40 L40_var_out; + + L40_var_out = (Word40) L_var1; + + if (L_var1 & 0x80000000) { + L40_var_out = L40_set (L40_var_out | 0xff00000000); + +#if (WMOPS) + multiCounter[currCounter].L40_set--; +#endif /* ifdef WMOPS */ + } +#if (WMOPS) + multiCounter[currCounter].L40_deposit32++; +#endif /* ifdef WMOPS */ + + return (L40_var_out); +} + + + + + + + + +/***************************************************************************** + * + * Function Name : L40_round + * + * Purpose : + * + * Rounds the lower 16 bits of the 40 bit input number. Returns the 40 bit + * result with bits 15-0 cleared. + * Calls the macro L40_UNDERFLOW_OCCURED() in case of underflow on 40-bit. + * Calls the macro L40_OVERFLOW_OCCURED() in case of overflow on 40-bit. + * + * + * Complexity weight : 1 + * + * Inputs : + * + * L40_var1 40 bit long signed integer (Word40) whose value falls in the + * range : MIN_40 <= L40_var1 <= MAX_40. + * + * + * Outputs : + * + * none + * + * Return Value : + * + * L40_var_out 40 bit long signed integer (Word40) whose value falls in + * the range : MIN_40 <= L40_var_out <= MAX_40. + * + *****************************************************************************/ +static __inline Word40 L40_round (Word40 L40_var1) { + Word40 L40_var_out; + Word40 L40_constant = L40_set (0xffffff0000); + + L40_var_out = L40_add (0x8000, L40_var1); + L40_var_out = L40_var_out & L40_constant; + +#if (WMOPS) + multiCounter[currCounter].L40_set--; + multiCounter[currCounter].L40_add--; + multiCounter[currCounter].L40_round++; +#endif /* ifdef WMOPS */ + + return (L40_var_out); +} + +/***************************************************************************** + * + * Function Name : round40 + * + * Purpose : + * + * Rounds the lower 16 bits of the 40 bit input number. Saturates the 40 + * bit result to 32-bit and returns the resulting higher 16-bit. + * round40( L40_var1) = extract_h( L_saturate40( L40_round( L40_var1))) + * Calls the macro L40_UNDERFLOW_OCCURED() in case of underflow on 40-bit. + * Calls the macro L40_OVERFLOW_OCCURED() in case of overflow on 40-bit. + * + * + * Complexity weight : 1 + * + * Inputs : + * + * L40_var1 40 bit long signed integer (Word40) whose value falls in the + * range : MIN_40 <= L40_var1 <= MAX_40. + * + * + * Outputs : + * + * none + * + * Return Value : + * + * var_out 16 bit short signed integer (Word16) whose value falls in + * the range 0xffff 8000 <= var_out <= 0x0000 7fff. + * + *****************************************************************************/ +static __inline Word16 round40 (Word40 L40_var1) { + Word16 var_out; + + var_out = extract_h (L_saturate40 (L40_round (L40_var1))); + +#if (WMOPS) + multiCounter[currCounter].L40_round--; + multiCounter[currCounter].L_saturate40--; + multiCounter[currCounter].extract_h--; + multiCounter[currCounter].round40++; +#endif /* ifdef WMOPS */ + + return (var_out); +} + + +/***************************************************************************** + * + * Function Name : L40_mult + * + * Purpose : + * + * Multiplies var1 by var2 and shifts the result left by 1. Returns the + * full precision result on 40-bit. + * L40_mult( var1, var2) = shiftleft(( var1 times var2), 1) + * + * Complexity weight : 1 + * + * Inputs : + * + * var1 16 bit short signed integer (Word16) whose value falls in + * the range : MIN_16 <= var1 <= MAX_16. + * + * var2 16 bit short signed integer (Word16) whose value falls in + * the range : MIN_16 <= var2 <= MAX_16. + * + * Outputs : + * + * none + * + * Return Value : + * + * L40_var_out 40 bit long signed integer (Word40) whose value falls in + * the range : MIN_40 <= L40_var_out <= MAX_40. + * + *****************************************************************************/ +static __inline Word40 L40_mult (Word16 var1, Word16 var2) { + Word32 L_var_out; + Word40 L40_var_out; + + L_var_out = (Word32) var1 *(Word32) var2; + L40_var_out = (Word40) L_var_out; + + /* Below line can not overflow, so we can use << instead of L40_shl. */ + L40_var_out = L40_var_out << 1; + +#if (WMOPS) + multiCounter[currCounter].L40_mult++; +#endif /* ifdef WMOPS */ + + return (L40_var_out); +} + + + + + + + + + + + + +/***************************************************************************** + * + * Function Name : L40_mac + * + * Purpose : + * + * Multiplies var2 by var3. Shifts left the 40-bit result by 1 and adds + * the result to L40_var1. Returns a 40 bit result. + * L40_mac( L40_var1, var2, var3) + * = L40_add( L40_var1, L40_mult( var2, var3)) + * Calls the macro L40_UNDERFLOW_OCCURED() in case of underflow on 40-bit. + * Calls the macro L40_OVERFLOW_OCCURED() in case of overflow on 40-bit. + * + * Complexity weight : 1 + * + * Inputs : + * + * L40_var1 40 bit long signed integer (Word40) whose value falls in the + * range : MIN_40 <= L40_var1 <= MAX_40. + * + * var2 16 bit short signed integer (Word16) whose value falls in + * the range : MIN_16 <= var2 <= MAX_16. + * + * var3 16 bit short signed integer (Word16) whose value falls in + * the range : MIN_16 <= var3 <= MAX_16. + * + * Outputs : + * + * none + * + * Return Value : + * + * L40_var_out 40 bit long signed integer (Word40) whose value falls in + * the range : MIN_40 <= L40_var_out <= MAX_40. + * + *****************************************************************************/ +static __inline Word40 L40_mac (Word40 L40_var1, Word16 var2, Word16 var3) { + Word40 L40_var_out; + + L40_var_out = L40_mult (var2, var3); + L40_var_out = L40_add (L40_var1, L40_var_out); + +#if (WMOPS) + multiCounter[currCounter].L40_mult--; + multiCounter[currCounter].L40_add--; + multiCounter[currCounter].L40_mac++; +#endif /* ifdef WMOPS */ + + return (L40_var_out); +} + + + + + + +/***************************************************************************** + * + * Function Name : mac_r40 + * + * Purpose : + * + * Multiplies var2 by var3. Shifts left the 40-bit result by 1 and adds + * the result to L40_var1. Rounds the lower 16 bits of the 40 bit result. + * Saturates the 40 bit result to 32-bit and returns the resulting higher + * 16-bit. + * mac_r40( L40_var1, var2, var3) + * = round40( L40_mac( L40_var1, var2, var3)) + * Calls the macro L40_UNDERFLOW_OCCURED() in case of underflow on 40-bit. + * Calls the macro L40_OVERFLOW_OCCURED() in case of overflow on 40-bit. + * + * Complexity weight : 2 + * + * Inputs : + * + * L40_var1 40 bit long signed integer (Word40) whose value falls in the + * range : MIN_40 <= L40_var1 <= MAX_40. + * + * var2 16 bit short signed integer (Word16) whose value falls in + * the range : MIN_16 <= var2 <= MAX_16. + * + * var3 16 bit short signed integer (Word16) whose value falls in + * the range : MIN_16 <= var3 <= MAX_16. + * + * Outputs : + * + * none + * + * Return Value : + * + * var_out 16 bit short signed integer (Word16) whose value falls in + * the range : MIN_16 <= var_out <= MAX_16. + * + *****************************************************************************/ +static __inline Word16 mac_r40 (Word40 L40_var1, Word16 var2, Word16 var3) { + Word40 L40_var_out; + Word16 var_out; + + L40_var_out = L40_mac (L40_var1, var2, var3); + var_out = round40 (L40_var_out); + +#if (WMOPS) + multiCounter[currCounter].L40_mac--; + multiCounter[currCounter].round40--; + multiCounter[currCounter].mac_r40++; +#endif /* ifdef WMOPS */ + + return (var_out); +} + + + + + + +/***************************************************************************** + * + * Function Name : L40_msu + * + * Purpose : + * + * Multiplies var2 by var3. Shifts left the 40-bit result by 1 and + * subtracts the result from L40_var1. Returns a 40 bit result. + * L40_msu( L40_var1, var2, var3) + * = L40_sub( L40_var1, L40_mult( var2, var3)) + * Calls the macro L40_UNDERFLOW_OCCURED() in case of underflow on 40-bit. + * Calls the macro L40_OVERFLOW_OCCURED() in case of overflow on 40-bit. + * + * Complexity weight : 1 + * + * Inputs : + * + * L40_var1 40 bit long signed integer (Word40) whose value falls in the + * range : MIN_40 <= L40_var1 <= MAX_40. + * + * var2 16 bit short signed integer (Word16) whose value falls in + * the range : MIN_16 <= var2 <= MAX_16. + * + * var3 16 bit short signed integer (Word16) whose value falls in + * the range : MIN_16 <= var3 <= MAX_16. + * + * Outputs : + * + * none + * + * Return Value : + * + * L40_var_out 40 bit long signed integer (Word40) whose value falls in + * the range : MIN_40 <= L40_var_out <= MAX_40. + * + *****************************************************************************/ +static __inline Word40 L40_msu (Word40 L40_var1, Word16 var2, Word16 var3) { + Word40 L40_var_out; + + L40_var_out = L40_mult (var2, var3); + L40_var_out = L40_sub (L40_var1, L40_var_out); + +#if (WMOPS) + multiCounter[currCounter].L40_mult--; + multiCounter[currCounter].L40_sub--; + multiCounter[currCounter].L40_msu++; +#endif /* ifdef WMOPS */ + + return (L40_var_out); +} + + + + + + +/***************************************************************************** + * + * Function Name : msu_r40 + * + * Purpose : + * + * Multiplies var2 by var3. Shifts left the 40-bit result by 1 and + * subtracts the result from L40_var1. Rounds the lower 16 bits of the + * 40 bit result. Saturates the 40 bit result to 32-bit and returns the + * resulting higher 16-bit. + * msu_r40( L40_var1, var2, var3) + * = round40( L40_msu( L40_var1, var2, var3)) + * Calls the macro L40_UNDERFLOW_OCCURED() in case of underflow on 40-bit. + * Calls the macro L40_OVERFLOW_OCCURED() in case of overflow on 40-bit. + * + * Complexity weight : 2 + * + * Inputs : + * + * L40_var1 40 bit long signed integer (Word40) whose value falls in the + * range : MIN_40 <= L40_var1 <= MAX_40. + * + * var2 16 bit short signed integer (Word16) whose value falls in + * the range : MIN_16 <= var2 <= MAX_16. + * + * var3 16 bit short signed integer (Word16) whose value falls in + * the range : MIN_16 <= var3 <= MAX_16. + * + * Outputs : + * + * none + * + * Return Value : + * + * var_out 16 bit short signed integer (Word16) whose value falls in + * the range : MIN_16 <= var_out <= MAX_16. + * + *****************************************************************************/ +static __inline Word16 msu_r40 (Word40 L40_var1, Word16 var2, Word16 var3) { + Word40 L40_var_out; + Word16 var_out; + + L40_var_out = L40_msu (L40_var1, var2, var3); + var_out = round40 (L40_var_out); + +#if (WMOPS) + multiCounter[currCounter].L40_msu--; + multiCounter[currCounter].round40--; + multiCounter[currCounter].msu_r40++; +#endif /* ifdef WMOPS */ + + return (var_out); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +#endif /*_ENH40_H*/ + + +/* end of file */ diff --git a/basic_op/enh64.c b/basic_op/enh64.c new file mode 100644 index 0000000000000000000000000000000000000000..4a365ee2c119d12f4e7515e4b0f2ddb0a51096ea --- /dev/null +++ b/basic_op/enh64.c @@ -0,0 +1,1665 @@ +/***************************************************************************** +* +* Enhanced 64 bit operators : +* +* W_mac_32_16() +* W_mac0_16_16() +* W_msu0_16_16() +* +*****************************************************************************/ + + +/***************************************************************************** +* +* Include-Files +* +*****************************************************************************/ +#include +#include +#include "enh64.h" + +#if (WMOPS) +extern BASIC_OP multiCounter[MAXCOUNTERS]; +extern int currCounter; +#endif /* if WMOPS */ + + +/***************************************************************************** +* +* Local Functions +* +*****************************************************************************/ + +/***************************************************************************** +* +* Constants and Globals +* +*****************************************************************************/ + + +/***************************************************************************** +* +* Functions +* +*****************************************************************************/ + +#ifdef ENH_64_BIT_OPERATOR + + +/*___________________________________________________________________________ +| | +| Function Name : W_add_nosat | +| | +| Purpose : | +| | +| 64 bits addition of the two 64 bits variables (L64_var1+L64_var2) | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| L64_var2 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +|___________________________________________________________________________| +*/ +Word64 W_add_nosat (Word64 L64_var1, Word64 L64_var2) { + Word64 L64_var_out; + + L64_var_out = L64_var1 + L64_var2; + +#if (WMOPS) + multiCounter[currCounter].W_add_nosat++; +#endif + + return L64_var_out; +} + + +/*___________________________________________________________________________ +| | +| Function Name : W_sub_nosat | +| | +| Purpose : | +| | +| 64 bits subtraction of the two 64 bits variables (L64_var1-L64_var2) | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| L64_var2 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +|___________________________________________________________________________| +*/ +Word64 W_sub_nosat (Word64 L64_var1, Word64 L64_var2) { + Word64 L64_var_out; + + L64_var_out = L64_var1 - L64_var2; + +#if (WMOPS) + multiCounter[currCounter].W_sub_nosat++; +#endif + + return L64_var_out; +} + + +/*___________________________________________________________________________ +| | +| Function Name : W_shl | +| | +| Purpose : | +| | +| Arithmetically shift the 64 bit input L64_var1 left var2 positions. Zero| +| fill the var2 LSB of the result. If var2 is negative, arithmetically | +| shift L64_var1 right by -var2 with sign extension. Saturate the result | +| in case of underflows or overflows. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 64 bit long signed integer (Word64) whose value falls in the| +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| var2 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0xffff 8000 <= var1 <= 0x0000 7fff. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +|___________________________________________________________________________| +*/ +Word64 W_shl (Word64 L64_var1, Word16 var2) { + + Word64 L64_var_out = 0LL; + + if (var2 <= 0) { + if (var2 < -64) + var2 = -64; + var2 = -var2; + L64_var_out = L64_var1 >> var2; + } + else { + for (; var2 > 0; var2--) { + if (L64_var1 > (Word64) 0X3fffffffffffffffLL) { + Overflow = 1; + L64_var_out = (Word64) 0X7fffffffffffffffLL; + break; + } + else { + if (L64_var1 < (Word64) 0xc000000000000000LL) { + Overflow = 1; + L64_var_out = (Word64)0x8000000000000000LL; + break; + } + } + L64_var1 *= 2; + L64_var_out = L64_var1; + } + } +#if (WMOPS) + multiCounter[currCounter].W_shl++; +#endif + +/* BASOP_CHECK();*/ + + return (L64_var_out); +} + + +/*___________________________________________________________________________ +| | +| Function Name : W_shr | +| | +| Purpose : | +| | +| Arithmetically shift the 64 bit input L64_var1 right var2 positions. | +| Zero fill the var2 LSB of the result. If var2 is negative, | +| arithmetically shift L64_var1 left by -var2 with sign extension. | +| Saturate the result in case of underflows or overflows. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 64 bit long signed integer (Word64) whose value falls in the| +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| var2 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0xffff 8000 <= var1 <= 0x0000 7fff. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +|___________________________________________________________________________| +*/ +Word64 W_shr (Word64 L64_var1, Word16 var2) { + Word64 L64_var_out; + + if (var2 < 0) { + var2 = -var2; + L64_var_out = W_shl (L64_var1, var2); + +#if (WMOPS) + multiCounter[currCounter].W_shl--; +#endif /* if WMOPS */ + + } else { + L64_var_out = L64_var1 >> var2; + } + +#if (WMOPS) + multiCounter[currCounter].W_shr++; +#endif /* if WMOPS */ + + return (L64_var_out); +} + + +/*___________________________________________________________________________ +| | +| Function Name : W_shl_nosat | +| | +| Purpose : | +| | +| Arithmetically shifts left the 64-bit variable W_var1 by var2 positions. | +| if var2 is negative, W_var1 is shifted to the least significant bits by | +| (�var2) positions with extension of the sign bit . | +| if var2 is positive, W_var1 is shifted to the most significant bits by | +| (var2) positions without saturation control on 64 bits. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 64 bit long signed integer (Word64) whose value falls in the| +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| var2 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0xffff 8000 <= var1 <= 0x0000 7fff. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +|___________________________________________________________________________| +*/ +Word64 W_shl_nosat (Word64 L64_var1, Word16 var2) { + + Word64 L64_var_out = 0LL; + + if (var2 <= 0) { + var2 = -var2; + L64_var_out = L64_var1 >> var2; + } + else { + L64_var_out = L64_var1 << var2; + } +#if (WMOPS) + multiCounter[currCounter].W_shl_nosat++; +#endif + +/* BASOP_CHECK();*/ + + return (L64_var_out); +} + + +/*___________________________________________________________________________ +| | +| Function Name : W_shr_nosat | +| | +| Purpose : | +| | +| Arithmetically shifts right the 64-bit variable W_var1 by var2 positions. | +| if var2 is negative, W_var1 is shifted to the most significant bits by | +| (�var2) positions without saturation control on 64 bits. | +| if var2 is positive, W_var1 is shifted to the least significant bits by | +| (var2) positions with extension of the sign bit . | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 64 bit long signed integer (Word64) whose value falls in the| +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| var2 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0xffff 8000 <= var1 <= 0x0000 7fff. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +|___________________________________________________________________________| +*/ +Word64 W_shr_nosat (Word64 L64_var1, Word16 var2) { + Word64 L64_var_out; + + if (var2 < 0) { + var2 = -var2; + L64_var_out = L64_var1 << var2; + + } else { + L64_var_out = L64_var1 >> var2; + } + +#if (WMOPS) + multiCounter[currCounter].W_shr_nosat++; +#endif /* if WMOPS */ + + return (L64_var_out); +} + + +/*_________________________________________________________________________________________________ +| | +| Function Name : W_mac_32_16 | +| | +| Purpose : | +| | +| Multiply L_var2 by var3 and shift the result left by 1. Add the 64 bit | +| result to L64_var1, return a 64 bit result. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 | +| 64 bit long long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| L_var2 | +| 32 bit signed integer (Word32) whose value falls in the | +| range : 0x8000 0000 <= L_var2 <= 0x7fff ffff | +| | +| var3 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0xffff 8000 <= var3 <= 0x0000 7fff. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var_out <= 0x7fffffff ffffffffLL. | +|_________________________________________________________________________________________________| +*/ +Word64 W_mac_32_16 (Word64 L64_var1, Word32 L_var2, Word16 var3) { + Word64 L64_var_out = ((Word64) L_var2*var3) << 1; + L64_var_out += L64_var1; +#if (WMOPS) + multiCounter[currCounter].W_mac_32_16++; +#endif /* if WMOPS */ + return L64_var_out; +} + + +/*_________________________________________________________________________________________________ +| | +| Function Name : W_msu_32_16 | +| | +| Purpose : | +| | +| Multiply L_var2 by var3 and shift the result left by 1. Subtract the 64 bit | +| result from L64_var1, return a 64 bit result. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 | +| 64 bit long long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| L_var2 | +| 32 bit signed integer (Word32) whose value falls in the | +| range : 0x8000 0000 <= L_var2 <= 0x7fff ffff | +| | +| var3 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0xffff 8000 <= var3 <= 0x0000 7fff. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var_out <= 0x7fffffff ffffffffLL. | +|_________________________________________________________________________________________________| +*/ +Word64 W_msu_32_16(Word64 L64_var1, Word32 L_var2, Word16 var3) { + Word64 L64_var_out = ((Word64 )L_var2*var3) << 1; + L64_var_out = L64_var1 - L64_var_out; +#if (WMOPS) + multiCounter[currCounter].W_msu_32_16++; +#endif /* if WMOPS */ + return L64_var_out; +} + + +/*_________________________________________________________________________________________________ +| | +| Function Name : W_mult_32_16 | +| | +| Purpose : | +| | +| Multiply L_var1 by var2 and shift the result left by 1. Return a 64 bit result. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L_var1 | +| 32 bit signed integer (Word32) whose value falls in the | +| range : 0x8000 0000 <= L_var1 <= 0x7fff ffff | +| | +| var2 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0xffff 8000 <= var2 <= 0x0000 7fff. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var_out <= 0x7fffffff ffffffffLL. | +|_________________________________________________________________________________________________| +*/ +Word64 W_mult_32_16(Word32 L_var1, Word16 var2) { + Word64 L64_var_out = ((Word64 )L_var1*var2) << 1; +#if (WMOPS) + multiCounter[currCounter].W_mult_32_16++; +#endif /* if WMOPS */ + return L64_var_out; +} + +/*________________________________________________________________________________________________ +| | +| Function Name : W_mult0_16_16 | +| | +| Purpose : | +| | +| Multiply var1 by var2 and return a 64 bit result. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| var1 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0x8000 0000 <= L_var1 <= 0x7fff ffff | +| | +| var2 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0xffff 8000 <= var1 <= 0x0000 7fff. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_acc <= 0x7fffffff ffffffffLL. | +|_________________________________________________________________________________________________| +*/ +Word64 W_mult0_16_16(Word16 var1, Word16 var2) { + Word64 L64_var_out = (Word64 )var1*var2; +#if (WMOPS) + multiCounter[currCounter].W_mult0_16_16++; +#endif /* if WMOPS */ + return L64_var_out; +} + +/*________________________________________________________________________________________________ +| | +| Function Name : W_mac0_16_16 | +| | +| Purpose : | +| | +| Multiply var2 by var3 and add the 64 bit result to L64_var1, return a 64 bit result. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 | +| 64 bit long long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| var2 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0xffff 8000 <= var2 <= 0x0000 7fff. | +| | +| var3 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0xffff 8000 <= var3 <= 0x0000 7fff. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var_out <= 0x7fffffff ffffffffLL. | +|_________________________________________________________________________________________________| +*/ +Word64 W_mac0_16_16(Word64 L64_var1, Word16 var2, Word16 var3) { + Word64 L64_var_out = (Word64 )var2*var3; + L64_var_out += L64_var1; +#if (WMOPS) + multiCounter[currCounter].W_mac0_16_16++; +#endif /* if WMOPS */ + return L64_var_out; +} + + +/*________________________________________________________________________________________________ +| | +| Function Name : W_msu0_16_16 | +| | +| Purpose : | +| | +| Multiply var2 by var3 and subtract the 64 bit result from L64_var1, return a 64 bit result. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 | +| 64 bit long long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| var2 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0xffff 8000 <= var2 <= 0x0000 7fff. | +| | +| var3 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0xffff 8000 <= var3 <= 0x0000 7fff. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var_out <= 0x7fffffff ffffffffLL. | +|_________________________________________________________________________________________________| +*/ +Word64 W_msu0_16_16 (Word64 L64_var1, Word16 var2, Word16 var3) { + Word64 L64_var_out = (Word64) var2*var3; + L64_var_out = L64_var1 - L64_var_out; +#if (WMOPS) + multiCounter[currCounter].W_msu0_16_16++; +#endif /* if WMOPS */ + return L64_var_out; +} + + + +/*_____________________________________________________________________________________ +| | +| Function Name : W_sat_l | +| | +| Purpose : | +| | +| Saturate the lower 32 bits of the 64 bit input number L64_var into 32 bits. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var | +| 64 bit long long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var <= 0x7fffffff ffffffffLL. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L_var_out | +| 32 bit signed integer (Word32) whose value falls in the | +| range : 0x8000 0000 <= L_var_out <= 0x7fff 0000. | +|_____________________________________________________________________________________| +*/ +Word32 W_sat_l (Word64 L64_var) { + Word32 L_var_out; + + if (L64_var > 0x7FFFFFFF) { + L_var_out = 0x7FFFFFFF; + } + else if (L64_var < (int)0x80000000) { + L_var_out = 0x80000000; + } + else { + L_var_out = (Word32)L64_var; + } + +#if (WMOPS) + multiCounter[currCounter].W_sat_l++; +#endif /* if WMOPS */ + + return L_var_out; +} + + + +/*___________________________________________________________________________________ +| | +| Function Name : W_sat_m | +| | +| Purpose : | +| | +| Truncates the lower 16 bits of the 64 bit input L64_var | +| and saturates the number into 32 bits. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var | +| 64 bit long long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var <= 0x7fffffff ffffffffLL. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L_var_out | +| 32 bit signed integer (Word32) whose value falls in the | +| range : 0x8000 0000 <= L_var_out <= 0x7fff 0000. | +|_____________________________________________________________________________________| +*/ +Word32 W_sat_m (Word64 L64_var) { + Word32 L_var_out; + + L64_var = L64_var >> 16; + L_var_out = W_sat_l (L64_var); + +#if (WMOPS) + multiCounter[currCounter].W_sat_l--; + multiCounter[currCounter].W_sat_m++; +#endif /* if WMOPS */ + + return L_var_out; +} + + +/*__________________________________________________________________________________ +| | +| Function Name : W_deposit32_l | +| | +| Purpose : | +| | +| Deposit the 32 bit L_var1 into the 32 LS bits of the 64 bit output. The | +| 32 MS bits of the output are sign extended. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L_var1 | +| 32 bit long signed integer (Word32) whose value falls in the | +| range : 0x8000 0000 <= var_out <= 0x7fff 0000. | | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long long signed integer (Word64) whose value falls in | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +|__________________________________________________________________________________| +*/ +Word64 W_deposit32_l (Word32 L_var1) { + Word64 L64_var_out; + + L64_var_out = (Word64) L_var1; + +#if (WMOPS) + multiCounter[currCounter].W_deposit32_l++; +#endif + + return (L64_var_out); +} + + +/*__________________________________________________________________________________ +| | +| Function Name : W_deposit32_h | +| | +| Purpose : | +| | +| Deposit the 32 bit L_var1 into the 32 MS bits of the 64 bit output. The | +| 32 LS bits of the output are zeroed. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L_var1 | +| 32 bit long signed integer (Word32) whose value falls in the | +| range : 0x8000 0000 <= var_out <= 0x7fff 0000. | | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long long signed integer (Word64) whose value falls in | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +|__________________________________________________________________________________| +*/ +Word64 W_deposit32_h (Word32 L_var1) { + Word64 L64_var_out; + + L64_var_out = (Word64) L_var1 << 32; + +#if (WMOPS) + multiCounter[currCounter].W_deposit32_h++; +#endif + + return (L64_var_out); +} + + +/*__________________________________________________________________________________ +| | +| Function Name : W_extract_l | +| | +| Purpose : | +| | +| Return the 32 LSB of L64_var1. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 | +| 64 bit long long signed integer (Word64) whose value falls in | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L_var_out | +| 32 bit long signed integer (Word32) whose value falls in the | +| range : 0x8000 0000 <= L_var_out <= 0x7fff 0000. | +|__________________________________________________________________________________| +*/ +Word32 W_extract_l (Word64 L64_var1) { + Word32 L_var_out; + + L_var_out = (Word32) L64_var1; + +#if (WMOPS) + multiCounter[currCounter].W_extract_l++; +#endif /* if WMOPS */ + + return (L_var_out); +} + + + +/*__________________________________________________________________________________ +| | +| Function Name : W_extract_h | +| | +| Purpose : | +| | +| Return the 32 MSB of L64_var1. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 | +| 64 bit long long signed integer (Word64) whose value falls in | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L_var_out | +| 32 bit long signed integer (Word32) whose value falls in the | +| range : 0x8000 0000 <= L_var_out <= 0x7fff 0000. | +|__________________________________________________________________________________| +*/ +Word32 W_extract_h (Word64 L64_var1) { + Word32 L_var_out; + + L_var_out = (Word32) (L64_var1 >> 32); + +#if (WMOPS) + multiCounter[currCounter].W_extract_h++; +#endif /* if WMOPS */ + + return (L_var_out); +} + + + +/*________________________________________________________________________________________________ +| | +| Function Name : W_mult_16_16 | +| | +| Purpose : | +| | +| Multiply var1 by var2 and shift the result left by 1. Return a 64 bit result. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| var1 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0x8000 0000 <= L_var1 <= 0x7fff ffff | +| | +| var2 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0xffff 8000 <= var1 <= 0x0000 7fff. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_acc <= 0x7fffffff ffffffffLL. | +|_________________________________________________________________________________________________| +*/ +Word64 W_mult_16_16 (Word16 var1, Word16 var2) { + Word64 L64_var_out = ((Word64) var1*var2) << 1; +#if (WMOPS) + multiCounter[currCounter].W_mult_16_16++; +#endif /* if WMOPS */ + return L64_var_out; +} +/*________________________________________________________________________________________________ +| | +| Function Name : W_mac_16_16 | +| | +| Purpose : | +| | +| Multiply var1 by var2 and shift the result left by 1 and add the 64 bit result to L64_acc, | +| return a 64 bit result. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_acc | +| 64 bit long long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_acc <= 0x7fffffff ffffffffLL. | +| | +| var1 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0xffff 8000 <= var1 <= 0x0000 7fff. | +| | +| var2 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0xffff 8000 <= var2 <= 0x0000 7fff. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var_out <= 0x7fffffff ffffffffLL. | +|_________________________________________________________________________________________________| +*/ +Word64 W_mac_16_16 (Word64 L64_acc, Word16 var1, Word16 var2) { + Word64 L64_var_out = ((Word64) var1*var2) << 1; + L64_acc = L64_acc + L64_var_out; + +#if (WMOPS) + multiCounter[currCounter].W_mac_16_16++; +#endif /* if WMOPS */ + return L64_acc; +} + + + +/*________________________________________________________________________________________________ +| | +| Function Name : W_msu_16_16 | +| | +| Purpose : | +| | +| Multiply var2 by var3 and shift the result left by1 and subtract the 64 bit result | +| from L64_var1, return a 64 bit result. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 | +| 64 bit long long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| var2 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0xffff 8000 <= var2 <= 0x0000 7fff. | +| | +| var3 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0xffff 8000 <= var3 <= 0x0000 7fff. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var_out <= 0x7fffffff ffffffffLL. | +|_________________________________________________________________________________________________| +*/ +Word64 W_msu_16_16 (Word64 L64_var1, Word16 var2, Word16 var3) { + Word64 L64_var_out = ((Word64)var2*var3) << 1; + L64_var_out = L64_var1 - L64_var_out; +#if (WMOPS) + multiCounter[currCounter].W_msu_16_16++; +#endif /* if WMOPS */ + return L64_var_out; +} + + +/*___________________________________________________________________________ +| | +| Function Name : W_shl_sat_l | +| | +| Purpose : | +| | +| Arithmetically shift the 64 bit input L64_var left by n positions with | +| lower 32 bit saturation and return the 32 LSB of 64 bit result | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var | +| 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var <= 0x7fffffff ffffffffLL. | +| | +| n | +| 32 bit signed integer (Word32) whose value falls in the | +| range : 0x8000 0000 <= n <= 0x7fff 0000. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L_result | +| 32 bit long signed integer (Word32) whose value falls in the | +| range : 0x8000 0000 <= L_result <= 0x7fff 0000. | +|___________________________________________________________________________| +*/ +Word32 W_shl_sat_l (Word64 L64_var, Word32 n) { + Word32 L_result; + Word64 d_var_64; + + d_var_64 = W_shl (L64_var, n); + L_result = W_sat_l (d_var_64); + +#if (WMOPS) + multiCounter[currCounter].W_shl_sat_l++; + multiCounter[currCounter].W_shl--; + multiCounter[currCounter].W_sat_l--; +#endif /* if WMOPS */ + + return L_result; +} + + +/*__________________________________________________________________________________ +| | +| Function Name : W_round48_L | +| | +| Purpose : | +| | +| Round asymmetrically lower 16 bits, and | +| saturate the 17.47-bit values to 1.31-bit values | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 | +| 64 bit long long signed integer (Word64) whose value falls in | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L_var_out | +| 32 bit long signed integer (Word32) whose value falls in the | +| range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | +|__________________________________________________________________________________| +*/ +Word32 W_round48_L (Word64 L64_var1) { + Word64 L64_var_out; + Word32 L_result; + + Word64 L64_var2 = 0x80000000; + Word64 L64_MIN = 0x8000000000000000LL; + Word64 L64_MAX = 0x7FFFFFFFFFFFFFFFLL; + + L64_var1 = W_shl (L64_var1, 16); + + L64_var_out = L64_var1 + L64_var2; + + if ( ( (L64_var1 ^ L64_var2) & L64_MIN) == 0) { + if ( (L64_var_out ^ L64_var1) & L64_MIN) { + L64_var_out = (L64_var1 < 0) ? L64_MIN : L64_MAX; + Overflow = 1; + } + } + L_result = W_extract_h (L64_var_out); +#if (WMOPS) + multiCounter[currCounter].W_round48_L++; + multiCounter[currCounter].W_extract_h--; + multiCounter[currCounter].W_shl--; +#endif /* if WMOPS */ + + return (L_result); +} + +/*__________________________________________________________________________________ +| | +| Function Name : W_round32_s | +| | +| Purpose : | +| | +| Round asymmetrically lower 32 bits, and | +| saturate the 17.47-bit values to 1.15-bit values | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 | +| 64 bit long long signed integer (Word64) whose value falls in | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| var_out | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0xffff 8000 <= var_out <= 0x0000 7fff. | +|__________________________________________________________________________________| +*/ +Word16 W_round32_s (Word64 L64_var1) { + Word64 L64_var_out; + Word32 L_var; + Word16 var_out; + + + Word64 L64_var2 = 0x800000000000LL; + Word64 L64_MIN = 0x8000000000000000LL; + Word64 L64_MAX = 0x7FFFFFFFFFFFFFFFLL; + + L64_var1 = W_shl (L64_var1, 16); + L64_var_out = L64_var1 + L64_var2; + + if (((L64_var1 ^ L64_var2) & L64_MIN) == 0) { + if ((L64_var_out ^ L64_var1) & L64_MIN) { + L64_var_out = (L64_var1 < 0) ? L64_MIN : L64_MAX; + Overflow = 1; + } + } + L_var = W_extract_h (L64_var_out); + var_out = extract_h (L_var); +#if (WMOPS) + multiCounter[currCounter].W_round32_s ++; + multiCounter[currCounter].W_extract_h--; + multiCounter[currCounter].extract_h--; + multiCounter[currCounter].W_shl--; +#endif /* if WMOPS */ + + return (var_out); +} +/*___________________________________________________________________________ +| | +| Function Name : W_norm | +| | +| Purpose : | +| | +| Produces the number of left shifts needed to normalize the 64 bit varia-| +| ble L64_var1. +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 | +| 64 bit long long signed integer (Word64) whose value falls in | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| var_out | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0x0000 0000 <= var_out <= 0x0000 003f. | +|___________________________________________________________________________| +*/ +Word16 W_norm (Word64 L64_var1) { + Word16 var_out; + if (L64_var1 == 0) { + var_out = 0; + } + else { + if (L64_var1 == (Word64) 0xffffffffffffffffLL) { + var_out = 63; + } + else { + if (L64_var1 < 0) { + L64_var1 = ~L64_var1; + } + for (var_out = 0; L64_var1 < (Word64) 0x4000000000000000LL; var_out++) { + L64_var1 <<= 1; + } + } + } +#if (WMOPS) + multiCounter[currCounter].W_norm ++; +#endif /* if WMOPS */ + return (var_out); +} + + + +/*______________________________________________________________________________ +| | +| Function Name : W_add | +| | +| Purpose : | +| | +| 64 bits addition of the two 64 bits variables (L64_var1+L64_var2) with | +| overflow control and saturation; the result is set at 0x7fffffffffffffffLL | +| when overflow occurs or at 0x8000000000000000LL when underflow occurs. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| L64_var2 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +|_______________________________________________________________________________| +*/ +Word64 W_add (Word64 L64_var1, Word64 L64_var2) { + Word64 L64_var_out; + + L64_var_out = L64_var1 + L64_var2; + + if (((L64_var1 ^ L64_var2) & MIN_64) == 0) { + if ((L64_var_out ^ L64_var1) & MIN_64) { + L64_var_out = (L64_var1 < 0) ? MIN_64 : MAX_64; + Overflow = 1; + } + } + +#if (WMOPS) + multiCounter[currCounter].W_add++; +#endif + return L64_var_out; +} + +/*______________________________________________________________________________ +| | +| Function Name : W_sub | +| | +| Purpose : | +| | +| 64 bits subtraction of the two 64 bits variables (L64_var1-L64_var2) with | +| overflow control and saturation; the result is set at 0x7fffffffffffffffLL | +| when overflow occurs or at 0x8000000000000000LL when underflow occurs. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| L64_var2 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +|_______________________________________________________________________________| +*/ +Word64 W_sub (Word64 L64_var1, Word64 L64_var2) { + Word64 L64_var_out; + + L64_var_out = L64_var1 - L64_var2; + + if (((L64_var1 ^ L64_var2) & MIN_64) != 0) { + if ((L64_var_out ^ L64_var1) & MIN_64) { + L64_var_out = (L64_var1 < 0) ? MIN_64 : MAX_64; + Overflow = 1; + } + } + +#if (WMOPS) + multiCounter[currCounter].W_add++; +#endif + return L64_var_out; +} + + +/*______________________________________________________________________________ +| | +| Function Name : W_neg | +| | +| Purpose : | +| | +| Negate the 64 bit variable L64_var1 with overflow control and saturation; | +| Saturate and set overflow in the case where input is 0x8000000000000000LL. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +|_______________________________________________________________________________| +*/ +Word64 W_neg (Word64 L64_var1) { + Word64 L64_var_out; + + if (L64_var1 == MIN_64) { + L64_var_out = MAX_64; + Overflow = 1; + } + else { + L64_var_out = -L64_var1; + } + +#if (WMOPS) + multiCounter[currCounter].W_neg++; +#endif + + return (L64_var_out); + +} + + +/*___________________________________________________________________________ + | | + | Function Name : W_abs | + | | + | Purpose : | + | | + | Absolute value of L64_var1; Saturate in case where the input is | + | 0x8000000000000000LL | + | | + | Complexity weight : 1 | + | | + | Inputs : | + | | + | L64_var1 64 bit long signed integer (Word64) whose value falls in the | + | range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | + | | + | Outputs : | + | | + | none | + | | + | Return Value : | + | | + | L64_var_out | + | 64 bit long signed integer (Word64) whose value falls in the | + | range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | + |___________________________________________________________________________| +*/ +Word64 W_abs (Word64 L64_var1) { + Word64 L64_var_out; + + if (L64_var1 == MIN_64) { + L64_var_out = MAX_64; + Overflow = 1; + } + else { + if (L64_var1 < 0) { + L64_var_out = -L64_var1; + } + else { + L64_var_out = L64_var1; + } + } + +#if (WMOPS) + multiCounter[currCounter].W_abs++; +#endif + + return (L64_var_out); +} + +/*_________________________________________________________________________________________________ +| | +| Function Name : W_mult_32_32 | +| | +| Purpose : | +| | +| Multiply L_var1 by L_var2 and shift the result left by 1.Saturate and set overflow in case | +| where both inputs are 0x80000000 . Return a 64 bit result. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L_var1 | +| 32 bit signed integer (Word32) whose value falls in the | +| range : 0x8000 0000 <= L_var1 <= 0x7fff ffff | +| | +| L_var2 | +| 32 bit signed integer (Word32) whose value falls in the | +| range : 0x8000 0000 <= L_var1 <= 0x7fff ffff | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var_out <= 0x7fffffff ffffffffLL. | +|_________________________________________________________________________________________________| +*/ +Word64 W_mult_32_32(Word32 L_var1, Word32 L_var2) { + Word64 L64_var_out; + + if ((L_var1 == MIN_32) && (L_var2 == MIN_32)) { + L64_var_out = MAX_64; + Overflow = 1; + } + else { + L64_var_out = ((Word64 )L_var1*L_var2) << 1; + } + +#if (WMOPS) + multiCounter[currCounter].W_mult_32_32++; +#endif /* if WMOPS */ + return L64_var_out; +} + +/*_________________________________________________________________________________________________ +| | +| Function Name : W_mult0_32_32 | +| | +| Purpose : | +| | +| Multiply L_var1 by L_var2. Return a 64 bit result. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L_var1 | +| 32 bit signed integer (Word32) whose value falls in the | +| range : 0x8000 0000 <= L_var1 <= 0x7fff ffff | +| | +| L_var2 | +| 32 bit signed integer (Word32) whose value falls in the | +| range : 0x8000 0000 <= L_var1 <= 0x7fff ffff | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var_out <= 0x7fffffff ffffffffLL. | +|_________________________________________________________________________________________________| +*/ +Word64 W_mult0_32_32 (Word32 L_var1, Word32 L_var2) { + Word64 L64_var_out; + + L64_var_out = (Word64) L_var1*L_var2; + + +#if (WMOPS) + multiCounter[currCounter].W_mult0_32_32++; +#endif /* if WMOPS */ + return L64_var_out; +} + + +/*_____________________________________________________________________________ +| | +| Function Name : W_lshl | +| | +| Purpose : | +| | +| Logically shift the 64 bit unsigned input L64_var1 left by var2 positions. | +| Zero fill the var2 LSB of the result. If var2 is negative, logically shift | +| L64_var1 right by -var2 with zero fill in the MSB. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 64 bit long unsigned signed integer (UWord64) whose value falls | +| in the range : 0LL <= L64_var1 <= 0xffffffff ffffffffLL. | +| | +| var2 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0xffff 8000 <= var1 <= 0x0000 7fff. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long unsigned signed integer (UWord64) whose value falls | +| in the range : 0LL <= L64_var1 <= 0xffffffff ffffffffLL. | +|______________________________________________________________________________| +*/ +UWord64 W_lshl (UWord64 L64_var1, Word16 var2) { + + UWord64 L64_var_out = 0LL; + + if (var2 < 0) { + L64_var_out = L64_var1 >> (-var2); + } + else { + L64_var_out = L64_var1 << var2 ; + } +#if (WMOPS) + multiCounter[currCounter].W_lshl++; +#endif + + return (L64_var_out); +} + +/*_____________________________________________________________________________ +| | +| Function Name : W_lshr | +| | +| Purpose : | +| | +| Logically shift the 64 bit unsigned input L64_var1 right by var2 positions.| +| Zero fill the var2 MSB of the result. If var2 is negative, logically shift | +| L64_var1 left by -var2 with zero fill in the LSB. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 64 bit long unsigned signed integer (UWord64) whose value falls | +| in the range : 0LL <= L64_var1 <= 0xffffffff ffffffffLL. | +| | +| var2 | +| 16 bit short signed integer (Word16) whose value falls in the | +| range : 0xffff 8000 <= var1 <= 0x0000 7fff. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long unsigned signed integer (UWord64) whose value falls | +| in the range : 0LL <= L64_var1 <= 0xffffffff ffffffffLL. | +|______________________________________________________________________________| +*/ +UWord64 W_lshr (UWord64 L64_var1, Word16 var2) { + + UWord64 L64_var_out = 0LL; + + if (var2 < 0) { + L64_var_out = L64_var1 << (-var2); + } + else { + L64_var_out = L64_var1 >> var2 ; + } +#if (WMOPS) + multiCounter[currCounter].W_lshr++; +#endif + + return (L64_var_out); +} + + +/*__________________________________________________________________________________ +| | +| Function Name : W_round64_L | +| | +| Purpose : | +| | +| Round asymmetrically lower 32 bits, and | +| saturate the 1.63-bit values to 1.31-bit values | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 | +| 64 bit long long signed integer (Word64) whose value falls in | +| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L_var_out | +| 32 bit long signed integer (Word32) whose value falls in the | +| range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | +|__________________________________________________________________________________| +*/ +Word32 W_round64_L (Word64 L64_var1) { + Word64 L64_var_out; + Word32 L_result; + + + Word64 L64_tmp = 0x80000000; + L64_var_out = W_add (L64_var1, L64_tmp); + L_result = W_extract_h (L64_var_out); + +#if (WMOPS) + multiCounter[currCounter].W_round64_L++; + multiCounter[currCounter].W_extract_h--; + multiCounter[currCounter].W_add--; +#endif /* if WMOPS */ + + return (L_result); +} + +#endif /* #ifdef ENH_64_BIT_OPERATOR */ + +/* end of file */ diff --git a/basic_op/enh64.h b/basic_op/enh64.h new file mode 100644 index 0000000000000000000000000000000000000000..ac15ffdcd98da585c2aa55d3e933056ebcf436f2 --- /dev/null +++ b/basic_op/enh64.h @@ -0,0 +1,73 @@ + +#ifndef _ENH64_H +#define _ENH64_H + +#include "stl.h" + +#ifndef Word64 +#define Word64 long long int +#endif + +#ifndef UWord64 +#define UWord64 unsigned long long int +#endif + +#define MAX_64 (Word64)0x7fffffffffffffffLL +#define MIN_64 (Word64)0x8000000000000000LL + + /***************************************************************************** + * + * Prototypes for enhanced 64 bit arithmetic operators + * + *****************************************************************************/ +#ifdef ENH_64_BIT_OPERATOR +Word64 W_add_nosat (Word64 L64_var1, Word64 L64_var2); +Word64 W_sub_nosat (Word64 L64_var1, Word64 L64_var2); +Word64 W_shl (Word64 L64_var1, Word16 var2); +Word64 W_shr (Word64 L64_var1, Word16 var2); +Word64 W_shl_nosat (Word64 L64_var1, Word16 var2); +Word64 W_shr_nosat (Word64 L64_var1, Word16 var2); +Word64 W_mult_32_16 (Word32 L_var1, Word16 var2); +Word64 W_mac_32_16 (Word64 L64_acc, Word32 L_var1, Word16 var2); +Word64 W_msu_32_16 (Word64 L64_acc, Word32 L_var1, Word16 var2); +Word64 W_mult0_16_16 (Word16 var1, Word16 var2); +Word64 W_mac0_16_16 (Word64 L64_acc, Word16 var1, Word16 var2); +Word64 W_msu0_16_16 (Word64 L64_acc, Word16 var1, Word16 var2); +Word64 W_mult_16_16 (Word16 var1, Word16 var2); +Word64 W_mac_16_16 (Word64 L64_acc, Word16 var1, Word16 var2); +Word64 W_msu_16_16 (Word64 L64_acc, Word16 var1, Word16 var2); + +Word64 W_deposit32_l (Word32 L_var1); +Word64 W_deposit32_h (Word32 L_var1); + +Word32 W_sat_l (Word64 L64_var); +Word32 W_sat_m (Word64 L64_var); +Word32 W_shl_sat_l (Word64 L64_var, Word32 n); + +Word32 W_extract_l (Word64 L64_var1); +Word32 W_extract_h (Word64 L64_var1); + +Word32 W_round48_L (Word64 L64_var1); +Word16 W_round32_s (Word64 L64_var1); + +Word16 W_norm (Word64 L_var1); + + +Word64 W_add (Word64 L64_var1, Word64 L64_var2); +Word64 W_sub (Word64 L64_var1, Word64 L64_var2); +Word64 W_neg (Word64 L64_var1); +Word64 W_abs (Word64 L64_var1); +Word64 W_mult_32_32 (Word32 L_var1, Word32 L_var2); +Word64 W_mult0_32_32 (Word32 L_var1, Word32 L_var2); +UWord64 W_lshl (UWord64 L64_var1, Word16 var2); +UWord64 W_lshr (UWord64 L64_var1, Word16 var2); +Word32 W_round64_L (Word64 L64_var1) ; + +#endif /* #ifdef ENH_64_BIT_OPERATOR */ + +#endif /*_ENH64_H*/ + + +/* end of file */ + + diff --git a/basic_op/enhUL32.c b/basic_op/enhUL32.c index 3192fdfa1cc75ed4f54a2e6ce4f98ede6d4f139b..9f82d044348b8cefcfdfb443e182457a16e9655c 100644 --- a/basic_op/enhUL32.c +++ b/basic_op/enhUL32.c @@ -1,10 +1,11 @@ /* - =========================================================================== - File: ENHUL32.C v.0.5 - 21.March.2014 - =========================================================================== + ============================================================================ + File: ENHUL32.C v.1.0 - 01.July.2018 + ============================================================================ ENHANCED UNSIGNED 32-BIT ARITHMETIC OPERATORS History: + v.0.5 - 21.March.2014 ============================================================================ */ @@ -12,7 +13,7 @@ /***************************************************************************** * * Enhanced Unsigned 32 bit operators : - * see complete list in .h file + * see complete list in .h file * *****************************************************************************/ @@ -24,12 +25,9 @@ #include #include #include "stl.h" -#include "wmc_auto.h" - #include "enhUL32.h" - -#ifdef WMOPS +#if (WMOPS) extern BASIC_OP multiCounter[MAXCOUNTERS]; extern int currCounter; #endif /* if WMOPS */ @@ -47,7 +45,7 @@ extern int currCounter; * Functions * *****************************************************************************/ -#ifdef ENHUL32 +#ifdef ENH_U_32_BIT_OPERATOR /*___________________________________________________________________________ | | @@ -57,74 +55,69 @@ extern int currCounter; | | | Deposit the 16 bit var1 into the 16 LS bits of the 32 bit output. The | | 16 MS bits of the output are not sign extended. | - | | - |___________________________________________________________________________ */ + |___________________________________________________________________________| +*/ -UWord32 UL_deposit_l(UWord16 uvar){ - UWord32 UL_result; - UL_result = (UWord32)uvar; /* no sign extension*/ -#ifdef WMOPS - multiCounter[currCounter].L_deposit_l++; +UWord32 UL_deposit_l (UWord16 uvar) { + UWord32 UL_result; + UL_result = (UWord32) uvar; /* no sign extension*/ +#if (WMOPS) + multiCounter[currCounter].UL_deposit_l++; #endif - return (UL_result); + return (UL_result); } - -/*___________________________________________________________________________ - | | - | Function Name : norm_ul | - | | - | Purpose : | - | | - | Produces the number of left shifts needed to normalize the 32 bit varia-| - | ble UL_var1 for positive values on the interval with minimum of | - | 0 and maximum of 0xffffffff, ; in order to normalize the | - | result, the following operation must be done : | - | | - | norm_UL_var1 = UL_lshl(UL_var1, norm_ul(UL_var1)). | - | | - | Complexity weight : 1 | - | | - | Inputs : | - | | - | UL_var1 | - | 32 bit long unsigned integer (UWord32) whose value falls in the | - | range : 0x0000 0000 <= var1 <= 0xffff ffff. | - | | - | Outputs : | - | | - | none | - | | - | Return Value : | - | | - | var_out | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0x0000 0000 <= var_out <= 0x0000 001f. (0..31d) | - |___________________________________________________________________________| +/*_____________________________________________________________________________ + | | + | Function Name : norm_ul | + | | + | Purpose : | + | | + | Produces the number of left shifts needed to normalize the 32 bit varia- | + | ble UL_var1 for positive values on the interval with minimum of | + | 0 and maximum of 0xffffffff, ; in order to normalize the | + | result, the following operation must be done : | + | | + | norm_UL_var1 = UL_lshl(UL_var1, norm_ul(UL_var1)). | + | | + | Complexity weight : 1 | + | | + | Inputs : | + | | + | UL_var1 | + | 32 bit long unsigned integer (UWord32) whose value falls in the | + | range : 0x0000 0000 <= var1 <= 0xffff ffff. | + | | + | Outputs : | + | | + | none | + | | + | Return Value : | + | | + | var_out | + | 16 bit short signed integer (Word16) whose value falls in the | + | range : 0x0000 0000 <= var_out <= 0x0000 001f. (0..31d) | + |_____________________________________________________________________________| */ -Word16 norm_ul( UWord32 UL_var1) -{ - Word16 var_out; +Word16 norm_ul (UWord32 UL_var1) { + Word16 var_out; - if (UL_var1 == 0) - { - var_out = 0; - } - else - { - /* simply test shift up until highest bit is set */ - for (var_out = 0; UL_var1 < (UWord32) 0x80000000U; var_out++) - { - UL_var1 <<= 1; - } + if (UL_var1 == 0) { + var_out = 0; + } + else { + /* simply test shift up until highest bit is set */ + for (var_out = 0; UL_var1 < (UWord32) 0x80000000U; var_out++) { + UL_var1 <<= 1; } + } -#ifdef WMOPS - multiCounter[currCounter].norm_l++; /* now new counter added for UL_ */ +#if (WMOPS) + multiCounter[currCounter].norm_ul++; #endif - return (var_out); -} + return (var_out); +} /*___________________________________________________________________________ | | @@ -134,243 +127,227 @@ Word16 norm_ul( UWord32 UL_var1) | | | 32 bits addition of the two unsigned 32 bits variables | | (L_var1+L_var2) with overflow control, but without saturation | - | + | | | Outputs : | - | *wrap = 1 if wrap occured, otherwize 0 | - | - | Return Value : - | UL_var3 = modulo(UL_var1+UL_var2,32) + | | + | *wrap = 1 if wrap occured, otherwize 0 | + | | + | Return Value : | + | | + | UL_var3 = modulo(UL_var1+UL_var2,32) | |___________________________________________________________________________| */ -UWord32 UL_addNs(UWord32 UL_var1, UWord32 UL_var2, UWord16 * wrap ) -{ - UWord32 UL_var3; - - /* STL Overflow flag is not updated */ - - UL_var3 = UL_var1 + UL_var2; /* 32bit wrap may occur, like in C */ - - if ( ( ((UWord64)UL_var1 + (UWord64)UL_var2) ) > ((UWord64) maxUWord32 ) ) - { - *wrap = 1; /* wrapped output */ +UWord32 UL_addNs (UWord32 UL_var1, UWord32 UL_var2, UWord16 * wrap) { + UWord32 UL_var3; + + /* STL Overflow flag is not updated */ + UL_var3 = UL_var1 + UL_var2; /* 32-bit wrap may occur, like in C */ + + if (((UWord64) UL_var1 + (UWord64) UL_var2) > 0xFFFFFFFFU) { + *wrap = 1; /* wrapped output */ } - else - { - *wrap = 0; + else { + *wrap = 0; } -#ifdef WMOPS - multiCounter[currCounter].L_add++; /* now new counter added for UL_ */ +#if WMOPS + multiCounter[currCounter].UL_addNs++; #endif - return UL_var3; + + return UL_var3; } /*___________________________________________________________________________ | | - | Function Name : UL_subNs | + | Function Name : UL_subNs | | | | Purpose : | | | | 32 bits subtraction of the two unsigned 32 bits variables | | (L_var1-L_var2) with overflow control, but without saturation | - | + | | | Outputs : | - | *sgn = 1 if wrap (to "negative" occured, otherwise 0 | - | - | Return Value : - | UL_var3 = modulo(UL_var1-UL_var2,32) + | | + | *sgn = 1 if wrap (to "negative" occured, otherwise 0) | + | | + | Return Value : | + | | + | UL_var3 = modulo(UL_var1-UL_var2,32) | |___________________________________________________________________________| */ -UWord32 UL_subNs(UWord32 UL_var1, UWord32 UL_var2, UWord16 * sgn) -{ +UWord32 UL_subNs (UWord32 UL_var1, UWord32 UL_var2, UWord16 * sgn) { UWord32 UL_var3; - UL_var3 = UL_var1 - UL_var2; /*wrap may occur, like in C */ - if (UL_var1 >= UL_var2) - { + UL_var3 = UL_var1 - UL_var2; /*wrap may occur, like in C */ + if (UL_var1 >= UL_var2) { *sgn = 0; } - else - { - *sgn = 1; /* "negative" , wrapped output */ + else { + *sgn = 1; /* "negative", wrapped output */ } -#ifdef WMOPS - multiCounter[currCounter].L_sub++; /* now new counter added for UL_ */ +#if WMOPS + multiCounter[currCounter].UL_subNs++; #endif - return UL_var3; + return UL_var3; } +/*________________________________________________________________________________ + | | + | Function Name : Mpy_32_16_uu | + | | + | Purpose : | + | | + | Multiplies the 2 unsigned values UL_var1 and uvar2. | + | The operation is performed in fractional mode : | + | - UL_var1 is supposed to be in Q32 format. | + | - var2 is supposed to be in Q16 format. | + | - The result is produced in Q48 format : UL_varout_h points to the | + | 32 MSBits while varout_l points to the 16 LSBits. | + | | + | Complexity weight : 2 | + | | + | Inputs : | + | | + | UL_var1 32 bit long unsigned integer (UWord32) whose value falls in | + | the range : 0x0000 0000 <= L_var1 <= 0xffff ffff. | + | | + | var2 16 bit short unsigned integer (UWord16) whose value falls in | + | the range : 0x0000 <= var2 <= 0x0000 ffff. | + | | + | Outputs : | + | | + | *UL_varout_h 32 bit long unsigned integer (UWord32) whose value falls in | + | the range : 0x0000 0000 <= UL_varout_h <= 0xffff ffff. | + | | + | *varout_l 16 bit short unsigned integer (UWord16) whose value falls in | + | the range : 0x0000 0000 <= varout_l <= 0x0000 ffff. | + | | + | Return Value : | + | | + | none | + |________________________________________________________________________________| +*/ +void Mpy_32_16_uu (UWord32 UL_var1, UWord16 uvar2, UWord32 *UL_varout_h, UWord16 *varout_l) { + UWord64 UL64_var1; + /* 4294967295 * 65535 < 281474976710655 */ + /* (uint64(2)^16-1 )*(uint64(2)^32-1) < (uint64(2)^(16+32)-1) */ + UL64_var1 = ((UWord64) UL_var1)*((UWord64) uvar2); + *varout_l = (UWord16) UL64_var1; + *UL_varout_h = (UWord32) (UL64_var1>>16); +#if (WMOPS) + multiCounter[currCounter].Mpy_32_16_uu++; +#endif /* if WMOPS */ -/***************************************************************************** - * - * Function Name : Mpy_32_16_uu - * - * Purpose : - * - * Multiplies the 2 unsigned values UL_var1 and uvar2 - * with saturation control on 48-bit.( does not happen for unsigned) - * The operation is performed in fractional mode : - * - UL_var1 is supposed to be in Q32 format. - * - var2 is supposed to be in Q16 format. - * - The result is produced in Q48 format : UL_varout_h points to the - * 32 MSBits while varout_l points to the 16 LSBits. - * - * Complexity weight : 2 - * - * Inputs : - * - * UL_var1 32 bit long unsigned integer (UWord32) whose value falls in - * the range : 0x0000 0000 <= L_var1 <= 0xffff ffff. - * - * var2 16 bit short unsigned integer (UWord16) whose value falls in - * the range : 0x0000 <= var2 <= 0x0000 ffff. - * - * Outputs : - * - * *UL_varout_h 32 bit long unsigned integer (UWord32) whose value falls in - * the range : 0x0000 0000 <= UL_varout_h <= 0xffff ffff. - * - * *varout_l 16 bit short unsigned integer (UWord16) whose value falls in - * the range : 0x0000 0000 <= varout_l <= 0x0000 ffff. - * - * Return Value : - * - * none - * - *****************************************************************************/ -void Mpy_32_16_uu( UWord32 UL_var1, UWord16 uvar2, UWord32 *UL_varout_h, UWord16 *varout_l) { - UWord64 UL64_var1; - - /* 4294967295 * 65535 < 281474976710655 */ - /* (uint64(2)^16-1 )*(uint64(2)^32-1) < (uint64(2)^(16+32)-1) */ - { - UL64_var1 = ( UWord64) UL_var1 * ( UWord64)uvar2 ; - - *varout_l = ( UWord16)( UL64_var1 ); - - *UL_varout_h = (UWord32)(UL64_var1>>16); - } - - #ifdef WMOPS - multiCounter[currCounter].Mpy_32_16_ss++; /* now new counter added for UL_ */ - #endif /* if WMOPS */ - - return; + return; } +/*__________________________________________________________________________________ + | | + | Function Name : Mpy_32_32_uu | + | | + | Purpose : | + | | + | Multiplies the 2 unsigned values UL_var1 and UL_var2. | + | The operation is performed in fractional mode : | + | - UL_var1 and UL_var2 are supposed to be in Q32 format. | + | - The result is produced in Q64 format : UL_varout_h points to the | + | 32 MSBits while UL_varout_l points to the 32 LSBits. | + | | + | Complexity weight : 4 | + | | + | Inputs : | + | | + | UL_var1 32 bit long unsigned integer (UWord32) whose value falls in the | + | range : 0x0000 0000 <= L_var1 <= 0xffff ffff. | + | | + | UL_var2 32 bit long unsigned integer (UWord32) whose value falls in the | + | range : 0x0000 0000 <= L_var2 <= 0xffff ffff. | + | | + | Outputs : | + | | + | *UL_varout_h 32 bit long signed integer (Word32) whose value falls in | + | the range : 0x0000 0000 <= UL_varout_h <= 0xffff ffff. | + | | + | *UL_varout_l 32 bit short unsigned integer (UWord32) whose value falls in | + | the range : 0x0000 0000 <= UL_varout_l <= 0xffff ffff. | + | | + | Return Value : | + | | + | none | + |__________________________________________________________________________________| + */ +void Mpy_32_32_uu (UWord32 UL_var1, UWord32 UL_var2, UWord32 *UL_varout_h, UWord32 *UL_varout_l) { + UWord64 UL64_var1; + /* (uint64(2)^32-1 )*(uint64(2)^32-1) < (uint64(2)^(32+32)-1) */ + UL64_var1 = ((UWord64) UL_var1)*((UWord64) UL_var2); + *UL_varout_h = (UWord32)(UL64_var1>>32); + *UL_varout_l = (UWord32)(UL64_var1); + +#if (WMOPS) + multiCounter[currCounter].Mpy_32_32_uu++; +#endif /* if WMOPS */ -/***************************************************************************** - * - * Function Name : Mpy_32_32_uu - * - * Purpose : - * - * Multiplies the 2 unsigned values UL_var1 and UL_var2 - * with saturation control on 64-bit. (not needed for unsigned) - * The operation is performed in fractional mode : - * - UL_var1 and UL_var2 are supposed to be in Q32 format. - * - The result is produced in Q64 format : UL_varout_h points to the - * 32 MSBits while UL_varout_l points to the 32 LSBits. - * - * Complexity weight : 4 - * - * Inputs : - * - * UL_var1 32 bit long unsigned integer (UWord32) whose value falls in the - * range : 0x0000 0000 <= L_var1 <= 0xffff ffff. - * - * UL_var2 32 bit long unsigned integer (UWord32) whose value falls in the - * range : 0x0000 0000 <= L_var2 <= 0xffff ffff. - * - * Outputs : - * - * *UL_varout_h 32 bit long signed integer (Word32) whose value falls in - * the range : 0x0000 0000 <= UL_varout_h <= 0xffff ffff. - * - * *UL_varout_l 32 bit short unsigned integer (UWord32) whose value falls in - * the range : 0x0000 0000 <= UL_varout_l <= 0xffff ffff. - * - * - * Return Value : - * - * none - * - *****************************************************************************/ -void Mpy_32_32_uu( UWord32 UL_var1, UWord32 UL_var2, UWord32 *UL_varout_h, UWord32 *UL_varout_l) -{ - UWord64 UL64_var1; - - /* (uint64(2)^32-1 )*(uint64(2)^32-1) < (uint64(2)^(32+32)-1) */ - { - UL64_var1 = ((UWord64) UL_var1)*((UWord64) UL_var2); - *UL_varout_h = (UWord32)(UL64_var1>>32); - *UL_varout_l = (UWord32)(UL64_var1); - } - #ifdef WMOPS - multiCounter[currCounter].Mpy_32_32_ss++; /* now new counter added for UL_ */ - #endif /* if WMOPS */ - - return; + return; } -/***************************************************************************** - * - * Function Name : UL_Mpy_32_32 - * - * Purpose : - * - * Multiplies the 2 unsigned values UL_var1 and UL_var2 - * and returns the lower 32 bits, without saturation control. - * - * - UL_var1 and UL_var2 are supposed to be in Q32 format. - * - The result is produced in Q64 format, (the 32 LSBits. ) - * - * operates like a regular 32-by-32 bit unsigned int multiplication in ANSI-C. - * UWord32) = (unsigned int)*(unsigned int); - * - * - * Complexity weight : 2 - * - * Inputs : - * - * UL_var1 32 bit long unsigned integer (UWord32) whose value falls in the - * range : 0x0000 0000 <= UL_var1 <= 0xffff ffff. - * - * UL_var2 32 bit long unsigned integer (UWord32) whose value falls in the - * range : 0x0000 0000 <= UL_var2 <= 0xffff ffff. - * - * Outputs : - * - * Return Value : - * *UL_varout_l 32 bit short unsigned integer (UWord32) whose value falls in - * the range : 0x0000 0000 <= UL_varout_l <= 0xffff ffff. - * - * none - * - *****************************************************************************/ -UWord32 UL_Mpy_32_32( UWord32 UL_var1, UWord32 UL_var2) -{ - UWord32 UL_varout_l; +/*_____________________________________________________________________________________ + | | + | Function Name : UL_Mpy_32_32 | + | | + | Purpose : | + | | + | Multiplies the 2 unsigned values UL_var1 and UL_var2 | + | and returns the lower 32 bits, without saturation control. | + | | + | - UL_var1 and UL_var2 are supposed to be in Q32 format. | + | - The result is produced in Q64 format, the 32 LSBits. | + | | + | operates like a regular 32-by-32 bit unsigned int multiplication in ANSI-C. | + | UWord32) = (unsigned int)*(unsigned int); | + | | + | | + | Complexity weight : 2 | + | | + | Inputs : | + | | + | UL_var1 32 bit long unsigned integer (UWord32) whose value falls in the | + | range : 0x0000 0000 <= UL_var1 <= 0xffff ffff. | + | | + | UL_var2 32 bit long unsigned integer (UWord32) whose value falls in the | + | range : 0x0000 0000 <= UL_var2 <= 0xffff ffff. | + | | + | Outputs : | + | | + | none | + | | + | Return Value : | + | *UL_varout_l 32 bit short unsigned integer (UWord32) whose value falls in | + | the range : 0x0000 0000 <= UL_varout_l <= 0xffff ffff. | + | | + |_____________________________________________________________________________________| +*/ +UWord32 UL_Mpy_32_32 (UWord32 UL_var1, UWord32 UL_var2) { + UWord32 UL_varout_l; #define MASK32 0xFFFFFFFFU - /* MASK32 may be needed in case Hardware is using larger than 32 bits for UWord32 type) */ - UL_varout_l = (UL_var1&MASK32)*(UL_var2&MASK32); - UL_varout_l = (UL_varout_l&MASK32); -#undef MASK32 - + /* MASK32 may be needed in case Hardware is using larger than 32 bits for UWord32 type */ + UL_varout_l = (UL_var1&MASK32)*(UL_var2&MASK32); + UL_varout_l = UL_varout_l&MASK32; +#undef MASK32 -#ifdef WMOPS - multiCounter[currCounter].Mpy_32_16_ss++; /* now new counters added for UL_ ops*/ +#if (WMOPS) + multiCounter[currCounter].UL_Mpy_32_32++; #endif /* if WMOPS */ - return UL_varout_l; + return UL_varout_l; } + #ifdef STL_TYPECASTS /* (Reuse of existing signed STL "L" operators) with typecasting to make the resulting "UL" code a lot cleaner and more readable. */ @@ -427,6 +404,6 @@ UWord32 UL_addNsD(UWord32 UL_var1, UWord32 UL_var2 ) } #endif -#endif /* ENHUL32 */ +#endif /* ENH_U_32_BIT_OPERATOR */ /* end of file */ diff --git a/basic_op/enhUL32.h b/basic_op/enhUL32.h index 1d6df3847581a0383d1ba436ad027d516823ee2f..a89b2489b20ef5b55ec2fb1d1de3bc15e3b48834 100644 --- a/basic_op/enhUL32.h +++ b/basic_op/enhUL32.h @@ -1,36 +1,30 @@ /* - =========================================================================== - File: ENHUL32.H v.0.5 - 19.Mar.2014 - =========================================================================== + ============================================================================ + File: ENHUL32.H v.1.0 - 01.July.2018 + ============================================================================ ============================================================================ */ - #ifndef _ENHUL32_H #define _ENHUL32_H - /***************************************************************************** * * Constants and Globals * *****************************************************************************/ -#define ENHUL32 /* all the enhanced unsigned operators */ #define STL_TYPECASTS /* logical shift and bitwise manipulation functions */ /* algorithmically exact to existing signed L_lshr and L_lshr */ -#include "stl.h" +#include "stl.h" #ifndef UWord64 -#define UWord64 unsigned long long /* for local use inside UL_Mpy_32_* */ +#define UWord64 unsigned long long /* for local use inside UL_Mpy_32_* */ #endif - - - -#ifdef WMOPS +#if (WMOPS) #include "count.h" extern BASIC_OP multiCounter[MAXCOUNTERS]; /* existing signed counters are reused for unsigedn operators */ extern int currCounter; @@ -41,17 +35,17 @@ extern int currCounter; * Prototypes for enhanced unsigned 32 bit arithmetic operators * *****************************************************************************/ -UWord32 UL_addNs(UWord32 a, UWord32 b, UWord16* wrap); -UWord32 UL_subNs(UWord32 a, UWord32 b, UWord16* sgn); - -UWord32 UL_Mpy_32_32(UWord32 a, UWord32 b); -void Mpy_32_32_uu( UWord32 a, UWord32 b, UWord32 *c_h, UWord32 *c_l); /* does not saturate */ -void Mpy_32_16_uu( UWord32 a, UWord16 b,UWord32 *c_h, UWord16 *c_l); /* does not saturate */ +#ifdef ENH_U_32_BIT_OPERATOR +UWord32 UL_addNs (UWord32 a, UWord32 b, UWord16* wrap); +UWord32 UL_subNs (UWord32 a, UWord32 b, UWord16* sgn); -/* Other */ -Word16 norm_ul (UWord32 UL_var1); -UWord32 UL_deposit_l(UWord16); /* deposit low without sign extension ) */ +UWord32 UL_Mpy_32_32 (UWord32 a, UWord32 b); +void Mpy_32_32_uu (UWord32 a, UWord32 b, UWord32 *c_h, UWord32 *c_l); /* does not saturate */ +void Mpy_32_16_uu (UWord32 a, UWord16 b, UWord32 *c_h, UWord16 *c_l); /* does not saturate */ +Word16 norm_ul (UWord32 UL_var1); +UWord32 UL_deposit_l (UWord16); /* deposit low without sign extension */ +#endif /* ENH_U_32_BIT_OPERATOR */ /***************************************************************************** * diff --git a/basic_op/move.h b/basic_op/move.h index 7be629a71dff59fb43d86b32d20774c07ec0f4e7..8a02bd99c9e0d4eb41c0d6e4a2e8239678ce6953 100644 --- a/basic_op/move.h +++ b/basic_op/move.h @@ -25,16 +25,16 @@ #include "stl.h" -#ifdef WMOPS +#if (WMOPS) extern BASIC_OP multiCounter[MAXCOUNTERS]; extern int currCounter; -#endif /* if WMOPS */ +#endif /* ifdef WMOPS */ -static __inline void move16( void) { -#ifdef WMOPS - multiCounter[currCounter].move16++; -#endif /* if WMOPS */ +static __inline void move16 (void) { +#if WMOPS + multiCounter[currCounter].move16++; +#endif /* ifdef WMOPS */ } @@ -42,43 +42,50 @@ static __inline void move16( void) { -static __inline void move32( void) { -#ifdef WMOPS - multiCounter[currCounter].move32++; -#endif /* if WMOPS */ +static __inline void move32 (void) { +#if WMOPS + multiCounter[currCounter].move32++; +#endif /* ifdef WMOPS */ } +#ifdef ENH_64_BIT_OPERATOR +static __inline void move64 (void) { +#if WMOPS + multiCounter[currCounter].move64++; +#endif /* if WMOPS */ +} +#endif /* #ifdef ENH_64_BIT_OPERATOR */ -static __inline void test( void) { -#ifdef WMOPS - multiCounter[currCounter].Test++; -#endif /* if WMOPS */ +static __inline void test (void) { +#if WMOPS + multiCounter[currCounter].Test++; +#endif /* ifdef WMOPS */ } -static __inline void logic16( void) { -#ifdef WMOPS - multiCounter[currCounter].Logic16++; -#endif /* if WMOPS */ +static __inline void logic16 (void) { +#if WMOPS + multiCounter[currCounter].Logic16++; +#endif /* ifdef WMOPS */ } -static __inline void logic32( void) { -#ifdef WMOPS - multiCounter[currCounter].Logic32++; -#endif /* if WMOPS */ +static __inline void logic32 (void) { +#if WMOPS + multiCounter[currCounter].Logic32++; +#endif /* ifdef WMOPS */ } /*-------- legacy ----------*/ -#define data_move() move16() -#define L_data_move() move32() -#define data_move_external() move16() -#define compare_zero() test() +#define data_move () move16 () +#define L_data_move () move32 () +#define data_move_external () move16 () +#define compare_zero () test () /*-------- end legacy ----------*/ diff --git a/basic_op/patch.h b/basic_op/patch.h new file mode 100644 index 0000000000000000000000000000000000000000..c843cb78bf069494e8ee897309c869ec8e70d077 --- /dev/null +++ b/basic_op/patch.h @@ -0,0 +1,51 @@ +/* + =========================================================================== + File: PATCH.H v.2.3 - 30.Nov.2009 + =========================================================================== + + ITU-T STL BASIC OPERATORS + + OPERATOR NAME PATCHING + + History: + 07 Nov 04 v2.0 Incorporation of new 32-bit / 40-bit / control + operators for the ITU-T Standard Tool Library as + described in Geneva, 20-30 January 2004 WP 3/16 Q10/16 + TD 11 document and subsequent discussions on the + wp3audio@yahoogroups.com email reflector. + + ============================================================================ +*/ + + +#ifndef _PATCH_H +#define _PATCH_H + + +#if 1 +/***************************************************************************** + * start of Patch1 : + * It is enabled. + * + * This patch enables to keep compatibility with old ITU DSP operator names + * following naming conventions as proposed to ITU-T Standard Tool Library + * definition group in Geneva, 20-30 January 2004 WP 3/16 Q10/16 + * TD 11 document. + * + *****************************************************************************/ +#define shift_r( var1, var2) shl_r( var1, var2) +#define L_shift_r( L_var1, var2) L_shl_r( L_var1, var2) + + +#endif /* end of Patch1 */ + + + + + + + + + + +#endif /* end of _PATCH_H */ diff --git a/basic_op/stl.h b/basic_op/stl.h index 0bce7969a33c5c82bf7280cf46e0e36494f3ba6f..0ba4c3ff353b059179c8da826aea3b76f209d000 100644 --- a/basic_op/stl.h +++ b/basic_op/stl.h @@ -13,8 +13,7 @@ described in Geneva, 20-30 January 2004 WP 3/16 Q10/16 TD 11 document and subsequent discussions on the wp3audio@yahoogroups.com email reflector. - March 06 v2.1 Changed to improve portability. - 31 Mar 15 v2.1E Clarified usage of operators needed for the EVS codec. + March 06 v2.1 Changed to improve portability. ============================================================================ */ @@ -23,28 +22,44 @@ #ifndef _STL_H #define _STL_H + +#include /* for size_t */ + +#define ENH_U_32_BIT_OPERATOR +#define COMPLEX_OPERATOR +#define CONTROL_CODE_OPS +#define ENH_32_BIT_OPERATOR + +#include "patch.h" /* both ALLOW_40bits and ALLOW_ENH_UL32 shall be enabled for the EVS codec. */ #define ALLOW_40bits /* allow 32x16 and 32x32 multiplications */ #define ALLOW_ENH_UL32 /* allow enhanced unsigned 32bit operators */ - -#include "options.h" /* note: needed until BASOP_NOGLOB is accepted */ #include "typedef.h" -#include "typedefs.h" -#include "basop32.h" +#include "basop32.h" #include "count.h" -#include "wmc_auto.h" #include "move.h" #include "control.h" -#include "enh1632.h" +#include "enh1632.h" #include "oper_32b.h" #include "math_op.h" #include "log2.h" -#if defined (ALLOW_40bits) #include "enh40.h" + + +#ifdef ENH_64_BIT_OPERATOR +#include "enh64.h" +#endif + +#ifdef ENH_32_BIT_OPERATOR +#include "enh32.h" +#endif + +#ifdef COMPLEX_OPERATOR +#include "complex_basop.h" #endif -#if defined (ALLOW_ENH_UL32) +#ifdef ENH_U_32_BIT_OPERATOR #include "enhUL32.h" #endif diff --git a/basic_op/typedef.h b/basic_op/typedef.h index 31972be5dd125388102d8ad0ac148adebcae5be0..cd031a3a6e3a7964d9ddacfb6291779c2147b394 100644 --- a/basic_op/typedef.h +++ b/basic_op/typedef.h @@ -8,15 +8,15 @@ TYPE DEFINITION PROTOTYPES History: - 26.Jan.00 v1.0 Incorporated to the STL from updated G.723.1/G.729 + 26.Jan.00 v1.0 Incorporated to the STL from updated G.723.1/G.729 basic operator library (based on basic_op.h) 03 Nov 04 v2.0 Incorporation of new 32-bit / 40-bit / control - operators for the ITU-T Standard Tool Library as + operators for the ITU-T Standard Tool Library as described in Geneva, 20-30 January 2004 WP 3/16 Q10/16 TD 11 document and subsequent discussions on the wp3audio@yahoogroups.com email reflector. - March 06 v2.1 Changed to improve portability. + March 06 v2.1 Changed to improve portability. ============================================================================ */ @@ -32,13 +32,8 @@ #ifndef _TYPEDEF_H #define _TYPEDEF_H "$Id $" - - -#define ORIGINAL_TYPEDEF_H /* Define to get "original" version * - * of typedef.h (this file). */ - #undef ORIGINAL_TYPEDEF_H /* Undefine to get the "new" version * - * of typedef.h (see typedefs.h). */ - +#define ORIGINAL_TYPEDEF_H /* Define to get "original" version of typedef.h (this file). */ +#undef ORIGINAL_TYPEDEF_H /* Undefine to get the "new" version of typedef.h (see typedefs.h). */ #ifdef ORIGINAL_TYPEDEF_H @@ -74,7 +69,7 @@ typedef unsigned short UWord16; typedef unsigned long UWord32; typedef int Flag; -#elif defined(__unix__) || defined(__unix) +#elif defined(__unix__) || defined(__unix) || defined(__APPLE__) typedef signed char Word8; typedef short Word16; typedef int Word32; diff --git a/basic_op/typedefs.h b/basic_op/typedefs.h index c3e19f71b01b7a155bf448cfafe256428afed682..c0e7645a706bbbc90c4bc34adcf8d58db0035f26 100644 --- a/basic_op/typedefs.h +++ b/basic_op/typedefs.h @@ -72,7 +72,7 @@ #include #include - +#define ENH_64_BIT_OPERATOR /***************************************************************************** * DEFINITION OF CONSTANTS @@ -86,6 +86,7 @@ typedef unsigned short int UNS_Word16; /* 16 bit "register" (sw*) */ #ifdef UNS_Word16 #pragma message ("UNS_Word16 is defined but not officially part of STL2009@") #endif + /* ********* define 8 bit signed/unsigned types & constants */ @@ -101,6 +102,7 @@ typedef unsigned char UWord8; #error cannot find 8-bit type #endif + /* ********* define 16 bit signed/unsigned types & constants */ @@ -122,6 +124,11 @@ typedef unsigned short UWord16; #error cannot find 16-bit type #endif +/* Definition of Word64 */ +#ifdef ENH_64_BIT_OPERATOR +#define Word64 long long int +#endif /* #ifdef ENH_64_BIT_OPERATOR */ + /* Definition of Word40 was missing 10/06/2013 */ #define Word40 long long @@ -152,16 +159,22 @@ typedef unsigned long UWord32; /* use "if 0" below if Float should be double; use "if 1" below if Float should be float */ +#if 0 +typedef float Float; +#define maxFloat FLT_MAX +#define minFloat FLT_MIN +#else typedef double Float; #define maxFloat DBL_MAX #define minFloat DBL_MIN +#endif /* ********* define complex type */ typedef struct { - Float r; /* real part */ - Float i; /* imaginary part */ + Float r; /* real part */ + Float i; /* imaginary part */ } CPX; /* @@ -174,19 +187,19 @@ typedef int Bool; /* ********* Check current platform */ -#if defined(__MSDOS__) +#if defined (__MSDOS__) #define PC #define PLATFORM "PC" #define LSBFIRST -#elif defined(__osf__) +#elif defined (__osf__) #define OSF #define PLATFORM "OSF" #define LSBFIRST -#elif defined(__sun__) || defined(__sun) +#elif defined (__sun__) || defined (__sun) #define SUN #define PLATFORM "SUN" #undef LSBFIRST -#elif defined(linux) && defined(i386) +#elif defined (linux) && defined (i386) #define PC #define PLATFORM "PC" #define LSBFIRST diff --git a/lib_com/ACcontextMapping.c b/lib_com/ACcontextMapping.c index b11113a3232e0e65973edd5672a182d4e7de7ad3..2581d0ff02b2a16704a95749fbc3bdb46fe39dcb 100644 --- a/lib_com/ACcontextMapping.c +++ b/lib_com/ACcontextMapping.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -12,9 +12,6 @@ #include "prot_fx.h" #include "rom_com_fx.h" #include "stl.h" -#include "wmc_auto.h" - - /* Returns: index of next coefficient */ Word16 get_next_coeff_mapped( diff --git a/lib_com/ari.c b/lib_com/ari.c index cd63f9a977dc8d72ad8d32644a81d8851b023e38..da6fa93c514bf98125cfdabcbc0aa53af2535c84 100644 --- a/lib_com/ari.c +++ b/lib_com/ari.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -8,9 +8,6 @@ #include "basop_mpy.h" #include "cnst_fx.h" #include "stl.h" -#include "wmc_auto.h" - - /** * \brief 31x16 Bit multiply (x*y) diff --git a/lib_com/ari_hm.c b/lib_com/ari_hm.c index 72bd6cf69c32fa34152a926cf5b883805cce589a..6fa0523bd719b9506a1505f8435f6fc705341d59 100644 --- a/lib_com/ari_hm.c +++ b/lib_com/ari_hm.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ @@ -8,9 +8,6 @@ #include #include #include "stl.h" -#include "wmc_auto.h" - - #include "cnst_fx.h" #include "basop_util.h" #include "rom_com_fx.h" @@ -43,19 +40,19 @@ void UnmapIndex( } ELSE { - IF (sub(PeriodicityIndex, 16) < 0) + IF (LT_16(PeriodicityIndex, 16)) { *FractionalResolution = 3; move16(); Lag16 = add(PeriodicityIndex, GET_ADJ2(0, 6, 3)); } - ELSE IF (sub(PeriodicityIndex, 80) < 0) + ELSE IF (LT_16(PeriodicityIndex, 80)) { *FractionalResolution = 4; move16(); Lag16 = add(PeriodicityIndex, GET_ADJ2(16, 8, 4)); } - ELSE IF (sub(PeriodicityIndex, 208) < 0) + ELSE IF (LT_16(PeriodicityIndex, 208)) { *FractionalResolution = 3; move16(); @@ -63,7 +60,7 @@ void UnmapIndex( } ELSE { test(); - IF (sub(PeriodicityIndex, 224) < 0 || SmallerLags != 0) + IF (LT_16(PeriodicityIndex, 224)||SmallerLags!=0) { *FractionalResolution = 1; move16(); @@ -96,7 +93,7 @@ void ConfigureContextHm( Bandwidth = 0; move16(); - if (sub(NumCoeffs, 256) >= 0) + if (GE_16(NumCoeffs, 256)) { Bandwidth = 1; move16(); @@ -105,7 +102,7 @@ void ConfigureContextHm( SmallerLags = 0; move16(); test(); - if ((sub(TargetBits, kSmallerLagsTargetBitsThreshold) <= 0) || (Bandwidth == 0)) + if ((LE_16(TargetBits, kSmallerLagsTargetBitsThreshold))||(Bandwidth==0)) { SmallerLags = 1; move16(); @@ -121,7 +118,7 @@ void ConfigureContextHm( hm_cfg->peakIndices = hm_cfg->indexBuffer; tmp = hm_cfg->peakIndices; Limit = L_shl(L_deposit_l(sub(NumCoeffs, 1)), FractionalResolution); - IF (L_sub(Lag, Limit) < 0) + IF (LT_32(Lag, Limit)) { FOR (i=Lag; i 0 ) + IF( GT_16(13915,PeakDeviation)) { /* A bit error was encountered */ return 1; @@ -276,7 +273,7 @@ void tcx_hm_modify_envelope( L_frame_m1 = sub(L_frame,1); L_frame_for_loop = add(L_frame,kTcxHmParabolaHalfWidth - 1); - WHILE ( sub(k,L_frame_for_loop) <= 0 ) + WHILE ( LE_16(k,L_frame_for_loop)) { l1 = s_max(0, sub(k,kTcxHmParabolaHalfWidth)); l2 = s_min(add(k,kTcxHmParabolaHalfWidth), L_frame_m1); diff --git a/lib_com/arith_coder.c b/lib_com/arith_coder.c index af428337eeb5705c4462da8646605c78cf6c685e..62e614853b032ac1b215c183cf92495075748f07 100644 --- a/lib_com/arith_coder.c +++ b/lib_com/arith_coder.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -12,9 +12,6 @@ #include "options.h" #include "cnst_fx.h" #include "stl.h" -#include "wmc_auto.h" - - /* Fixed point implementation of exp(negate()) */ Word32 expfp( /* o: Q31 */ @@ -290,7 +287,7 @@ void tcx_arith_scale_envelope( { s = Mpy_32_16_1(ienv[k], scale); /* Q16 */ - IF (L_sub(s, 5243l/*0.08f Q16*/) <= 0) + IF (LE_32(s, 5243l/*0.08f Q16*/)) { /* If s = 0.08, the expected bit-consumption is log2(1.0224). Below 0.08, the bit-consumption estimate function becomes inaccurate, so use log2(1.0224) for all values below 0.08. */ @@ -300,7 +297,7 @@ void tcx_arith_scale_envelope( statesi = shl(statesi, tmp); bits = add(bits, sub(1, tmp)); } - ELSE IF (L_sub(s, 16711680l/*255.0 Q16*/) <= 0) + ELSE IF (LE_32(s, 16711680l/*255.0 Q16*/)) { /* a = 5.436564f * s + 0.15f + 0.035f * env[k] * iscale; */ L_tmp = L_shl(Mpy_32_16_1(s, 22268/*5.436564f Q12*/), 3); @@ -325,7 +322,7 @@ void tcx_arith_scale_envelope( } } - IF (sub(bits, target_bits) <= 0) /* Bits leftover => scale is too small */ + IF (LE_16(bits, target_bits)) /* Bits leftover => scale is too small */ { lob = scale; move16(); diff --git a/lib_com/basop_mpy.c b/lib_com/basop_mpy.c deleted file mode 100644 index 0a695991436010bbc58c24d4898d903ce563c13b..0000000000000000000000000000000000000000 --- a/lib_com/basop_mpy.c +++ /dev/null @@ -1,60 +0,0 @@ -/*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 - ====================================================================================*/ - -#include "basop_mpy.h" -#include "stl.h" -#include "wmc_auto.h" - -#include "options.h" /* Needed for Stack Counting Mechanism Macros (when Instrumented) */ - -Word32 Mpy_32_16_1(Word32 x, Word16 y) -{ - Word32 mh; - UWord16 ml; - - Mpy_32_16_ss(x, y, &mh, &ml); - - return (mh); -} - -Word32 Mpy_32_16_r(Word32 x, Word16 y) -{ - Word32 mh; - UWord16 ml; - - Mpy_32_16_ss(x, y, &mh, &ml); - - if(s_and(ml, -32768 /* 0x8000 */)) - { - mh = L_add(mh, 1); - } - - return (mh); -} - -Word32 Mpy_32_32(Word32 x, Word32 y) -{ - Word32 mh; - UWord32 ml; - - Mpy_32_32_ss(x, y, &mh, &ml); - - return (mh); -} - -Word32 Mpy_32_32_r(Word32 x, Word32 y) -{ - Word32 mh; - UWord32 ml; - - Mpy_32_32_ss(x, y, &mh, &ml); - - if(L_and(ml, 0x80000000)) - { - mh = L_add(mh, 1); - } - - return (mh); -} - diff --git a/lib_com/basop_mpy.h b/lib_com/basop_mpy.h index 44dc37c461f1ea3d1ca032a907ddc4236e81ab85..dce472e2123234777a8a41495d4e49900265ba16 100644 --- a/lib_com/basop_mpy.h +++ b/lib_com/basop_mpy.h @@ -1,104 +1,10 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #ifndef __BASOP_MPY_H #define __BASOP_MPY_H -#include "stl.h" -#include "options.h" - -/** - * \brief 32*16 Bit fractional Multiplication using 40 bit OPS - * Performs a multiplication of a 32-bit variable x by - * a 16-bit variable y, returning a 32-bit value. - * - * \param[i] x - * \param[i] y - * - * \return x*y - */ -Word32 Mpy_32_16_1(Word32 x, - Word16 y); - -/** - * \brief 32*16 Bit fractional Multiplication using 40 bit OPS - * Performs a multiplication of a 32-bit variable x by - * a 16-bit variable y incl. rounding, returning a 32-bit value. - * - * \param[i] x - * \param[i] y - * - * \return x*y - */ -Word32 Mpy_32_16_r(Word32 x, - Word16 y); - -/** - * \brief 32*32 Bit fractional Multiplication using 40 bit OPS - * - * Performs a multiplication of a 32-bit variable x by - * a 32-bit variable y, returning a 32-bit value. - * - * \param[i] x - * \param[i] y - * - * \return x*y - */ -Word32 Mpy_32_32(Word32 x, - Word32 y); - -/** - * \brief 32*32 Bit fractional Multiplication using 40 bit OPS including rounding - * - * Performs a multiplication of a 32-bit variable x by - * a 32-bit variable y, returning a 32-bit value. - * - * \param[i] x - * \param[i] y - * - * \return x*y - */ -Word32 Mpy_32_32_r(Word32 x, Word32 y); - -/** - * \brief 32*16 Bit integer Multiplication using 40 bit OPS - * - * Performs a multiplication of a 32-bit variable x by - * a 16-bit variable y, returning a 32-bit value. - * - * \param[i] x - * \param[i] y - * - * \return x*y - */ -Word32 Mpy_32_16_2(Word32 x, - Word16 y); - - -/** - * \brief 32*16 Bit complex fractional multiplication using 40 Bit and 32 Bit operators - * - * The function mixes 40 Bit and 32 Bit operators, thus it must not be applied - * inside of loops where 32 and 16 bit operators are used. - * - * \param[i] c_Re - * \param[i] c_Im - * \param[i] a_Re - * \param[i] a_Im - * \param[i] b_Re - * \param[i] b_Im - * - * \return none - */ -void cplxMpy_32_16(Word32 *c_Re, - Word32 *c_Im, - const Word32 a_Re, - const Word32 a_Im, - const Word16 b_Re, - const Word16 b_Im - ); - #define MUL_F(A,B) Mpy_32_16_1((A),(B)) #endif /* __BASOP_SETTINGS_H */ diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c index 46b97b898cd7f445f05ac858117402a68e0e755a..58979d9bf394ed87454a521e70808f47e9091f80 100644 --- a/lib_com/basop_util.c +++ b/lib_com/basop_util.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "basop_util.h" @@ -13,8 +13,6 @@ #include #include "stl.h" -#include "wmc_auto.h" - #define DOT12_SUBDIV_LD 2 /* log2(number of dot product sub divisions) */ @@ -118,7 +116,7 @@ Word32 BASOP_Util_InvLog2(Word32 x) return 0; } test(); - if ( (L_sub(x,1040187392l/*31.0/64.0 Q31*/) >= 0) || (x == 0) ) + if ( (GE_32(x,1040187392l/*31.0/64.0 Q31*/))||(x==0)) { return 0x7FFFFFFF; @@ -476,24 +474,6 @@ Word32 Sqrt32( /*!< output mantissa */ return mantissa; } -Word32 Sqrt32norm( /*!< output mantissa */ - Word32 mantissa, /*!< normalized input mantissa */ - Word16 *exponent /*!< pointer to exponent */ -) -{ - - assert((mantissa >= 0x40000000) || (mantissa == 0)); - - /* calc mantissa */ - mantissa = Sqrt32_common(mantissa, *exponent); - - /* e = (e + 1) >> 1 */ - *exponent = mult_r(*exponent, 1 << 14); - move16(); - - return mantissa; -} - Word32 ISqrt32( /*!< output mantissa */ Word32 mantissa, /*!< input mantissa */ @@ -708,8 +688,8 @@ Word16 getScaleFactor32( /* o: measured headroom in range [0..31], - x_max = L_add(0, 0); - x_min = L_add(0, 0); + x_max = 0; move32(); + x_min = 0; move32(); FOR (i = 0; i < len_x; i++) { if (x[i] >= 0) @@ -791,7 +771,7 @@ Word16 divide1616(Word16 x, Word16 y) move16(); z = 0x7fff; - if ( sub(num, den) < 0) + if ( LT_16(num, den)) z = div_s(num,den); if (0 != sign) @@ -858,12 +838,12 @@ Word16 BASOP_Util_Divide3232_uu_1616_Scale(Word32 x, Word32 y, Word16 *s) x16 = extract_h(L_shl(x,sx)); y16 = extract_h(L_shl(y,sy)); - if(sub(x16,y16) > 0) + if(GT_16(x16,y16)) { sx = sub(sx,1); } - if(sub(y16,x16) < 0) + if(LT_16(y16,x16)) { x16 = mult_r(x16,0x4000); } @@ -925,10 +905,10 @@ Word16 BASOP_Util_Divide3216_Scale( /* o: result of division x/y, not normaliz } sign = s_xor(extract_h(x),y); /* just to exor the sign bits */ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF x = L_abs(x); y = abs_s(y); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON sx = sub(norm_l(x),1); x = L_shl(x,sx); sy = norm_s(y); @@ -1200,10 +1180,10 @@ Word16 getCosWord16R2(Word16 theta) residual = fixp_sin_cos_residual_16(theta, 1, &sine, &cosine, 1); /* This negation prevents the subsequent addition from overflow */ /* The negation cannot overflow, sine is in range [0x0..0x7FFF] */ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF sine = negate(sine); result = msu_r(L_mult(sine, residual), cosine, -32768); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON return result; @@ -1285,7 +1265,7 @@ Word16 findIndexOfMinWord32(Word32 *x, const Word16 len) move16(); FOR (i = 1; i < len; i++) { - if (L_sub(x[i],x[indx]) < 0) + if (LT_32(x[i],x[indx])) { indx = i; move16(); @@ -1408,6 +1388,29 @@ Word32 norm_llQ31( /* o : normalized result Q31 */ return L_sum; } +Word32 w_norm_llQ31( Word64 L_sum, Word16 * exp ); +Word32 w_norm_llQ31( /* o : normalized result Q31 */ + Word64 L_sum, /* i : upper and lower bits of accu, unsigned Q31 */ + Word16 * exp /* o : exponent of result in [-32,31] Q0 */ +) +{ + Word32 L_tmp; + Word16 exp_val; + Word64 L64_inp64 = L_sum; move64(); + + L64_inp64 = W_shl( L64_inp64, 1); + exp_val = W_norm( L64_inp64 ); + L64_inp64 = W_shl( L64_inp64, exp_val ); + exp_val = sub( 31, exp_val ); + if(EQ_64(L_sum , 0)) + { + exp_val = -32; move16(); + } + *exp = exp_val; move16(); + + L_tmp = W_extract_h( L64_inp64 ); + return L_tmp; +} Word32 Dot_product16HQ( /* o : normalized result Q31 */ const Word32 L_off, /* i : initial sum value Qn */ @@ -1418,30 +1421,17 @@ Word32 Dot_product16HQ( /* o : normalized result Q31 */ ) { Word16 i; - Word32 L_sum, L_c, L_test; - /* Clear carry flag and init sum */ - Carry = 0; - L_c = L_add(0,0); - L_sum = L_macNs(L_off,0,0); - if (L_sum > 0) - L_c = L_macNs(L_c,0,0); - if (L_sum < 0) - L_c = L_msuNs(L_c,0,0); + Word32 L_sum; + Word64 L_sum64; + + L_sum64 = W_deposit32_l( L_off ); FOR (i=0; i < lg; i++) { - BASOP_SATURATE_WARNING_OFF;/*in case of both multiplicands being -32768, overflow occurs - not severe*/ - L_test = L_mult(x[i], y[i]); - BASOP_SATURATE_WARNING_ON; - Carry = 0; - L_sum = L_macNs(L_sum, x[i], y[i]); - Overflow = 0; /* to avoid useless warning in L_macNs/L_msuNs calling L_mult */ - if (L_test >= 0) - L_c = L_macNs(L_c,0,0); - if (L_test < 0) - L_c = L_msuNs(L_c,0,0); - } - L_sum = norm_llQ31(L_c,L_sum,exp); + L_sum64 = W_mac_16_16(L_sum64,x[i], y[i]); + } + + L_sum = w_norm_llQ31(L_sum64,exp); return L_sum; } @@ -1479,26 +1469,17 @@ Word32 Dot_productSq16HQ( /* o : normalized result Q31 */ ) { Word16 i; - Word32 L_sum, L_c; - /* Clear carry flag and init sum */ - Carry = 0; - L_c = L_add(0,0); - L_sum = L_macNs(L_off,0,0); - if (L_sum > 0) - L_c = L_macNs(L_c,0,0); - if (L_sum < 0) - L_c = L_msuNs(L_c,0,0); + Word32 L_sum; + Word64 L_sum64; + + L_sum64 = W_deposit32_l( L_off ); FOR (i=0; i < lg; i++) { - Carry = 0; - BASOP_SATURATE_WARNING_OFF;/*multiplication of -32768 * -32768 throws an overflow, but is not critical*/ - L_sum = L_macNs(L_sum, x[i], x[i]); - BASOP_SATURATE_WARNING_ON; - Overflow = 0; /* to avoid useless warning in L_macNs calling L_mult */ - L_c = L_macNs(L_c,0,0); + L_sum64 = W_mac_16_16(L_sum64, x[i], x[i]); } - L_sum = norm_llQ31(L_c,L_sum,exp); + L_sum = w_norm_llQ31(L_sum64,exp); + return L_sum; } @@ -1510,7 +1491,8 @@ Word32 dotp_s_fx(const Word16 *x, const Word16 *y, const Word16 n, Word16 s) Word32 L_sum; - L_sum = L_add(0,0); + L_sum = 0; + move32(); n2 = shr(n,1); @@ -1614,7 +1596,7 @@ Word16 findIndexOfMaxWord32(Word32 *x, const Word16 len) move16(); FOR (i = 1; i < len; i++) { - if (L_sub(x[i],x[indx]) > 0) + if (GT_32(x[i],x[indx])) { indx = i; move16(); @@ -1717,12 +1699,15 @@ Word32 Dot_product12_offs( /* (o) Q31: normalized result (1 < va Word16 i, sft; Word32 L_sum; + Word64 L_sum64; - L_sum = L_mac0(L_off, x[0], y[0]); - FOR (i = 1; i < lg; i++) + L_sum64 = W_deposit32_l( L_off ); + FOR (i = 0; i < lg; i++) { - L_sum = L_mac0(L_sum, x[i], y[i]); + L_sum64 = W_mac0_16_16(L_sum64, x[i], y[i]); } + L_sum = W_sat_l( L_sum64 ); + /* Normalize acc in Q31 */ sft = norm_l(L_sum); @@ -1813,10 +1798,16 @@ Word32 BASOP_Util_Add_Mant32Exp /*!< o: normalized result manti */ if (!a_m) - a_e = add(b_e,0); + { + a_e = b_e; + move16(); + } if (!b_m) - b_e = add(a_e,0); + { + b_e = a_e; + move16(); + } shift = sub(a_e, b_e); shift = s_max(-31,shift); @@ -1837,7 +1828,10 @@ Word32 BASOP_Util_Add_Mant32Exp /*!< o: normalized result manti if (shift) L_tmp = L_shl(L_tmp,shift); if (L_tmp == 0) - a_e = add(0,0); + { + a_e = 0; + move16(); + } if (L_tmp != 0) a_e = sub(a_e,shift); *ptr_e = a_e; @@ -1883,13 +1877,19 @@ Word16 BASOP_Util_Cmp_Mant32Exp /*!< o: flag: result of compari /* align exponent, if any mantissa is zero */ if (!a_m) - a_e = add(b_e,0); + { + a_e = b_e; + move16(); + } if (!b_m) - b_e = add(a_e,0); + { + b_e = a_e; + move16(); + } - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF diff_m = L_sub(a_m,b_m); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON diff_e = sub(a_e,b_e); test(); @@ -1906,7 +1906,8 @@ Word16 BASOP_Util_Cmp_Mant32Exp /*!< o: flag: result of compari /* a is positive */ if (b_m < 0) { - result = add(1,0); + result = 1; + move16(); } test(); @@ -1914,7 +1915,8 @@ Word16 BASOP_Util_Cmp_Mant32Exp /*!< o: flag: result of compari test(); if ((b_m >= 0) && ((diff_e > 0) || (diff_e == 0 && diff_m > 0))) { - result = add(1,0); + result = 1; + move16(); } } ELSE @@ -1925,7 +1927,8 @@ Word16 BASOP_Util_Cmp_Mant32Exp /*!< o: flag: result of compari test(); if ((b_m < 0) && ((diff_e < 0) || (diff_e == 0 && diff_m > 0))) { - result = add(1,0); + result = 1; + move16(); } } return result; @@ -1993,8 +1996,9 @@ Word32 dotWord32_16_Mant32Exp(const Word32 *bufX32,/* i: 32-bit buffer with unkn shift = getScaleFactor32(bufX32, len); /* current available headroom */ shift = sub(shift, sub(14,norm_s(len))); /* reduced required headroom */ - L_sum = L_add(0,0); /* Clear accu */ - FOR(i=0; i < len; i++) + L_sum = 0; /* Clear accu */ + move32(); + FOR(i=0; i < len; i++) { L_sum = L_mac0(L_sum, round_fx(L_shl(bufX32[i], shift)), bufY16[i]); } @@ -2078,19 +2082,19 @@ Word16 BASOP_util_atan2( /* o: atan2(y,x) [-pi,pi] Q13 q = 32767/*1.0f Q15*/; /* y/x = neg/zero = -Inf */ sf = 0; - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF q = BASOP_Util_Divide3232_uu_1616_Scale(L_abs(y),L_abs(x), &sf); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF if(L_sign < 0) q = negate(q); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON sfo = add(sf,e); /* --- atan() */ - IF ( sub(sfo,ATI_SF) > 0 ) + IF ( GT_16(sfo,ATI_SF)) { /* --- could not calc fixp_atan() here bec of input data out of range ==> therefore give back boundary values */ @@ -2166,13 +2170,13 @@ Word16 BASOP_util_atan( /* o: atan(x) [-pi/2;pi/2] x = L_abs(x); /* calc of arctan */ - IF(L_sub(x, 1509950l/*0.045f/64.0f Q31*/) < 0 ) + IF(LT_32(x, 1509950l/*0.045f/64.0f Q31*/)) { result = round_fx(L_shl(x,5)); /*Q14*/ /*BASOP_util_atan_16(0.0444059968): max error 0.0000567511, mean 0.000017, abs mean 0.000017*/ } ELSE - IF(L_sub(x,( L_shl(1,Q_ATANINP)-8482560l/*0.00395 Q31*/)) < 0 ) + IF(LT_32(x,( L_shl(1,Q_ATANINP)-8482560l/*0.00395 Q31*/))) { xx =round_fx(L_shl(x,6)); tmp = mult_r(xx, xx); /* q15 * q15 - (16-1) = q15*/ @@ -2180,11 +2184,11 @@ Word16 BASOP_util_atan( /* o: atan(x) [-pi/2;pi/2] tmp = add(tmp, 0x4000); /*L_shl(1,14) = 524288*/ /* q14 + q14 = q14 */ res_e=Q_ATANOUT-15+14-16+1; move16(); - if(sub(xx,tmp) > 0) + if(GT_16(xx,tmp)) { res_e = add(res_e,1); } - if(sub(xx,tmp) > 0) + if(GT_16(xx,tmp)) { xx = shr(xx,1); } @@ -2192,7 +2196,7 @@ Word16 BASOP_util_atan( /* o: atan(x) [-pi/2;pi/2] result = msu_r(0, result, shl(-32768,res_e)); /*BASOP_util_atan_16(0.7471138239): max error 0.0020029545, mean 0.000715, abs mean 0.000715*/ } - ELSE IF( L_sub(x,42949673l/*1.28/64.0 Q31*/) < 0 ) + ELSE IF( LT_32(x,42949673l/*1.28/64.0 Q31*/)) { Word16 delta_fix; Word32 PI_BY_4 = 1686629684l/*3.1415926/4.0 Q31*//2; /* pi/4 in q30 */ @@ -2236,3 +2240,45 @@ Word16 compMantExp16Unorm(Word16 m1, Word16 e1, Word16 m2, Word16 e2) return tmp; } +cmplx CL_scale_t(cmplx x, Word16 y) +{ + cmplx result; + result.re = Mpy_32_16_1(x.re, y); + result.im = Mpy_32_16_1(x.im, y); +#if (WMOPS) + multiCounter[currCounter].Mpy_32_16_1--; + multiCounter[currCounter].Mpy_32_16_1--; + multiCounter[currCounter].CL_scale++; +#endif + return (result); +} + +cmplx CL_dscale_t(cmplx x, Word16 y1, Word16 y2) +{ + cmplx result; + result.re = Mpy_32_16_1(x.re, y1); + result.im = Mpy_32_16_1(x.im, y2); +#if (WMOPS) + multiCounter[currCounter].Mpy_32_16_1--; + multiCounter[currCounter].Mpy_32_16_1--; + multiCounter[currCounter].CL_dscale++; +#endif/* #if (WMOPS) */ + return (result); +} + +cmplx CL_mult_32x16(cmplx input, cmplx_s coeff) +{ + cmplx result; + result.re = L_sub(Mpy_32_16_1(input.re,coeff.re), Mpy_32_16_1(input.im, coeff.im)); + result.im = L_add(Mpy_32_16_1(input.re,coeff.im), Mpy_32_16_1(input.im, coeff.re)); +#if (WMOPS) + multiCounter[currCounter].CL_multr_32x16++; + multiCounter[currCounter].Mpy_32_16_1--; + multiCounter[currCounter].Mpy_32_16_1--; + multiCounter[currCounter].Mpy_32_16_1--; + multiCounter[currCounter].Mpy_32_16_1--; + multiCounter[currCounter].L_sub--; + multiCounter[currCounter].L_add--; +#endif + return result; +} diff --git a/lib_com/basop_util.h b/lib_com/basop_util.h index 12bdf46f02420810fbfd8ea82fbf7179eef52280..4538d801d6ac2af76fcde0d1aa88f74fcab26b38 100644 --- a/lib_com/basop_util.h +++ b/lib_com/basop_util.h @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #ifndef __BASOP_UTIL_H__ @@ -132,10 +132,6 @@ Word32 Sqrt32( /*!< output mantissa */ Word16 *exponent /*!< pointer to exponent */ ); -Word32 Sqrt32norm( /*!< output mantissa */ - Word32 mantissa, /*!< normalized input mantissa */ - Word16 *exponent /*!< pointer to exponent */ -); /* deprecated, use Sqrt16! */ void BASOP_Util_Sqrt_MantExp (Word16 *mantissa, /*!< Pointer to mantissa */ @@ -813,5 +809,8 @@ Word32 norm_llQ31( /* o : normalized result Q31 */ Word16 compMantExp16Unorm(Word16 m1, Word16 e1, Word16 m2, Word16 e2); +cmplx CL_scale_t(cmplx x, Word16 y); +cmplx CL_dscale_t(cmplx x, Word16 y1, Word16 y2); +cmplx CL_mult_32x16(cmplx input, cmplx_s coeff); #endif /* __BASOP_UTIL_H__ */ diff --git a/lib_com/bitalloc_fx.c b/lib_com/bitalloc_fx.c index 482169eed3011e40f956a44248743808c9b9385f..abb0ce569146a65ce167be13b17fcce0ff481889 100644 --- a/lib_com/bitalloc_fx.c +++ b/lib_com/bitalloc_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ @@ -7,9 +7,7 @@ #include "cnst_fx.h" /* Common constants */ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ -#include "stl.h" -#include "wmc_auto.h" - /* required for wmc_tool */ +#include "stl.h" /* required for wmc_tool */ void bitalloc_fx ( Word16 *y, /* i : reordered norm of sub-vectors Q0 */ @@ -31,7 +29,7 @@ void bitalloc_fx ( N = sub(N, 1); - if ( sub(hqswb_clas, HQ_HARMONIC) == 0 ) + if ( EQ_16(hqswb_clas, HQ_HARMONIC)) { SFM_thr = 22; move16(); @@ -62,11 +60,11 @@ void bitalloc_fx ( } } - IF ( sub(temp, y[m]) < 0 ) + IF ( LT_16(temp, y[m])) { k = m; move16(); - if ( sub(im, N) < 0 ) + if ( LT_16(im, N)) { im = add(im, 1); } @@ -76,14 +74,14 @@ void bitalloc_fx ( move16(); test(); - IF ( sub(sum,sfmsize[j]) >= 0 && sub(r[j],K) < 0 ) + IF ( GE_16(sum,sfmsize[j])&<_16(r[j],K)) { y[k] = sub(y[k], fac); move16(); r[j] = add(r[j], 1); move16(); - if ( sub(r[j], K) >= 0 ) + if ( GE_16(r[j], K)) { y[k] = -32768; move16(); @@ -96,14 +94,14 @@ void bitalloc_fx ( move16(); k = add(k, 1); test(); - if ( sub(k, im) == 0 && sub(im, N) < 0 ) + if ( EQ_16(k, im)&<_16(im,N)) { im = add(im, 1); } } test(); - IF ( (sub(sum, WID_G1)<0) || (sub(diff, sum)==0) ) + IF ( (LT_16(sum, WID_G1))||(EQ_16(diff,sum))) { BREAK; } @@ -112,13 +110,13 @@ void bitalloc_fx ( move16(); v = sub(N, 1); - IF ( sub(k, v) > 0 ) + IF ( GT_16(k, v)) { FOR ( ii=0; ii<=N; ii++ ) { - IF ( sub(y[ii], -32768) > 0 ) + IF ( GT_16(y[ii], -32768)) { - if ( sub(ii, N) < 0 ) + if ( LT_16(ii, N)) { im = add(ii, 1); } @@ -129,7 +127,7 @@ void bitalloc_fx ( } - IF ( sub(sum, WID_G2) >= 0 ) + IF ( GE_16(sum, WID_G2)) { FOR (i=0; i<=N; i++) { @@ -137,12 +135,12 @@ void bitalloc_fx ( move16(); test(); test(); - IF ( sub(j, SFM_G1) >= 0 && sub(j, SFM_thr) < 0 && r[j] == 0 ) + IF ( GE_16(j, SFM_G1)&<_16(j,SFM_thr)&&r[j]==0) { r[j] = 1; move16(); sum = sub(sum, WID_G2); - IF (sub(sum, WID_G2) < 0) + IF (LT_16(sum, WID_G2)) { BREAK; } @@ -150,7 +148,7 @@ void bitalloc_fx ( } } - IF ( sub(sum, WID_G2) >= 0 ) + IF ( GE_16(sum, WID_G2)) { FOR (i=0; i<=N; i++) { @@ -158,12 +156,12 @@ void bitalloc_fx ( move16(); test(); test(); - IF ( sub(j,SFM_G1) >= 0 && sub(j, SFM_thr) < 0 && sub(r[j], 1) == 0 ) + IF ( GE_16(j,SFM_G1)&<_16(j,SFM_thr)&&EQ_16(r[j],1)) { r[j] = 2; move16(); sum = sub(sum, WID_G2); - IF ( sub(sum, WID_G2) < 0 ) + IF ( LT_16(sum, WID_G2)) { BREAK; } @@ -171,19 +169,19 @@ void bitalloc_fx ( } } - IF ( sub(sum, WID_G1) >= 0 ) + IF ( GE_16(sum, WID_G1)) { FOR (i=0; i<=N; i++) { j = idx[i]; move16(); test(); - IF ( sub(j, SFM_G1) < 0 && r[j] == 0 ) + IF ( LT_16(j, SFM_G1)&&r[j]==0) { r[j] = 1; move16(); sum = sub(sum, WID_G1); - IF ( sub(sum, WID_G1) < 0 ) + IF ( LT_16(sum, WID_G1)) { BREAK; } @@ -191,19 +189,19 @@ void bitalloc_fx ( } } - IF ( sub(sum, WID_G1) >= 0 ) + IF ( GE_16(sum, WID_G1)) { FOR (i=0; i<=N; i++) { j = idx[i]; move16(); test(); - IF ( sub(j, SFM_G1) < 0 && sub(r[j], 1) == 0 ) + IF ( LT_16(j, SFM_G1)&&EQ_16(r[j],1)) { r[j] = 2; move16(); sum = sub(sum, WID_G1); - IF ( sub(sum, WID_G1) < 0 ) + IF ( LT_16(sum, WID_G1)) { BREAK; } @@ -246,7 +244,7 @@ Word16 BitAllocF_fx ( fac = 3; move16(); - IF (L_sub(bit_rate, 32000) < 0) + IF (LT_32(bit_rate, 32000)) { bs = 2; move16(); @@ -261,7 +259,7 @@ Word16 BitAllocF_fx ( Nmin = N; move16(); - if ( sub(Nmin,SFM_N) > 0) + if ( GT_16(Nmin,SFM_N)) { Nmin = SFM_N; move16(); @@ -269,7 +267,7 @@ Word16 BitAllocF_fx ( /* Initial bits distribution */ test(); - IF (sub(hqswb_clas , HQ_GEN_SWB) == 0 || sub(hqswb_clas , HQ_GEN_FB) == 0) + IF (EQ_16(hqswb_clas , HQ_GEN_SWB)||EQ_16(hqswb_clas,HQ_GEN_FB)) { /* Initial bits distribution */ L_tmp1 = 0; @@ -357,7 +355,7 @@ Word16 BitAllocF_fx ( /* Distribute the remaining bits to subbands with non-zero bits */ B_fx = L_shl(B, 15); - WHILE (L_sub(L_shr(L_add(t_fx, 16384), 15) , B) != 0) + WHILE (NE_32(L_shr(L_add(t_fx, 16384), 15) , B)) { L_tmp1 = L_sub(t_fx, B_fx); exp1 = sub(norm_l(L_tmp1), 1); @@ -400,11 +398,11 @@ Word16 BitAllocF_fx ( IF (Rsubband_w32_fx[i] > 0) { test(); - IF ((L_sub(Rsubband_w32_fx[i] , L_shl(add(bs, LNb[i]), 15)) <0) && (sub(low_rate,1) == 0)) + IF ((LT_32(Rsubband_w32_fx[i] , L_shl(add(bs, LNb[i]), 15)))&&(EQ_16(low_rate,1))) { Rsubband_w32_fx[i] = L_deposit_l(0); } - ELSE IF ( L_sub(Rsubband_w32_fx[i] , L_shl(Nb[i], 15)) <=0) + ELSE IF ( LE_32(Rsubband_w32_fx[i] , L_shl(Nb[i], 15))) { B = sub(B,Nb[i]); Rsubband_w32_fx[i] = L_shl(Nb[i], 15); @@ -419,7 +417,7 @@ Word16 BitAllocF_fx ( } /* Distribute the remaining bits to subbands with more than 1-bit per sample */ - WHILE (L_sub(L_shr(L_add(t_fx, 16384), 15) ,B) != 0) + WHILE (NE_32(L_shr(L_add(t_fx, 16384), 15) ,B)) { L_tmp1 = L_sub(t_fx, L_shl(B, 15)); L_tmp2 = L_abs(L_tmp1); @@ -440,11 +438,11 @@ Word16 BitAllocF_fx ( move16(); FOR( i = 0; i < N; i++) { - IF (L_sub(Rsubband_w32_fx[i] , L_shl(Nb[i], 15)) > 0) + IF (GT_32(Rsubband_w32_fx[i] , L_shl(Nb[i], 15))) { Rsubband_w32_fx[i] = L_msu(Rsubband_w32_fx[i], m_fx, Nb[i]); move32(); - IF (L_sub(Rsubband_w32_fx[i] ,L_shl(Nb[i], 15)) > 0) + IF (GT_32(Rsubband_w32_fx[i] ,L_shl(Nb[i], 15))) { n = add(n,Nb[i]); @@ -490,12 +488,12 @@ Word16 BitAllocF_fx ( B = Bits; B_w16_fx = shl(B, 3); - IF (sub(tmp ,B_w16_fx)>0) + IF (GT_16(tmp ,B_w16_fx)) { tmp = sub(tmp, B_w16_fx); FOR ( i = 0; i < N; i++) { - IF (sub(Rsubband_fx[i], add(shl(Nb[i], 3), tmp)) >= 0) + IF (GE_16(Rsubband_fx[i], add(shl(Nb[i], 3), tmp))) { Rsubband_fx[i] = sub(Rsubband_fx[i], tmp); move16(); @@ -553,17 +551,17 @@ void Bit_group_fx ( /* initialization for bit allocation in one group*/ tmp = 6554; move16(); /*Q15 1/5 */ - if(sub(thr,5) == 0) + if(EQ_16(thr,5)) { tmp = 6554; move16(); /*Q15 1/5 */ } - if(sub(thr,6) == 0) + if(EQ_16(thr,6)) { tmp = 5462; move16();/*Q15 1/6 */ } - if(sub(thr,7) == 0) + if(EQ_16(thr,7)) { tmp = 4682; move16();/*Q15 1/7 */ @@ -584,7 +582,7 @@ void Bit_group_fx ( /* norm vector modification */ factor_fx = div_s(1, band_num);/*Q15 */ - IF ( sub(thr,5) > 0 ) + IF ( GT_16(thr,5)) { FOR ( i = 0; i < band_num; i++ ) { @@ -610,7 +608,7 @@ void Bit_group_fx ( /* bit allocation based on modified norm */ L_tmp = L_mult(band_num,24576);/*Q16 */ tmp = extract_h(L_shl(L_tmp,7));/*Q7 */ - IF ( sub(shl(bit_band,7),tmp) >= 0 ) + IF ( GE_16(shl(bit_band,7),tmp)) { FOR ( j = 0; j < band_num; j++) { @@ -657,7 +655,7 @@ void Bit_group_fx ( } L_tmp = L_shl(L_deposit_l(thr),21);/*Q21 */ - IF ( L_sub(R_temp_fx[i],L_tmp) < 0 ) + IF ( LT_32(R_temp_fx[i],L_tmp)) { R_temp_fx[i] = L_deposit_h(0); norm_sum = sub(norm_sum,y_index[i]); @@ -722,7 +720,7 @@ void Bit_group_fx ( L_tmp = L_shl(L_deposit_l(thr),21);/*Q21 */ FOR (k = 0; k < i; k++) { - IF (L_sub(R_temp_fx[k],L_tmp) < 0) + IF (LT_32(R_temp_fx[k],L_tmp)) { FOR(m = k; m < i; m++) { @@ -737,7 +735,7 @@ void Bit_group_fx ( R_sum_fx = L_add(R_sum_fx,R_temp_fx[k]); } } - IF (L_sub(R_sum_fx,R_sum_org_fx) == 0) + IF (EQ_32(R_sum_fx,R_sum_org_fx)) { BREAK; } @@ -786,7 +784,7 @@ Word16 BitAllocWB_fx( /* o : t BANDS = N; move16(); - if( sub(BANDS,SFM_N) > 0) + if( GT_16(BANDS,SFM_N)) { BANDS = SFM_N; move16(); @@ -862,7 +860,7 @@ Word16 BitAllocWB_fx( /* o : t move32();/*Q16 */ test(); - IF ( L_sub(R_diff_32_fx[0],393216) < 0 && L_sub(R_diff_32_fx[1],245760) < 0 ) + IF ( LT_32(R_diff_32_fx[0],393216)&<_32(R_diff_32_fx[1],245760)) { IF(Rsum_fx == 0) { @@ -882,7 +880,7 @@ Word16 BitAllocWB_fx( /* o : t L_tmp = Mult_32_16(L_tmp1,tmp);/*Q(15-exp) */ B1 = extract_h(L_shl(L_tmp,add(exp,1)));/*Q0 */ test(); - if(L_sub(L_tmp1,L_mult(B1,Rsum_fx)) > 0 && L_sub(L_tmp1,L_mult(add(B1,1),Rsum_fx)) >= 0) + if(GT_32(L_tmp1,L_mult(B1,Rsum_fx))&&GE_32(L_tmp1,L_mult(add(B1,1),Rsum_fx))) { B1 = add(B1,1); } @@ -890,7 +888,7 @@ Word16 BitAllocWB_fx( /* o : t L_tmp = Mult_32_16(L_tmp1,tmp);/*Q(15-exp) */ B2 = extract_h(L_shl(L_tmp,add(exp,1)));/*Q0 */ test(); - if(L_sub(L_tmp1,L_mult(B2,Rsum_fx)) > 0 && L_sub(L_tmp1,L_mult(add(B2,1),Rsum_fx)) >= 0) + if(GT_32(L_tmp1,L_mult(B2,Rsum_fx))&&GE_32(L_tmp1,L_mult(add(B2,1),Rsum_fx))) { B2 = add(B2,1); } @@ -898,23 +896,23 @@ Word16 BitAllocWB_fx( /* o : t L_tmp = Mult_32_16(L_tmp1,tmp);/*Q(15-exp) */ B3 = extract_h(L_shl(L_tmp,add(exp,1)));/*Q0 */ test(); - if(L_sub(L_tmp1,L_mult(B3,Rsum_fx)) > 0 && L_sub(L_tmp1,L_mult(add(B3,1),Rsum_fx)) >= 0) + if(GT_32(L_tmp1,L_mult(B3,Rsum_fx))&&GE_32(L_tmp1,L_mult(add(B3,1),Rsum_fx))) { B3 = add(B3,1); } } - IF ( L_sub(Ravg_sub_32_fx[2],786432) > 0 ) + IF ( GT_32(Ravg_sub_32_fx[2],786432)) { B_saved = 0; move16(); - IF ( sub(B1,288) > 0 ) + IF ( GT_16(B1,288)) { B_saved = sub(B1,288); B1 = 288; move16(); } - IF ( sub(B2,256) > 0 ) + IF ( GT_16(B2,256)) { tmp = sub(B2,256); B_saved = add(B_saved,tmp); @@ -922,7 +920,7 @@ Word16 BitAllocWB_fx( /* o : t move16(); } - IF ( sub(B3,96) > 0 ) + IF ( GT_16(B3,96)) { tmp = sub(B3,96); B_saved = add(B_saved,tmp); @@ -932,7 +930,7 @@ Word16 BitAllocWB_fx( /* o : t IF ( B_saved > 0 ) { - IF ( sub(B1,288) == 0 ) + IF ( EQ_16(B1,288)) { tmp = shr(B_saved,1); B2 = add(B2,tmp); @@ -943,7 +941,7 @@ Word16 BitAllocWB_fx( /* o : t { tmp = shr(B_saved,1); B1 = add(B1,tmp); - IF ( sub(B2,256) == 0 ) + IF ( EQ_16(B2,256)) { tmp = sub(B,B1); B3 = sub(tmp,B2); @@ -982,7 +980,7 @@ Word16 BitAllocWB_fx( /* o : t L_tmp = Mult_32_16(L_tmp1,tmp);/*Q(15-exp) */ B1 = extract_h(L_shl(L_tmp,add(exp,1)));/*Q0 */ test(); - if(L_sub(L_tmp1,L_mult(B1,Rsum_fx)) > 0 && L_sub(L_tmp1,L_mult(add(B1,1),Rsum_fx)) >= 0) + if(GT_32(L_tmp1,L_mult(B1,Rsum_fx))&&GE_32(L_tmp1,L_mult(add(B1,1),Rsum_fx))) { B1 = add(B1,1); } @@ -991,7 +989,7 @@ Word16 BitAllocWB_fx( /* o : t L_tmp = Mult_32_16(L_tmp1,tmp);/*Q(27-exp) */ B2 = extract_h(L_shl(L_tmp,sub(exp,11)));/*Q0 */ test(); - if(L_sub(L_tmp1,L_shl(L_mult(B2,Rsum_fx),12)) > 0 && L_sub(L_add(L_tmp1,2),L_shl(L_mult(add(B2,1),Rsum_fx),12)) >= 0) + if(GT_32(L_tmp1,L_shl(L_mult(B2,Rsum_fx),12))&&GE_32(L_add(L_tmp1,2),L_shl(L_mult(add(B2,1),Rsum_fx),12))) { B2 = add(B2,1); } @@ -1001,7 +999,7 @@ Word16 BitAllocWB_fx( /* o : t } } - IF ( sub(Rsum_sub_fx[2],3) < 0 ) + IF ( LT_16(Rsum_sub_fx[2],3)) { B2 = add(B2,B3); B3 = 0; diff --git a/lib_com/bitallocsum_fx.c b/lib_com/bitallocsum_fx.c index 06c83625abb038a01b751188c7ccd0c74a609304..123894b4c2033d3bc36b8b698a9f4ede4299ffda 100644 --- a/lib_com/bitallocsum_fx.c +++ b/lib_com/bitallocsum_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "cnst_fx.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ -#include "stl.h" -#include "wmc_auto.h" - /* Common constants */ +#include "stl.h" /* Common constants */ /*-------------------------------------------------------------------------- * bitallocsum_fx() @@ -39,7 +37,7 @@ void bitallocsum_fx( } *sum = total; - IF ( sub(length, L_FRAME32k) <= 0 ) + IF ( LE_16(length, L_FRAME32k)) { diff = sub(v, *sum); i = (Word16)0; @@ -54,7 +52,7 @@ void bitallocsum_fx( *sum = add(*sum, 1); } i = add(i, 1); - if ( sub(i, nb_sfm) >= 0 ) + if ( GE_16(i, nb_sfm)) { i = (Word16)0; move16(); diff --git a/lib_com/bits_alloc.c b/lib_com/bits_alloc.c index 1df8a9f52a8765332e9ed643e28ed34921d7ed6a..237eceddac4b966e4724e9c1dca3332e617eb565 100644 --- a/lib_com/bits_alloc.c +++ b/lib_com/bits_alloc.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -8,8 +8,6 @@ #include "prot_fx.h" #include "basop_util.h" #include "stl.h" -#include "wmc_auto.h" - #include "options.h" #include "rom_com_fx.h" @@ -77,7 +75,7 @@ void BITS_ALLOC_init_config_acelp( } /*Wide band @ 16kHz*/ - IF ( sub(nb_subfr,NB_SUBFR16k) == 0 ) + IF ( EQ_16(nb_subfr,NB_SUBFR16k)) { move16(); move16(); @@ -129,16 +127,16 @@ Word16 BITS_ALLOC_config_acelp( { move16(); pConfigAcelp->formant_enh = 1; - if(sub(coder_type,INACTIVE) == 0) + if(EQ_16(coder_type,INACTIVE)) { move16(); pConfigAcelp->formant_enh = 0; } } - IF ( s_and(sub(band_index,1)==0, sub(nb_subfr,4)==0) ) + IF ( s_and((Word16)EQ_16(band_index,1),(Word16)EQ_16(nb_subfr,4))) { - IF(sub(coder_type,INACTIVE) == 0) + IF(EQ_16(coder_type,INACTIVE)) { pConfigAcelp->pre_emphasis = 0; move16(); @@ -165,9 +163,9 @@ Word16 BITS_ALLOC_config_acelp( move16(); } } - IF (sub(coder_type,UNVOICED) == 0 ) + IF (EQ_16(coder_type,UNVOICED)) { - IF(sub(ACELP_GAINS_MODE[mode_index][band_index][coder_type], 6) == 0) + IF(EQ_16(ACELP_GAINS_MODE[mode_index][band_index][coder_type], 6)) { pConfigAcelp->pitch_sharpening = 0; move16(); @@ -190,7 +188,7 @@ Word16 BITS_ALLOC_config_acelp( move16(); } - IF(sub(coder_type,ACELP_MODE_MAX) > 0) /* keep pitch sharpening for RF_ALLPRED mode */ + IF(GT_16(coder_type,ACELP_MODE_MAX)) /* keep pitch sharpening for RF_ALLPRED mode */ { pConfigAcelp->pitch_sharpening = 0; pConfigAcelp->phase_scrambling = 0; @@ -218,7 +216,7 @@ Word16 BITS_ALLOC_config_acelp( move16(); pConfigAcelp->ltf_bits=ACELP_LTF_BITS[pConfigAcelp->ltf_mode]; - if ( s_and(sub(nb_subfr,5)==0, sub(pConfigAcelp->ltf_bits,4)==0) ) + if ( s_and((Word16)EQ_16(nb_subfr,5),(Word16)EQ_16(pConfigAcelp->ltf_bits,4))) { pConfigAcelp->ltf_bits = add(pConfigAcelp->ltf_bits,1); } @@ -233,7 +231,7 @@ Word16 BITS_ALLOC_config_acelp( /* skip subframe 1, 3 gain encoding, and use from subframe 0, and 3, respectively */ test(); test(); - IF(sub(coder_type,ACELP_MODE_MAX) >= 0 && (sub(i,1) == 0 || sub(i,3) == 0)) + IF(GE_16(coder_type,ACELP_MODE_MAX)&&(EQ_16(i,1)||EQ_16(i,3))) { pConfigAcelp->gains_mode[i] = 0; } @@ -247,17 +245,17 @@ Word16 BITS_ALLOC_config_acelp( /*Innovation*/ - if ( sub(bits_frame,bits) < 0) + if ( LT_16(bits_frame,bits)) { printf("Warning: bits per frame too low\n"); return -1; } - IF( sub(coder_type,RF_ALLPRED) == 0 ) + IF( EQ_16(coder_type,RF_ALLPRED)) { set16_fx(pConfigAcelp->fixed_cdk_index, -1, nb_subfr); } - ELSE IF ( sub(coder_type,RF_GENPRED) == 0 ) + ELSE IF ( EQ_16(coder_type,RF_GENPRED)) { pConfigAcelp->fixed_cdk_index[0] = 0; /* 7 bits */ pConfigAcelp->fixed_cdk_index[1] = -1; @@ -266,7 +264,7 @@ Word16 BITS_ALLOC_config_acelp( pConfigAcelp->fixed_cdk_index[4] = -1; bits = add(bits,14); } - ELSE IF( sub(coder_type,RF_NOPRED) == 0 ) + ELSE IF( EQ_16(coder_type,RF_NOPRED)) { set16_fx(pConfigAcelp->fixed_cdk_index, 0, nb_subfr); bits = add(bits,28); @@ -306,13 +304,13 @@ Word16 BITS_ALLOC_adjust_generic( move16(); inb_subfr = 8192/*1.0f/NB_SUBFR Q15*/; move16(); - if ( sub(nb_subfr,NB_SUBFR16k) == 0 ) + if ( EQ_16(nb_subfr,NB_SUBFR16k)) { inb_subfr = 6554/*1.0f/NB_SUBFR16k Q15*/; move16(); } - IF ( sub(bits_subframe2, i_mult2(pulseconfigbits[0], nb_subfr)) < 0 ) /* not in final code - not instrumented */ + IF ( LT_16(bits_subframe2, i_mult2(pulseconfigbits[0], nb_subfr))) /* not in final code - not instrumented */ { return add(bits_frame,1); /* Not enough bits for lowest mode. -> trigger alarm*/ } @@ -343,7 +341,7 @@ Word16 BITS_ALLOC_adjust_generic( bits_currsubframe = sub(add(i_mult2(sfr, bits_subframe2), bits_subframe2), bitsused); /* try increasing mode while below threshold */ - WHILE ( (sub(k, pulseconfig_size-1) < 0) && (sub(i_mult2(pulseconfigbits[add(k,1)], nb_subfr),bits_currsubframe) <= 0) ) + WHILE ( (LT_16(k, pulseconfig_size-1))&&(LE_16(i_mult2(pulseconfigbits[add(k,1)],nb_subfr),bits_currsubframe))) { test(); k = add(k,1); diff --git a/lib_com/bitstream_fx.c b/lib_com/bitstream_fx.c index 9c8984dae359740b5780124321be5a50bcd19e74..7090aeb95dc5aa21fc06ea5b72b6fb14db5f330c 100644 --- a/lib_com/bitstream_fx.c +++ b/lib_com/bitstream_fx.c @@ -1,12 +1,10 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include #include #include "stl.h" -#include "wmc_auto.h" - #include "cnst_fx.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #include "options.h" @@ -163,7 +161,7 @@ void push_indice_fx( Word16 i; - IF ( sub(st_fx->last_ind_fx, id) == 0 ) + IF ( EQ_16(st_fx->last_ind_fx, id)) { /* indice with the same name as the previous one */ i = st_fx->next_ind_fx; @@ -173,7 +171,7 @@ void push_indice_fx( /* new indice - find an empty slot in the list */ i = id; move16(); - WHILE (sub(st_fx->ind_list_fx[i].nb_bits, -1) != 0) + WHILE (NE_16(st_fx->ind_list_fx[i].nb_bits, -1)) { i = add(i, 1); } @@ -256,7 +254,7 @@ void push_next_bits_fx( ++ptr; } } - IF (sub(i, nb_bits) < 0) + IF (LT_16(i, nb_bits)) { FOR (; inext_bit_pos_fx,nb_bits),st_fx->total_num_bits) > 0 ) + IF( GT_16(add(st_fx->next_bit_pos_fx,nb_bits),st_fx->total_num_bits)) { st_fx->BER_detect = 1; move16(); @@ -322,8 +320,8 @@ UWord16 get_next_indice_1_fx( /* o : value of the indice */ test(); test(); test(); - IF(( sub(add(st_fx->next_bit_pos_fx,1),st_fx->total_num_bits) > 0 && sub(st_fx->codec_mode,MODE1) == 0 ) || - ( sub(add(st_fx->next_bit_pos_fx,1),add(st_fx->total_num_bits,2*8)) > 0 && sub(st_fx->codec_mode,MODE2) == 0 ) /* add two zero bytes for arithmetic coder flush */ + IF( ( GT_16(add(st_fx->next_bit_pos_fx,1),st_fx->total_num_bits)&&EQ_16(st_fx->codec_mode,MODE1))|| + ( GT_16(add(st_fx->next_bit_pos_fx,1),add(st_fx->total_num_bits,2*8)) && EQ_16(st_fx->codec_mode,MODE2)) /* add two zero bytes for arithmetic coder flush */ ) { st_fx->BER_detect = 1; @@ -367,7 +365,7 @@ UWord16 get_indice_fx( /* o : value of the indice */ assert(nb_bits <= 16); /* detect corrupted bitstream */ - IF( sub(add(pos,nb_bits),st_fx->total_num_bits) > 0 ) + IF( GT_16(add(pos,nb_bits),st_fx->total_num_bits)) { st_fx->BER_detect = 1; move16(); @@ -397,7 +395,7 @@ UWord16 get_indice_1_fx( /* o : value of the indice */ ) { /* detect corrupted bitstream */ - IF( sub(add(pos,1),st_fx->total_num_bits) > 0 ) + IF( GT_16(add(pos,1),st_fx->total_num_bits)) { st_fx->BER_detect = 1; move16(); @@ -697,15 +695,15 @@ static void decoder_selectCodec( test(); test(); /* check if we are in AMR-WB IO mode */ - IF( L_sub(total_brate, SID_1k75) == 0 || - L_sub(total_brate, ACELP_6k60) == 0 || L_sub(total_brate, ACELP_8k85) == 0 || L_sub(total_brate, ACELP_12k65) == 0 || - L_sub(total_brate, ACELP_14k25) == 0 || L_sub(total_brate, ACELP_15k85) == 0 || L_sub(total_brate, ACELP_18k25) == 0 || - L_sub(total_brate, ACELP_19k85) == 0 || L_sub(total_brate, ACELP_23k05) == 0 || L_sub(total_brate, ACELP_23k85) == 0 ) + IF( EQ_32(total_brate, SID_1k75)|| + EQ_32(total_brate, ACELP_6k60) || EQ_32(total_brate, ACELP_8k85) || EQ_32(total_brate, ACELP_12k65) || + EQ_32(total_brate, ACELP_14k25) || EQ_32(total_brate, ACELP_15k85) || EQ_32(total_brate, ACELP_18k25) || + EQ_32(total_brate, ACELP_19k85) || EQ_32(total_brate, ACELP_23k05) || EQ_32(total_brate, ACELP_23k85) ) { st->Opt_AMR_WB_fx = 1; move16(); } - ELSE IF ( L_sub(total_brate, FRAME_NO_DATA) != 0 ) + ELSE IF ( NE_32(total_brate, FRAME_NO_DATA)) { st->Opt_AMR_WB_fx = 0; move16(); @@ -789,7 +787,7 @@ static void decoder_selectCodec( IF ( st->ini_frame_fx == 0 ) { - IF(sub(st->codec_mode,-1) == 0 ) + IF(EQ_16(st->codec_mode,-1)) { st->codec_mode = MODE1; move16(); @@ -799,7 +797,7 @@ static void decoder_selectCodec( } /* set SID/CNG type */ - IF ( L_sub(total_brate,SID_2k40) == 0 ) + IF ( EQ_32(total_brate,SID_2k40)) { IF ( bit0 == G192_BIN0 ) { @@ -814,7 +812,7 @@ static void decoder_selectCodec( { st->cng_type_fx = FD_CNG; test(); - if ( sub(st->last_codec_mode, MODE2) == 0 && L_sub(st->last_total_brate_fx,13200) == 0 ) + if ( EQ_16(st->last_codec_mode, MODE2)&&EQ_32(st->last_total_brate_fx,13200)) { st->codec_mode = MODE1; move16(); @@ -841,12 +839,12 @@ void dec_prm_core(Decoder_State_fx *st) st->core_fx = -1; move16(); - IF (L_sub(st->total_brate_fx, FRAME_NO_DATA) == 0) + IF (EQ_32(st->total_brate_fx, FRAME_NO_DATA)) { st->m_frame_type = ZERO_FRAME; move16(); } - ELSE IF (L_sub(st->total_brate_fx, SID_2k40) == 0) + ELSE IF (EQ_32(st->total_brate_fx, SID_2k40)) { st->m_frame_type = SID_FRAME; move16(); @@ -860,7 +858,7 @@ void dec_prm_core(Decoder_State_fx *st) assert(num_bits == st->total_brate_fx/50); FOR (n=0; nbwidth_fx = add(st->bwidth_fx, FrameSizeConfig[frame_size_index].bandwidth_min); - if (sub(st->bwidth_fx, FB) > 0) + if (GT_16(st->bwidth_fx, FB)) { st->bwidth_fx = FB; move16(); @@ -881,7 +879,7 @@ void dec_prm_core(Decoder_State_fx *st) move16(); } - if (sub(st->bwidth_fx, SWB) > 0 && L_sub(st->total_brate_fx, ACELP_16k40) < 0) + if (GT_16(st->bwidth_fx, SWB)&<_32(st->total_brate_fx,ACELP_16k40)) { st->bwidth_fx = SWB; move16(); @@ -933,7 +931,7 @@ void decision_matrix_core_dec( move16(); test(); - IF ( L_sub(st->total_brate_fx, FRAME_NO_DATA) == 0 || L_sub(st->total_brate_fx, SID_2k40) == 0 ) + IF ( EQ_32(st->total_brate_fx, FRAME_NO_DATA)||EQ_32(st->total_brate_fx,SID_2k40)) { st->core_fx = ACELP_CORE; move16(); @@ -951,12 +949,12 @@ void decision_matrix_core_dec( *---------------------------------------------------------------------*/ test(); - IF ( L_sub(st->total_brate_fx, ACELP_24k40) < 0 ) + IF ( LT_32(st->total_brate_fx, ACELP_24k40)) { st->core_fx = ACELP_CORE; move16(); } - ELSE IF ( L_sub(st->total_brate_fx, ACELP_24k40) >= 0 && L_sub(st->total_brate_fx, ACELP_64k) <= 0 ) + ELSE IF ( GE_32(st->total_brate_fx, ACELP_24k40)&&LE_32(st->total_brate_fx,ACELP_64k)) { /* read the ACELP/HQ core selection bit */ st->core_fx = imult1616(get_next_indice_fx( st, 1 ), HQ_CORE); @@ -971,12 +969,12 @@ void decision_matrix_core_dec( * Read ACELP signalling bits from the bitstream *-----------------------------------------------------------------*/ - IF ( sub(st->core_fx, ACELP_CORE) == 0 ) + IF ( EQ_16(st->core_fx, ACELP_CORE)) { /* find the section in the ACELP signalling table corresponding to bitrate */ start_idx = 0; move16(); - WHILE ( L_sub(acelp_sig_tbl[start_idx], st->total_brate_fx) != 0 ) + WHILE ( NE_32(acelp_sig_tbl[start_idx], st->total_brate_fx)) { start_idx = add(start_idx, 1); } @@ -993,7 +991,7 @@ void decision_matrix_core_dec( st->bwidth_fx = extract_l(L_and(L_shr(ind, 3), 0x7)); /* convert signalling indice into signalling information */ - if ( L_sub(L_and(ind, 0x7), LR_MDCT) == 0 ) + if ( EQ_32(L_and(ind, 0x7), LR_MDCT)) { st->core_fx = HQ_CORE; move16(); @@ -1005,7 +1003,7 @@ void decision_matrix_core_dec( * Set HQ core type *-----------------------------------------------------------------*/ - IF ( sub(st->core_fx, HQ_CORE) == 0 ) + IF ( EQ_16(st->core_fx, HQ_CORE)) { /* read the HQ/TCX core switching flag */ if ( get_next_indice_fx( st, 1 ) != 0 ) @@ -1016,7 +1014,7 @@ void decision_matrix_core_dec( /* For TCX: read/set band-width (needed for different I/O sampling rate support) */ test(); - IF( sub(st->core_fx, TCX_20_CORE) == 0 && L_sub(st->total_brate_fx, ACELP_16k40) > 0 ) + IF( EQ_16(st->core_fx, TCX_20_CORE)&>_32(st->total_brate_fx,ACELP_16k40)) { ind = get_next_indice_fx( st, 2 ); @@ -1025,12 +1023,12 @@ void decision_matrix_core_dec( st->bwidth_fx = NB; move16(); } - ELSE IF( L_sub(ind, 1) == 0 ) + ELSE IF( EQ_32(ind, 1)) { st->bwidth_fx = WB; move16(); } - ELSE IF( L_sub(ind, 2) == 0 ) + ELSE IF( EQ_32(ind, 2)) { st->bwidth_fx = SWB; move16(); @@ -1063,12 +1061,12 @@ static void mdct_switching_dec( test(); test(); - IF (L_sub(st->total_brate_fx, ACELP_13k20) == 0 || L_sub(st->total_brate_fx, ACELP_32k) == 0) + IF (EQ_32(st->total_brate_fx, ACELP_13k20)||EQ_32(st->total_brate_fx,ACELP_32k)) { st->mdct_sw_enable = MODE1; move16(); } - ELSE IF (L_sub(ACELP_16k40, st->total_brate_fx) <= 0 && L_sub(st->total_brate_fx, ACELP_24k40) <= 0) + ELSE IF (LE_32(ACELP_16k40, st->total_brate_fx)&&LE_32(st->total_brate_fx,ACELP_24k40)) { st->mdct_sw_enable = MODE2; move16(); @@ -1076,7 +1074,7 @@ static void mdct_switching_dec( test(); test(); - IF ( sub(st->codec_mode, MODE1) == 0 && sub(st->mdct_sw_enable, MODE1) == 0 ) + IF ( EQ_16(st->codec_mode, MODE1)&&EQ_16(st->mdct_sw_enable,MODE1)) { /* Read ahead core mode signaling */ Word16 next_bit_pos_save; @@ -1092,7 +1090,7 @@ static void mdct_switching_dec( decision_matrix_core_dec(st); /* sets st->core */ - IF (sub(st->core_fx, TCX_20_CORE) == 0) + IF (EQ_16(st->core_fx, TCX_20_CORE)) { /* Trigger TCX */ st->codec_mode = MODE2; @@ -1114,7 +1112,7 @@ static void mdct_switching_dec( } } } - ELSE IF (sub(st->codec_mode, MODE2) == 0 && sub(st->mdct_sw_enable, MODE2) == 0) + ELSE IF (EQ_16(st->codec_mode, MODE2)&&EQ_16(st->mdct_sw_enable,MODE2)) { /* Read ahead core mode signaling */ Word16 next_bit_pos_save; @@ -1130,7 +1128,7 @@ static void mdct_switching_dec( dec_prm_core(st); /* sets st->core */ - IF (sub(st->core_fx, HQ_CORE) == 0) + IF (EQ_16(st->core_fx, HQ_CORE)) { /* Trigger HQ_CORE */ st->codec_mode = MODE1; @@ -1196,7 +1194,7 @@ Word16 BRATE2IDX16k_fx(Word32 brate) #define START_16K 5 extern const Word16 bit_rates_16k_div50[]; - if(L_sub(brate,ACELP_16k40)==0) + if(EQ_32(brate,ACELP_16k40)) { brate=ACELP_14k80; } @@ -1328,7 +1326,7 @@ Word16 read_indices_fx( /* o : 1 = reading OK, 0 = problem } /* set the BFI indicator according the value of Sync Header */ - if ( sub(utmp, SYNC_BAD_FRAME) == 0 ) + if ( EQ_16(utmp, SYNC_BAD_FRAME)) { st->bfi_fx = 1; } @@ -1384,7 +1382,7 @@ Word16 read_indices_fx( /* o : 1 = reading OK, 0 = problem } } - while ( rew_flag && (st->bfi_fx || L_sub(total_brate,2800) < 0) ); + while ( rew_flag && (st->bfi_fx || LT_32(total_brate,2800))); /* G.192 RX DTX handler*/ if( !rew_flag ) @@ -1588,7 +1586,7 @@ static Word32 read_indices_mime_handle_dtx( Word16 amrwb_sid_first = 0; /* derived from sti SID_FIRST indicator in AMRWB payload */ /* keep st->CNG , st_bfi and total_brate updated for proper synthesis in DTX and FER */ - if( total_brate > SID_2k40 ) + if( GT_32(total_brate, SID_2k40) ) { if( st->bfi_fx != 1 ) /* so far derived from q bit in AMRWB/AMRWBIO cases */ { @@ -1644,7 +1642,7 @@ static Word32 read_indices_mime_handle_dtx( assert( st->bfi_fx==1); /* bfi stays 1 */ } - if( total_brate > SID_2k40 && st->bfi_fx == 1 ) /* typically from q bit */ + if( GT_32(total_brate, SID_2k40) && st->bfi_fx == 1 ) /* typically from q bit */ { speech_bad = 1; /* initial assumption, CNG synt state decides what to actually do */ } @@ -1980,7 +1978,7 @@ Word16 read_indices_mime( /* o : 1 = reading OK, 0 = problem { /* select MODE1 or MODE2 in MIME */ decoder_selectCodec( st, total_brate, *st->bit_stream_fx ? G192_BIN1 : G192_BIN0); - + /* a change of the total bitrate should not be known to the decoder, if the received frame was truly lost */ st->total_brate_fx = total_brate; mdct_switching_dec(st); @@ -2002,11 +2000,11 @@ static void berCheck( ) { /* In case of RF flag = 1, and valid RF packet with primary and partial copy */ - if ( ( sub( st->bwidth_fx, NB) == 0 || sub( st->bwidth_fx, FB) == 0 ) - || (sub(*coder_type,TRANSITION) >= 0 ) + if ( ( EQ_16( st->bwidth_fx, NB)||EQ_16(st->bwidth_fx,FB)) + || (GE_16(*coder_type,TRANSITION) ) ) { - if( sub( st->use_partial_copy, 1 ) == 0 ) + if( EQ_16( st->use_partial_copy, 1 )) { st->use_partial_copy = 0; move16(); @@ -2052,7 +2050,7 @@ void getPartialCopyInfo( st->rf_target_bits = 0; /* Get the number of bits used for RF*/ - IF( sub(st->rf_flag,1) == 0 ) + IF( EQ_16(st->rf_flag,1)) { *coder_type = s_and(ind,0x7); st->bwidth_fx = s_and(shr(ind,3), 0x7); @@ -2061,12 +2059,12 @@ void getPartialCopyInfo( move16(); get_rfTargetBits( st->rf_frame_type, &(st->rf_target_bits) ); - IF( sub(st->bfi_fx,FRAMEMODE_FUTURE) == 0 ) + IF( EQ_16(st->bfi_fx,FRAMEMODE_FUTURE)) { st->use_partial_copy = 1; /* now set the frame mode to normal mode */ test(); - IF(sub(st->rf_frame_type,RF_TCXFD) >= 0 && sub(st->rf_frame_type, RF_TCXTD2) <= 0) + IF(GE_16(st->rf_frame_type,RF_TCXFD)&&LE_16(st->rf_frame_type,RF_TCXTD2)) { st->bfi_fx = 1; st->core_fx = 1; @@ -2108,11 +2106,11 @@ void get_rfFlag( /* check for rf_flag in the packet and extract the rf_frame_type and rf_fec_offset */ test(); test(); - IF( L_sub(st->total_brate_fx,ACELP_13k20) == 0 && (sub(st->bfi_fx,FRAMEMODE_NORMAL) == 0 || sub(st->bfi_fx, FRAMEMODE_FUTURE) == 0) ) + IF( EQ_32(st->total_brate_fx,ACELP_13k20)&&(EQ_16(st->bfi_fx,FRAMEMODE_NORMAL)||EQ_16(st->bfi_fx,FRAMEMODE_FUTURE))) { /* find the section in the ACELP signalling table corresponding to bitrate */ start_idx = 0; - WHILE ( L_sub(acelp_sig_tbl[start_idx], st->total_brate_fx) != 0 ) + WHILE ( NE_32(acelp_sig_tbl[start_idx], st->total_brate_fx)) { start_idx++; assert((start_idx < MAX_ACELP_SIG) && "ERROR: start_idx larger than acelp_sig_tbl[].\n"); @@ -2155,10 +2153,10 @@ void get_rfFrameType( { Word16 num_bits = 0; - IF( sub(st->rf_flag, 1)== 0) + IF( EQ_16(st->rf_flag, 1)) { /*num_bits = st->total_brate_fx/50;*/ - if( L_sub(st->total_brate_fx, ACELP_13k20) == 0 ) + if( EQ_32(st->total_brate_fx, ACELP_13k20)) { num_bits = 264; move16(); /* @13.2kbps */ @@ -2193,10 +2191,10 @@ void get_rf_fec_offset( { Word16 num_bits, tmp; - IF( sub(st->rf_flag,1)== 0) + IF( EQ_16(st->rf_flag,1)) { /*num_bits = st->total_brate_fx/50;*/ - if( L_sub(st->total_brate_fx, ACELP_13k20) == 0 ) + if( EQ_32(st->total_brate_fx, ACELP_13k20)) { num_bits = 264; move16(); /* @13.2kbps */ @@ -2300,7 +2298,7 @@ void get_NextCoderType_fx( bit_stream[k] = (bitsteam[k / 8] >> (7 - (k % 8))) & 0x1; } start_idx = 0; - WHILE ( L_sub(acelp_sig_tbl[start_idx], ACELP_13k20) != 0 ) + WHILE ( NE_32(acelp_sig_tbl[start_idx], ACELP_13k20)) { start_idx = add(start_idx,1); assert((start_idx < MAX_ACELP_SIG) && "ERROR: start_idx larger than acelp_sig_tbl[].\n"); @@ -2488,11 +2486,11 @@ void evs_dec_previewFrame( *partialCopyOffset = 0; total_brate = bitstreamSize * 50; - IF( L_sub(total_brate,ACELP_13k20) == 0 ) + IF( EQ_32(total_brate,ACELP_13k20)) { /* find the section in the ACELP signalling table corresponding to bitrate */ start_idx = 0; - WHILE ( L_sub(acelp_sig_tbl[start_idx], total_brate) != 0 ) + WHILE ( NE_32(acelp_sig_tbl[start_idx], total_brate)) { start_idx = add(start_idx,1); assert((start_idx < MAX_ACELP_SIG) && "ERROR: start_idx larger than acelp_sig_tbl[].\n"); @@ -2514,9 +2512,9 @@ void evs_dec_previewFrame( /* read the fec offset at which the partial copy is received */ ind = get_indice_preview( bitstream, bitstreamSize, (bitstreamSize-5), 2 ); IF(ind== 0) *partialCopyOffset = 2; - ELSE IF(L_sub(ind,1)==0) *partialCopyOffset = 3; - ELSE IF(L_sub(ind,2)==0) *partialCopyOffset = 5; - ELSE IF(L_sub(ind,3)==0) *partialCopyOffset = 7; + ELSE IF(EQ_32(ind,1))*partialCopyOffset=3; + ELSE IF(EQ_32(ind,2))*partialCopyOffset=5; + ELSE IF(EQ_32(ind,3))*partialCopyOffset=7; /* the last three bits in a packet is the RF frame type */ *partialCopyFrameType = get_indice_preview( bitstream, bitstreamSize, bitstreamSize - 3, 3 ); diff --git a/lib_com/cb_shape_fx.c b/lib_com/cb_shape_fx.c index 8c49bc396579abffd2fe2e4f07ef2b3e20b64fc6..085ecba11fc1dd7905e764af314272c98006861d 100644 --- a/lib_com/cb_shape_fx.c +++ b/lib_com/cb_shape_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -8,8 +8,6 @@ #include "rom_com_fx.h" /* */ #include "stl.h" -#include "wmc_auto.h" - /* * E_GAIN_f_pitch_sharpening diff --git a/lib_com/cldfb.c b/lib_com/cldfb.c index 393e2c3fd8102cbf0feb5a2aeda8457fac9ef35e..5245fb6a615d9964fae0bb3252c114e57a5b96bd 100644 --- a/lib_com/cldfb.c +++ b/lib_com/cldfb.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ /*! \file @@ -16,8 +16,6 @@ */ #include "stl.h" -#include "wmc_auto.h" - #include "cnst_fx.h" #include "stat_com.h" #include "rom_com_fx.h" @@ -54,17 +52,25 @@ static void cldfb_init_proto_and_twiddles(HANDLE_CLDFB_FILTER_BANK hs); -#define cplxMpyS(yr,yi,xr,xi,cr,ci,syr,syi,sxr,sxi,zr,zi) zr = L_sub(Mpy_32_16_1(*xr,*cr), Mpy_32_16_1(*xi,*ci)); \ - zi = L_add(Mpy_32_16_1(*xr,*ci), Mpy_32_16_1(*xi,*cr)); \ - *yr = zr; move32(); \ - *yi = zi; move32(); \ - yr+=syr, yi+=syi, xr+=sxr, xi+=sxi, cr++, ci++ - -#define cplxMpy(ryr,ryi,iyr,iyi,rxr,rxi,ixr,ixi,cr,ci,g,sx,sr) ryr = Mpy_32_16_1(L_sub(Mpy_32_16_1(*rxr,*cr),Mpy_32_16_1(*rxi,*ci)),g); \ - ryi = Mpy_32_16_1(L_add(Mpy_32_16_1(*rxr,*ci),Mpy_32_16_1(*rxi,*cr)),g); \ - iyr = Mpy_32_16_1(L_sub(Mpy_32_16_1(*ixr,*cr),Mpy_32_16_1(*ixi,*ci)),g); \ - iyi = Mpy_32_16_1(L_add(Mpy_32_16_1(*ixr,*ci),Mpy_32_16_1(*ixi,*cr)),g); \ - rxr+=sx, rxi+=sx, ixr+=sx, ixi+=sx, cr+=sr, ci+=sr +#define cplxMpyS(yr,yi,xr,xi,cr,ci,syr,syi,sxr,sxi,CL_x,CL_z,C_c) CL_x = CL_form( *xr, *xi ); \ + C_c = C_form( *cr, *ci ); \ + CL_z = CL_mult_32x16( CL_x, C_c ); \ + *yr = CL_Extract_real( CL_z ); \ + *yi = CL_Extract_imag( CL_z ); \ + yr+=syr, yi+=syi, xr+=sxr, xi+=sxi, cr++, ci++ + +#define cplxMpy(ryr,ryi,iyr,iyi,rxr,rxi,ixr,ixi,cr,ci,g,sx,sr,CL_x,CL_ry,CL_iy,C_c) CL_x = CL_form( *rxr, *rxi ); \ + C_c = C_form( *cr, *ci ); \ + CL_ry = CL_mult_32x16( CL_x, C_c ); \ + CL_x = CL_form( *ixr, *ixi ); \ + CL_iy = CL_mult_32x16( CL_x, C_c ); \ + CL_ry = CL_scale_t( CL_ry, g ); \ + CL_iy = CL_scale_t( CL_iy, g ); \ + ryr = CL_Extract_real( CL_ry ); \ + ryi = CL_Extract_imag( CL_ry ); \ + iyr = CL_Extract_real( CL_iy ); \ + iyi = CL_Extract_imag( CL_iy ); \ + rxr+=sx, rxi+=sx, ixr+=sx, ixi+=sx, cr+=sr, ci+=sr #define add1(y1,y2,y3,y4,rr12,ri12,ir12,ii12,s) *y1 = round_fx(L_shl(L_negate(L_add(rr12,ii12)),s)); \ *y2 = round_fx(L_shl(L_negate(L_add(ri12,ir12)),s)); \ @@ -93,61 +99,6 @@ cldfb_init_proto_and_twiddles(HANDLE_CLDFB_FILTER_BANK hs); -static void cplxMult10(Word32 *yr, Word32 *yi, Word32 *xr, Word32 *xi, const Word16 *cr, const Word16 *ci, Word16 syr, Word16 syi, Word16 sxr, Word16 sxi) -{ - Word32 zr, zi; - - cplxMpyS(yr,yi,xr,xi,cr,ci,syr,syi,sxr,sxi,zr,zi); - cplxMpyS(yr,yi,xr,xi,cr,ci,syr,syi,sxr,sxi,zr,zi); - cplxMpyS(yr,yi,xr,xi,cr,ci,syr,syi,sxr,sxi,zr,zi); - cplxMpyS(yr,yi,xr,xi,cr,ci,syr,syi,sxr,sxi,zr,zi); - cplxMpyS(yr,yi,xr,xi,cr,ci,syr,syi,sxr,sxi,zr,zi); -} - -static void cplxMult16(Word32 *yr, Word32 *yi, Word32 *xr, Word32 *xi, const Word16 *cr, const Word16 *ci, Word16 syr, Word16 syi, Word16 sxr, Word16 sxi) -{ - Word32 zr, zi; - - cplxMpyS(yr,yi,xr,xi,cr,ci,syr,syi,sxr,sxi,zr,zi); - cplxMpyS(yr,yi,xr,xi,cr,ci,syr,syi,sxr,sxi,zr,zi); - cplxMpyS(yr,yi,xr,xi,cr,ci,syr,syi,sxr,sxi,zr,zi); - cplxMpyS(yr,yi,xr,xi,cr,ci,syr,syi,sxr,sxi,zr,zi); - cplxMpyS(yr,yi,xr,xi,cr,ci,syr,syi,sxr,sxi,zr,zi); - cplxMpyS(yr,yi,xr,xi,cr,ci,syr,syi,sxr,sxi,zr,zi); - cplxMpyS(yr,yi,xr,xi,cr,ci,syr,syi,sxr,sxi,zr,zi); - cplxMpyS(yr,yi,xr,xi,cr,ci,syr,syi,sxr,sxi,zr,zi); -} - -static void cplxMult20(Word32 *yr, Word32 *yi, Word32 *xr, Word32 *xi, const Word16 *cr, const Word16 *ci, Word16 syr, Word16 syi, Word16 sxr, Word16 sxi) -{ - cplxMult10(&yr[0*N10*syr], &yi[0*N10*syi], &xr[0*N10*sxr], &xi[0*N10*sxi], &cr[0*N10], &ci[0*N10], syr, syi, sxr, sxi); - cplxMult10(&yr[1*N10*syr], &yi[1*N10*syi], &xr[1*N10*sxr], &xi[1*N10*sxi], &cr[1*N10], &ci[1*N10], syr, syi, sxr, sxi); -} - -static void cplxMult30(Word32 *yr, Word32 *yi, Word32 *xr, Word32 *xi, const Word16 *cr, const Word16 *ci, Word16 syr, Word16 syi, Word16 sxr, Word16 sxi) -{ - cplxMult10(&yr[0*N10*syr], &yi[0*N10*syi], &xr[0*N10*sxr], &xi[0*N10*sxi], &cr[0*N10], &ci[0*N10], syr, syi, sxr, sxi); - cplxMult10(&yr[1*N10*syr], &yi[1*N10*syi], &xr[1*N10*sxr], &xi[1*N10*sxi], &cr[1*N10], &ci[1*N10], syr, syi, sxr, sxi); - cplxMult10(&yr[2*N10*syr], &yi[2*N10*syi], &xr[2*N10*sxr], &xi[2*N10*sxi], &cr[2*N10], &ci[2*N10], syr, syi, sxr, sxi); -} - -static void cplxMult32(Word32 *yr, Word32 *yi, Word32 *xr, Word32 *xi, const Word16 *cr, const Word16 *ci, Word16 syr, Word16 syi, Word16 sxr, Word16 sxi) -{ - cplxMult16(&yr[0*N16*syr], &yi[0*N16*syi], &xr[0*N16*sxr], &xi[0*N16*sxi], &cr[0*N16], &ci[0*N16], syr, syi, sxr, sxi); - cplxMult16(&yr[1*N16*syr], &yi[1*N16*syi], &xr[1*N16*sxr], &xi[1*N16*sxi], &cr[1*N16], &ci[1*N16], syr, syi, sxr, sxi); -} - -static void cplxMult40(Word32 *yr, Word32 *yi, Word32 *xr, Word32 *xi, const Word16 *cr, const Word16 *ci, Word16 syr, Word16 syi, Word16 sxr, Word16 sxi) -{ - cplxMult20(&yr[0*N20*syr], &yi[0*N20*syi], &xr[0*N20*sxr], &xi[0*N20*sxi], &cr[0*N20], &ci[0*N20], syr, syi, sxr, sxi); - cplxMult20(&yr[1*N20*syr], &yi[1*N20*syi], &xr[1*N20*sxr], &xi[1*N20*sxi], &cr[1*N20], &ci[1*N20], syr, syi, sxr, sxi); -} - -static void cplxMult60(Word32 *yr, Word32 *yi, Word32 *xr, Word32 *xi, const Word16 *cr, const Word16 *ci, Word16 syr, Word16 syi, Word16 sxr, Word16 sxi) -{ - cplxMult30(&yr[0*N30*syr], &yi[0*N30*syi], &xr[0*N30*sxr], &xi[0*N30*sxi], &cr[0*N30], &ci[0*N30], syr, syi, sxr, sxi); - cplxMult30(&yr[1*N30*syr], &yi[1*N30*syi], &xr[1*N30*sxr], &xi[1*N30*sxi], &cr[1*N30], &ci[1*N30], syr, syi, sxr, sxi); -} static void cplxMultAdd10_1(Word16 *rY1, Word16 *rY2, Word16 *rY3, Word16 *rY4, Word32 *rXR, Word32 *rXI, Word32 *iXR, Word32 *iXI, @@ -155,11 +106,14 @@ static void cplxMultAdd10_1(Word16 *rY1, Word16 *rY2, Word16 *rY3, Word16 *rY4, Word16 sx, Word16 sr) { Word32 rr12, ri12, ir12, ii12; + cmplx CL_x,CL_ry, CL_iy; + cmplx_s C_c; - cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr); + cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr,CL_x,CL_ry, CL_iy,C_c); add1(rY1, rY2, rY3, rY4, rr12, ri12, ir12, ii12, s); - cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr); + cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr,CL_x,CL_ry, CL_iy,C_c); add1(rY1, rY2, rY3, rY4, rr12, ri12, ir12, ii12, s); + } static void cplxMultAdd10_2(Word16 *rY1, Word16 *rY2, Word16 *rY3, Word16 *rY4, @@ -168,13 +122,16 @@ static void cplxMultAdd10_2(Word16 *rY1, Word16 *rY2, Word16 *rY3, Word16 *rY4, Word16 sx, Word16 sr) { Word32 rr12, ri12, ir12, ii12; - - cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr); - add2(rY1, rY2, rY3, rY4, rr12, ri12, ir12, ii12, s); - cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr); + cmplx CL_x,CL_ry, CL_iy; + cmplx_s C_c; + + cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr, CL_x, CL_ry, CL_iy, C_c); add2(rY1, rY2, rY3, rY4, rr12, ri12, ir12, ii12, s); - cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr); + cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr, CL_x, CL_ry, CL_iy, C_c); add2(rY1, rY2, rY3, rY4, rr12, ri12, ir12, ii12, s); + cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr, CL_x, CL_ry, CL_iy, C_c); + add2(rY1, rY2, rY3, rY4, rr12, ri12, ir12, ii12, s); + } @@ -184,17 +141,21 @@ static void cplxMultAdd20_1(Word16 *rY1, Word16 *rY2, Word16 *rY3, Word16 *rY4, Word16 sx, Word16 sr) { Word32 rr12, ri12, ir12, ii12; - - cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr); + cmplx CL_x,CL_ry, CL_iy; + cmplx_s C_c; + + cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr, CL_x, CL_ry, CL_iy, C_c); add1(rY1, rY2, rY3, rY4, rr12, ri12, ir12, ii12, s); - cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr); + cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr, CL_x, CL_ry, CL_iy, C_c); add1(rY1, rY2, rY3, rY4, rr12, ri12, ir12, ii12, s); - cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr); + cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr, CL_x, CL_ry, CL_iy, C_c); add1(rY1, rY2, rY3, rY4, rr12, ri12, ir12, ii12, s); - cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr); + cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr, CL_x, CL_ry, CL_iy, C_c); add1(rY1, rY2, rY3, rY4, rr12, ri12, ir12, ii12, s); - cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr); + cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr, CL_x, CL_ry, CL_iy, C_c); add1(rY1, rY2, rY3, rY4, rr12, ri12, ir12, ii12, s); + + } static void cplxMultAdd20_2(Word16 *rY1, Word16 *rY2, Word16 *rY3, Word16 *rY4, @@ -203,17 +164,20 @@ static void cplxMultAdd20_2(Word16 *rY1, Word16 *rY2, Word16 *rY3, Word16 *rY4, Word16 sx, Word16 sr) { Word32 rr12, ri12, ir12, ii12; + cmplx CL_x,CL_ry, CL_iy; + cmplx_s C_c; - cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr); - add2(rY1, rY2, rY3, rY4, rr12, ri12, ir12, ii12, s); - cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr); + cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr, CL_x, CL_ry, CL_iy, C_c); add2(rY1, rY2, rY3, rY4, rr12, ri12, ir12, ii12, s); - cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr); + cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr, CL_x, CL_ry, CL_iy, C_c); add2(rY1, rY2, rY3, rY4, rr12, ri12, ir12, ii12, s); - cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr); + cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr, CL_x, CL_ry, CL_iy, C_c); add2(rY1, rY2, rY3, rY4, rr12, ri12, ir12, ii12, s); - cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr); + cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr, CL_x, CL_ry, CL_iy, C_c); add2(rY1, rY2, rY3, rY4, rr12, ri12, ir12, ii12, s); + cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr, CL_x, CL_ry, CL_iy, C_c); + add2(rY1, rY2, rY3, rY4, rr12, ri12, ir12, ii12, s); + } /* calcModulation @@ -264,35 +228,29 @@ static void calcModulation( Word32 *rYR, Word16 m ) { + cmplx CL_x,CL_z; + cmplx_s C_c; + int i; + int lc = m >> 1; - SWITCH (m) + const Word16 *cr = rRotVctr; + const Word16 *ci = iRotVctr; + + for(i=0;ilb_scale = add(cldfbBank->anaScalefactor, add(cldfbBank->FilterStates_eg, scale)); move16(); /* FFT of DCT IV */ - BASOP_cfft(&iBuffer[0], &iBuffer[1], m2, 2, &scale, workBuffer); + BASOP_cfft((cmplx *)iBuffer, m2, &scale, workBuffer); /* post modulation of DST IV and DCT IV */ calcModulation(&rAnalysis[k][m-1], &rAnalysis[k][0], &rBuffer[0], &rBuffer[1],-2, 2, 2, 2, @@ -766,7 +724,7 @@ cldfbSynthesisFiltering( HANDLE_CLDFB_FILTER_BANK cldfbBank, scale = scaleFactor->lb_scale; move16(); - if ( sub(Lz, Mz) != 0 ) + if ( NE_16(Lz, Mz)) { scale = s_max(scale, scaleFactor->hb_scale); } @@ -779,14 +737,14 @@ cldfbSynthesisFiltering( HANDLE_CLDFB_FILTER_BANK cldfbBank, scaleMod = sub(add(scale, cldfbBank->outScalefactor), outScale); /* Increase CLDFB synthesis states for low level signals */ - IF ( sub(scale, 8) < 0) + IF ( LT_16(scale, 8)) { scaleMod = add(scaleMod, 2); outScale = sub(outScale, 2); } scaleMod = sub(scaleMod, timeOut_e); scale = add(outScale, timeOut_e); - IF ( sub(scale, cldfbBank->FilterStates_eg) != 0) + IF ( NE_16(scale, cldfbBank->FilterStates_eg)) { Scale_sig(cldfbBank->FilterStates, statesSizeM2, sub(cldfbBank->FilterStates_eg, scale)); cldfbBank->FilterStates_eg = scale; @@ -804,7 +762,7 @@ cldfbSynthesisFiltering( HANDLE_CLDFB_FILTER_BANK cldfbBank, move32(); } - IF ( sub(i,Mz) < 0 ) + IF ( LT_16(i,Mz)) { FOR ( ; i < Mz; i+=2) { @@ -815,7 +773,7 @@ cldfbSynthesisFiltering( HANDLE_CLDFB_FILTER_BANK cldfbBank, } } - IF ( sub(i,m) < 0 ) + IF ( LT_16(i,m)) { FOR ( ; i < m; i+=2) { @@ -832,7 +790,7 @@ cldfbSynthesisFiltering( HANDLE_CLDFB_FILTER_BANK cldfbBank, move32(); } - IF ( sub(i,Mz) < 0 ) + IF ( LT_16(i,Mz)) { FOR ( ; i < Mz; i+=2) { @@ -843,7 +801,7 @@ cldfbSynthesisFiltering( HANDLE_CLDFB_FILTER_BANK cldfbBank, } } - IF ( sub(i,m) < 0 ) + IF ( LT_16(i,m)) { FOR ( ; i < m; i+=2) { @@ -862,12 +820,12 @@ cldfbSynthesisFiltering( HANDLE_CLDFB_FILTER_BANK cldfbBank, /* FFT of DST IV */ scale = 0; move16(); - BASOP_cfft(&rBuffer[0], &rBuffer[1], m2, 2, &scale, workBuffer); + BASOP_cfft((cmplx *)rBuffer, m2, &scale, workBuffer); /* FFT of DCT IV */ scale = scaleMod; move16(); - BASOP_cfft(&iBuffer[0], &iBuffer[1], m2, 2, &scale, workBuffer); + BASOP_cfft((cmplx *)iBuffer, m2, &scale, workBuffer); /* post modulation and folding */ calcModulationAndFolding(nBuffer, rBuffer, iBuffer, rRotVctr, iRotVctr, cldfbBank->synGain, scale, m, m2); @@ -904,9 +862,9 @@ cldfbSynthesisFiltering( HANDLE_CLDFB_FILTER_BANK cldfbBank, acc = L_mac(acc, *pStatesI, *pFilterS++); acc = L_mac(acc, nBuffer[channels1-i], *pFilterM++); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF timeOut[(offset1-i)*stride] = round_fx(L_shl(acc,outScale)); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON } FOR ( ; ino_channels; i++) @@ -935,9 +893,9 @@ cldfbSynthesisFiltering( HANDLE_CLDFB_FILTER_BANK cldfbBank, acc = L_mac(acc, nBuffer[channels1+m-i], *pFilterS++); pFilterM++; - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF timeOut[(offset2-i)*stride] = round_fx(L_shl(acc,outScale)); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON } FOR (i=0; ino_channels; i++) @@ -1301,7 +1259,7 @@ GetEnergyCldfb( Word32 *energyLookahead, /*!< o: Q(*sf_energyLookahead) | p } } - IF(sub(numberBands, freqTable[1]) >= 0) + IF(GE_16(numberBands, freqTable[1])) { Word32 *tempEnergyValuesArry[CLDFB_NO_COL_MAX]; Word16 ScaleX2; @@ -1343,7 +1301,7 @@ GetEnergyCldfb( Word32 *energyLookahead, /*!< o: Q(*sf_energyLookahead) | p move32(); } test(); - IF ( j == 0 || sub(energyValuesSumE[j],*energyValuesSum_Exp) > 0 ) + IF ( j == 0 || GT_16(energyValuesSumE[j],*energyValuesSum_Exp)) { *energyValuesSum_Exp = energyValuesSumE[j]; } @@ -1356,7 +1314,7 @@ GetEnergyCldfb( Word32 *energyLookahead, /*!< o: Q(*sf_energyLookahead) | p *energyValuesSum_Exp = sub( *energyValuesSum_Exp, shl( sf_Values, 1 ) ); move16(); - IF ( sub(numberBands,20) > 0 ) + IF ( GT_16(numberBands,20)) { numberBandsM = s_min(numberBands, 40); numberBandsM20 = sub(numberBandsM, 20); @@ -1401,12 +1359,12 @@ GetEnergyCldfb( Word32 *energyLookahead, /*!< o: Q(*sf_energyLookahead) | p s = sub(shl(sf_Values, 1), s); sm = sub(s_min(s, 44), 1); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF /* nrg + 6.1e-5f => value 0x40000000, scale 44 */ *energyLookahead = L_add(L_shr(nrg, sub(s, sm)), L_shr(0x40000000, s_max(-31, s_min(31, sub(44, sm))))); move32(); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON *sf_energyLookahead = sm; move16(); @@ -1470,7 +1428,7 @@ CLDFB_getNumChannels(Word32 sampleRate) static Word16 cldfb_get_memory_length (HANDLE_CLDFB_FILTER_BANK hs) { - IF (sub(hs->type,CLDFB_ANALYSIS)==0) + IF (EQ_16(hs->type,CLDFB_ANALYSIS)) { return (i_mult(hs->no_channels,STATE_BUFFER_SIZE)); } @@ -1671,7 +1629,7 @@ cldfb_restore_memory (HANDLE_CLDFB_FILTER_BANK hs) /* i/o: cldfb handle */ move16(); /* adjust sample rate if it was changed in the meanwhile */ - IF (sub (hs->memory_length,size) != 0) + IF (NE_16 (hs->memory_length,size)) { lerp(hs->FilterStates, hs->FilterStates, size, hs->memory_length); } diff --git a/lib_com/cng_exc_fx.c b/lib_com/cng_exc_fx.c index a6e163b8f40ddaa7fd26cbe61c7d15dfd4a084d2..c4f4cd7e27883d4ef69f9bc09aaaa00c3519c05e 100644 --- a/lib_com/cng_exc_fx.c +++ b/lib_com/cng_exc_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "cnst_fx.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - #include "rom_com_fx.h" /*---------------------------------------------------------------------* @@ -74,7 +72,7 @@ void CNG_exc_fx( pit_max = PIT16k_MAX; move16(); - if( sub(L_frame,L_FRAME) == 0 ) + if( EQ_16(L_frame,L_FRAME)) { pit_max = PIT_MAX; move16(); @@ -86,7 +84,7 @@ void CNG_exc_fx( IF(*first_CNG == 0 ) { - IF(L_sub(core_brate,FRAME_NO_DATA) == 0 ) + IF(EQ_32(core_brate,FRAME_NO_DATA)) { /* needed only in decoder when the very first SID frame was erased and this frame is FRAME_NO_DATA frame */ /*fenew = dotp( fexc, fexc, pit_max )/pit_max;*/ @@ -94,7 +92,7 @@ void CNG_exc_fx( L_tmp_ener = Mult_32_16(L_tmp_ener, 9079); /* divide by PIT_MAX (in Q15 + Q6 to get output in Q6)*/ L_tmp_ener = L_shr(L_tmp_ener, Q_ener); /* -> If we want ener in Q6 */ - if(sub(L_frame, L_FRAME16k) == 0) + if(EQ_16(L_frame, L_FRAME16k)) { L_tmp_ener = Mult_32_16(L_tmp_ener, 26214); /* Compensate for 16kHz */ } @@ -111,14 +109,14 @@ void CNG_exc_fx( *---------------------------------------------------------------------*/ test(); test(); - IF( L_sub(last_core_brate,SID_1k75) != 0 && L_sub(last_core_brate,FRAME_NO_DATA) != 0 && L_sub(last_core_brate,SID_2k40) != 0 ) + IF( NE_32(last_core_brate,SID_1k75)&&NE_32(last_core_brate,FRAME_NO_DATA)&&NE_32(last_core_brate,SID_2k40)) { /* Partially reset CNG energy after active speech period */ test(); IF ( allow_cn_step == 0 && *last_allow_cn_step == 0 ) { test(); - IF( sub(num_ho,3) < 0 || L_sub(Mult_32_16(*Enew,21845 /*1/1.5f, Q15*/), *lp_ener) < 0 ) + IF( LT_16(num_ho,3)||LT_32(Mult_32_16(*Enew,21845/*1/1.5f, Q15*/),*lp_ener)) { /**lp_ener = 0.8f * *lp_ener + 0.2f * *Enew;*/ L_tmp_ener = Mult_32_16(*lp_ener, 26214); @@ -134,7 +132,8 @@ void CNG_exc_fx( } ELSE { - L_tmp_ener = L_add(0,*Enew); + L_tmp_ener = *Enew; + move32(); *last_allow_cn_step = 0; move16(); } @@ -151,7 +150,7 @@ void CNG_exc_fx( ELSE { test(); - if ( L_sub(core_brate,SID_1k75) == 0 || L_sub(core_brate,SID_2k40) == 0 ) + if ( EQ_32(core_brate,SID_1k75)||EQ_32(core_brate,SID_2k40)) { *last_allow_cn_step = 0; move16(); @@ -165,7 +164,7 @@ void CNG_exc_fx( *lp_ener = L_max(L_tmp_ener,1); move32(); /*To avoid / per 0*/ - if ( sub(allow_cn_step,1) == 0) + if ( EQ_16(allow_cn_step,1)) { *last_allow_cn_step = 1; move16(); @@ -205,11 +204,11 @@ void CNG_exc_fx( exp = sub(exp, exp2); - if (sub(tmp, tmp2) > 0) + if (GT_16(tmp, tmp2)) { exp = add(exp, 1); } - if (sub(tmp, tmp2) > 0) + if (GT_16(tmp, tmp2)) { tmp = shr(tmp, 1); } @@ -230,7 +229,7 @@ void CNG_exc_fx( exc2[i_subfr+i] = round_fx(L_shl(L_tmp, exp)); } } - IF ( sub(Opt_AMR_WB,1) != 0 ) + IF ( NE_16(Opt_AMR_WB,1)) { Copy( exc2, exc3, L_FRAME16k); @@ -248,7 +247,7 @@ void CNG_exc_fx( enr1 = L_shr(L_tmp,10);/* Q6 */ - IF ( L_sub(core_brate,SID_2k40) == 0 ) + IF ( EQ_32(core_brate,SID_2k40)) { IF ( *sid_bw == 0 ) { @@ -292,7 +291,7 @@ void CNG_exc_fx( /* calculate the spectrum of random excitation signal */ Copy(exc2, fft_io, L_frame); - IF ( sub(L_frame,L_FRAME16k) == 0 ) + IF ( EQ_16(L_frame,L_FRAME16k)) { modify_Fs_fx( fft_io, L_FRAME16k, 16000, fft_io, 12800, exc_mem1, 0 ); } @@ -377,11 +376,11 @@ void CNG_exc_fx( exp2 = sub(31-6, exp2); /* in Q15 (L_tmp in Q6)*/ exp = sub(exp2, exp); /* Denormalize and substract */ - if (sub(tmp2, tmp) > 0) + if (GT_16(tmp2, tmp)) { exp = add(exp, 1); } - if (sub(tmp2, tmp) > 0) + if (GT_16(tmp2, tmp)) { tmp2 = shr(tmp2, 1); } @@ -400,7 +399,7 @@ void CNG_exc_fx( ifft_rel_fx(fft_io, L_FFT, LOG2_L_FFT); - IF ( sub(L_frame,L_FRAME16k) == 0 ) + IF ( EQ_16(L_frame,L_FRAME16k)) { modify_Fs_fx( fft_io, L_FFT, 12800, fft_io, 16000, exc_mem, 0 ); } @@ -409,7 +408,7 @@ void CNG_exc_fx( enr1 = L_deposit_l(1); pt_fft_io = fft_io; - IF( sub(L_frame, L_FRAME) == 0) + IF( EQ_16(L_frame, L_FRAME)) { FOR (j=0; j<128; j++) { @@ -453,11 +452,11 @@ void CNG_exc_fx( exp = sub(exp, exp2); - if (sub(tmp, tmp2) > 0) + if (GT_16(tmp, tmp2)) { exp = add(exp, 1); } - if (sub(tmp, tmp2) > 0) + if (GT_16(tmp, tmp2)) { tmp = shr(tmp, 1); } @@ -468,9 +467,9 @@ void CNG_exc_fx( test(); test(); test(); - IF( L_sub(last_core_brate,SID_2k40) != 0 && L_sub(last_core_brate,SID_1k75) != 0 && L_sub(last_core_brate,FRAME_NO_DATA) != 0 && L_sub(core_brate,SID_2k40) == 0 ) + IF( NE_32(last_core_brate,SID_2k40)&&NE_32(last_core_brate,SID_1k75)&&NE_32(last_core_brate,FRAME_NO_DATA)&&EQ_32(core_brate,SID_2k40)) { - IF ( L_sub(L_tmp,L_shl(1,sub(31,exp))) > 0 ) + IF ( GT_32(L_tmp,L_shl(1,sub(31,exp)))) { L_tmp = L_shl(1,sub(31,exp)); } @@ -497,7 +496,7 @@ void CNG_exc_fx( L_tmp2 = L_deposit_l(1); pt_fft_io = fft_io; - IF( sub(L_frame, L_FRAME) == 0) + IF( EQ_16(L_frame, L_FRAME)) { FOR (j=0; j<128; j++) { @@ -534,11 +533,11 @@ void CNG_exc_fx( exp2 = sub(31-6, exp2); /* in Q15 (L_tmp in Q6)*/ exp = sub(exp2, exp); /* Denormalize and substract */ - if (sub(tmp2, tmp) > 0) + if (GT_16(tmp2, tmp)) { exp = add(exp, 1); } - if (sub(tmp2, tmp) > 0) + if (GT_16(tmp2, tmp)) { tmp2 = shr(tmp2, 1); } @@ -555,7 +554,7 @@ void CNG_exc_fx( } Copy( fft_io, exc2, L_frame ); } - IF ( sub(Opt_AMR_WB,1) != 0 ) + IF ( NE_16(Opt_AMR_WB,1)) { Copy( exc3, exc, L_frame ); } @@ -564,7 +563,7 @@ void CNG_exc_fx( Copy( exc2, exc, L_frame ); } - IF( sub(L_frame,L_FRAME) == 0) + IF( EQ_16(L_frame,L_FRAME)) { interp_code_5over2_fx( exc2, bwe_exc, L_FRAME ); } @@ -640,19 +639,19 @@ void cng_params_postupd_fx( } Copy32(sp,env,NUM_ENV_CNG); - IF( L_sub(last_active_brate,ACELP_13k20) > 0 ) + IF( GT_32(last_active_brate,ACELP_13k20)) { CNG_mode = 4; } - ELSE IF( L_sub(last_active_brate,ACELP_9k60) > 0 ) + ELSE IF( GT_32(last_active_brate,ACELP_9k60)) { CNG_mode = 3; } - ELSE IF( L_sub(last_active_brate,ACELP_8k00) > 0 ) + ELSE IF( GT_32(last_active_brate,ACELP_8k00)) { CNG_mode = 2; } - ELSE IF( L_sub(last_active_brate,ACELP_7k20) > 0 ) + ELSE IF( GT_32(last_active_brate,ACELP_7k20)) { CNG_mode = 1; } @@ -685,7 +684,7 @@ void cng_params_postupd_fx( Copy32( env, &(ho_env_circ[(ptr)*NUM_ENV_CNG]), NUM_ENV_CNG ); ptr = add(ptr, 1); - if(sub(ptr, HO_HIST_SIZE) == 0) + if(EQ_16(ptr, HO_HIST_SIZE)) { ptr = 0; } @@ -740,7 +739,7 @@ void cng_params_upd_fx( /* update the pointer to circular buffer of old LSP vectors */ *ho_circ_ptr = add(*ho_circ_ptr,1); - if( sub(*ho_circ_ptr, HO_HIST_SIZE) == 0 ) + if( EQ_16(*ho_circ_ptr, HO_HIST_SIZE)) { *ho_circ_ptr = 0; move16(); @@ -763,7 +762,7 @@ void cng_params_upd_fx( pt_exc2 = exc2; move16(); L_ener = L_deposit_l(0); - IF( sub(L_frame, L_FRAME) == 0) + IF( EQ_16(L_frame, L_FRAME)) { FOR (j=0; j<128; j++) { @@ -795,11 +794,11 @@ void cng_params_upd_fx( ho_ener_circ[*ho_circ_ptr] = L_ener; move32(); - IF( sub(enc_dec_flag, ENC) == 0 ) + IF( EQ_16(enc_dec_flag, ENC)) { /* Store residual signal for postponed FFT-processing*/ *cng_buf_cnt = add(*cng_buf_cnt,1); - if( sub(*cng_buf_cnt, HO_HIST_SIZE) > 0 ) + if( GT_16(*cng_buf_cnt, HO_HIST_SIZE)) { *cng_buf_cnt = HO_HIST_SIZE; move16(); @@ -835,19 +834,19 @@ void cng_params_upd_fx( } Copy32(sp,env,NUM_ENV_CNG); - IF( L_sub(last_active_brate,ACELP_13k20) > 0 ) + IF( GT_32(last_active_brate,ACELP_13k20)) { CNG_mode = 4; } - ELSE IF( L_sub(last_active_brate,ACELP_9k60) > 0 ) + ELSE IF( GT_32(last_active_brate,ACELP_9k60)) { CNG_mode = 3; } - ELSE IF( L_sub(last_active_brate,ACELP_8k00) > 0 ) + ELSE IF( GT_32(last_active_brate,ACELP_8k00)) { CNG_mode = 2; } - ELSE IF( L_sub(last_active_brate,ACELP_7k20) > 0 ) + ELSE IF( GT_32(last_active_brate,ACELP_7k20)) { CNG_mode = 1; } @@ -881,7 +880,7 @@ void cng_params_upd_fx( Copy32( env, &(ho_env_circ[(*ho_circ_ptr)*NUM_ENV_CNG]), NUM_ENV_CNG ); } *ho_circ_size = add(*ho_circ_size,1); - if( sub(*ho_circ_size,HO_HIST_SIZE) > 0 ) + if( GT_16(*ho_circ_size,HO_HIST_SIZE)) { *ho_circ_size = HO_HIST_SIZE; move16(); diff --git a/lib_com/cnst_fx.h b/lib_com/cnst_fx.h index 4d1b08389b4e0d0ddc072c0308cd595ceec8ad2b..8ffedebd1193bfbcda30c654ac0233b539e08d8f 100644 --- a/lib_com/cnst_fx.h +++ b/lib_com/cnst_fx.h @@ -1,12 +1,12 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #ifndef CNST_FX_H #define CNST_FX_H #include "options.h" /* Compilation switches */ -#include "stl.h" + #define MODE1 1 #define MODE2 2 diff --git a/lib_com/codec_tcx_common.c b/lib_com/codec_tcx_common.c index 6e0ec772f12fd5cb1247868abd342d0aa9c36e31..b1609e6d2adffef49c10424cf0295e86377b1d6a 100644 --- a/lib_com/codec_tcx_common.c +++ b/lib_com/codec_tcx_common.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -7,8 +7,6 @@ #include "options.h" #include "stl.h" -#include "wmc_auto.h" - #include "prot_fx.h" #include "basop_util.h" #include "rom_basop_util.h" @@ -100,7 +98,7 @@ void tcxFormantEnhancement( move16(); test(); - IF ((sub(xn_buf[i-1], xn_buf[i]) <= 0) && (sub(xn_buf[i+1], xn_buf[i]) <= 0)) + IF ((LE_16(xn_buf[i-1], xn_buf[i]))&&(LE_16(xn_buf[i+1],xn_buf[i]))) { m = s_max(xn_buf[i-1], xn_buf[i+1]); e = xn_buf_e; @@ -270,7 +268,7 @@ void tcxInvertWindowGrouping(TCX_config *tcx_cfg, IF ((tcx_cfg->fIsTNSAllowed != 0) && (bfi == 0) && (fUseTns != 0)) { /* rearrange LF sub-window lines prior to TNS synthesis filtering */ - IF (sub(L_spec, L_frame) < 0) + IF (LT_16(L_spec, L_frame)) { Copy32(spectrum+8, spectrum+16, sub(shr(L_spec,1),8)); Copy32(spectrum+L_frame/2, spectrum+8, 8); diff --git a/lib_com/core_com_config_fx.c b/lib_com/core_com_config_fx.c index f3e3972ca9a6c6586e494f79f4bb4511da12ea61..9c24ffd460edb5a919ce2ee19adc3064cdcefd31 100644 --- a/lib_com/core_com_config_fx.c +++ b/lib_com/core_com_config_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -9,8 +9,6 @@ #include "options.h" #include "stl.h" -#include "wmc_auto.h" - #include "basop_util.h" #include "prot_fx.h" #include "rom_com_fx.h" @@ -23,7 +21,7 @@ Word8 getTcxonly(const Word32 bitrate) tcxonly = 0; move16(); - if( L_sub(bitrate,32000) > 0 ) + if( GT_32(bitrate,32000)) { tcxonly = 1; move16(); @@ -59,7 +57,7 @@ Word8 getResq(const Word32 bitrate) resq = 0; move16(); - if (L_sub(bitrate,64000) <= 0) + if (LE_32(bitrate,64000)) { resq = 1; move16(); @@ -79,7 +77,7 @@ Word8 getTnsAllowed(const Word32 bitrate move16(); IF ( igf != 0 ) { - if( L_sub(bitrate, HQ_16k40) > 0 ) + if( GT_32(bitrate, HQ_16k40)) { tnsAllowed = 1; move16(); @@ -87,7 +85,7 @@ Word8 getTnsAllowed(const Word32 bitrate } ELSE { - if( L_sub(bitrate, HQ_32k) > 0) + if( GT_32(bitrate, HQ_32k)) { tnsAllowed = 1; move16(); @@ -107,7 +105,7 @@ Word8 getRestrictedMode(const Word32 bitrate, const Word16 Opt_AMR_WB) move16(); test(); - IF ( (Opt_AMR_WB == 0) && (L_sub(bitrate,32000) > 0 ) ) + IF ( (Opt_AMR_WB == 0) && (GT_32(bitrate,32000))) { restrictedMode = 6; move16(); @@ -181,30 +179,30 @@ Word32 getCoreSamplerateMode2(const Word32 bitrate, const Word16 bandwidth, cons test(); test(); - IF( L_sub( bandwidth,NB) == 0 ) + IF( EQ_32( bandwidth,NB)) { sr_core = 12800; move32(); } - ELSE IF ( L_and(L_sub(bandwidth,WB)==0, L_sub(bitrate,13200)<0) || - L_and(L_sub(bandwidth,SWB)==0, L_sub(bitrate,13200)<=0) || sub(rf_mode,1) == 0 ) + ELSE IF ( L_and(EQ_32(bandwidth,WB),LT_32(bitrate,13200))|| + L_and(EQ_32(bandwidth,SWB), LE_32(bitrate,13200)) || EQ_16(rf_mode,1) ) { sr_core = 12800; move32(); } - ELSE IF (L_sub(bandwidth,WB)==0 || ( (L_sub(bitrate,32000)<=0) && ((L_sub(bandwidth,SWB)==0) || (L_sub(bandwidth,FB)==0)) ) ) + ELSE IF (EQ_32(bandwidth,WB)||((LE_32(bitrate,32000))&&((EQ_32(bandwidth,SWB))||(EQ_32(bandwidth,FB))))) { sr_core = 16000; move32(); } - ELSE IF ( ((L_sub(bandwidth,SWB)==0) || (L_sub(bandwidth,FB)==0)) && (L_sub(bitrate,64000)<=0) ) + ELSE IF ( ((EQ_32(bandwidth,SWB))||(EQ_32(bandwidth,FB)))&&(LE_32(bitrate,64000))) { sr_core = 25600; move32(); } - ELSE IF (L_sub(bandwidth,SWB)==0 || L_sub(bandwidth,FB)==0) + ELSE IF (EQ_32(bandwidth,SWB)||EQ_32(bandwidth,FB)) { sr_core = 32000; move32(); @@ -224,7 +222,7 @@ Word16 getTcxBandwidth(const Word16 bandwidth) tcxBandwidth = 16384/*0.5f Q15*/; move16(); - if(sub(bandwidth, NB) == 0) + if(EQ_16(bandwidth, NB)) { tcxBandwidth = 10240/*0.3125f Q15*/; move16(); @@ -248,21 +246,21 @@ Word8 getIgfPresent( test(); test(); - if( (sub(bandwidth, SWB) == 0) && (L_sub(bitrate, ACELP_9k60) >= 0) && (L_sub(bitrate, HQ_64k) < 0) ) + if( (EQ_16(bandwidth, SWB))&&(GE_32(bitrate,ACELP_9k60))&&(LT_32(bitrate,HQ_64k))) { igfPresent = 1; move16(); } test(); - if( sub(bandwidth, FB) == 0 && (L_sub(bitrate, ACELP_16k40) >= 0)) + if( EQ_16(bandwidth, FB)&&(GE_32(bitrate,ACELP_16k40))) { igfPresent = 1; move16(); } test(); - if( (sub(bandwidth, WB) == 0) && (L_sub(bitrate, ACELP_9k60) == 0) ) + if( (EQ_16(bandwidth, WB))&&(EQ_32(bitrate,ACELP_9k60))) { igfPresent = 1; move16(); @@ -271,7 +269,7 @@ Word8 getIgfPresent( test(); test(); test(); - if( ((sub(bandwidth, WB) == 0) || (sub(bandwidth, SWB) == 0)) && (sub(rf_mode, 1) == 0) && (L_sub(bitrate, ACELP_13k20) == 0) ) + if( ((EQ_16(bandwidth, WB))||(EQ_16(bandwidth,SWB)))&&(EQ_16(rf_mode,1))&&(EQ_32(bitrate,ACELP_13k20))) { igfPresent = 1; move16(); @@ -291,21 +289,21 @@ Word8 getCnaPresent( flag_cna = 0; move16(); test(); - if( sub(bandwidth, NB) == 0 && (L_sub(bitrate, ACELP_13k20) <= 0) ) + if( EQ_16(bandwidth, NB)&&(LE_32(bitrate,ACELP_13k20))) { flag_cna = 1; move16(); } test(); - if( (sub(bandwidth, WB) == 0) && (L_sub(bitrate, ACELP_13k20) <= 0) ) + if( (EQ_16(bandwidth, WB))&&(LE_32(bitrate,ACELP_13k20))) { flag_cna = 1; move16(); } test(); - if( (sub(bandwidth, SWB) == 0) && (L_sub(bitrate, ACELP_13k20) <= 0) ) + if( (EQ_16(bandwidth, SWB))&&(LE_32(bitrate,ACELP_13k20))) { flag_cna = 1; move16(); @@ -322,7 +320,7 @@ Word8 getTcxLtp(const Word32 sr_core) tcxltp = 0; move16(); test(); - if ( (L_sub(sr_core, 25600) <= 0) ) + if ( (LE_32(sr_core, 25600))) { tcxltp = 1; move16(); @@ -344,7 +342,7 @@ Word16 initPitchLagParameters( Word16 pit_res_max; - IF (L_sub(sr_core, 12800) == 0) + IF (EQ_32(sr_core, 12800)) { *pit_min = PIT_MIN_12k8; @@ -361,7 +359,7 @@ Word16 initPitchLagParameters( move16(); } - ELSE IF (L_sub(sr_core, 16000) == 0) + ELSE IF (EQ_32(sr_core, 16000)) { *pit_min = PIT_MIN_16k; @@ -378,7 +376,7 @@ Word16 initPitchLagParameters( move16(); } - ELSE IF (L_sub(sr_core, 25600) == 0) + ELSE IF (EQ_32(sr_core, 25600)) { *pit_min = PIT_MIN_25k6; @@ -423,25 +421,25 @@ Word16 getNumTcxCodedLines(const Word16 bwidth) tcx_coded_lines = 0; move16(); - if(sub(bwidth, NB) == 0) + if(EQ_16(bwidth, NB)) { tcx_coded_lines = 160; move16(); } - if(sub(bwidth, WB) == 0) + if(EQ_16(bwidth, WB)) { tcx_coded_lines = 320; move16(); } - if(sub(bwidth, SWB) == 0) + if(EQ_16(bwidth, SWB)) { tcx_coded_lines = 640; move16(); } - if(sub(bwidth, FB) == 0) + if(EQ_16(bwidth, FB)) { tcx_coded_lines = 960; move16(); @@ -462,7 +460,7 @@ Word16 getTcxLpcShapedAri( (void) bwidth; test(); - if( (L_sub(total_brate, LPC_SHAPED_ARI_MAX_RATE) <= 0) || rf_mode ) + if( (LE_32(total_brate, LPC_SHAPED_ARI_MAX_RATE))||rf_mode) { tcx_lpc_shaped_ari = 1; move16(); diff --git a/lib_com/deemph_fx.c b/lib_com/deemph_fx.c index cb793c8e54b26e4d18f01b84e66ab1ce16616e08..1bb1de589e9528966d1d9ae5c4dc97b45d8ad03a 100644 --- a/lib_com/deemph_fx.c +++ b/lib_com/deemph_fx.c @@ -1,12 +1,10 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - #include "basop_util.h" /*========================================================================*/ diff --git a/lib_com/delay_comp.c b/lib_com/delay_comp.c index e6f929d7f9366200c3480c95d519d088238807dc..68028778dd0a66a960d0afd4b0d5f309cec0b059 100644 --- a/lib_com/delay_comp.c +++ b/lib_com/delay_comp.c @@ -1,11 +1,9 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "stl.h" -#include "wmc_auto.h" - #include "prot_fx.h" @@ -22,14 +20,14 @@ Word32 get_delay_fx( /* o : delay value in ms { Word32 delay = 0; - IF( sub(what_delay,ENC) == 0 ) + IF( EQ_16(what_delay,ENC)) { delay = (DELAY_FIR_RESAMPL_NS + ACELP_LOOK_NS); move32(); } ELSE { - IF( L_sub(io_fs,8000) == 0 ) + IF( EQ_32(io_fs,8000)) { delay = DELAY_CLDFB_NS; move32(); diff --git a/lib_com/disclaimer.c b/lib_com/disclaimer.c index f8faa472a50667e0d85cc53cf1a7f6ab630ec118..6d30dc30603ed953da85f515cb4e545ba7944bf0 100644 --- a/lib_com/disclaimer.c +++ b/lib_com/disclaimer.c @@ -1,12 +1,10 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "disclaimer.h" #include "options.h" #include "stl.h" -#include "wmc_auto.h" - /* WMC_TOOL_SKIP_FILE */ @@ -14,9 +12,8 @@ int print_disclaimer(FILE *fPtr) { fprintf(fPtr, "\n===========================================================================\n"); - fprintf(fPtr, " EVS Codec 3GPP TS26.442 August 12, 2021. \n"); - fprintf(fPtr, " Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0\n"); + fprintf(fPtr, " EVS Codec 3GPP TS26.452 November 04, 2021. \n"); + fprintf(fPtr, " Version 16.4.0\n"); fprintf(fPtr, "===========================================================================\n\n\n"); - return 0; } diff --git a/lib_com/disclaimer.h b/lib_com/disclaimer.h index d6f0e508a466f345c782d52bb9370b07b486ab5a..33129e00fa9d18dd7217a2420e8dabbd3035ec09 100644 --- a/lib_com/disclaimer.h +++ b/lib_com/disclaimer.h @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #ifndef __INCLUDED_DISCLAIMER_H diff --git a/lib_com/dlpc_bfi.c b/lib_com/dlpc_bfi.c index 0bb59ac94eb88efee3dd62323947016108f248de..0585fffdee5b60b62472f94a6025b4e830237476 100644 --- a/lib_com/dlpc_bfi.c +++ b/lib_com/dlpc_bfi.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ @@ -9,8 +9,6 @@ #include #include "prot_fx.h" #include "stl.h" -#include "wmc_auto.h" - #include "prot_fx.h" void dlpc_bfi( @@ -41,7 +39,7 @@ void dlpc_bfi( ,0 ); - IF ( sub(numlpc,2)==0 ) + IF ( EQ_16(numlpc,2)) { /* Decode the second LPC */ lsf_dec_bfi( diff --git a/lib_com/edct_fx.c b/lib_com/edct_fx.c index 46ffaf1d74389a3ca4134e56b072fd9168e11066..01700f1a4f812318956e75ecb54df12804a8b23f 100644 --- a/lib_com/edct_fx.c +++ b/lib_com/edct_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -9,8 +9,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - #include "math_32.h" @@ -112,8 +110,7 @@ void edct_fx( Word32 re; Word32 im; const Word16 *edct_table = 0; /*Q16 */ - Word32 re2[L_FRAME48k/2+240]; - Word32 im2[L_FRAME48k/2+240]; + Word32 complex_buf[2*(L_FRAME48k/2+240)]; Word32 L_tmp; Word16 tmp; Word16 len1; @@ -124,22 +121,22 @@ void edct_fx( FOR (i = 0; i < len1; i++) { L_tmp = Mult_32_16(x[2*i], edct_table[i]); /*Q(q+1) */ - re2[i] = Madd_32_16(L_tmp, x[length-1-2*i], edct_table[len1-1-i]); /*Q(q+1) */ move32(); + complex_buf[2*i] = Madd_32_16(L_tmp, x[length-1-2*i], edct_table[len1-1-i]); /*Q(q+1) */ move32(); L_tmp = Mult_32_16(x[length-1-2*i], edct_table[i]); /*Q(q+1) */ - im2[i] = Msub_32_16(L_tmp, x[2*i], edct_table[len1-1-i]); /*Q(q+1) */ move32(); + complex_buf[2*i+1] = Msub_32_16(L_tmp, x[2*i], edct_table[len1-1-i]); /*Q(q+1) */ move32(); } *q = sub(15, *q); - BASOP_cfft(re2, im2, len1, 1, q, y); + BASOP_cfft((cmplx *)complex_buf, len1, q, y); tmp = div_s(1, length); /*Q15 */ tmp = round_fx(L_shl(L_mult(tmp, 19302), 2)); /*Q15 */ FOR (i = 0; i < len1; i++) { - re = Msub_32_16(re2[i], im2[i], tmp); - im = Madd_32_16(im2[i], re2[i], tmp); + re = Msub_32_16(complex_buf[2*i], complex_buf[2*i+1], tmp); + im = Madd_32_16(complex_buf[2*i+1], complex_buf[2*i], tmp); y[2 * i] = L_add(Mult_32_16(re, edct_table[i]), Mult_32_16(im, edct_table[len1 - 1 - i])); move32(); y[length - 1 - 2 * i] = L_sub(Mult_32_16(re, edct_table[len1 - 1 - i]), Mult_32_16(im, edct_table[i])); @@ -174,8 +171,7 @@ void edst_fx( Word32 re; Word32 im; const Word16 *edct_table = 0; /*Q16 */ - Word32 re2[L_FRAME48k/2+240]; - Word32 im2[L_FRAME48k/2+240]; + Word32 complex_buf[2*(L_FRAME48k/2+240)]; Word32 L_tmp; Word16 tmp; Word16 len1; @@ -186,23 +182,23 @@ void edst_fx( FOR (i = 0; i < len1; i++) { L_tmp = Mult_32_16(x[length-1-2*i], edct_table[i]); - re2[i] = Madd_32_16(L_tmp, x[2*i], edct_table[len1-1-i]); + complex_buf[2*i] = Madd_32_16(L_tmp, x[2*i], edct_table[len1-1-i]); move32(); L_tmp = Mult_32_16(x[2*i], edct_table[i]); - im2[i] = Msub_32_16(L_tmp, x[length-1-2*i], edct_table[len1-1-i]); + complex_buf[2*i+1] = Msub_32_16(L_tmp, x[length-1-2*i], edct_table[len1-1-i]); move32(); } *q = sub(15, *q); - BASOP_cfft(re2, im2, len1, 1, q, y); + BASOP_cfft((cmplx *)complex_buf, len1, q, y); tmp = div_s(1, length); /*Q15 */ tmp = round_fx(L_shl(L_mult(tmp, 19302), 2)); /*Q15 */ FOR (i = 0; i < len1; i++) { - re = Msub_32_16(re2[i], im2[i], tmp); - im = Madd_32_16(im2[i], re2[i], tmp); + re = Msub_32_16(complex_buf[2*i], complex_buf[2*i+1], tmp); + im = Madd_32_16(complex_buf[2*i+1], complex_buf[2*i], tmp); y[2 * i] = L_add(Mult_32_16(re, edct_table[i]), Mult_32_16(im, edct_table[len1 - 1 - i])); move32(); y[length - 1 - 2 * i] = L_sub(Mult_32_16(im, edct_table[i]), Mult_32_16(re, edct_table[len1 - 1 - i])); @@ -257,17 +253,17 @@ void edct_16fx( /*COMPLETE: some eDCT sub function are missing */ - IF (sub(length,L_FRAME32k) == 0) + IF (EQ_16(length,L_FRAME32k)) { edct_table = &edct_table_320_16fx[0]; move16(); } - ELSE IF (sub(length,L_FRAME) == 0) + ELSE IF (EQ_16(length,L_FRAME)) { edct_table = &edct_table_128_16fx[0]; move16(); } - ELSE IF (sub(length,L_FRAME16k) == 0) + ELSE IF (EQ_16(length,L_FRAME16k)) { edct_table = &edct_table_160_16fx[0]; move16(); @@ -322,15 +318,15 @@ void edct_16fx( px -= 2; pt--; } - IF (sub(length,L_FRAME32k) == 0) + IF (EQ_16(length,L_FRAME32k)) { DoRTFT320_16fx(re2, im2); } - ELSE IF (sub(length,L_FRAME )== 0) + ELSE IF (EQ_16(length,L_FRAME )) { DoRTFT128_16fx(re2, im2); } - ELSE IF (sub(length,L_FRAME16k) == 0) + ELSE IF (EQ_16(length,L_FRAME16k)) { DoRTFT160_16fx(re2, im2); } diff --git a/lib_com/enhancer_fx.c b/lib_com/enhancer_fx.c index 5210febe0d21b495e57686e321a901b9e9aeb741..c532490e4b05124b11a9643d69c5eda04c0765b2 100644 --- a/lib_com/enhancer_fx.c +++ b/lib_com/enhancer_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -7,8 +7,6 @@ #include "prot_fx.h" /* Function prototypes */ #include "rom_com_fx.h" /* Static table prototypes */ #include "stl.h" -#include "wmc_auto.h" - #include "basop_util.h" /*---------------------------------------------------------------------* @@ -98,30 +96,30 @@ void enhancer_fx( move16(); /* no dispersion */ IF (Opt_AMR_WB) { - IF ( L_sub(core_brate,ACELP_6k60) <= 0) + IF ( LE_32(core_brate,ACELP_6k60)) { i = 0; move16(); /* high dispersion */ } - ELSE if ( L_sub(core_brate,ACELP_8k85) <= 0) + ELSE if ( LE_32(core_brate,ACELP_8k85)) { i = 1; move16(); /* low dispersion */ } } - ELSE IF( sub(coder_type,UNVOICED) != 0) + ELSE IF( NE_16(coder_type,UNVOICED)) { test(); test(); test(); test(); - IF ( L_sub(core_brate,ACELP_7k20) <= 0 ) + IF ( LE_32(core_brate,ACELP_7k20)) { i = 0; move16(); /* high dispersion */ } - ELSE if ( ( sub(coder_type,GENERIC) == 0 || sub(coder_type,TRANSITION) == 0 || sub(coder_type,AUDIO) == 0 || sub(coder_type,INACTIVE) == 0 ) && L_sub(core_brate,ACELP_9k60) <= 0 ) + ELSE if ( ( EQ_16(coder_type,GENERIC)||EQ_16(coder_type,TRANSITION)||EQ_16(coder_type,AUDIO)||EQ_16(coder_type,INACTIVE))&&LE_32(core_brate,ACELP_9k60)) { i = 1; move16(); /* low dispersion */ @@ -143,7 +141,7 @@ void enhancer_fx( /* fac = stab_fac * tmp */ fac = mult(stab_fac, tmp); /*Q15*/ - IF (L_sub(norm_gain_code, *gc_threshold) < 0) + IF (LT_32(norm_gain_code, *gc_threshold)) { L_tmp = Madd_32_16(norm_gain_code, norm_gain_code, 6226);/*Q16 */ L_tmp = L_min(L_tmp, *gc_threshold);/*Q16 */ @@ -176,7 +174,7 @@ void enhancer_fx( * filter to decrease energy of code at low frequency. *------------------------------------------------------------*/ test(); - IF( !Opt_AMR_WB && sub(coder_type,UNVOICED) == 0 ) + IF( !Opt_AMR_WB && EQ_16(coder_type,UNVOICED)) { /* Copy(code, exc2, L_SUBFR) */ FOR (i = 0; i < L_SUBFR; i++) @@ -188,12 +186,12 @@ void enhancer_fx( { test(); test(); - IF ( Opt_AMR_WB && ( L_sub(core_brate,ACELP_8k85) == 0|| L_sub(core_brate,ACELP_6k60) == 0 ) ) + IF ( Opt_AMR_WB && ( EQ_32(core_brate,ACELP_8k85)||EQ_32(core_brate,ACELP_6k60))) { pit_sharp = shl(gain_pit, 1); /* saturation can occur here Q14 -> Q15 */ /* saturation takes care of "if (pit_sharp > 1.0) { pit_sharp=1.0; }" */ - IF (sub(pit_sharp, 16384) > 0) + IF (GT_16(pit_sharp, 16384)) { tmp16 = mult(pit_sharp, 8192); FOR (i = 0; i < L_SUBFR; i++) @@ -205,7 +203,7 @@ void enhancer_fx( } } - IF ( sub(L_frame, L_FRAME16k) == 0 ) + IF ( EQ_16(L_frame, L_FRAME16k)) { /* tmp = 0.150 * (1.0 + voice_fac) */ /* 0.30=voiced, 0=unvoiced */ @@ -249,9 +247,9 @@ void enhancer_fx( move16();/* in Q_exc */ test(); test(); - IF ( Opt_AMR_WB && ( L_sub(core_brate,ACELP_8k85) == 0 || L_sub(core_brate,ACELP_6k60) == 0 ) ) + IF ( Opt_AMR_WB && ( EQ_32(core_brate,ACELP_8k85)||EQ_32(core_brate,ACELP_6k60))) { - IF (sub(pit_sharp, 16384) > 0) + IF (GT_16(pit_sharp, 16384)) { FOR (i = 0; i < L_SUBFR; i++) { @@ -305,7 +303,7 @@ Word16 E_UTIL_enhancer( max_cdk_index_uv = 10; move16(); - if ( sub(L_frame, L_FRAME16k) == 0 ) + if ( EQ_16(L_frame, L_FRAME16k)) { max_cdk_index_uv = 14; move16(); @@ -315,11 +313,11 @@ Word16 E_UTIL_enhancer( test(); test(); test(); - IF ( ( (sub(coder_type, VOICED) != 0) && (sub(cdk_index, 2) <= 0) ) || ( (sub(coder_type, UNVOICED) == 0) && (sub(cdk_index, max_cdk_index_uv) <= 0) ) ) + IF ( ( (NE_16(coder_type, VOICED))&&(LE_16(cdk_index,2)))||((EQ_16(coder_type,UNVOICED))&&(LE_16(cdk_index,max_cdk_index_uv)))) { disp_mode = 0; /* high */ move16(); } - ELSE IF ( (sub(coder_type, VOICED) != 0) && (sub(cdk_index, 7) <= 0) ) + ELSE IF ( (NE_16(coder_type, VOICED))&&(LE_16(cdk_index,7))) { disp_mode = 1; /* low */ move16(); } @@ -338,14 +336,15 @@ Word16 E_UTIL_enhancer( move16(); /* if gain_code is computed function of energy, noise enhancer is by-passed.*/ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF tmp = msu_r(1073741824l/*0.5f Q31*/, 16384/*0.5f Q15*/, voice_fac); /* 1=unvoiced, 0=voiced */ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON fac = mult_r(stab_fac, tmp); /* fac in Q15 */ - L_tmp = L_add(0,gain_code); /* L_tmp in 15Q16 */ + L_tmp = gain_code; /* L_tmp in 15Q16 */ + move32(); - IF (L_sub(L_tmp,*gc_threshold) < 0) + IF (LT_32(L_tmp,*gc_threshold)) { L_tmp = L_shl(Mpy_32_32(L_tmp, 1277752832l/*1.19f/2.0f Q31*/),1); L_tmp = L_min(L_tmp, *gc_threshold); @@ -390,7 +389,7 @@ Word16 E_UTIL_enhancer( gain = add(sub(code_exp, exc2_exp), 1); tmp = mac_r(268435456l/*0.125f Q31*/, 4096/*0.125f Q15*/, voice_fac); /* 0.25=voiced, 0=unvoiced */ - if ( sub(L_frame, L_FRAME16k) == 0 ) + if ( EQ_16(L_frame, L_FRAME16k)) { tmp = mac_r(322122560l/*0.150f Q31*/, 4915/*0.150f Q15*/, voice_fac); /* 0.30=voiced, 0=unvoiced */ } @@ -485,13 +484,13 @@ static void phase_dispersion_fx( state = 2; move16(); - if (sub(gain_pit, pitch_0_9) < 0) + if (LT_16(gain_pit, pitch_0_9)) { state = 1; move16(); } - if (sub(gain_pit, pitch_0_6) < 0) + if (LT_16(gain_pit, pitch_0_6)) { state = 0; move16(); @@ -505,7 +504,7 @@ static void phase_dispersion_fx( prev_gain_pit[0] = gain_pit; move16(); - IF (L_sub(L_sub(gain_code, *prev_gain_code), L_shl(*prev_gain_code, 1)) > 0) + IF (GT_32(L_sub(gain_code, *prev_gain_code), L_shl(*prev_gain_code, 1))) { state = s_min(add(state, 1), 2); } @@ -519,13 +518,13 @@ static void phase_dispersion_fx( j = sub(j, shr(sub(prev_gain_pit[i], pitch_0_6), 15)); } - if (sub(j, 2) > 0) + if (GT_16(j, 2)) { state = 0; move16(); } - if (sub(sub(state, *prev_state), 1) > 0) + if (GT_16(sub(state, *prev_state), 1)) { state = sub(state, 1); } @@ -542,7 +541,7 @@ static void phase_dispersion_fx( state = add(state, mode); /* level of dispersion */ - IF (sub(state, 2) < 0) + IF (LT_16(state, 2)) { r_fft_fx_lc(phs_tbl_dec, SIZE, SIZE2, NUM_STAGES, code, code2, 1); diff --git a/lib_com/enr_1_az_fx.c b/lib_com/enr_1_az_fx.c index 1a3e98e532c034509621e5c65b164151635a5bf7..9aa68151e8b4acaa0202a75fa6553d5794a0b76a 100644 --- a/lib_com/enr_1_az_fx.c +++ b/lib_com/enr_1_az_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "cnst_fx.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*-------------------------------------------------------------------* * Enr_1_Az_fx_12Q3() diff --git a/lib_com/env_adj_fx.c b/lib_com/env_adj_fx.c index 6449912c6041887ccb6c0e12e45378bb8e3e2912..d3d91805b6d66998e7440c9914292ad4cbc55ba4 100644 --- a/lib_com/env_adj_fx.c +++ b/lib_com/env_adj_fx.c @@ -1,14 +1,12 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "cnst_fx.h" /* Common constants */ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ -#include "stl.h" -#include "wmc_auto.h" - /* required by wmc_tool */ +#include "stl.h" /* required by wmc_tool */ /*--------------------------------------------------------------------------* * env_adj() @@ -47,13 +45,13 @@ void env_adj_fx npul = pulses[i]; move16(); - IF( sub(length, L_FRAME32k) == 0 ) + IF( EQ_16(length, L_FRAME32k)) { IF( npul == 0 ) { /* Noise filled band */ - IF ( sub(group,1) <= 0 ) + IF ( LE_16(group,1)) { test(); test(); @@ -72,7 +70,7 @@ void env_adj_fx adj[i] = 23593; /* Q15, 0.72f */ move16(); } } - ELSE IF ( sub(i,last_sfm) < 0 ) + ELSE IF ( LT_16(i,last_sfm)) { test(); IF ( pulses[i-1] != 0 && pulses[i+1] != 0 ) @@ -103,7 +101,7 @@ void env_adj_fx ELSE { adj[i] = MAX_16; /* Q15, 1.0f (saturated) */ - IF( sub(att_state, 1) == 0 ) /* End of attenuation region found */ + IF( EQ_16(att_state, 1)) /* End of attenuation region found */ { /* tmp = min(1, max(0, len-ENV_ADJ_START)*(1.0f/ENV_ADJ_INCL)); */ tmp = round_fx(L_shl(L_mult0(s_max( 0, sub(len, ENV_ADJ_START_FX)), ENV_ADJ_INV_INCL_FX),16)); /* Q15 (15+16-16) */ @@ -128,11 +126,11 @@ void env_adj_fx gain_adj = 32767; /* Q15, 1.0f (saturated) */ move16(); test(); - IF( npul > 0 && sub(npul, MAX_P_ATT) < 0 ) + IF( npul > 0 && LT_16(npul, MAX_P_ATT)) { /*idx = (short)(npul * att_step[group] + 0.5f) - 1; */ idx = sub(mult_r(shl(npul,2),att_step_fx[group]), 1); /* Q0 (2+13+1-16) */ - if( sub(idx, MAX_P_ATT) < 0 ) + if( LT_16(idx, MAX_P_ATT)) { gain_adj = gain_att_fx[idx]; /* Q15 */ move16(); } @@ -143,7 +141,7 @@ void env_adj_fx } /* Check if the sequence ended with an attenuation region */ - IF( sub(att_state, 1) == 0 ) + IF( EQ_16(att_state, 1)) { /* tmp = min(1, max(0, len-ENV_ADJ_START)*(1.0f/ENV_ADJ_INCL)); */ tmp = round_fx(L_shl(L_mult0(s_max( 0, sub(len, ENV_ADJ_START_FX)), ENV_ADJ_INV_INCL_FX),16)); /* Q15 (15+16-16) */ diff --git a/lib_com/env_stab_fx.c b/lib_com/env_stab_fx.c index 33444430d1633d7c0097f76ae65291bc02212395..28dcac1dc490b17b1f7c66cbf67d20d1f30794c0 100644 --- a/lib_com/env_stab_fx.c +++ b/lib_com/env_stab_fx.c @@ -1,14 +1,12 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "cnst_fx.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #include "rom_com_fx.h" /* Static table prototypes */ -#include "stl.h" -#include "wmc_auto.h" - /* required by wmc_tool */ +#include "stl.h" /* required by wmc_tool */ /*--------------------------------------------------------------------------* * Local constants @@ -59,7 +57,7 @@ Word16 env_stability_fx( /* in Q15 */ L_tmp = Sqrt_l(L_env_delta, &exp2); /* exp+4+31+exp2 */ exp = add(35, add(exp, exp2)); - if ( sub(s_and(exp, 1), 1) == 0 ) + if ( EQ_16(s_and(exp, 1), 1)) { L_tmp = Mult_32_16(L_tmp, 23170); /* 1/sqrt(2) in Q15 */ } @@ -107,7 +105,7 @@ Word16 env_stability_fx( /* in Q15 */ env_stab = stab_trans_fx[i]; move16(); - if(sub(env_delta, M_STAB_TBL_FX) < 0) + if(LT_16(env_delta, M_STAB_TBL_FX)) { env_stab = sub(0x7FFF,stab_trans_fx[i]); } @@ -174,7 +172,7 @@ Word16 env_stab_smo_fx( /* Q0 */ /* apply some hangover for speech */ test(); - if (state == 0 && sub(prev_state, 1) == 0) + if (state == 0 && EQ_16(prev_state, 1)) { *ho_cnt = ENV_STAB_SMO_HO; move16(); diff --git a/lib_com/env_stab_trans_fx.c b/lib_com/env_stab_trans_fx.c index 9a24a75334d9e607c6dd7d0ffd9625d878a5dfe5..b4fee8d169fae12d5320c299cc10a980ee7c5f44 100644 --- a/lib_com/env_stab_trans_fx.c +++ b/lib_com/env_stab_trans_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -7,9 +7,7 @@ #include "prot_fx.h" /* Function prototypes */ #include "rom_com_fx.h" /* Static table prototypes */ #include "math_op.h" /* WMOPS macros */ -#include "stl.h" -#include "wmc_auto.h" - /* required by wmc_tool */ +#include "stl.h" /* required by wmc_tool */ /*--------------------------------------------------------------------------* * env_stab_transient_detect() @@ -43,7 +41,7 @@ void env_stab_transient_detect_fx( temp = 32; move16(); - IF( sub(HQ_mode,HQ_HVQ) == 0 ) + IF( EQ_16(HQ_mode,HQ_HVQ)) { FOR (i = 0; i < bin_th; i++) /* find adaptive shift */ { @@ -58,7 +56,7 @@ void env_stab_transient_detect_fx( bin_th_1 = INV_HVQ_THRES_BIN_24k; move16(); - if (sub(bin_th, HVQ_THRES_BIN_32k) == 0) + if (EQ_16(bin_th, HVQ_THRES_BIN_32k)) { bin_th_1 = INV_HVQ_THRES_BIN_32k; move16(); @@ -67,7 +65,7 @@ void env_stab_transient_detect_fx( L_e_frame = Sqrt_l(L_temp,&sqrt_exp); L_e_frame = L_shr(L_e_frame, add(sub(add(sh,Qcoeff),10),shr(sqrt_exp,1))); /* Adjust by (Qcoeff+sh-10) to fixed Q13: Qcoeff+sh+(-25+31)/2 - (Qcoeff+sh-10) -> Q13 */ - IF ( L_sub(L_e_frame, ENERGY_TH_FX) > 0 ) + IF ( GT_32(L_e_frame, ENERGY_TH_FX)) { L_energy_lt_local = Mult_32_16(*L_energy_lt, ENERGY_LT_BETA_FX); L_temp = Mult_32_16(L_e_frame, ENERGY_LT_BETA_1_FX); @@ -86,7 +84,7 @@ void env_stab_transient_detect_fx( L_e_frame = L_deposit_l(0); test(); - IF (is_transient && sub(length,L_FRAME32k) == 0) + IF (is_transient && EQ_16(length,L_FRAME32k)) { /* Measure subframe energies */ FOR (blk = 0; blk < NUM_SUBFRAMES; blk++) @@ -109,14 +107,15 @@ void env_stab_transient_detect_fx( /* Test for transient */ /* if (e_frame > ENERGY_TH * NUM_SUBFRAMES) */ - IF (L_sub(L_e_frame, ENERGY_TH_NUM_SUBFRAMES) > 0) + IF (GT_32(L_e_frame, ENERGY_TH_NUM_SUBFRAMES)) { FOR (blk = 0; blk < NUM_SUBFRAMES-1; blk++) { L_delta_e_sub = L_sub(L_E_sub[blk+1],L_E_sub[blk]); /* Q12 */ - if (L_sub(L_delta_e_sub,L_d_max)>0) + if (GT_32(L_delta_e_sub,L_d_max)) { - L_d_max = L_add(L_delta_e_sub,0); /* L_d_max is NOT normalized with *energy_lt */ + L_d_max = L_delta_e_sub; /* L_d_max is NOT normalized with *energy_lt */ + move32(); } } } @@ -133,7 +132,7 @@ void env_stab_transient_detect_fx( L_e_frame = Mult_32_16(L_e_frame, INV_SFM_N_ENV_STAB); /* Q(9+19-15) -> Q13 */ - IF ( L_sub(L_e_frame, ENERGY_TH_FX) > 0 ) + IF ( GT_32(L_e_frame, ENERGY_TH_FX)) { L_energy_lt_local = Mult_32_16(*L_energy_lt, ENERGY_LT_BETA_FX); L_temp = Mult_32_16(L_e_frame, ENERGY_LT_BETA_1_FX); @@ -145,7 +144,7 @@ void env_stab_transient_detect_fx( /* Add hang-over for conservative application of stability dependent attenuation */ /* -> Note: L_d_max not normalized with *energy_lt */ /* Hence, we compare L_d_max/DELTA_TH with *energy_lt */ - IF (L_sub(Mult_32_16(L_d_max, INV_DELTA_TH),L_energy_lt_local) > 0) /* Q13 = Q(12 + 16 -15) */ + IF (GT_32(Mult_32_16(L_d_max, INV_DELTA_TH),L_energy_lt_local)) /* Q13 = Q(12 + 16 -15) */ { *no_att_hangover = ATT_LIM_HANGOVER; move16(); diff --git a/lib_com/est_tilt_fx.c b/lib_com/est_tilt_fx.c index 1112e435f686941e435894796514f3c38aef9ce3..83059dab83ad01d82953ab31579b788cabb88550 100644 --- a/lib_com/est_tilt_fx.c +++ b/lib_com/est_tilt_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "cnst_fx.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - #include "basop_mpy.h" #include "basop_util.h" @@ -66,10 +64,10 @@ Word16 est_tilt_fx( /* o : tilt of the code Q15 exp2 = sub(exp2, add(exp, exp)); i = sub(exp1, exp2); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF ener1 = shr(ener1, sub(1, s_min(i, 0))); ener2 = shr(ener2, add(s_max(0, i), 1)); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON tmp = sub(ener1, ener2); ener1 = add(add(ener1, ener2), 1); @@ -168,29 +166,33 @@ void E_UTIL_voice_factor( Word16 *exc, /* i : pointer to the excitatio { Word16 i, e, e2, stmp, exp_ener, fac; Word32 ener, tmp, num; + Word64 ener_64; BASOP_SATURATE_ERROR_ON; + - IF(shift != 0) - { - fac = shl(0x4000,add(1,shift)); - /* energy of pitch excitation */ - stmp = mult_r(exc[0+i_subfr], fac); /* remove fac bits */ - ener = L_mac0(0L,stmp, stmp); - FOR (i=1; i exponent = (15-Q_new)*2+1 */ + ener_64 = W_mult0_16_16(exc[0+i_subfr], exc[0+i_subfr]); + FOR (i=1; i exponent = (15-Q_new)*2+1 */ + } } - } + ener = W_sat_l( ener_64 ); + /* exponent of ener: (2*(15-Q_new+shift)+1+2-exp_ener-2*e2) */ exp_ener = norm_l(ener); @@ -228,9 +230,9 @@ void E_UTIL_voice_factor( Word16 *exc, /* i : pointer to the excitatio ELSE { tmp = L_shr(tmp,1); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF ener = L_shr(ener, sub(1,i)); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON } *voice_fac = 0; @@ -238,10 +240,10 @@ void E_UTIL_voice_factor( Word16 *exc, /* i : pointer to the excitatio num = L_sub(ener, tmp); IF(num != 0) { - BASOP_SATURATE_WARNING_OFF;/* Allow saturating the voice factor because if has a limited range by definition. */ + BASOP_SATURATE_WARNING_OFF /* Allow saturating the voice factor because if has a limited range by definition. */ *voice_fac = divide3232(num, L_add(ener, tmp)); move16(); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON } /* find tilt of code for next subframe */ diff --git a/lib_com/fd_cng_com.c b/lib_com/fd_cng_com.c index 8278555d22037e2e8dcc0ee2c259375f699fd614..0a6f8c83d7eb517417c707559ce61290e7115632 100644 --- a/lib_com/fd_cng_com.c +++ b/lib_com/fd_cng_com.c @@ -1,16 +1,12 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include #include "stl.h" -#include "wmc_auto.h" - #include "basop_util.h" #include "options.h" #include "stl.h" -#include "wmc_auto.h" - #include "rom_basop_util.h" #include "rom_com_fx.h" #include "prot_fx.h" @@ -168,7 +164,7 @@ void initPartitions( const Word16* part_in, { len_out = 0; move16(); - IF (sub(stopBandFR, startBand) > 0) + IF (GT_16(stopBandFR, startBand)) { len_out = sub(stopBandFR, startBand); FOR(i = 0 ; i < len_out; i++) @@ -179,13 +175,13 @@ void initPartitions( const Word16* part_in, } FOR(j=0 ; j < npart_in; j++) { - IF (sub(part_in[j], stopBand) >= 0) + IF (GE_16(part_in[j], stopBand)) { BREAK; } tmp16 = sub(part_in[j],startBand); test(); - if (sub(part_in[j],stopBandFR) >= 0 && tmp16 >= 0) + if (GE_16(part_in[j],stopBandFR)&&tmp16>=0) { part_out[len_out++] = tmp16; move16(); @@ -409,7 +405,7 @@ void minimum_statistics ( msPeriodogSum = st->msPeriodogSum; /* No minimum statistics at initialization */ - IF ( sub(st->msFrCnt_init_counter,st->msFrCnt_init_thresh) < 0 ) + IF ( LT_16(st->msFrCnt_init_counter,st->msFrCnt_init_thresh)) { Copy(msPeriodog, msPsd, len); /* 6Q9 */ Copy(msPeriodog, msNoiseFloor, len); /* 6Q9 */ @@ -421,7 +417,7 @@ void minimum_statistics ( move32(); msPsdSum[0] = msPeriodogSum[0]; /* 16Q15 */ move32(); - IF ( sub(lenFFT,len) < 0 ) + IF ( LT_16(lenFFT,len)) { msPeriodogSum[1] = dotp_s_fx(msPeriodog+lenFFT, psize+lenFFT, sub(len,lenFFT), CNG_HS); move32(); @@ -430,7 +426,7 @@ void minimum_statistics ( /* Increment frame counter at initialization */ /* Some frames are sometimes zero at initialization => ignore them */ - IF ( sub(msPeriodog[0],st->init_old) < 0 ) + IF ( LT_16(msPeriodog[0],st->init_old)) { set32_fx(msCurrentMinOut, 2147483647l/*1.0 Q31*/, len); /* 16Q15 */ set32_fx(msCurrentMin, 2147483647l/*1.0 Q31*/, len); /* 16Q15 */ @@ -454,7 +450,7 @@ void minimum_statistics ( stop = lenFFT; move16(); totsize = sub(st->stopFFTbin,st->startBand); - WHILE ( sub(stop,start) > 0 ) + WHILE ( GT_16(stop,start)) { current_len = sub(stop,start); @@ -524,7 +520,7 @@ void minimum_statistics ( /* msPeriodogSum[cnt] with format 16Q15 */ snr = dotp_s_fx(msNoiseFloor+start, psize+start, current_len, CNG_HS); - IF ( L_sub(L_shr(Mpy_32_16_1(msPsdSum[cnt],18431/*0.56246299817 Q15*/),13),snr) > 0 ) + IF ( GT_32(L_shr(Mpy_32_16_1(msPsdSum[cnt],18431/*0.56246299817 Q15*/),13),snr)) { tmp0 = BASOP_Util_Log2(msPsdSum[cnt]); tmp1 = BASOP_Util_Log2(snr); @@ -715,7 +711,7 @@ void minimum_statistics ( msNewMinFlag[j] = 0; move16(); - IF ( L_sub(scalar2,msCurrentMin[j]) < 0l/*0.0 Q31*/ ) + IF ( LT_32(scalar2,msCurrentMin[j])/*0.0 Q31*/) { msNewMinFlag[j] = 1; move16(); @@ -731,11 +727,11 @@ void minimum_statistics ( } /* This is used later to identify local minima */ - IF ( sub(st->msFrCnt,MSSUBFRLEN) >= 0 ) + IF ( GE_16(st->msFrCnt,MSSUBFRLEN)) { FOR ( i = 0; i < 3; i++ ) { - IF ( L_sub(st->msQeqInvAv[cnt],L_shr(L_deposit_h(msQeqInvAv_thresh[i]),CNG_S)) < 0l/*0.0 Q31*/ ) + IF ( LT_32(st->msQeqInvAv[cnt],L_shr(L_deposit_h(msQeqInvAv_thresh[i]),CNG_S))/*0.0 Q31*/) { BREAK; } @@ -756,7 +752,7 @@ void minimum_statistics ( /* Update minimum between sub windows */ test(); - IF ( sub(st->msFrCnt,1) > 0 && sub(st->msFrCnt,MSSUBFRLEN) < 0 ) + IF ( GT_16(st->msFrCnt,1)&<_16(st->msFrCnt,MSSUBFRLEN)) { FOR (j=0; jmsFrCnt,MSSUBFRLEN) >= 0 ) + IF ( GE_16(st->msFrCnt,MSSUBFRLEN)) { /* Collect buffers */ Copy32(msCurrentMinSubWindow, msMinBuf+len*st->msMinBufferPtr, len); @@ -789,7 +785,7 @@ void minimum_statistics ( { FOR (j=0; jmsSlope[1]; move16(); @@ -813,8 +809,8 @@ void minimum_statistics ( test(); IF ( ( msLocalMinFlag[j] != 0 ) && ( msNewMinFlag[j] == 0 ) - && ( L_sub(L_shr(msCurrentMinSubWindow[j],1),Mpy_32_16_1(msCurrentMinOut[j],slope)) < 0l/*0.0 Q31*/ ) - && ( L_sub(msCurrentMinSubWindow[j],msCurrentMinOut[j]) > 0l/*0.0 Q31*/ ) + && ( LT_32(L_shr(msCurrentMinSubWindow[j],1),Mpy_32_16_1(msCurrentMinOut[j],slope)) /*0.0 Q31*/ ) + && ( GT_32(msCurrentMinSubWindow[j],msCurrentMinOut[j]) /*0.0 Q31*/ ) ) { msCurrentMinOut[j] = msCurrentMinSubWindow[j]; @@ -841,7 +837,7 @@ void minimum_statistics ( /* Detect sudden offsets based on the FFT bins (core bandwidth) */ - IF ( L_sub(Mpy_32_16_1(msPsdSum[0],655/*0.02 Q15*/), msPeriodogSum[0]) > 0l/*0.0 Q31*/ ) + IF ( GT_32(Mpy_32_16_1(msPsdSum[0],655/*0.02 Q15*/), msPeriodogSum[0])/*0.0 Q31*/) { IF ( st->offsetflag > 0 ) { @@ -857,7 +853,7 @@ void minimum_statistics ( msPsdSum[0] = dotp_s_fx(msPeriodog, psize, lenFFT, CNG_HS); move32(); - IF ( sub(lenFFT,len) < 0 ) + IF ( LT_16(lenFFT,len)) { msPsdSum[1] = dotp_s_fx(msPeriodog+lenFFT, psize+lenFFT, sub(len,lenFFT), CNG_HS); move32(); @@ -874,13 +870,13 @@ void minimum_statistics ( /* Increment frame counter */ - IF ( sub(st->msFrCnt,MSSUBFRLEN) == 0) + IF ( EQ_16(st->msFrCnt,MSSUBFRLEN)) { st->msFrCnt = 1; move16(); st->msMinBufferPtr = add(st->msMinBufferPtr,1); move16(); - if ( sub(st->msMinBufferPtr,MSNUMSUBFR) == 0 ) + if ( EQ_16(st->msMinBufferPtr,MSNUMSUBFR)) { st->msMinBufferPtr = 0; move16(); @@ -903,7 +899,7 @@ void minimum_statistics ( *msPeriodogBufPtr = add(*msPeriodogBufPtr,1); move16(); - if ( sub(*msPeriodogBufPtr,MSBUFLEN) == 0 ) + if ( EQ_16(*msPeriodogBufPtr,MSBUFLEN)) { (*msPeriodogBufPtr) = 0; move16(); @@ -919,7 +915,7 @@ void minimum_statistics ( scalar = L_mac(scalar, msPeriodogBuf[i], 6554/*1.0/MSBUFLEN Q15*/); } scalar16 = round_fx(scalar); - if ( sub(msNoiseEst[j],scalar16) > 0/*0.0 Q15*/ ) + if ( GT_16(msNoiseEst[j],scalar16)/*0.0 Q15*/) { msNoiseEst[j] = scalar16; move16(); @@ -944,7 +940,7 @@ void apply_scale(Word32 *scale, Word16 bwmode, Word32 bitrate) FOR (i=0; i < scaleTableSize; i++) { cast16(); - IF ( s_and( sub(bwmode, (Word16)scaleTable[i].bwmode) == 0, + IF ( s_and( (Word16)EQ_16(bwmode, (Word16)scaleTable[i].bwmode), s_and( L_sub(bitrate,scaleTable[i].bitrateFrom) >= 0, L_sub(bitrate,scaleTable[i].bitrateTo) < 0)) ) @@ -980,7 +976,7 @@ void bandcombinepow(Word32* bandpow, /* i : Power for - IF (sub(nband, npart) == 0) + IF (EQ_16(nband, npart)) { Copy32(bandpow, partpow, nband); smin = 0; @@ -1012,7 +1008,8 @@ void bandcombinepow(Word32* bandpow, /* i : Power for FOR (p = 0; p < npart; p++) { /* Arithmetic averaging of power for all bins in partition */ - temp = L_add(0,0); + temp = 0; + move32(); FOR ( ; i <= part[p]; i++) { temp = L_add(temp, Mpy_32_16_1(L_shl(bandpow[i],facTabExp[p]),psize_inv[p])); @@ -1054,7 +1051,7 @@ void scalebands (Word32 *partpow, /* i : Power for each partition */ partpowLD64M1 = 0L; /* to avoid compilation warnings */ /* Interpolate the bin/band-wise levels from the partition levels */ - IF ( sub(nband, npart) == 0 ) + IF ( EQ_16(nband, npart)) { Copy32(partpow, bandpow, npart); } @@ -1067,11 +1064,11 @@ void scalebands (Word32 *partpow, /* i : Power for each partition */ stopPart = nFFTpart; move16(); - WHILE ( sub(startBand,nband) < 0 ) + WHILE ( LT_16(startBand,nband)) { stopPartM1 = sub(stopPart, 1); test(); - IF ( (flag_fft_en != 0) || (sub(startPart,nFFTpart) >= 0) ) + IF ( (flag_fft_en != 0) || (GE_16(startPart,nFFTpart))) { /* first half partition */ j = startPart; @@ -1138,10 +1135,11 @@ void scalebands (Word32 *partpow, /* i : Power for each partition */ } bandpow[i++] = partpow[j]; move32(); - partpowLD64M1 = L_add(0,partpowLD64); + partpowLD64M1 = partpowLD64; + move32(); } - IF ( sub(shr(delta, s), delta_cmp) > 0 ) + IF ( GT_16(shr(delta, s), delta_cmp)) { delta = 0x4000; move16(); @@ -1150,7 +1148,8 @@ void scalebands (Word32 *partpow, /* i : Power for each partition */ } /* last half partition */ - val = L_add(0,partpow[stopPartM1]); + val = partpow[stopPartM1]; + move32(); FOR ( ; i <= part[stopPartM1]; i++) { val = L_shl(Mpy_32_16_1(val,delta), s1); @@ -1201,7 +1200,7 @@ void getmidbands(Word16* part, /* i : Partition upper boundaries ( move16(); psize_inv[j] = getNormReciprocalWord16(psize[j]); move16(); - if(sub(psize[j], max_psize) > 0) + if(GT_16(psize[j], max_psize)) { max_psize = psize[j]; move16(); @@ -1390,7 +1389,7 @@ SynthesisSTFT (Word32 *fftBuffer, /* i : pointer to FFT bins */ } /* Generate excitation */ - IF ( sub( gen_exc, 1 ) == 0 ) + IF ( EQ_16( gen_exc, 1 )) { FOR (i=0; i < M+1+st->frameSize; i++) { @@ -1401,7 +1400,7 @@ SynthesisSTFT (Word32 *fftBuffer, /* i : pointer to FFT bins */ E_UTIL_f_preemph2( *Q_new-1, buf+1, PREEMPH_FAC, M+st->frameSize, &tmp ); Residu3_fx( st->A_cng, buf+1+M, st->exc_cng, st->frameSize, 1 ); } - IF ( sub( gen_exc, 2 ) == 0 ) + IF ( EQ_16( gen_exc, 2 )) { FOR (i=0; i < M+1+st->frameSize; i++) { @@ -1432,12 +1431,12 @@ void mhvals(Word16 d, move16(); FOR (i=0 ; i < len ; i++) { - IF (sub(d,d_array[i]) <= 0) + IF (LE_16(d,d_array[i])) { BREAK; } } - IF (sub(i, len) == 0) + IF (EQ_16(i, len)) { i = sub(len, 1); j = i; @@ -1447,7 +1446,7 @@ void mhvals(Word16 d, { j = sub(i, 1); } - IF (sub(d, d_array[i]) == 0) + IF (EQ_16(d, d_array[i])) { *m = m_array[i]; move16(); @@ -1578,7 +1577,8 @@ void lpc_from_spectrum (Word32 *powspec, fftlen8 = shr(fftlen,3); /* Power Spectrum */ - maxVal = L_add(0,0); + maxVal = 0; + move32(); len = sub(stop, start); FOR (i=0; i < len; i++) { @@ -1664,7 +1664,8 @@ void lpc_from_spectrum (Word32 *powspec, } move32(); fftBuffer[1] = Mpy_32_16_1( fftBuffer[1], add( tmp, preemph_fac2 ) ); - maxVal = L_add(0,0); + maxVal = 0; + move32(); FOR (i=0; i < fftlen; i++) { maxVal = L_max(maxVal, L_abs(fftBuffer[i])); @@ -1802,7 +1803,7 @@ void FdCng_exc( move16(); /* Q15 (15+15+1-16) */ } - IF(sub(L_frame, L_FRAME16k)== 0) + IF(EQ_16(L_frame, L_FRAME16k)) { lsp2lsf_fx( lsp_new, lsf_new, M, INT_FS_16k_FX ); } @@ -1813,7 +1814,7 @@ void FdCng_exc( Copy( hs->exc_cng, exc, L_frame ); Copy( hs->exc_cng, exc2, L_frame ); - IF( sub(L_frame,L_FRAME) == 0 ) + IF( EQ_16(L_frame,L_FRAME)) { interp_code_5over2_fx( exc2, bwe_exc, L_frame ); } diff --git a/lib_com/fft.c b/lib_com/fft.c index 89eaa49f7f9fc1c226533eb392a377dd859d9194..7bce530755f2f68a30fdb051be31d6cb7ff7258d 100644 --- a/lib_com/fft.c +++ b/lib_com/fft.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -8,9 +8,8 @@ #include "rom_basop_util.h" #include "options.h" #include "stl.h" -#include "wmc_auto.h" - +void fft16_with_cmplx_data( cmplx *pInp, Word16 bsacle); /** * \brief Profiling / Precision results @@ -76,76 +75,12 @@ #define C166 (FFTC(0xcf043ab3)) /* FL2WORD32(-3.826834323650898e-1) -COS_3PI_DIV8 */ - -#define cplxMpy3_0(a,b,c,d) as = L_shr(a,1); \ - bs = L_shr(b,1); \ - a = L_sub(Mpy_32_xx(as,c),Mpy_32_xx(bs,d)); \ - b = L_add(Mpy_32_xx(as,d),Mpy_32_xx(bs,c)); - - -#define cplxMpy4_4_0(re,im,a,b,c,d) re = L_shr(L_sub(Mpy_32_xx(a,c),Mpy_32_xx(b,d)),SCALEFACTOR60-SCALEFACTOR15); \ - im = L_shr(L_add(Mpy_32_xx(a,d),Mpy_32_xx(b,c)),SCALEFACTOR60-SCALEFACTOR15); - -#define cplxMpy4_4_1(re,im,a,b) re = L_shr(a,SCALEFACTOR60-SCALEFACTOR15); \ - im = L_shr(b,SCALEFACTOR60-SCALEFACTOR15); - #define cplxMpy4_8_0(re,im,a,b,c,d) re = L_shr(L_sub(Mpy_32_xx(a,c),Mpy_32_xx(b,d)),1); \ im = L_shr(L_add(Mpy_32_xx(a,d),Mpy_32_xx(b,c)),1); #define cplxMpy4_8_1(re,im,a,b) re = L_shr(a,1); \ im = L_shr(b,1); -/* -re = a*c - b*d -im = a*d + b*c -*/ -#if (SCALEFACTOR20 == SCALEFACTOR10) -#define cplxMpy4_10_0(re,im,a,b,c,d) re = L_sub(Mpy_32_xx(a,c),Mpy_32_xx(b,d)); move32(); \ - im = L_add(Mpy_32_xx(a,d),Mpy_32_xx(b,c)); move32(); - -#define cplxMpy4_10_1(re,im,a,b) re = (a); move32(); \ - im = (b); move32(); -#else -#define cplxMpy4_10_0(re,im,a,b,c,d) re = L_shr(L_sub(Mpy_32_xx(a,c),Mpy_32_xx(b,d)),SCALEFACTOR20-SCALEFACTOR10); move32(); \ - im = L_shr(L_add(Mpy_32_xx(a,d),Mpy_32_xx(b,c)),SCALEFACTOR20-SCALEFACTOR10); move32(); - -#define cplxMpy4_10_1(re,im,a,b) re = L_shr(a,SCALEFACTOR20-SCALEFACTOR10); move32(); \ - im = L_shr(b,SCALEFACTOR20-SCALEFACTOR10); move32(); -#endif - - -#if (SCALEFACTOR20 == SCALEFACTOR30) -#define cplxMpy4_20_30_0(re,im,a,b,c,d) re = L_sub(Mpy_32_xx(a,c),Mpy_32_xx(b,d)); move32(); \ - im = L_add(Mpy_32_xx(a,d),Mpy_32_xx(b,c)); move32(); - -#define cplxMpy4_20_30_1(re,im,a,b) re = (a); move32(); \ - im = (b); move32(); -#else -#define cplxMpy4_20_30_0(re,im,a,b,c,d) re = L_shr(L_sub(Mpy_32_xx(a,c),Mpy_32_xx(b,d)),SCALEFACTOR20-SCALEFACTOR30); move32(); \ - im = L_shr(L_add(Mpy_32_xx(a,d),Mpy_32_xx(b,c)),SCALEFACTOR20-SCALEFACTOR30); move32(); - -#define cplxMpy4_20_30_1(re,im,a,b) re = L_shr(a,SCALEFACTOR20-SCALEFACTOR30); move32(); \ - im = L_shr(b,SCALEFACTOR20-SCALEFACTOR30); move32(); -#endif - - -#define cplxMpy4_12_0(re,im,a,b,c,d) re = L_shr(L_sub(Mpy_32_xx(a,c),Mpy_32_xx(b,d)),SCALEFACTOR16-SCALEFACTOR12); move32(); \ - im = L_shr(L_add(Mpy_32_xx(a,d),Mpy_32_xx(b,c)),SCALEFACTOR16-SCALEFACTOR12); move32(); -#define cplxMpy4_12_1(re,im,a,b) re = L_shr(a,SCALEFACTOR16-SCALEFACTOR12); move32(); \ - im = L_shr(b,SCALEFACTOR16-SCALEFACTOR12); move32(); - -#define cplxMpy4_16_0(re,im,a,b,c,d) re = L_shr(L_sub(Mpy_32_xx(a,c),Mpy_32_xx(b,d)),SCALEFACTOR16); move32(); \ - im = L_shr(L_add(Mpy_32_xx(a,d),Mpy_32_xx(b,c)),SCALEFACTOR16); move32(); - -#define cplxMpy4_16_1(re,im,a,b) re = L_shr(a,SCALEFACTOR16); move32(); \ - im = L_shr(b,SCALEFACTOR16); move32(); - - -#define cplxMpy4_5_0(re,im,a,b,c,d) re = L_shr(L_sub(Mpy_32_xx(a,c),Mpy_32_xx(b,d)),SCALEFACTORN2); \ - im = L_shr(L_add(Mpy_32_xx(a,d),Mpy_32_xx(b,c)),SCALEFACTORN2); - -#define cplxMpy4_5_1(re,im,a,b) re = L_shr(a,SCALEFACTORN2); \ - im = L_shr(b,SCALEFACTORN2); @@ -162,90 +97,51 @@ im = a*d + b*c * * \return void */ -static void fft5(Word32 *re, Word32 *im, Word16 s) +static void fft5_with_cmplx_data(cmplx *inp) { - Word32 x0,x1,x2,x3,x4; - Word32 r1,r2,r3,r4; - Word32 s1,s2,s3,s4; - Word32 t; - - - /* */ + cmplx x0,x1,x2,x3,x4; + cmplx y1,y2,y3,y4; + cmplx t; + + x0 = CL_shr(inp[0],SCALEFACTOR5); + x1 = CL_shr(inp[1],SCALEFACTOR5); + x2 = CL_shr(inp[2],SCALEFACTOR5); + x3 = CL_shr(inp[3],SCALEFACTOR5); + x4 = CL_shr(inp[4],SCALEFACTOR5); + + y1 = CL_add(x1,x4); + y4 = CL_sub(x1,x4); + y3 = CL_add(x2,x3); + y2 = CL_sub(x2,x3); + t = CL_scale_t(CL_sub(y1,y3),C54); + y1 = CL_add(y1,y3); + inp[0] = CL_add(x0,y1); - /* real part */ - x0 = L_shr(re[s*0],SCALEFACTOR5); - x1 = L_shr(re[s*1],SCALEFACTOR5); - x2 = L_shr(re[s*2],SCALEFACTOR5); - x3 = L_shr(re[s*3],SCALEFACTOR5); - x4 = L_shr(re[s*4],SCALEFACTOR5); - - r1 = L_add(x1,x4); - r4 = L_sub(x1,x4); - r3 = L_add(x2,x3); - r2 = L_sub(x2,x3); - t = Mpy_32_xx(L_sub(r1,r3),C54); - r1 = L_add(r1,r3); - re[0] = L_add(x0,r1); - move32(); - /* Bit shift left because of the constant C55 which was scaled with the factor 0.5 because of the representation of - the values as fracts */ - r1 = L_add(re[0],(L_shl(Mpy_32_xx(r1,C55),1))); - r3 = L_sub(r1,t); - r1 = L_add(r1,t); - t = Mpy_32_xx(L_add(r4,r2),C51); - /* Bit shift left because of the constant C55 which was scaled with the factor 0.5 because of the representation of - the values as fracts */ - r4 = L_add(t,L_shl(Mpy_32_xx(r4, C52),1)); - r2 = L_add(t,Mpy_32_xx(r2,C53)); - - /* imaginary part */ - x0 = L_shr(im[s*0],SCALEFACTOR5); - x1 = L_shr(im[s*1],SCALEFACTOR5); - x2 = L_shr(im[s*2],SCALEFACTOR5); - x3 = L_shr(im[s*3],SCALEFACTOR5); - x4 = L_shr(im[s*4],SCALEFACTOR5); - - s1 = L_add(x1,x4); - s4 = L_sub(x1,x4); - s3 = L_add(x2,x3); - s2 = L_sub(x2,x3); - t = Mpy_32_xx(L_sub(s1,s3),C54); - s1 = L_add(s1,s3); - im[0] = L_add(x0,s1); - move32(); /* Bit shift left because of the constant C55 which was scaled with the factor 0.5 because of the representation of - the values as fracts */ - s1 = L_add(im[0],L_shl(Mpy_32_xx(s1,C55),1)); - s3 = L_sub(s1,t); - s1 = L_add(s1,t); - t = Mpy_32_xx(L_add(s4,s2),C51); + the values as fracts */ + y1 = CL_add(inp[0],(CL_shl(CL_scale_t(y1,C55),1))); + y3 = CL_sub(y1,t); + y1 = CL_add(y1,t); + + t = CL_scale_t(CL_add(y4,y2),C51); /* Bit shift left because of the constant C55 which was scaled with the factor 0.5 because of the representation of - the values as fracts */ - s4 = L_add(t,L_shl(Mpy_32_xx(s4,C52),1)); - s2 = L_add(t,Mpy_32_xx(s2,C53)); + the values as fracts */ + y4 = CL_add(t,CL_shl(CL_scale_t(y4, C52),1)); + y2 = CL_add(t,CL_scale_t(y2,C53)); + /* combination */ - re[s*1] = L_add(r1,s2); - move32(); - re[s*4] = L_sub(r1,s2); - move32(); - re[s*2] = L_sub(r3,s4); - move32(); - re[s*3] = L_add(r3,s4); - move32(); - - im[s*1] = L_sub(s1,r2); - move32(); - im[s*4] = L_add(s1,r2); - move32(); - im[s*2] = L_add(s3,r4); - move32(); - im[s*3] = L_sub(s3,r4); - move32(); - - /* */ -} + inp[1] = CL_msu_j(y1,y2); + inp[4] = CL_mac_j(y1,y2); + inp[2] = CL_mac_j(y3,y4); + inp[3] = CL_msu_j(y3,y4); + +#if (WMOPS) + multiCounter[currCounter].CL_move += 5; +#endif + +} /** * \brief Function performs a complex 8-point FFT @@ -260,112 +156,72 @@ static void fft5(Word32 *re, Word32 *im, Word16 s) * * \return void */ -static void fft8(Word32 *re, Word32 *im, Word16 s) +static void fft8_with_cmplx_data(cmplx *inp) { - Word32 x00,x01,x02,x03,x04,x05,x06,x07; - Word32 x08,x09,x10,x11,x12,x13,x14,x15; - Word32 t00,t01,t02,t03,t04,t05,t06,t07; - Word32 t08,t09,t10,t11,t12,t13,t14,t15; - Word32 s00,s01,s02,s03,s04,s05,s06,s07; - Word32 s08,s09,s10,s11,s12,s13,s14,s15; + cmplx x0, x1, x2, x3, x4, x5, x6, x7; + cmplx s0, s1, s2, s3, s4, s5, s6, s7; + cmplx t0, t1, t2, t3, t4, t5, t6, t7; + /* Pre-additions */ + x0 = CL_shr(inp[0], SCALEFACTOR8); + x1 = CL_shr(inp[1], SCALEFACTOR8); + x2 = CL_shr(inp[2], SCALEFACTOR8); + x3 = CL_shr(inp[3], SCALEFACTOR8); + x4 = CL_shr(inp[4], SCALEFACTOR8); + x5 = CL_shr(inp[5], SCALEFACTOR8); + x6 = CL_shr(inp[6], SCALEFACTOR8); + x7 = CL_shr(inp[7], SCALEFACTOR8); + + /* loops are unrolled */ + { + t0 = CL_add(x0,x4); + t1 = CL_sub(x0,x4); + t2 = CL_add(x1,x5); + t3 = CL_sub(x1,x5); - /* Pre-additions */ + t4 = CL_add(x2,x6); + t5 = CL_sub(x2,x6); - x00 = L_shr(re[s*0],SCALEFACTOR8); - x01 = L_shr(im[s*0],SCALEFACTOR8); - x02 = L_shr(re[s*1],SCALEFACTOR8); - x03 = L_shr(im[s*1],SCALEFACTOR8); - x04 = L_shr(re[s*2],SCALEFACTOR8); - x05 = L_shr(im[s*2],SCALEFACTOR8); - x06 = L_shr(re[s*3],SCALEFACTOR8); - x07 = L_shr(im[s*3],SCALEFACTOR8); - x08 = L_shr(re[s*4],SCALEFACTOR8); - x09 = L_shr(im[s*4],SCALEFACTOR8); - x10 = L_shr(re[s*5],SCALEFACTOR8); - x11 = L_shr(im[s*5],SCALEFACTOR8); - x12 = L_shr(re[s*6],SCALEFACTOR8); - x13 = L_shr(im[s*6],SCALEFACTOR8); - x14 = L_shr(re[s*7],SCALEFACTOR8); - x15 = L_shr(im[s*7],SCALEFACTOR8); - - t00 = L_add(x00,x08); - t02 = L_sub(x00,x08); - t01 = L_add(x01,x09); - t03 = L_sub(x01,x09); - t04 = L_add(x02,x10); - t06 = L_sub(x02,x10); - t05 = L_add(x03,x11); - t07 = L_sub(x03,x11); - t08 = L_add(x04,x12); - t10 = L_sub(x04,x12); - t09 = L_add(x05,x13); - t11 = L_sub(x05,x13); - t12 = L_add(x06,x14); - t14 = L_sub(x06,x14); - t13 = L_add(x07,x15); - t15 = L_sub(x07,x15); + t6 = CL_add(x3,x7); + t7 = CL_sub(x3,x7); + } /* Pre-additions and core multiplications */ - s00 = L_add(t00,t08); - s04 = L_sub(t00,t08); - s01 = L_add(t01,t09); - s05 = L_sub(t01,t09); - s08 = L_sub(t02,t11); - s10 = L_add(t02,t11); - s09 = L_add(t03,t10); - s11 = L_sub(t03,t10); - s02 = L_add(t04,t12); - s07 = L_sub(t04,t12); - s03 = L_add(t05,t13); - s06 = L_sub(t13,t05); - - t01 = L_add(t06,t14); - t02 = L_sub(t06,t14); - t00 = L_add(t07,t15); - t03 = L_sub(t07,t15); - - s12 = Mpy_32_xx(L_add(t00,t02),C81); - s14 = Mpy_32_xx(L_sub(t00,t02),C81); - s13 = Mpy_32_xx(L_sub(t03,t01),C81); - s15 = Mpy_32_xx(L_add(t01,t03),C82); + s0 = CL_add(t0, t4); + s2 = CL_sub(t0, t4); + + s4 = CL_mac_j(t1, t5); + s5 = CL_msu_j(t1, t5); + + s1 = CL_add(t2, t6); + s3 = CL_sub(t2, t6); + s3 = CL_mul_j(s3); + + t0 = CL_add(t3, t7); + t1 = CL_sub(t3, t7); + + s6 = CL_scale_t(CL_msu_j(t1, t0), C81); + s7 = CL_dscale_t(CL_swap_real_imag(CL_msu_j(t0, t1)), C81, C82); /* Post-additions */ - re[s*0] = L_add(s00,s02); - move32(); - re[s*4] = L_sub(s00,s02); - move32(); - im[s*0] = L_add(s01,s03); - move32(); - im[s*4] = L_sub(s01,s03); - move32(); - re[s*2] = L_sub(s04,s06); - move32(); - re[s*6] = L_add(s04,s06); - move32(); - im[s*2] = L_sub(s05,s07); - move32(); - im[s*6] = L_add(s05,s07); - move32(); - re[s*3] = L_add(s08,s14); - move32(); - re[s*7] = L_sub(s08,s14); - move32(); - im[s*3] = L_add(s09,s15); - move32(); - im[s*7] = L_sub(s09,s15); - move32(); - re[s*1] = L_add(s10,s12); - move32(); - re[s*5] = L_sub(s10,s12); - move32(); - im[s*1] = L_add(s11,s13); - move32(); - im[s*5] = L_sub(s11,s13); - move32(); + inp[0] = CL_add(s0, s1); + inp[4] = CL_sub(s0, s1); + + inp[2] = CL_sub(s2, s3); + inp[6] = CL_add(s2, s3); + + inp[3] = CL_add(s4, s7); + inp[7] = CL_sub(s4, s7); + + inp[1] = CL_add(s5, s6); + inp[5] = CL_sub(s5, s6); +#if (WMOPS) + multiCounter[currCounter].CL_move += 8; +#endif + } @@ -383,170 +239,99 @@ static void fft8(Word32 *re, Word32 *im, Word16 s) * * \return void */ -static void fft10(Word32 *re, Word32 *im, Word16 s) -{ - Word32 t; - Word32 x0,x1,x2,x3,x4; - Word32 r1,r2,r3,r4; - Word32 s1,s2,s3,s4; - Word32 y00,y01,y02,y03,y04,y05,y06,y07,y08,y09; - Word32 y10,y11,y12,y13,y14,y15,y16,y17,y18,y19; - - - - /* 2 fft5 stages */ - /* real part */ - x0 = L_shr(re[s*0],SCALEFACTOR10); - x1 = L_shr(re[s*2],SCALEFACTOR10); - x2 = L_shr(re[s*4],SCALEFACTOR10); - x3 = L_shr(re[s*6],SCALEFACTOR10); - x4 = L_shr(re[s*8],SCALEFACTOR10); - - r1 = L_add(x3,x2); - r4 = L_sub(x3,x2); - r3 = L_add(x1,x4); - r2 = L_sub(x1,x4); - t = Mpy_32_xx(L_sub(r1,r3),C54); - r1 = L_add(r1,r3); - y00 = L_add(x0,r1); - r1 = L_add(y00,(L_shl(Mpy_32_xx(r1,C55),1))); - r3 = L_sub(r1,t); - r1 = L_add(r1,t); - t = Mpy_32_xx((L_add(r4,r2)),C51); - r4 = L_add(t,L_shl(Mpy_32_xx(r4, C52),1)); - r2 = L_add(t,Mpy_32_xx(r2,C53)); - - /* imaginary part */ - x0 = L_shr(im[s*0],SCALEFACTOR10); - x1 = L_shr(im[s*2],SCALEFACTOR10); - x2 = L_shr(im[s*4],SCALEFACTOR10); - x3 = L_shr(im[s*6],SCALEFACTOR10); - x4 = L_shr(im[s*8],SCALEFACTOR10); - - s1 = L_add(x3,x2); - s4 = L_sub(x3,x2); - s3 = L_add(x1,x4); - s2 = L_sub(x1,x4); - t = Mpy_32_xx(L_sub(s1,s3),C54); - s1 = L_add(s1,s3); - y01 = L_add(x0,s1); - s1 = L_add(y01,L_shl(Mpy_32_xx(s1,C55),1)); - s3 = L_sub(s1,t); - s1 = L_add(s1,t); - t = Mpy_32_xx(L_add(s4,s2),C51); - s4 = L_add(t,L_shl(Mpy_32_xx(s4,C52),1)); - s2 = L_add(t,Mpy_32_xx(s2,C53)); - - /* combination */ - y04 = L_add(r1,s2); - y16 = L_sub(r1,s2); - y08 = L_sub(r3,s4); - y12 = L_add(r3,s4); - - y05 = L_sub(s1,r2); - y17 = L_add(s1,r2); - y09 = L_add(s3,r4); - y13 = L_sub(s3,r4); +static void fft10_with_cmplx_data(cmplx *inp_data) +{ + cmplx r1,r2,r3,r4; + cmplx x0,x1,x2,x3,x4,t; + cmplx y[10]; - /* real part */ - x0 = L_shr(re[s*5],SCALEFACTOR10); - x1 = L_shr(re[s*1],SCALEFACTOR10); - x2 = L_shr(re[s*3],SCALEFACTOR10); - x3 = L_shr(re[s*7],SCALEFACTOR10); - x4 = L_shr(re[s*9],SCALEFACTOR10); - - r1 = L_add(x1,x4); - r4 = L_sub(x1,x4); - r3 = L_add(x3,x2); - r2 = L_sub(x3,x2); - t = Mpy_32_xx(L_sub(r1,r3),C54); - r1 = L_add(r1,r3); - y02 = L_add(x0,r1); - r1 = L_add(y02,(L_shl(Mpy_32_xx(r1,C55),1))); - r3 = L_sub(r1,t); - r1 = L_add(r1,t); - t = Mpy_32_xx((L_add(r4,r2)),C51); - r4 = L_add(t,L_shl(Mpy_32_xx(r4, C52),1)); - r2 = L_add(t,Mpy_32_xx(r2,C53)); - - /* imaginary part */ - x0 = L_shr(im[s*5],SCALEFACTOR10); - x1 = L_shr(im[s*1],SCALEFACTOR10); - x2 = L_shr(im[s*3],SCALEFACTOR10); - x3 = L_shr(im[s*7],SCALEFACTOR10); - x4 = L_shr(im[s*9],SCALEFACTOR10); - - s1 = L_add(x1,x4); - s4 = L_sub(x1,x4); - s3 = L_add(x3,x2); - s2 = L_sub(x3,x2); - t = Mpy_32_xx(L_sub(s1,s3),C54); - s1 = L_add(s1,s3); - y03 = L_add(x0,s1); - s1 = L_add(y03,L_shl(Mpy_32_xx(s1,C55),1)); - s3 = L_sub(s1,t); - s1 = L_add(s1,t); - t = Mpy_32_xx(L_add(s4,s2),C51); - s4 = L_add(t,L_shl(Mpy_32_xx(s4,C52),1)); - s2 = L_add(t,Mpy_32_xx(s2,C53)); + /* FOR i=0 */ + { + x0 = CL_shr(inp_data[0],SCALEFACTOR10); + x1 = CL_shr(inp_data[2],SCALEFACTOR10); + x2 = CL_shr(inp_data[4],SCALEFACTOR10); + x3 = CL_shr(inp_data[6],SCALEFACTOR10); + x4 = CL_shr(inp_data[8],SCALEFACTOR10); + + r1 = CL_add(x3,x2); + r4 = CL_sub(x3,x2); + r3 = CL_add(x1,x4); + r2 = CL_sub(x1,x4); + t = CL_scale_t(CL_sub(r1,r3),C54); + r1 = CL_add(r1,r3); + y[0] = CL_add(x0,r1); + r1 = CL_add(y[0],(CL_shl(CL_scale_t(r1,C55),1))); + r3 = CL_sub(r1,t); + r1 = CL_add(r1,t); + t = CL_scale_t((CL_add(r4,r2)),C51); + r4 = CL_add(t,CL_shl(CL_scale_t(r4, C52),1)); + r2 = CL_add(t,CL_scale_t(r2,C53)); + + + y[2] = CL_msu_j(r1,r2); + y[8] = CL_mac_j(r1,r2); + y[4] = CL_mac_j(r3,r4); + y[6] = CL_msu_j(r3,r4); + } + /* FOR i=1 */ + { + x0 = CL_shr(inp_data[5],SCALEFACTOR10); + x1 = CL_shr(inp_data[1],SCALEFACTOR10); + x2 = CL_shr(inp_data[3],SCALEFACTOR10); + x3 = CL_shr(inp_data[7],SCALEFACTOR10); + x4 = CL_shr(inp_data[9],SCALEFACTOR10); + + r1 = CL_add(x1,x4); + r4 = CL_sub(x1,x4); + r3 = CL_add(x3,x2); + r2 = CL_sub(x3,x2); + t = CL_scale_t(CL_sub(r1,r3),C54); + r1 = CL_add(r1,r3); + y[1] = CL_add(x0,r1); + r1 = CL_add(y[1],(CL_shl(CL_scale_t(r1,C55),1))); + r3 = CL_sub(r1,t); + r1 = CL_add(r1,t); + t = CL_scale_t((CL_add(r4,r2)),C51); + r4 = CL_add(t,CL_shl(CL_scale_t(r4, C52),1)); + r2 = CL_add(t,CL_scale_t(r2,C53)); + + + y[3] = CL_msu_j(r1,r2); + y[9] = CL_mac_j(r1,r2); + y[5] = CL_mac_j(r3,r4); + y[7] = CL_msu_j(r3,r4); + } - /* combination */ - y06 = L_add(r1,s2); - y18 = L_sub(r1,s2); - y10 = L_sub(r3,s4); - y14 = L_add(r3,s4); - - y07 = L_sub(s1,r2); - y19 = L_add(s1,r2); - y11 = L_add(s3,r4); - y15 = L_sub(s3,r4); - - /* 5 fft2 stages */ - re[s*0] = L_add(y00,y02); - move32(); - im[s*0] = L_add(y01,y03); - move32(); - re[s*5] = L_sub(y00,y02); - move32(); - im[s*5] = L_sub(y01,y03); - move32(); - - re[s*2] = L_add(y04,y06); - move32(); - im[s*2] = L_add(y05,y07); - move32(); - re[s*7] = L_sub(y04,y06); - move32(); - im[s*7] = L_sub(y05,y07); - move32(); - - re[s*4] = L_add(y08,y10); - move32(); - im[s*4] = L_add(y09,y11); - move32(); - re[s*9] = L_sub(y08,y10); - move32(); - im[s*9] = L_sub(y09,y11); - move32(); - - re[s*6] = L_add(y12,y14); - move32(); - im[s*6] = L_add(y13,y15); - move32(); - re[s*1] = L_sub(y12,y14); - move32(); - im[s*1] = L_sub(y13,y15); - move32(); - - re[s*8] = L_add(y16,y18); - move32(); - im[s*8] = L_add(y17,y19); - move32(); - re[s*3] = L_sub(y16,y18); - move32(); - im[s*3] = L_sub(y17,y19); - move32(); + /* FOR i=0 */ + { + inp_data[0] = CL_add(y[0],y[1]); + inp_data[5] = CL_sub(y[0],y[1]); + } + /* FOR i=2 */ + { + inp_data[2] = CL_add(y[2],y[3]); + inp_data[7] = CL_sub(y[2],y[3]); + } + /* FOR i=4 */ + { + inp_data[4] = CL_add(y[4],y[5]); + inp_data[9] = CL_sub(y[4],y[5]); + } + /* FOR i=6 */ + { + inp_data[6] = CL_add(y[6],y[7]); + inp_data[1] = CL_sub(y[6],y[7]); + } + /* FOR i=8 */ + { + inp_data[8] = CL_add(y[8],y[9]); + inp_data[3] = CL_sub(y[8],y[9]); + } + +#if (WMOPS) + multiCounter[currCounter].CL_move += 10; +#endif } @@ -564,311 +349,142 @@ static void fft10(Word32 *re, Word32 *im, Word16 s) * * \return void */ -static void fft15(Word32 *re, Word32 *im, Word16 s) -{ - Word32 t; - Word32 r1,r2,r3,r4; - Word32 s1,s2,s3,s4; - Word32 x00,x01,x02,x03,x04,x05,x06,x07,x08,x09; - Word32 x10,x11,x12,x13,x14,x15,x16,x17,x18,x19; - Word32 x20,x21,x22,x23,x24,x25,x26,x27,x28,x29; - Word32 y00,y01,y02,y03,y04,y05,y06,y07,y08,y09; - Word32 y10,y11,y12,y13,y14,y15,y16,y17,y18,y19; - Word32 y20,y21,y22,y23,y24,y25,y26,y27,y28,y29; - - - - x00 = L_shr(re[s* 0],SCALEFACTOR15); - x01 = L_shr(im[s* 0],SCALEFACTOR15); - x02 = L_shr(re[s* 3],SCALEFACTOR15); - x03 = L_shr(im[s* 3],SCALEFACTOR15); - x04 = L_shr(re[s* 6],SCALEFACTOR15); - x05 = L_shr(im[s* 6],SCALEFACTOR15); - x06 = L_shr(re[s* 9],SCALEFACTOR15); - x07 = L_shr(im[s* 9],SCALEFACTOR15); - x08 = L_shr(re[s*12],SCALEFACTOR15); - x09 = L_shr(im[s*12],SCALEFACTOR15); - - x10 = L_shr(re[s* 5],SCALEFACTOR15); - x11 = L_shr(im[s* 5],SCALEFACTOR15); - x12 = L_shr(re[s* 8],SCALEFACTOR15); - x13 = L_shr(im[s* 8],SCALEFACTOR15); - x14 = L_shr(re[s*11],SCALEFACTOR15); - x15 = L_shr(im[s*11],SCALEFACTOR15); - x16 = L_shr(re[s*14],SCALEFACTOR15); - x17 = L_shr(im[s*14],SCALEFACTOR15); - x18 = L_shr(re[s* 2],SCALEFACTOR15); - x19 = L_shr(im[s* 2],SCALEFACTOR15); - - x20 = L_shr(re[s*10],SCALEFACTOR15); - x21 = L_shr(im[s*10],SCALEFACTOR15); - x22 = L_shr(re[s*13],SCALEFACTOR15); - x23 = L_shr(im[s*13],SCALEFACTOR15); - x24 = L_shr(re[s* 1],SCALEFACTOR15); - x25 = L_shr(im[s* 1],SCALEFACTOR15); - x26 = L_shr(re[s* 4],SCALEFACTOR15); - x27 = L_shr(im[s* 4],SCALEFACTOR15); - x28 = L_shr(re[s* 7],SCALEFACTOR15); - x29 = L_shr(im[s* 7],SCALEFACTOR15); - /* 1. FFT5 stage */ - - /* real part */ - r1 = L_add(x02,x08); - r4 = L_sub(x02,x08); - r3 = L_add(x04,x06); - r2 = L_sub(x04,x06); - t = Mpy_32_xx(L_sub(r1,r3),C54); - r1 = L_add(r1,r3); - y00 = L_add(x00,r1); - r1 = L_add(y00,(L_shl(Mpy_32_xx(r1,C55),1))); - r3 = L_sub(r1,t); - r1 = L_add(r1,t); - t = Mpy_32_xx((L_add(r4,r2)),C51); - r4 = L_add(t,L_shl(Mpy_32_xx(r4,C52),1)); - r2 = L_add(t,Mpy_32_xx(r2,C53)); - - /* imaginary part */ - s1 = L_add(x03,x09); - s4 = L_sub(x03,x09); - s3 = L_add(x05,x07); - s2 = L_sub(x05,x07); - t = Mpy_32_xx(L_sub(s1,s3),C54); - s1 = L_add(s1,s3); - y01 = L_add(x01,s1); - s1 = L_add(y01,L_shl(Mpy_32_xx(s1,C55),1)); - s3 = L_sub(s1,t); - s1 = L_add(s1,t); - t = Mpy_32_xx(L_add(s4,s2),C51); - s4 = L_add(t,L_shl(Mpy_32_xx(s4,C52),1)); - s2 = L_add(t,Mpy_32_xx(s2,C53)); +static void fft15_with_cmplx_data(cmplx *inp_data) +{ + cmplx c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14; + cmplx c_z0,c_z1, c_z2, c_z3, c_z4, c_z5, c_z6, c_z7, c_z8, c_z9, c_z10, c_z11, c_z12, c_z13, c_z14; + cmplx c_y1,c_y2,c_y3,c_y4; + cmplx c_t; + + c0 = CL_shr(inp_data[ 0],SCALEFACTOR15); + c1 = CL_shr(inp_data[ 3],SCALEFACTOR15); + c2 = CL_shr(inp_data[ 6],SCALEFACTOR15); + c3 = CL_shr(inp_data[ 9],SCALEFACTOR15); + c4 = CL_shr(inp_data[12],SCALEFACTOR15); + c5 = CL_shr(inp_data[ 5],SCALEFACTOR15); + c6 = CL_shr(inp_data[ 8],SCALEFACTOR15); + c7 = CL_shr(inp_data[11],SCALEFACTOR15); + c8 = CL_shr(inp_data[14],SCALEFACTOR15); + c9 = CL_shr(inp_data[ 2],SCALEFACTOR15); + c10 = CL_shr(inp_data[10],SCALEFACTOR15); + c11 = CL_shr(inp_data[13],SCALEFACTOR15); + c12 = CL_shr(inp_data[ 1],SCALEFACTOR15); + c13 = CL_shr(inp_data[ 4],SCALEFACTOR15); + c14 = CL_shr(inp_data[ 7],SCALEFACTOR15); + + /* 1. FFT5 stage */ + c_y1 = CL_add(c1,c4); + c_y4 = CL_sub(c1,c4); + c_y3 = CL_add(c2,c3); + c_y2 = CL_sub(c2,c3); + c_t = CL_scale_t(CL_sub(c_y1,c_y3),C54); + c_y1 = CL_add(c_y1,c_y3); + c_z0 = CL_add(c0,c_y1); + c_y1 = CL_add(c_z0,(CL_shl(CL_scale_t(c_y1,C55),1))); + c_y3 = CL_sub(c_y1,c_t); + c_y1 = CL_add(c_y1,c_t); + c_t = CL_scale_t(CL_add(c_y4,c_y2),C51); + c_y4 = CL_add(c_t,CL_shl(CL_scale_t(c_y4,C52),1)); + c_y2 = CL_add(c_t,CL_scale_t(c_y2,C53)); /* combination */ - y02 = L_add(r1,s2); - y08 = L_sub(r1,s2); - y04 = L_sub(r3,s4); - y06 = L_add(r3,s4); + c_z1 = CL_msu_j(c_y1,c_y2); + c_z2 = CL_mac_j(c_y3,c_y4); + c_z3 = CL_msu_j(c_y3,c_y4); + c_z4 = CL_mac_j(c_y1,c_y2); - y03 = L_sub(s1,r2); - y09 = L_add(s1,r2); - y05 = L_add(s3,r4); - y07 = L_sub(s3,r4); /* 2. FFT5 stage */ - - /* real part */ - r1 = L_add(x12,x18); - r4 = L_sub(x12,x18); - r3 = L_add(x14,x16); - r2 = L_sub(x14,x16); - t = Mpy_32_xx(L_sub(r1,r3),C54); - r1 = L_add(r1,r3); - y10 = L_add(x10,r1); - r1 = L_add(y10,(L_shl(Mpy_32_xx(r1,C55),1))); - r3 = L_sub(r1,t); - r1 = L_add(r1,t); - t = Mpy_32_xx((L_add(r4,r2)),C51); - r4 = L_add(t,L_shl(Mpy_32_xx(r4,C52),1)); - r2 = L_add(t,Mpy_32_xx(r2,C53)); - - /* imaginary part */ - s1 = L_add(x13,x19); - s4 = L_sub(x13,x19); - s3 = L_add(x15,x17); - s2 = L_sub(x15,x17); - t = Mpy_32_xx(L_sub(s1,s3),C54); - s1 = L_add(s1,s3); - y11 = L_add(x11,s1); - s1 = L_add(y11,L_shl(Mpy_32_xx(s1,C55),1)); - s3 = L_sub(s1,t); - s1 = L_add(s1,t); - t = Mpy_32_xx(L_add(s4,s2),C51); - s4 = L_add(t,L_shl(Mpy_32_xx(s4,C52),1)); - s2 = L_add(t,Mpy_32_xx(s2,C53)); - + c_y1 = CL_add(c6,c9); + c_y4 = CL_sub(c6,c9); + c_y3 = CL_add(c7,c8); + c_y2 = CL_sub(c7,c8); + c_t = CL_scale_t(CL_sub(c_y1,c_y3),C54); + c_y1 = CL_add(c_y1,c_y3); + c_z5 = CL_add(c5,c_y1); + c_y1 = CL_add(c_z5,(CL_shl(CL_scale_t(c_y1,C55),1))); + c_y3 = CL_sub(c_y1,c_t); + c_y1 = CL_add(c_y1,c_t); + c_t = CL_scale_t(CL_add(c_y4,c_y2),C51); + c_y4 = CL_add(c_t,CL_shl(CL_scale_t(c_y4,C52),1)); + c_y2 = CL_add(c_t,CL_scale_t(c_y2,C53)); /* combination */ - y12 = L_add(r1,s2); - y18 = L_sub(r1,s2); - y14 = L_sub(r3,s4); - y16 = L_add(r3,s4); + c_z6 = CL_msu_j(c_y1,c_y2); + c_z7 = CL_mac_j(c_y3,c_y4); + c_z8 = CL_msu_j(c_y3,c_y4); + c_z9 = CL_mac_j(c_y1,c_y2); - y13 = L_sub(s1,r2); - y19 = L_add(s1,r2); - y15 = L_add(s3,r4); - y17 = L_sub(s3,r4); /* 3. FFT5 stage */ - /* real part */ - r1 = L_add(x22,x28); - r4 = L_sub(x22,x28); - r3 = L_add(x24,x26); - r2 = L_sub(x24,x26); - t = Mpy_32_xx(L_sub(r1,r3),C54); - r1 = L_add(r1,r3); - y20 = L_add(x20,r1); - r1 = L_add(y20,(L_shl(Mpy_32_xx(r1,C55),1))); - r3 = L_sub(r1,t); - r1 = L_add(r1,t); - t = Mpy_32_xx((L_add(r4,r2)),C51); - r4 = L_add(t,L_shl(Mpy_32_xx(r4,C52),1)); - r2 = L_add(t,Mpy_32_xx(r2,C53)); - - /* imaginary part */ - s1 = L_add(x23,x29); - s4 = L_sub(x23,x29); - s3 = L_add(x25,x27); - s2 = L_sub(x25,x27); - t = Mpy_32_xx(L_sub(s1,s3),C54); - s1 = L_add(s1,s3); - y21 = L_add(x21,s1); - s1 = L_add(y21,L_shl(Mpy_32_xx(s1,C55),1)); - s3 = L_sub(s1,t); - s1 = L_add(s1,t); - t = Mpy_32_xx(L_add(s4,s2),C51); - s4 = L_add(t,L_shl(Mpy_32_xx(s4,C52),1)); - s2 = L_add(t,Mpy_32_xx(s2,C53)); - + c_y1 = CL_add(c11,c14); + c_y4 = CL_sub(c11,c14); + c_y3 = CL_add(c12,c13); + c_y2 = CL_sub(c12,c13); + c_t = CL_scale_t(CL_sub(c_y1,c_y3),C54); + c_y1 = CL_add(c_y1,c_y3); + c_z10 = CL_add(c10,c_y1); + c_y1 = CL_add(c_z10,(CL_shl(CL_scale_t(c_y1,C55),1))); + c_y3 = CL_sub(c_y1,c_t); + c_y1 = CL_add(c_y1,c_t); + c_t = CL_scale_t(CL_add(c_y4,c_y2),C51); + c_y4 = CL_add(c_t,CL_shl(CL_scale_t(c_y4,C52),1)); + c_y2 = CL_add(c_t,CL_scale_t(c_y2,C53)); /* combination */ - y22 = L_add(r1,s2); - y28 = L_sub(r1,s2); - y24 = L_sub(r3,s4); - y26 = L_add(r3,s4); + c_z11 = CL_msu_j(c_y1,c_y2); + c_z12 = CL_mac_j(c_y3,c_y4); + c_z13 = CL_msu_j(c_y3,c_y4); + c_z14 = CL_mac_j(c_y1,c_y2); - y23 = L_sub(s1,r2); - y29 = L_add(s1,r2); - y25 = L_add(s3,r4); - y27 = L_sub(s3,r4); - /* 1. FFT3 stage */ - /* real part */ - r1 = L_add(y10,y20); - r2 = Mpy_32_xx(L_sub(y10,y20),C31); - re[s*0] = L_add(y00,r1); - move32(); - r1 = L_sub(y00,L_shr(r1,1)); - - /* imaginary part */ - s1 = L_add(y11,y21); - s2 = Mpy_32_xx(L_sub(y11,y21),C31); - im[s*0] = L_add(y01,s1); - move32(); - s1 = L_sub(y01,L_shr(s1,1)); + /* 1. FFT3 stage */ - /* combination */ - re[s*10] = L_sub(r1,s2); - move32(); - re[s* 5] = L_add(r1,s2); - move32(); - im[s*10] = L_add(s1,r2); - move32(); - im[s* 5] = L_sub(s1,r2); - move32(); + c_y1 = CL_add(c_z5,c_z10); + c_y2 = CL_scale_t(CL_sub(c_z5,c_z10),C31); + inp_data[0] = CL_add(c_z0,c_y1); + c_y1 = CL_sub(c_z0,CL_shr(c_y1,1)); + inp_data[10] = CL_mac_j(c_y1,c_y2); + inp_data[5] = CL_msu_j(c_y1,c_y2); /* 2. FFT3 stage */ - - /* real part */ - r1 = L_add(y12,y22); - r2 = Mpy_32_xx(L_sub(y12,y22),C31); - re[s*6] = L_add(y02,r1); - move32(); - r1 = L_sub(y02,L_shr(r1,1)); - - /* imaginary part */ - s1 = L_add(y13,y23); - s2 = Mpy_32_xx(L_sub(y13,y23),C31); - im[s*6] = L_add(y03,s1); - move32(); - s1 = L_sub(y03,L_shr(s1,1)); - - /* combination */ - re[s* 1] = L_sub(r1,s2); - move32(); - re[s*11] = L_add(r1,s2); - move32(); - im[s* 1] = L_add(s1,r2); - move32(); - im[s*11] = L_sub(s1,r2); - move32(); + c_y1 = CL_add(c_z6,c_z11); + c_y2 = CL_scale_t(CL_sub(c_z6,c_z11),C31); + inp_data[6] = CL_add(c_z1,c_y1); + c_y1 = CL_sub(c_z1,CL_shr(c_y1,1)); + inp_data[1] = CL_mac_j(c_y1,c_y2); + inp_data[11] = CL_msu_j(c_y1,c_y2); /* 3. FFT3 stage */ + c_y1 = CL_add(c_z7,c_z12); + c_y2 = CL_scale_t(CL_sub(c_z7,c_z12),C31); + inp_data[12] = CL_add(c_z2,c_y1); + c_y1 = CL_sub(c_z2,CL_shr(c_y1,1)); + inp_data[7] = CL_mac_j(c_y1,c_y2); + inp_data[2] = CL_msu_j(c_y1,c_y2); - /* real part */ - r1 = L_add(y14,y24); - r2 = Mpy_32_xx(L_sub(y14,y24),C31); - re[s*12] = L_add(y04,r1); - move32(); - r1 = L_sub(y04,L_shr(r1,1)); - - /* imaginary part */ - s1 = L_add(y15,y25); - s2 = Mpy_32_xx(L_sub(y15,y25),C31); - im[s*12] = L_add(y05,s1); - move32(); - s1 = L_sub(y05,L_shr(s1,1)); - - /* combination */ - re[s* 7] = L_sub(r1,s2); - move32(); - re[s* 2] = L_add(r1,s2); - move32(); - im[s* 7] = L_add(s1,r2); - move32(); - im[s* 2] = L_sub(s1,r2); - move32(); /* 4. FFT3 stage */ + c_y1 = CL_add(c_z8,c_z13); + c_y2 = CL_scale_t(CL_sub(c_z8,c_z13),C31); + inp_data[3] = CL_add(c_z3,c_y1); + c_y1 = CL_sub(c_z3,CL_shr(c_y1,1)); + inp_data[13] = CL_mac_j(c_y1,c_y2); + inp_data[8] = CL_msu_j(c_y1,c_y2); - /* real part */ - r1 = L_add(y16,y26); - r2 = Mpy_32_xx(L_sub(y16,y26),C31); - re[s*3] = L_add(y06,r1); - move32(); - r1 = L_sub(y06,L_shr(r1,1)); - - /* imaginary part */ - s1 = L_add(y17,y27); - s2 = Mpy_32_xx(L_sub(y17,y27),C31); - im[s*3] = L_add(y07,s1); - move32(); - s1 = L_sub(y07,L_shr(s1,1)); - - /* combination */ - re[s*13] = L_sub(r1,s2); - move32(); - re[s* 8] = L_add(r1,s2); - move32(); - im[s*13] = L_add(s1,r2); - move32(); - im[s* 8] = L_sub(s1,r2); - move32(); /* 5. FFT3 stage */ - - /* real part */ - r1 = L_add(y18,y28); - r2 = Mpy_32_xx(L_sub(y18,y28),C31); - re[s*9] = L_add(y08,r1); - move32(); - r1 = L_sub(y08,L_shr(r1,1)); - - /* imaginary part */ - s1 = L_add(y19,y29); - s2 = Mpy_32_xx(L_sub(y19,y29),C31); - im[s*9] = L_add(y09,s1); - move32(); - s1 = L_sub(y09,L_shr(s1,1)); - - /* combination */ - re[s* 4] = L_sub(r1,s2); - move32(); - re[s*14] = L_add(r1,s2); - move32(); - im[s* 4] = L_add(s1,r2); - move32(); - im[s*14] = L_sub(s1,r2); - move32(); + c_y1 = CL_add(c_z9,c_z14); + c_y2 = CL_scale_t(CL_sub(c_z9,c_z14),C31); + inp_data[9] = CL_add(c_z4,c_y1); + c_y1 = CL_sub(c_z4,CL_shr(c_y1,1)); + inp_data[4] = CL_mac_j(c_y1,c_y2); + inp_data[14] = CL_msu_j(c_y1,c_y2); + +#if (WMOPS) + multiCounter[currCounter].CL_move += 15; +#endif } @@ -889,385 +505,219 @@ static void fft15(Word32 *re, Word32 *im, Word16 s) */ void fft16(Word32 *re, Word32 *im, Word16 s, Word16 bScale) { - Word32 x0,x1,x2,x3,x4,x5,x6,x7; - Word32 t0,t1,t2,t3,t4,t5,t6,t7; - Word32 y00,y01,y02,y03,y04,y05,y06,y07; - Word32 y08,y09,y10,y11,y12,y13,y14,y15; - Word32 y16,y17,y18,y19,y20,y21,y22,y23; - Word32 y24,y25,y26,y27,y28,y29,y30,y31; - - - - IF (bScale) + int i; + if ( s == 2 ) { - x0 = L_shr(re[s* 0],SCALEFACTOR16); - x1 = L_shr(im[s* 0],SCALEFACTOR16); - x2 = L_shr(re[s* 4],SCALEFACTOR16); - x3 = L_shr(im[s* 4],SCALEFACTOR16); - x4 = L_shr(re[s* 8],SCALEFACTOR16); - x5 = L_shr(im[s* 8],SCALEFACTOR16); - x6 = L_shr(re[s*12],SCALEFACTOR16); - x7 = L_shr(im[s*12],SCALEFACTOR16); - - /* Pre-additions */ - t0 = L_add(x0,x4); - t2 = L_sub(x0,x4); - t1 = L_add(x1,x5); - t3 = L_sub(x1,x5); - t4 = L_add(x2,x6); - t7 = L_sub(x2,x6); - t5 = L_add(x7,x3); - t6 = L_sub(x7,x3); - - /* Post-additions */ - y00 = L_add(t0,t4); - y01 = L_add(t1,t5); - y02 = L_sub(t2,t6); - y03 = L_sub(t3,t7); - y04 = L_sub(t0,t4); - y05 = L_sub(t1,t5); - y06 = L_add(t2,t6); - y07 = L_add(t3,t7); - - x0 = L_shr(re[s* 1],SCALEFACTOR16); - x1 = L_shr(im[s* 1],SCALEFACTOR16); - x2 = L_shr(re[s* 5],SCALEFACTOR16); - x3 = L_shr(im[s* 5],SCALEFACTOR16); - x4 = L_shr(re[s* 9],SCALEFACTOR16); - x5 = L_shr(im[s* 9],SCALEFACTOR16); - x6 = L_shr(re[s*13],SCALEFACTOR16); - x7 = L_shr(im[s*13],SCALEFACTOR16); - - /* Pre-additions */ - t0 = L_add(x0,x4); - t2 = L_sub(x0,x4); - t1 = L_add(x1,x5); - t3 = L_sub(x1,x5); - t4 = L_add(x2,x6); - t7 = L_sub(x2,x6); - t5 = L_add(x7,x3); - t6 = L_sub(x7,x3); - - /* Post-additions */ - y08 = L_add(t0,t4); - y09 = L_add(t1,t5); - y10 = L_sub(t2,t6); - y11 = L_sub(t3,t7); - y12 = L_sub(t0,t4); - y13 = L_sub(t1,t5); - y14 = L_add(t2,t6); - y15 = L_add(t3,t7); - - x0 = L_shr(re[s* 2],SCALEFACTOR16); - x1 = L_shr(im[s* 2],SCALEFACTOR16); - x2 = L_shr(re[s* 6],SCALEFACTOR16); - x3 = L_shr(im[s* 6],SCALEFACTOR16); - x4 = L_shr(re[s*10],SCALEFACTOR16); - x5 = L_shr(im[s*10],SCALEFACTOR16); - x6 = L_shr(re[s*14],SCALEFACTOR16); - x7 = L_shr(im[s*14],SCALEFACTOR16); - - /* Pre-additions */ - t0 = L_add(x0,x4); - t2 = L_sub(x0,x4); - t1 = L_add(x1,x5); - t3 = L_sub(x1,x5); - t4 = L_add(x2,x6); - t7 = L_sub(x2,x6); - t5 = L_add(x7,x3); - t6 = L_sub(x7,x3); - - /* Post-additions */ - y16 = L_add(t0,t4); - y17 = L_add(t1,t5); - y18 = L_sub(t2,t6); - y19 = L_sub(t3,t7); - y20 = L_sub(t1,t5); - y21 = L_sub(t4,t0); - y22 = L_add(t2,t6); - y23 = L_add(t3,t7); - - x0 = L_shr(re[s* 3],SCALEFACTOR16); - x1 = L_shr(im[s* 3],SCALEFACTOR16); - x2 = L_shr(re[s* 7],SCALEFACTOR16); - x3 = L_shr(im[s* 7],SCALEFACTOR16); - x4 = L_shr(re[s*11],SCALEFACTOR16); - x5 = L_shr(im[s*11],SCALEFACTOR16); - x6 = L_shr(re[s*15],SCALEFACTOR16); - x7 = L_shr(im[s*15],SCALEFACTOR16); - - /* Pre-additions */ - t0 = L_add(x0,x4); - t2 = L_sub(x0,x4); - t1 = L_add(x1,x5); - t3 = L_sub(x1,x5); - t4 = L_add(x2,x6); - t7 = L_sub(x2,x6); - t5 = L_add(x7,x3); - t6 = L_sub(x7,x3); - - /* Post-additions */ - y24 = L_add(t0,t4); - y25 = L_add(t1,t5); - y26 = L_sub(t2,t6); - y27 = L_sub(t3,t7); - y28 = L_sub(t0,t4); - y29 = L_sub(t1,t5); - y30 = L_add(t2,t6); - y31 = L_add(t3,t7); + fft16_with_cmplx_data( (cmplx *) re, bScale ); } - ELSE + else { - /* Pre-additions */ - t0 = L_add(re[s* 0],re[s* 8]); - t2 = L_sub(re[s* 0],re[s* 8]); - t1 = L_add(im[s* 0],im[s* 8]); - t3 = L_sub(im[s* 0],im[s* 8]); - t4 = L_add(re[s* 4],re[s*12]); - t7 = L_sub(re[s* 4],re[s*12]); - t5 = L_add(im[s*12],im[s* 4]); - t6 = L_sub(im[s*12],im[s* 4]); - - /* Post-additions */ - y00 = L_add(t0,t4); - y01 = L_add(t1,t5); - y02 = L_sub(t2,t6); - y03 = L_sub(t3,t7); - y04 = L_sub(t0,t4); - y05 = L_sub(t1,t5); - y06 = L_add(t2,t6); - y07 = L_add(t3,t7); - - /* Pre-additions */ - t0 = L_add(re[s* 1],re[s* 9]); - t2 = L_sub(re[s* 1],re[s* 9]); - t1 = L_add(im[s* 1],im[s* 9]); - t3 = L_sub(im[s* 1],im[s* 9]); - t4 = L_add(re[s* 5],re[s*13]); - t7 = L_sub(re[s* 5],re[s*13]); - t5 = L_add(im[s*13],im[s* 5]); - t6 = L_sub(im[s*13],im[s* 5]); - - /* Post-additions */ - y08 = L_add(t0,t4); - y09 = L_add(t1,t5); - y10 = L_sub(t2,t6); - y11 = L_sub(t3,t7); - y12 = L_sub(t0,t4); - y13 = L_sub(t1,t5); - y14 = L_add(t2,t6); - y15 = L_add(t3,t7); - - /* Pre-additions */ - t0 = L_add(re[s* 2],re[s*10]); - t2 = L_sub(re[s* 2],re[s*10]); - t1 = L_add(im[s* 2],im[s*10]); - t3 = L_sub(im[s* 2],im[s*10]); - t4 = L_add(re[s* 6],re[s*14]); - t7 = L_sub(re[s* 6],re[s*14]); - t5 = L_add(im[s*14],im[s* 6]); - t6 = L_sub(im[s*14],im[s* 6]); - - /* Post-additions */ - y16 = L_add(t0,t4); - y17 = L_add(t1,t5); - y18 = L_sub(t2,t6); - y19 = L_sub(t3,t7); - y20 = L_sub(t1,t5); - y21 = L_sub(t4,t0); - y22 = L_add(t2,t6); - y23 = L_add(t3,t7); - - /* Pre-additions */ - t0 = L_add(re[s* 3],re[s*11]); - t2 = L_sub(re[s* 3],re[s*11]); - t1 = L_add(im[s* 3],im[s*11]); - t3 = L_sub(im[s* 3],im[s*11]); - t4 = L_add(re[s* 7],re[s*15]); - t7 = L_sub(re[s* 7],re[s*15]); - t5 = L_add(im[s*15],im[s* 7]); - t6 = L_sub(im[s*15],im[s* 7]); - - /* Post-additions */ - y24 = L_add(t0,t4); - y25 = L_add(t1,t5); - y26 = L_sub(t2,t6); - y27 = L_sub(t3,t7); - y28 = L_sub(t0,t4); - y29 = L_sub(t1,t5); - y30 = L_add(t2,t6); - y31 = L_add(t3,t7); + cmplx inp_data[16]; + FOR(i=0; i<16; i++) + { + inp_data[i] = CL_form(re[s*i], im[s*i]); + } + fft16_with_cmplx_data(inp_data, bScale ); + FOR(i=0; i<16; i++) + { + re[s*i] = CL_Extract_real(inp_data[i]); + im[s*i] = CL_Extract_imag(inp_data[i]); + } } +} - /* rotation */ - - x0 = Mpy_32_xx(y22,C162); - x1 = Mpy_32_xx(y23,C162); - y22 = L_sub(x0,x1); - y23 = L_add(x0,x1); - - x0 = Mpy_32_xx(y28,C162); - x1 = Mpy_32_xx(y29,C162); - y28 = L_sub(x0,x1); - y29 = L_add(x0,x1); - - x0 = Mpy_32_xx(y12,C161); - x1 = Mpy_32_xx(y13,C161); - y12 = L_add(x0,x1); - y13 = L_sub(x1,x0); - - x0 = Mpy_32_xx(y18,C161); - x1 = Mpy_32_xx(y19,C161); - y18 = L_add(x0,x1); - y19 = L_sub(x1,x0); - - x0 = Mpy_32_xx(y10,C163); - x1 = Mpy_32_xx(y11,C166); - x2 = Mpy_32_xx(y10,C166); - x3 = Mpy_32_xx(y11,C163); - y10 = L_sub(x0,x1); - y11 = L_add(x2,x3); - - x0 = Mpy_32_xx(y14,C165); - x1 = Mpy_32_xx(y15,C164); - x2 = Mpy_32_xx(y14,C164); - x3 = Mpy_32_xx(y15,C165); - y14 = L_sub(x0,x1); - y15 = L_add(x2,x3); - - x0 = Mpy_32_xx(y26,C165); - x1 = Mpy_32_xx(y27,C164); - x2 = Mpy_32_xx(y26,C164); - x3 = Mpy_32_xx(y27,C165); - y26 = L_sub(x0,x1); - y27 = L_add(x2,x3); - - x0 = Mpy_32_xx(y30,C164); - x1 = Mpy_32_xx(y31,C165); - x2 = Mpy_32_xx(y30,C165); - x3 = Mpy_32_xx(y31,C164); - y30 = L_sub(x0,x1); - y31 = L_add(x2,x3); - - /* Pre-additions */ - - t0 = L_add(y00,y16); - t2 = L_sub(y00,y16); - t1 = L_add(y01,y17); - t3 = L_sub(y01,y17); - t4 = L_add(y08,y24); - t7 = L_sub(y08,y24); - t5 = L_add(y25,y09); - t6 = L_sub(y25,y09); - - /* Post-additions */ - - re[s* 0] = L_add(t0,t4); - move32(); - im[s* 0] = L_add(t1,t5); - move32(); - re[s* 4] = L_sub(t2,t6); - move32(); - im[s* 4] = L_sub(t3,t7); - move32(); - re[s* 8] = L_sub(t0,t4); - move32(); - im[s* 8] = L_sub(t1,t5); - move32(); - re[s*12] = L_add(t2,t6); - move32(); - im[s*12] = L_add(t3,t7); - move32(); - - /* Pre-additions */ - - t0 = L_add(y02,y18); - t2 = L_sub(y02,y18); - t1 = L_add(y03,y19); - t3 = L_sub(y03,y19); - t4 = L_add(y10,y26); - t7 = L_sub(y10,y26); - t5 = L_add(y27,y11); - t6 = L_sub(y27,y11); - - /* Post-additions */ +void fft16_with_cmplx_data(cmplx *input, Word16 bScale ) +{ + cmplx x0, x1, x2, x3, temp; + cmplx t0,t2,t4,t6,t7; + cmplx y[16]; - re[s* 1] = L_add(t0,t4); - move32(); - im[s* 1] = L_add(t1,t5); - move32(); - re[s* 5] = L_sub(t2,t6); - move32(); - im[s* 5] = L_sub(t3,t7); - move32(); - re[s* 9] = L_sub(t0,t4); - move32(); - im[s* 9] = L_sub(t1,t5); - move32(); - re[s*13] = L_add(t2,t6); - move32(); - im[s*13] = L_add(t3,t7); - move32(); + IF (bScale) + { + { + x0 = CL_shr(input[0],SCALEFACTOR16); + x1 = CL_shr(input[4],SCALEFACTOR16); + x2 = CL_shr(input[8],SCALEFACTOR16); + x3 = CL_shr(input[12],SCALEFACTOR16); + t0 = CL_add(x0,x2); + t2 = CL_sub(x0,x2); + t4 = CL_add(x1,x3); + t6 = CL_sub(x1,x3); + t6 = CL_mul_j(t6); + y[0] = CL_add(t0,t4); + y[1] = CL_sub(t2,t6); + y[2] = CL_sub(t0,t4); + y[3] = CL_add(t2,t6); + + + x0 = CL_shr(input[1],SCALEFACTOR16); + x1 = CL_shr(input[5],SCALEFACTOR16); + x2 = CL_shr(input[9],SCALEFACTOR16); + x3 = CL_shr(input[13],SCALEFACTOR16); + t0 = CL_add(x0,x2); + t2 = CL_sub(x0,x2); + t4 = CL_add(x1,x3); + t6 = CL_sub(x1,x3); + t6 = CL_mul_j(t6); + y[4] = CL_add(t0,t4); + y[5] = CL_sub(t2,t6); + y[6] = CL_sub(t0,t4); + y[7] = CL_add(t2,t6); + + + x0 = CL_shr(input[2],SCALEFACTOR16); + x1 = CL_shr(input[6],SCALEFACTOR16); + x2 = CL_shr(input[10],SCALEFACTOR16); + x3 = CL_shr(input[14],SCALEFACTOR16); + t0 = CL_add(x0,x2); + t2 = CL_sub(x0,x2); + t4 = CL_add(x1,x3); + t6 = CL_sub(x1,x3); + t6 = CL_mul_j(t6); + y[8] = CL_add(t0,t4); + y[9] = CL_sub(t2,t6); + y[10] = CL_sub(t4,t0); + y[10] = CL_mul_j(y[10]); + y[11] = CL_add(t2,t6); + + + x0 = CL_shr(input[3],SCALEFACTOR16); + x1 = CL_shr(input[7],SCALEFACTOR16); + x2 = CL_shr(input[11],SCALEFACTOR16); + x3 = CL_shr(input[15],SCALEFACTOR16); + t0 = CL_add(x0,x2); + t2 = CL_sub(x0,x2); + t4 = CL_add(x1,x3); + t6 = CL_sub(x1,x3); + t6 = CL_mul_j(t6); + y[12] = CL_add(t0,t4); + y[13] = CL_sub(t2,t6); + y[14] = CL_sub(t0,t4); + y[15] = CL_add(t2,t6); + } + } + else + { + { + t0 = CL_add(input[ 0],input[ 8]); + t2 = CL_sub(input[ 0],input[ 8]); + t4 = CL_add(input[ 4],input[12]); + t7 = CL_sub(input[ 4],input[12]); + + y[0] = CL_add(t0,t4); + y[1] = CL_msu_j(t2,t7); + y[2] = CL_sub(t0,t4); + y[3] = CL_mac_j(t2,t7); + } + /* i=1 */ + { + t0 = CL_add(input[ 1],input[ 9]); + t2 = CL_sub(input[ 1],input[ 9]); + t4 = CL_add(input[ 5],input[13]); + t7 = CL_sub(input[ 5],input[13]); + + y[4] = CL_add(t0,t4); + y[5] = CL_msu_j(t2,t7); + y[6] = CL_sub(t0,t4); + y[7] = CL_mac_j(t2,t7); + } + /* i=2 */ + { + t0 = CL_add(input[ 2],input[ 10]); + t2 = CL_sub(input[ 2],input[ 10]); + t4 = CL_add(input[ 6],input[14]); + t7 = CL_sub(input[ 6],input[14]); + + y[8] = CL_add(t0,t4); + y[9] = CL_msu_j(t2,t7); + temp = CL_sub(t0,t4); + y[10] = CL_negate(CL_mul_j(temp)); + y[11] = CL_mac_j(t2,t7); + } + /* i=3 */ + { + t0 = CL_add(input[ 3],input[ 11]); + t2 = CL_sub(input[ 3],input[ 11]); + t4 = CL_add(input[ 7],input[15]); + t7 = CL_sub(input[ 7],input[15]); + + y[12] = CL_add(t0,t4); + y[13] = CL_msu_j(t2,t7); + y[14] = CL_sub(t0,t4); + y[15] = CL_mac_j(t2,t7); + } - /* Pre-additions */ + } - t0 = L_add(y04,y20); - t2 = L_sub(y04,y20); - t1 = L_add(y05,y21); - t3 = L_sub(y05,y21); - t4 = L_add(y12,y28); - t7 = L_sub(y12,y28); - t5 = L_add(y29,y13); - t6 = L_sub(y29,y13); + x0 = CL_scale_t(y[11],C162); + y[11] = CL_mac_j(x0,x0); - /* Post-additions */ + x0 = CL_scale_t(y[14],C162); + y[14] = CL_mac_j(x0,x0); - re[s* 2] = L_add(t0,t4); - move32(); - im[s* 2] = L_add(t1,t5); - move32(); - re[s* 6] = L_sub(t2,t6); - move32(); - im[s* 6] = L_sub(t3,t7); - move32(); - re[s*10] = L_sub(t0,t4); - move32(); - im[s*10] = L_sub(t1,t5); - move32(); - re[s*14] = L_add(t2,t6); - move32(); - im[s*14] = L_add(t3,t7); - move32(); + x0 = CL_scale_t(y[6],C161); + y[6] = CL_msu_j(x0,x0); - /* Pre-additions */ + x0 = CL_scale_t(y[9],C161); + y[9] = CL_msu_j(x0,x0); - t0 = L_add(y06,y22); - t2 = L_sub(y06,y22); - t1 = L_add(y07,y23); - t3 = L_sub(y07,y23); - t4 = L_add(y14,y30); - t7 = L_sub(y14,y30); - t5 = L_add(y31,y15); - t6 = L_sub(y31,y15); + y[5] = CL_mac_j(CL_scale_t(y[5], C163), CL_scale_t(y[5], C166)); + y[7] = CL_mac_j(CL_scale_t(y[7], C165), CL_scale_t(y[7], C164)); + y[13] = CL_mac_j(CL_scale_t(y[13], C165), CL_scale_t(y[13], C164)); + y[15] = CL_mac_j(CL_scale_t(y[15], C164), CL_scale_t(y[15], C165)); - /* Post-additions */ - re[s* 3] = L_add(t0,t4); - move32(); - im[s* 3] = L_add(t1,t5); - move32(); - re[s* 7] = L_sub(t2,t6); - move32(); - im[s* 7] = L_sub(t3,t7); - move32(); - re[s*11] = L_sub(t0,t4); - move32(); - im[s*11] = L_sub(t1,t5); - move32(); - re[s*15] = L_add(t2,t6); - move32(); - im[s*15] = L_add(t3,t7); - move32(); + /* i=0 */ + { + t0 = CL_add(y[ 0],y[ 8]); + t2 = CL_sub(y[ 0],y[ 8]); + t4 = CL_add(y[ 4],y[12]); + t7 = CL_sub(y[ 4],y[12]); + + input[0] = CL_add(t0,t4); + input[4] = CL_msu_j(t2,t7); + input[8] = CL_sub(t0,t4); + input[12] = CL_mac_j(t2,t7); + } + /* i=1 */ + { + t0 = CL_add(y[ 1],y[ 9]); + t2 = CL_sub(y[ 1],y[ 9]); + t4 = CL_add(y[ 5],y[13]); + t7 = CL_sub(y[ 5],y[13]); + + input[1] = CL_add(t0,t4); + input[5] = CL_msu_j(t2,t7); + input[9] = CL_sub(t0,t4); + input[13] = CL_mac_j(t2,t7); + } + /* i=2 */ + { + t0 = CL_add(y[ 2],y[ 10]); + t2 = CL_sub(y[ 2],y[ 10]); + t4 = CL_add(y[ 6],y[14]); + t7 = CL_sub(y[ 6],y[14]); + + input[2] = CL_add(t0,t4); + input[6] = CL_msu_j(t2,t7); + input[10] = CL_sub(t0,t4); + input[14] = CL_mac_j(t2,t7); + } + /* i=3 */ + { + t0 = CL_add(y[ 3],y[ 11]); + t2 = CL_sub(y[ 3],y[ 11]); + t4 = CL_add(y[ 7],y[15]); + t7 = CL_sub(y[ 7],y[15]); + + input[3] = CL_add(t0,t4); + input[7] = CL_msu_j(t2,t7); + input[11] = CL_sub(t0,t4); + input[15] = CL_mac_j(t2,t7); + } +#if (WMOPS) + multiCounter[currCounter].CL_move += 16; +#endif } @@ -1285,395 +735,242 @@ void fft16(Word32 *re, Word32 *im, Word16 s, Word16 bScale) * * \return void */ -static void fft20(Word32 *re, Word32 *im, Word16 s) +static void fft20_with_cmplx_data(cmplx *inp_data) { - Word32 r1,r2,r3,r4; - Word32 s1,s2,s3,s4; - Word32 x0,x1,x2,x3,x4; - Word32 t,t0,t1,t2,t3,t4,t5,t6,t7; - Word32 y00,y01,y02,y03,y04,y05,y06,y07,y08,y09; - Word32 y10,y11,y12,y13,y14,y15,y16,y17,y18,y19; - Word32 y20,y21,y22,y23,y24,y25,y26,y27,y28,y29; - Word32 y30,y31,y32,y33,y34,y35,y36,y37,y38,y39; - - - /* */ - - /* 1. FFT5 stage */ - - /* real part */ - x0 = L_shr(re[s* 0],SCALEFACTOR20); - x1 = L_shr(re[s*16],SCALEFACTOR20); - x2 = L_shr(re[s*12],SCALEFACTOR20); - x3 = L_shr(re[s* 8],SCALEFACTOR20); - x4 = L_shr(re[s* 4],SCALEFACTOR20); - - r1 = L_add(x1,x4); - r4 = L_sub(x1,x4); - r3 = L_add(x2,x3); - r2 = L_sub(x2,x3); - t = Mpy_32_xx(L_sub(r1,r3),C54); - r1 = L_add(r1,r3); - y00 = L_add(x0,r1); - r1 = L_add(y00,(L_shl(Mpy_32_xx(r1,C55),1))); - r3 = L_sub(r1,t); - r1 = L_add(r1,t); - t = Mpy_32_xx((L_add(r4,r2)),C51); - r4 = L_add(t,L_shl(Mpy_32_xx(r4, C52),1)); - r2 = L_add(t,Mpy_32_xx(r2,C53)); - - /* imaginary part */ - x0 = L_shr(im[s* 0],SCALEFACTOR20); - x1 = L_shr(im[s*16],SCALEFACTOR20); - x2 = L_shr(im[s*12],SCALEFACTOR20); - x3 = L_shr(im[s* 8],SCALEFACTOR20); - x4 = L_shr(im[s* 4],SCALEFACTOR20); - - s1 = L_add(x1,x4); - s4 = L_sub(x1,x4); - s3 = L_add(x2,x3); - s2 = L_sub(x2,x3); - t = Mpy_32_xx(L_sub(s1,s3),C54); - s1 = L_add(s1,s3); - y01 = L_add(x0,s1); - s1 = L_add(y01,L_shl(Mpy_32_xx(s1,C55),1)); - s3 = L_sub(s1,t); - s1 = L_add(s1,t); - t = Mpy_32_xx(L_add(s4,s2),C51); - s4 = L_add(t,L_shl(Mpy_32_xx(s4,C52),1)); - s2 = L_add(t,Mpy_32_xx(s2,C53)); - - /* combination */ - y08 = L_add(r1,s2); - y32 = L_sub(r1,s2); - y16 = L_sub(r3,s4); - y24 = L_add(r3,s4); + cmplx r1,r2,r3,r4; + cmplx x0,x1,x2,x3,x4; + cmplx t,t0,t1,t2,t3; + cmplx y[20]; + cmplx *y0, *y1,*y2,*y3,*y4; + + y0 = y; + y1 = &y[4]; + y2 = &y[16]; + y3 = &y[8]; + y4 = &y[12]; - y09 = L_sub(s1,r2); - y33 = L_add(s1,r2); - y17 = L_add(s3,r4); - y25 = L_sub(s3,r4); - - /* 2. FFT5 stage */ - - /* real part */ - x0 = L_shr(re[s* 5],SCALEFACTOR20); - x1 = L_shr(re[s* 1],SCALEFACTOR20); - x2 = L_shr(re[s*17],SCALEFACTOR20); - x3 = L_shr(re[s*13],SCALEFACTOR20); - x4 = L_shr(re[s* 9],SCALEFACTOR20); - - r1 = L_add(x1,x4); - r4 = L_sub(x1,x4); - r3 = L_add(x2,x3); - r2 = L_sub(x2,x3); - t = Mpy_32_xx(L_sub(r1,r3),C54); - r1 = L_add(r1,r3); - y02 = L_add(x0,r1); - r1 = L_add(y02,(L_shl(Mpy_32_xx(r1,C55),1))); - r3 = L_sub(r1,t); - r1 = L_add(r1,t); - t = Mpy_32_xx((L_add(r4,r2)),C51); - r4 = L_add(t,L_shl(Mpy_32_xx(r4, C52),1)); - r2 = L_add(t,Mpy_32_xx(r2,C53)); - - /* imaginary part */ - x0 = L_shr(im[s* 5],SCALEFACTOR20); - x1 = L_shr(im[s* 1],SCALEFACTOR20); - x2 = L_shr(im[s*17],SCALEFACTOR20); - x3 = L_shr(im[s*13],SCALEFACTOR20); - x4 = L_shr(im[s* 9],SCALEFACTOR20); - - s1 = L_add(x1,x4); - s4 = L_sub(x1,x4); - s3 = L_add(x2,x3); - s2 = L_sub(x2,x3); - t = Mpy_32_xx(L_sub(s1,s3),C54); - s1 = L_add(s1,s3); - y03 = L_add(x0,s1); - s1 = L_add(y03,L_shl(Mpy_32_xx(s1,C55),1)); - s3 = L_sub(s1,t); - s1 = L_add(s1,t); - t = Mpy_32_xx(L_add(s4,s2),C51); - s4 = L_add(t,L_shl(Mpy_32_xx(s4,C52),1)); - s2 = L_add(t,Mpy_32_xx(s2,C53)); - - /* combination */ - y10 = L_add(r1,s2); - y34 = L_sub(r1,s2); - y18 = L_sub(r3,s4); - y26 = L_add(r3,s4); - - y11 = L_sub(s1,r2); - y35 = L_add(s1,r2); - y19 = L_add(s3,r4); - y27 = L_sub(s3,r4); - - /* 3. FFT5 stage */ - - /* real part */ - x0 = L_shr(re[s*10],SCALEFACTOR20); - x1 = L_shr(re[s* 6],SCALEFACTOR20); - x2 = L_shr(re[s* 2],SCALEFACTOR20); - x3 = L_shr(re[s*18],SCALEFACTOR20); - x4 = L_shr(re[s*14],SCALEFACTOR20); - - r1 = L_add(x1,x4); - r4 = L_sub(x1,x4); - r3 = L_add(x2,x3); - r2 = L_sub(x2,x3); - t = Mpy_32_xx(L_sub(r1,r3),C54); - r1 = L_add(r1,r3); - y04 = L_add(x0,r1); - r1 = L_add(y04,(L_shl(Mpy_32_xx(r1,C55),1))); - r3 = L_sub(r1,t); - r1 = L_add(r1,t); - t = Mpy_32_xx((L_add(r4,r2)),C51); - r4 = L_add(t,L_shl(Mpy_32_xx(r4, C52),1)); - r2 = L_add(t,Mpy_32_xx(r2,C53)); - - /* imaginary part */ - x0 = L_shr(im[s*10],SCALEFACTOR20); - x1 = L_shr(im[s* 6],SCALEFACTOR20); - x2 = L_shr(im[s* 2],SCALEFACTOR20); - x3 = L_shr(im[s*18],SCALEFACTOR20); - x4 = L_shr(im[s*14],SCALEFACTOR20); - - s1 = L_add(x1,x4); - s4 = L_sub(x1,x4); - s3 = L_add(x2,x3); - s2 = L_sub(x2,x3); - t = Mpy_32_xx(L_sub(s1,s3),C54); - s1 = L_add(s1,s3); - y05 = L_add(x0,s1); - s1 = L_add(y05,L_shl(Mpy_32_xx(s1,C55),1)); - s3 = L_sub(s1,t); - s1 = L_add(s1,t); - t = Mpy_32_xx(L_add(s4,s2),C51); - s4 = L_add(t,L_shl(Mpy_32_xx(s4,C52),1)); - s2 = L_add(t,Mpy_32_xx(s2,C53)); - - /* combination */ - y12 = L_add(r1,s2); - y36 = L_sub(r1,s2); - y20 = L_sub(r3,s4); - y28 = L_add(r3,s4); - - y13 = L_sub(s1,r2); - y37 = L_add(s1,r2); - y21 = L_add(s3,r4); - y29 = L_sub(s3,r4); + { + x0 = CL_shr(inp_data[0],SCALEFACTOR20); + x1 = CL_shr(inp_data[16],SCALEFACTOR20); + x2 = CL_shr(inp_data[12],SCALEFACTOR20); + x3 = CL_shr(inp_data[8],SCALEFACTOR20); + x4 = CL_shr(inp_data[4],SCALEFACTOR20); + + r4 = CL_sub(x1,x4); + r2 = CL_sub(x2,x3); + r1 = CL_add(x1,x4); + r3 = CL_add(x2,x3); + t = CL_scale_t(CL_sub(r1,r3),C54); + r1 = CL_add(r1,r3); + y0[0] = CL_add(x0,r1); + r1 = CL_add(y0[0],(CL_shl(CL_scale_t(r1,C55),1))); + r3 = CL_sub(r1,t); + r1 = CL_add(r1,t); + t = CL_scale_t((CL_add(r4,r2)),C51); + r4 = CL_add(t,CL_shl(CL_scale_t(r4, C52),1)); + r2 = CL_add(t,CL_scale_t(r2,C53)); + + + y1[0] = CL_msu_j(r1,r2); + y2[0] = CL_mac_j(r1,r2); + y3[0] = CL_mac_j(r3,r4); + y4[0] = CL_msu_j(r3,r4); + } + { + x0 = CL_shr(inp_data[5],SCALEFACTOR20); + x1 = CL_shr(inp_data[1],SCALEFACTOR20); + x2 = CL_shr(inp_data[17],SCALEFACTOR20); + x3 = CL_shr(inp_data[13],SCALEFACTOR20); + x4 = CL_shr(inp_data[9],SCALEFACTOR20); + + r4 = CL_sub(x1,x4); + r2 = CL_sub(x2,x3); + r1 = CL_add(x1,x4); + r3 = CL_add(x2,x3); + t = CL_scale_t(CL_sub(r1,r3),C54); + r1 = CL_add(r1,r3); + y0[1] = CL_add(x0,r1); + r1 = CL_add(y0[1],(CL_shl(CL_scale_t(r1,C55),1))); + r3 = CL_sub(r1,t); + r1 = CL_add(r1,t); + t = CL_scale_t((CL_add(r4,r2)),C51); + r4 = CL_add(t,CL_shl(CL_scale_t(r4, C52),1)); + r2 = CL_add(t,CL_scale_t(r2,C53)); + + + y1[1] = CL_msu_j(r1,r2); + y2[1] = CL_mac_j(r1,r2); + y3[1] = CL_mac_j(r3,r4); + y4[1] = CL_msu_j(r3,r4); + } + { + x0 = CL_shr(inp_data[10],SCALEFACTOR20); + x1 = CL_shr(inp_data[6],SCALEFACTOR20); + x2 = CL_shr(inp_data[2],SCALEFACTOR20); + x3 = CL_shr(inp_data[18],SCALEFACTOR20); + x4 = CL_shr(inp_data[14],SCALEFACTOR20); + + r4 = CL_sub(x1,x4); + r2 = CL_sub(x2,x3); + r1 = CL_add(x1,x4); + r3 = CL_add(x2,x3); + t = CL_scale_t(CL_sub(r1,r3),C54); + r1 = CL_add(r1,r3); + y0[2] = CL_add(x0,r1); + r1 = CL_add(y0[2],(CL_shl(CL_scale_t(r1,C55),1))); + r3 = CL_sub(r1,t); + r1 = CL_add(r1,t); + t = CL_scale_t((CL_add(r4,r2)),C51); + r4 = CL_add(t,CL_shl(CL_scale_t(r4, C52),1)); + r2 = CL_add(t,CL_scale_t(r2,C53)); + + + y1[2] = CL_msu_j(r1,r2); + y2[2] = CL_mac_j(r1,r2); + y3[2] = CL_mac_j(r3,r4); + y4[2] = CL_msu_j(r3,r4); + } + { + x0 = CL_shr(inp_data[15],SCALEFACTOR20); + x1 = CL_shr(inp_data[11],SCALEFACTOR20); + x2 = CL_shr(inp_data[7],SCALEFACTOR20); + x3 = CL_shr(inp_data[3],SCALEFACTOR20); + x4 = CL_shr(inp_data[19],SCALEFACTOR20); + + r4 = CL_sub(x1,x4); + r2 = CL_sub(x2,x3); + r1 = CL_add(x1,x4); + r3 = CL_add(x2,x3); + t = CL_scale_t(CL_sub(r1,r3),C54); + r1 = CL_add(r1,r3); + y0[3] = CL_add(x0,r1); + r1 = CL_add(y0[3],(CL_shl(CL_scale_t(r1,C55),1))); + r3 = CL_sub(r1,t); + r1 = CL_add(r1,t); + t = CL_scale_t((CL_add(r4,r2)),C51); + r4 = CL_add(t,CL_shl(CL_scale_t(r4, C52),1)); + r2 = CL_add(t,CL_scale_t(r2,C53)); + + + y1[3] = CL_msu_j(r1,r2); + y2[3] = CL_mac_j(r1,r2); + y3[3] = CL_mac_j(r3,r4); + y4[3] = CL_msu_j(r3,r4); + } - /* 4. FFT5 stage */ + { + cmplx * ptr_y = y; + { + cmplx Cy0, Cy1, Cy2, Cy3; - /* real part */ - x0 = L_shr(re[s*15],SCALEFACTOR20); - x1 = L_shr(re[s*11],SCALEFACTOR20); - x2 = L_shr(re[s* 7],SCALEFACTOR20); - x3 = L_shr(re[s* 3],SCALEFACTOR20); - x4 = L_shr(re[s*19],SCALEFACTOR20); - - r1 = L_add(x1,x4); - r4 = L_sub(x1,x4); - r3 = L_add(x2,x3); - r2 = L_sub(x2,x3); - t = Mpy_32_xx(L_sub(r1,r3),C54); - r1 = L_add(r1,r3); - y06 = L_add(x0,r1); - r1 = L_add(y06,(L_shl(Mpy_32_xx(r1,C55),1))); - r3 = L_sub(r1,t); - r1 = L_add(r1,t); - t = Mpy_32_xx((L_add(r4,r2)),C51); - r4 = L_add(t,L_shl(Mpy_32_xx(r4, C52),1)); - r2 = L_add(t,Mpy_32_xx(r2,C53)); - - /* imaginary part */ - x0 = L_shr(im[s*15],SCALEFACTOR20); - x1 = L_shr(im[s*11],SCALEFACTOR20); - x2 = L_shr(im[s* 7],SCALEFACTOR20); - x3 = L_shr(im[s* 3],SCALEFACTOR20); - x4 = L_shr(im[s*19],SCALEFACTOR20); - - s1 = L_add(x1,x4); - s4 = L_sub(x1,x4); - s3 = L_add(x2,x3); - s2 = L_sub(x2,x3); - t = Mpy_32_xx(L_sub(s1,s3),C54); - s1 = L_add(s1,s3); - y07 = L_add(x0,s1); - s1 = L_add(y07,L_shl(Mpy_32_xx(s1,C55),1)); - s3 = L_sub(s1,t); - s1 = L_add(s1,t); - t = Mpy_32_xx(L_add(s4,s2),C51); - s4 = L_add(t,L_shl(Mpy_32_xx(s4,C52),1)); - s2 = L_add(t,Mpy_32_xx(s2,C53)); + Cy0 = *ptr_y++; + Cy1 = *ptr_y++; + Cy2 = *ptr_y++; + Cy3 = *ptr_y++; - /* combination */ - y14 = L_add(r1,s2); - y38 = L_sub(r1,s2); - y22 = L_sub(r3,s4); - y30 = L_add(r3,s4); + /* Pre-additions */ + t0 = CL_add(Cy0,Cy2); + t1 = CL_sub(Cy0,Cy2); + t2 = CL_add(Cy1,Cy3); + t3 = CL_sub(Cy1,Cy3); - y15 = L_sub(s1,r2); - y39 = L_add(s1,r2); - y23 = L_add(s3,r4); - y31 = L_sub(s3,r4); + inp_data[0] = CL_add(t0,t2); + inp_data[5] = CL_msu_j(t1,t3); + inp_data[10] = CL_sub(t0,t2); + inp_data[15] = CL_mac_j(t1,t3); + } - /* 1. FFT4 stage */ + { + cmplx Cy0, Cy1, Cy2, Cy3; - /* Pre-additions */ - t0 = L_add(y00,y04); - t2 = L_sub(y00,y04); - t1 = L_add(y01,y05); - t3 = L_sub(y01,y05); - t4 = L_add(y02,y06); - t7 = L_sub(y02,y06); - t5 = L_add(y07,y03); - t6 = L_sub(y07,y03); + Cy0 = *ptr_y++; + Cy1 = *ptr_y++; + Cy2 = *ptr_y++; + Cy3 = *ptr_y++; - /* Post-additions */ - re[s* 0] = L_add(t0,t4); - move32(); - im[s* 0] = L_add(t1,t5); - move32(); - re[s* 5] = L_sub(t2,t6); - move32(); - im[s* 5] = L_sub(t3,t7); - move32(); - re[s*10] = L_sub(t0,t4); - move32(); - im[s*10] = L_sub(t1,t5); - move32(); - re[s*15] = L_add(t2,t6); - move32(); - im[s*15] = L_add(t3,t7); - move32(); + /* Pre-additions */ + t0 = CL_add(Cy0,Cy2); + t1 = CL_sub(Cy0,Cy2); + t2 = CL_add(Cy1,Cy3); + t3 = CL_sub(Cy1,Cy3); - /* 2. FFT4 stage */ - /* Pre-additions */ - t0 = L_add(y08,y12); - t2 = L_sub(y08,y12); - t1 = L_add(y09,y13); - t3 = L_sub(y09,y13); - t4 = L_add(y10,y14); - t7 = L_sub(y10,y14); - t5 = L_add(y15,y11); - t6 = L_sub(y15,y11); + inp_data[4] = CL_add(t0,t2); + inp_data[9] = CL_msu_j(t1,t3); + inp_data[14] = CL_sub(t0,t2); + inp_data[19] = CL_mac_j(t1,t3); + } - /* Post-additions */ - re[s* 4] = L_add(t0,t4); - move32(); - im[s* 4] = L_add(t1,t5); - move32(); - re[s* 9] = L_sub(t2,t6); - move32(); - im[s* 9] = L_sub(t3,t7); - move32(); - re[s*14] = L_sub(t0,t4); - move32(); - im[s*14] = L_sub(t1,t5); - move32(); - re[s*19] = L_add(t2,t6); - move32(); - im[s*19] = L_add(t3,t7); - move32(); + { + cmplx Cy0, Cy1, Cy2, Cy3; + Cy0 = *ptr_y++; + Cy1 = *ptr_y++; + Cy2 = *ptr_y++; + Cy3 = *ptr_y++; - /* 3. FFT4 stage */ + /* Pre-additions */ + t0 = CL_add(Cy0,Cy2); + t1 = CL_sub(Cy0,Cy2); + t2 = CL_add(Cy1,Cy3); + t3 = CL_sub(Cy1,Cy3); - /* Pre-additions */ - t0 = L_add(y16,y20); - t2 = L_sub(y16,y20); - t1 = L_add(y17,y21); - t3 = L_sub(y17,y21); - t4 = L_add(y18,y22); - t7 = L_sub(y18,y22); - t5 = L_add(y23,y19); - t6 = L_sub(y23,y19); - /* Post-additions */ - re[s* 8] = L_add(t0,t4); - move32(); - im[s* 8] = L_add(t1,t5); - move32(); - re[s*13] = L_sub(t2,t6); - move32(); - im[s*13] = L_sub(t3,t7); - move32(); - re[s*18] = L_sub(t0,t4); - move32(); - im[s*18] = L_sub(t1,t5); - move32(); - re[s* 3] = L_add(t2,t6); - move32(); - im[s* 3] = L_add(t3,t7); - move32(); + inp_data[8] = CL_add(t0,t2); + inp_data[13] = CL_msu_j(t1,t3); + inp_data[18] = CL_sub(t0,t2); + inp_data[3] = CL_mac_j(t1,t3); + } - /* 4. FFT4 stage */ + { + cmplx Cy0, Cy1, Cy2, Cy3; + + Cy0 = *ptr_y++; + Cy1 = *ptr_y++; + Cy2 = *ptr_y++; + Cy3 = *ptr_y++; + + /* Pre-additions */ + t0 = CL_add(Cy0,Cy2); + t1 = CL_sub(Cy0,Cy2); + t2 = CL_add(Cy1,Cy3); + t3 = CL_sub(Cy1,Cy3); + + inp_data[12] = CL_add(t0,t2); + inp_data[17] = CL_msu_j(t1,t3); + inp_data[2] = CL_sub(t0,t2); + inp_data[7] = CL_mac_j(t1,t3); + } - /* Pre-additions */ - t0 = L_add(y24,y28); - t2 = L_sub(y24,y28); - t1 = L_add(y25,y29); - t3 = L_sub(y25,y29); - t4 = L_add(y26,y30); - t7 = L_sub(y26,y30); - t5 = L_add(y31,y27); - t6 = L_sub(y31,y27); + { + cmplx Cy0, Cy1, Cy2, Cy3; - /* Post-additions */ - re[s*12] = L_add(t0,t4); - move32(); - im[s*12] = L_add(t1,t5); - move32(); - re[s*17] = L_sub(t2,t6); - move32(); - im[s*17] = L_sub(t3,t7); - move32(); - re[s* 2] = L_sub(t0,t4); - move32(); - im[s* 2] = L_sub(t1,t5); - move32(); - re[s* 7] = L_add(t2,t6); - move32(); - im[s* 7] = L_add(t3,t7); - move32(); + Cy0 = *ptr_y++; + Cy1 = *ptr_y++; + Cy2 = *ptr_y++; + Cy3 = *ptr_y++; - /* 5. FFT4 stage */ + /* Pre-additions */ + t0 = CL_add(Cy0,Cy2); + t1 = CL_sub(Cy0,Cy2); + t2 = CL_add(Cy1,Cy3); + t3 = CL_sub(Cy1,Cy3); - /* Pre-additions */ - t0 = L_add(y32,y36); - t2 = L_sub(y32,y36); - t1 = L_add(y33,y37); - t3 = L_sub(y33,y37); - t4 = L_add(y34,y38); - t7 = L_sub(y34,y38); - t5 = L_add(y39,y35); - t6 = L_sub(y39,y35); - /* Post-additions */ - re[s*16] = L_add(t0,t4); - move32(); - im[s*16] = L_add(t1,t5); - move32(); - re[s* 1] = L_sub(t2,t6); - move32(); - im[s* 1] = L_sub(t3,t7); - move32(); - re[s* 6] = L_sub(t0,t4); - move32(); - im[s* 6] = L_sub(t1,t5); - move32(); - re[s*11] = L_add(t2,t6); - move32(); - im[s*11] = L_add(t3,t7); - move32(); - - /* */ + inp_data[16] = CL_add(t0,t2); + inp_data[1] = CL_msu_j(t1,t3); + inp_data[6] = CL_sub(t0,t2); + inp_data[11] = CL_mac_j(t1,t3); + } + } +#if (WMOPS) + multiCounter[currCounter].CL_move += 20; +#endif + } + /** * \brief Function performs a complex 30-point FFT * The FFT is performed inplace. The result of the FFT @@ -1687,801 +984,415 @@ static void fft20(Word32 *re, Word32 *im, Word16 s) * * \return void */ -static void fft30(Word32 *re, Word32 *im, Word16 s) -{ - Word32 t; - Word32 r1,r2,r3,r4; - Word32 s1,s2,s3,s4; - Word32 x00,x01,x02,x03,x04,x05,x06,x07,x08,x09; - Word32 x10,x11,x12,x13,x14,x15,x16,x17,x18,x19; - Word32 x20,x21,x22,x23,x24,x25,x26,x27,x28,x29; - Word32 y00,y01,y02,y03,y04,y05,y06,y07,y08,y09; - Word32 y10,y11,y12,y13,y14,y15,y16,y17,y18,y19; - Word32 y20,y21,y22,y23,y24,y25,y26,y27,y28,y29; +static void fft30_with_cmplx_data(cmplx * inp) +{ + cmplx *l = &inp[0]; + cmplx *h = &inp[15]; - Word32 z00,z01,z02,z03,z04,z05,z06,z07,z08,z09; - Word32 z10,z11,z12,z13,z14,z15,z16,z17,z18,z19; - Word32 z20,z21,z22,z23,z24,z25,z26,z27,z28,z29; - Word32 z30,z31,z32,z33,z34,z35,z36,z37,z38,z39; - Word32 z40,z41,z42,z43,z44,z45,z46,z47,z48,z49; - Word32 z50,z51,z52,z53,z54,z55,z56,z57,z58,z59; + cmplx z[30], y[15], x[15], rs1, rs2, rs3, rs4, t; - Word32 *rel = &re[s* 0]; - Word32 *reh = &re[s*15]; + /* 1. FFT15 stage */ - Word32 *iml = &im[s* 0]; - Word32 *imh = &im[s*15]; + x[0] = CL_shr(inp[0],SCALEFACTOR30_1); + x[1] = CL_shr(inp[18],SCALEFACTOR30_1); + x[2] = CL_shr(inp[6],SCALEFACTOR30_1); + x[3] = CL_shr(inp[24],SCALEFACTOR30_1); + x[4] = CL_shr(inp[12],SCALEFACTOR30_1); + x[5] = CL_shr(inp[20],SCALEFACTOR30_1); + x[6] = CL_shr(inp[8],SCALEFACTOR30_1); + x[7] = CL_shr(inp[26],SCALEFACTOR30_1); + x[8] = CL_shr(inp[14],SCALEFACTOR30_1); + x[9] = CL_shr(inp[2],SCALEFACTOR30_1); + x[10] = CL_shr(inp[10],SCALEFACTOR30_1); + x[11] = CL_shr(inp[28],SCALEFACTOR30_1); + x[12] = CL_shr(inp[16],SCALEFACTOR30_1); + x[13] = CL_shr(inp[4],SCALEFACTOR30_1); + x[14] = CL_shr(inp[22],SCALEFACTOR30_1); - /* 1. FFT15 stage */ - x00 = L_shr(re[s* 0],SCALEFACTOR30_1); - x01 = L_shr(im[s* 0],SCALEFACTOR30_1); - x02 = L_shr(re[s*18],SCALEFACTOR30_1); - x03 = L_shr(im[s*18],SCALEFACTOR30_1); - x04 = L_shr(re[s* 6],SCALEFACTOR30_1); - x05 = L_shr(im[s* 6],SCALEFACTOR30_1); - x06 = L_shr(re[s*24],SCALEFACTOR30_1); - x07 = L_shr(im[s*24],SCALEFACTOR30_1); - x08 = L_shr(re[s*12],SCALEFACTOR30_1); - x09 = L_shr(im[s*12],SCALEFACTOR30_1); - - x10 = L_shr(re[s*20],SCALEFACTOR30_1); - x11 = L_shr(im[s*20],SCALEFACTOR30_1); - x12 = L_shr(re[s* 8],SCALEFACTOR30_1); - x13 = L_shr(im[s* 8],SCALEFACTOR30_1); - x14 = L_shr(re[s*26],SCALEFACTOR30_1); - x15 = L_shr(im[s*26],SCALEFACTOR30_1); - x16 = L_shr(re[s*14],SCALEFACTOR30_1); - x17 = L_shr(im[s*14],SCALEFACTOR30_1); - x18 = L_shr(re[s* 2],SCALEFACTOR30_1); - x19 = L_shr(im[s* 2],SCALEFACTOR30_1); - - x20 = L_shr(re[s*10],SCALEFACTOR30_1); - x21 = L_shr(im[s*10],SCALEFACTOR30_1); - x22 = L_shr(re[s*28],SCALEFACTOR30_1); - x23 = L_shr(im[s*28],SCALEFACTOR30_1); - x24 = L_shr(re[s*16],SCALEFACTOR30_1); - x25 = L_shr(im[s*16],SCALEFACTOR30_1); - x26 = L_shr(re[s* 4],SCALEFACTOR30_1); - x27 = L_shr(im[s* 4],SCALEFACTOR30_1); - x28 = L_shr(re[s*22],SCALEFACTOR30_1); - x29 = L_shr(im[s*22],SCALEFACTOR30_1); /* 1. FFT5 stage */ - - /* real part */ - r1 = L_add(x02,x08); - r4 = L_sub(x02,x08); - r3 = L_add(x04,x06); - r2 = L_sub(x04,x06); - t = Mpy_32_xx(L_sub(r1,r3),C54); - r1 = L_add(r1,r3); - y00 = L_add(x00,r1); - r1 = L_add(y00,(L_shl(Mpy_32_xx(r1,C55),1))); - r3 = L_sub(r1,t); - r1 = L_add(r1,t); - t = Mpy_32_xx((L_add(r4,r2)),C51); - r4 = L_add(t,L_shl(Mpy_32_xx(r4,C52),1)); - r2 = L_add(t,Mpy_32_xx(r2,C53)); - - /* imaginary part */ - s1 = L_add(x03,x09); - s4 = L_sub(x03,x09); - s3 = L_add(x05,x07); - s2 = L_sub(x05,x07); - t = Mpy_32_xx(L_sub(s1,s3),C54); - s1 = L_add(s1,s3); - y01 = L_add(x01,s1); - s1 = L_add(y01,L_shl(Mpy_32_xx(s1,C55),1)); - s3 = L_sub(s1,t); - s1 = L_add(s1,t); - t = Mpy_32_xx(L_add(s4,s2),C51); - s4 = L_add(t,L_shl(Mpy_32_xx(s4,C52),1)); - s2 = L_add(t,Mpy_32_xx(s2,C53)); + rs1 = CL_add(x[1],x[4]); + rs4 = CL_sub(x[1],x[4]); + rs3 = CL_add(x[2],x[3]); + rs2 = CL_sub(x[2],x[3]); + t = CL_scale_t(CL_sub(rs1,rs3),C54); + rs1 = CL_add(rs1,rs3); + y[0] = CL_add(x[0],rs1); + rs1 = CL_add(y[0],(CL_shl(CL_scale_t(rs1,C55),1))); + rs3 = CL_sub(rs1,t); + rs1 = CL_add(rs1,t); + t = CL_scale_t(CL_add(rs4,rs2),C51); + rs4 = CL_add(t,CL_shl(CL_scale_t(rs4, C52),1)); + rs2 = CL_add(t,CL_scale_t(rs2,C53)); /* combination */ - y02 = L_add(r1,s2); - y08 = L_sub(r1,s2); - y04 = L_sub(r3,s4); - y06 = L_add(r3,s4); + y[1] = CL_msu_j(rs1,rs2); + y[4] = CL_mac_j(rs1,rs2); + y[2] = CL_mac_j(rs3,rs4); + y[3] = CL_msu_j(rs3,rs4); - y03 = L_sub(s1,r2); - y09 = L_add(s1,r2); - y05 = L_add(s3,r4); - y07 = L_sub(s3,r4); /* 2. FFT5 stage */ - - /* real part */ - r1 = L_add(x12,x18); - r4 = L_sub(x12,x18); - r3 = L_add(x14,x16); - r2 = L_sub(x14,x16); - t = Mpy_32_xx(L_sub(r1,r3),C54); - r1 = L_add(r1,r3); - y10 = L_add(x10,r1); - r1 = L_add(y10,(L_shl(Mpy_32_xx(r1,C55),1))); - r3 = L_sub(r1,t); - r1 = L_add(r1,t); - t = Mpy_32_xx((L_add(r4,r2)),C51); - r4 = L_add(t,L_shl(Mpy_32_xx(r4,C52),1)); - r2 = L_add(t,Mpy_32_xx(r2,C53)); - - /* imaginary part */ - s1 = L_add(x13,x19); - s4 = L_sub(x13,x19); - s3 = L_add(x15,x17); - s2 = L_sub(x15,x17); - t = Mpy_32_xx(L_sub(s1,s3),C54); - s1 = L_add(s1,s3); - y11 = L_add(x11,s1); - s1 = L_add(y11,L_shl(Mpy_32_xx(s1,C55),1)); - s3 = L_sub(s1,t); - s1 = L_add(s1,t); - t = Mpy_32_xx(L_add(s4,s2),C51); - s4 = L_add(t,L_shl(Mpy_32_xx(s4,C52),1)); - s2 = L_add(t,Mpy_32_xx(s2,C53)); + rs1 = CL_add(x[6],x[9]); + rs4 = CL_sub(x[6],x[9]); + rs3 = CL_add(x[7],x[8]); + rs2 = CL_sub(x[7],x[8]); + t = CL_scale_t(CL_sub(rs1,rs3),C54); + rs1 = CL_add(rs1,rs3); + y[5] = CL_add(x[5],rs1); + rs1 = CL_add(y[5],(CL_shl(CL_scale_t(rs1,C55),1))); + rs3 = CL_sub(rs1,t); + rs1 = CL_add(rs1,t); + t = CL_scale_t(CL_add(rs4,rs2),C51); + rs4 = CL_add(t,CL_shl(CL_scale_t(rs4, C52),1)); + rs2 = CL_add(t,CL_scale_t(rs2,C53)); /* combination */ - y12 = L_add(r1,s2); - y18 = L_sub(r1,s2); - y14 = L_sub(r3,s4); - y16 = L_add(r3,s4); + y[6] = CL_msu_j(rs1,rs2); + y[9] = CL_mac_j(rs1,rs2); + y[7] = CL_mac_j(rs3,rs4); + y[8] = CL_msu_j(rs3,rs4); - y13 = L_sub(s1,r2); - y19 = L_add(s1,r2); - y15 = L_add(s3,r4); - y17 = L_sub(s3,r4); /* 3. FFT5 stage */ - - /* real part */ - r1 = L_add(x22,x28); - r4 = L_sub(x22,x28); - r3 = L_add(x24,x26); - r2 = L_sub(x24,x26); - t = Mpy_32_xx(L_sub(r1,r3),C54); - r1 = L_add(r1,r3); - y20 = L_add(x20,r1); - r1 = L_add(y20,(L_shl(Mpy_32_xx(r1,C55),1))); - r3 = L_sub(r1,t); - r1 = L_add(r1,t); - t = Mpy_32_xx((L_add(r4,r2)),C51); - r4 = L_add(t,L_shl(Mpy_32_xx(r4,C52),1)); - r2 = L_add(t,Mpy_32_xx(r2,C53)); - - /* imaginary part */ - s1 = L_add(x23,x29); - s4 = L_sub(x23,x29); - s3 = L_add(x25,x27); - s2 = L_sub(x25,x27); - t = Mpy_32_xx(L_sub(s1,s3),C54); - s1 = L_add(s1,s3); - y21 = L_add(x21,s1); - s1 = L_add(y21,L_shl(Mpy_32_xx(s1,C55),1)); - s3 = L_sub(s1,t); - s1 = L_add(s1,t); - t = Mpy_32_xx(L_add(s4,s2),C51); - s4 = L_add(t,L_shl(Mpy_32_xx(s4,C52),1)); - s2 = L_add(t,Mpy_32_xx(s2,C53)); + rs1 = CL_add(x[11],x[14]); + rs4 = CL_sub(x[11],x[14]); + rs3 = CL_add(x[12],x[13]); + rs2 = CL_sub(x[12],x[13]); + t = CL_scale_t(CL_sub(rs1,rs3),C54); + rs1 = CL_add(rs1,rs3); + y[10] = CL_add(x[10],rs1); + rs1 = CL_add(y[10],(CL_shl(CL_scale_t(rs1,C55),1))); + rs3 = CL_sub(rs1,t); + rs1 = CL_add(rs1,t); + t = CL_scale_t(CL_add(rs4,rs2),C51); + rs4 = CL_add(t,CL_shl(CL_scale_t(rs4, C52),1)); + rs2 = CL_add(t,CL_scale_t(rs2,C53)); /* combination */ - y22 = L_add(r1,s2); - y28 = L_sub(r1,s2); - y24 = L_sub(r3,s4); - y26 = L_add(r3,s4); + y[11] = CL_msu_j(rs1,rs2); + y[14] = CL_mac_j(rs1,rs2); + y[12] = CL_mac_j(rs3,rs4); + y[13] = CL_msu_j(rs3,rs4); + /*for (i=10; i<15; i++) + { + printf("%d,\t %d,\t",y[i].re, y[i].im); + } + printf("\n\n");*/ - y23 = L_sub(s1,r2); - y29 = L_add(s1,r2); - y25 = L_add(s3,r4); - y27 = L_sub(s3,r4); /* 1. FFT3 stage */ - /* real part */ - r1 = L_add(y10,y20); - r2 = Mpy_32_xx(L_sub(y10,y20),C31); - z00 = L_add(y00,r1); - r1 = L_sub(y00,L_shr(r1,1)); + rs1 = CL_add(y[5],y[10]); + rs2 = CL_scale_t(CL_sub(y[5],y[10]),C31); + z[0] = CL_add(y[0],rs1); + rs1 = CL_sub(y[0],CL_shr(rs1,1)); - /* imaginary part */ - s1 = L_add(y11,y21); - s2 = Mpy_32_xx(L_sub(y11,y21),C31); - z01 = L_add(y01,s1); - s1 = L_sub(y01,L_shr(s1,1)); - - /* combination */ - z20 = L_sub(r1,s2); - z10 = L_add(r1,s2); - z21 = L_add(s1,r2); - z11 = L_sub(s1,r2); + z[10] = CL_mac_j(rs1,rs2); + z[5] = CL_msu_j(rs1,rs2); /* 2. FFT3 stage */ + rs1 = CL_add(y[6],y[11]); + rs2 = CL_scale_t(CL_sub(y[6],y[11]),C31); + z[6] = CL_add(y[1],rs1); + rs1 = CL_sub(y[1],CL_shr(rs1,1)); - /* real part */ - r1 = L_add(y12,y22); - r2 = Mpy_32_xx(L_sub(y12,y22),C31); - z12 = L_add(y02,r1); - r1 = L_sub(y02,L_shr(r1,1)); + z[1] = CL_mac_j(rs1,rs2); + z[11] = CL_msu_j(rs1,rs2); - /* imaginary part */ - s1 = L_add(y13,y23); - s2 = Mpy_32_xx(L_sub(y13,y23),C31); - z13 = L_add(y03,s1); - s1 = L_sub(y03,L_shr(s1,1)); - - /* combination */ - z02 = L_sub(r1,s2); - z22 = L_add(r1,s2); - z03 = L_add(s1,r2); - z23 = L_sub(s1,r2); /* 3. FFT3 stage */ + rs1 = CL_add(y[7],y[12]); + rs2 = CL_scale_t(CL_sub(y[7],y[12]),C31); + z[12] = CL_add(y[2],rs1); + rs1 = CL_sub(y[2],CL_shr(rs1,1)); - /* real part */ - r1 = L_add(y14,y24); - r2 = Mpy_32_xx(L_sub(y14,y24),C31); - z24 = L_add(y04,r1); - r1 = L_sub(y04,L_shr(r1,1)); - - /* imaginary part */ - s1 = L_add(y15,y25); - s2 = Mpy_32_xx(L_sub(y15,y25),C31); - z25 = L_add(y05,s1); - s1 = L_sub(y05,L_shr(s1,1)); + z[7] = CL_mac_j(rs1,rs2); + z[2] = CL_msu_j(rs1,rs2); - /* combination */ - z14 = L_sub(r1,s2); - z04 = L_add(r1,s2); - z15 = L_add(s1,r2); - z05 = L_sub(s1,r2); /* 4. FFT3 stage */ + rs1 = CL_add(y[8],y[13]); + rs2 = CL_scale_t(CL_sub(y[8],y[13]),C31); + z[3] = CL_add(y[3],rs1); + rs1 = CL_sub(y[3],CL_shr(rs1,1)); - /* real part */ - r1 = L_add(y16,y26); - r2 = Mpy_32_xx(L_sub(y16,y26),C31); - z06 = L_add(y06,r1); - r1 = L_sub(y06,L_shr(r1,1)); - - /* imaginary part */ - s1 = L_add(y17,y27); - s2 = Mpy_32_xx(L_sub(y17,y27),C31); - z07 = L_add(y07,s1); - s1 = L_sub(y07,L_shr(s1,1)); + z[13] = CL_mac_j(rs1,rs2); + z[8] = CL_msu_j(rs1,rs2); - /* combination */ - z26 = L_sub(r1,s2); - z16 = L_add(r1,s2); - z27 = L_add(s1,r2); - z17 = L_sub(s1,r2); /* 5. FFT3 stage */ + rs1 = CL_add(y[9],y[14]); + rs2 = CL_scale_t(CL_sub(y[9],y[14]),C31); + z[9] = CL_add(y[4],rs1); + rs1 = CL_sub(y[4],CL_shr(rs1,1)); - /* real part */ - r1 = L_add(y18,y28); - r2 = Mpy_32_xx(L_sub(y18,y28),C31); - z18 = L_add(y08,r1); - r1 = L_sub(y08,L_shr(r1,1)); - - /* imaginary part */ - s1 = L_add(y19,y29); - s2 = Mpy_32_xx(L_sub(y19,y29),C31); - z19 = L_add(y09,s1); - s1 = L_sub(y09,L_shr(s1,1)); + z[4] = CL_mac_j(rs1,rs2); + z[14] = CL_msu_j(rs1,rs2); - /* combination */ - z08 = L_sub(r1,s2); - z28 = L_add(r1,s2); - z09 = L_add(s1,r2); - z29 = L_sub(s1,r2); + /*for (i=0; i<15; i++) + printf("%d,\t %d,\t",z[i].re, z[i].im); + printf("\n\n");*/ /* 2. FFT15 stage */ - x00 = L_shr(re[s*15],SCALEFACTOR30_1); - x01 = L_shr(im[s*15],SCALEFACTOR30_1); - x02 = L_shr(re[s* 3],SCALEFACTOR30_1); - x03 = L_shr(im[s* 3],SCALEFACTOR30_1); - x04 = L_shr(re[s*21],SCALEFACTOR30_1); - x05 = L_shr(im[s*21],SCALEFACTOR30_1); - x06 = L_shr(re[s* 9],SCALEFACTOR30_1); - x07 = L_shr(im[s* 9],SCALEFACTOR30_1); - x08 = L_shr(re[s*27],SCALEFACTOR30_1); - x09 = L_shr(im[s*27],SCALEFACTOR30_1); - - x10 = L_shr(re[s* 5],SCALEFACTOR30_1); - x11 = L_shr(im[s* 5],SCALEFACTOR30_1); - x12 = L_shr(re[s*23],SCALEFACTOR30_1); - x13 = L_shr(im[s*23],SCALEFACTOR30_1); - x14 = L_shr(re[s*11],SCALEFACTOR30_1); - x15 = L_shr(im[s*11],SCALEFACTOR30_1); - x16 = L_shr(re[s*29],SCALEFACTOR30_1); - x17 = L_shr(im[s*29],SCALEFACTOR30_1); - x18 = L_shr(re[s*17],SCALEFACTOR30_1); - x19 = L_shr(im[s*17],SCALEFACTOR30_1); - - x20 = L_shr(re[s*25],SCALEFACTOR30_1); - x21 = L_shr(im[s*25],SCALEFACTOR30_1); - x22 = L_shr(re[s*13],SCALEFACTOR30_1); - x23 = L_shr(im[s*13],SCALEFACTOR30_1); - x24 = L_shr(re[s* 1],SCALEFACTOR30_1); - x25 = L_shr(im[s* 1],SCALEFACTOR30_1); - x26 = L_shr(re[s*19],SCALEFACTOR30_1); - x27 = L_shr(im[s*19],SCALEFACTOR30_1); - x28 = L_shr(re[s* 7],SCALEFACTOR30_1); - x29 = L_shr(im[s* 7],SCALEFACTOR30_1); - /* 1. FFT5 stage */ + x[0] = CL_shr(inp[15],SCALEFACTOR30_1); + x[1] = CL_shr(inp[3],SCALEFACTOR30_1); + x[2] = CL_shr(inp[21],SCALEFACTOR30_1); + x[3] = CL_shr(inp[9],SCALEFACTOR30_1); + x[4] = CL_shr(inp[27],SCALEFACTOR30_1); - /* real part */ - r1 = L_add(x02,x08); - r4 = L_sub(x02,x08); - r3 = L_add(x04,x06); - r2 = L_sub(x04,x06); - t = Mpy_32_xx(L_sub(r1,r3),C54); - r1 = L_add(r1,r3); - y00 = L_add(x00,r1); - r1 = L_add(y00,(L_shl(Mpy_32_xx(r1,C55),1))); - r3 = L_sub(r1,t); - r1 = L_add(r1,t); - t = Mpy_32_xx((L_add(r4,r2)),C51); - r4 = L_add(t,L_shl(Mpy_32_xx(r4,C52),1)); - r2 = L_add(t,Mpy_32_xx(r2,C53)); - - /* imaginary part */ - s1 = L_add(x03,x09); - s4 = L_sub(x03,x09); - s3 = L_add(x05,x07); - s2 = L_sub(x05,x07); - t = Mpy_32_xx(L_sub(s1,s3),C54); - s1 = L_add(s1,s3); - y01 = L_add(x01,s1); - s1 = L_add(y01,L_shl(Mpy_32_xx(s1,C55),1)); - s3 = L_sub(s1,t); - s1 = L_add(s1,t); - t = Mpy_32_xx(L_add(s4,s2),C51); - s4 = L_add(t,L_shl(Mpy_32_xx(s4,C52),1)); - s2 = L_add(t,Mpy_32_xx(s2,C53)); + x[5] = CL_shr(inp[5],SCALEFACTOR30_1); + x[6] = CL_shr(inp[23],SCALEFACTOR30_1); + x[7] = CL_shr(inp[11],SCALEFACTOR30_1); + x[8] = CL_shr(inp[29],SCALEFACTOR30_1); + x[9] = CL_shr(inp[17],SCALEFACTOR30_1); + + x[10] = CL_shr(inp[25],SCALEFACTOR30_1); + x[11] = CL_shr(inp[13],SCALEFACTOR30_1); + x[12] = CL_shr(inp[1],SCALEFACTOR30_1); + x[13] = CL_shr(inp[19],SCALEFACTOR30_1); + x[14] = CL_shr(inp[7],SCALEFACTOR30_1); + + /* 1. FFT5 stage */ + rs1 = CL_add(x[1],x[4]); + rs4 = CL_sub(x[1],x[4]); + rs3 = CL_add(x[2],x[3]); + rs2 = CL_sub(x[2],x[3]); + t = CL_scale_t(CL_sub(rs1,rs3),C54); + rs1 = CL_add(rs1,rs3); + y[0] = CL_add(x[0],rs1); + rs1 = CL_add(y[0],(CL_shl(CL_scale_t(rs1,C55),1))); + rs3 = CL_sub(rs1,t); + rs1 = CL_add(rs1,t); + t = CL_scale_t(CL_add(rs4,rs2),C51); + rs4 = CL_add(t,CL_shl(CL_scale_t(rs4, C52),1)); + rs2 = CL_add(t,CL_scale_t(rs2,C53)); /* combination */ - y02 = L_add(r1,s2); - y08 = L_sub(r1,s2); - y04 = L_sub(r3,s4); - y06 = L_add(r3,s4); + y[1] = CL_msu_j(rs1,rs2); + y[4] = CL_mac_j(rs1,rs2); + y[2] = CL_mac_j(rs3,rs4); + y[3] = CL_msu_j(rs3,rs4); - y03 = L_sub(s1,r2); - y09 = L_add(s1,r2); - y05 = L_add(s3,r4); - y07 = L_sub(s3,r4); /* 2. FFT5 stage */ - - /* real part */ - r1 = L_add(x12,x18); - r4 = L_sub(x12,x18); - r3 = L_add(x14,x16); - r2 = L_sub(x14,x16); - t = Mpy_32_xx(L_sub(r1,r3),C54); - r1 = L_add(r1,r3); - y10 = L_add(x10,r1); - r1 = L_add(y10,(L_shl(Mpy_32_xx(r1,C55),1))); - r3 = L_sub(r1,t); - r1 = L_add(r1,t); - t = Mpy_32_xx((L_add(r4,r2)),C51); - r4 = L_add(t,L_shl(Mpy_32_xx(r4,C52),1)); - r2 = L_add(t,Mpy_32_xx(r2,C53)); - - /* imaginary part */ - s1 = L_add(x13,x19); - s4 = L_sub(x13,x19); - s3 = L_add(x15,x17); - s2 = L_sub(x15,x17); - t = Mpy_32_xx(L_sub(s1,s3),C54); - s1 = L_add(s1,s3); - y11 = L_add(x11,s1); - s1 = L_add(y11,L_shl(Mpy_32_xx(s1,C55),1)); - s3 = L_sub(s1,t); - s1 = L_add(s1,t); - t = Mpy_32_xx(L_add(s4,s2),C51); - s4 = L_add(t,L_shl(Mpy_32_xx(s4,C52),1)); - s2 = L_add(t,Mpy_32_xx(s2,C53)); + rs1 = CL_add(x[6],x[9]); + rs4 = CL_sub(x[6],x[9]); + rs3 = CL_add(x[7],x[8]); + rs2 = CL_sub(x[7],x[8]); + t = CL_scale_t(CL_sub(rs1,rs3),C54); + rs1 = CL_add(rs1,rs3); + y[5] = CL_add(x[5],rs1); + rs1 = CL_add(y[5],(CL_shl(CL_scale_t(rs1,C55),1))); + rs3 = CL_sub(rs1,t); + rs1 = CL_add(rs1,t); + t = CL_scale_t(CL_add(rs4,rs2),C51); + rs4 = CL_add(t,CL_shl(CL_scale_t(rs4, C52),1)); + rs2 = CL_add(t,CL_scale_t(rs2,C53)); /* combination */ - y12 = L_add(r1,s2); - y18 = L_sub(r1,s2); - y14 = L_sub(r3,s4); - y16 = L_add(r3,s4); + y[6] = CL_msu_j(rs1,rs2); + y[9] = CL_mac_j(rs1,rs2); + y[7] = CL_mac_j(rs3,rs4); + y[8] = CL_msu_j(rs3,rs4); - y13 = L_sub(s1,r2); - y19 = L_add(s1,r2); - y15 = L_add(s3,r4); - y17 = L_sub(s3,r4); /* 3. FFT5 stage */ - - /* real part */ - r1 = L_add(x22,x28); - r4 = L_sub(x22,x28); - r3 = L_add(x24,x26); - r2 = L_sub(x24,x26); - t = Mpy_32_xx(L_sub(r1,r3),C54); - r1 = L_add(r1,r3); - y20 = L_add(x20,r1); - r1 = L_add(y20,(L_shl(Mpy_32_xx(r1,C55),1))); - r3 = L_sub(r1,t); - r1 = L_add(r1,t); - t = Mpy_32_xx((L_add(r4,r2)),C51); - r4 = L_add(t,L_shl(Mpy_32_xx(r4,C52),1)); - r2 = L_add(t,Mpy_32_xx(r2,C53)); - - /* imaginary part */ - s1 = L_add(x23,x29); - s4 = L_sub(x23,x29); - s3 = L_add(x25,x27); - s2 = L_sub(x25,x27); - t = Mpy_32_xx(L_sub(s1,s3),C54); - s1 = L_add(s1,s3); - y21 = L_add(x21,s1); - s1 = L_add(y21,L_shl(Mpy_32_xx(s1,C55),1)); - s3 = L_sub(s1,t); - s1 = L_add(s1,t); - t = Mpy_32_xx(L_add(s4,s2),C51); - s4 = L_add(t,L_shl(Mpy_32_xx(s4,C52),1)); - s2 = L_add(t,Mpy_32_xx(s2,C53)); + rs1 = CL_add(x[11],x[14]); + rs4 = CL_sub(x[11],x[14]); + rs3 = CL_add(x[12],x[13]); + rs2 = CL_sub(x[12],x[13]); + t = CL_scale_t(CL_sub(rs1,rs3),C54); + rs1 = CL_add(rs1,rs3); + y[10] = CL_add(x[10],rs1); + rs1 = CL_add(y[10],(CL_shl(CL_scale_t(rs1,C55),1))); + rs3 = CL_sub(rs1,t); + rs1 = CL_add(rs1,t); + t = CL_scale_t(CL_add(rs4,rs2),C51); + rs4 = CL_add(t,CL_shl(CL_scale_t(rs4, C52),1)); + rs2 = CL_add(t,CL_scale_t(rs2,C53)); /* combination */ - y22 = L_add(r1,s2); - y28 = L_sub(r1,s2); - y24 = L_sub(r3,s4); - y26 = L_add(r3,s4); + y[11] = CL_msu_j(rs1,rs2); + y[14] = CL_mac_j(rs1,rs2); + y[12] = CL_mac_j(rs3,rs4); + y[13] = CL_msu_j(rs3,rs4); + /*for (i=10; i<15; i++) + { + printf("%d,\t %d,\t",y[i].re, y[i].im); + } + printf("\n\n");*/ - y23 = L_sub(s1,r2); - y29 = L_add(s1,r2); - y25 = L_add(s3,r4); - y27 = L_sub(s3,r4); /* 1. FFT3 stage */ - /* real part */ - r1 = L_add(y10,y20); - r2 = Mpy_32_xx(L_sub(y10,y20),C31); - z30 = L_add(y00,r1); - r1 = L_sub(y00,L_shr(r1,1)); + rs1 = CL_add(y[5],y[10]); + rs2 = CL_scale_t(CL_sub(y[5],y[10]),C31); + z[15] = CL_add(y[0],rs1); + rs1 = CL_sub(y[0],CL_shr(rs1,1)); - /* imaginary part */ - s1 = L_add(y11,y21); - s2 = Mpy_32_xx(L_sub(y11,y21),C31); - z31 = L_add(y01,s1); - s1 = L_sub(y01,L_shr(s1,1)); - - /* combination */ - z50 = L_sub(r1,s2); - z40 = L_add(r1,s2); - z51 = L_add(s1,r2); - z41 = L_sub(s1,r2); + z[25] = CL_mac_j(rs1,rs2); + z[20] = CL_msu_j(rs1,rs2); /* 2. FFT3 stage */ + rs1 = CL_add(y[6],y[11]); + rs2 = CL_scale_t(CL_sub(y[6],y[11]),C31); + z[21] = CL_add(y[1],rs1); + rs1 = CL_sub(y[1],CL_shr(rs1,1)); - /* real part */ - r1 = L_add(y12,y22); - r2 = Mpy_32_xx(L_sub(y12,y22),C31); - z42 = L_add(y02,r1); - r1 = L_sub(y02,L_shr(r1,1)); - - /* imaginary part */ - s1 = L_add(y13,y23); - s2 = Mpy_32_xx(L_sub(y13,y23),C31); - z43 = L_add(y03,s1); - s1 = L_sub(y03,L_shr(s1,1)); + z[16] = CL_mac_j(rs1,rs2); + z[26] = CL_msu_j(rs1,rs2); - /* combination */ - z32 = L_sub(r1,s2); - z52 = L_add(r1,s2); - z33 = L_add(s1,r2); - z53 = L_sub(s1,r2); /* 3. FFT3 stage */ + rs1 = CL_add(y[7],y[12]); + rs2 = CL_scale_t(CL_sub(y[7],y[12]),C31); + z[27] = CL_add(y[2],rs1); + rs1 = CL_sub(y[2],CL_shr(rs1,1)); - /* real part */ - r1 = L_add(y14,y24); - r2 = Mpy_32_xx(L_sub(y14,y24),C31); - z54 = L_add(y04,r1); - r1 = L_sub(y04,L_shr(r1,1)); - - /* imaginary part */ - s1 = L_add(y15,y25); - s2 = Mpy_32_xx(L_sub(y15,y25),C31); - z55 = L_add(y05,s1); - s1 = L_sub(y05,L_shr(s1,1)); + z[22] = CL_mac_j(rs1,rs2); + z[17] = CL_msu_j(rs1,rs2); - /* combination */ - z44 = L_sub(r1,s2); - z34 = L_add(r1,s2); - z45 = L_add(s1,r2); - z35 = L_sub(s1,r2); /* 4. FFT3 stage */ + rs1 = CL_add(y[8],y[13]); + rs2 = CL_scale_t(CL_sub(y[8],y[13]),C31); + z[18] = CL_add(y[3],rs1); + rs1 = CL_sub(y[3],CL_shr(rs1,1)); - /* real part */ - r1 = L_add(y16,y26); - r2 = Mpy_32_xx(L_sub(y16,y26),C31); - z36 = L_add(y06,r1); - r1 = L_sub(y06,L_shr(r1,1)); - - /* imaginary part */ - s1 = L_add(y17,y27); - s2 = Mpy_32_xx(L_sub(y17,y27),C31); - z37 = L_add(y07,s1); - s1 = L_sub(y07,L_shr(s1,1)); + z[28] = CL_mac_j(rs1,rs2); + z[23] = CL_msu_j(rs1,rs2); - /* combination */ - z56 = L_sub(r1,s2); - z46 = L_add(r1,s2); - z57 = L_add(s1,r2); - z47 = L_sub(s1,r2); /* 5. FFT3 stage */ + rs1 = CL_add(y[9],y[14]); + rs2 = CL_scale_t(CL_sub(y[9],y[14]),C31); + z[24] = CL_add(y[4],rs1); + rs1 = CL_sub(y[4],CL_shr(rs1,1)); - /* real part */ - r1 = L_add(y18,y28); - r2 = Mpy_32_xx(L_sub(y18,y28),C31); - z48 = L_add(y08,r1); - r1 = L_sub(y08,L_shr(r1,1)); - - /* imaginary part */ - s1 = L_add(y19,y29); - s2 = Mpy_32_xx(L_sub(y19,y29),C31); - z49 = L_add(y09,s1); - s1 = L_sub(y09,L_shr(s1,1)); + z[19] = CL_mac_j(rs1,rs2); + z[29] = CL_msu_j(rs1,rs2); - /* combination */ - z38 = L_sub(r1,s2); - z58 = L_add(r1,s2); - z39 = L_add(s1,r2); - z59 = L_sub(s1,r2); + /*for (i=0; i<30; i++) + printf("%d,\t %d,\t",z[i].re, z[i].im); + printf("\n\n");*/ /* 1. FFT2 stage */ - r1 = L_shr(z00,SCALEFACTOR30_2); - r2 = L_shr(z30,SCALEFACTOR30_2); - r3 = L_shr(z01,SCALEFACTOR30_2); - r4 = L_shr(z31,SCALEFACTOR30_2); - *rel = L_add(r1,r2); - move32(); - *reh = L_sub(r1,r2); - move32(); - *iml = L_add(r3,r4); - move32(); - *imh = L_sub(r3,r4); - move32(); - rel+=s, reh+=s, iml+=s; - imh+=s; + rs1 = CL_shr(z[0], SCALEFACTOR30_2); + rs2 = CL_shr(z[15],SCALEFACTOR30_2); + *l = CL_add(rs1,rs2); + *h = CL_sub(rs1,rs2); + l+=1; h+=1; /* 2. FFT2 stage */ - r1 = L_shr(z16,SCALEFACTOR30_2); - r2 = L_shr(z46,SCALEFACTOR30_2); - r3 = L_shr(z17,SCALEFACTOR30_2); - r4 = L_shr(z47,SCALEFACTOR30_2); - *reh = L_add(r1,r2); - move32(); - *rel = L_sub(r1,r2); - move32(); - *imh = L_add(r3,r4); - move32(); - *iml = L_sub(r3,r4); - move32(); - rel+=s, reh+=s, iml+=s; - imh+=s; + rs1 = CL_shr(z[8], SCALEFACTOR30_2); + rs2 = CL_shr(z[23],SCALEFACTOR30_2); + *h = CL_add(rs1,rs2); + *l = CL_sub(rs1,rs2); + l+=1; h+=1; + /* 3. FFT2 stage */ - r1 = L_shr(z02,SCALEFACTOR30_2); - r2 = L_shr(z32,SCALEFACTOR30_2); - r3 = L_shr(z03,SCALEFACTOR30_2); - r4 = L_shr(z33,SCALEFACTOR30_2); - *rel = L_add(r1,r2); - move32(); - *reh = L_sub(r1,r2); - move32(); - *iml = L_add(r3,r4); - move32(); - *imh = L_sub(r3,r4); - move32(); - rel+=s, reh+=s, iml+=s; - imh+=s; + rs1 = CL_shr(z[1], SCALEFACTOR30_2); + rs2 = CL_shr(z[16],SCALEFACTOR30_2); + *l = CL_add(rs1,rs2); + *h = CL_sub(rs1,rs2); + l+=1; h+=1; + /* 4. FFT2 stage */ - r1 = L_shr(z18,SCALEFACTOR30_2); - r2 = L_shr(z48,SCALEFACTOR30_2); - r3 = L_shr(z19,SCALEFACTOR30_2); - r4 = L_shr(z49,SCALEFACTOR30_2); - *reh = L_add(r1,r2); - move32(); - *rel = L_sub(r1,r2); - move32(); - *imh = L_add(r3,r4); - move32(); - *iml = L_sub(r3,r4); - move32(); - rel+=s, reh+=s, iml+=s; - imh+=s; + rs1 = CL_shr(z[9], SCALEFACTOR30_2); + rs2 = CL_shr(z[24],SCALEFACTOR30_2); + *h = CL_add(rs1,rs2); + *l = CL_sub(rs1,rs2); + l+=1; h+=1; /* 5. FFT2 stage */ - r1 = L_shr(z04,SCALEFACTOR30_2); - r2 = L_shr(z34,SCALEFACTOR30_2); - r3 = L_shr(z05,SCALEFACTOR30_2); - r4 = L_shr(z35,SCALEFACTOR30_2); - *rel = L_add(r1,r2); - move32(); - *reh = L_sub(r1,r2); - move32(); - *iml = L_add(r3,r4); - move32(); - *imh = L_sub(r3,r4); - move32(); - rel+=s, reh+=s, iml+=s; - imh+=s; + rs1 = CL_shr(z[2], SCALEFACTOR30_2); + rs2 = CL_shr(z[17],SCALEFACTOR30_2); + *l = CL_add(rs1,rs2); + *h = CL_sub(rs1,rs2); + l+=1; h+=1; /* 6. FFT2 stage */ - r1 = L_shr(z20,SCALEFACTOR30_2); - r2 = L_shr(z50,SCALEFACTOR30_2); - r3 = L_shr(z21,SCALEFACTOR30_2); - r4 = L_shr(z51,SCALEFACTOR30_2); - *reh = L_add(r1,r2); - move32(); - *rel = L_sub(r1,r2); - move32(); - *imh = L_add(r3,r4); - move32(); - *iml = L_sub(r3,r4); - move32(); - rel+=s, reh+=s, iml+=s; - imh+=s; + rs1 = CL_shr(z[10], SCALEFACTOR30_2); + rs2 = CL_shr(z[25],SCALEFACTOR30_2); + *h = CL_add(rs1,rs2); + *l = CL_sub(rs1,rs2); + l+=1; h+=1; /* 7. FFT2 stage */ - r1 = L_shr(z06,SCALEFACTOR30_2); - r2 = L_shr(z36,SCALEFACTOR30_2); - r3 = L_shr(z07,SCALEFACTOR30_2); - r4 = L_shr(z37,SCALEFACTOR30_2); - *rel = L_add(r1,r2); - move32(); - *reh = L_sub(r1,r2); - move32(); - *iml = L_add(r3,r4); - move32(); - *imh = L_sub(r3,r4); - move32(); - rel+=s, reh+=s, iml+=s; - imh+=s; + rs1 = CL_shr(z[3], SCALEFACTOR30_2); + rs2 = CL_shr(z[18],SCALEFACTOR30_2); + *l = CL_add(rs1,rs2); + *h = CL_sub(rs1,rs2); + l+=1; h+=1; /* 8. FFT2 stage */ - r1 = L_shr(z22,SCALEFACTOR30_2); - r2 = L_shr(z52,SCALEFACTOR30_2); - r3 = L_shr(z23,SCALEFACTOR30_2); - r4 = L_shr(z53,SCALEFACTOR30_2); - *reh = L_add(r1,r2); - move32(); - *rel = L_sub(r1,r2); - move32(); - *imh = L_add(r3,r4); - move32(); - *iml = L_sub(r3,r4); - move32(); - rel+=s, reh+=s, iml+=s; - imh+=s; + rs1 = CL_shr(z[11], SCALEFACTOR30_2); + rs2 = CL_shr(z[26],SCALEFACTOR30_2); + *h = CL_add(rs1,rs2); + *l = CL_sub(rs1,rs2); + l+=1; h+=1; /* 9. FFT2 stage */ - r1 = L_shr(z08,SCALEFACTOR30_2); - r2 = L_shr(z38,SCALEFACTOR30_2); - r3 = L_shr(z09,SCALEFACTOR30_2); - r4 = L_shr(z39,SCALEFACTOR30_2); - *rel = L_add(r1,r2); - move32(); - *reh = L_sub(r1,r2); - move32(); - *iml = L_add(r3,r4); - move32(); - *imh = L_sub(r3,r4); - move32(); - rel+=s, reh+=s, iml+=s; - imh+=s; + rs1 = CL_shr(z[4], SCALEFACTOR30_2); + rs2 = CL_shr(z[19],SCALEFACTOR30_2); + *l = CL_add(rs1,rs2); + *h = CL_sub(rs1,rs2); + l+=1; h+=1; /* 10. FFT2 stage */ - r1 = L_shr(z24,SCALEFACTOR30_2); - r2 = L_shr(z54,SCALEFACTOR30_2); - r3 = L_shr(z25,SCALEFACTOR30_2); - r4 = L_shr(z55,SCALEFACTOR30_2); - *reh = L_add(r1,r2); - move32(); - *rel = L_sub(r1,r2); - move32(); - *imh = L_add(r3,r4); - move32(); - *iml = L_sub(r3,r4); - move32(); - rel+=s, reh+=s, iml+=s; - imh+=s; + rs1 = CL_shr(z[12], SCALEFACTOR30_2); + rs2 = CL_shr(z[27],SCALEFACTOR30_2); + *h = CL_add(rs1,rs2); + *l = CL_sub(rs1,rs2); + l+=1; h+=1; /* 11. FFT2 stage */ - r1 = L_shr(z10,SCALEFACTOR30_2); - r2 = L_shr(z40,SCALEFACTOR30_2); - r3 = L_shr(z11,SCALEFACTOR30_2); - r4 = L_shr(z41,SCALEFACTOR30_2); - *rel = L_add(r1,r2); - move32(); - *reh = L_sub(r1,r2); - move32(); - *iml = L_add(r3,r4); - move32(); - *imh = L_sub(r3,r4); - move32(); - rel+=s, reh+=s, iml+=s; - imh+=s; + rs1 = CL_shr(z[5], SCALEFACTOR30_2); + rs2 = CL_shr(z[20],SCALEFACTOR30_2); + *l = CL_add(rs1,rs2); + *h = CL_sub(rs1,rs2); + l+=1; h+=1; /* 12. FFT2 stage */ - r1 = L_shr(z26,SCALEFACTOR30_2); - r2 = L_shr(z56,SCALEFACTOR30_2); - r3 = L_shr(z27,SCALEFACTOR30_2); - r4 = L_shr(z57,SCALEFACTOR30_2); - *reh = L_add(r1,r2); - move32(); - *rel = L_sub(r1,r2); - move32(); - *imh = L_add(r3,r4); - move32(); - *iml = L_sub(r3,r4); - move32(); - rel+=s, reh+=s, iml+=s; - imh+=s; + rs1 = CL_shr(z[13], SCALEFACTOR30_2); + rs2 = CL_shr(z[28],SCALEFACTOR30_2); + *h = CL_add(rs1,rs2); + *l = CL_sub(rs1,rs2); + l+=1; h+=1; /* 13. FFT2 stage */ - r1 = L_shr(z12,SCALEFACTOR30_2); - r2 = L_shr(z42,SCALEFACTOR30_2); - r3 = L_shr(z13,SCALEFACTOR30_2); - r4 = L_shr(z43,SCALEFACTOR30_2); - *rel = L_add(r1,r2); - move32(); - *reh = L_sub(r1,r2); - move32(); - *iml = L_add(r3,r4); - move32(); - *imh = L_sub(r3,r4); - move32(); - rel+=s, reh+=s, iml+=s; - imh+=s; + rs1 = CL_shr(z[6], SCALEFACTOR30_2); + rs2 = CL_shr(z[21],SCALEFACTOR30_2); + *l = CL_add(rs1,rs2); + *h = CL_sub(rs1,rs2); + l+=1; h+=1; /* 14. FFT2 stage */ - r1 = L_shr(z28,SCALEFACTOR30_2); - r2 = L_shr(z58,SCALEFACTOR30_2); - r3 = L_shr(z29,SCALEFACTOR30_2); - r4 = L_shr(z59,SCALEFACTOR30_2); - *reh = L_add(r1,r2); - move32(); - *rel = L_sub(r1,r2); - move32(); - *imh = L_add(r3,r4); - move32(); - *iml = L_sub(r3,r4); - move32(); - rel+=s, reh+=s, iml+=s; - imh+=s; + rs1 = CL_shr(z[14], SCALEFACTOR30_2); + rs2 = CL_shr(z[29],SCALEFACTOR30_2); + *h = CL_add(rs1,rs2); + *l = CL_sub(rs1,rs2); + l+=1; h+=1; /* 15. FFT2 stage */ - r1 = L_shr(z14,SCALEFACTOR30_2); - r2 = L_shr(z44,SCALEFACTOR30_2); - r3 = L_shr(z15,SCALEFACTOR30_2); - r4 = L_shr(z45,SCALEFACTOR30_2); - *rel = L_add(r1,r2); - move32(); - *reh = L_sub(r1,r2); - move32(); - *iml = L_add(r3,r4); - move32(); - *imh = L_sub(r3,r4); - move32(); - rel+=s, reh+=s, iml+=s; - imh+=s; + rs1 = CL_shr(z[7], SCALEFACTOR30_2); + rs2 = CL_shr(z[22],SCALEFACTOR30_2); + *l = CL_add(rs1,rs2); + *h = CL_sub(rs1,rs2); + l+=1; h+=1; + +#if (WMOPS) + multiCounter[currCounter].CL_move += 30; +#endif } @@ -2498,617 +1409,365 @@ static void fft30(Word32 *re, Word32 *im, Word16 s) * * \return void */ -static void fft32(Word32 * re, Word32 * im, Word16 s) -{ - Word32 as,bs; - Word32 x00,x01,x02,x03,x04,x05,x06,x07; - Word32 x08,x09,x10,x11,x12,x13,x14,x15; - Word32 t00,t01,t02,t03,t04,t05,t06,t07; - Word32 t08,t09,t10,t11,t12,t13,t14,t15; - Word32 s00,s01,s02,s03,s04,s05,s06,s07; - Word32 s08,s09,s10,s11,s12,s13,s14,s15; - - Word32 y00,y01,y02,y03,y04,y05,y06,y07; - Word32 y08,y09,y10,y11,y12,y13,y14,y15; - Word32 y16,y17,y18,y19,y20,y21,y22,y23; - Word32 y24,y25,y26,y27,y28,y29,y30,y31; - Word32 y32,y33,y34,y35,y36,y37,y38,y39; - Word32 y40,y41,y42,y43,y44,y45,y46,y47; - Word32 y48,y49,y50,y51,y52,y53,y54,y55; - Word32 y56,y57,y58,y59,y60,y61,y62,y63; - +static void fft32_with_cmplx_data(cmplx * inp) +{ + cmplx x[32], y[32], t[32], s[32], temp, temp1; + const cmplx_s *pRotVector_32 = ( const cmplx_s *)RotVector_32; + /* 1. FFT8 stage */ - x00 = L_shr(re[s* 0],SCALEFACTOR32_1); - x01 = L_shr(im[s* 0],SCALEFACTOR32_1); - x02 = L_shr(re[s* 4],SCALEFACTOR32_1); - x03 = L_shr(im[s* 4],SCALEFACTOR32_1); - x04 = L_shr(re[s* 8],SCALEFACTOR32_1); - x05 = L_shr(im[s* 8],SCALEFACTOR32_1); - x06 = L_shr(re[s*12],SCALEFACTOR32_1); - x07 = L_shr(im[s*12],SCALEFACTOR32_1); - x08 = L_shr(re[s*16],SCALEFACTOR32_1); - x09 = L_shr(im[s*16],SCALEFACTOR32_1); - x10 = L_shr(re[s*20],SCALEFACTOR32_1); - x11 = L_shr(im[s*20],SCALEFACTOR32_1); - x12 = L_shr(re[s*24],SCALEFACTOR32_1); - x13 = L_shr(im[s*24],SCALEFACTOR32_1); - x14 = L_shr(re[s*28],SCALEFACTOR32_1); - x15 = L_shr(im[s*28],SCALEFACTOR32_1); - - t00 = L_add(x00,x08); - t02 = L_sub(x00,x08); - t01 = L_add(x01,x09); - t03 = L_sub(x01,x09); - t04 = L_add(x02,x10); - t06 = L_sub(x02,x10); - t05 = L_add(x03,x11); - t07 = L_sub(x03,x11); - t08 = L_add(x04,x12); - t10 = L_sub(x04,x12); - t09 = L_add(x05,x13); - t11 = L_sub(x05,x13); - t12 = L_add(x06,x14); - t14 = L_sub(x06,x14); - t13 = L_add(x07,x15); - t15 = L_sub(x07,x15); + + x[0] = CL_shr(inp[0], SCALEFACTOR32_1); + x[1] = CL_shr(inp[4], SCALEFACTOR32_1); + x[2] = CL_shr(inp[8], SCALEFACTOR32_1); + x[3] = CL_shr(inp[12], SCALEFACTOR32_1); + x[4] = CL_shr(inp[16], SCALEFACTOR32_1); + x[5] = CL_shr(inp[20], SCALEFACTOR32_1); + x[6] = CL_shr(inp[24], SCALEFACTOR32_1); + x[7] = CL_shr(inp[28], SCALEFACTOR32_1); + + + t[0] = CL_add(x[0],x[4]); + t[1] = CL_sub(x[0],x[4]); + t[2] = CL_add(x[1],x[5]); + t[3] = CL_sub(x[1],x[5]); + t[4] = CL_add(x[2],x[6]); + t[5] = CL_sub(x[2],x[6]); + t[6] = CL_add(x[3],x[7]); + t[7] = CL_sub(x[3],x[7]); /* Pre-additions and core multiplications */ - s00 = L_add(t00,t08); - s04 = L_sub(t00,t08); - s01 = L_add(t01,t09); - s05 = L_sub(t01,t09); - s08 = L_sub(t02,t11); - s10 = L_add(t02,t11); - s09 = L_add(t03,t10); - s11 = L_sub(t03,t10); - s02 = L_add(t04,t12); - s07 = L_sub(t04,t12); - s03 = L_add(t05,t13); - s06 = L_sub(t13,t05); - t01 = L_add(t06,t14); - t02 = L_sub(t06,t14); - t00 = L_add(t07,t15); - t03 = L_sub(t07,t15); - - s12 = Mpy_32_xx(L_add(t00,t02),C81); - s14 = Mpy_32_xx(L_sub(t00,t02),C81); - s13 = Mpy_32_xx(L_sub(t03,t01),C81); - s15 = Mpy_32_xx(L_add(t01,t03),C82); - /* Post-additions */ - y00 = L_add(s00,s02); - y08 = L_sub(s00,s02); - y01 = L_add(s01,s03); - y09 = L_sub(s01,s03); - y04 = L_sub(s04,s06); - y12 = L_add(s04,s06); - y05 = L_sub(s05,s07); - y13 = L_add(s05,s07); - y06 = L_add(s08,s14); - y14 = L_sub(s08,s14); - y07 = L_add(s09,s15); - y15 = L_sub(s09,s15); - y02 = L_add(s10,s12); - y10 = L_sub(s10,s12); - y03 = L_add(s11,s13); - y11 = L_sub(s11,s13); + s[0] = CL_add(t[0], t[4]); + s[2] = CL_sub(t[0], t[4]); + s[4] = CL_mac_j(t[1], t[5]); + s[5] = CL_msu_j(t[1], t[5]); + s[1] = CL_add(t[2], t[6]); + s[3] = CL_sub(t[2], t[6]); + s[3] = CL_mul_j(s[3]); + + temp = CL_add(t[3], t[7]); + temp1 = CL_sub(t[3], t[7]); + s[6] = CL_scale_t(CL_msu_j(temp1, temp), C81); + s[7] = CL_dscale_t(CL_swap_real_imag( CL_msu_j(temp, temp1)), C81, C82); + + + y[0] = CL_add(s[0],s[1]); + y[4] = CL_sub(s[0],s[1]); + y[2] = CL_sub(s[2],s[3]); + y[6] = CL_add(s[2],s[3]); + y[3] = CL_add(s[4],s[7]); + y[7] = CL_sub(s[4],s[7]); + y[1] = CL_add(s[5],s[6]); + y[5] = CL_sub(s[5],s[6]); /* 2. FFT8 stage */ - x00 = L_shr(re[s* 1],SCALEFACTOR32_1); - x01 = L_shr(im[s* 1],SCALEFACTOR32_1); - x02 = L_shr(re[s* 5],SCALEFACTOR32_1); - x03 = L_shr(im[s* 5],SCALEFACTOR32_1); - x04 = L_shr(re[s* 9],SCALEFACTOR32_1); - x05 = L_shr(im[s* 9],SCALEFACTOR32_1); - x06 = L_shr(re[s*13],SCALEFACTOR32_1); - x07 = L_shr(im[s*13],SCALEFACTOR32_1); - x08 = L_shr(re[s*17],SCALEFACTOR32_1); - x09 = L_shr(im[s*17],SCALEFACTOR32_1); - x10 = L_shr(re[s*21],SCALEFACTOR32_1); - x11 = L_shr(im[s*21],SCALEFACTOR32_1); - x12 = L_shr(re[s*25],SCALEFACTOR32_1); - x13 = L_shr(im[s*25],SCALEFACTOR32_1); - x14 = L_shr(re[s*29],SCALEFACTOR32_1); - x15 = L_shr(im[s*29],SCALEFACTOR32_1); - - t00 = L_add(x00,x08); - t02 = L_sub(x00,x08); - t01 = L_add(x01,x09); - t03 = L_sub(x01,x09); - t04 = L_add(x02,x10); - t06 = L_sub(x02,x10); - t05 = L_add(x03,x11); - t07 = L_sub(x03,x11); - t08 = L_add(x04,x12); - t10 = L_sub(x04,x12); - t09 = L_add(x05,x13); - t11 = L_sub(x05,x13); - t12 = L_add(x06,x14); - t14 = L_sub(x06,x14); - t13 = L_add(x07,x15); - t15 = L_sub(x07,x15); + + x[0] = CL_shr(inp[1], SCALEFACTOR32_1); + x[1] = CL_shr(inp[5], SCALEFACTOR32_1); + x[2] = CL_shr(inp[9], SCALEFACTOR32_1); + x[3] = CL_shr(inp[13], SCALEFACTOR32_1); + x[4] = CL_shr(inp[17], SCALEFACTOR32_1); + x[5] = CL_shr(inp[21], SCALEFACTOR32_1); + x[6] = CL_shr(inp[25], SCALEFACTOR32_1); + x[7] = CL_shr(inp[29], SCALEFACTOR32_1); + + + t[0] = CL_add(x[0],x[4]); + t[1] = CL_sub(x[0],x[4]); + t[2] = CL_add(x[1],x[5]); + t[3] = CL_sub(x[1],x[5]); + t[4] = CL_add(x[2],x[6]); + t[5] = CL_sub(x[2],x[6]); + t[6] = CL_add(x[3],x[7]); + t[7] = CL_sub(x[3],x[7]); /* Pre-additions and core multiplications */ - s00 = L_add(t00,t08); - s04 = L_sub(t00,t08); - s01 = L_add(t01,t09); - s05 = L_sub(t01,t09); - s08 = L_sub(t02,t11); - s10 = L_add(t02,t11); - s09 = L_add(t03,t10); - s11 = L_sub(t03,t10); - s02 = L_add(t04,t12); - s07 = L_sub(t04,t12); - s03 = L_add(t05,t13); - s06 = L_sub(t13,t05); - t01 = L_add(t06,t14); - t02 = L_sub(t06,t14); - t00 = L_add(t07,t15); - t03 = L_sub(t07,t15); - - s12 = Mpy_32_xx(L_add(t00,t02),C81); - s14 = Mpy_32_xx(L_sub(t00,t02),C81); - s13 = Mpy_32_xx(L_sub(t03,t01),C81); - s15 = Mpy_32_xx(L_add(t01,t03),C82); + + s[0] = CL_add(t[0], t[4]); + s[2] = CL_sub(t[0], t[4]); + s[4] = CL_mac_j(t[1], t[5]); + s[5] = CL_msu_j(t[1], t[5]); + s[1] = CL_add(t[2], t[6]); + s[3] = CL_sub(t[2], t[6]); + s[3] = CL_mul_j(s[3]); + + temp = CL_add(t[3], t[7]); + temp1 = CL_sub(t[3], t[7]); + s[6] = CL_scale_t(CL_msu_j(temp1, temp), C81); + s[7] = CL_dscale_t(CL_swap_real_imag( CL_msu_j(temp, temp1)), C81, C82); /* Post-additions */ - y16 = L_add(s00,s02); - y24 = L_sub(s00,s02); - y17 = L_add(s01,s03); - y25 = L_sub(s01,s03); - y20 = L_sub(s04,s06); - y28 = L_add(s04,s06); - y21 = L_sub(s05,s07); - y29 = L_add(s05,s07); - y22 = L_add(s08,s14); - y30 = L_sub(s08,s14); - y23 = L_add(s09,s15); - y31 = L_sub(s09,s15); - y18 = L_add(s10,s12); - y26 = L_sub(s10,s12); - y19 = L_add(s11,s13); - y27 = L_sub(s11,s13); + + y[8] = CL_add(s[0],s[1]); + y[12] = CL_sub(s[0],s[1]); + y[10] = CL_sub(s[2],s[3]); + y[14] = CL_add(s[2],s[3]); + y[11] = CL_add(s[4],s[7]); + y[15] = CL_sub(s[4],s[7]); + y[9] = CL_add(s[5],s[6]); + y[13] = CL_sub(s[5],s[6]); /* 3. FFT8 stage */ - x00 = L_shr(re[s* 2],SCALEFACTOR32_1); - x01 = L_shr(im[s* 2],SCALEFACTOR32_1); - x02 = L_shr(re[s* 6],SCALEFACTOR32_1); - x03 = L_shr(im[s* 6],SCALEFACTOR32_1); - x04 = L_shr(re[s*10],SCALEFACTOR32_1); - x05 = L_shr(im[s*10],SCALEFACTOR32_1); - x06 = L_shr(re[s*14],SCALEFACTOR32_1); - x07 = L_shr(im[s*14],SCALEFACTOR32_1); - x08 = L_shr(re[s*18],SCALEFACTOR32_1); - x09 = L_shr(im[s*18],SCALEFACTOR32_1); - x10 = L_shr(re[s*22],SCALEFACTOR32_1); - x11 = L_shr(im[s*22],SCALEFACTOR32_1); - x12 = L_shr(re[s*26],SCALEFACTOR32_1); - x13 = L_shr(im[s*26],SCALEFACTOR32_1); - x14 = L_shr(re[s*30],SCALEFACTOR32_1); - x15 = L_shr(im[s*30],SCALEFACTOR32_1); - - t00 = L_add(x00,x08); - t02 = L_sub(x00,x08); - t01 = L_add(x01,x09); - t03 = L_sub(x01,x09); - t04 = L_add(x02,x10); - t06 = L_sub(x02,x10); - t05 = L_add(x03,x11); - t07 = L_sub(x03,x11); - t08 = L_add(x04,x12); - t10 = L_sub(x04,x12); - t09 = L_add(x05,x13); - t11 = L_sub(x05,x13); - t12 = L_add(x06,x14); - t14 = L_sub(x06,x14); - t13 = L_add(x07,x15); - t15 = L_sub(x07,x15); + + x[0] = CL_shr(inp[2], SCALEFACTOR32_1); + x[1] = CL_shr(inp[6], SCALEFACTOR32_1); + x[2] = CL_shr(inp[10], SCALEFACTOR32_1); + x[3] = CL_shr(inp[14], SCALEFACTOR32_1); + x[4] = CL_shr(inp[18], SCALEFACTOR32_1); + x[5] = CL_shr(inp[22], SCALEFACTOR32_1); + x[6] = CL_shr(inp[26], SCALEFACTOR32_1); + x[7] = CL_shr(inp[30], SCALEFACTOR32_1); + + + t[0] = CL_add(x[0],x[4]); + t[1] = CL_sub(x[0],x[4]); + t[2] = CL_add(x[1],x[5]); + t[3] = CL_sub(x[1],x[5]); + t[4] = CL_add(x[2],x[6]); + t[5] = CL_sub(x[2],x[6]); + t[6] = CL_add(x[3],x[7]); + t[7] = CL_sub(x[3],x[7]); /* Pre-additions and core multiplications */ - s00 = L_add(t00,t08); - s04 = L_sub(t00,t08); - s01 = L_add(t01,t09); - s05 = L_sub(t01,t09); - s08 = L_sub(t02,t11); - s10 = L_add(t02,t11); - s09 = L_add(t03,t10); - s11 = L_sub(t03,t10); - s02 = L_add(t04,t12); - s07 = L_sub(t04,t12); - s03 = L_add(t05,t13); - s06 = L_sub(t13,t05); - t01 = L_add(t06,t14); - t02 = L_sub(t06,t14); - t00 = L_add(t07,t15); - t03 = L_sub(t07,t15); - - s12 = Mpy_32_xx(L_add(t00,t02),C81); - s14 = Mpy_32_xx(L_sub(t00,t02),C81); - s13 = Mpy_32_xx(L_sub(t03,t01),C81); - s15 = Mpy_32_xx(L_add(t01,t03),C82); + + s[0] = CL_add(t[0], t[4]); + s[2] = CL_sub(t[0], t[4]); + s[4] = CL_mac_j(t[1], t[5]); + s[5] = CL_msu_j(t[1], t[5]); + s[1] = CL_add(t[2], t[6]); + s[3] = CL_sub(t[2], t[6]); + s[3] = CL_mul_j(s[3]); + + temp = CL_add(t[3], t[7]); + temp1 = CL_sub(t[3], t[7]); + s[6] = CL_scale_t(CL_msu_j(temp1, temp), C81); + s[7] = CL_dscale_t(CL_swap_real_imag( CL_msu_j(temp, temp1)), C81, C82); /* Post-additions */ - y32 = L_add(s00,s02); - y40 = L_sub(s00,s02); - y33 = L_add(s01,s03); - y41 = L_sub(s01,s03); - y36 = L_sub(s04,s06); - y44 = L_add(s04,s06); - y37 = L_sub(s05,s07); - y45 = L_add(s05,s07); - y38 = L_add(s08,s14); - y46 = L_sub(s08,s14); - y39 = L_add(s09,s15); - y47 = L_sub(s09,s15); - y34 = L_add(s10,s12); - y42 = L_sub(s10,s12); - y35 = L_add(s11,s13); - y43 = L_sub(s11,s13); + + y[16] = CL_add(s[0],s[1]); + y[20] = CL_sub(s[0],s[1]); + y[18] = CL_sub(s[2],s[3]); + y[22] = CL_add(s[2],s[3]); + y[19] = CL_add(s[4],s[7]); + y[23] = CL_sub(s[4],s[7]); + y[17] = CL_add(s[5],s[6]); + y[21] = CL_sub(s[5],s[6]); /* 4. FFT8 stage */ - x00 = L_shr(re[s* 3],SCALEFACTOR32_1); - x01 = L_shr(im[s* 3],SCALEFACTOR32_1); - x02 = L_shr(re[s* 7],SCALEFACTOR32_1); - x03 = L_shr(im[s* 7],SCALEFACTOR32_1); - x04 = L_shr(re[s*11],SCALEFACTOR32_1); - x05 = L_shr(im[s*11],SCALEFACTOR32_1); - x06 = L_shr(re[s*15],SCALEFACTOR32_1); - x07 = L_shr(im[s*15],SCALEFACTOR32_1); - x08 = L_shr(re[s*19],SCALEFACTOR32_1); - x09 = L_shr(im[s*19],SCALEFACTOR32_1); - x10 = L_shr(re[s*23],SCALEFACTOR32_1); - x11 = L_shr(im[s*23],SCALEFACTOR32_1); - x12 = L_shr(re[s*27],SCALEFACTOR32_1); - x13 = L_shr(im[s*27],SCALEFACTOR32_1); - x14 = L_shr(re[s*31],SCALEFACTOR32_1); - x15 = L_shr(im[s*31],SCALEFACTOR32_1); - - t00 = L_add(x00,x08); - t02 = L_sub(x00,x08); - t01 = L_add(x01,x09); - t03 = L_sub(x01,x09); - t04 = L_add(x02,x10); - t06 = L_sub(x02,x10); - t05 = L_add(x03,x11); - t07 = L_sub(x03,x11); - t08 = L_add(x04,x12); - t10 = L_sub(x04,x12); - t09 = L_add(x05,x13); - t11 = L_sub(x05,x13); - t12 = L_add(x06,x14); - t14 = L_sub(x06,x14); - t13 = L_add(x07,x15); - t15 = L_sub(x07,x15); + + x[0] = CL_shr(inp[3], SCALEFACTOR32_1); + x[1] = CL_shr(inp[7], SCALEFACTOR32_1); + x[2] = CL_shr(inp[11], SCALEFACTOR32_1); + x[3] = CL_shr(inp[15], SCALEFACTOR32_1); + x[4] = CL_shr(inp[19], SCALEFACTOR32_1); + x[5] = CL_shr(inp[23], SCALEFACTOR32_1); + x[6] = CL_shr(inp[27], SCALEFACTOR32_1); + x[7] = CL_shr(inp[31], SCALEFACTOR32_1); + + + t[0] = CL_add(x[0],x[4]); + t[1] = CL_sub(x[0],x[4]); + t[2] = CL_add(x[1],x[5]); + t[3] = CL_sub(x[1],x[5]); + t[4] = CL_add(x[2],x[6]); + t[5] = CL_sub(x[2],x[6]); + t[6] = CL_add(x[3],x[7]); + t[7] = CL_sub(x[3],x[7]); + /* Pre-additions and core multiplications */ - s00 = L_add(t00,t08); - s04 = L_sub(t00,t08); - s01 = L_add(t01,t09); - s05 = L_sub(t01,t09); - s08 = L_sub(t02,t11); - s10 = L_add(t02,t11); - s09 = L_add(t03,t10); - s11 = L_sub(t03,t10); - s02 = L_add(t04,t12); - s07 = L_sub(t04,t12); - s03 = L_add(t05,t13); - s06 = L_sub(t13,t05); - t01 = L_add(t06,t14); - t02 = L_sub(t06,t14); - t00 = L_add(t07,t15); - t03 = L_sub(t07,t15); - - s12 = Mpy_32_xx(L_add(t00,t02),C81); - s14 = Mpy_32_xx(L_sub(t00,t02),C81); - s13 = Mpy_32_xx(L_sub(t03,t01),C81); - s15 = Mpy_32_xx(L_add(t01,t03),C82); + + s[0] = CL_add(t[0], t[4]); + s[2] = CL_sub(t[0], t[4]); + s[4] = CL_mac_j(t[1], t[5]); + s[5] = CL_msu_j(t[1], t[5]); + s[1] = CL_add(t[2], t[6]); + s[3] = CL_sub(t[2], t[6]); + s[3] = CL_mul_j(s[3]); + + temp = CL_add(t[3], t[7]); + temp1 = CL_sub(t[3], t[7]); + s[6] = CL_scale_t(CL_msu_j(temp1, temp), C81); + s[7] = CL_dscale_t(CL_swap_real_imag( CL_msu_j(temp, temp1)), C81, C82); /* Post-additions */ - y48 = L_add(s00,s02); - y56 = L_sub(s00,s02); - y49 = L_add(s01,s03); - y57 = L_sub(s01,s03); - y52 = L_sub(s04,s06); - y60 = L_add(s04,s06); - y53 = L_sub(s05,s07); - y61 = L_add(s05,s07); - y54 = L_add(s08,s14); - y62 = L_sub(s08,s14); - y55 = L_add(s09,s15); - y63 = L_sub(s09,s15); - y50 = L_add(s10,s12); - y58 = L_sub(s10,s12); - y51 = L_add(s11,s13); - y59 = L_sub(s11,s13); + + y[24] = CL_add(s[0],s[1]); + y[28] = CL_sub(s[0],s[1]); + y[26] = CL_sub(s[2],s[3]); + y[30] = CL_add(s[2],s[3]); + y[27] = CL_add(s[4],s[7]); + y[31] = CL_sub(s[4],s[7]); + y[25] = CL_add(s[5],s[6]); + y[29] = CL_sub(s[5],s[6]); + /* apply twiddle factors */ - y00 = L_shr(y00,SCALEFACTOR32_2); - y01 = L_shr(y01,SCALEFACTOR32_2); - y02 = L_shr(y02,SCALEFACTOR32_2); - y03 = L_shr(y03,SCALEFACTOR32_2); - y04 = L_shr(y04,SCALEFACTOR32_2); - y05 = L_shr(y05,SCALEFACTOR32_2); - y06 = L_shr(y06,SCALEFACTOR32_2); - y07 = L_shr(y07,SCALEFACTOR32_2); - y08 = L_shr(y08,SCALEFACTOR32_2); - y09 = L_shr(y09,SCALEFACTOR32_2); - y10 = L_shr(y10,SCALEFACTOR32_2); - y11 = L_shr(y11,SCALEFACTOR32_2); - y12 = L_shr(y12,SCALEFACTOR32_2); - y13 = L_shr(y13,SCALEFACTOR32_2); - y14 = L_shr(y14,SCALEFACTOR32_2); - y15 = L_shr(y15,SCALEFACTOR32_2); - y16 = L_shr(y16,SCALEFACTOR32_2); - y17 = L_shr(y17,SCALEFACTOR32_2); - y32 = L_shr(y32,SCALEFACTOR32_2); - y33 = L_shr(y33,SCALEFACTOR32_2); - y48 = L_shr(y48,SCALEFACTOR32_2); - y49 = L_shr(y49,SCALEFACTOR32_2); - y40 = L_shr(y40,SCALEFACTOR32_2); - y41 = L_shr(y41,SCALEFACTOR32_2); - - cplxMpy3_0(y18, y19, RotVector_32[2* 0+0], RotVector_32[2* 0+1]); - cplxMpy3_0(y20, y21, RotVector_32[2* 1+0], RotVector_32[2* 1+1]); - cplxMpy3_0(y22, y23, RotVector_32[2* 2+0], RotVector_32[2* 2+1]); - cplxMpy3_0(y24, y25, RotVector_32[2* 3+0], RotVector_32[2* 3+1]); - cplxMpy3_0(y26, y27, RotVector_32[2* 4+0], RotVector_32[2* 4+1]); - cplxMpy3_0(y28, y29, RotVector_32[2* 5+0], RotVector_32[2* 5+1]); - cplxMpy3_0(y30, y31, RotVector_32[2* 6+0], RotVector_32[2* 6+1]); - cplxMpy3_0(y34, y35, RotVector_32[2* 7+0], RotVector_32[2* 7+1]); - cplxMpy3_0(y36, y37, RotVector_32[2* 8+0], RotVector_32[2* 8+1]); - cplxMpy3_0(y38, y39, RotVector_32[2* 9+0], RotVector_32[2* 9+1]); - cplxMpy3_0(y42, y43, RotVector_32[2*10+0], RotVector_32[2*10+1]); - cplxMpy3_0(y44, y45, RotVector_32[2*11+0], RotVector_32[2*11+1]); - cplxMpy3_0(y46, y47, RotVector_32[2*12+0], RotVector_32[2*12+1]); - cplxMpy3_0(y50, y51, RotVector_32[2*13+0], RotVector_32[2*13+1]); - cplxMpy3_0(y52, y53, RotVector_32[2*14+0], RotVector_32[2*14+1]); - cplxMpy3_0(y54, y55, RotVector_32[2*15+0], RotVector_32[2*15+1]); - cplxMpy3_0(y56, y57, RotVector_32[2*16+0], RotVector_32[2*16+1]); - cplxMpy3_0(y58, y59, RotVector_32[2*17+0], RotVector_32[2*17+1]); - cplxMpy3_0(y60, y61, RotVector_32[2*18+0], RotVector_32[2*18+1]); - cplxMpy3_0(y62, y63, RotVector_32[2*19+0], RotVector_32[2*19+1]); + y[0] = CL_shr(y[0],SCALEFACTOR32_2); + y[1] = CL_shr(y[1],SCALEFACTOR32_2); + y[2] = CL_shr(y[2],SCALEFACTOR32_2); + y[3] = CL_shr(y[3],SCALEFACTOR32_2); + y[4] = CL_shr(y[4],SCALEFACTOR32_2); + y[5] = CL_shr(y[5],SCALEFACTOR32_2); + y[6] = CL_shr(y[6],SCALEFACTOR32_2); + y[7] = CL_shr(y[7],SCALEFACTOR32_2); + y[8] = CL_shr(y[8],SCALEFACTOR32_2); + y[16] = CL_shr(y[16],SCALEFACTOR32_2); + y[24] = CL_shr(y[24],SCALEFACTOR32_2); + y[20] = CL_shr(y[20],SCALEFACTOR32_2); + + + y[9] = CL_mult_32x16((CL_shr(y[9],1)), pRotVector_32[ 0 ]); + y[10] = CL_mult_32x16((CL_shr(y[10],1)), pRotVector_32[ 1 ]); + y[11] = CL_mult_32x16((CL_shr(y[11],1)), pRotVector_32[ 2 ]); + y[12] = CL_mult_32x16((CL_shr(y[12],1)), pRotVector_32[ 3 ]); + y[13] = CL_mult_32x16((CL_shr(y[13],1)), pRotVector_32[ 4 ]); + y[14] = CL_mult_32x16((CL_shr(y[14],1)), pRotVector_32[ 5 ]); + y[15] = CL_mult_32x16((CL_shr(y[15],1)), pRotVector_32[ 6 ]); + y[17] = CL_mult_32x16((CL_shr(y[17],1)), pRotVector_32[ 7 ]); + y[18] = CL_mult_32x16((CL_shr(y[18],1)), pRotVector_32[ 8 ]); + y[19] = CL_mult_32x16((CL_shr(y[19],1)), pRotVector_32[ 9 ]); + y[21] = CL_mult_32x16((CL_shr(y[21],1)), pRotVector_32[ 10 ]); + y[22] = CL_mult_32x16((CL_shr(y[22],1)), pRotVector_32[ 11 ]); + y[23] = CL_mult_32x16((CL_shr(y[23],1)), pRotVector_32[ 12 ]); + y[25] = CL_mult_32x16((CL_shr(y[25],1)), pRotVector_32[ 13 ]); + y[26] = CL_mult_32x16((CL_shr(y[26],1)), pRotVector_32[ 14 ]); + y[27] = CL_mult_32x16((CL_shr(y[27],1)), pRotVector_32[ 15 ]); + y[28] = CL_mult_32x16((CL_shr(y[28],1)), pRotVector_32[ 16 ]); + y[29] = CL_mult_32x16((CL_shr(y[29],1)), pRotVector_32[ 17 ]); + y[30] = CL_mult_32x16((CL_shr(y[30],1)), pRotVector_32[ 18 ]); + y[31] = CL_mult_32x16((CL_shr(y[31],1)), pRotVector_32[ 19 ]); /* 1. FFT4 stage */ - /* Pre-additions */ - t00 = L_add(y00,y32); - t02 = L_sub(y00,y32); - t01 = L_add(y01,y33); - t03 = L_sub(y01,y33); - t04 = L_add(y16,y48); - t07 = L_sub(y16,y48); - t05 = L_add(y49,y17); - t06 = L_sub(y49,y17); + /* Pre-additions */ + t[0] = CL_add(y[0],y[16]); + t[1] = CL_sub(y[0],y[16]); + t[2] = CL_add(y[8],y[24]); + t[3] = CL_mul_j(CL_sub(y[8],y[24])); - /* Post-additions */ - re[s* 0] = L_add(t00,t04); - move32(); - im[s* 0] = L_add(t01,t05); - move32(); - re[s* 8] = L_sub(t02,t06); - move32(); - im[s* 8] = L_sub(t03,t07); - move32(); - re[s*16] = L_sub(t00,t04); - move32(); - im[s*16] = L_sub(t01,t05); - move32(); - re[s*24] = L_add(t02,t06); - move32(); - im[s*24] = L_add(t03,t07); - move32(); + /* Post-additions */ + inp[0] = CL_add(t[0], t[2]); + inp[8] = CL_sub(t[1], t[3]); + inp[16] = CL_sub(t[0], t[2]); + inp[24] = CL_add(t[1], t[3]); /* 2. FFT4 stage */ - /* Pre-additions */ - t00 = L_add(y02,y34); - t02 = L_sub(y02,y34); - t01 = L_add(y03,y35); - t03 = L_sub(y03,y35); - t04 = L_add(y18,y50); - t07 = L_sub(y18,y50); - t05 = L_add(y51,y19); - t06 = L_sub(y51,y19); + /* Pre-additions */ + t[0] = CL_add(y[1],y[17]); + t[1] = CL_sub(y[1],y[17]); + t[2] = CL_add(y[9],y[25]); + t[3] = CL_mul_j(CL_sub(y[9],y[25])); + + /* Post-additions */ + inp[1] = CL_add(t[0], t[2]); + inp[9] = CL_sub(t[1], t[3]); + inp[17] = CL_sub(t[0], t[2]); + inp[25] = CL_add(t[1], t[3]); - /* Post-additions */ - re[s* 1] = L_add(t00,t04); - move32(); - im[s* 1] = L_add(t01,t05); - move32(); - re[s* 9] = L_sub(t02,t06); - move32(); - im[s* 9] = L_sub(t03,t07); - move32(); - re[s*17] = L_sub(t00,t04); - move32(); - im[s*17] = L_sub(t01,t05); - move32(); - re[s*25] = L_add(t02,t06); - move32(); - im[s*25] = L_add(t03,t07); - move32(); /* 3. FFT4 stage */ - /* Pre-additions */ - t00 = L_add(y04,y36); - t02 = L_sub(y04,y36); - t01 = L_add(y05,y37); - t03 = L_sub(y05,y37); - t04 = L_add(y20,y52); - t07 = L_sub(y20,y52); - t05 = L_add(y53,y21); - t06 = L_sub(y53,y21); + /* Pre-additions */ + t[0] = CL_add(y[2],y[18]); + t[1] = CL_sub(y[2],y[18]); + t[2] = CL_add(y[10],y[26]); + t[3] = CL_mul_j(CL_sub(y[10],y[26])); + + /* Post-additions */ + inp[2] = CL_add(t[0], t[2]); + inp[10] = CL_sub(t[1], t[3]); + inp[18] = CL_sub(t[0], t[2]); + inp[26] = CL_add(t[1], t[3]); - /* Post-additions */ - re[s* 2] = L_add(t00,t04); - move32(); - im[s* 2] = L_add(t01,t05); - move32(); - re[s*10] = L_sub(t02,t06); - move32(); - im[s*10] = L_sub(t03,t07); - move32(); - re[s*18] = L_sub(t00,t04); - move32(); - im[s*18] = L_sub(t01,t05); - move32(); - re[s*26] = L_add(t02,t06); - move32(); - im[s*26] = L_add(t03,t07); - move32(); /* 4. FFT4 stage */ - /* Pre-additions */ - t00 = L_add(y06,y38); - t02 = L_sub(y06,y38); - t01 = L_add(y07,y39); - t03 = L_sub(y07,y39); - t04 = L_add(y22,y54); - t07 = L_sub(y22,y54); - t05 = L_add(y55,y23); - t06 = L_sub(y55,y23); + /* Pre-additions */ + t[0] = CL_add(y[3],y[19]); + t[1] = CL_sub(y[3],y[19]); + t[2] = CL_add(y[11],y[27]); + t[3] = CL_mul_j(CL_sub(y[11],y[27])); + + + /* Post-additions */ + inp[3] = CL_add(t[0], t[2]); + inp[11] = CL_sub(t[1], t[3]); + inp[19] = CL_sub(t[0], t[2]); + inp[27] = CL_add(t[1], t[3]); - /* Post-additions */ - re[s* 3] = L_add(t00,t04); - move32(); - im[s* 3] = L_add(t01,t05); - move32(); - re[s*11] = L_sub(t02,t06); - move32(); - im[s*11] = L_sub(t03,t07); - move32(); - re[s*19] = L_sub(t00,t04); - move32(); - im[s*19] = L_sub(t01,t05); - move32(); - re[s*27] = L_add(t02,t06); - move32(); - im[s*27] = L_add(t03,t07); - move32(); /* 5. FFT4 stage */ - /* Pre-additions */ - t00 = L_add(y08,y41); - t02 = L_sub(y08,y41); - t01 = L_sub(y09,y40); - t03 = L_add(y09,y40); - t04 = L_add(y24,y56); - t07 = L_sub(y24,y56); - t05 = L_add(y57,y25); - t06 = L_sub(y57,y25); + /* Pre-additions */ + t[0] = CL_msu_j(y[4],y[20]); + t[1] = CL_mac_j(y[4],y[20]); + t[2] = CL_add(y[12],y[28]); + t[3] = CL_mul_j(CL_sub(y[12],y[28])); + + + /* Post-additions */ + inp[4] = CL_add(t[0], t[2]); + inp[12] = CL_sub(t[1], t[3]); + inp[20] = CL_sub(t[0], t[2]); + inp[28] = CL_add(t[1], t[3]); - /* Post-additions */ - re[s* 4] = L_add(t00,t04); - move32(); - im[s* 4] = L_add(t01,t05); - move32(); - re[s*12] = L_sub(t02,t06); - move32(); - im[s*12] = L_sub(t03,t07); - move32(); - re[s*20] = L_sub(t00,t04); - move32(); - im[s*20] = L_sub(t01,t05); - move32(); - re[s*28] = L_add(t02,t06); - move32(); - im[s*28] = L_add(t03,t07); - move32(); /* 6. FFT4 stage */ - /* Pre-additions */ - t00 = L_add(y10,y42); - t02 = L_sub(y10,y42); - t01 = L_add(y11,y43); - t03 = L_sub(y11,y43); - t04 = L_add(y26,y58); - t07 = L_sub(y26,y58); - t05 = L_add(y59,y27); - t06 = L_sub(y59,y27); + /* Pre-additions */ + t[0] = CL_add(y[5],y[21]); + t[1] = CL_sub(y[5],y[21]); + t[2] = CL_add(y[13],y[29]); + t[3] = CL_mul_j(CL_sub(y[13],y[29])); + + + /* Post-additions */ + inp[5] = CL_add(t[0], t[2]); + inp[13] = CL_sub(t[1], t[3]); + inp[21] = CL_sub(t[0], t[2]); + inp[29] = CL_add(t[1], t[3]); - /* Post-additions */ - re[s* 5] = L_add(t00,t04); - move32(); - im[s* 5] = L_add(t01,t05); - move32(); - re[s*13] = L_sub(t02,t06); - move32(); - im[s*13] = L_sub(t03,t07); - move32(); - re[s*21] = L_sub(t00,t04); - move32(); - im[s*21] = L_sub(t01,t05); - move32(); - re[s*29] = L_add(t02,t06); - move32(); - im[s*29] = L_add(t03,t07); - move32(); /* 7. FFT4 stage */ - /* Pre-additions */ - t00 = L_add(y12,y44); - t02 = L_sub(y12,y44); - t01 = L_add(y13,y45); - t03 = L_sub(y13,y45); - t04 = L_add(y28,y60); - t07 = L_sub(y28,y60); - t05 = L_add(y61,y29); - t06 = L_sub(y61,y29); + /* Pre-additions */ + t[0] = CL_add(y[6],y[22]); + t[1] = CL_sub(y[6],y[22]); + t[2] = CL_add(y[14],y[30]); + t[3] = CL_mul_j(CL_sub(y[14],y[30])); + + + /* Post-additions */ + inp[6] = CL_add(t[0], t[2]); + inp[14] = CL_sub(t[1], t[3]); + inp[22] = CL_sub(t[0], t[2]); + inp[30] = CL_add(t[1], t[3]); - /* Post-additions */ - re[s* 6] = L_add(t00,t04); - move32(); - im[s* 6] = L_add(t01,t05); - move32(); - re[s*14] = L_sub(t02,t06); - move32(); - im[s*14] = L_sub(t03,t07); - move32(); - re[s*22] = L_sub(t00,t04); - move32(); - im[s*22] = L_sub(t01,t05); - move32(); - re[s*30] = L_add(t02,t06); - move32(); - im[s*30] = L_add(t03,t07); - move32(); /* 8. FFT4 stage */ - /* Pre-additions */ - t00 = L_add(y14,y46); - t02 = L_sub(y14,y46); - t01 = L_add(y15,y47); - t03 = L_sub(y15,y47); - t04 = L_add(y30,y62); - t07 = L_sub(y30,y62); - t05 = L_add(y63,y31); - t06 = L_sub(y63,y31); + /* Pre-additions */ + t[0] = CL_add(y[7],y[23]); + t[1] = CL_sub(y[7],y[23]); + t[2] = CL_add(y[15],y[31]); + t[3] = CL_mul_j(CL_sub(y[15],y[31])); + + + /* Post-additions */ + inp[7] = CL_add(t[0], t[2]); + inp[15] = CL_sub(t[1], t[3]); + inp[23] = CL_sub(t[0], t[2]); + inp[31] = CL_add(t[1], t[3]); + +#if (WMOPS) + multiCounter[currCounter].CL_move += 32; +#endif - /* Post-additions */ - re[s* 7] = L_add(t00,t04); - move32(); - im[s* 7] = L_add(t01,t05); - move32(); - re[s*15] = L_sub(t02,t06); - move32(); - im[s*15] = L_sub(t03,t07); - move32(); - re[s*23] = L_sub(t00,t04); - move32(); - im[s*23] = L_sub(t01,t05); - move32(); - re[s*31] = L_add(t02,t06); - move32(); - im[s*31] = L_add(t03,t07); - move32(); } @@ -3129,334 +1788,318 @@ static void fft32(Word32 * re, Word32 * im, Word16 s) * * \return void */ + static void fftN2( - Word32 *re, - Word32 *im, - const Word16 *W, - Word16 len, - Word16 dim1, - Word16 dim2, - Word16 sx, - Word16 sc, - Word32 *x, - Word16 Woff + cmplx *__restrict pComplexBuf, + const Word16 *__restrict W, + Word16 len, + Word16 dim1, + Word16 dim2, + Word16 sc, + Word32 *x, + Word16 Woff ) { - Word16 i,j; - Word32 y[2*20]; - - - assert( len == (dim1*dim2) ); - assert( (dim1==3) || (dim1==5) || (dim1==8) || (dim1==10) || (dim1==15) || (dim1==16) || (dim1==20) || (dim1==30) || (dim1==32) ); - assert( (dim2==4) || (dim2==8) || (dim2==10) || (dim2==12) || (dim2==16) || (dim2==20) ); - - FOR (i=0; i /*-----------------------------------------------------------------* @@ -61,27 +59,27 @@ void DoRTFTn_fx( move16(); } - IF (sub(n, 16) == 0) + IF (EQ_16(n, 16)) { - cdftForw_fx(2*n,z,Ip_fft16_fx,w_fft16_fx); + cdftForw_fx(2*n,z,Ip_fft16_fx,w_fft512_fx); } - ELSE IF (sub(n, 32) == 0) + ELSE IF (EQ_16(n, 32)) { - cdftForw_fx(2*n,z,Ip_fft32_fx,w_fft32_fx); + cdftForw_fx(2*n,z,Ip_fft32_fx,w_fft512_fx); } - ELSE IF (sub(n, 64) == 0) + ELSE IF (EQ_16(n, 64)) { - cdftForw_fx(2*n,z,Ip_fft64_fx,w_fft64_fx); + cdftForw_fx(2*n,z,Ip_fft64_fx,w_fft512_fx); } - ELSE IF (sub(n, 128) == 0) + ELSE IF (EQ_16(n, 128)) { - cdftForw_fx(2*n,z,Ip_fft128_fx,w_fft128_fx); + cdftForw_fx(2*n,z,Ip_fft128_fx,w_fft512_fx); } - ELSE IF (sub(n, 256) == 0) + ELSE IF (EQ_16(n, 256)) { - cdftForw_fx(2*n,z,Ip_fft256_fx,w_fft256_fx); + cdftForw_fx(2*n,z,Ip_fft256_fx,w_fft512_fx); } - ELSE IF (sub(n, 512) == 0) + ELSE IF (EQ_16(n, 512)) { cdftForw_fx(2*n,z,Ip_fft512_fx,w_fft512_fx); } @@ -158,10 +156,10 @@ static void bitrv2_SR_fx( { j1 = add(shl(j, 1), ip[k]); k1 = add(shl(k, 1), ip[j]); - xr = L_add(0,a[j1]); - xi = L_add(0,a[j1 + 1]); - yr = L_add(0,a[k1]); - yi = L_add(0,a[k1 + 1]); + xr = a[j1]; move32(); + xi = a[j1 + 1]; move32(); + yr = a[k1]; move32(); + yi = a[k1 + 1]; move32(); a[j1] = yr; move32(); a[j1 + 1] = yi; @@ -172,10 +170,10 @@ static void bitrv2_SR_fx( move32(); j1 = add(j1, m2); k1 = add(k1, shl(m2, 1)); - xr = L_add(0,a[j1]); - xi = L_add(0,a[j1 + 1]); - yr = L_add(0,a[k1]); - yi = L_add(0,a[k1 + 1]); + xr = a[j1]; move32(); + xi = a[j1 + 1]; move32(); + yr = a[k1]; move32(); + yi = a[k1 + 1]; move32(); a[j1] = yr; move32(); a[j1 + 1] = yi; @@ -186,11 +184,11 @@ static void bitrv2_SR_fx( move32(); j1 = add(j1, m2); k1 = sub(k1, m2); - xr = L_add(0,a[j1]); - xi = L_add(0,a[j1 + 1]); - xi = L_add(0,a[j1 + 1]); - yr = L_add(0,a[k1]); - yi = L_add(0,a[k1 + 1]); + xr = a[j1]; move32(); + xi = a[j1 + 1]; move32(); + xi = a[j1 + 1]; move32(); + yr = a[k1]; move32(); + yi = a[k1 + 1]; move32(); a[j1] = yr; move32(); a[j1 + 1] = yi; @@ -201,10 +199,10 @@ static void bitrv2_SR_fx( move32(); j1 = add(j1, m2); k1 = add(k1, shl(m2, 1)); - xr = L_add(0,a[j1]); - xi = L_add(0,a[j1 + 1]); - yr = L_add(0,a[k1]); - yi = L_add(0,a[k1 + 1]); + xr = a[j1]; move32(); + xi = a[j1 + 1]; move32(); + yr = a[k1]; move32(); + yi = a[k1 + 1]; move32(); a[j1] = yr; move32(); a[j1 + 1] = yi; @@ -217,10 +215,10 @@ static void bitrv2_SR_fx( j1 = add(add(shl(k, 1), m2), ip[k]); k1 = add(j1, m2); - xr = L_add(0,a[j1]); - xi = L_add(0,a[j1 + 1]); - yr = L_add(0,a[k1]); - yi = L_add(0,a[k1 + 1]); + xr = a[j1]; move32(); + xi = a[j1 + 1]; move32(); + yr = a[k1]; move32(); + yi = a[k1 + 1]; move32(); a[j1] = yr; move32(); a[j1 + 1] = yi; @@ -239,10 +237,10 @@ static void bitrv2_SR_fx( { j1 = add(shl(j, 1), ip[k]); k1 = add(shl(k, 1), ip[j]); - xr = L_add(0,a[j1]); - xi = L_add(0,a[j1 + 1]); - yr = L_add(0,a[k1]); - yi = L_add(0,a[k1 + 1]); + xr = a[j1]; move32(); + xi = a[j1 + 1]; move32(); + yr = a[k1]; move32(); + yi = a[k1 + 1]; move32(); a[j1] = yr; move32(); a[j1 + 1] = yi; @@ -253,10 +251,10 @@ static void bitrv2_SR_fx( move32(); j1 = add(j1, m2); k1 = add(k1, m2); - xr = L_add(0,a[j1]); - xi = L_add(0,a[j1 + 1]); - yr = L_add(0,a[k1]); - yi = L_add(0,a[k1 + 1]); + xr = a[j1]; move32(); + xi = a[j1 + 1]; move32(); + yr = a[k1]; move32(); + yi = a[k1 + 1]; move32(); a[j1] = yr; move32(); a[j1 + 1] = yi; @@ -723,14 +721,14 @@ static void cftbsub_fx( l = 8; move16(); - WHILE (sub(shl(l, 2), n) < 0) + WHILE (LT_16(shl(l, 2), n)) { cftmdl_fx(n, l, a, w); l = shl(l, 2); } } - IF (sub(shl(l, 2), n) == 0) + IF (EQ_16(shl(l, 2), n)) { FOR (j = 0; j < l; j += 2) { @@ -800,7 +798,7 @@ static void rftfsub_fx( tmp = shl(nc, 1); ks = 0; move16(); - WHILE (sub(tmp, m) >= 0) + WHILE (GE_16(tmp, m)) { ks = add(ks, 1); tmp = sub(tmp, m); @@ -847,7 +845,7 @@ static void rftbsub_fx( tmp = shl(nc, 1); ks = 0; move16(); - WHILE (sub(tmp, m) >= 0) + WHILE (GE_16(tmp, m)) { ks = add(ks, 1); tmp = sub(tmp, m); @@ -896,7 +894,7 @@ static void dctsub_fx( move16(); ks = 0; move16(); - WHILE (sub(tmp, n) >= 0) + WHILE (GE_16(tmp, n)) { ks = add(ks, 1); tmp = sub(tmp, n); @@ -948,7 +946,7 @@ void edct2_fx( nw = ip[0]; move16(); - if (sub(n, shl(nw, 2)) > 0) + if (GT_16(n, shl(nw, 2))) { nw = shr(n, 2); } @@ -1294,7 +1292,7 @@ static void fft64_16fx( move16(); } - cdftForw_16fx(128,z,Ip_fft64_16fx,w_fft64_16fx); + cdftForw_16fx(128, z, Ip_fft64_16fx, w_fft128_16fx); move16();/*penalty for 1 ptr init */ FOR( i=0; i<64 ; i++) @@ -1486,14 +1484,14 @@ static void bitrv2_SR_16fx( m = 1; move16(); - WHILE (sub(shl(m,3),l) < 0) + WHILE (LT_16(shl(m,3),l)) { l = shr(l,1); m = shl(m,1); } m2 = shl(m,1); - IF (sub(shl(m, 3),l) == 0) + IF (EQ_16(shl(m, 3),l)) { FOR (k = 0; k < m; k++) { @@ -1659,19 +1657,19 @@ static void cftfsub_16fx( l = 2; move16(); - IF (sub(n,8) > 0) + IF (GT_16(n,8)) { cft1st_16fx(n, a, w); l = 8; move16(); - WHILE (sub(shl(l, 2),n) < 0) + WHILE (LT_16(shl(l, 2),n)) { cftmdl_16fx(n, l, a, w); l = shl(l,2); } } - IF (sub(shl(l,2),n) == 0) + IF (EQ_16(shl(l,2),n)) { FOR (j = 0; j < l; j += 2) { @@ -1814,10 +1812,10 @@ static void cft1st_16fx( k1 = add(k1,2); k2 = shl(k1,1); - wk2r = L_add(0,w[k1]); - wk2i = L_add(0,w[k1 + 1]); - wk1r = L_add(0,w[k2]); - wk1i = L_add(0,w[k2 + 1]); + wk2r = w[k1]; move32(); + wk2i = w[k1 + 1]; move32(); + wk1r = w[k2]; move32(); + wk1i = w[k2 + 1]; move32(); L_tmp = L_shl(Mult_32_32(wk2i,wk1i),1);/*Q29 */ wk3r = L_sub(wk1r,L_shl(L_tmp,1));/*Q30 */ @@ -1868,8 +1866,8 @@ static void cft1st_16fx( L_tmp = Madd_32_16(L_tmp,wk3i,x0r); /*Q(15+Qx+Q_edct) */ a[j + 7] = round_fx(L_shl(L_tmp,1)); /*Q(Qx+Q_edct) */ - wk1r = L_add(0,w[k2 + 2]); - wk1i = L_add(0,w[k2 + 3]); + wk1r = w[k2 + 2]; move32(); + wk1i = w[k2 + 3]; move32(); L_tmp = L_shl(Mult_32_32(wk2r,wk1i),1);/*Q29 */ wk3r = L_sub(wk1r,L_shl(L_tmp,1)); /*Q30 */ @@ -2030,10 +2028,10 @@ static void cftmdl_16fx( { k1 = add(k1,2); k2 = shl(k1,1); - wk2r = L_add(0,w[k1]); - wk2i = L_add(0,w[k1 + 1]); - wk1r = L_add(0,w[k2]); - wk1i = L_add(0,w[k2 + 1]); + wk2r = w[k1]; move32(); + wk2i = w[k1 + 1]; move32(); + wk1r = w[k2]; move32(); + wk1i = w[k2 + 1]; move32(); L_tmp = L_shl(Mult_32_32(wk2i,wk1i),1);/*Q29 */ wk3r = L_sub(wk1r,L_shl(L_tmp,1));/*Q30 */ diff --git a/lib_com/fft_rel_fx.c b/lib_com/fft_rel_fx.c index 8430895ed396546e3e1cf7e78bdf59c86f389a14..da5d6096fbbf740e3f6182268b4514615855a522 100644 --- a/lib_com/fft_rel_fx.c +++ b/lib_com/fft_rel_fx.c @@ -1,14 +1,13 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "prot_fx.h" /* Function prototypes */ #include "rom_com_fx.h" /* Static table prototypes */ #include "stl.h" -#include "wmc_auto.h" - +#include "stdint.h" /*------------------------------------------------------------------ * * This is an implementation of decimation-in-time FFT algorithm for @@ -84,27 +83,28 @@ static void c_fft_fx( Word16 tmp1,tmp2,tmp3,tmp4; const Word16 *table_ptr; const Word16 *input_ptr1,*input_ptr2,*input_ptr3,*input_ptr4; - + Word16 shift=0; /* Setup Reorder Variables */ table_ptr = NULL; - SWITCH (SIZE) - { - case 1024: - table_ptr = FFT_REORDER_1024; - BREAK; - case 512: - table_ptr = FFT_REORDER_512; - BREAK; - case 256: - table_ptr = FFT_reorder_256; - BREAK; - case 128: - table_ptr = FFT_REORDER_128; - BREAK; - case 64: - table_ptr = FFT_reorder_64; - BREAK; - } + table_ptr = FFT_REORDER_1024; + SWITCH(SIZE) + { + case 1024: + shift = 0; + BREAK; + case 512: + shift = 1; + BREAK; + case 256: + shift = 2; + BREAK; + case 128: + shift = 3; + BREAK; + case 64: + shift = 4; + BREAK; + } /* The FFT part */ IF (isign != 0) { @@ -124,18 +124,18 @@ static void c_fft_fx( * is counted as a move16() */ - input_ptr1 = in_ptr + *table_ptr++; + input_ptr1 = in_ptr + (const Word16 ) ((uintptr_t)(*table_ptr++)>>(uintptr_t)shift); L_tmp1 = L_mult(*input_ptr1++, 16384); L_tmp2 = L_mult(*input_ptr1, 16384); - input_ptr1 = in_ptr + *table_ptr++; + input_ptr1 = in_ptr + (const Word16)((uintptr_t)(*table_ptr++) >> (uintptr_t)shift); tmp1 = msu_r(L_tmp1, *input_ptr1, 16384); tmp3 = mac_r(L_tmp1, *input_ptr1++, 16384); - input_ptr2 = in_ptr + *table_ptr++; - input_ptr3 = in_ptr + *table_ptr++; + input_ptr2 = in_ptr + (const Word16)((uintptr_t)(*table_ptr++) >> (uintptr_t)shift); + input_ptr3 = in_ptr + (const Word16)((uintptr_t)(*table_ptr++) >> (uintptr_t)shift); L_tmp1 = L_mult(*input_ptr2++, 16384); tmp2 = mac_r(L_tmp1, *input_ptr3, 16384); @@ -227,12 +227,12 @@ static void c_fft_fx( * The addition of 'in_ptr' + and index value from 'reorder_ptr' * is counted as a move16() */ + input_ptr1= in_ptr + (const Word16)((uintptr_t)(*table_ptr++) >> (uintptr_t)shift); + input_ptr2 = in_ptr + (const Word16)((uintptr_t)(*table_ptr++) >> (uintptr_t)shift); - input_ptr1 = in_ptr + *table_ptr++; - input_ptr2 = in_ptr + *table_ptr++; + input_ptr3 = in_ptr + (const Word16)((uintptr_t)(*table_ptr++) >> (uintptr_t)shift); + input_ptr4 = in_ptr + (const Word16)((uintptr_t)(*table_ptr++) >> (uintptr_t)shift); - input_ptr3 = in_ptr + *table_ptr++; - input_ptr4 = in_ptr + *table_ptr++; tmp3 = sub(*input_ptr1, *input_ptr2); tmp4 = add(*input_ptr1++, *input_ptr2++); diff --git a/lib_com/fft_rel_sas_fx.c b/lib_com/fft_rel_sas_fx.c index b92c16be55bb412b36df31ec53cee7ac3d411802..66e4f5396fd7122fc6870ba9de987a1af1b37877 100644 --- a/lib_com/fft_rel_sas_fx.c +++ b/lib_com/fft_rel_sas_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -7,8 +7,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*---------------------------------------------------------------------* * Local constants @@ -67,7 +65,7 @@ void fft_rel_fx( move16(); FOR (i = 0; i < n-1; i++) { - IF (sub(i,j) < 0) + IF (LT_16(i,j)) { xt = x[j]; move16(); @@ -78,7 +76,7 @@ void fft_rel_fx( } x0++; k = shr(n,1); - WHILE (sub(k,j) <= 0) + WHILE (LE_16(k,j)) { j = sub(j,k); k = shr(k,1); @@ -224,7 +222,7 @@ void ifft_rel_fx( n8 = shr(n4,1); move16(); tmp = sub(n,1); - WHILE( sub(is,tmp) < 0 ) + WHILE( LT_16(is,tmp)) { xi1 = x + is + 1; move16(); @@ -247,7 +245,7 @@ void ifft_rel_fx( *xi4 = add(t1,shl(*xi4,1)); move16(); - IF (sub(n4,1) != 0) + IF (NE_16(n4,1)) { t1 = mult_r(sub(*(xi2+n8),*(xi1+n8)),INV_SQR2_FX); t2 = mult_r(add(*(xi4+n8),*(xi3+n8)),INV_SQR2_FX); @@ -309,7 +307,7 @@ void ifft_rel_fx( move16(); s3 += 3*step; move16(); - WHILE (sub(is,sub(n,1)) < 0) + WHILE (LT_16(is,sub(n,1))) { xup1 = x + j + is; move16(); @@ -425,7 +423,7 @@ void ifft_rel_fx( move16(); FOR (i=1; i #include "options.h" /* Compilation switches */ #include "cnst_fx.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ -#include "stl.h" -#include "wmc_auto.h" - /* required for wmc_tool */ +#include "stl.h" /* required for wmc_tool */ /*--------------------------------------------------------------------------* * fill_spectrum() @@ -82,11 +80,11 @@ void fill_spectrum_fx( move16(); test(); - IF ( sub(HQ_mode, HQ_TRANSIENT) == 0 ) + IF ( EQ_16(HQ_mode, HQ_TRANSIENT)) { last_sfm = sub(num_sfm, 1); } - ELSE IF ( sub(HQ_mode,HQ_GEN_SWB) == 0 || sub(HQ_mode,HQ_GEN_FB) == 0 ) + ELSE IF ( EQ_16(HQ_mode,HQ_GEN_SWB)||EQ_16(HQ_mode,HQ_GEN_FB)) { last_sfm = s_max(core_sfm,sub(num_env_bands,1)); } @@ -96,29 +94,29 @@ void fill_spectrum_fx( move16(); } - IF ( sub(HQ_mode, HQ_HARMONIC) == 0 ) + IF ( EQ_16(HQ_mode, HQ_HARMONIC)) { /*high_sfm = (core_brate == HQ_24k40) ? HVQ_THRES_SFM_24k-1 : HVQ_THRES_SFM_32k-3; */ high_sfm = sub(HVQ_THRES_SFM_32k, 1); - if (L_sub(L_core_brate, HQ_24k40) == 0) + if (EQ_32(L_core_brate, HQ_24k40)) { high_sfm = sub(HVQ_THRES_SFM_24k, 1); } - if( sub(last_sfm, high_sfm) < 0 ) + if( LT_16(last_sfm, high_sfm)) { last_sfm = high_sfm; move16(); } } - ELSE if ( sub(HQ_mode, HQ_HVQ) == 0 ) + ELSE if ( EQ_16(HQ_mode, HQ_HVQ)) { bin_th = sfm_end[last_sfm]; move16(); } /* Transient analysis for envelope stability measure */ - IF ( sub(length, L_FRAME32k) == 0 ) + IF ( EQ_16(length, L_FRAME32k)) { env_stab_transient_detect_fx( is_transient, length, norm, no_att_hangover, L_energy_lt, HQ_mode, bin_th, L_coeff_out, 12 ); } @@ -127,8 +125,8 @@ void fill_spectrum_fx( test(); test(); test(); - IF ( sub(length, L_FRAME16k) == 0 || - ((sub(length, L_FRAME32k) == 0 && sub(HQ_mode, HQ_HARMONIC) != 0 && sub(HQ_mode, HQ_HVQ) != 0) && *no_att_hangover == 0) ) + IF ( EQ_16(length, L_FRAME16k)|| + ((EQ_16(length, L_FRAME32k) && NE_16(HQ_mode, HQ_HARMONIC) && NE_16(HQ_mode, HQ_HVQ) ) && *no_att_hangover == 0) ) { /* Norm adjustment function */ env_adj_fx( npulses, length, last_sfm, norm_adj, env_stab, sfmsize ); @@ -140,7 +138,7 @@ void fill_spectrum_fx( test(); test(); test(); - if ( sub(length, L_FRAME32k) == 0 && ( (sub(env_stab, 16384) < 0 && *no_att_hangover == 0) || sub(HQ_mode, HQ_HVQ) == 0 ) ) + if ( EQ_16(length, L_FRAME32k)&&((LT_16(env_stab,16384)&&*no_att_hangover==0)||EQ_16(HQ_mode,HQ_HVQ))) { flag_32K_env_hangover = 1; move16(); @@ -151,7 +149,7 @@ void fill_spectrum_fx( * Build noise-fill codebook *----------------------------------------------------------------*/ - IF ( sub(HQ_mode, HQ_HVQ) != 0 ) + IF ( NE_16(HQ_mode, HQ_HVQ)) { cb_size = build_nf_codebook_fx(flag_32K_env_hangover, coeff, sfm_start, sfmsize, sfm_end, last_sfm, R, CodeBook, CodeBook_mod); } @@ -159,11 +157,11 @@ void fill_spectrum_fx( * Prepare fine structure for Harmonic and HVQ *----------------------------------------------------------------*/ - IF ( sub(HQ_mode, HQ_HARMONIC) == 0 ) + IF ( EQ_16(HQ_mode, HQ_HARMONIC)) { harm_bwe_fine_fx( R, last_sfm, high_sfm, num_sfm, norm, sfm_start, sfm_end, prev_L_swb_norm, coeff, L_coeff_out, coeff_fine ); } - ELSE IF ( sub(HQ_mode, HQ_HVQ) == 0 ) + ELSE IF ( EQ_16(HQ_mode, HQ_HVQ)) { hvq_bwe_fine_fx( last_sfm, num_sfm, sfm_end, peak_idx, Npeaks, peak_pos, prev_L_swb_norm, L_coeff_out, bwe_peaks, coeff_fine ); } @@ -173,7 +171,7 @@ void fill_spectrum_fx( *----------------------------------------------------------------*/ test(); - IF ( sub(HQ_mode, HQ_HVQ) != 0 && cb_size > 0 ) + IF ( NE_16(HQ_mode, HQ_HVQ)&&cb_size>0) { apply_noisefill_HQ_fx( R, length, flag_32K_env_hangover, L_core_brate, last_sfm, CodeBook, CodeBook_mod, cb_size, sfm_start, sfm_end, sfmsize, coeff ); @@ -195,8 +193,8 @@ void fill_spectrum_fx( test(); test(); test(); - IF( (sub(length, L_FRAME32k) >= 0 || L_sub(L_core_brate, HQ_32k) > 0 || L_sub(L_core_brate, HQ_24k40) < 0) - && sub(HQ_mode, HQ_HVQ) != 0 ) + IF( (GE_16(length, L_FRAME32k)||GT_32(L_core_brate,HQ_32k)||LT_32(L_core_brate,HQ_24k40)) + && NE_16(HQ_mode, HQ_HVQ) ) { apply_nf_gain_fx(nf_idx, last_sfm, R, sfm_start, sfm_end, coeff); } @@ -205,7 +203,7 @@ void fill_spectrum_fx( * Prepare fine strucutre for HQ GENERIC *----------------------------------------------------------------*/ test(); - IF ( sub(HQ_mode, HQ_GEN_SWB) == 0 || sub(HQ_mode, HQ_GEN_FB) == 0 ) + IF ( EQ_16(HQ_mode, HQ_GEN_SWB)||EQ_16(HQ_mode,HQ_GEN_FB)) { hq_generic_fine_fx( coeff, last_sfm, sfm_start, sfm_end, bwe_seed, coeff_fine ); } @@ -215,7 +213,7 @@ void fill_spectrum_fx( *----------------------------------------------------------------*/ test(); - IF ( sub(HQ_mode, HQ_HARMONIC) != 0 && sub(HQ_mode, HQ_HVQ) != 0 ) + IF ( NE_16(HQ_mode, HQ_HARMONIC)&&NE_16(HQ_mode,HQ_HVQ)) { apply_envelope_fx( coeff, norm, norm_adj, num_sfm, last_sfm, HQ_mode, length, sfm_start, sfm_end, L_normq_v, L_coeff_out, coeff_fine, L_coeff_out1 ); @@ -225,17 +223,17 @@ void fill_spectrum_fx( * Harmonic BWE, HVQ BWE and HQ SWB BWE *----------------------------------------------------------------*/ test(); - IF ( sub(HQ_mode, HQ_HARMONIC) == 0 ) + IF ( EQ_16(HQ_mode, HQ_HARMONIC)) { harm_bwe_fx( coeff_fine, coeff, num_sfm, sfm_start, sfm_end, last_sfm, R, prev_hq_mode, norm, noise_level, prev_noise_level, bwe_seed, L_coeff_out ); } - ELSE IF ( sub(HQ_mode, HQ_HVQ) == 0 ) + ELSE IF ( EQ_16(HQ_mode, HQ_HVQ)) { hvq_bwe_fx( L_coeff_out, coeff_fine, sfm_start, sfm_end, sfmsize, last_sfm, prev_hq_mode, bwe_peaks, bin_th, num_sfm, L_core_brate, R, norm, noise_level, prev_noise_level, bwe_seed, L_coeff_out, 15, 12 ); } - ELSE IF ( sub(HQ_mode, HQ_GEN_SWB) == 0 || sub(HQ_mode, HQ_GEN_FB) == 0 ) + ELSE IF ( EQ_16(HQ_mode, HQ_GEN_SWB)||EQ_16(HQ_mode,HQ_GEN_FB)) { hq_bwe_fx( HQ_mode, L_coeff_out1, hq_generic_fenv, L_coeff_out, hq_generic_offset, prev_L_swb_norm, hq_generic_exc_clas, sfm_end, num_sfm, num_env_bands, R ); } @@ -244,7 +242,7 @@ void fill_spectrum_fx( * HQ WB BWE refinements *----------------------------------------------------------------*/ test(); - IF ( sub(length, L_FRAME16k) == 0 && L_sub(L_core_brate, HQ_32k) == 0 ) + IF ( EQ_16(length, L_FRAME16k)&&EQ_32(L_core_brate,HQ_32k)) { hq_wb_nf_bwe_fx( coeff, is_transient, prev_bfi, L_normq_v, num_sfm, sfm_start, sfm_end, sfmsize, last_sfm, R, prev_is_transient, prev_normq, prev_env, bwe_seed, prev_coeff_out, prev_R, L_coeff_out, prev_env_Q ); @@ -255,7 +253,7 @@ void fill_spectrum_fx( *----------------------------------------------------------------*/ test(); - IF ( sub(HQ_mode, HQ_HARMONIC) != 0 && sub(HQ_mode, HQ_HVQ) != 0 ) + IF ( NE_16(HQ_mode, HQ_HARMONIC)&&NE_16(HQ_mode,HQ_HVQ)) { prev_noise_level[0] = 3277; move16();/* 0.1 in Q15 */ @@ -263,14 +261,14 @@ void fill_spectrum_fx( move16();/* 0.1 in Q15 */ } test(); - IF ( !(sub(length, L_FRAME16k) == 0 && L_sub(L_core_brate, HQ_32k) == 0) ) + IF ( !(EQ_16(length, L_FRAME16k)&&EQ_32(L_core_brate,HQ_32k))) { set32_fx( prev_env, 0, SFM_N_WB ); set32_fx( prev_normq, 0, SFM_N_WB ); } test(); - IF ( sub(length, L_FRAME32k) == 0 && L_sub(L_core_brate, HQ_32k) <= 0 ) + IF ( EQ_16(length, L_FRAME32k)&&LE_32(L_core_brate,HQ_32k)) { *prev_R = R[SFM_N_WB-1]; Copy32( L_coeff_out + L_FRAME16k - L_HQ_WB_BWE, prev_coeff_out, L_HQ_WB_BWE ); diff --git a/lib_com/findpulse_fx.c b/lib_com/findpulse_fx.c index da067bf5dd719526b7f324e3efa8a2e5d7fd813c..165c276b5dd9b7e963efc0ed0eb9ce6b6254baf7 100644 --- a/lib_com/findpulse_fx.c +++ b/lib_com/findpulse_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "cnst_fx.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*----------------------------------------------------------------------------------* * findpulse() @@ -95,7 +93,7 @@ Word16 findpulse_fx( /* o : pulse position */ { FOR (i = 0; i < T0; i++) { - if (sub(res[i], maxval) >= 0) + if (GE_16(res[i], maxval)) { maxi = add(i, 1); } @@ -106,7 +104,7 @@ Word16 findpulse_fx( /* o : pulse position */ { FOR (i = 0; i < T0; i++) { - if (sub(res[i], maxval) <= 0) + if (LE_16(res[i], maxval)) { maxi = add(i, 1); } diff --git a/lib_com/fine_gain_bits_fx.c b/lib_com/fine_gain_bits_fx.c index aa80a7c3216058d4e1a85a093f633fd75605df43..0f75c6484703fbba64d15477f9c720466a3873a5 100644 --- a/lib_com/fine_gain_bits_fx.c +++ b/lib_com/fine_gain_bits_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ -#include "stl.h" -#include "wmc_auto.h" - /* required for wmc_tool */ +#include "stl.h" /* required for wmc_tool */ /*-------------------------------------------------------------------------- @@ -33,7 +31,7 @@ void subband_gain_bits_fx( { /*bps = (short)(Rk[i]*((word16)min(32767, ceil(32767.0f/sfmsize[i]); inexact C-integer division approx. */ bps = extract_l(L_shr(L_mult0(Rk[i], inv_tbl_fx[sfmsize[i]]), 18)); /* 3+15 */ - if (L_sub(L_shl(L_mult0(sfmsize[i], add(bps, 1)), 3), Rk[i]) == 0) + if (EQ_32(L_shl(L_mult0(sfmsize[i], add(bps, 1)), 3), Rk[i])) { bps = add(bps, 1); } @@ -76,7 +74,7 @@ Word16 assign_gain_bits_fx( /* o : Number of assigned gain bits Word16 i; /* Allocate gain bits for every subband used, based on bit rate and bandwidth */ - IF( sub(core, HQ_CORE) == 0 ) + IF( EQ_16(core, HQ_CORE)) { subband_gain_bits_fx(Rk, BANDS, gain_bits_array, band_width); } diff --git a/lib_com/frame_ener_fx.c b/lib_com/frame_ener_fx.c index bf1293967e2704c6eed26fc6ec3ae5f6733b0480..c551865330dc79081ab102e96fc612d7aaf2ad96 100644 --- a/lib_com/frame_ener_fx.c +++ b/lib_com/frame_ener_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -7,8 +7,6 @@ #include "cnst_fx.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*----------------------------------------------------------------------------------* * frame_ener() @@ -36,7 +34,7 @@ Word16 frame_ener_fx( move16(); test(); test(); - IF( (sub(clas, VOICED_CLAS) == 0) || (sub(clas, ONSET) == 0) || (sub(clas, SIN_ONSET) == 0) ) /* current frame is voiced */ + IF( (EQ_16(clas, VOICED_CLAS))||(EQ_16(clas,ONSET))||(EQ_16(clas,SIN_ONSET))) /* current frame is voiced */ { /* current frame is voiced */ len = pitch; @@ -76,7 +74,7 @@ Word16 frame_ener_fx( Ltmp = L_mac(Ltmp, synth[pos+i], synth[pos+i]); } test(); - IF (L_sub(Ltmp, MAX_32) == 0 || enc != 0) + IF (EQ_32(Ltmp, MAX_32)||enc!=0) { /* scale down when overflow occurs */ *enr_q = Energy_scale(synth+pos, L_frame2, shift, &exp_enrq); @@ -105,7 +103,7 @@ Word16 frame_ener_fx( exp_enrq = sub(exp_enrq, exp_tmp); exp_enrq = sub(31, exp_enrq); - IF(sub(L_frame, 320) == 0) + IF(EQ_16(L_frame, 320)) { *enr_q = Mult_32_16(*enr_q, 26214); /*x 0.8 to get /160*/ i = norm_l(*enr_q); @@ -156,7 +154,7 @@ Word16 frame_energy_fx( /* o : Frame energy in /* len = (0.5f * (pitch[2]/64.0 + pitch[3]/64.0) + 0.5f) */ len = mult_r(add(pitch[2], pitch[3]), 256); - if(sub(len,L_SUBFR) < 0 ) + if(LT_16(len,L_SUBFR)) { len = shl(len, 1); } diff --git a/lib_com/g192.c b/lib_com/g192.c index 3a753724b66b880cbcd47d23f68224a561bda3f9..05ad613443a08e809ea128ee598fd7e8e18eec7a 100644 --- a/lib_com/g192.c +++ b/lib_com/g192.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.442 May 28, 2020. Version 12.13.0 / 13.8.0 / 14.4.0 / 15.2.0 / 16.0.0 ====================================================================================*/ #include @@ -21,8 +21,6 @@ typedef signed __int64 int64_t; #endif #include "options.h" #include "stl.h" -#include "wmc_auto.h" - #include "g192.h" diff --git a/lib_com/g192.h b/lib_com/g192.h index e866b7fbccfecf4b38ab1a007a31a64012e66e99..12981f6f78db56a7d474856419d68f5b4a242330 100644 --- a/lib_com/g192.h +++ b/lib_com/g192.h @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.442 May 28, 2020. Version 12.13.0 / 13.8.0 / 14.4.0 / 15.2.0 / 16.0.0 ====================================================================================*/ #ifndef G192_H diff --git a/lib_com/gain_inov.c b/lib_com/gain_inov.c index e2ab2be7cad687d76b4bd6da0dab9757daf5c75f..700d7150ece8dbd2b8910e701622dcf46b5f23d8 100644 --- a/lib_com/gain_inov.c +++ b/lib_com/gain_inov.c @@ -1,12 +1,10 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include #include "prot_fx.h" #include "stl.h" -#include "wmc_auto.h" - #include "basop_util.h" #include "rom_com_fx.h" diff --git a/lib_com/get_gain.c b/lib_com/get_gain.c index 0a4a4393136ce1e221c4d97914e30734a1dd1d29..b3c169d522f33ead7690207debed6d18a672e1a2 100644 --- a/lib_com/get_gain.c +++ b/lib_com/get_gain.c @@ -1,12 +1,10 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" #include "prot_fx.h" #include "stl.h" -#include "wmc_auto.h" - #include "basop_util.h" Word32 get_gain( /* output: codebook gain (adaptive or fixed) Q16 */ @@ -62,15 +60,15 @@ Word32 get_gain2( /* output: codebook gain (adaptive or fixed) Q16 */ negative = 1; move16(); } - BASOP_SATURATE_WARNING_OFF;/*tcorr max be negative maxvall - not critical*/ + BASOP_SATURATE_WARNING_OFF /*tcorr max be negative maxvall - not critical*/ tcorr = L_abs(tcorr); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON m_corr = extract_h(tcorr); m_ener = extract_h(tener); - IF (sub(m_corr, m_ener) > 0) + IF (GT_16(m_corr, m_ener)) { m_corr = shr(m_corr, 1); Q_corr = add(Q_corr,1); diff --git a/lib_com/gs_bitallocation_fx.c b/lib_com/gs_bitallocation_fx.c index 14bbeb1b9e5e73bac26055bd7d4af1d88219c067..1c10e8737df224debac677e22138bd18a6f3e495 100644 --- a/lib_com/gs_bitallocation_fx.c +++ b/lib_com/gs_bitallocation_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -8,8 +8,6 @@ #include "prot_fx.h" /* Function prototypes */ #include "assert.h" /* Debug prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*==================================================================================*/ /* FUNCTION : void bands_and_bit_alloc_fx(); */ @@ -102,9 +100,9 @@ void bands_and_bit_alloc_fx( test(); test(); - IF( (sub(coder_type,AUDIO) == 0 || sub(coder_type,INACTIVE) == 0) && sub(bwidth,NB) == 0 ) + IF( (EQ_16(coder_type,AUDIO)||EQ_16(coder_type,INACTIVE))&&EQ_16(bwidth,NB)) { - IF(L_sub(core_brate,ACELP_9k60) >= 0) + IF(GE_32(core_brate,ACELP_9k60)) { /* *bit = (short)(core_brate*(1.0f/50) + 0.5f) - bits_used - 25; */ L_tmp = Mult_32_16(core_brate,20971); @@ -132,7 +130,7 @@ void bands_and_bit_alloc_fx( move16(); } - IF( sub(GSC_noisy_speech,1) == 0 ) + IF( EQ_16(GSC_noisy_speech,1)) { SWB_bit_budget = *bit; move16(); @@ -182,7 +180,7 @@ void bands_and_bit_alloc_fx( st_band = 7; move16(); - IF( L_sub(core_brate,ACELP_9k60) <= 0 ) + IF( LE_32(core_brate,ACELP_9k60)) { *pvq_len = 80; move16(); @@ -212,28 +210,28 @@ void bands_and_bit_alloc_fx( test(); test(); test(); - IF( sub(coder_type,INACTIVE) == 0 || sub(noise_lev,NOISE_LEVEL_SP3) >= 0 ) + IF( EQ_16(coder_type,INACTIVE)||GE_16(noise_lev,NOISE_LEVEL_SP3)) { /* Probably classification error -> concentrate bits on LF */ nb_bands_max = nb_bands; move16(); - if( L_sub(core_brate,ACELP_8k00) >= 0 ) + if( GE_32(core_brate,ACELP_8k00)) { nb_bands_max = add(nb_bands,1); } } - ELSE IF( sub(noise_lev,NOISE_LEVEL_SP2) >= 0 || - (L_sub(core_brate,ACELP_13k20) <= 0 && L_sub(core_brate,ACELP_9k60) >= 0 && cor_strong_limit == 0) ) /* Very low dynamic, tend to speech, do not try to code HF at all */ + ELSE IF( GE_16(noise_lev,NOISE_LEVEL_SP2)|| + (LE_32(core_brate,ACELP_13k20) && GE_32(core_brate,ACELP_9k60) && cor_strong_limit == 0) ) /* Very low dynamic, tend to speech, do not try to code HF at all */ { nb_bands_max = sub(nb_bands_max,2); } - ELSE if( sub(noise_lev,NOISE_LEVEL_SP1) >= 0) /* Very low dynamic, tend to speech, code less HF */ + ELSE if( GE_16(noise_lev,NOISE_LEVEL_SP1)) /* Very low dynamic, tend to speech, code less HF */ { nb_bands_max = sub(nb_bands_max,1); } test(); - if( sub(bwidth,NB) == 0 && sub(nb_bands_max,10) > 0 ) + if( EQ_16(bwidth,NB)&>_16(nb_bands_max,10)) { nb_bands_max = 10; move16(); @@ -242,7 +240,7 @@ void bands_and_bit_alloc_fx( /*------------------------------------------------------------------------ * Find extra number of band to code according to bit rate availables *-----------------------------------------------------------------------*/ - WHILE ( sub(bit_tmp,bit_new_bands) >= 0 && sub(nb_bands,sub(nb_bands_max, 1)) <= 0 ) + WHILE ( GE_16(bit_tmp,bit_new_bands)&&LE_16(nb_bands,sub(nb_bands_max,1))) { bit_tmp = sub(bit_tmp,bit_new_bands); nb_bands = add(nb_bands,1); @@ -260,7 +258,7 @@ void bands_and_bit_alloc_fx( imax = 5; move16(); - if( L_sub(core_brate,ACELP_9k60) > 0 ) + if( GT_32(core_brate,ACELP_9k60)) { imax = 7; move16(); @@ -305,12 +303,12 @@ void bands_and_bit_alloc_fx( test(); test(); test(); - IF( sub(noise_lev,NOISE_LEVEL_SP1a) <= 0 ) + IF( LE_16(noise_lev,NOISE_LEVEL_SP1a)) { bandoffset = sub(bandoffset,1); } - ELSE if ( (L_sub(core_brate,ACELP_13k20) <= 0 && (sub(coder_type,INACTIVE) == 0 || sub(noise_lev,NOISE_LEVEL_SP3) >= 0)) || - (L_sub(core_brate,ACELP_13k20) <= 0 && L_sub(core_brate,ACELP_9k60) >= 0 && cor_strong_limit == 0) ) + ELSE if ( (LE_32(core_brate,ACELP_13k20)&&(EQ_16(coder_type,INACTIVE)||GE_16(noise_lev,NOISE_LEVEL_SP3)))|| + (LE_32(core_brate,ACELP_13k20) && GE_32(core_brate,ACELP_9k60) && cor_strong_limit == 0) ) { bandoffset = add(bandoffset,1); } @@ -350,7 +348,7 @@ void bands_and_bit_alloc_fx( test(); test(); test(); - IF( sub(sub(nb_tot_bands, bandoffset),nb_bands) > 0 && ( sub(pos,7) > 0 && L_sub(core_brate,ACELP_8k00) == 0 ) && sub(bwidth,WB) == 0 ) + IF( GT_16(sub(nb_tot_bands, bandoffset),nb_bands)&&(GT_16(pos,7)&&EQ_32(core_brate,ACELP_8k00))&&EQ_16(bwidth,WB)) { band = sub(nb_tot_bands, add(bandoffset,nb_bands)); FOR(j=0; j 0) /* 112 in Q18 */ + IF( GT_32(bits_per_bands[i],29360128)) /* 112 in Q18 */ { sum_bit = L_add(sum_bit,L_sub(bits_per_bands[i],29360128)); /* Q18 */ bits_per_bands[i] = 29360128; move32(); j = add(i,1); } - ELSE if( L_sub(L_add(bits_per_bands[i],L_tmp),29360128 ) > 0) /* Q18 */ + ELSE if( GT_32(L_add(bits_per_bands[i],L_tmp),29360128 )) /* Q18 */ { j = add(i,1); } @@ -446,7 +444,7 @@ void bands_and_bit_alloc_fx( } tmp = shl(*bit,3); - IF( sub(tmp,w_sum_bit)>0 ) + IF( GT_16(tmp,w_sum_bit)) { i = sub(nb_bands,1); move16(); diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index aaaee74f645e3ce656a2d8bf4b855ead1d739cd3..4006287421e3b833a8258c590678ce4d126152c8 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -7,8 +7,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*-------------------------------------------------------------------* @@ -66,7 +64,7 @@ void Comp_and_apply_gain_fx( StartBin = add(StartBin, NB_Qbins); NB_Qbins = mfreq_bindiv_loc[i_band]; move16(); - IF( sub(ReUseGain,1) == 0 ) + IF( EQ_16(ReUseGain,1)) { y_gain = Ener_per_bd_yQ[i_band]; move16(); @@ -177,7 +175,7 @@ void Ener_per_band_comp_fx( pt_fx += 16; } - IF( sub(Eflag,1) == 0 ) + IF( EQ_16(Eflag,1)) { y_gain4_fx[j+1] = Comp_band_log_ener(pt_fx, 32, Q_exc, -1); move16(); @@ -204,7 +202,7 @@ static void GSC_gain_adj( /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */ Word16 Gain_off, i; - IF( sub(coder_type,INACTIVE) != 0 ) + IF( NE_16(coder_type,INACTIVE)) { FOR( i = 0; i < MBANDS_GN; i++ ) { @@ -218,27 +216,27 @@ static void GSC_gain_adj( { Gain_off = 0; move16(); - IF(L_sub(core_brate,ACELP_7k20) <= 0 ) + IF(LE_32(core_brate,ACELP_7k20)) { Gain_off = 32767; move16(); /* 8 -> Q12 */ } - ELSE IF (L_sub(core_brate,ACELP_8k00) <= 0) + ELSE IF (LE_32(core_brate,ACELP_8k00)) { Gain_off = 27034; move16(); /* 6.6f -> Q12 */ } - ELSE IF (L_sub(core_brate,ACELP_9k60) <= 0) + ELSE IF (LE_32(core_brate,ACELP_9k60)) { Gain_off = 19661; move16(); /*4.8f-> Q12 */ } - ELSE IF (L_sub(core_brate,ACELP_11k60) <= 0) + ELSE IF (LE_32(core_brate,ACELP_11k60)) { Gain_off = 14336; move16(); /* 3.5f -> Q12 */ } - ELSE IF (L_sub(core_brate,ACELP_13k20) <= 0) + ELSE IF (LE_32(core_brate,ACELP_13k20)) { Gain_off = 12288; move16(); /* 3.0f -> Q12 dB */ @@ -293,7 +291,7 @@ Word16 gsc_gaindec_fx( /* o : average frequency gain */ test(); test(); - IF( (sub(coder_type_fx,AUDIO) == 0 || sub(coder_type_fx,INACTIVE) == 0) && sub(bwidth_fx,NB) == 0 ) + IF( (EQ_16(coder_type_fx,AUDIO)||EQ_16(coder_type_fx,INACTIVE))&&EQ_16(bwidth_fx,NB)) { idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 ); VDQ_vec_fx(&mean_4g_fx, Gain_meanNB_fx, Gain_mean_dicNB_fx, idx_g_fx, 1 ); @@ -302,7 +300,7 @@ Word16 gsc_gaindec_fx( /* o : average frequency gain */ move16(); VDQ_vec_fx(y_gainQ_fx, Mean_dic_NB_fx, Gain_dic1_NB_fx, idx_g_fx, 3 ); - IF(L_sub(core_brate_fx,ACELP_9k60) < 0) + IF(LT_32(core_brate_fx,ACELP_9k60)) { idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 ); VDQ_vec_fx(y_gainQ_fx+3, Mean_dic_NB_fx+3, Gain_dic2_NB_fx, idx_g_fx, 3 ); @@ -319,7 +317,7 @@ Word16 gsc_gaindec_fx( /* o : average frequency gain */ VDQ_vec_fx(y_gainQ_fx+6, Mean_dic_NB_fx+6, Gain_dic3_NBHR_fx, idx_g_fx, 4 ); } test(); - IF( L_sub(core_brate_fx,ACELP_9k60) <= 0 && sub(coder_type_fx,INACTIVE) == 0 ) + IF( LE_32(core_brate_fx,ACELP_9k60)&&EQ_16(coder_type_fx,INACTIVE)) { /* Some energy is needed in high band for stat_noise_uv_enc to be functional in inactive speech */ @@ -347,7 +345,7 @@ Word16 gsc_gaindec_fx( /* o : average frequency gain */ VDQ_vec_fx(&mean_4g_fx, mean_m_fx, mean_gain_dic_fx, idx_g_fx, 1 ); - IF(L_sub(core_brate_fx,ACELP_9k60) <= 0) + IF(LE_32(core_brate_fx,ACELP_9k60)) { /*--------------------------------------------------------------------------------------* * UQ of the first 8 bands and half of the last 8 bands @@ -443,7 +441,7 @@ Word16 gsc_gainQ_fx( /*Q12*/ test(); test(); - IF( (sub(coder_type,AUDIO) == 0 || sub(coder_type,INACTIVE) == 0) && sub(bwidth,NB) == 0 ) + IF( (EQ_16(coder_type,AUDIO)||EQ_16(coder_type,INACTIVE))&&EQ_16(bwidth,NB)) { /*ftmp1 = mean(y_gain4, 10)-0.6f;*/ @@ -486,7 +484,7 @@ Word16 gsc_gainQ_fx( /*Q12*/ idx_g = vquant_fx(y_gain_tmp, Mean_dic_NB_fx, y_gain_tmp, Gain_dic1_NB_fx, 3, 64); push_indice_fx( st_fx, IND_Y_GAIN_TMP, idx_g, 6 ); - IF(L_sub(core_brate,ACELP_9k60) < 0) + IF(LT_32(core_brate,ACELP_9k60)) { idx_g = vquant_fx(y_gain_tmp+3, Mean_dic_NB_fx+3, y_gain_tmp+3, Gain_dic2_NB_fx, 3, 32); push_indice_fx( st_fx, IND_Y_GAIN_TMP, idx_g, 5 ); @@ -502,7 +500,7 @@ Word16 gsc_gainQ_fx( /*Q12*/ }/*add end */ test(); - IF( L_sub(core_brate,ACELP_9k60) <= 0 && sub(coder_type,INACTIVE) == 0 ) + IF( LE_32(core_brate,ACELP_9k60)&&EQ_16(coder_type,INACTIVE)) { /* Some energy is needed in high band for stat_noise_uv_enc to be functional in inactive speech */ @@ -569,7 +567,7 @@ Word16 gsc_gainQ_fx( /*Q12*/ move16(); } - IF( L_sub(core_brate,ACELP_9k60) < 0 ) + IF( LT_32(core_brate,ACELP_9k60)) { /*mvr2r(y_gain_tmp, y_gain_tmp2, 8); */ Copy(y_gain_tmp, y_gain_tmp2, 8); diff --git a/lib_com/gs_inact_switching_fx.c b/lib_com/gs_inact_switching_fx.c index d037c5fdc0b56d44d83dce94a7016b8ffc932789..d9a7fbeb4d6783d7fb64615a84a5457d833ba938 100644 --- a/lib_com/gs_inact_switching_fx.c +++ b/lib_com/gs_inact_switching_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -7,8 +7,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*-------------------------------------------------------------------* * Local constants @@ -71,7 +69,7 @@ void Inac_swtch_ematch_fx( test(); test(); test(); - IF(sub(coder_type,AUDIO) == 0 && bfi == 0) + IF(EQ_16(coder_type,AUDIO)&&bfi==0) { Ener_per_band_comp_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1); @@ -83,7 +81,7 @@ void Inac_swtch_ematch_fx( } } - ELSE IF( sub(coder_type,VOICED) == 0 || sub(coder_type,GENERIC) == 0 || sub(coder_type,TRANSITION) == 0 || sub(last_core,ACELP_CORE) != 0 || sub(last_codec_mode,MODE1) != 0 ) + ELSE IF( EQ_16(coder_type,VOICED)||EQ_16(coder_type,GENERIC)||EQ_16(coder_type,TRANSITION)||NE_16(last_core,ACELP_CORE)||NE_16(last_codec_mode,MODE1)) { /* Find spectrum and energy per band for GC and VC frames */ edct_16fx( exc2, dct_exc_tmp, L_frame, 5 ); @@ -97,7 +95,7 @@ void Inac_swtch_ematch_fx( move16(); } } - ELSE IF( sub(coder_type,INACTIVE) == 0 && L_sub(core_brate,ACELP_24k40) <= 0) + ELSE IF( EQ_16(coder_type,INACTIVE)&&LE_32(core_brate,ACELP_24k40)) { /* Find spectrum and energy per band for inactive frames */ edct_16fx( exc2, dct_exc_tmp, L_frame, 5 ); @@ -125,7 +123,7 @@ void Inac_swtch_ematch_fx( /* 16384 < Pow2() <= 32767 */ exp = sub(exp,14); - IF( sub(i,2) < 0 ) + IF( LT_16(i,2)) { FOR (j = 0; j < 8; j ++) { diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c index 419cf6deaf0720cd266ee16c1972a4bf3beb766d..8ef917f38146a20ed377ce76dcb4d833f6cd967f 100644 --- a/lib_com/gs_noisefill_fx.c +++ b/lib_com/gs_noisefill_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" #include "rom_com_fx.h" #include "prot_fx.h" #include "stl.h" -#include "wmc_auto.h" - /*-------------------------------------------------------------------* * gs_noisf() @@ -35,7 +33,7 @@ static void gs_noisf_fx( NB_zer = shr(NB_Qbins,1); const_1 = L_shl(const_1, add(qNoise_fac, qNoise_fac)); - if( sub(coder_type,INACTIVE) == 0 ) + if( EQ_16(coder_type,INACTIVE)) { NB_zer = 2; move16(); @@ -56,7 +54,7 @@ static void gs_noisf_fx( ftmp = L_mac0(ftmp, exc_diffQ[i], exc_diffQ[i]); } - IF (L_sub(L_shl(ftmp, 1),const_1) < 0) + IF (LT_32(L_shl(ftmp, 1),const_1)) { FOR(i=k; i 0) && sub(bwidth,NB) != 0) + IF( (EQ_32(bitrate,ACELP_8k00)&>_16(last_bin,8))&&NE_16(bwidth,NB)) { FOR( ; Mbands_gn > i_band; i_band++) { @@ -197,7 +195,7 @@ static void EstimateNoiseLevel_fx( } } test(); - IF ( (sub(coder_type,INACTIVE) == 0 || sub(noise_lev,NOISE_LEVEL_SP3) >= 0) ) + IF ( (EQ_16(coder_type,INACTIVE)||GE_16(noise_lev,NOISE_LEVEL_SP3))) { FOR( i_band = 9; i_band < Mbands_gn; i_band++ ) { @@ -256,7 +254,7 @@ static void Apply_NoiseFill_fx( NB_Qbins = freq_nsbin_per_band[i_band]; move16(); - IF( sub(Diff_len,L_FRAME) < 0 ) + IF( LT_16(Diff_len,L_FRAME)) { gs_noisf_fx( StartBin , NB_Qbins, noisepb[i_band], exc_diffQ, exc_diffQ, seed_tcx, coder_type, qexc_diffQ); } @@ -302,13 +300,13 @@ void freq_dnw_scaling_fx( start_sc = L_FRAME; move16(); test(); - IF( L_sub(core_brate,ACELP_8k00) <= 0 && sub(coder_type,INACTIVE) == 0 ) + IF( LE_32(core_brate,ACELP_8k00)&&EQ_16(coder_type,INACTIVE)) { sc_dyn = mult_r(sc_dyn,4915); /*Q15 (0.15 in Q15) */ start_sc = 64; move16(); } - ELSE IF ( sub(coder_type,INACTIVE) == 0 ) + ELSE IF ( EQ_16(coder_type,INACTIVE)) { sc_dyn = mult_r(sc_dyn,8192); /*Q15 (0.25 in Q15) */ start_sc = 80; @@ -319,7 +317,7 @@ void freq_dnw_scaling_fx( /*sc_dyn = (float)(NOISE_LEVEL_SP3 - noise_lev)/10.0f + 0.4f;*/ sc_dyn = extract_l(L_mac(13107, sub(NOISE_LEVEL_SP3, noise_lev), 1638)); /*Q0*Q14x2+Q15 =Q15*/ start_sc = add(112, shl(sub(NOISE_LEVEL_SP3, noise_lev), 4)); - if( sub(noise_lev,NOISE_LEVEL_SP0) == 0) + if( EQ_16(noise_lev,NOISE_LEVEL_SP0)) { start_sc = L_FRAME; move16(); @@ -334,7 +332,7 @@ void freq_dnw_scaling_fx( test(); test(); - IF( (L_sub(core_brate,ACELP_13k20) < 0 && cor_strong_limit == 0) || L_sub(core_brate,ACELP_9k60) < 0) + IF( (LT_32(core_brate,ACELP_13k20)&&cor_strong_limit==0)||LT_32(core_brate,ACELP_9k60)) { FOR(i = 160; i < L_FRAME; i++) { @@ -344,7 +342,7 @@ void freq_dnw_scaling_fx( move16(); } } - ELSE IF ( L_sub(core_brate,ACELP_22k60) < 0 ) + ELSE IF ( LT_32(core_brate,ACELP_22k60)) { FOR(i = 160; i < L_FRAME; i++) { @@ -388,7 +386,7 @@ static void Decreas_freqPeak_fx( move16(); FOR(i=160; i 0) + IF(GT_16(abs_s(exc_diffQ[i]),max)) { max = abs_s(exc_diffQ[i]); pos = i; @@ -403,7 +401,7 @@ static void Decreas_freqPeak_fx( move16(); /* When the search is false, should equate the end of the vector, not the beginning */ FOR(i=0; i<(M-1); i++) { - if(sub(lsf_new[i],10240) > 0) + if(GT_16(lsf_new[i],10240)) { last_bin = i; move16(); @@ -414,7 +412,7 @@ static void Decreas_freqPeak_fx( FOR(i=last_bin; i<14; i++) { tmp = mult_r(rat,lsf_new_diff[i-1] );/*Qx2.56 */ - IF(sub(tmp , lsf_new_diff[i])>0) + IF(GT_16(tmp , lsf_new_diff[i])) { src = &exc_diffQ[shl(sub(i,1),4)]; move16(); @@ -423,7 +421,7 @@ static void Decreas_freqPeak_fx( FOR(k=0; k<16; k++) { tmp = mult_r(16384,abs_s(*src)); - IF(sub(tmp,avrg)>0) + IF(GT_16(tmp,avrg)) { tmp = abs_s(*src) ; exp = norm_s(max); @@ -454,7 +452,7 @@ static void Decreas_freqPeak_fx( tmp = mult_r(8192,max);/*Q_exc */ test(); - IF(sub(abs_s(exc_diffQ[pos]),max) == 0 && sub(tmp ,avrg)>0) + IF(EQ_16(abs_s(exc_diffQ[pos]),max)&>_16(tmp,avrg)) { FOR(i=pos-1; i 0) + IF(GT_32(L_abs(L_exc_diffQ_fx[i]), exc_diffQ_max)) { exc_diffQ_max = L_abs(L_exc_diffQ_fx[i]); } } exp = norm_l(exc_diffQ_max); - IF(sub(exp,16) > 0) + IF(GT_16(exp,16)) { *Q_hb_exc = 12; move16(); @@ -648,21 +646,22 @@ void highband_exc_dct_in_fx( /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ exp = sub(exp, 14); - tmp1 = shl(tmp,add(exp,0)); + tmp1 = shl(tmp,exp); + move16(); ener = add (tmp1,ener);/*Q0 */ } test(); - IF( L_sub(core_brate,ACELP_8k00) == 0 && sub(bwidth,NB) != 0 ) + IF( EQ_32(core_brate,ACELP_8k00)&&NE_16(bwidth,NB)) { - if(sub(last_coder_type,AUDIO) != 0) + if(NE_16(last_coder_type,AUDIO)) { *last_ener = ener; move16(); } test(); test(); - IF((sub(last_bin,8) > 0 || Diff_len != 0) && sub(last_coder_type,AUDIO) == 0) + IF((GT_16(last_bin,8)||Diff_len!=0)&&EQ_16(last_coder_type,AUDIO)) { MAX_Bin = 10; move16(); @@ -715,7 +714,7 @@ void highband_exc_dct_in_fx( * VQ of remaining gain per band *--------------------------------------------------------------------------------------*/ test(); - IF( L_sub(core_brate,ACELP_8k00) == 0 && sub(bwidth,NB) != 0 ) + IF( EQ_32(core_brate,ACELP_8k00)&&NE_16(bwidth,NB)) { Ener_per_band_comp_fx(exc_diffQ, Ener_per_bd_yQ, Qexc_diffQ, add(last_bin,1), 0); } @@ -723,7 +722,7 @@ void highband_exc_dct_in_fx( { Ener_per_band_comp_fx(exc_diffQ, Ener_per_bd_yQ, Qexc_diffQ, MBANDS_GN, 1 ); - IF( sub(nb_subfr, 4) < 0 ) + IF( LT_16(nb_subfr, 4)) { FOR(i = L_FRAME-16; i < L_FRAME; i++) { @@ -740,7 +739,7 @@ void highband_exc_dct_in_fx( IF( bfi ) { test(); - IF (GSC_noisy_speech == 0 && sub(coder_type,UNVOICED) > 0 ) /* Here coder_type == last_coder_type because of the bfi */ + IF (GSC_noisy_speech == 0 && GT_16(coder_type,UNVOICED)) /* Here coder_type == last_coder_type because of the bfi */ { FOR( i=0; i Q_exc as expected */ } - IF( sub(nb_subfr,4) < 0 ) + IF( LT_16(nb_subfr,4)) { FOR( i = sub(L_FRAME,16); i < L_FRAME; i++ ) { @@ -876,7 +875,7 @@ void highband_exc_dct_in_fx( tmp= mult_r(10923,abs_s(*src)); tmp1 =mult_r(10923,abs_s(*dst)); - IF(sub(tmp,abs_s(*dst)) >0) + IF(GT_16(tmp,abs_s(*dst))) { tmp2 = *src; *src = mult_r(16384,sub(*src , abs_s(*dst))); /*Q_exc */ move16(); @@ -887,7 +886,7 @@ void highband_exc_dct_in_fx( move16(); } } - ELSE IF (sub(tmp1,abs_s(*src)) >0) + ELSE IF (GT_16(tmp1,abs_s(*src))) { tmp = mult_r(*src,22938); tmp1 = mult_r(9830,abs_s(*dst)); @@ -904,7 +903,7 @@ void highband_exc_dct_in_fx( } } } - IF(sub(bwe_flag,1) == 0) + IF(EQ_16(bwe_flag,1)) { Decreas_freqPeak_fx( lsf_new, exc_dct_in, 9830 ); } diff --git a/lib_com/gs_preech_fx.c b/lib_com/gs_preech_fx.c index 9f073aa1fa7048297f0b27a05125b812a2b4a78f..78396c5e5c5dbe10319dbdbd4626e0b133c729a0 100644 --- a/lib_com/gs_preech_fx.c +++ b/lib_com/gs_preech_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -7,8 +7,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*-------------------------------------------------------------------* @@ -56,7 +54,7 @@ void pre_echo_att_fx( Word16 tmp, n1, n2, exp, frac1, frac2; Word32 etmp1_fx; test(); - IF ( sub(gsc_attack_flag_fx,1) == 0 && sub(last_coder_type_fx, AUDIO) == 0) /*gsc_attack_flag_fx does not get set for all the test cases */ + IF ( EQ_16(gsc_attack_flag_fx,1)&&EQ_16(last_coder_type_fx,AUDIO)) /*gsc_attack_flag_fx does not get set for all the test cases */ { /*-------------------------------------------------------------------------* * Find where the onset (attack) occurs by computing the energy per section @@ -83,7 +81,7 @@ void pre_echo_att_fx( /* If the maximum normalized energy > last frame energy + 6dB */ test(); - IF( L_sub(etmp_fx,*Last_frame_ener_fx) > 0 && attack_pos_fx > 0 ) + IF( GT_32(etmp_fx,*Last_frame_ener_fx)&&attack_pos_fx>0) { /* Find the average energy before the attack */ L_tmp = sum32_fx( finc_fx, attack_pos_fx); /*Q1 */ diff --git a/lib_com/guided_plc_util.c b/lib_com/guided_plc_util.c index ce97224b0fe2f42476c23005f1273a894503a3a0..f42de3cedc612c38286ebc68148ea222f90149fc 100644 --- a/lib_com/guided_plc_util.c +++ b/lib_com/guided_plc_util.c @@ -1,11 +1,9 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "prot_fx.h" #include "stl.h" -#include "wmc_auto.h" - #include "rom_com_fx.h" #include "basop_util.h" @@ -17,7 +15,7 @@ void getLookAheadResSig( Word16 *speechLookAhead, Word16 *A_3Q12, Word16 *res, W Word16 i_subfr; Word16 subfr_len[2] = { L_SUBFR, L_SUBFR }; - if( sub( L_FRAME16k, L_frame )>0 ) + if( GT_16( L_FRAME16k, L_frame )) { subfr_len[1] = 48; move16(); /* 0.75 * L_SUBFR(64) */ @@ -86,7 +84,7 @@ void getConcealedLP( HANDLE_PLC_ENC_EVS memDecState, Word16 *AqCon, const Word16 int_fs = INT_FS_FX; move32(); - if( sub(L_frame,L_FRAME_16k) == 0 ) + if( EQ_16(L_frame,L_FRAME_16k)) { int_fs = INT_FS_16k_FX; move32(); @@ -169,7 +167,7 @@ void modify_lsf( th_x1p28_Q14 = 4864/*1900.0f*1.28f Q1*/; move16(); - if( L_sub( sr_core, 16000 ) == 0 ) + if( EQ_32( sr_core, 16000 )) { th_x1p28_Q14 = 6080/*2375.0f*1.28f Q1*/; move16(); @@ -178,7 +176,7 @@ void modify_lsf( IF( reset_q == 0 ) { th_x1p28_Q14 = 2048; /* 800.0f*1.28f Q1*/ move16(); - if( L_sub( sr_core, 16000 ) == 0 ) + if( EQ_32( sr_core, 16000 )) { th_x1p28_Q14 = 2560; /*1000.0f*1.28f Q1*/ move16(); } @@ -186,7 +184,7 @@ void modify_lsf( FOR ( i=1; i= 0 ) + IF ( GE_16(lsf[i], th_x1p28_Q14)) { BREAK; } @@ -228,7 +226,7 @@ static void reorder_lsfs( fs2 = 16384/*6400.0 * 1.28 Q1*/; move16(); - if(L_sub(sr_core, 16000) == 0) + if(EQ_32(sr_core, 16000)) { fs2 = 20480/*8000.0 * 1.28 Q1*/; move16(); @@ -237,7 +235,7 @@ static void reorder_lsfs( /*-----------------------------------------------------------------* * Verify the LSF ordering and minimum GAP *-----------------------------------------------------------------*/ - IF( L_sub( sr_core, 16000 )==0 ) + IF( EQ_32( sr_core, 16000 )) { th1 = 3200; move16(); @@ -264,21 +262,21 @@ static void reorder_lsfs( FOR (i = 0; i < n; i++) { - IF (sub(lsf[i], th1) > 0) + IF (GT_16(lsf[i], th1)) { curr_min_dist = min_dist_fac2; move16(); } ELSE { - if (sub(lsf[i], th2) > 0) + if (GT_16(lsf[i], th2)) { curr_min_dist = min_dist; move16(); } } - if (sub(lsf[i], lsf_min) < 0) + if (LT_16(lsf[i], lsf_min)) { lsf[i] = lsf_min; move16(); @@ -294,25 +292,25 @@ static void reorder_lsfs( lsf_max = sub(fs2, curr_min_dist); - IF (sub(lsf[n-1], lsf_max) > 0) /* If danger of unstable filter in case of resonance in HF */ + IF (GT_16(lsf[n-1], lsf_max)) /* If danger of unstable filter in case of resonance in HF */ { FOR (i = sub(n, 1); i >= 0; i--) /* Reverify the minimum ISF gap in the reverse direction */ { - IF (sub(lsf[i], th2) <= 0) + IF (LE_16(lsf[i], th2)) { curr_min_dist = min_dist_fac2; move16(); } ELSE { - if (sub(lsf[i], th1) <= 0) + if (LE_16(lsf[i], th1)) { curr_min_dist = min_dist_fac3; move16(); } } - if (sub(lsf[i], lsf_max) > 0) + if (GT_16(lsf[i], lsf_max)) { lsf[i] = lsf_max; move16(); diff --git a/lib_com/hp50.c b/lib_com/hp50.c index 34031cea95a7cd0450355b8879684ef554abc6bf..c30819e573256445b5b6dd91858169531595cdbf 100644 --- a/lib_com/hp50.c +++ b/lib_com/hp50.c @@ -1,12 +1,10 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include #include "stl.h" -#include "wmc_auto.h" - #include "prot_fx.h" #include "basop_util.h" #include "options.h" @@ -67,7 +65,7 @@ static void filter_2nd_order( */ /* Execute first 2 iterations with 32-bit x anx y memory values */ - BASOP_SATURATE_ERROR_ON; + BASOP_SATURATE_ERROR_ON L_sum = HP50_Mpy_32_32_fix(b2,mem[2]); /* b2*x2 */ L_sum = L_add(L_sum,HP50_Mpy_32_32_fix(b1,mem[3])); /* b1*x1 */ x2 = shr(signal[0*stride], prescale); @@ -76,12 +74,12 @@ static void filter_2nd_order( L_sum = L_add(L_sum, HP50_Mpy_32_32_fix(mem[1],a1)); /* y1*a1 */ L_y2 = L_shl(L_sum, HP20_COEFF_SCALE); - BASOP_SATURATE_ERROR_OFF; - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_ERROR_OFF + BASOP_SATURATE_WARNING_OFF signal[0*stride] = round_fx(L_shl(L_y2, prescale)); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON - BASOP_SATURATE_ERROR_ON; + BASOP_SATURATE_ERROR_ON L_sum = HP50_Mpy_32_32_fix(b2,mem[3]); /* b2*x2 */ L_sum = L_add(L_sum,HP50_Mode2_Mpy_32_16_fix(b1,x2)); /* b1*x1 */ x1 = shr(signal[1*stride], prescale); @@ -90,16 +88,16 @@ static void filter_2nd_order( L_sum = L_add(L_sum, HP50_Mpy_32_32_fix(L_y2, a1)); /* y1*a1 */ L_y1 = L_shl(L_sum, HP20_COEFF_SCALE); - BASOP_SATURATE_ERROR_OFF; - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_ERROR_OFF + BASOP_SATURATE_WARNING_OFF signal[1*stride] = round_fx(L_shl(L_y1, prescale)); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON /* New we use a trick and toggle x1/x2 and L_y1/L_y2 to save a few cycles unrolling the loop by 2 */ FOR (i = 2; i < lg; i+=2) { /* y[i+0] = b2*x[i-2] + b1*x[i-1] + b2*x[i-0] + a2*y[i-2] + a1*y[i-1]; */ - BASOP_SATURATE_ERROR_ON; + BASOP_SATURATE_ERROR_ON L_sum = HP50_Mode2_Mpy_32_16_fix(b2,x2); L_sum = L_add(L_sum,HP50_Mode2_Mpy_32_16_fix(b1,x1)); x2 = shr(signal[i*stride], prescale); @@ -108,12 +106,12 @@ static void filter_2nd_order( L_sum = L_add(L_sum, HP50_Mpy_32_32_fix(L_y1,a1)); L_y2 = L_shl(L_sum, HP20_COEFF_SCALE); - BASOP_SATURATE_ERROR_OFF; - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_ERROR_OFF + BASOP_SATURATE_WARNING_OFF signal[i*stride] = round_fx(L_shl(L_y2, prescale)); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON /* y[i+1] = b2*x[i-1] + b1*x[i-0] + b2*x[i+1] + a2*y[i-1] + a1*y[i+0]; */ - BASOP_SATURATE_ERROR_ON; + BASOP_SATURATE_ERROR_ON L_sum = HP50_Mode2_Mpy_32_16_fix(b2,x1); L_sum = L_add(L_sum,HP50_Mode2_Mpy_32_16_fix(b1,x2)); x1 = shr(signal[(i+1)*stride], prescale); @@ -122,10 +120,10 @@ static void filter_2nd_order( L_sum = L_add(L_sum, HP50_Mpy_32_32_fix(L_y2,a1)); L_y1 = L_shl(L_sum, HP20_COEFF_SCALE); - BASOP_SATURATE_ERROR_OFF; - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_ERROR_OFF + BASOP_SATURATE_WARNING_OFF signal[(i+1)*stride] = round_fx(L_shl(L_y1, prescale)); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON } /* update static filter memory from variables */ mem[0] = L_y2; @@ -185,40 +183,40 @@ void hp20(Word16 signal[], /* i/o: signal to filter any */ mem[4] = L_deposit_l(prescale); } - IF ( L_sub(sFreq,8000) == 0 ) + IF ( EQ_32(sFreq,8000)) { /* hp filter 20Hz at 3dB for 8000 Hz input sampling rate [b,a] = butter(2, 20.0/4000.0, 'high'); b = [0.988954248067140 -1.977908496134280 0.988954248067140] a = [1.000000000000000 -1.977786483776764 0.978030508491796]*/ - a1 = L_add(0,1061816033l/* 1.977786483776764 Q29*/); - a2 = L_add(0,-525076131l/*-0.978030508491796 Q29*/); - b1 = L_add(0,-1061881538l/*-1.977908496134280 Q29*/); - b2 = L_add(0,530940769l/* 0.988954248067140 Q29*/); + a1 = 1061816033l/* 1.977786483776764 Q29*/; move32(); + a2 = -525076131l/*-0.978030508491796 Q29*/; move32(); + b1 = -1061881538l/*-1.977908496134280 Q29*/; move32(); + b2 = 530940769l/* 0.988954248067140 Q29*/; move32(); } - ELSE IF ( L_sub(sFreq,16000) == 0 ) + ELSE IF ( EQ_32(sFreq,16000)) { /* hp filter 20Hz at 3dB for 16000KHz sampling rate [b,a] = butter(2, 20.0/8000.0, 'high'); b = [0.994461788958195 -1.988923577916390 0.994461788958195] a = [1.000000000000000 -1.988892905899653 0.988954249933127] */ - a1 = L_add(0,1067778748l/* 1.988892905899653 Q29*/); - a2 = L_add(0,-530940770l/*-0.988954249933127 Q29*/); - b1 = L_add(0,-1067795215l/*-1.988923577916390 Q29*/); - b2 = L_add(0,533897608l/* 0.994461788958195 Q29*/); + a1 = 1067778748l/* 1.988892905899653 Q29*/; move32(); + a2 = -530940770l/*-0.988954249933127 Q29*/; move32(); + b1 = -1067795215l/*-1.988923577916390 Q29*/; move32(); + b2 = 533897608l/* 0.994461788958195 Q29*/; move32(); } - ELSE IF ( L_sub(sFreq,32000) == 0 ) + ELSE IF ( EQ_32(sFreq,32000)) { /* hp filter 20Hz at 3dB for 32000KHz sampling rate [b,a] = butter(2, 20.0/16000.0, 'high'); b = [0.997227049904470 -1.994454099808940 0.997227049904470] a = [1.000000000000000 -1.994446410541927 0.994461789075954]*/ - a1 = L_add(0,1070760263l/* 1.994446410541927 Q29*/); - a2 = L_add(0,-533897608l/*-0.994461789075954 Q29*/); - b1 = L_add(0,-1070764392l/*-1.994454099808940 Q29*/); - b2 = L_add(0,535382196l/* 0.997227049904470 Q29*/); + a1 = 1070760263l/* 1.994446410541927 Q29*/; move32(); + a2 = -533897608l/*-0.994461789075954 Q29*/; move32(); + b1 = -1070764392l/*-1.994454099808940 Q29*/; move32(); + b2 = 535382196l/* 0.997227049904470 Q29*/; move32(); } ELSE { @@ -227,10 +225,10 @@ void hp20(Word16 signal[], /* i/o: signal to filter any */ [b,a] = butter(2, 20.0/24000.0, 'high'); b =[0.998150511190452 -1.996301022380904 0.998150511190452] a =[1.000000000000000 -1.996297601769122 0.996304442992686]*/ - a1 = L_add(0,1071754114l/* 1.996297601769122 Q29*/); - a2 = L_add(0,-534886875l/*-0.996304442992686 Q29*/); - b1 = L_add(0,-1071755951l/*-1.996301022380904 Q29*/); - b2 = L_add(0,535877975l/* 0.998150511190452 Q29*/); + a1 = 1071754114l/* 1.996297601769122 Q29*/; move32(); + a2 = -534886875l/*-0.996304442992686 Q29*/; move32(); + b1 = -1071755951l/*-1.996301022380904 Q29*/; move32(); + b2 = 535877975l/* 0.998150511190452 Q29*/; move32(); } diff --git a/lib_com/hq2_bit_alloc_fx.c b/lib_com/hq2_bit_alloc_fx.c index 7826a6a36220226b1dca328c4dc5a650c64a7f90..f0bfd9d79883e7ebc858ee89364c90c84b429f2f 100644 --- a/lib_com/hq2_bit_alloc_fx.c +++ b/lib_com/hq2_bit_alloc_fx.c @@ -1,12 +1,10 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" #include "prot_fx.h" -#include "stl.h" -#include "wmc_auto.h" - /* required for wmc_tool */ +#include "stl.h" /* required for wmc_tool */ #define MIN_BITS_FIX 0 /* QRk=18 */ #define HQ_16k40_BIT (HQ_16k40/50) /* 16400/50=328 */ @@ -134,7 +132,7 @@ void Bits2indvsb_fx ( th_5_fx = shl(5, QRavg); FOR (j = 0; j < be_cnt_fx; j++) { - if( sub(abs_s(sub(Ravg_fx, shl(y_index_fx[j], QRavg))), th_5_fx) > 0 ) + if( GT_16(abs_s(sub(Ravg_fx, shl(y_index_fx[j], QRavg))), th_5_fx)) { enr_diffcnt_fx = add(enr_diffcnt_fx, 1); } @@ -192,7 +190,7 @@ void Bits2indvsb_fx ( L_R_temp[k] = L_add(L_shr(L_temp1, sub(add(QBavg, 1), SWB_BWE_LR_QRk)), L_shr(L_temp2, sub(add(QRavg, 16), SWB_BWE_LR_QRk))); /* SWB_BWE_LR_QRk */ } } - IF ( L_sub(L_R_temp[i], L_Bits_needed) < 0 ) + IF ( LT_32(L_R_temp[i], L_Bits_needed)) { L_R_temp[i] = L_deposit_l(0); @@ -311,7 +309,7 @@ void hq2_bit_alloc_har_fx ( gmax_range_fx[1]= G1G2_RANGE; move16(); - IF( L_sub(L_core_brate, HQ_16k40) == 0 ) + IF( EQ_32(L_core_brate, HQ_16k40)) { gmax_range_fx[1] = add(gmax_range_fx[1], 2); move16(); @@ -330,7 +328,7 @@ void hq2_bit_alloc_har_fx ( move16(); k_fx = 0; move16(); - WHILE( L_sub(L_temp_band_energy[gmax_range_fx[i]-1], L_temp_band_energy[j_fx] ) >= 0x0L && sub(j_fx, grp_rngmax_fx[i]) < 0x0 ) + WHILE(GE_32(L_temp_band_energy[gmax_range_fx[i] - 1], L_temp_band_energy[j_fx]) && LT_16(j_fx, grp_rngmax_fx[i]) ) { test(); k_fx = add(k_fx, 1); @@ -339,18 +337,18 @@ void hq2_bit_alloc_har_fx ( temp_fx = k_fx; move16(); - IF( sub(temp_fx, 1) > 0 ) + IF( GT_16(temp_fx, 1)) { FOR( temp_fx = 2; temp_fx <= k_fx ; ) { - IF( L_sub(L_temp_band_energy[gmax_range_fx[i]+temp_fx-1], L_temp_band_energy[gmax_range_fx[i]+temp_fx]) < 0 ) + IF( LT_32(L_temp_band_energy[gmax_range_fx[i]+temp_fx-1], L_temp_band_energy[gmax_range_fx[i]+temp_fx])) { BREAK; } - ELSE IF( L_sub(L_temp_band_energy[gmax_range_fx[i]+temp_fx-1], L_temp_band_energy[gmax_range_fx[i]+temp_fx]) >= 0 ) + ELSE IF( GE_32(L_temp_band_energy[gmax_range_fx[i]+temp_fx-1], L_temp_band_energy[gmax_range_fx[i]+temp_fx])) { temp_fx = add(temp_fx, 1);; - IF( sub(temp_fx, k_fx) > 0 ) + IF( GT_16(temp_fx, k_fx)) { temp_fx = sub(temp_fx, 1); BREAK; @@ -408,22 +406,22 @@ void hq2_bit_alloc_har_fx ( FOR(j=1; j< harmonic_band_fx; j++) { - IF( L_sub(L_temp_band_energydiff[j], L_G1_BE_DIFF_VAL) > 0 ) + IF( GT_32(L_temp_band_energydiff[j], L_G1_BE_DIFF_VAL)) { G1_BE_DIFF_POS_fx = j; move16(); - L_G1_BE_DIFF_VAL = L_add(0,L_temp_band_energydiff[j]); + L_G1_BE_DIFF_VAL = L_temp_band_energydiff[j]; } } test(); test(); - IF( sub(G1_BE_DIFF_POS_fx, gmax_range_fx[0] ) < 0 && G1_BE_DIFF_POS_fx > 0 ) + IF( LT_16(G1_BE_DIFF_POS_fx, gmax_range_fx[0] )&&G1_BE_DIFF_POS_fx>0) { final_gr_fact_pos_fx = 0; move16(); } - ELSE IF ( sub(G1_BE_DIFF_POS_fx, gmax_range_fx[0]) >= 0 && sub(G1_BE_DIFF_POS_fx, gmax_range_fx[1] ) < 0 ) + ELSE IF ( GE_16(G1_BE_DIFF_POS_fx, gmax_range_fx[0])&<_16(G1_BE_DIFF_POS_fx,gmax_range_fx[1])) { final_gr_fact_pos_fx = 1; move16(); @@ -435,9 +433,9 @@ void hq2_bit_alloc_har_fx ( } test(); - IF( final_gr_fact_pos_fx == 0 || sub(final_gr_fact_pos_fx, 1) == 0 ) + IF( final_gr_fact_pos_fx == 0 || EQ_16(final_gr_fact_pos_fx, 1)) { - IF( L_sub(L_core_brate, HQ_16k40 ) == 0 ) + IF( EQ_32(L_core_brate, HQ_16k40 )) { bits_fact_fx = BITS_FACT_1p10; move16(); /* 1.10f; */ /* G1 */ @@ -454,7 +452,7 @@ void hq2_bit_alloc_har_fx ( } ELSE { - IF( L_sub(L_core_brate, HQ_16k40) == 0 ) + IF( EQ_32(L_core_brate, HQ_16k40)) { bits_fact_fx = BITS_FACT_0p97; move16(); /* 0.97f; */ /* G1 */ @@ -545,7 +543,7 @@ void hq2_bit_alloc_har_fx ( L_avg_enhf_en_diff = L_sub(L_temp_band_energy[index_fx[0]], L_shl(L_deposit_h(div_fx), sub(sub(SWB_BWE_LR_Qbe, (add(Qns,sub(exp_normn,exp_normd)))),31))); /* Qbe - (Qns+exp_normn-(exp_normd)+15) -16 */ test(); - IF( sub(lf_hf_ge_r_fx , 26214) > 0x0 && L_sub(L_avg_enhf_en_diff, (Word32)(8< 0x0L) /* 0.8=26214.4(Q15) 8.0f=131072(Qbe) */ + IF(GT_16(lf_hf_ge_r_fx, 26214) && GT_32(L_avg_enhf_en_diff, (Word32)(8 << SWB_BWE_LR_Qbe))) /* 0.8=26214.4(Q15) 8.0f=131072(Qbe) */ { bits_allocweigh_fx = 6554; move16(); /* 0.2 6553.6(Q15) */ @@ -567,7 +565,7 @@ void hq2_bit_alloc_har_fx ( Bits_grp_fx[GRP_SB-1] = s_min(Bits_grp_fx[GRP_SB-1], 10); move16(); - if( sub(Bits_grp_fx[GRP_SB-1], esthf_bits_fx) < 0 ) + if( LT_16(Bits_grp_fx[GRP_SB-1], esthf_bits_fx)) { Bits_grp_fx[GRP_SB-1] = 0; move16(); @@ -580,7 +578,7 @@ void hq2_bit_alloc_har_fx ( B_norm_fx = shl(B_fx, exp_norm); exp_shift = add(exp_shift, exp_norm); - IF( sub(final_gr_fact_pos_fx, 1) == 0 ) + IF( EQ_16(final_gr_fact_pos_fx, 1)) { L_temp = Mult_32_16(L_Ravg_sub[1], extract_h(L_mult(bits_fact_fx, B_norm_fx))); L_temp = Mult_32_16(L_temp, Inv_norm_sum_fx); @@ -607,7 +605,7 @@ void hq2_bit_alloc_har_fx ( move16(); } - IF( sub(Bits_grp_fx[2], THR2 ) < 0 ) + IF( LT_16(Bits_grp_fx[2], THR2 )) { Bits_grp_fx[1] = add(Bits_grp_fx[1], Bits_grp_fx[2]); move16(); @@ -624,7 +622,7 @@ void hq2_bit_alloc_har_fx ( ELSE { set32_fx(L_Rsubband+grp_bound_fx[i], 0x0L, sub(grp_bound_fx[i+1], grp_bound_fx[i])); - IF( sub(i, GRP_SB-1) == 0 ) + IF( EQ_16(i, GRP_SB-1)) { set16_fx(p2a_flags_fx+grp_bound_fx[i], 0, sub(grp_bound_fx[i+1], grp_bound_fx[i])); } @@ -685,12 +683,12 @@ Word32 hq2_bit_alloc_fx ( L_THR3 = L_shl(L_deposit_l(THR3), SWB_BWE_LR_QRk); /* Init Rk to non-zero values for bands to be allocated bits */ - IF( sub(num_bits, HQ_16k40_BIT) <= 0 ) + IF( LE_16(num_bits, HQ_16k40_BIT)) { set32_fx( L_Rk, (Word32)(C1_QRk), bands); /* 1< 0 && sub(bit_budget_norm_fx, tmp) < 0 ) + IF( bit_budget_norm_fx > 0 && LT_16(bit_budget_norm_fx, tmp)) { div_fx = div_s(bit_budget_norm_fx, tmp); } @@ -782,7 +781,7 @@ Word32 hq2_bit_alloc_fx ( L_Rcalc = L_deposit_l(0); FOR (k = 0; k < bands; k++) { - IF ( L_sub(L_Rk[k], MIN_BITS_FIX) < 0 ) + IF ( LT_32(L_Rk[k], MIN_BITS_FIX)) { L_Rk[k] = L_deposit_l(0); negflag = 1; @@ -793,7 +792,7 @@ Word32 hq2_bit_alloc_fx ( /* prune noiselike bands with low allocation */ test(); - IF ( sub(num_bits, HQ_16k40_BIT) <= 0 && negflag == 0) + IF ( LE_16(num_bits, HQ_16k40_BIT)&&negflag==0) { L_maxxy = L_deposit_l(0); maxdex_fx = -1; @@ -807,16 +806,17 @@ Word32 hq2_bit_alloc_fx ( L_dummy = L_sub(L_shl(L_deposit_l(tmp_fx), SWB_BWE_LR_QRk), L_Rk[k]) ; /*SWB_BWE_LR_QRk */ test(); test(); - IF ( p2a_flags[k] == 0 && L_sub(L_dummy, L_maxxy) > 0 && L_Rk[k] > 0 ) + IF ( p2a_flags[k] == 0 && GT_32(L_dummy, L_maxxy)&&L_Rk[k]>0) { maxdex_fx = k; move16(); - L_maxxy = L_add(0,L_dummy); /*SWB_BWE_LR_QRk */ + L_maxxy = L_dummy; /*SWB_BWE_LR_QRk */ + move32(); } } /* prune worst allocation and recalculate total allocation */ - if ( sub(maxdex_fx, -1) > 0) + if ( GT_16(maxdex_fx, -1)) { L_Rk[maxdex_fx] = L_deposit_l(0); } @@ -827,12 +827,12 @@ Word32 hq2_bit_alloc_fx ( } test(); test(); - IF ( L_sub(L_Rcalc, L_Rcalc1) == 0 && sub(bwidth, SWB) == 0 ) + IF ( EQ_32(L_Rcalc, L_Rcalc1)&&EQ_16(bwidth,SWB)) { /* Reallocate bits to individual subbands for HQ_NORMAL mode */ /* if bits allocated to subbands areless than predefined threshold */ test(); - IF( sub(hqswb_clas, HQ_NORMAL) == 0 && sub(num_bits, HQ_16k40_BIT) < 0 ) + IF( EQ_16(hqswb_clas, HQ_NORMAL)&<_16(num_bits,HQ_16k40_BIT)) { L_dummy = L_deposit_l(0); FOR( k = 0; k < bands; k++ ) @@ -842,15 +842,15 @@ Word32 hq2_bit_alloc_fx ( test(); test(); test(); - IF( sub(k, 11) < 0 && L_sub(L_Rk[k], L_THR1) < 0 ) + IF( LT_16(k, 11)&<_32(L_Rk[k],L_THR1)) { L_Rk[k] = L_deposit_l(0); } - ELSE IF( sub(k, 11) >= 0 && sub(k, 16) < 0 && L_sub(L_Rk[k], L_THR2) < 0 ) + ELSE IF( GE_16(k, 11)&<_16(k,16)&<_32(L_Rk[k],L_THR2)) { L_Rk[k] = L_deposit_l(0); } - ELSE if( sub(k, 16) >= 0 && sub(k, bands ) < 0 && L_sub(L_Rk[k], L_THR3) < 0 ) + ELSE if( GE_16(k, 16)&<_16(k,bands)&<_32(L_Rk[k],L_THR3)) { L_Rk[k] = L_deposit_l(0); } @@ -858,10 +858,10 @@ Word32 hq2_bit_alloc_fx ( L_dummy = L_add(L_dummy, L_Rk[k]); } - IF( L_sub(L_dummy, L_Rcalc ) == 0 ) + IF( EQ_32(L_dummy, L_Rcalc )) { test(); - IF( sub(hqswb_clas, HQ_NORMAL) == 0 && sub(num_bits, HQ_16k40_BIT) < 0) + IF( EQ_16(hqswb_clas, HQ_NORMAL)&<_16(num_bits,HQ_16k40_BIT)) { bit_budget_temp_fx = *bit_budget_fx; move16(); @@ -876,14 +876,14 @@ Word32 hq2_bit_alloc_fx ( } } - IF( sub(bit_budget_temp_fx, *bit_budget_fx ) < 0) + IF( LT_16(bit_budget_temp_fx, *bit_budget_fx )) { *bit_budget_fx = bit_budget_temp_fx; move16(); /* a negative *bit_budget_fx may occur here due to Bit Errors */ /* handled outside this function to properly set flag: st_fx->BER_detect */ } - ELSE IF( sub(bit_budget_temp_fx, *bit_budget_fx ) == 0 ) + ELSE IF( EQ_16(bit_budget_temp_fx, *bit_budget_fx )) { BREAK; } @@ -899,7 +899,7 @@ Word32 hq2_bit_alloc_fx ( BREAK; } } - ELSE IF ( L_sub(L_Rcalc, L_Rcalc1 ) == 0 && sub(bwidth, SWB) != 0) + ELSE IF ( EQ_32(L_Rcalc, L_Rcalc1 )&&NE_16(bwidth,SWB)) { BREAK; } diff --git a/lib_com/hq2_core_com_fx.c b/lib_com/hq2_core_com_fx.c index ae33a67c2ac756c8c9394b29467a3d4e10c68c9c..970d769e63bd768c959fc4b73994e56c154a0419 100644 --- a/lib_com/hq2_core_com_fx.c +++ b/lib_com/hq2_core_com_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" @@ -7,8 +7,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" #include "stl.h" -#include "wmc_auto.h" - #include "basop_mpy.h" /*--------------------------------------------------------------------------* @@ -234,19 +232,19 @@ void hq2_core_configure_fx ( xcore_config_fx = &xcore_config_32kHz_013200bps_long_fx; /* default set for VC Warning */ - IF ( sub(frame_length, L_FRAME8k) == 0 ) + IF ( EQ_16(frame_length, L_FRAME8k)) { IF( is_transient ) { - IF ( sub(num_bits, ACELP_7k20 / 50) <= 0 ) + IF ( LE_16(num_bits, ACELP_7k20 / 50)) { xcore_config_fx = &xcore_config_8kHz_007200bps_short_fx; } - ELSE IF ( sub(num_bits, ACELP_8k00 / 50) <= 0 ) + ELSE IF ( LE_16(num_bits, ACELP_8k00 / 50)) { xcore_config_fx = &xcore_config_8kHz_008000bps_short_fx; } - ELSE IF ( sub(num_bits, ACELP_13k20 / 50) <= 0 ) + ELSE IF ( LE_16(num_bits, ACELP_13k20 / 50)) { xcore_config_fx = &xcore_config_8kHz_013200bps_short_fx; } @@ -257,15 +255,15 @@ void hq2_core_configure_fx ( } ELSE { - IF ( sub(num_bits, ACELP_7k20 / 50) <= 0 ) + IF ( LE_16(num_bits, ACELP_7k20 / 50)) { xcore_config_fx = &xcore_config_8kHz_007200bps_long_fx; } - ELSE IF ( sub(num_bits, ACELP_8k00 / 50) <= 0 ) + ELSE IF ( LE_16(num_bits, ACELP_8k00 / 50)) { xcore_config_fx = &xcore_config_8kHz_008000bps_long_fx; } - ELSE IF ( sub(num_bits, ACELP_13k20 / 50) <= 0) + ELSE IF ( LE_16(num_bits, ACELP_13k20 / 50)) { xcore_config_fx = &xcore_config_8kHz_013200bps_long_fx; } @@ -275,16 +273,16 @@ void hq2_core_configure_fx ( } } } - ELSE IF ( sub(frame_length, L_FRAME16k) == 0 ) + ELSE IF ( EQ_16(frame_length, L_FRAME16k)) { IF (is_transient) { - IF ( sub(num_bits, ACELP_13k20 / 50) <= 0 ) + IF ( LE_16(num_bits, ACELP_13k20 / 50)) { xcore_config_fx = &xcore_config_16kHz_013200bps_short_fx; move16(); } - ELSE if ( sub(num_bits, ACELP_16k40 / 50) <= 0 ) + ELSE if ( LE_16(num_bits, ACELP_16k40 / 50)) { xcore_config_fx = &xcore_config_16kHz_016400bps_short_fx; move16(); @@ -292,12 +290,12 @@ void hq2_core_configure_fx ( } ELSE { - IF ( sub(num_bits, ACELP_13k20 / 50) <= 0 ) + IF ( LE_16(num_bits, ACELP_13k20 / 50)) { xcore_config_fx = &xcore_config_16kHz_013200bps_long_fx; move16(); } - ELSE if ( sub(num_bits, ACELP_16k40 / 50) <= 0 ) + ELSE if ( LE_16(num_bits, ACELP_16k40 / 50)) { xcore_config_fx = &xcore_config_16kHz_016400bps_long_fx; move16(); @@ -308,12 +306,12 @@ void hq2_core_configure_fx ( { IF (is_transient) { - IF ( L_sub(L_bwe_br, ACELP_13k20) <= 0 ) + IF ( LE_32(L_bwe_br, ACELP_13k20)) { xcore_config_fx = &xcore_config_32kHz_013200bps_short_fx; move16(); } - ELSE if ( L_sub(L_bwe_br, ACELP_16k40) <= 0 ) + ELSE if ( LE_32(L_bwe_br, ACELP_16k40)) { xcore_config_fx = &xcore_config_32kHz_016400bps_short_fx; move16(); @@ -321,12 +319,12 @@ void hq2_core_configure_fx ( } ELSE { - IF ( L_sub(L_bwe_br, ACELP_13k20) <= 0 ) + IF ( LE_32(L_bwe_br, ACELP_13k20)) { xcore_config_fx = &xcore_config_32kHz_013200bps_long_fx; move16(); } - ELSE if ( L_sub(L_bwe_br, ACELP_16k40) <= 0 ) + ELSE if ( LE_32(L_bwe_br, ACELP_16k40)) { xcore_config_fx = &xcore_config_32kHz_016400bps_long_fx; move16(); @@ -481,7 +479,7 @@ void spt_shorten_domain_pre_fx( const Word16 *p_bw_SPT_tbl; /* pointer of bw_SPT_tbl */ p_bw_SPT_tbl = bw_SPT_tbl[0]; - if( L_sub(L_bwe_br, HQ_16k40) == 0 ) + if( EQ_32(L_bwe_br, HQ_16k40)) { p_bw_SPT_tbl = bw_SPT_tbl[1]; } @@ -503,14 +501,14 @@ void spt_shorten_domain_pre_fx( new_band_end[j] = add(prev_SWB_peak_pos[kpos], new_band_width_half); move16(); - IF( sub(new_band_start[j], band_start[k]) < 0 ) + IF( LT_16(new_band_start[j], band_start[k])) { new_band_start[j] = band_start[k]; move16(); new_band_end[j] = add(new_band_start[j], sub(new_band_width[j],1)); move16(); } - ELSE IF ( sub(new_band_end[j], band_end[k]) > 0 ) + ELSE IF ( GT_16(new_band_end[j], band_end[k])) { new_band_end[j] = band_end[k]; move16(); @@ -638,7 +636,7 @@ void spt_swb_peakpos_tmp_save_fx( { L_abs_y2 = L_abs(L_y2[i]); move32(); - IF( L_sub( L_peak_max, L_abs_y2) < 0x0L ) + IF( LT_32( L_peak_max, L_abs_y2)) { L_peak_max = L_abs_y2; move32(); @@ -677,8 +675,8 @@ void bit_allocation_second_fx( test(); test(); test(); - IF((( sub(k_sort[k],sub(BANDS,p2a_bands)) >= 0 )&&( sub(p2a_flags[k_sort[k]],1) == 0 )) || - (( sub(k_sort[k],sub(BANDS,2)) >= 0 )&&( sub(last_bitalloc[sub(k_sort[k], sub(BANDS,2))], 1) == 0 ))) + IF((( GE_16(k_sort[k],sub(BANDS,p2a_bands)))&&(EQ_16(p2a_flags[k_sort[k]],1)))|| + (( GE_16(k_sort[k],sub(BANDS,2)) )&&( EQ_16(last_bitalloc[sub(k_sort[k], sub(BANDS,2))], 1) ))) { exp = norm_s(band_width[k_sort[k]]); tmp = shl(band_width[k_sort[k]],exp);/*Q(exp) */ @@ -686,7 +684,7 @@ void bit_allocation_second_fx( L_tmp = Mult_32_16(Rk_sort[k],tmp);/* Q(16+29-exp-15 = 30-exp) */ tmp = sub(18,exp); ever_bits[k] = extract_l(L_shr(L_tmp,tmp));/*Q12 */ - IF( sub(ever_bits[k],rk_temp) < 0 ) + IF( LT_16(ever_bits[k],rk_temp)) { rk_temp = ever_bits[k]; move16(); @@ -697,12 +695,12 @@ void bit_allocation_second_fx( } } test(); - IF( class_flag ==0 || sub(input_frame,L_FRAME8k) == 0) + IF( class_flag ==0 || EQ_16(input_frame,L_FRAME8k)) { FOR(k = 0; k < BANDS; k++) { test(); - IF( sub(k_sort[k],sub(BANDS,p2a_bands)) < 0 && Rk_sort[k] > 0 ) + IF( LT_16(k_sort[k],sub(BANDS,p2a_bands))&&Rk_sort[k]>0) { exp = norm_s(band_width[k_sort[k]]); tmp = shl(band_width[k_sort[k]],exp);/*Q(exp) */ @@ -710,7 +708,7 @@ void bit_allocation_second_fx( L_tmp = Mult_32_16(Rk_sort[k],tmp);/* Q(16+29-exp-15 = 30-exp) */ tmp = sub(18,exp); ever_sort[k] = extract_l(L_shr(L_tmp,tmp));/*Q12 */ - IF(sub(ever_sort[k],ever_temp) < 0) + IF(LT_16(ever_sort[k],ever_temp)) { ever_temp = ever_sort[k]; move16(); @@ -722,11 +720,11 @@ void bit_allocation_second_fx( } k_num[0] = k2; - IF(sub(k_sort[k2],sub(BANDS,1)) == 0) + IF(EQ_16(k_sort[k2],sub(BANDS,1))) { FOR (k = 0; k < BANDS; k++) { - if(sub(k_sort[k],sub(k_sort[k2],1)) == 0) + if(EQ_16(k_sort[k],sub(k_sort[k2],1))) { k_num[1] = k; move16(); @@ -737,7 +735,7 @@ void bit_allocation_second_fx( { FOR (k = 0; k < BANDS; k++) { - if(sub(k_sort[k],add(k_sort[k2],1)) == 0) + if(EQ_16(k_sort[k],add(k_sort[k2],1))) { k_num[1] = k; move16(); @@ -746,11 +744,11 @@ void bit_allocation_second_fx( } ELSE { - IF ( L_sub( Rk[sub(k_sort[k2],1)],Rk[add(k_sort[k2],1)] ) < 0 ) + IF ( LT_32( Rk[sub(k_sort[k2],1)],Rk[add(k_sort[k2],1)] )) { FOR (k = 0; k < BANDS; k++) { - if(sub(k_sort[k],sub(k_sort[k2],1)) == 0) + if(EQ_16(k_sort[k],sub(k_sort[k2],1))) { k_num[1] = k; move16(); @@ -761,7 +759,7 @@ void bit_allocation_second_fx( { FOR (k = 0; k < BANDS; k++) { - if(sub(k_sort[k],add(k_sort[k2],1)) == 0) + if(EQ_16(k_sort[k],add(k_sort[k2],1))) { k_num[1] = k; move16(); diff --git a/lib_com/hq2_noise_inject_fx.c b/lib_com/hq2_noise_inject_fx.c index ca72474064d55a22d04d6f82dffd27ef9e7b7682..5f6934c68bd75133f6fc878af9d129749d70c9c7 100644 --- a/lib_com/hq2_noise_inject_fx.c +++ b/lib_com/hq2_noise_inject_fx.c @@ -1,11 +1,9 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" #include "stl.h" -#include "wmc_auto.h" - #include "prot_fx.h" #include "math_op.h" #include "math_32.h" @@ -77,11 +75,11 @@ void hq2_noise_inject_fx( test(); test(); test(); - IF( (sub(hqswb_clas,HQ_HARMONIC) ==0 || sub(hqswb_clas,HQ_NORMAL) ==0 ) && (L_sub(bwe_br,HQ_16k40) ==0 || L_sub(bwe_br,HQ_13k20) ==0 ) && sub(bwidth,SWB) ==0 ) + IF( (EQ_16(hqswb_clas,HQ_HARMONIC)||EQ_16(hqswb_clas,HQ_NORMAL))&&(EQ_32(bwe_br,HQ_16k40)||EQ_32(bwe_br,HQ_13k20))&&EQ_16(bwidth,SWB)) { sb = 17; move16(); - if( L_sub(bwe_br,HQ_16k40) == 0 ) + if( EQ_32(bwe_br,HQ_16k40)) { sb = 19; move16(); @@ -97,12 +95,14 @@ void hq2_noise_inject_fx( L_tmp = Mult_32_16(Rk_fx[k],tmp);/*Q(16+15-15=16) */ pd_fx[k] = extract_h(L_shl(L_tmp,10)); /*16+10-16 =Q10 */ - L_tmp2 = L_add(0,Ep_fx[k]);/*Q0 */ + L_tmp2 = Ep_fx[k];/*Q0 */ + move32(); L_tmp = L_max(1, L_tmp2); exp = norm_l(L_tmp); tmp = extract_h(L_shl(L_tmp, exp)); - L_tmp3 = L_add(0,(Word32)band_width[k]); + L_tmp3 = (Word32)band_width[k]; + move32(); exp2 = norm_l(L_tmp3); tmp2 = extract_h(L_shl(L_tmp3, exp2)); @@ -138,7 +138,7 @@ void hq2_noise_inject_fx( L_tmp =L_mult0(y2hat_fx[i],y2hat_fx[i]); /*0 */ Ep_fx[k] =L_sub(Ep_fx[k],L_tmp); move32();/*0 */ - IF(sub(abs_s(y2hat_fx[i]),peak_fx[k]) > 0) + IF(GT_16(abs_s(y2hat_fx[i]),peak_fx[k])) { peak_fx[k] = abs_s(y2hat_fx[i]); move16();/*0 */ @@ -152,7 +152,8 @@ void hq2_noise_inject_fx( } max_pos_pulse = k; - L_tmp2 = L_add(0,Ep_fx[k]); + L_tmp2 = Ep_fx[k]; + move32(); L_tmp = L_max(1, L_tmp2); exp = norm_l(L_tmp); tmp = extract_h(L_shl(L_tmp, exp)); @@ -194,7 +195,7 @@ void hq2_noise_inject_fx( /* calculate the noise gain */ satur =0; move16(); - if(sub(pd_fx[k],819)>= 0) + if(GE_16(pd_fx[k],819)) { satur =1; move16(); @@ -205,9 +206,9 @@ void hq2_noise_inject_fx( { IF(npulses[k] != 0) { - IF( sub(bwidth,SWB) ==0) + IF( EQ_16(bwidth,SWB)) { - IF(sub(hqswb_clas,HQ_TRANSIENT) !=0 ) + IF(NE_16(hqswb_clas,HQ_TRANSIENT)) { IF(peak_fx[k]!=0) { @@ -227,7 +228,7 @@ void hq2_noise_inject_fx( tmpx = add(tmp,1); tmp2 = extract_l(L_shr(L_tmp2x,s_min(tmpx, 31)));/*Q13 Ep[k]/peak[k] */ - IF(sub(hqswb_clas,HQ_HARMONIC) == 0 ) + IF(EQ_16(hqswb_clas, HQ_HARMONIC)) { tmp = sub(1536,pd_fx[k]); /*Q10 */ tmp3 = shl(tmp,4); /*Q14 */ @@ -260,14 +261,14 @@ void hq2_noise_inject_fx( fac_fx = tmp1; move16();/*Q12 */ - if(sub(k,sb) > 0) + if(GT_16(k,sb)) { fac_fx =mult(24576,tmp2);/*//Q(14+13-15=12) */ } } ELSE { - IF(sub(k,sb) <= 0) + IF(LE_16(k,sb)) { tmp = sub(1536,pd_fx[k]); /*Q10 */ tmp3 = shl(tmp,4); /*Q14 */ @@ -321,7 +322,7 @@ void hq2_noise_inject_fx( fac_fx = extract_h(L_shl(L_tmp,tmp));/*Q12 */ test(); - IF(sub(k,1) > 0 && sub(k,sub(ni_end_band,1)) < 0) + IF(GT_16(k,1)&<_16(k,sub(ni_end_band,1))) { IF(env_fx2[k]!=0) { @@ -360,7 +361,7 @@ void hq2_noise_inject_fx( } test(); - IF(sub(k,sub(ni_end_band,p2a_bands)) >= 0 && sub(bwidth, WB) == 0) + IF(GE_16(k,sub(ni_end_band,p2a_bands))&&EQ_16(bwidth,WB)) { L_tmp = Mult_32_16(enerH_fx, bw_low); L_tmp2= Mult_32_16(enerL_fx, bw_high); @@ -427,7 +428,7 @@ void hq2_noise_inject_fx( fac_fx = 4505; move16(); test(); - if( sub(hqswb_clas,HQ_HARMONIC) == 0 && sub(bwidth,SWB) == 0 ) + if( EQ_16(hqswb_clas,HQ_HARMONIC)&&EQ_16(bwidth,SWB)) { fac_fx = 3277; move16(); @@ -446,16 +447,16 @@ void hq2_noise_inject_fx( /* smooth the noise gain between the current frame and the previous frame */ pos = s_max(max_pos_pulse, *last_max_pos_pulse); move16(); - if( sub(bwidth,SWB) == 0 ) + if( EQ_16(bwidth,SWB)) { pos = sub(ni_end_band,1); move16(); } - IF(sub(k,pos) <=0 ) + IF(LE_16(k,pos)) { test(); - IF(k > 0 && add(sub(k,ni_end_band),1) < 0) + IF(k > 0 && LT_16(sub(k,ni_end_band),-1)) { tmp1 = mult(last_env_fx[k],16384);/*Q(1+15-15=1) Q1 */ tmp2 = sub(env_fx2[k],tmp1);/*>0 */ @@ -474,7 +475,7 @@ void hq2_noise_inject_fx( test(); IF( (tmp2 > 0 && tmp3 < 0) ||(L_tmp2 > 0 && L_tmp3 < 0)) { - IF( L_sub(ni_gain_fx[k],last_ni_gain_fx[k]) > 0 ) + IF( GT_32(ni_gain_fx[k],last_ni_gain_fx[k])) { L_tmp = Mult_32_16(ni_gain_fx[k],6554);/*Q(17+15-15 = 17) */ L_tmp1 = Mult_32_16(last_ni_gain_fx[k],26214);/*Q17 */ @@ -508,7 +509,7 @@ void hq2_noise_inject_fx( test(); IF( (tmp2 > 0 && tmp3 < 0) ||(L_tmp2 > 0 && L_tmp3 < 0)) { - IF( L_sub(ni_gain_fx[k],last_ni_gain_fx[k]) > 0 ) + IF( GT_32(ni_gain_fx[k],last_ni_gain_fx[k])) { L_tmp = Mult_32_16(ni_gain_fx[k],6554);/*Q(17+15-15 = 17) */ L_tmp1 = Mult_32_16(last_ni_gain_fx[k],26214);/*Q17 */ @@ -529,7 +530,7 @@ void hq2_noise_inject_fx( /* inject noise into the non-decoded coeffs */ test(); test(); - IF(add(sub(k,ni_end_band),p2a_bands) >=0 && p2a_flags[k] == 0 && sub(bwidth,SWB) !=0 ) + IF(add(sub(k,ni_end_band),p2a_bands) >=0 && p2a_flags[k] == 0 && NE_16(bwidth,SWB) ) { FOR (i = band_start[k]; i <= band_end[k]; i++) { @@ -544,7 +545,7 @@ void hq2_noise_inject_fx( test(); test(); test(); - IF(sub(k,max_pos_pulse) == 0 && add(sub(k,bands),p2a_bands)< 0 && sub(satur,1) != 0 && sub(bwidth,SWB) !=0) + IF(EQ_16(k,max_pos_pulse)&&add(sub(k,bands),p2a_bands)<0&&NE_16(satur,1)&&NE_16(bwidth,SWB)) { j = 0; Q_speech = norm_l(ni_gain_fx[k]); diff --git a/lib_com/hq_bit_allocation_fx.c b/lib_com/hq_bit_allocation_fx.c index 4220ce41678beafb5e5c58994895967388fb396f..c350b70de49181da58ac6d9859f1394d4f71255a 100644 --- a/lib_com/hq_bit_allocation_fx.c +++ b/lib_com/hq_bit_allocation_fx.c @@ -1,11 +1,9 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ -#include "stl.h" -#include "wmc_auto.h" - /* required for wmc_tool */ +#include "stl.h" /* required for wmc_tool */ #include "prot_fx.h" /* Function prototypes */ #include "cnst_fx.h" /* Common constants */ @@ -54,16 +52,16 @@ void hq_bit_allocation_fx( test(); test(); test(); - if( sub(hqswb_clas, HQ_TRANSIENT) != 0 && sub(hqswb_clas, HQ_HVQ) != 0 && !(sub(length, L_FRAME16k) == 0 && L_sub(core_brate, HQ_32k) == 0)) + if( NE_16(hqswb_clas, HQ_TRANSIENT)&&NE_16(hqswb_clas,HQ_HVQ)&&!(EQ_16(length,L_FRAME16k)&&EQ_32(core_brate,HQ_32k))) { /* 'nf_idx' 2-bits index written later */ *num_bits = sub(*num_bits, 2); } test(); - IF ( sub(hqswb_clas, HQ_GEN_SWB) == 0 || sub(hqswb_clas, HQ_GEN_FB) == 0 ) + IF ( EQ_16(hqswb_clas, HQ_GEN_SWB)||EQ_16(hqswb_clas,HQ_GEN_FB)) { - IF ( L_sub(core_brate, HQ_32k) == 0 ) + IF ( EQ_32(core_brate, HQ_32k)) { *num_bits = sub(*num_bits, HQ_GENERIC_SWB_NBITS2 ); } @@ -72,17 +70,17 @@ void hq_bit_allocation_fx( *num_bits = sub(*num_bits, HQ_GENERIC_SWB_NBITS ); } - if ( sub(hqswb_clas, HQ_GEN_FB) == 0 ) + if ( EQ_16(hqswb_clas, HQ_GEN_FB)) { *num_bits = sub(*num_bits, HQ_GENERIC_FB_NBITS ); } } - IF( ( sub(length, L_FRAME48k) == 0 ) && (sub(hqswb_clas, HQ_HARMONIC) != 0) && (sub(hqswb_clas, HQ_HVQ) != 0)) + IF( ( EQ_16(length, L_FRAME48k))&&(NE_16(hqswb_clas,HQ_HARMONIC))&&(NE_16(hqswb_clas,HQ_HVQ))) { tmp = 0; move16(); - if( sub(hqswb_clas,HQ_TRANSIENT) == 0 ) + if( EQ_16(hqswb_clas,HQ_TRANSIENT)) { tmp = 1; move16(); @@ -94,7 +92,7 @@ void hq_bit_allocation_fx( Copy( normqlg2, wnorm, nb_sfm ); } - IF( sub(hqswb_clas, HQ_HARMONIC) == 0 ) + IF( EQ_16(hqswb_clas, HQ_HARMONIC)) { /* classification and limit bandwidth for bit allocation */ sfm_limit = sub(sfm_limit, 2); @@ -111,7 +109,7 @@ void hq_bit_allocation_fx( FOR( i = SFM_G1; i < nb_sfm; i++) { E_hb_mean = add(E_hb_mean, wnorm[i]); - IF( sub(wnorm[i], E_max) > 0) + IF( GT_16(wnorm[i], E_max)) { E_max = wnorm[i]; move16(); @@ -125,7 +123,7 @@ void hq_bit_allocation_fx( { IF (L_msu(L_deposit_h(E_hb_mean), E_max, 21955) <= 0) /* 21955 = 0.67 (Q15) */ { - if (sub(i_max, sfm_limit) >= 0) + if (GE_16(i_max, sfm_limit)) { wnorm[i_max] = E_max; move16(); @@ -137,18 +135,18 @@ void hq_bit_allocation_fx( test(); test(); test(); - IF( sub(hqswb_clas, HQ_HVQ) == 0 ) + IF( EQ_16(hqswb_clas, HQ_HVQ)) { *sum = 0; move16(); } - ELSE IF ( sub(hqswb_clas, HQ_GEN_SWB) == 0 || (sub(hqswb_clas, HQ_TRANSIENT) == 0 && sub(length, L_FRAME32k) == 0 && L_sub(core_brate, HQ_32k) <= 0) ) + ELSE IF ( EQ_16(hqswb_clas, HQ_GEN_SWB)||(EQ_16(hqswb_clas,HQ_TRANSIENT)&&EQ_16(length,L_FRAME32k)&&LE_32(core_brate,HQ_32k))) { *sum = BitAllocF_fx( wnorm, core_brate, *num_bits, nb_sfm, R, Rsubband, hqswb_clas, num_env_bands ); } - ELSE IF( sub(length, L_FRAME16k) == 0 && L_sub(core_brate, HQ_32k) == 0 ) + ELSE IF( EQ_16(length, L_FRAME16k)&&EQ_32(core_brate,HQ_32k)) { - IF( sub(hqswb_clas, HQ_TRANSIENT) != 0 ) + IF( NE_16(hqswb_clas, HQ_TRANSIENT)) { avrg_wnorm = wnorm[10]; move16(); @@ -160,7 +158,7 @@ void hq_bit_allocation_fx( avrg_wnorm = shr(avrg_wnorm, 3); FOR( i=0; i<4; i++ ) { - if( sub(wnorm[i], avrg_wnorm) < 0 ) + if( LT_16(wnorm[i], avrg_wnorm)) { wnorm[i] = avrg_wnorm; move16(); @@ -182,7 +180,7 @@ void hq_bit_allocation_fx( reordvct_fx(wnorm, nb_sfm, idx); /* enlarge the wnorm value so that more bits can be allocated to (sfm_limit/2 ~ sfm_limit) range */ - IF( sub(hqswb_clas, HQ_HARMONIC) == 0 ) + IF( EQ_16(hqswb_clas, HQ_HARMONIC)) { tmp = shr(sfm_limit,1); tmp2 = sub(tmp,1); @@ -200,14 +198,14 @@ void hq_bit_allocation_fx( *core_sfm = sub(nb_sfm, 1); test(); test(); - IF( hqswb_clas == HQ_NORMAL || sub(hqswb_clas, HQ_HARMONIC) == 0 ) + IF( hqswb_clas == HQ_NORMAL || EQ_16(hqswb_clas, HQ_HARMONIC)) { *core_sfm = find_last_band_fx(R, nb_sfm ); } - ELSE IF ( sub(hqswb_clas, HQ_GEN_SWB) == 0 || sub(hqswb_clas, HQ_GEN_FB) == 0 ) + ELSE IF ( EQ_16(hqswb_clas, HQ_GEN_SWB)||EQ_16(hqswb_clas,HQ_GEN_FB)) { *core_sfm = find_last_band_fx( R, nb_sfm ); - IF ( sub(*core_sfm ,num_env_bands) <0 ) + IF ( LT_16(*core_sfm ,num_env_bands)) { *core_sfm = sub(num_env_bands,1); } diff --git a/lib_com/hq_conf_fx.c b/lib_com/hq_conf_fx.c index 0f147d5bc8cef01a20a4503ed59773bc95fa5028..fa1fb99c78464e9b723cb56824d6d74eee29e59e 100644 --- a/lib_com/hq_conf_fx.c +++ b/lib_com/hq_conf_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -7,9 +7,7 @@ #include "cnst_fx.h" /* Audio core constants */ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ -#include "stl.h" -#include "wmc_auto.h" - /* required for wmc_tool */ +#include "stl.h" /* required for wmc_tool */ /*--------------------------------------------------------------------------* * hq_configure() @@ -35,9 +33,9 @@ void hq_configure_fx( *start_norm = 0; move16(); - IF ( sub(length, L_FRAME48k) == 0 ) + IF ( EQ_16(length, L_FRAME48k)) { - IF ( sub(hqswb_clas, HQ_GEN_FB) == 0 ) + IF ( EQ_16(hqswb_clas, HQ_GEN_FB)) { *num_sfm = NB_SFM; move16(); @@ -49,12 +47,12 @@ void hq_configure_fx( move16(); test(); - IF ( L_sub(core_brate, HQ_32k) == 0 ) + IF ( EQ_32(core_brate, HQ_32k)) { *hq_generic_offset = HQ_GENERIC_FOFFSET_32K; move16(); } - ELSE IF ( L_sub(core_brate, HQ_16k40) == 0 || L_sub(core_brate, HQ_24k40) == 0 ) + ELSE IF ( EQ_32(core_brate, HQ_16k40)||EQ_32(core_brate,HQ_24k40)) { *hq_generic_offset = HQ_GENERIC_FOFFSET_24K4; move16(); @@ -62,12 +60,12 @@ void hq_configure_fx( /* setting start frequency of FD BWE */ test(); - IF ( L_sub(core_brate, HQ_32k) == 0 ) + IF ( EQ_32(core_brate, HQ_32k)) { *num_env_bands = SFM_N_STA_10k; move16(); } - ELSE IF ( L_sub(core_brate, HQ_16k40) == 0 || L_sub(core_brate, HQ_24k40) == 0 ) + ELSE IF ( EQ_32(core_brate, HQ_16k40)||EQ_32(core_brate,HQ_24k40)) { *num_env_bands = SFM_N_STA_8k; move16(); @@ -77,7 +75,7 @@ void hq_configure_fx( } ELSE { - IF(sub(hqswb_clas, HQ_HARMONIC) == 0) + IF(EQ_16(hqswb_clas, HQ_HARMONIC)) { *num_sfm = SFM_N_HARM_FB; move16(); @@ -93,9 +91,9 @@ void hq_configure_fx( *sfm_end = band_end_harm; move16(); } - ELSE IF ( sub(hqswb_clas, HQ_HVQ) == 0 ) + ELSE IF ( EQ_16(hqswb_clas, HQ_HVQ)) { - IF ( L_sub(core_brate, HQ_24k40) == 0 ) + IF ( EQ_32(core_brate, HQ_24k40)) { *num_sfm = SFM_N_HARM_FB; move16(); @@ -148,9 +146,9 @@ void hq_configure_fx( } } } - ELSE IF( sub(length, L_FRAME32k) == 0 ) + ELSE IF( EQ_16(length, L_FRAME32k)) { - IF ( sub(hqswb_clas, HQ_HARMONIC) == 0 ) + IF ( EQ_16(hqswb_clas, HQ_HARMONIC)) { *num_sfm = SFM_N_HARM; move16(); @@ -166,9 +164,9 @@ void hq_configure_fx( *sfm_end = band_end_harm; move16(); } - ELSE IF ( sub(hqswb_clas, HQ_HVQ) == 0 ) + ELSE IF ( EQ_16(hqswb_clas, HQ_HVQ)) { - IF ( L_sub(core_brate, HQ_24k40) == 0 ) + IF ( EQ_32(core_brate, HQ_24k40)) { *num_sfm = SFM_N_HARM; move16(); @@ -203,7 +201,7 @@ void hq_configure_fx( move16(); } } - ELSE IF ( sub(hqswb_clas, HQ_GEN_SWB) == 0 ) + ELSE IF ( EQ_16(hqswb_clas, HQ_GEN_SWB)) { *num_sfm = SFM_N_SWB; move16(); @@ -214,24 +212,24 @@ void hq_configure_fx( *sfm_end = band_end_HQ; move16(); - IF ( L_sub(core_brate, HQ_32k) == 0 ) + IF ( EQ_32(core_brate, HQ_32k)) { *hq_generic_offset = HQ_GENERIC_FOFFSET_32K; move16(); } - ELSE if ( L_sub(core_brate, HQ_24k40) == 0 ) + ELSE if ( EQ_32(core_brate, HQ_24k40)) { *hq_generic_offset = HQ_GENERIC_FOFFSET_24K4; move16(); } /* setting start frequency of HQ Generic */ - IF ( L_sub(core_brate, HQ_32k) == 0 ) + IF ( EQ_32(core_brate, HQ_32k)) { *num_env_bands = SFM_N_STA_10k; move16(); } - ELSE if( L_sub(core_brate, HQ_24k40) == 0 ) + ELSE if( EQ_32(core_brate, HQ_24k40)) { *num_env_bands = SFM_N_STA_8k; move16(); diff --git a/lib_com/hq_tools_fx.c b/lib_com/hq_tools_fx.c index c9cd2ee5f86e4d46c713f89580379744a0477a50..dec147d32a0c59ba727bf0bee314f5bb3053ecca 100644 --- a/lib_com/hq_tools_fx.c +++ b/lib_com/hq_tools_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include #include "options.h" /* Compilation switches */ #include "rom_com_fx.h" /* Static table prototypes FIP version */ -#include "stl.h" -#include "wmc_auto.h" - /* required for wmc_tool */ +#include "stl.h" /* required for wmc_tool */ #include "prot_fx.h" /*--------------------------------------------------------------------------* @@ -143,8 +141,9 @@ void limit_band_noise_level_calc_fx( ener_sum = add(ener_sum, wnorm[nb_sfm-1]); - fact = L_add(2022929597, 0); - if (L_sub(core_brate, HQ_24k40) == 0) + fact = 2022929597; + move32(); + if (EQ_32(core_brate, HQ_24k40)) { fact = L_add(1900523029, 1); } @@ -153,7 +152,7 @@ void limit_band_noise_level_calc_fx( i = 9; move16(); test(); - WHILE (L_sub(L_deposit_h(ener_limit), fact) < 0 && sub(add(i,1), nb_sfm) < 0) + WHILE (LT_32(L_deposit_h(ener_limit), fact)&<_16(add(i,1),nb_sfm)) { ener_limit = add(ener_limit, wnorm[++i]); test(); @@ -168,7 +167,7 @@ void limit_band_noise_level_calc_fx( move16(); } - IF (sub(*noise_level, shr(ener_sum, 2)) >= 0) + IF (GE_16(*noise_level, shr(ener_sum, 2))) { *noise_level = 0; move16(); @@ -366,7 +365,7 @@ void apply_noisefill_HQ_fx( test(); test(); - IF ( (sub(length, L_FRAME32k) >= 0) || (L_sub(L_core_brate, HQ_32k) > 0) || (L_sub(L_core_brate, HQ_24k40) < 0) ) + IF ( (GE_16(length, L_FRAME32k))||(GT_32(L_core_brate,HQ_32k))||(LT_32(L_core_brate,HQ_24k40))) { /* Read from codebook */ cb_pos = 0; @@ -376,10 +375,10 @@ void apply_noisefill_HQ_fx( { IF (R[sfm] == 0) { - IF (sub(flag_32K_env_ho, 1) == 0) + IF (EQ_16(flag_32K_env_ho, 1)) { L_E_cb_vec = L_deposit_l(0); - IF (sub(sfm, 20) < 0) + IF (LT_16(sfm, 20)) { FOR (i = 0; i < sfmsize[sfm]; i++) { @@ -387,7 +386,7 @@ void apply_noisefill_HQ_fx( move16(); L_E_cb_vec = L_mac0(L_E_cb_vec, cb_buff[i], cb_buff[i]); /*Q24 (12+12) */ - if (sub(cb_pos, cb_size) >= 0) + if (GE_16(cb_pos, cb_size)) { cb_pos = 0; move16(); @@ -402,7 +401,7 @@ void apply_noisefill_HQ_fx( move16(); L_E_cb_vec = L_mac0(L_E_cb_vec, cb_buff[i], cb_buff[i]); /*Q24 (12+12) */ - if (sub(cb_pos, cb_size) >= 0) + if (GE_16(cb_pos, cb_size)) { cb_pos = 0; move16(); @@ -432,7 +431,7 @@ void apply_noisefill_HQ_fx( { coeff[j] = CodeBook[cb_pos++]; move16(); - if (sub(cb_pos, cb_size) >= 0) + if (GE_16(cb_pos, cb_size)) { cb_pos = 0; move16(); @@ -483,7 +482,8 @@ void harm_bwe_fine_fx( { IF( R[sfm] != 0 ) { - normq = L_add(0,dicn_fx[norm[sfm]]); + normq = dicn_fx[norm[sfm]]; + move32(); FOR (i = sfm_start[sfm]; i < sfm_end[sfm]; i++) { @@ -535,7 +535,7 @@ void harm_bwe_fine_fx( dst = coeff_fine + sfm_end[last_sfm]; end = coeff_fine + sfm_end[num_sfm-1]; - IF (sub(sfm_end[last_sfm], sfm_end[high_sfm]) <= L_HARMONIC_EXC - START_EXC ) + IF (LE_16(sub(sfm_end[last_sfm], sfm_end[high_sfm]),(L_HARMONIC_EXC - START_EXC) )) { src = SWB_signal + START_EXC + sub(sfm_end[last_sfm], sfm_end[high_sfm]); } @@ -633,7 +633,7 @@ void hvq_bwe_fine_fx( FOR (i = 0; i < Npeaks; i++) { - if ( sub(peak_idx[i], L_HARMONIC_EXC) < 0 ) + if ( LT_16(peak_idx[i], L_HARMONIC_EXC)) { peak_pos[peak_idx[i]] = 1; move16(); @@ -643,13 +643,13 @@ void hvq_bwe_fine_fx( i = sub(L_HARMONIC_EXC, 1); WHILE ( i-- > 0 ) { - IF ( sub(peak_pos[i], 1) == 0 ) + IF ( EQ_16(peak_pos[i], 1)) { BREAK; } } - if ( sub(i, 180) < 0 ) + if ( LT_16(i, 180)) { i = 180; move16(); @@ -826,15 +826,15 @@ void harm_bwe_fx( noise_level[1] = round_fx(L_mac(L_tmp, 3277, noise_level[1])); test(); - IF (prev_hq_mode == HQ_NORMAL || sub(prev_hq_mode, HQ_GEN_SWB) == 0) + IF (prev_hq_mode == HQ_NORMAL || EQ_16(prev_hq_mode, HQ_GEN_SWB)) { - IF (sub(noise_level[0], 8192) < 0) + IF (LT_16(noise_level[0], 8192)) { noise_level[0] = shl(noise_level[0], 2); move16(); } - IF (sub(noise_level[1], 8192) < 0) + IF (LT_16(noise_level[1], 8192)) { noise_level[1] = shl(noise_level[1], 2); move16(); @@ -843,18 +843,20 @@ void harm_bwe_fx( FOR (i = add(last_sfm, 1); i < num_sfm; i++) { - E_L = L_add(0,1); + E_L = 1; + move32(); FOR (j = sfm_start[i]; j < sfm_end[i]; j++) { L_tmp =L_mult0(coeff_fine[j], coeff_fine[j]);/*Q30 */ E_L =L_add(E_L,L_shr(L_tmp,6));/*Q24 */ } - normq = L_add(0,dicn_fx[norm[i]]); + normq = dicn_fx[norm[i]]; + move32(); alfa = noise_level[0]; move16(); - if (sub(i, 27) > 0) + if (GT_16(i, 27)) { alfa = noise_level[1]; move16(); @@ -917,7 +919,7 @@ void harm_bwe_fx( *dst = Mult_32_16(*dst, hvq_bwe_fac_fx[i]); /* Q12 (12+15+1-16) */ move32(); dst--; } - IF(sub(num_sfm, 33) == 0) + IF(EQ_16(num_sfm, 33)) { set32_fx(&coeff_out[800], 0, 160); } @@ -986,15 +988,15 @@ void hvq_bwe_fx( noise_level[1] = round_fx(L_mac(L_mult(29491,prev_noise_level[1]),3277,noise_level[1])); /* Q15 (15+15+1-16) */ test(); - IF (prev_hq_mode == HQ_NORMAL || sub(prev_hq_mode, HQ_GEN_SWB) == 0) + IF (prev_hq_mode == HQ_NORMAL || EQ_16(prev_hq_mode, HQ_GEN_SWB)) { - IF( sub(noise_level[0], 8192 /* 0.25f */) < 0 ) + IF( LT_16(noise_level[0], 8192 /* 0.25f */)) { noise_level[0] = shl(noise_level[0], 2); move16(); } - IF( sub(noise_level[1], 8192 /* 0.25f */) < 0 ) + IF( LT_16(noise_level[1], 8192 /* 0.25f */)) { noise_level[1] = shl(noise_level[1], 2); move16(); @@ -1002,7 +1004,7 @@ void hvq_bwe_fx( } norm_ind = add(last_sfm, 1); - IF ( L_sub(core_brate, HQ_24k40) == 0 ) + IF ( EQ_32(core_brate, HQ_24k40)) { peak_band = 0; move16(); @@ -1145,7 +1147,7 @@ void hvq_bwe_fx( last_norm_ind = sub(num_sfm, 1); test(); test(); - IF ( sub(peak_band, 1) == 0 && sub(norm_ind,add(last_sfm, 1)) > 0 && sub(norm_ind, last_norm_ind) < 0 ) + IF ( EQ_16(peak_band, 1)&>_16(norm_ind,add(last_sfm,1))&<_16(norm_ind,last_norm_ind)) { istart = sub(istart, shr(sfm_len[norm_ind-1],1)); iend = add(iend, shr(sfm_len[norm_ind+1],1)); @@ -1162,7 +1164,8 @@ void hvq_bwe_fx( /* Headroom for square and accumulate */ shift = sub(norm_s(tmp), sqac_headroom_fx[band_size]); - L_E = L_add(0,1L); + L_E = 1L; + move32(); FOR (i = istart; i < iend; i++) { /* E_L += coeff_fine[i-offset] * coeff_fine[i-offset]; */ @@ -1179,13 +1182,14 @@ void hvq_bwe_fx( /* To avoid overflow in Isqrt() */ if( L_E == 0 ) { - L_E = L_add(1L,0); + L_E = 1L; + move32(); } L_E = Isqrt(L_E); /* Q17 (31-28/2) */ IF ( peak_band ) { - IF ( sub(add(norm_ind,2), num_sfm) > 0 ) + IF ( GT_16(add(norm_ind,2), num_sfm)) { /* normq = 0.15f*dicn[norm[norm_ind-1]] + 0.85f*dicn[norm[norm_ind]]; */ L_normq = Madd_32_16(Mult_32_16(dicn_fx[norm[norm_ind]], 27853 /* Q15, 0.85f */), dicn_fx[norm[norm_ind-1]], 4915 /* Q15, 0.1f */); /* Q14 (14+15+1-16) */ move16(); @@ -1209,7 +1213,7 @@ void hvq_bwe_fx( move16(); FOR (j = low; j <= high; j++) { - if ( sub(norm[j], sel_norm) > 0 ) + if ( GT_16(norm[j], sel_norm)) { sel_norm = norm[j]; move16(); @@ -1221,7 +1225,7 @@ void hvq_bwe_fx( iend = s_min(sfm_end[norm_ind], bwe_noise_th); move16(); - IF( sub(iend, sfm_start[norm_ind]) > 0 ) + IF( GT_16(iend, sfm_start[norm_ind])) { noise_mix_fx( &coeff_fine[-offset], L_E, L_normq, bwe_seed, sfm_start[norm_ind], iend, noise_level[0], L_coeff_out, qin, qout); } @@ -1232,7 +1236,7 @@ void hvq_bwe_fx( noise_mix_fx( &coeff_fine[-offset], L_E, L_normq, bwe_seed, sfm_start[norm_ind], iend, noise_level[1], L_coeff_out, qin, qout); } /* Noisemix up to threshold done */ - IF( sub(iend, bwe_noise_th) == 0 ) + IF( EQ_16(iend, bwe_noise_th)) { noise_mix_fx( &coeff_fine[-offset], L_E, L_normq, bwe_seed, iend, sfm_end[norm_ind], noise_level[1], L_coeff_out, qin, qout); } @@ -1287,7 +1291,7 @@ void hvq_concat_bands_fx FOR (k = 0; k < pvq_bands; k++) { - IF( sub(k, sub(pvq_bands, n_sel_bnds)) >= 0) + IF( GE_16(k, sub(pvq_bands, n_sel_bnds))) { k_1 = sub(k, 1); hvq_band_start[k] = hvq_band_end[k_1]; @@ -1483,7 +1487,7 @@ void map_hq_generic_fenv_norm_fx( set32_fx(env_fl,0,17); - IF ( sub(hq_generic_offset,144) == 0 ) + IF ( EQ_16(hq_generic_offset,144)) { env_fl[0] = L_shl(hq_generic_fenv[1],7); move32(); @@ -1532,9 +1536,9 @@ void map_hq_generic_fenv_norm_fx( move32(); } - IF ( sub(hqswb_clas, HQ_GEN_FB) == 0 ) + IF ( EQ_16(hqswb_clas, HQ_GEN_FB)) { - IF ( sub( hq_generic_offset, 144) == 0 ) + IF ( EQ_16( hq_generic_offset, 144)) { env_fl[9] = L_shl(hq_generic_fenv[12],7); move32(); @@ -1585,7 +1589,7 @@ static void update_rsubband_fx(const Word16 nb_sfm, i=sub(nb_sfm,1); WHILE(b_add_bits_denv>0 && i>=0) { - IF ( sub(Rsubband[i], 24)>0) + IF ( GT_16(Rsubband[i], 24)) { Rsubband[i] = sub(Rsubband[i] , 8); move16(); @@ -1612,7 +1616,7 @@ Word16 get_nor_delta_hf_fx( add_bits_denv = 0; move16(); - IF (sub(core_sfm ,num_env_bands) >= 0) + IF (GE_16(core_sfm ,num_env_bands)) { bitsforDelta = (Word16)get_next_indice_fx(st,2); bitsforDelta = add(bitsforDelta, 2); @@ -1628,7 +1632,7 @@ Word16 get_nor_delta_hf_fx( /* safety check in case of bit errors */ test(); - if ( ynrm[i] < 0 || sub(ynrm[i],39) > 0 ) + if ( ynrm[i] < 0 || GT_16(ynrm[i],39)) { ynrm[i] = 39; move16(); @@ -1682,16 +1686,16 @@ Word16 calc_nor_delta_hf_fx( { delta = negate(delta); } - if (sub(delta,max_delta)>0) + if (GT_16(delta,max_delta)) { max_delta = delta; move16(); } } } - IF (sub(core_sfm ,num_env_bands)>= 0) + IF (GE_16(core_sfm ,num_env_bands)) { - IF (sub(max_delta, 16) < 0) + IF (LT_16(max_delta, 16)) { bitsforDelta = 2; move16(); @@ -1717,12 +1721,12 @@ Word16 calc_nor_delta_hf_fx( IF (Rsubband[i]!=0) { delta = sub(ynrm_t[i] ,ynrm[i]); - IF (sub(delta, max_delta) > 0) + IF (GT_16(delta, max_delta)) { delta = max_delta; move16(); } - ELSE if (sub(delta , min_delta) < 0) + ELSE if (LT_16(delta , min_delta)) { delta = min_delta; move16(); @@ -1821,7 +1825,7 @@ void hq_wb_nf_bwe_fx( IF( is_transient == 0 ) { - IF( sub(prev_bfi, 1) == 0) + IF( EQ_16(prev_bfi, 1)) { Copy32(L_normq_v,prev_normq_fx,SFM_N_WB); } @@ -1836,7 +1840,7 @@ void hq_wb_nf_bwe_fx( total_bit = add(total_bit,R[sfm]); } test(); - IF(sub(last_sfm,8) > 0 && total_bit > 0) + IF(GT_16(last_sfm,8)&&total_bit>0) { exp = norm_s(total_bit); tmp = shl(total_bit,exp);/*Q(exp) */ @@ -1855,7 +1859,7 @@ void hq_wb_nf_bwe_fx( { tmp = shl(sfmsize[sfm], 9);/*Q9 */ tmp = mult( rat_fx[sfm],tmp );/*Q(14+9-15=8) */ - IF(sub(shl(R[sfm],8),tmp) >= 0) + IF(GE_16(shl(R[sfm],8),tmp)) { peak_fx = 0; move16(); @@ -1865,9 +1869,10 @@ void hq_wb_nf_bwe_fx( { fabs_coeff_out_fx = L_abs(L_coeff_out[i]); mean_fx = L_add(mean_fx, fabs_coeff_out_fx);/*Q12 */ - if(L_sub(fabs_coeff_out_fx, peak_fx) > 0) + if(GT_32(fabs_coeff_out_fx, peak_fx)) { - peak_fx = L_add(fabs_coeff_out_fx,0);/*Q12 */ + peak_fx = fabs_coeff_out_fx;/*Q12 */ + move32(); } } @@ -1927,7 +1932,7 @@ void hq_wb_nf_bwe_fx( exp = 0; move16(); test(); - IF(R[sfm] != 0 && sub(R[sfm], shl(mult(24756,sfmsize[sfm]),1)) < 0) + IF(R[sfm] != 0 && LT_16(R[sfm], shl(mult(24756,sfmsize[sfm]),1))) { /* calculate the energy of the undecoded coefficients */ env_fx =L_deposit_l(0); @@ -1936,19 +1941,22 @@ void hq_wb_nf_bwe_fx( L_tmp1 = Mult_32_32(L_tmp4,L_tmp4); /*2*exp1-3 14+exp1+14+exp1 -31 */ L_tmp2 =L_deposit_l(0); peak_fx = L_deposit_l(0); - min_coef_fx = L_add(0,0x7fffffff); + min_coef_fx = 0x7fffffff; + move32(); FOR (i = sfm_start[sfm]; i < sfm_end[sfm]; i++) { fabs_coeff_out_fx = L_abs(L_coeff_out[i]); test(); - if(L_sub(fabs_coeff_out_fx, min_coef_fx)<0 && L_coeff_out[i] != 0) + if(LT_32(fabs_coeff_out_fx, min_coef_fx)&&L_coeff_out[i]!=0) { - min_coef_fx = L_add(0,fabs_coeff_out_fx); + min_coef_fx = fabs_coeff_out_fx; + move32(); } - if(L_sub(fabs_coeff_out_fx,peak_fx) > 0) + if(GT_32(fabs_coeff_out_fx,peak_fx)) { - peak_fx = L_add(0,fabs_coeff_out_fx); + peak_fx = fabs_coeff_out_fx; + move32(); } } @@ -1988,7 +1996,7 @@ void hq_wb_nf_bwe_fx( prev_avrg_norm_fx = L_add(L_shr(prev_normq_fx[0],1),L_shr(prev_normq_fx[1],1));/*13 */ prev_avrg_norm_fx = L_add(prev_avrg_norm_fx,L_shr(prev_normq_fx[2],1));/*13 */ } - ELSE IF (sub(sfm,25) == 0) + ELSE IF (EQ_16(sfm,25)) { avrg_norm_fx = L_add(L_shr(L_normq_v[23],1),L_shr(L_normq_v[24],1));/*13 */ avrg_norm_fx = L_add(avrg_norm_fx,L_shr(L_normq_v[25],1));/*13 */ @@ -2005,7 +2013,7 @@ void hq_wb_nf_bwe_fx( test(); test(); - IF((sub(bitalloc_var_fx,4915) > 0 || L_sub(L_normq_v[sfm], peak_fx)<0) && peak_fx != 0) + IF((GT_16(bitalloc_var_fx,4915)||LT_32(L_normq_v[sfm],peak_fx))&&peak_fx!=0) { Word16 exp_p; exp_p =norm_l(peak_fx); @@ -2022,7 +2030,7 @@ void hq_wb_nf_bwe_fx( ELSE { L_tmp1 = Mult_32_16(L_normq_v[sfm],alfa_fx);/*12 13 + 14 + 1 -16 */ - IF(L_sub(L_tmp1,peak_fx)<0) + IF(LT_32(L_tmp1,peak_fx)) { exp=sub(31,exp); env_fx = Isqrt_lc(env_fx,&exp); @@ -2053,14 +2061,14 @@ void hq_wb_nf_bwe_fx( sharp_fx = add(sharp_fx,shr(step_fx,1)); } - IF(L_sub(L_tmp2,L_shl(min_coef_fx,sub(exp,13)))>0)/*exp */ + IF(GT_32(L_tmp2,L_shl(min_coef_fx,sub(exp,13))))/*exp */ { L_tmp2 = L_shr(min_coef_fx,1); exp = 12; move16(); } - IF(sub(prev_bfi,1) == 0) + IF(EQ_16(prev_bfi,1)) { prev_env_Q[sfm] = exp; move16(); @@ -2070,7 +2078,7 @@ void hq_wb_nf_bwe_fx( /* smooth the noise magnitudes between inter-frame */ test(); test(); - IF(L_sub(prev_avrg_norm_fx,L_shr(avrg_norm_fx,1))>0 && L_sub(prev_avrg_norm_fx,L_shl(avrg_norm_fx,1))<0 && prev_is_transient == 0) + IF(GT_32(prev_avrg_norm_fx,L_shr(avrg_norm_fx,1))&<_32(prev_avrg_norm_fx,L_shl(avrg_norm_fx,1))&&prev_is_transient==0) { exp1 =norm_l(prev_env_fx[sfm]); L_tmp1 = L_shl(prev_env_fx[sfm],exp1);/* prev_env_Q[sfm] +exp1 */ @@ -2118,7 +2126,8 @@ void hq_wb_nf_bwe_fx( move32(); } } - L_tmp2 = L_add(0,L_normq_v[sfm]); + L_tmp2 = L_normq_v[sfm]; + move32(); exp = 14; move16(); } @@ -2127,8 +2136,8 @@ void hq_wb_nf_bwe_fx( test(); test(); test(); - IF(sub(sfm,sub(SFM_N_WB,1))==0 && prev_is_transient == 0 && L_sub(prev_normq_fx[sfm],L_shr(L_normq_v[sfm],1))>0 - && L_sub(prev_normq_fx[sfm],L_shl(L_normq_v[sfm],1)) < 0 && sub(bitalloc_var_fx,4915) <= 0) + IF(EQ_16(sfm,sub(SFM_N_WB,1))&&prev_is_transient==0&>_32(prev_normq_fx[sfm],L_shr(L_normq_v[sfm],1)) + && LT_32(prev_normq_fx[sfm],L_shl(L_normq_v[sfm],1)) && LE_16(bitalloc_var_fx,4915)) { Word32 *p_prev_coeff_out = prev_coeff_out_fx; FOR (i = add(sfm_start[sfm],12); i < sfm_end[sfm]; i++) @@ -2137,8 +2146,8 @@ void hq_wb_nf_bwe_fx( test(); test(); test(); - IF(L_sub(L_abs(L_coeff_out[i]),L_shl(L_abs(*p_prev_coeff_out),2)) >0 - || L_sub(L_abs(L_coeff_out[i]),L_shr(L_abs(*p_prev_coeff_out),2)) <0 + IF(GT_32(L_abs(L_coeff_out[i]),L_shl(L_abs(*p_prev_coeff_out),2)) + || LT_32(L_abs(L_coeff_out[i]),L_shr(L_abs(*p_prev_coeff_out),2)) || ((R[sfm] == 0 || *prev_R == 0) && add(R[sfm], *prev_R) != 0)) { L_tmp = L_add(L_shr(L_abs(L_coeff_out[i]),1),L_shr(L_abs(*p_prev_coeff_out),1)); @@ -2205,9 +2214,9 @@ void enforce_zero_for_min_envelope_fx( Word16 i, j; /* prevent non-zero output for all-zero input */ - IF( sub(hqswb_clas,HQ_HVQ) != 0 ) + IF( NE_16(hqswb_clas,HQ_HVQ)) { - IF( sub(ynrm[0], 31) == 0 ) + IF( EQ_16(ynrm[0], 31)) { FOR( j = sfm_start[0]; j < sfm_end[0]; j++ ) { @@ -2217,7 +2226,7 @@ void enforce_zero_for_min_envelope_fx( FOR( i = 1; i < nb_sfm; i++ ) { - IF( sub(ynrm[i], 39) == 0 ) + IF( EQ_16(ynrm[i], 39)) { FOR( j = sfm_start[i]; j < sfm_end[i]; j++ ) { @@ -2262,12 +2271,12 @@ void apply_envelope_fx( len = num_sfm; move16(); test(); - if( sub(HQ_mode, HQ_GEN_SWB) == 0 || sub(HQ_mode, HQ_GEN_FB) == 0 ) + if( EQ_16(HQ_mode, HQ_GEN_SWB)||EQ_16(HQ_mode,HQ_GEN_FB)) { len = add(last_sfm, 1); } - IF( sub(length, L_FRAME16k) == 0 ) + IF( EQ_16(length, L_FRAME16k)) { FOR (sfm = 0; sfm < num_sfm; sfm++) { @@ -2297,7 +2306,8 @@ void apply_envelope_fx( Mpy_32_16_ss(normq_v[sfm], norm_adj[sfm], &normq_v[sfm], &lsb); move32(); /* Q14 (14+15+1-16) */ - normq = L_add(0,normq_v[sfm]); + normq = normq_v[sfm]; + move32(); FOR (i = sfm_start[sfm]; i < sfm_end[sfm]; i++) { /*coeff_out[i] = coeff[i]*normq; */ @@ -2308,11 +2318,12 @@ void apply_envelope_fx( } test(); - IF ( sub(HQ_mode, HQ_GEN_SWB) == 0 || sub(HQ_mode, HQ_GEN_FB) == 0 ) + IF ( EQ_16(HQ_mode, HQ_GEN_SWB)||EQ_16(HQ_mode,HQ_GEN_FB)) { FOR (sfm = 0; sfm <= last_sfm; sfm++) { - normq = L_add(0,normq_v[sfm]); + normq = normq_v[sfm]; + move32(); FOR (i = sfm_start[sfm]; i < sfm_end[sfm]; i++) { /*coeff_out1[i] = coeff_out1[i]*normq; */ diff --git a/lib_com/hvq_pvq_bitalloc_fx.c b/lib_com/hvq_pvq_bitalloc_fx.c index 2d99e2b5f22d4401ddd8b657cef9c4a13515bb86..24e86e8bc0bb141a18ce6969efc12cbd9a535bf4 100644 --- a/lib_com/hvq_pvq_bitalloc_fx.c +++ b/lib_com/hvq_pvq_bitalloc_fx.c @@ -1,11 +1,9 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ -#include "stl.h" -#include "wmc_auto.h" - /* required by wmc_tool */ +#include "stl.h" /* required by wmc_tool */ #include "rom_com_fx.h" @@ -45,7 +43,7 @@ Word16 hvq_pvq_bitalloc_fx( UWord16 lsb; Word16 num_sfm; - IF (sub(bwidth_fx, FB) == 0) + IF (EQ_16(bwidth_fx, FB)) { num_sfm = SFM_N_HARM_FB; } @@ -54,7 +52,7 @@ Word16 hvq_pvq_bitalloc_fx( num_sfm = SFM_N_HARM; } - IF ( L_sub(brate, HQ_24k40) == 0 ) + IF ( EQ_32(brate, HQ_24k40)) { band_max_bits = HVQ_BAND_MAX_BITS_24k; move16(); @@ -62,7 +60,7 @@ Word16 hvq_pvq_bitalloc_fx( move16(); k_start = HVQ_THRES_SFM_24k; move16(); - IF (sub(bwidth_fx, FB) == 0) + IF (EQ_16(bwidth_fx, FB)) { reciprocal = 2731; /* Q15, 1/(SFM_N_HARM_FB + 1 - k_start) */ move16(); } @@ -79,7 +77,7 @@ Word16 hvq_pvq_bitalloc_fx( move16(); k_start = HVQ_THRES_SFM_32k; move16(); - IF (sub(bwidth_fx, FB) == 0) + IF (EQ_16(bwidth_fx, FB)) { reciprocal = 3641; /* Q15, 1/(SFM_N_HARM_FB + 1 - k_start) */ move16(); } @@ -92,7 +90,7 @@ Word16 hvq_pvq_bitalloc_fx( num_bands = mult( num_bits, one_over_band_max_bits ); /* Q0 */ num_bits = sub( num_bits, i_mult(num_bands, band_max_bits) ); /* Q0 */ - IF ( sub(num_bits, HVQ_NEW_BAND_BIT_THR) >= 0 ) + IF ( GE_16(num_bits, HVQ_NEW_BAND_BIT_THR)) { num_bands = add(num_bands, 1); } @@ -102,7 +100,7 @@ Word16 hvq_pvq_bitalloc_fx( } /* safety check in case of bit errors */ - if (sub(num_bands, 1) < 0) + if (LT_16(num_bands, 1)) { return 0; } @@ -118,17 +116,19 @@ Word16 hvq_pvq_bitalloc_fx( { indx = ynrm[k]; move16(); - tmp = L_add(0,dicn_fx[indx]); /* Q14 */ + tmp = dicn_fx[indx]; /* Q14 */ + move32(); envSum = add(envSum, indx); /* Since the size of dicn_fx = 40, ynrm[k] must be less than 41. 16 bits are enough for envSum.*/ - IF (L_sub(tmp, E_max) > 0) + IF (GT_32(tmp, E_max)) { - E_max = L_add(0,tmp); + E_max = tmp; + move32(); k_max = k; move16(); } } env_mean = L_mult(envSum, reciprocal); /* env_mean in Q16 */ - IF (L_sub(L_sub(env_mean, L_deposit_h(ynrm[k_max])), 0x30000L) > 0) /* condition: env_mean - ynrm[k_max] > 3 */ + IF (GT_32(L_sub(env_mean, L_deposit_h(ynrm[k_max])), 0x30000L)) /* condition: env_mean - ynrm[k_max] > 3 */ { expo = norm_l(E_max); E_max = L_shl(E_max, expo); @@ -153,7 +153,7 @@ Word16 hvq_pvq_bitalloc_fx( IF (acc > 0) /* condition: E_max*5.e5 > E_peak */ { - IF ( sub(band_len_harm[k_max], 96) == 0 ) + IF ( EQ_16(band_len_harm[k_max], 96)) { n = 61; } @@ -162,9 +162,9 @@ Word16 hvq_pvq_bitalloc_fx( QuantaPerDsDirac_fx(band_len_harm[k_max], 1, hBitsN, &n); } m = shl(sub(num_bits, HVQ_PVQ_GAIN_BITS), 3); - IF (sub(m, n) >= 0) + IF (GE_16(m, n)) { - IF (sub(num_bands, 1) > 0) /* condition: num_bands > 1 */ + IF (GT_16(num_bands, 1)) /* condition: num_bands > 1 */ { sel_bands[*n_sel_bands] = k_max; move16(); diff --git a/lib_com/igf_base.c b/lib_com/igf_base.c index 3ba63258a3dec877668238c42890308c9428a557..a5ef9f9f0fdee02c291c744e1442852abcb76a21 100644 --- a/lib_com/igf_base.c +++ b/lib_com/igf_base.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -8,8 +8,6 @@ #include #include "options.h" #include "stl.h" -#include "wmc_auto.h" - #include "prot_fx.h" #include "rom_com_fx.h" #include "basop_util.h" @@ -24,7 +22,7 @@ static Word16 IGF_ApplyTransFac( { Word16 ret; - if(sub(transFac, 0x4000) == 0) + if(EQ_16(transFac, 0x4000)) { return val; } @@ -58,7 +56,7 @@ static Word16 IGF_MapBitRateToIndex( switch (bitRate) { case 13200: - if (sub(rf_mode,1) == 0) + if (EQ_16(rf_mode,1)) { bitRateIndex = IGF_BITRATE_RF_WB_13200; } @@ -78,7 +76,7 @@ static Word16 IGF_MapBitRateToIndex( break; case 13200: bitRateIndex = IGF_BITRATE_SWB_13200; - if (sub(rf_mode,1) == 0) + if (EQ_16(rf_mode,1)) { bitRateIndex = IGF_BITRATE_RF_SWB_13200; } @@ -727,7 +725,7 @@ Word16 IGFCommonFuncsIGFConfiguration( ,rf_mode ); - IF (sub(hIGFInfo->bitRateIndex, IGF_BITRATE_UNKNOWN) != 0) + IF (NE_16(hIGFInfo->bitRateIndex, IGF_BITRATE_UNKNOWN)) { retValue = 1; /* no error */ move16(); @@ -802,6 +800,7 @@ Word16 IGFCommonFuncsIGFGetCFTables( Word16 retValue; Word16 bitRateIndex; +Word16 temp_var; retValue = 0; /* bitrate index is unknown -> error! */ move16(); bitRateIndex = IGF_MapBitRateToIndex(bitRate, mode @@ -809,7 +808,7 @@ Word16 IGFCommonFuncsIGFGetCFTables( ); - IF (sub(bitRateIndex, IGF_BITRATE_UNKNOWN) != 0) + IF (NE_16(bitRateIndex, IGF_BITRATE_UNKNOWN)) { retValue = 1; /* no error */ move16(); SWITCH(bitRateIndex) @@ -826,8 +825,26 @@ Word16 IGFCommonFuncsIGFGetCFTables( *cf_se00 = cf_se00_tab; *cf_se01 = cf_se01_tab[bitRateIndex]; *cf_off_se01 = cf_off_se01_tab[bitRateIndex]; + temp_var = bitRateIndex; + if ((bitRateIndex == 0) || (bitRateIndex == 1)) + { + bitRateIndex = 0; + } + else if ((bitRateIndex == 2) || (bitRateIndex == 3) || (bitRateIndex == 4) || (bitRateIndex == 5)) + { + bitRateIndex = 1; + } + else if ((bitRateIndex == 6) || (bitRateIndex == 7)) + { + bitRateIndex = 2; + } + else if (bitRateIndex == 8) + { + bitRateIndex = 3; + } *cf_se02 = &cf_se02_tab[bitRateIndex][0][0]; move16(); + bitRateIndex = temp_var; *cf_off_se02 = &cf_off_se02_tab[bitRateIndex][0]; move16(); *cf_se10 = &cf_se10_tab[0]; @@ -845,8 +862,18 @@ Word16 IGFCommonFuncsIGFGetCFTables( *cf_se00 = cf_se00_tab; *cf_se01 = cf_se01_tab[bitRateIndex]; *cf_off_se01 = cf_off_se01_tab[bitRateIndex]; + temp_var = bitRateIndex; + if (bitRateIndex == 5) + { + bitRateIndex = 1; + } + else if (bitRateIndex == 6 || bitRateIndex == 7) + { + bitRateIndex = 2; + } *cf_se02 = &cf_se02_tab[bitRateIndex][0][0]; move16(); + bitRateIndex = temp_var; *cf_off_se02 = &cf_off_se02_tab[bitRateIndex][0]; move16(); *cf_se10 = &cf_se10_tab[0]; @@ -862,8 +889,11 @@ Word16 IGFCommonFuncsIGFGetCFTables( *cf_se00 = cf_se00_tab; *cf_se01 = cf_se01_tab[bitRateIndex]; *cf_off_se01 = cf_off_se01_tab[bitRateIndex]; + temp_var = bitRateIndex; + bitRateIndex = 3; *cf_se02 = &cf_se02_tab[bitRateIndex][0][0]; move16(); + bitRateIndex = temp_var; *cf_off_se02 = &cf_off_se02_tab[bitRateIndex][0]; move16(); *cf_se10 = &cf_se10_tab[0]; @@ -881,8 +911,11 @@ Word16 IGFCommonFuncsIGFGetCFTables( *cf_se00 = cf_se00_tab; *cf_se01 = cf_se01_tab[bitRateIndex]; *cf_off_se01 = cf_off_se01_tab[bitRateIndex]; + temp_var = bitRateIndex; + bitRateIndex = 3; *cf_se02 = &cf_se02_tab[bitRateIndex][0][0]; move16(); + bitRateIndex = temp_var; *cf_off_se02 = &cf_off_se02_tab[bitRateIndex][0]; move16(); *cf_se10 = &cf_se10_tab[0]; diff --git a/lib_com/index_pvq_opt_fx.c b/lib_com/index_pvq_opt_fx.c index 97beeee59594c2c1612ffdba82bc70cb880ff976..4e57c96baf88c1e6cf0e3cf29d7056b63645ce04 100644 --- a/lib_com/index_pvq_opt_fx.c +++ b/lib_com/index_pvq_opt_fx.c @@ -1,14 +1,12 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" #include "cnst_fx.h" /* Common constants */ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ -#include "stl.h" -#include "wmc_auto.h" - /* required for wmc_tool */ +#include "stl.h" /* required for wmc_tool */ #include "basop_util.h" #include @@ -240,7 +238,7 @@ void initOffsets_fx( Word16 dim_in , UWord32* h_mem, Word16 k_val_in) h_mem[1] = UL_deposit_l(1); /* A(*,k=1) */ UL_k_val_in = UL_deposit_l(k_val_in); - IF(sub(dim_in,2)==0) + IF(EQ_16(dim_in,2)) { FOR( k_val = 2 ; k_val <= UL_k_val_in ; k_val++ ) { @@ -403,11 +401,11 @@ UWord32 nm_h_prep_opt_fx( /* o: msize for dim */ mem_size_m1 = add(k_val_in,1); assert(dim_in > N_OPT_FX); /* code now optimized with direct functions for dim <= N_OPT_FX ) */ - IF( (sub(k_val_in, TABLE_LIM_OPT_FX) > 0) ) + IF( (GT_16(k_val_in, TABLE_LIM_OPT_FX))) { d_start = 2; move16(); - if( sub(dim_in,3) >= 0 ) + if( GE_16(dim_in,3)) { /* start from A(3), U(3) */ d_start = 3; @@ -453,7 +451,7 @@ UWord32 nm_h_prep_opt_fx( /* o: msize for dim */ add_last_odd = s_and(k_val_in,0x1) ; move16(); /* odd -> 0x00100*/ /* even loop limits, and odd tail exists , and */ - if(add_last_odd != 0 ) + if(NE_16(add_last_odd,0)) { end_loop = sub(end_loop,1); /* make initial loop to even number of (odd-even )pairs *//* one basicop */ } @@ -475,7 +473,7 @@ UWord32 nm_h_prep_opt_fx( /* o: msize for dim */ } } - IF( add_last_odd != 0 ) + if(NE_16(add_last_odd,0)) { /* add a last odd call as needed , not to be called if k_val_in is [0,1,2] */ h_saveB = UL_addNsD(h_saveB,f_even_exact_div_opt_fx(numDsub1, h_saveA, h_saveB, sub(k_val,1))); @@ -528,7 +526,7 @@ Word16 find_amp_split_offset_func_mem_fx( /* o: found k_v { /* (*tmp_offset < ind_in) */ low = add(1, k_test) ; - if( sub(k_test ,high) >= 0) + if( GE_16(k_test ,high)) { not_ready = 0; move16(); /* single basicop */ @@ -611,7 +609,7 @@ void mind2vec_two_fx( /* ind_in == 0 */ mind2vec_one_fx( k_val_in,leading_sign,ind_in,vec_out); } - ELSE IF ( sub((Word16)u_extract_l(ind_in), sub(shl(k_val_in,1),1)) == 0 ) + ELSE IF ( EQ_16((Word16)u_extract_l(ind_in), sub(shl(k_val_in,1),1))) { /* signed ops fine as 2*KMAX << 32767) */ /* (ind_in == ( (unsigned int)(k_val_in< 0 ) /* non-direct solutions, use A+U relation */ + IF(GT_16(dim_in, N_OPT_FX)) /* non-direct solutions, use A+U relation */ { entry.size = nm_h_prep_opt_fx(entry.dim, entry.k_val, h_mem); } @@ -874,7 +872,7 @@ void mpvq_decode_vec_fx( /* o : void */ IF(entry->k_val != 0) { - IF(sub(entry->dim,N_OPT_FX)> 0 ) /* N_OPT_FX */ + IF(GT_16(entry->dim,N_OPT_FX)) /* N_OPT_FX */ { /* generic */ mind2vec_fx(entry->dim, entry->k_val, leading_sign, entry->index, vec_out, h_mem); @@ -1170,7 +1168,7 @@ PvqEntry_fx mpvq_encode_vec_fx( /* o : leading_sign_ind result.dim = dim_in; move16(); /* NB , k_val_local may be changed in some sub encoding routines */ - IF( sub(dim_in, N_OPT_FX) > 0 ) + IF( GT_16(dim_in, N_OPT_FX)) { /* use the generic dimension function */ vec2mind_fx(dim_in, k_val_local, vec_in, &lead_sign_ind, &result.index, &result.size, h_mem); diff --git a/lib_com/int_lsp_fx.c b/lib_com/int_lsp_fx.c index dbc9dba00d9373246ed2bf52dd3d2d5aa564152f..08fe1003b145760646c9e09816cbf2c4f5e397a2 100644 --- a/lib_com/int_lsp_fx.c +++ b/lib_com/int_lsp_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -7,8 +7,6 @@ #include "prot_fx.h" /* Function prototypes */ #include "rom_com_fx.h" /* Static table prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*========================================================================*/ /* FUNCTION : int_lsp4_fx() */ @@ -50,17 +48,17 @@ void int_lsp4_fx( Word32 L_tmp; const Word16 *pt_int_coeffs; - IF( sub(L_frame,L_FRAME) == 0) + IF( EQ_16(L_frame,L_FRAME)) { - IF ( sub(relax_prev_lsf_interp,1) == 0) + IF ( EQ_16(relax_prev_lsf_interp,1)) { pt_int_coeffs = interpol_frac_mid_relaxprev_12k8_fx; } - ELSE IF ( sub(relax_prev_lsf_interp,2) == 0 ) + ELSE IF ( EQ_16(relax_prev_lsf_interp,2)) { pt_int_coeffs = interpol_frac_mid_FEC_fx; } - ELSE IF ( sub(relax_prev_lsf_interp,-1) == 0 ) + ELSE IF ( EQ_16(relax_prev_lsf_interp,-1)) { pt_int_coeffs = interpol_frac_mid_relaxprev_pred_12k8_fx; } @@ -71,15 +69,15 @@ void int_lsp4_fx( } ELSE /* L_frame == L_FRAME16k */ { - IF ( sub(relax_prev_lsf_interp,1) == 0 ) + IF ( EQ_16(relax_prev_lsf_interp,1)) { pt_int_coeffs = interpol_frac_mid_relaxprev_16k_fx; } - ELSE IF ( sub(relax_prev_lsf_interp,2) == 0 ) + ELSE IF ( EQ_16(relax_prev_lsf_interp,2)) { pt_int_coeffs = interpol_frac_mid_16k_FEC_fx; } - ELSE IF ( sub(relax_prev_lsf_interp,-1) == 0 ) + ELSE IF ( EQ_16(relax_prev_lsf_interp,-1)) { pt_int_coeffs = interpol_frac_mid_relaxprev_pred_16k_fx; } @@ -136,7 +134,7 @@ void int_lsp_fx( tmp = shr(L_frame,6); /*L_frame/L_SUBFR */ - IF( sub(L_frame,L_FRAME) == 0 ) + IF( EQ_16(L_frame,L_FRAME)) { pt_int_coeffs = int_coeffs; move16(); diff --git a/lib_com/interleave_spectrum_fx.c b/lib_com/interleave_spectrum_fx.c index 28cdfb98c47fa50a31fe4d26f624822dd3dede17..2f387052b86b88f2184366c2fa2db8fb2162cb80 100644 --- a/lib_com/interleave_spectrum_fx.c +++ b/lib_com/interleave_spectrum_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "cnst_fx.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ -#include "stl.h" -#include "wmc_auto.h" - /* required for wmc_tool */ +#include "stl.h" /* required for wmc_tool */ /*--------------------------------------------------------------------------* * interleave_spectrum_fx() @@ -33,7 +31,7 @@ void interleave_spectrum_fx( p1 = coefs; p_out = coefs_out; - IF ( sub(length, L_FRAME48k) == 0 ) + IF ( EQ_16(length, L_FRAME48k)) { bw = intl_bw_48; cnt = intl_cnt_48; @@ -43,7 +41,7 @@ void interleave_spectrum_fx( p3 = p2 + sublen[0]; p4 = p3 + sublen[0]; } - ELSE IF( sub(length, L_FRAME32k) == 0 ) + ELSE IF( EQ_16(length, L_FRAME32k)) { bw = intl_bw_32; cnt = intl_cnt_32; @@ -120,7 +118,7 @@ void de_interleave_spectrum_fx( /* common for all groups */ p1 = coefs_out; - IF ( sub(length, L_FRAME48k) == 0 ) + IF ( EQ_16(length, L_FRAME48k)) { bw = intl_bw_48; cnt = intl_cnt_48; @@ -131,7 +129,7 @@ void de_interleave_spectrum_fx( p3 = coefs_out + sublen[4]; /* 480, 2*length/4 */ p4 = coefs_out + sublen[5]; /* 720, 3*length/4 */ } - ELSE IF( sub(length, L_FRAME32k) == 0 ) + ELSE IF( EQ_16(length, L_FRAME32k)) { bw = intl_bw_32; cnt = intl_cnt_32; diff --git a/lib_com/interpol_fx.c b/lib_com/interpol_fx.c index 37c4cb7ad146d07071b24f0cf0a70003205fb1ef..521ebe6614563fe8d827f263d1c459a7cd5cd51f 100644 --- a/lib_com/interpol_fx.c +++ b/lib_com/interpol_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "prot_fx.h" /* Function prototypes */ #include "rom_com_fx.h" /* tables definition */ #include "stl.h" -#include "wmc_auto.h" - Word32 Interpol_lc_fx( /* o : interpolated value Qx+16 */ @@ -25,23 +23,20 @@ Word32 Interpol_lc_fx( /* o : interpolated value Qx+16 */ x2 = &x[1]; c1 = &win[frac]; c2 = &win[sub(up_samp,frac)]; - L_sum = L_mult0(*x--, *c1); - L_sum = L_mac0(L_sum, *x2++, *c2); - FOR (i=1; icore_brate_fx,SID_1k75) == 0 ) + IF ( EQ_32(st->core_brate_fx,SID_1k75)) { indice[0] = (Word16)get_next_indice_fx( st, 6 ); @@ -65,7 +63,7 @@ void isf_dec_amr_wb_fx( * ISF de-quantization of all other frames *-----------------------------------------------------------------*/ - IF( L_sub(st->core_brate_fx,ACELP_6k60) == 0 ) + IF( EQ_32(st->core_brate_fx,ACELP_6k60)) { indice[0] = (Word16)get_next_indice_fx( st, 8 ); move16(); @@ -203,7 +201,7 @@ void disf_2s_46b_fx( { i = 0; move16(); - WHILE (sub(Indirect_dico1[i], indice[0]) != 0) + WHILE (NE_16(Indirect_dico1[i], indice[0])) { i = add(i, 1); } @@ -276,7 +274,7 @@ void disf_2s_36b_fx( { i = 0; move16(); - WHILE (sub(Indirect_dico1[i], indice[0]) != 0) + WHILE (NE_16(Indirect_dico1[i], indice[0])) { i = add(i,1); } diff --git a/lib_com/lag_wind.c b/lib_com/lag_wind.c index d377d53714893442f16ef4fcb433cb029e13015c..682f95cf5ce9bf304aa02cb1d95a44d4511ddf34 100644 --- a/lib_com/lag_wind.c +++ b/lib_com/lag_wind.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -7,8 +7,6 @@ #include "rom_com_fx.h" #include "basop_util.h" #include "stl.h" -#include "wmc_auto.h" - /*-------------------------------------------------------------------* * Local constants @@ -102,21 +100,21 @@ void adapt_lag_wind( pitch_gain = Tnc; move16(); - IF (sub(pitch_lag, 80) < 0) + IF (LT_16(pitch_lag, 80)) { strength = LAGW_STRONG; move16(); - if (sub(pitch_gain, kLagWinThGain1) <= 0) + if (LE_16(pitch_gain, kLagWinThGain1)) { strength = LAGW_MEDIUM; move16(); } } - ELSE IF (sub(pitch_lag, 160) < 0) + ELSE IF (LT_16(pitch_lag, 160)) { strength = LAGW_MEDIUM; move16(); - if (sub(pitch_gain, kLagWinThGain2) <= 0) + if (LE_16(pitch_gain, kLagWinThGain2)) { strength = LAGW_WEAK; move16(); diff --git a/lib_com/lerp.c b/lib_com/lerp.c index 5106b92d804f61327ce9dac5c4fdbeed4398261e..ca6e3dd24284f5cf9779b2f1b1cc445352984403 100644 --- a/lib_com/lerp.c +++ b/lib_com/lerp.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" @@ -7,8 +7,6 @@ #include "prot_fx.h" #include #include "stl.h" -#include "wmc_auto.h" - @@ -30,16 +28,16 @@ void lerp(Word16 *f, Word16 *f_out, Word16 bufferNewSize, Word16 bufferOldSize) tmp2 = shl(tmp2,tmpexp); test(); test(); - IF(sub(tmp1,16224 /*3,9609375 in Q12*/) > 0) + IF(GT_16(tmp1,16224 /*3,9609375 in Q12*/)) { Word16 tmpNewSize = shl(bufferOldSize,1); - WHILE(sub(bufferNewSize, bufferOldSize) > 0) + WHILE(GT_16(bufferNewSize, bufferOldSize)) { BASOP_Util_Divide_MantExp(bufferNewSize, 0, bufferOldSize, 0, &tmp1, &tmpexp); tmp1 = shr(tmp1,3); /*Q12*/ tmp1 = shl(tmp1,tmpexp); test(); - IF(sub(tmp1,16224 /*3,9609375 in Q12*/) <= 0) + IF(LE_16(tmp1,16224 /*3,9609375 in Q12*/)) { tmpNewSize = bufferNewSize; } @@ -51,16 +49,16 @@ void lerp(Word16 *f, Word16 *f_out, Word16 bufferNewSize, Word16 bufferOldSize) tmpNewSize = shl(tmpNewSize,1); } } - ELSE IF(sub(tmp2,16224 /*3,9609375 in Q12*/) > 0) + ELSE IF(GT_16(tmp2,16224 /*3,9609375 in Q12*/)) { Word16 tmpNewSize = shr(bufferOldSize,1); - WHILE(sub(bufferNewSize, bufferOldSize) < 0) + WHILE(LT_16(bufferNewSize, bufferOldSize)) { BASOP_Util_Divide_MantExp(bufferOldSize, 0, bufferNewSize, 0, &tmp2, &tmpexp); tmp2 = shr(tmp2,3); /*Q12*/ tmp2 = shl(tmp2,tmpexp); test(); - IF(sub(tmp2,16224 /*3,9609375 in Q12*/) <= 0) + IF(LE_16(tmp2,16224 /*3,9609375 in Q12*/)) { tmpNewSize = bufferNewSize; } @@ -98,7 +96,7 @@ void lerp_proc(Word16 *f, Word16 *f_out, Word16 bufferNewSize, Word16 bufferOld move16(); } - IF( sub(bufferNewSize, bufferOldSize) == 0 ) + IF( EQ_16(bufferNewSize, bufferOldSize)) { Copy(f, f_out, bufferNewSize); return; @@ -109,7 +107,7 @@ void lerp_proc(Word16 *f, Word16 *f_out, Word16 bufferNewSize, Word16 bufferOld pos = L_sub(L_shr(shift, 1), 32768l/*1.0f Q15*/); /* Adjust interpolation shift to avoid accessing beyond end of input buffer. */ - if ( L_sub(shift, 19661l/*0.3f Q16*/) < 0) + if ( LT_32(shift, 19661l/*0.3f Q16*/)) { pos = L_sub(pos, 8520l/*0.13f Q16*/); } @@ -158,7 +156,7 @@ void lerp_proc(Word16 *f, Word16 *f_out, Word16 bufferNewSize, Word16 bufferOld /* last point */ - if ( L_sub(pos, L_deposit_h(sub(bufferOldSize,1))) > 0 ) + if ( GT_32(pos, L_deposit_h(sub(bufferOldSize,1)))) { idx = sub(bufferOldSize,2); } diff --git a/lib_com/limit_t0_fx.c b/lib_com/limit_t0_fx.c index 209a288b229280219798eba46c47870156659249..50c39dcf01de416159beb20e86f310d793c8e498 100644 --- a/lib_com/limit_t0_fx.c +++ b/lib_com/limit_t0_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -7,8 +7,6 @@ #include "cnst_fx.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - #include "rom_basop_util.h" @@ -44,7 +42,7 @@ void limit_T0_fx( IF( limit_flag == 0 ) /* restrained Q limits */ { /* set limits */ - IF( sub(L_frame,L_FRAME) == 0) + IF( EQ_16(L_frame,L_FRAME)) { pit_max = PIT_MAX; move16(); @@ -63,7 +61,7 @@ void limit_T0_fx( T1 = T0; move16(); - if( sub(T0_frac,2) >= 0 ) + if( GE_16(T0_frac,2)) { T1 = add(T1,1); } @@ -76,7 +74,7 @@ void limit_T0_fx( *T0_max = add(*T0_min,delta2); move16(); - IF( sub(*T0_max,pit_max) > 0) + IF( GT_16(*T0_max,pit_max)) { *T0_max = pit_max; move16(); @@ -87,13 +85,13 @@ void limit_T0_fx( ELSE /* extended Q limits */ { /* set limits */ - IF( sub(L_frame, L_FRAME) == 0) + IF( EQ_16(L_frame, L_FRAME)) { pit_max = PIT_MAX; move16(); pit_min = PIT_MIN_EXTEND; move16(); - if( sub(limit_flag, 2) == 0 ) + if( EQ_16(limit_flag, 2)) { pit_min = PIT_MIN_DOUBLEEXTEND; move16(); @@ -111,7 +109,7 @@ void limit_T0_fx( move16(); T1 = T0; move16(); - if( sub(T0_frac,2) >= 0 ) + if( GE_16(T0_frac,2)) { T1 = add(T1,1); } @@ -124,7 +122,7 @@ void limit_T0_fx( *T0_max = add(*T0_min, delta2); move16(); - IF( sub(*T0_max,pit_max) > 0) + IF( GT_16(*T0_max,pit_max)) { *T0_max = pit_max; move16(); @@ -142,7 +140,7 @@ void limit_T0_fx( *T0_max = *T0_min + delta2; move16(); - IF( sub(*T0_max, add(pit_max, LIMIT_PIT_REL_UPPER)) > 0 ) + IF( GT_16(*T0_max, add(pit_max, LIMIT_PIT_REL_UPPER))) { *T0_max = add(pit_max, LIMIT_PIT_REL_UPPER); move16(); @@ -183,7 +181,7 @@ void limit_T0_voiced( res2 = res; move16(); - if(sub(res,6) == 0) + if(EQ_16(res,6)) { res2 = shr(res2,1); } @@ -191,7 +189,7 @@ void limit_T0_voiced( /* Mid-point */ T1 = T0; test(); - if( sub(T0_res,1) > 0 && sub(T0_frac,(shr(T0_res,1))) >= 0 ) + if( GT_16(T0_res,1)&&GE_16(T0_frac,(shr(T0_res,1)))) { T1 = add(T1,1); } @@ -200,7 +198,7 @@ void limit_T0_voiced( temp1 = sub(i_mult(T1,res),shl(1,sub(nbits,1))); temp2 = mult(temp1,inv_T0_res[res2]); - if(sub(res,6) == 0) + if(EQ_16(res,6)) { temp2 = shr(temp2,1); } @@ -211,7 +209,7 @@ void limit_T0_voiced( *T0_min_frac = sub(temp1,i_mult(temp2,res)); move16(); - IF ( sub(*T0_min,pit_min) < 0) + IF ( LT_16(*T0_min,pit_min)) { *T0_min = pit_min; move16(); @@ -223,7 +221,7 @@ void limit_T0_voiced( temp1 = add(i_mult(*T0_min,res),add(*T0_min_frac,sub(shl(1,nbits),1))); temp2 = mult(temp1,inv_T0_res[res2]); - if(sub(res,6) == 0) + if(EQ_16(res,6)) { temp2 = shr(temp2,1); } @@ -234,7 +232,7 @@ void limit_T0_voiced( *T0_max_frac = sub(temp1,i_mult(temp2,res)); move16(); - IF ( sub(*T0_max,pit_max) > 0) + IF ( GT_16(*T0_max,pit_max)) { *T0_max = pit_max; move16(); @@ -245,7 +243,7 @@ void limit_T0_voiced( temp1 = add(i_mult(*T0_max,res),sub(*T0_max_frac,sub(shl(1,nbits),1))); temp2 = mult(temp1,inv_T0_res[res2]); - if(sub(res,6) == 0) + if(EQ_16(res,6)) { temp2 = shr(temp2,1); } diff --git a/lib_com/logqnorm_fx.c b/lib_com/logqnorm_fx.c index 9badd48855e9b4de62addb44cabef03fab066477..659de79cb23c95c243db0557ec8e2c69b3d17f37 100644 --- a/lib_com/logqnorm_fx.c +++ b/lib_com/logqnorm_fx.c @@ -1,12 +1,10 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "prot_fx.h" /* Function prototypes */ -#include "stl.h" -#include "wmc_auto.h" - /* required for wmc_tool */ +#include "stl.h" /* required for wmc_tool */ #include "rom_com_fx.h" /* Static table prototypes */ #include "cnst_fx.h" /* Common constants */ @@ -53,7 +51,7 @@ void logqnorm_fx( L_temp = L_mac0(L_temp, coefs16[i], coefs16[i]); } - if( sub(N, 1) > 0 ) + if( GT_16(N, 1)) { Mpy_32_16_ss(L_temp, inv_tbl_fx[N], &L_temp, &lsb); } @@ -69,18 +67,18 @@ void logqnorm_fx( IF( m < 5 && hvq_flag ) { m = shl(m, 1); - IF( L_sub(L_temp1, 1276901417L /* 2^0.25 Q30 */) < 0 ) + IF( LT_32(L_temp1, 1276901417L /* 2^0.25 Q30 */)) { m = add(m, 2); } - ELSE if( L_sub(L_temp1, 1805811301L /* 2^0.75 Q30 */) < 0 ) + ELSE if( LT_32(L_temp1, 1805811301L /* 2^0.75 Q30 */)) { m = add(m, 1); } } ELSE { - if ( L_sub(L_temp1, THREN2POW /* 2^0.5 Q30 */) < 0 ) + if ( LT_32(L_temp1, THREN2POW /* 2^0.5 Q30 */)) { m = add(m, 1); } @@ -112,12 +110,12 @@ void logqnorm_2_fx( FOR( i=n_env_band; i < nb_sfm; i++ ) { temp = env_fl[ sub(i,n_env_band) ]; - IF ( L_sub(thren[0], temp) <= 0 ) + IF ( LE_32(thren[0], temp)) { *ynrm = 0; move16(); } - ELSE IF ( L_sub(thren[sub(L,2)], temp) > 0) + ELSE IF ( GT_32(thren[sub(L,2)], temp)) { *ynrm = sub(L, 1); } @@ -128,10 +126,10 @@ void logqnorm_2_fx( j1 = 0; move16(); j2 = sub(L, 1); - WHILE ( sub(sub(j2,j1),1) > 0 ) + WHILE ( GT_16(sub(j2,j1),1)) { j = shr(add(j1 , j2), 1); - IF ( L_sub(power,thren[j]) >= 0 ) + IF ( GE_32(power,thren[j])) { j2 = j; move16(); diff --git a/lib_com/longarith.c b/lib_com/longarith.c index 2df1b15c221a18b056e25afc246076fee36f5fab..50274fb05674e32c5fafb7214289cd4476c18f84 100644 --- a/lib_com/longarith.c +++ b/lib_com/longarith.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include #include #include "prot_fx.h" #include "stl.h" -#include "wmc_auto.h" - /** diff --git a/lib_com/low_rate_band_att_fx.c b/lib_com/low_rate_band_att_fx.c index 3ed3e5982545d4537d755eb08141ba9bd92be2a8..7a460420c433f053c4642669d65012da4d3dc814 100644 --- a/lib_com/low_rate_band_att_fx.c +++ b/lib_com/low_rate_band_att_fx.c @@ -1,14 +1,12 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include #include "options.h" /* Compilation switches */ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" -#include "stl.h" -#include "wmc_auto.h" - /* required for wmc_tool */ +#include "stl.h" /* required for wmc_tool */ /*--------------------------------------------------------------------------* @@ -77,7 +75,7 @@ void fine_gain_pred_fx( test(); test(); - IF (sub(core, HQ_CORE) == 0 && R != NULL && sub(R[i_sort[band]], 256) <= 0) /* 256 is 32 in Q3 */ + IF (EQ_16(core, HQ_CORE)&&R!=NULL&&LE_16(R[i_sort[band]],256)) /* 256 is 32 in Q3 */ { /*accuracy = ((float)k/(float)bw)*maxpulse[i_sort[band]]; */ L_tmp = L_mult(k, inv_tbl_fx[bw]); /*0+15+1 */ @@ -154,7 +152,7 @@ void get_max_pulses_fx( FOR (i = band_start[k_sort[k]]; i < band_end[k_sort[k]]; i++) { tmp = abs_s(inp_vector[i]); - if (sub(tmp, maxp) > 0) + if (GT_16(tmp, maxp)) { maxp = tmp; move16(); diff --git a/lib_com/lpc_tools_fx.c b/lib_com/lpc_tools_fx.c index 721fae28046487c7707b8134d915858d2e21408b..e4a3c5b1aeca0a93b8b5e0c381be902d76a77bcb 100644 --- a/lib_com/lpc_tools_fx.c +++ b/lib_com/lpc_tools_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -8,8 +8,6 @@ #include "prot_fx.h" /* Function prototypes */ #include "rom_com_fx.h" #include "stl.h" -#include "wmc_auto.h" - #include "basop_mpy.h" #include "basop_util.h" @@ -41,7 +39,7 @@ void autocorr_fx( Word16 fact; Word32 L_sum, L_tmp; - IF(sub(rev_flag,1) == 0) + IF(EQ_16(rev_flag,1)) { /* Windowing of signal */ FOR (i = 0; i < len; i++) @@ -50,7 +48,7 @@ void autocorr_fx( move16(); } } - ELSE IF( sub(sym_flag,1) == 0 ) + ELSE IF( EQ_16(sym_flag,1)) { /* symmetric window of even length */ FOR( i=0; i 0))) + if ((mem!=NULL) && ((GT_16(abs_s(extract_h(t2)), k_max)))) { flag=1; move16();/* Test for unstable filter. If unstable keep old A(z) */ } - if ((mem!=NULL) && ((L_sub(L_abs(t2), 5) < 0))) + if ((mem!=NULL) && ((LT_32(L_abs(t2), 5)))) { flag=1; move16(); /*R matrix not reliable (R saturated for many coeff), keep old A(z) */ @@ -391,7 +389,7 @@ Word16 E_LPC_lev_dur_stab(const Word16 Rh[], const Word16 Rl[], Word16 A[], A[i] = round_fx(L_shl(t0, k)); } - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON IF (mem != NULL) { /* Enforce stable LPC filter - parcorr[0] and parcorr[1] are not LPC coeffiecients */ @@ -499,7 +497,7 @@ static void lsp_reorder( /* If danger of unstable filter in case of resonance in HF */ lpcorder = sub(lpcorder, 1); - IF (sub(lsp[lpcorder], lsp_max) > 0) + IF (GT_16(lsp[lpcorder], lsp_max)) { /* Reverify the minimum LSF gap in the reverse sense */ FOR (i = lpcorder; i>=0; --i) @@ -531,12 +529,12 @@ Word16 E_LPC_lsp_unweight( assert(lpcorder == 16); /* Table selection */ - IF (sub(inv_gamma, GAMMA16k_INV) == 0) + IF (EQ_16(inv_gamma, GAMMA16k_INV)) { unw_coeffs = p16_gamma0_94to1; move16(); } - ELSE IF (sub(inv_gamma, GAMMA1_INV) == 0) + ELSE IF (EQ_16(inv_gamma, GAMMA1_INV)) { unw_coeffs = p16_gamma0_92to1; move16(); @@ -656,7 +654,8 @@ Word32 E_LPC_schur(Word32 r[], Word16 reflCoeff[], Word32 epsP[], const Word16 m tmp_epsP = L_shr(g1[0],s); if (tmp_epsP <= 0 ) { - tmp_epsP = L_add(0,min_epsP); + tmp_epsP = min_epsP; + move32(); } epsP[i+1] = tmp_epsP; move32(); @@ -667,7 +666,8 @@ Word32 E_LPC_schur(Word32 r[], Word16 reflCoeff[], Word32 epsP[], const Word16 m tmp_epsP = L_shr(tmp_epsP,s); if (tmp_epsP <= 0) { - tmp_epsP = L_add(min_epsP, 0); + tmp_epsP = min_epsP; + move32(); } epsP[i+1] = tmp_epsP; move32(); @@ -705,7 +705,7 @@ void spec2isf( move16(); s = spec_r[specix++]; - WHILE (sub(specix , speclen) <0 && sub(lsfix,15) <= 0) + WHILE (LT_16(specix , speclen)&&LE_16(lsfix,15)) { /*check for next zero crossing*/ @@ -739,7 +739,7 @@ void spec2isf( s = negate(s); } - IF (sub(lsfix,16) < 0) + IF (LT_16(lsfix,16)) { FOR(i=0; i<16; i++) { @@ -796,12 +796,12 @@ void E_LPC_a_lsf_isf_conversion(Word16 *lpcCoeffs, Word16 *lsf, const Word16 * s[1] = BASOP_Util_Divide3232_Scale(L_sub(L_tmp1,L_tmp),L_tmp3, &step); move16(); /*s[1] = BASOP_Util_Divide1616_Scale(sub(s[2],s[1]),add(s[2],s[1]), &step); move16();*/ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF s[0] = negate(shr(-32768,step+1)); move16(); s[2] = negate(shr(-32768,step+1)); move16(); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON } ELSE { @@ -927,18 +927,18 @@ void E_LPC_a_lsf_isf_conversion(Word16 *lpcCoeffs, Word16 *lsf, const Word16 * Word16 ReBr = extract_h(L_sub(RealFFT[N/2-i], RealFFT[i])); Word16 ImAr = extract_h(L_sub(ImagFFT[i], ImagFFT[N/2-i])); Word16 ImBr = extract_h(L_add(ImagFFT[i], ImagFFT[N/2-i])); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF tmpw15.v.re = mac_r(L_mult(ptwiddle->v.re, pwn17->v.re), ptwiddle->v.im, pwn17->v.im); tmpw15.v.im = msu_r(L_mult(ptwiddle->v.re, pwn17->v.im), ptwiddle->v.im, pwn17->v.re); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON RealOut[i] = mac_r(L_msu(L_msu(L_mult(ReAr, pwn17->v.re),ImAr, pwn17->v.im), ReBr, pwn15->v.im), ImBr, pwn15->v.re); move16(); ImagOut[i] = mac_r(L_mac(L_mac(L_mult(ReAr, pwn17->v.im), ImAr, pwn17->v.re), ReBr, pwn15->v.re), ImBr, pwn15->v.im); move16(); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF tmpw15.v.re = msu_r(L_mult(ptwiddle->v.im, pwn17i->v.im), ptwiddle->v.re, pwn17i->v.re); tmpw15.v.im = mac_r(L_mult(ptwiddle->v.re, pwn17i->v.im), ptwiddle->v.im, pwn17i->v.re); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON RealOut[N/2-i] = msu_r(L_mac(L_mac(L_mult(ReAr, pwn17i->v.re), ImAr, pwn17i->v.im), ImBr, pwn15i->v.re), ReBr, pwn15i->v.im); move16(); ImagOut[N/2-i] = msu_r(L_msu(L_msu(L_mult(ReAr, pwn17i->v.im), ImAr, pwn17i->v.re), ReBr, pwn15i->v.re), ImBr, pwn15i->v.im); @@ -957,18 +957,18 @@ void E_LPC_a_lsf_isf_conversion(Word16 *lpcCoeffs, Word16 *lsf, const Word16 * Word16 ReBr = extract_h(L_sub(RealFFT[N/2-i], RealFFT[i])); Word16 ImAr = extract_h(L_sub(ImagFFT[i], ImagFFT[N/2-i])); Word16 ImBr = extract_h(L_add(ImagFFT[i], ImagFFT[N/2-i])); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF tmpw15.v.re = mac_r(L_mult(ptwiddle->v.im, pwn17->v.re), ptwiddle->v.re, pwn17->v.im); tmpw15.v.im = msu_r(L_mult(ptwiddle->v.im, pwn17->v.im), ptwiddle->v.re, pwn17->v.re); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON RealOut[i] = mac_r(L_msu(L_msu(L_mult(ReAr, pwn17->v.re),ImAr, pwn17->v.im), ReBr, pwn15->v.im), ImBr, pwn15->v.re); move16(); ImagOut[i] = mac_r(L_mac(L_mac(L_mult(ReAr, pwn17->v.im), ImAr, pwn17->v.re), ReBr, pwn15->v.re), ImBr, pwn15->v.im); move16(); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF tmpw15.v.re = msu_r(L_mult(ptwiddle->v.re, pwn17i->v.im), ptwiddle->v.im, pwn17i->v.re); tmpw15.v.im = mac_r(L_mult(ptwiddle->v.im, pwn17i->v.im), ptwiddle->v.re, pwn17i->v.re); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON RealOut[N/2-i] = msu_r(L_mac(L_mac(L_mult(ReAr, pwn17i->v.re), ImAr, pwn17i->v.im), ImBr, pwn15i->v.re), ReBr, pwn15i->v.im); move16(); ImagOut[N/2-i] = msu_r(L_msu(L_msu(L_mult(ReAr, pwn17i->v.im), ImAr, pwn17i->v.re), ReBr, pwn15i->v.re), ImBr, pwn15i->v.im); @@ -984,10 +984,10 @@ void E_LPC_a_lsf_isf_conversion(Word16 *lpcCoeffs, Word16 *lsf, const Word16 * Word16 ReBr = extract_h(L_sub(RealFFT[N/2-i], RealFFT[i])); Word16 ImAr = extract_h(L_sub(ImagFFT[i], ImagFFT[N/2-i])); Word16 ImBr = extract_h((L_negate(L_add(ImagFFT[i], ImagFFT[N/2-i])))); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF tmpw15.v.re = mac_r(L_mult(ptwiddle->v.im, pwn17->v.re), ptwiddle->v.re, pwn17->v.im); tmpw15.v.im = msu_r(L_mult(ptwiddle->v.im, pwn17->v.im), ptwiddle->v.re, pwn17->v.re); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON RealOut[i] = msu_r(L_msu(L_msu(L_mult(ReAr, pwn17->v.re), ImAr, pwn17->v.im), ReBr, pwn15->v.im), ImBr, pwn15->v.re); move16(); ImagOut[i] = msu_r(L_mac(L_mac(L_mult(ReAr, pwn17->v.im), ImAr, pwn17->v.re), ReBr, pwn15->v.re), ImBr, pwn15->v.im); diff --git a/lib_com/lsf_dec_bfi_fx.c b/lib_com/lsf_dec_bfi_fx.c index a5751d25f00ebbaeb691ed782fa9fb9b7f90400d..f0703db251248fa85cd2bd875c3737111964aad1 100644 --- a/lib_com/lsf_dec_bfi_fx.c +++ b/lib_com/lsf_dec_bfi_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ @@ -7,8 +7,6 @@ #include #include #include "stl.h" -#include "wmc_auto.h" - #include "basop_util.h" #include "rom_com_fx.h" #include "cnst_fx.h" @@ -53,7 +51,7 @@ void lsf_dec_bfi( Word16 beta; Word16 gap; - IF (sub(codec_mode,MODE1) == 0) + IF (EQ_16(codec_mode,MODE1)) { pt_meansForMemUpdate = lsf_mean; /* Update inital guess to something stable, with proper sampling frequency and format (ISF/LSF)*/ @@ -64,11 +62,11 @@ void lsf_dec_bfi( ELSE { /* 12.8kHz ACELP sampling */ - IF( sub(L_frame,L_FRAME) == 0 ) + IF( EQ_16(L_frame,L_FRAME)) { pt_meansForFading = GEWB_Ave_fx; - if (sub(MODE1_bwidth,NB)==0) + if (EQ_16(MODE1_bwidth,NB)) { pt_meansForFading = GENB_Ave_fx; } @@ -89,34 +87,34 @@ void lsf_dec_bfi( pt_meansForFading = lsf_cng; } } - IF( sub(nbLostCmpt, 3) <= 0 ) + IF( LE_16(nbLostCmpt, 3)) { test(); test(); - IF( (sub(last_coder_type, UNVOICED) == 0) ) /* Clear unvoiced last good frame */ + IF( (EQ_16(last_coder_type, UNVOICED))) /* Clear unvoiced last good frame */ { move16(); alpha = _ALPHA_UU_FX; } - ELSE IF( sub(last_coder_type,AUDIO) == 0 || sub(last_good,INACTIVE_CLAS) == 0 ) + ELSE IF( EQ_16(last_coder_type,AUDIO)||EQ_16(last_good,INACTIVE_CLAS)) { alpha = 32604/*0.995f Q15*/; move16(); test(); - if( Last_GSC_pit_band_idx > 0 && sub(nbLostCmpt, 1) > 0 ) + if( Last_GSC_pit_band_idx > 0 && GT_16(nbLostCmpt, 1)) { alpha = 26214/*0.8f Q15*/; move16(); } } - ELSE IF( sub(last_good,UNVOICED_CLAS) == 0 ) + ELSE IF( EQ_16(last_good,UNVOICED_CLAS)) { - IF( sub(nbLostCmpt,1) <= 0 ) + IF( LE_16(nbLostCmpt,1)) { /* If stable, do not flatten the spectrum in the 1st erased frame */ alpha = add(mult(stab_fac, 32768 - _ALPHA_U_FX_X_2), _ALPHA_U_FX_X_2); } - ELSE IF(sub(nbLostCmpt,2) == 0) + ELSE IF(EQ_16(nbLostCmpt,2)) { alpha = sub(_ALPHA_U_FX_X_2,shr(_ALPHA_U_FX,1)); /* 0.6 */ } @@ -126,18 +124,18 @@ void lsf_dec_bfi( move16(); /* go rapidly to CNG spectrum */ } } - ELSE IF( sub(last_good ,UNVOICED_TRANSITION) == 0 ) + ELSE IF( EQ_16(last_good ,UNVOICED_TRANSITION)) { alpha = _ALPHA_UT_FX; move16(); } - ELSE IF( (sub(last_good,VOICED_CLAS) == 0) || (sub(last_good,ONSET) == 0) ) + ELSE IF( (EQ_16(last_good,VOICED_CLAS))||(EQ_16(last_good,ONSET))) { /* clearly voiced - mild convergence to the CNG spectrum for the first 3 erased frames */ move16(); alpha = _ALPHA_V_FX; } - ELSE IF( sub(last_good ,SIN_ONSET) == 0 ) + ELSE IF( EQ_16(last_good ,SIN_ONSET)) { alpha = _ALPHA_S_FX; move16(); @@ -153,7 +151,7 @@ void lsf_dec_bfi( alpha = Inv16(nbLostCmpt, &exp); /*1.f/bfi_cnt;*/ alpha = shl(alpha,exp); } - IF(sub(codec_mode,MODE1) == 0) + IF(EQ_16(codec_mode,MODE1)) { beta = BETA_FEC_FX; move16(); @@ -191,9 +189,9 @@ void lsf_dec_bfi( } ELSE { - IF( sub(L_frame,L_FRAME) == 0 ) + IF( EQ_16(L_frame,L_FRAME)) { - IF(sub(codec_mode, MODE1) == 0) + IF(EQ_16(codec_mode, MODE1)) { reorder_lsf_fx(lsf, MODE1_LSF_GAP_FX, M, INT_FS_FX); /*arg1&2: 14Q1*1.18*/ } @@ -209,15 +207,15 @@ void lsf_dec_bfi( } ELSE IF ( tcxonly != 0 ) { - IF ( sub(L_frame,320) == 0 ) + IF ( EQ_16(L_frame,320)) { gap = 143; } - ELSE IF ( sub(L_frame,512) == 0 ) + ELSE IF ( EQ_16(L_frame,512)) { gap = 90; } - ELSE IF ( sub(L_frame,640) == 0 ) + ELSE IF ( EQ_16(L_frame,640)) { gap = 72; } @@ -269,11 +267,11 @@ Word16 const * PlcGetLsfBase (Word16 const lpcQuantization, is kept as before (without the define PLC_FIX_XSF_HANDLING); the correct value would be isf[m] as returned by lpc_unquantize() during normal decoding */ - IF(L_sub(sr_core,32000)==0) + IF(EQ_32(sr_core,32000)) { return means_swb_cleanspeech_lsf32k0; } - ELSE IF(L_sub(sr_core,25600)==0) + ELSE IF(EQ_32(sr_core,25600)) { return means_swb_cleanspeech_lsf25k6; } @@ -285,7 +283,7 @@ Word16 const * PlcGetLsfBase (Word16 const lpcQuantization, /* lpcQuntization == 1 is left */ - IF (L_sub(sr_core,16000)==0) + IF (EQ_32(sr_core,16000)) { return GEWB2_Ave_fx; } diff --git a/lib_com/lsf_msvq_ma.c b/lib_com/lsf_msvq_ma.c index de1a88ad6c2eab373a87d7798c7ab8099898d4fa..be9815c72652230ba13690d9e5d0f8ea14307ffa 100644 --- a/lib_com/lsf_msvq_ma.c +++ b/lib_com/lsf_msvq_ma.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -8,8 +8,6 @@ #include "rom_com_fx.h" #include "prot_fx.h" #include "stl.h" -#include "wmc_auto.h" - #include "basop_util.h" #include "prot_fx.h" #include "options.h" @@ -39,7 +37,7 @@ void midlsf_dec( move16(); /* Select codebook */ - IF ( sub(coder_type, UNVOICED) == 0 ) + IF ( EQ_16(coder_type, UNVOICED)) { ratio = tbl_mid_unv_wb_5b_fx; } @@ -58,11 +56,11 @@ void midlsf_dec( IF(mid_lsf_int != NULL) /*at the decoder*/ { /* check for incorrect LSF ordering */ - IF ( sub(*mid_lsf_int, 1) == 0 ) + IF ( EQ_16(*mid_lsf_int, 1)) { FOR (j=1; j 0 && sub(j, M) <0 && sub(qlsf[j], add( qlsf[j-1], LSF_GAP_MID_FX))<0 ) + IF ( j > 0 && LT_16(j, M)&<_16(qlsf[j],add(qlsf[j-1],LSF_GAP_MID_FX))) { qlsf[j] = add(qlsf[j-1], LSF_GAP_MID_FX); move16(); @@ -98,7 +96,7 @@ void midlsf_dec( { test(); test(); - IF ( j > 0 && sub(j, M) < 0 && sub(qlsf[j], add( qlsf[j-1],LSF_GAP_MID_FX))<0 ) + IF ( j > 0 && LT_16(j, M)&<_16(qlsf[j],add(qlsf[j-1],LSF_GAP_MID_FX))) { qlsf[j] = add(qlsf[j-1], LSF_GAP_MID_FX); move16(); @@ -125,7 +123,7 @@ void midlsf_dec( { test(); test(); - IF ( j > 0 && sub(j, M) <0 && sub(qlsf[j], add(qlsf[j-1], LSF_GAP_MID_FX))<0 ) + IF ( j > 0 && LT_16(j, M)&<_16(qlsf[j],add(qlsf[j-1],LSF_GAP_MID_FX))) { qlsf[j] = add(qlsf[j-1], LSF_GAP_MID_FX); move16(); diff --git a/lib_com/lsf_tools_fx.c b/lib_com/lsf_tools_fx.c index 8eb9bdce59dd42af0ff0f01dbc19c97965f0e571..516f6e65ad2722e726d3d971ebf35358b58ca4f3 100644 --- a/lib_com/lsf_tools_fx.c +++ b/lib_com/lsf_tools_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -7,8 +7,6 @@ #include #include "options.h" /* Compilation switches */ #include "stl.h" -#include "wmc_auto.h" - #include "basop_util.h" #include "rom_com_fx.h" #include "cnst_fx.h" @@ -83,7 +81,7 @@ static Word16 chebyshev(Word16 x, Word32 *f, Word16 n, Word16 shift) t0 = L_sub(t0, b2); /* t0 = 2*x*b1 - b2 */ /* If the LP order is greater than 10 */ - IF(sub(n, 5) > 0) + IF(GT_16(n, 5)) { b2 = L_add(t0, *f++); /* b0 = 2*x*b1 - b2 + f[i] */ /* i = 5 */ @@ -111,7 +109,10 @@ static Word16 chebyshev(Word16 x, Word32 *f, Word16 n, Word16 shift) /*b1 = L_add(b2,0);*/ } ELSE - b2 = L_add(b1,0); + { + b2 = b1; + move32(); + } t0/*b2*/ = L_add(t0, *f++); /* b0 = 2*x*b1 - b2 + f[i] */ @@ -122,11 +123,11 @@ static Word16 chebyshev(Word16 x, Word32 *f, Word16 n, Word16 shift) t0 = L_add(t0, *f++); /* t0 = x*b1 - b2 + 0.5*f[n] */ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF t0 = L_shl(t0, shift); /* Qx to Q30 with saturation */ cheb = round_fx(t0); /* Result in Q14 */ cheb = s_max(-32767,cheb); /* to avoid saturation */ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON return (cheb); } @@ -287,7 +288,7 @@ void E_LPC_a_isp_conversion(const Word16 a[], Word16 isp[], const Word16 old_isp isp[nf++] = xlow; move16(); - IF (sub(nf,(m-1)) >= 0) + IF (GE_16(nf,(m-1))) { BREAK; } @@ -415,11 +416,11 @@ void E_LPC_f_isp_a_conversion(const Word16 *isp, Word16 *a, const Word16 m) /* a[NC] = 0.5*f1[NC]*(1.0 + isp[m-1]) */ t0 = Madd_32_16(f1[nc], f1[nc], isp[m - 1]); - BASOP_SATURATE_WARNING_OFF;/*overflow handling in loop expression*/ + BASOP_SATURATE_WARNING_OFF /*overflow handling in loop expression*/ t0 = L_shl(t0, q); t0n = L_sub(t0 , 0x7FFFFFFF); /*check for positive overflow*/ t0p = L_sub(t0, 0x80000000); /*check for negative overflow*/ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON q = sub(q,1); /*decrease q in case of overflow*/ } WHILE(t0n == 0 || t0p == 0); /*in case of overflow, recalculate coefficients*/ @@ -513,7 +514,7 @@ Word16 lpc2lsp_fx( move16(); high = add( high, 8 ); - IF( sub( rt, prev_rt ) >= 0 ) + IF( GE_16( rt, prev_rt )) { tfreq[rc] = rt; move16(); @@ -525,7 +526,7 @@ Word16 lpc2lsp_fx( tfreq[rc] = 0x3f80; move16(); /* Set a high enough value as fake root for Q search */ - IF ( sub( rc, order ) < 0 ) + IF ( LT_16( rc, order )) { /* lost P root */ /* copy from previous LSP and return */ @@ -630,7 +631,7 @@ void lsp2lpc_fx( Ltemp = L_add( pq[ i ], pq[ i + 1 ] ); giOverflow = ( Word16 )Overflow; move16(); - IF ( sub(giOverflow,1) == 0 ) + IF ( EQ_16(giOverflow,1)) { BREAK; } @@ -639,7 +640,7 @@ void lsp2lpc_fx( move32(); } - IF ( sub(giOverflow,1) == 0 ) + IF ( EQ_16(giOverflow,1)) { FOR (i=0; i < order; i++ ) { @@ -662,7 +663,7 @@ void lsp2lpc_fx( Ltemp = L_sub( pq[ i+1 ], pq[i] ); giOverflow = ( Word16 ) Overflow; move16(); - IF ( sub(giOverflow,1) == 0 ) + IF ( EQ_16(giOverflow,1)) { BREAK; } @@ -671,7 +672,7 @@ void lsp2lpc_fx( move32(); } - IF ( sub(giOverflow,1) == 0 ) + IF ( EQ_16(giOverflow,1)) { FOR (i = 0; i < order; i++ ) { @@ -704,7 +705,7 @@ void lsp2lpc_fx( a[i] = extract_h( Lacc ); /* a[i] in Q12 */ - IF ( sub(giOverflow,1) == 0 ) + IF ( EQ_16(giOverflow,1)) { BREAK; } @@ -732,7 +733,7 @@ void lsp2lpc_fx( a[ order-1-i ] = extract_h( Lacc ); - IF ( sub(giOverflow,1) == 0 ) + IF ( EQ_16(giOverflow,1)) { BREAK; } @@ -741,7 +742,7 @@ void lsp2lpc_fx( } - IF ( sub(giOverflow,1) == 0 ) + IF ( EQ_16(giOverflow,1)) { FOR ( i = 0; i < order; i++ ) { @@ -977,9 +978,9 @@ void E_LPC_a_lsp_conversion( IF (y != 0) { x = sub(xhigh, xlow); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF tmp = abs_s(y); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON exp = norm_s(tmp); if (exp) tmp = shl(tmp, exp); @@ -999,7 +1000,7 @@ void E_LPC_a_lsp_conversion( lsp[nf++] = xlow; move16(); - IF (sub(nf,m) >= 0) + IF (GE_16(nf,m)) { BREAK; } @@ -1012,7 +1013,7 @@ void E_LPC_a_lsp_conversion( /* Check if m roots found */ /* if not use the LSPs from previous frame */ - IF (sub(nf,m) < 0) + IF (LT_16(nf,m)) { FOR(i=0; i 0) /* If danger of unstable filter in case of resonance in HF */ + IF (GT_16(lsf[n_m_1], lsf_max)) /* If danger of unstable filter in case of resonance in HF */ { FOR (i = n_m_1; i >= 0; i--) /* Reverify the minimum LSF gap in the reverse direction */ { - if (sub(lsf[i], lsf_max) > 0) + if (GT_16(lsf[i], lsf_max)) { lsf[i] = lsf_max; move16(); @@ -1191,7 +1192,7 @@ void space_lsfs_fx ( } ELSE { - IF( sub(i,order) == 0 ) + IF( EQ_16(i,order)) { delta = sub( HALF_POINT_FX, lsfs[i-1] ); move16(); @@ -1202,7 +1203,7 @@ void space_lsfs_fx ( move16(); } } - IF ( sub( delta, SPC_FX ) < 0 ) + IF ( LT_16( delta, SPC_FX )) { flag = 1; move16(); @@ -1286,7 +1287,7 @@ void lsp_weights_fx( norm[i] = n1; move16(); - if (sub(norm[i],n_max) > 0 ) + if (GT_16(norm[i],n_max)) { n_max = norm[i]; move16(); @@ -1302,7 +1303,7 @@ void lsp_weights_fx( norm[i] = n1; move16(); - if ( sub(norm[i], n_max) > 0 ) + if ( GT_16(norm[i], n_max)) { n_max = norm[i]; move16(); @@ -1500,7 +1501,7 @@ void a2rc_fx( const Word16* a, /* i: can be any Q */ move16(); test(); - IF ( sub( km_fx, negate(One_Qx)) <= 0 || sub( km_fx, One_Qx) >= 0 ) + IF ( LE_16( km_fx, negate(One_Qx))||GE_16(km_fx,One_Qx)) { FOR ( j = 0; j < lpcorder; j++ ) { @@ -1513,7 +1514,8 @@ void a2rc_fx( const Word16* a, /* i: can be any Q */ refl[m] = negate( km_fx ); move16(); - L_tmp1 = L_add(0,One_Qx2); /* 1 in 2xq_a+1 */ + L_tmp1 = One_Qx2; /* 1 in 2xq_a+1 */ + move32(); L_tmp1 = L_msu( L_tmp1, km_fx, km_fx ); /* 1-km*km in Q25 */ /* new_mant = invert_dp(L_tmp1,4, &tmp_denom_exp,1); sum in Q61-Q25-n=Q36-n */ @@ -1595,7 +1597,7 @@ Word16 vq_dec_lvq_fx ( * add contribution of each stage *-----------------------------------------------*/ stagesm1 = sub(stages,1); - IF (sub(sf_flag,1) == 0) + IF (EQ_16(sf_flag,1)) { FOR(i=0; i0) + IF (GT_16(nbits0, -1)) { IF (nbits0>0) { @@ -1706,7 +1708,7 @@ void lsf_allocate_fx( /*---------------------------------------------------* * Calculate bit allocation for predictive quantizer *---------------------------------------------------*/ - IF ( sub(framemode_p, -1)>0 ) + IF ( GT_16(framemode_p, -1)) { cumleft = BitsVQ_p_fx[framemode_p]; move16(); @@ -1714,11 +1716,11 @@ void lsf_allocate_fx( nbits0 = CBbits_p_fx[framemode_p]; move16(); - IF (sub(nbits0,-1) > 0) + IF (GT_16(nbits0,-1)) { IF ( nbits0 > 0 ) { - IF ( sub(framemode_p, 7) == 0 ) + IF ( EQ_16(framemode_p, 7)) { /* for UNVOICED_WB only */ n_stages = 3; @@ -1793,11 +1795,11 @@ Word16 find_pred_mode( /* bwidth = 0(NB), 1 (WB), 2(WB2); line index in predmode_tab[][] */ idx = bwidth; move16(); - if (sub(idx, 1) >0) + if (GT_16(idx, 1)) { idx = 1; } - IF (L_sub(int_fs, INT_FS_16k) == 0) + IF (EQ_32(int_fs, INT_FS_16k)) { /* WB2 is actually used if sampling frequency is 16kHz */ idx = 2; @@ -1807,7 +1809,7 @@ Word16 find_pred_mode( { test(); test(); - if ((L_sub(core_brate, GENERIC_MA_LIMIT) >= 0)&&(sub(coder_type, GENERIC) == 0)&&(sub(idx,1) == 0)) + if ((GE_32(core_brate, GENERIC_MA_LIMIT))&&(EQ_16(coder_type,GENERIC))&&(EQ_16(idx,1))) { idx = 3; move16(); @@ -1815,7 +1817,7 @@ Word16 find_pred_mode( } predmode = predmode_tab[idx][coder_type]; move16(); - IF (sub(idx, 2) <= 0) + IF (LE_16(idx, 2)) { *p_mode_lvq = add(i_mult2(NO_CODING_MODES, idx), coder_type); IF (predmode>0) @@ -1832,7 +1834,7 @@ Word16 find_pred_mode( ELSE /* WB 12.8 with MA pred in GENERIC*/ { *p_mode_lvq = add(NO_CODING_MODES, coder_type); - IF (sub(coder_type, GENERIC) == 0) + IF (EQ_16(coder_type, GENERIC)) { *p_mode_lvq_p = 18; move16(); @@ -1880,7 +1882,7 @@ void reorder_isf_fx( FOR (i = 0; i < n - 1; i++) { - if (sub(isf[i], isf_min) < 0) + if (LT_16(isf[i], isf_min)) { isf[i] = isf_min; move16(); @@ -1895,11 +1897,11 @@ void reorder_isf_fx( /*isf_max = sub(shr(fs,1), min_dist);*/ isf_max = sub(fs, min_dist); /* Fs already divide per 2 */ - IF (sub(isf[n-2], isf_max) > 0) /* If danger of unstable filter in case of resonance in HF */ + IF (GT_16(isf[n-2], isf_max)) /* If danger of unstable filter in case of resonance in HF */ { FOR (i = sub(n, 2); i >= 0; i--) /* Reverify the minimum ISF gap in the reverse direction */ { - if (sub(isf[i], isf_max) > 0) + if (GT_16(isf[i], isf_max)) { isf[i] = isf_max; move16(); @@ -2139,7 +2141,7 @@ void lsp2lsf_fx( /* Retrieve Index Guess */ /* Based on lsp[i] */ L_tmp = sub_lsp2lsf_fx(lsp[i]); - IF(L_sub(int_fs, INT_FS_16k_FX) ==0) + IF(EQ_32(int_fs, INT_FS_16k_FX)) { L_tmp = L_shr(L_mult0(extract_l(L_tmp),5),2); } @@ -2182,7 +2184,7 @@ void lsf2lsp_fx( /* 0.75 = (1< 0) + IF (GT_16(nBits, 30)) { FOR (i = 0; i < 8; i++) { @@ -2414,7 +2416,7 @@ Word16 qlsf_ARSN_tcvq_Dec_16k_fx ( { tcvq_Dec_fx(&indice[1], /*y, */y_fx, safety_net); - IF (sub(nBits, 30) > 0) + IF (GT_16(nBits, 30)) { FOR (i = 0; i < 8; i++) { @@ -2703,7 +2705,7 @@ Word16 tcxlpc_get_cdk( move16(); cdk = 0; - if ( sub(acelp_ext_mode, VOICED) == 0 ) + if ( EQ_16(acelp_ext_mode, VOICED)) { cdk = 1; move16(); @@ -3071,7 +3073,8 @@ void lsp_convolve_fx( p2[i + 1] = Lacc; move32(); - Ltemp = L_add(0,p1[i]); + Ltemp = p1[i]; + move32(); } /* end for */ p2[i + 1] = p2[i - 1]; @@ -3195,7 +3198,7 @@ Word16 root_search_fx( Word16 low, vh = v_high; move16(); - WHILE ( sub( sub( high, low ), 2 ) >= 0 ) + WHILE ( GE_16( sub( high, low ), 2 )) { /* high-low>=2 */ f = shr( add( high, low ), 1 ); /* f=( high+low)/2 */ @@ -3214,7 +3217,8 @@ Word16 root_search_fx( Word16 low, /* root between f & low */ high = f; move16(); - vh = L_add(0,Ltemp); + vh = Ltemp; + move32(); } ELSE { @@ -3230,7 +3234,7 @@ Word16 root_search_fx( Word16 low, /* Lacc=divide_dp( *v_low, L_sub( *v_low,vh),2,1); // Lacc in Q31 */ L_tmp = L_sub( *v_low, vh ); - if ( L_sub( *v_low, vh ) < 0 ) + if ( LT_32( *v_low, vh )) { L_tmp = L_negate( L_tmp ); } @@ -3242,7 +3246,7 @@ Word16 root_search_fx( Word16 low, tmp = div_s( 16384, tmp ); /* 15+exp1 */ Ltmp = Mult_32_16( *v_low, tmp ); /* 15+exp1+25-15 */ Ltemp = L_shl( Ltmp, ( 6 - exp1 ) ); /* Q31 */ - if ( L_sub( *v_low, vh ) < 0 ) + if ( LT_32( *v_low, vh )) { Ltemp = L_negate( Ltemp ); } @@ -3374,7 +3378,7 @@ Word32 polynomial_eval_fx( Word16 f, } idx += f; - if ( sub(idx, 512) >= 0 ) idx = sub(idx, 512); /* modulo of 512 */ + if ( GE_16(idx, 512)) idx=sub(idx, 512); /* modulo of 512 */ } coslut = cos_table[idx]; @@ -3406,7 +3410,7 @@ void v_sort( move16(); FOR (j=i; j @@ -10,8 +10,6 @@ #include #include "rom_enc_fx.h" /* prototypes */ #include "stl.h" -#include "wmc_auto.h" - #include "basop_util.h" @@ -80,7 +78,7 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */ *-------------------------------------------------------------------*/ /* check if fin and fout are the same */ - IF (L_sub(fin,fout) == 0) + IF (EQ_32(fin,fout)) { /* just copy the signal_fx and quit */ Copy(sigIn_fx, sigOut_fx, lg); @@ -91,7 +89,7 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */ { /* find the resampling configuration in the lookup table */ cfg_ptr_fx = &resampling_cfg_tbl_fx[0]; - WHILE ( (cfg_ptr_fx->fin_fx != 0) && !(L_sub(cfg_ptr_fx->fin_fx,fin) == 0 && L_sub(cfg_ptr_fx->fout_fx,fout) == 0) ) + WHILE ( (cfg_ptr_fx->fin_fx != 0) && !(EQ_32(cfg_ptr_fx->fin_fx,fin)&&EQ_32(cfg_ptr_fx->fout_fx,fout))) { test(); test(); @@ -102,12 +100,12 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */ /* find config with NB 4kHz low-pass */ test(); test(); - IF ( nblp && (L_sub(fin, 8000) > 0) && (L_sub(fout, 12800) == 0) ) + IF ( nblp && (GT_32(fin, 8000))&&(EQ_32(fout,12800))) { flag_low_order = 1; move16(); cfg_ptr_fx++; - WHILE ( (cfg_ptr_fx->fin_fx != 0) && !( (L_sub(cfg_ptr_fx->fin_fx, fin) == 0) && (L_sub(cfg_ptr_fx->fout_fx, fout) == 0)) ) + WHILE ( (cfg_ptr_fx->fin_fx != 0) && !( (EQ_32(cfg_ptr_fx->fin_fx, fin))&&(EQ_32(cfg_ptr_fx->fout_fx,fout)))) { test(); test(); @@ -123,7 +121,7 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */ fac_den = cfg_ptr_fx->fac_den_fx; move16(); - IF(sub(lg,L_FRAME)>=0) + IF(GE_16(lg,L_FRAME)) { lg_out = cfg_ptr_fx->lg_out ; move16(); @@ -140,7 +138,7 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */ move16(); test(); - IF ( (L_sub(fin, 8000) == 0) && (L_sub(fout, 12800) == 0) ) + IF ( (EQ_32(fin, 8000))&&(EQ_32(fout,12800))) { plus_sample_in = 7; move16(); @@ -187,8 +185,7 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */ mu_preemph_fx = extract_h(t0); /*r_fx[1] / r_fx[0]; */ mem_preemph_fx = signal_ana_fx[mem_len_ana+lg-LEN_WIN_SSS - 1]; move16(); - /*preemph_fx(signal_ana_fx+mem_len_ana+lg-LEN_WIN_SSS, mu_preemph_fx, LEN_WIN_SSS, &mem_preemph_fx);*/ - preemph_copy_fx(signal_ana_fx + mem_len_ana + lg - LEN_WIN_SSS, signal_ana_fx + mem_len_ana + lg - LEN_WIN_SSS, mu_preemph_fx, LEN_WIN_SSS, &mem_preemph_fx); + preemph_fx(signal_ana_fx+mem_len_ana+lg-LEN_WIN_SSS, mu_preemph_fx, LEN_WIN_SSS, &mem_preemph_fx); /* Autocorrelations */ @@ -247,13 +244,13 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */ } /* rescaling */ test(); - IF ((sub(fac_num,fac_den) > 0) == ((cfg_ptr_fx->flags_fx & RS_INV_FAC) != 0)) + IF ((GT_16(fac_num,fac_den))==((cfg_ptr_fx->flags_fx&RS_INV_FAC)!=0)) { - IF(sub(fac_num, fac_den) < 0) + IF(LT_16(fac_num, fac_den)) { num_den = div_s(fac_num,fac_den);/*Q15*/ test(); - IF( L_sub(fin, 16000) > 0 && sub(lg_out, 512) == 0 ) + IF( GT_32(fin, 16000)&&EQ_16(lg_out,512)) { FOR( i=0; i 0 && ( sub(lg_out, L_FRAME) == 0 || sub(lg_out, L_FRAME16k) == 0 || sub(lg_out, 512) == 0) ) + if( GT_32(fin, 16000)&&(EQ_16(lg_out,L_FRAME)||EQ_16(lg_out,L_FRAME16k)||EQ_16(lg_out,512))) { num_den = shl(num_den, 1); } @@ -279,7 +276,7 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */ } ELSE { - IF(sub(fac_num,8)==0) + IF(EQ_16(fac_num,8)) { num_den = 26214; FOR( i=0; iflags_fx & RS_INV_FAC) != 0)) + ELSE IF((LT_16(fac_num,fac_den))&&((cfg_ptr_fx->flags_fx&RS_INV_FAC)!=0)) { FOR( i=0; i= 0) + if(GE_16(i, lim)) { lim3 = sub(ctptr[11], 3); /* last, incomplete period*/ } @@ -530,7 +527,7 @@ Word16 modify_Fs_intcub3m_sup_fx( /* o : length of output */ } kk = add(kk, 1); - if( sub(kk, 4) == 0 ) + if( EQ_16(kk, 4)) { kk = 0; move16(); @@ -546,7 +543,7 @@ Word16 modify_Fs_intcub3m_sup_fx( /* o : length of output */ move16(); } - if( sub(ctptr[10], 1) == 0 ) + if( EQ_16(ctptr[10], 1)) { *sigOutptr++ = sigIn[i]; move16(); @@ -567,7 +564,7 @@ Word16 modify_Fs_intcub3m_sup_fx( /* o : length of output */ move16();/* Q16 -> Q0*/ } - if( sub(ctptr[10], 3) < 0 ) + if( LT_16(ctptr[10], 3)) { *sigOutptr++ = sigIn[add(i, 1)]; move16(); @@ -586,7 +583,7 @@ Word16 modify_Fs_intcub3m_sup_fx( /* o : length of output */ move16();/* Q16 -> Q0*/ } - if( sub(ctptr[10], 1) == 0 ) + if( EQ_16(ctptr[10], 1)) { *sigOutptr = sigIn[add(i, 2)]; move16(); diff --git a/lib_com/mslvq_com_fx.c b/lib_com/mslvq_com_fx.c index 03d5cd4801687e21ff7751cede68ae9263bb4739..0f9c4da25c2202ef69ec538f5b4ead8dd4b4d04f 100644 --- a/lib_com/mslvq_com_fx.c +++ b/lib_com/mslvq_com_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -7,8 +7,6 @@ #include "rom_com_fx.h" #include "cnst_fx.h" #include "stl.h" -#include "wmc_auto.h" - /*-----------------------------------------------------------------* * Local functions @@ -54,7 +52,7 @@ void permute_fx( p1 = perm[2]; move16(); - IF ( add(p1, 1) > 0 ) + IF ( GT_16(p1, -1) ) { p2 = perm[3]; move16(); @@ -87,7 +85,7 @@ void init_lvq_fx( j=0; move16(); test(); - WHILE ((sub(j,MAX_NO_SCALES)<0) && (no_lead_fx[i][j] >0 )) + WHILE ((LT_16(j,MAX_NO_SCALES))&&(no_lead_fx[i][j]>0)) { j++; } @@ -96,7 +94,7 @@ void init_lvq_fx( j = MAX_NO_SCALES; move16(); test(); - WHILE ((sub(j,shl(MAX_NO_SCALES,1))<0) && (no_lead_fx[i][j] >0 )) + WHILE ((LT_16(j,shl(MAX_NO_SCALES,1)))&&(no_lead_fx[i][j]>0)) { j++; } @@ -108,7 +106,7 @@ void init_lvq_fx( { j=0; move16(); - WHILE ((sub(j,MAX_NO_SCALES)<0) && (no_lead_p_fx[i][j] >0 )) + WHILE ((LT_16(j,MAX_NO_SCALES))&&(no_lead_p_fx[i][j]>0)) { j++; } @@ -116,7 +114,7 @@ void init_lvq_fx( move16(); j = MAX_NO_SCALES; move16(); - WHILE ((sub(j, shl(MAX_NO_SCALES,1))<0) && (no_lead_p_fx[i][j] >0 )) + WHILE ((LT_16(j, shl(MAX_NO_SCALES,1)))&&(no_lead_p_fx[i][j]>0)) { j++; } @@ -205,11 +203,11 @@ decode_indexes_fx( no_modes = MAX_NO_SCALES+1; move16(); - IF (sub(no_bits,shl(LEN_INDICE,1)) <= 0) /* the third short is not used */ + IF (LE_16(no_bits,shl(LEN_INDICE,1))) /* the third short is not used */ { index[2] = 0; move16(); - if ( sub(no_bits,LEN_INDICE) <= 0 ) + if ( LE_16(no_bits,LEN_INDICE)) { index[1] =0; move16(); @@ -252,7 +250,7 @@ decode_indexes_fx( } ELSE { - IF( L_sub(index1, p_offset_scale1[mode_glb*no_modes+p_no_scales[mode_glb*2]]) >= 0 ) + IF( GE_32(index1, p_offset_scale1[mode_glb*no_modes+p_no_scales[mode_glb*2]])) { /* safety check in case of bit errors */ set16_fx( x_lvq, 0, 2*LATTICE_DIM ); @@ -264,7 +262,7 @@ decode_indexes_fx( /* find idx_scale */ i = 1; move16(); - WHILE( sub(i, p_no_scales[mode_glb*2]) <= 0 && L_sub(index1, p_offset_scale1[mode_glb*no_modes +i])>= 0 ) + WHILE( LE_16(i, p_no_scales[mode_glb*2])&&GE_32(index1,p_offset_scale1[mode_glb*no_modes+i])) { i = add(i,1); } @@ -276,7 +274,7 @@ decode_indexes_fx( i = 1; move16(); - WHILE( L_sub(index1, table_no_cv_fx[i]) >= 0 ) + WHILE( GE_32(index1, table_no_cv_fx[i])) { i = add(i, 1); } @@ -301,7 +299,7 @@ decode_indexes_fx( /* find the index for the scale/truncation */ i = 1; move16(); - WHILE( L_sub(index2, p_offset_scale2[tmp+i]) >= 0 ) + WHILE( GE_32(index2, p_offset_scale2[tmp+i])) { i = add(i, 1); } @@ -311,7 +309,7 @@ decode_indexes_fx( /* find the index of the leader vector */ i = 1; move16(); - WHILE ( L_sub(index2, table_no_cv_fx[i]) >= 0 ) + WHILE ( GE_32(index2, table_no_cv_fx[i])) { i = add(i, 1); } @@ -342,7 +340,7 @@ Word16 deindex_lvq_fx( Word16 scales[2]; Word16 ber_flag; - IF ( sub(sf_flag,1) == 0 ) + IF ( EQ_16(sf_flag,1)) { mode_glb = add(offset_lvq_modes_SN_fx[mode], offset_in_lvq_mode_SN_fx[mode][sub(no_bits,min_lat_bits_SN_fx[mode])]); p_scales = &scales_fx[0][0]; @@ -361,7 +359,7 @@ Word16 deindex_lvq_fx( p_offset_scale2, x_lvq, mode_glb, scales ); /* x_lvq is here Q1 */ - IF ( sub(sf_flag,1) == 0 ) + IF ( EQ_16(sf_flag,1)) { /* safety-net case*/ IF(scales[0]) @@ -484,7 +482,7 @@ static void idx2c_fx( move16(); k1 = sub(k,1); move16(); - WHILE( sub(add(skip, sub(C_VQ_fx[n-pos-1][k1] ,1)), val) < 0 ) + WHILE( LT_16(add(skip,sub(C_VQ_fx[n-pos-1][k1] ,1)), val)) { skip = add(skip, C_VQ_fx[n-pos-1][k1]); move16(); @@ -496,7 +494,7 @@ static void idx2c_fx( move16(); n = sub(n,add(pos,1)); val = sub(val,skip); - IF ( sub(k, 1) == 0 ) + IF ( EQ_16(k, 1)) { return; } @@ -557,9 +555,9 @@ void decode_sign_pc1_fx( } } - IF ( sub(len, LATTICE_DIM)<0 ) + IF ( LT_16(len, LATTICE_DIM)) { - IF (sub(cnt_neg, parity) != 0) + IF (NE_16(cnt_neg, parity)) { c[len] = negate(c[len]); move16(); @@ -570,38 +568,6 @@ void decode_sign_pc1_fx( } -/*-----------------------------------------------------------------* - * multiply32_32_64_fx() - * - * (function for int64 ) - *-----------------------------------------------------------------*/ - -void multiply32_32_64_fx( - Word32 x, /* i: first factor */ - Word32 y, /* i: second factor */ - Word32 *res /* o: multiplication result as array of 2 Word32*/ -) -{ - Word32 tmp, high; - Word16 x_tmp[2], y_tmp[2]; - - x_tmp[0] = extract_l(L_and(x, 0x7fff)); /*extract_l(x); */ /* lowest 16 bits */ - x_tmp[1] = extract_l(L_and(L_shr(x,15),0x7fff)); /*extract_h(x); */ - y_tmp[0] = extract_l(L_and(y, 0x7fff)); /*extract_l(y); */ - y_tmp[1] = extract_l(L_and(L_shr(y,15),0x7fff)); /*extract_h(y); */ - tmp = L_mult0(x_tmp[0], y_tmp[0]); - high = L_shr(tmp,15); /*extract_h(tmp); */ - res[0] = L_and(tmp, 0x7fff); /* extract_l(tmp); */ - tmp = L_mac0(L_mac0(high, x_tmp[1], y_tmp[0]), x_tmp[0],y_tmp[1]); /* x and y are not using all 32 bits, so this is valid */ - high = L_shr(tmp,15);/*extract_h(tmp); */ - res[0] = L_add(res[0], L_shl(L_and(tmp,0x7fff), 15)); - move32(); - res[1] = L_mac0(high, x_tmp[1], y_tmp[1]); - move32(); - - return; -} - static void decode_leaders_fx( Word16 index, /* i : index to be decoded */ Word16 idx_lead, /* i : leader class index */ @@ -675,7 +641,7 @@ static Word32 divide_32_32_fx(Word32 y, /* i */ Word16 i, ny, nx, nyx; - IF (L_sub(y, x) < 0) + IF (LT_32(y, x)) { result = L_deposit_l(0); *rem = y; @@ -735,7 +701,7 @@ static Word16 divide_16_16_fx(Word16 y, /* i */ Word16 i, ny, nx, nyx; - IF (L_sub(y, x) < 0) + IF (LT_32(y, x)) { result = 0; move16(); diff --git a/lib_com/nelp_fx.c b/lib_com/nelp_fx.c index 258b58f2ea77673f71d450cea64fb3b0bd0de62b..70f48257cb34760aa3f47652a30cebd3c9bfe9d2 100644 --- a/lib_com/nelp_fx.c +++ b/lib_com/nelp_fx.c @@ -1,12 +1,10 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "rom_com_fx.h" #include "prot_fx.h" #include "stl.h" -#include "wmc_auto.h" - /*===================================================================*/ @@ -46,7 +44,7 @@ Word16 dequantize_uvg_fx( Word32 L_tmp; Word16 Q_gain = 0; - IF( sub(bwidth_fx,NB) == 0 ) + IF( EQ_16(bwidth_fx,NB)) { UVG1CB = UVG1CB_NB_FX; move16(); @@ -55,7 +53,7 @@ Word16 dequantize_uvg_fx( UVG2CB2 = UVG2CB2_NB_FX; move16(); } - ELSE IF( sub(bwidth_fx,WB) == 0 || sub(bwidth_fx,SWB) == 0) + ELSE IF( EQ_16(bwidth_fx,WB)||EQ_16(bwidth_fx,SWB)) { test(); UVG1CB = UVG1CB_WB_FX; @@ -74,7 +72,7 @@ Word16 dequantize_uvg_fx( ELSE { test(); - IF ( ( sub(UVG1CB[iG1][0], 4096) < 0 ) && ( sub(UVG1CB[iG1][1],4096) < 0 ) ) /* if x < 1, where 10^x is used for gain computation */ + IF ( ( LT_16(UVG1CB[iG1][0], 4096))&&(LT_16(UVG1CB[iG1][1],4096))) /* if x < 1, where 10^x is used for gain computation */ { sc = 8; move16(); @@ -101,7 +99,7 @@ Word16 dequantize_uvg_fx( frac = extract_l(Pow2(14,frac)); G[i*5+k] = round_fx(L_shl(L_mult(frac,UVG2CB1[iG2[i]][k]),exp-sc)); /* Q0 */ } - ELSE IF (sub(i,1)==0) + ELSE IF (EQ_16(i,1)) { L_tmp = L_mult(UVG1CB[iG1][i],27213); /* Q(13+13+1)->Q27 */ L_tmp = L_shr_r(L_tmp,11); /* Q16 */ @@ -150,7 +148,7 @@ void generate_nelp_excitation_fx( FOR (i=0; i<10; i++) { - IF (sub(i,9)==0) + IF (EQ_16(i,9)) { len=31; move16(); @@ -185,7 +183,7 @@ void generate_nelp_excitation_fx( { FOR (k2=add(k1,1); k20) + IF (GT_16(tmp1[k2],tmp1[k1])) { tmpi = I[k2]; move16(); diff --git a/lib_com/options.h b/lib_com/options.h index f804201ebf3bfb11355d8e8c153de9cdc7aa5542..23528b23f0f395965710c92ba0f762f4d4e65ff4 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -1,11 +1,13 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #ifndef OPTIONS_H #define OPTIONS_H +#include "stl.h" + /* ################### Start compiler switches ######################## */ /* */ #ifdef _MSC_VER @@ -14,17 +16,6 @@ #define SUPPORT_JBM_TRACEFILE /* support for JBM tracefile, which is needed for 3GPP objective/subjective testing, but not relevant for real-world implementations */ -#define WMOPS /* Activate complexity and memory counters */ -#ifdef WMOPS -/*#define WMOPS_PER_FRAME*/ /* Output per-frame complexity (writes one float value per frame to the file "wmops_analysis") */ -/*#define WMOPS_DETAIL*/ /* Output detailed complexity printout for every function. Increases runtime overhead */ -/*#define WMOPS_WC_FRAME_ANALYSIS*/ /* Output detailed complexity analysis for the worst-case frame */ -/*#define MEM_COUNT_DETAILS*/ /* Output detailed memory analysis for the worst-case frame (writes to the file "mem_analysis.csv") */ -#endif - - - - /* */ /* ##################### End compiler switches ######################## */ diff --git a/lib_com/parameter_bitmaping.c b/lib_com/parameter_bitmaping.c index 7064eca5e06a0557177067892848c0e9300d2c20..74f000b9f9cac16aa8344be36aa2c45d1bffe90f 100644 --- a/lib_com/parameter_bitmaping.c +++ b/lib_com/parameter_bitmaping.c @@ -1,11 +1,9 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "stl.h" -#include "wmc_auto.h" - #include #include "prot_fx.h" @@ -85,10 +83,7 @@ void GetParameters(ParamsBitMap const * paramsBitMap, Word16 nArrayLength, void move16(); param = & paramsBitMap->params[iParam]; -#define WMC_TOOL_SKIP pSubStruct = param->GetParamValue(pParameter, index, &value); -#undef WMC_TOOL_SKIP - /* If a function for encoding/decoding value is defined than it should take care of 0 */ IF ( s_or(param->fZeroAllowed != 0, param->EncodeValue != NULL) ) { @@ -112,9 +107,7 @@ void GetParameters(ParamsBitMap const * paramsBitMap, Word16 nArrayLength, void ELSE { move16(); -#define WMC_TOOL_SKIP - *pnBits = add(*pnBits, param->GetNumberOfBits(value, index)); -#undef WMC_TOOL_SKIP + *pnBits = add(*pnBits, param->GetNumberOfBits(value, index)); } IF ( s_and(param->pSubParamBitMap != NULL, value > 0) ) @@ -164,10 +157,7 @@ void SetParameters(ParamsBitMap const * paramsBitMap, Word16 nArrayLength, void } value = add(value, *(*pStream)++); -#define WMC_TOOL_SKIP pSubStruct = param->SetParamValue(pParameter, index, value); -#undef WMC_TOOL_SKIP - move16(); *pnSize = add(*pnSize, 1); @@ -208,9 +198,7 @@ void WriteToBitstream(ParamsBitMap const * paramsBitMap, Word16 nArrayLength, Wo nBits = param->nBits; IF (param->nBits == 0) { -#define WMC_TOOL_SKIP nBits = param->GetNumberOfBits(**pStream, index); -#undef WMC_TOOL_SKIP } test(); diff --git a/lib_com/phase_dispersion.c b/lib_com/phase_dispersion.c index 38a35ab5a214f1a13e329f082b1ef4a744acf7cf..d67f90c3e9cdbab1fe3f0d7aeb911a281cbf4de2 100644 --- a/lib_com/phase_dispersion.c +++ b/lib_com/phase_dispersion.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ @@ -7,9 +7,7 @@ #include "options.h" /* EV-VBR compilation switches */ #include "prot_fx.h" #include "basop_util.h" -#include "stl.h" -#include "wmc_auto.h" - /* Weighted mops computation related code */ +#include "stl.h" /* Weighted mops computation related code */ /*-----------------------------------------------------------------------* * phase_dispersion: @@ -39,12 +37,12 @@ void phase_dispersion( move16(); state = 2; - if ( sub(gain_pit,14746/*0.9f Q14*/) < 0) + if ( LT_16(gain_pit,14746/*0.9f Q14*/)) { move16(); state = 1; } - if ( sub(gain_pit, 9830/*0.6f Q14*/) < 0 ) + if ( LT_16(gain_pit, 9830/*0.6f Q14*/)) { move16(); state = 0; @@ -59,9 +57,9 @@ void phase_dispersion( prev_gain_pit[0] = gain_pit; - IF ( L_sub(gain_code, L_add(*prev_gain_code, L_shl(*prev_gain_code,1))) > 0 ) + IF ( GT_32(gain_code, L_add(*prev_gain_code, L_shl(*prev_gain_code,1)))) { - if (sub(state,2) < 0) + if (LT_16(state,2)) { state = add(state, 1); } @@ -72,19 +70,19 @@ void phase_dispersion( FOR (i=0; i<6; i++) { - if ( L_sub(prev_gain_pit[i], 9830/*0.6f Q14*/) < 0 ) + if ( LT_32(prev_gain_pit[i], 9830/*0.6f Q14*/)) { j = add(j,1); } } - if (sub(j,2) > 0) + if (GT_16(j,2)) { move16(); state = 0; } - if ( sub(sub(state, *prev_state),1) > 0 ) + if ( GT_16(sub(state, *prev_state),1)) { state = sub(state,1); } @@ -102,7 +100,7 @@ void phase_dispersion( state = add(state, mode); /* level of dispersion */ j = *code_exp; move16(); - IF( sub(state,2) < 0 ) + IF( LT_16(state,2)) { FOR(i=0; i= 0) + IF (GE_16(t_quanta_o, sv[nsv])) { *DsIdx = nsv; move16(); return ; } - IF (sub(t_quanta_o, sv[1]) <= 0) + IF (LE_16(t_quanta_o, sv[1])) { *DsIdx = 1; move16(); @@ -157,7 +155,7 @@ void dsDiracPerQuanta_fx( dsIndex = shl(1, frQuanta[0][td]); - if (sub(t_quanta_o, sv[shr(nsv, 1) ]) > 0 ) + if (GT_16(t_quanta_o, sv[shr(nsv, 1) ])) { dsIndex = sub(nsv, dsIndex ); } @@ -229,7 +227,7 @@ void conservativeL1Norm_fx( *Qspare = sub(Qavail, Qtestminus); Mprime = sub(Mprime, 1); } - WHILE ( (Mprime >= 0) && sub(*Qspare, QUANTAQ3OFFSET ) < 0 ); + WHILE ( (Mprime >= 0) && LT_16(*Qspare, QUANTAQ3OFFSET )); if(Mprime < 0) { @@ -267,7 +265,7 @@ void bandBitsAdjustment_fx( rangeCoderFinalizationFBits_fx(Brc, INTrc, &Bff); - IF(sub(D, Nbands) < 0) + IF(LT_16(D, Nbands)) { L_tmp = L_deposit_l(sub(Breserv, Bff)); Btemp = extract_l(intLimCDivSigned_fx(L_tmp, s_min(D, 3))); /* result always fits in Word16 */ @@ -409,7 +407,7 @@ void NearOppSplitAdjustment_fx( /* skew calc code */ qskew = 0 ; move16(); - IF (sub(Nhead, 1) > 0) + IF (GT_16(Nhead, 1)) { qavg = extract_h(L_shl(intLimCDivSigned_fx((Word32)qboth, Np),16)); /* qboth may be negative */ dsDiracPerQuanta_fx(Ntail, qavg, FlagCons, hBitsN, &Midx ); @@ -428,7 +426,7 @@ void NearOppSplitAdjustment_fx( } *qnear = qboth; QIb = extract_h(L_shl(L_QIb, 16)); /* may saturate */ - if (sub(QIb, qboth) <= 0) + if (LE_16(QIb, qboth)) { *qnear = QIb; } @@ -567,7 +565,7 @@ void srt_vec_ind16_fx ( { FOR (npos = (pos + 1); npos < length; npos++) { - IF (sub(srt[npos], srt[pos]) < 0) + IF (LT_16(srt[npos], srt[pos])) { idxMem = I[pos]; move16(); @@ -635,7 +633,7 @@ Word16 atan2_fx( /* o: Angle between 0 and PI/2 radian (Q14) */ /* For 8.0 <= x < 10.0, 1/(5x^5) is not completely negligible. * For more accurate result, add very small correction term. */ - if (L_sub(L_shr(arg, 15), 10L) < 0) + if (LT_32(L_shr(arg, 15), 10L)) { angle = add(angle, 8); /* Add tiny correction term. */ } diff --git a/lib_com/range_com_fx.c b/lib_com/range_com_fx.c index ce338948e6215dda9b973b7ce883c5b0621698a8..2cfaebd661ec9d95d043bc8abffb075a711bd67f 100644 --- a/lib_com/range_com_fx.c +++ b/lib_com/range_com_fx.c @@ -1,14 +1,12 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include #include "options.h" /* Compilation switches */ #include "cnst_fx.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ -#include "stl.h" -#include "wmc_auto.h" - /* required for wmc_tool */ +#include "stl.h" /* required for wmc_tool */ /*-------------------------------------------------------------------* diff --git a/lib_com/re8_ppv_fx.c b/lib_com/re8_ppv_fx.c index 7d4dba38c4531798f63d528e7a5ae51ad454cafc..965ae0a948f2af907989376b9b5d4a8b9823549b 100644 --- a/lib_com/re8_ppv_fx.c +++ b/lib_com/re8_ppv_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "cnst_fx.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*-------------------------------------------------------------------* * Prototypes @@ -66,7 +64,7 @@ void re8_PPV_fx( /*--------------------------------------------------------------* * select best candidate y0 or y1 to minimize distortion *--------------------------------------------------------------*/ - IF( L_sub(e0, e1) < 0 ) + IF( LT_32(e0, e1)) { Copy( y0, y, 8 ); } @@ -134,7 +132,7 @@ static void nearest_neighbor_2D8_fx( s = L_abs(e); /* check if |ei| is maximal, if so, set j=i */ - if( L_sub(em, s) < 0 ) + if( LT_32(em, s)) { j = i; move16(); diff --git a/lib_com/re8_util_fx.c b/lib_com/re8_util_fx.c index d24c415f9188d3dee59301785daddfd5eeaed485..ec902708761535c4951cffcddfb2b4e37e089a62 100644 --- a/lib_com/re8_util_fx.c +++ b/lib_com/re8_util_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -7,8 +7,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*-------------------------------------------------------------------* @@ -70,7 +68,7 @@ void re8_vor_fx( * and replace n by n = n' + 2r where n' = 3 or 4 (c is in Qn') and r is defined above *----------------------------------------------------------------*/ - IF( sub(*n, 4) <= 0 ) + IF( LE_16(*n, 4)) { Copy( y, c, 8 ); } @@ -142,7 +140,7 @@ void re8_vor_fx( n_tmp = Da_nq_fx[ka_tmp]; move16(); - IF( sub(n_tmp, 4) > 0 ) + IF( GT_16(n_tmp, 4)) { /*--------------------------------------------------------* * if c is not in Q2, Q3, or Q4 (i.e. n_tmp>4), use m = 2^(r+1) instead of 2^r @@ -297,7 +295,7 @@ static Word16 re8_identify_absolute_leader_fx( /* o : integer indicating if y i * the maximal value of s for y in Q0, Q2, Q3 or Q4 is NB_SPHERE * if s> NB_SPHERE, y is an outlier (the value of ka is set correctly) *-------------------------------------------------------------------*/ - IF( sub(s, NB_SPHERE) <= 0 ) + IF( LE_16(s, NB_SPHERE)) { /*---------------------------------------------------------------* * compute the unique identifier id of the absolute leader related to y: @@ -330,7 +328,7 @@ static Word16 re8_identify_absolute_leader_fx( /* o : integer indicating if y i move16(); FOR( i=0; iburst_ho_cnt_fx = add(st->burst_ho_cnt_fx,1); st->burst_ho_cnt_fx = s_min(st->burst_ho_cnt_fx, HO_HIST_SIZE); - IF( sub(st->bwidth_fx, NB) != 0) + IF( NE_16(st->bwidth_fx, NB)) { offset = 5; test(); - if( sub(st->bwidth_fx, WB) == 0 && st->CNG_mode_fx >= 0 ) + if( EQ_16(st->bwidth_fx, WB)&&st->CNG_mode_fx>=0) { offset = st->CNG_mode_fx; move16(); @@ -223,7 +199,7 @@ void calc_residu_fx( ELSE { test(); - IF( ( st->Opt_DTX_ON_fx != 0 ) && ( vad_flag_dtx != 0 ) ) + IF( (st->Opt_DTX_ON_fx != 0) && (vad_flag_dtx != 0) ) { st->burst_ho_cnt_fx = 0; move16(); diff --git a/lib_com/rom_basop_util.c b/lib_com/rom_basop_util.c index 4e4dad8bd266ba3c23dfd328b3191f659a878346..94c60165a1db0bc20824646f3c01fd48fedc951c 100644 --- a/lib_com/rom_basop_util.c +++ b/lib_com/rom_basop_util.c @@ -1,11 +1,9 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "rom_basop_util.h" #include "stl.h" -#include "wmc_auto.h" - #include #include #include "options.h" diff --git a/lib_com/rom_basop_util.h b/lib_com/rom_basop_util.h index e6386327b117cc9368787b5175ddbfc00271b05f..d576754b2396dffda37b542360a770d3e5c3e89d 100644 --- a/lib_com/rom_basop_util.h +++ b/lib_com/rom_basop_util.h @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #ifndef __BASOP_UTIL_ROM_H__ diff --git a/lib_com/rom_com_fx.c b/lib_com/rom_com_fx.c index 7f2f25c1c0e595e7ba72868550f79766947714fa..ec12d194e83e5a9bf5e531e42bc4f274fca6ea68 100644 --- a/lib_com/rom_com_fx.c +++ b/lib_com/rom_com_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -7,9 +7,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "cnst_fx.h" /* Decoder static structure */ #include "stl.h" -#include "wmc_auto.h" - - #include "basop_util.h" @@ -5812,100 +5809,8 @@ const Word16 sincos_t_ext_fx[641] = -23028 }; -const Word16 FFT_reorder_64[]= -{ - 0, 32, 16, 48, - 8, 40, 24, 56, - 4, 36, 20, 52, - 12, 44, 28, 60, - 2, 34, 18, 50, - 10, 42, 26, 58, - 6, 38, 22, 54, - 14, 46, 30, 62 -}; - -const Word16 FFT_reorder_256[]= -{ - 0, 128, 64, 192, - 32, 160, 96, 224, - 16, 144, 80, 208, - 48, 176, 112, 240, - 8, 136, 72, 200, - 40, 168, 104, 232, - 24, 152, 88, 216, - 56, 184, 120, 248, - 4, 132, 68, 196, - 36, 164, 100, 228, - 20, 148, 84, 212, - 52, 180, 116, 244, - 12, 140, 76, 204, - 44, 172, 108, 236, - 28, 156, 92, 220, - 60, 188, 124, 252, - 2, 130, 66, 194, - 34, 162, 98, 226, - 18, 146, 82, 210, - 50, 178, 114, 242, - 10, 138, 74, 202, - 42, 170, 106, 234, - 26, 154, 90, 218, - 58, 186, 122, 250, - 6, 134, 70, 198, - 38, 166, 102, 230, - 22, 150, 86, 214, - 54, 182, 118, 246, - 14, 142, 78, 206, - 46, 174, 110, 238, - 30, 158, 94, 222, - 62, 190, 126, 254 -}; - -const Word16 FFT_REORDER_128[64] = -{ - 0, 64, 32, 96, 16, 80, 48, 112, - 8, 72, 40, 104, 24, 88, 56, 120, - 4, 68, 36, 100, 20, 84, 52, 116, - 12, 76, 44, 108, 28, 92, 60, 124, - 2, 66, 34, 98, 18, 82, 50, 114, - 10, 74, 42, 106, 26, 90, 58, 122, - 6, 70, 38, 102, 22, 86, 54, 118, - 14, 78, 46, 110, 30, 94, 62, 126 -}; -const Word16 FFT_REORDER_512[256] = -{ - 0, 256, 128, 384, 64, 320, 192, 448, - 32, 288, 160, 416, 96, 352, 224, 480, - 16, 272, 144, 400, 80, 336, 208, 464, - 48, 304, 176, 432, 112, 368, 240, 496, - 8, 264, 136, 392, 72, 328, 200, 456, - 40, 296, 168, 424, 104, 360, 232, 488, - 24, 280, 152, 408, 88, 344, 216, 472, - 56, 312, 184, 440, 120, 376, 248, 504, - 4, 260, 132, 388, 68, 324, 196, 452, - 36, 292, 164, 420, 100, 356, 228, 484, - 20, 276, 148, 404, 84, 340, 212, 468, - 52, 308, 180, 436, 116, 372, 244, 500, - 12, 268, 140, 396, 76, 332, 204, 460, - 44, 300, 172, 428, 108, 364, 236, 492, - 28, 284, 156, 412, 92, 348, 220, 476, - 60, 316, 188, 444, 124, 380, 252, 508, - 2, 258, 130, 386, 66, 322, 194, 450, - 34, 290, 162, 418, 98, 354, 226, 482, - 18, 274, 146, 402, 82, 338, 210, 466, - 50, 306, 178, 434, 114, 370, 242, 498, - 10, 266, 138, 394, 74, 330, 202, 458, - 42, 298, 170, 426, 106, 362, 234, 490, - 26, 282, 154, 410, 90, 346, 218, 474, - 58, 314, 186, 442, 122, 378, 250, 506, - 6, 262, 134, 390, 70, 326, 198, 454, - 38, 294, 166, 422, 102, 358, 230, 486, - 22, 278, 150, 406, 86, 342, 214, 470, - 54, 310, 182, 438, 118, 374, 246, 502, - 14, 270, 142, 398, 78, 334, 206, 462, - 46, 302, 174, 430, 110, 366, 238, 494, - 30, 286, 158, 414, 94, 350, 222, 478, - 62, 318, 190, 446, 126, 382, 254, 510 -}; + + const Word16 FFT_REORDER_1024[512] = { @@ -6099,13 +6004,6 @@ const Word16 Odx_fft64_16fx[64] = 0,59,54,49,44,39,34,29,24,19,14,9,4,63,58,53,48,43,38,33,28,23,18,13,8,3,62,57,52,47,42,37, 32,27,22,17,12,7,2,61,56,51,46,41,36,31,26,21,16,11,6,1,60,55,50,45,40,35,30,25,20,15,10,5 }; -const Word32 w_fft64_16fx[32] = -{ - 1073741824, 0, 759250112, 759250112, 992008064, 410903232, 410903232, 992008064, - 1053110144, 209476640, 596539008, 892783680, 892783680, 596539008, 209476640, 1053110144, - 1068571456, 105245104, 681174592, 830013632, 946955712, 506158400, 311690816, 1027506880, - 1027506880, 311690816, 506158400, 946955712, 830013632, 681174592, 105245104, 1068571456, -}; const Word32 w_fft32_16fx[16] = { 1073741824, 0, 759250113, 759250113, 992008059, 410903236, 410903236, 992008059, @@ -6680,42 +6578,16 @@ const Word16 edct_table_400_fx[] = }; const Word16 Ip_fft16_fx[6] = {8,1,0,16,8,24}; -const Word16 w_fft16_fx[8] = {16384, 0, 11585, 11585, 15137, 6270, 6270, 15137}; /*Q14 */ const Word16 Ip_fft8_fx[6] = {4,1,0,8,4,12}; const Word16 w_fft8_fx[4] = {16384, 0, 11585, 11585}; /*Q14 */ const Word16 Ip_fft32_fx[6] = {16,1,0,32,16,48}; -const Word16 w_fft32_fx[16] = /*Q14 */ -{ - 16384, 0, 11585, 11585, 15137, 6270, 6270, 15137, - 16069, 3196, 9102, 13623, 13623, 9102, 3196, 16069 -}; - const Word16 Ip_fft64_fx[6] = {32,1,0,64,32,96}; -const Word16 w_fft64_fx[32] = /*Q14 */ -{ - 16384, 0, 11585, 11585, 15137, 6270, 6270, 15137, - 16069, 3196, 9102, 13623, 13623, 9102, 3196, 16069, - 16305, 1606, 10394, 12665, 14449, 7723, 4756, 15679, - 15679, 4756, 7723, 14449, 12665, 10394, 1606, 16305 -}; - const Word16 Ip_fft4_fx[6] = {2,1,0,4,2,6}; const Word16 w_fft4_fx[2] = {16384, 0}; /*Q14 */ const Word16 Ip_fft128_fx[10] = {64,1,0,128,64,192,32,160,96,224}; -const Word16 w_fft128_fx[64] = /*Q14 */ -{ - 16384, 0, 11585, 11585, 15137, 6270, 6270, 15137, - 16069, 3196, 9102, 13623, 13623, 9102, 3196, 16069, - 16305, 1606, 10394, 12665, 14449, 7723, 4756, 15679, - 15679, 4756, 7723, 14449, 12665, 10394, 1606, 16305, - 16364, 804, 11003, 12140, 14811, 7005, 5520, 15426, - 15893, 3981, 8423, 14053, 13160, 9760, 2404, 16207, - 16207, 2404, 9760, 13160, 14053, 8423, 3981, 15893, - 15426, 5520, 7005, 14811, 12140, 11003, 804, 16364 -}; /* For the general fix point fft implementation */ const Word16 sincos_t_fx[161] = @@ -10255,25 +10127,6 @@ const Word16 swb_hr_env_code3_fx[NUM_ENVLOPE_CODE_HR_TR*N_BANDS_TRANS_BWE_HR] = const Word16 Ip_fft256_fx[10] = {128, 1, 0, 256, 128, 384, 64, 320,192, 448}; -const Word16 w_fft256_fx[128] = -{ - 16384, 0, 11585, 11585, 15137, 6270, 6270, 15137, - 16069, 3196, 9102, 13623, 13623, 9102, 3196, 16069, - 16305, 1606, 10394, 12665, 14449, 7723, 4756, 15679, - 15679, 4756, 7723, 14449, 12665, 10394, 1606, 16305, - 16364, 804, 11003, 12140, 14811, 7005, 5520, 15426, - 15893, 3981, 8423, 14053, 13160, 9760, 2404, 16207, - 16207, 2404, 9760, 13160, 14053, 8423, 3981, 15893, - 15426, 5520, 7005, 14811, 12140, 11003, 804, 16364, - 16379, 402, 11297, 11866, 14978, 6639, 5897, 15286, - 15986, 3590, 8765, 13842, 13395, 9434, 2801, 16143, - 16261, 2006, 10080, 12916, 14256, 8076, 4370, 15791, - 15557, 5139, 7366, 14635, 12406, 10702, 1205, 16340, - 16340, 1205, 10702, 12406, 14635, 7366, 5139, 15557, - 15791, 4370, 8076, 14256, 12916, 10080, 2006, 16261, - 16143, 2801, 9434, 13395, 13842, 8765, 3590, 15986, - 15286, 5897, 6639, 14978, 11866, 11297, 402, 16379 -}; const Word16 Ip_fft512_fx[18] = {256, 1, 0, 512, 256, 768, 128, 640,384, 896, 64, 576, 320, 832, 192, 704,448, 960}; const Word16 w_fft512_fx[256] = @@ -14164,122 +14017,6 @@ const Word16 dqnt_LSB_fx[STATES_LSB][4] = { {0,8,1,8}, {0,8,1,8}, {8,0,8,1}, {8, const Word16 dstep_LSB_fx[4][2] = { {0,2}, {0,2}, {1,3}, {1,3} }; const Word16 ddec_LSB_fx[4][2] = { {0,3}, {3,0}, {2,1}, {1,2} }; -const Word16 window_48kHz_fx16[1110] = /* Q15 */ -{ - - 0, 1, 2, 3, 5, 8, 10, 13, 17, 21, - 25, 30, 35, 40, 46, 52, 58, 65, 72, 80, - 88, 96, 105, 114, 124, 133, 144, 154, 165, 176, - 188, 200, 212, 225, 238, 251, 265, 279, 293, 308, - 323, 339, 354, 371, 387, 404, 421, 439, 457, 475, - 493, 512, 532, 551, 571, 591, 612, 633, 654, 676, - 698, 720, 743, 766, 789, 813, 837, 861, 885, 910, - 936, 961, 987, 1013, 1040, 1067, 1094, 1122, 1149, 1178, - 1206, 1235, 1264, 1293, 1323, 1353, 1384, 1414, 1445, 1477, - 1508, 1540, 1573, 1605, 1638, 1671, 1705, 1739, 1773, 1807, - 1842, 1877, 1912, 1948, 1984, 2020, 2057, 2093, 2130, 2168, - 2206, 2244, 2282, 2320, 2359, 2399, 2438, 2478, 2518, 2558, - 2599, 2640, 2681, 2722, 2764, 2806, 2848, 2891, 2934, 2977, - 3020, 3064, 3108, 3152, 3196, 3241, 3286, 3332, 3377, 3423, - 3469, 3515, 3562, 3609, 3656, 3704, 3751, 3799, 3847, 3896, - 3945, 3994, 4043, 4092, 4142, 4192, 4242, 4293, 4343, 4394, - 4445, 4497, 4549, 4600, 4653, 4705, 4758, 4811, 4864, 4917, - 4971, 5024, 5078, 5133, 5187, 5242, 5297, 5352, 5407, 5463, - 5519, 5575, 5631, 5688, 5744, 5801, 5859, 5916, 5974, 6031, - 6089, 6147, 6206, 6265, 6323, 6382, 6442, 6501, 6561, 6620, - 6680, 6741, 6801, 6862, 6922, 6983, 7045, 7106, 7168, 7229, - 7291, 7353, 7416, 7478, 7541, 7604, 7667, 7730, 7793, 7857, - 7920, 7984, 8048, 8112, 8177, 8241, 8306, 8371, 8436, 8501, - 8566, 8632, 8697, 8763, 8829, 8895, 8961, 9028, 9094, 9161, - 9228, 9295, 9362, 9429, 9497, 9564, 9632, 9700, 9768, 9836, - 9904, 9972, 10041, 10109, 10178, 10247, 10316, 10385, 10454, 10523, - 10593, 10662, 10732, 10802, 10871, 10941, 11012, 11082, 11152, 11222, - 11283, 11344, 11406, 11467, 11529, 11591, 11653, 11716, 11778, 11840, - 11903, 11966, 12028, 12091, 12154, 12217, 12280, 12343, 12406, 12469, - 12532, 12595, 12658, 12722, 12785, 12849, 12912, 12976, 13039, 13103, - 13166, 13230, 13294, 13358, 13421, 13485, 13549, 13613, 13677, 13741, - 13805, 13869, 13933, 13997, 14061, 14125, 14189, 14253, 14318, 14382, - 14446, 14510, 14574, 14639, 14703, 14767, 14832, 14896, 14960, 15025, - 15089, 15153, 15218, 15282, 15346, 15411, 15475, 15540, 15604, 15668, - 15733, 15797, 15862, 15926, 15990, 16055, 16119, 16183, 16248, 16312, - 16376, 16441, 16505, 16569, 16634, 16698, 16762, 16826, 16891, 16955, - 17019, 17083, 17147, 17211, 17275, 17340, 17404, 17468, 17532, 17596, - 17659, 17723, 17787, 17851, 17915, 17979, 18042, 18106, 18170, 18233, - 18297, 18361, 18424, 18488, 18551, 18614, 18678, 18741, 18804, 18868, - 18931, 18994, 19057, 19120, 19183, 19246, 19309, 19372, 19434, 19497, - 19560, 19622, 19685, 19748, 19810, 19872, 19935, 19997, 20059, 20121, - 20183, 20245, 20307, 20369, 20431, 20493, 20554, 20616, 20677, 20739, - 20800, 20862, 20923, 20984, 21045, 21106, 21167, 21228, 21289, 21349, - 21410, 21471, 21531, 21591, 21652, 21712, 21772, 21832, 21892, 21952, - 22012, 22071, 22131, 22190, 22250, 22309, 22368, 22427, 22486, 22545, - 22604, 22663, 22722, 22780, 22839, 22897, 22955, 23013, 23071, 23129, - 23187, 23245, 23303, 23360, 23418, 23475, 23532, 23589, 23646, 23703, - 23760, 23817, 23873, 23930, 23986, 24042, 24098, 24154, 24210, 24266, - 24321, 24377, 24432, 24488, 24543, 24598, 24653, 24707, 24762, 24817, - 24871, 24925, 24979, 25034, 25087, 25141, 25195, 25248, 25302, 25355, - 25408, 25461, 25514, 25567, 25620, 25672, 25724, 25777, 25829, 25881, - 25932, 25984, 26036, 26087, 26138, 26189, 26240, 26291, 26342, 26393, - 26443, 26493, 26543, 26593, 26643, 26693, 26743, 26792, 26841, 26890, - 26939, 26988, 27037, 27086, 27134, 27182, 27230, 27278, 27326, 27374, - 27421, 27469, 27516, 27563, 27610, 27657, 27703, 27750, 27796, 27842, - 27888, 27934, 27980, 28025, 28071, 28116, 28161, 28206, 28250, 28295, - 28340, 28384, 28428, 28472, 28516, 28559, 28603, 28646, 28689, 28732, - 28775, 28818, 28860, 28903, 28945, 28987, 29029, 29071, 29112, 29154, - 29195, 29236, 29277, 29318, 29358, 29399, 29439, 29479, 29519, 29559, - 29598, 29638, 29677, 29716, 29755, 29794, 29832, 29871, 29909, 29947, - 29985, 30023, 30061, 30098, 30135, 30172, 30209, 30246, 30283, 30319, - 30356, 30392, 30428, 30464, 30499, 30535, 30570, 30605, 30640, 30675, - 30710, 30744, 30779, 30813, 30847, 30881, 30914, 30948, 30981, 31014, - 31047, 31080, 31113, 31145, 31178, 31210, 31242, 31274, 31306, 31337, - 31369, 31400, 31431, 31462, 31493, 31523, 31554, 31584, 31614, 31644, - 31674, 31704, 31733, 31763, 31792, 31821, 31850, 31879, 31907, 31936, - 31964, 31992, 32020, 32048, 32076, 32104, 32131, 32159, 32186, 32213, - 32240, 32267, 32294, 32320, 32347, 32373, 32399, 32426, 32452, 32478, - 32504, 32530, 32556, 32582, 32607, 32633, 32659, 32685, 32712, 32739, - 32739, 32712, 32685, 32659, 32633, 32606, 32580, 32553, 32527, 32500, - 32473, 32446, 32418, 32391, 32363, 32335, 32307, 32279, 32251, 32222, - 32193, 32164, 32134, 32105, 32075, 32045, 32015, 31984, 31953, 31922, - 31891, 31859, 31828, 31796, 31764, 31731, 31698, 31665, 31632, 31599, - 31565, 31531, 31497, 31462, 31428, 31393, 31357, 31322, 31286, 31250, - 31214, 31177, 31141, 31104, 31066, 31029, 30991, 30953, 30915, 30876, - 30837, 30798, 30759, 30719, 30679, 30639, 30599, 30558, 30517, 30476, - 30435, 30393, 30351, 30309, 30266, 30224, 30181, 30138, 30094, 30050, - 30006, 29962, 29917, 29873, 29827, 29782, 29737, 29691, 29645, 29598, - 29551, 29505, 29457, 29410, 29362, 29314, 29266, 29218, 29169, 29120, - 29070, 29021, 28971, 28921, 28871, 28820, 28769, 28718, 28667, 28615, - 28563, 28511, 28459, 28406, 28353, 28300, 28246, 28192, 28138, 28084, - 28030, 27975, 27920, 27864, 27809, 27753, 27697, 27640, 27584, 27527, - 27470, 27412, 27355, 27297, 27238, 27180, 27121, 27062, 27003, 26944, - 26884, 26824, 26763, 26703, 26642, 26581, 26520, 26458, 26396, 26334, - 26272, 26209, 26146, 26083, 26020, 25956, 25892, 25828, 25763, 25699, - 25634, 25568, 25503, 25437, 25371, 25305, 25239, 25172, 25105, 25037, - 24970, 24902, 24834, 24766, 24697, 24628, 24559, 24490, 24420, 24351, - 24281, 24210, 24140, 24069, 23998, 23926, 23855, 23783, 23711, 23638, - 23566, 23493, 23420, 23346, 23273, 23199, 23125, 23050, 22976, 22901, - 22826, 22750, 22675, 22599, 22523, 22446, 22370, 22293, 22215, 22138, - 22060, 21983, 21904, 21826, 21747, 21669, 21589, 21510, 21430, 21351, - 21271, 21190, 21110, 21029, 20948, 20866, 20785, 20703, 20621, 20538, - 20456, 20373, 20290, 20207, 20123, 20039, 19955, 19871, 19787, 19702, - 19617, 19532, 19446, 19360, 19274, 19188, 19102, 19015, 18928, 18841, - 18754, 18666, 18578, 18490, 18402, 18313, 18224, 18135, 18046, 17956, - 17866, 17776, 17686, 17595, 17505, 17414, 17322, 17231, 17139, 17047, - 16955, 16863, 16770, 16677, 16584, 16490, 16397, 16303, 16209, 16114, - 16020, 15925, 15830, 15735, 15639, 15543, 15447, 15351, 15254, 15158, - 15061, 14964, 14866, 14768, 14671, 14572, 14474, 14375, 14276, 14177, - 14078, 13978, 13878, 13778, 13678, 13578, 13477, 13376, 13274, 13173, - 13071, 12969, 12867, 12764, 12662, 12559, 12455, 12352, 12248, 12144, - 12040, 11936, 11831, 11726, 11621, 11515, 11410, 11304, 11197, 11091, - 10984, 10877, 10770, 10663, 10555, 10447, 10339, 10230, 10122, 10013, - 9904, 9794, 9684, 9574, 9464, 9353, 9243, 9131, 9020, 8909, - 8797, 8684, 8572, 8459, 8346, 8233, 8119, 8006, 7892, 7777, - 7662, 7547, 7432, 7317, 7201, 7085, 6968, 6851, 6734, 6617, - 6499, 6381, 6263, 6144, 6025, 5906, 5786, 5666, 5546, 5425, - 5304, 5183, 5061, 4939, 4817, 4694, 4570, 4447, 4323, 4198, - 4074, 3948, 3823, 3696, 3570, 3443, 3315, 3187, 3058, 2929, - 2800, 2669, 2539, 2407, 2275, 2142, 2009, 1875, 1740, 1604, - 1467, 1330, 1191, 1051, 909, 766, 621, 474, 324, 169, -}; - const Word16 SmoothingWin_NB875_fx[70] = /*Q15*/ { @@ -14690,7 +14427,7 @@ const Word16 lim_neg_inv_tbl_fx[MAX_SPLITS + 1] = -const Word16 Idx2Freq_Tbl[6] = { 6554/*12.8*512*/, 48*512, 13108/*25.6*512*/, 32*512, 16*512, 8*512 }; /* in Q9 */ +const Word16 Idx2Freq_Tbl[] = { 6554/*12.8*512*/, 48*512, 13108/*25.6*512*/, 32*512, 16*512, 8*512 }; /* in Q9 */ /*-------------------------------------------------------------------* * inverse (reciprocal) of integer, used in FEC_fx.c, pitch_extr and in pitchDoubling_det @@ -20019,90 +19756,47 @@ const Word16 cf_se01_tab[9][IGF_SYMBOLS_IN_TABLE + 1] = {16384, 16368, 16355, 16334, 16291, 16212, 16071, 15816, 15359, 14523, 13014, 10534, 7345, 4272, 2228, 1149, 626, 357, 215, 139, 93, 67, 53, 43, 36, 28, 22, 0} /* 48.0 kbs B*/ }; - -const Word16 cf_se02_tab[9][IGF_CTX_COUNT][IGF_SYMBOLS_IN_TABLE + 1] = -{ - { /* 9.6 kbs B */ - { 16384, 16369, 16348, 16316, 16256, 16172, 16017, 15735, 15246, 14363, 13036, 11139, 8916, 6724, 4757, 3282, 2221, 1549, 1105, 771, 548, 364, 238, 151, 89, 50, 30, 0}, - { 16384, 16371, 16358, 16339, 16290, 16241, 16153, 16040, 15813, 15397, 14601, 13301, 11360, 8916, 6254, 3911, 2220, 1280, 755, 461, 278, 177, 111, 70, 35, 20, 12, 0}, - { 16384, 16375, 16359, 16333, 16286, 16243, 16154, 16024, 15771, 15380, 14712, 13537, 11742, 9425, 6872, 4378, 2327, 1197, 671, 412, 259, 145, 93, 52, 26, 13, 5, 0}, - { 16384, 16372, 16358, 16326, 16289, 16241, 16147, 16014, 15765, 15321, 14670, 13546, 11912, 9787, 7323, 4824, 2536, 1330, 731, 438, 258, 148, 86, 37, 22, 11, 2, 0}, - { 16384, 16376, 16364, 16344, 16315, 16272, 16219, 16119, 15910, 15620, 15100, 14254, 13063, 11489, 9413, 7100, 4738, 2751, 1584, 973, 597, 349, 201, 96, 47, 22, 9, 0}, - { 16384, 16364, 16340, 16312, 16288, 16237, 16166, 16026, 15756, 15390, 14833, 13870, 12627, 10998, 8985, 6893, 4720, 3048, 1860, 1131, 725, 449, 215, 111, 56, 34, 14, 0}, - { 16384, 16326, 16297, 16246, 16183, 16064, 15884, 15632, 15240, 14763, 14107, 13230, 12185, 10886, 9390, 7781, 6194, 4696, 3350, 2259, 1506, 975, 604, 356, 201, 106, 48, 0} - }, - { /* 13.2 kbs WB RF B*/ - { 16384, 16369, 16348, 16316, 16256, 16172, 16017, 15735, 15246, 14363, 13036, 11139, 8916, 6724, 4757, 3282, 2221, 1549, 1105, 771, 548, 364, 238, 151, 89, 50, 30, 0}, - { 16384, 16371, 16358, 16339, 16290, 16241, 16153, 16040, 15813, 15397, 14601, 13301, 11360, 8916, 6254, 3911, 2220, 1280, 755, 461, 278, 177, 111, 70, 35, 20, 12, 0}, - { 16384, 16375, 16359, 16333, 16286, 16243, 16154, 16024, 15771, 15380, 14712, 13537, 11742, 9425, 6872, 4378, 2327, 1197, 671, 412, 259, 145, 93, 52, 26, 13, 5, 0}, - { 16384, 16372, 16358, 16326, 16289, 16241, 16147, 16014, 15765, 15321, 14670, 13546, 11912, 9787, 7323, 4824, 2536, 1330, 731, 438, 258, 148, 86, 37, 22, 11, 2, 0}, - { 16384, 16376, 16364, 16344, 16315, 16272, 16219, 16119, 15910, 15620, 15100, 14254, 13063, 11489, 9413, 7100, 4738, 2751, 1584, 973, 597, 349, 201, 96, 47, 22, 9, 0}, - { 16384, 16364, 16340, 16312, 16288, 16237, 16166, 16026, 15756, 15390, 14833, 13870, 12627, 10998, 8985, 6893, 4720, 3048, 1860, 1131, 725, 449, 215, 111, 56, 34, 14, 0}, - { 16384, 16326, 16297, 16246, 16183, 16064, 15884, 15632, 15240, 14763, 14107, 13230, 12185, 10886, 9390, 7781, 6194, 4696, 3350, 2259, 1506, 975, 604, 356, 201, 106, 48, 0} - }, - { /* 9.6 kbs SWB B*/ - { 16384, 16359, 16349, 16331, 16300, 16236, 16112, 15894, 15480, 14691, 13257, 10996, 8168, 5357, 3193, 1864, 1098, 676, 426, 265, 173, 117, 81, 59, 45, 35, 26, 0}, - { 16384, 16374, 16370, 16367, 16362, 16348, 16325, 16283, 16204, 16058, 15715, 14980, 13521, 11144, 7972, 4702, 2366, 1063, 480, 241, 128, 71, 42, 22, 14, 9, 5, 0}, - { 16384, 16380, 16377, 16375, 16372, 16365, 16354, 16334, 16295, 16216, 16056, 15716, 15034, 13690, 11467, 8404, 5150, 2385, 908, 417, 199, 106, 62, 35, 21, 13, 7, 0}, - { 16384, 16378, 16376, 16373, 16368, 16360, 16346, 16318, 16267, 16173, 15991, 15644, 14932, 13623, 11575, 8688, 5224, 2309, 891, 393, 202, 103, 57, 34, 20, 11, 8, 0}, - { 16384, 16375, 16372, 16365, 16348, 16322, 16279, 16201, 16046, 15728, 15214, 14297, 12811, 10673, 7918, 4530, 2109, 978, 466, 234, 121, 72, 46, 31, 25, 17, 13, 0}, - { 16384, 16366, 16357, 16341, 16325, 16289, 16220, 16084, 15768, 15300, 14466, 13206, 11402, 9176, 6633, 4092, 2192, 1171, 592, 315, 179, 111, 74, 46, 31, 26, 18, 0}, - { 16384, 16301, 16266, 16211, 16140, 16045, 15889, 15652, 15358, 14883, 14192, 13119, 11753, 10181, 8445, 6708, 5023, 3449, 2226, 1375, 849, 516, 353, 231, 153, 107, 78, 0} - }, - { /* 13.2 kbs A */ - { 16384, 16359, 16349, 16331, 16300, 16236, 16112, 15894, 15480, 14691, 13257, 10996, 8168, 5357, 3193, 1864, 1098, 676, 426, 265, 173, 117, 81, 59, 45, 35, 26, 0}, - { 16384, 16374, 16370, 16367, 16362, 16348, 16325, 16283, 16204, 16058, 15715, 14980, 13521, 11144, 7972, 4702, 2366, 1063, 480, 241, 128, 71, 42, 22, 14, 9, 5, 0}, - { 16384, 16380, 16377, 16375, 16372, 16365, 16354, 16334, 16295, 16216, 16056, 15716, 15034, 13690, 11467, 8404, 5150, 2385, 908, 417, 199, 106, 62, 35, 21, 13, 7, 0}, - { 16384, 16378, 16376, 16373, 16368, 16360, 16346, 16318, 16267, 16173, 15991, 15644, 14932, 13623, 11575, 8688, 5224, 2309, 891, 393, 202, 103, 57, 34, 20, 11, 8, 0}, - { 16384, 16375, 16372, 16365, 16348, 16322, 16279, 16201, 16046, 15728, 15214, 14297, 12811, 10673, 7918, 4530, 2109, 978, 466, 234, 121, 72, 46, 31, 25, 17, 13, 0}, - { 16384, 16366, 16357, 16341, 16325, 16289, 16220, 16084, 15768, 15300, 14466, 13206, 11402, 9176, 6633, 4092, 2192, 1171, 592, 315, 179, 111, 74, 46, 31, 26, 18, 0}, - { 16384, 16301, 16266, 16211, 16140, 16045, 15889, 15652, 15358, 14883, 14192, 13119, 11753, 10181, 8445, 6708, 5023, 3449, 2226, 1375, 849, 516, 353, 231, 153, 107, 78, 0} - }, - { /* 13.2 kbs SWB RF B*/ - { 16384, 16359, 16349, 16331, 16300, 16236, 16112, 15894, 15480, 14691, 13257, 10996, 8168, 5357, 3193, 1864, 1098, 676, 426, 265, 173, 117, 81, 59, 45, 35, 26, 0}, - { 16384, 16374, 16370, 16367, 16362, 16348, 16325, 16283, 16204, 16058, 15715, 14980, 13521, 11144, 7972, 4702, 2366, 1063, 480, 241, 128, 71, 42, 22, 14, 9, 5, 0}, - { 16384, 16380, 16377, 16375, 16372, 16365, 16354, 16334, 16295, 16216, 16056, 15716, 15034, 13690, 11467, 8404, 5150, 2385, 908, 417, 199, 106, 62, 35, 21, 13, 7, 0}, - { 16384, 16378, 16376, 16373, 16368, 16360, 16346, 16318, 16267, 16173, 15991, 15644, 14932, 13623, 11575, 8688, 5224, 2309, 891, 393, 202, 103, 57, 34, 20, 11, 8, 0}, - { 16384, 16375, 16372, 16365, 16348, 16322, 16279, 16201, 16046, 15728, 15214, 14297, 12811, 10673, 7918, 4530, 2109, 978, 466, 234, 121, 72, 46, 31, 25, 17, 13, 0}, - { 16384, 16366, 16357, 16341, 16325, 16289, 16220, 16084, 15768, 15300, 14466, 13206, 11402, 9176, 6633, 4092, 2192, 1171, 592, 315, 179, 111, 74, 46, 31, 26, 18, 0}, - { 16384, 16301, 16266, 16211, 16140, 16045, 15889, 15652, 15358, 14883, 14192, 13119, 11753, 10181, 8445, 6708, 5023, 3449, 2226, 1375, 849, 516, 353, 231, 153, 107, 78, 0} - }, - { /* 16.4 kbs B */ - { 16384, 16359, 16349, 16331, 16300, 16236, 16112, 15894, 15480, 14691, 13257, 10996, 8168, 5357, 3193, 1864, 1098, 676, 426, 265, 173, 117, 81, 59, 45, 35, 26, 0}, - { 16384, 16374, 16370, 16367, 16362, 16348, 16325, 16283, 16204, 16058, 15715, 14980, 13521, 11144, 7972, 4702, 2366, 1063, 480, 241, 128, 71, 42, 22, 14, 9, 5, 0}, - { 16384, 16380, 16377, 16375, 16372, 16365, 16354, 16334, 16295, 16216, 16056, 15716, 15034, 13690, 11467, 8404, 5150, 2385, 908, 417, 199, 106, 62, 35, 21, 13, 7, 0}, - { 16384, 16378, 16376, 16373, 16368, 16360, 16346, 16318, 16267, 16173, 15991, 15644, 14932, 13623, 11575, 8688, 5224, 2309, 891, 393, 202, 103, 57, 34, 20, 11, 8, 0}, - { 16384, 16375, 16372, 16365, 16348, 16322, 16279, 16201, 16046, 15728, 15214, 14297, 12811, 10673, 7918, 4530, 2109, 978, 466, 234, 121, 72, 46, 31, 25, 17, 13, 0}, - { 16384, 16366, 16357, 16341, 16325, 16289, 16220, 16084, 15768, 15300, 14466, 13206, 11402, 9176, 6633, 4092, 2192, 1171, 592, 315, 179, 111, 74, 46, 31, 26, 18, 0}, - { 16384, 16301, 16266, 16211, 16140, 16045, 15889, 15652, 15358, 14883, 14192, 13119, 11753, 10181, 8445, 6708, 5023, 3449, 2226, 1375, 849, 516, 353, 231, 153, 107, 78, 0} - }, - { /* 24.4 kbs B */ - { 16384, 16351, 16333, 16303, 16254, 16163, 15993, 15681, 15080, 13987, 12109, 9465, 6588, 4160, 2488, 1480, 912, 589, 389, 266, 190, 131, 93, 68, 47, 34, 24, 0}, - { 16384, 16379, 16375, 16369, 16360, 16345, 16328, 16286, 16211, 16078, 15810, 15233, 14058, 11933, 8881, 5609, 2940, 1290, 558, 274, 150, 80, 47, 29, 17, 11, 6, 0}, - { 16384, 16382, 16380, 16377, 16370, 16358, 16337, 16300, 16224, 16088, 15811, 15233, 14112, 12019, 9061, 5723, 2780, 1121, 480, 239, 123, 69, 41, 22, 13, 8, 5, 0}, - { 16384, 16377, 16375, 16369, 16363, 16351, 16325, 16268, 16172, 16009, 15686, 15039, 13830, 11799, 8924, 5422, 2444, 960, 441, 220, 111, 63, 37, 22, 11, 6, 3, 0}, - { 16384, 16374, 16369, 16363, 16356, 16335, 16290, 16214, 16068, 15826, 15382, 14550, 13126, 10956, 8000, 4622, 2090, 973, 478, 249, 128, 75, 42, 19, 13, 7, 4, 0}, - { 16384, 16375, 16370, 16367, 16362, 16340, 16298, 16232, 16097, 15860, 15440, 14718, 13570, 11874, 9557, 6790, 4053, 2166, 1150, 622, 323, 179, 96, 53, 33, 17, 12, 0}, - { 16384, 16335, 16304, 16276, 16228, 16166, 16094, 15983, 15775, 15501, 15040, 14417, 13552, 12326, 10847, 9117, 7308, 5373, 3666, 2297, 1336, 807, 495, 313, 216, 152, 114, 0} - }, - { /* 32.0 kbs A */ - { 16384, 16351, 16333, 16303, 16254, 16163, 15993, 15681, 15080, 13987, 12109, 9465, 6588, 4160, 2488, 1480, 912, 589, 389, 266, 190, 131, 93, 68, 47, 34, 24, 0}, - { 16384, 16379, 16375, 16369, 16360, 16345, 16328, 16286, 16211, 16078, 15810, 15233, 14058, 11933, 8881, 5609, 2940, 1290, 558, 274, 150, 80, 47, 29, 17, 11, 6, 0}, - { 16384, 16382, 16380, 16377, 16370, 16358, 16337, 16300, 16224, 16088, 15811, 15233, 14112, 12019, 9061, 5723, 2780, 1121, 480, 239, 123, 69, 41, 22, 13, 8, 5, 0}, - { 16384, 16377, 16375, 16369, 16363, 16351, 16325, 16268, 16172, 16009, 15686, 15039, 13830, 11799, 8924, 5422, 2444, 960, 441, 220, 111, 63, 37, 22, 11, 6, 3, 0}, - { 16384, 16374, 16369, 16363, 16356, 16335, 16290, 16214, 16068, 15826, 15382, 14550, 13126, 10956, 8000, 4622, 2090, 973, 478, 249, 128, 75, 42, 19, 13, 7, 4, 0}, - { 16384, 16375, 16370, 16367, 16362, 16340, 16298, 16232, 16097, 15860, 15440, 14718, 13570, 11874, 9557, 6790, 4053, 2166, 1150, 622, 323, 179, 96, 53, 33, 17, 12, 0}, - { 16384, 16335, 16304, 16276, 16228, 16166, 16094, 15983, 15775, 15501, 15040, 14417, 13552, 12326, 10847, 9117, 7308, 5373, 3666, 2297, 1336, 807, 495, 313, 216, 152, 114, 0} - }, - { /* 48.0 kbs B */ - { 16384, 16334, 16310, 16285, 16254, 16204, 16128, 16031, 15903, 15697, 15380, 14820, 13857, 12267, 9878, 7099, 4509, 2576, 1478, 871, 531, 349, 230, 163, 111, 80, 62, 0}, - { 16384, 16337, 16327, 16307, 16278, 16239, 16178, 16092, 15947, 15719, 15286, 14428, 12833, 10246, 7123, 4088, 1896, 849, 481, 287, 190, 139, 94, 66, 52, 34, 24, 0}, - { 16384, 16352, 16341, 16329, 16312, 16295, 16265, 16223, 16151, 16026, 15825, 15437, 14645, 13089, 10612, 7364, 4077, 1783, 779, 444, 281, 192, 138, 93, 65, 43, 30, 0}, - { 16384, 16354, 16347, 16337, 16314, 16284, 16233, 16165, 16051, 15847, 15450, 14621, 13069, 10623, 7298, 3789, 1569, 727, 445, 302, 207, 143, 96, 59, 36, 18, 9, 0}, - { 16384, 16352, 16342, 16330, 16314, 16295, 16266, 16215, 16127, 15984, 15709, 15190, 14242, 12540, 9979, 6448, 3160, 1392, 752, 481, 344, 251, 169, 115, 73, 28, 8, 0}, - { 16384, 16340, 16320, 16302, 16272, 16257, 16220, 16135, 16011, 15784, 15370, 14688, 13423, 11457, 8721, 5529, 2736, 1375, 784, 525, 353, 263, 172, 113, 78, 26, 11, 0}, - { 16384, 16238, 16170, 16113, 16077, 16030, 16000, 15948, 15873, 15752, 15535, 15157, 14595, 13788, 12569, 10767, 8611, 6186, 4101, 2459, 1478, 881, 607, 385, 243, 168, 116, 0} - } +const Word16 cf_se02_tab[4][IGF_CTX_COUNT][IGF_SYMBOLS_IN_TABLE + 1] = +{ + { /* 9.6 kbs B */ + { 16384, 16369, 16348, 16316, 16256, 16172, 16017, 15735, 15246, 14363, 13036, 11139, 8916, 6724, 4757, 3282, 2221, 1549, 1105, 771, 548, 364, 238, 151, 89, 50, 30, 0 }, +{ 16384, 16371, 16358, 16339, 16290, 16241, 16153, 16040, 15813, 15397, 14601, 13301, 11360, 8916, 6254, 3911, 2220, 1280, 755, 461, 278, 177, 111, 70, 35, 20, 12, 0 }, +{ 16384, 16375, 16359, 16333, 16286, 16243, 16154, 16024, 15771, 15380, 14712, 13537, 11742, 9425, 6872, 4378, 2327, 1197, 671, 412, 259, 145, 93, 52, 26, 13, 5, 0 }, +{ 16384, 16372, 16358, 16326, 16289, 16241, 16147, 16014, 15765, 15321, 14670, 13546, 11912, 9787, 7323, 4824, 2536, 1330, 731, 438, 258, 148, 86, 37, 22, 11, 2, 0 }, +{ 16384, 16376, 16364, 16344, 16315, 16272, 16219, 16119, 15910, 15620, 15100, 14254, 13063, 11489, 9413, 7100, 4738, 2751, 1584, 973, 597, 349, 201, 96, 47, 22, 9, 0 }, +{ 16384, 16364, 16340, 16312, 16288, 16237, 16166, 16026, 15756, 15390, 14833, 13870, 12627, 10998, 8985, 6893, 4720, 3048, 1860, 1131, 725, 449, 215, 111, 56, 34, 14, 0 }, +{ 16384, 16326, 16297, 16246, 16183, 16064, 15884, 15632, 15240, 14763, 14107, 13230, 12185, 10886, 9390, 7781, 6194, 4696, 3350, 2259, 1506, 975, 604, 356, 201, 106, 48, 0 } + }, + + { /* 9.6 kbs SWB B*/ + { 16384, 16359, 16349, 16331, 16300, 16236, 16112, 15894, 15480, 14691, 13257, 10996, 8168, 5357, 3193, 1864, 1098, 676, 426, 265, 173, 117, 81, 59, 45, 35, 26, 0 }, +{ 16384, 16374, 16370, 16367, 16362, 16348, 16325, 16283, 16204, 16058, 15715, 14980, 13521, 11144, 7972, 4702, 2366, 1063, 480, 241, 128, 71, 42, 22, 14, 9, 5, 0 }, +{ 16384, 16380, 16377, 16375, 16372, 16365, 16354, 16334, 16295, 16216, 16056, 15716, 15034, 13690, 11467, 8404, 5150, 2385, 908, 417, 199, 106, 62, 35, 21, 13, 7, 0 }, +{ 16384, 16378, 16376, 16373, 16368, 16360, 16346, 16318, 16267, 16173, 15991, 15644, 14932, 13623, 11575, 8688, 5224, 2309, 891, 393, 202, 103, 57, 34, 20, 11, 8, 0 }, +{ 16384, 16375, 16372, 16365, 16348, 16322, 16279, 16201, 16046, 15728, 15214, 14297, 12811, 10673, 7918, 4530, 2109, 978, 466, 234, 121, 72, 46, 31, 25, 17, 13, 0 }, +{ 16384, 16366, 16357, 16341, 16325, 16289, 16220, 16084, 15768, 15300, 14466, 13206, 11402, 9176, 6633, 4092, 2192, 1171, 592, 315, 179, 111, 74, 46, 31, 26, 18, 0 }, +{ 16384, 16301, 16266, 16211, 16140, 16045, 15889, 15652, 15358, 14883, 14192, 13119, 11753, 10181, 8445, 6708, 5023, 3449, 2226, 1375, 849, 516, 353, 231, 153, 107, 78, 0 } + }, + +{ /* 24.4 kbs B */ + { 16384, 16351, 16333, 16303, 16254, 16163, 15993, 15681, 15080, 13987, 12109, 9465, 6588, 4160, 2488, 1480, 912, 589, 389, 266, 190, 131, 93, 68, 47, 34, 24, 0 }, +{ 16384, 16379, 16375, 16369, 16360, 16345, 16328, 16286, 16211, 16078, 15810, 15233, 14058, 11933, 8881, 5609, 2940, 1290, 558, 274, 150, 80, 47, 29, 17, 11, 6, 0 }, +{ 16384, 16382, 16380, 16377, 16370, 16358, 16337, 16300, 16224, 16088, 15811, 15233, 14112, 12019, 9061, 5723, 2780, 1121, 480, 239, 123, 69, 41, 22, 13, 8, 5, 0 }, +{ 16384, 16377, 16375, 16369, 16363, 16351, 16325, 16268, 16172, 16009, 15686, 15039, 13830, 11799, 8924, 5422, 2444, 960, 441, 220, 111, 63, 37, 22, 11, 6, 3, 0 }, +{ 16384, 16374, 16369, 16363, 16356, 16335, 16290, 16214, 16068, 15826, 15382, 14550, 13126, 10956, 8000, 4622, 2090, 973, 478, 249, 128, 75, 42, 19, 13, 7, 4, 0 }, +{ 16384, 16375, 16370, 16367, 16362, 16340, 16298, 16232, 16097, 15860, 15440, 14718, 13570, 11874, 9557, 6790, 4053, 2166, 1150, 622, 323, 179, 96, 53, 33, 17, 12, 0 }, +{ 16384, 16335, 16304, 16276, 16228, 16166, 16094, 15983, 15775, 15501, 15040, 14417, 13552, 12326, 10847, 9117, 7308, 5373, 3666, 2297, 1336, 807, 495, 313, 216, 152, 114, 0 } +}, + +{ /* 48.0 kbs B */ + { 16384, 16334, 16310, 16285, 16254, 16204, 16128, 16031, 15903, 15697, 15380, 14820, 13857, 12267, 9878, 7099, 4509, 2576, 1478, 871, 531, 349, 230, 163, 111, 80, 62, 0}, + { 16384, 16337, 16327, 16307, 16278, 16239, 16178, 16092, 15947, 15719, 15286, 14428, 12833, 10246, 7123, 4088, 1896, 849, 481, 287, 190, 139, 94, 66, 52, 34, 24, 0 }, + { 16384, 16352, 16341, 16329, 16312, 16295, 16265, 16223, 16151, 16026, 15825, 15437, 14645, 13089, 10612, 7364, 4077, 1783, 779, 444, 281, 192, 138, 93, 65, 43, 30, 0 }, + { 16384, 16354, 16347, 16337, 16314, 16284, 16233, 16165, 16051, 15847, 15450, 14621, 13069, 10623, 7298, 3789, 1569, 727, 445, 302, 207, 143, 96, 59, 36, 18, 9, 0 }, + { 16384, 16352, 16342, 16330, 16314, 16295, 16266, 16215, 16127, 15984, 15709, 15190, 14242, 12540, 9979, 6448, 3160, 1392, 752, 481, 344, 251, 169, 115, 73, 28, 8, 0 }, + { 16384, 16340, 16320, 16302, 16272, 16257, 16220, 16135, 16011, 15784, 15370, 14688, 13423, 11457, 8721, 5529, 2736, 1375, 784, 525, 353, 263, 172, 113, 78, 26, 11, 0 }, + { 16384, 16238, 16170, 16113, 16077, 16030, 16000, 15948, 15873, 15752, 15535, 15157, 14595, 13788, 12569, 10767, 8611, 6186, 4101, 2459, 1478, 881, 607, 385, 243, 168, 116, 0 } +} }; /* only needed for >= 48 kbs */ diff --git a/lib_com/rom_com_fx.h b/lib_com/rom_com_fx.h index 5f9c51340971defc1e94b00bc29580555e084d74..c33934a983dfc1066035fb753ead139d0519fe00 100644 --- a/lib_com/rom_com_fx.h +++ b/lib_com/rom_com_fx.h @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #ifndef ROM_COM_FX_H @@ -270,8 +270,6 @@ extern const Word16 inter4_1_fx[]; extern const Word16 Low_H_phasedisp[L_SUBFR]; extern const Word16 Mid_H_phasedisp[L_SUBFR]; extern const Word16 phs_tbl_dec[]; -extern const Word16 FFT_reorder_64[]; -extern const Word16 FFT_reorder_256[]; extern const Word16 tbl_gain_trans_tc_fx[]; extern const Word16 Glottal_cdbk_fx[]; @@ -298,8 +296,6 @@ extern const Word16 edct_table_400_fx[]; /*------------------------------------------------------------------------------* * FFT transform *------------------------------------------------------------------------------*/ -extern const Word16 FFT_REORDER_128[]; -extern const Word16 FFT_REORDER_512[]; extern const Word16 FFT_REORDER_1024[]; extern const Word16 FFT_W64[]; extern const Word16 FFT_W128[]; @@ -315,20 +311,16 @@ extern const Word16 Ip_fft8_fx[6]; extern const Word16 w_fft8_fx[4]; extern const Word16 Ip_fft32_fx[6]; -extern const Word16 w_fft32_fx[16]; extern const Word16 Ip_fft64_fx[6]; -extern const Word16 w_fft64_fx[32]; extern const Word16 Ip_fft4_fx[6]; extern const Word16 w_fft4_fx[2]; extern const Word16 Ip_fft128_fx[10]; -extern const Word16 w_fft128_fx[64]; extern const Word16 ip_edct2_64_fx[6]; extern const Word16 w_edct2_64_fx[80]; -extern const Word32 w_fft64_16fx[32]; extern const Word16 Odx_fft64_16fx[64]; extern const Word16 Ip_fft64_16fx[6]; extern const Word16 Ip_fft32_16fx[6]; @@ -619,7 +611,6 @@ extern const Word16 win_lpc_shb_fx[]; /* Window for calcul extern const Word16 cos_table[512]; extern const Word16 cos_diff_table[512]; extern const Word16 Ip_fft256_fx[10]; -extern const Word16 w_fft256_fx[128]; extern const Word16 Ip_fft512_fx[18]; extern const Word16 w_fft512_fx[256]; extern const Word16 sinq_16k[]; @@ -833,7 +824,6 @@ extern const Word16 ddec_LSB_fx[4][2]; extern const Word16 SmoothingWin_NB875_fx[]; extern const Word16 SmoothingWin_NB2_fx[]; -extern const Word16 window_48kHz_fx16[]; extern const Word16 ENR_ATT_fx[5]; @@ -1190,7 +1180,7 @@ extern const Word16 cf_off_se11_tab[IGF_CTX_COUNT][IGF_CTX_COUNT]; extern const Word16 cf_se00_tab[IGF_SYMBOLS_IN_TABLE + 1]; extern const Word16 cf_se01_tab[9][IGF_SYMBOLS_IN_TABLE + 1]; -extern const Word16 cf_se02_tab[9][IGF_CTX_COUNT][IGF_SYMBOLS_IN_TABLE + 1]; +extern const Word16 cf_se02_tab[4][IGF_CTX_COUNT][IGF_SYMBOLS_IN_TABLE + 1]; extern const Word16 cf_se10_tab[IGF_SYMBOLS_IN_TABLE + 1]; extern const Word16 cf_se11_tab[IGF_CTX_COUNT][IGF_CTX_COUNT][IGF_SYMBOLS_IN_TABLE + 1]; diff --git a/lib_com/scale_mem_fx.c b/lib_com/scale_mem_fx.c index f02d99f7c190c1b239247aaeab3004dbd8531746..3ab78b4a1586cd512ed38b3d238e4d36dd800c8a 100644 --- a/lib_com/scale_mem_fx.c +++ b/lib_com/scale_mem_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Common prototypes */ #include "prot_fx.h" /* Common prototypes */ #include "cnst_fx.h" #include "stl.h" -#include "wmc_auto.h" - /*-------------------------------------------------------------------* * Rescale_exc: @@ -64,25 +62,25 @@ Word16 Rescale_exc( /*---------------------------------------------- * new_Q = smallest Q since 4 subframes (20ms) *----------------------------------------------*/ - IF( sub( coder_type, TRANSITION ) == 0 ) + IF( EQ_16( coder_type, TRANSITION )) { tmp = s_min(tmp, 7); } - ELSE IF (sub(coder_type,INACTIVE)==0) + ELSE IF (EQ_16(coder_type,INACTIVE)) { tmp = s_min(tmp, 13); } - ELSE IF( sub(lg,L_SUBFR) > 0 )/* --> can only happen in AUDIO mode */ + ELSE IF( GT_16(lg,L_SUBFR))/* --> can only happen in AUDIO mode */ { tmp = s_min(tmp, 4); /* Limitation of the scaling gain because the frequency domain will add much more energy to the excitation*/ - if( L_sub(L_abs(L_gain_code), 3276800) >= 0 ) /*(1-gain_pit)*past gain code*4 > 50 */ + if( GE_32(L_abs(L_gain_code), 3276800)) /*(1-gain_pit)*past gain code*4 > 50 */ { tmp = s_min(tmp, 2); /* Limitation of the scaling gain because the frequency domain might add much more energy to the excitation*/ } } new_Q = s_min(tmp, sQsubfr[0]); - IF(sub(lg, L_SUBFR)==0) + IF(EQ_16(lg, L_SUBFR)) { FOR(i = L_Q_MEM-1; i >= 1; i--) { @@ -93,7 +91,7 @@ Word16 Rescale_exc( } ELSE { - IF(sub(lg, 2*L_SUBFR)==0) + IF(EQ_16(lg, 2*L_SUBFR)) { new_Q = s_min(new_Q, sQsubfr[L_Q_MEM-1]); FOR(i = L_Q_MEM-1; i >= 2; i--) @@ -325,7 +323,7 @@ Word16 rescale_mem( new_Q = s_max(new_Q, -1); tmp = add(max_scale, *Q_syn); - if( sub(s_min(new_Q, *prev_Q_syn), tmp) > 0) + if( GT_16(s_min(new_Q, *prev_Q_syn), tmp)) { new_Q = s_max(tmp, -1); } diff --git a/lib_com/stab_est_fx.c b/lib_com/stab_est_fx.c index dd07aa9f321ea0b7e91890458c558a99edf1878e..2d53b33a48e492ae63eb656581fce34575204201 100644 --- a/lib_com/stab_est_fx.c +++ b/lib_com/stab_est_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "cnst_fx.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ -#include "stl.h" -#include "wmc_auto.h" - /* required for wmc_tool */ +#include "stl.h" /* required for wmc_tool */ #include "basop_mpy.h" /*-------------------------------------------------------------------* @@ -122,7 +120,7 @@ Word16 stab_est_fx( test(); test(); test(); - IF ((sub(dev, thresh[3])< 0 ) && (sub(*last_music_flag,3) >= 0) ) + IF ((LT_16(dev, thresh[3]))&&(GE_16(*last_music_flag,3))) { music_flag2 = 4; move16(); @@ -136,7 +134,7 @@ Word16 stab_est_fx( * statistical deviation < thresh2 and last signal category type >= 2 * (last category was "moderatly tonal" and the new one is a "tonal" ) *--------------------------------------------------------------------*/ - ELSE IF ((sub(dev, thresh[2])< 0 ) && (sub(*last_music_flag,2) >= 0) ) + ELSE IF ((LT_16(dev, thresh[2]))&&(GE_16(*last_music_flag,2))) { music_flag2 = 3; move16(); @@ -150,7 +148,7 @@ Word16 stab_est_fx( * statistical deviation < thresh1 and last signal category type >= 1 * (last category was "slightly tonal" and the new one is a "moderatly tonal") *--------------------------------------------------------------------*/ - ELSE IF ((sub(dev, thresh[1])< 0 ) && (sub(*last_music_flag,1) >= 0) ) + ELSE IF ((LT_16(dev, thresh[1]))&&(GE_16(*last_music_flag,1))) { music_flag2 = 2; move16(); @@ -160,7 +158,7 @@ Word16 stab_est_fx( * statistical deviation < thresh0 * (last category was "not tonal" and the new one is "slightly tonal") *--------------------------------------------------------------------*/ - ELSE IF ((sub(dev, thresh[0]) < 0 ) ) + ELSE IF ((LT_16(dev, thresh[0]))) { music_flag2 = 1; move16();/* [2000, 4000] Hz */ @@ -181,7 +179,7 @@ Word16 stab_est_fx( /*------------------------------------------------------------------------* * Update the thresholds *------------------------------------------------------------------------*/ - IF (sub(*nb_thr_3,NB_TH3_MIN) > 0) + IF (GT_16(*nb_thr_3,NB_TH3_MIN)) { /* the number of consecutive categories type 3 or 4 (most tonal and tonal) */ @@ -196,7 +194,7 @@ Word16 stab_est_fx( move16(); } - ELSE IF (sub(*nb_thr_1,NB_TH1_MIN) > 0) + ELSE IF (GT_16(*nb_thr_1,NB_TH1_MIN)) { /* the number of consecutive categories type 0 (non tonal frames) */ /* is greater than 30 frames -> decrease the deviations thresholds to allow less variation */ diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h index bc1cdf6bccad8bb24ffdfef9e77074bfefbc4240..717aab2659fa872ac70369a1fc796f42e23cdbc0 100644 --- a/lib_com/stat_com.h +++ b/lib_com/stat_com.h @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #ifndef STAT_COM_H diff --git a/lib_com/stat_noise_uv_mod_fx.c b/lib_com/stat_noise_uv_mod_fx.c index cd82d1e00c7bb8fa08581059416a729ace6fd585..2728c180b9c3f75ffbbf79f421715b6eecfeefed 100644 --- a/lib_com/stat_noise_uv_mod_fx.c +++ b/lib_com/stat_noise_uv_mod_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "prot_fx.h" /* Function prototypes */ #include "cnst_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*---------------------------------------------------------------------* * Local constants @@ -88,7 +86,7 @@ void stat_noise_uv_mod_fx( test(); test(); test(); - IF (sub(coder_type,INACTIVE) == 0 && ( L_sub(bitrate,ACELP_9k60) == 0 || (L_sub(bitrate,ACELP_9k60) < 0 && sub(bwidth_fx,NB) > 0) ) ) + IF (EQ_16(coder_type,INACTIVE)&&(EQ_32(bitrate,ACELP_9k60)||(LT_32(bitrate,ACELP_9k60)&>_16(bwidth_fx,NB)))) { min_alpha = *st_min_alpha; move16(); @@ -124,7 +122,7 @@ void stat_noise_uv_mod_fx( test(); test(); test(); - IF ( sub(coder_type,INACTIVE) == 0 && ( L_sub(bitrate,ACELP_9k60) == 0 || (L_sub(bitrate,ACELP_9k60) < 0 && sub(bwidth_fx,NB) > 0) ) ) + IF ( EQ_16(coder_type,INACTIVE)&&(EQ_32(bitrate,ACELP_9k60)||(LT_32(bitrate,ACELP_9k60)&>_16(bwidth_fx,NB)))) { /* use a local working copy for scaling and filtering, not needed if input Q-range is fixed */ Copy(exc2, Exc2_local, L_FRAME); @@ -148,27 +146,26 @@ void stat_noise_uv_mod_fx( En_shift = 0; move16(); - if (sub(Q_local, 3) > 0) + if (GT_16(Q_local, 3)) { /* increase margin for energy accumulation in calc_tilt and vare accumulation */ En_shift = sub(Q_local, 3); } - IF (sub(min_alpha, TILT_COMP_LIM_FX) < 0) + IF (LT_16(min_alpha, TILT_COMP_LIM_FX)) { FOR (i_subfr=0; i_subfrge_sm = ISP_SMOOTHING_QUANT_A1 * st->ge_sm + (1.0f-ISP_SMOOTHING_QUANT_A1) * ge */ - IF ( sub(*uv_count,1) == 0) + IF ( EQ_16(*uv_count,1)) { *ge_sm = L_shr(L_Ge,Q_local); } @@ -318,7 +315,7 @@ void stat_noise_uv_mod_fx( ELSE /* (unvoiced_vad != 0) */ { (*act_count)++; - IF (sub(*act_count,3) > 0) + IF (GT_16(*act_count,3)) { *act_count = 3; move16(); diff --git a/lib_com/swb_bwe_com_fx.c b/lib_com/swb_bwe_com_fx.c index ea79bc67ea637dc122a2def59ffba0a2cb0e3c64..b12896f44d2e8d15dfc3a32d60edea1b52965fc1 100644 --- a/lib_com/swb_bwe_com_fx.c +++ b/lib_com/swb_bwe_com_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -9,8 +9,6 @@ #include "basop_util.h" #include "rom_com_fx.h" #include "stl.h" -#include "wmc_auto.h" - /*==========================================================================*/ @@ -96,14 +94,14 @@ Word16 WB_BWE_gain_pred_fx( L_tmp = L_shr(enerL, 4); test(); - IF(L_sub(L_max(L_WB_fenv1, L_WB_fenv0), L_tmp) > 0 && sub(9856, pitch) > 0) + IF(GT_32(L_max(L_WB_fenv1, L_WB_fenv0), L_tmp)&>_16(9856,pitch)) { ener_var_flag = 1; move16(); } test(); - IF(L_sub(L_WB_fenv0, L_shl(L_WB_fenv1,1)) > 0) + IF(GT_32(L_WB_fenv0, L_shl(L_WB_fenv1,1))) { exp = norm_l(L_WB_fenv0); tmp = extract_h(L_shl(L_WB_fenv0, exp)); @@ -114,7 +112,7 @@ Word16 WB_BWE_gain_pred_fx( alfa = s_max(tmp, 3277);/*Q15 */ L_WB_fenv0 = Mult_32_16(L_WB_fenv0, alfa);/*2*Q_syn+15-15->2*Q_syn */ } - ELSE IF (L_sub(L_WB_fenv1, L_shl(L_WB_fenv0, 1)) > 0 && sub(coder_type,UNVOICED) != 0) + ELSE IF (GT_32(L_WB_fenv1, L_shl(L_WB_fenv0, 1))&&NE_16(coder_type,UNVOICED)) { exp = norm_l(L_WB_fenv1); tmp = extract_h(L_shl(L_WB_fenv1, exp)); @@ -155,7 +153,7 @@ Word16 WB_BWE_gain_pred_fx( test(); test(); - IF(sub(coder_type,AUDIO) != 0&& sub(coder_type,UNVOICED) != 0 && ener_var_flag == 0) + IF(NE_16(coder_type,AUDIO)&&NE_16(coder_type,UNVOICED)&&ener_var_flag==0) { WB_fenv[0]= add(WB_fenv[0], mult_r(WB_fenv[0], 16384)); move16(); @@ -177,9 +175,9 @@ Word16 WB_BWE_gain_pred_fx( test(); test(); test(); - IF( sub(coder_type,TRANSITION) != 0 && sub(coder_type,AUDIO) != 0 && sub(coder_type,UNVOICED) != 0 && - sub(enerL_40, WB_fenv[0]) > 0 && sub(alfa,29491) > 0 && !(sub(coder_type, prev_coder_type) == 0 && - sub(WB_fenv[0],prev_WB_fenv) > 0) ) + IF( NE_16(coder_type,TRANSITION)&&NE_16(coder_type,AUDIO)&&NE_16(coder_type,UNVOICED)&& + GT_16(enerL_40, WB_fenv[0]) && GT_16(alfa,29491) && !(EQ_16(coder_type, prev_coder_type) && + GT_16(WB_fenv[0],prev_WB_fenv) ) ) { IF(WB_fenv[0] != 0) { @@ -192,7 +190,7 @@ Word16 WB_BWE_gain_pred_fx( WB_fenv[0] = extract_l(L_tmp);/*Q3 */ } - IF( sub(WB_fenv[0],prev_WB_fenv ) > 0) + IF( GT_16(WB_fenv[0],prev_WB_fenv )) { /*WB_fenv[0]= add(mult_r(9830, WB_fenv[0]), mult_r(22938, prev_WB_fenv)); move16();//Q3 */ WB_fenv[0] = round_fx(L_mac(L_mult(9830, WB_fenv[0]), 22938, prev_WB_fenv));/*Q3 */ @@ -222,7 +220,7 @@ Word16 WB_BWE_gain_pred_fx( test(); test(); test(); - IF( sub(shr(enerL_16, 3), tmp) > 0 && L_sub(enerL, L_tmp) > 0 && sub(prev_coder_type,UNVOICED) != 0 && WB_fenv[0] != 0) + IF( GT_16(shr(enerL_16, 3), tmp)&>_32(enerL,L_tmp)&&NE_16(prev_coder_type,UNVOICED)&&WB_fenv[0]!=0) { env_var_flag = 1; move16(); @@ -236,7 +234,7 @@ Word16 WB_BWE_gain_pred_fx( L_tmp = L_shr( L_mult0(tmp, WB_fenv[0]), 12);/*Q3 */ WB_fenv[0] = extract_l(L_tmp);/*Q3 */ - IF( sub(WB_fenv[0],prev_WB_fenv) > 0 ) + IF( GT_16(WB_fenv[0],prev_WB_fenv)) { /*WB_fenv[0] = add(mult_r(9830, WB_fenv[0]), mult_r(22938, prev_WB_fenv));//Q3 */ WB_fenv[0] = round_fx(L_mac(L_mult(9830, WB_fenv[0]), 22938, prev_WB_fenv));/*Q3 */ @@ -244,13 +242,13 @@ Word16 WB_BWE_gain_pred_fx( } test(); - IF(sub(coder_type,UNVOICED) == 0 || sub(prev_coder_type,UNVOICED) == 0) + IF(EQ_16(coder_type,UNVOICED)||EQ_16(prev_coder_type,UNVOICED)) { WB_fenv[0] = shr(WB_fenv[0], 1); move16();/*Q3 */ } - IF(sub(coder_type,AUDIO) != 0) + IF(NE_16(coder_type,AUDIO)) { tmp = mult_r(voice_factor, 19661); /*Q12 */ tmp = s_max(tmp, 4096); @@ -266,13 +264,13 @@ Word16 WB_BWE_gain_pred_fx( WB_fenv[0] = round_fx(L_shl(L_tmp,16)); /*Q3 */ } test(); - IF( L_sub(last_core_brate,ACELP_8k00) > 0 && sub(WB_fenv[0],last_wb_bwe_ener) > 0 ) + IF( GT_32(last_core_brate,ACELP_8k00)&>_16(WB_fenv[0],last_wb_bwe_ener)) { /*WB_fenv[0]= add(mult_r(29491, last_wb_bwe_ener), mult_r(3277, WB_fenv[0]));//Q3 */ WB_fenv[0] = round_fx(L_mac(L_mult(29491, last_wb_bwe_ener), 3277, WB_fenv[0]));/*Q3 */ } - IF( sub(last_extl_fx, WB_BWE) != 0 && sub(tilt_wb_fx, 128) < 0) + IF( NE_16(last_extl_fx, WB_BWE)&<_16(tilt_wb_fx,128)) { WB_fenv[0] = mult_r(s_min(16384, shl(tilt_wb_fx, 8)), WB_fenv[0]); } @@ -291,7 +289,7 @@ Word16 WB_BWE_gain_pred_fx( } test(); - IF(sub(coder_type,UNVOICED) == 0 || sub(prev_coder_type,UNVOICED) == 0) + IF(EQ_16(coder_type,UNVOICED)||EQ_16(prev_coder_type,UNVOICED)) { WB_fenv[1] = shr(WB_fenv[1], 1); move16();/*Q3 */ @@ -320,16 +318,16 @@ void calc_norm_envelop_lf_fx( *sfreq = 2; move16(); - IF ( sub(hq_generic_offset, HQ_GENERIC_FOFFSET_24K4) == 0 ) + IF ( EQ_16(hq_generic_offset, HQ_GENERIC_FOFFSET_24K4)) { *efreq = 146; move16(); - if ( sub(HQ_mode, HQ_GEN_FB) == 0 ) + if ( EQ_16(HQ_mode, HQ_GEN_FB)) { *efreq = 306; move16(); } - IF ( sub(add(shl(sub(328,*efreq),1),1),*L_swb_norm) < 0) + IF ( LT_16(add(shl(sub(328,*efreq),1),1),*L_swb_norm)) { *L_swb_norm = add(shl(sub(328,*efreq),1),1); } @@ -338,12 +336,12 @@ void calc_norm_envelop_lf_fx( { *efreq = 130; move16(); - if ( sub(HQ_mode, HQ_GEN_FB) == 0 ) + if ( EQ_16(HQ_mode, HQ_GEN_FB)) { *efreq = 290; move16(); } - IF ( sub(add(shl(sub(400,*efreq),1),1),*L_swb_norm) < 0) + IF ( LT_16(add(shl(sub(400,*efreq),1),1),*L_swb_norm)) { *L_swb_norm = add(shl(sub(400,*efreq),1),1); } @@ -408,7 +406,7 @@ void calc_normal_length_fx( move16(); test(); test(); - if( sub(core,HQ_CORE) == 0 || sub(extl,SWB_BWE) == 0 || sub(extl, FB_BWE) == 0 ) + if( EQ_16(core,HQ_CORE)||EQ_16(extl,SWB_BWE)||EQ_16(extl,FB_BWE)) { THRES = 8; move16(); @@ -418,7 +416,7 @@ void calc_normal_length_fx( move16(); test(); test(); - if( sub(core,HQ_CORE) == 0 && (sub(mode,HQ_HARMONIC) == 0 || sub(mode,HQ_HVQ) == 0) ) + if( EQ_16(core,HQ_CORE)&&(EQ_16(mode,HQ_HARMONIC)||EQ_16(mode,HQ_HVQ))) { N = 13; move16(); @@ -444,7 +442,7 @@ void calc_normal_length_fx( } L_tmp = L_mult0(peak,15+THRES);/*Q_syn */ - IF ( sub(THRES,8) == 0 ) + IF ( EQ_16(THRES,8)) { L_tmp1 = L_shl(Mult_32_16(L_mean,32767), 3); } @@ -454,13 +452,13 @@ void calc_normal_length_fx( } test(); - if( L_sub(L_tmp,L_tmp1)>0 && (sub(peak,shl(10,Q_syn)) > 0)) + if( GT_32(L_tmp,L_tmp1)&&(GT_16(peak,shl(10,Q_syn)))) { n_band = add(1,n_band); } } - IF( sub(core, ACELP_CORE) == 0 ) + IF( EQ_16(core, ACELP_CORE)) { L_swb_norm_trans = add(4, mult(n_band, 8192)); L_swb_norm_norm = add(8, mult(n_band, 16384)); @@ -468,12 +466,12 @@ void calc_normal_length_fx( L_tmp = L_add(65536, L_mult0(n_band, 4096)); /*Q16 */ L_swb_norm_harm = s_max(round_fx(L_shl(L_tmp, 5)), 24); /* Q0 */ - IF( sub(mode,HARMONIC) == 0 ) + IF( EQ_16(mode,HARMONIC)) { L_swb_norm_cur = L_swb_norm_harm; move16(); } - ELSE IF( sub(mode,NORMAL) == 0 ) + ELSE IF( EQ_16(mode,NORMAL)) { L_swb_norm_cur = L_swb_norm_norm; move16(); @@ -491,7 +489,7 @@ void calc_normal_length_fx( ELSE { test(); - IF( sub(mode,HQ_HARMONIC) == 0 || sub(mode,HQ_HVQ) == 0 ) + IF( EQ_16(mode,HQ_HARMONIC)||EQ_16(mode,HQ_HVQ)) { L_tmp = L_add(65536, L_mult(n_band, 2560)); L_swb_norm_cur = round_fx(L_shl(L_tmp, 5));/*Q0 */ @@ -522,7 +520,7 @@ Word32 calc_tilt_bwe_fx( /* o : Tilt in Q24 */ const Word16 *ptr; Word16 exp2; - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF /* this is required for adaptative precision energy summation loop, do not remove */ Overflow = 0; @@ -593,7 +591,7 @@ Word32 calc_tilt_bwe_fx( /* o : Tilt in Q24 */ /* Put in Q24 */ L_temp = L_shr(L_temp, sub(exp2, 24)); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON return L_temp; } @@ -724,7 +722,7 @@ void WB_BWE_decoding_fx( /* copy excitation */ test(); - if( sub(coder_type,AUDIO) != 0 && L_sub(total_brate,ACELP_8k00) <= 0 ) + if( NE_16(coder_type,AUDIO)&&LE_32(total_brate,ACELP_8k00)) { core_type = 0; move16(); @@ -746,7 +744,7 @@ void WB_BWE_decoding_fx( { exp = norm_s(L_wb_norm); inv_L_wb_norm = shl(div_s(shl(1,sub(14,exp)),L_wb_norm),sub(exp,14)); /* Q(15) */ - IF(sub(mode,HARMONIC) != 0) + IF(NE_16(mode,HARMONIC)) { tmp = add(shl(inv_L_wb_norm,1),inv_L_wb_norm) ; weight = s_max(s_min(tmp,16384),8192); @@ -777,7 +775,7 @@ void WB_BWE_decoding_fx( WB_signal[n_freq] = extract_l(Mult_32_16(L_tmp,tmp)); /* Q_syn */ } - IF(sub(signum[n_freq],1) != 0) + IF(NE_16(signum[n_freq],1)) { WB_signal[n_freq] = negate(WB_signal[n_freq]); move16(); @@ -805,13 +803,13 @@ void WB_BWE_decoding_fx( L = 1; move16(); - if( sub(mode,HARMONIC) == 0 ) + if( EQ_16(mode,HARMONIC)) { L = 4; move16(); } - IF( sub(coder_type,UNVOICED) == 0 ) + IF( EQ_16(coder_type,UNVOICED)) { FOR ( n_freq = swb_bwe_subband_fx[0]; n_freq < swb_bwe_subband_fx[4]; n_freq++ ) { @@ -855,7 +853,7 @@ void WB_BWE_decoding_fx( IF( core_type == 1 ) { test(); - IF( sub(prev_coder_type,AUDIO) != 0 && L_sub(total_brate,ACELP_8k00) <= 0 ) + IF( NE_16(prev_coder_type,AUDIO)&&LE_32(total_brate,ACELP_8k00)) { FOR(i=160; i<240; i++) { @@ -870,7 +868,7 @@ void WB_BWE_decoding_fx( } } - IF(L_sub(total_brate,ACELP_8k00) <= 0) + IF(LE_32(total_brate,ACELP_8k00)) { alfa = 26214; move16(); /*0.8f in Q15; */ @@ -887,7 +885,7 @@ void WB_BWE_decoding_fx( } ELSE { - IF( sub(prev_coder_type,AUDIO) == 0 ) + IF( EQ_16(prev_coder_type,AUDIO)) { FOR(i=80; i<240; i++) { @@ -903,7 +901,7 @@ void WB_BWE_decoding_fx( } test(); - IF( sub(prev_coder_type,coder_type) == 0 && sub(WB_fenv[0],prev_WB_fenv[0]) > 0 ) + IF( EQ_16(prev_coder_type,coder_type)&>_16(WB_fenv[0],prev_WB_fenv[0])) { alfa = 13107; move16();/*.4 in Q15 */ @@ -921,7 +919,7 @@ void WB_BWE_decoding_fx( test(); test(); test(); - IF( sub(coder_type,GENERIC) == 0 || ((L_sub(EnergyL,L_shr(*prev_Energy,1)) > 0 && L_sub(*prev_Energy,L_shr( EnergyL, 1))>0 && sub(*prev_flag,1) == 0)) ) + IF( EQ_16(coder_type,GENERIC)||((GT_32(EnergyL,L_shr(*prev_Energy,1))&>_32(*prev_Energy,L_shr(EnergyL,1))&&EQ_16(*prev_flag,1)))) { WB_fenv[0] = shr( WB_fenv[0], 1); move16(); @@ -938,7 +936,7 @@ void WB_BWE_decoding_fx( test(); test(); - IF( (sub(mode,HARMONIC) == 0 &&sub(shr(WB_fenv[0], 2), WB_fenv[1]) > 0) || sub(mode,NORMAL) == 0 ) + IF( (EQ_16(mode,HARMONIC)&>_16(shr(WB_fenv[0],2),WB_fenv[1]))||EQ_16(mode,NORMAL)) { test(); test(); @@ -953,11 +951,11 @@ void WB_BWE_decoding_fx( test(); test(); test(); - IF( sub(last_extl,WB_BWE) == 0 && - ( (sub(prev_coder_type,AUDIO) == 0 && sub(coder_type,AUDIO) != 0) || - (sub(prev_coder_type,AUDIO) != 0 && sub(coder_type,AUDIO) == 0)) && L_sub(total_brate,ACELP_8k00) <= 0 ) + IF( EQ_16(last_extl,WB_BWE)&& + ( (EQ_16(prev_coder_type,AUDIO) && NE_16(coder_type,AUDIO) ) || + (NE_16(prev_coder_type,AUDIO) && EQ_16(coder_type,AUDIO) )) && LE_32(total_brate,ACELP_8k00) ) { - IF( sub(WB_fenv[0],prev_WB_fenv[0]) > 0 ) + IF( GT_16(WB_fenv[0],prev_WB_fenv[0])) { /*wfenv[0]= add(mult_r(9830, WB_fenv[0]), mult_r(22938, prev_WB_fenv[0]));//Q3 */ wfenv[0]= round_fx(L_mac(L_mult(9830, WB_fenv[0]), 22938, prev_WB_fenv[0]));/*Q3 */ @@ -972,16 +970,16 @@ void WB_BWE_decoding_fx( wfenv[1]= round_fx(L_mac(L_mult(13108,WB_fenv[1]),13108,prev_WB_fenv[1]));/*Q3 */ } } - ELSE IF ( sub(last_extl,WB_BWE) == 0 && L_sub(L_tmp1,L_tmp2)<0 && sub(WB_fenv[0],prev_WB_fenv[0]) > 0&& - sub(coder_type,AUDIO) != 0 && sub(coder_type,UNVOICED) != 0 && L_sub(total_brate,ACELP_8k00) <= 0) + ELSE IF ( EQ_16(last_extl,WB_BWE)&<_32(L_tmp1,L_tmp2)&>_16(WB_fenv[0],prev_WB_fenv[0])&& + NE_16(coder_type,AUDIO) && NE_16(coder_type,UNVOICED) && LE_32(total_brate,ACELP_8k00)) { /*wfenv[0]= add(mult_r(9830,WB_fenv[0]),mult_r(22938,prev_WB_fenv[0]));//Q3 */ wfenv[0]= round_fx(L_mac(L_mult(9830,WB_fenv[0]),22938,prev_WB_fenv[0]));/*Q3 */ /*wfenv[1]= add(mult_r(9830,WB_fenv[1]),mult_r(22938,prev_WB_fenv[1]));//Q3 */ wfenv[1]= round_fx(L_mac(L_mult(9830,WB_fenv[1]),22938,prev_WB_fenv[1]));/*Q3 */ } - ELSE IF ( sub(last_extl,WB_BWE) == 0 && L_sub(EnergyL,prev_ener_alpha) >0 && L_sub(prev_ener_beta,EnergyL) >0 && - sub(prev_coder_type,UNVOICED) != 0 ) + ELSE IF ( EQ_16(last_extl,WB_BWE)&>_32(EnergyL,prev_ener_alpha)&>_32(prev_ener_beta,EnergyL)&& + NE_16(prev_coder_type,UNVOICED) ) { /*wfenv[0] = add(shr(WB_fenv[0],1), shr(prev_WB_fenv[0],1));//Q3 */ wfenv[0] = round_fx(L_mac(L_mult(WB_fenv[0],16384), prev_WB_fenv[0],16384));/*Q3 */ @@ -1018,7 +1016,7 @@ void WB_BWE_decoding_fx( test(); test(); - IF(sub(last_extl,WB_BWE) == 0 && L_sub(EnergyL,L_shr(*prev_Energy,1)) > 0 && L_sub(*prev_Energy,L_shr(EnergyL,1))>0) + IF(EQ_16(last_extl,WB_BWE)&>_32(EnergyL,L_shr(*prev_Energy,1))&>_32(*prev_Energy,L_shr(EnergyL,1))) { L_tmp1 = L_mac(L_mult(8192,wfenv[0]),12288, prev_WB_fenv[0]); wfenv[0] = round_fx(L_mac(L_tmp1, 12288, prev_WB_fenv[1])); @@ -1049,7 +1047,7 @@ void WB_BWE_decoding_fx( move32(); } - IF( sub(core_type,1) == 0 ) + IF( EQ_16(core_type,1)) { pit1 = &WB_signal_32[280]; FOR(n_freq=0; n_freq<40; n_freq++) @@ -1172,7 +1170,7 @@ void SWB_BWE_decoding_fx( fenvL_16 = round_fx(L_shl(L_tmp, sub(exp, 12))); /* Q3 */ } - IF(sub(fenvL_16, shl(SWB_fenv[0], 5)) > 0) + IF(GT_16(fenvL_16, shl(SWB_fenv[0], 5))) { fenvL_16 = shl(SWB_fenv[0], 2); move16(); @@ -1195,7 +1193,7 @@ void SWB_BWE_decoding_fx( calc_normal_length_fx( ACELP_CORE, core_dec_freq, mode, extl, &L_swb_norm, prev_L_swb_norm ,Q_syn); set16_fx( SWB_signal, 0, L_FRAME32k ); - IF( sub(mode,TRANSIENT) == 0 ) + IF( EQ_16(mode,TRANSIENT)) { Energy = L_deposit_l(0); FOR(n_band = 0; n_band < SWB_FENV_TRANS; n_band++) @@ -1307,9 +1305,9 @@ void SWB_BWE_decoding_fx( L_tmp = Mult_32_16(L_energy,tmp); /*Q(1+29-exp+1)->Q(15-exp) */ Energy_16 = round_fx(L_shl(L_tmp,add(exp,4))); /*Q3 */ - IF(sub(last_extl, SWB_BWE) != 0 && sub(last_extl, FB_BWE) != 0) + IF(NE_16(last_extl, SWB_BWE)&&NE_16(last_extl,FB_BWE)) { - IF(Energy_16 < shr(EnergyL_16, 4) && sub(extl, FB_BWE) == 0) + IF(Energy_16 < shr(EnergyL_16, 4) && EQ_16(extl, FB_BWE)) { FOR(n_band=0; n_band 0 || (sub(tilt_nb,14336) > 0 && sub(Energy_16,shr(EnergyL_16,1)) > 0) || - sub(tilt_nb,24576) > 0) && sub(Energy_16,600) > 0 && sub(fenvL_16,200) > 0)) + IF( EQ_16(mode, NOISE)||((GT_16(Energy_16,EnergyL_16)||(GT_16(tilt_nb,14336)&>_16(Energy_16,shr(EnergyL_16,1)))|| + GT_16(tilt_nb,24576)) && GT_16(Energy_16,600) && GT_16(fenvL_16,200) )) { tmp = add(swb_bwe_subband_fx[SWB_FENV], st_offset); FOR (n_freq=add(swb_bwe_subband_fx[0],st_offset); n_freq 0) + IF(GT_16(mult_r(SWB_fenv[n_band],29491), SWB_fenv[n_band+1])) { tmp = extract_l(L_mac0(26214, n_band, 492)); /*Q15; 0.015 in Q15 = 492 */ SWB_fenv[n_band+1] = mult_r(SWB_fenv[n_band+1], tmp); move16();/*Q1 */ } - IF(sub(mult_r(SWB_fenv[n_band+1],29491),SWB_fenv[n_band]) > 0) + IF(GT_16(mult_r(SWB_fenv[n_band+1],29491),SWB_fenv[n_band])) { tmp = extract_l(L_mac0(26214, n_band,492)); /*Q15; 0.015 in Q15 = 492 */ SWB_fenv[n_band] = mult_r(SWB_fenv[n_band],tmp); @@ -1380,11 +1378,11 @@ void SWB_BWE_decoding_fx( move16(); test(); - IF((tmp2 == 0) || (sub(tmp2, mult_r(tmp1, 9830)) < 0)) + IF((tmp2 == 0) || (LT_16(tmp2, mult_r(tmp1, 9830)))) { tmp3 = 9830; move16();/*0.3 in Q15 */ - WHILE(sub(tmp3,32767) < 0) + WHILE(LT_16(tmp3,32767)) { *pit1 = mult_r(*pit1,tmp3); move16(); /*Q_syn */ @@ -1392,12 +1390,12 @@ void SWB_BWE_decoding_fx( tmp3 = add(tmp3,3277); /*Q15 */ } } - ELSE IF(sub(tmp2, tmp1) < 0) + ELSE IF(LT_16(tmp2, tmp1)) { exp = norm_s(tmp1); tmp = div_s(shl(1,sub(14,exp)),tmp1); /*Q(29-exp) */ tmp3 = round_fx(L_shl(L_mult(tmp2,tmp),add(exp,2))); /*Q15 */ - WHILE(sub(tmp3, 32767) < 0) + WHILE(LT_16(tmp3, 32767)) { *pit1 = mult_r(*pit1,tmp3); move16(); /*Q_syn */ @@ -1408,7 +1406,7 @@ void SWB_BWE_decoding_fx( pit1 = &SWB_signal[367+st_offset]; move16(); - IF(sub(mult_r(tmp1,6554),tmp2) > 0) + IF(GT_16(mult_r(tmp1,6554),tmp2)) { /*20480 = 5 in Q12 */ FOR(tmp3 = 20480; tmp3 > 4096; tmp3 -= 2048) @@ -1424,11 +1422,11 @@ void SWB_BWE_decoding_fx( move16(); test(); - IF((tmp2 == 0) || (sub(tmp2,mult_r(tmp1,9830)) < 0)) + IF((tmp2 == 0) || (LT_16(tmp2,mult_r(tmp1,9830)))) { tmp3 = 9830; move16(); /*0.3 in Q15 */ - WHILE(sub(tmp3,32767) < 0) + WHILE(LT_16(tmp3,32767)) { *pit1 = mult_r(*pit1,tmp3); move16(); /*Q_syn */ @@ -1436,12 +1434,12 @@ void SWB_BWE_decoding_fx( tmp3 = add(tmp3,3277); /*Q15 */ } } - ELSE IF(sub(tmp2,tmp1) < 0) + ELSE IF(LT_16(tmp2,tmp1)) { exp = norm_s(tmp1); tmp = div_s(shl(1,sub(14,exp)),tmp1); /*Q(29-exp) */ tmp3 = round_fx(L_shl(L_mult(tmp2,tmp),add(exp,2))); /*Q15 */ - WHILE(sub(tmp3,32767) < 0) + WHILE(LT_16(tmp3,32767)) { *pit1 = mult_r(*pit1,tmp3); move16();/*Q_syn */ @@ -1464,7 +1462,7 @@ void SWB_BWE_decoding_fx( } L_tmp1 = L_shl(1L,sub(30,exp)); - WHILE( L_sub(L_tmp3,L_tmp1) > 0 ) + WHILE( GT_32(L_tmp3,L_tmp1)) { L_tmp = Mult_32_16(L_tmp3,*pit1); /*Q(16-exp) */ *pit1-- = round_fx(L_shl(L_tmp,exp)); /*Q_syn */ @@ -1478,13 +1476,13 @@ void SWB_BWE_decoding_fx( /* Normalize with envelope */ test(); - IF( *frica_flag == 0 && sub(mode, NOISE) != 0 ) + IF( *frica_flag == 0 && NE_16(mode, NOISE)) { L = add(swb_bwe_subband_fx[0],st_offset); exp = norm_s(L_swb_norm); inv_L_swb_norm = shl(div_s(shl(1,sub(14,exp)),L_swb_norm),sub(exp,14)); /* Q15 */ - IF(sub(mode,HARMONIC) != 0) + IF(NE_16(mode,HARMONIC)) { tmp = add(shl(inv_L_swb_norm,1), inv_L_swb_norm) ; weight = s_max(s_min(tmp,16384), 6554); @@ -1521,7 +1519,7 @@ void SWB_BWE_decoding_fx( SWB_signal[n_freq] = extract_l(L_tmp); /* Q_syn */ } - IF(sub(signum[n_freq],1) != 0) + IF(NE_16(signum[n_freq],1)) { SWB_signal[n_freq] = negate(SWB_signal[n_freq]); move16(); @@ -1556,7 +1554,7 @@ void SWB_BWE_decoding_fx( *prev_weight = s_max(s_min(tmp,16384),6554); /* Q15 */ } - IF(sub(mode,HARMONIC) == 0) + IF(EQ_16(mode,HARMONIC)) { pit1 = &SWB_signal[swb_bwe_subband_fx[0]+st_offset]; move16(); @@ -1573,7 +1571,7 @@ void SWB_BWE_decoding_fx( move16(); FOR(n_freq=0; n_freq<16; n_freq++) { - if(sub(abs_s(*pit1),mean) < 0) + if(LT_16(abs_s(*pit1),mean)) { *pit1 = mult_r(*pit1,6554); /*Q15*/ move16(); } @@ -1584,7 +1582,7 @@ void SWB_BWE_decoding_fx( L = 1; move16(); - if(sub(mode,HARMONIC) == 0) + if(EQ_16(mode,HARMONIC)) { L = 2; move16(); @@ -1603,7 +1601,7 @@ void SWB_BWE_decoding_fx( IF(energy == 0) { tmp_ener = sqrt_swb_bwe_subband_fx_L1[n_band];/*Q12 */ move16(); - if(sub(L,1) != 0) + if(NE_16(L,1)) { tmp_ener = sqrt_swb_bwe_subband_fx_L2[shr(n_band, 1)];/*Q12 */ move16(); } @@ -1638,7 +1636,7 @@ void SWB_BWE_decoding_fx( } } - IF(sub(*prev_Energy,add(Energy_16,shr(Energy_16,2))) > 0 && Energy_16 > 0) + IF(GT_16(*prev_Energy,add(Energy_16,shr(Energy_16,2)))&&Energy_16>0) { weight = shr(div_s(Energy_16,*prev_Energy),1); /*Q15 */ } @@ -1652,7 +1650,7 @@ void SWB_BWE_decoding_fx( wfenv = round_fx(L_tmp); /*Q1 */ tmp = norm_s(wfenv); - IF ( sub(tmp,4) > 0 ) + IF ( GT_16(tmp,4)) { tmp = 12; move16(); @@ -1686,7 +1684,7 @@ void SWB_BWE_decoding_fx( move16(); /*Q1 */ factor1 = mult_r(sub(wfenv,SWB_fenv[n_band]), smooth_factor_fx[n_band]); /*Q1 */ tmp = norm_s(factor); - IF ( sub(tmp,4) > 0) + IF ( GT_16(tmp,4)) { tmp = 12; move16(); @@ -1820,7 +1818,7 @@ void time_envelop_shaping_fx( } test(); - IF(L_sub(SWB_tenv[i], 65536) < 0 && L_sub(Energy, L_shl(SWB_tenv[i], sub(16,exp))) < 0) + IF(LT_32(SWB_tenv[i], 65536)&<_32(Energy,L_shl(SWB_tenv[i],sub(16,exp)))) { *Q_synth = add(*Q_synth, 3); move16(); @@ -1925,7 +1923,7 @@ void time_reduce_pre_echo_fx( { L_tmp = Mult_32_16(energyL[i], 29491); /*Q14 */ test(); - IF(L_sub(L_shr(energyL[i+1], 1), L_tmp) > 0 && L_sub(energyL[i+1], 1638400) > 0) + IF(GT_32(L_shr(energyL[i+1], 1), L_tmp)&>_32(energyL[i+1],1638400)) { pos = add(i, 1); move16(); @@ -1935,7 +1933,7 @@ void time_reduce_pre_echo_fx( IF (pos > 0) { - if(sub(pos, 3) < 0) + if(LT_16(pos, 3)) { pos = add(pos, 1); } @@ -1966,7 +1964,7 @@ void time_reduce_pre_echo_fx( } tmp = mult_r(energy_16, 6554); /*Q0 */ - if(sub(prev_td_energy, tmp) < 0) + if(LT_16(prev_td_energy, tmp)) { prev_td_energy = tmp; move16(); @@ -2063,7 +2061,7 @@ void calc_normal_length_fx_32( move16(); test(); test(); - if( sub(core,HQ_CORE) == 0 || sub(extl,SWB_BWE) == 0 || sub(extl,FB_BWE) == 0 ) + if( EQ_16(core,HQ_CORE)||EQ_16(extl,SWB_BWE)||EQ_16(extl,FB_BWE)) { THRES = 8; move16(); @@ -2073,7 +2071,7 @@ void calc_normal_length_fx_32( move16(); test(); test(); - if( sub(core,HQ_CORE) == 0 && (sub(mode,HQ_HARMONIC) == 0 || sub(mode,HQ_HVQ) == 0) ) + if( EQ_16(core,HQ_CORE)&&(EQ_16(mode,HQ_HARMONIC)||EQ_16(mode,HQ_HVQ))) { N = 13; move16(); @@ -2093,7 +2091,7 @@ void calc_normal_length_fx_32( FOR (n_freq = 0; n_freq < 16; n_freq ++) { mag = L_abs(*pit); - if (L_sub(mag , peak) > 0) + if (GT_32(mag , peak)) { peak = mag; move16(); @@ -2105,13 +2103,13 @@ void calc_normal_length_fx_32( L_tmp1 = Mult_32_16(peak, shl(15+THRES, 10)); L_tmp2 = Mult_32_16(mean, shl(THRES, 10)); test(); - if (L_sub(L_tmp1,L_tmp2) > 0 && L_sub(peak,40960) > 0) + if (GT_32(L_tmp1,L_tmp2)&>_32(peak,40960)) { n_band = add(n_band, 1); } } - IF( sub(core,ACELP_CORE) == 0 ) + IF( EQ_16(core,ACELP_CORE)) { L_swb_norm_trans = add(4, shr(n_band, 2)); L_swb_norm_norm = add(8, shr(n_band, 1)); @@ -2252,7 +2250,7 @@ void hq_generic_decoding_fx( Word16 signum[L_FRAME16k]; nenv = sub(SWB_FENV,2); - if ( sub(hq_generic_offset, HQ_GENERIC_FOFFSET_24K4) <= 0 ) + if ( LE_16(hq_generic_offset, HQ_GENERIC_FOFFSET_24K4)) { nenv = SWB_FENV; move16(); @@ -2260,7 +2258,7 @@ void hq_generic_decoding_fx( tenv = nenv; move16(); - if ( sub(HQ_mode, HQ_GEN_FB) == 0 ) + if ( EQ_16(HQ_mode, HQ_GEN_FB)) { tenv = add(nenv , DIM_FB); } @@ -2303,12 +2301,12 @@ void hq_generic_decoding_fx( blen = 16; move16(); - IF ( sub(hq_generic_exc_clas, HQ_GENERIC_EXC0) == 0 ) + IF ( EQ_16(hq_generic_exc_clas, HQ_GENERIC_EXC0)) { rn_weight0_fx = 819; move16();/* 0.8 Q10 */ } - ELSE IF ( sub(hq_generic_exc_clas, HQ_GENERIC_EXC1) == 0 ) + ELSE IF ( EQ_16(hq_generic_exc_clas, HQ_GENERIC_EXC1)) { rn_weight0_fx = 51; move16();/* 0.05 Q10*/ @@ -2320,7 +2318,7 @@ void hq_generic_decoding_fx( } tmp = sub(efidx,sfidx); - IF( sub(tmp,0) == 0 ) + IF( EQ_16(tmp,0)) { nband_lf = 0; } @@ -2408,7 +2406,7 @@ void hq_generic_decoding_fx( } } - IF ( sub(hq_generic_exc_clas, HQ_GENERIC_EXC0) == 0 ) + IF ( EQ_16(hq_generic_exc_clas, HQ_GENERIC_EXC0)) { bwe_seed = add(add(shl(R[0],3),shl(R[1],2)),add(shl(R[2],1),R[3])); @@ -2479,7 +2477,7 @@ void hq_generic_decoding_fx( tmp = add(i_mult2(add(k,1),blen),sfidx); FOR ( i = add((i_mult2(k,blen)),sfidx); i < tmp; ++i ) { - IF ( L_sub( L_abs( coeff_out1_fx[i] ), coeff_out1_fx[i] ) != 0 ) + IF ( NE_32( L_abs( coeff_out1_fx[i] ), coeff_out1_fx[i] )) { s = -1; move16(); @@ -2511,14 +2509,14 @@ void hq_generic_decoding_fx( Copy32(&coeff_out1_fx[HQ_GENERIC_OFFSET], &coeff_out_fx[add(HQ_GENERIC_HIGH0,hq_generic_offset)], HQ_GENERIC_LEN0); Copy32(&coeff_out1_fx[HQ_GENERIC_OFFSET], &coeff_out_fx[add(HQ_GENERIC_HIGH1,hq_generic_offset)], HQ_GENERIC_LEN0); - IF ( sub(hq_generic_offset , HQ_GENERIC_FOFFSET_24K4) <= 0) + IF ( LE_16(hq_generic_offset , HQ_GENERIC_FOFFSET_24K4)) { Copy32( &coeff_out1_fx[HQ_GENERIC_LOW0], &coeff_out_fx[add(HQ_GENERIC_HIGH2,hq_generic_offset)], sub(HQ_GENERIC_END_FREQ , HQ_GENERIC_HIGH2) ); } - IF ( sub(HQ_mode , HQ_GEN_FB) == 0 ) + IF ( EQ_16(HQ_mode , HQ_GEN_FB)) { - IF ( sub(hq_generic_offset, HQ_GENERIC_FOFFSET_24K4) <= 0 ) + IF ( LE_16(hq_generic_offset, HQ_GENERIC_FOFFSET_24K4)) { Copy32(&coeff_out1_fx[sub(add(HQ_GENERIC_LOW0 , HQ_GENERIC_END_FREQ),HQ_GENERIC_HIGH2)], &coeff_out_fx[fb_bwe_subband[0]], 160); } @@ -2547,7 +2545,7 @@ void hq_generic_decoding_fx( tmp3_fx = div_s(tmp2_fx, tmp1_fx);/*15 + exp2 + 15 - (exp1 + 15) */ tmp3_fx = shr(tmp3_fx, add(5, sub(exp2, exp1)));/*10 */ - if (sub(tmp3_fx , 307) < 0) + if (LT_16(tmp3_fx , 307)) { tmp3_fx = 307; move16(); @@ -2568,7 +2566,7 @@ void hq_generic_decoding_fx( tmp3_fx = div_s(tmp1_fx, tmp2_fx);/*15 + exp2 + 15 - (exp1 + 15) */ tmp3_fx = shr(tmp3_fx, add(5, sub(exp1, exp2)));/*10 */ - IF (sub(tmp3_fx , 5120)>0) + IF (GT_16(tmp3_fx , 5120)) { FOR ( tmp3_fx = 5120; tmp3_fx > 1024; tmp3_fx -= 512) { @@ -2578,7 +2576,7 @@ void hq_generic_decoding_fx( } } - IF ( sub(hq_generic_offset , HQ_GENERIC_FOFFSET_24K4) <= 0 ) + IF ( LE_16(hq_generic_offset , HQ_GENERIC_FOFFSET_24K4)) { L_tmp1 = L_add(L_abs(coeff_out_fx[add(HQ_GENERIC_HIGH2 , hq_generic_offset)]), L_abs(coeff_out_fx[add(add(HQ_GENERIC_HIGH2,1),hq_generic_offset)])); L_tmp2 = L_add(L_abs(coeff_out_fx[add(sub(HQ_GENERIC_HIGH2,4),hq_generic_offset)]), L_add(L_abs(coeff_out_fx[add(sub(HQ_GENERIC_HIGH2,3),hq_generic_offset)]), @@ -2595,7 +2593,7 @@ void hq_generic_decoding_fx( tmp3_fx = div_s(tmp2_fx, tmp1_fx);/*15 + exp2 + 15 - (exp1 + 15) */ tmp3_fx = shr(tmp3_fx, add(5, sub(exp2, exp1)));/*10 */ - if (sub(tmp3_fx, 307) < 0) + if (LT_16(tmp3_fx, 307)) { tmp3_fx = 307; move16(); @@ -2687,7 +2685,7 @@ void hq_generic_decoding_fx( n_freq++; } - IF ( sub(HQ_mode , HQ_GEN_SWB) == 0 ) + IF ( EQ_16(HQ_mode , HQ_GEN_SWB)) { FOR(n_band=sub(nenv,1); n_band 0 ) + IF( GT_16(tilt_wb_fx, 10240)) { FOR( i=0; i 0 ) + if( EQ_16(max_bwe_fx, min_bwe_fx)&>_16(min_bwe_fx,shl(1,Q_audio))) { min_bwe_fx = mult_r(min_bwe_fx, 16384); } @@ -120,14 +118,14 @@ void swb_hr_noise_fill_fx( Nsv = shr(sub(spect_end, spect_start), 3); alpha_fx = 8192; move16();/*Q15 */ - IF( sub(tilt_wb_fx, 10240) > 0 ) + IF( GT_16(tilt_wb_fx, 10240)) { beta_fx = 8192; move16();/*Q15 */ } ELSE { - IF( sub(6400, pitch_fx) > 0 ) + IF( GT_16(6400, pitch_fx)) { beta_fx = 8192; move16();/*Q15 */ @@ -145,7 +143,7 @@ void swb_hr_noise_fill_fx( i = 1; move16(); test(); - WHILE( sub(i, Nsv) < 0 && nq[i] == 0 ) + WHILE( LT_16(i, Nsv)&&nq[i]==0) { i++; move16(); @@ -155,7 +153,7 @@ void swb_hr_noise_fill_fx( pos_start = i; move16(); test(); - WHILE( sub(i, Nsv) < 0 && nq[i] != 0 ) + WHILE( LT_16(i, Nsv)&&nq[i]!=0) { i++; move16(); @@ -165,7 +163,7 @@ void swb_hr_noise_fill_fx( pos_end = sub(i, 1); move16(); - IF( sub(pos_end, shl(pos_start, 1)) > 0 ) + IF( GT_16(pos_end, shl(pos_start, 1))) { pos_end = sub(shl(pos_start, 1), 1); move16(); @@ -187,7 +185,7 @@ void swb_hr_noise_fill_fx( } /*incr = sub(incr, pos_start) < 0 ? pos_end : sub(incr, 1); move16(); */ - IF(sub(incr, pos_start) < 0) + IF(LT_16(incr, pos_start)) { incr = pos_end; move16(); @@ -199,7 +197,7 @@ void swb_hr_noise_fill_fx( } } - WHILE( sub(i, Nsv) < 0 ) + WHILE( LT_16(i, Nsv)) { IF( nq[i] == 0 ) { @@ -220,7 +218,7 @@ void swb_hr_noise_fill_fx( } } - IF( sub(pos_start, pos_end) == 0 ) + IF( EQ_16(pos_start, pos_end)) { i = Nsv; move16(); diff --git a/lib_com/swb_bwe_com_lr_fx.c b/lib_com/swb_bwe_com_lr_fx.c index b16357f534239c943df7ad75cc1f27b2c11d163f..74f3023a4e5cfaab301165872e1362e99ce82dc5 100644 --- a/lib_com/swb_bwe_com_lr_fx.c +++ b/lib_com/swb_bwe_com_lr_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -8,9 +8,7 @@ #include "prot_fx.h" #include "rom_com_fx.h" -#include "stl.h" -#include "wmc_auto.h" - /* required for wmc_tool */ +#include "stl.h" /* required for wmc_tool */ #include "basop_mpy.h" #include @@ -74,11 +72,11 @@ void est_freq_har_decis_fx( test(); test(); - IF( sub(k1, 1) > 0 ) + IF( GT_16(k1, 1)) { *har_freq_est2 = div_s_ss(sharp1, k1); } - ELSE IF( sub(k1, 2) < 0 && ( k2 != 0 || sub(k, 1) > 0) ) + ELSE IF( LT_16(k1, 2)&&(k2!=0||GT_16(k,1))) { *har_freq_est2 = *har_freq_est1; move16(); @@ -106,12 +104,12 @@ void est_freq_har_decis_fx( test(); har_freq_est2_2 = shl(*har_freq_est2, 1); prev_frm_hfe2_2 = shl(*prev_frm_hfe2, 1); - IF( *prev_frm_hfe2 != 0 && ( sub(abs_s(sub(*prev_frm_hfe2, *har_freq_est2)), 10) < 0 || sub(abs_s(sub(*prev_frm_hfe2, har_freq_est2_2)),10) < 0 ) ) + IF( *prev_frm_hfe2 != 0 && ( LT_16(abs_s(sub(*prev_frm_hfe2, *har_freq_est2)), 10)||LT_16(abs_s(sub(*prev_frm_hfe2,har_freq_est2_2)),10))) { *har_freq_est2 = *prev_frm_hfe2; move16(); } - ELSE IF(*prev_frm_hfe2 != 0 && sub(abs_s(sub(*har_freq_est2, prev_frm_hfe2_2)), 10) < 0) + ELSE IF(*prev_frm_hfe2 != 0 && LT_16(abs_s(sub(*har_freq_est2, prev_frm_hfe2_2)), 10)) { *har_freq_est2 = prev_frm_hfe2_2; move16(); @@ -121,7 +119,7 @@ void est_freq_har_decis_fx( temp_hfe2 = shr(add(*prev_frm_hfe2, *har_freq_est2), 1); move16(); - IF( sub(abs_s(sub(temp_hfe2, *prev_frm_hfe2)), 2) < 0 ) + IF( LT_16(abs_s(sub(temp_hfe2, *prev_frm_hfe2)), 2)) { temp_hfe2 =*prev_frm_hfe2; move16(); @@ -132,7 +130,7 @@ void est_freq_har_decis_fx( test(); test(); - if( sub(*har_freq_est2, *har_freq_est1) < 0 && ( sub(k, 1) > 0 && sub(k1, 2) < 0 ) ) + if( LT_16(*har_freq_est2, *har_freq_est1)&&(GT_16(k,1)&<_16(k1,2))) { *har_freq_est2 = *har_freq_est1; move16(); @@ -224,7 +222,7 @@ Word16 har_est_fx( /*if( N/(LR_BLK_LEN) - blk_end > 0.0f) */ blk_end_LEN = i_mult(blk_end, LR_BLK_LEN); - if( sub(N, blk_end_LEN) > 0 ) + if( GT_16(N, blk_end_LEN)) { blk_end = add(blk_end, 1); } @@ -248,7 +246,7 @@ Word16 har_est_fx( FOR(j = 0; j < LR_BLK_LEN; j ++) { - IF ( L_sub(L_input_abs[q], L_peak) > 0x0L ) + IF ( GT_32(L_input_abs[q], L_peak)) { L_peak = L_input_abs[q]; move32(); @@ -259,7 +257,7 @@ Word16 har_est_fx( test(); test(); test(); - IF( sub(i, blk_st) > 0 && L_input_abs[q] != 0x0L && L_sub(L_input_abs[q], L_peak) == 0 && sub(sub(peak_pos, blk_peak_pos[i-1]), LR_HLF_PK_BLK_LEN) < 0 ) + IF( GT_16(i, blk_st)&&L_input_abs[q]!=0x0L&&EQ_32(L_input_abs[q],L_peak)&<_16(sub(peak_pos,blk_peak_pos[i-1]),LR_HLF_PK_BLK_LEN)) { L_peak = L_input_abs[q]; move32(); @@ -281,15 +279,15 @@ Word16 har_est_fx( pm1_blk_peak_pos = &blk_peak_pos[sub(blk_st, 1)]; FOR(i = blk_st; i < blk_end; i++) { - IF( sub(i, blk_st) > 0 ) + IF( GT_16(i, blk_st)) { test(); IF( *p_blk_peak_pos != 0 && *pm1_blk_peak_pos != 0 ) { - IF( sub(sub(*p_blk_peak_pos, *pm1_blk_peak_pos), LR_LOWBAND_DIF_PK_LEN) < 0 ) + IF( LT_16(sub(*p_blk_peak_pos, *pm1_blk_peak_pos), LR_LOWBAND_DIF_PK_LEN)) { - IF( L_sub(*p_L_blk_peak, *pm1_L_blk_peak) > 0 ) + IF( GT_32(*p_L_blk_peak, *pm1_L_blk_peak)) { *pm1_L_blk_peak = L_deposit_l(0); *pm1_blk_peak_pos = 0; @@ -330,11 +328,11 @@ Word16 har_est_fx( { blk_peak_pos_te[j] = blk_peak_pos[i]; move16(); - IF( sub(blk_peak_pos[i], r2) < 0 ) + IF( LT_16(blk_peak_pos[i], r2)) { hfe_est_countk = add(hfe_est_countk, 1); } - ELSE IF( sub(blk_peak_pos[i], r3) < 0 ) + ELSE IF( LT_16(blk_peak_pos[i], r3)) { hfe_est_countk1 = add(hfe_est_countk1, 1); } @@ -365,13 +363,13 @@ Word16 har_est_fx( FOR(i = 1; i < j; i++) { *pm1_diff_peak_pos = sub(blk_peak_pos_te[i], blk_peak_pos_te[sub(i,1)]); - if( sub(*pm1_diff_peak_pos, min_har_pos) <= 0 ) + if( LE_16(*pm1_diff_peak_pos, min_har_pos)) { min_har_pos = *pm1_diff_peak_pos; move16(); } - IF( L_sub(L_blk_peak_te[sub(i,1)], L_blk_peak_max) > 0x0L ) + IF( GT_32(L_blk_peak_te[sub(i,1)], L_blk_peak_max)) { L_blk_peak_max = L_blk_peak_te[sub(i,1)]; move32(); @@ -392,14 +390,14 @@ Word16 har_est_fx( test(); test(); test(); - IF((sub(hfe_est_countk, 2) < 0 && sub(hfe_est_countk1, 2) < 0 && sub(hfe_est_countk2, 2) <0 ) || sub(min_har_pos, SWB_HAR_RAN1) >= 0 ) + IF((LT_16(hfe_est_countk, 2)&<_16(hfe_est_countk1,2)&<_16(hfe_est_countk2,2))||GE_16(min_har_pos,SWB_HAR_RAN1)) { *flag_dis = 0; move16(); test(); test(); test(); - if( (sub(hfe_est_countk, 1) == 0 && sub(hfe_est_countk1, 1) == 0) && (sub(hfe_est_countk2, 1) == 0 || hfe_est_countk2 == 0) ) + if( (EQ_16(hfe_est_countk, 1)&&EQ_16(hfe_est_countk1,1))&&(EQ_16(hfe_est_countk2,1)||hfe_est_countk2==0)) { *flag_dis = 1; move16(); @@ -408,7 +406,7 @@ Word16 har_est_fx( thr1 = add(blk_peak_pos_max_diff, LR_LOWBAND_DIF_PK_LEN); FOR(i=0; i 0) + IF( LE_16(diff_peak_pos[i], thr1)&&diff_peak_pos[i]>0) { sharp = add(sharp, diff_peak_pos[i]); k = add(k, 1); } - ELSE IF( sub(diff_peak_pos[i], thr2) <= 0 && diff_peak_pos[i] > 0) + ELSE IF( LE_16(diff_peak_pos[i], thr2)&&diff_peak_pos[i]>0) { sharp1 = add(sharp1, diff_peak_pos[i]); k1 = add(k1, 1); @@ -485,7 +483,7 @@ Word16 har_est_fx( IF( rem_hfe2 == 0 ) { test(); - IF( sub(diff_posmax_hfe2, 9) < 0 || *har_freq_est2 == 0 ) + IF( LT_16(diff_posmax_hfe2, 9)||*har_freq_est2==0) { blk_peak_pos_max = *prev_stab_hfe2; move16(); @@ -495,7 +493,7 @@ Word16 har_est_fx( q_diffpos_hfe2 = div_s_ss(diff_posmax_hfe2, *har_freq_est2); q_diffpos_prevhfe2 = div_s_ss(diff_posmax_hfe2, *prev_frm_hfe2); test(); - IF( sub(q_diffpos_hfe2, 10) < 0 || sub(q_diffpos_prevhfe2, 10) < 0) + IF( LT_16(q_diffpos_hfe2, 10)||LT_16(q_diffpos_prevhfe2,10)) { blk_peak_pos_max = *prev_stab_hfe2; move16(); @@ -543,9 +541,9 @@ Word16 har_est_fx( FOR(i = 0; i < j; i++) { test(); - IF( sub(blk_peak_pos_te[i], sub(subband_search_offset[0], nlags_half)) >= 0 + IF( GE_16(blk_peak_pos_te[i], sub(subband_search_offset[0], nlags_half)) && - sub(blk_peak_pos_te[i], add(add(subband_search_offset[0], sbWidth[0]), nlags_half)) < 0) + LT_16(blk_peak_pos_te[i], add(add(subband_search_offset[0], sbWidth[0]), nlags_half))) { blk_peak_pos_hfsb2[ct_hfsb2] = blk_peak_pos_te[i]; move16(); @@ -554,7 +552,7 @@ Word16 har_est_fx( } } - IF( sub(ct_hfsb2, 1) > 0 ) + IF( GT_16(ct_hfsb2, 1)) { sum_diff = 0; move16(); @@ -631,7 +629,7 @@ void genhf_noise_fx( l = 0; move16(); - WHILE( sub(st_last_peakpos, add(fLenLow,subband_offsets[k])) < 0) + WHILE( LT_16(st_last_peakpos, add(fLenLow,subband_offsets[k]))) { st_last_peakpos = add(st_last_peakpos, har_freq_est2); } @@ -665,7 +663,7 @@ void genhf_noise_fx( /*Copy the LF Smoothed Noise floor to the HF*/ FOR(j=st_pos; j>(dst_pos); j--) { - IF (sub(ii, add(sbWidth[k],sbWidth[k-1])) >= 0) + IF (GE_16(ii, add(sbWidth[k],sbWidth[k-1]))) { BREAK; } @@ -688,7 +686,7 @@ void genhf_noise_fx( FOR(j = 0; j< l; j++) { st_last_peakpos = add(st_last_peakpos, har_freq_est2); - IF( sub(st_last_peakpos, hfband_end[k]) < 0 ) + IF( LT_16(st_last_peakpos, hfband_end[k])) { pk_sf_fx[k*8+pos].nmrValue_fx = hf_pulse_peaks_fx[j]; move16(); /* Qss */ @@ -725,11 +723,11 @@ void genhf_noise_fx( } pos = 0; move16(); - WHILE( sub(st_last_peakpos, hfband_end[k-1]) < 0 ) + WHILE( LT_16(st_last_peakpos, hfband_end[k-1])) { st_last_peakpos = add(st_last_peakpos, har_freq_est2); } - WHILE( sub(st_last_peakpos, hfband_end[k]) < 0 && sub(pul_res[k], pul_res[2-l]) < 0 && sub(l, 2) <= 0 ) + WHILE( LT_16(st_last_peakpos, hfband_end[k])&<_16(pul_res[k],pul_res[2-l])&&LE_16(l,2)) { test(); test(); @@ -846,7 +844,7 @@ void SmoothSpec_fx( /* 1.0f -> 0x7fff Q15 */ inItems = 0x7fff; move16(); - if(sub(nItems, 3) == 0) + if(EQ_16(nItems, 3)) { /* 1/3 = 0.333f -> 0x2AAA Q15 */ inItems = 0x2AAA; @@ -905,7 +903,7 @@ void SpectrumSmoothing_fx( num_subband_smooth_pre_fx = mult(fLen, 21845); /* 1/L_SB = 1/12 = 21845(Q18) Q = exp_normn-18 */ num_subband_smooth_fx = shr(num_subband_smooth_pre_fx, 18-15); - IF( sub(num_subband_smooth_pre_fx, shl(num_subband_smooth_fx, 18-15)) != 0 ) + IF( NE_16(num_subband_smooth_pre_fx, shl(num_subband_smooth_fx, 18-15))) { num_subband_smooth_fx++; } @@ -932,7 +930,7 @@ void SpectrumSmoothing_fx( FOR( k=0; k 0) + IF(GT_32(L_max_val[i], 0x1L)) { exp_normd = norm_l(L_max_val[i]); max_val_norm_fx = div_s(0x2800, round_fx(L_shl(L_max_val[i], exp_normd))); /* Q10-(Qs+exp_normd-16) */ @@ -972,7 +970,7 @@ void SpectrumSmoothing_fx( outBuf_pss_fx[j] = 0; move16(); } - ELSE IF ( L_sub(L_abs(L_inBuf_pss[j]), L_max_val[i] ) < 0x0L ) + ELSE IF ( LT_32(L_abs(L_inBuf_pss[j]), L_max_val[i] )) { IF( L_inBuf_pss[j] >= 0 ) { @@ -1027,7 +1025,7 @@ void SpectrumSmoothing_fx( IF( cnt_zero_cont != 0 ) { test(); - IF( sub(j, div_s_ss(subband_search_offsets_fx[0], L_SB)) > 0 && reset_flag == 0 ) + IF( GT_16(j, div_s_ss(subband_search_offsets_fx[0], L_SB))&&reset_flag==0) { n = 0; move16(); @@ -1040,14 +1038,14 @@ void SpectrumSmoothing_fx( } test(); - if( sub(reset_flag, 1) == 0 && sub(n, 1) == 0 ) + if( EQ_16(reset_flag, 1)&&EQ_16(n,1)) { m = 0; move16(); } pk = sub(k, L_SB); - IF( sub(cnt_zero_cont, mult_r(L_SB, 24576)) > 0 ) /* cnt_zero_cont > 3*L_SB/4 */ + IF( GT_16(cnt_zero_cont, mult_r(L_SB, 24576))) /* cnt_zero_cont > 3*L_SB/4 */ { pp = round_fx(L_shl(L_mult(n_list[m], L_SB), 15)); FOR( i=0; i 0 ) + if( GT_16(abs_s(outBuf_pss_fx[i]), th_cut_fx)) { outBuf_fx[i] = outBuf_pss_fx[i]; move16(); @@ -1142,7 +1140,7 @@ void convert_lagIndices_pls2smp_fx( i = 0; move16(); - WHILE( sub(cnt, lagIndices_in_fx[sb]) <= 0 ) + WHILE( LE_16(cnt, lagIndices_in_fx[sb])) { if( sspectra_fx[subband_search_offsets_fx[sb]+i] != 0 ) { @@ -1151,7 +1149,7 @@ void convert_lagIndices_pls2smp_fx( i = add(i, 1); - IF( sub(add(subband_search_offsets_fx[sb], add(i, sbWidth_fx[sb])) , fLenLow_fx) >= 0) + IF( GE_16(add(subband_search_offsets_fx[sb], add(i, sbWidth_fx[sb])) , fLenLow_fx)) { BREAK; } @@ -1180,14 +1178,14 @@ Word16 get_usebit_npswb_fx( bits = 0; move16(); - IF( sub(hqswb_clas_fx, HQ_NORMAL) == 0 ) + IF( EQ_16(hqswb_clas_fx, HQ_NORMAL)) { up_lmt = NB_SWB_SUBBANDS; move16(); bits_req = bits_lagIndices_modeNormal_fx; move16(); } - ELSE IF ( sub(hqswb_clas_fx, HQ_HARMONIC) == 0 ) + ELSE IF ( EQ_16(hqswb_clas_fx, HQ_HARMONIC)) { up_lmt = NB_SWB_SUBBANDS_HAR_SEARCH_SB; move16(); @@ -1322,7 +1320,7 @@ void SpectrumSmoothing_nss_fx( FOR( i = 0; i < fLen; i++ ) { r0_fx = abs_s(inBufw_fx[i]); - if( sub(max_peak_fx, r0_fx) < 0 ) + if( LT_16(max_peak_fx, r0_fx)) { max_peak_fx = r0_fx; move16(); /* Qm */ @@ -1468,7 +1466,7 @@ void SpectrumSmoothing_nss_fx( FOR(i = 0; i < fLen; i++) { - IF( sub(abs_s(outBufw_fx[i]), thre_fx) > 0 ) + IF( GT_16(abs_s(outBufw_fx[i]), thre_fx)) { temp_fx = thre_fx; move16(); @@ -1481,7 +1479,7 @@ void SpectrumSmoothing_nss_fx( move16(); } - if( sub(abs_s(outBufw_fx[i]), thre_min_fx) < 0 ) + if( LT_16(abs_s(outBufw_fx[i]), thre_min_fx)) { outBufw_fx[i] = 0; move16(); @@ -1516,7 +1514,7 @@ void return_bits_normal2_fx( p_p2a_flags_fx = &p2a_flags_fx[sub(bands_fx, NB_SWB_SUBBANDS)]; FOR( i=0 ; i < NB_SWB_SUBBANDS; i++ ) { - if( sub(*p_p2a_flags_fx++, 1) == 0 ) + if( EQ_16(*p_p2a_flags_fx++, 1)) { *bit_budget_fx = add(*bit_budget_fx, bits_lagIndices_fx[i]); move16(); @@ -1545,7 +1543,7 @@ void preset_hq2_swb_fx Word32 L_m[] /* o : MDCT */ ) { - IF( sub(hqswb_clas_fx, HQ_HARMONIC) == 0 ) + IF( EQ_16(hqswb_clas_fx, HQ_HARMONIC)) { *har_bands_fx = add(sub(bands_fx, p2a_bands_fx), 1); move16(); @@ -1592,7 +1590,7 @@ void post_hq2_swb_fx /* copy the scratch buffer to the output */ Copy32( &L_m[lowlength_fx], &L_y2[lowlength_fx], highlength_fx ); - IF( sub(hqswb_clas_fx, HQ_HARMONIC) == 0 ) + IF( EQ_16(hqswb_clas_fx, HQ_HARMONIC)) { k = har_bands_fx; move16(); @@ -1658,7 +1656,7 @@ void GetSynthesizedSpecThinOut_fx( fLen_fx = sbWidth_fx[sb]; lag_fx = lagIndices_fx[sb]; - if( sub(add(lag_fx , fLen_fx) ,predBufLen_fx) > 0 ) + if( GT_16(add(lag_fx , fLen_fx) ,predBufLen_fx)) { /* should never happen */ lag_fx = sub(predBufLen_fx, fLen_fx); @@ -1740,7 +1738,7 @@ void hf_parinitiz_fx( *swb_highband_fx = highlength_fx; move16(); - IF( sub(hqswb_clas_fx, HQ_HARMONIC) == 0 ) + IF( EQ_16(hqswb_clas_fx, HQ_HARMONIC)) { /* Mode dependent initializations (performed every frame in case mode-switching implemented) */ *nBands_fx = NB_SWB_SUBBANDS_HAR; @@ -1748,7 +1746,7 @@ void hf_parinitiz_fx( *nBands_search_fx = NB_SWB_SUBBANDS_HAR_SEARCH_SB; move16(); - IF ( L_sub(L_total_brate, HQ_13k20) == 0 ) + IF ( EQ_32(L_total_brate, HQ_13k20)) { wBands_fx[0] = SWB_SB_BW_LEN0_12KBPS_HAR; move16(); @@ -1787,7 +1785,7 @@ void hf_parinitiz_fx( *nBands_search_fx = NB_SWB_SUBBANDS; move16(); - IF ( L_sub(L_total_brate, HQ_13k20) == 0 ) + IF ( EQ_32(L_total_brate, HQ_13k20)) { wBands_fx[0] = SWB_SB_LEN0_12KBPS; move16(); @@ -1868,7 +1866,7 @@ void GetlagGains_fx( lag = lagIndices[sb]; move16(); - IF( sub(add(lag, fLen),predBufLen) > 0 ) + IF( GT_16(add(lag, fLen),predBufLen)) { /* should never happen */ lag = sub(predBufLen, fLen); @@ -2001,7 +1999,7 @@ void noise_extr_corcod_fx( } Qss_d = add(Qss_d, exp_norm); - IF ( sub(Qss_s, Qss_d) < 0 ) + IF ( LT_16(Qss_s, Qss_d)) { *Qss = Qss_s; move16(); @@ -2055,9 +2053,9 @@ void noise_extr_corcod_fx( ni_ratio_cur_fx = mult_r(ni_ratio_cur_fx, br_adj_fx); } - IF( sub(prev_hqswb_clas_fx, HQ_HARMONIC) == 0 ) + IF( EQ_16(prev_hqswb_clas_fx, HQ_HARMONIC)) { - IF( sub(ni_ratio_cur_fx, *prev_ni_ratio_fx) > 0 ) + IF( GT_16(ni_ratio_cur_fx, *prev_ni_ratio_fx)) { /* 0.8: 26214(Q15) 0.2: 6554(Q15) */ ni_ratio_fx = mac_r(L_mult(ni_ratio_cur_fx, 26214), *prev_ni_ratio_fx, 6554); @@ -2217,7 +2215,7 @@ void ton_ene_est_fx( move16(); } k = add(k, 1); - } WHILE( sub(k, NB_SWB_SUBBANDS) < 0 ); + } WHILE( LT_16(k, NB_SWB_SUBBANDS)); k = 0; move16(); @@ -2260,7 +2258,7 @@ void ton_ene_est_fx( exp_shift = sub(18, QE_r); E_r_shift_fx = shl(E_r_fx, exp_shift); - IF ( sub(E_r_shift_fx, 15729) < 0 ) /* E_r < 0.06 */ + IF ( LT_16(E_r_shift_fx, 15729)) /* E_r < 0.06 */ { /* avg_pe[k] = (float) sqrt(pow(2.0f,band_energy[i])/band_width[i]); */ /* Pre SQRT part */ @@ -2296,7 +2294,7 @@ void ton_ene_est_fx( L_temp = Mult_32_16(L_temp, E_r_fx); /* 0.12f: 257698038 (Q31) */ - if( L_sub(L_shl(L_temp,sub(31, add(add(shl(Qavg_pe[k], 1), QE_r), 1-15))), 257698038) >= 0 ) + if( GE_32(L_shl(L_temp,sub(31, add(add(shl(Qavg_pe[k], 1), QE_r), 1-15))), 257698038)) { ni_gain_fx[k] = mult_r(1638, ni_gain_fx[k]); /* 0.05 : 1638(Q15) */ move16(); } @@ -2444,7 +2442,7 @@ void Gettonl_scalfact_fx band_pos_fx = add(k_fx, harmonic_band); count_pos_st_fx = pos_fx; move16(); - WHILE(sub(sb_ton_loc_fx[pos_fx], sub(band_end[band_pos_fx], fLenLow)) <= 0 && sb_ton_loc_fx[pos_fx] >= 0 ) + WHILE(LE_16(sb_ton_loc_fx[pos_fx], sub(band_end[band_pos_fx], fLenLow))&&sb_ton_loc_fx[pos_fx]>=0) { test(); pos_fx = add(pos_fx, 1); @@ -2496,7 +2494,7 @@ void Gettonl_scalfact_fx pos_tmp_fx = add(pos_tmp_fx, 1); } k_fx = add(k_fx, 1); - } WHILE(sub(k_fx, NB_SWB_SUBBANDS) < 0); + } WHILE(LT_16(k_fx, NB_SWB_SUBBANDS)); /* Gap filling for the core coder */ /* 0.077=20185(Q18) */ @@ -2540,7 +2538,7 @@ void Gettonl_scalfact_fx move16(); } - IF(sub(p2aflags[band_pos_fx], 1) == 0) + IF(EQ_16(p2aflags[band_pos_fx], 1)) { FOR(i= band_start[band_pos_fx]; i<=band_end[band_pos_fx]; i++) { @@ -2787,7 +2785,7 @@ void FindNBiggest2_simple_fx_har( L_abs_in[j] = L_abs(L_inBuf[j]); /* Qabs_in */ L_abs_in_sft[j] = L_shr(L_abs_in[j], 8); /* 8 is safe shift */ - if( L_sub(L_max_in, L_abs_in_sft[j]) < 0 ) + if( LT_32(L_max_in, L_abs_in_sft[j])) { L_max_in = L_abs_in_sft[j]; move32(); @@ -2814,7 +2812,7 @@ void FindNBiggest2_simple_fx_har( peak_cnt_fx = 0; move16(); - IF( L_sub(L_max_in, 0x1) <= 0 ) + IF( LE_32(L_max_in, 0x1)) { FOR (j = 0; j < n_nbiggestsearch; j++) { @@ -2832,11 +2830,11 @@ void FindNBiggest2_simple_fx_har( L_thr = L_add(extract_l(avg_in_fx), L_shr(extract_l(temp_fx), sub(sub(Qsigma,1), Qavg_in)) ); L_thr = L_shr(L_thr, sub(Qavg_in, Qabs_in)); - IF( sub(peak_cnt_fx, n_nbiggestsearch) < 0 ) + IF( LT_16(peak_cnt_fx, n_nbiggestsearch)) { FOR (j = 0; j < nIdx_fx; j++) { - IF(L_sub(L_abs_in[j], L_thr) > 0 ) + IF(GT_32(L_abs_in[j], L_thr)) { pk_sf_fx[peak_cnt_fx].nmrValue_fx = round_fx(L_abs_in[j]); /* Qabs_in-16 */ pk_sf_fx[peak_cnt_fx].gainIndex_fx = j; @@ -2846,7 +2844,7 @@ void FindNBiggest2_simple_fx_har( move16(); } - IF( sub(peak_cnt_fx, n_nbiggestsearch) == 0 ) + IF( EQ_16(peak_cnt_fx, n_nbiggestsearch)) { BREAK; } @@ -2860,11 +2858,11 @@ void FindNBiggest2_simple_fx_har( temp_fx = add(round_fx(L_shl(L_temp, 14)), 22938); /* shift: 17+14-16 -> 15 */ /* 0.7(22937.6:Q15)*/ L_thr = Mult_32_16(L_thr, temp_fx); - IF( sub(peak_cnt_fx, n_nbiggestsearch) < 0 ) + IF( LT_16(peak_cnt_fx, n_nbiggestsearch)) { FOR (j = 0; j < nIdx_fx; j++) { - IF( L_sub(L_abs_in[j], L_thr) > 0 ) + IF( GT_32(L_abs_in[j], L_thr)) { pk_sf_fx[peak_cnt_fx].nmrValue_fx = round_fx(L_abs_in[j]); /* Qabs_in-16 */ pk_sf_fx[peak_cnt_fx].gainIndex_fx = j; @@ -2874,7 +2872,7 @@ void FindNBiggest2_simple_fx_har( move16(); } - IF( sub(peak_cnt_fx, n_nbiggestsearch) == 0 ) + IF( EQ_16(peak_cnt_fx, n_nbiggestsearch)) { BREAK; } @@ -2888,11 +2886,11 @@ void FindNBiggest2_simple_fx_har( temp_fx = add(round_fx(L_shl(L_temp, 15)), 9830); /* shift: 16+15-16 -> 15 */ /* 0.3(9830.4:Q15)*/ L_thr = Mult_32_16(L_thr, temp_fx); - IF( sub(peak_cnt_fx, n_nbiggestsearch) < 0 ) + IF( LT_16(peak_cnt_fx, n_nbiggestsearch)) { FOR (j = 0; j < nIdx_fx; j++) { - IF( L_sub(L_abs_in[j], L_thr) > 0 ) + IF( GT_32(L_abs_in[j], L_thr)) { pk_sf_fx[peak_cnt_fx].nmrValue_fx = round_fx(L_abs_in[j]); /* Qabs_in-16 */ pk_sf_fx[peak_cnt_fx].gainIndex_fx = j; @@ -2902,7 +2900,7 @@ void FindNBiggest2_simple_fx_har( move16(); } - IF( sub(peak_cnt_fx, n_nbiggestsearch) == 0 ) + IF( EQ_16(peak_cnt_fx, n_nbiggestsearch)) { BREAK; } @@ -2984,7 +2982,7 @@ Word16 spectrumsmooth_noiseton_fx( /* o : Qss ss_min FOR(i=0; i= 0x0L ) + if( GE_32(L_abs(L_spectra[i]), L_cut_input)) { L_spectra_rm[i] = L_spectra[i]; move32(); @@ -3005,7 +3003,7 @@ Word16 spectrumsmooth_noiseton_fx( /* o : Qss ss_min FOR(i=0; i= 0x0L ) + if( GE_32(L_abs(L_spectra_diff[i]), L_cut_input)) { L_spectra_rm[i] = L_spectra_diff[i]; move32(); @@ -3025,7 +3023,7 @@ Word16 spectrumsmooth_noiseton_fx( /* o : Qss ss_min sign_fx = 1; move16(); } - IF( sub(abs_s(sspectra_fx[i]), ss_min_fx ) > 0) + IF( GT_16(abs_s(sspectra_fx[i]), ss_min_fx )) { /*sspectra[i] = sign*((10-ss_min)/10.0f*(float)fabs(sspectra[i])+ss_min);*/ sspectra_fx[i] = add(mult_r(ratio_fx, abs_s(sspectra_fx[i])), ss_min_fx); @@ -3127,7 +3125,7 @@ void noiseinj_hf_fx( { FOR(i=band_start_fx[k]; i<=band_end_fx[k]; i++) { - IF( L_sub(L_abs(L_xSynth_har[i-fLenLow_fx]), L_th_g[k-(BANDS_fx-NB_SWB_SUBBANDS)] ) <= 0x0L ) + IF( LE_32(L_abs(L_xSynth_har[i-fLenLow_fx]), L_th_g[k-(BANDS_fx-NB_SWB_SUBBANDS)] )) { *p_L_En = L_mac(*p_L_En, xSynth_har_fx[i-fLenLow_fx], xSynth_har_fx[i-fLenLow_fx]); } @@ -3158,7 +3156,7 @@ void noiseinj_hf_fx( { L_temp = Mult_32_16(L_band_energy[k], 26214); /* 0.8: 26214(Q15) */ temp_fx = round_fx(L_shl(L_temp, sub(QsEn, sub(Qbe,16)))); - IF( sub(*p_prev_En_sb_fx, temp_fx) < 0 ) + IF( LT_16(*p_prev_En_sb_fx, temp_fx)) { /**p_Enn_sm_sb = (0.15f*(*p_En)) + (0.85f*prev_En_sb[k-(BANDS-NB_SWB_SUBBANDS)]);*/ /* 0.15: 4915.2(Q15) 0.85: 27852.80(Q15) */ @@ -3218,7 +3216,7 @@ void noiseinj_hf_fx( ni_scale_fx = mult_r(ni_scale_fx, 26214); /* 0.8=26214.4(Q15) -> Q14 */ FOR(i=band_start_fx[k]; i<=band_end_fx[k]; i++) { - IF( L_sub(L_abs(L_xSynth_har[i-fLenLow_fx]), L_th_g[k-(BANDS_fx-NB_SWB_SUBBANDS)]) <= 0x0L ) + IF( LE_32(L_abs(L_xSynth_har[i-fLenLow_fx]), L_th_g[k-(BANDS_fx-NB_SWB_SUBBANDS)])) { IF(map_pulse_fx[i] == 0) { @@ -3271,7 +3269,7 @@ void updat_prev_frm_fx( Copy32( L_y2, L_t_audio, length_fx ); /* If the input frame is larger than coded bandwidth, zero out uncoded MDCT coefficients */ - IF ( sub(inner_frame_fx, length_fx) > 0 ) + IF ( GT_16(inner_frame_fx, length_fx)) { set32_fx( L_t_audio + length_fx, 0x0L, sub(inner_frame_fx, length_fx) ); } @@ -3279,7 +3277,7 @@ void updat_prev_frm_fx( ELSE /* transient frame */ { test(); - IF( sub(inner_frame_fx, length_fx) == 0 || bws_cnt_fx > 0) + IF( EQ_16(inner_frame_fx, length_fx)||bws_cnt_fx>0) { /* Copy the scratch buffer to the output */ Copy32( L_y2, L_t_audio, length_fx ); @@ -3317,11 +3315,11 @@ void updat_prev_frm_fx( } } - IF( (L_sub(L_bwe_br, HQ_16k40) == 0 || L_sub(L_bwe_br, HQ_13k20) == 0 ) && sub(bwidth_fx, SWB) == 0 ) + IF( (EQ_32(L_bwe_br, HQ_16k40)||EQ_32(L_bwe_br,HQ_13k20))&&EQ_16(bwidth_fx,SWB)) { *prev_hqswb_clas_fx = hqswb_clas_fx; move16(); - IF ( sub(hqswb_clas_fx, HQ_HARMONIC) != 0 ) + IF ( NE_16(hqswb_clas_fx, HQ_HARMONIC)) { *prev_frm_hfe2_fx = 0; move16(); @@ -3338,7 +3336,7 @@ void updat_prev_frm_fx( test(); test(); test(); - IF( (L_sub(L_bwe_br, HQ_16k40) == 0 || L_sub(L_bwe_br, HQ_13k20) == 0) && sub(bwidth_fx, SWB) == 0 && sub(hqswb_clas_fx, HQ_NORMAL) == 0 ) + IF( (EQ_32(L_bwe_br, HQ_16k40)||EQ_32(L_bwe_br,HQ_13k20))&&EQ_16(bwidth_fx,SWB)&&EQ_16(hqswb_clas_fx,HQ_NORMAL)) { j = 0; move16(); diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 4594db761ff2bfce3f826d9f5de0179b82ee2243..ac60555da299a2b3de853f164b2c8ad422b647ec 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ @@ -9,8 +9,6 @@ #include "prot_fx.h" #include "rom_com_fx.h" #include "stl.h" -#include "wmc_auto.h" - #include "basop_util.h" /*-----------------------------------------------------------------* @@ -127,7 +125,7 @@ Word16 tbe_celp_exc_offset( Word16 offset_fx, tmp_fx, tmp1_fx, tmp2_fx, tmp_fac; tmp_fac = 320; move16(); /*2.5 in Q7*/ - if(sub(L_frame, L_FRAME16k) == 0) + if(EQ_16(L_frame, L_FRAME16k)) { tmp_fac = 256; move16(); /*2.0 in Q7*/ @@ -140,7 +138,7 @@ Word16 tbe_celp_exc_offset( tmp2_fx = shl(tmp1_fx,1);/*Q0 */ - IF(sub(L_frame, L_FRAME) == 0) + IF(EQ_16(L_frame, L_FRAME)) { tmp2_fx = add(shl(tmp1_fx,1),shr(tmp1_fx,1));/*Q0; (5/2 = 2 + 1/2)*/ } @@ -165,7 +163,7 @@ void tbe_celp_exc( ) { Word16 offset_fx, tmp_fx, i; - IF( sub(L_frame_fx,L_FRAME) == 0 ) + IF( EQ_16(L_frame_fx,L_FRAME)) { /*offset = T0 * HIBND_ACB_L_FAC + (int) ((float) T0_frac * 0.25f * HIBND_ACB_L_FAC + 2 * HIBND_ACB_L_FAC + 0.5f) - 2 * HIBND_ACB_L_FAC; for (i=0; i 0) + IF (GT_16(g0, 1024)) { temp = div_s(1024, g0); /* temp = 2**15 / gain0 */ FOR (i = 0; i < L_SUBFR16k; i++) @@ -630,7 +628,7 @@ static void filt_mu_fx( Word16 tmp,exp; - IF ( SubFrameLength == L_SUBFR ) + IF ( EQ_16(SubFrameLength ,L_SUBFR )) { IF (parcor0 > 0) { @@ -691,7 +689,7 @@ static void scale_st_swb( Word16 s_g_in, s_g_out,sh_g0,temp; - IF( SubFrameLength == L_SUBFR ) + IF ( EQ_16(SubFrameLength ,L_SUBFR )) { agc_fac1_para_fx = AGC_FAC1_FX; move16(); @@ -742,7 +740,7 @@ static void scale_st_swb( sh_g0 = add(scal_in, 1); sh_g0 = sub(sh_g0, scal_out); /* scal_in - scal_out + 1 */ - IF (sub(s_g_in, s_g_out) < 0) + IF (LT_16(s_g_in, s_g_out)) { g0_fx = div_s(s_g_in, s_g_out); /* s_g_in/s_g_out in Q15 */ } @@ -966,14 +964,14 @@ void GenShapedWBExcitation_fx( Word16* excSHB, /* o : synthesized shaped shb ex test(); test(); test(); - IF( igf_flag != 0 && ( sub(coder_type, VOICED) == 0 || sub( avg_voice_fac, 11469 ) > 0 ) ) /*Q15 -> 0.35f*/ + IF( igf_flag != 0 && ( EQ_16(coder_type, VOICED)||GT_16(avg_voice_fac,11469))) /*Q15 -> 0.35f*/ { csfilt_num2[0] = 6554; move16(); /*Q15 -> 0.2f*/ neg_csfilt_den2[1] = 26214; move16(); /*Q15 -> 0.8f*/ } - ELSE IF( igf_flag != 0 && ( sub(coder_type, UNVOICED) == 0 || sub( avg_voice_fac, 6654 ) < 0 ) ) /*Q15 -> 0.2f*/ + ELSE IF( igf_flag != 0 && ( EQ_16(coder_type, UNVOICED)||LT_16(avg_voice_fac,6654))) /*Q15 -> 0.2f*/ { csfilt_num2[0] = 328; move16(); /*Q15 -> 0.01f*/ @@ -987,7 +985,7 @@ void GenShapedWBExcitation_fx( Word16* excSHB, /* o : synthesized shaped shb ex IF ( uv_flag ) { create_random_vector_fx( exc4kWhtnd, L_FRAME16k / 4, bwe_seed ); - IF ( sub( Q_bwe_exc, 5 ) < 0 ) + IF ( LT_16( Q_bwe_exc, 5 )) { FOR ( i = 0; i < L_FRAME16k / 4; i++ ) @@ -1096,7 +1094,7 @@ void GenShapedWBExcitation_fx( Word16* excSHB, /* o : synthesized shaped shb ex test(); test(); - IF( sub(coder_type, UNVOICED) == 0 || ( igf_flag != 0 && sub( avg_voice_fac, 6654 ) < 0 ) ) + IF( EQ_16(coder_type, UNVOICED)||(igf_flag!=0&<_16(avg_voice_fac,6654))) { L_tmp = root_a_over_b_fx( pow1, sub( 22, shl( n1, 1 ) ), pow22, sub( 22, shl( n2, 1 ) ), &exp ); scale = round_fx( L_shl( L_tmp, exp ) ); /*Q15 */ @@ -1115,13 +1113,13 @@ void GenShapedWBExcitation_fx( Word16* excSHB, /* o : synthesized shaped shb ex FOR ( i = 0; i < 4; i++ ) { test(); - IF( igf_flag != 0 && sub(coder_type, VOICED) == 0 ) + IF( igf_flag != 0 && EQ_16(coder_type, VOICED)) { /*tmp_vfac = 2*voice_factors[i]; tmp_vfac = min(1, tmp_vfac);*/ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF tmp_vfac = shl(voice_factors[i], 1); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON } ELSE { @@ -1337,7 +1335,7 @@ void GenShapedSHBExcitation_fx( /* i: exc16k in Q_bwe_exc */ /* o: exc16kWhtnd in Q_bwe_exc */ - IF( L_sub(bitrate, ACELP_24k40) >= 0) + IF( GE_32(bitrate, ACELP_24k40)) { temp2 = 0; move16(); @@ -1370,7 +1368,7 @@ void GenShapedSHBExcitation_fx( Q_pow1 = shl(*Q_bwe_exc,1); test(); - IF( (L_sub( bitrate, ACELP_13k20 ) <= 0) && (L_sub( bitrate, ACELP_7k20 ) >= 0) ) + IF( (LE_32( bitrate, ACELP_13k20 ))&&(GE_32(bitrate,ACELP_7k20))) { /* varEnvShape = mean_fx(voice_factors, 4); */ /* unroll the loop */ @@ -1390,7 +1388,7 @@ void GenShapedSHBExcitation_fx( varEnvShape = mac_r(L_tmp, voice_factors[4], 6554 ); /* varEnvShape in Q15 */ } - IF ( sub(extl, FB_TBE) == 0 ) + IF ( EQ_16(extl, FB_TBE)) { /*pow(varEnvShape,3) */ tmp = mult_r(varEnvShape, varEnvShape); @@ -1416,7 +1414,7 @@ void GenShapedSHBExcitation_fx( test(); test(); test(); - IF ( *mem_csfilt == 0 && ( (L_sub( bitrate, ACELP_9k60 ) == 0) || (L_sub( bitrate, ACELP_16k40 ) == 0) || (L_sub( bitrate, ACELP_24k40 ) == 0) ) ) + IF ( *mem_csfilt == 0 && ( (EQ_32( bitrate, ACELP_9k60 ))||(EQ_32(bitrate,ACELP_16k40))||(EQ_32(bitrate,ACELP_24k40)))) { /* pre-init smoothing filter to avoid energy drop outs */ L_tmp = L_mult(excTmp2[0], 1638); @@ -1429,7 +1427,7 @@ void GenShapedSHBExcitation_fx( /* don't apply for FB in case the FB start-frame was potentially lost - White_exc16k is very sensitive to enery mismatch between enc - dec */ /* rather stick to the more conservative approach, to avoid potential clippings */ test(); - IF( !(prev_bfi && sub(extl, FB_TBE) == 0) ) + IF( !(prev_bfi && EQ_16(extl, FB_TBE))) { /* use weak smoothing for 1st frame after switching to make filter recover more quickly */ varEnvShape = 26214/*0.8f Q15*/; @@ -1504,9 +1502,9 @@ void GenShapedSHBExcitation_fx( Q_pow22 = shl( sub( *Q_bwe_exc, NOISE_QADJ ), 1); - IF( L_sub(bitrate, ACELP_24k40) >= 0) + IF( GE_32(bitrate, ACELP_24k40)) { - IF( sub(*vf_ind,20) == 0) /* encoder side */ + IF( EQ_16(*vf_ind,20)) /* encoder side */ { Estimate_mix_factors_fx(shb_res, Q_shb, exc16kWhtnd, *Q_bwe_exc, White_exc16k, (*Q_bwe_exc-NOISE_QADJ), pow1, Q_pow1, @@ -1519,7 +1517,7 @@ void GenShapedSHBExcitation_fx( tmp = shl( *vf_ind, (15-3) ); } tmp2 = MAX_16; - if( sub(tmp, 22938/*0.7f Q15*/) <= 0) + if( LE_16(tmp, 22938/*0.7f Q15*/)) { tmp2 = 26214/*0.8f Q15*/; } @@ -1549,7 +1547,7 @@ void GenShapedSHBExcitation_fx( /* i/o: White_exc16k (Q_bwe_exc-NOISE_QADJ) */ /* i: tbe_demph (Q_bwe_exc-NOISE_QADJ) */ - IF ( sub(coder_type, UNVOICED) == 0 ) + IF ( EQ_16(coder_type, UNVOICED)) { L_tmp = root_a_over_b_fx( pow1, Q_pow1, pow22, Q_pow22, &exp ); scale = round_fx( L_shl( L_tmp, exp ) ); /*Q15 */ @@ -1562,8 +1560,7 @@ void GenShapedSHBExcitation_fx( exc16kWhtnd[k] = round_fx( L_shl(L_tmp, NOISE_QADJ) ); /* exc16kWhtnd: Q_bwe_exc */ } - /*preemph_fx(exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph);*/ - preemph_copy_fx( exc16kWhtnd, exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); + preemph_fx( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); /* i/o: exc16kWhtnd (Q_bwe_exc) */ /* i/o: tbe_premph (Q_bwe_exc) */ } @@ -1575,7 +1572,7 @@ void GenShapedSHBExcitation_fx( /*nbSubFr = ( bitrate < ACELP_24k40 )? NB_SUBFR : NB_SUBFR16k;*/ nbSubFr = NB_SUBFR16k; lSubFr = (L_FRAME16k/NB_SUBFR16k); - IF(L_sub(bitrate, ACELP_24k40) < 0) + IF(LT_32(bitrate, ACELP_24k40)) { nbSubFr = NB_SUBFR; move16(); @@ -1586,7 +1583,7 @@ void GenShapedSHBExcitation_fx( FOR( i = 0; i < nbSubFr; i++ ) { test(); - IF( sub(coder_type, VOICED) == 0 && ( L_sub(bitrate, ACELP_24k40) < 0 ) ) + IF( EQ_16(coder_type, VOICED)&&(LT_32(bitrate,ACELP_24k40))) { exp = 0; tempQ15 = Sqrt16(voice_factors[i], &exp); /* Q15 */ @@ -1641,15 +1638,14 @@ void GenShapedSHBExcitation_fx( temp = div_s( temp, temp2 ); /* Q15 */ temp = mult_r( PREEMPH_FAC, temp ); - /*preemph_fx(&exc16kWhtnd[i * lSubFr], temp, lSubFr, tbe_premph);*/ - preemph_copy_fx( &exc16kWhtnd[i*lSubFr], &exc16kWhtnd[i * lSubFr], temp, lSubFr, tbe_premph ); + preemph_fx( &exc16kWhtnd[i*lSubFr], temp, lSubFr, tbe_premph ); /* exc16kWhtnd: Q_bwe_exc; tbe_premph: Q_bwe_exc*/ } } - IF ( L_sub(bitrate, ACELP_24k40) < 0 ) + IF ( LT_32(bitrate, ACELP_24k40)) { Syn_filt_s(0, lpc_shb, LPC_SHB_ORDER, exc16kWhtnd, excSHB, L_FRAME16k, state_lpc_syn, 1 ); /* i: exc16kWhtnd in Q_bwe_exc */ @@ -1678,7 +1674,7 @@ void GenShapedSHBExcitation_fx( /* i: exc16kWhtnd in Q_bwe_exc */ /* o: tempSHB in Q_bwe_exc */ /* o: syn_shb_ener_sf in (2*Q_bwe_exc+1) */ - IF(L_sub(bitrate,ACELP_32k) <= 0) + IF(LE_32(bitrate,ACELP_32k)) { L_tmp = sum32_fx(syn_shb_ener_sf, 4); @@ -1690,7 +1686,7 @@ void GenShapedSHBExcitation_fx( *Q_bwe_exc = sub(*Q_bwe_exc, exp); move16(); /* compensate for the exp shift */ tmp2 = add( prev_Q_bwe_syn, n_mem2 ); - IF( sub( *Q_bwe_exc, tmp2) > 0 ) + IF( GT_16( *Q_bwe_exc, tmp2)) { L_tmp2 = L_shl(L_tmp2, sub(tmp2, *Q_bwe_exc)); *Q_bwe_exc = tmp2; @@ -1728,7 +1724,7 @@ void GenShapedSHBExcitation_fx( /* o: excSHB in (Q_bwe_exc) */ } - IF ( sub(extl, FB_TBE) == 0) + IF ( EQ_16(extl, FB_TBE)) { tmp = sub( add(*Q_bwe_exc_fb, 20), prev_Q_bwe_exc_fb ); Scale_sig( fb_state_lpc_syn, LPC_SHB_ORDER, tmp ); @@ -2017,7 +2013,7 @@ void ScaleShapedSHB_fx( /* check for headroom of previous buff memories: overlap, Hilbert, and interp all-pass mem */ tmpQ15 = add( prev_Q_bwe_syn2, n_mem3 ); - if( sub( *Q_bwe_exc, tmpQ15) > 0 ) + if( GT_16( *Q_bwe_exc, tmpQ15)) { *Q_bwe_exc = tmpQ15; move16(); @@ -2093,7 +2089,7 @@ void ScaleShapedWB_fx( set32_fx( mod_syn, 0, L_FRAME16k+L_SHB_LAHEAD ); /* apply gain for each subframe, and store noise output signal using overlap-add */ - IF ( sub(length,SHB_OVERLAP_LEN / 2 ) == 0) + IF ( EQ_16(length,SHB_OVERLAP_LEN / 2 )) { /* WB Gain shape and gain frame application with overlap */ skip = skip_bands_WB_TBE; @@ -2192,7 +2188,7 @@ void ScaleShapedWB_fx( FOR( i = 0; i < l_frame + l_shb_lahead; i++ ) { abs_sig = abs_s( round_fx(mod_syn[i]) ); - if(sub(abs_sig,max)>0) + if(GT_16(abs_sig,max)) { max = abs_sig; move16(); @@ -2202,7 +2198,7 @@ void ScaleShapedWB_fx( FOR( i = 0; i < HILBERT_MEM_SIZE; i++ ) { abs_sig = abs_s( round_fx(Hilbert_Mem[i]) ); - if(sub(abs_sig,max)>0) + if(GT_16(abs_sig,max)) { max = abs_sig; move16(); @@ -2217,7 +2213,7 @@ void ScaleShapedWB_fx( shift = sub(13, Q_bwe_exc); /* earlier = (10 - Q_bwe_exc) but we changed GainFrame Q21 to Q18 */ *Qx = 0; } - ELSE IF (sub(L_frame,L_FRAME) == 0) /* 12.8k core */ + ELSE IF (EQ_16(L_frame,L_FRAME)) /* 12.8k core */ { max_headroom = sub(add(sc1,sc2),4); /* Max headroom after multiplying = sc1 + sc2 -3 (keep 3 bit extra headroom) */ /* 12.8k core needs extra headroom than 16k core */ @@ -2396,7 +2392,7 @@ void non_linearity_fx( Word16 length_half; - IF ( sub(L_frame, L_FRAME16k ) == 0 ) + IF ( EQ_16(L_frame, L_FRAME16k )) { nframes = 5; move16(); @@ -2418,7 +2414,7 @@ void non_linearity_fx( } test(); - if ( sub( coder_type, VOICED )==0 && sub( v_fac, ths ) > 0 ) + if ( EQ_16( coder_type, VOICED )&>_16(v_fac,ths)) { en_abs = 1; move16(); @@ -2435,7 +2431,7 @@ void non_linearity_fx( FOR ( i = j = 0; i < length_half; i++ ) { tmp = abs_s(input[i]); - if(sub(tmp,max)>0) + if(GT_16(tmp,max)) { j = i; move16(); @@ -2445,7 +2441,7 @@ void non_linearity_fx( } - IF ( sub(max, shl(1,Q_inp)) > 0 ) + IF ( GT_16(max, shl(1,Q_inp))) { exp = norm_s( max ); tmp = div_s( shl(1, sub( 14, exp)), max ); /* Q(29-exp-Q_inp) */ @@ -2458,7 +2454,7 @@ void non_linearity_fx( } test(); - IF ( prev_scale <= 0 || L_sub( Mult_32_16( prev_scale, 32 ), scale ) > 0 ) + IF ( prev_scale <= 0 || GT_32( Mult_32_16( prev_scale, 32 ), scale )) { scale_step = 16384; move16(); /* Q14 */ @@ -2511,7 +2507,7 @@ void non_linearity_fx( FOR ( i = length_half; i < length; i++ ) { tmp = abs_s(input[i]); - if(sub(tmp,max)>0) + if(GT_16(tmp,max)) { j = i; move16(); @@ -2519,7 +2515,7 @@ void non_linearity_fx( max = s_max(max, tmp); } - IF ( sub( max, shl( 1, Q_inp ) ) > 0 ) + IF ( GT_16( max, shl( 1, Q_inp ) )) { exp = norm_s( max ); tmp = div_s( shl(1, sub( 14, exp)), max ); /* Q(29-exp-Q_inp) */ @@ -2532,7 +2528,7 @@ void non_linearity_fx( } test(); - IF ( prev_scale <= 0 || L_sub( Mult_32_16( prev_scale, 32 ), scale ) > 0 ) + IF ( prev_scale <= 0 || GT_32( Mult_32_16( prev_scale, 32 ), scale )) { scale_step = 16384; move16(); /*Q14 */ @@ -2542,7 +2538,7 @@ void non_linearity_fx( { /*scale_step = (float) exp(1.0f / (float) (j - length/2) * (float) log(scale / prev_scale)); */ /* Computing log2(scale) */ - IF ( sub(j,length_half) == 0 ) + IF ( EQ_16(j,length_half)) { scale_step = 32767; move16();/*Q14 */ @@ -2620,7 +2616,7 @@ void create_random_vector_fx( k = extract_l( L_shr( L_tmp, 23 ) ); k = s_and( k, 0xff ); - WHILE ( sub(k,j) == 0 ) + WHILE ( EQ_16(k,j)) { L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) );/*Q23 */ k = extract_l( L_shr( L_tmp, 23 ) ); @@ -3120,7 +3116,7 @@ void synthesise_fb_high_band_fx( } exp_tmp = sub(Q_fb_exc,2); - IF( sub(L_frame,L_FRAME16k) == 0 ) + IF( EQ_16(L_frame,L_FRAME16k)) { /* for 16kHz ACELP core */ elliptic_bpf_48k_generic_fx( excitation_in_interp3, &exp_tmp, tmp, bpf_memory, bpf_memory_Q,full_band_bpf_3_fx ); @@ -3143,7 +3139,7 @@ void synthesise_fb_high_band_fx( exp2 = sub(sub(31,sub(shl(exp_tmp, 1), 8)), exp2); /* in Q15 (temp1 in Q9)*/ exp = sub(exp2, exp); /* Denormalize and substract */ - IF (sub(tmp2, tmp3) > 0) + IF (GT_16(tmp2, tmp3)) { tmp2 = shr(tmp2, 1); exp = add(exp, 1); @@ -3299,7 +3295,7 @@ void Estimate_mix_factors_fx( exp1 = sub(expb,expa); tmp = shl(tmp,exp1); - if(sub(num_flag,den_flag) != 0) + if(NE_16(num_flag,den_flag)) { tmp = negate(tmp); } @@ -3404,7 +3400,7 @@ void prep_tbe_exc_fx( test(); test(); - IF ( ( ( sub(coder_type,VOICED) == 0 ) || ( sub( pitch, 14784 ) > 0 ) ) && ( L_sub(core_brate,ACELP_8k00) > 0 ) ) + IF ( ( ( EQ_16(coder_type,VOICED))||(GT_16(pitch,14784)))&&(GT_32(core_brate,ACELP_8k00))) { tmp = MAX_16; move16(); @@ -3414,7 +3410,7 @@ void prep_tbe_exc_fx( *voice_factors_fx = s_min(s_max(*voice_factors_fx, 0), MAX_16); move16(); - IF ( sub(L_frame_fx,L_FRAME) == 0 ) + IF ( EQ_16(L_frame_fx,L_FRAME)) { interp_code_5over2_fx( code_fx, tmp_code_fx, L_SUBFR ); /* code: Q9, tmp_code: Q9 */ gain_code16 = round_fx( L_shl( gain_code_fx, Q_exc ) ); /*Q_exc */ @@ -3506,7 +3502,7 @@ Word16 swb_formant_fac_fx( /* o : Formant filter strength [0,1] */ formant_fac = mult_r( tmp, SWB_TILT_DELTA_FX ); /* Q12 */ - IF ( sub( formant_fac, 4096 ) > 0 ) + IF ( GT_16( formant_fac, 4096 )) { formant_fac = 4096; move16(); @@ -3546,18 +3542,18 @@ Word16 get_tbe_bits_fx( { Word16 i, bits = 0; - IF( sub(rf_mode,1)==0 ) + IF( EQ_16(rf_mode,1)) { /* TBE bits for core, primary frame */ test(); test(); - IF( (sub(bandwidth, WB ) == 0) && (L_sub(bitrate, ACELP_13k20) == 0) ) + IF( (EQ_16(bandwidth, WB ))&&(EQ_32(bitrate,ACELP_13k20))) { /* Gain frame: 4, Gain shapes: 0, and LSFs: 2 */ bits = NUM_BITS_SHB_FrameGain_LBR_WB + NUM_BITS_LBR_WB_LSF; move16(); } - ELSE IF( (sub(bandwidth, SWB ) == 0) && (L_sub(bitrate, ACELP_13k20) == 0) ) + ELSE IF( (EQ_16(bandwidth, SWB ))&&(EQ_32(bitrate,ACELP_13k20))) { /* Gain frame: 5, Gain shapes: 5, and lowrate LSFs: 8 */ bits = NUM_BITS_SHB_FRAMEGAIN + NUM_BITS_SHB_SUBGAINS + 8; @@ -3568,20 +3564,20 @@ Word16 get_tbe_bits_fx( { test(); test(); - IF( (sub(bandwidth, WB ) == 0) && (L_sub(bitrate, ACELP_9k60) == 0) ) + IF( (EQ_16(bandwidth, WB ))&&(EQ_32(bitrate,ACELP_9k60))) { bits = NUM_BITS_LBR_WB_LSF + NUM_BITS_SHB_FrameGain_LBR_WB; move16(); } - ELSE IF( (sub( bandwidth, SWB ) == 0) || (sub( bandwidth, FB ) == 0) ) + ELSE IF( (EQ_16( bandwidth, SWB ))||(EQ_16(bandwidth,FB))) { test(); - IF( L_sub(bitrate, ACELP_9k60) == 0 ) + IF( EQ_32(bitrate, ACELP_9k60)) { bits = NUM_BITS_SHB_FRAMEGAIN + NUM_BITS_SHB_SUBGAINS + 8; move16(); } - ELSE IF( (L_sub( bitrate, ACELP_13k20 ) >= 0 ) && (L_sub( bitrate, ACELP_32k ) <= 0 ) ) + ELSE IF( (GE_32( bitrate, ACELP_13k20 ))&&(LE_32(bitrate,ACELP_32k))) { bits = NUM_BITS_SHB_SUBGAINS + NUM_BITS_SHB_FRAMEGAIN + NUM_LSF_GRID_BITS + MIRROR_POINT_BITS; move16(); @@ -3592,19 +3588,19 @@ Word16 get_tbe_bits_fx( } } - if ( L_sub( bitrate, ACELP_24k40 ) >= 0 ) + if ( GE_32( bitrate, ACELP_24k40 )) { bits = add( bits, NUM_BITS_SHB_ENER_SF + NUM_BITS_SHB_VF + NUM_BITS_SHB_RES_GS*NB_SUBFR16k ); } test(); test(); - if( sub(bandwidth, SWB) == 0 && (L_sub(bitrate, ACELP_16k40) == 0 || L_sub(bitrate, ACELP_24k40) == 0) ) + if( EQ_16(bandwidth, SWB)&&(EQ_32(bitrate,ACELP_16k40)||EQ_32(bitrate,ACELP_24k40))) { bits = add( bits, BITS_TEC+BITS_TFA ); } - if ( sub(bandwidth, FB) == 0 ) + if ( EQ_16(bandwidth, FB)) { /* full band slope */ bits = add( bits, 4 ); diff --git a/lib_com/syn_12k8_fx.c b/lib_com/syn_12k8_fx.c index 9d0afb3e15bb0a9be6f7c73af55e19fa160ddd70..93794fc3f14cd7cf2b1e01cc56deea48998da258 100644 --- a/lib_com/syn_12k8_fx.c +++ b/lib_com/syn_12k8_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "cnst_fx.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*===========================================================================*/ diff --git a/lib_com/syn_filt_fx.c b/lib_com/syn_filt_fx.c index cf9aedafd7393e21f19ca67ed0c731ecf50c1e15..da5cbe25fdf1478ead41fbc1757f2ccac92d6570 100644 --- a/lib_com/syn_filt_fx.c +++ b/lib_com/syn_filt_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -9,8 +9,6 @@ #include "prot_fx.h" /* Function prototypes */ #include "rom_com_fx.h" /* Static table prototypes */ #include "stl.h" -#include "wmc_auto.h" - static Word32 syn_kern_2(Word32 L_tmp, const Word16 a[], const Word16 y[]) { @@ -150,19 +148,19 @@ void E_UTIL_synthesis(const Word16 shift, const Word16 a[], const Word16 x[], Wo Word16 q; Word32 (*syn_kern)(Word32 L_tmp, const Word16 a[], const Word16 y[]) = NULL; - if (sub(m, 6) == 0) + if (EQ_16(m, 6)) { syn_kern = syn_kern_6; } - if (sub(m, 10) == 0) + if (EQ_16(m, 10)) { syn_kern = syn_kern_10; } - if (sub(m, 16) == 0) + if (EQ_16(m, 16)) { syn_kern = syn_kern_16; } - if (sub(m, 24) == 0) + if (EQ_16(m, 24)) { syn_kern = syn_kern_24; } @@ -248,7 +246,7 @@ void synth_mem_updt2( Word16 mem_syn_r_size_old, mem_syn_r_size_new; /* Residual and update old_exc */ - IF( sub(dec, DEC) == 0 ) + IF( EQ_16(dec, DEC)) { lerp( old_exc+L_EXC_MEM_DEC-(last_L_frame+last_L_frame/2), old_exc+L_EXC_MEM_DEC-(L_frame+L_frame/2), L_frame+L_frame/2, last_L_frame+last_L_frame/2 ); } diff --git a/lib_com/tcq_position_arith_fx.c b/lib_com/tcq_position_arith_fx.c index ee654d24c11a325ab73027f0ae9414295a254260..24d15f4f7a5b053dc6570b0a73a73603383cfe5b 100644 --- a/lib_com/tcq_position_arith_fx.c +++ b/lib_com/tcq_position_arith_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -8,8 +8,6 @@ #include #include "options.h" /* Compilation switches */ #include "stl.h" -#include "wmc_auto.h" - #include "rom_com_fx.h" #include "prot_fx.h" @@ -26,11 +24,11 @@ Word32 ar_div(Word32 num, Word32 denum) denum = L_abs(denum); test(); - IF (L_sub(num, denum) < 0 || denum == 0) + IF (LT_32(num, denum)||denum==0) { return 0; } - ELSE IF (L_sub(num, denum) == 0) + ELSE IF (EQ_32(num, denum)) { return 1; } @@ -98,7 +96,7 @@ static UWord32 bitstream_load_bit(PBITSTREAM_FX pBS) Word16 *curPos; /* safety check in case of bit errors */ - IF( L_sub(pBS->numByte, pBS->maxBytes) >= 0 ) + IF( GE_32(pBS->numByte, pBS->maxBytes)) { return 0; } @@ -128,7 +126,7 @@ static void bitstream_rollback(PBITSTREAM_FX pBS, Word32 numBits) pBS->curPos++; move16(); pBS->numbits = L_sub(pBS->numbits, 1); - IF (sub(pBS->curPos, 8) == 0) + IF (EQ_16(pBS->curPos, 8)) { pBS->curPos = 0; move16(); @@ -236,13 +234,13 @@ static void ar_encode_fx( PARCODEC_FX arInst, Word16 const *model, Word32 symbol FOR( ; ; ) { - IF ( L_sub(high, AR_HALF) < 0 ) + IF ( LT_32(high, AR_HALF)) { transmission_bits( arInst, 0 ); } ELSE { - IF (L_sub(low, AR_HALF) >= 0 ) + IF (GE_32(low, AR_HALF)) { transmission_bits( arInst, 1 ); @@ -252,7 +250,7 @@ static void ar_encode_fx( PARCODEC_FX arInst, Word16 const *model, Word32 symbol ELSE { test(); - IF (L_sub(low, AR_FIRST) >= 0 && L_sub(high, AR_THIRD) < 0 ) + IF (GE_32(low, AR_FIRST)&<_32(high,AR_THIRD)) { arInst->bits_to_follow ++; move16(); @@ -337,7 +335,7 @@ static Word16 ar_decode_fx( PARCODEC_FX arInst, Word16 const *model ) symbol = 1; move16(); - WHILE ( sub(model[symbol], cum) > 0 ) + WHILE ( GT_16(model[symbol], cum)) { symbol = add(symbol, 1); } @@ -352,7 +350,7 @@ static Word16 ar_decode_fx( PARCODEC_FX arInst, Word16 const *model ) L_msb_high = L_shr(high,14); L_msb_low = L_shr(low,14); L_msb_diff = L_sub(L_msb_high, L_msb_low); - IF (L_sub(L_msb_diff,2) >= 0) + IF (GE_32(L_msb_diff,2)) { BREAK; } @@ -394,7 +392,7 @@ static Word16 quantize_fx( Word16 val, Word16 D) /* 2nd zero check */ IF (D == 0) { - if (sub(abs_s(sub(shl(abs_s(retval_fx), 10), abs_s(val))), abs_s(val)) > 0) + if (GT_16(abs_s(sub(shl(abs_s(retval_fx), 10), abs_s(val))), abs_s(val))) { retval_fx = 0; move16(); @@ -446,7 +444,7 @@ static Word32 GetBitsFromPulses_fx(Word16 m, Word16 n) frac_fx32 = Mult_32_32(L_shl(pow_getbitsfrompulses_fx[temp_fx1], exp1), L_shl(frac_fx32, exp2));/*21 + exp1 + 30 + exp2 - 31 */ frac_fx32 = L_shr(frac_fx32, exp1 + exp2) + 1;/*20 */ - IF (sub(exp, integer_fx) < 0) + IF (LT_16(exp, integer_fx)) { mantissa_fx = L_shr(mantissa_fx, sub(integer_fx, exp)); mantissa_fx = L_add(mantissa_fx, frac_fx32); @@ -458,7 +456,7 @@ static Word32 GetBitsFromPulses_fx(Word16 m, Word16 n) { mantissa_fx = L_add(mantissa_fx, L_shr(frac_fx32, sub(exp, integer_fx))); } - IF (L_sub(mantissa_fx, 0x200000) >= 0) + IF (GE_32(mantissa_fx, 0x200000)) { exp++; move16(); @@ -535,7 +533,7 @@ void TCQnew_fx( Word32 *v_fx, Word32 scale_fx, Word16 Qscale, tmp32 = Mult_32_16(v_fx[i], extract_h(tmp32));/*12 + 20 + exp - 16 - 15 + Qscale */ exp1 = 26-(exp-19+Qscale); exp2 = norm_l(tmp32); - IF( sub(exp2, exp1) >= 0 ) + IF( GE_16(exp2, exp1)) { value_fx = extract_h(L_shl(tmp32, sub(26, add(sub(exp, 19), Qscale))));/*exp -19 + Qscale*/ /*10*/ } @@ -549,7 +547,7 @@ void TCQnew_fx( Word32 *v_fx, Word32 scale_fx, Word16 Qscale, newdist1_fx = mult(newdist1_fx, newdist1_fx); /* 5 */ test(); - if (sub(add(quantum1_fx , pused_fx[step_tcq_fx[st][0]][i]), pulses) > 0 && terminate) + if (GT_16(add(quantum1_fx , pused_fx[step_tcq_fx[st][0]][i]), pulses)&&terminate) { newdist1_fx = MAX_16; move16(); @@ -560,14 +558,14 @@ void TCQnew_fx( Word32 *v_fx, Word32 scale_fx, Word16 Qscale, newdist2_fx = mult(newdist2_fx, newdist2_fx);/*5*/ test(); - if (sub(add(quantum2_fx , pused_fx[step_tcq_fx[st][1]][i]), pulses) > 0 && terminate) + if (GT_16(add(quantum2_fx , pused_fx[step_tcq_fx[st][1]][i]), pulses)&&terminate) { newdist2_fx = MAX_16; move16(); } /* decision */ - IF (L_sub(L_add(curdist1_fx, newdist1_fx), L_add(curdist2_fx, newdist2_fx)) < 0) + IF (LT_32(L_add(curdist1_fx, newdist1_fx), L_add(curdist2_fx, newdist2_fx))) { path_fx[st][i+1] = step_tcq_fx[st][0]; move16(); @@ -601,8 +599,8 @@ void TCQnew_fx( Word32 *v_fx, Word32 scale_fx, Word16 Qscale, test(); test(); test(); - IF ( (L_sub(dmin_fx, metric_fx[ i][ length]) > 0 && sub(pused_fx[i][ length], pulses) == 0) || - (sub(pused_fx[dminpos][ length], pulses) != 0 && sub(pused_fx[i][ length], pulses) == 0) ) + IF ( (GT_32(dmin_fx, metric_fx[ i][ length])&&EQ_16(pused_fx[i][length],pulses))|| + (NE_16(pused_fx[dminpos][ length], pulses) && EQ_16(pused_fx[i][ length], pulses)) ) { dmin_fx = L_add(metric_fx[ i][ length], 0); dminpos = i; @@ -757,7 +755,7 @@ Word32 GetISCScale_fx( Word32 *quants_fx, Word16 size, Word32 bits_fx, Word16 *m } /* Pulses redistribution */ - WHILE (sub(t_fx, pulsesnum) != 0 ) + WHILE (NE_16(t_fx, pulsesnum)) { pn_fx = 0; move16(); @@ -776,7 +774,7 @@ Word32 GetISCScale_fx( Word32 *quants_fx, Word16 size, Word32 bits_fx, Word16 *m direction = -1; move16(); - if ( sub(pulsesnum, t_fx) > 0 ) + if ( GT_16(pulsesnum, t_fx)) { direction = 1; move16(); @@ -841,7 +839,7 @@ Word32 GetISCScale_fx( Word32 *quants_fx, Word16 size, Word32 bits_fx, Word16 *m tmp32 = L_add(sxy_fx, L_shr(aquants_fx[i], 12-Qsxy));/*Qsxy */ t32 = L_add( sy2_fx, L_add( 1, L_deposit_l( shl(magn_fx[i], 1) ) ) ); - IF( sub(norm_l(t32), 15) < 0 ) + IF( LT_16(norm_l(t32), 15)) { SafeExp = sub(16, norm_l(t32)); tmp16 = extract_l( L_shr( t32, SafeExp) ); @@ -859,7 +857,7 @@ Word32 GetISCScale_fx( Word32 *quants_fx, Word16 size, Word32 bits_fx, Word16 *m t32 = L_add( sy2_fx, L_sub( 1, L_deposit_l( shl(magn_fx[i], 1) ) ) ); SafeExp = norm_l(t32); - IF( sub(norm_l(t32), 15) <= 0 ) + IF( LE_16(norm_l(t32), 15)) { SafeExp = sub(16, norm_l(t32)); tmp16 = extract_l( L_shr( t32, SafeExp) ); @@ -876,7 +874,7 @@ Word32 GetISCScale_fx( Word32 *quants_fx, Word16 size, Word32 bits_fx, Word16 *m dist_fx[i] = Mult_32_16(tmp32, g_fx);/*Qsxy + exp - 15 */ move32(); exp_dist[i] = add(Qsxy-15, exp); move16(); - if (sub(exp_dist[i], Q_temp) < 0) + if (LT_16(exp_dist[i], Q_temp)) { Q_temp = exp_dist[i]; move16(); @@ -897,7 +895,7 @@ Word32 GetISCScale_fx( Word32 *quants_fx, Word16 size, Word32 bits_fx, Word16 *m dmin_fx = L_add(dist_fx[0], 0); FOR (i = 1; i < size; i++) { - IF (L_sub(dmin_fx, dist_fx[i]) > 0) + IF (GT_32(dmin_fx, dist_fx[i])) { pos = L_deposit_l(i); dmin_fx = L_add(dist_fx[i], 0); @@ -920,7 +918,7 @@ Word32 GetISCScale_fx( Word32 *quants_fx, Word16 size, Word32 bits_fx, Word16 *m FOR (; i < size; i++) { test(); - IF (magn_fx[i] != 0 && L_sub(dmin_fx, dist_fx[i]) < 0) + IF (magn_fx[i] != 0 && LT_32(dmin_fx, dist_fx[i])) { pos = L_deposit_l(i); dmin_fx = L_add(dist_fx[i], 0); @@ -976,16 +974,16 @@ Word32 GetISCScale_fx( Word32 *quants_fx, Word16 size, Word32 bits_fx, Word16 *m test(); test(); - IF ( (sub(nzpos, pulsesnum) != 0 && sub(nzpos, 1) > 0) && noTCQ == 0 ) + IF ( (NE_16(nzpos, pulsesnum)&>_16(nzpos,1))&&noTCQ==0) { terminate = L_deposit_l(1); /*TCQnew( quants, scale, size, magn, pulsesnum, &pulsescurr, &nzposcurr, savedstates, &lasttrellislevel, terminate); */ TCQnew_fx(quants_fx, scale_fx32, Qscale, size, magn_fx, pulsesnum, &pulsescurr, &nzposcurr, savedstates, &lasttrellislevel, terminate); - IF (sub(pulsesnum, pulsescurr) > 0 ) + IF (GT_16(pulsesnum, pulsescurr)) { Word32 L_tmp; - IF( L_sub( 1952247030, scale_fx32) > 0 ) + IF( GT_32( 1952247030, scale_fx32)) { scale_fx32 = L_add(scale_fx32, Mult_32_16(scale_fx32, 3277)); } @@ -997,11 +995,11 @@ Word32 GetISCScale_fx( Word32 *quants_fx, Word16 size, Word32 bits_fx, Word16 *m } } - if(sub(pulsesnum, pulsescurr) < 0 ) + if(LT_16(pulsesnum, pulsescurr)) { scale_fx32 = Mult_32_16(scale_fx32, 29491); } - IF (sub(pulsesnum, pulsescurr) > 0) + IF (GT_16(pulsesnum, pulsescurr)) { diff = sub(pulsesnum, pulsescurr); @@ -1032,7 +1030,7 @@ Word32 GetISCScale_fx( Word32 *quants_fx, Word16 size, Word32 bits_fx, Word16 *m } } } - ELSE IF(sub(pulsesnum, pulsescurr) < 0) + ELSE IF(LT_16(pulsesnum, pulsescurr)) { diff = sub(pulsescurr, pulsesnum); @@ -1054,7 +1052,7 @@ Word32 GetISCScale_fx( Word32 *quants_fx, Word16 size, Word32 bits_fx, Word16 *m } m_int = abs_s(magn_fx[i]); - IF (sub(diff, m_int) < 0) + IF (LT_16(diff, m_int)) { /*magn_fx[i] = sign * sub(abs_s(magn_fx[i]), diff); move16(); */ IF (sign > 0) @@ -1093,7 +1091,7 @@ Word32 GetISCScale_fx( Word32 *quants_fx, Word16 size, Word32 bits_fx, Word16 *m FOR ( i = 0; i < size; i++) { - IF (sub(leftnz, 1) <= 0) + IF (LE_16(leftnz, 1)) { BREAK; } @@ -1104,7 +1102,7 @@ Word32 GetISCScale_fx( Word32 *quants_fx, Word16 size, Word32 bits_fx, Word16 *m { num = sub(leftnz, 1); denum = sub(leftp, add(j, 1)); - IF (sub(num, denum) >= 0) + IF (GE_16(num, denum)) { prob1_fx = MAX_16; move16(); @@ -1127,7 +1125,7 @@ Word32 GetISCScale_fx( Word32 *quants_fx, Word16 size, Word32 bits_fx, Word16 *m quantum2_fx = quantize_fx(shl(add(j, 1), 10), ddec_fx[st][1]); test(); - IF(sub(quantum1_fx, add(j, 1)) != 0 && sub(quantum2_fx, add(j, 1)) != 0 ) + IF(NE_16(quantum1_fx, add(j, 1))&&NE_16(quantum2_fx,add(j,1))) { /* this magnitude is not possible so set probabilities */ prob0_fx = MAX_16; @@ -1136,7 +1134,7 @@ Word32 GetISCScale_fx( Word32 *quants_fx, Word16 size, Word32 bits_fx, Word16 *m move16(); } - IF (sub(j, sub(abs_s(magn_fx[i]), 1)) < 0 ) + IF (LT_16(j, sub(abs_s(magn_fx[i]), 1))) { exp1 = norm_s(prob0_fx); tmp32 = L_deposit_h(shl(prob0_fx, exp1));/*exp1 + 15 + 16 */ @@ -1201,7 +1199,7 @@ Word32 GetISCScale_fx( Word32 *quants_fx, Word16 size, Word32 bits_fx, Word16 *m FOR ( i = 0; i < size; i++) { test(); - IF (flag_g1 == 0 || sub(*bcount, 2*TCQ_AMP) >= 0) + IF (flag_g1 == 0 || GE_16(*bcount, 2*TCQ_AMP)) { BREAK; } @@ -1344,7 +1342,7 @@ void TCQLSB_fx(Word16 bcount, Word32 *abuffer_fx, Word16 *mbuffer_fx, Word32 *sb newdist2_fx = L_add(Mult_32_32(tmp1, tmp1), Mult_32_32(tmp2, tmp2));/*-7*/ /* decision */ - IF ( L_sub(L_add(curdist1_fx, newdist1_fx), L_add(curdist2_fx, newdist2_fx)) < 0 ) + IF ( LT_32(L_add(curdist1_fx, newdist1_fx), L_add(curdist2_fx, newdist2_fx))) { path[st][i/2+1] = step_LSB_fx[st][0]; move16(); @@ -1367,7 +1365,7 @@ void TCQLSB_fx(Word16 bcount, Word32 *abuffer_fx, Word16 *mbuffer_fx, Word32 *sb move16(); } - if( L_sub( MaxPath, metric_fx[st][i/2+1]) > 0 ) + if( GT_32( MaxPath, metric_fx[st][i/2+1])) { MaxPath = L_add(metric_fx[st][i/2+1], 0); } @@ -1386,7 +1384,7 @@ void TCQLSB_fx(Word16 bcount, Word32 *abuffer_fx, Word16 *mbuffer_fx, Word32 *sb dmin_fx = L_add(metric_fx[ dminpos][ i/2], 0); FOR ( st = 1; st < 4; st++) { - IF ( L_sub(dmin_fx, metric_fx[ st][ i/2]) > 0 ) + IF ( GT_32(dmin_fx, metric_fx[ st][ i/2])) { dmin_fx = L_add(metric_fx[ st][ i/2], 0); dminpos = st; @@ -1485,7 +1483,7 @@ void RestoreTCQ_fx( Word16 * magn, Word16 size, Word16 *bcount, Word16 *mbuffer) IF ( magn[i] != 0 ) { nzpos = add(nzpos, 1); - if ( sub(abs_s(magn[i]), 5) > 0 ) + if ( GT_16(abs_s(magn[i]), 5)) { flag_g1 = 1; move16(); @@ -1493,12 +1491,12 @@ void RestoreTCQ_fx( Word16 * magn, Word16 size, Word16 *bcount, Word16 *mbuffer) } } - IF ( sub(nzpos, 1) > 0) + IF ( GT_16(nzpos, 1)) { FOR( i = 0; i < size; i++) { test(); - IF (flag_g1 == 0 || sub(*bcount, 2*TCQ_AMP) >= 0) + IF (flag_g1 == 0 || GE_16(*bcount, 2*TCQ_AMP)) { BREAK; } @@ -1526,7 +1524,7 @@ void RestoreTCQdec_fx( Word16 * magn, Word16 size, Word16 *bcount, Word16 *mbuff IF( magn[i] != 0 ) { nzpos = add(nzpos, 1); - if ( sub(abs_s(magn[i]), 1) > 0 ) + if ( GT_16(abs_s(magn[i]), 1)) { flag_g1 = 1; move16(); @@ -1535,12 +1533,12 @@ void RestoreTCQdec_fx( Word16 * magn, Word16 size, Word16 *bcount, Word16 *mbuff } } - IF( sub(nzpos, 1) > 0) + IF( GT_16(nzpos, 1)) { FOR ( i = 0; i < size; i++) { test(); - IF (!(flag_g1 && sub(*bcount, 2*TCQ_AMP) < 0)) + IF (!(flag_g1 && LT_16(*bcount, 2*TCQ_AMP))) { BREAK; } @@ -1636,7 +1634,7 @@ Word32 encode_position_ari_fx(PARCODEC_FX parenc, Word16* quants, Word16 size, W pnzp_fx = L_add(pnzp_fx, L_add(L_sub(table_logcum_fx[size + 1], L_add(table_logcum_fx[i + 2], table_logcum_fx[size - i])), L_sub(table_logcum_fx[pulses], L_add(table_logcum_fx[i + 1], table_logcum_fx[pulses - i])))); pnzp_fx = L_add(pnzp_fx, 917498);/*16 */ - IF( L_sub( pnzp_fx, 0) > 0) + IF( GT_32( pnzp_fx, 0)) { integer = extract_h(pnzp_fx); frac = extract_l(L_shr(L_sub(pnzp_fx, L_deposit_h(integer)), 1));/*15 */ @@ -1658,7 +1656,7 @@ Word32 encode_position_ari_fx(PARCODEC_FX parenc, Word16* quants, Word16 size, W ar_make_model_fx(prob, model_num_nz, s_min(pulses, size)); - IF (sub(nz, 1) > 0) + IF (GT_16(nz, 1)) { ar_encode_fx(parenc, model_num_nz, nz - 1);/*encode #nz */ scp = L_add(fxp1, 0); @@ -1713,9 +1711,9 @@ Word32 encode_position_ari_fx(PARCODEC_FX parenc, Word16* quants, Word16 size, W } } } - ELSE IF (sub(nz, 1) == 0) + ELSE IF (EQ_16(nz, 1)) { - IF (sub(pulses, 1) > 0) + IF (GT_16(pulses, 1)) { /*temp -= log2_f((float)(model_num_nz[nz-1] - model_num_nz[nz]) / MAX_AR_FREQ); */ ar_encode_fx(parenc, model_num_nz, 0);/*encode #nz */ @@ -1755,7 +1753,7 @@ Word32 encode_magnitude_usq_fx(ARCODEC_FX* parenc, Word16* magn_fx, Word16 size, *est_frame_bits_fx = L_add(*est_frame_bits_fx, bits_fx); test(); - IF (sub(npulses, nzpos) == 0 || sub(nzpos, 1) == 0) + IF (EQ_16(npulses, nzpos)||EQ_16(nzpos,1)) { return bits_fx; } @@ -1861,7 +1859,7 @@ Word32 encode_magnitude_tcq_fx(ARCODEC_FX* parenc, Word16* magn_fx, Word16 size, *est_frame_bits_fx = L_add(*est_frame_bits_fx, tcq_bits_fx); test(); - IF (sub(nzpos, npulses) == 0 || sub(nzpos, 1) == 0) + IF (EQ_16(nzpos, npulses)||EQ_16(nzpos,1)) { return bits_fx; } @@ -1869,7 +1867,7 @@ Word32 encode_magnitude_tcq_fx(ARCODEC_FX* parenc, Word16* magn_fx, Word16 size, st = L_deposit_l(0); FOR ( i = 0; i < size; i++) { - IF (sub(leftnz, 1) <= 0) + IF (LE_16(leftnz, 1)) { BREAK; } @@ -1882,7 +1880,7 @@ Word32 encode_magnitude_tcq_fx(ARCODEC_FX* parenc, Word16* magn_fx, Word16 size, /*calculate the two path probs point to next two states */ num = sub(leftnz, 1); denum = sub(leftp, add(j, 0x1)); - IF (sub(num, denum) >= 0) + IF (GE_16(num, denum)) { prob1_fx = MAX_16; move16(); @@ -1904,7 +1902,7 @@ Word32 encode_magnitude_tcq_fx(ARCODEC_FX* parenc, Word16* magn_fx, Word16 size, quantum2_fx = quantize_fx(shl(add(j, 1), 10), ddec_fx[st][1]); test(); - IF (sub(quantum1_fx, add(j, 1)) != 0 && sub(quantum2_fx, add(j, 1)) != 0) + IF (NE_16(quantum1_fx, add(j, 1))&&NE_16(quantum2_fx,add(j,1))) { prob0_fx = MAX_16; move16(); @@ -1913,13 +1911,13 @@ Word32 encode_magnitude_tcq_fx(ARCODEC_FX* parenc, Word16* magn_fx, Word16 size, } test(); - IF (sub(prob0_fx, MAX_16) == 0 || sub(prob1_fx, MAX_16) == 0) + IF (EQ_16(prob0_fx, MAX_16)||EQ_16(prob1_fx,MAX_16)) { CONTINUE; } magn_mode[1] = mult(prob1_fx, MAX_AR_FREQ); - IF (sub(j, sub(abs_s(magn_fx[i]), 1)) < 0) + IF (LT_16(j, sub(abs_s(magn_fx[i]), 1))) { ar_encode_fx(parenc, magn_mode, 0); } @@ -1990,7 +1988,7 @@ void decode_position_ari_fx(PARCODEC_FX pardec, Word16 size, Word16 npulses, Wor move16(); } - IF (L_sub(npulses, 1) > 0) + IF (GT_32(npulses, 1)) { btcq_fx = GetBitsFromPulses_fx(npulses, size); tmp = s_min(npulses, size); @@ -2002,7 +2000,7 @@ void decode_position_ari_fx(PARCODEC_FX pardec, Word16 size, Word16 npulses, Wor pnzp_fx = L_add(pnzp_fx, L_add(L_sub(table_logcum_fx[size + 1], L_add(table_logcum_fx[i + 2], table_logcum_fx[size - i])), L_sub(table_logcum_fx[npulses], L_add(table_logcum_fx[i + 1], table_logcum_fx[npulses - i])))); pnzp_fx = L_add(pnzp_fx, 917498);/*16 */ - IF( L_sub( pnzp_fx, 0) > 0) + IF( GT_32( pnzp_fx, 0)) { integer = extract_h(pnzp_fx); frac = extract_l(L_shr(L_sub(pnzp_fx, L_deposit_h(integer)), 1));/*15 */ @@ -2108,7 +2106,7 @@ void decode_position_ari_fx(PARCODEC_FX pardec, Word16 size, Word16 npulses, Wor } } } - ELSE IF (L_sub(npulses, 1) == 0) + ELSE IF (EQ_32(npulses, 1)) { *nz = npulses; move16(); @@ -2145,7 +2143,7 @@ void decode_magnitude_usq_fx(ARCODEC_FX* pardec, Word16 size, Word16 npulses, Wo move32(); set16_fx( magns, 1, TCQ_MAX_BAND_SIZE ); - IF (sub(nzpos, npulses) == 0) + IF (EQ_16(nzpos, npulses)) { FOR (i = 0; i < size; i++) { @@ -2154,7 +2152,7 @@ void decode_magnitude_usq_fx(ARCODEC_FX* pardec, Word16 size, Word16 npulses, Wo } return; } - ELSE IF (sub(nzpos, 1) == 0) + ELSE IF (EQ_16(nzpos, 1)) { FOR (i = 0; i < size; i++) { @@ -2312,7 +2310,7 @@ void decode_mangitude_tcq_fx(ARCODEC_FX* pardec, Word16 size, Word16 npulses, Wo bits_fx = L_deposit_l(0); tcq_bits_fx = L_sub(table_logcum_fx[npulses], L_add(table_logcum_fx[nzpos], table_logcum_fx[npulses - (nzpos - 1)])); - IF (sub(nzpos, npulses) == 0) + IF (EQ_16(nzpos, npulses)) { FOR (i = 0; i < size; i++) { @@ -2322,7 +2320,7 @@ void decode_mangitude_tcq_fx(ARCODEC_FX* pardec, Word16 size, Word16 npulses, Wo return; } - ELSE IF (sub(nzpos, 1) == 0) + ELSE IF (EQ_16(nzpos, 1)) { FOR (i = 0; i < size; i++) { @@ -2338,7 +2336,7 @@ void decode_mangitude_tcq_fx(ARCODEC_FX* pardec, Word16 size, Word16 npulses, Wo move16(); FOR (i = 0; i < size; i++) { - IF (sub(leftnz, 1) <= 0) + IF (LE_16(leftnz, 1)) { BREAK; } @@ -2353,7 +2351,7 @@ void decode_mangitude_tcq_fx(ARCODEC_FX* pardec, Word16 size, Word16 npulses, Wo { num = sub(leftnz, 1); denum = sub(leftp, add(j, 1)); - IF (sub(num, denum) >= 0) + IF (GE_16(num, denum)) { prob1_fx = MAX_16; move16(); @@ -2369,7 +2367,7 @@ void decode_mangitude_tcq_fx(ARCODEC_FX* pardec, Word16 size, Word16 npulses, Wo prob1_fx = shl(prob1_fx, sub(15, exp)); prob0_fx = sub(MAX_16, prob1_fx); } - IF (L_sub(sub(leftp, j), leftnz) == 0) + IF (EQ_32(sub(leftp, j), leftnz)) { symbol = add(j, 1); BREAK; @@ -2379,7 +2377,7 @@ void decode_mangitude_tcq_fx(ARCODEC_FX* pardec, Word16 size, Word16 npulses, Wo quantum2_fx = quantize_fx(shl(add(j, 1), 10), ddec_fx[st][1]); test(); - IF (sub(quantum1_fx, add(j, 1)) != 0 && sub(quantum2_fx, add(j, 1)) != 0) + IF (NE_16(quantum1_fx, add(j, 1))&&NE_16(quantum2_fx,add(j,1))) { prob0_fx = MAX_16; move16(); @@ -2388,7 +2386,7 @@ void decode_mangitude_tcq_fx(ARCODEC_FX* pardec, Word16 size, Word16 npulses, Wo } test(); - IF (sub(prob0_fx, MAX_16) == 0 || sub(prob1_fx, MAX_16) == 0) + IF (EQ_16(prob0_fx, MAX_16)||EQ_16(prob1_fx,MAX_16)) { symbol = add(j, 1); CONTINUE; @@ -2426,7 +2424,7 @@ void decode_mangitude_tcq_fx(ARCODEC_FX* pardec, Word16 size, Word16 npulses, Wo quantum2_fx = quantize_fx(out[i], ddec_fx[st][1]); /*generate the next state */ - IF (sub(quantum1_fx, out[i]) == 0) + IF (EQ_16(quantum1_fx, out[i])) { st = nextstate[st][0]; move16(); @@ -2451,7 +2449,7 @@ void decode_mangitude_tcq_fx(ARCODEC_FX* pardec, Word16 size, Word16 npulses, Wo } test(); - IF (sub(nzpos, npulses) != 0 && sub(nzpos, 1) > 0) + IF (NE_16(nzpos, npulses)&>_16(nzpos,1)) { /*update the surplus */ *surplus_fx = L_add(*surplus_fx, L_sub(tcq_bits_fx, L_shl(bits_fx, 1))); @@ -2506,7 +2504,7 @@ Word16 GetScale_fx( Word16 blen, Word32 bits_fx/*Q16*/, Word32 *surplus_fx/*Q16* FOR( ; pulses >= 0; pulses--) { estbits_fx = GetBitsFromPulses_fx( pulses, blen); - IF( L_sub( bits_fx, estbits_fx) >= 0) + IF( GE_32( bits_fx, estbits_fx)) { BREAK; } @@ -2546,7 +2544,7 @@ void srt_vec_ind_fx ( { FOR (npos = add(pos, 1); npos < length; npos++) { - IF (L_sub(srt[npos], srt[pos]) < 0) + IF (LT_32(srt[npos], srt[pos])) { idxMem = I[pos]; move16(); diff --git a/lib_com/tcx_ltp.c b/lib_com/tcx_ltp.c index e10cbec186ff042fea02ab88decd4aa47d51510a..4aac002d328648e85d827f037c1ef4c5eef634d2 100644 --- a/lib_com/tcx_ltp.c +++ b/lib_com/tcx_ltp.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include #include "options.h" #include "prot_fx.h" #include "stl.h" -#include "wmc_auto.h" - #include "cnst_fx.h" #include "basop_util.h" #include "rom_com_fx.h" @@ -54,11 +52,16 @@ void tcx_ltp_get_lpc(Word16 *x, Word16 L, Word16 *A, Word16 order) r = L_deposit_l(0); tmp = lshl((Word16)0x8000, s); /* factor corresponding to right shift by -s */ - FOR (j = 0; j < L; j++) { - tmpbuf[j] = mult_r(x[j], tmp); - move16(); - r = L_mac0(r, tmpbuf[j], tmpbuf[j]); + Word64 r64 = 0; + move64(); + FOR (j = 0; j < L; j++) + { + tmpbuf[j] = mult_r(x[j], tmp); + move16(); + r64 = W_mac0_16_16(r64, tmpbuf[j], tmpbuf[j]); + } + r = W_sat_l(r64); } r = L_max(r, L_shl(100, shl(s, 1))); r = Mpy_32_16_1(r, 16386/*1.0001f Q14*/); @@ -78,9 +81,14 @@ void tcx_ltp_get_lpc(Word16 *x, Word16 L, Word16 *A, Word16 order) r = L_deposit_l(0); tmp = sub(L, i); - FOR (j = 0; j < tmp; j++) { - r = L_mac0(r, p[j], p[j+i]); + Word64 r64 = 0; + move64(); + FOR (j = 0; j < tmp; j++) + { + r64 = W_mac0_16_16(r64, p[j], p[j+i]); + } + r = W_sat_l(r64); } r = L_shl(r, s2); r_l[i] = L_Extract_lc(r, &r_h[i]); @@ -152,7 +160,7 @@ static void tcx_ltp_get_zir( Word16 *zir, Word16 length, Word16 *synth_ltp, Word { step = mult_r(step, 26214/*64.f/80.f Q15*/); } - if (sub(length, 240) == 0) + if (EQ_16(length, 240)) { step = 273/*1.f/120.f Q15*/; move16(); @@ -192,7 +200,7 @@ void predict_signal( } win = &inter4_2tcx2[frac][0]; - if (sub(frac_max, 6) == 0) win = &inter6_2tcx2[frac][0]; + if (EQ_16(frac_max, 6))win=&inter6_2tcx2[frac][0]; FOR (j = 0; j < L_subfr; j++) { @@ -260,7 +268,7 @@ static void tcx_ltp_synth_filter( Word16 *synth_ltp, { step = mult_r(step, 26214/*64.f/80.f Q15*/); } - if (sub(length, 240) == 0) + if (EQ_16(length, 240)) { step = 137/*1.f/240.f Q15*/; move16(); @@ -332,7 +340,7 @@ Word16 tcx_ltp_decode_params( Word16 *ltp_param, { tmp = imult1616(sub(pitfr2, pitmin), pitres); - IF ( sub(ltp_param[1], tmp) < 0 ) + IF ( LT_16(ltp_param[1], tmp)) { tmp2 = idiv1616U(ltp_param[1], pitres); @@ -346,7 +354,7 @@ Word16 tcx_ltp_decode_params( Word16 *ltp_param, pitres = shr(pitres, 1); tmp2 = imult1616(sub(pitfr1, pitfr2), pitres); - IF ( sub(ltp_param[1], add(tmp, tmp2)) < 0 ) + IF ( LT_16(ltp_param[1], add(tmp, tmp2))) { tmp2 = idiv1616U(sub(ltp_param[1], tmp), pitres); @@ -367,7 +375,7 @@ Word16 tcx_ltp_decode_params( Word16 *ltp_param, *gain = imult1616(add(ltp_param[2], 1), 0x1400); move16(); - IF( sub(*pitch_int,PIT_MIN_SHORTER) < 0 ) + IF( LT_16(*pitch_int,PIT_MIN_SHORTER)) { /*pitch out of range due to bit error */ *pitch_int = PIT_MIN_SHORTER; @@ -375,7 +383,7 @@ Word16 tcx_ltp_decode_params( Word16 *ltp_param, return 1; } - IF( sub(*pitch_int,PIT_MAX_MAX) > 0 ) + IF( GT_16(*pitch_int,PIT_MAX_MAX)) { /*pitch out of range due to bit error */ *pitch_int = PIT_MAX_MAX; @@ -455,7 +463,7 @@ void tcx_ltp_post( Word8 tcxltp_on, /* TCX-LTP parameters: integer pitch, fractional pitch, gain */ test(); test(); - IF ( !(SideInfoOnly != 0 || tcxltp_on != 0) || sub(core, ACELP_CORE) == 0 ) + IF ( !(SideInfoOnly != 0 || tcxltp_on != 0) || EQ_16(core, ACELP_CORE)) { /* No LTP */ pitch_int = 0; @@ -468,7 +476,7 @@ void tcx_ltp_post( Word8 tcxltp_on, ELSE IF (bfi == 0) { /* LTP and good frame */ - IF (sub(L_frame, L_frame_core) != 0) + IF (NE_16(L_frame, L_frame_core)) { tmp = div_s(L_frame, shl(L_frame_core, 2)); /* Q13 */ tmp32 = L_mult0(add(imult1616(pitch_int, pitres), pitch_fr), tmp); /* Q13 */ @@ -478,11 +486,11 @@ void tcx_ltp_post( Word8 tcxltp_on, } test(); test(); - IF ( L_sub(bitrate, 48000) == 0 && sub(L_frame_core, L_FRAME16k) == 0 ) + IF ( EQ_32(bitrate, 48000)&&EQ_16(L_frame_core,L_FRAME16k)) { gain = mult_r(gain, 10486/*0.32f Q15*/); } - ELSE IF ( L_sub(bitrate, 48000) == 0 && sub(L_frame_core, 512) == 0 ) + ELSE IF ( EQ_32(bitrate, 48000)&&EQ_16(L_frame_core,512)) { gain = mult_r(gain, 13107/*0.40f Q15*/); } @@ -524,7 +532,7 @@ void tcx_ltp_post( Word8 tcxltp_on, gain2 = gain; move16(); - IF (sub(L_frame_core, L_FRAME) == 0) + IF (EQ_16(L_frame_core, L_FRAME)) { SWITCH ( L_frame ) { @@ -548,7 +556,7 @@ void tcx_ltp_post( Word8 tcxltp_on, assert(0); } } - ELSE IF (sub(L_frame_core, L_FRAME16k) == 0) + ELSE IF (EQ_16(L_frame_core, L_FRAME16k)) { SWITCH ( L_frame ) { @@ -572,7 +580,7 @@ void tcx_ltp_post( Word8 tcxltp_on, assert(0); } } - ELSE IF (sub(L_frame_core, 512) == 0) + ELSE IF (EQ_16(L_frame_core, 512)) { SWITCH ( L_frame ) { @@ -654,7 +662,7 @@ void tcx_ltp_post( Word8 tcxltp_on, *filtIdx_past ); } - ELSE IF ( sub(gain, *gain_past) == 0 && sub(pitch_int, *pitch_int_past) == 0 && sub(pitch_fr, *pitch_fr_past) == 0 ) + ELSE IF ( EQ_16(gain, *gain_past)&&EQ_16(pitch_int,*pitch_int_past)&&EQ_16(pitch_fr,*pitch_fr_past)) { tcx_ltp_synth_filter( sig_out+delay, sig_in+delay, diff --git a/lib_com/tcx_mdct.c b/lib_com/tcx_mdct.c index 60de633a67a5f5f44a4f41854f7b57ea251bc090..bf429f902b668f02db8e624acb20fa3a3eb59183 100644 --- a/lib_com/tcx_mdct.c +++ b/lib_com/tcx_mdct.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -9,29 +9,27 @@ #include "prot_fx.h" #include "basop_util.h" #include "stl.h" -#include "wmc_auto.h" - static Word16 TCX_MDCT_GetScaleFactor(Word16 L, Word16 *factor_e) { Word16 factor; - IF(sub(L, NORM_MDCT_FACTOR) == 0) + IF(EQ_16(L, NORM_MDCT_FACTOR)) { factor = 32767; move16(); *factor_e = 0; move16(); } - ELSE IF(sub(L, 2*NORM_MDCT_FACTOR) == 0) + ELSE IF(EQ_16(L, 2*NORM_MDCT_FACTOR)) { factor = 23170; move16(); *factor_e = 0; move16(); } - ELSE IF(sub(L, 4*NORM_MDCT_FACTOR) == 0) + ELSE IF(EQ_16(L, 4*NORM_MDCT_FACTOR)) { factor = 16384; move16(); @@ -56,21 +54,21 @@ static Word16 TCX_MDCT_Inverse_GetScaleFactor(Word16 L, Word16 *factor_e) Word16 factor; - IF(sub(L, NORM_MDCT_FACTOR) == 0) + IF(EQ_16(L, NORM_MDCT_FACTOR)) { factor = 32767; move16(); *factor_e = 0; move16(); } - ELSE IF(sub(L, 2*NORM_MDCT_FACTOR) == 0) + ELSE IF(EQ_16(L, 2*NORM_MDCT_FACTOR)) { factor = 23170; move16(); *factor_e = 1; move16(); } - ELSE IF(sub(L, 4*NORM_MDCT_FACTOR) == 0) + ELSE IF(EQ_16(L, 4*NORM_MDCT_FACTOR)) { factor = 32767; move16(); diff --git a/lib_com/tcx_mdct_window.c b/lib_com/tcx_mdct_window.c index 9c117809436b7d10a130e1de5f887cb14158e8b4..16484bf057af71ba355fa30938d0402b7a2ad0d7 100644 --- a/lib_com/tcx_mdct_window.c +++ b/lib_com/tcx_mdct_window.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ @@ -10,8 +10,6 @@ #include "rom_basop_util.h" #include "prot_fx.h" #include "stl.h" -#include "wmc_auto.h" - void mdct_window_sine(const PWord16 **window, const Word16 n) { @@ -77,7 +75,7 @@ void mdct_window_aldo( n2 = shr(imult1616(n, 14), 5); /* right slope length */ /* first part (long slope) */ - IF (sub(n, 1280/2) != 0) + IF (NE_16(n, 1280/2)) { FOR (i = 0; i < n0; i++) { @@ -97,7 +95,7 @@ void mdct_window_aldo( } test(); - if (sub(n, 512/2) == 0 || sub(n, 320/2) == 0) p1++; + if (EQ_16(n, 512/2)||EQ_16(n,320/2))p1++; FOR ( ; i < n1; i++) { @@ -153,7 +151,7 @@ void mdct_window_aldo( } /* second part (short slope) */ - IF (sub(n, 1280/2) != 0) + IF (NE_16(n, 1280/2)) { tmp = shr(n2, 1); FOR (i = 0; i < tmp; i++) @@ -165,7 +163,7 @@ void mdct_window_aldo( } test(); - if (sub(n, 512/2) == 0 || sub(n, 320/2) == 0) p2--; + if (EQ_16(n, 512/2)||EQ_16(n,320/2))p2--; FOR ( ; i < n2; i++) { diff --git a/lib_com/tcx_utils.c b/lib_com/tcx_utils.c index d00984a74b028bb88a10259d199cbf245b67c05a..8276c532230fe5724ee2288be69f3e061b1da745 100644 --- a/lib_com/tcx_utils.c +++ b/lib_com/tcx_utils.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include #include #include #include "stl.h" -#include "wmc_auto.h" - #include "options.h" #include "prot_fx.h" #include "rom_com_fx.h" @@ -232,7 +230,7 @@ void WindowSignal( /* Init lengths */ /* if past frame is ACELP */ - IF (sub(left_overlap_mode, TRANSITION_OVERLAP) == 0) + IF (EQ_16(left_overlap_mode, TRANSITION_OVERLAP)) { /* Increase frame size for 5ms */ IF (fullband == 0) @@ -255,7 +253,7 @@ void WindowSignal( tcx_windowing_analysis(in-shr(l,1)+offset, *L_frame, l, left_win, r, right_win, out); - IF (sub(left_overlap_mode, FULL_OVERLAP) == 0) + IF (EQ_16(left_overlap_mode, FULL_OVERLAP)) { /* fade truncated ALDO window to avoid discontinuities */ Word16 i, tmp; @@ -324,7 +322,7 @@ void tcx_windowing_synthesis_current_frame( test(); test(); test(); - IF ( sub(last_is_cng, 1)==0 && left_rect==0 ) + IF ( EQ_16(last_is_cng, 1)&&left_rect==0) { IF (!fullbandScale) { @@ -346,7 +344,7 @@ void tcx_windowing_synthesis_current_frame( } } /* Rectangular window (past-frame is ACELP) */ - ELSE IF ( sub(left_rect, 1)==0 && last_core_bfi==ACELP_CORE ) + ELSE IF ( EQ_16(left_rect, 1)&&last_core_bfi==ACELP_CORE) { tmp = sub(overlap,acelp_mem_len); FOR (i=0; i< tmp ; i++) @@ -416,7 +414,7 @@ void tcx_windowing_synthesis_current_frame( acelp_zir = tmp_buf; - IF( sub(acelp_zir_len, 2*64) >= 0 ) + IF( GE_16(acelp_zir_len, 2*64)) { /* apply a simple low-pass to the ZIR, to avoid potentially unmasked HF content */ FOR(i=2; iv.re); + ComplexData[2*i] = L_mult(lpcCoeffs[i], ptwiddle->v.re); move32(); - ImagData[i] = L_negate(L_mult(lpcCoeffs[i], ptwiddle->v.im)); + ComplexData[2*i+1] = L_negate(L_mult(lpcCoeffs[i], ptwiddle->v.im)); move32(); ptwiddle += step; } - /* zero padding */ FOR ( ; i= 0) + IF (GE_32(L_abs(x[i]), v4)) { /* Debug initialization to catch illegal x[i] values. */ @@ -1229,7 +1190,7 @@ void AdaptLowFreqDeemph(Word32 x[], Word16 x_e, FOR (i = 0; i < lg_4; i++) { - IF (L_sub(L_abs(x[i]), v4) >= 0) + IF (GE_32(L_abs(x[i]), v4)) { assert(x[i] != 0); if (x[i] < 0) tmp32 = L_add(x[i], v2); @@ -1415,7 +1376,7 @@ void tcx_noise_filling( s = add(s, sub(16, Q_e)); /* scaling */ tmp2 = sub(i, win); - IF (sub(segmentOffset, tmp2) < 0) + IF (LT_16(segmentOffset, tmp2)) { FOR (m = segmentOffset; m < tmp2; m++) { @@ -1440,7 +1401,7 @@ void tcx_noise_filling( } ELSE /* line is zero, so fill line and update window and energy */ { - if (sub(win, nTransWidth) < 0) + if (LT_16(win, nTransWidth)) { win = add(win, 1); } @@ -1491,7 +1452,7 @@ void InitTnsConfigs(Word32 nSampleRate, Word16 L_frame, ,Word32 bitrate ) { - IF (L_sub(bitrate,ACELP_32k) > 0) + IF (GT_32(bitrate,ACELP_32k)) { InitTnsConfiguration(nSampleRate, shr(L_frame,1), &tnsConfig[0][0], igfStopFreq, bitrate); } diff --git a/lib_com/tec_com.c b/lib_com/tec_com.c index 696eb4f96f9198a321d6318540145f550afa3859..9cf1b7975d6019062b28f8cdd083f3131ed6b9e6 100644 --- a/lib_com/tec_com.c +++ b/lib_com/tec_com.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include #include #include #include "stl.h" -#include "wmc_auto.h" - #include "basop_util.h" #include "prot_fx.h" #include "cnst_fx.h" @@ -90,7 +88,7 @@ static Word32 calcVar_Fix(const Word32 in[], Word32 len, Word32* x) { return 0; } - ELSE IF( L_sub(len,16) == 0) + ELSE IF( EQ_32(len,16)) { ans = L_sub(xx,L_shr(tmpX,4) ); @@ -136,7 +134,7 @@ calcCorrelationCoefficient2_Fix( } - IF( L_sub(len,16) ==0) + IF( EQ_32(len,16)) { exp1 = norm_l(x); exp2 = norm_l(y); @@ -529,7 +527,7 @@ static void calcGainLinear_TBE_Fx(const Word16* loTempEnv_m, /* Q7 = Q(15 - (LD_ IF ( tmp32 > 0 ) { - IF ( L_sub(tmp32,1006632960l/*0.46875 Q31*/) >= 0 ) + IF ( GE_32(tmp32,1006632960l/*0.46875 Q31*/)) { s = add(s,sub(WORD32_BITS,norm_l(BASOP_Util_InvLog2(L_sub(tmp32,1006632960l/*0.46875 Q31*/))))); s = add(s,30); @@ -594,7 +592,7 @@ calcGainTemp_TBE_Fx( IF (code > 0) { - IF (sub(code, 2) != 0) + IF (NE_16(code, 2)) { calcLoTempEnv_TBE_Fx(loBuffer_Fx + MAX_TEC_SMOOTHING_DEG, noCols, loTempEnv_Fx, 19531/*0.5f * ratioHiLoFacDec Q15*/); @@ -867,7 +865,7 @@ static Word16 procTec_Fx(Word16* hb_synth_Fx, test(); test(); - IF ( (sub(lower_limit_gain_e, min_curr_enr_e) > 0) || (sub(lower_limit_gain_e, min_curr_enr_e) == 0 && sub(lower_limit_gain_m, min_curr_enr_m) > 0) ) + IF ( (GT_16(lower_limit_gain_e, min_curr_enr_e))||(EQ_16(lower_limit_gain_e,min_curr_enr_e)&>_16(lower_limit_gain_m,min_curr_enr_m))) { lower_limit_gain_m = min_curr_enr_m; move16(); @@ -879,7 +877,7 @@ static Word16 procTec_Fx(Word16* hb_synth_Fx, upper_limit_gain_m = 19661/*0.6f Q15*/; /* norm = 0 */ move16(); upper_limit_gain_e = 1; move16(); - IF (sub(code, LOBUF_NO_SMOOTHING_MODE) == 0) + IF (EQ_16(code, LOBUF_NO_SMOOTHING_MODE)) { upper_limit_gain_m = 24576/*0.75f Q15*/; /* norm = 0 */ move16(); upper_limit_gain_e = 2; @@ -894,7 +892,7 @@ static Word16 procTec_Fx(Word16* hb_synth_Fx, { test(); test(); - IF ( (sub(lower_limit_gain_e, gain_e[i]) > 0) || (sub(lower_limit_gain_e, gain_e[i]) == 0 && sub(lower_limit_gain_m, gain_m[i]) > 0)) + IF ( (GT_16(lower_limit_gain_e, gain_e[i]))||(EQ_16(lower_limit_gain_e,gain_e[i])&>_16(lower_limit_gain_m,gain_m[i]))) { gain_m[i] = lower_limit_gain_m; move16(); @@ -913,7 +911,7 @@ static Word16 procTec_Fx(Word16* hb_synth_Fx, test(); test(); - IF ( (sub(upper_limit_gain_e, gain_e[i]) < 0) || (sub(upper_limit_gain_e, gain_e[i]) == 0 && sub(upper_limit_gain_m, gain_m[i]) < 0)) + IF ( (LT_16(upper_limit_gain_e, gain_e[i]))||(EQ_16(upper_limit_gain_e,gain_e[i])&<_16(upper_limit_gain_m,gain_m[i]))) { gain_m[i] = upper_limit_gain_m; @@ -938,7 +936,7 @@ static Word16 procTec_Fx(Word16* hb_synth_Fx, shift[k] = s - gain_e[i]; move16(); - if (sub(min_shift, shift[k]) > 0) + if (GT_16(min_shift, shift[k])) { min_shift = shift[k]; move16(); @@ -1064,7 +1062,7 @@ static Word16 procTfa_Fx(Word16* hb_synth_Fx, shift[k] = sub(s, gain_e[i]); move16(); - if (sub(min_shift, shift[k]) > 0) + if (GT_16(min_shift, shift[k])) { min_shift = shift[k]; move16(); @@ -1136,7 +1134,7 @@ Word16 procTecTfa_TBE_Fx(Word16 *hb_synth_Fx, } ELSE { - if (sub(last_core, ACELP_CORE) != 0) + if (NE_16(last_core, ACELP_CORE)) { i_offset = 1; move16(); @@ -1311,14 +1309,14 @@ calcLoEnvCheckCorrHiLo_Fix( move16(); FOR (i = 1; i < noCols; i++) { - if ( sub(maxHiFix , hiTempEnv[i]) < 0) + if ( LT_16(maxHiFix , hiTempEnv[i])) { maxPosHi = i; move16(); } maxHiFix = s_max(maxHiFix, hiTempEnv[i]); - if ( sub(maxLoFix , loTempEnv_ns_Fix[i]) < 0) + if ( LT_16(maxLoFix , loTempEnv_ns_Fix[i])) { maxPosLo = i; move16(); @@ -1326,7 +1324,7 @@ calcLoEnvCheckCorrHiLo_Fix( maxLoFix = s_max(maxLoFix, loTempEnv_ns_Fix[i]); } - if (sub(abs_s( sub(maxPosHi , maxPosLo)), 2) < 0) + if (LT_16(abs_s( sub(maxPosHi , maxPosLo)), 2)) { *corrFlag = 2; move16(); @@ -1361,13 +1359,13 @@ calcLoEnvCheckCorrHiLo_Fix( FOR (j = 1; j < len_window; j++) { - if ( sub( max_local_Fix , curr_pos_Fix[-j]) < 0) + if ( LT_16( max_local_Fix , curr_pos_Fix[-j])) { max_local_Fix = curr_pos_Fix[-j]; move16(); } - if ( sub(min_local_Fix, curr_pos_Fix[-j] ) > 0) + if ( GT_16(min_local_Fix, curr_pos_Fix[-j] )) { min_local_Fix = curr_pos_Fix[-j]; move16(); @@ -1375,7 +1373,7 @@ calcLoEnvCheckCorrHiLo_Fix( } feature_Fix[i] = sub(max_local_Fix , min_local_Fix); - if ( sub(feature_max_Fix , feature_Fix[i]) < 0) + if ( LT_16(feature_max_Fix , feature_Fix[i])) { pos_feature_max = i; move16(); @@ -1387,7 +1385,7 @@ calcLoEnvCheckCorrHiLo_Fix( IF (*corrFlag > 0) { test(); - if ((sub(feature_max_Fix, shl(20, 7)) <= 0 || sub(abs_s(sub(pos_feature_max, maxPosHi)), 3) >= 0 )) + if ((LE_16(feature_max_Fix, shl(20, 7))||GE_16(abs_s(sub(pos_feature_max,maxPosHi)),3))) { *corrFlag = 0; move16(); @@ -1471,19 +1469,19 @@ void tecEnc_TBE_fx(Word16* corrFlag, const Word16* voicing, Word16 coder_type) voice_diff = negate(voice_diff);/*voice_diff *= -1.0f;*/ } - IF( sub(*corrFlag, 1) == 0 ) + IF( EQ_16(*corrFlag, 1)) { test(); test(); test(); /*if( ((voice_sum > 0.35 * 2 && voice_sum < 0.55 * 2) && (voice_diff < 0.2)) )*/ - if( sub(coder_type,INACTIVE) == 0 || ((sub(voice_sum, 11469/*0.35 Q15*/) > 0 && sub(voice_sum, 18022/*0.55 Q15*/) < 0) && (sub(voice_diff, 6554/*0.2 Q15*/) < 0)) ) + if( EQ_16(coder_type,INACTIVE)||((GT_16(voice_sum,11469/*0.35 Q15*/)&<_16(voice_sum,18022/*0.55 Q15*/))&&(sub(voice_diff,6554/*0.2 Q15*/)<0))) { *corrFlag = 0; move16(); } } - if( sub(voice_sum, 19661/*0.6 Q15*/) > 0 ) /*if( voice_sum > 0.6 * 2 )*/ + if( GT_16(voice_sum, 19661/*0.6 Q15*/)) /*if( voice_sum > 0.6 * 2 )*/ { *corrFlag = 0; move16(); @@ -1497,13 +1495,13 @@ void set_TEC_TFA_code_fx(const Word16 corrFlag, Word16* tec_flag, Word16* tfa_fl IF (*tfa_flag == 0) { test(); - if (sub(corrFlag, 1) == 0 || sub(corrFlag, 2) == 0) + if (EQ_16(corrFlag, 1)||EQ_16(corrFlag,2)) { *tec_flag = 1; move16(); } - if (sub(corrFlag, 2) == 0) + if (EQ_16(corrFlag, 2)) { *tfa_flag = 1; move16(); diff --git a/lib_com/tns_base.c b/lib_com/tns_base.c index 5e93ed64b7c522902353b0540dd0552b55ac3af3..77715b91acb2223fbe3ba3dc4132ce73e1cdeda3 100644 --- a/lib_com/tns_base.c +++ b/lib_com/tns_base.c @@ -1,15 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "stl.h" -#include "wmc_auto.h" - #include "stat_com.h" #include "stl.h" -#include "wmc_auto.h" - #include #include #include "rom_com_fx.h" @@ -109,7 +105,7 @@ Word16 InitTnsConfiguration( move16(); pTnsConfig->maxOrder = TNS_MAX_FILTER_ORDER; - IF (L_sub(bitrate, ACELP_32k) <= 0) + IF (LE_32(bitrate, ACELP_32k)) { move16(); move16(); @@ -119,7 +115,7 @@ Word16 InitTnsConfiguration( ELSE { test(); - IF (L_sub(nSampleRate,32000) > 0 && L_sub(nSampleRate, L_mult0(100, frameLength)) == 0) + IF (GT_32(nSampleRate,32000)&&EQ_32(nSampleRate,L_mult0(100,frameLength))) { move16(); pTnsConfig->nMaxFilters = sizeof(tnsParameters48kHz_grouped)/sizeof(tnsParameters48kHz_grouped[0]); @@ -127,7 +123,7 @@ Word16 InitTnsConfiguration( pTnsConfig->pTnsParameters = tnsParameters48kHz_grouped; } ELSE - IF ( L_sub(nSampleRate,16000) > 0 ) + IF ( GT_32(nSampleRate,16000)) { move16(); pTnsConfig->nMaxFilters = sizeof(tnsParameters32kHz)/sizeof(tnsParameters32kHz[0]); @@ -135,7 +131,7 @@ Word16 InitTnsConfiguration( move16(); pTnsConfig->pTnsParameters = tnsParameters32kHz; - if ( L_sub(nSampleRate, L_mult0(100, frameLength)) == 0 ) /* sub-frame length is <= 10 ms */ + if ( EQ_32(nSampleRate, L_mult0(100, frameLength))) /* sub-frame length is <= 10 ms */ { move16(); pTnsConfig->pTnsParameters = tnsParameters32kHz_grouped; @@ -143,7 +139,7 @@ Word16 InitTnsConfiguration( } ELSE { - IF ( L_sub(nSampleRate, L_mult0(100, frameLength)) == 0 ) /* sub-frame length is <= 10 ms */ + IF ( EQ_32(nSampleRate, L_mult0(100, frameLength))) /* sub-frame length is <= 10 ms */ { move16(); move16(); @@ -314,10 +310,10 @@ Word16 ITF_Detect_fx(Word32 const pSpectrum[], iStartLine = imult1616(tmp, iSubdivisions); iEndLine = add(iStartLine, tmp); - if (sub(nSubdivisions, 3) == 0) iStartLine = mult(iStartLine, 0x2AAB); + if (EQ_16(nSubdivisions, 3))iStartLine=mult(iStartLine,0x2AAB); iStartLine = add(iStartLine, idx0); - if (sub(nSubdivisions, 3) == 0) iEndLine = mult(iEndLine, 0x2AAB); + if (EQ_16(nSubdivisions, 3))iEndLine=mult(iEndLine,0x2AAB); iEndLine = add(iEndLine, idx0); headroom = getScaleFactor32(pSpectrum+iStartLine-IGF_START_MN, sub(iEndLine, iStartLine)); /* Calculate norm of spectrum band */ @@ -347,7 +343,7 @@ Word16 ITF_Detect_fx(Word32 const pSpectrum[], } test(); - IF ((tmp32 > 0) && (sub(nSubdivisions, 1) > 0)) + IF ((tmp32 > 0) && (GT_16(nSubdivisions, 1))) { move16(); facs_e[iSubdivisions] = shl(sub(tmp, shifts[iSubdivisions]), 1); @@ -381,10 +377,10 @@ Word16 ITF_Detect_fx(Word32 const pSpectrum[], iStartLine = imult1616(spectrumLength, iSubdivisions); iEndLine = add(iStartLine, spectrumLength); - if (sub(nSubdivisions, 3) == 0) iStartLine = mult(iStartLine, 0x2AAB); + if (EQ_16(nSubdivisions, 3))iStartLine=mult(iStartLine,0x2AAB); iStartLine = add(iStartLine, idx0); - if (sub(nSubdivisions, 3) == 0) iEndLine = mult(iEndLine, 0x2AAB); + if (EQ_16(nSubdivisions, 3))iEndLine=mult(iEndLine,0x2AAB); iEndLine = add(iEndLine, idx0); @@ -402,10 +398,13 @@ Word16 ITF_Detect_fx(Word32 const pSpectrum[], { n = sub(sub(iEndLine,lag), iStartLine); - L_tmp = L_deposit_l(0); - FOR (i = 0; i < n; i++) { - L_tmp = L_mac0(L_tmp, tmpbuf[i], tmpbuf[i+lag]); + Word64 tmp64 = 0; + FOR (i = 0; i < n; i++) + { + tmp64 = W_mac0_16_16(tmp64, tmpbuf[i], tmpbuf[i+lag]); + } + L_tmp = W_sat_l(tmp64); } L_tmp = Mpy_32_16_1(L_tmp, facs[iSubdivisions]); @@ -417,7 +416,7 @@ Word16 ITF_Detect_fx(Word32 const pSpectrum[], } - IF ( sub(iSubdivisions,nSubdivisions) == 0 ) /* meaning there is no subdivision with low energy */ + IF ( EQ_16(iSubdivisions,nSubdivisions)) /* meaning there is no subdivision with low energy */ { /* Limit the maximum order to spectrum length/4 */ ITF_GetFilterParameters_fx(rxx, s_min (maxOrder, shr(spectrumLength,2)), A, Q_A, predictionGain); @@ -489,7 +488,7 @@ static Word16 DecodeUsingTable(Decoder_State_fx *st, Word16 * pValue, const Codi FOR (valueIndex = 0; valueIndex < nSize; valueIndex++) { - IF ( s_and(sub(codes[valueIndex].nBits,nBits) == 0, sub(codes[valueIndex].code,code) == 0) ) + IF ( s_and((Word16)EQ_16(codes[valueIndex].nBits,nBits),(Word16)EQ_16(codes[valueIndex].code,code))) { BREAK; } @@ -798,14 +797,16 @@ static Word32 FIRLattice(Word16 order, const Word16 *parCoeff /*Q15*/, Word32 *s Word32 tmpSave, tmp; - tmpSave = L_add(x,0); + tmpSave = x; + move32(); FOR (i = 0; i < order-1; i++) { tmp = L_add(state[i], Mpy_32_16_1(x, parCoeff[i])); x = L_add(x, Mpy_32_16_1(state[i], parCoeff[i])); /* exponent: 31+0 */ state[i] = tmpSave; move32(); - tmpSave = L_add(tmp,0); + tmpSave = tmp; + move32(); } /* last stage: only need half operations */ @@ -928,9 +929,9 @@ static void ITF_GetFilterParameters_fx(Word32 rxx[], /* compute filter in ParCor form with LeRoux-Gueguen algorithm */ L_tmp = E_LPC_schur(rxx, parCoeff, epsP, maxOrder); - BASOP_SATURATE_WARNING_OFF;/* Allow saturation, this value is compared against a threshold. */ + BASOP_SATURATE_WARNING_OFF /* Allow saturation, this value is compared against a threshold. */ *predictionGain = divide3232(L_shr(epsP[0], PRED_GAIN_E), L_tmp); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON { Word32 A32[ITF_MAX_FILTER_ORDER]; diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index 117ec3debe700f080b66005ac3336cbb192d8773..66b9b879257a758e86c72d99a43f73dd32fb6eac 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -10,8 +10,6 @@ #include "rom_com_fx.h" /* Function prototypes */ #include "cnst_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - #define INV_BANDS10 3277 /* 1/10 in Q15 */ #define INV_BANDS9 3641 /* 1/9 in Q15 */ @@ -92,12 +90,14 @@ Word32 Dot_product( /* o : Sum */ { Word16 i; Word32 L_sum; + Word64 L64_sum; - L_sum = L_mac(1L, x[0], y[0]); - FOR (i = 1; i < lg; i++) + L64_sum = 1; + FOR (i = 0; i < lg; i++) { - L_sum = L_mac(L_sum, x[i], y[i]); + L64_sum = W_mac_16_16(L64_sum, x[i], y[i]); } + L_sum = W_sat_l(L64_sum); return L_sum; } /*---------------------------------------------------------------------* @@ -253,7 +253,7 @@ void set32_fx( { Word16 i, tmp; tmp = extract_l(a); - IF (L_sub(L_deposit_l(tmp), a) == 0) + IF (EQ_32(L_deposit_l(tmp), a)) { FOR (i=0 ; i 0 ) + if( GT_16(vec_fx[j],tmp)) { ind = j; move16(); @@ -635,7 +635,7 @@ Word16 minimum_32_fx( /* o : index of the minimum value in the input vecto FOR ( j=1 ; j 0 ) + if( GT_32(vec[j],tmp)) { ind = j; move16(); @@ -905,7 +905,8 @@ Word32 dot_product_mat_fx( /* o : the dot product x'*A*x */ ) { Word16 i,j; - Word32 suma,tmp_sum; + Word64 tmp_sum_64; + Word32 suma, tmp_sum; const Word32 *pt_A; const Word16 *pt_x; @@ -914,14 +915,16 @@ Word32 dot_product_mat_fx( /* o : the dot product x'*A*x */ FOR(i=0; i 0) && (sub(cntnzcr, maxnzcr[tmp_fx2]) > 0) ) + if( (firstnzcr > 0) && (GT_16(cntnzcr, maxnzcr[tmp_fx2]))) { maxnzcr[tmp_fx2] = cntnzcr; move16(); @@ -291,7 +289,7 @@ void preecho_sb_fx( fxptr2++; fxptr3++; } - if(sub(j, NUMSF_M1) < 0) + if(LT_16(j, NUMSF_M1)) { cntnzcr = add(cntnzcr, 1); } @@ -307,7 +305,7 @@ void preecho_sb_fx( sptr2++; test(); - if( (firstnzcr > 0) && (sub(cntnzcr, maxnzcr[tmp_fx2]) > 0) ) + if( (firstnzcr > 0) && (GT_16(cntnzcr, maxnzcr[tmp_fx2]))) { maxnzcr[tmp_fx2] = cntnzcr; move16(); @@ -318,7 +316,7 @@ void preecho_sb_fx( test(); firstnzcr = 1; move16(); - IF((sub(j, NUMSF_M1) < 0) && (L_mult0(*fxptr2, *(fxptr2-1)) <= 0)) /* zcr between 2 subframes */ + IF((LT_16(j, NUMSF_M1))&&(L_mult0(*fxptr2,*(fxptr2-1))<=0)) /* zcr between 2 subframes */ { sptr1_loc = add(sptr1_loc, 1); /* counts for the nexte subframe */ cntnzcr = -1; @@ -329,7 +327,7 @@ void preecho_sb_fx( *fx32ptr1 = tmp_fxL1; move32(); - if( L_sub(*fx32ptr5, L_shr(*fx32ptr1, 1)) < 0 ) + if( LT_32(*fx32ptr5, L_shr(*fx32ptr1, 1))) { tmp_fxL1 = L_shl(L_sub(*fx32ptr1, *fx32ptr5),1); } @@ -399,12 +397,12 @@ void preecho_sb_fx( move16(); FOR (i = 1; i <= NUMSF; i++) { - IF (L_sub(es_mdct_hb_fx[i], max_es_hb_fx) >= 0) /* '=' to handle the first window*/ + IF (GE_32(es_mdct_hb_fx[i], max_es_hb_fx)) /* '=' to handle the first window*/ { max_es_hb_fx = L_add(es_mdct_hb_fx[i], 0); /* max energy low band, 8 present and 1 future subframes */ } - IF (L_sub(es_mdct_fx[i], max_es_fx) >= 0) /* '=' to handle the first window*/ + IF (GE_32(es_mdct_fx[i], max_es_fx)) /* '=' to handle the first window*/ { max_es_fx = L_add(es_mdct_fx[i], 0); /* max energy low band, 8 present and 1 future subframes */ maxind = i; @@ -416,13 +414,13 @@ void preecho_sb_fx( move16(); move16(); test(); - if( *prevflag != 0 || L_sub(max_es_fx, L_mult0(subframelength, 2500)) < 0 ) + if( *prevflag != 0 || LT_32(max_es_fx, L_mult0(subframelength, 2500))) { maxind = 0; move16(); } - if( L_sub(max_es_fx, L_shl(mean_prev_fx_loc, 2)) < 0 ) /*OK if saturated*/ + if( LT_32(max_es_fx, L_shl(mean_prev_fx_loc, 2)))/*OK if saturated*/ { maxind = 0; move16(); @@ -445,9 +443,9 @@ void preecho_sb_fx( test(); test(); test(); - IF( ( L_sub(tmp_fxL1, L_add(mean_prev_nc_fx_loc,125000)) > 0) || /* less then 20% energy in 3/4 of the subframe -> starting onset in the last quarter */ - (( L_sub(tmp_fxL2, L_add(mean_prev_nc_fx_loc,125000)) > 0) && - ((sub(zcr[i], limzcr) < 0) || ( L_sub(es_mdct_quart_fx[i], tmp_fxL3) < 0)) )) /* already an offset, plosif, do not touch */ + IF( ( GT_32(tmp_fxL1, L_add(mean_prev_nc_fx_loc,125000)))||/* less then 20% energy in 3/4 of the subframe -> starting onset in the last quarter */ + (( GT_32(tmp_fxL2, L_add(mean_prev_nc_fx_loc,125000))) && + ((LT_16(zcr[i], limzcr))||(LT_32(es_mdct_quart_fx[i],tmp_fxL3))))) /* already an offset, plosif, do not touch */ { maxind = i; move16(); /* no preecho reduction after the first subframe with gain 1 */ @@ -455,7 +453,7 @@ void preecho_sb_fx( move16(); FOR(j = sub(i,1); j >= 0; j--) { - if (L_sub(es_mdct_fx[j], L_shr(es_mdct_fx[i],1)) > 0) + if (GT_32(es_mdct_fx[j], L_shr(es_mdct_fx[i],1))) { maxind = j; move16(); @@ -464,20 +462,20 @@ void preecho_sb_fx( } ELSE { - IF (L_sub(es_mdct_fx[i], L_shr(max_es_fx, 4)) < 0) + IF (LT_32(es_mdct_fx[i], L_shr(max_es_fx, 4))) { g_fx = lim16_fx; move16(); cnt5 = add(cnt5,1); - IF (L_sub(es_mdct_fx[i], L_shr(max_es_fx, 5)) < 0) + IF (LT_32(es_mdct_fx[i], L_shr(max_es_fx, 5))) { g_fx = lim32_fx; move16(); cnt2 = add(cnt2, 1); } - IF(L_sub(mean_prev_fx_loc, es_mdct_fx[i]) < 0) + IF(LT_32(mean_prev_fx_loc, es_mdct_fx[i])) { tmp_fx1 = norm_l(es_mdct_fx[i]); tmp_fxL1 = L_shl(es_mdct_fx[i], tmp_fx1); @@ -489,7 +487,7 @@ void preecho_sb_fx( move16(); } - IF(L_sub(mean_prev_hb_fx_loc, es_mdct_hb_fx[i]) < 0) + IF(LT_32(mean_prev_hb_fx_loc, es_mdct_hb_fx[i])) { tmp_fx1 = norm_l(es_mdct_hb_fx[i]); tmp_fxL1 = L_shl(es_mdct_hb_fx[i], tmp_fx1); @@ -501,9 +499,9 @@ void preecho_sb_fx( move16(); } test(); - IF( (sub(zcr[i], limzcr/2) < 0) || (sub(maxnzcr[i], limmaxnzcr) > 0) ) + IF( (LT_16(zcr[i], limzcr/2))||(GT_16(maxnzcr[i],limmaxnzcr))) { - if(sub(min_g_fx[i], 32767) < 0) /* *mean_prev < es_mdct[i]) */ + if(LT_16(min_g_fx[i], 32767)) /* *mean_prev < es_mdct[i]) */ { mean_prev_fx_loc = L_add(es_mdct_fx[i], 0); } @@ -514,7 +512,7 @@ void preecho_sb_fx( ELSE { test(); - if( i > 0 && sub(maxind, NUMSF) < 0 ) + if( i > 0 && LT_16(maxind, NUMSF)) { *prevflag = 1; move16(); @@ -546,14 +544,14 @@ void preecho_sb_fx( move16(); FOR( i = 0; i < NUMSF; i++ ) { - if( sub(gt_fx[i], 32767) < 0 ) /*gt not yet limited by min_g*/ + if( LT_16(gt_fx[i], 32767)) /*gt not yet limited by min_g*/ { ind2 = add(i, 1); /* first subframe with gain = 1 after last gain < 1 --> frame with the attack*/ } } test(); - if( (sub(wmold_fx, 16384) > 0) && (sub(add(cnt2,cnt5), 2) < 0) ) /* mini either 1 cnt2 (and so also cnt5) or 2 cnt5 */ + if( (GT_16(wmold_fx, 16384))&&(LT_16(add(cnt2,cnt5),2))) /* mini either 1 cnt2 (and so also cnt5) or 2 cnt5 */ { /* maxind = 0; false alarm, no echo reduction */ ind2 = 0; @@ -603,7 +601,7 @@ void preecho_sb_fx( test(); test(); - IF( ind2 > 0 || sub(wmold_fx, 32767) < 0 || sub(*wmold_hb_fx, 32767) < 0 ) + IF( ind2 > 0 || LT_16(wmold_fx, 32767)||LT_16(*wmold_hb_fx,32767)) { ptr_fx = imdct_mem_fx; qtmp = qmemp1; @@ -641,7 +639,7 @@ void preecho_sb_fx( Mpy_32_16_ss(max_es_fx, 410, &tmp_fxL1, &tmp_u16); /* 410 for 1/80*/ test(); - if( (L_sub(tmp_fxL1, maxcrit_fx) > 0) && (sub(zcr[ind2], limzcr) > 0) ) + if( (GT_32(tmp_fxL1, maxcrit_fx))&&(GT_16(zcr[ind2],limzcr))) { maxcrit_fx = L_add(tmp_fxL1, 0); /* still 10 times smaller then mean max_es*/ } @@ -659,7 +657,7 @@ void preecho_sb_fx( tmp_fxL1 = L_mac0(tmp_fxL1, tmp_fx1, tmp_fx1); ptr_fx++; } - if( L_sub(tmp_fxL1, max_plus_es_mdct_fx) > 0 ) + if( GT_32(tmp_fxL1, max_plus_es_mdct_fx)) { max_plus_es_mdct_fx = L_add(tmp_fxL1, 0); } @@ -668,7 +666,7 @@ void preecho_sb_fx( *fx32ptr1 = tmp_fxL1; fx32ptr1++; Mpy_32_16_ss(sum_plus_es_fx, inv_jp2[j], fx32ptr4, &tmp_u16); /* 410 for 1/80*/ - if( L_sub(*fx32ptr4, maxcrit_fx) < 0) + if( LT_32(*fx32ptr4, maxcrit_fx)) { *fx32ptr4 = maxcrit_fx; move32(); @@ -679,7 +677,7 @@ void preecho_sb_fx( move32(); /*mean_plus_es_fx[pluslim] = -1; */ *mean_plus_es_fx = *plus_es_mdct_fx; move32(); /* index [0] */ - if( L_sub(*mean_plus_es_fx, maxcrit_fx) < 0) + if( LT_32(*mean_plus_es_fx, maxcrit_fx)) { *mean_plus_es_fx = maxcrit_fx; move32(); @@ -687,7 +685,7 @@ void preecho_sb_fx( j = 0; move16(); - WHILE((L_sub(plus_es_mdct_fx[j], mean_plus_es_fx[j]) < 0) && (L_sub(plus_es_mdct_fx[j], max_plus_es_mdct_fx/8) < 0 )) + WHILE((LT_32(plus_es_mdct_fx[j], mean_plus_es_fx[j]))&&(LT_32(plus_es_mdct_fx[j],max_plus_es_mdct_fx/8))) { test(); j = add(j,1); @@ -725,14 +723,14 @@ void preecho_sb_fx( sxyhb2_fx = L_sub(es_mdct_hb_fx[ind4], es_mdct_hb_fx[ind5]); /* / eshbmean2 * 2; 04042013: division not needed, only sign of sxyhb2 is used*/ - IF( sub(ind3, 2) > 0 ) + IF( GT_16(ind3, 2)) { tmp_fxL1 = L_add(eshbmean2_fx, es_mdct_hb_fx[ind6]); Mpy_32_16_ss(tmp_fxL1, 4369, &eshbmean3_fx, &tmp_u16); /*10922 : 1/3*/ sxylb3_fx = L_sub(es_mdct_fx[ind4], es_mdct_fx[ind6]); /* /eslbmean3 / 2; /2 for 3 points regression calc; 04042013: division not needed, only sign of sxylb3 is used*/ tmp_fxL1 = L_sub(es_mdct_hb_fx[ind4], es_mdct_hb_fx[ind6]); test(); - IF ((L_sub(tmp_fxL1, eshbmean3_fx) < 0) || (sxylb3_fx < 0)) + IF ((LT_32(tmp_fxL1, eshbmean3_fx))||(sxylb3_fx<0)) { ind2 = 0; move16(); @@ -759,7 +757,7 @@ void preecho_sb_fx( Mpy_32_16_ss(tmp_fxL1, 4369, &eshbmean3_fx, &tmp_u16); /*10922 : 1/3*/ tmp_fxL1 = L_sub(es_mdct_hb_fx[ind3], es_mdct_hb_fx[ind5]); - IF (L_sub(tmp_fxL1, eshbmean3_fx) < 0) + IF (LT_32(tmp_fxL1, eshbmean3_fx)) { ind2 = 0; move16(); @@ -814,7 +812,7 @@ void preecho_sb_fx( fattnext_fx = 32767; move16(); - if( sub(stind, framelength) > 0 ) + if( GT_16(stind, framelength)) { fattnext_fx = gt_fx[ind2_m1]; move16(); @@ -872,14 +870,14 @@ void preecho_sb_fx( FOR (i = 1; i < NUMSF; i++) /* all present subbands */ { - if( sub(i, NUMSF_S2) == 0 ) + if( EQ_16(i, NUMSF_S2)) { savehalfe_fx = L_add(mean_prev_nc_fx_loc, 0); } mean_prev_nc_fx_loc = L_add(mean_prev_nc_fx_loc, es_mdct_fx[i]); } - if( L_sub(savehalfe_fx, L_shr(mean_prev_nc_fx_loc,1) ) < 0 ) + if( LT_32(savehalfe_fx, L_shr(mean_prev_nc_fx_loc,1) )) { mean_prev_nc_fx_loc = L_shl(L_sub(mean_prev_nc_fx_loc, savehalfe_fx), 1); } @@ -900,7 +898,7 @@ void preecho_sb_fx( FOR (i = 1; i < NUMSF; i++) /* all present subbands */ { - IF(sub(i, NUMSF_S2) == 0) + IF(EQ_16(i, NUMSF_S2)) { savehalfe_fx = L_add(mean_prev_fx_loc, 0); savehalfe_hb_fx = L_add(mean_prev_hb_fx_loc, 0); @@ -911,13 +909,13 @@ void preecho_sb_fx( } tmp_fxL1 = L_sub(mean_prev_fx_loc, savehalfe_fx); - if( L_sub(savehalfe_fx, L_shr(mean_prev_fx_loc, 1) ) < 0 ) + if( LT_32(savehalfe_fx, L_shr(mean_prev_fx_loc, 1) )) { mean_prev_fx_loc = L_shl(tmp_fxL1, 1); } tmp_fxL1 = L_sub(mean_prev_hb_fx_loc, savehalfe_hb_fx); - if( L_sub(savehalfe_hb_fx, L_shr(mean_prev_hb_fx_loc, 1) ) < 0 ) + if( LT_32(savehalfe_hb_fx, L_shr(mean_prev_hb_fx_loc, 1) )) { mean_prev_hb_fx_loc = L_shl(tmp_fxL1, 1); } @@ -925,12 +923,12 @@ void preecho_sb_fx( last2_fx = L_shr(L_add(es_mdct_fx[NUMSF_M1], es_mdct_fx[NUMSF_M2]), 1); last2_hb_fx = L_shr(L_add(es_mdct_hb_fx[NUMSF_M1], es_mdct_hb_fx[NUMSF_M2]), 1); - if( L_sub(last2_fx, mean_prev_fx_loc) > 0 ) + if( GT_32(last2_fx, mean_prev_fx_loc)) { mean_prev_fx_loc = L_add(last2_fx, 0); } - if( L_sub(last2_hb_fx, mean_prev_hb_fx_loc) > 0 ) + if( GT_32(last2_hb_fx, mean_prev_hb_fx_loc)) { mean_prev_hb_fx_loc = L_add(last2_hb_fx, 0); } @@ -983,15 +981,15 @@ void Inverse_Transform( segment_length_div2 = shr(L, 2); segment_length_div4 = shr(L, 3); - IF (sub(L, L_FRAME48k) == 0) + IF (EQ_16(L, L_FRAME48k)) { win = short_window_48kHz_fx; } - ELSE IF (sub(L, L_FRAME32k) == 0) + ELSE IF (EQ_16(L, L_FRAME32k)) { win = short_window_32kHz_fx; } - ELSE IF( sub(L, L_FRAME16k) == 0 ) + ELSE IF( EQ_16(L, L_FRAME16k)) { win = short_window_16kHz_fx; } @@ -1047,7 +1045,7 @@ void Inverse_Transform( tmp = *Q; /* output of 'iedct_short_fx' has up to 'output frame length'/2 # of Elements */ iedct_short_fx( in_segment, &tmp, alias, segment_length ); - IF (sub(tmp, N_GUARD_BITS) > 0) + IF (GT_16(tmp, N_GUARD_BITS)) { q_out = sub(tmp, N_GUARD_BITS); tmp = sub(tmp, q_out); diff --git a/lib_com/vlpc_2st_com.c b/lib_com/vlpc_2st_com.c index a55c283f1c3bd838378cf2f1d2127389c4fe54c1..75c0f5de24ea67ed0ad272d52028a15363dd9487 100644 --- a/lib_com/vlpc_2st_com.c +++ b/lib_com/vlpc_2st_com.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -8,8 +8,6 @@ #include "cnst_fx.h" #include "prot_fx.h" #include "stl.h" -#include "wmc_auto.h" - #include "control.h" #include "basop_util.h" @@ -42,7 +40,7 @@ void lsf_weight_2st( weight = W_MODE0; move16(); /* abs */ } - ELSE IF (sub(mode,1) == 0) + ELSE IF (EQ_16(mode,1)) { weight = W_MODE1; move16(); /* mid */ diff --git a/lib_com/weight_a_fx.c b/lib_com/weight_a_fx.c index f0ced8a460cab372f658814e13c0b708d2d19b53..8c837e368645c65d0808b5b07d526da94df93e90 100644 --- a/lib_com/weight_a_fx.c +++ b/lib_com/weight_a_fx.c @@ -1,11 +1,9 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "stl.h" -#include "wmc_auto.h" - #include "prot_fx.h" /* Function prototypes */ #include "rom_com_fx.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ @@ -173,7 +171,7 @@ void E_LPC_a_weight_inv(const Word16 *a, Word16 *ap, const Word16 inv_gamma, con inv_gamma_tab = inv_gamma_tab_12k8; move16(); - if (sub(inv_gamma,GAMMA16k_INV) == 0) + if (EQ_16(inv_gamma,GAMMA16k_INV)) { inv_gamma_tab = inv_gamma_tab_16k; move16(); diff --git a/lib_com/weight_fx.c b/lib_com/weight_fx.c index 271df09d32465c297742d031836327c7cc22af60..dce673e1ed26ea8d8803df0fb03fe3c14c5782c6 100644 --- a/lib_com/weight_fx.c +++ b/lib_com/weight_fx.c @@ -1,14 +1,12 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "cnst_fx.h" /* Common constants */ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ -#include "stl.h" -#include "wmc_auto.h" - /* required for wmc_tool */ +#include "stl.h" /* required for wmc_tool */ /*--------------------------------------------------------------------------* * sfm2mqb_fx() @@ -76,7 +74,7 @@ static void sfm2mqb_fx( spe2q[16] = add(mult(tmp,10923),6); move16(); - IF (sub(nb_sfm, SFM_N_STA_8k) > 0) + IF (GT_16(nb_sfm, SFM_N_STA_8k)) { tmp = 0; move16(); @@ -87,7 +85,7 @@ static void sfm2mqb_fx( spe2q[17] = add(mult(tmp,10923),6); move16(); - IF (sub(nb_sfm, SFM_N_STA_10k) > 0) + IF (GT_16(nb_sfm, SFM_N_STA_10k)) { tmp = 0; move16(); @@ -184,7 +182,7 @@ static void mqb2sfm_fx( move16(); } - IF (sub(lnb_sfm, SFM_N_STA_8k) > 0) + IF (GT_16(lnb_sfm, SFM_N_STA_8k)) { FOR (i=27; i < 30; i++) { @@ -192,7 +190,7 @@ static void mqb2sfm_fx( move16(); } - IF (sub(lnb_sfm, SFM_N_STA_10k) > 0) + IF (GT_16(lnb_sfm, SFM_N_STA_10k)) { FOR (i=30; i < 35; i++) { diff --git a/lib_com/wi_fx.c b/lib_com/wi_fx.c index 6243d3726dd2f6c4a4a63674e81a2a7d4d33c5af..708c3a3d2ece3c2ad8af273c327fcaa19e738f93 100644 --- a/lib_com/wi_fx.c +++ b/lib_com/wi_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -10,8 +10,6 @@ #include "rom_com_fx.h" #include "log2.h" #include "stl.h" -#include "wmc_auto.h" - #define WARP_OS_RATE 8 #define LL 256 @@ -236,7 +234,7 @@ Word32 DTFS_freq_corr_fx( DTFS_STRUCTURE_FX X1_DTFS_fx, DTFS_STRUCTURE_FX X2_DTF Word32 L_tmp; Word16 Q_num,Q_den; - IF (sub(X1_DTFS_fx.lag_fx ,X2_DTFS_fx.lag_fx)< 0) + IF (LT_16(X1_DTFS_fx.lag_fx ,X2_DTFS_fx.lag_fx)) { DTFS_zeroPadd_fx(X2_DTFS_fx.lag_fx,&X1_DTFS_fx) ; } @@ -251,7 +249,7 @@ Word32 DTFS_freq_corr_fx( DTFS_STRUCTURE_FX X1_DTFS_fx, DTFS_STRUCTURE_FX X2_DTF FOR (k=0; k<=HalfLag; k++) { freq_fx = L_mult(k, 12800); - IF (L_sub(freq_fx, L_lband)>=0) + IF (GE_32(freq_fx, L_lband)) { BREAK; } @@ -260,7 +258,7 @@ Word32 DTFS_freq_corr_fx( DTFS_STRUCTURE_FX X1_DTFS_fx, DTFS_STRUCTURE_FX X2_DTF FOR (k=0; k<=HalfLag; k++) { freq_fx = L_mult(k, 12800); - IF (L_sub(freq_fx, L_hband)>=0) + IF (GE_32(freq_fx, L_hband)) { BREAK; } @@ -420,12 +418,12 @@ Word16 DTFS_alignment_weight_fx( DTFS_STRUCTURE_FX *X_fx, DTFS_STRUCTURE_FX X2, move16(); Adiff_fx = (Word16)s_max(768, mult_r(4915, shl(X2.lag_fx, 7))); /* Q7, 768=6*128, 4915 = 0.15*32768 */ - if (sub(X2.lag_fx,60) < 0) + if (LT_16(X2.lag_fx,60)) { diff_fx = 32; move16(); /* Q7 of 0.25 */ } - if (sub(X2.lag_fx,60) >= 0) + if (GE_16(X2.lag_fx,60)) { diff_fx = 64; move16(); /* Q7 of 0.5 */ @@ -476,7 +474,7 @@ Word16 DTFS_alignment_weight_fx( DTFS_STRUCTURE_FX *X_fx, DTFS_STRUCTURE_FX X2, temp1 = round_fx((Word32)L_shl(corr_fx, Qcorr)); /* Q(Qcorr-16) */ wcorr_fx = L_mult(temp1, shl(temp, 2)); /* Q(Qcorr-16+13+2+1)=Q(Qcorr) */ - IF (sub(Qmaxcorr,Qcorr) >= 0) + IF (GE_16(Qmaxcorr,Qcorr)) { diff_corr = L_sub(wcorr_fx, L_shl(maxcorr_fx, sub(Qcorr, Qmaxcorr))); /* Qcorr */ } @@ -534,7 +532,7 @@ Word16 DTFS_alignment_extract_td_fx(Word16 *x1, Word16 *x2, Word16 lag) { corr=L_mac(corr,x1[k],x2[(k-j+lag)%lag]); } - if (L_sub(corr,maxcorr)>0) + if (GT_32(corr,maxcorr)) { idx = j ; move16(); @@ -572,7 +570,7 @@ Word16 DTFS_alignment_fine_new_fx( DTFS_STRUCTURE_FX X1_fx, DTFS_STRUCTURE_FX X2 Word32 corr_fx; Word32 maxcorr_fx, wcorr_fx, diff_corr; - IF (sub(X1_fx.lag_fx, X2_fx.lag_fx) < 0) + IF (LT_16(X1_fx.lag_fx, X2_fx.lag_fx)) { DTFS_zeroPadd_fx(X2_fx.lag_fx, &X1_fx) ; } @@ -622,7 +620,7 @@ Word16 DTFS_alignment_fine_new_fx( DTFS_STRUCTURE_FX X1_fx, DTFS_STRUCTURE_FX X2 temp1 = round_fx((Word32)L_shl(corr_fx, Qcorr)); /* Q(Qcorr-16) */ wcorr_fx = L_mult(temp1, temp); /* Q(Qcorr-16+15+1)=Q(Qcorr) */ - IF (sub(Qmaxcorr,Qcorr) >= 0) + IF (GE_16(Qmaxcorr,Qcorr)) { diff_corr = L_sub(wcorr_fx, L_shl(maxcorr_fx, sub(Qcorr, Qmaxcorr))); /* Qcorr */ } @@ -687,7 +685,7 @@ Word16 DTFS_alignment_full_fx( DTFS_STRUCTURE_FX X1_DTFS_fx, DTFS_STRUCTURE_FX X find_rem(temp, shl(X1_DTFS_fx.lag_fx, 7), &Eshift); /* Q7 */ Eshift=shl(shr(Eshift,7),1); /* Q1 but integer */ - IF (sub(X2_DTFS_fx.lag_fx,60) > 0) + IF (GT_16(X2_DTFS_fx.lag_fx,60)) { Adiff_fx = shl(X2_DTFS_fx.lag_fx,1-3); /* lag_fx/8 in Q1 */ } @@ -743,7 +741,7 @@ Word16 DTFS_alignment_full_fx( DTFS_STRUCTURE_FX X1_DTFS_fx, DTFS_STRUCTURE_FX X temp = add(temp, temp1); } - if (L_sub(corr_fx, maxcorr_fx) > 0) + if (GT_32(corr_fx, maxcorr_fx)) { fshift_fx = n ; /* Q1 */ move16(); maxcorr_fx = L_add(corr_fx, 0); @@ -889,7 +887,7 @@ void DTFS_zeroPadd_fx(Word16 N_fx,DTFS_STRUCTURE_FX *X_fx) { Word16 i, start, end ,diff_fx,rem_fx; - if (sub(N_fx,X_fx->lag_fx) == 0) + if (EQ_16(N_fx,X_fx->lag_fx)) { return ; } @@ -912,7 +910,7 @@ void DTFS_zeroPadd_fx(Word16 N_fx,DTFS_STRUCTURE_FX *X_fx) diff_fx = find_rem(12800,X_fx->lag_fx,&rem_fx); X_fx->nH_fx = find_rem(X_fx->upper_cut_off_freq_fx,diff_fx,&rem_fx); - if(sub(sub(X_fx->upper_cut_off_freq_fx,shr((Word16)L_mult(diff_fx,X_fx->nH_fx),1)),diff_fx)>=0) + if(GE_16(sub(X_fx->upper_cut_off_freq_fx,shr((Word16)L_mult(diff_fx,X_fx->nH_fx),1)),diff_fx)) { X_fx->nH_fx = add(X_fx->nH_fx,1); } @@ -964,7 +962,7 @@ void DTFS_to_fs_fx( IF (!FR_flag) { - IF (sub(Fs,16000)==0) + IF (EQ_16(Fs,16000)) { X_fx->upper_cut_off_freq_of_interest_fx=4000; move16(); @@ -973,7 +971,7 @@ void DTFS_to_fs_fx( X_fx->Fs_fx=INT_FS_FX; move16(); } - ELSE IF (sub(Fs,8000)==0) + ELSE IF (EQ_16(Fs,8000)) { X_fx->upper_cut_off_freq_of_interest_fx=3300; move16(); @@ -1007,12 +1005,12 @@ void DTFS_to_fs_fx( nH_4kHz = mult(10240,(X_fx->lag_fx)); /* 4000/12800 in Q15 */ - if(sub(sub(X_fx->upper_cut_off_freq_fx,shr((Word16)L_mult(diff_fx,nH_band),1)),diff_fx)>=0) + if(GE_16(sub(X_fx->upper_cut_off_freq_fx,shr((Word16)L_mult(diff_fx,nH_band),1)),diff_fx)) { nH_band = add(nH_band,1); } - if(sub(sub(4000,shr((Word16)L_mult(diff_fx,nH_4kHz),1)),diff_fx)>=0) + if(GE_16(sub(4000,shr((Word16)L_mult(diff_fx,nH_4kHz),1)),diff_fx)) { nH_4kHz = add(nH_4kHz,1); } @@ -1053,13 +1051,13 @@ void DTFS_to_fs_fx( L_temp=L_abs(La[k]); - if (L_sub(L_temp,Labmax)>0) + if (GT_32(L_temp,Labmax)) { Labmax=L_temp; } L_temp=L_abs(Lb[k]); - if (L_sub(L_temp,Labmax)>0) + if (GT_32(L_temp,Labmax)) { Labmax=L_temp; } @@ -1094,7 +1092,7 @@ void DTFS_to_fs_fx( L_temp=L_abs(La[k]); - if (L_sub(L_temp,Labmax)>0) + if (GT_32(L_temp,Labmax)) { Labmax = L_add(L_temp, 0); } @@ -1241,7 +1239,7 @@ void DTFS_transform_fx( /* q2=sub(n,19); */ /* adjust Q factor to Q26 */ - IF (sub(sub(N, WI_SAMPLE_THLD), X_fx.lag_fx) > 0 ) + IF (GT_16(sub(N, WI_SAMPLE_THLD), X_fx.lag_fx)) { inv_fx = inv2_fx; move16(); @@ -1260,7 +1258,7 @@ void DTFS_transform_fx( { IF (FR_flag==0) { - IF ( sub(sub(N, WI_SAMPLE_THLD), X_fx.lag_fx) > 0 ) + IF ( GT_16(sub(N, WI_SAMPLE_THLD), X_fx.lag_fx)) { L_tmp = L_shl(Lw_fx,q2); /* Q29-exp2+q2 */ @@ -1289,7 +1287,7 @@ void DTFS_transform_fx( N1 = sub(N , tmp2_dtfs_fx->lag_fx); - IF (sub(i,N1) < 0) + IF (LT_16(i,N1)) /* w = (i+1)/N1; */ { @@ -1442,7 +1440,7 @@ void DTFS_zeroFilter_fx( DTFS_STRUCTURE_FX *X_fx,Word16 *LPC, Word16 N, Word16 * move16(); } - if (sub(na, nb)<0) + if (LT_16(na, nb)) { nb=na; move16(); @@ -1452,7 +1450,7 @@ void DTFS_zeroFilter_fx( DTFS_STRUCTURE_FX *X_fx,Word16 *LPC, Word16 N, Word16 * Qab[k] = sub(nb, 3); - if (sub(Qab[k], Qmin)<0) + if (LT_16(Qab[k], Qmin)) { Qmin = Qab[k]; move16(); @@ -1548,7 +1546,7 @@ void DTFS_poleFilter_fx_9( DTFS_STRUCTURE_FX *X_fx, Word16 *pf_temp1, Word16 *pf move16(); } - if (sub(na, nb)<0) + if (LT_16(na, nb)) { nb=na; move16(); @@ -1559,7 +1557,7 @@ void DTFS_poleFilter_fx_9( DTFS_STRUCTURE_FX *X_fx, Word16 *pf_temp1, Word16 *pf Qab[k] = add(sub(nb, 3), n2_temp1); - if (sub(Qab[k], Qmin)<0) + if (LT_16(Qab[k], Qmin)) { Qmin = Qab[k]; move16(); @@ -1607,12 +1605,12 @@ void DTFS_adjustLag_fx( Word16 exp,tmp; Word32 L_tmp; - if (sub(N_fx,X_DTFS_FX->lag_fx)==0) + if (EQ_16(N_fx,X_DTFS_FX->lag_fx)) { return ; } - IF(sub(N_fx,X_DTFS_FX->lag_fx)>0) + IF(GT_16(N_fx,X_DTFS_FX->lag_fx)) { DTFS_zeroPadd_fx(N_fx,X_DTFS_FX); } @@ -1651,7 +1649,7 @@ void DTFS_adjustLag_fx( X_DTFS_FX->nH_4kHz_fx = extract_l(L_shl(L_tmp, sub(exp,29))); - if(sub(sub(X_DTFS_FX->upper_cut_off_freq_fx, shr((Word16)L_mult(diff_fx,X_DTFS_FX->nH_fx),1)), diff_fx) >= 0) + if(GE_16(sub(X_DTFS_FX->upper_cut_off_freq_fx, shr((Word16)L_mult(diff_fx,X_DTFS_FX->nH_fx),1)), diff_fx)) { X_DTFS_FX->nH_fx = add(X_DTFS_FX->nH_fx,1); move16(); @@ -1662,7 +1660,7 @@ void DTFS_adjustLag_fx( tempnH_fx = Mult_32_32(mul1_fx,mul2_fx);/* Q6 */ tempnH_fx = L_sub((Word32)256000,tempnH_fx);/* Q6 */ - if(L_sub(tempnH_fx,temp32_fx)>=0) + if(GE_32(tempnH_fx,temp32_fx)) { X_DTFS_FX->nH_4kHz_fx = add(X_DTFS_FX->nH_4kHz_fx,1); move16(); @@ -1807,7 +1805,7 @@ Word32 DTFS_getEngy_band_fx(DTFS_STRUCTURE_FX X_fx,Word16 lband, Word16 hband) FOR (k=1; k<=HalfLag; k++) { freq_fx = L_mult(k, 12800); - IF (L_sub(freq_fx, L_lband)>=0) + IF (GE_32(freq_fx, L_lband)) { BREAK; } @@ -1817,7 +1815,7 @@ Word32 DTFS_getEngy_band_fx(DTFS_STRUCTURE_FX X_fx,Word16 lband, Word16 hband) FOR (k=1; k<=HalfLag; k++) { freq_fx = L_mult(k, 12800); - IF (L_sub(freq_fx, L_hband)>=0) + IF (GE_32(freq_fx, L_hband)) { BREAK; } @@ -2092,7 +2090,7 @@ Word32 DTFS_setEngyHarm_fx( count=add(count,1); } - IF( L_sub( Lacc_max, 2147483647 ) >= 0 ) + IF( GE_32( Lacc_max, 2147483647 )) { tmp = sub(HalfLag_fx, f_low_fx); exp = norm_s(tmp); @@ -2129,7 +2127,7 @@ Word32 DTFS_setEngyHarm_fx( expb = norm_l(en1_fx); fracb = round_fx(L_shl(en1_fx,expb)); - IF( L_sub( Lacc_max, 2147483647 ) >= 0 ) + IF( GE_32( Lacc_max, 2147483647 )) { expb = sub( 30, add( expb, sub(shl(X_fx->Q, 1),expp) ) ); } @@ -2147,7 +2145,7 @@ Word32 DTFS_setEngyHarm_fx( L_tmp = Isqrt_lc(L_deposit_h(tmp),&exp); /* Q(31-exp) */ - IF( L_sub( Lacc_max, 2147483647 ) >= 0 ) + IF( GE_32( Lacc_max, 2147483647 )) { factor_fx = L_shr(L_tmp,add(1,s_min(2,expp))); } @@ -2171,7 +2169,7 @@ Word32 DTFS_setEngyHarm_fx( X_fx->a_fx[k] = round_fx(L_temp_fx); /* Q(temp+X1.Q-15-16)=Q(temp+X1.Q-31); */ } - if ( L_sub( Lacc_max, 2147483647 ) >= 0) + if ( GE_32( Lacc_max, 2147483647 )) { *Qa_fx = sub( sub(X_fx->Q,add(1,s_min(2,expp))) , exp); } @@ -2274,7 +2272,7 @@ void cubicPhase_fx( Ltemp2 = L_sub(L_shl(L_deposit_h(factor),4),Ltemp2); /* Ltemp2=factor-N*f1, Q20 */ Ltemp1 = L_add(Ltemp2,L_shl(Ltemp1,5)); /* Ltemp1 in Q20 */ - IF(sub(N,180)>0) + IF(GT_16(N,180)) { Ltemp2 = L_shl(L_mult0(N,N),14); Ltemp2 = L_shl(Mult_32_16(Ltemp2,N),1); @@ -2294,7 +2292,7 @@ void cubicPhase_fx( Ltemp3 = L_sub(Ltemp3,L_shl(Ltemp1,1)); /* Ltemp3=N*c1-2*Ltemp1, Q20 */ - IF (L_sub(L_abs(Ltemp3),L_shl(Ltemp2,8)) >= 0) + IF (GE_32(L_abs(Ltemp3),L_shl(Ltemp2,8))) { Lacc = L_add(MIN_32, 0); if (Ltemp3 > 0) @@ -2421,7 +2419,7 @@ void cubicPhase_fx( /* ph[n]= c0*n^3+c1*n^2+c2*n+c3, Q15 */ phOut_fx[0] = L_shl(ph1_fx,11);/* Q27 */ - IF(sub(N,181) < 0) + IF(LT_16(N,181)) { FOR (n=1; n0) + IF (GT_16(count[i],1)) { IF(sum_a_fx[i]<0) { @@ -2677,14 +2675,14 @@ void erb_slot_fx( upper_cut_off_freq_fx=4000; move16(); - IF (sub(num_erb_fx,NUM_ERB_NB)==0) + IF (EQ_16(num_erb_fx,NUM_ERB_NB)) { upper_cut_off_freq_fx=4000; move16(); erb_fx=&(erb_NB_fx[0]); move16(); } - ELSE IF (sub(num_erb_fx,NUM_ERB_WB)==0) + ELSE IF (EQ_16(num_erb_fx,NUM_ERB_WB)) { upper_cut_off_freq_fx=6400; move16(); @@ -2732,18 +2730,18 @@ void erb_slot_fx( Ltemp_fx=L_mult(diff_fx,i); /* Ltemp=i*diff, Q20 */ /* freq=round32_16(L_shl(Ltemp,11)); : freq=i*diff, Q15 */ - IF (sub(num_erb_fx,NUM_ERB_NB)==0) + IF (EQ_16(num_erb_fx,NUM_ERB_NB)) { Ltemp_fx=L_min(Ltemp_fx,0x050000); /* 0x50000=0.3125 in Q20 (4000Hz) */ } - ELSE IF (sub(num_erb_fx,NUM_ERB_WB)==0) + ELSE IF (EQ_16(num_erb_fx,NUM_ERB_WB)) { Ltemp_fx=L_min(Ltemp_fx,0x080000); /* 0x80000=0.5 in Q20 (6400Hz) */ } FOR ( ; j0) + IF (GT_16(out_fx[j],1)) { expb = norm_l(mf_fx[j]); fracb = round_fx(L_shl(mf_fx[j],expb)); @@ -2827,12 +2825,12 @@ void DTFS_erb_inv_fx( Word16 exp,tmp; - IF (sub(num_erb_fx,NUM_ERB_NB)==0) + IF (EQ_16(num_erb_fx,NUM_ERB_NB)) { upper_cut_off_freq_fx=0x02800; move16();/* 0x2800=0.3125 in Q15 (4000Hz) */ } - ELSE IF (sub(num_erb_fx,NUM_ERB_WB)==0) + ELSE IF (EQ_16(num_erb_fx,NUM_ERB_WB)) { upper_cut_off_freq_fx=0x04000; move16();/* 0x4000=0.5 in Q15 (6400Hz) */ @@ -3110,12 +3108,12 @@ void erb_diff_fx( Word16 tmp, t_prev_erb[NUM_ERB_WB], LPC[M+1], mfreq[NUM_ERB_WB], PowSpect[NUM_ERB_WB], dif_erb[NUM_ERB_WB] ; const Word16 *AmpCB1_fx = NULL; - IF (sub(num_erb,NUM_ERB_NB)==0) + IF (EQ_16(num_erb,NUM_ERB_NB)) { AmpCB1_fx=AmpCB1_NB_fx; move16(); } - ELSE IF (sub(num_erb,NUM_ERB_WB)==0) + ELSE IF (EQ_16(num_erb,NUM_ERB_WB)) { AmpCB1_fx=AmpCB1_WB_fx; move16(); @@ -3145,7 +3143,7 @@ void erb_diff_fx( t_prev_erb[i] = prev_erb[i] ; move16(); } - IF(sub(pl,l)>0) + IF(GT_16(pl,l)) { tmp = t_prev_erb[0] ; move16(); @@ -3163,7 +3161,7 @@ void erb_diff_fx( } } } - ELSE IF (sub(l,pl)>0) + ELSE IF (GT_16(l,pl)) { tmp = t_prev_erb[num_erb-1] ; move16(); @@ -3193,7 +3191,7 @@ void erb_diff_fx( PowSpect, AmpCB1_fx, ERB_CBSIZE1, 10, 1) ; move16(); - IF (sub(num_erb,NUM_ERB_NB)==0) + IF (EQ_16(num_erb,NUM_ERB_NB)) { /* Second Band Amplitude Search */ index[1] = erb_diff_search_fx(t_prev_erb, curr_erb, dif_erb, @@ -3201,7 +3199,7 @@ void erb_diff_fx( ERB_CBSIZE2, 9, 11) ; move16(); } - ELSE IF (sub(num_erb,NUM_ERB_WB)==0) + ELSE IF (EQ_16(num_erb,NUM_ERB_WB)) { /* Second Band Amplitude Search */ index[1] = erb_diff_search_fx(t_prev_erb, curr_erb, dif_erb, @@ -3248,12 +3246,12 @@ void erb_add_fx( Word16 tmp_fx,tmp2_fx,tmp_loop; const Word16 *AmpCB1_fx = NULL; /*move16(); */ - IF (sub(num_erb_fx,NUM_ERB_NB)==0) + IF (EQ_16(num_erb_fx,NUM_ERB_NB)) { AmpCB1_fx=AmpCB1_NB_fx; move16(); } - ELSE IF (sub(num_erb_fx,NUM_ERB_WB)==0) + ELSE IF (EQ_16(num_erb_fx,NUM_ERB_WB)) { AmpCB1_fx=AmpCB1_WB_fx; move16(); @@ -3269,7 +3267,7 @@ void erb_add_fx( } - IF (sub(pl_fx,l_fx)>0) + IF (GT_16(pl_fx,l_fx)) { tmp_fx = t_prev_erb_fx[0]; move16(); /* Q13 */ @@ -3288,7 +3286,7 @@ void erb_add_fx( } } } - ELSE IF (sub(l_fx,pl_fx)>0) + ELSE IF (GT_16(l_fx,pl_fx)) { tmp_fx = t_prev_erb_fx[sub(num_erb_fx,1)]; /* Q13 */ FOR (i=sub(num_erb_fx,1); i>=0; i--) @@ -3331,13 +3329,13 @@ void erb_add_fx( IF (cslot_fx[i]!=0) { - IF (sub(num_erb_fx,NUM_ERB_NB)==0) + IF (EQ_16(num_erb_fx,NUM_ERB_NB)) { curr_erb_fx[i] = add(AmpCB2_NB_fx[sub(add(tmp_fx,i),11)],t_prev_erb_fx[i]) ;/* Q13+Q13=Q13 */ curr_erb_fx[i] = s_max(0, curr_erb_fx[i]); move16(); } - ELSE IF (sub(num_erb_fx,NUM_ERB_WB)==0) + ELSE IF (EQ_16(num_erb_fx,NUM_ERB_WB)) { curr_erb_fx[i] = add(AmpCB2_WB_fx[sub(add(tmp2_fx,i),11)],t_prev_erb_fx[i]) ; /* Q13 */ curr_erb_fx[i] = s_max(0, curr_erb_fx[i]); @@ -3412,14 +3410,14 @@ Word16 DTFS_quant_cw_fx( /* upper_cute_off_freq are normalized to 12800 */ - IF (sub(X_fx->upper_cut_off_freq_fx,0x2800)==0)/* 4000 hz normalized to 12800 in Q15 */ + IF (EQ_16(X_fx->upper_cut_off_freq_fx,0x2800))/* 4000 hz normalized to 12800 in Q15 */ { num_erb=NUM_ERB_NB; move16(); PowerCB_fx=PowerCB_NB_fx; move16(); } - ELSE IF (sub(X_fx->upper_cut_off_freq_fx,0x4000)==0)/* 6400 hz normalized to 12800 in Q15 */ + ELSE IF (EQ_16(X_fx->upper_cut_off_freq_fx,0x4000))/* 6400 hz normalized to 12800 in Q15 */ { num_erb=NUM_ERB_WB; move16(); @@ -3455,7 +3453,7 @@ Word16 DTFS_quant_cw_fx( { Ltemp= Mult_32_16(Ltemp,0x6666); /* *=0.8 */ } - IF (L_sub(Ltemp, minerror)<0) + IF (LT_32(Ltemp, minerror)) { minerror = L_add(Ltemp, 0); *POWER_IDX = j ; @@ -3512,7 +3510,7 @@ Word16 DTFS_quant_cw_fx( tmp=round_fx(Lacc); /* tmp in Q15 */ test(); - if (sub(tmp,0x3C29)>0 && add(target[0],819)>0) + if (GT_16(tmp,0x3C29)&>_16(target[0],-819)) { flag = 0 ; /* Bumping up */ move16(); } @@ -3792,7 +3790,7 @@ void DTFS_dequant_cw_fx( L_temp = L_shl(L_tmp, add(exp1,15) ); /* Q15 */ L_tmp2 = L_temp; - if( L_sub( L_temp, 2147483647 ) >= 0 ) + if( GE_32( L_temp, 2147483647 )) { L_temp = L_shl(L_tmp, 15 ); /*Q(15-exp1) */ } @@ -3800,7 +3798,7 @@ void DTFS_dequant_cw_fx( n=norm_l(L_temp); Ltemp_fx=L_shl(L_temp,n); /* Ltemp in Q(15+n) or Q(15 - exp1 +n) */ - IF( L_sub( L_tmp2, 2147483647 ) >= 0 ) + IF( GE_32( L_tmp2, 2147483647 )) { DTFS_setEngyHarm_fx( 236, 2828, 0, 2828, Ltemp_fx, add(15,sub(n,exp1)), &Ql, X_fx ); } @@ -3819,7 +3817,7 @@ void DTFS_dequant_cw_fx( L_temp = L_shl(L_tmp,exp1 +15 ); /* Q15 */ L_tmp2 = L_temp; - if( L_sub( L_temp, 2147483647 ) >= 0 ) + if( GE_32( L_temp, 2147483647 )) { L_temp = L_shl(L_tmp, 15 ); /*Q(15-exp1) */ } @@ -3828,7 +3826,7 @@ void DTFS_dequant_cw_fx( n=norm_l(L_temp); Ltemp_fx=L_shl(L_temp,n); /* Ltemp in Q(15+n) or Q(15 - exp1 +n) */ - IF( L_sub( L_tmp2, 2147483647 ) >= 0 ) + IF( GE_32( L_tmp2, 2147483647 )) { DTFS_setEngyHarm_fx( 2828, X_fx->upper_cut_off_freq_of_interest_fx,2828, X_fx->upper_cut_off_freq_fx, Ltemp_fx,add( 15, sub( n, exp1 )),&Qh, X_fx ); } @@ -3904,7 +3902,7 @@ void WIsyn_fx( DTFS_STRUCTURE_FX *CURRCW_DTFS_FX=DTFS_new_fx(); - IF (sub(PREVCW_FX.Q,CURR_CW_DTFS_FX->Q) < 0) + IF (LT_16(PREVCW_FX.Q,CURR_CW_DTFS_FX->Q)) { temp = sub(CURR_CW_DTFS_FX->Q, PREVCW_FX.Q); tmp = s_min(shr(CURR_CW_DTFS_FX->lag_fx,1),CURR_CW_DTFS_FX->nH_fx); @@ -3920,7 +3918,7 @@ void WIsyn_fx( } - IF (sub(CURR_CW_DTFS_FX->Q,PREVCW_FX.Q)<0) + IF (LT_16(CURR_CW_DTFS_FX->Q,PREVCW_FX.Q)) { temp = sub(PREVCW_FX.Q, CURR_CW_DTFS_FX->Q); tmp = s_min(shr(PREVCW_FX.lag_fx, 1),PREVCW_FX.nH_fx); @@ -3940,7 +3938,7 @@ void WIsyn_fx( alignment_fx = mult_r(*ph_offset_fx, shl(PREVCW_FX.lag_fx, 7)); /* confirmed I<2 by smv12.org, Q7 */ - IF (sub(flag,1)==0) + IF (EQ_16(flag,1)) alignment_fx = extract_l(L_shr(L_mult(alignment_fx, I), 1)) ; /* Q7 */ /* Calculating the expected alignment shift */ @@ -3969,7 +3967,7 @@ void WIsyn_fx( } - IF (sub(alignment_fx,shl(CURRCW_DTFS_FX->lag_fx, 7))>=0) + IF (GE_16(alignment_fx,shl(CURRCW_DTFS_FX->lag_fx, 7))) { temp=sub(alignment_fx, shl(CURRCW_DTFS_FX->lag_fx, 7)); tmp = shl(CURRCW_DTFS_FX->lag_fx, 7); @@ -4021,7 +4019,7 @@ void WIsyn_fx( - IF (sub(flag,2)==0) + IF (EQ_16(flag,2)) { L_temp = L_shr(L_mult(tmp_fx, I), 1); /* Q15 */ } @@ -4096,7 +4094,7 @@ Word16 ppp_extract_pitch_period_fx( { x=abs_s(ptr[i]); - if (sub(x,max)>0) + if (GT_16(x,max)) { max=x; move16(); @@ -4115,7 +4113,7 @@ Word16 ppp_extract_pitch_period_fx( { k=(j+l)%l; - if (sub(ptr[k],neg_max)<0) + if (LT_16(ptr[k],neg_max)) { neg_max=ptr[k]; move16(); @@ -4133,7 +4131,7 @@ Word16 ppp_extract_pitch_period_fx( { k=(j+l)%l; - if (sub(ptr[k],pos_max)>0) + if (GT_16(ptr[k],pos_max)) { pos_max=ptr[k]; move16(); @@ -4144,7 +4142,7 @@ Word16 ppp_extract_pitch_period_fx( } test(); - IF ((sub((l-1-s_max(spike_pos,spike_neg)),2)<=0) ||(sub(s_min(spike_pos,spike_neg),2)<=0)) + IF ((LE_16((l-1-s_max(spike_pos,spike_neg)),2))||(LE_16(s_min(spike_pos,spike_neg),2))) { *out_of_bound=1; move16(); @@ -4161,12 +4159,12 @@ Word16 ppp_extract_pitch_period_fx( range = shr(tmp,3);/* Q0 */ test(); - IF((sub(spike,range)<0) || (sub(add(spike,range),l)>=0)) + IF((LT_16(spike,range))||(GE_16(add(spike,range),l))) { /* need to grab from one lag before ensure that there is no array bound read */ - IF(sub(sub(L_FRAME,l),l) < 0) + IF(LT_16(sub(L_FRAME,l),l)) { *out_of_bound=1; move16(); @@ -4176,7 +4174,7 @@ Word16 ppp_extract_pitch_period_fx( move16(); } - IF(sub(spike,range)<0) + IF(LT_16(spike,range)) { tmp = add(l,sub(spike,range)); FOR(i=0; i= 0) + ELSE IF (GE_16(add(spike,range),l)) { tmp = sub(spike,range); FOR(i=0; i= 0) { - if (L_sub(L_temp,maxPosEn_fx)>0) + if (GT_32(L_temp,maxPosEn_fx)) { maxPosEn_fx = L_temp ; /* Q(1) */ } } ELSE { - if (L_sub(L_temp,maxNegEn_fx)>0) + if (GT_32(L_temp,maxNegEn_fx)) { maxNegEn_fx = L_temp ; /* Q(1) */ } @@ -4567,7 +4565,7 @@ static void c_fft_wi_fx(Word16 * farray_ptr_fx, Word16 size, Word16 stage, Word1 move16(); move16(); - IF (sub(j,i) > 0) + IF (GT_16(j,i)) { ftmp_fx = *(farray_ptr_fx + i); *(farray_ptr_fx + i) = *(farray_ptr_fx + j); @@ -4959,7 +4957,7 @@ Word32 getSpEngyFromResAmp_fx( DTFS_STRUCTURE_FX *X_fx,Word16 lband, Word16 hban en = L_deposit_l(0); - if (sub(hband,X_fx->upper_cut_off_freq_fx)==0) + if (EQ_16(hband,X_fx->upper_cut_off_freq_fx)) { hband = 0x2803; move16(); /* 4001.0/12800 in Q15 */ @@ -4981,7 +4979,7 @@ Word32 getSpEngyFromResAmp_fx( DTFS_STRUCTURE_FX *X_fx,Word16 lband, Word16 hban freq=extract_h(L_shl(Ltemp,11)); /* k*fdiff in Q15 */ test(); - IF (sub(freq,hband)<0 && sub(freq,lband)>=0) + IF (LT_16(freq,hband)&&GE_16(freq,lband)) { Lacc = L_add(0x10000000, 0); /* Re=1.0, Q28 */ k4=shl(k,2); /* k4=4*k */ @@ -5043,7 +5041,7 @@ Word32 getSpEngyFromResAmp_fx( DTFS_STRUCTURE_FX *X_fx,Word16 lband, Word16 hban } test(); - IF (X_fx->lag_fx%2==0 && sub(k,shr(X_fx->lag_fx,1))==0) + IF (X_fx->lag_fx%2==0 && EQ_16(k,shr(X_fx->lag_fx,1))) en=L_add(en,L_shr(Ltemp,1)); ELSE en=L_add(en,Ltemp); /* en in 2Q-13 */ @@ -5152,7 +5150,7 @@ void DTFS_poleFilter_fx( DTFS_STRUCTURE_FX *X_fx,Word16 *LPC, Word16 N, Word16 * move16(); } - if (sub(na, nb)<0) + if (LT_16(na, nb)) { nb=na; move16(); @@ -5163,7 +5161,7 @@ void DTFS_poleFilter_fx( DTFS_STRUCTURE_FX *X_fx,Word16 *LPC, Word16 N, Word16 * Qab[k] = add(sub(add(nb, 2), temp1),X_fx->Q); - if (sub(Qab[k], Qmin)<0) + if (LT_16(Qab[k], Qmin)) { Qmin = Qab[k]; move16(); @@ -5243,7 +5241,7 @@ void poleFilter_setup_fx(const Word16 *LPC, Word16 N, DTFS_STRUCTURE_FX X_fx, Wo move16(); } - if (sub(n1, n2)<0) + if (LT_16(n1, n2)) { n2=n1; move16(); @@ -5311,7 +5309,7 @@ Word32 DTFS_getEngy_band_wb_fx(DTFS_STRUCTURE_FX X_fx,Word16 lband, Word16 hband { freq_fx = L_mult(k, 12800); - if (L_sub(freq_fx, L_lband)>=0) + if (GE_32(freq_fx, L_lband)) { BREAK; } @@ -5321,7 +5319,7 @@ Word32 DTFS_getEngy_band_wb_fx(DTFS_STRUCTURE_FX X_fx,Word16 lband, Word16 hband FOR (k=1; k<=HalfLag; k++) { freq_fx = L_mult(k, 12800); - if (L_sub(freq_fx, L_hband)>=0) + if (GE_32(freq_fx, L_hband)) { BREAK; } diff --git a/lib_com/window.c b/lib_com/window.c index bfcff1b2a85cc76db2647d28df649695fa3f5a38..0e666e8a16e246660c2b3a898d497d52c0fd99bd 100644 --- a/lib_com/window.c +++ b/lib_com/window.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ @@ -7,8 +7,6 @@ #include "basop_util.h" #include "prot_fx.h" #include "stl.h" -#include "wmc_auto.h" - #define PI_HALF_0Q15 51472 /* ~=round(pi/2*2^15) */ #define PI2_15Q16 0x0006487F /* ~=round(2*PI*2^16) */ @@ -34,17 +32,17 @@ void ham_cos_window(Word16 *fh, /* o: 0Q15 */ assert( n1>=102 ); /* if n1 is too low -> overflow in div_l */ /* cte = PI2/(Float32)(2*n1 - 1); */ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF move16(); cte = L_deposit_l(div_l(PI2_10Q21,sub(shl(n1,1),1))); /*0Q15*/ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON cc = 0; FOR (i = 0; i < n1; i++) { /* fh_f[i] = 0.54f - 0.46f * (Float32)cos(cc); */ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF fh[i] = sub(P54_0Q15, mult_r(getCosWord16(round_fx(L_shl(cc,9))),P92_0Q15)); /*0Q15*/ move16(); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON cc = L_add(cc, cte); /*0Q15*/ } @@ -55,14 +53,14 @@ void ham_cos_window(Word16 *fh, /* o: 0Q15 */ move16(); add(n1,n2); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF FOR (i = n1; i < n1+n2; i++) { /* fh_f[i] = (Float32)cos(cc); */ fh[i] = shl(getCosWord16(round_fx(L_shl(cc,10))),1); /*0Q15*/ move16(); cc = L_add(cc, cte); } - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON return; diff --git a/lib_com/window_ola_fx.c b/lib_com/window_ola_fx.c index 9cf881ad37be12116715fe1bee7535e7508ea720..73905494cd2d3ee4326acb1587c68010f0335026 100644 --- a/lib_com/window_ola_fx.c +++ b/lib_com/window_ola_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "prot_fx.h" /* Function prototypes */ #include "rom_com_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - void sinq_fx( const Word16 tmp, /* i : sinus factor cos(tmp*i+phi) Q15*/ @@ -38,7 +36,7 @@ void sinq_fx( move16(); /* sin(x) approximated by (x-x^3/3!); Q15 */ - IF ( sub(abs_s(tmp),3) > 0 ) + IF ( GT_16(abs_s(tmp),3)) { /*A=(x[2]+x[0])/x[1]=2*cos(tmp); here approximated by 2*(1-tmp^2/2!) */ A32 = L_mult0(tmp,tmp); /*Q30 */ @@ -126,13 +124,13 @@ void window_ola_fx( /* rescaling for overlapp add */ - IF (sub(add(*Q_old,15),*Q_sig)>0) + IF (GT_16(add(*Q_old,15),*Q_sig)) { Copy_Scale_sig(OldauOut,OldauOut,L,sub(*Q_sig,add(*Q_old,15))); *Q_old=sub(*Q_sig,15); } - ELSE IF (sub(add(*Q_old,15),*Q_sig)<0) + ELSE IF (LT_16(add(*Q_old,15),*Q_sig)) { Scale_sig32(ImdctOut,L,sub(add(*Q_old,15),*Q_sig)); *Q_sig=add(*Q_old,15); @@ -151,7 +149,7 @@ void window_ola_fx( move16(); test(); - IF (sub(L,L_FRAME32k)==0 || sub(L,L_FRAME16k)==0 ) + IF (EQ_16(L,L_FRAME32k)||EQ_16(L,L_FRAME16k)) { decimate = 3; move16(); @@ -160,14 +158,14 @@ void window_ola_fx( n=R1_16-R2_16; move16(); - if(sub(L,L_FRAME32k)==0) + if(EQ_16(L,L_FRAME32k)) { n=2*N16_CORE_SW; move16(); } } - ELSE IF (sub(L,L_FRAME8k)==0) + ELSE IF (EQ_16(L,L_FRAME8k)) { decimate = 6; move16(); @@ -177,7 +175,7 @@ void window_ola_fx( move16(); } - ELSE IF (sub(L,512)==0) + ELSE IF (EQ_16(L,512)) { windecay48 = WINDECAY48_256; move16(); @@ -189,7 +187,7 @@ void window_ola_fx( move16(); } - ELSE IF (sub(L,256)==0) + ELSE IF (EQ_16(L,256)) { windecay48 = WINDECAY48_256; move16(); @@ -204,7 +202,7 @@ void window_ola_fx( paout=auOut-n; - IF( sub(use_bfi_win,1)==0 ) + IF( EQ_16(use_bfi_win,1)) { temp=sub(L,n); @@ -214,7 +212,7 @@ void window_ola_fx( sinq_fx(shr(tmp2,1), shr(tmp2,2), temp, SS2); - IF ( sub(L,L_FRAME32k)==0 ) + IF ( EQ_16(L,L_FRAME32k)) { p4=SS2+sub(shr(L,1),1); p1=wret2+sub(shr(L,1),n); @@ -328,7 +326,7 @@ void window_ola_fx( } } - IF ( sub( L, L_FRAME32k)==0 ) + IF ( EQ_16( L, L_FRAME32k)) { IF (use_bfi_win==0) @@ -582,10 +580,10 @@ void core_switching_OLA_fx( /* conversion from 12.8kHz to output_Fs */ - IF( sub(last_L_frame,L_FRAME)==0) + IF( EQ_16(last_L_frame,L_FRAME)) { /* resample filter memory */ - IF ( sub(output_frame,L_FRAME8k)==0 ) + IF ( EQ_16(output_frame,L_FRAME8k)) { Copy( synth_subfr_out + SWITCH_GAP_LENGTH_8k, tmp_buf_switch+ SWITCH_GAP_LENGTH_8k, NS2SA(output_Fs, DELAY_CLDFB_NS)); /* copy subframe to tmp buffer */ } @@ -607,7 +605,7 @@ void core_switching_OLA_fx( test(); test(); test(); - IF ( (sub(bwidth, NB) == 0 && L_sub(output_Fs, 16000) >= 0) || (sub(bwidth, NB) > 0 && L_sub(output_Fs, 16000) > 0) ) + IF ( (EQ_16(bwidth, NB)&&GE_32(output_Fs,16000))||(GT_16(bwidth,NB)&>_32(output_Fs,16000))) { /* mix cubic and CLDFB resampled buffers in case of resampling to higher frequency rates */ buf_offset = i_mult2(SWITCH_GAP_LENGTH_8k, delta); @@ -659,7 +657,7 @@ void core_switching_OLA_fx( test(); test(); test(); - IF ( (sub(bwidth, NB) == 0 && L_sub(output_Fs, 16000) >= 0) || (sub(bwidth, NB) > 0 && L_sub(output_Fs, 16000) > 0) ) + IF ( (EQ_16(bwidth, NB)&&GE_32(output_Fs,16000))||(GT_16(bwidth,NB)&>_32(output_Fs,16000))) { /* mix cubic and CLDFB resampled buffers in case of resampling to higher frequency rates */ buf_offset = i_mult2(SWITCH_GAP_LENGTH_8k, delta); @@ -692,7 +690,7 @@ void core_switching_OLA_fx( set16_fx(synth,0,tmp); - IF( sub(output_frame,L_FRAME32k)==0 ) + IF( EQ_16(output_frame,L_FRAME32k)) { pt=synth+tmp; diff --git a/lib_com/wtda_fx.c b/lib_com/wtda_fx.c index bb5deb2833e74e52c5184fcda90d61ce027af8ec..07e97ad71d65de33020aeb921516c1356daa85a5 100644 --- a/lib_com/wtda_fx.c +++ b/lib_com/wtda_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "cnst_fx.h" /* Common constants */ #include "rom_com_fx.h" /* Static table prototypes */ -#include "stl.h" -#include "wmc_auto.h" - /* required by wmc_tool */ +#include "stl.h" /* required by wmc_tool */ #include "prot_fx.h" /* required by wmc_tool */ #include "stat_com.h" @@ -90,10 +88,10 @@ void tcx_get_windows_mode1( ) { /* Left part */ - IF ( sub(left_mode,MIN_OVERLAP)==0) + IF ( EQ_16(left_mode,MIN_OVERLAP)) { test(); - IF ( sub(L,256)==0 || sub(L,512)==0 ) + IF ( EQ_16(L,256)||EQ_16(L,512)) { copy_win(left_win,R1_25-4*R2_25/7,small_overlap_25,R2_25/7,3*R2_25/7,1); } @@ -103,10 +101,10 @@ void tcx_get_windows_mode1( copy_win(left_win_int,R1_16-4*R2_16/7,small_overlap_int,R2_16/7,3*R2_16/7,1); } } - ELSE IF( sub(left_mode,HALF_OVERLAP)==0) + ELSE IF( EQ_16(left_mode,HALF_OVERLAP)) { test(); - IF ( sub(L,256)==0 || sub(L,512)==0 ) + IF ( EQ_16(L,256)||EQ_16(L,512)) { copy_win(left_win,R1_25-5*R2_25/7,half_overlap_25,3*R2_25/7,2*R2_25/7,1); } @@ -116,10 +114,10 @@ void tcx_get_windows_mode1( copy_win(left_win_int,R1_16-5*R2_16/7,half_overlap_int,3*R2_16/7,2*R2_16/7,1); } } - ELSE IF (sub(left_mode, ALDO_WINDOW)==0) /* ALDO */ + ELSE IF (EQ_16(left_mode, ALDO_WINDOW)) /* ALDO */ { test(); - IF ( sub(L,256)==0 || sub(L,512)==0 ) + IF ( EQ_16(L,256)||EQ_16(L,512)) { Copy(window_256kHz,left_win,R1_25); } @@ -136,10 +134,10 @@ void tcx_get_windows_mode1( /* Right part */ test(); - IF ( sub(right_mode,MIN_OVERLAP)==0 || sub(right_mode,TRANSITION_OVERLAP)==0) + IF ( EQ_16(right_mode,MIN_OVERLAP)||EQ_16(right_mode,TRANSITION_OVERLAP)) { test(); - IF ( sub(L,256)==0 || sub(L,512)==0 ) + IF ( EQ_16(L,256)||EQ_16(L,512)) { copy_win(right_win,3*R2_25/7,small_overlap_25,R2_25/7,3*R2_25/7,-1); } @@ -150,10 +148,10 @@ void tcx_get_windows_mode1( copy_win(right_win_int,3*R2_16/7,small_overlap_int,R2_16/7,3*R2_16/7,-1); } } - ELSE IF (sub(right_mode, HALF_OVERLAP)==0) + ELSE IF (EQ_16(right_mode, HALF_OVERLAP)) { test(); - IF ( sub(L,256)==0 || sub(L,512)==0 ) + IF ( EQ_16(L,256)||EQ_16(L,512)) { copy_win(right_win,2*R2_25/7,half_overlap_25,3*R2_25/7,2*R2_25/7,-1); } @@ -163,10 +161,10 @@ void tcx_get_windows_mode1( copy_win(right_win_int,2*R2_16/7,half_overlap_int,3*R2_16/7,2*R2_16/7,-1); } } - ELSE IF (sub(right_mode,ALDO_WINDOW)==0) + ELSE IF (EQ_16(right_mode,ALDO_WINDOW)) { test(); - IF ( sub(L,256)==0 || sub(L,512)==0 ) + IF ( EQ_16(L,256)||EQ_16(L,512)) { Copy(window_256kHz+R1_25,right_win,R2_25); } @@ -217,7 +215,7 @@ void wtda_fx( move16(); test(); - IF (sub(L,L_FRAME32k)==0 || sub(L,L_FRAME16k)==0 ) + IF (EQ_16(L,L_FRAME32k)||EQ_16(L,L_FRAME16k)) { decimate = 3; move16(); @@ -226,14 +224,14 @@ void wtda_fx( n=R1_16-R2_16; move16(); - if(sub(L,L_FRAME32k)==0) + if(EQ_16(L,L_FRAME32k)) { n=2*N16_CORE_SW; move16(); } } - ELSE IF (sub(L,L_FRAME8k)==0) + ELSE IF (EQ_16(L,L_FRAME8k)) { decimate = 6; move16(); @@ -255,14 +253,14 @@ void wtda_fx( { /* Rescale signals if Q are not identical */ - IF (sub(*Qold_wtda,*Q)>0) + IF (GT_16(*Qold_wtda,*Q)) { Copy_Scale_sig(old_wtda,old_wtda,L,sub(*Q,*Qold_wtda)); *Qold_wtda=*Q; move16(); } - ELSE IF (sub(*Qold_wtda,*Q)<0) + ELSE IF (LT_16(*Qold_wtda,*Q)) { Copy_Scale_sig(new_audio,new_audio,L,sub(*Qold_wtda,*Q)); *Q=*Qold_wtda; diff --git a/lib_dec/ACcontextMapping_dec.c b/lib_dec/ACcontextMapping_dec.c index f7b502c0987a58981ea38e7d891195656291c51b..04a6cc25623c16693da4ef532cd8dc5e59fa5dfe 100644 --- a/lib_dec/ACcontextMapping_dec.c +++ b/lib_dec/ACcontextMapping_dec.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -8,16 +8,10 @@ #include #include "options.h" #include "stl.h" -#include "wmc_auto.h" - - #include "rom_com_fx.h" #include "rom_dec_fx.h" #include "basop_util.h" #include "stl.h" -#include "wmc_auto.h" - - #include "cnst_fx.h" #include "prot_fx.h" @@ -65,7 +59,7 @@ Word16 ACcontextMapping_decode2_no_mem_s17_LC( /* Rate flag */ rateFlag = 0; move16(); - if (sub(nbbits, 400) > 0) + if (GT_16(nbbits, 400)) { rateFlag = 2 << NBITS_CONTEXT; move16(); @@ -93,7 +87,7 @@ Word16 ACcontextMapping_decode2_no_mem_s17_LC( lastnz = shl(n, 1); - IF (sub(lastnz, nt) > 0 || st->BER_detect) + IF (GT_16(lastnz, nt) || st->BER_detect) { st->BER_detect = 1; move16(); @@ -161,7 +155,7 @@ Word16 ACcontextMapping_decode2_no_mem_s17_LC( move16(); t = add(*ctx, rateFlag); - if (sub(idx, nt_half) > 0) + if (GT_16(idx, nt_half)) { t = add(t, 1 << NBITS_CONTEXT); } @@ -188,7 +182,7 @@ Word16 ACcontextMapping_decode2_no_mem_s17_LC( move16(); r = ari_decode_14bits_s17_ext(st, &as, ari_pk_s17_LC_ext[pki]); - IF (sub(r, VAL_ESC) < 0) + IF (LT_16(r, VAL_ESC)) { BREAK; } @@ -200,7 +194,7 @@ Word16 ACcontextMapping_decode2_no_mem_s17_LC( test(); test(); - IF ( ((sub(lsbs_bit_pos, -1) < 0 && sub(r, VAL_ESC) >= 0)) || (sub(lev, 14) > 0) ) + IF ( ((LT_16(lsbs_bit_pos, -1)&&GE_16(r,VAL_ESC)))||(GT_16(lev,14))) { x[a1_i] = 0; move16(); @@ -255,7 +249,7 @@ Word16 ACcontextMapping_decode2_no_mem_s17_LC( move16(); /* Update context for next 2-tuple */ - IF (sub(p1, p2) == 0) /* peak-peak or hole-hole context */ + IF (EQ_16(p1, p2)) /* peak-peak or hole-hole context */ { lev = sub(esc_nb, 1); if (lev > 0) t = add(12, lev); @@ -285,7 +279,7 @@ Word16 ACcontextMapping_decode2_no_mem_s17_LC( get_next_indice_tmp_fx(st, -(cbitsnew - 2)); /*detect overflow*/ - IF (sub(k, lastnz) != 0) + IF (NE_16(k, lastnz)) { rest_bits = add(rest_bits, nbbits_m2); /* Set bit-stream position to (start_bit_pos+nbbits-rest_bits) */ diff --git a/lib_dec/EvsRXlib.c b/lib_dec/EvsRXlib.c index f802202df0c4bb3906d7ab3367a45f495494e77b..54768aaf257e2e24f171c7e43cf9f98b7c5fea14 100644 --- a/lib_dec/EvsRXlib.c +++ b/lib_dec/EvsRXlib.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -13,8 +13,6 @@ #include "jbm_pcmdsp_fifo.h" #include "stl.h" -#include "wmc_auto.h" - #include "basop_util.h" #include "basop_util_jbm.h" @@ -87,28 +85,28 @@ EVS_RX_ERROR EVS_RX_Open(EVS_RX_HANDLE* phEvsRX, hEvsRX->samplesPerMs = shl(hEvsRX->samplesPerMs, add(divScaleFac, 1)); assert(hEvsRX->samplesPerMs == st->output_Fs_fx / 1000); - IF(L_sub(st->output_Fs_fx, 8000) == 0) + IF(EQ_32(st->output_Fs_fx, 8000)) { wss = 1; move16(); css = 1; move16(); } - ELSE IF(L_sub(st->output_Fs_fx, 16000) == 0) + ELSE IF(EQ_32(st->output_Fs_fx, 16000)) { wss = 2; move16(); css = 1; move16(); } - ELSE IF(L_sub(st->output_Fs_fx, 32000) == 0) + ELSE IF(EQ_32(st->output_Fs_fx, 32000)) { wss = 4; move16(); css = 2; move16(); } - ELSE IF(L_sub(st->output_Fs_fx, 48000) == 0) + ELSE IF(EQ_32(st->output_Fs_fx, 48000)) { wss = 6; move16(); @@ -219,7 +217,7 @@ EVS_RX_FeedFrame(EVS_RX_HANDLE hEvsRX, return EVS_RX_JBM_ERROR; } test(); - IF(sub(partialCopyFrameType, RF_NO_DATA) != 0 && partialCopyOffset != 0) + IF(NE_16(partialCopyFrameType, RF_NO_DATA)&&partialCopyOffset!=0) { /* create data unit for partial copy in the frame */ dataUnit = JB4_AllocDataUnit(hEvsRX->hJBM); @@ -281,7 +279,7 @@ EVS_RX_GetSamples(EVS_RX_HANDLE hEvsRX, move16(); /* make sure that the FIFO after decoder/scaler contains at least one sound card frame (i.e. 20ms) */ - WHILE(sub(pcmdsp_fifo_nReadableSamples(hEvsRX->hFifoAfterTimeScaler), soundCardFrameSize) < 0) + WHILE(LT_16(pcmdsp_fifo_nReadableSamples(hEvsRX->hFifoAfterTimeScaler), soundCardFrameSize)) { extBufferedSamples = pcmdsp_fifo_nReadableSamples( hEvsRX->hFifoAfterTimeScaler ); extBufferedTime_ms = L_deposit_l(idiv1616U(extBufferedSamples, hEvsRX->samplesPerMs)); @@ -293,7 +291,7 @@ EVS_RX_GetSamples(EVS_RX_HANDLE hEvsRX, { return EVS_RX_JBM_ERROR; } - if(sub(maxScaling, 20) > 0) + if(GT_16(maxScaling, 20)) { maxScaling = 20; move16(); @@ -301,7 +299,7 @@ EVS_RX_GetSamples(EVS_RX_HANDLE hEvsRX, maxScaling = i_mult2(maxScaling, hEvsRX->samplesPerMs); assert(maxScaling >= 0); /* avoid time scaling multiple times in one sound card slot */ - IF(sub(scale, 100) != 0) + IF(NE_16(scale, 100)) { if( timeScalingDone != 0 ) { @@ -315,10 +313,10 @@ EVS_RX_GetSamples(EVS_RX_HANDLE hEvsRX, /* copy bitstream into decoder state */ IF(dataUnit) { - IF( sub(st->codec_mode,0) != 0 ) + IF( NE_16(st->codec_mode,0)) { tmp = 0; - if (sub(dataUnit->partial_frame,1)==0) + if (EQ_16(dataUnit->partial_frame,1)) { tmp = 1; } @@ -354,8 +352,8 @@ EVS_RX_GetSamples(EVS_RX_HANDLE hEvsRX, } /* run the main decoding routine */ - push_wmops("evs_dec"); - IF( sub(st->codec_mode, MODE1) == 0 ) + SUB_WMOPS_INIT("evs_dec"); + IF( EQ_16(st->codec_mode, MODE1)) { IF( st->Opt_AMR_WB_fx ) { @@ -366,13 +364,13 @@ EVS_RX_GetSamples(EVS_RX_HANDLE hEvsRX, evs_dec_fx( st, pcmBuf, FRAMEMODE_NORMAL ); } } - ELSE IF( sub(st->codec_mode, MODE2) == 0 ) + ELSE IF( EQ_16(st->codec_mode, MODE2)) { IF(st->bfi_fx == 0) { evs_dec_fx(st, pcmBuf, FRAMEMODE_NORMAL); } - ELSE IF ( sub(st->bfi_fx,2) == 0 ) + ELSE IF ( EQ_16(st->bfi_fx,2)) { evs_dec_fx(st, pcmBuf, FRAMEMODE_FUTURE); /* FRAMEMODE_FUTURE */ } @@ -381,12 +379,12 @@ EVS_RX_GetSamples(EVS_RX_HANDLE hEvsRX, evs_dec_fx(st, pcmBuf, FRAMEMODE_MISSING); } } - pop_wmops(); + END_SUB_WMOPS; test(); - IF( sub(st->codec_mode, MODE1) == 0 || sub(st->codec_mode, MODE2) == 0 ) + IF( EQ_16(st->codec_mode, MODE1)||EQ_16(st->codec_mode,MODE2)) { /* increase the counter of initialization frames */ - if( sub(st->ini_frame_fx, MAX_FRAME_COUNTER) < 0 ) + if( LT_16(st->ini_frame_fx, MAX_FRAME_COUNTER)) { st->ini_frame_fx = add(st->ini_frame_fx, 1); } @@ -412,10 +410,10 @@ EVS_RX_GetSamples(EVS_RX_HANDLE hEvsRX, } /* limit scale to range supported by time scaler */ - if(sub(scale, APA_MIN_SCALE) < 0) + if(LT_16(scale, APA_MIN_SCALE)) scale = APA_MIN_SCALE; move16(); - if(sub(scale, APA_MAX_SCALE) > 0) + if(GT_16(scale, APA_MAX_SCALE)) scale = APA_MAX_SCALE; move16(); /* apply time scaling on decoded/concealed samples */ @@ -558,11 +556,11 @@ static Word16 isSidFrame( Word16 size ) ret = 0; move16(); - if(sub(size, SID_1k75 / 50) == 0) + if(EQ_16(size, SID_1k75 / 50)) { ret = 1; /* AMR-WB SID */ move16(); } - if(sub(size, SID_2k40 / 50) == 0) + if(EQ_16(size, SID_2k40 / 50)) { ret = 1; /* EVS SID */ move16(); } diff --git a/lib_dec/EvsRXlib.h b/lib_dec/EvsRXlib.h index 701191fbcd48e928696636cdb2502d5a836f6782..765e171a21d2cf70ed00316edf7ffecd814d8c22 100644 --- a/lib_dec/EvsRXlib.h +++ b/lib_dec/EvsRXlib.h @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #ifndef EvsRXLIB_H diff --git a/lib_dec/FEC_HQ_core_fx.c b/lib_dec/FEC_HQ_core_fx.c index 6bf7f3ea733434f8c5938200cd9e423c81157fe4..bb875c1c6e5f911af0c7a2292034871288415455 100644 --- a/lib_dec/FEC_HQ_core_fx.c +++ b/lib_dec/FEC_HQ_core_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -7,8 +7,6 @@ #include "cnst_fx.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - #include "prot_fx.h" #include "rom_com_fx.h" @@ -146,7 +144,7 @@ void HQ_FEC_processing_fx( tmp_fx = div_s(shl(tmp_fx, exp1), shl(st_fx->energy_MA_Curr_fx[0], exp2));/*15 + exp1 - exp2*/ energy_diff_fx = shl(tmp_fx, sub(sub(exp2, exp1), 5));/*10*/ test(); - IF ((sub(energy_diff_fx, 1024) < 0) && (is_transient==0)) /* First erasure frame */ + IF ((LT_16(energy_diff_fx, 1024))&&(is_transient==0)) /* First erasure frame */ { mute_start = 5; move16(); @@ -158,17 +156,17 @@ void HQ_FEC_processing_fx( } test(); test(); - if( sub(st_fx->prev_old_bfi_fx, 1) == 0 && sub(st_fx->nbLostCmpt, 1) == 0 && sub(output_frame, L_FRAME8k) == 0 ) + if( EQ_16(st_fx->prev_old_bfi_fx, 1)&&EQ_16(st_fx->nbLostCmpt,1)&&EQ_16(output_frame,L_FRAME8k)) { st_fx->nbLostCmpt = add(st_fx->nbLostCmpt, 1); } /* Frequency-domain FEC */ - IF ( sub(st_fx->nbLostCmpt, 1) == 0 ) /* First erasure frame */ + IF ( EQ_16(st_fx->nbLostCmpt, 1)) /* First erasure frame */ { IF ( is_transient == 0 ) { - IF (sub(energy_diff_fx, 1024) < 0) + IF (LT_16(energy_diff_fx, 1024)) { FOR (i=0; i < output_frame; i++) { @@ -193,7 +191,7 @@ void HQ_FEC_processing_fx( { FOR (sfm = 0; sfm < HQ_FEC_SIGN_SFM; sfm++) { - IF (sub(st_fx->prev_sign_switch_fx[sfm], HQ_FEC_SIGN_THRES) >= 0) + IF (GE_16(st_fx->prev_sign_switch_fx[sfm], HQ_FEC_SIGN_THRES)) { FOR (i = 0; i < HQ_FEC_BAND_SIZE; i++) { @@ -207,7 +205,7 @@ void HQ_FEC_processing_fx( { FOR (sfm = 0; sfm < HQ_FEC_SIGN_SFM; sfm++) { - IF (sub(st_fx->prev_sign_switch_fx[sfm], HQ_FEC_SIGN_THRES_TRANS) >= 0) + IF (GE_16(st_fx->prev_sign_switch_fx[sfm], HQ_FEC_SIGN_THRES_TRANS)) { FOR (i = 0; i < HQ_FEC_BAND_SIZE; i++) { @@ -270,7 +268,7 @@ void HQ_FEC_processing_fx( ELSE /* st_fx->nbLostCmpt > 1 */ { test(); - IF( sub(energy_diff_fx, 1024) < 0 && is_transient == 0 ) + IF( LT_16(energy_diff_fx, 1024)&&is_transient==0) { num_pgf = 4; move16(); @@ -283,7 +281,7 @@ void HQ_FEC_processing_fx( Num_sb_bwe = num_Sb; move16(); - IF ( sub(st_fx->nbLostCmpt, 2) == 0 ) + IF ( EQ_16(st_fx->nbLostCmpt, 2)) { FOR ( i=0; inbLostCmpt, mute_start) >= 0 ) + IF( GE_16(st_fx->nbLostCmpt, mute_start)) { /* Scaling */ FOR ( i=0; i < output_frame; i++ ) @@ -333,7 +331,7 @@ void HQ_FEC_processing_fx( extract_h(L_shl(norm_values_fx[0], exp2)));/*15 + (5 + exp1 - 16) - (12 + exp2 - 16)*/ tmp_fx = shl(tmp_fx, add(6, sub(exp2, exp1)));/*14*/ - if (sub(tmp_fx, 16384) > 0) + if (GT_16(tmp_fx, 16384)) { tmp_fx = 16384; move16(); @@ -426,11 +424,11 @@ void HQ_FEC_Mem_update_fx( } } - IF(sub(output_frame, L_FRAME8k) == 0) + IF(EQ_16(output_frame, L_FRAME8k)) { /* if LR MDCT core is used, recalculate norms from decoded MDCT spectrum (using code from hq_hr_enc_fx()) */ test(); - IF ( ( sub(hqswb_clas, HQ_HVQ) == 0 ) || ( sub(hq_core_type, LOW_RATE_HQ_CORE) == 0 ) ) + IF ( ( EQ_16(hqswb_clas, HQ_HVQ))||(EQ_16(hq_core_type,LOW_RATE_HQ_CORE))) { /* First group */ logqnorm_fx(t_audio_q_fx, 12, ynrm, 32, WID_G1, (hqswb_clas == HQ_HVQ)); @@ -479,7 +477,7 @@ void HQ_FEC_Mem_update_fx( } test(); test(); - IF((c_switching_flag)||((sub(st_fx->last_core_fx, ACELP_CORE) == 0)&&(sub(st_fx->core_fx, HQ_CORE) == 0))) + IF((c_switching_flag)||((EQ_16(st_fx->last_core_fx, ACELP_CORE))&&(EQ_16(st_fx->core_fx,HQ_CORE)))) { FOR (i=0; idiff_energy_fx = shl(st_fx->diff_energy_fx, sub(11, exp));/*11*/ /* Classify the stationary mode : 12% */ - IF (sub(st_fx->diff_energy_fx, ED_THRES_12P_fx) < 0) + IF (LT_16(st_fx->diff_energy_fx, ED_THRES_12P_fx)) { stat_mode_curr = 1; move16(); @@ -521,7 +519,7 @@ void HQ_FEC_Mem_update_fx( } /* Apply Hysteresis to prevent frequent mode changing */ - IF(sub(st_fx->stat_mode_old_fx, stat_mode_curr) == 0) + IF(EQ_16(st_fx->stat_mode_old_fx, stat_mode_curr)) { st_fx->stat_mode_out_fx = stat_mode_curr; move16(); @@ -536,7 +534,7 @@ void HQ_FEC_Mem_update_fx( Min_value = L_deposit_l(100); FOR (i=0; i 0) + IF(GT_32(Min_value, ynrm[i])) { Min_value = ynrm[i]; move16(); @@ -554,7 +552,7 @@ void HQ_FEC_Mem_update_fx( FOR (i=0; i<8; i++) { L_tmp = L_abs(t_audio_q_fx[i]); - IF (L_sub(Max_coeff_fx, L_tmp) < 0) + IF (LT_32(Max_coeff_fx, L_tmp)) { Max_coeff_fx = L_add(L_tmp, 0); Max_ind = i; @@ -599,13 +597,13 @@ void HQ_FEC_Mem_update_fx( test(); test(); test(); - IF ((sub(Min_ind, 5) < 0) && (sub(abs_s(sub(Min_ind, st_fx->old_Min_ind_fx)), 2) < 0) &&(sub(st_fx->diff_energy_fx, ED_THRES_90P_fx) < 0)&&(!st_fx->bfi_fx) && (!st_fx->prev_bfi_fx)&&(!st_fx->prev_old_bfi_fx) + IF ((LT_16(Min_ind, 5))&&(LT_16(abs_s(sub(Min_ind,st_fx->old_Min_ind_fx)),2))&&(LT_16(st_fx->diff_energy_fx,ED_THRES_90P_fx))&&(!st_fx->bfi_fx)&&(!st_fx->prev_bfi_fx)&&(!st_fx->prev_old_bfi_fx) &&(!is_transient)&&(!st_fx->old_is_transient_fx[1]) && (st_fx->prev_last_core_fx==HQ_CORE) && (st_fx->last_core_fx==HQ_CORE)) { st_fx->phase_mat_flag_fx = 1; move16(); test(); - if ((Min_ind == 0)&&(sub(Max_ind, 3) < 0)) + if ((Min_ind == 0)&&(LT_16(Max_ind, 3))) { st_fx->phase_mat_flag_fx = 0; move16(); @@ -693,7 +691,7 @@ static Word16 find_best_delay_fx( L_tmp1 = Mult_32_32(L_shl(Rxy_fx[d1], exp1), L_shl(min_corr_fx, exp2)); L_tmp2 = Mult_32_32(L_shl(Ryy_fx[d1], exp1), L_shl(min_sq_cross_fx, exp2)); - IF ( L_sub(L_tmp1, L_tmp2) >= 0) + IF ( GE_32(L_tmp1, L_tmp2)) { d1m = d1; move16(); @@ -726,7 +724,7 @@ static Word16 find_best_delay_fx( *false_flag = 0; move16(); test(); - if (sub(tmp, 8192) < 0 || sub(tmp, 24576) > 0) + if (LT_16(tmp, 8192)||GT_16(tmp,24576)) { *false_flag = 1; move16(); @@ -783,7 +781,7 @@ static Word16 Search_Max_Corr_fx( min_d1 = s_max(mind1, tmp1); max_d1 = s_min(maxd1, tmp2); pos2 = find_best_delay_fx(mu_o_fx, in_fx, min_d1, max_d1, lin, delta2, &false_flag); - IF (sub(mind1, tmp1) > 0) + IF (GT_16(mind1, tmp1)) { pos = pos2; move16(); @@ -822,7 +820,7 @@ static Word16 Search_Max_Corr_fx( max_d1 = s_min(maxd1, tmp2); pos2 = find_best_delay_fx(mu_o_fx, in_fx, min_d1, max_d1, lin, delta2, &false_flag); - IF (sub(mind1, tmp1) > 0 ) + IF (GT_16(mind1, tmp1)) { pos = pos2; move16(); @@ -872,7 +870,7 @@ Word16 FEC_phase_matching_fx( FOR (i=0; i 0)||(sub(mean_en_high_fx, 16) < 0)) + IF ((GT_16(mean_en_high_fx, 64))||(LT_16(mean_en_high_fx,16))) { oldout_pha_idx = 1; move16(); @@ -1004,7 +1002,7 @@ void FEC_phase_matching_nextgood_fx( move16(); } - IF (sub(oldout_pha_idx, 1) == 0) + IF (EQ_16(oldout_pha_idx, 1)) { /* Use phase matching and overlapping with the Oldauout*/ /* Windowing */ @@ -1056,7 +1054,7 @@ void FEC_phase_matching_burst_fx( FOR (i=0; inbLostCmpt, 1) == 0)&&(sub(st_fx->phase_mat_flag_fx, 1) == 0)&&(sub(st_fx->phase_mat_next_fx, 0) == 0) ) + IF( (EQ_16(st_fx->nbLostCmpt, 1))&&(EQ_16(st_fx->phase_mat_flag_fx,1))&&(EQ_16(st_fx->phase_mat_next_fx,0))) { IF (FEC_phase_matching_fx(st_fx, wtda_audio_fx, out_fx, st_fx->old_out_fx, st_fx->old_out_pha_fx) ) { @@ -1472,7 +1470,7 @@ void time_domain_FEC_HQ_fx( move16(); } } - ELSE IF((sub(st_fx->prev_bfi_fx, 1) == 0)&&(st_fx->bfi_fx == 0) &&(sub(st_fx->phase_mat_next_fx, 1) == 0)) + ELSE IF((EQ_16(st_fx->prev_bfi_fx, 1))&&(st_fx->bfi_fx==0)&&(EQ_16(st_fx->phase_mat_next_fx,1))) { FEC_phase_matching_nextgood_fx( wtda_audio_fx, out_fx, st_fx->old_out_fx, st_fx->old_out_pha_fx, mean_en_high_fx); @@ -1481,7 +1479,7 @@ void time_domain_FEC_HQ_fx( *Q_synth = 0; move16(); } - ELSE IF((sub(st_fx->prev_bfi_fx, 1) == 0)&&(sub(st_fx->bfi_fx, 1) == 0) &&(sub(st_fx->phase_mat_next_fx, 1) == 0)) + ELSE IF((EQ_16(st_fx->prev_bfi_fx, 1))&&(EQ_16(st_fx->bfi_fx,1))&&(EQ_16(st_fx->phase_mat_next_fx,1))) { FEC_phase_matching_burst_fx( wtda_audio_fx, out_fx, st_fx->old_out_fx, st_fx->old_out_pha_fx, st_fx->prev_oldauOut_fx); st_fx->phase_mat_next_fx = 1; @@ -1493,15 +1491,15 @@ void time_domain_FEC_HQ_fx( { /*n4 = (short)(N_LEAD_MDCT*(float)(output_frame/20));*/ test(); - IF (st_fx->bfi_fx == 0 && sub(st_fx->prev_bfi_fx, 1) == 0) + IF (st_fx->bfi_fx == 0 && EQ_16(st_fx->prev_bfi_fx, 1)) { test(); - IF((sub(st_fx->stat_mode_out_fx, 1) == 0) || (sub(st_fx->diff_energy_fx, ED_THRES_50P_fx) < 0))/* Q11 */ + IF((EQ_16(st_fx->stat_mode_out_fx, 1))||(LT_16(st_fx->diff_energy_fx,ED_THRES_50P_fx)))/* Q11 */ { Word16 tmp; tmp = 0; - if( sub(st_fx->old_bfi_cnt_fx,1) > 0 ) + if( GT_16(st_fx->old_bfi_cnt_fx,1)) { tmp = 1; } @@ -1509,7 +1507,7 @@ void time_domain_FEC_HQ_fx( *Q_synth = 0; move16(); } - ELSE IF(sub(st_fx->old_bfi_cnt_fx, 1) > 0) + ELSE IF(GT_16(st_fx->old_bfi_cnt_fx, 1)) { Next_good_after_burst_erasures_fx( wtda_audio_fx, out_fx, st_fx->old_out_fx, N_LEAD_NB ); *Q_synth = 0; @@ -1525,7 +1523,7 @@ void time_domain_FEC_HQ_fx( ELSE /* if(st->bfi_fx == 1) */ { test(); - IF( (sub(st_fx->stat_mode_out_fx, 1) == 0) || (sub(st_fx->diff_energy_fx, ED_THRES_50P_fx) < 0 )) + IF( (EQ_16(st_fx->stat_mode_out_fx, 1))||(LT_16(st_fx->diff_energy_fx,ED_THRES_50P_fx))) { /* if( window_ola_bfi( wtda_audio, out, st->oldIMDCTout, st->old_out, output_frame, st->prev_oldauOut, N_LEAD_NB) ) */ IF( Repetition_smoothing_fx( wtda_audio_fx, out_fx, st_fx->oldIMDCTout_fx, st_fx->old_out_fx, output_frame, st_fx->prev_oldauOut_fx, N_LEAD_NB) ) @@ -1569,7 +1567,7 @@ void Next_good_after_burst_erasures_fx( move16(); FOR (i=0; i= 0) /*currently est_mus_content only calculated for SWB and FB */ + IF (GE_16(output_frame, L_FRAME32k)) /*currently est_mus_content only calculated for SWB and FB */ { roundEstMusContent = 0; move16(); - if (sub(est_mus_content, FEC_HQ_ECU_POINT5) >= 0) /* est_mus_content is in [0.0, 1.0]. */ + if (GE_16(est_mus_content, FEC_HQ_ECU_POINT5)) /* est_mus_content is in [0.0, 1.0]. */ { roundEstMusContent = 1; move16(); @@ -257,7 +255,7 @@ static void trans_ana_fx( att_per_frame = sub(ATT_PER_FRAME, 1); /* in Q0 */ } - IF (sub(burst_len, burst_phdith_thresh) > 0) + IF (GT_16(burst_len, burst_phdith_thresh)) { /* increase degree of dither */ #if BURST_PHDITH_RAMPUP_LEN != 2 @@ -265,7 +263,7 @@ static void trans_ana_fx( #endif *ph_dith = 32767; /* 1.0 in Q15. N.B. 2*PI is not included. */ move16(); tmp16 = sub(burst_len, burst_phdith_thresh); - if (sub(tmp16, burst_phdith_rampup_len) < 0) + if (LT_16(tmp16, burst_phdith_rampup_len)) { *ph_dith = 16384; /* 0.5 in Q15. N.B. 2*PI is not included. */ move16(); } @@ -273,7 +271,7 @@ static void trans_ana_fx( attDegreeFrames = 0; move16(); - IF (sub(burst_len, burst_att_thresh) > 0) + IF (GT_16(burst_len, burst_att_thresh)) { att_always = 1; move16(); @@ -288,7 +286,7 @@ static void trans_ana_fx( * If attDegreeFrames is greater than 15, it means there are more than 15 successive * bad frames. In this case, no matter what to do, the sound quality will be bad. */ - if (sub(attDegreeFrames, OFF_FRAMES_LIMIT) > 0) + if (GT_16(attDegreeFrames, OFF_FRAMES_LIMIT)) { attDegreeFrames = OFF_FRAMES_LIMIT; /* Hard limit the no. of frames */ move16(); } @@ -299,7 +297,7 @@ static void trans_ana_fx( test(); test(); - IF (sub(burst_len, 1) <= 0 || (sub(burst_len, 2) == 0 && last_fec != 0)) + IF (LE_16(burst_len, 1)||(EQ_16(burst_len,2)&&last_fec!=0)) { set16_fx(alpha, 32767, Lgw_max); @@ -314,7 +312,7 @@ static void trans_ana_fx( windowing(pXfp, xfp_right, w_hamm, 0, Ltrana_2); /* 4th quarter */ /* spectrum */ - IF (sub(output_frame, L_FRAME48k) == 0) + IF (EQ_16(output_frame, L_FRAME48k)) { fft3_fx(xfp_left, xfp_left, Ltrana); fft3_fx(xfp_right, xfp_right, Ltrana); @@ -342,7 +340,7 @@ static void trans_ana_fx( { test(); test(); - IF (sub(burst_len, 1) <= 0 || (sub(burst_len, 2) == 0 && last_fec != 0)) + IF (LE_16(burst_len, 1)||(EQ_16(burst_len,2)&&last_fec!=0)) { lowerEdge = *pGw++; move16(); @@ -369,7 +367,7 @@ static void trans_ana_fx( acc = Sqrt_l(acc, &expo); /* -headroom+31+expo */ expo = sub(add(expo, 31), headroom); - if ( sub(s_and(expo, 1), 1) == 0) + if ( EQ_16(s_and(expo, 1), 1)) { acc = Mult_32_16(acc, 23170); /* 1/sqrt(2) in Q15 */ } @@ -383,14 +381,14 @@ static void trans_ana_fx( move16(); Mpy_32_16_ss(*pGrPowLeft, THRESH_TR_LIN_BY2_FX, &acc, &lsb); /* To facilitate fixed-point implementation, divide threshold by 2. */ acc = L_or(L_shl(acc,16), L_and(0xffffL,lsb)); /* Equivalent to concatenate acc and lsb, and then down shift by 16 bits. */ - if (L_sub(*pGrPowRight, acc) > 0) /* gr_pow_right > thres_tr_lin*gr_pow_left */ + if (GT_32(*pGrPowRight, acc)) /* gr_pow_right > thres_tr_lin*gr_pow_left */ { tr_dec[k] = 1; move16(); } Mpy_32_16_ss(*pGrPowRight, THRESH_TR_LIN_BY2_FX, &acc, &lsb); acc = L_or(L_shl(acc,16), L_and(0xffffL,lsb)); /* Equivalent to concatenate acc and lsb, and then down shift by 16 bits. */ - if (L_sub(*pGrPowLeft, acc) > 0) /* gr_pow_left > thres_tr_lin*gr_pow_right */ + if (GT_32(*pGrPowLeft, acc)) /* gr_pow_left > thres_tr_lin*gr_pow_right */ { tr_dec[k] = 1; move16(); @@ -405,9 +403,9 @@ static void trans_ana_fx( #endif att_val = 32767; move16(); - IF (L_sub(*pGrPowRight, 0) > 0) + IF (GT_32(*pGrPowRight, 0)) { - IF (L_sub(*pGrPowRight, *pGrPowLeft) < 0) /* i.e., (gr_pow_right/gr_pow_left) < 1.0 */ + IF (LT_32(*pGrPowRight, *pGrPowLeft)) /* i.e., (gr_pow_right/gr_pow_left) < 1.0 */ { /* Compute sqrt(grp_pow_chg), where grp_pow_chg = gr_pow_right/gr_pow_left. */ tmp16 = ratio(*pGrPowRight, *pGrPowLeft, &expo); /* tmp16 in Q14 */ @@ -448,7 +446,7 @@ static void trans_ana_fx( * either ATT_PER_FRAME-1 or ATT_PER_FRAME and nothing else. This * means only 2 tables of size=(OFF_FRAMES_LIMIT+1) each are required. * To take square root into account, it is divided by 20 instead of 10. */ - IF (sub(att_per_frame, ATT_PER_FRAME) == 0) /* Select the corresponding lookup-table. */ + IF (EQ_16(att_per_frame, ATT_PER_FRAME)) /* Select the corresponding lookup-table. */ { att_val = POW_ATT_TABLE0[attDegreeFrames]; /* 10^(-attDegreeFrames*(ATT_PER_FRAME)/20) */ move16(); } @@ -458,7 +456,7 @@ static void trans_ana_fx( } mag_chg[k] = mult_r(mag_chg_1st[k], att_val); /* Q15 */ - if (sub(burst_len, BETA_MUTE_THR) > 0) + if (GT_16(burst_len, BETA_MUTE_THR)) { *beta_mute = shr(*beta_mute, 1); } @@ -468,7 +466,7 @@ static void trans_ana_fx( acc = L_sub(1073741824, L_mult0(alpha[k], alpha[k])); acc = Sqrt_l(acc, &expo); expo = add(30, add(31, expo)); - if (sub(s_and(expo, 1), 1) == 0) + if (EQ_16(s_and(expo, 1), 1)) { acc = Mult_32_16(acc, 23170); /* 1/sqrt(2) in Q15 */ } @@ -476,11 +474,11 @@ static void trans_ana_fx( beta[k] = mult_r(*beta_mute, round_fx(L_shl(acc, sub(31, expo)))); move16(); - IF (sub(k, LGW32K-1) >= 0) + IF (GE_16(k, LGW32K-1)) { beta[k] = mult_r(beta[k], 3277); /* 0.1 in Q15 */ } - ELSE IF (sub(k, LGW16K-1) >= 0) + ELSE IF (GE_16(k, LGW16K-1)) { beta[k] = mult_r(beta[k], 16384); /* 0.5 in Q15 */ } @@ -564,7 +562,7 @@ static void peakfinder_fx( minimum_fx(x, len, &minMag); pInd = indarr; - IF (sub(len, 2) > 0) + IF (GT_16(len, 2)) { /* Set initial parameters for loop */ tempMag = minMag; @@ -586,11 +584,11 @@ static void peakfinder_fx( xAt1 = *pX++; move16(); xAt2 = *pX--; /* After decrement, pX points to x[1]. */ move16(); - IF (sub(xAt0, xAt1) >= 0) + IF (GE_16(xAt0, xAt1)) { ii = -1; move16(); - IF (sub(xAt1, xAt2) >= 0) /* x[1] is not extremum -> overwrite with x[0] */ + IF (GE_16(xAt1, xAt2)) /* x[1] is not extremum -> overwrite with x[0] */ { *pX = xAt0; /* x[1] = x[0] */ move16(); tmp16 = *pInd++; @@ -603,7 +601,7 @@ static void peakfinder_fx( ELSE /* First point is smaller than the second */ { ii = 0; - IF (sub(xAt1, xAt2) < 0) /* x[1] is not extremum -> overwrite with x[0] */ + IF (LT_16(xAt1, xAt2)) /* x[1] is not extremum -> overwrite with x[0] */ { *pX = xAt0; /* x[1] = x[0] */ move16(); tmp16 = *pInd++; @@ -623,14 +621,14 @@ static void peakfinder_fx( ii = add(ii, 1); /* This is a peak */ /* Make sure we don't iterate past the length of our vector */ - IF (sub(ii, lenMinus1) >= 0) + IF (GE_16(ii, lenMinus1)) { BREAK; } /*Reset peak finding if we had a peak and the next peak is bigger than the last or the left min was small enough to reset.*/ - IF (sub(foundPeak,0) > 0) + IF (GT_16(foundPeak,0)) { tempMag = minMag; move16(); @@ -640,9 +638,9 @@ static void peakfinder_fx( /* Found new peak that was larger than temp mag and selectivity larger than the minimum to its left. */ - IF (sub(*(++pX), tempMag) > 0) + IF (GT_16(*(++pX), tempMag)) { - IF ( sub(*pX, threshold) > 0) /* threshold = leftMin + sel */ + IF ( GT_16(*pX, threshold)) /* threshold = leftMin + sel */ { tempLoc = ii; move16(); @@ -657,7 +655,7 @@ static void peakfinder_fx( /* Come down at least sel from peak */ IF (foundPeak == 0) { - IF (sub(tempMag, add(sel, *pX)) > 0) + IF (GT_16(tempMag, add(sel, *pX))) { foundPeak = 1; /* We have found a peak */ move16(); leftMin = *pX; @@ -671,7 +669,7 @@ static void peakfinder_fx( } IF (foundPeak == 0) /* The above IF-block has not found the peak yet. */ { - IF (sub(*pX, leftMin) < 0)/* New left minimum */ + IF (LT_16(*pX, leftMin))/* New left minimum */ { leftMin = *pX; move16(); @@ -681,9 +679,9 @@ static void peakfinder_fx( } /* Check end point */ - IF (sub(x[lenMinus1], tempMag) > 0) + IF (GT_16(x[lenMinus1], tempMag)) { - IF (sub(x[lenMinus1], threshold) > 0) /* threshold = leftMin + sel */ + IF (GT_16(x[lenMinus1], threshold)) /* threshold = leftMin + sel */ { peakLoc[*cInd] = lenMinus1; move16(); @@ -696,7 +694,7 @@ static void peakfinder_fx( } IF (foundPeak == 0) /* Check if we still need to add the last point */ { - IF (sub(tempMag, minMag) > 0) + IF (GT_16(tempMag, minMag)) { peakLoc[*cInd] = tempLoc; move16(); @@ -718,7 +716,7 @@ static void peakfinder_fx( { xInd = 1; move16(); - if (sub(x[0], x[1]) > 0) + if (GT_16(x[0], x[1])) { xInd = 0; move16(); @@ -726,7 +724,7 @@ static void peakfinder_fx( peakMag[0] = x[xInd]; move16(); - IF (sub(peakMag[0], add(minMag, sel)) > 0) + IF (GT_16(peakMag[0], add(minMag, sel))) { plocs[0] = *(indarr + xInd); move16(); @@ -798,10 +796,10 @@ static Word16 imax_fx( /* o: The location, relative to the middle of the 3 given /* For both edges (left and right), the extremum found above may be minimum. * It needs to reject the minimum. */ - IF (sub(special,0) != 0) /* Either edge specical case. */ + IF (NE_16(special,0)) /* Either edge specical case. */ { edge = 0x7fff; /* 1 in Q15 for the right edge special case */ move16(); - if (sub(special,0) < 0) + if (LT_16(special,0)) { edge = 0; /* Left edge special case */ move16(); } @@ -812,9 +810,9 @@ static Word16 imax_fx( /* o: The location, relative to the middle of the 3 given * Therefore, the slope at y=0 is simply B. Use this slope to determine * if the parabola is concave upward or downward. */ - IF (sub(posi,0) > 0) /* The extremum is in between the middle and the right given data points. */ + IF (GT_16(posi,0)) /* The extremum is in between the middle and the right given data points. */ { - IF (sub(y3, y1) <= 0) /* Check the slope at y=0, i.e., at the middle given data point. */ + IF (LE_16(y3, y1)) /* Check the slope at y=0, i.e., at the middle given data point. */ { posi = edge; /* minimum case */ move16(); } @@ -825,7 +823,7 @@ static Word16 imax_fx( /* o: The location, relative to the middle of the 3 given } ELSE /* The extremum is in between the left and the middle given data points. */ { - IF (sub(y3, y1) >= 0) + IF (GE_16(y3, y1)) { posi = edge; /* minimum case */ move16(); } @@ -870,12 +868,12 @@ static void spec_ana_fx( sinTblOffset = 0; - IF (sub(output_frame, L_FRAME48k) == 0) + IF (EQ_16(output_frame, L_FRAME48k)) { Lprot = Lprot48k; /* 1536=(2*output_frame)*1024/1280; */ move16(); hamm_len2 = Lprot_hamm_len2_48k; /* half Hamming window = 288 */ move16(); } - ELSE IF (sub(output_frame, L_FRAME32k) == 0) + ELSE IF (EQ_16(output_frame, L_FRAME32k)) { Lprot = Lprot32k; /* 1024 */ move16(); sinTblOffset = 4; @@ -903,7 +901,7 @@ static void spec_ana_fx( move16(); Copy_Scale_sig(prevsynth, xfp, Lprot, *Q); - IF (sub(output_frame, L_FRAME48k) == 0) + IF (EQ_16(output_frame, L_FRAME48k)) { /* Apply hamming-rect window */ windowing(xfp, xfp, w_hamm_sana48k_2_fx, rectLength, hamm_len2); @@ -919,7 +917,7 @@ static void spec_ana_fx( } /* Apply zeroing of non-coded FFT spectrum */ - IF (sub(output_frame, inner_frame_tbl_fx[bwidth_fx]) > 0) + IF (GT_16(output_frame, inner_frame_tbl_fx[bwidth_fx])) { stop_band_start = shl(128, bwidth_fx); stop_band_length = sub(Lprot, shl(stop_band_start,1)); @@ -974,7 +972,7 @@ static void spec_ana_fx( pPlocs = plocs; n = sub(*num_plocs, 1); /* -1 so as to exclude the very last peak. */ /* Special case-- The very 1st peak if it is at 0 index position */ - IF (sub(*pPlocs, 0) == 0) /* Only the very 1st peak is possible the peak at 0 index position. */ + IF (EQ_16(*pPlocs, 0)) /* Only the very 1st peak is possible the peak at 0 index position. */ { fraction = imax_fx(xfp, -1); /* -1 signifies special left edge case. */ acc = L_deposit_h(*pPlocs++); /* N.B., (*pPlocs) must be zero here. */ @@ -996,7 +994,7 @@ static void spec_ana_fx( { /* Special case-- The very last peak */ pXfp = pXfp1 + *pPlocs; - IF (sub(*pPlocs, Lprot2) == 0) /* Only the very last peak is possible the peak at Lprot2 index position. */ + IF (EQ_16(*pPlocs, Lprot2)) /* Only the very last peak is possible the peak at Lprot2 index position. */ { pXfp--; /* Special case needs extra decrement */ special = 1; /* Signify special right edge case. */ move16(); @@ -1063,12 +1061,12 @@ static void subst_spec_fx( move16(); Lecu = shl(output_frame, 1); - IF (sub(output_frame, L_FRAME48k) == 0) + IF (EQ_16(output_frame, L_FRAME48k)) { Lprot = Lprot48k; /* 1536=(2*output_frame)*1024/1280; */ move16(); Lprot_inv = 2731; /* Q22 */ move16(); } - ELSE IF (sub(output_frame, L_FRAME32k) == 0) + ELSE IF (EQ_16(output_frame, L_FRAME32k)) { Lprot = Lprot32k; /* 1024 */ move16(); Lprot_inv = 4096; /* Q22 */ move16(); @@ -1132,17 +1130,17 @@ static void subst_spec_fx( IF (m > 0) { delta_tmp = shr(sub(sub(pkLocation, pkLocation_1), 1), 1); - if (sub(delta_tmp, DELTA_CORR) < 0) + if (LT_16(delta_tmp, DELTA_CORR)) { delta_corr_dn = delta_tmp; move16(); } } - IF (sub(m, lastPeak) < 0 ) + IF (LT_16(m, lastPeak)) { delta_tmp = shr(sub(sub(pkLocation1, pkLocation), 1), 1); - if (sub(delta_tmp, DELTA_CORR ) < 0) + if (LT_16(delta_tmp, DELTA_CORR )) { delta_corr_up = delta_tmp; move16(); @@ -1162,7 +1160,7 @@ static void subst_spec_fx( move16(); tmp = sub(mult_r(re, cos_F), mult_r(im, sin_F)); im = add(mult_r(re, sin_F), mult_r(im, cos_F)); - IF (sub(alpha[k], 32766) < 0) + IF (LT_16(alpha[k], 32766)) { *seed = rand_phase_fx(*seed, &sin_F, &cos_F); tmp2 = mult_r(beta[k], Xavg[k]); @@ -1179,14 +1177,14 @@ static void subst_spec_fx( move16(); } i = add(i, 1); - if (sub(i, gwlpr_fx[k+1]) >= 0) + if (GE_16(i, gwlpr_fx[k+1])) { k = add(k, 1); } } e = add(pkLocation, delta_corr_up); - if (sub(e, lprotBy2Minus1) > 0) + if (GT_16(e, lprotBy2Minus1)) { e = lprotBy2Minus1; move16(); @@ -1194,10 +1192,10 @@ static void subst_spec_fx( Xph = *pCorrPhase; Xph_short = s_and(extract_l(L_shr(Xph, 16 - 10)), 0x3ff); /* 10 bits precision after radix point */ - IF (sub(Xph_short, 512) >=0) + IF (GE_16(Xph_short, 512)) { sin_F = negate(sincos_t_ext_fx[Xph_short - 512]); - IF (sub(Xph_short, 768) < 0) + IF (LT_16(Xph_short, 768)) { cos_F = negate(sincos_t_ext_fx[Xph_short - (512 - 256)]); } @@ -1211,7 +1209,7 @@ static void subst_spec_fx( { sin_F = sincos_t_ext_fx[Xph_short]; move16(); - IF (sub(Xph_short, 256) < 0) + IF (LT_16(Xph_short, 256)) { cos_F = sincos_t_ext_fx[Xph_short + 256]; move16(); @@ -1242,10 +1240,10 @@ static void subst_spec_fx( mag_chg_local = mult_r(mag_chg_local, sub(32767, shr(ph_dith, 1))); } Xph_short = s_and(extract_l(L_shr(Xph, 16 - 10)), 0x3ff); - IF (sub(Xph_short, 512) >= 0) + IF (GE_16(Xph_short, 512)) { sin_F = negate(sincos_t_ext_fx[Xph_short - 512]); - IF (sub(Xph_short, 768) < 0) + IF (LT_16(Xph_short, 768)) { cos_F = negate(sincos_t_ext_fx[Xph_short - (512 - 256)]); } @@ -1259,7 +1257,7 @@ static void subst_spec_fx( { sin_F = sincos_t_ext_fx[Xph_short]; move16(); - IF (sub(Xph_short, 256) < 0) + IF (LT_16(Xph_short, 256)) { cos_F = sincos_t_ext_fx[Xph_short + 256]; move16(); @@ -1277,7 +1275,7 @@ static void subst_spec_fx( move16(); tmp = sub(mult_r(re, cos_F), mult_r(im, sin_F)); im = add(mult_r(re, sin_F), mult_r(im, cos_F)); - IF (sub(alpha[k], 32766) < 0) + IF (LT_16(alpha[k], 32766)) { alpha_local = mag_chg_local; move16(); @@ -1285,18 +1283,18 @@ static void subst_spec_fx( acc = L_sub(1073741824L, L_mult0(alpha_local, alpha_local)); acc = Sqrt_l(acc, &expo); expo = add(30, add(31, expo)); - if (sub(s_and(expo, 1), 1) == 0) + if (EQ_16(s_and(expo, 1), 1)) { acc = Mult_32_16(acc, 23170); /* 1/sqrt(2) in Q15 */ } expo = shr(expo, 1); beta_local = mult_r(beta_mute, round_fx(L_shl(acc, sub(31, expo)))); - IF (sub(k, LGW32K-1) >= 0) + IF (GE_16(k, LGW32K-1)) { beta_local = mult_r(beta_local, 3277); /* 0.1 in Q15 */ } - ELSE if (sub(k, LGW16K-1) >= 0) + ELSE if (GE_16(k, LGW16K-1)) { beta_local = mult_r(beta_local, 16384); /* 0.5 in Q15 */ } @@ -1317,7 +1315,7 @@ static void subst_spec_fx( } i = add(i, 1); - if (sub(i, gwlpr_fx[k+1]) >= 0) + if (GE_16(i, gwlpr_fx[k+1])) { k = add(k, 1); } @@ -1336,7 +1334,7 @@ static void subst_spec_fx( move16(); tmp = sub(mult_r(re, cos_F), mult_r(im, sin_F)); im = add(mult_r(re, sin_F), mult_r(im, cos_F)); - IF (sub(alpha[k], 32766) < 0) + IF (LT_16(alpha[k], 32766)) { *seed = rand_phase_fx(*seed, &sin_F, &cos_F); tmp2 = mult_r(beta[k], Xavg[k]); @@ -1354,7 +1352,7 @@ static void subst_spec_fx( } i = add(i, 1); - if (sub(i, gwlpr_fx[k+1]) >= 0) + if (GE_16(i, gwlpr_fx[k+1])) { k = add(k, 1); } @@ -1392,13 +1390,13 @@ static void rec_wtda_fx( xf_len = 26; move16(); tbl_delta = 10082; /* Q12 */ move16(); - IF (sub(output_frame, L_FRAME48k) == 0) + IF (EQ_16(output_frame, L_FRAME48k)) { xf_len = 78; move16(); tbl_delta = 3361; /* Q12 */ move16(); } - ELSE IF (sub(output_frame, L_FRAME32k) == 0) + ELSE IF (EQ_16(output_frame, L_FRAME32k)) { xf_len = 52; move16(); @@ -1458,11 +1456,11 @@ static void rec_frame_fx( lprotLog2Minus1 = 9 - 1; move16(); pFftTbl = FFT_W256; /* Table for 512-point real input FFT */ - IF (sub(output_frame, L_FRAME48k) == 0) + IF (EQ_16(output_frame, L_FRAME48k)) { Lprot = Lprot48k; /* 1536 = (2*output_frame)*1024/1280 */ move16(); } - ELSE IF (sub(output_frame, L_FRAME32k) == 0) + ELSE IF (EQ_16(output_frame, L_FRAME32k)) { Lprot = Lprot32k; /* 1024 */ move16(); lprotLog2Minus1 = 10 - 1; @@ -1471,7 +1469,7 @@ static void rec_frame_fx( } /* extend spectrum and IDFT */ - IF (sub(output_frame, L_FRAME48k) == 0) + IF (EQ_16(output_frame, L_FRAME48k)) { ifft3_fx(X, X, Lprot); } @@ -1922,7 +1920,7 @@ void fec_ecu_dft_fx( Tfr16[*Nfft-1] = target[N-1]; move16(); - IF(sub(*Nfft,N)==0) + IF(EQ_16(*Nfft,N)) { Copy(&target[1],&Tfr16[1],*Nfft-2); } @@ -2068,7 +2066,7 @@ void sinusoidal_synthesis_fx( flag = HqVoicing; move16(); - if (sub(N, Lon20_10)>0 ) + if (GT_16(N, Lon20_10)) { flag = 1; move16(); /*flag corresponds to condition sub(N, Lon20_10)>0 || HqVoicing */ @@ -2096,10 +2094,10 @@ void sinusoidal_synthesis_fx( move16(); } tmp=sub(shr(N,1),3); - WHILE(sub(cpt,tmp)<=0) + WHILE(LE_16(cpt,tmp)) { test(); - IF(sub(Tf_abs[cpt],old)>0 && sub(Tf_abs[cpt],new_s)>0) + IF(GT_16(Tf_abs[cpt],old)&>_16(Tf_abs[cpt],new_s)) { Word16 tmp2; @@ -2167,7 +2165,7 @@ void sinusoidal_synthesis_fx( { tmp = *pt4++; move16(); - if (sub(Tf_abs[tmp], mmax)>0) + if (GT_16(Tf_abs[tmp], mmax)) { indmax = tmp; move16(); @@ -2197,7 +2195,7 @@ void sinusoidal_synthesis_fx( { tmp = *pt4++; move16(); - if (sub(Tf_abs[tmp], mmax)>0) + if (GT_16(Tf_abs[tmp], mmax)) { indmax = tmp; move16(); @@ -2217,7 +2215,7 @@ void sinusoidal_synthesis_fx( move16(); maxi=sub(maxi,1); - } WHILE( maxi>0 && L_sub(cumsum, L_tmp)<0); + } WHILE( maxi>0 && LT_32(cumsum, L_tmp)); nb_pulses_final = sub(nb_pulses_final,maxi); move16(); @@ -2236,7 +2234,7 @@ void sinusoidal_synthesis_fx( pt2 = a_im; pt3 = freqi; q = shr_r(N,2); - if (sub(N,shl(q,2))>0) + if (GT_16(N,shl(q,2))) { q = add(q,1); } @@ -2290,11 +2288,11 @@ void fec_noise_filling_fx( - IF ( sub(L, L_FRAME32k) == 0 ) + IF ( EQ_16(L, L_FRAME32k)) { sinq_tab = sinq_32k; } - ELSE IF ( sub(L, L_FRAME48k) == 0 ) + ELSE IF ( EQ_16(L, L_FRAME48k)) { sinq_tab = sinq_48k; } @@ -2436,12 +2434,12 @@ void fec_alg_fx( move16(); test(); - IF (sub(output_frame,L_FRAME32k)==0 || sub(output_frame,L_FRAME16k)==0 ) + IF (EQ_16(output_frame,L_FRAME32k)||EQ_16(output_frame,L_FRAME16k)) { n=R1_16-R2_16; move16(); - if(sub(output_frame,L_FRAME32k)==0) + if(EQ_16(output_frame,L_FRAME32k)) { n=2*N16_CORE_SW; move16(); @@ -2488,11 +2486,11 @@ static void hq_phase_ecu_fx( Word16 seed; Word16 alpha[Lgw_max], beta[Lgw_max]; - IF (sub(output_frame, L_FRAME48k) == 0) + IF (EQ_16(output_frame, L_FRAME48k)) { lprot = Lprot48k; /* 1536 = (2*output_frame)*1024/1280 */ move16(); } - ELSE IF (sub(output_frame, L_FRAME32k) == 0) + ELSE IF (EQ_16(output_frame, L_FRAME32k)) { lprot = Lprot32k; /* 1024 */ move16(); } @@ -2510,7 +2508,7 @@ static void hq_phase_ecu_fx( test(); test(); test(); - IF ( prev_bfi == 0 || (prev_bfi != 0 && *last_fec != 0 && (sub(*time_offs, output_frame) == 0)) ) + IF ( prev_bfi == 0 || (prev_bfi != 0 && *last_fec != 0 && (EQ_16(*time_offs, output_frame)))) { test(); if( !(prev_bfi != 0 && *last_fec != 0) ) @@ -2603,7 +2601,7 @@ void hq_ecu_fx( /* find pitch and R value */ - IF (!(sub(output_frame,L_FRAME16k) < 0) ) + IF (!(LT_16(output_frame,L_FRAME16k))) { fec_ecu_pitch_fx( prevsynth+NS2SA(output_frame*50,ACELP_LOOK_NS/2-PH_ECU_LOOKAHEAD_NS), prevsynth_LP, output_frame, &N, &corr, &decimatefactor, ph_ecu_HqVoicing); } @@ -2628,9 +2626,9 @@ void hq_ecu_fx( test(); test(); test(); - IF ( (L_sub(st_fx->total_brate_fx,48000) >= 0 && - ( sub(output_frame, L_FRAME16k) >= 0 && !prev_bfi && (!old_is_transient[0] || old_is_transient[1] ) && (ph_ecu_HqVoicing != 0 || ( ((st_fx->env_stab_plc_fx != 0) && (sub(corr,19661)<0)) || (!(st_fx->env_stab_plc_fx != 0) && (sub(corr, 27853) > 0 )))))) || - (L_sub(st_fx->total_brate_fx,48000) < 0 && ( ( ph_ecu_HqVoicing || sub(corr, 27853) > 0 ) && !prev_bfi && (!old_is_transient[0] || old_is_transient[1]) )) ) + IF ( (GE_32(st_fx->total_brate_fx,48000)&& + ( GE_16(output_frame, L_FRAME16k) && !prev_bfi && (!old_is_transient[0] || old_is_transient[1] ) && (NE_16(ph_ecu_HqVoicing,0) || ( ((NE_16(st_fx->env_stab_plc_fx ,0)) && (LT_16(corr,19661))) || (!(NE_16(st_fx->env_stab_plc_fx ,0)) && (GT_16(corr, 27853)) ))))) || + (LT_32(st_fx->total_brate_fx,48000) && ( ( ph_ecu_HqVoicing || GT_16(corr, 27853)) && !prev_bfi && (!old_is_transient[0] || old_is_transient[1]) )) ) { fec_alg_fx( prevsynth+NS2SA(output_frame*50,ACELP_LOOK_NS/2-PH_ECU_LOOKAHEAD_NS), prevsynth_LP, &st_fx->ni_seed_forfec, ecu_rec, output_frame, N, decimatefactor, ph_ecu_HqVoicing, gapsynth); diff --git a/lib_dec/FEC_adapt_codebook_fx.c b/lib_dec/FEC_adapt_codebook_fx.c index fcddf6c1754b55f327d28d35f0fe58c972e9bcb4..f521acf0066d302267e115febdb88f551660ea71 100644 --- a/lib_dec/FEC_adapt_codebook_fx.c +++ b/lib_dec/FEC_adapt_codebook_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -8,8 +8,6 @@ #include "rom_dec_fx.h" /* Decoder static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*---------------------------------------------------------------------* @@ -39,7 +37,7 @@ Word16 FEC_SinOnset_fx ( move16(); L_subfr = L_SUBFR; move16(); - if( sub(L_frame,L_FRAME16k) == 0 ) + if( EQ_16(L_frame,L_FRAME16k)) { L_subfr = L_SUBFR16k; move16(); @@ -60,12 +58,12 @@ Word16 FEC_SinOnset_fx ( test(); test(); - IF ( sub(P0,PIT_MAX) > 0 && sub(L_frame,L_FRAME) == 0 ) + IF ( GT_16(P0,PIT_MAX)&&EQ_16(L_frame,L_FRAME)) { P0 = PIT_MAX; move16();/* Should never be the case, however... */ } - ELSE if ( sub(P0,PIT16k_MAX) > 0 && sub(L_frame,L_FRAME16k) == 0 ) + ELSE if ( GT_16(P0,PIT16k_MAX)&&EQ_16(L_frame,L_FRAME16k)) { P0 = PIT16k_MAX; move16(); /* Should never be the case, however... */ @@ -95,7 +93,7 @@ Word16 FEC_SinOnset_fx ( tmp = extract_h(L_shl(enr_q, exp2)); tmp = mult(tmp, 24576); /* multpiply by 1.5 */ - IF(sub(tmp, 16384) < 0) + IF(LT_16(tmp, 16384)) { exp2 = add(exp2, 1); tmp = shl(tmp, 1); @@ -103,7 +101,7 @@ Word16 FEC_SinOnset_fx ( exp2 = sub(30, exp2); /* in Q15 */ - IF(sub(enr_LP, tmp) > 0) + IF(GT_16(enr_LP, tmp)) { enr_LP = shr(enr_LP, 1); exp_gain = add(exp_gain, 1); @@ -211,7 +209,7 @@ Word16 FEC_enhACB_fx( P0 = negate(P0); } - IF( sub(L_frame,L_FRAME) == 0 ) + IF( EQ_16(L_frame,L_FRAME)) { P0 = s_min(PIT_MAX, P0); } @@ -240,7 +238,7 @@ Word16 FEC_enhACB_fx( /*if(Terr > abs(Tlist[1]-Tc + P0))*/ - IF(sub(Terr,abs_s(add(sub(Tlist[1],Tc), P0))) > 0) + IF(GT_16(Terr,abs_s(add(sub(Tlist[1],Tc), P0)))) { dist_Plast = sub(Tc,Tlist[1]); Terr = abs_s(add(sub(Tlist[1],Tc), P0)); @@ -251,7 +249,7 @@ Word16 FEC_enhACB_fx( tmp2 = mult_r(div_s(16, Tc), shr(L_frame,4)); test(); test(); - IF (sub(Terr, i_mult(tmp2, diff_pit)) <= 0 && + IF (LE_16(Terr, i_mult(tmp2, diff_pit))&& Terr != 0 && /* If Terr = 0, no resynchronization required */ sub(Terr, L_SUBFR) < 0 )/* prevent catastrophy search */ { @@ -266,7 +264,7 @@ Word16 FEC_enhACB_fx( move16(); } - if( sub(last_L_frame, L_FRAME16k) != 0 ) + if( NE_16(last_L_frame, L_FRAME16k)) { Do_WI = 0; move16(); @@ -316,7 +314,7 @@ Word16 FEC_synchro_exc_fx( /* o : do_WI flag tmp16 = div_s(pos, tmp16); nb_min = shr(tmp16, 10); /* if Old pitch < 128, must have at least 2 min */ - if (sub(Old_pitch, 128) <= 0) + if (LE_16(Old_pitch, 128)) { nb_min = s_max(nb_min, 2); } @@ -328,7 +326,7 @@ Word16 FEC_synchro_exc_fx( /* o : do_WI flag /* Find starting point for minimum energy search */ start_search = mult_r(Old_pitch, -24576); - if(sub(s_and(Old_pitch,3),1) ==0) + if(EQ_16(s_and(Old_pitch,3),1)) { /* Only be align with integer operation -3*Old_pitch/4 */ start_search = add(start_search,1); @@ -336,7 +334,7 @@ Word16 FEC_synchro_exc_fx( /* o : do_WI flag IF (add(start_search, pos) < 0) { start_search = negate(pos); - IF (sub(abs_s(start_search), shr(Old_pitch, 3)) < 0) + IF (LT_16(abs_s(start_search), shr(Old_pitch, 3))) { /* it's not safe to remove/add point inside 1/8 of the pulse position */ return 0; @@ -356,7 +354,7 @@ Word16 FEC_synchro_exc_fx( /* o : do_WI flag L_tmp = L_mac(L_tmp, pt_exc[start_search + 3], pt_exc[start_search + 3]); L_tmp = L_mac(L_tmp, pt_exc[start_search + 4], pt_exc[start_search + 4]); - IF (L_sub(L_tmp, L_min_energy) < 0) + IF (LT_32(L_tmp, L_min_energy)) { L_min_energy = L_add(L_tmp, 0); min_pos[0] = add(add(pos, start_search), 2); @@ -367,9 +365,10 @@ Word16 FEC_synchro_exc_fx( /* o : do_WI flag L_tmp = L_msu(L_tmp, pt_exc[i], pt_exc[i]); L_tmp = L_mac(L_tmp, pt_exc[i + 5], pt_exc[i + 5]); - IF (L_sub(L_tmp, L_min_energy) < 0) + IF (LT_32(L_tmp, L_min_energy)) { - L_min_energy = L_add(0,L_tmp); /* sets to 'L_tmp' in 1 clock */ + L_min_energy = L_tmp; /* sets to 'L_tmp' in 1 clock */ + move32(); min_pos[0] = add(add(pos, i), 2); } } @@ -387,12 +386,12 @@ Word16 FEC_synchro_exc_fx( /* o : do_WI flag } /* safety-measure against not properly initialized min_pos[] */ - IF( L_sub(L_min_energy, MAX_32) >= 0 ) + IF( GE_32(L_min_energy, MAX_32)) { return 0; } - IF(sub(nb_min,16)>0) /* inv_sqi & sqi are built for a maximum of nb_min-2 = 14 values*/ + IF(GT_16(nb_min,16)) /* inv_sqi & sqi are built for a maximum of nb_min-2 = 14 values*/ { return 0; } @@ -402,7 +401,7 @@ Word16 FEC_synchro_exc_fx( /* o : do_WI flag * more towards the end of the frame * --------------------------------------------------------------------*/ test(); - IF (sub(nb_min, 1) == 0 || sub(abs_s(point_to_remove), 1) == 0) + IF (EQ_16(nb_min, 1)||EQ_16(abs_s(point_to_remove),1)) { nb_min = 1; move16(); @@ -424,7 +423,7 @@ Word16 FEC_synchro_exc_fx( /* o : do_WI flag total_point = add(total_point, points_by_pos[i-1]); /* ensure a constant increase */ - IF (sub(points_by_pos[i-1], points_by_pos[i-2]) < 0) + IF (LT_16(points_by_pos[i-1], points_by_pos[i-2])) { tmp16 = points_by_pos[i-2]; move16(); diff --git a/lib_dec/FEC_clas_estim_fx.c b/lib_dec/FEC_clas_estim_fx.c index 69614aa6c3f1926720c631832b93d6da45ed48c4..25f9e6025611ea68daa3a82f40b3de8fba08870c 100644 --- a/lib_dec/FEC_clas_estim_fx.c +++ b/lib_dec/FEC_clas_estim_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ @@ -8,8 +8,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - #include "basop_util.h" /*-------------------------------------------------------------------* @@ -116,11 +114,11 @@ void FEC_clas_estim_fx( test(); test(); test(); - IF((L_sub(last_core_brate, SID_1k75)==0 || L_sub(last_core_brate, ACELP_6k60)==0 || L_sub(last_core_brate, ACELP_8k85)==0 - || L_sub(last_core_brate, ACELP_12k65)==0 || L_sub(last_core_brate, ACELP_14k25)==0 || L_sub(last_core_brate, ACELP_15k85)==0 - || L_sub(last_core_brate, ACELP_18k25)==0 || L_sub(last_core_brate, ACELP_19k85)==0 || L_sub(last_core_brate, ACELP_23k05)==0 - || L_sub(last_core_brate, ACELP_23k85)==0) && !Opt_AMR_WB && sub(codec_mode, MODE2)==0 - && sub(L_frame,L_FRAME) > 0) + IF((EQ_32(last_core_brate, SID_1k75)||EQ_32(last_core_brate,ACELP_6k60)||EQ_32(last_core_brate,ACELP_8k85) + || EQ_32(last_core_brate, ACELP_12k65) || EQ_32(last_core_brate, ACELP_14k25) || EQ_32(last_core_brate, ACELP_15k85) + || EQ_32(last_core_brate, ACELP_18k25) || EQ_32(last_core_brate, ACELP_19k85) || EQ_32(last_core_brate, ACELP_23k05) + || EQ_32(last_core_brate, ACELP_23k85)) && !Opt_AMR_WB && EQ_16(codec_mode, MODE2) + && GT_16(L_frame,L_FRAME) ) { Word16 oldLenClasBuff, newLenClasBuff; oldLenClasBuff = extract_l(L_shr(Mpy_32_16_1(L_mult0(st_fx->last_L_frame_fx,getInvFrameLen(st_fx->L_frame_fx)/*Q21*/)/*Q21*/,L_SYN_MEM_CLAS_ESTIM/*Q0*/)/*Q6*/,6)/*Q0*/); @@ -132,7 +130,7 @@ void FEC_clas_estim_fx( /*Rescale synthesis mem buffer or synthesis buffer, if necessary - allign them to the same scaling in case of switching MODE2->MODE1*/ - IF(sub(codec_mode, MODE2) == 0) + IF(EQ_16(codec_mode, MODE2)) { memmax=1; move16(); @@ -152,14 +150,14 @@ void FEC_clas_estim_fx( { /*check for upscaling mem syn, first*/ tmp_scale_mem = norm_s(sub(memmax,1)); - if (sub(memmax,1) == 0) + if (EQ_16(memmax,1)) { tmp_scale_mem = 14; move16(); } tmp_scale_syn = sub(add(*Q_mem_syn, tmp_scale_mem), Q_syn); /*if this is negative, syn can be scaled down*/ test(); - IF(tmp_scale_syn > 0 || sub(mode , 1/*CLASSIFIER_TCX*/) == 0) /*dont scale up syn, but scale mem_syn, adequately*/ + IF(tmp_scale_syn > 0 || EQ_16(mode , 1/*CLASSIFIER_TCX*/)) /*dont scale up syn, but scale mem_syn, adequately*/ { tmp_scale_mem = sub(tmp_scale_mem,tmp_scale_syn); tmp_scale_syn = 0; @@ -184,7 +182,7 @@ void FEC_clas_estim_fx( /**Q_mem_syn = *Q_syn; move16();*/ test(); - IF(sub(codec_mode,MODE2) == 0 && sub(mode , 1/*CLASSIFIER_TCX*/)==0 ) + IF(EQ_16(codec_mode,MODE2)&&EQ_16(mode,1/*CLASSIFIER_TCX*/)) { /* TCX outputs non-pe-speech */ move16(); @@ -204,26 +202,26 @@ void FEC_clas_estim_fx( test(); test(); test(); - IF (( sub(codec_mode , MODE1) == 0 && ( L_sub(bitrate , ACELP_11k60) < 0 - || sub(coder_type , UNVOICED) <= 0 || Opt_AMR_WB)) || - (sub(codec_mode , MODE2) == 0 && sub(bfi,1) != 0 && !tcxonly )) + IF (( EQ_16(codec_mode , MODE1)&&(LT_32(bitrate,ACELP_11k60) + || LE_16(coder_type , UNVOICED) || Opt_AMR_WB)) || + (EQ_16(codec_mode , MODE2) && NE_16(bfi,1) && !tcxonly )) { /*------------------------------------------------------------------------* * Overwrite classification decision using coder_type information *------------------------------------------------------------------------*/ test(); - IF( sub(coder_type,VOICED) == 0 ) + IF( EQ_16(coder_type,VOICED)) { *clas = VOICED_CLAS; move16(); } - ELSE IF( sub(coder_type,UNVOICED) == 0 ) + ELSE IF( EQ_16(coder_type,UNVOICED)) { *clas = UNVOICED_CLAS; move16(); } - ELSE IF( sub(coder_type,INACTIVE) == 0 && !Opt_AMR_WB) + ELSE IF( EQ_16(coder_type,INACTIVE)&&!Opt_AMR_WB) { *clas = INACTIVE_CLAS; move16(); @@ -251,7 +249,7 @@ void FEC_clas_estim_fx( zc_frame = shl(extract_l(Ltmp),4); /* Q4 */ - if( sub(L_frame,L_FRAME16k) == 0) + if( EQ_16(L_frame,L_FRAME16k)) { /*zc_frame *= 0.8f;*/ /* Renormalization for 12.8kHz core*/ zc_frame = mult_r(zc_frame, 26214); @@ -264,7 +262,7 @@ void FEC_clas_estim_fx( T0 = shr(pitch[3], 6); Ltmp1 = L_mult(pitch[3], 256); - if (sub(T0, L_SUBFR*3/2) > 0) + if (GT_16(T0, L_SUBFR*3/2)) { T0 = mac_r(Ltmp1, pitch[2], 256); } @@ -287,7 +285,7 @@ void FEC_clas_estim_fx( pos = sub(pos, T0); /* T0 [34 231] */ Corre(&pt1[pos], &pt1[pos-T0], T0, &cor_max[1]); Ltmp = L_add(Ltmp, cor_max[1]); - IF (sub(pos, pos_limit) > 0) + IF (GT_16(pos, pos_limit)) { j = 10923; move16(); @@ -295,7 +293,7 @@ void FEC_clas_estim_fx( Corre(&pt1[pos], &pt1[pos-T0], T0, &cor_max[2]); Ltmp = L_add(Ltmp, cor_max[2]); } - IF (sub(pos, pos_limit) > 0) + IF (GT_16(pos, pos_limit)) { j = 8192; move16(); @@ -319,11 +317,11 @@ void FEC_clas_estim_fx( move16(); test(); test(); - IF (sub(codec_mode , MODE1) == 0 || !(sub(LTP_Gain , -32768/*-1.f Q15*/) != 0 && sub(mode , CLASSIFIER_TCX) == 0) ) + IF (EQ_16(codec_mode , MODE1)||!(NE_16(LTP_Gain,-32768/*-1.f Q15*/)&&EQ_16(mode,CLASSIFIER_TCX))) { pc = shr(abs_s(sub(add(pitch[3], sub(pitch[2], pitch[1])), pitch[0])), 6); - if(sub(L_frame,L_FRAME16k) == 0) + if(EQ_16(L_frame,L_FRAME16k)) { pc = mult_r(pc, 26214); /* Renormalization for 12.8kHz core*/ } @@ -350,9 +348,9 @@ void FEC_clas_estim_fx( IF (Ltmp != 0) { - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF tmp16 = extract_l(L_or(L_shr(Ltmp1, 32), 1)); /* sets a flag -1 or 1 for sign of Ltmp1 */ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON Ltmp1 = L_abs(Ltmp1); exp1 = norm_l(Ltmp1); tmp_y = extract_h(L_shl(Ltmp1, exp1)); @@ -360,9 +358,9 @@ void FEC_clas_estim_fx( exp2 = norm_l(Ltmp); tmp_x = extract_h(L_shl(Ltmp, exp2)); exp2 = sub(31-1+3, exp2); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF tmpS = shr(sub(tmp_x, tmp_y), 16); /* if tmp_x >= tmp_y tmpS = 0, -1 otherwise */ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON tmp_y = shl(tmp_y, tmpS); exp1 = sub(exp1, tmpS); @@ -389,12 +387,12 @@ void FEC_clas_estim_fx( zcn = extract_h(L_shl(L_mac(C_ZC_FX, K_ZC_FX, zc_frame), 4)); /* Q4 -> Q8*/ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF tmp16 = sub(LTP_Gain , -32768/*-1.f Q15*/); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON test(); test(); - IF ( sub(codec_mode , MODE2) == 0 && tmp16 != 0 && sub(mode , CLASSIFIER_TCX) == 0 ) + IF ( EQ_16(codec_mode , MODE2)&&tmp16!=0&&EQ_16(mode,CLASSIFIER_TCX)) { pcn = round_fx(L_shl(Mpy_32_16_1(C_PC_FX/*Q16*/, LTP_Gain/*Q15*/),8)); /*Q16*/ } @@ -411,15 +409,15 @@ void FEC_clas_estim_fx( Ltmp = L_mac(Ltmp, zcn, UNS6); Ltmp = L_mac(Ltmp, pcn, UNS6); Ltmp = L_mac(Ltmp, enern, UNS6); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF fmerit1 = round_fx(L_shl(Ltmp, 15-8)); /*Q15 can saturate to 1.0 */ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON test(); - if ( sub(codec_mode,MODE2) == 0 && narrowBand != 0 ) + if ( EQ_16(codec_mode,MODE2)&&narrowBand!=0) { fmerit1 = mult_r(fmerit1, 29491/*0.9f Q15*/); /* 0.90 */ } - IF(sub(codec_mode, MODE1) == 0) + IF(EQ_16(codec_mode, MODE1)) { *class_para = round_fx(L_shl(Ltmp, 14-8)); /*Q14 - cannot be saturated, degrades HF synthesis */ } @@ -429,7 +427,7 @@ void FEC_clas_estim_fx( *------------------------------------------------------------------------*/ test(); test(); - if ( (sub(coder_type,VOICED) != 0 && L_sub(bitrate,ACELP_11k60) < 0) || Opt_AMR_WB ) + if ( (NE_16(coder_type,VOICED)&<_32(bitrate,ACELP_11k60))||Opt_AMR_WB) { Word16 result = UNVOICED_CLAS; move16(); @@ -439,13 +437,13 @@ void FEC_clas_estim_fx( case ONSET: case SIN_ONSET: case VOICED_TRANSITION: - IF(sub(fmerit1, 12780/*0.39f Q15*/) < 0) + IF(LT_16(fmerit1, 12780/*0.39f Q15*/)) { result = UNVOICED_CLAS; move16(); } - ELSE IF(sub(fmerit1, 20644/*0.63f Q15*/) < 0 - && (add(ener,3840) < 0 || sub(codec_mode,MODE2) == 0)) + ELSE IF(LT_16(fmerit1, 20644/*0.63f Q15*/) + && (LT_16(ener,-3840) || EQ_16(codec_mode,MODE2))) { result = VOICED_TRANSITION; move16(); @@ -461,12 +459,12 @@ void FEC_clas_estim_fx( case UNVOICED_CLAS: case UNVOICED_TRANSITION: case INACTIVE_CLAS: - IF( sub(fmerit1, 18350/*0.56f Q15*/) > 0 ) + IF( GT_16(fmerit1, 18350/*0.56f Q15*/)) { result = ONSET; move16(); } - ELSE IF( sub(fmerit1, 14746/*0.45f Q15*/) > 0 ) + ELSE IF( GT_16(fmerit1, 14746/*0.45f Q15*/)) { result = UNVOICED_TRANSITION; move16(); @@ -486,12 +484,12 @@ void FEC_clas_estim_fx( - IF(sub(codec_mode,MODE1)==0) + IF(EQ_16(codec_mode,MODE1)) { /*------------------------------------------------------------------------* * Overwrite classification decision in case of music *------------------------------------------------------------------------*/ - IF( sub(coder_type,AUDIO) == 0 ) + IF( EQ_16(coder_type,AUDIO)) { (*decision_hyst) = add(*decision_hyst,4); move16(); @@ -502,12 +500,12 @@ void FEC_clas_estim_fx( move16(); } - if( sub(coder_type,INACTIVE) == 0 ) + if( EQ_16(coder_type,INACTIVE)) { *decision_hyst = sub(*decision_hyst,10); move16(); } - IF( sub(*decision_hyst,200) > 0 ) + IF( GT_16(*decision_hyst,200)) { *decision_hyst = 200; move16(); @@ -520,7 +518,7 @@ void FEC_clas_estim_fx( test(); test(); - if( sub(*decision_hyst,16) > 0 && sub(*clas,VOICED_CLAS) < 0 && sub(coder_type,AUDIO) == 0 ) + if( GT_16(*decision_hyst,16)&<_16(*clas,VOICED_CLAS)&&EQ_16(coder_type,AUDIO)) { *clas = VOICED_CLAS; move16(); @@ -530,15 +528,15 @@ void FEC_clas_estim_fx( /*---------------------------------------------------------------------------------* * Measure energy on active voice frames (to improve FEC performance) *---------------------------------------------------------------------------------*/ - IF( sub(*clas,VOICED_CLAS) == 0 ) + IF( EQ_16(*clas,VOICED_CLAS)) { test(); test(); test(); test(); test(); - IF( (sub(codec_mode,MODE2) == 0 && sub(coder_type, VOICED) == 0) - || (sub(codec_mode,MODE1) == 0 && (Opt_AMR_WB || (sub(coder_type,GENERIC) != 0 && sub(coder_type,TRANSITION) != 0) ) ) + IF( (EQ_16(codec_mode,MODE2)&&EQ_16(coder_type,VOICED)) + || (EQ_16(codec_mode,MODE1) && (Opt_AMR_WB || (NE_16(coder_type,GENERIC) && NE_16(coder_type,TRANSITION) ) ) ) ) { /* pitch-synchronous energy at the frame end */ @@ -550,14 +548,14 @@ void FEC_clas_estim_fx( move16(); /* lp_speech update */ } - IF(sub(codec_mode, MODE1) == 0) + IF(EQ_16(codec_mode, MODE1)) { /*---------------------------------------------------------------------------------* * Overwrite classification decision to UNVOICED_CLAS in case of INACTIVE frame *---------------------------------------------------------------------------------*/ test(); - if( sub(coder_type, INACTIVE) == 0 && sub(*clas,INACTIVE_CLAS) != 0 ) + if( EQ_16(coder_type, INACTIVE)&&NE_16(*clas,INACTIVE_CLAS)) { *clas = UNVOICED_CLAS; move16(); @@ -576,9 +574,9 @@ void FEC_clas_estim_fx( *-----------------------------------------------------------------------------*/ test(); - IF( sub(*clas, UNVOICED_CLAS) == 0 && sub(coder_type, INACTIVE) != 0 ) + IF( EQ_16(*clas, UNVOICED_CLAS)&&NE_16(coder_type,INACTIVE)) { - IF ( sub(*lp_speech, 40*256/*Q8*/) <= 0 ) + IF ( LE_16(*lp_speech, 40*256/*Q8*/)) { *UV_cnt = 16; move16(); @@ -595,7 +593,7 @@ void FEC_clas_estim_fx( * Number of frames between UV is increased *-----------------------------------------------------------------------------*/ - ELSE IF ( sub(coder_type, INACTIVE) != 0 ) + ELSE IF ( NE_16(coder_type, INACTIVE)) { move16(); *UV_cnt = add(*UV_cnt, 1); @@ -616,7 +614,7 @@ void FEC_clas_estim_fx( * update long-term average *-----------------------------------------------------------------------------*/ - IF ( sub(coder_type, INACTIVE) == 0 ) + IF ( EQ_16(coder_type, INACTIVE)) { move16(); *LT_UV_cnt = mult_r(31130/*0.95f*/, *LT_UV_cnt); /* tend to speech if no activity */ @@ -650,14 +648,14 @@ void FEC_clas_estim_fx( *amr_io_class = *clas; move16(); test(); - if ( sub(*LT_UV_cnt, LT_UV_THR_FX) > 0 && sub(diff_ener, 12*256/*Q8*/) < 0 ) + if ( GT_16(*LT_UV_cnt, LT_UV_THR_FX)&<_16(diff_ener,12*256/*Q8*/)) { move16(); *amr_io_class = AUDIO_CLAS; } test(); test(); - if ( (sub(diff_ener, 6*256/*Q8*/) > 0 && sub(*clas, AUDIO_CLAS) == 0) || sub(diff_ener, 9*256/*Q8*/) > 0 ) + if ( (GT_16(diff_ener, 6*256/*Q8*/)&&EQ_16(*clas,AUDIO_CLAS))||GT_16(diff_ener,9*256/*Q8*/)) { *locattack = 1; move16(); @@ -667,7 +665,7 @@ void FEC_clas_estim_fx( * Find mean of the past 40 frames energy variation *------------------------------------------------------------------------*/ - IF( sub(coder_type, INACTIVE) != 0 ) + IF( NE_16(coder_type, INACTIVE)) { Ltmp = L_deposit_l(0); FOR (i = 1; i 0 ) + IF ( EQ_16(*amr_io_class, AUDIO_CLAS)&>_16(tmp16,5*256/*Q8*/)) { *amr_io_class = *clas; move16(); @@ -725,7 +723,7 @@ void FEC_clas_estim_fx( /* update the memory of synthesis for frame class estimation */ - IF(sub(codec_mode,2)==0) + IF(EQ_16(codec_mode,2)) { Copy( old_synth + L_frame, mem_syn_clas_estim, L_SYN_MEM_CLAS_ESTIM ); } @@ -755,7 +753,7 @@ static Word16 FEC_dec_class_fx( clas = ONSET; move16(); - IF( sub(coder_type,VOICED) != 0 ) + IF( NE_16(coder_type,VOICED)) { /* decode the class */ tmpS = (Word16)get_next_indice_fx( st_fx, FEC_BITS_CLS ); @@ -765,9 +763,9 @@ static Word16 FEC_dec_class_fx( clas = UNVOICED_CLAS; move16(); } - ELSE IF( sub(tmpS,1) == 0 ) + ELSE IF( EQ_16(tmpS,1)) { - IF( sub(last_good,VOICED_TRANSITION) >= 0 ) + IF( GE_16(last_good,VOICED_TRANSITION)) { clas = VOICED_TRANSITION; move16(); @@ -778,7 +776,7 @@ static Word16 FEC_dec_class_fx( move16(); } } - ELSE IF( sub(tmpS,2) == 0 ) + ELSE IF( EQ_16(tmpS,2)) { clas = VOICED_CLAS; move16(); @@ -793,7 +791,7 @@ static Word16 FEC_dec_class_fx( /* decode the energy */ test(); test(); - IF( L_sub(bitrate,ACELP_14k80) >= 0 && sub(coder_type,TRANSITION) != 0 && sub(coder_type,AUDIO) < 0 ) + IF( GE_32(bitrate,ACELP_14k80)&&NE_16(coder_type,TRANSITION)&<_16(coder_type,AUDIO)) { tmpS = (Word16)get_next_indice_fx( st_fx, FEC_BITS_ENR ); /* convert from logarithmic to linear domain (the range is 0 : 3.0 : 96 dB) */ @@ -823,10 +821,10 @@ Word16 FEC_pos_dec_fx( T0 = 0; move16(); - IF( sub(coder_type,UNVOICED) > 0 ) + IF( GT_16(coder_type,UNVOICED)) { /* decode the clas and energy information */ - IF( sub(coder_type,AUDIO) < 0 ) + IF( LT_16(coder_type,AUDIO)) { *clas = FEC_dec_class_fx( st_fx, core_brate, coder_type, enr_q, last_good); move16(); @@ -834,7 +832,7 @@ Word16 FEC_pos_dec_fx( test(); test(); test(); - IF( sub(coder_type,GENERIC) == 0 && sub(*clas,VOICED_CLAS) == 0 && ( sub(last_good,UNVOICED_CLAS) <= 0 || sub(last_good,INACTIVE_CLAS) == 0) ) + IF( EQ_16(coder_type,GENERIC)&&EQ_16(*clas,VOICED_CLAS)&&(LE_16(last_good,UNVOICED_CLAS)||EQ_16(last_good,INACTIVE_CLAS))) { *clas = SIN_ONSET; move16(); @@ -842,11 +840,11 @@ Word16 FEC_pos_dec_fx( } test(); - IF( sub(coder_type,GENERIC) == 0 && L_sub(core_brate,ACELP_24k40) > 0 ) + IF( EQ_16(coder_type,GENERIC)&>_32(core_brate,ACELP_24k40)) { nBits = 0; move16(); - IF( sub(coder_type,AUDIO) != 0 ) + IF( NE_16(coder_type,AUDIO)) { nBits = ACB_bits_16kHz_tbl[BIT_ALLOC_IDX_16KHZ_fx(core_brate, coder_type, 0, 0)]; move16(); @@ -855,11 +853,11 @@ Word16 FEC_pos_dec_fx( /* use the absolute position of pitch index in the bitstream (this value is hard-coded and must be udpated when it changes in the encoder) */ bit_pos_pitch_index = 71; move16(); /* 64 kbps WB,SWB and FB*/ - if( L_sub(core_brate,ACELP_32k) <= 0 ) + if( LE_32(core_brate,ACELP_32k)) { bit_pos_pitch_index = 72; move16(); /* 32 kbp, WB*/ - if(sub(st_fx->bwidth_fx,WB) > 0) + if(GT_16(st_fx->bwidth_fx,WB)) { bit_pos_pitch_index = 73; move16(); /* 32 kbp, SWB, FB*/ @@ -880,12 +878,12 @@ Word16 FEC_pos_dec_fx( *last_pulse_pos = (Word16)get_next_indice_fx( st_fx, FEC_BITS_POS ); /* respect the sign */ - IF (sub(*last_pulse_pos,128) >= 0) + IF (GE_16(*last_pulse_pos,128)) { *last_pulse_pos = negate(s_and(*last_pulse_pos , 0x7F)); move16(); } - if ( sub(T0,128) >= 0) + if ( GE_16(T0,128)) { *last_pulse_pos = add(*last_pulse_pos,*last_pulse_pos); move16(); diff --git a/lib_dec/FEC_fx.c b/lib_dec/FEC_fx.c index 51d89539af96d74403f6c2ca5b7ca5dab2b2e8ce..8cdf8641a48975fe6427cde8cd8888c67643e4bc 100644 --- a/lib_dec/FEC_fx.c +++ b/lib_dec/FEC_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -9,8 +9,6 @@ #include "rom_dec_fx.h" /* Decoder static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - #include "basop_util.h" /*-------------------------------------------------------------------* @@ -141,7 +139,7 @@ void FEC_exc_estim_fx( tmp_old_pitch = &st_fx->old_pitch_buf_fx[2*NB_SUBFR16k-1]; tmp_pitmin = PIT16k_MIN_EXTEND; tmp_pitmax = PIT16k_MAX; - IF(sub(L_frame, L_FRAME) == 0) + IF(EQ_16(L_frame, L_FRAME)) { tmp_old_pitch = &st_fx->old_pitch_buf_fx[2*NB_SUBFR-1]; tmp_pitmin = PIT_MIN_DOUBLEEXTEND; @@ -178,13 +176,13 @@ void FEC_exc_estim_fx( *tmp_tc = st_fx->bfi_pitch_fx; move16(); /*Q6*/ - IF( sub(L_frame,L_FRAME) == 0 ) + IF( EQ_16(L_frame,L_FRAME)) { test(); test(); - IF ( (sub(round_fx(L_shl(st_fx->old_pitch_buf_fx[2*NB_SUBFR-1], 6)), shl(mult(29491, st_fx->bfi_pitch_fx), 1)) < 0 && - sub(round_fx(L_shl(st_fx->old_pitch_buf_fx[2*NB_SUBFR-1], 6)), mult(19661, st_fx->bfi_pitch_fx)) > 0) || /* last pitch coherent with the past */ - sub(st_fx->upd_cnt_fx, MAX_UPD_CNT) >= 0) /* or last update too far in the past */ + IF ( (LT_16(round_fx(L_shl(st_fx->old_pitch_buf_fx[2*NB_SUBFR-1], 6)), shl(mult(29491, st_fx->bfi_pitch_fx), 1))&& + GT_16(round_fx(L_shl(st_fx->old_pitch_buf_fx[2*NB_SUBFR-1], 6)), mult(19661, st_fx->bfi_pitch_fx)) ) || /* last pitch coherent with the past */ + GE_16(st_fx->upd_cnt_fx, MAX_UPD_CNT) ) /* or last update too far in the past */ { /* take the pitch value of last subframe of the previous frame */ *tmp_tc = round_fx(L_shl(st_fx->old_pitch_buf_fx[2*NB_SUBFR-1], 6)); @@ -194,9 +192,9 @@ void FEC_exc_estim_fx( { test(); test(); - IF ( (sub(round_fx(L_shl(st_fx->old_pitch_buf_fx[2*NB_SUBFR16k-1], 6)), shl(mult(29491, st_fx->bfi_pitch_fx), 1)) < 0 && - sub(round_fx(L_shl(st_fx->old_pitch_buf_fx[2*NB_SUBFR16k-1], 6)), mult(19661, st_fx->bfi_pitch_fx)) > 0) || /* last pitch coherent with the past */ - sub(st_fx->upd_cnt_fx, MAX_UPD_CNT) >= 0) /* or last update too far in the past */ + IF ( (LT_16(round_fx(L_shl(st_fx->old_pitch_buf_fx[2*NB_SUBFR16k-1], 6)), shl(mult(29491, st_fx->bfi_pitch_fx), 1))&& + GT_16(round_fx(L_shl(st_fx->old_pitch_buf_fx[2*NB_SUBFR16k-1], 6)), mult(19661, st_fx->bfi_pitch_fx))) || /* last pitch coherent with the past */ + GE_16(st_fx->upd_cnt_fx, MAX_UPD_CNT)) /* or last update too far in the past */ { /* take the pitch value of last subframe of the previous frame */ *tmp_tc = round_fx(L_shl(st_fx->old_pitch_buf_fx[2*NB_SUBFR16k-1], 6)); @@ -222,7 +220,7 @@ void FEC_exc_estim_fx( ) { tmp16 = *tmp_tc; /*Q6*/ move16(); - IF(sub(nb_subfr,4)==0) + IF(EQ_16(nb_subfr,4)) { delta = shr(sub(shl(new_pit,6), *tmp_tc),2 ); /* 4 sub-frames */ } @@ -262,21 +260,21 @@ void FEC_exc_estim_fx( test(); test(); test(); - IF( st_fx->last_coder_type_fx == UNVOICED && sub(st_fx->nbLostCmpt, 3) <= 0 ) + IF( st_fx->last_coder_type_fx == UNVOICED && LE_16(st_fx->nbLostCmpt, 3)) { /* last good frame was clearly unvoiced */ alpha = _ALPHA_UU_FX; move16(); } - ELSE IF( sub(st_fx->last_coder_type_fx,AUDIO) == 0 || sub(st_fx->last_good_fx,INACTIVE_CLAS) == 0 ) + ELSE IF( EQ_16(st_fx->last_coder_type_fx,AUDIO)||EQ_16(st_fx->last_good_fx,INACTIVE_CLAS)) { test(); - IF( st_fx->Last_GSC_pit_band_idx_fx > 0 && sub(st_fx->nbLostCmpt,1) > 0 ) + IF( st_fx->Last_GSC_pit_band_idx_fx > 0 && GT_16(st_fx->nbLostCmpt,1)) { alpha = 26214; move16(); } - ELSE IF( sub(st_fx->nbLostCmpt,5) <= 0 ) + ELSE IF( LE_16(st_fx->nbLostCmpt,5)) { alpha = 32604; move16(); @@ -287,14 +285,14 @@ void FEC_exc_estim_fx( move16(); } } - ELSE IF( sub(st_fx->last_good_fx,UNVOICED_CLAS) == 0 ) + ELSE IF( EQ_16(st_fx->last_good_fx,UNVOICED_CLAS)) { - IF( sub(st_fx->nbLostCmpt,1) <= 0) + IF( LE_16(st_fx->nbLostCmpt,1)) { /* if stable, do not decrease the energy, pitch_gain = 0 */ alpha = mac_r((1L<<16)*2*_ALPHA_U_FX, st_fx->stab_fac_fx, 32768-2*_ALPHA_U_FX); /*st_fx->stab_fac_fx in Q15*/ } - ELSE IF ( sub(st_fx->nbLostCmpt,2) == 0 ) + ELSE IF ( EQ_16(st_fx->nbLostCmpt,2)) { alpha =_ALPHA_S_FX; move16(); /* ALPHA_U*1.5f = 0.6 */ @@ -305,31 +303,31 @@ void FEC_exc_estim_fx( move16(); /* 0.4 go rapidly to CNG gain, pitch gain = 0 */ } } - ELSE IF( sub(st_fx->last_good_fx,UNVOICED_TRANSITION) == 0 ) + ELSE IF( EQ_16(st_fx->last_good_fx,UNVOICED_TRANSITION)) { alpha = _ALPHA_UT_FX; move16(); } - ELSE IF( sub(st_fx->last_good_fx,ONSET) == 0 && sub(st_fx->nbLostCmpt,3) <= 0 && (sub(st_fx->last_coder_type_fx,GENERIC) == 0 || sub(st_fx->last_coder_type_fx,TRANSITION) == 0) ) + ELSE IF( EQ_16(st_fx->last_good_fx,ONSET)&&LE_16(st_fx->nbLostCmpt,3)&&(EQ_16(st_fx->last_coder_type_fx,GENERIC)||EQ_16(st_fx->last_coder_type_fx,TRANSITION))) { alpha = 26214; move16(); /* mild convergence to 0 for the first 3 erased frames 0.8 in Q15 */ } - ELSE IF( ( sub(st_fx->last_good_fx,VOICED_CLAS) == 0 || sub(st_fx->last_good_fx,ONSET) == 0 ) && sub(st_fx->nbLostCmpt,3) <= 0 ) + ELSE IF( ( EQ_16(st_fx->last_good_fx,VOICED_CLAS)||EQ_16(st_fx->last_good_fx,ONSET))&&LE_16(st_fx->nbLostCmpt,3)) { alpha = _ALPHA_V_FX; move16(); /* constant for the first 3 erased frames */ } - ELSE IF( sub(st_fx->last_good_fx,SIN_ONSET) == 0 ) + ELSE IF( EQ_16(st_fx->last_good_fx,SIN_ONSET)) { alpha = _ALPHA_S_FX; move16(); } test(); test(); - IF( sub(st_fx->last_good_fx,VOICED_CLAS) >= 0 && sub(st_fx->last_good_fx,INACTIVE_CLAS) < 0 && sub(st_fx->last_coder_type_fx,AUDIO) != 0 ) + IF( GE_16(st_fx->last_good_fx,VOICED_CLAS)&<_16(st_fx->last_good_fx,INACTIVE_CLAS)&&NE_16(st_fx->last_coder_type_fx,AUDIO)) { - IF( sub(st_fx->nbLostCmpt,1) == 0 ) /* if first erased frame in a block, reset harmonic gain */ + IF( EQ_16(st_fx->nbLostCmpt,1)) /* if first erased frame in a block, reset harmonic gain */ { /* move pitch gain towards 1 for voiced to remove energy fluctuations */ /*gain = (float)sqrt( st_fx->lp_gainp );*/ @@ -362,8 +360,8 @@ void FEC_exc_estim_fx( test(); test(); test(); - IF( (sub(st_fx->last_good_fx,UNVOICED_TRANSITION) >= 0 && sub(st_fx->last_good_fx,INACTIVE_CLAS) < 0) || - ( (sub(st_fx->last_coder_type_fx,AUDIO) == 0 || sub(st_fx->last_good_fx,INACTIVE_CLAS) == 0) && st_fx->Last_GSC_pit_band_idx_fx > 0) ) + IF( (GE_16(st_fx->last_good_fx,UNVOICED_TRANSITION)&<_16(st_fx->last_good_fx,INACTIVE_CLAS))|| + ( (EQ_16(st_fx->last_coder_type_fx,AUDIO) || EQ_16(st_fx->last_good_fx,INACTIVE_CLAS) ) && st_fx->Last_GSC_pit_band_idx_fx > 0) ) { pt_exc = exc; @@ -371,7 +369,7 @@ void FEC_exc_estim_fx( pt1_exc = pt_exc - Tc; move16(); - IF (sub(st_fx->nbLostCmpt,1) == 0) + IF (EQ_16(st_fx->nbLostCmpt,1)) { /* first pitch cycle is low-pass filtered */ @@ -416,7 +414,7 @@ void FEC_exc_estim_fx( } test(); test(); - IF( sub(st_fx->last_good_fx,UNVOICED_TRANSITION) == 0 && ( sub(st_fx->last_coder_type_fx,GENERIC) == 0 || sub(st_fx->last_coder_type_fx,TRANSITION) == 0 ) ) + IF( EQ_16(st_fx->last_good_fx,UNVOICED_TRANSITION)&&(EQ_16(st_fx->last_coder_type_fx,GENERIC)||EQ_16(st_fx->last_coder_type_fx,TRANSITION))) { /* start of the frame gain */ gain = 0; @@ -438,7 +436,7 @@ void FEC_exc_estim_fx( /* end of the frame gain */ test(); - IF(!(sub(st_fx->last_good_fx,VOICED_CLAS) >= 0 && sub(st_fx->last_good_fx,INACTIVE_CLAS) < 0 && sub(st_fx->last_coder_type_fx,AUDIO) != 0 && sub(st_fx->nbLostCmpt, 1) > 0 )) + IF(!(GE_16(st_fx->last_good_fx,VOICED_CLAS)&<_16(st_fx->last_good_fx,INACTIVE_CLAS)&&NE_16(st_fx->last_coder_type_fx,AUDIO)&>_16(st_fx->nbLostCmpt,1))) { st_fx->lp_gainp_fx = shr(alpha,1); /* alpha in Q15 */ } @@ -448,7 +446,7 @@ void FEC_exc_estim_fx( move16(); /* alpha in Q14 */ } - IF(sub(L_frame, L_FRAME) == 0) + IF(EQ_16(L_frame, L_FRAME)) { step = shr(sub(gain,st_fx->lp_gainp_fx),8); } @@ -469,7 +467,7 @@ void FEC_exc_estim_fx( } test(); test(); - IF( (sub(st_fx->last_coder_type_fx,AUDIO) == 0 || sub(st_fx->last_good_fx,INACTIVE_CLAS) == 0) && st_fx->Last_GSC_pit_band_idx_fx > 0 ) + IF( (EQ_16(st_fx->last_coder_type_fx,AUDIO)||EQ_16(st_fx->last_good_fx,INACTIVE_CLAS))&&st_fx->Last_GSC_pit_band_idx_fx>0) { Diff_len = mfreq_loc_div_25[st_fx->Last_GSC_pit_band_idx_fx]; move16(); @@ -503,7 +501,7 @@ void FEC_exc_estim_fx( test(); test(); test(); - IF( sub(st_fx->last_coder_type_fx,AUDIO) == 0 || (sub(st_fx->last_good_fx,INACTIVE_CLAS) == 0 && L_sub(st_fx->total_brate_fx,ACELP_24k40) <= 0 && !st_fx->Opt_AMR_WB_fx) ) + IF( EQ_16(st_fx->last_coder_type_fx,AUDIO)||(EQ_16(st_fx->last_good_fx,INACTIVE_CLAS)&&LE_32(st_fx->total_brate_fx,ACELP_24k40)&&!st_fx->Opt_AMR_WB_fx)) { st_fx->GSC_noisy_speech_fx = st_fx->Last_GSC_noisy_speech_flag_fx; move16(); @@ -534,7 +532,7 @@ void FEC_exc_estim_fx( test(); test(); test(); - IF(!(sub(st_fx->last_good_fx,VOICED_CLAS) >= 0 && sub(st_fx->last_good_fx,INACTIVE_CLAS) < 0 && sub(st_fx->last_coder_type_fx,AUDIO) != 0 && sub(st_fx->nbLostCmpt, 1) > 0 )) + IF(!(GE_16(st_fx->last_good_fx,VOICED_CLAS)&<_16(st_fx->last_good_fx,INACTIVE_CLAS)&&NE_16(st_fx->last_coder_type_fx,AUDIO)&>_16(st_fx->nbLostCmpt,1))) { /* Here alpha is in Q15 and lp_gainc_fx in Q3 */ /* st_fx->lp_gainc = alpha * st_fx->lp_gainc + (1.0f - alpha) * gainCNG; */ @@ -553,7 +551,7 @@ void FEC_exc_estim_fx( test(); test(); test(); - if( sub(st_fx->last_good_fx,UNVOICED_TRANSITION) == 0 && ( sub(st_fx->last_coder_type_fx,GENERIC) == 0 || sub(st_fx->last_coder_type_fx,TRANSITION) == 0 ) && gainCNG > 0 ) + if( EQ_16(st_fx->last_good_fx,UNVOICED_TRANSITION)&&(EQ_16(st_fx->last_coder_type_fx,GENERIC)||EQ_16(st_fx->last_coder_type_fx,TRANSITION))&&gainCNG>0) { st_fx->lp_gainc_fx = gainCNG; move16(); @@ -563,7 +561,7 @@ void FEC_exc_estim_fx( /* step = (1.0f/L_FRAME) * (gain - *lp_gainc); */ step = sub(gain,st_fx->lp_gainc_fx); /* divide by L_FRAME done later */ test(); - if(sub(L_frame,L_FRAME16k) == 0) + if(EQ_16(L_frame,L_FRAME16k)) { step = mult_r(step,26214); /* L_frame16k-> L_frame and division by L_frame done later*/ } @@ -589,7 +587,7 @@ void FEC_exc_estim_fx( L_tmp = L_add(L_tmp, L_shr(L_tmp2, 1)); /* Q-7 */ } test(); - if(sub(L_frame,L_FRAME16k) == 0) + if(EQ_16(L_frame,L_FRAME16k)) { L_tmp = Mult_32_16(L_tmp, 26214); /* x0.8 to normalize to 256 samples */ } @@ -603,7 +601,7 @@ void FEC_exc_estim_fx( /* attenuate somewhat on unstable unvoiced */ test(); test(); - if( (sub(st_fx->last_good_fx,UNVOICED_CLAS) == 0 || sub(st_fx->last_good_fx,INACTIVE_CLAS) == 0) && sub(st_fx->last_coder_type_fx,UNVOICED) != 0 ) + if( (EQ_16(st_fx->last_good_fx,UNVOICED_CLAS)||EQ_16(st_fx->last_good_fx,INACTIVE_CLAS))&&NE_16(st_fx->last_coder_type_fx,UNVOICED)) { gain_inov = mult_r(gain_inov, 26214); } @@ -651,12 +649,12 @@ void FEC_exc_estim_fx( test(); test(); test(); - IF( (sub(st_fx->last_coder_type_fx,AUDIO) == 0 || sub(st_fx->last_good_fx,INACTIVE_CLAS) == 0) && L_sub(st_fx->total_brate_fx,ACELP_24k40) <= 0 && !st_fx->Opt_AMR_WB_fx) + IF( (EQ_16(st_fx->last_coder_type_fx,AUDIO)||EQ_16(st_fx->last_good_fx,INACTIVE_CLAS))&&LE_32(st_fx->total_brate_fx,ACELP_24k40)&&!st_fx->Opt_AMR_WB_fx) { /* For GSC - the excitation is already computed */ Copy( exc, exc2, st_fx->L_frame_fx ); } - ELSE IF( sub(st_fx->last_good_fx,UNVOICED_TRANSITION) >= 0 && sub(st_fx->last_good_fx,INACTIVE_CLAS) < 0 ) + ELSE IF( GE_16(st_fx->last_good_fx,UNVOICED_TRANSITION)&<_16(st_fx->last_good_fx,INACTIVE_CLAS)) { /* For voiced and generic signals - prepare a HP filter for the random part of excitation */ /* tmp = -(1-tilt_code) to correctly represent 1.0000 */ @@ -691,7 +689,7 @@ void FEC_exc_estim_fx( Copy( exc2_buf + MODE1_L_FIR_FER/2, exc2, L_frame ); } - IF( sub(L_frame,L_FRAME) == 0 ) + IF( EQ_16(L_frame,L_FRAME)) { interp_code_5over2_fx( exc, bwe_exc, L_frame ); @@ -701,9 +699,9 @@ void FEC_exc_estim_fx( interp_code_4over2_fx( exc, bwe_exc, L_frame ); } test(); - IF( sub(st_fx->last_coder_type_fx,AUDIO) == 0 || sub(st_fx->last_good_fx,INACTIVE_CLAS) == 0 ) + IF( EQ_16(st_fx->last_coder_type_fx,AUDIO)||EQ_16(st_fx->last_good_fx,INACTIVE_CLAS)) { - IF( sub(st_fx->L_frame_fx,L_FRAME) == 0 ) + IF( EQ_16(st_fx->L_frame_fx,L_FRAME)) { set16_fx( voice_factors, 32767, NB_SUBFR ); } @@ -714,7 +712,7 @@ void FEC_exc_estim_fx( } ELSE { - IF( sub(st_fx->L_frame_fx,L_FRAME) == 0 ) + IF( EQ_16(st_fx->L_frame_fx,L_FRAME)) { set16_fx( voice_factors, st_fx->last_voice_factor_fx, NB_SUBFR); /* The factor of the last subframe is propagated forward */ } @@ -746,10 +744,10 @@ static void pulseRes_preCalc(Word16* cond1, Word16* cond2, Word32* cond3 ,Word16 tmp_frame = BASOP_Util_Divide1616_Scale(4096/*1.f Q12*/,tmp_frame, &tmp_frame_e);/*Q15*/ tmp_frame = shl(tmp_frame,add(tmp_frame_e,1)); tmp_frame = sub(32767/*1.f Q15*/, tmp_frame);/*Q15*/ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF /*To calc Q15 threshold, overflow may happen - do negation and compare with negated value to check also highest possible value*/ tmp_pit = shl(negate(tmp_pit),tmp_pit_e); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON *cond1 = sub(tmp_pit, negate(tmp_frame)); *cond2 = sub(Tc, new_pit); @@ -757,10 +755,10 @@ static void pulseRes_preCalc(Word16* cond1, Word16* cond2, Word32* cond3 ,Word16 tmp_pit_e = BASOP_Util_Add_MantExp(new_pit,15-0,negate(Tc),15-0,&tmp_pit);/*Q15*/ tmp_pit = abs_s(tmp_pit); tmp_pit2 = L_mult(Tc,4915/*0.15f Q15*/);/*Q16*/ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF /*To calc Q15 threshold, overflow may happen - do negation and compare with negated value to check also highest possible value*/ tmp_pit2 = L_shl(L_negate(tmp_pit2),sub(15-16,tmp_pit_e)); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON *cond3 = L_sub(L_mult0(-1, tmp_pit),tmp_pit2); } diff --git a/lib_dec/FEC_lsf_estim_fx.c b/lib_dec/FEC_lsf_estim_fx.c index 9ab4181dd04f29105270bae23168a967381fd790..63f57db8dd0f2ba8cee392bc59af73133b81c93e 100644 --- a/lib_dec/FEC_lsf_estim_fx.c +++ b/lib_dec/FEC_lsf_estim_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ @@ -8,8 +8,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*-------------------------------------------------------------------* * FEC_lsf_estim() @@ -34,7 +32,7 @@ void FEC_lsf2lsp_interp( } ELSE { - IF( sub(L_frame,L_FRAME) == 0 ) + IF( EQ_16(L_frame,L_FRAME)) { lsf2lsp_fx( lsf, lsp, M, INT_FS_FX ); } diff --git a/lib_dec/FEC_pitch_estim_fx.c b/lib_dec/FEC_pitch_estim_fx.c index 8c8e217529202adc7b2f10fa87501c75b37d1529..907d459db164be9b616041a586a7b9cc0ea00fd7 100644 --- a/lib_dec/FEC_pitch_estim_fx.c +++ b/lib_dec/FEC_pitch_estim_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "cnst_fx.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - #include "basop_mpy.h" /*========================================================================*/ @@ -61,7 +59,7 @@ void FEC_pitch_estim_fx( tmp16k1 = round_fx(L_shl(Mpy_32_16_1(old_pitch_buf[2*NB_SUBFR16k-1],22938), 6)); /*Q6 0.7f * old_pitch_buf[2*NB_SUBFR16k-1]*/ tmp16k2 = shl(tmp16k1,1); /*Q6 1.4f * old_pitch_buf[2*NB_SUBFR16k-1]*/ - IF( sub(last_core,HQ_CORE) == 0 ) + IF( EQ_16(last_core,HQ_CORE)) { *bfi_pitch = pitch_buf[shr(L_frame,6)-1]; move16(); @@ -74,7 +72,7 @@ void FEC_pitch_estim_fx( test(); test(); test(); - IF( (sub(clas,VOICED_CLAS) == 0 && sub(last_good,VOICED_TRANSITION) >= 0) || (Opt_AMR_WB && sub(clas,VOICED_CLAS) == 0) ) + IF( (EQ_16(clas,VOICED_CLAS)&&GE_16(last_good,VOICED_TRANSITION))||(Opt_AMR_WB&&EQ_16(clas,VOICED_CLAS))) { test(); test(); @@ -86,13 +84,13 @@ void FEC_pitch_estim_fx( test(); test(); test(); - IF( ( (sub(pitch_buf[3],tmp1) < 0) && (sub(pitch_buf[3],tmp) > 0) && - (sub(pitch_buf[1],tmp3) < 0) && (sub(pitch_buf[1],tmp2) > 0) && - (sub(L_frame,L_FRAME) == 0) ) || - ( (sub(pitch_buf[3],tmp1) < 0) && (sub(pitch_buf[3],tmp) > 0) && - (sub(pitch_buf[1],tmp16k2) < 0) && (sub(pitch_buf[1],tmp16k1) > 0) && - (sub(L_frame,L_FRAME16k) == 0) ) - || (sub(coder_type, TRANSITION) == 0) ) + IF( ( (LT_16(pitch_buf[3],tmp1))&&(GT_16(pitch_buf[3],tmp))&& + (LT_16(pitch_buf[1],tmp3) ) && (GT_16(pitch_buf[1],tmp2) ) && + (EQ_16(L_frame,L_FRAME) ) ) || + ( (LT_16(pitch_buf[3],tmp1) ) && (GT_16(pitch_buf[3],tmp) ) && + (LT_16(pitch_buf[1],tmp16k2) ) && (GT_16(pitch_buf[1],tmp16k1) ) && + (EQ_16(L_frame,L_FRAME16k) ) ) + || (EQ_16(coder_type, TRANSITION) ) ) { *bfi_pitch = pitch_buf[shr(L_frame,6)-1]; move16(); diff --git a/lib_dec/FEC_scale_syn_fx.c b/lib_dec/FEC_scale_syn_fx.c index 04c5d093ad4a742286a81018943ac2ebb3271e42..2a91f3a420af680d16e1eb09d8031051edd21e16 100644 --- a/lib_dec/FEC_scale_syn_fx.c +++ b/lib_dec/FEC_scale_syn_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "cnst_fx.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - #include "basop_mpy.h" /*-------------------------------------------------------------------* @@ -112,9 +110,9 @@ void FEC_scale_syn_fx( * Find the synthesis filter impulse response on voiced *-----------------------------------------------------------------*/ test(); - IF( sub(clas,VOICED_TRANSITION) >= 0 && sub(clas,INACTIVE_CLAS) < 0 ) + IF( GE_16(clas,VOICED_TRANSITION)&<_16(clas,INACTIVE_CLAS)) { - IF( sub(L_frame,L_FRAME) == 0 ) + IF( EQ_16(L_frame,L_FRAME)) { enr_LP = Enr_1_Az_fx(Aq+(NB_SUBFR-1)*(M+1), L_SUBFR ); } @@ -136,12 +134,12 @@ void FEC_scale_syn_fx( ELSE IF( prev_bfi ) { test(); - IF( ( sub(LSF_Q_prediction,AUTO_REGRESSIVE) == 0 ) || ( sub(LSF_Q_prediction,MOVING_AVERAGE) == 0 ) ) + IF( ( EQ_16(LSF_Q_prediction,AUTO_REGRESSIVE))||(EQ_16(LSF_Q_prediction,MOVING_AVERAGE))) { *scaling_flag = 2; move16(); /* Decoded LSFs affected */ } - ELSE IF( sub(coder_type,TRANSITION) != 0 ) + ELSE IF( NE_16(coder_type,TRANSITION)) { *scaling_flag = 1; move16(); /* SN, but not TC mode - LSF still affected by the interpolation */ @@ -156,7 +154,7 @@ void FEC_scale_syn_fx( ELSE { test(); - IF( (sub(LSF_Q_prediction,AUTO_REGRESSIVE) == 0) && (sub(*scaling_flag,2) == 0) ) + IF( (EQ_16(LSF_Q_prediction,AUTO_REGRESSIVE))&&(EQ_16(*scaling_flag,2))) { *scaling_flag = 2; move16(); /* Continue with energy control till the end of AR prediction */ @@ -175,7 +173,7 @@ void FEC_scale_syn_fx( /*fer_energy( L_frame, clas, synth, pitch[(L_frame>>6)-1], &enr2, L_frame );*/ frame_ener_fx(L_frame,clas, synth, pitch[sub(shr(L_frame,6),1)], &L_enr2/*Q0*/, 1, Q_syn, 3, 0); - if( bfi || (L_sub(total_brate,ACELP_7k20) == 0) || (L_sub(total_brate,ACELP_8k00) == 0) ) + if( bfi || (EQ_32(total_brate,ACELP_7k20))||(EQ_32(total_brate,ACELP_8k00))) { /* previous frame erased and no TC frame */ IF( *scaling_flag > 0 ) @@ -243,9 +241,9 @@ void FEC_scale_syn_fx( test(); test(); test(); - IF( ( sub(tilt,22938) > 0 ) && /* HF resonnant filter */ - ( (sub(pitch_dist, 8<<4) > 0) || (sub(mean_pitch,PIT_MIN<<4) < 0) ) && /* pitch unstable or very short */ - ( (prev_bfi) || ( (sub(coder_type,GENERIC) == 0) && (sub(LSF_Q_prediction,AUTO_REGRESSIVE) == 0) ) ) ) + IF( ( GT_16(tilt,22938))&& /* HF resonnant filter */ + ( (GT_16(pitch_dist, 8<<4) ) || (LT_16(mean_pitch,PIT_MIN<<4) ) ) && /* pitch unstable or very short */ + ( (prev_bfi) || ( (EQ_16(coder_type,GENERIC) ) && (EQ_16(LSF_Q_prediction,AUTO_REGRESSIVE) ) ) ) ) { /*if( enr_q > scaling * enr_old ){enr_q = scaling * enr_old;}*/ L_enr_q = L_min(L_enr_q, L_shl(Mult_32_16(L_enr_old, scaling),1)); /* scaling in Q14*/ @@ -255,7 +253,7 @@ void FEC_scale_syn_fx( ener_max = *lp_ener_FEC_max; move32(); test(); - if( sub(clas,VOICED_TRANSITION) == 0 || (sub(clas,INACTIVE_CLAS) >= 0)) + if( EQ_16(clas,VOICED_TRANSITION)||(GE_16(clas,INACTIVE_CLAS))) { ener_max = *lp_ener_FEC_av; move32(); @@ -282,8 +280,8 @@ void FEC_scale_syn_fx( test(); test(); test(); - IF( ( (sub(last_good,VOICED_TRANSITION) >= 0 && sub(last_good,INACTIVE_CLAS) < 0 && (sub(clas,UNVOICED_CLAS) == 0 || sub(clas,INACTIVE_CLAS) == 0)) || - L_sub(last_core_brate,SID_1k75) == 0 || L_sub(last_core_brate,SID_2k40) == 0 || L_sub(last_core_brate,FRAME_NO_DATA) == 0 ) && prev_bfi ) + IF( ( (GE_16(last_good,VOICED_TRANSITION)&<_16(last_good,INACTIVE_CLAS)&&(EQ_16(clas,UNVOICED_CLAS)||EQ_16(clas,INACTIVE_CLAS)))|| + EQ_32(last_core_brate,SID_1k75) || EQ_32(last_core_brate,SID_2k40) || EQ_32(last_core_brate,FRAME_NO_DATA) ) && prev_bfi ) { /* voiced -> unvoiced signal transition */ /* CNG -> active signal transition */ @@ -309,7 +307,7 @@ void FEC_scale_syn_fx( /* prevent amplifying the unvoiced or inactive part of the frame in case an offset is followed by an onset */ test(); test(); - if( sub(clas,ONSET) == 0 && sub(gain1,gain2) > 0 && prev_bfi ) + if( EQ_16(clas,ONSET)&>_16(gain1,gain2)&&prev_bfi) { gain1 = gain2; move16(); @@ -348,7 +346,7 @@ void FEC_scale_syn_fx( { /* previous frame erased and no TC frame */ test(); - IF( prev_bfi && sub(coder_type,TRANSITION) != 0 ) + IF( prev_bfi && NE_16(coder_type,TRANSITION)) { IF( L_enr_q == 0 ) { @@ -371,19 +369,19 @@ void FEC_scale_syn_fx( test(); test(); test(); - IF( ( ( (L_sub(total_brate,ACELP_13k20) == 0) || (L_sub(total_brate,ACELP_12k85) == 0) || (L_sub(total_brate,ACELP_12k15) == 0) || (L_sub(total_brate,ACELP_11k60) == 0) || - (L_sub(total_brate,ACELP_9k60) == 0) ) && - ( sub(tilt,22938) > 0 ) && /* HF resonnant filter */ - ( (sub(clas,UNVOICED_CLAS) == 0) || (sub(clas,INACTIVE_CLAS) == 0) ) ) ) /* unvoiced classification */ + IF( ( ( (EQ_32(total_brate,ACELP_13k20))||(EQ_32(total_brate,ACELP_12k85))||(EQ_32(total_brate,ACELP_12k15))||(EQ_32(total_brate,ACELP_11k60))|| + (EQ_32(total_brate,ACELP_9k60)) ) && + ( GT_16(tilt,22938) ) && /* HF resonnant filter */ + ( (EQ_16(clas,UNVOICED_CLAS))||(EQ_16(clas,INACTIVE_CLAS))))) /* unvoiced classification */ { /*if( enr_q > scaling * enr_old )enr_q = scaling * enr_old;*/ L_enr_q = L_min(L_enr_q, L_shl(Mult_32_16(L_enr_old, scaling),1)); /* scaling in Q14*/ } - ELSE IF( sub(last_good,VOICED_TRANSITION) >= 0 && sub(last_good,INACTIVE_CLAS) < 0 && sub(clas,VOICED_TRANSITION) >= 0 && sub(clas,INACTIVE_CLAS) < 0 ) + ELSE IF( GE_16(last_good,VOICED_TRANSITION)&<_16(last_good,INACTIVE_CLAS)&&GE_16(clas,VOICED_TRANSITION)&<_16(clas,INACTIVE_CLAS)) { /* Voiced-voiced recovery */ test(); - IF( *old_enr_LP != 0 && sub(enr_LP, shl(*old_enr_LP, 1)) > 0 ) + IF( *old_enr_LP != 0 && GT_16(enr_LP, shl(*old_enr_LP, 1))) { /* enr_q /= enr_LP */ exp = norm_l(L_enr_q); @@ -409,7 +407,7 @@ void FEC_scale_syn_fx( ELSE { test(); - IF( avoid_lpc_burst_on_recovery && sub(enr_LP, 160) > 0 ) + IF( avoid_lpc_burst_on_recovery && GT_16(enr_LP, 160)) { exp = norm_s(enr_LP); tmp = shl(enr_LP, exp); @@ -419,7 +417,7 @@ void FEC_scale_syn_fx( tmp2 = 160 << 7; /* 160 = 20.0f in Q3 */ exp = sub(exp2, exp); - IF (sub(tmp, tmp2) > 0) + IF (GT_16(tmp, tmp2)) { tmp = shr(tmp, 1); exp = add(exp, 1); @@ -435,11 +433,11 @@ void FEC_scale_syn_fx( test(); test(); test(); - IF( (sub(last_good,VOICED_TRANSITION) >= 0 && sub(last_good,INACTIVE_CLAS) < 0 && sub(clas,VOICED_TRANSITION) >= 0 && sub(clas,INACTIVE_CLAS) < 0) + IF( (GE_16(last_good,VOICED_TRANSITION)&<_16(last_good,INACTIVE_CLAS)&&GE_16(clas,VOICED_TRANSITION)&<_16(clas,INACTIVE_CLAS)) || force_scaling ) { - IF( L_sub(L_enr_q, L_enr_old) > 0) /* Prevent energy to increase on voiced */ + IF( GT_32(L_enr_q, L_enr_old)) /* Prevent energy to increase on voiced */ { L_enr_q = L_add(Mpy_32_16_1(L_enr_old, 32767 - SCLSYN_LAMBDA), Mpy_32_16_1(L_enr_q, SCLSYN_LAMBDA)); } @@ -475,7 +473,7 @@ void FEC_scale_syn_fx( *-----------------------------------------------------------------*/ gain2 = s_min(gain2, 19661); /* Gain modification clipping */ - if (L_sub(L_enr_q, 2) < 0) + if (LT_32(L_enr_q, 2)) { gain2 = s_min(gain2, 16384); /* Gain modification clipping */ } @@ -490,15 +488,15 @@ void FEC_scale_syn_fx( test(); test(); test(); - IF( sub(clas,SIN_ONSET) == 0 ) /* slow increase */ + IF( EQ_16(clas,SIN_ONSET)) /* slow increase */ { gain1 = shr(gain2, 1); } /*------------------------------------------------------------* * voiced->unvoiced transition recovery *------------------------------------------------------------*/ - ELSE IF( (sub(last_good,VOICED_TRANSITION) >= 0 && sub(last_good,INACTIVE_CLAS) < 0 && (sub(clas,UNVOICED_CLAS) == 0 || sub(clas,INACTIVE_CLAS) == 0)) || /* voiced->unvoiced transition recovery */ - L_sub(last_core_brate,SID_1k75) == 0 || L_sub(last_core_brate,SID_2k40) == 0 || L_sub(last_core_brate,FRAME_NO_DATA) == 0) /* CNG -> active signal transition */ + ELSE IF( (GE_16(last_good,VOICED_TRANSITION)&<_16(last_good,INACTIVE_CLAS)&&(EQ_16(clas,UNVOICED_CLAS)||EQ_16(clas,INACTIVE_CLAS)))|| /* voiced->unvoiced transition recovery */ + EQ_32(last_core_brate,SID_1k75) || EQ_32(last_core_brate,SID_2k40) || EQ_32(last_core_brate,FRAME_NO_DATA)) /* CNG -> active signal transition */ { gain1 = gain2; move16(); @@ -537,7 +535,7 @@ void FEC_scale_syn_fx( test(); test(); - if( avoid_lpc_burst_on_recovery && (sub(enr_LP, 160) > 0) && (sub(enr_LP, shl(*old_enr_LP, 1)) <= 0) ) + if( avoid_lpc_burst_on_recovery && (GT_16(enr_LP, 160))&&(LE_16(enr_LP,shl(*old_enr_LP,1)))) { gain1 = s_min(gain1, 16384); } @@ -546,7 +544,7 @@ void FEC_scale_syn_fx( * Prevent a catastrophy in case of offset followed by onset *--------------------------------------------------------*/ test(); - if( ( sub(clas,ONSET) == 0 ) && (sub(gain1,gain2) > 0) ) + if( ( EQ_16(clas,ONSET))&&(GT_16(gain1,gain2))) { gain1 = gain2; move16(); @@ -580,9 +578,9 @@ void FEC_scale_syn_fx( test(); test(); - IF( !bfi && (sub(clas,VOICED_TRANSITION) >= 0 && sub(clas,INACTIVE_CLAS) < 0) ) + IF( !bfi && (GE_16(clas,VOICED_TRANSITION)&<_16(clas,INACTIVE_CLAS))) { - IF( sub(clas,VOICED_TRANSITION) == 0 ) + IF( EQ_16(clas,VOICED_TRANSITION)) { L_enr2_av = L_enr2; move32(); @@ -607,7 +605,7 @@ void FEC_scale_syn_fx( * Update the LP filter energy for voiced frames *-----------------------------------------------------------------*/ test(); - if( sub(clas,VOICED_TRANSITION) >= 0 && sub(clas,INACTIVE_CLAS) < 0 ) + if( GE_16(clas,VOICED_TRANSITION)&<_16(clas,INACTIVE_CLAS)) { *old_enr_LP = enr_LP; move16(); diff --git a/lib_dec/LD_music_post_filter_fx.c b/lib_dec/LD_music_post_filter_fx.c index 6d254dc34be29183b7d98f32ceeb920bc218e6f3..20f79fb5d00abbf2d1a291e57bf6bbeb3cb7eb33 100644 --- a/lib_dec/LD_music_post_filter_fx.c +++ b/lib_dec/LD_music_post_filter_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -7,8 +7,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*-------------------------------------------------------------------* @@ -104,7 +102,7 @@ void LD_music_post_filter_fx , nb_thr_3, nb_thr_1, thresh, last_music_flag, 1 ); test(); - if ( L_sub(core_brate,ACELP_6k60) < 0 || sub(Last_coder_type, AUDIO) != 0 ) + if ( LT_32(core_brate,ACELP_6k60)||NE_16(Last_coder_type,AUDIO)) { /* do not perform music improvement on SID frames */ music_flag2 = 0; @@ -113,7 +111,7 @@ void LD_music_post_filter_fx *last_nonfull_music = add(*last_nonfull_music,1); move16(); - if( sub(music_flag2,4) < 0 ) + if( LT_16(music_flag2,4)) { *last_nonfull_music = 0; move16(); @@ -127,25 +125,25 @@ void LD_music_post_filter_fx * Section to "remap" the minimal band and the minimum gain for our needs *------------------------------------------------------------------------*/ - IF( sub(music_flag2,3) > 0) + IF( GT_16(music_flag2,3)) { min_band = 2; move16(); local_min_gain = 8231; /*Q15->0.25119f;*/ move16(); } - ELSE IF( sub(music_flag2,3) == 0) + ELSE IF( EQ_16(music_flag2,3)) { min_band = 3; move16(); local_min_gain = 8231; /*Q15->0.25119f; */ move16(); } - ELSE IF( sub(music_flag2,2) == 0) + ELSE IF( EQ_16(music_flag2,2)) { min_band = 4; move16(); local_min_gain = 11626; /*Q15->0.35481f; */ move16(); } - ELSE IF( sub(music_flag2,1) == 0) + ELSE IF( EQ_16(music_flag2,1)) { min_band = 4; move16(); @@ -155,14 +153,14 @@ void LD_music_post_filter_fx min_band = add(min_band, 4); MAX_GN = 1638; /*Q14*/ move16(); - if( L_sub(core_brate,ACELP_9k60) > 0 ) + if( GT_32(core_brate,ACELP_9k60)) { /* overshoot not allowed, since GSC already matches the energy */ MAX_GN = 0; move16(); } - if( sub(coder_type,AUDIO) == 0 ) + if( EQ_16(coder_type,AUDIO)) { /* with GSC we know for sure that we are in music */ min_band = s_min( min_band, 3 ); @@ -260,7 +258,7 @@ void LD_music_post_filter_fx * on the pow(x,4) energy spectrum *------------------------------------------------------------------------*/ - if( sub(coder_type,AUDIO) == 0 ) + if( EQ_16(coder_type,AUDIO)) { MAX_band = 16; move16(); @@ -272,7 +270,7 @@ void LD_music_post_filter_fx i = 0; move16(); - IF( sub(music_flag2,1) >= 0 ) + IF( GE_16(music_flag2,1)) { FOR(i = 0; i < BIN_1KHZ; i++) { @@ -281,7 +279,7 @@ void LD_music_post_filter_fx } } { - IF( sub(*last_nonfull_music,40) > 0 ) + IF( GT_16(*last_nonfull_music,40)) { max_ovf_2k = 5120; /*1.25 Q12*/ move16(); max_ovf_4k = 6144; /*1.5 Q12*/ move16(); @@ -294,7 +292,7 @@ void LD_music_post_filter_fx min_g_6k = 0; move16(); - IF( sub(coder_type,AUDIO ) == 0) + IF( EQ_16(coder_type,AUDIO )) { max_ovf_2k = 4096; /*1.0 Q12*/ move16(); max_ovf_4k = 4506; /*1.1 Q12*/ move16(); @@ -304,7 +302,7 @@ void LD_music_post_filter_fx min_g_4k = 2048; /*0.5 Q12*/ move16(); min_g_6k = 2048; /*0.5 Q12*/ move16(); - IF( L_sub(core_brate,ACELP_9k60) > 0 ) + IF( GT_32(core_brate,ACELP_9k60)) { max_ovf_4k = 4096; /*1.0 Q12*/ move16(); max_ovf_6k = 4710; /*1.15 Q12*/ move16(); @@ -314,12 +312,12 @@ void LD_music_post_filter_fx min_g_6k = 3072; /*0.75 Q12*/ move16(); } } - ELSE IF( L_sub(core_brate,ACELP_12k65) >= 0 ) + ELSE IF( GE_32(core_brate,ACELP_12k65)) { max_ovf_2k = 4096; /*1.0 Q12*/ move16(); max_ovf_4k = 5120; /*1.25 Q12*/ move16(); - IF( L_sub(core_brate,ACELP_15k85) > 0 ) + IF( GT_32(core_brate,ACELP_15k85)) { max_ovf_4k = 4096; /*1.0 Q12*/ move16(); max_ovf_6k = 5120; /*1.25 Q12*/ move16(); @@ -348,7 +346,7 @@ void LD_music_post_filter_fx } test(); - IF( sub(coder_type,AUDIO) != 0 || L_sub(core_brate,ACELP_8k85) > 0 ) + IF( NE_16(coder_type,AUDIO)||GT_32(core_brate,ACELP_8k85)) { /* Do not modify HF when coded with GSC at LR, because the spectrum is just noise */ FOR(; i < DCT_L_POST; i++) @@ -360,7 +358,7 @@ void LD_music_post_filter_fx } } } - ELSE IF( sub(*last_nonfull_music,25) > 0 ) + ELSE IF( GT_16(*last_nonfull_music,25)) { /* When unsure on content type only slight clean-up allowed, no overshoot allowed */ FOR(; i < DCT_L_POST; i++) @@ -474,7 +472,7 @@ static void spectrum_mod_dct_fx( IF ( music_flag != 0 ) /* prevent subtraction on clean speech */ { - IF( L_sub(maxNoise, L_shl(10, scaling)) <= 0) + IF( LE_32(maxNoise, L_shl(10, scaling))) { minE = 18432/2; /*Q14*/ move16(); } @@ -538,7 +536,7 @@ static void spectrum_mod_dct_fx( /*gain = 1.0f;*/ Lgain = L_deposit_h(16384); /*if (noiseE[i] >= 0.5f)*/ - IF (L_sub(noiseE[i], dot5_scaled) > 0 )/* Do not alter if noise E very low */ + IF (GT_32(noiseE[i], dot5_scaled))/* Do not alter if noise E very low */ { /*gain = tmpN * *pt2 + shift;*/ /* limits: [x,y] = {[1, minE], [MAX_SNR1, 1]}, */ e_binE = norm_l(*Lpt2); @@ -754,7 +752,7 @@ void Prep_music_postP_fx( * Resetting some memories in case of switching *------------------------------------------------------------*/ - IF( sub(last_core,HQ_CORE) == 0 ) + IF( EQ_16(last_core,HQ_CORE)) { set16_fx( filt_lfE, 4096, DCT_L_POST ); set16_fx( LDm_enh_lp_gbin, 16384, VOIC_BINS_HR ); @@ -847,7 +845,7 @@ static Word16 norm_lfe( tmp16 = mult_r(tmp16,tmp16); exp3 = sub(12+16, exp2); /* tmp16 in Q exp2 */ - if(sub(exp2,31) !=0) + if(NE_16(exp2,31)) { exp3 = sub(exp2, 12+16-3); /* if exp2 < 31, means that tmp >= 1.0 */ /* Need to shl by 3 to take into account the 3 multiplications */ diff --git a/lib_dec/TonalComponentDetection.c b/lib_dec/TonalComponentDetection.c index fcce91a50daf4fc3f04150ae664c0f7c1c7ced8a..601e878abfb7cf264017fede994a48ea0c7836c8 100644 --- a/lib_dec/TonalComponentDetection.c +++ b/lib_dec/TonalComponentDetection.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #define _USE_MATH_DEFINES #include #include "stl.h" -#include "wmc_auto.h" - #include "options.h" #include "prot_fx.h" @@ -146,13 +144,13 @@ void RefineTonalComponents(Word16 indexOfTonalPeak[], { /* We don't want that the old peak index is at the border of the new peak region, that is why >= newUpperIndex and > newLowerIndex */ test(); - WHILE (sub(iNew,newNumIndexes) < 0 && sub(indexOfTonalPeak[iOld],newUpperIndex[iNew]) >= 0) + WHILE (LT_16(iNew,newNumIndexes)&&GE_16(indexOfTonalPeak[iOld],newUpperIndex[iNew])) { iNew = add(iNew,1); } test(); - IF (sub(iNew,newNumIndexes) < 0 && sub(indexOfTonalPeak[iOld],newLowerIndex[iNew]) > 0) + IF (LT_16(iNew,newNumIndexes)&>_16(indexOfTonalPeak[iOld],newLowerIndex[iNew])) { newIndexOfTonalPeak[nPreservedPeaks] = indexOfTonalPeak[iOld]; move16(); @@ -211,7 +209,7 @@ static void calcPseudoSpec(Word32 * mdctSpec, /* i: MDCT spectrum k = sub(31, *powerSpec_exp); /* If the signal is bellow floor, special care is needed for *powerSpec_exp */ - IF (sub(add(16-3, norm_s(floorPowerSpectrum)), k) < 0) /*extra 3 bits of headroom for MA filter in getEnvelope*/ + IF (LT_16(add(16-3, norm_s(floorPowerSpectrum)), k)) /*extra 3 bits of headroom for MA filter in getEnvelope*/ { k = add(16-3, norm_s(floorPowerSpectrum)); /*extra 3 bits of headroom for MA filter in getEnvelope*/ L_tmp_floor = L_shl(L_deposit_l(floorPowerSpectrum), k); @@ -353,7 +351,7 @@ static void GetF0(Word16 /*int*/ const nSamples, /*i - Q0 /* Use only F0 >= 100 Hz */ test(); - IF ((pitchLag > 0) && (sub(round_fx(pitchLag) , shr(nSamplesCore,1)) <= 0)) + IF ((pitchLag > 0) && (LE_16(round_fx(pitchLag) , shr(nSamplesCore,1)))) { tmpPitchLag /*"halfPitchLag" in FLC - read as Q5 for comparison to halfpitchlag */ @@ -369,7 +367,7 @@ static void GetF0(Word16 /*int*/ const nSamples, /*i - Q0 *pOrigF0 = *pF0; /*Q10*/ move16(); tmp = 2*LAST_HARMONIC_POS_TO_CHECK; - if (sub(nSamples , 2*LAST_HARMONIC_POS_TO_CHECK) < 0 ) + if (LT_16(nSamples , 2*LAST_HARMONIC_POS_TO_CHECK)) { move16(); tmp = nSamples; @@ -431,7 +429,7 @@ static void findStrongestHarmonics(Word16 nSamples, pHarmonicIndexes[nPeaks] = i; move16(); - IF (L_sub(newPeak,smallestPeak) <= 0) + IF (LE_32(newPeak,smallestPeak)) { iSmallestPeak = nPeaks; move16(); @@ -450,7 +448,7 @@ static void findStrongestHarmonics(Word16 nSamples, newPeak = L_add(powerSpectrum[k], 0); - IF (L_sub(newPeak,smallestPeak) > 0) + IF (GT_32(newPeak,smallestPeak)) { peaks[iSmallestPeak] = newPeak; move32(); @@ -510,12 +508,12 @@ static void CorrectF0(Word16 /*int*/ const * pHarmonicIndexes, /*I - Q0 */ move16(); i = 1; move16(); - IF (sub(imult1616(sortedDiff[0],pHarmonicIndexes[0]),1) == 0) + IF (EQ_16(imult1616(sortedDiff[0],pHarmonicIndexes[0]),1)) { /* Find how many distances between peaks have length 1 */ FOR (; i < tmp; i++) { - if (sub(sortedDiff[i],1) == 0) + if (EQ_16(sortedDiff[i],1)) { nSameDiff=add(nSameDiff,1); } @@ -526,18 +524,18 @@ static void CorrectF0(Word16 /*int*/ const * pHarmonicIndexes, /*I - Q0 */ /* If there are at least 3 distances between peaks with length 1 and if the 1st harmonic is in pHarmonicIndexes then keep the original F0 */ /* Otherwise find the most common distance between peaks */ - IF (sub(nSameDiff,3) < 0) + IF (LT_16(nSameDiff,3)) { /* Find the most common difference */ FOR (i = nSameDiff; i < tmp; i++) { - IF (sub(sortedDiff[i], sortedDiff[i-1]) == 0 ) + IF (EQ_16(sortedDiff[i], sortedDiff[i-1])) { nSameDiff=add(nSameDiff,1); } ELSE { - IF (sub(nSameDiff, nMostCommonDiff) > 0) + IF (GT_16(nSameDiff, nMostCommonDiff)) { nMostCommonDiff = nSameDiff; move16(); @@ -546,7 +544,7 @@ static void CorrectF0(Word16 /*int*/ const * pHarmonicIndexes, /*I - Q0 */ } ELSE { test(); - IF (sub(nSameDiff, nMostCommonDiff)==0 && (abs_s(sub(iMostCommonDiff,pHarmonicIndexes[0])) > abs_s(sub(sortedDiff[i-1],pHarmonicIndexes[0])))) + IF (EQ_16(nSameDiff, nMostCommonDiff)&&(abs_s(sub(iMostCommonDiff,pHarmonicIndexes[0]))>abs_s(sub(sortedDiff[i-1],pHarmonicIndexes[0])))) { nMostCommonDiff = nSameDiff; move16(); @@ -558,7 +556,7 @@ static void CorrectF0(Word16 /*int*/ const * pHarmonicIndexes, /*I - Q0 */ move16(); } } - IF (sub(nSameDiff,nMostCommonDiff) > 0) + IF (GT_16(nSameDiff,nMostCommonDiff)) { nMostCommonDiff = nSameDiff; move16(); @@ -568,13 +566,13 @@ static void CorrectF0(Word16 /*int*/ const * pHarmonicIndexes, /*I - Q0 */ } /* If there are enough peaks at the same distance */ - IF (sub(nMostCommonDiff, MAX_PEAKS_FROM_PITCH/2) >= 0) + IF (GE_16(nMostCommonDiff, MAX_PEAKS_FROM_PITCH/2)) { iMult = 1; move16(); FOR (i = 0; i < tmp; i++) { - IF (sub(diff[i], iMostCommonDiff) == 0) + IF (EQ_16(diff[i], iMostCommonDiff)) { iMult = pHarmonicIndexes[i]; move16(); @@ -583,7 +581,7 @@ static void CorrectF0(Word16 /*int*/ const * pHarmonicIndexes, /*I - Q0 */ /* for rare cases of octave mismatch or missing harmonics */ test(); test(); - IF (sub(sub(nHarmonics,2),i) > 0 && (sub(diff[i], diff[i+1]) == 0) && (sub(add(diff[i],diff[i+1]), iMostCommonDiff) == 0)) + IF (GT_16(sub(nHarmonics,2),i)&&(EQ_16(diff[i],diff[i+1]))&&(EQ_16(add(diff[i],diff[i+1]),iMostCommonDiff))) { iMult = pHarmonicIndexes[i]; move16(); @@ -593,7 +591,7 @@ static void CorrectF0(Word16 /*int*/ const * pHarmonicIndexes, /*I - Q0 */ /* If the real F0 is much higher than the original F0 from the pitch */ - IF (sub(iMult, 3) <= 0) + IF (LE_16(iMult, 3)) { /* Use iMostCommonDiff, because the lowest pHarmonicIndexes[i] (which is equal to iMult) may not correspond to the new F0, but to it's multiple */ F0 = round_fx(L_shl(L_mult(iMostCommonDiff /*Q0*/,F0 /*Q10*/),15)); @@ -608,7 +606,7 @@ static void CorrectF0(Word16 /*int*/ const * pHarmonicIndexes, /*I - Q0 */ ELSE { test(); - if ((sub(iMostCommonDiff,1) > 0) || (sub(nMostCommonDiff,3) < 0)) + if ((GT_16(iMostCommonDiff,1))||(LT_16(nMostCommonDiff,3))) { /* Not enough peaks at the same distance => don't use the pitch. */ F0 = 0; @@ -717,39 +715,39 @@ static void findCandidates(Word16 nSamples, /* i: frame siz move16(); tmp_loop1 = sub(nSamples, (GROUP_LENGTH-GROUP_LENGTH/2)); tmp_loop2 = sub(nSamples,1); - WHILE ( sub(k, tmp_loop1) <= 0) + WHILE ( LE_16(k, tmp_loop1)) { - IF (L_sub(smoothedSpectrum[k],envelope[k]) > 0) + IF (GT_32(smoothedSpectrum[k],envelope[k])) { /* The check that bin at k is bigger than bins at k-1 and k+1 is needed to avoid deadlocks when the thresholds are low. */ /* It removes some true peaks, especially if non weighted sum is used for the smoothed spectrum. */ biggerNeighbor = L_max(powerSpectrum[k-1], powerSpectrum[k+1]); - IF (L_sub(powerSpectrum[k], biggerNeighbor) >= 0) + IF (GE_32(powerSpectrum[k], biggerNeighbor)) { /* Find the right foot */ upperIdx = add(k, 1); - WHILE ( sub(upperIdx,tmp_loop2) < 0 ) + WHILE ( LT_16(upperIdx,tmp_loop2)) { - IF (L_sub(powerSpectrum[upperIdx],powerSpectrum[upperIdx+1]) < 0) + IF (LT_32(powerSpectrum[upperIdx],powerSpectrum[upperIdx+1])) { /* Side lobes may increase for certain amount */ - IF (L_sub( L_shl(Mpy_32_16_1(powerSpectrum[upperIdx], ALLOWED_SIDE_LOBE_FLUCTUATION), ALLOWED_SIDE_LOBE_FLUCTUATION_EXP), powerSpectrum[upperIdx+1] ) < 0 ) + IF (LT_32( L_shl(Mpy_32_16_1(powerSpectrum[upperIdx], ALLOWED_SIDE_LOBE_FLUCTUATION), ALLOWED_SIDE_LOBE_FLUCTUATION_EXP), powerSpectrum[upperIdx+1] )) { BREAK; } /* Check for further decrease after a side lobe increase */ FOR (j = add(upperIdx,1); j < tmp_loop2; j++) { - IF (L_sub( powerSpectrum[j], L_shl(Mpy_32_16_1(powerSpectrum[j+1], ALLOWED_SIDE_LOBE_FLUCTUATION), ALLOWED_SIDE_LOBE_FLUCTUATION_EXP) ) < 0) + IF (LT_32( powerSpectrum[j], L_shl(Mpy_32_16_1(powerSpectrum[j+1], ALLOWED_SIDE_LOBE_FLUCTUATION), ALLOWED_SIDE_LOBE_FLUCTUATION_EXP) )) { BREAK; } } /* Side lobe increase must be 2 times smaller than the decrease to the foot */ /* Eq. to 2.0f*powerSpectrum[lowerIdx-1]/powerSpectrum[lowerIdx] > powerSpectrum[lowerIdx]/powerSpectrum[j] */ - IF ( L_sub( Mpy_32_32(L_shl(powerSpectrum[upperIdx+1],1),powerSpectrum[j]), Mpy_32_32(powerSpectrum[upperIdx], powerSpectrum[upperIdx]) ) > 0 ) + IF ( GT_32( Mpy_32_32(L_shl(powerSpectrum[upperIdx+1],1),powerSpectrum[j]), Mpy_32_32(powerSpectrum[upperIdx], powerSpectrum[upperIdx]) )) { BREAK; } @@ -762,24 +760,24 @@ static void findCandidates(Word16 nSamples, /* i: frame siz WHILE ( lowerIdx > 0 ) { - IF (L_sub(powerSpectrum[lowerIdx], powerSpectrum[lowerIdx-1]) < 0) + IF (LT_32(powerSpectrum[lowerIdx], powerSpectrum[lowerIdx-1])) { /* Side lobes may increase for certain amount */ - IF (L_sub( L_shl(Mpy_32_16_1(powerSpectrum[lowerIdx], ALLOWED_SIDE_LOBE_FLUCTUATION), ALLOWED_SIDE_LOBE_FLUCTUATION_EXP), powerSpectrum[lowerIdx-1]) < 0 ) + IF (LT_32( L_shl(Mpy_32_16_1(powerSpectrum[lowerIdx], ALLOWED_SIDE_LOBE_FLUCTUATION), ALLOWED_SIDE_LOBE_FLUCTUATION_EXP), powerSpectrum[lowerIdx-1])) { BREAK; } /* Check for further decrease after a side lobe increase */ FOR (j = sub(lowerIdx,1); j > 0; j--) { - IF (L_sub (powerSpectrum[j], L_shl(Mpy_32_16_1(powerSpectrum[j-1], ALLOWED_SIDE_LOBE_FLUCTUATION), ALLOWED_SIDE_LOBE_FLUCTUATION_EXP) ) < 0) + IF (LT_32(powerSpectrum[j], L_shl(Mpy_32_16_1(powerSpectrum[j-1], ALLOWED_SIDE_LOBE_FLUCTUATION), ALLOWED_SIDE_LOBE_FLUCTUATION_EXP) ) ) { BREAK; } } /* Side lobe increase must be 2 times smaller than the decrease to the foot */ /* Eq. to 2.0f*powerSpectrum[lowerIdx-1]/powerSpectrum[lowerIdx] > powerSpectrum[lowerIdx]/powerSpectrum[j] */ - IF (L_sub ( Mpy_32_32(L_shl(powerSpectrum[lowerIdx-1],1), powerSpectrum[j]), Mpy_32_32(powerSpectrum[lowerIdx], powerSpectrum[lowerIdx])) > 0 ) + IF (GT_32 ( Mpy_32_32(L_shl(powerSpectrum[lowerIdx-1],1), powerSpectrum[j]), Mpy_32_32(powerSpectrum[lowerIdx], powerSpectrum[lowerIdx])) ) { BREAK; } @@ -792,7 +790,7 @@ static void findCandidates(Word16 nSamples, /* i: frame siz tmp_loop3 = s_min(upperIdx, tmp_loop1); FOR (j = s_max(GROUP_LENGTH/2, lowerIdx); j <= tmp_loop3; j++) { - if (L_sub(powerSpectrum[j], powerSpectrum[k]) > 0) + if (GT_32(powerSpectrum[j], powerSpectrum[k])) { k = j; move16(); @@ -806,7 +804,7 @@ static void findCandidates(Word16 nSamples, /* i: frame siz thresholdModificationNew[j] = BIG_THRESHOLD; move16(); - if (L_sub(smoothedSpectrum[j], envelope[j]) > 0) + if (GT_32(smoothedSpectrum[j], envelope[j])) { thresholdModificationNew[j] = SMALL_THRESHOLD; move16(); @@ -839,7 +837,7 @@ static void RefineThresholdsUsingPitch(Word16 nSamples, pitchIsStable = 0; move16(); L_tmp = L_abs(L_sub(lastPitchLag, currentPitchLag)); - if (L_sub(L_tmp, 16384l/*0.25f Q16*/) < 0) + if (LT_32(L_tmp, 16384l/*0.25f Q16*/)) { pitchIsStable = 1; move16(); @@ -890,39 +888,39 @@ static void findTonalComponents(Word16 * indexOfTonalPeak, /* OUT */ move16(); tmp_loop1 = sub(nSamples, (GROUP_LENGTH-GROUP_LENGTH/2)); tmp_loop2 = sub(nSamples,1); - WHILE ( sub(k, tmp_loop1) <= 0) + WHILE ( LE_16(k, tmp_loop1)) { /* There is 3 bits headroom in envelope and max of thresholdModification is 16384, so shifting left for 4 would produce overflow only when the result is anyhow close to 1 */ - IF (L_sub(L_shr(smoothedSpectrum[k], 1), L_shl(Mpy_32_16_1(envelope[k]/*Q28,powerSpec_exp*/, thresholdModification[k]/*Q10*/), 4)) > 0) + IF (GT_32(L_shr(smoothedSpectrum[k], 1), L_shl(Mpy_32_16_1(envelope[k]/*Q28,powerSpec_exp*/, thresholdModification[k]/*Q10*/), 4))) { /* The check that bin at k is bigger than bins at k-1 and k+1 is needed to avoid deadlocks when the thresholds are low. */ /* It removes some true peaks, especially if non weighted sum is used for the smoothed spectrum. */ biggerNeighbor = L_max(powerSpectrum[k-1], powerSpectrum[k+1]); - IF (L_sub(powerSpectrum[k], biggerNeighbor) >= 0 ) + IF (GE_32(powerSpectrum[k], biggerNeighbor)) { /* Find the right foot */ upperIdx = add(k, 1); - WHILE (sub(upperIdx, tmp_loop2) < 0) + WHILE (LT_16(upperIdx, tmp_loop2)) { - IF (L_sub(powerSpectrum[upperIdx], powerSpectrum[upperIdx+1]) < 0) + IF (LT_32(powerSpectrum[upperIdx], powerSpectrum[upperIdx+1])) { /* Side lobes may increase for certain amount */ - IF (L_sub( L_shl(Mpy_32_16_1(powerSpectrum[upperIdx], ALLOWED_SIDE_LOBE_FLUCTUATION), ALLOWED_SIDE_LOBE_FLUCTUATION_EXP), powerSpectrum[upperIdx+1]) < 0) + IF (LT_32( L_shl(Mpy_32_16_1(powerSpectrum[upperIdx], ALLOWED_SIDE_LOBE_FLUCTUATION), ALLOWED_SIDE_LOBE_FLUCTUATION_EXP), powerSpectrum[upperIdx+1])) { BREAK; } /* Check for further decrease after a side lobe increase */ FOR (j = add(upperIdx, 1); j < tmp_loop2; j++) { - IF (L_sub( powerSpectrum[j], L_shl(Mpy_32_16_1(powerSpectrum[j+1], ALLOWED_SIDE_LOBE_FLUCTUATION), ALLOWED_SIDE_LOBE_FLUCTUATION_EXP)) < 0) + IF (LT_32( powerSpectrum[j], L_shl(Mpy_32_16_1(powerSpectrum[j+1], ALLOWED_SIDE_LOBE_FLUCTUATION), ALLOWED_SIDE_LOBE_FLUCTUATION_EXP))) { BREAK; } } /* Side lobe increase must be 2 times smaller than the decrease to the foot */ /* Eq. to 2.0f*powerSpectrum[lowerIdx-1]/powerSpectrum[lowerIdx] > powerSpectrum[lowerIdx]/powerSpectrum[j] */ - IF (L_sub( Mpy_32_32(L_shl(powerSpectrum[upperIdx+1], 1), powerSpectrum[j]), Mpy_32_32(powerSpectrum[upperIdx], powerSpectrum[upperIdx])) > 0) + IF (GT_32( Mpy_32_32(L_shl(powerSpectrum[upperIdx+1], 1), powerSpectrum[j]), Mpy_32_32(powerSpectrum[upperIdx], powerSpectrum[upperIdx]))) { BREAK; } @@ -932,26 +930,26 @@ static void findTonalComponents(Word16 * indexOfTonalPeak, /* OUT */ } /* left foot */ lowerIdx = sub(k, 1); - WHILE (sub(lowerIdx, lowerBound) > 0) + WHILE (GT_16(lowerIdx, lowerBound)) { - IF (L_sub(powerSpectrum[lowerIdx], powerSpectrum[lowerIdx-1]) < 0) + IF (LT_32(powerSpectrum[lowerIdx], powerSpectrum[lowerIdx-1])) { /* Side lobes may increase for certain amount */ - IF ( L_sub(L_shl(Mpy_32_16_1(powerSpectrum[lowerIdx], ALLOWED_SIDE_LOBE_FLUCTUATION), ALLOWED_SIDE_LOBE_FLUCTUATION_EXP), powerSpectrum[lowerIdx-1]) < 0) + IF ( LT_32(L_shl(Mpy_32_16_1(powerSpectrum[lowerIdx], ALLOWED_SIDE_LOBE_FLUCTUATION), ALLOWED_SIDE_LOBE_FLUCTUATION_EXP), powerSpectrum[lowerIdx-1])) { BREAK; } /* Check for further decrease after a side lobe increase */ FOR (j = sub(lowerIdx, 1); j > 0; j--) { - IF (L_sub(powerSpectrum[j], L_shl(Mpy_32_16_1(powerSpectrum[j-1], ALLOWED_SIDE_LOBE_FLUCTUATION), ALLOWED_SIDE_LOBE_FLUCTUATION_EXP)) < 0) + IF (LT_32(powerSpectrum[j], L_shl(Mpy_32_16_1(powerSpectrum[j-1], ALLOWED_SIDE_LOBE_FLUCTUATION), ALLOWED_SIDE_LOBE_FLUCTUATION_EXP))) { BREAK; } } /* Side lobe increase must be 2 times smaller than the decrease to the foot */ /* Eq. to 2.0f*powerSpectrum[lowerIdx-1]/powerSpectrum[lowerIdx] > powerSpectrum[lowerIdx]/powerSpectrum[j] */ - IF ( L_sub( Mpy_32_32(L_shl(powerSpectrum[lowerIdx-1], 1), powerSpectrum[j]), Mpy_32_32(powerSpectrum[lowerIdx], powerSpectrum[lowerIdx])) > 0) + IF ( GT_32( Mpy_32_32(L_shl(powerSpectrum[lowerIdx-1], 1), powerSpectrum[j]), Mpy_32_32(powerSpectrum[lowerIdx], powerSpectrum[lowerIdx]))) { BREAK; } @@ -967,7 +965,7 @@ static void findTonalComponents(Word16 * indexOfTonalPeak, /* OUT */ tmp_loop3 = s_min(upperIdx, tmp_loop1); FOR (j = s_max(GROUP_LENGTH/2, lowerIdx); j <= tmp_loop3; j++) { - if (L_sub(powerSpectrum[j],powerSpectrum[k]) > 0) + if (GT_32(powerSpectrum[j],powerSpectrum[k])) { k = j; @@ -984,7 +982,7 @@ static void findTonalComponents(Word16 * indexOfTonalPeak, /* OUT */ move16(); test(); - IF ((nrOfFIS > 0) && (sub(lowerIndex[nrOfFIS], upperIndex[nrOfFIS-1]) <= 0)) + IF ((nrOfFIS > 0) && (LE_16(lowerIndex[nrOfFIS], upperIndex[nrOfFIS-1]))) { m = shr(add(k, indexOfTonalPeak[nrOfFIS-1]), 1); upperIndex[nrOfFIS-1] = m; @@ -996,7 +994,7 @@ static void findTonalComponents(Word16 * indexOfTonalPeak, /* OUT */ indexOfTonalPeak[nrOfFIS++] = k; move16(); - IF (sub(nrOfFIS, MAX_NUMBER_OF_IDX) == 0 ) + IF (EQ_16(nrOfFIS, MAX_NUMBER_OF_IDX)) { BREAK; } diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index cf24e9bfbf9edf5d2fa64b3ed0004d9838dcc079..544c38cb37d0b953d5ce78b99f2f28b80d0c6659 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -8,9 +8,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - - #include "basop_mpy.h" /*==========================================================================*/ @@ -125,7 +122,7 @@ void acelp_core_dec_fx( move16(); st_fx->bpf_off_fx = 0; move16(); - if( sub(st_fx->last_core_fx,HQ_CORE) == 0 ) + if( EQ_16(st_fx->last_core_fx,HQ_CORE)) { /* in case of HQ->ACELP switching, do not apply BPF */ st_fx->bpf_off_fx = 1; @@ -169,7 +166,7 @@ void acelp_core_dec_fx( move16(); set16_fx( gain_buf, 0, NB_SUBFR16k ); - IF( sub(st_fx->L_frame_fx,L_FRAME) == 0 ) + IF( EQ_16(st_fx->L_frame_fx,L_FRAME)) { st_fx->gamma = GAMMA1; move16(); @@ -199,7 +196,7 @@ void acelp_core_dec_fx( move16(); test(); test(); - if( st_fx->last_con_tcx && sub(st_fx->L_frameTCX_past, st_fx->L_frame_fx) != 0 && st_fx->last_core_fx != 0 ) + if( st_fx->last_con_tcx && NE_16(st_fx->L_frameTCX_past, st_fx->L_frame_fx)&&st_fx->last_core_fx!=0) { avoid_lpc_burst_on_recovery = 1; move16(); @@ -209,7 +206,7 @@ void acelp_core_dec_fx( * Updates in case of internal sampling rate switching *----------------------------------------------------------------*/ test(); - IF( sub(st_fx->last_L_frame_fx,st_fx->L_frame_fx) != 0 && sub(st_fx->last_core_fx, HQ_CORE) != 0 ) + IF( NE_16(st_fx->last_L_frame_fx,st_fx->L_frame_fx)&&NE_16(st_fx->last_core_fx,HQ_CORE)) { if( st_fx->pfstat.on != 0 ) { @@ -232,7 +229,7 @@ void acelp_core_dec_fx( Copy( st_fx->lsf_old_fx, st_fx->lsf_adaptive_mean_fx, M ); /* Reset LPC mem */ - IF( L_sub(st_fx->sr_core,16000) == 0 ) + IF( EQ_32(st_fx->sr_core,16000)) { Copy( GEWB2_Ave_fx, st_fx->mem_AR_fx, M ); } @@ -251,18 +248,18 @@ void acelp_core_dec_fx( } - IF( sub(st_fx->last_L_frame_fx,st_fx->L_frame_fx) != 0 ) + IF( NE_16(st_fx->last_L_frame_fx,st_fx->L_frame_fx)) { /* update buffer of old subframe pitch values */ - IF( sub(st_fx->L_frame_fx,L_FRAME) == 0 ) + IF( EQ_16(st_fx->L_frame_fx,L_FRAME)) { move16(); - IF( sub(st_fx->last_L_frame_fx,L_FRAME32k) == 0 ) + IF( EQ_16(st_fx->last_L_frame_fx,L_FRAME32k)) { /* (float)12800/(float)32000; */ k = 13107; } - ELSE IF( sub(st_fx->last_L_frame_fx,512) == 0 ) + ELSE IF( EQ_16(st_fx->last_L_frame_fx,512)) { /* (float)12800/(float)25600; */ k = 16384; @@ -288,12 +285,12 @@ void acelp_core_dec_fx( ELSE { move16(); - IF( sub(st_fx->last_L_frame_fx,L_FRAME32k) == 0 ) + IF( EQ_16(st_fx->last_L_frame_fx,L_FRAME32k)) { /* (float)16000/(float)32000; */ k = -16384; } - ELSE IF( sub(st_fx->last_L_frame_fx,512) == 0 ) + ELSE IF( EQ_16(st_fx->last_L_frame_fx,512)) { /* tmpF = (float)16000/(float)25600; */ k = -12288; @@ -322,17 +319,17 @@ void acelp_core_dec_fx( } } - IF( sub(st_fx->bfi_pitch_frame_fx, st_fx->L_frame_fx) != 0 ) + IF( NE_16(st_fx->bfi_pitch_frame_fx, st_fx->L_frame_fx)) { - IF( sub(st_fx->L_frame_fx,L_FRAME) == 0 ) + IF( EQ_16(st_fx->L_frame_fx,L_FRAME)) { move16(); - IF( sub(st_fx->bfi_pitch_frame_fx,L_FRAME32k) == 0 ) + IF( EQ_16(st_fx->bfi_pitch_frame_fx,L_FRAME32k)) { /* (float)12800/(float)32000; */ k = 13107; } - ELSE IF( sub(st_fx->bfi_pitch_frame_fx,512) == 0 ) + ELSE IF( EQ_16(st_fx->bfi_pitch_frame_fx,512)) { /* (float)12800/(float)25600; */ k = 16384; @@ -349,12 +346,12 @@ void acelp_core_dec_fx( ELSE { move16(); - IF( sub(st_fx->bfi_pitch_frame_fx,L_FRAME32k) == 0 ) + IF( EQ_16(st_fx->bfi_pitch_frame_fx,L_FRAME32k)) { /* (float)16000/(float)32000; */ k = -16384; } - ELSE IF( sub(st_fx->bfi_pitch_frame_fx,512) == 0 ) + ELSE IF( EQ_16(st_fx->bfi_pitch_frame_fx,512)) { /* tmpF = (float)16000/(float)25600; */ k = -12288; @@ -372,7 +369,7 @@ void acelp_core_dec_fx( test(); test(); - if( sub(st_fx->last_bwidth_fx,NB)==0 && sub(st_fx->bwidth_fx,NB)!=0 && st_fx->ini_frame_fx!=0 ) + if( EQ_16(st_fx->last_bwidth_fx,NB)&&NE_16(st_fx->bwidth_fx,NB)&&st_fx->ini_frame_fx!=0) { st_fx->rate_switching_reset=1; move16(); @@ -391,7 +388,7 @@ void acelp_core_dec_fx( tc_subfr_fx = -1; move16(); - if( sub(coder_type_fx,TRANSITION) == 0 ) + if( EQ_16(coder_type_fx,TRANSITION)) { tc_subfr_fx = tc_classif_fx( st_fx, st_fx->L_frame_fx ); move16(); @@ -401,10 +398,10 @@ void acelp_core_dec_fx( * Decoding of inactive CNG frames *----------------------------------------------------------------*/ test(); - IF ( st_fx->core_brate_fx == FRAME_NO_DATA || L_sub(st_fx->core_brate_fx,SID_2k40) == 0 ) + IF ( st_fx->core_brate_fx == FRAME_NO_DATA || EQ_32(st_fx->core_brate_fx,SID_2k40)) { /* decode CNG parameters */ - IF ( sub(st_fx->cng_type_fx,LP_CNG) == 0 ) + IF ( EQ_16(st_fx->cng_type_fx,LP_CNG)) { CNG_dec_fx( st_fx, st_fx->L_frame_fx, Aq_fx, st_fx->core_brate_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step_fx, sid_bw, q_env ); @@ -416,7 +413,7 @@ void acelp_core_dec_fx( } ELSE { - IF( L_sub(st_fx->core_brate_fx,SID_2k40) == 0 ) + IF( EQ_32(st_fx->core_brate_fx,SID_2k40)) { FdCng_decodeSID(st_fx->hFdCngDec_fx->hFdCngCom, st_fx); *sid_bw=0; @@ -433,7 +430,7 @@ void acelp_core_dec_fx( delta_mem_scale = 3; move16(); test(); - if( L_sub(st_fx->lp_ener_fx,40) < 0 && sub(st_fx->cng_type_fx,LP_CNG) == 0 ) /* very low energy frames, less than 0.3125 */ + if( LT_32(st_fx->lp_ener_fx,40)&&EQ_16(st_fx->cng_type_fx,LP_CNG)) /* very low energy frames, less than 0.3125 */ { delta_mem_scale = 0; move16(); @@ -487,7 +484,7 @@ void acelp_core_dec_fx( *-----------------------------------------------------------------*/ test(); - IF ( st_fx->last_core_brate_fx == FRAME_NO_DATA || L_sub(st_fx->last_core_brate_fx,SID_2k40) == 0 ) + IF ( st_fx->last_core_brate_fx == FRAME_NO_DATA || EQ_32(st_fx->last_core_brate_fx,SID_2k40)) { Copy( st_fx->lspCNG_fx, st_fx->lsp_old_fx, M ); @@ -520,7 +517,7 @@ void acelp_core_dec_fx( * FEC - first good frame after lost frame(s) (possibility to correct the ACB) *-----------------------------------------------------------------*/ - IF( L_sub(st_fx->core_brate_fx,ACELP_11k60) >= 0 ) + IF( GE_32(st_fx->core_brate_fx,ACELP_11k60)) { last_pulse_pos = 0; move16(); @@ -531,7 +528,7 @@ void acelp_core_dec_fx( test(); test(); - IF( sub(st_fx->last_core_fx,HQ_CORE) != 0 || (sub(st_fx->last_core_fx,HQ_CORE) == 0 && st_fx->last_con_tcx) ) + IF( NE_16(st_fx->last_core_fx,HQ_CORE)||(EQ_16(st_fx->last_core_fx,HQ_CORE)&&st_fx->last_con_tcx)) { test(); test(); @@ -539,12 +536,12 @@ void acelp_core_dec_fx( test(); test(); test(); - IF( sub(st_fx->clas_dec,SIN_ONSET) == 0 && last_pulse_pos != 0 && sub(st_fx->prev_bfi_fx,1) == 0 ) + IF( EQ_16(st_fx->clas_dec,SIN_ONSET)&&last_pulse_pos!=0&&EQ_16(st_fx->prev_bfi_fx,1)) { st_fx->Q_exc = FEC_SinOnset_fx( old_exc_fx+L_EXC_MEM_DEC-L_EXC_MEM, last_pulse_pos, T0_tmp, enr_q_fx, Aq_fx, st_fx->L_frame_fx, st_fx->Q_exc ); } - ELSE IF( (sub(coder_type_fx,GENERIC) == 0 || sub(coder_type_fx,VOICED) == 0) && last_pulse_pos != 0 && sub(st_fx->old_bfi_cnt_fx,1) == 0 && sub(output_frame,L_FRAME16k) == 0) + ELSE IF( (EQ_16(coder_type_fx,GENERIC)||EQ_16(coder_type_fx,VOICED))&&last_pulse_pos!=0&&EQ_16(st_fx->old_bfi_cnt_fx,1)&&EQ_16(output_frame,L_FRAME16k)) { do_WI_fx = FEC_enhACB_fx( st_fx->L_frame_fx, st_fx->last_L_frame_fx, old_exc_fx+L_EXC_MEM_DEC-L_EXC_MEM , T0_tmp, last_pulse_pos, st_fx->bfi_pitch_fx ); } @@ -559,7 +556,7 @@ void acelp_core_dec_fx( test(); test(); test(); - IF( st_fx->stab_fac_fx == 0 && st_fx->old_bfi_cnt_fx > 0 && sub(st_fx->clas_dec,VOICED_CLAS) != 0 && sub(st_fx->clas_dec,ONSET) != 0 && st_fx->relax_prev_lsf_interp_fx == 0 ) + IF( st_fx->stab_fac_fx == 0 && st_fx->old_bfi_cnt_fx > 0 && NE_16(st_fx->clas_dec,VOICED_CLAS)&&NE_16(st_fx->clas_dec,ONSET)&&st_fx->relax_prev_lsf_interp_fx==0) { int_lsp4_fx(st_fx->L_frame_fx, st_fx->lsp_old_fx, lsp_mid_fx, lsp_new_fx, Aq_fx, M, 2 ); } @@ -575,11 +572,11 @@ void acelp_core_dec_fx( test(); test(); test(); - IF( ( sub(coder_type_fx,UNVOICED) != 0 && - sub(coder_type_fx,AUDIO) != 0 && - sub(coder_type_fx,INACTIVE) != 0 && - !(L_sub(st_fx->core_brate_fx,ACELP_8k00) <= 0 && sub(coder_type_fx,TRANSITION) != 0) ) || - (sub(coder_type_fx,INACTIVE) == 0 && L_sub(st_fx->total_brate_fx,ACELP_32k) >= 0) + IF( ( NE_16(coder_type_fx,UNVOICED)&& + NE_16(coder_type_fx,AUDIO) && + NE_16(coder_type_fx,INACTIVE) && + !(LE_32(st_fx->core_brate_fx,ACELP_8k00) && NE_16(coder_type_fx,TRANSITION) ) ) || + (EQ_16(coder_type_fx,INACTIVE) && GE_32(st_fx->total_brate_fx,ACELP_32k) ) ) { Es_pred_dec_fx( st_fx, &Es_pred_fx, coder_type_fx, st_fx->core_brate_fx ); @@ -591,7 +588,7 @@ void acelp_core_dec_fx( test(); test(); - IF( sub(st_fx->nelp_mode_dec_fx,1) == 0) + IF( EQ_16(st_fx->nelp_mode_dec_fx,1)) { /* SC-VBR - NELP frames */ Scale_sig(exc_fx-L_EXC_MEM, L_EXC_MEM, -st_fx->Q_exc); @@ -603,12 +600,12 @@ void acelp_core_dec_fx( Rescale_exc(st_fx->dct_post_old_exc_fx, exc_fx, NULL, st_fx->last_exc_dct_in_fx, L_FRAME, 0, (Word32)0, &(st_fx->Q_exc), st_fx->Q_subfr, exc2_fx, L_FRAME, coder_type_fx); } - ELSE IF( sub(coder_type_fx,UNVOICED) == 0) + ELSE IF( EQ_16(coder_type_fx,UNVOICED)) { /* UNVOICED frames */ decod_unvoiced_fx( st_fx, Aq_fx, coder_type_fx, &tmp_noise_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, gain_buf ); } - ELSE IF ( sub(st_fx->ppp_mode_dec_fx,1) == 0 ) + ELSE IF ( EQ_16(st_fx->ppp_mode_dec_fx,1)) { Scale_sig(exc_fx-L_EXC_MEM, L_EXC_MEM, -st_fx->Q_exc); st_fx->Q_exc = 0; @@ -617,11 +614,11 @@ void acelp_core_dec_fx( Rescale_exc( st_fx->dct_post_old_exc_fx, exc_fx, NULL, st_fx->last_exc_dct_in_fx, L_FRAME, 0, (Word32)0, &(st_fx->Q_exc), st_fx->Q_subfr, exc2_fx, L_FRAME, coder_type_fx ); } - ELSE IF( sub(coder_type_fx,TRANSITION ) == 0) + ELSE IF( EQ_16(coder_type_fx,TRANSITION )) { decod_tran_fx( st_fx, st_fx->L_frame_fx, tc_subfr_fx, Aq_fx, coder_type_fx, Es_pred_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, unbits, sharpFlag, gain_buf ); } - ELSE IF( sub(coder_type_fx,AUDIO) == 0|| ( sub(coder_type_fx,INACTIVE) == 0 && L_sub(st_fx->core_brate_fx,ACELP_24k40) <= 0) ) + ELSE IF( EQ_16(coder_type_fx,AUDIO)||(EQ_16(coder_type_fx,INACTIVE)&&LE_32(st_fx->core_brate_fx,ACELP_24k40))) { decod_audio_fx( st_fx, dct_exc_tmp, Aq_fx, coder_type_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf ); tmp_noise_fx = shr_r(st_fx->lp_gainc_fx,3); /*Q0*/ @@ -647,7 +644,7 @@ void acelp_core_dec_fx( * Decode information and modify the excitation signal of stationary unvoiced frames *------------------------------------------------------------*/ - IF ( sub(st_fx->nelp_mode_dec_fx,1) != 0 ) + IF ( NE_16(st_fx->nelp_mode_dec_fx,1)) { stat_noise_uv_dec_fx( st_fx, coder_type_fx, lsp_new_fx, lsp_mid_fx, Aq_fx, exc2_fx ); } @@ -663,7 +660,7 @@ void acelp_core_dec_fx( Copy( st_fx->dct_post_old_exc_fx, exc_buffer_fx, DCT_L_POST-OFFSET2 ); test(); - IF( sub(coder_type_fx, AUDIO )== 0 && st_fx->GSC_noisy_speech_fx == 0 ) + IF( EQ_16(coder_type_fx, AUDIO )&&st_fx->GSC_noisy_speech_fx==0) { /* Extrapolation of the last future part, windowing and high resolution DCT transform */ @@ -688,7 +685,7 @@ void acelp_core_dec_fx( /* Core synthesis at 12.8kHz or 16kHz */ i = 1; move16(); - if( sub(coder_type_fx,INACTIVE) == 0 ) + if( EQ_16(coder_type_fx,INACTIVE)) { i = 0; move16(); @@ -698,7 +695,7 @@ void acelp_core_dec_fx( move16(); test(); test(); - if( sub(coder_type_fx, INACTIVE) == 0 && st_fx->flag_cna && sub(round_fx(L_shl(st_fx->lp_noise,1)), 15<<7) >= 0 ) + if( EQ_16(coder_type_fx, INACTIVE)&&st_fx->flag_cna&&GE_16(round_fx(L_shl(st_fx->lp_noise,1)),15<<7)) { k = 1; move16(); @@ -754,7 +751,7 @@ void acelp_core_dec_fx( exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, st_fx->Q_exc, st_fx->Q_syn , avoid_lpc_burst_on_recovery, 0 ); test(); - if( (L_sub(st_fx->total_brate_fx,ACELP_7k20) == 0) || (L_sub(st_fx->total_brate_fx,ACELP_8k00) == 0) ) + if( (EQ_32(st_fx->total_brate_fx,ACELP_7k20))||(EQ_32(st_fx->total_brate_fx,ACELP_8k00))) { frame_ener_fx( st_fx->L_frame_fx, st_fx->clas_dec, syn_fx, pitch_buf_tmp[sub(shr(st_fx->L_frame_fx,6),1)], &st_fx->enr_old_fx, st_fx->L_frame_fx, st_fx->Q_syn, 3, 0 ); } @@ -768,7 +765,7 @@ void acelp_core_dec_fx( ELSE { /* SC-VBR */ - if ( sub(st_fx->last_nelp_mode_dec_fx,1) == 0 ) + if ( EQ_16(st_fx->last_nelp_mode_dec_fx,1)) { st_fx->nelp_mode_dec_fx = 1; move16(); @@ -777,7 +774,7 @@ void acelp_core_dec_fx( /* long burst frame erasures */ test(); test(); - if( sub(st_fx->nbLostCmpt,5) > 0 && sub(st_fx->clas_dec,VOICED_CLAS) >= 0 && sub(st_fx->clas_dec,INACTIVE_CLAS) < 0 ) + if( GT_16(st_fx->nbLostCmpt,5)&&GE_16(st_fx->clas_dec,VOICED_CLAS)&<_16(st_fx->clas_dec,INACTIVE_CLAS)) { st_fx->last_good_fx = VOICED_TRANSITION; move16(); @@ -840,7 +837,7 @@ void acelp_core_dec_fx( move16(); test(); test(); - if( sub(coder_type_fx, INACTIVE) == 0 && st_fx->flag_cna && sub(round_fx(L_shl(st_fx->lp_noise,1)), 15<<7) >= 0 ) + if( EQ_16(coder_type_fx, INACTIVE)&&st_fx->flag_cna&&GE_16(round_fx(L_shl(st_fx->lp_noise,1)),15<<7)) { k = 1; move16(); @@ -849,7 +846,7 @@ void acelp_core_dec_fx( Rescale_mem( st_fx->Q_exc, &st_fx->prev_Q_syn, &st_fx->Q_syn, st_fx->mem_syn2_fx, st_fx->mem_syn_clas_estim_fx, 4, &st_fx->mem_deemph_fx, st_fx->pst_old_syn_fx, &st_fx->pst_mem_deemp_err_fx, &st_fx->agc_mem_fx[1], &st_fx->pfstat, 1, k, temp_buf_fx ); - if( (L_sub(st_fx->total_brate_fx,ACELP_7k20) == 0) || (L_sub(st_fx->total_brate_fx,ACELP_8k00) == 0) ) + if( (EQ_32(st_fx->total_brate_fx,ACELP_7k20))||(EQ_32(st_fx->total_brate_fx,ACELP_8k00))) { Copy( st_fx->mem_syn2_fx, mem_tmp_fx, M ); } @@ -877,7 +874,7 @@ void acelp_core_dec_fx( move16(); } - if( (L_sub(st_fx->total_brate_fx,ACELP_7k20) == 0) || (L_sub(st_fx->total_brate_fx,ACELP_8k00) == 0) ) + if( (EQ_32(st_fx->total_brate_fx,ACELP_7k20))||(EQ_32(st_fx->total_brate_fx,ACELP_8k00))) { k = 0; move16(); @@ -914,7 +911,7 @@ void acelp_core_dec_fx( st_fx->FadeScale_fx = mult(st_fx->FadeScale_fx,24576); /*24576 in Q15*/ } - IF (sub(st_fx->L_frame_fx,L_FRAME) == 0) + IF (EQ_16(st_fx->L_frame_fx,L_FRAME)) { Copy( Aq_fx+2*(M+1), st_fx->cur_sub_Aq_fx, (M+1) ); } @@ -927,7 +924,7 @@ void acelp_core_dec_fx( * Apply NB postfilter in case of 8kHz output *--------------------------------------------------------*/ - IF( sub(st_fx->last_bwidth_fx,NB) == 0 ) + IF( EQ_16(st_fx->last_bwidth_fx,NB)) { k = 0; move16(); @@ -938,7 +935,7 @@ void acelp_core_dec_fx( k++; } - IF(sub(st_fx->bwidth_fx,NB) == 0) + IF(EQ_16(st_fx->bwidth_fx,NB)) { st_fx->pfstat.on = 1; move16(); @@ -977,14 +974,14 @@ void acelp_core_dec_fx( test(); test(); - IF( sub(st_fx->last_bwidth_fx,WB) >= 0 && L_sub(st_fx->core_brate_fx,ACELP_24k40) > 0 && L_sub(st_fx->core_brate_fx,ACELP_32k) <= 0) + IF( GE_16(st_fx->last_bwidth_fx,WB)&>_32(st_fx->core_brate_fx,ACELP_24k40)&&LE_32(st_fx->core_brate_fx,ACELP_32k)) { Copy( syn_fx, temp_buf + L_SYN_MEM, L_FRAME16k ); st_fx->pfstat.on = 1; move16(); formant_post_filt( &(st_fx->pfstat), temp_buf + L_SYN_MEM, Aq_fx, syn_fx, L_FRAME16k, st_fx->lp_noise, st_fx->total_brate_fx, 0); } - ELSE IF( sub(st_fx->last_bwidth_fx,WB) >= 0 ) + ELSE IF( GE_16(st_fx->last_bwidth_fx,WB)) { if( st_fx->pfstat.on ) { @@ -1008,7 +1005,7 @@ void acelp_core_dec_fx( test(); test(); test(); - IF( st_fx->flag_cna || (sub(st_fx->cng_type_fx,FD_CNG) == 0 && L_sub(st_fx->total_brate_fx,ACELP_32k) <= 0) || (sub(st_fx->cng_type_fx,LP_CNG) == 0 && L_sub(st_fx->total_brate_fx, SID_2k40) <= 0) ) + IF( st_fx->flag_cna || (EQ_16(st_fx->cng_type_fx,FD_CNG)&&LE_32(st_fx->total_brate_fx,ACELP_32k))||(EQ_16(st_fx->cng_type_fx,LP_CNG)&&LE_32(st_fx->total_brate_fx,SID_2k40))) { /*VAD only for non inactive frame*/ test(); @@ -1032,14 +1029,14 @@ void acelp_core_dec_fx( test(); test(); ApplyFdCng( syn_fx, st_fx->Q_syn, realBuffer, imagBuffer, 0, st_fx->hFdCngDec_fx, st_fx->m_frame_type, st_fx, 0, - (sub(coder_type_fx, AUDIO )== 0 && st_fx->GSC_noisy_speech_fx == 0) ); + (EQ_16(coder_type_fx, AUDIO ) && st_fx->GSC_noisy_speech_fx == 0) ); /* CNA: Generate additional comfort noise to mask potential coding artefacts */ test(); test(); test(); test(); - IF( st_fx->flag_cna && sub(coder_type_fx,AUDIO) != 0 ) + IF( st_fx->flag_cna && NE_16(coder_type_fx,AUDIO)) { generate_masking_noise( syn_fx, st_fx->Q_syn, st_fx->hFdCngDec_fx->hFdCngCom, st_fx->hFdCngDec_fx->hFdCngCom->frameSize, 0 ); } @@ -1053,7 +1050,7 @@ void acelp_core_dec_fx( } } - IF( st_fx->flag_cna == 0 && sub(st_fx->L_frame_fx,L_FRAME16k) == 0 && st_fx->last_flag_cna == 1 && ( (st_fx->last_core_fx == ACELP_CORE && st_fx->last_coder_type_fx != AUDIO) || st_fx->last_core_fx == AMR_WB_CORE) ) + IF( st_fx->flag_cna == 0 && EQ_16(st_fx->L_frame_fx,L_FRAME16k)&&st_fx->last_flag_cna==1&&((st_fx->last_core_fx==ACELP_CORE&&st_fx->last_coder_type_fx!=AUDIO)||st_fx->last_core_fx==AMR_WB_CORE)) { FOR (i=0; i < st_fx->L_frame_fx/2; i++) { @@ -1063,7 +1060,7 @@ void acelp_core_dec_fx( } test(); - IF( st_fx->flag_cna == 0 || sub(coder_type_fx,AUDIO) == 0 ) + IF( st_fx->flag_cna == 0 || EQ_16(coder_type_fx,AUDIO)) { set16_fx( st_fx->hFdCngDec_fx->hFdCngCom->olapBufferSynth2, 0, st_fx->hFdCngDec_fx->hFdCngCom->fftlen ); } @@ -1088,13 +1085,13 @@ void acelp_core_dec_fx( } test(); - IF( sub(st_fx->L_frame_fx,st_fx->last_L_frame_fx) != 0 && sub(st_fx->last_codec_mode,MODE2) != 0 ) + IF( NE_16(st_fx->L_frame_fx,st_fx->last_L_frame_fx)&&NE_16(st_fx->last_codec_mode,MODE2)) { - IF( sub(st_fx->L_frame_fx,L_FRAME) == 0 ) + IF( EQ_16(st_fx->L_frame_fx,L_FRAME)) { retro_interp5_4_fx( st_fx->pst_old_syn_fx ); } - ELSE IF( sub(st_fx->L_frame_fx,L_FRAME16k) == 0 ) + ELSE IF( EQ_16(st_fx->L_frame_fx,L_FRAME16k)) { retro_interp4_5_fx( syn_fx, st_fx->pst_old_syn_fx ); } @@ -1122,12 +1119,12 @@ void acelp_core_dec_fx( i, st_fx->cldfbAna_fx->no_col, st_fx->cldfbAna_fx->no_channels, &scaleFactor ); /* set output mask for upsampling */ - IF( sub(st_fx->bwidth_fx,NB) == 0 ) + IF( EQ_16(st_fx->bwidth_fx,NB)) { /* set NB mask for upsampling */ st_fx->cldfbSyn_fx->bandsToZero = sub(st_fx->cldfbSyn_fx->no_channels,10); } - ELSE if( sub(st_fx->cldfbSyn_fx->bandsToZero,sub(st_fx->cldfbSyn_fx->no_channels,st_fx->cldfbAna_fx->no_channels)) != 0 ) + ELSE if( NE_16(st_fx->cldfbSyn_fx->bandsToZero,sub(st_fx->cldfbSyn_fx->no_channels,st_fx->cldfbAna_fx->no_channels))) { /* in case of BW switching, re-init to default */ st_fx->cldfbSyn_fx->bandsToZero = sub(st_fx->cldfbSyn_fx->no_channels, st_fx->cldfbAna_fx->no_channels); @@ -1140,13 +1137,13 @@ void acelp_core_dec_fx( test(); test(); test(); - IF( ( L_sub(st_fx->core_brate_fx,FRAME_NO_DATA) == 0 || L_sub(st_fx->core_brate_fx,SID_2k40) == 0 ) && ( sub(st_fx->cng_type_fx,FD_CNG) == 0 ) && ( sub(st_fx->hFdCngDec_fx->hFdCngCom->numCoreBands,st_fx->cldfbSyn_fx->no_channels) < 0 ) ) + IF( ( EQ_32(st_fx->core_brate_fx,FRAME_NO_DATA)||EQ_32(st_fx->core_brate_fx,SID_2k40))&&(EQ_16(st_fx->cng_type_fx,FD_CNG))&&(LT_16(st_fx->hFdCngDec_fx->hFdCngCom->numCoreBands,st_fx->cldfbSyn_fx->no_channels))) { generate_comfort_noise_dec_hf( realBuffer, imagBuffer, &scaleFactor.hb_scale, st_fx ); st_fx->cldfbSyn_fx->bandsToZero = 0; move16(); - if( sub(st_fx->hFdCngDec_fx->hFdCngCom->regularStopBand, st_fx->cldfbSyn_fx->no_channels) < 0 ) + if( LT_16(st_fx->hFdCngDec_fx->hFdCngCom->regularStopBand, st_fx->cldfbSyn_fx->no_channels)) { st_fx->cldfbSyn_fx->bandsToZero = sub(st_fx->cldfbSyn_fx->no_channels, st_fx->hFdCngDec_fx->hFdCngCom->regularStopBand); } @@ -1178,8 +1175,8 @@ void acelp_core_dec_fx( test(); test(); test(); - IF( (sub(st_fx->L_frame_fx,L_FRAME) == 0 && sub(st_fx->bwidth_fx,NB) != 0 && sub(output_frame,L_FRAME16k) >= 0 && - ( sub(st_fx->extl_fx,-1) == 0 || sub(st_fx->extl_fx,SWB_CNG) == 0 || (sub(st_fx->extl_fx,WB_BWE) == 0 && st_fx->extl_brate_fx == 0 && sub(coder_type_fx,AUDIO) != 0)) ) ) + IF( (EQ_16(st_fx->L_frame_fx,L_FRAME)&&NE_16(st_fx->bwidth_fx,NB)&&GE_16(output_frame,L_FRAME16k)&& + ( EQ_16(st_fx->extl_fx,-1) || EQ_16(st_fx->extl_fx,SWB_CNG) || (EQ_16(st_fx->extl_fx,WB_BWE) && st_fx->extl_brate_fx == 0 && NE_16(coder_type_fx,AUDIO) )) ) ) { hf_synth_fx( st_fx->core_brate_fx, output_frame, Aq_fx, exc2_fx, syn_fx, synth_out, &st_fx->seed2_fx, st_fx->mem_hp400_fx, st_fx->mem_syn_hf_fx, st_fx->mem_hf_fx, st_fx->Q_exc, @@ -1205,7 +1202,7 @@ void acelp_core_dec_fx( test(); test(); test(); - IF( ( !st_fx->bfi_fx && ( st_fx->prev_bfi_fx )) || ((sub(st_fx->last_vbr_hw_BWE_disable_dec_fx,1) == 0) && (st_fx->vbr_hw_BWE_disable_dec_fx == 0)) || ((sub(st_fx->extl_fx,SWB_TBE)==0 || sub(st_fx->extl_fx,WB_TBE)==0 || sub(st_fx->extl_fx,FB_TBE)==0) && sub(st_fx->last_extl_fx,SWB_TBE)!=0 && sub(st_fx->last_extl_fx,WB_TBE)!=0 && sub(st_fx->last_extl_fx,FB_TBE)!=0) ) + IF( ( !st_fx->bfi_fx && ( st_fx->prev_bfi_fx )) || ((EQ_16(st_fx->last_vbr_hw_BWE_disable_dec_fx,1))&&(st_fx->vbr_hw_BWE_disable_dec_fx==0))||((EQ_16(st_fx->extl_fx,SWB_TBE)||EQ_16(st_fx->extl_fx,WB_TBE)||EQ_16(st_fx->extl_fx,FB_TBE))&&NE_16(st_fx->last_extl_fx,SWB_TBE)&&NE_16(st_fx->last_extl_fx,WB_TBE)&&NE_16(st_fx->last_extl_fx,FB_TBE))) { st_fx->bwe_non_lin_prev_scale_fx = L_deposit_l(0); set16_fx( st_fx->old_bwe_exc_extended_fx, 0, NL_BUFF_OFFSET ); @@ -1219,7 +1216,7 @@ void acelp_core_dec_fx( } test(); - if( L_sub(st_fx->core_brate_fx,FRAME_NO_DATA) == 0 || L_sub(st_fx->core_brate_fx,SID_2k40) == 0 ) + if( EQ_32(st_fx->core_brate_fx,FRAME_NO_DATA)||EQ_32(st_fx->core_brate_fx,SID_2k40)) { st_fx->bwe_non_lin_prev_scale_fx = L_deposit_l(0); } @@ -1230,7 +1227,7 @@ void acelp_core_dec_fx( updt_dec_fx( st_fx, st_fx->L_frame_fx, coder_type_fx, old_exc_fx, pitch_buf_fx, Es_pred_fx, Aq_fx, lsf_new_fx, lsp_new_fx, voice_factors, old_bwe_exc_fx, gain_buf ); - IF( L_sub(st_fx->core_brate_fx,SID_2k40) > 0 ) + IF( GT_32(st_fx->core_brate_fx,SID_2k40)) { /* update CNG parameters in active frames */ cng_params_upd_fx( lsp_new_fx, exc_fx, st_fx->L_frame_fx, &st_fx->ho_circ_ptr_fx, st_fx->ho_ener_circ_fx, &st_fx->ho_circ_size_fx, st_fx->ho_lsp_circ_fx, @@ -1239,7 +1236,7 @@ void acelp_core_dec_fx( /* Set 16k LSP flag for CNG buffer */ st_fx->ho_16k_lsp_fx[st_fx->ho_circ_ptr_fx] = 0; move16(); - if( sub(st_fx->L_frame_fx, L_FRAME) != 0 ) + if( NE_16(st_fx->L_frame_fx, L_FRAME)) { st_fx->ho_16k_lsp_fx[st_fx->ho_circ_ptr_fx] = 1; move16(); diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index 8e95e5a3fe51ad603033d693e18bab28c12893de..8d8784dd8f0bd9fbb9228deda81fa6e1f0d24334 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -7,10 +7,7 @@ #include "cnst_fx.h" /* Common constants */ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ -#include "stl.h" -#include "wmc_auto.h" - - /* required for wmc_tool */ +#include "stl.h" /* required for wmc_tool */ /*---------------------------------------------------------------------* * Local functions @@ -76,7 +73,7 @@ void acelp_core_switch_dec_fx( /* set multiplication factor according to the sampling rate */ delta = 1; - if( sub(output_frame, L_FRAME16k) > 0 ) + if( GT_16(output_frame, L_FRAME16k)) { delta = shr(output_frame,8); } @@ -88,15 +85,15 @@ void acelp_core_switch_dec_fx( test(); test(); test(); - IF( core_switching_flag && sub(st_fx->last_L_frame_fx, st_fx->last_L_frame_ori_fx) == 0 && ( (sub(st_fx->last_core_fx, ACELP_CORE) == 0) || (sub(st_fx->last_core_fx, AMR_WB_CORE) == 0) ) ) + IF( core_switching_flag && EQ_16(st_fx->last_L_frame_fx, st_fx->last_L_frame_ori_fx)&&((EQ_16(st_fx->last_core_fx,ACELP_CORE))||(EQ_16(st_fx->last_core_fx,AMR_WB_CORE)))) { exc = old_exc + L_EXC_MEM_DEC; Copy( st_fx->old_exc_fx, old_exc, L_EXC_MEM_DEC ); /*scaling of exc from previous frame*/ - IF( sub(st_fx->last_L_frame_fx, L_FRAME) == 0 ) + IF( EQ_16(st_fx->last_L_frame_fx, L_FRAME)) { cbrate = L_add(st_fx->core_brate_fx, 0); - if( L_sub(cbrate, ACELP_24k40) > 0 ) + if( GT_32(cbrate, ACELP_24k40)) { cbrate = L_add(ACELP_24k40, 0); } @@ -106,11 +103,11 @@ void acelp_core_switch_dec_fx( } ELSE { - IF( L_sub(st_fx->core_brate_fx, ACELP_8k00) <= 0 ) + IF( LE_32(st_fx->core_brate_fx, ACELP_8k00)) { cbrate = L_add(ACELP_8k00, 0); } - ELSE IF( L_sub(st_fx->core_brate_fx, ACELP_14k80) <= 0 ) + ELSE IF( LE_32(st_fx->core_brate_fx, ACELP_14k80)) { cbrate = L_add(ACELP_14k80, 0); } @@ -139,7 +136,7 @@ void acelp_core_switch_dec_fx( syn_12k8_fx( 2*L_SUBFR, Aq, exc, synth_intFreq, st_fx->mem_syn2_fx, 1, st_fx->Q_exc, st_fx->Q_syn ); - IF(st_fx->pfstat.on && (sub(st_fx->last_bwidth_fx,NB) == 0)) + IF(st_fx->pfstat.on && (EQ_16(st_fx->last_bwidth_fx,NB))) { Word16 tmp_noise, pitch_buf_tmp[2]; tmp_noise = 0; @@ -151,7 +148,7 @@ void acelp_core_switch_dec_fx( nb_post_filt( 2*L_SUBFR, &(st_fx->pfstat), &tmp_noise, 0, synth_intFreq, Aq, pitch_buf_tmp, AUDIO, st_fx->BER_detect, 0 ); } - IF( sub(L_frame_for_cs,L_FRAME)==0 ) + IF( EQ_16(L_frame_for_cs,L_FRAME)) { deemph_fx( synth_intFreq, PREEMPH_FAC, 2*L_SUBFR, &(st_fx->mem_deemph_fx) ); } @@ -164,7 +161,7 @@ void acelp_core_switch_dec_fx( Copy( syn_fx_tmp+M, synth_intFreq, 2*L_SUBFR ); test(); - IF( st_fx->pfstat.on && (sub(st_fx->last_bwidth_fx,NB) != 0) ) + IF( st_fx->pfstat.on && (NE_16(st_fx->last_bwidth_fx,NB))) { Copy( st_fx->pfstat.mem_pf_in+L_SYN_MEM-M, bpf_error_signal, M ); Copy( synth_intFreq, bpf_error_signal + M, L_SUBFR ); @@ -233,7 +230,7 @@ void acelp_core_switch_dec_fx( move16(); test(); test(); - IF( !(( sub(inner_frame_tbl[st_fx->bwidth_fx], L_FRAME16k) == 0 && sub(st_fx->last_L_frame_fx, L_FRAME16k) == 0) || sub(inner_frame_tbl[st_fx->bwidth_fx], L_FRAME8k) == 0) ) + IF( !(( EQ_16(inner_frame_tbl[st_fx->bwidth_fx], L_FRAME16k)&&EQ_16(st_fx->last_L_frame_fx,L_FRAME16k))||EQ_16(inner_frame_tbl[st_fx->bwidth_fx],L_FRAME8k))) { /* Decoding of BWE */ d1m = (Word16)get_next_indice_fx(st_fx, AUDIODELAYBITS); @@ -246,25 +243,25 @@ void acelp_core_switch_dec_fx( test(); test(); test(); - IF( decode_bwe && !(( sub(output_frame, L_FRAME16k) == 0 && sub(st_fx->last_L_frame_fx, L_FRAME16k) == 0) || sub(output_frame, L_FRAME8k) == 0) ) + IF( decode_bwe && !(( EQ_16(output_frame, L_FRAME16k)&&EQ_16(st_fx->last_L_frame_fx,L_FRAME16k))||EQ_16(output_frame,L_FRAME8k))) { set16_fx( tmp_mem2, 0, 2*L_FILT48k ); hp_filter = hp16000_48000_fx; fdelay = 48; move16(); - IF ( L_sub(st_fx->output_Fs_fx, 16000) == 0 ) + IF ( EQ_32(st_fx->output_Fs_fx, 16000)) { - IF( sub(st_fx->last_L_frame_fx, L_FRAME) == 0 ) + IF( EQ_16(st_fx->last_L_frame_fx, L_FRAME)) { hp_filter = hp12800_16000_fx; fdelay = 20; move16(); } } - ELSE IF( L_sub(st_fx->output_Fs_fx, 32000) == 0 ) + ELSE IF( EQ_32(st_fx->output_Fs_fx, 32000)) { - IF( sub(st_fx->last_L_frame_fx, L_FRAME) == 0 ) + IF( EQ_16(st_fx->last_L_frame_fx, L_FRAME)) { hp_filter = hp12800_32000_fx; fdelay = 40; @@ -277,7 +274,7 @@ void acelp_core_switch_dec_fx( move16(); } } - ELSE IF( sub(st_fx->last_L_frame_fx, L_FRAME) == 0 ) + ELSE IF( EQ_16(st_fx->last_L_frame_fx, L_FRAME)) { hp_filter = hp12800_48000_fx; fdelay = 60; @@ -287,13 +284,13 @@ void acelp_core_switch_dec_fx( /* safety check in case of bit errors */ i = MAX_D1M_16k; move16(); - if( sub(st_fx->last_L_frame_fx,L_FRAME) == 0 ) + if( EQ_16(st_fx->last_L_frame_fx,L_FRAME)) { i = MAX_D1M_12k8; move16(); } - IF( sub(d1m,i) >= 0 ) + IF( GE_16(d1m,i)) { d1m = sub(i,1); gain = 0; /* force muting */ move16(); @@ -400,7 +397,7 @@ void acelp_core_switch_dec_bfi_fx( move16(); /* SC-VBR */ - if( sub(st_fx->last_nelp_mode_dec_fx, 1) == 0 ) + if( EQ_16(st_fx->last_nelp_mode_dec_fx, 1)) { st_fx->nelp_mode_dec_fx = 1; move16(); @@ -423,7 +420,7 @@ void acelp_core_switch_dec_bfi_fx( * Excitation decoding *----------------------------------------------------------------*/ - IF( sub(st_fx->nelp_mode_dec_fx, 1) == 0 ) + IF( EQ_16(st_fx->nelp_mode_dec_fx, 1)) { Word16 gain_buf[NB_SUBFR16k]; Scale_sig(exc-L_EXC_MEM, L_EXC_MEM, -st_fx->Q_exc); @@ -487,7 +484,7 @@ void acelp_core_switch_dec_bfi_fx( move16(); /*if in acelp_core_dec_fx deemph_fx is used*/ /*tmp_float = shr(st_fx->mem_deemph_fx, sub(st_fx->Q_syn,1)); if in acelp_core_dec_fx Deemph2 is used*/ - IF(sub(st_fx->L_frame_fx,L_FRAME )==0) + IF(EQ_16(st_fx->L_frame_fx,L_FRAME )) { deemph_fx( syn, PREEMPH_FAC, L_FRAME, &tmp_float[0] ); /*Q0*/ } @@ -574,7 +571,7 @@ static void decod_gen_voic_core_switch_fx( * initializations *----------------------------------------------------------------------*/ - IF( sub(L_frame, L_FRAME) == 0 ) + IF( EQ_16(L_frame, L_FRAME)) { T0_max = PIT_MAX; move16(); @@ -618,7 +615,7 @@ static void decod_gen_voic_core_switch_fx( * Estimate spectrum tilt and voicing *--------------------------------------------------------------*/ - IF( sub(L_frame, L_FRAME) == 0 ) + IF( EQ_16(L_frame, L_FRAME)) { gain_dec_mless_fx( st_fx, core_brate, L_frame, TRANSITION, 0, -1, code, st_fx->old_Es_pred_fx, &gain_pit, &gain_code, &gain_inov, &norm_gain_code ); } @@ -638,7 +635,7 @@ static void decod_gen_voic_core_switch_fx( *----------------------------------------------------------------------*/ /* Rescaling for 12.8k core */ - IF ( sub(L_frame,L_FRAME) == 0 ) + IF ( EQ_16(L_frame,L_FRAME)) { Rescale_exc( NULL, &exc[0], NULL, st_fx->last_exc_dct_in_fx, L_SUBFR, L_SUBFR * HIBND_ACB_L_FAC, gain_code, &(st_fx->Q_exc), st_fx->Q_subfr, NULL, 0, GENERIC ); } diff --git a/lib_dec/amr_wb_dec_fx.c b/lib_dec/amr_wb_dec_fx.c index a6f626aa42b7336e0e8157c9dbcce042ecc273b0..3644bbcfe73f959db15156d4f6602987675df832 100644 --- a/lib_dec/amr_wb_dec_fx.c +++ b/lib_dec/amr_wb_dec_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -8,9 +8,6 @@ #include "rom_com_fx.h" #include "prot_fx.h" #include "stl.h" -#include "wmc_auto.h" - - #include "basop_mpy.h" #include "basop_util.h" /* Function prototypes */ @@ -125,7 +122,7 @@ void amr_wb_dec_fx( st_fx->bpf_off_fx = 0; move16(); - if( sub(st_fx->last_core_fx,HQ_CORE) == 0 ) + if( EQ_16(st_fx->last_core_fx,HQ_CORE)) { st_fx->bpf_off_fx = 1; move16(); @@ -149,7 +146,7 @@ void amr_wb_dec_fx( } /* Updates in case of EVS primary mode -> AMR-WB IO mode switching */ - IF( sub(st_fx->last_core_fx,AMR_WB_CORE) != 0 ) + IF( NE_16(st_fx->last_core_fx,AMR_WB_CORE)) { updt_IO_switch_dec_fx( output_frame, st_fx ); } @@ -192,9 +189,9 @@ void amr_wb_dec_fx( test(); IF (!st_fx->bfi_fx && st_fx->prev_bfi_fx - && (sub(st_fx->last_codec_mode, MODE2) == 0) - && (sub(st_fx->last_core_bfi, TCX_20_CORE) == 0 - || sub(st_fx->last_core_bfi, TCX_10_CORE) == 0)) + && (EQ_16(st_fx->last_codec_mode, MODE2) ) + && (EQ_16(st_fx->last_core_bfi, TCX_20_CORE) + || EQ_16(st_fx->last_core_bfi, TCX_10_CORE) )) { /* v_multc(st_fx->old_out_fx, st_fx->plcInfo.recovery_gain, */ /* st_fx->old_out_fx, st_fx->L_frameTCX); */ @@ -208,7 +205,7 @@ void amr_wb_dec_fx( move16(); test(); test(); - if (st_fx->last_con_tcx && (sub(st_fx->L_frameTCX_past, st_fx->L_frame_fx) != 0) && (st_fx->last_core_fx != 0)) + if (st_fx->last_con_tcx && (NE_16(st_fx->L_frameTCX_past, st_fx->L_frame_fx))&&(st_fx->last_core_fx!=0)) { avoid_lpc_burst_on_recovery = 1; move16(); @@ -221,7 +218,7 @@ void amr_wb_dec_fx( move16(); test(); test(); - IF( sub(st_fx->last_core_fx,AMR_WB_CORE) != 0 && sub(st_fx->last_L_frame_fx,L_FRAME16k ) == 0 && sub(st_fx->last_core_fx,HQ_CORE) != 0) + IF( NE_16(st_fx->last_core_fx,AMR_WB_CORE)&&EQ_16(st_fx->last_L_frame_fx,L_FRAME16k)&&NE_16(st_fx->last_core_fx,HQ_CORE)) { /* in case of switching, do not apply BPF */ st_fx->bpf_off_fx = 1; @@ -263,15 +260,15 @@ void amr_wb_dec_fx( } /* update buffer of old subframe pitch values */ - IF( sub(st_fx->last_L_frame_fx,L_FRAME) != 0 ) + IF( NE_16(st_fx->last_L_frame_fx,L_FRAME)) { move16(); - IF( sub(st_fx->last_L_frame_fx,L_FRAME32k) == 0 ) + IF( EQ_16(st_fx->last_L_frame_fx,L_FRAME32k)) { /* (float)12800/(float)32000; */ tmp16 = 13107; } - ELSE IF( sub(st_fx->last_L_frame_fx,512) == 0 ) + ELSE IF( EQ_16(st_fx->last_L_frame_fx,512)) { /* (float)12800/(float)25600; */ tmp16 = 16384; @@ -295,15 +292,15 @@ void amr_wb_dec_fx( } } - IF( sub(st_fx->bfi_pitch_frame_fx, L_FRAME) != 0 ) + IF( NE_16(st_fx->bfi_pitch_frame_fx, L_FRAME)) { move16(); - IF( sub(st_fx->bfi_pitch_frame_fx,L_FRAME32k) == 0 ) + IF( EQ_16(st_fx->bfi_pitch_frame_fx,L_FRAME32k)) { /* (float)12800/(float)32000; */ tmp16 = 13107; } - ELSE IF( sub(st_fx->bfi_pitch_frame_fx,512) == 0 ) + ELSE IF( EQ_16(st_fx->bfi_pitch_frame_fx,512)) { /* (float)12800/(float)25600; */ tmp16 = 16384; @@ -318,7 +315,7 @@ void amr_wb_dec_fx( move16(); } - IF( sub(st_fx->last_core_fx,AMR_WB_CORE) != 0 ) + IF( NE_16(st_fx->last_core_fx,AMR_WB_CORE)) { /* reset the unvoiced/audio signal improvement memories */ E_LPC_f_isp_a_conversion( st_fx->lsp_old_fx, st_fx->old_Aq_fx, M ); @@ -328,7 +325,7 @@ void amr_wb_dec_fx( } test(); - if( sub(st_fx->last_bwidth_fx,NB)==0 && st_fx->ini_frame_fx!=0 ) + if( EQ_16(st_fx->last_bwidth_fx,NB)&&st_fx->ini_frame_fx!=0) { st_fx->rate_switching_reset=1; move16(); @@ -346,7 +343,7 @@ void amr_wb_dec_fx( *----------------------------------------------------------------*/ test(); - IF ( L_sub(st_fx->core_brate_fx,FRAME_NO_DATA) == 0 || L_sub(st_fx->core_brate_fx,SID_1k75) == 0 ) + IF ( EQ_32(st_fx->core_brate_fx,FRAME_NO_DATA)||EQ_32(st_fx->core_brate_fx,SID_1k75)) { /* decode CNG parameters */ CNG_dec_fx( st_fx, L_FRAME, Aq_fx, st_fx->core_brate_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step, &sid_bw, q_env ); @@ -370,7 +367,7 @@ void amr_wb_dec_fx( delta_mem_scale = 3; move16(); test(); - if( L_sub(st_fx->lp_ener_fx,40) < 0 ) /* very low energy frames, less than 0.3125 */ + if( LT_32(st_fx->lp_ener_fx,40)) /* very low energy frames, less than 0.3125 */ { delta_mem_scale = 0; move16(); @@ -397,7 +394,7 @@ void amr_wb_dec_fx( /* update st_fx->mem_syn1 for ACELP core switching */ Copy_Scale_sig( st_fx->mem_syn3_fx, st_fx->mem_syn1_fx, M, sub(-1,st_fx->Q_syn) ); /*Q-1*/ - IF( sub(output_frame,L_FRAME8k) != 0 ) + IF( NE_16(output_frame,L_FRAME8k)) { Word16 pitch_temp[4]; pitch_temp[2] = shl(L_FRAME, 6); @@ -434,7 +431,7 @@ void amr_wb_dec_fx( *-----------------------------------------------------------------*/ test(); - IF ( L_sub(st_fx->last_core_brate_fx,FRAME_NO_DATA) == 0 || L_sub(st_fx->last_core_brate_fx,SID_1k75) == 0 ) + IF ( EQ_32(st_fx->last_core_brate_fx,FRAME_NO_DATA)||EQ_32(st_fx->last_core_brate_fx,SID_1k75)) { Copy( st_fx->lspCNG_fx, st_fx->lsp_old_fx, M ); E_LPC_isp_isf_conversion( st_fx->lspCNG_fx, st_fx->lsf_old_fx, M ); @@ -475,9 +472,9 @@ void amr_wb_dec_fx( * Update ISP vector for CNG *------------------------------------------------------------*/ - IF( sub(coder_type,INACTIVE) == 0 ) + IF( EQ_16(coder_type,INACTIVE)) { - IF( sub(st_fx->unv_cnt_fx,20) > 0 ) + IF( GT_16(st_fx->unv_cnt_fx,20)) { /*ftmp = st->lp_gainc * st->lp_gainc;*/ L_tmp1 = L_mult0(st_fx->lp_gainc_fx, st_fx->lp_gainc_fx); /* Q3*Q3 -> Q6*/ @@ -511,7 +508,7 @@ void amr_wb_dec_fx( move16(); test(); test(); - if(sub(coder_type,INACTIVE) == 0 && st_fx->flag_cna && sub(st_fx->psf_lp_noise_fx,15<<7) >= 0) + if(EQ_16(coder_type,INACTIVE)&&st_fx->flag_cna&&GE_16(st_fx->psf_lp_noise_fx,15<<7)) { tmp16 = 1; move16(); @@ -536,9 +533,9 @@ void amr_wb_dec_fx( Copy( exc2_fx, st_fx->dct_post_old_exc_fx + (DCT_L_POST-L_FRAME-OFFSET2), L_FRAME ); Copy( st_fx->dct_post_old_exc_fx, exc_buffer_fx, DCT_L_POST-OFFSET2 ); - IF( sub(output_frame,L_FRAME8k) != 0 ) + IF( NE_16(output_frame,L_FRAME8k)) { - IF ( sub(coder_type,INACTIVE) == 0 ) + IF ( EQ_16(coder_type,INACTIVE)) { frame_energy_fx( L_FRAME, pitch_buf_fx, syn_fx, 0, &frame_e_fx, st_fx->Q_syn ); /*st->psf_lp_noise = 0.99f * st->psf_lp_noise + 0.01f * frame_e; */ @@ -548,12 +545,12 @@ void amr_wb_dec_fx( test(); test(); - IF( sub(amr_io_class,UNVOICED_CLAS) != 0 && sub(coder_type,INACTIVE) != 0 && sub(st_fx->psf_lp_noise_fx,15<<8) < 0 ) + IF( NE_16(amr_io_class,UNVOICED_CLAS)&&NE_16(coder_type,INACTIVE)&<_16(st_fx->psf_lp_noise_fx,15<<8)) { tmp_coder_type = AUDIO; move16(); test(); - if (sub(st_fx->last_coder_type_fx,INACTIVE) == 0 || sub(st_fx->last_coder_type_fx,UNVOICED) == 0) + if (EQ_16(st_fx->last_coder_type_fx,INACTIVE)||EQ_16(st_fx->last_coder_type_fx,UNVOICED)) { tmp_coder_type = INACTIVE; move16(); @@ -623,7 +620,7 @@ void amr_wb_dec_fx( { /* long burst frame erasures */ test(); - if( sub(st_fx->nbLostCmpt,5) > 0 && sub(st_fx->clas_dec,VOICED_CLAS) >= 0 ) + if( GT_16(st_fx->nbLostCmpt,5)&&GE_16(st_fx->clas_dec,VOICED_CLAS)) { st_fx->last_good_fx = VOICED_TRANSITION; move16(); @@ -701,14 +698,14 @@ void amr_wb_dec_fx( * NB post-filter *--------------------------------------------------------*/ test(); - IF( sub(output_frame,L_FRAME8k) == 0 || sub(st_fx->last_bwidth_fx,NB) == 0) + IF( EQ_16(output_frame,L_FRAME8k)||EQ_16(st_fx->last_bwidth_fx,NB)) { FOR( i=0; ipfstat.on = 1; move16(); @@ -743,7 +740,7 @@ void amr_wb_dec_fx( *-----------------------------------------------------------------*/ Copy( syn_fx, tmp_buffer_fx + L_SYN_MEM, L_FRAME ); - IF( sub(output_frame,L_FRAME8k) != 0 && sub(st_fx->last_bwidth_fx,NB) != 0) + IF( NE_16(output_frame,L_FRAME8k)&&NE_16(st_fx->last_bwidth_fx,NB)) { st_fx->pfstat.on = 1; move16(); @@ -758,11 +755,11 @@ void amr_wb_dec_fx( flag_cna = 0; move16(); test(); - IF( (sub(st_fx->psf_lp_noise_fx,15<<8) >= 0) || (coder_type == INACTIVE) ) + IF( (GE_16(st_fx->psf_lp_noise_fx,15<<8))||(coder_type==INACTIVE)) { /*VAD only for non inactive frame*/ test(); - IF( sub(st_fx->VAD, 1) == 0 && sub(coder_type,INACTIVE) != 0 ) + IF( EQ_16(st_fx->VAD, 1)&&NE_16(coder_type,INACTIVE)) { st_fx->VAD = 1; move16(); @@ -791,7 +788,7 @@ void amr_wb_dec_fx( move16(); test(); - IF( st_fx->flag_cna && sub(st_fx->psf_lp_noise_fx,15<<8) >= 0 ) + IF( st_fx->flag_cna && GE_16(st_fx->psf_lp_noise_fx,15<<8)) { flag_cna = 1; move16(); @@ -815,7 +812,7 @@ void amr_wb_dec_fx( test(); test(); test(); - IF( sub(st_fx->last_flag_cna,1) == 0 && ( (sub(st_fx->last_core_fx,ACELP_CORE) == 0 && sub(st_fx->last_coder_type_fx,AUDIO) != 0) || sub(st_fx->last_core_fx,AMR_WB_CORE) == 0 ) ) + IF( EQ_16(st_fx->last_flag_cna,1)&&((EQ_16(st_fx->last_core_fx,ACELP_CORE)&&NE_16(st_fx->last_coder_type_fx,AUDIO))||EQ_16(st_fx->last_core_fx,AMR_WB_CORE))) { FOR (i=0; i < L_FRAME/2; i++) { @@ -869,7 +866,7 @@ void amr_wb_dec_fx( st_fx->Q_syn2 = st_fx->Q_syn; move16(); - if( sub(st_fx->cldfbSyn_fx->bandsToZero,sub(st_fx->cldfbSyn_fx->no_channels,st_fx->cldfbAna_fx->no_channels)) != 0 ) + if( NE_16(st_fx->cldfbSyn_fx->bandsToZero,sub(st_fx->cldfbSyn_fx->no_channels,st_fx->cldfbAna_fx->no_channels))) { /* in case of BW switching, re-init to default */ st_fx->cldfbSyn_fx->bandsToZero = sub(st_fx->cldfbSyn_fx->no_channels, st_fx->cldfbAna_fx->no_channels); @@ -912,7 +909,7 @@ void amr_wb_dec_fx( test(); test(); - IF( sub(output_frame,L_FRAME16k) >= 0 && (sub(st_fx->cldfbSyn_fx->bandsToZero, sub( st_fx->cldfbSyn_fx->no_channels, 10 )) != 0 || sub(st_fx->last_flag_filter_NB, 1) != 0 ) ) + IF( GE_16(output_frame,L_FRAME16k)&&(NE_16(st_fx->cldfbSyn_fx->bandsToZero,sub(st_fx->cldfbSyn_fx->no_channels,10))||NE_16(st_fx->last_flag_filter_NB,1))) { hf_synth_amr_wb_fx( st_fx->core_brate_fx, output_frame, Aq_fx, exc2_fx, syn_fx, st_fx->mem_syn_hf_fx, st_fx->delay_syn_hf_fx, &st_fx->prev_r_fx, &st_fx->fmerit_w_sm_fx, &amr_io_class, st_fx->mem_hp_interp_fx, synth_out_fx, @@ -948,11 +945,11 @@ void amr_wb_dec_fx( test(); if (!st_fx->bfi_fx && st_fx->prev_bfi_fx - && L_sub(st_fx->last_total_brate_fx, HQ_48k) >= 0 - && sub(st_fx->last_codec_mode, MODE2) == 0 - && (sub(st_fx->last_core_bfi, TCX_20_CORE) == 0 || sub(st_fx->last_core_bfi, TCX_10_CORE) == 0) + && GE_32(st_fx->last_total_brate_fx, HQ_48k) + && EQ_16(st_fx->last_codec_mode, MODE2) + && (EQ_16(st_fx->last_core_bfi, TCX_20_CORE) || EQ_16(st_fx->last_core_bfi, TCX_10_CORE) ) && st_fx->plcInfo.concealment_method == TCX_NONTONAL - && L_sub(st_fx->plcInfo.nbLostCmpt, 4) < 0 ) + && LT_32(st_fx->plcInfo.nbLostCmpt, 4) ) { waveadj_rec = 1; move16(); @@ -1003,7 +1000,7 @@ void amr_wb_dec_fx( Scale_sig(st_fx->delay_buf_out_fx, delay_comp, sub(st_fx->Q_syn2,st_fx->Q_old_postdec)); st_fx->Q_old_postdec=st_fx->Q_syn2; move16(); - IF( sub(last_core_ori,HQ_CORE) == 0 ) + IF( EQ_16(last_core_ori,HQ_CORE)) { Word16 step, alpha,nz; @@ -1039,16 +1036,16 @@ void amr_wb_dec_fx( st_fx->prev_bfi_fx = st_fx->bfi_fx; st_fx->last_con_tcx = st_fx->con_tcx; - if( L_sub(st_fx->core_brate_fx,SID_1k75) > 0 ) + if( GT_32(st_fx->core_brate_fx,SID_1k75)) { st_fx->last_active_brate_fx = st_fx->total_brate_fx; move32(); } test(); - IF( L_sub(st_fx->core_brate_fx,SID_1k75) > 0 && st_fx->first_CNG_fx ) + IF( GT_32(st_fx->core_brate_fx,SID_1k75)&&st_fx->first_CNG_fx) { - if( sub(st_fx->act_cnt_fx,BUF_DEC_RATE) >= 0 ) + if( GE_16(st_fx->act_cnt_fx,BUF_DEC_RATE)) { st_fx->act_cnt_fx = 0; move16(); @@ -1057,7 +1054,7 @@ void amr_wb_dec_fx( st_fx->act_cnt_fx = add(st_fx->act_cnt_fx,1); test(); - if( sub(st_fx->act_cnt_fx,BUF_DEC_RATE) == 0 && st_fx->ho_hist_size_fx > 0 ) + if( EQ_16(st_fx->act_cnt_fx,BUF_DEC_RATE)&&st_fx->ho_hist_size_fx>0) { st_fx->ho_hist_size_fx = sub(st_fx->ho_hist_size_fx,1); } @@ -1074,7 +1071,7 @@ void amr_wb_dec_fx( *----------------------------------------------------------------*/ /* Delay ACELP synthesis by DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS delay */ - IF ( sub(output_frame,L_FRAME16k) >= 0 ) + IF ( GE_16(output_frame,L_FRAME16k)) { tmps = NS2SA_fx2(st_fx->output_Fs_fx, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS); Scale_sig( st_fx->prev_synth_buffer_fx, tmps, sub(st_fx->Q_syn2, st_fx->Qprev_synth_buffer_fx) ); @@ -1088,7 +1085,7 @@ void amr_wb_dec_fx( if (waveadj_rec) { tmps = 0; - IF( sub(output_frame,L_FRAME16k) >= 0 ) + IF( GE_16(output_frame,L_FRAME16k)) { tmps = NS2SA_fx2(st_fx->output_Fs_fx, DELAY_BWE_TOTAL_NS); } diff --git a/lib_dec/ari_dec.c b/lib_dec/ari_dec.c index 001a7a8ef267f1d67fc60777b096b384a4f5025a..afe3ad2467357aa26c2d640c079931dfbf590be3 100644 --- a/lib_dec/ari_dec.c +++ b/lib_dec/ari_dec.c @@ -1,13 +1,10 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include #include "assert.h" #include "stl.h" -#include "wmc_auto.h" - - #include "basop_mpy.h" #include "cnst_fx.h" #include "rom_com_fx.h" @@ -85,32 +82,32 @@ static Word16 ari_lookup_s17(Word32 cum, Word32 range, UWord16 const *cum_freq) range_h = extract_l(L_shr(range,15)); tmp = L_multi31x16_X2(range_h, range_l,p[8]); - if (L_sub(tmp,cum) > 0) + if (GT_32(tmp,cum)) { p = p + 8; } tmp = L_multi31x16_X2(range_h, range_l,p[4]); - if (L_sub(tmp,cum) > 0) + if (GT_32(tmp,cum)) { p = p + 4; } tmp = L_multi31x16_X2(range_h, range_l,p[2]); - if (L_sub(tmp,cum) > 0) + if (GT_32(tmp,cum)) { p = p + 2; } tmp = L_multi31x16_X2(range_h, range_l,p[1]); - IF (L_sub(tmp,cum) > 0) + IF (GT_32(tmp,cum)) { p = p + 1; tmp = L_multi31x16_X2(range_h, range_l,p[1]); test(); - if ( ((Word32)(&cum_freq[15] - p) == 0) && (L_sub(tmp,cum) > 0) ) + if ( ((Word32)(&cum_freq[15] - p) == 0) && (GT_32(tmp,cum))) { p = p + 1; } @@ -201,7 +198,7 @@ static Word16 ari_lookup_s27(Word32 cum, Word32 range, UWord16 const *cum_freq) move16(); } - IF (sub(sub(ih, il), 1) > 0) /* if the interval has more than one symbol */ + IF (GT_16(sub(ih, il), 1)) /* if the interval has more than one symbol */ { /* here, only ih == il + 2 is possible, which means two symbols in the interval */ im = add(il, 1); /* (il + ih) >> 1 */ @@ -255,16 +252,19 @@ static Word16 ari_decode_14bits_ext( Word32 value; Word16 i; - low = L_add(0,s->low); - high = L_add(0,s->high); - value = L_add(0,s->vobf); + low = s->low; + move32(); + high = s->high; + move32(); + value = s->vobf; + move32(); range = L_sub(high, low); cum = L_add(L_shl(L_sub(value, low), stat_bitsnew), sub(shl(1,stat_bitsnew),1)); if (cum < 0) { - cum = L_add(0,0x7fffffff); + cum = 0x7fffffff; } symbol = lookup_fn(cum, range, cum_freq); @@ -279,7 +279,7 @@ static Word16 ari_decode_14bits_ext( L_msb_high = L_shr(L_sub(high,1),14); L_msb_low = L_shr(low,14); L_msb_diff = L_sub(L_msb_high, L_msb_low); - IF (L_sub(L_msb_diff,2) >= 0) + IF (GE_32(L_msb_diff,2)) { BREAK; } @@ -352,7 +352,7 @@ static Word16 ari_lookup_pow(TastatDec *s, Word16 base) move16(); /* search for the interval where "cum" fits */ - IF (L_sub(L_multi31x16_X2(range_h, range_l, lowlim), cum) > 0) /* below pow-1 */ + IF (GT_32(L_multi31x16_X2(range_h, range_l, lowlim), cum)) /* below pow-1 */ { pows[0] = base; move16(); @@ -367,7 +367,7 @@ static Word16 ari_lookup_pow(TastatDec *s, Word16 base) move16(); testval = mult_r(pows[k], base); - IF (L_sub(L_multi31x16_X2(range_h, range_l, shr(testval, 1)), cum) <= 0) /* found! big range is [lowlim,testval], (now narrow it down) */ + IF (LE_32(L_multi31x16_X2(range_h, range_l, shr(testval, 1)), cum)) /* found! big range is [lowlim,testval], (now narrow it down) */ { lowlim = testval; move16(); @@ -383,7 +383,7 @@ static Word16 ari_lookup_pow(TastatDec *s, Word16 base) { testval = mult_r(highlim, pows[k+1]); - IF (L_sub(L_multi31x16_X2(range_h, range_l, shr(testval, 1)), cum) <= 0) + IF (LE_32(L_multi31x16_X2(range_h, range_l, shr(testval, 1)), cum)) { lowlim = testval; move16(); @@ -419,7 +419,7 @@ static Word16 ari_lookup_sign(TastatDec *s, Word16 base) cum = L_sub(s->vobf, s->low); range = L_shr(range, 1); - IF (L_sub(range, cum) > 0) + IF (GT_32(range, cum)) { symbol = 1; move16(); @@ -463,7 +463,7 @@ static Word16 ari_decode_14bits_notbl( L_msb_high = L_shr(L_sub(high,1),14); L_msb_low = L_shr(low,14); L_msb_diff = L_sub(L_msb_high, L_msb_low); - IF (L_sub(L_msb_diff,2) >= 0) + IF (GE_32(L_msb_diff,2)) { BREAK; } @@ -481,7 +481,7 @@ static Word16 ari_decode_14bits_notbl( test(); test(); test(); - IF ((lookup_fn != ari_lookup_sign) && !(sub(bp, bits) != 0 || ! ((L_sub(s->low, low) == 0) && (L_sub(s->high, L_sub(high,1)) == 0) && (L_sub(s->vobf, value) == 0)))) + IF ((lookup_fn != ari_lookup_sign) && !(NE_16(bp, bits)||!((EQ_32(s->low,low))&&(EQ_32(s->high,L_sub(high,1)))&&(EQ_32(s->vobf,value))))) { /* This should not happen except of bit errors. */ s->high = 0; diff --git a/lib_dec/ari_hm_dec.c b/lib_dec/ari_hm_dec.c index 8fc9b8577db7bcf4ba0eb4a6bf7a39906fcde1f0..08a3b6cb185c074c6f79bc743cf022ebeaf5b4b9 100644 --- a/lib_dec/ari_hm_dec.c +++ b/lib_dec/ari_hm_dec.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ @@ -8,8 +8,6 @@ #include #include #include "stl.h" -#include "wmc_auto.h" - #include "cnst_fx.h" #include "basop_util.h" #include "rom_com_fx.h" @@ -22,7 +20,7 @@ DecodeIndex( Word16 *PeriodicityIndex) { test(); - IF ( (st->tcx_hm_LtpPitchLag > 0) && sub(st->tcxltp_gain, kLtpHmGainThr) > 0) + IF ( (st->tcx_hm_LtpPitchLag > 0) && GT_16(st->tcxltp_gain, kLtpHmGainThr)) { Word16 LtpPitchIndex = sub(mult_r(st->tcx_hm_LtpPitchLag, 1 << (15-kLtpHmFractionalResolution)), 2); @@ -55,7 +53,7 @@ static Word16 tcx_hm_dequantize_gain( /* safety check in case of bit errors */ test(); - IF(!(0 <= gain_idx && sub(gain_idx,(1 << kTcxHmNumGainBits)) < 0)) + IF(!(0 <= gain_idx && LT_16(gain_idx,(1 << kTcxHmNumGainBits)))) { *gain = 0; return 1; @@ -92,7 +90,7 @@ void tcx_hm_decode( L_frame_m_256 = sub(L_frame,256); test(); - IF( !(sub(coder_type,VOICED) == 0 || sub(coder_type,GENERIC) == 0) ) + IF( !(EQ_16(coder_type,VOICED)||EQ_16(coder_type,GENERIC))) { /* A bit error was encountered */ *hm_bits = -1; @@ -104,7 +102,7 @@ void tcx_hm_decode( NumTargetBits = add(NumTargetBits,targetBits); - if ( sub(coder_type,VOICED) == 0 ) + if ( EQ_16(coder_type,VOICED)) { NumTargetBits = add(NumTargetBits,kTcxHmNumGainBits); } @@ -117,7 +115,7 @@ void tcx_hm_decode( prm_hm[1], (L_frame_m_256 >= 0), LtpPitchLag, - (( sub(NumTargetBits,kSmallerLagsTargetBitsThreshold) <= 0 ) || ( L_frame_m_256 < 0 )), + (( LE_16(NumTargetBits,kSmallerLagsTargetBitsThreshold) ) || ( L_frame_m_256 < 0 )), &fract_res, &lag ); @@ -134,7 +132,7 @@ void tcx_hm_decode( } /* Dequantize gain */ - IF( tcx_hm_dequantize_gain(sub(coder_type,VOICED) == 0,prm_hm[2],&gain) ) + IF( tcx_hm_dequantize_gain((Word16)EQ_16(coder_type,VOICED),prm_hm[2],&gain)) { /* A bit error was encountered */ *hm_bits = -1; diff --git a/lib_dec/arith_coder_dec.c b/lib_dec/arith_coder_dec.c index 5606019b2bc6cb24240f10cabc8da41afb7b0ae8..bded109d23d4cfd24fead3388aa15d3e105e5382 100644 --- a/lib_dec/arith_coder_dec.c +++ b/lib_dec/arith_coder_dec.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -11,9 +11,6 @@ #include "cnst_fx.h" #include "rom_com_fx.h" #include "stl.h" -#include "wmc_auto.h" - - #include "prot_fx.h" /* Returns: number of bits consumed */ @@ -70,7 +67,7 @@ static Word16 tcx_arith_decode( IF (ari_decode_overflow(&as)) { - if( sub(bp, target_bits) < 0 ) /* safety check in case of bit errors */ + if( LT_16(bp, target_bits)) /* safety check in case of bit errors */ { bp = -1; move16(); @@ -118,7 +115,7 @@ void tcx_arith_decode_envelope( test(); test(); - IF( sub(L_spec,N_MAX_ARI) > 0 || sub(target_bits, (ACELP_13k20/50)) > 0 || (target_bits <= 0) ) + IF( GT_16(L_spec,N_MAX_ARI)||GT_16(target_bits,(ACELP_13k20/50))||(target_bits<=0)) { /* this could happen in case of bit errors */ st->BER_detect = 1; diff --git a/lib_dec/avq_dec_fx.c b/lib_dec/avq_dec_fx.c index 2850a16721c3ffd070e189a22c160fa463143cac..ebbe673b51dc3577a66a963e6b85f04056846270 100644 --- a/lib_dec/avq_dec_fx.c +++ b/lib_dec/avq_dec_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -7,8 +7,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*-----------------------------------------------------------------* * Function AVQ_Demuxdec_Bstr * @@ -41,7 +39,7 @@ void AVQ_demuxdec_fx( nq[i] = 0; move16();/* initialization and also forced if the budget is exceeded */ - IF( sub(bits, 8) > 0 ) + IF( GT_16(bits, 8)) { /* read the unary code including the stop bit for nq[i] */ nq[i] = -1; @@ -68,7 +66,7 @@ void AVQ_demuxdec_fx( } /* check for potential bit errors */ - IF( sub(nq[i], NB_SPHERE) > 0 ) + IF( GT_16(nq[i], NB_SPHERE)) { st_fx->BER_detect = 1; move16(); @@ -92,7 +90,7 @@ void AVQ_demuxdec_fx( /* read codebook indices (rank I and event. Voronoi index kv) */ IF( nq[i] != 0 ) /* for Q0 nothing to read */ { - IF( sub(nq[i], 5) < 0 ) /* Q2, Q3, Q4 */ + IF( LT_16(nq[i], 5)) /* Q2, Q3, Q4 */ { tmp16 = shl(nq[i], 2); order_v = 0; @@ -189,7 +187,7 @@ void AVQ_dec_lpc( n = nq; move16(); - IF (sub(nq, 4) > 0) + IF (GT_16(nq, 4)) { nk = shr(sub(nq, 3), 1); n = sub(nq, shl(nk, 1)); diff --git a/lib_dec/basop_util_jbm.c b/lib_dec/basop_util_jbm.c index be7dc5cce3712f2919fe28808f5df77204075f77..fa2d9f380eb0286711ea0464d0f9d08a3c395bc0 100644 --- a/lib_dec/basop_util_jbm.c +++ b/lib_dec/basop_util_jbm.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ /*! @file basop_util_jbm.c basop utility functions for JBM. */ @@ -8,8 +8,6 @@ #include "basop_util_jbm.h" #include "options.h" #include "stl.h" -#include "wmc_auto.h" - /* Adds two uint32_t values with overflow like plain C. */ Word32 rtpTs_add( Word32 ts1, Word32 ts2 ) @@ -29,10 +27,10 @@ Word32 rtpTs_sub( Word32 ts1, Word32 ts2 ) { Word32 ret; - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF Carry = 1; ret = L_sub_c(ts1, ts2); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON Carry = 0; Overflow = 0; diff --git a/lib_dec/basop_util_jbm.h b/lib_dec/basop_util_jbm.h index 22be8ed77e21c73ecff105197f7a4721a313be85..a1989d19329f9004dc33f013030bffbc00f6aa5c 100644 --- a/lib_dec/basop_util_jbm.h +++ b/lib_dec/basop_util_jbm.h @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ /*! @file basop_util_jbm.h basop utility functions for JBM. */ diff --git a/lib_dec/bass_psfilter_fx.c b/lib_dec/bass_psfilter_fx.c index 27aa69381f9c3fe43197b891b9cb76b639adc296..03850a9e618e3b59a10b2a537d16b996ab64b401 100644 --- a/lib_dec/bass_psfilter_fx.c +++ b/lib_dec/bass_psfilter_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -11,8 +11,6 @@ #include "rom_dec_fx.h" /* Static table prototypes */ #include "stl.h" -#include "wmc_auto.h" - #include "basop_mpy.h" #include "basop_util.h" @@ -156,7 +154,7 @@ void bass_psfilter_fx( tmp = round_fx(Ltmp); /*Q4*/ /*tmp2 = div_s(1,nb_subfr); //Q15 */ tmp = mult_r(tmp,8192); /*divide per 4 (when L_frame == L_FRAME) -> Q4*/ - if(sub(nb_subfr,5)==0) + if(EQ_16(nb_subfr,5)) { tmp = mult_r(tmp, 26214); /* multiply by 0.8 for case where L_frame == L_FRAME16k*/ } @@ -168,7 +166,7 @@ void bass_psfilter_fx( dist_pit_diff = abs_s(sub(idx_pit_max,idx_pit_min)); diff_pit = sub(loc_pit_max,loc_pit_min); /*Q4 */ - if( sub(L_frame,L_FRAME16k) == 0) + if( EQ_16(L_frame,L_FRAME16k)) { diff_pit = mult_r(diff_pit,26214); /*Q4 */ } @@ -176,7 +174,7 @@ void bass_psfilter_fx( test(); test(); test(); - if( coder_type != INACTIVE && sub(diff_pit,2<<4) >= 0 && sub(diff_pit,10<<4) < 0 && sub(dist_pit_diff,3)>= 0) + if( coder_type != INACTIVE && GE_16(diff_pit,2<<4)&<_16(diff_pit,10<<4)&&GE_16(dist_pit_diff,3)) { vibrato = 1; move16(); @@ -200,7 +198,7 @@ void bass_psfilter_fx( alp_tmp = s_max( 3277, alp_tmp ); - IF( sub(alp_tmp,*psf_att) > 0 ) + IF( GT_16(alp_tmp,*psf_att)) { /**psf_att = add(mult_r(1638,alp_tmp),mult_r(31130,*psf_att)); //Q15 */ *psf_att = round_fx(L_mac(L_mult(1638,alp_tmp),31130,*psf_att)); /*Q15 */ @@ -235,7 +233,7 @@ void bass_psfilter_fx( tmp = add(pitch_buf_fx[i],32); T_sf[i] = shr(tmp,6); - IF(sub(L_frame,L_FRAME16k) == 0) + IF(EQ_16(L_frame,L_FRAME16k)) { T_sf[i] = s_min(T_sf[i], NBPSF_PIT_MAX); move16(); @@ -272,11 +270,11 @@ void bass_psfilter_fx( IF (T != 0) { test(); - IF( sub(T,PIT_MIN)>=0 && Opt_AMR_WB ) + IF( GE_16(T,PIT_MIN)&&Opt_AMR_WB) { T = Pit_track_fx(syn_fx, T); - if(sub(T,T_sf[subfr_pos]) != 0) + if(NE_16(T,T_sf[subfr_pos])) { Track_on = 1; move16(); @@ -324,7 +322,7 @@ void bass_psfilter_fx( tmp = round_fx(L_shl(Ltmp, exp)); exp2 = norm_l(Lener); tmp2 = round_fx(L_shl(Lener, exp2)); - if (sub(tmp, tmp2) > 0) + if (GT_16(tmp, tmp2)) { exp = sub(exp, 1); } @@ -362,7 +360,7 @@ void bass_psfilter_fx( Lener = L_add(Lener, Pow2(tmp2, exp2)); exp2 = norm_l(Lener); tmp2 = round_fx(L_shl(Lener, exp2)); - if (sub(tmp, tmp2) > 0) + if (GT_16(tmp, tmp2)) { exp = sub(exp, 1); } @@ -379,12 +377,12 @@ void bass_psfilter_fx( alpha = mult_r(alpha,*psf_att); test(); test(); - IF (sub(alpha,9830) > 0 && Track_on) + IF (GT_16(alpha,9830)&&Track_on) { alpha = 9830; move16(); } - ELSE if (sub(alpha,13107) > 0 && vibrato ) + ELSE if (GT_16(alpha,13107)&&vibrato) { alpha = 13107; move16(); @@ -433,7 +431,7 @@ void bass_psfilter_fx( exp2 = -1-2; move16(); /* 'Lener' is divided by 2 */ - IF (L_sub(Lener, 2147483647L) == 0) + IF (EQ_32(Lener, 2147483647L)) { Lener = L_deposit_h(-32768); sigPtr = err + L_SUBFR/2; @@ -475,7 +473,7 @@ void bass_psfilter_fx( Track_on = 0; move16(); - if( sub(coder_type,AUDIO) == 0 ) /* GSC mode without temporal component */ + if( EQ_16(coder_type,AUDIO)) /* GSC mode without temporal component */ { Track_on = 1; move16(); @@ -514,7 +512,7 @@ void bass_psfilter_fx( tmp = round_fx(L_shl(Ltmp, exp)); exp2 = norm_l(Lener); tmp2 = round_fx(L_shl(Lener, exp2)); - if (sub(tmp, tmp2) > 0) + if (GT_16(tmp, tmp2)) { exp = sub(exp, 1); } @@ -552,7 +550,7 @@ void bass_psfilter_fx( Lener = L_add(Lener, Pow2(tmp2, exp2)); exp2 = norm_l(Lener); tmp2 = round_fx(L_shl(Lener, exp2)); - if (sub(tmp, tmp2) > 0) + if (GT_16(tmp, tmp2)) { exp = sub(exp, 1); } @@ -588,7 +586,7 @@ void bass_psfilter_fx( exp2 = -1-2; move16(); /* 'Lener' is divided by 2 */ - IF (L_sub(Lener, 2147483647L) == 0) + IF (EQ_32(Lener, 2147483647L)) { Lener = L_deposit_h(-32768); sigPtr = err + L_SUBFR/2; @@ -692,7 +690,7 @@ static Word16 Pit_track_fx( /* o : Pitch */ because it is a signed sum. */ FOR (j = 0; j < 14; j++) { - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF Lener0 = L_mult0(*v1, *v1); Ltmp0 = L_mult0(*v2, *v2); Lcorr0 = L_mult0(*v1++, *v2++); @@ -702,13 +700,13 @@ static Word16 Pit_track_fx( /* o : Pitch */ Ltmp0 = L_mac0(Ltmp0, *v2, *v2); Lcorr0 = L_mac0(Lcorr0, *v1++, *v2++); } - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON test(); test(); test(); - IF (L_sub(Lener0, 2147483647L) == 0 || - L_sub(Ltmp0, 2147483647L) == 0 || - L_sub(Lcorr0, 2147483647L) == 0 || L_sub(Lcorr0, -2147483647-1L) == 0) + IF (EQ_32(Lener0, 2147483647L)|| + EQ_32(Ltmp0, 2147483647L) || + EQ_32(Lcorr0, 2147483647L) || EQ_32(Lcorr0, -2147483647-1L)) { v1 -= i; move16(); @@ -761,7 +759,7 @@ static Word16 Pit_track_fx( /* o : Pitch */ Ltmp = L_shl(Ltmp, exp1); /* cn = normalized correlation of pitch/2 */ - if (L_sub(Ltmp, 2040109466L) > 0) /* 0.95f in Q31 */ + if (GT_32(Ltmp, 2040109466L)) /* 0.95f in Q31 */ { T = T2; move16(); diff --git a/lib_dec/cng_dec_fx.c b/lib_dec/cng_dec_fx.c index e2aa2f81b242878d0f706e042529aa3807680122..cb13e88a9acc58ddfc3879a86833530b13a99ca7 100644 --- a/lib_dec/cng_dec_fx.c +++ b/lib_dec/cng_dec_fx.c @@ -1,12 +1,10 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "stl.h" -#include "wmc_auto.h" - #include "prot_fx.h" #include "cnst_fx.h" #include "rom_com_fx.h" @@ -81,7 +79,7 @@ void CNG_dec_fx( * Decode CNG spectral envelope (only in SID frame) *-----------------------------------------------------------------*/ test(); - IF ( L_sub(core_brate,SID_1k75) == 0 || L_sub(core_brate, SID_2k40) == 0 ) + IF ( EQ_32(core_brate,SID_1k75)||EQ_32(core_brate,SID_2k40)) { /* de-quantize the LSF vector */ IF ( st_fx->Opt_AMR_WB_fx != 0 ) @@ -142,11 +140,11 @@ void CNG_dec_fx( *allow_cn_step = 0; move16(); test(); - IF( L_sub(core_brate,SID_1k75) == 0 || L_sub(core_brate, SID_2k40) == 0 ) + IF( EQ_32(core_brate,SID_1k75)||EQ_32(core_brate,SID_2k40)) { istep = ISTEP_AMR_WB_SID_FX; move16(); - if( L_sub(core_brate,SID_2k40) == 0 ) + if( EQ_32(core_brate,SID_2k40)) { istep = ISTEP_SID_FX; move16(); @@ -164,31 +162,31 @@ void CNG_dec_fx( /* decode the energy index */ L_enr_index = get_next_indice_fx( st_fx, num_bits ); - IF( L_sub(st_fx->last_core_brate_fx, SID_2k40) <= 0 || sub(st_fx->prev_bfi_fx, 1) == 0 ) - { - tmp1 = add(st_fx->old_enr_index_fx, 20); - } - ELSE - { - tmp1 = add(st_fx->old_enr_index_fx, 40); - } - IF(sub(L_enr_index, tmp1) > 0 && st_fx->old_enr_index_fx >= 0 ) /* Likely bit error and not startup */ - { - L_enr_index = tmp1; move16(); - L_enr_index = s_min(L_enr_index, 127); - if (st_fx->Opt_AMR_WB_fx != 0) - { - L_enr_index = s_min(L_enr_index, 63); - } - } + IF( LE_32(st_fx->last_core_brate_fx, SID_2k40) || EQ_16(st_fx->prev_bfi_fx, 1) ) + { + tmp1 = add(st_fx->old_enr_index_fx, 20); + } + ELSE + { + tmp1 = add(st_fx->old_enr_index_fx, 40); + } + IF( GT_16(L_enr_index, tmp1) && st_fx->old_enr_index_fx >= 0 ) /* Likely bit error and not startup */ + { + L_enr_index = tmp1; move16(); + L_enr_index = s_min(L_enr_index, 127); + if (st_fx->Opt_AMR_WB_fx != 0) + { + L_enr_index = s_min(L_enr_index, 63); + } + } test(); test(); test(); - if (L_sub(st_fx->last_core_brate_fx,SID_1k75) > 0 && + if (GT_32(st_fx->last_core_brate_fx,SID_1k75)&& st_fx->first_CNG_fx != 0 && st_fx->old_enr_index_fx >= 0 && - sub(L_enr_index, add(st_fx->old_enr_index_fx,1)) > 0) + GT_16(L_enr_index, add(st_fx->old_enr_index_fx,1))) { *allow_cn_step = 1; move16(); @@ -212,7 +210,7 @@ void CNG_dec_fx( /* find the new energy value */ st_fx->Enew_fx = Pow2(ener_int, ener_fra); - IF( L_sub(core_brate,SID_2k40) == 0 ) + IF( EQ_32(core_brate,SID_2k40)) { burst_ho_cnt = get_next_indice_fx( st_fx, 3 ); /* 3bit */ @@ -232,7 +230,7 @@ void CNG_dec_fx( /* Reset CNG history if CNG frame length is changed */ test(); test(); - if ( sub(st_fx->bwidth_fx,WB) == 0 && st_fx->first_CNG_fx != 0 && sub(st_fx->L_frame_fx,st_fx->last_CNG_L_frame_fx) != 0 ) + if ( EQ_16(st_fx->bwidth_fx,WB)&&st_fx->first_CNG_fx!=0&&NE_16(st_fx->L_frame_fx,st_fx->last_CNG_L_frame_fx)) { st_fx->ho_hist_size_fx = 0; move16(); @@ -249,14 +247,14 @@ void CNG_dec_fx( IF( st_fx->last_core_brate_fx <= SID_2k40 ) { /* Reset hangover counter if not first SID period */ - if( L_sub(st_fx->core_brate_fx,FRAME_NO_DATA) > 0 ) + if( GT_32(st_fx->core_brate_fx,FRAME_NO_DATA)) { st_fx->num_ho_fx = 0; move16(); } /* Update LSPs if last SID energy not outlier or insufficient number of hangover frames */ test(); - IF( sub(st_fx->num_ho_fx,3) < 0 || L_sub(Mult_32_16(st_fx->Enew_fx,21845 /*1/1.5f, Q15*/), st_fx->lp_ener_fx) < 0 ) + IF( LT_16(st_fx->num_ho_fx,3)||LT_32(Mult_32_16(st_fx->Enew_fx,21845/*1/1.5f, Q15*/),st_fx->lp_ener_fx)) { FOR( i=0; iOpt_AMR_WB_fx || sub(st_fx->bwidth_fx,WB) == 0 ) - && ( !st_fx->first_CNG_fx || sub(st_fx->act_cnt2_fx,MIN_ACT_CNG_UPD) >= 0 ) ) + IF( ( st_fx->Opt_AMR_WB_fx || EQ_16(st_fx->bwidth_fx,WB)) + && ( !st_fx->first_CNG_fx || GE_16(st_fx->act_cnt2_fx,MIN_ACT_CNG_UPD) ) ) { - IF( L_sub(st_fx->last_active_brate_fx,ACELP_16k40) > 0) + IF( GT_32(st_fx->last_active_brate_fx,ACELP_16k40)) { st_fx->CNG_mode_fx = -1; move16(); } - ELSE IF( L_sub(st_fx->last_active_brate_fx,ACELP_13k20) > 0 ) + ELSE IF( GT_32(st_fx->last_active_brate_fx,ACELP_13k20)) { st_fx->CNG_mode_fx = 4; move16(); } - ELSE IF( L_sub(st_fx->last_active_brate_fx,ACELP_9k60) > 0 ) + ELSE IF( GT_32(st_fx->last_active_brate_fx,ACELP_9k60)) { st_fx->CNG_mode_fx = 3; move16(); } - ELSE IF( L_sub(st_fx->last_active_brate_fx,ACELP_8k00) > 0 ) + ELSE IF( GT_32(st_fx->last_active_brate_fx,ACELP_8k00)) { st_fx->CNG_mode_fx = 2; move16(); } - ELSE IF( L_sub(st_fx->last_active_brate_fx,ACELP_7k20) > 0 ) + ELSE IF( GT_32(st_fx->last_active_brate_fx,ACELP_7k20)) { st_fx->CNG_mode_fx = 1; move16(); @@ -321,7 +319,7 @@ void CNG_dec_fx( FOR( ll = burst_ho_cnt; ll > 0; ll-- ) { st_fx->ho_hist_ptr_fx = add(st_fx->ho_hist_ptr_fx,1); - if( sub(st_fx->ho_hist_ptr_fx, HO_HIST_SIZE) == 0 ) + if( EQ_16(st_fx->ho_hist_ptr_fx, HO_HIST_SIZE)) { st_fx->ho_hist_ptr_fx = 0; move16(); @@ -331,7 +329,7 @@ void CNG_dec_fx( test(); test(); test(); - IF( ( sub(L_frame,L_FRAME16k) == 0 && st_fx->ho_16k_lsp_fx[s_ptr] == 0 ) || ( sub(L_frame,L_FRAME) == 0 && sub(st_fx->ho_16k_lsp_fx[s_ptr],1) == 0 ) ) + IF( ( EQ_16(L_frame,L_FRAME16k)&&st_fx->ho_16k_lsp_fx[s_ptr]==0)||(EQ_16(L_frame,L_FRAME)&&EQ_16(st_fx->ho_16k_lsp_fx[s_ptr],1))) { /* Conversion from 16k LPSs to 12k8 */ lsp_convert_poly_fx( &(st_fx->ho_lsp_circ_fx[s_ptr*M]), L_frame, 0 ); @@ -344,14 +342,14 @@ void CNG_dec_fx( st_fx->ho_hist_size_fx = add(st_fx->ho_hist_size_fx,1); - if (sub(st_fx->ho_hist_size_fx, HO_HIST_SIZE) > 0) + if (GT_16(st_fx->ho_hist_size_fx, HO_HIST_SIZE)) { st_fx->ho_hist_size_fx = HO_HIST_SIZE; move16(); } s_ptr = add(s_ptr,1); - if( sub(s_ptr, st_fx->ho_circ_size_fx) == 0 ) + if( EQ_16(s_ptr, st_fx->ho_circ_size_fx)) { s_ptr = 0; move16(); @@ -400,8 +398,8 @@ void CNG_dec_fx( } test(); - IF ( L_sub(Mult_32_16(st_fx->ho_ener_hist_fx[ptr],ONE_OVER_BUF_H_NRG_FX),st_fx->ho_ener_hist_fx[st_fx->ho_hist_ptr_fx]) < 0 && - L_sub(st_fx->ho_ener_hist_fx[ptr],Mult_32_16(st_fx->ho_ener_hist_fx[st_fx->ho_hist_ptr_fx], BUF_L_NRG_FX)) > 0 ) + IF ( LT_32(Mult_32_16(st_fx->ho_ener_hist_fx[ptr],ONE_OVER_BUF_H_NRG_FX),st_fx->ho_ener_hist_fx[st_fx->ho_hist_ptr_fx])&& + GT_32(st_fx->ho_ener_hist_fx[ptr],Mult_32_16(st_fx->ho_ener_hist_fx[st_fx->ho_hist_ptr_fx], BUF_L_NRG_FX))) { /*enr += W_DTX_HO[k] * st_fx->ho_ener_hist[ptr];*/ L_tmp1 = Mult_32_16(st_fx->ho_ener_hist_fx[ptr],W_DTX_HO_FX[k]) ; /* Q6+15-15->Q6 */ @@ -433,7 +431,7 @@ void CNG_dec_fx( FOR( i=0; iL_frame_fx,L_FRAME) == 0 ) + IF ( EQ_16(st_fx->L_frame_fx,L_FRAME)) { lsp2lsf_fx( &tmp[i*M], lsf_tmp, M, INT_FS_FX ); ftmp_fx = 964; @@ -460,7 +458,7 @@ void CNG_dec_fx( C[i] = Mpy_32_16_1(L_tmp,1928); /*QX6.5536*/ move32(); - IF ( L_sub(C[i],max[0]) > 0 ) + IF ( GT_32(C[i],max[0])) { max[1] = max[0]; move32(); @@ -471,7 +469,7 @@ void CNG_dec_fx( max_idx[0] = i; move16(); } - ELSE IF ( L_sub(C[i],max[1]) > 0 ) + ELSE IF ( GT_32(C[i],max[1])) { max[1] = C[i]; move32(); @@ -480,11 +478,11 @@ void CNG_dec_fx( } } - IF ( sub(m,1) == 0 ) + IF ( EQ_16(m,1)) { Copy(tmp, lsp_tmp, M); } - ELSE IF ( sub(m,4) < 0 ) + ELSE IF ( LT_16(m,4)) { FOR ( i=0; i 0 ) + if ( GT_16(dev,max_dev)) { max_dev = dev; move16(); @@ -531,7 +529,7 @@ void CNG_dec_fx( } test(); - IF ( sub(dist,13107) > 0 || sub(max_dev,3277) > 0 ) + IF ( GT_16(dist,13107)||GT_16(max_dev,3277)) { FOR( i=0; ilp_ener_fx; */ - IF(sub(m1,1) == 0) + IF(EQ_16(m1,1)) { L_tmp = L_sub(L_tmp,L_add(st_fx->lp_ener_fx,st_fx->lp_ener_fx)); } @@ -583,15 +581,15 @@ void CNG_dec_fx( } test(); - IF( L_sub(st_fx->core_brate_fx, SID_1k75) == 0 || L_sub(st_fx->core_brate_fx, SID_2k40) == 0 ) + IF( EQ_32(st_fx->core_brate_fx, SID_1k75)||EQ_32(st_fx->core_brate_fx,SID_2k40)) { /* Update hangover memory during CNG */ test(); - IF ( *allow_cn_step == 0 && L_sub(st_fx->Enew_fx,L_add(st_fx->lp_ener_fx,L_shr(st_fx->lp_ener_fx,1))) < 0) + IF ( *allow_cn_step == 0 && LT_32(st_fx->Enew_fx,L_add(st_fx->lp_ener_fx,L_shr(st_fx->lp_ener_fx,1)))) { /* update the pointer to circular buffer of old LSP vectors */ st_fx->ho_hist_ptr_fx = add(st_fx->ho_hist_ptr_fx, 1); - if( sub(st_fx->ho_hist_ptr_fx,HO_HIST_SIZE) == 0 ) + if( EQ_16(st_fx->ho_hist_ptr_fx,HO_HIST_SIZE)) { st_fx->ho_hist_ptr_fx = 0; move16(); @@ -604,7 +602,7 @@ void CNG_dec_fx( st_fx->ho_ener_hist_fx[st_fx->ho_hist_ptr_fx] = st_fx->Enew_fx; move32(); test(); - IF ( L_sub(core_brate,SID_2k40) == 0 && *sid_bw == 0 ) + IF ( EQ_32(core_brate,SID_2k40)&&*sid_bw==0) { /* enr1 = (float)log10( st->Enew*L_frame + 0.1f ) / (float)log10( 2.0f );*/ exp = norm_l(st_fx->Enew_fx); @@ -642,7 +640,7 @@ void CNG_dec_fx( } st_fx->ho_hist_size_fx = add(st_fx->ho_hist_size_fx,1); - if( sub(st_fx->ho_hist_size_fx,HO_HIST_SIZE) > 0 ) + if( GT_16(st_fx->ho_hist_size_fx,HO_HIST_SIZE)) { st_fx->ho_hist_size_fx = HO_HIST_SIZE; move16(); @@ -652,7 +650,7 @@ void CNG_dec_fx( st_fx->last_CNG_L_frame_fx = st_fx->L_frame_fx; move16(); - if( L_sub(core_brate,SID_1k75) != 0 ) + if( NE_32(core_brate,SID_1k75)) { st_fx->num_ho_fx = m; move16(); @@ -662,7 +660,7 @@ void CNG_dec_fx( /* Update the frame length memory */ st_fx->last_CNG_L_frame_fx = st_fx->L_frame_fx; - if( L_sub(core_brate,SID_1k75) != 0 ) + if( NE_32(core_brate,SID_1k75)) { st_fx->num_ho_fx = m; move16(); @@ -699,11 +697,11 @@ void swb_CNG_dec_fx( ) { test(); - IF ( st_fx->core_brate_fx == FRAME_NO_DATA || L_sub(st_fx->core_brate_fx, SID_2k40) == 0 ) + IF ( st_fx->core_brate_fx == FRAME_NO_DATA || EQ_32(st_fx->core_brate_fx, SID_2k40)) { /* SHB SID decoding and CNG */ test(); - IF (st_fx->cng_type_fx == LP_CNG && sub(st_fx->extl_fx, SWB_CNG) == 0) + IF (st_fx->cng_type_fx == LP_CNG && EQ_16(st_fx->extl_fx, SWB_CNG)) { shb_CNG_decod_fx( st_fx, synth_fx, shb_synth_fx, sid_bw, Qsyn ); } @@ -717,7 +715,7 @@ void swb_CNG_dec_fx( st_fx->last_vad_fx = 1; move16(); st_fx->burst_cnt_fx = add(st_fx->burst_cnt_fx, 1); - if ( sub(st_fx->burst_cnt_fx, 10) > 0 ) + if ( GT_16(st_fx->burst_cnt_fx, 10)) { st_fx->burst_cnt_fx = 0; move16(); @@ -768,7 +766,7 @@ static void shb_CNG_decod_fx( IF ( st_fx->bfi_fx == 0 ) { test(); - IF ( L_sub(st_fx->core_brate_fx, SID_2k40) == 0 && sub(sid_bw, 1) == 0 ) + IF ( EQ_32(st_fx->core_brate_fx, SID_2k40)&&EQ_16(sid_bw,1)) { idx_ener_fx = get_next_indice_fx(st_fx, 4); @@ -798,7 +796,7 @@ static void shb_CNG_decod_fx( move16(); /*Q14*/ } - if ( sub(st_fx->shb_dtx_count_fx, 1000) < 0 ) + if ( LT_16(st_fx->shb_dtx_count_fx, 1000)) { st_fx->shb_dtx_count_fx = add(st_fx->shb_dtx_count_fx, 1); } @@ -826,13 +824,13 @@ static void shb_CNG_decod_fx( st_fx->wb_cng_ener_fx = wb_ener16_fx; move16();/*Q8 */ } - if ( sub(abs_s(sub(wb_ener16_fx,st_fx->wb_cng_ener_fx)),3072) > 0 ) + if ( GT_16(abs_s(sub(wb_ener16_fx,st_fx->wb_cng_ener_fx)),3072)) { allow_cn_step_fx = 1; move16(); } - IF ( sub(allow_cn_step_fx, 1) == 0 ) + IF ( EQ_16(allow_cn_step_fx, 1)) { st_fx->wb_cng_ener_fx = wb_ener16_fx; move16(); /*Q8 */ @@ -845,7 +843,7 @@ static void shb_CNG_decod_fx( } test(); test(); - IF ( L_sub(st_fx->core_brate_fx, SID_2k40) == 0 && sub(sid_bw, 1) == 0 && st_fx->bfi_fx == 0 ) + IF ( EQ_32(st_fx->core_brate_fx, SID_2k40)&&EQ_16(sid_bw,1)&&st_fx->bfi_fx==0) { st_fx->last_wb_cng_ener_fx = st_fx->wb_cng_ener_fx; move16(); @@ -858,14 +856,14 @@ static void shb_CNG_decod_fx( } gain_fx = sub(st_fx->wb_cng_ener_fx, st_fx->last_wb_cng_ener_fx); /*8 */ - if (sub(gain_fx, 15) > 0) + if (GT_16(gain_fx, 15)) { gain_fx = 15; move16(); } step_fx = sub(add(gain_fx, st_fx->last_shb_cng_ener_fx), st_fx->shb_cng_ener_fx); /*Q8 */ test(); - IF ( sub(allow_cn_step_fx,1) == 0 || L_sub(st_fx->last_core_brate_fx,SID_2k40) > 0 ) + IF ( EQ_16(allow_cn_step_fx,1)||GT_32(st_fx->last_core_brate_fx,SID_2k40)) { st_fx->shb_cng_ener_fx = add(st_fx->shb_cng_ener_fx, step_fx); } @@ -894,12 +892,12 @@ static void shb_CNG_decod_fx( L_tmp = L_shl(L_tmp, q); q = q - 32; ener_excSHB_fx = round_fx(L_tmp); /*Qq */ - IF ( sub(st_fx->last_vad_fx, 1) == 0 ) + IF ( EQ_16(st_fx->last_vad_fx, 1)) { st_fx->trans_cnt_fx = 0; move16(); test(); - if ( sub(st_fx->burst_cnt_fx, 3) > 0 && sub(st_fx->last_core_fx, HQ_CORE) != 0 ) + if ( GT_16(st_fx->burst_cnt_fx, 3)&&NE_16(st_fx->last_core_fx,HQ_CORE)) { st_fx->trans_cnt_fx = 5; move16(); @@ -938,7 +936,7 @@ static void shb_CNG_decod_fx( exp1 = norm_s(ener_excSHB_fx); fra = shl(ener_excSHB_fx, exp1); /*Q15*/ - IF ( sub(fra,tmp) > 0 ) + IF ( GT_16(fra,tmp)) { fra = shr(fra, 1); /*Q15*/ exp1 = sub(exp1, 1); @@ -954,7 +952,7 @@ static void shb_CNG_decod_fx( } test(); - IF(sub(st_fx->last_extl_fx, SWB_TBE) == 0 || sub(st_fx->last_extl_fx, FB_TBE) == 0 ) + IF(EQ_16(st_fx->last_extl_fx, SWB_TBE)||EQ_16(st_fx->last_extl_fx,FB_TBE)) { /* rescale the Hilbert memories to Q0 */ FOR(i = 0; i < HILBERT_MEM_SIZE ; i++) @@ -971,7 +969,7 @@ static void shb_CNG_decod_fx( } GenSHBSynth_fx( shb_syn16k_fx, shb_synth_fx, st_fx->genSHBsynth_Hilbert_Mem_fx, st_fx->genSHBsynth_state_lsyn_filt_shb_local_fx, st_fx->L_frame_fx, &(st_fx->syn_dm_phase_fx) ); - IF ( L_sub(st_fx->output_Fs_fx,48000) == 0 ) + IF ( EQ_32(st_fx->output_Fs_fx,48000)) { interpolate_3_over_2_allpass_fx( shb_synth_fx, L_FRAME32k, shb_synth_fx, st_fx->interpol_3_2_cng_dec_fx, allpass_poles_3_ov_2 ); } diff --git a/lib_dec/core_dec_init.c b/lib_dec/core_dec_init.c index 05c6d9cd7144abc09543c3df4b67a91920bf79de..66015d515f217309575392b4daf6e6bfcf26efbb 100644 --- a/lib_dec/core_dec_init.c +++ b/lib_dec/core_dec_init.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -11,8 +11,6 @@ #include "rom_com_fx.h" #include "options.h" #include "stl.h" -#include "wmc_auto.h" - #include "cnst_fx.h" /* for MIN_CNG_LEV */ /*-----------------------------------------------------------------------* @@ -59,8 +57,8 @@ void open_decoder_LPD( Decoder_State_fx *st, Word32 bit_rate, Word16 bandwidth_m test(); test(); test(); - if ( (sub(st->L_frame_fx,L_FRAME16k) == 0 && L_sub(st->total_brate_fx,32000) <= 0 ) || - (st->tcxonly != 0 && (L_sub(st->sr_core,32000)==0 || L_sub(st->sr_core,16000)==0) ) + if ( (EQ_16(st->L_frame_fx,L_FRAME16k)&&LE_32(st->total_brate_fx,32000))|| + (st->tcxonly != 0 && (EQ_32(st->sr_core,32000) || EQ_32(st->sr_core,16000)) ) ) { st->nb_subfr = NB_SUBFR16k; @@ -77,7 +75,7 @@ void open_decoder_LPD( Decoder_State_fx *st, Word32 bit_rate, Word16 bandwidth_m st->TcxBandwidth = getTcxBandwidth(bandwidth_mode); st->narrowBand = 0; move16(); - if (sub(bandwidth_mode, NB) == 0) + if (EQ_16(bandwidth_mode, NB)) { st->narrowBand = 1; move16(); @@ -94,11 +92,11 @@ void open_decoder_LPD( Decoder_State_fx *st, Word32 bit_rate, Word16 bandwidth_m /*Preemphasis param*/ st->preemph_fac = PREEMPH_FAC_SWB; /*SWB*/ move16(); - IF ( sub(st->fscale, (16000*FSCALE_DENOM)/12800) < 0) + IF ( LT_16(st->fscale, (16000*FSCALE_DENOM)/12800)) { st->preemph_fac = PREEMPH_FAC; /*WB*/ move16(); } - ELSE if ( sub(st->fscale, (24000*FSCALE_DENOM)/12800) < 0) + ELSE if ( LT_16(st->fscale, (24000*FSCALE_DENOM)/12800)) { st->preemph_fac = PREEMPH_FAC_16k; /*WB*/ move16(); } @@ -107,7 +105,7 @@ void open_decoder_LPD( Decoder_State_fx *st, Word32 bit_rate, Word16 bandwidth_m move16(); st->inv_gamma = GAMMA1_INV; move16(); - IF ( L_sub(st->sr_core, 16000) == 0 ) + IF ( EQ_32(st->sr_core, 16000)) { st->gamma = GAMMA16k; move16(); @@ -119,7 +117,7 @@ void open_decoder_LPD( Decoder_State_fx *st, Word32 bit_rate, Word16 bandwidth_m st-> lpcQuantization = 0; move16(); test(); - if( st->tcxonly == 0 && L_sub(st->sr_core, 16000) <= 0) + if( st->tcxonly == 0 && LE_32(st->sr_core, 16000)) { st->lpcQuantization = 1; } @@ -224,7 +222,7 @@ void open_decoder_LPD( Decoder_State_fx *st, Word32 bit_rate, Word16 bandwidth_m { /* Reset old_synth in case of core sampling rate switching and codec switching*/ test(); - IF( (sub(st->L_frame_fx, st->last_L_frame_fx) != 0) || (sub(st->last_codec_mode,MODE1)==0) ) + IF( (NE_16(st->L_frame_fx, st->last_L_frame_fx))||(EQ_16(st->last_codec_mode,MODE1))) { set16_fx(st->old_synth, 0, OLD_SYNTH_INTERNAL_DEC); } @@ -237,12 +235,12 @@ void open_decoder_LPD( Decoder_State_fx *st, Word32 bit_rate, Word16 bandwidth_m /*Reset LPC mem*/ test(); test(); - IF( (sub(st->L_frame_fx,st->last_L_frame_fx)!=0) || (sub(st->last_core_fx,AMR_WB_CORE)==0) - || sub(st->last_core_fx,HQ_CORE) == 0 ) + IF( (NE_16(st->L_frame_fx,st->last_L_frame_fx))||(EQ_16(st->last_core_fx,AMR_WB_CORE)) + || EQ_16(st->last_core_fx,HQ_CORE) ) { /*LPC quant. mem*/ set16_fx(st->mem_MA_fx, 0, M); - IF( L_sub(st->sr_core,16000) == 0 ) + IF( EQ_32(st->sr_core,16000)) { Copy( GEWB2_Ave_fx, st->mem_AR_fx, M ); } @@ -253,13 +251,13 @@ void open_decoder_LPD( Decoder_State_fx *st, Word32 bit_rate, Word16 bandwidth_m } /*Codec switching*/ - IF( sub(st->last_codec_mode,MODE1)==0 ) + IF( EQ_16(st->last_codec_mode,MODE1)) { Copy( st->lsp_old_fx, st->lspold_uw, M ); Copy( st->lsf_old_fx, st->lsfold_uw, M ); set16_fx( st->syn, 0, M ); } - IF( sub(st->last_core_fx,AMR_WB_CORE)==0 ) + IF( EQ_16(st->last_core_fx,AMR_WB_CORE)) { st->last_core_fx = ACELP_CORE; move16(); @@ -269,7 +267,7 @@ void open_decoder_LPD( Decoder_State_fx *st, Word32 bit_rate, Word16 bandwidth_m /*Codec switching from ACELP-A */ test(); - IF( sub(st->last_codec_mode, MODE1)==0 && sub(st->last_core_fx, ACELP_CORE)==0 ) + IF( EQ_16(st->last_codec_mode, MODE1)&&EQ_16(st->last_core_fx,ACELP_CORE)) { st->last_core_bfi = ACELP_CORE; move16(); @@ -323,10 +321,10 @@ void open_decoder_LPD( Decoder_State_fx *st, Word32 bit_rate, Word16 bandwidth_m test(); test(); test(); - IF( sub(st->last_codec_mode,MODE2) == 0 && - sub(st->L_frame_fx, st->last_L_frame_fx) != 0 && - ( ( sub(st->m_frame_type, SID_FRAME) == 0 && sub(st->last_core_fx, ACELP_CORE) > 0 ) || - ( sub(st->last_core_fx, ACELP_CORE) > 0 && sub(st->core_fx, ACELP_CORE) > 0) || + IF( EQ_16(st->last_codec_mode,MODE2)&& + NE_16(st->L_frame_fx, st->last_L_frame_fx) && + ( ( EQ_16(st->m_frame_type, SID_FRAME) && GT_16(st->last_core_fx, ACELP_CORE) ) || + ( GT_16(st->last_core_fx, ACELP_CORE) && GT_16(st->core_fx, ACELP_CORE) ) || st->prev_bfi_fx ) ) { lerp(st->old_out_LB_fx, st->old_out_LB_fx, st->L_frame_fx, st->last_L_frame_fx); @@ -336,7 +334,7 @@ void open_decoder_LPD( Decoder_State_fx *st, Word32 bit_rate, Word16 bandwidth_m test(); test(); test(); - IF( sub(st->last_codec_mode,MODE1)==0 && sub(st->last_core_fx,HQ_CORE)==0 ) + IF( EQ_16(st->last_codec_mode,MODE1)&&EQ_16(st->last_core_fx,HQ_CORE)) { /*Codec switching from MDCT */ @@ -373,7 +371,7 @@ void open_decoder_LPD( Decoder_State_fx *st, Word32 bit_rate, Word16 bandwidth_m cldfb_reset_memory( st->cldfbBPF_fx ); cldfb_reset_memory( st->cldfbSyn_fx ); } - ELSE IF( (sub(st->L_frame_fx,st->last_L_frame_fx)!=0) && (sub(st->L_frame_fx,L_FRAME16k)<=0) && (sub(st->last_L_frame_fx,L_FRAME16k)<=0)) /* Rate switching between 12.8 and 16 kHz*/ + ELSE IF( (NE_16(st->L_frame_fx,st->last_L_frame_fx))&&(LE_16(st->L_frame_fx,L_FRAME16k))&&(LE_16(st->last_L_frame_fx,L_FRAME16k))) /* Rate switching between 12.8 and 16 kHz*/ { /*Interpolation of ACELP memories*/ @@ -400,7 +398,7 @@ void open_decoder_LPD( Decoder_State_fx *st, Word32 bit_rate, Word16 bandwidth_m /*mem of deemphasis stayed unchanged.*/ } - ELSE IF( sub(st->L_frame_fx,st->last_L_frame_fx)!=0 ) /* Rate switching involving TCX only modes */ + ELSE IF( NE_16(st->L_frame_fx,st->last_L_frame_fx)) /* Rate switching involving TCX only modes */ { /*Partial reset of ACELP memories*/ st->rate_switching_reset = 1; @@ -420,7 +418,7 @@ void open_decoder_LPD( Decoder_State_fx *st, Word32 bit_rate, Word16 bandwidth_m /*Untouched memories : st->syn */ } - ELSE IF( !st->tcxonly && sub(st->L_frame_fx,L_FRAME16k) == 0 && L_sub(st->last_total_brate_fx,ACELP_32k) > 0 ) + ELSE IF( !st->tcxonly && EQ_16(st->L_frame_fx,L_FRAME16k)&>_32(st->last_total_brate_fx,ACELP_32k)) { lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, st->sr_core ); } @@ -428,7 +426,7 @@ void open_decoder_LPD( Decoder_State_fx *st, Word32 bit_rate, Word16 bandwidth_m test(); test(); - if(sub(st->last_bwidth_fx,NB)==0 && sub(st->bwidth_fx,NB)!=0 && st->ini_frame_fx!=0) + if(EQ_16(st->last_bwidth_fx,NB)&&NE_16(st->bwidth_fx,NB)&&st->ini_frame_fx!=0) { st->rate_switching_reset=1; move16(); @@ -447,7 +445,7 @@ void open_decoder_LPD( Decoder_State_fx *st, Word32 bit_rate, Word16 bandwidth_m { /*do nothing*/ } - ELSE IF( sub(st->last_codec_mode,MODE2)==0) + ELSE IF( EQ_16(st->last_codec_mode,MODE2)) { IF (st->tcxonly==0) { @@ -475,7 +473,7 @@ void open_decoder_LPD( Decoder_State_fx *st, Word32 bit_rate, Word16 bandwidth_m { /*codec switching*/ /*reset post-filter except for Narrowband*/ - IF ( L_sub(st->output_Fs_fx,8000)!=0 ) + IF ( NE_32(st->output_Fs_fx,8000)) { st->pfstat.reset = 1; if(st->pfstat.on!=0) @@ -530,7 +528,7 @@ void open_decoder_LPD( Decoder_State_fx *st, Word32 bit_rate, Word16 bandwidth_m st->last_gain_syn_deemph_e = 1; move16(); test(); - IF( sub(st->last_codec_mode,MODE1) == 0 || st->ini_frame_fx == 0 ) + IF( EQ_16(st->last_codec_mode,MODE1)||st->ini_frame_fx==0) { /* this assumes that MODE1 fades out in the frequency domain - otherwise some data from MODE1 would be needed here */ @@ -575,7 +573,7 @@ void open_decoder_LPD( Decoder_State_fx *st, Word32 bit_rate, Word16 bandwidth_m { /* calculate energy at the end of the previous frame */ test(); - IF( sub(st->core_fx,ACELP_CORE) == 0 && sub(st->last_core_fx,HQ_CORE) == 0 ) + IF( EQ_16(st->core_fx,ACELP_CORE)&&EQ_16(st->last_core_fx,HQ_CORE)) { frame_ener_fx( st->output_frame_fx, UNVOICED_CLAS, st->previoussynth_fx, -1, &st->enr_old_fx, 1, 0, 0, 0 ); } @@ -640,7 +638,7 @@ void open_decoder_LPD( Decoder_State_fx *st, Word32 bit_rate, Word16 bandwidth_m move16(); test(); - IF ( st->ini_frame_fx == 0 || sub(st->last_codec_mode,MODE1)==0) + IF ( st->ini_frame_fx == 0 || EQ_16(st->last_codec_mode,MODE1)) { st->tcxltp_pitch_int = st->pit_max; move16(); @@ -694,8 +692,8 @@ void open_decoder_LPD( Decoder_State_fx *st, Word32 bit_rate, Word16 bandwidth_m move16(); test(); test(); - if ( sub(bandwidth_mode, SWB) == 0 && - (L_sub(st->total_brate_fx, ACELP_16k40) == 0 || L_sub(st->total_brate_fx, ACELP_24k40) == 0) ) + if ( EQ_16(bandwidth_mode, SWB)&& + (EQ_32(st->total_brate_fx, ACELP_16k40) || EQ_32(st->total_brate_fx, ACELP_24k40)) ) { st->tec_tfa = 1; move16(); @@ -721,14 +719,14 @@ void open_decoder_LPD( Decoder_State_fx *st, Word32 bit_rate, Word16 bandwidth_m st->enablePlcWaveadjust = 0; move16(); - IF(L_sub(st->total_brate_fx, 48000) >= 0 ) + IF(GE_32(st->total_brate_fx, 48000)) { st->enablePlcWaveadjust = 1; move16(); test(); test(); test(); - IF (st->ini_frame_fx == 0 || L_sub(st->last_total_brate_fx, HQ_48k) < 0 || sub(st->last_codec_mode, MODE1) == 0 || st->force_lpd_reset ) + IF (st->ini_frame_fx == 0 || LT_32(st->last_total_brate_fx, HQ_48k)||EQ_16(st->last_codec_mode,MODE1)||st->force_lpd_reset) { concealment_init_x( st->L_frameTCX, &st->plcInfo ); } @@ -766,8 +764,8 @@ void open_decoder_LPD( Decoder_State_fx *st, Word32 bit_rate, Word16 bandwidth_m test(); test(); test(); - if( (L_sub(st->total_brate_fx, 9600)==0)||( L_sub(st->total_brate_fx, 16400)==0)|| - (L_sub(st->total_brate_fx, 24400)==0)) + if( (EQ_32(st->total_brate_fx, 9600))||(EQ_32(st->total_brate_fx,16400))|| + (EQ_32(st->total_brate_fx, 24400))) { move16(); st->dec_glr = 1; diff --git a/lib_dec/core_dec_reconf.c b/lib_dec/core_dec_reconf.c index d2bd184a3b89d1553e12c1c02233f7194eaa8394..02f9811eab6c91f34a7b6bbcab6e9fe78050718a 100644 --- a/lib_dec/core_dec_reconf.c +++ b/lib_dec/core_dec_reconf.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -9,8 +9,6 @@ #include "prot_fx.h" #include "options.h" #include "stl.h" -#include "wmc_auto.h" - #include "rom_com_fx.h" @@ -60,7 +58,7 @@ void reconfig_decoder_LPD( Decoder_State_fx *st, Word16 bits_frame, Word16 bandw st->tcx_cfg.na_scale=32767/*1.0f Q15*/; test(); - IF ((sub(bandwidth_mode,SWB)<0) && !(st->tcxonly)) + IF ((LT_16(bandwidth_mode,SWB))&&!(st->tcxonly)) { Word16 scaleTableSize = sizeof (scaleTcxTable) / sizeof (scaleTcxTable[0]); /* is a constant */ @@ -68,9 +66,9 @@ void reconfig_decoder_LPD( Decoder_State_fx *st, Word16 bits_frame, Word16 bandw { test(); test(); - IF ( (sub (bandwidth_mode,scaleTcxTable[i].bwmode) == 0) && - (L_sub (bitrate,scaleTcxTable[i].bitrateFrom) >= 0) && - (L_sub (bitrate,scaleTcxTable[i].bitrateTo) < 0 ) + IF ( (EQ_16(bandwidth_mode,scaleTcxTable[i].bwmode)) && + (GE_32 (bitrate,scaleTcxTable[i].bitrateFrom) ) && + (LT_32 (bitrate,scaleTcxTable[i].bitrateTo) ) ) { if( st->rf_flag ) @@ -90,7 +88,7 @@ void reconfig_decoder_LPD( Decoder_State_fx *st, Word16 bits_frame, Word16 bandw test(); test(); test(); - IF( sub (st->fscale,st->fscale_old) != 0 + IF( NE_16 (st->fscale,st->fscale_old) && ! (st->last_codec_mode == MODE1 && st->last_core_fx == ACELP_CORE && st->prev_bfi_fx != 0)) @@ -108,7 +106,7 @@ void reconfig_decoder_LPD( Decoder_State_fx *st, Word16 bits_frame, Word16 bandw test(); test(); - IF( (st->prev_bfi_fx && sub(st->last_core_bfi,ACELP_CORE)==0) || sub(st->last_core_fx,ACELP_CORE)==0 ) + IF( (st->prev_bfi_fx && EQ_16(st->last_core_bfi,ACELP_CORE))||EQ_16(st->last_core_fx,ACELP_CORE)) { newLen = shr(st->L_frame_fx,1); oldLen = shr(L_frame_old,1); @@ -118,22 +116,22 @@ void reconfig_decoder_LPD( Decoder_State_fx *st, Word16 bits_frame, Word16 bandw lerp( st->syn_Overl, st->syn_Overl, newLen, oldLen ); test(); - IF( st->prev_bfi_fx && sub(st->last_core_bfi,ACELP_CORE)==0 ) + IF( st->prev_bfi_fx && EQ_16(st->last_core_bfi,ACELP_CORE)) { lerp( st->syn_Overl_TDAC, st->syn_Overl_TDAC, newLen, oldLen ); } } - IF (sub(st->L_frame_fx,L_FRAME16k) <= 0) + IF (LE_16(st->L_frame_fx,L_FRAME16k)) { - IF (sub(st->last_L_frame_fx,L_FRAME16k) <= 0) + IF (LE_16(st->last_L_frame_fx,L_FRAME16k)) { - IF (sub(st->L_frame_fx,st->last_L_frame_fx) != 0) + IF (NE_16(st->L_frame_fx,st->last_L_frame_fx)) { Word16 oldLenClasBuff; Word16 newLenClasBuff; - IF (sub(st->L_frame_fx,st->last_L_frame_fx) > 0) + IF (GT_16(st->L_frame_fx,st->last_L_frame_fx)) { oldLenClasBuff = extract_l(L_shr(Mpy_32_16_1(L_mult0(st->last_L_frame_fx,getInvFrameLen(st->L_frame_fx)/*Q21*/)/*Q21*/,L_SYN_MEM_CLAS_ESTIM/*Q0*/)/*Q6*/,6)/*Q0*/); diff --git a/lib_dec/core_dec_switch.c b/lib_dec/core_dec_switch.c index ec267b6025000f5a3fd701eb75bdd4cd063dea9a..780b7165a121b61e3f5e4b1f0ca24b3539bf0539 100644 --- a/lib_dec/core_dec_switch.c +++ b/lib_dec/core_dec_switch.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -8,8 +8,6 @@ #include "basop_util.h" #include "prot_fx.h" #include "stl.h" -#include "wmc_auto.h" - #include "options.h" #include "rom_com_fx.h" @@ -28,7 +26,7 @@ void mode_switch_decoder_LPD( Decoder_State_fx *st, Word16 bandwidth, Word32 bit bSwitchFromAmrwbIO = 0; move16(); - if (sub(st->last_core_fx,AMR_WB_CORE)==0) + if (EQ_16(st->last_core_fx,AMR_WB_CORE)) { bSwitchFromAmrwbIO = 1; move16(); @@ -44,12 +42,12 @@ void mode_switch_decoder_LPD( Decoder_State_fx *st, Word16 bandwidth, Word32 bit test(); test(); - IF (( (sub(bandwidth, WB) >= 0) && (sub(fscale, (FSCALE_DENOM*16000)/12800) == 0) && (sub(fscale, st->fscale) == 0) )) + IF (( (GE_16(bandwidth, WB))&&(EQ_16(fscale,(FSCALE_DENOM*16000)/12800))&&(EQ_16(fscale,st->fscale)))) { test(); test(); test(); - if ( ((L_sub(bitrate, 32000) > 0) && (st->tcxonly == 0)) || ((L_sub(bitrate, 32000) <= 0) && (st->tcxonly != 0)) ) + if ( ((GT_32(bitrate, 32000))&&(st->tcxonly==0))||((LE_32(bitrate,32000))&&(st->tcxonly!=0))) { switchWB = 1; move16(); @@ -57,7 +55,7 @@ void mode_switch_decoder_LPD( Decoder_State_fx *st, Word16 bandwidth, Word32 bit } test(); - if( sub(st->last_L_frame_fx,L_FRAME16k) >0 && L_sub(st->total_brate_fx,ACELP_32k) <=0 ) + if( GT_16(st->last_L_frame_fx,L_FRAME16k)&&LE_32(st->total_brate_fx,ACELP_32k)) { switchWB = 1; move16(); @@ -79,7 +77,7 @@ void mode_switch_decoder_LPD( Decoder_State_fx *st, Word16 bandwidth, Word32 bit test(); test(); test(); - IF ( sub(fscale, st->fscale) != 0 || switchWB != 0 || bSwitchFromAmrwbIO != 0 || sub(st->last_codec_mode,MODE1)==0 || st->force_lpd_reset ) + IF ( NE_16(fscale, st->fscale)||switchWB!=0||bSwitchFromAmrwbIO!=0||EQ_16(st->last_codec_mode,MODE1)||st->force_lpd_reset) { open_decoder_LPD( st, bitrate, bandwidth ); } @@ -106,7 +104,7 @@ void mode_switch_decoder_LPD( Decoder_State_fx *st, Word16 bandwidth, Word32 bit st->narrowBand = 0; move16(); - if ( sub(bandwidth, NB) == 0 ) + if ( EQ_16(bandwidth, NB)) { st->narrowBand = 1; move16(); @@ -146,8 +144,8 @@ void mode_switch_decoder_LPD( Decoder_State_fx *st, Word16 bandwidth, Word32 bit { E_LPC_lsp_lsf_conversion( st->lsp_old_fx, st->lsfoldbfi1_fx, M ); } - MVR2R_WORD16(st->lsfoldbfi1_fx, st->lsfoldbfi0_fx,M); - MVR2R_WORD16(st->lsfoldbfi1_fx, st->lsf_adaptive_mean_fx,M); + mvr2r_Word16(st->lsfoldbfi1_fx, st->lsfoldbfi0_fx,M); + mvr2r_Word16(st->lsfoldbfi1_fx, st->lsf_adaptive_mean_fx,M); IF( st->igf != 0 ) { @@ -156,9 +154,9 @@ void mode_switch_decoder_LPD( Decoder_State_fx *st, Word16 bandwidth, Word32 bit test(); test(); test(); - IF( (sub(st->bwidth_fx, WB)==0 && sub(st->last_extl_fx, WB_TBE)!=0) || - (sub(st->bwidth_fx, SWB)==0 && sub(st->last_extl_fx, SWB_TBE)!=0) || - (sub(st->bwidth_fx, FB)==0 && sub(st->last_extl_fx,FB_TBE)!=0) ) + IF( (EQ_16(st->bwidth_fx, WB)&&NE_16(st->last_extl_fx,WB_TBE))|| + (EQ_16(st->bwidth_fx, SWB) && NE_16(st->last_extl_fx, SWB_TBE)) || + (EQ_16(st->bwidth_fx, FB) && NE_16(st->last_extl_fx,FB_TBE)) ) { TBEreset_dec_fx(st, st->bwidth_fx); } @@ -175,8 +173,8 @@ void mode_switch_decoder_LPD( Decoder_State_fx *st, Word16 bandwidth, Word32 bit test(); test(); - IF( (sub(bandwidth, SWB) == 0) && - (L_sub(st->total_brate_fx, ACELP_16k40) == 0 || L_sub(st->total_brate_fx, ACELP_24k40) == 0) + IF( (EQ_16(bandwidth, SWB))&& + (EQ_32(st->total_brate_fx, ACELP_16k40) || EQ_32(st->total_brate_fx, ACELP_24k40)) ) { IF (st->tec_tfa == 0) @@ -205,7 +203,7 @@ void mode_switch_decoder_LPD( Decoder_State_fx *st, Word16 bandwidth, Word32 bit test(); test(); test(); - if( (sub(bandwidth, WB ) == 0 && L_sub(bitrate, 24400) == 0) || + if( (EQ_16(bandwidth, WB )&&EQ_32(bitrate,24400))|| (sub(bandwidth, SWB) == 0 && L_sub(bitrate, 24400) == 0 )|| (sub(bandwidth, FB) == 0 && L_sub(bitrate, 24400) == 0 ) ) { @@ -216,8 +214,8 @@ void mode_switch_decoder_LPD( Decoder_State_fx *st, Word16 bandwidth, Word32 bit st->dec_glr = 0; test(); test(); - if( (L_sub(st->total_brate_fx, 9600)==0)||( L_sub(st->total_brate_fx, 16400)==0)|| - (L_sub(st->total_brate_fx, 24400)==0)) + if( (EQ_32(st->total_brate_fx, 9600))||(EQ_32(st->total_brate_fx,16400))|| + (EQ_32(st->total_brate_fx, 24400))) { st->dec_glr = 1; move16(); diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index c1f5ab133969ce0d9586c6ed48a7fba294bc64ad..1254d55edfc2902e32765f506e9d8e5f9ebad18a 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -7,9 +7,7 @@ #include "cnst_fx.h" /* Common constants */ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ -#include "stl.h" -#include "wmc_auto.h" - /* required for wmc_tool */ +#include "stl.h" /* required for wmc_tool */ #include "basop_mpy.h" /*required for CodeB_Mpy_32_16()*/ #include "basop_util.h" /* Function prototypes */ @@ -28,20 +26,20 @@ void bandwidth_switching_detect_fx( test(); test(); test(); - IF( sub(st_fx->bws_cnt1_fx, N_NS2W_FRAMES) >= 0 ) + IF( GE_16(st_fx->bws_cnt1_fx, N_NS2W_FRAMES)) { st_fx->bws_cnt1_fx = 0; move16(); } - ELSE IF( L_sub(st_fx->total_brate_fx, ACELP_9k60) > 0 && L_sub(st_fx->last_core_brate_fx, ACELP_9k60) < 0 - && sub(st_fx->bwidth_fx, SWB) == 0 && sub(st_fx->last_bwidth_fx, WB) == 0 ) + ELSE IF( GT_32(st_fx->total_brate_fx, ACELP_9k60)&<_32(st_fx->last_core_brate_fx,ACELP_9k60) + && EQ_16(st_fx->bwidth_fx, SWB) && EQ_16(st_fx->last_bwidth_fx, WB) ) { st_fx->bws_cnt1_fx = add(st_fx->bws_cnt1_fx,1); move16(); } ELSE IF( st_fx->bws_cnt1_fx > 0 ) { - IF( sub(st_fx->bwidth_fx, st_fx->last_bwidth_fx) < 0 ) + IF( LT_16(st_fx->bwidth_fx, st_fx->last_bwidth_fx)) { st_fx->bws_cnt_fx = sub( shl(sub(N_NS2W_FRAMES, st_fx->bws_cnt1_fx), 1), 1 ); move16(); @@ -52,14 +50,14 @@ void bandwidth_switching_detect_fx( move16(); } - IF( sub(st_fx->bwidth_fx, st_fx->last_bwidth_fx) < 0 ) + IF( LT_16(st_fx->bwidth_fx, st_fx->last_bwidth_fx)) { st_fx->bws_cnt1_fx = 0; move16(); } ELSE { - IF(sub(st_fx->bwidth_fx, SWB) == 0) + IF(EQ_16(st_fx->bwidth_fx, SWB)) { st_fx->bws_cnt1_fx = add(st_fx->bws_cnt1_fx,1); move16(); @@ -76,20 +74,20 @@ void bandwidth_switching_detect_fx( test(); test(); test(); - IF( sub(st_fx->bws_cnt_fx, N_WS2N_FRAMES) >= 0 ) + IF( GE_16(st_fx->bws_cnt_fx, N_WS2N_FRAMES)) { st_fx->bws_cnt_fx = 0; move16(); } - ELSE IF( L_sub(st_fx->total_brate_fx, ACELP_9k60) < 0 && L_sub(st_fx->last_core_brate_fx, ACELP_9k60) > 0 - && sub(st_fx->bwidth_fx, st_fx->last_bwidth_fx) < 0 && sub(st_fx->bwidth_fx, WB) == 0 ) + ELSE IF( LT_32(st_fx->total_brate_fx, ACELP_9k60)&>_32(st_fx->last_core_brate_fx,ACELP_9k60) + && LT_16(st_fx->bwidth_fx, st_fx->last_bwidth_fx) && EQ_16(st_fx->bwidth_fx, WB) ) { st_fx->bws_cnt_fx = add(st_fx->bws_cnt_fx,1); move16(); } ELSE IF( st_fx->bws_cnt_fx > 0 ) { - IF( sub(st_fx->bwidth_fx, st_fx->last_bwidth_fx) > 0 ) + IF( GT_16(st_fx->bwidth_fx, st_fx->last_bwidth_fx)) { st_fx->bws_cnt1_fx = shr(sub(N_WS2N_FRAMES, st_fx->bws_cnt_fx), 1); move16(); @@ -100,14 +98,14 @@ void bandwidth_switching_detect_fx( move16(); } - IF( sub(st_fx->bwidth_fx, st_fx->last_bwidth_fx) > 0 ) + IF( GT_16(st_fx->bwidth_fx, st_fx->last_bwidth_fx)) { st_fx->bws_cnt_fx = 0; move16(); } ELSE { - IF( sub(st_fx->bwidth_fx, WB) == 0 ) + IF( EQ_16(st_fx->bwidth_fx, WB)) { st_fx->bws_cnt_fx = add(st_fx->bws_cnt_fx,1); move16(); @@ -166,7 +164,7 @@ void bw_switching_pre_proc_fx( Word16 i; Word16 syn_dct_fx[L_FRAME]; Word32 L_tmp; - IF( sub(st_fx->core_fx, ACELP_CORE) == 0 ) + IF( EQ_16(st_fx->core_fx, ACELP_CORE)) { /*----------------------------------------------------------------------* * Calculate tilt of the ACELP core synthesis @@ -240,13 +238,13 @@ void bw_switching_pre_proc_fx( test(); test(); test(); - IF( st_fx->last_bwidth_fx == 0 && sub(st_fx->extl_fx, SWB_CNG) <= 0 ) + IF( st_fx->last_bwidth_fx == 0 && LE_16(st_fx->extl_fx, SWB_CNG)) { st_fx->prev_ener_shb_fx = 0; move16(); set16_fx(st_fx->prev_SWB_fenv_fx, 0, SWB_FENV); } - ELSE if(((sub(st_fx->core_fx, ACELP_CORE) == 0 && sub(st_fx->last_core_fx, HQ_CORE) == 0) || (sub(st_fx->core_fx, st_fx->last_core_fx) == 0 && sub(st_fx->extl_fx, st_fx->last_extl_fx) != 0)) && sub(st_fx->last_bwidth_fx, SWB) >= 0) + ELSE if(((EQ_16(st_fx->core_fx, ACELP_CORE)&&EQ_16(st_fx->last_core_fx,HQ_CORE))||(EQ_16(st_fx->core_fx,st_fx->last_core_fx)&&NE_16(st_fx->extl_fx,st_fx->last_extl_fx)))&&GE_16(st_fx->last_bwidth_fx,SWB)) { st_fx->attenu_fx = 3277; move16(); @@ -256,9 +254,9 @@ void bw_switching_pre_proc_fx( test(); test(); test(); - IF(sub(st_fx->last_core_fx, HQ_CORE) == 0 - || ( sub(st_fx->last_core_fx, ACELP_CORE) == 0 - && !(sub(st_fx->last_extl_fx, WB_TBE) == 0 || sub(st_fx->last_extl_fx, SWB_TBE) == 0 || sub(st_fx->last_extl_fx, FB_TBE) == 0) && L_sub(st_fx->core_brate_fx, ACELP_8k00) > 0)) + IF(EQ_16(st_fx->last_core_fx, HQ_CORE) + || ( EQ_16(st_fx->last_core_fx, ACELP_CORE) + && !(EQ_16(st_fx->last_extl_fx, WB_TBE) || EQ_16(st_fx->last_extl_fx, SWB_TBE) || EQ_16(st_fx->last_extl_fx, FB_TBE) ) && GT_32(st_fx->core_brate_fx, ACELP_8k00) )) { st_fx->prev_fractive_fx = 0; move16(); @@ -281,7 +279,7 @@ void core_switching_pre_dec_fx( Word16 oldLenClasBuff, newLenClasBuff; /* Codec switching */ - IF( sub(st_fx->last_codec_mode,MODE2)==0 ) + IF( EQ_16(st_fx->last_codec_mode,MODE2)) { st_fx->mem_deemph_fx = st_fx->syn[M]; move16(); @@ -302,7 +300,7 @@ void core_switching_pre_dec_fx( st_fx->psf_lp_noise_fx = round_fx(L_shl(st_fx->lp_noise,1)); /* reset old HB synthesis buffer */ - IF( sub(st_fx->last_L_frame_fx,L_FRAME) == 0 ) + IF( EQ_16(st_fx->last_L_frame_fx,L_FRAME)) { st_fx->old_bwe_delay_fx = NS2SA_fx2( st_fx->output_Fs_fx, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_12k8_NS ); } @@ -320,14 +318,14 @@ void core_switching_pre_dec_fx( st_fx->igf = 0; move16(); - IF( sub(st_fx->last_core_fx,ACELP_CORE) != 0 ) + IF( NE_16(st_fx->last_core_fx,ACELP_CORE)) { /* reset BWE memories */ set16_fx( st_fx->old_bwe_exc_fx, 0, PIT16k_MAX*2 ); st_fx->bwe_non_lin_prev_scale_fx = L_deposit_l(0); } - IF( L_sub(st_fx->output_Fs_fx,16000) >= 0 ) + IF( GE_32(st_fx->output_Fs_fx,16000)) { hf_synth_reset_fx( &st_fx->seed2_fx, st_fx->mem_hf_fx, st_fx->mem_syn_hf_fx, st_fx->mem_hp400_fx, st_fx->mem_hp_interp_fx, st_fx->delay_syn_hf_fx ); } @@ -341,7 +339,7 @@ void core_switching_pre_dec_fx( st_fx->last_max_pos_pulse_fx = 0; move16(); - IF( L_sub(st_fx->output_Fs_fx,16000)>0 ) + IF( GT_32(st_fx->output_Fs_fx,16000)) { set32_fx( st_fx->prev_coeff_out_fx, 0, L_HQ_WB_BWE ); } @@ -354,7 +352,7 @@ void core_switching_pre_dec_fx( move32(); test(); - IF( sub(st_fx->last_core_fx,TCX_20_CORE)==0 || sub(st_fx->last_core_fx,TCX_10_CORE)==0 ) + IF( EQ_16(st_fx->last_core_fx,TCX_20_CORE)||EQ_16(st_fx->last_core_fx,TCX_10_CORE)) { st_fx->last_core_fx = HQ_CORE; move16(); @@ -382,7 +380,7 @@ void core_switching_pre_dec_fx( delay_comp = NS2SA_fx2(st_fx->output_Fs_fx, DELAY_CLDFB_NS); - IF( !st_fx->last_con_tcx && st_fx->last_core_bfi == ACELP_CORE && sub(st_fx->core_fx,HQ_CORE)==0 ) + IF( !st_fx->last_con_tcx && st_fx->last_core_bfi == ACELP_CORE && EQ_16(st_fx->core_fx,HQ_CORE)) { Word16 i, no_col; @@ -417,7 +415,7 @@ void core_switching_pre_dec_fx( cldfb_restore_memory( st_fx->cldfbSyn_fx ); } - IF( !st_fx->last_con_tcx && st_fx->last_core_bfi == ACELP_CORE && sub(st_fx->core_fx,HQ_CORE)==0 ) + IF( !st_fx->last_con_tcx && st_fx->last_core_bfi == ACELP_CORE && EQ_16(st_fx->core_fx,HQ_CORE)) { lerp(st_fx->syn_Overl, st_fx->fer_samples_fx+delay_comp,shr(st_fx->output_frame_fx,1), shr(st_fx->last_L_frame_fx,1)); /*Set to zero the remaining part*/ @@ -433,14 +431,14 @@ void core_switching_pre_dec_fx( } /*FEC*/ - IF( sub(st_fx->L_frame_fx,L_FRAME16k)<=0 ) + IF( LE_16(st_fx->L_frame_fx,L_FRAME16k)) { test(); - IF( sub(st_fx->last_L_frame_fx,L_FRAME16k)<=0 && sub(st_fx->core_fx, HQ_CORE)!=0 ) + IF( LE_16(st_fx->last_L_frame_fx,L_FRAME16k)&&NE_16(st_fx->core_fx,HQ_CORE)) { - IF( sub(st_fx->L_frame_fx,st_fx->last_L_frame_fx)!=0 ) + IF( NE_16(st_fx->L_frame_fx,st_fx->last_L_frame_fx)) { - IF (sub(st_fx->L_frame_fx,st_fx->last_L_frame_fx)>0) + IF (GT_16(st_fx->L_frame_fx,st_fx->last_L_frame_fx)) { oldLenClasBuff = extract_l(L_shr(Mpy_32_16_1(L_mult0(st_fx->last_L_frame_fx,getInvFrameLen(st_fx->L_frame_fx)/*Q21*/)/*Q21*/,L_SYN_MEM_CLAS_ESTIM/*Q0*/)/*Q6*/,6)/*Q0*/); newLenClasBuff = L_SYN_MEM_CLAS_ESTIM; @@ -467,7 +465,7 @@ void core_switching_pre_dec_fx( within ACELP_CORE if switching from another bitarate to vbr, last_ppp and last_nelp is always updated in the previous frame */ test(); test(); - IF( sub(st_fx->core_fx, ACELP_CORE) == 0 && ( sub(st_fx->last_core_fx, ACELP_CORE) != 0 || sub(st_fx->last_codec_mode,MODE2) == 0 )) + IF( EQ_16(st_fx->core_fx, ACELP_CORE)&&(NE_16(st_fx->last_core_fx,ACELP_CORE)||EQ_16(st_fx->last_codec_mode,MODE2))) { st_fx->last_ppp_mode_dec_fx = 0; move16(); @@ -478,7 +476,7 @@ void core_switching_pre_dec_fx( test(); test(); test(); - IF( sub(st_fx->core_fx, ACELP_CORE) == 0 && ( sub(st_fx->last_core_fx, ACELP_CORE) != 0 || sub(st_fx->last_codec_mode,MODE2) == 0 || L_sub(st_fx->last_total_brate_fx, PPP_NELP_2k80) <= 0 )) + IF( EQ_16(st_fx->core_fx, ACELP_CORE)&&(NE_16(st_fx->last_core_fx,ACELP_CORE)||EQ_16(st_fx->last_codec_mode,MODE2)||LE_32(st_fx->last_total_brate_fx,PPP_NELP_2k80))) { st_fx->act_count_fx = 3; move16(); @@ -488,9 +486,9 @@ void core_switching_pre_dec_fx( test(); test(); - IF( (sub(st_fx->core_fx,ACELP_CORE)==0 || sub(st_fx->core_fx, AMR_WB_CORE)==0 ) && sub( st_fx->last_core_fx,HQ_CORE)==0 ) + IF( (EQ_16(st_fx->core_fx,ACELP_CORE)||EQ_16(st_fx->core_fx,AMR_WB_CORE))&&EQ_16(st_fx->last_core_fx,HQ_CORE)) { - IF(sub(st_fx->L_frame_fx, L_FRAME16k)==0 ) + IF(EQ_16(st_fx->L_frame_fx, L_FRAME16k)) { Copy( TRWB2_Ave_fx, st_fx->lsf_old_fx, M ); Copy( TRWB2_Ave_fx, st_fx->lsfoldbfi1_fx, M ); @@ -520,7 +518,7 @@ void core_switching_pre_dec_fx( /* Reset ACELP parameters */ set16_fx( st_fx->mem_MA_fx,0, M ); - IF( L_sub(st_fx->sr_core,16000) == 0 ) + IF( EQ_32(st_fx->sr_core,16000)) { Copy( GEWB2_Ave_fx, st_fx->mem_AR_fx, M ); } @@ -578,7 +576,7 @@ void core_switching_pre_dec_fx( { set16_fx(st_fx->old_exc_fx,0, L_EXC_MEM_DEC ); } - ELSE IF (sub(st_fx->L_frame_fx,L_FRAME16k) < 0) + ELSE IF (LT_16(st_fx->L_frame_fx,L_FRAME16k)) { /* resample from 16kHz to 12.8kHZ */ synth_mem_updt2( st_fx->L_frame_fx, L_FRAME16k, st_fx->old_exc_fx, st_fx->mem_syn_r, st_fx->mem_syn2_fx, NULL, DEC ); @@ -586,7 +584,7 @@ void core_switching_pre_dec_fx( set16_fx( st_fx->old_bwe_exc_fx, 0, PIT16k_MAX*2 ); - IF( L_sub(st_fx->output_Fs_fx, 16000L)>=0 ) + IF( GE_32(st_fx->output_Fs_fx, 16000L)) { hf_synth_reset_fx( &st_fx->seed2_fx, st_fx->mem_hf_fx, st_fx->mem_syn_hf_fx, st_fx->mem_hp400_fx, st_fx->mem_hp_interp_fx, st_fx->delay_syn_hf_fx ); } @@ -595,7 +593,7 @@ void core_switching_pre_dec_fx( test(); test(); - IF( sub(st_fx->core_fx,HQ_CORE)==0 && (sub(st_fx->last_core_fx,ACELP_CORE)==0 || st_fx->last_core_fx == AMR_WB_CORE) ) + IF( EQ_16(st_fx->core_fx,HQ_CORE)&&(EQ_16(st_fx->last_core_fx,ACELP_CORE)||st_fx->last_core_fx==AMR_WB_CORE)) { set32_fx( st_fx->prev_env_fx, 0, SFM_N_WB ); set32_fx( st_fx->prev_normq_fx, 0, SFM_N_WB ); @@ -608,7 +606,7 @@ void core_switching_pre_dec_fx( st_fx->prev_frm_hfe2_fx = 0; st_fx->prev_stab_hfe2_fx = 0; - IF( L_sub(st_fx->output_Fs_fx,16000) > 0 ) + IF( GT_32(st_fx->output_Fs_fx,16000)) { set32_fx( st_fx->prev_coeff_out_fx, 0, L_HQ_WB_BWE ); } @@ -625,14 +623,14 @@ void core_switching_pre_dec_fx( reset_preecho_dec_fx( st_fx ); } - IF( L_sub(st_fx->core_brate_fx,FRAME_NO_DATA) == 0 ) + IF( EQ_32(st_fx->core_brate_fx,FRAME_NO_DATA)) { st_fx->VAD = 0; move16(); st_fx->m_frame_type = ZERO_FRAME; move16(); } - ELSE IF( L_sub(st_fx->core_brate_fx,SID_2k40) <= 0 ) + ELSE IF( LE_32(st_fx->core_brate_fx,SID_2k40)) { st_fx->VAD = 0; move16(); @@ -652,23 +650,23 @@ void core_switching_pre_dec_fx( test(); test(); test(); - IF( sub(st_fx->core_fx,AMR_WB_CORE) != 0 && st_fx->VAD && L_sub(st_fx->total_brate_fx,CNA_MAX_BRATE) <= 0 ) + IF( NE_16(st_fx->core_fx,AMR_WB_CORE)&&st_fx->VAD&&LE_32(st_fx->total_brate_fx,CNA_MAX_BRATE)) { st_fx->flag_cna = 1; move16(); } - ELSE IF( sub(st_fx->core_fx,AMR_WB_CORE) == 0 && st_fx->VAD && L_sub(st_fx->total_brate_fx,ACELP_8k85) <= 0 ) + ELSE IF( EQ_16(st_fx->core_fx,AMR_WB_CORE)&&st_fx->VAD&&LE_32(st_fx->total_brate_fx,ACELP_8k85)) { st_fx->flag_cna = 1; move16(); } - ELSE IF( st_fx->VAD || ( sub(st_fx->cng_type_fx,FD_CNG) == 0 && sub(st_fx->L_frame_fx,L_FRAME16k) == 0 ) ) + ELSE IF( st_fx->VAD || ( EQ_16(st_fx->cng_type_fx,FD_CNG)&&EQ_16(st_fx->L_frame_fx,L_FRAME16k))) { st_fx->flag_cna = 0; move16(); } - if( sub(st_fx->core_fx,AMR_WB_CORE) == 0 ) + if( EQ_16(st_fx->core_fx,AMR_WB_CORE)) { st_fx->cng_type_fx = LP_CNG; move16(); @@ -678,19 +676,19 @@ void core_switching_pre_dec_fx( test(); test(); test(); - IF( st_fx->hFdCngDec_fx && ((sub(st_fx->last_L_frame_fx,st_fx->L_frame_fx) != 0) || - (sub(st_fx->hFdCngDec_fx->hFdCngCom->frameSize,st_fx->L_frame_fx)!=0) || - st_fx->ini_frame_fx == 0 || sub(st_fx->bwidth_fx, st_fx->last_bwidth_fx) != 0)) + IF( st_fx->hFdCngDec_fx && ((NE_16(st_fx->last_L_frame_fx,st_fx->L_frame_fx))|| + (NE_16(st_fx->hFdCngDec_fx->hFdCngCom->frameSize,st_fx->L_frame_fx)) || + st_fx->ini_frame_fx == 0 || NE_16(st_fx->bwidth_fx, st_fx->last_bwidth_fx) )) { - IF( sub(st_fx->core_fx,AMR_WB_CORE) != 0 ) + IF( NE_16(st_fx->core_fx,AMR_WB_CORE)) { Word32 tmp; tmp = st_fx->total_brate_fx; move32(); test(); - if( sub(st_fx->rf_flag,1) == 0 && L_sub(st_fx->total_brate_fx,ACELP_13k20) == 0 ) + if( EQ_16(st_fx->rf_flag,1)&&EQ_32(st_fx->total_brate_fx,ACELP_13k20)) { tmp = ACELP_9k60; move32(); @@ -710,14 +708,14 @@ void core_switching_pre_dec_fx( test(); test(); - IF ( sub(st_fx->last_L_frame_fx,st_fx->L_frame_fx) != 0 && sub(st_fx->L_frame_fx,L_FRAME16k) <= 0 && sub(st_fx->last_L_frame_fx,L_FRAME16k) <= 0 ) + IF ( NE_16(st_fx->last_L_frame_fx,st_fx->L_frame_fx)&&LE_16(st_fx->L_frame_fx,L_FRAME16k)&&LE_16(st_fx->last_L_frame_fx,L_FRAME16k)) { lerp( st_fx->hFdCngDec_fx->hFdCngCom->olapBufferSynth2, st_fx->hFdCngDec_fx->hFdCngCom->olapBufferSynth2, st_fx->L_frame_fx*2, st_fx->last_L_frame_fx*2 ); test(); - IF( L_sub(st_fx->total_brate_fx,SID_2k40) <= 0 && L_sub(st_fx->last_total_brate_fx,SID_2k40) <= 0 ) + IF( LE_32(st_fx->total_brate_fx,SID_2k40)&&LE_32(st_fx->last_total_brate_fx,SID_2k40)) { lerp( st_fx->hFdCngDec_fx->hFdCngCom->olapBufferSynth, st_fx->hFdCngDec_fx->hFdCngCom->olapBufferSynth, st_fx->L_frame_fx*2, st_fx->last_L_frame_fx*2 ); - IF( sub(st_fx->L_frame_fx, L_FRAME) == 0 ) + IF( EQ_16(st_fx->L_frame_fx, L_FRAME)) { Word16 n; FOR( n=0; n < st_fx->L_frame_fx*2; n++ ) @@ -769,7 +767,7 @@ void core_switching_post_dec_fx( *Qsynth=add(*Qsynth,tmp); test(); - IF( sub(st_fx->core_fx, ACELP_CORE) == 0 && st_fx->bfi_fx ) + IF( EQ_16(st_fx->core_fx, ACELP_CORE)&&st_fx->bfi_fx) { acelp_core_switch_dec_bfi_fx( st_fx, st_fx->fer_samples_fx, coder_type ); /*the output at Q0*/ } @@ -780,7 +778,7 @@ void core_switching_post_dec_fx( delta = 1; move16(); - if ( sub(output_frame, L_FRAME16k) >= 0) + if ( GE_16(output_frame, L_FRAME16k)) { delta = shr(Fs_kHz, 3); } @@ -788,7 +786,7 @@ void core_switching_post_dec_fx( /* set delay compensation between HQ synthesis and ACELP synthesis */ delay_comp = i_mult2(delta, HQ_DELAY_COMP); - IF( sub(st_fx->core_fx, HQ_CORE) == 0 ) + IF( EQ_16(st_fx->core_fx, HQ_CORE)) { st_fx->use_acelp_preq = 0; move16(); @@ -803,13 +801,13 @@ void core_switching_post_dec_fx( test(); test(); test(); - IF ( core_switching_flag && sub(st_fx->last_L_frame_fx, st_fx->last_L_frame_ori_fx) == 0 && ( sub(st_fx->last_core_fx, ACELP_CORE) == 0 || sub(st_fx->last_core_fx, AMR_WB_CORE) == 0 )) + IF ( core_switching_flag && EQ_16(st_fx->last_L_frame_fx, st_fx->last_L_frame_ori_fx)&&(EQ_16(st_fx->last_core_fx,ACELP_CORE)||EQ_16(st_fx->last_core_fx,AMR_WB_CORE))) { acelp_core_switch_dec_fx( st_fx, synth_subfr_out, synth_subfr_bwe, output_frame, core_switching_flag, mem_synth, &Qsubfr ); } test(); test(); - IF( core_switching_flag && sub(st_fx->last_core_fx, HQ_CORE) == 0 && st_fx->prev_bfi_fx ) + IF( core_switching_flag && EQ_16(st_fx->last_core_fx, HQ_CORE)&&st_fx->prev_bfi_fx) { Copy( st_fx->delay_buf_out_fx, synth_subfr_out, delay_comp ); Qsubfr=st_fx->Q_old_postdec; @@ -840,12 +838,12 @@ void core_switching_post_dec_fx( test(); test(); test(); - IF ( core_switching_flag && sub(st_fx->last_L_frame_fx, st_fx->last_L_frame_ori_fx) == 0 && ( sub(st_fx->last_core_fx, ACELP_CORE) == 0 || sub(st_fx->last_core_fx, AMR_WB_CORE) == 0 )) + IF ( core_switching_flag && EQ_16(st_fx->last_L_frame_fx, st_fx->last_L_frame_ori_fx)&&(EQ_16(st_fx->last_core_fx,ACELP_CORE)||EQ_16(st_fx->last_core_fx,AMR_WB_CORE))) { /* mem_over_hp_fx : Qsubfr */ core_switching_OLA_fx( mem_synth, st_fx->last_L_frame_fx, st_fx->output_Fs_fx, synth, synth_subfr_out, synth_subfr_bwe, output_frame, st_fx->bwidth_fx, Qsynth, &Qsubfr ); } - ELSE IF ( core_switching_flag && sub(st_fx->last_core_fx, HQ_CORE) == 0 && st_fx->prev_bfi_fx ) /* HQ | ACELP | TRANSITION with ACELP frame lost */ + ELSE IF ( core_switching_flag && EQ_16(st_fx->last_core_fx, HQ_CORE)&&st_fx->prev_bfi_fx) /* HQ | ACELP | TRANSITION with ACELP frame lost */ { /* Overlapp between old->out (stocked in st_fx->fer_samples)and good HQ frame on L/2 */ ptmp1 = &synth[delay_comp]; @@ -867,8 +865,8 @@ void core_switching_post_dec_fx( tmpF = add(tmpF, tmp); } } - ELSE IF ( ( !core_switching_flag && sub(st_fx->core_fx, HQ_CORE) == 0 && (sub(st_fx->last_core_fx, ACELP_CORE) == 0 || sub(st_fx->last_core_fx,AMR_WB_CORE) == 0) ) /* ACELP | TRANSITION | HQ with TRANSITION lost */ - || (core_switching_flag && st_fx->prev_bfi_fx && sub(st_fx->last_L_frame_fx, st_fx->last_L_frame_ori_fx) != 0) ) + ELSE IF ( ( !core_switching_flag && EQ_16(st_fx->core_fx, HQ_CORE)&&(EQ_16(st_fx->last_core_fx,ACELP_CORE)||EQ_16(st_fx->last_core_fx,AMR_WB_CORE))) /* ACELP | TRANSITION | HQ with TRANSITION lost */ + || (core_switching_flag && st_fx->prev_bfi_fx && NE_16(st_fx->last_L_frame_fx, st_fx->last_L_frame_ori_fx) ) ) { /* Overlapp between CELP estimation (BFI) and good HQ frame on L/2 */ shift = i_mult2(Fs_kHz, 10); @@ -889,7 +887,7 @@ void core_switching_post_dec_fx( } st_fx->bwe_non_lin_prev_scale_fx = L_deposit_l(0); - IF ( !(sub(inner_frame_tbl[st_fx->bwidth_fx], L_FRAME16k) == 0 && L_sub(st_fx->core_brate_fx, HQ_32k) == 0 ) ) + IF ( !(EQ_16(inner_frame_tbl[st_fx->bwidth_fx], L_FRAME16k)&&EQ_32(st_fx->core_brate_fx,HQ_32k))) { set32_fx( st_fx->prev_env_fx, 0, SFM_N_WB ); set32_fx( st_fx->prev_normq_fx, 0, SFM_N_WB ); @@ -902,7 +900,7 @@ void core_switching_post_dec_fx( } ELSE { - IF ( sub(st_fx->last_core_fx, HQ_CORE) == 0 ) /* MDCT to ACELP transition */ + IF ( EQ_16(st_fx->last_core_fx, HQ_CORE)) /* MDCT to ACELP transition */ { Qtmp = s_min(s_min(*Qsynth, st_fx->Q_old_postdec), st_fx->Q_old_wtda); @@ -963,23 +961,23 @@ void core_switching_post_dec_fx( test(); test(); test(); - IF(st_fx->bws_cnt_fx == 0 || (st_fx->bws_cnt_fx > 0 && sub(coder_type, INACTIVE) != 0 && sub(coder_type,AUDIO) != 0)) + IF(st_fx->bws_cnt_fx == 0 || (st_fx->bws_cnt_fx > 0 && NE_16(coder_type, INACTIVE)&&NE_16(coder_type,AUDIO))) { st_fx->attenu_fx = 3277; move16(); } - IF( ( sub(st_fx->last_extl_fx, SWB_BWE) != 0 && sub(st_fx->extl_fx, SWB_BWE) == 0 ) || ( sub(st_fx->last_extl_fx, FB_BWE) != 0 && sub(st_fx->extl_fx, FB_BWE) == 0 ) || - ((sub(st_fx->last_core_fx, HQ_CORE) == 0 || sub(st_fx->last_extl_fx, SWB_TBE) == 0) && st_fx->extl_fx < 0 && sub(st_fx->core_fx, HQ_CORE) != 0) - || (sub(st_fx->last_core_fx,ACELP_CORE) == 0 && sub(st_fx->core_fx,ACELP_CORE) == 0 - && ((sub(st_fx->prev_coder_type_fx,INACTIVE) != 0 && sub(coder_type,INACTIVE) == 0) || (sub(st_fx->prev_coder_type_fx,AUDIO) != 0 && sub(coder_type,AUDIO) == 0)) + IF( ( NE_16(st_fx->last_extl_fx, SWB_BWE)&&EQ_16(st_fx->extl_fx,SWB_BWE))||(NE_16(st_fx->last_extl_fx,FB_BWE)&&EQ_16(st_fx->extl_fx,FB_BWE))|| + ((EQ_16(st_fx->last_core_fx, HQ_CORE) || EQ_16(st_fx->last_extl_fx, SWB_TBE) ) && st_fx->extl_fx < 0 && NE_16(st_fx->core_fx, HQ_CORE) ) + || (EQ_16(st_fx->last_core_fx,ACELP_CORE) && EQ_16(st_fx->core_fx,ACELP_CORE) + && ((NE_16(st_fx->prev_coder_type_fx,INACTIVE) && EQ_16(coder_type,INACTIVE) ) || (NE_16(st_fx->prev_coder_type_fx,AUDIO) && EQ_16(coder_type,AUDIO) )) && st_fx->bws_cnt_fx > 0) ) { set16_fx( st_fx->L_old_wtda_swb_fx, 0, output_frame ); st_fx->old_wtda_swb_fx_exp = 0; move16(); - if( sub(st_fx->last_extl_fx, WB_BWE) != 0 ) + if( NE_16(st_fx->last_extl_fx, WB_BWE)) { st_fx->prev_mode_fx = NORMAL; move16(); @@ -1002,12 +1000,12 @@ void core_switching_post_dec_fx( /* reset WB BWE buffers */ test(); - IF( sub(st_fx->last_extl_fx, WB_BWE) != 0 && sub(st_fx->extl_fx, WB_BWE) == 0 ) + IF( NE_16(st_fx->last_extl_fx, WB_BWE)&&EQ_16(st_fx->extl_fx,WB_BWE)) { set16_fx(st_fx->L_old_wtda_swb_fx, 0, output_frame); test(); - if ( sub(st_fx->last_extl_fx, SWB_BWE) != 0 && sub(st_fx->last_extl_fx, FB_BWE) != 0 ) + if ( NE_16(st_fx->last_extl_fx, SWB_BWE)&&NE_16(st_fx->last_extl_fx,FB_BWE)) { st_fx->prev_mode_fx = NORMAL; move16(); @@ -1037,11 +1035,11 @@ void core_switching_post_dec_fx( test(); test(); test(); - IF( (( sub(st_fx->extl_fx, SWB_TBE) == 0 || sub(st_fx->extl_fx, FB_TBE) == 0 || sub(st_fx->extl_fx, SWB_CNG) == 0) && - ( sub(st_fx->L_frame_fx, st_fx->last_L_frame_fx) != 0 || ( sub(st_fx->last_extl_fx, SWB_TBE) != 0 && sub(st_fx->last_extl_fx, FB_TBE) != 0 ) || sub(st_fx->last_core_fx, HQ_CORE) == 0 )) || - ( sub(st_fx->bwidth_fx, st_fx->last_bwidth_fx) < 0 && sub(st_fx->last_extl_fx, SWB_TBE) != 0 ) || st_fx->old_ppp_mode_fx - || ((sub(st_fx->prev_coder_type_fx, AUDIO) == 0 || sub(st_fx->prev_coder_type_fx, INACTIVE) == 0) && st_fx->bws_cnt_fx > 0) - || (st_fx->bws_cnt_fx == 0 && sub(st_fx->prev_bws_cnt_fx, N_WS2N_FRAMES) == 0) ) + IF( (( EQ_16(st_fx->extl_fx, SWB_TBE)||EQ_16(st_fx->extl_fx,FB_TBE)||EQ_16(st_fx->extl_fx,SWB_CNG))&& + ( NE_16(st_fx->L_frame_fx, st_fx->last_L_frame_fx) || ( NE_16(st_fx->last_extl_fx, SWB_TBE) && NE_16(st_fx->last_extl_fx, FB_TBE) ) || EQ_16(st_fx->last_core_fx, HQ_CORE) )) || + ( LT_16(st_fx->bwidth_fx, st_fx->last_bwidth_fx) && NE_16(st_fx->last_extl_fx, SWB_TBE) ) || st_fx->old_ppp_mode_fx + || ((EQ_16(st_fx->prev_coder_type_fx, AUDIO) || EQ_16(st_fx->prev_coder_type_fx, INACTIVE) ) && st_fx->bws_cnt_fx > 0) + || (st_fx->bws_cnt_fx == 0 && EQ_16(st_fx->prev_bws_cnt_fx, N_WS2N_FRAMES)) ) { swb_tbe_reset_fx( st_fx->mem_csfilt_fx, st_fx->mem_genSHBexc_filt_down_shb_fx, st_fx->state_lpc_syn_fx, st_fx->syn_overlap_fx, st_fx->state_syn_shbexc_fx, &(st_fx->tbe_demph_fx), &(st_fx->tbe_premph_fx) @@ -1050,16 +1048,16 @@ void core_switching_post_dec_fx( set16_fx( st_fx->GainShape_Delay, 0, NUM_SHB_SUBFR/2 ); swb_tbe_reset_synth_fx( st_fx->genSHBsynth_Hilbert_Mem_fx, st_fx->genSHBsynth_state_lsyn_filt_shb_local_fx ); - IF( sub(output_frame, L_FRAME16k) == 0 ) + IF( EQ_16(output_frame, L_FRAME16k)) { /* reset in case that SWB TBE layer is transmitted, but the output is 16kHz sampled */ set16_fx( st_fx->mem_resamp_HB_32k_fx, 0, 2*ALLPASSSECTIONS_STEEP+1 ); } set16_fx(st_fx->int_3_over_2_tbemem_dec_fx, 0, INTERP_3_2_MEM_LEN); } - ELSE IF( ( sub(st_fx->extl_fx, SWB_TBE) == 0 || sub(st_fx->extl_fx, FB_TBE) == 0 ) && - ( L_sub(st_fx->last_total_brate_fx, st_fx->total_brate_fx) != 0 || sub(st_fx->last_bwidth_fx, st_fx->bwidth_fx) != 0 || - sub(st_fx->last_codec_mode, MODE1) != 0 || sub(st_fx->rf_flag, st_fx->rf_flag_last) != 0 ) ) + ELSE IF( ( EQ_16(st_fx->extl_fx, SWB_TBE)||EQ_16(st_fx->extl_fx,FB_TBE))&& + ( NE_32(st_fx->last_total_brate_fx, st_fx->total_brate_fx) || NE_16(st_fx->last_bwidth_fx, st_fx->bwidth_fx) || + NE_16(st_fx->last_codec_mode, MODE1) || NE_16(st_fx->rf_flag, st_fx->rf_flag_last) ) ) { set16_fx( st_fx->state_lpc_syn_fx, 0, LPC_SHB_ORDER ); set16_fx( st_fx->state_syn_shbexc_fx, 0, L_SHB_LAHEAD ); @@ -1073,7 +1071,7 @@ void core_switching_post_dec_fx( test(); test(); test(); - IF(L_sub(st_fx->output_Fs_fx,48000)==0 && ( (L_sub(st_fx->last_core_brate_fx,SID_2k40)>0 ) && (L_sub(st_fx->core_brate_fx,FRAME_NO_DATA)==0 || L_sub(st_fx->core_brate_fx,SID_2k40)==0)) ) + IF(EQ_32(st_fx->output_Fs_fx,48000)&&((GT_32(st_fx->last_core_brate_fx,SID_2k40))&&(EQ_32(st_fx->core_brate_fx,FRAME_NO_DATA)||EQ_32(st_fx->core_brate_fx,SID_2k40)))) { set16_fx( st_fx->interpol_3_2_cng_dec_fx, 0, INTERP_3_2_MEM_LEN ); } @@ -1081,7 +1079,7 @@ void core_switching_post_dec_fx( /* reset FB TBE buffers */ test(); test(); - IF( sub(st_fx->extl_fx, FB_TBE) == 0 && ( sub(st_fx->last_extl_fx, FB_TBE) != 0 || sub(st_fx->L_frame_fx, st_fx->last_L_frame_fx) != 0 ) ) + IF( EQ_16(st_fx->extl_fx, FB_TBE)&&(NE_16(st_fx->last_extl_fx,FB_TBE)||NE_16(st_fx->L_frame_fx,st_fx->last_L_frame_fx))) { set16_fx( st_fx->fb_state_lpc_syn_fx, 0, LPC_SHB_ORDER ); st_fx->fb_tbe_demph_fx = 0; @@ -1090,7 +1088,7 @@ void core_switching_post_dec_fx( /* reset WB TBE buffers */ test(); - IF( sub(st_fx->last_extl_fx, WB_TBE) != 0 && sub(st_fx->extl_fx, WB_TBE) == 0 ) + IF( NE_16(st_fx->last_extl_fx, WB_TBE)&&EQ_16(st_fx->extl_fx,WB_TBE)) { wb_tbe_extras_reset_fx( st_fx->mem_genSHBexc_filt_down_wb2_fx, st_fx->mem_genSHBexc_filt_down_wb3_fx ); wb_tbe_extras_reset_synth_fx( st_fx->state_lsyn_filt_shb_fx, st_fx->state_lsyn_filt_dwn_shb_fx, st_fx->state_32and48k_WB_upsample_fx, st_fx->mem_resamp_HB_fx ); @@ -1119,22 +1117,22 @@ void core_switching_hq_prepare_dec_fx( Word32 cbrate; test(); - IF( sub(st_fx->last_core_fx, HQ_CORE) == 0 && st_fx->prev_bfi_fx ) + IF( EQ_16(st_fx->last_core_fx, HQ_CORE)&&st_fx->prev_bfi_fx) { Copy_Scale_sig( st_fx->old_out_fx, st_fx->fer_samples_fx, output_frame, negate(st_fx->Q_old_wtda) ); /*Q0*/ } /* set switching frame bit-rate */ - IF( sub(st_fx->last_L_frame_fx, L_FRAME) == 0 ) + IF( EQ_16(st_fx->last_L_frame_fx, L_FRAME)) { cbrate = L_add(st_fx->core_brate_fx, 0); - if( L_sub(st_fx->core_brate_fx, ACELP_24k40) > 0 ) + if( GT_32(st_fx->core_brate_fx, ACELP_24k40)) { cbrate = L_add(ACELP_24k40, 0); } /* subtract ACELP switching frame bits */ - if( L_sub(st_fx->core_brate_fx, ACELP_11k60) >= 0 ) + if( GE_32(st_fx->core_brate_fx, ACELP_11k60)) { (*num_bits) = sub((*num_bits), 1); /* LP_FLAG bit */ } @@ -1144,11 +1142,11 @@ void core_switching_hq_prepare_dec_fx( } ELSE /* L_frame_fx == L_FRAME16k */ { - IF( L_sub(st_fx->core_brate_fx, ACELP_8k00) <= 0 ) + IF( LE_32(st_fx->core_brate_fx, ACELP_8k00)) { cbrate = L_add(ACELP_8k00, 0); } - ELSE IF( L_sub(st_fx->core_brate_fx, ACELP_14k80) <= 0 ) + ELSE IF( LE_32(st_fx->core_brate_fx, ACELP_14k80)) { cbrate = L_add(ACELP_14k80, 0); } @@ -1158,7 +1156,7 @@ void core_switching_hq_prepare_dec_fx( } /* subtract ACELP switching frame bits */ - if( L_sub(st_fx->core_brate_fx, ACELP_11k60) >= 0 ) + if( GE_32(st_fx->core_brate_fx, ACELP_11k60)) { (*num_bits) = sub((*num_bits), 1); /* LP_FLAG bit */ } @@ -1170,7 +1168,7 @@ void core_switching_hq_prepare_dec_fx( /* subtract BWE bits */ test(); test(); - IF( !( ( sub(inner_frame_tbl_fx[st_fx->bwidth_fx], L_FRAME16k) == 0 && sub(st_fx->last_L_frame_fx, L_FRAME16k) == 0 ) || sub(inner_frame_tbl_fx[st_fx->bwidth_fx], L_FRAME8k) == 0 ) ) + IF( !( ( EQ_16(inner_frame_tbl_fx[st_fx->bwidth_fx], L_FRAME16k)&&EQ_16(st_fx->last_L_frame_fx,L_FRAME16k))||EQ_16(inner_frame_tbl_fx[st_fx->bwidth_fx],L_FRAME8k))) { *num_bits = sub((*num_bits), (NOOFGAINBITS1 + AUDIODELAYBITS)); } diff --git a/lib_dec/d_gain2p.c b/lib_dec/d_gain2p.c index 8fba70020a6718b6295f3ed5df392b06e8c99942..cdb3d969b6a5e6a6dba1590d1937a076c33b8714 100644 --- a/lib_dec/d_gain2p.c +++ b/lib_dec/d_gain2p.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ /*-------------------------------------------------------------------* @@ -10,8 +10,6 @@ #include "prot_fx.h" #include "basop_util.h" #include "stl.h" -#include "wmc_auto.h" - #include "rom_com_fx.h" @@ -93,7 +91,7 @@ static void Mode2_gain_dec_mless( t_qua_gain = E_ROM_qua_gain5b_const; } - if(sub(coder_type,1) == 0) + if(EQ_16(coder_type,1)) { t_qua_gain = E_ROM_qua_gain6b_const; } @@ -337,22 +335,22 @@ void decode_acelp_gains( index = **pt_indice; (*pt_indice)++; - IF ( s_and(gains_mode > 0, sub(gains_mode, 4) < 0) ) + IF ( s_and(gains_mode > 0,(Word16) LT_16(gains_mode, 4))) { /* ACELP gains quantizer (5bits/subfr) */ Mode2_gain_dec_mless(index, code, L_subfr, gain_pit, gain_code, mean_ener_code, past_gpit, past_gcode, gain_inov, gains_mode-1 ); } - ELSE IF (s_or(sub(gains_mode,4) == 0, sub(gains_mode,5) == 0)) + ELSE IF (s_or((Word16)EQ_16(gains_mode,4),(Word16)EQ_16(gains_mode,5))) { /* AMR-WB gains quantizer (6bits/subfr (mode 2) or 7bits/subfr (mode 3)) */ assert(0); } - ELSE IF ( sub(gains_mode,6) == 0) + ELSE IF ( EQ_16(gains_mode,6)) { /* UV gains quantizer (6bits/subfr) */ gain_dec_uv( index, code, L_subfr, gain_pit, gain_code, past_gpit, past_gcode, gain_inov ); } - ELSE IF (sub(gains_mode,7) == 0) + ELSE IF (EQ_16(gains_mode,7)) { /* GACELP_UV gains quantizer (7=5-2bits/subfr) */ gain_dec_gacelp_uv( index, code, code2, mean_ener_code, L_subfr, gain_pit, gain_code, gain_code2, past_gpit, past_gcode, gain_inov ); @@ -386,19 +384,19 @@ void d_gain_pred( *Es_pred = 0; move16(); - if( sub(nrg_mode,1) == 0 ) + if( EQ_16(nrg_mode,1)) { *Es_pred = Es_pred_qua[indice]; move16(); } - if( sub(nrg_mode,2) == 0 ) + if( EQ_16(nrg_mode,2)) { *Es_pred = Es_pred_qua_2[indice]; move16(); } - IF( sub(nrg_mode,2) > 0 ) + IF( GT_16(nrg_mode,2)) { move16(); *Es_pred= extract_l(L_mac(-335544320l/* -20.f Q24*/, indice, 224/* 1.75f Q7*/)); /*(Q8 - ((Q0*Q7)=Q8))*/ diff --git a/lib_dec/dec2t32_fx.c b/lib_dec/dec2t32_fx.c index f64fd89d99ac06166d6ab24734ed942cdb5a0160..47922260c099ac3b729f4f44e35102ae086670a0 100644 --- a/lib_dec/dec2t32_fx.c +++ b/lib_dec/dec2t32_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "cnst_fx.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*==========================================================================*/ @@ -112,7 +110,7 @@ void dec_acelp_1t64_fx( sgn = -512; move16(); - IF( sub(pos,L_SUBFR) >= 0) + IF( GE_16(pos,L_SUBFR)) { pos = sub(pos, L_SUBFR); move16(); diff --git a/lib_dec/dec4t64_fx.c b/lib_dec/dec4t64_fx.c index 6f96281abd46cd6ed33b862e46ebd0a5e97439b9..ba9a73c851fa5ac2f7bbf357154ffbe5660cadf0 100644 --- a/lib_dec/dec4t64_fx.c +++ b/lib_dec/dec4t64_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -8,8 +8,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "assert.h" /* Static table prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*-------------------------------------------------------------------* * Local functions @@ -135,7 +133,7 @@ void dec_acelp_4t64_fx( move16(); } - IF (sub(nbbits,20) == 0) + IF (EQ_16(nbbits,20)) { FOR (k=0; k>pulse_pos_num;*/ j = L_shr((*code_index) , pulse_pos_num); - IF(L_sub(j,PI_select_table_fx[16][pulse_pos_num]) < 0) + IF(LT_32(j,PI_select_table_fx[16][pulse_pos_num])) { k = L_deposit_l(0); mn9 = L_add(j, 0); @@ -637,7 +635,7 @@ static Word32 fcb_decode_class_all_p_fx( /* o: The index of pulse positions { L_tmp = L_deposit_l(0); L_tmp1 = L_add(j, 0); - WHILE(L_sub(L_tmp1,PI_select_table_fx[16][pulse_pos_num]) >= 0) + WHILE(GE_32(L_tmp1,PI_select_table_fx[16][pulse_pos_num])) { L_tmp = L_add(L_tmp,1); L_tmp1 = L_sub(L_tmp1,PI_select_table_fx[16][pulse_pos_num]); @@ -648,7 +646,7 @@ static Word32 fcb_decode_class_all_p_fx( /* o: The index of pulse positions /* mn9 = Mult_32_32(sub(j , k) , PI_select_table_fx[16][pulse_pos_num]);*/ test(); - IF ( (sub( pulse_pos_num,pulse_num) < 0 ) && ( sub(pulse_pos_num,1) > 0 ) ) + IF ( (LT_16( pulse_pos_num,pulse_num))&&(GT_16(pulse_pos_num,1))) { FOR (i=0; i= k; l+=2); - if (L_sub(k,PI_select_table_fx[L_sub(17,l)][temp]) > 0) + if (GT_32(k,PI_select_table_fx[L_sub(17,l)][temp])) { l = L_sub(l,1); } @@ -781,7 +779,7 @@ void D_ACELP_decode_43bit(UWord16 idxs[], Word16 code[], Word16 *pulsestrack) ps[2] = L_add(L_shl(s_and(idxs[1], 3), 7), L_shr(idxs[0], 9)); joint_index = L_shr(L_add(L_shl((Word32) idxs[2], 16), (Word32) idxs[1]), 2); - if (L_sub(joint_index, joint_offset) >= 0) + if (GE_32(joint_index, joint_offset)) { joint_index = L_sub(joint_index, joint_offset); } diff --git a/lib_dec/dec_LPD.c b/lib_dec/dec_LPD.c index 8db82ad5c00673d7c55b81d72d54ef3479ff4306..396db52bb05569006737a2ab27448de4ac18a25a 100644 --- a/lib_dec/dec_LPD.c +++ b/lib_dec/dec_LPD.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ @@ -11,8 +11,6 @@ #include "rom_com_fx.h" #include "options.h" #include "stl.h" -#include "wmc_auto.h" - /* #if defined(_WIN32) && (_MSC_VER <= 1200) /\* disable global optimizations to overcome an internal compiler error *\/ */ #if defined(_MSC_VER) && (_MSC_VER <= 1200) /* disable global optimizations to overcome an internal compiler error */ @@ -85,7 +83,7 @@ void decoder_LPD( test(); test(); - if(st->use_partial_copy && sub(st->rf_frame_type, RF_TCXFD) >= 0 && sub(st->rf_frame_type, RF_TCXTD2) <= 0) + if(st->use_partial_copy && GE_16(st->rf_frame_type, RF_TCXFD)&&LE_16(st->rf_frame_type,RF_TCXTD2)) { bfi = st->bfi_fx; move16(); @@ -147,8 +145,8 @@ void decoder_LPD( move16(); tcx_current_overlap_mode = st->tcx_cfg.tcx_curr_overlap_mode; move16(); - dec_prm( coder_type, param, param_lpc, total_nbbits, st, L_frame, bitsRead ); - IF(!st->rate_switching_init && sub((st->last_codec_mode), MODE2) == 0 && st->BER_detect) + dec_prm(coder_type, param, param_lpc, total_nbbits, st, L_frame, bitsRead); + IF(!st->rate_switching_init && EQ_16((st->last_codec_mode), MODE2)&&st->BER_detect) { *coder_type = st->last_coder_type_fx; move16(); @@ -176,12 +174,12 @@ void decoder_LPD( test(); test(); - IF( st->use_partial_copy && sub(st->rf_frame_type, RF_TCXFD) >= 0 && sub(st->rf_frame_type, RF_TCXTD2) <= 0 ) + IF( st->use_partial_copy && GE_16(st->rf_frame_type, RF_TCXFD)&&LE_16(st->rf_frame_type,RF_TCXTD2)) { dec_prm( coder_type, param, param_lpc, total_nbbits, st, L_frame, bitsRead ); } - if (sub(st->nbLostCmpt, 1) > 0) + if (GT_16(st->nbLostCmpt, 1)) { st->flagGuidedAcelp = 0; move16(); @@ -197,7 +195,7 @@ void decoder_LPD( IF ( bfi == 0 ) { - IF( sub(st->prev_bfi_fx, 1)==0 ) + IF( EQ_16(st->prev_bfi_fx, 1)) { st->prev_nbLostCmpt = st->nbLostCmpt; move16(); @@ -219,16 +217,16 @@ void decoder_LPD( test(); test(); test(); - IF( (bfi == 0 ) || ( bfi != 0 && st->use_partial_copy != 0 && sub(st->rf_frame_type,RF_TCXFD) == 0) ) + IF( (bfi == 0 ) || ( bfi != 0 && st->use_partial_copy != 0 && EQ_16(st->rf_frame_type,RF_TCXFD))) { test(); test(); test(); test(); test(); - IF(sub(st->use_partial_copy,1)==0 && ( sub(st->rf_frame_type, RF_TCXFD) < 0 || sub(st->rf_frame_type, RF_TCXTD2) > 0)) + IF(EQ_16(st->use_partial_copy,1)&&(LT_16(st->rf_frame_type,RF_TCXFD)||GT_16(st->rf_frame_type,RF_TCXTD2))) { - IF( sub((Word16)st->envWeighted,1)==0 ) + IF( EQ_16((Word16)st->envWeighted,1)) { Copy( st->lspold_uw, st->lsp_old_fx, M ); Copy( st->lsfold_uw, st->lsf_old_fx, M ); @@ -268,9 +266,9 @@ void decoder_LPD( lsp_diff = L_add(lsp_diff,(Word32)abs_s(sub(lsp[i+M],lsp[i]))); } - IF( sub(st->core_fx,ACELP_CORE) == 0 && sub(st->last_core_fx,ACELP_CORE) == 0 - && L_sub(lsp_diff, 52428 ) < 0 && L_sub(lsp_diff,3932) >0 && sub(st->next_coder_type,GENERIC ) == 0 - && !st->prev_use_partial_copy && sub(st->last_coder_type_fx,UNVOICED) == 0 && sub(st->rf_frame_type,RF_GENPRED) >= 0 ) + IF( EQ_16(st->core_fx,ACELP_CORE)&&EQ_16(st->last_core_fx,ACELP_CORE) + && LT_32(lsp_diff, 52428 )&>_32(lsp_diff,3932)&&EQ_16(st->next_coder_type,GENERIC) + && !st->prev_use_partial_copy && EQ_16(st->last_coder_type_fx,UNVOICED) && GE_16(st->rf_frame_type,RF_GENPRED) ) { Copy( &lsp[0], &lsp[M], M ); } @@ -286,10 +284,10 @@ void decoder_LPD( } } ELSE - IF ((st->enableTcxLpc !=0 && sub(st->core_fx , ACELP_CORE)!= 0) || (bfi && st->use_partial_copy && st->rf_frame_type == RF_TCXFD)) + IF ((st->enableTcxLpc !=0 && NE_16(st->core_fx , ACELP_CORE))||(bfi&&st->use_partial_copy&&st->rf_frame_type==RF_TCXFD)) { Word16 tcx_lpc_cdk; - IF(bfi && st->use_partial_copy && sub(st->rf_frame_type, RF_TCXFD) == 0) + IF(bfi && st->use_partial_copy && EQ_16(st->rf_frame_type, RF_TCXFD)) { tcx_lpc_cdk = tcxlpc_get_cdk(GENERIC); } @@ -323,7 +321,7 @@ void decoder_LPD( st->envWeighted = 0; move16(); } - IF (sub(st->core_fx, TCX_20_CORE) == 0) + IF (EQ_16(st->core_fx, TCX_20_CORE)) { lpc_unquantize( st, st->lsf_old_fx, st->lsp_old_fx, lsf, lsp, M, st->lpcQuantization, param_lpc, st->numlpc, st->core_fx, st->mem_MA_fx, st->mem_AR_fx, lspmid, lsfmid, AUDIO, st->acelp_cfg.midLpc, st->narrowBand, &(st->seed_acelp), @@ -334,8 +332,8 @@ void decoder_LPD( lpc_unquantize( st, st->lsf_old_fx, st->lsp_old_fx, lsf, lsp, M, st->lpcQuantization, param_lpc, st->numlpc, st->core_fx, st->mem_MA_fx, st->mem_AR_fx, lspmid, lsfmid, *coder_type, st->acelp_cfg.midLpc, st->narrowBand, &(st->seed_acelp), st->sr_core, &st->mid_lsf_int_fx, st->prev_bfi_fx, &LSF_Q_prediction, &st->safety_net_fx ); - IF(sub(st->prev_use_partial_copy,1)==0 && sub(st->last_core_fx,ACELP_CORE) == 0 && sub(st->core_fx,ACELP_CORE) == 0 - && sub(st->prev_rf_frame_type, RF_GENPRED) >= 0 && sub(*coder_type,UNVOICED) == 0 ) + IF(EQ_16(st->prev_use_partial_copy,1)&&EQ_16(st->last_core_fx,ACELP_CORE)&&EQ_16(st->core_fx,ACELP_CORE) + && GE_16(st->prev_rf_frame_type, RF_GENPRED) && EQ_16(*coder_type,UNVOICED) ) { IF ( st->lpcQuantization && st->acelp_cfg.midLpc ) { @@ -375,12 +373,12 @@ void decoder_LPD( st->numlpc = 2; move16(); test(); - if ( st->tcxonly == 0 || sub(st->core_fx, TCX_10_CORE) < 0 ) + if ( st->tcxonly == 0 || LT_16(st->core_fx, TCX_10_CORE)) { move16(); st->numlpc = 1; } - IF(sub(st->nbLostCmpt,1)==0) + IF(EQ_16(st->nbLostCmpt,1)) { Copy(st->lsf_old_fx, st->old_lsf_q_cng, M); Copy(st->lsp_old_fx, st->old_lsp_q_cng, M); @@ -450,7 +448,7 @@ void decoder_LPD( IF(st->enablePlcWaveadjust) { - if(sub(st->core_fx, ACELP_CORE) == 0) + if(EQ_16(st->core_fx, ACELP_CORE)) { st->tonality_flag = 0; move16(); @@ -468,7 +466,7 @@ void decoder_LPD( test(); test(); test(); - IF( (st->prev_bfi_fx!=0) && (bfi==0) && (sub(*coder_type,VOICED)==0) && sub(st->prev_nbLostCmpt,4)>0 ) + IF( (st->prev_bfi_fx!=0) && (bfi==0) && (EQ_16(*coder_type,VOICED))&>_16(st->prev_nbLostCmpt,4)) { st->dec_glr_idx = 1; move16(); @@ -504,10 +502,10 @@ void decoder_LPD( test(); test(); test(); - IF( (bfi == 0) && ((sub(st->dec_glr_idx, 1) == 0) || ((st->safety_net_fx==0) && (shr(enr_new,11) > 0) && (sub(shr(enr_new,1),enr_old)>0))) && (st->prev_bfi_fx != 0 ) ) + IF( (bfi == 0) && ((EQ_16(st->dec_glr_idx, 1))||((st->safety_net_fx==0)&&(shr(enr_new,11)>0)&&(GT_16(shr(enr_new,1),enr_old))))&&(st->prev_bfi_fx!=0)) { Word16 reset_q = 0; - if( sub(st->dec_glr_idx, 1) == 0 ) + if( EQ_16(st->dec_glr_idx, 1)) { reset_q = 1; move16(); @@ -529,7 +527,7 @@ void decoder_LPD( IF (st->prev_bfi_fx) { /* check if LSP interpolation can be relaxed */ - IF ( sub(enr_new, shr(enr_old, 2)) < 0 ) + IF ( LT_16(enr_new, shr(enr_old, 2))) { st->relax_prev_lsf_interp_fx = -1; move16(); @@ -537,7 +535,7 @@ void decoder_LPD( test(); test(); test(); - if ( sub(st->clas_dec, UNVOICED_CLAS) == 0 || sub(st->clas_dec, SIN_ONSET) == 0 || sub(st->clas_dec, INACTIVE_CLAS) == 0 || sub(*coder_type, GENERIC) == 0 || sub(*coder_type, TRANSITION) == 0 ) + if ( EQ_16(st->clas_dec, UNVOICED_CLAS)||EQ_16(st->clas_dec,SIN_ONSET)||EQ_16(st->clas_dec,INACTIVE_CLAS)||EQ_16(*coder_type,GENERIC)||EQ_16(*coder_type,TRANSITION)) { st->relax_prev_lsf_interp_fx = 1; move16(); @@ -549,7 +547,7 @@ void decoder_LPD( test(); test(); test(); - if (st->stab_fac_fx == 0 && st->old_bfi_cnt_fx > 0 && sub(st->clas_dec, VOICED_CLAS) != 0 && sub(st->clas_dec, ONSET) != 0 && st->relax_prev_lsf_interp_fx == 0 ) + if (st->stab_fac_fx == 0 && st->old_bfi_cnt_fx > 0 && NE_16(st->clas_dec, VOICED_CLAS)&&NE_16(st->clas_dec,ONSET)&&st->relax_prev_lsf_interp_fx==0) { st->relax_prev_lsf_interp_fx = 2; move16(); @@ -577,7 +575,7 @@ void decoder_LPD( ELSE { /* ACELP decoder */ - IF (sub(st->L_frame_fx,L_FRAME)== 0) + IF (EQ_16(st->L_frame_fx,L_FRAME)) { Copy(Aq+2*(M+1), st->cur_sub_Aq_fx, (M+1)); } @@ -629,7 +627,7 @@ void decoder_LPD( /* LPC for ACELP/BBWE */ test(); test(); - IF( st->narrowBand || (L_sub(st->sr_core, 12800) == 0) || (L_sub(st->sr_core, 16000) == 0) ) + IF( st->narrowBand || (EQ_32(st->sr_core, 12800))||(EQ_32(st->sr_core,16000))) { Copy(Aq, st->mem_Aq, nb_subfr*(M+1)); } @@ -654,7 +652,7 @@ void decoder_LPD( * TCX20 *--------------------------------------------------------------------------------*/ - IF ( sub(st->core_fx, TCX_20_CORE) == 0 ) + IF ( EQ_16(st->core_fx, TCX_20_CORE)) { /* Set pointer to parameters */ prm = param; @@ -732,7 +730,7 @@ void decoder_LPD( * TCX10 *--------------------------------------------------------------------------------*/ - IF ( sub(st->core_fx, TCX_10_CORE) == 0 ) + IF ( EQ_16(st->core_fx, TCX_10_CORE)) { FOR (k=0; k<2; k++) { @@ -772,13 +770,13 @@ void decoder_LPD( test(); - IF (sub(st->core_fx, TCX_10_CORE) == 0 || sub(st->core_fx, TCX_20_CORE) == 0) + IF (EQ_16(st->core_fx, TCX_10_CORE)||EQ_16(st->core_fx,TCX_20_CORE)) { test(); test(); IF(st->enablePlcWaveadjust || /* bfi */ - (L_sub(st->last_total_brate_fx, HQ_48k) >= 0 && /* recovery */ - sub(st->last_codec_mode, MODE2) == 0) ) + (GE_32(st->last_total_brate_fx, HQ_48k) && /* recovery */ + EQ_16(st->last_codec_mode, MODE2) ) ) { /* waveform adjustment */ concealment_signal_tuning_fx( bfi, st->core_fx, @@ -788,7 +786,7 @@ void decoder_LPD( test(); test(); test(); - IF ((bfi || st->prev_bfi_fx) && st->plcInfo.Pitch_fx && (sub(st->plcInfo.concealment_method, TCX_NONTONAL) == 0)) + IF ((bfi || st->prev_bfi_fx) && st->plcInfo.Pitch_fx && (EQ_16(st->plcInfo.concealment_method, TCX_NONTONAL))) { lerp( synthFB, synth, L_frame, L_frameTCX ); test(); @@ -806,12 +804,12 @@ void decoder_LPD( } decoder_tcx_post( st, synth, synthFB, Aq, bfi ); - IF (sub(st->core_fx, TCX_20_CORE) == 0) + IF (EQ_16(st->core_fx, TCX_20_CORE)) { /* LPC Interpolation for BBWE/post-processing */ test(); test(); - IF( st->narrowBand || (L_sub(st->sr_core, 12800) == 0) || (L_sub(st->sr_core, 16000) == 0) ) + IF( st->narrowBand || (EQ_32(st->sr_core, 12800))||(EQ_32(st->sr_core,16000))) { int_lsp_fx( L_frame, st->lspold_uw, xspnew_uw, Aq, M, interpol_frac_fx, 0 ); Copy(Aq, st->mem_Aq, nb_subfr*(M+1)); @@ -821,12 +819,12 @@ void decoder_LPD( /* PLC: [Common: Classification] */ - IF( L_sub( st->sr_core, 16000) <= 0 ) + IF( LE_32( st->sr_core, 16000)) { test(); test(); test(); - IF ( sub(st->core_fx, TCX_20_CORE) == 0 || sub(st->core_fx, TCX_10_CORE) == 0 || (st->tcxonly && st->bfi_fx) ) + IF ( EQ_16(st->core_fx, TCX_20_CORE)||EQ_16(st->core_fx,TCX_10_CORE)||(st->tcxonly&&st->bfi_fx)) { Word16 pitch_C[NB_SUBFR16k]; Word16 core_ext_mode, LTP_Gain; @@ -884,7 +882,7 @@ void decoder_LPD( *--------------------------------------------------------------------------------*/ test(); - IF( bfi && sub(st->last_core_bfi , ACELP_CORE) != 0 ) + IF( bfi && NE_16(st->last_core_bfi , ACELP_CORE)) { /* Update FEC_scale_syn parameters */ IF(st->tcxltp_gain == 0) @@ -902,11 +900,11 @@ void decoder_LPD( test(); test(); - IF(!bfi && sub(st->clas_dec, VOICED_TRANSITION) >= 0 && sub(st->clas_dec, INACTIVE_CLAS) < 0) + IF(!bfi && GE_16(st->clas_dec, VOICED_TRANSITION)&<_16(st->clas_dec,INACTIVE_CLAS)) { Word16 offset; - IF(sub(st->core_fx, ACELP_CORE)==0) + IF(EQ_16(st->core_fx, ACELP_CORE)) { offset = sub(st->nb_subfr,1); offset = imult1616(offset,add(M,1)); @@ -949,7 +947,7 @@ void decoder_LPD( IF( st->tcxonly == 0 ) { /* update CNG parameters in active frames */ - IF (sub(st->bwidth_fx,NB) == 0 && st->enableTcxLpc !=0 && sub(st->core_fx , ACELP_CORE)!= 0) + IF (EQ_16(st->bwidth_fx,NB)&&st->enableTcxLpc!=0&&NE_16(st->core_fx,ACELP_CORE)) { Word16 buf[L_LP], res[L_FRAME], A[M+1], Qexc, r_l[M+1], r_h[M+1], lsptmp[M], Q_r, tmp; @@ -977,7 +975,7 @@ void decoder_LPD( /* Set 16k LSP flag for CNG buffer */ st->ho_16k_lsp_fx[st->ho_circ_ptr_fx] = 1; move16(); - if ( sub(st->L_frame_fx,L_FRAME) == 0 ) + if ( EQ_16(st->L_frame_fx,L_FRAME)) { st->ho_16k_lsp_fx[st->ho_circ_ptr_fx] = 0; move16(); diff --git a/lib_dec/dec_ace.c b/lib_dec/dec_ace.c index 45c9a1836a8b88345a5ae6b2973709bc0b07ac97..2c34618c628f514ce2d141d1aa623ae32d945d70 100644 --- a/lib_dec/dec_ace.c +++ b/lib_dec/dec_ace.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ /*BASOp version info: This file is up to date with trunk rev. 39929 */ @@ -11,8 +11,6 @@ #include "prot_fx.h" #include "basop_util.h" #include "stl.h" -#include "wmc_auto.h" - /*-------------------------------------------------------------------* * decoder_acelp() @@ -107,7 +105,7 @@ void decoder_acelp( prev_gain_pit = 0; tmp_noise = 0; - IF(sub(st->nb_subfr,4)==0) + IF(EQ_16(st->nb_subfr,4)) { move16(); move16(); @@ -138,7 +136,7 @@ void decoder_acelp( move16(); test(); test(); - if (st->last_con_tcx && (sub(st->L_frameTCX_past, st->L_frame_fx) != 0) && (st->last_core_fx != 0)) + if (st->last_con_tcx && (NE_16(st->L_frameTCX_past, st->L_frame_fx))&&(st->last_core_fx!=0)) { avoid_lpc_burst_on_recovery = 1; move16(); @@ -162,7 +160,7 @@ void decoder_acelp( /* Update of synthesis filter memories in case of 12k8 core */ test(); test(); - IF ( st->prev_bfi_fx && st->last_con_tcx && sub(st->L_frame_fx, L_FRAME16k) < 0 ) + IF ( st->prev_bfi_fx && st->last_con_tcx && LT_16(st->L_frame_fx, L_FRAME16k)) { synth_mem_updt2( st->L_frame_fx, L_FRAME16k, st->old_exc_fx, st->mem_syn_r, st->mem_syn2_fx, NULL, DEC ); } @@ -174,10 +172,10 @@ void decoder_acelp( /* rescale excitation buffer if LPC energies differs too much */ enr_LP = Enr_1_Az_fx( A, L_SUBFR ); - IF(sub(st->old_enr_LP, enr_LP) < 0) + IF(LT_16(st->old_enr_LP, enr_LP)) { ratio = div_s(st->old_enr_LP,enr_LP); /* Q15 */ - IF (sub(ratio, 26215) < 0) + IF (LT_16(ratio, 26215)) { FOR (i = 0; i < L_EXC_MEM_DEC; i++) { @@ -209,7 +207,7 @@ void decoder_acelp( * Fast recovery flag *------------------------------------------------------------------------*/ test(); - if(st->prev_bfi_fx && sub(coder_type,VOICED)==0) + if(st->prev_bfi_fx && EQ_16(coder_type,VOICED)) { /*Force BPF to be applied fully*/ st->bpf_gain_param=3; @@ -251,7 +249,7 @@ void decoder_acelp( { test(); - IF( sub(st->use_partial_copy,1)== 0 && sub(st->rf_frame_type,RF_NELP) == 0 ) + IF( EQ_16(st->use_partial_copy,1)&&EQ_16(st->rf_frame_type,RF_NELP)) { IF( i_subfr == 0 ) { @@ -269,7 +267,7 @@ void decoder_acelp( *-------------------------------------------------------*/ test(); - IF( sub(st->use_partial_copy,1)== 0 && st->acelp_cfg.gains_mode[i_subfr/L_SUBFR] == 0 ) + IF( EQ_16(st->use_partial_copy,1)&&st->acelp_cfg.gains_mode[i_subfr/L_SUBFR]==0) { gain_pit = prev_gain_pit; } @@ -305,9 +303,9 @@ void decoder_acelp( } /* find pitch excitation */ test(); - IF( sub(st->pit_res_max,6) == 0 && !(st->use_partial_copy) ) + IF( EQ_16(st->pit_res_max,6)&&!(st->use_partial_copy)) { - IF ( sub(T0_res, shr(st->pit_res_max, 1)) == 0) + IF ( EQ_16(T0_res, shr(st->pit_res_max, 1))) { pred_lt4( &exc[i_subfr], &exc[i_subfr], T0, shl(T0_frac,1), L_SUBFR+1, pitch_inter6_2, PIT_L_INTERPOL6_2, PIT_UP_SAMP6 ); } @@ -318,7 +316,7 @@ void decoder_acelp( } ELSE { - IF ( sub(T0_res, shr(st->pit_res_max, 1)) == 0) + IF ( EQ_16(T0_res, shr(st->pit_res_max, 1))) { pred_lt4( &exc[i_subfr], &exc[i_subfr], T0, shl(T0_frac,1), L_SUBFR+1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); } @@ -332,7 +330,7 @@ void decoder_acelp( lp_flag = acelp_cfg.ltf_mode; move16(); - IF( sub(acelp_cfg.ltf_mode, NORMAL_OPERATION) == 0 ) + IF( EQ_16(acelp_cfg.ltf_mode, NORMAL_OPERATION)) { lp_flag = *prm; move16(); @@ -367,10 +365,10 @@ void decoder_acelp( test(); test(); test(); - IF( sub(st->use_partial_copy,1)==0 && - ( sub(st->rf_frame_type,RF_ALLPRED) == 0 || - ( sub(st->rf_frame_type,RF_GENPRED) == 0 && - ( sub(i_subfr,L_SUBFR) == 0 || sub(i_subfr,3*L_SUBFR) == 0 )) ) ) + IF( EQ_16(st->use_partial_copy,1)&& + ( EQ_16(st->rf_frame_type,RF_ALLPRED) || + ( EQ_16(st->rf_frame_type,RF_GENPRED) && + ( EQ_16(i_subfr,L_SUBFR) || EQ_16(i_subfr,3*L_SUBFR) )) ) ) { set16_fx(code, 0, L_SUBFR); } @@ -390,7 +388,7 @@ void decoder_acelp( * - Generate Gaussian excitation * *-------------------------------------------------------*/ test(); - IF( sub(acelp_cfg.gains_mode[i_subfr/L_SUBFR],7)==0 && !st->use_partial_copy ) + IF( EQ_16(acelp_cfg.gains_mode[i_subfr/L_SUBFR],7)&&!st->use_partial_copy) { gaus_L2_dec( code2, st->tilt_code_fx, p_A, acelp_cfg.formant_enh_num, &(st->seed_acelp) ); } @@ -424,7 +422,7 @@ void decoder_acelp( IF( st->igf != 0 ) { /* Rescaling for 12.8k and 16k cores related to BWE */ - IF ( sub(st->L_frame_fx, L_FRAME) == 0 ) + IF ( EQ_16(st->L_frame_fx, L_FRAME)) { /* 5/2 times resampled past memories*/ reScaleLen_fx = add(shl(i_subfr, 1), shr(i_subfr, 1)); @@ -476,14 +474,14 @@ void decoder_acelp( { gain_code_pre = 0; } - IF ( sub(st->core_fx,ACELP_CORE) == 0 && sub(st->last_core_fx,ACELP_CORE) == 0 && ( sub(st->use_partial_copy,1) == 0|| sub(st->prev_use_partial_copy, 1) == 0)) + IF ( EQ_16(st->core_fx,ACELP_CORE)&&EQ_16(st->last_core_fx,ACELP_CORE)&&(EQ_16(st->use_partial_copy,1)||EQ_16(st->prev_use_partial_copy,1))) { - IF( i_subfr > 0 && sub(gain_pit,20152) > 0 && sub(st->prev_tilt_code_dec_fx,6553) > 0 && sub(st->next_coder_type,VOICED) == 0 - &&( sub(st->use_partial_copy,1) == 0 || sub(st->prev_use_partial_copy, 1) ==0 ) ) + IF( i_subfr > 0 && GT_16(gain_pit,20152)&>_16(st->prev_tilt_code_dec_fx,6553)&&EQ_16(st->next_coder_type,VOICED) + &&( EQ_16(st->use_partial_copy,1) || EQ_16(st->prev_use_partial_copy, 1) ) ) { gain_pit = mult(gain_pit,sub(26214, mult(i_subfr,51))); } - ELSE IF( !st->prev_use_partial_copy && sub(st->last_coder_type_fx,UNVOICED) == 0 && sub(st->next_coder_type,UNVOICED) != 0 && L_sub(gain_code,gain_code_pre)< 0) + ELSE IF( !st->prev_use_partial_copy && EQ_16(st->last_coder_type_fx,UNVOICED)&&NE_16(st->next_coder_type,UNVOICED)&<_32(gain_code,gain_code_pre)) { gain_code = 0; @@ -507,9 +505,9 @@ void decoder_acelp( Ltmp2 = Mpy_32_16_1(gain_code, code[i]); Ltmp2 = L_shl(Ltmp2, add(5,st->Q_exc)); Ltmp = L_add(Ltmp, Ltmp2); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF Ltmp = L_shl(Ltmp, 1); /* saturation can occur here */ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON exc[i + i_subfr] = round_fx(Ltmp); } tmp2 = L_SUBFR; @@ -580,7 +578,7 @@ void decoder_acelp( * - update pitch lag for guided ACELP * *----------------------------------------------------------*/ test(); - if( st->enableGplc && sub( shr(i_subfr,6), sub(st->nb_subfr,1) )==0 ) + if( st->enableGplc && EQ_16( shr(i_subfr,6), sub(st->nb_subfr,1) )) { st->T0_4th = T0; move16(); @@ -694,7 +692,7 @@ void decoder_acelp( test(); test(); test(); - IF ( (sub(st->clas_dec,ONSET) == 0) || ((sub(st->last_good_fx,VOICED_TRANSITION) >= 0) && (sub(st->last_good_fx,INACTIVE_CLAS) < 0)) ) + IF ( (EQ_16(st->clas_dec,ONSET))||((GE_16(st->last_good_fx,VOICED_TRANSITION))&&(LT_16(st->last_good_fx,INACTIVE_CLAS)))) { force_scale_syn = 1; move16(); diff --git a/lib_dec/dec_acelp.c b/lib_dec/dec_acelp.c index d660aaa30bdf1320b8dedeb5bf988506c41e168a..7e3b97fc666f13703129853cc0c80a7bd4105422 100644 --- a/lib_dec/dec_acelp.c +++ b/lib_dec/dec_acelp.c @@ -1,12 +1,10 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include #include #include "stl.h" -#include "wmc_auto.h" - #include "basop_util.h" #include "prot_fx.h" #include "rom_com_fx.h" @@ -133,7 +131,7 @@ void D_ACELP_indexing( cast16(); } - IF (sub(config.bits, 43) == 0) + IF (EQ_16(config.bits, 43)) { D_ACELP_decode_43bit(idxs, code, pulsestrack); } @@ -168,7 +166,7 @@ void D_ACELP_indexing( move16(); /* safety check in case of bit errors */ - IF( L_sub(s,pulsestostates[16][pulses-1]) >= 0 ) + IF( GE_32(s,pulsestostates[16][pulses-1])) { set16_fx( code, 0, L_SUBFR ); *BER_detect = 1; @@ -205,7 +203,7 @@ static void D_ACELP_decode_arithtrack(Word16 v[], Word32 s, Word16 p, Word16 tra FOR(; p; p--) /* one pulse placed, so one less left */ { - IF (L_sub(s, pulsestostates[k][p-1]) < 0) + IF (LT_32(s, pulsestostates[k][p-1])) { BREAK; } @@ -263,7 +261,7 @@ void fcb_pulse_track_joint_decode(UWord16 *idxs, Word16 wordcnt, UWord32 *index_ hi_to_low[4] = 1; move16(); - if (sub(indx_flag, track_num) >= 0) + if (GE_16(indx_flag, track_num)) { hi_to_low[4] = 9; move16(); @@ -271,18 +269,18 @@ void fcb_pulse_track_joint_decode(UWord16 *idxs, Word16 wordcnt, UWord32 *index_ hi_to_low[7] = 1; move16(); - if (sub(indx_flag_2, 1) >= 0) + if (GE_16(indx_flag_2, 1)) { hi_to_low[7] = 9; move16(); } - IF (sub(indx_flag_1, track_num) >= 0) + IF (GE_16(indx_flag_1, track_num)) { - IF (sub(indx_flag, track_num) >= 0) + IF (GE_16(indx_flag, track_num)) { index = L_deposit_l(0); - IF (sub(indx_flag_2, 1) >= 0) + IF (GE_16(indx_flag_2, 1)) { FOR (track = sub(wordcnt, 1); track >= 6; track--) { diff --git a/lib_dec/dec_acelp_tcx_main.c b/lib_dec/dec_acelp_tcx_main.c index bcdb388755aa3e481fa7e33bcfbb1192d219d2db..002d8d0403d2eb38e9fb385000d0786c682faf03 100644 --- a/lib_dec/dec_acelp_tcx_main.c +++ b/lib_dec/dec_acelp_tcx_main.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ @@ -8,8 +8,6 @@ #include "stat_com.h" #include "options.h" #include "stl.h" -#include "wmc_auto.h" - #include "prot_fx.h" #include "basop_util.h" @@ -35,14 +33,14 @@ void decode_frame_type(Decoder_State_fx *st) /* Get Frame Type (NULL,SID,ACTIVE) and Frame Mode (2kbps, 4kbps,...) */ - IF (sub(st->mdct_sw, MODE1) == 0) + IF (EQ_16(st->mdct_sw, MODE1)) { st->m_frame_type = ACTIVE_FRAME; move16(); FOR (n=0; ntotal_brate_fx, FRAME_NO_DATA) == 0 ) + IF ( EQ_32(st->total_brate_fx, FRAME_NO_DATA)) { st->bwidth_fx = st->last_bwidth_fx; move16(); @@ -64,10 +62,10 @@ void decode_frame_type(Decoder_State_fx *st) } /* SID frame */ - ELSE IF ( L_sub(st->total_brate_fx, SID_2k40) == 0 ) + ELSE IF ( EQ_32(st->total_brate_fx, SID_2k40)) { st->cng_type_fx = get_next_indice_fx(st, 1); - if( sub(st->cng_type_fx, FD_CNG) != 0 ) + if( NE_16(st->cng_type_fx, FD_CNG)) { st->BER_detect = 1; } @@ -79,7 +77,7 @@ void decode_frame_type(Decoder_State_fx *st) move16(); frame_len_indicator = get_next_indice_fx(st, 1); - IF ( sub(st->bwidth_fx, NB) == 0 ) + IF ( EQ_16(st->bwidth_fx, NB)) { if( frame_len_indicator ) { @@ -111,7 +109,7 @@ void decode_frame_type(Decoder_State_fx *st) num_bits = extract_l(L_shr(L_tmp, 3)); /* Q0 */ FOR (n=0; nbwidth_fx += FrameSizeConfig[frame_size_index].bandwidth_min; } - IF (sub(st->bwidth_fx, FB) > 0) + IF (GT_16(st->bwidth_fx, FB)) { st->bwidth_fx = FB; move16(); @@ -162,7 +160,7 @@ void decode_frame_type(Decoder_State_fx *st) } test(); - IF ( sub(st->bwidth_fx, SWB) > 0 && L_sub(st->total_brate_fx, ACELP_16k40) < 0 ) + IF ( GT_16(st->bwidth_fx, SWB)&<_32(st->total_brate_fx,ACELP_16k40)) { st->bwidth_fx = SWB; move16(); @@ -188,13 +186,14 @@ void decode_frame_type(Decoder_State_fx *st) st->rate_switching_init = 0; move16(); + if( st->last_codec_mode != MODE2 || !st->BER_detect ) { /* Mode or Rate Change */ test(); test(); test(); - IF ( (sub(st->m_frame_type, ACTIVE_FRAME) == 0 || sub(st->m_frame_type, SID_FRAME) == 0) && (s_or(s_or(s_or(s_or(L_sub(st->total_brate_fx, st->last_total_brate_fx)!=0, sub(st->bwidth_fx,st->last_bwidth_fx)!=0), sub(st->last_codec_mode, MODE1) == 0), sub(st->rf_flag, st->rf_flag_last) != 0),st->force_lpd_reset)) ) + IF ( (EQ_16(st->m_frame_type, ACTIVE_FRAME)||EQ_16(st->m_frame_type,SID_FRAME))&&(s_or(s_or(s_or(s_or((Word16)NE_32(st->total_brate_fx,st->last_total_brate_fx),(Word16)NE_16(st->bwidth_fx,st->last_bwidth_fx)),(Word16)EQ_16(st->last_codec_mode,MODE1)),(Word16)NE_16(st->rf_flag,st->rf_flag_last)),st->force_lpd_reset))) { st->rate_switching_init = 1; move16(); @@ -203,17 +202,17 @@ void decode_frame_type(Decoder_State_fx *st) mode_switch_decoder_LPD( st, st->bwidth_fx, st->total_brate_fx, frame_size_index ); /* Reconf CLDFB */ - IF( sub (i_mult(st->cldfbAna_fx->no_channels,st->cldfbAna_fx->no_col), st->L_frame_fx) != 0 ) + IF( NE_16 (i_mult(st->cldfbAna_fx->no_channels,st->cldfbAna_fx->no_col), st->L_frame_fx) ) { Word16 newCldfbBands = CLDFB_getNumChannels(L_mult0(st->L_frame_fx,50)); resampleCldfb( st->cldfbAna_fx, newCldfbBands, st->L_frame_fx, 0 ); - IF ( sub (st->L_frame_fx,L_FRAME16k) <= 0 ) + IF ( LE_16(st->L_frame_fx,L_FRAME16k) ) { resampleCldfb( st->cldfbBPF_fx, newCldfbBands, st->L_frame_fx, 0 ); } } - IF ( sub(st->bwidth_fx,NB)==0 ) + IF ( EQ_16(st->bwidth_fx,NB)) { st->cldfbSyn_fx->bandsToZero = sub (st->cldfbSyn_fx->no_channels,10); } @@ -226,7 +225,7 @@ void decode_frame_type(Decoder_State_fx *st) L_tmp = st->total_brate_fx; move32(); test(); - if( sub(st->rf_flag,1) == 0 && L_sub(st->total_brate_fx,ACELP_13k20) == 0 ) + if( EQ_16(st->rf_flag,1)&&EQ_32(st->total_brate_fx,ACELP_13k20)) { L_tmp = ACELP_9k60; move32(); @@ -234,15 +233,15 @@ void decode_frame_type(Decoder_State_fx *st) configureFdCngDec( st->hFdCngDec_fx, st->bwidth_fx, L_tmp, st->L_frame_fx ); test(); test(); - IF ( (sub(st->last_L_frame_fx,st->L_frame_fx)!=0) && (sub(st->L_frame_fx,320)<=0) && (sub(st->last_L_frame_fx,320)<=0) ) + IF ( (NE_16(st->last_L_frame_fx,st->L_frame_fx))&&(LE_16(st->L_frame_fx,320))&&(LE_16(st->last_L_frame_fx,320))) { lerp( st->hFdCngDec_fx->hFdCngCom->olapBufferSynth2, st->hFdCngDec_fx->hFdCngCom->olapBufferSynth2, st->L_frame_fx*2, st->last_L_frame_fx*2 ); test(); - IF ( sub(st->m_frame_type, SID_FRAME) == 0 && sub(st->hFdCngDec_fx->hFdCngCom->frame_type_previous, ACTIVE_FRAME) != 0 ) + IF ( EQ_16(st->m_frame_type, SID_FRAME)&&NE_16(st->hFdCngDec_fx->hFdCngCom->frame_type_previous,ACTIVE_FRAME)) { lerp( st->hFdCngDec_fx->hFdCngCom->olapBufferSynth, st->hFdCngDec_fx->hFdCngCom->olapBufferSynth, st->L_frame_fx*2, st->last_L_frame_fx*2 ); - IF( sub(st->L_frame_fx, L_FRAME) == 0 ) + IF( EQ_16(st->L_frame_fx, L_FRAME)) { FOR( n=0; n < st->L_frame_fx*2; n++ ) { @@ -258,7 +257,7 @@ void decode_frame_type(Decoder_State_fx *st) } } } - IF ( sub(st->bwidth_fx,st->last_bwidth_fx)!=0 ) + IF ( NE_16(st->bwidth_fx,st->last_bwidth_fx)) { st->hFdCngDec_fx->hFdCngCom->msFrCnt_init_counter = 0; st->hFdCngDec_fx->hFdCngCom->init_old = 32767; @@ -311,7 +310,7 @@ Word16 dec_acelp_tcx_frame(Decoder_State_fx *st, start_bit_pos = st->next_bit_pos_fx; move16(); - if( sub(st->rf_flag,1) == 0 ) + if( EQ_16(st->rf_flag,1)) { start_bit_pos = sub(start_bit_pos,2); } @@ -339,7 +338,7 @@ Word16 dec_acelp_tcx_frame(Decoder_State_fx *st, test(); test(); test(); - IF( (sub(st->last_codec_mode, MODE2) == 0) && (st->BER_detect || (st->prev_bfi_fx && (sub(st->m_frame_type, ZERO_FRAME) == 0) && (sub(st->m_old_frame_type, ACTIVE_FRAME) == 0) ) ) ) + IF( (EQ_16(st->last_codec_mode, MODE2))&&(st->BER_detect||(st->prev_bfi_fx&&(EQ_16(st->m_frame_type,ZERO_FRAME))&&(EQ_16(st->m_old_frame_type,ACTIVE_FRAME))))) { /* Copy back parameters from previous frame, because there is a high risk they are corrupt * DO concealment with configuration used in previous frame */ @@ -366,7 +365,7 @@ Word16 dec_acelp_tcx_frame(Decoder_State_fx *st, test(); test(); - IF( (sub(st->bwidth_fx, st->last_bwidth_fx) != 0 ) || (sub(st->rf_flag, st->rf_flag_last) != 0) || (L_sub(st->total_brate_fx, st->last_total_brate_fx) != 0) ) + IF( (NE_16(st->bwidth_fx, st->last_bwidth_fx))||(NE_16(st->rf_flag,st->rf_flag_last))||(NE_32(st->total_brate_fx,st->last_total_brate_fx))) { st->force_lpd_reset = 1; move16(); @@ -400,7 +399,7 @@ Word16 dec_acelp_tcx_frame(Decoder_State_fx *st, } - IF ( s_and(sub(st->m_frame_type,SID_FRAME) != 0, sub(st->m_frame_type,ZERO_FRAME) != 0) ) /* test */ + IF ( s_and((Word16)NE_16(st->m_frame_type,SID_FRAME),(Word16)NE_16(st->m_frame_type,ZERO_FRAME))) /* test */ { /* -------------------------------------------------------------- */ @@ -415,7 +414,7 @@ Word16 dec_acelp_tcx_frame(Decoder_State_fx *st, ptr_bwe_exc = old_bwe_exc + PIT16k_MAX * 2; Copy( st->old_bwe_exc_fx, old_bwe_exc, PIT16k_MAX * 2 ); - IF ( sub(st->m_decodeMode, DEC_NO_FRAM_LOSS) == 0 ) + IF ( EQ_16(st->m_decodeMode, DEC_NO_FRAM_LOSS)) { decoder_LPD(pcmBuf, pcmbufFB, @@ -436,7 +435,7 @@ Word16 dec_acelp_tcx_frame(Decoder_State_fx *st, test(); test(); test(); - IF( st->rate_switching_init == 0 && sub((st->last_codec_mode), MODE2) == 0 && !(st->use_partial_copy && sub(st->rf_frame_type, RF_TCXFD) >= 0 && sub(st->rf_frame_type, RF_TCXTD2) <= 0) && sub(st->bfi_fx, 1) == 0 ) + IF( st->rate_switching_init == 0 && EQ_16((st->last_codec_mode), MODE2)&&!(st->use_partial_copy&&GE_16(st->rf_frame_type,RF_TCXFD)&&LE_16(st->rf_frame_type,RF_TCXTD2))&&EQ_16(st->bfi_fx,1)) { *concealWholeFrame = 1; move16(); @@ -447,7 +446,7 @@ Word16 dec_acelp_tcx_frame(Decoder_State_fx *st, } } - ELSE IF (sub(st->m_decodeMode, DEC_CONCEALMENT_EXT) == 0) + ELSE IF (EQ_16(st->m_decodeMode, DEC_CONCEALMENT_EXT)) { /* Decode the LPD data */ decoder_LPD( pcmBuf, @@ -469,7 +468,7 @@ Word16 dec_acelp_tcx_frame(Decoder_State_fx *st, test(); test(); test(); - IF( ( st->bfi_fx == 0 && (sub(st->prev_bfi_fx, 1) == 0 || sub(st->prev_use_partial_copy,1) == 0)) || ((sub(st->last_vbr_hw_BWE_disable_dec_fx,1) == 0) && (st->vbr_hw_BWE_disable_dec_fx == 0)) ) + IF( ( st->bfi_fx == 0 && (EQ_16(st->prev_bfi_fx, 1)||EQ_16(st->prev_use_partial_copy,1)))||((EQ_16(st->last_vbr_hw_BWE_disable_dec_fx,1))&&(st->vbr_hw_BWE_disable_dec_fx==0))) { st->bwe_non_lin_prev_scale_fx = 0; set16_fx( st->old_bwe_exc_extended_fx, 0, NL_BUFF_OFFSET ); @@ -497,11 +496,11 @@ Word16 dec_acelp_tcx_frame(Decoder_State_fx *st, /* for ACELP mode, skip core data to read TD-BWE side info */ test(); test(); - IF( (!st->bfi_fx) && sub(st->core_fx,ACELP_CORE) == 0 && st->total_brate_fx > 0) + IF( (!st->bfi_fx) && EQ_16(st->core_fx,ACELP_CORE)&&st->total_brate_fx>0) { /* target bs-position "-3": -2 as earlier "start_bit_pos -= 2;" are included in st->rf_target_bits -1 as flag-bit not considered in rf_target_bits */ - IF (sub(st->rf_flag, 1)==0) + IF (EQ_16(st->rf_flag, 1)) { get_next_indice_tmp_fx(st, start_bit_pos + num_bits - st->rf_target_bits - 3 - get_tbe_bits_fx(st->total_brate_fx, st->bwidth_fx, st->rf_flag) - st->next_bit_pos_fx); } @@ -521,7 +520,7 @@ Word16 dec_acelp_tcx_frame(Decoder_State_fx *st, ELSE { - IF ( sub(st->m_frame_type,SID_FRAME) == 0) + IF ( EQ_16(st->m_frame_type,SID_FRAME)) { FdCng_decodeSID(st->hFdCngDec_fx->hFdCngCom, st); } diff --git a/lib_dec/dec_amr_wb_fx.c b/lib_dec/dec_amr_wb_fx.c index 0bafb630efa65666070ab68bb4091ea4dc68c501..e399e96131a17686510ec439fb5b70e0295185a0 100644 --- a/lib_dec/dec_amr_wb_fx.c +++ b/lib_dec/dec_amr_wb_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -7,8 +7,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*---------------------------------------------------------------------* @@ -115,7 +113,7 @@ void decod_amr_wb_fx( * HF gain modification factors at 23.85 kbps *-----------------------------------------------------------------*/ - IF ( L_sub(st_fx->core_brate_fx,ACELP_23k85) == 0 ) + IF ( EQ_32(st_fx->core_brate_fx,ACELP_23k85)) { hf_gain_fx[shr(i_subfr,6)] = (Word16)get_next_indice_fx(st_fx, 4); } diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index 3dce8bfb2be237e359e55d8d79c3191ccbd4346d..4781d0c7d1e904b22f56827e1311b39a3bf37838 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -8,8 +8,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - #include "basop_util.h" @@ -120,7 +118,7 @@ void decod_gen_voic_fx( move16(); test(); test(); - IF( (L_sub(st_fx->core_brate_fx,ACELP_24k40) > 0 && L_sub(st_fx->core_brate_fx,ACELP_32k) <= 0) && sub(coder_type_fx,GENERIC) == 0 ) + IF( (GT_32(st_fx->core_brate_fx,ACELP_24k40)&&LE_32(st_fx->core_brate_fx,ACELP_32k))&&EQ_16(coder_type_fx,GENERIC)) { harm_flag_acelp = (Word16)get_next_indice_fx( st_fx, 1 ); } @@ -168,7 +166,7 @@ void decod_gen_voic_fx( *-----------------------------------------------------------------*/ test(); - IF( L_sub(st_fx->core_brate_fx,ACELP_24k40) > 0 && sub(coder_type_fx,INACTIVE) != 0 ) + IF( GT_32(st_fx->core_brate_fx,ACELP_24k40)&&NE_16(coder_type_fx,INACTIVE)) { gain_code_fx = 0; move16(); @@ -188,11 +186,11 @@ void decod_gen_voic_fx( * Estimate spectrum tilt and voicing *--------------------------------------------------------------*/ - IF( L_sub(st_fx->core_brate_fx,ACELP_8k00) <= 0) + IF( LE_32(st_fx->core_brate_fx,ACELP_8k00)) { gain_dec_lbr_fx( st_fx, st_fx->core_brate_fx, coder_type_fx, i_subfr_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, gc_mem, gp_mem ); } - ELSE IF( L_sub(st_fx->core_brate_fx,ACELP_32k) > 0 ) + ELSE IF( GT_32(st_fx->core_brate_fx,ACELP_32k)) { gain_dec_SQ_fx( st_fx, st_fx->core_brate_fx, coder_type_fx, i_subfr_fx, -1, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx ); } @@ -206,7 +204,7 @@ void decod_gen_voic_fx( * Transform domain contribution decoding *-----------------------------------------------------------------*/ test(); - IF( L_sub( st_fx->core_brate_fx,ACELP_24k40) > 0 && sub(coder_type_fx,INACTIVE) == 0 ) + IF( GT_32( st_fx->core_brate_fx,ACELP_24k40)&&EQ_16(coder_type_fx,INACTIVE)) { transf_cdbk_dec_fx( st_fx, st_fx->core_brate_fx, coder_type_fx, harm_flag_acelp, i_subfr_fx, -1, Es_pred_fx, gain_code_fx, &st_fx->mem_preemp_preQ_fx, &gain_preQ_fx, &norm_gain_preQ_fx, code_preQ_fx, unbits ); @@ -219,7 +217,7 @@ void decod_gen_voic_fx( * Find the total excitation *----------------------------------------------------------------------*/ - IF ( sub(L_frame_fx,L_FRAME) == 0 ) /* Rescaling for 12.8k core */ + IF ( EQ_16(L_frame_fx,L_FRAME)) /* Rescaling for 12.8k core */ { Rescale_exc( st_fx->dct_post_old_exc_fx, &exc_fx[i_subfr_fx], &bwe_exc_fx[i_subfr_fx * HIBND_ACB_L_FAC], st_fx->last_exc_dct_in_fx, L_SUBFR, L_SUBFR * HIBND_ACB_L_FAC, gain_code_fx, &(st_fx->Q_exc), st_fx->Q_subfr, exc2_fx, i_subfr_fx, coder_type_fx ); @@ -238,7 +236,7 @@ void decod_gen_voic_fx( * Add the ACELP pre-quantizer contribution *-----------------------------------------------------------------*/ - IF( L_sub(st_fx->core_brate_fx,ACELP_24k40) > 0 ) + IF( GT_32(st_fx->core_brate_fx,ACELP_24k40)) { tmp1_fx = add(15-Q_AVQ_OUT_DEC-2,st_fx->Q_exc); FOR( i = 0; i < L_SUBFR; i++ ) @@ -280,7 +278,7 @@ void decod_gen_voic_fx( *----------------------------------------------------------------*/ test(); - IF( L_sub(st_fx->core_brate_fx,ACELP_32k) > 0 || sub(coder_type_fx,INACTIVE) == 0 ) + IF( GT_32(st_fx->core_brate_fx,ACELP_32k)||EQ_16(coder_type_fx,INACTIVE)) { Copy( exc_fx+i_subfr_fx, exc2_fx+i_subfr_fx, L_SUBFR ); } @@ -398,9 +396,9 @@ void decod_gen_voic_fx( test(); test(); test(); - IF ( sub(shl_r(enratio,15-Qenratio), 8192) > 0 && /*compare with 0.25 in Q15*/ - sub(shl_r(enratio,10-Qenratio), 15360) < 0 && /*compare with 15.0 in Q10*/ - sub(shl_r(sp_enratio,15-Qsp_enratio), 4915) > 0 &&/*compare with 0.15 in Q15*/ + IF ( GT_16(shl_r(enratio,15-Qenratio), 8192)&& /*compare with 0.25 in Q15*/ + LT_16(shl_r(enratio,10-Qenratio), 15360) && /*compare with 15.0 in Q10*/ + GT_16(shl_r(sp_enratio,15-Qsp_enratio), 4915) &&/*compare with 0.15 in Q15*/ st_fx->bfi_pitch_fx < 9600 && /*Q6*/ pitch_buf_fx[ sub( NB_SUBFR16k, 1 ) ] < 9600 ) /*Q6*/ { diff --git a/lib_dec/dec_higher_acelp_fx.c b/lib_dec/dec_higher_acelp_fx.c index 7db220a9c4fa0160807b4e2f05ee4661ae490a01..388f08c0fcb9201557b88ec06bd0819946e6f657 100644 --- a/lib_dec/dec_higher_acelp_fx.c +++ b/lib_dec/dec_higher_acelp_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -7,8 +7,6 @@ #include "prot_fx.h" /* Function prototypes */ #include "rom_com_fx.h" /* Static table prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*-----------------------------------------------------------------* * Transform domain contribution decoding @@ -52,13 +50,13 @@ void transf_cdbk_dec_fx( index = (Word16)get_next_indice_fx(st_fx, G_AVQ_BITS ); - IF( sub(coder_type,INACTIVE) == 0 ) + IF( EQ_16(coder_type,INACTIVE)) { - IF( L_sub(core_brate,ACELP_64k) == 0 ) + IF( EQ_32(core_brate,ACELP_64k)) { gain16 = usdequant_fx( index, G_AVQ_MIN_INACT_64k_Q12, G_AVQ_DELTA_INACT_64k_Q12>>1 ); } - ELSE IF( L_sub(core_brate,ACELP_48k) == 0 ) + ELSE IF( EQ_32(core_brate,ACELP_48k)) { gain16 = usdequant_fx( index, G_AVQ_MIN_INACT_48k_Q12, G_AVQ_DELTA_INACT_48k_Q12>>1 ); } @@ -73,7 +71,7 @@ void transf_cdbk_dec_fx( } ELSE { - IF( L_sub(core_brate,ACELP_32k) <= 0 ) + IF( LE_32(core_brate,ACELP_32k)) { gain16 = gain_dequant_fx( index, G_AVQ_MIN_32kbps_Q15, G_AVQ_MAX_Q0, G_AVQ_BITS, &exp16 ); } @@ -117,7 +115,7 @@ void transf_cdbk_dec_fx( test(); test(); - IF( sub(coder_type,INACTIVE) == 0 || L_sub(core_brate,ACELP_32k) > 0 || harm_flag_acelp ) + IF( EQ_16(coder_type,INACTIVE)||GT_32(core_brate,ACELP_32k)||harm_flag_acelp) { qdct = 0; move16(); @@ -133,7 +131,7 @@ void transf_cdbk_dec_fx( *--------------------------------------------------------------*/ /* in extreme cases at subframe boundaries, lower the preemphasis memory to avoid a saturation */ test(); - if( (nq[7] != 0) && (sub( sub(st_fx->last_nq_preQ_fx, nq[0]), 7) > 0) ) + if( (nq[7] != 0) && (GT_16( sub(st_fx->last_nq_preQ_fx, nq[0]), 7))) { /* *mem_preemp /= 16; */ *mem_preemp = shr(*mem_preemp,4); @@ -142,8 +140,7 @@ void transf_cdbk_dec_fx( st_fx->last_nq_preQ_fx = nq[7]; move16(); - /*preemph_fx(code_preQ, FAC_PRE_AVQ_FX, L_SUBFR, mem_preemp);*/ - preemph_copy_fx( code_preQ, code_preQ, FAC_PRE_AVQ_FX, L_SUBFR, mem_preemp ); + preemph_fx( code_preQ, FAC_PRE_AVQ_FX, L_SUBFR, mem_preemp ); /*--------------------------------------------------------------* * Compute normalized prequantizer excitation gain for FEC @@ -156,7 +153,7 @@ void transf_cdbk_dec_fx( L_tmp = Dot_product12(code_preQ, code_preQ, L_SUBFR, &exp16); - IF( L_sub(L_tmp,L_shl(1,sub(30,exp16))) == 0 ) + IF( EQ_32(L_tmp,L_shl(1,sub(30,exp16)))) { /* pre-quantizer contribution is zero */ *norm_gain_preQ = 1; diff --git a/lib_dec/dec_nelp_fx.c b/lib_dec/dec_nelp_fx.c index 740a819af1a8ea9e8d634574037e42bde71838c5..eee377df1c63810b732b9867a8e36b7581d74818 100644 --- a/lib_dec/dec_nelp_fx.c +++ b/lib_dec/dec_nelp_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "cnst_fx.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*======================================================================*/ /* FUNCTION : decod_nelp_fx() */ diff --git a/lib_dec/dec_pit_exc_fx.c b/lib_dec/dec_pit_exc_fx.c index 1891fc88de4be8188341518d4d22232a87c93b2c..2e7cf74e9bce4ccb6edee0c93dad9c960a67b894 100644 --- a/lib_dec/dec_pit_exc_fx.c +++ b/lib_dec/dec_pit_exc_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -7,8 +7,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*==========================================================================*/ @@ -65,7 +63,7 @@ void dec_pit_exc_fx( Word32 L_tmp; Word16 nbits; - IF( sub(st_fx->GSC_noisy_speech_fx,1) == 0 ) + IF( EQ_16(st_fx->GSC_noisy_speech_fx,1)) { Local_BR_fx = ACELP_7k20; move16(); @@ -113,7 +111,7 @@ void dec_pit_exc_fx( * Innovation decoding *--------------------------------------------------------------*/ - IF( sub(st_fx->GSC_noisy_speech_fx,1) == 0) + IF( EQ_16(st_fx->GSC_noisy_speech_fx,1)) { inov_decode_fx( st_fx, Local_BR_fx, 0, L_FRAME, LOCAL_CT, 1, i_subfr_fx, -1, p_Aq_fx, st_fx->tilt_code_fx, *pt_pitch_fx, code_fx ); /*--------------------------------------------------------------* @@ -157,7 +155,7 @@ void dec_pit_exc_fx( gain_code16 = round_fx(L_shl(gain_code_fx,st_fx->Q_exc)); /*Q_exc*/ - IF( sub(st_fx->GSC_noisy_speech_fx,1) == 0) + IF( EQ_16(st_fx->GSC_noisy_speech_fx,1)) { Acelp_dec_total_exc( exc_fx, exc2_bidon-i_subfr_fx, gain_code16, gain_pit_fx, i_subfr_fx, code_fx ); } @@ -182,7 +180,7 @@ void dec_pit_exc_fx( } } } - IF( sub(L_subfr_fx,128) == 0) /*2*L_SUBFR*/ + IF( EQ_16(L_subfr_fx,128)) /*2*L_SUBFR*/ { p_Aq_fx += 2*(M+1); move16(); @@ -211,7 +209,7 @@ void dec_pit_exc_fx( move16(); } } - ELSE IF( sub(L_subfr_fx,256) == 0) /*4*L_SUBFR*/ + ELSE IF( EQ_16(L_subfr_fx,256)) /*4*L_SUBFR*/ { pt_pitch_fx++; *pt_pitch_fx = *(pt_pitch_fx-1); diff --git a/lib_dec/dec_post.c b/lib_dec/dec_post.c index 7e8fa93d339ff25e6383fe5621b625bfb78a40be..acd535eb15c69f67e49334a83a9fa61fd9c02607 100644 --- a/lib_dec/dec_post.c +++ b/lib_dec/dec_post.c @@ -1,14 +1,12 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include #include "options.h" #include "prot_fx.h" #include "basop_util.h" -#include "stl.h" -#include "wmc_auto.h" - /* Weighted mops computation related code */ +#include "stl.h" /* Weighted mops computation related code */ #include "rom_dec_fx.h" #include "cnst_fx.h" @@ -101,7 +99,7 @@ void nb_post_filt( IF( BER_detect == 0 ) { /* update long-term background noise energy during inactive frames */ - IF( sub(coder_type,INACTIVE) == 0 ) + IF( EQ_16(coder_type,INACTIVE)) { *psf_lp_noise = round_fx(L_mac(L_mult(31130, *psf_lp_noise), 26214 /*0.05 Q19*/, shl(tmp_noise,4))); /*Q8*Q15 + Q19*Q4 -> Q8 */ } @@ -125,7 +123,7 @@ void nb_post_filt( Copy( Synth, Pf_in, L_frame ); Copy( &Synth[L_frame - L_SYN_MEM], Pfstat->mem_pf_in, L_SYN_MEM ); /* deactivation of the post filter in case of AUDIO because it causes problems to singing sequences */ - if( sub(coder_type,AUDIO) == 0 ) + if( EQ_16(coder_type,AUDIO)) { Post_G1 = 32767; move16(); @@ -274,21 +272,21 @@ void formant_post_filt( /*default parameter for noisy speech and high bit-rates*/ - IF (sub(L_frame, L_FRAME) == 0) + IF (EQ_16(L_frame, L_FRAME)) { post_G2 = 22938/*0.7f Q15*/; move16(); - IF (L_sub(lp_noise, LP_NOISE_THRESH) < 0) + IF (LT_32(lp_noise, LP_NOISE_THRESH)) { /*Clean speech*/ - IF (L_sub(rate, ACELP_13k20) < 0) + IF (LT_32(rate, ACELP_13k20)) { /*Low rates*/ post_G1 = 26214/*0.8f Q15*/; move16(); } - ELSE IF (L_sub(rate, ACELP_24k40) < 0) + ELSE IF (LT_32(rate, ACELP_24k40)) { /*Low rates*/ @@ -305,7 +303,7 @@ void formant_post_filt( { post_G1 = 22938/*0.7f Q15*/; move16(); - if (L_sub(rate, ACELP_15k85) < 0) + if (LT_32(rate, ACELP_15k85)) { /*Low rates*/ post_G1 = 24576/*0.75f Q15*/; @@ -318,21 +316,21 @@ void formant_post_filt( post_G2 = 24904/*0.76f Q15*/; move16(); test(); - IF (L_sub(lp_noise, LP_NOISE_THRESH) >= 0) + IF (GE_32(lp_noise, LP_NOISE_THRESH)) { post_G1 = 24904/*0.76f Q15*/; } - ELSE IF (L_sub(rate, ACELP_13k20) == 0) + ELSE IF (EQ_32(rate, ACELP_13k20)) { post_G1 = 26870/*0.82f Q15*/; move16(); } - ELSE IF (L_sub(rate, ACELP_16k40) == 0) + ELSE IF (EQ_32(rate, ACELP_16k40)) { post_G1 = 26214/*0.80f Q15*/; move16(); } - ELSE IF (L_sub(rate, ACELP_24k40) == 0 || L_sub(rate, ACELP_32k) == 0) + ELSE IF (EQ_32(rate, ACELP_24k40)||EQ_32(rate,ACELP_32k)) { post_G1 = 25559/*0.78f Q15*/; move16(); @@ -428,7 +426,7 @@ static void Dec_formant_postfilt( } scale_down = 0; move16(); - if (sub(max, 16384) > 0) + if (GT_16(max, 16384)) { scale_down = 1; move16(); @@ -498,7 +496,7 @@ static void modify_pst_param( test(); - IF( sub(coder_type,INACTIVE) != 0 && sub(lp_noise, LP_NOISE_THR_FX) < 0 ) + IF( NE_16(coder_type,INACTIVE)&<_16(lp_noise,LP_NOISE_THR_FX)) { lp_noiseQ12 = shl(lp_noise, 4); /* to go from Q8 to Q12 */ @@ -607,7 +605,7 @@ static void pst_ltp( compute_ltp_l(ptr_sig_cadr, ltpdel, phase, ptr_sig_pst0, &num2_gltp, &den2_gltp, &sh_num2, &sh_den2); - IF (sub(select_ltp(num_gltp, den_gltp, sh_num, sh_den, num2_gltp, den2_gltp, sh_num2, sh_den2), 1) == 0) + IF (EQ_16(select_ltp(num_gltp, den_gltp, sh_num, sh_den, num2_gltp, den2_gltp, sh_num2, sh_den2), 1)) { /* select short filter */ temp = sub(phase, 1); @@ -650,7 +648,7 @@ static void pst_ltp( { num_gltp = shl(num_gltp, temp); /* >> (-temp) */ } - IF (sub(num_gltp, den_gltp) >= 0) + IF (GE_16(num_gltp, den_gltp)) { /* beta bounded to 1 */ gain_plt = MIN_GPLT_FX; @@ -818,7 +816,8 @@ static void search_del( return; } - L_den_int = L_add(0, L_acc); /* sets to 'L_acc' in 1 clock */ + L_den_int = L_acc; /* sets to 'L_acc' in 1 clock */ + move32(); /*---------------------------------- * Select best phase around lambda @@ -827,7 +826,8 @@ static void search_del( *----------------------------------*/ ptr_y_up = y_up; - L_den_max = L_add(0, L_den_int); /* sets to 'L_acc' in 1 clock */ + L_den_max = L_den_int; /* sets to 'L_acc' in 1 clock */ + move32(); ptr_L_den0 = L_den0; ptr_L_den1 = L_den1; ptr_h = Tab_hup_s; @@ -861,7 +861,8 @@ static void search_del( { L_acc = L_mac(L_acc, ptr_y_up[n], ptr_y_up[n]); } - L_temp0 = L_add(0, L_acc); /* sets to 'L_acc' in 1 clock (saved for den1) */ + L_temp0 = L_acc; /* sets to 'L_acc' in 1 clock (saved for den1) */ + move32(); /* den0 */ L_acc = L_mac(L_acc, ptr_y_up[0], ptr_y_up[0]); @@ -873,7 +874,7 @@ static void search_del( *ptr_L_den1 = L_acc; move32(); - IF (sub(abs_s(ptr_y_up[0]), abs_s(ptr_y_up[L_SUBFR])) > 0) + IF (GT_16(abs_s(ptr_y_up[0]), abs_s(ptr_y_up[L_SUBFR]))) { L_den_max = L_max(*ptr_L_den0, L_den_max); } @@ -922,7 +923,7 @@ static void search_del( /* sh_num = Max(sh_den, sh_ener) */ sh_num = sh_ener; move16(); - if (sub(sh_den, sh_ener) >= 0) + if (GE_16(sh_den, sh_ener)) { sh_num = sh_den; move16(); @@ -977,7 +978,8 @@ static void search_del( { num_max = num; move16(); - L_numsq_max = L_add(0, L_temp1); /* sets to 'L_temp1' in 1 clock */ + L_numsq_max = L_temp1; /* sets to 'L_temp1' in 1 clock */ + move32(); den_max = den0; move16(); ioff = 0; @@ -1009,7 +1011,8 @@ static void search_del( { num_max = num; move16(); - L_numsq_max = L_add(0, L_temp1); /* sets to 'L_temp1' in 1 clock */ + L_numsq_max = L_temp1; /* sets to 'L_temp1' in 1 clock */ + move32(); den_max = den1; move16(); ioff = 1; @@ -1025,7 +1028,7 @@ static void search_del( * test if normalized crit0[iopt] > THRESHCRIT *--------------------------------------------------*/ test(); - IF (num_max == 0 || sub(den_max, 1) <= 0) + IF (num_max == 0 || LE_16(den_max, 1)) { *num_gltp = 0; move16(); @@ -1320,7 +1323,7 @@ static void calc_st_filt( g0 = extract_h(L_shl(L_g0, 14)); /* Scale signal i of 1/A(gamma1) */ - IF (sub(g0, 1024) > 0) + IF (GT_16(g0, 1024)) { temp = div_s(1024, g0); /* temp = 2**15 / gain0 */ FOR (i = 0; i < L_SUBFR; i++) @@ -1450,10 +1453,13 @@ void scale_st( s_g_in = extract_h(L_acc); /* normalized */ /* Compute o gain */ - L_acc = L_mult0(1, abs_s(sig_out[0])); - FOR (i = 1; i < L_subfr; i++) { - L_acc = L_mac0(L_acc, 1, abs_s(sig_out[i])); + Word64 acc64 = 0; + FOR (i = 0; i < L_subfr; i++) + { + acc64 = W_mac0_16_16(acc64, 1, abs_s(sig_out[i])); + } + L_acc = W_sat_l(acc64); } IF (L_acc == 0L) { @@ -1468,7 +1474,7 @@ void scale_st( sh_g0 = add(scal_in, 1); sh_g0 = sub(sh_g0, scal_out); /* scal_in - scal_out + 1 */ - IF (sub(s_g_in, s_g_out) < 0) + IF (LT_16(s_g_in, s_g_out)) { g0 = div_s(s_g_in, s_g_out); /* s_g_in/s_g_out in Q15 */ } diff --git a/lib_dec/dec_ppp_fx.c b/lib_dec/dec_ppp_fx.c index 9418632859d846bc772546ecf70580a11d89a999..3777576460a95ea5a4f8c888ab8dbdba92c045ee 100644 --- a/lib_dec/dec_ppp_fx.c +++ b/lib_dec/dec_ppp_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include #include "options.h" /* Compilation switches */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*===================================================================*/ /* FUNCTION : void decod_ppp_fx () */ diff --git a/lib_dec/dec_prm.c b/lib_dec/dec_prm.c index 66e09c962452b27d3a701a8bd00a8d649fb5067c..69359be3a8ef7ad68954008552279358760d99a8 100644 --- a/lib_dec/dec_prm.c +++ b/lib_dec/dec_prm.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ @@ -10,8 +10,6 @@ #include #include "rom_com_fx.h" #include "stl.h" -#include "wmc_auto.h" - #include "prot_fx.h" #include "basop_util.h" @@ -25,7 +23,7 @@ static void dec_prm_hm( /* Disable HM for non-GC,VC modes */ test(); - IF (sub(st->tcx_cfg.coder_type, VOICED) != 0 && sub(st->tcx_cfg.coder_type, GENERIC) != 0) + IF (NE_16(st->tcx_cfg.coder_type, VOICED)&&NE_16(st->tcx_cfg.coder_type,GENERIC)) { prm_hm[0] = 0; move16(); @@ -46,7 +44,7 @@ static void dec_prm_hm( { tmp = 0; move16(); - if (sub(L_frame, 256) >= 0) + if (GE_16(L_frame, 256)) { tmp = 1; move16(); @@ -55,7 +53,7 @@ static void dec_prm_hm( DecodeIndex(st, tmp, &prm_hm[1]); /* Gain index */ - IF (sub(st->tcx_cfg.coder_type, VOICED) == 0) + IF (EQ_16(st->tcx_cfg.coder_type, VOICED)) { prm_hm[2] = get_next_indice_fx(st, kTcxHmNumGainBits); move16(); @@ -112,7 +110,7 @@ void dec_prm( hm_cfg.indexBuffer = indexBuffer; move16(); - IF (sub(st->mdct_sw, MODE1) == 0) + IF (EQ_16(st->mdct_sw, MODE1)) { start_bit_pos = 0; /* count from frame start */ move16(); @@ -122,7 +120,7 @@ void dec_prm( Mpy_32_16_ss(st->total_brate_fx, 5243, &L_tmp, &lsb); /* 5243 is 1/50 in Q18. (0+18-15=3) */ num_bits = extract_l(L_shr(L_tmp, 3)); /* Q0 */ assert(num_bits == st->total_brate_fx/50); - IF (sub(FrameSizeConfig[n].frame_bits, num_bits) == 0) + IF (EQ_16(FrameSizeConfig[n].frame_bits, num_bits)) { st->bits_frame_core = add(st->bits_frame_core, FrameSizeConfig[n].bandwidth_bits); BREAK; @@ -131,7 +129,7 @@ void dec_prm( } ELSE { - IF( sub(st->rf_flag,1) == 0 ) + IF( EQ_16(st->rf_flag,1)) { /*Inherent adjustment to accommodate the compact packing used in the RF mode*/ start_bit_pos = sub(st->next_bit_pos_fx,2); @@ -176,17 +174,17 @@ void dec_prm( st->clas_dec = UNVOICED_CLAS; move16(); } - ELSE IF( sub(ind, 1) == 0 ) + ELSE IF( EQ_16(ind, 1)) { st->clas_dec = UNVOICED_TRANSITION; move16(); - if( sub(st->last_good_fx, VOICED_TRANSITION) >= 0 ) + if( GE_16(st->last_good_fx, VOICED_TRANSITION)) { st->clas_dec = VOICED_TRANSITION; move16(); } } - ELSE if( sub(ind, 2) == 0 ) + ELSE if( EQ_16(ind, 2)) { st->clas_dec = VOICED_CLAS; move16(); @@ -197,7 +195,7 @@ void dec_prm( } ELSE { - IF (sub(st->mdct_sw, MODE1) == 0) + IF (EQ_16(st->mdct_sw, MODE1)) { /* 2 bits instead of 3 as TCX is already signaled */ st->core_fx = TCX_20_CORE; @@ -209,7 +207,7 @@ void dec_prm( } ELSE { - IF (sub(st->mdct_sw_enable, MODE2) == 0) + IF (EQ_16(st->mdct_sw_enable, MODE2)) { IF (get_next_indice_1_fx(st) != 0) /* TCX */ { @@ -232,7 +230,7 @@ void dec_prm( } ELSE { - IF(sub(st->rf_flag,1) == 0) + IF(EQ_16(st->rf_flag,1)) { IF( !( st->use_partial_copy ) ) { @@ -257,11 +255,11 @@ void dec_prm( move16(); *coder_type = get_next_indice_fx(st, 3); move16(); - IF ( sub(*coder_type, ACELP_MODE_MAX) >= 0) + IF ( GE_16(*coder_type, ACELP_MODE_MAX)) { st->core_fx = TCX_20_CORE; move16(); - *coder_type = sub(*coder_type,ACELP_MODE_MAX); + *coder_type=sub(*coder_type,ACELP_MODE_MAX); st->tcx_cfg.coder_type = *coder_type; move16(); } @@ -270,12 +268,12 @@ void dec_prm( } test(); - IF ( st->igf != 0 && (sub(st->core_fx, ACELP_CORE) == 0) ) + IF ( st->igf != 0 && EQ_16(st->core_fx, ACELP_CORE) ) { st->bits_frame_core = sub( st->bits_frame_core, get_tbe_bits_fx(st->total_brate_fx, st->bwidth_fx, st->rf_flag) ); } - IF( sub(st->rf_flag, 1) == 0) + IF( EQ_16(st->rf_flag,1)) { st->bits_frame_core = sub(st->bits_frame_core, add(st->rf_target_bits, 1)); /* +1 as flag-bit not considered in rf_target_bits */ } @@ -283,7 +281,7 @@ void dec_prm( /* Inactive frame detection on non-DTX mode */ st->VAD = 1; move16(); - if( sub(*coder_type, INACTIVE) == 0 ) + if( EQ_16(*coder_type, INACTIVE)) { st->VAD = 0; move16(); @@ -294,7 +292,7 @@ void dec_prm( st->core_ext_mode = *coder_type; move16(); - if( sub(*coder_type, INACTIVE) == 0 ) + if( EQ_16(*coder_type, INACTIVE)) { st->core_ext_mode = UNVOICED; move16(); @@ -305,7 +303,7 @@ void dec_prm( move16(); test(); test(); - IF( ( st->core_fx != ACELP_CORE || st->tcx_cfg.lfacNext > 0 ) && st->use_partial_copy == 0 ) + IF( ( NE_16(st->core_fx, ACELP_CORE) || st->tcx_cfg.lfacNext > 0 ) && st->use_partial_copy == 0 ) { st->last_core_bs_fx = get_next_indice_fx(st, 1); move16(); @@ -321,9 +319,8 @@ void dec_prm( { st->last_core_fx = st->last_core_bs_fx; } - - /* for TCX 10 force last_core to be TCX since ACELP as previous core is forbidden */ - IF( sub(st->core_fx, TCX_10_CORE) == 0 ) + /*for TCX 10 force last_core to be TCX since ACELP as previous core is forbidden*/ + IF( EQ_16(st->core_fx, TCX_10_CORE)) { st->last_core_fx = TCX_20_CORE; st->last_core_bs_fx = TCX_20_CORE; @@ -334,7 +331,7 @@ void dec_prm( test(); test(); - IF(sub(st->rf_flag, 1) == 0 && sub(st->use_partial_copy, 1) == 0 && !st->tcxonly) + IF(EQ_16(st->rf_flag,1)&&EQ_16(st->use_partial_copy,1)&&!st->tcxonly) { st->bits_frame_core = st->rf_target_bits; @@ -349,7 +346,7 @@ void dec_prm( { /* Set the last overlap mode based on the previous and current frame type and coded overlap mode */ test(); - IF ((sub(st->last_core_fx, ACELP_CORE) == 0) || (sub(st->last_core_fx, AMR_WB_CORE) == 0)) + IF ((EQ_16(st->last_core_fx, ACELP_CORE))||(EQ_16(st->last_core_fx,AMR_WB_CORE))) { st->tcx_cfg.tcx_last_overlap_mode = TRANSITION_OVERLAP; move16(); @@ -357,7 +354,7 @@ void dec_prm( ELSE { test(); - IF ((sub(st->core_fx, TCX_10_CORE) == 0) && (sub(st->tcx_cfg.tcx_curr_overlap_mode, ALDO_WINDOW) == 0)) + IF ((EQ_16(st->core_fx, TCX_10_CORE))&&(EQ_16(st->tcx_cfg.tcx_curr_overlap_mode,ALDO_WINDOW))) { st->tcx_cfg.tcx_last_overlap_mode = FULL_OVERLAP; move16(); @@ -367,7 +364,7 @@ void dec_prm( st->tcx_cfg.tcx_last_overlap_mode = st->tcx_cfg.tcx_curr_overlap_mode; move16(); test(); - if ((sub(st->core_fx, TCX_10_CORE) != 0) && (sub(st->tcx_cfg.tcx_curr_overlap_mode, FULL_OVERLAP) == 0)) + if ((NE_16(st->core_fx, TCX_10_CORE))&&(EQ_16(st->tcx_cfg.tcx_curr_overlap_mode,FULL_OVERLAP))) { st->tcx_cfg.tcx_last_overlap_mode = ALDO_WINDOW; move16(); @@ -378,7 +375,7 @@ void dec_prm( st->tcx_cfg.tcx_curr_overlap_mode = ALDO_WINDOW; move16(); - IF (sub(st->core_fx, ACELP_CORE) != 0) + IF (NE_16(st->core_fx, ACELP_CORE)) { tmp = 0; move16(); @@ -394,7 +391,7 @@ void dec_prm( test(); test(); test(); - if ((sub(st->core_fx, TCX_20_CORE) == 0) && (tmp == 0) && (sub(st->last_core_fx, ACELP_CORE) != 0) && (sub(st->last_core_fx, AMR_WB_CORE) != 0)) + if ((EQ_16(st->core_fx, TCX_20_CORE))&&(tmp==0)&&(NE_16(st->last_core_fx,ACELP_CORE))&&(NE_16(st->last_core_fx,AMR_WB_CORE))) { st->tcx_cfg.tcx_curr_overlap_mode = ALDO_WINDOW; move16(); @@ -440,7 +437,7 @@ void dec_prm( { move16(); st->dec_glr_idx = -1; - IF( sub(st->core_fx, ACELP_CORE) == 0 ) + IF( EQ_16(st->core_fx, ACELP_CORE) ) { st->dec_glr_idx = get_next_indice_fx(st, G_LPC_RECOVERY_BITS); } @@ -450,12 +447,12 @@ void dec_prm( * LPC PARAMETERS *--------------------------------------------------------------------------------*/ - /* Initialization of LPC Mid flag */ + /*Initialization of LPC Mid flag*/ st->acelp_cfg.midLpc = st->acelp_cfg.midLpc_enable; move16(); test(); test(); - IF( (sub(st->lpcQuantization, 1) == 0 && (sub(*coder_type, VOICED) == 0) ) || (st->use_partial_copy)) + IF( (EQ_16(st->lpcQuantization, 1)&&(EQ_16(*coder_type,VOICED)))||(st->use_partial_copy)) { st->acelp_cfg.midLpc = 0; move16(); @@ -467,7 +464,7 @@ void dec_prm( st->numlpc = 2; move16(); test(); - if ( st->tcxonly == 0 || sub(st->core_fx, TCX_10_CORE) < 0 ) + if ( st->tcxonly==0 || LT_16(st->core_fx, TCX_10_CORE)) { st->numlpc = 1; move16(); @@ -475,7 +472,7 @@ void dec_prm( /* Decode LPC parameters */ test(); - IF (st->enableTcxLpc && sub(st->core_fx, ACELP_CORE) != 0) + IF (st->enableTcxLpc && NE_16(st->core_fx, ACELP_CORE)) { Word16 tcx_lpc_cdk; tcx_lpc_cdk = tcxlpc_get_cdk(*coder_type); @@ -488,11 +485,11 @@ void dec_prm( decode_lpc_avq( st, st->numlpc, param_lpc ); move16(); } - ELSE IF (sub(st->lpcQuantization, 1) == 0) + ELSE IF (EQ_16(st->lpcQuantization, 1)) { test(); test(); - IF(L_sub(st->sr_core, 16000) == 0 && sub(*coder_type, VOICED) == 0 && sub(st->core_fx, ACELP_CORE) == 0) + IF(EQ_32(st->sr_core, 16000)&&EQ_16(*coder_type,VOICED)&&EQ_16(st->core_fx,ACELP_CORE)) { lsf_bctcvq_decprm(st, param_lpc); } @@ -514,7 +511,7 @@ void dec_prm( move16(); test(); - IF( sub(st->rf_frame_type, RF_TCXFD) == 0 ) + IF( EQ_16(st->rf_frame_type, RF_TCXFD)) { param_lpc[0] = 0; move16(); @@ -522,7 +519,7 @@ void dec_prm( param_lpc[2] = get_next_indice_fx(st, lsf_numbits[1]); /* VQ 2 */ param_lpc[3] = get_next_indice_fx(st, lsf_numbits[2]); /* VQ 3 */ } - ELSE IF( sub(st->rf_frame_type, RF_ALLPRED) >= 0 && sub(st->rf_frame_type, RF_NELP) <= 0 ) + ELSE IF( GE_16(st->rf_frame_type, RF_ALLPRED)&&LE_16(st->rf_frame_type,RF_NELP)) { /* LSF indices */ param_lpc[0] = get_next_indice_fx(st, 8); /* VQ 1 */ @@ -539,7 +536,7 @@ void dec_prm( *--------------------------------------------------------------------------------*/ test(); test(); - IF( sub(st->core_fx, ACELP_CORE) == 0 && st->use_partial_copy == 0 ) + IF( EQ_16(st->core_fx,ACELP_CORE)&&st->use_partial_copy==0) { /* Target Bits */ acelp_target_bits = sub(st->bits_frame_core, st->bits_common); @@ -590,7 +587,7 @@ void dec_prm( } /* Adaptive codebook filtering (1 bit) */ - IF ( sub(st->acelp_cfg.ltf_mode, 2) == 0) + IF ( EQ_16(st->acelp_cfg.ltf_mode, 2)) { prm[j++] = get_next_indice_fx(st, 1); move16(); @@ -606,7 +603,7 @@ void dec_prm( /* sanity check for testing - not instrumented */ test(); - if ( sub(st->acelp_cfg.fixed_cdk_index[sfr], ACELP_FIXED_CDK_NB) >= 0 || (st->acelp_cfg.fixed_cdk_index[sfr] < 0)) + if ( GE_16(st->acelp_cfg.fixed_cdk_index[sfr], ACELP_FIXED_CDK_NB)||(st->acelp_cfg.fixed_cdk_index[sfr]<0)) { st->acelp_cfg.fixed_cdk_index[sfr] = 0; move16(); @@ -638,7 +635,7 @@ void dec_prm( }/*end of subfr loop*/ } - ELSE IF( sub(st->rf_frame_type,RF_ALLPRED) >= 0 && st->use_partial_copy ) + ELSE IF( GE_16(st->rf_frame_type,RF_ALLPRED)&&st->use_partial_copy) { Word16 acelp_bits = BITS_ALLOC_config_acelp( st->rf_target_bits, /* target bits ranges from 56 to 72 depending on rf_type */ @@ -654,7 +651,7 @@ void dec_prm( } /* rf_frame_type NELP: 7 */ - IF(sub(st->rf_frame_type,RF_NELP) == 0) + IF(EQ_16(st->rf_frame_type,RF_NELP)) { /* NELP gain indices */ st->rf_indx_nelp_iG1 = get_next_indice_fx( st, 5 ); @@ -690,8 +687,8 @@ void dec_prm( test(); test(); test(); - IF( sub(st->rf_frame_type,RF_NOPRED) == 0 - || ( sub(st->rf_frame_type,RF_GENPRED) == 0 && (sfr == 0 || sub(sfr,2) == 0)) ) + IF( EQ_16(st->rf_frame_type,RF_NOPRED) + || ( EQ_16(st->rf_frame_type,RF_GENPRED) && (sfr == 0 || EQ_16(sfr,2) )) ) { /* NOTE: FCB actual bits need to be backed up as well */ /*n = ACELP_FIXED_CDK_BITS(st->rf_indx_fcb[fec_offset][sfr]) & 15;*/ @@ -701,7 +698,7 @@ void dec_prm( /* Gains (5b, 6b or 7b / subfr) */ test(); - IF( sfr == 0 || sub(sfr,2) == 0) + IF( sfr == 0 || EQ_16(sfr,2)) { n = ACELP_GAINS_BITS[gains_mode]; prm[j++] = get_next_indice_fx(st, n); @@ -716,7 +713,7 @@ void dec_prm( * TCX20 *--------------------------------------------------------------------------------*/ test(); - IF( sub(st->core_fx, TCX_20_CORE) == 0 && st->use_partial_copy == 0 ) + IF( EQ_16(st->core_fx, TCX_20_CORE)&&st->use_partial_copy==0) { flag_ctx_hm = 0; move16(); @@ -738,7 +735,7 @@ void dec_prm( /* LTP data */ /* PLC pitch info for HB */ test(); - IF (st->tcxltp != 0 || L_sub(st->sr_core, 25600) > 0) + IF (st->tcxltp != 0 || GT_32(st->sr_core, 25600)) { prm[j] = get_next_indice_fx(st, 1); @@ -769,7 +766,7 @@ void dec_prm( move16(); test(); - IF ((st->tcxonly == 0) && (sub(st->tcxltp_pitch_int, L_frame) < 0)) + IF ((st->tcxonly == 0) && (LT_16(st->tcxltp_pitch_int, L_frame))) { Word32 tmp32 = L_shl(L_mult0(st->L_frame_fx, st->pit_res_max), 1+kLtpHmFractionalResolution+1); Word16 tmp1 = add(imult1616(st->tcxltp_pitch_int, st->pit_res_max), st->tcxltp_pitch_fr); @@ -785,7 +782,7 @@ void dec_prm( lgFB = st->tcx_cfg.tcx_coded_lines; move16(); - IF (sub(st->last_core_bs_fx, ACELP_CORE) == 0) + IF (st->last_core_bs_fx == ACELP_CORE ) { /* ACE->TCX transition */ lg = add(lg, st->tcx_cfg.tcx_offset); @@ -813,7 +810,7 @@ void dec_prm( hm_size = shl(mult(st->TcxBandwidth, lg), 1); test(); - IF (st->tcx_lpc_shaped_ari != 0 && sub(st->last_core_bs_fx, ACELP_CORE) != 0) + IF (st->tcx_lpc_shaped_ari != 0 && NE_16(st->last_core_bs_fx, ACELP_CORE)) { dec_prm_hm(st, &prm[j], hm_size); } @@ -826,7 +823,7 @@ void dec_prm( /*Context HM flag*/ test(); - IF ( st->tcx_cfg.ctx_hm && sub(st->last_core_bs_fx, ACELP_CORE) != 0 ) + IF ( st->tcx_cfg.ctx_hm && NE_16(st->last_core_bs_fx, ACELP_CORE)) { prm[j] = get_next_indice_fx(st, 1); move16(); @@ -838,7 +835,7 @@ void dec_prm( tmp = 0; move16(); - if(sub(hm_size, 256) >= 0) + if(GE_16(hm_size, 256)) { tmp = 1; move16(); @@ -869,7 +866,7 @@ void dec_prm( n = st->next_bit_pos_fx; move16(); - IF (sub(st->last_core_bs_fx, ACELP_CORE) == 0) + IF (EQ_16(st->last_core_bs_fx, ACELP_CORE)) { IGFDecReadLevel( &st->hIGFDec, st, IGF_GRID_LB_TRAN, 1 ); IGFDecReadData( &st->hIGFDec, st, IGF_GRID_LB_TRAN, 1 ); @@ -919,7 +916,7 @@ void dec_prm( test(); test(); - IF( sub(st->rf_frame_type,RF_TCXFD) >= 0 && sub(st->rf_frame_type,RF_TCXTD2) <= 0 && sub(st->use_partial_copy,1) == 0 ) + IF( GE_16(st->rf_frame_type,RF_TCXFD)&&LE_16(st->rf_frame_type,RF_TCXTD2)&&EQ_16(st->use_partial_copy,1)) { /* classification */ ind = get_next_indice_fx(st, 2); @@ -931,9 +928,9 @@ void dec_prm( st->clas_dec = UNVOICED_CLAS; move16(); } - ELSE IF( sub(ind, 1) == 0 ) + ELSE IF( EQ_16(ind, 1)) { - IF( sub(st->last_good_fx, VOICED_TRANSITION) >= 0 ) + IF( GE_16(st->last_good_fx, VOICED_TRANSITION)) { st->clas_dec = VOICED_TRANSITION; move16(); @@ -944,13 +941,13 @@ void dec_prm( move16(); } } - ELSE IF( sub(ind, 2) == 0 ) + ELSE IF( EQ_16(ind, 2)) { st->clas_dec = VOICED_CLAS; move16(); } - IF( sub(st->rf_frame_type, RF_TCXFD) == 0 ) + IF( EQ_16(st->rf_frame_type, RF_TCXFD)) { /* TCX Gain = 7 bits */ st->old_gaintcx_bfi = get_next_indice_fx(st, 7); @@ -960,7 +957,7 @@ void dec_prm( /* LTP data */ IF( st->tcxltp != 0 ) { - IF( sub(st->rf_frame_type, RF_TCXTD2) == 0 || sub(st->rf_frame_type, RF_TCXTD1) == 0) + IF( EQ_16(st->rf_frame_type, RF_TCXTD2)||EQ_16(st->rf_frame_type,RF_TCXTD1)) { prm_ltp[0] = 1; move16(); /* LTP active*/ @@ -986,7 +983,7 @@ void dec_prm( /*--------------------------------------------------------------------------------* * TCX10 *--------------------------------------------------------------------------------*/ - IF ( sub(st->core_fx, TCX_10_CORE) == 0) + IF ( EQ_16(st->core_fx, TCX_10_CORE)) { Word16 tcxltp_prm_0 = 0; Word16 tcxltp_prm_1 = 0; @@ -1043,7 +1040,7 @@ void dec_prm( /* LTP data */ test(); test(); - IF ( (k == 0) && ((st->tcxltp != 0) || (L_sub(st->sr_core, 25600) > 0)) ) + IF ( (k == 0) && ((st->tcxltp != 0) || (GT_32(st->sr_core, 25600)))) { prm[j] = get_next_indice_fx(st, 1); move16(); @@ -1117,7 +1114,7 @@ void dec_prm( IF (st->tcx_cfg.fIsTNSAllowed) { - IF( sub(st->last_core_bs_fx, ACELP_CORE) == 0 && (k == 0)) + IF( EQ_16(st->last_core_bs_fx, ACELP_CORE)&&(k==0)) { st->BER_detect = 1; st->last_core_fx = TCX_20_CORE; move16(); @@ -1187,7 +1184,7 @@ void dec_prm( IF(!st->use_partial_copy) { - IF (sub(sub(*total_nbbits, bitsRead[0]), sub(st->next_bit_pos_fx, start_bit_pos)) < 0) + IF (LT_16(sub(*total_nbbits, bitsRead[0]), sub(st->next_bit_pos_fx, start_bit_pos))) { st->BER_detect = 1; move16(); diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c index fd13d2c376abb1bfb14ad45989fcc2fb58469ed6..1eb103d4870d58f068d682579ea75183488c0e50 100644 --- a/lib_dec/dec_tcx.c +++ b/lib_dec/dec_tcx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -8,8 +8,6 @@ #include "prot_fx.h" #include "basop_util.h" #include "stl.h" -#include "wmc_auto.h" - #include "options.h" #include "prot_fx.h" @@ -221,7 +219,7 @@ void decoder_tcx( move16(); } - IF ( frame_cnt == 0 && sub(st->last_core_bs_fx, ACELP_CORE) == 0 ) + IF ( frame_cnt == 0 && EQ_16(st->last_core_bs_fx, ACELP_CORE) ) { L_spec += st->tcx_cfg.tcx_coded_lines >> 2; } @@ -233,7 +231,7 @@ void decoder_tcx( } test(); - IF ( (sub(L_frame, shr(st->L_frame_fx, 1)) == 0) && (st->tcxonly)) + IF ( (EQ_16(L_frame, shr(st->L_frame_fx, 1)))&&(st->tcxonly)) { IGFDecUpdateInfo( &st->hIGFDec, @@ -244,7 +242,7 @@ void decoder_tcx( { test(); test(); - IF ((sub(st->last_core_fx, ACELP_CORE) == 0) || (left_rect && st->bfi_fx)) + IF ((EQ_16(st->last_core_fx, ACELP_CORE))||(left_rect&&st->bfi_fx)) { IGFDecUpdateInfo( &st->hIGFDec, @@ -382,7 +380,7 @@ void decoder_tcx( tmp8 = 1; move16(); - if (sub(st->last_core_bs_fx, ACELP_CORE) == 0) + if (EQ_16(st->last_core_bs_fx, ACELP_CORE)) { tmp8 = 0; move16(); @@ -491,7 +489,7 @@ void decoder_tcx( IF( st->use_partial_copy != 0 ) { - IF( sub(st->rf_frame_type, RF_TCXFD) == 0 ) + IF( EQ_16(st->rf_frame_type, RF_TCXFD)) { tmp32 = L_shl(L_mult0(st->old_gaintcx_bfi, 0x797D), 7); /* 6Q25; 0x797D -> log2(10)/28 (Q18) */ gain_tcx_e = add(extract_l(L_shr(tmp32, 25)), 1); /* get exponent */ @@ -587,7 +585,7 @@ void decoder_tcx( move16(); } /* not instrumenting the additional test() here seems to be common practice */ - ELSE IF (sub(TCX_20_CORE, st->core_fx)== 0 || sub(frame_cnt, 1) == 0 ) + ELSE IF (EQ_16(TCX_20_CORE, st->core_fx)||EQ_16(frame_cnt,1)) { /* gainCompensate = st->last_gain_syn_deemph/(float)sqrt(dot_product( h1, h1, L_SUBFR)); */ tmp32 = Dot_productSq16HQ( 0, h1, L_SUBFR, &gainCompensate_e)/*Q15, gainCompensate_e*/; @@ -602,7 +600,7 @@ void decoder_tcx( tmp1 = T_DIV_L_Frame[L_shl(L_mac(-28000,st->L_frame_fx,95),1-15)]; - IF (sub(st->nbLostCmpt,1)==0) + IF (EQ_16(st->nbLostCmpt,1)) { /* stepCompensate = (1.f - gainCompensate)/st->L_frame_fx; */ st->stepCompensate_e = BASOP_Util_Add_MantExp( @@ -700,7 +698,7 @@ void decoder_tcx( /* Replication of ACELP formant enhancement for low rates */ - IF (L_sub(st->total_brate_fx, ACELP_13k20) < 0 || st->rf_flag != 0 ) + IF (LT_32(st->total_brate_fx, ACELP_13k20)||st->rf_flag!=0) { tcxFormantEnhancement(xn_buf, gainlpc2, gainlpc2_e, x, &x_e, L_frame, L_frameTCX); } @@ -736,7 +734,7 @@ void decoder_tcx( tmp1 = 0; move16(); test(); - if ( sub(st->bits_frame, 256) >= 0 && st->rf_flag == 0 ) + if ( GE_16(st->bits_frame, 256)&&st->rf_flag==0) { tmp1 = 1; move16(); @@ -757,7 +755,7 @@ void decoder_tcx( } noiseTransWidth = HOLE_SIZE_FROM_LTP(s_max(st->tcxltp_gain, tmp1)); - if (sub(L_frame, shr(st->L_frame_fx, 1)) == 0) + if (EQ_16(L_frame, shr(st->L_frame_fx, 1))) { noiseTransWidth = 3; /* minimum transition fading for noise filling in TCX-10 */ move16(); } @@ -802,16 +800,16 @@ void decoder_tcx( { IF (bfi) { - IF (sub(st->nbLostCmpt, 1) == 0) + IF (EQ_16(st->nbLostCmpt, 1)) { st->plcInfo.concealment_method = TCX_NONTONAL; move16(); /* tonal/non-tonal decision */ test(); test(); - IF (0 == sub(st->plcInfo.Transient[0],1) - && 0 == sub(st->plcInfo.Transient[1], 1) - && 0 == sub(st->plcInfo.Transient[2], 1)) + IF (EQ_16(st->plcInfo.Transient[0],1) + && EQ_16(st->plcInfo.Transient[1], 1) + && EQ_16(st->plcInfo.Transient[2], 1)) { Word16 sum_word16 = 0; move16(); @@ -821,7 +819,7 @@ void decoder_tcx( sum_word16 = add(sum_word16, st->plcInfo.TCX_Tonality[i]); } - if(sub(sum_word16, 6) >= 0 ) + if(GE_16(sum_word16, 6)) { st->plcInfo.concealment_method = TCX_TONAL; move16(); @@ -835,7 +833,7 @@ void decoder_tcx( } } - if (sub(L_frameTCX, st->L_frameTCX) > 0) + if (GT_16(L_frameTCX, st->L_frameTCX)) { st->plcInfo.concealment_method = TCX_TONAL; move16(); @@ -844,14 +842,14 @@ void decoder_tcx( temp_concealment_method = st->plcInfo.concealment_method; move16(); - if (0 == sub(st->core_fx, TCX_10_CORE)) + if (EQ_16(st->core_fx, TCX_10_CORE)) { temp_concealment_method = TCX_TONAL; move16(); } } /* get the starting location of the subframe in the frame */ - IF (0 ==sub(st->core_fx, TCX_10_CORE)) + IF (EQ_16(st->core_fx, TCX_10_CORE)) { st->plcInfo.subframe_fx =extract_l( L_mult0(frame_cnt,L_frameTCX_glob)); } @@ -873,7 +871,7 @@ void decoder_tcx( ELSE { test(); - IF( !st->enablePlcWaveadjust || sub(temp_concealment_method, TCX_TONAL) == 0 ) + IF( !st->enablePlcWaveadjust || EQ_16(temp_concealment_method, TCX_TONAL)) { Word16 f, tmp; @@ -889,8 +887,8 @@ void decoder_tcx( test(); test(); - IF ( (frame_cnt == 0) && (sub(L_frameTCX, shr(st->L_frameTCX, 1)) == 0) - && (st->tcxonly) && (!st->tonal_mdct_plc_active) && (sub(st->nbLostCmpt, 1) == 0) + IF ( (frame_cnt == 0) && (EQ_16(L_frameTCX, shr(st->L_frameTCX, 1))) + && (st->tcxonly) && (!st->tonal_mdct_plc_active) && (EQ_16(st->nbLostCmpt, 1)) && (tcx_cfg->tcx_last_overlap_mode != FULL_OVERLAP) && (tcx_cfg->tcx_curr_overlap_mode != FULL_OVERLAP) ) { @@ -907,7 +905,7 @@ void decoder_tcx( test(); test(); /* replace higher energy TCX5 frame by lower one to avoid energy fluctuation */ - IF(sub(tmp1,16384 /*2 in Q13*/) > 0) + IF(GT_16(tmp1,16384 /*2 in Q13*/)) { FOR(i=0; itonalMDCTconceal.lastBlockData.spectralData[i] = st->tonalMDCTconceal.lastBlockData.spectralData[i+1]; } } - ELSE IF(sub(tmp1,4096/*0.5 in Q13*/) < 0) + ELSE IF(LT_16(tmp1,4096/*0.5 in Q13*/)) { FOR(i=0; ibits_frame, 256) >= 0 && st->rf_flag == 0) + IF( GE_16(st->bits_frame, 256)&&st->rf_flag==0) { tmp = 1; move16(); @@ -953,11 +951,11 @@ void decoder_tcx( } - IF (sub(L_spec, L_frame) < 0) + IF (LT_16(L_spec, L_frame)) { set32_fx(x+L_spec, 0, sub(L_frame,L_spec)); } - ELSE IF (sub(L_spec, L_frameTCX) > 0) + ELSE IF (GT_16(L_spec, L_frameTCX)) { set32_fx(x+L_frameTCX, 0, sub(L_spec,L_frameTCX)); } @@ -971,9 +969,9 @@ void decoder_tcx( test(); test(); test(); - IF ( bfi && (!st->enablePlcWaveadjust || sub(temp_concealment_method, TCX_TONAL) == 0) - && st->igf && (frame_cnt == 0) && (sub(L_frameTCX, shr(st->L_frameTCX, 1)) == 0) - && (st->tcxonly) && (!st->tonal_mdct_plc_active) && (sub(st->nbLostCmpt, 1) == 0) + IF ( bfi && (!st->enablePlcWaveadjust || EQ_16(temp_concealment_method, TCX_TONAL)) + && st->igf && (frame_cnt == 0) && (EQ_16(L_frameTCX, shr(st->L_frameTCX, 1))) + && (st->tcxonly) && (!st->tonal_mdct_plc_active) && (EQ_16(st->nbLostCmpt, 1)) && (tcx_cfg->tcx_last_overlap_mode != FULL_OVERLAP) && (tcx_cfg->tcx_curr_overlap_mode != FULL_OVERLAP) ) { @@ -993,7 +991,7 @@ void decoder_tcx( IF(st->igf && ! bfi) { test(); - IF ( (sub(L_frame, shr(st->L_frame_fx, 1)) == 0) && (st->tcxonly)) + IF ( (EQ_16(L_frame, shr(st->L_frame_fx, 1)))&&(st->tcxonly)) { IGFDecCopyLPCFlatSpectrum( &st->hIGFDec, @@ -1004,7 +1002,7 @@ void decoder_tcx( } ELSE { - IF (sub(st->last_core_fx, ACELP_CORE) == 0) + IF (EQ_16(st->last_core_fx, ACELP_CORE)) { IGFDecCopyLPCFlatSpectrum( &st->hIGFDec, @@ -1029,7 +1027,7 @@ void decoder_tcx( /* LPC gains already available */ test(); test(); - IF(!st->enablePlcWaveadjust || !bfi || (sub(temp_concealment_method, TCX_TONAL) == 0)) + IF(!st->enablePlcWaveadjust || !bfi || (EQ_16(temp_concealment_method, TCX_TONAL))) { x_e = add(x_e, gain_tcx_e); mdct_shaping(x, L_frame, gainlpc2, gainlpc2_e); @@ -1045,7 +1043,7 @@ void decoder_tcx( set32_fx(x+L_spec, 0, sub(L_frameTCX, L_spec)); test(); test(); - IF (( bfi != 0) && ( !st->enablePlcWaveadjust || sub(temp_concealment_method, TCX_TONAL) == 0 )) + IF (( bfi != 0) && ( !st->enablePlcWaveadjust || EQ_16(temp_concealment_method, TCX_TONAL))) { scale_sig32(x+infoIGFStartLine, sub(L_spec, infoIGFStartLine), negate(gain_tcx_e)); } @@ -1082,7 +1080,7 @@ void decoder_tcx( core = st->core_fx; move16(); /* spectrum concealment */ - IF (bfi && (sub(temp_concealment_method, TCX_NONTONAL) == 0)) + IF (bfi && (EQ_16(temp_concealment_method, TCX_NONTONAL))) { /* x_e =31-x_scale; */ concealment_decode_fix(core, x, &x_e, &st->plcInfo); @@ -1096,13 +1094,13 @@ void decoder_tcx( *-----------------------------------------------------------*/ test(); test(); - IF (st->igf && !((sub(L_frame, shr(st->L_frame_fx, 1)) == 0) && (st->tcxonly))) + IF (st->igf && !((EQ_16(L_frame, shr(st->L_frame_fx, 1)))&&(st->tcxonly))) { Word16 igfGridIdx; test(); test(); - IF ((sub(st->last_core_fx, ACELP_CORE) == 0) || (left_rect && bfi)) + IF ((EQ_16(st->last_core_fx, ACELP_CORE))||(left_rect&&bfi)) { /* packet loss after first TCX must be handled like transition frame */ igfGridIdx = IGF_GRID_LB_TRAN; @@ -1124,7 +1122,7 @@ void decoder_tcx( } test(); test(); - IF (st->igf && ((sub(L_frame, shr(st->L_frame_fx, 1)) == 0) && (st->tcxonly))) + IF (st->igf && ((EQ_16(L_frame, shr(st->L_frame_fx, 1)))&&(st->tcxonly))) { st->hIGFDec.igfData.igfInfo.nfSeed = extract_l(L_mac0(13849L, nf_seed, 31821)); IGFDecApplyMono( @@ -1170,7 +1168,7 @@ void decoder_tcx( FOR (j = startLine; j < endLine; j++) { - IF (sub(chk_sparse[j-IGF_START_MN], 2) == 0) + IF (EQ_16(chk_sparse[j-IGF_START_MN], 2)) { x_itf[j-IGF_START_MN] = x[j]; move32(); @@ -1197,7 +1195,7 @@ void decoder_tcx( FOR (j = startLine; j < endLine; j++) { - if (sub(chk_sparse[j-IGF_START_MN],2) == 0) + if (EQ_16(chk_sparse[j-IGF_START_MN],2)) { x[j] = x_itf[j-IGF_START_MN]; move32(); @@ -1207,7 +1205,7 @@ void decoder_tcx( } test(); - IF ((sub(L_frame, shr(st->L_frame_fx, 1)) == 0) && (st->tcxonly != 0)) + IF ((EQ_16(L_frame, shr(st->L_frame_fx, 1)))&&(st->tcxonly!=0)) { Word16 L = L_frameTCX; move16(); @@ -1215,7 +1213,7 @@ void decoder_tcx( test(); test(); test(); - if ((tcx_cfg->fIsTNSAllowed != 0 && fUseTns != 0 && bfi == 0) || (sub(L_spec, L_frameTCX) > 0)) + if ((tcx_cfg->fIsTNSAllowed != 0 && fUseTns != 0 && bfi == 0) || (GT_16(L_spec, L_frameTCX))) { L = L_spec; move16(); @@ -1250,7 +1248,7 @@ void decoder_tcx( ApplyTnsFilter(tcx_cfg->pCurrentTnsConfig, &tnsData, x, 0); test(); - IF ((sub(L_frame, shr(st->L_frame_fx, 1)) == 0) && (st->tcxonly != 0)) + IF ((EQ_16(L_frame, shr(st->L_frame_fx, 1)))&&(st->tcxonly!=0)) { test(); @@ -1427,7 +1425,7 @@ void decoder_tcx_post(Decoder_State_fx *st_fx, /* first TCX frame after ACELP; overwrite ltp initialization done during acelp PLC */ test(); test(); - if (!st_fx->bfi_fx && st_fx->prev_bfi_fx && sub(st_fx->last_core_fx,ACELP_CORE) == 0) + if (!st_fx->bfi_fx && st_fx->prev_bfi_fx && EQ_16(st_fx->last_core_fx,ACELP_CORE)) { st_fx->tcxltp_last_gain_unmodified = 0; move16(); @@ -1436,7 +1434,7 @@ void decoder_tcx_post(Decoder_State_fx *st_fx, { test(); /* run lpc gain compensation not for waveform adjustment */ - IF ( 0 == st_fx->enablePlcWaveadjust || sub(st_fx->plcInfo.concealment_method,TCX_TONAL) == 0 ) + IF ( 0 == st_fx->enablePlcWaveadjust || EQ_16(st_fx->plcInfo.concealment_method,TCX_TONAL)) { UWord32 dmy; tmp32_1 /*gainHelperFB*/ = L_shl_r(L_deposit_h(st_fx->gainHelper) ,sub(st_fx->gainHelper_e, 31-28));/*Q28*/ @@ -1475,11 +1473,15 @@ void decoder_tcx_post(Decoder_State_fx *st_fx, /* level_syn = (float)sqrt(( dot_product(synthFB, synthFB, L_frame)) / L_frame ); */ s = sub(getScaleFactor16(synthFB, st_fx->L_frameTCX), 4); - tmp32 = L_deposit_l(0); - FOR (i = 0; i < st_fx->L_frameTCX; i++) { - tmp1 = shl(synthFB[i], s); - tmp32 = L_mac0(tmp32, tmp1, tmp1); + Word64 tmp64 = 0; + move64(); + FOR (i = 0; i < st_fx->L_frameTCX; i++) + { + tmp1 = shl(synthFB[i], s); + tmp64 = W_mac0_16_16(tmp64, tmp1, tmp1); + } + tmp32 = W_sat_l(tmp64); } tmp32 = Mpy_32_16_1(tmp32, getInvFrameLen(st_fx->L_frameTCX)); tmp2 = norm_l(tmp32); @@ -1495,7 +1497,7 @@ void decoder_tcx_post(Decoder_State_fx *st_fx, level_syn_e = add(s,15); test(); test(); - IF (bfi == 0 && st_fx->tcxonly != 0 && sub(st_fx->clas_dec , UNVOICED_CLAS) == 0) + IF (bfi == 0 && st_fx->tcxonly != 0 && EQ_16(st_fx->clas_dec , UNVOICED_CLAS)) { Word16 Qnew_levelBackgroundTrace; @@ -1560,7 +1562,7 @@ void decoder_tcx_post(Decoder_State_fx *st_fx, } } - if ((sub(st_fx->nbLostCmpt, 1) == 0)) + if ((EQ_16(st_fx->nbLostCmpt, 1))) { st_fx->conceal_eof_gain = 16384/*1.0f Q14*/; /*Q14*/ move16(); } @@ -1599,7 +1601,7 @@ void decoder_tcx_post(Decoder_State_fx *st_fx, } st_fx->conceal_eof_gain = round_fx(conceal_eof_gain32); /*Q14*/ move16(); /* run lpc gain compensation not for waveform adjustment */ test(); - IF ( 0 == st_fx->enablePlcWaveadjust || sub(st_fx->plcInfo.concealment_method,TCX_TONAL) == 0 ) + IF ( 0 == st_fx->enablePlcWaveadjust || EQ_16(st_fx->plcInfo.concealment_method,TCX_TONAL)) { st_fx->plcInfo.recovery_gain = extract_h(L_shl(Mpy_32_16_1(conceal_eof_gainFB, st_fx->last_concealed_gain_syn_deemph), @@ -1669,7 +1671,8 @@ static Word32 CalculateAbsEnergy( /* o : normalized result Q31 */ Word32 L_sum, L_c; /* Clear carry flag and init sum */ Carry = 0; - L_c = L_add(0,0); + L_c = 0; + move32(); L_sum = L_macNs(L_off,0,0); if (L_sum > 0) L_c = L_macNs(L_c,0,0); @@ -1679,9 +1682,9 @@ static Word32 CalculateAbsEnergy( /* o : normalized result Q31 */ FOR (i=0; i < lg; i+=2) { Carry = 0; - BASOP_SATURATE_WARNING_OFF;/*multiplication of -32768 * -32768 throws an overflow, but is not critical*/ + BASOP_SATURATE_WARNING_OFF /*multiplication of -32768 * -32768 throws an overflow, but is not critical*/ L_sum = L_macNs(L_sum, x[i], x[i]); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON Overflow = 0; /* to avoid useless warning in L_macNs calling L_mult */ L_c = L_macNs(L_c,0,0); } @@ -1743,7 +1746,7 @@ static void IMDCT(Word32 *x, Word16 x_e, } test(); - IF ((sub(L_frameTCX, shr(st->L_frameTCX, 1)) == 0) && (st->tcxonly != 0)) + IF ((EQ_16(L_frameTCX, shr(st->L_frameTCX, 1)))&&(st->tcxonly!=0)) { /* Mode decision in PLC @@ -1775,7 +1778,7 @@ static void IMDCT(Word32 *x, Word16 x_e, L_win = shr(L_frame, 1); L_ola = tcx_mdct_window_half_length; move16(); - if (sub(tcx_cfg->tcx_last_overlap_mode, MIN_OVERLAP) == 0) + if (EQ_16(tcx_cfg->tcx_last_overlap_mode, MIN_OVERLAP)) { L_ola = tcx_mdct_window_min_length; move16(); @@ -1809,7 +1812,7 @@ static void IMDCT(Word32 *x, Word16 x_e, move16(); } test(); - if(w == 0 && sub(index,2) == 0) + if(w == 0 && EQ_16(index,2)) { tmp2 = MIN_OVERLAP; move16(); @@ -2031,7 +2034,7 @@ static void IMDCT(Word32 *x, Word16 x_e, { assert(frame_cnt == 0); - IF (sub(st->tcx_cfg.tcx_last_overlap_mode, TRANSITION_OVERLAP) != 0) + IF (NE_16(st->tcx_cfg.tcx_last_overlap_mode, TRANSITION_OVERLAP)) { Word32 tmp_buf[L_FRAME_PLUS]; Word16 Q; @@ -2136,7 +2139,7 @@ static void IMDCT(Word32 *x, Word16 x_e, { test(); test(); - IF (((sub(L_frameTCX, shr(st->L_frameTCX, 1)) == 0) && (st->tcxonly != 0)) || (sub(st->tcx_cfg.tcx_last_overlap_mode, TRANSITION_OVERLAP) == 0)) + IF (((EQ_16(L_frameTCX, shr(st->L_frameTCX, 1)))&&(st->tcxonly!=0))||(EQ_16(st->tcx_cfg.tcx_last_overlap_mode,TRANSITION_OVERLAP))) { test(); test(); @@ -2194,7 +2197,7 @@ static void IMDCT(Word32 *x, Word16 x_e, tmp1 = index; move16(); test(); - if ((index == 0) || (sub(tcx_cfg->tcx_last_overlap_mode, MIN_OVERLAP) == 0)) + if ((index == 0) || (EQ_16(tcx_cfg->tcx_last_overlap_mode, MIN_OVERLAP))) { tmp1 = tcx_cfg->tcx_last_overlap_mode; move16(); @@ -2233,7 +2236,7 @@ static void IMDCT(Word32 *x, Word16 x_e, xn_buf[i+tmp1] = shl(tmp2, TCX_IMDCT_HEADROOM); move16(); } - IF (sub(add(i, tmp1), L_frame) < 0) + IF (LT_16(add(i, tmp1), L_frame)) { FOR (i = add(i, tmp1); i < L_frame; i++) { @@ -2251,7 +2254,7 @@ static void IMDCT(Word32 *x, Word16 x_e, move16(); } - IF (sub(i, L_frame) < 0) + IF (LT_16(i, L_frame)) { FOR ( ; i < L_frame; i++) { @@ -2276,7 +2279,7 @@ static void IMDCT(Word32 *x, Word16 x_e, move16(); } - IF (sub(add(i, tmp1), L_frame) < 0) + IF (LT_16(add(i, tmp1), L_frame)) { FOR (i = add(i, tmp1); i < L_frame; i++) { @@ -2311,8 +2314,8 @@ static void IMDCT(Word32 *x, Word16 x_e, test(); test(); IF ( (aldo == 0) && - ((sub(L_frameTCX, shr(st->L_frameTCX, 1)) == 0 && frame_cnt > 0) || - sub(L_frameTCX, shr(st->L_frameTCX, 1)) != 0) ) + ((EQ_16(L_frameTCX, shr(st->L_frameTCX, 1)) && frame_cnt > 0) || + NE_16(L_frameTCX, shr(st->L_frameTCX, 1)) ) ) { /*Compute windowed synthesis in case of switching to ALDO windows in next frame*/ FOR (i = 0; i < nz; i++) @@ -2334,7 +2337,7 @@ static void IMDCT(Word32 *x, Word16 x_e, ); /* If current overlap mode = FULL_OVERLAP -> ALDO_WINDOW */ - IF (sub(tcx_cfg->tcx_curr_overlap_mode, FULL_OVERLAP) == 0) + IF (EQ_16(tcx_cfg->tcx_curr_overlap_mode, FULL_OVERLAP)) { FOR (i=0; iQ_exc,2) > 0 ) + IF( i_subfr == 0 && GT_16(st_fx->Q_exc,2)) { tmp16 = sub(2, st_fx->Q_exc); Scale_sig(exc_fx-L_EXC_MEM, L_EXC_MEM, tmp16); @@ -110,7 +108,7 @@ void decod_tran_fx( * Transform domain contribution decoding - active frames *-----------------------------------------------------------------*/ - IF( L_sub(st_fx->core_brate_fx,ACELP_24k40) > 0 ) + IF( GT_32(st_fx->core_brate_fx,ACELP_24k40)) { gain_code_fx = 0; move16(); @@ -138,7 +136,7 @@ void decod_tran_fx( ELSE { /* 5-bit decoding */ - IF( L_sub(st_fx->core_brate_fx,ACELP_32k) > 0 ) + IF( GT_32(st_fx->core_brate_fx,ACELP_32k)) { gain_dec_SQ_fx( st_fx, st_fx->core_brate_fx, coder_type_fx, i_subfr, tc_subfr_fx, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx ); } @@ -159,7 +157,7 @@ void decod_tran_fx( * Find the total excitation *----------------------------------------------------------------------*/ - IF ( sub(L_frame_fx,L_FRAME) == 0 ) /* Rescaling for 12.8k core */ + IF ( EQ_16(L_frame_fx,L_FRAME)) /* Rescaling for 12.8k core */ { Rescale_exc( st_fx->dct_post_old_exc_fx, &exc_fx[i_subfr], &bwe_exc_fx[i_subfr * HIBND_ACB_L_FAC], st_fx->last_exc_dct_in_fx, L_SUBFR, L_SUBFR * HIBND_ACB_L_FAC, gain_code_fx, &(st_fx->Q_exc), st_fx->Q_subfr, exc2_fx, i_subfr, coder_type_fx ); @@ -177,7 +175,7 @@ void decod_tran_fx( * Add the ACELP pre-quantizer contribution *-----------------------------------------------------------------*/ - IF( L_sub(st_fx->core_brate_fx,ACELP_24k40) > 0 ) + IF( GT_32(st_fx->core_brate_fx,ACELP_24k40)) { tmp1_fx = add(15-Q_AVQ_OUT_DEC-2,st_fx->Q_exc); FOR( i = 0; i < L_SUBFR; i++ ) @@ -205,7 +203,7 @@ void decod_tran_fx( * Excitation enhancements (update of total excitation signal) *----------------------------------------------------------------*/ - IF( L_sub(st_fx->core_brate_fx,ACELP_32k) > 0 ) + IF( GT_32(st_fx->core_brate_fx,ACELP_32k)) { Copy( exc_fx+i_subfr, exc2_fx+i_subfr, L_SUBFR ); } diff --git a/lib_dec/dec_uv.c b/lib_dec/dec_uv.c index 58bd9a15ffeeaf83d74eada405766b88cff598b3..438aa30cbbec2403133566d3f373f35b88203375 100644 --- a/lib_dec/dec_uv.c +++ b/lib_dec/dec_uv.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "cnst_fx.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*-------------------------------------------------------------------* * decod_unvoiced() @@ -39,7 +37,7 @@ void decod_unvoiced_fx( Word16 *pt_pitch_fx; test(); - IF ( sub(st_fx->last_ppp_mode_dec_fx,1) == 0 || sub(st_fx->last_nelp_mode_dec_fx,1) == 0 ) + IF ( EQ_16(st_fx->last_ppp_mode_dec_fx,1)||EQ_16(st_fx->last_nelp_mode_dec_fx,1)) { /* SC_VBR - reset the decoder, to avoid memory not updated issue for this unrealistic case */ CNG_reset_dec_fx( st_fx, pitch_buf_fx, voice_factors_fx ); diff --git a/lib_dec/decision_matrix_dec_fx.c b/lib_dec/decision_matrix_dec_fx.c index ec853c64a9681deb2b0d764d2a29993a812d95cb..9522c22ffc546ae4cb987f750826f22ecf993369 100644 --- a/lib_dec/decision_matrix_dec_fx.c +++ b/lib_dec/decision_matrix_dec_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -9,8 +9,6 @@ #include "stat_dec_fx.h" #include "rom_com_fx.h" #include "stl.h" -#include "wmc_auto.h" - /*-----------------------------------------------------------------* @@ -49,13 +47,13 @@ void decision_matrix_dec_fx( st->igf = 0; move16(); - if( L_sub(st->total_brate_fx,ACELP_8k00) > 0 ) + if( GT_32(st->total_brate_fx,ACELP_8k00)) { st->vbr_hw_BWE_disable_dec_fx = 0; move16(); } - IF (sub(st->mdct_sw, MODE2) == 0) + IF (EQ_16(st->mdct_sw, MODE2)) { st->core_fx = HQ_CORE; move16(); @@ -63,24 +61,24 @@ void decision_matrix_dec_fx( ELSE { test(); - IF( L_sub(st->total_brate_fx,FRAME_NO_DATA) == 0 || L_sub(st->total_brate_fx,SID_2k40) == 0 ) + IF( EQ_32(st->total_brate_fx,FRAME_NO_DATA)||EQ_32(st->total_brate_fx,SID_2k40)) { st->core_fx = ACELP_CORE; move16(); st->core_brate_fx = st->total_brate_fx; move32(); - IF( L_sub(st->total_brate_fx,FRAME_NO_DATA) != 0 ) + IF( NE_32(st->total_brate_fx,FRAME_NO_DATA)) { st->cng_type_fx = get_next_indice_fx( st, 1 ); - IF( sub(st->cng_type_fx,LP_CNG) == 0 ) + IF( EQ_16(st->cng_type_fx,LP_CNG)) { st->L_frame_fx = L_FRAME; move16(); tmp16 = get_next_indice_fx( st, 1 ); - if( sub(tmp16,1) == 0 ) + if( EQ_16(tmp16,1)) { st->L_frame_fx = L_FRAME16k; move16(); @@ -104,7 +102,7 @@ void decision_matrix_dec_fx( } test(); - if( L_sub(st->output_Fs_fx,32000) >= 0 && sub(st->bwidth_fx,SWB) >= 0 ) + if( GE_32(st->output_Fs_fx,32000)&&GE_16(st->bwidth_fx,SWB)) { st->extl_fx = SWB_CNG; move16(); @@ -113,7 +111,7 @@ void decision_matrix_dec_fx( test(); test(); test(); - if( L_sub(st->total_brate_fx,FRAME_NO_DATA) == 0 && st->prev_bfi_fx && !st->bfi_fx && sub(st->L_frame_fx,L_FRAME16k) > 0 ) + if( EQ_32(st->total_brate_fx,FRAME_NO_DATA)&&st->prev_bfi_fx&&!st->bfi_fx&>_16(st->L_frame_fx,L_FRAME16k)) { st->L_frame_fx = st->last_CNG_L_frame_fx; move16(); @@ -123,7 +121,7 @@ void decision_matrix_dec_fx( } /* SC-VBR */ - ELSE IF( L_sub(st->total_brate_fx,PPP_NELP_2k80) == 0 ) + ELSE IF( EQ_32(st->total_brate_fx,PPP_NELP_2k80)) { st->core_fx = ACELP_CORE; move16(); @@ -159,7 +157,7 @@ void decision_matrix_dec_fx( st->bwidth_fx = NB; move16(); } - ELSE IF( sub(ppp_nelp_mode,1) == 0 ) + ELSE IF( EQ_16(ppp_nelp_mode,1)) { st->ppp_mode_dec_fx = 1; move16(); @@ -168,7 +166,7 @@ void decision_matrix_dec_fx( st->bwidth_fx = WB; move16(); } - ELSE IF( sub(ppp_nelp_mode,2) == 0 ) + ELSE IF( EQ_16(ppp_nelp_mode,2)) { st->nelp_mode_dec_fx = 1; move16(); @@ -177,7 +175,7 @@ void decision_matrix_dec_fx( st->bwidth_fx = NB; move16(); } - ELSE IF( sub(ppp_nelp_mode,3) == 0 ) + ELSE IF( EQ_16(ppp_nelp_mode,3)) { st->nelp_mode_dec_fx = 1; move16(); @@ -196,12 +194,12 @@ void decision_matrix_dec_fx( *---------------------------------------------------------------------*/ test(); - IF( L_sub(st->total_brate_fx,ACELP_24k40) < 0 ) + IF( LT_32(st->total_brate_fx,ACELP_24k40)) { st->core_fx = ACELP_CORE; move16(); } - ELSE IF( L_sub(st->total_brate_fx,ACELP_24k40) >= 0 && L_sub(st->total_brate_fx,ACELP_64k) <= 0 ) + ELSE IF( GE_32(st->total_brate_fx,ACELP_24k40)&&LE_32(st->total_brate_fx,ACELP_64k)) { /* read the ACELP/HQ core selection bit */ temp_core = get_next_indice_fx( st, 1 ); @@ -220,15 +218,15 @@ void decision_matrix_dec_fx( * Read ACELP signalling bits from the bitstream *-----------------------------------------------------------------*/ - IF( sub(st->core_fx,ACELP_CORE) == 0 ) + IF( EQ_16(st->core_fx,ACELP_CORE)) { /* find the section in the ACELP signalling table corresponding to bitrate */ start_idx = 0; move16(); - WHILE( L_sub(acelp_sig_tbl[start_idx],st->total_brate_fx) != 0 ) + WHILE( NE_32(acelp_sig_tbl[start_idx],st->total_brate_fx)) { start_idx = add(start_idx,1); - IF( sub(start_idx,MAX_ACELP_SIG) >= 0 ) + IF( GE_16(start_idx,MAX_ACELP_SIG)) { st->BER_detect = 1; move16(); @@ -261,7 +259,7 @@ void decision_matrix_dec_fx( /* convert signalling indice into signalling information */ *coder_type = extract_l(L_and(ind,0x7L)); - IF( sub(*coder_type,LR_MDCT) == 0 ) + IF( EQ_16(*coder_type,LR_MDCT)) { st->core_fx = HQ_CORE; move16(); @@ -293,13 +291,13 @@ void decision_matrix_dec_fx( test(); test(); IF( ( st->BER_detect ) || - ( L_sub(ind,1<<7) >= 0 ) || - ( L_sub(st->total_brate_fx,ACELP_13k20) <= 0 && sub(st->bwidth_fx,FB) == 0 ) || - ( L_sub(st->total_brate_fx,ACELP_32k) >= 0 && sub(st->bwidth_fx,NB) == 0 ) || - ( L_sub(st->total_brate_fx,ACELP_32k) >= 0 && !(sub(*coder_type,GENERIC) == 0 || sub(*coder_type,TRANSITION) == 0 || sub(*coder_type,INACTIVE) == 0 ) ) || - ( L_sub(st->total_brate_fx,ACELP_13k20) < 0 && sub(st->bwidth_fx,NB) != 0 && sub(*coder_type,LR_MDCT) == 0 ) || - ( L_sub(st->total_brate_fx,ACELP_13k20) >= 0 && sub(*coder_type,UNVOICED) == 0 ) || - ( L_sub(st->total_brate_fx,ACELP_13k20) >= 0 && sub(*coder_type,AUDIO) == 0 && sub(st->bwidth_fx,NB) == 0 ) + ( GE_32(ind,1<<7) ) || + ( LE_32(st->total_brate_fx,ACELP_13k20) && EQ_16(st->bwidth_fx,FB) ) || + ( GE_32(st->total_brate_fx,ACELP_32k) && EQ_16(st->bwidth_fx,NB) ) || + ( GE_32(st->total_brate_fx,ACELP_32k) && !(EQ_16(*coder_type,GENERIC) || EQ_16(*coder_type,TRANSITION) || EQ_16(*coder_type,INACTIVE) ) ) || + ( LT_32(st->total_brate_fx,ACELP_13k20) && NE_16(st->bwidth_fx,NB) && EQ_16(*coder_type,LR_MDCT) ) || + ( GE_32(st->total_brate_fx,ACELP_13k20) && EQ_16(*coder_type,UNVOICED) ) || + ( GE_32(st->total_brate_fx,ACELP_13k20) && EQ_16(*coder_type,AUDIO) && EQ_16(st->bwidth_fx,NB) ) ) { st->BER_detect = 0; @@ -318,7 +316,7 @@ void decision_matrix_dec_fx( st->last_core_brate_fx = st->core_brate_fx; move32(); } - ELSE IF( L_sub(st->last_total_brate_fx, -1) == 0 ) /* can happen in case of BER when no good frame was received before */ + ELSE IF( EQ_32(st->last_total_brate_fx, -1)) /* can happen in case of BER when no good frame was received before */ { *coder_type = st->last_coder_type_fx; move16(); @@ -327,14 +325,14 @@ void decision_matrix_dec_fx( st->total_brate_fx = st->last_total_brate_ber_fx; move32(); test(); - IF( sub(st->last_core_fx, AMR_WB_CORE) == 0 ) + IF( EQ_16(st->last_core_fx, AMR_WB_CORE)) { st->core_fx = ACELP_CORE; move16(); st->codec_mode = MODE1; move16(); } - ELSE IF( sub(st->last_core_bfi, TCX_20_CORE) == 0 || sub(st->last_core_bfi, TCX_10_CORE) == 0 ) + ELSE IF( EQ_16(st->last_core_bfi, TCX_20_CORE)||EQ_16(st->last_core_bfi,TCX_10_CORE)) { st->core_fx = st->last_core_bfi; move16(); @@ -365,14 +363,14 @@ void decision_matrix_dec_fx( move16(); test(); - IF( sub(st->last_core_fx,AMR_WB_CORE) == 0 ) + IF( EQ_16(st->last_core_fx,AMR_WB_CORE)) { st->core_fx = ACELP_CORE; move16(); st->codec_mode = MODE1; move16(); } - ELSE IF( sub(st->last_core_fx,TCX_20_CORE) == 0 || sub(st->last_core_fx,TCX_10_CORE) == 0 ) + ELSE IF( EQ_16(st->last_core_fx,TCX_20_CORE)||EQ_16(st->last_core_fx,TCX_10_CORE)) { st->core_fx = st->last_core_fx; move16(); @@ -415,7 +413,7 @@ void decision_matrix_dec_fx( test(); test(); test(); - IF( sub(st->core_fx,ACELP_CORE) == 0 && sub(st->bwidth_fx,WB) == 0 && L_sub(st->total_brate_fx,ACELP_9k60) < 0 ) + IF( EQ_16(st->core_fx,ACELP_CORE)&&EQ_16(st->bwidth_fx,WB)&<_32(st->total_brate_fx,ACELP_9k60)) { if( st->vbr_hw_BWE_disable_dec_fx == 0 ) { @@ -423,11 +421,11 @@ void decision_matrix_dec_fx( move16(); } } - ELSE IF( sub(st->core_fx,ACELP_CORE) == 0 && sub(st->bwidth_fx,WB) == 0 && L_sub(st->total_brate_fx,ACELP_9k60) >= 0 && L_sub(st->total_brate_fx,ACELP_16k40) <= 0 ) + ELSE IF( EQ_16(st->core_fx,ACELP_CORE)&&EQ_16(st->bwidth_fx,WB)&&GE_32(st->total_brate_fx,ACELP_9k60)&&LE_32(st->total_brate_fx,ACELP_16k40)) { /* read the WB TBE/BWE selection bit */ tmp16 = get_next_indice_fx( st, 1 ); - IF( sub(tmp16,1) == 0 ) + IF( EQ_16(tmp16,1)) { st->extl_fx = WB_BWE; move16(); @@ -442,13 +440,13 @@ void decision_matrix_dec_fx( move32(); } } - ELSE IF( sub(st->core_fx,ACELP_CORE) == 0 && (sub(st->bwidth_fx,SWB) == 0 || sub(st->bwidth_fx,FB) == 0) && L_sub(st->total_brate_fx,ACELP_13k20) >= 0 ) + ELSE IF( EQ_16(st->core_fx,ACELP_CORE)&&(EQ_16(st->bwidth_fx,SWB)||EQ_16(st->bwidth_fx,FB))&&GE_32(st->total_brate_fx,ACELP_13k20)) { - IF( L_sub(st->total_brate_fx,ACELP_48k) >=0 ) + IF( GE_32(st->total_brate_fx,ACELP_48k)) { st->extl_fx = SWB_BWE_HIGHRATE; move16(); - if( sub(st->bwidth_fx,FB) == 0 ) + if( EQ_16(st->bwidth_fx,FB)) { st->extl_fx = FB_BWE_HIGHRATE; move16(); @@ -475,7 +473,7 @@ void decision_matrix_dec_fx( move16(); st->extl_brate_fx = SWB_TBE_1k6; move32(); - if( L_sub(st->total_brate_fx,ACELP_24k40) >= 0 ) + if( GE_32(st->total_brate_fx,ACELP_24k40)) { st->extl_brate_fx = SWB_TBE_2k8; move32(); @@ -485,16 +483,16 @@ void decision_matrix_dec_fx( /* set FB TBE and FB BWE extension layers */ test(); - IF( sub(st->bwidth_fx,FB) == 0 && L_sub(st->total_brate_fx,ACELP_24k40) >= 0 ) + IF( EQ_16(st->bwidth_fx,FB)&&GE_32(st->total_brate_fx,ACELP_24k40)) { - IF( sub(st->extl_fx,SWB_BWE) == 0 ) + IF( EQ_16(st->extl_fx,SWB_BWE)) { st->extl_fx = FB_BWE; move16(); st->extl_brate_fx = FB_BWE_1k8; move32(); } - ELSE IF( sub(st->extl_fx,SWB_TBE) == 0 ) + ELSE IF( EQ_16(st->extl_fx,SWB_TBE)) { st->extl_fx = FB_TBE; move16(); @@ -515,9 +513,9 @@ void decision_matrix_dec_fx( *-----------------------------------------------------------------*/ - IF( sub(st->core_fx,HQ_CORE) == 0 ) + IF( EQ_16(st->core_fx,HQ_CORE)) { - IF( sub(st->mdct_sw, MODE2) != 0 ) + IF( NE_16(st->mdct_sw, MODE2)) { /* skip the HQ/TCX core switching flag */ get_next_indice_tmp_fx( st, 1 ); @@ -526,7 +524,7 @@ void decision_matrix_dec_fx( /* read ACELP->HQ core switching flag */ *core_switching_flag = get_next_indice_fx( st, 1 ); - IF( sub(*core_switching_flag,1) == 0 ) + IF( EQ_16(*core_switching_flag,1)) { st->last_L_frame_ori_fx = st->last_L_frame_fx; move16(); @@ -542,11 +540,11 @@ void decision_matrix_dec_fx( } } - IF( sub(st->mdct_sw, MODE2) != 0 ) + IF( NE_16(st->mdct_sw, MODE2)) { /* read/set band-width (needed for different I/O sampling rate support) */ - IF( L_sub(st->total_brate_fx,ACELP_16k40) > 0 ) + IF( GT_32(st->total_brate_fx,ACELP_16k40)) { tmp16 = get_next_indice_fx( st, 2 ); @@ -555,12 +553,12 @@ void decision_matrix_dec_fx( st->bwidth_fx = NB; move16(); } - ELSE IF( sub(tmp16,1) == 0 ) + ELSE IF( EQ_16(tmp16,1)) { st->bwidth_fx = WB; move16(); } - ELSE IF( sub(tmp16,2) == 0 ) + ELSE IF( EQ_16(tmp16,2)) { st->bwidth_fx = SWB; move16(); @@ -578,8 +576,8 @@ void decision_matrix_dec_fx( test(); test(); test(); - IF( ( L_sub(st->total_brate_fx,ACELP_24k40) >= 0 && sub(st->bwidth_fx,NB) == 0 ) || - ( sub(st->core_fx,HQ_CORE) == 0 && L_sub(st->total_brate_fx,LRMDCT_CROSSOVER_POINT) <= 0 && sub(st->bwidth_fx,FB) == 0) + IF( ( GE_32(st->total_brate_fx,ACELP_24k40)&&EQ_16(st->bwidth_fx,NB))|| + ( EQ_16(st->core_fx,HQ_CORE) && LE_32(st->total_brate_fx,LRMDCT_CROSSOVER_POINT) && EQ_16(st->bwidth_fx,FB) ) ) { st->bfi_fx = 1; @@ -591,7 +589,7 @@ void decision_matrix_dec_fx( move16(); st->extl_brate_fx = 0; move32(); - IF( sub(st->last_core_fx,AMR_WB_CORE) == 0 ) + IF( EQ_16(st->last_core_fx,AMR_WB_CORE)) { st->core_fx = ACELP_CORE; move16(); @@ -602,7 +600,7 @@ void decision_matrix_dec_fx( st->last_L_frame_fx = L_FRAME; move16(); - IF( L_sub(st->total_brate_fx,ACELP_16k40) >= 0 ) + IF( GE_32(st->total_brate_fx,ACELP_16k40)) { st->total_brate_fx = ACELP_13k20; move32(); @@ -624,12 +622,12 @@ void decision_matrix_dec_fx( test(); test(); - IF( (sub(st->bwidth_fx,SWB) == 0 || sub(st->bwidth_fx,WB) == 0) && L_sub(st->total_brate_fx,LRMDCT_CROSSOVER_POINT) <= 0 ) + IF( (EQ_16(st->bwidth_fx,SWB)||EQ_16(st->bwidth_fx,WB))&&LE_32(st->total_brate_fx,LRMDCT_CROSSOVER_POINT)) { *hq_core_type = LOW_RATE_HQ_CORE; move16(); } - ELSE IF( sub(st->bwidth_fx,NB) == 0 ) + ELSE IF( EQ_16(st->bwidth_fx,NB)) { *hq_core_type = LOW_RATE_HQ_CORE; move16(); @@ -649,20 +647,20 @@ void decision_matrix_dec_fx( test(); test(); test(); - IF( L_sub(st->core_brate_fx,FRAME_NO_DATA) == 0 ) + IF( EQ_32(st->core_brate_fx,FRAME_NO_DATA)) { /* prevent "L_frame" changes in CNG segments */ st->L_frame_fx = st->last_L_frame_fx; move16(); } - ELSE IF( L_sub(st->core_brate_fx,SID_2k40) == 0 && sub(st->bwidth_fx,WB) == 0 && st->first_CNG_fx && sub(st->act_cnt2_fx,MIN_ACT_CNG_UPD) < 0 ) + ELSE IF( EQ_32(st->core_brate_fx,SID_2k40)&&EQ_16(st->bwidth_fx,WB)&&st->first_CNG_fx&<_16(st->act_cnt2_fx,MIN_ACT_CNG_UPD)) { /* prevent "L_frame" changes in SID frame after short segment of active frames */ st->L_frame_fx = st->last_CNG_L_frame_fx; move16(); } - ELSE IF( ( L_sub(st->core_brate_fx,SID_2k40) == 0 && L_sub(st->total_brate_fx,ACELP_9k60) >= 0 && sub(st->bwidth_fx,WB) == 0 ) || - ( L_sub(st->total_brate_fx,ACELP_24k40) > 0 && L_sub(st->total_brate_fx,HQ_96k) < 0 ) || ( L_sub(st->total_brate_fx,ACELP_24k40) == 0 && sub(st->bwidth_fx,WB) >= 0 ) ) + ELSE IF( ( EQ_32(st->core_brate_fx,SID_2k40)&&GE_32(st->total_brate_fx,ACELP_9k60)&&EQ_16(st->bwidth_fx,WB))|| + ( GT_32(st->total_brate_fx,ACELP_24k40) && LT_32(st->total_brate_fx,HQ_96k) ) || ( EQ_32(st->total_brate_fx,ACELP_24k40) && GE_16(st->bwidth_fx,WB) ) ) { st->L_frame_fx = L_FRAME16k; move16(); @@ -675,19 +673,19 @@ void decision_matrix_dec_fx( st->nb_subfr = NB_SUBFR; move16(); - if ( sub(st->L_frame_fx,L_FRAME16k) == 0) + if ( EQ_16(st->L_frame_fx,L_FRAME16k)) { st->nb_subfr = NB_SUBFR16k; move16(); } test(); - IF( L_sub(st->output_Fs_fx,8000) == 0 ) + IF( EQ_32(st->output_Fs_fx,8000)) { st->extl_fx = -1; move16(); } - ELSE IF( L_sub(st->output_Fs_fx,16000) == 0 && sub(st->L_frame_fx,L_FRAME16k) == 0 ) + ELSE IF( EQ_32(st->output_Fs_fx,16000)&&EQ_16(st->L_frame_fx,L_FRAME16k)) { st->extl_fx = -1; move16(); diff --git a/lib_dec/decoder.c b/lib_dec/decoder.c index 5a7677215e29db43fa9f18983588b0a88e4a0a96..bfdc69cd39322c2933af8dcbbddc7ebd46008eb8 100644 --- a/lib_dec/decoder.c +++ b/lib_dec/decoder.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -9,8 +9,6 @@ #include #include "options.h" #include "stl.h" -#include "wmc_auto.h" - #include "stat_dec_fx.h" #include "prot_fx.h" #include "g192.h" @@ -18,15 +16,9 @@ #include "EvsRXlib.h" -#define WMC_TOOL_SKIP - /*------------------------------------------------------------------------------------------* * Global variables *------------------------------------------------------------------------------------------*/ - -#if !defined( DEBUGGING ) && !defined( WMOPS ) -static -#endif long frame = 0; /* Counter of frames */ @@ -45,10 +37,11 @@ int main(int argc, char *argv[]) Word16 noDelayCmp = 0; char *jbmFECoffsetFileName = NULL; /* FEC offset file name */ -#ifdef WMOPS - reset_wmops(); - reset_mem(USE_BYTES); -#endif + + BASOP_init + + + /*------------------------------------------------------------------------------------------* * Allocation of memory for static variables @@ -137,34 +130,39 @@ int main(int argc, char *argv[]) else { fprintf( stdout, "\n-- Start the decoder (quiet mode) --\n\n" ); } - -#ifdef WMOPS - reset_stack(); - reset_wmops(); + BASOP_end_noprint; + BASOP_init; +#if (WMOPS) + Init_WMOPS_counter(); + Reset_WMOPS_counter(); + setFrameRate(48000, 960); #endif /*----- loop: decode-a-frame -----*/ WHILE( st_fx->bitstreamformat==G192 ? read_indices_fx( st_fx, f_stream, 0 ) : read_indices_mime( st_fx, f_stream, 0) ) { +#if (WMOPS) + fwc(); + Reset_WMOPS_counter(); +#endif + + + SUB_WMOPS_INIT("evs_dec"); + /* run the main encoding routine */ - IF(sub(st_fx->codec_mode, MODE1) == 0) + IF(EQ_16(st_fx->codec_mode, MODE1)) { IF ( st_fx->Opt_AMR_WB_fx ) { - push_wmops("amr_wb_dec"); amr_wb_dec_fx( output,st_fx); - pop_wmops(); } ELSE { - push_wmops("evs_dec"); evs_dec_fx( st_fx, output, FRAMEMODE_NORMAL); - pop_wmops(); } } ELSE { - push_wmops("evs_dec"); IF(st_fx->bfi_fx == 0) { evs_dec_fx( st_fx, output, FRAMEMODE_NORMAL); @@ -173,12 +171,15 @@ int main(int argc, char *argv[]) { evs_dec_fx( st_fx, output, FRAMEMODE_MISSING); } - pop_wmops(); } + END_SUB_WMOPS; + + + /* increase the counter of initialization frames */ - if( sub(st_fx->ini_frame_fx,MAX_FRAME_COUNTER) < 0 ) + if( LT_16(st_fx->ini_frame_fx,MAX_FRAME_COUNTER)) { st_fx->ini_frame_fx = add(st_fx->ini_frame_fx,1); } @@ -191,7 +192,7 @@ int main(int argc, char *argv[]) } ELSE { - IF ( sub(dec_delay , output_frame) <= 0 ) + IF ( LE_16(dec_delay , output_frame)) { fwrite( output +dec_delay, sizeof(Word16), sub(output_frame , dec_delay), f_synth ); dec_delay = 0; @@ -204,14 +205,6 @@ int main(int argc, char *argv[]) } -#ifdef WMOPS - update_wmops(); - update_mem(); -#ifdef MEM_COUNT_DETAILS - export_mem("mem_analysis.csv"); -#endif -#endif - frame++; if (quietMode == 0) { @@ -232,13 +225,27 @@ int main(int argc, char *argv[]) printf("Decoding of %ld frames finished\n\n", frame); } fprintf( stdout, "\n\n" ); + fflush(stdout); + + + fflush(stdout); fflush(stderr); + /* end of WMOPS counting */ +#if (WMOPS) + fwc(); + printf("\nDecoder complexity\n"); + WMOPS_output(0); + printf("\n"); +#endif + /* add zeros at the end to have equal length of synthesized signals */ set16_fx( output, 0, zero_pad ); fwrite( output, sizeof(Word16), zero_pad, f_synth ); + BASOP_init destroy_decoder( st_fx ); + BASOP_end_noprint } /* free memory etc. */ @@ -246,10 +253,6 @@ int main(int argc, char *argv[]) fclose( f_synth ); fclose( f_stream ); -#ifdef WMOPS - print_wmops(); - print_mem(NULL); -#endif return 0; } diff --git a/lib_dec/dlpc_avq.c b/lib_dec/dlpc_avq.c index c8d8aaf88efd835269bf0861163f37d0e6060863..b8b4fc6afd2fd1b0acd4b5844f85c6665f30d24f 100644 --- a/lib_dec/dlpc_avq.c +++ b/lib_dec/dlpc_avq.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ @@ -8,8 +8,6 @@ #include #include #include "stl.h" -#include "wmc_auto.h" - #include "prot_fx.h" /* Constants */ @@ -36,7 +34,7 @@ Word16 dlpc_avq( move16(); last = 0; - if ( sub(numlpc,1)!=0 ) + if ( NE_16(numlpc,1)) { move16(); last = M; @@ -60,7 +58,7 @@ Word16 dlpc_avq( /* Decode intermediate LPC (512 framing) */ - IF ( sub(numlpc,2)==0 ) + IF ( EQ_16(numlpc,2)) { move16(); q_type = p_index[0]; @@ -78,7 +76,7 @@ Word16 dlpc_avq( p_index++; vlpc_2st_dec(&LSF_Q[0], &p_index[0], 0, sr_core); } - ELSE IF ( sub(q_type,1) == 0 ) + ELSE IF ( EQ_16(q_type,1)) { FOR (i=0; i 0 ) + IF ( GT_16(qn1,4)) { nb = unary_decode(st, &qn1); - if ( sub(nb,1) == 0 ) + if ( EQ_16(nb,1)) { qn1 = add(qn1, 5); } - if (sub(nb,2) == 0) + if (EQ_16(nb,2)) { qn1 = add(qn1, 4); } - if ( sub(nb,3) == 0 ) + if ( EQ_16(nb,3)) { move16(); qn1 = 0; } - if ( sub(nb,3) > 0 ) + if ( GT_16(nb,3)) { qn1 = add(qn1, 3); } } - IF ( sub(qn2,4) > 0 ) + IF ( GT_16(qn2,4)) { nb = unary_decode(st, &qn2); - if ( sub(nb,1) == 0 ) + if ( EQ_16(nb,1)) { qn2 = add(qn2, 5); } - if (sub(nb,2) == 0) + if (EQ_16(nb,2)) { qn2 = add(qn2, 4); } - if ( sub(nb,3) == 0 ) + if ( EQ_16(nb,3)) { move16(); qn2 = 0; } - if ( sub(nb,3) > 0 ) + if ( GT_16(nb,3)) { qn2 = add(qn2, 3); } @@ -244,7 +242,7 @@ Word16 decode_lpc_avq( Decoder_State_fx *st, Word16 numlpc, Word16 *param_lpc ) /* check for potential bit errors */ test(); - IF( (sub(qn1, NB_SPHERE) > 0) || (sub(qn2, NB_SPHERE) > 0) ) + IF( (GT_16(qn1, NB_SPHERE))||(GT_16(qn2,NB_SPHERE))) { qn1 = 0; move16(); diff --git a/lib_dec/dlpc_stoch.c b/lib_dec/dlpc_stoch.c index 8cbcc5f84d5efaf06da050393e7bc92f81bcee69..e9c32b72d2b731606699b6a89fb1b227f96d3b73 100644 --- a/lib_dec/dlpc_stoch.c +++ b/lib_dec/dlpc_stoch.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ @@ -8,8 +8,6 @@ #include #include #include "stl.h" -#include "wmc_auto.h" - #include "basop_util.h" #include "prot_fx.h" @@ -62,10 +60,10 @@ void lpc_unquantize( E_LPC_lsf_lsp_conversion(&lsf[(k+1)*m], &lsp[(k+1)*m], m); } } - ELSE IF ( sub(lpcQuantization, 1) == 0 ) + ELSE IF ( EQ_16(lpcQuantization, 1)) { test(); - IF ((L_sub(sr_core, INT_FS_16k) == 0) && (sub(coder_type, UNVOICED) == 0 )) + IF ((EQ_32(sr_core, INT_FS_16k))&&(EQ_16(coder_type,UNVOICED))) { lsf_end_dec_fx( st, 1, GENERIC, sub(1,narrow_band) /* st->bwidth */ , 31, &lsf[m], mem_AR, mem_MA, sr_core, st->core_brate_fx, &st->offset_scale1_fx[0][0], &st->offset_scale2_fx[0][0], &st->offset_scale1_p_fx[0][0], &st->offset_scale2_p_fx[0][0], @@ -73,7 +71,7 @@ void lpc_unquantize( } ELSE { - IF (sub(st->core_fx, TCX_20_CORE)==0) + IF (EQ_16(st->core_fx, TCX_20_CORE)) { lsf_end_dec_fx( st, 1, AUDIO, sub(1, narrow_band) /* st->bwidth */ , 31, &lsf[m], mem_AR, mem_MA, sr_core, st->core_brate_fx, &st->offset_scale1_fx[0][0], &st->offset_scale2_fx[0][0], &st->offset_scale1_p_fx[0][0], &st->offset_scale2_p_fx[0][0], diff --git a/lib_dec/er_dec_acelp.c b/lib_dec/er_dec_acelp.c index 7b8f2df8bcec37e14326063aeb31b313cd7f43d2..fdccc8c3ed70def8e0d711202fa526a061a8ad8a 100644 --- a/lib_dec/er_dec_acelp.c +++ b/lib_dec/er_dec_acelp.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ /*VERSIONINFO: File up to date with trunk rev. 39929*/ @@ -13,8 +13,6 @@ #include "rom_dec_fx.h" #include "options.h" #include "stl.h" -#include "wmc_auto.h" - extern const Word16 T_DIV_L_Frame[];/*0Q15 * 2^-7 */ @@ -130,7 +128,7 @@ void con_acelp( * PLC: [ACELP:Extrapolate Pitch Lag] *------------------------------------------------------------------------*/ - if (sub(st->flagGuidedAcelp, 1) == 0) + if (EQ_16(st->flagGuidedAcelp, 1)) { T0 = st->guidedT0; move16(); @@ -184,7 +182,7 @@ void con_acelp( * PLC: calculate damping factor */ alpha = Damping_fact(coder_type, st->nbLostCmpt, st->last_good_fx, stab_fac, &(st->Mode2_lp_gainp), 0); /*Q14*/ st->cummulative_damping = shl(mult(st->cummulative_damping,alpha),1);/*shl(Q15*Q14,1)=shl(Q14,1) = Q15*/ - if (sub(st->nbLostCmpt,1)==0) + if (EQ_16(st->nbLostCmpt,1)) { st->cummulative_damping = 32767/*1.f Q15*/; /*Q15*/ } @@ -194,7 +192,7 @@ void con_acelp( * PLC: Construct the harmonic part of excitation *-----------------------------------------------------------------*/ - IF( sub(st->last_good_fx , UNVOICED_TRANSITION ) >= 0) + IF( GE_16(st->last_good_fx , UNVOICED_TRANSITION )) { /*---------------------------------------------------------------* @@ -202,13 +200,13 @@ void con_acelp( *---------------------------------------------------------------*/ Tc = round_fx(tmp_tc); - BASOP_SATURATE_WARNING_OFF;/*if this ever saturates, it doesn't matter*/ + BASOP_SATURATE_WARNING_OFF /*if this ever saturates, it doesn't matter*/ tmp = sub(shl(abs_s(sub(T0,Tc)),6) , mult(19661/*0.15f Q17*/,shl(Tc,4)) /*Q6*/); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON test(); test(); test(); - if ((T0 > 0) && (sub(T0 , Tc) != 0 ) + if ((T0 > 0) && (NE_16(T0 , Tc)) && ( tmp < 0 ) && extrapolationFailed == 0 ) { @@ -232,7 +230,7 @@ void con_acelp( assert(pt_exc < pt1_exc-1); } - IF (sub(st->nbLostCmpt, 1) == 0) + IF (EQ_16(st->nbLostCmpt, 1)) { /* pitch cycle is first low-pass filtered */ @@ -296,7 +294,7 @@ void con_acelp( move16(); move16(); pitch_buf[3] = pitch_buf[2] = pitch_buf[1]; /* do not resync on second half of frame */ - if (sub(st->nb_subfr, 5) == 0) + if (EQ_16(st->nb_subfr, 5)) { /* for guided acelp cases and nSubframes=2, set pitch_buf[4] to avoid memory_access issues in post_decoder() */ pitch_buf[4] = pitch_buf[3]; @@ -342,7 +340,7 @@ void con_acelp( { move32(); st->old_fpitch = predPitchLag; - if (sub(st->flagGuidedAcelp ,1) == 0) + if (EQ_16(st->flagGuidedAcelp ,1)) { st->old_fpitch = L_deposit_h(T0); } @@ -371,9 +369,9 @@ void con_acelp( test(); test();/*test();*/ - IF (sub(st->last_good_fx , UNVOICED_TRANSITION) <= 0 - && (sub(coder_type , GENERIC ) == 0) - && L_sub(pc , 6*2*32768/*6(15Q16)*/ ) > 0 /*&& (stab_fac <= 0.5f)*/ + IF (LE_16(st->last_good_fx , UNVOICED_TRANSITION) + && (EQ_16(coder_type , GENERIC ) ) + && GT_32(pc , 6*2*32768/*6(15Q16)*/ ) /*&& (stab_fac <= 0.5f)*/ ) { gain = 0; @@ -413,9 +411,9 @@ void con_acelp( FOR (; i < l; i++) { move16(); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF exc[i] = mult_r(exc[i] , shl(gain,1)); /*overflow is first iteration because gain may be 1 after shift*/ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON gain = sub(gain , step); } } @@ -424,9 +422,9 @@ void con_acelp( FOR (; i < l; i++ ) { move16(); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF exc[i] = mult_r(exc[i] , shl(gain,1)); /*overflow is first iteration because gain may become 1 due to shift*/ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON gain = sub(gain , step); } @@ -523,16 +521,16 @@ void con_acelp( ftmp = round_fx(L_shl(gain_32,1));/*Q0*/ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF tmp_16 = sub(shl(gainCNG,sub(gainCNG_e,5/*Q5*/)),ftmp); /*in case of overflow:*/ test(); - if ((sub(shl(ftmp,sub(gainCNG_e,1)),MAXVAL_WORD16) == 0) && (gainCNG == MAXVAL_WORD16)) + if ((EQ_16(shl(ftmp,sub(gainCNG_e,1)),MAXVAL_WORD16))&&(gainCNG==MAXVAL_WORD16)) { move16(); tmp_16 = 1; } - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON IF (tmp_16 > 0 ) { @@ -562,7 +560,7 @@ void con_acelp( s_16 = BASOP_Util_Add_MantExp(tmp_16,s_16,tmp2,s2,&tmp_16); st->Mode2_lp_gainc = L_shl(L_deposit_l(tmp_16),add(s_16,1)); test(); - IF( (sub(st->last_good_fx, UNVOICED_TRANSITION)==0 ) && (sub(coder_type,GENERIC)==0) ) + IF( (EQ_16(st->last_good_fx, UNVOICED_TRANSITION))&&(EQ_16(coder_type,GENERIC))) { st->Mode2_lp_gainc = L_deposit_h(gainCNG);/*Q21*/ st->Mode2_lp_gainc = L_shr(st->Mode2_lp_gainc,sub(5,gainCNG_e)); /*15Q16, no scaling*/ @@ -575,9 +573,9 @@ void con_acelp( /*** Find energy normalization factor ***/ /*gain_inov = 1.0f / (float)sqrt( dot_product( pt_exc, pt_exc, st->L_frame_fx ) / st->L_frame_fx );*//* normalize energy */ /*<--- FLC*/ - BASOP_SATURATE_WARNING_OFF;/*norm_llQ31 at the end of Dot_productSq16HQ may throw an overflow, but result is okay*/ + BASOP_SATURATE_WARNING_OFF /*norm_llQ31 at the end of Dot_productSq16HQ may throw an overflow, but result is okay*/ tmp_32 = Dot_productSq16HQ(0,pt_exc,st->L_frame_fx,&s_32); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON s_32 = add(s_32, 31-1); /*scalingfactor is twice the headroom (at noise insertion onto the buffer), -1 (because of mult) +31 (Result is Q31) +s_32 (output scalingfactor of dot_product)*/ @@ -610,12 +608,12 @@ void con_acelp( step_32 = L_shr(step_32, 7); /* 15Q16 */ test(); - if ((sub(st->last_good_fx ,UNVOICED_CLAS)==0) && (sub(coder_type,UNVOICED)!= 0)) /* Attenuate somewhat on unstable unvoiced */ + if ((EQ_16(st->last_good_fx ,UNVOICED_CLAS))&&(NE_16(coder_type,UNVOICED))) /* Attenuate somewhat on unstable unvoiced */ { gain_inov = mult_r(gain_inov, 26214/*0.8f Q15*/); /*Q15 * 2^s_gain_inov*/ } - IF ( sub(st->last_good_fx , UNVOICED_TRANSITION)>=0 ) + IF ( GE_16(st->last_good_fx , UNVOICED_TRANSITION)) { Word16 tilt_code; @@ -692,7 +690,7 @@ void con_acelp( } /* Compute total excitation in noisebuffer to save memories */ - IF( sub( st->last_good_fx, UNVOICED_TRANSITION ) >= 0 ) + IF( GE_16( st->last_good_fx, UNVOICED_TRANSITION )) { Vr_add(exc, exc_unv, noise_buf, add(st->L_frame_fx, 1)); } @@ -701,7 +699,7 @@ void con_acelp( noise_buf = exc_unv; } - IF( sub( st->L_frame_fx, L_FRAME ) == 0 ) + IF( EQ_16( st->L_frame_fx, L_FRAME )) { interp_code_5over2_fx(noise_buf, bwe_exc, st->L_frame_fx); set16_fx(voice_factors, st->last_voice_factor_fx, NB_SUBFR); @@ -720,7 +718,7 @@ void con_acelp( syn = buf + M; Copy(st->mem_syn2_fx, buf, M ); - IF (sub(st->nbLostCmpt,1) == 0) + IF (EQ_16(st->nbLostCmpt,1)) { IF( st->last_good_fx < UNVOICED_TRANSITION ) { @@ -809,7 +807,7 @@ void con_acelp( } test(); - IF(sub(st->nbLostCmpt,5)>0 && (s_16 > 0) ) + IF(GT_16(st->nbLostCmpt,5)&&(s_16>0)) { /*scale back mem_syn, exc and synthesis*/ Scale_sig(mem_syn,M,negate(s_16)); @@ -886,7 +884,7 @@ void con_acelp( } Copy(mem_syn_unv,st->mem_syn_unv_back,M); - IF(sub(st->last_good_fx,UNVOICED_TRANSITION) < 0) + IF(LT_16(st->last_good_fx,UNVOICED_TRANSITION)) { Copy(mem_syn_unv,mem_syn,M); /* unvoiced for ola */ @@ -894,11 +892,11 @@ void con_acelp( } test(); - IF(sub(st->nbLostCmpt,5)>0 && (s_16 > 0) ) + IF(GT_16(st->nbLostCmpt,5)&&(s_16>0)) { /*scale back mem_syn_unv, exc_unv and synthesis*/ Scale_sig(mem_syn_unv,M,negate(s_16)); - IF(sub(st->last_good_fx,UNVOICED_TRANSITION) < 0) + IF(LT_16(st->last_good_fx,UNVOICED_TRANSITION)) { Scale_sig(mem_syn,M,negate(s_16)); Scale_sig(syn_unv, add(shr(st->L_frame_fx,1),st->L_frame_fx) ,negate(s_16)); @@ -914,7 +912,7 @@ void con_acelp( } /* add separate synthesis buffers */ - IF (sub(st->last_good_fx,UNVOICED_TRANSITION) >= 0) + IF (GE_16(st->last_good_fx,UNVOICED_TRANSITION)) { FOR( i=0 ; i < st->L_frame_fx; i++ ) { @@ -1084,7 +1082,7 @@ void con_acelp( static void memsynPrecission(Word16 nbLostCmpt,Word16* mem_syn, Word16* exc, Word16 len, Word16*s_16) { - IF(sub(nbLostCmpt,5)>0 ) + IF(GT_16(nbLostCmpt,5)) { Word16 sf_mem_syn, sf_exc,k, tmp_loop, max, tmp, i; tmp = 0; @@ -1098,9 +1096,9 @@ static void memsynPrecission(Word16 nbLostCmpt,Word16* mem_syn, Word16* exc, Wor FOR(i=0; i 0 ) diff --git a/lib_dec/er_dec_tcx.c b/lib_dec/er_dec_tcx.c index 0f41bffdaa994b2c57f6103109c8a56e06cc1d9a..aebc1b536d1607824ed19e14039cb24415566d27 100644 --- a/lib_dec/er_dec_tcx.c +++ b/lib_dec/er_dec_tcx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ @@ -11,8 +11,6 @@ #include "basop_util.h" #include "rom_dec_fx.h" #include "stl.h" -#include "wmc_auto.h" - /***************************************************** @@ -32,9 +30,9 @@ static void calcGainc(Word16* exc, Word16 Q_exc, Word32 old_fpitch, Word16 L_sub tmp16 = round_fx(old_fpitch);/*Q0*/ tmp_loop = shl(L_subfr,1); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF tmp16_2 = round_fx(L_shl(lp_gainp,2)); /*Q31->Q15, no severe saturation, because st->lp_gainp here is [0,1]*/ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON FOR ( i=0; i< tmp_loop; i++ ) { @@ -193,7 +191,7 @@ void con_tcx( move16(); test(); - IF ( (sub( st->nbLostCmpt, 1 ) == 0) || st->tcxConceal_recalc_exc ) + IF ( (EQ_16( st->nbLostCmpt, 1 ))||st->tcxConceal_recalc_exc) { /* apply pre-emphasis to the signal */ mem = synth[-((shr(L_frame,1))+st->pit_max_TCX+M+M)-1]; @@ -225,14 +223,14 @@ void con_tcx( /* Residu */ assert((2*L_subfr+Tc+1+M) <= st->old_synth_lenFB); - BASOP_SATURATE_WARNING_OFF;/*saturation possible in case of spiky synthesis*/ + BASOP_SATURATE_WARNING_OFF /*saturation possible in case of spiky synthesis*/ Residu3_fx( A_local, &(synth[-(2*L_subfr+Tc+1+M)]), /*Qx = Q0*/ &(exc[-(2*L_subfr+Tc+1+M)]), /*Qx+1 = Q1*/ add(add(add(shl(L_subfr,1),Tc),1),M), 1); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON } ELSE { @@ -242,7 +240,7 @@ void con_tcx( Copy(st->old_Aq_12_8_fx, A_local, M+1); offset = shr(L_frame,1); - IF(sub(st->last_good_fx, UNVOICED_TRANSITION) >= 0 ) + IF(GE_16(st->last_good_fx, UNVOICED_TRANSITION)) { tmp16 = s_max(Tc - shr(L_frame,1), 0); Copy_Scale_sig(st->old_excFB_fx, &(exc[-tmp16]), offset+tmp16, Q_exc-st->Q_exc); @@ -258,17 +256,17 @@ void con_tcx( test(); test(); - IF( sub(st->last_good_fx, UNVOICED_CLAS) > 0 && !(sub(st->last_good_fx, UNVOICED_TRANSITION) == 0 && sub(st->core_ext_mode, GENERIC) == 0) ) + IF( GT_16(st->last_good_fx, UNVOICED_CLAS)&&!(EQ_16(st->last_good_fx,UNVOICED_TRANSITION)&&EQ_16(st->core_ext_mode,GENERIC))) { - IF ( sub(st->nbLostCmpt,1) == 0 || st->tcxConceal_recalc_exc ) + IF ( EQ_16(st->nbLostCmpt,1)||st->tcxConceal_recalc_exc) { calcGainc( exc, Q_exc, st->old_fpitchFB, L_subfr, st->Mode2_lp_gainp, &(st->Mode2_lp_gainc)); } tmp16 = 0; move16(); - if (L_sub(st->output_Fs_fx , 25600) > 0) + if (GT_32(st->output_Fs_fx , 25600)) { tmp16 = 1; move16(); @@ -278,7 +276,7 @@ void con_tcx( test(); test(); test(); - IF( ((sub(st->nbLostCmpt,1) == 0) || st->tcxConceal_recalc_exc) && sub(st->rf_frame_type,RF_TCXFD) >= 0 && sub(st->rf_frame_type,RF_TCXTD2) <= 0 && st->use_partial_copy ) + IF( ((EQ_16(st->nbLostCmpt,1))||st->tcxConceal_recalc_exc)&&GE_16(st->rf_frame_type,RF_TCXFD)&&LE_16(st->rf_frame_type,RF_TCXTD2)&&st->use_partial_copy) { Word32 tcxltp_pitch_tmp = L_add(L_deposit_h(st->tcxltp_pitch_int), L_shl(L_deposit_l(div_s(st->tcxltp_pitch_fr,st->pit_res_max)),1)); /*15Q16*/ Word16 scale_tmp = mult_r(st->L_frameTCX, getInvFrameLen(st->L_frame_fx)); /*getInvFrameLen()->9Q6*/ @@ -291,8 +289,8 @@ void con_tcx( test(); test(); if ( (T0 > 0) - && (sub(T0,Tc) != 0) - && (L_sub(L_deposit_h(abs_s(sub(T0,Tc)))/*Q16*/ , L_mult(4915/*.15f Q15*//*Q15*/,Tc/*Q0*/) /*Q16*/ ) < 0) + && (NE_16(T0,Tc) ) + && (LT_32(L_deposit_h(abs_s(sub(T0,Tc)))/*Q16*/ , L_mult(4915/*.15f Q15*//*Q15*/,Tc/*Q0*/) /*Q16*/ ) ) ) { fUseExtrapolatedPitch = 1; @@ -322,8 +320,8 @@ void con_tcx( test(); test(); if ( (T0 > 0) - && (sub(T0,Tc) != 0) - && (L_sub(L_deposit_h(abs_s(sub(T0,Tc)))/*Q16*/ , L_mult(4915/*.15f Q15*//*Q15*/,Tc/*Q0*/) /*Q16*/ ) < 0) + && (NE_16(T0,Tc) ) + && (LT_32(L_deposit_h(abs_s(sub(T0,Tc)))/*Q16*/ , L_mult(4915/*.15f Q15*//*Q15*/,Tc/*Q0*/) /*Q16*/ ) ) && (extrapolationFailed == 0) ) { @@ -343,11 +341,11 @@ void con_tcx( pt_exc = buf; } test(); - IF( sub(st->stab_fac_fx ,32767/*1.f Q15*/) < 0 && sub(st->nbLostCmpt , 1) == 0 ) + IF( LT_16(st->stab_fac_fx ,32767/*1.f Q15*/)&&EQ_16(st->nbLostCmpt,1)) { /* pitch cycle is first low-pass filtered */ - IF (L_sub(st->output_Fs_fx , 16000) <= 0) + IF (LE_32(st->output_Fs_fx , 16000)) { FOR( i=0 ; i< Tc; i++ ) { @@ -434,7 +432,7 @@ void con_tcx( set32_fx( pitch_buf, st->old_fpitch, st->nb_subfr); } - IF ( sub(st->nbLostCmpt , 1) == 0 ) + IF ( EQ_16(st->nbLostCmpt , 1)) { pt_exc = exc+L_frame; IF (T0 == 0) @@ -465,7 +463,7 @@ void con_tcx( /* PLC: calculate damping factor */ alpha = Damping_fact(st->core_ext_mode, st->nbLostCmpt, st->last_good_fx, st->stab_fac_fx, &(st->Mode2_lp_gainp), 0);/*Q14*/ - IF ( sub(st->nbLostCmpt , 1) == 0 ) + IF ( EQ_16(st->nbLostCmpt , 1)) { st->cummulative_damping = 32767/*1.f Q15*/; move16(); @@ -477,7 +475,7 @@ void con_tcx( gain32 = L_add(2147483647l/*1.f Q31*/, 0); /*Q31*/ gain = 32767/*1.f Q15*/; /*Q15*/ move16(); - if( sub(st->rf_frame_type, RF_TCXTD1) == 0 && sub(st->use_partial_copy, 1) == 0 ) + if( EQ_16(st->rf_frame_type, RF_TCXTD1)&&EQ_16(st->use_partial_copy,1)) { gain32 = 1073741824l/*0.5f Q31*/; gain = 16384/*0.5f Q15*/; @@ -504,7 +502,7 @@ void con_tcx( offset = s_max(round_fx(st->old_fpitchFB) - shr(L_frame,1), 0); Copy(exc+L_frame-offset, st->old_excFB_fx, shr(L_frame,1)+offset); /* copy old_exc as 16kHz for acelp decoding */ - IF ( sub(st->nbLostCmpt, 1) == 0 ) + IF ( EQ_16(st->nbLostCmpt, 1)) { lerp(exc - shr(L_frame,1), st->old_exc_fx, L_EXC_MEM_DEC, add(L_frame, shr(L_frame,1))); } @@ -519,7 +517,7 @@ void con_tcx( { /* No harmonic part */ set16_fx(&exc[0], 0, add(L_frame,shr(L_frame,1))); - IF ( sub(st->nbLostCmpt , 1) == 0 ) + IF ( EQ_16(st->nbLostCmpt , 1)) { calcGainc2(&exc[0], Q_exc, L_subfr, &(st->Mode2_lp_gainc)); } @@ -554,11 +552,11 @@ void con_tcx( move16(); } test(); - IF (sub(st->last_good_fx , VOICED_CLAS)==0 || sub(st->last_good_fx , ONSET)==0) + IF (EQ_16(st->last_good_fx , VOICED_CLAS)||EQ_16(st->last_good_fx,ONSET)) { tmp16 = 19661/*0.6f Q15*/; move16(); - if ( L_sub(st->output_Fs_fx,16000) <= 0 ) + if ( LE_32(st->output_Fs_fx,16000)) { tmp16 = 6554/*0.2f Q15*/; move16(); @@ -569,7 +567,7 @@ void con_tcx( preemph_copy_fx(&noise[1], &noise[1], tmp16, L_frame+(L_frame/2)+L_FIR_FER2, &mem); } /* high rate filter tuning */ - IF ( L_sub(st->output_Fs_fx,16000) <= 0 ) + IF ( LE_32(st->output_Fs_fx,16000)) { FOR( i=0; i< L_FIR_FER2; i++ ) { @@ -585,32 +583,24 @@ void con_tcx( move16(); } } - IF ( sub(st->nbLostCmpt,1) == 0 ) + IF ( EQ_16(st->nbLostCmpt,1)) { highPassFiltering(st->last_good_fx, add(add(L_frame, shr(L_frame,1)),L_FIR_FER2), noise, hp_filt, L_FIR_FER2); } ELSE { - IF(sub( st->last_good_fx , UNVOICED_TRANSITION) > 0 ) + IF(GT_16( st->last_good_fx , UNVOICED_TRANSITION)) { tmp_loop = add(add(L_frame,shr(L_frame,1)),L_FIR_FER2); gain_tmp = negate(add(-32768,st->cummulative_damping));/*Q15*/ FOR( i=0 ; i < tmp_loop; i++ ) { - /*noise[i] = (1-st->cummulative_damping)*noise[i] + st->cummulative_damping*dot_product(&noise[i], hp_filt, L_FIR_FER2);*/ - move16(); - L_tmp2 = L_mac(0, noise[i+L_FIR_FER2-11], hp_filt[0+L_FIR_FER2-11]); - L_tmp2 = L_mac(L_tmp2, noise[i+L_FIR_FER2-10], hp_filt[0+L_FIR_FER2-10]); - L_tmp2 = L_mac(L_tmp2, noise[i+L_FIR_FER2-9], hp_filt[0+L_FIR_FER2-9]); - L_tmp2 = L_mac(L_tmp2, noise[i+L_FIR_FER2-8], hp_filt[0+L_FIR_FER2-8]); - L_tmp2 = L_mac(L_tmp2, noise[i+L_FIR_FER2-7], hp_filt[0+L_FIR_FER2-7]); - L_tmp2 = L_mac(L_tmp2, noise[i+L_FIR_FER2-6], hp_filt[0+L_FIR_FER2-6]); - L_tmp2 = L_mac(L_tmp2, noise[i+L_FIR_FER2-5], hp_filt[0+L_FIR_FER2-5]); - L_tmp2 = L_mac(L_tmp2, noise[i+L_FIR_FER2-4], hp_filt[0+L_FIR_FER2-4]); - L_tmp2 = L_mac(L_tmp2, noise[i+L_FIR_FER2-3], hp_filt[0+L_FIR_FER2-3]); - L_tmp2 = L_mac(L_tmp2, noise[i+L_FIR_FER2-2], hp_filt[0+L_FIR_FER2-2]); - L_tmp2 = L_mac(L_tmp2, noise[i+L_FIR_FER2-1], hp_filt[0+L_FIR_FER2-1]); - + Word16 j; + L_tmp2 = 0; move32(); + for (j=11; j>0; j--) + { + L_tmp2 = L_mac(L_tmp2, noise[i+L_FIR_FER2-j], hp_filt[L_FIR_FER2-j]); + } L_tmp2 = Mpy_32_16_1(L_tmp2, st->cummulative_damping/*Q15*/);/*Q0, noise_e*/ noise[i] = mac_r(L_tmp2, gain_tmp,noise[i]);/*Q15, noise_e*/ } @@ -645,13 +635,13 @@ void con_tcx( } gain32 = L_add(st->Mode2_lp_gainc, 0); /* start-of-the-frame gain - Q16*/ - if( sub(st->rf_frame_type, RF_TCXTD1) == 0 && sub(st->use_partial_copy, 1) == 0 ) + if( EQ_16(st->rf_frame_type, RF_TCXTD1)&&EQ_16(st->use_partial_copy,1)) { gain32 = Mpy_32_16_1(gain32, 22938/*0.7f Q15*/); } L_tmp = L_shl(gain32,1); - IF (L_sub(L_shl(L_deposit_h(gainCNG),sub(gainCNG_e,31-16)/*Q16*/) , L_tmp) > 0) + IF (GT_32(L_shl(L_deposit_h(gainCNG),sub(gainCNG_e,31-16)/*Q16*/) , L_tmp)) { gainCNG_e = sub(15+1,norm_l(L_tmp)); gainCNG = extract_l(L_shr(L_tmp,gainCNG_e));/*Q15,gainCNG_e*/ @@ -685,11 +675,11 @@ void con_tcx( move16(); test(); test(); - IF (sub(st->last_good_fx , UNVOICED_CLAS) == 0 && sub(st->core_ext_mode , UNVOICED) != 0) + IF (EQ_16(st->last_good_fx , UNVOICED_CLAS)&&NE_16(st->core_ext_mode,UNVOICED)) { gain_inov = mult_r(gain_inov,26214/*0.8f Q15*/); } - ELSE IF (!( sub(st->last_good_fx , UNVOICED_CLAS) == 0 || sub(st->last_good_fx , UNVOICED_TRANSITION) == 0 )) + ELSE IF (!( EQ_16(st->last_good_fx , UNVOICED_CLAS)||EQ_16(st->last_good_fx,UNVOICED_TRANSITION))) { /*gain_inov *= (1.1f- 0.75*st->lp_gainp);*/ L_tmp = Mpy_32_16_1(L_sub(590558016l/*1.1f Q29*/, Mpy_32_16_1(st->Mode2_lp_gainp,24576))/*Q29*/,gain_inov/*Q15,gain_inov_e*/);/*Q29,gain_inov_e*/ @@ -738,7 +728,7 @@ void con_tcx( * Construct the total excitation *-----------------------------------------------------------------*/ - IF( sub(st->last_good_fx , UNVOICED_TRANSITION) >= 0 ) + IF( GE_16(st->last_good_fx , UNVOICED_TRANSITION)) { tmp16 = add(L_frame,shr(L_frame,1)); FOR( i=0 ; i< tmp16; i++ ) @@ -751,7 +741,7 @@ void con_tcx( bufferCopyFx(noise+L_FIR_FER2/2, exc, add(L_frame , shr(L_frame,1)),0/*Q_noise*/, noise_e, Q_exc, 0/*exc_e*/); Copy(exc+L_frame-2*L_subfr, st->old_excFB_fx, 2*L_subfr+shr(L_frame,1)); /* copy old_exc as 16kHz for acelp decoding */ - IF ( sub(st->nbLostCmpt, 1) == 0 ) + IF ( EQ_16(st->nbLostCmpt, 1)) { lerp(exc, st->old_exc_fx, L_EXC_MEM_DEC, add(L_frame, shr(L_frame,1))); } @@ -843,9 +833,9 @@ void con_tcx( /* As long as there is no synth scaling factor introduced, which is given to the outside, there might occur overflows here */ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF bufferCopyFx(syn, synth, L_frame, Q_syn, 0, 0, 0); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON Copy_Scale_sig(syn+L_frame, st->syn_OverlFB, shr(L_frame,1), negate(Q_syn)); diff --git a/lib_dec/er_scale_syn.c b/lib_dec/er_scale_syn.c index 9e6c97cf1f8a8a314bcbf40b6f4f3018477560f4..94405ccfa7d0112d42c7954b92d6364322a6e723 100644 --- a/lib_dec/er_scale_syn.c +++ b/lib_dec/er_scale_syn.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ /*This file is up to date with trunk rev 36531*/ @@ -10,8 +10,6 @@ #include "basop_util.h" #include "cnst_fx.h" #include "stl.h" -#include "wmc_auto.h" - /*----------------------------------------------------------------------------------* @@ -44,19 +42,19 @@ Word16 Damping_fact( /* o : damping factor test();/*ELSEIF*/ test(); test();/*ELSEIF*/ - IF( ( sub(coder_type, UNVOICED) == 0) && (sub(nbLostCmpt, 3) <= 0)) /* Clear unvoiced last good frame */ + IF( ( EQ_16(coder_type, UNVOICED))&&(LE_16(nbLostCmpt,3))) /* Clear unvoiced last good frame */ { alpha = mult_r(_ALPHA_UU_FX,16384); /*Q14*/ } - ELSE IF( sub(last_good, UNVOICED_CLAS) == 0 ) + ELSE IF( EQ_16(last_good, UNVOICED_CLAS)) { - IF( sub(nbLostCmpt,1) == 0 ) + IF( EQ_16(nbLostCmpt,1)) { /* If stable, do not decrease the energy, pitch gain = 0 */ /* * (1.0f - 2.0f*_ALPHA_U_FX) + 2.0f*MODE2_ALPHA_U; */ /* [0.8, 1.0] */ alpha = add(mult_r(stab_fac,sub(16384,_ALPHA_U_FX)),_ALPHA_U_FX); } - ELSE IF (sub(nbLostCmpt, 2) == 0 ) + ELSE IF (EQ_16(nbLostCmpt, 2)) { /*alpha = _ALPHA_U_FX * 1.5f;*/ /* 0.6 */ alpha = mult_r(_ALPHA_U_FX, 24576/*1.5f Q14*/); /*Q14*/ @@ -66,25 +64,25 @@ Word16 Damping_fact( /* o : damping factor alpha = mult_r(_ALPHA_U_FX,16384); /*Q14*/ /* 0.4 go rapidly to CNG gain, pitch gain = 0 */ } } - ELSE IF( sub(last_good, UNVOICED_TRANSITION) == 0 ) + ELSE IF( EQ_16(last_good, UNVOICED_TRANSITION)) { alpha = mult_r(_ALPHA_UT_FX,16384); /*Q14*/ } - ELSE IF( (sub(last_good, ONSET) == 0) && (sub(nbLostCmpt, 3) <= 0 ) && (sub(coder_type, GENERIC) == 0)) + ELSE IF( (EQ_16(last_good, ONSET))&&(LE_16(nbLostCmpt,3))&&(EQ_16(coder_type,GENERIC))) { alpha = 13107/*0.8f Q14*/; /*Q14*/ } - ELSE if( ( (sub(last_good, VOICED_CLAS) == 0) || (sub(last_good,ONSET) == 0) ) && (sub(nbLostCmpt, 3) <= 0) ) + ELSE if( ( (EQ_16(last_good, VOICED_CLAS))||(EQ_16(last_good,ONSET)))&&(LE_16(nbLostCmpt,3))) { alpha = mult_r(_ALPHA_V_FX,16384); /* constant for the first 3 erased frames */ } - IF (sub(last_good, VOICED_CLAS) >= 0 ) + IF (GE_16(last_good, VOICED_CLAS)) { move16(); lp_tmp = *lp_gainp; - IF( sub(nbLostCmpt, 1) == 0 ) /* if first erased frame in a block, reset harmonic gain */ + IF( EQ_16(nbLostCmpt, 1)) /* if first erased frame in a block, reset harmonic gain */ { /*lp_gainp_E = 1;*/ /*For sqrt, because *lp_gain is Q14 */ @@ -99,7 +97,7 @@ Word16 Damping_fact( /* o : damping factor gain = s_max(gain, 27853/*0.85f Q15*/); /*Q15*/ alpha = mult_r(alpha , gain); /*Q14*/ } - ELSE IF ( sub(nbLostCmpt, 2) == 0 ) + ELSE IF ( EQ_16(nbLostCmpt, 2)) { /*0.6 + 0.35*stab_fac*/ alpha = mult_r(mac_r(1288490240l/*0.6f Q31*/, 11469/*0.35f Q15*/, stab_fac), round_fx(L_shl(lp_tmp,1))); @@ -117,11 +115,11 @@ Word16 Damping_fact( /* o : damping factor ELSE { alpha = mac_r(375809632l/*0.35f Q30*/,6554/*0.4f Q14*/,stab_fac); /*Q14*/ - if (sub(nbLostCmpt,2)< 0 ) + if (LT_16(nbLostCmpt,2)) { alpha = mac_r(751619264l/*0.70f Q30*/,4915/*0.3f Q14*/,stab_fac); /*Q14*/ } - if (sub(nbLostCmpt, 2)==0) + if (EQ_16(nbLostCmpt, 2)) { alpha = mac_r(483183808l/*0.45f Q30*/,6554/*0.4f Q14*/,stab_fac); /*Q14*/ } diff --git a/lib_dec/er_sync_exc.c b/lib_dec/er_sync_exc.c index c5a6977f3ced467d978088cf819f6bb2beb8399d..591db9aae446051427eeb78342f36dd13d80e38b 100644 --- a/lib_dec/er_sync_exc.c +++ b/lib_dec/er_sync_exc.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ /*This BASOP port is up to date with trunk rev. 36554*/ #include "cnst_fx.h" #include "stl.h" -#include "wmc_auto.h" - #include "prot_fx.h" #include #include @@ -57,14 +55,14 @@ static Word16 GetMinimumPosition( tmp16 = shr(x[i],tmp_e); energy = L_msu(energy_old,tmp16,tmp16); tmp16 = shr(x[i+filterLength],tmp_e); - BASOP_SATURATE_WARNING_OFF;/*Saturation will be handled*/ + BASOP_SATURATE_WARNING_OFF /*Saturation will be handled*/ energy = L_mac(energy,tmp16,tmp16); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON /*if (energy == MAXVAL_WORD32)*/ - BASOP_SATURATE_WARNING_OFF;/*saturates if energy < 0*/ + BASOP_SATURATE_WARNING_OFF /*saturates if energy < 0*/ tmptest = L_sub(energy,MAXVAL_WORD32); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON IF (tmptest == 0) { tmp_e = add(tmp_e,1); @@ -111,7 +109,7 @@ static Word16 FindMaxPeak move16(); FOR (i = 1; i < length; i++) { - if (sub(abs_s(x[i]) , abs_s(x[iMax]))>0) + if (GT_16(abs_s(x[i]) , abs_s(x[iMax]))) { move16(); iMax = i; @@ -249,16 +247,16 @@ void PulseResynchronization( test(); test(); test(); - IF ((L_sub(L_deposit_h(nFrameLength),pitchStart) < 0) + IF ((LT_32(L_deposit_h(nFrameLength),pitchStart)) || (pitchStart <= 0) || (pitchEnd <= 0) - || (sub(nSubframes, 1) < 0) - || (sub(nSubframes, 5) > 0) - || (L_sub(Mpy_32_16_1(pitchEnd,add(nSubframes,1)),Mpy_32_16_1(pitchStart,sub(nSubframes,1))) <= 0) + || (LT_16(nSubframes, 1) ) + || (GT_16(nSubframes, 5) ) + || (LE_32(Mpy_32_16_1(pitchEnd,add(nSubframes,1)),Mpy_32_16_1(pitchStart,sub(nSubframes,1)))) || (src_exc-dst_exc >= 0)) { /* This is error handling and recovery that should never occur. */ test(); - IF (src_exc != dst_exc && sub(nFrameLength, 1200) <= 0) + IF (src_exc != dst_exc && LE_16(nFrameLength, 1200)) { Copy(src_exc, dst_exc, nFrameLength); } @@ -276,7 +274,7 @@ void PulseResynchronization( /*samplesDelta = 0.5f*pitchDelta*nFrameLength*(nSubframes+1)*freqStart;*/ /* pitchDelta*freqStart = ((pitchEnd - pitchStart)/roundedPitchStart)/nSubframes */ tmp16 = shl(roundedPitchStart, 2); /*Q0*/ - if (sub(nSubframes, 5) == 0) + if (EQ_16(nSubframes, 5)) { tmp16 = add(tmp16, roundedPitchStart);/*Q0*/ /*tmp16=roundedPitchStart*nSubframes*/ } @@ -329,7 +327,7 @@ void PulseResynchronization( tmp32 = L_add(tmp32,65536l/*1.f Q16*/); k=extract_h(tmp32); test(); - IF ((k >= 0) && sub(add(k,1) , NB_PULSES_MAX)<=0) + IF ((k >= 0) && LE_16(add(k,1) , NB_PULSES_MAX)) { absPitchDiff = L_abs(L_sub(L_deposit_h(roundedPitchStart),pitchEnd));/*Q16*/ @@ -402,7 +400,7 @@ void PulseResynchronization( cycleDelta32 = L_max(0, cycleDelta32); /* Make sure that the number of samples increases */ - IF (L_sub(L_deposit_h(roundedCycleDelta), cycleDelta32) > 0) + IF (GT_32(L_deposit_h(roundedCycleDelta), cycleDelta32)) { iDeltaSamples[i] = roundedCycleDelta; move16(); @@ -446,7 +444,7 @@ void PulseResynchronization( { /* Find the location of the minimum energy before the first pulse */ - IF (sub(iMinPos1 , add(roundedPitchStart , shr(iDeltaSamples[0],1))) > 0 ) + IF (GT_16(iMinPos1 , add(roundedPitchStart , shr(iDeltaSamples[0],1)))) { iMinPos[0] = sub(iMinPos1 , sub(roundedPitchStart , shr(iDeltaSamples[0],1))); move16(); @@ -465,7 +463,7 @@ void PulseResynchronization( } /* Find the location of the minimum energy after the last pulse */ - IF (sub(add(iMinPos1 , add(imult1616(k,roundedPitchStart) , sub(iDeltaSamples[k+1] , shr(iDeltaSamples[k+1],1)))) , sub(nFrameLength,nSamplesDelta) ) < 0) + IF (LT_16(add(iMinPos1 , add(imult1616(k,roundedPitchStart) , sub(iDeltaSamples[k+1] , shr(iDeltaSamples[k+1],1)))) , sub(nFrameLength,nSamplesDelta) )) { move16(); iMinPos[k+1] = add(iMinPos1 , sub(imult1616(k,roundedPitchStart) , shr(iDeltaSamples[k+1],1))); @@ -482,7 +480,7 @@ void PulseResynchronization( move16(); } - IF (sub(add(iMinPos[k+1],iDeltaSamples[k+1]) , sub(nFrameLength,nSamplesDelta)) > 0 ) + IF (GT_16(add(iMinPos[k+1],iDeltaSamples[k+1]) , sub(nFrameLength,nSamplesDelta))) { iDeltaSamples[k] += add(iMinPos[k+1] , sub(iDeltaSamples[k+1] , sub(nFrameLength,nSamplesDelta))); iDeltaSamples[k+1] = sub(nFrameLength , add(nSamplesDelta , iMinPos[k+1])); @@ -494,7 +492,7 @@ void PulseResynchronization( ELSE { /* Find the location of the minimum energy before the first pulse */ - IF (sub(iMinPos1 , roundedPitchStart) > 0 ) + IF (GT_16(iMinPos1 , roundedPitchStart)) { iMinPos[0] = sub(iMinPos1 , roundedPitchStart); move16(); @@ -514,7 +512,7 @@ void PulseResynchronization( } /* Find the location of the minimum energy after the last pulse */ - IF (sub(iMinPos1 , sub(nFrameLength,nSamplesDelta)) < 0) + IF (LT_16(iMinPos1 , sub(nFrameLength,nSamplesDelta))) { iMinPos[k+1] = iMinPos1; move16(); @@ -528,7 +526,7 @@ void PulseResynchronization( move16(); } - IF (sub(add(iMinPos[k+1],iDeltaSamples[k+1]) , sub(nFrameLength,nSamplesDelta)) > 0 ) + IF (GT_16(add(iMinPos[k+1],iDeltaSamples[k+1]) , sub(nFrameLength,nSamplesDelta))) { move16(); move16(); diff --git a/lib_dec/er_util.c b/lib_dec/er_util.c index 3f23f0cf327d7a003e4b2b21cbe1bc983e2e9544..ed0cf17caa17b4768137c37af324a896e6c97d81 100644 --- a/lib_dec/er_util.c +++ b/lib_dec/er_util.c @@ -1,12 +1,10 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" #include "stl.h" -#include "wmc_auto.h" - #include "prot_fx.h" #include "basop_util.h" #include @@ -51,16 +49,16 @@ void minimumStatistics(Word16* noiseLevelMemory, /* Qx, internal stat aOpt_e = 0; - BASOP_SATURATE_WARNING_ON; - IF (sub(shl(currentFrameLevel, currentFrameLevel_e),PLC_MIN_CNG_LEV) < 0) + BASOP_SATURATE_WARNING_OFF + IF (LT_16(shl(currentFrameLevel, currentFrameLevel_e),PLC_MIN_CNG_LEV)) { - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON currentFrameLevel = PLC_MIN_CNG_LEV; move16(); move16(); currentFrameLevel_e = 0; } - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON /* compute optimal factor aOpt for recursive smoothing of frame minima */ tmp2 = BASOP_Util_Add_MantExp(*lastFrameLevel,*lastFrameLevel_e,negate(*noiseEstimate),noiseEstimate_e,&tmp); @@ -136,7 +134,7 @@ void minimumStatistics(Word16* noiseLevelMemory, /* Qx, internal stat setnoiseLevelMemory(f,new_noiseEstimate_e, noiseLevelMemory_e, noiseLevelMemory, currLevelIndex); /* current min is not a new min, so check if min must be re-searched */ - IF (sub(p, *currLevelIndex) != 0) + IF (NE_16(p, *currLevelIndex)) { f = noiseLevelMemory[p]; /* min is still in memory, so return it */ move16(); @@ -165,7 +163,7 @@ void minimumStatistics(Word16* noiseLevelMemory, /* Qx, internal stat p = add(*currLevelIndex,1); *currLevelIndex = add(*currLevelIndex, 1); move16(); - if (sub(*currLevelIndex, PLC_MIN_STAT_BUFF_SIZE) == 0) + if (EQ_16(*currLevelIndex, PLC_MIN_STAT_BUFF_SIZE)) { *currLevelIndex = 0; move16(); @@ -240,7 +238,7 @@ Word16 getLevelSynDeemph( /*10Q5*/ tmp16 = 32767/*1.0f Q15*/; move16(); - if (sub(numLoops , 1) > 0) + if (GT_16(numLoops , 1)) { tmp16 = div_s(1,numLoops); } @@ -265,7 +263,7 @@ void genPlcFiltBWAdap(const Word32 sr_core, Word16 *lpFiltAdapt, const Word16 ty assert(type == 0 || type == 1); - IF ( L_sub(sr_core, 16000) == 0 ) + IF ( EQ_32(sr_core, 16000)) { IF (type == 0) { @@ -337,7 +335,7 @@ void highPassFiltering( { Word16 i; /*int*/ - IF( sub(last_good , UNVOICED_TRANSITION)> 0 ) + IF( GT_16(last_good , UNVOICED_TRANSITION)) { FOR( i=0 ; i< L_buffer; i++ ) @@ -359,7 +357,7 @@ Word16 GetPLCModeDecision( Word16 numIndices = 0; - IF( sub(st->flagGuidedAcelp,1) == 0 ) + IF( EQ_16(st->flagGuidedAcelp,1)) { st->old_pitch_buf_fx[2*st->nb_subfr] = L_deposit_h(st->guidedT0); st->old_pitch_buf_fx[2*st->nb_subfr+1] = L_deposit_h(st->guidedT0); @@ -370,7 +368,7 @@ Word16 GetPLCModeDecision( test(); test(); if(( st->last_core_fx > ACELP_CORE && st->tcxltp_last_gain_unmodified!=0 ) - || ( sub(st->flagGuidedAcelp,1) == 0 ) + || ( EQ_16(st->flagGuidedAcelp,1) ) ) { /* no updates needed here, because already updated in last good frame */ @@ -378,7 +376,7 @@ Word16 GetPLCModeDecision( move16(); } - IF (sub(st->last_core_fx,-1) == 0) + IF (EQ_16(st->last_core_fx,-1)) { core = TCX_20_CORE; move16(); @@ -396,19 +394,19 @@ Word16 GetPLCModeDecision( { core = ACELP_CORE; move16(); - if (sub(st->nbLostCmpt,1) > 0) + if (GT_16(st->nbLostCmpt,1)) { core = st->last_core_bfi; move16(); } - IF (sub(st->nbLostCmpt,1) == 0) + IF (EQ_16(st->nbLostCmpt,1)) { st->tonal_mdct_plc_active = 0; move16(); test(); test(); test(); - IF ( !(st->rf_flag && st->use_partial_copy && (sub(st->rf_frame_type, RF_TCXTD1) == 0 || sub(st->rf_frame_type, RF_TCXTD2) == 0))) + IF ( !(st->rf_flag && st->use_partial_copy && (EQ_16(st->rf_frame_type, RF_TCXTD1)||EQ_16(st->rf_frame_type,RF_TCXTD2)))) { test(); test(); @@ -416,13 +414,13 @@ Word16 GetPLCModeDecision( test(); test(); test(); - IF ((sub(st->last_core_fx,TCX_20_CORE) == 0) && (sub(st->second_last_core,TCX_20_CORE) == 0) - && ((L_sub(st->old_fpitch,L_deposit_h(shr(st->L_frame_fx,1)))) <= 0 - || (sub(st->tcxltp_last_gain_unmodified,13107/*0.4f Q15*/) <= 0)) + IF ((EQ_16(st->last_core_fx,TCX_20_CORE))&&(EQ_16(st->second_last_core,TCX_20_CORE)) + && ((LE_32(st->old_fpitch,L_deposit_h(shr(st->L_frame_fx,1)))) + || (LE_16(st->tcxltp_last_gain_unmodified,13107/*0.4f Q15*/))) /* it is fine to call the detection even if no ltp information is available, meaning that st->old_fpitch == st->tcxltp_second_last_pitch == st->L_frame */ - && (L_sub(st->old_fpitch, st->tcxltp_second_last_pitch) == 0) + && (EQ_32(st->old_fpitch, st->tcxltp_second_last_pitch)) && !st->last_tns_active && !st->second_last_tns_active) { Word32 pitch; @@ -443,18 +441,18 @@ Word16 GetPLCModeDecision( test(); test(); test(); - IF ((sub(numIndices,10) > 0) - || ((sub(numIndices,5) > 0) - && (L_sub(L_abs(L_sub(st->tcxltp_third_last_pitch,st->tcxltp_second_last_pitch)),32768l/*0.5f Q16*/) < 0)) - || ((numIndices > 0) && ((sub(st->last_good_fx,UNVOICED_TRANSITION) <= 0) || (sub(st->tcxltp_last_gain_unmodified,13107/*0.4f Q15*/) <= 0)) - && (L_sub(L_abs(L_sub(st->tcxltp_third_last_pitch,st->tcxltp_second_last_pitch)),32768l/*0.5f Q16*/) < 0))) + IF ((GT_16(numIndices,10)) + || ((GT_16(numIndices,5) ) + && (LT_32(L_abs(L_sub(st->tcxltp_third_last_pitch,st->tcxltp_second_last_pitch)),32768l/*0.5f Q16*/) )) + || ((numIndices > 0) && ((LE_16(st->last_good_fx,UNVOICED_TRANSITION))||(LE_16(st->tcxltp_last_gain_unmodified,13107/*0.4f Q15*/))) + && (LT_32(L_abs(L_sub(st->tcxltp_third_last_pitch,st->tcxltp_second_last_pitch)),32768l/*0.5f Q16*/) ))) { core = TCX_20_CORE; move16(); st->tonal_mdct_plc_active = 1; move16(); } - ELSE IF (sub(st->last_good_fx,UNVOICED_TRANSITION) <= 0 || sub(st->tcxltp_last_gain_unmodified,13107/*0.4f Q15*/)<=0) + ELSE IF (LE_16(st->last_good_fx,UNVOICED_TRANSITION)||LE_16(st->tcxltp_last_gain_unmodified,13107/*0.4f Q15*/)) { core = TCX_20_CORE; move16(); @@ -463,7 +461,7 @@ Word16 GetPLCModeDecision( ELSE IF (st->last_core_fx != ACELP_CORE) { test(); - if (sub(st->last_good_fx,UNVOICED_TRANSITION) <= 0 || sub(st->tcxltp_last_gain_unmodified,13107/*0.4f Q15*/)<=0) + if (LE_16(st->last_good_fx,UNVOICED_TRANSITION)||LE_16(st->tcxltp_last_gain_unmodified,13107/*0.4f Q15*/)) { core = st->last_core_fx; move16(); diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index 812984860e0582e404a753a3d8fd125158a5583e..d702a1bbf72afd1e9fe4905ee7833fb2d1314f3c 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -7,9 +7,7 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "basop_util.h" /* Function prototypes */ -#include "stl.h" -#include "wmc_auto.h" - /* required for wmc_tool */ +#include "stl.h" /* required for wmc_tool */ #include /* Debug prototypes */ @@ -106,7 +104,7 @@ void evs_dec_fx( Qpostd_prev = st_fx->Qprev_synth_buffer_fx; move16(); - IF( sub(st_fx->bfi_fx,1) == 0 ) + IF( EQ_16(st_fx->bfi_fx,1)) { hq_core_type = st_fx->last_hq_core_type_fx; move16(); @@ -129,9 +127,9 @@ void evs_dec_fx( test(); IF (!st_fx->bfi_fx && st_fx->prev_bfi_fx - && (sub(st_fx->last_codec_mode, MODE2) == 0) - && (sub(st_fx->last_core_bfi, TCX_20_CORE) == 0 - || sub(st_fx->last_core_bfi, TCX_10_CORE) == 0)) + && (EQ_16(st_fx->last_codec_mode, MODE2) ) + && (EQ_16(st_fx->last_core_bfi, TCX_20_CORE) + || EQ_16(st_fx->last_core_bfi, TCX_10_CORE) )) { /* v_multc(st_fx->old_out_fx, st_fx->plcInfo.recovery_gain, */ /* st_fx->old_out_fx, st_fx->L_frameTCX); */ @@ -189,12 +187,12 @@ void evs_dec_fx( * Updates in case of AMR-WB IO mode -> EVS primary switching *----------------------------------------------------------------*/ - IF( sub(st_fx->last_core_fx,AMR_WB_CORE) == 0 ) + IF( EQ_16(st_fx->last_core_fx,AMR_WB_CORE)) { updt_IO_switch_dec_fx( output_frame, st_fx ); } - IF( sub(frameMode,FRAMEMODE_MISSING) != 0 ) /* frame mode normal or future frame */ + IF( NE_16(frameMode,FRAMEMODE_MISSING)) /* frame mode normal or future frame */ { getPartialCopyInfo(st_fx, &coder_type, &sharpFlag); @@ -202,7 +200,7 @@ void evs_dec_fx( } test(); - IF( sub(st_fx->rf_frame_type,RF_NO_DATA) == 0 && sub(st_fx->use_partial_copy,1)==0 ) + IF( EQ_16(st_fx->rf_frame_type,RF_NO_DATA)&&EQ_16(st_fx->use_partial_copy,1)) { /* the partial copy is a RF FRAME_NO_DATA frame and should follow the concealment path*/ st_fx->bfi_fx = 1; @@ -219,8 +217,8 @@ void evs_dec_fx( test(); test(); test(); - IF( sub(st_fx->use_partial_copy,1)==0 && sub(st_fx->core_fx,TCX_20_CORE)==0 && - sub(st_fx->prev_bfi_fx,1)==0 && sub(st_fx->last_core_fx,ACELP_CORE)==0 ) + IF( EQ_16(st_fx->use_partial_copy,1)&&EQ_16(st_fx->core_fx,TCX_20_CORE)&& + EQ_16(st_fx->prev_bfi_fx,1) && EQ_16(st_fx->last_core_fx,ACELP_CORE) ) { st_fx->bfi_fx = 1; move16(); @@ -253,17 +251,17 @@ void evs_dec_fx( * Decoding *-----------------------------------------------------------------*/ - IF( sub(st_fx->codec_mode,MODE1) == 0 ) + IF( EQ_16(st_fx->codec_mode,MODE1)) { /*------------------------------------------------------------------* * Decision matrix (selection of technologies) *-----------------------------------------------------------------*/ - IF ( sub(st_fx->bfi_fx,1) != 0 ) + IF ( NE_16(st_fx->bfi_fx,1)) { decision_matrix_dec_fx( st_fx, &coder_type, &sharpFlag, &hq_core_type, &core_switching_flag ); - IF( sub(st_fx->bfi_fx,1) != 0 ) + IF( NE_16(st_fx->bfi_fx,1)) { st_fx->sr_core = i_mult(st_fx->L_frame_fx,50); st_fx->fscale_old = st_fx->fscale; @@ -277,13 +275,13 @@ void evs_dec_fx( } } - IF( sub(st_fx->codec_mode,MODE1) == 0 ) + IF( EQ_16(st_fx->codec_mode,MODE1)) { /*------------------------------------------------------------------* * Initialization *-----------------------------------------------------------------*/ - IF( sub(st_fx->bfi_fx,1) == 0 ) + IF( EQ_16(st_fx->bfi_fx,1)) { st_fx->nbLostCmpt = add(st_fx->nbLostCmpt,1); } @@ -311,7 +309,7 @@ void evs_dec_fx( * ACELP core decoding * HQ core decoding *---------------------------------------------------------------------*/ - IF ( sub(st_fx->core_fx,ACELP_CORE) == 0 ) + IF ( EQ_16(st_fx->core_fx,ACELP_CORE)) { /* ACELP core decoder */ acelp_core_dec_fx( st_fx, synth_fx, bwe_exc_extended_fx, voice_factors_fx, old_syn_12k8_16k_fx, coder_type, sharpFlag, pitch_buf_fx, &unbits, &sid_bw ); @@ -342,12 +340,12 @@ void evs_dec_fx( * WB BWE decoding *---------------------------------------------------------------------*/ - IF ( sub(st_fx->extl_fx,WB_TBE) == 0 ) + IF ( EQ_16(st_fx->extl_fx,WB_TBE)) { /* WB TBE decoder */ wb_tbe_dec_fx( st_fx, coder_type, bwe_exc_extended_fx, st_fx->Q_exc, voice_factors_fx, hb_synth_fx, &hb_synth_fx_exp ); } - ELSE IF ( sub(st_fx->extl_fx,WB_BWE) == 0 && st_fx->bws_cnt_fx == 0) + ELSE IF ( EQ_16(st_fx->extl_fx,WB_BWE)&&st_fx->bws_cnt_fx==0) { /* WB BWE decoder */ hb_synth_fx_exp = wb_bwe_dec_fx( synth_fx, hb_synth_fx, output_frame, coder_type, voice_factors_fx, pitch_buf_fx, st_fx, &Qpostd ); @@ -369,10 +367,10 @@ void evs_dec_fx( test(); test(); test(); - IF ( sub(st_fx->extl_fx,SWB_TBE) == 0 || sub(st_fx->extl_fx,FB_TBE) == 0 - || (sub(coder_type,AUDIO) != 0 && sub(coder_type,INACTIVE) != 0 && L_sub(st_fx->core_brate_fx,SID_2k40) > 0 && sub(st_fx->core_fx,ACELP_CORE) == 0 - && L_sub(st_fx->output_Fs_fx,32000) >= 0 && sub(st_fx->bwidth_fx,NB) > 0 && st_fx->bws_cnt_fx > 0 && !st_fx->ppp_mode_dec_fx - && !( sub( st_fx->nelp_mode_dec_fx, 1) == 0 && sub( st_fx->bfi_fx, 1) == 0 ) ) ) + IF ( EQ_16(st_fx->extl_fx,SWB_TBE)||EQ_16(st_fx->extl_fx,FB_TBE) + || (NE_16(coder_type,AUDIO) && NE_16(coder_type,INACTIVE) && GT_32(st_fx->core_brate_fx,SID_2k40) && EQ_16(st_fx->core_fx,ACELP_CORE) + && GE_32(st_fx->output_Fs_fx,32000) && GT_16(st_fx->bwidth_fx,NB) && st_fx->bws_cnt_fx > 0 && !st_fx->ppp_mode_dec_fx + && !( EQ_16( st_fx->nelp_mode_dec_fx, 1) && EQ_16( st_fx->bfi_fx, 1) ) ) ) { swb_tbe_dec_fx( st_fx, coder_type, bwe_exc_extended_fx, st_fx->Q_exc, voice_factors_fx, @@ -380,19 +378,19 @@ void evs_dec_fx( /* FB TBE decoder/synthesis */ test(); - IF ( sub(output_frame,L_FRAME48k) == 0 && sub(st_fx->extl_fx,FB_TBE) == 0 ) + IF ( EQ_16(output_frame,L_FRAME48k)&&EQ_16(st_fx->extl_fx,FB_TBE)) { fb_tbe_dec_fx( st_fx, fb_exc_fx, Q_fb_exc, hb_synth_fx, hb_synth_fx_exp); } } - ELSE IF( sub(st_fx->extl_fx,SWB_BWE) == 0 || sub(st_fx->extl_fx,FB_BWE) == 0 || - (L_sub(st_fx->output_Fs_fx,32000) >= 0 && sub(st_fx->core_fx,ACELP_CORE) == 0 && sub(st_fx->bwidth_fx,NB) > 0 && st_fx->bws_cnt_fx > 0 && !st_fx->ppp_mode_dec_fx - && !( sub( st_fx->nelp_mode_dec_fx, 1) == 0 && sub( st_fx->bfi_fx, 1) == 0 ) ) ) + ELSE IF( EQ_16(st_fx->extl_fx,SWB_BWE)||EQ_16(st_fx->extl_fx,FB_BWE)|| + (GE_32(st_fx->output_Fs_fx,32000) && EQ_16(st_fx->core_fx,ACELP_CORE) && GT_16(st_fx->bwidth_fx,NB) && st_fx->bws_cnt_fx > 0 && !st_fx->ppp_mode_dec_fx + && !( EQ_16( st_fx->nelp_mode_dec_fx, 1) && EQ_16( st_fx->bfi_fx, 1) ) ) ) { /* SWB BWE decoder */ hb_synth_fx_exp = swb_bwe_dec_fx( st_fx, synth_fx, hb_synth_fx, output_frame, &Qpostd, coder_type ); } - ELSE IF( sub(st_fx->extl_fx,SWB_BWE_HIGHRATE) == 0 || sub(st_fx->extl_fx,FB_BWE_HIGHRATE) == 0 ) + ELSE IF( EQ_16(st_fx->extl_fx,SWB_BWE_HIGHRATE)||EQ_16(st_fx->extl_fx,FB_BWE_HIGHRATE)) { hb_synth_fx_exp = swb_bwe_dec_hr_fx( st_fx, old_syn_12k8_16k_fx, Qpostd, hb_synth_fx, output_frame, unbits, pitch_buf_fx ); } @@ -403,11 +401,11 @@ void evs_dec_fx( test(); test(); - IF ( st_fx->prev_bfi_fx && sub(st_fx->last_core_fx,HQ_CORE) == 0 && sub(st_fx->extl_fx,-1) != 0 ) + IF ( st_fx->prev_bfi_fx && EQ_16(st_fx->last_core_fx,HQ_CORE)&&NE_16(st_fx->extl_fx,-1)) { /*tmp = FRAC_BWE_SMOOTH/output_frame;*/ tmp16 = shr(410,shr(output_frame,8)); - if(sub(output_frame, L_FRAME48k)==0) + if(EQ_16(output_frame, L_FRAME48k)) { tmp16 = 68; move16(); @@ -428,13 +426,13 @@ void evs_dec_fx( /*---------------------------------------------------------------------* * SWB CNG *---------------------------------------------------------------------*/ - IF( sub(output_frame,L_FRAME32k) >= 0 ) + IF( GE_16(output_frame,L_FRAME32k)) { /* SHB CNG decoder */ swb_CNG_dec_fx( st_fx, synth_fx, hb_synth_fx, sid_bw, Qpostd ); test(); - if( L_sub(st_fx->core_brate_fx, SID_2k40) <= 0 && st_fx->bws_cnt_fx == 0 ) + if( LE_32(st_fx->core_brate_fx, SID_2k40)&&st_fx->bws_cnt_fx==0) { hb_synth_fx_exp = 3; move16(); @@ -445,7 +443,7 @@ void evs_dec_fx( * Delay ACELP core synthesis to be synchronized with the components of bandwidth extension layers *----------------------------------------------------------------*/ - IF ( sub(output_frame,L_FRAME16k) >= 0 ) + IF ( GE_16(output_frame,L_FRAME16k)) { tmps = NS2SA_fx2(st_fx->output_Fs_fx, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS); @@ -480,17 +478,17 @@ void evs_dec_fx( test(); test(); test(); - IF (sub(st_fx->core_fx,ACELP_CORE) == 0 + IF (EQ_16(st_fx->core_fx,ACELP_CORE) && !st_fx->bfi_fx && st_fx->prev_bfi_fx - && L_sub(st_fx->last_total_brate_fx, HQ_48k) >= 0 - && sub(st_fx->last_codec_mode, MODE2) == 0 - && (sub(st_fx->last_core_bfi, TCX_20_CORE) == 0 || sub(st_fx->last_core_bfi, TCX_10_CORE) == 0) + && GE_32(st_fx->last_total_brate_fx, HQ_48k) + && EQ_16(st_fx->last_codec_mode, MODE2) + && (EQ_16(st_fx->last_core_bfi, TCX_20_CORE) || EQ_16(st_fx->last_core_bfi, TCX_10_CORE) ) && st_fx->plcInfo.concealment_method == TCX_NONTONAL - && L_sub(st_fx->plcInfo.nbLostCmpt, 4) < 0 ) + && LT_32(st_fx->plcInfo.nbLostCmpt, 4) ) { tmps = 0; - IF( sub(output_frame,L_FRAME16k) >= 0 ) + IF( GE_16(output_frame,L_FRAME16k)) { tmps = NS2SA_fx2(st_fx->output_Fs_fx, DELAY_BWE_TOTAL_NS); } @@ -517,10 +515,10 @@ void evs_dec_fx( test(); test(); - IF ( sub(st_fx->extl_fx,-1) != 0 || (st_fx->bws_cnt_fx > 0 && sub(st_fx->core_fx,ACELP_CORE) == 0) ) + IF ( NE_16(st_fx->extl_fx,-1)||(st_fx->bws_cnt_fx>0&&EQ_16(st_fx->core_fx,ACELP_CORE))) { /* Calculate an additional delay of extension layer components to be synchronized with ACELP synthesis */ - IF ( sub(st_fx->L_frame_fx,L_FRAME) == 0 ) + IF ( EQ_16(st_fx->L_frame_fx,L_FRAME)) { /* TBE on top of ACELP@12.8kHz */ tmps = NS2SA_fx2( st_fx->output_Fs_fx, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_12k8_NS ); @@ -528,7 +526,7 @@ void evs_dec_fx( ELSE { test(); - IF( sub(st_fx->extl_fx,SWB_BWE_HIGHRATE) == 0 || sub(st_fx->extl_fx,FB_BWE_HIGHRATE) == 0 ) + IF( EQ_16(st_fx->extl_fx,SWB_BWE_HIGHRATE)||EQ_16(st_fx->extl_fx,FB_BWE_HIGHRATE)) { /* HR SWB BWE on top of ACELP@16kHz */ tmps = NS2SA_fx2( st_fx->output_Fs_fx, DELAY_BWE_TOTAL_NS ); @@ -545,8 +543,8 @@ void evs_dec_fx( test(); test(); test(); - IF ( (sub(st_fx->extl_fx,st_fx->last_extl_fx) != 0 || (sub(st_fx->extl_fx,st_fx->last_extl_fx) == 0 && sub((st_fx->core_fx ^ st_fx->last_core_fx),HQ_CORE) == 0)) - && !(sub(st_fx->extl_fx,SWB_CNG) == 0 && sub(st_fx->last_extl_fx,SWB_TBE) == 0) ) + IF ( (NE_16(st_fx->extl_fx,st_fx->last_extl_fx)||(EQ_16(st_fx->extl_fx,st_fx->last_extl_fx)&&EQ_16((st_fx->core_fx^st_fx->last_core_fx),HQ_CORE))) + && !(EQ_16(st_fx->extl_fx,SWB_CNG) && EQ_16(st_fx->last_extl_fx,SWB_TBE)) ) { /*incr = (short) ( L_FRAME / (tmps + 0.5f) );*/ incr = idiv1616(L_FRAME*2, add(shl(tmps,1),1)); @@ -560,7 +558,7 @@ void evs_dec_fx( } set16_fx( st_fx->hb_prev_synth_buffer_fx, 0, tmps ); } - ELSE IF ( sub(tmps,st_fx->old_bwe_delay_fx) < 0 ) + ELSE IF ( LT_16(tmps,st_fx->old_bwe_delay_fx)) { /* the previous frame was TBE on top of ACELP@16kHz and the current frame is TBE on top of ACELP@12.8kHz */ /*incr = (short) ( L_FRAME / (tmps + 0.5f) );*/ @@ -575,7 +573,7 @@ void evs_dec_fx( } Copy(tmp_buffer_fx, st_fx->hb_prev_synth_buffer_fx, tmps); } - ELSE IF (sub(tmps,st_fx->old_bwe_delay_fx) > 0) + ELSE IF (GT_16(tmps,st_fx->old_bwe_delay_fx)) { /* the previous frame was TBE on top of ACELP@12.8kHz and the current frame is TBE on top of ACELP@16kHz */ /*incr = (short)( L_FRAME / (st->old_bwe_delay + 0.5f) );*/ @@ -624,11 +622,11 @@ void evs_dec_fx( test(); test(); test(); - IF( ( st_fx->ppp_mode_dec_fx || (sub(st_fx->nelp_mode_dec_fx,1) == 0 && sub( st_fx->bfi_fx, 1 ) == 0 ) ) && sub(st_fx->L_frame_fx, st_fx->last_L_frame_fx) == 0 && (st_fx->bws_cnt_fx > 1 || st_fx->last_extl_fx != -1) ) + IF( ( st_fx->ppp_mode_dec_fx || (EQ_16(st_fx->nelp_mode_dec_fx,1)&&EQ_16(st_fx->bfi_fx,1)))&&EQ_16(st_fx->L_frame_fx,st_fx->last_L_frame_fx)&&(st_fx->bws_cnt_fx>1||st_fx->last_extl_fx!=-1)) { Copy( st_fx->old_hb_synth_fx, hb_synth_fx, output_frame ); - IF(sub(st_fx->prev_hb_synth_fx_exp, 14) < 0) + IF(LT_16(st_fx->prev_hb_synth_fx_exp, 14)) { hb_synth_fx_exp = add(st_fx->prev_hb_synth_fx_exp, 1); } @@ -646,7 +644,7 @@ void evs_dec_fx( /* SWB CNG/DTX - calculate SHB energy */ test(); - IF ( sub(output_frame, L_FRAME32k) >= 0 && sub(st_fx->extl_fx, SWB_CNG) > 0 ) + IF ( GE_16(output_frame, L_FRAME32k)&>_16(st_fx->extl_fx,SWB_CNG)) { SWITCH (output_frame) { @@ -707,17 +705,17 @@ void evs_dec_fx( concealWholeFrame = 0; move16(); - if( sub(frameMode, FRAMEMODE_NORMAL) == 0 ) + if( EQ_16(frameMode, FRAMEMODE_NORMAL)) { st_fx->m_decodeMode = DEC_NO_FRAM_LOSS; move16(); } - IF( sub(frameMode, FRAMEMODE_MISSING) == 0 ) + IF( EQ_16(frameMode, FRAMEMODE_MISSING)) { test(); test(); - IF( st_fx->use_partial_copy && sub(st_fx->rf_frame_type, RF_TCXFD) >= 0 && sub(st_fx->rf_frame_type, RF_TCXTD2) <= 0) + IF( st_fx->use_partial_copy && GE_16(st_fx->rf_frame_type, RF_TCXFD)&&LE_16(st_fx->rf_frame_type,RF_TCXTD2)) { st_fx->m_decodeMode = DEC_NO_FRAM_LOSS; move16(); @@ -797,7 +795,7 @@ void evs_dec_fx( test(); test(); - if( L_sub(st_fx->output_Fs_fx,8000) == 0 || ( L_sub(st_fx->output_Fs_fx,16000) == 0 && sub(st_fx->L_frame_fx,L_FRAME16k) == 0 ) ) + if( EQ_32(st_fx->output_Fs_fx,8000)||(EQ_32(st_fx->output_Fs_fx,16000)&&EQ_16(st_fx->L_frame_fx,L_FRAME16k))) { st_fx->extl_fx = -1; move16(); @@ -812,25 +810,25 @@ void evs_dec_fx( st_fx->tilt_wb_fx = 0; move16(); - IF( sub(st_fx->m_frame_type, ACTIVE_FRAME) == 0 ) + IF( EQ_16(st_fx->m_frame_type, ACTIVE_FRAME)) { test(); test(); IF( ( st_fx->bfi_fx == 0 || st_fx->last_core_fx == ACELP_CORE ) && st_fx->core_fx == ACELP_CORE ) { test(); - IF( sub(st_fx->extl_fx, WB_TBE) == 0 ) + IF( EQ_16(st_fx->extl_fx, WB_TBE)) { wb_tbe_dec_fx( st_fx, coder_type, bwe_exc_extended_fx, st_fx->Q_exc, voice_factors_fx, hb_synth_fx, &hb_synth_fx_exp ); } - ELSE IF( sub(st_fx->extl_fx, SWB_TBE) == 0 || sub(st_fx->extl_fx, FB_TBE) == 0 ) + ELSE IF( EQ_16(st_fx->extl_fx, SWB_TBE)||EQ_16(st_fx->extl_fx,FB_TBE)) { /* SWB TBE decoder */ swb_tbe_dec_fx( st_fx, coder_type, bwe_exc_extended_fx, st_fx->Q_exc, voice_factors_fx, st_fx->old_core_synth_fx, fb_exc_fx, &Q_fb_exc, hb_synth_fx, &hb_synth_fx_exp, pitch_buf_fx ); test(); - IF( sub(st_fx->extl_fx, FB_TBE) == 0 && sub(output_frame, L_FRAME48k) == 0 ) + IF( EQ_16(st_fx->extl_fx, FB_TBE)&&EQ_16(output_frame,L_FRAME48k)) { fb_tbe_dec_fx( st_fx, fb_exc_fx, Q_fb_exc, hb_synth_fx, hb_synth_fx_exp ); } @@ -839,19 +837,19 @@ void evs_dec_fx( } ELSE { - IF( sub(st_fx->last_core_fx,ACELP_CORE) == 0 ) + IF( EQ_16(st_fx->last_core_fx,ACELP_CORE)) { test(); test(); test(); test(); - IF( ( sub(st_fx->bwidth_fx, SWB) == 0 || sub(st_fx->bwidth_fx, FB) == 0 ) && - (( sub(st_fx->last_extl_fx, SWB_TBE) == 0 || sub(st_fx->last_extl_fx, FB_TBE) == 0) && sub(st_fx->last_codec_mode, MODE2) == 0 ) ) + IF( ( EQ_16(st_fx->bwidth_fx, SWB)||EQ_16(st_fx->bwidth_fx,FB))&& + (( EQ_16(st_fx->last_extl_fx, SWB_TBE) || EQ_16(st_fx->last_extl_fx, FB_TBE) ) && EQ_16(st_fx->last_codec_mode, MODE2) ) ) { GenTransition_fx( st_fx->syn_overlap_fx, st_fx->old_tbe_synth_fx, 2*NS2SA(st_fx->output_Fs_fx, DELAY_BWE_TOTAL_NS), hb_synth_fx, st_fx->genSHBsynth_Hilbert_Mem_fx, st_fx->genSHBsynth_state_lsyn_filt_shb_local_fx, - st_fx->mem_resamp_HB_32k_fx, - &(st_fx->syn_dm_phase_fx), st_fx->output_Fs_fx, st_fx->int_3_over_2_tbemem_dec_fx, st_fx->rf_flag, st_fx->total_brate_fx ); + st_fx->mem_resamp_HB_32k_fx, + &(st_fx->syn_dm_phase_fx), st_fx->output_Fs_fx, st_fx->int_3_over_2_tbemem_dec_fx, st_fx->rf_flag, st_fx->total_brate_fx ); hb_synth_fx_exp = st_fx->prev_Q_bwe_syn2; move16(); @@ -867,11 +865,11 @@ void evs_dec_fx( TBEreset_dec_fx( st_fx, st_fx->bwidth_fx ); } - ELSE IF ( sub(st_fx->last_codec_mode,MODE1)==0) + ELSE IF ( EQ_16(st_fx->last_codec_mode,MODE1)) { swb_tbe_reset_fx( st_fx->mem_csfilt_fx, st_fx->mem_genSHBexc_filt_down_shb_fx, st_fx->state_lpc_syn_fx, st_fx->syn_overlap_fx, st_fx->state_syn_shbexc_fx, &(st_fx->tbe_demph_fx), &(st_fx->tbe_premph_fx), st_fx->mem_stp_swb_fx, &(st_fx->gain_prec_swb_fx) ); - IF( sub(st_fx->extl_fx, FB_TBE) == 0 ) + IF( EQ_16(st_fx->extl_fx, FB_TBE)) { set16_fx( st_fx->fb_state_lpc_syn_fx, 0, LPC_SHB_ORDER ); st_fx->fb_tbe_demph_fx = 0; @@ -883,7 +881,7 @@ void evs_dec_fx( } } - IF( sub(st_fx->m_frame_type,ACTIVE_FRAME) != 0 ) + IF( NE_16(st_fx->m_frame_type,ACTIVE_FRAME)) { st_fx->extl_fx = -1; move16(); @@ -909,7 +907,7 @@ void evs_dec_fx( test(); test(); test(); - IF ( st_fx->hFdCngDec_fx != NULL && (L_sub(st_fx->sr_core,8000) == 0 || L_sub(st_fx->sr_core,12800) == 0 || L_sub(st_fx->sr_core,16000) == 0) && L_sub(st_fx->total_brate_fx,ACELP_32k) <= 0 ) + IF ( st_fx->hFdCngDec_fx != NULL && (EQ_32(st_fx->sr_core,8000)||EQ_32(st_fx->sr_core,12800)||EQ_32(st_fx->sr_core,16000))&&LE_32(st_fx->total_brate_fx,ACELP_32k)) { /*************************************** In CLDFB domain: @@ -935,7 +933,7 @@ void evs_dec_fx( /* Generate additional comfort noise to mask potential coding artefacts */ test(); - IF( sub(st_fx->m_frame_type,ACTIVE_FRAME) == 0 && st_fx->flag_cna ) + IF( EQ_16(st_fx->m_frame_type,ACTIVE_FRAME)&&st_fx->flag_cna) { generate_masking_noise( output_sp, 0, hFdCngDec->hFdCngCom, hFdCngDec->hFdCngCom->frameSize, 0 ); } @@ -948,8 +946,8 @@ void evs_dec_fx( test(); test(); test(); - IF( st_fx->flag_cna == 0 && sub(st_fx->L_frame_fx,L_FRAME16k) == 0 && sub(st_fx->last_flag_cna,1) == 0 - && ( (st_fx->last_core_fx == ACELP_CORE && sub(st_fx->last_coder_type_fx,AUDIO) != 0) || sub(st_fx->last_core_fx,TCX_20_CORE) == 0 || sub(st_fx->last_core_fx,AMR_WB_CORE) == 0 ) ) + IF( st_fx->flag_cna == 0 && EQ_16(st_fx->L_frame_fx,L_FRAME16k)&&EQ_16(st_fx->last_flag_cna,1) + && ( (st_fx->last_core_fx == ACELP_CORE && NE_16(st_fx->last_coder_type_fx,AUDIO) ) || EQ_16(st_fx->last_core_fx,TCX_20_CORE) || EQ_16(st_fx->last_core_fx,AMR_WB_CORE) ) ) { FOR (i=0; i < st_fx->L_frame_fx/2; i++) { @@ -958,10 +956,10 @@ void evs_dec_fx( } } - IF( sub(st_fx->m_frame_type,ACTIVE_FRAME) == 0 ) + IF( EQ_16(st_fx->m_frame_type,ACTIVE_FRAME)) { timeIn_e = s_max(0, sub(getScaleFactor16( output_sp, st_fx->L_frame_fx ), 3)); - IF( sub(st_fx->core_fx,ACELP_CORE) != 0 ) + IF( NE_16(st_fx->core_fx,ACELP_CORE)) { timeIn_e = s_max(0, s_min(sub(getScaleFactor16( pcmbufFB, st_fx->L_frameTCX ), 3),timeIn_e)); } @@ -986,7 +984,7 @@ void evs_dec_fx( { generate_masking_noise( timeDomainBuffer, 0, st_fx->hFdCngDec_fx->hFdCngCom, st_fx->hFdCngDec_fx->hFdCngCom->frameSize, 0 ); } - ELSE IF( sub(st_fx->L_frame_fx,L_FRAME16k) == 0 && sub(st_fx->last_flag_cna,1) == 0 && ( (sub(st_fx->last_core_fx,ACELP_CORE) == 0 && sub(st_fx->last_coder_type_fx,AUDIO) != 0 ) || sub(st_fx->last_core_fx,TCX_20_CORE) == 0 || sub(st_fx->last_core_fx,AMR_WB_CORE) == 0) ) + ELSE IF( EQ_16(st_fx->L_frame_fx,L_FRAME16k)&&EQ_16(st_fx->last_flag_cna,1)&&((EQ_16(st_fx->last_core_fx,ACELP_CORE)&&NE_16(st_fx->last_coder_type_fx,AUDIO))||EQ_16(st_fx->last_core_fx,TCX_20_CORE)||EQ_16(st_fx->last_core_fx,AMR_WB_CORE))) { FOR( i=0; i < st_fx->L_frame_fx/2; i++ ) { @@ -995,7 +993,7 @@ void evs_dec_fx( } } /* check if the CLDFB works on the right sample rate */ - IF( sub((st_fx->cldfbAna_fx->no_channels * st_fx->cldfbAna_fx->no_col),st_fx->L_frame_fx) != 0 ) + IF( NE_16((st_fx->cldfbAna_fx->no_channels * st_fx->cldfbAna_fx->no_col),st_fx->L_frame_fx)) { Word16 newCldfbBands = CLDFB_getNumChannels(L_mult0(st_fx->L_frame_fx, 50)); @@ -1006,7 +1004,7 @@ void evs_dec_fx( st_fx->cldfbSyn_fx->bandsToZero = 0; move16(); test(); - IF ( sub( st_fx->bwidth_fx, NB ) == 0 && sub( st_fx->cldfbSyn_fx->no_channels, 10 ) > 0 ) + IF ( EQ_16( st_fx->bwidth_fx, NB )&>_16(st_fx->cldfbSyn_fx->no_channels,10)) { st_fx->cldfbSyn_fx->bandsToZero = sub( st_fx->cldfbSyn_fx->no_channels, 10 ); } @@ -1036,7 +1034,7 @@ void evs_dec_fx( { Word16 timeInBpf_e = timeIn_e; move16(); - if( sub(st_fx->m_frame_type,ACTIVE_FRAME) == 0 ) + if( EQ_16(st_fx->m_frame_type,ACTIVE_FRAME)) { timeInBpf_e = 0; move16(); @@ -1045,14 +1043,14 @@ void evs_dec_fx( addBassPostFilterFx( st_fx->p_bpf_noise_buf, realBuffer, imagBuffer, st_fx->cldfbBPF_fx, workBuffer, timeInBpf_e, CLDFB_NO_COL_MAX, st_fx->cldfbAna_fx->no_col, st_fx->cldfbAna_fx->no_channels, &st_fx->scaleFactor ); - IF( sub(st_fx->m_frame_type,ACTIVE_FRAME) != 0 ) + IF( NE_16(st_fx->m_frame_type,ACTIVE_FRAME)) { Scale_sig(st_fx->p_bpf_noise_buf, st_fx->L_frame_fx, timeIn_e); } } - IF (L_sub(st_fx->output_Fs_fx, 8000) > 0) + IF (GT_32(st_fx->output_Fs_fx, 8000)) { st_fx->tecDec_fx.cldfbExp = add(15, st_fx->scaleFactor.lb_scale); @@ -1065,7 +1063,7 @@ void evs_dec_fx( } /* set high band buffers to zero. Covering the current frame and the overlap area. */ - IF( sub(st_fx->m_frame_type,ACTIVE_FRAME) == 0 ) + IF( EQ_16(st_fx->m_frame_type,ACTIVE_FRAME)) { FOR( i = 0; i < 16; i++ ) { @@ -1084,16 +1082,16 @@ void evs_dec_fx( st_fx->Q_old_postdec = 0; move16(); delay_tdbwe= NS2SA_fx2(st_fx->output_Fs_fx, DELAY_BWE_TOTAL_NS- DELAY_CLDFB_NS); - IF( sub(output_frame,L_FRAME16k) >= 0 ) + IF( GE_16(output_frame,L_FRAME16k)) { Scale_sig(st_fx->prev_synth_buffer_fx, delay_tdbwe, sub(Qpostd, st_fx->Qprev_synth_buffer_fx)); } test(); - IF( sub(st_fx->last_codec_mode,MODE1) == 0 && sub(st_fx->last_core_bfi,ACELP_CORE) > 0 ) + IF( EQ_16(st_fx->last_codec_mode,MODE1)&>_16(st_fx->last_core_bfi,ACELP_CORE)) { Copy_Scale_sig( st_fx->delay_buf_out_fx, output_sp, delay_comp, negate(timeIn_e) ); /* copy the HQ/ACELP delay synchronization buffer at the beginning of ACELP frame */ - IF( sub(st_fx->core_fx,ACELP_CORE) == 0 ) + IF( EQ_16(st_fx->core_fx,ACELP_CORE)) { Word16 step, alpha, nz; @@ -1127,7 +1125,7 @@ void evs_dec_fx( } ELSE { - IF( L_sub(st_fx->output_Fs_fx,8000) == 0 ) + IF( EQ_32(st_fx->output_Fs_fx,8000)) { Copy(st_fx->delay_buf_out_fx, st_fx->FBTCXdelayBuf, delay_comp); } @@ -1141,7 +1139,7 @@ void evs_dec_fx( /* set delay compensation between HQ synthesis and ACELP synthesis */ test(); - IF( sub(st_fx->core_fx,ACELP_CORE) == 0 && !(st_fx->con_tcx) ) + IF( EQ_16(st_fx->core_fx,ACELP_CORE)&&!(st_fx->con_tcx)) { set16_fx( st_fx->delay_buf_out_fx, 0, delay_comp ); Copy_Scale_sig( output_sp, st_fx->previoussynth_fx, output_frame, timeIn_e ); @@ -1149,7 +1147,7 @@ void evs_dec_fx( ELSE { Copy( st_fx->old_synthFB_fx+st_fx->old_synth_lenFB-delay_comp, st_fx->delay_buf_out_fx, delay_comp ); - IF( L_sub(st_fx->output_Fs_fx, 8000) == 0 ) + IF( EQ_32(st_fx->output_Fs_fx, 8000)) { Copy(st_fx->FBTCXdelayBuf, st_fx->previoussynth_fx, delay_comp); } @@ -1162,7 +1160,7 @@ void evs_dec_fx( } /* Delay compensation for TD-BWE*/ - IF( sub(output_frame,L_FRAME16k) >= 0 ) + IF( GE_16(output_frame,L_FRAME16k)) { Copy( output_sp, tmp_buffer_fx, output_frame ); Copy_Scale_sig( st_fx->prev_synth_buffer_fx, output_sp, delay_tdbwe, negate(timeIn_e) ); @@ -1171,17 +1169,17 @@ void evs_dec_fx( } test(); - IF( st_fx->igf != 0 && sub( st_fx->m_frame_type, ACTIVE_FRAME ) == 0 ) + IF( st_fx->igf != 0 && EQ_16( st_fx->m_frame_type, ACTIVE_FRAME )) { test(); test(); test(); test(); - IF( st_fx->bfi_fx == 0 && sub(st_fx->core_fx, ACELP_CORE) == 0 && (st_fx->tec_flag != 0 || st_fx->tfa_flag != 0) && L_sub( st_fx->output_Fs_fx, 8000 ) > 0 ) + IF( st_fx->bfi_fx == 0 && EQ_16(st_fx->core_fx, ACELP_CORE)&&(st_fx->tec_flag!=0||st_fx->tfa_flag!=0)&>_32(st_fx->output_Fs_fx,8000)) { tmp16 = 0; move16(); - if (sub(st_fx->tec_flag, 2) == 0) + if (EQ_16(st_fx->tec_flag, 2)) { tmp16 = 1; move16(); @@ -1198,15 +1196,15 @@ void evs_dec_fx( test(); test(); IF( (( ( st_fx->bfi_fx == 0 || st_fx->last_core_fx == ACELP_CORE ) && st_fx->core_fx == ACELP_CORE ) || - ( ( sub(st_fx->last_core_fx, ACELP_CORE) == 0 ) && (sub(st_fx->bwidth_fx, NB) != 0 && sub(st_fx->last_codec_mode, MODE2) == 0) )) - && (L_sub( st_fx->output_Fs_fx, 8000 ) > 0) ) + ( ( EQ_16(st_fx->last_core_fx, ACELP_CORE) ) && (NE_16(st_fx->bwidth_fx, NB) && EQ_16(st_fx->last_codec_mode, MODE2) ) )) + && (GT_32( st_fx->output_Fs_fx, 8000 ) ) ) { add_vec_fx( output_sp, negate(timeIn_e), hb_synth_fx, hb_synth_fx_exp, output_sp, negate(timeIn_e), output_frame ); } } - IF( L_sub( st_fx->output_Fs_fx, 8000 ) == 0 ) + IF( EQ_32( st_fx->output_Fs_fx, 8000 )) { tmps = NS2SA_fx2(st_fx->output_Fs_fx, DELAY_CLDFB_NS ); } @@ -1219,13 +1217,13 @@ void evs_dec_fx( test(); test(); test(); - IF ( (st_fx->bfi_fx && sub(st_fx->last_core_fx, ACELP_CORE) > 0) || sub(st_fx->core_fx, ACELP_CORE) > 0) + IF ( (st_fx->bfi_fx && GT_16(st_fx->last_core_fx, ACELP_CORE))||GT_16(st_fx->core_fx,ACELP_CORE)) { test(); test(); test(); test(); - IF ( sub(st_fx->last_core_bfi, ACELP_CORE) > 0 || (st_fx->bfi_fx && st_fx->last_core_fx > ACELP_CORE) || (st_fx->prev_bfi_fx && st_fx->last_con_tcx)) + IF ( GT_16(st_fx->last_core_bfi, ACELP_CORE)||(st_fx->bfi_fx&&st_fx->last_core_fx>ACELP_CORE)||(st_fx->prev_bfi_fx&&st_fx->last_con_tcx)) { Copy_Scale_sig(st_fx->FBTCXdelayBuf, output_sp, tmps, negate(timeIn_e)); Copy_Scale_sig(pcmbufFB, output_sp + tmps, sub(st_fx->L_frameTCX, tmps), negate(timeIn_e)); @@ -1253,9 +1251,9 @@ void evs_dec_fx( Copy( pcmbufFB + st_fx->L_frameTCX - tmps, st_fx->FBTCXdelayBuf, tmps ); test(); - IF( st_fx->bfi_fx && sub(st_fx->last_core_fx, ACELP_CORE) > 0 ) + IF( st_fx->bfi_fx && GT_16(st_fx->last_core_fx, ACELP_CORE)) { - IF( L_sub(st_fx->output_Fs_fx, 8000) == 0 ) + IF( EQ_32(st_fx->output_Fs_fx, 8000)) { Copy(st_fx->FBTCXdelayBuf, st_fx->delay_buf_out_fx, NS2SA(st_fx->output_Fs_fx, DELAY_CLDFB_NS)); } @@ -1266,7 +1264,7 @@ void evs_dec_fx( } } } - ELSE IF( (sub(st_fx->last_codec_mode,MODE2)==0) && (sub(st_fx->last_core_fx, ACELP_CORE) > 0) ) + ELSE IF( (EQ_16(st_fx->last_codec_mode,MODE2))&&(GT_16(st_fx->last_core_fx,ACELP_CORE))) { Word16 step, alpha; @@ -1308,7 +1306,7 @@ void evs_dec_fx( * Save synthesis for HQ FEC *----------------------------------------------------------------*/ post_hq_delay = NS2SA_fx2( st_fx->output_Fs_fx, POST_HQ_DELAY_NS ); - IF (sub(st_fx->codec_mode, MODE1) == 0) + IF (EQ_16(st_fx->codec_mode, MODE1)) { Copy( st_fx->synth_history_fx+output_frame, st_fx->synth_history_fx, output_frame-post_hq_delay+NS2SA_fx2( st_fx->output_Fs_fx, PH_ECU_MEM_NS )); @@ -1317,14 +1315,14 @@ void evs_dec_fx( this buffer are not available for all cases, the impact on the output is limited */ set16_fx( st_fx->old_synthFB_fx+2*output_frame-post_hq_delay, 0, post_hq_delay ); - IF( sub(output_frame, L_FRAME16k) >= 0 ) + IF( GE_16(output_frame, L_FRAME16k)) { Copy_Scale_sig( st_fx->prev_synth_buffer_fx, st_fx->old_synthFB_fx+2*output_frame-NS2SA_fx2(st_fx->output_Fs_fx, DELAY_BWE_TOTAL_NS), NS2SA_fx2(st_fx->output_Fs_fx, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS),negate(st_fx->Qprev_synth_buffer_fx)); } - IF( sub(st_fx->core_fx,ACELP_CORE) != 0 ) + IF( NE_16(st_fx->core_fx,ACELP_CORE)) { - IF( sub(output_frame, L_FRAME16k) >= 0 ) + IF( GE_16(output_frame, L_FRAME16k)) { Copy_Scale_sig( synth_fx+output_frame, st_fx->old_synthFB_fx+2*output_frame-NS2SA_fx2(st_fx->output_Fs_fx, DELAY_CLDFB_NS), NS2SA_fx2(st_fx->output_Fs_fx, DELAY_CLDFB_NS),negate(Qpostd)); @@ -1352,7 +1350,7 @@ void evs_dec_fx( * Synthesis output *----------------------------------------------------------------*/ - IF( sub(st_fx->codec_mode,MODE1) == 0 ) + IF( EQ_16(st_fx->codec_mode,MODE1)) { /* final output of synthesis signal */ syn_output_fx( st_fx->codec_mode, synth_fx, output_frame, output_sp, Qpostd ); @@ -1367,19 +1365,19 @@ void evs_dec_fx( *--------------------------------------------------------*/ test(); - IF( st_fx->last_is_cng == 0 && sub(st_fx->codec_mode,MODE2) == 0 ) + IF( st_fx->last_is_cng == 0 && EQ_16(st_fx->codec_mode,MODE2)) { st_fx->bfi_fx = 0; move16(); - IF( st_fx->use_partial_copy && sub(st_fx->rf_frame_type, RF_TCXFD) >= 0 && sub(st_fx->rf_frame_type, RF_TCXTD2) <= 0) + IF( st_fx->use_partial_copy && GE_16(st_fx->rf_frame_type, RF_TCXFD)&&LE_16(st_fx->rf_frame_type,RF_TCXTD2)) { - if( sub(frameMode, FRAMEMODE_MISSING) == 0 ) + if( EQ_16(frameMode, FRAMEMODE_MISSING)) { st_fx->bfi_fx = 1; move16(); } } - ELSE IF( sub(st_fx->m_decodeMode, DEC_CONCEALMENT_EXT) == 0 ) + ELSE IF( EQ_16(st_fx->m_decodeMode, DEC_CONCEALMENT_EXT)) { st_fx->bfi_fx = 1; move16(); @@ -1388,17 +1386,17 @@ void evs_dec_fx( } ELSE { - if( sub(st_fx->codec_mode,MODE2) == 0 ) + if( EQ_16(st_fx->codec_mode,MODE2)) { st_fx->bfi_fx = 0; move16(); } updt_dec_common_fx( st_fx, hq_core_type, output_sp ); } - IF( sub(st_fx->codec_mode,MODE2) == 0 ) + IF( EQ_16(st_fx->codec_mode,MODE2)) { test(); - IF(sub(st_fx->use_partial_copy,1)==0 && sub(st_fx->rf_frame_type,RF_NELP) == 0) + IF(EQ_16(st_fx->use_partial_copy,1)&&EQ_16(st_fx->rf_frame_type,RF_NELP)) { st_fx->last_nelp_mode_dec_fx = 1; } @@ -1426,16 +1424,16 @@ void evs_dec_fx( st_fx->prev_coder_type_fx = coder_type; move16(); - if( sub(st_fx->core_fx,HQ_CORE) == 0 ) + if( EQ_16(st_fx->core_fx,HQ_CORE)) { st_fx->prev_coder_type_fx = GENERIC; move16(); } test(); - IF ( L_sub(st_fx->core_brate_fx,SID_2k40) > 0 && sub(st_fx->first_CNG_fx,1) == 0 ) + IF ( GT_32(st_fx->core_brate_fx,SID_2k40)&&EQ_16(st_fx->first_CNG_fx,1)) { - if( sub(st_fx->act_cnt_fx,BUF_DEC_RATE) >= 0 ) + if( GE_16(st_fx->act_cnt_fx,BUF_DEC_RATE)) { st_fx->act_cnt_fx = 0; move16(); @@ -1444,13 +1442,13 @@ void evs_dec_fx( st_fx->act_cnt_fx = add(st_fx->act_cnt_fx, 1); test(); - if( (sub(st_fx->act_cnt_fx,BUF_DEC_RATE)==0) && (st_fx->ho_hist_size_fx > 0) ) + if( (EQ_16(st_fx->act_cnt_fx,BUF_DEC_RATE))&&(st_fx->ho_hist_size_fx>0)) { st_fx->ho_hist_size_fx = sub(st_fx->ho_hist_size_fx,1); } st_fx->act_cnt2_fx = add(st_fx->act_cnt2_fx,1); - if( sub(st_fx->act_cnt2_fx,MIN_ACT_CNG_UPD) >= 0 ) + if( GE_16(st_fx->act_cnt2_fx,MIN_ACT_CNG_UPD)) { st_fx->act_cnt2_fx = MIN_ACT_CNG_UPD; move16(); @@ -1459,14 +1457,14 @@ void evs_dec_fx( test(); test(); - if ( L_sub(st_fx->core_brate_fx,SID_2k40) <= 0 && st_fx->first_CNG_fx == 0 && sub(st_fx->cng_type_fx,LP_CNG) == 0 ) + if ( LE_32(st_fx->core_brate_fx,SID_2k40)&&st_fx->first_CNG_fx==0&&EQ_16(st_fx->cng_type_fx,LP_CNG)) { st_fx->first_CNG_fx = 1; move16(); } /* update bandwidth switching parameters */ - IF( sub(st_fx->codec_mode, MODE1) == 0 ) + IF( EQ_16(st_fx->codec_mode, MODE1)) { updt_bw_switching_fx( st_fx, synth_fx, Qpostd ); } @@ -1479,7 +1477,7 @@ void evs_dec_fx( /* synchronisation of CNG seeds*/ test(); test(); - IF( st_fx->bfi_fx || (L_sub(st_fx->core_brate_fx,FRAME_NO_DATA) != 0 && L_sub(st_fx->core_brate_fx,SID_2k40) != 0) ) + IF( st_fx->bfi_fx || (NE_32(st_fx->core_brate_fx,FRAME_NO_DATA)&&NE_32(st_fx->core_brate_fx,SID_2k40))) { Random( &(st_fx->cng_seed_fx) ); Random( &(st_fx->cng_ener_seed_fx) ); diff --git a/lib_dec/evs_rtp_payload.c b/lib_dec/evs_rtp_payload.c index ab9ace9dda6ec3d9faee7ad1eb3647788606de90..43bcb4192e5cb2c5383f3615cbde5961ee04a02a 100644 --- a/lib_dec/evs_rtp_payload.c +++ b/lib_dec/evs_rtp_payload.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include diff --git a/lib_dec/evs_rtp_payload.h b/lib_dec/evs_rtp_payload.h index bf67631caeab036f44b79d39cc4ce3056fbab11c..00e2965ca4b5e80e76c62fa62f62e14047f3d7d1 100644 --- a/lib_dec/evs_rtp_payload.h +++ b/lib_dec/evs_rtp_payload.h @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #pragma once diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index a7e4c35ef37c2a8de9330c0a5a88d66a08c4599c..84316c7814bc0a42332062821d9344c4d13d8fff 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ @@ -7,8 +7,6 @@ #include "rom_com_fx.h" #include "stat_dec_fx.h" #include "stl.h" -#include "wmc_auto.h" - #include "options.h" #include "prot_fx.h" #include "basop_util.h" @@ -149,12 +147,12 @@ void configureFdCngDec (HANDLE_FD_CNG_DEC hsDec, /* i/o: Contains the variable hsCom->CngBandwidth = bandwidth; - IF ( sub( hsCom->CngBandwidth, FB ) == 0 ) + IF ( EQ_16( hsCom->CngBandwidth, FB )) { hsCom->CngBandwidth = SWB; } test(); - if ( bitrate != FRAME_NO_DATA && L_sub(bitrate, SID_2k40) != 0 ) + if ( bitrate != FRAME_NO_DATA && NE_32(bitrate, SID_2k40)) { hsCom->CngBitrate = L_add(bitrate, 0); } @@ -172,13 +170,13 @@ void configureFdCngDec (HANDLE_FD_CNG_DEC hsDec, /* i/o: Contains the variable } /* WB configuration */ - ELSE IF ( sub(bandwidth, WB) == 0 ) + ELSE IF ( EQ_16(bandwidth, WB)) { /* FFT 6.4kHz, no CLDFB */ test(); test(); - IF ( L_sub(hsCom->CngBitrate, ACELP_8k00) <= 0 - && sub(L_frame,L_FRAME)==0 + IF ( LE_32(hsCom->CngBitrate, ACELP_8k00) + && EQ_16(L_frame,L_FRAME) ) { hsCom->FdCngSetup = FdCngSetup_wb1; @@ -188,8 +186,8 @@ void configureFdCngDec (HANDLE_FD_CNG_DEC hsDec, /* i/o: Contains the variable move16(); } /* FFT 6.4kHz, CLDFB 8.0kHz */ - ELSE IF ( L_sub(hsCom->CngBitrate, ACELP_13k20) <= 0 - || sub(L_frame,L_FRAME)==0 + ELSE IF ( LE_32(hsCom->CngBitrate, ACELP_13k20) + || EQ_16(L_frame,L_FRAME) ) { hsCom->FdCngSetup = FdCngSetup_wb2; @@ -198,7 +196,7 @@ void configureFdCngDec (HANDLE_FD_CNG_DEC hsDec, /* i/o: Contains the variable hsCom->regularStopBand = 20; move16(); IF ( - sub(L_frame,L_FRAME16k)==0 + EQ_16(L_frame,L_FRAME16k) ) { hsCom->FdCngSetup = FdCngSetup_wb2; @@ -228,8 +226,8 @@ void configureFdCngDec (HANDLE_FD_CNG_DEC hsDec, /* i/o: Contains the variable { /* FFT 6.4kHz, CLDFB 14kHz */ IF ( - sub(L_frame,L_FRAME)==0 - ) + EQ_16(L_frame,L_FRAME) + ) { hsCom->FdCngSetup = FdCngSetup_swb1; hsCom->numCoreBands = 16; @@ -261,12 +259,12 @@ void configureFdCngDec (HANDLE_FD_CNG_DEC hsDec, /* i/o: Contains the variable hsCom->nFFTpart = 21; move16(); - if ( sub(hsCom->stopFFTbin, 256) == 0 ) + if ( EQ_16(hsCom->stopFFTbin, 256)) { hsCom->nFFTpart = 20; move16(); } - if ( sub(hsCom->stopFFTbin, 160) == 0 ) + if ( EQ_16(hsCom->stopFFTbin, 160)) { hsCom->nFFTpart = 17; move16(); @@ -282,7 +280,7 @@ void configureFdCngDec (HANDLE_FD_CNG_DEC hsDec, /* i/o: Contains the variable } stopBandFR = 1000/25; - if ( sub(stopBandFR, hsCom->stopFFTbin) > 0 ) + if ( GT_16(stopBandFR, hsCom->stopFFTbin)) { stopBandFR = hsCom->stopFFTbin; move16(); @@ -392,7 +390,7 @@ Word16 ApplyFdCng (Word16 *timeDomainInput, /* i : pointer to time doma Word16 lsp_cng[M]; - if(sub(st->hFdCngCom->frame_type_previous,ACTIVE_FRAME)==0) + if(EQ_16(st->hFdCngCom->frame_type_previous,ACTIVE_FRAME)) { st->hFdCngCom->inactive_frame_counter = 0; move16(); @@ -534,7 +532,7 @@ Word16 ApplyFdCng (Word16 *timeDomainInput, /* i : pointer to time doma } /* adapt scaling for rest of the buffer */ - IF (sub(s2,-(WORD32_BITS-1)) != 0) + IF (NE_16(s2,-(WORD32_BITS-1))) { s = sub(*cngNoiseLevel_exp,add(st->bandNoiseShape_exp,s2)); FOR ( ; k < st->hFdCngCom->npart; k++) @@ -605,7 +603,7 @@ Word16 ApplyFdCng (Word16 *timeDomainInput, /* i : pointer to time doma L_tmp = L_add(L_tmp,L_shr(cngNoiseLevel[j],16)); } L_tmp_exp = add(*cngNoiseLevel_exp,16); - IF (sub(concealWholeFrame,1)==0 && sub(stdec->nbLostCmpt,1)==0 && (L_shl(L_tmp,L_tmp_exp)>21474836 /*0.01f Q31*/)) + IF (EQ_16(concealWholeFrame,1)&&EQ_16(stdec->nbLostCmpt,1)&&(L_shl(L_tmp,L_tmp_exp)>21474836 /*0.01f Q31*/)) { /* update isf cng estimate for concealment. Do that during concealment, in order to avoid addition clean channel complexity*/ lpc_from_spectrum(cngNoiseLevel, *cngNoiseLevel_exp, st->hFdCngCom->startBand, st->hFdCngCom->stopFFTbin, st->hFdCngCom->fftlen, st->hFdCngCom->A_cng, @@ -686,7 +684,7 @@ Word16 ApplyFdCng (Word16 *timeDomainInput, /* i : pointer to time doma *************************************/ /* Detect first non-active frame */ - IF ( sub(st->hFdCngCom->inactive_frame_counter,1) == 0 ) + IF ( EQ_16(st->hFdCngCom->inactive_frame_counter,1)) { /* Compute the fine spectral structure of the comfort noise shape using the decoder-side noise estimates */ bandcombinepow ( @@ -701,9 +699,9 @@ Word16 ApplyFdCng (Word16 *timeDomainInput, /* i : pointer to time doma ); } - IF ( sub(m_frame_type,SID_FRAME) == 0 ) + IF ( EQ_16(m_frame_type,SID_FRAME)) { - IF ( L_sub(st->hFdCngCom->msFrCnt_init_counter,L_deposit_l(st->hFdCngCom->msFrCnt_init_thresh)) < 0 ) + IF ( LT_32(st->hFdCngCom->msFrCnt_init_counter,L_deposit_l(st->hFdCngCom->msFrCnt_init_thresh))) { /* At initialization, interpolate the bin/band-wise levels from the partition levels */ scalebands ( @@ -722,7 +720,7 @@ Word16 ApplyFdCng (Word16 *timeDomainInput, /* i : pointer to time doma ELSE { /* Interpolate the CLDFB band levels from the SID (partition) levels */ - IF ( sub( st->hFdCngCom->regularStopBand, st->hFdCngCom->numCoreBands ) > 0 ) + IF ( GT_16( st->hFdCngCom->regularStopBand, st->hFdCngCom->numCoreBands )) { scalebands ( st->hFdCngCom->sidNoiseEst, @@ -808,7 +806,7 @@ Word16 ApplyFdCng (Word16 *timeDomainInput, /* i : pointer to time doma } - IF ( sub(stdec->codec_mode, MODE2) == 0 ) + IF ( EQ_16(stdec->codec_mode, MODE2)) { /* Generate comfort noise during SID or zero frames */ generate_comfort_noise_dec ( @@ -938,23 +936,23 @@ void perform_noise_estimation_dec (const Word16 *timeDomainInput, /* i: pointe fac = 20972/*0.64 Q15*/; move16(); - if( sub(st->hFdCngCom->fftlen,512) == 0 ) + if( EQ_16(st->hFdCngCom->fftlen,512)) { fac = 16384/*0.5 Q15*/; move16(); } - if ( sub(st->hFdCngCom->fftlen,640) == 0 ) + if ( EQ_16(st->hFdCngCom->fftlen,640)) { s = 18; move16(); } - if ( sub(st->hFdCngCom->fftlen,512) == 0 ) + if ( EQ_16(st->hFdCngCom->fftlen,512)) { s = 17; move16(); } - if ( sub(st->hFdCngCom->fftlen,320) == 0 ) + if ( EQ_16(st->hFdCngCom->fftlen,320)) { s = 16; move16(); @@ -1243,7 +1241,7 @@ void noisy_speech_detection (const Word16 vad, logEtot = BASOP_Util_Log2(Etot); logEtotExp = L_shl(L_deposit_l(Etot_exp),WORD32_BITS-1-LD_DATA_SCALE); logEtot = Mpy_32_16_1(L_add(logEtot,logEtotExp),24660/*0.75257498916 Q15*/); - IF ( sub( frameSize, L_FRAME16k ) == 0 ) + IF ( EQ_16( frameSize, L_FRAME16k )) { logEtot = L_add( logEtot, -184894985l/*-0.086098436822497 Q31*/ ); } @@ -1259,7 +1257,7 @@ void noisy_speech_detection (const Word16 vad, tmp = L_sub(*lp_speech,377487360l/*45.0 Q23*/); - if ( L_sub(*lp_noise,tmp) < 0 ) + if ( LT_32(*lp_noise,tmp)) { *lp_noise = tmp; move32(); @@ -1267,7 +1265,7 @@ void noisy_speech_detection (const Word16 vad, *flag_noisy_speech = 0; move16(); - if ( L_sub(L_sub(*lp_speech,*lp_noise),234881024l/*28.0 Q23*/) < 0 ) + if ( LT_32(L_sub(*lp_speech,*lp_noise),234881024l/*28.0 Q23*/)) { *flag_noisy_speech = 1; move16(); @@ -1429,9 +1427,9 @@ generate_comfort_noise_dec (Word32 **bufferReal, /* o : matrix to real Lener = L_sub(Lener, 10802114l/*0.3219280949f Q25*/); /*log2(320) = 8.3219280949f*/ } /* decrease the energy in case of WB input */ - IF( sub(stdec->bwidth_fx, NB) != 0 ) + IF( NE_16(stdec->bwidth_fx, NB)) { - IF( sub(stdec->bwidth_fx,WB) == 0 ) + IF( EQ_16(stdec->bwidth_fx,WB)) { IF( stdec->CNG_mode_fx >= 0 ) { @@ -1464,7 +1462,7 @@ generate_comfort_noise_dec (Word32 **bufferReal, /* o : matrix to real Amplitudes are adjusted to the estimated noise level cngNoiseLevel in each band */ test(); - IF ( bufferReal!=NULL && (sub(st->numCoreBands,st->regularStopBand) < 0) ) + IF ( bufferReal!=NULL && (LT_16(st->numCoreBands,st->regularStopBand))) { sn = sub(sn,1); @@ -1524,7 +1522,7 @@ generate_comfort_noise_dec (Word32 **bufferReal, /* o : matrix to real Word16 left_overlap_mode; left_overlap_mode = stdec->tcx_cfg.tcx_last_overlap_mode; move16(); - if (sub(left_overlap_mode, ALDO_WINDOW) == 0) + if (EQ_16(left_overlap_mode, ALDO_WINDOW)) { left_overlap_mode = FULL_OVERLAP; move16(); @@ -1746,7 +1744,7 @@ generate_comfort_noise_dec_hf (Word32 **bufferReal, /* o : matrix to r randGaussExp = CNG_RAND_GAUSS_SHIFT; move16(); - IF ( sub(st->numCoreBands,st->regularStopBand) < 0 ) + IF ( LT_16(st->numCoreBands,st->regularStopBand)) { sc = add(shr(add(cngNoiseLevelExp,CLDFBinvScalingFactor_EXP+1-1),1),randGaussExp); @@ -1835,10 +1833,10 @@ void generate_masking_noise (Word16 *timeDomainBuffer, /* i/o : pointer to time { test(); test(); - IF ( ( sub(st->CngBandwidth,scaleTable_cn_only[i].bwmode) == 0 ) - && ( L_sub(st->CngBitrate,scaleTable_cn_only[i].bitrateFrom) >= 0 ) - && ( L_sub(st->CngBitrate,scaleTable_cn_only[i].bitrateTo) < 0 ) - ) + IF ( ( EQ_16(st->CngBandwidth,scaleTable_cn_only[i].bwmode)) + && (GE_32(st->CngBitrate,scaleTable_cn_only[i].bitrateFrom) ) + && ( LT_32(st->CngBitrate,scaleTable_cn_only[i].bitrateTo) )) + { scale = scaleTable_cn_only[i].scale; move16(); @@ -1857,7 +1855,7 @@ void generate_masking_noise (Word16 *timeDomainBuffer, /* i/o : pointer to time move16(); FOR (i=0; i < scaleTableSize; i++) { - IF ( L_sub(st->CngBitrate,scaleTable_cn_only_amrwbio[i][0]) >= 0 ) + IF ( GE_32(st->CngBitrate,scaleTable_cn_only_amrwbio[i][0])) { scale = scaleTable_cn_only_amrwbio[i][1]; move16(); @@ -2051,9 +2049,9 @@ void generate_masking_noise_mdct (Word32 *mdctBuffer, /* i/o: time-domain { test(); test(); - IF ( ( sub(st->CngBandwidth,scaleTable_cn_only[i].bwmode) == 0 ) - && ( L_sub(st->CngBitrate,scaleTable_cn_only[i].bitrateFrom) >= 0 ) - && ( L_sub(st->CngBitrate,scaleTable_cn_only[i].bitrateTo) < 0 ) + IF ( ( EQ_16(st->CngBandwidth,scaleTable_cn_only[i].bwmode)) + && ( GE_32(st->CngBitrate,scaleTable_cn_only[i].bitrateFrom) ) + && ( LT_32(st->CngBitrate,scaleTable_cn_only[i].bitrateTo) ) ) { scale = scaleTable_cn_only[i].scale; diff --git a/lib_dec/gain_dec_fx.c b/lib_dec/gain_dec_fx.c index 75c9d941b96ef5de27e49c152a6cbf4412ddc5e0..db2568897b7fba53fe0fbc8d226c6243507c24f9 100644 --- a/lib_dec/gain_dec_fx.c +++ b/lib_dec/gain_dec_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -7,8 +7,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*===========================================================================*/ @@ -115,7 +113,7 @@ void gain_dec_tc_fx( /*----------------------------------------------------------------* * find number of bits for gain dequantization *----------------------------------------------------------------*/ - IF( sub(L_frame_fx,L_FRAME) == 0) + IF( EQ_16(L_frame_fx,L_FRAME)) { nBits = gain_bits_tbl[BIT_ALLOC_IDX_fx(core_brate_fx, TRANSITION, i_subfr_fx, TC_SUBFR2IDX_fx(tc_subfr_fx))]; move16(); @@ -136,7 +134,8 @@ void gain_dec_tc_fx( expg = sub(expg, 18 + 6); /* exp: -18 (code in Q9), -6 (/L_SUBFR) */ expg2 = expg; move16(); - L_tmp1 = L_add(0,L_tmp); /* sets to 'L_tmp' in 1 clock */ + L_tmp1 = L_tmp; /* sets to 'L_tmp' in 1 clock */ + move32(); L_tmp = Isqrt_lc(L_tmp, &expg); *gain_inov_fx = extract_h(L_shl(L_tmp, sub(expg, 3))); @@ -173,7 +172,7 @@ void gain_dec_tc_fx( move16(); - IF( sub(nBits,3) > 0 ) + IF( GT_16(nBits,3)) { wgain_code = gain_dequant_fx( index, G_CODE_MIN_TC_Q15, G_CODE_MAX_TC_Q0, nBits, &expg ); wgain_code = shl(wgain_code,add(expg,13)); /* wgain_code in Q13*/ @@ -256,7 +255,7 @@ void gain_dec_mless_fx( /*-----------------------------------------------------------------* * decode pitch gain *-----------------------------------------------------------------*/ - IF( sub(L_frame_fx,L_FRAME) == 0) + IF( EQ_16(L_frame_fx,L_FRAME)) { nBits = gain_bits_tbl[BIT_ALLOC_IDX_fx(core_brate_fx, coder_type_fx, i_subfr_fx, TC_SUBFR2IDX_fx(tc_subfr_fx))]; move16(); @@ -271,8 +270,8 @@ void gain_dec_mless_fx( test(); test(); test(); - IF( (sub(tc_subfr_fx,3*L_SUBFR ) == 0 && sub(i_subfr_fx,3*L_SUBFR) == 0 && sub(L_frame_fx,L_FRAME) == 0) || - (sub(tc_subfr_fx,4*L_SUBFR ) == 0 && sub(i_subfr_fx,4*L_SUBFR) == 0 && sub(L_frame_fx,L_FRAME16k) == 0) ) + IF( (EQ_16(tc_subfr_fx,3*L_SUBFR )&&EQ_16(i_subfr_fx,3*L_SUBFR)&&EQ_16(L_frame_fx,L_FRAME))|| + (EQ_16(tc_subfr_fx,4*L_SUBFR ) && EQ_16(i_subfr_fx,4*L_SUBFR) && EQ_16(L_frame_fx,L_FRAME16k)) ) { /* decode pitch gain */ index = (Word16)get_next_indice_fx( st_fx, shr(nBits,1) ); @@ -293,7 +292,8 @@ void gain_dec_mless_fx( expg = sub(expg, 18 + 6); /* exp: -18 (code in Q12), -6 (/L_SUBFR) */ expg2 = expg; move16(); - L_tmp1 = L_add(0,L_tmp); /* sets to 'L_tmp' in 1 clock */ + L_tmp1 = L_tmp; /* sets to 'L_tmp' in 1 clock */ + move32(); L_tmp = Isqrt_lc(L_tmp, &expg); *gain_inov_fx = extract_h(L_shl(L_tmp, sub(expg, 3))); /* gain_inov in Q12 */ @@ -371,7 +371,7 @@ void gain_dec_mless_fx( } test(); - if( sub(coder_type_fx,INACTIVE) == 0&& sub(nBits,6) == 0 ) + if( EQ_16(coder_type_fx,INACTIVE)&&EQ_16(nBits,6)) { nBits = sub(nBits, 1); } @@ -389,7 +389,8 @@ void gain_dec_mless_fx( expg = sub(expg, 18 + 6); /* exp: -18 (code in Q9), -6 (/L_SUBFR) */ expg2 = expg; move16(); - L_tmp1 = L_add(0,L_tmp); /* sets to 'L_tmp' in 1 clock */ + L_tmp1 = L_tmp; /* sets to 'L_tmp' in 1 clock */ + move32(); L_tmp = Isqrt_lc(L_tmp, &expg); *gain_inov_fx = extract_h(L_shl(L_tmp, sub(expg, 3))); /* gain_inov in Q12 */ @@ -495,7 +496,8 @@ void gain_dec_lbr_fx( expg = sub(expg, 18 + 6); /* exp: -18 (code in Q9), -6 (/L_SUBFR) */ expg2 = expg; move16(); - L_tmp2 = L_add(0,L_tmp); /* sets to 'L_tmp' in 1 clock */ + L_tmp2 = L_tmp; /* sets to 'L_tmp' in 1 clock */ + move32(); L_tmp = Isqrt_lc(L_tmp, &expg); *gain_inov_fx = extract_h(L_shl(L_tmp, sub(expg, 3))); /* gain_inov in Q12 */ @@ -597,7 +599,7 @@ void gain_dec_lbr_fx( gp_mem[0] = *gain_pit_fx; move16(); /*Q14*/ } - ELSE IF (sub(i_subfr,L_SUBFR) == 0) + ELSE IF (EQ_16(i_subfr,L_SUBFR)) { b_fx = b_2sfr_fx; move16(); @@ -666,7 +668,7 @@ void gain_dec_lbr_fx( gp_mem[1] = *gain_pit_fx; move16(); } - ELSE IF (sub(i_subfr,2*L_SUBFR) == 0) + ELSE IF (EQ_16(i_subfr,2*L_SUBFR)) { b_fx = b_3sfr_fx; move16(); @@ -732,7 +734,7 @@ void gain_dec_lbr_fx( gp_mem[2] = *gain_pit_fx; move16(); } - ELSE IF (sub(i_subfr,3*L_SUBFR) == 0) + ELSE IF (EQ_16(i_subfr,3*L_SUBFR)) { b_fx = b_4sfr_fx; move16(); @@ -852,7 +854,7 @@ void lp_gain_updt_fx( Word16 tmp; tmp = extract_h(L_shl(norm_gain_code,3)); /*(16+3)-16 -> Q3*/ - IF( sub(L_frame,L_FRAME) == 0) + IF( EQ_16(L_frame,L_FRAME)) { IF(i_subfr == 0) { @@ -861,14 +863,14 @@ void lp_gain_updt_fx( *lp_gainc = mult_r(3277,tmp); move16(); /* (15+3)-15 -> Q3*/ } - ELSE IF( sub(i_subfr,L_SUBFR) == 0) + ELSE IF( EQ_16(i_subfr,L_SUBFR)) { *lp_gainp = add(*lp_gainp, mult(6554, gain_pit)); move16(); /*Q14 (0.2 in Q15 = 6554)*/ *lp_gainc = mac_r(L_deposit_h(*lp_gainc), 6554, tmp); move16(); /*Q3*/ } - ELSE IF( sub(i_subfr,2*L_SUBFR) == 0) + ELSE IF( EQ_16(i_subfr,2*L_SUBFR)) { *lp_gainp = add( *lp_gainp, mult(9830, gain_pit)); move16(); /*Q14 (0.3 in Q15 = 9830)*/ @@ -892,21 +894,21 @@ void lp_gain_updt_fx( *lp_gainc = mult_r(2185,tmp); move16(); /* (15+3)-15 -> Q3*/ } - ELSE IF( sub(i_subfr,L_SUBFR ) == 0) + ELSE IF( EQ_16(i_subfr,L_SUBFR )) { *lp_gainp = add(*lp_gainp, mult(4369, gain_pit)); move16(); /*Q14 (2.0/15.0 in Q15 = 4369)*/ *lp_gainc = mac_r(L_deposit_h(*lp_gainc), 4369, tmp); move16(); /*Q3*/ } - ELSE IF( sub(i_subfr,2*L_SUBFR) == 0) + ELSE IF( EQ_16(i_subfr,2*L_SUBFR)) { *lp_gainp = add(*lp_gainp, mult(6554, gain_pit)); move16(); /*Q14 (3.0/15.0 in Q15 = 6554)*/ *lp_gainc = mac_r(L_deposit_h(*lp_gainc), 6554, tmp); move16(); /*Q3*/ } - ELSE IF( sub(i_subfr,3*L_SUBFR) == 0) + ELSE IF( EQ_16(i_subfr,3*L_SUBFR)) { *lp_gainp = add(*lp_gainp, mult(8738, gain_pit)); move16(); /*Q14 (4.0/15.0 in Q15 = 8738)*/ @@ -1039,7 +1041,8 @@ void gain_dec_SQ_fx( expg = sub(expg, 18 + 6); /* exp: -18 (code in Q9), -6 (/L_SUBFR) */ expg2 = expg; move16(); - L_tmp1 = L_add(0,L_tmp); /* sets to 'L_tmp' in 1 clock */ + L_tmp1 = L_tmp; /* sets to 'L_tmp' in 1 clock */ + move32(); L_tmp = Isqrt_lc(L_tmp, &expg); *gain_inov = extract_h(L_shl(L_tmp, sub(expg, 3))); /* gain_inov in Q12 */ @@ -1127,7 +1130,7 @@ void gain_dec_amr_wb_fx( move16(); t_qua_gain = t_qua_gain7b_fx; - IF( L_sub(core_brate,ACELP_12k65) < 0) + IF( LT_32(core_brate,ACELP_12k65)) { nbits = 6; move16(); diff --git a/lib_dec/gaus_dec_fx.c b/lib_dec/gaus_dec_fx.c index 11cfe698dc72f2cf23f7dcaf1ac9c2d98ea7b264..ad50aabbdf2486310c8f4df8d5686e169c936ef7 100644 --- a/lib_dec/gaus_dec_fx.c +++ b/lib_dec/gaus_dec_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -7,8 +7,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*---------------------------------------------------------------------* * Local functions @@ -73,7 +71,7 @@ void gaus_dec_fx( move16(); /* safety check in case of bit errors */ - IF( sub(idx,78) > 0 ) + IF( GT_16(idx,78)) { idx = 78; move16(); @@ -103,7 +101,7 @@ void gaus_dec_fx( set16_fx(&exc[i_subfr],0, L_SUBFR); set16_fx(&exc2[i_subfr],0, L_SUBFR); - IF( sub(st_fx->L_frame_fx,L_FRAME) == 0 ) + IF( EQ_16(st_fx->L_frame_fx,L_FRAME)) { Rescale_exc( st_fx->dct_post_old_exc_fx, &exc[i_subfr], &bwe_exc_fx[i_subfr * HIBND_ACB_L_FAC], st_fx->last_exc_dct_in_fx, L_SUBFR, L_SUBFR* HIBND_ACB_L_FAC, *L_gain_code, sQ_exc, sQsubfr, exc2, i_subfr, UNVOICED ); @@ -231,7 +229,7 @@ static void dec_2pos_fx( move16(); *sign2 = *sign1; move16(); - if (sub(*ind1, *ind2) > 0) + if (GT_16(*ind1, *ind2)) { *sign2 = negate(*sign1); move16(); diff --git a/lib_dec/gs_dec_amr_wb_fx.c b/lib_dec/gs_dec_amr_wb_fx.c index 40be555b651f0409f65f9ed45a7b8c8beb3ca8f5..3d606886a75833991070f8d52d832059c31c54dc 100644 --- a/lib_dec/gs_dec_amr_wb_fx.c +++ b/lib_dec/gs_dec_amr_wb_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -7,8 +7,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*-------------------------------------------------------------------* @@ -227,7 +225,7 @@ static void gs_dec_amr_wb_fx( * adjust quantization noise for the low level to compensate for the poor 6 bit gainQ *--------------------------------------------------------------------------------------*/ - IF( L_sub(core_brate,ACELP_12k65) < 0) + IF( LT_32(core_brate,ACELP_12k65)) { temp = 0; move16(); @@ -238,7 +236,7 @@ static void gs_dec_amr_wb_fx( test(); test(); - IF((sub(coder_type,INACTIVE) == 0 || sub(clas,VOICED_TRANSITION) == 0) && sub(temp, 20) < 0 ) + IF((EQ_16(coder_type,INACTIVE)||EQ_16(clas,VOICED_TRANSITION))&<_16(temp,20)) { FOR(i = 0; i < CRIT_NOIS_BAND; i++) { @@ -261,7 +259,7 @@ static void gs_dec_amr_wb_fx( L_temp = L_mult(temp, 12800); L_temp = L_shl(L_temp, sub(3, exp)); /* *8.0f */ - if( L_sub(core_brate, ACELP_12k65) >= 0 ) + if( GE_32(core_brate, ACELP_12k65)) { L_temp = L_shl(L_temp, 1); } @@ -276,7 +274,7 @@ static void gs_dec_amr_wb_fx( { temp2 = sub(crit_bands_loc_fx[i], mDiff_len); temp2 = abs_s(temp2); - if (sub(temp, temp2) > 0) + if (GT_16(temp, temp2)) { L_temp = L_msu(L_temp, crit_bins[i], -32768); } @@ -370,9 +368,9 @@ void improv_amr_wb_gs_fx( test(); test(); test(); - IF( ( locattack == 0 && L_sub(core_brate, ACELP_12k65) <= 0) && - ( (L_sub(core_brate, ACELP_8k85) < 0 && sub(clas, AUDIO_CLAS) != 0 && - (sub(clas, UNVOICED_CLAS) == 0 || sub(clas, VOICED_TRANSITION) == 0)) || sub(coder_type, INACTIVE) == 0 ) ) + IF( ( locattack == 0 && LE_32(core_brate, ACELP_12k65))&& + ( (LT_32(core_brate, ACELP_8k85) && NE_16(clas, AUDIO_CLAS) && + (EQ_16(clas, UNVOICED_CLAS) || EQ_16(clas, VOICED_TRANSITION) )) || EQ_16(coder_type, INACTIVE) ) ) { /*------------------------------------------------------------* * two differents paths: @@ -385,7 +383,7 @@ void improv_amr_wb_gs_fx( test(); test(); test(); - IF( sub(coder_type, INACTIVE) == 0 && sub(Last_ener_fx, -3*256) > 0 && sub(last_coder_type_fx,UNVOICED) == 0 && rate_switching_reset == 0 ) /* 3.0 x 256 to Go to Q8 */ + IF( EQ_16(coder_type, INACTIVE)&>_16(Last_ener_fx,-3*256)&&EQ_16(last_coder_type_fx,UNVOICED)&&rate_switching_reset==0) /* 3.0 x 256 to Go to Q8 */ { FOR(i =0; i < NB_SUBFR; i++) diff --git a/lib_dec/gs_dec_fx.c b/lib_dec/gs_dec_fx.c index 35a30de38560a2bcfa62d71ab57c68387f4d98ac..89c855a53ce31c67d73d44763939a6ffec54dafe 100644 --- a/lib_dec/gs_dec_fx.c +++ b/lib_dec/gs_dec_fx.c @@ -1,10 +1,8 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "stl.h" -#include "wmc_auto.h" - #include "options.h" #include "cnst_fx.h" #include "rom_com_fx.h" @@ -72,14 +70,14 @@ void decod_audio_fx( /* decode GSC SWB speech flag */ test(); - IF( sub(coder_type,INACTIVE) != 0 && L_sub(st_fx->total_brate_fx,ACELP_13k20) >= 0 ) + IF( NE_16(coder_type,INACTIVE)&&GE_32(st_fx->total_brate_fx,ACELP_13k20)) { st_fx->GSC_noisy_speech_fx = (Word16) get_next_indice_fx( st_fx, 1 ); } /* safety check in case of bit errors */ test(); - IF( st_fx->GSC_noisy_speech_fx && sub(st_fx->bwidth_fx,SWB) != 0 ) + IF( st_fx->GSC_noisy_speech_fx && NE_16(st_fx->bwidth_fx,SWB)) { st_fx->BER_detect = 1; move16(); @@ -90,7 +88,7 @@ void decod_audio_fx( /*---------------------------------------------------------------* * Decode energy dynamics *---------------------------------------------------------------*/ - IF( sub(st_fx->GSC_noisy_speech_fx,1) == 0 ) + IF( EQ_16(st_fx->GSC_noisy_speech_fx,1)) { nb_subfr = NB_SUBFR; move16(); @@ -101,7 +99,7 @@ void decod_audio_fx( } ELSE { - IF( L_sub(st_fx->core_brate_fx,ACELP_8k00) <= 0 ) + IF( LE_32(st_fx->core_brate_fx,ACELP_8k00)) { st_fx->noise_lev_fx = add((Word16)get_next_indice_fx( st_fx, 2 ), NOISE_LEVEL_SP2); } @@ -119,7 +117,7 @@ void decod_audio_fx( nb_subfr = SWNB_SUBFR; move16(); - IF( L_sub(st_fx->core_brate_fx,ACELP_9k60) >= 0 ) + IF( GE_32(st_fx->core_brate_fx,ACELP_9k60)) { nbits = 1; move16(); @@ -139,12 +137,12 @@ void decod_audio_fx( * Decode the last band where the adaptive (pitch) contribution is significant *---------------------------------------------------------------*/ - IF( L_sub(st_fx->core_brate_fx,CFREQ_BITRATE) < 0 ) + IF( LT_32(st_fx->core_brate_fx,CFREQ_BITRATE)) { nbits = 3; move16(); test(); - if( L_sub(st_fx->core_brate_fx,ACELP_9k60) < 0 && (sub(coder_type,INACTIVE) == 0)) + if( LT_32(st_fx->core_brate_fx,ACELP_9k60)&&(EQ_16(coder_type,INACTIVE))) { nbits = 1; move16(); @@ -156,7 +154,7 @@ void decod_audio_fx( move16(); } test(); - IF( L_sub(st_fx->core_brate_fx,ACELP_9k60) < 0 && sub(coder_type,INACTIVE) != 0 ) + IF( LT_32(st_fx->core_brate_fx,ACELP_9k60)&&NE_16(coder_type,INACTIVE)) { pit_band_idx = 1; move16(); @@ -168,7 +166,7 @@ void decod_audio_fx( IF( pit_band_idx != 0 ) { - IF( L_sub(st_fx->core_brate_fx,ACELP_9k60) < 0 ) + IF( LT_32(st_fx->core_brate_fx,ACELP_9k60)) { pit_band_idx = 7+BAND1k2; move16(); /* At low rate, if pitch model is chosen, then for to be use on extented and constant frequency range */ @@ -179,7 +177,7 @@ void decod_audio_fx( } /* detect bit errors in the bitstream */ - IF( sub(pit_band_idx,13) > 0 ) /* The maximum decodable index is 10 + BAND1k2 (3) = 13 */ + IF( GT_16(pit_band_idx,13)) /* The maximum decodable index is 10 + BAND1k2 (3) = 13 */ { pit_band_idx = 13; move16(); @@ -197,13 +195,13 @@ void decod_audio_fx( * Decode adaptive (pitch) excitation contribution * Reset unvaluable part of the adaptive (pitch) excitation contribution *--------------------------------------------------------------------------------------*/ - IF( sub(pit_band_idx,BAND1k2) > 0 ) + IF( GT_16(pit_band_idx,BAND1k2)) { /*---------------------------------------------------------------* * Decode adaptive (pitch) excitation contribution *---------------------------------------------------------------*/ test(); - IF( sub(st_fx->GSC_noisy_speech_fx,1) == 0 && sub(nb_subfr,NB_SUBFR) == 0 ) + IF( EQ_16(st_fx->GSC_noisy_speech_fx,1)&&EQ_16(nb_subfr,NB_SUBFR)) { Es_pred_dec_fx( st_fx, &Es_pred, GENERIC, st_fx->core_brate_fx ); } @@ -212,22 +210,22 @@ void decod_audio_fx( , gain_buf ); - IF( L_sub(st_fx->core_brate_fx,ACELP_9k60) < 0 ) + IF( LT_32(st_fx->core_brate_fx,ACELP_9k60)) { minimum_fx( pitch_buf, shr(L_FRAME,6), &low_pit); low_pit = shr(low_pit, 6); /*Q6 -> Q0 */ - IF( sub(low_pit,64) < 0) + IF( LT_16(low_pit,64)) { pit_band_idx = 9+BAND1k2; move16(); - if(sub(st_fx->bwidth_fx,NB) == 0) + if(EQ_16(st_fx->bwidth_fx,NB)) { pit_band_idx = 7+BAND1k2; move16(); } } - ELSE IF ( sub(low_pit,128) < 0 ) + ELSE IF ( LT_16(low_pit,128)) { pit_band_idx = 5+BAND1k2; move16(); @@ -255,7 +253,7 @@ void decod_audio_fx( max_len = sub( L_FRAME, Diff_len ); - if(sub(st_fx->bwidth_fx,NB) == 0) + if(EQ_16(st_fx->bwidth_fx,NB)) { max_len = sub(160,Diff_len); } @@ -269,7 +267,7 @@ void decod_audio_fx( } test(); - IF(L_sub(st_fx->core_brate_fx,ACELP_8k00) == 0 && sub(st_fx->bwidth_fx,NB) != 0 ) + IF(EQ_32(st_fx->core_brate_fx,ACELP_8k00)&&NE_16(st_fx->bwidth_fx,NB)) { FOR (i=0; i < max_len; i++) { @@ -342,7 +340,7 @@ void decod_audio_fx( test(); - if( sub(coder_type,INACTIVE) == 0 && L_sub(st_fx->core_brate_fx,ACELP_9k60) <= 0 ) + if( EQ_16(coder_type,INACTIVE)&&LE_32(st_fx->core_brate_fx,ACELP_9k60)) { tmp_nb_bits_tot = add(tmp_nb_bits_tot,5); } @@ -478,7 +476,7 @@ void gsc_dec_fx( *last_bin = 0; move16(); test(); - IF( L_sub(st_fx->core_brate_fx,ACELP_8k00) == 0 && sub(st_fx->bwidth_fx,NB) != 0 ) + IF( EQ_32(st_fx->core_brate_fx,ACELP_8k00)&&NE_16(st_fx->bwidth_fx,NB)) { bitallocation_exc[0] = 0; move16(); @@ -489,7 +487,7 @@ void gsc_dec_fx( set16_fx( bitallocation_band, 0, MBANDS_GN ); test(); - IF( (sub(st_fx->bfi_fx,1) == 0) || st_fx->BER_detect ) + IF( (EQ_16(st_fx->bfi_fx,1))||st_fx->BER_detect) { /*--------------------------------------------------------------------------------------* * Copy old spectrum @@ -497,7 +495,7 @@ void gsc_dec_fx( * save spectrum *--------------------------------------------------------------------------------------*/ test(); - IF( sub(st_fx->last_good_fx,INACTIVE_CLAS) == 0 || sub(st_fx->Last_GSC_noisy_speech_flag_fx,1) == 0 ) + IF( EQ_16(st_fx->last_good_fx,INACTIVE_CLAS)||EQ_16(st_fx->Last_GSC_noisy_speech_flag_fx,1)) { FOR( i=0; ilast_coder_type_fx, AUDIO) != 0 /* First audio frame */ - && sub(st_fx->last_coder_type_fx, UNVOICED) != 0 )/* last_coder_type == INACTIVE is overwritten in update_dec to UNVOICED */ + IF( NE_16(st_fx->last_coder_type_fx, AUDIO) /* First audio frame */ + && NE_16(st_fx->last_coder_type_fx, UNVOICED) )/* last_coder_type == INACTIVE is overwritten in update_dec to UNVOICED */ { FOR( j = 0; j < shl(nb_subbands,4); j++ ) { @@ -564,7 +562,7 @@ void gsc_dec_fx( move16(); } test(); - IF( L_sub(st_fx->core_brate_fx,ACELP_8k00) == 0 && sub(st_fx->bwidth_fx,NB) != 0 ) + IF( EQ_32(st_fx->core_brate_fx,ACELP_8k00)&&NE_16(st_fx->bwidth_fx,NB)) { if( exc_diffQ[L_FRAME8k - 2] != 0 ) { diff --git a/lib_dec/hdecnrm_fx.c b/lib_dec/hdecnrm_fx.c index 48a6061f85590a59a5af01d91ee54d9792015d2a..a1525906bc1549e09cc825a85783b255d925c8a1 100644 --- a/lib_dec/hdecnrm_fx.c +++ b/lib_dec/hdecnrm_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "prot_fx.h" #include "rom_dec_fx.h" -#include "stl.h" -#include "wmc_auto.h" - /* required for wmc_tool */ +#include "stl.h" /* required for wmc_tool */ /*--------------------------------------------------------------------------*/ /* Function hdecnrm_fx */ @@ -142,7 +140,7 @@ void hdecnrm_context_fx( prevj = add(index[0], OFFSET_NORM); FOR( i=1; i < N; i++) { - IF( sub(prevj, HTH_NORM) >0 ) + IF( GT_16(prevj, HTH_NORM)) { /* above */ tmp = decode_huff_context_fx( st_fx, hntable_fx, n_length); @@ -151,7 +149,7 @@ void hdecnrm_context_fx( } ELSE { - IF( sub(prevj, LTH_NORM) <0 ) + IF( LT_16(prevj, LTH_NORM)) { /* less */ index[i] = decode_huff_context_fx(st_fx, hntable_fx, n_length); @@ -204,17 +202,17 @@ void hdecnrm_resize_fx( } } - IF( sub(k, 11) == 0) + IF( EQ_16(k, 11)) { temp = 25; move16(); } - ELSE IF ( sub(k, 10) == 0) + ELSE IF ( EQ_16(k, 10)) { temp = 5; move16(); } - ELSE IF ( sub(k, 9) == 0) + ELSE IF ( EQ_16(k, 9)) { temp = 6; move16(); @@ -278,7 +276,7 @@ void huff_dec_fx( /* Find codeword length */ j = sub(num_lengths, 1); - WHILE ( sub(val, thres[j]) < 0 ) + WHILE ( LT_16(val, thres[j])) { j = sub(j, 1); } @@ -341,7 +339,7 @@ void hdecnrm_tran_fx( test(); test(); test(); - IF((j==0 && k==0) || (sub(j, 1)==0 && k==0) || (sub(j,1)==0 && sub(k,1)==0)) + IF((j==0 && k==0) || (EQ_16(j, 1)&&k==0)||(EQ_16(j,1)&&EQ_16(k,1))) { temp = sub(add(15, l), n); } @@ -369,15 +367,15 @@ void hdecnrm_tran_fx( } test(); - IF( k==0 || sub(k, 3) == 0 ) + IF( k==0 || EQ_16(k, 3)) { temp = sub(temp, 5); - if( sub(k, 3) == 0 ) + if( EQ_16(k, 3)) { temp = sub(temp, 1); } } - ELSE IF( sub(k,1)==0 ) + ELSE IF( EQ_16(k,1)) { temp = add(temp, 1); } diff --git a/lib_dec/hf_synth_fx.c b/lib_dec/hf_synth_fx.c index d56a3944b622d3073e16dfd22efede0393017a8f..8c5424887e93c32231ad1e1e9ca499e6ec2fd915 100644 --- a/lib_dec/hf_synth_fx.c +++ b/lib_dec/hf_synth_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -7,8 +7,6 @@ #include "prot_fx.h" /* Function prototypes */ #include "rom_com_fx.h" /* Static table prototypes */ #include "stl.h" -#include "wmc_auto.h" - #include "basop32.h" #include "cnst_fx.h" @@ -264,7 +262,7 @@ static void hf_synthesis_fx( tmp = add(1, sub(32767, tmp)); test(); - if( L_sub(core_brate,FRAME_NO_DATA) == 0 || L_sub(core_brate,SID_2k40) == 0) + if( EQ_32(core_brate,FRAME_NO_DATA)||EQ_32(core_brate,SID_2k40)) { /* emphasize HF noise in CNG */ /*fac *= 2.0f;*/ @@ -313,7 +311,7 @@ static void hf_synthesis_fx( Copy( temp_buffer, delay_syn_hf, delay ); /* interpolate the HF synthesis */ - IF( sub(output_subfr,L_SUBFR48k) == 0 ) /* 48kHz sampled output */ + IF( EQ_16(output_subfr,L_SUBFR48k)) /* 48kHz sampled output */ { { Word16 s; @@ -328,7 +326,7 @@ static void hf_synthesis_fx( } Scale_sig( upsampled_HF_syn, L_SUBFR48k, -1 ); } - ELSE IF( sub(output_subfr,L_SUBFR32k) == 0 ) /* 32kHz sampled output */ + ELSE IF( EQ_16(output_subfr,L_SUBFR32k)) /* 32kHz sampled output */ { { Word16 s; @@ -381,41 +379,13 @@ static void filt_6k_7k_scale_fx( } FOR (i = 0; i < lg; i++) { - L_tmp = L_mult(x[i], fir_6k_7k_fx[0]); - - /* Inner Loop Unrolled */ - /* All fir_6k_7k_fx[j] could be replaced by Constants and */ - /* thus the table could be removed from rom_com_fx */ - L_tmp = L_mac(L_tmp, x[i+1], fir_6k_7k_fx[1]); - L_tmp = L_mac(L_tmp, x[i+2], fir_6k_7k_fx[2]); - L_tmp = L_mac(L_tmp, x[i+3], fir_6k_7k_fx[3]); - L_tmp = L_mac(L_tmp, x[i+4], fir_6k_7k_fx[4]); - L_tmp = L_mac(L_tmp, x[i+5], fir_6k_7k_fx[5]); - L_tmp = L_mac(L_tmp, x[i+6], fir_6k_7k_fx[6]); - /*L_tmp = L_mac(L_tmp, x[i+7], fir_6k_7k_fx[7]); Coef is 0 */ - L_tmp = L_mac(L_tmp, x[i+8], fir_6k_7k_fx[8]); - L_tmp = L_mac(L_tmp, x[i+9], fir_6k_7k_fx[9]); - L_tmp = L_mac(L_tmp, x[i+10], fir_6k_7k_fx[10]); - L_tmp = L_mac(L_tmp, x[i+11], fir_6k_7k_fx[11]); - L_tmp = L_mac(L_tmp, x[i+12], fir_6k_7k_fx[12]); - L_tmp = L_mac(L_tmp, x[i+13], fir_6k_7k_fx[13]); - L_tmp = L_mac(L_tmp, x[i+14], fir_6k_7k_fx[14]); - L_tmp = L_mac(L_tmp, x[i+15], fir_6k_7k_fx[15]); - L_tmp = L_mac(L_tmp, x[i+16], fir_6k_7k_fx[16]); - L_tmp = L_mac(L_tmp, x[i+17], fir_6k_7k_fx[17]); - L_tmp = L_mac(L_tmp, x[i+18], fir_6k_7k_fx[18]); - L_tmp = L_mac(L_tmp, x[i+19], fir_6k_7k_fx[19]); - L_tmp = L_mac(L_tmp, x[i+20], fir_6k_7k_fx[20]); - L_tmp = L_mac(L_tmp, x[i+21], fir_6k_7k_fx[21]); - L_tmp = L_mac(L_tmp, x[i+22], fir_6k_7k_fx[22]); - /*L_tmp = L_mac(L_tmp, x[i+23], fir_6k_7k_fx[23]); Coef is 0 */ - L_tmp = L_mac(L_tmp, x[i+24], fir_6k_7k_fx[24]); - L_tmp = L_mac(L_tmp, x[i+25], fir_6k_7k_fx[25]); - L_tmp = L_mac(L_tmp, x[i+26], fir_6k_7k_fx[26]); - L_tmp = L_mac(L_tmp, x[i+27], fir_6k_7k_fx[27]); - L_tmp = L_mac(L_tmp, x[i+28], fir_6k_7k_fx[28]); - L_tmp = L_mac(L_tmp, x[i+29], fir_6k_7k_fx[29]); - L_tmp = L_mac(L_tmp, x[i+30], fir_6k_7k_fx[30]); + + Word16 j; + L_tmp = 0; move32(); + for (j = 0; j<31; j++) + { + L_tmp = L_mac(L_tmp, x[i+j], fir_6k_7k_fx[j]); + } signal[i] = round_fx(L_tmp); } @@ -640,7 +610,7 @@ void hf_synth_amr_wb_fx( output_subfr = shr(output_frame , 2); - if( sub(*amr_io_class, 7) != 0 ) + if( NE_16(*amr_io_class, 7)) { core_type = 0; move16(); @@ -657,7 +627,7 @@ void hf_synth_amr_wb_fx( pitch_var_cur = add(pitch_var_cur, shr(tmp1,1)); /*Q6 -> Q5 */ } test(); - IF( sub(*frame_count, FRAME_COUNT) > 0 && *amr_io_class == UNVOICED_CLAS ) + IF( GT_16(*frame_count, FRAME_COUNT)&&*amr_io_class==UNVOICED_CLAS) { *frame_count = 0; move16(); @@ -669,12 +639,12 @@ void hf_synth_amr_wb_fx( tmp1 = *frame_count; move16(); *frame_count = add(*frame_count ,1); - if(sub(tmp1, 2*FRAME_COUNT)>0) + if(GT_16(tmp1, 2*FRAME_COUNT)) { *frame_count = 2*FRAME_COUNT; move16(); } - if ( sub(ng_ener_ST, *ne_min) < 0 ) + if ( LT_16(ng_ener_ST, *ne_min)) { *ne_min = ng_ener_ST; move16();/*Q8; */ @@ -695,7 +665,7 @@ void hf_synth_amr_wb_fx( fmerit_w = s_min(fmerit,5734); fmerit_w = s_max(fmerit_w,2458); - if ( sub(core_type, 1) == 0 ) + if ( EQ_16(core_type, 1)) { fmerit_w = shr(fmerit_w, 1); /*Q14; */ } @@ -709,7 +679,7 @@ void hf_synth_amr_wb_fx( tmp1 = fmerit; move16(); - if(sub(fmerit, 8192) < 0) + if(LT_16(fmerit, 8192)) { tmp1 = 16384; move16(); @@ -822,7 +792,7 @@ void hf_synth_amr_wb_fx( gamma = s_min(16384, gamma); gamma = s_max(4915, gamma); - IF ( sub(beta, 16384) < 0) + IF ( LT_16(beta, 16384)) { L_tmp = 1; /*variable for tonal energy*/ @@ -939,14 +909,14 @@ void hf_synth_amr_wb_fx( scale = 32767; /*~1 in Q15 */ move16(); } - IF ( L_sub(core_brate, ACELP_6k60) == 0 ) + IF ( EQ_32(core_brate, ACELP_6k60)) { filt_weight_coeff = 60; move16(); rev_filt_weight_coeff = 555; move16(); /* 1/(filt_weight_coeff-1) Q15 */ } - ELSE IF ( L_sub(core_brate, ACELP_8k85) == 0 ) + ELSE IF ( EQ_32(core_brate, ACELP_8k85)) { filt_weight_coeff = 40; move16(); @@ -970,7 +940,7 @@ void hf_synth_amr_wb_fx( move16();/*Q14 */ } - IF ( L_sub(core_brate, ACELP_23k85) == 0 ) + IF ( EQ_32(core_brate, ACELP_23k85)) { pt1 = dct_hb+240; tmp = sub(filt_weight_coeff, 80); @@ -979,7 +949,7 @@ void hf_synth_amr_wb_fx( { *pt1 = mult_r(*pt1, scale); /*qdct */ move16(); - IF ( sub(i, sub(320, filt_weight_coeff)) >= 0 ) + IF ( GE_16(i, sub(320, filt_weight_coeff))) { *pt1 = round_fx(L_shl(L_mult(*pt3, *pt1), 1)); /*qdct */ } @@ -1012,13 +982,13 @@ void hf_synth_amr_wb_fx( FOR( i = 240; i < L_FRAME16k; i++ ) { *pt1 = mult_r(*pt1, scale); /*qdct */ - IF ( sub(i, 255) > 0 ) + IF ( GT_16(i, 255)) { *pt1 = mult_r(19505, *pt1); move16(); } - IF ( sub(i, sub(320, filt_weight_coeff)) >= 0 ) + IF ( GE_16(i, sub(320, filt_weight_coeff))) { *pt1 = round_fx(L_shl(L_mult(*pt3, *pt1), 1)); /*qdct */ } @@ -1140,7 +1110,7 @@ static void hf_synthesis_amr_wb_fx( Word32 L_tmp; Word16 q1, q2,q3, shift; Word16 *pt1, *pt2, flag; - IF ( L_sub(core_brate, ACELP_23k85) == 0 ) + IF ( EQ_32(core_brate, ACELP_23k85)) { ener = dot_prod_satcontr(exc, exc, Q_exc, Q_exc, &q1, L_SUBFR); tmp = dot_prod_satcontr(exc16k, exc16k, qhf, qhf, &q2, L_SUBFR16k); @@ -1188,7 +1158,7 @@ static void hf_synthesis_amr_wb_fx( scale = round_fx(Isqrt(L_shl(L_tmp, sub(q2, 24)))); /*Q12 */ flag = negate(s_and(til,-0x8000)); - if (sub(scale, 4096) > 0) + if (GT_16(scale, 4096)) { flag = 1; move16(); @@ -1241,7 +1211,7 @@ static void hf_synthesis_amr_wb_fx( Copy( delay_syn_hf, HF_syn, delay ); Copy( temp_buffer, delay_syn_hf, delay ); - IF( sub(output_subfr, L_SUBFR48k) == 0 ) /* 48kHz sampled output */ + IF( EQ_16(output_subfr, L_SUBFR48k)) /* 48kHz sampled output */ { Word16 s; s = s_max(s_min(sub(s_min(Find_Max_Norm16(HF_syn, L_SUBFR16k), Find_Max_Norm16(mem_hp_interp, INTERP_3_1_MEM_LEN - 3)), 3), @@ -1255,7 +1225,7 @@ static void hf_synthesis_amr_wb_fx( Scale_sig( mem_hp_interp, INTERP_3_1_MEM_LEN, -s ); Scale_sig( HF_syn, L_SUBFR16k, -s ); } - ELSE IF( sub(output_subfr, L_SUBFR32k) == 0 ) /* 32kHz sampled output */ + ELSE IF( EQ_16(output_subfr, L_SUBFR32k)) /* 32kHz sampled output */ { Word16 s; s = s_max( sub(s_min(Find_Max_Norm16(HF_syn, L_SUBFR16k), Find_Max_Norm16(mem_hp_interp, 2*ALLPASSSECTIONS_STEEP)),2), 0 ); @@ -1314,7 +1284,7 @@ static Word16 EnhanceClass_fx( /**unvoicing_fx = add(mult_r(16384, *unvoicing_fx), mult_r(16384, unvoicing_tmp_fx)); //Q15 */ *unvoicing_fx = round_fx(L_mac(L_mult(16384, *unvoicing_fx), 16384, unvoicing_tmp_fx)); /*Q15 */ - IF( sub(*unvoicing_sm_fx, *unvoicing_fx) > 0 ) + IF( GT_16(*unvoicing_sm_fx, *unvoicing_fx)) { /**unvoicing_sm_fx = add(mult_r(29491, *unvoicing_sm_fx), mult_r(3277, *unvoicing_fx)); //Q15 */ *unvoicing_sm_fx = round_fx(L_mac(L_mult(29491, *unvoicing_sm_fx), 3277, *unvoicing_fx)); /*Q15 */ @@ -1325,17 +1295,17 @@ static Word16 EnhanceClass_fx( *unvoicing_sm_fx = round_fx(L_mac(L_mult(32440, *unvoicing_sm_fx), 328, *unvoicing_fx)); /*Q15 */ } - if ( sub(sub(*unvoicing_fx, *unvoicing_sm_fx),3277) > 0) + if ( GT_16(sub(*unvoicing_fx, *unvoicing_sm_fx),3277)) { *unvoicing_flag = 1; } - if ( sub(sub(*unvoicing_fx, *unvoicing_sm_fx),1638) < 0) + if ( LT_16(sub(*unvoicing_fx, *unvoicing_sm_fx),1638)) { *unvoicing_flag = 0; } test(); - return ( *unvoicing_flag && sub(qq_fx, pp_fx)>0 ); + return ( *unvoicing_flag && GT_16(qq_fx, pp_fx) ); } static void envelope_fx( @@ -1372,7 +1342,7 @@ static void envelope_fx( Copy_Scale_sig(Aq_dyn_scal, Aq, M+1, shift); /* LPC envelope weighting */ - IF( L_sub(core_brate,ACELP_6k60) == 0 ) + IF( EQ_32(core_brate,ACELP_6k60)) { weight_a_lc_fx( Aq, Ap, Gamma_29491_Tbl, M ); } @@ -1465,7 +1435,7 @@ static void envelope_fx( rr = round_fx(Isqrt(L_shr(L_tmp, add(11, shl(q2, 1))))); /*Q10*/ Copy(Aq, As, 3); - IF ( add(2048, shr(As[2],1)) == 0 ) + IF ( EQ_16(shr(As[2],1),-2048) ) { k2 = -2458; move16(); @@ -1498,22 +1468,22 @@ static void envelope_fx( k1 = round_fx(L_shl(L_tmp, q1)); /*Q12 */ k2 = As[2]; move16(); /*Q12 */ - if ( sub(k2, 2458) > 0 ) + if ( GT_16(k2, 2458)) { k2 = 2458; move16(); } - if ( add(k2, 2458) < 0 ) + if ( LT_16(k2, -2458) ) { k2 = -2458; move16(); } - if ( sub(k1, 4055) > 0 ) + if ( GT_16(k1, 4055)) { k1 = 4055; move16(); } - if ( add(k1, 4055) < 0 ) + if ( LT_16(k1, -4055) ) { k1 = -4055; move16(); @@ -1571,7 +1541,7 @@ static void envelope_fx( move16(); IF ( Unvoicing_flag ) { - IF ( sub(rr, (*prev_r)) > 0 ) + IF ( GT_16(rr, (*prev_r))) { rr = shr(add(rr, (*prev_r)), 1); } @@ -1595,7 +1565,7 @@ static void envelope_fx( ELSE { test(); - IF ( sub(rr, 1024) < 0 && sub((*prev_r), 1024) < 0 ) + IF ( LT_16(rr, 1024)&<_16((*prev_r),1024)) { L_tmp = L_mult(rr, rr); /*Q21*/ tmp = round_fx(L_shl(L_tmp, 9)); /*Q14*/ @@ -1670,14 +1640,14 @@ void AdaptiveStartBand_fx( test(); test(); test(); - if( sub(voicing_fac_fx, 6554) > 0 || (sub(voicing_fac_fx, 4915) > 0 && sub(clas,VOICED_CLAS) >= 0) || sub(clas,AUDIO_CLAS) == 0 ) + if( GT_16(voicing_fac_fx, 6554)||(GT_16(voicing_fac_fx,4915)&&GE_16(clas,VOICED_CLAS))||EQ_16(clas,AUDIO_CLAS)) { *voicing_flag = 1; move16(); } test(); - if( sub(voicing_fac_fx, 3277) < 0 && sub(clas,VOICED_CLAS) < 0 ) + if( LT_16(voicing_fac_fx, 3277)&<_16(clas,VOICED_CLAS)) { *voicing_flag = 0; move16(); @@ -1686,7 +1656,7 @@ void AdaptiveStartBand_fx( /* rate adaptive start band */ *start_band = 160; move16(); - IF( L_sub(rate, ACELP_23k05) < 0 ) + IF( LT_32(rate, ACELP_23k05)) { pt1 = lsf_diff_fx+1; pt2 = lsf_fx+1; @@ -1701,7 +1671,7 @@ void AdaptiveStartBand_fx( tmp2 = extract_l(L_tmp); /*Q26 */ W_fx = mult_r(tmp1, tmp2); /*Q25 */ - if (sub(clas,AUDIO_CLAS) == 0) + if (EQ_16(clas,AUDIO_CLAS)) { W_fx = mult_r(W_fx, 24576); /*Q25 */ } @@ -1709,17 +1679,17 @@ void AdaptiveStartBand_fx( pos = 2; move16(); M2 = sub(M, 2); - IF( sub(*voicing_flag,1) == 0 ) + IF( EQ_16(*voicing_flag,1)) { - IF( L_sub(rate, ACELP_8k85) <= 0 ) + IF( LE_32(rate, ACELP_8k85)) { M2 = sub(M, 8); } - ELSE IF( L_sub(rate, ACELP_12k65) <= 0 ) + ELSE IF( LE_32(rate, ACELP_12k65)) { M2 = sub(M, 6); } - ELSE IF( L_sub(rate, ACELP_15k85) <= 0 ) + ELSE IF( LE_32(rate, ACELP_15k85)) { M2 = sub(M, 4); } @@ -1742,7 +1712,7 @@ void AdaptiveStartBand_fx( Crit_fx = Mult_32_16(L_tmp, *pt1++); /* Q2.56+25+1+2.56-15 = Q11+2.56+2.56 */ - IF( L_sub(Crit_fx, OptCrit_fx) <= 0 ) + IF( LE_32(Crit_fx, OptCrit_fx)) { OptCrit_fx = L_add(Crit_fx, 0); /* Q11+2.56+2.56 */ pos = i; @@ -1758,14 +1728,14 @@ void AdaptiveStartBand_fx( test(); test(); test(); - IF ( sub(voicing_flag_old, *voicing_flag) != 0 || ( *voicing_flag == 0 && L_sub(OptCrit_fx, *OptCrit_old_fx) < 0 ) || - ( L_sub(OptCrit_fx, L_tmp) < 0 && L_sub(*OptCrit_old_fx, 858993) > 0 ) ) + IF ( NE_16(voicing_flag_old, *voicing_flag)||(*voicing_flag==0&<_32(OptCrit_fx,*OptCrit_old_fx))|| + ( LT_32(OptCrit_fx, L_tmp) && GT_32(*OptCrit_old_fx, 858993) > 0 ) ) { *OptCrit_old_fx = OptCrit_fx; move16(); test(); test(); - if ( sub(abs_s(sub((*start_band),(*start_band_old))), 20)<0 && sub(*voicing_flag,1)==0 && sub(voicing_flag_old,1)==0 ) + if ( LT_16(abs_s(sub((*start_band),(*start_band_old))), 20)&&EQ_16(*voicing_flag,1)&&EQ_16(voicing_flag_old,1)) { *start_band = *start_band_old; move16(); @@ -1774,7 +1744,7 @@ void AdaptiveStartBand_fx( ELSE { test(); - if (L_sub(OptCrit_fx, (*OptCrit_old_fx))<0 && sub((*voicing_flag),1)==0) + if (LT_32(OptCrit_fx, (*OptCrit_old_fx))&&EQ_16((*voicing_flag),1)) { *OptCrit_old_fx = OptCrit_fx; move16(); @@ -1784,7 +1754,7 @@ void AdaptiveStartBand_fx( move16(); } - if (sub(clas,AUDIO_CLAS) == 0) + if (EQ_16(clas,AUDIO_CLAS)) { *start_band = s_min(*start_band, 120); move16(); diff --git a/lib_dec/hq_classifier_dec_fx.c b/lib_dec/hq_classifier_dec_fx.c index 1892426a46b181bb3f0db6d033c14b7ba98e7671..8dd054b3ce775f6c27f1816578c1ef9a431c597d 100644 --- a/lib_dec/hq_classifier_dec_fx.c +++ b/lib_dec/hq_classifier_dec_fx.c @@ -1,12 +1,10 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "prot_fx.h" /* Function prototypes */ -#include "stl.h" -#include "wmc_auto.h" - /* required for wmc_tool */ +#include "stl.h" /* required for wmc_tool */ /*--------------------------------------------------------------------------* * hq_classifier_dec() @@ -25,12 +23,12 @@ Word16 hq_classifier_dec_fx( /* o : Consumed bits Q0 Word16 bits; test(); - IF ( sub(length, L_FRAME32k) >= 0 && L_sub(core_brate, HQ_32k) <= 0 ) + IF ( GE_16(length, L_FRAME32k)&&LE_32(core_brate,HQ_32k)) { *hqswb_clas = get_next_indice_fx( st_fx, 2 ); move16(); test(); - if (( sub(length, L_FRAME48k) == 0 ) && ( sub(*hqswb_clas, HQ_NORMAL) == 0 )) + if (( EQ_16(length, L_FRAME48k))&&(EQ_16(*hqswb_clas,HQ_NORMAL))) { *hqswb_clas = HQ_GEN_FB; move16(); @@ -44,7 +42,7 @@ Word16 hq_classifier_dec_fx( /* o : Consumed bits Q0 *is_transient = 0; move16(); - if ( sub(*hqswb_clas, HQ_TRANSIENT) == 0 ) + if ( EQ_16(*hqswb_clas, HQ_TRANSIENT)) { *is_transient = 1; move16(); @@ -52,7 +50,7 @@ Word16 hq_classifier_dec_fx( /* o : Consumed bits Q0 test(); test(); - if ( *hqswb_clas == HQ_NORMAL && sub(length, L_FRAME32k) == 0 && L_sub(core_brate, HQ_32k) <= 0) + if ( *hqswb_clas == HQ_NORMAL && EQ_16(length, L_FRAME32k)&&LE_32(core_brate,HQ_32k)) { *hqswb_clas = HQ_GEN_SWB; move16(); @@ -61,7 +59,7 @@ Word16 hq_classifier_dec_fx( /* o : Consumed bits Q0 bits = 1; move16(); test(); - if ( sub(length, L_FRAME32k) >= 0 && L_sub(core_brate, HQ_32k) <= 0 ) + if ( GE_16(length, L_FRAME32k)&&LE_32(core_brate,HQ_32k)) { bits = 2; move16(); diff --git a/lib_dec/hq_conf_fec_fx.c b/lib_dec/hq_conf_fec_fx.c index 7c6fa968a4906128954e1699ee7a57bc099010bf..f7fafe2e862ba91f3d2f18a1d550e77b3d242248 100644 --- a/lib_dec/hq_conf_fec_fx.c +++ b/lib_dec/hq_conf_fec_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -7,9 +7,7 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" #include "cnst_fx.h" -#include "stl.h" -#include "wmc_auto.h" - /* required for wmc_tool */ +#include "stl.h" /* required for wmc_tool */ /*--------------------------------------------------------------------------* diff --git a/lib_dec/hq_core_dec_fx.c b/lib_dec/hq_core_dec_fx.c index 290567f35437f56374b9db6afc22165d92a4fbfa..eea721c61d1c173af9a781493f94af0b2d541b6e 100644 --- a/lib_dec/hq_core_dec_fx.c +++ b/lib_dec/hq_core_dec_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -7,8 +7,6 @@ #include "prot_fx.h" /* Function prototypes */ #include "rom_com_fx.h" /* Static table prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*-------------------------------------------------------------------------- * hq_core_dec() * @@ -58,7 +56,7 @@ void hq_core_dec_fx( st_fx->tcx_cfg.tcx_last_overlap_mode = st_fx->tcx_cfg.tcx_curr_overlap_mode; move16(); - if (sub(st_fx->tcx_cfg.tcx_curr_overlap_mode, FULL_OVERLAP) == 0) + if (EQ_16(st_fx->tcx_cfg.tcx_curr_overlap_mode, FULL_OVERLAP)) { st_fx->tcx_cfg.tcx_last_overlap_mode = ALDO_WINDOW; move16(); @@ -77,12 +75,12 @@ void hq_core_dec_fx( IF( !st_fx->bfi_fx ) { - IF ( sub(core_switching_flag, 1) == 0 ) + IF ( EQ_16(core_switching_flag, 1)) { core_switching_hq_prepare_dec_fx( st_fx, &num_bits, output_frame ); /* During ACELP->HQ core switching, limit the HQ core bitrate to 48kbps */ - if ( sub(num_bits, HQ_48k / 50) > 0 ) + if ( GT_16(num_bits, HQ_48k / 50)) { num_bits = (Word16)(HQ_48k / 50); move16(); @@ -97,7 +95,7 @@ void hq_core_dec_fx( /* subtract the number of bits for pitch & gain at higher bitrates */ test(); - IF ( !(core_switching_flag) && L_sub(st_fx->core_brate_fx, MINIMUM_RATE_TO_ENCODE_VOICING_FLAG) > 0 ) + IF ( !(core_switching_flag) && GT_32(st_fx->core_brate_fx, MINIMUM_RATE_TO_ENCODE_VOICING_FLAG)) { st_fx->HqVoicing_fx = get_next_indice_fx( st_fx, 1 ); num_bits = sub(num_bits, 1); @@ -106,7 +104,7 @@ void hq_core_dec_fx( { st_fx->HqVoicing_fx = 0; move16(); - if ( L_sub(st_fx->core_brate_fx, MINIMUM_RATE_TO_ENCODE_VOICING_FLAG) > 0 ) + if ( GT_32(st_fx->core_brate_fx, MINIMUM_RATE_TO_ENCODE_VOICING_FLAG)) { st_fx->HqVoicing_fx = 1; move16(); @@ -127,14 +125,14 @@ void hq_core_dec_fx( { st_fx->ph_ecu_HqVoicing_fx = 0; move16(); - if ( sub(output_frame, L_FRAME16k) >= 0 ) + if ( GE_16(output_frame, L_FRAME16k)) { st_fx->ph_ecu_HqVoicing_fx = st_fx->HqVoicing_fx; move16(); } } - IF ( sub(output_frame, L_FRAME8k) == 0 ) + IF ( EQ_16(output_frame, L_FRAME8k)) { hq_configure_bfi_fx( &nb_sfm, &num_Sb, num_bands_p, &sfmsize, &sfm_start, &sfm_end ); } @@ -143,11 +141,11 @@ void hq_core_dec_fx( * transform-domain decoding *--------------------------------------------------------------------------*/ - IF( sub(st_fx->bfi_fx, 1) == 0 ) + IF( EQ_16(st_fx->bfi_fx, 1)) { is_transient = st_fx->old_is_transient_fx[0]; move16(); - IF ( sub(output_frame, L_FRAME16k) >= 0 ) /* Apply phase ecu for WB, SWB and FB */ + IF ( GE_16(output_frame, L_FRAME16k)) /* Apply phase ecu for WB, SWB and FB */ { /* ecu_rec sent to OLA, env_stab passed in ph_ecu_st */ hq_ecu_fx( st_fx->prev_good_synth_fx, t_audio_q, &st_fx->time_offs_fx, st_fx->X_sav_fx, &st_fx->Q_X_sav, &st_fx->num_p_fx, st_fx->plocs_fx, st_fx->plocsi_fx, st_fx->env_stab_fx, @@ -165,7 +163,7 @@ void hq_core_dec_fx( st_fx->old_is_transient_fx[1] = st_fx->old_is_transient_fx[0]; move16(); - IF ( sub(output_frame, L_FRAME16k) >= 0 ) + IF ( GE_16(output_frame, L_FRAME16k)) { /* keep st->previoussynth updated as in FEC_HQ_pitch_analysis but no LP analysis */ delay_comp = NS2SA_fx2(st_fx->output_Fs_fx, DELAY_CLDFB_NS); @@ -181,9 +179,9 @@ void hq_core_dec_fx( } ELSE { - IF( sub(hq_core_type, LOW_RATE_HQ_CORE) == 0 ) + IF( EQ_16(hq_core_type, LOW_RATE_HQ_CORE)) { - IF( sub(st_fx->prev_bfi_fx, 1) == 0 ) + IF( EQ_16(st_fx->prev_bfi_fx, 1)) { set32_fx( st_fx->last_ni_gain_fx, 0, BANDS_MAX ); set16_fx( st_fx->last_env_fx, 0, BANDS_MAX ); @@ -208,9 +206,9 @@ void hq_core_dec_fx( } /* scaling (coefficients are in nominal level) */ - IF( sub(output_frame, NORM_MDCT_FACTOR) != 0 ) + IF( NE_16(output_frame, NORM_MDCT_FACTOR)) { - IF (sub(output_frame, L_FRAME32k) == 0) + IF (EQ_16(output_frame, L_FRAME32k)) { Q_audio = sub(Q_audio, 1); /* Multiply by 2 */ } @@ -237,7 +235,7 @@ void hq_core_dec_fx( /* attenuate HFs in case of band-width switching */ IF( st_fx->bws_cnt1_fx > 0 ) { - IF( sub(st_fx->bws_cnt1_fx,N_NS2W_FRAMES) == 0 ) + IF( EQ_16(st_fx->bws_cnt1_fx,N_NS2W_FRAMES)) { ener_match = 32767; move16(); /*Q15*/ @@ -289,10 +287,10 @@ void hq_core_dec_fx( *--------------------------------------------------------------------------*/ test(); - IF (sub(output_frame, L_FRAME8k) == 0 || st_fx->bfi_fx == 0) + IF (EQ_16(output_frame, L_FRAME8k)||st_fx->bfi_fx==0) { test(); - IF( sub(inner_frame, output_frame) != 0 && sub(st_fx->bfi_fx, 1) == 0 ) + IF( NE_16(inner_frame, output_frame)&&EQ_16(st_fx->bfi_fx,1)) { Inverse_Transform( t_audio_q, &Q_audio, wtda_audio, is_transient, output_frame, output_frame ); } @@ -304,14 +302,14 @@ void hq_core_dec_fx( move16(); } - IF ( sub(output_frame, L_FRAME8k) == 0 ) + IF ( EQ_16(output_frame, L_FRAME8k)) { test(); IF( st_fx->bfi_fx == 0 && st_fx->prev_bfi_fx == 0) { Copy_Scale_sig(st_fx->old_out_fx+N_ZERO_NB, st_fx->prev_oldauOut_fx, output_frame-N_ZERO_NB, negate(st_fx->Q_old_wtda) ); } - ELSE IF( sub(st_fx->prev_bfi_fx, 1) == 0) + ELSE IF( EQ_16(st_fx->prev_bfi_fx, 1)) { set16_fx( st_fx->prev_oldauOut_fx, 0, output_frame ); } @@ -320,7 +318,7 @@ void hq_core_dec_fx( test(); test(); test(); - IF( (sub(st_fx->prev_bfi_fx, 1) == 0 || sub(st_fx->bfi_fx, 1) == 0) && st_fx->old_is_transient_fx[2] == 0 && sub(st_fx->last_core_fx, HQ_CORE) == 0 && sub(st_fx->last_codec_mode,MODE1)==0) + IF( (EQ_16(st_fx->prev_bfi_fx, 1)||EQ_16(st_fx->bfi_fx,1))&&st_fx->old_is_transient_fx[2]==0&&EQ_16(st_fx->last_core_fx,HQ_CORE)&&EQ_16(st_fx->last_codec_mode,MODE1)) { time_domain_FEC_HQ_fx( st_fx, wtda_audio, synth, mean_en_high_fx, output_frame, Q_synth ); } @@ -334,7 +332,7 @@ void hq_core_dec_fx( test(); test(); - IF ( (st_fx->bfi_fx == 0 && st_fx->prev_bfi_fx == 0) || !(sub(output_frame, L_FRAME16k) >= 0)) + IF ( (st_fx->bfi_fx == 0 && st_fx->prev_bfi_fx == 0) || !(GE_16(output_frame, L_FRAME16k))) { preecho_sb_fx( st_fx->core_brate_fx, wtda_audio, Q_audio, synth, *Q_synth, output_frame, &st_fx->memfilt_lb_fx, &st_fx->mean_prev_hb_fx, &st_fx->smoothmem_fx, &st_fx->mean_prev_fx, &st_fx->mean_prev_nc_fx, &st_fx->wmold_hb_fx, &st_fx->prevflag_fx, &st_fx->pastpre_fx, st_fx->bwidth_fx ); @@ -343,7 +341,7 @@ void hq_core_dec_fx( ELSE { test(); - IF (sub(st_fx->bfi_fx, 1) == 0 && sub(output_frame, L_FRAME16k) >= 0 ) + IF (EQ_16(st_fx->bfi_fx, 1)&&GE_16(output_frame,L_FRAME16k)) { /* PHASE_ECU active */ Q_audio = 15; @@ -362,7 +360,7 @@ void hq_core_dec_fx( test(); test(); - IF ( (st_fx->bfi_fx == 0 && st_fx->prev_bfi_fx == 0) || !(sub(output_frame, L_FRAME16k) >= 0)) + IF ( (st_fx->bfi_fx == 0 && st_fx->prev_bfi_fx == 0) || !(GE_16(output_frame, L_FRAME16k))) { preecho_sb_fx( st_fx->core_brate_fx, wtda_audio, Q_audio, synth,*Q_synth, output_frame, &st_fx->memfilt_lb_fx, &st_fx->mean_prev_hb_fx, &st_fx->smoothmem_fx, &st_fx->mean_prev_fx, &st_fx->mean_prev_nc_fx, &st_fx->wmold_hb_fx, &st_fx->prevflag_fx, &st_fx->pastpre_fx, st_fx->bwidth_fx ); @@ -379,11 +377,11 @@ void hq_core_dec_fx( test(); IF (!st_fx->bfi_fx && st_fx->prev_bfi_fx - && L_sub(st_fx->last_total_brate_fx, HQ_48k) >= 0 - && sub(st_fx->last_codec_mode, MODE2) == 0 - && (sub(st_fx->last_core_bfi, TCX_20_CORE) == 0 || sub(st_fx->last_core_bfi, TCX_10_CORE) == 0) + && GE_32(st_fx->last_total_brate_fx, HQ_48k) + && EQ_16(st_fx->last_codec_mode, MODE2) + && (EQ_16(st_fx->last_core_bfi, TCX_20_CORE) || EQ_16(st_fx->last_core_bfi, TCX_10_CORE) ) && st_fx->plcInfo.concealment_method == TCX_NONTONAL - && L_sub(st_fx->plcInfo.nbLostCmpt, 4) < 0 ) + && LT_32(st_fx->plcInfo.nbLostCmpt, 4) ) { st_fx->plcInfo.recovery_gain = shl(st_fx->plcInfo.recovery_gain, *Q_synth); waveform_adj2_fix(st_fx->tonalMDCTconceal.secondLastPcmOut, @@ -401,9 +399,9 @@ void hq_core_dec_fx( st_fx->bfi_fx); } - IF (sub(output_frame, L_FRAME16k) >= 0) + IF (GE_16(output_frame, L_FRAME16k)) { - IF (sub(st_fx->ph_ecu_HqVoicing_fx, 1) == 0) + IF (EQ_16(st_fx->ph_ecu_HqVoicing_fx, 1)) { st_fx->oldHqVoicing_fx = 1; move16(); @@ -421,13 +419,13 @@ void hq_core_dec_fx( move16(); } - if( sub(st_fx->nbLostCmpt, FRAMECTTOSTART_MDCT) == 0 ) + if( EQ_16(st_fx->nbLostCmpt, FRAMECTTOSTART_MDCT)) { st_fx->HqVoicing_fx = 0; move16(); } - IF( sub(output_frame, L_FRAME8k) == 0) + IF( EQ_16(output_frame, L_FRAME8k)) { Copy32( wtda_audio, st_fx->oldIMDCTout_fx, L_FRAME8k/2 ); Copy(&st_fx->old_auOut_2fr_fx[output_frame], st_fx->old_auOut_2fr_fx, output_frame); @@ -440,7 +438,7 @@ void hq_core_dec_fx( Word16 nbsubfr; /*nbsubfr = extract_l(L_mult0(st_fx->L_frame_fx,FL2WORD16(1/L_SUBFR)));*/ nbsubfr = 4; - if(sub(st_fx->L_frame_fx,320) == 0) + if(EQ_16(st_fx->L_frame_fx,320)) { nbsubfr = 5; move16(); @@ -448,7 +446,7 @@ void hq_core_dec_fx( /* update buffer of old subframe pitch values */ test(); - IF( sub(st_fx->last_core_fx,HQ_CORE) == 0 && sub(st_fx->L_frame_fx,st_fx->last_L_frame_fx) != 0 ) + IF( EQ_16(st_fx->last_core_fx,HQ_CORE)&&NE_16(st_fx->L_frame_fx,st_fx->last_L_frame_fx)) { set32_fx( &st_fx->old_pitch_buf_fx[nbsubfr], (L_SUBFR<<16), nbsubfr ); } diff --git a/lib_dec/hq_env_dec_fx.c b/lib_dec/hq_env_dec_fx.c index 0c9ca457ad41979b8d631dbd2728b40c7cf0f6e5..3cd741bc6ffc91208ecea9e4c4afc3f5fb29618c 100644 --- a/lib_dec/hq_env_dec_fx.c +++ b/lib_dec/hq_env_dec_fx.c @@ -1,14 +1,12 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include #include "options.h" /* Compilation switches */ #include "prot_fx.h" /* Function prototypes */ #include "rom_com_fx.h" /* Static table prototypes */ -#include "stl.h" -#include "wmc_auto.h" - /* required for wmc_tool */ +#include "stl.h" /* required for wmc_tool */ /*------------------------------------------------------------------------* * decode_envelope_indices_fx() @@ -33,7 +31,7 @@ Word16 decode_envelope_indices_fx( /* o : Number of bits */ Word16 *pDifidx,*pDifidx1; test(); - IF( sub(flag_HQ2, LOW_RATE_HQ_CORE) == 0 || sub(flag_HQ2, LOW_RATE_HQ_CORE_TRAN) == 0 ) + IF( EQ_16(flag_HQ2, LOW_RATE_HQ_CORE)||EQ_16(flag_HQ2,LOW_RATE_HQ_CORE_TRAN)) { LCmode = (Word16)get_next_indice_fx ( st_fx, BITS_DE_HMODE); difidx[start_norm] = (Word16)get_next_indice_fx ( st_fx, BITS_DE_FCOMP); @@ -45,11 +43,11 @@ Word16 decode_envelope_indices_fx( /* o : Number of bits */ } test(); - IF( is_transient && sub(flag_HQ2, LOW_RATE_HQ_CORE_TRAN) == 0 ) + IF( is_transient && EQ_16(flag_HQ2, LOW_RATE_HQ_CORE_TRAN)) { hcode_l = 0; move16(); - IF( sub(LCmode, 1) == 0 ) + IF( EQ_16(LCmode, 1)) { hdecnrm_tran_fx(st_fx, num_sfm, &difidx[start_norm + 1] ); j = add(start_norm, num_sfm); @@ -176,7 +174,7 @@ void dequantize_norms_fx( move16(); /* safety check in case of bit errors */ test(); - IF ( idxbuf[i] < 0 || sub( idxbuf[i], 39 ) > 0) + IF ( idxbuf[i] < 0 || GT_16( idxbuf[i], 39 )) { idxbuf[i] = 39; move16(); @@ -201,7 +199,7 @@ void dequantize_norms_fx( move16(); /* safety check in case of bit errors */ test(); - IF ( *pYnrm < 0 || sub( *pYnrm, 39 ) > 0) + IF ( *pYnrm < 0 || GT_16( *pYnrm, 39 )) { *pYnrm = 39; move16(); diff --git a/lib_dec/hq_hr_dec_fx.c b/lib_dec/hq_hr_dec_fx.c index 868fe0777e1e4ffbef136b8805c1cf39be6e29f7..d60328197324d675b7eca9288225a396e0477a8b 100644 --- a/lib_dec/hq_hr_dec_fx.c +++ b/lib_dec/hq_hr_dec_fx.c @@ -1,11 +1,9 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "stl.h" -#include "wmc_auto.h" - #include "prot_fx.h" /* Function prototypes */ #include "rom_com_fx.h" /* Static table prototypes */ @@ -21,12 +19,12 @@ void hq_pred_hb_bws_fx( Word16 i; Word32 L_tmp; - IF( sub(length,L_FRAME32k) >= 0) + IF( GE_16(length,L_FRAME32k)) { /* calculate the switching parameters */ test(); test(); - IF( ( sub(hqswb_clas,HQ_GEN_SWB) != 0 && L_sub(st_fx->core_brate_fx,HQ_32k) <= 0 ) || L_sub(st_fx->core_brate_fx,HQ_32k) > 0 ) + IF( ( NE_16(hqswb_clas,HQ_GEN_SWB)&&LE_32(st_fx->core_brate_fx,HQ_32k))||GT_32(st_fx->core_brate_fx,HQ_32k)) { st_fx->prev_ener_shb_fx = 0; move16(); @@ -51,7 +49,7 @@ void hq_pred_hb_bws_fx( } } - IF( sub(st_fx->last_inner_frame_fx,L_FRAME32k) >= 0 ) + IF( GE_16(st_fx->last_inner_frame_fx,L_FRAME32k)) { set16_fx(st_fx->prev_SWB_fenv_fx, st_fx->prev_ener_shb_fx, SWB_FENV); } @@ -141,7 +139,7 @@ void hq_hr_dec_fx( test(); test(); test(); - IF( !*is_transient && sub(*hqswb_clas, HQ_HVQ) != 0 && !(sub(length, L_FRAME16k) == 0 && L_sub(st_fx->core_brate_fx, HQ_32k) == 0)) + IF( !*is_transient && NE_16(*hqswb_clas, HQ_HVQ)&&!(EQ_16(length,L_FRAME16k)&&EQ_32(st_fx->core_brate_fx,HQ_32k))) { nf_idx = get_next_indice_fx( st_fx, 2 ); } @@ -156,10 +154,10 @@ void hq_hr_dec_fx( dequantize_norms_fx( st_fx, start_norm, num_env_bands, *is_transient, ynrm, normqlg2 ); test(); - IF ( sub(*hqswb_clas, HQ_GEN_SWB) == 0 || sub(*hqswb_clas, HQ_GEN_FB) == 0 ) + IF ( EQ_16(*hqswb_clas, HQ_GEN_SWB)||EQ_16(*hqswb_clas,HQ_GEN_FB)) { hq_generic_exc_clas = swb_bwe_gain_deq_fx( st_fx, HQ_CORE, NULL, SWB_fenv, st_fx->core_brate_fx == HQ_32k, *hqswb_clas ); - if ( sub(hq_generic_exc_clas , HQ_GENERIC_SP_EXC) == 0) + if ( EQ_16(hq_generic_exc_clas , HQ_GENERIC_SP_EXC)) { num_bits = add(num_bits,1); /* conditional 1 bit saving for representing HQ GENERIC excitation class */ } @@ -168,12 +166,12 @@ void hq_hr_dec_fx( env_stab = 0; move16(); - IF( sub(*hqswb_clas, HQ_HVQ) == 0 ) + IF( EQ_16(*hqswb_clas, HQ_HVQ)) { st_fx->mem_env_delta_fx = 0; move16(); } - ELSE IF( sub(length, L_FRAME32k) == 0 ) + ELSE IF( EQ_16(length, L_FRAME32k)) { env_stab = env_stability_fx( ynrm, SFM_N_ENV_STAB, st_fx->mem_norm_fx, &st_fx->mem_env_delta_fx ); } @@ -185,14 +183,14 @@ void hq_hr_dec_fx( move16(); } - IF ( sub(*hqswb_clas, HQ_HVQ) == 0 ) + IF ( EQ_16(*hqswb_clas, HQ_HVQ)) { st_fx->env_stab_fx = 32767; move16(); /* 1 in Q15, stable by definition */ } ELSE { - IF ( sub(length, L_FRAME32k) == 0 ) + IF ( EQ_16(length, L_FRAME32k)) { st_fx->env_stab_fx = env_stab; move16(); /* calculated stability */ @@ -213,11 +211,11 @@ void hq_hr_dec_fx( test(); test(); - IF( sub(*hqswb_clas, HQ_GEN_SWB) == 0 && st_fx->bws_cnt1_fx > 0 && L_sub(st_fx->core_brate_fx, HQ_24k40) == 0 ) + IF( EQ_16(*hqswb_clas, HQ_GEN_SWB)&&st_fx->bws_cnt1_fx>0&&EQ_32(st_fx->core_brate_fx,HQ_24k40)) { tmp = i_mult(st_fx->bws_cnt1_fx, 1638); move16(); - IF( sub(st_fx->L_frame_fx, L_FRAME16k) == 0 ) + IF( EQ_16(st_fx->L_frame_fx, L_FRAME16k)) { FOR (n_band = 0; n_band < 4; n_band++) { @@ -234,7 +232,7 @@ void hq_hr_dec_fx( } test(); - IF ( sub(*hqswb_clas , HQ_GEN_SWB) == 0 || sub(*hqswb_clas , HQ_GEN_FB) == 0 ) + IF ( EQ_16(*hqswb_clas , HQ_GEN_SWB)||EQ_16(*hqswb_clas,HQ_GEN_FB)) { b_delta_env = get_nor_delta_hf_fx(st_fx, ynrm, Rsubband, num_env_bands, nb_sfm, core_sfm ); sum = sub(sum,b_delta_env); @@ -244,7 +242,7 @@ void hq_hr_dec_fx( * Decode spectral fine structure using HVQ/PVQ *------------------------------------------------------------------*/ - IF( sub(*hqswb_clas, HQ_HVQ) == 0 ) + IF( EQ_16(*hqswb_clas, HQ_HVQ)) { hvq_dec_fx( st_fx, num_bits, st_fx->core_brate_fx, ynrm, R, noise_level, peak_idx, &Npeaks, t_audio_q, st_fx->core_fx ); } @@ -254,7 +252,7 @@ void hq_hr_dec_fx( } test(); - IF ( sub(*hqswb_clas, HQ_HVQ) == 0 || sub(*hqswb_clas, HQ_HARMONIC) == 0 ) + IF ( EQ_16(*hqswb_clas, HQ_HVQ)||EQ_16(*hqswb_clas,HQ_HARMONIC)) { subband_search_offset = subband_search_offsets_13p2kbps_Har_fx; wBands[0] = SWB_SB_BW_LEN0_16KBPS_HAR; @@ -262,7 +260,7 @@ void hq_hr_dec_fx( wBands[1] = SWB_SB_BW_LEN1_16KBPS_HAR; move16(); - IF (sub(*hqswb_clas, HQ_HARMONIC) == 0) + IF (EQ_16(*hqswb_clas, HQ_HARMONIC)) { Q_shift = sub(SWB_BWE_LR_Qs, Q_audio); FOR (i = 0; i < 300; i++) @@ -279,7 +277,7 @@ void hq_hr_dec_fx( test(); test(); - IF ( sub(*hqswb_clas, HQ_HARMONIC) != 0 || sub(*hqswb_clas, HQ_HVQ) != 0 || flag_dis == 0) + IF ( NE_16(*hqswb_clas, HQ_HARMONIC)||NE_16(*hqswb_clas,HQ_HVQ)||flag_dis==0) { st_fx->prev_frm_hfe2_fx = 0; /*reset*/ move16(); st_fx->prev_stab_hfe2_fx = 0; /*reset*/ move16(); @@ -297,7 +295,7 @@ void hq_hr_dec_fx( enforce_zero_for_min_envelope_fx( *hqswb_clas, ynrm, t_audio_q, nb_sfm, sfm_start, sfm_end ); - IF( sub(*is_transient, 1) == 0 ) + IF( EQ_16(*is_transient, 1)) { de_interleave_spectrum_fx( t_audio_q, length ); } diff --git a/lib_dec/hq_lr_dec_fx.c b/lib_dec/hq_lr_dec_fx.c index 6003483bdf756c70bb05110684ffc977cb16f308..aaa9bb5898324dc94edddc49f9bdb440356d7862 100644 --- a/lib_dec/hq_lr_dec_fx.c +++ b/lib_dec/hq_lr_dec_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -10,9 +10,7 @@ #include "rom_dec_fx.h" #include "prot_fx.h" #include "rom_com_fx.h" -#include "stl.h" -#include "wmc_auto.h" - /* required for wmc_tool */ +#include "stl.h" /* required for wmc_tool */ #include "basop_mpy.h" /*--------------------------------------------------------------------------* @@ -83,11 +81,11 @@ static void spt_shorten_domain_set_dec_fx( { spt_shorten_flag[j] = 0; move16(); - IF( sub(p2a_flags[k], 1) == 0) + IF( EQ_16(p2a_flags[k], 1)) { spt_shorten_flag[j] = get_next_indice_fx (st_fx, 1 ); *bit_budget = sub(*bit_budget, 1); - IF( sub(spt_shorten_flag[j], 1) == 0) + IF( EQ_16(spt_shorten_flag[j], 1)) { band_start[k] = new_band_start[j]; move16(); @@ -208,14 +206,14 @@ void hq_lr_dec_fx( move16(); test(); test(); - IF( sub(st_fx->bwidth_fx, SWB) == 0 && ( L_sub(L_bwe_br, HQ_16k40) == 0 || L_sub(L_bwe_br, HQ_13k20) == 0 ) ) + IF( EQ_16(st_fx->bwidth_fx, SWB)&&(EQ_32(L_bwe_br,HQ_16k40)||EQ_32(L_bwe_br,HQ_13k20))) { hqswb_clas_fx = get_next_indice_fx(st_fx, 2); num_bits = sub(num_bits, 2); *is_transient_fx = 0; move16(); - if ( sub(hqswb_clas_fx, HQ_TRANSIENT) == 0 ) + if ( EQ_16(hqswb_clas_fx, HQ_TRANSIENT)) { *is_transient_fx = 1; move16(); @@ -241,15 +239,15 @@ void hq_lr_dec_fx( test(); test(); test(); - IF( sub(st_fx->bwidth_fx, SWB) == 0 && *is_transient_fx == 0 && (L_sub(L_bwe_br, HQ_16k40) == 0 || L_sub(L_bwe_br, HQ_13k20) == 0) ) + IF( EQ_16(st_fx->bwidth_fx, SWB)&&*is_transient_fx==0&&(EQ_32(L_bwe_br,HQ_16k40)||EQ_32(L_bwe_br,HQ_13k20))) { /* reserve bits for HQ_NORMAL2 and HQ_HARMONIC modes */ test(); - IF( sub(hqswb_clas_fx, HQ_NORMAL) == 0 || sub(hqswb_clas_fx, HQ_HARMONIC) == 0 ) + IF( EQ_16(hqswb_clas_fx, HQ_NORMAL)||EQ_16(hqswb_clas_fx,HQ_HARMONIC)) { num_bits = sub(num_bits, get_usebit_npswb_fx(hqswb_clas_fx)); } - if( sub(hqswb_clas_fx, HQ_NORMAL) == 0) + if( EQ_16(hqswb_clas_fx, HQ_NORMAL)) { flag_spt_fx = 1; move16(); @@ -258,9 +256,9 @@ void hq_lr_dec_fx( test(); test(); - IF(( L_sub(L_bwe_br, HQ_16k40) == 0 || L_sub(L_bwe_br, HQ_13k20) == 0) && sub(st_fx->bwidth_fx, SWB) == 0 ) + IF(( EQ_32(L_bwe_br, HQ_16k40)||EQ_32(L_bwe_br,HQ_13k20))&&EQ_16(st_fx->bwidth_fx,SWB)) { - IF( sub(st_fx->prev_hqswb_clas_fx, HQ_NORMAL) != 0 ) + IF( NE_16(st_fx->prev_hqswb_clas_fx, HQ_NORMAL)) { j = 0; move16(); @@ -281,7 +279,7 @@ void hq_lr_dec_fx( { /* Max: 45.0(737279,Q14) at 32kHz, highest band, Min: -6.600037(-108135,Q14) at 8kHz(NB),8kbps, is_transient (-6.7f(-109772,Q14) is safty-threshold) */ test(); - IF( L_sub(L_band_energy[k], 737279L) > 0 || L_sub(L_band_energy[k], -109772L) < 0 ) + IF( GT_32(L_band_energy[k], 737279L)||LT_32(L_band_energy[k],-109772L)) { st_fx->BER_detect = 1; move16(); @@ -301,9 +299,9 @@ void hq_lr_dec_fx( move16(); test(); test(); - IF( sub(st_fx->bwidth_fx, SWB) == 0 && (L_sub(L_bwe_br, HQ_16k40) == 0 || L_sub(L_bwe_br, HQ_13k20) == 0 ) ) + IF( EQ_16(st_fx->bwidth_fx, SWB)&&(EQ_32(L_bwe_br,HQ_16k40)||EQ_32(L_bwe_br,HQ_13k20))) { - IF ( sub(hqswb_clas_fx, HQ_HARMONIC) == 0 ) + IF ( EQ_16(hqswb_clas_fx, HQ_HARMONIC)) { set16_fx( p2a_flags_fx, 1, har_bands_fx ); } @@ -312,7 +310,7 @@ void hq_lr_dec_fx( pbits_fx = p2a_threshold_dequant_fx( st_fx, p2a_flags_fx, bands_fx, p2a_bands_fx ); bit_budget_fx = sub(bit_budget_fx, pbits_fx); - IF( sub(hqswb_clas_fx, HQ_NORMAL) == 0 ) + IF( EQ_16(hqswb_clas_fx, HQ_NORMAL)) { return_bits_normal2_fx( &bit_budget_fx, p2a_flags_fx, bands_fx, bits_lagIndices_modeNormal_fx ); } @@ -324,7 +322,7 @@ void hq_lr_dec_fx( bit_budget_fx = sub(bit_budget_fx, pbits_fx); } - IF( sub(flag_spt_fx, 1) == 0 ) + IF( EQ_16(flag_spt_fx, 1)) { /* initalize the desired parameters for SPT */ spt_shorten_domain_band_save_fx(bands_fx, band_start, band_end, band_width, org_band_start, org_band_end, org_band_width); @@ -333,7 +331,7 @@ void hq_lr_dec_fx( } /* safety check in case of bit errors */ - IF( sub(bit_budget_fx, 2) < 0 ) + IF( LT_16(bit_budget_fx, 2)) { st_fx->BER_detect = 1; move16(); @@ -386,7 +384,7 @@ void hq_lr_dec_fx( test(); test(); test(); - IF ( *is_transient_fx == 0 && sub(inner_frame, L_FRAME8k) == 0 && L_sub(st_fx->core_brate_fx, ACELP_13k20) <= 0 ) + IF ( *is_transient_fx == 0 && EQ_16(inner_frame, L_FRAME8k)&&LE_32(st_fx->core_brate_fx,ACELP_13k20)) { /* decode the last p2a_bands-1 subbands bit-allocation index of the previous frame */ j = 0; @@ -406,7 +404,7 @@ void hq_lr_dec_fx( set16_fx(&p2a_flags_tmp[sub(bands_fx,trans_bit_fx)], 0, 2); - IF( L_sub(st_fx->core_brate_fx, ACELP_13k20) == 0 ) + IF( EQ_32(st_fx->core_brate_fx, ACELP_13k20)) { beta_fx = 13107; move16();/*14 1.25f; */ @@ -422,7 +420,7 @@ void hq_lr_dec_fx( Ep_peak_fx = L_deposit_l(0); FOR( i = 0; i < bands_fx; i++ ) { - IF( sub(i,lowband) >= 0) + IF( GE_16(i,lowband)) { Ep_vari_fx = L_add(Ep_vari_fx,L_abs(L_sub(Ep_tmp_fx[i],Ep_tmp_fx[sub(i,1)])));/*Q15 */ Ep_avrg_fx = L_add(Ep_avrg_fx,Ep_tmp_fx[i]);/*Q15 */ @@ -431,7 +429,7 @@ void hq_lr_dec_fx( ELSE { Ep_avrgL_fx = L_add(Ep_avrgL_fx,Ep_tmp_fx[i]);/*Q15 */ - if(L_sub(Ep_tmp_fx[i],Ep_peak_fx) > 0) + if(GT_32(Ep_tmp_fx[i],Ep_peak_fx)) { Ep_peak_fx = L_add(Ep_tmp_fx[i], 0); /*Q15 */ } @@ -448,13 +446,13 @@ void hq_lr_dec_fx( test(); test(); test(); - IF(( (L_sub(L_tmp, L_shr(Ep_avrgL_fx,1)) < 0 && L_sub(st_fx->core_brate_fx, ACELP_13k20) == 0 ) || L_sub(st_fx->core_brate_fx, ACELP_13k20) < 0 )&& - L_sub(L_tmp2, L_tmp3) < 0 && L_sub(L_tmp2, L_shr(Ep_avrg_fx,7)) > 0) + IF(( (LT_32(L_tmp, L_shr(Ep_avrgL_fx,1))&&EQ_32(st_fx->core_brate_fx,ACELP_13k20))||LT_32(st_fx->core_brate_fx,ACELP_13k20))&& + LT_32(L_tmp2, L_tmp3) && GT_32(L_tmp2, L_shr(Ep_avrg_fx,7)) ) { FOR(i = lowband; i < bands_fx; i++) { L_tmp = Mult_32_16(Ep_avrg_fx,24576);/*Q(13+14-15 = 12) 1.5 */ - IF(L_sub(L_shr(Ep_tmp_fx[i],1), L_tmp) < 0) + IF(LT_32(L_shr(Ep_tmp_fx[i],1), L_tmp)) { L_tmp = Mult_32_16(Ep_peak_fx,sub(bands_fx,lowband));/*Q(13+0-15 = -2) */ tmp = Calc_inv(L_shl(L_tmp,14), &exp); @@ -471,7 +469,7 @@ void hq_lr_dec_fx( { alpha_fx = 16384; move16();/*Q14 */ - IF( sub(p2a_flags_tmp[i],1) == 0) + IF( EQ_16(p2a_flags_tmp[i],1)) { L_tmp = Mult_32_16(Ep_tmp_fx[i],sub(bands_fx,lowband));/*Q(13+0-15 = -2) */ tmp = Calc_inv(L_shl(L_tmp,14), &exp); @@ -501,7 +499,7 @@ void hq_lr_dec_fx( alpha_fx =add(16384,tmp); } - IF(sub(last_bitalloc_max_band[j++], 1) == 0) + IF(EQ_16(last_bitalloc_max_band[j++], 1)) { L_tmp = Mult_32_16(Ep_tmp_fx[i],sub(bands_fx,lowband));/*Q(13+0-15 = -2) */ tmp = Calc_inv(L_shl(L_tmp,14), &exp); @@ -544,14 +542,14 @@ void hq_lr_dec_fx( Ep_peak_fx = L_deposit_l(0); FOR(i = 0; i < bands_fx; i++) { - IF(sub(i,lowband) >=0 ) + IF(GE_16(i,lowband)) { Ep_avrg_fx = L_add(Ep_avrg_fx,Ep_tmp_fx[i]);/*Q15 */ } ELSE { Ep_avrgL_fx = L_add(Ep_avrgL_fx,L_shr(Ep_tmp_fx[i],1));/*Q12 */ - if(L_sub(Ep_tmp_fx[i],Ep_peak_fx) > 0) + if(GT_32(Ep_tmp_fx[i],Ep_peak_fx)) { Ep_peak_fx = L_add(Ep_tmp_fx[i], 0); /*Q13 */ } @@ -561,7 +559,7 @@ void hq_lr_dec_fx( L_tmp2 =Mult_32_16(Ep_avrgL_fx,24576);/*Q(12+14-15 = 11) */ test(); test(); - IF( L_sub(L_shr(Ep_avrg_fx,2), L_tmp2) > 0 && L_sub(L_shr(Ep_avrg_fx,4), L_tmp2) < 0 && L_sub(L_tmp, Ep_avrgL_fx)>0) + IF( GT_32(L_shr(Ep_avrg_fx,2), L_tmp2)&<_32(L_shr(Ep_avrg_fx,4),L_tmp2)&>_32(L_tmp,Ep_avrgL_fx)) { adjustFlag = 1; move16(); @@ -581,7 +579,7 @@ void hq_lr_dec_fx( L_band_energy_tmp, bands_fx, L_Rk, &bit_budget_fx, p2a_flags_fx, bit_alloc_weight_fx, band_width, num_bits, hqswb_clas_fx, st_fx->bwidth_fx, *is_transient_fx ); } - ELSE IF( *is_transient_fx == 0 && sub(inner_frame, L_FRAME16k) == 0 ) + ELSE IF( *is_transient_fx == 0 && EQ_16(inner_frame, L_FRAME16k)) { bit_budget_fx = sub(bit_budget_fx,2);/* bits in high bands to indicate the last 2 subbands is allocated bits or not */ @@ -595,7 +593,7 @@ void hq_lr_dec_fx( Ep_tmp_fx[i] = L_shl(Ep_tmp_fx[i],2); move32(); } - IF( L_sub( st_fx->core_brate_fx, ACELP_13k20 ) == 0) + IF( EQ_32( st_fx->core_brate_fx, ACELP_13k20 )) { lowband = 8; move16(); @@ -621,17 +619,17 @@ void hq_lr_dec_fx( FOR( i = 0; i < bands_fx; i++ ) { test(); - IF( sub(i,lowband) >= 0 && add(sub(i,bands_fx),p2a_bands_fx) < 0) + IF( GE_16(i,lowband)&&add(sub(i,bands_fx),p2a_bands_fx)<0) { Ep_vari_fx = L_add(Ep_vari_fx,L_abs(L_sub(Ep_tmp_fx[i],Ep_tmp_fx[sub(i,1)])));/*Q15 */ Ep_avrg_fx = L_add(Ep_avrg_fx,Ep_tmp_fx[i]);/*Q15 */ } - IF(sub(i,highband) >= 0) + IF(GE_16(i,highband)) { enerH_fx = L_add(enerH_fx,L_shl(Ep_fx[i],2));/*Q0 */ } - ELSE IF(sub(i,lowband) >= 0) + ELSE IF(GE_16(i,lowband)) { enerL_fx = L_add(enerL_fx,L_shl(Ep_fx[i],2));/*Q0 */ } @@ -649,7 +647,7 @@ void hq_lr_dec_fx( FOR( i = sub(bands_fx,p2a_bands_fx); i < bands_fx; i++ ) { test(); - IF( sub(p2a_flags_fx[i],1) == 0 || L_tmp2 > 0 ) + IF( EQ_16(p2a_flags_fx[i],1)||L_tmp2>0) { tmp = sub(bands_fx,p2a_bands_fx); tmp = sub(tmp,lowband);/*Q0 */ @@ -691,7 +689,7 @@ void hq_lr_dec_fx( IF(add(sub(i,bands_fx),p2a_bands_fx) > 0) { tmp = sub(bands_fx, p2a_bands_fx); - IF(sub(last_bitalloc_max_band[sub(i, add(tmp, 1))], 1) == 0) + IF(EQ_16(last_bitalloc_max_band[sub(i, add(tmp, 1))], 1)) { tmp = sub(tmp,lowband); L_tmp = Mult_32_16(Ep_tmp_fx[i],tmp);/*Q(15+0-15 = 0) */ @@ -740,14 +738,14 @@ void hq_lr_dec_fx( Ep_peak_fx = L_deposit_l(0); FOR(i = 0; i < bands_fx; i++) { - IF(sub(i,lowband) >= 0) + IF(GE_16(i,lowband)) { Ep_avrg_fx = L_add(Ep_avrg_fx,Ep_tmp_fx[i]);/*Q15 */ } ELSE { Ep_avrgL_fx = L_add(Ep_avrgL_fx,Ep_tmp_fx[i]);/*Q15 */ - if(L_sub(Ep_tmp_fx[i],Ep_peak_fx) > 0) + if(GT_32(Ep_tmp_fx[i],Ep_peak_fx)) { Ep_peak_fx = L_add(Ep_tmp_fx[i], 0); /*Q15 */ } @@ -764,8 +762,8 @@ void hq_lr_dec_fx( test(); test(); test(); - IF( (L_sub(L_shr(Ep_avrgL_fx,1), Ep_avrg_fx)>0 && L_sub(L_tmp,L_shr(Ep_avrgL_fx,2)) > 0 && L_sub(L_shr(Ep_avrgL_fx,1),L_tmp2) < 0 ) || - (L_sub(L_shr(Ep_avrg_fx,1), Ep_avrgL_fx)>0 && L_sub(L_shr(Ep_avrg_fx,3),L_tmp3) < 0 && L_sub(L_tmp,L_shr(Ep_avrgL_fx,2)) > 0 ) ) + IF( (GT_32(L_shr(Ep_avrgL_fx,1), Ep_avrg_fx)&>_32(L_tmp,L_shr(Ep_avrgL_fx,2))&<_32(L_shr(Ep_avrgL_fx,1),L_tmp2))|| + (GT_32(L_shr(Ep_avrg_fx,1), Ep_avrgL_fx) && LT_32(L_shr(Ep_avrg_fx,3),L_tmp3) && GT_32(L_tmp,L_shr(Ep_avrgL_fx,2)) ) ) { adjustFlag = 1; move16(); @@ -785,7 +783,7 @@ void hq_lr_dec_fx( L_band_energy_tmp, bands_fx, L_Rk, &bit_budget_fx, p2a_flags_fx, bit_alloc_weight_fx, band_width, num_bits, hqswb_clas_fx, st_fx->bwidth_fx, *is_transient_fx ); } - ELSE IF( sub(st_fx->bwidth_fx, SWB) == 0 && sub(hqswb_clas_fx, HQ_HARMONIC) == 0 && (L_sub(L_bwe_br, HQ_16k40) == 0 || L_sub(L_bwe_br, HQ_13k20) == 0) ) + ELSE IF( EQ_16(st_fx->bwidth_fx, SWB)&&EQ_16(hqswb_clas_fx,HQ_HARMONIC)&&(EQ_32(L_bwe_br,HQ_16k40)||EQ_32(L_bwe_br,HQ_13k20))) { hq2_bit_alloc_har_fx( L_band_energy, bit_budget_fx, bands_fx, L_Rk, p2a_bands_fx, L_bwe_br, p2a_flags_fx, band_width ); } @@ -817,7 +815,7 @@ void hq_lr_dec_fx( test(); test(); /* Restore the band information */ - IF( sub(flag_spt_fx, 1) == 0 ) + IF( EQ_16(flag_spt_fx, 1)) { spt_shorten_domain_band_restore_fx(bands_fx, band_start, band_end, band_width, org_band_start, org_band_end, org_band_width); } @@ -834,10 +832,10 @@ void hq_lr_dec_fx( test(); test(); - IF( sub(st_fx->bwidth_fx, SWB) == 0 && (L_sub(L_bwe_br, HQ_16k40) == 0 || L_sub(L_bwe_br, HQ_13k20) == 0 ) ) + IF( EQ_16(st_fx->bwidth_fx, SWB)&&(EQ_32(L_bwe_br,HQ_16k40)||EQ_32(L_bwe_br,HQ_13k20))) { test(); - IF( sub(hqswb_clas_fx, HQ_NORMAL) == 0 || sub(hqswb_clas_fx, HQ_HARMONIC) == 0) + IF( EQ_16(hqswb_clas_fx, HQ_NORMAL)||EQ_16(hqswb_clas_fx,HQ_HARMONIC)) { preset_hq2_swb_fx( hqswb_clas_fx, band_end, &har_bands_fx, p2a_bands_fx,length_fx, bands_fx, &lowlength_fx, &highlength_fx, L_m ); @@ -854,7 +852,7 @@ void hq_lr_dec_fx( post_hq2_swb_fx( L_m, lowlength_fx, highlength_fx, hqswb_clas_fx, har_bands_fx, bands_fx, p2a_flags_fx, band_start, band_end, L_y2, npulses_fx ); - IF( sub(hqswb_clas_fx, HQ_NORMAL) == 0 ) + IF( EQ_16(hqswb_clas_fx, HQ_NORMAL)) { spt_swb_peakpos_tmp_save_fx(L_y2, bands_fx, band_start, band_end, prev_SWB_peak_pos_tmp_fx); FOR( k=0; klast_inner_frame_fx, L_FRAME16k) >= 0 && st_fx->bws_cnt_fx > 0 )) + IF( !(GE_16(st_fx->last_inner_frame_fx, L_FRAME16k)&&st_fx->bws_cnt_fx>0)) { k1_fx = sub(bands_fx,2); - if(sub(*is_transient_fx,1) != 0) + if(NE_16(*is_transient_fx,1)) { k1_fx = sub(bands_fx,6); } @@ -895,7 +893,7 @@ void hq_lr_dec_fx( } st_fx->prev_ener_shb_fx = extract_l(L_shr(L_tmp, 14)); } - IF( sub(st_fx->last_inner_frame_fx,L_FRAME32k) >= 0 ) + IF( GE_16(st_fx->last_inner_frame_fx,L_FRAME32k)) { set16_fx(st_fx->prev_SWB_fenv_fx, st_fx->prev_ener_shb_fx ,SWB_FENV); } @@ -1030,7 +1028,7 @@ static Word16 large_symbol_dec_fx( /* o : bits IF ( ns2mode0 == 0 ) { - IF ( sub(ns2mode1, 1) == 0 ) + IF ( EQ_16(ns2mode1, 1)) { pos_outlyer = get_next_indice_fx (st_fx, BITS_DE_8SPOS); cntbits = add(cntbits, BITS_DE_8SPOS); @@ -1064,7 +1062,7 @@ static Word16 large_symbol_dec_fx( /* o : bits } ELSE { - IF ( sub(ns2mode1, 1) == 0 ) + IF ( EQ_16(ns2mode1, 1)) { pos_outlyer = get_next_indice_fx (st_fx, BITS_DE_8SPOS); cntbits = add(cntbits, BITS_DE_8SPOS); diff --git a/lib_dec/igf_dec.c b/lib_dec/igf_dec.c index 12eec106183396aa364ec12ba78bb6f3e5f6c637..156999b7482f64b6e23ea6d31092bdc3c9bd96df 100644 --- a/lib_dec/igf_dec.c +++ b/lib_dec/igf_dec.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -8,8 +8,6 @@ #include #include "options.h" #include "stl.h" -#include "wmc_auto.h" - #include "prot_fx.h" #include "cnst_fx.h" #include "stat_dec_fx.h" @@ -32,9 +30,10 @@ static Word16 IGF_getScaleFactor32Cond( Word32 tmp32; - x_max = L_add(0, 0); - x_min = L_add(0, 0); - + x_max = 0; + move32(); + x_min = 0; + move32(); FOR (i = 0; i < len_x; i++) { tmp32 = L_add(x[i], 0); /*L_and(x[i], cond[i]);*/ @@ -97,7 +96,8 @@ static Word16 IGF_replaceTCXNoise_1( noise = 0; move16(); s_l = sub(s_l, 5); - nE = L_add(0, 0); + nE = 0; + move32(); FOR (sb = start; sb < stop; sb++) { @@ -142,7 +142,8 @@ static void IGF_replaceTCXNoise_2(Word32 *in, val = 0; move16(); - rE = L_add(0, 0); + rE = 0; + move32(); FOR (sb = start; sb < stop; sb++) { @@ -183,7 +184,8 @@ static void IGF_replaceTCXNoise_2(Word32 *in, L_tmp = L_sub(rE, totalNoiseNrg); if (L_tmp < 0) { - rE = L_add(totalNoiseNrg, 0); /* save move32() -> use L_add(x, 0) = x; */ + rE = totalNoiseNrg; /* save move32() -> use L_add(x, 0) = x; */ + move32(); } @@ -324,10 +326,11 @@ static void IGF_prep(IGF_DEC_PRIVATE_DATA_HANDLE hPrivate move16(); /* strong whitening detected */ - IF (sub(IGF_WHITENING_STRONG, hPrivateData->currWhiteningLevel[tile_idx]) == 0) + IF (EQ_16(IGF_WHITENING_STRONG, hPrivateData->currWhiteningLevel[tile_idx])) { Word32 abs_sum; - abs_sum = L_add(0, 0); + abs_sum = 0; + move32(); FOR(i = strt_cpy; i < hGrid->startLine; i++) { @@ -349,7 +352,8 @@ static void IGF_prep(IGF_DEC_PRIVATE_DATA_HANDLE hPrivate { FOR (i = strt_cpy; i < startLine; i++) { - igf_spec[tb++] = L_add(0, 0); + igf_spec[tb++] = 0; + move32(); } } @@ -360,7 +364,7 @@ static void IGF_prep(IGF_DEC_PRIVATE_DATA_HANDLE hPrivate ELSE { /* medium whitening detected */ - IF (sub(IGF_WHITENING_MID, hPrivateData->currWhiteningLevel[tile_idx]) == 0) + IF (EQ_16(IGF_WHITENING_MID, hPrivateData->currWhiteningLevel[tile_idx])) { IF (n_noise_bands != 0) { @@ -593,8 +597,10 @@ static void IGF_appl(IGF_DEC_PRIVATE_DATA_HANDLE hPrivate move16(); dNlocal_e = 0; move16(); - L_tmp = L_add(0, 0); - dNlocal = L_add(0, 0); + L_tmp = 0; + move32(); + dNlocal = 0; + move32(); set16_fx(gain, 0, IGF_MAX_SFB); set16_fx(gain_e, 0, IGF_MAX_SFB); @@ -637,7 +643,8 @@ static void IGF_appl(IGF_DEC_PRIVATE_DATA_HANDLE hPrivate &dE_e, negate(tmp)); - L_c = L_add(0, 0); + L_c = 0; + move32(); FOR (tb = 0; tb < 24; tb++) { Carry = 0; @@ -656,12 +663,12 @@ static void IGF_appl(IGF_DEC_PRIVATE_DATA_HANDLE hPrivate /* select correct hopsize for envelope refinement */ hopsize = 2; move16(); - if (sub(hPrivateData->currWhiteningLevel[0], IGF_WHITENING_OFF) == 0) + if (EQ_16(hPrivateData->currWhiteningLevel[0], IGF_WHITENING_OFF)) { hopsize = 4; move16(); } - if (sub(hPrivateData->currWhiteningLevel[0], IGF_WHITENING_STRONG) == 0) + if (EQ_16(hPrivateData->currWhiteningLevel[0], IGF_WHITENING_STRONG)) { hopsize = 1; move16(); @@ -741,10 +748,10 @@ static void IGF_appl(IGF_DEC_PRIVATE_DATA_HANDLE hPrivate /* max(0.001 * sNlocal, L_tmp) */ /* Build a threshold and compare with L_tmp. Build negated threshold and compare with negated L_tmp to cover also fullscale L_tmp case */ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF L_tmp2 = L_shl(L_negate(Mpy_32_16_1(sNlocal, 33/*0.001f Q15*/)), sub(sNlocal_e, L_tmp_e)); L_tmp2 = L_sub(L_tmp2, L_negate(L_tmp)); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON IF (L_tmp2 < 0) { @@ -810,10 +817,10 @@ static void IGF_appl(IGF_DEC_PRIVATE_DATA_HANDLE hPrivate /* max(0.001 * sNlocal, L_tmp) */ /* Build a threshold and compare with L_tmp. Build negated threshold and compare with negated L_tmp to cover also fullscale L_tmp case */ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF L_tmp2 = L_shl(L_negate(Mpy_32_16_1(sNlocal, 33/*0.001f Q15*/)), sub(sNlocal_e,L_tmp_e)); L_tmp2 = L_sub(L_tmp2, L_negate(L_tmp)); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON IF (L_tmp2 < 0 ) { @@ -861,7 +868,7 @@ static void IGF_appl(IGF_DEC_PRIVATE_DATA_HANDLE hPrivate sfb_p1 = add(start_sfb, 1); sfb_m1 = sub(stop_sfb, 1); test(); - IF (hGrid->infoIsRefined != 0 && sub(hopsize, 1) == 0) + IF (hGrid->infoIsRefined != 0 && EQ_16(hopsize, 1)) { /* apply filter to absolute energy values: */ FOR (sfb = sfb_p1; sfb < sfb_m1; sfb++) @@ -908,7 +915,8 @@ static void IGF_appl(IGF_DEC_PRIVATE_DATA_HANDLE hPrivate move16(); FOR (sfb = start_sfb; sfb < stop_sfb; sfb += hopsize) { - E = L_add(0, 0); + E = 0; + move32(); E_e = 0; move16(); sum = 0; @@ -1011,7 +1019,7 @@ static void IGF_appl(IGF_DEC_PRIVATE_DATA_HANDLE hPrivate /*--- check gains /spectrum exponents for possible overflows --- */ /* get tile index */ - if (sub(hGrid->sfbWrap[tileIdx + 1], sfb) <= 0) + if (LE_16(hGrid->sfbWrap[tileIdx + 1], sfb)) { tileIdx = add(tileIdx, 1); } @@ -1061,7 +1069,7 @@ static void IGF_appl(IGF_DEC_PRIVATE_DATA_HANDLE hPrivate FOR (sfb = start_sfb; sfb < stop_sfb; sfb++) { /* get tile index */ - if (sub(hGrid->sfbWrap[tileIdx + 1], sfb) == 0) + if (EQ_16(hGrid->sfbWrap[tileIdx + 1], sfb)) { tileIdx = add(tileIdx, 1); } @@ -1074,9 +1082,9 @@ static void IGF_appl(IGF_DEC_PRIVATE_DATA_HANDLE hPrivate gain_e[sfb] = sub(gain_e[sfb], tmp); /* gain[sfb] = min(gain[sfb], 12.f); */ - BASOP_SATURATE_WARNING_OFF; /* threshold, may overflow */ + BASOP_SATURATE_WARNING_OFF /* threshold, may overflow */ tmp = shl(gain[sfb], sub(gain_e[sfb], 15 - 5)); /* 10Q5 | tmp is in 10Q5 */ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON IF (tmp > 384) /* 10Q5 | 384 = 12 in 10Q5 */ { @@ -1086,22 +1094,22 @@ static void IGF_appl(IGF_DEC_PRIVATE_DATA_HANDLE hPrivate move16(); } - IF (sub(hPrivateData->frameLossCounter, 5) < 0) + IF (LT_16(hPrivateData->frameLossCounter, 5)) { /* gain[sfb] -= gain[sfb] / 8 * hPrivateData->frameLossCounter; -> multiply with 0Q15 -> adaption of the exponent not needed */ - IF (sub(hPrivateData->frameLossCounter, 1) == 0) + IF (EQ_16(hPrivateData->frameLossCounter, 1)) { /* 0Q15 | >> 3 ^= * 0.125 = 1 / 8 */ gain[sfb] = sub(gain[sfb], shr_r(gain[sfb], 3)); move16(); } - ELSE IF (sub(hPrivateData->frameLossCounter, 2) == 0) + ELSE IF (EQ_16(hPrivateData->frameLossCounter, 2)) { /* 0Q15 | >> 2 ^= * 0.25 = 2 / 8 */ gain[sfb] = sub(gain[sfb], shr_r(gain[sfb], 2)); move16(); } - ELSE IF (sub(hPrivateData->frameLossCounter, 3) == 0) + ELSE IF (EQ_16(hPrivateData->frameLossCounter, 3)) { /* 0Q15 | * 12288 ^= * 0.3750 = 3 / 8 */ gain[sfb] = sub(gain[sfb], mult_r(gain[sfb], 12288)); @@ -1125,7 +1133,8 @@ static void IGF_appl(IGF_DEC_PRIVATE_DATA_HANDLE hPrivate FOR (tb = hGrid->swb_offset[sfb]; tb < hGrid->swb_offset[sfb + 1]; tb++) { /* multiply the prepared IGF spectrum with the gain */ - L_tmp2 = L_add(0, 0); /* set L_tmp2 to default value */ + L_tmp2 = 0; /* set L_tmp2 to default value */ + move32(); L_tmp = Mpy_32_16_1(igf_spec[tb], gain[sfb]); L_tmp_e = add(igf_spec_e[tileIdx], gain_e[sfb]); @@ -1185,7 +1194,8 @@ static void IGF_getWhiteSpectralData(const Word32 *in, div = 0; move16(); s_l = sub(s_l, 2); - ak = L_add(0, 0); + ak = 0; + move32(); FOR (j = start - level; j < start + level; j++) @@ -1232,7 +1242,7 @@ static void IGF_getWhiteSpectralData(const Word32 *in, tmp_16 = s_min(14, sub(15, shr(tmp_16, 1))); div = shl(1, tmp_16); - if (L_sub(ak, 16) < 0) + if (LT_32(ak, 16)) { div = 1; move16(); @@ -1455,8 +1465,8 @@ void IGFDecApplyMono(const IGF_DEC_INSTANCE_HANDLE hInstance, move16(); hPrivateData->headroom_TCX_noise = 0; move16(); - hPrivateData->totalNoiseNrg = L_add(0, 0); - hPrivateData->totalNoiseNrg_off = L_add(0, 0); + hPrivateData->totalNoiseNrg = 0; move32(); + hPrivateData->totalNoiseNrg_off = 0; move32(); set32_fx(igf_spec, 0, IGF_MAX_GRANULE_LEN); set16_fx(igf_spec_e, 0, IGF_MAX_TILES); @@ -1478,7 +1488,7 @@ void IGFDecApplyMono(const IGF_DEC_INSTANCE_HANDLE hInstance, FOR (i = 0; i < hGrid->nTiles; i++) { - IF (sub(hPrivateData->currWhiteningLevel[i], IGF_WHITENING_MID) == 0) + IF (EQ_16(hPrivateData->currWhiteningLevel[i], IGF_WHITENING_MID)) { s_l = getScaleFactor32(hPrivateData->pSpecFlat + hGrid->minSrcSubband - whiteningLevel, add(sub(hGrid->startLine, hGrid->minSrcSubband), whiteningLevel)); @@ -1598,7 +1608,7 @@ void IGFDecSetMode(const IGF_DEC_INSTANCE_HANDLE hInstance, move16(); test(); - IF ((sub(hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_SWB_48000) <= 0) || (sub(hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_FB_48000) <= 0)) + IF ((LE_16(hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_SWB_48000))||(LE_16(hPrivateData->igfInfo.bitRateIndex,IGF_BITRATE_FB_48000))) { IGF_RefineGrid(&hPrivateData->igfInfo.grid[IGF_GRID_LB_NORM]); IGF_RefineGrid(&hPrivateData->igfInfo.grid[IGF_GRID_LB_TRAN]); diff --git a/lib_dec/igf_scf_dec.c b/lib_dec/igf_scf_dec.c index 5f107d1d8379e6fea4fa8c5c66194da7a2b2335a..63ac40bb3dafc9d5d5fd17a50fafcc65965cba4b 100644 --- a/lib_dec/igf_scf_dec.c +++ b/lib_dec/igf_scf_dec.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -8,8 +8,6 @@ #include #include "options.h" #include "stl.h" -#include "wmc_auto.h" - #include "prot_fx.h" #include "stat_dec_fx.h" #include "basop_util.h" @@ -116,7 +114,7 @@ static Word16 arith_decode_residual_fx( /* meaning of the values of val: */ /* esc_{0} IGF_MIN_ENC_SEPARATE ... IGF_MAX_ENC_SEPARATE esc_{IGF_SYMBOLS_IN_TABLE - 1} */ test(); - IF ((val != 0) && (sub(val, IGF_SYMBOLS_IN_TABLE - 1) != 0)) + IF ((val != 0) && (NE_16(val, IGF_SYMBOLS_IN_TABLE - 1))) { x = add(val, - 1 + IGF_MIN_ENC_SEPARATE); /* (val - 1) + IGF_MIN_ENC_SEPARATE */ @@ -129,11 +127,11 @@ static Word16 arith_decode_residual_fx( /* decode one of the tails of the distribution */ /* decode extra with 4 bits */ extra = arith_decode_bits_fx(hPrivateData, st, 4); - IF (sub(extra, 15) == 0) /* escape code 15 to indicate extra >= 15 */ + IF (EQ_16(extra, 15)) /* escape code 15 to indicate extra >= 15 */ { /* decode addtional extra with 6 bits */ extra = arith_decode_bits_fx(hPrivateData, st, 6); - IF (sub(extra, 63) == 0) /* escape code 63 to indicate extra >= 63 */ + IF (EQ_16(extra, 63)) /* escape code 63 to indicate extra >= 63 */ { /* decode safety extra with 7 bits */ extra = arith_decode_bits_fx(hPrivateData, st, 7); @@ -147,7 +145,7 @@ static Word16 arith_decode_residual_fx( /* escape code 0 to indicate x <= IGF_MIN_ENC_SEPARATE - 1 */ x = sub(IGF_MIN_ENC_SEPARATE - 1, extra); } - if (sub(val, IGF_SYMBOLS_IN_TABLE - 1) == 0) + if (EQ_16(val, IGF_SYMBOLS_IN_TABLE - 1)) { /* escape code (IGF_SYMBOLS_IN_TABLE - 1) to indicate x >= IGF_MAX_ENC_SEPARATE + 1 */ x = add(IGF_MAX_ENC_SEPARATE + 1, extra); @@ -209,7 +207,7 @@ static void decode_sfe_vector_fx( x[f] = add(shl(res, 2), pred); move16(); } - ELSE IF (sub(f, 1) == 0) + ELSE IF (EQ_16(f, 1)) { /* (t == 0) && (f == 1) */ res = arith_decode_residual_fx(hPrivateData, @@ -283,7 +281,7 @@ static void decode_sfe_vector_fx( move16(); } - IF (sub(x[f],91) > 0 ) + IF (GT_16(x[f],91)) { x[f] = 91; move16(); diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index 480a5ffe3597562f7669dfaf507026b659c65dc7..c1b43dfb1c37ca78d02b749147b5b70b1b6694fc 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -1,14 +1,12 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "prot_fx.h" #include "cnst_fx.h" /* Common constants */ #include "rom_com_fx.h" /* Static table prototypes */ -#include "stl.h" -#include "wmc_auto.h" - /* required for wmc_tool */ +#include "stl.h" /* required for wmc_tool */ #include "basop_util.h" /*----------------------------------------------------------------------* @@ -596,7 +594,7 @@ void init_decoder_fx( InitSWBdecBuffer_fx( st_fx ); ResetSHBbuffer_Dec_fx(st_fx); - IF( L_sub(st_fx->output_Fs_fx,48000) == 0 ) + IF( EQ_32(st_fx->output_Fs_fx,48000)) { set32_fx( st_fx->fbbwe_hpf_mem_fx[0], 0, 4 ); set32_fx( st_fx->fbbwe_hpf_mem_fx[1], 0, 4 ); diff --git a/lib_dec/inov_dec_fx.c b/lib_dec/inov_dec_fx.c index d470c1779e08835c7bc6038d3375b19bda572586..0abd045950d686e04e1f6f135b983a2d5f329de7 100644 --- a/lib_dec/inov_dec_fx.c +++ b/lib_dec/inov_dec_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -7,8 +7,6 @@ #include "prot_fx.h" /* Function prototypes */ #include "rom_com_fx.h" /* Static table prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*======================================================================*/ /* FUNCTION : inov_decode_fx() */ @@ -59,7 +57,7 @@ void inov_decode_fx( Word16 nBits; Word16 g1, g2; - IF( sub(L_frame,L_FRAME) == 0 ) + IF( EQ_16(L_frame,L_FRAME)) { g1 = FORMANT_SHARPENING_G1; g2 = FORMANT_SHARPENING_G2; @@ -72,7 +70,7 @@ void inov_decode_fx( IF ( !Opt_AMR_WB ) { - IF( sub(L_frame, L_FRAME) == 0) + IF( EQ_16(L_frame, L_FRAME)) { nBits = FCB_bits_tbl[BIT_ALLOC_IDX_fx(core_brate, coder_type, i_subfr, TC_SUBFR2IDX_fx(tc_subfr))]; move16(); @@ -82,11 +80,11 @@ void inov_decode_fx( nBits = FCB_bits_16kHz_tbl[BIT_ALLOC_IDX_16KHZ_fx(core_brate, coder_type, i_subfr, TC_SUBFR2IDX_16KHZ_fx(tc_subfr))]; move16(); } - IF(sub(nBits,7) == 0) + IF(EQ_16(nBits,7)) { dec_acelp_1t64_fx(st_fx, code); } - ELSE IF( sub(nBits,12) == 0) + ELSE IF( EQ_16(nBits,12)) { dec_acelp_2t32_fx( st_fx, code ); } @@ -97,31 +95,31 @@ void inov_decode_fx( } ELSE { - IF ( L_sub(core_brate,ACELP_6k60) == 0) + IF ( EQ_32(core_brate,ACELP_6k60)) { dec_acelp_2t32_fx( st_fx, code ); } - ELSE IF ( L_sub(core_brate,ACELP_8k85) == 0 ) + ELSE IF ( EQ_32(core_brate,ACELP_8k85)) { dec_acelp_4t64_fx( st_fx, 20, code, Opt_AMR_WB ); } - ELSE IF ( L_sub(core_brate,ACELP_12k65) == 0) + ELSE IF ( EQ_32(core_brate,ACELP_12k65)) { dec_acelp_4t64_fx( st_fx, 36, code, Opt_AMR_WB ); } - ELSE IF ( L_sub(core_brate,ACELP_14k25) == 0) + ELSE IF ( EQ_32(core_brate,ACELP_14k25)) { dec_acelp_4t64_fx( st_fx, 44, code, Opt_AMR_WB ); } - ELSE IF ( L_sub(core_brate,ACELP_15k85) == 0) + ELSE IF ( EQ_32(core_brate,ACELP_15k85)) { dec_acelp_4t64_fx( st_fx, 52, code, Opt_AMR_WB ); } - ELSE IF ( L_sub(core_brate,ACELP_18k25) == 0) + ELSE IF ( EQ_32(core_brate,ACELP_18k25)) { dec_acelp_4t64_fx( st_fx, 64, code, Opt_AMR_WB ); } - ELSE IF ( L_sub(core_brate,ACELP_19k85) == 0) + ELSE IF ( EQ_32(core_brate,ACELP_19k85)) { dec_acelp_4t64_fx( st_fx, 72, code, Opt_AMR_WB ); } diff --git a/lib_dec/io_dec_fx.c b/lib_dec/io_dec_fx.c index 1ec597ea1b937d0b6b756a10376dcbe08ee6a47d..0e77e569704e122e2291153b8a6c4a8ae91552bc 100644 --- a/lib_dec/io_dec_fx.c +++ b/lib_dec/io_dec_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -7,8 +7,6 @@ #include #include "options.h" /* Compilation switches */ #include "stl.h" -#include "wmc_auto.h" - #include "cnst_fx.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #include "disclaimer.h" /*for disclaimer*/ @@ -291,7 +289,7 @@ void io_ini_dec_fx( } usage_dec(); } - if( (sub(utmp, SYNC_GOOD_FRAME) != 0) && (sub(utmp, SYNC_BAD_FRAME) != 0) ) + if( (NE_16(utmp, SYNC_GOOD_FRAME))&&(NE_16(utmp,SYNC_BAD_FRAME))) { /* check for a valid first G.192 synch word in Sync Header */ fprintf(stderr, "Error: input bitstream file %s does not have a valid G.192 synch word value \n\n",argv[i]); diff --git a/lib_dec/jbm_jb4_circularbuffer.c b/lib_dec/jbm_jb4_circularbuffer.c index eb2ab5a95af1b8060fc409da225d40c9b2870831..bdee9f033c2a9413a0b0cf6d80b12a963b3cb6ba 100644 --- a/lib_dec/jbm_jb4_circularbuffer.c +++ b/lib_dec/jbm_jb4_circularbuffer.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ /** \file jbm_jb4_circularbuffer.c circular buffer (FIFO) with fixed capacity */ @@ -12,8 +12,6 @@ #include "jbm_jb4_circularbuffer.h" /* instrumentation */ #include "stl.h" -#include "wmc_auto.h" - #include "options.h" #include "basop_util.h" @@ -115,7 +113,7 @@ Word16 JB4_CIRCULARBUFFER_Enque( JB4_CIRCULARBUFFER_HANDLE h, JB4_CIRCULARBUFFER move32(); h->writePos = add( h->writePos, 1 ); - if( sub( h->capacity, h->writePos ) == 0 ) + if( EQ_16( h->capacity, h->writePos )) { h->writePos = 0; move16(); @@ -135,7 +133,7 @@ Word16 JB4_CIRCULARBUFFER_Deque( JB4_CIRCULARBUFFER_HANDLE h, JB4_CIRCULARBUFFER move32(); h->readPos = add( h->readPos, 1 ); - if( sub( h->capacity, h->readPos ) == 0 ) + if( EQ_16( h->capacity, h->readPos )) { h->readPos = 0; move16(); @@ -171,7 +169,7 @@ Word16 JB4_CIRCULARBUFFER_IsEmpty( const JB4_CIRCULARBUFFER_HANDLE h ) ret = 0; move16(); - if( sub( h->readPos, h->writePos ) == 0 ) + if( EQ_16( h->readPos, h->writePos )) ret = 1; move16(); return ret; @@ -184,14 +182,14 @@ Word16 JB4_CIRCULARBUFFER_IsFull( const JB4_CIRCULARBUFFER_HANDLE h ) writePosInc = add( h->writePos, 1 ); /* check if writePos++ should wrap around */ - if( sub( writePosInc, h->capacity ) == 0 ) + if( EQ_16( writePosInc, h->capacity )) writePosInc = 0; move16(); ret = 0; move16(); - if( sub( writePosInc, h->readPos ) == 0 ) + if( EQ_16( writePosInc, h->readPos )) ret = 1; move16(); return ret; @@ -219,8 +217,8 @@ void JB4_CIRCULARBUFFER_Min( const JB4_CIRCULARBUFFER_HANDLE h, JB4_CIRCULARBUFF move32(); return; } - BASOP_SATURATE_WARNING_ON; - IF( sub( h->writePos, h->readPos ) > 0 ) + BASOP_SATURATE_WARNING_OFF + IF( GT_16( h->writePos, h->readPos )) { /* no wraparound */ /* calc statistics for [readPos;writePos[ */ @@ -239,18 +237,18 @@ void JB4_CIRCULARBUFFER_Min( const JB4_CIRCULARBUFFER_HANDLE h, JB4_CIRCULARBUFF * lower region so skip lower region find() (find requires at least two elements in the region) */ IF( h->writePos == 0 ) { - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON return; } /* otherwise find min for [0;writePos[ */ lowerMinElePos = findIndexOfMinWord32( h->data, h->writePos ); - if( L_sub( *pMin, h->data[lowerMinElePos] ) > 0 ) + if( GT_32( *pMin, h->data[lowerMinElePos] )) *pMin = h->data[ lowerMinElePos ]; move32(); } - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON } /* Calculates statistics over all elements: max element */ @@ -264,8 +262,8 @@ void JB4_CIRCULARBUFFER_Max( const JB4_CIRCULARBUFFER_HANDLE h, JB4_CIRCULARBUFF move32(); return; } - BASOP_SATURATE_WARNING_ON; - IF( sub( h->writePos, h->readPos ) > 0 ) + BASOP_SATURATE_WARNING_OFF + IF( GT_16( h->writePos, h->readPos )) { /* no wraparound */ /* find max for [readPos;writePos[ */ @@ -284,18 +282,18 @@ void JB4_CIRCULARBUFFER_Max( const JB4_CIRCULARBUFFER_HANDLE h, JB4_CIRCULARBUFF * lower region so skip lower region find() (find requires at least two elements in the region) */ IF( h->writePos == 0 ) { - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON return; } /* otherwise find max for [0;writePos[ */ lowerMaxElePos = findIndexOfMaxWord32( h->data, h->writePos ); - if( L_sub( h->data[lowerMaxElePos], *pMax ) > 0 ) + if( GT_32( h->data[lowerMaxElePos], *pMax )) *pMax = h->data[ lowerMaxElePos ]; move32(); } - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON } /* Calculates statistics over a considered fraction of all elements: min element and percentile */ @@ -319,14 +317,14 @@ void JB4_CIRCULARBUFFER_MinAndPercentile( const JB4_CIRCULARBUFFER_HANDLE h, Wor maxElementsCapacity = L_add( nElementsToIgnore, 1 ); - BASOP_SATURATE_WARNING_ON; - IF( L_sub( h->readPos, h->writePos ) <= 0 ) + BASOP_SATURATE_WARNING_OFF + IF( LE_32( h->readPos, h->writePos )) { /* no wrap around */ /* calc statistics for [readPos;writePos[ */ FOR( i = h->readPos; i != h->writePos; ++i ) { - if( L_sub( h->data[i], minEle ) < 0 ) + if( LT_32( h->data[i], minEle )) { minEle = L_add(h->data[i], 0); } @@ -339,7 +337,7 @@ void JB4_CIRCULARBUFFER_MinAndPercentile( const JB4_CIRCULARBUFFER_HANDLE h, Wor /* calc statistics for [readPos;capacity[ */ FOR( i = h->readPos; i != h->capacity; ++i ) { - if( L_sub( h->data[i], minEle ) < 0 ) + if( LT_32( h->data[i], minEle )) { minEle = L_add(h->data[i], 0); } @@ -348,14 +346,14 @@ void JB4_CIRCULARBUFFER_MinAndPercentile( const JB4_CIRCULARBUFFER_HANDLE h, Wor /* calc statistics for [0;writePos[ */ FOR( i = 0; i != h->writePos; ++i ) { - if( L_sub( h->data[i], minEle ) < 0 ) + if( LT_32( h->data[i], minEle )) { minEle = L_add(h->data[i], 0); } JB4_CIRCULARBUFFER_calcPercentile( maxElements, &maxElementsSize, maxElementsCapacity, h->data[i] ); } } - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON *pPercentile = maxElements[0]; move32(); *pMin = minEle; @@ -369,11 +367,11 @@ static void JB4_CIRCULARBUFFER_calcPercentile( JB4_CIRCULARBUFFER_ELEMENT *eleme Word32 i,j; /* insert newElement if elements buffer is not yet full */ - IF( L_sub( *size, capacity ) < 0 ) + IF( LT_32( *size, capacity )) { FOR( i = 0; i != *size; ++i ) { - IF( L_sub( newElement, elements[i] ) <= 0 ) + IF( LE_32( newElement, elements[i] )) { /* insert newElement at index i (move all elements above insert pos up a place */ FOR( j = *size; j >= i; --j ) @@ -396,7 +394,7 @@ static void JB4_CIRCULARBUFFER_calcPercentile( JB4_CIRCULARBUFFER_ELEMENT *eleme } /* check if newElement is too small to be inserted in elements buffer */ - IF( L_sub( newElement, elements[0] ) <= 0 ) + IF( LE_32( newElement, elements[0] )) { return; } @@ -404,7 +402,7 @@ static void JB4_CIRCULARBUFFER_calcPercentile( JB4_CIRCULARBUFFER_ELEMENT *eleme /* select position to insert newElement to elements */ FOR( i = *size - 1; i != 0; --i ) { - IF( L_sub( newElement, elements[i] ) > 0 ) + IF( GT_32( newElement, elements[i] )) { /* insert newElement at index i (move all elements below insert pos down a place)*/ FOR( j = 0; j < i; j++ ) diff --git a/lib_dec/jbm_jb4_circularbuffer.h b/lib_dec/jbm_jb4_circularbuffer.h index ae0850d170ebd7194a23315457e37428c2ebe6c2..df2a7f60a7fdc495b112d9d487c4e1fc2a76289a 100644 --- a/lib_dec/jbm_jb4_circularbuffer.h +++ b/lib_dec/jbm_jb4_circularbuffer.h @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ /** \file jbm_jb4_circularbuffer.h circular buffer (FIFO) with fixed capacity */ diff --git a/lib_dec/jbm_jb4_inputbuffer.c b/lib_dec/jbm_jb4_inputbuffer.c index 67c475ea9935e008d9a29002999f1b505416f7d6..f4005f2437275fe8b159e150f9473e496d98a425 100644 --- a/lib_dec/jbm_jb4_inputbuffer.c +++ b/lib_dec/jbm_jb4_inputbuffer.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ /** \file jbm_jb4_inputbuffer.c RTP input buffer with fixed capacity. */ @@ -13,9 +13,7 @@ #include "options.h" #include "jbm_jb4_inputbuffer.h" #include "stl.h" -#include "wmc_auto.h" -#define WMC_TOOL_SKIP /** input buffer with fixed capacity */ struct JB4_INPUTBUFFER @@ -117,7 +115,7 @@ Word16 JB4_INPUTBUFFER_Enque( JB4_INPUTBUFFER_HANDLE h, JB4_INPUTBUFFER_ELEMENT size = JB4_INPUTBUFFER_Size( h ); - IF(sub(size, sub(h->capacity, 1)) >= 0) + IF(GE_16(size, sub(h->capacity, 1))) { return -1; } @@ -129,7 +127,7 @@ Word16 JB4_INPUTBUFFER_Enque( JB4_INPUTBUFFER_HANDLE h, JB4_INPUTBUFFER_ELEMENT move16(); h->writePos = add( h->writePos, 1 ); - if( sub( h->writePos, h->capacity ) == 0 ) + if( EQ_16( h->writePos, h->capacity )) { h->writePos = 0; move16(); @@ -144,7 +142,7 @@ Word16 JB4_INPUTBUFFER_Enque( JB4_INPUTBUFFER_HANDLE h, JB4_INPUTBUFFER_ELEMENT move16(); h->writePos = add( h->writePos, 1 ); - if( sub( h->writePos, h->capacity ) == 0 ) + if( EQ_16( h->writePos, h->capacity )) { h->writePos = 0; move16(); @@ -205,7 +203,7 @@ Word16 JB4_INPUTBUFFER_Enque( JB4_INPUTBUFFER_HANDLE h, JB4_INPUTBUFFER_ELEMENT canMoveLeft = h->readPos; move16(); - IF( sub( h->readPos, h->writePos ) >= 0 ) + IF( GE_16( h->readPos, h->writePos )) { canMoveRight = sub( h->writePos, insertPos ); canMoveLeft = sub( insertPos, h->writePos ); @@ -227,7 +225,7 @@ Word16 JB4_INPUTBUFFER_Enque( JB4_INPUTBUFFER_HANDLE h, JB4_INPUTBUFFER_ELEMENT move16(); h->writePos = add( h->writePos, 1 ); - if( sub( h->writePos, h->capacity ) == 0 ) + if( EQ_16( h->writePos, h->capacity )) { h->writePos = 0; move16(); @@ -261,7 +259,7 @@ Word16 JB4_INPUTBUFFER_Deque( JB4_INPUTBUFFER_HANDLE h, JB4_INPUTBUFFER_ELEMENT *pElement = h->data[h->readPos]; h->readPos = add( h->readPos, 1 ); - if( sub( h->readPos, h->capacity ) == 0 ) + if( EQ_16( h->readPos, h->capacity )) { h->readPos = 0; move16(); @@ -321,7 +319,7 @@ Word16 JB4_INPUTBUFFER_IsEmpty( const JB4_INPUTBUFFER_HANDLE h ) ret = 0; move16(); - if( sub( h->readPos, h->writePos ) == 0 ) + if( EQ_16( h->readPos, h->writePos )) { ret = 1; move16(); @@ -335,7 +333,7 @@ Word16 JB4_INPUTBUFFER_IsFull( const JB4_INPUTBUFFER_HANDLE h ) ret = 0; move16(); - IF( sub( JB4_INPUTBUFFER_Size( h ), sub( h->capacity, 1 )) == 0 ) + IF( EQ_16( JB4_INPUTBUFFER_Size( h ), sub( h->capacity, 1 ))) { ret = 1; move16(); @@ -350,7 +348,7 @@ Word16 JB4_INPUTBUFFER_Size( const JB4_INPUTBUFFER_HANDLE h ) ret = sub( h->writePos, h->readPos ); /* wrap around */ - if( sub( h->readPos, h->writePos ) > 0 ) + if( GT_16( h->readPos, h->writePos )) ret = add( ret, h->capacity ); return ret; } diff --git a/lib_dec/jbm_jb4_inputbuffer.h b/lib_dec/jbm_jb4_inputbuffer.h index 853cec805be3ff20993a54a1bb2ba7fc7a446b2f..3f20faf37594c7e8cdd5342216b3dfe773e61e40 100644 --- a/lib_dec/jbm_jb4_inputbuffer.h +++ b/lib_dec/jbm_jb4_inputbuffer.h @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ /** \file jbm_jb4_inputbuffer.h RTP input buffer with fixed capacity. diff --git a/lib_dec/jbm_jb4_jmf.c b/lib_dec/jbm_jb4_jmf.c index 9fdfc64b10ca0d377fa5b70ba847eb808bae6796..81ef85a225d176571fa1819bbe09c838aa75abe5 100644 --- a/lib_dec/jbm_jb4_jmf.c +++ b/lib_dec/jbm_jb4_jmf.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ /** \file jbm_jb4_jmf.cpp jitter measure fifo - a fifo used for windowed measure of network status */ @@ -11,8 +11,6 @@ /* instrumentation */ #include "options.h" #include "stl.h" -#include "wmc_auto.h" - #include "basop_util.h" /* local includes */ #include "jbm_jb4_jmf.h" @@ -179,7 +177,7 @@ Word16 JB4_JMF_PushPacket( JB4_JMF_HANDLE h, Word32 sysTime, Word32 rtpTimeStamp /* reset delay if absolute value is greater than 60s * to avoid overflow caused by clockdrift */ test(); - if( L_sub( delay, h->maxDelay ) > 0 || L_add( delay, h->maxDelay ) < 0 ) + if( GT_32( delay, h->maxDelay )||L_add(delay,h->maxDelay)<0) { h->lastDelay = L_deposit_l(0); } @@ -193,7 +191,7 @@ Word16 JB4_JMF_Jitter( const JB4_JMF_HANDLE h, Word32 *jitter ) JB4_CIRCULARBUFFER_ELEMENT min, percentile; /* sanity check (must not be empty) and return invalid result if there is only one entry */ - IF( sub( JB4_CIRCULARBUFFER_Size( h->fifo ), 2 ) < 0 ) + IF( LT_16( JB4_CIRCULARBUFFER_Size( h->fifo ), 2 )) { return -1; } @@ -250,7 +248,7 @@ static void JB4_JMF_pushBack( JB4_JMF_HANDLE h, Word32 delay, Word32 offset, Wor duration = L_sub( maxTime, minTime ); test(); - WHILE( duration > 0 && L_sub( duration, h->maxWindowDuration ) > 0 ) + WHILE( duration > 0 && GT_32( duration, h->maxWindowDuration )) { test(); JB4_JMF_popFront( h ); diff --git a/lib_dec/jbm_jb4_jmf.h b/lib_dec/jbm_jb4_jmf.h index 60748a17042e3f1da604ca85057291542ea90082..97bd3bd6b12238f79f43e74ccc1f1c784f1d6390 100644 --- a/lib_dec/jbm_jb4_jmf.h +++ b/lib_dec/jbm_jb4_jmf.h @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ /** \file jbm_jb4_jmf.h jitter measure fifo - a fifo used for windowed measure of network status */ diff --git a/lib_dec/jbm_jb4sb.c b/lib_dec/jbm_jb4sb.c index f4c9c82794daa14b4e870a07b41eb73b463ca628..b06d17252fd2f2b7b355d609ad4e8075a5c963ae 100644 --- a/lib_dec/jbm_jb4sb.c +++ b/lib_dec/jbm_jb4sb.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ /*! \file jbm_jb4sb.c Jitter Buffer Management Interface */ @@ -9,8 +9,6 @@ #include /* instrumentation headers */ #include "stl.h" -#include "wmc_auto.h" - #include "options.h" #include "basop_util.h" #include "basop_util_jbm.h" @@ -369,8 +367,8 @@ Word16 JB4_PushDataUnit( JB4_HANDLE h, JB4_DATAUNIT_HANDLE dataUnit, Word32 rcvT /* ignore frames from too far in future (3 seconds) */ test(); IF( h->firstDataUnitPopped && - L_sub(JB4_rtpTimeStampDiff(h->lastReturnedTs, dataUnit->timeStamp), - L_mult0(50 * 3, extract_l(dataUnit->duration))) >= 0) + GE_32(JB4_rtpTimeStampDiff(h->lastReturnedTs, dataUnit->timeStamp), + L_mult0(50 * 3, extract_l(dataUnit->duration)))) { JB4_FreeDataUnit(h, dataUnit); return 0; @@ -387,14 +385,14 @@ Word16 JB4_PushDataUnit( JB4_HANDLE h, JB4_DATAUNIT_HANDLE dataUnit, Word32 rcvT * avoid unexpected resets because RF_NO_DATA partial copies are dropped before JBM */ IF(dataUnit->silenceIndicator == 0 && dataUnit->partial_frame == 0) { - IF(sub(dataUnit->partialCopyOffset, 0) == 0) + IF(EQ_16(dataUnit->partialCopyOffset, 0)) { h->rfOffset2Active = s_max(sub(h->rfOffset2Active, 1), 0); h->rfOffset3Active = s_max(sub(h->rfOffset3Active, 1), 0); h->rfOffset5Active = s_max(sub(h->rfOffset5Active, 1), 0); h->rfOffset7Active = s_max(sub(h->rfOffset7Active, 1), 0); } - ELSE IF(sub(dataUnit->partialCopyOffset, 2) == 0) + ELSE IF(EQ_16(dataUnit->partialCopyOffset, 2)) { h->rfOffset2Active = 100; move16(); @@ -405,7 +403,7 @@ Word16 JB4_PushDataUnit( JB4_HANDLE h, JB4_DATAUNIT_HANDLE dataUnit, Word32 rcvT h->rfOffset7Active = 0; move16(); } - ELSE IF(sub(dataUnit->partialCopyOffset, 3) == 0) + ELSE IF(EQ_16(dataUnit->partialCopyOffset, 3)) { h->rfOffset2Active = 0; move16(); @@ -416,7 +414,7 @@ Word16 JB4_PushDataUnit( JB4_HANDLE h, JB4_DATAUNIT_HANDLE dataUnit, Word32 rcvT h->rfOffset7Active = 0; move16(); } - ELSE IF(sub(dataUnit->partialCopyOffset, 5) == 0) + ELSE IF(EQ_16(dataUnit->partialCopyOffset, 5)) { h->rfOffset2Active = 0; move16(); @@ -427,7 +425,7 @@ Word16 JB4_PushDataUnit( JB4_HANDLE h, JB4_DATAUNIT_HANDLE dataUnit, Word32 rcvT h->rfOffset7Active = 0; move16(); } - ELSE IF(sub(dataUnit->partialCopyOffset, 7) == 0) + ELSE IF(EQ_16(dataUnit->partialCopyOffset, 7)) { h->rfOffset2Active = 0; move16(); @@ -452,17 +450,17 @@ Word16 JB4_PushDataUnit( JB4_HANDLE h, JB4_DATAUNIT_HANDLE dataUnit, Word32 rcvT /* drop partial copy if the missing frame was already concealed */ IF( h->firstDataUnitPopped ) { - IF( sub(dataUnit->partialCopyOffset, 3) <= 0 && JB4_rtpTimeStampDiff( h->nextExpectedTs, dataUnit->timeStamp ) < 0) + IF( LE_16(dataUnit->partialCopyOffset, 3)&&JB4_rtpTimeStampDiff(h->nextExpectedTs,dataUnit->timeStamp)<0) { JB4_FreeDataUnit(h, dataUnit); return 0; } - ELSE IF( sub(dataUnit->partialCopyOffset, 5) == 0 && L_add(JB4_rtpTimeStampDiff( h->nextExpectedTs, dataUnit->timeStamp ), 40) < 0) + ELSE IF( EQ_16(dataUnit->partialCopyOffset, 5)&<_32(JB4_rtpTimeStampDiff(h->nextExpectedTs,dataUnit->timeStamp),-40)) { JB4_FreeDataUnit(h, dataUnit); return 0; } - ELSE IF( sub(dataUnit->partialCopyOffset, 7) == 0 && L_add(JB4_rtpTimeStampDiff( h->nextExpectedTs, dataUnit->timeStamp ), 80) < 0) + ELSE IF( EQ_16(dataUnit->partialCopyOffset, 7)&<_32(JB4_rtpTimeStampDiff(h->nextExpectedTs,dataUnit->timeStamp),-80)) { JB4_FreeDataUnit(h, dataUnit); return 0; @@ -473,7 +471,7 @@ Word16 JB4_PushDataUnit( JB4_HANDLE h, JB4_DATAUNIT_HANDLE dataUnit, Word32 rcvT IF(JB4_INPUTBUFFER_Enque( h->inputBuffer, dataUnit, (void**)&droppedDataUnit ) == 0) { /* partial copy is useful, consider it in long-term jitter estimation */ - IF( sub(dataUnit->partialCopyOffset, 3) <= 0 ) + IF( LE_16(dataUnit->partialCopyOffset, 3)) { JB4_JMF_PushPacket( h->ltJmf, rcvTime, dataUnit->timeStamp ); } @@ -523,7 +521,7 @@ Word16 JB4_PopDataUnit( JB4_HANDLE h, Word32 sysTime, Word32 extBufferedTime, Word16 ret; assert( sysTime >= h->prevPopSysTime ); - if( L_sub(sysTime, L_add(h->prevPopSysTime, h->frameDuration)) > 0 ) + if( GT_32(sysTime, L_add(h->prevPopSysTime, h->frameDuration))) { h->lastPlayoutOffset = rtpTs_add(h->lastPlayoutOffset, h->frameDuration); } @@ -558,7 +556,7 @@ Word16 JB4_getFECoffset(JB4_HANDLE h) Word16 JB4_FECoffset(JB4_HANDLE h) { - IF ( L_sub( h->netLossRate, 1634) < 0 ) + IF ( LT_32( h->netLossRate, 1634)) { return (Word16)0; } @@ -615,7 +613,7 @@ static void JB4_targetPlayoutDelay( const JB4_HANDLE h, Word32 *targetMin, move16(); *targetStartUp = L_shr(L_add(*targetMin, *targetMax), 1); } - if(L_sub(*targetStartUp, 60) < 0) + if(LT_32(*targetStartUp, 60)) { *targetStartUp = 60; move32(); @@ -731,7 +729,7 @@ static void JB4_adaptActivePlayout( JB4_HANDLE h, Word32 sysTime, } /* decided between shrinking/stretching */ - IF( L_sub(currPlayoutDelay, targetMax) > 0 ) /* time shrinking */ + IF( GT_32(currPlayoutDelay, targetMax)) /* time shrinking */ { gap = extract_l(L_sub(currPlayoutDelay, h->targetPlayoutDelay)); /* check if gap is positive and dropping is allowed @@ -741,7 +739,7 @@ static void JB4_adaptActivePlayout( JB4_HANDLE h, Word32 sysTime, IF( gap > 0 && JB4_inspectBufferForDropping( h, &dropEarly, &buffered ) == 0 && ( convertToLateLoss || - L_sub(L_add(L_add(buffered, h->frameDuration), extBufferedTime), targetMax) > 0 ) ) + GT_32(L_add(L_add(buffered, h->frameDuration), extBufferedTime), targetMax) ) ) { IF( convertToLateLoss ) { @@ -773,8 +771,8 @@ static void JB4_adaptActivePlayout( JB4_HANDLE h, Word32 sysTime, * Also make sure that the delay doesn't increase too much. */ delayWithClearedExternalBuffer = L_add(L_sub(currPlayoutDelay, extBufferedTime), h->frameDuration); targetMaxStretch = L_sub(targetMax, h->frameDuration); - IF( L_sub(L_add(delayWithClearedExternalBuffer, h->frameDuration), targetMaxStretch) <= 0 && - L_sub(currPlayoutDelay, targetMaxStretch) < 0 && L_sub(currPlayoutDelay, L_add(110, L_shr(h->rfDelay, 2))) < 0) + IF( LE_32(L_add(delayWithClearedExternalBuffer, h->frameDuration), targetMaxStretch)&& + LT_32(currPlayoutDelay, targetMaxStretch) && LT_32(currPlayoutDelay, L_add(110, L_shr(h->rfDelay, 2))) ) { *scale = 120; move16(); @@ -830,14 +828,14 @@ static void JB4_adaptDtxPlayout( JB4_HANDLE h, Word32 sysTime, Word16 *stretchTi move32(); headRoom = L_deposit_l(12); /* 600 * 20 (h->frameDuration) / 1000 */ /* decided between shrinking/stretching */ - IF( L_sub(currPlayoutDelay, L_add(targetStartUp, headRoom)) > 0) /* time shrinking */ + IF( GT_32(currPlayoutDelay, L_add(targetStartUp, headRoom))) /* time shrinking */ { IF( JB4_checkDtxDropping( h ) ) { JB4_dropFromBuffer( h, sysTime ); } } - ELSE IF( L_sub(L_add(currPlayoutDelay, headRoom), targetStartUp) < 0 ) /* time stretching */ + ELSE IF( LT_32(L_add(currPlayoutDelay, headRoom), targetStartUp)) /* time stretching */ { *stretchTime = true; move16(); @@ -851,14 +849,14 @@ static void JB4_adaptDtxPlayout( JB4_HANDLE h, Word32 sysTime, Word16 *stretchTi move32(); /* decided between shrinking/stretching */ - IF( L_sub(currPlayoutDelay, L_add(targetDtx, h->frameDuration)) >= 0 ) /* time shrinking */ + IF( GE_32(currPlayoutDelay, L_add(targetDtx, h->frameDuration))) /* time shrinking */ { IF( JB4_checkDtxDropping( h ) ) { JB4_dropFromBuffer( h, sysTime ); } } - ELSE IF( L_sub(L_add(currPlayoutDelay, L_shr(h->frameDuration, 1)), targetDtx) < 0 ) /* time stretching */ + ELSE IF( LT_32(L_add(currPlayoutDelay, L_shr(h->frameDuration, 1)), targetDtx)) /* time stretching */ { *stretchTime = true; move16(); @@ -881,7 +879,7 @@ static void JB4_adaptFirstPlayout( JB4_HANDLE h, Word32 sysTime, Word16 *prebuff } JB4_targetPlayoutDelay( h, &targetMin, &targetMax, &targetDtx, &targetStartUp ); - IF(L_sub(targetStartUp, h->frameDuration) < 0) + IF(LT_32(targetStartUp, h->frameDuration)) { return; } @@ -895,7 +893,7 @@ static void JB4_adaptFirstPlayout( JB4_HANDLE h, Word32 sysTime, Word16 *prebuff return; } - IF( L_sub(L_add(currPlayoutDelay, L_shr(h->frameDuration, 1)), targetStartUp) < 0 ) /* time stretching */ + IF( LT_32(L_add(currPlayoutDelay, L_shr(h->frameDuration, 1)), targetStartUp)) /* time stretching */ { *prebuffer = true; move16(); @@ -936,7 +934,7 @@ static Word16 JB4_inspectBufferForDropping( const JB4_HANDLE h, Word16 *dropEarl IF( tsDiff <= 0 ) { /* preview data unit to play after dropping */ - IF( sub(inputBufferSize, 1) <= 0 ) + IF( LE_16(inputBufferSize, 1)) { /* data unit to play missing, avoid drop followed by concealment */ return -1; @@ -968,7 +966,7 @@ static Word16 JB4_inspectBufferForDropping( const JB4_HANDLE h, Word16 *dropEarl } /* add time stamp difference of last and first actually buffered data unit */ - IF( sub(inputBufferSize, 1) == 0 ) + IF( EQ_16(inputBufferSize, 1)) { bufferedTs = rtpTs_add(bufferedTs, h->frameDuration); } @@ -1138,7 +1136,7 @@ static void JB4_popFromBuffer( JB4_HANDLE h, Word32 sysTime, JB4_DATAUNIT_HANDLE h->totWin += 1; move16(); test(); - IF ( ( L_sub(h->totWin , 3000) > 0) || ( L_sub( h->FecOffWinLen , 100) >0 ) ) + IF ( ( GT_32(h->totWin , 3000))||(GT_32(h->FecOffWinLen,100))) { maxval = h->FecOffWin[1]; move16(); @@ -1146,7 +1144,7 @@ static void JB4_popFromBuffer( JB4_HANDLE h, Word32 sysTime, JB4_DATAUNIT_HANDLE move16(); FOR( i = 2; i < MAXOFFSET ; i++ ) { - IF ( L_sub( h->FecOffWin[i], maxval ) > 0 ) + IF ( GT_32( h->FecOffWin[i], maxval )) { maxval = h->FecOffWin[i] ; move16(); @@ -1197,7 +1195,7 @@ static void JB4_popFromBuffer( JB4_HANDLE h, Word32 sysTime, JB4_DATAUNIT_HANDLE { frameoffset = Mult_32_16(JB4_rtpTimeStampDiff( h->nextExpectedTs, tempDataUnit->timeStamp ), 1639 ) ; /* divide by 20 */ test(); - IF ( frameoffset > 0 && (L_sub( frameoffset, MAXOFFSET) < 0) ) + IF ( frameoffset > 0 && (LT_32( frameoffset, MAXOFFSET))) { h->FecOffWin[frameoffset] = L_add(h->FecOffWin[frameoffset], 1); } @@ -1230,7 +1228,7 @@ static void JB4_popFromBuffer( JB4_HANDLE h, Word32 sysTime, JB4_DATAUNIT_HANDLE *pDataUnit = nextDataUnit; move16(); nextDataUnit->nextCoderType = INACTIVE; - IF( sub(h->pre_partial_frame,1) == 0 || sub(nextDataUnit->partial_frame,1) == 0 ) + IF( EQ_16(h->pre_partial_frame,1)||EQ_16(nextDataUnit->partial_frame,1)) { IF( nextDataUnit->partial_frame ) { @@ -1245,7 +1243,7 @@ static void JB4_popFromBuffer( JB4_HANDLE h, Word32 sysTime, JB4_DATAUNIT_HANDLE FOR(searchpos = 0; searchpos < endpos; searchpos++) { partialCopyDu = (JB4_DATAUNIT_HANDLE)JB4_INPUTBUFFER_Element(h->inputBuffer, searchpos); - IF ( L_sub(partialCopyDu->timeStamp,L_add(nextDataUnit->timeStamp,partialCopyDu->duration)) == 0) + IF ( EQ_32(partialCopyDu->timeStamp,L_add(nextDataUnit->timeStamp,partialCopyDu->duration))) { get_NextCoderType_fx( partialCopyDu->data, &nextDataUnit->nextCoderType); break; @@ -1255,7 +1253,7 @@ static void JB4_popFromBuffer( JB4_HANDLE h, Word32 sysTime, JB4_DATAUNIT_HANDLE JB4_INPUTBUFFER_Deque( h->inputBuffer, (void**)pDataUnit ); - IF ( sub(nextDataUnit->partial_frame,1) == 0 ) + IF ( EQ_16(nextDataUnit->partial_frame,1)) { h->nPartialCopiesUsed = L_add(h->nPartialCopiesUsed, 1); @@ -1269,7 +1267,7 @@ static void JB4_popFromBuffer( JB4_HANDLE h, Word32 sysTime, JB4_DATAUNIT_HANDLE { frameoffset = Mult_32_16(JB4_rtpTimeStampDiff( h->nextExpectedTs, tempDataUnit->timeStamp ), 1639 ) ; test(); - IF ( frameoffset > 0 && (L_sub( frameoffset, MAXOFFSET) < 0) ) + IF ( frameoffset > 0 && (LT_32( frameoffset, MAXOFFSET))) { h->FecOffWin[frameoffset] = L_add(h->FecOffWin[frameoffset], 1); } @@ -1484,8 +1482,8 @@ static Word32 JB4_inputBufferCompareFunction( const JB4_INPUTBUFFER_ELEMENT newE *replaceWithNewElementIfEqual = 1; move16(); } - ELSE IF(sub(newDataUnit->partial_frame, arrayDataUnit->partial_frame) == 0 && - L_sub(newDataUnit->dataSize, arrayDataUnit->dataSize) > 0) + ELSE IF(EQ_16(newDataUnit->partial_frame, arrayDataUnit->partial_frame)&& + GT_32(newDataUnit->dataSize, arrayDataUnit->dataSize)) { /* if both are primary or partial: take the one with higher size (e.g. higher bitrate) */ *replaceWithNewElementIfEqual = 1; diff --git a/lib_dec/jbm_jb4sb.h b/lib_dec/jbm_jb4sb.h index 3f788a811e383d42f8e4272b2ba27f343d374578..b0dd8d3baf4d8d03878ba850156d9f243368ccf3 100644 --- a/lib_dec/jbm_jb4sb.h +++ b/lib_dec/jbm_jb4sb.h @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ /** \file jbm_jb4sb.h Jitter Buffer Management Interface */ diff --git a/lib_dec/jbm_pcmdsp_apa.c b/lib_dec/jbm_pcmdsp_apa.c index eafbd4729c62782c42ba7b9a1cad68f2a1b7105b..b809ab0f9c820e9436231c3a409a170cae325a83 100644 --- a/lib_dec/jbm_pcmdsp_apa.c +++ b/lib_dec/jbm_pcmdsp_apa.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ /*! @file pcmdsp_apa.c Adaptive Playout for Audio (apa). */ @@ -10,8 +10,6 @@ #include /* flc header */ #include "stl.h" -#include "wmc_auto.h" - /* instrumentation */ /* local headers */ #include "jbm_pcmdsp_apa.h" @@ -276,14 +274,14 @@ Word8 apa_set_rate( apa_state_t * ps, Word32 rate, Word16 num_channels ) move16(); ps->win_incrementor = 1; move16(); - IF(L_sub(ps->rate, 48000) == 0) + IF(EQ_32(ps->rate, 48000)) { ps->win = pcmdsp_window_hann_960; move16(); ps->l_halfwin = 480; move16(); } - IF(L_sub(ps->rate, 24000) == 0) + IF(EQ_32(ps->rate, 24000)) { ps->win = pcmdsp_window_hann_960; move16(); @@ -294,10 +292,10 @@ Word8 apa_set_rate( apa_state_t * ps, Word32 rate, Word16 num_channels ) } /* sample rates 8k, 16k & 32k use a Hann window of length of 640, * where 8k and 16k subsample */ - if(L_sub(ps->rate, 16000) == 0) + if(EQ_32(ps->rate, 16000)) ps->win_incrementor = 2; move16(); - if(L_sub(ps->rate, 8000) == 0) + if(EQ_32(ps->rate, 8000)) ps->win_incrementor = 4; move16(); @@ -334,7 +332,7 @@ Word8 apa_set_scale (apa_state_t * ps, Word16 scale) /* do nothing if same scale is set multiple times */ /* (otherwise scale control is confused) */ - IF( sub(ps->scale, scale) == 0 ) + IF( EQ_16(ps->scale, scale)) { return 0; } @@ -380,9 +378,9 @@ Word8 apa_set_quality( Word16 qualityrise) { assert(ps != (apa_state_t *) NULL); - assert(L_sub(L_deposit_h(-2), qualityQ16) <= 0 && L_sub(qualityQ16, L_deposit_h(3)) <= 0); - assert(qualityred > 0 && sub( qualityred, 20 ) <= 0); - assert(qualityrise > 0 && sub(qualityrise, 20) <= 0); + assert(LE_32(L_deposit_h(-2), qualityQ16) && LE_32(qualityQ16, L_deposit_h(3)) ); + assert(qualityred > 0 && LE_16( qualityred, 20 )); + assert(qualityrise > 0 && LE_16(qualityrise, 20)); ps->targetQualityQ16 = qualityQ16; move32(); @@ -524,13 +522,13 @@ Word8 apa_exec (apa_state_t * ps, /* i/o: state struct */ return 2; } /* check size of input */ - IF( L_sub( l_in, ps->l_frm ) != 0 ) + IF( NE_32( l_in, ps->l_frm )) { return 3; } /* get target length */ - IF(s_or(sub(ps->l_frm, 480) == 0, sub(ps->l_frm, 960) == 0)) + IF(s_or((Word16)EQ_16(ps->l_frm, 480),(Word16)EQ_16(ps->l_frm,960))) { /* decomposite ps->l_frm into 15<l_frm)); @@ -559,7 +557,7 @@ Word8 apa_exec (apa_state_t * ps, /* i/o: state struct */ /* Wait until we have l_frm outputs samples */ /* (required to search for correlation in the past). */ /* If we don't have enough samples, simply copy input to output */ - IF( sub( ps->l_buf_out, ps->l_frm ) < 0 ) + IF( LT_16( ps->l_buf_out, ps->l_frm )) { FOR( i = 0; i < ps->l_frm; i++ ) { @@ -590,12 +588,12 @@ Word8 apa_exec (apa_state_t * ps, /* i/o: state struct */ move16(); } /* no scaling */ - IF( sub( ps->scale, 100 ) == 0 ) + IF( EQ_16( ps->scale, 100 )) { copy_frm (ps, frm_in, a_out, &l_frm_out); } /* shrink */ - ELSE IF( sub( ps->scale, 100 ) < 0 ) + ELSE IF( LT_16( ps->scale, 100 )) { shrink_frm (ps, frm_in, maxScaling, a_out, &l_frm_out); } @@ -604,21 +602,21 @@ Word8 apa_exec (apa_state_t * ps, /* i/o: state struct */ extend_frm (ps, frm_in, a_out, &l_frm_out); } /* control the amount/frequency of scaling */ - IF( sub( l_frm_out, ps->l_frm ) != 0 ) + IF( NE_16( l_frm_out, ps->l_frm )) { test(); IF( maxScaling != 0U && - sub( abs_s( sub( ps->l_frm, l_frm_out) ), maxScaling ) > 0 ) + GT_16( abs_s( sub( ps->l_frm, l_frm_out) ), maxScaling )) { /* maxScaling exceeded -> discard scaled frame */ copy_frm (ps, frm_in, a_out, &l_frm_out); } - ELSE IF( L_sub( L_abs( l_frm_out_target ), L_deposit_l(ps->l_frm) ) > 0 ) /* ignore small difference */ + ELSE IF( GT_32( L_abs( l_frm_out_target ), L_deposit_l(ps->l_frm) )) /* ignore small difference */ { dl_copied = L_sub( l_frm_out_target, L_deposit_l(ps->l_frm) ); dl_scaled = L_sub( l_frm_out_target, L_deposit_l(l_frm_out) ); /* discard scaled frame if copied frame is closer to target length */ - IF( L_sub( L_abs( dl_copied ), L_abs( dl_scaled ) ) < 0 ) + IF( LT_32( L_abs( dl_copied ), L_abs( dl_scaled ) )) { copy_frm (ps, frm_in, a_out, &l_frm_out); } @@ -629,7 +627,7 @@ Word8 apa_exec (apa_state_t * ps, /* i/o: state struct */ /* copy output to internal buffer */ /* avoid buffer overflow: */ /* discard old samples; always keep at least most recent l_frm samples */ - IF ( sub( add( ps->l_buf_out, l_frm_out), APA_BUF ) > 0) + IF ( GT_16( add( ps->l_buf_out, l_frm_out), APA_BUF )) { buf_out_ptr1 = ps->buf_out; move16(); @@ -652,7 +650,7 @@ Word8 apa_exec (apa_state_t * ps, /* i/o: state struct */ move16(); } /* append new output samples */ - IF( sub( add( ps->l_buf_out, l_frm_out), APA_BUF ) > 0) + IF( GT_16( add( ps->l_buf_out, l_frm_out), APA_BUF )) { return 5; } @@ -673,9 +671,9 @@ Word8 apa_exec (apa_state_t * ps, /* i/o: state struct */ /* update statistics */ ps->l_in_total = L_add( ps->l_in_total, L_deposit_l( ps->l_frm ) ); test(); - IF( L_sub(L_abs(ps->diffSinceSetScale), - L_sub(0x7FFFFF, L_deposit_l(sub(l_frm_out, ps->l_frm)))) < 0 && - sub(ps->nFramesSinceSetScale, statsResetThreshold) < 0 ) + IF( LT_32(L_abs(ps->diffSinceSetScale), + L_sub(0x7FFFFF, L_deposit_l(sub(l_frm_out, ps->l_frm)))) && + LT_16(ps->nFramesSinceSetScale, statsResetThreshold) ) { ps->diffSinceSetScale = L_add(ps->diffSinceSetScale, L_deposit_l(sub(l_frm_out, ps->l_frm))); ps->nFramesSinceSetScale = add(ps->nFramesSinceSetScale, 1); @@ -730,7 +728,7 @@ static void get_scaling_quality(const apa_state_t * ps, IF(pitch_cn > 0) { /* calculate correlation for double pitch */ - IF(sub(add(add(shl(pitch, 1), offset), corr_len), s_len) <= 0) + IF(LE_16(add(add(shl(pitch, 1), offset), corr_len), s_len)) { double_pitch_cn = normalized_cross_correlation_self(signal, add(shl(pitch, 1), offset), offset, corr_len, shl(ps->num_channels, 1), &double_pitch_energy); @@ -742,7 +740,7 @@ static void get_scaling_quality(const apa_state_t * ps, double_pitch_energy = L_add(pitch_energy, 0); } /* calculate correlation for three/half pitch */ - IF(sub(add(add(shr(i_mult2(pitch, 3), 1), offset), corr_len), s_len) <= 0) + IF(LE_16(add(add(shr(i_mult2(pitch, 3), 1), offset), corr_len), s_len)) { three_halves_pitch_cn = normalized_cross_correlation_self(signal, add(shr(i_mult2(pitch, 3), 1), offset), offset, corr_len, shl(ps->num_channels, 1), &three_halves_pitch_energy); @@ -754,7 +752,7 @@ static void get_scaling_quality(const apa_state_t * ps, three_halves_pitch_energy = L_add(pitch_energy, 0); } /* calculate correlation for half pitch */ - IF(sub(add(add(shr(pitch, 1), offset), corr_len), s_len) <= 0) + IF(LE_16(add(add(shr(pitch, 1), offset), corr_len), s_len)) { half_pitch_cn = normalized_cross_correlation_self(signal, add(shr(pitch, 1), offset), offset, corr_len, shl(ps->num_channels, 1), &half_pitch_energy); @@ -769,9 +767,9 @@ static void get_scaling_quality(const apa_state_t * ps, /* combine correlation results: Q15.16 */ *qualityQ16 = L_shr(L_mac0(L_mult0(half_pitch_cn, three_halves_pitch_cn), pitch_cn, double_pitch_cn), 14); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF energy = L_add(L_add(L_add(pitch_energy, half_pitch_energy), three_halves_pitch_energy), double_pitch_energy); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON } ELSE { @@ -780,7 +778,7 @@ static void get_scaling_quality(const apa_state_t * ps, } /* update the quality by the quality of the signal with the highest energy */ - IF(L_sub(energy, maxEnergy) > 0) + IF(GT_32(energy, maxEnergy)) { qualityOfMaxEnergy = L_add(*qualityQ16, 0); maxEnergy = L_add(energy, 0); @@ -829,16 +827,16 @@ Word16 apa_getQualityIncreaseForLowEnergy(Word16 energydBQ8) move16(); /* increase calculated quality of signals with low energy */ - IF(sub(energydBQ8, qualIncreaseMaxEnergy) < 0) + IF(LT_16(energydBQ8, qualIncreaseMaxEnergy)) { qualIncForLowEnergy = energydBQ8; move16(); - if(sub(qualIncForLowEnergy, qualIncreaseMinEnergy) < 0) + if(LT_16(qualIncForLowEnergy, qualIncreaseMinEnergy)) { qualIncForLowEnergy = qualIncreaseMinEnergy; move16(); } - if(sub(qualIncForLowEnergy, qualIncreaseMaxEnergy) > 0) + if(GT_16(qualIncForLowEnergy, qualIncreaseMaxEnergy)) { qualIncForLowEnergy = qualIncreaseMaxEnergy; move16(); @@ -899,7 +897,7 @@ static Word8 logarithmic_search(const apa_state_t * ps, FOR(i = s_start; i < s_start+inlen; i += css) { test(); - IF( sub(wss,1) == 0 && sub(ps->num_channels, 1) == 0 ) + IF( EQ_16(wss,1)&&EQ_16(ps->num_channels,1)) { coeff = cross_correlation_self(signal, add(i, offset), add(fixed_pos, offset), corr_len); } @@ -910,29 +908,29 @@ static Word8 logarithmic_search(const apa_state_t * ps, } /* update max corr */ - IF( sub(ps->scale, 100) < 0 ) + IF( LT_16(ps->scale, 100)) { /* shrinking: prefer greater synchpos for equal coeff */ - BASOP_SATURATE_WARNING_ON; - IF(L_sub(coeff, coeff_max) >= 0) + BASOP_SATURATE_WARNING_OFF + IF(GE_32(coeff, coeff_max)) { coeff_max = L_add(coeff, 0); *synchpos = i; move16(); } - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON } ELSE { /* extending: prefer smaller synchpos for equal coeff */ - BASOP_SATURATE_WARNING_ON; - IF(L_sub(coeff, coeff_max) > 0) + BASOP_SATURATE_WARNING_OFF + IF(GT_32(coeff, coeff_max)) { coeff_max = L_add(coeff, 0); *synchpos = i; move16(); } - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON } } /* backup old search range */ @@ -947,17 +945,17 @@ static Word8 logarithmic_search(const apa_state_t * ps, move16(); s_start = sub( *synchpos, shr( inlen, 1 ) ); - if( sub(s_start,s_start_old) < 0 ) + if( LT_16(s_start,s_start_old)) { s_start = s_start_old; move16(); } - IF( sub( add(s_start,inlen), add(s_start_old,s_len_old) ) > 0 ) + IF( GT_16( add(s_start,inlen), add(s_start_old,s_len_old) )) { inlen = add( sub( s_start_old, s_start), s_len_old ); } - } WHILE( sub( css, 2 ) > 0 ); + } WHILE( GT_16( css, 2 )); return 0; } @@ -1112,7 +1110,7 @@ static Word16 shrink_frm (apa_state_t * ps, } s_end = add( s_start, ps->l_search ); - if( sub( add( s_end, l_seg ), l_frm ) >= 0 ) + if( GE_16( add( s_end, l_seg ), l_frm )) { s_end = sub( l_frm, l_seg ); } @@ -1128,7 +1126,7 @@ static Word16 shrink_frm (apa_state_t * ps, /* set to last valid element (i.e. element[len - 1] but note for stereo last element is last pair of samples) */ xtract = sub( s_end, ps->num_channels ); test(); - if( maxScaling != 0U && sub( s_end, add( maxScaling, 1 ) ) > 0 ) + if( maxScaling != 0U && GT_16( s_end, add( maxScaling, 1 ) )) { xtract = maxScaling; move16(); @@ -1151,15 +1149,15 @@ static Word16 shrink_frm (apa_state_t * ps, /* test whether frame has sufficient quality */ /* 6554=0.1 in Q15.16; 13107=0.2 in Q15.16 */ - IF(L_sub(qualityQ16, L_add(L_sub(ps->targetQualityQ16, + IF(LT_32(qualityQ16, L_add(L_sub(ps->targetQualityQ16, L_mult0(ps->bad_frame_count, 6554)), - L_mult0(ps->good_frame_count, 13107))) < 0) + L_mult0(ps->good_frame_count, 13107)))) { /* not sufficient */ over = 0; move16(); - if( sub( ps->bad_frame_count, ps->qualityred ) < 0 ) + if( LT_16( ps->bad_frame_count, ps->qualityred )) { ps->bad_frame_count = add( ps->bad_frame_count, 1 ); } @@ -1175,7 +1173,7 @@ static Word16 shrink_frm (apa_state_t * ps, { ps->bad_frame_count = sub( ps->bad_frame_count, 1 ); } - if( sub( ps->good_frame_count, ps->qualityrise ) < 0 ) + if( LT_16( ps->good_frame_count, ps->qualityrise )) { ps->good_frame_count = add( ps->good_frame_count, 1 ); } @@ -1184,7 +1182,7 @@ static Word16 shrink_frm (apa_state_t * ps, /* Calculate output data */ test(); IF( over != 0 && xtract != 0 ) { - IF( sub( findSynchResult, 1) == 0 ) + IF( EQ_16( findSynchResult, 1)) { return 1; } @@ -1274,7 +1272,7 @@ static Word16 extend_frm (apa_state_t * ps, assert( (l_frm_out_target / l_seg) - 1 == N ); - if( sub(N, 1) < 0 ) + if( LT_16(N, 1)) { N = 1; move16(); @@ -1293,7 +1291,7 @@ static Word16 extend_frm (apa_state_t * ps, s_min = negate( l_frm ); } s_max = sub( sub( l_frm, shl( l_seg, 1 ) ), ps->l_search ); - if( sub( s_max, s_min ) < 0 ) + if( LT_16( s_max, s_min )) { N = 1; move16(); @@ -1303,7 +1301,7 @@ static Word16 extend_frm (apa_state_t * ps, move16(); /* else, spread linear in between s_min and s_max */ /* (including s_min and s_max) */ - IF( sub( N, 1 ) != 0 ) + IF( NE_16( N, 1 )) { FOR( n = 2; n <= (N + 1); n++ ) { @@ -1336,17 +1334,17 @@ static Word16 extend_frm (apa_state_t * ps, move16(); s_end = add( s_start, ps->l_search ); - IF( sub( sn_plus_search, sync_start_sub_pmin ) >= 0 ) + IF( GE_16( sn_plus_search, sync_start_sub_pmin )) { /* shrink search region to enforce minimum shift */ s_end = sync_start_sub_pmin; move16(); - IF( sub( sn_plus_search, sync_start ) < 0 ) + IF( LT_16( sn_plus_search, sync_start )) { s_start = s[n]; /* just do it with normal start position */ move16(); } - ELSE IF( sub( n, add(N,1) ) == 0 ) /* move search region left for last segment */ + ELSE IF( EQ_16( n, add(N,1) )) /* move search region left for last segment */ { s_start = sub( s_end, sub( ps->l_search, ps->p_min ) ); } @@ -1387,9 +1385,9 @@ static Word16 extend_frm (apa_state_t * ps, /* test for sufficient quality */ /* 6554=0.1 in Q15.16; 13107=0.2 in Q15.16 */ - IF(L_sub(qualityQ16, L_add(L_sub(ps->targetQualityQ16, + IF(LT_32(qualityQ16, L_add(L_sub(ps->targetQualityQ16, L_mult0(ps->bad_frame_count, 6554)), - L_mult0(ps->good_frame_count, 13107))) < 0) + L_mult0(ps->good_frame_count, 13107)))) { /* not sufficient */ over[n] = 0; @@ -1397,7 +1395,7 @@ static Word16 extend_frm (apa_state_t * ps, xtract[n] = sync_start; move16(); - if( sub( ps->bad_frame_count, ps->qualityred ) < 0 ) + if( LT_16( ps->bad_frame_count, ps->qualityred )) { ps->bad_frame_count = add( ps->bad_frame_count, 1 ); } @@ -1413,7 +1411,7 @@ static Word16 extend_frm (apa_state_t * ps, { ps->bad_frame_count = sub( ps->bad_frame_count, 1 ); } - if(sub(ps->good_frame_count, ps->qualityrise) < 0) + if(LT_16(ps->good_frame_count, ps->qualityrise)) { ps->good_frame_count = add( ps->good_frame_count, 1 ); } @@ -1436,7 +1434,7 @@ static Word16 extend_frm (apa_state_t * ps, FOR( n = 2; n <= N; n++ ) { test(); - IF( over[n] != 0 && sub( add( xtract[sub(n,1)], l_seg ), xtract[n] ) != 0 ) + IF( over[n] != 0 && NE_16( add( xtract[sub(n,1)], l_seg ), xtract[n] )) { /* mix 2nd half of previous segment with 1st half of current segment */ fadeOut = frm_in + l_frm + xtract[n - 1] + l_seg; diff --git a/lib_dec/jbm_pcmdsp_apa.h b/lib_dec/jbm_pcmdsp_apa.h index faab4b480dda7d0c6c2188bc1f5b7a4ad298c18a..c65dcbcf3d55ad12170be1efa92b7a501176b248 100644 --- a/lib_dec/jbm_pcmdsp_apa.h +++ b/lib_dec/jbm_pcmdsp_apa.h @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ /*! @file pcmdsp_apa.h Adaptive Playout for Audio (apa). */ diff --git a/lib_dec/jbm_pcmdsp_fifo.c b/lib_dec/jbm_pcmdsp_fifo.c index 53ad782b5327aa4c0b2dbe2cc9942879ffa0b80a..bc87ffd87cc6cfcca3e0e8f6ead46f3c933ef5db 100644 --- a/lib_dec/jbm_pcmdsp_fifo.c +++ b/lib_dec/jbm_pcmdsp_fifo.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ /*! @file pcmdsp_fifo.c Ringbuffer (FIFO) with fixed capacity for audio samples */ @@ -9,8 +9,6 @@ /* instrumentation headers */ #include "options.h" #include "stl.h" -#include "wmc_auto.h" - #include "basop_util.h" /* local headers */ #include "jbm_pcmdsp_fifo.h" @@ -118,7 +116,7 @@ Word16 pcmdsp_fifo_write( PCMDSP_FIFO_HANDLE h, const UWord8 *samples, Word16 nS return 0; } /* check, if enough space left */ - IF( sub( nSamplesPerChannel, sub( h->capacity, h->size ) ) > 0 ) + IF( GT_16( nSamplesPerChannel, sub( h->capacity, h->size ) )) { return -1; } @@ -168,7 +166,7 @@ Word16 pcmdsp_fifo_read( PCMDSP_FIFO_HANDLE h, Word16 nSamplesPerChannel, UWord8 return 0; } /* check, if enough bytes readable */ - IF( L_sub( nSamplesPerChannel, h->size ) > 0 ) + IF( GT_32( nSamplesPerChannel, h->size )) { return -1; } diff --git a/lib_dec/jbm_pcmdsp_fifo.h b/lib_dec/jbm_pcmdsp_fifo.h index db60556883175ff5ac80537c485dcacb8a0a36d9..734407ff78251888c2a9b3a1b594a6bbffd61fd6 100644 --- a/lib_dec/jbm_pcmdsp_fifo.h +++ b/lib_dec/jbm_pcmdsp_fifo.h @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ /*! @file pcmdsp_fifo.h Ringbuffer (FIFO) with fixed capacity for audio samples. */ diff --git a/lib_dec/jbm_pcmdsp_similarityestimation.c b/lib_dec/jbm_pcmdsp_similarityestimation.c index 73049554e766cca037d9d6f6fe2aeff0bc6b3cc8..71b1abbbe11eafb545c4791900973fd6251cd7f9 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ /*! @file pcmdsp_similarityestimation.c Algorithms for correlation and similarity estimation. */ @@ -9,8 +9,6 @@ #include /* flc header */ #include "stl.h" -#include "wmc_auto.h" - #include "basop_util.h" /* local headers */ #include "jbm_pcmdsp_similarityestimation.h" @@ -21,12 +19,12 @@ Word16 getSignalScaleForCorrelation(Word32 sampleRate) { Word16 ret; - IF( L_sub(sampleRate, 16000) < 0 ) + IF( LT_32(sampleRate, 16000)) { ret = 2; move16(); } - ELSE IF( L_sub(sampleRate, 32000) >= 0 ) + ELSE IF( GE_32(sampleRate, 32000)) { ret = 4; move16(); @@ -133,9 +131,9 @@ Word16 normalized_cross_correlation_self(const Word16 * signal, cc = BASOP_Util_Divide3216_Scale(sumXY, sqrtXY, &normCC); normCC = add(normCC, 16); /* scale to Q15 with saturation */ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF cc = shl_r(cc, add(normXY, normCC)); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON *energy = L_shr_r(L_deposit_l(sqrtXY), normXY); } ELSE /* conceal silent frames */ @@ -178,12 +176,12 @@ Word8 isSilence(const Word16 * signal, Word16 len, Word16 segments) { /* division by 32768 is done later */ energy = L_add(energy, L_abs(L_deposit_l(signal[i]))); - IF( sub(i, j) == 0 ) + IF( EQ_16(i, j)) { /* check energy of current segment */ /* 20 * log10(energy / 32768 / samplesPerSegment) > -65 * => energy > samplesPerSegment * 10 ^ (-65 / 20) * 32768 */ - IF( L_sub(energy, maxEnergy) > 0 ) + IF( GT_32(energy, maxEnergy)) { ret = 0; move16(); @@ -194,7 +192,7 @@ Word8 isSilence(const Word16 * signal, Word16 len, Word16 segments) } } /* check last segment */ - if( L_sub(energy, maxEnergy) > 0 ) + if( GT_32(energy, maxEnergy)) { ret = 0; move16(); diff --git a/lib_dec/jbm_pcmdsp_similarityestimation.h b/lib_dec/jbm_pcmdsp_similarityestimation.h index 32b6d2c0a45958a90a58fba4300baebd67afe0ba..750ff554cbc8642c93c9d1b3a872ffbe77a538d1 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation.h +++ b/lib_dec/jbm_pcmdsp_similarityestimation.h @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ /*! @file pcmdsp_similarityestimation.h Algorithms for correlation and similarity estimation. */ diff --git a/lib_dec/jbm_pcmdsp_window.c b/lib_dec/jbm_pcmdsp_window.c index 360cfd3b2383d84bcd3fed0248b379282c13b760..d7fc848017882cca06f8ed2cae6648fcd170ed6f 100644 --- a/lib_dec/jbm_pcmdsp_window.c +++ b/lib_dec/jbm_pcmdsp_window.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ /*! @file pcmdsp_window.c Window functions. */ @@ -9,8 +9,6 @@ #include "jbm_pcmdsp_window.h" #include "options.h" #include "stl.h" -#include "wmc_auto.h" - /* Overlap/Add of two signal with a given window. */ diff --git a/lib_dec/jbm_pcmdsp_window.h b/lib_dec/jbm_pcmdsp_window.h index aa4cc96be05ad13e29316c6cdbbc5028b5f682bb..e00247a05e1f58ceafa5d8a099cb7f2bdbdec1e1 100644 --- a/lib_dec/jbm_pcmdsp_window.h +++ b/lib_dec/jbm_pcmdsp_window.h @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ /*! @file pcmdsp_window.h Window functions. */ diff --git a/lib_dec/lead_deindexing_fx.c b/lib_dec/lead_deindexing_fx.c index 4f482123ab2f842b43207ccfdb576c9ff7c41ad8..e16f04a8c490103d88b69741ef411248caec39a0 100644 --- a/lib_dec/lead_deindexing_fx.c +++ b/lib_dec/lead_deindexing_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -9,8 +9,6 @@ #include "rom_dec_fx.h" #include "prot_fx.h" #include "stl.h" -#include "wmc_auto.h" - /*-------------------------------------------------------------------* * Local function prototype @@ -40,7 +38,7 @@ void re8_decode_base_index_fx( Word16 element_a10, element_a11 = 0, element_a12 = 0; - IF (sub( n, 2 ) < 0) + IF (LT_16( n, 2 )) { FOR (i=0; i<8; i++) { @@ -50,7 +48,7 @@ void re8_decode_base_index_fx( } ELSE { - if ( L_sub( I, 65519 ) > 0 ) + if ( GT_32( I, 65519 )) { I = 0; move16(); @@ -60,11 +58,11 @@ void re8_decode_base_index_fx( * search for the identifier ka of the absolute leader (table-lookup) * Q2 is a subset of Q3 - the two cases are considered in the same branch *-------------------------------------------------------------------*/ - IF (sub(n,3) <= 0 ) + IF (LE_16(n,3)) { FOR (i = 1; i < NB_LDQ3; i++) { - IF (L_sub(I, I3_fx[i]) < 0) + IF (LT_32(I, I3_fx[i])) { BREAK; } @@ -76,7 +74,7 @@ void re8_decode_base_index_fx( { FOR (i = 1; i < NB_LDQ4; i++) { - IF (L_sub(I, I4_fx[i]) < 0) + IF (LT_32(I, I4_fx[i])) { BREAK; } @@ -223,7 +221,7 @@ void re8_decode_base_index_fx( /*--------------------------------------------------------------------* * recover the sign of last element if needed *--------------------------------------------------------------------*/ - IF (sub( k1, 7 ) == 0) + IF (EQ_16( k1, 7 )) { m1 = 0; move16(); @@ -276,7 +274,7 @@ static void fcb_decode_pos_fx( move16(); k = sub(*select_table24,k); - WHILE (sub( k, *select_table24 ) <= 0 ) + WHILE (LE_16( k, *select_table24 )) { l = add(l,1); select_table24--; diff --git a/lib_dec/lp_exc_d_fx.c b/lib_dec/lp_exc_d_fx.c index a3bce056c367d2bb36bc0fe6c826e1282f11b0bd..c812b8c1c8ad4701963c4d11495cd41fec9f9abf 100644 --- a/lib_dec/lp_exc_d_fx.c +++ b/lib_dec/lp_exc_d_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "cnst_fx.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*======================================================================*/ /* FUNCTION : lp_filt_exc_dec_fx() */ @@ -55,17 +53,17 @@ void lp_filt_exc_dec_fx( /*-----------------------------------------------------------------* * Select LP filtering of the adaptive excitation *-----------------------------------------------------------------*/ - IF( sub(codec_type, MODE1) == 0) + IF( EQ_16(codec_type, MODE1)) { test(); test(); test(); - IF ( ( Opt_AMR_WB || sub(coder_type,GENERIC) == 0|| sub(coder_type,TRANSITION) == 0) && L_sub(core_brate,ACELP_11k60) < 0) + IF ( ( Opt_AMR_WB || EQ_16(coder_type,GENERIC)||EQ_16(coder_type,TRANSITION))&<_32(core_brate,ACELP_11k60)) { lp_flag = LOW_PASS; move16(); } - ELSE IF ( L_sub(core_brate,ACELP_11k60) >= 0) + ELSE IF ( GE_32(core_brate,ACELP_11k60)) { lp_flag = (Word16)get_next_indice_fx( st_fx, 1 ); move16(); @@ -77,7 +75,7 @@ void lp_filt_exc_dec_fx( } } - IF ( sub(lp_flag, LOW_PASS) == 0) + IF ( EQ_16(lp_flag, LOW_PASS)) { /* pointer positionning to avoid doing it inside the loop */ test(); diff --git a/lib_dec/lsf_dec_fx.c b/lib_dec/lsf_dec_fx.c index 3501be3ff5af9edf2ec4a05b9cc5547fbf81c439..0021596c946cd4976441688fe510acaa6b20652b 100644 --- a/lib_dec/lsf_dec_fx.c +++ b/lib_dec/lsf_dec_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -8,8 +8,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*-------------------------------------------------------------------* * Local functions @@ -59,7 +57,7 @@ static void dqlsf_CNG_fx( test(); test(); test(); - IF ( ((sub(st_fx->L_frame_fx, L_FRAME16k)==0)&&(sub(lsf_q[M-1],WB_LIMIT_LSF_FX)<=0)) || ((sub(st_fx->L_frame_fx, L_FRAME16k)<0)&&(sub(lsf_q[M-1],WB_LIMIT_LSF_FX)>0))) + IF ( ((EQ_16(st_fx->L_frame_fx, L_FRAME16k))&&(LE_16(lsf_q[M-1],WB_LIMIT_LSF_FX)))||((LT_16(st_fx->L_frame_fx,L_FRAME16k))&&(GT_16(lsf_q[M-1],WB_LIMIT_LSF_FX)))) { st_fx->BER_detect = 1; move16(); @@ -118,14 +116,14 @@ void lsf_dec_fx( /* initialize */ int_fs = INT_FS_16k_FX; move16(); - if( sub(L_frame,L_FRAME) == 0 ) + if( EQ_16(L_frame,L_FRAME)) { int_fs = INT_FS_FX; move16(); } /* Find the number of bits for LSF quantization */ - IF ( L_sub(st_fx->core_brate_fx,SID_2k40) == 0 ) + IF ( EQ_32(st_fx->core_brate_fx,SID_2k40)) { nBits = LSF_BITS_CNG; move16(); @@ -138,20 +136,20 @@ void lsf_dec_fx( nBits = LSF_bits_tbl[LSF_BIT_ALLOC_IDX_fx(st_fx->core_brate_fx, coder_type)]; move16(); } - ELSE IF ( sub(st_fx->nelp_mode_dec_fx,1) == 0 ) + ELSE IF ( EQ_16(st_fx->nelp_mode_dec_fx,1)) { - IF ( sub(coder_type,UNVOICED) == 0 ) + IF ( EQ_16(coder_type,UNVOICED)) { nBits = 30; move16(); - if ( sub(bwidth,NB) == 0 ) + if ( EQ_16(bwidth,NB)) { nBits = 32; move16(); } } } - ELSE IF ( sub(st_fx->ppp_mode_dec_fx,1) == 0 ) + ELSE IF ( EQ_16(st_fx->ppp_mode_dec_fx,1)) { nBits = 26; move16(); @@ -166,7 +164,7 @@ void lsf_dec_fx( /* convert quantized LSFs to LSPs */ lsf2lsp_fx(lsf_new, lsp_new, M ,int_fs); - IF ( L_sub(st_fx->core_brate_fx,SID_2k40) == 0 ) + IF ( EQ_32(st_fx->core_brate_fx,SID_2k40)) { /* return if SID frame (conversion to A(z) done in the calling function) */ return; @@ -186,11 +184,11 @@ void lsf_dec_fx( test(); test(); - IF ( ( st_fx->prev_bfi_fx && (sub(coder_type,TRANSITION) == 0) && (sub(tc_subfr,sub(L_frame,L_SUBFR)) == 0) ) ) + IF ( ( st_fx->prev_bfi_fx && (EQ_16(coder_type,TRANSITION))&&(EQ_16(tc_subfr,sub(L_frame,L_SUBFR))))) { lsf_diff = 1205; move16(); /*int_fs / (float)(2*(M+1)); = 470.588 -> 1205 in Q2.56 */ - if( sub(L_frame,L_FRAME) == 0 ) + if( EQ_16(L_frame,L_FRAME)) { lsf_diff = 964; move16(); /*int_fs / (float)(2*(M+1)); = 376.47 -> 964 in Q2.56 */ @@ -222,7 +220,7 @@ void lsf_dec_fx( } test(); test(); - IF ( !( st_fx->prev_bfi_fx && (sub(coder_type,TRANSITION) == 0) && (sub(tc_subfr,sub(L_frame,L_SUBFR)) == 0) ) ) + IF ( !( st_fx->prev_bfi_fx && (EQ_16(coder_type,TRANSITION))&&(EQ_16(tc_subfr,sub(L_frame,L_SUBFR))))) { IF ( st_fx->prev_bfi_fx) { @@ -235,7 +233,7 @@ void lsf_dec_fx( } IF ( st_fx->prev_bfi_fx ) { - IF( sub(enr_new, mult_r(9830/*0.3 Q15*/,enr_old)) < 0 ) + IF( LT_16(enr_new, mult_r(9830/*0.3 Q15*/,enr_old))) { /* OLD CODE : if( st->safety_net == 1), replaced with a decision similar to MODE2 */ st_fx->relax_prev_lsf_interp_fx = -1; @@ -244,7 +242,7 @@ void lsf_dec_fx( test(); test(); test(); - if ( sub(st_fx->clas_dec, UNVOICED_CLAS) == 0 || sub(st_fx->clas_dec, SIN_ONSET) == 0 || sub(st_fx->clas_dec, INACTIVE_CLAS) == 0 || sub(coder_type, GENERIC) == 0 || sub(coder_type, TRANSITION) == 0 ) + if ( EQ_16(st_fx->clas_dec, UNVOICED_CLAS)||EQ_16(st_fx->clas_dec,SIN_ONSET)||EQ_16(st_fx->clas_dec,INACTIVE_CLAS)||EQ_16(coder_type,GENERIC)||EQ_16(coder_type,TRANSITION)) { st_fx->relax_prev_lsf_interp_fx = 1; move16(); @@ -253,7 +251,7 @@ void lsf_dec_fx( } } test(); - IF( sub(st_fx->last_core_fx, HQ_CORE)==0 && sub(st_fx->core_fx,ACELP_CORE)==0 ) + IF( EQ_16(st_fx->last_core_fx, HQ_CORE)&&EQ_16(st_fx->core_fx,ACELP_CORE)) { /* update old LSPs/LSFs in case of HQ->ACELP core switching */ Copy( lsp_mid, st_fx->lsp_old_fx, M ); @@ -357,11 +355,11 @@ void lsf_end_dec_fx( test(); test(); - IF((sub(coder_type_org, GENERIC) == 0) && (L_sub(int_fs, INT_FS_16k) == 0) && (mode2_flag == 0)) + IF((EQ_16(coder_type_org, GENERIC))&&(EQ_32(int_fs,INT_FS_16k))&&(mode2_flag==0)) { coder_type = (Word16)get_next_indice_fx( st, 1 ); coder_type = add(coder_type,2); - if (sub(coder_type, GENERIC) == 0) + if (EQ_16(coder_type, GENERIC)) { nBits = sub(nBits,1); } @@ -414,7 +412,7 @@ void lsf_end_dec_fx( } ELSE { - IF (sub(mode2_flag, 1) == 0) + IF (EQ_16(mode2_flag, 1)) { nr_ind = add(nr_ind,1); /* read from param_lpc */ @@ -454,11 +452,11 @@ void lsf_end_dec_fx( move16(); } - IF (sub(mode2_flag, 1) == 0) + IF (EQ_16(mode2_flag, 1)) { /* VOICED_WB@16kHz */ test(); - IF ( L_sub(int_fs, INT_FS_16k) == 0 && sub(coder_type, VOICED) == 0 ) + IF ( EQ_32(int_fs, INT_FS_16k)&&EQ_16(coder_type,VOICED)) { *nb_indices = 10; move16(); @@ -483,7 +481,7 @@ void lsf_end_dec_fx( move16(); WHILE ( cumleft > 0 ) { - IF ( sub(cumleft, LEN_INDICE) >0 ) + IF ( GT_16(cumleft, LEN_INDICE)) { cumleft = sub(cumleft, LEN_INDICE); num_bits = LEN_INDICE; @@ -510,7 +508,7 @@ void lsf_end_dec_fx( { /* VOICED_WB@16kHz */ test(); - IF ( L_sub(int_fs, INT_FS_16k)== 0 && sub(coder_type, VOICED) == 0 ) + IF ( EQ_32(int_fs, INT_FS_16k)&&EQ_16(coder_type,VOICED)) { Bit_alloc1 = &BC_TCVQ_BIT_ALLOC_40B[1]; TCQIdx[0] = safety_net; @@ -532,7 +530,7 @@ void lsf_end_dec_fx( cumleft = levels[sub(stages,1)]; WHILE ( cumleft > 0 ) { - IF ( sub(cumleft, LEN_INDICE) > 0 ) + IF ( GT_16(cumleft, LEN_INDICE)) { cumleft = sub(cumleft, LEN_INDICE); num_bits = LEN_INDICE; @@ -552,7 +550,7 @@ void lsf_end_dec_fx( } } - IF(sub(st->reset_mem_AR,1) == 0) + IF(EQ_16(st->reset_mem_AR,1)) { FOR( i=0; iBER_detect = s_or(st->BER_detect, ber_flag); - IF (sub(predmode, 1) == 0) /* MA only */ + IF (EQ_16(predmode, 1)) /* MA only */ { Copy(qlsf, mem_MA, M); Vr_add( qlsf, pred1, qlsf, M ); @@ -725,13 +723,13 @@ void lsf_mid_dec_fx( lsp2lsf_fx( qlsp1, qlsf1, M, int_fs); /* Codebook selection */ - IF ( sub(ppp_mode,1) == 0 ) + IF ( EQ_16(ppp_mode,1)) { nb_bits = 1; move16(); ratio = &tbl_mid_voi_wb_1b_fx[0]; } - ELSE IF ( sub(nelp_mode,1) == 0 ) + ELSE IF ( EQ_16(nelp_mode,1)) { nb_bits = 4; move16(); @@ -744,7 +742,7 @@ void lsf_mid_dec_fx( /* codebook selection */ - IF ( sub(coder_type,VOICED) == 0 ) + IF ( EQ_16(coder_type,VOICED)) { SWITCH ( nb_bits ) { @@ -795,11 +793,11 @@ void lsf_mid_dec_fx( } /* check for incorrect LSF ordering */ - IF ( sub(*mid_lsf_int, 1) == 0 ) + IF ( EQ_16(*mid_lsf_int, 1)) { FOR (j=1; j 0 && sub(j, M) <0 && sub(qlsf[j], add( qlsf[j-1], LSF_GAP_MID_FX))<0 ) + IF ( j > 0 && LT_16(j, M)&<_16(qlsf[j],add(qlsf[j-1],LSF_GAP_MID_FX))) { qlsf[j] = add(qlsf[j-1], LSF_GAP_MID_FX); move16(); @@ -835,7 +833,7 @@ void lsf_mid_dec_fx( { test(); test(); - IF ( j > 0 && sub(j, M) < 0 && sub(qlsf[j], add( qlsf[j-1],LSF_GAP_MID_FX))<0 ) + IF ( j > 0 && LT_16(j, M)&<_16(qlsf[j],add(qlsf[j-1],LSF_GAP_MID_FX))) { qlsf[j] = add(qlsf[j-1], LSF_GAP_MID_FX); move16(); diff --git a/lib_dec/lsf_msvq_ma_dec.c b/lib_dec/lsf_msvq_ma_dec.c index 76c7fffab948d6a3708ab383367e9772ecf92b8c..8fccf8dfa562574c4c9fb5d051f30f5303a4243d 100644 --- a/lib_dec/lsf_msvq_ma_dec.c +++ b/lib_dec/lsf_msvq_ma_dec.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include #include #include #include "stl.h" -#include "wmc_auto.h" - #include "options.h" #include "cnst_fx.h" #include "prot_fx.h" @@ -32,7 +30,7 @@ Word16 lsf_msvq_ma_decprm( Decoder_State_fx * st, Word16 *param_lpc, Word16 core move16(); test(); - IF ((L_sub(sr_core, INT_FS_16k) == 0)&&(sub(acelp_mode, UNVOICED) == 0)) + IF ((EQ_32(sr_core, INT_FS_16k))&&(EQ_16(acelp_mode,UNVOICED))) { predmode = find_pred_mode(GENERIC, sub(1, narrowBand) /*st->bwidth*/, sr_core, &mode_lvq, &mode_lvq_p, st->total_brate_fx); @@ -40,7 +38,7 @@ Word16 lsf_msvq_ma_decprm( Decoder_State_fx * st, Word16 *param_lpc, Word16 core } ELSE { - IF (sub(core, TCX_20_CORE) == 0) + IF (EQ_16(core, TCX_20_CORE)) { predmode = find_pred_mode(AUDIO, sub(1,narrowBand)/*st->bwidth*/, sr_core, &mode_lvq, &mode_lvq_p, st->total_brate_fx ); @@ -60,12 +58,12 @@ Word16 lsf_msvq_ma_decprm( Decoder_State_fx * st, Word16 *param_lpc, Word16 core nbits_lpc = 0; move16(); - IF (sub(predmode, 2) == 0) + IF (EQ_16(predmode, 2)) { /* there is choice between SN and AR prediction */ safety_net = get_next_indice_fx(st, 1); - IF (sub(safety_net,1) == 0) + IF (EQ_16(safety_net,1)) { stages = stages0; move16(); @@ -114,7 +112,7 @@ Word16 lsf_msvq_ma_decprm( Decoder_State_fx * st, Word16 *param_lpc, Word16 core test(); test(); - IF ( sub(acelp_mode, VOICED) != 0 && core==0 && acelp_midLpc) + IF ( NE_16(acelp_mode, VOICED)&&core==0&&acelp_midLpc) { *param_lpc = get_next_indice_fx(st, bits_midlpc); diff --git a/lib_dec/nelp_dec_fx.c b/lib_dec/nelp_dec_fx.c index befc502bf5f7f4fc2ac43fd77d158ddc2e86c762..adc39dadae6fee0ace6f3df7cc512a45d8ab7c78 100644 --- a/lib_dec/nelp_dec_fx.c +++ b/lib_dec/nelp_dec_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -8,8 +8,6 @@ #include "rom_com_fx.h" #include "stl.h" -#include "wmc_auto.h" - /*===================================================================*/ /* FUNCTION : normalize_arr() */ @@ -107,7 +105,7 @@ void nelp_decoder_fx( Decoder_State_fx *st_fx, Word16 *exc_nelp, Word16 *exc, Wo Word16 max_val = 0, norm_val = 0; Word16 qGain=0; - if (sub(st_fx->last_nelp_mode_dec_fx,1) == 0 && sub(st_fx->bwidth_fx, st_fx->last_bwidth_fx) != 0) + if (EQ_16(st_fx->last_nelp_mode_dec_fx,1)&&NE_16(st_fx->bwidth_fx,st_fx->last_bwidth_fx)) { st_fx->last_nelp_mode_dec_fx = 0; } @@ -115,9 +113,9 @@ void nelp_decoder_fx( Decoder_State_fx *st_fx, Word16 *exc_nelp, Word16 *exc, Wo test(); test(); test(); - IF ( sub(coder_type,UNVOICED) == 0 && sub(st_fx->bwidth_fx,NB) == 0 ) + IF ( EQ_16(coder_type,UNVOICED)&&EQ_16(st_fx->bwidth_fx,NB)) { - IF (sub(st_fx->last_nelp_mode_dec_fx,1) != 0) + IF (NE_16(st_fx->last_nelp_mode_dec_fx,1)) { BP1_ORDER = 7; move16(); @@ -125,17 +123,17 @@ void nelp_decoder_fx( Decoder_State_fx *st_fx, Word16 *exc_nelp, Word16 *exc, Wo set32_fx(st_fx->bp1_filt_mem_nb_dec_fx, 0, BP1_ORDER*2); } } - ELSE IF ( sub(coder_type,UNVOICED) == 0 && (sub(st_fx->bwidth_fx,WB) == 0|| sub(st_fx->bwidth_fx, SWB) == 0)) + ELSE IF ( EQ_16(coder_type,UNVOICED)&&(EQ_16(st_fx->bwidth_fx,WB)||EQ_16(st_fx->bwidth_fx,SWB))) { BP1_ORDER =4; move16(); - IF (sub(st_fx->last_nelp_mode_dec_fx,1) != 0) + IF (NE_16(st_fx->last_nelp_mode_dec_fx,1)) { set16_fx(st_fx->bp1_filt_mem_wb_dec_fx, 0 , BP1_ORDER*2); } } - IF (sub(st_fx->last_nelp_mode_dec_fx,1) != 0) + IF (NE_16(st_fx->last_nelp_mode_dec_fx,1)) { set16_fx(st_fx->shape1_filt_mem_dec_fx, 0, 10); set16_fx(st_fx->shape2_filt_mem_dec_fx, 0, 10); @@ -145,7 +143,7 @@ void nelp_decoder_fx( Decoder_State_fx *st_fx, Word16 *exc_nelp, Word16 *exc, Wo IF (bfi == 0) { test(); - IF(sub(st_fx->rf_frame_type,RF_NELP) == 0 && sub(st_fx->use_partial_copy,1)==0) + IF(EQ_16(st_fx->rf_frame_type,RF_NELP)&&EQ_16(st_fx->use_partial_copy,1)) { iG1 = st_fx->rf_indx_nelp_iG1; iG2[0] = st_fx->rf_indx_nelp_iG2[0]; @@ -164,10 +162,10 @@ void nelp_decoder_fx( Decoder_State_fx *st_fx, Word16 *exc_nelp, Word16 *exc, Wo test(); test(); - IF ( sub(coder_type,UNVOICED) == 0 && (sub(st_fx->bwidth_fx,WB) == 0|| sub(st_fx->bwidth_fx, SWB) == 0)) + IF ( EQ_16(coder_type,UNVOICED)&&(EQ_16(st_fx->bwidth_fx,WB)||EQ_16(st_fx->bwidth_fx,SWB))) { test(); - IF(sub(st_fx->rf_frame_type,RF_NELP) == 0 && sub(st_fx->use_partial_copy,1)==0) + IF(EQ_16(st_fx->rf_frame_type,RF_NELP)&&EQ_16(st_fx->use_partial_copy,1)) { fid = st_fx->rf_indx_nelp_fid; } @@ -240,13 +238,13 @@ void nelp_decoder_fx( Decoder_State_fx *st_fx, Word16 *exc_nelp, Word16 *exc, Wo move16();/* 1.37f - Q14 */ test(); test(); - if ( sub(coder_type,UNVOICED) == 0 && (sub(st_fx->bwidth_fx,WB) == 0|| sub(st_fx->bwidth_fx, SWB) == 0)) + if ( EQ_16(coder_type,UNVOICED)&&(EQ_16(st_fx->bwidth_fx,WB)||EQ_16(st_fx->bwidth_fx,SWB))) { gain_fac = 19005; move16(); /* 1.16f - Q14 */ } - IF (sub(st_fx->bwidth_fx,WB) == 0|| sub(st_fx->bwidth_fx, SWB) == 0) + IF (EQ_16(st_fx->bwidth_fx,WB)||EQ_16(st_fx->bwidth_fx,SWB)) { /* Normalize Gains[10] with headroom 4, qGain is the new Q value os Gains, not Q0*/ /* This is done to avoid internal overflow observed in the wb bp filter below, similar to encoder */ @@ -258,7 +256,7 @@ void nelp_decoder_fx( Decoder_State_fx *st_fx, Word16 *exc_nelp, Word16 *exc, Wo test(); test(); - IF ( sub(coder_type,UNVOICED ) == 0&& (sub(st_fx->bwidth_fx,WB) == 0|| sub(st_fx->bwidth_fx, SWB) == 0) ) + IF ( EQ_16(coder_type,UNVOICED )&&(EQ_16(st_fx->bwidth_fx,WB)||EQ_16(st_fx->bwidth_fx,SWB))) { BP1_ORDER =4; move16(); @@ -272,7 +270,7 @@ void nelp_decoder_fx( Decoder_State_fx *st_fx, Word16 *exc_nelp, Word16 *exc, Wo } test(); - IF ( sub(coder_type,UNVOICED ) == 0&& (sub(st_fx->bwidth_fx,NB) == 0) ) + IF ( EQ_16(coder_type,UNVOICED )&&(EQ_16(st_fx->bwidth_fx,NB))) { BP1_ORDER = 7; move16(); @@ -323,7 +321,7 @@ void nelp_decoder_fx( Decoder_State_fx *st_fx, Word16 *exc_nelp, Word16 *exc, Wo test(); test(); - IF ( sub(coder_type,UNVOICED ) == 0&& (sub(st_fx->bwidth_fx,WB) == 0|| sub(st_fx->bwidth_fx, SWB) == 0) ) + IF ( EQ_16(coder_type,UNVOICED )&&(EQ_16(st_fx->bwidth_fx,WB)||EQ_16(st_fx->bwidth_fx,SWB))) { pz_filter_sp_fx(shape1_num_coef_fx, shape1_den_coef_fx, ptr, ptr_tmp, st_fx->shape1_filt_mem_dec_fx, 10, 10, L_FRAME, (sub(16,SHAPE1_COEF_QF))); diff --git a/lib_dec/peak_vq_dec_fx.c b/lib_dec/peak_vq_dec_fx.c index a622a98b2ec3b8985b7f63b78391636cacb288b5..76ab156b024a88e56c898e17d66e5f792daf41b8 100644 --- a/lib_dec/peak_vq_dec_fx.c +++ b/lib_dec/peak_vq_dec_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "prot_fx.h" #include "rom_com_fx.h" -#include "stl.h" -#include "wmc_auto.h" - /* required for wmc_tool */ +#include "stl.h" /* required for wmc_tool */ #define PK_VQ_NOISE_DELTA ((Word16)3277) /* 0.1 in Q15 */ @@ -112,7 +110,7 @@ void peak_vq_dec_fx( set16_fx( pvq_inp_vector, 0, HVQ_PVQ_BUF_LEN ); /* Set bitrate dependent variables */ - IF (sub(brate, HQ_24k40) == 0) + IF (EQ_16(brate, HQ_24k40)) { max_peaks = HVQ_MAX_PEAKS_24k; move16(); @@ -140,7 +138,7 @@ void peak_vq_dec_fx( move16(); /* safety check in case of bit errors */ - IF( sub(*Npeaks, HVQ_MIN_PEAKS) < 0 ) + IF( LT_16(*Npeaks, HVQ_MIN_PEAKS)) { st_fx->BER_detect = 1; move16(); @@ -174,7 +172,7 @@ void peak_vq_dec_fx( } /* safety check in case of bit errors */ - IF( sub(j, vq_peaks) < 0 ) + IF( LT_16(j, vq_peaks)) { st_fx->BER_detect = 1; move16(); @@ -189,7 +187,7 @@ void peak_vq_dec_fx( pgain_difidx[0] = get_next_indice_fx( st_fx, GAIN0_BITS ); /* safety check in case of bit errors */ - IF( sub(pgain_difidx[0], 44) > 0 ) + IF( GT_16(pgain_difidx[0], 44)) { st_fx->BER_detect = 1; move16(); @@ -232,7 +230,7 @@ void peak_vq_dec_fx( /* safety check in case of bit errors */ test(); - IF( sub(pgain_difidx[i], 44) > 0 || pgain_difidx[i] < 0) + IF( GT_16(pgain_difidx[i], 44)||pgain_difidx[i]<0) { st_fx->BER_detect = 1; move16(); @@ -334,7 +332,7 @@ void peak_vq_dec_fx( j = 0; move16(); - IF (sub(k, sub(pvq_bands, n_sel_bnds)) >= 0) + IF (GE_16(k, sub(pvq_bands, n_sel_bnds))) { i = band_start_harm[*pSelBnds++]; move16(); @@ -342,9 +340,9 @@ void peak_vq_dec_fx( pCoefsOut = coefs_out + i; } normq = L_add(dicn_fx[pvq_norm[k]], 0); - WHILE (sub(j, hvq_band_width[k]) < 0) + WHILE (LT_16(j, hvq_band_width[k])) { - IF (L_sub(*pCoefsOut, 0) == 0) + IF (EQ_32(*pCoefsOut, 0)) { Mpy_32_16_ss(normq, *pPvqVector++, &acc, &dontCare); /* acc(Q11), normq(Q14), pvq_vector(Q12) */ *pCoefsOut = L_shl(acc, 12 - 11); /* Q12 */ move32(); @@ -423,14 +421,14 @@ static void dequant_peaks_fx( ELSE { absPeakGain1 = L_abs(peak_gain[-1]); - IF(L_sub(absPeakGain1, absPeakGain) <= 0) + IF(LE_32(absPeakGain1, absPeakGain)) { Mpy_32_16_ss(*peak_gain, xq[0], &vect_out[0], &dontCare); /* vect_out in Q12 */ Mpy_32_16_ss(*peak_gain, xq[1], &vect_out[1], &dontCare); /* Q12 */ } ELSE { - IF(vect_out[1] == 0 || (L_sub(absPeakGain1, absPeakGain) <= 0)) + IF(vect_out[1] == 0 || (LE_32(absPeakGain1, absPeakGain))) { Mpy_32_16_ss(*peak_gain, xq[1], &vect_out[1], &dontCare); } @@ -495,7 +493,7 @@ static Word16 hvq_dec_pos_fx( peak_idx[i] = add(add(delta[i], peak_idx[i-1]), HVQ_CP_HUFF_OFFSET); move16(); /* safety check in case of bit errors */ - IF (sub(peak_idx[i], HVQ_THRES_BIN_32k) >= 0) + IF (GE_16(peak_idx[i], HVQ_THRES_BIN_32k)) { peak_idx[i] = HVQ_THRES_BIN_32k - 1; move16(); @@ -537,7 +535,7 @@ static Word16 hvq_dec_pos_fx( test(); FOR (i = 0; i < length && j < num_peaks; i++) { - if (sub(pos_vec[i], 1) == 0) + if (EQ_16(pos_vec[i], 1)) { pos_vec[i] = i_mult2(pos_vec[i], sign_vec[j++]); move16(); @@ -582,7 +580,7 @@ static Word16 sparse_dec_pos_fx( FOR (j = 0; j < layer_length; j++) { - IF (sub(layer2[j], 1) == 0) + IF (EQ_16(layer2[j], 1)) { idx = get_next_indice_fx(st_fx, HVQ_CP_MAP_IDX_LEN); bits = add(bits, HVQ_CP_MAP_IDX_LEN); @@ -590,7 +588,7 @@ static Word16 sparse_dec_pos_fx( val = hvq_cp_layer1_map5[idx]; move16(); test(); /* safety check in case of bit errors */ - IF ( j == 0 && sub(val, 4) > 0 ) /* out[0] and out[1] are invalid positions */ + IF ( j == 0 && GT_16(val, 4)) /* out[0] and out[1] are invalid positions */ { st_fx->BER_detect = 1; move16(); diff --git a/lib_dec/pit_dec.c b/lib_dec/pit_dec.c index c6ce746ad30f2e3f7ded9c2e80d277ee78565c05..3812c993b29846d427192ff8cdc798350e513956 100644 --- a/lib_dec/pit_dec.c +++ b/lib_dec/pit_dec.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -8,8 +8,6 @@ #include "cnst_fx.h" #include "prot_fx.h" #include "stl.h" -#include "wmc_auto.h" - #include "options.h" #include "rom_basop_util.h" @@ -52,7 +50,7 @@ Word32 Mode2_pit_decode( /* o: floating pitch value *T0_res = 1; move16(); } - ELSE IF(sub(coder_type,1) == 0) /* 8/4/4/4 (EVS) */ + ELSE IF(EQ_16(coder_type,1)) /* 8/4/4/4 (EVS) */ { IF (i_subfr == 0) { @@ -66,10 +64,10 @@ Word32 Mode2_pit_decode( /* o: floating pitch value Mode2_delta_pit_dec( T0, T0_frac, *T0_res, T0_min, T0_min_frac, pt_indice); } } - ELSE IF(sub(coder_type,2) == 0) /* 8/5/8/5 (EVS) */ + ELSE IF(EQ_16(coder_type,2)) /* 8/5/8/5 (EVS) */ { test(); - IF ( ( i_subfr == 0 ) || ( sub(i_subfr,shl(L_subfr,1)) == 0) ) + IF ( ( i_subfr == 0 ) || ( EQ_16(i_subfr,shl(L_subfr,1)))) { Mode2_abs_pit_dec( T0, T0_frac, T0_res, pt_indice, pit_min, pit_fr1b, pit_min, pit_res_max); } @@ -81,10 +79,10 @@ Word32 Mode2_pit_decode( /* o: floating pitch value Mode2_delta_pit_dec( T0, T0_frac, *T0_res, T0_min, T0_min_frac, pt_indice); } } - ELSE IF(sub(coder_type,3) == 0) /* 9/6/6/6 (HRs- VC) */ + ELSE IF(EQ_16(coder_type,3)) /* 9/6/6/6 (HRs- VC) */ { Word16 pit_res_max2 = pit_res_max; - if ( sub(pit_min,PIT_MIN_16k)==0 ) + if ( EQ_16(pit_min,PIT_MIN_16k)) { pit_res_max2 = shr(pit_res_max,1); } @@ -101,15 +99,15 @@ Word32 Mode2_pit_decode( /* o: floating pitch value Mode2_delta_pit_dec( T0, T0_frac, *T0_res, T0_min, T0_min_frac, pt_indice); } } - ELSE IF(sub(coder_type,4) == 0) /* 9/6/9/6 (AMRWB) */ + ELSE IF(EQ_16(coder_type,4)) /* 9/6/9/6 (AMRWB) */ { Word16 pit_res_max2 = pit_res_max; - if ( sub(pit_min,PIT_MIN_16k)==0 ) + if ( EQ_16(pit_min,PIT_MIN_16k)) { pit_res_max2 = shr(pit_res_max,1); } test(); - IF ( ( i_subfr == 0 ) || ( sub(i_subfr,shl(L_subfr,1)) == 0 ) ) + IF ( ( i_subfr == 0 ) || ( EQ_16(i_subfr,shl(L_subfr,1)))) { Mode2_abs_pit_dec( T0, T0_frac, T0_res, pt_indice, pit_min, pit_fr1, pit_fr2, pit_res_max); } @@ -121,7 +119,7 @@ Word32 Mode2_pit_decode( /* o: floating pitch value Mode2_delta_pit_dec( T0, T0_frac, *T0_res, T0_min, T0_min_frac, pt_indice); } } - ELSE IF(sub(coder_type,8) == 0) /* 8/5/5/5 (RF all pred mode) */ + ELSE IF(EQ_16(coder_type,8)) /* 8/5/5/5 (RF all pred mode) */ { IF (i_subfr == 0) { @@ -134,7 +132,7 @@ Word32 Mode2_pit_decode( /* o: floating pitch value Mode2_delta_pit_dec( T0, T0_frac, *T0_res, T0_min, T0_min_frac, pt_indice); } } - ELSE IF(sub(coder_type,9) == 0) /* 8/0/8/0 (RF gen pred mode) */ + ELSE IF(EQ_16(coder_type,9)) /* 8/0/8/0 (RF gen pred mode) */ { IF (i_subfr == 0) { @@ -193,19 +191,19 @@ void Mode2_abs_pit_dec( tmp1 = i_mult(sub(pit_fr2,pit_min),pit_res_max); tmp2 = i_mult(sub(pit_fr1,pit_fr2),pit_res_max_half); - IF (sub(index,tmp1) < 0) + IF (LT_16(index,tmp1)) { assert(pit_res_max > 1 && pit_res_max<=6); res = pit_res_max; move16(); - if(sub(pit_res_max,6) == 0) + if(EQ_16(pit_res_max,6)) { res =shr(res,1); } *T0 = mult(index,inv_T0_res[res]); - if(sub(pit_res_max,6) == 0) + if(EQ_16(pit_res_max,6)) { *T0 =shr(*T0,1); } @@ -264,7 +262,7 @@ void Mode2_delta_pit_dec( res = T0_res; move16(); - if(sub(T0_res,6) == 0) + if(EQ_16(T0_res,6)) { res =shr(res,1); } @@ -275,7 +273,7 @@ void Mode2_delta_pit_dec( *T0 = mult(add(index,*T0_min_frac),inv_T0_res[res]); - if(sub(T0_res,6) == 0) + if(EQ_16(T0_res,6)) { *T0 =shr(*T0,1); } @@ -343,7 +341,7 @@ Word16 pit_decode_fx( /* o : floating pitch value pit_flag = i_subfr; move16(); - if (sub(i_subfr,PIT_DECODE_2XL_SUBFR) == 0) + if (EQ_16(i_subfr,PIT_DECODE_2XL_SUBFR)) { pit_flag = 0; move16(); @@ -364,21 +362,21 @@ Word16 pit_decode_fx( /* o : floating pitch value *limit_flag = 1; move16(); - if( sub(coder_type,VOICED) == 0) + if( EQ_16(coder_type,VOICED)) { *limit_flag = 2; move16(); /* double-extended limits */ } test(); - if( sub(coder_type,GENERIC ) == 0 && L_sub(core_brate,ACELP_7k20) == 0) + if( EQ_16(coder_type,GENERIC )&&EQ_32(core_brate,ACELP_7k20)) { *limit_flag = 0; move16(); } } - ELSE IF( sub(i_subfr,2*L_SUBFR) == 0 && L_sub(coder_type,GENERIC) == 0 && L_sub(core_brate,ACELP_13k20) <= 0 ) + ELSE IF( EQ_16(i_subfr,2*L_SUBFR)&&EQ_32(coder_type,GENERIC)&&LE_32(core_brate,ACELP_13k20)) { - if( sub(*T0,shr(add(PIT_FR1_EXTEND_8b, PIT_MIN),1) ) > 0) + if( GT_16(*T0,shr(add(PIT_FR1_EXTEND_8b, PIT_MIN),1) )) { *limit_flag = 0; move16(); @@ -391,10 +389,10 @@ Word16 pit_decode_fx( /* o : floating pitch value nBits = 0; move16(); - IF( sub(coder_type, AUDIO) != 0) + IF( NE_16(coder_type, AUDIO)) { /* find the number of bits */ - IF( sub(L_frame,L_FRAME) == 0) + IF( EQ_16(L_frame,L_FRAME)) { nBits = ACB_bits_tbl[BIT_ALLOC_IDX_fx(core_brate, coder_type, i_subfr, 0)]; move16(); @@ -413,10 +411,10 @@ Word16 pit_decode_fx( /* o : floating pitch value * Pitch decoding in AUDIO mode * (both ACELP@12k8 and ACELP@16k cores) *-------------------------------------------------------*/ - IF( sub(coder_type, AUDIO) == 0) + IF( EQ_16(coder_type, AUDIO)) { test(); - if( sub(L_subfr,L_FRAME/2) == 0 && i_subfr != 0 ) + if( EQ_16(L_subfr,L_FRAME/2)&&i_subfr!=0) { pit_flag = L_SUBFR; move16(); @@ -437,7 +435,7 @@ Word16 pit_decode_fx( /* o : floating pitch value test(); test(); - IF( sub(L_subfr,L_FRAME/2) == 0 && i_subfr != 0 && sub(pitch_index,32) >= 0 ) /* safety check in case of bit errors */ + IF( EQ_16(L_subfr,L_FRAME/2)&&i_subfr!=0&&GE_16(pitch_index,32)) /* safety check in case of bit errors */ { pitch_index = shr(pitch_index,1); move16(); @@ -447,13 +445,13 @@ Word16 pit_decode_fx( /* o : floating pitch value pit_Q_dec_fx( 0, pitch_index, nBits, 4, pit_flag, *limit_flag, T0, T0_frac, T0_min, T0_max, &st_fx->BER_detect ); } - ELSE IF( sub(coder_type,VOICED) == 0) + ELSE IF( EQ_16(coder_type,VOICED)) { /*-------------------------------------------------------* * Pitch decoding in VOICED mode * (ACELP@12k8 core only) *-------------------------------------------------------*/ - if( sub(i_subfr,2*L_SUBFR) == 0) + if( EQ_16(i_subfr,2*L_SUBFR)) { pit_flag = i_subfr; move16(); @@ -467,7 +465,7 @@ Word16 pit_decode_fx( /* o : floating pitch value * Pitch decoding in GENERIC mode * (both ACELP@12k8 and ACELP@16k cores) *-------------------------------------------------------*/ - IF( sub(L_frame,L_FRAME) == 0) + IF( EQ_16(L_frame,L_FRAME)) { pit_Q_dec_fx( 0, pitch_index, nBits, 8, pit_flag, *limit_flag, T0, T0_frac, T0_min, T0_max, &st_fx->BER_detect ); } @@ -488,7 +486,7 @@ Word16 pit_decode_fx( /* o : floating pitch value move16(); test(); test(); - IF( i_subfr == 0 || ( sub(i_subfr, 2*L_SUBFR) == 0 && L_sub(core_brate,ACELP_8k85) == 0 ) ) + IF( i_subfr == 0 || ( EQ_16(i_subfr, 2*L_SUBFR)&&EQ_32(core_brate,ACELP_8k85))) { nBits = 8; move16(); @@ -498,12 +496,12 @@ Word16 pit_decode_fx( /* o : floating pitch value nBits = 5; move16(); } - IF( L_sub(core_brate, ACELP_8k85) > 0) + IF( GT_32(core_brate, ACELP_8k85)) { nBits = 6; move16(); test(); - if( i_subfr == 0 || sub(i_subfr, 2*L_SUBFR) == 0) + if( i_subfr == 0 || EQ_16(i_subfr, 2*L_SUBFR)) { nBits = 9; move16(); @@ -545,14 +543,14 @@ void pit_Q_dec_fx( ,Word16 *BER_detect /* o : BER detect flag */ ) { - IF( sub(nBits, 10) == 0) /* absolute decoding with 10 bits */ + IF( EQ_16(nBits, 10)) /* absolute decoding with 10 bits */ { IF( limit_flag == 0 ) { *T0 = add(PIT_MIN,shr(pitch_index,2)); *T0_frac = sub(pitch_index,shl(sub(*T0,PIT_MIN),2)); } - ELSE IF( sub(limit_flag,1) == 0 ) + ELSE IF( EQ_16(limit_flag,1)) { *T0 = add(PIT_MIN_EXTEND,shr(pitch_index,2)); *T0_frac = sub(pitch_index ,shl(sub(*T0,PIT_MIN_EXTEND),2)); @@ -563,7 +561,7 @@ void pit_Q_dec_fx( *T0_frac = sub(pitch_index ,shl(sub(*T0,PIT_MIN_DOUBLEEXTEND),2)); } } - ELSE IF( sub(nBits, 9) == 0) /* absolute decoding with 9 bits */ + ELSE IF( EQ_16(nBits, 9)) /* absolute decoding with 9 bits */ { abs_pit_dec_fx( 4, pitch_index, limit_flag, T0, T0_frac ); @@ -573,7 +571,7 @@ void pit_Q_dec_fx( limit_T0_fx( L_FRAME, delta, pit_flag, 0, *T0, 0, T0_min, T0_max ); /* T0_frac==0 to keep IO with AMR-WB */ } } - ELSE IF( sub(nBits, 8) == 0 ) /* absolute decoding with 8 bits */ + ELSE IF( EQ_16(nBits, 8)) /* absolute decoding with 8 bits */ { abs_pit_dec_fx( 2, pitch_index, limit_flag, T0, T0_frac ); @@ -583,13 +581,13 @@ void pit_Q_dec_fx( limit_T0_fx( L_FRAME, delta, pit_flag, 0, *T0, 0, T0_min, T0_max ); /* T0_frac==0 to keep IO with AMR-WB */ } } - ELSE IF( sub(nBits, 6) == 0) /* relative decoding with 6 bits */ + ELSE IF( EQ_16(nBits, 6)) /* relative decoding with 6 bits */ { delta_pit_dec_fx( 4, pitch_index, T0, T0_frac, *T0_min ); } - ELSE IF( sub(nBits, 5) == 0 ) /* relative decoding with 5 bits */ + ELSE IF( EQ_16(nBits, 5)) /* relative decoding with 5 bits */ { - IF( sub(delta,8) == 0 ) + IF( EQ_16(delta,8)) { delta_pit_dec_fx( 2, pitch_index, T0, T0_frac, *T0_min ); } @@ -600,7 +598,7 @@ void pit_Q_dec_fx( } ELSE /* nBits == 4 */ /* relative decoding with 4 bits */ { - IF( sub(delta,8) == 0 ) + IF( EQ_16(delta,8)) { delta_pit_dec_fx( 0, pitch_index, T0, T0_frac, *T0_min ); } @@ -613,7 +611,7 @@ void pit_Q_dec_fx( /* biterror detection mechanism */ test(); test(); - IF( sub(add((*T0<<2),*T0_frac),add((PIT_MAX<<2),2)) > 0 && pit_flag == 0 && !Opt_AMR_WB ) + IF( GT_16(add((*T0<<2),*T0_frac),add((PIT_MAX<<2),2))&&pit_flag==0&&!Opt_AMR_WB) { *T0 = L_SUBFR; move16(); @@ -651,10 +649,10 @@ void pit16k_Q_dec_fx( { Word16 index; - IF( sub(nBits,10) == 0) /* absolute decoding with 10 bits */ + IF( EQ_16(nBits,10)) /* absolute decoding with 10 bits */ { { - IF( sub(pitch_index,shl((PIT16k_FR2_EXTEND_10b-PIT16k_MIN_EXTEND),2)) < 0 ) + IF( LT_16(pitch_index,shl((PIT16k_FR2_EXTEND_10b-PIT16k_MIN_EXTEND),2))) { *T0 = add(PIT16k_MIN_EXTEND, shr(pitch_index,2)); move16(); @@ -673,17 +671,17 @@ void pit16k_Q_dec_fx( } } - ELSE IF ( sub(nBits,9) == 0 ) /* absolute decoding with 9 bits */ + ELSE IF ( EQ_16(nBits,9)) /* absolute decoding with 9 bits */ { { - IF (sub(pitch_index,(PIT16k_FR2_EXTEND_9b-PIT16k_MIN_EXTEND)*4) < 0) + IF (LT_16(pitch_index,(PIT16k_FR2_EXTEND_9b-PIT16k_MIN_EXTEND)*4)) { *T0 = add(PIT16k_MIN_EXTEND, shr(pitch_index,2)); move16(); *T0_frac = sub(pitch_index, shl(sub(*T0, PIT16k_MIN_EXTEND),2)); move16(); } - ELSE IF (sub(pitch_index,( (PIT16k_FR2_EXTEND_9b-PIT16k_MIN_EXTEND)*4 + (PIT16k_FR1_EXTEND_9b-PIT16k_FR2_EXTEND_9b)*2)) < 0 ) + ELSE IF (LT_16(pitch_index,( (PIT16k_FR2_EXTEND_9b-PIT16k_MIN_EXTEND)*4 + (PIT16k_FR1_EXTEND_9b-PIT16k_FR2_EXTEND_9b)*2))) { index = sub(pitch_index, (PIT16k_FR2_EXTEND_9b-PIT16k_MIN_EXTEND)*4); *T0 = add(PIT16k_FR2_EXTEND_9b, shr(index,1)); @@ -708,7 +706,7 @@ void pit16k_Q_dec_fx( /* biterror detection mechanism */ test(); - IF( sub(add((*T0<<2),*T0_frac),(PIT16k_MAX<<2)) > 0 && sub(nBits,9) >= 0 ) + IF( GT_16(add((*T0<<2),*T0_frac),(PIT16k_MAX<<2))&&GE_16(nBits,9)) { *T0 = L_SUBFR; move16(); @@ -742,9 +740,9 @@ void abs_pit_dec_fx( IF( limit_flag == 0 ) { - IF(sub(fr_steps,2) == 0) + IF(EQ_16(fr_steps,2)) { - IF(sub(pitch_index,PIT_FR1_8b_MINUS_PIT_MIN_X2) < 0) + IF(LT_16(pitch_index,PIT_FR1_8b_MINUS_PIT_MIN_X2)) { *T0= add(PIT_MIN,shr(pitch_index,1)); move16(); @@ -760,9 +758,9 @@ void abs_pit_dec_fx( move16(); } } - ELSE IF( sub(fr_steps,4) == 0 ) + ELSE IF( EQ_16(fr_steps,4)) { - IF(sub(pitch_index,PIT_FR2_9b_MINUS_PIT_MIN_X4) < 0) + IF(LT_16(pitch_index,PIT_FR2_9b_MINUS_PIT_MIN_X4)) { *T0= add(PIT_MIN,shr(pitch_index,2)); move16(); @@ -770,7 +768,7 @@ void abs_pit_dec_fx( *T0_frac = sub(pitch_index,temp); move16(); } - ELSE IF (sub(pitch_index,PIT_DECODE_1) < 0) /*( (PIT_FR2_9b-PIT_MIN)*4 + (PIT_FR1_9b-PIT_FR2_9b)*2) = 440*/ + ELSE IF (LT_16(pitch_index,PIT_DECODE_1)) /*( (PIT_FR2_9b-PIT_MIN)*4 + (PIT_FR1_9b-PIT_FR2_9b)*2) = 440*/ { pitch_index = sub(pitch_index,PIT_DECODE_2); /*pitch_index -= (PIT_FR2_9b-PIT_MIN)*4(=376);*/ *T0 = add(PIT_FR2_9b,shr(pitch_index,1)); @@ -792,11 +790,11 @@ void abs_pit_dec_fx( /* not used in the codec */ } } - ELSE IF( sub(limit_flag, 1) == 0 ) /* extended Q range */ + ELSE IF( EQ_16(limit_flag, 1)) /* extended Q range */ { - IF( sub(fr_steps,2) == 0 ) + IF( EQ_16(fr_steps,2)) { - IF( sub(pitch_index, PIT_FR1_EXT8b_MINUS_PIT_MIN_EXT_X2) < 0 ) + IF( LT_16(pitch_index, PIT_FR1_EXT8b_MINUS_PIT_MIN_EXT_X2)) { *T0 = add(PIT_MIN_EXTEND, shr(pitch_index,1)); move16(); @@ -812,9 +810,9 @@ void abs_pit_dec_fx( move16(); } } - ELSE IF( sub(fr_steps,4) == 0 ) + ELSE IF( EQ_16(fr_steps,4)) { - IF( sub(pitch_index, PIT_FR2_EXT9b_MINUS_PIT_MIN_EXT_X4) < 0 ) + IF( LT_16(pitch_index, PIT_FR2_EXT9b_MINUS_PIT_MIN_EXT_X4)) { /**T0 = PIT_MIN_EXTEND + (pitch_index/4);*/ *T0 = add(PIT_MIN_EXTEND, shr(pitch_index,2)); @@ -823,7 +821,7 @@ void abs_pit_dec_fx( *T0_frac = sub(pitch_index, shl(sub(*T0, PIT_MIN_EXTEND),2)); move16(); } - ELSE IF( sub(pitch_index,add(PIT_FR2_EXT9b_MINUS_PIT_MIN_EXT_X4, PIT_FR1_EXT9b_MINUS_PIT_FR2_EXT9b_X2)) < 0 ) + ELSE IF( LT_16(pitch_index,add(PIT_FR2_EXT9b_MINUS_PIT_MIN_EXT_X4, PIT_FR1_EXT9b_MINUS_PIT_FR2_EXT9b_X2))) { /*pitch_index -= (PIT_FR2_EXTEND_9b-PIT_MIN_EXTEND)*4;*/ pitch_index = sub(pitch_index, PIT_FR2_EXT9b_MINUS_PIT_MIN_EXT_X4); @@ -848,9 +846,9 @@ void abs_pit_dec_fx( } ELSE /* limit_flag == 2 */ { - IF( sub(fr_steps,2) == 0 ) + IF( EQ_16(fr_steps,2)) { - IF( sub(pitch_index,PIT_FR1_DEXT8b_MINUS_PIT_MIN_DEXT_X2) < 0) + IF( LT_16(pitch_index,PIT_FR1_DEXT8b_MINUS_PIT_MIN_DEXT_X2)) { *T0 = add(PIT_MIN_DOUBLEEXTEND, shr(pitch_index,1)); move16(); @@ -868,16 +866,16 @@ void abs_pit_dec_fx( move16(); } } - ELSE IF( sub(fr_steps,4) == 0 ) + ELSE IF( EQ_16(fr_steps,4)) { - IF( sub(pitch_index, PIT_FR2_DEXT9b_MINUS_PIT_MIN_DEXT_X4) < 0) + IF( LT_16(pitch_index, PIT_FR2_DEXT9b_MINUS_PIT_MIN_DEXT_X4)) { *T0 = add(PIT_MIN_DOUBLEEXTEND, shr(pitch_index,2)); move16(); *T0_frac = sub(pitch_index, shl(sub(*T0, PIT_MIN_DOUBLEEXTEND),2)); move16(); } - ELSE IF( sub(pitch_index,PIT_DECODE_9) < 0) + ELSE IF( LT_16(pitch_index,PIT_DECODE_9)) { /*pitch_index -= (PIT_FR2_DOUBLEEXTEND_9b-PIT_MIN_DOUBLEEXTEND)*4;move16();*/ pitch_index = sub(pitch_index , PIT_FR2_DEXT9b_MINUS_PIT_MIN_DEXT_X4); @@ -929,7 +927,7 @@ void delta_pit_dec_fx( *T0_frac = 0; move16(); } - ELSE IF( sub(fr_steps,2) == 0 ) + ELSE IF( EQ_16(fr_steps,2)) { *T0 = add(T0_min,shr(pitch_index,1)); move16(); @@ -937,7 +935,7 @@ void delta_pit_dec_fx( *T0_frac = shl(sub(pitch_index,temp),1); move16(); } - ELSE IF ( sub(fr_steps,4) == 0 ) + ELSE IF ( EQ_16(fr_steps,4)) { *T0 = add(T0_min,shr(pitch_index,2)); move16(); diff --git a/lib_dec/pitch_extr.c b/lib_dec/pitch_extr.c index c3285895d1cb9dd4106872e929e31b4b80fa2eed..0a8fa906727882dcfa1f96a4fdbff5ef186a5703 100644 --- a/lib_dec/pitch_extr.c +++ b/lib_dec/pitch_extr.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ @@ -12,8 +12,6 @@ #include "prot_fx.h" #include "basop_util.h" #include "stl.h" -#include "wmc_auto.h" - #include "options.h" @@ -64,7 +62,7 @@ void pitch_pred_linear_fit( /* Inverse the order the pitch lag memory */ - IF ( sub(nb_subfr, 4) == 0 ) + IF ( EQ_16(nb_subfr, 4)) { FOR (i = 0; i < 2*NB_SUBFR+2; i++) { @@ -86,7 +84,7 @@ void pitch_pred_linear_fit( move16(); move16(); /*timeweight*/ - IF ( 0 > sub(pit_max,extract_h(*old_fpitch)) ) + IF (LT_16(pit_max,extract_h(*old_fpitch)) ) { *extrapolationFailed = 1; *T0_out = pit_max; @@ -99,7 +97,7 @@ void pitch_pred_linear_fit( test(); test(); - IF (sub(bfi_cnt , 1) == 0 && sub(last_good , UNVOICED_TRANSITION) >= 0 && sub(last_good , ONSET) < 0) + IF (EQ_16(bfi_cnt , 1)&&GE_16(last_good,UNVOICED_TRANSITION)&<_16(last_good,ONSET)) { move16(); no_subfr_pred = 4; @@ -131,7 +129,7 @@ void pitch_pred_linear_fit( FOR (i = 1; i last_bwidth_fx,NB)==0 ) + IF ( EQ_16(st->last_bwidth_fx,NB)) { Copy( synth, synth2_pe, L_frame ); tmp = synth[-1]; @@ -100,9 +98,9 @@ void post_decoder( move16(); test(); test(); - if ((L_sub(st->lp_noise, LP_NOISE_THRESH) > 0) || + if ((GT_32(st->lp_noise, LP_NOISE_THRESH))|| (st->core_fx != ACELP_CORE) || - (sub(coder_type, UNVOICED) == 0)) + (EQ_16(coder_type, UNVOICED))) { tmp = 1; move16(); @@ -113,7 +111,7 @@ void post_decoder( st->pfstat.reset = 1; move16(); } - IF ( sub(st->bwidth_fx,NB) == 0) + IF ( EQ_16(st->bwidth_fx,NB)) { st->pfstat.on = 1; move16(); @@ -141,7 +139,7 @@ void post_decoder( st->pfstat.reset = 1; move16(); } - IF ( sub(st->last_bwidth_fx,WB)>=0 ) + IF ( GE_16(st->last_bwidth_fx,WB)) { st->pfstat.on = 1; move16(); @@ -159,7 +157,7 @@ void post_decoder( tmp8 = 0; move16(); test(); - if( L_sub(st->lp_noise,LP_NOISE_THRESH) > 0 && st->narrowBand ) + if( GT_32(st->lp_noise,LP_NOISE_THRESH)&&st->narrowBand) { tmp8 = 1; move16(); @@ -244,25 +242,41 @@ static void bass_pf_1sf_delay( IF (lg > 0) { - FOR (i = 0; i < lg; i++) - { - tmp32 = L_mult(syn[i+i_subfr-T], 0x4000); - tmp32 = L_mac(tmp32, syn[i+i_subfr+T], 0x4000); - tmp16 = round_fx(L_shl(tmp32, s1)); /* Q0+s1 */ - tmp = L_mac0(tmp, shl(syn[i+i_subfr], s1), tmp16); /* Q0+2*s1 */ - nrg = L_mac0(nrg, tmp16, tmp16); /* Q0+2*s1 */ + { + Word64 tmp64 = W_deposit32_l( tmp ); + Word64 nrg64 = W_deposit32_l( nrg ); + FOR (i = 0; i < lg; i++) + { + tmp32 = L_mult(syn[i+i_subfr-T], 0x4000); + tmp32 = L_mac(tmp32, syn[i+i_subfr+T], 0x4000); + tmp16 = round_fx(L_shl(tmp32, s1)); /* Q0+s1 */ + + tmp64 = W_mac0_16_16(tmp64, shl(syn[i+i_subfr], s1), tmp16); /* Q0+2*s1 */ + nrg64 = W_mac0_16_16(nrg64, tmp16, tmp16); /* Q0+2*s1 */ + } + tmp = W_sat_l(tmp64); + nrg = W_sat_l(nrg64); } + } - IF (sub(lg, l_subfr) < 0) + IF (LT_16(lg, l_subfr)) { - FOR (i = lg; i < l_subfr; i++) + { - tmp16 = shl(syn[i+i_subfr-T], s1); /* Q0+s1 */ - tmp = L_mac0(tmp, shl(syn[i+i_subfr], s1), tmp16); /* Q0+2*s1 */ - nrg = L_mac0(nrg, tmp16, tmp16); /* Q0+2*s1 */ + Word64 tmp64 = W_deposit32_l( tmp ); + Word64 nrg64 = W_deposit32_l( nrg ); + FOR (i = lg; i < l_subfr; i++) + { + tmp16 = shl(syn[i+i_subfr-T], s1); /* Q0+s1 */ + tmp64 = W_mac0_16_16(tmp64, shl(syn[i+i_subfr], s1), tmp16); /* Q0+2*s1 */ + nrg64 = W_mac0_16_16(nrg64, tmp16, tmp16); /* Q0+2*s1 */ + } + tmp = W_sat_l(tmp64); + nrg = W_sat_l(nrg64); } + } /* gain = tmp/nrg; */ @@ -279,7 +293,7 @@ static void bass_pf_1sf_delay( st = sub(norm_l(lp_error), 3); test(); - if ((sub(st, s1) < 0) && (lp_error != 0)) + if ((LT_16(st, s1))&&(lp_error!=0)) { s1 = st; move16(); @@ -289,34 +303,46 @@ static void bass_pf_1sf_delay( IF (lg > 0) { - FOR (i = 0; i < lg; i++) - { - tmp32 = L_msu0(0, gain, syn[i+i_subfr-T]); - tmp32 = L_msu0(tmp32, gain, syn[i+i_subfr+T]); - tmp16 = mac_r(tmp32, gain, syn[i+i_subfr]); /* Q0 */ - - lp_error = Mpy_32_16_1(lp_error, 29491/*0.9f Q15*/); - lp_error = L_mac(lp_error, tmp16, 0x1000); /* Q13 */ - tmp16 = round_fx(L_shl(lp_error, s1)); /* Q0+s1-3 */ - ener2 = L_mac0(ener2, tmp16, tmp16); /* Q0+(s1-3)*2 */ + { + Word64 ener2_64 = W_deposit32_l( ener2 ); + FOR (i = 0; i < lg; i++) + { + tmp32 = L_msu0(0, gain, syn[i+i_subfr-T]); + tmp32 = L_msu0(tmp32, gain, syn[i+i_subfr+T]); + tmp16 = mac_r(tmp32, gain, syn[i+i_subfr]); /* Q0 */ + + lp_error = Mpy_32_16_1(lp_error, 29491/*0.9f Q15*/); + lp_error = L_mac(lp_error, tmp16, 0x1000); /* Q13 */ + + tmp16 = round_fx(L_shl(lp_error, s1)); /* Q0+s1-3 */ + ener2_64 = W_mac0_16_16(ener2_64, tmp16, tmp16); /* Q0+(s1-3)*2 */ + } + ener2 = W_sat_l(ener2_64); } + } - IF (sub(lg, l_subfr) < 0) + IF (LT_16(lg, l_subfr)) { - FOR (i = lg; i < l_subfr; i++) - { - tmp32 = L_mult0(gain, syn[i+i_subfr]); - tmp32 = L_msu0(tmp32, gain, syn[i+i_subfr-T]); /* Q0 */ - tmp16 = round_fx(tmp32); - - lp_error = Mpy_32_16_1(lp_error, 29491/*0.9f Q15*/); - lp_error = L_mac(lp_error, tmp16, 0x1000); /* Q13 */ - tmp16 = round_fx(L_shl(lp_error, s1)); /* Q0+s1-3 */ - ener2 = L_mac0(ener2, tmp16, tmp16); /* Q0+(s1-3)*2 */ + { + Word64 ener2_64 = W_deposit32_l( ener2 ); + FOR (i = lg; i < l_subfr; i++) + { + tmp32 = L_mult0(gain, syn[i+i_subfr]); + tmp32 = L_msu0(tmp32, gain, syn[i+i_subfr-T]); /* Q0 */ + tmp16 = round_fx(tmp32); + + lp_error = Mpy_32_16_1(lp_error, 29491/*0.9f Q15*/); + lp_error = L_mac(lp_error, tmp16, 0x1000); /* Q13 */ + + tmp16 = round_fx(L_shl(lp_error, s1)); /* Q0+s1-3 */ + ener2_64 = W_mac0_16_16(ener2_64, tmp16, tmp16); /* Q0+(s1-3)*2 */ + } + ener2 = W_sat_l(ener2_64); } + } st = shl(sub(s1, 3), 1); @@ -350,7 +376,7 @@ static void bass_pf_1sf_delay( BASOP_SATURATE_WARNING_OFF; tmp16 = shl(tmp16, sub(st, 2)); /* Q15 */ - if (sub(tmp16, 16384/*0.5f Q15*/) > 0) + if (GT_16(tmp16, 16384/*0.5f Q15*/)) { tmp16 = 16384/*0.5f Q15*/; move16(); @@ -380,7 +406,7 @@ static void bass_pf_1sf_delay( } } - IF (sub(lg, l_subfr) < 0) + IF (LT_16(lg, l_subfr)) { FOR (i = lg; i < l_subfr; i++) { @@ -438,16 +464,16 @@ void cldfb_synth_set_bandsToZero( perc_miss = 13107; /*0.80 in Q14*/ perc_detect = 14746; /*0.90 in Q14*/ - IF(sub(st->VAD,1) == 0) + IF(EQ_16(st->VAD,1)) { st->active_frame_cnt_bwddec = add(st->active_frame_cnt_bwddec,1); st->total_frame_cnt_bwddec = add(st->total_frame_cnt_bwddec,1); - if(sub(st->active_frame_cnt_bwddec, 99) > 0) + if(GT_16(st->active_frame_cnt_bwddec, 99)) { st->active_frame_cnt_bwddec = 100; move16(); } - if(sub(st->total_frame_cnt_bwddec, 500) > 0) + if(GT_16(st->total_frame_cnt_bwddec, 500)) { st->total_frame_cnt_bwddec = 500; move16(); @@ -468,7 +494,7 @@ void cldfb_synth_set_bandsToZero( nrg_band[i] = (nrgQ31); move16(); test(); - if(L_sub(nrg_band[i], max_nrg) > 0 && sub(i,11) >= 0) + if(GT_32(nrg_band[i], max_nrg)&&GE_16(i,11)) { max_nrg = nrg_band[i]; move16(); @@ -515,7 +541,7 @@ void cldfb_synth_set_bandsToZero( move16(); /*long term percentage*/ - IF(sub(update_perc, 1) == 0) + IF(EQ_16(update_perc, 1)) { IF(flag != 0) { @@ -541,7 +567,7 @@ void cldfb_synth_set_bandsToZero( } } test(); - IF(sub(st->total_frame_cnt_bwddec, offset) > 0 && sub(st->active_frame_cnt_bwddec, 50) > 0) + IF(GT_16(st->total_frame_cnt_bwddec, offset)&>_16(st->active_frame_cnt_bwddec,50)) { IF( (st->perc_bwddec >= perc_detect || (st->perc_bwddec >= perc_miss && st->last_flag_filter_NB)) && (sum16_fx(st->flag_buffer, WBcnt) != 0)) /*decision hysterysis*/ { @@ -580,7 +606,7 @@ void cldfb_synth_set_bandsToZero( move16(); } st->total_frame_cnt_bwddec = add(st->total_frame_cnt_bwddec, 1); - if(sub(st->total_frame_cnt_bwddec, 500) > 0) + if(GT_16(st->total_frame_cnt_bwddec, 500)) { st->total_frame_cnt_bwddec = 500; move16(); diff --git a/lib_dec/ppp_dec_fx.c b/lib_dec/ppp_dec_fx.c index 1363130dbbb435f247975bc369b2e1e392eefcd6..adecd0909f90061733e9d1f20f17615b90b538fa 100644 --- a/lib_dec/ppp_dec_fx.c +++ b/lib_dec/ppp_dec_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -7,8 +7,6 @@ #include "prot_fx.h" #include "rom_com_fx.h" #include "stl.h" -#include "wmc_auto.h" - /*===================================================================*/ @@ -78,12 +76,12 @@ void ppp_quarter_decoder_fx( Word16 tmp, exp; - IF ( sub(CURRCW_Q_DTFS_FX->upper_cut_off_freq_fx,4000 ) == 0) + IF ( EQ_16(CURRCW_Q_DTFS_FX->upper_cut_off_freq_fx,4000 )) { num_erb_fx = 22; move16(); } - ELSE IF ( sub(CURRCW_Q_DTFS_FX->upper_cut_off_freq_fx,6400) == 0 ) + ELSE IF ( EQ_16(CURRCW_Q_DTFS_FX->upper_cut_off_freq_fx,6400)) { num_erb_fx = 24; move16(); @@ -142,7 +140,7 @@ void ppp_quarter_decoder_fx( Erot_fx = sub(temp_l_fx,temp_fx); /*Q0 */ Q2phaseShift_fx(PREVDTFS_FX,shl(Erot_fx,2),CURRCW_Q_DTFS_FX->lag_fx,S_fx,C_fx); - IF ( sub(bfi,1) == 0 ) + IF ( EQ_16(bfi,1)) { DTFS_car2pol_fx(CURRCW_Q_DTFS_FX); } diff --git a/lib_dec/pvq_core_dec_fx.c b/lib_dec/pvq_core_dec_fx.c index e0148d7448db8b724216e28b60f991e3bc2f05ab..9332c406f2e01916afe6b0783d976e44eecc63ec 100644 --- a/lib_dec/pvq_core_dec_fx.c +++ b/lib_dec/pvq_core_dec_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -8,8 +8,6 @@ #include "prot_fx.h" /* Function prototypes */ #include "rom_com_fx.h" /* Static table prototypes */ #include "stl.h" -#include "wmc_auto.h" - #include "basop_util.h" static Word16 get_pvq_splits_fx(Decoder_State_fx *st_fx, const Word16 band_bits, const Word16 sfmsize, Word16 *bits); @@ -57,7 +55,7 @@ static void pvq_decode_band_fx( /* Encode energies */ set16_fx( g_part_neg, -32768, Np ); - IF( sub(Np, 1) > 0 ) + IF( GT_16(Np, 1)) { decode_energies_fx( st_fx, Np, dim_part, bits_part, g_part_neg, band_bits_tot, bits_left, sfmsize, strict_bits ); } @@ -71,12 +69,12 @@ static void pvq_decode_band_fx( move16(); pool_part = 0; move16(); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF FOR (j = 0; j < Np; j++) { g_part[j] = negate(g_part_neg[j]); } - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON srt_vec_ind16_fx(g_part, sg_part, idx_sort, Np); FOR(j = 0; j < Np; j++) { @@ -334,7 +332,7 @@ void decode_energies_fx( &l_bits, &r_bits, bits_left); - IF (sub(l_Np, 1) > 0) + IF (GT_16(l_Np, 1)) { decode_energies_fx( st_fx, l_Np, dim_part, bits_part, g_part, l_bits, bits_left, l_dim, strict_bits ); } @@ -344,7 +342,7 @@ void decode_energies_fx( move16(); } - IF (sub(r_Np, 1) > 0) + IF (GT_16(r_Np, 1)) { decode_energies_fx( st_fx, r_Np, &dim_part[l_Np], &bits_part[l_Np], &g_part[l_Np], r_bits, bits_left, r_dim, strict_bits ); } @@ -401,7 +399,7 @@ static void densitySymbolIndexDecode_fx(Decoder_State_fx *st_fx, sym_freq = L_mac(1L, sub(density, alpha), 1); cum_freq = L_mac0(L_mult(alpha, density), alpha, 1); } - ELSE IF (sub(c, density) == 0) + ELSE IF (EQ_16(c, density)) { dec_freq = rc_decode_fx(st_fx, tot); @@ -426,7 +424,7 @@ static void densitySymbolIndexDecode_fx(Decoder_State_fx *st_fx, acc = L_add(acc, L_add(density, 1)); acc = L_sub(acc, L_add(c, 1)); acc = L_sub(tot, acc); - IF (L_sub(dec_freq, acc ) < 0) + IF (LT_32(dec_freq, acc )) { acc = L_add((Word32)density_c, L_shl(dec_freq, 2)); acc = L_sub(acc, 2); @@ -527,10 +525,10 @@ static Word16 get_pvq_splits_fx( /* o : Number of segments */ } *bits = 0; move16(); - IF (sub(Np, MAX_SPLITS) < 0) + IF (LT_16(Np, MAX_SPLITS)) { acc = L_mult0(8*THR_ADD_SPLIT, sfmsize); - IF (L_sub(band_bits, acc) > 0) + IF (GT_32(band_bits, acc)) { flag = rc_dec_bits_fx(st_fx, 1); *bits = 8; diff --git a/lib_dec/pvq_decode_fx.c b/lib_dec/pvq_decode_fx.c index 3a60086360b5f9225d6f4dbde559553e4ccafe8f..6fdca0587fab2a1df54e55e5f4e489b4c3d36929 100644 --- a/lib_dec/pvq_decode_fx.c +++ b/lib_dec/pvq_decode_fx.c @@ -1,12 +1,10 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include #include "options.h" /* Compilation switches */ #include "stl.h" -#include "wmc_auto.h" - #include "prot_fx.h" #include "rom_com_fx.h" @@ -37,7 +35,7 @@ void pvq_decode_fx( entry = get_size_mpvq_calc_offset_fx(dim, k_val, h_mem); /* get size & prepare H(adaptive table for entry.size=N_MPVQ(dim,k_val) */ - IF( sub(dim, 1) != 0) + IF( NE_16(dim, 1)) { entry.lead_sign_ind = (short)rc_dec_bits_fx(st_fx, 1); entry.index = rc_dec_uniform_fx(st_fx, entry.size); @@ -45,7 +43,7 @@ void pvq_decode_fx( /* safety check in case of bit errors */ test(); - IF( L_sub(entry.index, entry.size) >= 0 || st_fx->ber_occured_in_pvq != 0 ) + IF( GE_32(entry.index, entry.size)||st_fx->ber_occured_in_pvq!=0) { st_fx->ber_occured_in_pvq = 1; move16(); diff --git a/lib_dec/range_dec_fx.c b/lib_dec/range_dec_fx.c index 862af66b03a7ae278ecd4e0d352e75b2a938723d..8aae451442394ac33127deee5d21c57dc087a4ed 100644 --- a/lib_dec/range_dec_fx.c +++ b/lib_dec/range_dec_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -10,8 +10,6 @@ #include "stl.h" -#include "wmc_auto.h" - static Word16 rc_dec_read_fx(Decoder_State_fx *st_fx); @@ -132,7 +130,7 @@ Word32 rc_dec_bits_fx( /* i : Decoded value */ st_fx->rc_num_bits_fx = add(st_fx->rc_num_bits_fx, bits); - IF (sub(bits, 16) > 0) + IF (GT_16(bits, 16)) { st_fx->rc_offset_fx = sub(st_fx->rc_offset_fx, sub(bits, 16)); value = UL_lshl(UL_deposit_l(get_indice_fx(st_fx, st_fx->rc_offset_fx, sub(bits, 16))), 16); @@ -163,7 +161,7 @@ UWord32 rc_dec_uniform_fx( /* i : Decoded value */ Word16 n; n = sub(32, norm_ul(tot - 1)); - IF (sub(n, 8) <= 0) + IF (LE_16(n, 8)) { value = rc_decode_fx(st_fx, tot); rc_dec_update_fx(st_fx, value, 1); @@ -215,4 +213,3 @@ static Word16 rc_dec_read_fx(Decoder_State_fx *st_fx) } } - diff --git a/lib_dec/re8_dec_fx.c b/lib_dec/re8_dec_fx.c index 90319c2706a9b89afc590a44b9de78b408da9ba8..9ba13296b04e8b158f0ea8cf67e5a5a820332c10 100644 --- a/lib_dec/re8_dec_fx.c +++ b/lib_dec/re8_dec_fx.c @@ -1,12 +1,10 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*-------------------------------------------------------------------------- * re8_dec_fx() @@ -30,7 +28,7 @@ void re8_dec_fx( * if n=0,2,3,4, decode I (no Voronoi extension) * if n>4, Voronoi extension is used, decode I and kv[] *------------------------------------------------------------------------*/ - IF( sub(n, 4) <= 0 ) + IF( LE_16(n, 4)) { re8_decode_base_index_fx( n, I, y ); } diff --git a/lib_dec/rom_dec_fx.c b/lib_dec/rom_dec_fx.c index 0ce7451fe538ad96149ab4ab2cc072071a37658a..1c5da26f8d0095a9cff4871373c8952e1b513845 100644 --- a/lib_dec/rom_dec_fx.c +++ b/lib_dec/rom_dec_fx.c @@ -1,11 +1,8 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "stl.h" -#include "wmc_auto.h" - - #include "cnst_fx.h" /* Common constants */ #include "basop_util.h" diff --git a/lib_dec/rom_dec_fx.h b/lib_dec/rom_dec_fx.h index f08edb586cfc82298c0aa637fa46197fd7755646..5c434a3785f0a7b3746ac32aecb69de907349ed6 100644 --- a/lib_dec/rom_dec_fx.h +++ b/lib_dec/rom_dec_fx.h @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ diff --git a/lib_dec/rst_dec_fx.c b/lib_dec/rst_dec_fx.c index 982267686bf378422350ac662bdd746573167b88..62b1fd8783c87c74a56cf28aeab71d04abfedefd 100644 --- a/lib_dec/rst_dec_fx.c +++ b/lib_dec/rst_dec_fx.c @@ -1,11 +1,9 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "stl.h" -#include "wmc_auto.h" - #include "cnst_fx.h" /* Common constants */ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ @@ -65,7 +63,7 @@ void CNG_reset_dec_fx( st_fx->lp_gainc_fx = round_fx(L_shl(L_tmp, sub(exp, 12))); /* In Q3 */ } /* reset the pitch buffer in case of FRAME_NO_DATA or SID frames */ - IF( sub(st_fx->L_frame_fx,L_FRAME) == 0 ) + IF( EQ_16(st_fx->L_frame_fx,L_FRAME)) { set16_fx( pitch_buf, L_SUBFR<<6, NB_SUBFR ); } diff --git a/lib_dec/rtpdump.c b/lib_dec/rtpdump.c index f51eb3d28cc9411a1ff54abeb5e3d8c9a189b8da..9bfd32a6c95c425f4e537f8e5dd313e616753d7b 100644 --- a/lib_dec/rtpdump.c +++ b/lib_dec/rtpdump.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include diff --git a/lib_dec/rtpdump.h b/lib_dec/rtpdump.h index 0f81900ee9c9137f702543039d7a77acc77d0d4c..fb6e8e00194d0489468c3de155be89517768a49c 100644 --- a/lib_dec/rtpdump.h +++ b/lib_dec/rtpdump.h @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #pragma once diff --git a/lib_dec/stat_dec_fx.h b/lib_dec/stat_dec_fx.h index a55ce6645abcd43f377699ee29327ce17f5e0452..5beae6286cc36837bdc020db79ec8ff4cdf9ed89 100644 --- a/lib_dec/stat_dec_fx.h +++ b/lib_dec/stat_dec_fx.h @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #ifndef STAT_DEC_FX_H diff --git a/lib_dec/stat_noise_uv_dec_fx.c b/lib_dec/stat_noise_uv_dec_fx.c index 56d6acbb61179da593c2fa76d77e45b775448c1a..ff5365561ef67ad4c2051c3329d45cddb2f2e06b 100644 --- a/lib_dec/stat_noise_uv_dec_fx.c +++ b/lib_dec/stat_noise_uv_dec_fx.c @@ -1,11 +1,9 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "stl.h" -#include "wmc_auto.h" - #include "prot_fx.h" /* Function prototypes */ @@ -31,7 +29,7 @@ void stat_noise_uv_dec_fx( *-----------------------------------------------------------------*/ test(); test(); - IF( sub(coder_type,UNVOICED ) == 0|| ( sub(coder_type,INACTIVE) == 0 && L_sub(st_fx->core_brate_fx,ACELP_9k60) <= 0 ) ) + IF( EQ_16(coder_type,UNVOICED )||(EQ_16(coder_type,INACTIVE)&&LE_32(st_fx->core_brate_fx,ACELP_9k60))) { /* read the noisiness parameter */ noisiness = (Word16)get_next_indice_fx( st_fx, 5 ); @@ -42,9 +40,9 @@ void stat_noise_uv_dec_fx( * Update long-term energies for FEC * Update LSP vector for CNG *-----------------------------------------------------------------*/ - IF (sub(coder_type,INACTIVE) == 00) + IF (EQ_16(coder_type,INACTIVE)) { - IF (sub(st_fx->unv_cnt_fx,20) > 0) + IF (GT_16(st_fx->unv_cnt_fx,20)) { /*ftmp = st->lp_gainc * st->lp_gainc;*/ L_tmp = L_mult0(st_fx->lp_gainc_fx, st_fx->lp_gainc_fx); /*Q3 * Q3 ->Q6*/ diff --git a/lib_dec/swb_bwe_dec_fx.c b/lib_dec/swb_bwe_dec_fx.c index 8185b0ba7630ce8bb142d4cdcd07c745dce2722f..7d3598da41a7bac252544f06b0e114588102d1dc 100644 --- a/lib_dec/swb_bwe_dec_fx.c +++ b/lib_dec/swb_bwe_dec_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -11,8 +11,6 @@ #include "stl.h" -#include "wmc_auto.h" - #define MAX_Q_NEW_INPUT 8 #define Q_WTDA_FX 13 #define Q_32_BITS 15 @@ -78,7 +76,7 @@ Word16 para_pred_bws_fx( { tmp = 0; move16(); - if(sub(shr(peak_fx, 3), shl(1, Q_syn)) > 0) + if(GT_16(shr(peak_fx, 3), shl(1, Q_syn))) { tmp = 1; move16(); @@ -108,10 +106,10 @@ Word16 para_pred_bws_fx( peak_32_fx = L_deposit_l(0); FOR(i = 4; i < 7; i ++) { - IF(L_sub(mean_fx[i], L_shl(avrg2_fx, 1)) > 0) + IF(GT_32(mean_fx[i], L_shl(avrg2_fx, 1))) { exp = norm_l(mean_fx[i]); - IF(sub(exp, 16) < 0) + IF(LT_16(exp, 16)) { tmp_den = extract_l(L_shr(mean_fx[i], sub(16, exp))); /*Qsyn - 16 + exp */ tmp_num = extract_l(L_shr(avrg2_fx, sub(15, exp))); /*//Qsyn - 16 + exp */ @@ -141,9 +139,9 @@ Word16 para_pred_bws_fx( /*} */ } - IF(sub(st_fx->tilt_wb_fx, 16384) > 0) + IF(GT_16(st_fx->tilt_wb_fx, 16384)) { - IF(sub(st_fx->tilt_wb_fx, 30720) > 0) + IF(GT_16(st_fx->tilt_wb_fx, 30720)) { min_fx = peak_32_fx; } @@ -162,7 +160,7 @@ Word16 para_pred_bws_fx( ELSE { exp = norm_l(peak_32_fx); - IF(sub(exp, 16) < 0) + IF(LT_16(exp, 16)) { tmp_den = extract_l(L_shr(peak_32_fx, sub(16, exp))); /*Qsyn - 16 + exp */ tmp = div_s(16384, tmp_den); /*Q15+14 - (Qsyn - 16 + exp) */ @@ -213,7 +211,7 @@ Word16 para_pred_bws_fx( move16(); } - IF(L_sub(avrg1_fx, L_shl(avrg2_fx, 3)) > 0) + IF(GT_32(avrg1_fx, L_shl(avrg2_fx, 3))) { FOR(i = 0; i < SWB_FENV; i ++) { @@ -227,14 +225,14 @@ Word16 para_pred_bws_fx( test(); test(); test(); - IF( sub(st_fx->last_core_fx, HQ_CORE) != 0 && sub(st_fx->last_codec_mode, MODE1) == 0 && - (L_sub(st_fx->enerLH_fx, L_shr(st_fx->prev_enerLH_fx, 1)) > 0 && L_sub(L_shr(st_fx->enerLH_fx, 1), st_fx->prev_enerLH_fx) < 0) && - (L_sub(st_fx->enerLL_fx, L_shr(st_fx->prev_enerLL_fx, 1)) > 0 && L_sub(L_shr(st_fx->enerLL_fx, 1), st_fx->prev_enerLL_fx) < 0) ) + IF( NE_16(st_fx->last_core_fx, HQ_CORE)&&EQ_16(st_fx->last_codec_mode,MODE1)&& + (GT_32(st_fx->enerLH_fx, L_shr(st_fx->prev_enerLH_fx, 1)) && LT_32(L_shr(st_fx->enerLH_fx, 1), st_fx->prev_enerLH_fx) ) && + (GT_32(st_fx->enerLL_fx, L_shr(st_fx->prev_enerLL_fx, 1)) && LT_32(L_shr(st_fx->enerLL_fx, 1), st_fx->prev_enerLL_fx) ) ) { FOR(i=0; iprev_coder_type_fx, coder_type) != 0 && sub(mult_r(SWB_fenv_fx[i], 16384), st_fx->prev_SWB_fenv_fx[i]) > 0) + IF(NE_16(st_fx->prev_coder_type_fx, coder_type)&>_16(mult_r(SWB_fenv_fx[i],16384),st_fx->prev_SWB_fenv_fx[i])) { /*SWB_fenv_fx[i] = add(mult_r(SWB_fenv_fx[i], 3277), mult_r(st_fx->prev_SWB_fenv_fx[i], 29491)); */ SWB_fenv_fx[i] = round_fx(L_mac(L_mult(SWB_fenv_fx[i], 3277), st_fx->prev_SWB_fenv_fx[i], 29491)); @@ -246,7 +244,7 @@ Word16 para_pred_bws_fx( } } - IF(sub(st_fx->attenu_fx, 29491) < 0) + IF(LT_16(st_fx->attenu_fx, 29491)) { st_fx->attenu_fx = add(st_fx->attenu_fx, 1638); move16(); @@ -258,12 +256,12 @@ Word16 para_pred_bws_fx( test(); test(); test(); - IF( L_sub(st_fx->core_brate_fx, st_fx->last_core_brate_fx) != 0 || (L_sub(st_fx->enerLH_fx, L_shr(st_fx->prev_enerLH_fx, 1)) > 0 && L_sub(L_shr(st_fx->enerLH_fx, 1), st_fx->prev_enerLH_fx) < 0) || - (L_sub(st_fx->enerLL_fx, L_shr(st_fx->prev_enerLL_fx, 1)) > 0 && L_sub(L_shr(st_fx->enerLL_fx, 1), st_fx->prev_enerLL_fx) < 0) ) + IF( NE_32(st_fx->core_brate_fx, st_fx->last_core_brate_fx)||(GT_32(st_fx->enerLH_fx,L_shr(st_fx->prev_enerLH_fx,1))&<_32(L_shr(st_fx->enerLH_fx,1),st_fx->prev_enerLH_fx))|| + (GT_32(st_fx->enerLL_fx, L_shr(st_fx->prev_enerLL_fx, 1)) && LT_32(L_shr(st_fx->enerLL_fx, 1), st_fx->prev_enerLL_fx) ) ) { FOR(i=0; iprev_SWB_fenv_fx[i]) > 0) + if(GT_16(mult_r(SWB_fenv_fx[i], 16384), st_fx->prev_SWB_fenv_fx[i])) { SWB_fenv_fx[i] = st_fx->prev_SWB_fenv_fx[i]; move16(); @@ -280,7 +278,7 @@ Word16 para_pred_bws_fx( move16(); } - if(sub(k, 3) > 0) + if(GT_16(k, 3)) { mode = HARMONIC; move16(); @@ -289,7 +287,7 @@ Word16 para_pred_bws_fx( att_fx = i_mult(sub(N_WS2N_FRAMES, st_fx->bws_cnt_fx), 819); move16();/*15 */ - IF( sub(st_fx->L_frame_fx, L_FRAME16k) == 0 ) + IF( EQ_16(st_fx->L_frame_fx, L_FRAME16k)) { FOR( i = 0; i < 4; i++ ) { @@ -400,7 +398,7 @@ Word16 wb_bwe_dec_fx( Q_syn = add(sub(new_input_fx_exp, 16), scl); IF( !st_fx->bfi_fx ) { - IF( L_sub(st_fx->total_brate_fx, ACELP_13k20) == 0 ) + IF( EQ_32(st_fx->total_brate_fx, ACELP_13k20)) { /* de-quantization */ mode = WB_BWE_gain_deq_fx(st_fx, WB_fenv_fx ); @@ -408,7 +406,7 @@ Word16 wb_bwe_dec_fx( } ELSE { - if( sub(st_fx->last_extl_fx, WB_BWE) != 0 ) + if( NE_16(st_fx->last_extl_fx, WB_BWE)) { st_fx->prev_SWB_fenv_fx[0] = 0; move16(); @@ -432,13 +430,13 @@ Word16 wb_bwe_dec_fx( } } test(); - IF( sub(st_fx->last_extl_fx, WB_BWE) != 0 || st_fx->bfi_fx ) + IF( NE_16(st_fx->last_extl_fx, WB_BWE)||st_fx->bfi_fx) { Copy( WB_fenv_fx, st_fx->prev_SWB_fenv_fx, 2 ); } exp = norm_l(st_fx->prev_Energy_wb_fx); - IF(sub(add(st_fx->prev_Q_synth, exp),Q_syn) > 0) + IF(GT_16(add(st_fx->prev_Q_synth, exp),Q_syn)) { st_fx->prev_Energy_wb_fx = L_shr(st_fx->prev_Energy_wb_fx, sub(st_fx->prev_Q_synth, Q_syn)); } @@ -451,11 +449,11 @@ Word16 wb_bwe_dec_fx( st_fx->last_extl_fx, &st_fx->prev_Energy_wb_fx, st_fx->prev_SWB_fenv_fx, &st_fx->prev_L_swb_norm_fx, st_fx->extl_fx, coder_type, st_fx->total_brate_fx, &st_fx->Seed_fx, &st_fx->prev_flag_fx, st_fx->prev_coder_type_fx, Q_syn, &Q_syn_hb ); - IF ( L_sub(st_fx->output_Fs_fx, 32000) == 0) + IF ( EQ_32(st_fx->output_Fs_fx, 32000)) { set32_fx( &ysynth_32[L_FRAME16k], 0, L_FRAME16k ); } - ELSE IF ( L_sub(st_fx->output_Fs_fx, 48000) == 0 ) + ELSE IF ( EQ_32(st_fx->output_Fs_fx, 48000)) { set32_fx( &ysynth_32[L_FRAME16k], 0, L_FRAME32k ); } @@ -507,7 +505,7 @@ Word16 swb_bwe_gain_deq_fx( /* o : BWE class */ } test(); - IF( sub(mode,1) == 0 && sub(core,ACELP_CORE) == 0 ) + IF( EQ_16(mode,1)&&EQ_16(core,ACELP_CORE)) { FOR( n_band = 0; n_band < SWB_TENV; n_band++ ) { @@ -580,7 +578,7 @@ Word16 swb_bwe_gain_deq_fx( /* o : BWE class */ nb_bits[3] = 5; move16(); - IF ( sub(hr_flag,1) == 0 ) + IF ( EQ_16(hr_flag,1)) { nb_bits[4] = 5; move16(); @@ -601,7 +599,7 @@ Word16 swb_bwe_gain_deq_fx( /* o : BWE class */ move16(); } - IF ( sub(hqswb_clas,HQ_GEN_FB) == 0 ) + IF ( EQ_16(hqswb_clas,HQ_GEN_FB)) { indice[n_band] = (Word16) get_next_indice_fx(st_fx, 5 ); move16(); @@ -619,7 +617,7 @@ Word16 swb_bwe_gain_deq_fx( /* o : BWE class */ move16(); /*Q8 */ } - IF ( sub(hr_flag,1) == 0 ) + IF ( EQ_16(hr_flag,1)) { quant_tmp[6] = add(quant_tmp[6],quant_tmp2[6]); move16();/*Q8 */ @@ -674,7 +672,7 @@ Word16 swb_bwe_gain_deq_fx( /* o : BWE class */ move16();/*Q1 */ } - IF ( sub(hqswb_clas,HQ_GEN_FB) == 0 ) + IF ( EQ_16(hqswb_clas,HQ_GEN_FB)) { Copy( &EnvCdbkFB_fx[i_mult2(indice[5], DIM_FB)], &SWB_fenv[nenv], DIM_FB ); /*Q7 */ @@ -779,7 +777,7 @@ Word16 swb_bwe_dec_fx( L = SWB_FENV; move16(); - if(sub(mode, TRANSIENT) == 0) + if(EQ_16(mode, TRANSIENT)) { L = SWB_FENV_TRANS; move16(); @@ -800,7 +798,7 @@ Word16 swb_bwe_dec_fx( ELSE { /* SHB FEC */ - IF( sub(st_fx->prev_mode_fx, TRANSIENT) != 0 ) + IF( NE_16(st_fx->prev_mode_fx, TRANSIENT)) { mode = st_fx->prev_mode_fx; move16(); @@ -816,7 +814,7 @@ Word16 swb_bwe_dec_fx( /* reconstruction of MDCT spectrum of the error signal */ set32_fx( ysynth_32, 0, output_frame ); - IF ( sub(st_fx->L_frame_fx, L_FRAME16k) == 0 ) + IF ( EQ_16(st_fx->L_frame_fx, L_FRAME16k)) { SWB_BWE_decoding_fx( ysynth_fx, SWB_fenv_fx, ysynth_32, L_FRAME32k-80, mode, &frica_flag, &st_fx->prev_Energy_fx, st_fx->prev_SWB_fenv_fx, &st_fx->prev_L_swb_norm_fx, st_fx->tilt_wb_fx, &st_fx->Seed_fx, 80, &st_fx->prev_weight_fx, st_fx->extl_fx, Q_syn @@ -832,7 +830,7 @@ Word16 swb_bwe_dec_fx( } test(); - IF ( sub(st_fx->prev_frica_flag_fx, 1) == 0 && frica_flag == 0 ) + IF ( EQ_16(st_fx->prev_frica_flag_fx, 1)&&frica_flag==0) { FOR( i = 0; i < L_SUBFR; i++ ) { @@ -849,7 +847,7 @@ Word16 swb_bwe_dec_fx( } /* decode information */ - IF ( sub(st_fx->extl_fx, FB_BWE) == 0 ) + IF ( EQ_16(st_fx->extl_fx, FB_BWE)) { IF( !st_fx->bfi_fx ) { @@ -864,7 +862,7 @@ Word16 swb_bwe_dec_fx( st_fx->prev_fb_ener_adjust_fx = fb_ener_adjust_fx; move16(); - IF(sub(mode, TRANSIENT) == 0) + IF(EQ_16(mode, TRANSIENT)) { ener_adjust_quan_fx = shr(fb_ener_adjust_fx, 2); move16(); /*Q13*/ @@ -917,7 +915,7 @@ Word16 swb_bwe_dec_fx( l_subfr = mult(output_frame, 8192); test(); - IF( sub(mode,TRANSIENT) == 0 ) + IF( EQ_16(mode,TRANSIENT)) { FOR(i = 0; i < SWB_TENV; i++) { @@ -932,7 +930,7 @@ Word16 swb_bwe_dec_fx( st_fx->prev_td_energy_fx = SWB_tenv_fx[3]; move16(); } - ELSE IF( sub(frica_flag, 1) == 0 && st_fx->prev_frica_flag_fx == 0 ) + ELSE IF( EQ_16(frica_flag, 1)&&st_fx->prev_frica_flag_fx==0) { time_reduce_pre_echo_fx( synth_fx, hb_synth_fx, st_fx->prev_td_energy_fx, l_subfr, *Qpost, Q_syn_hb ); } diff --git a/lib_dec/swb_bwe_dec_hr_fx.c b/lib_dec/swb_bwe_dec_hr_fx.c index e7fc29d781d70eae7878e120f84ce79b094dd308..2ae003d6d7b8bec5d929d22c96885e523603fdec 100644 --- a/lib_dec/swb_bwe_dec_hr_fx.c +++ b/lib_dec/swb_bwe_dec_hr_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -8,8 +8,6 @@ #include "rom_dec_fx.h" /* Static table prototypes */ #include "cnst_fx.h" /* Static table prototypes */ #include "stl.h" -#include "wmc_auto.h" - #define Q_GUARD 1 #define Q_32_BITS 14 /* scaling of 't_audio32' */ @@ -46,27 +44,27 @@ static Word16 Gain_Dequant_HR( /* o: decoded gain (Q13) */ move32(); move32(); - IF (sub(min, G_AVQ_MIN_FX) == 0) + IF (EQ_16(min, G_AVQ_MIN_FX)) { L_mini = MAKE_PSEUDO_FLT(26214, 15); /* 0.8 in Q15 */ L_fact = MAKE_PSEUDO_FLT(14145, 11); /* Log2(96) - Log2(0.8) in Q11 */ } - ELSE IF (sub(min, G_AVQ_MIN_DIV10_FX) == 0) + ELSE IF (EQ_16(min, G_AVQ_MIN_DIV10_FX)) { L_mini = MAKE_PSEUDO_FLT(20972, 18); /* 0.8*0.1 in Q18 */ L_fact = MAKE_PSEUDO_FLT(20949, 11); /* Log2(96) - Log2(0.8*0.1) in Q11 */ } - ELSE IF (sub(min, G_CODE_MIN_FX) == 0) + ELSE IF (EQ_16(min, G_CODE_MIN_FX)) { L_mini = MAKE_PSEUDO_FLT(20972, 20); /* 0.02 in Q20 */ L_fact = MAKE_PSEUDO_FLT(32628, 12); /* Log2(5) - Log2(0.02) in Q12 */ } - ELSE IF (sub(min, G_CODE_MIN_TC192_FX) == 0) + ELSE IF (EQ_16(min, G_CODE_MIN_TC192_FX)) { L_mini = MAKE_PSEUDO_FLT(19661, 15); /* 0.6 in Q15 */ L_fact = MAKE_PSEUDO_FLT(24963, 12); /* Log2(41) - Log2(0.6) in Q12 */ } - ELSE IF (sub(min, MIN_GLOB_GAIN_BWE_HR_FX) == 0) + ELSE IF (EQ_16(min, MIN_GLOB_GAIN_BWE_HR_FX)) { L_mini = MAKE_PSEUDO_FLT(24576, 13); /* 3.0 in Q13 */ L_fact = MAKE_PSEUDO_FLT(30232, 12); /* Log2(500) - Log2(3) in Q12 */ @@ -132,7 +130,7 @@ static Word16 TD_Postprocess( /* o : gain in Q15 */ FOR( i = 1; i < input_frame; i++ ) { temp = abs_s(hb_synth_fx[i]); - if( sub(temp, max_samp) > 0 ) + if( GT_16(temp, max_samp)) { pos = i; move16(); @@ -140,7 +138,7 @@ static Word16 TD_Postprocess( /* o : gain in Q15 */ max_samp = s_max(temp, max_samp); } - IF( sub(pos, 160) < 0 ) + IF( LT_16(pos, 160)) { L_Energy = Calc_Energy_Autoscaled(hb_synth_fx + sub(input_frame, 80), hb_synth_fx_exp, 80, &temp1 ); } @@ -182,7 +180,7 @@ static Word16 TD_Postprocess( /* o : gain in Q15 */ temp = round_fx(L_Energy); test(); - IF( sub(last_extl, SWB_BWE) == 0 || sub(last_extl, FB_BWE) == 0 ) + IF( EQ_16(last_extl, SWB_BWE)||EQ_16(last_extl,FB_BWE)) { FOR( i = ind1; i < input_frame; i++ ) { @@ -198,7 +196,7 @@ static Word16 TD_Postprocess( /* o : gain in Q15 */ move16(); } - IF ( sub(ind2, input_frame) != 0 ) + IF ( NE_16(ind2, input_frame)) { /* alpha_flt = (gain_flt > 0.5f) ? 1.0f : 0.5f;*/ /* beta_flt = (alpha_flt - gain_flt)/sub(input_frame, ind2);*/ @@ -299,7 +297,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB synthesis */ /* reset memories in case that last frame was a different technology */ test(); - IF( sub(st_fx->last_core_fx, HQ_CORE) == 0 || sub(st_fx->last_extl_fx, st_fx->extl_fx) != 0 ) + IF( EQ_16(st_fx->last_core_fx, HQ_CORE)||NE_16(st_fx->last_extl_fx,st_fx->extl_fx)) { set16_fx( st_fx->L_old_wtda_swb_fx, 0, L_FRAME48k ); st_fx->Q_old_wtda = 14; @@ -336,7 +334,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB synthesis */ /* Replication of the last spectrum, with an attenuation */ test(); test(); - IF( (sub(st_fx->clas_dec, VOICED_CLAS) == 0 || sub(st_fx->clas_dec, INACTIVE_CLAS) == 0) && sub(st_fx->nbLostCmpt, 3) <= 0 ) + IF( (EQ_16(st_fx->clas_dec, VOICED_CLAS)||EQ_16(st_fx->clas_dec,INACTIVE_CLAS))&&LE_16(st_fx->nbLostCmpt,3)) { alpha = 26214; /* 0.80 */ move16(); t_audio_exp = 0; @@ -363,7 +361,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB synthesis */ tmpS = (2*END_FREQ_BWE_FULL_FB/50)/NUM_TIME_SWITCHING_BLOCKS - NUM_TRANS_START_FREQ_COEF; move16(); /* set BWE spectrum length */ - if( sub(output_frame, L_FRAME32k) == 0 ) + if( EQ_16(output_frame, L_FRAME32k)) { tmpS = L_FRAME32k/NUM_TIME_SWITCHING_BLOCKS - NUM_TRANS_START_FREQ_COEF; move16(); @@ -410,7 +408,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB synthesis */ tmpS = 2*END_FREQ_BWE_FULL_FB/50 - NUM_NONTRANS_START_FREQ_COEF; move16(); /* set BWE spectrum length */ - if( sub(output_frame, L_FRAME32k) == 0 ) + if( EQ_16(output_frame, L_FRAME32k)) { tmpS = L_FRAME32k - NUM_NONTRANS_START_FREQ_COEF; move16(); @@ -483,7 +481,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB synthesis */ /* set width of noncoded (blind estimated) spectrum */ test(); - IF( sub(st_fx->extl_fx, SWB_BWE_HIGHRATE) == 0 || sub(output_frame, L_FRAME32k) == 0 ) + IF( EQ_16(st_fx->extl_fx, SWB_BWE_HIGHRATE)||EQ_16(output_frame,L_FRAME32k)) { width_noncoded = L_FRAME32k/NUM_TIME_SWITCHING_BLOCKS - NUM_TRANS_END_FREQ_COEF; move16(); @@ -527,7 +525,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB synthesis */ ELSE { ind1 = (Word16)get_next_indice_fx( st_fx, NBITS_ENVELOPE_BWE_HR_TR - 1 ); - if( sub(ind2, 8) >= 0 ) + if( GE_16(ind2, 8)) { ind1 = add(ind1, NUM_ENVLOPE_CODE_HR_TR2); } @@ -550,22 +548,22 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB synthesis */ en_noncoded = en_band[N_BANDS_TRANS_BWE_HR-1]; move16(); - IF( sub(st_fx->extl_fx, FB_BWE_HIGHRATE) == 0) + IF( EQ_16(st_fx->extl_fx, FB_BWE_HIGHRATE)) { ind1 = (Word16)get_next_indice_fx( st_fx, NBITS_HF_GAIN_BWE_HR ); nBits = sub(nBits, NBITS_HF_GAIN_BWE_HR); - IF (sub(ind1, 1) == 0) + IF (EQ_16(ind1, 1)) { en_noncoded = round_fx(L_mult0(en_noncoded, BWE_HR_TRANS_EN_LIMIT1_FX_Q16)); } - IF( sub(ind1, 2) == 0 ) + IF( EQ_16(ind1, 2)) { en_noncoded = round_fx(L_mult0(en_noncoded, BWE_HR_TRANS_EN_LIMIT2_FX_Q16)); } - IF( sub(ind1, 3) == 0 ) + IF( EQ_16(ind1, 3)) { en_noncoded = round_fx(L_mult0(en_noncoded, BWE_HR_TRANS_EN_LIMIT3_FX_Q16)); } @@ -658,7 +656,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB synthesis */ ptr32 = &t_audio32[temp2]; temp4 = i_mult2(NSV_OVERLAP, shr(WIDTH_BAND, 2)); /* overlap region */ - IF( sub(output_frame,L_FRAME48k) == 0 ) + IF( EQ_16(output_frame,L_FRAME48k)) { FOR( i=0; iextl_fx, FB_BWE_HIGHRATE) == 0 ) + IF( EQ_16(st_fx->extl_fx, FB_BWE_HIGHRATE)) { ind1 = (Word16) get_next_indice_fx( st_fx, NBITS_HF_GAIN_BWE_HR ); nBits = sub(nBits, NBITS_HF_GAIN_BWE_HR); - if (sub(ind1, 1) == 0) + if (EQ_16(ind1, 1)) { /* en_noncoded = BWE_HR_NONTRANS_EN_LIMIT1*(0.5*min_env) ==> 0.25*min_env */ en_noncoded = mult_r(min_env, BWE_HR_NONTRANS_EN_LIMIT2_FX_Q15/2); } - IF (sub(ind1, 2) == 0) + IF (EQ_16(ind1, 2)) { /* en_noncoded = 2.0*BWE_HR_NONTRANS_EN_LIMIT2*(0.5*min_env) ==> 1.2*min_env */ en_noncoded = round_fx(L_shl(L_mult(BWE_HR_NONTRANS_EN_LIMIT2_FX_Q14, min_env), 1)); } - if (sub(ind1, 3) == 0) + if (EQ_16(ind1, 3)) { /* en_noncoded = 2.0*BWE_HR_NONTRANS_EN_LIMIT3*(0.5*min_env) ==> 0.8*min_env */ en_noncoded = mult_r(BWE_HR_NONTRANS_EN_LIMIT3_FX_Q15, min_env); @@ -839,7 +837,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB synthesis */ *---------------------------------------------------------------------*/ test(); - IF( sub(nBits, 9 + NBITS_GLOB_GAIN_BWE_HR) >= 0 && sum16_fx( nq, Nsv) > 0 ) + IF( GE_16(nBits, 9 + NBITS_GLOB_GAIN_BWE_HR)&&sum16_fx(nq,Nsv)>0) { ind1 = (Word16) get_next_indice_fx( st_fx, NBITS_GLOB_GAIN_BWE_HR ); gain2_fx = Gain_Dequant_HR( ind1, MIN_GLOB_GAIN_BWE_HR_FX, NBITS_GLOB_GAIN_BWE_HR, &exp2 ); @@ -847,7 +845,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB synthesis */ exp2 = add(exp2, 4); /* calculate the number of subbands according to the rest bits */ - IF( sub(nBits, 396) > 0 ) + IF( GT_16(nBits, 396)) { Nsv2 = 33; move16(); @@ -863,7 +861,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB synthesis */ /* Nsv2 * 12 <= nBits (Nsv2 is not too high) AND */ /* nBits - Nsv2 * 12 < 12 (Nsv2 is the highest divisor) */ L_temp = L_msu0(L_deposit_l(nBits), 12, Nsv2); - if (L_sub(L_temp, 12L) >= 0) + if (GE_32(L_temp, 12L)) Nsv2 = add(Nsv2, 1); if (L_temp < 0) Nsv2 = sub(Nsv2, 1); @@ -887,7 +885,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB synthesis */ } Copy( nq, nq_tmp, Nsv ); - IF( sub(Nsv2, Nsv) > 0 ) + IF( GT_16(Nsv2, Nsv)) { /* Safety check, happens rarely */ set16_fx( nq_tmp + Nsv, 0, sub(Nsv2, Nsv) ); @@ -900,7 +898,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB synthesis */ FOR( i=0; i= 0 ) + IF( GE_16(i, Nsv2)) { BREAK; } @@ -947,7 +945,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB synthesis */ ptr16 = t_audio + NUM_NONTRANS_START_FREQ_COEF; - IF( sub(nBits_total, NBITS_THRESH_BWE_HR) > 0 ) + IF( GT_16(nBits_total, NBITS_THRESH_BWE_HR)) { Copy( t_audio_tmp, ptr16, NUM_NONTRANS_END_FREQ_COEF - NUM_NONTRANS_START_FREQ_COEF ); /* Update Maximum Written Location (from t_audio + NUM_NONTRANS_START_FREQ_COEF) */ @@ -968,7 +966,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB synthesis */ temp4 = s_max(temp4, NUM_NONTRANS_END_FREQ_COEF - NUM_NONTRANS_START_FREQ_COEF); /* reconstruct non-encoded subband */ - IF( sub(pos, 3) == 0 ) + IF( EQ_16(pos, 3)) { Copy( t_audio + NUM_NONTRANS_START_FREQ_COEF + 128, ptr16 + 200, 72 ); /* Update Maximum Written Location (from t_audio + NUM_NONTRANS_START_FREQ_COEF) */ @@ -1001,7 +999,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB synthesis */ } /* apply noise-fill */ - IF( sub(nBits, 200) < 0 ) + IF( LT_16(nBits, 200)) { swb_hr_noise_fill_fx( is_transient, NUM_NONTRANS_START_FREQ_COEF, NUM_NONTRANS_END_FREQ_COEF, round_fx(L_shl(L_tilt_wb, 3)), /* Q(24+3-16) -> Q11 */ @@ -1025,7 +1023,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB synthesis */ /* smoothing 12.6-12.8kHz */ test(); - IF( sub(pos, 3) == 0 && sub(nBits_total, 400) <= 0 ) + IF( EQ_16(pos, 3)&&LE_16(nBits_total,400)) { ptr16 = &t_audio[NUM_NONTRANS_START_FREQ_COEF + 200 - WIDTH_BAND]; L_temp = L_mac0(1L/* EPSILON */, *ptr16, *ptr16); @@ -1071,7 +1069,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB synthesis */ width_noncoded = 2*END_FREQ_BWE_FULL_FB/50 - NUM_NONTRANS_END_FREQ_COEF; move16(); /* st->extl == FB_BWE_HIGHRATE */ test(); - if( sub(st_fx->extl_fx, SWB_BWE_HIGHRATE) == 0 || sub(output_frame, L_FRAME32k) == 0 ) + if( EQ_16(st_fx->extl_fx, SWB_BWE_HIGHRATE)||EQ_16(output_frame,L_FRAME32k)) { width_noncoded = L_FRAME32k - NUM_NONTRANS_END_FREQ_COEF; move16(); @@ -1131,7 +1129,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB synthesis */ /* tmpF = max_env / min_env; */ temp = BASOP_Util_Divide1616_Scale( max_env, min_env, &temp2 ); test(); - IF( sub(st_fx->extl_fx,SWB_BWE_HIGHRATE) == 0 || sub(temp,shl(18022,sub(15-13,temp2))) < 0 ) /* 2.2 in Q13 == 18022 */ + IF( EQ_16(st_fx->extl_fx,SWB_BWE_HIGHRATE)||LT_16(temp,shl(18022,sub(15-13,temp2)))) /* 2.2 in Q13 == 18022 */ { /* (en_band_flt[3] - j*(en_band_flt[3]/WIDTH_BAND - en_noncoded_flt/WIDTH_BAND)) */ @@ -1160,7 +1158,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB synthesis */ { tmpS = L_FRAME32k - NUM_NONTRANS_END_FREQ_COEF; move16(); - if( sub(output_frame,L_FRAME48k) == 0 ) + if( EQ_16(output_frame,L_FRAME48k)) { tmpS = sub(width_noncoded,2*WIDTH_NONTRANS_FREQ_COEF); } @@ -1191,7 +1189,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB synthesis */ /* Overlap region */ ptr32 = &t_audio32[NUM_NONTRANS_START_FREQ_COEF]; - IF( sub(output_frame, L_FRAME48k) == 0 ) + IF( EQ_16(output_frame, L_FRAME48k)) { FOR( i=0; i 0 && temp3 == 0)) + IF (temp3 < 0 || (GT_32(L_temp, L_EnergyLT)&&temp3==0)) { IsTransient = 1; move16(); @@ -1368,7 +1366,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB synthesis */ test(); test(); test(); - IF( IsTransient != 0 && pos > 0 && L_sub(L_tilt_wb, 16777216L*3/*tilt_wb in Q24*/) < 0 && sub(pitch, 500*16/*Q4*/) > 0 ) + IF( IsTransient != 0 && pos > 0 && LT_32(L_tilt_wb, 16777216L*3/*tilt_wb in Q24*/)&>_16(pitch,500*16/*Q4*/)) { Nsv = i_mult2(pos, shr(output_frame, 2)); @@ -1389,7 +1387,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB synthesis */ exp1 = 14; move16(); - IF( sub(st_fx->last_extl_fx, st_fx->extl_fx) == 0 ) + IF( EQ_16(st_fx->last_extl_fx, st_fx->extl_fx)) { L_temp = Div_flt32_flt32( L_ener_saved, ener_saved_exp, st_fx->L_mem_EnergyLT_fx, st_fx->mem_EnergyLT_fx_exp, &temp2 ); temp3 = sub(temp2, 1); @@ -1458,9 +1456,9 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB synthesis */ /* post-processing in case of TD/FD switching */ test(); - IF( sub(st_fx->last_core_fx, HQ_CORE) == 0 || sub(st_fx->last_extl_fx, st_fx->extl_fx) != 0 ) + IF( EQ_16(st_fx->last_core_fx, HQ_CORE)||NE_16(st_fx->last_extl_fx,st_fx->extl_fx)) { - IF( L_sub(L_tilt_wb, 16777216L*3/*tilt_wb in Q24*/) < 0 ) + IF( LT_32(L_tilt_wb, 16777216L*3/*tilt_wb in Q24*/)) { temp = TD_Postprocess( hb_synth_fx, hb_synth_fx_exp, output_frame, st_fx->last_extl_fx ); @@ -1472,7 +1470,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB synthesis */ tmpS = L_FRAME32k - NUM_NONTRANS_START_FREQ_COEF; move16(); - if( sub(output_frame,L_FRAME48k) == 0 ) + if( EQ_16(output_frame,L_FRAME48k)) { tmpS = 2*END_FREQ_BWE_FULL_FB/50 - NUM_NONTRANS_START_FREQ_COEF; move16(); diff --git a/lib_dec/swb_bwe_dec_lr_fx.c b/lib_dec/swb_bwe_dec_lr_fx.c index 1efb533d3104ed125299f01816331741b077c0b6..5b800e450ee91a5a9d5ee36c8db5b6df4b735e75 100644 --- a/lib_dec/swb_bwe_dec_lr_fx.c +++ b/lib_dec/swb_bwe_dec_lr_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" @@ -8,9 +8,7 @@ #include "prot_fx.h" #include "rom_com_fx.h" -#include "stl.h" -#include "wmc_auto.h" - /* required for wmc_tool */ +#include "stl.h" /* required for wmc_tool */ /*-------------------------------------------------------------------* * DecodeSWBGenericParameters() @@ -32,7 +30,7 @@ static void DecodeSWBGenericParameters_fx( /* lag index for each subband (except last two) */ FOR (sb = 0; sb < nBands_search_fx; sb++) { - IF( sub(hq_swb_clas_fx, HQ_HARMONIC) ==0 ) + IF( EQ_16(hq_swb_clas_fx, HQ_HARMONIC)) { lagIndices_fx[sb] = get_next_indice_fx(st_fx, bits_lagIndices_mode0_Har_fx[sb]); move16(); @@ -131,14 +129,14 @@ static void DecodeSWBSubbands_fx( set16_fx(pul_res_fx,0,NB_SWB_SUBBANDS); - IF( sub(hqswb_clas_fx, HQ_HARMONIC) == 0 ) + IF( EQ_16(hqswb_clas_fx, HQ_HARMONIC)) { pos_max_hfe2 = har_est_fx( L_spectra, fLenLow_fx, &har_freq_est1, &har_freq_est2, &flag_dis, prev_frm_hfe2_fx, subband_search_offset_fx, sbWidth_fx, prev_stab_hfe2_fx ); noise_extr_corcod_fx(L_spectra, L_spectra_ni, sspectra_fx, sspectra_diff_fx, sspectra_ni_fx, fLenLow_fx, st_fx->prev_hqswb_clas_fx, &(st_fx->prev_ni_ratio_fx), &Qss); IF( flag_dis == 0 ) { test(); - if( sub(har_freq_est2, SWB_HAR_RAN1) != 0 || sub(har_freq_est2, *prev_frm_hfe2_fx) != 0 ) + if( NE_16(har_freq_est2, SWB_HAR_RAN1)||NE_16(har_freq_est2,*prev_frm_hfe2_fx)) { har_freq_est2 = add(har_freq_est2, lagIndices_fx[0]); } @@ -189,7 +187,7 @@ static void DecodeSWBSubbands_fx( } } } - ELSE IF ( sub(hqswb_clas_fx, HQ_NORMAL) == 0 ) + ELSE IF ( EQ_16(hqswb_clas_fx, HQ_NORMAL)) { ss_min_fx = spectrumsmooth_noiseton_fx( L_spectra, /*QsL,*/ L_spectra_ni, sspectra_fx, sspectra_diff_fx, sspectra_ni_fx, &Qss, fLenLow_fx, ni_seed_fx); @@ -197,7 +195,7 @@ static void DecodeSWBSubbands_fx( convert_lagIndices_pls2smp_fx( lagIndices_fx, nBands_fx, lagIndices_real_fx, sspectra_fx, sbWidth_fx, fLenLow_fx ); FOR (k = 0; k < nBands_fx; k++) { - if ( sub(p2a_flags_fx[BANDS_fx-NB_SWB_SUBBANDS+k], 1) == 0 ) + if ( EQ_16(p2a_flags_fx[BANDS_fx-NB_SWB_SUBBANDS+k], 1)) { lagIndices_real_fx[k] = 0; move16(); @@ -210,7 +208,7 @@ static void DecodeSWBSubbands_fx( FOR(k=0; ktotal_brate_fx, ACELP_24k40) < 0) + if(LT_32(st_fx->total_brate_fx, ACELP_24k40)) { max = s_max(max, max2); } @@ -106,7 +104,7 @@ void find_max_mem_dec( tempQ15 = abs_s( st_fx->tbe_premph_fx ); max = s_max(max, tempQ15); - IF( sub(st_fx->extl_fx, FB_TBE) == 0 ) + IF( EQ_16(st_fx->extl_fx, FB_TBE)) { FOR ( i = 0; i < LPC_SHB_ORDER; i++ ) { @@ -155,7 +153,7 @@ void find_max_mem_dec( max3 = s_max(max3, tempQ15); } /* find max in prev int_3_over_2_tbemem_dec_fx */ - IF( L_sub(st_fx->output_Fs_fx, 48000) == 0 ) + IF( EQ_32(st_fx->output_Fs_fx, 48000)) { FOR ( i = 0; i < INTERP_3_2_MEM_LEN; i++ ) { @@ -163,7 +161,7 @@ void find_max_mem_dec( max3 = s_max(max3, tempQ15); } } - IF( L_sub(st_fx->output_Fs_fx, 16000) == 0 ) + IF( EQ_32(st_fx->output_Fs_fx, 16000)) { FOR ( i = 0; i < (2*ALLPASSSECTIONS_STEEP+1); i++ ) { @@ -176,7 +174,7 @@ void find_max_mem_dec( if( max3 == 0 ) *n_mem3 = 15; Lmax3 = 0; - IF(sub(st_fx->L_frame_fx, L_FRAME) == 0) + IF(EQ_16(st_fx->L_frame_fx, L_FRAME)) { /* find max in prev genSHBsynth_Hilbert_Mem_fx */ FOR ( i = 0; i < HILBERT_MEM_SIZE; i++ ) @@ -220,7 +218,7 @@ void rescale_genSHB_mem_dec( } /* -- Apply memory scaling for 13.2 and 16.4k bps using sf ----*/ - IF(L_sub(st_fx->total_brate_fx, ACELP_24k40) < 0) + IF(LT_32(st_fx->total_brate_fx, ACELP_24k40)) { FOR ( i = 0; i < LPC_SHB_ORDER; i++ ) { @@ -235,7 +233,7 @@ void rescale_genSHB_mem_dec( } } - IF( sub(st_fx->extl_fx, FB_TBE) == 0 ) + IF( EQ_16(st_fx->extl_fx, FB_TBE)) { } st_fx->mem_csfilt_fx[0] = L_shl( st_fx->mem_csfilt_fx[0], sf ); @@ -446,7 +444,7 @@ void ResetSHBbuffer_Dec_fx( Decoder_State_fx* st_fx /* i/o: SHB encoder structur set16_fx( st_fx->state_syn_shbexc_fx, 0, L_SHB_LAHEAD ); set16_fx( st_fx->state_lpc_syn_fx, 0, LPC_SHB_ORDER ); - IF( sub(st_fx->extl_fx, FB_TBE) == 0 ) + IF( EQ_16(st_fx->extl_fx, FB_TBE)) { set16_fx( st_fx->fb_state_lpc_syn_fx, 0, LPC_SHB_ORDER ); st_fx->fb_tbe_demph_fx = 0; @@ -578,9 +576,9 @@ void wb_tbe_dec_fx( IF( !st_fx->bfi_fx ) { - IF(sub(st_fx->use_partial_copy,1)==0) + IF(EQ_16(st_fx->use_partial_copy,1)) { - IF(sub(st_fx->last_extl_fx, WB_TBE) != 0) + IF(NE_16(st_fx->last_extl_fx, WB_TBE)) { st_fx->GainFrame_prevfrm_fx = 0; st_fx->lsp_prevfrm_fx[0] = 3277/*0.1f Q15*/; @@ -593,14 +591,14 @@ void wb_tbe_dec_fx( Copy( st_fx->lsp_prevfrm_fx, lsf_wb, LPC_SHB_ORDER_LBR_WB ); set16_fx( GainShape, RECIP_ROOT_EIGHT_FX, NUM_SHB_SUBFR/2 ); - IF( sub(st_fx->rf_frame_type,RF_NELP) == 0 ) + IF( EQ_16(st_fx->rf_frame_type,RF_NELP)) { /* Frame gain */ st_fx->rf_indx_tbeGainFr = s_and(st_fx->rf_indx_tbeGainFr, 0xF); /* only four LSBs are valid */ Copy32( SHBCB_FrameGain16_fx + st_fx->rf_indx_tbeGainFr, &GainFrame, 1 ); - IF( sub(st_fx->core_fx,ACELP_CORE) == 0 && sub(st_fx->last_core_fx,ACELP_CORE) == 0 - && !st_fx->prev_use_partial_copy && sub(st_fx->prev_coder_type_fx,UNVOICED) == 0 - && L_sub(GainFrame,st_fx->GainFrame_prevfrm_fx) != 0 && sub(st_fx->last_extl_fx, WB_TBE) == 0 ) + IF( EQ_16(st_fx->core_fx,ACELP_CORE)&&EQ_16(st_fx->last_core_fx,ACELP_CORE) + && !st_fx->prev_use_partial_copy && EQ_16(st_fx->prev_coder_type_fx,UNVOICED) + && NE_32(GainFrame,st_fx->GainFrame_prevfrm_fx) && EQ_16(st_fx->last_extl_fx, WB_TBE) ) { /*GainFrame = 0.2f*GainFrame + 0.8f*st_fx->GainFrame_prevfrm_fx;*/ GainFrame = L_add(Mult_32_16(st_fx->GainFrame_prevfrm_fx, 26214), Mult_32_16(GainFrame, 6553)); @@ -615,39 +613,39 @@ void wb_tbe_dec_fx( { case 0: GainFrame = 131072; /* 0.5f in Q18 */ - IF(L_sub(st_fx->GainFrame_prevfrm_fx, 327680l/*1.25 Q18*/) <= 0) temp = 26214/*0.8 Q15*/; + IF(LE_32(st_fx->GainFrame_prevfrm_fx, 327680l/*1.25 Q18*/)) temp = 26214/*0.8 Q15*/; move16(); BREAK; case 1: GainFrame = 524288; /* 2.0f in Q18 */ - IF(L_sub(st_fx->GainFrame_prevfrm_fx, 327680l/*1.25 Q18*/) > 0 && L_sub(st_fx->GainFrame_prevfrm_fx, 786432l/*3 Q18*/) <= 0) temp = 26214/*0.8 Q15*/; + IF(GT_32(st_fx->GainFrame_prevfrm_fx, 327680l/*1.25 Q18*/)&&LE_32(st_fx->GainFrame_prevfrm_fx,786432l/*3 Q18*/)) temp = 26214/*0.8 Q15*/; move16(); test(); BREAK; case 2: GainFrame = 1048576;/* 4.0f in Q18 */ - IF(L_sub(st_fx->GainFrame_prevfrm_fx, 786432l/*3 Q18*/) > 0 && L_sub(st_fx->GainFrame_prevfrm_fx, 1572864l/*6 Q18*/) <= 0) temp = 26214/*0.8 Q15*/; + IF(GT_32(st_fx->GainFrame_prevfrm_fx, 786432l/*3 Q18*/)&&LE_32(st_fx->GainFrame_prevfrm_fx,1572864l/*6 Q18*/)) temp = 26214/*0.8 Q15*/; move16(); test(); BREAK; case 3: GainFrame = 2097152;/* 8.0f in Q18 */ - IF(L_sub(st_fx->GainFrame_prevfrm_fx, 1572864l/*6 Q18*/) > 0 && L_sub(st_fx->GainFrame_prevfrm_fx, 4194304l/*16 Q18*/) <= 0) temp = 26214/*0.8 Q15*/; + IF(GT_32(st_fx->GainFrame_prevfrm_fx, 1572864l/*6 Q18*/)&&LE_32(st_fx->GainFrame_prevfrm_fx,4194304l/*16 Q18*/)) temp = 26214/*0.8 Q15*/; move16(); test(); BREAK; default: fprintf(stderr, "RF SWB-TBE gain bits not supported."); } - IF(sub(st_fx->last_extl_fx, WB_TBE) == 0) + IF(EQ_16(st_fx->last_extl_fx, WB_TBE)) { GainFrame = L_add(Mult_32_16(st_fx->GainFrame_prevfrm_fx, temp), Mult_32_16(GainFrame, sub(32767,temp))); } - IF(sub(st_fx->core_fx,ACELP_CORE) == 0 && sub(st_fx->last_core_fx,ACELP_CORE) == 0) + IF(EQ_16(st_fx->core_fx,ACELP_CORE)&&EQ_16(st_fx->last_core_fx,ACELP_CORE)) { - IF(!st_fx->prev_use_partial_copy && sub(st_fx->last_coder_type_fx, VOICED) == 0 && sub(st_fx->rf_frame_type,RF_GENPRED) == 0 - && sub(st_fx->prev_tilt_code_dec_fx,1497) < 0 && sub(st_fx->prev_tilt_code_dec_fx,200) > 0 ) + IF(!st_fx->prev_use_partial_copy && EQ_16(st_fx->last_coder_type_fx, VOICED)&&EQ_16(st_fx->rf_frame_type,RF_GENPRED) + && LT_16(st_fx->prev_tilt_code_dec_fx,1497) && GT_16(st_fx->prev_tilt_code_dec_fx,200) ) { GainFrame = Mult_32_16(GainFrame,9830); } @@ -662,7 +660,7 @@ void wb_tbe_dec_fx( } ELSE { - IF( L_sub( st_fx->extl_brate_fx, WB_TBE_0k35) == 0 ) + IF( EQ_32( st_fx->extl_brate_fx, WB_TBE_0k35)) { Copy( st_fx->lsp_prevfrm_fx, lsf_wb, LPC_SHB_ORDER_LBR_WB ); } @@ -675,7 +673,7 @@ void wb_tbe_dec_fx( st_fx->GainAttn_fx = mult_r( st_fx->GainAttn_fx, 27853 ); move16(); - IF(sub(st_fx->codec_mode, MODE1) == 0) + IF(EQ_16(st_fx->codec_mode, MODE1)) { GainFrame = Mult_32_16( st_fx->GainFrame_prevfrm_fx, st_fx->GainAttn_fx ); /*Q18*/ } @@ -752,7 +750,7 @@ void wb_tbe_dec_fx( } test(); - if( uv_flag && sub( Q_bwe_exc, 20 ) > 0) + if( uv_flag && GT_16( Q_bwe_exc, 20 )) { Q_bwe_exc = 20; move16(); /* restrict this to 21 due to the Q factor requireemnt of the random number generator (keep 1 bit headroom) */ @@ -792,7 +790,7 @@ void wb_tbe_dec_fx( L_SHB_LAHEAD / 4] ); /* Q(2*Q_bwe_exc_ext) */ } - if( sub( voice_factors[0], 24576 ) > 0 ) + if( GT_16( voice_factors[0], 24576 )) { curr_pow = L_shr( curr_pow, 2 ); /* Q(2*Q_bwe_exc_ext) */ } @@ -855,7 +853,7 @@ void wb_tbe_dec_fx( } curr_frame_pow_exp = add( n, n ); - IF ( sub(st_fx->prev_frame_pow_exp, curr_frame_pow_exp) > 0 ) + IF ( GT_16(st_fx->prev_frame_pow_exp, curr_frame_pow_exp)) { curr_frame_pow = L_shr( curr_frame_pow, sub( st_fx->prev_frame_pow_exp, curr_frame_pow_exp ) ); curr_frame_pow_exp = st_fx->prev_frame_pow_exp; @@ -868,7 +866,7 @@ void wb_tbe_dec_fx( test(); IF( !st_fx->bfi_fx && st_fx->prev_bfi_fx ) { - IF( L_sub( L_shr( curr_frame_pow, 1 ), st_fx->prev_wb_bwe_frame_pow_fx ) > 0 ) + IF( GT_32( L_shr( curr_frame_pow, 1 ), st_fx->prev_wb_bwe_frame_pow_fx )) { L_tmp = root_a_over_b_fx( st_fx->prev_wb_bwe_frame_pow_fx, 22, curr_frame_pow, 22, &exp ); scale = round_fx( L_shl( L_tmp, exp ) ); /*Q15*/ @@ -894,7 +892,7 @@ void wb_tbe_dec_fx( } IF( temp > 0 ) { - IF( sub( scale, temp ) < 0 ) + IF( LT_16( scale, temp )) { scale = div_s( scale, temp ); } @@ -950,14 +948,14 @@ void wb_tbe_dec_fx( max = abs_s( st_fx->state_lsyn_filt_dwn_shb_fx[i] ); } - IF( L_sub(st_fx->output_Fs_fx, 32000) == 0 ) + IF( EQ_32(st_fx->output_Fs_fx, 32000)) { FOR ( i = 0; i < 2*ALLPASSSECTIONS_STEEP; i++ ) { max = s_max(max, abs_s( st_fx->state_32and48k_WB_upsample_fx[i] )); } } - IF( L_sub(st_fx->output_Fs_fx, 48000) == 0 ) + IF( EQ_32(st_fx->output_Fs_fx, 48000)) { FOR ( i = 0; i < INTERP_3_1_MEM_LEN; i++ ) { @@ -1040,13 +1038,13 @@ void wb_tbe_dec_fx( } - IF( L_sub(st_fx->output_Fs_fx, 32000) == 0 ) /* 32kHz sampling rate, but only WB output - interpolate */ + IF( EQ_32(st_fx->output_Fs_fx, 32000)) /* 32kHz sampling rate, but only WB output - interpolate */ { Scale_sig(st_fx->state_32and48k_WB_upsample_fx, 2*ALLPASSSECTIONS_STEEP, sub( Qx, st_fx->prev_Qx )); Interpolate_allpass_steep_fx( synth, st_fx->state_32and48k_WB_upsample_fx, L_FRAME16k, upsampled_synth ); Copy( upsampled_synth, synth, L_FRAME32k ); } - ELSE IF( L_sub(st_fx->output_Fs_fx, 48000) == 0 ) + ELSE IF( EQ_32(st_fx->output_Fs_fx, 48000)) { Scale_sig(st_fx->mem_resamp_HB_fx, INTERP_3_1_MEM_LEN, sub( Qx, st_fx->prev_Qx )); interpolate_3_over_1_allpass_fx( synth, L_FRAME16k, upsampled_synth, st_fx->mem_resamp_HB_fx, allpass_poles_3_ov_2 ); @@ -1075,7 +1073,7 @@ void wb_tbe_dec_fx( } /* Update previous frame parameters for FEC */ - IF( L_sub(st_fx->extl_brate_fx, WB_TBE_0k35) == 0 ) + IF( EQ_32( st_fx->extl_brate_fx, WB_TBE_0k35 ) ) { Copy( lsf_wb, st_fx->lsp_prevfrm_fx, LPC_SHB_ORDER_LBR_WB ); } @@ -1218,7 +1216,7 @@ void swb_tbe_dec_fx( /* i: old_syn_12k8_16k in st_fx->Q_syn2 */ /* o: tilt_swb_fec in Q11 */ test(); - IF( st_fx->bfi_fx && sub(st_fx->clas_dec,UNVOICED_CLAS) != 0 ) + IF( st_fx->bfi_fx && NE_16(st_fx->clas_dec,UNVOICED_CLAS)) { tilt_swb_fec = st_fx->tilt_swb_fec_fx; move16(); @@ -1227,7 +1225,7 @@ void swb_tbe_dec_fx( /* WB/SWB bandwidth switching */ test(); test(); - IF( ( sub(st_fx->tilt_wb_fx, 10240) > 0 && sub(st_fx->clas_dec, UNVOICED_CLAS) == 0 ) || sub(st_fx->tilt_wb_fx, 20480) > 0 ) + IF( ( GT_16(st_fx->tilt_wb_fx, 10240)&&EQ_16(st_fx->clas_dec,UNVOICED_CLAS))||GT_16(st_fx->tilt_wb_fx,20480)) { test(); test(); @@ -1237,12 +1235,12 @@ void swb_tbe_dec_fx( test(); test(); IF( (st_fx->prev_fractive_fx == 0 && - (L_sub( st_fx->prev_enerLH_fx, L_shl( st_fx->enerLH_fx, 1 ) ) < 0 && L_sub( st_fx->prev_enerLH_fx, L_shr( st_fx->enerLH_fx, 1 ) ) > 0 - && L_sub( st_fx->prev_enerLL_fx, L_shl( st_fx->enerLL_fx, 1 ) ) < 0 && L_sub( st_fx->prev_enerLL_fx, L_shr( st_fx->enerLL_fx, 1 ) ) > 0)) - || (sub(st_fx->prev_fractive_fx,1) == 0 && - L_sub(L_shr(st_fx->prev_enerLH_fx,2), Mult_32_16(st_fx->enerLH_fx,24576)) > 0 ) /* 24576 in Q13*/ - || (L_sub(L_shr(st_fx->enerLL_fx,1), Mult_32_16(st_fx->enerLH_fx, 24576)) > 0 && /*24576 = 1.5 in Q14*/ - sub(st_fx->tilt_wb_fx, 20480) < 0 )/* 20480 = 10 in Q11*/ + (LT_32( st_fx->prev_enerLH_fx, L_shl( st_fx->enerLH_fx, 1 ) ) && GT_32( st_fx->prev_enerLH_fx, L_shr( st_fx->enerLH_fx, 1 ) ) + && LT_32( st_fx->prev_enerLL_fx, L_shl( st_fx->enerLL_fx, 1 ) ) && GT_32( st_fx->prev_enerLL_fx, L_shr( st_fx->enerLL_fx, 1 ) ) )) + || (EQ_16(st_fx->prev_fractive_fx,1) && + GT_32(L_shr(st_fx->prev_enerLH_fx,2), Mult_32_16(st_fx->enerLH_fx,24576)) ) /* 24576 in Q13*/ + || (GT_32(L_shr(st_fx->enerLL_fx,1), Mult_32_16(st_fx->enerLH_fx, 24576)) && /*24576 = 1.5 in Q14*/ + LT_16(st_fx->tilt_wb_fx, 20480) )/* 20480 = 10 in Q11*/ ) { is_fractive = 0; @@ -1260,7 +1258,7 @@ void swb_tbe_dec_fx( { f_fx = 1489; /*Q15*/ inc_fx = 1489; /*Q15*/ - IF(sub(is_fractive, 1) == 0) + IF(EQ_16(is_fractive, 1)) { Copy(lsf_tab_fx, st_fx->lsp_prevfrm_fx, LPC_SHB_ORDER); } @@ -1280,7 +1278,7 @@ void swb_tbe_dec_fx( test(); test(); test(); - IF( (sub(st_fx->last_extl_fx, SWB_TBE) != 0 && sub(st_fx->last_extl_fx, FB_TBE) != 0 && + IF( (NE_16(st_fx->last_extl_fx, SWB_TBE)&&NE_16(st_fx->last_extl_fx,FB_TBE)&& !(L_sub(L_shr(st_fx->prev_enerLH_fx, 1), st_fx->enerLH_fx) < 0 &&L_sub(st_fx->prev_enerLH_fx, L_shr(st_fx->enerLH_fx,1)>0))) || sub(st_fx->last_core_fx, ACELP_CORE) != 0 || (sub(st_fx->last_core_fx, ACELP_CORE) == 0 && L_sub(L_abs(L_sub(st_fx->last_core_brate_fx, st_fx->core_brate_fx)), 3600) > 0) @@ -1290,7 +1288,7 @@ void swb_tbe_dec_fx( } ELSE { - if(sub(st_fx->prev_GainShape_fx, 11587) > 0) + if(GT_16(st_fx->prev_GainShape_fx, 11587)) { st_fx->prev_GainShape_fx = 11587; move16(); @@ -1304,7 +1302,7 @@ void swb_tbe_dec_fx( ELSE /* No bandwidth switching */ { test(); - IF( sub(st_fx->last_extl_fx, SWB_TBE) != 0 && sub(st_fx->last_extl_fx, FB_TBE) != 0 ) + IF( NE_16(st_fx->last_extl_fx, SWB_TBE)&&NE_16(st_fx->last_extl_fx,FB_TBE)) { f_fx = 1489; /*Q15*/ move16(); inc_fx = 1489; /*Q15*/ move16(); @@ -1320,7 +1318,7 @@ void swb_tbe_dec_fx( { IF(st_fx->use_partial_copy) { - IF(sub(st_fx->last_extl_fx, SWB_TBE) != 0) + IF(NE_16(st_fx->last_extl_fx, SWB_TBE)) { st_fx->GainFrame_prevfrm_fx = 0; move16(); @@ -1338,7 +1336,7 @@ void swb_tbe_dec_fx( Copy( st_fx->lsp_prevfrm_fx, lsf_shb, LPC_SHB_ORDER ); set16_fx( GainShape, RECIP_ROOT_EIGHT_FX, NUM_SHB_SUBFR ); - IF( sub(st_fx->rf_frame_type,RF_NELP) == 0 ) + IF( EQ_16(st_fx->rf_frame_type,RF_NELP)) { /* Frame gain */ GainFrame = L_mac( SHB_GAIN_QLOW_FX, st_fx->rf_indx_tbeGainFr, SHB_GAIN_QDELTA_FX ); @@ -1348,9 +1346,9 @@ void swb_tbe_dec_fx( frac = L_Extract_lc( L_tmp, &exp ); L_tmp = Pow2( 30, frac ); GainFrame = L_shl( L_tmp, sub( exp, 12 ) ); /*Q18*/ - IF( sub(st_fx->core_fx,ACELP_CORE) == 0 && sub(st_fx->last_core_fx,ACELP_CORE) == 0 - && !st_fx->prev_use_partial_copy && sub(st_fx->prev_coder_type_fx,UNVOICED) == 0 - && L_sub(GainFrame,st_fx->GainFrame_prevfrm_fx) != 0 && sub(st_fx->next_coder_type,GENERIC) != 0 && sub(st_fx->last_extl_fx, SWB_TBE) == 0) + IF( EQ_16(st_fx->core_fx,ACELP_CORE)&&EQ_16(st_fx->last_core_fx,ACELP_CORE) + && !st_fx->prev_use_partial_copy && EQ_16(st_fx->prev_coder_type_fx,UNVOICED) + && NE_32(GainFrame,st_fx->GainFrame_prevfrm_fx) && NE_16(st_fx->next_coder_type,GENERIC) && EQ_16(st_fx->last_extl_fx, SWB_TBE) ) { /*GainFrame = 0.2f*GainFrame + 0.8f*st_fx->GainFrame_prevfrm_fx;*/ GainFrame = L_add(Mult_32_16(st_fx->GainFrame_prevfrm_fx, 26214), Mult_32_16(GainFrame, 6553)); @@ -1365,37 +1363,37 @@ void swb_tbe_dec_fx( { case 0: GainFrame = 131072; /* 0.5f in Q18 */ - IF(L_sub(st_fx->GainFrame_prevfrm_fx, 327680l/*1.25 Q18*/) <= 0) temp = 26214/*0.8 Q15*/; + IF(LE_32(st_fx->GainFrame_prevfrm_fx, 327680l/*1.25 Q18*/)) temp = 26214/*0.8 Q15*/; move16(); BREAK; case 1: GainFrame = 524288; /* 2.0f in Q18 */ - IF(L_sub(st_fx->GainFrame_prevfrm_fx, 327680l/*1.25 Q18*/) > 0 && L_sub(st_fx->GainFrame_prevfrm_fx, 786432l/*3 Q18*/) <= 0) temp = 26214/*0.8 Q15*/; + IF(GT_32(st_fx->GainFrame_prevfrm_fx, 327680l/*1.25 Q18*/)&&LE_32(st_fx->GainFrame_prevfrm_fx,786432l/*3 Q18*/)) temp = 26214/*0.8 Q15*/; move16(); test(); BREAK; case 2: GainFrame = 1048576;/* 4.0f in Q18 */ - IF(L_sub(st_fx->GainFrame_prevfrm_fx, 786432l/*3 Q18*/) > 0 && L_sub(st_fx->GainFrame_prevfrm_fx, 1572864l/*6 Q18*/) <= 0) temp = 26214/*0.8 Q15*/; + IF(GT_32(st_fx->GainFrame_prevfrm_fx, 786432l/*3 Q18*/)&&LE_32(st_fx->GainFrame_prevfrm_fx,1572864l/*6 Q18*/)) temp = 26214/*0.8 Q15*/; move16(); test(); BREAK; case 3: GainFrame = 2097152;/* 8.0f in Q18 */ - IF(L_sub(st_fx->GainFrame_prevfrm_fx, 1572864l/*6 Q18*/) > 0 && L_sub(st_fx->GainFrame_prevfrm_fx, 4194304l/*16 Q18*/) <= 0) temp = 26214/*0.8 Q15*/; + IF(GT_32(st_fx->GainFrame_prevfrm_fx, 1572864l/*6 Q18*/)&&LE_32(st_fx->GainFrame_prevfrm_fx,4194304l/*16Q18*/)) temp = 26214/*0.8 Q15*/; move16(); test(); BREAK; default: fprintf(stderr, "RF SWB-TBE gain bits not supported."); } - IF(sub(st_fx->last_extl_fx, SWB_TBE) == 0) + IF(EQ_16(st_fx->last_extl_fx, SWB_TBE)) { GainFrame = L_add(Mult_32_16(st_fx->GainFrame_prevfrm_fx, temp), Mult_32_16(GainFrame, sub(32767,temp))); } - IF(sub(st_fx->core_fx,ACELP_CORE) == 0 && sub(st_fx->last_core_fx,ACELP_CORE) == 0) + IF(EQ_16(st_fx->core_fx,ACELP_CORE)&&EQ_16(st_fx->last_core_fx,ACELP_CORE)) { - IF(!st_fx->prev_use_partial_copy && sub(st_fx->last_coder_type_fx, VOICED) == 0 && sub(st_fx->rf_frame_type,RF_GENPRED) == 0 && L_sub(GainFrame, 2097152) > 0 && L_sub(GainFrame, 3059606) < 0 ) + IF(!st_fx->prev_use_partial_copy && EQ_16(st_fx->last_coder_type_fx, VOICED)&&EQ_16(st_fx->rf_frame_type,RF_GENPRED)&>_32(GainFrame,2097152)&<_32(GainFrame,3059606)) { GainFrame = Mult_32_16(GainFrame,9830); } @@ -1421,7 +1419,7 @@ void swb_tbe_dec_fx( Copy( st_fx->lsp_prevfrm_fx, lsf_shb, LPC_SHB_ORDER ); /* Gain shape concealment */ - IF( sub(st_fx->codec_mode, MODE1) == 0 ) + IF( EQ_16(st_fx->codec_mode, MODE1)) { /* Gradient based GS estimation */ gradientGainShape(st_fx, GainShape, &GainFrame); @@ -1438,13 +1436,13 @@ void swb_tbe_dec_fx( move16(); } } - IF( sub( tilt_swb_fec, 8<<11 ) > 0 ) /* tilt_swb_fec in Q11 */ + IF( GT_16( tilt_swb_fec, 8<<11 )) /* tilt_swb_fec in Q11 */ { - IF ( sub(st_fx->nbLostCmpt, 1) == 0 ) + IF ( EQ_16(st_fx->nbLostCmpt, 1)) { GainFrame = Mult_32_16(st_fx->GainFrame_prevfrm_fx, 19661/*0.6f Q15*/); } - ELSE IF( sub(st_fx->nbLostCmpt, 2) == 0 ) + ELSE IF( EQ_16(st_fx->nbLostCmpt, 2)) { GainFrame = Mult_32_16(st_fx->GainFrame_prevfrm_fx, 11469/*0.35f Q15*/); } @@ -1463,9 +1461,9 @@ void swb_tbe_dec_fx( /* FER concealment for 24.4kbps and 32kbps */ test(); - IF(L_sub(st_fx->total_brate_fx,ACELP_24k40) == 0 || L_sub(st_fx->total_brate_fx, ACELP_32k) == 0) + IF(EQ_32(st_fx->total_brate_fx,ACELP_24k40)||EQ_32(st_fx->total_brate_fx,ACELP_32k)) { - IF(sub(st_fx->codec_mode, MODE1) == 0) + IF(EQ_16(st_fx->codec_mode, MODE1)) { /*scale = st->prev1_shb_ener_sf/root_a(st->prev2_shb_ener_sf * st->prev3_shb_ener_sf); */ L_tmp = L_mult(extract_l(st_fx->prev2_shb_ener_sf_fx), extract_l(st_fx->prev3_shb_ener_sf_fx)); /*Q1*/ @@ -1488,13 +1486,13 @@ void swb_tbe_dec_fx( scale = mult_r(st_fx->prev_res_shb_gshape_fx, tmp); /* Q14 */ test(); - IF( L_sub( L_shr(st_fx->prev2_shb_ener_sf_fx, 1), st_fx->prev1_shb_ener_sf_fx ) > 0 || - L_sub( L_shr(st_fx->prev3_shb_ener_sf_fx, 1), st_fx->prev2_shb_ener_sf_fx ) > 0 ) + IF( GT_32( L_shr(st_fx->prev2_shb_ener_sf_fx, 1), st_fx->prev1_shb_ener_sf_fx )|| + GT_32( L_shr(st_fx->prev3_shb_ener_sf_fx, 1), st_fx->prev2_shb_ener_sf_fx ) ) { /* shb_ener_sf_32 = 0.5f * scale * st_fx->prev1_shb_ener_sf_fx; */ shb_ener_sf_32 = Mult_32_16( st_fx->prev1_shb_ener_sf_fx, scale ); - if( sub(st_fx->nbLostCmpt, 1) > 0) + if( GT_16(st_fx->nbLostCmpt, 1)) { /* shb_ener_sf_32 *= 0.5f; */ shb_ener_sf_32 = L_shr(shb_ener_sf_32, 1); @@ -1510,8 +1508,8 @@ void swb_tbe_dec_fx( ELSE { test(); - IF( L_sub( L_shr(st_fx->prev2_shb_ener_sf_fx, 1), st_fx->prev1_shb_ener_sf_fx ) > 0 || - L_sub( L_shr(st_fx->prev3_shb_ener_sf_fx, 1), st_fx->prev2_shb_ener_sf_fx ) > 0 ) + IF( GT_32( L_shr(st_fx->prev2_shb_ener_sf_fx, 1), st_fx->prev1_shb_ener_sf_fx )|| + GT_32( L_shr(st_fx->prev3_shb_ener_sf_fx, 1), st_fx->prev2_shb_ener_sf_fx ) ) { /* shb_ener_sf_32 = 0.5f * st->cummulative_damping * st_fx->prev1_shb_ener_sf_fx; */ shb_ener_sf_32 = L_shr( Mult_32_16( st_fx->prev1_shb_ener_sf_fx, st_fx->cummulative_damping ), 1 ); @@ -1526,7 +1524,7 @@ void swb_tbe_dec_fx( shb_ener_sf_32 = L_max( shb_ener_sf_32, 1l/*1.0f Q0*/ ); mixFactors = st_fx->prev_mixFactors_fx; - IF(sub(st_fx->codec_mode, MODE1) == 0) + IF(EQ_16(st_fx->codec_mode, MODE1)) { set16_fx( shb_res_gshape, 3277/*0.2f Q14*/, 5 ); /* Q14 */ } @@ -1539,7 +1537,7 @@ void swb_tbe_dec_fx( /* get the gainshape delay */ Copy( &st_fx->GainShape_Delay[4], &st_fx->GainShape_Delay[0], NUM_SHB_SUBFR / 4 ); - IF ( (st_fx->rf_flag != 0) || L_sub(st_fx->total_brate_fx, ACELP_9k60) == 0 ) + IF ( (st_fx->rf_flag != 0) || EQ_32(st_fx->total_brate_fx, ACELP_9k60)) { FOR( i = 0; i < NUM_SHB_SUBFR / 4; i++ ) { @@ -1566,7 +1564,7 @@ void swb_tbe_dec_fx( Copy( voice_factors, vf_modified, NB_SUBFR16k ); test(); - IF( sub(coder_type, VOICED) == 0 || sub(mean_vf, 13107/*0.4f Q15*/ ) > 0 ) + IF( EQ_16(coder_type, VOICED)||GT_16(mean_vf,13107/*0.4f Q15*/ )) { FOR( i = 1; i < NB_SUBFR; i++ ) { @@ -1574,7 +1572,7 @@ void swb_tbe_dec_fx( vf_modified[i] = mac_r(L_tmp, voice_factors[i-1], 6554/*0.2f Q15*/); move16(); } - IF( sub(st_fx->L_frame_fx, L_FRAME) != 0 ) + IF( NE_16(st_fx->L_frame_fx, L_FRAME)) { L_tmp = L_mult(voice_factors[4], 26214/*0.8f Q15*/); vf_modified[4] = mac_r(L_tmp, voice_factors[3], 6554/*0.2f Q15*/); @@ -1586,7 +1584,7 @@ void swb_tbe_dec_fx( E_LPC_lsf_lsp_conversion(lsf_shb, lsp_shb_2, LPC_SHB_ORDER); test(); - IF( sub(st_fx->last_extl_fx, SWB_TBE) == 0 || sub(st_fx->last_extl_fx, FB_TBE) == 0) + IF( EQ_16(st_fx->last_extl_fx, SWB_TBE)||EQ_16(st_fx->last_extl_fx,FB_TBE)) { /* SHB LSP values from prev. frame for interpolation */ Copy(st_fx->swb_lsp_prev_interp_fx, lsp_shb_1, LPC_SHB_ORDER); @@ -1620,7 +1618,7 @@ void swb_tbe_dec_fx( tilt_para = add(sub(tmp1,tmp2),1335); /*Q10*/ test(); - IF(sub(st_fx->last_extl_fx,SWB_TBE) != 0 && sub(st_fx->last_extl_fx,FB_TBE) != 0) + IF(NE_16(st_fx->last_extl_fx,SWB_TBE)&&NE_16(st_fx->last_extl_fx,FB_TBE)) { FOR( i=1; itotal_brate_fx,ACELP_16k40) <= 0 ) + IF( LE_32(st_fx->total_brate_fx,ACELP_16k40)) { test(); test(); test(); test(); test(); - IF(!(sub(st_fx->prev_tilt_para_fx,5120) > 0 && (sub(coder_type,TRANSITION) == 0 || sub(tilt_para,1024) < 0)) && - !(((sub(st_fx->prev_tilt_para_fx,3072) < 0 && sub(st_fx->prev_coder_type_fx,VOICED) >= 0)) && sub(tilt_para,5120) > 0)) + IF(!(GT_16(st_fx->prev_tilt_para_fx,5120)&&(EQ_16(coder_type,TRANSITION)||LT_16(tilt_para,1024)))&& + !(((LT_16(st_fx->prev_tilt_para_fx,3072) && GE_16(st_fx->prev_coder_type_fx,VOICED))) && GT_16(tilt_para,5120) )) { FOR( i = 1; i < LPC_SHB_ORDER-1; i++ ) { - IF(sub(lsf_diff[i],st_fx->prev_lsf_diff_fx[i-1]) < 0) + IF(LT_16(lsf_diff[i],st_fx->prev_lsf_diff_fx[i-1])) { tmp = mult(26214,lsf_diff[i]); @@ -1708,7 +1706,7 @@ void swb_tbe_dec_fx( } test(); - IF ( L_sub(st_fx->total_brate_fx, ACELP_24k40 ) == 0 || L_sub( st_fx->total_brate_fx, ACELP_32k) == 0 ) + IF ( EQ_32(st_fx->total_brate_fx, ACELP_24k40 )||EQ_32(st_fx->total_brate_fx,ACELP_32k)) { /* ---------- SHB LSP interpolation ---------- */ ptr_lsp_interp_coef = interpol_frac_shb; /*Q15*/ @@ -1783,7 +1781,7 @@ void swb_tbe_dec_fx( find_max_mem_dec( st_fx, &n_mem, &n_mem2, &n_mem3 ); /* for >=24.4, use n_mem2 lpc_syn, shb_20sample, and mem_stp_swb_fx memory */ tmp = add( st_fx->prev_Q_bwe_exc, n_mem ); - if( sub( Q_bwe_exc, tmp) > 0 ) + if( GT_16( Q_bwe_exc, tmp)) { Q_bwe_exc = tmp; } @@ -1818,7 +1816,7 @@ void swb_tbe_dec_fx( Q_bwe_exc_fb = st_fx->prev_Q_bwe_exc_fb; move16(); - IF( L_sub(st_fx->total_brate_fx, ACELP_32k) > 0 ) + IF( GT_32(st_fx->total_brate_fx, ACELP_32k)) { FOR( j = 0; j < 4; j++ ) { @@ -1835,7 +1833,7 @@ void swb_tbe_dec_fx( &(st_fx->fb_tbe_demph_fx), &Q_bwe_exc, &Q_bwe_exc_fb,Q_shb, n_mem2, st_fx->prev_Q_bwe_syn, st_fx->total_brate_fx, st_fx->prev_bfi_fx ); *Q_white_exc = Q_bwe_exc_fb; - IF( sub(st_fx->extl_fx, FB_TBE) == 0 ) + IF( EQ_16(st_fx->extl_fx, FB_TBE)) { st_fx->prev_Q_bwe_exc_fb = Q_bwe_exc_fb; move16(); @@ -1871,7 +1869,7 @@ void swb_tbe_dec_fx( curr_pow = L_mac0( curr_pow, shaped_shb_excitation[i + L_SHB_LAHEAD + 10], shaped_shb_excitation[i+L_SHB_LAHEAD + 10] ); /* 2*Q_bwe_exc */ } - if( sub( voice_factors[0], 24576/*0.75f Q15*/ ) > 0 ) + if( GT_16( voice_factors[0], 24576/*0.75f Q15*/ )) { curr_pow = L_shr( curr_pow, 2 ); /* Q(2*Q_bwe_exc) */ } @@ -1911,10 +1909,17 @@ void swb_tbe_dec_fx( { L_tmp = 0; ener_tmp[i] = 0; - FOR(j = 0; j < l_subframe_fx; j++) + { - L_tmp = L_mac0( L_tmp, shaped_shb_excitation[i*l_subframe_fx+j], shaped_shb_excitation[i*l_subframe_fx+j] );/* 2*Q_bwe_exc */ + Word64 tmp64 = 0; + move64(); + FOR(j = 0; j < l_subframe_fx; j++) + { + tmp64 = W_mac0_16_16( tmp64, shaped_shb_excitation[i*l_subframe_fx+j], shaped_shb_excitation[i*l_subframe_fx+j] );/* 2*Q_bwe_exc */ + } + L_tmp = W_sat_l(tmp64); } + L_tmp = Mult_32_16(L_tmp, 410/*0.0125 Q15*/); /* 2*Q_bwe_exc: ener_tmp_fx in (2*Q_bwe_exc) */ IF( L_tmp != 0 ) { @@ -1936,7 +1941,7 @@ void swb_tbe_dec_fx( { ener = mult(ener, 11587); /*bandwidth switching should be updated*/ - if( sub( st_fx->tilt_swb_fx, 16384 ) > 0 ) + if( GT_16( st_fx->tilt_swb_fx, 16384 )) { st_fx->prev_fractive_fx = 1; move16(); @@ -1944,18 +1949,18 @@ void swb_tbe_dec_fx( IF( is_fractive == 0 ) { - IF( sub( st_fx->tilt_wb_fx, 2048 ) > 0 ) /*assuming st_fx->tilt_wb_fx in Q11*/ + IF( GT_16( st_fx->tilt_wb_fx, 2048 )) /*assuming st_fx->tilt_wb_fx in Q11*/ { st_fx->tilt_wb_fx = 2048; move16(); } - ELSE IF( sub( st_fx->tilt_wb_fx, 1024 ) < 0 ) + ELSE IF( LT_16( st_fx->tilt_wb_fx, 1024 )) { st_fx->tilt_wb_fx = 1024; move16(); } test(); - if( st_fx->prev_fractive_fx == 1 && sub( st_fx->tilt_wb_fx, 1024 ) > 0 ) + if( st_fx->prev_fractive_fx == 1 && GT_16( st_fx->tilt_wb_fx, 1024 )) { st_fx->tilt_wb_fx = 1024; move16(); @@ -1963,7 +1968,7 @@ void swb_tbe_dec_fx( } ELSE { - IF(sub(st_fx->tilt_wb_fx, 8192) > 0) + IF(GT_16(st_fx->tilt_wb_fx, 8192)) { IF(st_fx->prev_fractive_fx == 0) { @@ -1988,12 +1993,12 @@ void swb_tbe_dec_fx( inv_ener = div_s(16384, tmp);/*Q(15+14-3-exp) = 26- exp*/ test(); - IF( L_sub(L_tmp, st_fx->enerLH_fx) > 0) /*st_fx->Q_syn2*/ + IF( GT_32(L_tmp, st_fx->enerLH_fx)) /*st_fx->Q_syn2*/ { st_fx->tilt_wb_fx = extract_h(L_shr(Mult_32_16(st_fx->enerLH_fx, inv_ener), sub(sub(st_fx->Q_syn2, exp_ener),16))); /*Q11*/ /*st_fx->Q_syn2 -1 + 26- exp_ener -15 -(st_fx->Q_syn2 -exp_ener -16 ) -16 +1 -1 = (11) *0.5*/ } - ELSE IF( L_sub(L_tmp, Mult_32_16(st_fx->enerLH_fx, 1638)) < 0 && sub(is_fractive, 1) == 0 ) + ELSE IF( LT_32(L_tmp, Mult_32_16(st_fx->enerLH_fx, 1638))&&EQ_16(is_fractive,1)) { st_fx->tilt_wb_fx = extract_h(L_shr(Mult_32_16(st_fx->enerLH_fx, inv_ener), sub(sub(st_fx->Q_syn2, exp_ener), 15))); /*Q11*/ /*st_fx->Q_syn2 -1 + 26- exp_ener -15 -(st_fx->Q_syn2 -exp_ener -15 ) -16 = (11) 0.25*/ @@ -2006,7 +2011,7 @@ void swb_tbe_dec_fx( GainFrame_prevfrm_fx = 0; } - IF( sub(is_fractive , 1) == 0 ) + IF( EQ_16(is_fractive , 1)) { GainFrame = L_shl((Word32)st_fx->tilt_wb_fx, 10); } @@ -2016,7 +2021,7 @@ void swb_tbe_dec_fx( } test(); - IF( sub((is_fractive & st_fx->prev_fractive_fx), 1) == 0 && L_sub(GainFrame, GainFrame_prevfrm_fx) > 0) + IF( EQ_16((is_fractive & st_fx->prev_fractive_fx), 1)&>_32(GainFrame,GainFrame_prevfrm_fx)) { GainFrame = L_add(Mult_32_16(GainFrame_prevfrm_fx, 26214), Mult_32_16(GainFrame, 6554));/* 18 +15 -15 = 18*/ } @@ -2026,15 +2031,15 @@ void swb_tbe_dec_fx( test(); test(); test(); - IF((L_sub(L_shr(st_fx->prev_enerLH_fx, 1), st_fx->enerLH_fx) < 0 && L_sub(st_fx->prev_enerLH_fx, L_shr(st_fx->enerLH_fx, 1)) > 0) - && (L_sub(L_shr(st_fx->prev_enerLL_fx, 1), st_fx->enerLL_fx) < 0 && L_sub(st_fx->prev_enerLL_fx, L_shr(st_fx->enerLL_fx, 1)) > 0) && (is_fractive ^ st_fx->prev_fractive_fx) == 0) + IF((LT_32(L_shr(st_fx->prev_enerLH_fx, 1), st_fx->enerLH_fx)&& GT_32(st_fx->prev_enerLH_fx,L_shr(st_fx->enerLH_fx,1))) + && (LT_32(L_shr(st_fx->prev_enerLL_fx, 1), st_fx->enerLL_fx) && GT_32(st_fx->prev_enerLL_fx, L_shr(st_fx->enerLL_fx, 1)) ) && (is_fractive ^ st_fx->prev_fractive_fx) == 0) { GainFrame = L_add(L_shr(GainFrame, 1), L_shr(GainFrame_prevfrm_fx, 1)); } ELSE { test(); - IF(is_fractive == 0 && sub(st_fx->prev_fractive_fx, 1) == 0) + IF(is_fractive == 0 && EQ_16(st_fx->prev_fractive_fx, 1)) { L_tmp1 = L_shl(Mult_32_16(GainFrame, 3277), 13); /* 31 */ L_tmp = L_sub(2147483647, L_tmp1); /* 31 */ @@ -2055,7 +2060,7 @@ void swb_tbe_dec_fx( { GainFrame = Mult_32_16(GainFrame, i_mult(st_fx->bws_cnt1_fx, 819)); /*Q18*/ } - IF(sub(st_fx->nbLostCmpt, 1) >= 0) + IF(GE_16(st_fx->nbLostCmpt, 1)) { ener = s_max(1, ener); exp_ener = norm_s(ener); @@ -2064,7 +2069,7 @@ void swb_tbe_dec_fx( prev_ener_ratio_fx = L_shr(L_mult0(st_fx->prev_ener_shb_fx, inv_ener), sub(9, exp_ener)); /*Q: 1+26-exp-9+exp = 18 */ } - IF(sub(st_fx->nbLostCmpt, 1) == 0) + IF(EQ_16(st_fx->nbLostCmpt, 1)) { test(); test(); @@ -2076,14 +2081,14 @@ void swb_tbe_dec_fx( test(); test(); test(); - IF( sub(st_fx->clas_dec, UNVOICED_CLAS) != 0 && sub(st_fx->clas_dec, UNVOICED_TRANSITION) != 0 && sub(st_fx->tilt_swb_fec_fx, 16384) < 0 && - ((L_sub(st_fx->enerLL_fx, L_shr(st_fx->prev_enerLL_fx, 1)) > 0 && L_sub(L_shr(st_fx->enerLL_fx, 1), st_fx->prev_enerLL_fx) < 0)|| (L_sub(st_fx->enerLH_fx, L_shr(st_fx->prev_enerLH_fx, 1)) > 0 && L_sub(L_shr(st_fx->enerLH_fx, 1), st_fx->prev_enerLH_fx) < 0))) + IF( NE_16(st_fx->clas_dec, UNVOICED_CLAS)&&NE_16(st_fx->clas_dec,UNVOICED_TRANSITION)&<_16(st_fx->tilt_swb_fec_fx,16384)&& + ((GT_32(st_fx->enerLL_fx, L_shr(st_fx->prev_enerLL_fx, 1)) && LT_32(L_shr(st_fx->enerLL_fx, 1), st_fx->prev_enerLL_fx) )|| (GT_32(st_fx->enerLH_fx, L_shr(st_fx->prev_enerLH_fx, 1)) && LT_32(L_shr(st_fx->enerLH_fx, 1), st_fx->prev_enerLH_fx)))) { - IF(L_sub(L_shr(prev_ener_ratio_fx, 2), GainFrame) > 0) /*18*/ + IF(GT_32(L_shr(prev_ener_ratio_fx, 2), GainFrame))/*18*/ { GainFrame = L_add(Mult_32_16(prev_ener_ratio_fx, 13107), Mult_32_16(GainFrame, 19661));/*18*/ } - ELSE IF(L_sub(L_shr(prev_ener_ratio_fx, 1), GainFrame) > 0) + ELSE IF(GT_32(L_shr(prev_ener_ratio_fx, 1), GainFrame)) { GainFrame = L_add(Mult_32_16(prev_ener_ratio_fx, 26214), Mult_32_16(GainFrame, 6554)); } @@ -2093,7 +2098,7 @@ void swb_tbe_dec_fx( } test(); - IF(sub(tilt_swb_fec, st_fx->tilt_swb_fec_fx) > 0 && st_fx->tilt_swb_fec_fx > 0) + IF(GT_16(tilt_swb_fec, st_fx->tilt_swb_fec_fx)&&st_fx->tilt_swb_fec_fx>0) { exp = norm_s(st_fx->tilt_swb_fec_fx); tmp = shl(st_fx->tilt_swb_fec_fx, exp);/*Q(11+exp)*/ @@ -2103,13 +2108,13 @@ void swb_tbe_dec_fx( } } - ELSE IF( (sub(st_fx->clas_dec, UNVOICED_CLAS) != 0 || sub(st_fx->tilt_swb_fec_fx, 16384) > 0) && L_sub(L_shr(prev_ener_ratio_fx, 2), GainFrame) > 0 && - (L_sub(st_fx->enerLL_fx, L_shr(st_fx->prev_enerLL_fx, 1)) > 0 || L_sub(st_fx->enerLH_fx, L_shr(st_fx->prev_enerLH_fx, 1)) > 0) ) + ELSE IF( (NE_16(st_fx->clas_dec, UNVOICED_CLAS)||GT_16(st_fx->tilt_swb_fec_fx,16384))&>_32(L_shr(prev_ener_ratio_fx,2),GainFrame)&& + (GT_32(st_fx->enerLL_fx, L_shr(st_fx->prev_enerLL_fx, 1)) || GT_32(st_fx->enerLH_fx, L_shr(st_fx->prev_enerLH_fx, 1)) ) ) { GainFrame = L_add(Mult_32_16(prev_ener_ratio_fx, 6554), Mult_32_16(GainFrame, 26214)); } } - ELSE IF( sub(st_fx->nbLostCmpt, 1) > 0 ) + ELSE IF( GT_16(st_fx->nbLostCmpt, 1)) { test(); test(); @@ -2119,10 +2124,10 @@ void swb_tbe_dec_fx( test(); test(); test(); - IF(L_sub(L_shr(prev_ener_ratio_fx, 2), GainFrame) > 0 && ((sub(st_fx->codec_mode, MODE1) == 0 && L_sub(st_fx->enerLL_fx, st_fx->prev_enerLL_fx) > 0 && L_sub(st_fx->enerLH_fx, st_fx->prev_enerLH_fx) > 0) || sub(st_fx->codec_mode, MODE2) == 0)) + IF(GT_32(L_shr(prev_ener_ratio_fx, 2), GainFrame)&&((EQ_16(st_fx->codec_mode,MODE1)&>_32(st_fx->enerLL_fx,st_fx->prev_enerLL_fx)&>_32(st_fx->enerLH_fx,st_fx->prev_enerLH_fx))||EQ_16(st_fx->codec_mode,MODE2))) { test(); - IF( sub(tilt_swb_fec, 20480) > 0 && sub(st_fx->tilt_swb_fec_fx, 20480) > 0 ) + IF( GT_16(tilt_swb_fec, 20480)&>_16(st_fx->tilt_swb_fec_fx,20480)) { GainFrame = L_min(L_add(Mult_32_16(prev_ener_ratio_fx, 26214), Mult_32_16(GainFrame, 6554)), L_shl(Mult_32_16(GainFrame, 16384), 3)); /*Q18*/ } @@ -2131,10 +2136,10 @@ void swb_tbe_dec_fx( GainFrame = L_min(L_add(Mult_32_16(prev_ener_ratio_fx, 16384), Mult_32_16(GainFrame, 16384)), L_shl(Mult_32_16(GainFrame, 16384), 3)); /*Q18*/ } } - ELSE IF(L_sub(prev_ener_ratio_fx, GainFrame) > 0 &&((sub(st_fx->codec_mode, MODE1) == 0 && L_sub(st_fx->enerLL_fx, st_fx->prev_enerLL_fx) > 0 && L_sub(st_fx->enerLH_fx, st_fx->prev_enerLH_fx) > 0) || sub(st_fx->codec_mode, MODE2) == 0)) + ELSE IF(GT_32(prev_ener_ratio_fx, GainFrame)&&((EQ_16(st_fx->codec_mode,MODE1)&>_32(st_fx->enerLL_fx,st_fx->prev_enerLL_fx)&>_32(st_fx->enerLH_fx,st_fx->prev_enerLH_fx))||EQ_16(st_fx->codec_mode,MODE2))) { test(); - IF( sub(tilt_swb_fec, 20480) > 0 && sub(st_fx->tilt_swb_fec_fx, 20480) > 0 ) + IF( GT_16(tilt_swb_fec, 20480)&>_16(st_fx->tilt_swb_fec_fx,20480)) { GainFrame = L_add(Mult_32_16(prev_ener_ratio_fx, 16384), Mult_32_16(GainFrame, 16384)); } @@ -2149,7 +2154,7 @@ void swb_tbe_dec_fx( move16(); /* Adjust the subframe and frame gain of the synthesized shb signal */ - IF( sub(st_fx->L_frame_fx, L_FRAME) == 0 ) + IF( EQ_16(st_fx->L_frame_fx, L_FRAME)) { /* pitch = 0.25f*sum_s(pitch_buf, 4); */ L_tmp = L_mult(pitch_buf[0], 8192); @@ -2180,9 +2185,9 @@ void swb_tbe_dec_fx( test(); test(); test(); - IF( ((L_sub(st_fx->total_brate_fx, ACELP_24k40) >= 0 && sub(st_fx->prev_coder_type_fx, coder_type) == 0 && sub(coder_type, UNVOICED) != 0) - || (L_sub(st_fx->total_brate_fx, ACELP_16k40) <= 0 && (sub(st_fx->prev_coder_type_fx, coder_type) == 0 || (sub(st_fx->prev_coder_type_fx, VOICED) == 0 && sub(coder_type, GENERIC) == 0) || (sub(st_fx->prev_coder_type_fx, GENERIC) == 0 && sub(coder_type, VOICED) == 0)))) - && sub(pitch_fx, 4480 /*70 in Q6*/) > 0 && sub(st_fx->extl_fx, FB_TBE) < 0) + IF( ((GE_32(st_fx->total_brate_fx, ACELP_24k40)&&EQ_16(st_fx->prev_coder_type_fx,coder_type)&&NE_16(coder_type,UNVOICED)) + || (LE_32(st_fx->total_brate_fx, ACELP_16k40) && (EQ_16(st_fx->prev_coder_type_fx, coder_type) || (EQ_16(st_fx->prev_coder_type_fx, VOICED) && EQ_16(coder_type, GENERIC) ) || (EQ_16(st_fx->prev_coder_type_fx, GENERIC) && EQ_16(coder_type, VOICED) )))) + && GT_16(pitch_fx, 4480 /*70 in Q6*/) && LT_16(st_fx->extl_fx, FB_TBE) ) { FOR(i=0; iprev_ener_fx_Q, 1)); L_tmp2 = L_shl(L_tmp2, tmp); /* new Q = (2*Q_bwe_exc) */ - IF (L_sub(L_tmp1,L_tmp2) > 0) + IF (GT_32(L_tmp1,L_tmp2)) { /*GainShape_tmp_fx[i] = 0.5f*(L_tmp2/ener_tmp_fx[i] + GainShape_tmp_fx[i]);*/ /* tmp = L_tmp2/ener_tmp_fx[i]*/ @@ -2301,7 +2306,7 @@ void swb_tbe_dec_fx( tmp=sub( st_fx->prev_frame_pow_exp, curr_frame_pow_exp ); IF( tmp > 0 ) /* shifting prev */ { - IF (sub(tmp,32)>0) + IF (GT_16(tmp,32)) { st_fx->prev_frame_pow_exp = add(curr_frame_pow_exp,32); tmp = 32; @@ -2312,7 +2317,7 @@ void swb_tbe_dec_fx( } ELSE /* shifting curr */ { - IF (sub(tmp,-32)<0) + IF (LT_16(tmp,-32)) { curr_frame_pow_exp = sub(st_fx->prev_frame_pow_exp,32); tmp = -32; @@ -2328,8 +2333,8 @@ void swb_tbe_dec_fx( test(); test(); - IF( ( L_sub( L_shr( curr_frame_pow, 1 ), st_fx->prev_swb_bwe_frame_pow_fx ) > 0 ) && - ( L_sub( st_fx->prev_swb_bwe_frame_pow_fx, L_tmp ) > 0 ) && sub(st_fx->prev_coder_type_fx,UNVOICED) == 0) + IF( ( GT_32( L_shr( curr_frame_pow, 1 ), st_fx->prev_swb_bwe_frame_pow_fx ))&& + ( GT_32( st_fx->prev_swb_bwe_frame_pow_fx, L_tmp ) ) && EQ_16(st_fx->prev_coder_type_fx,UNVOICED) ) { L_tmp = root_a_over_b_fx( st_fx->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow, curr_frame_pow_exp, &exp ); scale = round_fx( L_shl( L_tmp, exp ) ); /*Q15*/ @@ -2360,7 +2365,7 @@ void swb_tbe_dec_fx( { /* scale <= temp, due to scale = sqrt( st->prev_swb_bwe_frame_pow_fx/curr_frame_pow ), temp = sqrt( scale, 1.f/8.f ) and curr_frame_pow > st->prev_swb_bwe_frame_pow_fx -> scale <= 1.0, sqrt(scale, 1.f/8.f) >= scale */ - IF( sub( scale, temp ) < 0 ) + IF( LT_16( scale, temp )) { scale = div_s( scale, temp ); } @@ -2384,7 +2389,7 @@ void swb_tbe_dec_fx( scale = temp = 4096; move16();/*Q12*/ - IF (sub(st_fx->nbLostCmpt,1) == 0 ) + IF (EQ_16(st_fx->nbLostCmpt,1)) { test(); test(); @@ -2394,9 +2399,9 @@ void swb_tbe_dec_fx( test(); test(); test(); - IF( L_sub(curr_frame_pow, st_fx->prev_swb_bwe_frame_pow_fx) >0 && - sub(st_fx->prev_coder_type_fx, UNVOICED)!= 0 && - sub(st_fx->last_good_fx,UNVOICED_CLAS) != 0 ) + IF( GT_32(curr_frame_pow, st_fx->prev_swb_bwe_frame_pow_fx)&& + NE_16(st_fx->prev_coder_type_fx, UNVOICED) && + NE_16(st_fx->last_good_fx,UNVOICED_CLAS) ) { L_tmp = root_a_over_b_fx( st_fx->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow, curr_frame_pow_exp, &exp ); /*31 - exp*/ scale = round_fx( L_shl( L_tmp, sub(exp,3))); /*Q12*/ @@ -2405,9 +2410,9 @@ void swb_tbe_dec_fx( L_tmp = root_a_fx( L_tmp, 31 - exp, &exp ); temp = round_fx( L_shl( L_tmp, sub(exp,3))); /*Q12*/ } - ELSE IF( L_sub(curr_frame_pow, L_shr(st_fx->prev_swb_bwe_frame_pow_fx,1)) <0 && sub(st_fx->nbLostCmpt,1) == 0 && - (L_sub(st_fx->enerLL_fx, L_shr( st_fx->prev_enerLL_fx,1)) > 0 || L_sub(st_fx->enerLH_fx, L_shr(st_fx->prev_enerLH_fx,1)) >0 ) && - (sub(st_fx->prev_coder_type_fx ,UNVOICED) == 0 || sub(st_fx->last_good_fx, UNVOICED_CLAS) == 0 || sub(st_fx->tilt_swb_fec_fx , 10240) > 0)) + ELSE IF( LT_32(curr_frame_pow, L_shr(st_fx->prev_swb_bwe_frame_pow_fx,1))&&EQ_16(st_fx->nbLostCmpt,1)&& + (GT_32(st_fx->enerLL_fx, L_shr( st_fx->prev_enerLL_fx,1)) || GT_32(st_fx->enerLH_fx, L_shr(st_fx->prev_enerLH_fx,1)) ) && + (EQ_16(st_fx->prev_coder_type_fx ,UNVOICED) || EQ_16(st_fx->last_good_fx, UNVOICED_CLAS) || GT_16(st_fx->tilt_swb_fec_fx , 10240) )) { L_tmp = root_a_over_b_fx( st_fx->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow, curr_frame_pow_exp, &exp ); scale = round_fx( L_shl( L_tmp, sub(exp,3) ) ); /*Q12*/ @@ -2417,14 +2422,14 @@ void swb_tbe_dec_fx( temp = round_fx( L_shl( L_tmp, sub(exp,3) ) ); /*Q12*/ } } - ELSE IF (sub(st_fx->nbLostCmpt,1) > 0 ) + ELSE IF (GT_16(st_fx->nbLostCmpt,1)) { test(); test(); test(); test(); test(); - IF( L_sub(curr_frame_pow , st_fx->prev_swb_bwe_frame_pow_fx) >0 ) + IF( GT_32(curr_frame_pow , st_fx->prev_swb_bwe_frame_pow_fx)) { L_tmp = root_a_over_b_fx( st_fx->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow, curr_frame_pow_exp, &exp ); scale = round_fx( L_shl( L_tmp, sub(exp,3) ) ); /*Q12*/ @@ -2434,9 +2439,9 @@ void swb_tbe_dec_fx( temp = round_fx( L_shl( L_tmp, sub(exp,3) ) ); /*Q12*/ } - ELSE IF( L_sub(curr_frame_pow, L_shr(st_fx->prev_swb_bwe_frame_pow_fx,1)) < 0 && - (L_sub(st_fx->enerLL_fx, L_shr( st_fx->prev_enerLL_fx,1)) > 0 || L_sub(st_fx->enerLH_fx, L_shr(st_fx->prev_enerLH_fx,1)) > 0) && - (st_fx->prev_coder_type_fx == UNVOICED || st_fx->last_good_fx == UNVOICED_CLAS || sub(st_fx->tilt_swb_fec_fx , 10240) > 0) ) + ELSE IF( LT_32(curr_frame_pow, L_shr(st_fx->prev_swb_bwe_frame_pow_fx,1))&& + (GT_32(st_fx->enerLL_fx, L_shr( st_fx->prev_enerLL_fx,1)) || GT_32(st_fx->enerLH_fx, L_shr(st_fx->prev_enerLH_fx,1)) ) && + (st_fx->prev_coder_type_fx == UNVOICED || st_fx->last_good_fx == UNVOICED_CLAS || GT_16(st_fx->tilt_swb_fec_fx , 10240)) ) { L_tmp = root_a_over_b_fx( st_fx->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow, curr_frame_pow_exp, &exp ); L_tmp =L_min(L_tmp,L_shl(2,(31 - exp)));/*31 - exp*/ @@ -2461,7 +2466,7 @@ void swb_tbe_dec_fx( IF( temp > 0 ) { - IF( sub( scale, temp ) < 0 ) + IF( LT_16( scale, temp )) { scale = shr(div_s( scale, temp ),3); } @@ -2486,12 +2491,18 @@ void swb_tbe_dec_fx( st_fx->prev_frame_pow_exp = curr_frame_pow_exp; move16(); - L_prev_ener_shb = L_deposit_l(0); - FOR( i = 0; i < L_FRAME16k; i++ ) + { - L_prev_ener_shb = L_mac0( L_prev_ener_shb, shaped_shb_excitation[i], shaped_shb_excitation[i] ); /* Q0 */ + Word64 prev_ener_shb64 = 0; + move64(); + FOR( i = 0; i < L_FRAME16k; i++ ) + { + prev_ener_shb64 = W_mac0_16_16( prev_ener_shb64, shaped_shb_excitation[i], shaped_shb_excitation[i] ); /* Q0 */ + } + L_prev_ener_shb = W_sat_l(prev_ener_shb64); } + /* st->prev_ener_shb = sqrt(st->prev_ener_shb/L_FRAME16k) */ L_prev_ener_shb = Mult_32_16( L_prev_ener_shb, 26214 ); /* 2*Q_bwe_exc_mod+8; 26214=(1/L_FRAME16k) in Q23 */ st_fx->prev_ener_shb_fx = 0; @@ -2535,7 +2546,7 @@ void swb_tbe_dec_fx( move16(); } - IF(sub(st_fx->L_frame_fx, L_FRAME) == 0) + IF(EQ_16(st_fx->L_frame_fx, L_FRAME)) { FOR( i = 0; i < HILBERT_MEM_SIZE; i++ ) { @@ -2564,15 +2575,15 @@ void swb_tbe_dec_fx( /* resample SHB synthesis (if needed) and scale down */ synth_scale_fx = 32767; move16(); /* 1.0 in Q15 */ - if(sub(st_fx->codec_mode,MODE1)==0) + if(EQ_16(st_fx->codec_mode,MODE1)) { synth_scale_fx = 29491; move16(); /* 0.9 in Q15 */ } - IF( L_sub(st_fx->output_Fs_fx, 48000) == 0 ) + IF( EQ_32(st_fx->output_Fs_fx, 48000)) { - IF( L_sub(st_fx->extl_fx,FB_TBE) == 0 ) + IF( EQ_32(st_fx->extl_fx,FB_TBE)) { tmp = norm_l( GainFrame ); if(GainFrame == 0) @@ -2605,7 +2616,7 @@ void swb_tbe_dec_fx( move16(); } - IF( sub(synth_scale_fx,32767) != 0 ) /* 1.0 in Q15 */ + IF( NE_16(synth_scale_fx,32767)) /* 1.0 in Q15 */ { FOR( i=0; iint_3_over_2_tbemem_dec_fx, allpass_poles_3_ov_2 ); } - ELSE IF( L_sub(st_fx->output_Fs_fx, 32000) == 0 ) + ELSE IF( EQ_32(st_fx->output_Fs_fx, 32000)) { - IF( sub(synth_scale_fx,32767) != 0 ) /* 1.0 in Q15 */ + IF( NE_16(synth_scale_fx,32767)) /* 1.0 in Q15 */ { FOR( i = 0; i < L_FRAME32k; i++ ) { @@ -2631,9 +2642,9 @@ void swb_tbe_dec_fx( Copy(error, synth, L_FRAME32k); } } - ELSE IF( L_sub(st_fx->output_Fs_fx, 16000) == 0 ) + ELSE IF( EQ_32(st_fx->output_Fs_fx, 16000)) { - IF( sub(synth_scale_fx,32767) != 0 ) /* 1.0 in Q15 */ + IF( NE_16(synth_scale_fx,32767)) /* 1.0 in Q15 */ { FOR( i = 0; i < L_FRAME32k; i++ ) { @@ -2647,7 +2658,7 @@ void swb_tbe_dec_fx( /* Update previous frame parameters for FEC */ Copy( lsf_shb, st_fx->lsp_prevfrm_fx, LPC_SHB_ORDER ); - IF(sub(st_fx->codec_mode, MODE1) == 0) + IF(EQ_16(st_fx->codec_mode, MODE1)) { st_fx->GainFrame_prevfrm_fx = GainFrame; move16(); /*Q18*/ @@ -2709,8 +2720,8 @@ static void gradientGainShape( test(); test(); test(); - IF( ( ( sub( shr( GainGrad1[2], 1 ), GainGrad1[1] ) > 0 ) && ( sub( shr( GainGrad1[1], 1 ), GainGrad1[0] ) > 0 ) ) || - ( ( sub( shr( GainGrad1[2], 1 ), GainGrad1[1] ) < 0 ) && ( sub( shr( GainGrad1[1], 1 ), GainGrad1[0] ) < 0 ) ) ) + IF( ( ( GT_16( shr( GainGrad1[2], 1 ), GainGrad1[1] ))&&(GT_16(shr(GainGrad1[1],1),GainGrad1[0])))|| + ( ( LT_16( shr( GainGrad1[2], 1 ), GainGrad1[1] ) ) && ( LT_16( shr( GainGrad1[1], 1 ), GainGrad1[0] ) ) ) ) { GainGradFEC[0] = add( mult_r( GainGrad1[1], 3277 ), mult_r( GainGrad1[2], 29490 ) ); move16(); /* Q14 */ @@ -2748,7 +2759,7 @@ static void gradientGainShape( tmp = mult_r( tmp, 26214 ); /* 0.8 in Q15 tmp*(8/10) */ test(); - IF( ( sub( tmp, GainGrad1[1] ) > 0 ) && GainGrad1[1] > 0 ) + IF( ( GT_16( tmp, GainGrad1[1] ))&&GainGrad1[1]>0) { FOR( i = 1; i < NUM_SHB_SUBFR / 4; i++ ) { @@ -2761,7 +2772,7 @@ static void gradientGainShape( ELSE { test(); - IF( ( sub( tmp, GainGrad1[1] ) > 0 ) && GainGrad1[1] < 0 ) + IF( ( GT_16( tmp, GainGrad1[1] ))&&GainGrad1[1]<0) { FOR( i = 1; i < NUM_SHB_SUBFR / 4; i++ ) { @@ -2795,7 +2806,7 @@ static void gradientGainShape( { tmp = mult_r( GainShapeTemp[i], 19660 ); /* GainShapeTemp[i]*0.6 */ - IF( sub( 8192, tmp ) > 0 ) + IF( GT_16( 8192, tmp )) { GainShape[i * 4 + j ] = shl( tmp, 2 ); move16(); /* (GainShapeTemp[i]*0.6)>>1 */ @@ -2815,7 +2826,7 @@ static void gradientGainShape( { FOR( j = 0; j < 4; j++ ) { - IF( sub( GainShapeTemp[i], 16384 ) < 0 ) + IF( LT_16( GainShapeTemp[i], 16384 )) { GainShape[i * 4 + j ] = shl( GainShapeTemp[i], 1 ); move16(); @@ -2847,7 +2858,7 @@ static void gradientGainShape( { FOR( j = 0; j < 4; j++ ) { - IF( sub( GainShapeTemp[i], 16384 ) < 0 ) + IF( LT_16( GainShapeTemp[i], 16384 )) { GainShape[i * 4 + j] = shl( GainShapeTemp[i], 1 ); move16(); @@ -2915,7 +2926,7 @@ static void Map_higher_LSF_fx( move16(); } - IF( sub( m, MAX_LSF_FX_BY_2 ) > 0 ) + IF( GT_16( m, MAX_LSF_FX_BY_2 )) { offset = lsf_map[0]; move16(); @@ -3015,9 +3026,9 @@ static void dequantizeSHBparams_fx_9_1( /* LSFs */ - IF( sub( extl, WB_TBE ) == 0 ) + IF( EQ_16( extl, WB_TBE )) { - IF( L_sub( extl_brate, WB_TBE_0k35 ) == 0 ) + IF( EQ_32( extl_brate, WB_TBE_0k35 )) { idxFrameGain = st_fx->gFrame_WB_fx; idxLSF = st_fx->lsf_WB_fx; @@ -3064,7 +3075,7 @@ static void dequantizeSHBparams_fx_9_1( } ELSE /* SWB TBE DEC */ { - IF(sub(st_fx->codec_mode,MODE2) == 0) + IF(EQ_16(st_fx->codec_mode,MODE2)) { idxSubGain = st_fx->idxSubGains_fx; idxFrameGain = st_fx->idxFrameGain_fx; @@ -3076,9 +3087,9 @@ static void dequantizeSHBparams_fx_9_1( } test(); - IF( L_sub(st_fx->total_brate_fx, ACELP_24k40) == 0 || L_sub(st_fx->total_brate_fx, ACELP_32k) == 0 ) + IF( EQ_32(st_fx->total_brate_fx, ACELP_24k40)||EQ_32(st_fx->total_brate_fx,ACELP_32k)) { - IF(sub(st_fx->codec_mode,MODE2) == 0) + IF(EQ_16(st_fx->codec_mode,MODE2)) { idx_shb_fr_gain = st_fx->idx_shb_fr_gain_fx; } @@ -3099,7 +3110,7 @@ static void dequantizeSHBparams_fx_9_1( FOR(i=0; i<5; i++) { - IF(sub(st_fx->codec_mode,MODE2) == 0) + IF(EQ_16(st_fx->codec_mode,MODE2)) { idx_res_gs[i] = st_fx->idx_res_gs_fx[i]; move16(); @@ -3117,7 +3128,7 @@ static void dequantizeSHBparams_fx_9_1( /* o: Q_shb_res_gshape in Q14 */ } - IF(sub(st_fx->codec_mode,MODE2) == 0) + IF(EQ_16(st_fx->codec_mode,MODE2)) { idx_mixFac = st_fx->idx_mixFac_fx; move16(); @@ -3146,16 +3157,16 @@ static void dequantizeSHBparams_fx_9_1( test(); test(); test(); - IF( (st_fx->rf_flag == 0) && !((L_sub(st_fx->total_brate_fx, ACELP_9k60) == 0) || ((st_fx->total_brate_fx == 0) && ( (L_sub(st_fx->last_total_brate_fx, ACELP_9k60) == 0) || (L_sub(st_fx->last_total_brate_fx, ACELP_13k20) == 0 && sub(st_fx->rf_flag_last, 1) == 0) ))) ) + IF( (st_fx->rf_flag == 0) && !((EQ_32(st_fx->total_brate_fx, ACELP_9k60))||((st_fx->total_brate_fx==0)&&((EQ_32(st_fx->last_total_brate_fx,ACELP_9k60))||(EQ_32(st_fx->last_total_brate_fx,ACELP_13k20)&&EQ_16(st_fx->rf_flag_last,1)))))) { /* LSFs */ test(); test(); test(); - IF ( L_sub(extl_brate, SWB_TBE_1k6) == 0 || L_sub(extl_brate, FB_TBE_1k8) == 0 || L_sub(extl_brate, SWB_TBE_2k8) == 0 || L_sub(extl_brate, FB_TBE_3k0) == 0 ) + IF ( EQ_32(extl_brate, SWB_TBE_1k6)||EQ_32(extl_brate,FB_TBE_1k8)||EQ_32(extl_brate,SWB_TBE_2k8)||EQ_32(extl_brate,FB_TBE_3k0)) { - IF(sub(st_fx->codec_mode,MODE2) == 0) + IF(EQ_16(st_fx->codec_mode,MODE2)) { FOR (i = 0; i < NUM_Q_LSF; i++) { @@ -3175,7 +3186,7 @@ static void dequantizeSHBparams_fx_9_1( } Dequant_lower_LSF_fx( lsf_idx, lsf_q ); - IF(sub(st_fx->codec_mode,MODE2) == 0) + IF(EQ_16(st_fx->codec_mode,MODE2)) { m_idx = st_fx->m_idx_fx; } @@ -3188,13 +3199,13 @@ static void dequantizeSHBparams_fx_9_1( Dequant_mirror_point_fx( lsf_q, m_idx, &m ); /* safety check in case of bit errors */ - IF(sub(m, MAX_LSF_FX) > 0) + IF(GT_16(m, MAX_LSF_FX)) { st_fx->BER_detect = 1; m = MAX_LSF_FX-1; } - IF(sub(st_fx->codec_mode,MODE2) == 0) + IF(EQ_16(st_fx->codec_mode,MODE2)) { grid_idx = st_fx->grid_idx_fx; } @@ -3209,7 +3220,7 @@ static void dequantizeSHBparams_fx_9_1( FOR (i = 0; i < LPC_SHB_ORDER; i++) { /* safety check in case of bit errors */ - IF(sub(lsf_q[LPC_SHB_ORDER - 1 - i], MAX_LSF_FX) > 0) + IF(GT_16(lsf_q[LPC_SHB_ORDER - 1 - i], MAX_LSF_FX)) { st_fx->BER_detect = 1; lsf_q[LPC_SHB_ORDER - 1 - i] = MAX_LSF_FX - 1; @@ -3285,9 +3296,9 @@ void fb_tbe_dec_fx( /* decode FB slope information */ test(); test(); - IF ( sub(st->extl_fx,FB_TBE) == 0 && !st->bfi_fx ) + IF ( EQ_16(st->extl_fx,FB_TBE)&&!st->bfi_fx) { - IF( sub(st->codec_mode,MODE2) == 0 ) + IF( EQ_16(st->codec_mode,MODE2)) { i = st->idxGain_fx; move16(); @@ -3298,7 +3309,7 @@ void fb_tbe_dec_fx( } ratio = shl(1,i); } - ELSE if ( sub(st->extl_fx,FB_TBE) == 0 && st->bfi_fx ) + ELSE if ( EQ_16(st->extl_fx,FB_TBE)&&st->bfi_fx) { ratio = st->prev_fbbwe_ratio_fx; move16(); @@ -3329,7 +3340,7 @@ void tbe_read_bitstream_fx( test(); test(); test(); - IF ( (sub(st_fx->rf_flag,1)==0 || L_sub(st_fx->total_brate_fx,ACELP_9k60) == 0 ) && sub(st_fx->bwidth_fx,WB) == 0) + IF ( (EQ_16(st_fx->rf_flag,1)||EQ_32(st_fx->total_brate_fx,ACELP_9k60))&&EQ_16(st_fx->bwidth_fx,WB)) { /* WB LSF */ st_fx->lsf_WB_fx = get_next_indice_fx(st_fx, NUM_BITS_LBR_WB_LSF); @@ -3337,11 +3348,11 @@ void tbe_read_bitstream_fx( /* WB frame gain */ st_fx->gFrame_WB_fx = get_next_indice_fx(st_fx, NUM_BITS_SHB_FrameGain_LBR_WB); } - ELSE IF ( ( L_sub( st_fx->total_brate_fx, ACELP_9k60 ) >= 0 ) && ( L_sub( st_fx->total_brate_fx, ACELP_32k ) <= 0 ) && - ( ( sub( st_fx->bwidth_fx, SWB ) == 0 ) || ( sub( st_fx->bwidth_fx, FB ) == 0 ) ) ) + ELSE IF ( ( GE_32( st_fx->total_brate_fx, ACELP_9k60 ))&&(LE_32(st_fx->total_brate_fx,ACELP_32k))&& + ( ( EQ_16( st_fx->bwidth_fx, SWB ) ) || ( EQ_16( st_fx->bwidth_fx, FB ) ) ) ) { test(); - IF( (st_fx->rf_flag == 0) && (L_sub(st_fx->total_brate_fx, ACELP_9k60) > 0) ) + IF( (st_fx->rf_flag == 0) && (GT_32(st_fx->total_brate_fx, ACELP_9k60))) { FOR (i = 0; i < NUM_Q_LSF; i++) { @@ -3370,7 +3381,7 @@ void tbe_read_bitstream_fx( /* frame gain */ st_fx->idxFrameGain_fx = get_next_indice_fx(st_fx, NUM_BITS_SHB_FRAMEGAIN); - IF ( L_sub( st_fx->total_brate_fx, ACELP_24k40 ) >= 0 ) + IF ( GE_32( st_fx->total_brate_fx, ACELP_24k40 )) { /* sub frame energy*/ st_fx->idx_shb_fr_gain_fx = get_next_indice_fx(st_fx, NUM_BITS_SHB_ENER_SF); @@ -3386,7 +3397,7 @@ void tbe_read_bitstream_fx( st_fx->idx_mixFac_fx = get_next_indice_fx(st_fx, NUM_BITS_SHB_VF); } - IF (sub(st_fx->tec_tfa, 1) == 0) + IF (EQ_16(st_fx->tec_tfa, 1)) { st_fx->tec_flag = get_next_indice_fx(st_fx, BITS_TEC); st_fx->tfa_flag = get_next_indice_fx(st_fx, BITS_TFA); @@ -3408,7 +3419,7 @@ void tbe_read_bitstream_fx( } } - IF ( sub( st_fx->bwidth_fx, FB ) == 0 ) + IF ( EQ_16( st_fx->bwidth_fx, FB )) { st_fx->idxGain_fx = get_next_indice_fx(st_fx, 4); } @@ -3423,8 +3434,8 @@ void tbe_read_bitstream_fx( * switching from TBE to IGF *---------------------------------------------------------------------*/ void GenTransition_fx( - const Word16 *input, /* i : gain shape overlap buffer */ - const Word16 *old_hb_synth, /* i : synthesized HB from previous frame */ + const Word16 *input, /* i : gain shape overlap buffer */ + const Word16 *old_hb_synth, /* i : synthesized HB from previous frame */ Word16 length, /* i : targeted length of transition signal */ Word16 *output, /* o : synthesized transitions signal */ Word32 Hilbert_Mem[], /* i/o: memory */ @@ -3447,7 +3458,7 @@ void GenTransition_fx( /* perform spectral flip and downmix with overlap snippet to match HB synth */ test(); - IF( (rf_flag != 0) || L_sub( bitrate, ACELP_9k60 ) == 0 ) + IF( (rf_flag != 0) || EQ_32( bitrate, ACELP_9k60 )) { flip_and_downmix_generic_fx( syn_overlap_32k, syn_overlap_32k, 2*SHB_OVERLAP_LEN, Hilbert_Mem, Hilbert_Mem + HILBERT_ORDER1, Hilbert_Mem + (HILBERT_ORDER1+2*HILBERT_ORDER2), @@ -3477,11 +3488,11 @@ void GenTransition_fx( output[i] = old_hb_synth[L_SHB_TRANSITION_LENGTH-1-i]; } - IF ( L_sub( target_fs, 48000 ) == 0 ) + IF ( EQ_32( target_fs, 48000 )) { interpolate_3_over_2_allpass_fx( output, length, output, up_mem, allpass_poles_3_ov_2 ); } - ELSE IF( L_sub( target_fs, 16000 ) == 0 ) + ELSE IF( EQ_32( target_fs, 16000 )) { Decimate_allpass_steep_fx( output, mem_resamp_HB_32k, L_FRAME32k, output ); } @@ -3544,12 +3555,12 @@ void GenTransition_WB_fx( } /* upsampling if necessary */ - IF( L_sub(output_Fs, 32000) == 0 ) + IF( EQ_32(output_Fs, 32000)) { Interpolate_allpass_steep_fx( output, up_mem, L_FRAME16k, upsampled_synth ); Copy( upsampled_synth, output, L_FRAME32k ); } - ELSE IF( L_sub(output_Fs, 48000) == 0 ) + ELSE IF( EQ_32(output_Fs, 48000)) { interpolate_3_over_1_allpass_fx( output, L_FRAME16k, upsampled_synth, up_mem, allpass_poles_3_ov_2 ); Copy( upsampled_synth, output, L_FRAME48k ); @@ -3568,7 +3579,7 @@ void TBEreset_dec_fx( Word16 bandwidth /* i : bandwidth mode */ ) { - IF( sub(st_fx->last_core_fx,ACELP_CORE) != 0 ) + IF( NE_16(st_fx->last_core_fx,ACELP_CORE)) { set16_fx( st_fx->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); st_fx->bwe_non_lin_prev_scale_fx = L_deposit_l(0); @@ -3577,7 +3588,7 @@ void TBEreset_dec_fx( } test(); - IF( sub(bandwidth, WB) == 0 ) + IF( EQ_16(bandwidth, WB)) { wb_tbe_extras_reset_fx( st_fx->mem_genSHBexc_filt_down_wb2_fx, st_fx->mem_genSHBexc_filt_down_wb3_fx ); wb_tbe_extras_reset_synth_fx( st_fx->state_lsyn_filt_shb_fx, st_fx->state_lsyn_filt_dwn_shb_fx, st_fx->state_32and48k_WB_upsample_fx, st_fx->mem_resamp_HB_fx ); @@ -3588,7 +3599,7 @@ void TBEreset_dec_fx( set16_fx( st_fx->syn_overlap_fx, 0, L_SHB_LAHEAD ); set32_fx( st_fx->mem_csfilt_fx, 0, 2 ); } - ELSE IF( sub(bandwidth, SWB) == 0 || sub(bandwidth, FB) == 0 ) + ELSE IF( EQ_16(bandwidth, SWB)||EQ_16(bandwidth,FB)) { swb_tbe_reset_fx( st_fx->mem_csfilt_fx, st_fx->mem_genSHBexc_filt_down_shb_fx, st_fx->state_lpc_syn_fx, st_fx->syn_overlap_fx, st_fx->state_syn_shbexc_fx, &(st_fx->tbe_demph_fx), @@ -3600,7 +3611,7 @@ void TBEreset_dec_fx( set16_fx( st_fx->int_3_over_2_tbemem_dec_fx, 0, INTERP_3_2_MEM_LEN); set16_fx( st_fx->mem_resamp_HB_32k_fx, 0, 2*ALLPASSSECTIONS_STEEP+1 ); - IF( sub(bandwidth, FB) == 0 ) + IF( EQ_16(bandwidth, FB)) { st_fx->prev_fb_ener_adjust_fx = 0; set16_fx( st_fx->fb_state_lpc_syn_fx, 0, LPC_SHB_ORDER ); diff --git a/lib_dec/syn_outp_fx.c b/lib_dec/syn_outp_fx.c index d700f9b57fc11290f69a4eb4ec6cab55dddd05a1..fc6017a3a0e166dc7aca70bdb98b703b3c46c840 100644 --- a/lib_dec/syn_outp_fx.c +++ b/lib_dec/syn_outp_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "cnst_fx.h" /* Common constants */ #include "prot_fx.h" /* Debug prototypes */ -#include "stl.h" -#include "wmc_auto.h" - /* required for wmc_tool */ +#include "stl.h" /* required for wmc_tool */ /*-------------------------------------------------------------------* * syn_output() @@ -34,7 +32,7 @@ void syn_output_fx( *-----------------------------------------------------------------*/ test(); - IF( codec_mode == MODE2 || sub(output_frame,L_FRAME8k) == 0 ) + IF( codec_mode == MODE2 || EQ_16(output_frame,L_FRAME8k)) { /* integer conversion */ /*mvr2s( synth, synth_out, output_frame ); */ @@ -77,12 +75,12 @@ void unscale_AGC( { max = s_max(max, abs_s(x[i])); } - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF tmp = shl(30000, Qx); /* saturation can occurs here */ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON frame_fac = 0; move16(); - IF (sub(max, tmp) > 0) + IF (GT_16(max, tmp)) { frame_fac = sub(16384, div_s(shr(tmp, 1), max)); /* frame fac in Q15 */ } diff --git a/lib_dec/tcq_core_dec_fx.c b/lib_dec/tcq_core_dec_fx.c index 4b4b38a92692ecbe1c1236953ab53beb3535a04e..0dc625c0bab16295164e22329a65f58065644b3b 100644 --- a/lib_dec/tcq_core_dec_fx.c +++ b/lib_dec/tcq_core_dec_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -8,9 +8,7 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" -#include "stl.h" -#include "wmc_auto.h" - /* required for wmc_tool */ +#include "stl.h" /* required for wmc_tool */ void tcq_core_LR_dec_fx( Decoder_State_fx *st_fx, @@ -71,7 +69,7 @@ void tcq_core_LR_dec_fx( test(); test(); - IF ( sub(input_frame, L_FRAME16k) <= 0 && adjustFlag == 0 && *is_transient == 0 ) + IF ( LE_16(input_frame, L_FRAME16k)&&adjustFlag==0&&*is_transient==0) { flag_wbnb = 1; move16(); @@ -91,7 +89,7 @@ void tcq_core_LR_dec_fx( /* Bits distribution analysis*/ FOR ( i = 0; i < BANDS; i++ ) { - IF (L_sub(ar_div(Rk_fx[i], band_width[i]), 49152) >= 0) + IF (GE_32(ar_div(Rk_fx[i], band_width[i]), 49152)) { /* USQ used for high importance bands*/ USQ_TCQ[i] = 1; @@ -180,7 +178,7 @@ void tcq_core_LR_dec_fx( test(); test(); - IF( sub(input_frame, L_FRAME16k) <= 0 && adjustFlag == 0 && *is_transient == 0 ) + IF( LE_16(input_frame, L_FRAME16k)&&adjustFlag==0&&*is_transient==0) { surplus_fx = -131072; move32();/*16 */ @@ -191,7 +189,7 @@ void tcq_core_LR_dec_fx( move16(); FOR ( j = 0; j < BANDS; j++ ) { - IF( sub(j, k_num[0]) == 0 || sub(j, k_num[1]) == 0) + IF( EQ_16(j, k_num[0])||EQ_16(j,k_num[1])) { sepbits = L_add( sepbits, Rk_fx[k_sort[j]]); } @@ -208,7 +206,7 @@ void tcq_core_LR_dec_fx( FOR( k = 0; k < BANDS; k++ ) { test(); - IF( sub(k, k_num[0]) != 0 && sub(k, k_num[1]) != 0) + IF( NE_16(k, k_num[0])&&NE_16(k,k_num[1])) { test(); test(); @@ -250,7 +248,7 @@ void tcq_core_LR_dec_fx( nzbands--; move16(); } - ELSE IF (Rk_fx[k_sort[k]] > 0 && sub(USQ_TCQ[k_sort[k]], 1) == 0) + ELSE IF (Rk_fx[k_sort[k]] > 0 && EQ_16(USQ_TCQ[k_sort[k]], 1)) { /* When number of bits per band is less than arithmetic bits overhead, this band is not encoded. @@ -331,7 +329,7 @@ void tcq_core_LR_dec_fx( test(); test(); test(); - IF (( L_sub(surplus_fx,524288) > 0 && sub(input_frame,L_FRAME8k) == 0 ) || ( L_sub(surplus_fx,786432) > 0 && sub(input_frame,L_FRAME16k) == 0 )) + IF (( GT_32(surplus_fx,524288)&&EQ_16(input_frame,L_FRAME8k))||(GT_32(surplus_fx,786432)&&EQ_16(input_frame,L_FRAME16k))) { bit_surplus_fx[0] = Mult_32_16(surplus_fx,24576);/* Q16 */ bit_surplus_fx[1] = Mult_32_16(surplus_fx,8192);/* Q16 */ @@ -347,7 +345,7 @@ void tcq_core_LR_dec_fx( { FOR ( j = 0; j < 2; j++ ) { - IF ( sub(k, k_num[j]) == 0 ) + IF ( EQ_16(k, k_num[j])) { Rk_fx[k_sort[k]] = L_add(Rk_fx[k_sort[k]],bit_surplus_fx[j]); move32(); diff --git a/lib_dec/tcx_utils_dec.c b/lib_dec/tcx_utils_dec.c index 4f8560b1d3d834ce4f3a007bf6525d372cdc2f8a..6762567a94b9bd2d07099e6563c831e9236f45c3 100644 --- a/lib_dec/tcx_utils_dec.c +++ b/lib_dec/tcx_utils_dec.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ @@ -7,8 +7,6 @@ #include #include #include "stl.h" -#include "wmc_auto.h" - #include "options.h" #include "prot_fx.h" #include "rom_basop_util.h" @@ -57,10 +55,10 @@ void tcx_decoder_memory_update( Copy(synth + sub(L_frame_glob, L_SYN_MEM), st->mem_syn_r, L_SYN_MEM); test(); - IF ( st->tcxonly == 0 || sub(L_frame_glob,L_FRAME16k)<=0) + IF ( st->tcxonly == 0 || LE_16(L_frame_glob,L_FRAME16k)) { /* Update excitation */ - IF(sub(st->Q_syn+1,st->Q_exc) != 0) + IF(NE_16(st->Q_syn+1,st->Q_exc)) { Scale_sig(st->old_exc_fx, L_EXC_MEM_DEC, sub(st->Q_syn+1,st->Q_exc)); } @@ -108,7 +106,7 @@ Word16 tcx_ari_res_invQ_spec( FOR (i=0; i < L_frame; i++) { - IF (sub(bits, target_bits) >= 0) /* no bits left */ + IF (GE_16(bits, target_bits)) /* no bits left */ { BREAK; } @@ -139,7 +137,7 @@ Word16 tcx_ari_res_invQ_spec( s = sub(x_Q_e, 1); FOR (j = 0; j < num_zeros; j++) { - IF (sub(bits, target_bits) >= 0) /* 1 or 0 bits left */ + IF (GE_16(bits, target_bits)) /* 1 or 0 bits left */ { BREAK; } @@ -177,7 +175,7 @@ Word16 tcx_res_invQ_gain( move16(); /* make sure we have a bit of headroom */ - IF (sub(gain, 0x7000) > 0) + IF (GT_16(gain, 0x7000)) { gain = shr(gain, 1); *gain_tcx_e = add(*gain_tcx_e, 1); @@ -237,14 +235,14 @@ Word16 tcx_res_invQ_spec( FOR (i = 0; i < L_frame; i++) { - IF (sub(bits, resQBits) >= 0) + IF (GE_16(bits, resQBits)) { BREAK; } test(); test(); - IF ((x[i] != 0) && ((lf_deemph_factors == NULL) || (sub(lf_deemph_factors[i], 0x2000) > 0))) + IF ((x[i] != 0) && ((lf_deemph_factors == NULL) || (GT_16(lf_deemph_factors[i], 0x2000)))) { if (lf_deemph_factors != NULL) { @@ -291,7 +289,7 @@ Word16 tcx_res_invQ_spec( { FOR (i = 0; i < L_frame; i++) { - IF (sub(bits, resQBits) >= 0) + IF (GE_16(bits, resQBits)) { BREAK; } @@ -318,13 +316,13 @@ Word16 tcx_res_invQ_spec( FOR (i = 0; i < L_frame; i++) { - IF (sub(bits, resQBits) >= 0) + IF (GE_16(bits, resQBits)) { BREAK; } test(); - IF ((x[i] == 0) && (sub(lf_deemph_factors[i], 0x2000) > 0)) + IF ((x[i] == 0) && (GT_16(lf_deemph_factors[i], 0x2000))) { IF (prm[bits] != 0) { diff --git a/lib_dec/tns_base_dec.c b/lib_dec/tns_base_dec.c index 1b7e20e1b01583d56940de9e0701e0ca196890df..2768d021e9201d41e414499734011066008175c5 100644 --- a/lib_dec/tns_base_dec.c +++ b/lib_dec/tns_base_dec.c @@ -1,15 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "stl.h" -#include "wmc_auto.h" - #include "prot_fx.h" #include "stl.h" -#include "wmc_auto.h" - #include #include #include "rom_com_fx.h" @@ -35,10 +31,10 @@ Word16 ReadTnsData(STnsConfig const * pTnsConfig, Decoder_State_fx *st, Word16 * move16(); start_bit_pos = st->next_bit_pos_fx; - IF ( sub(pTnsConfig->nMaxFilters, 1) > 0 ) + IF ( GT_16(pTnsConfig->nMaxFilters, 1)) { - IF ( sub(pTnsConfig->iFilterBorders[0],512) < 0) + IF ( LT_16(pTnsConfig->iFilterBorders[0],512)) { ReadFromBitstream(tnsEnabledSWBTCX10BitMap, 1, st, &stream, pnSize); } @@ -67,10 +63,10 @@ Word16 DecodeTnsData(STnsConfig const * pTnsConfig, Word16 const * stream, Word1 ResetTnsData(pTnsData); - IF ( sub(pTnsConfig->nMaxFilters, 1) > 0 ) + IF ( GT_16(pTnsConfig->nMaxFilters, 1)) { - IF ( sub(pTnsConfig->iFilterBorders[0],512) < 0 ) + IF ( LT_16(pTnsConfig->iFilterBorders[0],512)) { SetParameters(tnsEnabledSWBTCX10BitMap, 1, pTnsData, &stream, pnSize); } diff --git a/lib_dec/tonalMDCTconcealment.c b/lib_dec/tonalMDCTconcealment.c index 4e8cd101972a79859f087d60e6e26cff9a3906a2..e5902f2cd77c948ed550a60146cab6c233712aff 100644 --- a/lib_dec/tonalMDCTconcealment.c +++ b/lib_dec/tonalMDCTconcealment.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #define _USE_MATH_DEFINES #include #include "stl.h" -#include "wmc_auto.h" - #include "basop_util.h" #include "options.h" #include "typedef.h" @@ -64,7 +62,7 @@ TONALMDCTCONCEAL_ERROR TonalMDCTConceal_Init( TonalMDCTConcealPtr self, ) { test(); - IF (sub(nSamples,L_FRAME_MAX) > 0 || sub(nScaleFactors,FDNS_NPTS) > 0) + IF (GT_16(nSamples,L_FRAME_MAX)||GT_16(nScaleFactors,FDNS_NPTS)) { assert(nSamples <= L_FRAME_MAX); assert(nScaleFactors <= FDNS_NPTS); @@ -110,7 +108,7 @@ TONALMDCTCONCEAL_ERROR TonalMDCTConceal_Init( TonalMDCTConcealPtr self, self->lastPitchLag = L_deposit_l(0); - IF (sub(self->nSamples,nSamples) != 0) + IF (NE_16(self->nSamples,nSamples)) { self->secondLastBlockData.blockIsValid = 0; move16(); @@ -158,9 +156,9 @@ TONALMDCTCONCEAL_ERROR TonalMDCTConceal_SaveFreqSignal( TonalMDCTConcealPtr self /* Avoid overwriting self->secondLastPowerSpectrum stored in spectralData, because it is needed if the second last and the current frame are lost and concealed using the Tonal MDCT PLC */ test(); - IF (!self->lastBlockData.tonalConcealmentActive || sub(self->lastBlockData.nSamples,nNewSamples) != 0) + IF (!self->lastBlockData.tonalConcealmentActive || NE_16(self->lastBlockData.nSamples,nNewSamples)) { - IF (sub(nNewSamples,L_FRAME_MAX) <= 0) + IF (LE_16(nNewSamples,L_FRAME_MAX)) { /* Shift the buffers */ temp = self->secondLastBlockData.spectralData; /* Save the pointer */ move16(); @@ -233,7 +231,7 @@ TONALMDCTCONCEAL_ERROR TonalMDCTConceal_SaveFreqSignal( TonalMDCTConcealPtr self } test(); - IF ((nNewSamples > 0) && (sub(nNewSamples,2*L_FRAME_MAX) <= 0)) + IF ((nNewSamples > 0) && (LE_16(nNewSamples,2*L_FRAME_MAX))) { /* Store new data */ s = getScaleFactor32(mdctSpectrum, nNewSamples); @@ -285,7 +283,7 @@ TONALMDCTCONCEAL_ERROR TonalMDCTConceal_UpdateState(TonalMDCTConcealPtr self, newBlockIsValid = 0; move16(); test(); - if((sub(nNewSamples,2*L_FRAME_MAX) <= 0) && (nNewSamples > 0)) + if((LE_16(nNewSamples,2*L_FRAME_MAX))&&(nNewSamples>0)) { newBlockIsValid = 1; move16(); @@ -374,7 +372,7 @@ static void FindPhaseDifferences( /* o: Phase k = self->pTCI->indexOfTonalPeak[i]; move16(); - IF (L_sub(Mpy_32_16_1(powerSpectrum[k-1],512/*1.0f Q9*/),Mpy_32_16_1(powerSpectrum[k+1], MAXRATIO)) >= 0) + IF (GE_32(Mpy_32_16_1(powerSpectrum[k-1],512/*1.0f Q9*/),Mpy_32_16_1(powerSpectrum[k+1], MAXRATIO))) { phaseDiff[i] = 0; /*(float)tan(0.0f*EVS_PI/bandwidth);*/ move16(); if(s_and(k,1) != 0) @@ -382,7 +380,7 @@ static void FindPhaseDifferences( /* o: Phase } ELSE { - IF (L_sub(Mpy_32_16_1(powerSpectrum[k+1],512/*1.0f Q9*/),Mpy_32_16_1(powerSpectrum[k-1], MAXRATIO)) >= 0) + IF (GE_32(Mpy_32_16_1(powerSpectrum[k+1],512/*1.0f Q9*/),Mpy_32_16_1(powerSpectrum[k-1], MAXRATIO))) { phaseDiff[i] = 12868/*EVS_PI 3Q12*/; /*(float)tan(2.0f*PI/bandwidth);*/ move16(); if(s_and(k,1) != 0) @@ -427,15 +425,15 @@ static void FindPhaseDifferences( /* o: Phase /* fractional is in the range 0..+pi */ /* we need to stay in the range -2pi..+2pi */ - if(sub(s_and(k,3),1) == 0) + if(EQ_16(s_and(k,3),1)) { L_tmp = L_add(L_tmp, 421657440l/*+1*EVS_PI Q27*/); } - if(sub(s_and(k,3),2) == 0) + if(EQ_16(s_and(k,3),2)) { L_tmp = L_sub(L_tmp, 843314880l/*+2*EVS_PI=-2*EVS_PI Q27*/); } - if(sub(s_and(k,3),3) == 0) + if(EQ_16(s_and(k,3),3)) { L_tmp = L_sub(L_tmp, 421657440l/*+3*EVS_PI=-1*EVS_PI Q27*/); } @@ -485,7 +483,7 @@ static void CalcPowerSpecAndDetectTonalComponents(TonalMDCTConcealPtr const self with self->nSamplesCore; it relevant only for nb; it has no effect to the output, but memory checker may complain otherwise due to the usage of uninitialized values */ - IF ( sub(self->nSamplesCore, self->nSamples) > 0 ) + IF ( GT_16(self->nSamplesCore, self->nSamples)) { set32_fx(powerSpectrum+self->nSamples, 0, sub(self->nSamplesCore, self->nSamples)); } @@ -621,7 +619,7 @@ TONALMDCTCONCEAL_ERROR TonalMDCTConceal_Detect( TonalMDCTConcealPtr const self, test(); test(); IF (self->lastBlockData.blockIsValid && self->secondLastBlockData.blockIsValid - && (sub(self->lastBlockData.nSamples,nSamples) == 0) && (sub(self->secondLastBlockData.nSamples,nSamples) == 0) + && (EQ_16(self->lastBlockData.nSamples,nSamples) ) && (EQ_16(self->secondLastBlockData.nSamples,nSamples) ) && (!self->secondLastBlockData.blockIsConcealed || self->secondLastBlockData.tonalConcealmentActive || (pitchLag != 0)) /* Safety if the second last frame was concealed and tonal concealment was inactive */ ) { @@ -762,9 +760,9 @@ TONALMDCTCONCEAL_ERROR TonalMDCTConceal_InsertNoise( TonalMDCTConcealPtr self, move16(); inv_samples = Inv16(self->lastBlockData.nSamples, &inv_exp); tiltFactor = round_fx(BASOP_Util_fPow(L_max(L_tmp, L_deposit_h(tiltCompFactor)), 0, L_deposit_h(inv_samples),inv_exp, &exp)); - BASOP_SATURATE_WARNING_OFF;/*next op may result in 32768*/ + BASOP_SATURATE_WARNING_OFF /*next op may result in 32768*/ tiltFactor = shl(tiltFactor, exp); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON tilt = 32767/*1.0f Q15*/; move16(); @@ -936,9 +934,9 @@ TONALMDCTCONCEAL_ERROR TonalMDCTConceal_InsertNoise( TonalMDCTConcealPtr self, } tmp = round_fx(BASOP_Util_fPow(L_deposit_h(tiltFactor), 0, L_deposit_h(self->pTCI->upperIndex[self->pTCI->numIndexes-1]-self->pTCI->lowerIndex[self->pTCI->numIndexes-1]+1),15, &exp)); - BASOP_SATURATE_WARNING_OFF;/*next op may result in 32768*/ + BASOP_SATURATE_WARNING_OFF /*next op may result in 32768*/ tmp = shl(tmp, exp); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON tilt = mult_r(tilt,tmp); FOR (l = add(self->pTCI->upperIndex[self->pTCI->numIndexes-1], 1); l < crossOverFreq; l++) @@ -1146,11 +1144,11 @@ TONALMDCTCONCEAL_ERROR TonalMDCTConceal_Apply(TonalMDCTConcealPtr self, /*IN phaseToAdd = L_mult0(self->nFramesLost,phaseDiff[i]); /*Q1*3Q12=2Q13*/ /* Move phaseToAdd to range -PI..PI */ - WHILE (L_sub(phaseToAdd, 25736l/*EVS_PI Q13*/) > 0) + WHILE (GT_32(phaseToAdd, 25736l/*EVS_PI Q13*/)) { phaseToAdd = L_sub(phaseToAdd, 51472l/*2*EVS_PI Q13*/); } - WHILE (L_sub(phaseToAdd, -25736l/*-EVS_PI Q13*/) < 0) + WHILE (LT_32(phaseToAdd, -25736l/*-EVS_PI Q13*/)) { phaseToAdd = L_add(phaseToAdd, 51472l/*2*EVS_PI Q13*/); } @@ -1160,11 +1158,11 @@ TONALMDCTCONCEAL_ERROR TonalMDCTConceal_Apply(TonalMDCTConcealPtr self, /*IN /* *pCurrentPhase and phaseToAdd are in range -PI..PI */ currentPhase = L_mac0(phaseToAdd, (*pCurrentPhase++), 1); /*2Q13+2Q13=3Q13*/ - if (L_sub(currentPhase, 25736l/*EVS_PI Q13*/) > 0) + if (GT_32(currentPhase, 25736l/*EVS_PI Q13*/)) { currentPhase = L_sub(currentPhase, 51472l/*2*EVS_PI Q13*/); } - if (L_sub(currentPhase, -25736l/*-EVS_PI Q13*/) < 0) + if (LT_32(currentPhase, -25736l/*-EVS_PI Q13*/)) { currentPhase = L_add(currentPhase, 51472l/*2*EVS_PI Q13*/); } @@ -1186,7 +1184,7 @@ TONALMDCTCONCEAL_ERROR TonalMDCTConceal_SaveTimeSignal( TonalMDCTConcealPtr self Word16 nNewSamples ) { - IF (sub(nNewSamples,self->nSamples) == 0) + IF (EQ_16(nNewSamples,self->nSamples)) { assert(nNewSamples <= L_FRAME_MAX); IF (!self->secondLastBlockData.tonalConcealmentActive) @@ -1218,7 +1216,7 @@ static void CalcPowerSpec(Word32 * mdctSpec, /* i: MDCT spectrum k = sub(31, *powerSpec_exp); /* If the signal is bellow floor, special care is needed for *powerSpec_exp */ - IF (sub(add(16-3, norm_s(floorPowerSpectrum)), k) < 0) /*extra 3 bits of headroom for MA filter in getEnvelope*/ + IF (LT_16(add(16-3, norm_s(floorPowerSpectrum)), k)) /*extra 3 bits of headroom for MA filter in getEnvelope*/ { k = sub(k, add(16-3, norm_s(floorPowerSpectrum))); /*extra 3 bits of headroom for MA filter in getEnvelope*/ *powerSpec_exp = add(*powerSpec_exp, k); diff --git a/lib_dec/transition_dec_fx.c b/lib_dec/transition_dec_fx.c index b060409d942f56a7cadacc9d7a82b67f47f416bc..dcbd20ea4bb18bfa754015aa7c8abc39d1e0aa12 100644 --- a/lib_dec/transition_dec_fx.c +++ b/lib_dec/transition_dec_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -7,8 +7,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*----------------------------------------------------------------------* * Local functions @@ -71,11 +69,11 @@ void transition_dec_fx( * zero adaptive contribution (glottal shape codebook search not * in first subframe(s) ) *---------------------------------------------------------------------*/ - IF(sub(tc_subfr, add(i_subfr,TC_0_192)) > 0) + IF(GT_16(tc_subfr, add(i_subfr,TC_0_192))) { set16_fx(&exc[i_subfr], 0, L_SUBFR); - IF( sub(L_frame,L_FRAME) == 0 ) + IF( EQ_16(L_frame,L_FRAME)) { set16_fx(&bwe_exc[i_subfr*HIBND_ACB_L_FAC], 0, (Word16) (L_SUBFR*HIBND_ACB_L_FAC)); /* set past excitation buffer to 0 */ } @@ -96,11 +94,11 @@ void transition_dec_fx( * glottal shape codebook search *---------------------------------------------------------------------*/ - ELSE IF(((sub(tc_subfr,i_subfr) >= 0) && (sub(tc_subfr,i_subfr) <= TC_0_192) )) + ELSE IF(((GE_16(tc_subfr,i_subfr))&&(LE_16(sub(tc_subfr,i_subfr),TC_0_192)))) { set16_fx( exc-L_EXC_MEM, 0, L_EXC_MEM ); /* set past excitation buffer to 0 */ - IF( sub(L_frame,L_FRAME) == 0 ) + IF( EQ_16(L_frame,L_FRAME)) { set16_fx( bwe_exc-PIT_MAX*HIBND_ACB_L_FAC, 0, PIT_MAX*HIBND_ACB_L_FAC); /* set past excitation buffer to 0 */ } @@ -127,14 +125,14 @@ void transition_dec_fx( * construction and the pitch period coding is used) *---------------------------------------------------------------------*/ - ELSE IF ( sub(tc_subfr,i_subfr) < 0) + ELSE IF ( LT_16(tc_subfr,i_subfr)) { - IF( sub(L_frame,L_FRAME) == 0) + IF( EQ_16(L_frame,L_FRAME)) { *Jopt_flag = 1; move16(); test(); - IF( (sub(sub(i_subfr,tc_subfr),L_SUBFR) >= 0) && (sub(sub(i_subfr,tc_subfr),L_SUBFR + TC_0_192) <= 0) ) + IF( (GE_16(sub(i_subfr,tc_subfr),L_SUBFR))&&(LE_16(sub(i_subfr,tc_subfr),L_SUBFR+TC_0_192))) { pit_flag = 0; move16(); @@ -144,9 +142,9 @@ void transition_dec_fx( pit_flag = L_SUBFR; move16(); } - IF( sub(tc_subfr,TC_0_0) == 0) + IF( EQ_16(tc_subfr,TC_0_0)) { - IF( sub(i_subfr,L_SUBFR) == 0 ) + IF( EQ_16(i_subfr,L_SUBFR)) { limit_T0_fx( L_FRAME, 8, pit_flag, limit_flag, *T0, 0, T0_min, T0_max ); } @@ -170,7 +168,7 @@ void transition_dec_fx( test(); test(); test(); - IF( (sub(i_subfr,L_SUBFR) == 0) && (sub(tc_subfr,TC_0_128) >= 0) ) + IF( (EQ_16(i_subfr,L_SUBFR))&&(GE_16(tc_subfr,TC_0_128))) { /*--------------------------------------------------------* * second glottal impulse is in the 3rd or 4th subframe @@ -189,7 +187,7 @@ void transition_dec_fx( set16_fx( &bwe_exc[i_subfr*HIBND_ACB_L_FAC], 0, (Word16)(L_SUBFR*HIBND_ACB_L_FAC) ); } - ELSE IF( (sub(i_subfr,L_SUBFR) == 0) && (sub(tc_subfr,TC_0_64) == 0) ) + ELSE IF( (EQ_16(i_subfr,L_SUBFR))&&(EQ_16(tc_subfr,TC_0_64))) { /*--------------------------------------------------------* * second glottal impulse is in the 2nd subframe, @@ -197,7 +195,7 @@ void transition_dec_fx( *--------------------------------------------------------*/ pit_start = PIT_MIN; move16(); - if (sub(PIT_MIN,(*position)) > 0) + if (GT_16(PIT_MIN,(*position))) { pit_start = sub(L_SUBFR, *position); } @@ -229,7 +227,7 @@ void transition_dec_fx( } } - ELSE IF( (sub(i_subfr,2*L_SUBFR) == 0) && (sub(tc_subfr,TC_0_128) == 0) ) + ELSE IF( (EQ_16(i_subfr,2*L_SUBFR))&&(EQ_16(tc_subfr,TC_0_128))) { /*--------------------------------------------------------* * second glottal impulse is in the 3rd subframe @@ -259,7 +257,7 @@ void transition_dec_fx( } } - ELSE IF((sub(i_subfr,2*L_SUBFR) == 0) && (sub(tc_subfr,TC_0_192) == 0)) + ELSE IF((EQ_16(i_subfr,2*L_SUBFR))&&(EQ_16(tc_subfr,TC_0_192))) { /*--------------------------------------------------------* * second glottal impulse is in the 4th subframe @@ -277,7 +275,7 @@ void transition_dec_fx( set16_fx( &exc[i_subfr], 0, (Word16)(L_SUBFR+1) ); set16_fx( &bwe_exc[i_subfr*HIBND_ACB_L_FAC], 0, (Word16)(L_SUBFR*HIBND_ACB_L_FAC) ); } - ELSE IF( (sub(i_subfr,3*L_SUBFR) == 0) && (sub(tc_subfr,TC_0_192) == 0)) + ELSE IF( (EQ_16(i_subfr,3*L_SUBFR))&&(EQ_16(tc_subfr,TC_0_192))) { /*--------------------------------------------------------* * second glottal impulse is in the 4th subframe @@ -289,7 +287,7 @@ void transition_dec_fx( index = (Word16)get_next_indice_fx( st_fx, nBits ); - IF( sub(index,shl(sub(pit_limit,pit_start),1)) < 0) + IF( LT_16(index,shl(sub(pit_limit,pit_start),1))) { *T0 = add( pit_start, shr(index,1)); move16(); @@ -306,7 +304,7 @@ void transition_dec_fx( } /* biterror detection mechanism */ - IF( sub(add((*T0<<2),*T0_frac),add((PIT_MAX<<2),2)) > 0 ) + IF( GT_16(add((*T0<<2),*T0_frac),add((PIT_MAX<<2),2))) { *T0 = L_SUBFR; move16(); @@ -328,7 +326,7 @@ void transition_dec_fx( } - ELSE IF( (sub(i_subfr,3*L_SUBFR) == 0) && (sub(tc_subfr,TC_0_128) == 0) ) + ELSE IF( (EQ_16(i_subfr,3*L_SUBFR))&&(EQ_16(tc_subfr,TC_0_128))) { /*--------------------------------------------------------* * second glottal impulse in the 3rd subframe @@ -396,7 +394,7 @@ void transition_dec_fx( test(); test(); test(); - IF( (sub(tc_subfr,2*L_SUBFR) >= 0) && (sub(i_subfr,3*L_SUBFR) == 0) ) + IF( (GE_16(tc_subfr,2*L_SUBFR))&&(EQ_16(i_subfr,3*L_SUBFR))) { tmp = shl(add(shl(*T0,2),*T0_frac),4); (*pt_pitch) -= 3; @@ -413,7 +411,7 @@ void transition_dec_fx( (*pt_pitch) ++; move16(); } - ELSE IF( (sub(tc_subfr,L_SUBFR) == 0) && (sub(i_subfr,2*L_SUBFR) == 0) ) + ELSE IF( (EQ_16(tc_subfr,L_SUBFR))&&(EQ_16(i_subfr,2*L_SUBFR))) { tmp = shl(add(shl(*T0,2),*T0_frac),4); (*pt_pitch) -= 2; @@ -427,7 +425,7 @@ void transition_dec_fx( move16(); } - ELSE IF( (sub(tc_subfr,TC_0_64) == 0) && (sub(i_subfr,L_SUBFR) == 0) ) + ELSE IF( (EQ_16(tc_subfr,TC_0_64))&&(EQ_16(i_subfr,L_SUBFR))) { tmp = shl(add(shl(*T0,2),*T0_frac),4); (*pt_pitch) -= 1; @@ -436,7 +434,7 @@ void transition_dec_fx( move16(); /*Q6*/ (*pt_pitch)++; } - ELSE IF( (sub(tc_subfr,TC_0_128) == 0) && (sub(i_subfr,2*L_SUBFR) == 0) ) + ELSE IF( (EQ_16(tc_subfr,TC_0_128))&&(EQ_16(i_subfr,2*L_SUBFR))) { tmp = shl(add(shl(*T0,2),*T0_frac),4); (*pt_pitch) -= 2; @@ -449,7 +447,7 @@ void transition_dec_fx( (*pt_pitch) ++; move16(); } - ELSE IF( (sub(tc_subfr,TC_0_192) == 0) && (sub(i_subfr,3*L_SUBFR) == 0) ) + ELSE IF( (EQ_16(tc_subfr,TC_0_192))&&(EQ_16(i_subfr,3*L_SUBFR))) { tmp = shl(add(shl(*T0,2),*T0_frac),4); (*pt_pitch) -= 3; @@ -470,13 +468,13 @@ void transition_dec_fx( ELSE /* L_frame == L_FRAME16k */ { test(); - if( sub(i_subfr,2*L_SUBFR) >= 0) + if( GE_16(i_subfr,2*L_SUBFR)) { limit_flag = 1; move16(); } - IF( sub(sub(i_subfr, tc_subfr), L_SUBFR) == 0 ) + IF( EQ_16(sub(i_subfr, tc_subfr), L_SUBFR)) { limit_T0_fx( L_FRAME16k, 8, 0, limit_flag, *T0, *T0_frac, T0_min, T0_max ); } @@ -494,11 +492,11 @@ void transition_dec_fx( * Find adaptive part of excitation, encode pitch period *-----------------------------------------------------------------*/ - IF( sub(nBits,10) == 0 ) + IF( EQ_16(nBits,10)) { pit16k_Q_dec_fx( index, nBits, limit_flag, T0, T0_frac, T0_min, T0_max, &st_fx->BER_detect ); } - ELSE IF( sub(nBits,8) == 0 ) /* tc_subfr==0 && i_subfr==L_SUBFR */ + ELSE IF( EQ_16(nBits,8)) /* tc_subfr==0 && i_subfr==L_SUBFR */ { /*-----------------------------------------------------------------------------* * The pitch range is encoded absolutely with 8 bits and is divided as follows: @@ -506,7 +504,7 @@ void transition_dec_fx( * PIT16k_FR2_TC0_2SUBFR to 2*L_SUBFR resolution 1/2 (frac = 0 or 2) *-----------------------------------------------------------------------------*/ - IF( sub(index,(PIT16k_FR2_TC0_2SUBFR-PIT16k_MIN)*4) < 0 )/*(PIT16k_FR2_TC0_2SUBFR-PIT16k_MIN)*4*/ + IF( LT_16(index,(PIT16k_FR2_TC0_2SUBFR-PIT16k_MIN)*4))/*(PIT16k_FR2_TC0_2SUBFR-PIT16k_MIN)*4*/ { *T0 = add(PIT16k_MIN,shr(index,2)); move16(); @@ -527,7 +525,7 @@ void transition_dec_fx( } /* biterror detection mechanism */ - IF( sub(add((*T0<<2),*T0_frac),((2*L_SUBFR)<<2)) > 0 ) + IF( GT_16(add((*T0<<2),*T0_frac),((2*L_SUBFR)<<2))) { *T0 = L_SUBFR; move16(); @@ -537,11 +535,11 @@ void transition_dec_fx( move16(); } } - ELSE IF( sub(nBits,6) == 0 ) + ELSE IF( EQ_16(nBits,6)) { delta_pit_dec_fx( 4, index, T0, T0_frac, *T0_min ); } - IF( sub(nBits,6) == 0 ) + IF( EQ_16(nBits,6)) { limit_T0_fx( L_FRAME16k, 8, L_SUBFR, limit_flag, *T0, *T0_frac, T0_min, T0_max ); /* find T0_min and T0_max */ } @@ -551,7 +549,7 @@ void transition_dec_fx( * - LP filtering of the adaptive excitation (if non-zero) *-----------------------------------------------------------------*/ test(); - IF( (sub(i_subfr,L_SUBFR) == 0) && (sub(*T0,2*L_SUBFR) == 0) ) + IF( (EQ_16(i_subfr,L_SUBFR))&&(EQ_16(*T0,2*L_SUBFR))) { /* no adaptive excitation in the second subframe */ set16_fx( &exc[i_subfr], 0, L_SUBFR+1 ); @@ -586,7 +584,7 @@ void transition_dec_fx( *---------------------------------------------------------------------*/ test(); test(); - IF( (sub(sub(i_subfr, tc_subfr),L_SUBFR) == 0) || (tc_subfr==0 && sub(i_subfr,2*L_SUBFR)==0) ) + IF( (EQ_16(sub(i_subfr, tc_subfr),L_SUBFR))||(tc_subfr==0&&EQ_16(i_subfr,2*L_SUBFR))) { /*index = i_subfr/L_SUBFR;*/ index = shr(i_subfr,6); @@ -657,7 +655,7 @@ static void tc_dec_fx( /*----------------------------------------------------------------* * find the number of bits *----------------------------------------------------------------*/ - IF( sub(L_frame,L_FRAME) == 0 ) + IF( EQ_16(L_frame,L_FRAME)) { nBits = ACB_bits_tbl[BIT_ALLOC_IDX_fx(core_brate, TRANSITION, i_subfr, TC_SUBFR2IDX_fx(tc_subfr))]; move16(); @@ -671,14 +669,14 @@ static void tc_dec_fx( /*----------------------------------------------------------------* * decode parameter T0 (pitch period) *----------------------------------------------------------------*/ - IF( sub(L_frame,L_FRAME) == 0 ) + IF( EQ_16(L_frame,L_FRAME)) { test(); test(); test(); test(); test(); - IF ( ((i_subfr == 0) && ((tc_subfr == 0) || (sub(tc_subfr,TC_0_64) == 0) || (sub(tc_subfr,TC_0_128) == 0) || (sub(tc_subfr,TC_0_192) == 0) )) || (sub(tc_subfr,L_SUBFR) == 0) ) + IF ( ((i_subfr == 0) && ((tc_subfr == 0) || (EQ_16(tc_subfr,TC_0_64))||(EQ_16(tc_subfr,TC_0_128))||(EQ_16(tc_subfr,TC_0_192))))||(EQ_16(tc_subfr,L_SUBFR))) { *T0 = L_SUBFR; move16(); @@ -689,7 +687,7 @@ static void tc_dec_fx( { i = (Word16)get_next_indice_fx( st_fx, nBits ); - IF( sub(nBits,9) == 0 ) + IF( EQ_16(nBits,9)) { abs_pit_dec_fx( 4, i, 0, T0, T0_frac ); } @@ -712,7 +710,7 @@ static void tc_dec_fx( } ELSE { - IF( sub(tc_subfr,TC_0_0) == 0 ) + IF( EQ_16(tc_subfr,TC_0_0)) { delta_pit_dec_fx( 2, i, T0, T0_frac, PIT_MIN-1 ); } @@ -728,9 +726,9 @@ static void tc_dec_fx( i = (Word16)get_next_indice_fx( st_fx, nBits ); move16(); - IF( sub(nBits,10) == 0 ) + IF( EQ_16(nBits,10)) { - IF( sub(i,(PIT16k_FR2_EXTEND_10b-PIT16k_MIN_EXTEND)*4) < 0 ) + IF( LT_16(i,(PIT16k_FR2_EXTEND_10b-PIT16k_MIN_EXTEND)*4)) { *T0 = add(PIT16k_MIN_EXTEND,shr(i,2)); move16(); @@ -746,7 +744,7 @@ static void tc_dec_fx( (*T0_frac) = shl(*T0_frac,1); } } - ELSE IF( sub(nBits,6) == 0) + ELSE IF( EQ_16(nBits,6)) { *T0 = add(PIT16k_MIN ,shr(i,1)); move16(); @@ -788,7 +786,7 @@ static void tc_dec_fx( tempS = 4; move16(); test(); - if (sub(imp_gain, 3) <= 0) + if (LE_16(imp_gain, 3)) { tempS = 7; move16(); @@ -826,7 +824,7 @@ static void tc_dec_fx( pred_lt4_tc_fx( exc, *T0, *T0_frac, inter4_2_fx, imp_pos, i_subfr ); - IF( sub(L_frame,L_FRAME) == 0 ) + IF( EQ_16(L_frame,L_FRAME)) { interp_code_5over2_fx(&exc[i_subfr], &bwe_exc[i_subfr * HIBND_ACB_L_FAC], L_SUBFR); } @@ -853,7 +851,7 @@ Word16 tc_classif_fx( { Word16 tc_subfr, indice; - IF( sub(L_frame,L_FRAME) == 0 ) + IF( EQ_16(L_frame,L_FRAME)) { if ( get_next_indice_fx( st_fx, 1 ) ) { @@ -907,7 +905,7 @@ Word16 tc_classif_fx( { indice = (Word16) get_next_indice_fx( st_fx, 2 ); - IF( sub(indice,3) < 0 ) + IF( LT_16(indice,3)) { tc_subfr = shl(indice, 6); } diff --git a/lib_dec/updt_dec_fx.c b/lib_dec/updt_dec_fx.c index 88fe906357d8031786367647f8cdc54d805626ef..a0fcfc9bb153711f9ce73359bc27f97f23520586 100644 --- a/lib_dec/updt_dec_fx.c +++ b/lib_dec/updt_dec_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -8,8 +8,6 @@ #include "prot_fx.h" /* Function prototypes */ #include /* Debug prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*-------------------------------------------------------------------* * updt_dec() @@ -49,14 +47,14 @@ void updt_dec_fx( test(); test(); test(); - if( sub(coder_type,INACTIVE) == 0 || (sub(st_fx->bpf_off_fx,1) == 0 && sub(coder_type,AUDIO) != 0 && sub(coder_type,TRANSITION) != 0) ) + if( EQ_16(coder_type,INACTIVE)||(EQ_16(st_fx->bpf_off_fx,1)&&NE_16(coder_type,AUDIO)&&NE_16(coder_type,TRANSITION))) { st_fx->last_coder_type_fx = UNVOICED; move16(); } test(); test(); - if( (sub(coder_type,AUDIO) != 0 || st_fx->Last_GSC_noisy_speech_flag_fx != 0) && st_fx->Last_GSC_pit_band_idx_fx > 0 ) + if( (NE_16(coder_type,AUDIO)||st_fx->Last_GSC_noisy_speech_flag_fx!=0)&&st_fx->Last_GSC_pit_band_idx_fx>0) { st_fx->Last_GSC_pit_band_idx_fx = 0; move16(); /*The temporal contribution of the GSC is meaningless after 1 frame lost for inactive & unvoiced content */ @@ -64,7 +62,7 @@ void updt_dec_fx( /* this ensures that st_fx->last_coder_type_fx is never set to INACTIVE in case of AVQ inactive because the FEC does not distinguish between GSC inactive and AVQ inactive */ test(); - if( L_sub(st_fx->total_brate_fx,ACELP_24k40) > 0 && sub(coder_type,INACTIVE) == 0 ) + if( GT_32(st_fx->total_brate_fx,ACELP_24k40)&&EQ_16(coder_type,INACTIVE)) { st_fx->last_coder_type_fx = GENERIC; move16(); @@ -72,7 +70,7 @@ void updt_dec_fx( test(); test(); test(); - IF( sub(st_fx->Opt_AMR_WB_fx,1) == 0 && sub(coder_type,INACTIVE) == 0 && L_sub(st_fx->core_brate_fx,SID_1k75) != 0 && L_sub(st_fx->core_brate_fx,FRAME_NO_DATA) != 0 ) + IF( EQ_16(st_fx->Opt_AMR_WB_fx,1)&&EQ_16(coder_type,INACTIVE)&&NE_32(st_fx->core_brate_fx,SID_1k75)&&NE_32(st_fx->core_brate_fx,FRAME_NO_DATA)) { /* overwrite previous coding type to help FEC */ st_fx->last_coder_type_fx = UNVOICED; @@ -87,7 +85,7 @@ void updt_dec_fx( st_fx->last_voice_factor_fx = voice_factors[NB_SUBFR16k-1]; move16(); - if( sub(st_fx->L_frame_fx,L_FRAME) == 0 ) + if( EQ_16(st_fx->L_frame_fx,L_FRAME)) { st_fx->last_voice_factor_fx = voice_factors[NB_SUBFR-1]; move16(); @@ -127,7 +125,7 @@ void updt_dec_fx( move32(); } Copy( &st_fx->mem_pitch_gain[2], &st_fx->mem_pitch_gain[L_frame/L_SUBFR+2], L_frame/L_SUBFR ); - IF (sub(L_frame , L_FRAME) == 0) + IF (EQ_16(L_frame , L_FRAME)) { st_fx->mem_pitch_gain[2] = gain_buf[3]; move16(); @@ -158,12 +156,12 @@ void updt_dec_fx( Copy( lsf_new_fx, st_fx->lsfoldbfi0_fx, M ); /* update of pitch and voicing information for HQ FEC */ - IF ( sub(st_fx->last_core_fx,HQ_CORE) != 0 ) + IF ( NE_16(st_fx->last_core_fx,HQ_CORE)) { st_fx->HqVoicing_fx = 1; move16(); test(); - if( !st_fx->Opt_AMR_WB_fx && sub(coder_type,UNVOICED) == 0 ) + if( !st_fx->Opt_AMR_WB_fx && EQ_16(coder_type,UNVOICED)) { st_fx->HqVoicing_fx = 0; move16(); @@ -199,7 +197,7 @@ void updt_IO_switch_dec_fx( ) { Word16 xsp_tmp[M]; - IF( sub(st_fx->last_core_fx,AMR_WB_CORE) == 0 ) /* switching to EVS primary mode */ + IF( EQ_16(st_fx->last_core_fx,AMR_WB_CORE)) /* switching to EVS primary mode */ { /* AMR-WB IO mode uses ISF(ISP), but EVS primary mode mode LSF(LSP) */ Copy( stable_LSP_fx, xsp_tmp, M ); @@ -226,7 +224,7 @@ void updt_IO_switch_dec_fx( wb_tbe_extras_reset_fx( st_fx->mem_genSHBexc_filt_down_wb2_fx, st_fx->mem_genSHBexc_filt_down_wb3_fx ); wb_tbe_extras_reset_synth_fx( st_fx->state_lsyn_filt_shb_fx, st_fx->state_lsyn_filt_dwn_shb_fx, st_fx->state_32and48k_WB_upsample_fx, st_fx->mem_resamp_HB_fx ); - IF( sub(output_frame,L_FRAME32k) >= 0 ) + IF( GE_16(output_frame,L_FRAME32k)) { swb_tbe_reset_fx( st_fx->mem_csfilt_fx, st_fx->mem_genSHBexc_filt_down_shb_fx, st_fx->state_lpc_syn_fx, st_fx->syn_overlap_fx, st_fx->state_syn_shbexc_fx, &st_fx->tbe_demph_fx, &st_fx->tbe_premph_fx @@ -235,7 +233,7 @@ void updt_IO_switch_dec_fx( swb_tbe_reset_synth_fx( st_fx->genSHBsynth_Hilbert_Mem_fx, st_fx->genSHBsynth_state_lsyn_filt_shb_local_fx ); } - IF( sub(output_frame,L_FRAME48k) == 0 ) + IF( EQ_16(output_frame,L_FRAME48k)) { st_fx->prev_fb_ener_adjust_fx = 0; move16(); @@ -279,7 +277,7 @@ void updt_IO_switch_dec_fx( move16(); move16(); move16(); - if(sub(st_fx->last_flag_filter_NB, 1) == 0) + if(EQ_16(st_fx->last_flag_filter_NB, 1)) st_fx->cldfbSyn_fx->bandsToZero = 0; st_fx->last_active_bandsToZero_bwdec = 0; st_fx->flag_NB_bwddec = 0; @@ -383,12 +381,12 @@ void updt_bw_switching_fx( st_fx->last_bwidth_fx = st_fx->bwidth_fx; move32(); - IF( sub(st_fx->core_fx, ACELP_CORE) == 0 ) + IF( EQ_16(st_fx->core_fx, ACELP_CORE)) { st_fx->last_inner_frame_fx = L_FRAME32k; move16(); test(); - if( sub(st_fx->bwidth_fx, WB) == 0 && st_fx->bws_cnt_fx == 0 ) + if( EQ_16(st_fx->bwidth_fx, WB)&&st_fx->bws_cnt_fx==0) { st_fx->last_inner_frame_fx = L_FRAME16k; move16(); @@ -396,7 +394,7 @@ void updt_bw_switching_fx( st_fx->prev_weight1_fx = 16384; move16(); - if(sub(st_fx->prev_mode_fx, HARMONIC) == 0) + if(EQ_16(st_fx->prev_mode_fx, HARMONIC)) { st_fx->prev_weight1_fx = 6554; move16(); @@ -407,19 +405,19 @@ void updt_bw_switching_fx( test(); test(); test(); - IF( !(sub(st_fx->last_inner_frame_fx, L_FRAME16k) >= 0 && sub(inner_frame_tbl[st_fx->bwidth_fx], L_FRAME16k) <= 0 && st_fx->bws_cnt_fx > 0 && sub(st_fx->bws_cnt_fx, N_WS2N_FRAMES) < 0) ) + IF( !(GE_16(st_fx->last_inner_frame_fx, L_FRAME16k)&&LE_16(inner_frame_tbl[st_fx->bwidth_fx],L_FRAME16k)&&st_fx->bws_cnt_fx>0&<_16(st_fx->bws_cnt_fx,N_WS2N_FRAMES))) { st_fx->last_inner_frame_fx = inner_frame_tbl[st_fx->bwidth_fx]; move16(); } test(); - IF(sub(inner_frame_tbl[st_fx->bwidth_fx], L_FRAME32k) >= 0 || L_sub(st_fx->core_brate_fx, HQ_16k40) <= 0) + IF(GE_16(inner_frame_tbl[st_fx->bwidth_fx], L_FRAME32k)||LE_32(st_fx->core_brate_fx,HQ_16k40)) { st_fx->prev_weight1_fx = 16384; move16(); test(); - if(sub(st_fx->prev_hqswb_clas_fx, HQ_HARMONIC) == 0 || sub(st_fx->prev_hqswb_clas_fx, HQ_HVQ) == 0) + if(EQ_16(st_fx->prev_hqswb_clas_fx, HQ_HARMONIC)||EQ_16(st_fx->prev_hqswb_clas_fx,HQ_HVQ)) { st_fx->prev_weight1_fx = 6554; move16(); @@ -467,12 +465,12 @@ void updt_dec_common_fx( move16(); test(); test(); - IF( (sub(st_fx->rf_frame_type,RF_TCXFD) >= 0 && sub(st_fx->rf_frame_type,RF_TCXTD2) <= 0 && st_fx->use_partial_copy && st_fx->bfi_fx) || !st_fx->bfi_fx ) + IF( (GE_16(st_fx->rf_frame_type,RF_TCXFD)&&LE_16(st_fx->rf_frame_type,RF_TCXTD2)&&st_fx->use_partial_copy&&st_fx->bfi_fx)||!st_fx->bfi_fx) { test(); test(); test(); - if( st_fx->bfi_fx && (sub(st_fx->last_good_fx, UNVOICED_TRANSITION) <= 0) && (sub(st_fx->clas_dec, UNVOICED_TRANSITION) > 0) && st_fx->last_con_tcx ) + if( st_fx->bfi_fx && (LE_16(st_fx->last_good_fx, UNVOICED_TRANSITION))&&(GT_16(st_fx->clas_dec,UNVOICED_TRANSITION))&&st_fx->last_con_tcx) { st_fx->tcxConceal_recalc_exc = 1; move16(); @@ -489,12 +487,12 @@ void updt_dec_common_fx( st_fx->prev_rf_frame_type = INACTIVE; } - if (sub(st_fx->m_frame_type, ACTIVE_FRAME) == 0 && (st_fx->bfi_fx != 1 || st_fx->use_partial_copy != 0)) + if (EQ_16(st_fx->m_frame_type, ACTIVE_FRAME)&&(st_fx->bfi_fx!=1||st_fx->use_partial_copy!=0)) { st_fx->rf_flag_last = st_fx->rf_flag; } - IF( sub(st_fx->codec_mode,MODE1)==0 ) + IF( EQ_16(st_fx->codec_mode,MODE1)) { test(); if( !st_fx->bfi_fx && st_fx->core_brate_fx > SID_2k40 ) @@ -508,7 +506,7 @@ void updt_dec_common_fx( st_fx->last_core_fx = st_fx->core_fx; st_fx->last_hq_core_type_fx = hq_core_type_fx; } - ELSE IF( sub(st_fx->codec_mode,MODE2)==0 ) + ELSE IF( EQ_16(st_fx->codec_mode,MODE2)) { test(); if ((!st_fx->bfi_fx) && (st_fx->last_is_cng==0)) @@ -517,7 +515,7 @@ void updt_dec_common_fx( st_fx->last_active_brate_fx = st_fx->total_brate_fx; } /* INFO: moved from update_decoder_LPD_cng() */ - if (sub(st_fx->m_frame_type,ACTIVE_FRAME)!=0) + if (NE_16(st_fx->m_frame_type,ACTIVE_FRAME)) { move16(); st_fx->last_is_cng = 1; @@ -541,14 +539,14 @@ void updt_dec_common_fx( test(); test(); test(); - IF( ((L_sub(st_fx->core_brate_fx,SID_2k40) <= 0) && sub(st_fx->cng_type_fx, FD_CNG) == 0) - || (st_fx->tcxonly && sub(st_fx->codec_mode,MODE2)==0) + IF( ((LE_32(st_fx->core_brate_fx,SID_2k40))&&EQ_16(st_fx->cng_type_fx,FD_CNG)) + || (st_fx->tcxonly && EQ_16(st_fx->codec_mode,MODE2)) ) { /* reset LP memories */ set16_fx( st_fx->mem_MA_fx,0, M ); - IF( L_sub(st_fx->sr_core,16000) == 0 ) + IF( EQ_32(st_fx->sr_core,16000)) { Copy( GEWB2_Ave_fx, st_fx->mem_AR_fx, M ); } @@ -579,7 +577,7 @@ void update_decoder_LPD_cng( Decoder_State_fx *st, Word16 coder_type, Word16 *ti E_LPC_a_lsp_conversion( A, lsp, st->lsp_old_fx, M ); /* LSP -> LSF */ - IF(sub(st->L_frame_fx, L_FRAME16k)== 0) + IF(EQ_16(st->L_frame_fx, L_FRAME16k)) { lsp2lsf_fx( lsp, lsf, M, INT_FS_16k_FX ); } @@ -617,7 +615,7 @@ void update_decoder_LPD_cng( Decoder_State_fx *st, Word16 coder_type, Word16 *ti /* Update excitation memory */ assert(st->L_frame_fx < L_EXC_MEM_DEC); - IF(sub(add(st->Q_syn,1),st->Q_exc) != 0) + IF(NE_16(add(st->Q_syn,1),st->Q_exc)) { Scale_sig(st->old_exc_fx, L_EXC_MEM_DEC, sub(add(st->Q_syn,1),st->Q_exc)); } @@ -668,7 +666,7 @@ void update_decoder_LPD_cng( Decoder_State_fx *st, Word16 coder_type, Word16 *ti Copy( A, &(st->mem_Aq[(M+1)]), M+1 ); Copy( A, &(st->mem_Aq[2*(M+1)]), M+1 ); Copy( A, &(st->mem_Aq[3*(M+1)]), M+1 ); - IF( sub(st->L_frame_fx, L_FRAME16k) == 0 ) + IF( EQ_16(st->L_frame_fx, L_FRAME16k)) { Copy( A, &(st->mem_Aq[4*(M+1)]), M+1 ); } diff --git a/lib_dec/vlpc_1st_dec.c b/lib_dec/vlpc_1st_dec.c index e51ca0c44c6825518b2c22bcd55df7b7a479da32..351a6356bbae60c85bd487701ba53a3d9410c0bd 100644 --- a/lib_dec/vlpc_1st_dec.c +++ b/lib_dec/vlpc_1st_dec.c @@ -1,12 +1,10 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include #include "prot_fx.h" #include "stl.h" -#include "wmc_auto.h" - extern Word16 const dico_lsf_abs_8b[]; diff --git a/lib_dec/vlpc_2st_dec.c b/lib_dec/vlpc_2st_dec.c index fd3a18d9dc9c07e7ab376df0a231b153315ab65e..10ff36eaa2e5c0723ac44e2f082660cd9f061aa2 100644 --- a/lib_dec/vlpc_2st_dec.c +++ b/lib_dec/vlpc_2st_dec.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include #include #include "prot_fx.h" #include "stl.h" -#include "wmc_auto.h" - void vlpc_2st_dec( Word16 *lsfq, /* i/o: i:1st stage o:1st+2nd stage */ @@ -37,15 +35,15 @@ void vlpc_2st_dec( /* reorder */ sort_fx(lsfq, 0, M-1); - IF ( L_sub(sr_core,16000) == 0 ) + IF ( EQ_32(sr_core,16000)) { gap = 102; } - ELSE IF ( L_sub(sr_core,25600) == 0 ) + ELSE IF ( EQ_32(sr_core,25600)) { gap = 64; } - ELSE IF ( L_sub(sr_core,32000) == 0 ) + ELSE IF ( EQ_32(sr_core,32000)) { gap = 51; } diff --git a/lib_dec/voiced_dec_fx.c b/lib_dec/voiced_dec_fx.c index 7c0f7b86881e0619da4aa7594933537827fbf844..53187e5cf3295ae01ca9bb67e6b31ec6810f5c4e 100644 --- a/lib_dec/voiced_dec_fx.c +++ b/lib_dec/voiced_dec_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -7,8 +7,6 @@ #include "rom_com_fx.h" #include "log2.h" #include "stl.h" -#include "wmc_auto.h" - /*===================================================================*/ /* FUNCTION : void ppp_voiced_decoder_fx () */ @@ -72,14 +70,14 @@ void ppp_voiced_decoder_fx( Word16 temp_Fs; test(); - IF (sub(st_fx->bwidth_fx,WB) == 0 || sub(st_fx->bwidth_fx,SWB) == 0) + IF (EQ_16(st_fx->bwidth_fx,WB)||EQ_16(st_fx->bwidth_fx,SWB)) { upper_cut_off_freq_of_interest = 0x2800; move16();/*4000 normalized to 12800 in Q15 */ upper_cut_off_freq = 0x4000; move16();/*6400 normalized to 12800 in Q15 */ } - ELSE IF (sub(st_fx->bwidth_fx,NB) == 0 ) + ELSE IF (EQ_16(st_fx->bwidth_fx,NB)) { upper_cut_off_freq_of_interest = 0x2100; move16();/*3300 normalized to 12800 in Q15 */ @@ -89,7 +87,7 @@ void ppp_voiced_decoder_fx( temp_Fs = 8000; - if ( sub( st_fx->bwidth_fx, WB) == 0 ) + if ( EQ_16( st_fx->bwidth_fx, WB)) { temp_Fs = 16000; move16(); @@ -138,7 +136,7 @@ void ppp_voiced_decoder_fx( temp_l_fx = l; move16(); - IF (sub(temp_pl_fx,temp_l_fx) != 0) + IF (NE_16(temp_pl_fx,temp_l_fx)) { FOR(k=0; klast_coder_type_fx,UNVOICED) == 0) + if (EQ_16(st_fx->last_coder_type_fx,UNVOICED)) { pl = l; move16(); /* if prev frame was sil/uv*/ @@ -172,7 +170,7 @@ void ppp_voiced_decoder_fx( } temp = shr(temp,2);/*Q0 */ - if (sub(pl,temp) > 0) + if (GT_16(pl,temp)) { pl = shr(pl,1); } @@ -189,13 +187,13 @@ void ppp_voiced_decoder_fx( temp = shr(temp,2);/*Q0 */ test(); - if (sub(shl(pl,1),PIT_MAX) <= 0 && sub(pl,temp) <= 0) + if (LE_16(shl(pl,1),PIT_MAX)&&LE_16(pl,temp)) { pl = shl(pl,1); } /* Restoring PPP memories when the last frame is non-PPP or full-rate PPP */ - IF (sub(st_fx->last_ppp_mode_dec_fx,1) != 0) + IF (NE_16(st_fx->last_ppp_mode_dec_fx,1)) { GetSinCosTab_fx(pl, S_fx, C_fx); @@ -310,14 +308,14 @@ void ppp_voiced_decoder_fx( CURRP_Q_D_FX->nH_4kHz_fx = round_fx(L_shl(tempnH_fx,16-6));/*Q0 */ - IF(sub(sub(upper_cut_off_freq,shr((Word16)L_mult(diff,CURRP_Q_D_FX->nH_fx),1)),diff)>=0) + IF(GE_16(sub(upper_cut_off_freq,shr((Word16)L_mult(diff,CURRP_Q_D_FX->nH_fx),1)),diff)) { CURRP_Q_D_FX->nH_fx = add(CURRP_Q_D_FX->nH_fx,1); } tempnH_fx = L_mult0(extract_l(temp32_fx),CURRP_Q_D_FX->nH_4kHz_fx);/* */ tempnH_fx = L_sub((Word32)256000,tempnH_fx);/*Q6 */ - if(L_sub(tempnH_fx,temp32_fx)>=0) + if(GE_32(tempnH_fx,temp32_fx)) { CURRP_Q_D_FX->nH_4kHz_fx = add(CURRP_Q_D_FX->nH_4kHz_fx,1); } diff --git a/lib_dec/voip_client.c b/lib_dec/voip_client.c index 0a16d20183fba67b8a40b86a20569352f019fbe5..bd2afdf835063c577a377df501f1ebbc1d810854 100644 --- a/lib_dec/voip_client.c +++ b/lib_dec/voip_client.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -9,7 +9,6 @@ #include #include "options.h" #include "stl.h" -#include "wmc_auto.h" #include "prot_fx.h" #include "cnst_fx.h" #include "basop_util.h" @@ -132,7 +131,7 @@ Word16 decodeVoip( fprintf(stderr,"unable to set JBM trace file: %s\n", jbmTraceFileName); G192_Reader_Close(&g192); EVS_RTPDUMP_DEPACKER_close(&rtpdumpDepacker); - if( f_offset ) + if( f_offset ) { fclose(f_offset); } @@ -146,6 +145,10 @@ Word16 decodeVoip( dec_delay = NS2SA_fx2(st_fx->output_Fs_fx, get_delay_fx(DEC, st_fx->output_Fs_fx)); zero_pad = dec_delay; + /* start WMOPS counting for decoding process only */ + BASOP_end_noprint + BASOP_init + if (st_fx->bitstreamformat == VOIP_G192_RTP) { /* read first packet */ @@ -171,7 +174,7 @@ Word16 decodeVoip( fprintf(stderr,"failed to read first RTP packet\n"); G192_Reader_Close(&g192); EVS_RTPDUMP_DEPACKER_close(&rtpdumpDepacker); - if( f_offset ) + if( f_offset ) { fclose(f_offset); } @@ -193,6 +196,10 @@ Word16 decodeVoip( for( ; ; ) { Word16 nSamples = 0; +#if (WMOPS) + fwc(); + Reset_WMOPS_counter(); +#endif /* read all packets with a receive time smaller than the system time */ while( nextPacketRcvTime_ms != -1 && nextPacketRcvTime_ms <= systemTime_ms ) @@ -318,7 +325,7 @@ Word16 decodeVoip( } ELSE { - IF ( sub(dec_delay, nSamples) <= 0 ) + IF ( LE_16(dec_delay, nSamples)) { fwrite( pcmBuf + dec_delay, sizeof(Word16), sub(nSamples, dec_delay), f_synth ); dec_delay = 0; @@ -352,12 +359,14 @@ Word16 decodeVoip( } /* end of WMOPS counting */ + BASOP_end /* free memory etc. */ + BASOP_init G192_Reader_Close(&g192); EVS_RTPDUMP_DEPACKER_close(&rtpdumpDepacker); EVS_RX_Close(&hRX); - + BASOP_end_noprint return 0; } diff --git a/lib_dec/waveadjust_fec_dec.c b/lib_dec/waveadjust_fec_dec.c index 2390d944f566ea7b9a47aa622164d54494d2e4d2..c945136a3aa8d1eee1291a827b1718ce9d4a4913 100644 --- a/lib_dec/waveadjust_fec_dec.c +++ b/lib_dec/waveadjust_fec_dec.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -9,9 +9,7 @@ #include "prot_fx.h" #include "basop_util.h" #include "stat_com.h" -#include "stl.h" -#include "wmc_auto.h" - /* FOR wmc_tool */ +#include "stl.h" /* FOR wmc_tool */ void get_maxConv_and_pitch_x(Word16 *s_LP, Word16 s, Word16 e, Word16 N, Word32 *maxConv, Word16 *maxConv_bits, Word16 *pitch); @@ -48,7 +46,7 @@ void concealment_update_x(Word16 bfi, Word16 curr_mode, Word16 tonality, Word32 Word16 i; move16(); move16(); - IF (sub(curr_mode ,1)==0) + IF (EQ_16(curr_mode ,1)) { set_state(plcInfo->Transient, curr_mode, MAX_POST_LEN); @@ -68,7 +66,7 @@ void concealment_update_x(Word16 bfi, Word16 curr_mode, Word16 tonality, Word32 ELSE { - IF (subframe == 0) + IF (EQ_16(subframe,0)) { set_state(plcInfo->Transient, curr_mode, MAX_POST_LEN); @@ -81,7 +79,7 @@ void concealment_update_x(Word16 bfi, Word16 curr_mode, Word16 tonality, Word32 pitch_search_fx(), low_freq_rate is derived on the last good TCX-10 spectrum */ test(); - IF (!bfi || subframe == 0) + IF (!bfi || EQ_16(subframe,0)) { Word32 *ptr = data_reci2+subframe; @@ -146,7 +144,7 @@ Word16 int_div_s_x(Word16 a, Word16 b) move16(); move16(); test(); - IF (sub(a,b) < 0 || b == 0) + IF (LT_16(a,b)||b==0) { return 0; } @@ -159,7 +157,7 @@ Word16 int_div_s_x(Word16 a, Word16 b) { left = shr(a, i); result = shl(result,1); - IF (sub(left,b) >= 0) + IF (GE_16(left,b)) { result = add(result,1); left= sub(left, b); @@ -217,7 +215,7 @@ Word16 harmo_x(Word32 *X, Word16 Framesize, Word16 pitch) ener_w = extract_h(L_shl(ener,norm1)); ener_harmo_w = extract_h(L_shl(ener_harmo,norm1)); - IF (L_sub(ener_harmo ,ener)>= 0) + IF (GE_32(ener_harmo ,ener)) { return 32767; } @@ -243,7 +241,7 @@ Word16 get_low_freq_eng_rate_x(Word32 *mdct_data, N2 = N; move16(); move16(); - IF (sub(2 ,curr_mode)==0) + IF (EQ_16(2 ,curr_mode)) { N1 = shr(30,1); N2 = shr(N,1); @@ -346,7 +344,7 @@ void get_maxConv_and_pitch_x(Word16 *s_LP, Word16 s, Word16 e, Word16 N, cov_size = sub(N,t); tmp_sigma = dot_w32_accuracy_x(s_LP, s_LP+t, nbits, cov_size); - IF (sub(t,s) > 0) /* don't use the first value */ + IF (GT_16(t,s)) /* don't use the first value */ { Mpy_32_16_ss(tmp_sigma , cov_size_last, &r1_high, &r1_low); Mpy_32_16_ss(tmp_sigma_last, cov_size , &r2_high, &r2_low); @@ -355,8 +353,8 @@ void get_maxConv_and_pitch_x(Word16 *s_LP, Word16 s, Word16 e, Word16 N, test(); move16(); move16(); /* moves are for the (Word32) casts */ - IF((L_sub(r1_high, r2_high) > 0) || - (L_sub(r1_high, r2_high) == 0 && L_sub((Word32)r1_low, (Word32)r2_low) > 0)) + IF((GT_32(r1_high, r2_high))|| + (EQ_32(r1_high, r2_high) && GT_32((Word32)r1_low, (Word32)r2_low) )) { /* store the current cov, if it is larger than the last one */ cov_max_sigma_tmp = tmp_sigma; @@ -373,8 +371,8 @@ void get_maxConv_and_pitch_x(Word16 *s_LP, Word16 s, Word16 e, Word16 N, test(); move16(); move16(); /* moves are for the (Word32) casts */ - IF((L_sub(r1_high, r2_high) < 0) || - (L_sub(r1_high, r2_high) == 0 && L_sub((Word32)r1_low, (Word32)r2_low) < 0)) + IF((LT_32(r1_high, r2_high))|| + (EQ_32(r1_high, r2_high) && LT_32((Word32)r1_low, (Word32)r2_low))) { /* otherwise */ /* use the last value of cov, being a max */ @@ -433,7 +431,7 @@ Word16 get_voicing_x(Word16 *s_LP, Word16 pitch, Word32 covMax,Word16 maxConv_bi eng1_w = extract_h(L_shl(eng1, norm)); eng2_w = extract_h(L_shl(covMax, norm)); - IF (L_sub(covMax , eng1)>=0) + IF (GE_32(covMax , eng1)) { return 32767; } @@ -481,7 +479,7 @@ void pitch_modify_x(Word16 *s_LP, Word16 *voicing, Word16 *pitch, Word16 FrameSi eng1_w = extract_h(L_shl(eng1, norm)); eng2_w = extract_h(L_shl(eng3, norm)); - IF (L_sub(eng3,eng1) >= 0) + IF (GE_32(eng3,eng1)) { voicing2 = 32767; move16(); @@ -497,7 +495,7 @@ void pitch_modify_x(Word16 *s_LP, Word16 *voicing, Word16 *pitch, Word16 FrameSi } } - IF (sub(voicing2, *voicing) > 0) + IF (GT_16(voicing2, *voicing)) { *pitch = shIFt; move16(); @@ -515,28 +513,28 @@ Word16 Is_Periodic_x(Word32 *mdct_data, Word16 cov_max, Word16 zp, Word32 ener, test(); test(); test(); - IF (L_sub(ener, L_shl(50,8)) < 0 || (L_sub(ener, L_sub(ener_mean, L_shl(8,8))) < 0 - && sub(cov_max, 29491) < 0 )) + IF (LT_32(ener, L_shl(50,8))||(LT_32(ener,L_sub(ener_mean,L_shl(8,8))) + && LT_16(cov_max, 29491) )) { flag = 0; move16(); } - ELSE IF (sub(cov_max, 26214) > 0) + ELSE IF (GT_16(cov_max, 26214)) { flag = 1; move16(); } - ELSE IF (sub(zp, 100) > 0) + ELSE IF (GT_16(zp, 100)) { flag = 0; move16(); } - ELSE IF (L_sub(ener, L_sub(ener_mean,L_shl(6,8))) < 0) + ELSE IF (LT_32(ener, L_sub(ener_mean,L_shl(6,8)))) { flag = 0; move16(); } - ELSE IF (L_sub(ener, L_add(ener_mean, L_shl(1,8))) > 0 && sub(cov_max, 19661) > 0) + ELSE IF (GT_32(ener, L_add(ener_mean, L_shl(1,8)))&>_16(cov_max,19661)) { flag = 1; move16(); @@ -546,7 +544,7 @@ Word16 Is_Periodic_x(Word32 *mdct_data, Word16 cov_max, Word16 zp, Word32 ener, harm = harmo_x(mdct_data, Framesize, pitch); flag = 1; move16(); - if (sub(harm, 22938) < 0) + if (LT_16(harm, 22938)) { flag = 0; move16(); @@ -587,7 +585,7 @@ Word16 get_conv_relation_x(Word16 *s_LP, Word16 shIFt, Word16 N) eng1_w = extract_h(L_shl(eng1, norm)); eng2_w = extract_h(L_shl(eng3, norm)); - IF (L_sub(eng3, eng1) >= 0) + IF (GE_32(eng3, eng1)) { return 32767; } @@ -631,34 +629,34 @@ Word16 pitch_search_fx(Word16 *s, /* lastPcmOut */ move16(); curr_frmsize = Framesize; move16(); - if (sub(2, curr_mode) == 0) + if (EQ_16(2, curr_mode)) { curr_frmsize = shr(Framesize, 1); } zp_current = zero_pass_w32_x(outx_new, curr_frmsize); - if (sub(2, curr_mode) == 0) + if (EQ_16(2, curr_mode)) { zp_current = shl(zp_current,1); } - IF (sub(Framesize, 256) <= 0) + IF (LE_16(Framesize, 256)) { - IF (sub(zp_current, 70) > 0) + IF (GT_16(zp_current, 70)) { return 0; } } ELSE { - IF (sub(zp_current, 105) > 0) + IF (GT_16(zp_current, 105)) { return 0; } } mdctPtr = mdct_data; - if (sub(2, curr_mode) == 0) + if (EQ_16(2, curr_mode)) { mdctPtr = mdct_data + shr(Framesize,1); } @@ -674,11 +672,11 @@ Word16 pitch_search_fx(Word16 *s, /* lastPcmOut */ LpFilter2_x(s, s_LP, Framesize); sig_tilt_x(s_LP, Framesize, &tilt_enr1, &tilt_enr2); - IF (sub(Framesize, 320) <= 0) + IF (LE_16(Framesize, 320)) { test(); IF ((0==tilt_enr2) || - (L_sub(tilt_enr1, L_shr(tilt_enr2, 1)) < 0)) + (LT_32(tilt_enr1, L_shr(tilt_enr2, 1)) )) { return 0; } @@ -687,13 +685,13 @@ Word16 pitch_search_fx(Word16 *s, /* lastPcmOut */ { test(); IF ((0==tilt_enr2) || - (L_sub(tilt_enr1, Mpy_32_16_1(tilt_enr2, 22938)) < 0)) + (LT_32(tilt_enr1, Mpy_32_16_1(tilt_enr2, 22938)) )) { return 0; } } - IF (sub(Framesize, 320) <= 0) + IF (LE_16(Framesize, 320)) { start_pos = extract_l(L_shr(L_mac0(0x80, 34, Framesize), 8)); end_pos = extract_l(L_shr(L_mac0(0x2 , 3, Framesize), 2)); @@ -728,7 +726,7 @@ Word16 pitch_search_fx(Word16 *s, /* lastPcmOut */ { pitch_tmp[0] = 0; move16(); - if (sub(shl(pitch, 1), 1) > 0) + if (GT_16(shl(pitch, 1), 1)) { pitch_tmp[0] = sub(shl(pitch, 1), 1); move16(); @@ -745,7 +743,7 @@ Word16 pitch_search_fx(Word16 *s, /* lastPcmOut */ { cov_size = sub(Framesize, pitch_tmp[i]); end_pos = get_conv_relation_x(s_LP, pitch_tmp[i], cov_size); - IF (sub(end_pos, start_pos) > 0) + IF (GT_16(end_pos, start_pos)) { start_pos = end_pos; move16(); @@ -845,17 +843,17 @@ void concealment_decode_fix(Word16 curr_mode, Word32 *invkoef, Word16 *invkoef_s move16(); IF (plcInfo->concealment_method == TCX_NONTONAL) /* #define TCX_NONTONAL 0 */ { - IF (sub(curr_mode, 1) == 0) + IF (EQ_16(curr_mode, 1)) { /* copy the data of the last frame */ - MVR2R_WORD32(plcInfo->data_reci2_fx, invkoef, N); + mvr2r_Word32(plcInfo->data_reci2_fx, invkoef, N); *invkoef_scale = plcInfo->data_reci2_scale; move16(); /* sign randomization */ FOR (i = 0; i < N; i++) { sign = add(shl(shr(own_random_fix(seed),15),1),1); - if(sub(sign,-1)==0) + if(EQ_16(sign,-1)) { invkoef[i] = L_negate(invkoef[i]); move32(); @@ -1047,7 +1045,7 @@ void concealment_update2_x(Word16 *outx_new, void *_plcInfo, Word16 FrameSize) Log10OfEnergy_x(outx_new, &plcInfo->ener_fx, FrameSize); /* Q8 */ test(); - IF (sub(plcInfo->zp_fx, 100) < 0 && L_sub(plcInfo->ener_fx, L_shl(50,8)) > 0) + IF (LT_16(plcInfo->zp_fx, 100)&>_32(plcInfo->ener_fx,L_shl(50,8))) { plcInfo->ener_mean_fx = L_add(Mpy_32_16_1(plcInfo->ener_mean_fx ,32112/* 0.98 Q15 */), Mpy_32_16_1(plcInfo->ener_fx , 655/* 0.02 Q15 */)); @@ -1062,7 +1060,7 @@ static Word16 array_max_indx_fx(Word16 *s, Word16 N) move16(); FOR (i = 0; i < N; i++) { - if (sub(s[i], s[indx]) > 0) + if (GT_16(s[i], s[indx])) { indx = i; move16(); @@ -1121,12 +1119,12 @@ static Word16 OverlapAdd_fx(Word16 *pitch125_data, Word16 *sbuf, move16(); n2 = Framesize_sub_n; move16(); - if( sub(Loverlap, Framesize_sub_n) < 0 ) + if(LT_16(Loverlap, Framesize_sub_n)) { n1 = Loverlap; move16(); } - if( sub(pitch125, Framesize_sub_n) < 0 ) + if(LT_16(pitch125, Framesize_sub_n)) { n2 = pitch125; move16(); @@ -1213,12 +1211,12 @@ Word16 waveform_adj_fix(Word16 *overlapbuf, /* judge if the pitch is usable */ tmp = 1; move16(); - if (sub(zp1, 1) > 0) + if (GT_16(zp1, 1)) { tmp = zp1; move16(); } - IF (sub(shl(tmp,2), zp2) < 0) + IF (LT_16(shl(tmp,2), zp2)) { move16(); return 0; @@ -1228,8 +1226,8 @@ Word16 waveform_adj_fix(Word16 *overlapbuf, test(); test(); test(); - IF (T_bfi && (sub(pitch , Framesizediv2)<=0) - && (sub(Framesize ,256)>0) && (sub(curr_mode , 1)==0)) + IF (T_bfi && (LE_16(pitch , Framesizediv2)) + && (GT_16(Framesize ,256)) && (EQ_16(curr_mode , 1))) { Word16 i1 = 0, i2 = 0; Word16 pos1, pos2, pos3; @@ -1244,7 +1242,7 @@ Word16 waveform_adj_fix(Word16 *overlapbuf, test(); test(); - IF ((sub(pos1,pos2)<0) && (sub(pos3,pitch)>0) && (sub(pos1,Framesizediv2)<0)) + IF ((LT_16(pos1,pos2))&&(GT_16(pos3,pitch))&&(LT_16(pos1,Framesizediv2))) { pitch = add(i2,sub(pitch,i1)); } @@ -1300,7 +1298,7 @@ Word16 waveform_adj_fix(Word16 *overlapbuf, } } - WHILE (sub(n, Framesize) < 0) /* periodical extension */ + WHILE (LT_16(n, Framesize)) /* periodical extension */ { n = OverlapAdd_fx(pitch125_data,sbuf,n,pitch,Framesize); } @@ -1318,7 +1316,7 @@ Word16 waveform_adj_fix(Word16 *overlapbuf, /* use last good signal for noise generation */ add_noise(sbuf, outx_new_n1, outdata2, tmp, nsapp_gain, nsapp_gain_n, 1); /* save current (noisy) output from IMDCT */ - MVR2R_WORD16(outx_new, data_noise, tmp); + mvr2r_Word16(outx_new, data_noise, tmp); /* overlapbuf can now be filled with sbuf, needed for subsequently lost frames */ Copy(pitch125_data, &overlapbuf[Framesize/4], (3*Framesize)/4); } @@ -1384,11 +1382,11 @@ void waveform_adj2_fix( Word16 *overlapbuf, /* save current (noisy) output from IMDCT */ IF( bfi ) { - MVR2R_WORD16(outx_new, noise_ptr, size); + mvr2r_Word16(outx_new, noise_ptr, size); } } test(); - IF (sub(bfi_cnt ,4)==0 || bfi == 0) + IF (EQ_16(bfi_cnt ,4)||bfi==0) { SWITCH ( Framesize) { @@ -1513,7 +1511,7 @@ void concealment_signal_tuning_fx(Word16 bfi, Word16 curr_mode, Word16 *outx_new IF (st->enablePlcWaveadjust && plcInfo->concealment_method == TCX_NONTONAL) /* #define TCX_NONTONAL 0 */ { - IF (sub(nbLostCmpt, 1) == 0) + IF (EQ_16(nbLostCmpt, 1)) { plcInfo->Pitch_fx = pitch_search_fx(outdata2_fx, outx_new_fx, @@ -1544,7 +1542,7 @@ void concealment_signal_tuning_fx(Word16 bfi, Word16 curr_mode, Word16 *outx_new move16(); } } - ELSE IF (sub(nbLostCmpt, 5) < 0) /* waveform adjustment for the 2nd~4th lost frame */ + ELSE IF (LT_16(nbLostCmpt, 5)) /* waveform adjustment for the 2nd~4th lost frame */ { waveform_adj2_fix(OverlapBuf_fx, outx_new_fx, @@ -1571,12 +1569,12 @@ void concealment_signal_tuning_fx(Word16 bfi, Word16 curr_mode, Word16 *outx_new test(); IF (pre_bfi && past_core_mode != 0 && - L_sub(st->last_total_brate_fx, 48000) >= 0 && - sub(st->last_codec_mode, MODE2) == 0) + GE_32(st->last_total_brate_fx, 48000) && + EQ_16(st->last_codec_mode, MODE2) ) { IF (plcInfo->concealment_method == TCX_NONTONAL) /* #define TCX_NONTONAL 0 */ { - IF (L_sub(plcInfo->nbLostCmpt, 4) < 0) /* smoothing of the concealed signal with the good signal */ + IF (LT_32(plcInfo->nbLostCmpt, 4)) /* smoothing of the concealed signal with the good signal */ { waveform_adj2_fix(OverlapBuf_fx, outx_new_fx, diff --git a/lib_enc/ACcontextMapping_enc.c b/lib_enc/ACcontextMapping_enc.c index c47af4ed5765d48e08e006cab1043fcad26443af..fd2a1b38f8726fa0f24afe714c137b4394f785fa 100644 --- a/lib_enc/ACcontextMapping_enc.c +++ b/lib_enc/ACcontextMapping_enc.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -8,16 +8,11 @@ #include #include "options.h" #include "stl.h" -#include "wmc_auto.h" - #include "basop_util.h" #include "stl.h" -#include "wmc_auto.h" - #include "cnst_fx.h" #include "prot_fx.h" #include "rom_com_fx.h" -#include "wmc_auto.h" /** * \brief Arithmetic encoder @@ -63,7 +58,7 @@ Word16 ACcontextMapping_encode2_no_mem_s17_LC( /* Rate flag */ rateFlag = 0; move16(); - if (sub(nbbits, 400) > 0) + if (GT_16(nbbits, 400)) { rateFlag = 2 << NBITS_CONTEXT; move16(); @@ -163,7 +158,7 @@ Word16 ACcontextMapping_encode2_no_mem_s17_LC( move16(); t = add(*ctx, rateFlag); - if (sub(idx, nt_half) > 0) + if (GT_16(idx, nt_half)) { t = add(t, 1 << NBITS_CONTEXT); } @@ -210,7 +205,7 @@ Word16 ACcontextMapping_encode2_no_mem_s17_LC( } /* MSBs coding */ - WHILE (sub(s_max(a1, b1), A_THRES) >= 0) + WHILE (GE_16(s_max(a1, b1), A_THRES)) { tmp = add(t, Tab_esc_nb[lev1+1]); assert(tmp >= 0 && tmp < 4096); @@ -239,7 +234,7 @@ Word16 ACcontextMapping_encode2_no_mem_s17_LC( bp = ari_encode_14bits_ext(ptr, bp, &as, add(a1, shl(b1, A_THRES_SHIFT)), ari_pk_s17_LC_ext[pki]); /* Check bit budget */ - IF (sub(add(add(add(bp, extract_l(as.vobf)), nbbits_signs), nbbits_lsbs), nbbits_m2) > 0) + IF (GT_16(add(add(add(bp, extract_l(as.vobf)), nbbits_signs), nbbits_lsbs), nbbits_m2)) { ari_copy_states(&as_overflow, &as); bp = bp_overflow; @@ -269,7 +264,7 @@ Word16 ACcontextMapping_encode2_no_mem_s17_LC( move16(); bp = ari_encode_14bits_ext(ptr, bp, &as, 0, ari_pk_s17_LC_ext[pki]); - IF (sub(add(add(add(bp, extract_l(as.vobf)), nbbits_signs), nbbits_lsbs), nbbits_m2) > 0) + IF (GT_16(add(add(add(bp, extract_l(as.vobf)), nbbits_signs), nbbits_lsbs), nbbits_m2)) { ari_copy_states(&as_overflow, &as); bp = bp_overflow; @@ -289,7 +284,7 @@ Word16 ACcontextMapping_encode2_no_mem_s17_LC( } /* Update context for next 2-tuple */ - IF (sub(p1, p2) == 0) /* peak-peak or hole-hole context */ + IF (EQ_16(p1, p2)) /* peak-peak or hole-hole context */ { if (lev1 > 0) t = add(12, lev1); if (lev1 <= 0) t = add(a1, b1); @@ -318,7 +313,7 @@ Word16 ACcontextMapping_encode2_no_mem_s17_LC( bp = ari_done_encoding_14bits(ptr, bp, &as); /* Overflow is detected */ - IF (sub(k, lastnz) != 0) + IF (NE_16(k, lastnz)) { IF (hm_cfg) { @@ -470,7 +465,7 @@ Word16 ACcontextMapping_encode2_estimate_no_mem_s17_LC( /* Rate flag */ rateFlag = 0; move16(); - if (sub(target, 400) > 0) + if (GT_16(target, 400)) { rateFlag = 2 << NBITS_CONTEXT; move16(); @@ -552,7 +547,7 @@ Word16 ACcontextMapping_encode2_estimate_no_mem_s17_LC( move16(); t = add(*ctx, rateFlag); - if (sub(idx, nt_half) > 0) + if (GT_16(idx, nt_half)) { t = add(t, 1 << NBITS_CONTEXT); } @@ -580,7 +575,7 @@ Word16 ACcontextMapping_encode2_estimate_no_mem_s17_LC( /* MSBs coding */ lookup = &ari_lookup_s17_LC[t] + (1 << (NBITS_CONTEXT+NBITS_RATEQ)); /* address calculation not counted */ - WHILE (sub(s_max(a1, b1), A_THRES) >= 0) + WHILE (GE_16(s_max(a1, b1), A_THRES)) { pki = lookup[lev1]; move16(); @@ -649,7 +644,7 @@ Word16 ACcontextMapping_encode2_estimate_no_mem_s17_LC( } /* Update context for next 2-tuple */ - IF (sub(p1, p2) == 0) /* peak-peak or hole-hole context */ + IF (EQ_16(p1, p2)) /* peak-peak or hole-hole context */ { lev1 = shr(lev1, NBITS_CONTEXT+NBITS_RATEQ); if (lev1 > 0) t = add(12, lev1); diff --git a/lib_enc/FEC_enc_fx.c b/lib_enc/FEC_enc_fx.c index a38b671ef6744ffa433750ee54cf747b25b6572a..b5ff9076db225242d44edc6f45485d648b2c34f7 100644 --- a/lib_enc/FEC_enc_fx.c +++ b/lib_enc/FEC_enc_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -7,8 +7,6 @@ #include "prot_fx.h" /* Function prototypes */ #include "rom_com_fx.h" /* Static table prototypes */ #include "stl.h" -#include "wmc_auto.h" - @@ -66,26 +64,26 @@ void FEC_encode_fx( move16(); test(); test(); - IF( sub(coder_type,UNVOICED) > 0 && sub(coder_type,AUDIO) < 0 && L_sub(core_brate,ACELP_11k60) >= 0 ) + IF( GT_16(coder_type,UNVOICED)&<_16(coder_type,AUDIO)&&GE_32(core_brate,ACELP_11k60)) { /*-----------------------------------------------------------------* * encode signal class (not needed for VC mode since it is clearly voiced) (2 bits) *-----------------------------------------------------------------*/ - IF ( sub(coder_type,VOICED) != 0 ) + IF ( NE_16(coder_type,VOICED)) { /* encode signal clas with 2 bits */ test(); - IF(sub(clas,UNVOICED_CLAS) == 0 ) + IF(EQ_16(clas,UNVOICED_CLAS)) { index = 0; move16(); } - ELSE IF( sub(clas,VOICED_TRANSITION) == 0 || sub(clas,UNVOICED_TRANSITION) == 0 ) + ELSE IF( EQ_16(clas,VOICED_TRANSITION)||EQ_16(clas,UNVOICED_TRANSITION)) { index = 1; move16(); } - ELSE IF( sub(clas,VOICED_CLAS) == 0 ) + ELSE IF( EQ_16(clas,VOICED_CLAS)) { index = 2; move16(); @@ -102,7 +100,7 @@ void FEC_encode_fx( * encode frame energy (5 bits) *-----------------------------------------------------------------*/ test(); - IF( L_sub(total_brate,ACELP_16k40) >= 0 && sub(coder_type,TRANSITION) != 0) /* GENERIC and VOICED frames */ + IF( GE_32(total_brate,ACELP_16k40)&&NE_16(coder_type,TRANSITION)) /* GENERIC and VOICED frames */ { /* frame energy (maximum energy per pitch period for voiced frames or mean energy per sample over 2nd halframe for unvoiced frames) */ /*frame_ener( L_frame, clas, synth, fpit[(L_frame>>6)-1], &enr_q, 0 );*/ @@ -125,7 +123,7 @@ void FEC_encode_fx( * Encode last glottal pulse position (8 bits) *-----------------------------------------------------------------*/ test(); - IF( L_sub(total_brate,ACELP_32k) >= 0 && sub(coder_type,TRANSITION) != 0) /* GENERIC frames */ + IF( GE_32(total_brate,ACELP_32k)&&NE_16(coder_type,TRANSITION)) /* GENERIC frames */ { /* retrieve the last glottal pulse position of the previous frame */ /* use the current pitch information to scale or not the quantization */ @@ -142,12 +140,12 @@ void FEC_encode_fx( maxi = negate(maxi); } - if ( sub(tmp_FER_pitch,128) >= 0) + if ( GE_16(tmp_FER_pitch,128)) { maxi = shr(maxi , 1); } - if ( sub(maxi,127) > 0) + if ( GT_16(maxi,127)) { /* better not use the glottal pulse position at all instead of using a wrong pulse */ /* can happen only with pitch > 254 and max pit = 289 and should happen very rarely */ @@ -168,7 +166,7 @@ void FEC_encode_fx( /* If bitrate < 24k4, then the pitch is not represented in the same domain (12.k instead of 16k) */ test(); - IF( sub(clas,VOICED_CLAS) >= 0 && L_sub(total_brate,ACELP_24k40) >= 0 ) + IF( GE_16(clas,VOICED_CLAS)&&GE_32(total_brate,ACELP_24k40)) { /*maxi = findpulse( L_frame, res, (short)(fpit[(L_frame>>6)-1]), 0, &sign ); */ maxi = findpulse_fx( L_frame, res, shr_r(fpit[sub(shr(L_frame , 6) , 1)], 6), 0, &sign ); @@ -209,7 +207,7 @@ void FEC_lsf_estim_enc_fx( Word16 alpha, lsf_mean[M]; Word16 tmp; - IF( sub(L_frame, L_FRAME) == 0 ) + IF( EQ_16(L_frame, L_FRAME)) { Copy( UVWB_Ave_fx, lsf_mean, M ); } @@ -222,7 +220,7 @@ void FEC_lsf_estim_enc_fx( * Initialize the alpha factor *----------------------------------------------------------------------*/ - IF( sub(st_fx->last_coder_type_fx, UNVOICED) == 0 ) + IF( EQ_16(st_fx->last_coder_type_fx, UNVOICED)) { /* clearly unvoiced */ alpha = _ALPHA_UU_FX; @@ -232,29 +230,29 @@ void FEC_lsf_estim_enc_fx( { test(); test(); - IF( sub(st_fx->last_coder_type_fx, AUDIO) == 0 || sub(st_fx->clas_fx, INACTIVE_CLAS) == 0 ) + IF( EQ_16(st_fx->last_coder_type_fx, AUDIO)||EQ_16(st_fx->clas_fx,INACTIVE_CLAS)) { alpha = 32604; move16(); } - ELSE IF( sub(st_fx->clas_fx, UNVOICED_CLAS) == 0 ) + ELSE IF( EQ_16(st_fx->clas_fx, UNVOICED_CLAS)) { /* if stable, do not flatten the spectrum in the first erased frame */ /* alpha = st->stab_fac * (1.0f - 2.0f*ALPHA_U) + 2.0f*ALPHA_U; */ alpha = add(mult(st_fx->stab_fac_fx, 32768 - _ALPHA_U_FX_X_2), _ALPHA_U_FX_X_2); } - ELSE IF( sub(st_fx->clas_fx, UNVOICED_TRANSITION) == 0 ) + ELSE IF( EQ_16(st_fx->clas_fx, UNVOICED_TRANSITION)) { alpha = _ALPHA_UT_FX; move16(); } - ELSE IF( sub(st_fx->clas_fx, VOICED_CLAS) == 0 || sub(st_fx->clas_fx, ONSET) == 0 ) + ELSE IF( EQ_16(st_fx->clas_fx, VOICED_CLAS)||EQ_16(st_fx->clas_fx,ONSET)) { /* clearly voiced - mild convergence to the CNG spectrum for the first three erased frames */ alpha = _ALPHA_V_FX; move16(); } - ELSE IF( sub(st_fx->clas_fx, SIN_ONSET) == 0 ) + ELSE IF( EQ_16(st_fx->clas_fx, SIN_ONSET)) { alpha = _ALPHA_S_FX; move16(); @@ -283,7 +281,7 @@ void FEC_lsf_estim_enc_fx( } /* check LSF stability through LSF ordering */ - IF( sub(L_frame, L_FRAME) == 0 ) + IF( EQ_16(L_frame, L_FRAME)) { reorder_lsf_fx( lsf, MODE1_LSF_GAP_FX, M , INT_FS_FX); } diff --git a/lib_enc/SNR_calc.c b/lib_enc/SNR_calc.c index 449f78d4744e0b5bc41b177a8fe0445431b358a2..7e09a4554a2c8ec8c99803482b5f9ada178d9f35 100644 --- a/lib_enc/SNR_calc.c +++ b/lib_enc/SNR_calc.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -8,8 +8,6 @@ #include "basop_util.h" #include "options.h" #include "stl.h" -#include "wmc_auto.h" - #include "vad_basop.h" #include "rom_enc_fx.h" #include "prot_fx.h" @@ -49,9 +47,10 @@ void calc_lf_snr( l_snr = L_shr(l_snr, sub(q_divout, 25)); test(); - if(( sub(bg_energy_count, 56) < 0) || (sub(fg_energy_count, 56) < 0 )) + if(( LT_16(bg_energy_count, 56))||(LT_16(fg_energy_count,56))) { - l_snr = L_add(0, 161061275/* 4.8 Q25 */); + l_snr = 161061275/* 4.8 Q25 */; + move32(); } l_snr = MUL_F(l_snr, 3932/* 0.12 Q15 */); @@ -83,7 +82,7 @@ void calc_lt_snr(T_CldfbVadState *st, /*(io) vad state*/ tmp_lt_noise_sp_center = sub(lt_noise_sp_center0,1432/* 1.4 Q10 */); - if(sub(tmp_lt_noise_sp_center, 818/* 0.8 Q10 */) > 0) + if(GT_16(tmp_lt_noise_sp_center, 818/* 0.8 Q10 */)) { tmp_lt_noise_sp_center = 818/* 0.8 Q10 */; move16(); @@ -111,21 +110,22 @@ void calc_lt_snr(T_CldfbVadState *st, /*(io) vad state*/ div2 = VAD_L_div(div1,div2,q_div1,q_div2,&q_divout); lt_snr_org = VAD_Log2(div2,q_divout); lt_snr_org = MUL_F(lt_snr_org, 9864); - lt_snr = L_add(0, lt_snr_org); + lt_snr = lt_snr_org; move32(); *lt_snr_org_fp = lt_snr; move32(); test(); - IF(sub(bg_energy_count, 56)<0||sub(fg_energy_count,56)<0) + IF(LT_16(bg_energy_count, 56)||LT_16(fg_energy_count,56)) { - lt_snr = L_add(0, 70464302/* 2.1 Q25 */); + lt_snr = 70464302/* 2.1 Q25 */; + move32(); } - IF(sub(bw_index, CLDFBVAD_NB_ID)== 0) + IF(EQ_16(bw_index, CLDFBVAD_NB_ID)) { lt_snr = L_sub(L_shr(lt_snr,1), 25165823/* 0.75 Q25 */); } - ELSE IF(sub(bw_index, CLDFBVAD_WB_ID)== 0) + ELSE IF(EQ_16(bw_index, CLDFBVAD_WB_ID)) { lt_snr = L_sub(L_shr(lt_snr,1), 25165823/* 0.75 Q25 */); } @@ -146,9 +146,10 @@ void calc_lt_snr(T_CldfbVadState *st, /*(io) vad state*/ lt_snr = L_max(0, lt_snr); - if(L_sub(lt_snr,67108862/* 2.0 Q25 */)>0) + if(GT_32(lt_snr,67108862/* 2.0 Q25 */)) { - lt_snr = L_add(0, 67108862/* 2.0 Q25 */); + lt_snr = 67108862/* 2.0 Q25 */; + move32(); } *lt_snr_fp = lt_snr; @@ -170,7 +171,7 @@ void calc_snr_flux( test(); - IF( (L_sub(L_shr(tsnr,1) , 43620759/* 2.6f/2.0f Q25 */)<0 )&&tsnr>0) + IF( (LT_32(L_shr(tsnr,1) , 43620759/* 2.6f/2.0f Q25 */))&&tsnr>0) { pre_snr[0] = tsnr; move32(); @@ -187,7 +188,8 @@ void calc_snr_flux( } /*calculate snr_flux*/ - snr_flux = L_add(0, 0); + snr_flux = 0; + move32(); s16MaxCoefNorm = sub(ffr_getSfWord32(pre_snr, 32), 5); FOR(i=0; i<32; i++) { @@ -231,12 +233,15 @@ void snr_calc(T_CldfbVadState *st, /*(io) vad state*/ Word32 snr_tmpidx[12] = {0}; - SNR_sb_num = add(0, SNR_SUB_BAND_NUM[bandwith-CLDFBVAD_NB_ID]); + SNR_sb_num = SNR_SUB_BAND_NUM[bandwith-CLDFBVAD_NB_ID]; + move16(); sb_bg_energy = st->sb_bg_energy; frame_sb_energy = st->frame_sb_energy; - t_bg_energy = L_add(0, st->t_bg_energy); + t_bg_energy = st->t_bg_energy; + move32(); - snr_tmp = L_add(0, 0); + snr_tmp = 0; + move32(); FOR(i=0; iframe_sb_energy_scale, CONSTfix, 44, &tmp_addQ1); @@ -244,7 +249,7 @@ void snr_calc(T_CldfbVadState *st, /*(io) vad state*/ tmp = VAD_L_div(div1, div2, tmp_addQ1, tmp_addQ2, &q_divout); tmp = VAD_Log2(tmp, q_divout); - if(L_sub(tmp, -3355443/* -0.10 Q25 */)>0) + if(GT_32(tmp, -3355443/* -0.10 Q25 */)) { snr_tmpidx[i] = tmp; move32(); @@ -273,8 +278,8 @@ void snr_calc(T_CldfbVadState *st, /*(io) vad state*/ } ELSE { - tmpsb_eg = L_add(0, 0); - constff = L_add(0, 1); + tmpsb_eg = 0; move32(); + constff = 1; move32(); minscale2 = 31; move16(); } @@ -290,7 +295,7 @@ void snr_calc(T_CldfbVadState *st, /*(io) vad state*/ } ELSE { - tmp = L_add(0, 1); + tmp = 1; move32(); minscale2 = 31; move16(); } @@ -310,8 +315,8 @@ void snr_calc(T_CldfbVadState *st, /*(io) vad state*/ } ELSE { - tmpframe_eg = L_add(0, 0); - constff = L_add(0, CONSTfix); + tmpframe_eg = 0; move32(); + constff = CONSTfix; move32(); minscale1 = 44; move16(); } @@ -325,8 +330,8 @@ void snr_calc(T_CldfbVadState *st, /*(io) vad state*/ } ELSE { - tmpsb_eg = L_add(0, 0); - constff = L_add(0, CONSTfix); + tmpsb_eg = 0; move32(); + constff = CONSTfix; move32(); minscale2 = 44; move16(); } @@ -354,28 +359,31 @@ Word32 construct_snr_thresh( Word16 sp_center[], /*(i) spect - snr_delta = L_add(COMVAD_INIT_SNR_DELTA[bw_index],0); - bw_snr = L_add(lt_snr,0); + snr_delta = COMVAD_INIT_SNR_DELTA[bw_index]; + move32(); + bw_snr = lt_snr; + move32(); - test_l_snr = L_add(lt_snr,0); - IF(sub(bw_index, CLDFBVAD_SWB_ID)== 0) + test_l_snr = lt_snr; move32(); + IF(EQ_16(bw_index, CLDFBVAD_SWB_ID)) { - IF(sub(sp_center[3], 2864/* 2.80 Q10 */)>0) + IF(GT_16(sp_center[3], 2864/* 2.80 Q10 */)) { - snr_delta = L_add(snr_delta,0); + snr_delta = snr_delta; + move32(); } - ELSE IF(sub(sp_center[2], 2660/* 2.6 Q10 */)>0) + ELSE IF(GT_16(sp_center[2], 2660/* 2.6 Q10 */)) { snr_delta = L_add(snr_delta, 1006633/* 0.03 Q25 */); } - ELSE IF(sub(sp_center[2], 1637/* 1.6 Q10 */)>0) + ELSE IF(GT_16(sp_center[2], 1637/* 1.6 Q10 */)) { snr_delta = L_add(snr_delta ,1677722/* 0.05 Q25 */); } - ELSE IF(sub(sp_center[3], 1432/* 1.4 Q10 */)>0) + ELSE IF(GT_16(sp_center[3], 1432/* 1.4 Q10 */)) { snr_delta = L_add(snr_delta , 3355443/* 0.10 Q25 */); } @@ -389,39 +397,40 @@ Word32 construct_snr_thresh( Word16 sp_center[], /*(i) spect test(); test(); - IF(L_sub(continuous_speech_num, 8) > 0&& L_sub(fg_energy_est_start, 1) ==0) + IF(GT_32(continuous_speech_num, 8)&&EQ_32(fg_energy_est_start,1)) { snr_delta = L_sub(snr_delta, 6710886/* 0.2 Q25 */); } - ELSE IF(sub(continuous_noise_num,12) > 0&&(L_sub(snr_flux, tmp)>0)) + ELSE IF(GT_16(continuous_noise_num,12)&&(GT_32(snr_flux,tmp))) { snr_delta = L_add(snr_delta, 3355443/* 0.10 Q25 */); } - ELSE IF(sub(continuous_noise_num, 24) > 0) + ELSE IF(GT_16(continuous_noise_num, 24)) { snr_delta = L_add(snr_delta, 6710886/* 0.2 Q25 */); } - ELSE IF((sub(continuous_noise_num, 4) > 0)) + ELSE IF((GT_16(continuous_noise_num, 4))) { snr_delta = L_add(snr_delta, 3355443/* 0.10 Q25 */); } } - ELSE IF(sub(bw_index, CLDFBVAD_WB_ID) == 0) + ELSE IF(EQ_16(bw_index, CLDFBVAD_WB_ID)) { - IF(sub(sp_center[3], 2864/* 2.80 Q10 */)>0) + IF(GT_16(sp_center[3], 2864/* 2.80 Q10 */)) { - snr_delta = L_add(snr_delta,0); + snr_delta = snr_delta; + move32(); } - ELSE IF(sub(sp_center[2], 2660/* 2.6 Q10 */)>0) + ELSE IF(GT_16(sp_center[2], 2660/* 2.6 Q10 */)) { snr_delta = L_add(snr_delta, 1006633/* 0.03 Q25 */); } - ELSE IF(sub(sp_center[2], 1637/* 1.6 Q10 */)>0) + ELSE IF(GT_16(sp_center[2], 1637/* 1.6 Q10 */)) { snr_delta = L_add(snr_delta, 1677722/* 0.05 Q25 */); } - ELSE IF(sub(sp_center[3], 1432/* 1.4 Q10 */)>0) + ELSE IF(GT_16(sp_center[3], 1432/* 1.4 Q10 */)) { snr_delta = L_add(snr_delta, 3355443/* 0.10 Q25 */); } @@ -435,39 +444,40 @@ Word32 construct_snr_thresh( Word16 sp_center[], /*(i) spect test(); test(); - IF(L_sub(continuous_speech_num, 8) > 0 && L_sub(fg_energy_est_start, 1) == 0) + IF(GT_32(continuous_speech_num, 8)&&EQ_32(fg_energy_est_start,1)) { snr_delta = L_sub(snr_delta, 3355443/* 0.10 Q25 */); } - ELSE IF(sub(continuous_noise_num,12)>0 && (L_sub(snr_flux,tmp) > 0)) + ELSE IF(GT_16(continuous_noise_num,12)&&(GT_32(snr_flux,tmp))) { snr_delta = L_add(snr_delta, 3355443/* 0.10 Q25 */); } - ELSE IF(sub(continuous_noise_num,24) > 0) + ELSE IF(GT_16(continuous_noise_num,24)) { snr_delta = L_add(snr_delta, 6710886/* 0.20 Q25 */); } - ELSE IF((sub(continuous_noise_num,4) > 0)) + ELSE IF((GT_16(continuous_noise_num,4))) { snr_delta = L_add(snr_delta, 3355443/* 0.10 Q25 */); } } - ELSE IF(sub(bw_index, CLDFBVAD_NB_ID)== 0) + ELSE IF(EQ_16(bw_index, CLDFBVAD_NB_ID)) { - IF(sub(sp_center[3], 3069/* 3.0 Q10 */)>0) + IF(GT_16(sp_center[3], 3069/* 3.0 Q10 */)) { - snr_delta = L_add(snr_delta,0); + snr_delta = snr_delta; + move32(); } - ELSE IF(sub(sp_center[2], 2660/* 2.6 Q10 */)>0) + ELSE IF(GT_16(sp_center[2], 2660/* 2.6 Q10 */)) { snr_delta = L_add(snr_delta , 671089/* 0.02 Q25 */); } - ELSE IF(sub(sp_center[2],1637/* 1.6 Q10 */)>0) + ELSE IF(GT_16(sp_center[2],1637/* 1.6 Q10 */)) { snr_delta = L_add(snr_delta , 1342177/* 0.04 Q25 */); } - ELSE IF(sub(sp_center[2], 1494/* 1.46 Q10 */)>0) + ELSE IF(GT_16(sp_center[2], 1494/* 1.46 Q10 */)) { snr_delta = L_add(snr_delta , 3355443/* 0.10 Q25 */); } @@ -485,26 +495,27 @@ Word32 construct_snr_thresh( Word16 sp_center[], /*(i) spect test(); test(); test(); - IF(L_sub(continuous_speech_num, 80) > 0 && L_sub(fg_energy_est_start, 1) == 0 && (sub(sp_center[0],1432/* 1.4 Q10 */)>0)) + IF(GT_32(continuous_speech_num, 80)&&EQ_32(fg_energy_est_start,1)&&(GT_16(sp_center[0],1432/* 1.4 Q10 */))) { snr_delta = L_sub(snr_delta, 10737418/* 0.32 Q25 */); } - ELSE IF(L_sub(continuous_speech_num,8) > 0 && L_sub(fg_energy_est_start, 1)==0 && (L_sub(snr_flux,div1)>0)) + ELSE IF(GT_32(continuous_speech_num,8)&&EQ_32(fg_energy_est_start,1)&&(GT_32(snr_flux,div1))) { snr_delta = L_sub(snr_delta, 3355443/* 0.10 Q25 */); } - ELSE IF(sub(continuous_noise_num,12) > 0 && (L_sub(snr_flux,div2) >0)) + ELSE IF(GT_16(continuous_noise_num,12)&&(GT_32(snr_flux,div2))) { snr_delta = L_add(snr_delta, 3355443/* 0.10 Q25 */); } - ELSE IF(sub(continuous_noise_num, 24) > 0) + ELSE IF(GT_16(continuous_noise_num, 24)) { snr_delta = L_add(snr_delta, 6710886/* 0.2 Q25 */); } } ELSE { - snr_delta = L_add(33554431/* 1.0 Q25 */,0); + snr_delta = 33554431/* 1.0 Q25 */; + move32(); } tmp_snr = L_add(snr_delta, test_l_snr); diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 88b29384f272c8ea0aece251d884f6be655e2617..b9858ff4ee775df06e0f35e232ad5f334a2ed4e6 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -10,8 +10,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*-------------------------------------------------------------------* * acelp_core_enc() @@ -97,7 +95,7 @@ void acelp_core_enc_fx( Copy( pitch, T_op_fx, 3 ); /* convert pitch values to 16kHz domain */ - IF ( sub(st_fx->L_frame_fx,L_FRAME16k) == 0 ) + IF ( EQ_16(st_fx->L_frame_fx,L_FRAME16k)) { /*T_op[0] = (short)(T_op[0] * 1.25f + 0.5f);*/ T_op_fx[0] = round_fx(L_mac(L_shl(T_op_fx[0],16), T_op_fx[0], 8192)); @@ -115,7 +113,7 @@ void acelp_core_enc_fx( st_fx->bpf_off_fx = 0; move16(); test(); - IF( sub(st_fx->last_core_fx,HQ_CORE) == 0 || sub(st_fx->last_codec_mode,MODE2)==0) + IF( EQ_16(st_fx->last_core_fx,HQ_CORE)||EQ_16(st_fx->last_codec_mode,MODE2)) { /* in case of HQ->ACELP switching, do not apply BPF */ st_fx->bpf_off_fx = 1; @@ -125,7 +123,7 @@ void acelp_core_enc_fx( } /* force safety-net LSFQ in the first frames after CNG segment */ - if( L_sub(st_fx->last_core_brate_fx,SID_2k40) <= 0 ) + if( LE_32(st_fx->last_core_brate_fx,SID_2k40)) { st_fx->Nb_ACELP_frames_fx = 0; move16(); @@ -134,7 +132,7 @@ void acelp_core_enc_fx( int_fs_fx = INT_FS_16k_FX; move16(); - if( sub(st_fx->L_frame_fx, L_FRAME) == 0) + if( EQ_16(st_fx->L_frame_fx, L_FRAME)) { int_fs_fx = INT_FS_FX; move16(); @@ -164,7 +162,7 @@ void acelp_core_enc_fx( * ACELP@12k8 / ACELP@16k switching *-----------------------------------------------------------------*/ test(); - IF( sub(st_fx->last_L_frame_fx,st_fx->L_frame_fx) != 0 && sub(st_fx->last_core_fx,HQ_CORE) != 0 ) + IF( NE_16(st_fx->last_L_frame_fx,st_fx->L_frame_fx)&&NE_16(st_fx->last_core_fx,HQ_CORE)) { /* in case of switching, do not apply BPF */ st_fx->bpf_off_fx = 1; @@ -175,7 +173,7 @@ void acelp_core_enc_fx( move16(); /* convert old quantized LSP vector */ - IF( sub(st_fx->L_frame_fx,L_FRAME) == 0 ) + IF( EQ_16(st_fx->L_frame_fx,L_FRAME)) { st_fx->rate_switching_reset = lsp_convert_poly_fx( st_fx->lsp_old_fx, st_fx->L_frame_fx, 0 ); } @@ -217,7 +215,7 @@ void acelp_core_enc_fx( test(); test(); - if(sub(st_fx->last_bwidth_fx,NB)==0 && sub(st_fx->bwidth_fx,NB)!=0 && st_fx->ini_frame_fx!=0) + if(EQ_16(st_fx->last_bwidth_fx,NB)&&NE_16(st_fx->bwidth_fx,NB)&&st_fx->ini_frame_fx!=0) { st_fx->rate_switching_reset=1; move16(); @@ -226,9 +224,9 @@ void acelp_core_enc_fx( * Encoding of CNG frames *----------------------------------------------------------------*/ test(); - IF ( L_sub(st_fx->core_brate_fx,SID_2k40) == 0 || L_sub(st_fx->core_brate_fx,FRAME_NO_DATA) == 0 ) + IF ( EQ_32(st_fx->core_brate_fx,SID_2k40)||EQ_32(st_fx->core_brate_fx,FRAME_NO_DATA)) { - IF( sub(st_fx->cng_type_fx,LP_CNG) == 0 ) + IF( EQ_16(st_fx->cng_type_fx,LP_CNG)) { /* Run CNG post parameter update */ cng_params_postupd_fx( st_fx->ho_circ_ptr_fx, &st_fx->cng_buf_cnt, st_fx->cng_exc2_buf, st_fx->cng_Qexc_buf, @@ -243,7 +241,7 @@ void acelp_core_enc_fx( } ELSE { - IF( L_sub(st_fx->core_brate_fx, SID_2k40) == 0 ) + IF( EQ_32(st_fx->core_brate_fx, SID_2k40)) { FdCng_encodeSID( st_fx->hFdCngEnc_fx, st_fx, st_fx->preemph_fac ); st_fx->last_CNG_L_frame_fx = st_fx->L_frame_fx; @@ -257,7 +255,7 @@ void acelp_core_enc_fx( Copy( exc2_fx, exc3_fx, st_fx->L_frame_fx ); - IF( L_sub(st_fx->core_brate_fx, SID_2k40) == 0 ) + IF( EQ_32(st_fx->core_brate_fx, SID_2k40)) { maxv = 0; move16(); @@ -268,7 +266,7 @@ void acelp_core_enc_fx( scale = norm_s(maxv); pt_res = exc_fx; L_ener = L_deposit_l(1); - IF( sub(st_fx->L_frame_fx, L_FRAME) == 0) + IF( EQ_16(st_fx->L_frame_fx, L_FRAME)) { FOR (i=0; i<128; i++) { @@ -302,9 +300,9 @@ void acelp_core_enc_fx( enr = round_fx(L_shl(L_tmp, 8)); /* Q8 (16+8-16) */ /* decrease the energy in case of WB input */ - IF( sub(st_fx->bwidth_fx, NB) != 0 ) + IF( NE_16(st_fx->bwidth_fx, NB)) { - IF( sub(st_fx->bwidth_fx,WB) == 0 ) + IF( EQ_16(st_fx->bwidth_fx,WB)) { IF( st_fx->CNG_mode_fx >= 0 ) { @@ -376,7 +374,7 @@ void acelp_core_enc_fx( *-----------------------------------------------------------------*/ test(); - IF ( L_sub(st_fx->last_core_brate_fx,FRAME_NO_DATA) == 0 || L_sub(st_fx->last_core_brate_fx,SID_2k40) == 0 ) + IF ( EQ_32(st_fx->last_core_brate_fx,FRAME_NO_DATA)||EQ_32(st_fx->last_core_brate_fx,SID_2k40)) { Copy( st_fx->lspCNG_fx, st_fx->lsp_old_fx, M ); @@ -428,9 +426,9 @@ void acelp_core_enc_fx( test(); test(); test(); - IF( ( sub(coder_type_fx,UNVOICED) != 0 && sub(coder_type_fx,AUDIO) != 0 && sub(coder_type_fx,INACTIVE) != 0 - && !(L_sub(st_fx->core_brate_fx,ACELP_8k00) <= 0 && sub(coder_type_fx,TRANSITION) != 0) ) - || (sub(coder_type_fx,INACTIVE) == 0 && L_sub(st_fx->total_brate_fx,ACELP_32k) >= 0) ) + IF( ( NE_16(coder_type_fx,UNVOICED)&&NE_16(coder_type_fx,AUDIO)&&NE_16(coder_type_fx,INACTIVE) + && !(LE_32(st_fx->core_brate_fx,ACELP_8k00) && NE_16(coder_type_fx,TRANSITION) ) ) + || (EQ_16(coder_type_fx,INACTIVE) && GE_32(st_fx->total_brate_fx,ACELP_32k) ) ) { nb_bits = Es_pred_bits_tbl[BIT_ALLOC_IDX_fx(st_fx->core_brate_fx, coder_type_fx, -1, -1)]; move16(); @@ -450,13 +448,13 @@ void acelp_core_enc_fx( encod_nelp_fx( st_fx, mem, inp_fx, Aw_fx, Aq_fx, res_fx, syn_fx, &tmp_noise_fx, exc_fx, exc2_fx, pitch_buf_fx, voice_factors_fx, bwe_exc_fx, Q_new, shift); } - ELSE IF( sub(coder_type_fx,UNVOICED) == 0 ) + ELSE IF( EQ_16(coder_type_fx,UNVOICED)) { /* UNVOICED frames (Gauss. excitation) */ encod_unvoiced_fx( st_fx, mem, inp_fx, Aw_fx, Aq_fx, vad_flag_fx, res_fx, syn_fx, &tmp_noise_fx, exc_fx, pitch_buf_fx, voice_factors_fx, bwe_exc_fx,Q_new,shift ); } - ELSE IF( sub(coder_type_fx,TRANSITION) == 0) + ELSE IF( EQ_16(coder_type_fx,TRANSITION)) { tc_subfr_fx = encod_tran_fx( st_fx, mem, st_fx->L_frame_fx, inp_fx, Aw_fx, Aq_fx, coder_type_fx, Es_pred_fx, T_op_fx, voicing_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf_fx, voice_factors_fx, bwe_exc_fx, gsc_attack_flag_fx, unbits_fx, sharpFlag_fx, shift, Q_new ); @@ -481,13 +479,12 @@ void acelp_core_enc_fx( calc_residu_fx( st_fx, inp_fx, res_fx, Aq_fx, 0, 0 ); st_fx->burst_ho_cnt_fx = 0; move16(); - /* VOICED frames in SC-VBR when bumped up*/ encod_gen_voic_fx( st_fx, mem, st_fx->L_frame_fx, sharpFlag_fx, inp_fx, Aw_fx, Aq_fx, coder_type_fx, Es_pred_fx, T_op_fx, voicing_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf_fx, voice_factors_fx, bwe_exc_fx, unbits_fx, shift, Q_new ); } } - ELSE IF( sub(coder_type_fx,AUDIO) == 0 || ( sub(coder_type_fx,INACTIVE) == 0 && L_sub(st_fx->core_brate_fx,ACELP_24k40) <= 0 ) ) + ELSE IF( EQ_16(coder_type_fx,AUDIO)||(EQ_16(coder_type_fx,INACTIVE)&&LE_32(st_fx->core_brate_fx,ACELP_24k40))) { /* AUDIO and INACTIVE frames (coded by GSC technology) */ encod_audio_fx( st_fx, mem, inp_fx, Aw_fx, Aq_fx, T_op_fx, voicing_fx, res_fx, syn_fx, exc_fx, pitch_buf_fx, voice_factors_fx, bwe_exc_fx, @@ -519,7 +516,7 @@ void acelp_core_enc_fx( * Modify the excitation signal when the noise is stationary *--------------------------------------------------------------------------------------*/ - IF ( sub(st_fx->nelp_mode_fx,1) != 0 ) + IF ( NE_16(st_fx->nelp_mode_fx,1)) { L_epsP[0] = L_Comp(epsP_h_fx[2],epsP_l_fx[2]); move32(); @@ -536,7 +533,7 @@ void acelp_core_enc_fx( FEC_encode_fx( st_fx, syn_fx, coder_type_fx, st_fx->clas_fx, pitch_buf_fx, res_fx, &st_fx->Last_pulse_pos_fx, st_fx->L_frame_fx, st_fx->total_brate_fx, st_fx->core_brate_fx, Q_new, shift ); - IF( sub(st_fx->L_frame_fx,L_FRAME) == 0 ) + IF( EQ_16(st_fx->L_frame_fx,L_FRAME)) { Copy( Aq_fx+2*(M+1), st_fx->cur_sub_Aq_fx, (M+1) ); } @@ -553,17 +550,17 @@ void acelp_core_enc_fx( test(); test(); - IF ( L_sub(st_fx->core_brate_fx,SID_2k40) != 0 && L_sub(st_fx->core_brate_fx,FRAME_NO_DATA) != 0 && L_sub(st_fx->core_brate_fx,PPP_NELP_2k80) != 0 ) + IF ( NE_32(st_fx->core_brate_fx,SID_2k40)&&NE_32(st_fx->core_brate_fx,FRAME_NO_DATA)&&NE_32(st_fx->core_brate_fx,PPP_NELP_2k80)) { /* reserved bits */ test(); test(); - IF ( sub(coder_type_fx,AUDIO) == 0 || ( sub(coder_type_fx,INACTIVE) == 0 && L_sub(st_fx->core_brate_fx,ACELP_24k40) <= 0 ) ) + IF ( EQ_16(coder_type_fx,AUDIO)||(EQ_16(coder_type_fx,INACTIVE)&&LE_32(st_fx->core_brate_fx,ACELP_24k40))) { nBits = 0; move16(); } - ELSE IF( sub(st_fx->L_frame_fx,L_FRAME) == 0 ) + ELSE IF( EQ_16(st_fx->L_frame_fx,L_FRAME)) { nBits = reserved_bits_tbl[BIT_ALLOC_IDX_fx(st_fx->core_brate_fx, coder_type_fx, -1, TC_SUBFR2IDX_fx(tc_subfr_fx))]; move16(); @@ -593,7 +590,7 @@ void acelp_core_enc_fx( test(); test(); test(); - IF ( (sub(st_fx->last_Opt_SC_VBR_fx,1)==0 && st_fx->Opt_SC_VBR_fx==0) || ((sub(st_fx->extl_fx,SWB_TBE)==0 || sub(st_fx->extl_fx,WB_TBE)==0 || sub(st_fx->extl_fx,FB_TBE)==0) && sub(st_fx->last_extl_fx,SWB_TBE)!=0 && sub(st_fx->last_extl_fx,WB_TBE)!=0 && sub(st_fx->last_extl_fx,FB_TBE)!=0) ) + IF ( (EQ_16(st_fx->last_Opt_SC_VBR_fx,1)&&st_fx->Opt_SC_VBR_fx==0)||((EQ_16(st_fx->extl_fx,SWB_TBE)||EQ_16(st_fx->extl_fx,WB_TBE)||EQ_16(st_fx->extl_fx,FB_TBE))&&NE_16(st_fx->last_extl_fx,SWB_TBE)&&NE_16(st_fx->last_extl_fx,WB_TBE)&&NE_16(st_fx->last_extl_fx,FB_TBE))) { st_fx->bwe_non_lin_prev_scale_fx = L_deposit_l(0); set16_fx( st_fx->old_bwe_exc_extended_fx, 0, NL_BUFF_OFFSET ); @@ -605,7 +602,7 @@ void acelp_core_enc_fx( non_linearity_fx( bwe_exc_fx, bwe_exc_extended_fx, L_FRAME32k, &st_fx->bwe_non_lin_prev_scale_fx, Q_new, coder_type_fx, voice_factors_fx, st_fx->L_frame_fx); } test(); - if ( L_sub(st_fx->core_brate_fx,SID_2k40) == 0 || L_sub(st_fx->core_brate_fx,FRAME_NO_DATA) == 0 ) + if ( EQ_32(st_fx->core_brate_fx,SID_2k40)||EQ_32(st_fx->core_brate_fx,FRAME_NO_DATA)) { st_fx->bwe_non_lin_prev_scale_fx = L_deposit_l(0); } @@ -617,14 +614,14 @@ void acelp_core_enc_fx( Es_pred_fx,Aq_fx, lsf_new_fx, lsp_new_fx, old_bwe_exc_fx ); test(); - IF( (st_fx->Opt_DTX_ON_fx != 0 ) && (L_sub(st_fx->core_brate_fx,SID_2k40) > 0) ) + IF( (st_fx->Opt_DTX_ON_fx != 0 ) && (GT_32(st_fx->core_brate_fx,SID_2k40))) { /* update CNG parameters in active frames */ cng_params_upd_fx( lsp_new_fx, exc_fx, st_fx->L_frame_fx, &st_fx->ho_circ_ptr_fx, st_fx->ho_ener_circ_fx, &st_fx->ho_circ_size_fx, st_fx->ho_lsp_circ_fx, Q_new, ENC, NULL, &st_fx->cng_buf_cnt, st_fx->cng_exc2_buf, st_fx->cng_Qexc_buf, st_fx->cng_brate_buf, st_fx->last_active_brate_fx ); - IF( sub(st_fx->L_frame_fx,L_FRAME) == 0 ) + IF( EQ_16(st_fx->L_frame_fx,L_FRAME)) { /* store LSPs@16k, potentially to be used in CNG@16k */ Copy( st_fx->lsp_old16k_fx, &(st_fx->ho_lsp_circ2_fx[(st_fx->ho_circ_ptr_fx)*M]), M ); @@ -633,21 +630,21 @@ void acelp_core_enc_fx( /* Set 16k LSP flag for CNG buffer */ st_fx->ho_16k_lsp_fx[st_fx->ho_circ_ptr_fx] = 0; move16(); - if(sub(st_fx->L_frame_fx, L_FRAME) != 0) + if(NE_16(st_fx->L_frame_fx, L_FRAME)) { st_fx->ho_16k_lsp_fx[st_fx->ho_circ_ptr_fx] = 1; move16(); } /* efficient DTX hangover control */ - IF ( sub(st_fx->burst_ho_cnt_fx,1) > 0 ) + IF ( GT_16(st_fx->burst_ho_cnt_fx,1)) { dtx_hangover_control_fx( st_fx, lsp_new_fx ); } } /* SC-VBR update of average data rate */ - IF ( sub(vad_flag_fx,1) == 0 ) + IF ( EQ_16(vad_flag_fx,1)) { update_average_rate_fx( st_fx ); diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c index a682d3375599c61f87a1adfef08049f252968b84..3cd8f3ab639ae2bfec78c4dbb02d38a3f9b07afa 100644 --- a/lib_enc/acelp_core_switch_enc_fx.c +++ b/lib_enc/acelp_core_switch_enc_fx.c @@ -1,15 +1,12 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include #include "options.h" #include "rom_com_fx.h" #include "prot_fx.h" -#include "stl.h" -#include "wmc_auto.h" - /* required for wmc_tool */ -#include "wmc_auto.h" +#include "stl.h" /* required for wmc_tool */ /*---------------------------------------------------------------------* * Local functions @@ -66,11 +63,11 @@ void acelp_core_switch_enc_fx( * set switching frame bit-rate *----------------------------------------------------------------*/ - IF( sub(st_fx->last_L_frame_fx, L_FRAME) == 0 ) /* ACELP@12k8 core */ + IF( EQ_16(st_fx->last_L_frame_fx, L_FRAME)) /* ACELP@12k8 core */ { inp = inp12k8; - IF( L_sub(st_fx->core_brate_fx, ACELP_24k40 ) > 0 ) + IF( GT_32(st_fx->core_brate_fx, ACELP_24k40 )) { cbrate = L_add(ACELP_24k40, 0); } @@ -83,11 +80,11 @@ void acelp_core_switch_enc_fx( { inp = inp16k; - IF( L_sub(st_fx->core_brate_fx, ACELP_8k00) <= 0 ) + IF( LE_32(st_fx->core_brate_fx, ACELP_8k00)) { cbrate = L_add(ACELP_8k00, 0); } - ELSE IF (L_sub(st_fx->core_brate_fx, ACELP_14k80) <= 0 ) + ELSE IF (LE_32(st_fx->core_brate_fx, ACELP_14k80)) { cbrate = L_add(ACELP_14k80, 0); } @@ -97,7 +94,7 @@ void acelp_core_switch_enc_fx( } } - IF( sub(st_fx->last_L_frame_fx, L_FRAME) != 0 ) + IF( NE_16(st_fx->last_L_frame_fx, L_FRAME) ) { T_op[0] = shr(add(round_fx(L_shl(L_mult(20480, T_op[0]), 2)), 1), 1); move16(); @@ -131,7 +128,7 @@ void acelp_core_switch_enc_fx( test(); test(); - IF( !( ( sub(st_fx->last_L_frame_fx, L_FRAME16k) == 0 && sub(inner_frame_tbl[st_fx->bwidth_fx], L_FRAME16k) == 0 ) || sub(inner_frame_tbl[st_fx->bwidth_fx], L_FRAME8k) == 0 ) ) + IF( !( ( EQ_16(st_fx->last_L_frame_fx, L_FRAME16k)&&EQ_16(inner_frame_tbl[st_fx->bwidth_fx],L_FRAME16k))||EQ_16(inner_frame_tbl[st_fx->bwidth_fx],L_FRAME8k))) { bwe_switch_enc_fx( st_fx, (const Word16 *)st_fx->old_input_signal_fx ); } @@ -200,7 +197,7 @@ static void encod_gen_voic_core_switch_fx( unbits = 0; move16(); - IF( sub(L_frame, L_FRAME) == 0 ) + IF( EQ_16(L_frame, L_FRAME)) { T0_max = PIT_MAX; move16(); @@ -236,7 +233,7 @@ static void encod_gen_voic_core_switch_fx( Copy( res, exc, L_SUBFR ); - IF( sub(L_frame,L_FRAME16k)==0 ) + IF( EQ_16(L_frame,L_FRAME16k)) { weight_a_fx( A, Ap, GAMMA16k, M ); /* Bandwidth expansion of A(z) filter coefficients */ find_targets_fx(inp, mem->mem_syn, 0, &mem->mem_w0, Aq, res, L_SUBFR, Ap, PREEMPH_FAC_16k, xn, cn, h1); @@ -281,7 +278,7 @@ static void encod_gen_voic_core_switch_fx( lp_select = lp_filt_exc_enc_fx( MODE1, core_bitrate, 0, coder_type, 0, exc, h1, xn, y1, xn2, L_SUBFR, L_frame, g_corr, clip_gain, &gain_pit, &lp_flag ); - IF( sub(lp_flag,NORMAL_OPERATION) == 0 ) + IF( EQ_16(lp_flag,NORMAL_OPERATION)) { push_indice_fx( st_fx, IND_LP_FILT_SELECT, lp_select, 1 ); } @@ -296,7 +293,7 @@ static void encod_gen_voic_core_switch_fx( /*-----------------------------------------------------------------* * Gain encoding *-----------------------------------------------------------------*/ - IF( sub(L_frame,L_FRAME) == 0 ) + IF( EQ_16(L_frame,L_FRAME)) { gain_enc_mless_fx( st_fx,core_bitrate, L_frame, TRANSITION, 0, -1, xn, y1, shift_wsp, y2, code, st_fx->old_Es_pred_fx, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain ); @@ -387,7 +384,7 @@ static void bwe_switch_enc_fx( hp_filter_fx = ptmp; fdelay_fx=i_mult2(16,delta_fx); - IF(sub(st_fx->last_L_frame_fx,L_FRAME)==0) + IF(EQ_16(st_fx->last_L_frame_fx,L_FRAME)) { fdelay_fx=i_mult2(20,delta_fx); } @@ -423,11 +420,11 @@ static void bwe_switch_enc_fx( maxd1_fx = sub(tmp,add(gapsize_fx,fdelay_fx)); - IF (sub(delta_fx, 2) == 0) + IF (EQ_16(delta_fx, 2)) { maxd1_fx = shr(maxd1_fx,1); } - ELSE IF (sub(delta_fx, 3) == 0 ) + ELSE IF (EQ_16(delta_fx, 3)) { maxd1_fx = extract_h(L_mult(maxd1_fx, 10923)); } @@ -447,7 +444,7 @@ static void bwe_switch_enc_fx( L_tmp2 = L_shr(L_tmp2, sub(add(shl(q_tmp2,1),Qmc),shift)); L_tmp3 = L_shr(L_tmp3, sub(add(q_tmp1,Qsq),shift)); - IF (L_sub(L_tmp2,L_tmp3)>=0) + IF (GE_32(L_tmp2,L_tmp3)) { d1m_fx = k; move16(); diff --git a/lib_enc/acelp_enc_util.c b/lib_enc/acelp_enc_util.c index 1db62824e6ab24fea3e9c268d6ce1e08ab2975ea..4f510ac92296dd28932669683ac3a66f06b3aebb 100644 --- a/lib_enc/acelp_enc_util.c +++ b/lib_enc/acelp_enc_util.c @@ -1,23 +1,18 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include #include #include "stl.h" -#include "wmc_auto.h" - #include "prot_fx.h" #include "basop_util.h" #include "options.h" #include "cnst_fx.h" #include "stl.h" -#include "wmc_auto.h" - #include "rom_com_fx.h" #include "rom_enc_fx.h" -#include "wmc_auto.h" #define _1_Q9 0x200 @@ -73,7 +68,7 @@ Word16 E_ACELP_toeplitz_mul(const Word16 R[], const Word16 c[], Word16 d[], cons /* tot += 3*max / 8 */ L_maxloc = L_shr(L_maxloc, 2); /* Do not warn saturation of L_tot, since its for headroom estimation. */ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF L_tot = L_add(L_tot, L_maxloc); /* +max/4 */ L_maxloc = L_shr(L_maxloc, 1); L_tot = L_add(L_tot, L_maxloc); /* +max/8 */ @@ -86,7 +81,7 @@ Word16 E_ACELP_toeplitz_mul(const Word16 R[], const Word16 c[], Word16 d[], cons { L_tot = L_add(L_tot, L_maxloc); /* +max/16 */ } - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON } /* Find the number of right shifts to do on y32[] so that */ @@ -162,12 +157,14 @@ void E_ACELP_conv( FOR (k=0; k @@ -9,11 +9,8 @@ #include "rom_enc_fx.h" /* Encoder static table prototypes */ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ -#include "stl.h" -#include "wmc_auto.h" - /* required by wmc_tool */ +#include "stl.h" /* required by wmc_tool */ #include "basop_util.h" -#include "wmc_auto.h" /*-------------------------------------------------------------------* * amr_wb_enc() @@ -108,7 +105,7 @@ void amr_wb_enc_fx( st->bpf_off_fx = 0; move16(); test(); - if( sub(st->last_core_fx,HQ_CORE) == 0 || sub(st->last_codec_mode,MODE2) == 0 ) + if( EQ_16(st->last_core_fx,HQ_CORE)||EQ_16(st->last_codec_mode,MODE2)) { st->bpf_off_fx = 1; move16(); @@ -117,7 +114,7 @@ void amr_wb_enc_fx( move16(); /* Updates in case of EVS primary mode -> AMR-WB IO mode switching */ - IF( sub(st->last_core_fx,AMR_WB_CORE) != 0 ) + IF( NE_16(st->last_core_fx,AMR_WB_CORE)) { updt_IO_switch_enc_fx( st, input_frame); } @@ -146,7 +143,7 @@ void amr_wb_enc_fx( /* in case of switching, reset AMR-WB BWE memories */ test(); - IF( L_sub(st->total_brate_fx,ACELP_23k85) == 0 && L_sub(st->last_core_brate_fx,ACELP_23k85) != 0 ) + IF( EQ_32(st->total_brate_fx,ACELP_23k85)&&NE_32(st->last_core_brate_fx,ACELP_23k85)) { hf_cod_init_fx( st->mem_hp400_enc_fx, st->mem_hf_enc_fx, st->mem_syn_hf_enc_fx, st->mem_hf2_enc_fx, &st->gain_alpha_fx ); } @@ -181,7 +178,7 @@ void amr_wb_enc_fx( move16(); test(); test(); - IF( sub(st->last_core_fx,AMR_WB_CORE) != 0 && sub(st->last_L_frame_fx,L_FRAME16k) == 0 && sub(st->last_core_fx,HQ_CORE) != 0) + IF( NE_16(st->last_core_fx,AMR_WB_CORE)&&EQ_16(st->last_L_frame_fx,L_FRAME16k)&&NE_16(st->last_core_fx,HQ_CORE)) { /* in case of switching, do not apply BPF */ st->bpf_off_fx = 1; @@ -208,15 +205,15 @@ void amr_wb_enc_fx( } /* update buffer of old subframe pitch values */ - IF( sub(st->last_L_frame_fx,L_FRAME) != 0 ) + IF( NE_16(st->last_L_frame_fx,L_FRAME)) { move16(); - IF( sub(st->last_L_frame_fx,L_FRAME32k) == 0 ) + IF( EQ_16(st->last_L_frame_fx,L_FRAME32k)) { /* (float)12800/(float)32000; */ tmp = 13107; } - ELSE IF( sub(st->last_L_frame_fx,512) == 0 ) + ELSE IF( EQ_16(st->last_L_frame_fx,512)) { /* (float)12800/(float)25600; */ tmp = 16384; @@ -241,7 +238,7 @@ void amr_wb_enc_fx( } test(); - if( sub(st->last_bwidth_fx,NB)==0 && st->ini_frame_fx!=0 ) + if( EQ_16(st->last_bwidth_fx,NB)&&st->ini_frame_fx!=0) { st->rate_switching_reset=1; move16(); @@ -308,12 +305,12 @@ void amr_wb_enc_fx( * Select SID or FRAME_NO_DATA frame if DTX enabled *-----------------------------------------------------------------*/ - IF ( sub(st->last_core_fx,AMR_WB_CORE) != 0 ) + IF ( NE_16(st->last_core_fx,AMR_WB_CORE)) { st->fd_cng_reset_flag = 1; move16(); } - ELSE IF ( s_and((st->fd_cng_reset_flag > 0),(sub(st->fd_cng_reset_flag,10) < 0)) ) + ELSE IF ( s_and((st->fd_cng_reset_flag > 0),(Word16)(LT_16(st->fd_cng_reset_flag,10)))) { st->fd_cng_reset_flag = add(st->fd_cng_reset_flag,1); } @@ -339,7 +336,7 @@ void amr_wb_enc_fx( long_enr_fx( st, Etot, localVAD_HE_SAD, high_lpn_flag ); relE = sub(Etot, st->lp_speech_fx); /* Q8 */ - IF( sub(st->bwidth_fx, NB) != 0 ) + IF( NE_16(st->bwidth_fx, NB)) { lp_bckr = Mean32( st->bckr_fx, 10 ); } @@ -365,7 +362,7 @@ void amr_wb_enc_fx( bw_detect_fx( st, st->input, localVAD, NULL, NULL ); /* in AMR_WB IO, limit the maximum band-width to WB */ - if( sub(st->bwidth_fx,WB) > 0 ) + if( GT_16(st->bwidth_fx,WB)) { st->bwidth_fx = WB; move16(); @@ -399,7 +396,7 @@ void amr_wb_enc_fx( } test(); - if( sub(excitation_max_test,8192)>0 && shift==0 ) + if( GT_16(excitation_max_test,8192)&&shift==0) { shift = -1; move16(); @@ -426,7 +423,7 @@ void amr_wb_enc_fx( *----------------------------------------------------------------*/ test(); - IF( L_sub(st->input_Fs_fx, 16000) == 0 ) + IF( EQ_32(st->input_Fs_fx, 16000)) { /* no resampling needed, only delay adjustement to account for the FIR resampling delay */ tmps = NS2SA_fx2(16000, DELAY_FIR_RESAMPL_NS); @@ -434,7 +431,7 @@ void amr_wb_enc_fx( Copy_Scale_sig( st->input, new_inp_16k + tmps, sub(input_frame, tmps), -1 ); /* Input in Q0 -> Output in Q-1 to mimic the resampling filter */ Copy( st->input + input_frame - shl(tmps,1), st->mem_decim16k_fx, shl(tmps,1) ); /* memory still in Q0 */ } - ELSE IF( L_sub(st->input_Fs_fx, 32000) == 0 || L_sub(st->input_Fs_fx, 48000) == 0 ) + ELSE IF( EQ_32(st->input_Fs_fx, 32000)||EQ_32(st->input_Fs_fx,48000)) { modify_Fs_fx( st->input, input_frame, st->input_Fs_fx, new_inp_16k, 16000, st->mem_decim16k_fx, 0 ); } @@ -444,7 +441,7 @@ void amr_wb_enc_fx( *----------------------------------------------------------------*/ test(); - IF ( L_sub(st->core_brate_fx,SID_1k75) == 0 || L_sub(st->core_brate_fx,FRAME_NO_DATA) == 0 ) + IF ( EQ_32(st->core_brate_fx,SID_1k75)||EQ_32(st->core_brate_fx,FRAME_NO_DATA)) { /* encode CNG parameters */ CNG_enc_fx( st, L_FRAME, Aq, inp, ener, isp_new, isf_new , &allow_cn_step, st->burst_ho_cnt_fx, sub(Q_new,1), @@ -492,7 +489,7 @@ void amr_wb_enc_fx( * After inactive period, use the most up-to-date ISPs *-----------------------------------------------------------------*/ test(); - IF( L_sub(st->last_core_brate_fx,FRAME_NO_DATA) == 0 || L_sub(st->last_core_brate_fx,SID_1k75) == 0 ) + IF( EQ_32(st->last_core_brate_fx,FRAME_NO_DATA)||EQ_32(st->last_core_brate_fx,SID_1k75)) { Copy( st->lspCNG_fx, st->lsp_old_fx, M ); E_LPC_isp_isf_conversion( st->lspCNG_fx, st->lsf_old_fx, M); @@ -509,7 +506,7 @@ void amr_wb_enc_fx( * Calculation of LP residual (filtering through A[z] filter) *---------------------------------------------------------------*/ - calc_residu_fx(st, inp, res, Aq, 0, 0 ); + calc_residu_fx( st, inp, res, Aq, 0, 0 ); st->burst_ho_cnt_fx = 0; move16(); @@ -547,7 +544,7 @@ void amr_wb_enc_fx( Copy( &old_inp[L_FRAME], st->old_inp_12k8_fx, L_INP_MEM ); /* update old input signal @16kHz buffer */ - IF( L_sub(st->input_Fs_fx,8000) > 0 ) + IF( GT_32(st->input_Fs_fx,8000)) { Copy( &old_inp_16k[L_FRAME16k], st->old_inp_16k_fx, L_INP_MEM ); } @@ -587,21 +584,21 @@ void amr_wb_enc_fx( st->prev_Q_new = Q_new; /* Increase the counter of initialization frames */ - if( sub(st->ini_frame_fx,MAX_FRAME_COUNTER) < 0 ) + if( LT_16(st->ini_frame_fx,MAX_FRAME_COUNTER)) { st->ini_frame_fx = add(st->ini_frame_fx,1); } - if( L_sub(st->core_brate_fx,SID_1k75) > 0 ) + if( GT_32(st->core_brate_fx,SID_1k75)) { st->last_active_brate_fx = st->total_brate_fx; move32(); } test(); - IF ( L_sub(st->core_brate_fx,SID_1k75) > 0 && st->first_CNG_fx ) + IF ( GT_32(st->core_brate_fx,SID_1k75)&&st->first_CNG_fx) { - if( sub(st->act_cnt_fx,BUF_DEC_RATE) >= 0 ) + if( GE_16(st->act_cnt_fx,BUF_DEC_RATE)) { st->act_cnt_fx = 0; move16(); @@ -610,13 +607,13 @@ void amr_wb_enc_fx( st->act_cnt_fx = add(st->act_cnt_fx,1); test(); - if( sub(st->act_cnt_fx,BUF_DEC_RATE) == 0 && st->ho_hist_size_fx > 0 ) + if( EQ_16(st->act_cnt_fx,BUF_DEC_RATE)&&st->ho_hist_size_fx>0) { st->ho_hist_size_fx = sub(st->ho_hist_size_fx,1); } st->act_cnt2_fx = add(st->act_cnt2_fx,1); - if( sub(st->act_cnt2_fx, MIN_ACT_CNG_UPD) >= 0 ) + if( GE_16(st->act_cnt2_fx, MIN_ACT_CNG_UPD)) { st->act_cnt2_fx = MIN_ACT_CNG_UPD; move16(); diff --git a/lib_enc/analy_lp_fx.c b/lib_enc/analy_lp_fx.c index cb254d457cc7176e4bbaa746bc22031a08cb7726..07e2248655629df3fa7eb2eccc0f2e5e69c57f86 100644 --- a/lib_enc/analy_lp_fx.c +++ b/lib_enc/analy_lp_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -8,8 +8,6 @@ #include "rom_enc_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*-------------------------------------------------------------------* * analy_lp() @@ -50,7 +48,7 @@ void analy_lp_fx( const Word16 *pt; Word16 half_frame; - IF( sub(L_frame,L_FRAME) == 0 ) + IF( EQ_16(L_frame,L_FRAME)) { wind_length = L_LP; move16(); diff --git a/lib_enc/analy_sp.c b/lib_enc/analy_sp.c index 6b9095886f14f80ceedffcc67ba497d030530a57..6aa9c4d410417fd97999dc531f35af49e03cc44c 100644 --- a/lib_enc/analy_sp.c +++ b/lib_enc/analy_sp.c @@ -1,17 +1,14 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" #include "cnst_fx.h" #include "stl.h" -#include "wmc_auto.h" - #include "basop_util.h" #include "prot_fx.h" #include "rom_enc_fx.h" #include -#include "wmc_auto.h" static void find_enr( Word16 data[], Word32 band[], Word32 *ptE, Word32 *LEtot, const Word16 min_band, const Word16 max_band, @@ -276,9 +273,9 @@ static void find_enr( BASOP_SATURATE_WARNING_ON; test(); - IF (sub(i,min_band) >= 0 && sub(i,max_band) <= 0) + IF (GE_16(i,min_band)&&LE_16(i,max_band)) { - IF (L_sub(band[i],e_min) < 0) + IF (LT_32(band[i],e_min)) { Ltmp1 = L_shl(e_min, 0); exp_band = 0; @@ -301,7 +298,7 @@ static void find_enr( move32(); } - IF (sub(BIN_FREQ_FX, 50) == 0) + IF (EQ_16(BIN_FREQ_FX, 50)) { /*-----------------------------------------------------------------* * Continue compute the E per critical band for high frequencies @@ -349,9 +346,9 @@ static void find_enr( BASOP_SATURATE_WARNING_ON; test(); - IF (sub(i,min_band) >= 0 && sub(i,max_band) <= 0) + IF (GE_16(i,min_band)&&LE_16(i,max_band)) { - IF (L_sub(band[i],e_min) < 0) + IF (LT_32(band[i],e_min)) { Ltmp1 = L_shl(e_min, 0); exp_band = 0; diff --git a/lib_enc/ari_enc.c b/lib_enc/ari_enc.c index ad10c8111955a88b74039a3f7fd3ae52ef01c094..78b7e56a052a5938a896dcd69a38ca37167a85be 100644 --- a/lib_enc/ari_enc.c +++ b/lib_enc/ari_enc.c @@ -1,17 +1,14 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include #include "assert.h" #include "stl.h" -#include "wmc_auto.h" - #include "basop_mpy.h" #include "cnst_fx.h" #include "rom_com_fx.h" #include "prot_fx.h" -#include "wmc_auto.h" /** * \brief Copy state @@ -86,7 +83,7 @@ Word16 ari_done_encoding_14bits(Word16 *ptr, Word16 bp, TastatEnc *s) bit = 0; move16(); - if ( L_sub(s->low,ari_q1new) >= 0 ) + if ( GE_32(s->low,ari_q1new)) { bit = s_xor(bit,1); } @@ -140,13 +137,13 @@ Word16 ari_encode_14bits_ext( FOR (i = 0; i < 0x7FFF; i++) { - IF (L_sub(high, ari_q2new) <= 0) + IF (LE_32(high, ari_q2new)) { bp = ari_put_bit_plus_follow(ptr, bp, bits_to_follow, 0); bits_to_follow = 0; move16(); } - ELSE IF (L_sub(low, ari_q2new) >= 0) + ELSE IF (GE_32(low, ari_q2new)) { bp = ari_put_bit_plus_follow(ptr, bp, bits_to_follow, 1); bits_to_follow = 0; @@ -157,7 +154,7 @@ Word16 ari_encode_14bits_ext( ELSE { test(); - IF (L_sub(low, ari_q1new) >= 0 && L_sub(high, ari_q3new) <= 0) + IF (GE_32(low, ari_q1new)&&LE_32(high,ari_q3new)) { /* Output an opposite bit */ /* later if in middle half. */ @@ -201,13 +198,13 @@ static Word16 ari_encode_14bits_high_low(Word16 *ptr, Word16 bp, Word16 bits, Ta tmp = sub(16, bits); WHILE (add(add(bp, bits_to_follow), tmp) < 0) { - IF (L_sub(high, ari_q2new) <= 0) + IF (LE_32(high, ari_q2new)) { bp = ari_put_bit_plus_follow(ptr, bp, bits_to_follow, 0); bits_to_follow = 0; move16(); } - ELSE IF (L_sub(low, ari_q2new) >= 0) + ELSE IF (GE_32(low, ari_q2new)) { bp = ari_put_bit_plus_follow(ptr, bp, bits_to_follow, 1); bits_to_follow = 0; @@ -218,7 +215,7 @@ static Word16 ari_encode_14bits_high_low(Word16 *ptr, Word16 bp, Word16 bits, Ta ELSE { test(); - IF (L_sub(low, ari_q1new) >= 0 && L_sub(high, ari_q3new) <= 0) + IF (GE_32(low, ari_q1new)&&LE_32(high,ari_q3new)) { /* Output an opposite bit */ /* later if in middle half. */ @@ -301,7 +298,7 @@ Word16 ari_done_cbr_encoding_14bits(Word16 *ptr, Word16 bp, Word16 bits, TastatE Word16 high, tmp, k; tmp = sub(bits, 16); - WHILE (sub(sub(tmp, bp), s->vobf) > 0) + WHILE (GT_16(sub(tmp, bp), s->vobf)) { bp = ari_encode_14bits_sign(ptr, bp, bits, s, 0); } diff --git a/lib_enc/ari_hm_enc.c b/lib_enc/ari_hm_enc.c index 596b9d7c2be92ba00019dc6fc8deb793083becb0..f1577efa29627ff5941a76d6009dc59b0ed8b079 100644 --- a/lib_enc/ari_hm_enc.c +++ b/lib_enc/ari_hm_enc.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ @@ -8,14 +8,11 @@ #include #include #include "stl.h" -#include "wmc_auto.h" - #include "cnst_fx.h" #include "basop_util.h" #include "rom_com_fx.h" #include "rom_enc_fx.h" #include "prot_fx.h" -#include "wmc_auto.h" Word16 EncodeIndex( Word16 Bandwidth, @@ -117,7 +114,7 @@ static void SearchPeriodicityIndex_Range( FractionalResolution ); - if (sub(CurrentScore, BestScore) > 0) + if (GT_16(CurrentScore, BestScore)) { BestIndex = Index; move16(); @@ -125,7 +122,7 @@ static void SearchPeriodicityIndex_Range( BestScore = s_max(BestScore, CurrentScore); } - if (sub(BestScore, *Score) > 0) + if (GT_16(BestScore, *Score)) { *PeriodicityIndex = BestIndex; move16(); @@ -144,7 +141,7 @@ static void SearchPeriodicityIndex_Range( FractionalResolution ); - if (sub(CurrentScore, BestScore) > 0) + if (GT_16(CurrentScore, BestScore)) { *PeriodicityIndex = Index; move16(); @@ -163,7 +160,7 @@ static void SearchPeriodicityIndex_Range( FractionalResolution ); - if (sub(CurrentScore, BestScore) > 0) + if (GT_16(CurrentScore, BestScore)) { *PeriodicityIndex = Index; move16(); @@ -226,13 +223,13 @@ Word16 SearchPeriodicityIndex( AbsMdct3[i + 2] = round_fx(L_add(L_add(A, B), C)); } - IF (sub(i, sub(NumToConsider, 1)) < 0) + IF (LT_16(i, sub(NumToConsider, 1))) { C = L_shl(L_abs(Mdct[i + 1]), s); AbsMdct3[i] = round_fx(L_add(L_add(A, B), C)); } - IF (sub(i, sub(NumToConsider, 2)) < 0) + IF (LT_16(i, sub(NumToConsider, 2))) { A = L_shl(L_abs(Mdct[i + 2]), s); assert(C != -3000); @@ -259,11 +256,11 @@ Word16 SearchPeriodicityIndex( } test(); - IF ((LtpPitchLag > 0) && (sub(LtpGain, kLtpHmGainThr) > 0)) + IF ((LtpPitchLag > 0) && (GT_16(LtpGain, kLtpHmGainThr))) { Bandwidth = 0; move16(); - if (sub(NumToConsider, 256) >= 0) + if (GE_16(NumToConsider, 256)) { Bandwidth = 1; move16(); @@ -279,7 +276,7 @@ Word16 SearchPeriodicityIndex( Lag = L_shr(L_mult0(LtpPitchLag, Ratios[Bandwidth][LtpPitchIndex][Multiplier-1]), 8); test(); - IF ((L_sub(Lag, 4<= 0) && (L_sub(Lag, tmp32) <= 0)) + IF ((GE_32(Lag, 4< 0) + if (GT_16(CurrentScore, Score)) { PeriodicityIndex = s_or(Multiplier, kLtpHmFlag); } @@ -307,7 +304,7 @@ Word16 SearchPeriodicityIndex( FOR (i = 4; i < NumToConsider - 1; i += 3) { - if (L_sub(AbsMdct3[i], AbsMdct3[MaxAt]) > 0) + if (GT_32(AbsMdct3[i], AbsMdct3[MaxAt])) { MaxAt = i; move16(); @@ -315,7 +312,7 @@ Word16 SearchPeriodicityIndex( A = L_add(A, L_shr(AbsMdct3[i], 6)); } - if (L_sub(L_shr(AbsMdct3[MaxAt], 6), Mpy_32_16_1(A, 22938/*0.7 Q15*/)) > 0) + if (GT_32(L_shr(AbsMdct3[MaxAt], 6), Mpy_32_16_1(A, 22938/*0.7 Q15*/))) { NumToConsider = s_min( NumToConsider, add(MaxAt, 4) ); } @@ -354,7 +351,7 @@ Word16 SearchPeriodicityIndex( &Score ); - IF (sub(NumToConsider, 128) <= 0) /* no long lags for band-limited MDCTs */ + IF (LE_16(NumToConsider, 128)) /* no long lags for band-limited MDCTs */ { SearchPeriodicityIndex_Range( AbsMdct3, @@ -369,7 +366,7 @@ Word16 SearchPeriodicityIndex( } ELSE { test(); - IF (sub(TargetBits, kSmallerLagsTargetBitsThreshold) > 0 && sub(NumToConsider, 256) >= 0) + IF (GT_16(TargetBits, kSmallerLagsTargetBitsThreshold)&&GE_16(NumToConsider,256)) { SearchPeriodicityIndex_Range( AbsMdct3, @@ -413,9 +410,9 @@ Word16 SearchPeriodicityIndex( tmp = sub(norm_l(tmp32), 1); tmp2 = norm_l(AbsTotal); tmp3 = div_s( round_fx(L_shl(tmp32, tmp)), round_fx(L_shl(AbsTotal, tmp2)) ); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF *RelativeScore = shr(tmp3, add(sub(tmp, tmp2), 2)); /* -> 2Q13 */ move16(); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON } ELSE { @@ -564,7 +561,7 @@ static void tcx_hm_quantize_gain( assert(coder_type==VOICED || coder_type == GENERIC); s=0; move16(); - if (sub(coder_type,VOICED) == 0) + if (EQ_16(coder_type,VOICED)) { s=1; move16(); @@ -576,7 +573,7 @@ static void tcx_hm_quantize_gain( move16(); /* Disable the harmonic model if periodicity is very low */ - IF ( sub(relative_score,kLowPeriodicityThr[s]) < 0 ) + IF ( LT_16(relative_score,kLowPeriodicityThr[s])) { return; } @@ -591,7 +588,7 @@ static void tcx_hm_quantize_gain( be = tcx_hm_get_re(x16, *gain, lag, fract_res, p, env, L_frame); - IF ( sub(coder_type,GENERIC) == 0 ) + IF ( EQ_16(coder_type,GENERIC)) { e = tcx_hm_get_re( x16, @@ -607,7 +604,7 @@ static void tcx_hm_quantize_gain( move16(); /* pe is Q14 */ - IF ( L_sub(L_shl(Mpy_32_16_1(e,pe),1),be) < 0 ) + IF ( LT_32(L_shl(Mpy_32_16_1(e,pe),1),be)) { *gain_idx = 0; move16(); @@ -640,7 +637,7 @@ static void tcx_hm_quantize_gain( } /* Minimum selection, pe is Q14 */ - IF ( L_sub(L_shl(Mpy_32_16_1(e,pe),1),be) < 0 ) + IF ( LT_32(L_shl(Mpy_32_16_1(e,pe),1),be)) { be = L_add(e, 0); *gain_idx = g; @@ -701,7 +698,7 @@ void tcx_hm_analyse( /* Disable HM for non-GENERC, VOICED modes */ - if ( sub(coder_type, VOICED) < 0 ) + if ( LT_16(coder_type, VOICED)) { *hm_bits_out = 0; move16(); @@ -713,7 +710,7 @@ void tcx_hm_analyse( bw_flag = 0; move16(); - if (sub(L_frame, 256) >= 0) + if (GE_16(L_frame, 256)) { bw_flag = 1; move16(); @@ -737,7 +734,7 @@ void tcx_hm_analyse( prm_hm[1], bw_flag, LtpPitchLag, - (( sub(sub(targetBits, hm_bits),kSmallerLagsTargetBitsThreshold) <= 0 ) || !bw_flag), + (( LE_16(sub(targetBits, hm_bits),kSmallerLagsTargetBitsThreshold) ) || !bw_flag), &fract_res, &lag ); @@ -775,7 +772,7 @@ void tcx_hm_analyse( hm_bits = add(hm_bits, CountIndexBits(bw_flag, prm_hm[1])); - if (sub(coder_type, VOICED) == 0) + if (EQ_16(coder_type, VOICED)) { hm_bits = add(hm_bits, kTcxHmNumGainBits); } diff --git a/lib_enc/arith_coder_enc.c b/lib_enc/arith_coder_enc.c index 7145e0b80ef100e61dce26321bc207e9147fdef8..2d27543854a3df172c645780c94b5fbe2d7f7d6d 100644 --- a/lib_enc/arith_coder_enc.c +++ b/lib_enc/arith_coder_enc.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -13,8 +13,6 @@ #include "basop_util.h" #include "rom_com_fx.h" #include "stl.h" -#include "wmc_auto.h" - /* Returns: estimated SQ scale Q15-e */ static Word16 tcx_arith_estimate_scale( @@ -106,19 +104,19 @@ static void MinHeapify_i(Heap *H, Word16 i) largest = i; move16(); - if (L_sub(H->mElem[left].mScore, H->mElem[largest].mScore) < 0) + if (LT_32(H->mElem[left].mScore, H->mElem[largest].mScore)) { largest = left; move16(); } - if (L_sub(H->mElem[right].mScore, H->mElem[largest].mScore) < 0) + if (LT_32(H->mElem[right].mScore, H->mElem[largest].mScore)) { largest = right; move16(); } - WHILE (sub(largest, i) != 0) + WHILE (NE_16(largest, i)) { T.mIndex = H->mElem[i].mIndex; move16(); @@ -140,13 +138,13 @@ static void MinHeapify_i(Heap *H, Word16 i) left = add(shl(i, 1), 1); right = add(left, 1); - if (L_sub(H->mElem[left].mScore, H->mElem[largest].mScore) < 0) + if (LT_32(H->mElem[left].mScore, H->mElem[largest].mScore)) { largest = left; move16(); } - if (L_sub(H->mElem[right].mScore, H->mElem[largest].mScore) < 0) + if (LT_32(H->mElem[right].mScore, H->mElem[largest].mScore)) { largest = right; move16(); @@ -195,7 +193,7 @@ static Word16 tcx_arith_find_max_scale( /* Q15-e */ { p = Mpy_32_16_1(abs_spectrum[k], envelope[k]); - IF (L_sub(p, heap.mElem[0].mScore) > 0) + IF (GT_32(p, heap.mElem[0].mScore)) { heap.mElem[0].mScore = p; move32(); @@ -233,11 +231,11 @@ static Word16 tcx_arith_find_max_scale( /* Q15-e */ /* Refinement: get the exact q */ powfp_odd2(exps[k], q, &tmpi1, &tmpi2); - IF (sub(sub(tmpi1, tmpi2), 2) >= 0) /* q may be too low */ + IF (GE_16(sub(tmpi1, tmpi2), 2)) /* q may be too low */ { powfp_odd2(exps[k], add(q, 1), &tmpi1, &tmpi2); - WHILE (sub(sub(tmpi1, tmpi2), 2) >= 0) + WHILE (GE_16(sub(tmpi1, tmpi2), 2)) { q = add(q, 1); powfp_odd2(exps[k], add(q, 1), &tmpi1, &tmpi2); @@ -248,7 +246,7 @@ static Word16 tcx_arith_find_max_scale( /* Q15-e */ q = sub(q, 1); powfp_odd2(exps[k], q, &tmpi1, &tmpi2); - WHILE (sub(sub(tmpi1, tmpi2), 2) < 0) + WHILE (LT_16(sub(tmpi1, tmpi2), 2)) { q = sub(q, 1); powfp_odd2(exps[k], q, &tmpi1, &tmpi2); @@ -303,7 +301,7 @@ static Word16 tcx_arith_find_kMax( FOR (kMax = sub(L_frame, 1); kMax >= 0; kMax--) { - IF (L_sub(L_shl(Mpy_32_16_1(abs_spectrum[kMax], scale), scale_e), tmp[deadzone_flags[kMax]]) >= 0) + IF (GE_32(L_shl(Mpy_32_16_1(abs_spectrum[kMax], scale), scale_e), tmp[deadzone_flags[kMax]])) { BREAK; } @@ -392,7 +390,7 @@ static Word16 tcx_arith_rateloop( } tmp2 = L_msu0(L_sub(max_complexity, 48), L_frame, 11); - WHILE (L_sub(complexity, tmp2) < 0) + WHILE (LT_32(complexity, tmp2)) { kMax = tcx_arith_find_kMax( abs_spectrum, @@ -419,7 +417,7 @@ static Word16 tcx_arith_rateloop( IF (iter == 0) /* First rate loop iteration */ { - IF (sub(scale, scale_max) < 0) /* Only update in non-degenerate case */ + IF (LT_16(scale, scale_max)) /* Only update in non-degenerate case */ { /* Update estimator temporal compensation factor */ tmp = BASOP_Util_Divide3232_Scale(L_mult0(target_bits, 1<<9), bits, &s); @@ -433,10 +431,10 @@ static Word16 tcx_arith_rateloop( } } - IF (L_sub(bits, L_mult0(target_bits, 1<<9)) <= 0) /* Bits leftover => scale is too small */ + IF (LE_32(bits, L_mult0(target_bits, 1<<9))) /* Bits leftover => scale is too small */ { test(); - IF (flag <= 0 || sub(scale, scale_best) >= 0) + IF (flag <= 0 || GE_16(scale, scale_best)) { scale_best = scale; move16(); @@ -534,7 +532,7 @@ static Word16 tcx_arith_encode( { powfp_odd2(exps[k], q_abs_spectrum[k], &tmpi1, &tmpi2); - WHILE (sub(tmpi1, add(tmpi2, 2)) < 0) + WHILE (LT_16(tmpi1, add(tmpi2, 2))) { q_abs_spectrum[k] = sub(q_abs_spectrum[k], 1); move16(); @@ -549,7 +547,7 @@ static Word16 tcx_arith_encode( { /* printf("\noverflow at %d\n\n", k); */ - IF (sub(q_abs_spectrum[k], 1) > 0) /* Lower magnitude is still > 0 */ + IF (GT_16(q_abs_spectrum[k], 1)) /* Lower magnitude is still > 0 */ { /* Restore state */ ari_copy_states(&as_lastgood, &as); @@ -619,7 +617,7 @@ static Word16 tcx_arith_encode( } } - IF (sub(kEncoded, sub(L_frame, 1)) == 0) /* RESQ bits possibly available */ + IF (EQ_16(kEncoded, sub(L_frame, 1))) /* RESQ bits possibly available */ { /* Limit target bits to actually needed bits */ target_bits = add(add(bp, 16), extract_l(as.vobf)); diff --git a/lib_enc/avq_cod_fx.c b/lib_enc/avq_cod_fx.c index 998248cecb0b8321976de2a2b7f88f455a11bf67..ae2c60d330e63644dc1793561e1cf940894fcf4f 100644 --- a/lib_enc/avq_cod_fx.c +++ b/lib_enc/avq_cod_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "prot_fx.h" /* Function prototypes */ #include "rom_com_fx.h" /* Static table prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*-------------------------------------------------------------------* * Function AVQ_cod() * @@ -62,7 +60,7 @@ void AVQ_cod_fx( /* o: comfort noise gain factor */ test(); test(); } - WHILE( (sub(Q_in, Q_in_ref) <= 0) && sub( tot_est_bits, mult( 26214, NB_BITS )) <= 0 && sub( tot_est_bits, 600) > 0 ) ; /* limited to 1 possible iteration */ + WHILE( (LE_16(Q_in, Q_in_ref))&&LE_16(tot_est_bits,mult(26214,NB_BITS))&>_16(tot_est_bits,600)); /* limited to 1 possible iteration */ /*----------------------------------------------------------------* * subvector energy worst case: @@ -96,7 +94,7 @@ void AVQ_cod_fx( /* o: comfort noise gain factor */ nbits = add(tmp, nbits); } /* decrease gain when no overflow occurs */ - if (sub(nbits, nbits_max) <= 0) + if (LE_16(nbits, nbits_max)) { offset = sub(offset, fac); } @@ -169,7 +167,7 @@ void AVQ_encmux_fx( Word16 nq_ind, i_ind, kv_ind; test(); - IF( sub(extl,SWB_BWE_HIGHRATE) == 0 || sub(extl,FB_BWE_HIGHRATE) == 0 ) + IF( EQ_16(extl,SWB_BWE_HIGHRATE)||EQ_16(extl,FB_BWE_HIGHRATE)) { nq_ind = IND_NQ2; move16(); @@ -218,7 +216,7 @@ void AVQ_encmux_fx( move16(); FOR( j=1; j 0 ) + if( GT_16(t[j],bits)) { pos = j; move16(); @@ -253,7 +251,7 @@ void AVQ_encmux_fx( j = s_max(pos,j); /* compute (number of bits -1) to describe Q #nq */ - IF(sub(nq[pos],2) >= 0 ) + IF(GE_16(nq[pos],2)) { overflow = sub(i_mult2(nq[pos],5),1); } @@ -264,7 +262,7 @@ void AVQ_encmux_fx( } /* check for overflow and compute number of bits-1 (n) */ - IF( sub(add(bits,add(overflow,j)),*nb_bits) > 0 ) + IF( GT_16(add(bits,add(overflow,j)),*nb_bits)) { /* if budget overflow */ pos_tmp = add(shl(pos,3),8); /*(pos*8)+8*/ @@ -295,13 +293,13 @@ void AVQ_encmux_fx( FOR( i=0; i 0 ) + IF( GT_16(bits,8)) { /* write the unary code for nq[i] */ j = sub(nq[i], 1); @@ -332,7 +330,7 @@ void AVQ_encmux_fx( { /* nothing to write */ } - ELSE IF( sub(nq[i],5) < 0 ) /* Q2, Q3, Q4 */ + ELSE IF( LT_16(nq[i],5)) /* Q2, Q3, Q4 */ { push_indice_fx( st_fx, i_ind, I[i], shl(nq[i],2) ); bits = sub(bits, shl(nq[i],2)); @@ -424,7 +422,7 @@ void AVQ_cod_lpc( n = nq; move16(); - IF (sub(nq,4) > 0) + IF (GT_16(nq,4)) { nk = shr(sub(nq,3),1); /*nk = (nq-3)>>1;*/ n = sub(nq,shl(nk,1)); /*n = nq - nk*2; */ diff --git a/lib_enc/bass_psfilter_enc.c b/lib_enc/bass_psfilter_enc.c index 6b3ba7c71e48163c6e79595fd1af61a5f6ae71c6..df80fda0074efefc3f061c2fef5f4c6dd174913d 100644 --- a/lib_enc/bass_psfilter_enc.c +++ b/lib_enc/bass_psfilter_enc.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ @@ -11,8 +11,6 @@ #include "prot_fx.h" #include "basop_util.h" #include "stl.h" -#include "wmc_auto.h" - @@ -38,7 +36,7 @@ Word16 bass_pf_enc( Word32 ener2; - IF (sub(l_frame, L_FRAME16k) != 0) + IF (NE_16(l_frame, L_FRAME16k)) { pFilt = filt_lp; l_filt = L_FILT; @@ -81,7 +79,7 @@ Word16 bass_pf_enc( lg = 0; move16(); } - if (sub(lg, l_subfr) > 0) + if (GT_16(lg, l_subfr)) { lg = l_subfr; move16(); @@ -110,7 +108,7 @@ Word16 bass_pf_enc( } } - IF (sub(lg, l_subfr) < 0) + IF (LT_16(lg, l_subfr)) { FOR (i = lg; i < l_subfr; i++) { @@ -134,7 +132,7 @@ Word16 bass_pf_enc( st = sub(norm_l(lp_error), 3); test(); - if ((sub(st, s1) < 0) && (lp_error != 0)) + if ((LT_16(st, s1))&&(lp_error!=0)) { s1 = st; move16(); @@ -158,7 +156,7 @@ Word16 bass_pf_enc( } } - IF (sub(lg, l_subfr) < 0) + IF (LT_16(lg, l_subfr)) { FOR (i = lg; i < l_subfr; i++) { @@ -205,7 +203,7 @@ Word16 bass_pf_enc( BASOP_SATURATE_WARNING_OFF; tmp16 = shl(tmp16, sub(st, 2)); /* Q15 */ - if (sub(tmp16, 16384/*0.5f Q15*/) > 0) + if (GT_16(tmp16, 16384/*0.5f Q15*/)) { tmp16 = 16384/*0.5f Q15*/; move16(); @@ -233,7 +231,7 @@ Word16 bass_pf_enc( } } - IF (sub(lg, l_subfr) < 0) + IF (LT_16(lg, l_subfr)) { FOR (i = lg; i < l_subfr; i++) { @@ -349,7 +347,7 @@ Word16 bass_pf_enc( /* optimal gain = -/ */ *gain_factor_param = 2; move16(); - IF (sub(mode, 2) == 0) + IF (EQ_16(mode, 2)) { /* *gain_factor_param = (int)(-2.f*(cross_n_d/nrg_n)+0.5f); */ tmp16 = BASOP_Util_Divide3232_Scale(cross_n_d, nrg_n, &st); /* Q15-st-s3+s4 */ @@ -360,7 +358,7 @@ Word16 bass_pf_enc( *gain_factor_param = tmp16; move16(); - if (sub(tmp16, 3) > 0) + if (GT_16(tmp16, 3)) { *gain_factor_param = 3; move16(); diff --git a/lib_enc/bw_detect_fx.c b/lib_enc/bw_detect_fx.c index 8f220576bd20e7bd7122f3e275f426f7d6a37eba..ce75032353fd51e241314c91ff21c790534532dc 100644 --- a/lib_enc/bw_detect_fx.c +++ b/lib_enc/bw_detect_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -8,12 +8,9 @@ #include "rom_enc_fx.h" /* Encoder static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - #include "rom_com_fx.h" #include "basop_util.h" -#include "wmc_auto.h" /*-------------------------------------------------------------------* * Local constants @@ -68,7 +65,7 @@ void bw_detect_fx( } */ - IF( L_sub(st->input_Fs_fx,8000) > 0 ) + IF( GT_32(st->input_Fs_fx,8000)) { IF ( enerBuffer != NULL) @@ -114,7 +111,7 @@ void bw_detect_fx( move32();/* 1/log2(10) */ /* Q25 */ /* WB: 4.4 - 7.2 kHz, 8 cldfb-bands, mid band(14) counted twice */ - IF( L_sub(st->input_Fs_fx,16000) >= 0 ) + IF( GE_32(st->input_Fs_fx,16000)) { /* cldfb_bin[1] += Sum( &(enerBuffer[11]), cldfb_bin_width ); @@ -145,7 +142,7 @@ void bw_detect_fx( } /* SWB: 9.2 - 15.6 kHz, 16 cldfb-bands */ - IF( L_sub(st->input_Fs_fx,32000) >= 0 ) + IF( GE_32(st->input_Fs_fx,32000)) { /* cldfb_bin[3] += Sum( &(enerBuffer[23]), cldfb_bin_width ); @@ -183,7 +180,7 @@ void bw_detect_fx( } /* FB: 16.8 - 20.0 kHz, 8 cldfb-bands */ - IF( L_sub(st->input_Fs_fx,48000) >= 0 ) + IF( GE_32(st->input_Fs_fx,48000)) { /* cldfb_bin[7] += Sum( &(enerBuffer[42]), cldfb_bin_width ); @@ -221,7 +218,7 @@ void bw_detect_fx( { /* set width of a speactral bin (corresponds to 1.5kHz) */ - IF( L_sub(st->input_Fs_fx,16000) == 0 ) + IF( EQ_32(st->input_Fs_fx,16000)) { bw_max = WB; move16(); @@ -230,7 +227,7 @@ void bw_detect_fx( n_bins = 5; move16(); /* spectrum to 7.5 kHz */ } - ELSE IF( L_sub(st->input_Fs_fx,32000) == 0 ) + ELSE IF( EQ_32(st->input_Fs_fx,32000)) { bw_max = SWB; move16(); @@ -298,7 +295,7 @@ void bw_detect_fx( pt1++; } - IF( L_sub(sum32,1) <= 0 ) + IF( LE_32(sum32,1)) { /*deal with zero spectrum*/ spect_bin[i] = -1; @@ -353,7 +350,7 @@ void bw_detect_fx( /*if WB */ - IF( L_sub(st->input_Fs_fx,16000) == 0 ) + IF( EQ_32(st->input_Fs_fx,16000)) { /* for 16kHz sampled inputs, do not check SWB & FB */ mean_SWB = 0; @@ -368,7 +365,7 @@ void bw_detect_fx( ELSE { /* else if SWB */ - IF( L_sub(st->input_Fs_fx,32000) == 0 ) + IF( EQ_32(st->input_Fs_fx,32000)) { /* for 32kHz sampled inputs, do not check FB */ @@ -435,7 +432,7 @@ void bw_detect_fx( L_tmp = L_mac(L_tmp,*pt++,16384); mean_WB = round_fx(L_tmp); - IF( L_sub(st->input_Fs_fx,16000) == 0 ) + IF( EQ_32(st->input_Fs_fx,16000)) { /* for 16kHz sampled inputs, do not check SWB & FB */ mean_SWB = 0; @@ -458,7 +455,7 @@ void bw_detect_fx( L_tmp = L_mac(L_tmp,*pt++,8192); mean_SWB = round_fx(L_tmp); - IF( L_sub(st->input_Fs_fx,48000) == 0 ) + IF( EQ_32(st->input_Fs_fx,48000)) { /* FB: 16.5-19.5kHz (2 bins) */ pt++; @@ -483,7 +480,7 @@ void bw_detect_fx( /*if( localVAD || st->lp_noise > 30 )*/ test(); - IF( localVAD || sub(st->lp_noise_fx,7680) > 0 ) + IF( localVAD || GT_16(st->lp_noise_fx,7680)) { /*st->lt_mean_NB_fx = ALPHA_BWD * st->lt_mean_NB_fx + (1-ALPHA_BWD) * mean_NB;*/ L_tmp = L_mult(ALPHA_BWD_FX, st->lt_mean_NB_fx); /* Q15 * Q11 -> Q27 */ @@ -519,7 +516,7 @@ void bw_detect_fx( /*if( 2.5f * max_WB > max_NB )*/ L_tmp = L_mult(10240,max_WB); /* 2.5 in Q12 x Q11 -> Q24 */ L_tmp1 = L_mult(max_NB, 4096); /* Q11 x (1 in Q12) -> Q24 */ - IF( L_sub(L_tmp,L_tmp1) > 0 ) /* Q24 */ + IF( GT_32(L_tmp,L_tmp1)) /* Q24 */ { st->count_WB_fx = add(st->count_WB_fx,1); } @@ -636,7 +633,7 @@ void bw_detect_fx( L_tmp = L_msu(L_tmp,mean_NB,4096); test(); test(); - if( L_tmp < 0 && !(sub(mean_WB,-1) == 0 && sub(mean_NB,-1) == 0) ) + if( L_tmp < 0 && !(EQ_16(mean_WB,-1)&&EQ_16(mean_NB,-1))) { st->count_WB_fx = sub(st->count_WB_fx, 1); } @@ -661,7 +658,7 @@ void bw_detect_fx( L_tmp = L_msu(L_tmp,mean_WB,4096); test(); test(); - if( L_tmp < 0 && !(sub(mean_SWB,-1) == 0 && sub(mean_WB,-1) == 0) ) + if( L_tmp < 0 && !(EQ_16(mean_SWB,-1)&&EQ_16(mean_WB,-1))) { st->count_SWB_fx = sub(st->count_SWB_fx,1); } @@ -685,7 +682,7 @@ void bw_detect_fx( L_tmp = L_mult(12288,mean_FB); /* 3.0 in Q12 x Q11 -> Q24*/ test(); test(); - if( L_msu(L_tmp,mean_SWB,4096) < 0 && !(sub(mean_FB,-1) == 0 && sub(mean_SWB,-1) == 0) ) + if( L_msu(L_tmp,mean_SWB,4096) < 0 && !(EQ_16(mean_FB,-1)&&EQ_16(mean_SWB,-1))) { st->count_FB_fx = sub(st->count_FB_fx,1); } @@ -711,23 +708,23 @@ void bw_detect_fx( *---------------------------------------------------------------------*/ /* switching to a higher BW */ - IF( sub(st->last_input_bwidth_fx,NB) == 0 ) + IF( EQ_16(st->last_input_bwidth_fx,NB)) { - IF( sub(st->count_WB_fx,BWD_COUNT_WIDER_BW) > 0 ) + IF( GT_16(st->count_WB_fx,BWD_COUNT_WIDER_BW)) { st->input_bwidth_fx = WB; move16(); st->count_WB_fx = BWD_COUNT_MAX; move16(); - IF( sub(st->count_SWB_fx,BWD_COUNT_WIDER_BW) > 0 ) + IF( GT_16(st->count_SWB_fx,BWD_COUNT_WIDER_BW)) { st->input_bwidth_fx = SWB; move16(); st->count_SWB_fx = BWD_COUNT_MAX; move16(); - IF( sub(st->count_FB_fx,BWD_COUNT_WIDER_BW) > 0 ) + IF( GT_16(st->count_FB_fx,BWD_COUNT_WIDER_BW)) { st->input_bwidth_fx = FB; move16(); @@ -739,16 +736,16 @@ void bw_detect_fx( } test(); - IF( sub(st->last_input_bwidth_fx,WB) == 0 && L_sub(st->input_Fs_fx,16000) > 0 ) + IF( EQ_16(st->last_input_bwidth_fx,WB)&>_32(st->input_Fs_fx,16000)) { - IF( sub(st->count_SWB_fx,BWD_COUNT_WIDER_BW) > 0 ) + IF( GT_16(st->count_SWB_fx,BWD_COUNT_WIDER_BW)) { st->input_bwidth_fx = SWB; move16(); st->count_SWB_fx = BWD_COUNT_MAX; move16(); - IF( sub(st->count_FB_fx,BWD_COUNT_WIDER_BW) > 0 ) + IF( GT_16(st->count_FB_fx,BWD_COUNT_WIDER_BW)) { st->input_bwidth_fx = FB; move16(); @@ -759,9 +756,9 @@ void bw_detect_fx( } test(); - IF( sub(st->last_input_bwidth_fx,SWB) == 0 && L_sub(st->input_Fs_fx,32000) > 0 ) + IF( EQ_16(st->last_input_bwidth_fx,SWB)&>_32(st->input_Fs_fx,32000)) { - IF( sub(st->count_FB_fx,BWD_COUNT_WIDER_BW) > 0 ) + IF( GT_16(st->count_FB_fx,BWD_COUNT_WIDER_BW)) { st->input_bwidth_fx = FB; move16(); @@ -771,16 +768,16 @@ void bw_detect_fx( } /* switching to a lower BW */ - IF( sub(st->last_input_bwidth_fx,FB) == 0 ) + IF( EQ_16(st->last_input_bwidth_fx,FB)) { - IF( sub(st->count_FB_fx,10) < 0 ) + IF( LT_16(st->count_FB_fx,10)) { st->input_bwidth_fx = SWB; move16(); st->count_FB_fx = 0; move16(); } - IF( sub(st->count_SWB_fx,10) < 0 ) + IF( LT_16(st->count_SWB_fx,10)) { st->input_bwidth_fx = WB; move16(); @@ -789,7 +786,7 @@ void bw_detect_fx( st->count_FB_fx = 0; move16(); } - IF( sub(st->count_WB_fx,10) < 0 ) + IF( LT_16(st->count_WB_fx,10)) { st->input_bwidth_fx = NB; move16(); @@ -802,9 +799,9 @@ void bw_detect_fx( } } - IF( sub(st->last_input_bwidth_fx,SWB) == 0 ) + IF( EQ_16(st->last_input_bwidth_fx,SWB)) { - IF( sub(st->count_SWB_fx,10) < 0 ) + IF( LT_16(st->count_SWB_fx,10)) { st->input_bwidth_fx = WB; move16(); @@ -813,7 +810,7 @@ void bw_detect_fx( st->count_FB_fx = 0; move16(); } - IF( sub(st->count_WB_fx,10) < 0 ) + IF( LT_16(st->count_WB_fx,10)) { st->input_bwidth_fx = NB; move16(); @@ -827,9 +824,9 @@ void bw_detect_fx( } - IF( sub(st->last_input_bwidth_fx,WB) == 0 ) + IF( EQ_16(st->last_input_bwidth_fx,WB)) { - IF( sub(st->count_WB_fx,10) < 0 ) + IF( LT_16(st->count_WB_fx,10)) { st->input_bwidth_fx = NB; move16(); @@ -846,14 +843,14 @@ void bw_detect_fx( /* verify that maximum encoded bandwidth (specified on the command line) is not exceeded */ - IF( sub(st->input_bwidth_fx,st->max_bwidth_fx) > 0 ) + IF( GT_16(st->input_bwidth_fx,st->max_bwidth_fx)) { st->input_bwidth_fx = st->max_bwidth_fx; move16(); } /* Set and limit the encoded bandwidth */ - IF ( sub(st->codec_mode,MODE1) == 0 ) + IF ( EQ_16(st->codec_mode,MODE1)) { Word32 total_brate_fx; @@ -868,17 +865,17 @@ void bw_detect_fx( test(); test(); test(); - IF ( L_sub(total_brate_fx, ACELP_9k60) <= 0 && sub(st->bwidth_fx,NB) != 0 && sub(st->bwidth_fx,WB) != 0 ) + IF ( LE_32(total_brate_fx, ACELP_9k60)&&NE_16(st->bwidth_fx,NB)&&NE_16(st->bwidth_fx,WB)) { st->bwidth_fx = WB; move16(); } - ELSE IF ( L_sub(st->total_brate_fx,ACELP_13k20) >= 0 && L_sub(st->total_brate_fx,ACELP_16k40) <= 0 && sub(st->bwidth_fx,SWB) > 0 ) + ELSE IF ( GE_32(st->total_brate_fx,ACELP_13k20)&&LE_32(st->total_brate_fx,ACELP_16k40)&>_16(st->bwidth_fx,SWB)) { st->bwidth_fx = SWB; move16(); } - ELSE IF ( L_sub(st->total_brate_fx,ACELP_32k) >= 0 && sub(st->bwidth_fx,WB) < 0 ) + ELSE IF ( GE_32(st->total_brate_fx,ACELP_32k)&<_16(st->bwidth_fx,WB)) { st->bwidth_fx = WB; move16(); @@ -896,7 +893,7 @@ void bw_detect_fx( FOR (n=0; nrf_mode,1) == 0 ) + if( EQ_16(st->rf_mode,1)) { tmpbandwidthMin = WB; } diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c index d9d0ad99617fc913a27c690a1549fbea22bd7bdf..c062e243e9d9dbc77609a1c7c51ea4578d28613e 100644 --- a/lib_enc/cng_enc_fx.c +++ b/lib_enc/cng_enc_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -8,10 +8,7 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - #include "basop_mpy.h" -#include "wmc_auto.h" /*---------------------------------------------------------------------* * Local constants @@ -106,7 +103,7 @@ void CNG_enc_fx( pt_sp = speech; L_ener = L_deposit_l(1); /* L_ener = L_add(L_shr(sum2_f_fx( speech, L_frame ), 8) , L_ener);*/ - IF( sub(L_frame, L_FRAME) == 0) + IF( EQ_16(L_frame, L_FRAME)) { FOR (j=0; j<128; j++) { @@ -156,8 +153,8 @@ void CNG_enc_fx( test(); test(); test(); - IF( L_sub(st_fx->last_core_brate_fx, SID_2k40) > 0 && ( sub( st_fx->last_core_fx, HQ_CORE )==0 || burst_ho_cnt > 0 ) && sub(st_fx->lp_sp_enr_fx, 1536) < 0 && - sub(sub(sp_enr, st_fx->lp_sp_enr_fx), 1024) > 0 && sub(sp_enr, 1536) > 0) + IF( GT_32(st_fx->last_core_brate_fx, SID_2k40) && ( EQ_16( st_fx->last_core_fx, HQ_CORE ) || burst_ho_cnt > 0 ) && LT_16(st_fx->lp_sp_enr_fx, 1536) && + GT_16(sub(sp_enr, st_fx->lp_sp_enr_fx), 1024) && GT_16(sp_enr, 1536) ) { st_fx->lp_sp_enr_fx = sp_enr; move16(); @@ -171,7 +168,7 @@ void CNG_enc_fx( } /* update the pointer to circular buffer of old LSP vectors */ st_fx->cng_hist_ptr_fx = add(st_fx->cng_hist_ptr_fx,1); - if(sub(st_fx->cng_hist_ptr_fx, DTX_HIST_SIZE) == 0) + if(EQ_16(st_fx->cng_hist_ptr_fx, DTX_HIST_SIZE)) { st_fx->cng_hist_ptr_fx = 0; move16(); @@ -186,14 +183,14 @@ void CNG_enc_fx( *-----------------------------------------------------------------*/ test(); test(); - IF( (L_sub(st_fx->core_brate_fx, SID_2k40) == 0 || L_sub(st_fx->core_brate_fx, SID_1k75) == 0) && sub(st_fx->cng_cnt_fx, sub(st_fx->cng_hist_size_fx,1)) >= 0 ) + IF( (EQ_32(st_fx->core_brate_fx, SID_2k40)||EQ_32(st_fx->core_brate_fx,SID_1k75))&&GE_16(st_fx->cng_cnt_fx,sub(st_fx->cng_hist_size_fx,1))) { set32_fx( max, 0, 2 ); set16_fx( max_idx, 0, 2 ); FOR( i=0; icng_hist_size_fx; i++ ) { - IF ( sub(st_fx->L_frame_fx,L_FRAME) == 0 ) + IF ( EQ_16(st_fx->L_frame_fx,L_FRAME)) { lsp2lsf_fx( &st_fx->cng_lsp_hist_fx[i*M], lsf_tmp, M, INT_FS_FX ); ftmp_fx = 964; @@ -221,7 +218,7 @@ void CNG_enc_fx( C[i] = Mpy_32_16_1(L_tmp,1928); move32();/*QX6.5536 */ - IF ( L_sub(C[i],max[0]) > 0 ) + IF ( GT_32(C[i],max[0])) { max[1] = max[0]; move32(); @@ -232,7 +229,7 @@ void CNG_enc_fx( max_idx[0] = i; move16(); } - ELSE IF ( L_sub(C[i],max[1]) > 0 ) + ELSE IF ( GT_32(C[i],max[1])) { max[1] = C[i]; move32(); @@ -273,18 +270,18 @@ void CNG_enc_fx( test(); test(); IF( ((st_fx->cng_cnt_fx == 0) && - sub(st_fx->lp_sp_enr_fx, 1536) > 0 && - (sub(add(st_lp_sp_enr, 1024 /* 4.0, Q8 */), sp_enr) < 0) && + GT_16(st_fx->lp_sp_enr_fx, 1536) && + (LT_16(add(st_lp_sp_enr, 1024 /* 4.0, Q8 */), sp_enr)) && (st_fx->first_CNG_fx != 0) && (st_fx->old_enr_index_fx >= 0) && - (L_sub(st_fx->last_core_brate_fx, SID_2k40) > 0)) || - sub(force_cn_step, 1) == 0) + (GT_32(st_fx->last_core_brate_fx, SID_2k40))) || + EQ_16(force_cn_step, 1)) { *allow_cn_step = 1; move16(); } test(); - IF( L_sub(st_fx->core_brate_fx, SID_2k40) == 0 || L_sub(st_fx->core_brate_fx, SID_1k75) == 0 ) + IF( EQ_32(st_fx->core_brate_fx, SID_2k40)||EQ_32(st_fx->core_brate_fx,SID_1k75)) { /* LSF quantization */ IF ( st_fx->Opt_AMR_WB_fx != 0 ) @@ -298,7 +295,7 @@ void CNG_enc_fx( /* Reset CNG history if CNG frame length is changed */ test(); test(); - if ( sub(st_fx->bwidth_fx,WB) == 0 && st_fx->first_CNG_fx != 0 && sub(st_fx->L_frame_fx,st_fx->last_CNG_L_frame_fx) != 0 ) + if ( EQ_16(st_fx->bwidth_fx,WB)&&st_fx->first_CNG_fx!=0&&NE_16(st_fx->L_frame_fx,st_fx->last_CNG_L_frame_fx)) { st_fx->ho_hist_size_fx = 0; move16(); @@ -322,17 +319,17 @@ void CNG_enc_fx( * Find A(z) coefficients *---------------------------------------------------------------------*/ - IF( L_sub(st_fx->last_core_brate_fx, SID_2k40) <= 0 ) + IF( LE_32(st_fx->last_core_brate_fx, SID_2k40)) { /* Reset hangover counter if not first SID period */ - if( L_sub(st_fx->core_brate_fx,FRAME_NO_DATA) > 0 ) + if( GT_32(st_fx->core_brate_fx,FRAME_NO_DATA)) { st_fx->num_ho_fx = 0; move16(); } /* Update LSPs if last SID energy not outlier or insufficient number of hangover frames */ test(); - IF( sub(st_fx->num_ho_fx,3) < 0 || L_sub(Mult_32_16(st_fx->Enew_fx,21845 /*1/1.5f, Q15*/), st_fx->lp_ener_fx) < 0 ) + IF( LT_16(st_fx->num_ho_fx,3)||LT_32(Mult_32_16(st_fx->Enew_fx,21845 /*1/1.5f, Q15*/), st_fx->lp_ener_fx)) { FOR( i=0; iOpt_AMR_WB_fx || sub(st_fx->bwidth_fx,WB) == 0 ) - && ( !st_fx->first_CNG_fx || sub(st_fx->act_cnt2_fx,MIN_ACT_CNG_UPD) >= 0 ) ) + IF( ( st_fx->Opt_AMR_WB_fx || EQ_16(st_fx->bwidth_fx,WB)) + && ( !st_fx->first_CNG_fx || GE_16(st_fx->act_cnt2_fx,MIN_ACT_CNG_UPD) ) ) { - IF( L_sub(st_fx->last_active_brate_fx,ACELP_16k40) > 0) + IF( GT_32(st_fx->last_active_brate_fx,ACELP_16k40)) { st_fx->CNG_mode_fx = -1; move16(); } - ELSE IF( L_sub(st_fx->last_active_brate_fx,ACELP_13k20) > 0 ) + ELSE IF( GT_32(st_fx->last_active_brate_fx,ACELP_13k20)) { st_fx->CNG_mode_fx = 4; move16(); } - ELSE IF( L_sub(st_fx->last_active_brate_fx,ACELP_9k60) > 0 ) + ELSE IF( GT_32(st_fx->last_active_brate_fx,ACELP_9k60)) { st_fx->CNG_mode_fx = 3; move16(); } - ELSE IF( L_sub(st_fx->last_active_brate_fx,ACELP_8k00) > 0 ) + ELSE IF( GT_32(st_fx->last_active_brate_fx,ACELP_8k00)) { st_fx->CNG_mode_fx = 2; move16(); } - ELSE IF( L_sub(st_fx->last_active_brate_fx,ACELP_7k20) > 0 ) + ELSE IF( GT_32(st_fx->last_active_brate_fx,ACELP_7k20)) { st_fx->CNG_mode_fx = 1; move16(); @@ -396,7 +393,7 @@ void CNG_enc_fx( FOR( ll = burst_ho_cnt; ll > 0; ll-- ) { st_fx->ho_hist_ptr_fx = add(st_fx->ho_hist_ptr_fx,1); - if( sub(st_fx->ho_hist_ptr_fx, HO_HIST_SIZE) == 0 ) + if( EQ_16(st_fx->ho_hist_ptr_fx, HO_HIST_SIZE)) { st_fx->ho_hist_ptr_fx = 0; move16(); @@ -405,12 +402,12 @@ void CNG_enc_fx( /* Conversion between 12.8k and 16k LSPs */ test(); test(); - IF( sub(L_frame,L_FRAME ) == 0 && sub(st_fx->ho_16k_lsp_fx[s_ptr],1) == 0 ) + IF( EQ_16(L_frame,L_FRAME )&&EQ_16(st_fx->ho_16k_lsp_fx[s_ptr],1)) { /* Conversion from 16k LPSs to 12k8 */ lsp_convert_poly_fx( &(st_fx->ho_lsp_circ_fx[s_ptr*M]), L_frame, 0 ); } - ELSE IF ( sub(L_frame,L_FRAME16k) == 0 && st_fx->ho_16k_lsp_fx[s_ptr] == 0 ) + ELSE IF ( EQ_16(L_frame,L_FRAME16k)&&st_fx->ho_16k_lsp_fx[s_ptr]==0) { /* 16k LSPs already converted and stored, just copy to the other buffer */ Copy(&(st_fx->ho_lsp_circ2_fx[s_ptr*M]), &(st_fx->ho_lsp_circ_fx[s_ptr*M]), M ); @@ -422,7 +419,7 @@ void CNG_enc_fx( Copy32(&(st_fx->ho_env_circ_fx[s_ptr*NUM_ENV_CNG]), &(st_fx->ho_env_hist_fx[st_fx->ho_hist_ptr_fx*NUM_ENV_CNG]), NUM_ENV_CNG ); st_fx->ho_hist_size_fx = add(st_fx->ho_hist_size_fx,1); - if (sub(st_fx->ho_hist_size_fx, HO_HIST_SIZE) > 0) + if (GT_16(st_fx->ho_hist_size_fx, HO_HIST_SIZE)) { st_fx->ho_hist_size_fx = HO_HIST_SIZE; move16(); @@ -430,7 +427,7 @@ void CNG_enc_fx( s_ptr = add(s_ptr,1); - if( sub(s_ptr, st_fx->ho_circ_size_fx) == 0 ) + if( EQ_16(s_ptr, st_fx->ho_circ_size_fx)) { s_ptr = 0; move16(); @@ -479,8 +476,8 @@ void CNG_enc_fx( } test(); - IF ( L_sub(Mult_32_16(st_fx->ho_ener_hist_fx[ptr],ONE_OVER_BUF_H_NRG_FX),st_fx->ho_ener_hist_fx[st_fx->ho_hist_ptr_fx]) < 0 && - L_sub(st_fx->ho_ener_hist_fx[ptr],Mult_32_16(st_fx->ho_ener_hist_fx[st_fx->ho_hist_ptr_fx], BUF_L_NRG_FX)) > 0 ) + IF ( LT_32(Mult_32_16(st_fx->ho_ener_hist_fx[ptr],ONE_OVER_BUF_H_NRG_FX),st_fx->ho_ener_hist_fx[st_fx->ho_hist_ptr_fx])&& + GT_32(st_fx->ho_ener_hist_fx[ptr],Mult_32_16(st_fx->ho_ener_hist_fx[st_fx->ho_hist_ptr_fx], BUF_L_NRG_FX)) ) { /*enr += W_DTX_HO[k] * st_fx->ho_ener_hist[ptr]; */ L_tmp1 = Mult_32_16(st_fx->ho_ener_hist_fx[ptr],W_DTX_HO_FX[k]) ; /* Q6+15-15->Q6 */ @@ -513,7 +510,7 @@ void CNG_enc_fx( FOR( i=0; iL_frame_fx,L_FRAME) == 0 ) + IF ( EQ_16(st_fx->L_frame_fx,L_FRAME)) { lsp2lsf_fx( &tmp[i*M], lsf_tmp, M, INT_FS_FX ); ftmp_fx = 964; @@ -541,7 +538,7 @@ void CNG_enc_fx( C[i] = Mpy_32_16_1(L_tmp,1928); move32();/*QX6.5536 */ - IF ( L_sub(C[i],max[0]) > 0 ) + IF ( GT_32(C[i],max[0])) { max[1] = max[0]; move32(); @@ -552,7 +549,7 @@ void CNG_enc_fx( max_idx[0] = i; move16(); } - ELSE IF ( L_sub(C[i],max[1]) > 0 ) + ELSE IF ( GT_32(C[i],max[1])) { max[1] = C[i]; move32(); @@ -561,11 +558,11 @@ void CNG_enc_fx( } } - IF ( sub(m,1) == 0 ) + IF ( EQ_16(m,1)) { Copy(tmp, lsp_tmp, M); } - ELSE IF ( sub(m,4) < 0 ) + ELSE IF ( LT_16(m,4)) { FOR ( i=0; i 0 ) + if ( GT_16(dev,max_dev)) { max_dev = dev; move16(); @@ -612,7 +609,7 @@ void CNG_enc_fx( } test(); - IF ( sub(dist,13107) > 0 || sub(max_dev,3277) > 0 ) + IF ( GT_16(dist,13107)||GT_16(max_dev,3277)) { FOR( i=0; ilp_ener_fx; */ - IF(sub(m1,1) == 0) + IF(EQ_16(m1,1)) { L_tmp = L_sub(L_tmp,L_add(st_fx->lp_ener_fx,st_fx->lp_ener_fx)); } @@ -685,10 +682,10 @@ void CNG_enc_fx( /* calculate the residual signal */ Residu3_fx(Aq, speech, res, L_frame, 0); Copy(res, res1, L_frame); - IF( sub(st_fx->bwidth_fx,NB) != 0 ) + IF( NE_16(st_fx->bwidth_fx,NB)) { test(); - IF( sub(st_fx->bwidth_fx,WB) == 0 && st_fx->CNG_mode_fx >= 0 ) + IF( EQ_16(st_fx->bwidth_fx,WB)&&st_fx->CNG_mode_fx>=0) { ftmp_fx = HO_ATT_FX[st_fx->CNG_mode_fx]; } @@ -704,7 +701,7 @@ void CNG_enc_fx( tmp1 = add(16384,tmp1); att = div_s(16374,tmp1); /* Q15 */ - IF ( sub(att,ftmp_fx) < 0 ) + IF ( LT_16(att,ftmp_fx)) { att = ftmp_fx; move16(); @@ -722,7 +719,7 @@ void CNG_enc_fx( /* calculate the spectrum of residual signal */ Copy(res1, fft_io, st_fx->L_frame_fx); - IF ( sub(st_fx->L_frame_fx,L_FRAME16k) == 0 ) + IF ( EQ_16(st_fx->L_frame_fx,L_FRAME16k)) { modify_Fs_fx( fft_io, L_FRAME16k, 16000, fft_io, 12800, exc_mem2,0); } @@ -757,7 +754,7 @@ void CNG_enc_fx( scale = norm_s(maxv); pt_res = res; L_ener = L_deposit_l(1); - IF( sub(L_frame, L_FRAME) == 0) + IF( EQ_16(L_frame, L_FRAME)) { FOR (j=0; j<128; j++) { @@ -800,9 +797,9 @@ void CNG_enc_fx( * Quantize residual signal energy (only in SID frame) *-----------------------------------------------------------------*/ test(); - IF( L_sub(st_fx->core_brate_fx, SID_2k40) == 0 || L_sub(st_fx->core_brate_fx, SID_1k75) == 0 ) + IF( EQ_32(st_fx->core_brate_fx, SID_2k40)||EQ_32(st_fx->core_brate_fx,SID_1k75)) { - IF( sub(st_fx->cng_cnt_fx,sub(st_fx->cng_hist_size_fx,1)) >= 0 ) + IF( GE_16(st_fx->cng_cnt_fx,sub(st_fx->cng_hist_size_fx,1))) { /* average the envelope except outliers */ FOR ( i=0; icng_hist_size_fx - 2); */ tmp1 = sub(st_fx->cng_hist_size_fx,2); - IF(sub(tmp1,1) > 0) + IF(GT_16(tmp1,1)) { tmp1 = div_s(1,tmp1); L_tmp1 = Mult_32_16(L_tmp1,tmp1); @@ -861,9 +858,9 @@ void CNG_enc_fx( enr = round_fx(L_tmp); /* Q8 */ } /* decrease the energy in case of WB input */ - IF( sub(st_fx->bwidth_fx, NB) != 0 ) + IF( NE_16(st_fx->bwidth_fx, NB)) { - IF( sub(st_fx->bwidth_fx,WB) == 0 ) + IF( EQ_16(st_fx->bwidth_fx,WB)) { IF( st_fx->CNG_mode_fx >= 0 ) { @@ -919,7 +916,7 @@ void CNG_enc_fx( /* allow only slow energy increase */ test(); - IF( st_fx->old_enr_index_fx >= 0 && sub(enr_index, add(st_fx->old_enr_index_fx, MAX_DELTA)) > 0 ) + IF( st_fx->old_enr_index_fx >= 0 && GT_16(enr_index, add(st_fx->old_enr_index_fx, MAX_DELTA))) { IF( *allow_cn_step != 0 ) { @@ -947,7 +944,7 @@ void CNG_enc_fx( /* substract by 2 not done to leave Energy in Q2 */ lo = L_Extract_lc(L_tmp, &hi); st_fx->Enew_fx = Pow2(add(hi, 4), lo); /* Q6 */ - IF ( L_sub(st_fx->core_brate_fx, SID_2k40) == 0 ) + IF ( EQ_32(st_fx->core_brate_fx, SID_2k40)) { /* enr1 = (float)log10( st->Enew*L_frame + 0.1f ) / (float)log10( 2.0f );*/ exp = norm_l(st_fx->Enew_fx); @@ -1014,7 +1011,7 @@ void CNG_enc_fx( } - IF ( L_sub(d,min1) < 0 ) + IF ( LT_32(d,min1)) { min1 = L_add(d, 0); min1_idx = i; @@ -1030,11 +1027,11 @@ void CNG_enc_fx( } /* Update hangover memory during CNG */ test(); - IF ( *allow_cn_step == 0 && L_sub(Mult_32_16(st_fx->Enew_fx,21845 /*1/1.5f, Q15*/), st_fx->lp_ener_fx) < 0 ) + IF ( *allow_cn_step == 0 && LT_32(Mult_32_16(st_fx->Enew_fx,21845 /*1/1.5f, Q15*/), st_fx->lp_ener_fx)) { /* update the pointer to circular buffer of old LSP vectors */ st_fx->ho_hist_ptr_fx = add(st_fx->ho_hist_ptr_fx, 1); - if( sub(st_fx->ho_hist_ptr_fx,HO_HIST_SIZE) == 0 ) + if( EQ_16(st_fx->ho_hist_ptr_fx,HO_HIST_SIZE)) { st_fx->ho_hist_ptr_fx = 0; move16(); @@ -1046,7 +1043,7 @@ void CNG_enc_fx( /* update the hangover energy buffer */ st_fx->ho_ener_hist_fx[st_fx->ho_hist_ptr_fx] = st_fx->Enew_fx; move32(); - IF ( L_sub(st_fx->core_brate_fx, SID_2k40) == 0 ) + IF ( EQ_32(st_fx->core_brate_fx, SID_2k40)) { FOR ( i=0; iho_env_hist_fx[(st_fx->ho_hist_ptr_fx)*NUM_ENV_CNG]), NUM_ENV_CNG ); } st_fx->ho_hist_size_fx = add(st_fx->ho_hist_size_fx,1); - if( sub(st_fx->ho_hist_size_fx,HO_HIST_SIZE) > 0 ) + if( GT_16(st_fx->ho_hist_size_fx,HO_HIST_SIZE)) { st_fx->ho_hist_size_fx = HO_HIST_SIZE; move16(); @@ -1075,13 +1072,13 @@ void CNG_enc_fx( } } /* dithering bit for AMR-WB IO mode is always set to 0 */ - IF( L_sub(st_fx->core_brate_fx, SID_1k75) == 0 ) + IF( EQ_32(st_fx->core_brate_fx, SID_1k75)) { push_indice_fx( st_fx, IND_DITHERING, 0, 1 ); } - IF ( L_sub(st_fx->core_brate_fx, SID_2k40) == 0 ) + IF ( EQ_32(st_fx->core_brate_fx, SID_2k40)) { - IF(sub(st_fx->L_frame_fx, L_FRAME16k) == 0) + IF(EQ_16(st_fx->L_frame_fx, L_FRAME16k)) { push_indice_fx( st_fx, IND_ACELP_16KHZ, 1, 1 ); } @@ -1091,14 +1088,14 @@ void CNG_enc_fx( } } - IF ( L_sub(st_fx->core_brate_fx, SID_2k40) == 0 ) + IF ( EQ_32(st_fx->core_brate_fx, SID_2k40)) { push_indice_fx( st_fx, IND_CNG_HO, s_min(st_fx->burst_ho_cnt_fx, 7 ), 3 ); st_fx->num_ho_fx = m; move16(); push_indice_fx( st_fx, IND_SID_TYPE, 0, 1 ); - IF ( L_sub(st_fx->input_Fs_fx, 32000) < 0 ) + IF ( LT_32(st_fx->input_Fs_fx, 32000)) { push_indice_fx( st_fx, IND_SID_BW, 0, 1 ); *sid_bw = 0; @@ -1111,7 +1108,7 @@ void CNG_enc_fx( *-----------------------------------------------------------------*/ /* update the SID frames counter */ test(); - IF( L_sub(st_fx->core_brate_fx, SID_2k40) == 0 || L_sub(st_fx->core_brate_fx, SID_1k75) == 0 ) + IF( EQ_32(st_fx->core_brate_fx, SID_2k40)||EQ_32(st_fx->core_brate_fx,SID_1k75)) { st_fx->cng_cnt_fx = 0; move16(); @@ -1142,9 +1139,9 @@ void swb_CNG_enc_fx( Word16 shb_SID_updt_fx=0; test(); - IF ( L_sub(st_fx->core_brate_fx, SID_2k40) == 0 || st_fx->core_brate_fx == FRAME_NO_DATA ) + IF ( EQ_32(st_fx->core_brate_fx, SID_2k40)||st_fx->core_brate_fx==FRAME_NO_DATA) { - IF (sub(st_fx->cng_type_fx,LP_CNG) == 0) + IF (EQ_16(st_fx->cng_type_fx,LP_CNG)) { /* decide if SHB SID encoding or not */ shb_SID_updt_fx = shb_DTX_fx( st_fx, shb_speech_fx, syn_12k8_16k_fx ); @@ -1178,18 +1175,18 @@ static void shb_CNG_encod_fx( idx_ener_fx = 0; move16(); - IF ( sub(update_fx, 1) == 0 ) + IF ( EQ_16(update_fx, 1)) { /* SHB energy quantization */ idx_ener_fx = shr(add(mult(st_fx->mov_shb_cng_ener_fx, 9797), 1510), 8); /* Q0 */ - if ( sub(st_fx->bwidth_fx, SWB) < 0 ) + if ( LT_16(st_fx->bwidth_fx, SWB)) { idx_ener_fx = 0; move16(); } - IF ( sub(idx_ener_fx, 15) > 0 ) + IF ( GT_16(idx_ener_fx, 15)) { idx_ener_fx = 15; move16(); @@ -1210,7 +1207,7 @@ static void shb_CNG_encod_fx( } ELSE { - IF ( L_sub(st_fx->core_brate_fx, SID_2k40) == 0 ) + IF ( EQ_32(st_fx->core_brate_fx, SID_2k40)) { st_fx->ho_sid_bw_fx = L_shl(L_and(st_fx->ho_sid_bw_fx, (Word32) 0x3fffffffL ), 1); push_indice_fx( st_fx, IND_SID_BW, 0, 1 ); @@ -1289,13 +1286,13 @@ static Word16 shb_DTX_fx( move16(); } - if ( sub(abs_s(sub(log_wb_ener_fx, st_fx->mov_wb_cng_ener_fx)), 3072) > 0 ) + if ( GT_16(abs_s(sub(log_wb_ener_fx, st_fx->mov_wb_cng_ener_fx)), 3072)) { allow_cn_step_fx = 1; move16(); } - IF ( sub(allow_cn_step_fx, 1) == 0 ) + IF ( EQ_16(allow_cn_step_fx, 1)) { st_fx->mov_wb_cng_ener_fx = log_wb_ener_fx; move16(); @@ -1316,11 +1313,11 @@ static Word16 shb_DTX_fx( update_fx = 0; move16(); - IF ( L_sub(st_fx->core_brate_fx, SID_2k40) == 0 ) + IF ( EQ_32(st_fx->core_brate_fx, SID_2k40)) { test(); test(); - IF ( st_fx->first_CNG_fx == 0 || sub(st_fx->last_vad_fx, 1) == 0 || sub(st_fx->shb_NO_DATA_cnt_fx, 100) >= 0 ) + IF ( st_fx->first_CNG_fx == 0 || EQ_16(st_fx->last_vad_fx, 1)||GE_16(st_fx->shb_NO_DATA_cnt_fx,100)) { update_fx = 1; move16(); @@ -1335,7 +1332,7 @@ static Word16 shb_DTX_fx( } ELSE { - IF ( sub(abs_s(sub(sub(st_fx->mov_wb_cng_ener_fx, st_fx->mov_shb_cng_ener_fx), sub(st_fx->last_wb_cng_ener_fx, st_fx->last_shb_cng_ener_fx))), 768) > 0 ) + IF ( GT_16(abs_s(sub(sub(st_fx->mov_wb_cng_ener_fx, st_fx->mov_shb_cng_ener_fx), sub(st_fx->last_wb_cng_ener_fx, st_fx->last_shb_cng_ener_fx))), 768)) { update_fx = 1; move16(); @@ -1343,7 +1340,7 @@ static Word16 shb_DTX_fx( ELSE { test(); - IF ( sub(st_fx->bwidth_fx, SWB) >= 0 && sub(st_fx->last_SID_bwidth_fx, SWB) < 0 ) + IF ( GE_16(st_fx->bwidth_fx, SWB)&<_16(st_fx->last_SID_bwidth_fx,SWB)) { update_fx = 1; move16(); @@ -1351,7 +1348,7 @@ static Word16 shb_DTX_fx( ELSE { test(); - IF ( sub(st_fx->bwidth_fx, SWB) < 0 && sub(st_fx->last_SID_bwidth_fx, SWB) >= 0 ) + IF ( LT_16(st_fx->bwidth_fx, SWB)&&GE_16(st_fx->last_SID_bwidth_fx,SWB)) { update_fx = 1; move16(); @@ -1365,7 +1362,7 @@ static Word16 shb_DTX_fx( move16(); } - IF ( sub(update_fx, 1) == 0 ) + IF ( EQ_16(update_fx, 1)) { st_fx->last_wb_cng_ener_fx = st_fx->mov_wb_cng_ener_fx; move16(); diff --git a/lib_enc/cod2t32_fx.c b/lib_enc/cod2t32_fx.c index 0e04dca5483cc288ebefdcf5d38c32172d6b168f..e8f8210d0a2313732adf26908b88119dcbc79a1e 100644 --- a/lib_enc/cod2t32_fx.c +++ b/lib_enc/cod2t32_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "cnst_fx.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*-------------------------------------------------------------------* @@ -149,7 +147,7 @@ void acelp_2t32_fx( { L_tmp = L_msu(L_tmp, dn[1],11469); } - ELSE IF(sub(i,L_SUBFR-1)==0) + ELSE IF(EQ_16(i,L_SUBFR-1)) { L_tmp = L_deposit_h(dn[i]); L_tmp = L_msu(L_tmp,dn[i-1],11469); @@ -193,7 +191,7 @@ void acelp_2t32_fx( FOR(j=0; j 0) + IF (GT_16(abs_s(code[k]), 512)) { ind[j + 1] = tmp; move16(); diff --git a/lib_enc/cod_ace.c b/lib_enc/cod_ace.c index d2d86c65db003da1a733598a4aec940ce55b80ae..43c4f289aee18efe114d1bad78798f878acc700b 100644 --- a/lib_enc/cod_ace.c +++ b/lib_enc/cod_ace.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -9,11 +9,8 @@ #include "basop_util.h" #include "options.h" #include "stl.h" -#include "wmc_auto.h" - #include "rom_basop_util.h" -#include "wmc_auto.h" /*-------------------------------------------------------------------* * coder_acelp() @@ -161,7 +158,7 @@ Word16 coder_acelp( /* output SEGSNR for CL decision */ Es_pred=0; } - IF (sub(st->L_frame_fx,L_FRAME) == 0) + IF (EQ_16(st->L_frame_fx,L_FRAME)) { Copy(Aq+2*(M+1), st->cur_sub_Aq_fx, (M+1)); } @@ -368,7 +365,7 @@ Word16 coder_acelp( /* output SEGSNR for CL decision */ * Add Gaussian excitation * *----------------------------------------------------------------------*/ - IF (sub(acelp_cfg->gains_mode[j_subfr], 7) == 0) + IF (EQ_16(acelp_cfg->gains_mode[j_subfr], 7)) { gauss_L2(h1, @@ -470,16 +467,16 @@ Word16 coder_acelp( /* output SEGSNR for CL decision */ Ltmp = Mpy_32_16_1(gain_code2, code2[i]); Ltmp = L_shl(Ltmp, Q_new_p5); Ltmp = L_mac(Ltmp, gain_pit, exc[i+i_subfr]); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF exc2[i] = round_fx(L_shl(Ltmp, 1)); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON Ltmp2 = Mpy_32_16_1(gain_code_vect[j], code[i]); Ltmp2 = L_shl(Ltmp2, Q_new_p5); Ltmp = L_add(Ltmp, Ltmp2); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF Ltmp = L_shl(Ltmp, 1); /* saturation can occur here */ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON exc[i + i_subfr] = round_fx(Ltmp); } tmp2 = L_SUBFR; diff --git a/lib_enc/cod_tcx.c b/lib_enc/cod_tcx.c index a57e7eb5066af0541b0fcd9efbe51dafbe29dc9f..b54a074ccfe40a057a0f25dec4eec63b900468b3 100644 --- a/lib_enc/cod_tcx.c +++ b/lib_enc/cod_tcx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ @@ -10,10 +10,7 @@ #include "prot_fx.h" #include "basop_util.h" #include "stl.h" -#include "wmc_auto.h" - #include "basop_mpy.h" -#include "wmc_auto.h" @@ -162,14 +159,14 @@ void TNSAnalysis( * Temporal Noise Shaping analysis * *-----------------------------------------------------------*/ - IF (sub(tcxMode, TCX_5) == 0) + IF (EQ_16(tcxMode, TCX_5)) { tmp = shr(L_frame,2); /* rearrange LF sub-window lines prior to TNS analysis & filtering */ tmp2 = shr(L_spec,1); - IF (sub(tmp2, tmp) < 0) + IF (LT_16(tmp2, tmp)) { Copy32(spectrum+8, spectrum+16, sub(tmp2, 8)); Copy32(spectrum+tmp, spectrum+8, 8); @@ -192,10 +189,10 @@ void TNSAnalysis( ApplyTnsFilter(tcx_cfg->pCurrentTnsConfig, pTnsData, spectrum, 1); } - IF (sub(tcxMode, TCX_5) == 0) + IF (EQ_16(tcxMode, TCX_5)) { /* undo rearrangement of LF sub-window lines prior to TNS analysis */ - IF (sub(tmp2, tmp) < 0) + IF (LT_16(tmp2, tmp)) { Copy32(spectrum+tmp2+8, spectrum+tmp+8, sub(tmp2, 8)); Copy32(spectrum+8, spectrum+tmp, 8); @@ -267,7 +264,7 @@ void ShapeSpectrum( tcxGetNoiseFillingTilt(A, M, L_frame, - (L_sub(st->total_brate_fx, ACELP_13k20) >= 0 && st->rf_mode == 0 ), + (GE_32(st->total_brate_fx, ACELP_13k20) && st->rf_mode == 0 ), &st->noiseTiltFactor); /* Calculate Spectrum Flatness Measure for the TCX Concealment */ @@ -279,17 +276,18 @@ void ShapeSpectrum( test(); test(); test(); - IF( (L_sub(st->total_brate_fx, ACELP_9k60) == 0 && sub(st->bwidth_fx, SWB) == 0) || - (L_sub(st->total_brate_fx, ACELP_13k20) == 0 && sub(st->bwidth_fx, SWB) == 0) ) + IF( (EQ_32(st->total_brate_fx, ACELP_9k60)&&EQ_16(st->bwidth_fx,SWB))|| + (EQ_32(st->total_brate_fx, ACELP_13k20) && EQ_16(st->bwidth_fx, SWB) ) ) { max_low_pre = 0; move32(); FOR (i = 0; i < L_frame; i++) { Word32 tmp = L_abs(spectrum[i]); - if( L_sub(tmp, max_low_pre) > 0 ) + if( GT_32(tmp, max_low_pre)) { - max_low_pre = L_add(0, tmp); + max_low_pre = tmp; + move32(); } } @@ -298,9 +296,10 @@ void ShapeSpectrum( for (i = 0; i < L_spec - L_frame; i++) { Word32 tmp = L_abs(spectrum[L_frame + i]); - if( L_sub( tmp, max_high_pre) > 0 ) + if( GT_32( tmp, max_high_pre)) { - max_high_pre = L_add(0, tmp); + max_high_pre = tmp; + move32(); } } } @@ -322,8 +321,8 @@ void ShapeSpectrum( /* reduce the peaks in the IGF region, to make life of the core-coder easier... */ test(); - IF( ( L_sub(st->total_brate_fx, ACELP_9k60) == 0 && sub(st->bwidth_fx, SWB) == 0 ) || - ( L_sub(st->total_brate_fx, ACELP_13k20) == 0 && sub(st->bwidth_fx, SWB) == 0 ) ) + IF( ( EQ_32(st->total_brate_fx, ACELP_9k60)&&EQ_16(st->bwidth_fx,SWB))|| + ( EQ_32(st->total_brate_fx, ACELP_13k20)&&EQ_16(st->bwidth_fx, SWB)) ) { Word16 sf_width; Word16 dist_low, dist_high; @@ -353,9 +352,10 @@ void ShapeSpectrum( FOR (i = 0; i < sf_width; i++) { Word32 tmp = L_abs(spectrum[L_frame - 1 - i]); - IF( L_sub(tmp, max_low2) > 0 ) + IF( GT_32(tmp, max_low2)) { - max_low2 = L_add(0, tmp); + max_low2 = tmp; + move32(); dist_low = i; move16(); } @@ -366,9 +366,10 @@ void ShapeSpectrum( FOR (i = 0; i < sub(L_frame, sf_width); i++) { Word32 tmp = L_abs(spectrum[L_frame - sf_width - 1 - i]); - if( L_sub(tmp, max_low1) > 0 ) + if( GT_32(tmp, max_low1)) { - max_low1 = L_add(0, tmp); + max_low1 = tmp; + move32(); } if( tmp > max_low2 ) { @@ -385,9 +386,10 @@ void ShapeSpectrum( FOR (i = 0; i < sub(L_spec, L_frame); i++) { Word32 tmp = L_abs(spectrum[L_frame + i]); - if( L_sub(tmp, max_high) > 0 ) + if( GT_32(tmp, max_high)) { - max_high = L_add(0, tmp); + max_high = tmp; + move32(); dist_high = i; move16(); } @@ -408,7 +410,7 @@ void ShapeSpectrum( tmp16 = norm_l(max_high); if(max_high != 0) headroom = s_min(headroom, tmp16); - if( sub(headroom, 9) < 0) + if( LT_16(headroom, 9)) { shift = sub(9, headroom); } @@ -418,7 +420,7 @@ void ShapeSpectrum( test(); test(); - IF( L_sub(imult3216(max_high, dist_high), imult3216(L_shr(max_low, 2), dist_low)) > 0 && (L_sub(max_low_pre, L_shr(max_high_pre, 4)) > 0) && (L_sub(max_high, L_shl(Mpy_32_16_r(max_low2, max_fac_m), max_fac_s)) > 0) ) + IF( GT_32(imult3216(max_high, dist_high), imult3216(L_shr(max_low, 2), dist_low))&&(GT_32(max_low_pre,L_shr(max_high_pre,4)))&&(GT_32(max_high,L_shl(Mpy_32_16_r(max_low2,max_fac_m),max_fac_s)))) { Word16 fac; fac = divide3232(max_low2, max_high); @@ -605,14 +607,14 @@ void QuantizeSpectrum( SFM = SFM_Cal(spectrum, s_min(200, L_frame_glob)); test(); - IF (sub(L_frame_glob, 256) <= 0) + IF (LE_16(L_frame_glob, 256)) { K = 0x33333333; move32(); K2 = 0xCCCCCCD; move32(); } - ELSE IF (sub(L_frame_glob,320) == 0 || sub(L_frame_glob, 512)== 0 ) + ELSE IF (EQ_16(L_frame_glob,320)||EQ_16(L_frame_glob,512)) { K = 0x33333333; move32(); @@ -628,7 +630,7 @@ void QuantizeSpectrum( } - IF ( L_sub(SFM, K)<0 ) + IF ( LT_32(SFM, K)) { st->Tonal_SideInfo = 1; move16(); @@ -639,7 +641,7 @@ void QuantizeSpectrum( move16(); } - if ( L_sub(tcx_cfg->SFM2, K2)< 0) + if ( LT_32(tcx_cfg->SFM2, K2)) { st->Tonal_SideInfo = 1; move16(); @@ -688,7 +690,7 @@ void QuantizeSpectrum( move16(); test(); - IF ((tcxonly == 0) && (sub(st->tcxltp_pitch_int, st->L_frame_fx) < 0)) + IF ((tcxonly == 0) && (LT_16(st->tcxltp_pitch_int, st->L_frame_fx))) { tmp32 = L_shl(L_mult0(st->L_frame_fx, st->pit_res_max), 1+kLtpHmFractionalResolution+1); tmp1 = add(imult1616(st->tcxltp_pitch_int, st->pit_res_max), st->tcxltp_pitch_fr); @@ -729,7 +731,7 @@ void QuantizeSpectrum( tmp1 = 1; move16(); - if (sub(L_spec, 256) < 0) + if (LT_16(L_spec, 256)) { tmp1 = 0; move16(); @@ -785,8 +787,8 @@ void QuantizeSpectrum( test(); test(); - IF ((sub(Selector, 2) > 0) || ((sub(abs_s(Selector), 2) <= 0) && - (sub(kCtxHmOlRSThr, RelativeScore) < 0))) + IF ((GT_16(Selector, 2))||((LE_16(abs_s(Selector),2))&& + (LT_16(kCtxHmOlRSThr, RelativeScore) ))) { /* CtxHm is likely better */ sqTargetBits = sub(sqTargetBits, NumIndexBits); @@ -880,16 +882,16 @@ void QuantizeSpectrum( } tmp1 = BASOP_Util_Divide1616_Scale(sqTargetBits, tmp1, &tmp2); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF LPDmem->tcx_target_bits_fac = shl(mult(LPDmem->tcx_target_bits_fac, tmp1), tmp2); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON - if (sub(LPDmem->tcx_target_bits_fac, 0x5000) > 0) + if (GT_16(LPDmem->tcx_target_bits_fac, 0x5000)) { LPDmem->tcx_target_bits_fac = 0x5000; move16(); } - if (sub(LPDmem->tcx_target_bits_fac, 0x3000) < 0) + if (LT_16(LPDmem->tcx_target_bits_fac, 0x3000)) { LPDmem->tcx_target_bits_fac = 0x3000; move16(); @@ -1099,7 +1101,7 @@ void QuantizeSpectrum( LtpPitchLag = -1; move16(); - IF (sub(st->tcxltp_pitch_int, st->L_frame_fx) < 0) + IF (LT_16(st->tcxltp_pitch_int, st->L_frame_fx)) { tmp32 = L_shl(L_mult0(st->L_frame_fx, st->pit_res_max), 1+kLtpHmFractionalResolution+1); tmp1 = add(imult1616(st->tcxltp_pitch_int, st->pit_res_max), st->tcxltp_pitch_fr); @@ -1108,7 +1110,7 @@ void QuantizeSpectrum( tmp8 = 1; move16(); - if (sub(st->last_core_fx, ACELP_CORE) == 0) + if (EQ_16(st->last_core_fx, ACELP_CORE)) { tmp8 = 0; move16(); @@ -1179,7 +1181,7 @@ void QuantizeSpectrum( * Quantize TCX gain * *-----------------------------------------------------------*/ - IF (L_sub(st->total_brate_fx, ACELP_13k20) >= 0 && st->rf_mode == 0 ) + IF (GE_32(st->total_brate_fx, ACELP_13k20)&&st->rf_mode==0) { QuantizeGain(L_spec, &gain_tcx, &gain_tcx_e, &prm[0]); } @@ -1266,7 +1268,7 @@ void QuantizeSpectrum( * Estimate and quantize noise factor * *-----------------------------------------------------------*/ - IF (L_sub(st->total_brate_fx, HQ_96k) >= 0) + IF (GE_32(st->total_brate_fx, HQ_96k)) { fac_ns = 0; move16(); @@ -1277,7 +1279,7 @@ void QuantizeSpectrum( { /* noise filling start bin */ i = shr(L_frame, 3); - IF (L_sub(st->total_brate_fx, ACELP_13k20) >= 0 && st->rf_mode == 0 ) + IF (GE_32(st->total_brate_fx, ACELP_13k20)&&st->rf_mode==0) { i = idiv1616U(L_frame, 6); } @@ -1295,7 +1297,7 @@ void QuantizeSpectrum( } noiseTransWidth = HOLE_SIZE_FROM_LTP(s_max(st->tcxltp_gain, tmp1)); - if (sub(L_frame, shr(st->L_frame_fx, 1)) == 0) + if (EQ_16(L_frame, shr(st->L_frame_fx, 1))) { /* minimum transition for noise filling in TCX-10 */ noiseTransWidth = 3; @@ -1315,14 +1317,14 @@ void QuantizeSpectrum( /* hysteresis for very tonal passages (more stationary noise filling level) */ - IF (sub(prm[NOISE_FILL_RANGES], 1) == 0) + IF (EQ_16(prm[NOISE_FILL_RANGES], 1)) { st->noiseLevelMemory = add(1, abs_s(st->noiseLevelMemory)); /* update counter */ } ELSE { test(); - IF ((sub(prm[NOISE_FILL_RANGES], 2) == 0) && - (sub(abs_s(st->noiseLevelMemory), 5) > 0)) + IF ((EQ_16(prm[NOISE_FILL_RANGES], 2))&& + (GT_16(abs_s(st->noiseLevelMemory), 5))) { /* reduce noise filling level by one step */ prm[NOISE_FILL_RANGES] = 1; @@ -1371,7 +1373,7 @@ void QuantizeSpectrum( *-----------------------------------------------------------*/ /* Replication of ACELP formant enhancement for low rates */ - IF ( L_sub(st->total_brate_fx, ACELP_13k20) < 0 || st->rf_mode != 0) + IF ( LT_32(st->total_brate_fx, ACELP_13k20)||st->rf_mode!=0) { tcxFormantEnhancement(xn_buf16, gainlpc, gainlpc_e, spectrum, spectrum_e, L_frame, L_spec); } @@ -1380,7 +1382,7 @@ void QuantizeSpectrum( { tmp1 = 0; move16(); - if ( L_sub(st->total_brate_fx, ACELP_13k20) >= 0 && st->rf_mode == 0) + if ( GE_32(st->total_brate_fx, ACELP_13k20)&&st->rf_mode==0) { tmp1 = 1; move16(); @@ -1404,7 +1406,7 @@ void QuantizeSpectrum( ); } - IF (L_sub(st->total_brate_fx, ACELP_13k20) < 0 || st->rf_mode != 0) + IF (LT_32(st->total_brate_fx, ACELP_13k20)||st->rf_mode!=0) { /* partially recompute global gain (energy part), taking noise filling and formant enhancement into account */ s = sub(getScaleFactor32(spectrum, L_spec), 4); @@ -1438,7 +1440,7 @@ void QuantizeSpectrum( /*-----------------------------------------------------------* * Apply gain * *-----------------------------------------------------------*/ - IF (sub(st->tcx_cfg.coder_type, INACTIVE) == 0 ) + IF (EQ_16(st->tcx_cfg.coder_type, INACTIVE)) { gain_tcx = mult_r(gain_tcx, tcx_cfg->na_scale); } @@ -1454,14 +1456,14 @@ void QuantizeSpectrum( stop = tcx_cfg->tcx_last_overlap_mode; /* backup last TCX overlap mode */ move16(); test(); - IF ((sub(L_frame, shr(st->L_frame_fx, 1)) == 0) && (tcxonly != 0)) + IF ((EQ_16(L_frame, shr(st->L_frame_fx, 1)))&&(tcxonly!=0)) { Word16 L = L_frame; move16(); test(); test(); - if (((tcx_cfg->fIsTNSAllowed != 0) && (fUseTns != 0)) || (sub(L_spec, L_frame) > 0)) + if (((tcx_cfg->fIsTNSAllowed != 0) && (fUseTns != 0)) || (GT_16(L_spec, L_frame))) { L = L_spec; move16(); @@ -1495,7 +1497,7 @@ void QuantizeSpectrum( ApplyTnsFilter(tcx_cfg->pCurrentTnsConfig, pTnsData, spectrum, 0); test(); - IF ((sub(L_frame, shr(st->L_frame_fx, 1)) == 0) && (tcxonly != 0)) + IF ((EQ_16(L_frame, shr(st->L_frame_fx, 1)))&&(tcxonly!=0)) { test(); test(); @@ -1528,7 +1530,7 @@ void QuantizeSpectrum( * Compute inverse MDCT of spectrum[]. * *-----------------------------------------------------------*/ test(); - IF ((sub(L_frame, shr(st->L_frame_fx, 1)) == 0) && (tcxonly != 0)) + IF ((EQ_16(L_frame, shr(st->L_frame_fx, 1)))&&(tcxonly!=0)) { IF (tcx_cfg->tcx_last_overlap_mode != FULL_OVERLAP) { @@ -1540,7 +1542,7 @@ void QuantizeSpectrum( L_spec_TCX5 = shr(s_max(L_frame, L_spec), 1); L_ola = tcx_cfg->tcx_mdct_window_half_length; move16(); - if ( sub(tcx_cfg->tcx_last_overlap_mode, MIN_OVERLAP) == 0 ) + if ( EQ_16(tcx_cfg->tcx_last_overlap_mode, MIN_OVERLAP)) { L_ola = tcx_cfg->tcx_mdct_window_min_length; move16(); @@ -1552,7 +1554,7 @@ void QuantizeSpectrum( FOR (w = 0; w < 2; w++) { - IF (sub(tcx_cfg->tcx_last_overlap_mode, MIN_OVERLAP) == 0) + IF (EQ_16(tcx_cfg->tcx_last_overlap_mode, MIN_OVERLAP)) { TCX_MDCT_Inverse(spectrum + L_mult0(w, L_spec_TCX5), sub(*spectrum_e, TCX_IMDCT_SCALE+TCX_IMDCT_HEADROOM), win, @@ -1569,7 +1571,7 @@ void QuantizeSpectrum( move16(); test(); test(); - if ((w > 0) || ((w == 0) && (sub(stop, 2) == 0))) + if ((w > 0) || ((w == 0) && (EQ_16(stop, 2)))) { tmp1 = MIN_OVERLAP; move16(); @@ -1816,7 +1818,7 @@ void QuantizeSpectrum( } ELSE /* frame is TCX-20 or not TCX-only */ { - IF (sub(st->tcx_cfg.tcx_last_overlap_mode, TRANSITION_OVERLAP) != 0) + IF (NE_16(st->tcx_cfg.tcx_last_overlap_mode, TRANSITION_OVERLAP)) { Word32 tmp_buf[L_FRAME_PLUS]; Word16 Q; @@ -1906,7 +1908,7 @@ void QuantizeSpectrum( test(); test(); test(); - IF ((st->last_core_fx > ACELP_CORE) && (((sub(L_frameTCX, shr(st->L_frameTCX, 1)) == 0) && (st->tcxonly != 0)) || (sub(st->tcx_cfg.tcx_last_overlap_mode, TRANSITION_OVERLAP) == 0))) + IF ((st->last_core_fx > ACELP_CORE) && (((EQ_16(L_frameTCX, shr(st->L_frameTCX, 1)))&&(st->tcxonly!=0))||(EQ_16(st->tcx_cfg.tcx_last_overlap_mode,TRANSITION_OVERLAP)))) { IF (tcx_cfg->last_aldo != 0) @@ -1954,7 +1956,7 @@ void QuantizeSpectrum( tmp1 = stop; move16(); test(); - if ((stop == 0) || (sub(tcx_cfg->tcx_last_overlap_mode, MIN_OVERLAP) == 0)) + if ((stop == 0) || (EQ_16(tcx_cfg->tcx_last_overlap_mode, MIN_OVERLAP))) { tmp1 = tcx_cfg->tcx_last_overlap_mode; move16(); @@ -1978,7 +1980,7 @@ void QuantizeSpectrum( move16(); } - IF (sub(i, L_frame) < 0) + IF (LT_16(i, L_frame)) { FOR ( ; i < L_frame; i++) { @@ -2007,8 +2009,8 @@ void QuantizeSpectrum( test(); test(); IF ( (aldo == 0) && - ((sub(L_frameTCX, shr(st->L_frameTCX, 1)) == 0 && frame_cnt > 0) || - sub(L_frameTCX, shr(st->L_frameTCX, 1)) != 0) ) + ((EQ_16(L_frameTCX, shr(st->L_frameTCX, 1)) && frame_cnt > 0) || + NE_16(L_frameTCX, shr(st->L_frameTCX, 1)) ) ) { /*Compute windowed synthesis in case of switching to ALDO windows in next frame*/ FOR (i = 0; i < nz; i++) @@ -2030,7 +2032,7 @@ void QuantizeSpectrum( ); /* If current overlap mode = FULL_OVERLAP -> ALDO_WINDOW */ - IF (sub(tcx_cfg->tcx_curr_overlap_mode, FULL_OVERLAP) == 0) + IF (EQ_16(tcx_cfg->tcx_curr_overlap_mode, FULL_OVERLAP)) { FOR (i=0; itcx_cfg.tcx_last_overlap_mode, TRANSITION_OVERLAP) == 0) + IF (EQ_16(st->tcx_cfg.tcx_last_overlap_mode, TRANSITION_OVERLAP)) { WindowSignal(tcx_cfg, @@ -2159,14 +2161,14 @@ void coder_tcx( left_overlap_mode = tcx_cfg->tcx_last_overlap_mode; move16(); - if (sub(left_overlap_mode, ALDO_WINDOW) == 0) + if (EQ_16(left_overlap_mode, ALDO_WINDOW)) { left_overlap_mode = FULL_OVERLAP; move16(); } right_overlap_mode = tcx_cfg->tcx_curr_overlap_mode; move16(); - if (sub(right_overlap_mode, ALDO_WINDOW) == 0) + if (EQ_16(right_overlap_mode, ALDO_WINDOW)) { right_overlap_mode = FULL_OVERLAP; move16(); @@ -2213,7 +2215,7 @@ void coder_tcx( pWinMDST = winMDST; move16(); - if (sub(st->tcx_cfg.tcx_last_overlap_mode, TRANSITION_OVERLAP) == 0) + if (EQ_16(st->tcx_cfg.tcx_last_overlap_mode, TRANSITION_OVERLAP)) { pWinMDST = win; move16(); diff --git a/lib_enc/cod_uv.c b/lib_enc/cod_uv.c index 41e5ec122abc069f17075baf9f4ebe299a3479a9..94c904959b3d8e58220ba9b429e3f66edbf7d0da 100644 --- a/lib_enc/cod_uv.c +++ b/lib_enc/cod_uv.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ @@ -8,8 +8,6 @@ #include #include "prot_fx.h" #include "stl.h" -#include "wmc_auto.h" - /*-------------------------------------------------------------------* * gauss_L2: diff --git a/lib_enc/comvad_decision.c b/lib_enc/comvad_decision.c index 9b243c579a11a71f54d0fa26e1094998576bd409..f821e6ff791187232abfc08523918720a82ac864 100644 --- a/lib_enc/comvad_decision.c +++ b/lib_enc/comvad_decision.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ @@ -9,12 +9,9 @@ #include "basop_util.h" #include "stl.h" -#include "wmc_auto.h" - #include "vad_basop.h" #include "prot_fx.h" #include "rom_enc_fx.h" -#include "wmc_auto.h" @@ -42,13 +39,13 @@ Word16 comvad_hangover( Word32 lt_snr_org, /*(i)original long time speech_flag = pre_res_hang_num; move16(); - IF(sub(bw_index, CLDFBVAD_SWB_ID) == 0) + IF(EQ_16(bw_index, CLDFBVAD_SWB_ID)) { IF(vad_flag) { speech_flag = 4; move16(); - if(L_sub(lt_snr_org, 117440509/* 3.5 Q25 */) > 0) + if(GT_32(lt_snr_org, 117440509/* 3.5 Q25 */)) { speech_flag = 3; move16(); @@ -56,23 +53,23 @@ Word16 comvad_hangover( Word32 lt_snr_org, /*(i)original long time test(); test(); - IF((sub(continuous_speech_num2, 8) < 0)&& (L_sub(lt_snr_org, 134217724/* 4.0 Q25 */) < 0)) + IF((LT_16(continuous_speech_num2, 8))&&(LT_32(lt_snr_org,134217724/* 4.0 Q25 */))) { speech_flag = sub(8, continuous_speech_num2); } - ELSE IF((L_sub(snr_flux, 26843545/* 0.8 Q25 */) > 0 )&&(sub(continuous_speech_num2, 24) > 0)) + ELSE IF((GT_32(snr_flux, 26843545/* 0.8 Q25 */))&&(GT_16(continuous_speech_num2,24))) { - IF(L_sub(lt_snr_org, 120795952/* 3.6 Q25 */) > 0) + IF(GT_32(lt_snr_org, 120795952/* 3.6 Q25 */)) { speech_flag = 3; move16(); } - ELSE IF(L_sub(lt_snr_org, 87241521/* 2.6 Q25 */) > 0 ) + ELSE IF(GT_32(lt_snr_org, 87241521/* 2.6 Q25 */)) { speech_flag = 3; move16(); } - ELSE IF(L_sub(lt_snr_org, 53687090/* 1.6 Q25 */) > 0 ) + ELSE IF(GT_32(lt_snr_org, 53687090/* 1.6 Q25 */)) { speech_flag = 4; move16(); @@ -85,52 +82,52 @@ Word16 comvad_hangover( Word32 lt_snr_org, /*(i)original long time speech_flag = sub(speech_flag,1); } - IF(sub(continuous_speech_num2, 120) < 0) + IF(LT_16(continuous_speech_num2, 120)) { test(); - IF(L_sub(snr, 50331647/* 1.5 Q25 */)>0) + IF(GT_32(snr, 50331647/* 1.5 Q25 */)) { speech_flag = 9; move16(); } - ELSE IF(L_sub(snr, 33554431/* 1.0 Q25 */)>0 && sub(speech_flag, 7)<0) + ELSE IF(GT_32(snr, 33554431/* 1.0 Q25 */)&<_16(speech_flag,7)) { speech_flag = 7; move16(); } - ELSE IF(sub(speech_flag,3) <0) + ELSE IF(LT_16(speech_flag,3)) { speech_flag = 3; move16(); } - if(sub(speech_flag,3)>0) + if(GT_16(speech_flag,3)) { speech_flag =sub(speech_flag,2); } } ELSE { - IF(L_sub(lt_snr_org, 120795952/* 3.6 Q25 */) > 0) + IF(GT_32(lt_snr_org, 120795952/* 3.6 Q25 */)) { speech_flag = 1; move16(); } - ELSE IF(L_sub(lt_snr_org, 100663293/* 3.0 Q25 */) > 0) + ELSE IF(GT_32(lt_snr_org, 100663293/* 3.0 Q25 */)) { speech_flag = 2; move16(); } - ELSE IF(L_sub(lt_snr_org, 83886078/* 2.5 Q25 */) > 0) + ELSE IF(GT_32(lt_snr_org, 83886078/* 2.5 Q25 */)) { speech_flag = 3; move16(); } - ELSE IF(L_sub(lt_snr_org, 67108862/* 2.0 Q25 */) > 0) + ELSE IF(GT_32(lt_snr_org, 67108862/* 2.0 Q25 */)) { speech_flag = 3; move16(); } - ELSE IF(L_sub(lt_snr_org, 50331647/* 1.5 Q25 */)> 0) + ELSE IF(GT_32(lt_snr_org, 50331647/* 1.5 Q25 */)) { speech_flag = 4; move16(); @@ -142,18 +139,18 @@ Word16 comvad_hangover( Word32 lt_snr_org, /*(i)original long time } } - if(sub(noisy_type, SILENCE)==0) + if(EQ_16(noisy_type, SILENCE)) { speech_flag = 6; move16(); } } } - ELSE IF(sub(bw_index, CLDFBVAD_WB_ID) == 0) + ELSE IF(EQ_16(bw_index, CLDFBVAD_WB_ID)) { IF(vad_flag) { - IF(L_sub(lt_snr_org, 117440509/* 3.5 Q25 */) > 0) + IF(GT_32(lt_snr_org, 117440509/* 3.5 Q25 */)) { speech_flag = 1; move16(); @@ -166,23 +163,23 @@ Word16 comvad_hangover( Word32 lt_snr_org, /*(i)original long time test(); test(); - IF((sub(continuous_speech_num2, 8) < 0) && (L_sub(lt_snr_org, 134217724/* 4.0 Q25 */) <0 )) + IF((LT_16(continuous_speech_num2, 8))&&(LT_32(lt_snr_org,134217724/* 4.0 Q25 */))) { speech_flag = sub(8, continuous_speech_num2); } - ELSE IF((L_sub(snr_flux, 30198988/* 0.9 Q25 */) > 0) && (sub(continuous_speech_num2, 50) > 0)) + ELSE IF((GT_32(snr_flux, 30198988/* 0.9 Q25 */))&&(GT_16(continuous_speech_num2,50))) { - IF(L_sub(lt_snr_org, 120795952/* 3.6 Q25 */) > 0) + IF(GT_32(lt_snr_org, 120795952/* 3.6 Q25 */)) { speech_flag = 1; move16(); } - ELSE IF(L_sub(lt_snr_org, 87241521/* 2.6 Q25 */) > 0) + ELSE IF(GT_32(lt_snr_org, 87241521/* 2.6 Q25 */)) { speech_flag = 5; move16(); } - ELSE IF(L_sub(lt_snr_org, 53687090/* 1.6 Q25 */) > 0) + ELSE IF(GT_32(lt_snr_org, 53687090/* 1.6 Q25 */)) { speech_flag = 6; move16(); @@ -192,33 +189,33 @@ Word16 comvad_hangover( Word32 lt_snr_org, /*(i)original long time speech_flag = 7; move16(); } - IF(sub(speech_flag , 1)>0) + IF(GT_16(speech_flag , 1)) { speech_flag = sub(speech_flag , 1); } } - IF(sub(continuous_speech_num2, 120)< 0) + IF(LT_16(continuous_speech_num2, 120)) { test(); test(); test(); - IF(L_sub(snr, 50331647/* 1.5 Q25 */)>0) + IF(GT_32(snr, 50331647/* 1.5 Q25 */)) { speech_flag = 6; move16(); } - ELSE IF(L_sub(snr, 33554431/* 1.0 Q25 */)>0 && sub(speech_flag, 5) < 0) + ELSE IF(GT_32(snr, 33554431/* 1.0 Q25 */)&<_16(speech_flag,5)) { speech_flag = 5; move16(); } - ELSE IF(L_sub(snr, 26843545/* 0.8 Q25 */)>0 && L_sub(lt_snr_org,67108862/* 2.0 Q25 */) < 0 && sub(speech_flag, 4) < 0) + ELSE IF(GT_32(snr, 26843545/* 0.8 Q25 */)&<_32(lt_snr_org,67108862/* 2.0 Q25 */)&<_16(speech_flag,4)) { speech_flag = 4; move16(); } - ELSE IF(sub(speech_flag, 3) < 0) + ELSE IF(LT_16(speech_flag, 3)) { speech_flag = 3; move16(); @@ -226,22 +223,22 @@ Word16 comvad_hangover( Word32 lt_snr_org, /*(i)original long time } ELSE { - IF(L_sub(lt_snr_org,120795952/* 3.6 Q25 */) > 0) + IF(GT_32(lt_snr_org,120795952/* 3.6 Q25 */)) { speech_flag = 1; move16(); } - ELSE IF(L_sub(lt_snr_org, 100663293/* 3.0 Q25 */) > 0) + ELSE IF(GT_32(lt_snr_org, 100663293/* 3.0 Q25 */)) { speech_flag = 2; move16(); } - ELSE IF(L_sub(lt_snr_org, 83886078/* 2.5 Q25 */) > 0) + ELSE IF(GT_32(lt_snr_org, 83886078/* 2.5 Q25 */)) { speech_flag = 2; move16(); } - ELSE IF(L_sub(lt_snr_org, 67108862/* 2.0 Q25 */) > 0) + ELSE IF(GT_32(lt_snr_org, 67108862/* 2.0 Q25 */)) { speech_flag = 3; move16(); @@ -252,7 +249,7 @@ Word16 comvad_hangover( Word32 lt_snr_org, /*(i)original long time } } - if(sub(noisy_type, SILENCE)==0) + if(EQ_16(noisy_type, SILENCE)) { speech_flag = 6; move16(); @@ -265,7 +262,7 @@ Word16 comvad_hangover( Word32 lt_snr_org, /*(i)original long time { l_snr_add = L_add(0x0199999a,MUL_F(l_snr,0x0ccd)); - IF(L_sub(lt_snr_org, 117440509/* 3.5 Q25 */) > 0) + IF(GT_32(lt_snr_org, 117440509/* 3.5 Q25 */)) { speech_flag = 3; move16(); @@ -278,23 +275,23 @@ Word16 comvad_hangover( Word32 lt_snr_org, /*(i)original long time test(); test(); - IF((sub(continuous_speech_num2,8) < 0)&& (L_sub(lt_snr_org, 134217724/* 4.0 Q25 */) < 0)) + IF((LT_16(continuous_speech_num2,8))&&(LT_32(lt_snr_org,134217724/* 4.0 Q25 */))) { speech_flag = sub(8, continuous_speech_num2); } - ELSE IF((L_sub(snr_flux, l_snr_add) > 0)&&(sub(continuous_speech_num2, 24) > 0)) + ELSE IF((GT_32(snr_flux, l_snr_add))&&(GT_16(continuous_speech_num2,24))) { - IF(L_sub(lt_snr_org, 120795952/* 3.6 Q25 */) > 0) + IF(GT_32(lt_snr_org, 120795952/* 3.6 Q25 */)) { speech_flag = 3; move16(); } - ELSE IF(L_sub(lt_snr_org, 87241521/* 2.6 Q25 */) > 0) + ELSE IF(GT_32(lt_snr_org, 87241521/* 2.6 Q25 */)) { speech_flag = 8; move16(); } - ELSE IF(L_sub(lt_snr_org, 40265317/* 1.2 Q25 */) > 0) + ELSE IF(GT_32(lt_snr_org, 40265317/* 1.2 Q25 */)) { speech_flag = 10; move16(); @@ -305,27 +302,27 @@ Word16 comvad_hangover( Word32 lt_snr_org, /*(i)original long time move16(); } - IF(sub(speech_flag ,2)>0) + IF(GT_16(speech_flag ,2)) { speech_flag = sub(speech_flag,2); } } - IF(sub(continuous_speech_num2, 120) < 0) + IF(LT_16(continuous_speech_num2, 120)) { test(); test(); - IF(L_sub(snr, 50331647/* 1.5 Q25 */)>0) + IF(GT_32(snr, 50331647/* 1.5 Q25 */)) { speech_flag = 10; move16(); } - ELSE IF(L_sub(snr, 33554431/* 1.0 Q25 */)>0 && sub(speech_flag,7) < 0) + ELSE IF(GT_32(snr, 33554431/* 1.0 Q25 */)&<_16(speech_flag,7)) { speech_flag = 7; move16(); } - ELSE IF(sub(speech_flag, 3)<0 && sub(continuous_speech_num2, 12) > 0) + ELSE IF(LT_16(speech_flag, 3)&>_16(continuous_speech_num2,12)) { speech_flag = 3; move16(); @@ -333,27 +330,27 @@ Word16 comvad_hangover( Word32 lt_snr_org, /*(i)original long time } ELSE { - IF(L_sub(lt_snr_org, 120795952/* 3.6 Q25 */) > 0) + IF(GT_32(lt_snr_org, 120795952/* 3.6 Q25 */)) { speech_flag = 2; move16(); } - ELSE IF(L_sub(lt_snr_org, 100663293/* 3.0 Q25 */) > 0) + ELSE IF(GT_32(lt_snr_org, 100663293/* 3.0 Q25 */)) { speech_flag = 2; move16(); } - ELSE IF(L_sub(lt_snr_org, 83886078/* 2.5 Q25 */) > 0) + ELSE IF(GT_32(lt_snr_org, 83886078/* 2.5 Q25 */)) { speech_flag = 3; move16(); } - ELSE IF(L_sub(lt_snr_org, 67108862/* 2.0 Q25 */) > 0) + ELSE IF(GT_32(lt_snr_org, 67108862/* 2.0 Q25 */)) { speech_flag = 3; move16(); } - ELSE IF(L_sub(lt_snr_org, 50331647/* 1.5 Q25 */)> 0) + ELSE IF(GT_32(lt_snr_org, 50331647/* 1.5 Q25 */)) { speech_flag = 4; move16(); @@ -365,7 +362,7 @@ Word16 comvad_hangover( Word32 lt_snr_org, /*(i)original long time } } - if(sub(noisy_type, SILENCE) == 0) + if(EQ_16(noisy_type, SILENCE)) { speech_flag = 2; move16(); @@ -374,9 +371,9 @@ Word16 comvad_hangover( Word32 lt_snr_org, /*(i)original long time } - IF((sub(vad_flag,1)==0)) + IF((EQ_16(vad_flag,1))) { - IF((sub(noisy_type, SILENCE) != 0)) + IF((NE_16(noisy_type, SILENCE))) { speech_flag--; } @@ -433,8 +430,10 @@ Word16 comvad_decision( T_CldfbVadState *st, move16(); speech_flag = st->speech_flag; move16(); - fg_energy = L_add(st->fg_energy,0); - bg_energy = L_add(st->bg_energy,0); + fg_energy = st->fg_energy; + move32(); + bg_energy = st->bg_energy; + move32(); Qnorm_silence = 0; move16(); @@ -442,7 +441,7 @@ Word16 comvad_decision( T_CldfbVadState *st, move16(); test(); - IF(L_sub(st->lf_snr_smooth, LS_MIN_SILENCE_SNR[st->bw_index - CLDFBVAD_NB_ID] ) > 0 && L_sub(lt_snr_org, LT_MIN_SILENCE_SNR[st->bw_index - CLDFBVAD_NB_ID] )> 0) + IF(GT_32(st->lf_snr_smooth, LS_MIN_SILENCE_SNR[st->bw_index - CLDFBVAD_NB_ID] )&>_32(lt_snr_org,LT_MIN_SILENCE_SNR[st->bw_index-CLDFBVAD_NB_ID])) { noisy_type = SILENCE; move16(); @@ -460,28 +459,28 @@ Word16 comvad_decision( T_CldfbVadState *st, { vad_flag = 0; move16(); - if(L_sub(snr, tmp_snr) > 0) + if(GT_32(snr, tmp_snr)) { vad_flag = 1; move16(); } - if(L_sub(tsnr, 67108862/* 4.0/2.0 Q25 */) > 0 ) + if(GT_32(tsnr, 67108862/* 4.0/2.0 Q25 */)) { vad_flag = 1; move16(); } } - IF(sub(st->frameloop, 25) > 0) + IF(GT_16(st->frameloop, 25)) { test(); - IF(sub(vad_flag, 1) == 0 && L_sub(st->fg_energy_est_start, 1) == 0) + IF(EQ_16(vad_flag, 1)&&EQ_32(st->fg_energy_est_start,1)) { Word32 frame_energy_mult_fix32,bg_energy_mult_fix32; Word16 frame_energy_mult_Q,bg_energy_mult_Q; - IF(sub(st->fg_energy_count, 512) == 0) + IF(EQ_16(st->fg_energy_count, 512)) { fg_energy = MUL_F(fg_energy, 0x6000); st->fg_energy_count = 384; @@ -494,16 +493,16 @@ Word16 comvad_decision( T_CldfbVadState *st, bg_energy_mult_fix32 = MUL_F(bg_energy, 6); bg_energy_mult_Q = sub(st->bg_energy_scale, 15); - IF(sub(frame_energy_mult_Q, bg_energy_mult_Q) > 0) + IF(GT_16(frame_energy_mult_Q, bg_energy_mult_Q)) { frame_energy_mult_fix32 = L_shr(frame_energy_mult_fix32,sub(frame_energy_mult_Q, bg_energy_mult_Q)); } - IF(sub(frame_energy_mult_Q, bg_energy_mult_Q) < 0) + IF(LT_16(frame_energy_mult_Q, bg_energy_mult_Q)) { bg_energy_mult_fix32 = L_shr(bg_energy_mult_fix32,limitScale32(sub(bg_energy_mult_Q, frame_energy_mult_Q))); } - IF(L_sub(frame_energy_mult_fix32, bg_energy_mult_fix32) > 0) + IF(GT_32(frame_energy_mult_fix32, bg_energy_mult_fix32)) { fg_energy = VAD_L_ADD(fg_energy, st->fg_energy_scale, frame_energy, frame_energy_Q, &st->fg_energy_scale); st->fg_energy_count = add(st->fg_energy_count, 1); @@ -518,7 +517,7 @@ Word16 comvad_decision( T_CldfbVadState *st, move16(); } - IF(sub(vad_flag, 1) == 0) + IF(EQ_16(vad_flag, 1)) { IF (st->l_silence_snr == 0) { @@ -538,9 +537,9 @@ Word16 comvad_decision( T_CldfbVadState *st, snr_div_fix32 = L_shr(snr_div_fix32, add(6, sub(Qnorm_silence, Qnorm_silence_count))); - IF(L_sub(snr_sub, snr_div_fix32) > 0) + IF(GT_32(snr_sub, snr_div_fix32)) { - IF(L_sub(st->l_speech_snr_count, 512) == 0) + IF(EQ_32(st->l_speech_snr_count, 512)) { st->l_speech_snr = L_add(MUL_F(st->l_speech_snr, 0x6000), L_shr(snr, 9)); move32(); @@ -559,13 +558,13 @@ Word16 comvad_decision( T_CldfbVadState *st, lt_snr_org_cmp = L_sub(lt_snr_org, 117440509/* 3.5 Q25 */); - IF(sub(st->bw_index, CLDFBVAD_NB_ID) == 0) + IF(EQ_16(st->bw_index, CLDFBVAD_NB_ID)) { Word32 lt_snr_add; lt_snr_add = L_add(0x03cccccd, MUL_F(lt_snr, 0x23d7)); - if(L_sub(snr_flux, lt_snr_add) > 0) + if(GT_32(snr_flux, lt_snr_add)) { vad_flag = 1; move16(); @@ -573,7 +572,7 @@ Word16 comvad_decision( T_CldfbVadState *st, test(); test(); - if( (L_sub(snr_flux, 50331647/* 1.5 Q25 */) > 0) && (sub(st->sp_center[3], 1637/* 1.6 Q10 */) > 0) && (lt_snr_org_cmp < 0) ) + if( (GT_32(snr_flux, 50331647/* 1.5 Q25 */))&&(GT_16(st->sp_center[3],1637/* 1.6 Q10 */))&&(lt_snr_org_cmp<0)) { vad_flag = 1; move16(); @@ -581,7 +580,7 @@ Word16 comvad_decision( T_CldfbVadState *st, test(); test(); - if( (L_sub(snr_flux, 40265317/* 1.2 Q25 */) > 0) && (sub(st->sp_center[3], 1944/* 1.9 Q10 */) > 0) && (lt_snr_org_cmp < 0) ) + if( (GT_32(snr_flux, 40265317/* 1.2 Q25 */))&&(GT_16(st->sp_center[3],1944/* 1.9 Q10 */))&&(lt_snr_org_cmp<0)) { vad_flag = 1; move16(); @@ -589,19 +588,19 @@ Word16 comvad_decision( T_CldfbVadState *st, test(); test(); - if((L_sub(snr_flux, 33554431/* 1.0 Q25 */) > 0) && (sub(st->sp_center[3], 3274/* 3.2 Q10 */) > 0) && (lt_snr_org_cmp < 0)) + if((GT_32(snr_flux, 33554431/* 1.0 Q25 */))&&(GT_16(st->sp_center[3],3274/* 3.2 Q10 */))&&(lt_snr_org_cmp<0)) { vad_flag = 1; move16(); } } - ELSE IF(sub(st->bw_index, CLDFBVAD_WB_ID) == 0) + ELSE IF(EQ_16(st->bw_index, CLDFBVAD_WB_ID)) { Word32 lt_snr_add; lt_snr_add = L_add(0x04333333, MUL_F(lt_snr, 0x1eb8)); - if(L_sub(snr_flux, lt_snr_add) > 0) + if(GT_32(snr_flux, lt_snr_add)) { vad_flag = 1; move16(); @@ -609,7 +608,7 @@ Word16 comvad_decision( T_CldfbVadState *st, test(); test(); - if((L_sub(snr_flux, 53687090/* 1.6 Q25 */) > 0 ) && (sub(st->sp_center[3], 2558/* 2.5 Q10 */) > 0) && (lt_snr_org_cmp < 0)) + if((GT_32(snr_flux, 53687090/* 1.6 Q25 */))&&(GT_16(st->sp_center[3],2558/* 2.5 Q10 */))&&(lt_snr_org_cmp<0)) { vad_flag = 1; move16(); @@ -617,7 +616,7 @@ Word16 comvad_decision( T_CldfbVadState *st, test(); test(); - if((L_sub(snr_flux, 40265317/* 1.2 Q25 */) > 0) && (sub(st->sp_center[3], 2864/* 2.8 Q10 */) > 0) && (lt_snr_org_cmp < 0)) + if((GT_32(snr_flux, 40265317/* 1.2 Q25 */))&&(GT_16(st->sp_center[3],2864/* 2.8 Q10 */))&&(lt_snr_org_cmp<0)) { vad_flag = 1; move16(); @@ -625,7 +624,7 @@ Word16 comvad_decision( T_CldfbVadState *st, test(); test(); - if((L_sub(snr_flux, 33554431/* 1.0 Q25 */) > 0) && (sub(st->sp_center[3], 4604/* 4.5 Q10 */) > 0) && (lt_snr_org_cmp < 0)) + if((GT_32(snr_flux, 33554431/* 1.0 Q25 */))&&(GT_16(st->sp_center[3],4604/* 4.5 Q10 */))&&(lt_snr_org_cmp<0)) { vad_flag = 1; move16(); @@ -637,7 +636,7 @@ Word16 comvad_decision( T_CldfbVadState *st, lt_snr_add = L_add(0x04333333, MUL_F(lt_snr, 0x28f5)); - if((L_sub(snr_flux, lt_snr_add) > 0)) + if((GT_32(snr_flux, lt_snr_add))) { vad_flag = 1; move16(); @@ -645,7 +644,7 @@ Word16 comvad_decision( T_CldfbVadState *st, test(); test(); - if((L_sub(snr_flux, 56371444/* 1.68 Q25 */) > 0) && (sub(st->sp_center[3], 2823/* 2.76 Q10 */) > 0) && (lt_snr_org_cmp < 0)) + if((GT_32(snr_flux, 56371444/* 1.68 Q25 */))&&(GT_16(st->sp_center[3],2823/* 2.76 Q10 */))&&(lt_snr_org_cmp<0)) { vad_flag = 1; move16(); @@ -653,7 +652,7 @@ Word16 comvad_decision( T_CldfbVadState *st, test(); test(); - if((L_sub(snr_flux, 41607494/* 1.24 Q25 */) > 0) && (sub(st->sp_center[3], 2987/* 2.92 Q10 */) > 0) && (lt_snr_org_cmp < 0)) + if((GT_32(snr_flux, 41607494/* 1.24 Q25 */))&&(GT_16(st->sp_center[3],2987/* 2.92 Q10 */))&&(lt_snr_org_cmp<0)) { vad_flag = 1; move16(); @@ -661,7 +660,7 @@ Word16 comvad_decision( T_CldfbVadState *st, test(); test(); - if((L_sub(snr_flux, 36909874/* 1.10 Q25 */) > 0) && (sub(st->sp_center[3], 4706/* 4.6 Q10 */) > 0) && (lt_snr_org_cmp < 0)) + if((GT_32(snr_flux, 36909874/* 1.10 Q25 */))&&(GT_16(st->sp_center[3],4706/* 4.6 Q10 */))&&(lt_snr_org_cmp<0)) { vad_flag = 1; move16(); @@ -675,7 +674,7 @@ Word16 comvad_decision( T_CldfbVadState *st, test(); test(); - if(sub(st->ltd_stable_rate[0], 2621/* 0.08 Q15 */) > 0 && sub(vad_flag,1) == 0 && (tmpout> 0)) + if(GT_16(st->ltd_stable_rate[0], 2621/* 0.08 Q15 */)&&EQ_16(vad_flag,1)&&(tmpout>0)) { st->fg_energy_est_start = L_deposit_l(1); } @@ -702,60 +701,60 @@ Word16 comvad_decision( T_CldfbVadState *st, } vadb_flag = vad_flag; - IF(sub(st->bw_index, CLDFBVAD_SWB_ID) == 0) + IF(EQ_16(st->bw_index, CLDFBVAD_SWB_ID)) { test(); test(); test(); - IF(sub(SILENCE, noisy_type) == 0 - && L_sub(snr, 6710886/* 0.2 Q25 */) > 0 + IF(EQ_16(SILENCE, noisy_type) + && GT_32(snr, 6710886/* 0.2 Q25 */) && vad_flag == 0) { vad_flag = vada_flag; move16(); } - ELSE IF(L_sub(st->lf_snr_smooth,352321526/* 10.5 Q25 */)<0 || sub(SILENCE, noisy_type) != 0) + ELSE IF(LT_32(st->lf_snr_smooth,352321526/* 10.5 Q25 */)||NE_16(SILENCE,noisy_type)) { test(); test(); test(); - IF(L_sub(snr_flux, 83886078/* 2.5 Q25 */) > 0 - || (st->continuous_speech_num2 > 40 && L_sub(snr_flux, 67108862/* 2.0 Q25 */) > 0) + IF(GT_32(snr_flux, 83886078/* 2.5 Q25 */) + || ( st->continuous_speech_num2 > 40 && GT_32(snr_flux, 67108862/* 2.0 Q25 */) ) || music_backgound_f == 1) { vad_flag = s_or(vad_flag, vada_flag); } - ELSE IF(sub(SILENCE, noisy_type) == 0) + ELSE IF(EQ_16(SILENCE, noisy_type)) { vad_flag = vada_flag; } } } - ELSE IF(sub(st->bw_index, CLDFBVAD_WB_ID) == 0) + ELSE IF(EQ_16(st->bw_index, CLDFBVAD_WB_ID)) { test(); test(); test(); - IF(sub(SILENCE, noisy_type) == 0 - && L_sub(snr, 6710886/* 0.2 Q25 */) > 0 + IF(EQ_16(SILENCE, noisy_type) + && GT_32(snr, 6710886/* 0.2 Q25 */) && vad_flag == 0) { vad_flag = vada_flag; move16(); } - ELSE IF(L_sub(st->lf_snr_smooth,352321526/* 10.5 Q25 */)<0 || sub(SILENCE, noisy_type) != 0) + ELSE IF(LT_32(st->lf_snr_smooth,352321526/* 10.5 Q25 */)||NE_16(SILENCE,noisy_type)) { test(); test(); test(); - IF(L_sub(snr_flux, 73819748/* 2.2 Q25 */) > 0 - || (st->continuous_speech_num2 > 40 && L_sub(snr_flux, 57042532/* 1.7 Q25 */) > 0) + IF(GT_32(snr_flux, 73819748/* 2.2 Q25 */) + || (st->continuous_speech_num2 > 40 && GT_32(snr_flux, 57042532/* 1.7 Q25 */) ) || music_backgound_f == 1) { vad_flag = s_or(vad_flag, vada_flag); } - ELSE IF(sub(SILENCE, noisy_type) == 0) + ELSE IF(EQ_16(SILENCE, noisy_type)) { vad_flag = vada_flag; } @@ -765,10 +764,10 @@ Word16 comvad_decision( T_CldfbVadState *st, } ELSE { - IF(sub(SILENCE, noisy_type) == 0) + IF(EQ_16(SILENCE, noisy_type)) { test(); - IF(L_sub(st->lf_snr_smooth , 419430388/* 12.5 Q25 */) > 0 + IF(GT_32(st->lf_snr_smooth , 419430388/* 12.5 Q25 */) && music_backgound_f == 0) { vad_flag = vada_flag; @@ -779,8 +778,8 @@ Word16 comvad_decision( T_CldfbVadState *st, test(); test(); test(); - IF(L_sub(snr_flux, 67108862/* 2.0 Q25 */) > 0 - || (st->continuous_speech_num2 > 30 && L_sub(snr_flux, 50331647/* 1.5 Q25 */) > 0) + IF(GT_32(snr_flux, 67108862/* 2.0 Q25 */) + || (st->continuous_speech_num2 > 30 && GT_32(snr_flux, 50331647/* 1.5 Q25 */) ) || music_backgound_f == 1) { vad_flag = s_or(vad_flag, vada_flag); @@ -790,14 +789,14 @@ Word16 comvad_decision( T_CldfbVadState *st, IF(vad_flag == 0) { - IF(L_sub(st->l_silence_snr_count, 512) == 0) + IF(EQ_32(st->l_silence_snr_count, 512)) { st->l_silence_snr = L_add(MUL_F(st->l_silence_snr, 0x6000),L_shr(snr, 9)); move32(); st->l_silence_snr_count = L_deposit_l(384+1); move32(); } - ELSE IF(L_sub(snr, 26843545/* 0.8 Q25 */) < 0) + ELSE IF(LT_32(snr, 26843545/* 0.8 Q25 */)) { st->l_silence_snr = L_add(st->l_silence_snr, L_shr(snr,9)); move32(); @@ -808,14 +807,14 @@ Word16 comvad_decision( T_CldfbVadState *st, IF(vad_flag == 0) { - IF(sub(st->bg_energy_count, 512) == 0) + IF(EQ_16(st->bg_energy_count, 512)) { bg_energy = MUL_F(bg_energy, 0x6000); st->bg_energy_count = 384; move16(); } - IF(L_sub(tsnr, 16777216/* 1.0/2.0 Q25 */) < 0) + IF(LT_32(tsnr, 16777216/* 1.0/2.0 Q25 */)) { bg_energy = VAD_L_ADD(bg_energy, st->bg_energy_scale, frame_energy, frame_energy_Q, &st->bg_energy_scale); st->bg_energy_count = add(st->bg_energy_count, 1); @@ -825,7 +824,7 @@ Word16 comvad_decision( T_CldfbVadState *st, test(); st->vad_flag_for_bk_update = vad_flag; - IF(sub(st->update_count, 12) < 0 && sub(vadb_flag, 1)==0) + IF(LT_16(st->update_count, 12)&&EQ_16(vadb_flag,1)) { st->warm_hang_num = s_max(20, speech_flag); } @@ -852,8 +851,8 @@ Word16 comvad_decision( T_CldfbVadState *st, move16(); test(); - IF(sub(noisy_type, SILENCE) == 0 - && sub(st->bw_index, CLDFBVAD_NB_ID) != 0) + IF(EQ_16(noisy_type, SILENCE) + && NE_16(st->bw_index, CLDFBVAD_NB_ID)) { *cldfb_addition = 2; } @@ -861,17 +860,17 @@ Word16 comvad_decision( T_CldfbVadState *st, { *cldfb_addition = 0; - if(sub(st->bw_index, CLDFBVAD_WB_ID)==0) + if(EQ_16(st->bw_index, CLDFBVAD_WB_ID)) { *cldfb_addition = 3; move16(); } - if(sub(st->bw_index, CLDFBVAD_SWB_ID)==0) + if(EQ_16(st->bw_index, CLDFBVAD_SWB_ID)) { *cldfb_addition = 1; move16(); } - if(sub(st->bw_index, CLDFBVAD_NB_ID)==0) + if(EQ_16(st->bw_index, CLDFBVAD_NB_ID)) { *cldfb_addition = 1; move16(); diff --git a/lib_enc/cor_shif_fx.c b/lib_enc/cor_shif_fx.c index 8f104a9903cc4be1de5ab677145f0bff17307f9b..966d3e4d3670b7469440e0603caf8644f02738ce 100644 --- a/lib_enc/cor_shif_fx.c +++ b/lib_enc/cor_shif_fx.c @@ -1,12 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "cnst_fx.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" /*-------------------------------------------------------------------* @@ -28,7 +27,7 @@ Word16 correlation_shift_fx( /* o : noise dependent voicing correction Q15 corr_shift_fx = 0; move16(); - IF (sub(totalNoise_fx, 7215) > 0) /* to make corr_shift > 0.0 */ + IF (GT_16(totalNoise_fx, 7215)) /* to make corr_shift > 0.0 */ { /*------------------------------------------------------------* * useful values range from 0 to 1 (can saturate at 1.0) Q31 value diff --git a/lib_enc/core_enc_2div.c b/lib_enc/core_enc_2div.c index 71b49d9a511273e456bc81de3b798d62fdb16654..5b1bd0a15ac7fa17bdae5721107ce7950d1cf211 100644 --- a/lib_enc/core_enc_2div.c +++ b/lib_enc/core_enc_2div.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ @@ -11,8 +11,6 @@ #include "options.h" #include "cnst_fx.h" #include "stl.h" -#include "wmc_auto.h" - void core_encode_twodiv( const Word16 new_samples[], @@ -73,14 +71,14 @@ void core_encode_twodiv( T_op[i] = pitch[i]; /* check minimum pitch for quantization */ - IF ( sub(T_op[i], PIT_MIN_SHORTER) < 0 ) + IF ( LT_16(T_op[i], PIT_MIN_SHORTER)) { move16(); T_op[i] = shl(T_op[i], 1); } /* convert pitch values to core sampling-rate */ - IF ( sub(st->L_frame_fx, L_FRAME) != 0 ) + IF ( NE_16(st->L_frame_fx, L_FRAME)) { move16(); /* T_op[i] = (short)(T_op[i] * (float)st->L_frame_fx/(float)L_FRAME + 0.5f); */ @@ -94,7 +92,7 @@ void core_encode_twodiv( move16(); st->core_fx = TCX_10_CORE; - if ( sub(st->tcxMode,TCX_20) == 0 ) + if ( EQ_16(st->tcxMode,TCX_20)) { move16(); st->core_fx = TCX_20_CORE; @@ -148,7 +146,7 @@ void core_encode_twodiv( * Run Two TCX10 *---------------------------------------------------------------*/ - IF ( sub(st->core_fx,TCX_10_CORE) == 0 ) + IF ( EQ_16(st->core_fx,TCX_10_CORE)) { Word16 last_ace_mode; @@ -193,7 +191,7 @@ void core_encode_twodiv( /* subtract bits for TCX overlap mode (1 bit: full, 2 bits: half or no overlap) */ bitsAvailable = sub(bitsAvailable,1); test(); - if (sub(st->tcx_cfg.tcx_curr_overlap_mode, HALF_OVERLAP) == 0 || sub(st->tcx_cfg.tcx_curr_overlap_mode, MIN_OVERLAP) == 0) + if (EQ_16(st->tcx_cfg.tcx_curr_overlap_mode, HALF_OVERLAP)||EQ_16(st->tcx_cfg.tcx_curr_overlap_mode,MIN_OVERLAP)) { bitsAvailable = sub(bitsAvailable,1); } @@ -263,7 +261,7 @@ void core_encode_twodiv( * Run One TCX20 *---------------------------------------------------------------*/ - IF ( sub(st->core_fx,TCX_20_CORE) == 0 ) + IF ( EQ_16(st->core_fx,TCX_20_CORE)) { E_LPC_f_lsp_a_conversion(lsp_q, A_q, M); @@ -286,7 +284,7 @@ void core_encode_twodiv( /* subtract bits for TCX overlap mode (1 bit: full, 2 bits: half or no overlap) */ target_bits = sub(target_bits,1); test(); - if (sub(st->tcx_cfg.tcx_curr_overlap_mode, HALF_OVERLAP) == 0 || sub(st->tcx_cfg.tcx_curr_overlap_mode, MIN_OVERLAP) == 0) + if (EQ_16(st->tcx_cfg.tcx_curr_overlap_mode, HALF_OVERLAP)||EQ_16(st->tcx_cfg.tcx_curr_overlap_mode,MIN_OVERLAP)) { target_bits = sub(target_bits,1); } diff --git a/lib_enc/core_enc_init.c b/lib_enc/core_enc_init.c index 7258c061501426529755f8d5e5f894ec2b4aa458..afd1c3efa06790dfe216b61d1df3821230d0af21 100644 --- a/lib_enc/core_enc_init.c +++ b/lib_enc/core_enc_init.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -8,13 +8,10 @@ #include "options.h" #include "cnst_fx.h" #include "stl.h" -#include "wmc_auto.h" - #include "count.h" #include "basop_util.h" #include "rom_com_fx.h" #include -#include "wmc_auto.h" /*-----------------------------------------------------------------------* @@ -50,7 +47,7 @@ void init_coder_ace_plus(Encoder_State_fx *st, const Word16 shift) /* Narrowband? */ st->narrowBand = 0; move16(); - if( sub(st->bwidth_fx, NB) == 0 ) + if( EQ_16(st->bwidth_fx, NB)) { st->narrowBand = 1; move16(); @@ -69,7 +66,7 @@ void init_coder_ace_plus(Encoder_State_fx *st, const Word16 shift) move16(); L_subfr = shr(st->L_frame_fx, 2); test(); - IF ( sub(st->L_frame_fx, L_FRAME16k) == 0 && L_sub(st->total_brate_fx, 32000) <= 0 ) + IF ( EQ_16(st->L_frame_fx, L_FRAME16k)&&LE_32(st->total_brate_fx,32000)) { st->nb_subfr = NB_SUBFR16k; move16(); @@ -109,7 +106,7 @@ void init_coder_ace_plus(Encoder_State_fx *st, const Word16 shift) st->lpcQuantization = 0; move16(); test(); - if( L_sub(st->sr_core,16000) <= 0 && st->tcxonly == 0 ) + if( LE_32(st->sr_core,16000)&&st->tcxonly==0) { st->lpcQuantization = 1; move16(); @@ -120,7 +117,7 @@ void init_coder_ace_plus(Encoder_State_fx *st, const Word16 shift) move16(); test(); test(); - IF ( sub(st->last_L_frame_fx,st->L_frame_fx) != 0 || sub(st->last_core_fx,AMR_WB_CORE) == 0 || sub(st->last_core_fx,HQ_CORE) == 0 ) + IF ( NE_16(st->last_L_frame_fx,st->L_frame_fx)||EQ_16(st->last_core_fx,AMR_WB_CORE)||EQ_16(st->last_core_fx,HQ_CORE)) { set16_fx( st->mem_MA_fx, 0, M ); Copy(GEWB_Ave_fx, st->mem_AR_fx, M); @@ -163,7 +160,7 @@ void init_coder_ace_plus(Encoder_State_fx *st, const Word16 shift) move16(); test(); test(); - if( sub(st->bwidth_fx, SWB) == 0 && (L_sub(st->total_brate_fx, ACELP_16k40) == 0 || L_sub(st->total_brate_fx, ACELP_24k40) == 0) ) + if( EQ_16(st->bwidth_fx, SWB)&&(EQ_32(st->total_brate_fx,ACELP_16k40)||EQ_32(st->total_brate_fx,ACELP_24k40))) { st->tec_tfa = 1; move16(); @@ -186,8 +183,8 @@ void init_coder_ace_plus(Encoder_State_fx *st, const Word16 shift) test(); test(); test(); - if( (L_sub(st->total_brate_fx, ACELP_9k60)==0)||( L_sub(st->total_brate_fx, ACELP_16k40)==0)|| - (L_sub(st->total_brate_fx, ACELP_24k40)==0)||(L_sub(st->total_brate_fx, ACELP_32k)==0)) + if( (EQ_32(st->total_brate_fx, ACELP_9k60))||(EQ_32(st->total_brate_fx,ACELP_16k40))|| + (EQ_32(st->total_brate_fx, ACELP_24k40))||(EQ_32(st->total_brate_fx, ACELP_32k))) { st->glr = 1; move16(); @@ -222,7 +219,7 @@ void init_coder_ace_plus(Encoder_State_fx *st, const Word16 shift) st->enablePlcWaveadjust = 0; move16(); - if (L_sub(st->total_brate_fx, 48000) >= 0) + if (GE_32(st->total_brate_fx, 48000)) { st->enablePlcWaveadjust = 1; move16(); @@ -347,14 +344,14 @@ static void init_tcx( Encoder_State_fx *st, Word16 L_frame_old ) st->tcxltp_norm_corr_past = 0; move16(); } - ELSE IF ( sub(st->L_frame_fx,L_frame_old) != 0 && !((st->total_brate_fx==16400||st->total_brate_fx==24400)&&(st->total_brate_fx==st->last_total_brate_fx)&&(st->last_bwidth_fx==st->bwidth_fx)) ) + ELSE IF ( NE_16(st->L_frame_fx,L_frame_old)&&!((st->total_brate_fx==16400||st->total_brate_fx==24400)&&(st->total_brate_fx==st->last_total_brate_fx)&&(st->last_bwidth_fx==st->bwidth_fx))) { Word16 pitres, pitres_old; Word16 pit, pit_old; pitres_old = 4; move16(); - if (sub(160,shr(L_frame_old,sub(7,norm_s(L_frame_old)))) == 0) /*if ( L_frame_old%160==0 )*/ + if (EQ_16(160,shr(L_frame_old,sub(7,norm_s(L_frame_old))))) /*if ( L_frame_old%160==0 )*/ { pitres_old = 6; move16(); @@ -365,7 +362,7 @@ static void init_tcx( Encoder_State_fx *st, Word16 L_frame_old ) pitres = 4; move16(); - if (sub(160,shr(st->L_frame_fx,sub(7,norm_s(st->L_frame_fx)))) == 0) /*if ( st->L_frame_fx%160==0 )*/ + if (EQ_16(160,shr(st->L_frame_fx,sub(7,norm_s(st->L_frame_fx))))) /*if ( st->L_frame_fx%160==0 )*/ { pitres = 6; move16(); @@ -424,11 +421,11 @@ void init_sig_buffers( Encoder_State_fx *st, const Word16 L_frame_old, const Wor test(); test(); test(); - IF ( sub(st->L_frame_fx,L_frame_old) != 0 && !((L_sub(st->total_brate_fx,ACELP_16k40)==0||L_sub(st->total_brate_fx,ACELP_24k40)==0)&&(L_sub(st->total_brate_fx,st->last_total_brate_fx)==0)&&(sub(st->last_bwidth_fx,st->bwidth_fx)==0)) ) + IF ( NE_16(st->L_frame_fx,L_frame_old)&&!((EQ_32(st->total_brate_fx,ACELP_16k40)||EQ_32(st->total_brate_fx,ACELP_24k40))&&(EQ_32(st->total_brate_fx,st->last_total_brate_fx))&&(EQ_16(st->last_bwidth_fx,st->bwidth_fx)))) { lerp( st->buf_speech_enc, st->buf_speech_enc, st->L_frame_fx, L_frame_old ); test(); - IF( sub(st->last_core_fx,TCX_20_CORE) != 0 && sub(st->last_core_fx,TCX_10_CORE) != 0 ) /* condition should be checked again */ + IF( NE_16(st->last_core_fx,TCX_20_CORE)&&NE_16(st->last_core_fx,TCX_10_CORE)) /* condition should be checked again */ { Copy( st->buf_speech_enc, st->buf_speech_ltp, st->L_frame_fx ); } @@ -438,12 +435,12 @@ void init_sig_buffers( Encoder_State_fx *st, const Word16 L_frame_old, const Wor /*Resamp buffers needed only for ACELP*/ test(); test(); - IF( sub(st->L_frame_fx,L_FRAME) == 0 && !st->tcxonly ) + IF( EQ_16(st->L_frame_fx,L_FRAME)&&!st->tcxonly) { Copy_Scale_sig( st->old_inp_12k8_fx, st->buf_speech_enc_pe+st->L_frame_fx-L_INP_MEM,L_INP_MEM, sub(st->prev_Q_new, st->prev_Q_old)); } - ELSE IF( sub(st->L_frame_fx,L_FRAME16k) == 0 && !st->tcxonly ) + ELSE IF( EQ_16(st->L_frame_fx,L_FRAME16k)&&!st->tcxonly) { lerp( st->buf_wspeech_enc+st->L_frame_fx + L_SUBFR-L_WSP_MEM, st->buf_wspeech_enc+st->L_frame_fx + L_SUBFR-310, 310, L_WSP_MEM ); Copy( st->old_inp_16k_fx, st->buf_speech_enc_pe+st->L_frame_fx-L_INP_MEM,L_INP_MEM); @@ -456,13 +453,13 @@ void init_sig_buffers( Encoder_State_fx *st, const Word16 L_frame_old, const Wor move16(); } /*coming from TCXonly modes*/ - ELSE IF( !st->tcxonly && L_sub(st->last_total_brate_fx,ACELP_32k)>=0) + ELSE IF( !st->tcxonly && GE_32(st->last_total_brate_fx,ACELP_32k)) { Copy_Scale_sig( st->old_wsp_fx, st->buf_wspeech_enc+st->L_frame_fx + L_SUBFR-L_WSP_MEM,L_WSP_MEM, sub(st->prev_Q_new, st->prev_Q_old)); /*Resamp buffers needed only for ACELP*/ - IF( sub(st->L_frame_fx,L_FRAME16k) == 0) + IF( EQ_16(st->L_frame_fx,L_FRAME16k)) { lerp( st->buf_wspeech_enc+st->L_frame_fx + L_SUBFR-L_WSP_MEM, st->buf_wspeech_enc+st->L_frame_fx + L_SUBFR-310, 310, L_WSP_MEM ); } @@ -487,7 +484,7 @@ void init_sig_buffers( Encoder_State_fx *st, const Word16 L_frame_old, const Wor test(); test(); - IF( st->ini_frame_fx == 0 || sub(st->L_frame_fx,L_frame_old) != 0 || sub(st->last_codec_mode,MODE1) == 0 ) + IF( st->ini_frame_fx == 0 || NE_16(st->L_frame_fx,L_frame_old)||EQ_16(st->last_codec_mode,MODE1)) { set16_fx(st->buf_synth, 0, OLD_SYNTH_SIZE_ENC+L_FRAME32k); } @@ -505,11 +502,11 @@ static void init_core_sig_ana( Encoder_State_fx *st ) /* Pre-emphasis factor and memory */ st->preemph_fac = PREEMPH_FAC_SWB; /*SWB*/ move16(); - IF ( sub(st->fscale, (16000*FSCALE_DENOM)/12800) < 0 ) + IF ( LT_16(st->fscale, (16000*FSCALE_DENOM)/12800)) { st->preemph_fac = PREEMPH_FAC; /*WB*/ move16(); } - ELSE IF ( sub(st->fscale, (24000*FSCALE_DENOM)/12800) < 0 ) + ELSE IF ( LT_16(st->fscale, (24000*FSCALE_DENOM)/12800)) { st->preemph_fac = PREEMPH_FAC_16k; /*WB*/ move16(); } @@ -521,7 +518,7 @@ static void init_core_sig_ana( Encoder_State_fx *st ) move16(); st->inv_gamma = GAMMA1_INV; move16(); - IF ( L_sub(st->sr_core, 16000) == 0 ) + IF ( EQ_32(st->sr_core, 16000)) { st->gamma = GAMMA16k; move16(); @@ -568,7 +565,7 @@ static void init_acelp( Encoder_State_fx *st, Word16 L_frame_old , const Word16 } ELSE /*Rate switching*/ { - IF( sub(st->last_core_fx,ACELP_CORE) == 0 ) + IF( EQ_16(st->last_core_fx,ACELP_CORE)) { lerp( st->LPDmem.Txnq,st->LPDmem.Txnq, shr(st->L_frame_fx,1), shr(L_frame_old,1) ); } @@ -579,7 +576,7 @@ static void init_acelp( Encoder_State_fx *st, Word16 L_frame_old , const Word16 st->LPDmem.acelp_zir = st->LPDmem.Txnq + shr(st->L_frame_fx,1); /* Rate switching */ - IF( sub(st->last_codec_mode,MODE1) == 0 ) + IF( EQ_16(st->last_codec_mode,MODE1)) { Copy( st->mem_syn1_fx, st->LPDmem.mem_syn2, M ); set16_fx( st->LPDmem.Txnq, 0, L_FRAME32k/2+64); @@ -587,7 +584,7 @@ static void init_acelp( Encoder_State_fx *st, Word16 L_frame_old , const Word16 } /*AMR-WBIO->MODE2*/ - IF( sub(st->last_core_fx,AMR_WB_CORE) == 0 ) + IF( EQ_16(st->last_core_fx,AMR_WB_CORE)) { st->next_force_safety_net_fx=1; move16(); @@ -596,7 +593,7 @@ static void init_acelp( Encoder_State_fx *st, Word16 L_frame_old , const Word16 } /*HQ-CORE->MODE2*/ test(); - IF( sub(st->last_codec_mode,MODE1)==0 && sub(st->last_core_fx,HQ_CORE) == 0 ) + IF( EQ_16(st->last_codec_mode,MODE1)&&EQ_16(st->last_core_fx,HQ_CORE)) { /*Reset of ACELP memories*/ st->next_force_safety_net_fx=1; @@ -614,10 +611,10 @@ static void init_acelp( Encoder_State_fx *st, Word16 L_frame_old , const Word16 /* unquantized LPC*/ test(); - IF ( !((L_sub(st->total_brate_fx,ACELP_16k40)==0||L_sub(st->total_brate_fx,ACELP_24k40)==0)&&(L_sub(st->total_brate_fx,st->last_total_brate_fx)==0)&&(sub(st->last_bwidth_fx,st->bwidth_fx)==0)) ) + IF ( !((EQ_32(st->total_brate_fx,ACELP_16k40)||EQ_32(st->total_brate_fx,ACELP_24k40))&&(EQ_32(st->total_brate_fx,st->last_total_brate_fx))&&(EQ_16(st->last_bwidth_fx,st->bwidth_fx)))) { Copy( st->lsp_old1_fx, st->lspold_enc_fx, M ); /*lsp old @12.8kHz*/ - IF( sub(st->L_frame_fx,L_FRAME16k) == 0 ) + IF( EQ_16(st->L_frame_fx,L_FRAME16k)) { lsp_convert_poly_fx( st->lspold_enc_fx, st->L_frame_fx, 0 ); } @@ -643,7 +640,7 @@ static void init_acelp( Encoder_State_fx *st, Word16 L_frame_old , const Word16 { test(); test(); - IF( (sub(st->L_frame_fx,L_frame_old) != 0) && (sub(st->L_frame_fx,L_FRAME16k) <= 0) && (sub(L_frame_old,L_FRAME16k) <= 0) ) + IF( (NE_16(st->L_frame_fx,L_frame_old))&&(LE_16(st->L_frame_fx,L_FRAME16k))&&(LE_16(L_frame_old,L_FRAME16k))) { /* convert quantized LSP vector */ st->rate_switching_reset=lsp_convert_poly_fx( st->lsp_old_fx, st->L_frame_fx, 0 ); @@ -655,7 +652,7 @@ static void init_acelp( Encoder_State_fx *st, Word16 L_frame_old , const Word16 { E_LPC_lsp_lsf_conversion( st->lsp_old_fx, st->lsf_old_fx, M ); } - IF( sub(st->L_frame_fx,L_FRAME16k)==0 ) + IF( EQ_16(st->L_frame_fx,L_FRAME16k)) { Copy( st->lsp_old_fx, st->lspold_enc_fx, M ); } @@ -683,7 +680,7 @@ static void init_acelp( Encoder_State_fx *st, Word16 L_frame_old , const Word16 st->LPDmem.mem_w0 = sub(shr(st->wspeech_enc[-1],shift), tmp); } } - ELSE IF((sub(st->L_frame_fx,L_frame_old) != 0)) + ELSE IF((NE_16(st->L_frame_fx,L_frame_old))) { /*Partial reset of ACELP memories*/ st->next_force_safety_net_fx=1; @@ -713,7 +710,7 @@ static void init_acelp( Encoder_State_fx *st, Word16 L_frame_old , const Word16 /* unquantized LPC*/ Copy( st->lsp_old1_fx, st->lspold_enc_fx, M ); /*lsp old @12.8kHz*/ - IF( sub(st->L_frame_fx,L_FRAME16k)==0 ) + IF( EQ_16(st->L_frame_fx,L_FRAME16k)) { lsp_convert_poly_fx( st->lspold_enc_fx, st->L_frame_fx, 0 ); } @@ -727,7 +724,7 @@ static void init_acelp( Encoder_State_fx *st, Word16 L_frame_old , const Word16 E_LPC_lsp_lsf_conversion( st->lsp_old_fx, st->lsf_old_fx, M ); } } - ELSE IF( !st->tcxonly && sub(st->L_frame_fx,L_FRAME16k) == 0 && L_sub(st->last_total_brate_fx,ACELP_32k) > 0 ) + ELSE IF( !st->tcxonly && EQ_16(st->L_frame_fx,L_FRAME16k)&>_32(st->last_total_brate_fx,ACELP_32k)) { lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, st->sr_core ); } @@ -736,7 +733,7 @@ static void init_acelp( Encoder_State_fx *st, Word16 L_frame_old , const Word16 test(); test(); - if(sub(st->last_bwidth_fx,NB)==0 && sub(st->bwidth_fx,NB)!=0 && st->ini_frame_fx!=0) + if(EQ_16(st->last_bwidth_fx,NB)&&NE_16(st->bwidth_fx,NB)&&st->ini_frame_fx!=0) { st->rate_switching_reset=1; move16(); @@ -755,7 +752,7 @@ static void init_acelp( Encoder_State_fx *st, Word16 L_frame_old , const Word16 move16(); /*Use for 12.8 kHz sampling rate and low bitrates, the conventional pulse search->better SNR*/ - if ((L_sub(st->total_brate_fx, ACELP_9k60) <= 0 || st->rf_mode != 0) && (L_sub(st->sr_core,12800) == 0)) + if ((LE_32(st->total_brate_fx, ACELP_9k60)||st->rf_mode!=0)&&(EQ_32(st->sr_core,12800))) { st->acelp_autocorr = 0; move16(); @@ -763,7 +760,7 @@ static void init_acelp( Encoder_State_fx *st, Word16 L_frame_old , const Word16 /*BPF parameters for adjusting gain in function of background noise*/ - IF( sub(st->codec_mode,MODE2) == 0 ) + IF( EQ_16(st->codec_mode,MODE2)) { st->mem_bpf.lp_error_ener = L_deposit_l(0); if( st->last_codec_mode == MODE1 ) @@ -794,17 +791,17 @@ static void init_modes( Encoder_State_fx *st ) move16(); st->tcx10Enabled = 0; - if (sub(s_and(st->restrictedMode,1),1) == 0) + if (EQ_16(s_and(st->restrictedMode,1),1)) { st->acelpEnabled = 1; move16(); } - if (sub(s_and(st->restrictedMode,2),2) == 0) + if (EQ_16(s_and(st->restrictedMode,2),2)) { st->tcx20Enabled = 1; move16(); } - if (sub(s_and(st->restrictedMode,4),4) == 0) + if (EQ_16(s_and(st->restrictedMode,4),4)) { st->tcx10Enabled = 1; move16(); @@ -839,7 +836,7 @@ static void init_modes( Encoder_State_fx *st ) { FOR (n=0; nbits_frame_nominal) == 0) + IF (EQ_16(FrameSizeConfig[n].frame_bits,st->bits_frame_nominal)) { move16(); move16(); diff --git a/lib_enc/core_enc_ol.c b/lib_enc/core_enc_ol.c index 8ea9cc8bc07eb981385a09cfb8b2289ccd8091a3..d7684cb9af00ce289a9a56020eb0db2a454b4fb3 100644 --- a/lib_enc/core_enc_ol.c +++ b/lib_enc/core_enc_ol.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -10,10 +10,8 @@ #include "options.h" #include "cnst_fx.h" #include "stl.h" -#include "wmc_auto.h" - +#include "stl.h" #include "rom_com_fx.h" -#include "wmc_auto.h" @@ -159,7 +157,7 @@ void core_encode_openloop( st->acelp_cfg.midLpc = st->acelp_cfg.midLpc_enable; move16(); test(); - if ( (sub(st->lpcQuantization, 1) == 0) && (sub(coder_type, VOICED) == 0)) + if ( (EQ_16(st->lpcQuantization, 1))&&(EQ_16(coder_type,VOICED))) { st->acelp_cfg.midLpc = 0; move16(); @@ -176,7 +174,7 @@ void core_encode_openloop( move16(); } - IF(sub(st->core_fx,TCX_20_CORE)==0) + IF(EQ_16(st->core_fx,TCX_20_CORE)) { lpc_quantization( st, st->core_fx, st->lpcQuantization, st->lsf_old_fx, lsp_new, lsp_mid, lsp_q, lsf_q, lspmid_q, lspq_ind, st->clip_var_fx, st-> mem_MA_fx, st->mem_AR_fx, @@ -226,7 +224,7 @@ void core_encode_openloop( /* Calculate target bits */ target_bits = sub(sub(st->bits_frame_core, nbits_lpc), st->nb_bits_header_ace); - if(sub(st->rf_mode,1) == 0) + if(EQ_16(st->rf_mode,1)) { /* joint bit allocation for redundant frame and TBE */ /* calculate target bits for core coding */ @@ -249,7 +247,7 @@ void core_encode_openloop( } /* reset TBE buffers previous frame frame wasn't ACELP*/ - IF( sub( st->last_core_fx, ACELP_CORE ) != 0 ) + IF( NE_16( st->last_core_fx, ACELP_CORE )) { TBEreset_enc_fx( st, st->bwidth_fx ); } @@ -285,7 +283,7 @@ void core_encode_openloop( updateSpecPowDiffuseIdx(st); - if(sub(st->last_stab_fac, 655/*0.02f Q15*/) > 0) + if(GT_16(st->last_stab_fac, 655/*0.02f Q15*/)) { move16(); st->glr_idx[0] = 0; @@ -311,11 +309,11 @@ void core_encode_openloop( * Run TCX20 *---------------------------------------------------------------*/ - IF ( sub(st->core_fx, TCX_20_CORE) == 0 ) + IF ( EQ_16(st->core_fx, TCX_20_CORE)) { IF (st->enableTcxLpc) { - IF( sub(st->rf_mode,1)==0) + IF( EQ_16(st->rf_mode,1)) { Copy(st->mem_MA_fx, rf_mem_MA, M); } @@ -363,19 +361,19 @@ void core_encode_openloop( /* Calculate target bits */ target_bits = sub(sub(st->bits_frame_core, nbits_lpc), st->nb_bits_header_tcx); - if(sub(st->rf_mode,1) == 0) + if(EQ_16(st->rf_mode,1)) { /* joint bit allocation for redundant frame and TBE */ /* calculate target bits for core coding */ target_bits = sub(target_bits, st->rf_target_bits_write); } - IF (sub(st->mdct_sw, MODE1) == 0) + IF (EQ_16(st->mdct_sw, MODE1)) { /* Account for core mode signaling bits difference: bandwidth and ACELP/TCX signaling bit are replaced */ target_bits = add(target_bits, sub(add(FrameSizeConfig[st->frame_size_index].bandwidth_bits, 1), signalling_mode1_tcx20_enc(st, 0))); } - ELSE if ( sub(st->mdct_sw_enable, MODE2) == 0 ) + ELSE if ( EQ_16(st->mdct_sw_enable, MODE2)) { target_bits = sub(target_bits, 1); } @@ -388,7 +386,7 @@ void core_encode_openloop( /* subtract bits for TCX overlap mode (1 bit: full, 2 bits: half or no overlap) */ target_bits = sub(target_bits,1); test(); - if (sub(st->tcx_cfg.tcx_curr_overlap_mode, HALF_OVERLAP) == 0 || sub(st->tcx_cfg.tcx_curr_overlap_mode, MIN_OVERLAP) == 0) + if (EQ_16(st->tcx_cfg.tcx_curr_overlap_mode, HALF_OVERLAP)||EQ_16(st->tcx_cfg.tcx_curr_overlap_mode,MIN_OVERLAP)) { target_bits = sub(target_bits,1); } @@ -470,7 +468,7 @@ void core_encode_openloop( IF( st->Opt_DTX_ON_fx != 0 && vad_hover_flag != 0 ) { st->burst_ho_cnt_fx = add(st->burst_ho_cnt_fx,1); - if( sub(st->burst_ho_cnt_fx,HO_HIST_SIZE) > 0 ) + if( GT_16(st->burst_ho_cnt_fx,HO_HIST_SIZE)) { st->burst_ho_cnt_fx = HO_HIST_SIZE; move16(); @@ -478,7 +476,7 @@ void core_encode_openloop( } ELSE { - IF(st->Opt_DTX_ON_fx != 0 && vad_flag_dtx != 0) + IF( st->Opt_DTX_ON_fx != 0 && vad_flag_dtx != 0 ) { st->burst_ho_cnt_fx = 0; move16(); @@ -488,7 +486,7 @@ void core_encode_openloop( IF( st->Opt_DTX_ON_fx != 0 ) { /* update CNG parameters in active frames */ - IF ( sub(st->bwidth_fx,NB) == 0 && st->enableTcxLpc && st->core_fx != ACELP_CORE ) + IF ( EQ_16(st->bwidth_fx,NB)&&st->enableTcxLpc&&st->core_fx!=ACELP_CORE) { Word16 buf[L_LP], res[L_FRAME], A[M+1], r_l[M+1], r_h[M+1], lsptmp[M], Q_r; assert(st->L_frame_fx==L_FRAME); @@ -515,7 +513,7 @@ void core_encode_openloop( st->last_active_brate_fx ); } - IF( sub(st->L_frame_fx,L_FRAME) == 0 ) + IF( EQ_16(st->L_frame_fx,L_FRAME)) { /* store LSPs@16k, potentially to be used in CNG@16k */ Copy( st->lsp_old16k_fx, &(st->ho_lsp_circ2_fx[(st->ho_circ_ptr_fx)*M]), M ); @@ -524,14 +522,14 @@ void core_encode_openloop( /* Set 16k LSP flag for CNG buffer */ st->ho_16k_lsp_fx[st->ho_circ_ptr_fx] = 1; move16(); - if ( sub(st->L_frame_fx,L_FRAME) == 0 ) + if ( EQ_16(st->L_frame_fx,L_FRAME)) { st->ho_16k_lsp_fx[st->ho_circ_ptr_fx] = 0; move16(); } /* efficient DTX hangover control */ - IF ( sub(st->burst_ho_cnt_fx, 1) > 0 ) + IF ( GT_16(st->burst_ho_cnt_fx, 1)) { dtx_hangover_control_fx( st, lsp_new ); } @@ -542,7 +540,7 @@ void core_encode_openloop( *---------------------------------------------------------------*/ test(); - IF (sub(st->core_fx, ACELP_CORE)>0 || (st->rate_switching_reset!=0)) + IF (GT_16(st->core_fx, ACELP_CORE)||(st->rate_switching_reset!=0)) { /*TCX mode: copy values*/ set16_fx(st->mem_bpf.noise_buf, 0, 2*L_FILT16k); /*TCX->no gain*/ @@ -572,10 +570,10 @@ void core_encode_openloop( enc_prm( coder_type, param_core, param_lpc, st, st->L_frame_fx, &hm_cfg, bits_param_lpc, no_param_lpc ); /* Channel-aware mode - encode partial copy */ - IF( sub(st->rf_mode,1)==0) + IF( EQ_16(st->rf_mode,1)) { set16_fx(lsf_q_1st_rf, 0, M); - IF (sub(st->core_fx, ACELP_CORE) == 0) + IF (EQ_16(st->core_fx, ACELP_CORE)) { /* convert LSPs to LP coefficients */ lsp2lsf_fx( lsp_new, lsf_uq_rf, M, st->sr_core ); @@ -625,7 +623,7 @@ void core_encode_openloop( st->rf_indx_lsf[0][2] = param_lpc[3]; } - IF (sub(st->core_fx, ACELP_CORE) == 0) + IF (EQ_16(st->core_fx, ACELP_CORE)) { /* current n-th ACELP frame and its corresponding partial copy */ @@ -648,7 +646,7 @@ void core_encode_openloop( st->rf_indx_frametype[0] = st->rf_frame_type; st->rf_targetbits_buff[0] = st->rf_target_bits; - IF( sub(st->rf_frame_type,RF_NO_DATA) != 0 ) + IF( NE_16(st->rf_frame_type,RF_NO_DATA)) { /* coder_acelp_rf does the partial copy encoding based on the rf frame type chosen for the RF encoding */ coder_acelp_rf(&(st->acelp_cfg_rf), coder_type, Aw, Aq_rf, st->speech_enc_pe, voicing, pitch, @@ -667,12 +665,12 @@ void core_encode_openloop( test(); test(); - IF( (st->rf_gain_tcx[1] != 0) && (sub(st->rf_gain_tcx[0], tmp) > 0) && (sub(st->tcxltp_gain, 6554/*0.2 Q15*/) <= 0) ) + IF( (st->rf_gain_tcx[1] != 0) && (GT_16(st->rf_gain_tcx[0], tmp))&&(LE_16(st->tcxltp_gain,6554/*0.2 Q15*/))) { st->rf_gain_tcx[0] = tmp; move16(); - if( sub(tmp, 127) > 0) + if( GT_16(tmp, 127)) { st->rf_gain_tcx[0] = 127; move16(); @@ -691,11 +689,11 @@ void core_encode_openloop( test(); test(); IF( - (sub(st->core_fx, TCX_20_CORE) == 0)/*(st->core == TCX_20_CORE)*/ - && (sub(st->last_core_fx,TCX_20_CORE) == 0)/*&&(st->last_core == TCX_20_CORE)*/ - && (sub(st->rf_second_last_core, TCX_20_CORE) == 0)/*&& (st->rf_second_last_core == TCX_20_CORE)*/ - && ( (sub(st->tcxltp_pitch_int, shr(st->L_frame_fx, 1)) <= 0) || ( sub(st->tcxltp_gain, 13107/*0.4f Q15*/) <= 0) )/*&& ((st->tcxltp_pitch_int <= 0.5f*st->L_frame) || ( st->tcxltp_gain <= 0.4f))*/ - && (sub(st->tcxltp_pitch_int, st->rf_tcxltp_pitch_int_past) == 0)/*&& (st->tcxltp_pitch_int == st->rf_tcxltp_pitch_int_past)*/ + (EQ_16(st->core_fx, TCX_20_CORE) )/*(st->core == TCX_20_CORE)*/ + && (EQ_16(st->last_core_fx,TCX_20_CORE) )/*&&(st->last_core == TCX_20_CORE)*/ + && (EQ_16(st->rf_second_last_core, TCX_20_CORE) )/*&& (st->rf_second_last_core == TCX_20_CORE)*/ + && ( (LE_16(st->tcxltp_pitch_int, shr(st->L_frame_fx, 1)) ) || ( LE_16(st->tcxltp_gain, 13107/*0.4f Q15*/) ) )/*&& ((st->tcxltp_pitch_int <= 0.5f*st->L_frame) || ( st->tcxltp_gain <= 0.4f))*/ + && (EQ_16(st->tcxltp_pitch_int, st->rf_tcxltp_pitch_int_past) )/*&& (st->tcxltp_pitch_int == st->rf_tcxltp_pitch_int_past)*/ && (st->rf_last_tns_active == 0)/*!st->rf_last_tns_active*/ && (st->rf_second_last_tns_active == 0)/*!st->rf_second_last_tns_active*/ && ( (st->tcx_cfg.fIsTNSAllowed & st->fUseTns[0]) == 0)/*!(st->tcx_cfg.fIsTNSAllowed & st->fUseTns[0])*/ @@ -709,8 +707,8 @@ void core_encode_openloop( test(); test(); test(); - IF ( ((sub(st->clas_fx, UNVOICED_TRANSITION) <= 0) || (sub(st->last_clas_fx, UNVOICED_TRANSITION) <= 0) || (sub(st->tcxltp_gain, 13107/*0.4f Q15*/) <= 0)) - && sub(st->last_core_fx, -1) != 0 ) + IF ( ((LE_16(st->clas_fx, UNVOICED_TRANSITION))||(LE_16(st->last_clas_fx,UNVOICED_TRANSITION))||(LE_16(st->tcxltp_gain,13107/*0.4f Q15*/))) + && NE_16(st->last_core_fx, -1) ) { rf_PLC_Mode = st->last_core_fx; move16(); @@ -723,8 +721,8 @@ void core_encode_openloop( test(); test(); IF( rf_PLC_Mode == 0 && st->rf_gain_tcx[1] != 0 && - ( (st->transientDetection.transientDetector.bIsAttackPresent != 0 && sub(st->rf_gain_tcx[0], mult_r(st->rf_gain_tcx[1], 31785/*0.97f Q15*/)) < 0) || - sub(st->rf_gain_tcx[0], mult_r(st->rf_gain_tcx[1], 29491/*0.90f Q15*/)) < 0 ) + ( (st->transientDetection.transientDetector.bIsAttackPresent != 0 && LT_16(st->rf_gain_tcx[0], mult_r(st->rf_gain_tcx[1], 31785/*0.97f Q15*/)) ) || + LT_16(st->rf_gain_tcx[0], mult_r(st->rf_gain_tcx[1], 29491/*0.90f Q15*/)) ) ) { TD_mode = 0; @@ -782,8 +780,8 @@ void closest_centroid_rf( { Word16 i,j; Word16 tmp, tmpL; - Word32 werr, best_werr; - Word32 L_tmp; + Word64 werr_64; + Word32 L_tmp, best_werr, werr; ind_vec[0] = 0; @@ -793,20 +791,23 @@ void closest_centroid_rf( FOR( i = 0; i < centroids; i++ ) { - werr = L_deposit_l(0); + werr_64 = 0; + move64(); + tmpL = i_mult2(i, length); FOR( j = 0; j < length; j++ ) { tmp = sub( data[j], quantizer[tmpL + j] ); L_tmp = L_mult( tmp, tmp ); - werr = Madd_32_16( werr, L_tmp, weights[j] ); - } - - IF( werr < best_werr ) + werr_64 = W_mac_32_16( werr_64, L_tmp, weights[j] ); + } + werr = W_sat_m( werr_64); + if( LT_32( werr, best_werr) ) { ind_vec[0] = i; - best_werr = werr; + move16(); } + best_werr = L_min( best_werr, werr ); } return; @@ -858,14 +859,14 @@ void core_acelp_tcx20_switching( tmp16 = pitch[i]; move16(); /* check minimum pitch for quantization */ - if (sub(tmp16, PIT_MIN_SHORTER) < 0) + if (LT_16(tmp16, PIT_MIN_SHORTER)) { tmp16 = shl(tmp16, 1); } /* convert pitch values to 16kHz domain */ s = mult_r(tmp16, 8192/*0.25f Q15*/); - if (sub(st->L_frame_fx, L_FRAME16k) == 0) + if (EQ_16(st->L_frame_fx, L_FRAME16k)) { /*pitch[i] = (short)(pitch[i] * 1.25f + 0.5f);*/ tmp16 = add(tmp16, s); @@ -914,7 +915,7 @@ void core_acelp_tcx20_switching( ); /* Force TCX when TCX20 in MODE1 is selected */ - IF ( sub(st->mdct_sw, MODE1) == 0 ) + IF ( EQ_16(st->mdct_sw, MODE1)) { st->core_fx = TCX_20_CORE; move16(); @@ -932,7 +933,7 @@ void core_acelp_tcx20_switching( target = L_add(0x14C315C, 0); /* 1000.f * log2(10)/10 (15Q16) */ test(); - if (L_sub(st->sr_core, 16000) == 0 || L_sub(st->sr_core, 12800) == 0) + if (EQ_32(st->sr_core, 16000)||EQ_32(st->sr_core,12800)) { target = L_add(0x11A5D28, 0); /* 850.f * log2(10)/10 (15Q16) */ } @@ -953,7 +954,7 @@ void core_acelp_tcx20_switching( Copy(st->speech_ltp + sub(tcx_offset, shr(overlap, 1)), xn_buf, add(L_frame, overlap)); tmp16 = shr(overlap, 1); - IF (sub(st->last_core_fx,ACELP_CORE)==0) + IF (EQ_16(st->last_core_fx,ACELP_CORE)) { IF (tcx_offset < 0) { @@ -1066,33 +1067,33 @@ void core_acelp_tcx20_switching( { tmp32 = L_sub(en[i], offset); - if (L_sub(tmp32, 0xFF20) > 0) /* 0xFF20 -> 3.f * log2(10)/10 */ + if (GT_32(tmp32, 0xFF20)) /* 0xFF20 -> 3.f * log2(10)/10 */ { ener = L_add(ener, tmp32); } tmp32 = L_sub(en[i+1], offset); - if (L_sub(tmp32, 0xFF20) > 0) /* 0xFF20 -> 3.f * log2(10)/10 */ + if (GT_32(tmp32, 0xFF20)) /* 0xFF20 -> 3.f * log2(10)/10 */ { ener = L_add(ener, tmp32); } tmp32 = L_sub(en[i+2], offset); - if (L_sub(tmp32, 0xFF20) > 0) /* 0xFF20 -> 3.f * log2(10)/10 */ + if (GT_32(tmp32, 0xFF20)) /* 0xFF20 -> 3.f * log2(10)/10 */ { ener = L_add(ener, tmp32); } tmp32 = L_sub(en[i+3], offset); - if (L_sub(tmp32, 0xFF20) > 0) /* 0xFF20 -> 3.f * log2(10)/10 */ + if (GT_32(tmp32, 0xFF20)) /* 0xFF20 -> 3.f * log2(10)/10 */ { ener = L_add(ener, tmp32); } - IF (L_sub(ener, target) > 0) + IF (GT_32(ener, target)) { offset = L_add(offset, fac); BREAK; @@ -1100,7 +1101,7 @@ void core_acelp_tcx20_switching( } } - if (L_sub(offset, 0xAA153) <= 0) /* 0xAA153 -> 32.f * log2(10)/10 */ + if (LE_32(offset, 0xAA153)) /* 0xAA153 -> 32.f * log2(10)/10 */ { offset = L_add(0xFFD57AB5, 0); /* 0xFFD57AB5 -> -128.f * log2(10)/10; */ } @@ -1126,9 +1127,10 @@ void core_acelp_tcx20_switching( } tmp32 = L_shr(BASOP_Util_Log2(tmp32), 9); /* 15Q16 */ tmp32 = L_add(tmp32, L_sub( 0x1F0000, L_shl( L_deposit_h( add( Q_new, sub( shift, 1 ) ) ), 1 ) ) ); /* wspeech_enc scaling */ - if (L_sub(tmp32, 0xFFEC1185) < 0) + if (LT_32(tmp32, (Word32)0xFFEC1185)) { - tmp32 = L_add(0, 0xFFEC1185); /* 0xFFEC1185 -> log2(1e-6) in 15Q16 */ + tmp32 = 0xFFEC1185; /* 0xFFEC1185 -> log2(1e-6) in 15Q16 */ + move32(); } tcx_snr = L_add(tcx_snr, tmp32); @@ -1138,9 +1140,9 @@ void core_acelp_tcx20_switching( tcx_snr = L_sub(tcx_snr, L_deposit_h(add(ener_e, 15))); tcx_snr = L_shl(Mpy_32_16_1(tcx_snr, 0x6054), 2); /* 0x6054 -> 10/log2(10) (2Q13) */ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF snr_tcx = round_fx(L_shl(tcx_snr, 8)); /* 7Q8 */ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON /*--------------------------------------------------------------* * Estimate ACELP SNR @@ -1157,7 +1159,7 @@ void core_acelp_tcx20_switching( move16(); FOR (i = 0; i < st->L_frame_fx; i += L_SUBFR) { - IF ( L_sub( st->sr_core, 16000 ) == 0 ) + IF ( EQ_32( st->sr_core, 16000 )) { T0 = shr(add( add(pitch_fr[mult_r(i2,26214/*(float)L_FRAME/(float)L_FRAME16k Q15*/)], shr(pitch_fr[mult_r(i2,26214/*(float)L_FRAME/(float)L_FRAME16k Q15*/)], 2)) , (1 << 5) ), 6); } @@ -1185,23 +1187,27 @@ void core_acelp_tcx20_switching( i2 = add(i2, 1); } - if(sub(st->L_frame_fx,L_FRAME16k) == 0) + if(EQ_16(st->L_frame_fx,L_FRAME16k)) { tmp32 = Mpy_32_16_1(tmp32,26214/*(float)L_FRAME/(float)L_FRAME16k Q15*/); } - offset = L_add(0, -211332072l/*-12.5963731051575616 Q24*/); /* 10*log10(0.055f) */ - if (L_sub(st->sr_core, 16000) == 0) + offset = -211332072l/*-12.5963731051575616 Q24*/; /* 10*log10(0.055f) */ + move32(); + if (EQ_32(st->sr_core, 16000)) { - offset = L_add(0, -173847554l/*-10.362121726544446 Q24*/); /* 10*log10(0.092f) */ + offset = -173847554l/*-10.362121726544446 Q24*/; /* 10*log10(0.092f) */ + move32(); } - if (L_sub(st->sr_core, 12800) == 0) + if (EQ_32(st->sr_core, 12800)) { - offset = L_add(0, -206216813l/*-12.291479883578557 Q24*/); /* 10*log10(0.059f) */ + offset = -206216813l/*-12.291479883578557 Q24*/; /* 10*log10(0.059f) */ + move32(); } if (st->narrowBand != 0) { - offset = L_add(0, -138228949l/*-8.2390874094431865 Q24*/); /* 10*log10(0.15f) */ + offset = -138228949l/*-8.2390874094431865 Q24*/; /* 10*log10(0.15f) */ + move32(); } tmp32 = L_sub(tmp32, offset); @@ -1224,10 +1230,10 @@ void core_acelp_tcx20_switching( test(); test(); test(); - if ((sub(snr_acelp, snr_tcx) > 0) && - (sub(snr_acelp, add(snr_tcx, 512/*2.0f Q8*/)) < 0) && - (sub(add(st->prevTempFlatness_fx, currFlatness), 416/*3.25f Q7*/) < 0 || sub(stab_fac, 0x7fff) == 0 || (L_sub(st->sr_core, 12800) == 0 && sub(sp_aud_decision0,1)==0 && sub(add(st->prevTempFlatness_fx, currFlatness), 2560/*20.f Q7*/) < 0)) && - (sub(st->acelpFramesCount, 6) <= 0)) + if ((GT_16(snr_acelp, snr_tcx))&& + (LT_16(snr_acelp, add(snr_tcx, 512/*2.0f Q8*/)) ) && + (LT_16(add(st->prevTempFlatness_fx, currFlatness), 416/*3.25f Q7*/) || EQ_16(stab_fac, 0x7fff) || (EQ_32(st->sr_core, 12800) && EQ_16(sp_aud_decision0,1) && LT_16(add(st->prevTempFlatness_fx, currFlatness), 2560/*20.f Q7*/) )) && + (LE_16(st->acelpFramesCount, 6) )) { dsnr = -512/*-2.0f Q8*/; move16(); @@ -1237,10 +1243,10 @@ void core_acelp_tcx20_switching( test(); test(); test(); - if ((sub(snr_acelp, snr_tcx) < 0) && - (sub(snr_acelp, sub(snr_tcx, 512/*2.0f Q8*/)) > 0) && - (sub(add(st->prevTempFlatness_fx, currFlatness), 416/*3.25f Q7*/) > 0) && - (sub(st->acelpFramesCount, 6) >= 0)) + if ((LT_16(snr_acelp, snr_tcx))&& + (GT_16(snr_acelp, sub(snr_tcx, 512/*2.0f Q8*/)) ) && + (GT_16(add(st->prevTempFlatness_fx, currFlatness), 416/*3.25f Q7*/) ) && + (GE_16(st->acelpFramesCount, 6) )) { dsnr = 512/*2.0f Q8*/; move16(); @@ -1263,7 +1269,7 @@ void core_acelp_tcx20_switching( test(); test(); test(); - if( L_sub(st->sr_core, 12800) == 0 && (offset_tcx < 0x18950F) && sub(non_staX, 1280 /*5.0f Q8*/ ) > 0 && (snr_acelp >= snr_tcx - 1024 /*4.0f in Q8*/) && sub(st->acelpFramesCount,1) >= 0 && ( (sub(st->lps_fx, st->lpm_fx) > 0 && sub(tmp16, 9830) >= 0) || (sub(st->acelpFramesCount,6) >= 0 && (st->lps_fx > st->lpm_fx - 768))) && (sp_aud_decision0 == 0) && vad_flag != 0 ) + if( EQ_32(st->sr_core, 12800)&&(offset_tcx<0x18950F)&>_16(non_staX,1280 /*5.0f Q8*/ )&&(snr_acelp>=snr_tcx-1024 /*4.0f in Q8*/)&&GE_16(st->acelpFramesCount,1)&&((GT_16(st->lps_fx,st->lpm_fx)&&GE_16(tmp16,9830))||(GE_16(st->acelpFramesCount,6)&&(st->lps_fx>st->lpm_fx-768)))&&(sp_aud_decision0==0)&&vad_flag!=0) { /* Fine tuned across various databases based on various metrics to detect TCX frames in speech.*/ dsnr = 1024; @@ -1289,11 +1295,11 @@ void core_acelp_tcx20_switching( test(); test(); test(); - if (L_sub(st->sr_core, 12800) == 0 && (sub(non_staX,512/*2.0f Q8*/) < 0 || (st->flag_noisy_speech_snr==0&&sub(vad_flag, 1) == 0&&(offset_tcx==L_add(0xFFD57AB5, 0))&&sub(st->acelpFramesCount,6) >= 0)) && (st->last_core_fx==ACELP_CORE||st->last_core_fx==TCX_20_CORE)) + if (EQ_32(st->sr_core, 12800)&&(LT_16(non_staX,512/*2.0f Q8*/)||(st->flag_noisy_speech_snr==0&&EQ_16(vad_flag,1)&&(offset_tcx==L_add(0xFFD57AB5,0))&&GE_16(st->acelpFramesCount,6)))&&(st->last_core_fx==ACELP_CORE||st->last_core_fx==TCX_20_CORE)) { st->core_fx = st->last_core_fx; } - ELSE IF ( sub(add(snr_acelp, dsnr), snr_tcx) > 0 ) + ELSE IF ( GT_16(add(snr_acelp, dsnr), snr_tcx)) { st->core_fx = ACELP_CORE; move16(); @@ -1363,7 +1369,7 @@ void BITS_ALLOC_ACELP_config_rf(const Word16 coder_type, mean_tc = 0; move16(); /*mean_tc = mean_fx(tilt_code, nb_subfr);*/ - IF( sub(nb_subfr, 4) == 0 ) + IF( EQ_16(nb_subfr, 4)) { /* subframe 4 case */ L_tmp = L_mult(tilt_code[0], 8192); @@ -1397,18 +1403,18 @@ void BITS_ALLOC_ACELP_config_rf(const Word16 coder_type, dpit2 = abs_s( sub(pitch_buf[2], pitch_buf[1])); dpit3 = abs_s( sub(pitch_buf[3], pitch_buf[2])); - IF ( sub( rf_fec_indicator, 1 ) == 0 ) + IF ( EQ_16( rf_fec_indicator, 1 )) { test(); test(); test(); test(); - IF ( sub( max_tilt_code, 15729/*0.48f Q15*/ ) > 0 && sub( dpit1, 0 ) <= 0 && sub( dpit2, 0 ) <= 0 && sub( dpit3, 0 ) <= 0 && sub(coder_type, VOICED ) == 0 ) + IF ( GT_16( max_tilt_code, 15729/*0.48f Q15*/ )&&LE_16(dpit1,0)&&LE_16(dpit2,0)&&LE_16(dpit3,0)&&EQ_16(coder_type,VOICED)) { en_partial_red = 0; move16(); } - ELSE IF ( sub( max_tilt_code, 15401/*0.47f Q15*/ ) > 0 && sub( dpit1, 64 ) <= 0 && sub( dpit2, 64 ) <= 0 && sub( dpit3, 64 ) <= 0 && sub(coder_type, GENERIC ) == 0 ) + ELSE IF ( GT_16( max_tilt_code, 15401/*0.47f Q15*/ )&&LE_16(dpit1,64)&&LE_16(dpit2,64)&&LE_16(dpit3,64)&&EQ_16(coder_type,GENERIC)) { en_partial_red = 0; move16(); @@ -1420,12 +1426,12 @@ void BITS_ALLOC_ACELP_config_rf(const Word16 coder_type, test(); test(); test(); - IF ( sub( max_tilt_code, 15401/*0.47f Q15*/ )> 0 && sub( dpit1, 16 ) <= 0 && sub( dpit2, 16 ) <= 0 && sub( dpit3, 16 ) <= 0 && sub(coder_type, VOICED ) == 0 ) + IF ( GT_16( max_tilt_code, 15401/*0.47f Q15*/ )&&LE_16(dpit1,16)&&LE_16(dpit2,16)&&LE_16(dpit3,16)&&EQ_16(coder_type,VOICED)) { en_partial_red = 0; move16(); } - ELSE IF ( sub( max_tilt_code, 14746/*0.45f Q15*/ ) > 0 && sub( dpit1, 80 ) <= 0 && sub( dpit2, 80 ) <= 0 && sub( dpit3, 80 ) <= 0 && sub(coder_type, GENERIC ) == 0 ) + ELSE IF ( GT_16( max_tilt_code, 14746/*0.45f Q15*/ )&&LE_16(dpit1,80)&&LE_16(dpit2,80)&&LE_16(dpit3,80)&&EQ_16(coder_type,GENERIC)) { en_partial_red = 0; move16(); @@ -1452,19 +1458,19 @@ void BITS_ALLOC_ACELP_config_rf(const Word16 coder_type, *rf_frame_type = RF_ALLPRED; test(); - IF( sub(coder_type,INACTIVE) == 0 || en_partial_red == 0) + IF( EQ_16(coder_type,INACTIVE)||en_partial_red==0) { *rf_frame_type = RF_NO_DATA; } - ELSE IF ( sub(coder_type,UNVOICED) == 0 || sub(coder_type,INACTIVE) == 0) + ELSE IF ( EQ_16(coder_type,UNVOICED)||EQ_16(coder_type,INACTIVE)) { *rf_frame_type = RF_NELP; } - ELSE IF( sub(coder_type,GENERIC) == 0 && sub(max_tilt_code, 1638/*0.05f Q15*/) <0 ) + ELSE IF( EQ_16(coder_type,GENERIC)&<_16(max_tilt_code,1638/*0.05f Q15*/)) { *rf_frame_type = RF_NOPRED; } - ELSE IF( sub(coder_type,GENERIC) == 0 && sub(mean_tc,9830/*0.3f Q15*/) < 0) + ELSE IF( EQ_16(coder_type,GENERIC)&<_16(mean_tc,9830/*0.3f Q15*/)) { *rf_frame_type = RF_GENPRED; } @@ -1550,7 +1556,7 @@ void BITS_ALLOC_TCX_config_rf( move16(); test(); - IF( sub(coder_type, INACTIVE) == 0 || sub(last_core, ACELP_CORE) == 0 ) + IF( EQ_16(coder_type, INACTIVE)||EQ_16(last_core,ACELP_CORE)) { *rf_frame_type = RF_NO_DATA; move16(); @@ -1585,7 +1591,7 @@ void BITS_ALLOC_TCX_config_rf( } } - if( sub(*rf_frame_type, RF_TCXFD) == 0 ) + if( EQ_16(*rf_frame_type, RF_TCXFD)) { /* TCXFD: LSF bits 5 + 4 + 4 bits */ /* only embed LSF for FD concealment */ diff --git a/lib_enc/core_enc_reconf.c b/lib_enc/core_enc_reconf.c index 4ede5a081a8fb3ceb229915915efdfbc4f14c3db..5387763022908b34d89c1b4666a741fcaa314ffa 100644 --- a/lib_enc/core_enc_reconf.c +++ b/lib_enc/core_enc_reconf.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -9,11 +9,8 @@ #include "options.h" #include "cnst_fx.h" #include "stl.h" -#include "wmc_auto.h" - #include "rom_com_fx.h" #include "rom_enc_fx.h" -#include "wmc_auto.h" /*-----------------------------------------------------------------* * Funtion core_coder_reconfig * @@ -61,7 +58,7 @@ void core_coder_reconfig(Encoder_State_fx *st) /*Switch off TCX or ACELP?*/ - IF( L_sub(st->sr_core,12800) == 0 ) + IF( EQ_32(st->sr_core,12800)) { st->acelpEnabled = 0; move16(); @@ -106,7 +103,7 @@ void core_coder_reconfig(Encoder_State_fx *st) move16(); test(); - if( (L_sub(st->total_brate_fx, 9600) <= 0) && (L_sub(st->sr_core,12800) == 0) ) + if( (LE_32(st->total_brate_fx, 9600))&&(EQ_32(st->sr_core,12800))) { st->acelp_autocorr = 0; move16(); @@ -120,7 +117,7 @@ void core_coder_reconfig(Encoder_State_fx *st) { bandwidth_mode=0; } - ELSE IF( L_sub(st->sr_core, 16000)<=0 ) + ELSE IF( LE_32(st->sr_core, 16000)) { move16(); bandwidth_mode=1; @@ -135,7 +132,7 @@ void core_coder_reconfig(Encoder_State_fx *st) st->tcx_cfg.na_scale=32767/*1.0f Q15*/; test(); - IF( sub(bandwidth_mode,2)<0 && (st->tcxonly==0)) + IF( LT_16(bandwidth_mode,2)&&(st->tcxonly==0)) { const Word16 scaleTableSize = sizeof (scaleTcxTable) / sizeof (scaleTcxTable[0]); @@ -144,9 +141,9 @@ void core_coder_reconfig(Encoder_State_fx *st) test(); test(); - IF ( sub(bandwidth_mode, scaleTcxTable[i].bwmode) == 0 && - L_sub(st->total_brate_fx, scaleTcxTable[i].bitrateFrom) >= 0 && - L_sub(st->total_brate_fx, scaleTcxTable[i].bitrateTo) < 0 ) + IF ( EQ_16(bandwidth_mode, scaleTcxTable[i].bwmode)&& + GE_32(st->total_brate_fx, scaleTcxTable[i].bitrateFrom) && + LT_32(st->total_brate_fx, scaleTcxTable[i].bitrateTo) ) { if( st->rf_mode ) { @@ -164,13 +161,13 @@ void core_coder_reconfig(Encoder_State_fx *st) move16(); test(); - if ( sub(st->lpcQuantization, 1) == 0 && ( L_sub(st->total_brate_fx, LOWRATE_TCXLPC_MAX_BR) <= 0 || st->rf_mode != 0 ) ) + if ( EQ_16(st->lpcQuantization, 1)&&(LE_32(st->total_brate_fx,LOWRATE_TCXLPC_MAX_BR)||st->rf_mode!=0)) { st->enableTcxLpc = 1; move16(); } - IF ( st->ini_frame_fx == 0 || sub(st->last_codec_mode, MODE1) == 0 ) + IF ( st->ini_frame_fx == 0 || EQ_16(st->last_codec_mode, MODE1)) { st->envWeighted = 0; move16(); @@ -178,8 +175,8 @@ void core_coder_reconfig(Encoder_State_fx *st) test(); test(); - IF( sub(st->bwidth_fx, SWB) ==0 && - (L_sub(st->total_brate_fx, ACELP_16k40) == 0 || L_sub(st->total_brate_fx, ACELP_24k40) == 0) ) + IF( EQ_16(st->bwidth_fx, SWB)&& + (EQ_32(st->total_brate_fx, ACELP_16k40) || EQ_32(st->total_brate_fx, ACELP_24k40)) ) { IF(st->tec_tfa == 0) { @@ -200,7 +197,7 @@ void core_coder_reconfig(Encoder_State_fx *st) st->enablePlcWaveadjust = 0; move16(); - IF (L_sub(st->total_brate_fx, 48000) >= 0) + IF (GE_32(st->total_brate_fx, 48000)) { st->enablePlcWaveadjust = 1; move16(); @@ -212,8 +209,8 @@ void core_coder_reconfig(Encoder_State_fx *st) test(); test(); test(); - if( (L_sub(st->total_brate_fx, 9600)==0)||( L_sub(st->total_brate_fx, 16400)==0)|| - (L_sub(st->total_brate_fx, 24400)==0)) + if( (EQ_32(st->total_brate_fx, 9600))||(EQ_32(st->total_brate_fx,16400))|| + (EQ_32(st->total_brate_fx, 24400))) { move16(); st->glr = 1; @@ -226,7 +223,7 @@ void core_coder_reconfig(Encoder_State_fx *st) } test(); - IF (sub(st->bwidth_fx, NB) == 0 || sub(st->bwidth_fx, WB) == 0) + IF (EQ_16(st->bwidth_fx, NB)||EQ_16(st->bwidth_fx,WB)) { test(); IF (st->rf_mode==0) @@ -258,7 +255,7 @@ void core_coder_reconfig(Encoder_State_fx *st) test(); test(); test(); - IF ( (L_sub(st->total_brate_fx, ACELP_24k40) < 0) && (( L_sub(st->total_brate_fx, st->last_total_brate_fx) > 0) || (sub(st->last_codec_mode, MODE1) == 0) )) + IF ( (LT_32(st->total_brate_fx, ACELP_24k40))&&((GT_32(st->total_brate_fx,st->last_total_brate_fx))||(EQ_16(st->last_codec_mode,MODE1)))) { /* low-freq memQuantZeros must be reset partially if bitrate increased */ FOR (i = 0; i < st->nmStartLine; i++) @@ -267,7 +264,7 @@ void core_coder_reconfig(Encoder_State_fx *st) move16(); } } - ELSE IF ( (L_sub(st->total_brate_fx, ACELP_24k40) >= 0) && (L_sub(st->total_brate_fx, ACELP_32k) <= 0) && (L_sub(st->last_total_brate_fx, ACELP_13k20) >= 0) && (L_sub(st->last_total_brate_fx, ACELP_24k40) < 0) ) + ELSE IF ( (GE_32(st->total_brate_fx, ACELP_24k40))&&(LE_32(st->total_brate_fx,ACELP_32k))&&(GE_32(st->last_total_brate_fx,ACELP_13k20))&&(LT_32(st->last_total_brate_fx,ACELP_24k40))) { FOR (i = 0; i < st->L_frame_fx; i++) /* memQuantZeros won't be updated */ { diff --git a/lib_enc/core_enc_switch.c b/lib_enc/core_enc_switch.c index 6f5a9dc0bf27358c9732594a24cfbe73cc76727f..3caffdca1d5cc2518f4c96efe6ef8d81ee1a6ae9 100644 --- a/lib_enc/core_enc_switch.c +++ b/lib_enc/core_enc_switch.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -12,8 +12,6 @@ #include "rom_com_fx.h" #include "stl.h" -#include "wmc_auto.h" - void core_coder_mode_switch( Encoder_State_fx *st, const Word16 bandwidth_in, const Word32 bitrate, @@ -35,7 +33,7 @@ void core_coder_mode_switch( Encoder_State_fx *st, const Word16 bandwidth_in, switchWB = 0; bSwitchFromAmrwbIO = 0; - if ( sub(st->last_core_fx, AMR_WB_CORE) == 0 ) + if ( EQ_16(st->last_core_fx, AMR_WB_CORE)) { move16(); bSwitchFromAmrwbIO = 1; @@ -46,21 +44,21 @@ void core_coder_mode_switch( Encoder_State_fx *st, const Word16 bandwidth_in, fscale = sr2fscale(sr_core); move16(); - IF ( s_and(s_and(sub(bandwidth,WB)>=0, sub(fscale, (FSCALE_DENOM*16000)/12800)==0), sub(fscale, st->fscale)==0)) + IF ( s_and(s_and((Word16)GE_16(bandwidth,WB),(Word16)EQ_16(fscale,(FSCALE_DENOM*16000)/12800)),(Word16)EQ_16(fscale,st->fscale))) { - IF ( s_or(s_and(L_sub(bitrate, 32000)>0, (st->tcxonly==0)), s_and(L_sub(bitrate, 32000)<=0, st->tcxonly!=0)) ) + IF ( s_or(s_and((Word16)GT_32(bitrate, 32000),(st->tcxonly==0)),s_and((Word16)LE_32(bitrate,32000),st->tcxonly!=0))) { move16(); switchWB = 1; } } - if( sub(st->last_codec_mode,MODE1)==0 ) + if( EQ_16(st->last_codec_mode,MODE1)) { move16(); switchWB = 1; /*force init when coming from MODE1*/ } test(); - if( L_sub(st->last_total_brate_fx,ACELP_32k)>0 && L_sub(st->total_brate_fx,ACELP_32k) <= 0) + if( GT_32(st->last_total_brate_fx,ACELP_32k)&&LE_32(st->total_brate_fx,ACELP_32k)) { move16(); switchWB = 1; /*force init when coming from MODE1*/ @@ -68,7 +66,7 @@ void core_coder_mode_switch( Encoder_State_fx *st, const Word16 bandwidth_in, test(); test(); - IF ( (sub(fscale, st->fscale)==0) && (bSwitchFromAmrwbIO==0) && (switchWB==0) ) + IF ( (EQ_16(fscale, st->fscale))&&(bSwitchFromAmrwbIO==0)&&(switchWB==0)) { st->total_brate_fx = bitrate; move32(); @@ -129,7 +127,7 @@ void core_coder_mode_switch( Encoder_State_fx *st, const Word16 bandwidth_in, st->narrowBand = 0; move16(); - if(sub(st->bwidth_fx, NB) == 0) + if(EQ_16(st->bwidth_fx, NB)) { st->narrowBand = 1; move16(); @@ -152,7 +150,7 @@ void core_coder_mode_switch( Encoder_State_fx *st, const Word16 bandwidth_in, FOR (i=0; ibits_frame_nominal) == 0 ) + IF ( EQ_16(FrameSizeConfig[i].frame_bits, st->bits_frame_nominal)) { move16(); move16(); @@ -181,9 +179,9 @@ void core_coder_mode_switch( Encoder_State_fx *st, const Word16 bandwidth_in, test(); test(); test(); - IF( (sub(st->bwidth_fx, WB) == 0 && sub(st->last_extl_fx, WB_TBE) != 0) || - (sub(st->bwidth_fx, SWB) == 0 && sub(st->last_extl_fx, SWB_TBE) != 0) || - (sub(st->bwidth_fx, FB) == 0 && sub(st->last_extl_fx, FB_TBE) != 0) ) + IF( (EQ_16(st->bwidth_fx, WB)&&NE_16(st->last_extl_fx,WB_TBE))|| + (EQ_16(st->bwidth_fx, SWB) && NE_16(st->last_extl_fx, SWB_TBE) ) || + (EQ_16(st->bwidth_fx, FB) && NE_16(st->last_extl_fx, FB_TBE) ) ) { /* reset TBE buffers as previous frame wasn't using TBE */ TBEreset_enc_fx( st, st->bwidth_fx ); @@ -215,15 +213,15 @@ void core_coder_mode_switch( Encoder_State_fx *st, const Word16 bandwidth_in, st->enablePlcWaveadjust = 0; move16(); - if (L_sub(bitrate, 48000) >= 0) + if (GE_32(bitrate, 48000)) { st->enablePlcWaveadjust = 1; move16(); } test(); - IF(L_sub(st->last_total_brate_fx, 32000) > 0 - || L_sub(st->last_codec_mode,MODE1)==0 ) + IF(GT_32(st->last_total_brate_fx, 32000) + || EQ_32(st->last_codec_mode,MODE1)) { move16(); st->glr_reset = 1; diff --git a/lib_enc/core_enc_updt.c b/lib_enc/core_enc_updt.c index 7c024ad2a649ff49b06a5923e57ea18cb59f1d9f..e26517b2e60db1f71d4c5e0f8ad3383bda65cb70 100644 --- a/lib_enc/core_enc_updt.c +++ b/lib_enc/core_enc_updt.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -10,8 +10,6 @@ #include "options.h" #include "cnst_fx.h" #include "stl.h" -#include "wmc_auto.h" - void core_encode_update(Encoder_State_fx *st ) @@ -39,7 +37,7 @@ void core_encode_update(Encoder_State_fx *st } - IF ( s_or( s_or(st->core_fx == ACELP_CORE, s_or( L_sub(st->core_brate_fx, SID_2k40) == 0, L_sub(st->core_brate_fx, FRAME_NO_DATA) == 0) ), L_sub(st->core_fx, AMR_WB_CORE) == 0 ) ) + IF ( s_or( s_or(st->core_fx == ACELP_CORE, s_or( (Word16)EQ_32(st->core_brate_fx, SID_2k40),(Word16)EQ_32(st->core_brate_fx,FRAME_NO_DATA))),(Word16)EQ_32(st->core_fx,AMR_WB_CORE))) { Copy(st->buf_speech_enc + st->L_frame_fx, st->buf_speech_ltp + st->L_frame_fx, st->L_frame_fx); } @@ -57,8 +55,8 @@ void core_encode_update(Encoder_State_fx *st test(); test(); test(); - IF( ((L_sub(st->core_brate_fx,SID_2k40) <= 0) && sub(st->cng_type_fx, FD_CNG) == 0) - || (st->tcxonly && sub(st->codec_mode,MODE2)==0) + IF( ((LE_32(st->core_brate_fx,SID_2k40))&&EQ_16(st->cng_type_fx,FD_CNG)) + || (st->tcxonly && EQ_16(st->codec_mode,MODE2)) ) { /* reset LP memories */ @@ -92,7 +90,7 @@ void core_encode_update_cng( Encoder_State_fx *st, /* LPC -> LSP/lsp */ /* LSP/lsp -> LSF/lsf */ E_LPC_a_lsp_conversion( A, lsp, st->lsp_old_fx, M ); - IF(sub(st->L_frame_fx, L_FRAME16k)== 0) + IF(EQ_16(st->L_frame_fx, L_FRAME16k)) { lsp2lsf_fx( lsp, lsf, M, INT_FS_16k_FX ); } @@ -126,7 +124,7 @@ void core_encode_update_cng( Encoder_State_fx *st, Residu3_fx( A, synth, st->LPDmem.old_exc+s_max(L_EXC_MEM-st->L_frame_fx, 0), st->L_frame_fx, 1 ); /* Update LP_CNG memory */ - IF( L_sub(st->core_brate_fx, SID_2k40) == 0 ) + IF( EQ_32(st->core_brate_fx, SID_2k40)) { pt_res = st->LPDmem.old_exc + L_EXC_MEM - st->L_frame_fx; maxv = 0; @@ -137,7 +135,7 @@ void core_encode_update_cng( Encoder_State_fx *st, } scale = norm_s(maxv); L_ener = L_deposit_l(1); - IF( sub(st->L_frame_fx, L_FRAME) == 0) + IF( EQ_16(st->L_frame_fx, L_FRAME)) { FOR (i=0; i<128; i++) { @@ -171,9 +169,9 @@ void core_encode_update_cng( Encoder_State_fx *st, enr = round_fx(L_shl(L_tmp, 8)); /* Q8 (16+8-16) */ /* decrease the energy in case of WB input */ - IF( sub(st->bwidth_fx, NB) != 0 ) + IF( NE_16(st->bwidth_fx, NB)) { - IF( sub(st->bwidth_fx,WB) == 0 ) + IF( EQ_16(st->bwidth_fx,WB)) { IF( st->CNG_mode_fx >= 0 ) { diff --git a/lib_enc/core_switching_enc_fx.c b/lib_enc/core_switching_enc_fx.c index 87254534bd89f00ad9a9afee4cba57a8369f947f..5908c23890e9cc7b6384f7903b9d6341ecf8fcb2 100644 --- a/lib_enc/core_switching_enc_fx.c +++ b/lib_enc/core_switching_enc_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -7,10 +7,7 @@ #include "rom_enc_fx.h" /* Encoder static table prototypes */ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ -#include "stl.h" -#include "wmc_auto.h" - /* required for wmc_tool */ -#include "wmc_auto.h" +#include "stl.h" /* required for wmc_tool */ /*---------------------------------------------------------------------* @@ -31,7 +28,7 @@ void core_switching_pre_enc_fx( Word16 tmp; /* Mode switching */ - IF( sub(st_fx->last_codec_mode,MODE2) == 0 ) + IF( EQ_16(st_fx->last_codec_mode,MODE2)) { st_fx->mem_deemph_fx = st_fx->LPDmem.syn[M]; move16(); @@ -41,7 +38,7 @@ void core_switching_pre_enc_fx( st_fx->igf = 0; move16(); - IF( sub(st_fx->last_core_fx,ACELP_CORE) != 0 ) + IF( NE_16(st_fx->last_core_fx,ACELP_CORE)) { /* reset BWE memories */ set16_fx( st_fx->old_bwe_exc_fx, 0, PIT16k_MAX*2 ); @@ -51,7 +48,7 @@ void core_switching_pre_enc_fx( set16_fx( st_fx->old_syn_12k8_16k_fx, 0, NS2SA(16000, DELAY_FD_BWE_ENC_NS) ); test(); - IF( sub(st_fx->last_core_fx,TCX_20_CORE)==0 || sub(st_fx->last_core_fx,TCX_10_CORE)==0 ) + IF( EQ_16(st_fx->last_core_fx,TCX_20_CORE)||EQ_16(st_fx->last_core_fx,TCX_10_CORE)) { st_fx->last_core_fx = HQ_CORE; move16(); @@ -77,7 +74,7 @@ void core_switching_pre_enc_fx( } test(); - IF( (sub(st_fx->L_frame_fx,L_FRAME16k) == 0) && (sub(st_fx->last_L_frame_fx,L_FRAME) == 0)) + IF( (EQ_16(st_fx->L_frame_fx,L_FRAME16k))&&(EQ_16(st_fx->last_L_frame_fx,L_FRAME))) { Copy( st_fx->lsp_old_fx, st_fx->lsp_old16k_fx, M ); @@ -90,7 +87,7 @@ void core_switching_pre_enc_fx( } test(); - IF( add(st_fx->last_core_fx, 1) == 0 && sub(st_fx->core_fx, HQ_CORE) == 0 ) + IF( EQ_16(st_fx->last_core_fx, -1) && EQ_16(st_fx->core_fx, HQ_CORE)) { /* very first frame is HQ_CORE */ st_fx->last_core_fx = HQ_CORE; @@ -99,7 +96,7 @@ void core_switching_pre_enc_fx( test(); test(); - IF( sub(st_fx->core_fx, HQ_CORE) == 0 && ( sub(st_fx->last_core_fx, ACELP_CORE) == 0 || sub(st_fx->last_core_fx, AMR_WB_CORE) == 0 ) ) /* HQ init */ + IF( EQ_16(st_fx->core_fx, HQ_CORE)&&(EQ_16(st_fx->last_core_fx,ACELP_CORE)||EQ_16(st_fx->last_core_fx,AMR_WB_CORE))) /* HQ init */ { set32_fx( st_fx->last_ni_gain_fx, 0, BANDS_MAX ); set16_fx( st_fx->last_env_fx, 0, BANDS_MAX ); @@ -124,7 +121,7 @@ void core_switching_pre_enc_fx( within ACELP_CORE if switching from another bitarate to vbr, last_ppp and last_nelp is always updated in the previous frame */ test(); test(); - IF( sub(st_fx->core_fx, ACELP_CORE) == 0 && (sub(st_fx->last_core_fx, ACELP_CORE) != 0 || sub(st_fx->last_codec_mode,MODE2) == 0 )) + IF( EQ_16(st_fx->core_fx, ACELP_CORE)&&(NE_16(st_fx->last_core_fx,ACELP_CORE)||EQ_16(st_fx->last_codec_mode,MODE2))) { st_fx->last_last_ppp_mode_fx = 0; move16(); @@ -137,7 +134,7 @@ void core_switching_pre_enc_fx( test(); test(); test(); - IF( sub(st_fx->core_fx, ACELP_CORE) == 0 && ( sub(st_fx->last_core_fx, ACELP_CORE) != 0 || sub(st_fx->last_codec_mode,MODE2) == 0 || L_sub(st_fx->last_total_brate_fx, PPP_NELP_2k80) <= 0 )) + IF( EQ_16(st_fx->core_fx, ACELP_CORE)&&(NE_16(st_fx->last_core_fx,ACELP_CORE)||EQ_16(st_fx->last_codec_mode,MODE2)||LE_32(st_fx->last_total_brate_fx,PPP_NELP_2k80))) { st_fx->act_count_fx = 3; move16(); @@ -147,9 +144,9 @@ void core_switching_pre_enc_fx( test(); test(); - IF( ( sub(st_fx->core_fx, ACELP_CORE) == 0 || sub(st_fx->core_fx, AMR_WB_CORE) == 0 ) && sub(st_fx->last_core_fx, HQ_CORE) == 0 ) + IF( ( EQ_16(st_fx->core_fx, ACELP_CORE)||EQ_16(st_fx->core_fx,AMR_WB_CORE))&&EQ_16(st_fx->last_core_fx,HQ_CORE)) { - IF(sub(st_fx->L_frame_fx, L_FRAME16k)==0 ) + IF(EQ_16(st_fx->L_frame_fx, L_FRAME16k)) { Copy( TRWB2_Ave_fx, st_fx->lsf_old_fx, M ); /* init of LSP */ lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_16k ); @@ -193,7 +190,7 @@ void core_switching_pre_enc_fx( tmp16 = add(NB_SUBFR,1); move16(); - if( sub(st_fx->L_frame_fx,L_FRAME) == 0 ) + if( EQ_16(st_fx->L_frame_fx,L_FRAME)) { tmp16=NB_SUBFR; move16(); @@ -213,10 +210,10 @@ void core_switching_pre_enc_fx( test(); test(); - IF( L_sub(st_fx->input_Fs_fx, 16000) >= 0 && sub(st_fx->last_extl_fx, WB_BWE) != 0 && sub(st_fx->extl_fx, WB_BWE) == 0 ) + IF( GE_32(st_fx->input_Fs_fx, 16000)&&NE_16(st_fx->last_extl_fx,WB_BWE)&&EQ_16(st_fx->extl_fx,WB_BWE)) { test(); - IF( sub(st_fx->last_extl_fx, SWB_BWE) != 0 && sub(st_fx->last_extl_fx, FB_BWE) != 0 ) + IF( NE_16(st_fx->last_extl_fx, SWB_BWE)&&NE_16(st_fx->last_extl_fx,FB_BWE)) { st_fx->prev_mode_fx = NORMAL; move16(); @@ -233,12 +230,12 @@ void core_switching_pre_enc_fx( test(); test(); test(); - IF( ( L_sub(st_fx->input_Fs_fx, 32000) >= 0 && sub(st_fx->last_extl_fx, SWB_BWE) != 0 && sub(st_fx->extl_fx, SWB_BWE) == 0 ) || - ( L_sub(st_fx->input_Fs_fx, 48000) >= 0 && sub(st_fx->last_extl_fx, FB_BWE) != 0 && sub(st_fx->extl_fx, FB_BWE) == 0 ) ) + IF( ( GE_32(st_fx->input_Fs_fx, 32000)&&NE_16(st_fx->last_extl_fx,SWB_BWE)&&EQ_16(st_fx->extl_fx,SWB_BWE))|| + ( GE_32(st_fx->input_Fs_fx, 48000) && NE_16(st_fx->last_extl_fx, FB_BWE) && EQ_16(st_fx->extl_fx, FB_BWE) ) ) { /* we are switching to SWB BWE - reset SWB BWE buffers */ - IF( sub(st_fx->L_frame_fx, L_FRAME) == 0 ) + IF( EQ_16(st_fx->L_frame_fx, L_FRAME)) { Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS ); Sample_Delay_LP = NS2SA( 12800, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS ); @@ -256,7 +253,7 @@ void core_switching_pre_enc_fx( Copy( &st_fx->old_speech_shb_fx[tmp], st_fx->new_input_hp_fx, Sample_Delay_HP ); add(0,0); - IF (sub(st_fx->last_extl_fx,WB_BWE) != 0) + IF (NE_16(st_fx->last_extl_fx,WB_BWE)) { st_fx->prev_mode_fx = NORMAL; move16(); @@ -297,13 +294,13 @@ void core_switching_post_enc_fx( Copy( pitch, T_op, 3 ); - IF( sub(st_fx->core_fx, HQ_CORE) == 0 ) + IF( EQ_16(st_fx->core_fx, HQ_CORE)) { st_fx->use_acelp_preq = 0; move16(); test(); - IF( ( sub(st_fx->last_core_fx, ACELP_CORE) == 0 || sub(st_fx->last_core_fx, AMR_WB_CORE) == 0) ) /* core switching ==> CELP subframe encoding */ + IF( ( EQ_16(st_fx->last_core_fx, ACELP_CORE)||EQ_16(st_fx->last_core_fx,AMR_WB_CORE))) /* core switching ==> CELP subframe encoding */ { acelp_core_switch_enc_fx( st_fx, &(st_fx->LPDmem),old_inp_12k8 + L_INP_MEM - NS2SA_fx2(INT_FS_FX, ACELP_LOOK_NS), old_inp_16k + L_INP_MEM - NS2SA_fx2(INT_FS_16k, ACELP_LOOK_NS), T_op, voicing, A, Qshift, Q_new ); @@ -320,11 +317,11 @@ void core_switching_post_enc_fx( /* reset SWB TBE buffers */ test(); - IF( sub(st_fx->extl_fx, WB_TBE) == 0 && sub(st_fx->last_extl_fx, WB_TBE) != 0 ) + IF( EQ_16(st_fx->extl_fx, WB_TBE)&&NE_16(st_fx->last_extl_fx,WB_TBE)) { wb_tbe_extras_reset_fx( st_fx->mem_genSHBexc_filt_down_wb2_fx, st_fx->mem_genSHBexc_filt_down_wb3_fx ); - IF ( sub(st_fx->last_extl_fx, WB_BWE) != 0 ) + IF ( NE_16(st_fx->last_extl_fx, WB_BWE)) { set16_fx( st_fx->decim_state1_fx, 0, 2*ALLPASSSECTIONS_STEEP+1 ); set16_fx( st_fx->decim_state2_fx, 0, 2*ALLPASSSECTIONS_STEEP+1 ); @@ -346,9 +343,9 @@ void core_switching_post_enc_fx( test(); test(); test(); - IF( (sub(st_fx->extl_fx, SWB_TBE) == 0 || sub(st_fx->extl_fx, FB_TBE) == 0) && - ( sub(st_fx->last_core_fx,HQ_CORE) == 0 || sub(st_fx->L_frame_fx, st_fx->last_L_frame_fx) != 0 || - ( sub(st_fx->last_extl_fx, SWB_TBE) != 0 && sub(st_fx->last_extl_fx, FB_TBE) != 0 ) ) + IF( (EQ_16(st_fx->extl_fx, SWB_TBE)||EQ_16(st_fx->extl_fx,FB_TBE))&& + ( EQ_16(st_fx->last_core_fx,HQ_CORE) || NE_16(st_fx->L_frame_fx, st_fx->last_L_frame_fx) || + ( NE_16(st_fx->last_extl_fx, SWB_TBE) && NE_16(st_fx->last_extl_fx, FB_TBE) ) ) ) { set16_fx( st_fx->state_ana_filt_shb_fx, 0, (2*ALLPASSSECTIONS_STEEP+1) ); @@ -361,9 +358,9 @@ void core_switching_post_enc_fx( set16_fx( st_fx->dec_2_over_3_mem_fx,0, 12 ); set16_fx( st_fx->dec_2_over_3_mem_lp_fx,0, 6 ); } - ELSE IF( ( sub(st_fx->extl_fx, SWB_TBE) == 0 || sub(st_fx->extl_fx, FB_TBE) == 0 ) && - ( L_sub(st_fx->last_total_brate_fx, st_fx->total_brate_fx) != 0 || sub(st_fx->last_bwidth_fx, st_fx->bwidth_fx) != 0 || - sub(st_fx->last_codec_mode, MODE1) != 0 || sub(st_fx->rf_mode, st_fx->rf_mode_last) != 0 ) ) + ELSE IF( ( EQ_16(st_fx->extl_fx, SWB_TBE)||EQ_16(st_fx->extl_fx,FB_TBE))&& + ( NE_32(st_fx->last_total_brate_fx, st_fx->total_brate_fx) || NE_16(st_fx->last_bwidth_fx, st_fx->bwidth_fx) || + NE_16(st_fx->last_codec_mode, MODE1) || NE_16(st_fx->rf_mode, st_fx->rf_mode_last) ) ) { set16_fx( st_fx->state_lpc_syn_fx, 0, LPC_SHB_ORDER ); set16_fx( st_fx->state_syn_shbexc_fx, 0, L_SHB_LAHEAD ); @@ -375,7 +372,7 @@ void core_switching_post_enc_fx( test(); test(); - IF( sub(st_fx->extl_fx, FB_TBE) == 0 && ( sub(st_fx->last_extl_fx, FB_TBE) != 0 || sub(st_fx->L_frame_fx, st_fx->last_L_frame_fx) != 0 ) ) + IF( EQ_16(st_fx->extl_fx, FB_TBE)&&(NE_16(st_fx->last_extl_fx,FB_TBE)||NE_16(st_fx->L_frame_fx,st_fx->last_L_frame_fx))) { set16_fx( st_fx->fb_state_lpc_syn_fx, 0, LPC_SHB_ORDER ); st_fx->fb_tbe_demph_fx = 0; @@ -433,9 +430,9 @@ void core_switching_hq_prepare_enc_fx( } /* set switching frame bit-rate */ - IF( sub(st_fx->last_L_frame_fx, L_FRAME) == 0 ) + IF( EQ_16(st_fx->last_L_frame_fx, L_FRAME)) { - IF( L_sub(st_fx->core_brate_fx, ACELP_24k40) > 0 ) + IF( GT_32(st_fx->core_brate_fx, ACELP_24k40)) { cbrate = L_add(ACELP_24k40, 0); } @@ -445,7 +442,7 @@ void core_switching_hq_prepare_enc_fx( } /* subtract ACELP switching frame bits */ - IF( L_sub(st_fx->core_brate_fx, ACELP_11k60) >= 0 ) + IF( GE_32(st_fx->core_brate_fx, ACELP_11k60)) { (*num_bits) = sub((*num_bits), 1); /* LP_FLAG bit */ } @@ -455,11 +452,11 @@ void core_switching_hq_prepare_enc_fx( } ELSE /* L_frame == L_FRAME16k */ { - IF( L_sub(st_fx->core_brate_fx, ACELP_8k00) <= 0 ) + IF( LE_32(st_fx->core_brate_fx, ACELP_8k00)) { cbrate = L_add(ACELP_8k00, 0); } - ELSE IF( L_sub(st_fx->core_brate_fx, ACELP_14k80) <= 0 ) + ELSE IF( LE_32(st_fx->core_brate_fx, ACELP_14k80)) { cbrate = L_add(ACELP_14k80, 0); } @@ -469,7 +466,7 @@ void core_switching_hq_prepare_enc_fx( } /* subtract ACELP switching frame bits */ - IF( L_sub(st_fx->core_brate_fx, ACELP_11k60) >= 0 ) + IF( GE_32(st_fx->core_brate_fx, ACELP_11k60)) { (*num_bits) = sub((*num_bits), 1); /* LP_FLAG bit */ } @@ -481,7 +478,7 @@ void core_switching_hq_prepare_enc_fx( /* subtract BWE bits */ test(); test(); - IF( !( ( sub(inner_frame_tbl[st_fx->bwidth_fx], L_FRAME16k) == 0 && sub(st_fx->last_L_frame_fx, L_FRAME16k) == 0 ) || sub(inner_frame_tbl[st_fx->bwidth_fx], L_FRAME8k) == 0 ) ) + IF( !( ( EQ_16(inner_frame_tbl[st_fx->bwidth_fx], L_FRAME16k)&&EQ_16(st_fx->last_L_frame_fx,L_FRAME16k))||EQ_16(inner_frame_tbl[st_fx->bwidth_fx],L_FRAME8k))) { *num_bits = sub((*num_bits), (NOOFGAINBITS1 + AUDIODELAYBITS)); } diff --git a/lib_enc/corr_xh_fx.c b/lib_enc/corr_xh_fx.c index 641276d2fe2894701fa80892182490d3bbed73f2..664507cfda064e65ec00fdaefa7290da4aac6d17 100644 --- a/lib_enc/corr_xh_fx.c +++ b/lib_enc/corr_xh_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" #include "prot_fx.h" #include "cnst_fx.h" #include "stl.h" -#include "wmc_auto.h" - #define NB_TRACK 4 diff --git a/lib_enc/decision_matrix_enc_fx.c b/lib_enc/decision_matrix_enc_fx.c index 074402fb75f12ca16263e5e51204561eae0bf563..fe1d1dcb3f2465cf71d547b408ed1caa7155aac6 100644 --- a/lib_enc/decision_matrix_enc_fx.c +++ b/lib_enc/decision_matrix_enc_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -9,8 +9,6 @@ #include "stat_enc_fx.h" #include "rom_com_fx.h" #include "stl.h" -#include "wmc_auto.h" - /*-----------------------------------------------------------------* @@ -101,13 +99,13 @@ void decision_matrix_enc_fx( /* SID and FRAME_NO_DATA frames */ test(); test(); - IF( st_fx->Opt_DTX_ON_fx && (L_sub(st_fx->core_brate_fx,SID_2k40) == 0 || L_sub(st_fx->core_brate_fx,FRAME_NO_DATA) == 0 ) ) + IF( st_fx->Opt_DTX_ON_fx && (EQ_32(st_fx->core_brate_fx,SID_2k40)||EQ_32(st_fx->core_brate_fx,FRAME_NO_DATA))) { st_fx->core_fx = ACELP_CORE; move16(); test(); - if( L_sub(st_fx->input_Fs_fx,32000) >= 0 && sub(st_fx->bwidth_fx,SWB) >= 0 ) + if( GE_32(st_fx->input_Fs_fx,32000)&&GE_16(st_fx->bwidth_fx,SWB)) { st_fx->extl_fx = SWB_CNG; move16(); @@ -135,13 +133,13 @@ void decision_matrix_enc_fx( test(); test(); test(); - IF ( sub(st_fx->ppp_mode_fx,1) == 0 ) + IF ( EQ_16(st_fx->ppp_mode_fx,1)) { /* PPP mode */ st_fx->core_brate_fx = PPP_NELP_2k80; move16(); } - ELSE IF ( ( ( sub(coder_type,UNVOICED) == 0 || sub(coder_type,TRANSITION) == 0 ) && sp_aud_decision1 == 0 ) || sub(st_fx->bwidth_fx, NB) != 0 ) + ELSE IF ( ( ( EQ_16(coder_type,UNVOICED)||EQ_16(coder_type,TRANSITION))&&sp_aud_decision1==0)||NE_16(st_fx->bwidth_fx,NB)) { test(); test(); @@ -154,9 +152,9 @@ void decision_matrix_enc_fx( test(); test(); test(); - IF ( sub(coder_type,UNVOICED) == 0 && sub(vad_flag,1) == 0 && - ( ( sub(st_fx->last_bwidth_fx,SWB) >= 0 && st_fx->last_Opt_SC_VBR_fx == 1 ) || sub(st_fx->last_bwidth_fx, SWB) < 0 ) && - ( sub(st_fx->last_core_fx,HQ_CORE) != 0 || sub(st_fx->bwidth_fx, NB) != 0) ) + IF ( EQ_16(coder_type,UNVOICED)&&EQ_16(vad_flag,1)&& + ( ( GE_16(st_fx->last_bwidth_fx,SWB) && st_fx->last_Opt_SC_VBR_fx == 1 ) || LT_16(st_fx->last_bwidth_fx, SWB) ) && + ( NE_16(st_fx->last_core_fx,HQ_CORE) || NE_16(st_fx->bwidth_fx, NB) ) ) { /* NELP mode */ st_fx->nelp_mode_fx = 1; @@ -164,8 +162,8 @@ void decision_matrix_enc_fx( st_fx->core_brate_fx = PPP_NELP_2k80; move32(); } - ELSE IF ( sub(coder_type,TRANSITION) == 0 || ( sub(coder_type,UNVOICED) == 0 && sub(st_fx->nelp_mode_fx, 1) != 0 ) || - ( ( sub(coder_type,AUDIO) == 0 || sub(coder_type,INACTIVE) == 0 ) && sub(st_fx->bwidth_fx, NB) != 0 ) ) + ELSE IF ( EQ_16(coder_type,TRANSITION)||(EQ_16(coder_type,UNVOICED)&&NE_16(st_fx->nelp_mode_fx,1))|| + ( ( EQ_16(coder_type,AUDIO) || EQ_16(coder_type,INACTIVE) ) && NE_16(st_fx->bwidth_fx, NB) ) ) { /* silence portions */ @@ -183,13 +181,13 @@ void decision_matrix_enc_fx( * NB *---------------------------------------------------------------------*/ - ELSE IF ( sub(st_fx->bwidth_fx,NB) == 0 ) + ELSE IF ( EQ_16(st_fx->bwidth_fx,NB)) { st_fx->core_fx = ACELP_CORE; move16(); test(); - if ( L_sub(st_fx->total_brate_fx,HQCORE_NB_MIN_RATE) >= 0 && sub(sp_aud_decision1,1) == 0 ) + if ( GE_32(st_fx->total_brate_fx,HQCORE_NB_MIN_RATE)&&EQ_16(sp_aud_decision1,1)) { st_fx->core_fx = HQ_CORE; move16(); @@ -200,15 +198,15 @@ void decision_matrix_enc_fx( * WB *---------------------------------------------------------------------*/ - ELSE IF ( sub(st_fx->bwidth_fx,WB) == 0 ) + ELSE IF ( EQ_16(st_fx->bwidth_fx,WB)) { st_fx->core_fx = ACELP_CORE; move16(); test(); test(); - IF ( ( L_sub(st_fx->total_brate_fx,HQCORE_WB_MIN_RATE) >= 0 && sub(sp_aud_decision1,1) == 0 ) || - L_sub(st_fx->total_brate_fx,HQ_96k) >= 0 ) + IF ( ( GE_32(st_fx->total_brate_fx,HQCORE_WB_MIN_RATE)&&EQ_16(sp_aud_decision1,1))|| + GE_32(st_fx->total_brate_fx,HQ_96k) ) { st_fx->core_fx = HQ_CORE; move16(); @@ -219,18 +217,18 @@ void decision_matrix_enc_fx( test(); test(); test(); - IF ( sub(st_fx->bwidth_fx,WB) == 0 && L_sub(st_fx->total_brate_fx,ACELP_9k60) < 0 ) + IF ( EQ_16(st_fx->bwidth_fx,WB)&<_32(st_fx->total_brate_fx,ACELP_9k60)) { st_fx->extl_fx = WB_BWE; move16(); } - ELSE IF ( sub(st_fx->bwidth_fx,WB) == 0 && L_sub(st_fx->total_brate_fx,ACELP_9k60) >= 0 && L_sub(st_fx->total_brate_fx,ACELP_16k40) <= 0 ) + ELSE IF ( EQ_16(st_fx->bwidth_fx,WB)&&GE_32(st_fx->total_brate_fx,ACELP_9k60)&&LE_32(st_fx->total_brate_fx,ACELP_16k40)) { /* Note: WB BWE is used exceptionally at 13.2 kbps if GSC is selected instead of LR-MDCT */ test(); test(); test(); - IF ( sub(sp_aud_decision1,1) == 0 || sub(coder_type,INACTIVE) == 0 || ( sp_aud_decision1 == 0 && sub(sp_aud_decision2,1) == 0) ) + IF ( EQ_16(sp_aud_decision1,1)||EQ_16(coder_type,INACTIVE)||(sp_aud_decision1==0&&EQ_16(sp_aud_decision2,1))) { st_fx->extl_fx = WB_BWE; move16(); @@ -252,12 +250,12 @@ void decision_matrix_enc_fx( * SWB and FB *---------------------------------------------------------------------*/ - ELSE IF ( sub(st_fx->bwidth_fx,SWB) == 0 || sub(st_fx->bwidth_fx,FB) == 0 ) + ELSE IF ( EQ_16(st_fx->bwidth_fx,SWB)||EQ_16(st_fx->bwidth_fx,FB)) { test(); test(); - IF ( ( L_sub(st_fx->total_brate_fx,HQCORE_SWB_MIN_RATE) >= 0 && sub(sp_aud_decision1,1) == 0) || - L_sub(st_fx->total_brate_fx,HQ_96k) >= 0 ) + IF ( ( GE_32(st_fx->total_brate_fx,HQCORE_SWB_MIN_RATE)&&EQ_16(sp_aud_decision1,1))|| + GE_32(st_fx->total_brate_fx,HQ_96k) ) { st_fx->core_fx = HQ_CORE; move16(); @@ -269,7 +267,7 @@ void decision_matrix_enc_fx( test(); test(); - IF ( L_sub(st_fx->total_brate_fx,ACELP_13k20) >= 0 && L_sub(st_fx->total_brate_fx,ACELP_48k) < 0 ) + IF ( GE_32(st_fx->total_brate_fx,ACELP_13k20)&<_32(st_fx->total_brate_fx,ACELP_48k)) { /* Note: SWB BWE is not used in case of GSC noisy speech */ /* Note: SWB BWE is used exceptionally at 13.2 kbps if GSC is selected instead of LR-MDCT */ @@ -277,7 +275,7 @@ void decision_matrix_enc_fx( test(); test(); test(); - IF ( (sub(sp_aud_decision1,1) == 0 || sub(coder_type,INACTIVE) == 0 || ( sp_aud_decision1 == 0 && sub(sp_aud_decision2,1) == 0 )) && st_fx->GSC_noisy_speech_fx == 0 ) + IF ( (EQ_16(sp_aud_decision1,1)||EQ_16(coder_type,INACTIVE)||(sp_aud_decision1==0&&EQ_16(sp_aud_decision2,1)))&&st_fx->GSC_noisy_speech_fx==0) { st_fx->extl_fx = SWB_BWE; move16(); @@ -285,7 +283,7 @@ void decision_matrix_enc_fx( move32(); test(); - IF ( sub(st_fx->bwidth_fx,FB) == 0 && L_sub(st_fx->total_brate_fx,ACELP_24k40) >= 0 ) + IF ( EQ_16(st_fx->bwidth_fx,FB)&&GE_32(st_fx->total_brate_fx,ACELP_24k40)) { st_fx->extl_fx = FB_BWE; move16(); @@ -299,14 +297,14 @@ void decision_matrix_enc_fx( move16(); st_fx->extl_brate_fx = SWB_TBE_1k6; move32(); - if( L_sub(st_fx->total_brate_fx,ACELP_24k40) >= 0 ) + if( GE_32(st_fx->total_brate_fx,ACELP_24k40)) { st_fx->extl_brate_fx = SWB_TBE_2k8; move32(); } test(); - IF ( sub(st_fx->bwidth_fx,FB) == 0 && L_sub(st_fx->total_brate_fx,ACELP_24k40) >= 0 ) + IF ( EQ_16(st_fx->bwidth_fx,FB)&&GE_32(st_fx->total_brate_fx,ACELP_24k40)) { st_fx->extl_fx = FB_TBE; move16(); @@ -317,14 +315,14 @@ void decision_matrix_enc_fx( } } } - ELSE IF ( L_sub(st_fx->total_brate_fx,ACELP_48k) >= 0 ) + ELSE IF ( GE_32(st_fx->total_brate_fx,ACELP_48k)) { st_fx->extl_fx = SWB_BWE_HIGHRATE; move16(); st_fx->extl_brate_fx = SWB_BWE_16k; move32(); - if( sub(st_fx->bwidth_fx,FB) == 0 ) + if( EQ_16(st_fx->bwidth_fx,FB)) { st_fx->extl_fx = FB_BWE_HIGHRATE; move32(); @@ -337,20 +335,20 @@ void decision_matrix_enc_fx( * Set HQ core type *-----------------------------------------------------------------*/ - IF( sub(st_fx->core_fx,HQ_CORE) == 0 ) + IF( EQ_16(st_fx->core_fx,HQ_CORE)) { *hq_core_type = NORMAL_HQ_CORE; move16(); test(); test(); - IF( (sub(st_fx->bwidth_fx,SWB) == 0 || sub(st_fx->bwidth_fx,WB) == 0) && L_sub(st_fx->total_brate_fx,LRMDCT_CROSSOVER_POINT) <= 0 ) + IF( (EQ_16(st_fx->bwidth_fx,SWB)||EQ_16(st_fx->bwidth_fx,WB))&&LE_32(st_fx->total_brate_fx,LRMDCT_CROSSOVER_POINT)) { /* note that FB is always coded with NORMAL_HQ_CORE */ *hq_core_type = LOW_RATE_HQ_CORE; move16(); } - ELSE IF( sub(st_fx->bwidth_fx,NB) == 0 ) + ELSE IF( EQ_16(st_fx->bwidth_fx,NB)) { *hq_core_type = LOW_RATE_HQ_CORE; move16(); @@ -394,12 +392,12 @@ Word16 signalling_mode1_tcx20_enc( move16(); /* Use ACELP signaling for LR MDCT */ - IF ( L_sub(st->total_brate_fx, ACELP_16k40) <= 0 ) + IF ( LE_32(st->total_brate_fx, ACELP_16k40)) { /* find the section in the ACELP signalling table corresponding to bitrate */ idx = 0; move16(); - WHILE ( L_sub(acelp_sig_tbl[idx], st->total_brate_fx) != 0 ) + WHILE ( NE_32(acelp_sig_tbl[idx], st->total_brate_fx)) { idx = add(idx, 1); } @@ -412,7 +410,7 @@ Word16 signalling_mode1_tcx20_enc( idx = add(idx, 1); start_idx = idx; move16(); - WHILE ( L_sub(acelp_sig_tbl[idx], SIG2IND_fx(LR_MDCT, st->bwidth_fx, 0, 0)) != 0 ) + WHILE ( NE_32(acelp_sig_tbl[idx], SIG2IND_fx(LR_MDCT, st->bwidth_fx, 0, 0))) { idx = add(idx, 1); } @@ -432,7 +430,7 @@ Word16 signalling_mode1_tcx20_enc( } ELSE { - IF ( L_sub(st->core_brate_fx, ACELP_64k) <= 0 ) + IF ( LE_32(st->core_brate_fx, ACELP_64k)) { /* write ACELP/HQ core indication flag */ num_bits = add(num_bits, 1); @@ -453,15 +451,15 @@ Word16 signalling_mode1_tcx20_enc( IF (push != 0) { /* write band-width (needed for different I/O sampling rate support) */ - IF ( sub(st->bwidth_fx, NB) == 0 ) + IF ( EQ_16(st->bwidth_fx, NB)) { push_indice_fx( st, IND_HQ_BWIDTH, 0, 2 ); } - ELSE IF ( sub(st->bwidth_fx, WB) == 0 ) + ELSE IF ( EQ_16(st->bwidth_fx, WB)) { push_indice_fx( st, IND_HQ_BWIDTH, 1, 2 ); } - ELSE IF ( sub(st->bwidth_fx, SWB) == 0 ) + ELSE IF ( EQ_16(st->bwidth_fx, SWB)) { push_indice_fx( st, IND_HQ_BWIDTH, 2, 2 ); } @@ -490,7 +488,7 @@ void signalling_enc_fx( Word16 nBits, idx, start_idx; Word32 k; - IF (sub(st_fx->mdct_sw, MODE2) == 0) + IF (EQ_16(st_fx->mdct_sw, MODE2)) { assert(!st_fx->tcxonly); @@ -501,12 +499,12 @@ void signalling_enc_fx( /* write ACELP->HQ core switching flag */ test(); - IF ( sub(st_fx->last_core_fx, ACELP_CORE) == 0 || sub(st_fx->last_core_fx, AMR_WB_CORE) == 0 ) + IF ( EQ_16(st_fx->last_core_fx, ACELP_CORE)||EQ_16(st_fx->last_core_fx,AMR_WB_CORE)) { push_indice_fx( st_fx, IND_HQ_SWITCHING_FLG, 1, 1 ); /* write ACELP L_frame info */ - IF( sub(st_fx->last_L_frame_fx, L_FRAME) == 0 ) + IF( EQ_16(st_fx->last_L_frame_fx, L_FRAME)) { push_indice_fx( st_fx, IND_LAST_L_FRAME, 0, 1 ); } @@ -522,12 +520,12 @@ void signalling_enc_fx( return; } - IF( sub(st_fx->core_fx,ACELP_CORE ) == 0) + IF( EQ_16(st_fx->core_fx,ACELP_CORE )) { test(); test(); - IF( sub(st_fx->ppp_mode_fx,1) == 0 || sub(st_fx->nelp_mode_fx,1) == 0 ) + IF( EQ_16(st_fx->ppp_mode_fx,1)||EQ_16(st_fx->nelp_mode_fx,1)) { /* 1 bit to distinguish between 2.8kbps PPP/NELP frame and SID frame */ @@ -541,34 +539,34 @@ void signalling_enc_fx( test(); test(); test(); - IF ( sub(coder_type,VOICED) == 0 && sub(st_fx->bwidth_fx,NB) == 0 && sub(st_fx->ppp_mode_fx,1) == 0 ) + IF ( EQ_16(coder_type,VOICED)&&EQ_16(st_fx->bwidth_fx,NB)&&EQ_16(st_fx->ppp_mode_fx,1)) { push_indice_fx( st_fx, IND_PPP_NELP_MODE, 0, 2 ); } - ELSE IF ( sub(coder_type,VOICED) == 0 && sub(st_fx->bwidth_fx,NB) != 0 && sub(st_fx->ppp_mode_fx,1) == 0 ) + ELSE IF ( EQ_16(coder_type,VOICED)&&NE_16(st_fx->bwidth_fx,NB)&&EQ_16(st_fx->ppp_mode_fx,1)) { push_indice_fx( st_fx, IND_PPP_NELP_MODE, 1, 2 ); } - ELSE IF ( sub(coder_type,UNVOICED) == 0 && sub(st_fx->bwidth_fx,NB) == 0 && sub(st_fx->nelp_mode_fx,1) == 0 ) + ELSE IF ( EQ_16(coder_type,UNVOICED)&&EQ_16(st_fx->bwidth_fx,NB)&&EQ_16(st_fx->nelp_mode_fx,1)) { push_indice_fx( st_fx, IND_PPP_NELP_MODE, 2, 2); } - ELSE IF ( sub(coder_type,UNVOICED) == 0 && sub(st_fx->bwidth_fx,NB) != 0 && sub(st_fx->nelp_mode_fx,1) == 0 ) + ELSE IF ( EQ_16(coder_type,UNVOICED)&&NE_16(st_fx->bwidth_fx,NB)&&EQ_16(st_fx->nelp_mode_fx,1)) { push_indice_fx( st_fx, IND_PPP_NELP_MODE, 3, 2 ); } } - ELSE IF( L_sub(st_fx->core_brate_fx,SID_2k40) != 0 && L_sub(st_fx->core_brate_fx,FRAME_NO_DATA) != 0 ) + ELSE IF( NE_32(st_fx->core_brate_fx,SID_2k40)&&NE_32(st_fx->core_brate_fx,FRAME_NO_DATA)) { /* write the ACELP/HQ core selection bit */ - IF (L_sub(st_fx->total_brate_fx,ACELP_24k40) >= 0 ) + IF (GE_32(st_fx->total_brate_fx,ACELP_24k40)) { push_indice_fx( st_fx, IND_CORE, 0, 1 ); } /* find the section in the ACELP signalling table corresponding to bitrate */ idx = 0; - WHILE ( L_sub(acelp_sig_tbl[idx],st_fx->total_brate_fx) != 0 ) + WHILE ( NE_32(acelp_sig_tbl[idx],st_fx->total_brate_fx)) { idx++; } @@ -579,7 +577,7 @@ void signalling_enc_fx( /* retrieve the signalling index */ start_idx = ++idx; k = SIG2IND_fx(coder_type, st_fx->bwidth_fx, sharpFlag, st_fx->rf_mode); - WHILE( L_sub(acelp_sig_tbl[idx], k) != 0 ) + WHILE( NE_32(acelp_sig_tbl[idx], k)) { idx++; } @@ -594,11 +592,11 @@ void signalling_enc_fx( test(); test(); test(); - IF( sub(st_fx->extl_fx,WB_TBE) == 0 || sub(st_fx->extl_fx,SWB_TBE) == 0 || sub(st_fx->extl_fx,FB_TBE) == 0 ) + IF( EQ_16(st_fx->extl_fx,WB_TBE)||EQ_16(st_fx->extl_fx,SWB_TBE)||EQ_16(st_fx->extl_fx,FB_TBE)) { push_indice_fx( st_fx, IND_BWE_FLAG, 0, 1 ); } - ELSE IF( sub(st_fx->extl_fx,WB_BWE) == 0 || sub(st_fx->extl_fx,SWB_BWE) == 0 || sub(st_fx->extl_fx,FB_BWE) == 0 ) + ELSE IF( EQ_16(st_fx->extl_fx,WB_BWE)||EQ_16(st_fx->extl_fx,SWB_BWE)||EQ_16(st_fx->extl_fx,FB_BWE)) { push_indice_fx( st_fx, IND_BWE_FLAG, 1, 1 ); } @@ -608,11 +606,11 @@ void signalling_enc_fx( { /* write ACELP->HQ switching frame flag */ test(); - IF( sub(st_fx->last_core_fx,ACELP_CORE) == 0 || sub(st_fx->last_core_fx,AMR_WB_CORE) == 0 ) + IF( EQ_16(st_fx->last_core_fx,ACELP_CORE)||EQ_16(st_fx->last_core_fx,AMR_WB_CORE)) { push_indice_fx( st_fx, IND_HQ_SWITCHING_FLG, 1, 1 ); /* write ACELP L_frame info */ - IF( sub(st_fx->last_L_frame_fx, L_FRAME)==0 ) + IF( EQ_16(st_fx->last_L_frame_fx, L_FRAME)) { push_indice_fx( st_fx, IND_LAST_L_FRAME, 0, 1 ); } @@ -630,11 +628,11 @@ void signalling_enc_fx( push_indice_fx( st_fx, IND_MDCT_CORE, 0, 1 ); /* Use ACELP signaling for LR MDCT */ - IF ( L_sub(st_fx->total_brate_fx,ACELP_16k40) <= 0 ) + IF ( LE_32(st_fx->total_brate_fx,ACELP_16k40)) { /* find the section in the ACELP signalling table corresponding to bitrate */ idx = 0; - WHILE ( L_sub(acelp_sig_tbl[idx],st_fx->total_brate_fx) != 0 ) + WHILE ( NE_32(acelp_sig_tbl[idx],st_fx->total_brate_fx)) { idx++; } @@ -646,7 +644,7 @@ void signalling_enc_fx( start_idx = ++idx; move16(); k = SIG2IND_fx(LR_MDCT, st_fx->bwidth_fx, 0, 0); - WHILE( L_sub(acelp_sig_tbl[idx], k) != 0 ) + WHILE( NE_32(acelp_sig_tbl[idx], k)) { idx++; } @@ -656,22 +654,22 @@ void signalling_enc_fx( ELSE { - IF( L_sub(st_fx->core_brate_fx,ACELP_64k) <= 0 ) + IF( LE_32(st_fx->core_brate_fx,ACELP_64k)) { /* write ACELP/HQ core indication flag */ push_indice_fx( st_fx, IND_CORE, 1, 1 ); } /* write band-width (needed for different I/O sampling rate support) */ - IF( sub(st_fx->bwidth_fx,NB) == 0 ) + IF( EQ_16(st_fx->bwidth_fx,NB)) { push_indice_fx( st_fx, IND_HQ_BWIDTH, 0, 2 ); } - ELSE IF( sub(st_fx->bwidth_fx,WB) == 0 ) + ELSE IF( EQ_16(st_fx->bwidth_fx,WB)) { push_indice_fx( st_fx, IND_HQ_BWIDTH, 1, 2 ); } - ELSE IF( sub(st_fx->bwidth_fx,SWB) == 0 ) + ELSE IF( EQ_16(st_fx->bwidth_fx,SWB)) { push_indice_fx( st_fx, IND_HQ_BWIDTH, 2, 2 ); } @@ -700,7 +698,7 @@ void signalling_enc_rf( /* write partial copy into bitstream */ - IF(sub(st->rf_mode,1) == 0) + IF(EQ_16(st->rf_mode,1)) { enc_prm_rf(st, st->rf_indx_frametype[st->rf_fec_offset], st->rf_fec_offset); st->rf_indx_tbeGainFr[0] = st->rf_bwe_gainFr_ind; diff --git a/lib_enc/detect_transient_fx.c b/lib_enc/detect_transient_fx.c index d211aedcbf3781c04c8ceb41a7d3dab5be471530..ea2a706e5d575120eccd6810621f938a72bbbf1c 100644 --- a/lib_enc/detect_transient_fx.c +++ b/lib_enc/detect_transient_fx.c @@ -1,15 +1,12 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "cnst_fx.h" /* Common constants */ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ -#include "stl.h" -#include "wmc_auto.h" - /* required for wmc_tool */ -#include "wmc_auto.h" +#include "stl.h" /* required for wmc_tool */ /*--------------------------------------------------------------------------*/ /* Function hp_filter */ @@ -96,7 +93,7 @@ Word16 detect_transient_fx( IsTransient = 0; move16(); - IF (sub(st_fx->last_extl_fx, st_fx->extl_fx) != 0) + IF (NE_16(st_fx->last_extl_fx, st_fx->extl_fx)) { st_fx->TransientHangOver_fx = 0; move16(); @@ -113,7 +110,7 @@ Word16 detect_transient_fx( test(); test(); test(); - IF (sub(st_fx->last_extl_fx, st_fx->extl_fx) != 0 || (sub(st_fx->last_extl_fx, st_fx->extl_fx) == 0 && sub(st_fx->last_core_fx, st_fx->core_fx) != 0) || sub(st_fx->last_codec_mode, MODE2) == 0) + IF (NE_16(st_fx->last_extl_fx, st_fx->extl_fx)||(EQ_16(st_fx->last_extl_fx,st_fx->extl_fx)&&NE_16(st_fx->last_core_fx,st_fx->core_fx))||EQ_16(st_fx->last_codec_mode,MODE2)) { /*EnergyLT = EPSILON_FX; */ EnergyLT = L_deposit_l(0); @@ -127,7 +124,7 @@ Word16 detect_transient_fx( { EnergyLT = L_add(st_fx->EnergyLT_fx, 0); /*2Q_new */ } - IF (sub(L, L_FRAME8k) == 0) + IF (EQ_16(L, L_FRAME8k)) { Energy_in_fx[0] = st_fx->Energy_Old_fx; move32(); @@ -150,7 +147,7 @@ Word16 detect_transient_fx( Thres_fx = 2185;/*1 /15 */ move16(); - IF (L_sub(Mult_32_16(Energy_fx, 5461), EnergyLT) > 0) + IF (GT_32(Mult_32_16(Energy_fx, 5461), EnergyLT)) { IsTransient = 1; move16(); @@ -193,12 +190,12 @@ Word16 detect_transient_fx( Energy = L_add(L_shr(L_tmp, shift), L_shr(L_tmp2, shift)); test(); - IF( sub(st_fx->extl_fx,SWB_BWE) == 0 || sub(st_fx->extl_fx,FB_BWE) == 0 ) + IF( EQ_16(st_fx->extl_fx,SWB_BWE)||EQ_16(st_fx->extl_fx,FB_BWE)) { /*Calculate shift to get to Q0*/ test(); test(); - IF((L_sub(Mult_32_16(Energy, shl(2427, shift)), EnergyLT) > 0) || (L_sub(Mult_32_16(Energy, shl(3277, shift)), EnergyLT) > 0 && sub(coder_type,INACTIVE) == 0)) + IF((GT_32(Mult_32_16(Energy, shl(2427, shift)), EnergyLT))||(GT_32(Mult_32_16(Energy,shl(3277,shift)),EnergyLT)&&EQ_16(coder_type,INACTIVE))) { IsTransient = 1; move16(); @@ -209,7 +206,7 @@ Word16 detect_transient_fx( ELSE { test(); - IF( L_sub(st_fx->total_brate_fx,HQ_16k40) <= 0&& sub(st_fx->bwidth_fx,SWB) == 0 ) + IF( LE_32(st_fx->total_brate_fx,HQ_16k40)&&EQ_16(st_fx->bwidth_fx,SWB)) { thr = 2427; move16(); @@ -221,7 +218,7 @@ Word16 detect_transient_fx( } thr = shl(thr, shift); /*if(Energy > L_shr(Mult_32_16(EnergyLT,22624),shift_cnt)) //getting in Q0 32*16 = Q_inp1+Q_inp2+1-16 */ - IF(L_sub(Mult_32_16(Energy, thr),EnergyLT) > 0) + IF(GT_32(Mult_32_16(Energy, thr),EnergyLT)) /*if(Energy > 6.0f * EnergyLT) */ { IsTransient = 1; @@ -243,8 +240,8 @@ Word16 detect_transient_fx( test(); test(); test(); - if( ( sub(st_fx->last_extl_fx,SWB_BWE) != 0 && sub(st_fx->last_extl_fx,SWB_TBE) != 0 && sub(st_fx->extl_fx,SWB_BWE) == 0 ) || - ( sub(st_fx->last_extl_fx,FB_BWE) != 0 && sub(st_fx->last_extl_fx,FB_TBE) != 0 && sub(st_fx->extl_fx,FB_BWE) == 0 ) ) + if( ( NE_16(st_fx->last_extl_fx,SWB_BWE)&&NE_16(st_fx->last_extl_fx,SWB_TBE)&&EQ_16(st_fx->extl_fx,SWB_BWE))|| + ( NE_16(st_fx->last_extl_fx,FB_BWE) && NE_16(st_fx->last_extl_fx,FB_TBE) && EQ_16(st_fx->extl_fx,FB_BWE) ) ) { IsTransient = 0; move16(); @@ -287,16 +284,16 @@ Word16 detect_transient_fx( test(); test(); - IF (L_sub(L_shr(E_high_fx, 1), E_low_fx) < 0 && L_sub(E_high_fx, Mult_32_16(E_low_fx, 22938)) > 0 && L_sub(Mult_32_16(E_in_fx, Thres_fx), E_out_fx) > 0) + IF (LT_32(L_shr(E_high_fx, 1), E_low_fx)&>_32(E_high_fx,Mult_32_16(E_low_fx,22938))&>_32(Mult_32_16(E_in_fx,Thres_fx),E_out_fx)) { IsTransient = 0; move16(); } } - IF ( L_sub(st_fx->core_brate_fx,ACELP_24k40) == 0 ) + IF ( EQ_32(st_fx->core_brate_fx,ACELP_24k40)) { test(); - IF ( sub(st_fx->last_core_fx,HQ_CORE) != 0 || L_sub(st_fx->last_core_brate_fx,ACELP_24k40) != 0 ) + IF ( NE_16(st_fx->last_core_fx,HQ_CORE)||NE_32(st_fx->last_core_brate_fx,ACELP_24k40)) { st_fx->TransientHangOver_fx = 0; move16(); @@ -307,7 +304,7 @@ Word16 detect_transient_fx( { IF ( IsTransient ) { - IF ( sub(position,3) == 0 ) + IF ( EQ_16(position,3)) { /* Set Hangover */ st_fx->TransientHangOver_fx = 1; @@ -345,7 +342,7 @@ Word16 detect_transient_fx( } } - IF (sub(L, L_FRAME8k) == 0) + IF (EQ_16(L, L_FRAME8k)) { st_fx->Energy_Old_fx = Energy_in_fx[4]; move32(); diff --git a/lib_enc/diffcod_fx.c b/lib_enc/diffcod_fx.c index 75d1d222b7c7cda7214c52523b3e60bc03a25c4d..621bbbd4eccf9272a0788c902b3281cbd34ee02f 100644 --- a/lib_enc/diffcod_fx.c +++ b/lib_enc/diffcod_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function Prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*--------------------------------------------------------------------------*/ /* Function diffcod */ @@ -32,7 +30,7 @@ void diffcod_fx( { r = sub(i, 1); k = sub(y[i], y[r]); - if ( sub(k, -15) < 0 ) + if ( LT_16(k, -15)) { y[r] = add(y[i], 15); move16(); @@ -43,7 +41,7 @@ void diffcod_fx( { r = sub(i, 1); k = sub(y[i], y[r]); - IF ( sub(k, 16) > 0 ) + IF ( GT_16(k, 16)) { k = 16; move16(); @@ -95,7 +93,7 @@ void diffcod_lrmdct_fx( difidx[0] = sub(y[0], be_ref); move16(); - IF( sub(difidx[0], thr_h) > 0) + IF( GT_16(difidx[0], thr_h)) { difidx[0] = thr_h; move16(); @@ -103,7 +101,7 @@ void diffcod_lrmdct_fx( move16(); } - IF( sub(difidx[0],thr_l) < 0 ) + IF( LT_16(difidx[0],thr_l)) { difidx[0] = thr_l; move16(); @@ -117,7 +115,7 @@ void diffcod_lrmdct_fx( r = sub(i, 1); k = sub(y[i], y[r]); move16(); - if ( sub(k, thr_l) < 0 ) + if ( LT_16(k, thr_l)) { y[r] = sub(y[i], thr_l); move16(); @@ -128,7 +126,7 @@ void diffcod_lrmdct_fx( { r = sub(i, 1); k = sub(y[i], y[r]); - IF ( sub(k, thr_h) > 0 ) + IF ( GT_16(k, thr_h)) { k = thr_h; move16(); diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c index cf5d36dbf77a3b6f5e8105bbc40c7e07adb6dda9..6eefd98bea01fd1251e18aa502231fd5414b1322 100644 --- a/lib_enc/dtx_fx.c +++ b/lib_enc/dtx_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -7,11 +7,8 @@ #include "prot_fx.h" /* Function prototypes */ #include "rom_com_fx.h" #include "stl.h" -#include "wmc_auto.h" - #include "basop_mpy.h" #include "assert.h" -#include "wmc_auto.h" /*-------------------------------------------------------------------* * Local constants @@ -79,7 +76,7 @@ void dtx_fx( st_fx->cng_type_fx = FD_CNG; move16(); test(); - if( sub( st_fx->codec_mode, MODE1 ) == 0 || st_fx->Opt_AMR_WB_fx ) + if( EQ_16( st_fx->codec_mode, MODE1 )||st_fx->Opt_AMR_WB_fx) { st_fx->cng_type_fx = LP_CNG; move16(); @@ -88,9 +85,9 @@ void dtx_fx( test(); test(); IF( st_fx->Opt_DTX_ON_fx && vad == 0 && - sub(st_fx->ini_frame_fx,2) > 0 && /* CNG coding starts after 2 frames */ + GT_16(st_fx->ini_frame_fx,2) && /* CNG coding starts after 2 frames */ st_fx->fd_cng_reset_flag == 0 && - sub(st_fx->last_core_fx, AMR_WB_CORE) != 0 && + NE_16(st_fx->last_core_fx, AMR_WB_CORE) && st_fx->Opt_AMR_WB_fx == 0 ) { test(); @@ -98,21 +95,20 @@ void dtx_fx( test(); test(); test(); - IF ( L_sub(st_fx->last_core_brate_fx,SID_2k40) > 0 && - L_sub(st_fx->last_total_brate_cng_fx,-1) != 0 && - L_sub(st_fx->last_total_brate_cng_fx,st_fx->total_brate_fx) != 0 && - ( (L_sub(st_fx->last_total_brate_cng_fx, ACELP_24k40) <= 0) || (sub(st_fx->lp_noise_fx, 1280) < 0) ) ) + IF ( GT_32(st_fx->last_core_brate_fx,SID_2k40)&& + NE_32(st_fx->last_total_brate_cng_fx,-1) && + NE_32(st_fx->last_total_brate_cng_fx,st_fx->total_brate_fx) && + ( (LE_32(st_fx->last_total_brate_cng_fx, ACELP_24k40) ) || (LT_16(st_fx->lp_noise_fx, 1280) ) ) ) { st_fx->total_brate_fx = st_fx->last_total_brate_cng_fx; move32(); test(); - if( !(L_sub(st_fx->total_brate_fx,ACELP_7k20) == 0 && st_fx->Opt_SC_VBR_fx) ) + if( !(EQ_32(st_fx->total_brate_fx,ACELP_7k20)&&st_fx->Opt_SC_VBR_fx)) { st_fx->Opt_SC_VBR_fx = 0; move16(); } - - st_fx->rf_mode = st_fx->last_rf_mode_cng; + st_fx->rf_mode = st_fx->last_rf_mode_cng; move16(); st_fx->bwidth_fx = st_fx->last_bwidth_cng_fx; move16(); @@ -124,15 +120,15 @@ void dtx_fx( test(); test(); test(); - IF ( L_sub(st_fx->last_core_brate_fx,SID_2k40) <= 0 && - L_sub(st_fx->last_total_brate_fx,st_fx->total_brate_fx) != 0 && - ( L_sub(st_fx->last_total_brate_fx,ACELP_24k40) <= 0 || sub(st_fx->lp_noise_fx, 1280) < 0) ) + IF ( LE_32(st_fx->last_core_brate_fx,SID_2k40)&& + NE_32(st_fx->last_total_brate_fx,st_fx->total_brate_fx)&& + ( LE_32(st_fx->last_total_brate_fx,ACELP_24k40) || LT_16(st_fx->lp_noise_fx, 1280) ) ) { st_fx->total_brate_fx = st_fx->last_total_brate_fx; move32(); test(); - if( !(L_sub(st_fx->total_brate_fx,ACELP_7k20) == 0 && st_fx->Opt_SC_VBR_fx) ) + if( !(EQ_32(st_fx->total_brate_fx,ACELP_7k20)&&st_fx->Opt_SC_VBR_fx)) { st_fx->Opt_SC_VBR_fx = 0; move16(); @@ -143,7 +139,7 @@ void dtx_fx( test(); test(); test(); - if( st_fx->rf_mode && st_fx->rf_fec_offset > 0 && L_sub(st_fx->total_brate_fx,ACELP_13k20) == 0 && sub(st_fx->bwidth_fx,NB) != 0 ) + if( st_fx->rf_mode && st_fx->rf_fec_offset > 0 && EQ_32(st_fx->total_brate_fx,ACELP_13k20)&&NE_16(st_fx->bwidth_fx,NB)) { st_fx->Opt_RF_ON = 1; move16(); @@ -216,8 +212,8 @@ void dtx_fx( test(); test(); IF( st_fx->Opt_DTX_ON_fx && vad == 0 && - sub(st_fx->ini_frame_fx,2) > 0 && /* CNG coding starts after 2 frames */ - ( L_sub(st_fx->total_brate_fx,ACELP_24k40) <= 0 || sub(st_fx->lp_noise_fx, 1280) < 0) && + GT_16(st_fx->ini_frame_fx,2) && /* CNG coding starts after 2 frames */ + ( LE_32(st_fx->total_brate_fx,ACELP_24k40) || LT_16(st_fx->lp_noise_fx, 1280)) && st_fx->fd_cng_reset_flag == 0 ) { /* reset counter */ @@ -227,14 +223,14 @@ void dtx_fx( IF( st_fx->Opt_AMR_WB_fx ) { st_fx->last_total_brate_cng_fx = -1; + st_fx->last_rf_mode_cng = st_fx->rf_mode; + move16(); } ELSE { st_fx->last_total_brate_cng_fx = st_fx->total_brate_fx; st_fx->last_bwidth_cng_fx = st_fx->bwidth_fx; st_fx->last_codec_mode_cng = st_fx->codec_mode; - st_fx->last_rf_mode_cng = st_fx->rf_mode; - move16(); } IF( st_fx->cnt_SID_fx == 0 ) @@ -260,7 +256,7 @@ void dtx_fx( test(); test(); - IF( L_sub(st_fx->core_brate_fx,FRAME_NO_DATA) == 0 && sub(st_fx->last_core_fx,ACELP_CORE) != 0 && !st_fx->Opt_AMR_WB_fx ) + IF( EQ_32(st_fx->core_brate_fx,FRAME_NO_DATA)&&NE_16(st_fx->last_core_fx,ACELP_CORE)&&!st_fx->Opt_AMR_WB_fx) { /* force SID frame when switching from HQ core or AMR-WB IO mode into inactive frame in ACELP core when DTX is on */ st_fx->core_brate_fx = SID_2k40; @@ -268,11 +264,11 @@ void dtx_fx( } test(); - IF( sub(st_fx->cng_type_fx,FD_CNG) == 0 && L_sub(st_fx->total_brate_fx,ACELP_24k40) <= 0 ) /* at highest bit-rates, use exclusively LP_CNG */ + IF( EQ_16(st_fx->cng_type_fx,FD_CNG)&&LE_32(st_fx->total_brate_fx,ACELP_24k40)) /* at highest bit-rates, use exclusively LP_CNG */ { test(); test(); - IF ( L_sub(st_fx->total_brate_fx,ACELP_9k60) == 0 || L_sub(st_fx->total_brate_fx,ACELP_16k40) == 0 || L_sub(st_fx->total_brate_fx,ACELP_24k40) == 0 ) + IF ( EQ_32(st_fx->total_brate_fx,ACELP_9k60)||EQ_32(st_fx->total_brate_fx,ACELP_16k40)||EQ_32(st_fx->total_brate_fx,ACELP_24k40)) { st_fx->codec_mode = MODE2; move16(); @@ -300,7 +296,7 @@ void dtx_fx( /* NB core bit rate can be "-1" at startup , so one can not use core_brate_fx <=2400 */ test(); test(); - IF ( (L_sub(st_fx->core_brate_fx ,SID_2k40) != 0 ) && (L_sub(st_fx->core_brate_fx, SID_1k75) != 0 ) && (st_fx->core_brate_fx != 0)) + IF ( (NE_32(st_fx->core_brate_fx ,SID_2k40))&&(NE_32(st_fx->core_brate_fx,SID_1k75))&&(st_fx->core_brate_fx!=0)) { st_fx->cnt_SID_fx = 0; move16(); @@ -318,7 +314,7 @@ void dtx_fx( move16(); /* first SID update is only 3 frames after the active speech end */ } - IF ( sub(st_fx->interval_SID_fx,st_fx->max_SID_fx) < 0 ) + IF ( LT_16(st_fx->interval_SID_fx,st_fx->max_SID_fx)) { st_fx->max_SID_fx = st_fx->interval_SID_fx; move16();/* change SID update rate */ @@ -328,7 +324,7 @@ void dtx_fx( move16(); /* reset the counter of CNG frames for averaging */ test(); - IF( sub(st_fx->active_fr_cnt_fx,CNG_TYPE_HO) >= 0 && st_fx->Opt_AMR_WB_fx == 0 ) + IF( GE_16(st_fx->active_fr_cnt_fx,CNG_TYPE_HO)&&st_fx->Opt_AMR_WB_fx==0) { test(); test(); @@ -338,12 +334,12 @@ void dtx_fx( test(); test(); test(); - IF( sub(st_fx->cng_type_fx,LP_CNG) == 0 && ( (sub(st_fx->input_bwidth_fx,NB) == 0 && L_sub(st_fx->bckr_tilt_lt,589824l/*9.f Q16*/) > 0) || (sub(st_fx->input_bwidth_fx,NB) > 0 && L_sub(st_fx->bckr_tilt_lt,2949120l/*45.f Q16*/) > 0) ) ) + IF( EQ_16(st_fx->cng_type_fx,LP_CNG)&&((EQ_16(st_fx->input_bwidth_fx,NB)&>_32(st_fx->bckr_tilt_lt,589824l/*9.f Q16*/))||(GT_16(st_fx->input_bwidth_fx,NB)&>_32(st_fx->bckr_tilt_lt,2949120l/*45.f Q16*/)))) { st_fx->cng_type_fx = FD_CNG; move16(); } - ELSE IF( sub(st_fx->cng_type_fx,FD_CNG) == 0 && ( (sub(st_fx->input_bwidth_fx,NB) == 0 && L_sub(st_fx->bckr_tilt_lt,131072l/*2.f Q16*/) < 0) || (sub(st_fx->input_bwidth_fx,NB) > 0 && L_sub(st_fx->bckr_tilt_lt,655360l/*10.f Q16*/) < 0) ) ) + ELSE IF( EQ_16(st_fx->cng_type_fx,FD_CNG)&&((EQ_16(st_fx->input_bwidth_fx,NB)&<_32(st_fx->bckr_tilt_lt,131072l/*2.f Q16*/))||(GT_16(st_fx->input_bwidth_fx,NB)&<_32(st_fx->bckr_tilt_lt,655360l/*10.f Q16*/)))) { st_fx->cng_type_fx = LP_CNG; move16(); @@ -382,11 +378,11 @@ void dtx_fx( /* Active speech (voiced) */ - IF ( sub(st_fx->clas_fx,VOICED_CLAS) == 0 ) + IF ( EQ_16(st_fx->clas_fx,VOICED_CLAS)) { alpha = ALPHA_ENER_SLOW_FX; move16(); - if ( L_sub(st_fx->frame_ener_fx,st_fx->lt_ener_voiced_fx) > 0 ) + if ( GT_32(st_fx->frame_ener_fx,st_fx->lt_ener_voiced_fx)) { alpha = ALPHA_ENER_FAST_FX; move16();/*Q15 */ @@ -406,7 +402,7 @@ void dtx_fx( { alpha = ALPHA_ENER_SLOW_FX; move16(); - if (L_sub(st_fx->frame_ener_fx,st_fx->lt_ener_noise_fx) < 0) + if (LT_32(st_fx->frame_ener_fx,st_fx->lt_ener_noise_fx)) { alpha = ALPHA_ENER_FAST_FX; move16(); @@ -436,7 +432,7 @@ void dtx_fx( st_fx->bwidth_fx = st_fx->last_bwidth_fx; move16(); test(); - if( L_sub(st_fx->last_core_brate_fx, SID_2k40) > 0 && L_sub(st_fx->last_total_brate_cng_fx, -1) != 0 ) + if( GT_32(st_fx->last_core_brate_fx, SID_2k40)&&NE_32(st_fx->last_total_brate_cng_fx,-1)) { st_fx->bwidth_fx = st_fx->last_bwidth_cng_fx; move16(); @@ -444,7 +440,7 @@ void dtx_fx( test(); test(); - IF( st_fx->Opt_RF_ON && (L_sub(st_fx->total_brate_fx, ACELP_13k20) == 0) && (sub(st_fx->bwidth_fx, NB) == 0)) + IF( st_fx->Opt_RF_ON && (EQ_32(st_fx->total_brate_fx, ACELP_13k20))&&(EQ_16(st_fx->bwidth_fx,NB))) { st_fx->codec_mode = MODE1; move16(); @@ -457,7 +453,7 @@ void dtx_fx( test(); test(); - IF( st_fx->Opt_RF_ON && L_sub(st_fx->total_brate_fx, ACELP_13k20) != 0 ) + IF( st_fx->Opt_RF_ON && NE_32(st_fx->total_brate_fx, ACELP_13k20) ) { reset_rf_indices(st_fx); move16(); @@ -467,7 +463,7 @@ void dtx_fx( } /* Set and limit the encoded bandwidth */ - IF ( sub(st_fx->codec_mode, MODE2) == 0 ) + IF ( EQ_16(st_fx->codec_mode, MODE2)) { Word16 n, bits_frame_nominal; @@ -479,7 +475,7 @@ void dtx_fx( FOR (n=0; nrf_mode,1) == 0 ) + if( EQ_16(st_fx->rf_mode,1)) { tmpbandwidthMin = WB; } @@ -516,12 +512,12 @@ static void update_SID_cnt( test(); test(); - IF( L_sub(st_fx->core_brate_fx, SID_2k40) == 0 || L_sub(st_fx->core_brate_fx, SID_1k75) == 0 || st_fx->core_brate_fx == FRAME_NO_DATA ) + IF( EQ_32(st_fx->core_brate_fx, SID_2k40)||EQ_32(st_fx->core_brate_fx,SID_1k75)||st_fx->core_brate_fx==FRAME_NO_DATA) { /* Adapt the SID interval */ test(); test(); - IF ( st_fx->var_SID_rate_flag_fx != 0 && sub(st_fx->VarDTX_cnt_voiced_fx, MIN_CNT) == 0 && sub(st_fx->VarDTX_cnt_noise_fx, MIN_CNT) == 0 ) + IF ( st_fx->var_SID_rate_flag_fx != 0 && EQ_16(st_fx->VarDTX_cnt_voiced_fx, MIN_CNT)&&EQ_16(st_fx->VarDTX_cnt_noise_fx,MIN_CNT)) { /* EstimatedSNR = 10.0f * (float)log10( (0.01f + st_fx->lt_ener_voiced) / (0.01f + st_fx->lt_ener_noise) ); */ @@ -540,12 +536,12 @@ static void update_SID_cnt( L_tmp1 = Mpy_32_16_1(L_tmp1, 24660); /* mult by 3.0103 / 4 in Q15 */ L_tmp1 = L_shl(L_tmp1, 2+8); /* mult by 4 and shift left 8 to go in Q24 */ EstimatedSNR = round_fx(L_tmp1); /* now in Q8 */ - IF ( sub(EstimatedSNR,SNR_H_FX) > 0 ) + IF ( GT_16(EstimatedSNR,SNR_H_FX)) { st_fx->interval_SID_fx = INT_H; move16(); } - ELSE IF ( sub(EstimatedSNR,SNR_L_FX) < 0 ) + ELSE IF ( LT_16(EstimatedSNR,SNR_L_FX)) { st_fx->interval_SID_fx = INT_L; move16(); @@ -557,7 +553,8 @@ static void update_SID_cnt( st_fx->interval_SID_fx = s_min(s_max(st_fx->interval_SID_fx, INT_L), INT_H); test(); - if( st_fx->Opt_AMR_WB_fx == 0 || sub(st_fx->max_SID_fx,3) != 0 ) + + if( st_fx->Opt_AMR_WB_fx == 0 || NE_16(st_fx->max_SID_fx,3)) { st_fx->max_SID_fx = st_fx->interval_SID_fx; move16(); /* change SID update rate */ @@ -583,7 +580,7 @@ static void update_SID_cnt( delta = round_fx(L_tmp1); /* now in Q8 */ test(); test(); - if ( sub(delta,LTE_VAR_FX) < 0 && sub(st_fx->VarDTX_cnt_voiced_fx,MIN_CNT) == 0 && sub(st_fx->VarDTX_cnt_noise_fx, MIN_CNT) == 0 ) + if ( LT_16(delta,LTE_VAR_FX)&&EQ_16(st_fx->VarDTX_cnt_voiced_fx,MIN_CNT)&&EQ_16(st_fx->VarDTX_cnt_noise_fx,MIN_CNT)) { /* Send SID frame, and reset lt_ener_noise */ st_fx->lt_ener_noise_fx = st_fx->frame_ener_fx; @@ -604,7 +601,7 @@ static void update_SID_cnt( test(); test(); - if( st_fx->Opt_AMR_WB_fx != 0 && sub(st_fx->max_SID_fx,3) == 0 && sub(st_fx->cnt_SID_fx,3) == 0 ) + if( st_fx->Opt_AMR_WB_fx != 0 && EQ_16(st_fx->max_SID_fx,3)&&EQ_16(st_fx->cnt_SID_fx,3)) { /* set the size of CNG history buffer for averaging to DTX_HIST_SIZE frames */ /* be sure that DTX_HIST_SIZE >= INT_L */ @@ -613,7 +610,7 @@ static void update_SID_cnt( } test(); /*else if ( st_fx->max_SID_fx != 3 && st_fx->cnt_SID_fx == DTX_HIST_SIZE )//compile error */ - if( sub(st_fx->max_SID_fx,3) != 0 && sub(st_fx->cnt_SID_fx,DTX_HIST_SIZE) == 0 ) + if( NE_16(st_fx->max_SID_fx,3)&&EQ_16(st_fx->cnt_SID_fx,DTX_HIST_SIZE)) { /* set the size of CNG history buffer for averaging to 3 frames */ st_fx->cng_hist_size_fx = DTX_HIST_SIZE; @@ -621,18 +618,18 @@ static void update_SID_cnt( } } test(); - IF( st_fx->var_SID_rate_flag_fx == 0 && sub(st_fx->interval_SID_fx,1) > 0 ) + IF( st_fx->var_SID_rate_flag_fx == 0 && GT_16(st_fx->interval_SID_fx,1)) { /* set the size of CNG history buffer for averaging to interval_SID frames */ st_fx->cng_hist_size_fx = st_fx->interval_SID_fx; move16(); - if ( sub(st_fx->cng_hist_size_fx, DTX_HIST_SIZE) > 0 ) + if ( GT_16(st_fx->cng_hist_size_fx, DTX_HIST_SIZE)) { st_fx->cng_hist_size_fx = DTX_HIST_SIZE; move16(); } } - IF( sub(st_fx->cnt_SID_fx,st_fx->max_SID_fx) >= 0 ) + IF( GE_16(st_fx->cnt_SID_fx,st_fx->max_SID_fx)) { /* adaptive SID update interval */ st_fx->max_SID_fx = st_fx->interval_SID_fx; @@ -701,7 +698,7 @@ void dtx_hangover_control_fx( move32();/*Q6 */ ptr = add(ptr,1); - if ( sub(ptr,st_fx->ho_circ_size_fx) == 0 ) + if ( EQ_16(ptr,st_fx->ho_circ_size_fx)) { ptr = 0; move16(); @@ -720,8 +717,8 @@ void dtx_hangover_control_fx( FOR ( i=1; iburst_ho_cnt_fx-2; i++ ) { test(); - IF ( L_sub(Mpy_32_16_1(tmp_enr[ptr-i],ONE_OVER_BUF_H_NRG_FX),tmp_enr[ptr]) < 0 && - L_sub(tmp_enr[ptr-i],Mpy_32_16_1(tmp_enr[ptr], BUF_L_NRG_FX)) > 0 ) + IF ( LT_32(Mpy_32_16_1(tmp_enr[ptr-i],ONE_OVER_BUF_H_NRG_FX),tmp_enr[ptr])&& + GT_32(tmp_enr[ptr-i],Mpy_32_16_1(tmp_enr[ptr], BUF_L_NRG_FX)) ) { enr_est = L_add(enr_est,Mpy_32_16_1(tmp_enr[ptr-i],W_DTX_HO_FX[i])); /*Q6 */ weights = add(weights,W_DTX_HO_FX[i]); /*Q15 */ @@ -735,7 +732,7 @@ void dtx_hangover_control_fx( exp2 = norm_s(weights); fra2 = shl(weights,exp2); exp = sub(sub(exp,16),exp2); - IF ( sub(fra,fra2) > 0 ) + IF ( GT_16(fra,fra2)) { fra = shr(fra,1); exp = sub(exp,1); @@ -743,7 +740,7 @@ void dtx_hangover_control_fx( L_tmp = L_deposit_l(div_s(fra,fra2)); enr_est = L_shr(L_tmp,exp); /*Q6 */ - if ( L_sub(enr_est,64) < 0 ) + if ( LT_32(enr_est,64)) { enr_est = 64; move16();/*Q6 */ @@ -756,7 +753,7 @@ void dtx_hangover_control_fx( enr_est_log = round_fx(L_shl(L_tmp,8)); /*Q8 */ Denr_n2e = abs_s(sub(enr_new,enr_est_log)); /*Q8 */ - IF ( sub(m,3) < 0 ) + IF ( LT_16(m,3)) { enr_est = L_add(Mpy_32_16_1(enr_est,26214),Mpy_32_16_1(st_fx->ho_ener_circ_fx[st_fx->ho_circ_ptr_fx],6554)); /*Q6 */ } @@ -782,7 +779,7 @@ void dtx_hangover_control_fx( FOR( i=0; iL_frame_fx,L_FRAME) == 0 ) + IF ( EQ_16(st_fx->L_frame_fx,L_FRAME)) { lsp2lsf_fx( &tmp[i*M], lsf_tmp, M, INT_FS_FX ); ftmp_fx = 964; @@ -809,7 +806,7 @@ void dtx_hangover_control_fx( C[i] = Mpy_32_16_1(C[i],1928); /*QX6.5536 */ - IF ( L_sub(C[i],max[0]) > 0 ) + IF ( GT_32(C[i],max[0])) { max[1] = max[0]; move16(); @@ -820,7 +817,7 @@ void dtx_hangover_control_fx( max_idx[0] = i; move16(); } - ELSE IF ( L_sub(C[i],max[1]) > 0 ) + ELSE IF ( GT_32(C[i],max[1])) { max[1] = C[i]; move16(); @@ -829,11 +826,11 @@ void dtx_hangover_control_fx( } } - IF ( sub(m,1) == 0 ) + IF ( EQ_16(m,1)) { Copy( tmp, lsp_est, M ); } - ELSE IF ( sub(m,4) < 0 ) + ELSE IF ( LT_16(m,4)) { FOR ( i=0; ilspCNG_fx[i],lsp_est[i])); /*Q15 */ Dlsp = add(Dlsp,S_tmp); /*Q15 */ - IF ( sub(S_tmp,S_max) > 0 ) + IF ( GT_16(S_tmp,S_max)) { S_max = S_tmp; /*Q15 */ } @@ -912,10 +909,10 @@ void dtx_hangover_control_fx( test(); test(); test(); - IF ( ( sub(Dlsp,13107) < 0 && sub(Denr,359) < 0 && sub(S_max,3277) < 0 - && sub(Dlsp_n2e,13107) < 0 && sub(Denr_n2e,308) < 0 && st_fx->Opt_SC_VBR_fx == 1 ) || - ( sub(Dlsp,13107) < 0 && sub(Denr,205) < 0 && sub(S_max,3277) < 0 - && sub(Dlsp_n2e,13107) < 0 && sub(Denr_n2e,205) < 0 && st_fx->Opt_SC_VBR_fx == 0 ) ) + IF ( ( LT_16(Dlsp,13107)&<_16(Denr,359)&<_16(S_max,3277) + && LT_16(Dlsp_n2e,13107) && LT_16(Denr_n2e,308) && st_fx->Opt_SC_VBR_fx == 1 ) || + ( LT_16(Dlsp,13107) && LT_16(Denr,205) && LT_16(S_max,3277) + && LT_16(Dlsp_n2e,13107) && LT_16(Denr_n2e,205) && st_fx->Opt_SC_VBR_fx == 0 ) ) { st_fx->hangover_terminate_flag_fx = 1; diff --git a/lib_enc/enc_acelp.c b/lib_enc/enc_acelp.c index 0147fc44b674fdc9943df1b322fbf2879d657e82..39444303cc24f986a3de176ac3dcc9cfd2307d43 100644 --- a/lib_enc/enc_acelp.c +++ b/lib_enc/enc_acelp.c @@ -1,19 +1,16 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include #include #include "stl.h" -#include "wmc_auto.h" - #include "prot_fx.h" #include "options.h" #include "basop_util.h" #include "rom_com_fx.h" #include "rom_enc_fx.h" -#include "wmc_auto.h" #define _2_ 0x4000 /*Q12*/ #define _1_ 0x2000 /*Q12*/ @@ -298,7 +295,7 @@ static void E_ACELP_1pulse_search(UWord8 tracks[2], move16(); ntracks = 1; - if (sub(tracks[1], tracks[0]) != 0) + if (NE_16(tracks[1], tracks[0])) { ntracks = 2; move16(); @@ -398,10 +395,10 @@ static void E_ACELP_xh_corr(Word16 *x, Word16 *y, Word16 *h, Word16 L_subfr) /* tot += 3*max / 8 */ L_maxloc = L_shr(L_maxloc, 2); /* Do not warn saturation of L_tot, since its for headroom estimation. */ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF L_tot = L_add(L_tot, L_maxloc); /* +max/4 */ L_tot = L_add(L_tot, L_shr(L_maxloc, 1)); /* +max/8 */ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON } /* Find the number of right shifts to do on y32[] so that */ @@ -427,20 +424,25 @@ Word16 E_ACELP_hh_corr(Word16 *x, Word16 *y, Word16 L_subfr, Word16 bits) FOR (i = 0; i < L_subfr-1; i++) { - L_tmp = L_mult0( x[i], x[0] ); + Word64 L_tmp_64; + Word64 L_sum_64; + + L_tmp_64 = W_mult0_16_16( x[i], x[0] ); FOR (j = i+2; j < L_subfr; j+=2) { - L_tmp = L_mac0( L_tmp, x[j], x[j-i] ); + L_tmp_64 = W_mac0_16_16( L_tmp_64, x[j], x[j-i] ); } - L_sum = L_shr( L_tmp, 1 ); + L_sum_64 = L_tmp_64; + move64(); - L_tmp = L_mult0( x[i+1], x[1] ); + L_tmp_64 = W_mult0_16_16( x[i+1], x[1] ); FOR (j = i+3; j < L_subfr; j+=2) { - L_tmp = L_mac0( L_tmp, x[j], x[j-i] ); + L_tmp_64 = W_mac0_16_16( L_tmp_64, x[j], x[j-i] ); } - L_sum = L_add( L_sum, L_shr( L_tmp, 1 ) ); - + L_sum_64 = W_add_nosat( W_shr(L_sum_64,1), W_shr(L_tmp_64,1) ); + L_sum = W_sat_l( L_sum_64 ); + /* L_sum = L_shr( L_sum, 1 ); */ if (i == 0) { k = norm_l(L_sum); @@ -522,9 +524,9 @@ Word16 E_ACELP_xy1_corr(Word16 xn[], Word16 y1[], ACELP_CbkCorr *g_corr, Word16 i = add(exp_xy, 1 - 1); /* -1 -> gain in Q14 */ i = sub(i, exp_yy); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF gain = shl(gain, i); /* saturation can occur here */ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON /* gain = s_max(0, gain); */ /* see above xy < 0. */ /* if (gain > 1.2) gain = 1.2 in Q14 */ @@ -546,9 +548,9 @@ Word16 E_ACELP_xy1_corr(Word16 xn[], Word16 y1[], ACELP_CbkCorr *g_corr, Word16 /* Note: shl works as shl or shr. */ exp_tmp = sub(exp_tmp,1); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF tmp = round_fx(L_shl(Mpy_32_16_1( 1717986944l/*ACELP_GAINS_CONST Q31*/, tmp), exp_tmp)); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON gain = s_min(gain, tmp); } @@ -651,7 +653,7 @@ void E_ACELP_codebook_target_update(Word16 *x, Word16 *x2, Word16 *y, Q15_flag = 0; move16(); - if (sub(gain, 1<<14) < 0) + if (LT_16(gain, 1<<14)) { Q15_flag = 1; move16(); @@ -778,7 +780,7 @@ void E_ACELP_findcandidates(Word16 dn2[], Word16 dn2_pos[], Word16 pos_max[]) FOR (j = i+4; j < L_SUBFR; j += 4) { - if (sub(dn2[j], *ps_ptr) > 0) + if (GT_16(dn2[j], *ps_ptr)) { ps_ptr = &dn2[j]; move16(); @@ -1059,20 +1061,20 @@ void E_ACELP_4tsearch(Word16 dn[], const Word16 cn[], const Word16 H[], Word16 c scale = 0; move16(); L_tmp = L_deposit_l(0); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF FOR (i = 0; i < L_SUBFR; i++) { L_tmp = L_mac(L_tmp, H[i], H[i]); } val = extract_h(L_tmp); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON - if (sub(val, 0x2000) > 0) + if (GT_16(val, 0x2000)) { scale = -1; move16(); } - if (sub(val, 0x7000) > 0) + if (GT_16(val, 0x7000)) { scale = -2; move16(); @@ -1122,7 +1124,7 @@ void E_ACELP_4tsearch(Word16 dn[], const Word16 cn[], const Word16 H[], Word16 c move16(); set16_fx(vec, 0, L_SUBFR); } - ELSE IF (sub(config->fixedpulses, 2) == 0) /* 2222 and 3322 */ + ELSE IF (EQ_16(config->fixedpulses, 2)) /* 2222 and 3322 */ { /* first stage: fix 2 pulses */ ind[0] = pos_max[ipos[0]]; @@ -1219,7 +1221,7 @@ void E_ACELP_4tsearch(Word16 dn[], const Word16 cn[], const Word16 H[], Word16 c move16(); FOR (j = pos; j < nb_pulse; j += 2) { - IF (sub(nb_pulse_m2, j) >= 0) /* pair-wise search */ + IF (GE_16(nb_pulse_m2, j)) /* pair-wise search */ { /* * Calculate correlation of all possible positions @@ -1247,7 +1249,7 @@ void E_ACELP_4tsearch(Word16 dn[], const Word16 cn[], const Word16 H[], Word16 c &ind[j], dn, cor_x, cor_y); } - IF (0 < sub(nb_pulse_m2, j)) + IF (GT_16(nb_pulse_m2, j)) { p0 = h - ind[j]; if (sign[ind[j]] < 0) @@ -1393,7 +1395,7 @@ void E_ACELP_4t( test(); test(); - IF( sub(L_frame,last_L_frame) != 0 && L_sub(total_brate,ACELP_24k40) == 0 && L_sub(i_subfr, 5*L_SUBFR) < 0 ) + IF( NE_16(L_frame,last_L_frame)&&EQ_32(total_brate,ACELP_24k40)&<_32(i_subfr,5*L_SUBFR)) { config.nbiter = sub(config.nbiter, 1); config.nbiter = s_max(config.nbiter, 1); @@ -1460,7 +1462,7 @@ Word16 E_ACELP_indexing( set16_fx((Word16*)idx, 0, wordcnt); - IF (sub(config->bits, 43) == 0) /* EVS pulse indexing */ + IF (EQ_16(config->bits, 43)) /* EVS pulse indexing */ { saved_bits = E_ACELP_code43bit(code, s, p, idx); } @@ -1484,13 +1486,13 @@ Word16 E_ACELP_indexing( case TRACKPOS_FIXED_TWO: /* Code position of consecutive tracks with single extra pulses */ /* Find track with one pulse less. */ - if (sub(p[0], p[1]) != 0) + if (NE_16(p[0], p[1])) { /* Either 0110 or 1001 */ track = 1; move16(); } - if (sub(p[3], p[1]) > 0) + if (GT_16(p[3], p[1])) { track = add(track, 2); } @@ -1501,17 +1503,17 @@ Word16 E_ACELP_indexing( case TRACKPOS_FREE_THREE: /* Code position of track with one pulse less than others */ /* Find track with one pulse less. */ - if (sub(p[1], p[0]) < 0) + if (LT_16(p[1], p[0])) { track = 1; move16(); } - if (sub(p[2], p[0]) < 0) + if (LT_16(p[2], p[0])) { track = 2; move16(); } - if (sub(p[3], p[0]) < 0) + if (LT_16(p[3], p[0])) { track = 3; move16(); @@ -1523,17 +1525,17 @@ Word16 E_ACELP_indexing( case TRACKPOS_FREE_ONE: /* Code position of track with one pulse less than others */ /* Find track with one pulse less. */ - if (sub(p[1], p[0]) > 0) + if (GT_16(p[1], p[0])) { track = 1; move16(); } - if (sub(p[2], p[0]) > 0) + if (GT_16(p[2], p[0])) { track = 2; move16(); } - if (sub(p[3], p[0]) > 0) + if (GT_16(p[3], p[0])) { track = 3; move16(); @@ -1606,12 +1608,12 @@ void E_ACELP_adaptive_codebook( /* find pitch excitation */ /*for &exc[i_subfr]*/ - if (sub(T0_res, shr(T0_res_max, 1)) == 0) + if (EQ_16(T0_res, shr(T0_res_max, 1))) { T0_frac = shl(T0_frac, 1); } - IF (sub(T0_res_max, 6) == 0 && rf_mode == 0) + IF (EQ_16(T0_res_max, 6)&&rf_mode==0) { pitch_inter = pitch_inter6_2; pit_L_interpol = PIT_L_INTERPOL6_2; @@ -1631,7 +1633,7 @@ void E_ACELP_adaptive_codebook( pred_lt4( &exc[i_subfr], &exc[i_subfr], T0, T0_frac, L_SUBFR+1, pitch_inter, pit_L_interpol, pit_up_samp); test(); - IF(sub(mode,NORMAL_OPERATION)==0 || (sub(mode,FULL_BAND)==0)) + IF(EQ_16(mode,NORMAL_OPERATION)||(EQ_16(mode,FULL_BAND))) { E_UTIL_f_convolve(&exc[i_subfr], h1, y1,L_subfr); @@ -1640,7 +1642,7 @@ void E_ACELP_adaptive_codebook( gain1 = E_ACELP_xy1_corr(xn, y1, g_corr,1,L_subfr,exp_xn); /* clip gain if necessary to avoid problem at decoder */ test(); - if (clip_gain && sub(gain1,15565/*0.95 Q14*/) > 0) + if (clip_gain && GT_16(gain1,15565/*0.95 Q14*/)) { gain1 = 15565/*0.95f Q14*/; move16(); @@ -1660,12 +1662,12 @@ void E_ACELP_adaptive_codebook( * - find filtered pitch exc. y2[]=exc[] convolved with h1[]) * * - compute pitch gain2 * *-----------------------------------------------------------------*/ test(); - IF(sub(mode,NORMAL_OPERATION)==0 || sub(mode,LOW_PASS)==0) + IF(EQ_16(mode,NORMAL_OPERATION)||EQ_16(mode,LOW_PASS)) { /* find pitch excitation with lp filter */ fac_m = 20972/*0.64f Q15*/; move16(); - if ( sub(L_frame,L_FRAME16k)==0 ) + if ( EQ_16(L_frame,L_FRAME16k)) { fac_m = 19005/*0.58f Q15*/; move16(); @@ -1683,7 +1685,7 @@ void E_ACELP_adaptive_codebook( gain2 = E_ACELP_xy1_corr(xn, y2, &g_corr2, 1, L_subfr, exp_xn); /* clip gain if necessary to avoid problem at decoder */ test(); - if (clip_gain && sub(gain2,15565/*0.95 Q14*/) > 0) + if (clip_gain && GT_16(gain2,15565/*0.95 Q14*/)) { gain2 = 15565/*0.95f Q14*/; move16(); @@ -1697,7 +1699,7 @@ void E_ACELP_adaptive_codebook( /*-----------------------------------------------------------------* * use the best prediction (minimise quadratic error). * *-----------------------------------------------------------------*/ test(); - IF (sub(mode,LOW_PASS)==0 || L_sub(L_tmp,L_ener) < 0) + IF (EQ_16(mode,LOW_PASS)||LT_32(L_tmp,L_ener)) { /* use the lp filter for pitch excitation prediction */ select = LOW_PASS; @@ -1724,7 +1726,7 @@ void E_ACELP_adaptive_codebook( move16(); } - IF(sub(mode,NORMAL_OPERATION)==0) + IF(EQ_16(mode,NORMAL_OPERATION)) { **pt_indice = select; (*pt_indice)++; @@ -1786,7 +1788,7 @@ void E_ACELP_innovative_codebook( pitch = T0; move16(); - if (sub(T0_frac, shr(T0_res, 1)) > 0) + if (GT_16(T0_frac, shr(T0_res, 1))) { pitch = add(pitch,1); } @@ -1956,7 +1958,7 @@ void fcb_pulse_track_joint(UWord16 *idxs, Word16 wordcnt, UWord32 *index_n, Word indx_flag_2 = add(indx_flag_2, shr(pulse_num[track], 3)); } - IF (sub(indx_flag_2, 1) >= 0) + IF (GE_16(indx_flag_2, 1)) { hi_to_low[7] = 9; move16(); @@ -1965,7 +1967,7 @@ void fcb_pulse_track_joint(UWord16 *idxs, Word16 wordcnt, UWord32 *index_n, Word } ELSE { - if (sub(indx_flag, track_num) < 0) + if (LT_16(indx_flag, track_num)) { hi_to_low[4] = 1; move16(); @@ -1973,7 +1975,7 @@ void fcb_pulse_track_joint(UWord16 *idxs, Word16 wordcnt, UWord32 *index_n, Word index_mask = L_shr(0xFFFF, sub(9, hi_to_low[4])); } - IF (sub(indx_flag_1, track_num) >= 0) + IF (GE_16(indx_flag_1, track_num)) { indx_tmp = L_deposit_l(0); index = L_shr(index_n[0], low_len[pulse_num[0]]); @@ -1998,9 +2000,9 @@ void fcb_pulse_track_joint(UWord16 *idxs, Word16 wordcnt, UWord32 *index_n, Word index_n[track_num1] = L_and(L_add(L_and(index_n[track_num1], low_mask[pulse_num1]), L_lshl(index, low_len[pulse_num1])), index_mask); index = L_lshr(index, hi_to_low[pulse_num1]); - IF (sub(indx_flag, track_num) >= 0) + IF (GE_16(indx_flag, track_num)) { - IF (sub(indx_flag_2, 1) >= 0) + IF (GE_16(indx_flag_2, 1)) { idxs[0] = extract_l(index_n[0]); idxs[1] = extract_l(L_add(L_lshl(index_n[1], 8), L_lshr(index_n[0], 16))); diff --git a/lib_enc/enc_acelp_tcx_main.c b/lib_enc/enc_acelp_tcx_main.c index d3897c4038854baea1a0e497b40b247b76196963..1190058b6128838c91668c4645aea48aa81f0f44 100644 --- a/lib_enc/enc_acelp_tcx_main.c +++ b/lib_enc/enc_acelp_tcx_main.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -9,8 +9,6 @@ #include "options.h" #include "cnst_fx.h" #include "stl.h" -#include "wmc_auto.h" - void enc_acelp_tcx_main( @@ -36,7 +34,7 @@ void enc_acelp_tcx_main( Word16 *ptr_bwe_exc; ptr_bwe_exc = old_bwe_exc + PIT16k_MAX * 2; - IF( sub( st->last_core_fx, ACELP_CORE) == 0 ) + IF( EQ_16( st->last_core_fx, ACELP_CORE)) { set16_fx( old_bwe_exc + PIT16k_MAX * 2, 0, ((L_FRAME16k + 1) + L_SUBFR16k) * 2 ); Copy( st->old_bwe_exc_fx, old_bwe_exc, PIT16k_MAX * 2 ); @@ -64,7 +62,7 @@ void enc_acelp_tcx_main( pitch, voicing, Aw, lsp_new, lsp_mid, pitch_buf, voice_factors, ptr_bwe_exc, - vad_hover_flag, vad_flag_dtx , *Q_new, *shift ); + vad_hover_flag, vad_flag_dtx, *Q_new, *shift ); } ELSE { @@ -77,7 +75,7 @@ void enc_acelp_tcx_main( test(); - IF( sub( st->core_fx, ACELP_CORE ) == 0 && st->igf != 0 ) + IF( EQ_16( st->core_fx, ACELP_CORE )&&st->igf!=0) { non_linearity_fx( ptr_bwe_exc, bwe_exc_extended, L_FRAME32k, &st->bwe_non_lin_prev_scale_fx, *Q_new , coder_type, voice_factors, st->L_frame_fx diff --git a/lib_enc/enc_acelpx.c b/lib_enc/enc_acelpx.c index b0daee5e5736bb7415c12d0d9589ea3458ddae77..ed90f33dde143ab412bd1c2afb53799901df8742 100644 --- a/lib_enc/enc_acelpx.c +++ b/lib_enc/enc_acelpx.c @@ -1,18 +1,15 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include #include #include "stl.h" -#include "wmc_auto.h" - #include "prot_fx.h" #include "basop_util.h" #include "options.h" #include "rom_enc_fx.h" -#include "wmc_auto.h" #define _1_Q11 (2048/*1.0f Q11*/) /* 1.0f in 4Q11 */ @@ -29,7 +26,7 @@ static void E_ACELP_update_cor( const Word16 *pRx, *pRy; Word16 i, tmp; - IF (sub(nb_pulse, 2) == 0) + IF (EQ_16(nb_pulse, 2)) { /* Update product of autocorrelation and already fixed pulses. with the * two newly found ones */ @@ -99,7 +96,7 @@ static void E_ACELP_update_cor( } } } - ELSE IF (sub(nb_pulse, 4) == 0) + ELSE IF (EQ_16(nb_pulse, 4)) { E_ACELP_update_cor(pos, 2, sign, R, cor_in, cor_out); E_ACELP_update_cor(pos+2, 2, sign, R, cor_out, cor_out); @@ -282,7 +279,7 @@ static void E_ACELP_1pulse_searchx(UWord8 tracks[2], move16(); ntracks = 1; - if (sub(tracks[1], tracks[0]) != 0) + if (NE_16(tracks[1], tracks[0])) { ntracks = 2; move16(); @@ -372,40 +369,40 @@ void E_ACELP_4tsearchx(Word16 dn[], const Word16 cn[], Word16 Rw[], Word16 code[ { s = L_mac0(s, Rw[i], Rw[i]); } - if (s_and(sub(nb_pulse, 9) >= 0, L_sub(s, 0x800000) > 0)) + if (s_and((Word16)GE_16(nb_pulse, 9),(Word16)GT_32(s,0x800000))) { scale = -1; move16(); } - if (s_and(sub(nb_pulse, 13) >= 0, L_sub(s, 0x4000000) > 0)) + if (s_and((Word16)GE_16(nb_pulse, 13),(Word16)GT_32(s,0x4000000))) { scale = -2; move16(); } - IF (sub(nb_pulse, 18) >= 0) + IF (GE_16(nb_pulse, 18)) { - if (L_sub(s, 0x200000) > 0) + if (GT_32(s, 0x200000)) { scale = -1; move16(); } - if (L_sub( s, 0x400000 ) > 0) + if (GT_32( s, 0x400000 )) { scale = -2; move16(); } - if (L_sub( s, 0x4000000 ) > 0) + if (GT_32( s, 0x4000000 )) { scale = -3; move16(); } } - if (s_and(sub(nb_pulse, 28) >= 0, L_sub(s, 0x800000) > 0)) + if (s_and((Word16)GE_16(nb_pulse, 28),(Word16)GT_32(s,0x800000))) { scale = -3; move16(); } - if (s_and(sub(nb_pulse, 36) >= 0, L_sub(s, 0x4000000) > 0)) + if (s_and((Word16)GE_16(nb_pulse, 36),(Word16)GT_32(s,0x4000000))) { scale = -4; move16(); @@ -423,7 +420,7 @@ void E_ACELP_4tsearchx(Word16 dn[], const Word16 cn[], Word16 Rw[], Word16 code[ /* Sign value */ sign_val_2 = 0x2000; move16(); - if (sub(nb_pulse, 24) >= 0) + if (GE_16(nb_pulse, 24)) { sign_val_2 = shr(sign_val_2, 1); } @@ -497,7 +494,7 @@ void E_ACELP_4tsearchx(Word16 dn[], const Word16 cn[], Word16 Rw[], Word16 code[ move16(); FOR (j = pos; j < nb_pulse; j += 2) { - IF (sub(nb_pulse_m2, j) >= 0) /* pair-wise search */ + IF (GE_16(nb_pulse_m2, j)) /* pair-wise search */ { /* * Calculate correlation of all possible positions diff --git a/lib_enc/enc_amr_wb_fx.c b/lib_enc/enc_amr_wb_fx.c index 24e14ed1ac0b79447b7108974e481a71eeb4070e..68f22bab7412a3f2b9853830be8e3d6d0f359d06 100644 --- a/lib_enc/enc_amr_wb_fx.c +++ b/lib_enc/enc_amr_wb_fx.c @@ -1,14 +1,12 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "cnst_fx.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #include "rom_com_fx.h" /* Static table prototypes */ -#include "stl.h" -#include "wmc_auto.h" - +#include "stl.h" /* required by wmc_tool */ /*-------------------------------------------------------------------* * encod_amr_wb() @@ -86,13 +84,13 @@ void encod_amr_wb_fx( shift_wsp = add(Q_new,shift); Copy( pitch, T_op, 2 ); - if (sub(T_op[0],PIT_MIN) <= 0) + if (LE_16(T_op[0],PIT_MIN)) { T_op[0] = shl(T_op[0],1); move16(); } - if (sub(T_op[1],PIT_MIN) <= 0) + if (LE_16(T_op[1],PIT_MIN)) { /*T_op[1] *= 2;*/ T_op[1] = shl(T_op[1],1); @@ -149,7 +147,7 @@ void encod_amr_wb_fx( lp_select = lp_filt_exc_enc_fx( MODE1, st->core_brate_fx, 1, -1, i_subfr, exc, h1, xn, y1, xn2, L_SUBFR, L_FRAME, g_corr, clip_gain, &gain_pit, &lp_flag ); - IF( sub(lp_flag,NORMAL_OPERATION) == 0 ) + IF( EQ_16(lp_flag,NORMAL_OPERATION)) { push_indice_fx( st, IND_LP_FILT_SELECT, lp_select, 1 ); } @@ -213,9 +211,9 @@ void encod_amr_wb_fx( * HF gain modification factors at 23.85 kbps *-----------------------------------------------------------------*/ - IF ( L_sub(st->core_brate_fx,ACELP_23k85) == 0 ) + IF ( EQ_32(st->core_brate_fx,ACELP_23k85)) { - IF( L_sub(st->input_Fs_fx,16000) >= 0 ) + IF( GE_32(st->input_Fs_fx,16000)) { hf_cod_fx( st->core_brate_fx, &speech16k_fx[i_subfr * L_SUBFR16k/L_SUBFR], Aq, &exc[i_subfr], &syn[i_subfr], &st->seed2_enc_fx, st->mem_hp400_enc_fx, st->mem_syn_hf_enc_fx, st->mem_hf_enc_fx, st->mem_hf2_enc_fx, diff --git a/lib_enc/enc_gain.c b/lib_enc/enc_gain.c index a183bde0e483b4a8350f95bd2639bcaf1041888f..00d8b6665983865a0c5b64c0d7ae6eed57b24f37 100644 --- a/lib_enc/enc_gain.c +++ b/lib_enc/enc_gain.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -7,8 +7,6 @@ #include #include #include "stl.h" -#include "wmc_auto.h" - #include "prot_fx.h" #include "rom_com_fx.h" #include "basop_util.h" @@ -264,7 +262,7 @@ Word16 E_GAIN_closed_loop_search(Word16 exc[], FOR(i = t0_min + 1; i <= t0_max; i++) { BASOP_SATURATE_WARNING_OFF; - if( sub(corr[i],max) >= 0) + if( GE_16(corr[i],max)) { t0 = i; move16(); @@ -277,7 +275,7 @@ Word16 E_GAIN_closed_loop_search(Word16 exc[], /* If first subframe and t0 >= pit_fr1, do not search fractionnal pitch */ test(); - IF((i_subfr == 0) && sub(t0,pit_fr1) >= 0) + IF((i_subfr == 0) && GE_16(t0,pit_fr1)) { *pit_frac = 0; move16(); @@ -293,7 +291,7 @@ Word16 E_GAIN_closed_loop_search(Word16 exc[], * the interpolated normalized correlation. */ - IF ( sub(t0_min_max_res,shr(pit_res_max,1)) == 0) + IF ( EQ_16(t0_min_max_res,shr(pit_res_max,1))) { t0_min_frac = shl(t0_min_frac,1); t0_max_frac = shl(t0_max_frac,1); @@ -305,14 +303,14 @@ Word16 E_GAIN_closed_loop_search(Word16 exc[], test(); test(); - IF (((i_subfr == 0) && sub(t0,pit_fr2) >= 0) || sub(pit_fr2,pit_min) <= 0) + IF (((i_subfr == 0) && GE_16(t0,pit_fr2))||LE_16(pit_fr2,pit_min)) { step = 2; frac1 = sub(2,pit_res_max); frac2 = sub(pit_res_max,2); } test(); - IF ( (sub(t0,t0_min) == 0) && (t0_min_frac==0) ) + IF ( (EQ_16(t0,t0_min))&&(t0_min_frac==0)) { frac1 = t0_min_frac; move16(); @@ -320,20 +318,20 @@ Word16 E_GAIN_closed_loop_search(Word16 exc[], ELSE { test(); - IF ( (sub(t0,t0_min) == 0) && (sub(add(frac1,pit_res_max),t0_min_frac)<0) ) + IF ( (EQ_16(t0,t0_min))&&(LT_16(add(frac1,pit_res_max),t0_min_frac))) { frac1 = sub(t0_min_frac,pit_res_max); } } - if (sub(t0,t0_max) == 0) + if (EQ_16(t0,t0_max)) { frac2 = t0_max_frac; move16(); } assert(frac1<=0 && frac2>=0 && frac2>frac1); - IF (sub(pit_res_max,6) == 0) + IF (EQ_16(pit_res_max,6)) { cor_max = E_GAIN_norm_corr_interpolate6(&corr[t0], frac1); fraction = frac1; @@ -341,7 +339,7 @@ Word16 E_GAIN_closed_loop_search(Word16 exc[], FOR (i = (frac1 + step); i <= frac2; i += step) { temp = E_GAIN_norm_corr_interpolate6(&corr[t0], i); - IF (sub(temp,cor_max) > 0) + IF (GT_16(temp,cor_max)) { cor_max = temp; move16(); @@ -359,7 +357,7 @@ Word16 E_GAIN_closed_loop_search(Word16 exc[], FOR (i = (frac1 + step); i <= frac2; i += step) { temp = E_GAIN_norm_corr_interpolate(&corr[t0], i); - IF (sub(temp,cor_max) > 0) + IF (GT_16(temp,cor_max)) { cor_max = temp; move16(); @@ -378,7 +376,7 @@ Word16 E_GAIN_closed_loop_search(Word16 exc[], } test(); test(); - IF (((i_subfr == 0) && sub(t0,pit_fr2) >= 0) || sub(pit_fr2,pit_min) <= 0) + IF (((i_subfr == 0) && GE_16(t0,pit_fr2))||LE_16(pit_fr2,pit_min)) { *pit_res = shr(pit_res_max,1); move16(); diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index 11e273ba34af87aea6148b7f206952d3cd20e2ed..fc0501e46c1dbf3994c700152e99da4aba485334 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -8,8 +8,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*======================================================================*/ @@ -125,7 +123,7 @@ void encod_gen_voic_fx( error_fx = 0; move16(); - IF( sub(L_frame_fx,L_FRAME) == 0) + IF( EQ_16(L_frame_fx,L_FRAME)) { T0_max_fx = PIT_MAX; move16(); @@ -154,9 +152,9 @@ void encod_gen_voic_fx( move16(); test(); test(); - IF( L_sub(st_fx->core_brate_fx,ACELP_24k40) > 0 && L_sub(st_fx->core_brate_fx,ACELP_32k) <= 0 && sub(coder_type_fx,GENERIC) == 0 ) + IF( GT_32(st_fx->core_brate_fx,ACELP_24k40)&&LE_32(st_fx->core_brate_fx,ACELP_32k)&&EQ_16(coder_type_fx,GENERIC)) { - if( sub(st_fx->last_harm_flag_acelp_fx,2) > 0 ) + if( GT_16(st_fx->last_harm_flag_acelp_fx,2)) { harm_flag_acelp = 1; move16(); @@ -206,7 +204,7 @@ void encod_gen_voic_fx( clip_gain_fx = gp_clip_fx(st_fx->core_brate_fx,voicing_fx,i_subfr_fx,coder_type_fx,xn_fx,st_fx->clip_var_fx,sub(shift_wsp, 1)); - if( sub(coder_type_fx,INACTIVE) == 0 ) + if( EQ_16(coder_type_fx,INACTIVE)) { /* in case of AVQ inactive, limit the gain to 0.65 */ clip_gain_fx = 2; @@ -220,7 +218,7 @@ void encod_gen_voic_fx( lp_select = lp_filt_exc_enc_fx( MODE1, st_fx->core_brate_fx, 0, coder_type_fx, i_subfr_fx, exc_fx, h1_fx, xn_fx, y1_fx, xn2_fx, L_SUBFR, L_frame_fx, g_corr_fx, clip_gain_fx, &gain_pit_fx, &lp_flag ); - IF( sub(lp_flag,NORMAL_OPERATION) == 0 ) + IF( EQ_16(lp_flag,NORMAL_OPERATION)) { push_indice_fx( st_fx, IND_LP_FILT_SELECT, lp_select, 1 ); } @@ -233,7 +231,7 @@ void encod_gen_voic_fx( *-----------------------------------------------------------------*/ test(); - IF( L_sub(st_fx->core_brate_fx,ACELP_24k40) > 0 && sub(coder_type_fx,INACTIVE) != 0 ) + IF( GT_32(st_fx->core_brate_fx,ACELP_24k40)&&NE_16(coder_type_fx,INACTIVE)) { transf_cdbk_enc_fx( st_fx, st_fx->core_brate_fx, st_fx->extl_fx, coder_type_fx, harm_flag_acelp, i_subfr_fx, -1, cn_fx, exc_fx, p_Aq_fx, p_Aw_fx, h1_fx, xn_fx, xn2_fx, y1_fx, y2_fx, Es_pred_fx, &gain_pit_fx, gain_code_fx, g_corr_fx, clip_gain_fx, @@ -252,12 +250,12 @@ void encod_gen_voic_fx( * Gain encoding *-----------------------------------------------------------------*/ - IF ( L_sub(st_fx->core_brate_fx,ACELP_8k00) <= 0) + IF ( LE_32(st_fx->core_brate_fx,ACELP_8k00)) { gain_enc_lbr_fx( st_fx, st_fx->core_brate_fx, coder_type_fx, i_subfr_fx, xn_fx, y1_fx, shift_wsp, y2_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, gc_mem, gp_mem, clip_gain_fx ); } - ELSE IF ( L_sub(st_fx->core_brate_fx,ACELP_32k) > 0 ) + ELSE IF ( GT_32(st_fx->core_brate_fx,ACELP_32k)) { gain_enc_SQ_fx( st_fx, st_fx->core_brate_fx, coder_type_fx, i_subfr_fx, -1, xn_fx, y1_fx, y2_fx, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, clip_gain_fx, shift_wsp ); @@ -268,7 +266,7 @@ void encod_gen_voic_fx( &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, clip_gain_fx ); } - if ( sub(st_fx->last_ppp_mode_fx,1) == 0 ) + if ( EQ_16(st_fx->last_ppp_mode_fx,1)) { /* SC-VBR - all other st->clip_var values will be updated even in a PPP frame */ st_fx->clip_var_fx[1] = gain_pit_fx; @@ -286,7 +284,7 @@ void encod_gen_voic_fx( *-----------------------------------------------------------------*/ test(); - IF ( L_sub(st_fx->core_brate_fx,ACELP_24k40) > 0 && sub(coder_type_fx,INACTIVE) == 0 ) + IF ( GT_32(st_fx->core_brate_fx,ACELP_24k40)&&EQ_16(coder_type_fx,INACTIVE)) { transf_cdbk_enc_fx( st_fx, st_fx->core_brate_fx, st_fx->extl_fx, coder_type_fx, 0, i_subfr_fx, -1, cn_fx, exc_fx, p_Aq_fx, p_Aw_fx, h1_fx, xn_fx, xn2_fx, y1_fx, y2_fx, Es_pred_fx, &gain_pit_fx, gain_code_fx, g_corr_fx, clip_gain_fx, @@ -306,7 +304,7 @@ void encod_gen_voic_fx( Ltmp = L_shl(Ltmp, sub(1, shift)); mem->mem_w0 = round_fx(Ltmp); /*Q_new-1 */ - IF( L_sub(st_fx->core_brate_fx,ACELP_24k40) > 0 ) + IF( GT_32(st_fx->core_brate_fx,ACELP_24k40)) { tmp1_fx = add(16-(2+Q_AVQ_OUT_DEC+1),Q_new); diff --git a/lib_enc/enc_gen_voic_rf_fx.c b/lib_enc/enc_gen_voic_rf_fx.c index 6615464305355bdc99170d1295319acc94e32914..13da0ee0728d08b3512bf1128988d86485515674 100644 --- a/lib_enc/enc_gen_voic_rf_fx.c +++ b/lib_enc/enc_gen_voic_rf_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" @@ -7,8 +7,6 @@ #include "prot_fx.h" #include "rom_com_fx.h" #include "stl.h" -#include "wmc_auto.h" - #include "rom_basop_util.h" #include "basop_mpy.h" @@ -219,7 +217,7 @@ void coder_acelp_rf( *------------------------------------------------------------------------*/ Es_pred_rf = 0; - IF( acelp_cfg_rf->nrg_mode > 0 && sub(rf_frame_type,RF_NELP) != 0 ) + IF( acelp_cfg_rf->nrg_mode > 0 && NE_16(rf_frame_type,RF_NELP)) { Es_pred_enc_fx(&Es_pred_rf, &st->rf_indx_EsPred[0], L_frame, exc_rf, voicing, acelp_cfg_rf->nrg_bits, acelp_cfg_rf->nrg_mode>1, Q_new); @@ -254,7 +252,7 @@ void coder_acelp_rf( FOR (i_subfr=0; i_subfr 0 && !harm_flag_acelp ) + IF( NE_16(coder_type,INACTIVE)&&LE_32(core_brate,ACELP_32k)&>_32(core_brate,ACELP_24k40)&&!harm_flag_acelp) { Copy_Scale_sig( x_in, x_tran, L_SUBFR,-Q_MINUS+1 ); /*Q_new-1 -> Q_new-4*/ /*Copy( x_in, x_tran, L_SUBFR );*/ @@ -152,7 +150,7 @@ void transf_cdbk_enc_fx( m_ener = extract_h(L_shl(L_ener, e_ener)); e_ener = sub(30, e_ener); - IF(sub(m_corr,m_ener)>0) + IF(GT_16(m_corr,m_ener)) { m_corr = shr(m_corr,1); e_corr = add(e_corr,1); @@ -160,7 +158,7 @@ void transf_cdbk_enc_fx( m_corr = div_s(m_corr, m_ener); e_corr = sub(e_corr, e_ener); Ltmp = L_shl(m_corr, s_min(add(e_corr,1),31)); /* Lgain in Q16 */ - IF ( sub(coder_type,INACTIVE) == 0 ) + IF ( EQ_16(coder_type,INACTIVE)) { Ltmp1 = L_max(gain_code,1); e_den = norm_l(Ltmp1); @@ -179,11 +177,11 @@ void transf_cdbk_enc_fx( stmp = 0; move16(); } - IF( L_sub(core_brate,ACELP_64k) == 0 ) + IF( EQ_32(core_brate,ACELP_64k)) { index = usquant_fx( stmp, &stmp, G_AVQ_MIN_INACT_64k_Q12, G_AVQ_DELTA_INACT_64k_Q12>>1, (1 << G_AVQ_BITS) ); } - ELSE IF( L_sub(core_brate,ACELP_48k) == 0 ) + ELSE IF( EQ_32(core_brate,ACELP_48k)) { index = usquant_fx( stmp, &stmp, G_AVQ_MIN_INACT_48k_Q12, G_AVQ_DELTA_INACT_48k_Q12>>1, (1 << G_AVQ_BITS) ); } @@ -222,7 +220,7 @@ void transf_cdbk_enc_fx( Ltmp = L_deposit_l(0); } test(); - IF( L_sub(core_brate,ACELP_32k) <= 0 && L_sub(core_brate,ACELP_24k40) > 0 ) + IF( LE_32(core_brate,ACELP_32k)&>_32(core_brate,ACELP_24k40)) { index = gain_quant_fx(&Ltmp, &stmp, LG10_G_AVQ_MIN_32kbps_Q14, LG10_G_AVQ_MAX_Q13, G_AVQ_BITS, &e_den ); } @@ -249,7 +247,7 @@ void transf_cdbk_enc_fx( /* at the last subframe, write AVQ unused bits */ test(); test(); - IF( sub(i_subfr,4*L_SUBFR) == 0 && sub(extl,SWB_BWE_HIGHRATE) != 0 && sub(extl,FB_BWE_HIGHRATE) != 0 ) + IF( EQ_16(i_subfr,4*L_SUBFR)&&NE_16(extl,SWB_BWE_HIGHRATE)&&NE_16(extl,FB_BWE_HIGHRATE)) { WHILE( *unbits > 0 ) { @@ -274,7 +272,7 @@ void transf_cdbk_enc_fx( test(); test(); - IF(sub(coder_type,INACTIVE) != 0 && L_sub(core_brate,ACELP_32k) <= 0 && L_sub(core_brate,ACELP_24k40) > 0 && !harm_flag_acelp ) + IF(NE_16(coder_type,INACTIVE)&&LE_32(core_brate,ACELP_32k)&>_32(core_brate,ACELP_24k40)&&!harm_flag_acelp) { Copy( x_tran, code_preQ, L_SUBFR ); } @@ -294,7 +292,7 @@ void transf_cdbk_enc_fx( *--------------------------------------------------------------*/ /* in extreme cases at subframe boundaries, lower the preemphasis memory to avoid a saturation */ test(); - if( (nq[7] != 0) && (sub( sub(st_fx->last_nq_preQ_fx, nq[0]), 7) > 0) ) + if( (nq[7] != 0) && (GT_16( sub(st_fx->last_nq_preQ_fx, nq[0]), 7))) { /* *mem_preemp /= 16; */ *mem_preemp = shr(*mem_preemp,4); @@ -302,8 +300,7 @@ void transf_cdbk_enc_fx( } st_fx->last_nq_preQ_fx = nq[7]; move16(); - /*preemph_fx(code_preQ, FAC_PRE_AVQ_FX, L_SUBFR, mem_preemp);*/ - preemph_copy_fx( code_preQ, code_preQ, FAC_PRE_AVQ_FX, L_SUBFR, mem_preemp ); + preemph_fx( code_preQ, FAC_PRE_AVQ_FX, L_SUBFR, mem_preemp ); /*--------------------------------------------------------------* * For inactive segments @@ -313,7 +310,7 @@ void transf_cdbk_enc_fx( * - Update xn[L_subfr-1] for updating the memory of the weighting filter *--------------------------------------------------------------*/ - IF ( sub(coder_type,INACTIVE) == 0 ) + IF ( EQ_16(coder_type,INACTIVE)) { /*ftemp = fcode_preQ[0] *fh1[L_SUBFR-1];*/ Ltmp = L_mult(code_preQ[0], h1[L_SUBFR-1]); /*1+14+shift + Q_AVQ_OUT */ @@ -336,7 +333,7 @@ void transf_cdbk_enc_fx( /* clip gain if necessary to avoid problems at decoder */ test(); - if( sub(clip_gain,1) == 0 && sub(*gain_pit, 15565) > 0) + if( EQ_16(clip_gain,1)&>_16(*gain_pit,15565)) { *gain_pit = 15565; move16(); @@ -367,8 +364,7 @@ static void find_cn_fx( Copy( xn, tmp_fl+M, L_SUBFR ); tmp = 0; move16(); - /*preemph_fx(tmp_fl + M, PREEMPH_FAC_16k, L_SUBFR, &tmp);*/ - preemph_copy_fx( tmp_fl+M, tmp_fl + M, PREEMPH_FAC_16k, L_SUBFR, &tmp ); + preemph_fx( tmp_fl+M, PREEMPH_FAC_16k, L_SUBFR, &tmp ); syn_filt_s_lc_fx(0, Ap, tmp_fl+M, tmp_fl+M, L_SUBFR); Residu3_lc_fx( p_Aq, M, tmp_fl+M, cn, L_SUBFR, 1 ); diff --git a/lib_enc/enc_nelp_fx.c b/lib_enc/enc_nelp_fx.c index 7999c8c1145f59c90fb364f2ef855edd9dcd3a1f..202704e6175d06d784d013d7372473282fea591d 100644 --- a/lib_enc/enc_nelp_fx.c +++ b/lib_enc/enc_nelp_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "cnst_fx.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*==============================================================================*/ /* FUNCTION : encod_nelp_fx() */ @@ -69,7 +67,7 @@ void encod_nelp_fx( Word16 reduce_gains = 0; - IF ( sub(st_fx->bwidth_fx, NB) == 0 && L_sub(st_fx->input_Fs_fx, 16000) >= 0) + IF ( EQ_16(st_fx->bwidth_fx, NB)&&GE_32(st_fx->input_Fs_fx,16000)) { IF (st_fx->last_nelp_mode_fx == 0) { @@ -105,7 +103,7 @@ void encod_nelp_fx( IF (i_subfr == 0) { test(); - IF ( sub(st_fx->Local_VAD, 1 ) == 0 && sub( st_fx->bwidth_fx, NB) == 0 ) + IF ( EQ_16(st_fx->Local_VAD, 1 )&&EQ_16(st_fx->bwidth_fx,NB)) { reduce_gains = 1; } diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index c7e48a855f3ff7f454f1d87c5087e090410cfb34..f2550a6d2982fba86300015fd913e3253cc3e8f0 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -9,8 +9,6 @@ #include "stl.h" -#include "wmc_auto.h" - /*======================================================================*/ /* FUNCTION : enc_pit_exc_fx() */ @@ -143,7 +141,7 @@ void enc_pit_exc_fx( * ACELP subframe loop *------------------------------------------------------------------*/ cn = NULL; - if(sub(L_subfr, L_SUBFR)==0) + if(EQ_16(L_subfr, L_SUBFR)) { cn = cn1; move16(); @@ -198,7 +196,7 @@ void enc_pit_exc_fx( lp_select = lp_filt_exc_enc_fx( MODE1, st_fx->core_brate_fx, 0, AUDIO, i_subfr, exc, h1, xn, y1, xn2, L_subfr, L_FRAME, g_corr, clip_gain, &gain_pit, &lp_flag ); - IF( sub(lp_flag,NORMAL_OPERATION) == 0 ) + IF( EQ_16(lp_flag,NORMAL_OPERATION)) { push_indice_fx( st_fx, IND_LP_FILT_SELECT, lp_select, 1 ); } @@ -210,7 +208,7 @@ void enc_pit_exc_fx( gpit_tmp = gain_pit; move16(); /*Q14*/ test(); - IF( st_fx->GSC_noisy_speech_fx == 0 || sub(L_subfr,L_SUBFR ) != 0 ) + IF( st_fx->GSC_noisy_speech_fx == 0 || NE_16(L_subfr,L_SUBFR )) { pit_idx = vquant_fx( &gain_pit, mean_gp_fx, &gain_pit, dic_gp_fx, 1, 16 ); push_indice_fx( st_fx, IND_PIT_IDX, pit_idx, 4 ); @@ -302,7 +300,7 @@ void enc_pit_exc_fx( *-----------------------------------------------------------------*/ Syn_filt_s( 1, p_Aq, M, &exc[i_subfr], &synth[i_subfr], L_subfr, st_fx->mem_syn_tmp_fx, 1 ); - IF( sub(L_subfr,2*L_SUBFR) == 0 ) + IF( EQ_16(L_subfr,2*L_SUBFR)) { IF( i_subfr == 0 ) { @@ -321,7 +319,7 @@ void enc_pit_exc_fx( move16(); pt_pitch++; } - ELSE IF(sub(L_subfr,4*L_SUBFR) == 0 ) + ELSE IF(EQ_16(L_subfr,4*L_SUBFR)) { cum_gpit = gpit_tmp; move16(); diff --git a/lib_enc/enc_ppp_fx.c b/lib_enc/enc_ppp_fx.c index 536c36e6346b46c9a09018cf50382e3991d9e94c..e2ad04801e12058f48f0ab5ec4f207af8d0747bc 100644 --- a/lib_enc/enc_ppp_fx.c +++ b/lib_enc/enc_ppp_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "cnst_fx.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*Temporary location to be move in prot* when merge is done */ void E_LPC_f_lsp_a_conversion(const Word16 *lsp, Word16 *a, const Word16 m); @@ -128,14 +126,14 @@ void encod_ppp_fx( LPC_de_curr_fx, exc_fx, pitch_fx, st_fx->vadsnr_fx, Q_new ); Scale_sig(exc_fx, L_FRAME, (saved_Q_new - Q_new)); - if (sub(st_fx->bump_up_fx,1) == 0) + if (EQ_16(st_fx->bump_up_fx,1)) { i_subfr = L_FRAME; move16(); } } - IF( sub(st_fx->bump_up_fx,1) != 0 ) + IF( NE_16(st_fx->bump_up_fx,1)) { /*-----------------------------------------------------------------* * Gain clipping test to avoid unstable synthesis on frame erasure diff --git a/lib_enc/enc_prm.c b/lib_enc/enc_prm.c index 1af8f2970f897ca7b595b5002ebc57a26d6e257e..7ea18222b17edd2311732fb8d1374e2d886f20ef 100644 --- a/lib_enc/enc_prm.c +++ b/lib_enc/enc_prm.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -9,8 +9,6 @@ #include "options.h" #include "rom_com_fx.h" #include "stl.h" -#include "wmc_auto.h" - #include "prot_fx.h" @@ -24,7 +22,7 @@ static void enc_prm_hm( /* Disable HM for non-GC,VC modes */ test(); - IF (sub(st->tcx_cfg.coder_type, VOICED) != 0 && sub(st->tcx_cfg.coder_type, GENERIC) != 0) + IF (NE_16(st->tcx_cfg.coder_type, VOICED)&&NE_16(st->tcx_cfg.coder_type,GENERIC)) { return; } @@ -37,14 +35,14 @@ static void enc_prm_hm( /* Periodicy index */ flag = 0; move16(); - if ( sub(L_frame, 256) >= 0) + if ( GE_16(L_frame, 256)) { flag = 1; move16(); } EncodeIndex(flag, prm_hm[1], st); - IF (sub(st->tcx_cfg.coder_type, VOICED) == 0) + IF (EQ_16(st->tcx_cfg.coder_type, VOICED)) { /* Gain index */ push_next_indice_fx(st, prm_hm[2], kTcxHmNumGainBits); @@ -71,12 +69,12 @@ void enc_prm_rf( Encoder_State_fx *st, /* partial copy bitstream writing */ test(); - IF ( sub(rf_frame_type,RF_TCXFD) >= 0 && sub(rf_frame_type,RF_TCXTD2) <= 0) + IF ( GE_16(rf_frame_type,RF_TCXFD)&&LE_16(rf_frame_type,RF_TCXTD2)) { /* TCX frames partial copy write */ /* LSF indices */ - IF( sub(rf_frame_type, RF_TCXFD) == 0 ) + IF( EQ_16(rf_frame_type, RF_TCXFD)) { push_next_indice_fx(st, st->rf_indx_lsf[fec_offset][0], lsf_numbits[0]); /* VQ 1 */ push_next_indice_fx(st, st->rf_indx_lsf[fec_offset][1], lsf_numbits[1]); /* VQ 2 */ @@ -86,17 +84,17 @@ void enc_prm_rf( Encoder_State_fx *st, /* classification */ test(); test(); - IF( sub(st->rf_clas[fec_offset], UNVOICED_CLAS) == 0 ) + IF( EQ_16(st->rf_clas[fec_offset], UNVOICED_CLAS)) { index = 0; move16(); } - ELSE IF( (sub(st->rf_clas[fec_offset], VOICED_TRANSITION) == 0) || (sub(st->rf_clas[fec_offset], UNVOICED_TRANSITION) == 0) ) + ELSE IF( (EQ_16(st->rf_clas[fec_offset], VOICED_TRANSITION))||(EQ_16(st->rf_clas[fec_offset],UNVOICED_TRANSITION))) { index = 1; move16(); } - ELSE IF( sub(st->rf_clas[fec_offset], VOICED_CLAS) == 0 ) + ELSE IF( EQ_16(st->rf_clas[fec_offset], VOICED_CLAS)) { index = 2; move16(); @@ -108,7 +106,7 @@ void enc_prm_rf( Encoder_State_fx *st, } push_next_indice_fx(st, index, 2); - IF( sub(rf_frame_type, RF_TCXFD) == 0 ) + IF( EQ_16(rf_frame_type, RF_TCXFD)) { /* TCX global gain = 7 bits */ push_next_indice_fx(st, st->rf_gain_tcx[fec_offset], 7); @@ -125,13 +123,13 @@ void enc_prm_rf( Encoder_State_fx *st, /* pitch and gain */ /* LTP data */ test(); - IF ( (sub(rf_frame_type, RF_TCXTD1) == 0 || sub(rf_frame_type, RF_TCXTD2) == 0) && st->tcxltp != 0 ) + IF ( (EQ_16(rf_frame_type, RF_TCXTD1)||EQ_16(rf_frame_type,RF_TCXTD2))&&st->tcxltp!=0) { push_next_indice_fx(st, st->rf_tcxltp_param[fec_offset], 9); } } } - ELSE IF( sub(rf_frame_type,7) == 0 ) /* NELP bitstream writing */ + ELSE IF( EQ_16(rf_frame_type,7)) /* NELP bitstream writing */ { /* LSF indices */ push_next_indice_fx(st, st->rf_indx_lsf[fec_offset][0], 8); /* VQ 1 */ @@ -148,7 +146,7 @@ void enc_prm_rf( Encoder_State_fx *st, /* tbe gainFr */ push_next_indice_fx( st, st->rf_indx_tbeGainFr[fec_offset], 5 ); } - ELSE IF ( sub(rf_frame_type,4) >= 0 ) /* rf_frame_type ALL_PRED: 4, NO_PRED: 5, GEN_PRED: 6 */ + ELSE IF ( GE_16(rf_frame_type,4)) /* rf_frame_type ALL_PRED: 4, NO_PRED: 5, GEN_PRED: 6 */ { /* LSF indices */ push_next_indice_fx(st, st->rf_indx_lsf[fec_offset][0], 8); /* VQ 1 */ @@ -172,7 +170,7 @@ void enc_prm_rf( Encoder_State_fx *st, } /* Adaptive codebook filtering (1 bit) */ - IF( sub(ltf_mode,2) == 0 ) + IF( EQ_16(ltf_mode,2)) { push_next_indice_fx(st, st->rf_indx_ltfMode[fec_offset][sfr], 1); } @@ -181,16 +179,16 @@ void enc_prm_rf( Encoder_State_fx *st, test(); test(); test(); - IF( (sub(rf_frame_type,RF_NOPRED) == 0) || - (sub(rf_frame_type,RF_GENPRED) == 0 && - (sfr == 0 || sub(sfr,2) == 0)) ) + IF( (EQ_16(rf_frame_type,RF_NOPRED))|| + (EQ_16(rf_frame_type,RF_GENPRED) && + (sfr == 0 || EQ_16(sfr,2))) ) { push_next_indice_fx(st, st->rf_indx_fcb[fec_offset][sfr], 7); } /* Gains (5b, 6b or 7b / subfr) */ test(); - IF( sfr == 0 || sub(sfr,2) == 0 ) + IF( sfr == 0 || EQ_16(sfr,2)) { n = ACELP_GAINS_BITS[gains_mode]; push_next_indice_fx(st, st->rf_indx_gain[fec_offset][sfr], n); @@ -209,11 +207,11 @@ void enc_prm_rf( Encoder_State_fx *st, /* write FEC offset just before the rf_frame_type */ test(); test(); - IF(sub(fec_offset,2) == 0 ) + IF(EQ_16(fec_offset,2)) { push_next_indice_fx(st, 0, 2); } - ELSE IF(sub(fec_offset,3) == 0 || sub(fec_offset,5) == 0 || sub(fec_offset,7) == 0) + ELSE IF(EQ_16(fec_offset,3)||EQ_16(fec_offset,5)||EQ_16(fec_offset,7)) { push_next_indice_fx(st, (fec_offset - 1)/2, 2); } @@ -303,7 +301,7 @@ void enc_prm( * HEADER *--------------------------------------------------------------------------------*/ - IF (sub(st->mdct_sw, MODE1) == 0) + IF (EQ_16(st->mdct_sw, MODE1)) { /* Adjust st->bits_frame_core not to subtract MODE2 bandwidth signaling */ st->bits_frame_core = add(st->bits_frame_core, FrameSizeConfig[st->frame_size_index].bandwidth_bits); @@ -321,17 +319,17 @@ void enc_prm( index = 3; move16(); test(); - IF( sub(st->clas_fx, UNVOICED_CLAS) == 0 ) + IF( EQ_16(st->clas_fx, UNVOICED_CLAS)) { index = 0; move16(); } - ELSE IF( (sub(st->clas_fx, VOICED_TRANSITION) == 0) || (sub(st->clas_fx, UNVOICED_TRANSITION) == 0) ) + ELSE IF( (EQ_16(st->clas_fx, VOICED_TRANSITION))||(EQ_16(st->clas_fx,UNVOICED_TRANSITION))) { index = 1; move16(); } - ELSE IF( sub(st->clas_fx, VOICED_CLAS) == 0 ) + ELSE IF( EQ_16(st->clas_fx, VOICED_CLAS)) { index = 2; move16(); @@ -344,11 +342,11 @@ void enc_prm( IF ( core==ACELP_CORE ) { /* write the RF signalling information */ - IF( sub(st->rf_mode,1) == 0) + IF( EQ_16(st->rf_mode,1)) { /* find the section in the ACELP signalling table corresponding to bitrate */ idx = 0; - WHILE ( L_sub(acelp_sig_tbl[idx],st->total_brate_fx) != 0 ) /* total bitrate is kept at 13.2kbps */ + WHILE ( NE_32(acelp_sig_tbl[idx],st->total_brate_fx)) /* total bitrate is kept at 13.2kbps */ { idx = add(idx,1); } @@ -360,7 +358,7 @@ void enc_prm( idx = add(idx,1); start_idx = idx; tmp32 = SIG2IND_fx(coder_type, st->bwidth_fx, st->sharpFlag, st->rf_mode); - WHILE( L_sub(acelp_sig_tbl[idx], tmp32) != 0 ) + WHILE( NE_32(acelp_sig_tbl[idx], tmp32)) { idx = add(idx,1); } @@ -375,14 +373,14 @@ void enc_prm( } ELSE { - IF (sub(st->mdct_sw, MODE1) == 0) + IF (EQ_16(st->mdct_sw, MODE1)) { /* 2 bits instead of 3 as TCX is already signaled */ push_next_indice_fx(st, st->tcx_cfg.coder_type, 2 ); } ELSE { - IF (sub(st->mdct_sw_enable, MODE2) == 0) + IF (EQ_16(st->mdct_sw_enable, MODE2)) { push_next_indice_fx(st, 1, 1); /* TCX */ push_next_indice_fx(st, 0, 1); /* not HQ_CORE */ @@ -391,11 +389,11 @@ void enc_prm( ELSE { /*write the RF signalling information*/ - IF( sub(st->rf_mode,1) == 0) + IF( EQ_16(st->rf_mode,1)) { /* find the section in the ACELP signalling table corresponding to bitrate */ idx = 0; - WHILE (L_sub(acelp_sig_tbl[idx],st->total_brate_fx) != 0) + WHILE (NE_32(acelp_sig_tbl[idx],st->total_brate_fx)) { idx = add(idx,1); } @@ -405,9 +403,9 @@ void enc_prm( test(); test(); - IF(sub(st->tcx_cfg.coder_type,VOICED) == 0 || - sub(st->tcx_cfg.coder_type,GENERIC) == 0 || - sub(st->tcx_cfg.coder_type,TRANSITION) == 0) + IF(EQ_16(st->tcx_cfg.coder_type,VOICED)|| + EQ_16(st->tcx_cfg.coder_type,GENERIC)|| + EQ_16(st->tcx_cfg.coder_type,TRANSITION)) { st->sharpFlag=1; } @@ -420,7 +418,7 @@ void enc_prm( idx = add(idx,1); start_idx = idx; tmp32 = SIG2IND_fx(st->tcx_cfg.coder_type, st->bwidth_fx, st->sharpFlag, st->rf_mode); - WHILE( L_sub(acelp_sig_tbl[idx], tmp32)!= 0 ) + WHILE( NE_32(acelp_sig_tbl[idx], tmp32)) { idx = add(idx,1); } @@ -444,7 +442,7 @@ void enc_prm( tmp = 0; move16(); test(); - IF( sub(last_core, ACELP_CORE) != 0 || sub(core, TCX_10_CORE) == 0 ) + IF( NE_16(last_core, ACELP_CORE)||EQ_16(core,TCX_10_CORE)) { tmp = TCX_20_CORE; @@ -458,14 +456,14 @@ void enc_prm( { Word16 overlap_code; assert(st->tcx_cfg.tcx_curr_overlap_mode != NOT_SUPPORTED && st->tcx_cfg.tcx_curr_overlap_mode <= ALDO_WINDOW && st->tcx_cfg.tcx_curr_overlap_mode >= FULL_OVERLAP); /*1 is not allowed!*/ - IF (sub(st->tcx_cfg.tcx_curr_overlap_mode, MIN_OVERLAP) == 0) + IF (EQ_16(st->tcx_cfg.tcx_curr_overlap_mode, MIN_OVERLAP)) { nbits_tcx = 2; move16(); overlap_code = 2; move16(); } - ELSE IF (sub(st->tcx_cfg.tcx_curr_overlap_mode, HALF_OVERLAP) == 0) + ELSE IF (EQ_16(st->tcx_cfg.tcx_curr_overlap_mode, HALF_OVERLAP)) { nbits_tcx = 2; move16(); @@ -494,13 +492,13 @@ void enc_prm( test(); test(); test(); - if (core != ACELP_CORE || sub(coder_type,INACTIVE) == 0 || (st->last_core_fx == ACELP_CORE && sub(st->last_coder_type_raw_fx, INACTIVE) == 0) || st->glr_reset != 0) + if (core != ACELP_CORE || EQ_16(coder_type,INACTIVE)||(st->last_core_fx==ACELP_CORE&&EQ_16(st->last_coder_type_raw_fx,INACTIVE))||st->glr_reset!=0) { st->glr_idx[0] = 0; move16(); } - IF( sub(core,ACELP_CORE) == 0 ) + IF( EQ_16(core,ACELP_CORE)) { push_next_indice_fx(st, st->glr_idx[0], G_LPC_RECOVERY_BITS); } @@ -528,7 +526,7 @@ void enc_prm( /* LPC quantizer */ numlpc = 2; move16(); - if(sub(core, TCX_20_CORE) == 0) + if(EQ_16(core, TCX_20_CORE)) { numlpc = 1; move16(); @@ -536,11 +534,11 @@ void enc_prm( nbits_lpc = encode_lpc_avq(st, numlpc, param_lpc, core); } - ELSE IF (sub(st->lpcQuantization, 1)==0) + ELSE IF (EQ_16(st->lpcQuantization, 1)) { test(); test(); - IF(L_sub(st->sr_core, 16000)==0 && sub(coder_type, VOICED) == 0 && sub(core, ACELP_CORE) == 0) + IF(EQ_32(st->sr_core, 16000)&&EQ_16(coder_type,VOICED)&&EQ_16(core,ACELP_CORE)) { nbits_lpc = lsf_bctcvq_encprm(st, param_lpc, bits_param_lpc, no_param_lpc); } @@ -599,7 +597,7 @@ void enc_prm( /* Adaptive codebook filtering (1 bit) */ - IF(sub(st->acelp_cfg.ltf_mode,2)==0) + IF(EQ_16(st->acelp_cfg.ltf_mode,2)) { push_next_indice_fx(st, prm[j++], 1); } @@ -644,7 +642,7 @@ void enc_prm( /*--------------------------------------------------------------------------------* * TCX20 *--------------------------------------------------------------------------------*/ - IF ( s_or(sub(core,TCX_20_CORE) == 0, sub(core,HQ_CORE) == 0) ) + IF ( s_or((Word16)EQ_16(core,TCX_20_CORE),(Word16)EQ_16(core,HQ_CORE))) { flag_ctx_hm = 0; move16(); @@ -661,7 +659,7 @@ void enc_prm( /* LTP data */ test(); - IF ( st->tcxltp || L_sub(st->sr_core, 25600) > 0) + IF ( st->tcxltp || GT_32(st->sr_core, 25600)) { IF ( prm[j] ) { @@ -707,14 +705,14 @@ void enc_prm( hm_size = shl(mult(st->tcx_cfg.bandwidth, lg), 1); test(); - IF ( st->tcx_lpc_shaped_ari && sub(last_core, ACELP_CORE) != 0 ) + IF ( st->tcx_lpc_shaped_ari && NE_16(last_core, ACELP_CORE)) { enc_prm_hm(&prm[j], st, hm_size); } /*Context HM flag*/ test(); - IF ( st->tcx_cfg.ctx_hm && sub(last_core, ACELP_CORE) != 0 ) + IF ( st->tcx_cfg.ctx_hm && NE_16(last_core, ACELP_CORE)) { push_next_indice_fx(st, prm[j], 1); @@ -731,7 +729,7 @@ void enc_prm( { st->hIGFEnc.infoTotalBitsPerFrameWritten = 0; move16(); - IF (sub(st->last_core_fx, ACELP_CORE) == 0) + IF (EQ_16(st->last_core_fx, ACELP_CORE)) { IGFEncWriteBitstream( &st->hIGFEnc, st, &st->hIGFEnc.infoTotalBitsPerFrameWritten, IGF_GRID_LB_TRAN, 1 ); @@ -743,7 +741,7 @@ void enc_prm( } } total_nbbits = sub(st->nb_bits_tot_fx, nbits_start); - if(sub(st->rf_mode,1)==0) + if(EQ_16(st->rf_mode,1)) { total_nbbits = add(total_nbbits,st->rf_target_bits_write); } @@ -777,7 +775,7 @@ void enc_prm( *--------------------------------------------------------------------------------*/ - IF (sub(core,TCX_10_CORE) == 0) + IF (EQ_16(core,TCX_10_CORE)) { Word16 nbits_igf = 0; move16(); @@ -814,7 +812,7 @@ void enc_prm( /* LTP data */ test(); test(); - IF ( (k == 0) && (st->tcxltp!=0 || L_sub(st->sr_core, 25600) > 0 ) )/* PLC pitch info for HB */ + IF ( (k == 0) && (st->tcxltp!=0 || GT_32(st->sr_core, 25600)))/* PLC pitch info for HB */ { IF ( prm[j] ) { diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index 86b31b3ee7f1a2d759098091b2b8bfd6f1c289ef..e0bf4b909bd7f9b7876de1a349e4831401b3e5fa 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -8,8 +8,6 @@ #include "stl.h" -#include "wmc_auto.h" - /*=================================================================================*/ /* FUNCTION : void encod_tran_fx () */ @@ -109,7 +107,7 @@ Word16 encod_tran_fx( move16(); unbits_PI = 0; move16(); - IF( sub(L_frame_fx,L_FRAME) == 0 ) + IF( EQ_16(L_frame_fx,L_FRAME)) { T0_max = PIT_MAX; move16(); @@ -178,7 +176,7 @@ Word16 encod_tran_fx( * Transform domain contribution encoding - active frames *-----------------------------------------------------------------*/ - IF( L_sub(st_fx->core_brate_fx,ACELP_24k40) > 0 ) + IF( GT_32(st_fx->core_brate_fx,ACELP_24k40)) { transf_cdbk_enc_fx( st_fx, st_fx->core_brate_fx, st_fx->extl_fx, coder_type, 0, i_subfr, tc_subfr, cn, exc_fx, p_Aq, Aw_fx, h1, xn, xn2, y1, y2, Es_pred_fx, &gain_pit, gain_code, g_corr, clip_gain, @@ -195,7 +193,7 @@ Word16 encod_tran_fx( test(); test(); test(); - if( (sub(st_fx->L_frame_fx,L_FRAME16k) == 0) && (tc_subfr == 0) && (sub(i_subfr,L_SUBFR) == 0) && (sub(T0,2*L_SUBFR) == 0) ) + if( (EQ_16(st_fx->L_frame_fx,L_FRAME16k))&&(tc_subfr==0)&&(EQ_16(i_subfr,L_SUBFR))&&(EQ_16(T0,2*L_SUBFR))) { Jopt_flag = 1; move16(); @@ -213,7 +211,7 @@ Word16 encod_tran_fx( } ELSE { - IF ( L_sub(st_fx->core_brate_fx,ACELP_32k) > 0 ) + IF ( GT_32(st_fx->core_brate_fx,ACELP_32k)) { /* SQ gain_pit and gain_code */ gain_enc_SQ_fx( st_fx, st_fx->core_brate_fx, coder_type, i_subfr, tc_subfr, xn, y1, y2, code, Es_pred_fx, @@ -289,7 +287,7 @@ Word16 encod_tran_fx( * Add the ACELP pre-quantizer contribution *-----------------------------------------------------------------*/ - IF( L_sub(st_fx->core_brate_fx,ACELP_24k40) > 0 ) + IF( GT_32(st_fx->core_brate_fx,ACELP_24k40)) { tmp1_fx = add(16-(2+Q_AVQ_OUT_DEC+1),Q_new); FOR( i = 0; i < L_SUBFR; i++ ) @@ -333,46 +331,46 @@ Word16 encod_tran_fx( } /* write TC configuration */ - IF( sub(L_frame_fx,L_FRAME) == 0 ) + IF( EQ_16(L_frame_fx,L_FRAME)) { - IF( sub(tc_subfr,TC_0_0) == 0 ) + IF( EQ_16(tc_subfr,TC_0_0)) { push_indice_fx( st_fx, IND_TC_SUBFR, 1, 1 ); } - ELSE IF( sub(tc_subfr,TC_0_64) == 0 ) + ELSE IF( EQ_16(tc_subfr,TC_0_64)) { push_indice_fx( st_fx, IND_TC_SUBFR, 0, 1 ); push_indice_fx( st_fx, IND_TC_SUBFR, 1, 1 ); push_indice_fx( st_fx, IND_TC_SUBFR, 0, 1 ); push_indice_fx( st_fx, IND_TC_SUBFR, 1, 1 ); } - ELSE IF( sub(tc_subfr,TC_0_128) == 0 ) + ELSE IF( EQ_16(tc_subfr,TC_0_128)) { push_indice_fx( st_fx, IND_TC_SUBFR, 0, 1 ); push_indice_fx( st_fx, IND_TC_SUBFR, 1, 1 ); push_indice_fx( st_fx, IND_TC_SUBFR, 0, 1 ); push_indice_fx( st_fx, IND_TC_SUBFR, 0, 1 ); } - ELSE IF( sub(tc_subfr,TC_0_192) == 0 ) + ELSE IF( EQ_16(tc_subfr,TC_0_192)) { push_indice_fx( st_fx, IND_TC_SUBFR, 0, 1 ); push_indice_fx( st_fx, IND_TC_SUBFR, 1, 1 ); push_indice_fx( st_fx, IND_TC_SUBFR, 1, 1 ); } - ELSE IF( sub(tc_subfr,L_SUBFR) == 0 ) + ELSE IF( EQ_16(tc_subfr,L_SUBFR)) { push_indice_fx( st_fx, IND_TC_SUBFR, 0, 1 ); push_indice_fx( st_fx, IND_TC_SUBFR, 0, 1 ); push_indice_fx( st_fx, IND_TC_SUBFR, 1, 1 ); } - ELSE IF( sub(tc_subfr,2*L_SUBFR) == 0 ) + ELSE IF( EQ_16(tc_subfr,2*L_SUBFR)) { push_indice_fx( st_fx, IND_TC_SUBFR, 0, 1 ); push_indice_fx( st_fx, IND_TC_SUBFR, 0, 1 ); push_indice_fx( st_fx, IND_TC_SUBFR, 0, 1 ); push_indice_fx( st_fx, IND_TC_SUBFR, 1, 1 ); } - ELSE IF( sub(tc_subfr,3*L_SUBFR) == 0 ) + ELSE IF( EQ_16(tc_subfr,3*L_SUBFR)) { push_indice_fx( st_fx, IND_TC_SUBFR, 0, 1 ); push_indice_fx( st_fx, IND_TC_SUBFR, 0, 1 ); @@ -387,20 +385,20 @@ Word16 encod_tran_fx( { push_indice_fx( st_fx, IND_TC_SUBFR, 0, 2 ); } - ELSE IF( sub(tc_subfr,L_SUBFR) == 0 ) + ELSE IF( EQ_16(tc_subfr,L_SUBFR)) { push_indice_fx( st_fx, IND_TC_SUBFR, 1, 2 ); } - ELSE IF( sub(tc_subfr,2*L_SUBFR) == 0 ) + ELSE IF( EQ_16(tc_subfr,2*L_SUBFR)) { push_indice_fx( st_fx, IND_TC_SUBFR, 2, 2 ); } - ELSE IF( sub(tc_subfr,3*L_SUBFR) == 0 ) + ELSE IF( EQ_16(tc_subfr,3*L_SUBFR)) { push_indice_fx( st_fx, IND_TC_SUBFR, 3, 2 ); push_indice_fx( st_fx, IND_TC_SUBFR, 0, 1 ); } - ELSE IF( sub(tc_subfr,4*L_SUBFR) == 0 ) + ELSE IF( EQ_16(tc_subfr,4*L_SUBFR)) { push_indice_fx( st_fx, IND_TC_SUBFR, 3, 2 ); push_indice_fx( st_fx, IND_TC_SUBFR, 1, 1 ); diff --git a/lib_enc/enc_uv_fx.c b/lib_enc/enc_uv_fx.c index bcc926b73c3870694cb087e27f5dc3e0ce394640..830a36cea7d9f1dbbd1d69e73b62f29681604f36 100644 --- a/lib_enc/enc_uv_fx.c +++ b/lib_enc/enc_uv_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "cnst_fx.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*-------------------------------------------------------------------* * encod_unvoiced() @@ -55,7 +53,7 @@ void encod_unvoiced_fx( test(); test(); test(); - IF( st_fx->Opt_SC_VBR_fx && vad_flag_fx == 0 && (sub(st_fx->last_ppp_mode_fx,1) == 0 || sub(st_fx->last_nelp_mode_fx,1) == 0) ) + IF( st_fx->Opt_SC_VBR_fx && vad_flag_fx == 0 && (EQ_16(st_fx->last_ppp_mode_fx,1)||EQ_16(st_fx->last_nelp_mode_fx,1))) { /* SC_VBR - reset the encoder, to avoid memory not updated issue for the case when UNVOICED mode is used to code inactive speech */ diff --git a/lib_enc/encoder.c b/lib_enc/encoder.c index bff23610834954b6e1645ce93a13b158892ebe0e..c5dce16f66e7232f30c5887ad5b4a69250e904a2 100644 --- a/lib_enc/encoder.c +++ b/lib_enc/encoder.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ @@ -17,16 +17,10 @@ #include "g192.h" #include "stat_enc_fx.h" #include "prot_fx.h" -#include "wmc_auto.h" - -#define WMC_TOOL_SKIP /*------------------------------------------------------------------------------------------* * Global variables *------------------------------------------------------------------------------------------*/ -#if !defined( DEBUGGING ) && !defined( WMOPS ) -static -#endif long frame = 0; /* Counter of frames */ /*------------------------------------------------------------------------------------------* @@ -60,10 +54,8 @@ int main( int argc, char** argv ) Word16 pFrame_size = 0; -#ifdef WMOPS - reset_wmops(); - reset_mem(USE_BYTES); -#endif + /* start WMOPS counting */ + BASOP_init /*Inits*/ f_bwidth = f_rate = NULL; @@ -110,11 +102,6 @@ int main( int argc, char** argv ) } -#ifdef WMOPS - reset_stack(); - reset_wmops(); -#endif - /*------------------------------------------------------------------------------------------* * Loop for every frame of input data * - Read the input data @@ -122,6 +109,15 @@ int main( int argc, char** argv ) * - Run the encoder * - Write the parameters into output bitstream file *------------------------------------------------------------------------------------------*/ + BASOP_end_noprint; + BASOP_init; + +#if (WMOPS) + Init_WMOPS_counter(); + Reset_WMOPS_counter(); + setFrameRate(48000, 960); +#endif + if (quietMode == 0) { @@ -137,6 +133,11 @@ int main( int argc, char** argv ) /*Encode-a-frame loop start*/ while( (n_samples = (short)fread(data, sizeof(short), input_frame, f_input)) > 0 ) { +#if (WMOPS) + Reset_WMOPS_counter(); +#endif + SUB_WMOPS_INIT("enc"); + IF(f_rf != NULL) { read_next_rfparam_fx( @@ -157,10 +158,10 @@ int main( int argc, char** argv ) read_next_bwidth_fx( &st_fx->max_bwidth_fx, f_bwidth, &bwidth_profile_cnt, st_fx->input_Fs_fx ); } - IF( ( st_fx->Opt_RF_ON && ( L_sub( st_fx->total_brate_fx, ACELP_13k20 ) != 0 || L_sub( st_fx->input_Fs_fx, 8000 ) == 0 || st_fx->max_bwidth_fx == NB ) ) + IF( ( st_fx->Opt_RF_ON && ( NE_32( st_fx->total_brate_fx, ACELP_13k20 )||EQ_32(st_fx->input_Fs_fx,8000)||st_fx->max_bwidth_fx==NB)) || st_fx->rf_fec_offset == 0 ) { - IF( L_sub( st_fx->total_brate_fx, ACELP_13k20) == 0 ) + IF( EQ_32( st_fx->total_brate_fx, ACELP_13k20)) { st_fx->codec_mode = MODE1; reset_rf_indices(st_fx); @@ -170,7 +171,7 @@ int main( int argc, char** argv ) } - IF( Opt_RF_ON_loc && rf_fec_offset_loc != 0 && L_sub( st_fx->total_brate_fx, ACELP_13k20 ) == 0 && L_sub( st_fx->input_Fs_fx, 8000 ) != 0 && st_fx->max_bwidth_fx != NB ) + IF( Opt_RF_ON_loc && rf_fec_offset_loc != 0 && EQ_32( st_fx->total_brate_fx, ACELP_13k20 )&&NE_32(st_fx->input_Fs_fx,8000)&&st_fx->max_bwidth_fx!=NB) { st_fx->codec_mode = MODE2; IF(st_fx->Opt_RF_ON == 0) @@ -182,7 +183,7 @@ int main( int argc, char** argv ) } /* in case of 8kHz sampling rate or when in "max_band NB" mode, limit the total bitrate to 24.40 kbps */ - IF ( (L_sub( st_fx->input_Fs_fx, 8000 ) == 0 || (st_fx->max_bwidth_fx == NB)) && L_sub( st_fx->total_brate_fx, ACELP_24k40 ) > 0 ) + IF ( (EQ_32( st_fx->input_Fs_fx, 8000 )||(st_fx->max_bwidth_fx==NB))&>_32(st_fx->total_brate_fx,ACELP_24k40)) { st_fx->total_brate_fx = ACELP_24k40; st_fx->codec_mode = MODE2; @@ -194,16 +195,16 @@ int main( int argc, char** argv ) IF ( st_fx->Opt_AMR_WB_fx ) { - push_wmops("amr_wb_enc"); + SUB_WMOPS_INIT("amr_wb_enc"); amr_wb_enc_fx( st_fx, data, n_samples); - pop_wmops(); + END_SUB_WMOPS; } ELSE { - push_wmops("evs_enc"); + SUB_WMOPS_INIT("evs_enc"); /* EVS encoder*/ evs_enc_fx( st_fx, data, n_samples); - pop_wmops(); + END_SUB_WMOPS; } /* pack indices into serialized payload format */ if( st_fx->bitstreamformat == MIME ) @@ -214,6 +215,10 @@ int main( int argc, char** argv ) /* write indices into bitstream file */ write_indices_fx( st_fx, f_stream, pFrame, pFrame_size ); + END_SUB_WMOPS; + /* update WMPOS counting (end of frame) */ + + fflush(stderr); frame++; @@ -222,9 +227,8 @@ int main( int argc, char** argv ) fprintf( stdout, "%-8ld\b\b\b\b\b\b\b\b", frame ); } -#ifdef WMOPS - update_mem(); - update_wmops(); +#if (WMOPS) + fwc(); #endif } /* ----- Encode-a-frame loop end ----- */ @@ -240,6 +244,20 @@ int main( int argc, char** argv ) fprintf(stderr, "Encoding of %ld frames finished\n\n", frame); } + + + +#if (WMOPS) + fwc(); + printf("\nEncoder complexity\n"); + WMOPS_output(0); + printf("\n"); +#endif + + /* Close Encoder, Close files and free ressources */ + BASOP_init + + IF(st_fx != NULL) { /* common delete function */ @@ -247,10 +265,8 @@ int main( int argc, char** argv ) free(st_fx); } -#ifdef WMOPS - print_wmops(); - print_mem(NULL); -#endif + BASOP_end_noprint + IF(f_input) fclose(f_input); diff --git a/lib_enc/energy.c b/lib_enc/energy.c index 976df3f107ec54c4d269a153562482e4c4f829b9..5e575b6d271a63c09ed9bd70a931733c3b7f13f2 100644 --- a/lib_enc/energy.c +++ b/lib_enc/energy.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ @@ -10,8 +10,6 @@ #include "basop_util.h" #include "stl.h" -#include "wmc_auto.h" - #include "rom_enc_fx.h" #include "vad_basop.h" #include "prot_fx.h" @@ -65,19 +63,19 @@ void est_energy( sb_power_tmp = L_shr(sb_power[0],shr_tmp); - IF(L_sub(bandwidth,1)==0) + IF(EQ_32(bandwidth,1)) { frame_energy = L_add(frame_energy2,MUL_F(sb_power_tmp,0x147a)); } - ELSE IF(L_sub(bandwidth,2)==0) + ELSE IF(EQ_32(bandwidth,2)) { frame_energy = L_add(frame_energy2,MUL_F(sb_power_tmp,0x1eb8)); } - ELSE IF(L_sub(bandwidth,3)==0) + ELSE IF(EQ_32(bandwidth,3)) { frame_energy = L_add(frame_energy2,MUL_F(sb_power_tmp,0x23d7)); } - ELSE IF(L_sub(bandwidth,4)==0) + ELSE IF(EQ_32(bandwidth,4)) { frame_energy = L_add(frame_energy2,MUL_F(sb_power_tmp,0x23d7)); } @@ -111,7 +109,8 @@ void est_energy( FOR(i=6; iframe_sb_energy; move32(); - t_bg_energy = L_add(st->t_bg_energy,0); + t_bg_energy = st->t_bg_energy; move32(); t_bg_energy_sum = st->t_bg_energy_sum; @@ -249,11 +248,11 @@ void background_update(T_CldfbVadState *st, /*(io) vad state*/ test(); test(); test(); - IF( (sub(st->frameloop, 60) < 0) && (sub(st->frameloop, 5) > 0) &&(sub(f_tonality_rate[0],9174/* 0.56 Q14 */)<0) - && (sub(f_tonality_rate[1],8192/* 0.5 Q14 */)<0) && (sub(ltd_stable_rate[1],1966/* 0.06 Q15 */)<0) - && L_sub(snr, 83886080) < 0) + IF( (LT_16(st->frameloop, 60))&&(GT_16(st->frameloop,5))&&(LT_16(f_tonality_rate[0],9174/* 0.56 Q14 */)) + && (LT_16(f_tonality_rate[1],8192/* 0.5 Q14 */)) && (LT_16(ltd_stable_rate[1],1966/* 0.06 Q15 */)) + && LT_32(snr, 83886080) ) { - IF( sub(st->frameloop, 50) < 0 ) + IF( LT_16(st->frameloop, 50) ) { exp_frame_energy_amendment.s32Mantissa = VAD_L_div(exp_frame_energy.s32Mantissa, 10, exp_frame_energy.s16Exp, 0, &q_divout); exp_frame_energy_amendment.s16Exp = q_divout; @@ -269,11 +268,11 @@ void background_update(T_CldfbVadState *st, /*(io) vad state*/ test(); test(); - IF((L_sub(update_flag,1)==0) && (sub(st->frameloop, 2) > 0) && music_backgound_f==0) + IF((EQ_32(update_flag,1))&&(GT_16(st->frameloop,2))&&music_backgound_f==0) { - IF(sub(st->bg_update_count, 16) < 0) + IF(LT_16(st->bg_update_count, 16)) { - IF( sub(st->frameloop, 50) < 0) + IF( LT_16(st->frameloop, 50) ) { exp_frame_energy_amendment.s32Mantissa = VAD_L_div(exp_frame_energy.s32Mantissa, 10, exp_frame_energy.s16Exp, 0, &q_divout); exp_frame_energy_amendment.s16Exp = q_divout; @@ -310,7 +309,7 @@ void background_update(T_CldfbVadState *st, /*(io) vad state*/ /*ELSE IF(L_sub(tmp, -1) == 0) fixed bug*/ ELSE IF(cmp_tmp < 0) { - IF(sub(st->frameloop, 50) < 0) + IF( LT_16(st->frameloop, 50) ) { exp_frame_energy_amendment.s32Mantissa = VAD_L_div(exp_frame_energy.s32Mantissa, 10, exp_frame_energy.s16Exp, 0, &q_divout); exp_frame_energy_amendment.s16Exp = q_divout; @@ -329,7 +328,7 @@ void background_update(T_CldfbVadState *st, /*(io) vad state*/ cmp_pre_frame = VAD_L_CMP(t_bg_energy, st->scale_t_bg_energy, exp_frame_energy.s32Mantissa, exp_frame_energy.s16Exp); IF(cmp_pre_frame>0) { - IF( sub(st->frameloop, 50) < 0 ) + IF( LT_16(st->frameloop, 50) ) { exp_frame_energy_amendment.s32Mantissa = VAD_L_div(exp_frame_energy.s32Mantissa, 10, exp_frame_energy.s16Exp, 0, &q_divout); exp_frame_energy_amendment.s16Exp = q_divout; @@ -345,7 +344,7 @@ void background_update(T_CldfbVadState *st, /*(io) vad state*/ } ELSE { - IF( sub(st->frameloop, 50) < 0 ) + IF( LT_16(st->frameloop, 50) ) { exp_frame_energy_amendment.s32Mantissa = VAD_L_div(exp_frame_energy.s32Mantissa, 10, exp_frame_energy.s16Exp, 0, &q_divout); exp_frame_energy_amendment.s16Exp = q_divout; @@ -411,7 +410,7 @@ void background_update(T_CldfbVadState *st, /*(io) vad state*/ test(); test(); test(); - IF( (sub(music_backgound_f, 1) == 0) && (L_sub(st->lt_snr_org, 107374179/* 3.2 Q25 */) < 0) + IF( (EQ_16(music_backgound_f, 1))&&(LT_32(st->lt_snr_org,107374179/* 3.2 Q25 */)) && (cmp_pre_frame > 0) && update_flag == 0) { tmp = L_shr(2147/* 0.000001 Q31 */, sub(31, scale_sb_energy)); @@ -422,7 +421,7 @@ void background_update(T_CldfbVadState *st, /*(io) vad state*/ } } - IF(sub(music_backgound_f,1) == 0) + IF(EQ_16(music_backgound_f,1)) { cmp_pre_frame = VAD_L_CMP(exp_frame_energy.s32Mantissa, exp_frame_energy.s16Exp, MUL_F(t_bg_energy, 5000), sub(st->scale_t_bg_energy, 15)); IF(cmp_pre_frame < 0) @@ -436,7 +435,7 @@ void background_update(T_CldfbVadState *st, /*(io) vad state*/ } } - IF( (L_sub(st->tbg_energy_count, 64) == 0)) + IF( (EQ_32(st->tbg_energy_count, 64))) { st->tbg_energy_count = 48; move16(); diff --git a/lib_enc/eval_pit_contr_fx.c b/lib_enc/eval_pit_contr_fx.c index cf2c0a71cc63443a6b948767be945a54f62cf990..2839a213a4e976ecbe693394928c96a9bfd6a080 100644 --- a/lib_enc/eval_pit_contr_fx.c +++ b/lib_enc/eval_pit_contr_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -7,8 +7,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*-------------------------------------------------------------------* * Local constantes @@ -80,7 +78,7 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pitch contribution is si Word16 norm; Word16 val_thrs; - if( sub(st_fx->L_frame_fx,L_FRAME16k) == 0) + if( EQ_16(st_fx->L_frame_fx,L_FRAME16k)) { Mbands_loc = MBANDS_LOC; move16(); @@ -167,7 +165,7 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pitch contribution is si move16(); av_corr = round_fx(L_shl(L_mult0(av_corr,6400),16-12)); /*Q14*Q0-12=Q2*/ - if( L_sub(st_fx->core_brate_fx,ACELP_9k60) < 0 ) + if( LT_32(st_fx->core_brate_fx,ACELP_9k60)) { av_corr = shl(av_corr,1); /*Q2 Correlation really poor at low rate, time domain still valide*/ } @@ -177,7 +175,7 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pitch contribution is si { ftmp = abs_s(sub(mfreq_loc_Q2fx[i],av_corr)); /*Q2*/ - IF(sub(ftmp,min_corr) < 0) + IF(LT_16(ftmp,min_corr)) { last_pit_band = i; move16(); @@ -186,23 +184,23 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pitch contribution is si } } - IF( sub(F8th_harm,mfreq_loc_Q2fx[last_pit_band]) > 0 ) + IF( GT_16(F8th_harm,mfreq_loc_Q2fx[last_pit_band])) { DO { last_pit_band = add(last_pit_band,1); } - WHILE( sub(F8th_harm,mfreq_loc_Q2fx[last_pit_band]) >= 0 ); + WHILE( GE_16(F8th_harm,mfreq_loc_Q2fx[last_pit_band])); } test(); test(); test(); - IF( sub(last_pit_band,7+BAND1k2) > 0 && (L_sub(st_fx->core_brate_fx,CFREQ_BITRATE) < 0 || sub(st_fx->bwidth_fx,NB) == 0) )/*Added for 9.1*/ + IF( GT_16(last_pit_band,7+BAND1k2)&&(LT_32(st_fx->core_brate_fx,CFREQ_BITRATE)||EQ_16(st_fx->bwidth_fx,NB)))/*Added for 9.1*/ { last_pit_band = 7+BAND1k2; move16(); } - ELSE IF ( sub(last_pit_band,10+BAND1k2) > 0 && L_sub(st_fx->core_brate_fx,CFREQ_BITRATE) >= 0 ) + ELSE IF ( GT_16(last_pit_band,10+BAND1k2)&&GE_32(st_fx->core_brate_fx,CFREQ_BITRATE)) { last_pit_band = add(10,BAND1k2); } @@ -219,10 +217,10 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pitch contribution is si test(); test(); test(); - IF( (st_fx->mem_last_pit_band_fx > 0 && sub(st_fx->old_corr_fx,16384) > 0 && sub(st_fx->mold_corr_fx,16384) > 0 && sub(st_fx->lt_gpitch_fx,19661) >= 0/*1.5f*GPIT_THR*/ ) - || (sub(last_pit_band,6) > 0) - || (sub(last_pit_band,4) >= 0 && sub(st_fx->lt_gpitch_fx,19661) >= 0/*1.5f*GPIT_THR*/ && sub(st_fx->old_corr_fx,22938) > 0) - || (sub(last_pit_band,BAND1k2) > 0 && sub(st_fx->mold_corr_fx,26214) > 0 && sub(st_fx->lt_gpitch_fx,13107) >= 0/*GPIT_THR*/) + IF( (st_fx->mem_last_pit_band_fx > 0 && GT_16(st_fx->old_corr_fx,16384)&>_16(st_fx->mold_corr_fx,16384)&&GE_16(st_fx->lt_gpitch_fx,19661)/*1.5f*GPIT_THR*/) + || (GT_16(last_pit_band,6) ) + || (GE_16(last_pit_band,4) && GE_16(st_fx->lt_gpitch_fx,19661) /*1.5f*GPIT_THR*/ && GT_16(st_fx->old_corr_fx,22938) ) + || (GT_16(last_pit_band,BAND1k2) && GT_16(st_fx->mold_corr_fx,26214) && GE_16(st_fx->lt_gpitch_fx,13107) /*GPIT_THR*/) ) { tmp_dec = 1; @@ -238,7 +236,7 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pitch contribution is si test(); test(); test(); - IF ( (st_fx->mem_last_pit_band_fx == 0 && sub(tmp_dec,1) == 0) || (st_fx->mem_last_pit_band_fx > 0 && tmp_dec == 0) ) + IF ( (st_fx->mem_last_pit_band_fx == 0 && EQ_16(tmp_dec,1))||(st_fx->mem_last_pit_band_fx>0&&tmp_dec==0)) { IF( *hangover == 0 ) { @@ -278,28 +276,28 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pitch contribution is si move16(); test(); test(); - IF( sub(time_flg,1) == 0 || sub(coder_type,INACTIVE) != 0 || st_fx->GSC_noisy_speech_fx ) + IF( EQ_16(time_flg,1)||NE_16(coder_type,INACTIVE)||st_fx->GSC_noisy_speech_fx) { test(); test(); /*if(st_fx->core_brate_fx core_brate_fx,ACELP_9k60) < 0 && sub(low_pit , 4096) < 0) + IF(LT_32(st_fx->core_brate_fx,ACELP_9k60)&<_16(low_pit,4096)) { last_pit_band = add(9 , BAND1k2); - if(sub(st_fx->bwidth_fx,NB) == 0) + if(EQ_16(st_fx->bwidth_fx,NB)) { last_pit_band = add(7,BAND1k2); } } - ELSE IF(L_sub(st_fx->core_brate_fx,ACELP_9k60) < 0 && sub(low_pit , 8192) < 0) + ELSE IF(LT_32(st_fx->core_brate_fx,ACELP_9k60)&<_16(low_pit,8192)) { last_pit_band = add(5 , BAND1k2); } - ELSE IF(L_sub(st_fx->core_brate_fx,ACELP_9k60) < 0 ) + ELSE IF(LT_32(st_fx->core_brate_fx,ACELP_9k60)) { last_pit_band = add(3 , BAND1k2); } - ELSE IF( sub(last_pit_band,add(BAND1k2,1)) < 0 ) + ELSE IF( LT_16(last_pit_band,add(BAND1k2,1))) { last_pit_band = add(BAND1k2,1); } @@ -311,20 +309,20 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pitch contribution is si max_len = sub(st_fx->L_frame_fx,last_pit_bin); - if( sub(st_fx->bwidth_fx,NB) == 0 ) + if( EQ_16(st_fx->bwidth_fx,NB)) { max_len = sub(160,last_pit_bin); } Len = 80; move16(); - if(sub(max_len,80) < 0) + if(LT_16(max_len,80)) { Len = max_len; move16(); } test(); - IF((L_sub(st_fx->core_brate_fx,ACELP_8k00) == 0) && (sub(st_fx->bwidth_fx,NB) != 0)) + IF((EQ_32(st_fx->core_brate_fx,ACELP_8k00))&&(NE_16(st_fx->bwidth_fx,NB))) { move16(); /*ptr init*/ FOR (i=0; i < max_len; i++) @@ -385,9 +383,9 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pitch contribution is si move16(); } } - IF( L_sub(st_fx->core_brate_fx,CFREQ_BITRATE) < 0 ) + IF( LT_32(st_fx->core_brate_fx,CFREQ_BITRATE)) { - IF(L_sub(st_fx->core_brate_fx,ACELP_9k60) < 0) + IF(LT_32(st_fx->core_brate_fx,ACELP_9k60)) { if(pit_contr_idx>0) { @@ -395,7 +393,7 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pitch contribution is si move16(); } - IF( sub(coder_type,INACTIVE) == 0 ) + IF( EQ_16(coder_type,INACTIVE)) { push_indice_fx( st_fx, IND_PIT_CONTR_IDX, pit_contr_idx, 1 ); } diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c index 4d28cb59dd7099bc188701c44fe06b1d25bd1eac..3f8ba382001607f4114f73869e7523e51a4f99f0 100644 --- a/lib_enc/evs_enc_fx.c +++ b/lib_enc/evs_enc_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -7,9 +7,7 @@ #include "options.h" /* Compilation switches */ #include "prot_fx.h" #include "cnst_fx.h" /* Common constants */ -#include "stl.h" -#include "wmc_auto.h" - /* Debug prototypes */ +#include "stl.h" /* Debug prototypes */ #include "rom_com_fx.h" /* Common constants */ static void initFrameHeader_loc( Encoder_State_fx *st ); @@ -130,7 +128,7 @@ void evs_enc_fx( *----------------------------------------------------------------*/ Copy(data, st->input, input_frame); - IF( sub(n_samples,input_frame) < 0) + IF( LT_16(n_samples,input_frame)) { set16_fx( st->input + n_samples, 0, sub(input_frame, n_samples) ); } @@ -145,7 +143,7 @@ void evs_enc_fx( * Updates in case of AMR-WB IO mode -> EVS primary mode switching *----------------------------------------------------------------*/ - IF( sub(st->last_core_fx, AMR_WB_CORE) == 0 ) + IF( EQ_16(st->last_core_fx, AMR_WB_CORE)) { updt_IO_switch_enc_fx( st, input_frame ); set16_fx(st->old_speech_shb_fx, 0, L_LOOK_16k + L_SUBFR16k); @@ -166,7 +164,7 @@ void evs_enc_fx( st->sharpFlag = sharpFlag; - IF (sub(st->mdct_sw,MODE2) == 0) + IF (EQ_16(st->mdct_sw,MODE2)) { Mpy_32_16_ss(st->total_brate_fx, 5243, &L_tmp, &lsb); /* 5243 is 1/50 in Q18. (0+18-15=3) */ @@ -178,7 +176,7 @@ void evs_enc_fx( test(); test(); test(); - IF ((L_sub(st->total_brate_fx,ACELP_24k40) > 0 && L_sub(st->total_brate_fx,HQ_96k) < 0) || (L_sub(st->total_brate_fx,ACELP_24k40) == 0 && sub(st->bwidth_fx,WB) >= 0)) + IF ((GT_32(st->total_brate_fx,ACELP_24k40)&<_32(st->total_brate_fx,HQ_96k))||(EQ_32(st->total_brate_fx,ACELP_24k40)&&GE_16(st->bwidth_fx,WB))) { st->L_frame_fx = L_FRAME16k; move16(); @@ -189,7 +187,7 @@ void evs_enc_fx( weight_a_subfr_fx( NB_SUBFR16k, A, Aw, GAMMA16k, M ); test(); - IF (sub(st->last_L_frame_fx,L_FRAME) == 0 && st->ini_frame_fx != 0) + IF (EQ_16(st->last_L_frame_fx,L_FRAME)&&st->ini_frame_fx!=0) { /* this is just an approximation, but it is sufficient */ Copy( st->lsp_old1_fx, st->lspold_enc_fx, M ); @@ -215,20 +213,20 @@ void evs_enc_fx( move16(); test(); test(); - IF( (sub(st->bwidth_fx,SWB) == 0 || sub(st->bwidth_fx,WB) == 0) && L_sub(st->total_brate_fx,LRMDCT_CROSSOVER_POINT) <= 0 ) + IF( (EQ_16(st->bwidth_fx,SWB)||EQ_16(st->bwidth_fx,WB))&&LE_32(st->total_brate_fx,LRMDCT_CROSSOVER_POINT)) { /* note that FB (bit-rate >= 24400bps) is always coded with NORMAL_HQ_CORE */ hq_core_type = LOW_RATE_HQ_CORE; move16(); } - ELSE IF( sub(st->bwidth_fx,NB) == 0 ) + ELSE IF( EQ_16(st->bwidth_fx,NB)) { hq_core_type = LOW_RATE_HQ_CORE; move16(); } } - IF( sub(st->codec_mode,MODE1) == 0 ) + IF( EQ_16(st->codec_mode,MODE1)) { /*---------------------------------------------------------------------* * Write signalling info into the bitstream @@ -246,7 +244,7 @@ void evs_enc_fx( * ACELP core encoding *---------------------------------------------------------------------*/ - IF( sub(st->core_fx,ACELP_CORE) == 0 ) + IF( EQ_16(st->core_fx,ACELP_CORE)) { acelp_core_enc_fx( st, &(st->LPDmem), inp, vad_flag, ener, pitch, voicing, A, Aw, epsP_h, epsP_l, lsp_new, lsp_mid, coder_type, sharpFlag, vad_hover_flag, @@ -257,7 +255,7 @@ void evs_enc_fx( * HQ core encoding *---------------------------------------------------------------------*/ - IF( sub(st->core_fx,HQ_CORE) == 0 ) + IF( EQ_16(st->core_fx,HQ_CORE)) { hq_core_enc_fx( st, st->input - delay, input_frame, hq_core_type, Voicing_flag); } @@ -287,18 +285,18 @@ void evs_enc_fx( *----------------------------------------------------------------*/ /* Call main encoding function */ - enc_acelp_tcx_main(old_inp_16k + L_INP_MEM, st, coder_type, pitch, voicing, Aw, lsp_new, lsp_mid, - st->hFdCngEnc_fx, bwe_exc_extended, voice_factors, pitch_buf, - vad_hover_flag, vad_flag, &Q_new, &shift); + enc_acelp_tcx_main( old_inp_16k + L_INP_MEM, st, coder_type, pitch, voicing, Aw, lsp_new, lsp_mid, + st->hFdCngEnc_fx, bwe_exc_extended, voice_factors, pitch_buf, + vad_hover_flag, vad_flag, &Q_new, &shift ); /*---------------------------------------------------------------------* * Postprocessing for codec switching *---------------------------------------------------------------------*/ /* TBE interface */ test(); - IF ( st->igf != 0 && L_sub(st->core_brate_fx,SID_2k40) > 0 ) + IF ( st->igf != 0 && GT_32(st->core_brate_fx,SID_2k40)) { - IF( sub(st->core_fx,ACELP_CORE) == 0 ) + IF( EQ_16(st->core_fx,ACELP_CORE)) { SWITCH (st->bwidth_fx) { @@ -336,7 +334,7 @@ void evs_enc_fx( st->core_brate_fx = L_sub(st->total_brate_fx, st->extl_brate_fx); - IF( sub(st->tec_tfa, 1) == 0 ) + IF( EQ_16(st->tec_tfa, 1)) { st->core_brate_fx = L_sub(st->core_brate_fx, BITS_TEC); st->core_brate_fx = L_sub(st->core_brate_fx, BITS_TFA); @@ -351,7 +349,7 @@ void evs_enc_fx( test(); test(); - IF( st->igf != 0 && sub(st->core_fx,ACELP_CORE) == 0 && L_sub(st->core_brate_fx,SID_2k40) > 0 ) + IF( st->igf != 0 && EQ_16(st->core_fx,ACELP_CORE)&>_32(st->core_brate_fx,SID_2k40)) { /* padBits = ((st->bits_frame+7)/8)*8 - (st->nb_bits_tot + (st->rf_target_bits_write - ((st->Opt_RF_ON==1)?1:0) ) + get_tbe_bits(st->total_brate, st->bwidth, st->rf_mode )); */ tmp = add(get_tbe_bits_fx(st->total_brate_fx, st->bwidth_fx, st->rf_mode), sub(st->rf_target_bits_write, st->rf_mode)); @@ -377,24 +375,24 @@ void evs_enc_fx( *---------------------------------------------------------------------*/ test(); - IF ( L_sub(st->input_Fs_fx,16000 ) >= 0 && (sub(st->bwidth_fx, SWB) < 0) ) + IF ( GE_32(st->input_Fs_fx,16000 )&&(LT_16(st->bwidth_fx,SWB))) { /* Common pre-processing for WB TBE and WB BWE */ wb_pre_proc_fx( st, new_inp_resamp16k, hb_speech ); /* o: new_inp_resamp16k at Q = -1 */ } - IF ( sub(st->extl_fx,WB_TBE) == 0 ) + IF ( EQ_16(st->extl_fx,WB_TBE)) { /* WB TBE encoder */ wb_tbe_enc_fx( st, coder_type, hb_speech, bwe_exc_extended, Q_new, voice_factors, pitch_buf, voicing); - IF( sub(st->codec_mode,MODE2) == 0 ) + IF( EQ_16(st->codec_mode,MODE2)) { tbe_write_bitstream_fx( st ); } } - ELSE IF ( sub(st->extl_fx, WB_BWE) == 0 ) + ELSE IF ( EQ_16(st->extl_fx, WB_BWE)) { /* WB BWE encoder */ wb_bwe_enc_fx( st, new_inp_resamp16k, coder_type ); @@ -406,12 +404,12 @@ void evs_enc_fx( * SWB BWE encoding *---------------------------------------------------------------------*/ test(); - IF (!st->Opt_SC_VBR_fx && L_sub(st->input_Fs_fx,32000) >= 0 ) + IF (!st->Opt_SC_VBR_fx && GE_32(st->input_Fs_fx,32000)) { /* Common pre-processing for SWB(FB) TBE and SWB BWE */ swb_pre_proc_fx(st, st->input, new_swb_speech, shb_speech, &Q_shb_spch, realBuffer, imagBuffer, &cldfbScale ); } - ELSE IF( L_sub(st->input_Fs_fx,32000) >= 0 ) + ELSE IF( GE_32(st->input_Fs_fx,32000)) { set16_fx( st->old_speech_shb_fx, 0, L_LOOK_16k + L_SUBFR16k ); set16_fx( shb_speech, 0, L_FRAME16k ); @@ -424,26 +422,26 @@ void evs_enc_fx( test(); test(); test(); - IF ( sub(st->extl_fx, SWB_TBE) == 0 || sub(st->extl_fx, FB_TBE) == 0 || ( st->igf != 0 && sub(st->core_fx, ACELP_CORE) == 0 && sub(st->extl_fx, WB_TBE) != 0 ) ) + IF ( EQ_16(st->extl_fx, SWB_TBE)||EQ_16(st->extl_fx,FB_TBE)||(st->igf!=0&&EQ_16(st->core_fx,ACELP_CORE)&&NE_16(st->extl_fx,WB_TBE))) { test(); - IF( L_sub(st->core_brate_fx,FRAME_NO_DATA) != 0 && L_sub(st->core_brate_fx,SID_2k40) != 0 ) + IF( NE_32(st->core_brate_fx,FRAME_NO_DATA)&&NE_32(st->core_brate_fx,SID_2k40)) { swb_tbe_enc_fx( st, coder_type, shb_speech, bwe_exc_extended, voice_factors, fb_exc, &Q_fb_exc, Q_new, Q_shb_spch, voicing, pitch_buf ); - IF ( sub(st->extl_fx,FB_TBE) == 0 ) + IF ( EQ_16(st->extl_fx,FB_TBE)) { /* FB TBE encoder */ fb_tbe_enc_fx( st, st->input, fb_exc, Q_fb_exc ); } - IF( sub(st->codec_mode,MODE2) == 0 ) + IF( EQ_16(st->codec_mode,MODE2)) { - IF( sub(st->tec_tfa, 1) == 0 ) + IF( EQ_16(st->tec_tfa, 1)) { tecEnc_TBE_fx(&st->tecEnc.corrFlag, voicing, coder_type); - IF( sub(coder_type, INACTIVE) == 0 ) + IF( EQ_16(coder_type, INACTIVE)) { st->tec_flag = 0; move16(); @@ -467,12 +465,12 @@ void evs_enc_fx( } } } - ELSE IF ( sub(st->extl_fx,SWB_BWE) == 0 || sub(st->extl_fx,FB_BWE) == 0 ) + ELSE IF ( EQ_16(st->extl_fx,SWB_BWE)||EQ_16(st->extl_fx,FB_BWE)) { /* SWB BWE encoder */ swb_bwe_enc_fx( st, old_inp_12k8, old_inp_16k, old_syn_12k8_16k, new_swb_speech, shb_speech, coder_type, Q_shb_spch, sub(Q_new, 1) ); } - ELSE IF( sub(st->extl_fx,SWB_BWE_HIGHRATE) == 0 || sub(st->extl_fx,FB_BWE_HIGHRATE) == 0 ) + ELSE IF( EQ_16(st->extl_fx,SWB_BWE_HIGHRATE)||EQ_16(st->extl_fx,FB_BWE_HIGHRATE)) { /* SWB HR BWE encoder */ swb_bwe_enc_hr_fx(st, st->input - delay, st->Q_syn2, input_frame, coder_type, unbits ); @@ -483,7 +481,7 @@ void evs_enc_fx( *---------------------------------------------------------------------*/ test(); - IF ( st->Opt_DTX_ON_fx && sub(input_frame,L_FRAME32k) >= 0 ) + IF ( st->Opt_DTX_ON_fx && GE_16(input_frame,L_FRAME32k)) { swb_CNG_enc_fx( st, shb_speech, old_syn_12k8_16k ); } @@ -524,12 +522,12 @@ void evs_enc_fx( st->prev_Q_new = Q_new; - if( L_sub(st->core_brate_fx,SID_2k40) > 0 ) + if( GT_32(st->core_brate_fx,SID_2k40)) { st->last_active_brate_fx = st->total_brate_fx; move32(); } - IF ( sub(st->core_fx,HQ_CORE) == 0 ) + IF ( EQ_16(st->core_fx,HQ_CORE)) { /* in the HQ core, coder_type is not used so it could have been set to anything */ st->prev_coder_type_fx = GENERIC; @@ -540,9 +538,9 @@ void evs_enc_fx( } test(); - IF( L_sub(st->core_brate_fx,SID_2k40) > 0 && sub(st->first_CNG_fx,1) == 0 ) + IF( GT_32(st->core_brate_fx,SID_2k40)&&EQ_16(st->first_CNG_fx,1)) { - if( sub(st->act_cnt_fx,BUF_DEC_RATE) >= 0 ) + if( GE_16(st->act_cnt_fx,BUF_DEC_RATE)) { st->act_cnt_fx = 0; move16(); @@ -551,13 +549,13 @@ void evs_enc_fx( st->act_cnt_fx = add(st->act_cnt_fx,1); test(); - if( sub(st->act_cnt_fx,BUF_DEC_RATE) == 0 && st->ho_hist_size_fx > 0 ) + if( EQ_16(st->act_cnt_fx,BUF_DEC_RATE)&&st->ho_hist_size_fx>0) { st->ho_hist_size_fx = sub(st->ho_hist_size_fx,1); } st->act_cnt2_fx = add(st->act_cnt2_fx,1); - if( sub(st->act_cnt2_fx,MIN_ACT_CNG_UPD) >= 0 ) + if( GE_16(st->act_cnt2_fx,MIN_ACT_CNG_UPD)) { st->act_cnt2_fx = MIN_ACT_CNG_UPD; move16(); @@ -566,7 +564,7 @@ void evs_enc_fx( test(); test(); - if ( L_sub(st->core_brate_fx,SID_2k40) <= 0 && st->first_CNG_fx == 0 && sub(st->cng_type_fx,LP_CNG) == 0 ) + if ( LE_32(st->core_brate_fx,SID_2k40)&&st->first_CNG_fx==0&&EQ_16(st->cng_type_fx,LP_CNG)) { st->first_CNG_fx = 1; move16(); @@ -577,14 +575,14 @@ void evs_enc_fx( * Limit the max number of init. frames *-----------------------------------------------------------------*/ - if( sub(st->ini_frame_fx,MAX_FRAME_COUNTER) < 0 ) + if( LT_16(st->ini_frame_fx,MAX_FRAME_COUNTER)) { st->ini_frame_fx = add(st->ini_frame_fx, 1); } /* synchronisation of CNG seeds */ test(); - IF( L_sub(st->core_brate_fx,FRAME_NO_DATA) != 0 && L_sub(st->core_brate_fx, SID_2k40) != 0 ) + IF( NE_32(st->core_brate_fx,FRAME_NO_DATA)&&NE_32(st->core_brate_fx,SID_2k40)) { Random( &(st->cng_seed_fx) ); Random( &(st->cng_ener_seed_fx) ); @@ -594,7 +592,7 @@ void evs_enc_fx( /*---------------------------------------------------------------------* * Updates - MODE2 *---------------------------------------------------------------------*/ - IF( sub(st->mdct_sw,MODE2) == 0 ) + IF( EQ_16(st->mdct_sw,MODE2)) { st->codec_mode = MODE2; move16(); @@ -602,7 +600,7 @@ void evs_enc_fx( Mpy_32_16_ss(st->sr_core, 5243, &L_tmp, &lsb); /* 5243 is 1/50 in Q18. (0+18-15=3) */ st->L_frame_fx = extract_l(L_shr(L_tmp, 3)); /* Q0 */ assert(st->L_frame_fx == st->sr_core / 50); - IF ( L_sub(st->sr_core,12800) == 0 ) + IF ( EQ_32(st->sr_core,12800)) { st->preemph_fac = PREEMPH_FAC; move16(); @@ -623,7 +621,7 @@ void evs_enc_fx( st->last_clas_fx = st->clas_fx; core_encode_update( st ); - if( sub(st->mdct_sw,MODE1) == 0 ) + if( EQ_16(st->mdct_sw,MODE1)) { st->codec_mode = MODE1; move16(); @@ -634,9 +632,9 @@ void evs_enc_fx( move16(); } - IF (sub(st->rf_mode,1)==0 ) + IF (EQ_16(st->rf_mode,1)) { - IF (sub(st->rf_frame_type,RF_NELP) == 0) + IF (EQ_16(st->rf_frame_type,RF_NELP)) { st->last_nelp_mode_fx = 1; } @@ -648,7 +646,7 @@ void evs_enc_fx( /* RF mode updates */ st->rf_mode_last = st->rf_mode; - IF(sub(st->Opt_RF_ON,1)==0) + IF(EQ_16(st->Opt_RF_ON,1)) { st->L_frame_fx = L_FRAME; st->rf_mode = 1; @@ -670,7 +668,7 @@ static void initFrameHeader_loc( Encoder_State_fx *st ) Word16 n; - IF( L_sub(st->core_brate_fx, SID_2k40) == 0 ) + IF( EQ_32(st->core_brate_fx, SID_2k40)) { /*Get size of frame*/ st->bits_frame = FRAME_2_4; @@ -679,7 +677,7 @@ static void initFrameHeader_loc( Encoder_State_fx *st ) st->frame_size_index = 2; move16(); } - ELSE IF( L_sub(st->core_brate_fx,FRAME_NO_DATA) == 0 ) + ELSE IF( EQ_32(st->core_brate_fx,FRAME_NO_DATA)) { st->bits_frame = FRAME_0; move16(); @@ -691,7 +689,7 @@ static void initFrameHeader_loc( Encoder_State_fx *st ) { FOR( n=0; nbits_frame_nominal) == 0 ) + IF( EQ_16(FrameSizeConfig[n].frame_bits,st->bits_frame_nominal)) { st->frame_size_index = n; move16(); @@ -715,12 +713,12 @@ static void initFrameHeader_loc( Encoder_State_fx *st ) static void writeFrameHeader_loc( Encoder_State_fx *st ) { - IF( L_sub(st->core_brate_fx,FRAME_NO_DATA) != 0 ) + IF( NE_32(st->core_brate_fx,FRAME_NO_DATA)) { /* SID flag at 2.4kbps */ - IF( L_sub(st->core_brate_fx,SID_2k40) == 0 ) + IF( EQ_32(st->core_brate_fx,SID_2k40)) { - IF ( sub(st->cng_type_fx,FD_CNG) == 0 ) + IF ( EQ_16(st->cng_type_fx,FD_CNG)) { /* write SID/CNG type flag */ push_next_indice_fx( st, 1, 1 ); @@ -729,7 +727,7 @@ static void writeFrameHeader_loc( Encoder_State_fx *st ) push_next_indice_fx( st, st->bwidth_fx, 2 ); /* write L_frame */ - IF( sub(st->L_frame_fx,L_FRAME) == 0 ) + IF( EQ_16(st->L_frame_fx,L_FRAME)) { push_next_indice_fx( st, 0, 1 ); } @@ -772,7 +770,7 @@ static void configure_core_coder_loc( initFrameHeader_loc( st ); test(); - IF( L_sub(st->core_brate_fx, SID_2k40) != 0 && L_sub(st->core_brate_fx, FRAME_NO_DATA) != 0 ) + IF( NE_32(st->core_brate_fx, SID_2k40)&&NE_32(st->core_brate_fx,FRAME_NO_DATA)) { if( st->tcxonly ) { @@ -786,7 +784,7 @@ static void configure_core_coder_loc( test(); test(); - if( !st->tcxonly && !localVAD && sub(st->tcx_cfg.coder_type,GENERIC) == 0 ) + if( !st->tcxonly && !localVAD && EQ_16(st->tcx_cfg.coder_type,GENERIC)) { st->tcx_cfg.coder_type = UNVOICED; move16(); @@ -796,7 +794,7 @@ static void configure_core_coder_loc( st->igf = getIgfPresent(st->total_brate_fx, st->bwidth_fx, st->rf_mode); test(); - if( L_sub(st->core_brate_fx,SID_2k40) != 0 && L_sub(st->core_brate_fx,FRAME_NO_DATA) != 0 ) + if( NE_32(st->core_brate_fx,SID_2k40)&&NE_32(st->core_brate_fx,FRAME_NO_DATA)) { st->core_brate_fx = st->total_brate_fx; move32(); diff --git a/lib_enc/ext_sig_ana.c b/lib_enc/ext_sig_ana.c index 24da90b97fb61736542cf45962929a33c6268d52..badddd4d5ee84e45635cc2f043b24b7dddd258ae 100644 --- a/lib_enc/ext_sig_ana.c +++ b/lib_enc/ext_sig_ana.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include #include #include "prot_fx.h" #include "stl.h" -#include "wmc_auto.h" - #include "basop_util.h" @@ -95,7 +93,7 @@ void core_signal_analysis_high_bitrate( const Word16 *new_samples, /*i: 0Q15*/ tmp8 = 0; move16(); - if(L_sub(st->sr_core, 25600) > 0) + if(GT_32(st->sr_core, 25600)) { tmp8 = 1; move16(); @@ -157,7 +155,7 @@ void core_signal_analysis_high_bitrate( const Word16 *new_samples, /*i: 0Q15*/ Scale_sig(&(st->mem_wsp_enc), 1, Q_exp); } - IF (sub(st->tcxMode,TCX_10) == 0) + IF (EQ_16(st->tcxMode,TCX_10)) { Copy( ¶m_core[1+NOISE_FILL_RANGES], ¶m_core[NPRM_DIV+1+NOISE_FILL_RANGES], LTPSIZE ); } @@ -181,7 +179,7 @@ void core_signal_analysis_high_bitrate( const Word16 *new_samples, /*i: 0Q15*/ alw_voicing_wc = s_max(alw_voicing[0], alw_voicing[1]); overlap_mode[0] = last_overlap; /* Overlap between the last and the current frame */ move16(); - IF (sub(st->tcxMode, TCX_20) == 0) + IF (EQ_16(st->tcxMode, TCX_20)) { nSubframes = 1; move16(); @@ -197,7 +195,7 @@ void core_signal_analysis_high_bitrate( const Word16 *new_samples, /*i: 0Q15*/ { nSubframes = 2; move16(); - IF (sub(curr_overlap, FULL_OVERLAP) == 0) + IF (EQ_16(curr_overlap, FULL_OVERLAP)) { transform_type[0] = TCX_5; move16(); @@ -205,13 +203,13 @@ void core_signal_analysis_high_bitrate( const Word16 *new_samples, /*i: 0Q15*/ move16(); overlap_mode[1] = MIN_OVERLAP; /* Overlap between 2nd and 3rd sub-frame */ move16(); - if (sub(last_overlap, HALF_OVERLAP) == 0) + if (EQ_16(last_overlap, HALF_OVERLAP)) { overlap_mode[1] = HALF_OVERLAP; move16(); } } - ELSE IF (sub(last_overlap, FULL_OVERLAP) == 0) + ELSE IF (EQ_16(last_overlap, FULL_OVERLAP)) { transform_type[0] = TCX_10; move16(); @@ -219,7 +217,7 @@ void core_signal_analysis_high_bitrate( const Word16 *new_samples, /*i: 0Q15*/ move16(); overlap_mode[1] = MIN_OVERLAP; /* Overlap between 1st and 2nd sub-frame */ move16(); - if (sub(curr_overlap, HALF_OVERLAP) == 0) + if (EQ_16(curr_overlap, HALF_OVERLAP)) { overlap_mode[1] = HALF_OVERLAP; move16(); @@ -233,7 +231,7 @@ void core_signal_analysis_high_bitrate( const Word16 *new_samples, /*i: 0Q15*/ overlap_mode[1] = MIN_OVERLAP; /* Overlap between 2nd and 3rd sub-frame */ move16(); test(); - if (sub(last_overlap, HALF_OVERLAP) == 0 && sub(curr_overlap, HALF_OVERLAP) == 0) + if (EQ_16(last_overlap, HALF_OVERLAP)&&EQ_16(curr_overlap,HALF_OVERLAP)) { overlap_mode[1] = HALF_OVERLAP; move16(); @@ -241,7 +239,7 @@ void core_signal_analysis_high_bitrate( const Word16 *new_samples, /*i: 0Q15*/ } overlap_mode[2] = curr_overlap; /* Overlap between the current and the next frame */ move16(); } - IF (sub(transform_type[0], TCX_20) != 0) + IF (NE_16(transform_type[0], TCX_20)) { IGFEncResetTCX10BitCounter(&st->hIGFEnc); } @@ -253,25 +251,25 @@ void core_signal_analysis_high_bitrate( const Word16 *new_samples, /*i: 0Q15*/ { L_subframe = L_frameTCX; move16(); - if (sub(nSubframes, 1) != 0) L_subframe = shr(L_frameTCX, 1); + if (NE_16(nSubframes, 1))L_subframe=shr(L_frameTCX,1); lpc_left_overlap_mode = overlap_mode[frameno]; move16(); lpc_right_overlap_mode = overlap_mode[frameno+1]; move16(); - if (sub(lpc_left_overlap_mode, ALDO_WINDOW) == 0) + if (EQ_16(lpc_left_overlap_mode, ALDO_WINDOW)) { lpc_left_overlap_mode = FULL_OVERLAP; move16(); } - if (sub(lpc_right_overlap_mode, ALDO_WINDOW) == 0) + if (EQ_16(lpc_right_overlap_mode, ALDO_WINDOW)) { lpc_right_overlap_mode = FULL_OVERLAP; move16(); } test(); - IF ((sub(transform_type[frameno], TCX_20) != 0) || (sub(st->tcx_cfg.tcx_last_overlap_mode, TRANSITION_OVERLAP) == 0)) + IF ((NE_16(transform_type[frameno], TCX_20))||(EQ_16(st->tcx_cfg.tcx_last_overlap_mode,TRANSITION_OVERLAP))) { /* Windowing of the 2xTCX5 subframes or 1xTCX10 or 1xTCX20 */ WindowSignal(&st->tcx_cfg, @@ -286,7 +284,7 @@ void core_signal_analysis_high_bitrate( const Word16 *new_samples, /*i: 0Q15*/ ); } - IF (sub(transform_type[frameno], TCX_5) == 0) + IF (EQ_16(transform_type[frameno], TCX_5)) { folding_offset = shr(left_overlap, 1); @@ -344,7 +342,7 @@ void core_signal_analysis_high_bitrate( const Word16 *new_samples, /*i: 0Q15*/ spectrum_e[frameno] = 16; move16(); test(); - IF ((sub(transform_type[frameno], TCX_20) == 0) && (sub(st->tcx_cfg.tcx_last_overlap_mode, TRANSITION_OVERLAP) != 0)) + IF ((EQ_16(transform_type[frameno], TCX_20))&&(NE_16(st->tcx_cfg.tcx_last_overlap_mode,TRANSITION_OVERLAP))) { Word32 tmp_buf[L_FRAME_PLUS]; Word16 Q, tmp1, tmp2; @@ -402,12 +400,12 @@ void core_signal_analysis_high_bitrate( const Word16 *new_samples, /*i: 0Q15*/ /* For TCX20 at bitrates up to 64 kbps we need the power spectrum */ test(); test(); - IF (sub(st->tcxMode, TCX_20) == 0 && ((L_sub(st->total_brate_fx, HQ_96k) < 0) || st->igf)) + IF (EQ_16(st->tcxMode, TCX_20)&&((LT_32(st->total_brate_fx,HQ_96k))||st->igf)) { pMdstWin = tcx20Win; test(); - if (((sub(st->tcxMode, TCX_20) == 0) && (sub(st->tcx_cfg.tcx_last_overlap_mode, TRANSITION_OVERLAP) != 0))) + if (((EQ_16(st->tcxMode, TCX_20))&&(NE_16(st->tcx_cfg.tcx_last_overlap_mode,TRANSITION_OVERLAP)))) { pMdstWin = mdstWin; } @@ -434,7 +432,7 @@ void core_signal_analysis_high_bitrate( const Word16 *new_samples, /*i: 0Q15*/ EncodeTnsData(st->tcx_cfg.pCurrentTnsConfig, &st->tnsData[frameno], param_core+frameno*NPRM_DIV+1+NOISE_FILL_RANGES+LTPSIZE, pTnsSize+frameno, pTnsBits+frameno); - IF (sub(transform_type[frameno], TCX_5) == 0) + IF (EQ_16(transform_type[frameno], TCX_5)) { /* group sub-windows: interleave bins according to their frequencies */ FOR (i = 0; i < tcx5SizeFB; i++) @@ -480,7 +478,7 @@ void core_signal_analysis_high_bitrate( const Word16 *new_samples, /*i: 0Q15*/ } /* Copy memory */ - MVR2R_WORD16(lsp_new, st->lspold_enc_fx, M); + mvr2r_Word16(lsp_new, st->lspold_enc_fx, M); } diff --git a/lib_enc/fd_cng_enc.c b/lib_enc/fd_cng_enc.c index e3addbe5df4a62a8b0e3c55eb97e6e27740cdd55..ee6c5656e06318d02ac5db4bfa47b58d39e828be 100644 --- a/lib_enc/fd_cng_enc.c +++ b/lib_enc/fd_cng_enc.c @@ -1,16 +1,12 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include #include "stl.h" -#include "wmc_auto.h" - #include "options.h" #include "stl.h" -#include "wmc_auto.h" - #include "rom_com_fx.h" #include "prot_fx.h" #include "basop_util.h" @@ -59,7 +55,7 @@ void initFdCngEnc(HANDLE_FD_CNG_ENC hsEnc, Word32 input_Fs, Word16 scale) hsCom->numCoreBands = 16; move16(); hsCom->regularStopBand = idiv1616U( extract_l( L_shr( input_Fs, 5 ) ), 25 ); - if ( sub( hsCom->regularStopBand, 40 ) > 0 ) + if ( GT_16( hsCom->regularStopBand, 40 )) { hsCom->regularStopBand = 40; move16(); @@ -67,7 +63,7 @@ void initFdCngEnc(HANDLE_FD_CNG_ENC hsEnc, Word32 input_Fs, Word16 scale) hsCom->startBand = 2; move16(); - IF ( sub( hsCom->regularStopBand, 10 ) == 0 ) + IF ( EQ_16( hsCom->regularStopBand, 10 )) { hsCom->stopFFTbin = 160; move16(); @@ -149,7 +145,7 @@ void configureFdCngEnc(HANDLE_FD_CNG_ENC hsEnc, /* i/o: Contains the variables hsCom->CngBandwidth = bandwidth; move16(); - IF ( sub( hsCom->CngBandwidth, FB ) == 0 ) + IF ( EQ_16( hsCom->CngBandwidth, FB )) { hsCom->CngBandwidth = SWB; } @@ -157,21 +153,21 @@ void configureFdCngEnc(HANDLE_FD_CNG_ENC hsEnc, /* i/o: Contains the variables move32(); /* NB configuration */ - IF ( sub(bandwidth,NB) == 0 ) + IF ( EQ_16(bandwidth,NB)) { hsCom->FdCngSetup = FdCngSetup_nb; /* PTR assignation -> no move needed*/ } /* WB configuration */ - ELSE IF ( sub(bandwidth,WB) == 0 ) + ELSE IF ( EQ_16(bandwidth,WB)) { /* FFT 6.4kHz, no CLDFB */ - IF ( L_sub(bitrate,ACELP_8k00) <= 0 ) + IF ( LE_32(bitrate,ACELP_8k00)) { hsCom->FdCngSetup = FdCngSetup_wb1; } /* FFT 6.4kHz, CLDFB 8.0kHz */ - ELSE IF ( L_sub(bitrate,ACELP_13k20) <= 0 ) + ELSE IF ( LE_32(bitrate,ACELP_13k20)) { hsCom->FdCngSetup = FdCngSetup_wb2; } @@ -186,7 +182,7 @@ void configureFdCngEnc(HANDLE_FD_CNG_ENC hsEnc, /* i/o: Contains the variables ELSE { /* FFT 6.4kHz, CLDFB 14kHz */ - IF ( L_sub(bitrate,ACELP_13k20) <= 0 ) + IF ( LE_32(bitrate,ACELP_13k20)) { hsCom->FdCngSetup = FdCngSetup_swb1; } @@ -220,12 +216,12 @@ void configureFdCngEnc(HANDLE_FD_CNG_ENC hsEnc, /* i/o: Contains the variables psize_invDec, 0 ); - IF ( sub(hsEnc->stopFFTbinDec,160) == 0 ) + IF ( EQ_16(hsEnc->stopFFTbinDec,160)) { hsEnc->nFFTpartDec = 17; move16(); } - ELSE IF ( sub(hsEnc->stopFFTbinDec,256) == 0 ) + ELSE IF ( EQ_16(hsEnc->stopFFTbinDec,256)) { hsEnc->nFFTpartDec = 20; move16(); @@ -296,7 +292,7 @@ void resetFdCngEnc( move16(); IF ( totalNoiseIncrease > 0 ) { - IF ( sub(st->totalNoise_increase_len_fx,TOTALNOISE_HIST_SIZE) == 0 ) + IF ( EQ_16(st->totalNoise_increase_len_fx,TOTALNOISE_HIST_SIZE)) { FOR ( n = 0; n < TOTALNOISE_HIST_SIZE-1; n++ ) { @@ -327,10 +323,10 @@ void resetFdCngEnc( test(); test(); - tmpTest = ((sub (totalNoiseIncrease,thresh) > 0) && (sub(st->totalNoise_increase_len_fx,TOTALNOISE_HIST_SIZE)==0) && (sub(st->ini_frame_fx,150)>0) ); + tmpTest = ((GT_16 (totalNoiseIncrease,thresh) ) && (EQ_16(st->totalNoise_increase_len_fx,TOTALNOISE_HIST_SIZE)) && (GT_16(st->ini_frame_fx,150)) ); test(); - IF ( tmpTest || ( sub (st->input_bwidth_fx,st->last_input_bwidth_fx) > 0 ) || sub(st->last_core_fx,AMR_WB_CORE) == 0 ) + IF ( tmpTest || ( GT_16(st->input_bwidth_fx,st->last_input_bwidth_fx) ) || EQ_16(st->last_core_fx,AMR_WB_CORE)) { st->fd_cng_reset_flag = 1; move16(); @@ -339,7 +335,7 @@ void resetFdCngEnc( st->hFdCngEnc_fx->hFdCngCom->init_old = 32767; move16(); } - ELSE IF ( s_and((st->fd_cng_reset_flag > 0),(sub(st->fd_cng_reset_flag,10) < 0)) ) + ELSE IF ( s_and((st->fd_cng_reset_flag > 0),(Word16)(LT_16(st->fd_cng_reset_flag,10)))) { st->fd_cng_reset_flag = add(st->fd_cng_reset_flag,1); } @@ -556,7 +552,7 @@ AdjustFirstSID (Word16 npart, /* i : number of parts */ test(); - IF ( sub(stcod->cnt_SID_fx,1) == 0 && L_sub(stcod->last_core_brate_fx,SID_2k40) > 0 ) + IF ( EQ_16(stcod->cnt_SID_fx,1)&>_32(stcod->last_core_brate_fx,SID_2k40)) { /* Detect the hangover period and the first SID frame at the beginning of each CNG phase */ @@ -566,7 +562,7 @@ AdjustFirstSID (Word16 npart, /* i : number of parts */ move16(); /* Set first SID to current input level but add some smoothing */ - IF ( sub(*active_frame_counter,254) >= 0 ) + IF ( GE_16(*active_frame_counter,254)) { lambda = 0; move16(); @@ -607,12 +603,13 @@ AdjustFirstSID (Word16 npart, /* i : number of parts */ *msNoiseEst_exp = sc; move16(); - tmp32 = L_add(0,0); + tmp32 = 0; + move32(); FOR (i=0; i 0 ) + IF ( GT_32(msNoiseEst_local,energy_ho_local)) { msNoiseEst[i] = energy_ho_local; move32(); @@ -624,7 +621,8 @@ AdjustFirstSID (Word16 npart, /* i : number of parts */ } if ( msNoiseEst[i] > 0 ) { - tmp32 = L_add(0,1); + tmp32 = 1; + move32(); } } /* Set exponent to zero if msNoiseEst is zero */ @@ -638,7 +636,7 @@ AdjustFirstSID (Word16 npart, /* i : number of parts */ move16(); } test(); - IF ( L_sub(stcod->core_brate_fx,SID_2k40) != 0 && L_sub(stcod->core_brate_fx,FRAME_NO_DATA) != 0 ) + IF ( NE_32(stcod->core_brate_fx,SID_2k40)&&NE_32(stcod->core_brate_fx,FRAME_NO_DATA)) { /* Count the number of active frames in a row */ *active_frame_counter = add(*active_frame_counter, 1); @@ -801,9 +799,9 @@ static void msvq_encoder (const Word16 * const cb[], /* i : Codebook (indexed c tmp = L_add(dist[0][c], L_sub(en, L_shl(t1, 1))); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF t1 = L_sub(tmp,dist[1][p_max]); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON IF ( t1 <= 0 ) /* IF (L_sub(L_shr(tmp,1), L_shr(dist[1][p_max],1) ) <= 0 ) */ { @@ -820,9 +818,10 @@ static void msvq_encoder (const Word16 * const cb[], /* i : Codebook (indexed c FOR (i=1; i < maxC; i++) { - if (L_sub(dist[1][i],dist[1][p_max]) > 0) + if (GT_32(dist[1][i],dist[1][p_max])) { - p_max = add(i,0); + p_max = i; + move16(); } } } @@ -859,7 +858,7 @@ static void msvq_encoder (const Word16 * const cb[], /* i : Codebook (indexed c move16(); FOR (i=1; i < maxC; i++) { - if ( L_sub(dist[1][i], dist[1][c2]) < 0 ) + if ( LT_32(dist[1][i], dist[1][c2])) { c2 = i; move16(); @@ -1012,7 +1011,7 @@ void FdCng_encodeSID (HANDLE_FD_CNG_ENC stenc, /* i/o: pointer to FD_CNG struct move16(); } - if ( sub(index,127) > 0) + if ( GT_16(index,127)) { index = 127; move16(); @@ -1061,14 +1060,14 @@ void FdCng_encodeSID (HANDLE_FD_CNG_ENC stenc, /* i/o: pointer to FD_CNG struct } /* NB last band energy compensation */ - IF ( sub(st->CngBandwidth,NB) == 0 ) + IF ( EQ_16(st->CngBandwidth,NB)) { st->sidNoiseEst[N-1] = Mpy_32_16_1(st->sidNoiseEst[N-1], NB_LAST_BAND_SCALE); move32(); } test(); - if (sub( st->CngBandwidth,SWB) == 0 && L_sub(st->CngBitrate,ACELP_13k20) <= 0 ) + if (EQ_16( st->CngBandwidth,SWB)&&LE_32(st->CngBitrate,ACELP_13k20)) { st->sidNoiseEst[N-1] = Mpy_32_16_1(st->sidNoiseEst[N-1], SWB_13k2_LAST_BAND_SCALE); move32(); @@ -1076,7 +1075,7 @@ void FdCng_encodeSID (HANDLE_FD_CNG_ENC stenc, /* i/o: pointer to FD_CNG struct /* Write bitstream */ - IF ( sub(corest->codec_mode, MODE2) == 0 ) + IF ( EQ_16(corest->codec_mode, MODE2)) { FOR (i=0; ibwidth_fx, 2 ); - IF (sub(corest->L_frame_fx, L_FRAME16k) == 0) + IF (EQ_16(corest->L_frame_fx, L_FRAME16k)) { push_indice_fx( corest, IND_ACELP_16KHZ, 1, 1 ); } @@ -1223,12 +1222,12 @@ void generate_comfort_noise_enc (Encoder_State_fx *stcod, fftBufferExp = add(shr(cngNoiseLevelExp,1),randGaussExp); /* If previous frame is active, reset the overlap-add buffer */ - IF ( L_sub(stcod->last_core_brate_fx,SID_2k40) > 0 ) + IF ( GT_32(stcod->last_core_brate_fx,SID_2k40)) { set16_fx(st->olapBufferSynth, 0, st->fftlen); test(); test(); - IF ( (L_sub(stcod->last_core_fx,ACELP_CORE) > 0 && sub(stcod->codec_mode,MODE2) == 0) || sub(stcod->codec_mode,MODE1) == 0 ) + IF ( (GT_32(stcod->last_core_fx,ACELP_CORE)&&EQ_16(stcod->codec_mode,MODE2))||EQ_16(stcod->codec_mode,MODE1)) { tcx_transition = 1; move16(); @@ -1253,14 +1252,14 @@ void generate_comfort_noise_enc (Encoder_State_fx *stcod, /*(float)log10( enr + 0.1f ) / (float)log10( 2.0f );*/ Lener = BASOP_Util_Log2(Lener); Lener = L_add(Lener,L_shl(L_deposit_l(exp),WORD32_BITS-1-LD_DATA_SCALE)); /*Q25*/ - if(sub(stcod->L_frame_fx,L_FRAME16k) == 0) + if(EQ_16(stcod->L_frame_fx,L_FRAME16k)) { Lener = L_sub(Lener, 10802114l/*0.3219280949f Q25*/); /*log2(320) = 8.3219280949f*/ } /* decrease the energy in case of WB input */ - IF( sub(stcod->bwidth_fx, NB) != 0 ) + IF( NE_16(stcod->bwidth_fx, NB)) { - IF( sub(stcod->bwidth_fx,WB) == 0 ) + IF( EQ_16(stcod->bwidth_fx,WB)) { IF( stcod->CNG_mode_fx >= 0 ) { @@ -1290,7 +1289,7 @@ void generate_comfort_noise_enc (Encoder_State_fx *stcod, /* Overlap-add when previous frame is active */ test(); - IF ( ( L_sub(stcod->last_core_brate_fx,SID_2k40) > 0 ) && ( sub(stcod->codec_mode,MODE2) == 0 ) ) + IF ( ( GT_32(stcod->last_core_brate_fx,SID_2k40))&&(EQ_16(stcod->codec_mode,MODE2))) { Word32 old_exc_ener, gain, noise32; Word16 seed_loc, lpcorder, old_syn, tmp, gain16, N, N2, N4, N8; @@ -1310,12 +1309,12 @@ void generate_comfort_noise_enc (Encoder_State_fx *stcod, move16(); N2 = shr(st->frameSize,1); - IF ( sub(stcod->last_core_fx,ACELP_CORE) > 0 ) + IF ( GT_16(stcod->last_core_fx,ACELP_CORE)) { Word16 left_overlap_mode; left_overlap_mode = stcod->tcx_cfg.tcx_last_overlap_mode; move16(); - if (sub(left_overlap_mode, ALDO_WINDOW) == 0) + if (EQ_16(left_overlap_mode, ALDO_WINDOW)) { left_overlap_mode = FULL_OVERLAP; move16(); diff --git a/lib_enc/find_tar_fx.c b/lib_enc/find_tar_fx.c index 79865d421701c0fde3f91d4596e694f013581514..a6de65ac87f4e046ece5116f32bd588a311cb847 100644 --- a/lib_enc/find_tar_fx.c +++ b/lib_enc/find_tar_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -7,8 +7,6 @@ #include "cnst_fx.h" /* Common constants */ #include "basop_util.h" #include "stl.h" -#include "wmc_auto.h" - diff --git a/lib_enc/find_tilt_fx.c b/lib_enc/find_tilt_fx.c index 2722326c4f01850ee4bb3619f435ea2270e8a0ab..592c920f0b4c7d0e0a56484b03de95afb6507d82 100644 --- a/lib_enc/find_tilt_fx.c +++ b/lib_enc/find_tilt_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "cnst_fx.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - #include "basop_util.h" /*-------------------------------------------------------------------* @@ -47,7 +45,7 @@ void find_tilt_fx( *-----------------------------------------------------------------*/ scaling = add(Q_new, QSCALE); - IF( sub(bwidth,NB) != 0 ) + IF( NE_16(bwidth,NB)) { /* WB processing */ bin = BIN4_FX; @@ -90,7 +88,7 @@ void find_tilt_fx( *bckr_tilt_lt = L_add( Mpy_32_16_r( *bckr_tilt_lt, 29491 ), Mpy_32_16_r( Ltmp, 3277 ) ); test(); - IF ( sub(codec_mode,MODE2) == 0 || Opt_vbr_mode == 1) + IF ( EQ_16(codec_mode,MODE2)||Opt_vbr_mode==1) { /*lp_bckr *= FACT;*/ /*hp_bckr *= FACT;*/ @@ -128,7 +126,7 @@ void find_tilt_fx( } test(); - IF(sub(mean_voi,TH_COR_FX) > 0 && sub(pitch[2], TH_PIT_FX) < 0) /* High-pitched voiced frames */ + IF(GT_16(mean_voi,TH_COR_FX)&<_16(pitch[2],TH_PIT_FX)) /* High-pitched voiced frames */ { freq = bin; move16(); /* 1st useful frequency bin */ @@ -139,7 +137,7 @@ void find_tilt_fx( f1 = add(shr(f0,1),f0); /* Middle between 2 harmonics */ f2 = f0; move16(); - WHILE(sub(freq, 20320) <= 0) /* End frequency of 10th critical band */ + WHILE(LE_16(freq, 20320)) /* End frequency of 10th critical band */ { FOR (; freq <= f1; freq += BIN4_FX) { @@ -207,10 +205,10 @@ void find_tilt_fx( ee[i] = MAX_32; } - IF( sub(bwidth,NB) == 0 ) /* For NB input, compensate for the missing bands */ + IF( EQ_16(bwidth,NB)) /* For NB input, compensate for the missing bands */ { Ltmp = L_shl(ee[i], 3); - IF (L_sub(Ltmp, MAX_32) == 0) /* if Overflow: Compute with less precision */ + IF (EQ_32(Ltmp, MAX_32)) /* if Overflow: Compute with less precision */ { Ltmp = Mult_32_16(ee[i], 24576); /* 6/8 */ ee[i] = L_shl(Ltmp, 3); diff --git a/lib_enc/find_uv.c b/lib_enc/find_uv.c index 1bbd8b89321719dd2bfad9ca2fe099de044a0989..acb5178133a21472555025d7f621bab0fec60bb3 100644 --- a/lib_enc/find_uv.c +++ b/lib_enc/find_uv.c @@ -1,14 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "cnst_fx.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - - /*-------------------------------------------------------------------* * Local constants @@ -49,7 +46,7 @@ static Word16 find_ener_decrease_fx( /* o : maximum energy ratio Q10 FOR( i=j; i0) && (flag == 0) ) + IF( (GT_32(pt_enr_ssf[i], maxEnr))&&(flag==0)) { maxEnr = L_add(pt_enr_ssf[i], 0); /*Q0*/ j = add(j, 1); @@ -162,7 +159,7 @@ Word16 find_uv_fx( /* o : coding type fac = div_s(wtmp1,wtmp0); fac_32 = L_shr(L_deposit_l(fac), add(sub(exp1, exp0),15-13)); /* fac32 in Q13*/ - if(L_sub(fac_32, dE1 ) > 0) + if(GT_32(fac_32, dE1 )) { ind_deltaMax = i; move16(); @@ -203,11 +200,11 @@ Word16 find_uv_fx( /* o : coding type move32(); nb_cond = 1; move16(); /* no additional condition for WB input */ - IF ( sub(st_fx->input_bwidth_fx,NB) == 0 ) + IF ( EQ_16(st_fx->input_bwidth_fx,NB)) { dE2_th = 21<<10; move32(); - if(sub(add(mean_voi3, corr_shift), 22282) >= 0) /*( mean_voi3 + corr_shift ) >= 0.68f*/ + if(GE_16(add(mean_voi3, corr_shift), 22282)) /*( mean_voi3 + corr_shift ) >= 0.68f*/ { nb_cond = 0; move16(); @@ -220,9 +217,9 @@ Word16 find_uv_fx( /* o : coding type pt_enr_ssf = enr_ssf + 2*NB_SSF; test(); - IF( L_sub(dE1, 30<<13) > 0 && nb_cond) /*>30 Q13*/ + IF( GT_32(dE1, 30<<13)&&nb_cond) /*>30 Q13*/ { - IF( sub(sub(shl(NB_SSF,1), ind_deltaMax),L_ENR) < 0 ) + IF( LT_16(sub(shl(NB_SSF,1), ind_deltaMax),L_ENR)) { st_fx->old_ind_deltaMax_fx = ind_deltaMax; move16(); @@ -234,7 +231,7 @@ Word16 find_uv_fx( /* o : coding type move16(); dE2 = find_ener_decrease_fx( ind_deltaMax, pt_enr_ssf ); /*Q10*/ - if( L_sub(dE2,dE2_th) > 0) + if( GT_32(dE2,dE2_th)) { st_fx->spike_hyst_fx = 0; move16(); @@ -248,7 +245,7 @@ Word16 find_uv_fx( /* o : coding type Copy32( st_fx->old_enr_ssf_fx, enr_ssf, 2*NB_SSF ); dE2 = find_ener_decrease_fx( st_fx->old_ind_deltaMax_fx, enr_ssf ); - if( L_sub(dE2,dE2_th) > 0) + if( GT_32(dE2,dE2_th)) { st_fx->spike_hyst_fx = 1; move16(); @@ -266,7 +263,7 @@ Word16 find_uv_fx( /* o : coding type tmp_offset_flag = 1; move16(); - IF ( sub(st_fx->input_bwidth_fx, NB) != 0 ) + IF ( NE_16(st_fx->input_bwidth_fx, NB)) { ee0_th = 154; /*2.4 in Q6 */ move16(); voi_th = 24248; /*0.74f Q15 */ move16(); @@ -280,9 +277,9 @@ Word16 find_uv_fx( /* o : coding type test(); test(); test(); - if( ( sub(st_fx->last_coder_type_raw_fx,UNVOICED) == 0 ) || /* previous frame was unvoiced */ - ( ( L_sub(ee[0],ee0_th) < 0 ) && ( L_sub(hp_E[0],L_shl(E_MIN_FX,Q_new)) > 0 ) && /* energy is concentrated in high frequencies provided that some energy is present in HF */ - ( sub(add(voicing[0],corr_shift),voi_th) < 0 ) ) ) /* normalized correlation is low */ + if( ( EQ_16(st_fx->last_coder_type_raw_fx,UNVOICED))|| /* previous frame was unvoiced */ + ( ( LT_32(ee[0],ee0_th) ) && ( GT_32(hp_E[0],L_shl(E_MIN_FX,Q_new)) ) && /* energy is concentrated in high frequencies provided that some energy is present in HF */ + ( LT_16(add(voicing[0],corr_shift),voi_th)))) /* normalized correlation is low */ { tmp_offset_flag = 0; move16(); @@ -303,7 +300,7 @@ Word16 find_uv_fx( /* o : coding type ee1_th = 544; /*8.5f Q6*/ move16(); /* SC-VBR - determine the threshold on relative energy as a function of lp_noise */ - IF ( sub(st_fx->input_bwidth_fx,NB) != 0 ) + IF ( NE_16(st_fx->input_bwidth_fx,NB)) { /*relE_thres = 0.700f * st->lp_noise - 33.5f; (lp_noise in Q8, constant Q8<<16) */ L_tmp = L_mac(-562036736, 22938, st_fx->lp_noise_fx); @@ -324,7 +321,7 @@ Word16 find_uv_fx( /* o : coding type relE_thres = s_max(relE_thres , -6400); /* Q8 */ /* SC-VBR = set flag on low relative energy */ - if ( sub(relE,relE_thres) < 0 ) + if ( LT_16(relE,relE_thres)) { flag_low_relE = 1; move16(); @@ -332,7 +329,7 @@ Word16 find_uv_fx( /* o : coding type /* SC-VBR - correction of voicing threshold for NB inputs (important only in noisy conditions) */ test(); - if ( sub(st_fx->input_bwidth_fx,NB) == 0 && sub(st_fx->vadnoise_fx,20<<8) < 0 ) /* vadnoise in Q8, constant Q0<<8 */ + if ( EQ_16(st_fx->input_bwidth_fx,NB)&<_16(st_fx->vadnoise_fx,20<<8)) /* vadnoise in Q8, constant Q0<<8 */ { mean_voi3_offset = 1638; /*0.05f Q15*/ move16(); } @@ -342,7 +339,7 @@ Word16 find_uv_fx( /* o : coding type E_min_th = L_shl(E_MIN_FX,Q_new); coder_type = GENERIC; move16(); - IF ( sub(st_fx->input_bwidth_fx,NB) == 0 ) + IF ( EQ_16(st_fx->input_bwidth_fx,NB)) { test(); test(); @@ -355,14 +352,14 @@ Word16 find_uv_fx( /* o : coding type test(); test(); test(); - if( ( ( sub(add(mean_voi3, corr_shift),add(22282,mean_voi3_offset)) < 0) && /* normalized correlation low */ - ( ( sub(add(voicing[2], corr_shift),25887) ) < 0 ) && /* normalized correlation low on look-ahead - onset detection */ - ( L_sub(ee[0], 640) < 0 ) && ( L_sub(hp_E[0], E_min_th) > 0 ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ - ( L_sub(ee[1], ee1_th) < 0 ) && ( L_sub(hp_E[1], E_min_th) > 0 ) && /* ... biased towards look-ahead to detect onsets */ + if( ( ( LT_16(add(mean_voi3, corr_shift),add(22282,mean_voi3_offset)))&& /* normalized correlation low */ + ( LT_16(add(voicing[2], corr_shift),25887) ) && /* normalized correlation low on look-ahead - onset detection */ + ( LT_32(ee[0], 640) ) && ( GT_32(hp_E[0], E_min_th) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ + ( LT_32(ee[1], ee1_th) ) && ( GT_32(hp_E[1], E_min_th) ) && /* ... biased towards look-ahead to detect onsets */ ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ ( st_fx->music_hysteresis_fx == 0 ) && /* ... and in segment after AUDIO frames */ - ( L_sub(dE1, 237568) <= 0 ) && /* Avoid on sharp energy spikes */ - ( L_sub(st_fx->old_dE1_fx,237568) <= 0 ) && /* + one frame hysteresis */ + ( LE_32(dE1, 237568) ) && /* Avoid on sharp energy spikes */ + ( LE_32(st_fx->old_dE1_fx,237568) ) && /* + one frame hysteresis */ ( st_fx->spike_hyst_fx < 0 ) ) || /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ flag_low_relE ) /* low relative frame energy (only for SC-VBR) */ { @@ -384,17 +381,17 @@ Word16 find_uv_fx( /* o : coding type test(); test(); test(); - if( ( ( sub(add(mean_voi3, corr_shift),add(22774,mean_voi3_offset)) < 0) && /* normalized correlation low */ - ( ( sub(add(voicing[2], corr_shift),25887) ) < 0 ) && /* normalized correlation low on look-ahead - onset detection */ - ( L_sub(ee[0], 397) < 0 ) && ( L_sub(hp_E[0], E_min_th) > 0 ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ - ( L_sub(ee[1], 397) < 0 ) && ( L_sub(hp_E[1], E_min_th) > 0 ) && /* ... biased towards look-ahead to detect onsets */ + if( ( ( LT_16(add(mean_voi3, corr_shift),add(22774,mean_voi3_offset)))&& /* normalized correlation low */ + ( LT_16(add(voicing[2], corr_shift),25887) ) && /* normalized correlation low on look-ahead - onset detection */ + ( LT_32(ee[0], 397) ) && ( GT_32(hp_E[0], E_min_th) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ + ( LT_32(ee[1], 397) ) && ( GT_32(hp_E[1], E_min_th) ) && /* ... biased towards look-ahead to detect onsets */ ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ ( st_fx->music_hysteresis_fx == 0 ) && /* ... and in segment after AUDIO frames */ - ( L_sub(dE1, 245760) <= 0 ) && /* Avoid on sharp energy spikes */ - ( L_sub(st_fx->old_dE1_fx,245760) <= 0 ) && /* + one frame hysteresis */ + ( LE_32(dE1, 245760) ) && /* Avoid on sharp energy spikes */ + ( LE_32(st_fx->old_dE1_fx,245760) ) && /* + one frame hysteresis */ ( st_fx->spike_hyst_fx < 0 ) ) /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ || ( flag_low_relE - && ( L_sub(st_fx->old_dE1_fx,245760) <= 0 ) + && ( LE_32(st_fx->old_dE1_fx,245760) ) ) ) /* low relative frame energy (only for SC-VBR) */ { @@ -412,7 +409,7 @@ Word16 find_uv_fx( /* o : coding type test(); test(); - IF( sub(localVAD,1) == 0 && sub(coder_type,GENERIC) == 0 && sub(last_core_orig,AMR_WB_CORE) != 0 ) + IF( EQ_16(localVAD,1)&&EQ_16(coder_type,GENERIC)&&NE_16(last_core_orig,AMR_WB_CORE)) { dpit1 = abs_s( sub(T_op_fr[1], T_op_fr[0])); dpit2 = abs_s( sub(T_op_fr[2], T_op_fr[1])); @@ -427,19 +424,19 @@ Word16 find_uv_fx( /* o : coding type test(); test(); test(); - IF( ( sub(voicing_fr[0],19825)> 0 ) && /* normalized correlation high in 1st sf. */ - ( sub(voicing_fr[1],19825) > 0) && /* normalized correlation high in 2st sf. */ - ( sub(voicing_fr[2],19825) > 0) && /* normalized correlation high in 3st sf. */ - ( sub(voicing_fr[3],19825) > 0) && /* normalized correlation high in 4st sf. */ - ( L_sub(mean_ee,256) > 0 ) && /* energy concentrated in low frequencies */ - ( sub(dpit1,3<<6) < 0 ) && - ( sub(dpit2,3<<6) < 0 ) && - ( sub(dpit3,3<<6) < 0 ) ) + IF( ( GT_16(voicing_fr[0],19825))&& /* normalized correlation high in 1st sf. */ + ( GT_16(voicing_fr[1],19825) ) && /* normalized correlation high in 2st sf. */ + ( GT_16(voicing_fr[2],19825) ) && /* normalized correlation high in 3st sf. */ + ( GT_16(voicing_fr[3],19825) ) && /* normalized correlation high in 4st sf. */ + ( GT_32(mean_ee,256) ) && /* energy concentrated in low frequencies */ + ( LT_16(dpit1,3<<6) ) && + ( LT_16(dpit2,3<<6) ) && + ( LT_16(dpit3,3<<6) ) ) { coder_type = VOICED; move16(); } - ELSE IF ( st_fx->Opt_SC_VBR_fx && sub(st_fx->input_bwidth_fx,NB) == 0 && sub(st_fx->vadnoise_fx,20<<8) < 0 ) + ELSE IF ( st_fx->Opt_SC_VBR_fx && EQ_16(st_fx->input_bwidth_fx,NB)&<_16(st_fx->vadnoise_fx,20<<8)) { test(); test(); @@ -448,14 +445,14 @@ Word16 find_uv_fx( /* o : coding type test(); test(); test(); - IF( sub(voicing_fr[0],8192)> 0 && /* normalized correlation high in 1st sf. */ - ( sub(voicing_fr[1],8192) > 0) && /* normalized correlation high in 2st sf. */ - ( sub(voicing_fr[2],8192) > 0) && /* normalized correlation high in 3st sf. */ - ( sub(voicing_fr[3],8192) > 0) && /* normalized correlation high in 4st sf. */ - ( L_sub(mean_ee,64) > 0 ) && /* energy concentrated in low frequencies */ - ( sub(dpit1,5<<6) < 0 ) && - ( sub(dpit2,5<<6) < 0 ) && - ( sub(dpit3,5<<6) < 0 ) ) + IF( GT_16(voicing_fr[0],8192)&& /* normalized correlation high in 1st sf. */ + ( GT_16(voicing_fr[1],8192) ) && /* normalized correlation high in 2st sf. */ + ( GT_16(voicing_fr[2],8192) ) && /* normalized correlation high in 3st sf. */ + ( GT_16(voicing_fr[3],8192) ) && /* normalized correlation high in 4st sf. */ + ( GT_32(mean_ee,64) ) && /* energy concentrated in low frequencies */ + ( LT_16(dpit1,5<<6) ) && + ( LT_16(dpit2,5<<6) ) && + ( LT_16(dpit3,5<<6) ) ) { st_fx->set_ppp_generic_fx = 1; move16(); @@ -472,8 +469,8 @@ Word16 find_uv_fx( /* o : coding type test(); test(); test(); - IF ( *flag_spitch || ( sub(dpit1,3<<6) <= 0 && sub(dpit2,3<<6) <= 0 && sub(dpit3,3<<6) <= 0 && - sub(voicing_m, 31130) > 0 && sub(voicing_sm, 31785) > 0 ) ) + IF ( *flag_spitch || ( LE_16(dpit1,3<<6)&&LE_16(dpit2,3<<6)&&LE_16(dpit3,3<<6)&& + GT_16(voicing_m, 31130) && GT_16(voicing_sm, 31785) ) ) { coder_type = VOICED; move16(); @@ -489,17 +486,17 @@ Word16 find_uv_fx( /* o : coding type st_fx->rf_mode = st_fx->Opt_RF_ON; move16(); - IF ( sub ( coder_type, GENERIC ) == 0 ) + IF ( EQ_16 ( coder_type, GENERIC ) ) { test(); test(); test(); test(); - IF( ( sub(voicing_fr[0],6554) < 0) && /* normalized correlation high in 2st sf. */ - ( sub(voicing_fr[1],6554) < 0) && /* normalized correlation high in 2st sf. */ - ( sub(voicing_fr[2],6554) < 0) && /* normalized correlation high in 3rd sf. */ - ( sub(voicing_fr[3],6554) < 0) && /* normalized correlation high in 4th sf. */ - ( sub(st_fx->vadnoise_fx, 25 << 8 ) > 0 )) /* when speech is clean */ + IF( ( LT_16(voicing_fr[0],6554))&& /* normalized correlation high in 2st sf. */ + ( LT_16(voicing_fr[1],6554) ) && /* normalized correlation high in 2st sf. */ + ( LT_16(voicing_fr[2],6554) ) && /* normalized correlation high in 3rd sf. */ + ( LT_16(voicing_fr[3],6554) ) && /* normalized correlation high in 4th sf. */ + ( GT_16(st_fx->vadnoise_fx, 25 << 8 ) )) /* when speech is clean */ { st_fx->rf_mode = 0; @@ -523,7 +520,7 @@ Word16 find_uv_fx( /* o : coding type /* update spike hysteresis parameters */ test(); - if( st_fx->spike_hyst_fx >= 0 && sub(st_fx->spike_hyst_fx,2) < 0 ) + if( st_fx->spike_hyst_fx >= 0 && LT_16(st_fx->spike_hyst_fx,2)) { st_fx->spike_hyst_fx = add(st_fx->spike_hyst_fx,1); } @@ -532,9 +529,9 @@ Word16 find_uv_fx( /* o : coding type test(); test(); test(); - if( ( sub(st_fx->spike_hyst_fx,1) > 0 ) && - ( sub(dE3,5<<8) > 0 || /* energy increases */ - ( sub(relE, -3328) > 0 && ( sub(add(mean_voi3, corr_shift),22774) > 0) ) ) ) /* normalized correlation is high */ + if( ( GT_16(st_fx->spike_hyst_fx,1))&& + ( GT_16(dE3,5<<8) || /* energy increases */ + ( GT_16(relE, -3328)&&(GT_16(add(mean_voi3,corr_shift),22774))))) /* normalized correlation is high */ { st_fx->spike_hyst_fx = -1; move16(); diff --git a/lib_enc/find_wsp_fx.c b/lib_enc/find_wsp_fx.c index 137515cc11449896645b6317468f7d8644476b5d..0f73bd9e6daebafb09dc4cf37487ea7894be7fae 100644 --- a/lib_enc/find_wsp_fx.c +++ b/lib_enc/find_wsp_fx.c @@ -1,19 +1,15 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include #include #include "stl.h" -#include "wmc_auto.h" - #include "prot_fx.h" #include "options.h" #include "cnst_fx.h" #include "stl.h" -#include "wmc_auto.h" - @@ -62,7 +58,7 @@ void find_wsp( /*----------------------------------------------------------------* * Compute weighted speech for all subframes *----------------------------------------------------------------*/ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF p_Az = Aw; /*move16();*/ FOR (i_subfr = 0; i_subfr < L_frame; i_subfr += L_subfr) { @@ -70,7 +66,7 @@ void find_wsp( p_Az += (M+1); } p_Az -= (M+1); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON /*----------------------------------------------------------------* * Weighted speech computation is extended on look-ahead *----------------------------------------------------------------*/ diff --git a/lib_enc/frame_spec_dif_cor_rate.c b/lib_enc/frame_spec_dif_cor_rate.c index 7297432431aab96a7872f52eabd251e39088a758..7fd1cae783a359fa80d28b41a6639c11f42b6c84 100644 --- a/lib_enc/frame_spec_dif_cor_rate.c +++ b/lib_enc/frame_spec_dif_cor_rate.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ @@ -7,8 +7,6 @@ #include "basop_util.h" #include "stl.h" -#include "wmc_auto.h" - #include "vad_basop.h" #include "prot_fx.h" @@ -34,13 +32,14 @@ void frame_spec_dif_cor_rate(T_CldfbVadState *st, /*(io) vad state*/ p_dx_Q = &dx_Q; - maxVal = L_add(0,0); + maxVal = 0; move32(); FOR(i=0; i< PRE_SPEC_DIF_NUM; i++) { tmp = L_sub(spec_amp[i+6] ,spec_amp[i+5]); if ( tmp < 0 ) { - tmp = L_add(0,0); + tmp = 0; + move32(); } tmpspec_low_dif[i] = tmp; move32(); @@ -53,9 +52,9 @@ void frame_spec_dif_cor_rate(T_CldfbVadState *st, /*(io) vad state*/ resu = norm_l(maxVal); } - m = L_add(0,0); - dx = L_add(0,0); - dy = L_add(0,0); + m = 0; move32(); + dx = 0; move32(); + dy = 0; move32(); scalefactor = sub(resu,3); @@ -76,7 +75,7 @@ void frame_spec_dif_cor_rate(T_CldfbVadState *st, /*(io) vad state*/ move16(); *p_dx_Q = sub(*p_dx_Q ,32); move16(); - IF(sub(*p_dx_Q , 31)<0) + IF(LT_16(*p_dx_Q , 31)) { dx = L_add(dx,L_shr(FIX_cost1,limitScale32(sub(31,*p_dx_Q)))); } diff --git a/lib_enc/gain_enc_fx.c b/lib_enc/gain_enc_fx.c index 6c2d86731adb913e318e4d99db095166c907165e..be241f30d0a97602e6913861c46b2964a2e1925e 100644 --- a/lib_enc/gain_enc_fx.c +++ b/lib_enc/gain_enc_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -7,8 +7,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*-------------------------------------------------------------------* * Local constants @@ -69,7 +67,7 @@ void Es_pred_enc_fx( Lmean_ener_code = L_deposit_l(0); Q_res = sub(shl(Q_new, 1), 3); - IF( sub(L_frame,L_FRAME) == 0 ) + IF( EQ_16(L_frame,L_FRAME)) { weight = 8192; move16();/*0.25f in Q15*/ @@ -173,7 +171,7 @@ void Es_pred_enc_fx( FOR (i=1; i0) + IF(GT_16(exp1,exp2)) { L_tmp2 = L_shr(L_tmp2,sub(exp1,exp2)); /*Q31*/ exp_den = exp1; @@ -369,7 +367,7 @@ void gain_enc_mless_fx( L_tmp2 = L_shr(L_mult(coeff[1],coeff[2]),1); /*Q31*/ exp2 = add(exp_coeff[1], exp_coeff[2]); - IF(sub(exp1,exp2)>0) + IF(GT_16(exp1,exp2)) { L_tmp2 = L_shr(L_tmp2,sub(exp1,exp2)); /*Q31*/ exp_num = exp1; @@ -394,7 +392,7 @@ void gain_enc_mless_fx( L_tmp2 = L_shr(L_mult(coeff[0],coeff[3]),1); /*Q31*/ exp2 = add(exp_coeff[0], exp_coeff[3]); - IF(sub(exp1,exp2)>0) + IF(GT_16(exp1,exp2)) { L_tmp2 = L_shr(L_tmp2,sub(exp1,exp2)); /*Q31*/ exp_num = exp1; @@ -449,35 +447,35 @@ void gain_enc_mless_fx( { qua_table = gain_qua_mless_7b_fx; move16(); - if ( sub(clip_gain,1) == 0 ) size = sub(size,30); + if ( EQ_16(clip_gain,1))size=sub(size,30); BREAK; } case 6: { qua_table = gain_qua_mless_6b_fx; move16(); - if ( sub(clip_gain,1) == 0 ) size = sub(size,14); + if ( EQ_16(clip_gain,1))size=sub(size,14); BREAK; } case 5: { qua_table = gain_qua_mless_5b_fx; move16(); - if ( sub(clip_gain,1) == 0 ) size = sub(size,6); + if ( EQ_16(clip_gain,1))size=sub(size,6); BREAK; } default: { qua_table = gain_qua_mless_6b_fx; move16(); - if ( sub(clip_gain,1) == 0 ) size = sub(size,14); + if ( EQ_16(clip_gain,1))size=sub(size,14); BREAK; } } /* in case of AVQ inactive, limit the gain_pit to 0.65 */ test(); - IF( sub(clip_gain,2) == 0 && sub(nBits,6) == 0 ) + IF( EQ_16(clip_gain,2)&&EQ_16(nBits,6)) { size = sub(size,36); nBits = sub(nBits,1); @@ -646,7 +644,7 @@ void gain_enc_SQ_fx( L_tmp2 = L_mult(coeff[4],coeff[4]); /*Q31*/ exp2 = add(exp_coeff[4], exp_coeff[4]); - IF(sub(exp1,exp2)>0) + IF(GT_16(exp1,exp2)) { L_tmp2 = L_shr(L_tmp2,sub(exp1,exp2)); /*Q31*/ exp_den = exp1; @@ -674,7 +672,7 @@ void gain_enc_SQ_fx( L_tmp2 = L_mult(coeff[1],coeff[2]); /*Q31*/ exp2 = add(exp_coeff[1], exp_coeff[2]); - IF(sub(exp1,exp2)>0) + IF(GT_16(exp1,exp2)) { L_tmp2 = L_shr(L_tmp2,sub(exp1,exp2)); /*Q31*/ exp_num = exp1; @@ -699,7 +697,7 @@ void gain_enc_SQ_fx( L_tmp2 = L_mult(coeff[0],coeff[3]); /*Q31*/ exp2 = add(exp_coeff[0], exp_coeff[3]); - IF(sub(exp1,exp2)>0) + IF(GT_16(exp1,exp2)) { L_tmp2 = L_shr(L_tmp2,sub(exp1,exp2)); /*Q31*/ exp_num = exp1; @@ -725,12 +723,12 @@ void gain_enc_SQ_fx( test(); test(); - IF( sub(clip_gain,1) == 0 && sub(*gain_pit, 15565) > 0) + IF( EQ_16(clip_gain,1)&>_16(*gain_pit,15565)) { *gain_pit = 15565; move16(); } - ELSE IF( sub(clip_gain,2) == 0 && sub(*gain_pit,10650) > 0 ) + ELSE IF( EQ_16(clip_gain,2)&>_16(*gain_pit,10650)) { *gain_pit = 10650; move16(); @@ -868,7 +866,7 @@ void gain_enc_tc_fx( /*----------------------------------------------------------------* * get number of bits for gain quantization *----------------------------------------------------------------*/ - IF( sub(L_frame,L_FRAME) == 0 ) + IF( EQ_16(L_frame,L_FRAME)) { nBits = gain_bits_tbl[BIT_ALLOC_IDX_fx(core_brate, TRANSITION, i_subfr, TC_SUBFR2IDX_fx(tc_subfr))]; move16(); @@ -924,7 +922,8 @@ void gain_enc_tc_fx( expg = sub(expg, 18 + 6); /* exp: -18 (code in Q9), -6 (/L_SUBFR) */ expg2 = expg; move16(); - L_tmp1 = L_add(0,L_tmp); /* sets to 'L_tmp' in 1 clock */ + L_tmp1 = L_tmp; /* sets to 'L_tmp' in 1 clock */ + move32(); L_tmp = Isqrt_lc(L_tmp, &expg); *gain_inov_fx = extract_h(L_shl(L_tmp, sub(expg, 3))); @@ -948,7 +947,7 @@ void gain_enc_tc_fx( frac = L_Extract_lc(L_tmp, &exp_gcode0); /* Extract exponent of gcode0 */ gcode0_fx = extract_l(Pow2(14, frac));/* Put 14 as exponent so that */ exp_gcode0 = sub(exp_gcode0, 14); - IF( sub(nBits,3) > 0 ) + IF( GT_16(nBits,3)) { /*g_code = *gain_code / gcode0;*/ IF(gcode0_fx != 0) @@ -981,7 +980,7 @@ void gain_enc_tc_fx( L_tmp = L_mult(tbl_gain_code_tc_quant_mean[i], gcode0_fx); /* Q13*Q0 -> Q14 */ L_tmp = L_shl(L_tmp, add(exp_gcode0, 2)); /* Q14 -> Q16 */ - IF( L_sub(*gain_code_fx, L_tmp) < 0 ) + IF( LT_32(*gain_code_fx, L_tmp)) { index = i; move16(); @@ -991,7 +990,7 @@ void gain_enc_tc_fx( /*----------------------------------------------------------------* * 3-bit -> 2-bit encoding *----------------------------------------------------------------*/ - IF( sub(nBits,2) == 0 ) + IF( EQ_16(nBits,2)) { /* 2-bit -> 3-bit decoding */ index = shr(index ,1); @@ -1241,7 +1240,8 @@ void gain_enc_lbr_fx( /*Ecode = ( dotp( code, code, L_SUBFR ) + 0.01f ) / L_SUBFR; *gain_inov = 1.0f / (float)sqrt(Ecode);*/ L_tmp = Dot_product12(code, code, L_SUBFR, &exp_code); - L_inov = L_add(0,L_tmp); /* sets to 'L_tmp' in 1 clock */ + L_inov = L_tmp; /* sets to 'L_tmp' in 1 clock */ + move32(); /* exp_code: -18 (code in Q9), -6 (/L_SUBFR), -31 (L_tmp Q31->Q0) */ /* output gain_inov*/ exp_inov = sub(exp_code, 18 + 6); @@ -1277,7 +1277,7 @@ void gain_enc_lbr_fx( { cdbk = gp_gamma_1sfr_8b_fx; move16(); - if ( sub(clip_gain,1) == 0 ) size = sub(size,60); + if ( EQ_16(clip_gain,1))size=sub(size,60); move16(); BREAK; } @@ -1285,7 +1285,7 @@ void gain_enc_lbr_fx( { cdbk = gp_gamma_1sfr_7b_fx; move16(); - if ( sub(clip_gain,1) == 0 ) size = sub(size,27); + if ( EQ_16(clip_gain,1))size=sub(size,27); move16(); BREAK; } @@ -1293,7 +1293,7 @@ void gain_enc_lbr_fx( { cdbk = gp_gamma_1sfr_6b_fx; move16(); - if ( sub(clip_gain,1) == 0 ) size = sub(size,10); + if ( EQ_16(clip_gain,1))size=sub(size,10); move16(); BREAK; } @@ -1341,7 +1341,7 @@ void gain_enc_lbr_fx( gp_mem[0] = *gain_pit; move16();/*Q14*/ } - ELSE IF (sub(i_subfr,L_SUBFR) == 0) + ELSE IF (EQ_16(i_subfr,L_SUBFR)) { b = b_2sfr_fx; move16(); @@ -1354,7 +1354,7 @@ void gain_enc_lbr_fx( { cdbk = gp_gamma_2sfr_7b_fx; move16(); - if ( sub(clip_gain,1) == 0 ) size = sub(size,30); + if ( EQ_16(clip_gain,1))size=sub(size,30); move16(); BREAK; } @@ -1362,7 +1362,7 @@ void gain_enc_lbr_fx( { cdbk = gp_gamma_2sfr_6b_fx; move16(); - if ( sub(clip_gain,1) == 0 ) size = sub(size,12); + if ( EQ_16(clip_gain,1))size=sub(size,12); move16(); BREAK; } @@ -1406,7 +1406,7 @@ void gain_enc_lbr_fx( gp_mem[1] = *gain_pit; move16(); } - ELSE IF (sub(i_subfr,2*L_SUBFR) == 0) + ELSE IF (EQ_16(i_subfr,2*L_SUBFR)) { b = b_3sfr_fx; move16(); @@ -1414,7 +1414,7 @@ void gain_enc_lbr_fx( move16(); cdbk = gp_gamma_3sfr_6b_fx; move16(); - if ( sub(clip_gain,1) == 0 ) + if ( EQ_16(clip_gain,1)) { size = sub(size,11); } @@ -1494,7 +1494,7 @@ void gain_enc_lbr_fx( gp_mem[2] = *gain_pit; move16(); } - ELSE IF (sub(i_subfr,3*L_SUBFR) == 0) + ELSE IF (EQ_16(i_subfr,3*L_SUBFR)) { b = b_4sfr_fx; move16(); @@ -1503,7 +1503,7 @@ void gain_enc_lbr_fx( cdbk = gp_gamma_4sfr_6b_fx; move16(); - if ( sub(clip_gain,1) == 0 ) + if ( EQ_16(clip_gain,1)) { size = sub(size,11); move16(); @@ -1629,7 +1629,7 @@ void gain_enc_amr_wb_fx( j = NB_QUA_GAIN7B - RANGE; move16(); - IF (sub(clip_gain, 1) == 0) + IF (EQ_16(clip_gain, 1)) { j = sub(j, 27); /* limit gain pitch to 1.0 */ } @@ -1640,7 +1640,7 @@ void gain_enc_amr_wb_fx( FOR (i = 0; i < j; i++) { - if (sub(g_pitch, *p) > 0) + if (GT_16(g_pitch, *p)) { min_ind = add(min_ind, 1); } @@ -1657,7 +1657,7 @@ void gain_enc_amr_wb_fx( move16(); size = RANGE; move16(); - if (sub(clip_gain, 1) == 0) + if (EQ_16(clip_gain, 1)) { size = sub(size, 16); /* limit gain pitch to 1.0 */ } diff --git a/lib_enc/gaus_enc_fx.c b/lib_enc/gaus_enc_fx.c index af7506fd0975f873971cea18cc8eb4033c75f19a..0d749c9fb197b713472570253ac26e2627540462 100644 --- a/lib_enc/gaus_enc_fx.c +++ b/lib_enc/gaus_enc_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -8,8 +8,6 @@ #include "rom_enc_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - #include "basop_mpy.h" /*-------------------------------------------------------------------* @@ -329,7 +327,7 @@ void gauss2v_fx( DO { - IF (L_sub(cora, max[j]) >= 0) + IF (GE_32(cora, max[j])) { max[j+1] = max[j]; move32(); /*Q31*/ @@ -426,8 +424,8 @@ void gauss2v_fx( IF (difference_norm > 0) { - if (L_sub(L_shr(L_mult(cor2_mantissa, enerw_mantissa), difference_norm), - L_mult(cor2w_mantissa, eneri_mantissa)) > 0) + if (GT_32(L_shr(L_mult(cor2_mantissa, enerw_mantissa), difference_norm), + L_mult(cor2w_mantissa, eneri_mantissa))) { update_best = 1; move16(); @@ -623,9 +621,9 @@ static Word16 cod_2pos_fx( /* o : codebook quantization index */ move16(); } - IF (sub(s1, s2)==0) + IF (EQ_16(s1, s2)) { - IF (sub(ind1, ind2) <= 0) + IF (LE_16(ind1, ind2)) { i1 = ind1; move16(); @@ -642,7 +640,7 @@ static Word16 cod_2pos_fx( /* o : codebook quantization index */ } ELSE { - IF (sub(ind1, ind2)>0) + IF (GT_16(ind1, ind2)) { i1 = ind1; move16(); diff --git a/lib_enc/gp_clip_fx.c b/lib_enc/gp_clip_fx.c index ed45b77ee66b7d65c950e16768ee36ec44d6af73..e935551253ac4169bb283814e6eee64d12e12eab 100644 --- a/lib_enc/gp_clip_fx.c +++ b/lib_enc/gp_clip_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -7,8 +7,6 @@ #include "prot_fx.h" /* Function prototypes */ #include "basop_util.h" #include "stl.h" -#include "wmc_auto.h" - /*-------------------------------------------------------------------* * Local constants @@ -89,7 +87,7 @@ Word16 gp_clip_fx( { thres = add(14746, mult(1638, extract_l(L_mult(mem[0], (Word16)(16384/DIST_ISF_MAX_IO))))); /* clipping is activated when filtered pitch gain > threshold (0.94 to 1 in Q14) */ test(); - if (sub(mem[1], thres) > 0) + if (GT_16(mem[1], thres)) { clip = 1; move16(); @@ -98,7 +96,7 @@ Word16 gp_clip_fx( ELSE { test(); - if(sub(mem[0], DIST_ISF_THRES) < 0 && sub(mem[1], GAIN_PIT_THRES) > 0) + if(LT_16(mem[0], DIST_ISF_THRES)&>_16(mem[1],GAIN_PIT_THRES)) { clip = 1; move16(); @@ -120,7 +118,7 @@ Word16 gp_clip_fx( wener = round_fx(L_shl(ener, 10)); test(); - if (sub(wener, sub(mem[2], 1536)) < 0 && sub(mem[1], 16384) > 0) + if (LT_16(wener, sub(mem[2], 1536))&>_16(mem[1],16384)) { clip = 1; move16(); @@ -133,7 +131,7 @@ Word16 gp_clip_fx( test(); test(); - if (sub(coder_type,GENERIC) == 0 || sub(coder_type,TRANSITION) == 0 || sub(coder_type,INACTIVE) == 0 ) + if (EQ_16(coder_type,GENERIC)||EQ_16(coder_type,TRANSITION)||EQ_16(coder_type,INACTIVE)) { /* mem[4] = (1-ALPHA1) + ALPHA1 * mem[4], if branch taken */ /* mem[4] = ALPHA1 * mem[4], otherwise */ @@ -149,17 +147,17 @@ Word16 gp_clip_fx( move16(); /* /2 to put voicing from Q15 to Q14 */ } - if (sub(i_subfr, 2*L_SUBFR) == 0) + if (EQ_16(i_subfr, 2*L_SUBFR)) { /* mem[5] = (1-ALPHA4) * voicing[1] + ALPHA4 * mem[5] */ mem[5] = mac_r(L_tmp, (32768-ALPHA4)/2, voicing[1]); move16(); /* /2 to put voicing from Q15 to Q14 */ } - IF (sub(mem[3], WINDOW_SIZE) > 0) + IF (GT_16(mem[3], WINDOW_SIZE)) { test(); - if (sub(mem[4], THRESH_TYPE) > 0 && sub(mem[5], THRESH_VOICING) > 0) + if (GT_16(mem[4], THRESH_TYPE)&>_16(mem[5],THRESH_VOICING)) { clip = 1; move16(); @@ -193,7 +191,7 @@ void gp_clip_test_isf_fx( m = M; move16(); - if ( sub(Opt_AMR_WB,1)==0 ) + if ( EQ_16(Opt_AMR_WB,1)) { m = M-1; move16(); @@ -291,7 +289,7 @@ Word16 Mode2_gp_clip( clip = 0; test(); - if ((sub(mem[0],DIST_ISF_THRES) < 0) && (sub(mem[1],GAIN_PIT_THRES) > 0)) + if ((LT_16(mem[0],DIST_ISF_THRES))&&(GT_16(mem[1],GAIN_PIT_THRES))) { move16(); clip = 1; @@ -318,8 +316,8 @@ Word16 Mode2_gp_clip( /* exponent of wener = 6+2 */ test(); - if (sub(tmp, sub(mem[2], 768/*6.0f Q7*/)) < 0 && - sub(mem[1],16384/*1.0f Q14*/) > 0) + if (LT_16(tmp, sub(mem[2], 768/*6.0f Q7*/))&& + GT_16(mem[1],16384/*1.0f Q14*/) ) { move16(); clip = 1; @@ -329,7 +327,7 @@ Word16 Mode2_gp_clip( mem[2] = tmp; /* wener in 8Q7 format */ Ltmp = Mpy_32_16_1(ALPHA1, mem[4]); /* mem[4] in Q14 format, Ltmp in Q14 */ - if( s_or(sub(coder_type,GENERIC) == 0, sub(coder_type,TRANSITION) == 0) ) + if( s_or((Word16)EQ_16(coder_type,GENERIC),(Word16)EQ_16(coder_type,TRANSITION))) { Ltmp = L_add(Ltmp, ALPHA1_M1); } @@ -341,16 +339,16 @@ Word16 Mode2_gp_clip( move16(); /* voicing: Q15 */ mem[5] = round_fx(L_add(Mpy_32_16_1(ALPHA4_M1, voicing[0]), Ltmp)); } - ELSE IF( sub(i_subfr,shl(L_subfr,1)) == 0 ) + ELSE IF( EQ_16(i_subfr,shl(L_subfr,1))) { move16(); mem[5] = round_fx(L_add(Mpy_32_16_1(ALPHA4_M1, voicing[1]), Ltmp)); } - IF( sub(mem[3],WINDOW_SIZE) > 0 ) + IF( GT_16(mem[3],WINDOW_SIZE)) { test(); - if( ( sub(mem[4],THRESH_TYPE) > 0 ) && ( sub(mem[5],THRESH_VOICING) > 0 )) + if( ( GT_16(mem[4],THRESH_TYPE))&&(GT_16(mem[5],THRESH_VOICING))) { move16(); clip = 1; diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index 5f21bf9bb22dd256a4ed930347be3d1020908c81..71f60e4020ce09ec06c05afbf099f44914dcfd3f 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" @@ -7,8 +7,6 @@ #include "rom_com_fx.h" #include "prot_fx.h" #include "stl.h" -#include "wmc_auto.h" - /*-------------------------------------------------------------------* * Local functions @@ -82,7 +80,7 @@ void encod_audio_fx( push_indice_fx( st_fx, IND_GSC_ATTACK, attack_flag, 1 ); test(); - IF( sub(coder_type,INACTIVE ) != 0&& L_sub(st_fx->total_brate_fx,ACELP_13k20) >= 0) + IF( NE_16(coder_type,INACTIVE )&&GE_32(st_fx->total_brate_fx,ACELP_13k20)) { push_indice_fx( st_fx,IND_GSC_SWB_SPEECH, st_fx->GSC_noisy_speech_fx, 1); } @@ -90,12 +88,12 @@ void encod_audio_fx( * Find and encode the number of subframes *---------------------------------------------------------------*/ test(); - IF ( L_sub(st_fx->core_brate_fx,ACELP_9k60) >= 0&& L_sub(st_fx->core_brate_fx,ACELP_13k20) <= 0 ) + IF ( GE_32(st_fx->core_brate_fx,ACELP_9k60)&&LE_32(st_fx->core_brate_fx,ACELP_13k20)) { FOR( i = 0; i < 5; i++) { test(); - if( sub(abs_s(st_fx->gsc_lt_diff_etot_fx[MAX_LT-i-1]),1536) > 0 && sub(st_fx->cor_strong_limit_fx,1) == 0 ) + if( GT_16(abs_s(st_fx->gsc_lt_diff_etot_fx[MAX_LT-i-1]),1536)&&EQ_16(st_fx->cor_strong_limit_fx,1)) { st_fx->cor_strong_limit_fx = 0; move16(); @@ -115,7 +113,7 @@ void encod_audio_fx( { test(); test(); - IF( (st_fx->cor_strong_limit_fx == 0 || sub(coder_type,INACTIVE) == 0) && L_sub(st_fx->core_brate_fx,ACELP_9k60) >= 0 ) + IF( (st_fx->cor_strong_limit_fx == 0 || EQ_16(coder_type,INACTIVE))&&GE_32(st_fx->core_brate_fx,ACELP_9k60)) { nb_subfr = 2; move16(); @@ -131,7 +129,7 @@ void encod_audio_fx( nb_subfr_flag = 1; move16(); } - IF( L_sub(st_fx->core_brate_fx,ACELP_9k60) >= 0 ) + IF( GE_32(st_fx->core_brate_fx,ACELP_9k60)) { /* nb_subfr_flag can only have the value 0 or 1 */ push_indice_fx( st_fx, IND_HF_NOISE, nb_subfr_flag, 1); @@ -143,7 +141,7 @@ void encod_audio_fx( *---------------------------------------------------------------*/ test(); - IF( st_fx->GSC_noisy_speech_fx && sub(nb_subfr,NB_SUBFR ) == 0 ) + IF( st_fx->GSC_noisy_speech_fx && EQ_16(nb_subfr,NB_SUBFR )) { nb_bits = Es_pred_bits_tbl[BIT_ALLOC_IDX_fx(st_fx->core_brate_fx, GENERIC, -1, -1)]; move16(); @@ -171,7 +169,7 @@ void encod_audio_fx( } m_mean = round_fx(Lm_mean);/*Q7*/ - IF( sub(m_mean,st_fx->mid_dyn_fx) > 0 ) + IF( GT_16(m_mean,st_fx->mid_dyn_fx)) { /*st_fx->mid_dyn_fx = 0.2f * st_fx->mid_dyn_fx + 0.8f * m_mean;*/ st_fx->mid_dyn_fx = round_fx(L_mac(L_mult(26214,m_mean),6554,st_fx->mid_dyn_fx));/*Q7*/ @@ -181,7 +179,7 @@ void encod_audio_fx( /*st_fx->mid_dyn_fx = 0.6f * st_fx->mid_dyn_fx + 0.4f * m_mean;*/ st_fx->mid_dyn_fx = round_fx(L_mac(L_mult(13107,m_mean),19661,st_fx->mid_dyn_fx));/*Q7*/ } - IF( sub(coder_type,INACTIVE) != 0 ) + IF( NE_16(coder_type,INACTIVE)) { st_fx->noise_lev_fx = sub((NOISE_LEVEL_SP3+1), usquant_fx(st_fx->mid_dyn_fx, &m_mean, MIN_DYNAMIC_FX, shr(GSF_NF_DELTA_FX,1), GSC_NF_STEPS)); @@ -190,7 +188,7 @@ void encod_audio_fx( st_fx->past_dyn_dec_fx = st_fx->noise_lev_fx; move16(); - IF( L_sub(st_fx->core_brate_fx,ACELP_8k00) <= 0) + IF( LE_32(st_fx->core_brate_fx,ACELP_8k00)) { st_fx->noise_lev_fx = s_max(st_fx->noise_lev_fx, NOISE_LEVEL_SP2); push_indice_fx( st_fx, IND_NOISE_LEVEL, sub(st_fx->noise_lev_fx, NOISE_LEVEL_SP2), 2 ); @@ -237,7 +235,7 @@ void encod_audio_fx( tmp_nb_bits_tot = sub(tmp_nb_bits_tot,1); } test(); - if( sub(coder_type,INACTIVE) == 0 && L_sub(st_fx->core_brate_fx,ACELP_9k60) <= 0 ) + if( EQ_16(coder_type,INACTIVE)&&LE_32(st_fx->core_brate_fx,ACELP_9k60)) { /* add 5 bits for noisiness */ tmp_nb_bits_tot = add(tmp_nb_bits_tot,5); @@ -436,8 +434,8 @@ static void gsc_enc_fx( move16(); } test(); - IF( sub(st_fx->last_coder_type_fx, AUDIO) != 0 /* First audio frame */ - && sub(st_fx->last_coder_type_fx, UNVOICED) != 0 )/* last_coder_type == INACTIVE is overwritten in update_enc to UNVOICED */ + IF( NE_16(st_fx->last_coder_type_fx, AUDIO) /* First audio frame */ + && NE_16(st_fx->last_coder_type_fx, UNVOICED) )/* last_coder_type == INACTIVE is overwritten in update_enc to UNVOICED */ { FOR( j = 0; j < shl(nb_subbands,4); j++ ) { @@ -455,7 +453,7 @@ static void gsc_enc_fx( move16(); } test(); - IF( L_sub(st_fx->core_brate_fx,ACELP_8k00) == 0 && sub(st_fx->bwidth_fx,NB) != 0 ) + IF( EQ_32(st_fx->core_brate_fx,ACELP_8k00)&&NE_16(st_fx->bwidth_fx,NB)) { bitallocation_exc[0] = 0; move16(); diff --git a/lib_enc/guided_plc_enc.c b/lib_enc/guided_plc_enc.c index 8d4a0f095ca0c11b0e2b6a01e16415c3889a265f..421ad3d30fac5a6dd4f28ee5d7c5268e7c2965dd 100644 --- a/lib_enc/guided_plc_enc.c +++ b/lib_enc/guided_plc_enc.c @@ -1,11 +1,9 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "stl.h" -#include "wmc_auto.h" - #include "prot_fx.h" #include "stat_dec_fx.h" #include "basop_util.h" @@ -43,7 +41,7 @@ void coderLookAheadInnovation( /* Debug init (not instrumented) */ T0_fx = -3000; subfr_len = shl(L_SUBFR,1); /* 2*L_SUBFR */ - if( sub( L_FRAME16k, L_frame ) > 0 ) + if( GT_16( L_FRAME16k, L_frame )) { subfr_len = add(L_SUBFR,48); /* 1.75*L_SUBFR */ } @@ -126,7 +124,7 @@ void coderLookAheadInnovation( FOR( i=-search_range; ipit_max)>0 || sub(add(prev_pitch,i),st->pit_min)<0 ) + IF( GT_16(add(prev_pitch,i),st->pit_max)||LT_16(add(prev_pitch,i),st->pit_min)) { CONTINUE; } @@ -158,12 +156,12 @@ void coderLookAheadInnovation( ps_e = add(alp_e,ps_e); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF max_ps_tmp = L_shl(max_ps,sub(max_ps_e,ps_e)); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON - IF (L_sub(max_ps_tmp , ps) < 0) + IF (LT_32(max_ps_tmp , ps)) { max_ps = L_add(ps, 0); max_ps_e = ps_e; @@ -200,14 +198,14 @@ void enc_prm_side_Info( HANDLE_PLC_ENC_EVS hPlc_Ext, Encoder_State_fx *st ) search_range = 8; move16(); - IF( sub(hPlc_Ext->nBits,1)>0 ) + IF( GT_16(hPlc_Ext->nBits,1)) { push_next_indice_fx(st, 1, 1); diff_pitch = sub(hPlc_Ext->T0, hPlc_Ext->T0_4th); test(); - if( (sub(diff_pitch,sub(search_range,1)) > 0) || (sub(diff_pitch,add(-search_range,1)) < 0) ) + if( (GT_16(diff_pitch,sub(search_range,1)))||(LT_16(diff_pitch,add(-search_range,1)))) { diff_pitch = -8; move16(); @@ -245,7 +243,7 @@ void encoderSideLossSimulation( *************************************************************/ /* Decoder State Update */ - IF( sub(L_frame,L_FRAME_16k)==0 ) + IF( EQ_16(L_frame,L_FRAME_16k)) { lsf2lsp_fx( lsf_q, lspLocal_Q15, M, INT_FS_16k_FX ); } @@ -356,7 +354,7 @@ Word16 encSideSpecPowDiffuseDetector( cnt_imprv = 0; - IF( L_sub( sr_core, 16000 ) == 0 ) + IF( EQ_32( sr_core, 16000 )) { th = 2560; move16(); /* LSF */ @@ -378,7 +376,7 @@ Word16 encSideSpecPowDiffuseDetector( tmp = sub(lsf_mod[i], lsf_ref[i]); dist2 = L_mult(tmp, tmp); - if(L_sub(dist1, dist2) > 0) + if(GT_32(dist1, dist2)) { cnt_imprv = add(cnt_imprv, 1); } @@ -392,11 +390,11 @@ Word16 encSideSpecPowDiffuseDetector( test(); test(); test(); - if(L_sub(cum_dist1, L_add(cum_dist2, Mpy_32_16_1(cum_dist2, 4915))) > 0 - && sub(sub(lsf4_mean, *prev_lsf4_mean), th_dif) > 0 - && sub(*prev_lsf4_mean, th) < 0 - && sub(cnt_imprv, 2) > 0 - && sub(coder_type, GENERIC) == 0 ) + if(GT_32(cum_dist1, L_add(cum_dist2, Mpy_32_16_1(cum_dist2, 4915))) + && GT_16(sub(lsf4_mean, *prev_lsf4_mean), th_dif) + && LT_16(*prev_lsf4_mean, th) + && GT_16(cnt_imprv, 2) + && EQ_16(coder_type, GENERIC) ) { idx = 1; move16(); @@ -434,8 +432,8 @@ void updateSpecPowDiffuseIdx( Encoder_State_fx *st) /* Suppress saturation warning in threshold comparison. */ test(); - if(L_sub(st->mean_gc[1], L_add(st->mean_gc[0], Mpy_32_16_r(st->mean_gc[0], 3211/*0.098 Q15*/))) < 0 || - sub(min_gp, 13435/*0.82 Q14*/) > 0) + if(LT_32(st->mean_gc[1], L_add(st->mean_gc[0], Mpy_32_16_r(st->mean_gc[0], 3211/*0.098 Q15*/)))|| + GT_16(min_gp, 13435/*0.82 Q14*/)) { move16(); st->glr_idx [0]= 0; diff --git a/lib_enc/hf_cod_amrwb_fx.c b/lib_enc/hf_cod_amrwb_fx.c index ed08c2374641e0e5b8d12b442d6755db53f2694e..4191dd433de03ccba6eec18607274486c04c491e 100644 --- a/lib_enc/hf_cod_amrwb_fx.c +++ b/lib_enc/hf_cod_amrwb_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "prot_fx.h" #include "rom_com_fx.h" #include "stl.h" -#include "wmc_auto.h" - #include "cnst_fx.h" /*---------------------------------------------------------------------* @@ -119,7 +117,7 @@ void hf_cod_fx( ener_fx = dot_prod_satcontr(&synth_fx[1], &synth_fx[1], sub(Q_syn, 4), sub(Q_syn, 4), &q1, sub(L_SUBFR, 1)); tmp_fx = dot_prod_satcontr(&synth_fx[1], synth_fx, sub(Q_syn ,4), sub(Q_syn, 4), &q2, sub(L_SUBFR, 1)); - IF ( sub(abs_s(tmp_fx), ener_fx )>=0 ) + IF ( GE_16(abs_s(tmp_fx), ener_fx )) { tmp_fx = shr(tmp_fx, 1); q2 = sub(q2, 1); @@ -145,7 +143,7 @@ void hf_cod_fx( HF_est_gain_fx = sub(1024, fac_fx); /*Q12 */ test(); - IF( L_sub(core_brate_fx, SID_1k75) == 0 || core_brate_fx == FRAME_NO_DATA ) + IF( EQ_32(core_brate_fx, SID_1k75)||core_brate_fx==FRAME_NO_DATA) { HF_est_gain_fx = round_fx(L_shl(L_mult(HF_est_gain_fx, 20480), 1)); /*Q10 */ } @@ -181,7 +179,7 @@ void hf_cod_fx( /* set energy of HF synthesis to energy of original HF: cross-fade between HF levels in active and inactive frame in hangover period */ - IF ( sub(4, dtxHangoverCount_fx) > 0 ) + IF ( GT_16(4, dtxHangoverCount_fx)) { *gain_alpha_fx = 16384; move16(); @@ -194,7 +192,7 @@ void hf_cod_fx( } L_tmp = L_mult(sub(16384, *gain_alpha_fx), HF_est_gain_fx); /*Q25 */ L_tmp = L_mac(L_tmp, *gain_alpha_fx, HF_calc_gain_fx); /*Q25 */ - IF (L_sub(L_tmp,67108863) >= 0 ) + IF (GE_32(L_tmp,67108863)) { L_tmp = 67108863; move32(); @@ -212,7 +210,7 @@ void hf_cod_fx( { dist_fx = L_mult(sub(HF_corr_gain_fx, *pt2), sub(HF_corr_gain_fx, *pt2)); pt2++; - IF ( L_sub(dist_min_fx, dist_fx) > 0 ) + IF ( GT_32(dist_min_fx, dist_fx)) { dist_min_fx = L_add(dist_fx, 0); HF_gain_ind_fx = i; diff --git a/lib_enc/hq_classifier_enc_fx.c b/lib_enc/hq_classifier_enc_fx.c index ddf0103ee36290443561fce67bfbd2fd6559ab93..e74a937066a07878692611fd1929e563a48cbf5e 100644 --- a/lib_enc/hq_classifier_enc_fx.c +++ b/lib_enc/hq_classifier_enc_fx.c @@ -1,14 +1,12 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "cnst_fx.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #include "rom_com_fx.h" /* Static table prototypes */ -#include "stl.h" -#include "wmc_auto.h" - /* Debug prototypes */ +#include "stl.h" /* Debug prototypes */ /*-----------------------------------------------------------------* * Local constants @@ -46,7 +44,7 @@ Word16 hq_classifier_enc_fx( /* o : Consumed bits Q0 Word16 bits; *hqswb_clas = HQ_NORMAL; - IF( sub( is_transient, 1) == 0 ) + IF( EQ_16( is_transient, 1)) { *hqswb_clas = HQ_TRANSIENT; move16(); @@ -56,7 +54,7 @@ Word16 hq_classifier_enc_fx( /* o : Consumed bits Q0 test(); test(); test(); - IF( sub(length, L_FRAME32k) == 0 && sub(is_transient,1) != 0 && L_sub(st_fx->core_brate_fx, HQ_32k) <= 0 && sub(st_fx->bwidth_fx, st_fx->last_bwidth_fx) == 0 ) + IF( EQ_16(length, L_FRAME32k)&&NE_16(is_transient,1)&&LE_32(st_fx->core_brate_fx,HQ_32k)&&EQ_16(st_fx->bwidth_fx,st_fx->last_bwidth_fx)) { /* Detect HQ_HARMONIC mode */ *hqswb_clas = peak_avrg_ratio_fx( st_fx->total_brate_fx, coefs, NUMC_N+96, &st_fx->mode_count_fx, &st_fx->mode_count1_fx, 12 ); @@ -69,7 +67,7 @@ Word16 hq_classifier_enc_fx( /* o : Consumed bits Q0 test(); test(); test(); - IF ( sub(length, L_FRAME48k) == 0 && sub( is_transient, 1) != 0 && L_sub(st_fx->core_brate_fx, HQ_32k) <= 0 && sub( st_fx->bwidth_fx, st_fx->last_bwidth_fx) == 0 ) + IF ( EQ_16(length, L_FRAME48k)&&NE_16(is_transient,1)&&LE_32(st_fx->core_brate_fx,HQ_32k)&&EQ_16(st_fx->bwidth_fx,st_fx->last_bwidth_fx)) { /* Detect HQ_HARMONIC mode */ *hqswb_clas = peak_avrg_ratio_fx( st_fx->total_brate_fx, coefs, NUMC_N+96, &st_fx->mode_count_fx, &st_fx->mode_count1_fx, 12); @@ -80,14 +78,14 @@ Word16 hq_classifier_enc_fx( /* o : Consumed bits Q0 test(); test(); - IF( sub(length, L_FRAME48k) == 0 && L_sub(st_fx->core_brate_fx, HQ_32k) <= 0 && sub(*hqswb_clas,HQ_NORMAL) == 0 ) + IF( EQ_16(length, L_FRAME48k)&&LE_32(st_fx->core_brate_fx,HQ_32k)&&EQ_16(*hqswb_clas,HQ_NORMAL)) { *hqswb_clas = HQ_GEN_FB; move16(); } test(); - IF( sub( length, L_FRAME32k) >= 0 && L_sub( st_fx->core_brate_fx, HQ_32k) <= 0 ) + IF( GE_16( length, L_FRAME32k)&&LE_32(st_fx->core_brate_fx,HQ_32k)) { bits = 2; move16(); @@ -99,9 +97,9 @@ Word16 hq_classifier_enc_fx( /* o : Consumed bits Q0 } test(); - IF ( sub( length, L_FRAME48k) == 0 && L_sub( st_fx->core_brate_fx, HQ_32k) <= 0 ) + IF ( EQ_16( length, L_FRAME48k)&&LE_32(st_fx->core_brate_fx,HQ_32k)) { - IF ( sub( *hqswb_clas, HQ_GEN_SWB) >= 0) + IF ( GE_16( *hqswb_clas, HQ_GEN_SWB)) { push_indice_fx( st_fx, IND_HQ_SWB_CLAS, *hqswb_clas - 5, bits ); } @@ -117,7 +115,7 @@ Word16 hq_classifier_enc_fx( /* o : Consumed bits Q0 test(); test(); - IF ( sub( *hqswb_clas, HQ_NORMAL) == 0 && sub( length, L_FRAME32k) == 0 && L_sub( st_fx->core_brate_fx, HQ_32k ) <= 0 ) + IF ( EQ_16( *hqswb_clas, HQ_NORMAL)&&EQ_16(length,L_FRAME32k)&&LE_32(st_fx->core_brate_fx,HQ_32k)) { *hqswb_clas = HQ_GEN_SWB; move16(); @@ -170,16 +168,16 @@ Word16 peak_avrg_ratio_fx( { input_abs_fx[q] =L_shr(input_abs_fx[q],5); /*Q_coeff-5 */ mean_fx =L_add(mean_fx,input_abs_fx[q]); /*Q_coeff-5 */ - IF (L_sub(input_abs_fx[q] , peak_fx)>0) + IF (GT_32(input_abs_fx[q] , peak_fx)) { peak_fx =input_abs_fx[q] ; /*Q_coeff-5 */ } q ++; } - IF(sub(i,8) < 0) + IF(LT_16(i,8)) { - if(L_sub(peak_fx, Mult_32_16(mean_fx, 4608))>0) /* Q15 0.140625 */ + if(GT_32(peak_fx, Mult_32_16(mean_fx, 4608))) /* Q15 0.140625 */ { k = add(k,1); } @@ -187,8 +185,8 @@ Word16 peak_avrg_ratio_fx( ELSE { test(); - if(L_sub(peak_fx, Mult_32_16(mean_fx, 3686))>0 /*Q15 0.1125 */ - && L_sub(peak_fx, peak_th_fx) >0) /*Q27 10 */ + if(GT_32(peak_fx, Mult_32_16(mean_fx, 3686)) /*Q15 0.1125 */ + && GT_32(peak_fx, peak_th_fx)) /*Q27 10 */ { k1 = add(k1,1); } @@ -196,9 +194,9 @@ Word16 peak_avrg_ratio_fx( } test(); - IF( sub(add(k,k1),10) >= 0 && sub(k1,5) > 0 ) + IF( GE_16(add(k,k1),10)&>_16(k1,5)) { - if( sub(*mode_count,8) < 0 ) + if( LT_16(*mode_count,8)) { *mode_count = add(*mode_count,1); } @@ -210,7 +208,7 @@ Word16 peak_avrg_ratio_fx( } ELSE { - if( sub(*mode_count1,8) < 0 ) + if( LT_16(*mode_count1,8)) { *mode_count1 = add(*mode_count1,1); } @@ -227,8 +225,8 @@ Word16 peak_avrg_ratio_fx( test(); test(); test(); - if ((sub(add(k, k1), 5) >= 0 && sub(k1, 2) > 0 && L_sub(total_brate, HQ_24k40) == 0) - || (((sub(add(k, k1), 10) >= 0 && sub(k1, 5) > 0) || sub(*mode_count, 5) >= 0) && sub(*mode_count1, 5) < 0)) + if ((GE_16(add(k, k1), 5)&>_16(k1,2)&&EQ_32(total_brate,HQ_24k40)) + || (((GE_16(add(k, k1), 10) && GT_16(k1, 5) ) || GE_16(*mode_count, 5) ) && LT_16(*mode_count1, 5) )) { hqswb_clas = HQ_HARMONIC; move16(); @@ -289,7 +287,7 @@ void hvq_classifier_fx( L_input_max = L_deposit_l(0); set32_fx(L_thr, 0, L_FRAME16k); - IF ( L_sub(L_core_brate, HQ_24k40) == 0 ) + IF ( EQ_32(L_core_brate, HQ_24k40)) { nsub = HVQ_NSUB_24k; move16(); @@ -312,7 +310,7 @@ void hvq_classifier_fx( test(); test(); - IF ( sub(*hqswb_clas, HQ_HARMONIC) == 0 && last_core != ACELP_CORE && sub(last_core, AMR_WB_CORE) != 0 ) + IF ( EQ_16(*hqswb_clas, HQ_HARMONIC)&&last_core!=ACELP_CORE&&NE_16(last_core,AMR_WB_CORE)) { FOR ( i = 0; i < N; i++ ) { @@ -350,7 +348,7 @@ void hvq_classifier_fx( FOR ( j = 0; j < HVQ_BW; j++ ) { L_d = L_input_abs[q]; - IF ( L_sub(L_d, L_nf) > 0 ) + IF ( GT_32(L_d, L_nf)) { /*nf = HVQ_NF_WEIGHT1 * nf + (1 - HVQ_NF_WEIGHT1) * d; */ Mpy_32_16_ss(L_d, HVQ_NF_WEIGHT1B, &L_tmp, &lsb); /* 12+15-15=12 */ @@ -365,7 +363,7 @@ void hvq_classifier_fx( L_nf = L_add(L_nf, L_tmp); /*Q12 */ } - IF ( L_sub(L_d, L_pe) > 0 ) + IF ( GT_32(L_d, L_pe)) { /*pe = HVQ_PE_WEIGHT1 * pe + (1 - HVQ_PE_WEIGHT1) * d; */ Mpy_32_16_ss(L_d, HVQ_PE_WEIGHT1B, &L_tmp, &lsb); /* 12+15-15=12 */ @@ -383,7 +381,7 @@ void hvq_classifier_fx( L_nf_mean[i] = L_add(L_nf_mean[i], L_nf); L_pe_mean[i] = L_add(L_pe_mean[i], L_pe); - IF ( L_sub(L_d, L_peak) > 0 ) + IF ( GT_32(L_d, L_peak)) { L_peak = L_add(L_d, 0); } @@ -431,7 +429,7 @@ void hvq_classifier_fx( /*sharp_dist += (sharp[i]-HVQ_SHARP_THRES); */ sharp_dist = add(sharp_dist, sub(sharp[i], HVQ_SHARP_THRES_FX)); - if ( sub(sharp[i], HVQ_SHARP_THRES_FX) > 0 ) + if ( GT_16(sharp[i], HVQ_SHARP_THRES_FX)) { num_sharp_bands = add(num_sharp_bands, 1); } @@ -460,14 +458,14 @@ void hvq_classifier_fx( move16(); idx = mult(add(shl(i, 1), 1), add(inv_nsub, 1)); /*0+15-15 = 0 */ Mpy_32_16_ss(L_nf_gains[idx], HVQ_PA_FAC_FX, &L_tmp, &lsb); /* 12+15-15 -> Q12 */ - IF( L_sub(L_nf_mean[i], L_tmp) < 0 ) + IF( LT_32(L_nf_mean[i], L_tmp)) { - IF ( sub(sharp[i], HVQ_PA_SHARP_THRES3_FX) < 0 ) + IF ( LT_16(sharp[i], HVQ_PA_SHARP_THRES3_FX)) { avail_peaks[i] = HVQ_PA_PEAKS_SHARP3; move16(); } - ELSE IF( sub(sharp[i], HVQ_PA_SHARP_THRES2_FX) < 0 ) + ELSE IF( LT_16(sharp[i], HVQ_PA_SHARP_THRES2_FX)) { avail_peaks[i] = HVQ_PA_PEAKS_SHARP2; move16(); @@ -501,7 +499,7 @@ void hvq_classifier_fx( L_input_abs[N-1] = L_deposit_l(0); FOR ( i = 0; i < N-2; i++ ) { - IF ( L_sub(L_input_abs[i], L_thr[i]) < 0 ) + IF ( LT_32(L_input_abs[i], L_thr[i])) { L_input_abs[i] = L_deposit_l(0); } @@ -515,7 +513,7 @@ void hvq_classifier_fx( } } - IF ( L_sub(L_core_brate, HQ_24k40) == 0 ) + IF ( EQ_32(L_core_brate, HQ_24k40)) { peak_th = HVQ_MAX_PEAKS_24k_CLAS; move16(); @@ -531,7 +529,7 @@ void hvq_classifier_fx( i = 0; move16(); - WHILE ( L_m > 0 && sub(i, peak_th+1) < 0) + WHILE ( L_m > 0 && LT_16(i, peak_th+1)) { idx = mult(peak_cand_idx[pindx], INV_HVQ_BW); /* 0+15-15=0 */ IF ( avail_peaks[idx] > 0 ) @@ -550,7 +548,7 @@ void hvq_classifier_fx( } tmp = sub(num_peak_cands, 1); - if ( sub(k, tmp) > 0 ) + if ( GT_16(k, tmp)) { k = tmp; move16(); @@ -566,7 +564,7 @@ void hvq_classifier_fx( } tmp = sub(N, 1); - if ( sub(high, tmp) > 0 ) + if ( GT_16(high, tmp)) { high = tmp; move16(); @@ -574,7 +572,7 @@ void hvq_classifier_fx( FOR( q = j; q <= pindx; q++ ) { - IF( sub(peak_cand_idx[q], low) >= 0 ) + IF( GE_16(peak_cand_idx[q], low)) { peak_cand_idx[q] = 0; move16(); @@ -585,7 +583,7 @@ void hvq_classifier_fx( FOR( q = pindx + 1; q <= k; q++ ) { - IF ( sub(peak_cand_idx[q], high) <= 0 ) + IF ( LE_16(peak_cand_idx[q], high)) { peak_cand_idx[q] = 0; move16(); @@ -599,14 +597,14 @@ void hvq_classifier_fx( *Npeaks = i; move16(); - IF ( sub(*Npeaks, HVQ_MIN_PEAKS) > 0 ) + IF ( GT_16(*Npeaks, HVQ_MIN_PEAKS)) { test(); - IF ( sub(num_sharp_bands, sub(nsub, 3)) > 0 && sub(*Npeaks, peak_th) <= 0 ) + IF ( GT_16(num_sharp_bands, sub(nsub, 3))&&LE_16(*Npeaks,peak_th)) { sharp_dist = mult(sharp_dist, inv_nsub); /*x+15-15=x */ test(); - IF ( sub(sharp_dist, SHARP_DIST_THRES_FX) <= 0 && *hvq_hangover < 0 ) + IF ( LE_16(sharp_dist, SHARP_DIST_THRES_FX)&&*hvq_hangover<0) { *hvq_hangover = add(*hvq_hangover, 1); } @@ -647,7 +645,7 @@ void hvq_classifier_fx( } - IF ( L_sub(L_core_brate, HQ_24k40) == 0 ) + IF ( EQ_32(L_core_brate, HQ_24k40)) { *Npeaks = s_min( HVQ_MAX_PEAKS_24k, *Npeaks ); move16(); diff --git a/lib_enc/hq_core_enc_fx.c b/lib_enc/hq_core_enc_fx.c index a1a205c313ebf5f4b756e0c33753c8d208ff04c7..9fe59761ecdc3966dbac5e1473eef2a3e403fa6d 100644 --- a/lib_enc/hq_core_enc_fx.c +++ b/lib_enc/hq_core_enc_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -7,8 +7,6 @@ #include "cnst_fx.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*-------------------------------------------------------------------------- * hq_core_enc() @@ -80,13 +78,13 @@ void hq_core_enc_fx( st_fx->tcx_cfg.tcx_last_overlap_mode, st_fx->tcx_cfg.tcx_curr_overlap_mode, input_frame ); test(); - IF ( st_fx->last_core_fx == ACELP_CORE || sub(st_fx->last_core_fx, AMR_WB_CORE) == 0 ) + IF ( st_fx->last_core_fx == ACELP_CORE || EQ_16(st_fx->last_core_fx, AMR_WB_CORE)) { /* Preprocessing in the first HQ frame after ACELP frame */ core_switching_hq_prepare_enc_fx( st_fx, &num_bits, input_frame, wtda_audio, two_frames_buffer+input_frame ); /* During ACELP->HQ core switching, limit the HQ core bitrate to 48kbps */ - IF ( sub(num_bits, ACELP_48k_BITS) > 0 ) + IF ( GT_16(num_bits, ACELP_48k_BITS)) { extra_unused = sub(num_bits, ACELP_48k_BITS); num_bits = ACELP_48k_BITS; @@ -100,9 +98,9 @@ void hq_core_enc_fx( direct_transform_fx( wtda_audio, t_audio, is_transient, input_frame, &Q_audio ); /* scale coefficients to their nominal level (8kHz) */ - IF ( sub(input_frame, NORM_MDCT_FACTOR) != 0 ) + IF ( NE_16(input_frame, NORM_MDCT_FACTOR)) { - IF (sub(input_frame, L_FRAME32k) == 0) + IF (EQ_16(input_frame, L_FRAME32k)) { Q_audio = add(Q_audio, 1); /* Divide by 2 */ } @@ -123,9 +121,9 @@ void hq_core_enc_fx( inner_frame = inner_frame_tbl[st_fx->bwidth_fx]; move16(); - IF( sub(input_frame, inner_frame) > 0 ) + IF( GT_16(input_frame, inner_frame)) { - IF( sub(is_transient, 1) == 0 ) + IF( EQ_16(is_transient, 1)) { FOR ( i = 1; i < NUM_TIME_SWITCHING_BLOCKS; i++ ) { @@ -143,7 +141,7 @@ void hq_core_enc_fx( *--------------------------------------------------------------------------*/ test(); - IF ( sub(st_fx->last_core_fx, HQ_CORE) == 0 && L_sub(st_fx->core_brate_fx, MINIMUM_RATE_TO_ENCODE_VOICING_FLAG) > 0 ) + IF ( EQ_16(st_fx->last_core_fx, HQ_CORE)&>_32(st_fx->core_brate_fx,MINIMUM_RATE_TO_ENCODE_VOICING_FLAG)) { IF ( Voicing_flag > 0 ) { @@ -162,7 +160,7 @@ void hq_core_enc_fx( * Transform-domain encoding *--------------------------------------------------------------------------*/ - IF ( sub(hq_core_type, LOW_RATE_HQ_CORE) == 0 ) + IF ( EQ_16(hq_core_type, LOW_RATE_HQ_CORE)) { /* HQ low rate encoder */ FOR (i = 0; i < inner_frame; i++) diff --git a/lib_enc/hq_env_enc_fx.c b/lib_enc/hq_env_enc_fx.c index 06d1cb4a4169b0b3a198f388b610a5d54bba6967..c774c3a8bf3d15ffb36eac68316d8fd1b1a36119 100644 --- a/lib_enc/hq_env_enc_fx.c +++ b/lib_enc/hq_env_enc_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -7,8 +7,6 @@ #include "prot_fx.h" /* Function prototypes */ #include "rom_enc_fx.h" #include "stl.h" -#include "wmc_auto.h" - /*--------------------------------------------------------------------------------------* * encode_envelope_indices_fx() @@ -53,7 +51,7 @@ Word16 encode_envelope_indices_fx( /* o : Number of bits if flag_pack=0,0 if IF ( flag_pack == 0 ) { test(); - IF( is_transient && sub(flag_HQ2, LOW_RATE_HQ_CORE_TRAN) == 0) + IF( is_transient && EQ_16(flag_HQ2, LOW_RATE_HQ_CORE_TRAN)) { bits = 0; move16(); @@ -63,19 +61,19 @@ Word16 encode_envelope_indices_fx( /* o : Number of bits if flag_pack=0,0 if move16(); FOR( i = 0; i< num_sfm; i++ ) { - IF( sub(difidx[i], index_max) > 0 ) + IF( GT_16(difidx[i], index_max)) { index_max = difidx[i]; move16(); } - IF( sub(difidx[i], index_min) < 0 ) + IF( LT_16(difidx[i], index_min)) { index_min = difidx[i]; move16(); } } test(); - IF(sub(index_min, 10) > 0 && sub(index_max, 22) < 0) + IF(GT_16(index_min, 10)&<_16(index_max,22)) { FOR( i = 1; i < num_sfm; i++ ) { @@ -94,14 +92,14 @@ Word16 encode_envelope_indices_fx( /* o : Number of bits if flag_pack=0,0 if { j = difidx[i]; move16(); - IF( sub(prevj, HTH_NORM) > 0 ) + IF( GT_16(prevj, HTH_NORM)) { /* above */ hcode_l = add(hcode_l, huffsizn_n_fx[31-j]); } ELSE { - IF( sub(prevj, LTH_NORM) < 0 ) + IF( LT_16(prevj, LTH_NORM)) { /* less */ hcode_l = add(hcode_l, huffsizn_n_fx[j]); @@ -116,7 +114,7 @@ Word16 encode_envelope_indices_fx( /* o : Number of bits if flag_pack=0,0 if move16(); } test(); - IF( sub(hcode_l, bits) >= 0 && bits !=0) + IF( GE_16(hcode_l, bits)&&bits!=0) { /* LC mode 1 Transient Huffman Coding */ *LCmode = 1; @@ -135,14 +133,14 @@ Word16 encode_envelope_indices_fx( /* o : Number of bits if flag_pack=0,0 if { j = difidx[i]; move16(); - IF( sub(prevj, HTH_NORM) > 0 ) + IF( GT_16(prevj, HTH_NORM)) { /* above */ hcode_l = add(hcode_l, huffsizn_n_fx[sub(31,j)]); } ELSE { - IF( sub(prevj, LTH_NORM) < 0 ) + IF( LT_16(prevj, LTH_NORM)) { /* less */ hcode_l = add(hcode_l, huffsizn_n_fx[j]); @@ -177,7 +175,7 @@ Word16 encode_envelope_indices_fx( /* o : Number of bits if flag_pack=0,0 if * comparing bit expenses of coding mode 2 with that of the optimal coding mode *------------------------------------------------------------------------------*/ - if( sub(hcode_l, bits) > 0 ) + if( GT_16(hcode_l, bits)) { *LCmode = 2; move16(); @@ -202,11 +200,11 @@ Word16 encode_envelope_indices_fx( /* o : Number of bits if flag_pack=0,0 if move16(); FOR( i = 2; i < num_sfm; i++ ) { - IF( sub(difidx_org[i-1], 17) > 0 ) + IF( GT_16(difidx_org[i-1], 17)) { difidx[i] = add(difidx_org[i], s_min(sub(difidx_org[i-1],17),3)); move16(); - IF( sub(difidx[i], 31) > 0 ) + IF( GT_16(difidx[i], 31)) { difidx_flag = 1; move16(); @@ -214,7 +212,7 @@ Word16 encode_envelope_indices_fx( /* o : Number of bits if flag_pack=0,0 if } } - IF( sub(difidx_org[i-1], 13) < 0 ) + IF( LT_16(difidx_org[i-1], 13)) { difidx[i] = add(difidx_org[i], s_max(sub(difidx_org[i-1],13),-3)); move16(); @@ -239,7 +237,7 @@ Word16 encode_envelope_indices_fx( /* o : Number of bits if flag_pack=0,0 if index_rad = s_max(sub(15, index_min),sub(index_max, 15)); - IF( sub(index_rad, HUFF_THR) <= 0 ) + IF( LE_16(index_rad, HUFF_THR)) { FOR( i = 1; i < num_sfm; i++ ) { @@ -252,7 +250,7 @@ Word16 encode_envelope_indices_fx( /* o : Number of bits if flag_pack=0,0 if * comparing bit expenses of coding mode 1 with that of coding mode 0 *------------------------------------------------------------------*/ - if( sub(hcode_l, bits) > 0 ) + if( GT_16(hcode_l, bits)) { *LCmode = 1; move16(); @@ -269,7 +267,7 @@ Word16 encode_envelope_indices_fx( /* o : Number of bits if flag_pack=0,0 if * comparing bit expenses of coding mode 3 with that of the optimal coding mode *------------------------------------------------------------------------------*/ - if( sub(hcode_l, numnrmibits) >= 0 ) + if( GE_16(hcode_l, numnrmibits)) { *LCmode = 3; move16(); @@ -279,7 +277,7 @@ Word16 encode_envelope_indices_fx( /* o : Number of bits if flag_pack=0,0 if test(); test(); - IF( (sub(*LCmode, 1) != 0 && flag_HQ2 == NORMAL_HQ_CORE ) || sub(flag_HQ2, LOW_RATE_HQ_CORE) == 0 ) + IF( (NE_16(*LCmode, 1)&&flag_HQ2==NORMAL_HQ_CORE)||EQ_16(flag_HQ2,LOW_RATE_HQ_CORE)) { FOR(i = 2; i< num_sfm; i++) { @@ -292,7 +290,7 @@ Word16 encode_envelope_indices_fx( /* o : Number of bits if flag_pack=0,0 if ELSE { test(); - IF( sub(flag_HQ2, LOW_RATE_HQ_CORE_TRAN) == 0 || sub(flag_HQ2, LOW_RATE_HQ_CORE) == 0 ) + IF( EQ_16(flag_HQ2, LOW_RATE_HQ_CORE_TRAN)||EQ_16(flag_HQ2,LOW_RATE_HQ_CORE)) { push_indice_fx( st_fx, IND_HQ2_DENG_HMODE, *LCmode, BITS_DE_HMODE); push_indice_fx( st_fx, IND_HQ2_DIFF_ENERGY, difidx[0], BITS_DE_FCOMP); @@ -304,11 +302,11 @@ Word16 encode_envelope_indices_fx( /* o : Number of bits if flag_pack=0,0 if } test(); - IF(is_transient && sub(flag_HQ2, LOW_RATE_HQ_CORE_TRAN) == 0) + IF(is_transient && EQ_16(flag_HQ2, LOW_RATE_HQ_CORE_TRAN)) { hcode_l = 0; move16(); - IF ( sub(*LCmode, 1) == 0 ) + IF ( EQ_16(*LCmode, 1)) { /* LC mode 0 Transient Huffman Coding */ FOR( i = 1; i < num_sfm; i++ ) @@ -342,7 +340,7 @@ Word16 encode_envelope_indices_fx( /* o : Number of bits if flag_pack=0,0 if j = difidx[i]; move16(); - IF( sub(prevj, HTH_NORM) > 0 ) + IF( GT_16(prevj, HTH_NORM)) { /* above */ r = huffsizn_n_fx[sub(31,j)]; @@ -352,7 +350,7 @@ Word16 encode_envelope_indices_fx( /* o : Number of bits if flag_pack=0,0 if } ELSE { - IF( sub(prevj, LTH_NORM) < 0 ) + IF( LT_16(prevj, LTH_NORM)) { /* less */ r = huffsizn_n_fx[j]; @@ -388,7 +386,7 @@ Word16 encode_envelope_indices_fx( /* o : Number of bits if flag_pack=0,0 if j = difidx[i]; move16(); - IF( sub(prevj, HTH_NORM) > 0 ) + IF( GT_16(prevj, HTH_NORM)) { /* above */ r = huffsizn_n_fx[sub(31,j)]; @@ -398,7 +396,7 @@ Word16 encode_envelope_indices_fx( /* o : Number of bits if flag_pack=0,0 if } ELSE { - IF( sub(prevj, LTH_NORM) < 0 ) + IF( LT_16(prevj, LTH_NORM)) { /* less */ r = huffsizn_n_fx[j]; @@ -416,7 +414,7 @@ Word16 encode_envelope_indices_fx( /* o : Number of bits if flag_pack=0,0 if } } - IF( sub(flag_HQ2, LOW_RATE_HQ_CORE) == 0 ) + IF( EQ_16(flag_HQ2, LOW_RATE_HQ_CORE)) { push_indice_fx(st_fx, IND_HQ2_DIFF_ENERGY, m, r); } @@ -429,9 +427,9 @@ Word16 encode_envelope_indices_fx( /* o : Number of bits if flag_pack=0,0 if move16(); } } - ELSE IF( sub(*LCmode, 1) == 0 ) + ELSE IF( EQ_16(*LCmode, 1)) { - IF ( sub(flag_HQ2, 1) == 0 ) + IF ( EQ_16(flag_HQ2, 1)) { index_max = 0; move16(); @@ -445,11 +443,11 @@ Word16 encode_envelope_indices_fx( /* o : Number of bits if flag_pack=0,0 if FOR(i = 2; i< num_sfm; i++) { - IF(sub(difidx_org[i-1], 17) > 0) + IF(GT_16(difidx_org[i-1], 17)) { difidx[i] = add(difidx_org[i], s_min(sub(difidx_org[i-1],17),3)); move16(); - IF(sub(difidx[i], 31) > 0) + IF(GT_16(difidx[i], 31)) { difidx_flag = 1; move16(); @@ -457,7 +455,7 @@ Word16 encode_envelope_indices_fx( /* o : Number of bits if flag_pack=0,0 if } } - IF(sub(difidx_org[i-1], 13) < 0) + IF(LT_16(difidx_org[i-1], 13)) { difidx[i] = add(difidx_org[i], s_max(sub(difidx_org[i-1],13),-3)); move16(); @@ -480,7 +478,7 @@ Word16 encode_envelope_indices_fx( /* o : Number of bits if flag_pack=0,0 if index_rad = s_max(sub(15, index_min),sub(index_max, 15)); - IF(sub(index_rad, HUFF_THR) <= 0) + IF(LE_16(index_rad, HUFF_THR)) { FOR (i = 1; i < num_sfm; i++) { @@ -522,7 +520,7 @@ Word16 encode_envelope_indices_fx( /* o : Number of bits if flag_pack=0,0 if } } } - ELSE IF( sub(*LCmode, 2) == 0 ) + ELSE IF( EQ_16(*LCmode, 2)) { /* LC mode 1 -> LC mode 2 */ FOR( i = 1; i < num_sfm; i++ ) diff --git a/lib_enc/hq_hr_enc_fx.c b/lib_enc/hq_hr_enc_fx.c index b59277287d1377f272ddf9c28fd12bc4e4a80ec7..ab7cf6c1b0acfc34e4f9a9c966237b09846926e6 100644 --- a/lib_enc/hq_hr_enc_fx.c +++ b/lib_enc/hq_hr_enc_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -7,8 +7,6 @@ #include "prot_fx.h" /* Function prototypes */ #include "rom_com_fx.h" /* Static table prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*--------------------------------------------------------------------------* * hq_hr_enc_fx() @@ -100,7 +98,7 @@ void hq_hr_enc_fx( *------------------------------------------------------------------*/ /* Interleave MLT coefficients of 4 sub-vectors in case of transient */ - IF( sub( is_transient, 1 ) == 0 ) + IF( EQ_16( is_transient, 1 )) { interleave_spectrum_fx( t_audio, length ); } @@ -128,10 +126,10 @@ void hq_hr_enc_fx( *------------------------------------------------------------------*/ test(); - IF ( sub( hqswb_clas, HQ_GEN_SWB ) == 0 || sub( hqswb_clas, HQ_GEN_FB ) == 0 ) + IF ( EQ_16( hqswb_clas, HQ_GEN_SWB )||EQ_16(hqswb_clas,HQ_GEN_FB)) { hq_generic_encoding_fx(t_audio, hq_generic_fenv, hq_generic_offset, st_fx, &hq_generic_exc_clas); - IF (sub(hq_generic_exc_clas , HQ_GENERIC_SP_EXC) == 0) + IF (EQ_16(hq_generic_exc_clas , HQ_GENERIC_SP_EXC)) { *num_bits = add(*num_bits,1); /* conditional 1 bit saving for representing FD3 BWE excitation class */ } @@ -163,7 +161,7 @@ void hq_hr_enc_fx( /*------------------------------------------------------------------* * Quantize/code spectral fine structure using PVQ or HVQ *------------------------------------------------------------------*/ - IF( sub( hqswb_clas, HQ_HVQ) == 0 ) + IF( EQ_16( hqswb_clas, HQ_HVQ)) { sum = hvq_enc_fx( st_fx, st_fx->core_brate_fx, *num_bits, Npeaks, ynrm, R, peaks, nf_gains, noise_level, pe_gains, t_audio, t_audio_q ); @@ -177,7 +175,7 @@ void hq_hr_enc_fx( } test(); - IF ( sub(hqswb_clas, HQ_HVQ) == 0 || sub(hqswb_clas, HQ_HARMONIC) == 0 ) + IF ( EQ_16(hqswb_clas, HQ_HVQ)||EQ_16(hqswb_clas,HQ_HARMONIC)) { subband_search_offset = subband_search_offsets_13p2kbps_Har_fx; wBands[0] = SWB_SB_BW_LEN0_16KBPS_HAR; @@ -185,7 +183,7 @@ void hq_hr_enc_fx( wBands[1] = SWB_SB_BW_LEN1_16KBPS_HAR; move16(); - IF (sub(hqswb_clas, HQ_HARMONIC) == 0) + IF (EQ_16(hqswb_clas, HQ_HARMONIC)) { Q_shift = sub(SWB_BWE_LR_Qs, Q_audio); FOR (i = 0; i < 300; i++) @@ -202,7 +200,7 @@ void hq_hr_enc_fx( test(); test(); - IF ( sub(hqswb_clas, HQ_HARMONIC) != 0 || sub(hqswb_clas, HQ_HVQ) != 0 || flag_dis == 0) + IF ( NE_16(hqswb_clas, HQ_HARMONIC)||NE_16(hqswb_clas,HQ_HVQ)||flag_dis==0) { st_fx->prev_frm_hfe2_fx = 0; /*reset*/ move16(); st_fx->prev_stab_hfe2_fx = 0; /*reset*/ move16(); @@ -213,10 +211,10 @@ void hq_hr_enc_fx( test(); test(); test(); - IF ( sub(is_transient,1 ) != 0 && sub( hqswb_clas, HQ_HVQ )!= 0 && !(sub(length, L_FRAME16k) == 0 && L_sub( st_fx->core_brate_fx, HQ_32k) == 0) ) + IF ( NE_16(is_transient,1 )&&NE_16(hqswb_clas,HQ_HVQ)&&!(EQ_16(length,L_FRAME16k)&&EQ_32(st_fx->core_brate_fx,HQ_32k))) { test(); - IF (sub(hqswb_clas, HQ_GEN_SWB) == 0 || sub(hqswb_clas, HQ_GEN_FB) == 0) + IF (EQ_16(hqswb_clas, HQ_GEN_SWB)||EQ_16(hqswb_clas,HQ_GEN_FB)) { nf_idx = noise_adjust_fx( t_audio_norm, 12, R, sfm_start, sfm_end, s_max(core_sfm,sub(num_env_bands,1))); push_indice_fx( st_fx, IND_NF_IDX, nf_idx, 2 ); diff --git a/lib_enc/hq_lr_enc_fx.c b/lib_enc/hq_lr_enc_fx.c index 1c91b9e4865f321a53f745c8dd5497c83f8adfae..80ed53426c5e17b3c265fb055e1425c3cdcd7f25 100644 --- a/lib_enc/hq_lr_enc_fx.c +++ b/lib_enc/hq_lr_enc_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -9,8 +9,6 @@ #include "rom_com_fx.h" #include "rom_enc_fx.h" #include "stl.h" -#include "wmc_auto.h" - #include "basop_mpy.h" /*--------------------------------------------------------------------------* @@ -58,7 +56,7 @@ static void spt_shorten_domain_set_fx( move16(); FOR(k=sub(bands,SPT_SHORTEN_SBNUM); k= 0 && sub(max_y2_pos, new_band_end[j]) <= 0 ) + IF( GE_16(max_y2_pos, new_band_start[j])&&LE_16(max_y2_pos,new_band_end[j])) { band_start[k] = new_band_start[j]; move16(); @@ -193,9 +191,9 @@ void hq_lr_enc_fx( move16(); test(); test(); - IF( sub(st_fx->bwidth_fx, SWB) == 0 && (L_sub(L_bwe_br, HQ_16k40) == 0 || L_sub(L_bwe_br, HQ_13k20) == 0) ) + IF( EQ_16(st_fx->bwidth_fx, SWB)&&(EQ_32(L_bwe_br,HQ_16k40)||EQ_32(L_bwe_br,HQ_13k20))) { - IF ( sub(is_transient_fx, 1) == 0 ) + IF ( EQ_16(is_transient_fx, 1)) { hqswb_clas_fx = HQ_TRANSIENT; move16(); @@ -208,7 +206,7 @@ void hq_lr_enc_fx( /* write the classification information into the bitstream */ push_indice_fx( st_fx, IND_HQ2_SWB_CLAS, hqswb_clas_fx, 2 ); (*num_bits_fx) = sub(*num_bits_fx, 2); - if( sub(hqswb_clas_fx, HQ_NORMAL) == 0 ) + if( EQ_16(hqswb_clas_fx, HQ_NORMAL)) { flag_spt_fx = 1; move16(); @@ -235,11 +233,11 @@ void hq_lr_enc_fx( test(); test(); test(); - IF( sub(st_fx->bwidth_fx, SWB) == 0 && is_transient_fx == 0 && (L_sub(L_bwe_br, HQ_16k40) == 0 || L_sub(L_bwe_br, HQ_13k20) == 0) ) + IF( EQ_16(st_fx->bwidth_fx, SWB)&&is_transient_fx==0&&(EQ_32(L_bwe_br,HQ_16k40)||EQ_32(L_bwe_br,HQ_13k20))) { /* reserve bits for HQ_NORMAL2 and HQ_HARMONIC modes */ test(); - IF( sub(hqswb_clas_fx, HQ_NORMAL) == 0 || sub(hqswb_clas_fx, HQ_HARMONIC) == 0 ) + IF( EQ_16(hqswb_clas_fx, HQ_NORMAL)||EQ_16(hqswb_clas_fx,HQ_HARMONIC)) { (*num_bits_fx) = sub(*num_bits_fx, get_usebit_npswb_fx(hqswb_clas_fx)); } @@ -247,9 +245,9 @@ void hq_lr_enc_fx( test(); test(); - IF(( L_sub(L_bwe_br, HQ_16k40) == 0 || L_sub(L_bwe_br, HQ_13k20) == 0) && sub(st_fx->bwidth_fx, SWB) == 0 ) + IF(( EQ_32(L_bwe_br, HQ_16k40)||EQ_32(L_bwe_br,HQ_13k20))&&EQ_16(st_fx->bwidth_fx,SWB)) { - IF( sub(st_fx->prev_hqswb_clas_fx, HQ_NORMAL) != 0 ) + IF( NE_16(st_fx->prev_hqswb_clas_fx, HQ_NORMAL)) { j = 0; move16(); @@ -264,7 +262,7 @@ void hq_lr_enc_fx( /* Check if input frame is larger than coded bandwidth */ test(); - IF ( sub(inner_frame_fx, length_fx) > 0 && is_transient_fx ) + IF ( GT_16(inner_frame_fx, length_fx)&&is_transient_fx) { /* If so, collapse transient frame (4 short transforms) to remove uncoded coefficients */ @@ -300,9 +298,9 @@ void hq_lr_enc_fx( test(); test(); - IF( sub(st_fx->bwidth_fx, SWB) == 0 && (L_sub(L_bwe_br, HQ_16k40) == 0 || L_sub(L_bwe_br, HQ_13k20) == 0) ) + IF( EQ_16(st_fx->bwidth_fx, SWB)&&(EQ_32(L_bwe_br,HQ_16k40)||EQ_32(L_bwe_br,HQ_13k20))) { - IF( sub(hqswb_clas_fx, HQ_HARMONIC) == 0 ) + IF( EQ_16(hqswb_clas_fx, HQ_HARMONIC)) { set16_fx( p2a_flags_fx, 1, har_bands_fx ); } @@ -312,7 +310,7 @@ void hq_lr_enc_fx( pbits_fx = p2a_threshold_quant_fx( st_fx, L_t_audio, band_start, band_end, band_width, bands_fx, p2a_bands_fx, p2a_th_fx, p2a_flags_fx ); bit_budget_fx = sub(bit_budget_fx, pbits_fx); - IF( sub(hqswb_clas_fx, HQ_NORMAL) == 0 ) + IF( EQ_16(hqswb_clas_fx, HQ_NORMAL)) { return_bits_normal2_fx( &bit_budget_fx, p2a_flags_fx, bands_fx, bits_lagIndices_modeNormal_fx ); } @@ -325,7 +323,7 @@ void hq_lr_enc_fx( bit_budget_fx = sub(bit_budget_fx, pbits_fx); } - IF(sub(flag_spt_fx, 1) == 0) + IF(EQ_16(flag_spt_fx, 1)) { spt_shorten_domain_band_save_fx(bands_fx, band_start, band_end, band_width, org_band_start, org_band_end, org_band_width); spt_shorten_domain_pre_fx(band_start, band_end, st_fx->prev_SWB_peak_pos_fx, bands_fx, L_bwe_br, new_band_start, new_band_end, new_band_width); @@ -379,7 +377,7 @@ void hq_lr_enc_fx( test(); test(); test(); - IF ( is_transient_fx == 0 && sub(inner_frame_fx, L_FRAME8k) == 0 && L_sub(st_fx->core_brate_fx, ACELP_13k20) <= 0 ) + IF ( is_transient_fx == 0 && EQ_16(inner_frame_fx, L_FRAME8k)&&LE_32(st_fx->core_brate_fx,ACELP_13k20)) { lowband = 6; move16(); @@ -392,7 +390,7 @@ void hq_lr_enc_fx( set16_fx( &p2a_flags_tmp[sub(bands_fx,trans_bit)], 0, 2 ); - IF( L_sub(st_fx->core_brate_fx, ACELP_13k20) == 0 ) + IF( EQ_32(st_fx->core_brate_fx, ACELP_13k20)) { beta_fx = 13107; move16();/*14 1.25f; */ @@ -407,7 +405,7 @@ void hq_lr_enc_fx( Ep_peak_fx = L_deposit_l(0); FOR( i = 0; i < bands_fx; i++ ) { - IF( sub(i,lowband) >= 0) + IF( GE_16(i,lowband)) { Ep_vari_fx = L_add(Ep_vari_fx,L_abs(L_sub(Ep_tmp_fx[i],Ep_tmp_fx[sub(i,1)])));/*Q15 */ Ep_avrg_fx = L_add(Ep_avrg_fx,Ep_tmp_fx[i]);/*Q15 */ @@ -416,7 +414,7 @@ void hq_lr_enc_fx( ELSE { Ep_avrgL_fx = L_add(Ep_avrgL_fx,Ep_tmp_fx[i]);/*Q15 */ - IF(L_sub(Ep_tmp_fx[i],Ep_peak_fx) > 0) + IF(GT_32(Ep_tmp_fx[i],Ep_peak_fx)) { Ep_peak_fx = L_add(Ep_tmp_fx[i], 0); /*Q15 */ } @@ -432,13 +430,13 @@ void hq_lr_enc_fx( test(); test(); test(); - IF(( (L_sub(L_tmp, L_shr(Ep_avrgL_fx,1)) < 0 && L_sub(st_fx->core_brate_fx, ACELP_13k20) == 0 ) || L_sub(st_fx->core_brate_fx, ACELP_13k20) < 0 )&& - L_sub(L_tmp2, L_tmp3) < 0 && L_sub(L_tmp2, L_shr(Ep_avrg_fx,7)) > 0) + IF(( (LT_32(L_tmp, L_shr(Ep_avrgL_fx,1))&&EQ_32(st_fx->core_brate_fx,ACELP_13k20))||LT_32(st_fx->core_brate_fx,ACELP_13k20))&& + LT_32(L_tmp2, L_tmp3) && GT_32(L_tmp2, L_shr(Ep_avrg_fx,7)) ) { FOR(i = lowband; i < bands_fx; i++) { L_tmp = Mult_32_16(Ep_avrg_fx,24576);/*Q(13+14-15 = 12) 1.5 */ - IF(L_sub(L_shr(Ep_tmp_fx[i],1), L_tmp) < 0) + IF(LT_32(L_shr(Ep_tmp_fx[i],1), L_tmp)) { L_tmp = Mult_32_16(Ep_peak_fx,sub(bands_fx,lowband));/*Q(13+0-15 = -2) */ tmp = extract_h(L_shl(L_tmp,14));/*Q-4 */ @@ -471,7 +469,7 @@ void hq_lr_enc_fx( { alpha_fx = 16384; move16();/*Q14 */ - IF( sub(p2a_flags_tmp[i],1) == 0) + IF( EQ_16(p2a_flags_tmp[i],1)) { L_tmp = Mult_32_16(Ep_tmp_fx[i],sub(bands_fx,lowband));/*Q(13+0-15 = -2) */ tmp = extract_h(L_shl(L_tmp,14));/*Q-4 */ @@ -515,7 +513,7 @@ void hq_lr_enc_fx( alpha_fx =add(16384,tmp); } - IF(sub(st_fx->last_bitalloc_max_band_fx[j++], 1) == 0) + IF(EQ_16(st_fx->last_bitalloc_max_band_fx[j++], 1)) { L_tmp = Mult_32_16(Ep_tmp_fx[i],sub(bands_fx,lowband));/*Q(13+0-15 = -2) */ tmp = extract_h(L_shl(L_tmp,14));/*Q-2 */ @@ -572,14 +570,14 @@ void hq_lr_enc_fx( Ep_peak_fx = L_deposit_l(0); FOR(i = 0; i < bands_fx; i++) { - IF(sub(i,lowband) >=0 ) + IF(GE_16(i,lowband)) { Ep_avrg_fx = L_add(Ep_avrg_fx,Ep_tmp_fx[i]);/*Q15 */ } ELSE { Ep_avrgL_fx = L_add(Ep_avrgL_fx,L_shr(Ep_tmp_fx[i],1));/*Q12 */ - IF(L_sub(Ep_tmp_fx[i],Ep_peak_fx) > 0) + IF(GT_32(Ep_tmp_fx[i],Ep_peak_fx)) { Ep_peak_fx = L_add(Ep_tmp_fx[i], 0); /*Q13 */ } @@ -589,7 +587,7 @@ void hq_lr_enc_fx( L_tmp2 =Mult_32_16(Ep_avrgL_fx,24576);/*Q(12+14-15 = 11) */ test(); test(); - IF( L_sub(L_shr(Ep_avrg_fx,2), L_tmp2) > 0 && L_sub(L_shr(Ep_avrg_fx,4), L_tmp2) < 0 && L_sub(L_tmp, Ep_avrgL_fx)>0) + IF( GT_32(L_shr(Ep_avrg_fx,2), L_tmp2)&<_32(L_shr(Ep_avrg_fx,4),L_tmp2)&>_32(L_tmp,Ep_avrgL_fx)) { adjustFlag = 1; move16(); @@ -629,14 +627,14 @@ void hq_lr_enc_fx( push_indice_fx ( st_fx, IND_HQ2_LAST_BA_MAX_BAND, st_fx->last_bitalloc_max_band_fx[i], 1 ); } } - ELSE IF( is_transient_fx == 0 && sub(inner_frame_fx, L_FRAME16k) == 0 ) + ELSE IF( is_transient_fx == 0 && EQ_16(inner_frame_fx, L_FRAME16k)) { bit_budget_fx = sub(bit_budget_fx,2);/* bits in high bands to indicate the last 2 subbands is allocated bits or not */ FOR( i = 0; i < bands_fx; i++ ) { Ep_tmp_fx[i] = L_shl(Ep_tmp_fx[i],2); } - IF( L_sub( st_fx->core_brate_fx, ACELP_13k20 ) == 0) + IF( EQ_32( st_fx->core_brate_fx, ACELP_13k20 )) { lowband = 8; move16(); @@ -662,17 +660,17 @@ void hq_lr_enc_fx( FOR( i = 0; i < bands_fx; i++ ) { test(); - IF( sub(i,lowband) >= 0 && add(sub(i,bands_fx),p2a_bands_fx) < 0) + IF( GE_16(i,lowband)&&add(sub(i,bands_fx),p2a_bands_fx)<0) { Ep_vari_fx = L_add(Ep_vari_fx,L_abs(L_sub(Ep_tmp_fx[i],Ep_tmp_fx[sub(i,1)])));/*Q15 */ Ep_avrg_fx = L_add(Ep_avrg_fx,Ep_tmp_fx[i]);/*Q15 */ } - IF(sub(i,highband) >= 0) + IF(GE_16(i,highband)) { enerH_fx = L_add(enerH_fx,L_shl(Ep_fx[i],2));/*Q0 */ } - ELSE IF(sub(i,lowband) >= 0) + ELSE IF(GE_16(i,lowband)) { enerL_fx = L_add(enerL_fx,L_shl(Ep_fx[i],2));/*Q0 */ } @@ -690,7 +688,7 @@ void hq_lr_enc_fx( FOR( i = sub(bands_fx,p2a_bands_fx); i < bands_fx; i++ ) { test(); - IF( sub(p2a_flags_fx[i],1) == 0 || L_tmp2 > 0 ) + IF( EQ_16(p2a_flags_fx[i],1)||L_tmp2>0) { tmp = sub(bands_fx,p2a_bands_fx); tmp = sub(tmp,lowband);/*Q0 */ @@ -730,7 +728,7 @@ void hq_lr_enc_fx( IF(add(sub(i,bands_fx),p2a_bands_fx) > 0) { tmp = sub(bands_fx,p2a_bands_fx); - IF(sub(st_fx->last_bitalloc_max_band_fx[sub(i, add(tmp, 1))], 1) == 0) + IF(EQ_16(st_fx->last_bitalloc_max_band_fx[sub(i, add(tmp, 1))], 1)) { tmp = sub(tmp,lowband); L_tmp = Mult_32_16(Ep_tmp_fx[i],tmp);/*Q(15+0-15 = 0) */ @@ -792,14 +790,14 @@ void hq_lr_enc_fx( Ep_peak_fx = L_deposit_l(0); FOR(i = 0; i < bands_fx; i++) { - IF(sub(i,lowband) >= 0) + IF(GE_16(i,lowband)) { Ep_avrg_fx = L_add(Ep_avrg_fx,Ep_tmp_fx[i]);/*Q15 */ } ELSE { Ep_avrgL_fx = L_add(Ep_avrgL_fx,Ep_tmp_fx[i]);/*Q15 */ - IF(L_sub(Ep_tmp_fx[i],Ep_peak_fx) > 0) + IF(GT_32(Ep_tmp_fx[i],Ep_peak_fx)) { Ep_peak_fx = L_add(Ep_tmp_fx[i], 0); /*Q15 */ } @@ -815,8 +813,8 @@ void hq_lr_enc_fx( test(); test(); test(); - IF( (L_sub(L_shr(Ep_avrgL_fx,1), Ep_avrg_fx)>0 && L_sub(L_tmp,L_shr(Ep_avrgL_fx,2)) > 0 && L_sub(L_shr(Ep_avrgL_fx,1),L_tmp2) < 0 ) || - (L_sub(L_shr(Ep_avrg_fx,1), Ep_avrgL_fx)>0 && L_sub(L_shr(Ep_avrg_fx,3),L_tmp3) < 0 && L_sub(L_tmp,L_shr(Ep_avrgL_fx,2)) > 0 ) ) + IF( (GT_32(L_shr(Ep_avrgL_fx,1), Ep_avrg_fx)&>_32(L_tmp,L_shr(Ep_avrgL_fx,2))&<_32(L_shr(Ep_avrgL_fx,1),L_tmp2))|| + (GT_32(L_shr(Ep_avrg_fx,1), Ep_avrgL_fx) && LT_32(L_shr(Ep_avrg_fx,3),L_tmp3) && GT_32(L_tmp,L_shr(Ep_avrgL_fx,2)) ) ) { adjustFlag = 1; move16(); @@ -855,7 +853,7 @@ void hq_lr_enc_fx( push_indice_fx( st_fx, IND_HQ2_LAST_BA_MAX_BAND, st_fx->last_bitalloc_max_band_fx[i], 1 ); } } - ELSE IF( sub(st_fx->bwidth_fx, SWB) == 0 && sub(hqswb_clas_fx, HQ_HARMONIC) == 0 && (L_sub(L_bwe_br, HQ_16k40) == 0 || L_sub(L_bwe_br, HQ_13k20) == 0) ) + ELSE IF( EQ_16(st_fx->bwidth_fx, SWB)&&EQ_16(hqswb_clas_fx,HQ_HARMONIC)&&(EQ_32(L_bwe_br,HQ_16k40)||EQ_32(L_bwe_br,HQ_13k20))) { /* bit allocation for harmonic mode */ hq2_bit_alloc_har_fx( L_band_energy, bit_budget_fx, bands_fx, L_Rk, p2a_bands_fx, L_bwe_br, p2a_flags_fx, band_width ); @@ -872,7 +870,7 @@ void hq_lr_enc_fx( tcq_core_LR_enc_fx( st_fx, inp_vector_fx, /*t_audio, */L_t_audio, /*y2, */L_y2, bit_budget_fx, bands_fx, band_start, band_end, band_width, /*Rk*/L_Rk, npulses_fx, k_sort_fx, p2a_flags_fx, p2a_bands_fx, st_fx->last_bitalloc_max_band_fx, inner_frame_fx, adjustFlag, is_transient_fx ); - IF((sub(inner_frame_fx, L_FRAME8k) == 0 && L_sub(st_fx->core_brate_fx, ACELP_13k20) <= 0) || sub(inner_frame_fx, L_FRAME16k) == 0) + IF((EQ_16(inner_frame_fx, L_FRAME8k)&&LE_32(st_fx->core_brate_fx,ACELP_13k20))||EQ_16(inner_frame_fx,L_FRAME16k)) { j = 0; FOR(i = 2; i > 0; i--) @@ -898,7 +896,7 @@ void hq_lr_enc_fx( /* Restore the band information */ - IF( sub(flag_spt_fx, 1) == 0 ) + IF( EQ_16(flag_spt_fx, 1)) { spt_shorten_domain_band_restore_fx(bands_fx, band_start, band_end, band_width, org_band_start, org_band_end, org_band_width); } @@ -913,10 +911,10 @@ void hq_lr_enc_fx( test(); test(); - IF( sub(st_fx->bwidth_fx, SWB) == 0 && (L_sub(L_bwe_br, HQ_16k40) == 0 || L_sub(L_bwe_br, HQ_13k20) == 0) ) + IF( EQ_16(st_fx->bwidth_fx, SWB)&&(EQ_32(L_bwe_br,HQ_16k40)||EQ_32(L_bwe_br,HQ_13k20))) { test(); - IF( sub(hqswb_clas_fx, HQ_NORMAL) == 0 || sub(hqswb_clas_fx, HQ_HARMONIC) == 0) + IF( EQ_16(hqswb_clas_fx, HQ_NORMAL)||EQ_16(hqswb_clas_fx,HQ_HARMONIC)) { preset_hq2_swb_fx( hqswb_clas_fx, band_end, &har_bands_fx, p2a_bands_fx,length_fx, bands_fx, &lowlength_fx, &highlength_fx, L_m ); @@ -936,7 +934,7 @@ void hq_lr_enc_fx( post_hq2_swb_fx( L_m, lowlength_fx, highlength_fx, hqswb_clas_fx, har_bands_fx, bands_fx, p2a_flags_fx, band_start, band_end, L_y2, npulses_fx ); - IF( sub(hqswb_clas_fx, HQ_NORMAL) == 0 ) + IF( EQ_16(hqswb_clas_fx, HQ_NORMAL)) { spt_swb_peakpos_tmp_save_fx(L_y2, bands_fx, band_start, band_end, prev_SWB_peak_pos_tmp_fx); FOR( k=0; kbwidth_fx, is_transient_fx, hqswb_clas_fx, &st_fx->prev_hqswb_clas_fx, st_fx->prev_SWB_peak_pos_fx, prev_SWB_peak_pos_tmp_fx, &st_fx->prev_frm_hfe2_fx, &st_fx->prev_stab_hfe2_fx, 0 ); - IF( sub(st_fx->bwidth_fx, SWB) != 0 ) + IF( NE_16(st_fx->bwidth_fx, SWB)) { /* reset HQ classifier memories */ st_fx->mode_count_fx = 0; @@ -972,7 +970,7 @@ void hq_lr_enc_fx( test(); test(); test(); - IF( sub(hqswb_clas_fx, HQ_HARMONIC) != 0 && (L_sub(L_bwe_br, HQ_16k40) == 0 || L_sub(L_bwe_br, HQ_13k20) == 0 ) && sub(st_fx->bwidth_fx, SWB) == 0 ) + IF( NE_16(hqswb_clas_fx, HQ_HARMONIC)&&(EQ_32(L_bwe_br,HQ_16k40)||EQ_32(L_bwe_br,HQ_13k20))&&EQ_16(st_fx->bwidth_fx,SWB)) { st_fx->prev_frm_index_fx[0] = -1; move16(); @@ -1019,7 +1017,7 @@ static Word16 small_symbol_enc_tran_fx( /* o : bits FOR( i=0; i 0 || difidx[i] < 0 ) + IF ( GT_16(difidx[i],LRMDCT_BE_LIMIT)||difidx[i]<0) { /* Huffman cannot encode this vector */ return -1; @@ -1077,7 +1075,7 @@ static Word16 small_symbol_enc_fx( /* o : bits FOR( i=0; i= 0 || difidx[i] < 0 ) + IF ( GE_16(difidx[i], DE_LIMIT)||difidx[i]<0) { /* Huffman cannot encode this vector */ return -1; @@ -1159,16 +1157,16 @@ static Word16 large_symbol_enc_fx( /* o : bits test(); test(); - IF ( flag_pack == 0 || ( sub(flag_pack, 1) == 0 && *hLCmode0 == 0) ) + IF ( flag_pack == 0 || ( EQ_16(flag_pack, 1)&&*hLCmode0==0)) { test(); test(); - IF ( sub(qbidx[0], sub(ABS_ENG_OFFSET, 1)) > 0 || sub(qbidx[0],-ABS_ENG_OFFSET) < 0) + IF ( GT_16(qbidx[0], sub(ABS_ENG_OFFSET, 1))||LT_16(qbidx[0],-ABS_ENG_OFFSET)) { cnt_outlyer0 = 2; move16(); } - ELSE IF ( sub(qbidx[0],3) > 0 || sub(qbidx[0],-4) < 0 ) + ELSE IF ( GT_16(qbidx[0],3)||LT_16(qbidx[0],-4)) { cnt_outlyer0 = 1; move16(); @@ -1186,7 +1184,7 @@ static Word16 large_symbol_enc_fx( /* o : bits FOR( i=1; i 0 || sub(qbidx[i],-4) < 0 ) + IF ( GT_16(qbidx[i],3)||LT_16(qbidx[i],-4)) { cnt_outlyer = add(cnt_outlyer, 1); pos_outlyer = i; @@ -1194,7 +1192,7 @@ static Word16 large_symbol_enc_fx( /* o : bits } test(); - if ( sub(qbidx[i], sub(ABS_ENG_OFFSET,1)) > 0 || sub(qbidx[i], -ABS_ENG_OFFSET) < 0 ) + if ( GT_16(qbidx[i], sub(ABS_ENG_OFFSET,1))||LT_16(qbidx[i],-ABS_ENG_OFFSET)) { cnt_outlyer = add(cnt_outlyer, 1); } @@ -1202,10 +1200,10 @@ static Word16 large_symbol_enc_fx( /* o : bits test(); test(); - IF ( cnt_outlyer0 == 0 && sub(cnt_outlyer, 1) <= 0 ) + IF ( cnt_outlyer0 == 0 && LE_16(cnt_outlyer, 1)) { bitsmode0 = add(add(BITS_DE_8SMODE, BITS_DE_8SMODE_N0), BITS_DE_8SMODE_N1); - IF ( sub(cnt_outlyer, 1) == 0 ) + IF ( EQ_16(cnt_outlyer, 1)) { /* 01 */ bitsmode0 = add(bitsmode0, add(BITS_DE_8SPOS, BITS_ABS_ENG)); @@ -1225,13 +1223,13 @@ static Word16 large_symbol_enc_fx( /* o : bits bitsmode0 = add(bitsmode0, hessize_fx[tdifidx0[i]+4]); } } - ELSE IF ( sub(cnt_outlyer0, 1) == 0 && sub(cnt_outlyer, 1) <= 0 ) + ELSE IF ( EQ_16(cnt_outlyer0, 1)&&LE_16(cnt_outlyer,1)) { bitsmode0 = add(add(BITS_DE_8SMODE, BITS_DE_8SMODE_N0), BITS_DE_8SMODE_N1); tdifidx0[0] = qbidx[0]; move16(); bitsmode0 = add(bitsmode0, BITS_ABS_ENG); - IF ( sub(cnt_outlyer, 1) == 0 ) + IF ( EQ_16(cnt_outlyer, 1)) { /* 11 */ bitsmode0 = add(bitsmode0, add(BITS_DE_8SPOS, BITS_ABS_ENG)); @@ -1282,7 +1280,7 @@ static Word16 large_symbol_enc_fx( /* o : bits { /*if (max_q <= ((2<<(i+1))-1) && min_q >= -(2<<(i+1))) */ test(); - IF ( sub(max_q, sub(shl(2, add(i,1)), 1)) <= 0 && sub(min_q, -shl(2,add(i,1))) >= 0 ) + IF ( LE_16(max_q, sub(shl(2, add(i,1)), 1))&& GE_16(min_q,-shl(2,add(i,1)))) { BREAK; } @@ -1308,7 +1306,7 @@ static Word16 large_symbol_enc_fx( /* o : bits bitsmode1 = add(bitsmode1, add(hessize_fx[add(shr(qbidx[i], offset0), 4)], offset0)); } - IF ( sub(min_bits, bitsmode1) > 0 ) + IF ( GT_16(min_bits, bitsmode1)) { min_bits_pos = offset0; move16(); @@ -1334,7 +1332,7 @@ static Word16 large_symbol_enc_fx( /* o : bits { /* estimating # of bits */ /* Encoding MSB bits */ - IF ( sub(bitsmode0, bitsmode1) < 0 ) + IF ( LT_16(bitsmode0, bitsmode1)) { bits = bitsmode0; move16(); @@ -1361,7 +1359,7 @@ static Word16 large_symbol_enc_fx( /* o : bits { push_indice_fx(st_fx, IND_HQ2_DENG_8SMODE_N0, 0, BITS_DE_8SMODE_N0); bits = add(bits, BITS_DE_8SMODE_N0); - IF ( sub(cnt_outlyer, 1) == 0 ) + IF ( EQ_16(cnt_outlyer, 1)) { /* 01 */ push_indice_fx(st_fx, IND_HQ2_DENG_8SMODE_N1, 1, BITS_DE_8SMODE_N1); @@ -1390,11 +1388,11 @@ static Word16 large_symbol_enc_fx( /* o : bits bitsmode0 = add(bitsmode0, hessize_fx[tdifidx0[i]+4]); } } - ELSE IF ( sub(cnt_outlyer0, 1) == 0 ) + ELSE IF ( EQ_16(cnt_outlyer0, 1)) { push_indice_fx(st_fx, IND_HQ2_DENG_8SMODE_N0, 1, BITS_DE_8SMODE_N0); bits = add(bits, BITS_DE_8SMODE_N0); - IF ( sub(cnt_outlyer, 1) == 0 ) + IF ( EQ_16(cnt_outlyer, 1)) { push_indice_fx(st_fx, IND_HQ2_DENG_8SMODE_N1, 1, BITS_DE_8SMODE_N1); bits = add(bits, BITS_DE_8SMODE_N1); @@ -1569,12 +1567,12 @@ static Word16 band_energy_quant_fx( /* Modifying qbidx to be located in the range -256~255 */ FOR( i=0; i 0 ) + if ( GT_16(bq2_fx[i],MAXIMUM_ENERGY_LOWBRATE)) { bq2_fx[i] = MAXIMUM_ENERGY_LOWBRATE; move16(); } - if ( sub(bq2_fx[i], MINIMUM_ENERGY_LOWBRATE) < 0 ) + if ( LT_16(bq2_fx[i], MINIMUM_ENERGY_LOWBRATE)) { bq2_fx[i] = MINIMUM_ENERGY_LOWBRATE; move16(); @@ -1597,7 +1595,7 @@ static Word16 band_energy_quant_fx( /* comparing used bits */ test(); - IF ( sub(ebits, hbits) < 0 || sub(hbits, -1) == 0 ) + IF ( LT_16(ebits, hbits)||EQ_16(hbits,-1)) { deng_cmode = 0; move16(); @@ -1708,7 +1706,7 @@ static Word16 p2a_threshold_quant_fx( temp_fx = round_fx(L_shl(L_t_audio[i], exp_norm)); /* Q12+exp_norm-16 -> exp_norm-4 */ L_e = L_mult(temp_fx, temp_fx); - if ( L_sub(L_e, L_p) > 0 ) + if ( GT_32(L_e, L_p)) { L_p = L_add(L_e, 0); } @@ -1750,7 +1748,7 @@ static Word16 p2a_threshold_quant_fx( p2a_fx = round_fx(L_shl(L_p2a, 13)); /* 27 -16 -> 11 */ } - if ( sub(p2a_fx, p2a_th_fx) <= 0 ) + if ( LE_16(p2a_fx, p2a_th_fx)) { p2a_flags_fx[k] = 0; move16(); @@ -1891,7 +1889,7 @@ static void mdct_spectrum_fine_gain_enc_fx( FOR (i = 0; i < gqlevs; i++) { d_fx = abs_s (sub(gamma_fx, gain_table_fx[i])); - IF ( sub(d_fx, dmin_fx) < 0 ) + IF ( LT_16(d_fx, dmin_fx)) { dmin_fx = d_fx; move16(); diff --git a/lib_enc/hvq_enc_fx.c b/lib_enc/hvq_enc_fx.c index ee8a5f9a8e78b5bd4a44efe610f221a397f89067..a5dd7456c4d8d2ad61fc8bbca3930f7b0a2527f9 100644 --- a/lib_enc/hvq_enc_fx.c +++ b/lib_enc/hvq_enc_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "prot_fx.h" #include "cnst_fx.h" #include "stl.h" -#include "wmc_auto.h" - #define HVQ_ENC_NOISE_DELTA ((Word16)3277) /* 0.1 in Q15 */ @@ -83,7 +81,7 @@ Word16 hvq_enc_fx( /*o : Consumed bits */ { d = L_abs(*pCoefs++); /* Q12 */ - IF( L_sub(d, pe) > 0L ) + IF( GT_32(d, pe)) { /* W*pe + (1 - W)*d = (pe - d)*W + d */ acc = L_sub(pe, d); @@ -97,7 +95,7 @@ Word16 hvq_enc_fx( /*o : Consumed bits */ Mpy_32_16_ss(acc, HVQ_BWE_WEIGHT1_FX, &acc, &dontCare); pe = L_add(acc, d); /* in Q12 and always positive */ - IF( L_sub(d, nf) > 0L ) + IF( GT_32(d, nf)) { acc = L_sub(nf, d); Mpy_32_16_ss(acc, HVQ_BWE_WEIGHT1_FX, &acc, &dontCare); @@ -200,21 +198,21 @@ static Word16 quant_lc(const Word16 x, Word16 *qx) { Word16 indx; - IF (sub(x, HVQ_ENC_NOISE_DELTA/2) < 0) + IF (LT_16(x, HVQ_ENC_NOISE_DELTA/2)) { indx = 0; move16(); *qx = 0; move16(); } - ELSE IF (sub(x, 3*HVQ_ENC_NOISE_DELTA/2) < 0) + ELSE IF (LT_16(x, 3*HVQ_ENC_NOISE_DELTA/2)) { indx = 1; move16(); *qx = HVQ_ENC_NOISE_DELTA; move16(); } - ELSE IF (sub(x, 5*HVQ_ENC_NOISE_DELTA/2) < 0) + ELSE IF (LT_16(x, 5*HVQ_ENC_NOISE_DELTA/2)) { indx = 2; move16(); diff --git a/lib_enc/igf_enc.c b/lib_enc/igf_enc.c index fb1a1403c5ad95e19184f054df079a1009716f8a..ff403c1d47e1a9bb1ed1db8d8c0946b50ee741f4 100644 --- a/lib_enc/igf_enc.c +++ b/lib_enc/igf_enc.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -7,8 +7,6 @@ #include #include "options.h" #include "stl.h" -#include "wmc_auto.h" - #include "prot_fx.h" #include "cnst_fx.h" #include "stat_enc_fx.h" @@ -406,7 +404,8 @@ static void IGF_ErodeSpectrum(Word16 *highPassEner_e move16(); *highPassEner_exp = 0; move16(); - highPassEner = L_add(0, 0); + highPassEner = 0; + move32(); IF (NULL == pPowerSpectrum) { @@ -419,7 +418,7 @@ static void IGF_ErodeSpectrum(Word16 *highPassEner_e IF (igfBgn > 0) { - L_c = L_add(0, 0); + L_c = 0; move32(); FOR (i = 0; i < igfBgn; i++) { Carry = 0; @@ -432,9 +431,9 @@ static void IGF_ErodeSpectrum(Word16 *highPassEner_e *highPassEner_exp = add(*highPassEner_exp, pPowerSpectrum_exp); test(); test(); - if ( sub(hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_SWB_9600) != 0 && - sub(hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_RF_SWB_13200) != 0 && - sub(hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_SWB_13200 ) != 0 ) + if ( NE_16(hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_SWB_9600)&& + NE_16(hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_RF_SWB_13200) && + NE_16(hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_SWB_13200 ) ) { igfBgn = shl(igfBgn, 1); } @@ -442,48 +441,54 @@ static void IGF_ErodeSpectrum(Word16 *highPassEner_e *highPassEner_exp = add(add(*highPassEner_exp,s),12 - 16 + (31 - 15)); /*Q15->Q31,highPassEner_exp*/ lastLine = pSpectrum[i - 1]; move32(); - nextLine = L_add(0, 0); + nextLine = 0; + move32(); /* May overflow - just for threshold comparison */ /* negate because the negated may be 1 larger in abs, */ /* so whenever compared to the negation of a maximum possible pPowerspectrum, it is still larger */ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF highPassEner_Ovfl = L_shl(L_negate(highPassEner), sub(*highPassEner_exp, pPowerSpectrum_exp)); L_tmp = L_add(pPowerSpectrum[i - 1], highPassEner_Ovfl); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON if (L_tmp >= 0) { - nextLine = L_add(pSpectrum[i], 0); + nextLine = pSpectrum[i]; + move32(); } tmploop = sub(igfEnd,1); FOR (/*i*/; i < tmploop; i++) { /* May overflow - just for threshold comparison */ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF L_tmp = L_add(pPowerSpectrum[i], highPassEner_Ovfl); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON IF (L_tmp < 0) { - lastLine = L_add(pSpectrum[i], 0); + lastLine = pSpectrum[i]; + move32(); pSpectrum[i] = nextLine; move32(); - nextLine = L_add(0, 0); + nextLine = 0; + move32(); } ELSE { pSpectrum[i-1] = lastLine; move32(); - lastLine = L_add(pSpectrum[i], 0); - nextLine = L_add(pSpectrum[i+1], 0); + lastLine = pSpectrum[i]; + move32(); + nextLine = pSpectrum[i+1]; + move32(); } } /* May overflow - just for threshold comparison */ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF L_tmp = L_add(pPowerSpectrum[i], highPassEner_Ovfl); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON IF (L_tmp < 0) { pSpectrum[i] = L_deposit_l(0); @@ -544,7 +549,7 @@ static Word16 IGF_getCrest( Word16 tmp; Word32 tmp32; - x_eff32 = L_add(0, 0); + x_eff32 = 0; move32(); x_max = 0; move16(); crest = 16384/*.5f Q15*/; @@ -588,10 +593,10 @@ static Word16 IGF_getCrest( *crest_exp = add(sub(s, i), 15); /* limit crest factor to a lower bound of 1, may overflow */ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF tmp = shl(-1, sub(15, *crest_exp)); /* build negative threshold */ tmp = add(crest, tmp); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON if (tmp < 0) { crest = 1; @@ -628,8 +633,8 @@ static Word16 IGF_getSFM( Word32 L_c; Word16 invDenom, SFM; - L_c = L_add(0, 0); - num = L_add(0, 0); + L_c = 0; move32(); + num = 0; move32(); denom = L_shr(2147483 /*0,001 in Q31 - float is "1", here*/,s_min(*energy_exp, 31)); denom = L_max(denom, 1); *SFM_exp = 0; @@ -803,22 +808,22 @@ static void IGF_Whitening(const IGF_ENC_INSTANCE_HANDLE hInstanc SFM32 = L_add(tmp32,hPrivateData->prevSFM_FIR[p]); SFM32 = L_mac0(SFM32,hPrivateData->prevSFM_IIR[p]/*Q13*/,4/*.5f Q3*/);/*15Q16*/ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF /*SFM = min(2.7f, SFM);*/ /*Overflow possible in shift, intended*/ SFM = s_min(22118/*2.7f Q13*/,extract_h(L_shr(SFM32,16-29)/*->Q29*/)/*->Q13*/ ); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON hPrivateData->prevSFM_FIR[p] = tmp32; /*15Q16*/ move32(); hPrivateData->prevSFM_IIR[p] = SFM; move16(); - IF (sub(SFM , hGrid->whiteningThreshold[1][p]) > 0) + IF (GT_16(SFM , hGrid->whiteningThreshold[1][p])) { hPrivateData->igfCurrWhiteningLevel[p] = IGF_WHITENING_STRONG; move16(); } - ELSE IF (sub(SFM , hGrid->whiteningThreshold[0][p]) > 0) + ELSE IF (GT_16(SFM , hGrid->whiteningThreshold[0][p])) { hPrivateData->igfCurrWhiteningLevel[p] = IGF_WHITENING_MID; move16(); @@ -876,14 +881,14 @@ static void IGF_WriteWhiteningTile( Word16 whiteningLevel /**< in: Q0 | whitening levels to write */ ) { - IF (L_sub(whiteningLevel, IGF_WHITENING_MID) == 0) + IF (EQ_32(whiteningLevel, IGF_WHITENING_MID)) { IGF_write_bits(st, pBitOffset, 0, 1); } ELSE { IGF_write_bits(st, pBitOffset, 1, 1); - IF (L_sub(whiteningLevel , IGF_WHITENING_OFF) == 0) + IF (EQ_32(whiteningLevel , IGF_WHITENING_OFF)) { IGF_write_bits(st, pBitOffset, 0, 1); } @@ -929,9 +934,10 @@ static void IGF_WriteWhiteningLevels( { p = 0; move16(); - tmp32 = L_add(0, 0); + tmp32 = 0; + move32(); - WHILE ((sub(p, nTiles) < 0) && (tmp32 == 0)) + WHILE ((LT_16(p, nTiles))&&(tmp32==0)) { test(); tmp32 = L_sub(hPrivateData->igfCurrWhiteningLevel[p] , hPrivateData->igfPrevWhiteningLevel[p]); @@ -956,14 +962,15 @@ static void IGF_WriteWhiteningLevels( IGF_WriteWhiteningTile(st, pBitOffset, hPrivateData->igfCurrWhiteningLevel[0]); p = 1; move16(); - tmp32 = L_add(0, 0); - if (sub(p, nTiles) < 0) + tmp32 = 0; + move32(); + if (LT_16(p, nTiles)) { isSame = 1; move16(); } - WHILE ((sub(p, nTiles) < 0) && (tmp32 == 0)) + WHILE ((LT_16(p, nTiles))&&(tmp32==0)) { test(); tmp32 = L_sub(hPrivateData->igfCurrWhiteningLevel[p] , hPrivateData->igfCurrWhiteningLevel[p - 1]); diff --git a/lib_enc/igf_scf_enc.c b/lib_enc/igf_scf_enc.c index 3c2d8e4e9860da5abf0ec7b096b0698cbed57129..250950d18cb1b20ac0e8e1256cb8974048943963 100644 --- a/lib_enc/igf_scf_enc.c +++ b/lib_enc/igf_scf_enc.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -7,8 +7,6 @@ #include #include "options.h" #include "stl.h" -#include "wmc_auto.h" - #include "prot_fx.h" #include "stat_enc_fx.h" #include "stat_com.h" @@ -131,7 +129,7 @@ static void arith_encode_residual( x = add(x, tableOffset); test(); - IF ((sub(x, IGF_MIN_ENC_SEPARATE) >= 0) && (sub(x, IGF_MAX_ENC_SEPARATE) <= 0)) + IF ((GE_16(x, IGF_MIN_ENC_SEPARATE))&&(LE_16(x,IGF_MAX_ENC_SEPARATE))) { x = sub(x, IGF_MIN_ENC_SEPARATE - 1); /* (x - IGF_MIN_ENC_SEPARATE) + 1 */ /* encode one of the IGF_SYMBOLS_IN_TABLE == 27 alphabet symbols using the new raw AC function */ @@ -145,7 +143,7 @@ static void arith_encode_residual( return; } - IF (sub(x, IGF_MIN_ENC_SEPARATE) < 0) + IF (LT_16(x, IGF_MIN_ENC_SEPARATE)) { /* send escape code 0 to indicate x <= IGF_MIN_ENC_SEPARATE - 1 */ extra = sub(IGF_MIN_ENC_SEPARATE - 1, x); @@ -239,7 +237,7 @@ static void encode_sfe_vector( ); arith_encode_bits(hPrivateData, ptr, s_and(x[f], 3), 2); /* LSBs as 2 bit raw */ } - ELSE IF (sub(f, 1) == 0) + ELSE IF (EQ_16(f, 1)) { /* (t == 0) && (f == 1) */ res = sub(x[f], x[0]); /* pred = b */ diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index 11bde25a21d50d04e99cbd243058869558580839..178c25f67451efe0df3c5c110ae859f84d5e5edd 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -7,8 +7,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*-----------------------------------------------------------------------* @@ -178,7 +176,7 @@ void init_encoder_fx( st_fx->past_qua_en_fx[i] = -14336; /* Q10gain quantization memory (used also in AMR-WB IO mode) */ } - IF( L_sub(st_fx->input_Fs_fx,8000) == 0 ) + IF( EQ_32(st_fx->input_Fs_fx,8000)) { st_fx->min_band_fx = 1; move16(); @@ -897,9 +895,9 @@ void init_encoder_fx( test(); test(); test(); - IF( st_fx->Opt_RF_ON == 0 || (sub(st_fx->bwidth_fx,WB) != 0 && sub(st_fx->bwidth_fx,SWB) != 0) || L_sub(st_fx->total_brate_fx,ACELP_13k20) != 0 ) + IF( st_fx->Opt_RF_ON == 0 || (NE_16(st_fx->bwidth_fx,WB)&&NE_16(st_fx->bwidth_fx,SWB))||NE_32(st_fx->total_brate_fx,ACELP_13k20)) { - IF (sub(st_fx->Opt_RF_ON,1)==0 ) + IF (EQ_16(st_fx->Opt_RF_ON,1)) { printf("\nWarning: Channel-aware mode only available for 13.2 kbps WB/SWB\n"); printf(" Switched to normal mode!\n"); @@ -928,7 +926,7 @@ void init_encoder_fx( st_fx->last_sr_core = i_mult2 (st_fx->last_L_frame_fx, 50); - IF( sub(st_fx->codec_mode, MODE2) == 0 ) + IF( EQ_16(st_fx->codec_mode, MODE2)) { st_fx->igf = getIgfPresent( st_fx->total_brate_fx, st_fx->bwidth_fx, st_fx->rf_mode); } @@ -944,7 +942,7 @@ void init_encoder_fx( L_tmp = st_fx->total_brate_fx; move32(); test(); - if( st_fx->rf_mode && L_sub(st_fx->total_brate_fx,ACELP_13k20) == 0 ) + if( st_fx->rf_mode && EQ_32(st_fx->total_brate_fx,ACELP_13k20)) { L_tmp = ACELP_9k60; move32(); diff --git a/lib_enc/inov_enc_fx.c b/lib_enc/inov_enc_fx.c index 3dcf45f87893bcee6f6cc99d57f813dee769694d..392b4fcf3c779f7fdd2e9d8e7dd31577541c1e02 100644 --- a/lib_enc/inov_enc_fx.c +++ b/lib_enc/inov_enc_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -8,8 +8,6 @@ #include "basop_util.h" #include "rom_com_fx.h" /* Static table prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*==============================================================================*/ @@ -91,7 +89,7 @@ Word16 inov_encode_fx( stack_pulses = 0; move16(); - IF( sub(L_frame,L_FRAME) == 0 ) + IF( EQ_16(L_frame,L_FRAME)) { g1 = FORMANT_SHARPENING_G1; move16(); @@ -113,7 +111,7 @@ Word16 inov_encode_fx( *----------------------------------------------------------------*/ test(); - IF (L_sub(core_brate, ACELP_13k20) > 0 && !Opt_AMR_WB) + IF (GT_32(core_brate, ACELP_13k20)&&!Opt_AMR_WB) { acelpautoc = 1; move16(); @@ -146,11 +144,11 @@ Word16 inov_encode_fx( cmpl_flag = 0; move16(); test(); - IF( sub(L_frame,L_FRAME) == 0 && sub(coder_type,TRANSITION) == 0 ) + IF( EQ_16(L_frame,L_FRAME)&&EQ_16(coder_type,TRANSITION)) { test(); test(); - if( L_sub(core_brate,ACELP_8k00) == 0 && i_subfr == 0 && sub(tc_subfr,L_SUBFR) < 0 ) + if( EQ_32(core_brate,ACELP_8k00)&&i_subfr==0&<_16(tc_subfr,L_SUBFR)) { cmpl_flag = 3; move16(); @@ -160,7 +158,7 @@ Word16 inov_encode_fx( test(); test(); test(); - if( L_sub(core_brate,ACELP_11k60) == 0 && ( (i_subfr == 0 && sub(tc_subfr,L_SUBFR) < 0) || sub(tc_subfr,TC_0_0) == 0 || (sub(i_subfr,3*L_SUBFR ) == 0&& sub(tc_subfr,TC_0_64) == 0)) ) + if( EQ_32(core_brate,ACELP_11k60)&&((i_subfr==0&<_16(tc_subfr,L_SUBFR))||EQ_16(tc_subfr,TC_0_0)||(EQ_16(i_subfr,3*L_SUBFR)&&EQ_16(tc_subfr,TC_0_64)))) { cmpl_flag = 3; move16(); @@ -169,24 +167,24 @@ Word16 inov_encode_fx( test(); test(); test(); - if( (L_sub(core_brate,ACELP_13k20) == 0 || L_sub(core_brate,ACELP_12k15) == 0 ) && ( (i_subfr == 0 && sub(tc_subfr,L_SUBFR) < 0) || sub(tc_subfr,TC_0_64) <= 0 ) ) + if( (EQ_32(core_brate,ACELP_13k20)||EQ_32(core_brate,ACELP_12k15))&&((i_subfr==0&<_16(tc_subfr,L_SUBFR))||LE_16(tc_subfr,TC_0_64))) { cmpl_flag = 3; move16(); } } - IF( sub(L_frame,L_FRAME16k) == 0) + IF( EQ_16(L_frame,L_FRAME16k)) { - IF( L_sub(core_brate,ACELP_32k) <= 0 ) + IF( LE_32(core_brate,ACELP_32k)) { cmpl_flag = 4; move16(); test(); - IF( sub(coder_type,TRANSITION) == 0 && sub(bwidth,WB) > 0 ) + IF( EQ_16(coder_type,TRANSITION)&>_16(bwidth,WB)) { - IF( sub(i_subfr,L_SUBFR) <= 0 ) + IF( LE_16(i_subfr,L_SUBFR)) { cmpl_flag = sub(cmpl_flag,1); } @@ -196,14 +194,14 @@ Word16 inov_encode_fx( } } } - ELSE IF( L_sub(core_brate,ACELP_48k) <= 0 ) + ELSE IF( LE_32(core_brate,ACELP_48k)) { cmpl_flag = 3; move16(); - IF( sub(coder_type,TRANSITION) == 0 ) + IF( EQ_16(coder_type,TRANSITION)) { - IF( sub(i_subfr,L_SUBFR) <= 0 ) + IF( LE_16(i_subfr,L_SUBFR)) { cmpl_flag = sub(cmpl_flag,1); } @@ -218,9 +216,9 @@ Word16 inov_encode_fx( cmpl_flag = 4; move16(); - IF( sub(coder_type,TRANSITION) == 0 ) + IF( EQ_16(coder_type,TRANSITION)) { - IF( sub(i_subfr,L_SUBFR) <= 0 ) + IF( LE_16(i_subfr,L_SUBFR)) { cmpl_flag = sub(cmpl_flag,1); } @@ -230,7 +228,7 @@ Word16 inov_encode_fx( } } - if( sub(coder_type,INACTIVE) == 0 ) + if( EQ_16(coder_type,INACTIVE)) { cmpl_flag = 4; move16(); @@ -241,9 +239,9 @@ Word16 inov_encode_fx( test(); test(); test(); - IF( sub(L_frame,last_L_frame) != 0 && L_sub(core_brate,ACELP_13k20) > 0 && (L_sub(core_brate,ACELP_32k) < 0 || sub(bwidth,WB) == 0) ) + IF( NE_16(L_frame,last_L_frame)&>_32(core_brate,ACELP_13k20)&&(LT_32(core_brate,ACELP_32k)||EQ_16(bwidth,WB))) { - if( sub(cmpl_flag,1) > 0 ) + if( GT_16(cmpl_flag,1)) { cmpl_flag = sub(cmpl_flag,1); } @@ -257,7 +255,7 @@ Word16 inov_encode_fx( IF ( !Opt_AMR_WB ) { - IF( sub(L_frame,L_FRAME) == 0 ) + IF( EQ_16(L_frame,L_FRAME)) { nBits = FCB_bits_tbl[BIT_ALLOC_IDX_fx(core_brate, coder_type, i_subfr, TC_SUBFR2IDX_fx(tc_subfr))]; move16(); @@ -268,11 +266,11 @@ Word16 inov_encode_fx( move16(); } - IF( sub(nBits,7) == 0 ) + IF( EQ_16(nBits,7)) { acelp_1t64_fx( st_fx, dn, h2, code, y2 ); } - ELSE IF( sub(nBits,12) == 0 ) + ELSE IF( EQ_16(nBits,12)) { acelp_2t32_fx(st_fx, dn, h2, code, y2 ); } @@ -284,39 +282,39 @@ Word16 inov_encode_fx( } ELSE { - IF (L_sub(core_brate,ACELP_6k60) == 0) + IF (EQ_32(core_brate,ACELP_6k60)) { acelp_2t32_fx( st_fx, dn, h2, code, y2 ); } - ELSE IF( (L_sub(core_brate,ACELP_8k85) == 0) ) + ELSE IF( (EQ_32(core_brate,ACELP_8k85))) { acelp_4t64_fx(st_fx, dn, cn, h2, Rw, acelpautoc, code, y2, 20, cmpl_flag, Opt_AMR_WB ); } - ELSE IF( L_sub(core_brate,ACELP_12k65) == 0) + ELSE IF( EQ_32(core_brate,ACELP_12k65)) { acelp_4t64_fx(st_fx, dn, cn, h2, Rw, acelpautoc, code, y2, 36, cmpl_flag, Opt_AMR_WB ); } - ELSE IF( L_sub(core_brate,ACELP_14k25) == 0) + ELSE IF( EQ_32(core_brate,ACELP_14k25)) { acelp_4t64_fx( st_fx, dn, cn, h2, Rw, acelpautoc, code, y2, 44, cmpl_flag, Opt_AMR_WB ); } - ELSE IF( L_sub(core_brate,ACELP_15k85) == 0) + ELSE IF( EQ_32(core_brate,ACELP_15k85)) { acelp_4t64_fx( st_fx, dn, cn, h2, Rw, acelpautoc, code, y2, 52, cmpl_flag, Opt_AMR_WB ); } - ELSE IF( L_sub(core_brate,ACELP_18k25) == 0) + ELSE IF( EQ_32(core_brate,ACELP_18k25)) { acelp_4t64_fx(st_fx, dn, cn, h2, Rw, acelpautoc, code, y2, 64, cmpl_flag, Opt_AMR_WB ); } - ELSE IF( L_sub(core_brate,ACELP_19k85) == 0) + ELSE IF( EQ_32(core_brate,ACELP_19k85)) { acelp_4t64_fx(st_fx, dn, cn, h2, Rw, acelpautoc, code, y2, 72, cmpl_flag, Opt_AMR_WB ); } - ELSE IF( L_sub(core_brate,ACELP_23k05) == 0 ) + ELSE IF( EQ_32(core_brate,ACELP_23k05)) { acelp_4t64_fx(st_fx, dn, cn, h2, Rw, acelpautoc, code, y2, 88, cmpl_flag, Opt_AMR_WB ); } - ELSE IF( L_sub(core_brate,ACELP_23k85) == 0) + ELSE IF( EQ_32(core_brate,ACELP_23k85)) { acelp_4t64_fx(st_fx, dn, cn, h2, Rw, acelpautoc, code, y2, 88, 1, Opt_AMR_WB); } diff --git a/lib_enc/io_enc_fx.c b/lib_enc/io_enc_fx.c index cec332af206cd69a485d75b4ada45149bbbe208d..6135bdf7a0e2e02ea4d3440796fb8b152b115ce0 100644 --- a/lib_enc/io_enc_fx.c +++ b/lib_enc/io_enc_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include #include #include #include "stl.h" -#include "wmc_auto.h" - #include "options.h" /* Compilation switches */ #include "cnst_fx.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ diff --git a/lib_enc/isf_enc_amr_wb_fx.c b/lib_enc/isf_enc_amr_wb_fx.c index e33c595137e321fc7f39d169e6fe5f2bdb6e8b98..cfafdfef27df33a06564aec06d6258079a17c7d9 100644 --- a/lib_enc/isf_enc_amr_wb_fx.c +++ b/lib_enc/isf_enc_amr_wb_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -7,9 +7,7 @@ #include "rom_enc_fx.h" /* Encoder static table prototypes */ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ -#include "stl.h" -#include "wmc_auto.h" - /* required by wmc_tool */ +#include "stl.h" /* required by wmc_tool */ /*-----------------------------------------------------------------* @@ -60,7 +58,7 @@ void isf_enc_amr_wb_fx( * ISF quantization of SID frames *---------------------------------*/ - IF ( L_sub(st->core_brate_fx,SID_1k75) == 0 ) + IF ( EQ_32(st->core_brate_fx,SID_1k75)) { qisf_ns_28b_fx( st, isf_new ); @@ -79,11 +77,11 @@ void isf_enc_amr_wb_fx( * ISF quantization of all other frames *---------------------------------------*/ - IF ( L_sub(st->core_brate_fx,ACELP_6k60) == 0 ) + IF ( EQ_32(st->core_brate_fx,ACELP_6k60)) { qisf_2s_36b_fx( st, isf_new, 4, st->mem_AR_fx, st->mem_MA_fx ); } - ELSE IF( L_sub(st->core_brate_fx,ACELP_8k85) >= 0 ) + ELSE IF( GE_32(st->core_brate_fx,ACELP_8k85)) { qisf_2s_46b_fx( st, isf_new, 4, st->mem_AR_fx, st->mem_MA_fx ); } @@ -221,7 +219,7 @@ static void qisf_2s_36b_fx( tmp_ind[1] = sub_VQ_fx(&isf2[5], dico22_isf_36b_fx, 4, SIZE_BK22_36b, &min_err); temp = L_add(temp, min_err); - IF (L_sub(temp,distance) < 0) + IF (LT_32(temp,distance)) { distance = L_add(temp, 0); indice[0] = surv1[k]; @@ -255,7 +253,7 @@ static void qisf_2s_36b_fx( tmp_ind[0] = sub_VQ_fx(&isf2[9], dico23_isf_36b_fx, 3, SIZE_BK23_36b, &min_err); move16(); temp = L_add(min_err, 0); - IF (L_sub(temp, distance) < 0) + IF (LT_32(temp, distance)) { distance = L_add(temp, 0); indice[1] = surv1[k]; @@ -349,7 +347,7 @@ static void qisf_2s_46b_fx( temp = L_add(temp, min_err); tmp_ind[2] = sub_VQ_fx(&isf2[6], dico23_isf_46b_fx, 3, SIZE_BK23, &min_err); temp = L_add(temp, min_err); - IF (L_sub(temp,distance) < 0) + IF (LT_32(temp,distance)) { distance = L_add(temp, 0); indice[0] = surv1[k]; @@ -387,7 +385,7 @@ static void qisf_2s_46b_fx( move16(); temp = L_add(temp, min_err); - IF (L_sub(temp, distance) < 0) + IF (LT_32(temp, distance)) { distance = L_add(temp, 0); indice[1] = surv1[k]; @@ -467,7 +465,7 @@ static void VQ_stage1_fx( FOR (k=0; kk; l--) { @@ -524,7 +522,7 @@ static Word16 sub_VQ_fx( /* o : selected codebook vector index */ dist = L_mac(dist, temp, temp); } - IF (L_sub(dist,dist_min) < 0) + IF (LT_32(dist,dist_min)) { dist_min = L_add(dist, 0); index = i; diff --git a/lib_enc/lead_indexing_fx.c b/lib_enc/lead_indexing_fx.c index 7e4d68070aa3f7ee5dc9a8dc39100ead5b571dae..8418ad6db1cd04330e3e1476df2a40025ffad845 100644 --- a/lib_enc/lead_indexing_fx.c +++ b/lib_enc/lead_indexing_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -7,9 +7,7 @@ #include "prot_fx.h" #include "rom_com_fx.h" -#include "stl.h" -#include "wmc_auto.h" - /* required for wmc_tool */ +#include "stl.h" /* required for wmc_tool */ /*-------------------------------------------------------------------* * Local function prototypes @@ -55,7 +53,7 @@ void re8_compute_base_index_fx( test(); test(); - IF (sub(a2[1], 2) == 0 && s_xor(a1[0], 1) && sub(ka, 5)) + IF (EQ_16(a2[1], 2)&&s_xor(a1[0],1)&&sub(ka,5)) { FOR (i=0; i<8; i++) { @@ -99,7 +97,7 @@ void re8_compute_base_index_fx( } } - IF (sub(k1, m) != 0) + IF (NE_16(k1, m)) { sign_8p = shr(sign_8p, 1); } @@ -110,7 +108,7 @@ void re8_compute_base_index_fx( code_area = 8; move16(); - IF (sub(a2[2], 1) != 0) + IF (NE_16(a2[2], 1)) { FOR (j=0; jini_frame_fx, 4 ) < 0 ) + IF( LT_16(st_fx->ini_frame_fx, 4 )) { @@ -48,7 +46,7 @@ void long_enr_fx( } */ alpha = 655; move16();/* 0.02 Q15 */ - if ( sub(st_fx->ini_frame_fx, 150) < 0 ) /* should match HE_LT_CNT_INIT_FX */ + if ( LT_16(st_fx->ini_frame_fx, 150)) /* should match HE_LT_CNT_INIT_FX */ { alpha = 1638 ; move16(); /* 0.05 Q15 */ @@ -59,7 +57,7 @@ void long_enr_fx( IF ( (localVAD_HE_SAD != 0) && ( high_lpn_flag == 0) ) { - IF( sub(sub(st_fx->lp_speech_fx, Etot ), 10*256 ) < 0 ) /* 10.0 in Q8 */ + IF( LT_16(sub(st_fx->lp_speech_fx, Etot ), 10*256 )) /* 10.0 in Q8 */ { /* st->lp_speech = 0.98f * st->lp_speech + 0.02f * Etot; */ st_fx->lp_speech_fx = noise_est_AR1_Qx(Etot, st_fx->lp_speech_fx, 655); /* Q8 state, 0.02 in Q15 */ diff --git a/lib_enc/lp_exc_e_fx.c b/lib_enc/lp_exc_e_fx.c index c0e58f615faa85f5fa4c8a867fe857b9893f6c80..5b9dcffd17d3164d45bb280e72b83883629d6604 100644 --- a/lib_enc/lp_exc_e_fx.c +++ b/lib_enc/lp_exc_e_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "cnst_fx.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - #include "basop_util.h" /*-------------------------------------------------------------------* @@ -71,18 +69,18 @@ Word16 lp_filt_exc_enc_fx( * Select LP filtering flag *-----------------------------------------------------------------*/ - IF ( sub(codec_mode,MODE1) == 0 ) + IF ( EQ_16(codec_mode,MODE1)) { test(); test(); test(); test(); - IF ( ( Opt_AMR_WB || sub(coder_type,GENERIC) == 0|| sub(coder_type,TRANSITION) == 0 ) && L_sub(core_brate,ACELP_11k60) < 0 ) + IF ( ( Opt_AMR_WB || EQ_16(coder_type,GENERIC)||EQ_16(coder_type,TRANSITION))&<_32(core_brate,ACELP_11k60)) { *lp_flag = LOW_PASS; move16(); } - ELSE IF ( L_sub(core_brate,ACELP_11k60) >= 0 && sub(coder_type,AUDIO) != 0 ) + ELSE IF ( GE_32(core_brate,ACELP_11k60)&&NE_16(coder_type,AUDIO)) { *lp_flag = NORMAL_OPERATION; move16(); @@ -99,7 +97,7 @@ Word16 lp_filt_exc_enc_fx( * Find the target energy if the adaptive exc. is not filtered *----------------------------------------------------------------*/ test(); - IF( sub(codec_mode,MODE2) == 0 && sub(coder_type,100) == 0) + IF( EQ_16(codec_mode,MODE2)&&EQ_16(coder_type,100)) { use_prev_sf_pit_gain = 1; } @@ -108,7 +106,7 @@ Word16 lp_filt_exc_enc_fx( wtmp = 0; move16(); test(); - IF( sub(*lp_flag,FULL_BAND) == 0 || sub(*lp_flag,NORMAL_OPERATION) == 0 ) + IF( EQ_16(*lp_flag,FULL_BAND)||EQ_16(*lp_flag,NORMAL_OPERATION)) { wtmp = adpt_enr_fx( codec_mode, &exc[i_subfr], h1, y1, L_subfr, &gain1, g_corr, clip_gain, xn, xn2, &exp_ener, use_prev_sf_pit_gain); move16(); @@ -125,10 +123,10 @@ Word16 lp_filt_exc_enc_fx( wtmp1 = 0; move16(); test(); - IF( (sub(*lp_flag,LOW_PASS) == 0) || (sub(*lp_flag,NORMAL_OPERATION) == 0) ) + IF( (EQ_16(*lp_flag,LOW_PASS))||(EQ_16(*lp_flag,NORMAL_OPERATION))) { test(); - IF( sub(codec_mode,MODE2) == 0 && sub(L_frame,L_FRAME16k) == 0 ) + IF( EQ_16(codec_mode,MODE2)&&EQ_16(L_frame,L_FRAME16k)) { FOR ( i=0; i 0 ) + if ( GT_16(exp_ener, exp_ener1)) { wtmp1 = shr(wtmp1, 1); } @@ -169,7 +167,7 @@ Word16 lp_filt_exc_enc_fx( test(); test(); - IF( ( (sub(wtmp1,wtmp) < 0) && (sub(*lp_flag,NORMAL_OPERATION) == 0) ) || (sub(*lp_flag,LOW_PASS) == 0) ) + IF( ( (LT_16(wtmp1,wtmp))&&(EQ_16(*lp_flag,NORMAL_OPERATION)))||(EQ_16(*lp_flag,LOW_PASS))) { /* use the LP filter for pitch excitation prediction */ select = LOW_PASS; @@ -243,7 +241,7 @@ static Word16 adpt_enr_fx( /* o : adaptive excitation energy mant move16(); test(); - IF( sub(L_subfr, L_SUBFR) > 0 && Overflow ) + IF( GT_16(L_subfr, L_SUBFR)&&Overflow) { FOR(i = 0; i< L_subfr; i++) { @@ -260,14 +258,14 @@ static Word16 adpt_enr_fx( /* o : adaptive excitation energy mant /* clip gain, if necessary to avoid problems at decoder */ test(); - if(sub(clip_gain,1) == 0 && sub(*gain,15565) > 0) /* constant in Q14 */ + if(EQ_16(clip_gain,1)&>_16(*gain,15565)) /* constant in Q14 */ { *gain = 15565; move16(); } test(); - if( sub(clip_gain,2) == 0 && sub(*gain,10650) > 0 ) + if( EQ_16(clip_gain,2)&>_16(*gain,10650)) { *gain = 10650; move16(); @@ -277,7 +275,7 @@ static Word16 adpt_enr_fx( /* o : adaptive excitation energy mant /* find energy of new target xn2[] */ updt_tar_fx( xn, xn2, y1, *gain, L_subfr ); - IF(sub(L_subfr, L_SUBFR) > 0) + IF(GT_16(L_subfr, L_SUBFR)) { /* could possibly happen in GSC */ Ltmp = Calc_Energy_Autoscaled(xn2, 0, L_subfr, exp_ener); @@ -378,7 +376,7 @@ Word16 corr_xy1_fx( /* o : pitch gain (0..GAIN_PIT_MAX) */ /* find pitch gain and bound it by [0,GAIN_PIT_MAX] */ test(); - IF ( xy >= 0 && sub(s_or(yy, xy), 16384) != 0 ) + IF ( xy >= 0 && NE_16(s_or(yy, xy), 16384)) { /* compute gain = xy/yy */ xy = shr(xy, 1); /* be sure that xy < yy */ @@ -408,9 +406,9 @@ Word16 corr_xy1_fx( /* o : pitch gain (0..GAIN_PIT_MAX) */ /* Note: shl works as shl or shr. */ exp_xx = sub(exp_xx,1); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF gain_p_snr = round_fx(L_shl(Mpy_32_16_1( 1717986944l/*ACELP_GAINS_CONST Q31*/, tmp), exp_xx)); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON gain = s_min(gain, gain_p_snr); } diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c index 6281f2d4358f7c51e74c86940b6f7c2dd361754a..2036f840f13cea7092977f2344d793b22c16d082 100644 --- a/lib_enc/lsf_enc_fx.c +++ b/lib_enc/lsf_enc_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -8,8 +8,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - #include "prot_fx.h" @@ -87,7 +85,7 @@ void lsf_enc_fx( /* initialize */ int_fs = INT_FS_16k_FX; move16(); - if( sub(L_frame, L_FRAME) == 0 ) + if( EQ_16(L_frame, L_FRAME)) { int_fs = INT_FS_FX; move16(); @@ -100,7 +98,7 @@ void lsf_enc_fx( gp_clip_test_lsf_fx( lsf_new, st_fx->clip_var_fx, 0 ); /* Find the number of bits for LSF quantization */ - IF ( L_sub(st_fx->core_brate_fx, SID_2k40) == 0 ) + IF ( EQ_32(st_fx->core_brate_fx, SID_2k40)) { nBits = LSF_BITS_CNG; move16(); @@ -113,18 +111,18 @@ void lsf_enc_fx( nBits = LSF_bits_tbl[LSF_BIT_ALLOC_IDX_fx(st_fx->core_brate_fx, coder_type)]; move16(); } - ELSE IF ( sub(st_fx->nelp_mode_fx, 1) == 0 ) + ELSE IF ( EQ_16(st_fx->nelp_mode_fx, 1)) { nBits = 30; move16(); - if ( sub(st_fx->bwidth_fx,NB) == 0 ) + if ( EQ_16(st_fx->bwidth_fx,NB)) { nBits = 32; move16(); } } - ELSE IF ( sub(st_fx->ppp_mode_fx, 1) == 0 ) + ELSE IF ( EQ_16(st_fx->ppp_mode_fx, 1)) { nBits = 26; move16(); @@ -132,14 +130,14 @@ void lsf_enc_fx( } /* first three ACELP frames after an HQ frame shall be processed only with safety-net quantizer */ - if( (sub(Nb_ACELP_frames, 3) < 0) ) + if( (LT_16(Nb_ACELP_frames, 3))) { force_sf = 1; move16(); } /* in case of unstable filter in decoder FEC, choose safety-net to help FEC */ - IF ( sub(st_fx->next_force_safety_net_fx ,1) == 0 ) + IF ( EQ_16(st_fx->next_force_safety_net_fx ,1)) { force_sf = 1; move16(); @@ -159,12 +157,12 @@ void lsf_enc_fx( lsf2lsp_fx( lsf_new, lsp_new, M, int_fs); test(); - IF ( sub(st_fx->last_core_fx, HQ_CORE) == 0 && sub(st_fx->core_fx,ACELP_CORE) == 0 ) + IF ( EQ_16(st_fx->last_core_fx, HQ_CORE)&&EQ_16(st_fx->core_fx,ACELP_CORE)) { /* don't use old LSF values if this is the first ACELP frame after HQ frames */ Copy( lsf_new, st_fx->lsf_old_fx, M ); } - IF ( L_sub(st_fx->core_brate_fx, SID_2k40) == 0 ) + IF ( EQ_32(st_fx->core_brate_fx, SID_2k40)) { /* return if SID frame (conversion to A(z) done in the calling function) */ return; @@ -174,7 +172,7 @@ void lsf_enc_fx( * FEC - enforce safety-net in the next frame in case of unstable filter *-------------------------------------------------------------------------------------*/ - IF( sub(st_fx->last_L_frame_fx, st_fx->L_frame_fx) != 0 ) + IF( NE_16(st_fx->last_L_frame_fx, st_fx->L_frame_fx)) { /* FEC - in case of core switching, use old LSFs */ Copy( st_fx->lsf_old_fx, st_fx->lsfoldbfi1_fx, M ); @@ -191,12 +189,12 @@ void lsf_enc_fx( test(); test(); /* If decoder FEC frame may be unstable force safety-net usage */ - IF ( (sub(st_fx->L_frame_fx, L_FRAME16k)==0) && (sub(stab, STAB_FAC_LIMIT_FX)< 0) && (sub(coder_type, GENERIC) == 0 )) + IF ( (EQ_16(st_fx->L_frame_fx, L_FRAME16k))&&(LT_16(stab,STAB_FAC_LIMIT_FX))&&(EQ_16(coder_type,GENERIC))) { st_fx->next_force_safety_net_fx = 1; move16(); } - ELSE IF((sub(stab, STAB_FAC_LIMIT_FX) < 0) && (sub(st_fx->clas_fx, VOICED_CLAS)==0 || (sub(st_fx->clas_fx,VOICED_CLAS) < 0 && sub(coder_type,AUDIO) == 0) ) ) + ELSE IF((LT_16(stab, STAB_FAC_LIMIT_FX))&&(EQ_16(st_fx->clas_fx,VOICED_CLAS)||(LT_16(st_fx->clas_fx,VOICED_CLAS)&&EQ_16(coder_type,AUDIO)))) { st_fx->next_force_safety_net_fx = 1; move16(); @@ -231,7 +229,7 @@ void lsf_enc_fx( lsf_mid_enc_fx( st_fx, int_fs, st_fx->lsp_old_fx, lsp_new, lsp_mid, coder_type, st_fx->bwidth_fx, st_fx->core_brate_fx, st_fx->Bin_E_old_fx, st_fx->Bin_E_fx, Q_new+QSCALE-2, st_fx->ppp_mode_fx, st_fx->nelp_mode_fx); test(); - IF ( sub(st_fx->last_core_fx,HQ_CORE) == 0 && sub(st_fx->core_fx,ACELP_CORE) == 0 ) + IF ( EQ_16(st_fx->last_core_fx,HQ_CORE)&&EQ_16(st_fx->core_fx,ACELP_CORE)) { /* don't use old LSP/LSF values if this is the first ACELP frame after HQ frames */ Copy( lsp_mid, st_fx->lsp_old_fx, M ); @@ -287,7 +285,7 @@ static void lsfq_CNG_fx( coefficient (last coefficient of lsf). If the last LSF coefficient (lsf[M-1]) is larger than 6350 the decoded frame is WB2 with sampling rate of 16 kHz, otherwise it is sampled at 12.8kHz and contains either NB or WB LSF data. */ - IF(sub(lsf[M - 1], WB_LIMIT_LSF_FX) > 0) /* 16kHz sampled LSF vector*/ + IF(GT_16(lsf[M - 1], WB_LIMIT_LSF_FX)) /* 16kHz sampled LSF vector*/ { p_cb = &CNG_SN1_fx[0]; move16(); @@ -321,7 +319,7 @@ static void lsfq_CNG_fx( dist = L_add(dist, Mult_32_16(L_mult0(wghts[j], *p_cb),tmp)); p_cb++; } - IF ( L_sub(dist,min_dist) < 0 ) + IF ( LT_32(dist,min_dist)) { min_dist = dist; move16();/*Q-4 */ @@ -394,7 +392,7 @@ static Word16 qlsf_Mode_Select_fx( temp32 = Mult_32_16(op_loop_thr, streaklimit); /* choose the mode */ - IF ( L_sub(En, temp32) > 0) + IF ( GT_32(En, temp32)) { /* Safety-net */ safety_net = 1; @@ -512,9 +510,9 @@ void lsf_end_enc_fx( test(); test(); test(); - IF(sub(coder_type_org, GENERIC)== 0 && L_sub(int_fs, INT_FS_16k)== 0 && (rf_flag == 0) && (mode2_flag == 0)) + IF(EQ_16(coder_type_org, GENERIC)&&EQ_32(int_fs,INT_FS_16k)&&(rf_flag==0)&&(mode2_flag==0)) { - IF (sub(coder_type_raw, VOICED) == 0) + IF (EQ_16(coder_type_raw, VOICED)) { coder_type = VOICED; move16(); /* Reflect Inactive mode */ @@ -536,7 +534,7 @@ void lsf_end_enc_fx( * Calculate the number of stages and levels for each stage based on allowed bit budget * Set absolute threshold for codebook-type decision logic depending on signal bandwidth *------------------------------------------------------------------------------------ -*/ - IF ( sub(bwidth, NB) == 0 ) + IF ( EQ_16(bwidth, NB)) { abs_threshold = L_add(SFNETLOWLIMIT_NB, 0); } @@ -545,12 +543,12 @@ void lsf_end_enc_fx( abs_threshold = L_add(SFNETLOWLIMIT_WB, 0); } /* Calculate LSF weighting coefficients */ - Unified_weighting_fx(&Bin_Ener[L_FFT/2], Q_ener, lsf, wghts, sub(bwidth, NB) == 0, sub(coder_type,UNVOICED) == 0, int_fs,M); + Unified_weighting_fx(&Bin_Ener[L_FFT/2], Q_ener, lsf, wghts, (Word16)EQ_16(bwidth, NB),(Word16)EQ_16(coder_type,UNVOICED),int_fs,M); /*--------------------------------------------------------------------------------* * LSF quantization of SID frames *--------------------------------------------------------------------------------*/ - IF ( L_sub(core_brate, SID_2k40) == 0 ) + IF ( EQ_32(core_brate, SID_2k40)) { lsfq_CNG_fx( st, lsf, wghts, qlsf, &st->offset_scale1_fx[0][0], &st->offset_scale2_fx[0][0], &st->no_scales_fx[0][0] ); sort_fx( qlsf, 0, M-1 ); @@ -597,7 +595,7 @@ void lsf_end_enc_fx( *pstreaklen = 0; move16();/* predictive LSF quantizer streak is ended with safety-net */ } - ELSE IF (sub(predmode, 1) == 0) /* only MA prediction */ + ELSE IF (EQ_16(predmode, 1)) /* only MA prediction */ { Vr_subt(lsf, pred1, Tmp1, M); Err[1] = vq_lvq_lsf_enc(2, mode_lvq_p, Tmp1, levels1, stages1, wghts, Idx1, lsf, pred1, @@ -613,7 +611,7 @@ void lsf_end_enc_fx( test(); test(); test(); - IF ( ((sub(*pstreaklen, (STREAKLEN+3))>0)&&(sub(coder_type, VOICED)== 0)) || ((sub(*pstreaklen, (STREAKLEN)) >0) &&(sub(coder_type, VOICED) != 0))) + IF ( ((GT_16(*pstreaklen, (STREAKLEN+3)))&&(EQ_16(coder_type,VOICED)))||((GT_16(*pstreaklen,(STREAKLEN)))&&(NE_16(coder_type,VOICED)))) { /* update the adaptive scaling factor to become smaller with increasing number of concecutive predictive frames. */ *streaklimit = mult(*streaklimit,STREAKMULT_FX); @@ -628,7 +626,7 @@ void lsf_end_enc_fx( /* VOICED_WB@16kHz */ test(); - IF ( L_sub(int_fs, INT_FS_16k) == 0 && sub(coder_type, VOICED) == 0 ) + IF ( EQ_32(int_fs, INT_FS_16k)&&EQ_16(coder_type,VOICED)) { /* Subtract mean and AR prediction */ Copy( ModeMeans_fx[mode_lvq], pred0, M ); @@ -645,7 +643,7 @@ void lsf_end_enc_fx( /* select safety_net or predictive */ safety_net = qlsf_Mode_Select_fx( wghts, Tmp2, *streaklimit, OP_LOOP_THR_HVO ); - IF ( sub(force_sf, 1) == 0 ) + IF ( EQ_16(force_sf, 1)) { safety_net = 1; move16(); @@ -685,7 +683,7 @@ void lsf_end_enc_fx( st->offset_scale1_fx,st->offset_scale2_fx,st->no_scales_fx, resq, lsfq); /* Predictive quantizer is calculated only if it can be selected */ test(); - IF (!force_sf || L_sub(Err[0],abs_threshold) > 0 ) + IF (!force_sf || GT_32(Err[0],abs_threshold)) { Err[1] = vq_lvq_lsf_enc(2, mode_lvq_p, Tmp2, levels1, stages1, wghts, Idx1, lsf, pred2, st->offset_scale1_p_fx, st->offset_scale2_p_fx, st->no_scales_p_fx, &resq[M], &lsfq[M]); @@ -697,7 +695,7 @@ void lsf_end_enc_fx( if the non-predictive (safety-net) quantization error (Err[0]) is low enough (spectral distortion is low) it is selected or if the predictively quantized error (Err[1]) is by at least adaptive margin smaller than non-predictive quantizer. or if the in case of frame erasure the resulting concealed predictive LSF would be unstable safety-net is selected */ - IF ( force_sf || L_sub(Mult_32_16(Err[0],(*streaklimit)),L_add(Err[1],Mult_32_16(Err[1],PREFERSFNET_FX))) < 0 || L_sub(Err[0], abs_threshold) < 0 ) + IF ( force_sf || LT_32(Mult_32_16(Err[0],(*streaklimit)),L_add(Err[1],Mult_32_16(Err[1],PREFERSFNET_FX)))||LT_32(Err[0],abs_threshold)) { safety_net = 1; move16(); @@ -720,20 +718,20 @@ void lsf_end_enc_fx( { /* write coder_type bit for VOICED@16kHz or GENERIC@16kHz */ test(); - IF(sub(coder_type_org, GENERIC)==0 && L_sub(int_fs, INT_FS_16k)==0) + IF(EQ_16(coder_type_org, GENERIC)&&EQ_32(int_fs,INT_FS_16k)) { /* VOICED =2 and GENERIC=3, so "coder_type-2" means VOICED =0 and GENERIC=1*/ push_indice_fx( st, IND_LSF_PREDICTOR_SELECT_BIT, sub(coder_type,2), 1 ); } /* write predictor selection bit */ - IF ( sub(predmode, 2) == 0 ) + IF ( EQ_16(predmode, 2)) { push_indice_fx( st, IND_LSF_PREDICTOR_SELECT_BIT, safety_net, 1 ); } test(); - IF ( sub(coder_type, VOICED)== 0 && L_sub(int_fs, INT_FS_16k) == 0 ) + IF ( EQ_16(coder_type, VOICED)&&EQ_32(int_fs,INT_FS_16k)) { /* BC-TCVQ (only for VOICED@16kHz) */ TCQIdx = &TCQIdx0[1]; @@ -747,7 +745,7 @@ void lsf_end_enc_fx( { cumleft = nBits; move16(); - IF (sub( predmode, 2 )==0) + IF (EQ_16( predmode, 2 )) { /* subtract predictor selection bit */ cumleft = sub(nBits, 1); @@ -789,7 +787,7 @@ void lsf_end_enc_fx( indice[i] = Idx[i]; move16(); - IF ( sub(cumleft, LEN_INDICE) >0 ) + IF ( GT_16(cumleft, LEN_INDICE)) { num_bits = LEN_INDICE; move16(); @@ -809,7 +807,7 @@ void lsf_end_enc_fx( ELSE { test(); - IF ( sub(coder_type, VOICED)==0 && L_sub(int_fs, INT_FS_16k)== 0 ) + IF ( EQ_16(coder_type, VOICED)&&EQ_32(int_fs,INT_FS_16k)) { /* BC-TCVQ (only for VOICED@16kHz) */ /* Number of quantization indices */ @@ -828,7 +826,7 @@ void lsf_end_enc_fx( /* Number of quantization indices */ /* there are 31 bits */ - IF (sub(safety_net, 1) == 0) + IF (EQ_16(safety_net, 1)) { Idx = Idx0; move16(); @@ -875,7 +873,7 @@ void lsf_end_enc_fx( move16(); bits_param_lpc[stages1] = sub(bits1[tmp], LEN_INDICE); } - IF (sub(predmode,2) ==0 ) + IF (EQ_16(predmode,2)) { FOR (i=*no_indices; i>0; i--) { @@ -903,7 +901,7 @@ void lsf_end_enc_fx( { /* Safety-net */ test(); - IF ( sub(coder_type, VOICED) == 0 && L_sub(int_fs, INT_FS_16k) == 0 ) + IF ( EQ_16(coder_type, VOICED)&&EQ_32(int_fs,INT_FS_16k)) { /* BC-TCQ */ Copy( lsfq, mem_MA, M ); @@ -922,7 +920,7 @@ void lsf_end_enc_fx( ELSE { test(); - IF ( sub(coder_type, VOICED)== 0 && L_sub(int_fs, INT_FS_16k) == 0 ) + IF ( EQ_16(coder_type, VOICED)&&EQ_32(int_fs,INT_FS_16k)) { /* BC-TCVQ */ Copy( lsfq, mem_MA, M ); @@ -934,7 +932,7 @@ void lsf_end_enc_fx( vq_dec_lvq_fx( 0, qlsf, &indice[0], stages1, M, mode_lvq_p, levels1[stages1-1], &st->offset_scale1_fx[0][0], &st->offset_scale2_fx[0][0], &st->offset_scale1_p_fx[0][0], &st->offset_scale2_p_fx[0][0], &st->no_scales_fx[0][0], &st->no_scales_p_fx[0][0] ); - IF (sub(predmode,1) == 0) + IF (EQ_16(predmode,1)) { Copy(qlsf, mem_MA, M); Vr_add( qlsf, pred1, qlsf, M ); @@ -1099,7 +1097,7 @@ static void first_VQstages( L_tmp = L_add(dist[0][c], L_sub(en, L_shl(L_tmp, 1))); - IF ( L_sub(L_tmp,dist[1][p_max]) <= 0 ) + IF ( LE_32(L_tmp,dist[1][p_max])) { /* replace worst */ dist[1][p_max] = L_tmp; @@ -1110,10 +1108,10 @@ static void first_VQstages( move16(); /* limit number of times inner loop is entered */ - IF ( sub(counter, max_inner) < 0 ) + IF ( LT_16(counter, max_inner)) { counter=add(counter,1); - IF ( sub(counter, max_inner) < 0 ) + IF ( LT_16(counter, max_inner)) { /* find new worst */ p_max = maximum_32_fx(dist[1],maxC, &f_tmp); @@ -1311,7 +1309,7 @@ static void BcTcvq_1st_fx( temp16_fx = sub(x_fx[0][1], CB_fx[0][index][1]); dist_fx = L_add(dist_fx, Mult_32_16(L_mult0(temp16_fx, temp16_fx), W_fx[0][1])); /* 2.56*2.56*Q(-5) */ - if (L_sub(dist_fx, minDist_fx) < 0) + if (LT_32(dist_fx, minDist_fx)) { bestCode = index; move16(); @@ -1386,7 +1384,7 @@ static void BcTcvq_2nd_fx( temp16_fx = sub(target_fx[1], CB_fx[1][index][1]); dist_fx = L_add(dist_fx, Mult_32_16(L_mult0(temp16_fx, temp16_fx), W_fx[1][1])); /* 2.65*2.65*Q(-5) */ - if (L_sub(dist_fx, minDist_fx) < 0) + if (LT_32(dist_fx, minDist_fx)) { bestCode = index; move16(); @@ -1467,7 +1465,7 @@ static void BcTcvq_SubBlock_fx( temp16_fx = sub(target_fx[1], CB_fx[stage2][index][1]); dist_fx = L_add(dist_fx, Mult_32_16(L_mult0(temp16_fx, temp16_fx), W_fx[stage][1])); - if (L_sub(dist_fx, minDist_fx) < 0) + if (LT_32(dist_fx, minDist_fx)) { bestCode = index; move16(); @@ -1515,7 +1513,7 @@ static void BcTcvq_SubBlock_fx( dist_fx = Mult_32_16(L_mult0(temp16_fx, temp16_fx), W_fx[stage][0]); temp16_fx = sub(target_fx[1], CB_fx[stage2][index][1]); dist_fx = L_add(dist_fx, Mult_32_16(L_mult0(temp16_fx, temp16_fx), W_fx[stage][1])); - if (L_sub(dist_fx, minDist_fx) < 0) + if (LT_32(dist_fx, minDist_fx)) { bestCode = index; move16(); @@ -1537,7 +1535,7 @@ static void BcTcvq_SubBlock_fx( branch = 1; move16(); - if (L_sub(brDist_fx[0], brDist_fx[1]) <= 0) + if (LE_32(brDist_fx[0], brDist_fx[1])) { branch = 0; move16(); @@ -1613,7 +1611,7 @@ static Word32 BcTcvq_FixSearch_fx( temp16_fx = sub(target_fx[1], CB_fx[stage4][index][1]); dist_fx = L_add(dist_fx, Mult_32_16(L_mult0(temp16_fx, temp16_fx), W_fx[stage][1])); - if(L_sub(dist_fx, minDist_fx) < 0) + if(LT_32(dist_fx, minDist_fx)) { bestCode = index; move16(); @@ -1664,7 +1662,7 @@ static Word16 optimalPath_fx( FOR (state = 1; state < NUM_STATE; state++) { - if (L_sub(opDist_fx[state], minDist_fx) < 0) + if (LT_32(opDist_fx[state], minDist_fx)) { fBlock = state; move16(); @@ -1780,7 +1778,7 @@ static void buildCode_fx( FOR (stage = N_STAGE_VQ - 4; stage >= 1; stage--) { - if(sub(s[stage], 7) > 0) + if(GT_16(s[stage], 7)) { BrIndex[stage-1] =1; move16(); @@ -1941,7 +1939,7 @@ static void BcTcvq_fx( { fDist_fx = L_add(fDist_fx, BcTcvq_FixSearch_fx(X_fx, TCVQ_CB_SUB3_fx, fCodeword, quant_fx, FixBranch_tbl, stage, inis, i, &prev_state, W_fx, IntraCoeff_fx)); } - IF (L_sub(fDist_fx, minDist_fx) < 0) + IF (LT_32(fDist_fx, minDist_fx)) { minDist_fx = L_add(fDist_fx, 0); blockDist_fx[state] = minDist_fx; @@ -2000,7 +1998,7 @@ static Word16 SVQ_2d_fx( L_shr(Mult_32_16(L_mult(temp16_fx, temp16_fx), W_fx[j]), 1)); } - IF (L_sub(distortion_fx, temp_fx) < 0) + IF (LT_32(distortion_fx, temp_fx)) { temp_fx = L_add(distortion_fx, 0); index = i; @@ -2033,13 +2031,13 @@ Word32 qlsf_ARSN_tcvq_Enc_16k_fx ( Word16 error_svq_fx[M], error_svq_q_fx[M]; Word16 cl, cs; Word32 temp_l; - IF (sub(safety_net, 1) == 0) + IF (EQ_16(safety_net, 1)) { indice[0] = 1; move16(); BcTcvq_fx(1, /*x, x_q, w, */x_fx, x_q_fx, w_fx, &indice[1]); - IF (sub(nBits, 30) > 0) + IF (GT_16(nBits, 30)) { /* SVQ */ FOR (i = 0; i < M; i++) @@ -2066,7 +2064,7 @@ Word32 qlsf_ARSN_tcvq_Enc_16k_fx ( move16(); BcTcvq_fx(0, /*x, x_q, w, */x_fx, x_q_fx, w_fx, &indice[1]); - IF (sub(nBits, 30) > 0) + IF (GT_16(nBits, 30)) { /* SVQ */ FOR (i = 0; i < M; i++) @@ -2203,7 +2201,7 @@ static void lsf_mid_enc_fx( FFT_Mid_Interpol_16k_fx( Bin_Ener_old, &Bin_Ener[L_FFT/2], Bin_Ener_mid ); /* LSF weighting */ - Unified_weighting_fx( Bin_Ener_mid, Q_ener, lsf, wghts, sub(bwidth, NB) == 0, sub(coder_type, UNVOICED) == 0, int_fs, M ); + Unified_weighting_fx( Bin_Ener_mid, Q_ener, lsf, wghts, (Word16)EQ_16(bwidth, NB),(Word16)EQ_16(coder_type,UNVOICED),int_fs,M); move16(); /* codebook selection, number of bits, size of the codebook */ test(); @@ -2213,7 +2211,7 @@ static void lsf_mid_enc_fx( move16(); /* codebook selection */ - IF ( sub(coder_type, VOICED) == 0) + IF ( EQ_16(coder_type, VOICED)) { SWITCH ( nb_bits ) { @@ -2231,7 +2229,7 @@ static void lsf_mid_enc_fx( } } } - ELSE IF ( sub(coder_type, UNVOICED) == 0 ) + ELSE IF ( EQ_16(coder_type, UNVOICED)) { ratio = tbl_mid_unv_wb_5b_fx; } @@ -2258,7 +2256,7 @@ static void lsf_mid_enc_fx( size = (Word16) pow2[nb_bits]; move16(); } - ELSE IF ( sub(ppp_mode, 1) == 0 ) + ELSE IF ( EQ_16(ppp_mode, 1)) { ratio = tbl_mid_voi_wb_1b_fx; move16(); @@ -2267,7 +2265,7 @@ static void lsf_mid_enc_fx( size = 2; move16(); } - ELSE IF ( sub(nelp_mode, 1) == 0 ) + ELSE IF ( EQ_16(nelp_mode, 1)) { ratio = tbl_mid_unv_wb_4b_fx; move16(); @@ -2297,7 +2295,7 @@ static void lsf_mid_enc_fx( test(); test(); - IF ( j > 0 && sub(j, M) < 0 && sub(qlsf[j], add(qlsf[j-1], LSF_GAP_MID_FX)) < 0) + IF ( j > 0 && LT_16(j, M)&<_16(qlsf[j],add(qlsf[j-1],LSF_GAP_MID_FX))) { qlsf[j] = add(qlsf[j-1], LSF_GAP_MID_FX); move16(); @@ -2314,7 +2312,7 @@ static void lsf_mid_enc_fx( err = Mult_32_16(err,LSF_1_OVER_256SQ); /* err = Mult_32_16(err,Wmult); */ - IF ( L_sub(err,err_min) < 0 ) + IF ( LT_32(err,err_min)) { err_min = L_add(err, 0); idx = k; @@ -2334,7 +2332,7 @@ static void lsf_mid_enc_fx( test(); test(); - IF ( j > 0 && sub(j, M) < 0 && sub(qlsf[j], add(qlsf[j-1], LSF_GAP_MID_FX)) < 0 ) + IF ( j > 0 && LT_16(j, M)&<_16(qlsf[j],add(qlsf[j-1],LSF_GAP_MID_FX))) { qlsf[j] = add(qlsf[j-1], LSF_GAP_MID_FX); move16(); diff --git a/lib_enc/lsf_msvq_ma_enc.c b/lib_enc/lsf_msvq_ma_enc.c index d8fc1cad67e75f57d01778e62c75f62c470fd23b..dde41b8f4dbe70d2f82fc4cc9eed2ce2ac6bebe5 100644 --- a/lib_enc/lsf_msvq_ma_enc.c +++ b/lib_enc/lsf_msvq_ma_enc.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -8,8 +8,6 @@ #include "rom_com_fx.h" #include "prot_fx.h" #include "stl.h" -#include "wmc_auto.h" - #include "basop_util.h" #include "rom_enc_fx.h" @@ -30,7 +28,8 @@ static Word32 depack_mul_values(Word16 *Tmp, const Word16 *w, const Word16 *cbp, Word16 i, val0, val1, val2, val3; Word32 en; - en = L_add(0,0); + en = 0; + move32(); FOR (i = 0; i < N; i+=4) { depack_4_values(cbp+i_mult(shr(i,2),3), val0, val1, val2, val3) @@ -80,43 +79,43 @@ static Word16 msvq_enc_find_p_max_8(Word32 dist[]) p_max = 0; move16(); - BASOP_SATURATE_WARNING_ON; - if (L_sub(dist[1], dist[p_max]) > 0) + BASOP_SATURATE_WARNING_OFF + if (GT_32(dist[1], dist[p_max])) { p_max = 1; move16(); } - if (L_sub(dist[2], dist[p_max]) > 0) + if (GT_32(dist[2], dist[p_max])) { p_max = 2; move16(); } - if (L_sub(dist[3], dist[p_max]) > 0) + if (GT_32(dist[3], dist[p_max])) { p_max = 3; move16(); } - if (L_sub(dist[4], dist[p_max]) > 0) + if (GT_32(dist[4], dist[p_max])) { p_max = 4; move16(); } - if (L_sub(dist[5], dist[p_max]) > 0) + if (GT_32(dist[5], dist[p_max])) { p_max = 5; move16(); } - if (L_sub(dist[6], dist[p_max]) > 0) + if (GT_32(dist[6], dist[p_max])) { p_max = 6; move16(); } - if (L_sub(dist[7], dist[p_max]) > 0) + if (GT_32(dist[7], dist[p_max])) { p_max = 7; move16(); } - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON return p_max; } @@ -128,33 +127,33 @@ static Word16 msvq_enc_find_p_max_6(Word32 dist[]) p_max = 0; move16(); - BASOP_SATURATE_WARNING_ON; - if (L_sub(dist[1], dist[p_max]) > 0) + BASOP_SATURATE_WARNING_OFF + if (GT_32(dist[1], dist[p_max])) { p_max = 1; move16(); } - if (L_sub(dist[2], dist[p_max]) > 0) + if (GT_32(dist[2], dist[p_max])) { p_max = 2; move16(); } - if (L_sub(dist[3], dist[p_max]) > 0) + if (GT_32(dist[3], dist[p_max])) { p_max = 3; move16(); } - if (L_sub(dist[4], dist[p_max]) > 0) + if (GT_32(dist[4], dist[p_max])) { p_max = 4; move16(); } - if (L_sub(dist[5], dist[p_max]) > 0) + if (GT_32(dist[5], dist[p_max])) { p_max = 5; move16(); } - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON return p_max; } @@ -211,7 +210,7 @@ void msvq_enc func_ptr = msvq_enc_find_p_max_6; move16(); - if (sub(maxC,8) == 0) + if (EQ_16(maxC,8)) { func_ptr = msvq_enc_find_p_max_8; move16(); @@ -319,11 +318,11 @@ void msvq_enc t1 = L_mac(t1, pTmp[i], Tmp[i]); } - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF /*NOTE: as long as a shorter distance is found, saturation can be accepted.*/ tmp = L_add(dist[0][c], L_sub(en, L_shl(t1,1))); t1 = L_sub(tmp ,dist[1][p_max]); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON IF (t1 <= 0) { @@ -401,7 +400,7 @@ void midlsf_enc( - IF ( sub(coder_type, UNVOICED) == 0 ) + IF ( EQ_16(coder_type, UNVOICED)) { ratio = tbl_mid_unv_wb_5b_fx; } @@ -441,7 +440,7 @@ void midlsf_enc( qlsf[j] = round_fx(L_shl(L_tmp,2)); test(); test(); - IF ( j > 0 && sub(j, M) < 0 && sub(qlsf[j], add(qlsf[j-1], LSF_GAP_MID_FX)) < 0) + IF ( j > 0 && LT_16(j, M)&<_16(qlsf[j],add(qlsf[j-1],LSF_GAP_MID_FX))) { qlsf[j] = add(qlsf[j-1], LSF_GAP_MID_FX); } @@ -459,7 +458,7 @@ void midlsf_enc( err = Mult_32_16(err,LSF_1_OVER_256SQ); /* err = Mult_32_16(err,Wmult); */ - IF ( L_sub(err,err_min) < 0 ) + IF ( LT_32(err,err_min)) { err_min = L_add(err, 0); *idx = k; @@ -497,7 +496,7 @@ Word16 Q_lsf_tcxlpc( Word16 lsf_rem[M]; Word16 lsf_rem_q_ind[M]; - Unified_weighting_fx( Bin_Ener, Q_ener, lsf, weights, narrowband, sub(coder_type,UNVOICED)==0, 12800, M ); + Unified_weighting_fx( Bin_Ener, Q_ener, lsf, weights, narrowband,(Word16)EQ_16(coder_type,UNVOICED),12800,M); move16(); NumIndices = 0; @@ -685,7 +684,7 @@ Word16 lsf_msvq_ma_encprm( Encoder_State_fx * st, param_lpc++; nbits_lpc = add(nbits_lpc, bits_param_lpc[i]); } - IF ( sub(acelp_mode,VOICED) != 0 ) + IF ( NE_16(acelp_mode,VOICED)) { test(); IF ( core==0 && acelp_midLpc) diff --git a/lib_enc/ltd_stable.c b/lib_enc/ltd_stable.c index b3f618971338514cb6d6c9fe579f7e5bc07bbe73..6c0b30dd09b6cc95aa245524141f6d0bbcac4e6a 100644 --- a/lib_enc/ltd_stable.c +++ b/lib_enc/ltd_stable.c @@ -1,12 +1,10 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "basop_util.h" #include "stl.h" -#include "wmc_auto.h" - #include "vad_basop.h" #include "prot_fx.h" @@ -42,7 +40,8 @@ void ltd_stable(T_CldfbVadState *st, /*(io) vad state*/ Word32 seg_amp32tmp; Word16 tmp; - zerop001 = L_add(0, 0); + zerop001 = 0; + move32(); Q_dif = 0; move16(); Q_apow = 0; @@ -63,7 +62,7 @@ void ltd_stable(T_CldfbVadState *st, /*(io) vad state*/ Q_frames_power32 = add(Q_frames_power32, 16); /* +0.1 */ - IF (sub(Q_frames_power32, 40) >= 0) + IF (GE_16(Q_frames_power32, 40)) { zerop001 = L_shr(CNT0P001, 1); frame_energy_Sqr32 = L_shr(frame_energy_Sqr32,sub(Q_frames_power32, 39)); @@ -79,7 +78,7 @@ void ltd_stable(T_CldfbVadState *st, /*(io) vad state*/ frames_power_32[0] = L_add(frame_energy_Sqr32, zerop001); move32(); - IF(sub(frameloop, 3) < 0) + IF(LT_16(frameloop, 3)) { FOR(i=1; i<40; i++) { @@ -90,7 +89,8 @@ void ltd_stable(T_CldfbVadState *st, /*(io) vad state*/ ELSE { Word16 leadingzero; - maxVal = L_add(0, 0); + maxVal = 0; + move32(); FOR(i=1; i<40; i++) { maxVal = L_max(maxVal,frames_power_32[i]); @@ -102,7 +102,7 @@ void ltd_stable(T_CldfbVadState *st, /*(io) vad state*/ Q_frames_power_last_32 = add(Q_frames_power_last_32, leadingzero); - IF (sub(Q_frames_power_last_32,Q_frames_power32)>0) + IF (GT_16(Q_frames_power_last_32,Q_frames_power32)) { scale1 = sub(Q_frames_power_last_32, Q_frames_power32); scale1 = sub(scale1, leadingzero); @@ -133,7 +133,7 @@ void ltd_stable(T_CldfbVadState *st, /*(io) vad state*/ move32(); } - maxVal = L_add(0, 0); + maxVal = 0; move32(); FOR(i=0; i<20; i++) { maxVal = L_max(maxVal,mid_frame_ampadd32[i]); @@ -149,15 +149,15 @@ void ltd_stable(T_CldfbVadState *st, /*(io) vad state*/ move32(); } - seg_amp32 = L_add(0, 0); + seg_amp32 = 0; move32(); FOR(i=0; i<20; i++) { seg_amp32 = L_add(seg_amp32, L_shr(mid_frame_amp32[i], 5)); } seg_amp32 = MUL_F(seg_amp32, 0x0666); - dif32 = L_add(0, 0); - apow32 = L_add(0, 0); + dif32 = 0; move32(); + apow32 = 0; move32(); seg_amp32tmp = L_shl(seg_amp32, 5); FOR(i=0; i<20; i++) @@ -166,7 +166,7 @@ void ltd_stable(T_CldfbVadState *st, /*(io) vad state*/ move32(); } - maxVal = L_add(0, 0); + maxVal = 0; move32(); FOR(i=0; i<20; i++) { maxVal = L_max(maxVal,L_abs(tmp32[i])); @@ -219,7 +219,7 @@ void ltd_stable(T_CldfbVadState *st, /*(io) vad state*/ ltd_stable_rate[0] = shr(ltd_stable_rate[0],ltd_stable_rate_Qtmp); move16(); - maxVal = L_add(0, 0); + maxVal = 0; move32(); FOR(i=0; i<14; i++) { maxVal = L_max(maxVal, L_abs(mid_frame_ampadd32[i])); @@ -235,15 +235,15 @@ void ltd_stable(T_CldfbVadState *st, /*(io) vad state*/ move32(); } - seg_amp32 = L_add(0, 0); + seg_amp32 = 0; move32(); FOR(i=0; i<14; i++) { seg_amp32 = L_add(seg_amp32, L_shr(mid_frame_amp32[i],4)); } seg_amp32 = MUL_F(seg_amp32, 0x0924); - dif32 = L_add(0, 0); - apow32 = L_add(0, 0); + dif32 = 0; move32(); + apow32 = 0; move32(); seg_amp32tmp = L_shl(seg_amp32, 4); FOR(i=0; i<14; i++) { @@ -251,7 +251,7 @@ void ltd_stable(T_CldfbVadState *st, /*(io) vad state*/ move32(); } - maxVal = L_add(0, 0); + maxVal = 0; move32(); FOR(i=0; i<14; i++) { maxVal = L_max(maxVal,L_abs(tmp32[i])); @@ -289,7 +289,7 @@ void ltd_stable(T_CldfbVadState *st, /*(io) vad state*/ Qsum_dif32 = add(Qsum_dif32, leadingzero_tmp32); /* +0.1 */ - IF (sub(Qsum_apow32,44)>=0) + IF (GE_16(Qsum_apow32,44)) { zerop001 = L_shr(CNT0P0001, 1); apow32 = L_shr(apow32,limitScale32(sub(Qsum_apow32,43))); @@ -305,7 +305,7 @@ void ltd_stable(T_CldfbVadState *st, /*(io) vad state*/ apow32 = L_add(apow32, zerop001); IF (apow32 == 0) { - apow32 = L_add(0, CNT0P0001); + apow32 = CNT0P0001; move32(); Qsum_apow32 = 44; move16(); } @@ -337,7 +337,7 @@ void ltd_stable(T_CldfbVadState *st, /*(io) vad state*/ ltd_stable_rate[1] = shr(ltd_stable_rate[1],ltd_stable_rate_Qtmp); move16(); - maxVal = L_add(0, 0); + maxVal = 0; move32(); FOR(i=0; i<8; i++) { maxVal = L_max(maxVal,L_abs(mid_frame_ampadd32[i])); @@ -353,15 +353,15 @@ void ltd_stable(T_CldfbVadState *st, /*(io) vad state*/ move32(); } - seg_amp32 = L_add(0, 0); + seg_amp32 = 0; move32(); FOR(i=0; i<8; i++) { seg_amp32 = L_add(seg_amp32, L_shr(mid_frame_amp32[i], 3)); } seg_amp32 = MUL_F(seg_amp32, 0x1000); - dif32 = L_add(0, 0); - apow32 = L_add(0, 0); + dif32 = 0; move32(); + apow32 = 0; move32(); seg_amp32tmp = L_shl(seg_amp32, 3); FOR(i=0; i<8; i++) { @@ -369,7 +369,7 @@ void ltd_stable(T_CldfbVadState *st, /*(io) vad state*/ move32(); } - maxVal = L_add(0, 0); + maxVal = 0; move32(); FOR(i=0; i<8; i++) { maxVal = L_max(maxVal,L_abs(tmp32[i])); @@ -407,7 +407,7 @@ void ltd_stable(T_CldfbVadState *st, /*(io) vad state*/ Qsum_dif32 = add(Qsum_dif32,leadingzero_tmp32); /* +0.1 */ - IF (sub(Qsum_apow32,44) >= 0) + IF (GE_16(Qsum_apow32,44)) { zerop001 = L_shr(CNT0P0001, 1); apow32 = L_shr(apow32,limitScale32(sub(Qsum_apow32,43))); @@ -423,7 +423,7 @@ void ltd_stable(T_CldfbVadState *st, /*(io) vad state*/ apow32 = L_add(apow32, zerop001); IF (apow32 == 0) { - apow32 = L_add(0, CNT0P0001); + apow32 = CNT0P0001; move32(); Qsum_apow32 = 44; move16(); } diff --git a/lib_enc/mdct_classifier_fx.c b/lib_enc/mdct_classifier_fx.c index 6d77638db4b6960d3ed9b32df3f8b36fb3d3ea7d..554b8cf96ff3e336291d5a667e0f0a1ad7d7bab1 100644 --- a/lib_enc/mdct_classifier_fx.c +++ b/lib_enc/mdct_classifier_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" #include "cnst_fx.h" #include "prot_fx.h" #include "stl.h" -#include "wmc_auto.h" - /*--------------------------------------------------------------------------* * mdct_classifier() @@ -119,7 +117,7 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision */ { /* NB: a*f + b*(1 - f) needs two multiplies * = (a - b)*f + b saves one multiply */ - IF (L_sub(*(++pMagSq), nf) > 0L) + IF (GT_32(*(++pMagSq), nf)) { factor = 31385; move16();/* 0.9578 in Q15 */ @@ -132,7 +130,7 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision */ acc = L_sub(nf, *pMagSq); Mpy_32_16_ss(acc, factor, &acc, &lsb16); nf = L_add(acc, *pMagSq); - IF (L_sub(*pMagSq, pe) > 0L) + IF (GT_32(*pMagSq, pe)) { factor = 13840; move16();/* 0.42237 in Q15 */ @@ -146,9 +144,9 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision */ Mpy_32_16_ss(acc, factor, &acc, &lsb16); pe = L_add(acc, *pMagSq); Mpy_32_16_ss(pe, 20972, &acc, &lsb16); /* 0.64 in Q15 */ - IF (L_sub(*pMagSq, acc) > 0L) + IF (GT_32(*pMagSq, acc)) { - IF (L_sub(*pMagSq, max_cand) > 0L) + IF (GT_32(*pMagSq, max_cand)) { max_cand = L_add(*pMagSq, 0); max_i = add(2, k); @@ -158,7 +156,7 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision */ { IF (max_i > 0) { - IF (sub(np, 0) > 0) + IF (GT_16(np, 0)) { d_acc = sub(add(d_acc, max_i), pos_last); } @@ -216,7 +214,7 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision */ Mpy_32_16_ss(cldfbBuf_Ener[25], 6554, &avrg_H1, &lsb16); FOR (k = 1; k < 5; k++) { - IF(L_sub(cldfbBuf_Ener[k + 25], peak_H1) > 0) + IF(GT_32(cldfbBuf_Ener[k + 25], peak_H1)) { peak_H1 = L_add(cldfbBuf_Ener[k + 25], 0); } @@ -227,7 +225,7 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision */ Mpy_32_16_ss(cldfbBuf_Ener[20], 6554, &avrg_H2, &lsb16); FOR (k = 1; k < 5; k++) { - IF (L_sub(cldfbBuf_Ener[k + 20], peak_H2) > 0) + IF (GT_32(cldfbBuf_Ener[k + 20], peak_H2)) { peak_H2 = L_add(cldfbBuf_Ener[k + 20], 0); } @@ -242,11 +240,11 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision */ { avrg_l = L_add(avrg_l, L_shr(magSq[k + 20], 5)); avrg_h = L_add(avrg_h, L_shr(magSq[k + 96], 5)); - IF (L_sub(magSq[k + 20], peak_l) > 0) + IF (GT_32(magSq[k + 20], peak_l)) { peak_l = L_add(magSq[k + 20], 0); } - IF (L_sub(magSq[k + 96], peak_h) > 0) + IF (GT_32(magSq[k + 96], peak_h)) { peak_h = L_add(magSq[k + 96], 0); } @@ -291,7 +289,7 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision */ move16(); L_tmp = Mult_32_16(peak_h, 12603); - IF(L_sub(peak_l, L_tmp) > 0) + IF(GT_32(peak_l, L_tmp)) { exp = norm_l(peak_l); } @@ -299,7 +297,7 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision */ { exp = norm_l(L_tmp); } - IF(L_sub(avrg_h, avrg_l) > 0) + IF(GT_32(avrg_h, avrg_l)) { exp1 = norm_l(avrg_h); } @@ -309,7 +307,7 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision */ } L_tmp1 = Mult_32_16(peak_l, 12603); - IF(L_sub(peak_h, L_tmp1) > 0) + IF(GT_32(peak_h, L_tmp1)) { exp2 = norm_l(peak_h); } @@ -322,16 +320,16 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision */ test(); test(); test(); - IF (L_sub(Mult_32_16(gain3, 27307), gain2) > 0 || (L_sub(gain3, Mult_32_16(gain2, 26214)) >= 0 && L_sub(peak_H1, L_shl(avrg_H1, 1)) > 0) - || (L_sub(Mult_32_32(L_shl(peak_l, exp), L_shl(avrg_h, exp1)), Mult_32_32(L_shl(L_tmp, exp), L_shl(avrg_l, exp1))) < 0 - || L_sub(Mult_32_32(L_shl(L_tmp1, exp2), L_shl(avrg_h, exp1)), Mult_32_32(L_shl(peak_h, exp2), L_shl(avrg_l, exp1))) > 0)) + IF (GT_32(Mult_32_16(gain3, 27307), gain2)||(GE_32(gain3,Mult_32_16(gain2,26214))&>_32(peak_H1,L_shl(avrg_H1,1))) + || (LT_32(Mult_32_32(L_shl(peak_l, exp), L_shl(avrg_h, exp1)), Mult_32_32(L_shl(L_tmp, exp), L_shl(avrg_l, exp1))) + || GT_32(Mult_32_32(L_shl(L_tmp1, exp2), L_shl(avrg_h, exp1)), Mult_32_32(L_shl(peak_h, exp2), L_shl(avrg_l, exp1))))) { condition3 = 1; move16(); } L_tmp = Mult_32_16(peak_h, 12800); - IF(L_sub(peak_l, L_tmp) > 0) + IF(GT_32(peak_l, L_tmp)) { exp = norm_l(peak_l); } @@ -341,7 +339,7 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision */ } L_tmp1 = Mult_32_16(peak_l, 6400); - IF(L_sub(peak_h, L_tmp1) > 0) + IF(GT_32(peak_h, L_tmp1)) { exp2 = norm_l(peak_h); } @@ -350,7 +348,7 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision */ exp2 = norm_l(L_tmp1); } - IF(L_sub(peak_h, L_shl(L_tmp1, 1)) > 0) + IF(GT_32(peak_h, L_shl(L_tmp1, 1))) { exp3 = norm_l(peak_h); } @@ -368,11 +366,11 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision */ test(); test(); test(); - IF ((L_sub(gain4, Mult_32_16(gain11, 26214)) > 0 && L_sub(Mult_32_32(L_shl(peak_l, exp), L_shl(avrg_h, exp1)), Mult_32_32(L_shl(Mult_32_16(peak_h, 12800), exp), L_shl(avrg_l, exp1))) > 0 - && L_sub(Mult_32_32(L_shl(Mult_32_16(peak_l, 6400), exp2), L_shl(avrg_h, exp1)), Mult_32_32(L_shl(peak_h, exp2), L_shl(avrg_l, exp1))) < 0) - || (L_sub(gain4, Mult_32_16(gain11, 9830)) > 0 && L_sub(Mult_32_16(peak_h, 21845), avrg_h) < 0 && L_sub(Mult_32_16(peak_H2, 21845), avrg_H2) < 0) - || (L_sub(Mult_32_32(L_shl(peak_l, exp), L_shl(avrg_h, exp1)), Mult_32_32(L_shl(Mult_32_16(peak_h, 12800), exp), L_shl(avrg_l, exp1))) < 0 && L_sub(Mult_32_16(peak_h, 21845), avrg_h) > 0) - || (L_sub(Mult_32_32(L_shl(Mult_32_16(peak_l, 12800), exp3), L_shl(avrg_h, exp1)), Mult_32_32(L_shl(peak_h, exp3), L_shl(avrg_l, exp1))) > 0 && L_sub(Mult_32_16(peak_h, 21845), avrg_h) < 0) ) + IF ((GT_32(gain4, Mult_32_16(gain11, 26214))&>_32(Mult_32_32(L_shl(peak_l,exp),L_shl(avrg_h,exp1)),Mult_32_32(L_shl(Mult_32_16(peak_h,12800),exp),L_shl(avrg_l,exp1))) + && LT_32(Mult_32_32(L_shl(Mult_32_16(peak_l, 6400), exp2), L_shl(avrg_h, exp1)), Mult_32_32(L_shl(peak_h, exp2), L_shl(avrg_l, exp1)))) + || (GT_32(gain4, Mult_32_16(gain11, 9830))&& LT_32(Mult_32_16(peak_h, 21845), avrg_h)&& LT_32(Mult_32_16(peak_H2, 21845), avrg_H2)) + || (LT_32(Mult_32_32(L_shl(peak_l, exp), L_shl(avrg_h, exp1)), Mult_32_32(L_shl(Mult_32_16(peak_h, 12800), exp), L_shl(avrg_l, exp1))) && GT_32(Mult_32_16(peak_h, 21845), avrg_h)) + || (GT_32(Mult_32_32(L_shl(Mult_32_16(peak_l, 12800), exp3), L_shl(avrg_h, exp1)), Mult_32_32(L_shl(peak_h, exp3), L_shl(avrg_l, exp1))) > 0 && LT_32(Mult_32_16(peak_h, 21845), avrg_h))) { condition4 = 1; move16(); @@ -382,8 +380,8 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision */ test(); test(); test(); - IF ((L_sub(st_fx->total_brate_fx, HQ_32k) == 0 && (s_xor(condition1, condition2) != 0 || condition3)) - || (L_sub(st_fx->total_brate_fx, HQ_24k40) == 0 && condition4)) + IF ((EQ_32(st_fx->total_brate_fx, HQ_32k)&&(s_xor(condition1,condition2)!=0||condition3)) + || (EQ_32(st_fx->total_brate_fx, HQ_24k40)&& condition4)) { c = MDCT_CLASSIFER_HQ_LOCAL; /* Q13 */ move16(); } @@ -396,7 +394,7 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision */ acc = L_mult(st_fx->clas_sec_old_fx, MDCT_CLASSIFER_SMOOTH_FILT_COEFF); /* st_fx->clas_sec_old_fx in Q13 */ clas_sec = mac_r(acc, c, 0x7fff - MDCT_CLASSIFER_SMOOTH_FILT_COEFF); /* clas_sec and c are in Q13 */ /* Do thresholding with hysteresis */ - IF(sub(st_fx->last_enerBuffer_exp, enerBuffer_exp) > 0) + IF(GT_16(st_fx->last_enerBuffer_exp, enerBuffer_exp)) { gain1_tmp = L_shr(gain1, sub(st_fx->last_enerBuffer_exp, enerBuffer_exp)); move32(); @@ -421,18 +419,18 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision */ test(); test(); test(); - IF ((sub(st_fx->clas_final_old_fx, HQ_CORE) == 0 || sub(st_fx->clas_final_old_fx, TCX_20_CORE) == 0) - && ((L_sub(st_fx->last_gain1, L_shr(gain1_tmp, 1)) > 0 && L_sub(st_fx->last_gain1, L_shl(gain1_tmp, 1)) < 0) - && (L_sub(st_fx->last_gain2, L_shr(gain2_tmp, 1)) > 0 && L_sub(st_fx->last_gain2, L_shl(gain2_tmp, 1)) < 0))) + IF ((EQ_16(st_fx->clas_final_old_fx, HQ_CORE)||EQ_16(st_fx->clas_final_old_fx,TCX_20_CORE)) + && ((GT_32(st_fx->last_gain1, L_shr(gain1_tmp, 1)) && LT_32(st_fx->last_gain1, L_shl(gain1_tmp, 1))) + && (GT_32(st_fx->last_gain2, L_shr(gain2_tmp, 1)) && LT_32(st_fx->last_gain2, L_shl(gain2_tmp, 1))))) { clas_final = st_fx->clas_final_old_fx; move16(); } - ELSE IF (sub(clas_sec, st_fx->clas_sec_old_fx) > 0 && sub(clas_sec, MDCT_CLASSIFER_THRESH_UP) > 0) /* Going up? */ + ELSE IF (GT_16(clas_sec, st_fx->clas_sec_old_fx)&>_16(clas_sec,MDCT_CLASSIFER_THRESH_UP)) /* Going up? */ { clas_final = HQ_CORE; /* Q0 */ move16(); } - ELSE IF (sub(clas_sec, MDCT_CLASSIFER_THRESH_DOWN) < 0)/* Going down */ + ELSE IF (LT_16(clas_sec, MDCT_CLASSIFER_THRESH_DOWN))/* Going down */ { clas_final = TCX_20_CORE; move16(); @@ -447,7 +445,7 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision */ test(); test(); /* Prevent the usage of MDCTA on noisy-speech or inactive */ - if ( sub(st_fx->mdct_sw_enable, MODE2) == 0 && (sub(st_fx->flag_noisy_speech_snr, 1) == 0 || vadflag == 0 ) && sub(clas_final, HQ_CORE) == 0 ) + if ( EQ_16(st_fx->mdct_sw_enable, MODE2)&&(EQ_16(st_fx->flag_noisy_speech_snr,1)||vadflag==0)&&EQ_16(clas_final,HQ_CORE)) { clas_final = TCX_20_CORE; move16(); diff --git a/lib_enc/mdct_selector.c b/lib_enc/mdct_selector.c index f30d5d3fcfa7a1563f12b150888424b61f52fbcd..17b78adc9c1d45514bc17eec19d05b43cbc0dd8c 100644 --- a/lib_enc/mdct_selector.c +++ b/lib_enc/mdct_selector.c @@ -1,12 +1,10 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include #include "options.h" #include "stl.h" -#include "wmc_auto.h" - #include "cnst_fx.h" #include "prot_fx.h" #include @@ -54,7 +52,7 @@ static Word16 get_sparseness( /* Returns sparseness measure (Q15) */ FOR (i=1; i 0) + if (GT_16(Bin_E[i], s_max(s_max(Bin_E[i-1], Bin_E[i+1]), thr))) { num_max = add(num_max, 1); } @@ -74,7 +72,7 @@ static Word16 get_mean_ener( /* Returns mean energy in dB (Q8) */ Word16 i, shift, frac_nrg, exp_nrg; shift = sub(14, norm_s(n)); - if (sub(shl(1, shift), n) < 0) shift = add(shift, 1); + if (LT_16(shl(1, shift), n))shift=add(shift,1); L_tmp = L_deposit_l(0); FOR (i=0; imdct_sw_enable, MODE1) == 0 || sub(st->mdct_sw_enable, MODE2) == 0) + IF (EQ_16(st->mdct_sw_enable, MODE1)||EQ_16(st->mdct_sw_enable,MODE2)) { Word16 hi_ener, frame_voicing, sparseness; Word16 peak_count; @@ -117,7 +115,7 @@ void MDCT_selector( sp_floor = shl(sp_floor, 1); /* convert to Q8 */ - IF (sub(st->bwidth_fx, NB) == 0) + IF (EQ_16(st->bwidth_fx, NB)) { lob_cldfb = 3200/400; move16(); @@ -126,7 +124,7 @@ void MDCT_selector( lob_fft = (L_FFT/2)/2; /* 3.2 KHz */ move16(); hib_fft = (40*(L_FFT/2))/64; /* 4.0 KHz */ move16(); } - ELSE IF (sub(st->bwidth_fx, WB) == 0) + ELSE IF (EQ_16(st->bwidth_fx, WB)) { lob_cldfb = 4800/400; move16(); @@ -141,7 +139,7 @@ void MDCT_selector( move16(); hib_cldfb = 16000/400; move16(); - if (sub(st->bwidth_fx, FB) == 0) + if (EQ_16(st->bwidth_fx, FB)) { hib_cldfb = 24000/400; move16(); @@ -154,7 +152,7 @@ void MDCT_selector( last_core = st->last_core_fx; move16(); test(); - if (sub(st->last_codec_mode, MODE1) == 0 && sub(last_core, TCX_20_CORE) == 0) + if (EQ_16(st->last_codec_mode, MODE1)&&EQ_16(last_core,TCX_20_CORE)) { last_core = HQ_CORE; move16(); @@ -170,7 +168,7 @@ void MDCT_selector( hi_ener = get_mean_ener(&enerBuffer[lob_cldfb], enerBuffer_exp, sub(hib_cldfb, lob_cldfb)); /* Hi band sparseness */ - IF (sub(st->bwidth_fx, SWB) >= 0) + IF (GE_16(st->bwidth_fx, SWB)) { /* For SWB, assume hi band sparseness based on 4.8 KHz-6.4 KHz band */ lob_fft = 3*L_FFT/2/4; /* 4.8 KHz */ move16(); @@ -180,7 +178,7 @@ void MDCT_selector( tmp = add(MDCT_SW_SIG_LINE_THR, shr(Etot, 1)); /* Q7 */ FOR (i=lob_fft; ilgBin_E_fx[i], tmp) >= 0) + if (GE_16(st->lgBin_E_fx[i], tmp)) { peak_count = add(peak_count, 1); } @@ -188,7 +186,7 @@ void MDCT_selector( hi_sparse = 0; move16(); - if (sub(peak_count, mult_r(sub(hib_fft, lob_fft), MDCT_SW_HI_SPARSE_THR)) <= 0) + if (LE_16(peak_count, mult_r(sub(hib_fft, lob_fft), MDCT_SW_HI_SPARSE_THR))) { hi_sparse = 1; move16(); @@ -196,7 +194,7 @@ void MDCT_selector( sparse = 0; move16(); - if (sub(peak_count, mult_r(sub(hib_fft, lob_fft), MDCT_SW_SPARSE_THR)) <= 0) + if (LE_16(peak_count, mult_r(sub(hib_fft, lob_fft), MDCT_SW_SPARSE_THR))) { sparse = 1; move16(); @@ -205,7 +203,7 @@ void MDCT_selector( /* Hysteresis */ test(); test(); - if (st->prev_hi_sparse > 0 && sparse > 0 && sub(s_min(s_min(voicing[0], voicing[1]), voicing[2]), MDCT_SW_1_VOICING_THR) >= 0) + if (st->prev_hi_sparse > 0 && sparse > 0 && GE_16(s_min(s_min(voicing[0], voicing[1]), voicing[2]), MDCT_SW_1_VOICING_THR)) { hi_sparse = 1; move16(); @@ -223,12 +221,12 @@ void MDCT_selector( test(); test(); test(); - switching_point = (sub(last_core, HQ_CORE) != 0 && sub(last_core, TCX_20_CORE) != 0) || /* previous core was non-MDCT */ - (sub(st->prev_hi_ener, MDCT_SW_HI_ENER_LO_THR) <= 0 || sub(hi_ener, MDCT_SW_HI_ENER_LO_THR) <= 0) || /* hi band is close to silent */ - (sub(last_core, HQ_CORE) == 0 && (sub(st->mdct_sw_enable, MODE1) == 0 || (hi_sparse > 0 && st->prev_hi_sparse >= 0 && sub(st->prev_hi_sparse, 1) <= 0))) || /* HQ_CORE and hi band became sparse */ - (sub(last_core, TCX_20_CORE) == 0 && (hi_sparse == 0 && st->prev_hi_sparse > 0)); /* TCX and hi band became dense */ + switching_point = (NE_16(last_core, HQ_CORE) && NE_16(last_core, TCX_20_CORE) ) || /* previous core was non-MDCT */ + (LE_16(st->prev_hi_ener, MDCT_SW_HI_ENER_LO_THR) || LE_16(hi_ener, MDCT_SW_HI_ENER_LO_THR) ) || /* hi band is close to silent */ + (EQ_16(last_core, HQ_CORE) && (EQ_16(st->mdct_sw_enable, MODE1) || (hi_sparse > 0 && st->prev_hi_sparse >= 0 && LE_16(st->prev_hi_sparse, 1) ))) || /* HQ_CORE and hi band became sparse */ + (EQ_16(last_core, TCX_20_CORE) && (hi_sparse == 0 && st->prev_hi_sparse > 0)); /* TCX and hi band became dense */ - IF (sub(st->mdct_sw_enable, MODE1) == 0) + IF (EQ_16(st->mdct_sw_enable, MODE1)) { sig_lo_level_thr = MDCT_SW_1_SIG_LO_LEVEL_THR; move16(); @@ -276,9 +274,9 @@ void MDCT_selector( test(); test(); test(); - prefer_tcx = (sub(sub(Etot, sp_floor), sig_hi_level_thr) >= 0) && /* noise floor is low */ - (sub(cor_map_sum, cor_thr) >= 0 || sub(frame_voicing, voicing_thr) >= 0 || sub(sparseness, sparseness_thr) >= 0) && /* strong tonal components */ - (sub(hi_ener, hi_ener_lo_thr) <= 0 || hi_sparse > 0); /* high freqs have low energy or are sparse */ + prefer_tcx = (GE_16(sub(Etot, sp_floor), sig_hi_level_thr)) && /* noise floor is low */ + (GE_16(cor_map_sum, cor_thr) || GE_16(frame_voicing, voicing_thr) || GE_16(sparseness, sparseness_thr) ) && /* strong tonal components */ + (LE_16(hi_ener, hi_ener_lo_thr) || hi_sparse > 0); /* high freqs have low energy or are sparse */ test(); test(); @@ -286,13 +284,13 @@ void MDCT_selector( test(); test(); test(); - prefer_hq_core = (sub(sub(Etot, sp_floor), sig_lo_level_thr) < 0) || /* noise floor is very high */ - (sub(cor_map_sum, cor_thr2) < 0 && sub(frame_voicing, voicing_thr2) < 0 && sub(sparseness, sparseness_thr2) < 0) || /* too weak tonal components */ - (sub(st->mdct_sw_enable, MODE1) == 0 && prefer_tcx == 0 && sub(st->transientDetection.transientDetector.bIsAttackPresent, 1) == 0); + prefer_hq_core = (LT_16(sub(Etot, sp_floor), sig_lo_level_thr) ) || /* noise floor is very high */ + (LT_16(cor_map_sum, cor_thr2) && LT_16(frame_voicing, voicing_thr2) && LT_16(sparseness, sparseness_thr2) ) || /* too weak tonal components */ + (EQ_16(st->mdct_sw_enable, MODE1) && prefer_tcx == 0 && EQ_16(st->transientDetection.transientDetector.bIsAttackPresent, 1) ); /* Prefer HQ_CORE on transients */ test(); - IF ( sub(st->mdct_sw_enable, MODE2) == 0 && sub(st->transientDetection.transientDetector.bIsAttackPresent, 1) == 0 ) + IF ( EQ_16(st->mdct_sw_enable, MODE2)&&EQ_16(st->transientDetection.transientDetector.bIsAttackPresent,1)) { prefer_tcx = 0; move16(); @@ -316,7 +314,7 @@ void MDCT_selector( move16(); } } - ELSE IF (sub(last_core, HQ_CORE) == 0 || sub(last_core, TCX_20_CORE) == 0) + ELSE IF (EQ_16(last_core, HQ_CORE)||EQ_16(last_core,TCX_20_CORE)) { st->core_fx = last_core; move16(); @@ -326,7 +324,7 @@ void MDCT_selector( test(); test(); /* Prevent the usage of HQ_CORE on noisy-speech or inactive */ - IF (sub(st->mdct_sw_enable, MODE2) == 0 && sub(st->core_fx, HQ_CORE) == 0 && (sub(st->flag_noisy_speech_snr, 1) == 0 || vadflag==0)) + IF (EQ_16(st->mdct_sw_enable, MODE2)&&EQ_16(st->core_fx,HQ_CORE)&&(EQ_16(st->flag_noisy_speech_snr,1)||vadflag==0)) { st->core_fx = TCX_20_CORE; move16(); diff --git a/lib_enc/mslvq_enc_fx.c b/lib_enc/mslvq_enc_fx.c index df174ed67b6875c4f6a6ee89041220e82406bda5..ca736f34e99ed0f7b0945e5ef1e1e610344ea9b4 100644 --- a/lib_enc/mslvq_enc_fx.c +++ b/lib_enc/mslvq_enc_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "prot_fx.h" #include "rom_com_fx.h" #include "cnst_fx.h" #include "stl.h" -#include "wmc_auto.h" - /*-----------------------------------------------------------------* @@ -293,7 +291,7 @@ static Word32 calculate_min_dist_fx( FOR(l=0; l0) + if (GT_16(nb, max_nb)) { max_nb = nb; move16(); @@ -303,7 +301,7 @@ static Word32 calculate_min_dist_fx( FOR(l=0; l0) + if (GT_16(nb, max_nb1)) { max_nb1 = nb; move16(); @@ -360,13 +358,13 @@ static Word32 calculate_min_dist_fx( move16(); } } - IF (sub(l, LATTICE_DIM-1)==0) + IF (EQ_16(l, LATTICE_DIM-1)) { p = *pl_crt; /* if it went up to 7th position */ IF ( pl_par_fx[j] ) { - IF ( sub(sig,pl_par_fx[j]) != 0 ) + IF ( NE_16(sig,pl_par_fx[j])) { sum1[j] = L_msu(sum1[j], wx[l], p); /* Q(7-nb) + Q1 + Q1 = Q(9-nb) //Q-7 + Q1 + Q1 = Q-5 */ p1 = i_mult2(p,p); /*Q2 */ @@ -391,7 +389,7 @@ static Word32 calculate_min_dist_fx( } /* distance between the potential codevector and the input calculated in ordered space */ tmp_dist = L_sub(Mult_32_16(sum2[j],s2), Mult_32_16(L_shl(sum1[j],3),s)); /* Q(13-nb) + Q10 -Q15= Q(8-nb) Q(9-nb) + Q3+Q11 -Q15 = Q(8-nb) */ - IF ( L_sub(tmp_dist,min_dist) < 0 ) + IF ( LT_32(tmp_dist,min_dist)) { min_dist = L_add(tmp_dist, 0); best_scale = 0; @@ -405,7 +403,7 @@ static Word32 calculate_min_dist_fx( { s = scale[k]; move16(); /*Q11 */ - IF (sub(16, norm_l(s)) <= 0) + IF (LE_16(16, norm_l(s))) { s2 = extract_h(L_shl(L_mult(s,s),1)); /*Q11+Q11+Q1+Q1-Q16 = Q7 */ low_prec = 1; @@ -417,7 +415,7 @@ static Word32 calculate_min_dist_fx( FOR(j=0; j 0 ) + IF ( GT_16(best_scale,-1) ) { FOR(j=0; j0 ) + IF ( GT_16(idx_scale[0],-1) ) { index1 = L_add(encode_comb_fx(quant, idx_lead[0]), L_add(table_no_cv_fx[idx_lead[0]] , p_offset_scale1[i_mult2(mode,len_offset) +idx_scale[0]])); } @@ -643,26 +644,21 @@ void index_lvq_fx ( /* for second subvector */ index2 = L_deposit_l(0); - IF ( add(idx_scale[1], 1) >0 ) + IF ( GT_16(idx_scale[1], -1) ) { index2 = L_add(encode_comb_fx(&quant[LATTICE_DIM], idx_lead[1]), L_add(table_no_cv_fx[idx_lead[1]], p_offset_scale2[i_mult2(mode,len_offset)+idx_scale[1]])); } - - multiply32_32_64_fx(index1, p_offset_scale2[mode*len_offset+p_no_scales[mode*2+1]], idx); - - tmp = L_add(idx[0], index2); - idx[1] = L_add((tmp >> 30), idx[1]); - idx[0] = tmp; - move32(); + idx64 = W_mult0_32_32(index1, p_offset_scale2[mode*len_offset+p_no_scales[mode*2+1]]); + index2_64 = W_deposit32_l (index2); + idx64 = W_add_nosat(idx64, index2_64); /* convert to 3 short */ - index[0] = ((idx[0])&(0x7fff)); + index[0] = ((idx64)&(0x7fff)); move16(); - index[1] = ((idx[0])>>15)&(0x7fff); + index[1] = (idx64>>15)&(0x7fff); move16(); - index[2] = (idx[1])&(0x7fff); + index[2] = (idx64>>30)&(0x7fff); move16(); - return; } @@ -710,7 +706,7 @@ static Word16 index_leaders_fx( /* o : index */ no_vals_loc = no_vals_fx[idx_lead]; move16(); - IF ( sub(no_vals_loc, 1) == 0 ) + IF ( EQ_16(no_vals_loc, 1)) { return 0; } @@ -727,7 +723,7 @@ static Word16 index_leaders_fx( /* o : index */ index = c2idx_fx(LATTICE_DIM, p, nr); move16(); - IF ( sub(no_vals_loc, 2) == 0 ) + IF ( EQ_16(no_vals_loc, 2)) { return index; } @@ -742,7 +738,7 @@ static Word16 index_leaders_fx( /* o : index */ move16(); index = add(index,c2idx_fx( dim_loc, p, nr )); - IF ( sub(no_vals_loc, 3) == 0 ) + IF ( EQ_16(no_vals_loc, 3)) { return index; } @@ -780,7 +776,7 @@ Word16 find_pos_fx( /* o : number of positions */ /* how many (j) and which (p) positions are in the relation pred(arg,c[i]) */ FOR( i=0; i 0/*4.5f*/) + ELSE IF (GT_16(sub(mean_dyn , *st_last_sw_dyn),576)/*4.5f*/) { *cor_strong_limit = 1; move16(); } test(); - if( L_sub(total_brate,ACELP_9k60) < 0|| L_sub(total_brate,ACELP_16k40) > 0 ) + if( LT_32(total_brate,ACELP_9k60)||GT_32(total_brate,ACELP_16k40)) { *cor_strong_limit = 1; move16(); @@ -205,7 +203,7 @@ Word16 multi_harm_fx( /* o : frame multi-harmonicity (1-harmonic, 0-not) FOR (i = add(stemp,1); i <= ind_mins[N_mins]; i++) { - IF (sub(i,ind_mins[k]) == 0) + IF (EQ_16(i,ind_mins[k])) { /* include the last peak point (new minimum) to the corr. sum */ Lcory2 = L_mac(Lcory2, old_S[i], old_S[i]); @@ -303,7 +301,7 @@ Word16 multi_harm_fx( /* o : frame multi-harmonicity (1-harmonic, 0-not) /* cor_map_LT_sum += *pt1 */ Lcor_map_LT_sum = L_add(Lcor_map_LT_sum, *pt1); /* cor_map_LT_sum in Q15; max value is 128) */ - if(sub(*pt1, 31130) > 0/*0.95f*/) + if(GT_16(*pt1, 31130)/*0.95f*/) { cor_strong = 1; move16(); @@ -313,7 +311,7 @@ Word16 multi_harm_fx( /* o : frame multi-harmonicity (1-harmonic, 0-not) pt2++; } - IF ( sub(bwidth,NB) == 0 ) + IF ( EQ_16(bwidth,NB)) { /* cor_map_LT_sum *= 1.53f; */ /* tmp2 *= 1.53f; */ @@ -338,7 +336,7 @@ Word16 multi_harm_fx( /* o : frame multi-harmonicity (1-harmonic, 0-not) *------------------------------------------------------------------*/ stemp = add(*multi_harm_limit, THR_CORR_STEP_FX); - if (L_sub(Lcor_map_LT_sum, THR_CORR_FX) > 0) /* Q15 */ + if (GT_32(Lcor_map_LT_sum, THR_CORR_FX)) /* Q15 */ { /* *multi_harm_limit -= THR_CORR_STEP_FX */ stemp = sub(*multi_harm_limit, THR_CORR_STEP_FX); diff --git a/lib_enc/nelp_enc_fx.c b/lib_enc/nelp_enc_fx.c index 997efbb98860a9f526fcf67e731419f7408aba10..67cc77d13f029596be2f319a61841dbaeb29545f 100644 --- a/lib_enc/nelp_enc_fx.c +++ b/lib_enc/nelp_enc_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "control.h" @@ -10,8 +10,6 @@ #include "stl.h" -#include "wmc_auto.h" - /*===================================================================*/ /* FUNCTION : quantize_uvg_fx() */ @@ -46,7 +44,7 @@ void quantize_uvg_fx(Word16 *G, Word16 *iG1, Word16 *iG2, Word16 *quantG, Word16 const Word16 (*UVG2CB1_fx)[5]=NULL; const Word16 (*UVG2CB2_fx)[5]=NULL; test(); - IF( sub(bwidth_fx,NB)== 0 ) + IF( EQ_16(bwidth_fx,NB)) { UVG1CB_fx = UVG1CB_NB_FX; move16();/*Q13 */ @@ -55,7 +53,7 @@ void quantize_uvg_fx(Word16 *G, Word16 *iG1, Word16 *iG2, Word16 *quantG, Word16 UVG2CB2_fx = UVG2CB2_NB_FX; move16();/*Q12 */ } - ELSE IF( sub(bwidth_fx,WB) == 0 || sub(bwidth_fx,SWB) == 0) + ELSE IF( EQ_16(bwidth_fx,WB)||EQ_16(bwidth_fx,SWB)) { UVG1CB_fx = UVG1CB_WB_FX; move16();/*Q13 */ @@ -111,7 +109,7 @@ void quantize_uvg_fx(Word16 *G, Word16 *iG1, Word16 *iG2, Word16 *quantG, Word16 Lacc = L_mac0(Lacc,L16,L16); /*Q24 */ Lacc = L_mac0(Lacc,L16_1,L16_1);/*Q24 */ - IF (L_sub(Lacc,mmse)<0) + IF (LT_32(Lacc,mmse)) { *iG1 = i; move16(); @@ -175,7 +173,7 @@ void quantize_uvg_fx(Word16 *G, Word16 *iG1, Word16 *iG2, Word16 *quantG, Word16 } } - IF (L_sub(Lacc,mmse)<0) + IF (LT_32(Lacc,mmse)) { mmse = Lacc; iG2[i] = j; @@ -304,7 +302,7 @@ void nelp_encoder_fx( rf_flag = st_fx->rf_mode; - if (sub(st_fx->last_nelp_mode_fx,1) == 0 && sub(st_fx->bwidth_fx, st_fx->last_bwidth_fx) != 0) + if (EQ_16(st_fx->last_nelp_mode_fx,1)&&NE_16(st_fx->bwidth_fx,st_fx->last_bwidth_fx)) { st_fx->last_nelp_mode_fx = 0; } @@ -312,7 +310,7 @@ void nelp_encoder_fx( qIn = *qIn1; move16(); test(); - IF (sub(st_fx->bwidth_fx,NB) == 0) + IF (EQ_16(st_fx->bwidth_fx,NB)) { IF (st_fx->last_nelp_mode_fx != 1) { @@ -323,7 +321,7 @@ void nelp_encoder_fx( move16(); } } - ELSE IF (sub(st_fx->bwidth_fx,WB) == 0 || sub(st_fx->bwidth_fx,SWB) == 0) + ELSE IF (EQ_16(st_fx->bwidth_fx,WB)||EQ_16(st_fx->bwidth_fx,SWB)) { IF (st_fx->last_nelp_mode_fx != 1) { @@ -336,7 +334,7 @@ void nelp_encoder_fx( IF (st_fx->last_nelp_mode_fx != 1) { test(); - IF (st_fx->bwidth_fx == WB || sub(st_fx->bwidth_fx,SWB) == 0) + IF (st_fx->bwidth_fx == WB || EQ_16(st_fx->bwidth_fx,SWB)) { set16_fx(st_fx->shape1_filt_mem_fx, 0, 10); set16_fx(st_fx->shape2_filt_mem_fx, 0, 10); @@ -354,7 +352,7 @@ void nelp_encoder_fx( /* Start Unvoiced/NELP Processing */ test(); - IF ( sub(st_fx->bwidth_fx,WB) == 0 || sub(st_fx->bwidth_fx,SWB) == 0) + IF ( EQ_16(st_fx->bwidth_fx,WB)||EQ_16(st_fx->bwidth_fx,SWB)) { qE1 = qIn; move16(); @@ -452,7 +450,7 @@ void nelp_encoder_fx( Gains_fx[i] = round_fx(Ltemp); - IF ( sub(reduce_gains,1) == 0) + IF ( EQ_16(reduce_gains,1)) { FOR (i=0; i<10; i++) { @@ -599,7 +597,7 @@ void nelp_encoder_fx( } l_nelp_gain_mem = L_deposit_l(st_fx->nelp_gain_mem_fx); - IF(sub(qNelpGain,qGain) != 0) + IF(NE_16(qNelpGain,qGain)) { l_nelp_gain_mem = L_shl(l_nelp_gain_mem, sub(qGain, qNelpGain)); } @@ -626,7 +624,7 @@ void nelp_encoder_fx( quantize_uvg_fx(Gains_fx, &iG1_fx, iG2_fx, Gains_fx, st_fx->bwidth_fx); - IF( sub(rf_flag,1) == 0 ) + IF( EQ_16(rf_flag,1)) { st_fx->rf_indx_nelp_iG1[0] = iG1_fx; st_fx->rf_indx_nelp_iG2[0][0] = iG2_fx[0]; @@ -640,7 +638,7 @@ void nelp_encoder_fx( } test(); - IF (sub(st_fx->bwidth_fx,WB) == 0 || sub(st_fx->bwidth_fx,SWB) == 0) + IF (EQ_16(st_fx->bwidth_fx,WB)||EQ_16(st_fx->bwidth_fx,SWB)) { gain_fac_fx = 19005; move16();/* 1.16f in Q14 */ @@ -657,14 +655,14 @@ void nelp_encoder_fx( generate_nelp_excitation_fx(&(st_fx->nelp_enc_seed_fx), Gains_fx, ptr_fx, gain_fac_fx); test(); - IF (sub(st_fx->bwidth_fx,WB) == 0 || sub(st_fx->bwidth_fx,SWB) == 0) + IF (EQ_16(st_fx->bwidth_fx,WB)||EQ_16(st_fx->bwidth_fx,SWB)) { BP1_ORDER = 4; Scale_sig(st_fx->bp1_filt_mem_wb_fx, BP1_ORDER*2, qGain-st_fx->qprevGain_fx);/*qf-qAdj */ pz_filter_sp_fx(bp1_num_coef_wb_fx,bp1_den_coef_wb_fx, ptr_fx, ptr_tmp_fx, st_fx->bp1_filt_mem_wb_fx, BP1_ORDER, BP1_ORDER, L_FRAME, 2); Copy(ptr_tmp_fx,ptr_fx,L_FRAME); } - ELSE IF (sub(st_fx->bwidth_fx,NB) == 0) + ELSE IF (EQ_16(st_fx->bwidth_fx,NB)) { BP1_ORDER = 7; move16(); @@ -684,7 +682,7 @@ void nelp_encoder_fx( qE3= 2*qGain+1; move16(); test(); - IF (st_fx->bwidth_fx == WB|| sub(st_fx->bwidth_fx,SWB) == 0) + IF (st_fx->bwidth_fx == WB|| EQ_16(st_fx->bwidth_fx,SWB)) { Scale_sig(st_fx->shape1_filt_mem_fx, 10, (qGain-st_fx->qprevGain_fx)); pz_filter_sp_fx(shape1_num_coef_fx,shape1_den_coef_fx, ptr_fx, ptr_tmp_fx, st_fx->shape1_filt_mem_fx,10,10, L_FRAME, 1);/*1 = (16-qformat of shape1 cofficient) */ @@ -842,12 +840,12 @@ void nelp_encoder_fx( fid = 0; move16(); - IF (L_sub(RL_fx, -12288) < 0) /* -3 in Q12 */ + IF (LT_32(RL_fx, -12288)) /* -3 in Q12 */ { fid = 1; move16(); } - ELSE IF (L_sub(RH_fx, -12288) < 0) /* -3 in Q12 */ + ELSE IF (LT_32(RH_fx, -12288)) /* -3 in Q12 */ { fid = 2; move16(); @@ -948,7 +946,7 @@ void nelp_encoder_fx( move16(); } - IF( sub(rf_flag,1) == 0 ) + IF( EQ_16(rf_flag,1)) { st_fx->rf_indx_nelp_fid[0] = fid; move16(); diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c index 23e2bbe545170e0ecd0a01ff359ce260b2c8941c..9bbe73f5290e44fa3f5ed6899438d35cc3c759aa 100644 --- a/lib_enc/nois_est_fx.c +++ b/lib_enc/nois_est_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -7,8 +7,6 @@ #include "cnst_fx.h" #include "prot_fx.h" #include "stl.h" -#include "wmc_auto.h" - #include "basop_util.h" /*-----------------------------------------------------------------* @@ -237,7 +235,7 @@ void noise_est_pre_fx( { Word16 tmp; - IF (sub(ini_frame_fx, 1) <= 0) + IF (LE_16(ini_frame_fx, 1)) { *Etot_h = Etot; move16(); @@ -269,11 +267,11 @@ void noise_est_pre_fx( /* Could even be higher but it also delays first entry to DTX */ - IF ( sub(harm_cor_cnt,HE_LT_CNT_PRE_FX) > 0 ) + IF ( GT_16(harm_cor_cnt,HE_LT_CNT_PRE_FX)) { test(); - IF( ( sub( ini_frame_fx , s_min(HE_LT_CNT_INIT_FX ,MAX_FRAME_COUNTER-1) ) < 0 ) - && (sub(sub(*Etot_h, *Etot_lp),(Word16)3*256) < 0 ) /* 3.0 Q8 */ + IF( ( LT_16( ini_frame_fx , s_min(HE_LT_CNT_INIT_FX ,MAX_FRAME_COUNTER-1) )) + && (LT_16(sub(*Etot_h, *Etot_lp),(Word16)3*256) ) /* 3.0 Q8 */ ) { /* *Etot_l += min(2,(*Etot_last-*Etot_l)*0.1f); */ @@ -285,15 +283,15 @@ void noise_est_pre_fx( /* Avoids large steps in short active segments */ test(); - IF ( ( sub(sub(*Etot_last, *Etot_l), HE_LT_THR2_FX ) > 0 ) /* 30.0f*Q8 */ - && (sub(harm_cor_cnt,HE_LT_CNT_PRE_SHORT_FX)>0) + IF ( ( GT_16(sub(*Etot_last, *Etot_l), HE_LT_THR2_FX )) /* 30.0f*Q8 */ + && (GT_16(harm_cor_cnt,HE_LT_CNT_PRE_SHORT_FX)) ) { /* *Etot_l += (*Etot_last-*Etot_l)*0.02f; */ *Etot_l = add(*Etot_l, mult_r(sub(*Etot_last, *Etot_l), 655)); move16();/* 0.02 = 655 Q8*/ } - ELSE IF (sub(sub(*Etot_last, *Etot_l), HE_LT_THR1_FX ) > 0) /* 10.0 in Q8*/ + ELSE IF (GT_16(sub(*Etot_last, *Etot_l), HE_LT_THR1_FX )) /* 10.0 in Q8*/ { *Etot_l = add(*Etot_l, 20); move16();/* 0.08 is 20 in Q8*/ @@ -303,7 +301,7 @@ void noise_est_pre_fx( *Etot_l = s_min(*Etot_l, Etot); - IF ( sub(ini_frame_fx,100)<0 && sub(*Etot_l,*Etot_l_lp)<0 ) + IF ( LT_16(ini_frame_fx,100)&<_16(*Etot_l,*Etot_l_lp)) { /**Etot_l_lp = 0.1f * *Etot_l + (1.0f - 0.1) * *Etot_l_lp; */ *Etot_l_lp = mac_r(L_mult(3277, *Etot_l), 29491, *Etot_l_lp); @@ -315,11 +313,11 @@ void noise_est_pre_fx( test(); test(); test(); - IF ( ( (sub(harm_cor_cnt, HE_LT_CNT_FX) > 0 ) - && (sub(sub(*Etot_last, *Etot_l), HE_LT_THR2_FX ) > 0 ) + IF ( ( (GT_16(harm_cor_cnt, HE_LT_CNT_FX)) + && (GT_16(sub(*Etot_last, *Etot_l), HE_LT_THR2_FX ) ) ) - || ( (sub(harm_cor_cnt, HE_LT_CNT_FX) > 0) && (sub(ini_frame_fx, HE_LT_CNT_INIT_FX) < 0) ) - || (sub(sub(*Etot_l_lp, *Etot_l), HE_LT_THR2_FX ) > 0 ) + || ( (sub(harm_cor_cnt, HE_LT_CNT_FX) > 0 ) && (LT_16(ini_frame_fx, HE_LT_CNT_INIT_FX) ) ) + || (GT_16(sub(*Etot_l_lp, *Etot_l), HE_LT_THR2_FX ) ) ) { /**Etot_l_lp = 0.03f * *Etot_l + (1.0f - 0.03f) * *Etot_l_lp; */ @@ -574,7 +572,7 @@ void noise_est_fx( { st_fx->ener_RAT_fx = 32767; move16(); /*Q15*/ - if(sub(wtmp1, wtmp ) >= 0 ) + if(GE_16(wtmp1, wtmp )) { st_fx->ener_RAT_fx = div_s(wtmp, wtmp1); /*Q15*//* wtmp1 gte than wtmp */ } @@ -588,7 +586,7 @@ void noise_est_fx( * order" spectral envelope => the epsP ratio is much less effective. *-----------------------------------------------------------------*/ - IF (sub(vad_bwidth_fx,NB) != 0) /* WB input */ + IF (NE_16(vad_bwidth_fx,NB)) /* WB input */ { th_eps = TH_EPS16_FX; move16();/*Q11*/ @@ -629,7 +627,7 @@ void noise_est_fx( tmp_pc = pc; move16(); - if (sub(wtmp, cor_min) < 0) + if (LT_16(wtmp, cor_min)) { tmp_pc = TH_PC_FX; move16(); /* low correlation -> probably inactive signal */ @@ -697,7 +695,7 @@ void noise_est_fx( /* THR_SPDIV_FX = 5 , 1/5 Q15 = 6554 */ spec_div = 0; move16(); - if (L_sub(Mult_32_16(Lsum_num, 6554), Lsum_den) > 0) /* Qx+Q15+1-16 ==> Qx */ + if (GT_32(Mult_32_16(Lsum_num, 6554), Lsum_den)) /* Qx+Q15+1-16 ==> Qx */ { spec_div = 1; move16(); @@ -757,7 +755,7 @@ void noise_est_fx( nchar_thr = THR_NCHAR_WB_FX; move16(); /* 1.0 Q11 */ - if( sub(vad_bwidth_fx,NB) == 0 ) + if( EQ_16(vad_bwidth_fx,NB)) { nchar_thr = THR_NCHAR_NB_FX; move16(); /* 1.0 Q11 */ @@ -765,7 +763,7 @@ void noise_est_fx( noise_char = 0; move16(); - if (sub(st_fx->noise_char_fx, nchar_thr) > 0) + if (GT_16(st_fx->noise_char_fx, nchar_thr)) { noise_char = 1; move16(); @@ -827,7 +825,7 @@ void noise_est_fx( L_tmp_enr = L_add(enr[i] , Ltmp ); /* enr scale dynamic */ L_tmp_ave_enr = L_add(st_fx->ave_enr_fx[i], Ltmp); /* ave__enr scale dynamic */ - IF (L_sub(non_sta, th_sta) <= 0) /* Just to limit the saturation */ + IF (LE_32(non_sta, th_sta)) /* Just to limit the saturation */ { /* if( enr[i] > st_ave_enr2[i] ) */ /* non_sta2 = non_sta2 * ((enr[i]+1) / (st_ave_enr2[i]+1)) */ @@ -868,7 +866,7 @@ void noise_est_fx( /*L_tmp_enr = L_add(enr[i] , Ltmp );*/ /* enr scale dynamic , done above */ L_tmp_ave_enr2 = L_add(st_fx->ave_enr2_fx[i], Ltmp); /* ave__enr scale dynamic */ - IF (L_sub(Lnon_sta2, th_sta ) <= 0) /* Just to limit the saturation */ + IF (LE_32(Lnon_sta2, th_sta )) /* Just to limit the saturation */ { Lnum = L_max(L_tmp_enr, L_tmp_ave_enr2 ); Lden = L_min(L_tmp_enr, L_tmp_ave_enr2 ); @@ -892,7 +890,7 @@ void noise_est_fx( /* calculation of non-stationarity measure for speech/music classification */ test(); - IF ( sub(i,START_BAND_SPMUS) >= 0 && sub(i,NB_BANDS_SPMUS+START_BAND_SPMUS) < 0 ) + IF ( GE_16(i,START_BAND_SPMUS)&<_16(i,NB_BANDS_SPMUS+START_BAND_SPMUS)) { /* log_enr = (float)ln_fx(enr[i]); */ log_enr16 = noise_est_ln_q8_fx( enr[i], 0 ,tmp_Q); @@ -906,7 +904,7 @@ void noise_est_fx( tmp_enr = noise_est_ln_q8_fx( enr[i], 1 , tmp_Q); /* 1.0f added */ tmp_floor = LN_E_MIN_PLUS_ONE_FX ; move16(); /* non dynamic init constant in Q8 */ - IF ( sub(st_fx->ini_frame_fx, 100 ) >= 0 ) + IF ( GE_16(st_fx->ini_frame_fx, 100 )) { tmp_floor = noise_est_ln_q8_fx( st_fx->bckr_fx[i], 1, tmp_Q ); } @@ -915,7 +913,7 @@ void noise_est_fx( } /* end of band loop FOR( i = st_fx->min_band_fx; i <= st_fx->max_band_fx; i++ ) */ - IF (sub(Etot,-1280) < 0 ) + IF (LT_16(Etot,-1280)) { non_sta = L_deposit_l(1024); /* 1.0 in Q10 */ Lnon_sta2 = L_deposit_l(1024); /* 1.0 in Q10 */ @@ -958,23 +956,23 @@ void noise_est_fx( test(); test(); *st_harm_cor_cnt = add(*st_harm_cor_cnt , 1); - if( (Etot > 0) && ( (*loc_harm > 0 ) || (sub(round_fx(Ltmp), COR_MAX_NNE_FX ) > 0) )) + if( (Etot > 0) && ( (*loc_harm > 0 ) || (GT_16(round_fx(Ltmp), COR_MAX_NNE_FX )))) { *st_harm_cor_cnt = 0; move16(); } - IF( (sub(*st_harm_cor_cnt,1) > 0 ) &&( ( sub(Etot,3840) < 0 ) || /* 15 in Q8 */ - ( sub(st_fx->ini_frame_fx,10) > 0 && - sub(sub(Etot,st_fx->Etot_lp_fx),1792)>0 )) /* 7 in Q8 */ + IF( (GT_16(*st_harm_cor_cnt,1))&&((LT_16(Etot,3840))||/* 15 in Q8 */ + ( GT_16(st_fx->ini_frame_fx,10) && + GT_16(sub(Etot,st_fx->Etot_lp_fx),1792) )) /* 7 in Q8 */ ) { *st_harm_cor_cnt = 1; } - if ( sub(*st_harm_cor_cnt,1) > 0 && - sub(Etot,7680) > 0 && /* 30.0f in Q8 */ - sub(st_E_var_est_fx,32 )>0 /* 8.0f in Q2 */ + if ( GT_16(*st_harm_cor_cnt,1)&& + GT_16(Etot,7680) && /* 30.0f in Q8 */ + GT_16(st_E_var_est_fx,32 ) /* 8.0f in Q2 */ ) { @@ -987,7 +985,7 @@ void noise_est_fx( * Energy based pause length counter *-----------------------------------------------------------------*/ test(); - IF( (*bg_cnt >= 0) && (sub(sub(Etot , Etot_l_lp),1280) > 0/*5.0 in Q8*/)) + IF( (*bg_cnt >= 0) && (GT_16(sub(Etot , Etot_l_lp),1280)/*5.0 in Q8*/)) { /* Possible speech burst */ *bg_cnt = -1; @@ -996,7 +994,7 @@ void noise_est_fx( ELSE { test(); - if( sub(*bg_cnt,-1) == 0 && ( sub(sub(Etot , Etot_l_lp),1280) < 0 )/*5 in Q8*/ ) + if( EQ_16(*bg_cnt,-1)&&(LT_16(sub(Etot,Etot_l_lp),1280))/*5 in Q8*/) { /* Possible start of speech pause */ *bg_cnt = 0; @@ -1016,9 +1014,9 @@ void noise_est_fx( /*epsP_0_2 = max(0 , min(8, epsP[0] / epsP[2])); */ Ltmp = eps_quota_fx(epsP_h[0], epsP_l[0], epsP_h[2], epsP_l[2] , 12 ); /* Word32 Q12 */ - BASOP_SATURATE_WARNING_OFF; /* may saturate*/ + BASOP_SATURATE_WARNING_OFF /* may saturate*/ epsP_0_2 = round_fx(L_shl(Ltmp,16)); /* Q12+16 -16 -> Q12 , NB saturation in Q12 sets max value to 7,999 */ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON epsP_0_2 = s_max(0, epsP_0_2); /* min value is 0 , Q12 */ @@ -1038,7 +1036,7 @@ void noise_est_fx( } */ alpha = 6554; move16();/* 0.2 Q15 */ - if (sub(epsP_0_2_ad, st_fx->epsP_0_2_ad_lp_fx) < 0 ) + if (LT_16(epsP_0_2_ad, st_fx->epsP_0_2_ad_lp_fx)) { alpha = shr(alpha,1); /* 0.1 Q15 */ } @@ -1055,10 +1053,10 @@ void noise_est_fx( /* epsP_2_16 = max(0 , min(8, epsP[2] / epsP[16])); */ Ltmp = eps_quota_fx(epsP_h[2], epsP_l[2], epsP_h[16], epsP_l[16] , 12 ); /* Word32 Q12 */ - BASOP_SATURATE_WARNING_OFF; /* may saturate*/ + BASOP_SATURATE_WARNING_OFF /* may saturate*/ epsP_2_16 = round_fx(L_shl(Ltmp,16)); /* Q12+16 -16 -> Q12 , NB saturation in Q12 sets max value to 7,999 */ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON epsP_2_16 = s_max(0, epsP_2_16); /* min value is 0 , Q12 */ @@ -1073,7 +1071,7 @@ void noise_est_fx( alpha = 983 ; move16();/* 0.03 Q15 */ - if (sub(epsP_2_16 , st_fx->epsP_2_16_lp_fx) > 0 ) + if (GT_16(epsP_2_16 , st_fx->epsP_2_16_lp_fx)) { alpha = 6554; move16();/* 0.2 Q15 */ @@ -1092,7 +1090,7 @@ void noise_est_fx( }*/ alpha = 1638; move16();/* 0.05 Q15 */ - if (sub(epsP_2_16_dlp , st_fx->epsP_2_16_dlp_lp2_fx) < 0 ) + if (LT_16(epsP_2_16_dlp , st_fx->epsP_2_16_dlp_lp2_fx)) { alpha = 655; move16();/* 0.02 Q15 */ @@ -1110,7 +1108,7 @@ void noise_est_fx( /* st->lt_tn_track = 0.03f* (Etot - st->totalNoise < 10) + 0.97f*st->lt_tn_track; */ tmp2 = 0; move16(); - if( sub(tmp, 2560 ) < 0 ) /*10 in Q8 */ + if( LT_16(tmp, 2560 )) /*10 in Q8 */ { tmp2=32767; move16(); @@ -1149,7 +1147,7 @@ void noise_est_fx( tmp = 0; move16(); move16(); - if( sub( st_fx->lt_tn_track_fx , 1638 ) < 0 ) /* 0.05 in Q15*/ + if( LT_16( st_fx->lt_tn_track_fx , 1638 )) /* 0.05 in Q15*/ { tmp = add(st_fx->low_tn_track_cnt_fx, 1); } @@ -1166,7 +1164,7 @@ void noise_est_fx( Ltmp = L_mult(M_GAMMA_FX, st_fx->act_pred_fx); /*Q15*Q15+1 --> Q31 , 32440= .99 Q15 */ tmp = round_fx(Ltmp); /* Q15 */ test(); - if ( ( L_sub (non_sta, th_sta) > 0) /* float th_sta NB 5e10 , WB 3.5e10*/ + if ( ( GT_32(non_sta, th_sta)) /* float th_sta NB 5e10 , WB 3.5e10*/ || (*loc_harm > 0) ) { @@ -1223,14 +1221,14 @@ void noise_est_fx( test(); test(); - if( ( ( sub(*st_harm_cor_cnt, (3*HC_CNT_SLOW_FX) ) < 0 ) - && ( ( L_sub(non_sta, th_sta) > 0) || (sub(tmp_pc, TH_PC_FX) < 0) || ( noise_char > 0) ) ) + if( ( ( LT_16(*st_harm_cor_cnt, (3*HC_CNT_SLOW_FX) )) + && ( ( GT_32(non_sta, th_sta) ) || (LT_16(tmp_pc, TH_PC_FX) ) || ( GT_16(noise_char ,0)) ) ) || - ( (sub(st_fx->ini_frame_fx, HE_LT_CNT_INIT_FX ) > 0 ) && ( sub(sub(Etot, Etot_l_lp), 2560) > 0 ) ) || - ( sub(cor_tmp, cor_max) > 0 ) || /* Q15 */ - ( L_sub(LepsP, th_eps) > 0 ) || /* Q11 */ - ( *loc_harm > 0 ) || - ((sub(st_fx->act_pred_fx, 26214) > 0) && (L_sub(Lnon_sta2, th_sta) > 0) ) /*act_pred in Q15 , th_sta in Q10 */ + ( (GT_16(st_fx->ini_frame_fx, HE_LT_CNT_INIT_FX ) ) && ( GT_16(sub(Etot, Etot_l_lp), 2560) ) ) || + ( GT_16(cor_tmp, cor_max) ) || /* Q15 */ + ( GT_32(LepsP, th_eps) ) || /* Q11 */ + ( GT_16(*loc_harm,0)) || + ((GT_16(st_fx->act_pred_fx, 26214) ) && (GT_32(Lnon_sta2, th_sta) ) ) /*act_pred in Q15 , th_sta in Q10 */ ) { vad_2nd_stage_fx = 1; @@ -1277,7 +1275,7 @@ void noise_est_fx( /* Etot_l_lp_thr = st->Etot_l_lp + (1.5f + 1.5f * (st->Etot_lp<50.0f))*st->Etot_v_h2; */ tmp = 12288; move16();/* 1.5 Q13 */ - if( sub(st_fx->Etot_lp_fx, 12800 ) < 0 ) /* 50.0 in Q8 */ + if( LT_16(st_fx->Etot_lp_fx, 12800 )) /* 50.0 in Q8 */ { tmp =shl(tmp,1); /*1.5 + 1.5 Q13 */ } @@ -1287,7 +1285,7 @@ void noise_est_fx( /* enr_bgd = Etot < Etot_l_lp_thr; */ enr_bgd = 0; move16(); - if(sub(Etot, Etot_l_lp_thr ) < 0 ) /* Q8 */ + if(LT_16(Etot, Etot_l_lp_thr )) /* Q8 */ { enr_bgd = 1; move16();/* Q0 */ @@ -1297,8 +1295,8 @@ void noise_est_fx( cns_bgd = 0 ; move16(); test(); - if( (sub(epsP_0_2, 32563) >0 ) /* 7.95 in Q12 */ - && (L_sub(non_sta, 1024000L) < 0 ) ) /* 1e3f in Q10 ? */ + if( (GT_16(epsP_0_2, 32563)) /* 7.95 in Q12 */ + && (LT_32(non_sta, 1024000L) ) ) /* 1e3f in Q10 ? */ { cns_bgd = 1; move16(); /* Q0 */ @@ -1307,7 +1305,7 @@ void noise_est_fx( /*lp_bgd = epsP_2_16_dlp_max < 0.10f; */ lp_bgd = 0; move16(); - if( sub(epsP_2_16_dlp_max, 410) <0 ) /*0.10 Q12 */ + if( LT_16(epsP_2_16_dlp_max, 410)) /*0.10 Q12 */ { lp_bgd = 1; move16(); /* Q0 */ @@ -1317,7 +1315,7 @@ void noise_est_fx( /* ns_mask = non_sta < 1e5f; */ ns_mask = 0; move16(); - if( L_sub(non_sta, (Word32)102400000L ) < 0) /* (1e5f in Q10)*/ + if( LT_32(non_sta, (Word32)102400000L )) /* (1e5f in Q10)*/ { ns_mask = 1; move16(); /* Q0 */ @@ -1327,7 +1325,7 @@ void noise_est_fx( /* lt_haco_mask = st->lt_haco_ev < 0.5f; */ lt_haco_mask = 0; move16(); - if( sub(st_fx->lt_haco_ev_fx, 16384 ) < 0 ) /* ( .5 in Q15)*/ + if( LT_16(st_fx->lt_haco_ev_fx, 16384 )) /* ( .5 in Q15)*/ { lt_haco_mask = 1; move16(); /* Q0 */ @@ -1336,7 +1334,7 @@ void noise_est_fx( /* bg_haco_mask = haco_ev_max < 0.4f; */ bg_haco_mask = 0; move16(); - if( sub(haco_ev_max, 13107) < 0 ) /* ( 0.4 in Q15)*/ + if( LT_16(haco_ev_max, 13107)) /* ( 0.4 in Q15)*/ { bg_haco_mask = 1; move16(); /* Q0 */ @@ -1347,8 +1345,8 @@ void noise_est_fx( SD_1 = 0; move16(); test(); - if( (sub(epsP_0_2_ad,2048) > 0) /* 0.5 in Q12 */ - && (sub(epsP_0_2, 32563) > 0 )) /* 7.95 in Q12 */ + if( (GT_16(epsP_0_2_ad,2048)) /* 0.5 in Q12 */ + && (GT_16(epsP_0_2, 32563) )) /* 7.95 in Q12 */ { SD_1 = 1; move16(); /* Q0 */ @@ -1365,7 +1363,7 @@ void noise_est_fx( /*PD_1 = (epsP_2_16_dlp_max < 0.10f ) ; */ PD_1 = 0; move16(); - if( (sub( epsP_2_16_dlp_max, 410) < 0) ) /* 0.10 in Q12 */ + if( (LT_16( epsP_2_16_dlp_max, 410))) /* 0.10 in Q12 */ { PD_1 = 1; move16(); /* Q0 */ @@ -1374,7 +1372,7 @@ void noise_est_fx( /*PD_2 = (epsP_0_2_ad_lp_max < 0.10f ) ; */ PD_2 = 0; move16(); - if( (sub( epsP_0_2_ad_lp_max, 410) < 0) ) /* 0.10 in Q12 */ + if( (LT_16( epsP_0_2_ad_lp_max, 410))) /* 0.10 in Q12 */ { PD_2 = 1; move16(); /* Q0 */ @@ -1383,7 +1381,7 @@ void noise_est_fx( /*PD_3 = (comb_ahc_epsP < 0.85f ); */ PD_3 = 0; move16(); - if( (sub(comb_ahc_epsP, 3482 ) < 0) ) /* 0.85 in Q12 */ + if( (LT_16(comb_ahc_epsP, 3482 ))) /* 0.85 in Q12 */ { PD_3 = 1; move16(); /* Q0 */ @@ -1392,7 +1390,7 @@ void noise_est_fx( /* PD_4 = comb_ahc_epsP < 0.15f; */ PD_4 = 0; move16(); - if( (sub(comb_ahc_epsP, 614) < 0) ) /* 0.15 in Q12 */ + if( (LT_16(comb_ahc_epsP, 614))) /* 0.15 in Q12 */ { PD_4 = 1; move16(); /* Q0 */ @@ -1401,7 +1399,7 @@ void noise_est_fx( /*PD_5 = comb_hcm_epsP < 0.30f; */ PD_5 = 0; move16(); - if( (sub(comb_hcm_epsP, 1229) < 0) ) /* 0.30 in Q12 */ + if( (LT_16(comb_hcm_epsP, 1229))) /* 0.30 in Q12 */ { PD_5 = 1; move16(); /* Q0 */ @@ -1415,9 +1413,9 @@ void noise_est_fx( test(); test(); test(); - if( ( (SD_1 == 0) || (sub(Etot, Etot_l_lp_thr) < 0 ) ) - && (bg_haco_mask != 0) && ( sub(st_fx->act_pred_fx, 27853 ) < 0 ) /* 0.85f in Q15 */ - && (sub(st_fx->Etot_lp_fx, 50*256) < 0 )) /* 50.0 in Q8 */ + if( ( (SD_1 == 0) || (LT_16(Etot, Etot_l_lp_thr))) + && (bg_haco_mask != 0) && ( LT_16(st_fx->act_pred_fx, 27853 ) ) /* 0.85f in Q15 */ + && (LT_16(st_fx->Etot_lp_fx, 50*256) )) /* 50.0 in Q8 */ { BG_1 = 1; move16(); @@ -1435,7 +1433,7 @@ void noise_est_fx( } tmp = 0; move16();/*Q0*/ - if( sub(Etot, 55*256) <0) /*55.0 in Q8 */ + if( LT_16(Etot, 55*256)) /*55.0 in Q8 */ { tmp = 1; move16();/*Q0*/ @@ -1467,9 +1465,9 @@ void noise_est_fx( move16(); test(); test(); - if ( ( sub(st_fx->sign_dyn_lp_fx, 15*256) > 0 ) /* 15 in Q8 */ - && ( sub(sub(Etot, st_fx->Etot_l_lp_fx ), shl(Etot_v_h2, 1) ) < 0 ) /* Q8 , Etot_v_h2 has limited dynmics can be upscaled*/ - && (sub(*st_harm_cor_cnt, 20) > 0 ) ) + if ( ( GT_16(st_fx->sign_dyn_lp_fx, 15*256)) /* 15 in Q8 */ + && ( LT_16(sub(Etot, st_fx->Etot_l_lp_fx ), shl(Etot_v_h2, 1) ) ) /* Q8 , Etot_v_h2 has limited dynmics can be upscaled*/ + && (GT_16(*st_harm_cor_cnt, 20) ) ) { sd1_bgd = 1; move16(); @@ -1489,15 +1487,15 @@ void noise_est_fx( test(); test(); test(); - if ( ( (sub(st_fx->act_pred_fx, 19333) < 0 ) && ( sub(st_fx->lt_haco_ev_fx, 7537) < 0 ) ) /* .59 in Q15 .23 in Q15 */ - || (sub(st_fx->act_pred_fx, 12452) < 0 ) /* .38 in Q15 */ - || (sub(st_fx->lt_haco_ev_fx, 4915) < 0 ) /* .15 in Q15 */ - || (sub(non_staB, 50*256 ) < 0 ) /* 50.0 in Q8 */ + if ( ( (LT_16(st_fx->act_pred_fx, 19333))&&(LT_16(st_fx->lt_haco_ev_fx,7537))) /* .59 in Q15 .23 in Q15 */ + || (LT_16(st_fx->act_pred_fx, 12452) ) /* .38 in Q15 */ + || (LT_16(st_fx->lt_haco_ev_fx, 4915) ) /* .15 in Q15 */ + || (LT_16(non_staB, 50*256 ) ) /* 50.0 in Q8 */ || aE_bgd != 0 - || ( (sub(Etot,10752)<0) /* 42 in Q8 */ - && (sub(st_fx->harm_cor_cnt_fx, 10) > 0 ) - && ( sub(st_fx->lt_haco_ev_fx, 11469) < 0 ) /* 0.35 in Q15 */ - && ( sub(st_fx->act_pred_fx, 26214) < 0 ) /* 0.80 in Q15 */ + || ( (LT_16(Etot,10752)) /* 42 in Q8 */ + && (GT_16(st_fx->harm_cor_cnt_fx, 10) ) + && ( LT_16(st_fx->lt_haco_ev_fx, 11469) ) /* 0.35 in Q15 */ + && ( LT_16(st_fx->act_pred_fx, 26214) ) /* 0.80 in Q15 */ ) ) { @@ -1509,10 +1507,10 @@ void noise_est_fx( move16(); test(); test(); - if ( ( sub(st_fx->ini_frame_fx, HE_LT_CNT_INIT_FX ) < 0) - && ( sub(st_fx->harm_cor_cnt_fx,5) > 0 ) /* > 5 Q0 */ - && ( sub(sub(Etot,st_fx->Etot_lp_fx),1792 ) < 0 ) /* 7 in Q8 */ - && ( tmp != 0) ) + if ( ( LT_16(st_fx->ini_frame_fx, HE_LT_CNT_INIT_FX )) + && ( GT_16(st_fx->harm_cor_cnt_fx,5)) /* > 5 Q0 */ + && ( LT_16(sub(Etot,st_fx->Etot_lp_fx),1792 )) /* 7 in Q8 */ + && ( NE_16(tmp, 0)) ) { tn_ini = 1; move16(); @@ -1523,7 +1521,7 @@ void noise_est_fx( bg_bgd2 = 0; move16(); test(); - if ( ( sub(Etot, Etot_l_lp_thr) < 0 ) + if ( ( LT_16(Etot, Etot_l_lp_thr)) || (tn_ini != 0 ) ) { bg_bgd2 = 1; @@ -1536,7 +1534,7 @@ void noise_est_fx( || tn_ini ) */ tmp = 0; move16(); - if( sub(st_fx->lt_tn_track_fx, 29491 ) > 0 ) /* .90 in Q15 */ + if( GT_16(st_fx->lt_tn_track_fx, 29491 )) /* .90 in Q15 */ { tmp = 1; move16(); @@ -1585,16 +1583,16 @@ void noise_est_fx( test(); test(); test(); - IF( ( ( sub(st_fx->act_pred_fx, 27853) < 0 ) /* 0.85 in Q15 */ - && ( aE_bgd != 0 ) - && ( (sub(st_fx->lt_Ellp_dist_fx, 10*256) < 0) || ( sd1_bgd != 0 ) ) /* 10.0 in Q8*/ - && ( sub(st_fx->lt_tn_dist_fx, 40*256 ) < 0 ) /* 40.0 in Q8*/ - && ( sub(sub(Etot, st_fx->totalNoise_fx), 10*256) < 0 ) /* 10.0 in Q8*/ + IF( ( ( LT_16(st_fx->act_pred_fx, 27853)) /* 0.85 in Q15 */ + && ( NE_16(aE_bgd ,0) ) + && ( (LT_16(st_fx->lt_Ellp_dist_fx, 10*256) ) || ( NE_16(sd1_bgd, 0) ) ) /* 10.0 in Q8*/ + && ( LT_16(st_fx->lt_tn_dist_fx, 40*256 ) ) /* 40.0 in Q8*/ + && ( LT_16(sub(Etot, st_fx->totalNoise_fx), 10*256) ) /* 10.0 in Q8*/ ) - || ( (st_fx->first_noise_updt_fx == 0) && (sub(st_fx->harm_cor_cnt_fx,80) > 0) - && ( aE_bgd != 0 ) && (sub(st_fx->lt_aEn_zero_fx, 16384) > 0) /*.5 in Q15*/ + || ( (st_fx->first_noise_updt_fx == 0) && (GT_16(st_fx->harm_cor_cnt_fx,80) ) + && ( aE_bgd != 0 ) && (GT_16(st_fx->lt_aEn_zero_fx, 16384) ) /*.5 in Q15*/ ) - || ( (tn_ini != 0 ) && ( ( aE_bgd != 0 ) || ( sub(non_staB, 10*256) < 0 ) || (sub(st_fx->harm_cor_cnt_fx, 80) > 0 ) ) /* 10.0 in Q8*/ + || ( (tn_ini != 0 ) && ( ( aE_bgd != 0 ) || ( LT_16(non_staB, 10*256) ) || (GT_16(st_fx->harm_cor_cnt_fx, 80) ) ) /* 10.0 in Q8*/ ) ) @@ -1615,19 +1613,19 @@ void noise_est_fx( ( st->harm_cor_cnt > 50 && st->first_noise_updt > 30 && aE_bgd && st->lt_aEn_zero>0.5f ) || tn_ini ) */ - ELSE IF ( ( ( sub(st_fx->act_pred_fx, 26214) < 0 ) /* .8 in Q15*/ + ELSE IF ( ( ( LT_16(st_fx->act_pred_fx, 26214)) /* .8 in Q15*/ && ( ( aE_bgd != 0 ) || ( PAU != 0 ) ) - && (sub(st_fx->lt_haco_ev_fx, 3277) < 0 ) ) /* .10 in q15*/ - || ( ( sub(st_fx->act_pred_fx, 22938 ) < 0 ) /* 0.70 in Q15 */ - && ( (aE_bgd!=0 ) || ( sub(non_staB, 17*256 ) < 0 ) )/* 17.0 in Q8 */ + && (LT_16(st_fx->lt_haco_ev_fx, 3277) ) ) /* .10 in q15*/ + || ( ( LT_16(st_fx->act_pred_fx, 22938 ) ) /* 0.70 in Q15 */ + && ( (aE_bgd!=0 ) || ( LT_16(non_staB, 17*256 ) ) )/* 17.0 in Q8 */ && ( PAU != 0 ) - && ( sub(st_fx->lt_haco_ev_fx,4915) < 0 ) /* 0.15 in Q15 */ + && ( LT_16(st_fx->lt_haco_ev_fx,4915) ) /* 0.15 in Q15 */ ) - || ( (sub(st_fx->harm_cor_cnt_fx, 80)> 0 ) && (sub(st_fx->totalNoise_fx, 5*256) > 0 ) /* 5.0 in Q8 */ - && ( sub(Etot, s_max((Word16)1*256, add(Etot_l_lp, add(st_fx->Etot_v_h2_fx,shr(st_fx->Etot_v_h2_fx,1))))) < 0) /* 1.5= 1.0+.5 */ + || ( (GT_16(st_fx->harm_cor_cnt_fx, 80) ) && (GT_16(st_fx->totalNoise_fx, 5*256) ) /* 5.0 in Q8 */ + && ( LT_16(Etot, s_max((Word16)1*256, add(Etot_l_lp, add(st_fx->Etot_v_h2_fx,shr(st_fx->Etot_v_h2_fx,1))))) ) /* 1.5= 1.0+.5 */ ) - || ( (sub(st_fx->harm_cor_cnt_fx,50) >0) && (sub(st_fx->first_noise_updt_fx, 30) > 0) - && (aE_bgd != 0) && (sub(st_fx->lt_aEn_zero_fx, 16384) > 0) ) /*.5 in Q15*/ + || ( (GT_16(st_fx->harm_cor_cnt_fx,50) ) && (GT_16(st_fx->first_noise_updt_fx, 30) ) + && (aE_bgd != 0) && (GT_16(st_fx->lt_aEn_zero_fx, 16384) ) ) /*.5 in Q15*/ || ( tn_ini != 0 ) ) @@ -1646,11 +1644,11 @@ void noise_est_fx( test(); test(); IF ( ( aE_bgd==0 ) - && ( sub(st_fx->harm_cor_cnt_fx, 50) < 0 ) - && ( ( sub(st_fx->act_pred_fx, 19661) > 0 ) /* 0.6 in Q15*/ + && ( LT_16(st_fx->harm_cor_cnt_fx, 50) ) + && ( ( GT_16(st_fx->act_pred_fx, 19661) ) /* 0.6 in Q15*/ || ( ( tn_ini==0 ) - && (sub(sub(Etot_l_lp, st_fx->totalNoise_fx),10*256) < 0 ) /* 10.0 in Q8 */ - && (sub(non_staB, 8*256) > 0) /* 8.0 in in Q8*/ + && (LT_16(sub(Etot_l_lp, st_fx->totalNoise_fx),10*256) ) /* 10.0 in Q8 */ + && (GT_16(non_staB, 8*256) ) /* 8.0 in in Q8*/ ) ) ) @@ -1677,7 +1675,7 @@ void noise_est_fx( } */ } /*else if (aE_bgd || st->harm_cor_cnt > 100 )*/ - ELSE IF ( (aE_bgd !=0) || (sub(st_fx->harm_cor_cnt_fx, 100) > 0)) + ELSE IF ( (aE_bgd !=0) || (GT_16(st_fx->harm_cor_cnt_fx, 100))) { st_fx->first_noise_updt_fx = add(st_fx->first_noise_updt_fx,1); } @@ -1687,15 +1685,15 @@ void noise_est_fx( /* If in music lower bckr to drop further */ test(); test(); - IF ( (sub(st_fx->low_tn_track_cnt_fx, 300) > 0) - && (sub(st_fx->lt_haco_ev_fx, 29491 ) > 0 ) /*.9 in Q15 */ + IF ( (GT_16(st_fx->low_tn_track_cnt_fx, 300)) + && (GT_16(st_fx->lt_haco_ev_fx, 29491 ) ) /*.9 in Q15 */ && (st_fx->totalNoise_fx > 0 ) ) { updt_step = -655; move16(); /* for debug purposes */ FOR( i=0; i< NB_BANDS; i++ ) { - IF( L_sub(st_fx->bckr_fx[i], L_shl(Le_min_scaled, 1L) ) > 0 ) /* 2*E_MIN(float) in float, here we use 2*Le_min_scaled Q_new+Q_SCALE */ + IF( GT_32(st_fx->bckr_fx[i], L_shl(Le_min_scaled, 1L) )) /* 2*E_MIN(float) in float, here we use 2*Le_min_scaled Q_new+Q_SCALE */ { /* st->bckr[i] = 0.98f*st->bckr[i]; */ st_fx->bckr_fx[i] = Mult_32_16(st_fx->bckr_fx[i], 32113); /* .98 in Q15 */ diff --git a/lib_enc/noise_adjust_fx.c b/lib_enc/noise_adjust_fx.c index 9382a5b6dbfe344112938f6726b5fdade22fd6b3..1eaa4d4837f50de77feb7a783a5ab15fc7865314 100644 --- a/lib_enc/noise_adjust_fx.c +++ b/lib_enc/noise_adjust_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -7,9 +7,7 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ -#include "stl.h" -#include "wmc_auto.h" - /* required for wmc_tool */ +#include "stl.h" /* required for wmc_tool */ /*--------------------------------------------------------------------------* * noise_adjust_fx() diff --git a/lib_enc/normalizecoefs_fx.c b/lib_enc/normalizecoefs_fx.c index 2c60b563aed4f01c60860729881b3dc8ea2272d0..c74916b0defebc0bceee62088385cbfaf6a12288 100644 --- a/lib_enc/normalizecoefs_fx.c +++ b/lib_enc/normalizecoefs_fx.c @@ -1,11 +1,9 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "stl.h" -#include "wmc_auto.h" - #include "basop_mpy.h" #include "prot_fx.h" #include "cnst_fx.h" /* Common constants */ @@ -52,9 +50,9 @@ void normalizecoefs_fx( *pcoefs = Mpy_32_16_1(*pcoefs, INV2POWHALF); move32(); } - BASOP_SATURATE_WARNING_OFF;/* May saturate for strong peaks in a high band, in which case saturation is desirable */ + BASOP_SATURATE_WARNING_OFF /* May saturate for strong peaks in a high band, in which case saturation is desirable */ *pcoefs16++ = round_fx( L_shl(*pcoefs++, 16-k) ); /* Q12 */ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON } } diff --git a/lib_enc/peak_vq_enc_fx.c b/lib_enc/peak_vq_enc_fx.c index 7ddc642819752af9908dcca26d688aae6610bd24..1a419385be28135019e611ec5a6e0a8eac1726a6 100644 --- a/lib_enc/peak_vq_enc_fx.c +++ b/lib_enc/peak_vq_enc_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -8,9 +8,7 @@ #include "prot_fx.h" #include "rom_enc_fx.h" #include "rom_com_fx.h" -#include "stl.h" -#include "wmc_auto.h" - /* required for wmc_tool */ +#include "stl.h" /* required for wmc_tool */ /*-------------------------------------------------------------------------- * Local functions @@ -93,7 +91,7 @@ Word16 peak_vq_enc_fx( set16_fx(npulses, 0, MAX_PVQ_BANDS ); /* Set bit-rate dependent variables */ - IF (L_sub(brate, HQ_24k40) == 0) + IF (EQ_32(brate, HQ_24k40)) { max_peaks = HVQ_MAX_PEAKS_24k; move16(); @@ -142,7 +140,7 @@ Word16 peak_vq_enc_fx( { indx = *pVqPeakIdx++; move16(); - IF (sub(indx, low_peak_bin) < 0) + IF (LT_16(indx, low_peak_bin)) { low_peak_bin = indx; move16(); @@ -231,7 +229,7 @@ Word16 peak_vq_enc_fx( move16(); tmp16 = extract_l(L_mult0(GAINI_BITS, vqPeaksMinus1)); - IF ( sub(hcode_l, tmp16) >= 0) + IF ( GE_16(hcode_l, tmp16)) { hcode_l = tmp16; move16(); @@ -319,7 +317,7 @@ Word16 peak_vq_enc_fx( move16(); FOR (k = 0; k < pvq_bands; k++) { - IF (sub(k, sub(pvq_bands, n_sel_bnds)) >= 0) + IF (GE_16(k, sub(pvq_bands, n_sel_bnds))) { i = band_start_harm[*pSelBnds++]; move16(); @@ -330,7 +328,7 @@ Word16 peak_vq_enc_fx( j = 0; move16(); pPvqVectorBandStart = pPvqVector; - WHILE (sub(j, hvq_band_width[k]) < 0) + WHILE (LT_16(j, hvq_band_width[k])) { IF (*pCoefsOut++ == 0) { @@ -395,15 +393,15 @@ Word16 peak_vq_enc_fx( normq = L_add(dicn_fx[indx], 0); /* in Q14 */ j = 0; move16(); - IF (sub(k, sub(pvq_bands, n_sel_bnds)) >= 0) + IF (GE_16(k, sub(pvq_bands, n_sel_bnds))) { i = band_start_harm[*pSelBnds++]; move16(); pCoefsOut = coefs_out + i; } - WHILE (sub(j, hvq_band_width[k]) < 0) + WHILE (LT_16(j, hvq_band_width[k])) { - IF (L_sub(*pCoefsOut, 0) == 0) + IF (EQ_32(*pCoefsOut, 0)) { acc = L_mult(*pCoefsPvq++, fg_pred[k]); /* in Q(15 + 1 + 12 = 28) */ tmp16 = extract_h(acc); /* in Q(28 - 16 = 12) */ @@ -491,7 +489,7 @@ static void quant_peaks_fx( } FOR (i = 0; i < 4; i++) { - IF (sub(Qx_vec[i], Qx) != 0) + IF (NE_16(Qx_vec[i], Qx)) { x[i] = shr(x[i], sub(Qx_vec[i], Qx)); /* Qx */ } @@ -500,7 +498,7 @@ static void quant_peaks_fx( IF (vect_out[0] != 0) { absPeakGain1 = L_abs(peak_gain[-1]); - IF (L_sub(absPeakGain1, absPeakGain) > 0) + IF (GT_32(absPeakGain1, absPeakGain)) { weights[0] = 0; move16(); @@ -514,7 +512,7 @@ static void quant_peaks_fx( IF (overlap > 0) { absPeakGain1 = L_abs(peak_gain[1]); - IF (L_sub(absPeakGain1, absPeakGain) > 0) + IF (GT_32(absPeakGain1, absPeakGain)) { indx = sub(4, overlap); pWeights = &weights[indx]; @@ -551,14 +549,14 @@ static void quant_peaks_fx( *vq_idx = w_vquant_fx(x, Qx, weights, xq, hvq_peak_cb_fx, cbSize, 0); push_indice_fx(st_fx, IND_HVQ_PEAKS, 0, 1 ); } - ELSE IF( sub(cb_class, 1) == 0 ) + ELSE IF( EQ_16(cb_class, 1)) { indx = sub(HVQ_CB_SIZE*2, shl(search_overlap,2)); *vq_idx = w_vquant_fx(x, Qx, weights, xq, &hvq_peak_cb_fx[indx], cbSize, 0); *vq_idx = add(*vq_idx, sub(HVQ_CB_SIZE/2, search_overlap)); push_indice_fx(st_fx, IND_HVQ_PEAKS, 0, 1 ); } - ELSE IF( sub(cb_class, 2) == 0 ) + ELSE IF( EQ_16(cb_class, 2)) { indx = sub(HVQ_CB_SIZE*2, shl(search_overlap,2)); *vq_idx = w_vquant_fx(x, Qx, weights, xq, &hvq_peak_cb_fx[indx], cbSize, 1); @@ -647,7 +645,7 @@ static Word16 sparse_code_pos_fx( FOR (idx = 0; idx < HVQ_CP_MAP_LEN; idx++) { - IF (sub(hvq_cp_layer1_map5[idx], val) == 0) + IF (EQ_16(hvq_cp_layer1_map5[idx], val)) { BREAK; } @@ -717,7 +715,7 @@ static Word16 hvq_code_pos_fx( FOR (i = 1; i < num_peaks; i++) { delta[i] = sub(sub(peak_idx[i], peak_idx[i-1]), HVQ_CP_HUFF_OFFSET); - if (sub(delta_max, delta[i]) < 0) + if (LT_16(delta_max, delta[i])) { delta_max = delta[i]; move16(); @@ -727,7 +725,7 @@ static Word16 hvq_code_pos_fx( /* Calculate bits needed for huffman coding of deltas */ delta_bits = -1; move16(); - IF (sub(delta_max, HVQ_CP_HUFF_MAX) <= 0) + IF (LE_16(delta_max, HVQ_CP_HUFF_MAX)) { delta_bits = 0; move16(); @@ -742,7 +740,7 @@ static Word16 hvq_code_pos_fx( /* Decide which coding mode to use */ test(); - IF (sub(delta_bits, sparse_bits) > 0 || delta_bits < 0) + IF (GT_16(delta_bits, sparse_bits)||delta_bits<0) { push_indice_fx(st_fx, IND_POS_IDX, HVQ_CP_SPARSE, 1); diff --git a/lib_enc/pit_enc_fx.c b/lib_enc/pit_enc_fx.c index 9d485d3b6b0927fcc70a7a8b734ef48a1177d629..8cc92d8eb42463a39440484d0664a0b60e953495 100644 --- a/lib_enc/pit_enc_fx.c +++ b/lib_enc/pit_enc_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -9,8 +9,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - #include "rom_basop_util.h" #define inv_T0_res InvIntTable @@ -82,7 +80,7 @@ Word16 pit_encode_fx( /* o : Fractional pitch for each subframe *----------------------------------------------------------------*/ pit_flag = i_subfr; move16(); - if (sub(i_subfr,2*L_SUBFR) == 0) + if (EQ_16(i_subfr,2*L_SUBFR)) { pit_flag = 0; move16(); @@ -107,22 +105,22 @@ Word16 pit_encode_fx( /* o : Fractional pitch for each subframe { *limit_flag = 1; move16(); - if( sub(coder_type,VOICED) == 0 ) + if( EQ_16(coder_type,VOICED)) { *limit_flag = 2; move16(); /* double-extended limits */ } test(); - if( sub(coder_type,GENERIC) == 0 && L_sub(core_brate,ACELP_7k20) == 0 ) + if( EQ_16(coder_type,GENERIC)&&EQ_32(core_brate,ACELP_7k20)) { *limit_flag = 0; move16(); } } - ELSE IF( sub(i_subfr,2*L_SUBFR) == 0 && sub(coder_type,GENERIC) == 0 && L_sub(core_brate,ACELP_13k20) <= 0 ) + ELSE IF( EQ_16(i_subfr,2*L_SUBFR)&&EQ_16(coder_type,GENERIC)&&LE_32(core_brate,ACELP_13k20)) { /*if( *T0 > (PIT_FR1_EXTEND_8b + PIT_MIN)>>1 )*/ - if( sub(*T0,shr(add(PIT_FR1_EXTEND_8b , PIT_MIN), 1)) > 0) + if( GT_16(*T0,shr(add(PIT_FR1_EXTEND_8b , PIT_MIN), 1))) { *limit_flag = 0; move16(); @@ -133,12 +131,12 @@ Word16 pit_encode_fx( /* o : Fractional pitch for each subframe { test(); test(); - IF( i_subfr == 0 && sub(T_op[0],PIT_MIN) < 0 ) + IF( i_subfr == 0 && LT_16(T_op[0],PIT_MIN)) { mult_Top = 2; move16(); } - ELSE IF( sub(i_subfr,2*L_SUBFR) == 0 && sub(T_op[1],PIT_MIN) < 0 ) + ELSE IF( EQ_16(i_subfr,2*L_SUBFR)&<_16(T_op[1],PIT_MIN)) { mult_Top = 2; move16(); @@ -149,10 +147,10 @@ Word16 pit_encode_fx( /* o : Fractional pitch for each subframe *-------------------------------------------------------*/ nBits = 0; move16(); - IF( sub(coder_type,AUDIO) != 0 ) + IF( NE_16(coder_type,AUDIO)) { /* find the number of bits */ - IF( sub(L_frame,L_FRAME) == 0 ) + IF( EQ_16(L_frame,L_FRAME)) { { nBits = ACB_bits_tbl[BIT_ALLOC_IDX_fx(core_brate, coder_type, i_subfr, 0)]; @@ -165,7 +163,7 @@ Word16 pit_encode_fx( /* o : Fractional pitch for each subframe move16(); } } - IF( sub(coder_type,AUDIO) == 0 ) + IF( EQ_16(coder_type,AUDIO)) { /*-------------------------------------------------------* * Pitch encoding in AUDIO mode @@ -176,7 +174,7 @@ Word16 pit_encode_fx( /* o : Fractional pitch for each subframe move16(); test(); test(); - if ( sub(L_subfr,L_frame/2) == 0 && i_subfr != 0 && sub(L_frame,L_FRAME) == 0 ) + if ( EQ_16(L_subfr,L_frame/2)&&i_subfr!=0&&EQ_16(L_frame,L_FRAME)) { pit_flag = L_SUBFR; move16(); @@ -198,7 +196,7 @@ Word16 pit_encode_fx( /* o : Fractional pitch for each subframe { limit_T0_fx( L_frame, delta, pit_flag, *limit_flag, mult_Top*T_op[0], 0, T0_min, T0_max ); } - ELSE IF( sub(i_subfr,2*L_SUBFR) == 0 && pit_flag == 0 ) + ELSE IF( EQ_16(i_subfr,2*L_SUBFR)&& pit_flag == 0 ) { limit_T0_fx( L_frame, delta, pit_flag, *limit_flag, mult_Top*T_op[1], 0, T0_min, T0_max ); } @@ -208,7 +206,7 @@ Word16 pit_encode_fx( /* o : Fractional pitch for each subframe pit_Q_enc_fx( st_fx, 0, nBits, delta, pit_flag, *limit_flag, *T0, *T0_frac, T0_min, T0_max ); } - ELSE IF( sub(coder_type,VOICED) == 0 ) + ELSE IF( EQ_16(coder_type,VOICED)) { /*-------------------------------------------------------* * Pitch encoding in VOICED mode (ACELP@12k8 core only) @@ -216,7 +214,7 @@ Word16 pit_encode_fx( /* o : Fractional pitch for each subframe delta = 4; move16(); - if ( sub(i_subfr,2*L_SUBFR) == 0 ) + if ( EQ_16(i_subfr,2*L_SUBFR)) { pit_flag = i_subfr; move16(); @@ -231,12 +229,12 @@ Word16 pit_encode_fx( /* o : Fractional pitch for each subframe /* search and encode the closed loop pitch period */ test(); test(); - IF( sub(nBits,9) == 0 || sub(nBits,5) == 0 ) + IF( EQ_16(nBits,9)||EQ_16(nBits,5)) { *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_FR2_DOUBLEEXTEND_9b, PIT_FR1_DOUBLEEXTEND_9b, L_FRAME, L_SUBFR ); move16(); } - ELSE IF( sub(nBits,10) == 0 ) + ELSE IF( EQ_16(nBits,10)) { *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MAX, PIT_MAX, L_FRAME, L_SUBFR ); move16(); @@ -259,17 +257,17 @@ Word16 pit_encode_fx( /* o : Fractional pitch for each subframe { limit_T0_fx( L_frame, delta, pit_flag, *limit_flag, mult_Top*T_op[0], 0, T0_min, T0_max ); } - ELSE IF( sub(i_subfr,2*L_SUBFR) == 0) + ELSE IF( EQ_16(i_subfr,2*L_SUBFR)) { limit_T0_fx( L_frame, delta, pit_flag, *limit_flag, mult_Top*T_op[1], 0, T0_min, T0_max ); } /* search and encode the closed loop pitch period */ - IF( sub(L_frame,L_FRAME) == 0 ) + IF( EQ_16(L_frame,L_FRAME)) { test(); test(); - IF( sub(nBits,8) == 0 || sub(nBits,5) == 0 ) + IF( EQ_16(nBits,8)||EQ_16(nBits,5)) { IF( *limit_flag == 0 ) { @@ -280,7 +278,7 @@ Word16 pit_encode_fx( /* o : Fractional pitch for each subframe *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MIN_EXTEND, PIT_FR1_EXTEND_8b, L_FRAME, L_SUBFR ); } } - ELSE IF( sub(nBits,9) == 0 || sub(nBits,6) == 0) + ELSE IF( EQ_16(nBits,9)||EQ_16(nBits,6)) { IF( *limit_flag == 0 ) { @@ -291,7 +289,7 @@ Word16 pit_encode_fx( /* o : Fractional pitch for each subframe *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_FR2_EXTEND_9b, PIT_FR1_EXTEND_9b, L_FRAME, L_SUBFR ); } } - ELSE IF( sub(nBits,10) == 0 ) + ELSE IF( EQ_16(nBits,10)) { *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MAX, PIT_MAX, L_FRAME, L_SUBFR ); } @@ -301,7 +299,7 @@ Word16 pit_encode_fx( /* o : Fractional pitch for each subframe ELSE /* L_frame == L_FRAME16k */ { test(); - IF( sub(nBits,9) == 0 || sub(nBits,6) == 0 ) + IF( EQ_16(nBits,9)||EQ_16(nBits,6)) { *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT16k_FR2_EXTEND_9b, PIT16k_FR1_EXTEND_9b, L_FRAME16k, L_SUBFR ); } @@ -326,7 +324,7 @@ Word16 pit_encode_fx( /* o : Fractional pitch for each subframe *limit_flag = 0; move16(); - IF( L_sub(core_brate,ACELP_6k60) == 0 ) + IF( EQ_32(core_brate,ACELP_6k60)) { nBits = 5; move16(); @@ -339,7 +337,7 @@ Word16 pit_encode_fx( /* o : Fractional pitch for each subframe move16(); } - if( sub(i_subfr,2*L_SUBFR) == 0 ) + if( EQ_16(i_subfr,2*L_SUBFR)) { /* rewrite pit_flag - it must not be zero */ pit_flag = i_subfr; @@ -349,7 +347,7 @@ Word16 pit_encode_fx( /* o : Fractional pitch for each subframe /* search and encode the closed loop pitch period */ *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR ); } - ELSE IF( L_sub(core_brate,ACELP_8k85) == 0 ) + ELSE IF( EQ_32(core_brate,ACELP_8k85)) { nBits = 5; move16(); @@ -361,7 +359,7 @@ Word16 pit_encode_fx( /* o : Fractional pitch for each subframe nBits = 8; move16(); } - ELSE IF( sub(i_subfr,2*L_SUBFR) == 0 ) + ELSE IF( EQ_16(i_subfr,2*L_SUBFR)) { limit_T0_fx( L_FRAME, delta, pit_flag, *limit_flag, i_mult2(mult_Top,T_op[1]), 0, T0_min, T0_max ); nBits = 8; @@ -383,7 +381,7 @@ Word16 pit_encode_fx( /* o : Fractional pitch for each subframe nBits = 9; move16(); } - ELSE IF( sub(i_subfr,2*L_SUBFR) == 0 ) + ELSE IF( EQ_16(i_subfr,2*L_SUBFR)) { limit_T0_fx( L_FRAME, delta, pit_flag, *limit_flag, i_mult2(mult_Top,T_op[1]), 0, T0_min, T0_max ); nBits = 9; @@ -432,7 +430,7 @@ Word16 abs_pit_enc_fx( /* o : pitch index IF( limit_flag == 0 ) { - IF( sub(fr_steps,2) == 0 ) + IF( EQ_16(fr_steps,2)) { /*-----------------------------------------------------------------* * The pitch range is encoded absolutely with 8 bits @@ -441,7 +439,7 @@ Word16 abs_pit_enc_fx( /* o : pitch index * PIT_FR1_8b to PIT_MAX resolution 1 (frac = 0) *-----------------------------------------------------------------*/ - IF (sub(T0,PIT_FR1_8b) < 0) + IF (LT_16(T0,PIT_FR1_8b)) { /*pitch_index = T0*2 + (T0_frac>>1) - (PIT_MIN*2);*/ pitch_index = sub(add(shl(T0,1),shr(T0_frac,1)),(PIT_MIN*2)); @@ -452,7 +450,7 @@ Word16 abs_pit_enc_fx( /* o : pitch index pitch_index = add(sub(T0,PIT_FR1_8b),((PIT_FR1_8b-PIT_MIN)*2)); } } - ELSE IF( sub(fr_steps,4) == 0 ) + ELSE IF( EQ_16(fr_steps,4)) { /*-------------------------------------------------------------------* * The pitch range is encoded absolutely with 9 bits @@ -462,12 +460,12 @@ Word16 abs_pit_enc_fx( /* o : pitch index * PIT_FR1_9b to PIT_MAX resolution 1 (frac = 0) *-------------------------------------------------------------------*/ - IF (sub(T0,PIT_FR2_9b) < 0) + IF (LT_16(T0,PIT_FR2_9b)) { /*pitch_index = T0*4 + T0_frac - (PIT_MIN*4);*/ pitch_index = add(shl(T0,2),sub(T0_frac,(PIT_MIN*4))); } - ELSE IF (sub(T0,PIT_FR1_9b) < 0) + ELSE IF (LT_16(T0,PIT_FR1_9b)) { /* pitch_index = T0*2 + (T0_frac>>1) - (PIT_FR2_9b*2) + ((PIT_FR2_9b-PIT_MIN)*4);*/ pitch_index = add(sub(add(shl(T0,1),shr(T0_frac,1)),(PIT_FR2_9b*2)),((PIT_FR2_9b-PIT_MIN)*4)); @@ -485,9 +483,9 @@ Word16 abs_pit_enc_fx( /* o : pitch index move16(); } } - ELSE IF( sub(limit_flag,1) == 0 ) /* extended Q range */ + ELSE IF( EQ_16(limit_flag,1)) /* extended Q range */ { - IF( sub(fr_steps,2) == 0 ) + IF( EQ_16(fr_steps,2)) { /*-----------------------------------------------------------------* * The pitch range is encoded absolutely with 8 bits @@ -496,7 +494,7 @@ Word16 abs_pit_enc_fx( /* o : pitch index * PIT_FR1_EXTEND_8b to PIT_MAX_EXTEND resolution 1 (frac = 0) *-----------------------------------------------------------------*/ - IF( sub(T0,PIT_FR1_EXTEND_8b) < 0 ) + IF( LT_16(T0,PIT_FR1_EXTEND_8b)) { /*pitch_index = T0*2 + (T0_frac>>1) - (PIT_MIN_EXTEND*2);*/ pitch_index = sub(add(shl(T0,1),shr(T0_frac,1)),(PIT_MIN_EXTEND*2)); @@ -507,7 +505,7 @@ Word16 abs_pit_enc_fx( /* o : pitch index pitch_index = add(sub(T0,PIT_FR1_EXTEND_8b),((PIT_FR1_EXTEND_8b-PIT_MIN_EXTEND)*2)); } } - ELSE IF( sub(fr_steps,4) == 0 ) + ELSE IF( EQ_16(fr_steps,4)) { /*-------------------------------------------------------------------* * The pitch range is encoded absolutely with 9 bits @@ -517,7 +515,7 @@ Word16 abs_pit_enc_fx( /* o : pitch index * PIT_FR1_EXTEND_9b to PIT_MAX_EXTEND resolution 1 (frac = 0) *-------------------------------------------------------------------*/ - IF( sub(T0,PIT_FR2_EXTEND_9b) < 0) + IF( LT_16(T0,PIT_FR2_EXTEND_9b)) { /*pitch_index = T0*4 + T0_frac - (PIT_MIN_EXTEND*4);*/ pitch_index = add(shl(T0,2),sub(T0_frac,(PIT_MIN_EXTEND*4))); @@ -543,7 +541,7 @@ Word16 abs_pit_enc_fx( /* o : pitch index } ELSE /* double-extended Q range */ { - IF( sub(fr_steps,2) == 0 ) + IF( EQ_16(fr_steps,2)) { /*-----------------------------------------------------------------* * The pitch range is encoded absolutely with 8 bits @@ -552,7 +550,7 @@ Word16 abs_pit_enc_fx( /* o : pitch index * PIT_FR1_DOUBLEEXTEND_8b to PIT_MAX_EXTEND resolution 1 (frac = 0) *-----------------------------------------------------------------*/ - IF( sub(T0,PIT_FR1_DOUBLEEXTEND_8b) < 0) + IF( LT_16(T0,PIT_FR1_DOUBLEEXTEND_8b)) { /*pitch_index = T0*2 + (T0_frac>>1) - (PIT_MIN_DOUBLEEXTEND*2);*/ pitch_index = sub(add(shl(T0,1),shr(T0_frac,1)),(PIT_MIN_DOUBLEEXTEND*2)); @@ -563,7 +561,7 @@ Word16 abs_pit_enc_fx( /* o : pitch index pitch_index = add(sub(T0,PIT_FR1_DOUBLEEXTEND_8b),((PIT_FR1_DOUBLEEXTEND_8b-PIT_MIN_DOUBLEEXTEND)*2)); } } - ELSE IF( sub(fr_steps,4) == 0 ) + ELSE IF( EQ_16(fr_steps,4)) { /*-------------------------------------------------------------------* * The pitch range is encoded absolutely with 9 bits @@ -573,12 +571,12 @@ Word16 abs_pit_enc_fx( /* o : pitch index * PIT_FR1_DOUBLEEXTEND_9b to PIT_MAX_EXTEND resolution 1 (frac = 0) *-------------------------------------------------------------------*/ - IF(sub(T0,PIT_FR2_DOUBLEEXTEND_9b) < 0) + IF(LT_16(T0,PIT_FR2_DOUBLEEXTEND_9b)) { /*pitch_index = T0*4 + T0_frac - (PIT_MIN_DOUBLEEXTEND*4);*/ pitch_index = add(shl(T0,2),sub(T0_frac,(PIT_MIN_DOUBLEEXTEND*4))); } - ELSE IF( sub(T0,PIT_FR1_DOUBLEEXTEND_9b) < 0 ) + ELSE IF( LT_16(T0,PIT_FR1_DOUBLEEXTEND_9b)) { /*pitch_index = T0*2 + (T0_frac>>1) - (PIT_FR2_DOUBLEEXTEND_9b*2) + ((PIT_FR2_DOUBLEEXTEND_9b-PIT_MIN_DOUBLEEXTEND)*4);*/ pitch_index = add(sub(add(shl(T0,1),shr(T0_frac,1)),(PIT_FR2_DOUBLEEXTEND_9b*2)),((PIT_FR2_DOUBLEEXTEND_9b-PIT_MIN_DOUBLEEXTEND)*4)); @@ -624,12 +622,12 @@ Word16 delta_pit_enc_fx( /* o : pitch index */ { pitch_index = sub(T0,T0_min); } - ELSE IF( sub(fr_steps,2) == 0 ) + ELSE IF( EQ_16(fr_steps,2)) { /* pitch_index = (T0 - T0_min) * 2 + (T0_frac>>1);*/ pitch_index = add(shl(sub(T0,T0_min),1),shr(T0_frac,1)); } - ELSE IF( sub(fr_steps,4) == 0 ) + ELSE IF( EQ_16(fr_steps,4)) { /*pitch_index = (T0 - T0_min) * 4 + T0_frac;*/ pitch_index = add(shl(sub(T0,T0_min),2),T0_frac); @@ -670,7 +668,7 @@ Word16 pitch_fr4_fx( /* o : chosen integer pitch lag */ /* initialization */ IF( limit_flag == 0 ) { - IF( sub(L_frame,L_FRAME) == 0 ) + IF( EQ_16(L_frame,L_FRAME)) { pit_min = PIT_MIN; move16(); @@ -683,11 +681,11 @@ Word16 pitch_fr4_fx( /* o : chosen integer pitch lag */ } ELSE { - IF( sub(L_frame,L_FRAME) == 0 ) + IF( EQ_16(L_frame,L_FRAME)) { pit_min = PIT_MIN_EXTEND; move16(); - IF( sub(limit_flag,2) == 0 ) + IF( EQ_16(limit_flag,2)) { pit_min = PIT_MIN_DOUBLEEXTEND; move16(); @@ -734,18 +732,18 @@ Word16 pitch_fr4_fx( /* o : chosen integer pitch lag */ max = s_max(corr[i], max); } - IF( sub(t0_fr1,pit_min) == 0 ) + IF( EQ_16(t0_fr1,pit_min)) { /* don't search fraction (for 7b/4b quant) */ test(); - IF((i_subfr == 0) && (sub(t0,t0_fr2) >= 0)) + IF((i_subfr == 0) && (GE_16(t0,t0_fr2))) { i = shl(shr(t0,1),1); /* 2 samples resolution */ - if (sub(add(i,2),PIT_MAX) > 0) + if (GT_16(add(i,2),PIT_MAX)) { i = sub(i,2); } - IF (sub(corr[i],corr[i+2]) > 0) + IF (GT_16(corr[i],corr[i+2])) { t0 = i; move16(); @@ -762,7 +760,7 @@ Word16 pitch_fr4_fx( /* o : chosen integer pitch lag */ } test(); - IF( (i_subfr == 0) && (sub(t0,t0_fr1) >= 0) ) + IF( (i_subfr == 0) && (GE_16(t0,t0_fr1))) { *pit_frac = 0; move16(); @@ -784,7 +782,7 @@ Word16 pitch_fr4_fx( /* o : chosen integer pitch lag */ move16(); test(); test(); - IF (((i_subfr == 0) && (sub(t0,t0_fr2) >= 0)) || (sub(t0_fr2,pit_min) == 0)) + IF (((i_subfr == 0) && (GE_16(t0,t0_fr2)))||(EQ_16(t0_fr2,pit_min))) { step = 2; move16(); /* 1/2 subsample resolution */ @@ -792,7 +790,7 @@ Word16 pitch_fr4_fx( /* o : chosen integer pitch lag */ move16(); } - IF (sub(t0,t0_min) == 0) /* Limit case */ + IF (EQ_16(t0,t0_min)) /* Limit case */ { fraction = 0; move16(); @@ -805,7 +803,7 @@ Word16 pitch_fr4_fx( /* o : chosen integer pitch lag */ FOR(i = add(fraction, step); i <= 3; i = (Word16) (i + step)) { temp = Interpol_4( &corr[t0], i); - IF (sub(temp,cor_max) > 0) + IF (GT_16(temp,cor_max)) { cor_max = temp; move16(); @@ -818,7 +816,7 @@ Word16 pitch_fr4_fx( /* o : chosen integer pitch lag */ FOR (i = 0; i <= 3; i = (Word16) (i + step)) { temp = Interpol_4( &corr[t1], i); - IF (sub(temp,cor_max) > 0) + IF (GT_16(temp,cor_max)) { cor_max = temp; move16(); @@ -919,7 +917,7 @@ void norm_corr_fx( ncorr[t] = round_fx(L_tmp); /* update the filtered excitation excf[] for the next iteration */ - IF (sub(t, t_max) != 0) + IF (NE_16(t, t_max)) { k--; FOR (i = (Word16) (L_subfr - 1); i > 0; i--) @@ -957,14 +955,14 @@ void pit_Q_enc_fx( { Word16 pitch_index; - IF( sub(nBits,10) == 0 ) /* absolute encoding with 10 bits */ + IF( EQ_16(nBits,10)) /* absolute encoding with 10 bits */ { IF( limit_flag == 0 ) { /* pitch_index = T0*4 + T0_frac - (PIT_MIN*4);*/ pitch_index = sub(add(shl(T0 , 2), T0_frac), (PIT_MIN*4)); } - ELSE IF( sub(limit_flag,1) == 0 ) + ELSE IF( EQ_16(limit_flag,1)) { /*pitch_index = T0*4 + T0_frac - (PIT_MIN_EXTEND*4);*/ pitch_index = sub(add(shl(T0 , 2),T0_frac),(PIT_MIN_EXTEND*4)); @@ -975,7 +973,7 @@ void pit_Q_enc_fx( pitch_index = sub(add(shl(T0 , 2) ,T0_frac) , (PIT_MIN_DOUBLEEXTEND*4)); } } - ELSE IF( sub(nBits,9) == 0 ) /* absolute encoding with 9 bits */ + ELSE IF( EQ_16(nBits,9)) /* absolute encoding with 9 bits */ { pitch_index = abs_pit_enc_fx( 4, limit_flag, T0, T0_frac ); @@ -985,7 +983,7 @@ void pit_Q_enc_fx( limit_T0_fx( L_FRAME, delta, pit_flag, 0, T0, 0, T0_min, T0_max ); /* T0_frac==0 to keep IO with AMR-WB */ } } - ELSE IF( sub(nBits,8) == 0 ) /* absolute encoding with 8 bits */ + ELSE IF( EQ_16(nBits,8)) /* absolute encoding with 8 bits */ { pitch_index = abs_pit_enc_fx( 2, limit_flag, T0, T0_frac ); @@ -995,13 +993,13 @@ void pit_Q_enc_fx( limit_T0_fx( L_FRAME, delta, pit_flag, 0, T0, 0, T0_min, T0_max ); /* T0_frac==0 to keep IO with AMR-WB */ } } - ELSE IF( sub(nBits,6) == 0 ) /* relative encoding with 6 bits */ + ELSE IF( EQ_16(nBits,6)) /* relative encoding with 6 bits */ { pitch_index = delta_pit_enc_fx( 4, T0, T0_frac, *T0_min ); } - ELSE IF( sub(nBits,5) == 0 ) /* relative encoding with 5 bits */ + ELSE IF( EQ_16(nBits,5)) /* relative encoding with 5 bits */ { - IF( sub(delta,8) == 0 ) + IF( EQ_16(delta,8)) { pitch_index = delta_pit_enc_fx( 2, T0, T0_frac, *T0_min ); } @@ -1012,7 +1010,7 @@ void pit_Q_enc_fx( } ELSE /* nBits == 4 ) */ /* relative encoding with 4 bits */ { - IF( sub(delta,8) == 0 ) + IF( EQ_16(delta,8)) { pitch_index = delta_pit_enc_fx( 0, T0, T0_frac, *T0_min ); } @@ -1053,10 +1051,10 @@ void pit16k_Q_enc_fx( { Word16 pitch_index; - IF( sub(nBits,10) == 0 ) /* absolute encoding with 10 bits */ + IF( EQ_16(nBits,10)) /* absolute encoding with 10 bits */ { { - IF( sub(T0,PIT16k_FR2_EXTEND_10b) < 0) + IF( LT_16(T0,PIT16k_FR2_EXTEND_10b)) { /*pitch_index = T0*4 + T0_frac - (PIT16k_MIN_EXTEND*4);*/ pitch_index = add(shl(T0 , 2) , sub(T0_frac , (PIT16k_MIN_EXTEND*4))); @@ -1070,7 +1068,7 @@ void pit16k_Q_enc_fx( push_indice_fx( st_fx, IND_PITCH, pitch_index, nBits ); } - ELSE IF( sub(nBits,9) == 0 ) /* absolute encoding with 9 bits */ + ELSE IF( EQ_16(nBits,9)) /* absolute encoding with 9 bits */ { { /*-------------------------------------------------------------------* @@ -1081,12 +1079,12 @@ void pit16k_Q_enc_fx( * PIT16k_FR1_EXTEND_9b to PIT16k_MAX_EXTEND resolution 1 (frac = 0) *-------------------------------------------------------------------*/ - IF( sub(T0,PIT16k_FR2_EXTEND_9b) < 0) + IF( LT_16(T0,PIT16k_FR2_EXTEND_9b)) { /*pitch_index = T0*4 + T0_frac - (PIT16k_MIN_EXTEND*4);*/ pitch_index = add(shl(T0 , 2) , sub(T0_frac , (PIT16k_MIN_EXTEND*4))); } - ELSE IF( sub(T0,PIT16k_FR1_EXTEND_9b) < 0 ) + ELSE IF( LT_16(T0,PIT16k_FR1_EXTEND_9b)) { /*pitch_index = T0*2 + (T0_frac>>1) - (PIT16k_FR2_EXTEND_9b*2) + ((PIT16k_FR2_EXTEND_9b-PIT16k_MIN_EXTEND)*4);*/ pitch_index = add(sub(add(shl(T0,1),shr(T0_frac,1)),(PIT16k_FR2_EXTEND_9b*2)),((PIT16k_FR2_EXTEND_9b-PIT16k_MIN_EXTEND)*4)); @@ -1150,7 +1148,7 @@ void Mode2_pit_encode( /* Pitch flag */ pit_flag = i_subfr; move16(); - if ( sub(i_subfr,(2*L_SUBFR)) == 0) + if ( EQ_16(i_subfr,(2*L_SUBFR))) { pit_flag = 0; move16(); @@ -1171,7 +1169,7 @@ void Mode2_pit_encode( move16(); } - ELSE IF(sub(coder_type,1) == 0) /* 8/4/4/4 (EVS) */ + ELSE IF(EQ_16(coder_type,1)) /* 8/4/4/4 (EVS) */ { IF (i_subfr == 0) { @@ -1195,7 +1193,7 @@ void Mode2_pit_encode( } } - ELSE IF(sub(coder_type,2) == 0) /* 8/5/8/5 (EVS) */ + ELSE IF(EQ_16(coder_type,2)) /* 8/5/8/5 (EVS) */ { IF (i_subfr == 0) { @@ -1222,11 +1220,11 @@ void Mode2_pit_encode( Mode2_delta_pit_enc( *T0, *T0_frac, shr(pit_res_max,1), *T0_min, *T0_min_frac, pt_indice ); } } - ELSE IF(sub(coder_type,3) == 0) /* 9/6/6/6 (HRs- VC) */ + ELSE IF(EQ_16(coder_type,3)) /* 9/6/6/6 (HRs- VC) */ { Word16 pit_res_max2 = pit_res_max; - if ( sub(pit_min,PIT_MIN_16k)==0 ) + if ( EQ_16(pit_min,PIT_MIN_16k)) { pit_res_max2 = shr(pit_res_max, 1); } @@ -1255,12 +1253,12 @@ void Mode2_pit_encode( ELSE IF(coder_type == 4) /* 9/6/9/6 (AMRWB) */ { Word16 pit_res_max2 = pit_res_max; - if ( sub(pit_min,PIT_MIN_16k) == 0 ) + if ( EQ_16(pit_min,PIT_MIN_16k)) { pit_res_max2 = shr(pit_res_max,1); } test(); - IF ( (i_subfr == 0) || sub(i_subfr,shl(L_SUBFR,1)) == 0 ) + IF ( (i_subfr == 0) || EQ_16(i_subfr,shl(L_SUBFR,1))) { limit_T0_voiced2( pit_res_max2, T_op, T0_min, T0_min_frac, T0_max, T0_max_frac, pit_min, pit_max, i_subfr ); } @@ -1279,7 +1277,7 @@ void Mode2_pit_encode( Mode2_delta_pit_enc( *T0, *T0_frac, pit_res_max2, *T0_min, *T0_min_frac, pt_indice ); } } - ELSE IF(sub(coder_type,8) == 0) /* 8/5/5/5 (RF all pred mode) */ + ELSE IF(EQ_16(coder_type,8)) /* 8/5/5/5 (RF all pred mode) */ { IF (i_subfr == 0) { @@ -1301,7 +1299,7 @@ void Mode2_pit_encode( Mode2_delta_pit_enc( *T0, *T0_frac, shr(pit_res_max,1), *T0_min, *T0_min_frac, pt_indice ); } } - ELSE IF(sub(coder_type,9) == 0) /* 8/0/8/0 (RF mode Gen pred) */ + ELSE IF(EQ_16(coder_type,9)) /* 8/0/8/0 (RF mode Gen pred) */ { IF (i_subfr == 0) { @@ -1347,7 +1345,7 @@ static void limit_T0_voiced2( res2 = res; move16(); - if(sub(res,6) == 0) + if(EQ_16(res,6)) { res2 =shr(res2,1); } @@ -1362,7 +1360,7 @@ static void limit_T0_voiced2( temp1 = sub(i_mult2(T_op[1],res),32); } - IF (sub(T_op[0],T_op[1])<0) + IF (LT_16(T_op[0],T_op[1])) { t = sub(i_mult2(T_op[0],res),16); } @@ -1371,13 +1369,13 @@ static void limit_T0_voiced2( t = sub(i_mult2(T_op[1],res),16); } - if (sub(temp1,t)<0) + if (LT_16(temp1,t)) { temp1 = t; } temp2 = mult(temp1,inv_T0_res[res2]); - if(sub(res,6) == 0) + if(EQ_16(res,6)) { temp2 = shr(temp2,1); } @@ -1388,7 +1386,7 @@ static void limit_T0_voiced2( *T0_min_frac = sub(temp1,i_mult2(temp2,res)); move16(); - IF ( sub(*T0_min,pit_min) < 0) + IF ( LT_16(*T0_min,pit_min)) { *T0_min = pit_min; move16(); @@ -1408,7 +1406,7 @@ static void limit_T0_voiced2( t = add(i_mult2(T_op[0],res),add(15,res)); } - if (sub(temp1,t)>0) + if (GT_16(temp1,t)) { temp1 = t; move16(); @@ -1421,7 +1419,7 @@ static void limit_T0_voiced2( *T0_max_frac = sub(temp1, i_mult2(temp2,res)); - IF ( sub(*T0_max,pit_max) > 0) + IF ( GT_16(*T0_max,pit_max)) { *T0_max = pit_max; *T0_max_frac = sub(res,1); @@ -1429,7 +1427,7 @@ static void limit_T0_voiced2( temp1 = add(sub(i_mult2(*T0_max,res),64),res); temp2 = mult(temp1,inv_T0_res[res2]); - if(sub(res,6) == 0) + if(EQ_16(res,6)) { temp2 = shr(temp2,1); } @@ -1464,11 +1462,11 @@ void Mode2_abs_pit_enc( pit_res_max_half = shr(pit_res_max,1); - IF (sub(T0, pit_fr2) < 0) + IF (LT_16(T0, pit_fr2)) { **pt_indice = add( i_mult2(T0, pit_res_max), sub( T0_frac, i_mult2(pit_min, pit_res_max) ) ); } - ELSE IF (sub(T0, pit_fr1) < 0) + ELSE IF (LT_16(T0, pit_fr1)) { **pt_indice = add( sub( add(i_mult2(T0,pit_res_max_half), T0_frac), i_mult2(pit_fr2,pit_res_max_half) ), i_mult2(sub(pit_fr2, pit_min), pit_res_max) ); } diff --git a/lib_enc/pitch_ol.c b/lib_enc/pitch_ol.c index 5f256b5ffb98d95999a202f19b042fb702a16532..ad43566358fe3666dbcb08ec5099b042d10d3e17 100644 --- a/lib_enc/pitch_ol.c +++ b/lib_enc/pitch_ol.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ @@ -9,8 +9,6 @@ #include "cnst_fx.h" #include "basop_util.h" #include "stl.h" -#include "wmc_auto.h" - #include "rom_com_fx.h" #include "rom_enc_fx.h" @@ -241,7 +239,7 @@ void pitch_ol_fx( sec_length1 = sec_length1_12k8_fx; test(); - if ((sub(last_class,VOICED_TRANSITION) < 0) && (sub(bwidth,NB) != 0)) + if ((LT_16(last_class,VOICED_TRANSITION))&&(NE_16(bwidth,NB))) { /*reset last pitch reinforcement in case of unvoiced or transitions: it avoids some pitch doublings*/ *old_thres = 0; @@ -254,8 +252,8 @@ void pitch_ol_fx( test(); test(); test(); - IF ( ( (sub(bwidth,NB) != 0) && (sub(*old_pitch,PIT_MIN) > 0 ) ) || - ( (sub(bwidth,NB) == 0) && ( (sub(*old_pitch,PIT_MIN2_1) > 0) || (sub(*old_thres,3277) < 0) ) ) ) /* 0.1 inQ15*/ + IF ( ( (NE_16(bwidth,NB))&&(GT_16(*old_pitch,PIT_MIN)))|| + ( (EQ_16(bwidth,NB) ) && ( (GT_16(*old_pitch,PIT_MIN2_1) ) || (LT_16(*old_thres,3277) ) ) ) ) /* 0.1 inQ15*/ { pit_min = PIT_MIN/OPL_DECIM; move16(); @@ -375,7 +373,7 @@ void pitch_ol_fx( pt_exp3 = scaled_buf_exp + 2*(DELTA_COH-1) + len_x; pt_exp4 = pt_exp3; - IF( sub(i,NHFR-1) < 0 ) /* First two half-frames (current frame) */ + IF( LT_16(i,NHFR-1)) /* First two half-frames (current frame) */ { pt3 = pt1; pt5 = pt1; @@ -403,7 +401,8 @@ void pitch_ol_fx( /* Reduce complexity (length of 'enr2' section is equal or larger than 'enr') */ pt5 = pt3; - enr2 = L_add(enr,0); /* sets to 'enr' in 1 clock */ + enr2 = enr; /* sets to 'enr' in 1 clock */ + move32(); /* 2nd set */ k = (Word16)(pt1 - pt5); @@ -534,7 +533,8 @@ void pitch_ol_fx( /* Reduce complexity (length of 'enr2' section is equal or larger than 'enr') */ pt5 = pt3; - enr2 = L_add(enr,0); + enr2 = enr; + move16(); /* 2nd set */ k = (Word16)(pt5 - pt6); @@ -755,7 +755,7 @@ void pitch_ol_fx( /* 1st set */ offset_la = 0; move16(); - if( sub(i,2)==0 ) + if( EQ_16(i,2)) { offset_la = sub(L_LOOK_12k8/OPL_DECIM,len[j]); } @@ -763,7 +763,7 @@ void pitch_ol_fx( /* 2nd set */ offset_la1 = 0; move16(); - if( sub(i,2)==0 ) + if( EQ_16(i,2)) { offset_la1 = sub(L_LOOK_12k8/OPL_DECIM,len1[j]); } @@ -857,7 +857,7 @@ void pitch_ol_fx( find_mult_fx(&fac, pitchX[i][2], pitchX[i][3], pit_max[7], &scaledX[i][2], old_pitch, old_corr, DELTA0, STEP); /* Multiples in 3rd section */ find_mult_fx(&fac, pitchX[i][1], pitchX[i][2], pit_max[5], &scaledX[i][1], old_pitch, old_corr, DELTA0, STEP); /* Multiples in 2nd section */ test(); - IF((sect0==0) && sub(shl(pitchX[i][0],1),pit_min_coding)>=0) + IF((sect0==0) && GE_16(shl(pitchX[i][0],1),pit_min_coding)) { find_mult_fx( &fac, pitchX[i][0], pitchX[i][1], pit_max[3], &scaledX[i][0], old_pitch, old_corr, DELTA0, STEP ); /* Multiples in 2nd section */ } @@ -866,7 +866,7 @@ void pitch_ol_fx( find_mult_fx(&fac, pitchX[i][NSECT+2], pitchX[i][NSECT+3], pit_max[7], &scaledX[i][NSECT+2], old_pitch, old_corr, DELTA0, STEP); /* Multiples in 3rd section */ find_mult_fx(&fac, pitchX[i][NSECT+1], pitchX[i][NSECT+2], pit_max[6], &scaledX[i][NSECT+1], old_pitch, old_corr, DELTA0, STEP); /* Multiples in 2nd section */ test(); - IF((sect0==0) && sub(shl(pitchX[i][NSECT+0],1),pit_min_coding)>=0) + IF((sect0==0) && GE_16(shl(pitchX[i][NSECT+0],1),pit_min_coding)) { find_mult_fx( &fac, pitchX[i][NSECT+0], pitchX[i][NSECT+1], pit_max[4], &scaledX[i][NSECT+0], old_pitch, old_corr, DELTA0, STEP ); /* Multiples in 2nd section */ } @@ -877,7 +877,7 @@ void pitch_ol_fx( find_mult_fx(&fac, pitchX[i][2], pitchX[i][3], pit_max[7], &scaledX[i][2], old_pitch, old_corr, 2, 2); /* Multiples in 3rd section */ find_mult_fx(&fac, pitchX[i][1], pitchX[i][2], pit_max[5], &scaledX[i][1], old_pitch, old_corr, DELTA0, STEP); /* Multiples in 2nd section */ test(); - IF((sect0==0) && sub(shl(pitchX[i][0],1),pit_min_coding)>=0) + IF((sect0==0) && GE_16(shl(pitchX[i][0],1),pit_min_coding)) { find_mult_fx( &fac, pitchX[i][0], pitchX[i][1], pit_max[3], &scaledX[i][0], old_pitch, old_corr, DELTA0, STEP ); /* Multiples in 2nd section */ } @@ -886,7 +886,7 @@ void pitch_ol_fx( find_mult_fx(&fac, pitchX[i][NSECT+2], pitchX[i][NSECT+3], pit_max[7], &scaledX[i][NSECT+2], old_pitch, old_corr, 2, 2); /* Multiples in 3rd section */ find_mult_fx(&fac, pitchX[i][NSECT+1], pitchX[i][NSECT+2], pit_max[6], &scaledX[i][NSECT+1], old_pitch, old_corr, DELTA0, STEP); /* Multiples in 2nd section */ test(); - IF((sect0==0) && sub(shl(pitchX[i][NSECT+0],1),pit_min_coding)>=0) + IF((sect0==0) && GE_16(shl(pitchX[i][NSECT+0],1),pit_min_coding)) { find_mult_fx( &fac, pitchX[i][NSECT+0], pitchX[i][NSECT+1], pit_max[4], &scaledX[i][NSECT+0], old_pitch, old_corr, DELTA0, STEP ); /* Multiples in 2nd section */ /* Multiples in 2nd section */ } @@ -944,13 +944,13 @@ void pitch_ol_fx( ind1 = add(maximum_fx(scaledX[i]+add_sect0, sub_sect0, &ftmp), add_sect0); ind1_corX = add(maximum_fx(corX[i]+add_sect0, sub_sect0, &ftmp), add_sect0); - if ( sub(scaledX[i][ind1],scaledX[i][ind]) > 0 ) + if ( GT_16(scaledX[i][ind1],scaledX[i][ind])) { ind = ind1; move16(); } test(); - if ( Opt_SC_VBR && sub(corX[i][ind1_corX],corX[i][ind_corX]) > 0 ) + if ( Opt_SC_VBR && GT_16(corX[i][ind1_corX],corX[i][ind_corX])) { ind_corX = ind1_corX; move16(); @@ -958,9 +958,9 @@ void pitch_ol_fx( test(); test(); test(); - IF (Opt_SC_VBR && (sub(mult(pitchX[i][ind], 13107 /*0.4 in Q15*/),pitchX[i][ind_corX]) < 0) && - (sub(mult(pitchX[i][ind], 19661 /*0.6 in Q15*/),pitchX[i][ind_corX]) > 0) && - (sub(corX[i][ind_corX],29491/*0.9 in Q15*/)>=0)) + IF (Opt_SC_VBR && (LT_16(mult(pitchX[i][ind], 13107 /*0.4 in Q15*/),pitchX[i][ind_corX]))&& + (GT_16(mult(pitchX[i][ind], 19661 /*0.6 in Q15*/),pitchX[i][ind_corX]) ) && + (GE_16(corX[i][ind_corX],29491/*0.9 in Q15*/))) { pitch[i] = pitchX[i][ind_corX]; move16(); @@ -996,7 +996,7 @@ void pitch_ol_fx( test(); test(); test(); - IF ((coh_flag == 0) || (coh_flag1 == 0) || (sub(cor_mean, CORR_TH0) < 0) || (sub(relE, THR_relE) < 0)) + IF ((coh_flag == 0) || (coh_flag1 == 0) || (LT_16(cor_mean, CORR_TH0))||(LT_16(relE,THR_relE))) { /* Reset the threshold */ *old_thres = 0; @@ -1012,7 +1012,7 @@ void pitch_ol_fx( *old_thres = s_min(*old_thres, THRES3); move16(); - IF (sub(voicing[1], voicing[0]) > 0) + IF (GT_16(voicing[1], voicing[0])) { *old_corr = voicing[1]; move16(); @@ -1055,13 +1055,13 @@ void pitch_ol_fx( } cnt = add(cnt, coh_flag); } - if (sub(cnt, 2) == 0) + if (EQ_16(cnt, 2)) { /* *delta_pit /= 2; */ *delta_pit = shr(*delta_pit, 1); move16(); } - IF (sub(cnt, 3) == 0) + IF (EQ_16(cnt, 3)) { k = *delta_pit; move16(); @@ -1121,9 +1121,9 @@ static void find_mult_fx( pit_min = shl(pitch0, 1); /* double the higher section pitch */ - WHILE (sub(pit_min, add(pit_max0, delta)) <= 0) /* check for section boundary */ + WHILE (LE_16(pit_min, add(pit_max0, delta))) /* check for section boundary */ { - IF (sub(abs_s(sub(pit_min, pitch1)), delta) <= 0) /* if multiple in the allowed range */ + IF (LE_16(abs_s(sub(pit_min, pitch1)), delta)) /* if multiple in the allowed range */ { L_tmp = L_shl(L_mult(*corr, *fac), 3); @@ -1167,7 +1167,7 @@ static void pitch_neighbour_fx( { K = 3; move16(); - if (sub(k, (NSECT-1)) == 0) /* the number of tests depends on the section */ + if (EQ_16(k, (NSECT-1))) /* the number of tests depends on the section */ { K = 2; move16(); @@ -1178,9 +1178,9 @@ static void pitch_neighbour_fx( /* Compare pitch values of the present frame */ FOR (j=0; j < K; j++) /* Verify pitch coherence with neighbours (including past pitch) */ { - IF (sub(j, i) != 0) /* Exclude itself, of course */ + IF (NE_16(j, i)) /* Exclude itself, of course */ { - IF (sub(corr_tmp[j], CORR_TH1) >= 0) /* reinforcement can happen only if the correlation is high enough */ + IF (GE_16(corr_tmp[j], CORR_TH1)) /* reinforcement can happen only if the correlation is high enough */ { delta = abs_s(sub(pitch[i][k], pitch_tmp[j])); /* Find difference of pitch values */ coh_flag = pitch_coherence_fx(pitch[i][k], pitch_tmp[j], COH_FAC, DELTA_COH); @@ -1188,7 +1188,7 @@ static void pitch_neighbour_fx( IF (coh_flag != 0) { /* Favour stability across sections, favour closer values */ - IF (sub(ind_tmp[j], k) == 0) + IF (EQ_16(ind_tmp[j], k)) { /* corr[i][k] *= ( -thres1[j]/DELTA1 * delta + thres1[j]+1 ); */ /* operands are Q15, except corr[i][k] which is Q12 */ @@ -1217,7 +1217,7 @@ static void pitch_neighbour_fx( { K = 3; move16(); - if (sub(k, (NSECT-1)) == 0) /* the number of tests depends on the section */ + if (EQ_16(k, (NSECT-1))) /* the number of tests depends on the section */ { K = 2; move16(); @@ -1228,9 +1228,9 @@ static void pitch_neighbour_fx( /* Compare pitch values of the present frame */ FOR (j=0; j < K; j++)/* Verify pitch coherence with neighbours (including past pitch) */ { - IF (sub(j, i) != 0)/* Exclude itself, of course */ + IF (NE_16(j, i))/* Exclude itself, of course */ { - IF (sub(corr_tmp[j+NHFR], CORR_TH1) >= 0)/* reinforcement can happen only if the correlation is high enough */ + IF (GE_16(corr_tmp[j+NHFR], CORR_TH1))/* reinforcement can happen only if the correlation is high enough */ { delta = abs_s(sub(pitch[i][NSECT+k], pitch_tmp[j+NHFR])); /* Find difference of pitch values */ coh_flag = pitch_coherence_fx(pitch[i][NSECT+k], pitch_tmp[j+NHFR], COH_FAC, DELTA_COH); @@ -1238,7 +1238,7 @@ static void pitch_neighbour_fx( IF (coh_flag != 0) { /* Favour stability across sections, favour closer values */ - IF (sub(ind_tmp[j+NHFR], add(NSECT, k)) == 0) + IF (EQ_16(ind_tmp[j+NHFR], add(NSECT, k))) { /* corr[i][k] *= ( -thres1[j+NHFR]/DELTA1 * delta + thres1[j+NHFR]+1 ); */ /* operands are Q15, except corr[i][NSECT+k] which is Q12 */ @@ -1284,8 +1284,8 @@ static Word16 pitch_coherence_fx( pc = 0; move16(); test(); - if( (sub(larger, extract_h(L_shl(L_mult(fac_max, smaller), 3))) <= 0) && /* Changed to <= to keep BE */ - (sub(sub(larger, smaller), diff_max) < 0)) + if( (LE_16(larger, extract_h(L_shl(L_mult(fac_max, smaller), 3))))&& /* Changed to <= to keep BE */ + (LT_16(sub(larger, smaller), diff_max))) { pc = 1; move16(); @@ -1367,14 +1367,14 @@ static Word32 Dot_product12_OL( /* o : Q31: normalized result (1 < val <= -1) * Word32 L_sum, L_sum2; L_sum = L_mac(1, x[0], y[0]); - IF (sub(lg, lg2) <= 0) + IF (LE_16(lg, lg2)) { FOR (i = 1; i < lg; i++) { L_sum = L_mac(L_sum, x[i], y[i]); } /* sets to 'L_sum' in 1 clock */ - L_sum2 = L_add(0, L_sum); + L_sum2 = L_sum; move32(); FOR (; i < lg2; i++) { L_sum2 = L_mac(L_sum2, x[i], y[i]); @@ -1387,7 +1387,7 @@ static Word32 Dot_product12_OL( /* o : Q31: normalized result (1 < val <= -1) * L_sum = L_mac(L_sum, x[i], y[i]); } /* sets to 'L_sum' in 1 clock */ - L_sum2 = L_add(0, L_sum); + L_sum2 = L_sum; move32(); FOR (; i < lg; i++) { L_sum = L_mac(L_sum, x[i], y[i]); @@ -1429,14 +1429,14 @@ static Word32 Dot_product12_OL_back(/* o : Q31: normalized result (1 < val <= - Word32 L_sum, L_sum2; L_sum = L_mac(1, x[0], y[0]); - IF (sub(lg, lg2) <= 0) + IF (LE_16(lg, lg2)) { FOR (i = 1; i < lg; i++) { L_sum = L_mac(L_sum, x[-i], y[-i]); } /* sets to 'L_sum' in 1 clock */ - L_sum2 = L_add(0, L_sum); + L_sum2 = L_sum; move32(); FOR (; i < lg2; i++) { L_sum2 = L_mac(L_sum2, x[-i], y[-i]); @@ -1449,7 +1449,7 @@ static Word32 Dot_product12_OL_back(/* o : Q31: normalized result (1 < val <= - L_sum = L_mac(L_sum, x[-i], y[-i]); } /* sets to 'L_sum' in 1 clock */ - L_sum2 = L_add(0, L_sum); + L_sum2 = L_sum; move32(); FOR (; i < lg; i++) { L_sum = L_mac(L_sum, x[-i], y[-i]); @@ -1499,7 +1499,7 @@ void pitchDoubling_det( /* T= pitch_ol[0]/m; */ T = mult(pitch_ol[0],One_div_fx[m-1]); - IF(sub(T,PIT_MIN_12k8)>= 0) + IF(GE_16(T,PIT_MIN_12k8)) { pitch_ol2_fx( PIT_MIN_SHORTER, T, &(new_op_fr[0]), &new_voicing[0], 0, wspeech, 2 ); pitch_ol2_fx( PIT_MIN_SHORTER, T, &(new_op_fr[1]), &new_voicing[1], L_SUBFR, wspeech, 2 ); @@ -1522,7 +1522,7 @@ void pitchDoubling_det( /* T= pitch_ol[1]/m; */ T = mult(pitch_ol[1],One_div_fx[m-1]); - IF(sub(T,PIT_MIN_12k8)>= 0) + IF(GE_16(T,PIT_MIN_12k8)) { pitch_ol2_fx( PIT_MIN_SHORTER, T, &(new_op_fr[0]), &new_voicing[0], 2*L_SUBFR, wspeech, 2 ); pitch_ol2_fx( PIT_MIN_SHORTER, T, &(new_op_fr[1]), &new_voicing[1], 3*L_SUBFR, wspeech, 2 ); diff --git a/lib_enc/pitch_ol2_fx.c b/lib_enc/pitch_ol2_fx.c index 257b6e2a2a3c129226b5830722f13db871ebcf3d..c670bf1ee54487c1f214a98d1136bcf4f8cd7ea4 100644 --- a/lib_enc/pitch_ol2_fx.c +++ b/lib_enc/pitch_ol2_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -9,8 +9,6 @@ #include "rom_dec_fx.h" #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*-------------------------------------------------------------------* * Local constants @@ -85,7 +83,7 @@ void pitch_ol2_fx( move16(); FOR (t=add(t0_min, 1); t<=t0_max; t++) { - if (sub(*pt_cor_fx, cor_max_fx) > 0) + if (GT_16(*pt_cor_fx, cor_max_fx)) { t1s = t; move16(); @@ -108,7 +106,7 @@ void pitch_ol2_fx( fraction = 1; move16(); - IF (sub(t0s, t0_min) != 0) /* Process negative fractions */ + IF (NE_16(t0s, t0_min)) /* Process negative fractions */ { t0s = sub(t0s,1); cor_max_fx = Interpol_4(&pt_cor_fx[t0s], fraction); @@ -116,7 +114,7 @@ void pitch_ol2_fx( FOR (i=add(fraction, step); i<=3; i+=step) { temp_fx = Interpol_4(&pt_cor_fx[t0s], i); - if (sub(temp_fx, cor_max_fx) > 0) + if (GT_16(temp_fx, cor_max_fx)) { fraction = i; move16(); @@ -136,7 +134,7 @@ void pitch_ol2_fx( temp_fx = Interpol_4(&pt_cor_fx[t1s], i); move16(); - IF (sub(temp_fx,cor_max_fx) > 0) + IF (GT_16(temp_fx,cor_max_fx)) { cor_max_fx = temp_fx; move16(); @@ -150,7 +148,7 @@ void pitch_ol2_fx( *pitch_fr_fx = shl(add(shl(t0s, 2), fraction), 4); move16(); /*Q7*/ - IF( L_sub(t1, 1L) != 0 ) + IF( NE_32(t1, 1L)) { pred_lt4(pt_wsp_fx, wsp_fr_fx, t0s, fraction, L_SUBFR, pitch_inter4_1, 4, PIT_UP_SAMP); @@ -275,17 +273,17 @@ void StableHighPitchDetect_fx( { tmp = abs_s(tmp); tmp = div_s(16384,tmp); /*Q(15+exp)*/ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF diff = L_negate( L_shr(Mult_32_16(diff,tmp),sub(exp+7 ,31) )); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON diff16 = round_fx(diff); } ELSE { tmp = div_s(16384,tmp); /*Q(15+exp)*/ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF diff = L_shr(Mult_32_16(diff,tmp),sub(exp+7 ,31)); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON diff16 = round_fx(diff); } } @@ -295,14 +293,14 @@ void StableHighPitchDetect_fx( } test(); test(); - IF( L_sub(*diff_sm , -1280)<0 && L_sub( *energy_sm , 4928)< 0 && sub( diff16 , - 26214) <0 ) + IF( LT_32(*diff_sm , -1280)&<_32(*energy_sm,4928)&<_16(diff16,-26214)) { *predecision_flag = 1; move16(); } test(); test(); - if( L_sub(*diff_sm ,1280)>0 && L_sub( *energy_sm , 10624)>0 && sub(diff16 ,16384)>0 ) + if( GT_32(*diff_sm ,1280)&>_32(*energy_sm,10624)&>_16(diff16,16384)) { *predecision_flag = 0; move16(); @@ -320,13 +318,13 @@ void StableHighPitchDetect_fx( L_tmp = L_mac(L_tmp, *LF_EnergyRatio_sm,30720); *LF_EnergyRatio_sm = round_fx(L_tmp); test(); - if( sub(*LF_EnergyRatio_sm , 4480)>0 || sub( ratio ,6400)>0 ) + if( GT_16(*LF_EnergyRatio_sm , 4480)||GT_16(ratio,6400)) { *predecision_flag=1; move16(); } - if( sub(*LF_EnergyRatio_sm , 2048)<0 ) + if( LT_16(*LF_EnergyRatio_sm , 2048)) { *predecision_flag=0; move16(); @@ -346,7 +344,7 @@ void StableHighPitchDetect_fx( { energy1 = Dot_product( pt_wsp, pt_wsp-T, L_SUBFR ); test(); - IF( (L_sub(energy1,cor_max)>0) || (sub(T,pit_min) ==0) ) + IF( (GT_32(energy1,cor_max))||(EQ_16(T,pit_min))) { cor_max = L_add(energy1, 0); Tp = T; @@ -377,8 +375,8 @@ void StableHighPitchDetect_fx( test(); *flag_spitch = 0; move16(); - IF( (sub(localVAD,1)==0) && (sub(*predecision_flag,1)==0) && - (sub(*voicing0_sm,16384)>0) && (sub(*voicing0_sm, mult_r(*voicing_sm,21299))>0 )) + IF( (EQ_16(localVAD,1))&&(EQ_16(*predecision_flag,1))&& + (GT_16(*voicing0_sm,16384)) && (GT_16(*voicing0_sm, mult_r(*voicing_sm,21299)) )) { *flag_spitch = 1; move16(); diff --git a/lib_enc/plc_enc_ext.c b/lib_enc/plc_enc_ext.c index 6e2a9645990f013664c02f1e0b7d6b8b021170da..19cbf7daaf3e4587c7c102d974b0fe49afe493bb 100644 --- a/lib_enc/plc_enc_ext.c +++ b/lib_enc/plc_enc_ext.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include #include "stl.h" -#include "wmc_auto.h" - #include "cnst_fx.h" #include "stat_enc_fx.h" #include "prot_fx.h" @@ -49,7 +47,7 @@ void open_PLC_ENC_EVS( set16_fx(hPlcExt->lsf_adaptive_mean_14Q1,0,M); hPlcExt->stab_fac_Q15 = 0; move16(); - IF( L_sub(sampleRate,12800)==0 ) + IF( EQ_32(sampleRate,12800)) { hPlcExt->T0_4th = L_SUBFR; move16(); @@ -104,9 +102,9 @@ void gPLC_encInfo (HANDLE_PLC_ENC_EVS self, test(); test(); test(); - IF ( ( sub(modeBandwidth, WB) == 0 && L_sub(modeBitrate, 24400) == 0 ) || - ( sub(modeBandwidth, SWB) == 0 && L_sub(modeBitrate, 24400) == 0 ) || - ( sub(modeBandwidth, FB) == 0 && L_sub(modeBitrate, 24400) == 0 ) ) + IF ( ( EQ_16(modeBandwidth, WB)&&EQ_32(modeBitrate,24400))|| + ( EQ_16(modeBandwidth, SWB) && EQ_32(modeBitrate, 24400) ) || + ( EQ_16(modeBandwidth, FB) && EQ_32(modeBitrate, 24400) ) ) { self->enableGplc = 1; move16(); @@ -115,8 +113,8 @@ void gPLC_encInfo (HANDLE_PLC_ENC_EVS self, test(); test(); test(); - IF ( (sub(old_clas, VOICED_CLAS)==0 || sub(old_clas, ONSET)==0) && - (sub(coder_type, VOICED)==0 || sub(coder_type, GENERIC)==0 ) ) + IF ( (EQ_16(old_clas, VOICED_CLAS)||EQ_16(old_clas,ONSET))&& + (EQ_16(coder_type, VOICED) || EQ_16(coder_type, GENERIC) ) ) { self->nBits = NBITS_GACELP; move16(); diff --git a/lib_enc/ppp_enc_fx.c b/lib_enc/ppp_enc_fx.c index 21dda7deedf6a804afaf67c19ee336edd79b2cbd..e5f2c1847ccf8857573c9be15d817d1d02bf278a 100644 --- a/lib_enc/ppp_enc_fx.c +++ b/lib_enc/ppp_enc_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -7,8 +7,6 @@ #include "prot_fx.h" #include "rom_com_fx.h" #include "stl.h" -#include "wmc_auto.h" - /*=======================================================================================*/ /* FUNCTION : ppp_quarter_encoder_fx() */ @@ -160,7 +158,7 @@ Word16 ppp_quarter_encoder_fx( move16(); test(); - IF (sub(add(tmp_fx,12),28)>0 || add(tmp_fx,12)<0) + IF (GT_16(add(tmp_fx,12),28)||LT_16(tmp_fx,-12)) { tmp_fx = 0; move16(); @@ -203,8 +201,8 @@ void set_ppp_mode_fx( test(); test(); - IF ( sub( *vad_flag, 1) == 0 && - ( sub( noisy_speech_HO , 1 ) == 0 || sub( clean_speech_HO, 1 ) == 0 || sub( NB_speech_HO, 1) == 0 ) && + IF ( EQ_16( *vad_flag, 1)&& + ( EQ_16( noisy_speech_HO , 1 ) || EQ_16( clean_speech_HO, 1 ) || EQ_16( NB_speech_HO, 1) ) && ( localVAD == 0 || localVAD_he == 0 ) ) { @@ -214,7 +212,7 @@ void set_ppp_mode_fx( test(); test(); - IF ( sub( *coder_type , INACTIVE ) == 0 && ( *vad_flag == 0 ) && sub( st_fx->last_nelp_mode_fx, 1 ) == 0 ) /* avoid HO frame go to GSC */ + IF ( EQ_16( *coder_type , INACTIVE )&&(*vad_flag==0)&&EQ_16(st_fx->last_nelp_mode_fx,1)) /* avoid HO frame go to GSC */ { *coder_type = UNVOICED; move16(); @@ -223,7 +221,7 @@ void set_ppp_mode_fx( /* force the coder to NELP mode during the first five frames */ /* this will indicate the decoder that the coder is operating in the VBR mode */ - IF ( sub( st_fx->ini_frame_fx, 5) <0 ) + IF ( LT_16( st_fx->ini_frame_fx, 5)) { *coder_type = UNVOICED; move16(); @@ -232,7 +230,7 @@ void set_ppp_mode_fx( } /* Pattern PPP-CELP-CELP (pppcountE holds number of consecutive PPP frames) */ test(); - IF ( sub( *coder_type, VOICED ) != 0 || sub( st_fx->last_coder_type_fx, TRANSITION ) == 0 ) + IF ( NE_16( *coder_type, VOICED )||EQ_16(st_fx->last_coder_type_fx,TRANSITION)) { /* ensure no transient to PPP transition */ st_fx->pppcountE_fx = 0; @@ -246,15 +244,15 @@ void set_ppp_mode_fx( test(); test(); test(); - IF ( ( sub( st_fx->pppcountE_fx, 1 ) == 0 && sub( st_fx->last_last_ppp_mode_fx, 1) != 0 && st_fx->rate_control_fx == 0 ) || - ( sub( st_fx->pppcountE_fx, 1 ) == 0 && st_fx->mode_QQF_fx != 0) ) + IF ( ( EQ_16( st_fx->pppcountE_fx, 1 )&&NE_16(st_fx->last_last_ppp_mode_fx,1)&&st_fx->rate_control_fx==0)|| + ( EQ_16( st_fx->pppcountE_fx, 1 ) && st_fx->mode_QQF_fx != 0) ) { st_fx->ppp_mode_fx = 1; move16(); st_fx->core_brate_fx = PPP_NELP_2k80; move32(); } - ELSE IF ( sub(st_fx->pppcountE_fx, 2 ) == 0 ) + ELSE IF ( EQ_16(st_fx->pppcountE_fx, 2 )) { test(); IF ( st_fx->last_ppp_mode_fx != 0 && st_fx->mode_QQF_fx == 0 ) @@ -283,7 +281,7 @@ void set_ppp_mode_fx( test(); - IF ( st_fx->ppp_mode_fx == 0 && sub( st_fx->set_ppp_generic_fx, 1) == 0 ) + IF ( st_fx->ppp_mode_fx == 0 && EQ_16( st_fx->set_ppp_generic_fx, 1)) { st_fx->set_ppp_generic_fx = 0; move16(); @@ -306,7 +304,7 @@ void set_ppp_mode_fx( test(); test(); IF ( (st_fx->last_ppp_mode_fx != 0 ) && ( st_fx->ppp_mode_fx == 0 ) && ( sp_aud_decision1 != 0) - && sub(st_fx->bwidth_fx, NB) == 0 && st_fx->Opt_SC_VBR_fx != 0 ) /*if it were about to go from ppp->HQ*/ + && EQ_16(st_fx->bwidth_fx, NB)&&st_fx->Opt_SC_VBR_fx!=0) /*if it were about to go from ppp->HQ*/ { st_fx->avoid_HQ_VBR_NB = 1; move16(); @@ -317,7 +315,7 @@ void set_ppp_mode_fx( test(); test(); test(); - IF ( (st_fx->last_nelp_mode_fx != 0) && ( sp_aud_decision1 != 0) && sub( st_fx->bwidth_fx, NB) == 0 && ( st_fx->Opt_SC_VBR_fx != 0 ) ) /*if it were about to go from nelp->HQ*/ + IF ( (st_fx->last_nelp_mode_fx != 0) && ( sp_aud_decision1 != 0) && EQ_16( st_fx->bwidth_fx, NB)&&(st_fx->Opt_SC_VBR_fx!=0)) /*if it were about to go from nelp->HQ*/ { st_fx->avoid_HQ_VBR_NB = 1; move16(); @@ -329,9 +327,9 @@ void set_ppp_mode_fx( test(); test(); test(); - IF( ( sub(st_fx->old_pitch_buf_fx[(2*NB_SUBFR)-1], PPP_LAG_THRLD_Q6) > 0 || - sub(T_op_fx[1], PPP_LAG_THRLD)>0 || !st_fx->last_Opt_SC_VBR_fx ) && - sub(st_fx->ppp_mode_fx,1)==0 ) + IF( ( GT_16(st_fx->old_pitch_buf_fx[(2*NB_SUBFR)-1], PPP_LAG_THRLD_Q6)|| + GT_16(T_op_fx[1], PPP_LAG_THRLD) || !st_fx->last_Opt_SC_VBR_fx ) && + EQ_16(st_fx->ppp_mode_fx,1) ) { st_fx->ppp_mode_fx=0; move16(); diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index b4f50647dcfaa57ff9057ae462a98bee0f6705fd..1b7f463103a5395852c3030ca9f816bddde87062 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -9,8 +9,6 @@ #include "rom_com_fx.h" #include "prot_fx.h" #include "stl.h" -#include "wmc_auto.h" - /*-------------------------------------------------------------------* * pre_proc() @@ -103,7 +101,6 @@ void pre_proc_fx( Word16 tmp_e; Word16 currFlatness; Word16 high_lpn_flag; - Word16 cldfb_addition = add(0, 0); Word16 alw_pitch_lag_12k8[2]; Word16 alw_voicing[2]; Word16 flag_spitch; @@ -116,6 +113,7 @@ void pre_proc_fx( Word16 sp_aud_decision0; Word16 last_core_orig; Word16 headroom; + Word16 cldfb_addition = 0; move16(); Word16 old_pitch1; @@ -200,7 +198,7 @@ void pre_proc_fx( * Change the sampling frequency to 12.8 kHz *----------------------------------------------------------------*/ - modify_Fs_fx( signal_in, input_frame, st->input_Fs_fx, new_inp_12k8, 12800, st->mem_decim_fx, (sub(st->max_bwidth_fx,NB) == 0) ); + modify_Fs_fx( signal_in, input_frame, st->input_Fs_fx, new_inp_12k8, 12800, st->mem_decim_fx, (const Word16)(EQ_16(st->max_bwidth_fx,NB))); Copy( new_inp_12k8, st->buf_speech_enc+L_FRAME32k, L_FRAME ); Scale_sig( st->buf_speech_enc+L_FRAME32k, L_FRAME, 1 ); /*------------------------------------------------------------------* @@ -216,7 +214,7 @@ void pre_proc_fx( test(); /* reserve an extra bit of headroom in case of NB coding and if there is a chance of energy above 4 kHz */ /* st->bwidth_fx refers to the coded bandwidth of the previous frame */ - if( ((sub(st->bwidth_fx, NB) == 0) || (sub(st->max_bwidth_fx, NB) == 0)) && (L_sub(st->input_Fs_fx, 8000) > 0) ) + if( ((EQ_16(st->bwidth_fx, NB))||(EQ_16(st->max_bwidth_fx,NB)))&&(GT_32(st->input_Fs_fx,8000))) { headroom = add(headroom, 1); } @@ -260,7 +258,7 @@ void pre_proc_fx( enerBuffer, enerBuffer_exp,st->cldfbAna_Fx->no_channels, *vad_flag ); - IF ( sub( st->Pos_relE_cnt, 20) < 0) /* Ensure the level is high enough and cldfb decision is reliable */ + IF ( LT_16( st->Pos_relE_cnt, 20) ) /* Ensure the level is high enough and cldfb decision is reliable */ { /* Combine decisions from SADS */ test(); @@ -273,6 +271,7 @@ void pre_proc_fx( *vad_flag = vad_flag_cldfb; move16(); } + /* apply DTX hangover for CNG analysis */ vad_flag_dtx = dtx_hangover_addition_fx( st, *localVAD, *vad_flag, sub(st->lp_speech_fx,st->lp_noise_fx), cldfb_addition, vad_hover_flag ); @@ -300,7 +299,7 @@ void pre_proc_fx( relE = sub(*Etot, st->lp_speech_fx); /* Q8 */ /* relE = *Etot - st->lp_speech;*/ test(); - IF ( sub(relE, 384) > 0 ) /*relE > 1.5 */ + IF ( GT_16(relE, 384) ) /*relE > 1.5 */ { st->Pos_relE_cnt = 0; move16(); @@ -329,12 +328,12 @@ void pre_proc_fx( * Adjust FD-CNG Noise Estimator *----------------------------------------------------------------*/ test(); - IF( (L_sub(st->last_total_brate_fx,st->total_brate_fx) != 0) || (sub(st->last_bwidth_fx,st->bwidth_fx) != 0) ) + IF( (NE_32(st->last_total_brate_fx,st->total_brate_fx))||(NE_16(st->last_bwidth_fx,st->bwidth_fx))) { L_tmp = st->total_brate_fx; move32(); test(); - if( st->rf_mode && L_sub(st->total_brate_fx,ACELP_13k20) == 0 ) + if( st->rf_mode && EQ_32(st->total_brate_fx,ACELP_13k20)) { L_tmp = ACELP_9k60; move32(); @@ -353,7 +352,7 @@ void pre_proc_fx( * Reconfigure MODE2 *----------------------------------------------------------------*/ - IF ( sub(st->codec_mode,MODE2) == 0 ) + IF ( EQ_16(st->codec_mode,MODE2)) { SetModeIndex( st, st->total_brate_fx, st->bwidth_fx, *shift); } @@ -442,7 +441,7 @@ void pre_proc_fx( &st->LF_EnergyRatio_sm_fx, &st->predecision_flag_fx, &st->diff_sm_fx, &st->energy_sm_fx,*Q_new,st->lgBin_E_fx); /* 1/4 pitch precision improvement */ - IF( L_sub(st->total_brate_fx,ACELP_24k40) <= 0 ) + IF( LE_32(st->total_brate_fx,ACELP_24k40)) { /* 1/4 pitch precision improvement */ pitch_ol2_fx( PIT_MIN_EXTEND, pitch[0], &pitch_fr[0], &voicing_fr[0], 0, wsp, 7 ); @@ -510,7 +509,7 @@ void pre_proc_fx( st->rf_mode = 0; st->rf_target_bits_write = 0; } - ELSE IF( st->rf_mode && L_sub(st->core_brate_fx,FRAME_NO_DATA) != 0 && L_sub(st->core_brate_fx,SID_2k40) != 0 ) + ELSE IF( st->rf_mode && NE_32(st->core_brate_fx,FRAME_NO_DATA)&&NE_32(st->core_brate_fx,SID_2k40)) { /* the RF config is for (n- fec_offset)th frame that will be packed along with the n-th frame bistream */ st->rf_mode = 1; @@ -570,7 +569,7 @@ void pre_proc_fx( * Selection of internal ACELP Fs (12.8 kHz or 16 kHz) *----------------------------------------------------------------*/ - IF( sub(st->codec_mode,MODE1) == 0 ) + IF( EQ_16(st->codec_mode,MODE1)) { test(); test(); @@ -586,20 +585,20 @@ void pre_proc_fx( test(); test(); test(); - IF( L_sub(st->core_brate_fx,FRAME_NO_DATA) == 0 ) + IF( EQ_32(st->core_brate_fx,FRAME_NO_DATA)) { /* prevent "L_frame" changes in CNG segments */ st->L_frame_fx = st->last_L_frame_fx; move16(); } - ELSE IF ( L_sub(st->core_brate_fx,SID_2k40) == 0 && sub(st->bwidth_fx, WB) >= 0 && st->first_CNG_fx && sub(st->act_cnt2_fx,MIN_ACT_CNG_UPD) < 0 ) + ELSE IF ( EQ_32(st->core_brate_fx,SID_2k40)&&GE_16(st->bwidth_fx,WB)&&st->first_CNG_fx&<_16(st->act_cnt2_fx,MIN_ACT_CNG_UPD)) { /* prevent "L_frame" changes in SID frame after short segment of active frames */ st->L_frame_fx = st->last_CNG_L_frame_fx; move16(); } - ELSE IF ( ( L_sub(st->core_brate_fx,SID_2k40) == 0 && L_sub(st->total_brate_fx,ACELP_9k60) >= 0 && ((sub(st->bwidth_fx,WB) == 0 && !( L_sub(st->total_brate_fx,ACELP_13k20) == 0 && sub(st->cng_type_fx,FD_CNG) == 0)) || (sub(st->cng_type_fx,LP_CNG) == 0 && sub(st->bwidth_fx,WB) > 0 && L_sub(st->total_brate_fx,ACELP_16k40) >= 0)) ) || - ( L_sub(st->total_brate_fx,ACELP_24k40) > 0 && L_sub(st->total_brate_fx,HQ_96k) < 0 ) || ( L_sub(st->total_brate_fx,ACELP_24k40) == 0 && sub(st->bwidth_fx,WB) >= 0 ) ) + ELSE IF ( ( EQ_32(st->core_brate_fx,SID_2k40)&&GE_32(st->total_brate_fx,ACELP_9k60)&&((EQ_16(st->bwidth_fx,WB)&&!(EQ_32(st->total_brate_fx,ACELP_13k20)&&EQ_16(st->cng_type_fx,FD_CNG)))||(EQ_16(st->cng_type_fx,LP_CNG)&>_16(st->bwidth_fx,WB)&&GE_32(st->total_brate_fx,ACELP_16k40))))|| + ( GT_32(st->total_brate_fx,ACELP_24k40) && LT_32(st->total_brate_fx,HQ_96k) ) || ( EQ_32(st->total_brate_fx,ACELP_24k40) && GE_16(st->bwidth_fx,WB) ) ) { st->L_frame_fx = L_FRAME16k; move16(); @@ -617,7 +616,7 @@ void pre_proc_fx( move16(); } - IF( sub(st->L_frame_fx,L_FRAME) == 0 ) + IF( EQ_16(st->L_frame_fx,L_FRAME)) { st->gamma = GAMMA1; move16(); @@ -644,7 +643,7 @@ void pre_proc_fx( * enforce TC frames in case of switching *-----------------------------------------------------------------*/ - IF( sub(st->codec_mode,MODE1) == 0 ) + IF( EQ_16(st->codec_mode,MODE1)) { /* enforce TRANSITION frames */ test(); @@ -660,19 +659,19 @@ void pre_proc_fx( test(); test(); test(); - IF( sub(st->last_L_frame_fx,st->L_frame_fx) != 0 && L_sub(st->core_brate_fx,FRAME_NO_DATA) != 0 && L_sub(st->core_brate_fx,SID_2k40) != 0 && (sub(st->coder_type_raw_fx,VOICED) != 0) ) + IF( NE_16(st->last_L_frame_fx,st->L_frame_fx)&&NE_32(st->core_brate_fx,FRAME_NO_DATA)&&NE_32(st->core_brate_fx,SID_2k40)&&(NE_16(st->coder_type_raw_fx,VOICED))) { /* enforce TC frame in case of ACELP@12k8 <-> ACELP@16k core switching */ *coder_type = TRANSITION; move16(); } - ELSE IF( sub(st->last_core_fx,HQ_CORE) == 0 || sub(st->last_core_fx,TCX_10_CORE) == 0 || sub(st->last_core_fx,TCX_20_CORE) == 0 ) + ELSE IF( EQ_16(st->last_core_fx,HQ_CORE)||EQ_16(st->last_core_fx,TCX_10_CORE)||EQ_16(st->last_core_fx,TCX_20_CORE)) { /* enforce TC frame in case of HQ/TCX -> ACELP core switching */ *coder_type = TRANSITION; move16(); } - ELSE IF( L_sub(st->last_core_brate_fx,SID_2k40) <= 0 && sub(st->cng_type_fx,FD_CNG) == 0 ) + ELSE IF( LE_32(st->last_core_brate_fx,SID_2k40)&&EQ_16(st->cng_type_fx,FD_CNG)) { /* enforce TC frame in case of FD_CNG -> ACELP switching (past excitation not available) */ *coder_type = TRANSITION; @@ -680,12 +679,12 @@ void pre_proc_fx( } /* select INACTIVE frames */ - ELSE IF( L_sub(st->total_brate_fx,ACELP_24k40) <= 0 && *vad_flag == 0 ) + ELSE IF( LE_32(st->total_brate_fx,ACELP_24k40)&&*vad_flag==0) { /* inactive frames will be coded by GSC technology */ /* except for the VBR mode. VBR mode uses NELP for that */ test(); - IF ( !( sub(st->Opt_SC_VBR_fx, 1) == 0 && sub(vad_flag_dtx, 1 ) == 0 ) ) + IF ( !( EQ_16(st->Opt_SC_VBR_fx, 1)&&EQ_16(vad_flag_dtx,1))) { *coder_type = INACTIVE; move16(); @@ -693,8 +692,8 @@ void pre_proc_fx( move16(); } } - ELSE IF( L_sub(st->total_brate_fx,ACELP_24k40) > 0 && - ( (*vad_flag == 0 && sub(st->bwidth_fx,SWB) >= 0 && sub(st->max_bwidth_fx,SWB) >= 0) || (*localVAD == 0 && (sub(st->bwidth_fx,WB) <= 0 || sub(st->max_bwidth_fx,WB) <= 0)) ) + ELSE IF( GT_32(st->total_brate_fx,ACELP_24k40)&& + ( (*vad_flag == 0 && GE_16(st->bwidth_fx,SWB) && GE_16(st->max_bwidth_fx,SWB) ) || (*localVAD == 0 && (LE_16(st->bwidth_fx,WB) || LE_16(st->max_bwidth_fx,WB))) ) ) { /* inactive frames will be coded by AVQ technology */ @@ -709,7 +708,7 @@ void pre_proc_fx( *coder_type = INACTIVE; move16(); } - ELSE IF( sub(*coder_type,GENERIC) > 0 ) + ELSE IF( GT_16(*coder_type,GENERIC)) { *coder_type = GENERIC; move16(); @@ -729,19 +728,19 @@ void pre_proc_fx( { test(); test(); - IF ( L_sub(st->total_brate_fx,ACELP_13k20) == 0 || L_sub(st->total_brate_fx,ACELP_32k) == 0 ) + IF ( EQ_32(st->total_brate_fx,ACELP_13k20)||EQ_32(st->total_brate_fx,ACELP_32k)) { st->mdct_sw_enable = MODE1; move16(); } - ELSE IF ( L_sub(ACELP_16k40,st->total_brate_fx) <= 0 && L_sub(st->total_brate_fx,ACELP_24k40) <= 0) + ELSE IF ( LE_32(ACELP_16k40,st->total_brate_fx)&&LE_32(st->total_brate_fx,ACELP_24k40)) { st->mdct_sw_enable = MODE2; move16(); } } - IF( sub(st->codec_mode,MODE1) == 0 ) + IF( EQ_16(st->codec_mode,MODE1)) { /*---------------------------------------------------------------------* * Decision matrix (selection of technologies) @@ -750,11 +749,11 @@ void pre_proc_fx( decision_matrix_enc_fx( st, *sp_aud_decision1, *sp_aud_decision2, *coder_type, *vad_flag, hq_core_type ); /* HQ_CORE/TCX_20_CORE decision */ - IF ( sub(st->core_fx,HQ_CORE) == 0 ) /* Decision matrix decided for MDCT coding */ + IF ( EQ_16(st->core_fx,HQ_CORE)) /* Decision matrix decided for MDCT coding */ { test(); test(); - IF( (sub(st->bwidth_fx,SWB) == 0 || sub(st->bwidth_fx,FB) == 0) && L_sub(st->total_brate_fx,32000) == 0 ) + IF( (EQ_16(st->bwidth_fx,SWB)||EQ_16(st->bwidth_fx,FB))&&EQ_32(st->total_brate_fx,32000)) { /* Select MDCT Core */ st->core_fx = mdct_classifier_fx(fft_buff,st,*vad_flag, enerBuffer @@ -762,7 +761,7 @@ void pre_proc_fx( ); } test(); - IF( (L_sub(st->total_brate_fx,13200) == 0) && (sub(st->bwidth_fx,FB) != 0 )) + IF( (EQ_32(st->total_brate_fx,13200))&&(NE_16(st->bwidth_fx,FB))) { MDCT_selector( st, sp_floor, *Etot, cor_map_sum, voicing, enerBuffer, enerBuffer_exp, *vad_flag ); } @@ -773,11 +772,11 @@ void pre_proc_fx( } /* Switch to MODE2 if TCX_20_CORE */ - IF( sub(st->core_fx,TCX_20_CORE) == 0 ) + IF( EQ_16(st->core_fx,TCX_20_CORE)) { st->codec_mode = MODE2; move16(); - IF( sub(st->last_codec_mode,MODE1) == 0 ) + IF( EQ_16(st->last_codec_mode,MODE1)) { Word32 last_total_brate = L_add(st->last_total_brate_fx, 0); st->last_total_brate_fx = -1; @@ -798,7 +797,7 @@ void pre_proc_fx( st->encoderPastSamples_enc = shr(imult1616(st->L_frame_fx, 9), 4); assert(st->L_frame_fx == st->sr_core / 50); - IF ( L_sub(st->sr_core,12800) == 0 ) + IF ( EQ_32(st->sr_core,12800)) { st->preemph_fac = PREEMPH_FAC; move16(); @@ -824,7 +823,7 @@ void pre_proc_fx( *coder_type = INACTIVE; move16(); } - ELSE IF( sub((*coder_type),GENERIC) > 0 ) + ELSE IF( GT_16((*coder_type),GENERIC)) { *coder_type = GENERIC; move16(); @@ -843,8 +842,8 @@ void pre_proc_fx( test(); test(); test(); - IF( L_sub(st->total_brate_fx, ACELP_32k) == 0 && sub(loc_harm,1) == 0 && sub(cor_map_sum,50<<8) > 0 - && sub(st->clas_fx, VOICED_CLAS)== 0 && sub(*coder_type,GENERIC) == 0 ) + IF( EQ_32(st->total_brate_fx, ACELP_32k)&&EQ_16(loc_harm,1)&>_16(cor_map_sum,50<<8) + && EQ_16(st->clas_fx, VOICED_CLAS) && EQ_16(*coder_type,GENERIC) ) { st->last_harm_flag_acelp_fx = add(st->last_harm_flag_acelp_fx,1); st->last_harm_flag_acelp_fx = s_min(st->last_harm_flag_acelp_fx,10); @@ -859,11 +858,11 @@ void pre_proc_fx( * Update audio frames counter (used for UV decision) *-----------------------------------------------------------------*/ - IF( sub(*coder_type,AUDIO) == 0 ) + IF( EQ_16(*coder_type,AUDIO)) { st->audio_frame_cnt_fx = add(st->audio_frame_cnt_fx,AUDIO_COUNTER_STEP); } - ELSE IF (sub(*coder_type,INACTIVE) != 0) + ELSE IF (NE_16(*coder_type,INACTIVE)) { st->audio_frame_cnt_fx = sub(st->audio_frame_cnt_fx,1); } @@ -877,16 +876,16 @@ void pre_proc_fx( *sharpFlag = 0; move16(); - IF( sub(*coder_type,TRANSITION) == 0 ) + IF( EQ_16(*coder_type,TRANSITION)) { test(); test(); test(); test(); test(); - IF( ( L_sub(st->total_brate_fx,ACELP_48k) > 0 && sub(st->bwidth_fx,SWB) < 0 ) || /* Deactivate for core bitrates higher than 48.0 kb/s */ - ( L_sub(st->total_brate_fx,ACELP_13k20) >= 0 && L_sub(st->total_brate_fx,ACELP_16k40) <= 0 ) || /* Deactivate for bitrates <13.2, 16.4> kb/s (this is basically due to lack of signaling configurations */ - ( L_sub(st->total_brate_fx,ACELP_16k40) > 0 && sub(st->lp_noise_fx,FORMANT_SHARPENING_NOISE_THRESHOLD_FX ) > 0 ) ) /* Deactivate for bitrates >= 24.4 kb/s if the long-term noise level exceeds 34 dB */ + IF( ( GT_32(st->total_brate_fx,ACELP_48k)&<_16(st->bwidth_fx,SWB))|| /* Deactivate for core bitrates higher than 48.0 kb/s */ + ( GE_32(st->total_brate_fx,ACELP_13k20) && LE_32(st->total_brate_fx,ACELP_16k40) ) || /* Deactivate for bitrates <13.2, 16.4> kb/s (this is basically due to lack of signaling configurations */ + ( GT_32(st->total_brate_fx,ACELP_16k40)&>_16(st->lp_noise_fx,FORMANT_SHARPENING_NOISE_THRESHOLD_FX))) /* Deactivate for bitrates >= 24.4 kb/s if the long-term noise level exceeds 34 dB */ { *sharpFlag= 0; move16(); @@ -899,7 +898,7 @@ void pre_proc_fx( } test(); - IF( sub(*coder_type,GENERIC) == 0 || sub(*coder_type,VOICED) == 0 ) + IF( EQ_16(*coder_type,GENERIC)||EQ_16(*coder_type,VOICED)) { test(); test(); @@ -907,9 +906,9 @@ void pre_proc_fx( test(); test(); IF( *vad_hover_flag || - ( L_sub(st->total_brate_fx,ACELP_48k) > 0 && sub(st->bwidth_fx,SWB) < 0 ) || /* Deactivate for core bitrates higher than 48.0 kb/s */ - ( L_sub(st->total_brate_fx,ACELP_13k20) >= 0 && sub(st->lp_noise_fx,FORMANT_SHARPENING_NOISE_THRESHOLD_FX) > 0 /* Deactivate for bitrates >= 13.2 kb/s if the long-term noise level exceeds 34 dB */ - && L_sub(st->total_brate_fx,CNA_MAX_BRATE) > 0 ) ) + ( GT_32(st->total_brate_fx,ACELP_48k) && LT_16(st->bwidth_fx,SWB) ) || /* Deactivate for core bitrates higher than 48.0 kb/s */ + ( GE_32(st->total_brate_fx,ACELP_13k20)&>_16(st->lp_noise_fx,FORMANT_SHARPENING_NOISE_THRESHOLD_FX) /* Deactivate for bitrates >= 13.2 kb/s if the long-term noise level exceeds 34 dB */ + && GT_32(st->total_brate_fx,CNA_MAX_BRATE) ) ) { *sharpFlag = 0; move16(); @@ -924,7 +923,7 @@ void pre_proc_fx( /* channel-aware mode - due to lack of signalling bit, sharpFlag is 1 always in RF mode */ test(); test(); - IF( sub(st->rf_mode,1)==0 && ( sub(*coder_type,VOICED) == 0 || sub(*coder_type,GENERIC) == 0 ) ) + IF( EQ_16(st->rf_mode,1)&&(EQ_16(*coder_type,VOICED)||EQ_16(*coder_type,GENERIC))) { *sharpFlag = 1; } @@ -937,7 +936,7 @@ void pre_proc_fx( move16(); test(); test(); - if ( *sp_aud_decision1 == 0 && ( sub(*coder_type,VOICED) == 0 || sub(*coder_type,GENERIC) == 0 ) ) + if ( *sp_aud_decision1 == 0 && ( EQ_16(*coder_type,VOICED)||EQ_16(*coder_type,GENERIC))) { *Voicing_flag = 1; move16(); @@ -948,14 +947,14 @@ void pre_proc_fx( *----------------------------------------------------------------*/ sr_core_tmp = L_max(INT_FS_16k_FX,st->sr_core); /* indicates the ACELP sampling rate for MODE2, 16 kHz for MODE1 */ - if( sub(st->codec_mode,MODE1) == 0 ) + if( EQ_16(st->codec_mode,MODE1)) { sr_core_tmp = INT_FS_16k_FX; move32(); } L_frame_tmp = s_max(L_FRAME16k,st->L_frame_fx); - if( sub(st->codec_mode,MODE1) == 0 ) + if( EQ_16(st->codec_mode,MODE1)) { L_frame_tmp = L_FRAME16k; move16(); @@ -972,7 +971,7 @@ void pre_proc_fx( *----------------------------------------------------------------*/ test(); - IF( L_sub(st->input_Fs_fx,sr_core_tmp) == 0 ) + IF( EQ_32(st->input_Fs_fx,sr_core_tmp)) { /* no resampling needed, only delay adjustement to account for the FIR resampling delay */ delay = NS2SA_fx2(st->input_Fs_fx, DELAY_FIR_RESAMPL_NS); @@ -980,7 +979,7 @@ void pre_proc_fx( Copy_Scale_sig( signal_in, new_inp_16k + delay, input_frame - delay, -1 ); /* Input in Q0 -> Output in Q-1 to mimic the resampling filter */ Copy( signal_in + input_frame - shl(delay,1), st->mem_decim16k_fx, shl(delay,1) ); /* memory still in Q0 */ } - ELSE IF( L_sub(st->input_Fs_fx,32000) == 0 || L_sub(st->input_Fs_fx,48000) == 0 ) + ELSE IF( EQ_32(st->input_Fs_fx,32000)||EQ_32(st->input_Fs_fx,48000)) { modify_Fs_fx( signal_in, input_frame, st->input_Fs_fx, new_inp_16k, sr_core_tmp, st->mem_decim16k_fx, 0 ); } @@ -993,12 +992,12 @@ void pre_proc_fx( Copy( signal_in + sub(input_frame, shl(delay,1)), st->mem_decim16k_fx, shl(delay,1) ); } - IF( L_sub(sr_core_tmp,16000) == 0 ) + IF( EQ_32(sr_core_tmp,16000)) { /* save input resampled at 16kHz, non-preemhasised */ Copy( new_inp_16k, new_inp_resamp16k, L_FRAME16k ); } - ELSE IF( L_sub(sr_core_tmp,16000) > 0 ) + ELSE IF( GT_32(sr_core_tmp,16000)) { /* reset the buffer, the signal is needed for WB BWEs */ set16_fx( new_inp_resamp16k, 0, L_FRAME16k ); @@ -1010,17 +1009,17 @@ void pre_proc_fx( test(); test(); - IF( ((st->tcxonly == 0) || (sub(st->codec_mode,MODE1) == 0)) && L_sub(st->input_Fs_fx,8000) > 0 ) + IF( ((st->tcxonly == 0) || (EQ_16(st->codec_mode,MODE1)))&>_32(st->input_Fs_fx,8000)) { st->mem_preemph_enc = shl(new_inp_16k[sub(L_frame_tmp,1)],1); } test(); - IF( L_sub(st->input_Fs_fx,8000) > 0 && L_sub(sr_core_tmp,16000) == 0) + IF( GT_32(st->input_Fs_fx,8000)&&EQ_32(sr_core_tmp,16000)) { Preemph_scaled( new_inp_16k, &Q_new_16k, &(st->mem_preemph16k_fx), st->Q_max_16k, PREEMPH_FAC_16k, 0, 1, L_Q_MEM, L_FRAME16k, st->last_coder_type_fx, 1); } - ELSE IF( L_sub(st->input_Fs_fx,8000) > 0 ) /* keep memory up-to-date in case of bit-rate switching */ + ELSE IF( GT_32(st->input_Fs_fx,8000)) /* keep memory up-to-date in case of bit-rate switching */ { st->mem_preemph16k_fx = new_inp_16k[sub(L_frame_tmp,1)]; move16(); @@ -1036,15 +1035,15 @@ void pre_proc_fx( test(); test(); test(); - IF( ( ((st->tcxonly == 0) || !(L_sub(st->core_brate_fx,FRAME_NO_DATA) != 0 || L_sub(st->core_brate_fx,SID_2k40) != 0)) && sub(st->L_frame_fx,L_FRAME16k) == 0 && sub(st->codec_mode,MODE2) == 0 ) || - ( sub(st->L_frame_fx,L_FRAME16k) == 0 && sub(st->codec_mode,MODE1) == 0 ) ) + IF( ( ((st->tcxonly == 0) || !(NE_32(st->core_brate_fx,FRAME_NO_DATA)||NE_32(st->core_brate_fx,SID_2k40)))&&EQ_16(st->L_frame_fx,L_FRAME16k)&&EQ_16(st->codec_mode,MODE2))|| + ( EQ_16(st->L_frame_fx,L_FRAME16k) && EQ_16(st->codec_mode,MODE1) ) ) { *Q_new = Q_new_16k; move16(); } ELSE { - IF( L_sub(st->input_Fs_fx,8000) > 0 && L_sub(sr_core_tmp,16000) == 0 ) + IF( GT_32(st->input_Fs_fx,8000)&&EQ_32(sr_core_tmp,16000)) { Scale_sig(new_inp_16k, L_FRAME16k, sub(*Q_new,Q_new_16k)); } @@ -1070,8 +1069,8 @@ void pre_proc_fx( test(); test(); test(); - IF( ( ((st->tcxonly == 0) || !(L_sub(st->core_brate_fx,FRAME_NO_DATA) != 0 && L_sub(st->core_brate_fx,SID_2k40) != 0)) && sub(st->L_frame_fx,L_FRAME16k) == 0 && sub(st->codec_mode,MODE2) == 0 ) || - ( sub(st->L_frame_fx,L_FRAME16k) == 0 && sub(st->codec_mode,MODE1) == 0 ) ) + IF( ( ((st->tcxonly == 0) || !(NE_32(st->core_brate_fx,FRAME_NO_DATA) && NE_32(st->core_brate_fx,SID_2k40)))&&EQ_16(st->L_frame_fx,L_FRAME16k)&&EQ_16(st->codec_mode,MODE2))|| + ( EQ_16(st->L_frame_fx,L_FRAME16k) && EQ_16(st->codec_mode,MODE1) ) ) { /* update signal buffers */ Copy( new_inp_resamp16k, st->buf_speech_enc+L_FRAME16k, L_FRAME16k ); @@ -1088,7 +1087,7 @@ void pre_proc_fx( *---------------------------------------------------------------*/ test(); - IF( sub(st->last_L_frame_fx,L_FRAME) == 0 && sub(st->codec_mode,MODE1) == 0 ) + IF( EQ_16(st->last_L_frame_fx,L_FRAME)&&EQ_16(st->codec_mode,MODE1)) { /* this is just an approximation, but it is sufficient */ Copy( st->lsp_old1_fx, st->lspold_enc_fx, M ); @@ -1100,7 +1099,7 @@ void pre_proc_fx( * Compute Weighted Input *---------------------------------------------------------------*/ - IF( sub(st->codec_mode,MODE2) == 0 ) + IF( EQ_16(st->codec_mode,MODE2)) { find_wsp( A, st->speech_enc_pe, st->wspeech_enc, &st->mem_wsp_enc, PREEMPH_FAC_16k, L_FRAME16k, L_LOOK_16k, L_SUBFR, Aw, st->gamma, st->nb_subfr); @@ -1125,7 +1124,7 @@ void pre_proc_fx( } test(); test(); - IF( sub(st->codec_mode,MODE2) == 0 && st->tcxonly == 0 && Q_exp != 0 ) + IF( EQ_16(st->codec_mode,MODE2)&&st->tcxonly==0&&Q_exp!=0) { Scale_sig( st->buf_speech_enc_pe, st->encoderPastSamples_enc+st->encoderLookahead_enc, Q_exp ); Scale_sig( &(st->mem_wsp_enc), 1, Q_exp ); @@ -1140,7 +1139,7 @@ void pre_proc_fx( } test(); - IF( sub(excitation_max_test,8192) > 0 && *shift == 0 ) + IF( GT_16(excitation_max_test,8192)&&*shift==0) { excitation_max_test = 1; move16(); @@ -1157,13 +1156,13 @@ void pre_proc_fx( } test(); - IF ( sub(st->codec_mode,MODE2) == 0 && st->tcxonly == 0 ) + IF ( EQ_16(st->codec_mode,MODE2)&&st->tcxonly==0) { IF (Q_wsp_exp != 0) { Scale_sig(st->buf_wspeech_enc, st->L_frame_fx+L_SUBFR, Q_wsp_exp); } - IF( sub(excitation_max_test,1) == 0 ) + IF( EQ_16(excitation_max_test,1)) { Scale_sig( st->buf_wspeech_enc, st->L_frame_fx+L_SUBFR+st->L_frame_fx+st->encoderLookahead_enc, -1 ); } @@ -1173,11 +1172,11 @@ void pre_proc_fx( * ACELP/TCX20/HQ Switching Decision *-----------------------------------------------------------------*/ - IF ( sub(st->codec_mode,MODE2) == 0 ) + IF ( EQ_16(st->codec_mode,MODE2)) { test(); test(); - IF((L_sub(st->core_brate_fx,FRAME_NO_DATA) != 0 && L_sub(st->core_brate_fx,SID_2k40) != 0 && st->tcxonly == 0 )) + IF((NE_32(st->core_brate_fx,FRAME_NO_DATA)&&NE_32(st->core_brate_fx,SID_2k40)&&st->tcxonly==0)) { core_acelp_tcx20_switching( st,*vad_flag, sp_aud_decision0, non_staX, @@ -1185,21 +1184,21 @@ void pre_proc_fx( } test(); - IF (sub(st->mdct_sw_enable,MODE2) == 0 && !st->rf_mode) + IF (EQ_16(st->mdct_sw_enable,MODE2)&&!st->rf_mode) { - IF (sub(st->core_fx,TCX_20_CORE) == 0) /* Switching only possible from TCX_20 frames, not from TCX_10 frames */ + IF (EQ_16(st->core_fx,TCX_20_CORE)) /* Switching only possible from TCX_20 frames, not from TCX_10 frames */ { /* Select MDCT Core */ test(); test(); - IF ((sub(st->bwidth_fx,SWB)==0 || sub(st->bwidth_fx,FB)==0) && L_sub(st->total_brate_fx,24400)==0) + IF ((EQ_16(st->bwidth_fx,SWB)||EQ_16(st->bwidth_fx,FB))&&EQ_32(st->total_brate_fx,24400)) { st->core_fx = mdct_classifier_fx(fft_buff,st,*vad_flag, enerBuffer ,sub(enerBuffer_exp, 31) ); } test(); - IF ((L_sub(st->total_brate_fx,16400) == 0) && (sub(st->bwidth_fx,FB) !=0 )) + IF ((EQ_32(st->total_brate_fx,16400))&&(NE_16(st->bwidth_fx,FB))) { MDCT_selector( st, sp_floor, *Etot, cor_map_sum, voicing, enerBuffer, enerBuffer_exp, *vad_flag ); } @@ -1211,14 +1210,14 @@ void pre_proc_fx( /* Do the switching that was decided in the MDCT selector */ test(); - IF( sub(st->core_fx,HQ_CORE) == 0 ) + IF( EQ_16(st->core_fx,HQ_CORE)) { st->codec_mode = MODE1; move16(); st->mdct_sw = MODE2; move16(); } - ELSE IF( sub(st->last_codec_mode,MODE1) == 0 && sub(st->last_core_fx,HQ_CORE) == 0 ) + ELSE IF( EQ_16(st->last_codec_mode,MODE1)&&EQ_16(st->last_core_fx,HQ_CORE)) { Word16 L_frame_old = st->last_L_frame_fx; move16(); @@ -1249,11 +1248,11 @@ void pre_proc_fx( /* update old input signal @16kHz buffer */ test(); - IF( L_sub(st->input_Fs_fx,8000) > 0 && L_sub(sr_core_tmp,16000) == 0 ) + IF( GT_32(st->input_Fs_fx,8000)&&EQ_32(sr_core_tmp,16000)) { Copy( &old_inp_16k[L_frame_tmp], st->old_inp_16k_fx, L_INP_MEM ); } - ELSE IF( L_sub(st->input_Fs_fx,8000) > 0 ) + ELSE IF( GT_32(st->input_Fs_fx,8000)) { lerp( st->old_inp_12k8_fx+L_INP_MEM-L_INP_MEM*4/5, st->old_inp_16k_fx, L_INP_MEM, L_INP_MEM*4/5); Scale_sig(st->old_inp_16k_fx, L_INP_MEM, sub(*Q_new,st->Q_old)); @@ -1261,7 +1260,7 @@ void pre_proc_fx( test(); test(); - IF( (L_sub(sr_core_tmp,16000) == 0) && st->tcxonly && sub(st->codec_mode,MODE2) == 0 ) + IF( (EQ_32(sr_core_tmp,16000))&&st->tcxonly&&EQ_16(st->codec_mode,MODE2)) { /* copy input resampled at 16kHz, non-preemhasised */ Copy( new_inp_resamp16k, new_inp_16k, L_FRAME16k ); @@ -1272,7 +1271,7 @@ void pre_proc_fx( /* set the pointer of the current frame for the ACELP core */ *inp = inp_16k; - if ( sub(st->L_frame_fx,L_FRAME) == 0 ) + if ( EQ_16(st->L_frame_fx,L_FRAME)) { *inp = inp_12k8; } diff --git a/lib_enc/pvq_core_enc_fx.c b/lib_enc/pvq_core_enc_fx.c index 52e279761a5d80340f6ef0f024fa9f3c9c075386..8102f956e0d30fca5aa685a15f4167581d06d0e8 100644 --- a/lib_enc/pvq_core_enc_fx.c +++ b/lib_enc/pvq_core_enc_fx.c @@ -1,6 +1,6 @@ #include "options.h" /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -8,8 +8,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - static Word16 calc_pvq_splits_fx(Encoder_State_fx *st_fx, const Word16 band_bits, const Word16 sfmsize, const Word16 *y, const Word16 Q_y, Word16 *bits); @@ -75,7 +73,7 @@ static void pvq_encode_band_fx( /* Encode energies */ set16_fx(g_part_neg, -32768, Np); /* -1.0 in Q15 */ - IF (sub(Np, 1) > 0) + IF (GT_16(Np, 1)) { encode_energies_fx( st_fx, coefs_norm, Q_coefs, Np, dim_part, E_part, bits_part, g_part_neg, band_bits_tot, bits_left, enr, sfmsize, strict_bits ); } @@ -371,11 +369,11 @@ void encode_energies_fx( sqrt_r_enr = Sqrt_l(r_enr, &exp1); sqrt_l_enr = Sqrt_l(l_enr, &exp2); - IF (sub(exp1, exp2) < 0) + IF (LT_16(exp1, exp2)) { sqrt_l_enr = L_shr(sqrt_l_enr, shr(sub(exp2, exp1), 1)); } - ELSE IF (sub(exp2, exp1) < 0) + ELSE IF (LT_16(exp2, exp1)) { sqrt_r_enr = L_shr(sqrt_r_enr, shr(sub(exp1, exp2), 1)); exp1 = exp2; @@ -383,7 +381,7 @@ void encode_energies_fx( } exp1 = add(shl(sub(Q_coefs, 2), 1), add(31, exp1)); /* 2x exponent */ - IF (sub(s_and(exp1, 1), 1) == 0) + IF (EQ_16(s_and(exp1, 1), 1)) { sqrt_r_enr = Mult_32_16(sqrt_r_enr, 23170); /* Q(exp1/2) */ sqrt_l_enr = Mult_32_16(sqrt_l_enr, 23170); /* Q(exp1/2) */ @@ -425,7 +423,7 @@ void encode_energies_fx( l_dim, r_dim, oppRQ3, &l_bits, &r_bits, bits_left); - IF (sub(l_Np, 1) > 0) + IF (GT_16(l_Np, 1)) { encode_energies_fx( st_fx, coefs, Q_coefs, l_Np, dim_part, E_part, bits_part, g_part, l_bits, bits_left, l_enr, l_dim, strict_bits ); } @@ -436,7 +434,7 @@ void encode_energies_fx( bits_part[0] = l_bits; move16(); } - IF (sub(r_Np, 1) > 0) + IF (GT_16(r_Np, 1)) { encode_energies_fx( st_fx, &coefs[l_dim], Q_coefs, r_Np, &dim_part[l_Np], &E_part[l_Np], &bits_part[l_Np], &g_part[l_Np], r_bits, bits_left, r_enr, r_dim, strict_bits ); } @@ -483,7 +481,7 @@ void densityIndexSymbolEncode_fx( sym_freq = L_deposit_l(add(shl(sub(density, index_phi), 1), 1)); cum_freq = L_mac0(L_mult(index_phi, density), index_phi, 1); } - ELSE IF (sub(c, density) == 0) + ELSE IF (EQ_16(c, density)) { tot = L_mac0(1L, density, add(density, 1)); sym_freq = L_deposit_l(add(shl(index_phi, 1), 1)); @@ -496,7 +494,7 @@ void densityIndexSymbolEncode_fx( acc = L_or(L_shl(acc, 16), L_and(lsb, 0xffffL)); /* Concatenate acc and lsb forming 48-bit; upshift 16 bits; keep 32 MSB. */ acc = L_shr(acc, 1); /* Compensate fractional mode multiply (Mpy_32_16_ss) */ tot = L_add(L_add(acc, (Word32)density), 1L); /* density*c*(density - c) + density + 1 */ - IF (sub(index_phi, c) <= 0) + IF (LE_16(index_phi, c)) { sym_freq = L_mac(1L, index_phi, densitySubC); acc = L_mult0(densitySubC, sub(index_phi, 1)); @@ -566,10 +564,10 @@ static Word16 calc_pvq_splits_fx( /* o : Number of segments */ *bits = 0; move16(); - IF (sub(Np, MAX_SPLITS) < 0) + IF (LT_16(Np, MAX_SPLITS)) { acc = L_mult0(8*THR_ADD_SPLIT, sfmsize); - IF (L_sub(band_bits, acc) > 0) + IF (GT_32(band_bits, acc)) { Npart = extract_l((Word32)intLimCDivPos_fx(UL_deposit_l((UWord16)sfmsize), Np)); *bits = 8; @@ -608,7 +606,7 @@ static Word16 calc_pvq_splits_fx( /* o : Number of segments */ tmp = 0; move16() ; - if( L_sub(acc1, acc) > 0) + if( GT_32(acc1, acc)) { tmp = 1; move16(); diff --git a/lib_enc/pvq_encode_fx.c b/lib_enc/pvq_encode_fx.c index bcef4da334e342eb39b6d95bca263db9b6173c0c..e5aea6f749539bc821560c374370338908941d58 100644 --- a/lib_enc/pvq_encode_fx.c +++ b/lib_enc/pvq_encode_fx.c @@ -1,12 +1,10 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "cnst_fx.h" #include "stl.h" -#include "wmc_auto.h" - #include "prot_fx.h" #include "rom_com_fx.h" @@ -277,7 +275,7 @@ void pvq_encode_fx( L_yy=L_shr(L_yy,1); - IF (sub(pulses,127)<=0 ) + IF (LE_16(pulses,127)) { /* LC inner loop, enters here always for dimensions 6 and higher, and also sometimes for dimensions 1 .. 5 */ /* ( if high energy precision is inactive, max_amp_y is not needed , no max_amp_y(k-1) update ) */ @@ -363,7 +361,7 @@ void pvq_encode_fx( /* send the short codeword(s) to the range encoder */ rc_enc_bits_fx(st_fx, UL_deposit_l(entry.lead_sign_ind) , 1); /* 0 or 1 */ - IF( sub( dim, 1) != 0 ) + IF( NE_16( dim, 1)) { rc_enc_uniform_fx(st_fx, entry.index, entry.size); } diff --git a/lib_enc/q_gain2p.c b/lib_enc/q_gain2p.c index daabf649b3dc7298d398cca835653acaa611651b..58620aee54f6128ab1a48b692d78446996c9334e 100644 --- a/lib_enc/q_gain2p.c +++ b/lib_enc/q_gain2p.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ /*-------------------------------------------------------------------------* @@ -15,8 +15,6 @@ #include #include "prot_fx.h" #include "stl.h" -#include "wmc_auto.h" - #include "basop_util.h" #include "rom_com_fx.h" @@ -321,7 +319,7 @@ Word16 gain_enc( /* o : quantization pitch index size = NB_QUA_GAIN7B; } - if ( sub(clip_gain,1) == 0) + if ( EQ_16(clip_gain,1)) { size = sub(size, size_clip); /* limit pitch gain to 1.0 */ } @@ -362,7 +360,7 @@ Word16 gain_enc( /* o : quantization pitch index g_code_shl = norm_s(p[2*i+1]); g_code = shl(p[2*i+1],g_code_shl); g_code = mult_r(g_code, gcode0_gi); - BASOP_SATURATE_WARNING_OFF; /* needed to skip overflow warnings due to exceeding shift values */ + BASOP_SATURATE_WARNING_OFF /* needed to skip overflow warnings due to exceeding shift values */ L_tmp = L_shr(Mpy_32_16_1(L_mult(g_code, g_code),coeff2),shr_coeff2); if (g_code_shl != 0) L_tmp = L_shr(L_tmp,g_code_shl); @@ -374,7 +372,7 @@ Word16 gain_enc( /* o : quantization pitch index L_tmp = L_add(L_tmp,L_shr(L_mult0(p[2*i+0],p[2*i+0]), shr_coeff0)); L_tmp = L_sub(L_tmp,L_shr(L_mult(p[2*i+0], coeff1),shr_coeff1)); L_tmp1= L_sub(L_tmp, dist_min); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON if (L_tmp1 < 0) { index = i; @@ -446,7 +444,7 @@ Word16 gain_enc_uv( /* o : quantization pitch index gacelp_uv = 0; move16(); - if (sub(func_type, FUNC_GAIN_ENC_GACELP_UV) == 0) + if (EQ_16(func_type, FUNC_GAIN_ENC_GACELP_UV)) { gacelp_uv = 1; move16(); @@ -617,13 +615,13 @@ Word16 gain_enc_uv( /* o : quantization pitch index tmp = 0; move16(); - if (sub(c_e, c_index2_e) < 0) + if (LT_16(c_e, c_index2_e)) { tmp = 1; move16(); } test(); - if (sub(c_e, c_index2_e) == 0 && sub(abs_s(c), abs_s(c_index2)) < 0) + if (EQ_16(c_e, c_index2_e)&<_16(abs_s(c),abs_s(c_index2))) { tmp = 1; move16(); diff --git a/lib_enc/qlpc_avq.c b/lib_enc/qlpc_avq.c index 493b651837a120fec3a4dbe35f1fafac95856b37..97ec3310313f9a6210bb2e38e732362bf267b9d9 100644 --- a/lib_enc/qlpc_avq.c +++ b/lib_enc/qlpc_avq.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ @@ -7,8 +7,6 @@ #include #include #include "stl.h" -#include "wmc_auto.h" - #include "control.h" #include "prot_fx.h" @@ -58,7 +56,7 @@ void qlpc_avq( *tmp_index = 0; move16(); - IF (sub(core, TCX_20_CORE) == 0) + IF (EQ_16(core, TCX_20_CORE)) { return; @@ -87,7 +85,7 @@ void qlpc_avq( } nbits = vlpc_2st_cod(lsfmid, lsfmid_q0, indxt, 3, sr_core); - IF (sub(nbits,nbt) < 0) + IF (LT_16(nbits,nbt)) { nbt = nbits; move16(); @@ -239,7 +237,7 @@ Word16 encode_lpc_avq( Encoder_State_fx *st, Word16 numlpc, Word16 *param_lpc, W nb_bits = add(nb_bits, 4); i = sub(qn1, 2); - if ( s_or(i<0, sub(i,3)>0) ) + if ( s_or(i<0, (Word16)GT_16(i,3))) { move16(); i = 3; @@ -248,7 +246,7 @@ Word16 encode_lpc_avq( Encoder_State_fx *st, Word16 numlpc, Word16 *param_lpc, W i = sub(qn2, 2); - if ( s_or(i<0, sub(i,3)>0) ) + if ( s_or(i<0, (Word16)GT_16(i,3))) { move16(); i = 3; @@ -260,11 +258,11 @@ Word16 encode_lpc_avq( Encoder_State_fx *st, Word16 numlpc, Word16 *param_lpc, W move16(); nb = qn1; - IF ( sub(nb,6) > 0) + IF ( GT_16(nb,6)) { nb = sub(nb, 3); } - ELSE IF ( sub(nb,4) > 0) + ELSE IF ( GT_16(nb,4)) { nb = sub(nb, 4); } @@ -288,11 +286,11 @@ Word16 encode_lpc_avq( Encoder_State_fx *st, Word16 numlpc, Word16 *param_lpc, W move16(); nb = qn2; - IF ( sub(nb,6) > 0) + IF ( GT_16(nb,6)) { nb = sub(nb, 3); } - ELSE IF ( sub(nb,4) > 0) + ELSE IF ( GT_16(nb,4)) { nb = sub(nb, 4); } diff --git a/lib_enc/qlpc_stoch.c b/lib_enc/qlpc_stoch.c index 484d3dd2dac6a70b9086f1fe99104c37316219c0..4291a5c48b2ff000f3943c7cd90cd6e1cea0e79c 100644 --- a/lib_enc/qlpc_stoch.c +++ b/lib_enc/qlpc_stoch.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ @@ -11,8 +11,6 @@ #include "rom_enc_fx.h" #include "rom_com_fx.h" #include "stl.h" -#include "wmc_auto.h" - #include "prot_fx.h" #include "basop_util.h" #include "rom_basop_util.h" @@ -67,7 +65,7 @@ void lpc_quantization( /* check resonance for pitch clipping algorithm */ gp_clip_test_lsf_fx( lsf, clip_var, M ); - IF ( (sub(core, TCX_10_CORE) == 0) ) + IF ( (EQ_16(core, TCX_10_CORE))) { E_LPC_lsp_lsf_conversion(lspmid, lsfmid, M); } @@ -77,7 +75,7 @@ void lpc_quantization( E_LPC_lsf_lsp_conversion(lsf_q, lsp_q, M); - IF( sub(core, TCX_10_CORE) == 0 ) + IF( EQ_16(core, TCX_10_CORE)) { E_LPC_lsf_lsp_conversion( lsfmid_q, lspmid_q, M ); } @@ -87,7 +85,7 @@ void lpc_quantization( /****** Low-rate LPC quantizer *******/ - ELSE IF ( sub(lpcQuantization, 1) == 0) + ELSE IF ( EQ_16(lpcQuantization, 1)) { lsp2lsf_fx(lsp, lsf, M, extract_l(st->sr_core)); @@ -98,7 +96,7 @@ void lpc_quantization( /*Force safety net when possible in case of transitions*/ test(); test(); - IF( st->tc_cnt_fx >= 1 || L_sub(st->last_core_brate_fx,SID_2k40) <= 0 || (sub(st->next_force_safety_net_fx ,1) == 0) ) + IF( st->tc_cnt_fx >= 1 || LE_32(st->last_core_brate_fx,SID_2k40)||(EQ_16(st->next_force_safety_net_fx,1))) { force_sf = 1; move16(); @@ -107,14 +105,14 @@ void lpc_quantization( } test(); - IF ( sub(st->next_force_safety_net_fx,1) == 0 && sub(st->Opt_RF_ON,1)==0 ) + IF ( EQ_16(st->next_force_safety_net_fx,1)&&EQ_16(st->Opt_RF_ON,1)) { force_sf = 1; st->next_force_safety_net_fx = 0; } test(); - IF ( L_sub(st->sr_core, INT_FS_16k)== 0 && sub(coder_type,UNVOICED) == 0 ) + IF ( EQ_32(st->sr_core, INT_FS_16k)&&EQ_16(coder_type,UNVOICED)) { lsf_end_enc_fx( st, lsf, lsf_q, mem_AR, mem_MA, ENDLSF_NBITS, GENERIC, st->bwidth_fx, Bin_Ener, Q_ener, st->sr_core, st->core_brate_fx, &st->streaklimit_fx, &st->pstreaklen_fx, force_sf, 0, @@ -141,8 +139,8 @@ void lpc_quantization( test(); test(); test(); - IF ( sub(stab,add(STAB_FAC_LIMIT_FX, 6553/* =0.2 in Q15*/)) < 0 && - ( sub(coder_type,VOICED) == 0 || sub(coder_type,GENERIC) == 0) && sub(st->Opt_RF_ON,1)==0 ) + IF ( LT_16(stab,add(STAB_FAC_LIMIT_FX, 6553/* =0.2 in Q15*/))&& + ( EQ_16(coder_type,VOICED) || EQ_16(coder_type,GENERIC) ) && EQ_16(st->Opt_RF_ON,1 )) { st->next_force_safety_net_fx = 1; } @@ -246,7 +244,7 @@ void Unified_weighting_fx( move16(); Bin_Ener_fx = Bin_Ener_128_fx; } - ELSE IF( L_sub(sr_core, 12800) == 0 ) + ELSE IF( EQ_32(sr_core, 12800)) { ptr_lsf_fit_model = lsf_unified_fit_model_wb; nf_fx = 16384; @@ -314,7 +312,7 @@ void Unified_weighting_fx( L_tmp = L_max(Bin_Ener_fx[norm_lsf_fx[i]+1], L_tmp); /* Q_ener */ } - IF (L_sub(L_tmp, MIN_LOG_FX) <= 0) + IF (LE_32(L_tmp, MIN_LOG_FX)) { w_fft_fx[i] = MIN_LOG_VAL_FX; move16(); /* Q8 */ @@ -337,7 +335,7 @@ void Unified_weighting_fx( w_fft_fx[i] = round_fx(L_shl(L_tmp,10)); /* Q8 */ } - if (sub(w_fft_fx[i], min_fx) < 0) + if (LT_16(w_fft_fx[i], min_fx)) { min_fx = w_fft_fx[i]; move16(); @@ -346,7 +344,7 @@ void Unified_weighting_fx( FOR ( i=0; i @@ -10,8 +10,6 @@ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - static void rc_enc_shift_fx(Encoder_State_fx *st_fx); static void rc_enc_write_fx(Encoder_State_fx *st_fx, Word16 byte, Word16 bits); @@ -132,7 +130,7 @@ void rc_enc_finish_fx( st_fx->rc_low_fx = val; move32(); - IF ( sub(bits, sub(st_fx->rc_tot_bits_fx, st_fx->rc_num_bits_fx)) > 0 ) + IF ( GT_16(bits, sub(st_fx->rc_tot_bits_fx, st_fx->rc_num_bits_fx))) { bits = sub(st_fx->rc_tot_bits_fx, st_fx->rc_num_bits_fx); @@ -162,7 +160,7 @@ void rc_enc_finish_fx( bits = st_fx->rc_num_bits_fx; move16(); - WHILE (sub(bits, sub(st_fx->rc_tot_bits_fx, 16)) < 0) + WHILE (LT_16(bits, sub(st_fx->rc_tot_bits_fx, 16))) { rc_enc_write_fx(st_fx, 0, 16); bits = add(bits, 16); @@ -189,7 +187,7 @@ static void rc_enc_shift_fx( { test(); L_sub(0, 0); /* For comparision in if */ - IF (st_fx->rc_low_fx < (0xff000000UL) || sub(st_fx->rc_carry_fx, 1) == 0) + IF (st_fx->rc_low_fx < (0xff000000UL) || EQ_16(st_fx->rc_carry_fx, 1)) { IF (st_fx->rc_cache_fx >= 0) { @@ -227,11 +225,11 @@ void rc_enc_bits_fx( Word16 bits /* i : Number of bits used */ ) { - IF ( sub(add(rc_get_bits2_fx(st_fx->rc_num_bits_fx, st_fx->rc_range_fx), bits), st_fx->rc_tot_bits_fx) <= 0) + IF ( LE_16(add(rc_get_bits2_fx(st_fx->rc_num_bits_fx, st_fx->rc_range_fx), bits), st_fx->rc_tot_bits_fx)) { st_fx->rc_num_bits_fx = add(st_fx->rc_num_bits_fx, bits); - IF ( sub(bits, 16) > 0 ) + IF ( GT_16(bits, 16)) { push_indice_fx(st_fx, sub(IND_RC_END, st_fx->rc_offset_fx), u_extract_l(UL_lshr(value, 16)), sub(bits, 16)); st_fx->rc_offset_fx = add(st_fx->rc_offset_fx, 1); @@ -267,7 +265,7 @@ void rc_enc_uniform_fx( n = sub(32, norm_ul(UL_subNsD(tot, 1))); - IF (sub(n, 8) <= 0) + IF (LE_16(n, 8)) { rc_encode_fx(st_fx, value, 1, tot); } diff --git a/lib_enc/re8_cod_fx.c b/lib_enc/re8_cod_fx.c index 6bd14dd9242727a3ed7fc9972197aeecf3154af5..1d72617dee530e2faf82c98789a0f7a5f9aa2c91 100644 --- a/lib_enc/re8_cod_fx.c +++ b/lib_enc/re8_cod_fx.c @@ -1,12 +1,10 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "prot_fx.h" #include "stl.h" -#include "wmc_auto.h" - /*------------------------------------------------------------------------ * RE8_cod: @@ -38,7 +36,7 @@ void re8_cod_fx( re8_vor_fx(x, n, k, c_fx, &ka_fx); /* safeguard in case that the AVQ subquantizer is not found - might happen for extremely strong onsets at the end of the frame */ - IF( sub(ka_fx,NB_LEADER) >= 0 ) + IF( GE_16(ka_fx,NB_LEADER)) { *n = 0; move16(); diff --git a/lib_enc/reordernorm_fx.c b/lib_enc/reordernorm_fx.c index 5dcb24f0d0f84173b9221443ae148024bf96006b..c6669c1101392f933184a31c030736432424324e 100644 --- a/lib_enc/reordernorm_fx.c +++ b/lib_enc/reordernorm_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -7,9 +7,7 @@ #include "rom_com_fx.h" #include "prot_fx.h" -#include "stl.h" -#include "wmc_auto.h" - /* required for wmc_tool */ +#include "stl.h" /* required for wmc_tool */ /*--------------------------------------------------------------------------*/ /* Function reordernorm_fx */ diff --git a/lib_enc/rom_enc_fx.c b/lib_enc/rom_enc_fx.c index 2a0a4ea92b2ac0dbae0325a1cce52b3928ace8be..30a82fea1c3cacabf8c8b9d2486cba9a475c32f8 100644 --- a/lib_enc/rom_enc_fx.c +++ b/lib_enc/rom_enc_fx.c @@ -1,11 +1,9 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "stl.h" -#include "wmc_auto.h" - #include "cnst_fx.h" /* Common constants */ #include "rom_enc_fx.h" #include "basop_util.h" diff --git a/lib_enc/rom_enc_fx.h b/lib_enc/rom_enc_fx.h index 602051687a06b94c2a5671682149c6b2b643aade..5c9434ed3bc52dcb42e6fb04530f8bdc8f68cf5c 100644 --- a/lib_enc/rom_enc_fx.h +++ b/lib_enc/rom_enc_fx.h @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #ifndef ROM_ENC_FX_H diff --git a/lib_enc/rst_enc_fx.c b/lib_enc/rst_enc_fx.c index edb1a11b4fc8254e7cdceffdae865d7c5fc9b556..c24596e2ea7dbda5f8d629534072aeece519b672 100644 --- a/lib_enc/rst_enc_fx.c +++ b/lib_enc/rst_enc_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -7,8 +7,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*-------------------------------------------------------------------* * CNG_reset_enc() @@ -33,7 +31,7 @@ void CNG_reset_enc_fx( move16(); mem->gc_threshold = 0; move16(); - IF( sub(VBR_cng_reset_flag,1) == 0 ) + IF( EQ_16(VBR_cng_reset_flag,1)) { set16_fx( mem->mem_syn, 0, M ); } @@ -48,7 +46,7 @@ void CNG_reset_enc_fx( move16(); /* reset the pitch buffer in case of FRAME_NO_DATA or SID frames */ - IF( sub(st_fx->L_frame_fx,L_FRAME) == 0 ) + IF( EQ_16(st_fx->L_frame_fx,L_FRAME)) { set16_fx( pitch_buf, L_SUBFR, NB_SUBFR ); } diff --git a/lib_enc/scale_enc_fx.c b/lib_enc/scale_enc_fx.c index ab352d00ef2110aec01bc4791dd9731e9a248637..c7e3dc067fa91255c62f1253f369890507bbcfd2 100644 --- a/lib_enc/scale_enc_fx.c +++ b/lib_enc/scale_enc_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -7,8 +7,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*-------------------------------------------------------------------* * Scale_wsp @@ -92,12 +90,12 @@ void Preemph_scaled( * Scale signal to get maximum of precision in filtering * *---------------------------------------------------------------*/ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF QVal = shl(1, sub(15,bits)); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON mu = shr(Preemph_factor, bits); /* Q15 --> Q(15-bits) */ - IF(sub(Search_scaling,1)==0) + IF(EQ_16(Search_scaling,1)) { /* get max of new preemphased samples (L_FRAME+L_FILT) */ @@ -131,7 +129,7 @@ void Preemph_scaled( IF (tmp_fixed == 0) { - IF ( sub(last_coder_type, UNVOICED) != 0 ) + IF ( NE_16(last_coder_type, UNVOICED)) { *Q_new = s_min(*Q_new, 1); move16(); diff --git a/lib_enc/set_impulse_fx.c b/lib_enc/set_impulse_fx.c index aeaee29739f2f54662ef9c862674200b6d1fa470..51c9de21baa28fa5b410a0843f6196046c8f9ffd 100644 --- a/lib_enc/set_impulse_fx.c +++ b/lib_enc/set_impulse_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "cnst_fx.h" /* Common constants */ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*-----------------------------------------------------------------* * Local constant @@ -72,7 +70,7 @@ void set_impulse_fx( FOR (m = 0; m < NUM_IMPULSE; m++) { /* set searching ranges */ - IF (sub(*imp_pos, L_SUBFR-INPOL) < 0) + IF (LT_16(*imp_pos, L_SUBFR-INPOL)) { end1 = add(*imp_pos, INPOL); } @@ -81,7 +79,7 @@ void set_impulse_fx( end1 = L_SUBFR; move16(); } - IF (sub(*imp_pos, INPOL) > 0) + IF (GT_16(*imp_pos, INPOL)) { start1 = sub(*imp_pos, INPOL); } @@ -90,7 +88,7 @@ void set_impulse_fx( start1 = 0; move16(); } - IF (sub(start1, L_IMPULSE2)>0) + IF (GT_16(start1, L_IMPULSE2)) { start2 = start1; move16(); @@ -104,7 +102,7 @@ void set_impulse_fx( /*-----------------------------------------------------------* * nominator & DEnominator, gh=convolve(g,h) *-----------------------------------------------------------*/ - IF (sub(start1, L_IMPULSE2) <0 ) + IF (LT_16(start1, L_IMPULSE2)) { Lrr = L_deposit_l(0); Ldd = L_deposit_l(0); @@ -159,7 +157,7 @@ void set_impulse_fx( convolve_tc_fx(&Glottal_cdbk_fx[m*L_IMPULSE], h_orig_fx, gh_fx, L_IMPULSE, L_SUBFR); } - IF (sub(end1, start2) >= 0) + IF (GE_16(end1, start2)) { /* DEnominator row */ Lrr = L_mult(gh_fx[0], gh_fx[0]); @@ -198,7 +196,7 @@ void set_impulse_fx( num = div_s(num,den); krit_fx = shr(num, sub(sub(shl(exp_num, 1), exp_den), 2)); /* Q18 */ - IF (sub(krit_fx, krit_max_fx) > 0) + IF (GT_16(krit_fx, krit_max_fx)) { krit_max_fx = krit_fx; move16(); @@ -223,7 +221,7 @@ void set_impulse_fx( FOR (i = sub(*imp_pos, L_IMPULSE2); i <= j; i++) { test(); - if (i >= 0 && sub(i, L_SUBFR) < 0) + if (i >= 0 && LT_16(i, L_SUBFR)) { exc_fx[i] = pt_Glt[i]; move16();/*Q13*/ diff --git a/lib_enc/setmodeindex.c b/lib_enc/setmodeindex.c index 5435761682eb7c7f003cee414429497355fc137f..412798c6919e456f0a17d729bc758924e5bce699 100644 --- a/lib_enc/setmodeindex.c +++ b/lib_enc/setmodeindex.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -9,8 +9,6 @@ #include "options.h" #include "stl.h" -#include "wmc_auto.h" - #include "prot_fx.h" #include "cnst_fx.h" #include "rom_com_fx.h" @@ -38,10 +36,10 @@ void SetModeIndex( test(); test(); IF( - (L_sub(st->last_total_brate_fx,total_brate) != 0) || - (sub(st->last_bwidth_fx,bwidth) != 0) || - (sub(st->last_codec_mode,MODE1) == 0 ) - || (sub(st->rf_mode_last,st->rf_mode) != 0 ) + (NE_32(st->last_total_brate_fx,total_brate) ) || + (NE_16(st->last_bwidth_fx,bwidth) ) || + (EQ_16(st->last_codec_mode,MODE1) ) + || (NE_16(st->rf_mode_last,st->rf_mode) ) ) { core_coder_mode_switch( st, st->bwidth_fx, total_brate, shift); diff --git a/lib_enc/sig_clas.c b/lib_enc/sig_clas.c index 014905da2eda4be70efcaac841851b5011db4649..312928e5f50ea6ac7ad05d2ae507044e21397c24 100644 --- a/lib_enc/sig_clas.c +++ b/lib_enc/sig_clas.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -7,8 +7,6 @@ #include "cnst_fx.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*---------------------------------------------------------------------* * Local constants @@ -80,12 +78,12 @@ Word16 signal_clas_fx( /* o : classification for current frames test(); test(); - IF (L_sub(Ltmp, 2048) < 0) + IF (LT_32(Ltmp, 2048)) { een = 0; move16(); } - ELSE IF (L_sub(Ltmp, THRES_EEN) > 0 || hi > 0 || hi2 > 0) + ELSE IF (GT_32(Ltmp, THRES_EEN)||hi>0||hi2>0) { een = 512; move16(); @@ -165,7 +163,7 @@ Word16 signal_clas_fx( /* o : classification for current frames /* FEC classification */ test(); test(); - IF (localVAD == 0 || sub(*coder_type,UNVOICED) == 0 || sub(relE,-1536) < 0) + IF (localVAD == 0 || EQ_16(*coder_type,UNVOICED)||LT_16(relE,-1536)) { clas = UNVOICED_CLAS; move16(); @@ -178,12 +176,12 @@ Word16 signal_clas_fx( /* o : classification for current frames case ONSET: case VOICED_TRANSITION: - IF (sub(fmerit1, 16056) < 0) /*0.49f*/ + IF (LT_16(fmerit1, 16056)) /*0.49f*/ { clas = UNVOICED_CLAS; move16(); } - ELSE IF (sub(fmerit1, 21626) < 0) /*0.66*/ + ELSE IF (LT_16(fmerit1, 21626)) /*0.66*/ { clas = VOICED_TRANSITION; move16(); @@ -197,12 +195,12 @@ Word16 signal_clas_fx( /* o : classification for current frames case UNVOICED_CLAS: case UNVOICED_TRANSITION: - IF (sub(fmerit1, 20643) > 0) /*0.63*/ + IF (GT_16(fmerit1, 20643)) /*0.63*/ { clas = ONSET; move16(); } - ELSE IF (sub(fmerit1, 19169) > 0) /*0.585*/ + ELSE IF (GT_16(fmerit1, 19169)) /*0.585*/ { clas = UNVOICED_TRANSITION; move16(); @@ -232,10 +230,10 @@ Word16 signal_clas_fx( /* o : classification for current frames test(); test(); test(); - if( ( (sub(*coder_type,UNVOICED) == 0) || - (sub(st->input_bwidth_fx,NB) != 0 && sub(fmerit1,13435) < 0 && sub(st->mold_corr_fx,21299) > 0 ) || /* WB case */ - (sub(st->input_bwidth_fx,NB) == 0 && sub(mult_r(fmerit1,28836),13435) < 0 && sub(st->mold_corr_fx,18022) > 0 ) ) && /* NB case */ - sub(relE,-3840) > 0 && sub(st->lt_dec_thres_fx,768) < 0 ) /* to compute unvoiced on frame that tends to speech */ + if( ( (EQ_16(*coder_type,UNVOICED))|| + (NE_16(st->input_bwidth_fx,NB) && LT_16(fmerit1,13435) && GT_16(st->mold_corr_fx,21299) ) || /* WB case */ + (EQ_16(st->input_bwidth_fx,NB) && LT_16(mult_r(fmerit1,28836),13435) && GT_16(st->mold_corr_fx,18022) ) ) && /* NB case */ + GT_16(relE,-3840) && LT_16(st->lt_dec_thres_fx,768) ) /* to compute unvoiced on frame that tends to speech */ { *uc_clas = UNVOICED_CLAS; move16(); @@ -248,26 +246,26 @@ Word16 signal_clas_fx( /* o : classification for current frames /* tc_cnt == 1: onset/transition frame, coded by GC mode */ /* tc_cnt == 2: frame after onset/transition frame, coded by TC mode */ - if( sub(clas,UNVOICED_CLAS ) == 0) + if( EQ_16(clas,UNVOICED_CLAS )) { st->tc_cnt_fx = 0; move16(); } test(); - if( sub(clas,VOICED_TRANSITION) >= 0 && st->tc_cnt_fx >= 0 ) + if( GE_16(clas,VOICED_TRANSITION)&&st->tc_cnt_fx>=0) { st->tc_cnt_fx = add(st->tc_cnt_fx,1); move16(); } - if( sub(st->tc_cnt_fx,2) > 0 ) + if( GT_16(st->tc_cnt_fx,2)) { st->tc_cnt_fx = -1; move16(); } - IF ( sub(st->codec_mode,MODE1) == 0 ) + IF ( EQ_16(st->codec_mode,MODE1)) { /*---------------------------------------------------------------------* * Coder type modification @@ -279,7 +277,7 @@ Word16 signal_clas_fx( /* o : classification for current frames /* At higher rates, use GC coding instead of UC coding to improve quality */ test(); - if( L_sub(st->total_brate_fx,ACELP_9k60) > 0 && sub(*coder_type,UNVOICED) == 0 ) + if( GT_32(st->total_brate_fx,ACELP_9k60)&&EQ_16(*coder_type,UNVOICED)) { *coder_type = GENERIC; move16(); @@ -288,7 +286,7 @@ Word16 signal_clas_fx( /* o : classification for current frames /* Prevent UC coding on mixed content at 9.6 kb/s */ test(); test(); - if( L_sub(st->total_brate_fx,ACELP_9k60) == 0 && sub(*coder_type,UNVOICED) == 0 && st->audio_frame_cnt_fx != 0 ) + if( EQ_32(st->total_brate_fx,ACELP_9k60)&&EQ_16(*coder_type,UNVOICED)&&st->audio_frame_cnt_fx!=0) { *coder_type = GENERIC; move16(); @@ -307,9 +305,9 @@ Word16 signal_clas_fx( /* o : classification for current frames test(); if( localVAD == 0 && ( ( - sub(*coder_type,UNVOICED) == 0 - && ( ( st->Opt_SC_VBR_fx == 0) || ( ( st->Opt_SC_VBR_fx == 1 ) && st->vbr_generic_ho_fx == 0 && sub(st->last_coder_type_fx,UNVOICED) > 0 )) ) - || sub(*coder_type,TRANSITION) == 0 || sub(*coder_type,VOICED) == 0 ) + EQ_16(*coder_type,UNVOICED) + && ( ( st->Opt_SC_VBR_fx == 0) || ( ( st->Opt_SC_VBR_fx == 1 ) && st->vbr_generic_ho_fx == 0 && GT_16(st->last_coder_type_fx,UNVOICED) )) ) + || EQ_16(*coder_type,TRANSITION) || EQ_16(*coder_type,VOICED) ) ) { @@ -319,14 +317,14 @@ Word16 signal_clas_fx( /* o : classification for current frames test(); test(); - if( sub(*coder_type,GENERIC) == 0 && sub(unmod_coder_type,UNVOICED) == 0 && ( st->Opt_SC_VBR_fx == 1 ) ) + if( EQ_16(*coder_type,GENERIC)&&EQ_16(unmod_coder_type,UNVOICED)&&(st->Opt_SC_VBR_fx==1)) { st->vbr_generic_ho_fx = 1; move16(); } test(); - if ( sub(*coder_type,UNVOICED) > 0 && ( st->Opt_SC_VBR_fx == 1 ) ) + if ( GT_16(*coder_type,UNVOICED)&&(st->Opt_SC_VBR_fx==1)) { st->vbr_generic_ho_fx = 0; move16(); @@ -335,7 +333,7 @@ Word16 signal_clas_fx( /* o : classification for current frames st->last_7k2_coder_type_fx = *coder_type; move16(); test(); - if( localVAD == 0 && sub( *coder_type, UNVOICED ) == 0 ) + if( localVAD == 0 && EQ_16( *coder_type, UNVOICED )) { st->last_7k2_coder_type_fx = GENERIC; move16(); @@ -343,12 +341,12 @@ Word16 signal_clas_fx( /* o : classification for current frames /* Select TC mode for appropriate frames which is in general VOICED_TRANSITION, VOICED_CLAS or MODE1_ONSET frames following UNVOICED_CLAS frames */ test(); - IF( localVAD != 0 && sub(st->tc_cnt_fx,1) >= 0 ) /* TC mode is allowed only in active signal */ + IF( localVAD != 0 && GE_16(st->tc_cnt_fx,1)) /* TC mode is allowed only in active signal */ { /* frame after onset/transition frame is coded by TC mode */ *coder_type = TRANSITION; move16(); - if ( sub(st->tc_cnt_fx,1) == 0 ) + if ( EQ_16(st->tc_cnt_fx,1)) { /* onset/transition frame is always coded using GC mode */ *coder_type = GENERIC; @@ -359,7 +357,7 @@ Word16 signal_clas_fx( /* o : classification for current frames /* At higher rates and with 16kHz core, allow only GC and TC mode */ test(); test(); - if( (L_sub(st->total_brate_fx,ACELP_24k40) >= 0) && sub(*coder_type,GENERIC) != 0 && sub(*coder_type,TRANSITION) != 0 ) + if( (GE_32(st->total_brate_fx,ACELP_24k40))&&NE_16(*coder_type,GENERIC)&&NE_16(*coder_type,TRANSITION)) { *coder_type = GENERIC; move16(); @@ -369,7 +367,7 @@ Word16 signal_clas_fx( /* o : classification for current frames test(); test(); test(); - if( sub(*coder_type,VOICED) == 0 && sub(st->input_bwidth_fx,NB) == 0 && sub(relE,-2560) < 0 && L_sub(st->total_brate_fx,ACELP_8k00) <= 0 ) + if( EQ_16(*coder_type,VOICED)&&EQ_16(st->input_bwidth_fx,NB)&<_16(relE,-2560)&&LE_32(st->total_brate_fx,ACELP_8k00)) { *coder_type = GENERIC; move16(); diff --git a/lib_enc/spec_center.c b/lib_enc/spec_center.c index 6d073c80cc68a8c652f3f5f2f28f286dc1c2da4a..04393a9ad7d1e8cba593e4609546575afd97627d 100644 --- a/lib_enc/spec_center.c +++ b/lib_enc/spec_center.c @@ -1,11 +1,9 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "basop_util.h" #include "stl.h" -#include "wmc_auto.h" - #include "vad_basop.h" #include "prot_fx.h" #include "rom_enc_fx.h" @@ -33,9 +31,9 @@ void spec_center(Word32* sb_power, /*(i) energy of sub-band divided uniformly*/ Word16 d_t_sp_center_Qtmp; - zerop1 = L_add(0, 0); - t_sp_center = L_add(0, 0); - frame_power = L_add(0, 0); + zerop1 = 0; move32(); + t_sp_center = 0; move32(); + frame_power = 0; move32(); FOR (i=0; i<10; i++) { @@ -50,12 +48,12 @@ void spec_center(Word32* sb_power, /*(i) energy of sub-band divided uniformly*/ frame_power = L_add(sb_power_shr[i], frame_power);/*0-9 */ } - t_sp_center_nb = L_add(0, t_sp_center); - frame_power_nb = L_add(0, frame_power); + t_sp_center_nb = t_sp_center; move32(); + frame_power_nb = frame_power; move32(); /*+0.1 */ Q_t_sc = sub(Q_sb_p, 10); - IF (sub(Q_t_sc,34)>=0) + IF (GE_16(Q_t_sc,34)) { t_sp_center = L_shr(t_sp_center,sub(Q_t_sc, 33)); zerop1 = L_shr(CNT0P1,1); @@ -71,7 +69,7 @@ void spec_center(Word32* sb_power, /*(i) energy of sub-band divided uniformly*/ t_sp_center_num = L_add(t_sp_center, zerop1); Q_f_p = sub(Q_sb_p, 5); - IF (sub(Q_f_p,34)>=0) + IF (GE_16(Q_f_p,34)) { frame_power = L_shr(frame_power,sub(Q_f_p, 33)); zerop1 = L_shr(CNT0P1,1); @@ -88,7 +86,7 @@ void spec_center(Word32* sb_power, /*(i) energy of sub-band divided uniformly*/ frame_power_den = L_add(frame_power, zerop1); IF (frame_power == 0) { - frame_power_den = L_add(CNT0P1, 0); + frame_power_den = CNT0P1; move32(); Q_f_p = 34; move16(); } @@ -112,9 +110,9 @@ void spec_center(Word32* sb_power, /*(i) energy of sub-band divided uniformly*/ sp_center[2] = d_t_sp_center; move16(); - t_sp_center = L_add(0, 0); - frame_power = L_add(0, 0); - IF(L_sub(bandwith,CLDFBVAD_WB_ID)==0) + t_sp_center = 0; move32(); + frame_power = 0; move32(); + IF(EQ_32(bandwith,CLDFBVAD_WB_ID)) { FOR (i=10; i<20; i++) { @@ -131,7 +129,7 @@ void spec_center(Word32* sb_power, /*(i) energy of sub-band divided uniformly*/ /*+0.1 */ Q_t_sc = sub(Q_sb_p, 13); - IF (sub(Q_t_sc, 34) >= 0) + IF (GE_16(Q_t_sc, 34)) { t_sp_center = L_shr(t_sp_center,sub(Q_t_sc, 33)); zerop1 = L_shr(CNT0P1,1); @@ -147,7 +145,7 @@ void spec_center(Word32* sb_power, /*(i) energy of sub-band divided uniformly*/ t_sp_center_num = L_add(t_sp_center, zerop1); Q_f_p = sub(Q_sb_p, 5); - IF (sub(Q_f_p,34)>=0) + IF (GE_16(Q_f_p,34)) { frame_power = L_shr(frame_power, sub(Q_f_p, 33)); zerop1 = L_shr(CNT0P1,1); @@ -163,7 +161,7 @@ void spec_center(Word32* sb_power, /*(i) energy of sub-band divided uniformly*/ frame_power_den = L_add(frame_power, zerop1); IF (frame_power == 0) { - frame_power_den = L_add(0, CNT0P1); + frame_power_den = CNT0P1; move32(); Q_f_p = 34; move16(); } @@ -185,7 +183,7 @@ void spec_center(Word32* sb_power, /*(i) energy of sub-band divided uniformly*/ sp_center[3]= shr(d_t_sp_center,d_t_sp_center_Qtmp); move16(); } - ELSE IF(L_sub(bandwith, CLDFBVAD_SWB_ID)==0) + ELSE IF(EQ_32(bandwith, CLDFBVAD_SWB_ID)) { FOR (i=10; i<24; i++) { @@ -203,7 +201,7 @@ void spec_center(Word32* sb_power, /*(i) energy of sub-band divided uniformly*/ /*+0.1 */ Q_t_sc = sub(Q_sb_p, 14); - IF (sub(Q_t_sc,34)>=0) + IF (GE_16(Q_t_sc,34)) { t_sp_center = L_shr(t_sp_center, limitScale32(sub(Q_t_sc, 33))); zerop1 = L_shr(CNT0P1,1); @@ -219,7 +217,7 @@ void spec_center(Word32* sb_power, /*(i) energy of sub-band divided uniformly*/ t_sp_center_num = L_add(t_sp_center, zerop1); Q_f_p = sub(Q_sb_p, 5); - IF (sub(Q_f_p,34)>=0) + IF (GE_16(Q_f_p,34)) { frame_power = L_shr(frame_power,sub(Q_f_p, 33)); zerop1 = L_shr(CNT0P1,1); @@ -235,7 +233,7 @@ void spec_center(Word32* sb_power, /*(i) energy of sub-band divided uniformly*/ frame_power_den = L_add(frame_power, zerop1); IF (frame_power == 0) { - frame_power_den = L_add(0, CNT0P1); + frame_power_den = CNT0P1; move32(); Q_f_p = 34; move16(); } @@ -258,8 +256,8 @@ void spec_center(Word32* sb_power, /*(i) energy of sub-band divided uniformly*/ } ELSE { - t_sp_center = L_add(0, t_sp_center_nb); - frame_power = L_add(0, frame_power_nb); + t_sp_center = t_sp_center_nb; move32(); + frame_power = frame_power_nb; move32(); IF (frame_power==0) { @@ -283,8 +281,8 @@ void spec_center(Word32* sb_power, /*(i) energy of sub-band divided uniformly*/ move16(); move16(); - t_sp_center = L_add(0, 0); - frame_power = L_add(0, 0); + t_sp_center = 0; move32(); + frame_power = 0; move32(); FOR(i=1; i<10; i++) { sb_power_mlt = Mpy_32_16_1(sb_power[i],i_t_1[i-1]); diff --git a/lib_enc/spec_flatness.c b/lib_enc/spec_flatness.c index 7492574763e6013c7c861c9c6f69a2fa051b7642..083d9d8b97048b21f022e238674c4b47d2a77fa1 100644 --- a/lib_enc/spec_flatness.c +++ b/lib_enc/spec_flatness.c @@ -1,12 +1,10 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "basop_util.h" #include "stl.h" -#include "wmc_auto.h" - #include "vad_basop.h" #include "prot_fx.h" @@ -34,7 +32,8 @@ void spec_flatness(Word32 *spec_amp, /*(i) spectral amplitude*/ smooth_spec_amp32 = smooth_spec_amp; - zerop1 = L_add(0,0); + zerop1 = 0; + move32(); prods_Q = 0; move16(); FOR(i=MIN_AMP_ID; i<=MAX_AMP_ID; i++) @@ -43,8 +42,10 @@ void spec_flatness(Word32 *spec_amp, /*(i) spectral amplitude*/ move32(); } /*sSFM1*/ - sums = L_add(0,0); - prods = L_add(1,0); + sums = 0; + move32(); + prods = 1; + move32(); prods_Q = 0; move16(); @@ -90,7 +91,7 @@ void spec_flatness(Word32 *spec_amp, /*(i) spectral amplitude*/ sums = MUL_F(sums, 0x0888); /*+0.1 */ - IF (sub(prods_Q, 34) >= 0) + IF (GE_16(prods_Q, 34)) { prods = L_shr(prods, sub(prods_Q, 33)); zerop1 = L_shr(CNT0P1, 1); @@ -126,8 +127,10 @@ void spec_flatness(Word32 *spec_amp, /*(i) spectral amplitude*/ move16(); /*sSFM2*/ - sums = L_add(0,0); - prods = L_add(1,0); + sums = 0; + move32(); + prods = 1; + move32(); prods_Q = 0; move16(); @@ -172,7 +175,7 @@ void spec_flatness(Word32 *spec_amp, /*(i) spectral amplitude*/ sums = MUL_F(sums, 0x0666); /*+0.1 */ - IF (sub(prods_Q, 34) >= 0) + IF (GE_16(prods_Q, 34)) { prods = L_shr(prods,sub(prods_Q, 33)); zerop1 = L_shr(CNT0P1,1); @@ -207,8 +210,10 @@ void spec_flatness(Word32 *spec_amp, /*(i) spectral amplitude*/ sSFM[1] = add(mult(sSFM[1],0x6ccc),shr(mult(SFM,0x1333),SFM_Qtmp)); move16(); /*sSFM3*/ - sums = L_add(0,0); - prods = L_add(1,0); + sums = 0; + move32(); + prods =1; + move32(); prods_Q = 0; move16(); @@ -253,7 +258,7 @@ void spec_flatness(Word32 *spec_amp, /*(i) spectral amplitude*/ sums = MUL_F(sums, 0x051e); /*+0.1 */ - IF (sub(prods_Q, 34)>=0) + IF (GE_16(prods_Q, 34)) { prods = L_shr(prods,sub(prods_Q, 33)); zerop1 = L_shr(CNT0P1,1); diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index 4d0345b250939583d284626ebd0b31b0c6cee090..268857bab1516596a71e5569e8d7a099603e2857 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -10,8 +10,6 @@ #include "rom_enc_fx.h" #include "rom_com_fx.h" #include "stl.h" -#include "wmc_auto.h" - /*---------------------------------------------------------------------* * Local constants @@ -111,13 +109,13 @@ void speech_music_classif_fx( Q_esp, high_lpn_flag_ptr ); test(); - IF ( sub( st->codec_mode, MODE1) == 0 || L_sub(st->sr_core, 12800) == 0 ) + IF ( EQ_16( st->codec_mode, MODE1)||EQ_32(st->sr_core,12800)) { /* Improvement of the 1st stage decision on mixed/music content */ test(); - IF ( st->Opt_SC_VBR_fx == 0 && ( L_sub(st->total_brate_fx, ACELP_24k40) != 0 ) ) + IF ( st->Opt_SC_VBR_fx == 0 && ( NE_32(st->total_brate_fx, ACELP_24k40))) { @@ -134,7 +132,7 @@ void speech_music_classif_fx( *sp_aud_decision2 = *sp_aud_decision1; move16(); - IF ( sub(st->bwidth_fx,NB) > 0 ) + IF ( GT_16(st->bwidth_fx,NB)) { sp_mus_classif_2nd_fx( st, *sp_aud_decision1, sp_aud_decision2, pitch, Etot, coder_type, attack_flag, inp, Q_inp-1, localVAD, vad_flag ); @@ -143,7 +141,7 @@ void speech_music_classif_fx( and/or stable pitch with high correlation at low bitrates*/ test(); test(); - IF ( flag_spitch && sub(st->bwidth_fx,WB) == 0 && L_sub(st->total_brate_fx,ACELP_13k20) < 0 ) + IF ( flag_spitch && EQ_16(st->bwidth_fx,WB)&<_32(st->total_brate_fx,ACELP_13k20)) { *sp_aud_decision2 = 0; move16(); @@ -154,7 +152,7 @@ void speech_music_classif_fx( /* Context-based improvement of 1st and 2nd stage decision on stable tonal signals */ test(); - IF ( st->Opt_SC_VBR_fx == 0 && ( L_sub(st->total_brate_fx, ACELP_24k40) != 0 ) ) + IF ( st->Opt_SC_VBR_fx == 0 && ( NE_32(st->total_brate_fx, ACELP_24k40))) { tonal_context_improv_fx( st, PS, sp_aud_decision1, sp_aud_decision2, vad_flag, pitch, voicing, voi_fv, cor_map_sum_fv, LPCErr, Q_inp + QSCALE -2 ); @@ -165,15 +163,15 @@ void speech_music_classif_fx( test(); test(); test(); - IF ( !st->Opt_SC_VBR_fx && L_sub(st->total_brate_fx, ACELP_13k20) == 0 && sub(vad_flag, 1) == 0 && - ( sub(st->bwidth_fx, WB) == 0 || sub(st->bwidth_fx, SWB) == 0 ) ) + IF ( !st->Opt_SC_VBR_fx && EQ_32(st->total_brate_fx, ACELP_13k20)&&EQ_16(vad_flag,1)&& + ( EQ_16(st->bwidth_fx, WB) || EQ_16(st->bwidth_fx, SWB)) ) { detect_sparseness_fx( st, localVAD_HE_SAD, sp_aud_decision1, sp_aud_decision2, voi_fv ); } /* override speech/music classification to ACELP when background noise level reaches certain level */ /* this is a patch against mis-classifications during active noisy speech segments */ - IF ( sub(st->lp_noise_fx, 3072) > 0 ) + IF ( GT_16(st->lp_noise_fx, 3072)) { *sp_aud_decision1 = 0; move16(); @@ -191,9 +189,9 @@ void speech_music_classif_fx( test(); test(); test(); - IF ( sub(vad_flag,1) == 0 && L_sub(st->total_brate_fx,ACELP_13k20) >= 0 && L_sub(st->total_brate_fx,ACELP_24k40) < 0 && - sub(st->lp_noise_fx,3072) > 0 && *sp_aud_decision1 == 0 && sub(st->bwidth_fx,SWB) >= 0 && - sub(st->coder_type_raw_fx,UNVOICED) == 0 ) + IF ( EQ_16(vad_flag,1)&&GE_32(st->total_brate_fx,ACELP_13k20)&<_32(st->total_brate_fx,ACELP_24k40)&& + GT_16(st->lp_noise_fx,3072) && *sp_aud_decision1 == 0 && GE_16(st->bwidth_fx,SWB) && + EQ_16(st->coder_type_raw_fx,UNVOICED)) { st->GSC_noisy_speech_fx = 1; move16(); @@ -204,7 +202,7 @@ void speech_music_classif_fx( test(); test(); test(); - IF ( sub(st->codec_mode,MODE1) == 0 && ( *sp_aud_decision2 || st->GSC_noisy_speech_fx ) ) + IF ( EQ_16(st->codec_mode,MODE1)&&(*sp_aud_decision2||st->GSC_noisy_speech_fx)) { *coder_type = AUDIO; move16(); @@ -291,7 +289,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decision flag (1-music, 0-speech L_tmp = L_mac(L_tmp, pitch[2], 10923); test(); - IF ( sub(st_fx->tc_cnt_fx,1) == 0 || sub(st_fx->tc_cnt_fx,2) == 0 ) + IF ( EQ_16(st_fx->tc_cnt_fx,1)||EQ_16(st_fx->tc_cnt_fx,2)) { *pFV++ = pitch[2]; move16(); @@ -304,7 +302,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decision flag (1-music, 0-speech /* [1] voicing Q15 */ /*(float)(voicing[0] + voicing[1] + voicing[2]) / 3.0f*/ test(); - IF ( sub(st_fx->tc_cnt_fx,1) == 0 || sub(st_fx->tc_cnt_fx,2) == 0 ) + IF ( EQ_16(st_fx->tc_cnt_fx,1)||EQ_16(st_fx->tc_cnt_fx,2)) { *pFV++ = voicing[2]; move16(); @@ -346,7 +344,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decision flag (1-music, 0-speech move16(); /* [9] epsP Q10 */ - IF ( sub(st_fx->bwidth_fx,NB) == 0) + IF ( EQ_16(st_fx->bwidth_fx,NB)) { *pFV++ = -1687; move16(); /*Q10*/ @@ -458,7 +456,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decision flag (1-music, 0-speech FOR ( i = LOWEST_FBIN; i < HIGHEST_FBIN; i++ ) { /*mx = PS_norm[i] > st->past_PS[i] ? PS_norm[i] : st->past_PS[i];*/ - IF (L_sub(PS_norm[i],st_fx->past_PS_fx[i-LOWEST_FBIN]) > 0) + IF (GT_32(PS_norm[i],st_fx->past_PS_fx[i-LOWEST_FBIN])) { mx = PS_norm[i]; move16(); /*Q25 */ @@ -521,7 +519,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decision flag (1-music, 0-speech pFV = FV; move16(); - IF ( sub(st_fx->bwidth_fx,NB) == 0 ) + IF ( EQ_16(st_fx->bwidth_fx,NB)) { pSF_m = SF_8k_mult_fx; pSF_a = SF_8k_add_fx; @@ -625,8 +623,8 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decision flag (1-music, 0-speech *high_lpn_flag_ptr = 0; move16(); test(); - if ( (sub(lpn, lps) > 0) - && (sub(lpn, lpm) > 0) ) + if ( (GT_16(lpn, lps)) + && (GT_16(lpn, lpm)) ) { *high_lpn_flag_ptr = 1; move16(); @@ -648,7 +646,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decision flag (1-music, 0-speech /* determine HQ GENERIC speech class */ st_fx->hq_generic_speech_class_fx = 0; move16(); - if( sub(lps,add(lpm,256)) > 0 ) + if( GT_16(lps,add(lpm,256))) { st_fx->hq_generic_speech_class_fx = 1; move16(); @@ -664,11 +662,11 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decision flag (1-music, 0-speech test(); test(); test(); - IF ( sub(relE,-20*256) < 0 || (sub(lps,-5*512) <= 0 && sub(lpm,-5*512) <= 0) ) + IF ( LT_16(relE,-20*256)||(LE_16(lps,-5*512)&&LE_16(lpm,-5*512))) { IF ( st_fx->sp_mus_state_fx > 0 ) { - if ( sub(st_fx->sp_mus_state_fx,HANG_LEN) < 0 ) + if ( LT_16(st_fx->sp_mus_state_fx,HANG_LEN)) { /* energy is too low but we are in entry period -> reset the inactive counter to allow new entry later */ st_fx->inact_cnt_fx = 0; @@ -679,7 +677,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decision flag (1-music, 0-speech st_fx->sp_mus_state_fx = 0; move16(); } - ELSE IF ( sub(st_fx->sp_mus_state_fx,-HANG_LEN) > 0 ) + ELSE IF ( GT_16(st_fx->sp_mus_state_fx,-HANG_LEN)) { /* energy is still too low -> we are still in instable state */ st_fx->sp_mus_state_fx = sub(st_fx->sp_mus_state_fx,1); @@ -703,7 +701,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decision flag (1-music, 0-speech st_fx->inact_cnt_fx = 12; move16(); } - ELSE IF ( st_fx->sp_mus_state_fx > 0 && sub(st_fx->sp_mus_state_fx,HANG_LEN) < 0 ) + ELSE IF ( st_fx->sp_mus_state_fx > 0 && LT_16(st_fx->sp_mus_state_fx,HANG_LEN)) { /* we are inside an entry period -> increment the counter of entry frames */ st_fx->sp_mus_state_fx = add(st_fx->sp_mus_state_fx,1); @@ -718,7 +716,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decision flag (1-music, 0-speech ELSE { test(); - IF ( st_fx->sp_mus_state_fx > 0 && sub(st_fx->sp_mus_state_fx,HANG_LEN) < 0 ) + IF ( st_fx->sp_mus_state_fx > 0 && LT_16(st_fx->sp_mus_state_fx,HANG_LEN)) { st_fx->inact_cnt_fx = 0; move16(); @@ -729,7 +727,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decision flag (1-music, 0-speech } test(); - IF ( st_fx->sp_mus_state_fx > 0 && sub(st_fx->sp_mus_state_fx,HANG_LEN) < 0 ) + IF ( st_fx->sp_mus_state_fx > 0 && LT_16(st_fx->sp_mus_state_fx,HANG_LEN)) { st_fx->sp_mus_state_fx = -HANG_LEN; @@ -741,7 +739,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decision flag (1-music, 0-speech st_fx->sp_mus_state_fx = -1; move16(); } - ELSE IF ( sub(st_fx->sp_mus_state_fx,-HANG_LEN) > 0 ) + ELSE IF ( GT_16(st_fx->sp_mus_state_fx,-HANG_LEN)) { /* we are in inactive state */ st_fx->sp_mus_state_fx = sub(st_fx->sp_mus_state_fx,1); @@ -777,7 +775,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decision flag (1-music, 0-speech /* calculate weight based on drops of dlp (close to 1 during sudden drops of dlp, close to 0 otherwise) */ test(); - IF ( dlp < 0 && sub(dlp,st_fx->past_dlp_fx[0]) < 0 ) + IF ( dlp < 0 && LT_16(dlp,st_fx->past_dlp_fx[0])) { IF ( st_fx->past_dlp_fx[0] > 0 ) { @@ -810,7 +808,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decision flag (1-music, 0-speech L_tmp = L_mac(L_mult(wght, dlp), sub(512, wght), st_fx->wdlp_0_95_sp_fx); st_fx->wdlp_0_95_sp_fx = round_fx(L_shl(L_tmp, 6)); - if ( sub(st_fx->sp_mus_state_fx,-HANG_LEN) == 0 ) + if ( EQ_16(st_fx->sp_mus_state_fx,-HANG_LEN)) { st_fx->wdlp_0_95_sp_fx = 0; move16(); @@ -822,7 +820,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decision flag (1-music, 0-speech test(); test(); - IF ( !vad && sub(st_fx->sp_mus_state_fx,-HANG_LEN) == 0 ) + IF ( !vad && EQ_16(st_fx->sp_mus_state_fx,-HANG_LEN)) { /* inactive state */ dec = 0; @@ -834,7 +832,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decision flag (1-music, 0-speech dec = st_fx->past_dec_fx[0]; move16(); } - ELSE IF ( st_fx->sp_mus_state_fx > 0 && sub(st_fx->sp_mus_state_fx,HANG_LEN) < 0 ) + ELSE IF ( st_fx->sp_mus_state_fx > 0 && LT_16(st_fx->sp_mus_state_fx,HANG_LEN)) { /* entry state -> final decision is calculated based on weighted average of past non-binary decisions */ L_tmp = L_mult(w_spmus_fx[st_fx->sp_mus_state_fx-1][0], dlp); /*Q15*Q9 */ @@ -935,17 +933,17 @@ static void sp_mus_classif_2nd_fx( test(); test(); test(); - IF( sub(sp_aud_decision1,1) == 0 ) + IF( EQ_16(sp_aud_decision1,1)) { test(); test(); test(); - IF( sub(st->ener_RAT_fx,5898) < 0 && sub (st->lt_dec_thres_fx,7680) > 0 ) + IF( LT_16(st->ener_RAT_fx,5898)&>_16(st->lt_dec_thres_fx,7680)) { *sp_aud_decision2 = 0; move16(); } - ELSE IF( sub(st->high_stable_cor_fx, 1) == 0 && sub(pitch[0], 130) >= 0 ) + ELSE IF( EQ_16(st->high_stable_cor_fx, 1)&&GE_16(pitch[0],130)) { /* prevent GSC in highly correlated signal with low energy variation */ /* this is basically a patch against bassoon-type of music */ @@ -953,21 +951,21 @@ static void sp_mus_classif_2nd_fx( move16(); test(); - IF( sub(st->codec_mode,MODE1) == 0 && sub(*coder_type,TRANSITION) == 0 ) + IF( EQ_16(st->codec_mode,MODE1)&&EQ_16(*coder_type,TRANSITION)) { *coder_type = GENERIC; move16(); } } - ELSE IF( sub(st->gsc_lt_diff_etot_fx[MAX_LT-1],1152) > 0 && - sub(sub(st->gsc_lt_diff_etot_fx[MAX_LT-1], st->gsc_lt_diff_etot_fx[MAX_LT-2]),2560) > 0 ) /* 10.0f in Q8 */ + ELSE IF( GT_16(st->gsc_lt_diff_etot_fx[MAX_LT-1],1152)&& + GT_16(sub(st->gsc_lt_diff_etot_fx[MAX_LT-1], st->gsc_lt_diff_etot_fx[MAX_LT-2]),2560)) /* 10.0f in Q8 */ { - IF ( sub(st->tc_cnt_fx,1) == 0 ) + IF ( EQ_16(st->tc_cnt_fx,1)) { *sp_aud_decision2 = 0; move16(); - IF( sub(st->codec_mode,MODE1) == 0 ) + IF( EQ_16(st->codec_mode,MODE1)) { *coder_type = TRANSITION; move16(); @@ -975,20 +973,20 @@ static void sp_mus_classif_2nd_fx( } ELSE { - IF( sub(attack, ATT_3LSUB_POS) >= 0 ) + IF( GE_16(attack, ATT_3LSUB_POS)) { /* do TC coding if attack is located in the last subframe */ *sp_aud_decision2 = 0; move16(); *attack_flag = 1; move16(); - IF( sub(st->codec_mode,MODE1) == 0 ) + IF( EQ_16(st->codec_mode,MODE1)) { *coder_type = TRANSITION; move16(); } } - ELSE IF( sub(attack,ATT_SEG_LEN/2) >= 0 ) + ELSE IF( GE_16(attack,ATT_SEG_LEN/2)) { /* do GSC coding if attack is located after the first quarter of the first subframe */ /* (pre-echo will be treated at the decoder side) */ @@ -998,15 +996,15 @@ static void sp_mus_classif_2nd_fx( } } } - ELSE IF( sub(localVAD,1) == 0 && sub(*coder_type,GENERIC) == 0 && - ( (sub(attack,ATT_3LSUB_POS) >= 0 && L_sub(st->total_brate_fx,ACELP_24k40) < 0) || - (sub(attack,ATT_3LSUB_POS_16k) >= 0 && L_sub(st->total_brate_fx,ACELP_24k40) >= 0 && L_sub(st->total_brate_fx,ACELP_48k) < 0) ) + ELSE IF( EQ_16(localVAD,1)&&EQ_16(*coder_type,GENERIC)&& + ( (GE_16(attack,ATT_3LSUB_POS) && LT_32(st->total_brate_fx,ACELP_24k40)) || + (GE_16(attack,ATT_3LSUB_POS_16k) && GE_32(st->total_brate_fx,ACELP_24k40) && LT_32(st->total_brate_fx,ACELP_48k)) ) ) { /* do TC coding if attack is located in the last subframe */ *attack_flag = 1; move16(); - IF( sub(st->codec_mode,MODE1) == 0 ) + IF( EQ_16(st->codec_mode,MODE1)) { *coder_type = TRANSITION; move16(); @@ -1046,7 +1044,7 @@ static void var_cor_calc_fx( *high_stable_cor = 0; move16(); test(); - IF( sub(*mold_corr,26214) > 0 && sub(var_cor,2) < 0 ) + IF( GT_16(*mold_corr,26214)&<_16(var_cor,2)) { *high_stable_cor = 1; move16(); @@ -1080,7 +1078,7 @@ static Word16 attack_det_fx( /* o : attack flag att_3lsub_pos = ATT_3LSUB_POS; move16(); - if( L_sub(total_brate,ACELP_24k40) >= 0 ) + if( GE_32(total_brate,ACELP_24k40)) { att_3lsub_pos = ATT_3LSUB_POS_16k; move16(); @@ -1102,7 +1100,7 @@ static Word16 attack_det_fx( /* o : attack flag attack = maximum_32_fx( finc, ATT_NSEG, &etmp ); test(); - IF( sub(localVAD,1) == 0 && sub(coder_type,GENERIC) == 0 ) + IF( EQ_16(localVAD,1)&&EQ_16(coder_type,GENERIC)) { /*----------------------------------------------------------------------* * Detect if there is a strong onset in the last subframe @@ -1135,7 +1133,7 @@ static Word16 attack_det_fx( /* o : attack flag etmp2 = L_shl(L_tmp,sub(exp1,14)); /*Qx */ /* and compare them */ - if( L_sub(etmp,L_shr(etmp2,3)) > 0 ) + if( GT_32(etmp,L_shr(etmp2,3))) { /* stop, if the attack is not sufficiently strong */ attack = 0; @@ -1143,7 +1141,7 @@ static Word16 attack_det_fx( /* o : attack flag } test(); - if( sub(last_clas,VOICED_CLAS) == 0 && L_sub(L_add(L_shl(etmp,4),L_shl(etmp,2)),etmp2) > 0 ) + if( EQ_16(last_clas,VOICED_CLAS)&>_32(L_add(L_shl(etmp,4),L_shl(etmp,2)),etmp2)) { /* stop, if the signal was voiced and the attack is not sufficiently strong */ attack = 0; @@ -1157,7 +1155,7 @@ static Word16 attack_det_fx( /* o : attack flag etmp = Mult_32_16(etmp2, 16384); /* etmp2 / 2.0 = (etmp2*0.5) */ FOR( i=2; i 0 ) + IF( GT_32(finc[i],etmp)) { attack = 0; move16(); @@ -1174,7 +1172,7 @@ static Word16 attack_det_fx( /* o : attack flag { /*if( i != attack && finc[i] * 1.3f > etmp2 ) -> finc[i] > (etmp2*0.76923) */ test(); - IF( sub(i,attack) != 0 && L_sub(finc[i],etmp) > 0 ) + IF( NE_16(i,attack)&>_32(finc[i],etmp)) { attack = 0; move16(); @@ -1226,13 +1224,13 @@ static Word16 mode_decision_fx( logic16(); move16(); - IF ( sub(len,5) <= 0 ) + IF ( LE_16(len,5)) { return (mode); } ELSE { - IF ( sub(len,10) < 0 ) + IF ( LT_16(len,10)) { inv_len = div_s(1,len); /*Q15 */ @@ -1276,12 +1274,12 @@ static Word16 mode_decision_fx( test(); test(); test(); - IF ( (sub(M_pkh,2200) > 0 || L_sub(V_epsP_tilt,171799) < 0 || sub(M_cor_map_sum,25600) > 0) && voiced_cnt < 4 ) + IF ( (GT_16(M_pkh,2200)||LT_32(V_epsP_tilt,171799)||GT_16(M_cor_map_sum,25600))&&voiced_cnt<4) { mode = 1; move16(); } - ELSE IF ( sub(M_Ntonal,108) > 0 && voiced_cnt < 4 ) /*27 in Q2 */ + ELSE IF ( GT_16(M_Ntonal,108)&&voiced_cnt<4) /*27 in Q2 */ { mode = 1; move16(); @@ -1341,8 +1339,8 @@ static Word16 mode_decision_fx( test(); test(); test(); - IF ( (sub(M_flux10,4352) < 0 || (L_sub(V_epsP_tilt,2147484) < 0 && sub(M_flux10,6144) < 0)|| sub(M_pkh,2100) > 0 || sub(M_cor_map_sum,25600) > 0) && - sub(voiced_cnt,3) < 0 && sub(tmp,7680) < 0 ) + IF ( (LT_16(M_flux10,4352)||(LT_32(V_epsP_tilt,2147484)&<_16(M_flux10,6144))||GT_16(M_pkh,2100)||GT_16(M_cor_map_sum,25600))&& + LT_16(voiced_cnt,3) && LT_16(tmp,7680) ) { mode = 1; move16(); @@ -1356,7 +1354,7 @@ static Word16 mode_decision_fx( test(); test(); test(); - IF ( sub(M_flux10,8192) > 0 || (sub(M_flux10,7680) > 0 && voiced_cnt > 2) || sub(tmp,9728) > 0 || (sub(buf_flux[59],2560) >= 0 && sub(st->lps_fx,st->lpm_fx) > 0) ) + IF ( GT_16(M_flux10,8192)||(GT_16(M_flux10,7680)&&voiced_cnt>2)||GT_16(tmp,9728)||(GE_16(buf_flux[59],2560)&>_16(st->lps_fx,st->lpm_fx))) { mode = 0; move16(); @@ -1400,10 +1398,10 @@ static Word16 mode_decision_fx( test(); test(); test(); - IF ( ((sub(M_flux,add(6144,mult_r(1638,shl(sub(len,10),9)))) < 0 && sub(M_flux10,7680) < 0) || - L_sub(V_epsP_tilt,L_add(214748,L_shl(L_mult0(19327,(len-10)),1))) < 0 || - sub(M_pkh,sub(2100,extract_l(L_mult0(10,sub(len,10))))) > 0 || - sub(M_cor_map_sum,sub(24320,extract_l(L_mult0(77,sub(len,10))))) > 0) && sub(voiced_cnt,3) < 0 ) + IF ( ((LT_16(M_flux,add(6144,mult_r(1638,shl(sub(len,10),9))))&<_16(M_flux10,7680))|| + LT_32(V_epsP_tilt,L_add(214748,L_shl(L_mult0(19327,(len-10)),1))) || + GT_16(M_pkh,sub(2100,extract_l(L_mult0(10,sub(len,10))))) || + GT_16(M_cor_map_sum,sub(24320,extract_l(L_mult0(77,sub(len,10)))))) && LT_16(voiced_cnt,3)) { mode = 1; move16(); @@ -1411,7 +1409,7 @@ static Word16 mode_decision_fx( } } - IF ( sub(len,BUF_LEN) == 0 ) + IF ( EQ_16(len,BUF_LEN)) { tmp = 0; move16(); @@ -1441,12 +1439,12 @@ static Word16 mode_decision_fx( } test(); - IF ( sub(M_Ntonal,72) > 0 || sub(lf_Ntonal_ratio,6554) < 0 ) + IF ( GT_16(M_Ntonal,72)||LT_16(lf_Ntonal_ratio,6554)) { mode = 1; move16(); } - ELSE IF ( sub(M_Ntonal,4) < 0 ) + ELSE IF ( LT_16(M_Ntonal,4)) { mode = 0; move16(); @@ -1490,12 +1488,12 @@ static void tonal_dist_fx( move16(); FOR ( i=0; i<64; i++ ) { - if ( sub(p2v_map[i],7040) > 0 ) + if ( GT_16(p2v_map[i],7040)) { Ntonal = add(Ntonal,1); } - IF ( sub(p2v_map[i],10240) > 0 ) + IF ( GT_16(p2v_map[i],10240)) { Ntonal2 = add(Ntonal2,1); Ntonal_lf = add(Ntonal_lf,1); @@ -1508,11 +1506,11 @@ static void tonal_dist_fx( { pk = L_add(pk,p2v_map[i]); /*Q7 */ } - if ( sub(p2v_map[i],7040) > 0 ) + if ( GT_16(p2v_map[i],7040)) { Ntonal = add(Ntonal,1); } - if ( sub(p2v_map[i],10240) > 0 ) + if ( GT_16(p2v_map[i],10240)) { Ntonal2 = add(Ntonal2,1); } @@ -1589,7 +1587,7 @@ static void flux_fx( } test(); - if ( sub(flux,2560) > 0 && sub(dec_mov,26214) > 0 ) + if ( GT_16(flux,2560)&>_16(dec_mov,26214)) { flux = 2560; move16(); /*20 in Q7 */ @@ -1651,7 +1649,7 @@ static void spec_analysis_fx( FOR ( i=1; i 0 && sub(Bin_E[i],Bin_E[i+1]) > 0 ) + IF ( GT_16(Bin_E[i],Bin_E[i-1])&>_16(Bin_E[i],Bin_E[i+1])) { peak[k] = Bin_E[i]; move16(); @@ -1680,7 +1678,7 @@ static void spec_analysis_fx( m = 0; move16(); - IF ( sub(Bin_E[0],Bin_E[1]) < 0 ) + IF ( LT_16(Bin_E[0],Bin_E[1])) { valley[0] = Bin_E[0]; move16(); @@ -1693,7 +1691,7 @@ static void spec_analysis_fx( move16(); FOR ( i=125; i>=0; i-- ) { - IF (sub(Bin_E[i+1],Bin_E[i]) <= 0) + IF (LE_16(Bin_E[i+1],Bin_E[i])) { BREAK; } @@ -1704,7 +1702,7 @@ static void spec_analysis_fx( FOR ( i=1; i 0 && sub(peak_idx[k],valey_idx[i+1]) < 0 ) + IF ( GT_16(peak_idx[k],valey_idx[i])&<_16(peak_idx[k],valey_idx[i+1])) { p2v[k] = sub(shl(peak[k],1),add(valley[i],valley[i+1])); k = add(k,1); @@ -1772,7 +1770,7 @@ static void music_mixed_classif_improv_fx( /* music is considered only appearing in high SNR condition and active signal */ test(); - IF ( vad_flag == 0 || sub(sub(st->lp_speech_fx,st->lp_noise_fx),6400) < 0 ) /* 25 in Q8 */ + IF ( vad_flag == 0 || LT_16(sub(st->lp_speech_fx,st->lp_noise_fx),6400)) /* 25 in Q8 */ { /* st->dec_mov = 0.5f; */ /* st->dec_mov1 = 0.5f; */ @@ -1793,7 +1791,7 @@ static void music_mixed_classif_improv_fx( st->onset_cnt_fx = add(st->onset_cnt_fx,1); st->onset_cnt_fx = s_min(st->onset_cnt_fx, 9); - IF ( sub(st->onset_cnt_fx,1) == 0 ) + IF ( EQ_16(st->onset_cnt_fx,1)) { set16_fx( st->buf_flux_fx, -12800, BUF_LEN ); /*-100.0 in Q7 */ } @@ -1828,20 +1826,20 @@ static void music_mixed_classif_improv_fx( move16(); test(); test(); - IF ( sub(sub(st->buf_etot_fx[1],st->buf_etot_fx[0]),1536) > 0 && - sub(st->buf_etot_fx[2],st->buf_etot_fx[1]) < 0 && - sub(sub(st->buf_etot_fx[1],st->lp_speech_fx),768) > 0 ) /* 3 in Q8 */ + IF ( GT_16(sub(st->buf_etot_fx[1],st->buf_etot_fx[0]),1536)&& + LT_16(st->buf_etot_fx[2],st->buf_etot_fx[1]) && + GT_16(sub(st->buf_etot_fx[1],st->lp_speech_fx),768) ) /* 3 in Q8 */ { /*tmp = add(shr(voicing[0],2),shr(voicing[1],2)); //Q15 */ /*tmp = add(tmp,shr(old_cor,1)); //Q15 */ tmp = mac_r(L_mac(L_mult(voicing[0],8192),voicing[1],8192),old_cor, 16384); test(); test(); - IF ( sub(sub(st->buf_etot_fx[1],st->buf_etot_fx[3]),768) > 0 && - sub(st->buf_etot_fx[3],st->buf_etot_fx[2]) < 0 && - sub(tmp,24576) < 0 ) /* 0.75 in Q15 */ + IF ( GT_16(sub(st->buf_etot_fx[1],st->buf_etot_fx[3]),768)&& + LT_16(st->buf_etot_fx[3],st->buf_etot_fx[2]) && + LT_16(tmp,24576)) /* 0.75 in Q15 */ { - IF ( sub(st->dec_mov_fx,26214) > 0 ) /* 0.8 in Q15 */ + IF ( GT_16(st->dec_mov_fx,26214)) /* 0.8 in Q15 */ { percus_flag = 1; move16(); @@ -1851,7 +1849,7 @@ static void music_mixed_classif_improv_fx( test(); test(); test(); - IF ( sub(old_cor,24576) < 0 && sub(voicing[0],24576) < 0 && sub(voicing[1],24576) < 0 && sub(st->old_lt_diff_fx[0],1280) > 0 ) + IF ( LT_16(old_cor,24576)&<_16(voicing[0],24576)&<_16(voicing[1],24576)&>_16(st->old_lt_diff_fx[0],1280)) { percus_flag = 1; move16(); @@ -1864,19 +1862,19 @@ static void music_mixed_classif_improv_fx( test(); test(); test(); - IF ( sub(sub(st->buf_etot_fx[3],st->buf_etot_fx[2]),1536) > 0 - && sub(st->dec_mov_fx,29491) > 0 - && sub(sub(etot,st->lp_speech_fx),1280) > 0 - && sub(st->old_lt_diff_fx[0],640) > 0 ) + IF ( GT_16(sub(st->buf_etot_fx[3],st->buf_etot_fx[2]),1536) + && GT_16(st->dec_mov_fx,29491) + && GT_16(sub(etot,st->lp_speech_fx),1280) + && GT_16(st->old_lt_diff_fx[0],640)) { st->attack_hangover_fx = 3; move16(); } test(); - IF ( sub(voicing[0],29491) > 0 && sub(voicing[1],29491) > 0 ) + IF ( GT_16(voicing[0],29491)&>_16(voicing[1],29491)) { - IF ( sub(log_max_spl,st->mov_log_max_spl_fx) > 0 ) + IF ( GT_16(log_max_spl,st->mov_log_max_spl_fx)) { /**mov_log_max_spl = add(mult_r(31130,(*mov_log_max_spl)),mult_r(1638,log_max_spl)); //Q7 */ st->mov_log_max_spl_fx = round_fx(L_mac(L_mult(31130,st->mov_log_max_spl_fx),1638,log_max_spl)); /*Q7 */ @@ -1913,7 +1911,7 @@ static void music_mixed_classif_improv_fx( } /* reset flux buffer if percussive music is detected */ - IF ( sub(percus_flag,1) == 0 ) + IF ( EQ_16(percus_flag,1)) { set16_fx( &st->buf_flux_fx[BUF_LEN-len], 640, len ); /* 5 in Q7 */ } @@ -1930,7 +1928,7 @@ static void music_mixed_classif_improv_fx( FOR ( i=1; i<16; i++ ) { - IF(L_sub(epsP[i], epsP_max) == 0) + IF(EQ_32(epsP[i], epsP_max)) { tmp = -32768; move16(); @@ -1961,14 +1959,14 @@ static void music_mixed_classif_improv_fx( FOR ( i=1; i<16; i++ ) { - IF(L_sub(epsP[i], epsP_max) == 0) + IF(EQ_32(epsP[i], epsP_max)) { tmp = -32768; move16(); L_tmp = Mult_32_16(epsP[i+1],tmp); /*Q_epsP */ ftmp1 = L_sub(ftmp1,L_shr(L_tmp,4)); /*Q(Q_epsP-4) */ } - ELSE IF(L_sub(epsP[i+1],epsP_max) == 0) + ELSE IF(EQ_32(epsP[i+1],epsP_max)) { tmp = -32768; move16(); @@ -2050,7 +2048,7 @@ static void music_mixed_classif_improv_fx( move16(); /* update long term moving average of the classification decisions */ - IF ( sub(len,30) > 0 ) + IF ( GT_16(len,30)) { IF( dec == 0 ) { @@ -2068,8 +2066,8 @@ static void music_mixed_classif_improv_fx( test(); test(); test(); - IF ( (sub(st->coder_type_raw_fx,UNVOICED) == 0 || sub(st->coder_type_raw_fx,INACTIVE) == 0) && - sub(etot,384) > 0 && sub(st->buf_Ntonal2_fx[59],2) < 0 ) + IF ( (EQ_16(st->coder_type_raw_fx,UNVOICED)||EQ_16(st->coder_type_raw_fx,INACTIVE))&& + GT_16(etot,384) && LT_16(st->buf_Ntonal2_fx[59],2) ) { st->UV_cnt1_fx = sub(st->UV_cnt1_fx,8); } @@ -2087,14 +2085,14 @@ static void music_mixed_classif_improv_fx( /* revert classification decision due to long-term unvoiced counter */ test(); test(); - IF ( sub(dec,1) == 0 && sub(st->dec_mov1_fx,6554) < 0 && sub(st->LT_UV_cnt1_fx,12800) < 0 ) + IF ( EQ_16(dec,1)&<_16(st->dec_mov1_fx,6554)&<_16(st->LT_UV_cnt1_fx,12800)) { dec = 0; move16(); } /* overwrite 1st stage speech/music decision to music */ - IF (sub(dec,1) == 0 ) + IF (EQ_16(dec,1)) { *sp_aud_decision1 = 1; move16(); @@ -2130,7 +2128,7 @@ static void tonal_context_improv_fx( Word16 voi_mean, lt_pitch_diff; Word32 L_tmp, tonality, tonality1, tonality2, tonality3, sort_max, sort_avg, sort_val[80]; - IF ( sub(st_fx->last_codec_mode, MODE2) == 0) + IF ( EQ_16(st_fx->last_codec_mode, MODE2)) { set16_fx(st_fx->tonality2_buf_fx,0,HANG_LEN_INIT); set16_fx(st_fx->tonality3_buf_fx,0,HANG_LEN_INIT); @@ -2247,7 +2245,7 @@ static void tonal_context_improv_fx( voi_mean = mac_r(L_tmp, voicing[2], 10923); /* Q15 */ test(); - IF( sub(st_fx->hangover_cnt_fx,10) == 0&& sub(vad_flag,1) == 0 ) + IF( EQ_16(st_fx->hangover_cnt_fx,10)&&EQ_16(vad_flag,1)) { /* long-term voicing parameter */ st_fx->lt_voicing = round_fx(L_mac(L_mult(3277,st_fx->lt_voicing),29491, voi_mean)); @@ -2301,15 +2299,15 @@ static void tonal_context_improv_fx( test(); test(); IF ( *sp_aud_decision1 == 1 && - ( L_sub(L_min(L_min(tonality1, tonality2), tonality3),1638400) > 0 ) && - ( L_sub(L_add(tonality1, tonality2),6553600) > 0 && L_sub(L_add(tonality2, tonality3),6553600) > 0 && L_sub(L_add(tonality1, tonality3),6553600) > 0 ) && - ( L_sub(st_fx->lt_tonality,655360000) < 0 ) && - ( ( L_sub(st_fx->lt_tonality,32768000) > 0 && sub(s_max(st_fx->lt_voicing, voi_mean),32440) > 0 ) || - ( L_sub(st_fx->lt_tonality,49152000) > 0 && sub(st_fx->lt_corr,32440) > 0 ) || - ( L_sub(st_fx->lt_tonality,98304000) > 0 && sub(st_fx->lowrate_pitchGain,15729) > 0 ) || - ( lt_pitch_diff == 0 && sub(st_fx->lowrate_pitchGain,14582) > 0 ) ) ) + ( GT_32(L_min(L_min(tonality1, tonality2), tonality3),1638400) ) && + ( GT_32(L_add(tonality1, tonality2),6553600) && GT_32(L_add(tonality2, tonality3),6553600) && GT_32(L_add(tonality1, tonality3),6553600)) && + ( LT_32(st_fx->lt_tonality,655360000) ) && + ( ( GT_32(st_fx->lt_tonality,32768000) && GT_16(s_max(st_fx->lt_voicing, voi_mean),32440) ) || + ( GT_32(st_fx->lt_tonality,49152000) && GT_16(st_fx->lt_corr,32440) ) || + ( GT_32(st_fx->lt_tonality,98304000) && GT_16(st_fx->lowrate_pitchGain,15729) ) || + ( lt_pitch_diff == 0 && GT_16(st_fx->lowrate_pitchGain,14582)))) { - IF( sub(sum16_fx(st_fx->lt_old_mode, 2),2) < 0 ) + IF( LT_16(sum16_fx(st_fx->lt_old_mode, 2),2)) { /* probably speech - change the decision to speech */ *sp_aud_decision1 = 0; @@ -2388,16 +2386,16 @@ static void tonal_context_improv_fx( test(); test(); test(); - IF ( (sub(*sp_aud_decision1, 1) == 0) && st_fx->lt_music_state_fx == 0 && st_fx->lt_music_hangover_fx == 0 && - (sub(t2_fx, 8847) < 0) && (sub(t2_fx, 4260) > 0) && (sub(t3_fx, 3604) > 0) && (sub(tL_fx, 8847) < 0) && (sub(tL_fx, 4260) > 0) && (sub(err_fx, 8192) > 0) ) + IF ( (EQ_16(*sp_aud_decision1, 1))&&st_fx->lt_music_state_fx==0&&st_fx->lt_music_hangover_fx==0&& + (LT_16(t2_fx, 8847)) && (GT_16(t2_fx, 4260)) && (GT_16(t3_fx, 3604)) && (LT_16(tL_fx, 8847)) && (GT_16(tL_fx, 4260)) && (GT_16(err_fx, 8192)) ) { st_fx->lt_music_state_fx = 1; move16(); st_fx->lt_music_hangover_fx = 6; move16(); } - ELSE IF( sub(st_fx->lt_music_state_fx, 1) == 0 && st_fx->lt_music_hangover_fx == 0 && - (sub(t2_fx, 5571) < 0) && (sub(t3_fx, 4260) < 0) && (sub(tL_fx, 7373) < 0) ) + ELSE IF( EQ_16(st_fx->lt_music_state_fx, 1)&&st_fx->lt_music_hangover_fx==0&& + (LT_16(t2_fx, 5571) ) && (LT_16(t3_fx, 4260) ) && (LT_16(tL_fx, 7373) ) ) { st_fx->lt_music_state_fx = 0; move16(); @@ -2424,17 +2422,17 @@ static void tonal_context_improv_fx( test(); test(); test(); - IF ( (sub(*sp_aud_decision1, 1) == 0) && st_fx->lt_speech_state_fx == 0 && st_fx->lt_speech_hangover_fx == 0 && - (sub(cor_fx, 13107) > 0) && (sub(dft_fx, 1638) < 0) && sub(shr(voi_fv,1), add(cor_map_sum_fv, 1966)) > 0 && - (sub(t2_fx, shr(cor_fx, 1)) < 0) && (sub(t3_fx, shr(cor_fx, 1)) < 0) && (sub(tL_fx, shr(cor_fx, 1)) < 0) && - (sub(cor_map_sum_fv, cor_fx) < 0) && (sub(voi_fv, cor_fx) > 0) && (sub(voi_fv, 24903) > 0) ) + IF ( (EQ_16(*sp_aud_decision1, 1))&&st_fx->lt_speech_state_fx==0&&st_fx->lt_speech_hangover_fx==0&& + (GT_16(cor_fx, 13107)) && (LT_16(dft_fx, 1638)) && GT_16(shr(voi_fv,1), add(cor_map_sum_fv, 1966)) && + (LT_16(t2_fx, shr(cor_fx, 1))) && (LT_16(t3_fx, shr(cor_fx, 1))) && (LT_16(tL_fx, shr(cor_fx, 1))) && + (LT_16(cor_map_sum_fv, cor_fx)) && (GT_16(voi_fv, cor_fx)) && (GT_16(voi_fv, 24903) ) ) { st_fx->lt_speech_state_fx = 1; move16(); st_fx->lt_speech_hangover_fx = 6; move16(); } - ELSE IF ( (sub(st_fx->lt_speech_state_fx, 1) == 0) && st_fx->lt_speech_hangover_fx == 0 && (sub(cor_fx, 13107) < 0) ) + ELSE IF ( (EQ_16(st_fx->lt_speech_state_fx, 1))&&st_fx->lt_speech_hangover_fx==0&&(LT_16(cor_fx,13107))) { st_fx->lt_speech_state_fx = 0; move16(); @@ -2450,7 +2448,7 @@ static void tonal_context_improv_fx( /* final decision */ test(); test(); - IF ( sub(*sp_aud_decision1,1) == 0 && sub(st_fx->lt_speech_state_fx,1) == 0 ) + IF ( EQ_16(*sp_aud_decision1,1)&&EQ_16(st_fx->lt_speech_state_fx,1)) { /* strong speech - probably error in speech/music classification */ *sp_aud_decision1 = 0; @@ -2458,7 +2456,7 @@ static void tonal_context_improv_fx( *sp_aud_decision2 = 0; move16(); } - ELSE IF ( *sp_aud_decision1 == 0 && sub(st_fx->lt_speech_state_fx,1) == 0 ) + ELSE IF ( *sp_aud_decision1 == 0 && EQ_16(st_fx->lt_speech_state_fx,1)) { /* strong music - probably error in speech/music classification */ *sp_aud_decision1 = 0; @@ -2533,7 +2531,7 @@ static void detect_sparseness_fx( FOR (i = 0; i < 128; i++) { L_tmp = L_add(L_tmp, L_deposit_l(S1[i])); - IF (L_sub(L_shr(L_tmp, 7), L_tmp1) > 0) + IF (GT_32(L_shr(L_tmp, 7), L_tmp1)) { j = i; move16(); @@ -2552,7 +2550,7 @@ static void detect_sparseness_fx( st_fx->sparse_buf_fx[i] = sparse; move16(); - IF (sub(st_fx->bwidth_fx, WB) == 0) + IF (EQ_16(st_fx->bwidth_fx, WB)) { Msp = 0; move16(); @@ -2577,7 +2575,7 @@ static void detect_sparseness_fx( { FOR (j = 0; j < 4; j++) { - IF (sub(st_fx->sparse_buf_fx[i], tmp_buf[j]) > 0) + IF (GT_16(st_fx->sparse_buf_fx[i], tmp_buf[j])) { Copy(&tmp_buf[j], &tmp_buf[j+1], sub(3, j)); tmp_buf[j] = st_fx->sparse_buf_fx[i]; @@ -2636,7 +2634,7 @@ static void detect_sparseness_fx( { tmp = add(tmp, shr(st_fx->hf_spar_buf_fx[i], 3)); } - IF (sub(tmp, 6554) > 0) + IF (GT_16(tmp, 6554)) { hb_sp_high_flag = 1; move16(); @@ -2675,7 +2673,7 @@ static void detect_sparseness_fx( IF (tmp != 0) { tmp = div_s(tmp, add(tmp, extract_l(L_shr(L_tmp1, 7)))); - if (sub(tmp, 5898) > 0) + if (GT_16(tmp, 5898)) { lb_sp_high_flag = 1; move16(); @@ -2716,16 +2714,16 @@ static void detect_sparseness_fx( } /* avoid using LR-MDCT on sparse spectra */ - IF (sub(*sp_aud_decision1, 1) == 0) + IF (EQ_16(*sp_aud_decision1, 1)) { tmp = 91; move16(); - if (sub(st_fx->bwidth_fx, WB) == 0) + if (EQ_16(st_fx->bwidth_fx, WB)) { tmp = 90; } - IF (sub(sparse, tmp) > 0) + IF (GT_16(sparse, tmp)) { *sp_aud_decision1 = 0; move16(); @@ -2734,9 +2732,9 @@ static void detect_sparseness_fx( st_fx->gsc_hangover_fx = 1; move16(); } - ELSE IF (sub(st_fx->gsc_hangover_fx, 1) == 0) + ELSE IF (EQ_16(st_fx->gsc_hangover_fx, 1)) { - IF (sub(sparse, 85) > 0) + IF (GT_16(sparse, 85)) { *sp_aud_decision1 = 0; move16(); @@ -2754,7 +2752,7 @@ static void detect_sparseness_fx( tmp1 = div_s(1, st_fx->gsc_cnt_fx); tmp = mult(tmp, tmp1); - IF (sub(abs_s(sub(sparse, tmp)), 7) < 0) + IF (LT_16(abs_s(sub(sparse, tmp)), 7)) { *sp_aud_decision1 = 0; move16(); @@ -2764,7 +2762,7 @@ static void detect_sparseness_fx( } } - IF (sub(st_fx->bwidth_fx, WB) == 0) + IF (EQ_16(st_fx->bwidth_fx, WB)) { test(); test(); @@ -2775,8 +2773,8 @@ static void detect_sparseness_fx( test(); test(); test(); - IF (sub(st_fx->LT_sparse_fx, 15360) > 0 && sub(sparse, 50) > 0 && sub(Mlpe, -1331) < 0 && sub(Mv, 27853) > 0 && - lb_sp_high_flag == 0 && ((hb_sp_high_flag == 0 && sub(sumh, mult_r(4915, sum)) > 0) || sub(sumh, mult_r(4915, sum)) <= 0)) + IF (GT_16(st_fx->LT_sparse_fx, 15360)&>_16(sparse,50)&<_16(Mlpe,-1331)&>_16(Mv,27853)&& + lb_sp_high_flag == 0 && ((hb_sp_high_flag == 0 && GT_16(sumh, mult_r(4915, sum))) || LE_16(sumh, mult_r(4915, sum)))) { *sp_aud_decision1 = 0; move16(); @@ -2785,9 +2783,9 @@ static void detect_sparseness_fx( st_fx->gsc_hangover_fx = 1; move16(); } - ELSE IF (sub(st_fx->gsc_hangover_fx, 1) == 0 && !( *sp_aud_decision1 == 0 && *sp_aud_decision2 == 1)) + ELSE IF (EQ_16(st_fx->gsc_hangover_fx, 1)&&!(*sp_aud_decision1==0&&*sp_aud_decision2==1)) { - IF (sub(abs_s(sub(sparse, mean_fx(&st_fx->sparse_buf_fx[HANG_LEN_INIT-1-st_fx->gsc_cnt_fx], st_fx->gsc_cnt_fx))), 7) < 0) + IF (LT_16(abs_s(sub(sparse, mean_fx(&st_fx->sparse_buf_fx[HANG_LEN_INIT-1-st_fx->gsc_cnt_fx], st_fx->gsc_cnt_fx))), 7)) { *sp_aud_decision1 = 0; move16(); @@ -2800,10 +2798,10 @@ static void detect_sparseness_fx( /* update the counter of consecutive GSC frames with sparse spectrum */ test(); - IF (*sp_aud_decision1 == 0 && sub(*sp_aud_decision2, 1) == 0) + IF (*sp_aud_decision1 == 0 && EQ_16(*sp_aud_decision2, 1)) { st_fx->gsc_cnt_fx = add(st_fx->gsc_cnt_fx, 1); - IF (sub(st_fx->gsc_cnt_fx, 7) > 0) + IF (GT_16(st_fx->gsc_cnt_fx, 7)) { st_fx->gsc_cnt_fx = 7; move16(); @@ -2847,7 +2845,7 @@ static void order_spectrum_fx( end = sub(len, i); FOR(j = i; j < end; j++) { - IF(sub(vec[j], smax) > 0) + IF(GT_16(vec[j], smax)) { smax = vec[j]; move16(); @@ -2856,7 +2854,7 @@ static void order_spectrum_fx( } ELSE { - IF(sub(vec[j], smin) < 0) + IF(LT_16(vec[j], smin) ) { smin = vec[j]; move16(); @@ -2873,7 +2871,7 @@ static void order_spectrum_fx( vec[imax] = tmp; move16(); - IF(sub(imin, i) == 0) + IF(EQ_16(imin, i)) { imin = imax; move16(); diff --git a/lib_enc/stat_enc_fx.h b/lib_enc/stat_enc_fx.h index 26838c1d3bfe3a87fa0dcf81a5ce046b16ea02e1..0f2e28f8304309949ff8c3046a79b18ccb6723cc 100644 --- a/lib_enc/stat_enc_fx.h +++ b/lib_enc/stat_enc_fx.h @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #ifndef STAT_ENC_FX_H diff --git a/lib_enc/stat_noise_uv_enc_fx.c b/lib_enc/stat_noise_uv_enc_fx.c index 980b17cc582119576a9613280156efc634d43728..3ca194da18f4019c5226b8f3aa8a73f07cd51ea7 100644 --- a/lib_enc/stat_noise_uv_enc_fx.c +++ b/lib_enc/stat_noise_uv_enc_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "prot_fx.h" /* Function prototypes */ #include "rom_com_fx.h" /* Static table prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*======================================================================*/ /* FUNCTION : stat_noise_uv_enc_fx */ @@ -50,7 +48,7 @@ void stat_noise_uv_enc_fx( test(); test(); - IF ( sub(coder_type,UNVOICED) == 0 || ( sub(coder_type,INACTIVE) == 0 && L_sub(st_fx->core_brate_fx,ACELP_9k60) <= 0 ) ) + IF ( EQ_16(coder_type,UNVOICED)||(EQ_16(coder_type,INACTIVE)&&LE_32(st_fx->core_brate_fx,ACELP_9k60))) { /*-----------------------------------------------------------------* @@ -67,13 +65,13 @@ void stat_noise_uv_enc_fx( num = sub(num,1024);/*num - 1*/ test(); - IF ( sub(st_fx->bwidth_fx,NB) != 0 ) + IF ( NE_16(st_fx->bwidth_fx,NB)) { /* WB case */ /* noisiness = (Word16)(((epsP[2] / epsP[16]) - 1)*2 * 32);*/ noisiness = shr(num,4);/*Q10 x64 -> Q0 */ } - ELSE IF ( sub(coder_type,INACTIVE) == 0 && sub(st_fx->bwidth_fx,NB) == 0) + ELSE IF ( EQ_16(coder_type,INACTIVE)&&EQ_16(st_fx->bwidth_fx,NB)) { /* NB GSC case */ /* noisiness = (Word16)(((epsP[2] / epsP[16]) - 1)*.25f * 32);*/ diff --git a/lib_enc/subband_fft.c b/lib_enc/subband_fft.c index d3c310365cb2facc3aec617a7680564ca47d371f..c13836054dc17f91104e4e65c2bb9d7651f125a0 100644 --- a/lib_enc/subband_fft.c +++ b/lib_enc/subband_fft.c @@ -1,12 +1,10 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "basop_util.h" #include "stl.h" -#include "wmc_auto.h" - #include "vad_basop.h" #include "prot_fx.h" #include "rom_enc_fx.h" @@ -36,7 +34,8 @@ Word16 ffr_getSfWord32(Word32 *vector, /*!< Pointer to input vector */ Word16 resu; - maxVal = L_add(0,0); + maxVal = 0; + move32(); FOR(i=0; i @@ -9,8 +9,6 @@ #include "cnst_fx.h" #include "rom_com_fx.h" #include "stl.h" -#include "wmc_auto.h" - /*---------------------------------------------------------------------* * Local functions @@ -77,13 +75,13 @@ static void delay_input_signal_fx( max2_exp = norm_s(max); } - IF(sub(add(max1_exp, *Q_old), add(max2_exp, *Q_new)) > 0) + IF(GT_16(add(max1_exp, *Q_old), add(max2_exp, *Q_new))) { Copy_Scale_sig(new_sig, new_sig, m2, max2_exp); Copy_Scale_sig(old_sig, old_sig, m1, sub(add(max2_exp, *Q_new), *Q_old)); *Q_new = add(max2_exp, *Q_new); } - ELSE IF(sub(add(max1_exp, *Q_old), add(max2_exp, *Q_new)) < 0) + ELSE IF(LT_16(add(max1_exp, *Q_old), add(max2_exp, *Q_new))) { Copy_Scale_sig(new_sig, new_sig, m2, sub(add(max1_exp, *Q_old), *Q_new)); Copy_Scale_sig(old_sig, old_sig, m1, max1_exp); @@ -126,7 +124,7 @@ void wb_bwe_enc_fx( Word16 Q_synth; Word16 WB_fenv_fx[SWB_FENV]; - IF( L_sub(st_fx->total_brate_fx, ACELP_13k20) == 0 ) + IF( EQ_32(st_fx->total_brate_fx, ACELP_13k20)) { /*---------------------------------------------------------------------* * Delay the original input signal to be synchronized with ACELP core synthesis @@ -228,7 +226,7 @@ void swb_bwe_enc_fx( /*---------------------------------------------------------------------* * Delay the original input signal to be synchronized with ACELP core synthesis *---------------------------------------------------------------------*/ - IF( sub(st_fx->extl_fx, FB_BWE) == 0 ) + IF( EQ_16(st_fx->extl_fx, FB_BWE)) { inner_frame = L_FRAME48k; inner_Fs = 48000; @@ -241,7 +239,7 @@ void swb_bwe_enc_fx( set16_fx( old_input_fx, 0, add(NS2SA(inner_Fs, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS), inner_frame) ); - IF( sub(st_fx->L_frame_fx, L_FRAME) == 0 ) + IF( EQ_16(st_fx->L_frame_fx, L_FRAME)) { Sample_Delay_SWB_BWE = NS2SA(inner_Fs, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS); Sample_Delay_HP = NS2SA(16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS); @@ -302,7 +300,7 @@ void swb_bwe_enc_fx( move16(); Q_synth_hf = 0; move16(); - IF (sub(st_fx->L_frame_fx, L_FRAME16k) == 0) + IF (EQ_16(st_fx->L_frame_fx, L_FRAME16k)) { scl = 300; move16(); @@ -329,7 +327,7 @@ void swb_bwe_enc_fx( Copy_Scale_sig(&yorig_fx[scl], &yorig_fx[scl], sub(inner_frame, scl), exp); Q_synth_hf = add(exp, Q_synth); - IF(sub(st_fx->last_extl_fx, SWB_BWE) == 0 || sub(st_fx->last_extl_fx, FB_BWE) == 0) + IF(EQ_16(st_fx->last_extl_fx, SWB_BWE)||EQ_16(st_fx->last_extl_fx,FB_BWE)) { exp = norm_l(st_fx->EnergyLT_fx); IF(add(st_fx->EnergyLT_fx_exp, exp) > shl(sub(Q_synth_hf, 4), 1)) @@ -353,7 +351,7 @@ void swb_bwe_enc_fx( } Copy_Scale_sig(new_input_hp_fx, new_input_hp_fx, L_FRAME16k, sub(Q_shb, Q_shb_speech)); /* SWB BWE encoding */ - IF (sub(st_fx->L_frame_fx, L_FRAME16k) == 0) + IF (EQ_16(st_fx->L_frame_fx, L_FRAME16k)) { SWB_BWE_encoding_fx( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_fx, SWB_fenv_fx, tilt_nb_fx, 80, coder_type, Q_slb_speech, Q_shb, Q_synth_hf, Q_synth ); @@ -366,7 +364,7 @@ void swb_bwe_enc_fx( } /* FB BWE encoding */ - IF ( sub(st_fx->extl_fx, FB_BWE) == 0 ) + IF ( EQ_16(st_fx->extl_fx, FB_BWE)) { energy_fbe_fb_fx = L_deposit_l(0); FOR( i=FB_BAND_BEGIN; iextl_fx, FB_BWE) == 0 ) + IF( EQ_16(st_fx->extl_fx, FB_BWE)) { push_indice_fx(st_fx, IND_FB_SLOPE, idxGain, NUM_BITS_FB_FRAMEGAIN ); } @@ -459,7 +457,7 @@ static Word16 WB_BWE_fenv_q_fx( /* o: quantized gain index */ pit++; } - IF( L_sub(dist,min_dist) < 0) + IF( LT_32(dist,min_dist)) { min_dist = L_add(dist, 0); indx = i; @@ -498,9 +496,9 @@ static void get_normalize_spec_fx( set16_fx(SWB_signal, 0, add(HQ_GENERIC_HIGH0,offset) ); calc_normal_length_fx(core, org_fx, mode, extl, &L_swb_norm, prev_L_swb_norm, Q_new_lf); test(); - IF( sub(extl,SWB_BWE) == 0 || sub(extl,FB_BWE) == 0 ) + IF( EQ_16(extl,SWB_BWE)||EQ_16(extl,FB_BWE)) { - IF( sub(mode,HARMONIC) == 0 ) + IF( EQ_16(mode,HARMONIC)) { Copy( org_fx, &SWB_signal[add(240,offset)], 240 ); Copy( &org_fx[128], &SWB_signal[add(480,offset)], 80 ); @@ -513,7 +511,7 @@ static void get_normalize_spec_fx( } frq_end = add(560,offset); } - ELSE IF (sub(extl,WB_BWE) == 0) + ELSE IF (EQ_16(extl,WB_BWE)) { IF( core_type == 0 ) { @@ -530,7 +528,7 @@ static void get_normalize_spec_fx( { Copy( org_fx+HQ_GENERIC_OFFSET, SWB_signal+add(HQ_GENERIC_HIGH0,offset), HQ_GENERIC_LEN0 ); Copy( org_fx+HQ_GENERIC_OFFSET, SWB_signal+add(HQ_GENERIC_HIGH1,offset), HQ_GENERIC_LEN0 ); - IF ( sub(offset,HQ_GENERIC_FOFFSET_24K4 ) == 0) + IF ( EQ_16(offset,HQ_GENERIC_FOFFSET_24K4 )) { Copy( org_fx+HQ_GENERIC_LOW0, SWB_signal+add(HQ_GENERIC_HIGH2,offset), sub(HQ_GENERIC_END_FREQ,HQ_GENERIC_HIGH2) ); } @@ -607,7 +605,7 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class */ L_mean_d = 0L; /* to avoid compilation warnings */ test(); - IF ( sub(st_fx->extl_fx, SWB_BWE) == 0 || sub(st_fx->extl_fx, FB_BWE) == 0 ) + IF ( EQ_16(st_fx->extl_fx, SWB_BWE)||EQ_16(st_fx->extl_fx,FB_BWE)) { input_hi = &fSpectrum[256]; move16(); @@ -617,7 +615,7 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class */ test(); test(); test(); - IF ( ( sub(st_fx->last_extl_fx, SWB_BWE) == 0 && sub(st_fx->extl_fx, SWB_BWE) == 0 ) || ( sub(st_fx->last_extl_fx, FB_BWE) == 0 && sub(st_fx->extl_fx, FB_BWE) == 0 ) ) + IF ( ( EQ_16(st_fx->last_extl_fx, SWB_BWE)&&EQ_16(st_fx->extl_fx,SWB_BWE))||(EQ_16(st_fx->last_extl_fx,FB_BWE)&&EQ_16(st_fx->extl_fx,FB_BWE))) { IF(st_fx->prev_global_gain_fx == 0) { @@ -642,11 +640,11 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class */ gain_tmp = shl(tmp, sub(expn,1));/*Q14 */ } test(); - IF (sub(st_fx->prev_mode_fx,TRANSIENT) == 0) + IF (EQ_16(st_fx->prev_mode_fx,TRANSIENT)) { numharmonic = shl(numharmonic, 1); } - ELSE IF (sub(st_fx->prev_mode_fx, NORMAL) == 0 || sub(st_fx->prev_mode_fx, NOISE) == 0) + ELSE IF (EQ_16(st_fx->prev_mode_fx, NORMAL)||EQ_16(st_fx->prev_mode_fx,NOISE)) { numharmonic = add(shr(numharmonic, 1), numharmonic); } @@ -655,7 +653,7 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class */ { gain_tmp = 16384; move16(); - IF (sub(st_fx->prev_mode_fx, HARMONIC) == 0) + IF (EQ_16(st_fx->prev_mode_fx, HARMONIC)) { numharmonic = shr(numharmonic, 1); sharplimit = shr(sharplimit, 1); @@ -667,14 +665,14 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class */ } } } - ELSE IF (sub(st_fx->extl_fx, WB_BWE) == 0) + ELSE IF (EQ_16(st_fx->extl_fx, WB_BWE)) { input_hi = &fSpectrum[224]; move16(); numsharp = 3; move16(); - IF (sub(st_fx->prev_mode_fx, HARMONIC) == 0) + IF (EQ_16(st_fx->prev_mode_fx, HARMONIC)) { numharmonic = shr(numharmonic, 2); } @@ -682,9 +680,9 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class */ { numharmonic = shr(numharmonic, 1); } - IF (sub(st_fx->last_extl_fx, WB_BWE) != 0) + IF (NE_16(st_fx->last_extl_fx, WB_BWE)) { - IF (sub(st_fx->prev_mode_fx, HARMONIC) == 0) + IF (EQ_16(st_fx->prev_mode_fx, HARMONIC)) { sharplimit = shr(sharplimit, 1); } @@ -705,7 +703,7 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class */ FOR(j = 0; j < SHARP_WIDTH; j ++) { mag = abs_s(*input_hi); - IF (sub(mag, peak) > 0) + IF (GT_16(mag, peak)) { peak = mag; move16();/*Q_syn */ @@ -717,7 +715,7 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class */ L_meanH = L_add(L_meanH, mean[i]);/*Q_syn */ - IF(L_sub(mean[i], L_deposit_l(peak)) != 0) + IF(NE_32(mean[i], L_deposit_l(peak))) { L_tmp = L_sub(mean[i], peak);/*Q_syn */ L_tmp = Mult_32_16(L_tmp, 16913); /* 1/31->Q19 -> Q_syn+19-15 */ @@ -739,30 +737,30 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class */ } test(); - IF (sub(sharp, 4608) > 0 && sub(peak, shl(1, add(Q_syn, 3))) > 0) + IF (GT_16(sharp, 4608)&>_16(peak,shl(1,add(Q_syn,3)))) { k = add(k, 1); move16(); } - ELSE IF (sub(sharp, 3072) < 0) + ELSE IF (LT_16(sharp, 3072)) { noise = add(noise, 1); move16(); } - IF (sub(sharp, sharpPeak) > 0) + IF (GT_16(sharp, sharpPeak)) { sharpPeak = sharp; move16(); } } test(); - IF ( sub(st_fx->extl_fx, SWB_BWE) == 0 || sub(st_fx->extl_fx, FB_BWE) == 0 ) + IF ( EQ_16(st_fx->extl_fx, SWB_BWE)||EQ_16(st_fx->extl_fx,FB_BWE)) { test(); test(); test(); - IF(sub(k, numharmonic) >= 0 && sub(gain_tmp, 8192) > 0 && sub(gain_tmp, 29491) < 0 && sub(sharpPeak, shl(sharplimit, 10)) > 0) + IF(GE_16(k, numharmonic)&>_16(gain_tmp,8192)&<_16(gain_tmp,29491)&>_16(sharpPeak,shl(sharplimit,10))) { sharpMod = 1; move16(); @@ -782,10 +780,10 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class */ L_mean_d = L_add(L_mean_d, L_abs(L_tmp)); /*Q_syn+8 */ } } - ELSE IF (sub(st_fx->extl_fx, WB_BWE) == 0) + ELSE IF (EQ_16(st_fx->extl_fx, WB_BWE)) { test(); - IF (sub(k,numharmonic) >= 0 && sub(sharpPeak,shl(sharplimit, 10)) > 0) + IF (GE_16(k,numharmonic)&>_16(sharpPeak,shl(sharplimit,10))) { sharpMod = 1; move16(); @@ -799,7 +797,7 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class */ test(); test(); - IF (sharpMod && sub(st_fx->modeCount_fx, 12) < 0) + IF (sharpMod && LT_16(st_fx->modeCount_fx, 12)) { st_fx->modeCount_fx = add(st_fx->modeCount_fx, 1); } @@ -808,7 +806,7 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class */ st_fx->modeCount_fx = sub(st_fx->modeCount_fx, 1); } - IF (sub(st_fx->modeCount_fx, 2) >= 0) + IF (GE_16(st_fx->modeCount_fx, 2)) { sharpMod = 1; move16(); @@ -820,14 +818,14 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class */ mode = HARMONIC; move16(); } - ELSE IF ( sub(st_fx->extl_fx, SWB_BWE) == 0 || sub(st_fx->extl_fx, FB_BWE) == 0 ) + ELSE IF ( EQ_16(st_fx->extl_fx, SWB_BWE)||EQ_16(st_fx->extl_fx,FB_BWE)) { L_tmp = Mult_32_16(L_mean_d, 6827); /*Q_syn+8 ; 1/4.8 in Q15 */ test(); test(); test(); - IF (sub(noise, 4) > 0 && (L_sub(L_tmp, L_meanH) < 0 || L_meanH == 0) && sub(tilt_nb, 10240) < 0) + IF (GT_16(noise, 4)&&(LT_32(L_tmp,L_meanH)||L_meanH==0)&<_16(tilt_nb,10240)) { mode = NOISE; move16(); @@ -860,13 +858,13 @@ static void freq_weights_fx( move16(); FOR( i=1; i 0 ) + IF( GT_16(Band_Ener[i],max_b)) { max_b = Band_Ener[i]; move16();/*Q8 */ @@ -954,7 +952,7 @@ static void vqWithCand_w_fx( FOR( k = 0; k < surv; k++ ) { - IF( L_sub(L_dist,dist_min[k]) < 0 ) + IF( LT_32(L_dist,dist_min[k])) { FOR( l = surv - 1; l > k; l-- ) { @@ -1000,7 +998,7 @@ static void vqWithCand_w_fx( FOR( k = 0; k < surv; k++ ) { - IF( L_sub(L_dist,dist_min[k]) < 0 ) + IF( LT_32(L_dist,dist_min[k])) { FOR( l = surv - 1; l > k; l-- ) { @@ -1067,7 +1065,7 @@ static Word16 vqSimple_w_fx( L_tmp = Mult_32_16(L_tmp,temp);/*Q15 */ L_dist = L_add(L_dist,L_shr(L_tmp,10));/*Q5 */ } - IF (L_sub(L_dist, L_dist_min) < 0) + IF (LT_32(L_dist, L_dist_min)) { L_dist_min = L_add(L_dist, 0);/*Q5 */ index = i; @@ -1093,7 +1091,7 @@ static Word16 vqSimple_w_fx( L_tmp = L_mult(temp,temp);/*Q17 */ L_dist = L_add(L_dist,L_shr(L_tmp,12));/*Q5 */ } - IF (L_sub(L_dist, L_dist_min) < 0) + IF (LT_32(L_dist, L_dist_min)) { L_dist_min = L_add(L_dist, 0); index = i; @@ -1192,7 +1190,7 @@ static void MSVQ_Interpol_Tran_fx( } /* Check optimal candidate */ - IF (L_sub(L_dist, L_minDist) < 0) + IF (LT_32(L_dist, L_minDist)) { L_minDist = L_add(L_dist, 0); indice[0] = candInd[k]; @@ -1307,7 +1305,7 @@ static void msvq_interpol_fx( } /* Check optimal candidate */ - IF (L_sub(L_dist, L_minDist) < 0) + IF (LT_32(L_dist, L_minDist)) { L_minDist = L_add(L_dist, 0); @@ -1645,12 +1643,12 @@ static void energy_control_fx( Word16 SWB_signal_fx[L_FRAME32k], SFM_org_fx[SWB_FENV], SFM_gen_fx[SWB_FENV]; - IF ( sub(core,ACELP_CORE) == 0 ) + IF ( EQ_16(core,ACELP_CORE)) { gamma_fx = 11469; move16();/*.35 in Q15 */ test(); - IF ( sub(coder_type,AUDIO) != 0 && L_sub(st_fx->total_brate_fx,ACELP_8k85)<0 ) + IF ( NE_16(coder_type,AUDIO)&<_32(st_fx->total_brate_fx,ACELP_8k85)) { core_type = 0; move16(); @@ -1662,7 +1660,7 @@ static void energy_control_fx( } get_normalize_spec_fx(core, st_fx->extl_fx, mode, core_type, org_fx, SWB_signal_fx, &(st_fx->prev_L_swb_norm1_fx), offset, Q_new_lf); - IF ( sub(st_fx->extl_fx,WB_BWE) == 0) + IF ( EQ_16(st_fx->extl_fx,WB_BWE)) { max_band = 4; move16(); @@ -1685,7 +1683,7 @@ static void energy_control_fx( band_step = 1; move16(); - IF ( sub(offset,HQ_GENERIC_FOFFSET_32K) == 0 ) + IF ( EQ_16(offset,HQ_GENERIC_FOFFSET_32K)) { max_band = 12; move16(); @@ -1702,10 +1700,10 @@ static void energy_control_fx( calculate_Tonality_fx( org_fx+swb_bwe_subband_fx[n_band]+offset, SWB_signal_fx+swb_bwe_subband_fx[n_band]+offset, &SFM_org_fx[n_band], &SFM_gen_fx[n_band], swb_bwe_subband_fx[n_band+band_step]-swb_bwe_subband_fx[n_band] ); - IF( sub(SFM_gen_fx[n_band],mult_r(24576,SFM_org_fx[n_band])) < 0 ) + IF( LT_16(SFM_gen_fx[n_band],mult_r(24576,SFM_org_fx[n_band]))) { energy_factor_fx[n_band] = div_s(SFM_gen_fx[n_band],SFM_org_fx[n_band]);/*Q15 */ - IF( sub(energy_factor_fx[n_band],gamma_fx) < 0 ) + IF( LT_16(energy_factor_fx[n_band],gamma_fx)) { energy_factor_fx[n_band] = gamma_fx; move16(); @@ -1835,7 +1833,7 @@ static Word16 SWB_BWE_encoding_fx( Word16 max_fx; Word16 energy_factor_fx[SWB_FENV], w_env_fx[SWB_FENV]; - IF( sub(st_fx->L_frame_fx, L_FRAME ) == 0) + IF( EQ_16(st_fx->L_frame_fx, L_FRAME )) { L = L_SUBFR; move16(); @@ -1862,7 +1860,7 @@ static Word16 SWB_BWE_encoding_fx( energy_fx = L_add(energy_fx, L_shr(L_mult0(insig_lp_fx[i + tmp], insig_lp_fx[i + tmp]), 7)); /*2*Q_slb_speech - 7 */ } - IF(L_sub(Mult_32_16(energy_fx, 5958), st_fx->EnergyLF_fx) > 0) + IF(GT_32(Mult_32_16(energy_fx, 5958), st_fx->EnergyLF_fx)) { IsTransient_LF = 1; move16(); @@ -1877,7 +1875,7 @@ static Word16 SWB_BWE_encoding_fx( test(); test(); - IF( sub(IsTransient,1) == 0 && (sub(tilt_fx, 16384) > 0 || sub(st_fx->clas_fx,1) > 0) ) + IF( EQ_16(IsTransient,1)&&(GT_16(tilt_fx,16384)||GT_16(st_fx->clas_fx,1))) { IsTransient = 0; move16(); @@ -1885,7 +1883,7 @@ static Word16 SWB_BWE_encoding_fx( move16(); } - IF( sub(IsTransient,1) == 0 ) + IF( EQ_16(IsTransient,1)) { mode = IsTransient; move16(); @@ -1986,12 +1984,12 @@ static Word16 SWB_BWE_encoding_fx( move16(); } - IF(sub(Rat_tenv_fx, 8192) < 0) + IF(LT_16(Rat_tenv_fx, 8192)) { L_tmp = L_mult(Rat_tenv_fx, 19661);/*Q29 */ Rat_tenv_fx = round_fx(L_shl(L_tmp, 2));/*Q15 */ } - ELSE IF (sub(Rat_tenv_fx, 16384)> 0) + ELSE IF (GT_16(Rat_tenv_fx, 16384)) { Rat_tenv_fx = 32767; move16(); @@ -2009,7 +2007,7 @@ static Word16 SWB_BWE_encoding_fx( move16(); FOR(n_band = 1; n_band < SWB_TENV; n_band++) { - IF(sub(SWB_tenv_fx[n_band],max_fx) > 0) + IF(GT_16(SWB_tenv_fx[n_band],max_fx)) { max_fx = SWB_tenv_fx[n_band]; move16(); @@ -2057,7 +2055,7 @@ static Word16 SWB_BWE_encoding_fx( /*SWB_tenv_fx[pos] = add(SWB_tenv_fx[pos], mult_r(SWB_tenv_fx[pos], 164)); move16();//Q3 */ SWB_tenv_fx[pos] = round_fx(L_mac(L_mult(SWB_tenv_fx[pos],32767), SWB_tenv_fx[pos], 164)); /*Q3 */ - IF(L_sub(energy_fx, SWB_tenv_fx[pos]) < 0) + IF(LT_32(energy_fx, SWB_tenv_fx[pos])) { FOR(n_band = pos+1; n_band < SWB_TENV; n_band++) { @@ -2070,7 +2068,7 @@ static Word16 SWB_BWE_encoding_fx( { FOR(n_band = 1; n_band < SWB_TENV; n_band++) { - IF(sub(SWB_tenv_fx[n_band-1], SWB_tenv_fx[n_band]) > 0) + IF(GT_16(SWB_tenv_fx[n_band-1], SWB_tenv_fx[n_band])) { /*SWB_tenv_fx[n_band-1] = add(mult_r(SWB_tenv_fx[n_band-1], 16384), mult_r(SWB_tenv_fx[n_band], 16384)); move16();//Q3 */ SWB_tenv_fx[n_band-1] = round_fx(L_mac(L_mult(SWB_tenv_fx[n_band-1], 16384), SWB_tenv_fx[n_band], 16384)); /*Q3 */ @@ -2091,7 +2089,7 @@ static Word16 SWB_BWE_encoding_fx( test(); test(); - IF(IsTransient_LF == 0 && sub(coder_type,INACTIVE) == 0 && sub(st_fx->TransientHangOver_fx,1) == 0) + IF(IsTransient_LF == 0 && EQ_16(coder_type,INACTIVE)&&EQ_16(st_fx->TransientHangOver_fx,1)) { FOR(n_band = 0; n_band < SWB_TENV; n_band++) { @@ -2129,7 +2127,7 @@ static Word16 SWB_BWE_encoding_fx( SWB_tenv_tmp_fx[n_band] = round_fx(L_shl(L_tmp, 11)); /* Q11 */ } - IF (sub(SWB_tenv_tmp_fx[n_band], 30720) > 0) + IF (GT_16(SWB_tenv_tmp_fx[n_band], 30720)) { index = 15; move16(); @@ -2165,7 +2163,7 @@ static Word16 SWB_BWE_encoding_fx( energy_fx = L_add(L_tmp, energy_fx); /*2*Q_synth-5 */ } - IF (sub(n_band, sub(SWB_FENV,2)) < 0) + IF (LT_16(n_band, sub(SWB_FENV,2))) { global_gain_fx = L_add(global_gain_fx, L_shr(energy_fx, sub(2*Q_synth-5, 2*Q_shb))); /*2*Q_shb */ } @@ -2251,9 +2249,9 @@ static void get_normalize_spec_fx_32( set32_fx(SWB_signal_fx, 0, HQ_GENERIC_HIGH0+offset); calc_normal_length_fx_32(core, org_fx, mode, extl, &L_swb_norm, prev_L_swb_norm); test(); - IF(sub(extl , SWB_BWE) == 0 || sub( extl , FB_BWE) == 0 ) + IF(EQ_16(extl , SWB_BWE)||EQ_16(extl,FB_BWE)) { - IF ( sub(mode ,HARMONIC) == 0 ) + IF ( EQ_16(mode ,HARMONIC)) { Copy32(org_fx, &SWB_signal_fx[add(240,offset)], 240); Copy32(&org_fx[128], &SWB_signal_fx[add(480,offset)], 80); @@ -2267,7 +2265,7 @@ static void get_normalize_spec_fx_32( frq_end = 560+offset; move16(); } - ELSE IF (sub(extl , WB_BWE)==0) + ELSE IF (EQ_16(extl , WB_BWE)) { IF ( core_type == 0 ) { @@ -2284,7 +2282,7 @@ static void get_normalize_spec_fx_32( { Copy32( org_fx+HQ_GENERIC_OFFSET, SWB_signal_fx+HQ_GENERIC_HIGH0+offset, HQ_GENERIC_LEN0 ); Copy32( org_fx+HQ_GENERIC_OFFSET, SWB_signal_fx+HQ_GENERIC_HIGH1+offset, HQ_GENERIC_LEN0 ); - IF ( sub(offset , HQ_GENERIC_FOFFSET_24K4) == 0 ) + IF ( EQ_16(offset , HQ_GENERIC_FOFFSET_24K4)) { Copy32( org_fx+HQ_GENERIC_LOW0, SWB_signal_fx+HQ_GENERIC_HIGH2+offset, HQ_GENERIC_END_FREQ-HQ_GENERIC_HIGH2 ); } @@ -2344,7 +2342,7 @@ static void calculate_tonality_fx_32( { org_spec_fx[n_coeff] = L_abs(org_fx[n_coeff]); - IF (L_sub(max_fx , org_spec_fx[n_coeff])<0) + IF (LT_32(max_fx , org_spec_fx[n_coeff])) { max_fx = org_spec_fx[n_coeff]; move16(); @@ -2355,7 +2353,7 @@ static void calculate_tonality_fx_32( FOR ( n_coeff=0; n_coefftotal_brate_fx , ACELP_8k00)<=0 ) + IF ( NE_16(coder_type , AUDIO)&&LE_32(st_fx->total_brate_fx,ACELP_8k00)) { core_type = 0; move16(); @@ -2487,7 +2485,7 @@ static void energy_control_fx_32( get_normalize_spec_fx_32(core, st_fx->extl_fx, mode, core_type, org_fx, SWB_signal_fx, &(st_fx->prev_L_swb_norm1_fx), offset ); - IF ( sub(st_fx->extl_fx , WB_BWE) == 0) + IF ( EQ_16(st_fx->extl_fx , WB_BWE)) { max_band = 4; move16(); @@ -2501,7 +2499,7 @@ static void energy_control_fx_32( move16(); get_normalize_spec_fx_32(core, -1, mode, -1, org_fx, SWB_signal_fx, &(st_fx->prev_L_swb_norm1_fx), offset ); - IF ( sub(offset , HQ_GENERIC_FOFFSET_32K) == 0 ) + IF ( EQ_16(offset , HQ_GENERIC_FOFFSET_32K)) { max_band = 12; move16(); @@ -2524,7 +2522,7 @@ static void energy_control_fx_32( tmp = div_s(tmp1, tmp2);/*15 + (14 + exp1 ) - (14 + exp2) */ energy_factor_fx[n_band] = shl(tmp, sub(exp2, exp1));/*15 */ - IF (sub(energy_factor_fx[n_band] , gamma_fx)<0) + IF (LT_16(energy_factor_fx[n_band] , gamma_fx)) { energy_factor_fx[n_band] = gamma_fx; move16(); @@ -2559,7 +2557,7 @@ static Word16 decision_hq_generic_class_fx_32 ( Word32 p2a_fx; Word32 avgp2a_fx; - IF ( sub(hq_generic_offset , HQ_GENERIC_FOFFSET_24K4) == 0 ) + IF ( EQ_16(hq_generic_offset , HQ_GENERIC_FOFFSET_24K4)) { nband = 10; move16(); @@ -2586,7 +2584,7 @@ static Word16 decision_hq_generic_class_fx_32 ( tmp = extract_h(L_shl(coefs_fx[i], exp));/*12 + exp - 16 */ L_tmp = L_mult0(tmp, tmp);/*2 * exp - 8 */ L_tmp = L_shl(L_tmp, sub(14, shl(exp, 1)));/*6 */ - IF (L_sub(L_tmp , p_fx) > 0) + IF (GT_32(L_tmp , p_fx)) { p_fx = L_add(L_tmp, 0);/*6 */ } @@ -2612,7 +2610,7 @@ static Word16 decision_hq_generic_class_fx_32 ( } } avgp2a_fx = Mult_32_16(avgp2a_fx, inv_band_fx);/*16 + 15 - 15 */ - IF (L_sub(avgp2a_fx , 187227)>0)/*8.6 / 10log10(2), Q16 */ + IF (GT_32(avgp2a_fx , 187227))/*8.6 / 10log10(2), Q16 */ { return HQ_GENERIC_EXC1; } @@ -2644,7 +2642,7 @@ void hq_generic_encoding_fx( Word32 L_tmp, max_coefs_fx; Word16 w_env_fx[SWB_FENV]; - IF ( sub(hq_generic_offset , HQ_GENERIC_FOFFSET_24K4)<=0 ) + IF ( LE_16(hq_generic_offset , HQ_GENERIC_FOFFSET_24K4)) { nenv = SWB_FENV; move16(); @@ -2658,7 +2656,7 @@ void hq_generic_encoding_fx( energy_control_fx_32(st_fx, HQ_CORE, -1, -1, coefs_fx, hq_generic_offset, energy_factor_fx); - IF ( sub(st_fx->hq_generic_speech_class_fx , 1) == 0 ) + IF ( EQ_16(st_fx->hq_generic_speech_class_fx , 1)) { push_indice_fx( st_fx, IND_HQ_SWB_EXC_SP_CLAS, 1, 1 ); *hq_generic_exc_clas = HQ_GENERIC_SP_EXC; @@ -2678,7 +2676,7 @@ void hq_generic_encoding_fx( tmp2 = add(swb_bwe_subband_fx[n_band+1] , hq_generic_offset); FOR ( n_coeff = add(swb_bwe_subband_fx[n_band],hq_generic_offset); n_coeff < tmp2; n_coeff++ ) { - IF (L_sub(max_coefs_fx , L_abs(coefs_fx[n_coeff])) < 0) + IF (LT_32(max_coefs_fx , L_abs(coefs_fx[n_coeff]))) { max_coefs_fx = L_abs(coefs_fx[n_coeff]); } @@ -2711,7 +2709,7 @@ void hq_generic_encoding_fx( } } - IF ( sub(st_fx->bwidth_fx , FB) == 0 ) + IF ( EQ_16(st_fx->bwidth_fx , FB)) { FOR ( n_band = 0; n_band < DIM_FB; n_band++ ) { @@ -2720,7 +2718,7 @@ void hq_generic_encoding_fx( tmp2 = fb_bwe_subband[add(n_band,1)]; FOR ( n_coeff = fb_bwe_subband[n_band]; n_coeff < tmp2; n_coeff++ ) { - IF (L_sub(max_coefs_fx, L_abs(coefs_fx[n_coeff])) < 0) + IF (LT_32(max_coefs_fx, L_abs(coefs_fx[n_coeff]))) { max_coefs_fx = L_abs(coefs_fx[n_coeff]); } @@ -2770,7 +2768,7 @@ void hq_generic_encoding_fx( /* Energy VQ */ - IF ( sub(hq_generic_offset , HQ_GENERIC_FOFFSET_24K4) <= 0 ) + IF ( LE_16(hq_generic_offset , HQ_GENERIC_FOFFSET_24K4)) { msvq_interpol_fx( hq_generic_fenv_fx, w_env_fx, indice ); } @@ -2779,7 +2777,7 @@ void hq_generic_encoding_fx( msvq_interpol_2_fx(hq_generic_fenv_fx, w_env_fx, indice, nenv); } - IF ( sub(st_fx->bwidth_fx , FB) == 0 ) + IF ( EQ_16(st_fx->bwidth_fx , FB)) { indice[5] = vqSimple_w_fx(hq_generic_fenv_fx+nenv, hq_generic_fenv_fx+nenv, EnvCdbkFB_fx, NULL, DIM_FB, N_CB_FB, 0); } @@ -2789,7 +2787,7 @@ void hq_generic_encoding_fx( push_indice_fx( st_fx, IND_SWB_FENV_HQ, indice[2], 6 ); push_indice_fx( st_fx, IND_SWB_FENV_HQ, indice[3], 5 ); - IF ( sub(hq_generic_offset , HQ_GENERIC_FOFFSET_24K4) <= 0 ) + IF ( LE_16(hq_generic_offset , HQ_GENERIC_FOFFSET_24K4)) { push_indice_fx( st_fx, IND_SWB_FENV_HQ, indice[4], 6 ); } @@ -2798,7 +2796,7 @@ void hq_generic_encoding_fx( push_indice_fx( st_fx, IND_SWB_FENV_HQ, indice[4], 5 ); } - IF ( sub(st_fx->bwidth_fx , FB) == 0 ) + IF ( EQ_16(st_fx->bwidth_fx , FB)) { push_indice_fx( st_fx, IND_FB_FENV_HQ, indice[5], 5 ); } @@ -2815,7 +2813,7 @@ void hq_generic_encoding_fx( } - IF ( sub(st_fx->bwidth_fx , FB) == 0 ) + IF ( EQ_16(st_fx->bwidth_fx , FB)) { FOR ( n_band = 0; n_band < DIM_FB; n_band++ ) { diff --git a/lib_enc/swb_bwe_enc_hr_fx.c b/lib_enc/swb_bwe_enc_hr_fx.c index 587f0c9f466ed19dca138e8e7c915427a7866cb9..4dac348b02937920ee7c4935f546e7a8a70c540f 100644 --- a/lib_enc/swb_bwe_enc_hr_fx.c +++ b/lib_enc/swb_bwe_enc_hr_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -8,8 +8,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*-------------------------------------------------------------------* @@ -64,7 +62,7 @@ static Word16 en_band_quant_fx(/* o : quantization index */ tmp16 = sub(en_band[j], env_code[i*2+j]); L_err = L_mac0(L_err, tmp16, tmp16); } */ - if (L_sub(L_err, L_maxerr) < 0) + if (LT_32(L_err, L_maxerr)) { ind = i; move16(); @@ -142,7 +140,7 @@ void swb_bwe_enc_hr_fx( /* reset memories in case that last frame was a different technology */ test(); - IF( sub(st_fx->last_core_fx, HQ_CORE) == 0 || sub(st_fx->last_extl_fx, st_fx->extl_fx) != 0 ) + IF( EQ_16(st_fx->last_core_fx, HQ_CORE)||NE_16(st_fx->last_extl_fx,st_fx->extl_fx)) { set16_fx( st_fx->L_old_wtda_swb_fx, 0, L_FRAME48k ); st_fx->Q_old_wtda = 0; @@ -222,7 +220,7 @@ void swb_bwe_enc_hr_fx( nBits = add(nBits, s_and(nBits_total, NUM_TIME_SW_BLKS_MASK)); /* set width of noncoded (blind estimated) spectrum */ - IF( sub(st_fx->extl_fx, SWB_BWE_HIGHRATE) == 0) + IF( EQ_16(st_fx->extl_fx, SWB_BWE_HIGHRATE)) { width_noncoded = L_FRAME32k/NUM_TIME_SWITCHING_BLOCKS - NUM_TRANS_END_FREQ_COEF; move16(); @@ -275,7 +273,7 @@ void swb_bwe_enc_hr_fx( j = sub(t_audio_fx_exp, scl); /* compute energy of noncoded (14.4-20kHz) spectrum */ - IF( sub(st_fx->extl_fx, FB_BWE_HIGHRATE) == 0) + IF( EQ_16(st_fx->extl_fx, FB_BWE_HIGHRATE)) { L_tmp = Calc_Energy_Autoscaled(t_audio_fx + add(temp, NUM_TRANS_END_FREQ_COEF), j, width_noncoded, &temp2); L_en_noncoded_fx = Sqrt_Ratio32(L_tmp, temp2, L_deposit_l(width_noncoded), 0, &en_noncoded_fx_exp); @@ -354,7 +352,7 @@ void swb_bwe_enc_hr_fx( } ELSE { - IF( sub(ind2, NUM_ENVLOPE_CODE_HR_TR2 ) < 0) + IF( LT_16(ind2, NUM_ENVLOPE_CODE_HR_TR2 )) { ind1 = en_band_quant_fx( en_band_fx, swb_hr_env_code3_fx, NUM_ENVLOPE_CODE_HR_TR2 ); move16(); @@ -390,7 +388,7 @@ void swb_bwe_enc_hr_fx( * estimate energy of noncoded spectrum (14.4-20kHz) *---------------------------------------------------------------------*/ - IF( sub(st_fx->extl_fx, SWB_BWE_HIGHRATE) != 0) + IF( NE_16(st_fx->extl_fx, SWB_BWE_HIGHRATE)) { /* st->extl == FB_BWE_HIGHRATE */ /* 'en_noncoded /= (gain * en_band[N_BANDS_TRANS_BWE_HR-1])' */ @@ -466,7 +464,7 @@ void swb_bwe_enc_hr_fx( *---------------------------------------------------------------------*/ /* set width of noncoded (blind estimated) spectrum */ - IF( sub(st_fx->extl_fx, SWB_BWE_HIGHRATE) == 0) + IF( EQ_16(st_fx->extl_fx, SWB_BWE_HIGHRATE)) { width_noncoded = L_FRAME32k - NUM_NONTRANS_END_FREQ_COEF; move16(); @@ -478,7 +476,7 @@ void swb_bwe_enc_hr_fx( } /* compute energy of noncoded (14.4-20kHz) spectrum */ - IF( sub(st_fx->extl_fx, FB_BWE_HIGHRATE) == 0) + IF( EQ_16(st_fx->extl_fx, FB_BWE_HIGHRATE)) { L_tmp = Calc_Energy_Autoscaled(t_audio_fx + NUM_NONTRANS_END_FREQ_COEF, t_audio_fx_exp, width_noncoded, &temp2); L_en_noncoded_fx = Sqrt_Ratio32(L_tmp, temp2, L_deposit_l(width_noncoded), 0, &en_noncoded_fx_exp); @@ -593,7 +591,7 @@ void swb_bwe_enc_hr_fx( pos = 0; FOR (i=1; i 0) + IF( GT_16(nBits_total, NBITS_THRESH_BWE_HR)) { i = NUM_NONTRANS_END_FREQ_COEF - NUM_NONTRANS_START_FREQ_COEF; move16(); @@ -625,7 +623,7 @@ void swb_bwe_enc_hr_fx( /*---------------------------------------------------------------------* * estimate energy of noncoded spectrum (14.4-20kHz) *---------------------------------------------------------------------*/ - IF( sub(st_fx->extl_fx, SWB_BWE_HIGHRATE) != 0) + IF( NE_16(st_fx->extl_fx, SWB_BWE_HIGHRATE)) { /* st->extl == FB_BWE_HIGHRATE */ /* 'en_noncoded /= (gain * min_env)' */ @@ -694,7 +692,7 @@ void swb_bwe_enc_hr_fx( *---------------------------------------------------------------------*/ test(); - IF( sub(nBits, 9 + NBITS_GLOB_GAIN_BWE_HR) >= 0 && sum16_fx( nq, Nsv) > 0 ) + IF( GE_16(nBits, 9 + NBITS_GLOB_GAIN_BWE_HR)&&sum16_fx(nq,Nsv)>0) { /* select spectrum of the second stage coding */ ptr16 = &t_audio_fx[0]; @@ -725,7 +723,7 @@ void swb_bwe_enc_hr_fx( } /* calculate the number of subbands according to the rest bits */ - IF( sub(nBits, 396) > 0 ) + IF( GT_16(nBits, 396)) { Nsv2 = 33; move16(); @@ -741,7 +739,7 @@ void swb_bwe_enc_hr_fx( /* Nsv2 * 12 <= nBits (Nsv2 is not too high) AND */ /* nBits - Nsv2 * 12 < 12 (Nsv2 is the highest divisor) */ L_temp = L_msu0(L_deposit_l(nBits), 12, Nsv2); - if (L_sub(L_temp, 12L) >= 0) + if (GE_32(L_temp, 12L)) Nsv2 = add(Nsv2, 1); if (L_temp < 0) Nsv2 = sub(Nsv2, 1); diff --git a/lib_enc/swb_bwe_enc_lr_fx.c b/lib_enc/swb_bwe_enc_lr_fx.c index 299006dec0c7ad86d4c20541512667104ebcd93c..ab969889d3a7fff4467f5e1636312d9483df7894 100644 --- a/lib_enc/swb_bwe_enc_lr_fx.c +++ b/lib_enc/swb_bwe_enc_lr_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -8,8 +8,6 @@ #include "prot_fx.h" #include "rom_com_fx.h" #include "stl.h" -#include "wmc_auto.h" - #include "basop_mpy.h" /*--------------------------------------------------------------------------* @@ -388,14 +386,14 @@ static Word16 GetSubbandCorrIndex2_pulsestep_fx( } /* Get the initial energy for zero lag */ - WHILE( *ptr_predBuf == 0 && sub(absPos_fx, ssearch_buflim) < 0 ) + WHILE( *ptr_predBuf == 0 && LT_16(absPos_fx, ssearch_buflim)) { ptr_predBuf++; ptr_predBuf_ni++; absPos_fx = add(absPos_fx, 1); } - IF( sub(absPos_fx, ssearch_buflim) == 0 ) + IF( EQ_16(absPos_fx, ssearch_buflim)) { ptr_predBuf--; ptr_predBuf_ni--; @@ -490,7 +488,7 @@ static Word16 GetSubbandCorrIndex2_pulsestep_fx( ptr_predBuf_ni++; absPos_fx++; - WHILE( *ptr_predBuf == 0 && sub(absPos_fx, ssearch_buflim) < 0 ) + WHILE( *ptr_predBuf == 0 && LT_16(absPos_fx, ssearch_buflim)) { ptr_predBuf++; ptr_ssBuf_ni_fx++; @@ -498,9 +496,9 @@ static Word16 GetSubbandCorrIndex2_pulsestep_fx( absPos_fx = add(absPos_fx, 1); } - IF( sub(absPos_fx, ssearch_buflim) >= 0 ) + IF( GE_16(absPos_fx, ssearch_buflim)) { - if( sub(bestIdx_fx, -1) == 0 ) + if( EQ_16(bestIdx_fx, -1)) { ib_flag_fx = 1; move16(); @@ -510,7 +508,7 @@ static Word16 GetSubbandCorrIndex2_pulsestep_fx( } } - IF( sub(ib_flag_fx, 1) == 0 ) + IF( EQ_16(ib_flag_fx, 1)) { bestIdx_fx = 0; move16(); @@ -750,7 +748,7 @@ static void gethar_noisegn_fx( FOR (i = 0; i < gqlevs_fx; i++) { d_fx = abs_s(g_fx - gain_table_SWB_BWE_fx[i]); - IF (sub(d_fx, dmin_fx) < 0) + IF (LT_16(d_fx, dmin_fx)) { dmin_fx = d_fx; move16(); @@ -844,7 +842,7 @@ static void EncodeSWBSubbands_fx( set16_fx(pul_res_fx,0,NB_SWB_SUBBANDS); - IF( sub(hqswb_clas_fx, HQ_HARMONIC) == 0 ) + IF( EQ_16(hqswb_clas_fx, HQ_HARMONIC)) { pos_max_hfe2 = har_est_fx( L_spectra, fLenLow_fx, &har_freq_est1, &har_freq_est2, &flag_dis, prev_frm_hfe2_fx, subband_search_offset_fx, sbWidth_fx, prev_stab_hfe2_fx ); noise_extr_corcod_fx(L_spectra, L_spectra_ni, sspectra_fx, sspectra_diff_fx, sspectra_ni_fx, fLenLow_fx , st_fx->prev_hqswb_clas_fx ,&st_fx->prev_ni_ratio_fx, &Qss); @@ -863,7 +861,7 @@ static void EncodeSWBSubbands_fx( IF ( flag_dis == 0 ) { test(); - if ( sub(har_freq_est2, SWB_HAR_RAN1) != 0 || sub(har_freq_est2, *prev_frm_hfe2_fx) != 0 ) + if ( NE_16(har_freq_est2, SWB_HAR_RAN1)||NE_16(har_freq_est2,*prev_frm_hfe2_fx)) { har_freq_est2 = add(har_freq_est2, lagIndices_fx[0]); move16(); @@ -918,7 +916,7 @@ static void EncodeSWBSubbands_fx( /* Bitstream operations */ FOR(k=0; k @@ -8,8 +8,6 @@ #include "prot_fx.h" #include "rom_com_fx.h" #include "stl.h" -#include "wmc_auto.h" - #include "basop_util.h" #include @@ -60,12 +58,12 @@ void wb_pre_proc_fx( test(); test(); test(); - IF ( (L_sub(st_fx->last_total_brate_fx, ACELP_6k60)==0) || - (L_sub(st_fx->last_total_brate_fx, ACELP_8k85)==0) || - (L_sub(st_fx->last_total_brate_fx, ACELP_12k65)==0) || - (L_sub(st_fx->last_total_brate_fx, ACELP_14k25)==0) || - (L_sub(st_fx->last_total_brate_fx, ACELP_15k85)==0) || - (L_sub(st_fx->last_total_brate_fx, ACELP_18k25)>=0 && L_sub(st_fx->last_total_brate_fx, ACELP_23k85)<=0) ) + IF ( (EQ_32(st_fx->last_total_brate_fx, ACELP_6k60))|| + (EQ_32(st_fx->last_total_brate_fx, ACELP_8k85)) || + (EQ_32(st_fx->last_total_brate_fx, ACELP_12k65)) || + (EQ_32(st_fx->last_total_brate_fx, ACELP_14k25)) || + (EQ_32(st_fx->last_total_brate_fx, ACELP_15k85)) || + (GE_32(st_fx->last_total_brate_fx, ACELP_18k25) && LE_32(st_fx->last_total_brate_fx, ACELP_23k85)) ) { fSwitchFromIO = 1; move16(); @@ -100,7 +98,7 @@ void wb_pre_proc_fx( test(); test(); - IF ( sub(st_fx->extl_fx, WB_BWE) == 0 || sub(st_fx->extl_fx, WB_TBE) == 0 || st_fx->igf != 0 ) + IF ( EQ_16(st_fx->extl_fx, WB_BWE)||EQ_16(st_fx->extl_fx,WB_TBE)||st_fx->igf!=0) { ramp_flag = 0; @@ -108,7 +106,7 @@ void wb_pre_proc_fx( test(); test(); test(); - IF( (sub(st_fx->last_extl_fx, WB_TBE) != 0 && sub(st_fx->last_extl_fx, WB_BWE) != 0 && st_fx->igf == 0) || + IF( (NE_16(st_fx->last_extl_fx, WB_TBE)&&NE_16(st_fx->last_extl_fx,WB_BWE)&&st_fx->igf==0)|| (st_fx->igf != 0 && fSwitchFromIO != 0) ) { ramp_flag = 1; @@ -125,7 +123,7 @@ void wb_pre_proc_fx( Scale_sig(st_fx->decim_state1_fx, (2*ALLPASSSECTIONS_STEEP+1), -Q_wb_sp); Scale_sig(st_fx->decim_state2_fx, (2*ALLPASSSECTIONS_STEEP+1), -Q_wb_sp); - IF( sub(st_fx->extl_fx, WB_TBE) != 0 ) + IF( NE_16(st_fx->extl_fx, WB_TBE)) { /* Update the previous wideband speech buffer in case of a WB_BWE frame */ Sample_Delay_WB_BWE = (L_LOOK_12k8 + L_SUBFR) * 5/16; @@ -147,7 +145,7 @@ void wb_pre_proc_fx( test(); test(); test(); - IF ( (sub(st_fx->extl_fx, WB_BWE) != 0 || (sub(st_fx->extl_fx, WB_BWE) == 0 && L_sub(st_fx->total_brate_fx, ACELP_8k00) <= 0)) && !st_fx->ppp_mode_fx ) + IF ( (NE_16(st_fx->extl_fx, WB_BWE)||(EQ_16(st_fx->extl_fx,WB_BWE)&&LE_32(st_fx->total_brate_fx,ACELP_8k00)))&&!st_fx->ppp_mode_fx) { Sample_Delay_WB_BWE = NS2SA_fx2( 16000, DELAY_FD_BWE_ENC_12k8_NS ); @@ -225,27 +223,26 @@ void swb_pre_proc_fx( set16_fx( old_input_fx, 0, NS2SA_fx2(48000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS) + L_FRAME48k ); - IF( L_sub(st_fx->input_Fs_fx, 32000) == 0 ) + IF( EQ_32(st_fx->input_Fs_fx, 32000)) { Copy(input_fx, new_swb_speech_fx, L_FRAME32k); /*Q0 */ test(); test(); - IF( sub(st_fx->last_extl_fx, SWB_BWE) != 0 && sub(st_fx->last_extl_fx, FB_BWE) != 0 && sub(st_fx->extl_fx, SWB_BWE_HIGHRATE) != 0 ) + IF( NE_16(st_fx->last_extl_fx, SWB_BWE)&&NE_16(st_fx->last_extl_fx,FB_BWE)&&NE_16(st_fx->extl_fx,SWB_BWE_HIGHRATE)) { Sample_Delay_SWB_BWE = NS2SA_fx2( 32000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ); Copy( st_fx->old_fdbwe_speech_fx, &old_input_fx[Sample_Delay_SWB_BWE], L_FRAME32k ); set16_fx( old_input_fx, 0, Sample_Delay_SWB_BWE ); Copy( st_fx->old_fdbwe_speech_fx + L_FRAME32k - Sample_Delay_SWB_BWE, st_fx->old_input_fx, Sample_Delay_SWB_BWE ); - IF ( sub(st_fx->extl_fx, WB_BWE ) != 0) + IF( sub(st_fx->extl_fx, WB_BWE) != 0 ) { Copy( old_input_fx, st_fx->L_old_wtda_swb_fx, L_FRAME32k ); } - } test(); - IF( sub(st_fx->extl_fx, SWB_BWE) != 0 && sub(st_fx->extl_fx, FB_BWE) != 0 ) + IF( NE_16(st_fx->extl_fx, SWB_BWE)&&NE_16(st_fx->extl_fx,FB_BWE)) { Copy( input_fx, st_fx->old_fdbwe_speech_fx, L_FRAME32k ); } @@ -253,11 +250,11 @@ void swb_pre_proc_fx( ELSE /* 48 kHz */ { /* 48kHz sampled processing needs review of FD2 memory handling/Q-factors */ - IF( sub(st_fx->codec_mode,MODE1) == 0 ) + IF( EQ_16(st_fx->codec_mode,MODE1)) { test(); test(); - IF( sub(st_fx->extl_fx,SWB_BWE) != 0 && sub(st_fx->extl_fx,FB_BWE) != 0 && sub(st_fx->core_fx,ACELP_CORE) == 0 ) + IF( NE_16(st_fx->extl_fx,SWB_BWE)&&NE_16(st_fx->extl_fx,FB_BWE)&&EQ_16(st_fx->core_fx,ACELP_CORE)) { /* move the resampling out of the TDBWE path as new_swb_speech is not needed for TDBWE. */ Copy( input_fx, st_fx->old_fdbwe_speech_fx, L_FRAME48k ); @@ -265,10 +262,10 @@ void swb_pre_proc_fx( ELSE { test(); - IF( sub(st_fx->last_extl_fx,SWB_BWE) != 0 && sub(st_fx->last_extl_fx,FB_BWE) != 0 ) + IF( NE_16(st_fx->last_extl_fx,SWB_BWE)&&NE_16(st_fx->last_extl_fx,FB_BWE)) { /* resample 48 kHz to 32kHz */ - IF( sub(st_fx->last_bwidth_fx,FB) == 0 ) + IF( EQ_16(st_fx->last_bwidth_fx,FB)) { inner_frame = L_FRAME48k; inner_Fs = 48000; @@ -291,7 +288,7 @@ void swb_pre_proc_fx( move16(); } /* resample 48 kHz to 32kHz */ - IF( sub(st_fx->bwidth_fx,FB) == 0 ) + IF( EQ_16(st_fx->bwidth_fx,FB)) { Copy( input_fx, new_swb_speech_fx, L_FRAME48k ); } @@ -305,7 +302,7 @@ void swb_pre_proc_fx( ELSE { /* resample 48 kHz to 32kHz */ - IF( sub(st_fx->bwidth_fx,FB) == 0 ) + IF( EQ_16(st_fx->bwidth_fx,FB)) { Copy( input_fx, new_swb_speech_fx, L_FRAME48k ); } @@ -322,10 +319,10 @@ void swb_pre_proc_fx( test(); test(); test(); - IF( ( sub(st_fx->core_fx, ACELP_CORE) == 0 && sub( st_fx->extl_fx, SWB_BWE_HIGHRATE) != 0 && sub(st_fx->extl_fx, FB_BWE_HIGHRATE) != 0 ) - || ( ( L_sub(st_fx->total_brate_fx, 9600) == 0 || st_fx->rf_mode != 0 ) && sub(st_fx->bwidth_fx, SWB) == 0 ) ) + IF( ( EQ_16(st_fx->core_fx, ACELP_CORE)&&NE_16(st_fx->extl_fx,SWB_BWE_HIGHRATE)&&NE_16(st_fx->extl_fx,FB_BWE_HIGHRATE)) + || ( ( EQ_32(st_fx->total_brate_fx, 9600) || st_fx->rf_mode != 0 ) && EQ_16(st_fx->bwidth_fx, SWB) ) ) { - IF( sub(st_fx->L_frame_fx, L_FRAME) == 0 ) + IF( EQ_16(st_fx->L_frame_fx, L_FRAME)) { startB= 34; endB= 14; @@ -393,7 +390,7 @@ void swb_pre_proc_fx( test(); test(); - IF( sub(st_fx->extl_fx, WB_TBE) != 0 && sub(st_fx->extl_fx, SWB_TBE) != 0 && sub(st_fx->extl_fx, FB_TBE) != 0 ) + IF( NE_16(st_fx->extl_fx, WB_TBE)&&NE_16(st_fx->extl_fx,SWB_TBE)&&NE_16(st_fx->extl_fx,FB_TBE)) { /* Update the previous superwideband speech buffer in case of a SWB_BWE frame - this code is in swb_tbe_enc */ delay = L_LOOK_16k + L_SUBFR16k; @@ -402,7 +399,7 @@ void swb_pre_proc_fx( } ELSE { - IF( sub(st_fx->bwidth_fx, FB) == 0 || sub(st_fx->core_fx, ACELP_CORE) == 0) + IF( EQ_16(st_fx->bwidth_fx, FB)||EQ_16(st_fx->core_fx,ACELP_CORE)) { set16_fx( st_fx->old_speech_shb_fx, 0, L_LOOK_16k + L_SUBFR16k ); set16_fx( shb_speech_fx, 0, L_FRAME16k ); /* shb_speech for FB/SWB BWE_HIGHRATE is not used at 64kbps */ diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 8e4ab33d184aa6b5e25d2f31ea9cffbd01c26fc0..85bce18559bffe5114a74d1d10d0f7074b2c0286 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ @@ -9,8 +9,6 @@ #include "prot_fx.h" #include "rom_com_fx.h" #include "stl.h" -#include "wmc_auto.h" - /*-----------------------------------------------------------------* * Local functions @@ -137,7 +135,7 @@ void find_max_mem_enc( /* for total_brate > 16.4kbps, use n_mem2; else account for the max2 for n_mem calculation */ *n_mem2 = norm_s(max2); if(max2 == 0) *n_mem2 = 15; - if(L_sub(st_fx->total_brate_fx, ACELP_24k40) < 0) + if(LT_32(st_fx->total_brate_fx, ACELP_24k40)) { max = s_max(max, max2); } @@ -149,7 +147,7 @@ void find_max_mem_enc( tempQ15 = abs_s( st_fx->tbe_premph_fx ); max = s_max(max, tempQ15); - IF( sub(st_fx->extl_fx, FB_TBE) == 0 ) + IF( EQ_16(st_fx->extl_fx, FB_TBE)) { FOR ( i = 0; i < LPC_SHB_ORDER; i++ ) { @@ -203,7 +201,7 @@ void rescale_genSHB_mem_enc( Encoder_State_fx* st_fx, Word16 sf ) } /* -- Apply memory scaling for 13.2 and 16.4k bps using sf ----*/ - IF(L_sub(st_fx->total_brate_fx, ACELP_24k40) < 0) + IF(LT_32(st_fx->total_brate_fx, ACELP_24k40)) { FOR ( i = 0; i < LPC_SHB_ORDER; i++ ) { @@ -407,7 +405,7 @@ void ResetSHBbuffer_Enc_fx( set16_fx( st_fx->state_syn_shbexc_fx, 0, L_SHB_LAHEAD ); set16_fx( st_fx->state_lpc_syn_fx, 0, LPC_SHB_ORDER ); - IF( sub(st_fx->extl_fx, FB_TBE) == 0 ) + IF( EQ_16(st_fx->extl_fx, FB_TBE)) { set16_fx( st_fx->fb_state_lpc_syn_fx, 0, LPC_SHB_ORDER ); st_fx->fb_tbe_demph_fx = 0; @@ -524,8 +522,8 @@ void wb_tbe_enc_fx( test(); test(); test(); - IF ( ( sub (st_fx->last_extl_fx, WB_TBE) != 0 && sub( st_fx->last_extl_fx, WB_BWE) != 0 ) - && ( sub( st_fx->clas_fx, UNVOICED_CLAS) == 0 || ( sub( voicing_fx[0], 16384 ) < 0 && sub( voicing_fx[1], 16384 ) < 0 && sub( voicing_fx[2], 16384 ) < 0 ) ) + IF ( ( NE_16 (st_fx->last_extl_fx, WB_TBE) && NE_16( st_fx->last_extl_fx, WB_BWE)) + && ( EQ_16( st_fx->clas_fx, UNVOICED_CLAS) || ( LT_16( voicing_fx[0], 16384 ) && LT_16( voicing_fx[1], 16384 ) && LT_16( voicing_fx[2], 16384 ) ) ) && st_fx->igf == 0 ) { /* In case of unvoiced signals after switching cores, back-propagate the target signal */ @@ -594,7 +592,7 @@ void wb_tbe_enc_fx( move16(); test(); - IF ( sub(st_fx->rf_mode, 1) == 0 || L_sub(st_fx->extl_brate_fx, WB_TBE_0k35) == 0 ) + IF ( EQ_16(st_fx->rf_mode, 1)||EQ_32(st_fx->extl_brate_fx,WB_TBE_0k35)) { E_LPC_lev_dur(R_h, R_l, lpc_wb, LepsP, LPC_SHB_ORDER_LBR_WB, NULL); Copy_Scale_sig( lpc_wb, lpc_wb, LPC_SHB_ORDER_LBR_WB+1, sub(norm_s(lpc_wb[0]),2) ); @@ -624,7 +622,7 @@ void wb_tbe_enc_fx( /* Quantization of LSFs */ i = closest_centroid_fx( lsp_wb, weights_lsp, lbr_wb_bwe_lsfvq_cbook_2bit_fx, 4, LPC_SHB_ORDER_LBR_WB ); - IF( sub(st_fx->codec_mode, MODE2) == 0 ) + IF( EQ_16(st_fx->codec_mode, MODE2)) { st_fx->lsf_WB_fx = i; move16(); @@ -686,7 +684,7 @@ void wb_tbe_enc_fx( /* Quantization of LSFs */ i = closest_centroid_fx( lsp_wb, weights_lsp, wb_bwe_lsfvq_cbook_8bit_fx, 256, LPC_SHB_ORDER_WB );/*move16(); */ - IF( sub(st_fx->codec_mode, MODE2) == 0 ) + IF( EQ_16(st_fx->codec_mode, MODE2)) { st_fx->lsf_WB_fx = i; move16(); @@ -717,21 +715,21 @@ void wb_tbe_enc_fx( uv_flag = 0; move16(); test(); - if( L_sub(st_fx->extl_brate_fx, WB_TBE_1k05) == 0 && sub(st_fx->coder_type_raw_fx,UNVOICED) == 0 ) + if( EQ_32(st_fx->extl_brate_fx, WB_TBE_1k05)&&EQ_16(st_fx->coder_type_raw_fx,UNVOICED)) { uv_flag = 1; move16(); } Copy( voice_factors, vf_modified_fx, NB_SUBFR16k ); - IF( sub(coder_type,VOICED) == 0 ) + IF( EQ_16(coder_type,VOICED)) { FOR( i = 1; i < NB_SUBFR; i++ ) { /*vf_modified[i] = 0.8f * voice_factors[i] + 0.2f * voice_factors[i-1];*/ vf_modified_fx[i] = add( mult_r( 26214, voice_factors[i] ), mult_r( 6553, voice_factors[i - 1] ) ); } - IF( sub(st_fx->L_frame_fx, L_FRAME) != 0 ) + IF( NE_16(st_fx->L_frame_fx, L_FRAME)) { vf_modified_fx[4] = add( mult_r( 26214, voice_factors[4] ), mult_r( 6553, voice_factors[3] ) ); } @@ -754,14 +752,14 @@ void wb_tbe_enc_fx( find_max_mem_wb_enc( st_fx, &n_mem ); - if( sub(sub( Q_bwe_exc, st_fx->prev_Q_bwe_exc ),n_mem) > 0 ) + if( GT_16(sub( Q_bwe_exc, st_fx->prev_Q_bwe_exc ),n_mem)) { Q_bwe_exc = add( st_fx->prev_Q_bwe_exc, n_mem ); } IF( uv_flag ) { - if( sub( Q_bwe_exc, 20 ) > 0 ) + if( GT_16( Q_bwe_exc, 20 )) { Q_bwe_exc = 20; move16();/* restrict this to 20 due to the Q factor requireemnt of the random number generator (keep 1 bit headroom) */ @@ -804,7 +802,7 @@ void wb_tbe_enc_fx( curr_pow = L_mac0( curr_pow, shaped_wb_excitation[i + L_SHB_LAHEAD/4], shaped_wb_excitation[i + L_SHB_LAHEAD / 4] ); /* Q(2*Q_bwe_exc_ext) */ } - IF ( sub( voice_factors[0], 24576 ) > 0 ) + IF ( GT_16( voice_factors[0], 24576 )) { curr_pow = L_shr( curr_pow, 2 ); /* Q(2*Q_bwe_exc_ext) */ } @@ -907,7 +905,7 @@ void wb_tbe_enc_fx( p2m_in = pow_off_pk_fx( GainShape, shr(NUM_SHB_SUBFR,2), 1 ); move16(); - IF( L_sub(st_fx->extl_brate_fx,WB_TBE_0k35) == 0 ) + IF( EQ_32(st_fx->extl_brate_fx,WB_TBE_0k35)) { FOR( i = 0; i < 8; i++ ) { @@ -935,7 +933,7 @@ void wb_tbe_enc_fx( /* If there's a big difference in the power of gains away from the peak gain */ /* due to poor quantization then suppress energy of the high band. */ - IF( L_sub( p2m_out, L_shl( p2m_in, 1 ) ) > 0 ) + IF( GT_32( p2m_out, L_shl( p2m_in, 1 ) )) { L_tmp = root_a_over_b_fx( L_shl( p2m_in, 1 ), 29, p2m_out, 29, &exp_out ); GainFrame = L_shl( Mult_32_32( GainFrame, L_tmp ), exp_out ); /* Q18 */ @@ -969,12 +967,12 @@ void wb_tbe_enc_fx( tmp = s_max( s_min( tmp, 32767 ), 22938 ); /* Q15 */ GainFrame = Mult_32_16( GainFrame, tmp ); /* Q18 */ - IF( sub( lsp_spacing_fx, 328 ) < 0 && lsp_spacing_fx ) + IF( LT_16( lsp_spacing_fx, 328 )&&lsp_spacing_fx) { GainFrame = Mult_32_16( GainFrame, 21299 ); /* Q18 */ } - IF( sub(st_fx->codec_mode, MODE1) == 0 ) + IF( EQ_16(st_fx->codec_mode, MODE1)) { /*wbbwe_em_factor = add( mult_r( 29491, st_fx->prev_wbbwe_em_factor_fx ), mult_r( 3277, wbbwe_em_factor ) ); */ /* Q15 */ } @@ -990,13 +988,13 @@ void wb_tbe_enc_fx( test(); test(); - IF( st_fx->igf != 0 && sub(coder_type, VOICED) == 0 ) + IF( st_fx->igf != 0 && EQ_16(coder_type, VOICED)) { /*GainFrame *= 0.5f;*/ GainFrame = Mult_32_16( GainFrame, 16384 ); } - ELSE IF( st_fx->igf != 0 && sub( avg_voice_fac, 11469 ) > 0 ) /*Q15 -> 0.35f*/ + ELSE IF( st_fx->igf != 0 && GT_16( avg_voice_fac, 11469 )) /*Q15 -> 0.35f*/ { /*GainFrame *= 0.75f;*/ GainFrame = Mult_32_16( GainFrame, 24576 ); @@ -1166,7 +1164,7 @@ void swb_tbe_enc_fx( /* Spectral smoothing of autocorrelation coefficients */ test(); - IF( (st_fx->rf_mode != 0) || L_sub( st_fx->total_brate_fx, ACELP_9k60 ) == 0 ) + IF( (st_fx->rf_mode != 0) || EQ_32( st_fx->total_brate_fx, ACELP_9k60 )) { FOR( i = 1; i <= LPC_SHB_ORDER; i++ ) { @@ -1191,7 +1189,7 @@ void swb_tbe_enc_fx( enerG = Enr_1_Az_fx(lpc_shb1, 2*L_SUBFR); /* Q3 */ /* if the LP gain is greater than a threshold, avoid saturation */ - IF(sub(enerG, 256/*32 Q3*/) > 0) + IF(GT_16(enerG, 256/*32 Q3*/)) { set16_fx(lpc_shb_fx, 0, LPC_SHB_ORDER+1); E_LPC_lev_dur(R_h, R_l, lpc_shb_fx, LepsP, 2, NULL); /* LPC in Q14 */ @@ -1203,7 +1201,7 @@ void swb_tbe_enc_fx( /* Expand bandwidth of the LP coeffs */ test(); - IF( (st_fx->rf_mode != 0) || L_sub( st_fx->total_brate_fx, ACELP_9k60 ) == 0 ) + IF( (st_fx->rf_mode != 0) || EQ_32( st_fx->total_brate_fx, ACELP_9k60 )) { FOR( i = 1; i <= LPC_SHB_ORDER; i++ ) { @@ -1227,7 +1225,7 @@ void swb_tbe_enc_fx( Copy( lsf_shb_fx, lsf_shb_orig_fx, LPC_SHB_ORDER ); test(); - IF( (sub(st_fx->rf_mode,1)==0) || L_sub( st_fx->total_brate_fx, ACELP_9k60 ) == 0 ) + IF( (EQ_16(st_fx->rf_mode,1))||EQ_32(st_fx->total_brate_fx,ACELP_9k60)) { lsp_weights_fx( lsf_shb_fx, weights_lsp, LPC_SHB_ORDER, &Q_out ); @@ -1273,7 +1271,7 @@ void swb_tbe_enc_fx( Copy( voice_factors_fx, vf_modified_fx, NB_SUBFR16k ); test(); - IF( sub(coder_type_fx, VOICED) == 0 || sub(mean_vf, 13107/*0.4f Q15*/ ) > 0 ) + IF( EQ_16(coder_type_fx, VOICED)||GT_16(mean_vf,13107/*0.4f Q15*/)) { FOR( i = 1; i < NB_SUBFR; i++ ) { @@ -1281,7 +1279,7 @@ void swb_tbe_enc_fx( vf_modified_fx[i] = mac_r(L_tmp, voice_factors_fx[i-1], 6554); move16(); } - IF( sub(st_fx->L_frame_fx, L_FRAME) != 0 ) + IF( NE_16(st_fx->L_frame_fx, L_FRAME)) { L_tmp = L_mult(voice_factors_fx[4], 26214); vf_modified_fx[4] = mac_r(L_tmp, voice_factors_fx[3], 6554); @@ -1293,7 +1291,7 @@ void swb_tbe_enc_fx( E_LPC_lsf_lsp_conversion(lsf_shb_fx, lsp_shb_2_fx, LPC_SHB_ORDER); test(); - IF( sub(st_fx->last_extl_fx, SWB_TBE) == 0 || sub(st_fx->last_extl_fx, FB_TBE) == 0) + IF( EQ_16(st_fx->last_extl_fx, SWB_TBE)||EQ_16(st_fx->last_extl_fx,FB_TBE)) { /* SHB LSP values from prev. frame for interpolation */ Copy(st_fx->swb_lsp_prev_interp_fx, lsp_shb_1_fx, LPC_SHB_ORDER); @@ -1321,7 +1319,7 @@ void swb_tbe_enc_fx( tmp2 = shr(mult(31715,tmp),2); /* Q11 */ tilt_para = add(sub(tmp1,tmp2),1335);/*Q10*/ - IF(sub(st_fx->last_extl_fx,SWB_TBE) != 0) + IF(NE_16(st_fx->last_extl_fx,SWB_TBE)) { FOR( i=1; itotal_brate_fx,ACELP_16k40) <= 0 ) + IF( LE_32(st_fx->total_brate_fx,ACELP_16k40)) { test(); test(); test(); test(); test(); - IF(!(sub(st_fx->prev_tilt_para_fx,5120) > 0 && (sub(coder_type_fx,TRANSITION) == 0 || sub(tilt_para,1024) < 0)) && - !(((sub(st_fx->prev_tilt_para_fx,3072) < 0 && sub(st_fx->prev_coder_type_fx,VOICED) >= 0)) && sub(tilt_para,5120) > 0)) + IF(!(GT_16(st_fx->prev_tilt_para_fx,5120)&&(EQ_16(coder_type_fx,TRANSITION)||LT_16(tilt_para,1024)))&& + !(((LT_16(st_fx->prev_tilt_para_fx,3072) && GE_16(st_fx->prev_coder_type_fx,VOICED) )) && GT_16(tilt_para,5120) )) { FOR( i = 1; i < LPC_SHB_ORDER-1; i++ ) { - IF(sub(lsf_diff[i],st_fx->prev_lsf_diff_fx[i-1]) < 0) + IF(LT_16(lsf_diff[i],st_fx->prev_lsf_diff_fx[i-1])) { tmp = mult(26214,lsf_diff[i]); tmp = div_s(tmp,st_fx->prev_lsf_diff_fx[i-1]); @@ -1378,7 +1376,7 @@ void swb_tbe_enc_fx( shb_ener_sf_Q31 = 0; move16(); test(); - IF ( L_sub(st_fx->total_brate_fx, ACELP_24k40 ) == 0 || L_sub( st_fx->total_brate_fx, ACELP_32k) == 0 ) + IF ( EQ_32(st_fx->total_brate_fx, ACELP_24k40 )||EQ_32(st_fx->total_brate_fx,ACELP_32k)) { /* ---------- SHB LSP interpolation ---------- */ ptr_lsp_interp_coef_fx = interpol_frac_shb; /* Q15 */ @@ -1481,7 +1479,7 @@ void swb_tbe_enc_fx( find_max_mem_enc( st_fx, &n_mem, &n_mem2); tmp2 = add( st_fx->prev_Q_bwe_exc, n_mem ); - if( sub( Q_bwe_exc, tmp2) > 0 ) + if( GT_16( Q_bwe_exc, tmp2)) { Q_bwe_exc = tmp2; } @@ -1531,7 +1529,7 @@ void swb_tbe_enc_fx( &(st_fx->fb_tbe_demph_fx), &Q_bwe_exc,&Q_bwe_exc_fb, Q_shb, n_mem2, st_fx->prev_Q_bwe_syn, st_fx->total_brate_fx, 0 ); *Q_white_exc = Q_bwe_exc_fb; - IF( sub(st_fx->extl_fx, FB_TBE) == 0 ) + IF( EQ_16(st_fx->extl_fx, FB_TBE)) { st_fx->prev_Q_bwe_exc_fb = Q_bwe_exc_fb; } @@ -1544,9 +1542,9 @@ void swb_tbe_enc_fx( } test(); - IF( L_sub(st_fx->total_brate_fx, ACELP_24k40) == 0 || L_sub(st_fx->total_brate_fx, ACELP_32k) == 0 ) + IF( EQ_32(st_fx->total_brate_fx, ACELP_24k40)||EQ_32(st_fx->total_brate_fx,ACELP_32k)) { - IF( sub( st_fx->codec_mode, MODE2 ) == 0 ) + IF( EQ_16( st_fx->codec_mode, MODE2 )) { st_fx->idx_mixFac_fx = vf_ind_fx; move16(); @@ -1582,7 +1580,7 @@ void swb_tbe_enc_fx( curr_pow_fx = L_mac0( curr_pow_fx, shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10], shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10] ); /* 2*Q_bwe_exc */ } - if( sub( voice_factors_fx[0], 24576/*0.75f Q15*/ ) > 0 ) + if( GT_16( voice_factors_fx[0], 24576/*0.75f Q15*/ )) { /*curr_pow_fx = Mult_32_16( curr_pow_fx, 8192);*/ /* Q(2*Q_bwe_exc) */ curr_pow_fx = L_shr(curr_pow_fx, 2); /* scale by 0.25 */ @@ -1623,7 +1621,7 @@ void swb_tbe_enc_fx( Q_bwe_exc, GainShape_fx, subwin_shb_fx, &n_subfr_saturation ); /* Gain shape BWS/high band low energy fix */ - IF( sub(st_fx->cldfbHBLT, 8192/*1.0f Q13*/) < 0 ) /* cldfbHBLT in Q13 */ + IF( LT_16(st_fx->cldfbHBLT, 8192/*1.0f Q13*/)) /* cldfbHBLT in Q13 */ { /* There is not much HB past 10kHz; the temporal resolution is quite coarse, so reduce the dynamic range */ FOR(i = 0; i < NUM_SHB_SUBGAINS; i++) @@ -1715,7 +1713,7 @@ void swb_tbe_enc_fx( test(); test(); - IF( sub(frGainAttenuate,1) == 0 || ( sub( tmp, 19661 ) > 0 && sub( tmp1, 6554 ) > 0 ) ) + IF( EQ_16(frGainAttenuate,1)||(GT_16(tmp,19661)&>_16(tmp1,6554))) { temp_swb_fac = st_fx->prev_swb_GainShape_fx; @@ -1744,26 +1742,26 @@ void swb_tbe_enc_fx( EstimateSHBFrameGain_fx( SHB_OVERLAP_LEN, shb_frame_fx, Q_shb, shaped_shb_excitation_fx, Q_bwe_exc, GainShape_fx, &GainFrame_fx, window_shb_fx, subwin_shb_fx, n_subfr_saturation ); - IF( sub(st_fx->tec_tfa, 1) == 0 ) + IF( EQ_16(st_fx->tec_tfa, 1)) { tfaCalcEnv_fx( shb_frame_fx, st_fx->tfa_enr ); } /* If there's a big difference in the power of gains away from the peak gain */ /* due to poor quantization then suppress energy of the high band. */ - IF( L_sub( p2m_out_fx, L_shl( p2m_in_fx, 1 ) ) > 0 ) + IF( GT_32( p2m_out_fx, L_shl( p2m_in_fx, 1 ) )) { L_tmp = root_a_over_b_fx( p2m_in_fx, 28, p2m_out_fx, 29, &exp_out ); GainFrame_fx = L_shl( Mult_32_32( GainFrame_fx, L_tmp ), exp_out ); /* Q18 */ } test(); - IF( sub(frGainSmoothEn,1) == 0 && L_sub( st_fx->prev_gainFr_SHB_fx, GainFrame_fx ) < 0 ) + IF( EQ_16(frGainSmoothEn,1)&<_32(st_fx->prev_gainFr_SHB_fx,GainFrame_fx)) { GainFrame_fx = L_add( L_shr(st_fx->prev_gainFr_SHB_fx, 1), L_shr(GainFrame_fx, 1) ); /* Q18 */ } test(); - IF( sub(frGainAttenuate, 1) == 0 && sub( MA_lsp_shb_spacing, 79/*0.0024f Q15*/ ) <= 0 ) + IF( EQ_16(frGainAttenuate, 1)&&LE_16(MA_lsp_shb_spacing,79/*0.0024f Q15*/)) { exp1 = norm_l( GainFrame_fx ); frac = Log2_norm_lc( L_shl( GainFrame_fx, exp1 ) ); @@ -1774,7 +1772,7 @@ void swb_tbe_enc_fx( exp = sub( exp, 30); GainFrame_fx = L_shl( GainFrame_fx, exp + 18 ); /* Q18 */ } - ELSE IF( sub(st_fx->prev_frGainAtten_fx, 1) == 0 && L_sub( Mult_32_16( GainFrame_fx, 10923 ), st_fx->prev_gainFr_SHB_fx ) > 0 ) + ELSE IF( EQ_16(st_fx->prev_frGainAtten_fx, 1)&>_32(Mult_32_16(GainFrame_fx,10923),st_fx->prev_gainFr_SHB_fx)) { /*GainFrame *= (0.8f + 0.5f*feedback); */ tmp = add( 26214, mult_r( feedback, 16384 ) ); @@ -1788,7 +1786,7 @@ void swb_tbe_enc_fx( /* Gain attenuation when the SWB LSF quantization error is larger than a threshold */ tmp = mult_r(25600/*400 Q6*/, sd_uq_q_fx); /* Q6 * Q15 => Q6 */ - IF(sub(st_fx->L_frame_fx, L_FRAME) == 0) + IF(EQ_16(st_fx->L_frame_fx, L_FRAME)) { tmp1 = mult_r(6554/*0.2f Q15*/, tmp); /* Q15, Q6 => Q6 */ L_tmp = L_msu(8192l/*1.0f Q13*/, tmp1, tmp); /* Q13 */ @@ -1812,7 +1810,7 @@ void swb_tbe_enc_fx( /* voicingBufAvg = (sum_f(voice_factors, 4)=sum2 > 0.6f) ? 0.333f : 0.1667f; */ tmp2 = 5462/*0.1667f Q15*/; - if(sub(sum2, 4915/*0.6f Q13*/) > 0) + if(GT_16(sum2, 4915/*0.6f Q13*/)) { tmp2 = 10912/*0.333f Q15*/; /* Q15 */ } @@ -1842,7 +1840,7 @@ void swb_tbe_enc_fx( GainFrame_fx = Mult_32_16(GainFrame_fx, tmp); /* Q18 + Q15 + 1 - 16 : Q18 */ test(); - IF(sub(st_fx->L_frame_fx, L_FRAME16k) == 0 || sub(st_fx->rf_mode,1) == 0) + IF(EQ_16(st_fx->L_frame_fx, L_FRAME16k)||EQ_16(st_fx->rf_mode,1)) { /* Compensate for energy increase mismatch due to memory-less synthesis*/ GainFrame_fx = Mult_32_16(GainFrame_fx, 27853/*0.85f Q15*/ ); /* Q18 */ @@ -1853,7 +1851,7 @@ void swb_tbe_enc_fx( /* Adjust the subframe and frame gain of the synthesized SHB signal */ /* Scale the shaped excitation */ - IF( L_sub(st_fx->extl_fx,FB_TBE) == 0 ) + IF( EQ_32(st_fx->extl_fx,FB_TBE)) { tmp = norm_l( GainFrame_fx ); if(GainFrame_fx == 0) @@ -1957,7 +1955,7 @@ static void EstimateSHBFrameGain_fx( skip = skip_bands_SWB_TBE; - IF( sub(length,SHB_OVERLAP_LEN / 2) == 0 ) + IF( EQ_16(length,SHB_OVERLAP_LEN / 2)) { skip = skip_bands_WB_TBE; l_frame = L_FRAME16k / 4; @@ -1970,7 +1968,7 @@ static void EstimateSHBFrameGain_fx( set32_fx( mod_syn, 0, l_frame + l_shb_lahead ); - IF( sub(length,SHB_OVERLAP_LEN / 2 ) == 0) + IF( EQ_16(length,SHB_OVERLAP_LEN / 2 )) { sum_gain = 0; move16(); @@ -2082,7 +2080,7 @@ static void EstimateSHBFrameGain_fx( sig = round_fx( Mult_32_16( mod_syn[i], win_shb[l_frame + l_shb_lahead - 1 - i] ) ); /* Q_oriSHB */ synNrg = L_mac0( synNrg, sig, sig ); /* 2*Q_oriSHB */ } - IF(L_sub(oriNrg, MAX_32) == 0) + IF(EQ_32(oriNrg, MAX_32)) { scaling = negate(shr(n_subfr_saturation, 1) + 1); move16(); @@ -2127,7 +2125,7 @@ static Word32 pow_off_pk_fx( Word16 a[], Word16 len, Word16 step ) { L_tmp = L_shr( L_mult0( a[i], a[i] ), 1 ); /* Q29 */ sum = L_add( sum, L_tmp ); /* Q29 */ - if( sub( a[i], a[j] ) > 0 ) + if( GT_16( a[i], a[j] )) { j = i; move16(); @@ -2194,7 +2192,7 @@ static void EstimateSHBGainShape_fx( move16(); skip = skip_bands_SWB_TBE; - IF( sub(length,SHB_OVERLAP_LEN / 2) == 0 ) + IF( EQ_16(length,SHB_OVERLAP_LEN / 2)) { num_gains = NUM_SHB_SUBFR / 4; move16(); @@ -2207,7 +2205,7 @@ static void EstimateSHBGainShape_fx( synNrg = 0; move16(); - IF( sub(length,SHB_OVERLAP_LEN / 2) == 0 ) + IF( EQ_16(length,SHB_OVERLAP_LEN / 2)) { FOR( i = 0; i < NUM_SHB_SUBFR / 2; i++ ) { @@ -2276,13 +2274,13 @@ static void EstimateSHBGainShape_fx( } logic16(); - IF( sub(( i & 0x1 ),1) == 0 ) + IF( EQ_16(( i & 0x1 ),1)) { L_subgain[i / 2] = root_a_over_b_fx( oriNrg, 2 * Q_oriSHB, synNrg, 2 * Q_synSHB, &n ); move16(); /* Q(31-n) */ norm[i / 2] = n; move16(); - IF( sub(norm[i / 2],n_max) > 0 ) + IF( GT_16(norm[i / 2],n_max)) { n_max = norm[i / 2]; move16(); @@ -2331,7 +2329,7 @@ static void EstimateSHBGainShape_fx( /* Only implemented in SWB because the length of samples in SWB frame is longer, more likely to saturate */ scaling = 0; move16(); - IF(L_sub(oriNrg, MAX_32) == 0) + IF(EQ_32(oriNrg, MAX_32)) { if(n_subfr_saturation != NULL) { @@ -2362,7 +2360,7 @@ static void EstimateSHBGainShape_fx( n = sub(n, scaling); norm[i] = n; move16(); - IF( sub(norm[i],n_max) > 0 ) + IF( GT_16(norm[i],n_max)) { n_max = norm[i]; move16(); @@ -2423,32 +2421,33 @@ static Word16 closest_centroid_fx( { Word16 i, j, index; Word16 tmp, tmpL; - Word32 werr, best_werr; - Word32 L_tmp; + Word64 werr_64; + Word32 L_tmp, werr, best_werr; index = 0; move16(); - best_werr = L_add(MAX_32, 0); - + best_werr = MAX_32; + move32(); + FOR( i = 0; i < centroids; i++ ) { - werr = L_deposit_l(0); + werr_64 = 0; + move64(); tmpL = i_mult2(i, length); FOR( j = 0; j < length; j++ ) { tmp = sub( data[j], quantizer[tmpL + j] ); L_tmp = L_mult( tmp, tmp ); - werr = Madd_32_16( werr, L_tmp, weights[j] ); - } - if( L_sub( werr, best_werr ) < 0 ) + werr_64 = W_mac_32_16( werr_64, L_tmp, weights[j] ); + } + werr = W_sat_m( werr_64); + if( LT_32( werr, best_werr) ) { index = i; move16(); - } - best_werr = L_min(best_werr, werr); - + } + best_werr = L_min( best_werr, werr ); } - return index; } @@ -2492,7 +2491,7 @@ static Word16 closest_centroid_lc_fx( tmp = sub( data[3], quantizer[tmpL + 3] ); werr = L_mac(werr, tmp, tmp); - if( L_sub( werr, best_werr ) < 0 ) + if( LT_32( werr, best_werr )) { index = i; move16(); @@ -2532,12 +2531,12 @@ static void QuantizeSHBsubgains_fx( Word16 exp, frac; Word32 L_tmp; - IF( sub(extl, WB_TBE) == 0 ) + IF( EQ_16(extl, WB_TBE)) { set16_fx( Unit_weights10, 32767, ( Word16 )NUM_SHB_SUBFR / 4 ); FOR( i = 0; i < NUM_SHB_SUBFR / 4; i++ ) { - IF( subgains[i] == 0 ) + IF( EQ_16(subgains[i] ,0) ) { subgains[i + NUM_SHB_SUBFR / 4] = -18432; move16(); /* (-72) in Q8 */ @@ -2581,7 +2580,7 @@ static void QuantizeSHBsubgains_fx( { FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ ) { - IF( subgains[i] == 0 ) + IF( EQ_16(subgains[i] ,0) ) { subgains[i] = -12288; move16(); /* (-3) in Q12 */ @@ -2622,7 +2621,7 @@ static void QuantizeSHBsubgains_fx( st_fx->idxSubGains_fx = idxSubGain; move16(); - IF( sub( st_fx->codec_mode, MODE2 ) != 0 ) + IF( NE_16( st_fx->codec_mode, MODE2 )) { push_indice_fx( st_fx, IND_SHB_SUBGAIN, idxSubGain, NUM_BITS_SHB_SUBGAINS ); } @@ -2677,7 +2676,7 @@ static void Quant_shb_ener_sf_fx( st_fx->idx_shb_fr_gain_fx = idxSubEner_fx; move16(); - IF( sub( st_fx->codec_mode, MODE2 ) != 0 ) + IF( NE_16( st_fx->codec_mode, MODE2 )) { push_indice_fx( st_fx, IND_SHB_ENER_SF, idxSubEner_fx, NUM_BITS_SHB_ENER_SF); } @@ -2707,7 +2706,7 @@ static void Quant_shb_res_gshape_fx( shl(1,NUM_BITS_SHB_RES_GS)); st_fx->idx_res_gs_fx[i] = idxSubGain_fx[i]; - IF ( sub( st_fx->codec_mode, MODE2 ) != 0 ) + IF ( NE_16( st_fx->codec_mode, MODE2 )) { push_indice_fx( st_fx, IND_SHB_RES_GS1+i, idxSubGain_fx[i], NUM_BITS_SHB_RES_GS); } @@ -2748,16 +2747,16 @@ static void QuantizeSHBframegain_fx( Word32 L_tmp; Word32 GainFrameLog; - IF( sub(extl, WB_TBE) == 0 ) + IF( EQ_16(extl, WB_TBE)) { determine_gain_weights_fx( GainFrame, &( Unit_weights1 ), 1 ); - IF( L_sub(extl_brate,WB_TBE_0k35) == 0 ) + IF( EQ_32(extl_brate,WB_TBE_0k35)) { singlevectortest_gain_fx( GainFrame, 1, 1 << NUM_BITS_SHB_FrameGain_LBR_WB, &idxFrameGain, &Q_GainFrame, SHBCB_FrameGain16_fx ); test(); - IF( L_sub( Q_GainFrame, L_shl( Mult_32_16( *GainFrame, 17367 ), 1 ) ) > 0 && idxFrameGain > 0 ) /* 1.06 = +0.5 dB */ + IF( GT_32( Q_GainFrame, L_shl( Mult_32_16( *GainFrame, 17367 ), 1 ) )&&idxFrameGain>0) /* 1.06 = +0.5 dB */ { idxFrameGain--; Q_GainFrame = L_add(SHBCB_FrameGain16_fx[idxFrameGain], 0); /* Q18 */ @@ -2797,7 +2796,7 @@ static void QuantizeSHBframegain_fx( tmp = div_s( shl(1, sub(14, exp)), SHB_GAIN_QDELTA_FX_15 ); L_tmp = Mult_32_16( L_sub( GainFrameLog, SHB_GAIN_QLOW_FX_16 ), tmp ); idxFrameGain = extract_l( L_shr( L_add( L_tmp, shl(1, sub(14, exp)) ), sub(15, exp) ) ); /*Q0*/ - IF( sub( idxFrameGain, ( 1 << NUM_BITS_SHB_FRAMEGAIN ) - 1 ) > 0 ) + IF( GT_16( idxFrameGain, ( 1 << NUM_BITS_SHB_FRAMEGAIN ) - 1 )) { idxFrameGain = sub( ( 1 << NUM_BITS_SHB_FRAMEGAIN ), 1 ); } @@ -2813,7 +2812,7 @@ static void QuantizeSHBframegain_fx( L_tmp = SHB_GAIN_QLOW_FX_16; Q_GainFrame = L_mac( L_tmp, idxFrameGain, SHB_GAIN_QDELTA_FX_15 ); - WHILE( L_sub( Q_GainFrame, L_add( GainFrameLog, 4866 ) ) > 0 && + WHILE( GT_32( Q_GainFrame, L_add( GainFrameLog, 4866 ) )&& idxFrameGain != 0 ) { idxFrameGain = sub(idxFrameGain, 1); @@ -2831,17 +2830,17 @@ static void QuantizeSHBframegain_fx( st_fx->idxFrameGain_fx = idxFrameGain; move16(); - IF ( sub( st_fx->codec_mode, MODE2 ) != 0 ) + IF ( NE_16( st_fx->codec_mode, MODE2 )) { push_indice_fx( st_fx, IND_SHB_FRAMEGAIN, idxFrameGain, NUM_BITS_SHB_FRAMEGAIN ); } *rf_gainFrame_ind = idxFrameGain; } - IF( sub(st_fx->rf_mode,1)==0) + IF( EQ_16(st_fx->rf_mode,1)) { /*Currently intended for SWB only. Modify for WB is needed later!*/ - IF( sub(st_fx->rf_frame_type,RF_NELP) == 0) + IF( EQ_16(st_fx->rf_frame_type,RF_NELP)) { *rf_gainFrame_ind = idxFrameGain; /* NELP Frame uses full 5 bits */ } @@ -2894,7 +2893,7 @@ static void determine_gain_weights_fx ( FOR( j = 0; j < dims; j++ ) { - IF( L_sub(gain[j],8) > 0 )/* 8 = 0.001 in Q13 */ + IF( GT_32(gain[j],8))/* 8 = 0.001 in Q13 */ { /*weights[j] = (float)(pow (fabs (gain[j]), -0.9f)); = pow(2,(-0.9)*log2(gain[j])) */ exp1 = norm_l( gain[j] ); @@ -2907,7 +2906,7 @@ static void determine_gain_weights_fx ( tmp = extract_l( Pow2( 14, frac ) ); /* Q14 */ exp2 = sub(exp,8); - if( sub(exp1,21) <= 0 ) + if( LE_16(exp1,21)) { exp2 = sub(exp,2); } @@ -2981,7 +2980,7 @@ static void singlevectortest_gain_fx ( IF( flag == 0 ) { meanQ = sum32_fx( codebook + dimen * least[k], dimen ); /* Q18 */ - IF( L_sub( meanQ, L_tmp ) <= 0 ) + IF( LE_32( meanQ, L_tmp )) { flag = 1; move16(); @@ -3062,7 +3061,7 @@ static void return_M_Least_fx_GainFrame( distance[i] = Mult_32_32( diff[i], diff[i] ); move32(); - if( L_sub( distance[i], mindist ) < 0 ) + if( LT_32( distance[i], mindist )) { least[0] = i; move16(); @@ -3078,7 +3077,7 @@ static void return_M_Least_fx_GainFrame( mindist = L_add(MAX_32, 0); FOR( i = 0; i < num_grp; i++ ) { - if( L_sub( distance[i], mindist ) < 0 ) + if( LT_32( distance[i], mindist )) { least[k] = i; move16(); @@ -3181,7 +3180,7 @@ static Word16 Find_LSF_grid_fx( move16(); - IF( sub( m, MAX_LSF_FX_2 ) > 0 ) + IF( GT_16( m, MAX_LSF_FX_2 )) { offset = lsf_map[0]; move16(); @@ -3229,7 +3228,7 @@ static Word16 Find_LSF_grid_fx( /* D += (lsf_t[j] - lsf[NUM_Q_LSF + j])*(lsf_t[j] - lsf[NUM_Q_LSF + j]); */ } - IF( L_sub( D, D_best ) < 0 ) + IF( LT_32( D, D_best )) { Copy( lsf_t, lsf_smooth, NUM_MAP_LSF ); D_best = L_add(D, 0); @@ -3315,9 +3314,9 @@ static void gainFrSmooth_En_fx(Encoder_State_fx *st_fx, test(); test(); - IF( sub( st_fx->last_extl_fx, SWB_TBE ) != 0 - && sub(st_fx->last_extl_fx, FB_TBE) != 0 - && sub( lsp_spacing, 262 ) < 0 ) + IF( NE_16( st_fx->last_extl_fx, SWB_TBE ) + && NE_16(st_fx->last_extl_fx, FB_TBE) + && LT_16( lsp_spacing, 262 ) ) { st_fx->lsp_shb_spacing_fx[0] = lsp_spacing; move16(); @@ -3346,13 +3345,13 @@ static void gainFrSmooth_En_fx(Encoder_State_fx *st_fx, test(); test(); test(); - IF( ( sub( lsp_spacing, 262 ) < 0 && ( sub( *MA_lsp_shb_spacing, 164 ) < 0 || sub(st_fx->prev_frGainAtten_fx, 1) == 0 ) ) - || sub( lsp_spacing, 105 ) <= 0 ) + IF( ( LT_16( lsp_spacing, 262 )&&(LT_16(*MA_lsp_shb_spacing,164)||EQ_16(st_fx->prev_frGainAtten_fx,1))) + || LE_16( lsp_spacing, 105 ) ) { *frGainAttenuate = 1; move16(); - IF( L_sub(st_fx->total_brate_fx , ACELP_24k40) != 0 ) + IF( NE_32(st_fx->total_brate_fx , ACELP_24k40)) { Copy( shb_frame_fx, temp_shb_frame, L_FRAME16k + L_SHB_LAHEAD ); fir_fx( temp_shb_frame, lpc_shb_fx, shb_frame_fx, st_fx->shb_inv_filt_mem_fx, L_FRAME16k + L_SHB_LAHEAD, LPC_SHB_ORDER, 1,3); @@ -3363,7 +3362,7 @@ static void gainFrSmooth_En_fx(Encoder_State_fx *st_fx, } test(); - IF ( L_sub( lsp_slow_evol_rate, 2147484l/*0.001f Q31*/ ) < 0 && L_sub( lsp_fast_evol_rate, 2147484l/*0.001f Q31*/ ) < 0 ) + IF ( LT_32( lsp_slow_evol_rate, 2147484l/*0.001f Q31*/ )&<_32(lsp_fast_evol_rate,2147484l/*0.001f Q31*/)) { *frGainSmoothEn = 1; move16(); @@ -3407,7 +3406,7 @@ static void Quant_BWE_LSF_fx( { st_fx->lsf_idx_fx[i] = lsf_idx[i]; move16(); - IF( sub( st_fx->codec_mode, MODE2 ) != 0 ) + IF( NE_16( st_fx->codec_mode, MODE2 )) { push_indice_fx( st_fx, IND_SHB_LSF, lsf_idx[i], lsf_q_num_bits[i] ); } @@ -3417,7 +3416,7 @@ static void Quant_BWE_LSF_fx( st_fx->m_idx_fx = m_idx; move16(); - IF( sub( st_fx->codec_mode, MODE2 ) != 0 ) + IF( NE_16( st_fx->codec_mode, MODE2 )) { push_indice_fx( st_fx, IND_SHB_MIRROR, m_idx, MIRROR_POINT_BITS ); } @@ -3425,7 +3424,7 @@ static void Quant_BWE_LSF_fx( grid_idx = Find_LSF_grid_fx( lsf, lsf_q, m ); st_fx->grid_idx_fx = grid_idx; - IF( sub( st_fx->codec_mode, MODE2 ) != 0 ) + IF( NE_16( st_fx->codec_mode, MODE2 )) { push_indice_fx( st_fx, IND_SHB_GRID, grid_idx, NUM_LSF_GRID_BITS ); } @@ -3479,7 +3478,7 @@ void fb_tbe_enc_fx( elliptic_bpf_48k_generic_fx( input_fhb, &exp_temp , tmp_vec, st->elliptic_bpf_2_48k_mem_fx, st->elliptic_bpf_2_48k_mem_fx_Q,full_band_bpf_2_fx ); Sample_Delay_HP = NS2SA(48000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS) - L_FRAME48k/2 ; - IF( sub(st->last_extl_fx,FB_TBE) != 0 ) + IF( NE_16(st->last_extl_fx,FB_TBE)) { set16_fx( st->old_input_fhb_fx, 0, Sample_Delay_HP ); st->old_input_fhb_fx_Q = 0; @@ -3509,7 +3508,7 @@ void fb_tbe_enc_fx( exp2 = sub(sub(31,tmp1), exp2); /* in Q15 (L_tmp in Q6)*/ exp = sub(exp2, exp); /* Denormalize and substract */ - IF (sub(tmp2, tmp) > 0) + IF (GT_16(tmp2, tmp)) { tmp2 = shr(tmp2, 1); exp = add(exp, 1); @@ -3529,7 +3528,7 @@ void fb_tbe_enc_fx( /* idxGain = (short)( log2_f ((float)ratio) + 0.5f ); idxGain = max( 0, min(15,idxGain) ); */ ratio = 0; - IF(L_sub(L_tmp,32768) >= 0) + IF(GE_32(L_tmp,32768)) { idxGain = 15; } @@ -3540,7 +3539,7 @@ void fb_tbe_enc_fx( idxGain = sub(14, exp_norm); idxGain = s_max(0,idxGain); } - IF(sub(idxGain,2) > 0 && sub(idxGain,15) < 0 && sub(ratio,add(shl(2,sub(idxGain,1)),shl(2,sub(idxGain,2)))) > 0) + IF(GT_16(idxGain,2)&<_16(idxGain,15)&>_16(ratio,add(shl(2,sub(idxGain,1)),shl(2,sub(idxGain,2))))) { idxGain = add(idxGain,1); } @@ -3568,7 +3567,7 @@ void tbe_write_bitstream_fx( test(); test(); test(); - IF ( ( st_fx->rf_mode || L_sub( st_fx->total_brate_fx, ACELP_9k60 ) == 0 ) && ( sub( st_fx->bwidth_fx, WB ) == 0 ) ) + IF ( ( st_fx->rf_mode || EQ_32( st_fx->total_brate_fx, ACELP_9k60 ))&&(EQ_16(st_fx->bwidth_fx,WB))) { /* WB LSF */ push_next_indice_fx( st_fx, st_fx->lsf_WB_fx, NUM_BITS_LBR_WB_LSF ); @@ -3576,13 +3575,13 @@ void tbe_write_bitstream_fx( /* WB frame */ push_next_indice_fx( st_fx, st_fx->gFrame_WB_fx, NUM_BITS_SHB_FrameGain_LBR_WB ); } - ELSE IF ( ( L_sub( st_fx->total_brate_fx, ACELP_9k60 ) >= 0 ) && ( L_sub( st_fx->total_brate_fx, ACELP_32k ) <= 0 ) && - ( ( sub( st_fx->bwidth_fx, SWB ) == 0 ) || ( sub( st_fx->bwidth_fx, FB ) == 0 ) ) ) + ELSE IF ( ( GE_32( st_fx->total_brate_fx, ACELP_9k60 ))&&(LE_32(st_fx->total_brate_fx,ACELP_32k))&& + ( ( EQ_16( st_fx->bwidth_fx, SWB ) ) || ( EQ_16( st_fx->bwidth_fx, FB ) ) ) ) { /* LSF coefficients */ test(); - IF( (sub(st_fx->rf_mode,1)==0) || L_sub( st_fx->total_brate_fx, ACELP_9k60 ) == 0 ) + IF( (EQ_16(st_fx->rf_mode,1))||EQ_32(st_fx->total_brate_fx,ACELP_9k60)) { push_next_indice_fx( st_fx, st_fx->lsf_idx_fx[0], 8 ); } @@ -3606,7 +3605,7 @@ void tbe_write_bitstream_fx( /* frame gain */ push_next_indice_fx( st_fx, st_fx->idxFrameGain_fx, NUM_BITS_SHB_FRAMEGAIN ); - IF ( L_sub( st_fx->total_brate_fx, ACELP_24k40 ) >= 0 ) + IF ( GE_32( st_fx->total_brate_fx, ACELP_24k40 )) { /* sub frame energy*/ push_next_indice_fx( st_fx, st_fx->idx_shb_fr_gain_fx, NUM_BITS_SHB_ENER_SF ); @@ -3621,14 +3620,14 @@ void tbe_write_bitstream_fx( push_next_indice_fx( st_fx, st_fx->idx_mixFac_fx, NUM_BITS_SHB_VF ); } - IF( sub(st_fx->tec_tfa, 1) == 0 ) + IF( EQ_16(st_fx->tec_tfa, 1)) { push_next_indice_fx( st_fx, st_fx->tec_flag, BITS_TEC ); push_next_indice_fx( st_fx, st_fx->tfa_flag, BITS_TFA ); } } - IF ( sub( st_fx->bwidth_fx, FB ) == 0 ) + IF ( EQ_16( st_fx->bwidth_fx, FB )) { push_next_indice_fx( st_fx, st_fx->idxGain_fx, 4 ); } @@ -3640,7 +3639,7 @@ void TBEreset_enc_fx( Word16 bandwidth /* i : bandwidth mode */ ) { - IF( sub(st_fx->last_core_fx,ACELP_CORE) != 0 ) + IF( NE_16(st_fx->last_core_fx,ACELP_CORE)) { set16_fx( st_fx->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); st_fx->bwe_non_lin_prev_scale_fx = L_deposit_l(0); @@ -3649,7 +3648,7 @@ void TBEreset_enc_fx( } test(); - IF( sub( bandwidth, WB ) == 0 ) + IF( EQ_16( bandwidth, WB )) { wb_tbe_extras_reset_fx( st_fx->mem_genSHBexc_filt_down_wb2_fx, st_fx->mem_genSHBexc_filt_down_wb3_fx ); set16_fx( st_fx->mem_genSHBexc_filt_down_shb_fx, 0, 7 ); @@ -3658,7 +3657,7 @@ void TBEreset_enc_fx( set16_fx( st_fx->syn_overlap_fx, 0, L_SHB_LAHEAD ); set32_fx( st_fx->mem_csfilt_fx, 0, 2 ); } - ELSE IF( ( sub( bandwidth, SWB ) == 0 ) || ( sub( bandwidth, FB ) == 0 ) ) + ELSE IF( ( EQ_16( bandwidth, SWB ))||(EQ_16(bandwidth,FB))) { set16_fx( st_fx->state_ana_filt_shb_fx, 0, (2*ALLPASSSECTIONS_STEEP+1) ); @@ -3666,7 +3665,7 @@ void TBEreset_enc_fx( st_fx->syn_overlap_fx, st_fx->state_syn_shbexc_fx, &(st_fx->tbe_demph_fx), &(st_fx->tbe_premph_fx), st_fx->mem_stp_swb_fx, &(st_fx->gain_prec_swb_fx) ); - IF( sub( bandwidth, FB ) == 0 ) + IF( EQ_16( bandwidth, FB )) { set16_fx( st_fx->fb_state_lpc_syn_fx, 0, LPC_SHB_ORDER ); st_fx->fb_tbe_demph_fx = 0; diff --git a/lib_enc/tcq_core_enc_fx.c b/lib_enc/tcq_core_enc_fx.c index a6bff7e59265f579a020c3caa092b6a625e9059d..c2671a6e535137f5b6cf4b135601e7ad963118bb 100644 --- a/lib_enc/tcq_core_enc_fx.c +++ b/lib_enc/tcq_core_enc_fx.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include #include "options.h" /* Compilation switches */ #include "prot_fx.h" #include "stl.h" -#include "wmc_auto.h" - void tcq_core_LR_enc_fx( Encoder_State_fx* st_fx, @@ -104,7 +102,7 @@ void tcq_core_LR_enc_fx( /* Bits distribution analysis */ FOR ( i = 0; i < BANDS; i++ ) { - IF ( L_sub(ar_div(R_fx[i], sfmsize[i]), 49152) >= 0 ) + IF ( GE_32(ar_div(R_fx[i], sfmsize[i]), 49152)) { /* USQ used for high importance bands*/ USQ_TCQ[i] = 1; @@ -170,7 +168,7 @@ void tcq_core_LR_enc_fx( test(); test(); - IF ( sub(input_frame, L_FRAME16k) <= 0 && adjustFlag == 0 && is_transient == 0 ) + IF ( LE_16(input_frame, L_FRAME16k)&&adjustFlag==0&&is_transient==0) { surplus_fx = -131072; move32(); @@ -180,7 +178,7 @@ void tcq_core_LR_enc_fx( move16(); FOR ( j = 0; j < BANDS; j++ ) { - IF( sub(j, k_num[0]) != 0 && sub(j, k_num[1]) != 0) + IF( NE_16(j, k_num[0])&&NE_16(j,k_num[1])) { leftbits = L_add( leftbits, R_fx[k_sort[j]]); if( R_fx[k_sort[j]] > 0 ) @@ -198,7 +196,7 @@ void tcq_core_LR_enc_fx( FOR ( k = 0; k < BANDS; k++) /* Loop through non-zero blocks */ { test(); - IF ( sub(k, k_num[0]) != 0 && sub(k, k_num[1]) != 0) + IF ( NE_16(k, k_num[0])&&NE_16(k,k_num[1])) { test(); test(); @@ -225,7 +223,7 @@ void tcq_core_LR_enc_fx( nzbands--; } /* Have USQ coded band */ - ELSE IF( R_fx[k_sort[k]] > 0 && sub(USQ_TCQ[k_sort[k]], 1) == 0 ) + ELSE IF( R_fx[k_sort[k]] > 0 && EQ_16(USQ_TCQ[k_sort[k]], 1)) { size = sfmsize[k_sort[k]]; move16(); @@ -284,7 +282,7 @@ void tcq_core_LR_enc_fx( test(); test(); test(); - IF (( L_sub(surplus_fx,524288) > 0 && sub(input_frame,L_FRAME8k) == 0 ) || ( L_sub(surplus_fx,786432) > 0 && sub(input_frame,L_FRAME16k) == 0 )) + IF (( GT_32(surplus_fx,524288)&&EQ_16(input_frame,L_FRAME8k))||(GT_32(surplus_fx,786432)&&EQ_16(input_frame,L_FRAME16k))) { bit_surplus_fx[0] = Mult_32_16(surplus_fx,24576); /* Q16 */ bit_surplus_fx[1] = Mult_32_16(surplus_fx,8192); /* Q16 */ @@ -300,7 +298,7 @@ void tcq_core_LR_enc_fx( { FOR ( j = 0; j < 2; j++ ) { - IF ( sub(k, k_num[j]) == 0 ) + IF ( EQ_16(k, k_num[j])) { R_fx[k_sort[k]] = L_add(R_fx[k_sort[k]],bit_surplus_fx[j]); @@ -325,7 +323,7 @@ void tcq_core_LR_enc_fx( encode_signs_fx( parenc_fx, &coefs_norm_dec_fx[ sfm_start[ k_sort[k]]], size, nzp_fx, &est_frame_bits_fx ); } /* Have USQ coded band */ - ELSE IF( R_fx[k_sort[k]] > 0 && sub(USQ_TCQ[k_sort[k]], 1) == 0 ) + ELSE IF( R_fx[k_sort[k]] > 0 && EQ_16(USQ_TCQ[k_sort[k]], 1)) { size = sfmsize[k_sort[k]]; move16(); diff --git a/lib_enc/tcx_ltp_enc.c b/lib_enc/tcx_ltp_enc.c index 322c3d1f1849ad4b7fb3c551b935b530d9f0889a..c9b26e81070d0bcbe7faf19e8e7c57a0dd3b0532 100644 --- a/lib_enc/tcx_ltp_enc.c +++ b/lib_enc/tcx_ltp_enc.c @@ -1,13 +1,11 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include #include "options.h" #include "prot_fx.h" #include "stl.h" -#include "wmc_auto.h" - #include "cnst_fx.h" #include "basop_util.h" #include "rom_com_fx.h" @@ -17,14 +15,14 @@ static Word32 dot(const Word16 *X, const Word16 *Y, Word16 n) Word32 acc; Word16 i; - - acc = L_deposit_l(0); - + Word64 acc_64; + acc_64 = 0; + move64(); FOR (i = 0; i < n; i++) { - acc = L_mac0(acc, X[i], Y[i]); + acc_64 = W_mac0_16_16(acc_64, X[i], Y[i]); } - + acc = W_sat_l( acc_64 ); return acc; } @@ -40,7 +38,7 @@ static Word32 interpolate_corr( /* o : interpolated value */ win = E_ROM_inter4_1; - if (sub(frac_max, 6) == 0) win = E_ROM_inter6_1; + if (EQ_16(frac_max, 6))win=E_ROM_inter6_1; s = L_deposit_l(0); @@ -90,7 +88,7 @@ void tcx_ltp_pitch_search( delta = 16; move16(); - if ( sub(pitres, 6) == 0 ) + if ( EQ_16(pitres, 6)) { delta = 8; move16(); @@ -99,14 +97,14 @@ void tcx_ltp_pitch_search( t0_min = sub(pitch_ol, shr(delta, 1)); t0_max = sub(add(t0_min, delta), 1); - IF ( sub(t0_min, pitmin) < 0 ) + IF ( LT_16(t0_min, pitmin)) { t0_min = pitmin; move16(); t0_max = sub(add(t0_min, delta), 1); } - IF ( sub(t0_max, pitmax) > 0 ) + IF ( GT_16(t0_max, pitmax)) { t0_max = pitmax; move16(); @@ -171,11 +169,11 @@ void tcx_ltp_pitch_search( temp_m = divide1616(extract_h(L_shl(cor_max, s)), temp_m); temp_e = sub(negate(s), temp_e); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF *norm_corr = shl(temp_m, temp_e); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON - IF ( sub(t1, pitfr1) >= 0 ) + IF ( GE_16(t1, pitfr1)) { *pitch_int = t1; move16(); @@ -201,7 +199,7 @@ void tcx_ltp_pitch_search( step = 1; move16(); - if (sub(t0, pitfr2) >= 0) + if (GE_16(t0, pitfr2)) { step = 2; move16(); @@ -209,7 +207,7 @@ void tcx_ltp_pitch_search( fraction = step; move16(); - IF (sub(t0, t0_min) == 0) /* Limit case */ + IF (EQ_16(t0, t0_min)) /* Limit case */ { fraction = 0; move16(); @@ -224,7 +222,7 @@ void tcx_ltp_pitch_search( { temp = interpolate_corr( &pt_cor[t0], i, pitres ); - IF (L_sub(temp, cor_max) > 0) + IF (GT_32(temp, cor_max)) { cor_max = L_add(temp, 0); fraction = i; @@ -238,7 +236,7 @@ void tcx_ltp_pitch_search( { temp = interpolate_corr( &pt_cor[t1], i, pitres ); - IF (L_sub(temp, cor_max) > 0) + IF (GT_32(temp, cor_max)) { cor_max = L_add(temp, 0); fraction = i; @@ -253,7 +251,7 @@ void tcx_ltp_pitch_search( *pitch_fr = fraction; move16(); - IF ( sub(t0, pitfr2) >= 0 ) + IF ( GE_16(t0, pitfr2)) { *index = add( extract_l(L_mac0(L_mult0(sub(t0, pitfr2), shr(pitres,1)), sub(pitfr2, pitmin), pitres)), shr(fraction,1) ); @@ -301,9 +299,9 @@ static void tcx_ltp_find_gain( Word16 *speech, Word16 *pred_speech, Word16 L_fra s2 = sub(s2, tmp); g = divide1616(round_fx(corr), round_fx(ener)); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF g = shl(g, sub(s1, s2)); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON /* Quantize gain */ g = shr(sub(g, 0x1000), 13); @@ -384,7 +382,7 @@ void tcx_ltp_encode( Word8 tcxltp_on, Word16 nPrevSubblocks; Word8 isTCX10 = 0; - if (sub(tcxMode, TCX_10) == 0) + if (EQ_16(tcxMode, TCX_10)) { isTCX10 = 1; move16(); @@ -422,30 +420,30 @@ void tcx_ltp_encode( Word8 tcxltp_on, BASOP_SATURATE_WARNING_OFF; if ( ( tcxOnly == 0 && - sub(tcxMode, TCX_20) == 0 && - sub(mult(norm_corr, *norm_corr_past), 0x2000) > 0 && - sub(tempFlatness, 448/*3.5f Q7*/) < 0 + EQ_16(tcxMode, TCX_20) && + GT_16(mult(norm_corr, *norm_corr_past), 0x2000) && + LT_16(tempFlatness, 448/*3.5f Q7*/) ) || ( tcxOnly != 0 && - sub(tcxMode, TCX_10) == 0 && - sub(s_max(norm_corr, *norm_corr_past), 0x4000) > 0 && - sub(maxEnergyChange, 448/*3.5f Q7*/) < 0 + EQ_16(tcxMode, TCX_10) && + GT_16(s_max(norm_corr, *norm_corr_past), 0x4000) && + LT_16(maxEnergyChange, 448/*3.5f Q7*/) ) || ( /* Use LTP for lower correlation when pitch lag is big, L_frame*(1.2f-norm_corr) < pitch_int <=> norm_corr > 1.2f-pitch_int/L_frame */ tcxOnly != 0 && - sub(norm_corr, 14418/*0.44f Q15*/) > 0 && + GT_16(norm_corr, 14418/*0.44f Q15*/) && L_msu(L_mult(L_frame, sub(19661/*1.2f Q14*/, shr(norm_corr, 1))), *pitch_int, 1<<14) < 0 /* L_frame*(1.2f-norm_corr) < pitch_int */ ) || ( tcxOnly != 0 && - sub(tcxMode, TCX_20) == 0 && - sub(norm_corr, 14418/*0.44f Q15*/) > 0 && + EQ_16(tcxMode, TCX_20) && + GT_16(norm_corr, 14418/*0.44f Q15*/) && ( - sub(tempFlatness, 768/*6.0f Q7*/) < 0 || + LT_16(tempFlatness, 768/*6.0f Q7*/) || ( - sub(tempFlatness, 896/*7.0f Q7*/) < 0 && - sub(maxEnergyChange, 2816/*22.0f Q7*/) < 0 + LT_16(tempFlatness, 896/*7.0f Q7*/) && + LT_16(maxEnergyChange, 2816/*22.0f Q7*/) ) ) ) @@ -466,7 +464,7 @@ void tcx_ltp_encode( Word8 tcxltp_on, tcx_ltp_find_gain( speech, pred_speech, L_frame, gain, <p_param[2] ); /* Total number of bits for LTP */ - IF (add(ltp_param[2], 1) != 0) /* gain > 0 */ + IF (NE_16(ltp_param[2], -1) ) /* gain > 0 */ { *ltp_bits = 12; move16(); diff --git a/lib_enc/tcx_utils_enc.c b/lib_enc/tcx_utils_enc.c index 4e21c63ecebcccdc464200a5af5fa9aeeeca62fa..69b536af56c0e61df58571ad40c65b4940248be5 100644 --- a/lib_enc/tcx_utils_enc.c +++ b/lib_enc/tcx_utils_enc.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ @@ -7,8 +7,6 @@ #include #include #include "stl.h" -#include "wmc_auto.h" - #include "options.h" #include "prot_fx.h" #include "rom_basop_util.h" @@ -45,6 +43,7 @@ void ComputeSpectrumNoiseMeasure(const Word32 *powerSpec, Word16 tmp16; Word32 tmp1, tmp2 = 0; /* initialization only to avoid compiler warning, not counted */ + int j; IF (resetMemory != 0) { @@ -62,30 +61,19 @@ void ComputeSpectrumNoiseMeasure(const Word32 *powerSpec, } test(); - IF (powerSpec != NULL && sub(add(startLine, 6), L_frame) < 0) + IF (powerSpec != NULL && LT_16(add(startLine, 6), L_frame)) { lastTone = 0; move16(); /* noise-measure flags for spectrum filling and quantization (0: tonal, 1: noise-like) */ i = sub(startLine, 1); - - s = L_shr(powerSpec[i-7], 4); - s = L_add(s, L_shr(powerSpec[i-6], 4)); - s = L_add(s, L_shr(powerSpec[i-5], 4)); - s = L_add(s, L_shr(powerSpec[i-4], 4)); - s = L_add(s, L_shr(powerSpec[i-3], 4)); - s = L_add(s, L_shr(powerSpec[i-2], 4)); - s = L_add(s, L_shr(powerSpec[i-1], 4)); - s = L_add(s, L_shr(powerSpec[i ], 4)); - s = L_add(s, L_shr(powerSpec[i+1], 4)); - s = L_add(s, L_shr(powerSpec[i+2], 4)); - s = L_add(s, L_shr(powerSpec[i+3], 4)); - s = L_add(s, L_shr(powerSpec[i+4], 4)); - s = L_add(s, L_shr(powerSpec[i+5], 4)); - s = L_add(s, L_shr(powerSpec[i+6], 4)); - s = L_add(s, L_shr(powerSpec[i+7], 4)); - + s = 0; + move32(); + for (j=-7; j<8; j++) + { + s = L_add(s, L_shr(powerSpec[i+j], 4)); + } tmp16 = sub(lowpassLine, 7); FOR (i = add(i, 1); i < tmp16; i++) { @@ -164,7 +152,7 @@ void detectLowpassFac(const Word32 *powerSpec, Word16 powerSpec_e, Word16 L_fram threshold = 256l/*0.1f * 2*NORM_MDCT_FACTOR Q3*/; /* Q3 */ - BASOP_SATURATE_WARNING_OFF;/* Allow saturation, because threshold is being compared to powerSpec[i] below. */ + BASOP_SATURATE_WARNING_OFF /* Allow saturation, because threshold is being compared to powerSpec[i] below. */ threshold = L_shl(threshold, sub(28, powerSpec_e)); if (rectWin != 0) @@ -172,12 +160,12 @@ void detectLowpassFac(const Word32 *powerSpec, Word16 powerSpec_e, Word16 L_fram /* compensate for bad side-lobe attenuation with asymmetric windows */ threshold = L_shl(threshold, 1); } - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON tmp = shr(lowpassLine, 1); FOR (i = sub(lowpassLine, 1); i >= tmp; i--) { - IF (L_sub(powerSpec[i], threshold) > 0) + IF (GT_32(powerSpec[i], threshold)) { BREAK; } @@ -278,7 +266,7 @@ void AnalyzePowerSpectrum( move16(); test(); if ( L_msu0(L_mult0(st->L_frame_fx, extract_l(st->last_sr_core)), st->L_frame_past, extract_l(st->sr_core)) != 0 - || sub(st->last_core_fx, TCX_20_CORE ) != 0 ) + || NE_16(st->last_core_fx, TCX_20_CORE ) ) { tmp8 = 1; move16(); @@ -291,7 +279,7 @@ void AnalyzePowerSpectrum( st->memQuantZeros, lowpassLine); - IF( L_sub(st->total_brate_fx, ACELP_24k40) <= 0 ) + IF( LE_32(st->total_brate_fx, ACELP_24k40)) { lowpassLine = shl(mult(st->tcx_cfg.bandwidth, L_frame), 1); @@ -338,7 +326,7 @@ void AdaptLowFreqEmph(Word32 x[], tmp32 = L_shl(tmp32, sub(add(x_e, invGain_e), 15)); /* convert to 15Q16 */ test(); - IF ((sub(abs_s(xq[i]), 2) >= 0) && (tmp32 >= 0x3A000)) /* 0x3A000 -> 3.625 (15Q16) */ + IF ((GE_16(abs_s(xq[i]), 2))&&(tmp32>=0x3A000)) /* 0x3A000 -> 3.625 (15Q16) */ { /* Debug initialization to catch illegal cases of xq[i] */ @@ -390,7 +378,7 @@ void AdaptLowFreqEmph(Word32 x[], tmp32 = L_shl(tmp32, sub(add(x_e, invGain_e), 15)); /* convert to 15Q16 */ test(); - IF ((sub(abs_s(xq[i]), 2) >= 0) && (tmp32 >= 0x3A000)) /* 0x3A000 -> 3.625 (15Q16) */ + IF ((GE_16(abs_s(xq[i]), 2))&&(tmp32>=0x3A000)) /* 0x3A000 -> 3.625 (15Q16) */ { /* Debug initialization to catch illegal cases of xq[i] */ @@ -432,7 +420,7 @@ void AdaptLowFreqEmph(Word32 x[], IF (i_max_old >= 0) { invGain_e = sub(invGain_e, 1); /* reset inverse gain */ - if (sub(i_max, i_max_old) < 0) + if (LT_16(i_max, i_max_old)) { i_max = i_max_old; move16(); @@ -443,7 +431,7 @@ void AdaptLowFreqEmph(Word32 x[], tmp32 = Mpy_32_16_1(L_abs(x[i]), invGain); /* multiply */ tmp32 = L_shl(tmp32, sub(add(x_e, invGain_e), 15)); /* convert to 15Q16 */ - IF (L_sub(tmp32, 0x3A000) >= 0) + IF (GE_32(tmp32, 0x3A000)) { /* Debug initialization to catch illegal cases of xq[i] */ @@ -475,7 +463,7 @@ void AdaptLowFreqEmph(Word32 x[], tmp32 = Mpy_32_16_1(L_abs(x[i]), invGain); /* multiply */ tmp32 = L_shl(tmp32, sub(add(x_e, invGain_e), 15)); /* convert to 15Q16 */ - IF (L_sub(tmp32, 0x3A000) >= 0) + IF (GE_32(tmp32, 0x3A000)) { /* Debug initialization to catch illegal cases of xq[i] */ @@ -656,13 +644,13 @@ Word16 SQ_gain( /* output: SQ gain */ tmp32 = L_sub(en[i], offset); /* avoid SV with 1 bin of amp < 0.5f */ - if (L_sub(tmp32, 0xFF20) > 0) /* 0xFF20 -> 0.3*log2(10); */ + if (GT_32(tmp32, 0xFF20)) /* 0xFF20 -> 0.3*log2(10); */ { ener = L_add(ener, tmp32); } /* if ener is above target -> break and increase offset */ - IF (L_sub(ener, target) > 0) + IF (GT_32(ener, target)) { offset = L_add(offset, fac); BREAK; @@ -704,7 +692,7 @@ void tcx_scalar_quantization( tmp16 = negate(s_max(tmp16, 0)); i = sub(L_frame, 1); - WHILE ((memQuantZeros[i] != 0) && (L_sub(L_abs(L_shl(x[i], tmp16)), tmp32) < 0)) + WHILE ((memQuantZeros[i] != 0) && (LT_32(L_abs(L_shl(x[i], tmp16)), tmp32))) { test(); xq[i] = 0; @@ -718,7 +706,7 @@ void tcx_scalar_quantization( s = sub(add(x_e, gain_e), 15); /*It should almost never happen and if so the quantization will be discarded later on (saturation of gain Quantizer).*/ - IF( sub(s,31) > 0 ) + IF( GT_16(s,31)) { /* Limit the inverse gain to maximal possible value=sqrtL_spec/NORM_MDCT_FACTOR)*/ gain = 22435; /*sqrt(1200/NORM_MDCT_FACTOR) in 2Q13*/ @@ -842,7 +830,7 @@ Word16 tcx_scalar_quantization_rateloop( /* Loop */ FOR ( iter=0 ; iter= 0) && (sub(stopFlag, old_stopFlag) >= 0)) || - ((sub(*nEncoded, old_nEncoded) > 0) && ((stopFlag == 0) && (old_stopFlag > 0))) || + IF ( ((GE_16(*nEncoded, old_nEncoded))&&(GE_16(stopFlag,old_stopFlag)))|| + ((GT_16(*nEncoded, old_nEncoded) ) && ((stopFlag == 0) && (old_stopFlag > 0))) || ((stopFlag == 0) && (old_stopFlag == 0)) ) { *gain = sqGain; @@ -1181,7 +1169,7 @@ void tcx_noise_factor( segmentOffset = i; move16(); - IF (sub(nTransWidth, 3) <= 0) + IF (LE_16(nTransWidth, 3)) { accu1 = L_deposit_l(0); accu2 = L_deposit_l(0); @@ -1228,13 +1216,13 @@ void tcx_noise_factor( { inv_gain2 = shl(mult(inv_gain2, tilt_factor), 1); - IF (sub(maxK, 1) == 0) /* current line is not zero, so reset pointers */ + IF (EQ_16(maxK, 1)) /* current line is not zero, so reset pointers */ { k = sub(i, segmentOffset); IF (k > 0) /* add segment sum to sum of segment magnitudes */ { - IF (sub(nTransWidth, 3) <= 0) + IF (LE_16(nTransWidth, 3)) { tmp2 = sub(k, c1); if (tmp2 > 0) n = L_msu(n, k, (Word16)0x8000); @@ -1265,7 +1253,7 @@ void tcx_noise_factor( } ELSE /* current line is zero, so update pointers & segment sum */ { - if (sub(k, nTransWidth) < 0) + if (LT_16(k, nTransWidth)) { k = add(k, 1); } @@ -1293,13 +1281,13 @@ void tcx_noise_factor( { inv_gain2 = shl(mult(inv_gain2, tilt_factor), 1); - IF (sub(maxK, 1) == 0) /* current line is not zero, so reset pointers */ + IF (EQ_16(maxK, 1)) /* current line is not zero, so reset pointers */ { k = sub(i, segmentOffset); IF (k > 0) /* add segment sum to sum of segment magnitudes */ { - IF (sub(nTransWidth, 3) <= 0) + IF (LE_16(nTransWidth, 3)) { tmp2 = sub(k, c1); if (tmp2 > 0) n = L_msu(n, k, (Word16)0x8000); @@ -1319,11 +1307,11 @@ void tcx_noise_factor( } ELSE /* current line is zero, so update pointers & energy sum */ { - if (sub(k, nTransWidth) < 0) + if (LT_16(k, nTransWidth)) { k = add(k, 1); } - if (sub(maxK, nTransWidth) < 0) + if (LT_16(maxK, nTransWidth)) { maxK = sub(maxK, 1); } @@ -1338,7 +1326,7 @@ void tcx_noise_factor( k = sub(i, segmentOffset); IF (k > 0) /* add last segment sum to sum of segment magnitudes */ { - IF (sub(nTransWidth, 3) <= 0) + IF (LE_16(nTransWidth, 3)) { tmp2 = sub(k, c1); if (tmp2 > 0) n = L_msu(n, k, (Word16)0x8000); @@ -1373,7 +1361,7 @@ void tcx_noise_factor( /* quantize, dequantize noise level factor (range 0.09375 - 0.65625) */ tmp2 = round_fx(L_shr(L_mult(tmp1, 22016/*1.34375f Q14*/), 14-NBITS_NOISE_FILL_LEVEL)); - if (sub(tmp2, (1< 0) + if (GT_16(tmp2, (1<mem_syn_r, L_SYN_MEM); test(); - IF (st->tcxonly == 0 || sub(L_frame_glob,L_FRAME16k)<=0) + IF (st->tcxonly == 0 || LE_16(L_frame_glob,L_FRAME16k)) { /* Update excitation */ - IF (sub(L_frame_glob, L_EXC_MEM) < 0) + IF (LT_16(L_frame_glob, L_EXC_MEM)) { Copy( LPDmem->old_exc + L_frame_glob, LPDmem->old_exc, sub(L_EXC_MEM, L_frame_glob) ); Residu3_fx(A, synth, LPDmem->old_exc + sub(L_EXC_MEM, L_frame_glob), L_frame_glob, 1); @@ -1496,7 +1484,7 @@ Word16 tcx_ari_res_Q_spec( s = sub(add(gain_e, x_Q_e), x_orig_e); FOR (i=0; i < L_frame; i++) { - IF (sub(bits, target_bits) >= 0) /* no bits left */ + IF (GE_16(bits, target_bits)) /* no bits left */ { BREAK; } @@ -1520,7 +1508,7 @@ Word16 tcx_ari_res_Q_spec( L_tmp = L_abs(L_sub(x_orig[i], L_shl(Mpy_32_16_1(x_Q_m, gain), s))); L_tmp2 = L_abs(L_sub(x_orig[i], L_shl(Mpy_32_16_1(x_Q_p, gain), s))); - IF (L_sub(L_tmp, L_tmp2) < 0) /* Decrease magnitude */ + IF (LT_32(L_tmp, L_tmp2)) /* Decrease magnitude */ { x_Q[i] = x_Q_m; move32(); @@ -1552,7 +1540,7 @@ Word16 tcx_ari_res_Q_spec( s2 = sub(x_Q_e, 1); FOR (j = 0; j < num_zeros; j++) { - IF (sub(bits, target_bits) >= 0) /* 1 or 0 bits left */ + IF (GE_16(bits, target_bits)) /* 1 or 0 bits left */ { BREAK; } @@ -1562,7 +1550,7 @@ Word16 tcx_ari_res_Q_spec( thres = L_mult(fac_p, x_fac[i]); /* Q31 */ - IF (L_sub(L_abs(x_orig[i]), L_shl(Mpy_32_16_1(thres, gain), s)) > 0) + IF (GT_32(L_abs(x_orig[i]), L_shl(Mpy_32_16_1(thres, gain), s))) { prm[bits] = 1; move16(); @@ -1612,7 +1600,7 @@ Word16 tcx_res_Q_gain( move16(); /* make sure we have a bit of headroom */ - IF (sub(gain_reQ, 0x7000) > 0) + IF (GT_16(gain_reQ, 0x7000)) { gain_reQ = shr(gain_reQ, 1); gain_reQ_e = add(gain_reQ_e, 1); @@ -1623,7 +1611,7 @@ Word16 tcx_res_Q_gain( FOR (bits=0; bits < TCX_RES_Q_BITS_GAIN; bits++) { - IF (sub(sqGain, gain_reQ) < 0) + IF (LT_16(sqGain, gain_reQ)) { prm[bits] = 0; move16(); @@ -1636,7 +1624,7 @@ Word16 tcx_res_Q_gain( gain_reQ = shl(mult_r(gain_reQ, gain_corr_fac[bits]), 1); } - IF (sub(bits, sqTargetBits) < 0) + IF (LT_16(bits, sqTargetBits)) { *gain_tcx = gain_reQ; move16(); @@ -1688,14 +1676,14 @@ Word16 tcx_res_Q_spec( FOR (i = 0; i < L_frame; i++) { - IF (sub(bits, sub(sqTargetBits, kMaxEstimatorUndershoot)) >= 0) + IF (GE_16(bits, sub(sqTargetBits, kMaxEstimatorUndershoot))) { fac_m = 0; move16(); fac_p = 0; move16(); - IF (sub(bits, s_min(NPRM_RESQ, add(sqTargetBits, kMaxEstimatorOvershoot))) >= 0) + IF (GE_16(bits, s_min(NPRM_RESQ, add(sqTargetBits, kMaxEstimatorOvershoot)))) { BREAK; } @@ -1703,7 +1691,7 @@ Word16 tcx_res_Q_spec( test(); test(); - IF ((x_Q[i] != 0) && ((lf_deemph_factors == NULL) || (sub(lf_deemph_factors[i], 0x2000) > 0))) + IF ((x_Q[i] != 0) && ((lf_deemph_factors == NULL) || (GT_16(lf_deemph_factors[i], 0x2000)))) { tmp1 = L_add(x_orig[i], 0); tmp2 = Mpy_32_16_1(x_Q[i], sqGain); @@ -1716,7 +1704,7 @@ Word16 tcx_res_Q_spec( move16(); } - IF (L_sub(tmp1, tmp2) < 0) + IF (LT_32(tmp1, tmp2)) { prm[bits] = 0; move16(); @@ -1746,14 +1734,14 @@ Word16 tcx_res_Q_spec( FOR (i = 0; i < L_frame; i++) { - IF (sub(bits, sub(sqTargetBits, 2)) >= 0) + IF (GE_16(bits, sub(sqTargetBits, 2))) { BREAK; } test(); test(); - IF ((x_Q[i] == 0) && ((lf_deemph_factors == NULL) || (sub(lf_deemph_factors[i], 0x2000) > 0))) + IF ((x_Q[i] == 0) && ((lf_deemph_factors == NULL) || (GT_16(lf_deemph_factors[i], 0x2000)))) { if (lf_deemph_factors != NULL) { @@ -1764,7 +1752,7 @@ Word16 tcx_res_Q_spec( thres = L_mult(c, lf_deemph_factor); tmp1 = L_shl(Mpy_32_16_1(thres, sqGain), sub(sqGain_e, x_orig_e)); - IF (L_sub(x_orig[i], tmp1) > 0) + IF (GT_32(x_orig[i], tmp1)) { prm[bits] = 1; move16(); @@ -1848,7 +1836,7 @@ void ProcessIGF( /* It is short block */ igfGridIdx = IGF_GRID_LB_SHORT; move16(); - if (sub(frameno, 1) == 0) + if (EQ_16(frameno, 1)) { isIndepFlag = 0; move16(); @@ -1882,8 +1870,8 @@ void ProcessIGF( ITF_Detect_fx( spec_before, startLine, endLine, maxOrder, A, &Q_A, &predictionGain, &curr_order, shl((&st->hIGFEnc)->spec_be_igf_e, 1) ); *flatteningTrigger = 0; test(); - IF (L_sub(tns_predictionGain, 9646899l/*1.15 Q23*/) < 0 && - sub(predictionGain, 147/*1.15 Q7*/) < 0) + IF (LT_32(tns_predictionGain, 9646899l/*1.15 Q23*/)&& + LT_16(predictionGain, 147/*1.15 Q7*/)) { *flatteningTrigger = 1; } @@ -1926,7 +1914,7 @@ void attenuateNbSpectrum(Word16 L_frame, Word32 *spectrum) att = 21627/*0.66f Q15*/; move16(); - if (sub(length, 8) == 0) + if (EQ_16(length, 8)) { att = 19661/*0.6f Q15*/; move16(); diff --git a/lib_enc/tfa_enc.c b/lib_enc/tfa_enc.c index 7e57720340cf5c00bdb8a19055827b24ad5d5385..97f4f86b16fd59735306a9fbea3f1ca46e420b03 100644 --- a/lib_enc/tfa_enc.c +++ b/lib_enc/tfa_enc.c @@ -1,12 +1,10 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include #include #include "stl.h" -#include "wmc_auto.h" - #include "basop_util.h" #include "cnst_fx.h" #include "prot_fx.h" @@ -69,7 +67,7 @@ Word16 tfaEnc_TBE_fx(Word32* enr, } /* energy lower limit */ - IF(L_sub(m_a, m_a_bottom) < 0) + IF(LT_32(m_a, m_a_bottom)) { tfa_flag = 0; move16(); @@ -93,8 +91,8 @@ Word16 tfaEnc_TBE_fx(Word32* enr, test(); test(); test(); - IF ((L_sub(m_g, L_tmp) > 0 && sub(pitch_buf_sum, 7040/*110 Q6*/) > 0 && sub(voicing_sum, 22938/*0.70 Q15*/) > 0) || - (sub(last_core, TCX_20_CORE) == 0 && L_sub(m_g, L_tmp1) > 0 && sub(voicing_sum, 22938/*0.70 Q15*/) < 0)) + IF ((GT_32(m_g, L_tmp)&>_16(pitch_buf_sum,7040/*110 Q6*/)&>_16(voicing_sum,22938/*0.70 Q15*/))|| + (EQ_16(last_core, TCX_20_CORE) && GT_32(m_g, L_tmp1) && LT_16(voicing_sum, 22938/*0.70 Q15*/) )) { tfa_flag = 1; move16(); diff --git a/lib_enc/tns_base_enc.c b/lib_enc/tns_base_enc.c index a3cb3934400e2e99f15a41ab0af42b68e19db410..488d873a40a341be1947a2f65c019c200efcba93 100644 --- a/lib_enc/tns_base_enc.c +++ b/lib_enc/tns_base_enc.c @@ -1,17 +1,13 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "stl.h" -#include "wmc_auto.h" - #include "prot_fx.h" #include "basop_util.h" #include "stl.h" -#include "wmc_auto.h" - #include #include #include "rom_com_fx.h" @@ -99,10 +95,10 @@ Word16 DetectTnsFilt(STnsConfig const * pTnsConfig, iStartLine = imult1616(tmp, iSubdivisions); iEndLine = add(iStartLine, tmp); - if (sub(nSubdivisions, 3) == 0) iStartLine = mult(iStartLine, 0x2AAB); + if (EQ_16(nSubdivisions, 3))iStartLine=mult(iStartLine,0x2AAB); iStartLine = add(iStartLine, idx0); - if (sub(nSubdivisions, 3) == 0) iEndLine = mult(iEndLine, 0x2AAB); + if (EQ_16(nSubdivisions, 3))iEndLine=mult(iEndLine,0x2AAB); iEndLine = add(iEndLine, idx0); /*norms[iFilter][iSubdivisions] = norm2FLOAT(pSpectrum+iStartLine, iEndLine-iStartLine);*/ @@ -135,7 +131,7 @@ Word16 DetectTnsFilt(STnsConfig const * pTnsConfig, } test(); - IF ((tmp32 > 0) && (sub(nSubdivisions, 1) > 0)) + IF ((tmp32 > 0) && (GT_16(nSubdivisions, 1))) { move16(); facs_e[iFilter][iSubdivisions] = shl(sub(tmp, shifts[iFilter][iSubdivisions]), 1); @@ -196,10 +192,10 @@ Word16 DetectTnsFilt(STnsConfig const * pTnsConfig, iStartLine = imult1616(spectrumLength, iSubdivisions); iEndLine = add(iStartLine, spectrumLength); - if (sub(nSubdivisions, 3) == 0) iStartLine = mult(iStartLine, 0x2AAB); + if (EQ_16(nSubdivisions, 3))iStartLine=mult(iStartLine,0x2AAB); iStartLine = add(iStartLine, idx0); - if (sub(nSubdivisions, 3) == 0) iEndLine = mult(iEndLine, 0x2AAB); + if (EQ_16(nSubdivisions, 3))iEndLine=mult(iEndLine,0x2AAB); iEndLine = add(iEndLine, idx0); @@ -237,7 +233,7 @@ Word16 DetectTnsFilt(STnsConfig const * pTnsConfig, } - IF ( sub(iSubdivisions,nSubdivisions) == 0 ) /* meaning there is no subdivision with low energy */ + IF ( EQ_16(iSubdivisions,nSubdivisions)) /* meaning there is no subdivision with low energy */ { pFilter->spectrumLength = spectrumLength; move16(); @@ -264,7 +260,7 @@ Word16 DetectTnsFilt(STnsConfig const * pTnsConfig, pFilter = pTnsData->filter + iFilter; pTnsParameters = pTnsConfig->pTnsParameters + iFilter; - IF ( s_or(sub(pFilter->predictionGain,pTnsParameters->minPredictionGain) > 0, + IF ( s_or((Word16)GT_16(pFilter->predictionGain,pTnsParameters->minPredictionGain), sub(pFilter->avgSqrCoef,pTnsParameters->minAvgSqrCoef) > 0 ) ) { move16(); @@ -298,10 +294,10 @@ Word16 EncodeTnsData(STnsConfig const * pTnsConfig, STnsData const * pTnsData, W *pnSize = 0; *pnBits = 0; - IF ( sub(pTnsConfig->nMaxFilters, 1) > 0 ) + IF ( GT_16(pTnsConfig->nMaxFilters, 1)) { - IF ( sub(pTnsConfig->iFilterBorders[0],512) < 0 ) + IF ( LT_16(pTnsConfig->iFilterBorders[0],512)) { GetParameters(tnsEnabledSWBTCX10BitMap, 1, pTnsData, &stream, pnSize, pnBits); } @@ -321,10 +317,10 @@ Word16 EncodeTnsData(STnsConfig const * pTnsConfig, STnsData const * pTnsData, W Word16 WriteTnsData(STnsConfig const * pTnsConfig, Word16 const * stream, Word16 * pnSize, Encoder_State_fx *st, Word16 * pnBits) { - IF ( sub(pTnsConfig->nMaxFilters,1) > 0 ) + IF ( GT_16(pTnsConfig->nMaxFilters,1)) { - IF ( sub(pTnsConfig->iFilterBorders[0],512) < 0 ) + IF ( LT_16(pTnsConfig->iFilterBorders[0],512)) { WriteToBitstream(tnsEnabledSWBTCX10BitMap, 1, &stream, pnSize, st, pnBits); } @@ -369,9 +365,9 @@ static void GetFilterParameters(Word32 rxx[], Word16 maxOrder, STnsFilter * pTns /* compute TNS filter in lattice (ParCor) form with LeRoux-Gueguen algorithm */ L_tmp = E_LPC_schur(rxx, parCoeff, epsP, maxOrder); - BASOP_SATURATE_WARNING_OFF;/* Allow saturation, this value is compared against a threshold. */ + BASOP_SATURATE_WARNING_OFF /* Allow saturation, this value is compared against a threshold. */ pTnsFilter->predictionGain = divide3232(L_shr(epsP[0], PRED_GAIN_E), L_tmp); - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON /* non-linear quantization of TNS lattice coefficients with given resolution */ Parcor2Index(parCoeff, indexes, maxOrder); diff --git a/lib_enc/transient_detection.c b/lib_enc/transient_detection.c index 637e3c5c6ffe7c5ec5d685d99590bd45f2bb064a..2b86ad6adaee10e17c854a060a942e7b8e030cdb 100644 --- a/lib_enc/transient_detection.c +++ b/lib_enc/transient_detection.c @@ -1,12 +1,10 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" #include "stl.h" -#include "wmc_auto.h" - #include "basop_util.h" #include "prot_fx.h" #include @@ -73,7 +71,7 @@ static void GetAttackForTCXDecision(Word32 const * pSubblockNrg, Word32 const * bIsAttackPresent = FALSE; attackIndex = 0; /* Search for the last attack in the subblocks */ - if ( s_or(L_sub(L_shr(pSubblockNrg[-1],ATTACKTHRESHOLD_E), Mpy_32_16_1(pAccSubblockNrg[-1], attackRatioThreshold)) > 0, + if ( s_or((Word16)GT_32(L_shr(pSubblockNrg[-1],ATTACKTHRESHOLD_E), Mpy_32_16_1(pAccSubblockNrg[-1], attackRatioThreshold)), L_sub(L_shr(pSubblockNrg[-2],ATTACKTHRESHOLD_E), Mpy_32_16_1(pAccSubblockNrg[-2], attackRatioThreshold)) > 0) ) { move16(); @@ -82,7 +80,7 @@ static void GetAttackForTCXDecision(Word32 const * pSubblockNrg, Word32 const * FOR (i = 0; i < NSUBBLOCKS; i++) { - IF ( L_sub(L_shr(pSubblockNrg[i],ATTACKTHRESHOLD_E), Mpy_32_16_1(pAccSubblockNrg[i], attackRatioThreshold)) > 0 ) + IF ( GT_32(L_shr(pSubblockNrg[i],ATTACKTHRESHOLD_E), Mpy_32_16_1(pAccSubblockNrg[i], attackRatioThreshold))) { if (i < 6) { @@ -90,7 +88,7 @@ static void GetAttackForTCXDecision(Word32 const * pSubblockNrg, Word32 const * bIsAttackPresent = TRUE; } - if ( s_and(sub(attackIndex,2) != 0, sub(attackIndex,6) != 0) ) + if ( s_and((Word16)NE_16(attackIndex,2),(Word16)NE_16(attackIndex,6))) { move16(); attackIndex = i; @@ -98,11 +96,11 @@ static void GetAttackForTCXDecision(Word32 const * pSubblockNrg, Word32 const * } ELSE /* no attack, but set index anyway in case of strong energy increase */ { - IF ( s_and(( L_sub(L_shr(pSubblockNrg[i],1+ATTACKTHRESHOLD_E), Mpy_32_16_1(pSubblockNrg[sub(i,1)], attackRatioThreshold_1_5)) > 0 ), + IF ( s_and(( (Word16)GT_32(L_shr(pSubblockNrg[i],1+ATTACKTHRESHOLD_E), Mpy_32_16_1(pSubblockNrg[sub(i,1)], attackRatioThreshold_1_5))), ( L_sub(L_shr(pSubblockNrg[i],1+ATTACKTHRESHOLD_E), Mpy_32_16_1(pSubblockNrg[sub(i,2)], attackRatioThreshold_1_5)) > 0 )) ) { - if ( s_and(sub(attackIndex,2) != 0, sub(attackIndex,6) != 0) ) + if ( s_and((Word16)NE_16(attackIndex,2),(Word16)NE_16(attackIndex,6))) { move16(); attackIndex = i; @@ -111,12 +109,12 @@ static void GetAttackForTCXDecision(Word32 const * pSubblockNrg, Word32 const * } } /* avoid post-echos on click sounds (very short transients) due to TNS aliasing */ - if ( sub(attackIndex,4) == 0 ) + if ( EQ_16(attackIndex,4)) { move16(); attackIndex = 7; } - if ( sub(attackIndex,5) == 0 ) + if ( EQ_16(attackIndex,5)) { move16(); attackIndex = 6; @@ -246,7 +244,7 @@ Word16 GetTCXMaxenergyChange(struct TransientDetection const * pTransientDetecti /* find subblock with maximum energy */ FOR (i = 1; i < nTotBlocks; i++) { - if ( L_sub(nrgMax, pSubblockNrg[i]) < 0 ) + if ( LT_32(nrgMax, pSubblockNrg[i])) { idxMax = i; move16(); @@ -263,7 +261,7 @@ Word16 GetTCXMaxenergyChange(struct TransientDetection const * pTransientDetecti } /* lower maxEnergyChange if energy doesn't decrease much after energy peak */ /* if (nrgMin > 0.375f * nrgMax) */ - if ( 0 > L_sub(Mpy_32_16_1(nrgMax, 12288/*0.375f Q15*/), nrgMin) ) + if ( LT_32(Mpy_32_16_1(nrgMax, 12288/*0.375f Q15*/), nrgMin) ) { nTotBlocks = sub(idxMax, 3); } @@ -306,7 +304,7 @@ void SetTCXModeInfo(Encoder_State_fx *st, { assert(pTransientDetection != NULL); - IF( sub(st->codec_mode,MODE2) == 0 ) + IF( EQ_16(st->codec_mode,MODE2)) { /* determine window sequence (1 long or 2 short windows) */ @@ -319,8 +317,8 @@ void SetTCXModeInfo(Encoder_State_fx *st, test(); test(); IF ( ((pTransientDetection->transientDetector.bIsAttackPresent != 0) - || (L_sub(Mpy_32_16_1(st->currEnergyHF_fx, 840/*1.0f/39.0f Q15*/), st->prevEnergyHF_fx) > 0)) - && ((sub(st->last_core_fx, ACELP_CORE) != 0) && (sub(st->last_core_fx, AMR_WB_CORE) != 0)) ) + || (GT_32(Mpy_32_16_1(st->currEnergyHF_fx, 840/*1.0f/39.0f Q15*/), st->prevEnergyHF_fx) )) + && ((NE_16(st->last_core_fx, ACELP_CORE) ) && (NE_16(st->last_core_fx, AMR_WB_CORE) )) ) { move16(); st->tcxMode = TCX_10; @@ -356,7 +354,7 @@ void SetTCXModeInfo(Encoder_State_fx *st, move16(); st->tcx_cfg.tcx_last_overlap_mode = TRANSITION_OVERLAP; } - ELSE IF ( (sub(st->tcxMode, TCX_10) == 0) && (sub(st->tcx_cfg.tcx_curr_overlap_mode, ALDO_WINDOW) == 0)) + ELSE IF ( (EQ_16(st->tcxMode, TCX_10))&&(EQ_16(st->tcx_cfg.tcx_curr_overlap_mode,ALDO_WINDOW))) { move16(); st->tcx_cfg.tcx_last_overlap_mode = FULL_OVERLAP; @@ -369,7 +367,7 @@ void SetTCXModeInfo(Encoder_State_fx *st, /* determine window overlaps (0 full, 2 none, or 3 half) */ - IF ( sub(st->tcxMode, TCX_10) == 0 ) + IF ( EQ_16(st->tcxMode, TCX_10)) { IF( pTransientDetection->transientDetector.attackIndex < 0) { @@ -380,21 +378,21 @@ void SetTCXModeInfo(Encoder_State_fx *st, { move16(); *tcxModeOverlap = s_and(pTransientDetection->transientDetector.attackIndex, 3); - if ( sub(*tcxModeOverlap,1) == 0 ) + if ( EQ_16(*tcxModeOverlap,1)) { move16(); *tcxModeOverlap = FULL_OVERLAP; } } } - ELSE IF ( sub(st->tcxMode, TCX_20) == 0 ) + ELSE IF ( EQ_16(st->tcxMode, TCX_20)) { - IF (sub(pTransientDetection->transientDetector.attackIndex, 7) == 0) + IF (EQ_16(pTransientDetection->transientDetector.attackIndex, 7)) { move16(); *tcxModeOverlap = HALF_OVERLAP; } - ELSE IF (sub(pTransientDetection->transientDetector.attackIndex, 6) == 0) + ELSE IF (EQ_16(pTransientDetection->transientDetector.attackIndex, 6)) { move16(); *tcxModeOverlap = MIN_OVERLAP; @@ -411,7 +409,7 @@ void SetTCXModeInfo(Encoder_State_fx *st, *tcxModeOverlap = TRANSITION_OVERLAP; } test(); - if ((sub(st->tcx_cfg.tcx_last_overlap_mode, TRANSITION_OVERLAP) == 0) && (sub(*tcxModeOverlap, ALDO_WINDOW) == 0)) + if ((EQ_16(st->tcx_cfg.tcx_last_overlap_mode, TRANSITION_OVERLAP))&&(EQ_16(*tcxModeOverlap,ALDO_WINDOW))) { move16(); *tcxModeOverlap = FULL_OVERLAP; @@ -541,12 +539,10 @@ static void RunTransientDetector(TransientDetector * pTransientDetector) assert((pTransientDetector->CheckSubblocksForAttack != NULL)); -#define WMC_TOOL_SKIP pTransientDetector->CheckSubblocksForAttack(pSubblockNrg, pAccSubblockNrg, NSUBBLOCKS+nDelay, nRelativeDelay, attackRatioThreshold, &pTransientDetector->bIsAttackPresent, &pTransientDetector->attackIndex); -#undef WMC_TOOL_SKIP } @@ -609,7 +605,7 @@ static void UpdatedAndStoreAccWindowNrg(Word32 newWindowNrgF, Word32 * pAccSubbl /* Update the accumulated energy: maximum of the current and the accumulated energy */ *pAccSubblockNrg = Mpy_32_16_1(*pAccSubblockNrg, facAccSubblockNrg); - if ( L_sub(newWindowNrgF, *pAccSubblockNrg) > 0 ) + if ( GT_32(newWindowNrgF, *pAccSubblockNrg)) { move32(); *pAccSubblockNrg = newWindowNrgF; @@ -706,7 +702,7 @@ static void CalculateSubblockEnergies(Word16 const * input, Word16 nSamplesAvail w0 = L_add(pSubblockNrg[w], 0); w1 = L_add(pSubblockNrg[sub(w,1)], 0); - IF ( L_sub(w0, w1) > 0 ) + IF ( GT_32(w0, w1)) { k2 = BASOP_Util_Divide3232_uu_1616_Scale(w0, w1, &k); } @@ -716,7 +712,7 @@ static void CalculateSubblockEnergies(Word16 const * input, Word16 nSamplesAvail } move16(); pSubblockNrgChange[w] = MAX_16; - IF ( sub(k,SUBBLOCK_NRG_CHANGE_E) < 0 ) + IF ( LT_16(k,SUBBLOCK_NRG_CHANGE_E)) { move16(); pSubblockNrgChange[w] = shr(k2, sub(SUBBLOCK_NRG_CHANGE_E,k)); diff --git a/lib_enc/transition_enc_fx.c b/lib_enc/transition_enc_fx.c index fe7216d5cd72fad1bd93bd868d7d7f1730c395e6..d22d1e886c60ebd47884d2b664e532289e8230c6 100644 --- a/lib_enc/transition_enc_fx.c +++ b/lib_enc/transition_enc_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -8,8 +8,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*-----------------------------------------------------------------* * Local functions @@ -122,9 +120,9 @@ void transition_enc_fx( IF( i_subfr == 0 ) { - IF( sub(*tc_subfr,3*L_SUBFR) == 0 ) + IF( EQ_16(*tc_subfr,3*L_SUBFR)) { - IF( sub(L_frame,L_FRAME) == 0 ) + IF( EQ_16(L_frame,L_FRAME)) { *position = emaximum_fx( Q_new, res_fx + 3*L_SUBFR,s_min(add(T_op_fx[0],2),L_SUBFR), &temp ) + 3*L_SUBFR; move16(); @@ -147,8 +145,8 @@ void transition_enc_fx( test(); test(); test(); - IF( (sub(L_frame,L_FRAME) == 0 && sub(T_op_fx[0],2*PIT_MIN)>0 ) || - (sub(L_frame,L_FRAME16k) == 0 && sub(T_op_fx[0],2*PIT16k_MIN) >0) + IF( (EQ_16(L_frame,L_FRAME)&>_16(T_op_fx[0],2*PIT_MIN))|| + (EQ_16(L_frame,L_FRAME16k) && GT_16(T_op_fx[0],2*PIT16k_MIN) ) ) { Word16 position_tmp, len, exp_aver=0, exp=0, exp2=0; @@ -172,8 +170,8 @@ void transition_enc_fx( L_temp1 = Mult_32_16(temp, 8192); /* Q=31-exp */ test(); - IF( L_sub(temp2, L_shl(L_temp2,(31-exp2)-(31-exp))) > 0 && - L_sub(aver, L_shl(L_temp1,(31-exp_aver)-(31-exp))) < 0 ) + IF( GT_32(temp2, L_shl(L_temp2,(31-exp2)-(31-exp)))&& + LT_32(aver, L_shl(L_temp1,(31-exp_aver)-(31-exp))) ) { *position = position_tmp; } @@ -184,13 +182,13 @@ void transition_enc_fx( IF( limit_flag == 0 ) { test(); - IF( sub(L_frame,L_FRAME) == 0 && sub(T_op_fx[1],PIT_MIN) < 0 ) + IF( EQ_16(L_frame,L_FRAME)&<_16(T_op_fx[1],PIT_MIN)) { mult_Top = 2; move16(); } test(); - if( sub(L_frame,L_FRAME16k) == 0 && sub(T_op_fx[1],PIT16k_MIN) < 0 ) + if( EQ_16(L_frame,L_FRAME16k)&<_16(T_op_fx[1],PIT16k_MIN)) { mult_Top = 2; move16(); @@ -203,7 +201,7 @@ void transition_enc_fx( /*-----------------------------------------------------------------* * zero adaptive excitation signal construction *-----------------------------------------------------------------*/ - IF ( sub(*tc_subfr,i_subfr) > 0 ) + IF ( GT_16(*tc_subfr,i_subfr)) { *gain_pit_fx = 0; move16(); @@ -219,7 +217,7 @@ void transition_enc_fx( set16_fx(&exc_fx[i_subfr], 0, L_SUBFR); /* set excitation for current subrame to 0 */ - IF( sub(L_frame,L_FRAME) == 0 ) + IF( EQ_16(L_frame,L_FRAME)) { set16_fx(&bwe_exc_fx[i_subfr*HIBND_ACB_L_FAC], 0, (Word16)(L_SUBFR*HIBND_ACB_L_FAC)); /* set past excitation buffer to 0 */ } @@ -243,9 +241,9 @@ void transition_enc_fx( /*-----------------------------------------------------------------* * glottal codebook contribution construction *-----------------------------------------------------------------*/ - ELSE IF ( sub(*tc_subfr,i_subfr) == 0 ) + ELSE IF ( EQ_16(*tc_subfr,i_subfr)) { - IF( sub(L_frame,L_FRAME) == 0 ) + IF( EQ_16(L_frame,L_FRAME)) { set16_fx( bwe_exc_fx-PIT_MAX*HIBND_ACB_L_FAC, 0, PIT_MAX*HIBND_ACB_L_FAC); /* set past excitation buffer to 0 */ } @@ -273,15 +271,15 @@ void transition_enc_fx( * in the 1st subframe and the second one in 2nd subframe * and later *--------------------------------------------------------------*/ - ELSE IF ( sub(*tc_subfr,i_subfr) < 0) + ELSE IF ( LT_16(*tc_subfr,i_subfr)) { - IF( sub(L_frame,L_FRAME) == 0 ) + IF( EQ_16(L_frame,L_FRAME)) { *Jopt_flag = 1; move16(); /* pit_flag for T0 bits number coding determination */ test(); - IF( (sub(sub(i_subfr,*tc_subfr),L_SUBFR) == 0) || (sub(sub(i_subfr, *tc_subfr),L_SUBFR-TC_0_0) == 0) ) + IF( (EQ_16(sub(i_subfr,*tc_subfr),L_SUBFR))||(EQ_16(sub(i_subfr,*tc_subfr),L_SUBFR-TC_0_0))) { pit_flag = 0; move16(); @@ -292,9 +290,9 @@ void transition_enc_fx( move16(); } - IF( sub(*tc_subfr,TC_0_0) == 0 ) + IF( EQ_16(*tc_subfr,TC_0_0)) { - IF( sub(i_subfr,L_SUBFR) == 0 ) + IF( EQ_16(i_subfr,L_SUBFR)) { limit_T0_fx( L_FRAME, 8, pit_flag, limit_flag, *T0, 0, T0_min, T0_max ); } @@ -307,9 +305,9 @@ void transition_enc_fx( * second glot. impulse position *----------------------------------------------------------*/ test(); - IF( (*tc_subfr == 0) && (sub(i_subfr,L_SUBFR) == 0) ) + IF( (*tc_subfr == 0) && (EQ_16(i_subfr,L_SUBFR))) { - IF( sub(PIT_MIN,(*position)) > 0 ) + IF( GT_16(PIT_MIN,(*position))) { pit_start = sub(L_SUBFR, (*position)); } @@ -336,9 +334,9 @@ void transition_enc_fx( test(); - IF( sub((*T0),sub(2*L_SUBFR,(*position)))> 0 ) + IF( GT_16((*T0),sub(2*L_SUBFR,(*position)))) { - IF( sub(add((*T0), (*position)),3*L_SUBFR) >= 0) + IF( GE_16(add((*T0), (*position)),3*L_SUBFR)) { /* second glottal impulse is in the 4th subframe */ *tc_subfr = TC_0_192; @@ -351,7 +349,7 @@ void transition_enc_fx( move16(); } } - ELSE IF( (*tc_subfr == 0) && (sub(i_subfr,L_SUBFR) == 0) ) + ELSE IF( (*tc_subfr == 0) && (EQ_16(i_subfr,L_SUBFR))) { /* second glottal impulse is in the 2nd subframe */ *tc_subfr = TC_0_64; @@ -376,7 +374,7 @@ void transition_enc_fx( test(); test(); /* first glottal impulse is in the 1st subrame */ - IF( (sub(i_subfr,L_SUBFR) == 0) && (sub(*tc_subfr,TC_0_128) >= 0) ) + IF( (EQ_16(i_subfr,L_SUBFR))&&(GE_16(*tc_subfr,TC_0_128))) { /*--------------------------------------------------------* * second glottal impulse is in the 3rd or 4th subframe @@ -392,14 +390,14 @@ void transition_enc_fx( set16_fx( &bwe_exc_fx[i_subfr*HIBND_ACB_L_FAC], 0, (Word16)(L_SUBFR*HIBND_ACB_L_FAC) ); } - ELSE IF( (sub(i_subfr,L_SUBFR) == 0) && (sub(*tc_subfr,TC_0_64) == 0) ) + ELSE IF( (EQ_16(i_subfr,L_SUBFR))&&(EQ_16(*tc_subfr,TC_0_64))) { /*--------------------------------------------------------* * second glottal impulse is in the 2nd subframe, * - build exc[] in 2nd subframe *--------------------------------------------------------*/ - IF( sub(add(*T0,*position), L_SUBFR ) < 0 ) + IF( LT_16(add(*T0,*position), L_SUBFR )) { /* impulse must be in the 2nd subframe (not in 1st) */ *T0 = sub(L_SUBFR, (*position)); @@ -407,7 +405,7 @@ void transition_enc_fx( *T0_frac = 0; move16(); } - IF( sub(add(*T0,*position),2*L_SUBFR) >= 0 ) + IF( GE_16(add(*T0,*position),2*L_SUBFR)) { /* impulse must be in the 2nd subframe (not in 3rd) */ *T0 = sub(2*L_SUBFR-1,(*position)); @@ -435,7 +433,7 @@ void transition_enc_fx( } } - ELSE IF( (sub(i_subfr,2*L_SUBFR) == 0) && (sub(*tc_subfr,TC_0_128) == 0) ) + ELSE IF( (EQ_16(i_subfr,2*L_SUBFR))&&(EQ_16(*tc_subfr,TC_0_128))) { /*--------------------------------------------------------* * second glottal impulse is in the 3rd subframe @@ -448,7 +446,7 @@ void transition_enc_fx( *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, pit_start, 3*L_SUBFR, L_FRAME, L_SUBFR ); - IF( sub(add((*T0),(*position)),2*L_SUBFR) < 0 ) + IF( LT_16(add((*T0),(*position)),2*L_SUBFR)) { /* impulse must be in the 3rd subframe (not in 2nd) */ *T0 = sub(2*L_SUBFR, (*position)); @@ -457,7 +455,7 @@ void transition_enc_fx( move16(); } - IF (sub(add((*T0),(*position)),3*L_SUBFR) >= 0) + IF (GE_16(add((*T0),(*position)),3*L_SUBFR)) { /* impulse must be in the 3rd subframe (not in 4th) */ *T0 = sub(3*L_SUBFR - 1, (*position)); @@ -482,7 +480,7 @@ void transition_enc_fx( bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC] = bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC - offset]; } } - ELSE IF( (sub(i_subfr,2*L_SUBFR) == 0) && (sub(*tc_subfr,TC_0_192) == 0) ) + ELSE IF( (EQ_16(i_subfr,2*L_SUBFR))&&(EQ_16(*tc_subfr,TC_0_192))) { /*--------------------------------------------------------* * second glottal impulse is in the 4th subframe @@ -499,7 +497,7 @@ void transition_enc_fx( } - ELSE IF( (sub(i_subfr,3*L_SUBFR) == 0) && (sub(*tc_subfr,TC_0_192) == 0) ) + ELSE IF( (EQ_16(i_subfr,3*L_SUBFR))&&(EQ_16(*tc_subfr,TC_0_192))) { /*--------------------------------------------------------* * second glottal impulse is in the 4th subframe @@ -511,7 +509,7 @@ void transition_enc_fx( *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR ); - IF( sub(add(*T0, *position), 3*L_SUBFR) < 0 ) + IF( LT_16(add(*T0, *position), 3*L_SUBFR)) { /* impulse must be in the 4th subframe (not in 3rd) */ *T0 = sub(3*L_SUBFR, (*position)); @@ -523,7 +521,7 @@ void transition_enc_fx( pit_start = sub(3*L_SUBFR, (*position)); pit_limit = sub(2*L_FRAME - PIT_MAX -2, shl(*position,1)); - IF (sub((*T0),pit_limit) < 0) + IF (LT_16((*T0),pit_limit)) { index = add(shl(sub(*T0, pit_start),1), shr(*T0_frac,1)); } @@ -546,7 +544,7 @@ void transition_enc_fx( move16(); } } - ELSE IF( (sub(i_subfr,3*L_SUBFR) == 0) && (sub(*tc_subfr,TC_0_128) == 0) ) + ELSE IF( (EQ_16(i_subfr,3*L_SUBFR))&&(EQ_16(*tc_subfr,TC_0_128))) { /*--------------------------------------------------------* * second glottal impulse in the 3rd subframe @@ -578,10 +576,10 @@ void transition_enc_fx( ELSE { test(); - IF( sub(nBits,8) == 0 || sub(nBits,5) == 0) + IF( EQ_16(nBits,8)||EQ_16(nBits,5)) { test(); - IF( !((*tc_subfr == 0) && (sub(i_subfr,L_SUBFR) == 0)) ) + IF( !((*tc_subfr == 0) && (EQ_16(i_subfr,L_SUBFR)))) { *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR ); } @@ -632,7 +630,7 @@ void transition_enc_fx( lp_select = lp_filt_exc_enc_fx( MODE1, core_brate, 0, coder_type, i_subfr, exc_fx, h1_fx, xn_fx, y1_fx, xn2_fx, L_SUBFR, L_frame, g_corr_fx, *clip_gain, gain_pit_fx, &lp_flag ); - IF( sub(lp_flag,NORMAL_OPERATION) == 0 ) + IF( EQ_16(lp_flag,NORMAL_OPERATION)) { push_indice_fx( st_fx, IND_LP_FILT_SELECT, lp_select, 1 ); } @@ -724,18 +722,18 @@ void transition_enc_fx( } ELSE /* L_frame == L_FRAME16k */ { - if( sub(i_subfr,2*L_SUBFR) >= 0) + if( GE_16(i_subfr,2*L_SUBFR)) { limit_flag = 1; move16(); } - IF( sub(i_subfr,2*L_SUBFR) <= 0) + IF( LE_16(i_subfr,2*L_SUBFR)) { - IF( sub(i_subfr,2*L_SUBFR) < 0 ) + IF( LT_16(i_subfr,2*L_SUBFR)) { mult_Top = 1; move16(); - if( sub(T_op_fx[0],PIT16k_MIN) < 0 ) + if( LT_16(T_op_fx[0],PIT16k_MIN)) { mult_Top = 2; move16(); @@ -761,12 +759,12 @@ void transition_enc_fx( * Find adaptive part of excitation, encode pitch period *-----------------------------------------------------------------*/ - IF( sub(nBits,10) == 0 ) + IF( EQ_16(nBits,10)) { *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, limit_flag, PIT16k_FR2_EXTEND_10b, PIT16k_MAX, L_frame, L_SUBFR ); pit16k_Q_enc_fx( st_fx, nBits, limit_flag, *T0, *T0_frac, T0_min, T0_max ); } - ELSE IF( sub(nBits,8) == 0 ) /* tc_subfr==0 && i_subfr==L_SUBFR */ + ELSE IF( EQ_16(nBits,8)) /* tc_subfr==0 && i_subfr==L_SUBFR */ { /*-----------------------------------------------------------------------------* * The pitch range is encoded absolutely with 8 bits and is divided as follows: @@ -775,7 +773,7 @@ void transition_enc_fx( *-----------------------------------------------------------------------------*/ *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, limit_flag, PIT16k_FR2_TC0_2SUBFR, 2*L_SUBFR, L_frame, L_SUBFR ); - IF( sub(*T0_max,2*L_SUBFR) > 0) + IF( GT_16(*T0_max,2*L_SUBFR)) { *T0 = 2*L_SUBFR; move16(); @@ -783,7 +781,7 @@ void transition_enc_fx( move16(); } - IF( sub(*T0,PIT16k_FR2_TC0_2SUBFR ) < 0) + IF( LT_16(*T0,PIT16k_FR2_TC0_2SUBFR )) { /*index = (*T0)*4 + (*T0_frac) - (PIT16k_MIN*4);*/ index = add(shl(*T0,2), sub(*T0_frac, PIT16k_MIN*4)); @@ -795,7 +793,7 @@ void transition_enc_fx( } push_indice_fx( st_fx, IND_PITCH, index, nBits ); } - ELSE IF( sub(nBits,6) == 0 ) + ELSE IF( EQ_16(nBits,6)) { /* delta search */ *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, L_SUBFR, limit_flag, PIT16k_FR2_EXTEND_9b, PIT16k_FR1_EXTEND_9b, L_frame, L_SUBFR ); @@ -803,7 +801,7 @@ void transition_enc_fx( index = delta_pit_enc_fx( 4, *T0, *T0_frac, *T0_min ); push_indice_fx( st_fx, IND_PITCH, index, nBits ); } - IF( sub(nBits,6) == 0 ) + IF( EQ_16(nBits,6)) { limit_T0_fx( L_FRAME16k, 8, L_SUBFR, limit_flag, *T0, *T0_frac, T0_min, T0_max ); } @@ -814,7 +812,7 @@ void transition_enc_fx( * - codebook target computation *-----------------------------------------------------------------*/ test(); - IF( (sub(i_subfr,L_SUBFR) == 0) && (sub(*T0,2*L_SUBFR) == 0) ) + IF( (EQ_16(i_subfr,L_SUBFR))&&(EQ_16(*T0,2*L_SUBFR))) { *gain_pit_fx = 0; move16(); @@ -859,7 +857,7 @@ void transition_enc_fx( lp_select = lp_filt_exc_enc_fx( MODE1, core_brate, 0, coder_type, i_subfr, exc_fx, h1_fx, xn_fx, y1_fx, xn2_fx, L_SUBFR, L_frame, g_corr_fx, *clip_gain, gain_pit_fx, &lp_flag ); - IF( sub(lp_flag,NORMAL_OPERATION) == 0 ) + IF( EQ_16(lp_flag,NORMAL_OPERATION)) { push_indice_fx( st_fx, IND_LP_FILT_SELECT, lp_select, 1 ); } @@ -879,7 +877,7 @@ void transition_enc_fx( *---------------------------------------------------------------------*/ test(); test(); - IF( (sub(sub(i_subfr, *tc_subfr),L_SUBFR) == 0) || (*tc_subfr==0 && sub(i_subfr,2*L_SUBFR)==0) ) + IF( (EQ_16(sub(i_subfr, *tc_subfr),L_SUBFR))||(*tc_subfr==0&&EQ_16(i_subfr,2*L_SUBFR))) { index = shr(i_subfr,6); (*pt_pitch_fx) -= index; @@ -949,7 +947,7 @@ static void tc_enc_fx( * get number of bits for pitch encoding *-----------------------------------------------------------------*/ - IF( sub(L_frame,L_FRAME) == 0 ) + IF( EQ_16(L_frame,L_FRAME)) { nBits = ACB_bits_tbl[BIT_ALLOC_IDX_fx(core_brate, TRANSITION, i_subfr, TC_SUBFR2IDX_fx(*tc_subfr))]; move16(); @@ -967,16 +965,16 @@ static void tc_enc_fx( *T0_frac = 0; move16(); - IF( sub(L_frame,L_FRAME) == 0 ) + IF( EQ_16(L_frame,L_FRAME)) { test(); - IF( (sub(*T0_min,L_SUBFR) <= 0) || (sub(*tc_subfr,3*L_SUBFR) == 0) ) + IF( (LE_16(*T0_min,L_SUBFR))||(EQ_16(*tc_subfr,3*L_SUBFR))) { - IF( sub(nBits,9) == 0 ) + IF( EQ_16(nBits,9)) { *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, 0, PIT_FR2_9b, PIT_FR1_9b, L_FRAME, L_SUBFR ); } - ELSE IF( sub(nBits,6) == 0 ) + ELSE IF( EQ_16(nBits,6)) { *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, 0, PIT_MIN, L_SUBFR, L_FRAME, L_SUBFR ); } @@ -991,7 +989,7 @@ static void tc_enc_fx( move16(); } test(); - if( sub(*tc_subfr,L_SUBFR) == 0 && sub(*T0,L_SUBFR) < 0 ) + if( EQ_16(*tc_subfr,L_SUBFR)&<_16(*T0,L_SUBFR)) { *T0 = L_SUBFR; move16(); @@ -999,11 +997,11 @@ static void tc_enc_fx( } ELSE /* L_frame == L_FRAME16k */ { - IF( sub(nBits,10) == 0 ) + IF( EQ_16(nBits,10)) { *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, 1, PIT16k_FR2_EXTEND_10b, PIT16k_MAX, L_FRAME16k, L_SUBFR ); } - ELSE IF( sub(nBits,6) == 0 ) + ELSE IF( EQ_16(nBits,6)) { /* T0_frac with 1/2 sample resolution */ *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, 0, PIT16k_MIN, L_SUBFR, L_FRAME16k, L_SUBFR ); @@ -1022,7 +1020,7 @@ static void tc_enc_fx( test(); test(); test(); - if( i_subfr == 0 && sub(L_frame,L_FRAME) == 0 && ( sub(*T0,L_SUBFR) < 0 || sub(*tc_subfr,3*L_SUBFR) == 0) ) + if( i_subfr == 0 && EQ_16(L_frame,L_FRAME)&&(LT_16(*T0,L_SUBFR)||EQ_16(*tc_subfr,3*L_SUBFR))) { *tc_subfr = TC_0_0; move16(); @@ -1049,7 +1047,7 @@ static void tc_enc_fx( pred_lt4_tc_fx( exc_fx, *T0, *T0_frac, inter4_2_fx, imp_pos, i_subfr ); - IF( sub(L_frame,L_FRAME) == 0 ) + IF( EQ_16(L_frame,L_FRAME)) { interp_code_5over2_fx(&exc_fx[i_subfr], &bwe_exc_fx[i_subfr * HIBND_ACB_L_FAC], L_SUBFR); } @@ -1071,22 +1069,22 @@ static void tc_enc_fx( /*--------------------------------------------------------------* * Encode parameters and write indices *--------------------------------------------------------------*/ - IF( sub(L_frame,L_FRAME) == 0 ) + IF( EQ_16(L_frame,L_FRAME)) { test(); test(); - IF( ( (i_subfr != 0) || (sub(*tc_subfr,TC_0_0) == 0) ) - && (sub(*tc_subfr,L_SUBFR) != 0)) + IF( ( (i_subfr != 0) || (EQ_16(*tc_subfr,TC_0_0))) + && (NE_16(*tc_subfr,L_SUBFR) )) { test(); /* write pitch index */ - IF( (sub(*T0,L_SUBFR) >= 0) && (sub(*tc_subfr,3*L_SUBFR) != 0) ) + IF( (GE_16(*T0,L_SUBFR))&&(NE_16(*tc_subfr,3*L_SUBFR))) { push_indice_fx( st_fx, IND_PITCH, 0, nBits ); } - ELSE IF( sub(*tc_subfr,3*L_SUBFR) == 0) + ELSE IF( EQ_16(*tc_subfr,3*L_SUBFR)) { - IF( sub(nBits,9) == 0 ) + IF( EQ_16(nBits,9)) { index = abs_pit_enc_fx( 4, 0, *T0, *T0_frac ); } @@ -1100,7 +1098,7 @@ static void tc_enc_fx( } ELSE { - IF( sub(nBits,6) == 0 ) + IF( EQ_16(nBits,6)) { index = delta_pit_enc_fx( 2, *T0, *T0_frac, PIT_MIN-1 ); push_indice_fx( st_fx, IND_PITCH, index, nBits ); @@ -1115,11 +1113,11 @@ static void tc_enc_fx( } ELSE /* L_frame == L_FRAME16k */ { - IF( sub(nBits,10) == 0 ) + IF( EQ_16(nBits,10)) { pit16k_Q_enc_fx( st_fx, nBits, 1, *T0, *T0_frac, T0_min, T0_max ); } - ELSE IF( sub(nBits,6) == 0 ) + ELSE IF( EQ_16(nBits,6)) { index = add(shl(sub(*T0,PIT16k_MIN),1) , shr(*T0_frac,1)); push_indice_fx( st_fx, IND_PITCH, index, nBits ); @@ -1161,7 +1159,7 @@ static void gain_trans_enc_fx( move16(); gain_trans = extract_h(L_shl(gain_trans32,16)); /* Q7 */ - IF (L_sub(L_abs(gain_trans32), 29862L)>0) + IF (GT_32(L_abs(gain_trans32), 29862L)) { gain_trans = extract_h(L_shl(gain_trans32,16-3)); /* Q4 */ istart = 4; @@ -1183,7 +1181,7 @@ static void gain_trans_enc_fx( move16(); FOR (i = istart; i < imax; i++) { - IF (sub(gain_trans,tbl_gain_trans_tc_fx[i]) <= 0 ) + IF (LE_16(gain_trans,tbl_gain_trans_tc_fx[i])) { *quant_index = i; move16(); diff --git a/lib_enc/update_decision.c b/lib_enc/update_decision.c index a7ac8c5b4c9c74031fb255ffb727dc3ed3ebd185..fab847245e8614deb2edc49c4dc2778e7d8ff375 100644 --- a/lib_enc/update_decision.c +++ b/lib_enc/update_decision.c @@ -1,12 +1,10 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "basop_util.h" #include "stl.h" -#include "wmc_auto.h" - #include "vad_basop.h" #include "prot_fx.h" @@ -30,7 +28,8 @@ void bg_music_decision(T_CldfbVadState *st, Word16 fg_energy_Qtmp; - music_background_frame = L_add(0,0); + music_background_frame = 0; + move32(); tmp1 = L_mult(st->fg_energy_count,18842); tmp1_Q = norm_l(tmp1); tmp1 = L_shl(tmp1,tmp1_Q); @@ -43,21 +42,22 @@ void bg_music_decision(T_CldfbVadState *st, cmp_result = VAD_L_CMP(frame_energy_Mcount,fg_energy_Qtmp,st->fg_energy,st->fg_energy_scale); test(); - IF((sub(f_tonality_rate[1],9830/* 0.6 Q14 */)>0) - ||(sub(f_tonality_rate[0],14089/* 0.86 Q14 */)>0)) + IF((GT_16(f_tonality_rate[1],9830/* 0.6 Q14 */)) + ||(GT_16(f_tonality_rate[0],14089/* 0.86 Q14 */))) { test(); test(); test(); test(); - if((sub(ltd_stable_rate[0], 2359/* 0.072 Q15 */)<0) - &&(sub(sp_center[0],1228/* 1.2 Q10 */)>0) - &&((sub(sSFM[0],24903/* 0.76 Q15 */)<0) - ||(sub(sSFM[1],28835/* 0.88 Q15 */)<0) - ||(sub(sSFM[2],31456/* 0.96 Q15 */)<0))) + if((LT_16(ltd_stable_rate[0], 2359/* 0.072 Q15 */)) + &&(GT_16(sp_center[0],1228/* 1.2 Q10 */)) + &&((LT_16(sSFM[0],24903/* 0.76 Q15 */)) + ||(LT_16(sSFM[1],28835/* 0.88 Q15 */)) + ||(LT_16(sSFM[2],31456/* 0.96 Q15 */)))) { - music_background_frame = L_add(1,0); + music_background_frame = 1; + move32(); } } @@ -65,7 +65,7 @@ void bg_music_decision(T_CldfbVadState *st, test(); IF(music_background_frame &&(cmp_result > 0) - &&(L_sub(st->fg_energy_est_start,1)==0)) + &&(EQ_32(st->fg_energy_est_start,1))) { st->music_background_rate = add(mult(st->music_background_rate,31949), 819); move16(); @@ -83,7 +83,7 @@ void bg_music_decision(T_CldfbVadState *st, *music_backgound_f = 0; move16(); - if(sub(st->music_background_rate, 16384)> 0) + if(GT_16(st->music_background_rate, 16384)) { *music_backgound_f = 1; move16(); @@ -137,7 +137,7 @@ Word16 update_decision(T_CldfbVadState *st, move16(); lt_bg_highf_eng_trbl = MUL_F(st->lt_bg_highf_eng,24576); - IF (sub(14,HB_Power_Q)>0) + IF (GT_16(14,HB_Power_Q)) { lt_bg_highf_eng_trbl = L_shr(lt_bg_highf_eng_trbl,sub(14,HB_Power_Q)); } @@ -148,7 +148,7 @@ Word16 update_decision(T_CldfbVadState *st, flag_high_eng = 0; move16(); - if (L_sub(HB_Power,lt_bg_highf_eng_trbl)>0) + if (GT_32(HB_Power,lt_bg_highf_eng_trbl)) { flag_high_eng = 1; move16(); @@ -158,7 +158,7 @@ Word16 update_decision(T_CldfbVadState *st, IF(sub(frameloop, 50) > 0) { - if(sub(ltd_stable_rate[0],3932/* 0.12 Q15 */)>0) + if(GT_16(ltd_stable_rate[0],3932/* 0.12 Q15 */)) { update_flag = 0; @@ -167,16 +167,16 @@ Word16 update_decision(T_CldfbVadState *st, tmpout= VAD_L_CMP(frame_energy, sub(frame_energy_Q,2), st->frame_energy_smooth,st->frame_energy_smooth_scale); test(); - IF((sub(bw, CLDFBVAD_NB_ID) != 0) && tmpout>0 ) + IF((NE_16(bw, CLDFBVAD_NB_ID))&&tmpout>0) { test(); - if((flag_high_eng) && (sub(sp_center3_diff, 409)> 0)) + if((flag_high_eng) && (GT_16(sp_center3_diff, 409))) { update_flag = 0; move16(); } test(); - if((sub(sp_center[3],2864/* 2.8 Q10 */) >0)&&(sub(ltd_stable_rate[0], 655/* 0.02 Q15 */)>0)) + if((GT_16(sp_center[3],2864/* 2.8 Q10 */))&&(GT_16(ltd_stable_rate[0],655/* 0.02 Q15 */))) { update_flag = 0; move16(); @@ -185,8 +185,8 @@ Word16 update_decision(T_CldfbVadState *st, } test(); - if((sub(f_tonality_rate[1], 8192/* 0.5 Q14 */)>0 ) - && (sub(ltd_stable_rate[0],3277/* 0.1 Q15 */)>0)) + if((GT_16(f_tonality_rate[1], 8192/* 0.5 Q14 */)) + && (GT_16(ltd_stable_rate[0],3277/* 0.1 Q15 */))) { update_flag = 0; move16(); @@ -194,9 +194,9 @@ Word16 update_decision(T_CldfbVadState *st, test(); test(); - IF((sub(sSFM[1], 30146/* 0.92 Q15 */) <0 ) - && (sub(sSFM[0], 30146/* 0.92 Q15 */)< 0) - && (sub(sSFM[2], 30146/* 0.92 Q15 */)< 0)) + IF((LT_16(sSFM[1], 30146/* 0.92 Q15 */)) + && (LT_16(sSFM[0], 30146/* 0.92 Q15 */)) + && (LT_16(sSFM[2], 30146/* 0.92 Q15 */))) { update_flag = 0; move16(); @@ -204,9 +204,9 @@ Word16 update_decision(T_CldfbVadState *st, test(); test(); - IF((sub(sSFM[0], 26214/* 0.8 Q15 */)<0 ) - || (sub(sSFM[1],25558/* 0.78 Q15 */) <0 ) - || (sub(sSFM[2],26214/* 0.8 Q15 */) <0 )) + IF((LT_16(sSFM[0], 26214/* 0.8 Q15 */)) + || (LT_16(sSFM[1],25558/* 0.78 Q15 */) ) + || (LT_16(sSFM[2],26214/* 0.8 Q15 */) )) { update_flag = 0; move16(); @@ -236,7 +236,7 @@ Word16 update_decision(T_CldfbVadState *st, test(); test(); if((cmp_result>0) - &&(L_sub(st->fg_energy_est_start,1)==0) + &&(EQ_32(st->fg_energy_est_start,1)) &&(tmpout>0)) { update_flag = 0; @@ -244,8 +244,8 @@ Word16 update_decision(T_CldfbVadState *st, } test(); - IF((sub(f_tonality_rate[1],9830/* 0.6 Q14 */)>0) - ||(sub(f_tonality_rate[0],14089/* 0.86 Q14 */)>0)) + IF((GT_16(f_tonality_rate[1],9830/* 0.6 Q14 */)) + ||(GT_16(f_tonality_rate[0],14089/* 0.86 Q14 */))) { update_flag = 0; move16(); @@ -261,15 +261,15 @@ Word16 update_decision(T_CldfbVadState *st, move16(); } - if(sub(st->tonality_rate3, 16384)>0) + if(GT_16(st->tonality_rate3, 16384)) { update_flag = 0; move16(); } test(); - if((sub(sp_center[0], 4092/* 4.0 Q10 */)> 0) - && (sub(ltd_stable_rate[0], 1311/* 0.04 Q15 */)>0)) + if((GT_16(sp_center[0], 4092/* 4.0 Q10 */)) + && (GT_16(ltd_stable_rate[0], 1311/* 0.04 Q15 */))) { update_flag = 0; move16(); @@ -277,9 +277,9 @@ Word16 update_decision(T_CldfbVadState *st, test(); test(); - IF((sub(f_tonality_rate[1], 7536/* 0.46 Q14 */)> 0) - && ((sub(sSFM[1],30473/* 0.93 Q15 */) > 0) - ||(sub(ltd_stable_rate[0], 2949/* 0.09 Q15 */)>0))) + IF((GT_16(f_tonality_rate[1], 7536/* 0.46 Q14 */)) + && ((GT_16(sSFM[1],30473/* 0.93 Q15 */) ) + ||(GT_16(ltd_stable_rate[0], 2949/* 0.09 Q15 */)))) { update_flag = 0; @@ -289,10 +289,10 @@ Word16 update_decision(T_CldfbVadState *st, test(); test(); test(); - IF( (sub(sSFM[1],30473/* 0.93 Q15 */) < 0 - && sub(sSFM[0], 30146/* 0.92 Q15 */)< 0 - && sub(sSFM[2], 31784/* 0.97 Q15 */)< 0) - && (sub(f_tonality_rate[1], 8192/* 0.5 Q14 */)> 0)) + IF( (LT_16(sSFM[1],30473/* 0.93 Q15 */) + && LT_16(sSFM[0], 30146/* 0.92 Q15 */) + && LT_16(sSFM[2], 31784/* 0.97 Q15 */)) + && (GT_16(f_tonality_rate[1], 8192/* 0.5 Q14 */))) { update_flag = 0; move16(); @@ -308,9 +308,9 @@ Word16 update_decision(T_CldfbVadState *st, move16(); } - IF(sub(update_flag, 1)==0) + IF(EQ_16(update_flag, 1)) { - if(sub(st->update_count, 1000) < 0) + if(LT_16(st->update_count, 1000)) { st->update_count = add(st->update_count,1); } @@ -333,9 +333,9 @@ Word16 update_decision(T_CldfbVadState *st, test(); test(); if((tmpout>0) - &&(sub(frameloop, 100) < 0) - &&(sub(f_tonality_rate[1],9174/* 0.56 Q14 */)<0) - &&((sub(sp_center[0], 1391/* 1.36 Q10 */)<0)||sub(ltd_stable_rate[0],983/* 0.03 Q15 */)<0)) + &&(LT_16(frameloop, 100) ) + &&(LT_16(f_tonality_rate[1],9174/* 0.56 Q14 */)) + &&((LT_16(sp_center[0], 1391/* 1.36 Q10 */))||LT_16(ltd_stable_rate[0],983/* 0.03 Q15 */))) { update_flag = 1; move16(); @@ -347,12 +347,12 @@ Word16 update_decision(T_CldfbVadState *st, test(); test(); test(); - if((L_sub(snr,10066329/* 0.3 Q25 */) <0) && tmpout < 0 - &&(L_sub(L_shr(tsnr,1), 20132659/* 1.2/2.0 Q25 */)<0) + if((LT_32(snr,10066329/* 0.3 Q25 */))&&tmpout<0 + &&(LT_32(L_shr(tsnr,1), 20132659/* 1.2/2.0 Q25 */)) &&(vad_flag==0) - &&(sub(st->f_tonality_rate[1],8192/* 0.5 Q14 */)<0) + &&(LT_16(st->f_tonality_rate[1],8192/* 0.5 Q14 */)) &&(music_backgound_f==0) - &&(sub(st->ltd_stable_rate[3],3277/* 0.1 Q15 */)<0)) + &&(LT_16(st->ltd_stable_rate[3],3277/* 0.1 Q15 */))) { update_flag = 1; move16(); @@ -361,7 +361,7 @@ Word16 update_decision(T_CldfbVadState *st, test(); test(); test(); - IF(vad_flag && L_sub(snr, 33554431/* 1.0 Q25 */)>0 && sub(bw, CLDFBVAD_SWB_ID)==0 && tmpout > 0) + IF(vad_flag && GT_32(snr, 33554431/* 1.0 Q25 */)&&EQ_16(bw,CLDFBVAD_SWB_ID)&&tmpout>0) { update_flag = 0; } @@ -369,7 +369,7 @@ Word16 update_decision(T_CldfbVadState *st, test(); test(); test(); - IF(vad_flag && L_sub(snr, 50331647/* 1.5 Q25 */)>0 && sub(bw, CLDFBVAD_SWB_ID)!=0 && tmpout > 0) + IF(vad_flag && GT_32(snr, 50331647/* 1.5 Q25 */)&&NE_16(bw,CLDFBVAD_SWB_ID)&&tmpout>0) { update_flag = 0; } @@ -383,21 +383,21 @@ Word16 update_decision(T_CldfbVadState *st, { test(); test(); - IF(vad_flag && L_sub(snr, 100663293/* 3.0 Q25 */)>0 && sub(st->updateNumWithSnr, 10) < 0) + IF(vad_flag && GT_32(snr, 100663293/* 3.0 Q25 */)&<_16(st->updateNumWithSnr,10)) { - update_flag = add(0, 0); + update_flag = 0; move16(); st->updateNumWithSnr = add(st->updateNumWithSnr, 1); } } test(); - IF(vad_flag==0||sub(update_flag,1) == 0) + IF(vad_flag==0||EQ_16(update_flag,1)) { Word16 tmp_fix; tmp_fix = sub(st->sp_center[2],st->lt_noise_sp_center0); tmp_fix = abs_s(tmp_fix); - if (sub(tmp_fix, 2558/* 2.5 Q10 */)>0) + if (GT_16(tmp_fix, 2558/* 2.5 Q10 */)) { tmp_fix = 2558/* 2.5 Q10 */; move16(); @@ -407,7 +407,7 @@ Word16 update_decision(T_CldfbVadState *st, st->lt_noise_sp_center_diff_counter = L_add(st->lt_noise_sp_center_diff_counter,1); move32(); - IF(L_sub(st->lt_noise_sp_center_diff_counter, 128)==0) + IF(EQ_32(st->lt_noise_sp_center_diff_counter, 128)) { st->lt_noise_sp_center_diff_sum = MUL_F(st->lt_noise_sp_center_diff_sum,24576); move32(); @@ -417,12 +417,12 @@ Word16 update_decision(T_CldfbVadState *st, move16(); move16(); - IF(sub((Word16)abs_s(sub(st->sp_center[0],st->lt_noise_sp_center0)), 2455/* 2.4 Q10 */) > 0) + IF(GT_16((Word16)abs_s(sub(st->sp_center[0],st->lt_noise_sp_center0)), 2455/* 2.4 Q10 */)) { st->lt_noise_sp_center0 = add(mult(st->lt_noise_sp_center0,32637),mult(st->sp_center[0],131)); move16(); } - ELSE IF(sub((Word16)abs_s(sub(st->sp_center[0],st->lt_noise_sp_center0)), 1023/* 1.0 Q10 */) >0) + ELSE IF(GT_16((Word16)abs_s(sub(st->sp_center[0],st->lt_noise_sp_center0)), 1023/* 1.0 Q10 */)) { st->lt_noise_sp_center0 = add(mult(st->lt_noise_sp_center0,32440),mult(st->sp_center[0],328)); move16(); @@ -454,7 +454,7 @@ Word16 update_decision(T_CldfbVadState *st, div_r =extract_l(L_shr(div_r_32, sub(div_r_Q, SP_CENTER_Q))); test(); - if((sub(abs_s(sub(st->sp_center[2],st->lt_noise_sp_center0)), div_r)> 0) && (sub(frameloop, 200)>0)) + if((GT_16(abs_s(sub(st->sp_center[2],st->lt_noise_sp_center0)), div_r))&&(GT_16(frameloop,200))) { update_flag = 0; move16(); diff --git a/lib_enc/updt_enc_fx.c b/lib_enc/updt_enc_fx.c index 6cc8438e4e5cf0bd9a7fbcc51e34bb8c14d49899..2a70be35ac7984aa1115e8fd260a52819f5e7526 100644 --- a/lib_enc/updt_enc_fx.c +++ b/lib_enc/updt_enc_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -7,8 +7,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*-------------------------------------------------------------------* * updt_enc() @@ -49,7 +47,7 @@ void updt_enc_fx( test(); test(); test(); - if( sub(coder_type,INACTIVE) == 0|| (sub(st->bpf_off_fx,1) == 0 && sub(coder_type,AUDIO) != 0 && sub(coder_type,TRANSITION) != 0) ) + if( EQ_16(coder_type,INACTIVE)||(EQ_16(st->bpf_off_fx,1)&&NE_16(coder_type,AUDIO)&&NE_16(coder_type,TRANSITION))) { st->last_coder_type_fx = UNVOICED; move16(); @@ -57,7 +55,7 @@ void updt_enc_fx( /* this ensures that st->last_coder_type_fx is never set to INACTIVE in case of AVQ inactive because the FEC does not distinguish between GSC inactive and AVQ inactive */ test(); - if ( sub(coder_type,INACTIVE) == 0 && L_sub(st->total_brate_fx,ACELP_24k40) > 0) + if ( EQ_16(coder_type,INACTIVE)&>_32(st->total_brate_fx,ACELP_24k40)) { st->last_coder_type_fx = GENERIC; move16(); @@ -66,7 +64,7 @@ void updt_enc_fx( test(); test(); test(); - IF( st->Opt_AMR_WB_fx && sub(coder_type,INACTIVE) == 0 && st->core_brate_fx != SID_1k75 && st->core_brate_fx != FRAME_NO_DATA ) + IF( st->Opt_AMR_WB_fx && EQ_16(coder_type,INACTIVE)&&st->core_brate_fx!=SID_1k75&&st->core_brate_fx!=FRAME_NO_DATA) { /* overwrite previous coding type to help FEC */ st->last_coder_type_fx = UNVOICED; @@ -75,7 +73,7 @@ void updt_enc_fx( /* AC mode (GSC) - in speech we can consider that the last pitch band reached the max */ test(); - IF ( sub(coder_type,AUDIO) != 0 && sub(coder_type,INACTIVE) != 0 ) + IF ( NE_16(coder_type,AUDIO)&&NE_16(coder_type,INACTIVE)) { st->mem_last_pit_band_fx = 10 + BAND1k2; move16(); @@ -88,16 +86,16 @@ void updt_enc_fx( } /* convert old LSP vector from 12kHz domain to 16kHz domain (needed in case of ACELP@12k8 <-> ACELP@16kHz switching) */ - IF( sub(L_frame,L_FRAME) == 0 ) + IF( EQ_16(L_frame,L_FRAME)) { Copy( st->lsp_old_fx, st->lsp_old16k_fx, M ); st->rate_switching_reset_16kHz=lsp_convert_poly_fx( st->lsp_old16k_fx, L_FRAME16k, st->Opt_AMR_WB_fx ); } /* update buffer of old subframe pitch values */ - IF( sub(st->last_L_frame_fx,L_frame) != 0 ) + IF( NE_16(st->last_L_frame_fx,L_frame)) { - IF( sub(L_frame,L_FRAME) == 0 ) + IF( EQ_16(L_frame,L_FRAME)) { FOR( i=0; ilast_core_fx,AMR_WB_CORE) == 0 ) /* switching to EVS primary mode */ + IF( EQ_16(st->last_core_fx,AMR_WB_CORE)) /* switching to EVS primary mode */ { /* reset onset detection counter */ st->tc_cnt_fx = -1; @@ -177,8 +175,7 @@ void updt_IO_switch_enc_fx( /* Perform preemphasis of the old input signal @16kHz */ st->mem_preemph16k_fx = 0; move16(); - /*preemph_fx(st->old_inp_16k_fx, PREEMPH_FAC_16k, L_INP_MEM, &(st->mem_preemph16k_fx));*/ - preemph_copy_fx( st->old_inp_16k_fx, st->old_inp_16k_fx, PREEMPH_FAC_16k, L_INP_MEM, &(st->mem_preemph16k_fx) ); + preemph_fx( st->old_inp_16k_fx, PREEMPH_FAC_16k, L_INP_MEM, &(st->mem_preemph16k_fx) ); Scale_sig(st->old_inp_16k_fx, L_INP_MEM, st->prev_Q_new); /* reset TD BWE buffers */ set16_fx( st->old_speech_shb_fx, 0, L_LOOK_16k + L_SUBFR16k ); @@ -195,14 +192,14 @@ void updt_IO_switch_enc_fx( wb_tbe_extras_reset_fx( st->mem_genSHBexc_filt_down_wb2_fx, st->mem_genSHBexc_filt_down_wb3_fx ); - IF( sub(input_frame,L_FRAME32k) >= 0 ) + IF( GE_16(input_frame,L_FRAME32k)) { swb_tbe_reset_fx( st->mem_csfilt_fx, st->mem_genSHBexc_filt_down_shb_fx, st->state_lpc_syn_fx, st->syn_overlap_fx, st->state_syn_shbexc_fx, &(st->tbe_demph_fx),&(st->tbe_premph_fx), st->mem_stp_swb_fx, &(st->gain_prec_swb_fx) ); } - IF( sub(input_frame,L_FRAME48k) == 0 ) + IF( EQ_16(input_frame,L_FRAME48k)) { set16_fx(st->fb_state_lpc_syn_fx, 0, LPC_SHB_ORDER); st->fb_tbe_demph_fx = 0; diff --git a/lib_enc/updt_tar_fx.c b/lib_enc/updt_tar_fx.c index 6dba3e30842297a9558d0cdff57687f2ecbaf81d..18be6ea7cadaef484df6ae4cbda56f7bd0bdfc74 100644 --- a/lib_enc/updt_tar_fx.c +++ b/lib_enc/updt_tar_fx.c @@ -1,12 +1,10 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*----------------------------------------------------------------------------------* * procedure updt_tar: diff --git a/lib_enc/vad_basop.c b/lib_enc/vad_basop.c index ffa3fd1290a2054ecda1097953ab5870bf6e8733..17fcd668d90459b122f204e94e9b5a2116ce2d99 100644 --- a/lib_enc/vad_basop.c +++ b/lib_enc/vad_basop.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -8,8 +8,6 @@ #include "vad_basop.h" #include "basop_util.h" #include "stl.h" -#include "wmc_auto.h" - #include "options.h" /* Needed for Stack Counting Mechanism Macros (when Instrumented) */ Word32 vad_Sqrt_l( /* o : output value, Q31 */ diff --git a/lib_enc/vad_basop.h b/lib_enc/vad_basop.h index a4a648339e7732b8f61a3d367f34ab8c3f9429f8..52fb1bb00f7c60587526bbe7ddb0efd881230793 100644 --- a/lib_enc/vad_basop.h +++ b/lib_enc/vad_basop.h @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #ifndef __VAD_BASOP_H__ diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index ed50ecceee076efa621adad9124a4a46ba5286a0..d35f8c6eb12b089ac0ab0bceb24611f0d975df45 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ @@ -7,8 +7,6 @@ #include "prot_fx.h" /* Function prototypes */ #include "rom_enc_fx.h" #include "stl.h" -#include "wmc_auto.h" - @@ -171,13 +169,13 @@ void sign_thr_snr_acc_fx( Word32 L_tmp; L_tmp = L_deposit_l(min_snr); - if( L_sub(L_snr, L_deposit_l(sign_thr)) >= 0 ) + if( GE_32(L_snr, L_deposit_l(sign_thr))) { L_tmp = L_add(L_snr, 0); } - BASOP_SATURATE_WARNING_OFF; /* may saturate in BASOP */ + BASOP_SATURATE_WARNING_OFF /* may saturate in BASOP */ *L_snr_sum = L_add(*L_snr_sum, L_tmp); /* Q4 */ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON } /*-----------------------------------------------------------------* @@ -208,27 +206,27 @@ Word16 dtx_hangover_addition_fx( test(); test(); - if ( ( ( sub(lp_snr,(16*256)) < 0 ) - && ( sub(st_fx->input_bwidth_fx, NB) != 0 )) - || ( sub(st_fx->prim_act_he_fx, 31130) > 0 ) ) /*.95*Q15*/ + if ( ( ( LT_16(lp_snr,(16*256))) + && ( NE_16(st_fx->input_bwidth_fx, NB) )) + || ( GT_16(st_fx->prim_act_he_fx, 31130) ) ) /*.95*Q15*/ { hangover_short_dtx = 3; move16(); } /* Adjust hangover according to activity history */ - if (sub(st_fx->vad_prim_cnt_16_fx, 12) > 0 ) /* 12 requires roughly > 80% primary activity */ + if (GT_16(st_fx->vad_prim_cnt_16_fx, 12)) /* 12 requires roughly > 80% primary activity */ { hangover_short_dtx = add(hangover_short_dtx,2); } - if (sub(st_fx->vad_flag_cnt_50_fx, 40) > 0) /* 40 requires roughtly > 80% flag activity */ + if (GT_16(st_fx->vad_flag_cnt_50_fx, 40)) /* 40 requires roughtly > 80% flag activity */ { hangover_short_dtx = add(hangover_short_dtx,5); } /* Keep hangover_short lower than maximum hangover count */ - if (sub(hangover_short_dtx, HANGOVER_LONG_FX-1) > 0 ) + if (GT_16(hangover_short_dtx, HANGOVER_LONG_FX-1)) { hangover_short_dtx = (HANGOVER_LONG_FX-1); move16(); @@ -238,7 +236,7 @@ Word16 dtx_hangover_addition_fx( tmp = 3; move16(); /* default for EVS*/ - if (sub(st_fx->core_fx,AMR_WB_CORE) == 0 ) + if (EQ_16(st_fx->core_fx,AMR_WB_CORE)) { tmp = 2; move16(); /* default for AMRWBIO*/ @@ -247,9 +245,9 @@ Word16 dtx_hangover_addition_fx( /* need to be a bit stricter with the DTXHO in very clean WB, SWB cond for EVS12k8VAD section */ test(); test(); - if ( ( sub(st_fx->input_bwidth_fx, NB) != 0 ) /* WB or SWB or FB */ - && ( sub(st_fx->core_fx, AMR_WB_CORE) != 0 ) - && ( sub(lp_snr, 25*256) > 0 ) + if ( ( NE_16(st_fx->input_bwidth_fx, NB)) /* WB or SWB or FB */ + && ( NE_16(st_fx->core_fx, AMR_WB_CORE) ) + && ( GT_16(lp_snr, 25*256) ) ) { tmp = 2; @@ -262,10 +260,10 @@ Word16 dtx_hangover_addition_fx( test(); test(); test(); - if ( (sub(hangover_short_dtx, tmp) > 0 ) - && ( (sub(st_fx->vad_prim_cnt_16_fx, 7) < 0 ) - || ( (sub(lp_snr, (16*256)) > 0) - && (sub(st_fx->prim_act_he_fx, 27853) < 0) /*0.85f*2^15 */ + if ( (GT_16(hangover_short_dtx, tmp)) + && ( (LT_16(st_fx->vad_prim_cnt_16_fx, 7) ) + || ( (GT_16(lp_snr, (16*256)) ) + && (LT_16(st_fx->prim_act_he_fx, 27853) ) /*0.85f*2^15 */ ) ) ) @@ -277,7 +275,7 @@ Word16 dtx_hangover_addition_fx( /* hangover adjustment from combined FFT+CLDFBVAD */ - IF (sub(st_fx->core_fx,AMR_WB_CORE) != 0 ) + IF (NE_16(st_fx->core_fx,AMR_WB_CORE)) { hangover_short_dtx = sub(hangover_short_dtx, cldfb_subtraction); hangover_short_dtx = s_max(hangover_short_dtx, 0); @@ -290,8 +288,8 @@ Word16 dtx_hangover_addition_fx( /* Add hangover after sufficient # of active frames or sufficient activity during last second */ test(); - if ( ( sub(st_fx->nb_active_frames_fx, ACTIVE_FRAMES_FX) >=0 ) - || (sub(st_fx->vad_flag_cnt_50_fx,45) > 0) ) /* 45 requires roughly > 90% flag activity */ + if ( ( GE_16(st_fx->nb_active_frames_fx, ACTIVE_FRAMES_FX)) + || (GT_16(st_fx->vad_flag_cnt_50_fx,45)) ) /* 45 requires roughly > 90% flag activity */ { st_fx->hangover_cnt_dtx_fx = 0; move16(); @@ -299,7 +297,7 @@ Word16 dtx_hangover_addition_fx( /* inside HO period */ test(); - if( ( sub(st_fx->hangover_cnt_dtx_fx, HANGOVER_LONG_FX) < 0) + if( ( LT_16(st_fx->hangover_cnt_dtx_fx, HANGOVER_LONG_FX)) && (st_fx->hangover_cnt_dtx_fx != 0) ) { st_fx->hangover_cnt_dtx_fx = add(st_fx->hangover_cnt_dtx_fx, 1); @@ -311,10 +309,10 @@ Word16 dtx_hangover_addition_fx( test(); test(); test(); - if ( (sub(st_fx->prim_act_he_fx,31129) > 0) - && (sub(st_fx->Etot_lp_fx,40*256) > 0) - && (sub(st_fx->vad_prim_cnt_16_fx,14) > 0) - && (sub(st_fx->vad_flag_cnt_50_fx,48) > 0) ) /* 45 requires roughly > 95% flag activity */ + if ( (GT_16(st_fx->prim_act_he_fx,31129)) + && (GT_16(st_fx->Etot_lp_fx,40*256) ) + && (GT_16(st_fx->vad_prim_cnt_16_fx,14) ) + && (GT_16(st_fx->vad_flag_cnt_50_fx,48) ) ) /* 45 requires roughly > 95% flag activity */ { st_fx->hangover_cnt_music_fx = 0; move16(); @@ -322,7 +320,7 @@ Word16 dtx_hangover_addition_fx( /* inside Music HO period */ test(); - if( ( sub(st_fx->hangover_cnt_music_fx, HANGOVER_LONG_MUSIC_FX) < 0) + if( ( LT_16(st_fx->hangover_cnt_music_fx, HANGOVER_LONG_MUSIC_FX)) && (st_fx->hangover_cnt_music_fx != 0) ) { st_fx->hangover_cnt_music_fx = add(st_fx->hangover_cnt_music_fx, 1); @@ -331,11 +329,11 @@ Word16 dtx_hangover_addition_fx( ELSE { /* Reset the counter of speech frames necessary to start hangover algorithm */ - if(sub(st_fx->hangover_cnt_dtx_fx,HANGOVER_LONG_FX) <0 ) /* inside HO period */ + if(LT_16(st_fx->hangover_cnt_dtx_fx,HANGOVER_LONG_FX)) /* inside HO period */ { st_fx->hangover_cnt_dtx_fx = add(st_fx->hangover_cnt_dtx_fx,1); } - if(sub(st_fx->hangover_cnt_music_fx,HANGOVER_LONG_MUSIC_FX) <0 ) /* inside HO period */ + if(LT_16(st_fx->hangover_cnt_music_fx,HANGOVER_LONG_MUSIC_FX)) /* inside HO period */ { st_fx->hangover_cnt_music_fx = add(st_fx->hangover_cnt_music_fx,1); } @@ -350,20 +348,20 @@ Word16 dtx_hangover_addition_fx( st_fx->hangover_terminate_flag_fx = 0; move16(); /* Only shorten music hangover when low energy frames */ - if (sub(st_fx->Etot_lp_fx,20*256)<0) + if (LT_16(st_fx->Etot_lp_fx,20*256)) { st_fx->hangover_cnt_music_fx = HANGOVER_LONG_MUSIC_FX; move16(); } } - if( sub(st_fx->hangover_cnt_dtx_fx, hangover_short_dtx) <= 0) /* "hard" hangover */ + if( LE_16(st_fx->hangover_cnt_dtx_fx, hangover_short_dtx)) /* "hard" hangover */ { flag_dtx = 1; move16(); } - if( sub(st_fx->hangover_cnt_music_fx, 15) <= 0) /* "hard" hangover music */ + if( LE_16(st_fx->hangover_cnt_music_fx, 15)) /* "hard" hangover music */ { flag_dtx = 1; move16(); @@ -459,7 +457,7 @@ Word16 wb_vad_fx( L_msnr19 = L_deposit_l(8192); /* 1.0 Q13 */ - IF( sub(vad_bwidth_fx, NB) == 0) + IF( EQ_16(vad_bwidth_fx, NB)) { st_fx->min_band_fx = 1; move16(); @@ -477,7 +475,7 @@ Word16 wb_vad_fx( /*---------------------------------------------------------------------* * set SNR thresholds depending on the input bandwitdh *---------------------------------------------------------------------*/ - IF( sub(st_fx->max_band_fx,19) == 0 ) /* WB input */ /* or SWB input */ + IF( EQ_16(st_fx->max_band_fx,19)) /* WB input */ /* or SWB input */ { nk = 3277; move16(); /*0.1 Q15 */ @@ -553,12 +551,12 @@ Word16 wb_vad_fx( snr_idx = 2; move16(); - if( sub(lp_snr,4608) > 0 ) /*18.0 Q8*/ + if( GT_16(lp_snr,4608)) /*18.0 Q8*/ { snr_idx = 1; move16(); } - if ( sub(lp_snr,6144) > 0 ) /*24.0 Q8*/ + if ( GT_16(lp_snr,6144)) /*24.0 Q8*/ { snr_idx = 0; move16(); @@ -587,7 +585,7 @@ Word16 wb_vad_fx( L_vad_thr = L_mac0(L_vad_thr,77,lp_snr) ; /* (2.4)Q5*(lp_snr)Q8 */ L_vad_thr = L_min(L_vad_thr, 80*(1<<13) ); } - ELSE IF ( sub(snr_idx,1) == 0 ) + ELSE IF ( EQ_16(snr_idx,1)) { stmp = 6; move16(); @@ -661,7 +659,7 @@ Word16 wb_vad_fx( L_tmp2 = Madd_32_16(L_tmp, ftmp, 19661); /* 19661 = 0.3 in Q16 */ L_tmp2 = Msub_32_16(L_tmp2, ftmp1, -32768); /* -32768= -0.5 in Q16 */ - IF (L_sub(ftmp,ftmp1) > 0) + IF (GT_32(ftmp,ftmp1)) { /*snr[i] = ( 0.2f * st->enrO[i] + 0.4f * ftmp + 0.4f * ftmp1 ) / ftmp2 ;*/ /*snr[i] = L_tmp1/(ftmp2) */ @@ -728,7 +726,7 @@ Word16 wb_vad_fx( } } - if(L_sub(L_snr,2*(1<<4))<0 ) + if(LT_32(L_snr,2*(1<<4))) { nb_sig_snr=sub(nb_sig_snr,1); /* nb_sig_snr--; */ } @@ -743,15 +741,15 @@ Word16 wb_vad_fx( tmp = shl(snr,5); /* Q8 -> Q13 */ - IF (sub(i,2) < 0) + IF (LT_16(i,2)) { tmp = add(tmp,delta1); /*Q13 */ } - ELSE IF (sub(i,7) < 0) + ELSE IF (LT_16(i,7)) { tmp = add(tmp,delta2); /*Q13 */ } - ELSE IF (sub(i,18) < 0) + ELSE IF (LT_16(i,18)) { tmp = add(tmp,delta3); /*Q13 */ } @@ -779,12 +777,12 @@ Word16 wb_vad_fx( } L_mssnr = L_add(L_mssnr,L_msnr); /*Q13 mssnr += msnr;*/ - if ( sub(i,18) == 0 ) + if ( EQ_16(i,18)) { L_msnr18 = L_add(L_msnr, 0); /*Q13 msnr18 = msnr; */ } - if ( sub(i,19) == 0 ) + if ( EQ_16(i,19)) { L_msnr19 = L_add(L_msnr, 0); /* Q13 , msnr19 = msnr; */ } @@ -837,17 +835,17 @@ Word16 wb_vad_fx( /* float saves all snrs in an snr[] vector , in fix we only save two bands */ - if ( sub(i,18) == 0 ) + if ( EQ_16(i,18)) { L_snr18 = L_add(L_snr, 0); /*Q4 */ } - if ( sub(i,19) == 0 ) + if ( EQ_16(i,19)) { L_snr19 = L_add(L_snr, 0); /* Q4 */ } /* accumulate background noise energy in bands [0-2] and in bands [3-19]*/ - IF(sub(i,3) < 0) + IF(LT_16(i,3)) { L_accum_ener_L = L_add(L_accum_ener_L , st_fx->bckr_fx[i]);/*Q_new+QSCALE */ } @@ -857,7 +855,7 @@ Word16 wb_vad_fx( } /* Identify the outlier band */ - IF( L_sub(L_snr, L_snr_outlier) > 0 ) + IF( GT_32(L_snr, L_snr_outlier)) { L_snr_outlier = L_add(L_snr, 0); /*Q4*/ snr_outlier_index = i; @@ -868,22 +866,22 @@ Word16 wb_vad_fx( test(); test(); test(); /* one additional test for ELSE IF */ - IF ( (sub(st_fx->max_band_fx, 19) == 0 ) - && ( L_sub(L_snr18, 5*(1<<4)) > 0 ) - && ( L_sub(L_snr19, 5*(1<<4)) > 0 ) ) + IF ( (EQ_16(st_fx->max_band_fx, 19)) + && ( GT_32(L_snr18, 5*(1<<4)) ) + && ( GT_32(L_snr19, 5*(1<<4)) ) ) { /* mssnr = (mssnr + 3*(msnr18 + msnr19)) * 0.77f; */ /* mssnr = (mssnr*.77f + 2.31f*(msnr18 + msnr19)); */ L_tmp1 = Mult_32_16(L_mssnr, 25231 ); /* Q13+Q15+1-16 --> Q13 */ L_tmp = Mult_32_16(L_shl(L_add(L_msnr18, L_msnr19),2),18924 ); /* Q(13+2)+Q(15-2)+1-16 --> Q13 */ L_tmp = L_add( L_tmp1, L_tmp); - if ( L_sub(L_tmp, L_mssnr) > 0 ) + if ( GT_32(L_tmp, L_mssnr)) { L_mssnr = L_tmp; } } ELSE IF ( (snr_idx != 0) - && sub(nb_sig_snr, 13) > 0 ) + && GT_16(nb_sig_snr, 13) ) { L_tmp = -126976; move32() ; /* -15.5 Q13 */ @@ -901,10 +899,10 @@ Word16 wb_vad_fx( test(); test(); test(); - IF( ( sub(st_fx->max_band_fx, 19) == 0 ) - && L_sub(L_snr_outlier , MAX_SNR_OUTLIER_3_FX) < 0 - && sub(snr_outlier_index, 3) > 0 - && sub(snr_outlier_index, MAX_SNR_OUTLIER_IND_FX) < 0) + IF( ( EQ_16(st_fx->max_band_fx, 19)) + && LT_32(L_snr_outlier , MAX_SNR_OUTLIER_3_FX) + && GT_16(snr_outlier_index, 3) + && LT_16(snr_outlier_index, MAX_SNR_OUTLIER_IND_FX) ) { /* Update the total SNR only for WB signals */ @@ -926,16 +924,16 @@ Word16 wb_vad_fx( test(); test(); - IF( L_sub(L_accum_ener_H, Mult_32_16(L_accum_ener_L,INV_OUTLIER_THR_1_FX)) < 0 /* float:: (accum_ener_L*INV_OUTLIER_THR_1 > accum_ener_H ) !!! */ - || L_sub(L_snr_outlier,MAX_SNR_OUTLIER_1_FX) < 0 ) + IF( LT_32(L_accum_ener_H, Mult_32_16(L_accum_ener_L,INV_OUTLIER_THR_1_FX))/* float:: (accum_ener_L*INV_OUTLIER_THR_1 > accum_ener_H ) !!! */ + || LT_32(L_snr_outlier,MAX_SNR_OUTLIER_1_FX) ) { /* as weight1 is 1.0 we do not need to multiply here , i.e. no need to loose any precisison */ L_snr_sum_ol = L_sub(L_snr_sum_ol,L_snr_outlier); /*Q4 */ } - ELSE IF( L_sub(L_accum_ener_H, Mult_32_16(L_accum_ener_L,INV_OUTLIER_THR_2_FX)) < 0 /* float:: (accum_ener_L *INV_OUTLIER_THR_2 > accum_ener_H ) !!! */ - || L_sub(L_snr_outlier,MAX_SNR_OUTLIER_2_FX) < 0 ) + ELSE IF( LT_32(L_accum_ener_H, Mult_32_16(L_accum_ener_L,INV_OUTLIER_THR_2_FX))/* float:: (accum_ener_L *INV_OUTLIER_THR_2 > accum_ener_H ) !!! */ + || LT_32(L_snr_outlier,MAX_SNR_OUTLIER_2_FX) ) { /* L_snr_sum = SNR_OUTLIER_WGHT_2 * (snr_sum - snr_outlier); */ @@ -975,11 +973,11 @@ Word16 wb_vad_fx( lp_snr = sub(st_fx->lp_speech_fx,st_fx->lp_noise_fx); /*Q8*/ sub(0,0); - IF ( sub(lp_snr, st_fx->sign_dyn_lp_fx) <0 ) + IF ( LT_16(lp_snr, st_fx->sign_dyn_lp_fx)) { lp_snr = add(lp_snr,1<<8); /* lp_snr += 1; */ - if (sub(lp_snr, st_fx->sign_dyn_lp_fx) > 0 ) + if (GT_16(lp_snr, st_fx->sign_dyn_lp_fx)) { lp_snr = st_fx->sign_dyn_lp_fx; move16(); @@ -993,7 +991,7 @@ Word16 wb_vad_fx( thr1 = mac_r(L_tmp, lp_snr, nk ); /* Q8+Q15+1 - 16 --> Q8 */ - IF (sub(lp_snr, (Word16)20*(1<<8)) > 0 ) /* if (lp_snr > 20.0f )*/ + IF (GT_16(lp_snr, (Word16)20*(1<<8))) /* if (lp_snr > 20.0f )*/ { /* thr1 = thr1 + 0.3f * (lp_snr - 20.0f); */ thr1 = add(thr1, mult(9830, sub(lp_snr,(Word16) 20*(1<<8) ))); /* Q15*Q8+1 -16 --> Q8 */ @@ -1001,10 +999,10 @@ Word16 wb_vad_fx( test(); test(); test(); - if( sub(st_fx->max_band_fx,16) == 0 - && sub(lp_snr,40*256) > 0 - && sub(thr1,6600) > 0 - && sub(st_fx->lp_speech_fx,11520) < 0 ) + if( EQ_16(st_fx->max_band_fx,16) + && GT_16(lp_snr,40*256) + && GT_16(thr1,6600) + && LT_16(st_fx->lp_speech_fx,11520) ) { thr1 = 6600; } @@ -1019,7 +1017,7 @@ Word16 wb_vad_fx( * Hangover control & final VAD decision *---------------------------------------------------------------------*/ - IF( sub(vad_bwidth_fx, NB) != 0 ) + IF( NE_16(vad_bwidth_fx, NB)) { /* Outlier Detection first calculates thr1_ol and snr_sum_ol instead of @@ -1030,7 +1028,7 @@ Word16 wb_vad_fx( hangover_short = 3; move16(); - IF( sub(lp_snr,th_clean) < 0 ) + IF( LT_16(lp_snr,th_clean)) { hangover_short = 4; move16(); @@ -1046,8 +1044,8 @@ Word16 wb_vad_fx( test(); test(); test(); - IF( ( (sub(snr_outlier_index, 4) <= 0) && (sub(st_fx->last_coder_type_fx, UNVOICED) > 0) && ( st_fx->Opt_SC_VBR_fx != 0 ) ) || - ( (sub(snr_outlier_index, 4) <= 0) && (sub(st_fx->last_7k2_coder_type_fx, UNVOICED) > 0) && ( st_fx->Opt_SC_VBR_fx == 0 ) ) ) + IF( ( (LE_16(snr_outlier_index, 4))&&(GT_16(st_fx->last_coder_type_fx,UNVOICED))&&(st_fx->Opt_SC_VBR_fx!=0))|| + ( (LE_16(snr_outlier_index, 4)) && (GT_16(st_fx->last_7k2_coder_type_fx, UNVOICED) ) && ( st_fx->Opt_SC_VBR_fx == 0 ) ) ) { @@ -1056,8 +1054,8 @@ Word16 wb_vad_fx( snr_sum_ol = vad_snr_log_fx(st_fx->L_snr_sum_vad_fx, LG10); /* snr in Q8 */ } - ELSE IF ( ((sub(st_fx->last_coder_type_fx, UNVOICED) <= 0) && (L_sub(L_snr_outlier,MAX_SNR_OUTLIER_2_FX) < 0) && (st_fx->Opt_SC_VBR_fx != 0) ) || - ((sub(st_fx->last_7k2_coder_type_fx, UNVOICED) <= 0) && (L_sub(L_snr_outlier,MAX_SNR_OUTLIER_2_FX) < 0) && ( st_fx->Opt_SC_VBR_fx == 0 ) ) ) + ELSE IF ( ((LE_16(st_fx->last_coder_type_fx, UNVOICED))&&(LT_32(L_snr_outlier,MAX_SNR_OUTLIER_2_FX))&&(st_fx->Opt_SC_VBR_fx!=0))|| + ((LE_16(st_fx->last_7k2_coder_type_fx, UNVOICED) ) && (LT_32(L_snr_outlier,MAX_SNR_OUTLIER_2_FX)) && ( st_fx->Opt_SC_VBR_fx == 0 ) ) ) { /* thr1_ol = thr1 + (float)(1.0f - 0.04f * snr_outlier); */ @@ -1089,13 +1087,13 @@ Word16 wb_vad_fx( flag_he1 = 0; move16(); - IF ( L_sub(L_mssnr, L_vad_thr) > 0 ) + IF ( GT_32(L_mssnr, L_vad_thr)) { flag_he1 = 1; move16(); /* he1 primary decision */ st_fx->nb_active_frames_he1_fx = add(st_fx->nb_active_frames_he1_fx,1); /* Counter of consecutive active speech frames */ - IF ( sub(st_fx->nb_active_frames_he1_fx,ACTIVE_FRAMES_FX) >= 0 ) + IF ( GE_16(st_fx->nb_active_frames_he1_fx,ACTIVE_FRAMES_FX)) { st_fx->nb_active_frames_he1_fx = ACTIVE_FRAMES_FX; move16(); @@ -1125,9 +1123,9 @@ Word16 wb_vad_fx( - IF ( sub(st_fx->voiced_burst_fx, 3) > 0 ) + IF ( GT_16(st_fx->voiced_burst_fx, 3)) { - IF ( sub(st_fx->bcg_flux_fx, 640) < 0 ) /* Q4 */ + IF ( LT_16(st_fx->bcg_flux_fx, 640)) /* Q4 */ { st_fx->soft_hangover_fx = hangover_sf_tbl_fx[add(snr_idx,3)]; move16(); @@ -1143,7 +1141,7 @@ Word16 wb_vad_fx( hangover_hd = hangover_hd_tbl_fx[snr_idx]; move16(); - IF ( sub(st_fx->bcg_flux_fx, 640) < 0 ) + IF ( LT_16(st_fx->bcg_flux_fx, 640)) { hangover_hd = add(shr(hangover_hd,1), 1); move16(); @@ -1153,7 +1151,7 @@ Word16 wb_vad_fx( test(); IF ( flag_he1 == 0 && st_fx->soft_hangover_fx > 0 ) { - IF ( L_sub(L_mssnr_hov, L_vad_thr) > 0 ) + IF ( GT_32(L_mssnr_hov, L_vad_thr)) { flag_he1 = 1; move16(); @@ -1175,7 +1173,7 @@ Word16 wb_vad_fx( test(); test(); IF ( (flag_he1 == 0) - && (sub(st_fx->hangover_cnt_he1_fx, hangover_hd) < 0 ) + && (LT_16(st_fx->hangover_cnt_he1_fx, hangover_hd) ) && (st_fx->soft_hangover_fx == 0 ) ) { flag_he1 = 1; @@ -1189,11 +1187,11 @@ Word16 wb_vad_fx( test(); IF ( flag_he1 == 0 && st_fx->first_noise_updt_fx > 0 ) { - IF ( sub(snr_sumt, st_fx->bcg_flux_fx) > 0 ) + IF ( GT_16(snr_sumt, st_fx->bcg_flux_fx)) { IF ( st_fx->bcg_flux_init_fx-- > 0 ) { - IF ( sub(snr_sumt,add(st_fx->bcg_flux_fx,800)) > 0 ) + IF ( GT_16(snr_sumt,add(st_fx->bcg_flux_fx,800))) { /*st->bcg_flux = 0.9f * st->bcg_flux + (1-0.9f)*(st->bcg_flux+50);*/ st_fx->bcg_flux_fx = mac_r(L_mult(st_fx->bcg_flux_fx,29491),add(st_fx->bcg_flux_fx,800),3277); /*Q4 */ @@ -1206,7 +1204,7 @@ Word16 wb_vad_fx( } ELSE { - IF ( sub(snr_sumt,add(st_fx->bcg_flux_fx,160)) > 0 ) + IF ( GT_16(snr_sumt,add(st_fx->bcg_flux_fx,160))) { /*st->bcg_flux = 0.99f * st->bcg_flux + (1-0.99f)*(st->bcg_flux+10);*/ st_fx->bcg_flux_fx = mac_r(L_mult(st_fx->bcg_flux_fx,32440),add(st_fx->bcg_flux_fx,160),328); /*Q4 */ @@ -1222,7 +1220,7 @@ Word16 wb_vad_fx( { IF ( st_fx->bcg_flux_init_fx-- > 0 ) { - IF ( sub(snr_sumt,sub(st_fx->bcg_flux_fx,480)) < 0 ) + IF ( LT_16(snr_sumt,sub(st_fx->bcg_flux_fx,480))) { /*st->bcg_flux = 0.95f * st->bcg_flux + (1-0.95f)*(st->bcg_flux-30);*/ st_fx->bcg_flux_fx = mac_r(L_mult(st_fx->bcg_flux_fx,31130),sub(st_fx->bcg_flux_fx,480),1638); /*Q4 */ @@ -1235,7 +1233,7 @@ Word16 wb_vad_fx( } ELSE { - IF ( sub(snr_sumt,sub(st_fx->bcg_flux_fx,160)) < 0 ) + IF ( LT_16(snr_sumt,sub(st_fx->bcg_flux_fx,160))) { /*st->bcg_flux = 0.9992f * st->bcg_flux + (1-0.9992f)*(st->bcg_flux-10);*/ st_fx->bcg_flux_fx = mac_r(L_mult(st_fx->bcg_flux_fx,32742),sub(st_fx->bcg_flux_fx,160),26); /*Q4 */ @@ -1258,7 +1256,7 @@ Word16 wb_vad_fx( /* if ( snr_sum > thr1 && flag_he1 == 1 ) *//* Speech present */ test(); - IF ( (sub(snr_sum, thr1) > 0) && (sub(flag_he1,1) == 0)) /* Speech present */ + IF ( (GT_16(snr_sum, thr1))&&(EQ_16(flag_he1,1))) /* Speech present */ { flag = 1; move16(); @@ -1267,7 +1265,7 @@ Word16 wb_vad_fx( st_fx->nb_active_frames_fx = add(st_fx->nb_active_frames_fx,1); /* Counter of consecutive active speech frames */ - IF ( sub(st_fx->nb_active_frames_fx,ACTIVE_FRAMES_FX) >= 0 ) + IF ( GE_16(st_fx->nb_active_frames_fx,ACTIVE_FRAMES_FX)) { st_fx->nb_active_frames_fx = ACTIVE_FRAMES_FX; move16(); @@ -1277,7 +1275,7 @@ Word16 wb_vad_fx( /* inside HO period */ test(); - if( sub(st_fx->hangover_cnt_fx,HANGOVER_LONG_FX) < 0 + if( LT_16(st_fx->hangover_cnt_fx,HANGOVER_LONG_FX) && st_fx->hangover_cnt_fx != 0 ) { st_fx->hangover_cnt_fx = add(st_fx->hangover_cnt_fx,1); @@ -1289,28 +1287,28 @@ Word16 wb_vad_fx( st_fx->nb_active_frames_fx = 0; move16(); - if( sub(st_fx->hangover_cnt_fx,HANGOVER_LONG_FX) < 0 ) /* inside HO period */ + if( LT_16(st_fx->hangover_cnt_fx,HANGOVER_LONG_FX)) /* inside HO period */ { st_fx->hangover_cnt_fx = add(st_fx->hangover_cnt_fx,1); } - IF( sub(st_fx->hangover_cnt_fx, hangover_short) <= 0 ) /* "hard" hangover */ + IF( LE_16(st_fx->hangover_cnt_fx, hangover_short)) /* "hard" hangover */ { test(); test(); - if ( (sub(lp_snr,th_clean) < 0) + if ( (LT_16(lp_snr,th_clean)) && (st_fx->Opt_SC_VBR_fx != 0 ) - && (sub(st_fx->hangover_cnt_fx, 2) >= 0) ) + && (GE_16(st_fx->hangover_cnt_fx, 2)) ) { *noisy_speech_HO = 1; move16(); } test(); test(); - if ( (sub(lp_snr,th_clean) >= 0) + if ( (GE_16(lp_snr,th_clean)) && (st_fx->Opt_SC_VBR_fx != 0 ) - && (sub(st_fx->hangover_cnt_fx, 2) >= 0) ) + && (GE_16(st_fx->hangover_cnt_fx, 2) ) ) { *clean_speech_HO = 1; move16(); @@ -1327,8 +1325,8 @@ Word16 wb_vad_fx( move16(); test(); - IF ( (sub(snr_sum_HE_SAD, thr1) > 0) - && (sub(flag_he1, 1) == 0) ) /* Speech present */ + IF ( (GT_16(snr_sum_HE_SAD, thr1)) + && (EQ_16(flag_he1, 1) ) ) /* Speech present */ { *localVAD_HE_SAD = 1; @@ -1347,7 +1345,7 @@ Word16 wb_vad_fx( /* Add localVAD_HE_SAD also for NB operation for use with speech music classifier */ *localVAD_HE_SAD = 0; move16(); - if (sub(snr_sum_HE_SAD, thr1) > 0 ) + if (GT_16(snr_sum_HE_SAD, thr1)) { *localVAD_HE_SAD = 1; move16(); @@ -1355,10 +1353,10 @@ Word16 wb_vad_fx( *localVAD = 0; move16(); /* safety inits for fx */ - IF ( sub(snr_sum,thr1) > 0 ) /* Speech present, possibly in hangover */ + IF ( GT_16(snr_sum,thr1)) /* Speech present, possibly in hangover */ { st_fx->nb_active_frames_fx = add(st_fx->nb_active_frames_fx,1); /* Counter of consecutive active speech frames */ - IF ( sub(st_fx->nb_active_frames_fx,ACTIVE_FRAMES_FX) >= 0 ) + IF ( GE_16(st_fx->nb_active_frames_fx,ACTIVE_FRAMES_FX)) { st_fx->nb_active_frames_fx = ACTIVE_FRAMES_FX; move16(); @@ -1378,15 +1376,15 @@ Word16 wb_vad_fx( thr1_nb_mod = thr1; move16(); /* thr1 may be adjusted after this point */ - IF( sub(st_fx->hangover_cnt_fx,HANGOVER_LONG_NB_FX) < 0) + IF( LT_16(st_fx->hangover_cnt_fx,HANGOVER_LONG_NB_FX)) { st_fx->hangover_cnt_fx = add(st_fx->hangover_cnt_fx,1); - IF( sub(lp_snr, 4864 ) < 0) /*19.0f Q8*/ /* very low SNR */ + IF( LT_16(lp_snr, 4864 )) /*19.0f Q8*/ /* very low SNR */ { thr1_nb_mod = sub(thr1_nb_mod , 1331); /*thr1 -= 5.2f;*/ } - ELSE IF( sub(lp_snr, 8960) < 0 ) /*35 in Q8 */ /* low SNR */ + ELSE IF( LT_16(lp_snr, 8960)) /*35 in Q8 */ /* low SNR */ { thr1_nb_mod = sub(thr1_nb_mod , 512); /*thr1 -= 2.0f;*/ } @@ -1403,7 +1401,7 @@ Word16 wb_vad_fx( tmp = 282; move16(); /* 1.10f; */ } - if (sub(lp_snr,th_clean) < 0) + if (LT_16(lp_snr,th_clean)) { thr2 = sub(thr1_nb_mod, tmp); /*thr2 = thr1 - [ 1.10 || 1.3 ];*/ } @@ -1411,7 +1409,7 @@ Word16 wb_vad_fx( flag = 0; move16(); - IF ( sub(snr_sum, thr1_nb_mod) > 0 ) /* Speech assumed present, even though lowered thr1 */ + IF ( GT_16(snr_sum, thr1_nb_mod)) /* Speech assumed present, even though lowered thr1 */ { flag = 1; move16(); @@ -1420,8 +1418,8 @@ Word16 wb_vad_fx( test(); - IF ( (sub(snr_sum, thr1_nb_mod) < 0) - && (sub(snr_sum, thr2) > 0) ) /* Speech present */ + IF ( (LT_16(snr_sum, thr1_nb_mod)) + && (GT_16(snr_sum, thr2)) ) /* Speech present */ { flag = 1; move16(); @@ -1441,7 +1439,7 @@ Word16 wb_vad_fx( move16(); IF( vad_bwidth_fx != NB ) { - if(sub(lp_snr, TH16_2_NFLAG_FX ) < 0 ) /*now 27, original threshold: 35dB*/ + if(LT_16(lp_snr, TH16_2_NFLAG_FX )) /*now 27, original threshold: 35dB*/ { *flag_noisy_speech_snr = 1; move16(); @@ -1449,7 +1447,7 @@ Word16 wb_vad_fx( } ELSE { - if(sub(lp_snr, TH8_1_NFLAG_FX ) < 0 ) /* now 20.0 */ + if(LT_16(lp_snr, TH8_1_NFLAG_FX )) /* now 20.0 */ { *flag_noisy_speech_snr = 1; move16(); @@ -1479,7 +1477,7 @@ Word16 wb_vad_fx( tmp = st_fx->prim_act_slow_fx; move16(); - if (sub(st_fx->prim_act_quick_fx,st_fx->prim_act_slow_fx) <= 0) + if (LE_16(st_fx->prim_act_quick_fx,st_fx->prim_act_slow_fx)) { tmp=st_fx->prim_act_quick_fx; move16(); @@ -1503,7 +1501,7 @@ Word16 wb_vad_fx( tmp = st_fx->prim_act_slow_he_fx; move16(); - if (sub(st_fx->prim_act_quick_he_fx,st_fx->prim_act_slow_he_fx) <= 0) + if (LE_16(st_fx->prim_act_quick_he_fx,st_fx->prim_act_slow_he_fx)) { tmp = st_fx->prim_act_quick_he_fx; move16(); diff --git a/lib_enc/vad_param_updt_fx.c b/lib_enc/vad_param_updt_fx.c index 9773074042129aabdf2c538ceda8363c0344443d..fec50241117971148a840c3a43b2b95c8c3e40a2 100644 --- a/lib_enc/vad_param_updt_fx.c +++ b/lib_enc/vad_param_updt_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -7,8 +7,6 @@ #include "cnst_fx.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" -#include "wmc_auto.h" - /*-------------------------------------------------------------------* * vad_param_updt() @@ -24,7 +22,6 @@ void vad_param_updt_fx( Word16 corr_shift, /* i : correlation shift Q15*/ Word16 vad_flag, /* i : vad flag Q0*/ const Word16 Az[] /* i: a coeffs Q12 */ - ) { Word16 voice_tmp, pitch_tmp; @@ -47,33 +44,33 @@ void vad_param_updt_fx( tmp_active_flag = 0; move16(); test(); - if( (L_sub(st_fx->core_brate_fx, (Word32)SID_2k40) != 0) && (st_fx->core_brate_fx != 0) ) /* Note, core_brate_fx can be -1 */ + if( (NE_32(st_fx->core_brate_fx, (Word32)SID_2k40))&&(st_fx->core_brate_fx!=0)) /* Note, core_brate_fx can be -1 */ { tmp_active_flag = 1; move16(); /* reqires active coding according to dtx_fx logic */ } test(); test(); - IF( (st_fx->Opt_DTX_ON_fx != 0) && (tmp_active_flag == 0) && ( sub(st_fx->ini_frame_fx,3) > 0) ) + IF( (st_fx->Opt_DTX_ON_fx != 0) && (tmp_active_flag == 0) && ( GT_16(st_fx->ini_frame_fx,3))) { /* update the counter of consecutive inactive frames in DTX */ st_fx->consec_inactive_fx = add(st_fx->consec_inactive_fx,1); - IF( sub(st_fx->consec_inactive_fx,5) > 0 ) + IF( GT_16(st_fx->consec_inactive_fx,5)) { st_fx->consec_inactive_fx = 5; move16(); } - IF( sub(st_fx->consec_inactive_fx,5) == 0 ) + IF( EQ_16(st_fx->consec_inactive_fx,5)) { /* compute spectral tilt parameter */ a2rc_fx( &Az[1], refl, M ); /* cast to kill MSVC warning */ /* i: Az in Q12 */ /* o: refl in Q15 */ - IF( sub(st_fx->spectral_tilt_reset_fx,1) == 0 ) + IF( EQ_16(st_fx->spectral_tilt_reset_fx,1)) { st_fx->spectral_tilt_reset_fx = 0; move16(); @@ -94,7 +91,7 @@ void vad_param_updt_fx( st_fx->running_avg_fx = add(tmp1,tmp2); move16(); - IF( sub(abs_s(st_fx->ra_deltasum_fx), 6553) > 0 ) /*0.2 in Q15*/ + IF( GT_16(abs_s(st_fx->ra_deltasum_fx), 6553)) /*0.2 in Q15*/ { st_fx->spectral_tilt_reset_fx = 1; move16(); @@ -162,8 +159,8 @@ void vad_param_updt_fx( st_fx->voiced_burst_fx = add( st_fx->voiced_burst_fx,1); move16(); test(); - if ( ( sub(voice_tmp,21299) <= 0 ) /* 0.65 in Q15 */ - || ( sub(pitch_tmp,42) >= 0 ) ) /*3*14 = 42 Q0 */ + if ( ( LE_16(voice_tmp,21299)) /* 0.65 in Q15 */ + || ( GE_16(pitch_tmp,42) ) ) /*3*14 = 42 Q0 */ { st_fx->voiced_burst_fx = 0; move16(); diff --git a/lib_enc/vad_proc.c b/lib_enc/vad_proc.c index 7a944c98ecb25c0b6ed13066d82bf4b25b866d05..deb09b9cc364c436766e4b2f724732dcf8048622 100644 --- a/lib_enc/vad_proc.c +++ b/lib_enc/vad_proc.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ @@ -11,8 +11,6 @@ #include "basop_util.h" #include "stl.h" -#include "wmc_auto.h" - #include "vad_basop.h" #include "prot_fx.h" #include "stat_enc_fx.h" @@ -200,7 +198,7 @@ void UpdateState(T_CldfbVadState *vad_state, vad_state->lt_bg_highf_eng = L_add(MUL_F(vad_state->lt_bg_highf_eng, 31130), L_shr(MUL_F(HB_Power, 1638), sub(HB_Power_Q, lt_bg_highf_eng_Q))); } - if(sub(vad_state->frameloop, 1000) < 0) + if(LT_16(vad_state->frameloop, 1000)) { vad_state->frameloop = add(vad_state->frameloop, 1); move16(); @@ -217,12 +215,12 @@ void UpdateState(T_CldfbVadState *vad_state, { vad_state->continuous_speech_num2 = 0; move16(); - IF(sub(vad_state->continuous_noise_num, 10) > 0) + IF(GT_16(vad_state->continuous_noise_num, 10)) { vad_state->continuous_speech_num = 0; move16(); } - ELSE IF(L_sub(vad_state->continuous_speech_num, 9) > 0) + ELSE IF(GT_32(vad_state->continuous_speech_num, 9)) { vad_state->continuous_speech_num = 9; move16(); @@ -230,7 +228,7 @@ void UpdateState(T_CldfbVadState *vad_state, vad_state->continuous_noise_num = add(vad_state->continuous_noise_num, 1); move16(); - if(sub(vad_state->continuous_noise_num, 2048) > 0) + if(GT_16(vad_state->continuous_noise_num, 2048)) { vad_state->continuous_noise_num = 2048; move16(); @@ -243,13 +241,13 @@ void UpdateState(T_CldfbVadState *vad_state, vad_state->continuous_speech_num2 = add(vad_state->continuous_speech_num2, 1); vad_state->continuous_speech_num = add(vad_state->continuous_speech_num, 1); - if(sub(vad_state->continuous_speech_num, 2048) > 0) + if(GT_16(vad_state->continuous_speech_num, 2048)) { vad_state->continuous_speech_num = 2048; move16(); } - if(sub(vad_state->continuous_speech_num2, 2048) > 0) + if(GT_16(vad_state->continuous_speech_num2, 2048)) { vad_state->continuous_speech_num2 = 2048; move16(); @@ -285,16 +283,18 @@ Word16 vad_proc(T_CldfbVadState *vad_st, Word32 *cldfbBufferImag[CLDFB_NO_COL_MAX]; /* dynamic scaling; cldfbBufferImag_float[x][y] = cldfbBufferReal[x][y] * 2^(-Q_cldfb) */ - music_backgound_f = add(0,0); - frame_energy = L_add(0,0); + music_backgound_f = 0; + move16(); + frame_energy = 0; + move32(); - IF(sub(numBands, 20) < 0) + IF(LT_16(numBands, 20)) { bandwidth = 1; move16(); } - ELSE IF(sub(numBands, 40) < 0) + ELSE IF(LT_16(numBands, 40)) { bandwidth = 2; move16(); diff --git a/lib_enc/vbr_average_rate_fx.c b/lib_enc/vbr_average_rate_fx.c index 0bab044796b280ca6b6a399400c65b3908298d7c..22e76d3e8764702de9c4f91e9c059cfffc828969 100644 --- a/lib_enc/vbr_average_rate_fx.c +++ b/lib_enc/vbr_average_rate_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -9,8 +9,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "stat_enc_fx.h" /* Static table prototypes */ #include "stl.h" -#include "wmc_auto.h" - #define RATEWIN 600 /* length of the rate control window. This is 600 active speech frames. This equals roughly 12s of active speech */ @@ -50,13 +48,13 @@ void update_average_rate_fx( Word16 exp, recip, Qrecip; - IF ( sub(st_fx->numactive_fx,RATEWIN) == 0 ) /* goes into rate control only the numactive ==RATEWIN. So rate control is triggered after each RATEWIN avtive frames */ + IF ( EQ_16(st_fx->numactive_fx,RATEWIN)) /* goes into rate control only the numactive ==RATEWIN. So rate control is triggered after each RATEWIN avtive frames */ { /* after 1000 blocks of RATEWIN frames, we change the way we control the average rate by using st->global_avr_rate=0.99*st->global_avr_rate+0.01*st->sum_of_rates. This will avoid veriables growing indefinitely while providing a good long term average rate */ - IF ( L_sub(st_fx->frame_cnt_ratewin_fx,1000) < 0 ) + IF ( LT_32(st_fx->frame_cnt_ratewin_fx,1000)) { st_fx->frame_cnt_ratewin_fx = add(st_fx->frame_cnt_ratewin_fx,1); @@ -66,7 +64,7 @@ void update_average_rate_fx( recip = div_s(16384,tmp); Qrecip = 15-(exp-14); - IF(L_sub(st_fx->frame_cnt_ratewin_fx,1) >0) + IF(GT_32(st_fx->frame_cnt_ratewin_fx,1)) { tmp = div_s(sub(st_fx->frame_cnt_ratewin_fx,1),st_fx->frame_cnt_ratewin_fx); /*Q15*/ L_tmp1 = Mult_32_16(st_fx->global_avr_rate_fx, tmp); /* Q13*Q15 = Q13 */ @@ -97,12 +95,12 @@ void update_average_rate_fx( /* target = VBR_ADR_MAX_TARGET * 10 * RATEWIN; */ target_fx = L_shl(L_mult0(VBR_ADR_MAX_TARGET_x10_Q1,RATEWIN ),12); /*Q13 */ - IF ( L_sub(target_fx,st_fx->global_avr_rate_fx) < 0 ) /* Action is taken to reduce the averge rate. Only initiated if the global rate > target rate */ + IF ( LT_32(target_fx,st_fx->global_avr_rate_fx)) /* Action is taken to reduce the averge rate. Only initiated if the global rate > target rate */ { /* Check the vad snr values to table the noisey/not noisey decision */ test(); - IF ( sub(st_fx->SNR_THLD_fx , 17152) < 0 ) /*Q8 */ /* Currently in QFF mode. The bumpup thresholds are slightly relaxed for noisy speech. */ + IF ( LT_16(st_fx->SNR_THLD_fx , 17152)) /*Q8 */ /* Currently in QFF mode. The bumpup thresholds are slightly relaxed for noisy speech. */ { /* Increase the threshold so the the bumpup procedure is done using the noisy thresholds. Use 3.5 steps to quickly ramp up the rate control to reduce the settling time */ @@ -110,7 +108,7 @@ void update_average_rate_fx( /* st->SNR_THLD += 3.5f; */ st_fx->SNR_THLD_fx = add(st_fx->SNR_THLD_fx , 896 ); /*Q8 */ } - ELSE IF ( st_fx->mode_QQF_fx == 0 && L_sub(st_fx->sum_of_rates_fx, target_fx)>0 ) /* Now SNR_THLD is in the max allowed. Sill the global average is higher and + ELSE IF ( st_fx->mode_QQF_fx == 0 && GT_32(st_fx->sum_of_rates_fx, target_fx)) /* Now SNR_THLD is in the max allowed. Sill the global average is higher and last RATEWIN frames have a higher agerage than the target rate. Now slightly more aggresive rate control is used by changing the mode to QQF. Still the same strict bumpups (more bumpups,higher rate) are used. */ @@ -119,7 +117,7 @@ void update_average_rate_fx( st_fx->mode_QQF_fx = 1; move16(); } - ELSE IF ( L_sub(st_fx->sum_of_rates_fx , target_fx) > 0 ) /* Actions (1) and (2) are not sufficient to control the rate. Still the last RATEWIN active + ELSE IF ( GT_32(st_fx->sum_of_rates_fx , target_fx)) /* Actions (1) and (2) are not sufficient to control the rate. Still the last RATEWIN active frames have a higher average rate than the target rate. More aggresive rate control is needed. At this point the rate_control flag is set. This will enable the more relaxed bump up thresholds (less bump ups->reduced rate)*/ @@ -129,7 +127,7 @@ void update_average_rate_fx( move16(); /* This will be triggered only if the gloabl average rate is considerablly higher than the target rate. Keep a higher threshold to avoid short term rate increases over the target rate. */ - IF ( L_sub(st_fx->global_avr_rate_fx ,L_add(target_fx,3440640)) > 0 ) /* Last resort rate control. This is a safer rate control mechanism by increasing NELPS */ + IF ( GT_32(st_fx->global_avr_rate_fx ,L_add(target_fx,3440640))) /* Last resort rate control. This is a safer rate control mechanism by increasing NELPS */ { st_fx->Last_Resort_fx = 1; move16(); /* compute based on a larger window as the last resort */ @@ -140,7 +138,7 @@ void update_average_rate_fx( move16(); } } - ELSE IF ( L_sub(st_fx->sum_of_rates_fx, target_fx ) < 0) /* If the average rate of last RATEWIN frames is controlled by above actions, disable the most + ELSE IF ( LT_32(st_fx->sum_of_rates_fx, target_fx )) /* If the average rate of last RATEWIN frames is controlled by above actions, disable the most aggresive rate control mechanisms. Still keep QQF mode as the global rate is not under the target rate*/ { @@ -158,19 +156,19 @@ void update_average_rate_fx( st_fx->Last_Resort_fx = 0; move16(); - IF ( sub(st_fx->rate_control_fx,1) == 0 ) + IF ( EQ_16(st_fx->rate_control_fx,1)) { st_fx->rate_control_fx = 0; move16(); } - ELSE IF ( sub(st_fx->mode_QQF_fx,1) == 0) /* now rate control is not active and still the global rate is below the target. so go to QFF mode */ + ELSE IF ( EQ_16(st_fx->mode_QQF_fx,1)) /* now rate control is not active and still the global rate is below the target. so go to QFF mode */ { st_fx->mode_QQF_fx = 0; move16(); } ELSE { - IF ( sub(st_fx->SNR_THLD_fx, 15360) >= 0 ) + IF ( GE_16(st_fx->SNR_THLD_fx, 15360)) { st_fx->SNR_THLD_fx =sub(st_fx->SNR_THLD_fx ,384 ); /*Q8 */ } @@ -182,7 +180,7 @@ void update_average_rate_fx( } } - IF ( L_sub(st_fx->global_avr_rate_fx , L_sub(target_fx,983040)) < 0 ) /* In QFF mode and global rate is less than target rate-0.2kbps. We can send some Q frames + IF ( LT_32(st_fx->global_avr_rate_fx , L_sub(target_fx,983040))) /* In QFF mode and global rate is less than target rate-0.2kbps. We can send some Q frames to F frames to improve the quality */ { /* kick in bouncing back from Q to F */ @@ -212,7 +210,7 @@ void update_average_rate_fx( move16(); /* no bump up will ever happen */ } - if ( sub(st_fx->pattern_m_fx,1000) > 0 ) + if ( GT_16(st_fx->pattern_m_fx,1000)) { st_fx->pattern_m_fx = 1000; move16();/* 10% of bump ups */ diff --git a/lib_enc/vlpc_1st_cod.c b/lib_enc/vlpc_1st_cod.c index 11a91ef7dea2fdd6bad83fa71479a4eedf0c695d..28e8fd6d7d71a66db2db86b46dd08c9a13ebe635 100644 --- a/lib_enc/vlpc_1st_cod.c +++ b/lib_enc/vlpc_1st_cod.c @@ -1,11 +1,9 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include #include "stl.h" -#include "wmc_auto.h" - #include "control.h" #include "cnst_fx.h" #include "prot_fx.h" @@ -37,7 +35,7 @@ static void lsf_weight( } inv_di0 = 0x7fff; move16(); - if (sub(i, ISF_ONE) > 0) + if (GT_16(i, ISF_ONE)) { inv_di0 = div_s(ISF_ONE,i); /*0Q15*/ /*inv_di0 = 1.0f / lsfq[0];*/ } @@ -45,7 +43,7 @@ static void lsf_weight( /* Allow saturation during weight calculation, because the values that are weighted later are used for a minimum search and experimental saturation avoidance also showed no improvement. */ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_OFF FOR (i=1; i<(M-2); i+=2) /*for (i=1; i<(M-2); i+=2)*/ { inv_di1 = div_s(ISF_ONE,s_max(ISF_ONE, sub(lsfq[i],lsfq[i-1]))); /*0Q15*/ /*inv_di1 = 1.0f / (lsfq[i] - lsfq[i-1]);*/ @@ -62,7 +60,7 @@ static void lsf_weight( w[i] = add(inv_di1,inv_di0); move16(); /*w[i] = inv_di1 + inv_di0;*/ - BASOP_SATURATE_WARNING_ON; + BASOP_SATURATE_WARNING_ON return; @@ -84,7 +82,7 @@ Word16 vlpc_1st_cod( /* output: codebook index */ /* weighting */ lsf_weight(lsf, w);/*lsf:14Q1*1.28=>w:0Q15*/ - IF(sub(rf_mode, 1) == 0) + IF(EQ_16(rf_mode, 1)) { Word16 s; s = Find_Max_Norm16(w, M); @@ -101,7 +99,8 @@ Word16 vlpc_1st_cod( /* output: codebook index */ FOR (i = 0; i < 256; i++) { - dist = L_add(0,0); + dist = 0; + move32(); FOR (j = 0; j < M; j++) { diff = sub(lsf[j], p_dico[j]); @@ -110,9 +109,10 @@ Word16 vlpc_1st_cod( /* output: codebook index */ } p_dico += M; - if (L_sub(dist,dist_min) < 0) + if (LT_32(dist,dist_min)) { - index = add(i,0); /* store index of new minimum */ + index = i; /* store index of new minimum */ + move16(); } dist_min = L_min(dist,dist_min); } diff --git a/lib_enc/vlpc_2st_cod.c b/lib_enc/vlpc_2st_cod.c index 7e31e50deed3a218923c58199044bffee8d2ba46..bb9b09c227291eca12519c5f1a7610eb2d29bc63 100644 --- a/lib_enc/vlpc_2st_cod.c +++ b/lib_enc/vlpc_2st_cod.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -8,8 +8,6 @@ #include "cnst_fx.h" #include "prot_fx.h" #include "stl.h" -#include "wmc_auto.h" - #include "control.h" #include "basop_util.h" @@ -46,14 +44,14 @@ Word16 vlpc_2st_cod( /* output: number of allocated bits */ x[0] = i; /*5Q10*/ move16(); L_tmp = L_mult(x[0],x[0]); /*10Q21*/ - BASOP_SATURATE_WARNING_OFF;/* Allow saturate because we only need to know if the result is smaller than 8.0f */ + BASOP_SATURATE_WARNING_OFF /* Allow saturate because we only need to know if the result is smaller than 8.0f */ FOR (i=1; i wops) */ nbits = 6; /* 2*(2+1) */ move16(); test(); - IF ( (mode == 0) || (sub(mode,3) == 0) ) + IF ( (mode == 0) || (EQ_16(mode,3))) { nbits = 10; /* 2*(2+3) */ move16(); } - ELSE IF (sub(mode,1) == 0) + ELSE IF (EQ_16(mode,1)) { nbits = 2; /* 2*1 */ move16(); } @@ -107,12 +105,12 @@ Word16 vlpc_2st_cod( /* output: number of allocated bits */ /*nbits += (2+(nq*4));*/ nbits = add(nbits,add(2,shl(nq,2))); /* 2 bits to specify Q2,Q3,Q4,ext; nbits += (2+(nq*4)); */ - IF (sub(nq,6) > 0) + IF (GT_16(nq,6)) { /*nbits += nq-3;*/ nbits = add(nbits,sub(nq,3)); /* unary code (Q7=1110, ...) */ } - ELSE IF (sub(nq,4) > 0) + ELSE IF (GT_16(nq,4)) { /*nbits += nq-4;*/ nbits = add(nbits,sub(nq,4)); /* Q5=0, Q6=10 */ @@ -126,15 +124,15 @@ Word16 vlpc_2st_cod( /* output: number of allocated bits */ /* reorder */ sort_fx(lsfq, 0, M-1); - IF ( L_sub(sr_core,16000) == 0 ) + IF ( EQ_32(sr_core,16000)) { gap = 102; } - ELSE IF ( L_sub(sr_core,25600) == 0 ) + ELSE IF ( EQ_32(sr_core,25600)) { gap = 64; } - ELSE IF ( L_sub(sr_core,32000) == 0 ) + ELSE IF ( EQ_32(sr_core,32000)) { gap = 51; } diff --git a/lib_enc/voiced_enc_fx.c b/lib_enc/voiced_enc_fx.c index b4a7a3f6b81d8389f3464ab4f31cdd98720ab33d..d8c01bfa806df31e51de773971a2a3f24c4c9596 100644 --- a/lib_enc/voiced_enc_fx.c +++ b/lib_enc/voiced_enc_fx.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -7,8 +7,6 @@ #include "cnst_fx.h" #include "rom_com_fx.h" #include "stl.h" -#include "wmc_auto.h" - /*-------------------------------------------------------------------* * Local functions @@ -120,14 +118,14 @@ void ppp_voiced_encoder_fx( temp_Fs = 8000; move16(); - if ( sub( st_fx->bwidth_fx, WB) == 0 ) + if ( EQ_16( st_fx->bwidth_fx, WB)) { temp_Fs = 16000; move16(); } test(); - IF (sub(st_fx->bwidth_fx,WB) == 0 || sub(st_fx->bwidth_fx,SWB) == 0) + IF (EQ_16(st_fx->bwidth_fx,WB)||EQ_16(st_fx->bwidth_fx,SWB)) { upper_cut_off_freq_of_interest_fx = 4000; move16(); @@ -136,7 +134,7 @@ void ppp_voiced_encoder_fx( upper_cut_off_freq_norm_fx = 16384; move16();/*value normalized by 12800 */ } - ELSE IF (sub(st_fx->bwidth_fx,NB) == 0) + ELSE IF (EQ_16(st_fx->bwidth_fx,NB)) { upper_cut_off_freq_of_interest_fx = 3300; move16(); @@ -166,7 +164,7 @@ void ppp_voiced_encoder_fx( } test(); /* Figure out the PPP_MODE */ - IF ( sub(st_fx->last_ppp_mode_fx,1) == 0 && !st_fx->mode_QQF_fx ) + IF ( EQ_16(st_fx->last_ppp_mode_fx,1)&&!st_fx->mode_QQF_fx) { st_fx->bump_up_fx = 1; move16(); @@ -197,7 +195,7 @@ void ppp_voiced_encoder_fx( /* Bump up if the lag is out_fx of range */ test(); - IF (sub(sub(l,pl),13)>0 || sub(sub(l,pl),-11) < 0 || sub(l,19) < 0 || sub(pl,19) < 0 ) + IF (GT_16(sub(l,pl),13)||LT_16(sub(l,pl),-11)||LT_16(l,19)||LT_16(pl,19)) { st_fx->bump_up_fx = 1; move16(); @@ -210,14 +208,14 @@ void ppp_voiced_encoder_fx( return; } - IF (sub(st_fx->last_ppp_mode_fx,1)!=0) + IF (NE_16(st_fx->last_ppp_mode_fx,1)) { /* Obtain DTFS of last pl values of past excitation */ GetSinCosTab_fx(pl,S_fx,C_fx); DTFS_to_fs_fx(exc_fx-pl, pl, dtfs_temp_fx, temp_Fs, 0,S_fx,C_fx); } - if (sub(st_fx->last_coder_type_raw_fx,UNVOICED) == 0) + if (EQ_16(st_fx->last_coder_type_raw_fx,UNVOICED)) { pl = l; move16(); /* if prev frame was sil/uv */ @@ -277,7 +275,7 @@ void ppp_voiced_encoder_fx( curr_Engy=DTFS_getEngy_P2A_fx(CURRP_NQ_FX); /*2Q where Q=CURRP_NQ_FX->Q */ /* Restoring PPP memories when the last frame is non-PPP */ - IF (sub(st_fx->last_ppp_mode_fx,1)!=0) + IF (NE_16(st_fx->last_ppp_mode_fx,1)) { st_fx->ph_offset_E_fx = 0 ; @@ -377,7 +375,7 @@ void ppp_voiced_encoder_fx( sft=add(shl(sub(CURRP_NQ_FX->Q,dtfs_temp_fx->Q),1),4); IF (sft>0) { - if (L_sub(Lacc1,L_shr(Lacc,sft))<0) + if (LT_32(Lacc1,L_shr(Lacc,sft))) { res_enratio_fx=0x7FFF; move16(); @@ -385,7 +383,7 @@ void ppp_voiced_encoder_fx( } ELSE { - if (L_sub(L_shr(Lacc1,negate(sft)),Lacc)<0) + if (LT_32(L_shr(Lacc1,negate(sft)),Lacc)) { res_enratio_fx=0x7FFF; move16(); @@ -393,7 +391,7 @@ void ppp_voiced_encoder_fx( } /* max value res_enratio compared against is 0x7400 (14.5 in Q11) */ - IF (L_sub(res_enratio_fx,0x7FFF)!=0) + IF (NE_32(res_enratio_fx,0x7FFF)) { expb = norm_l(Lacc); @@ -489,11 +487,11 @@ void ppp_voiced_encoder_fx( } /*******************************************************************************/ - IF (sub(PPP_MODE_E,'Q') == 0) + IF (EQ_16(PPP_MODE_E,'Q')) { /* Bump up if the lag is out_fx of range */ test(); - IF (sub(sub(l,pl),13)>0 || sub(sub(l,pl),-11) < 0) + IF (GT_16(sub(l,pl),13)||LT_16(sub(l,pl),-11)) { PPP_MODE_E = 'B' ; move16(); @@ -504,12 +502,12 @@ void ppp_voiced_encoder_fx( } /* Bump up if big change between the previous and the current CWs */ - IF ( sub(shl(vadsnr_fx,1) ,st_fx->SNR_THLD_fx) < 0 ) /*Q8 */ + IF ( LT_16(shl(vadsnr_fx,1) ,st_fx->SNR_THLD_fx)) /*Q8 */ { /*if ( res_enratio > 5.0 && tmp < 0.65 ) */ /* 5 in Q11, 0.65 in Q15 // L_shl(tmp_fx,sub(31,Qtmp)) makes tmp_fx FIXED Q31 */ test(); - IF ((L_sub(res_enratio_fx,10240)>0) && (sub(extract_h(L_shl(tmp_fx,sub(31,Qtmp))),21299)<0)) + IF ((GT_32(res_enratio_fx,10240))&&(LT_16(extract_h(L_shl(tmp_fx,sub(31,Qtmp))),21299))) { PPP_MODE_E = 'B'; move16(); @@ -520,7 +518,7 @@ void ppp_voiced_encoder_fx( /* if ( res_enratio > 3.0 && tmp < 1.2 ) */ /*3 in Q11, 1.2 in Q14 // L_shl(tmp_fx,sub(31,Qtmp)) makes tmp_fx FIXED Q14 */ test(); - IF ( (L_sub(res_enratio_fx,6144)>0) && (sub(extract_h(L_shl(tmp_fx,sub(30,Qtmp))),19661)<0) ) + IF ( (GT_32(res_enratio_fx,6144))&&(LT_16(extract_h(L_shl(tmp_fx,sub(30,Qtmp))),19661))) { PPP_MODE_E = 'B'; move16(); @@ -531,10 +529,10 @@ void ppp_voiced_encoder_fx( /* Rapid rampdown frame where time resolution is important */ /* Not a suitable PPP frame -> Bump to CELP */ - IF ( sub(shl(vadsnr_fx,1) ,st_fx->SNR_THLD_fx) < 0 ) /*Q8 */ + IF ( LT_16(shl(vadsnr_fx,1) ,st_fx->SNR_THLD_fx)) /*Q8 */ { /* if (res_enratio < 0.025) */ - IF (L_sub(L_shl(res_enratio_fx,4),819)<0) /*0x0333 = 0.025 in Q15, res_enratio_fx in Q15 after shl 4 */ + IF (LT_32(L_shl(res_enratio_fx,4),819)) /*0x0333 = 0.025 in Q15, res_enratio_fx in Q15 after shl 4 */ { st_fx->bump_up_fx = 1; move16(); @@ -550,7 +548,7 @@ void ppp_voiced_encoder_fx( ELSE { /* if ( res_enratio < 0.092f) */ - if ( L_sub(L_shl(res_enratio_fx,4), 3015)< 0 )/*3015 = 0.092 in Q15, res_enratio_fx in Q15 after shl 4 */ + if ( LT_32(L_shl(res_enratio_fx,4), 3015))/*3015 = 0.092 in Q15, res_enratio_fx in Q15 after shl 4 */ { st_fx->bump_up_fx = 1; move16(); @@ -559,7 +557,7 @@ void ppp_voiced_encoder_fx( /* if (min(res_enratio, sp_enratio) < 0.075 && tmp < -0.5f)) : 2458 = 0.075 in Q15 */ test(); - if ( L_sub(L_min(L_shl(res_enratio_fx,4), sp_enratio_fx), 2458) < 0 && L_sub(tmp_fx , shl(-1,sub(Qtmp,1)))<0 ) + if ( LT_32(L_min(L_shl(res_enratio_fx,4), sp_enratio_fx), 2458)&<_32(tmp_fx,shl(-1,sub(Qtmp,1)))) { st_fx->bump_up_fx = 1; move16(); @@ -567,9 +565,9 @@ void ppp_voiced_encoder_fx( /* Rapid rampup frame where time resolution is important */ /* Not a suitable PPP frame -> Bump to CELP */ - IF ( sub(shl(vadsnr_fx,1) ,st_fx->SNR_THLD_fx) < 0 ) /*Q8 */ + IF ( LT_16(shl(vadsnr_fx,1) ,st_fx->SNR_THLD_fx)) /*Q8 */ { - IF (L_sub(res_enratio_fx,29696)>0) /*14.5 in Q11 */ + IF (GT_32(res_enratio_fx,29696)) /*14.5 in Q11 */ { st_fx->bump_up_fx = 1; move16(); @@ -584,7 +582,7 @@ void ppp_voiced_encoder_fx( } ELSE { - if (L_sub(res_enratio_fx,14336)>0) /* 7.0 in Q11 */ + if (GT_32(res_enratio_fx,14336)) /* 7.0 in Q11 */ { st_fx->bump_up_fx = 1; move16(); @@ -603,7 +601,7 @@ void ppp_voiced_encoder_fx( } /* Bump up when the previous frame is an unvoiced or a silent frame */ - IF (sub(st_fx->last_coder_type_raw_fx,UNVOICED) == 0) + IF (EQ_16(st_fx->last_coder_type_raw_fx,UNVOICED)) { st_fx->bump_up_fx = 1; move16(); @@ -618,11 +616,11 @@ void ppp_voiced_encoder_fx( /* -----End Open-loop Bump-Up */ /* PPP-WI Quantization */ - IF (sub(PPP_MODE_E,'Q') == 0) + IF (EQ_16(PPP_MODE_E,'Q')) { flag = 1; move16(); - IF (sub(PPP_MODE_E,'Q') == 0) + IF (EQ_16(PPP_MODE_E,'Q')) { flag = ppp_quarter_encoder_fx(CURRP_Q_E_FX, TMPDTFS_FX, dtfs_temp_fx->lag_fx, *CURRP_NQ_FX, lpc2_fx, &st_fx->lastLgainE_fx, &st_fx->lastHgainE_fx, st_fx->lasterbE_fx, *dtfs_temp_fx, S_fx, C_fx, st_fx); @@ -650,7 +648,7 @@ void ppp_voiced_encoder_fx( /* Usually triggers in the slow ramp down frames. Does not fall under the test condition (res_enratio < 0.025) as both frames have little energy and the ratio is not very small. Not suitable for PPP */ - IF ( sub(CURRP_Q_E_FX->upper_cut_off_freq_fx , 4000) >0 ) + IF ( GT_16(CURRP_Q_E_FX->upper_cut_off_freq_fx , 4000)) { Ltemp2 = DTFS_getEngy_band_wb_fx(*CURRP_Q_E_FX, 0, 2000); /* Use this bump-up only for WB signals */ @@ -695,7 +693,7 @@ void ppp_voiced_encoder_fx( /* if ( low_band_en < 25.0f && sp_hb_enratio < 1.6f ) */ /* 25.0 in Q13 = 204800, 1.6 in Q29 = 858993459 */ test(); - IF ( L_sub(low_band_en_fx , 204800 )< 0 && L_sub(sp_hb_enratio_fx , 858993459 ) < 0 ) + IF ( LT_32(low_band_en_fx , 204800 )&<_32(sp_hb_enratio_fx,858993459)) { PPP_MODE_E = 'B'; move16(); @@ -710,17 +708,17 @@ void ppp_voiced_encoder_fx( /* Ltmp1_32 = 0.8f * st->prev_cw_en */ Ltmp1_32 = Mult_32_16(st_fx->prev_cw_en_fx,26214); /* Q = (Q_prev_cw_en_fx + Q15+1)-Q16 = Q_prev_cw_en_fx */ - IF ( sub(shl(vadsnr_fx,1) ,st_fx->SNR_THLD_fx) < 0 ) /*Q8 */ + IF ( LT_16(shl(vadsnr_fx,1) ,st_fx->SNR_THLD_fx)) /*Q8 */ { /* if ( DTFS_getEngy(*CURRP_NQ) > 0.8f * st->prev_cw_en && max(pos_nq, neg_nq) > 3.0f && st->rate_control ) */ /* pos_nq_fx and neg_nq_fx in Q28 ???? */ test(); test(); - IF ( L_sub( Ltmp_32, Ltmp1_32) > 0 && L_sub(L_max(pos_nq_fx, neg_nq_fx) , 805306368) > 0 && st_fx->rate_control_fx ) + IF ( GT_32( Ltmp_32, Ltmp1_32)&>_32(L_max(pos_nq_fx,neg_nq_fx),805306368)&&st_fx->rate_control_fx) { /*if ( pos_nq > neg_nq && pos_nq > 2.0f * pos_q ) */ test(); - IF ( L_sub(pos_nq_fx , neg_nq_fx) > 0 && L_sub(Mult_32_16(pos_nq_fx,16384), pos_q_fx) > 0 ) + IF ( GT_32(pos_nq_fx , neg_nq_fx)&>_32(Mult_32_16(pos_nq_fx,16384),pos_q_fx)) { PPP_MODE_E = 'B'; move16(); @@ -728,7 +726,7 @@ void ppp_voiced_encoder_fx( test(); /*if ( pos_nq < neg_nq && neg_nq > 2.0f * neg_q ) */ - IF ( L_sub(pos_nq_fx , neg_nq_fx) < 0 && L_sub(Mult_32_16(neg_nq_fx,16384), neg_q_fx) > 0 ) + IF ( LT_32(pos_nq_fx , neg_nq_fx)&>_32(Mult_32_16(neg_nq_fx,16384),neg_q_fx)) { PPP_MODE_E = 'B'; move16(); @@ -745,8 +743,8 @@ void ppp_voiced_encoder_fx( test(); test(); test(); - IF ((((L_sub(Ltmp_32 ,(st_fx->prev_cw_en_fx)>0))&&(L_sub(L_max(pos_nq_fx,neg_nq_fx),939524096)>0))&&(st_fx->rate_control_fx))|| - (((L_sub( Ltmp_32, Ltmp1_32) > 0 ) && (L_sub(L_max(pos_nq_fx,neg_nq_fx),805306368)>0))&&(!st_fx->rate_control_fx))) + IF ((((L_sub(Ltmp_32 ,(st_fx->prev_cw_en_fx)>0))&&(GT_32(L_max(pos_nq_fx,neg_nq_fx),939524096)))&&(st_fx->rate_control_fx))|| + (((GT_32( Ltmp_32, Ltmp1_32) ) && (GT_32(L_max(pos_nq_fx,neg_nq_fx),805306368)))&&(!st_fx->rate_control_fx))) { /* if (((pos_nq > neg_nq) && (pos_nq > 2.5*pos_q)&&(st->rate_control))|| ((pos_nq > neg_nq) && (pos_nq > 2.0*pos_q)&&(!st->rate_control))) */ @@ -755,8 +753,8 @@ void ppp_voiced_encoder_fx( test(); test(); test(); - IF ((L_sub(pos_nq_fx , neg_nq_fx)>0 && L_sub(Mult_32_16(pos_nq_fx ,13107),pos_q_fx)>0 && (st_fx->rate_control_fx))|| - (L_sub(pos_nq_fx , neg_nq_fx)>0 && L_sub(Mult_32_16(pos_nq_fx,16384),pos_q_fx) >0 && (!st_fx->rate_control_fx))) + IF ((GT_32(pos_nq_fx , neg_nq_fx)&>_32(Mult_32_16(pos_nq_fx,13107),pos_q_fx)&&(st_fx->rate_control_fx))|| + (GT_32(pos_nq_fx , neg_nq_fx) && GT_32(Mult_32_16(pos_nq_fx,16384),pos_q_fx) && (!st_fx->rate_control_fx))) { PPP_MODE_E='B'; move16(); @@ -769,8 +767,8 @@ void ppp_voiced_encoder_fx( test(); test(); test(); - IF ((L_sub(pos_nq_fx , neg_nq_fx)<0 && L_sub(Mult_32_16(neg_nq_fx ,13107),neg_q_fx)>0 && (st_fx->rate_control_fx))|| - (L_sub(pos_nq_fx , neg_nq_fx)<0 && L_sub(Mult_32_16(neg_nq_fx,16384),neg_q_fx) >0 && (!st_fx->rate_control_fx))) + IF ((LT_32(pos_nq_fx , neg_nq_fx)&>_32(Mult_32_16(neg_nq_fx,13107),neg_q_fx)&&(st_fx->rate_control_fx))|| + (LT_32(pos_nq_fx , neg_nq_fx) && GT_32(Mult_32_16(neg_nq_fx,16384),neg_q_fx) && (!st_fx->rate_control_fx))) { PPP_MODE_E='B'; move16(); @@ -830,17 +828,17 @@ void ppp_voiced_encoder_fx( test(); test(); test(); - IF ((L_sub(Ltmp_32, st_fx->prev_cw_en_fx )>0) && (L_sub(L_max(pos_q_fx,neg_q_fx),939524096)>0) && (L_sub(energy_impz_fx,30720)>0) - && (L_sub(Mult_32_16(tmpres_fx,23265),shl(1,sub(Qtmpres,1)))>0) ) + IF ((GT_32(Ltmp_32, st_fx->prev_cw_en_fx ))&&(GT_32(L_max(pos_q_fx,neg_q_fx),939524096))&&(GT_32(energy_impz_fx,30720)) + && (GT_32(Mult_32_16(tmpres_fx,23265),shl(1,sub(Qtmpres,1)))) ) { /* if ((pos_q > neg_q) && ((pos_q>3.0*pos_nq0) || ((pos_q > 1.5*pos_nq0) && (neg_q < 1.5*neg_nq0)))) */ test(); test(); test(); - IF ( (L_sub(pos_q_fx , neg_q_fx)>0) - && ((L_sub(Mult_32_16(pos_q_fx,10923), L_shr(pos_nq0_fx,sub(Qposnq,28)) )>0) - || ((L_sub( Mult_32_16(pos_q_fx,21845),L_shr(pos_nq0_fx,sub(Qposnq,28)) )>0) - && (L_sub(Mult_32_16(neg_q_fx,21846), L_shr(neg_nq0_fx,sub(Qnegnq,28)) )<0) )) + IF ( (GT_32(pos_q_fx , neg_q_fx)) + && ((GT_32(Mult_32_16(pos_q_fx,10923), L_shr(pos_nq0_fx,sub(Qposnq,28)) )) + || ((GT_32( Mult_32_16(pos_q_fx,21845),L_shr(pos_nq0_fx,sub(Qposnq,28)) )) + && (LT_32(Mult_32_16(neg_q_fx,21846), L_shr(neg_nq0_fx,sub(Qnegnq,28)) )) )) ) /* 10923 = (1/3) oin Q15, pos_q_fx is Q28, so result of Mult_32_16(pos_q_fx,10923) = Q28 */ /* L_shr(pos_nq0_fx,sub(Qposnq,28)) brings pos_nq0_fx with variable Q to fixed Q28 */ @@ -852,10 +850,10 @@ void ppp_voiced_encoder_fx( test(); test(); /* if ((pos_q <= neg_q) && ((neg_q>3.0*neg_nq0)|| ((neg_q > 1.5*neg_nq0) && (pos_q < 1.5*pos_nq0)))) */ - IF ( (L_sub(pos_q_fx ,neg_q_fx)<=0) - && ((L_sub(Mult_32_16(neg_q_fx,10923), L_shr(neg_nq0_fx,sub(Qnegnq,28)))>0) - || ((L_sub(Mult_32_16(neg_q_fx,21846), L_shr(neg_nq0_fx,sub(Qnegnq,28)))>0) - && (L_sub( Mult_32_16( pos_q_fx,21846),L_shr(pos_nq0_fx,sub(Qposnq,28)))<0))) + IF ( (LE_32(pos_q_fx ,neg_q_fx)) + && ((GT_32(Mult_32_16(neg_q_fx,10923), L_shr(neg_nq0_fx,sub(Qnegnq,28)))) + || ((GT_32(Mult_32_16(neg_q_fx,21846), L_shr(neg_nq0_fx,sub(Qnegnq,28)))) + && (LT_32( Mult_32_16( pos_q_fx,21846),L_shr(pos_nq0_fx,sub(Qposnq,28)))))) ) { PPP_MODE_E='B'; @@ -900,7 +898,7 @@ void ppp_voiced_encoder_fx( } test(); - IF (L_sub(Ltemp_fx , 6710886)>0 && (!st_fx->rate_control_fx)) /* 0.05 in Q27 = 6710886 */ + IF (GT_32(Ltemp_fx , 6710886)&&(!st_fx->rate_control_fx)) /* 0.05 in Q27 = 6710886 */ { /*if (10.0*log10(DTFS_getEngy_band(*TMPDTFS,1500.0,upper_cut_off_freq_of_interest)/ */ /*DTFS_getEngy_band(*TMPDTFS3,1500.0,upper_cut_off_freq_of_interest)) < 0.1) */ @@ -942,10 +940,10 @@ void ppp_voiced_encoder_fx( exp_ee = sub(30,add(exp_ee,29)); /* 30 fixed here, 29 is the Q of Ltemp_fx */ Ltmp = Mpy_32_16(exp_ee, frac_ee, LG10); /* LG10 in Q13, so answer Ltmp in Q14 */ - IF(L_sub(Ltmp,1638)<0) /* 1638 = 0.1 in Q14 */ + IF(LT_32(Ltmp,1638)) /* 1638 = 0.1 in Q14 */ { /* if (res_enratio > 0.8) */ - if (L_sub(res_enratio_fx , 1638)>0) /* 1638 = 0.8 in Q11, res_enratio_fx in Q11 */ + if (GT_32(res_enratio_fx , 1638)) /* 1638 = 0.8 in Q11, res_enratio_fx in Q11 */ { PPP_MODE_E = 'B'; move16(); @@ -976,7 +974,7 @@ void ppp_voiced_encoder_fx( flag1=1; move16();/* do the divide */ } - IF (sub(flag1,1)==0) + IF (EQ_16(flag1,1)) { expb = norm_l(Lacc); fracb = extract_h(L_shl(Lacc,expb)); @@ -1013,7 +1011,7 @@ void ppp_voiced_encoder_fx( move16(); } - IF ( sub(shl(vadsnr_fx,1) ,st_fx->SNR_THLD_fx) < 0 ) /* Q8 */ + IF ( LT_16(shl(vadsnr_fx,1) ,st_fx->SNR_THLD_fx)) /* Q8 */ { /* if ((( tmp < 3.05 && max(res_enratio,sp_enratio) > 0.8 ) && (st->rate_control))|| (( tmp < 2.8 && max(res_enratio,sp_enratio) > 0.65 ) && (!st->rate_control))) */ @@ -1023,8 +1021,8 @@ void ppp_voiced_encoder_fx( test(); test(); test(); - if ((( L_sub(Ltemp, 25585254 ) < 0 && L_sub(L_max(L_shl(res_enratio_fx,4),sp_enratio_fx) , 6554)> 0 )&&(st_fx->rate_control_fx))|| - (( L_sub(Ltemp, 23488102 ) < 0 && L_sub(L_max(L_shl(res_enratio_fx,4),sp_enratio_fx) , 5325)> 0 )&&(!st_fx->rate_control_fx))) + if ((( LT_32(Ltemp, 25585254 )&>_32(L_max(L_shl(res_enratio_fx,4),sp_enratio_fx),6554))&&(st_fx->rate_control_fx))|| + (( LT_32(Ltemp, 23488102 ) && GT_32(L_max(L_shl(res_enratio_fx,4),sp_enratio_fx) , 5325) )&&(!st_fx->rate_control_fx))) { PPP_MODE_E = 'B'; move16(); @@ -1039,8 +1037,8 @@ void ppp_voiced_encoder_fx( test(); test(); test(); - if ((( L_sub(Ltemp ,20132659 ) < 0 && L_sub(L_max(L_shl(res_enratio_fx,4),sp_enratio_fx) , 7700)> 0 )&&(st_fx->rate_control_fx))|| - (( L_sub(Ltemp, 37748736 ) < 0 && L_sub(L_max(L_shl(res_enratio_fx,4),sp_enratio_fx) , 4096)> 0 )&&(!st_fx->rate_control_fx))) + if ((( LT_32(Ltemp ,20132659 )&>_32(L_max(L_shl(res_enratio_fx,4),sp_enratio_fx),7700))&&(st_fx->rate_control_fx))|| + (( LT_32(Ltemp, 37748736 ) && GT_32(L_max(L_shl(res_enratio_fx,4),sp_enratio_fx) , 4096) )&&(!st_fx->rate_control_fx))) { PPP_MODE_E = 'B'; move16(); @@ -1075,7 +1073,7 @@ void ppp_voiced_encoder_fx( { st_fx->patterncount_fx = add(st_fx->patterncount_fx ,st_fx->pattern_m_fx); - IF (sub(st_fx->patterncount_fx , 1000)>=0) + IF (GE_16(st_fx->patterncount_fx , 1000)) { st_fx->patterncount_fx = sub (st_fx->patterncount_fx , 1000); PPP_MODE_E = 'B'; @@ -1094,7 +1092,7 @@ void ppp_voiced_encoder_fx( } /* packetization of the delta lag in_fx PPP */ - IF (sub(PPP_MODE_E,'Q') == 0) + IF (EQ_16(PPP_MODE_E,'Q')) { Q_delta_lag = add(delta_lag_E,11); /* to make it positive always */ diff --git a/lib_enc/waveadjust_fec_cod.c b/lib_enc/waveadjust_fec_cod.c index d0309f9011dff1fdeece8be2973d9e78f5c72430..6c63c98611c18f7522f80a8ccb1fdab156c48101 100644 --- a/lib_enc/waveadjust_fec_cod.c +++ b/lib_enc/waveadjust_fec_cod.c @@ -1,5 +1,5 @@ /*==================================================================================== - EVS Codec 3GPP TS26.442 Nov 04, 2021. Version 12.15.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.4.0 + EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include @@ -7,9 +7,7 @@ #include #include "prot_fx.h" #include "stat_com.h" -#include "stl.h" -#include "wmc_auto.h" - /* for wmc_tool */ +#include "stl.h" /* for wmc_tool */ Word32 SFM_Cal(Word32 magn[], Word16 n) @@ -34,7 +32,7 @@ Word32 SFM_Cal(Word32 magn[], Word16 n) sumMagn =L_add(sumMagn, magn_abs); } - IF(L_sub(sumMagn,MAX_32)==0) + IF(EQ_32(sumMagn,MAX_32)) { sumMagn = L_deposit_l(0); FOR(i = 0; i < n; i++)