summaryrefslogtreecommitdiff
path: root/third_party
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2009-04-18 14:29:28 +0000
committerBenny Prijono <bennylp@teluu.com>2009-04-18 14:29:28 +0000
commit345cd27b4a25e0c326ed1efc6f7f8372bde4ed6b (patch)
tree23f45ad5fcde6553d7d0dcfa5065b22c94edc790 /third_party
parenta1af7e95f02cb3744d53b17671ce52cfb5edc7f8 (diff)
More ticket #774: optimization for siren7/siren14 codecs
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2616 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'third_party')
-rw-r--r--third_party/build/g7221/libg7221codec.dsp7
-rw-r--r--third_party/g7221/common/common.c14
-rw-r--r--third_party/g7221/common/stl-files/basop32.c957
-rw-r--r--third_party/g7221/common/stl-files/basop32.h53
-rw-r--r--third_party/g7221/common/stl-files/basop32_i.h730
-rw-r--r--third_party/g7221/common/stl-files/count.c303
-rw-r--r--third_party/g7221/common/stl-files/count.h68
-rw-r--r--third_party/g7221/decode/coef2sam.c10
-rw-r--r--third_party/g7221/decode/dct4_s.c54
-rw-r--r--third_party/g7221/decode/decoder.c28
-rw-r--r--third_party/g7221/encode/dct4_a.c33
-rw-r--r--third_party/g7221/encode/encoder.c62
-rw-r--r--third_party/g7221/encode/sam2coef.c10
13 files changed, 1016 insertions, 1313 deletions
diff --git a/third_party/build/g7221/libg7221codec.dsp b/third_party/build/g7221/libg7221codec.dsp
index 419d3f9a..3567a07d 100644
--- a/third_party/build/g7221/libg7221codec.dsp
+++ b/third_party/build/g7221/libg7221codec.dsp
@@ -42,7 +42,8 @@ RSC=rc.exe
# PROP Target_Dir ""
F90=df.exe
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "../.." /I "../../g7221/common" /I "../../g7221/common/stl-files" /I "../../../pjlib/include" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "../.." /I "../../g7221/common" /I "../../g7221/common/stl-files" /I "../../../pjlib/include" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FR /YX /FD /c
+# SUBTRACT CPP /Z<none>
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
@@ -66,7 +67,7 @@ LIB32=link.exe -lib
# PROP Target_Dir ""
F90=df.exe
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../.." /I "../../g7221/common" /I "../../g7221/common/stl-files" /I "../../../pjlib/include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../.." /I "../../g7221/common" /I "../../g7221/common/stl-files" /I "../../../pjlib/include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
@@ -101,7 +102,7 @@ SOURCE="..\..\g7221\common\stl-files\basop32.h"
# End Source File
# Begin Source File
-SOURCE="..\..\g7221\common\stl-files\count.c"
+SOURCE="..\..\g7221\common\stl-files\basop32_i.h"
# End Source File
# Begin Source File
diff --git a/third_party/g7221/common/common.c b/third_party/g7221/common/common.c
index 66e32ad4..94bcf79c 100644
--- a/third_party/g7221/common/common.c
+++ b/third_party/g7221/common/common.c
@@ -94,7 +94,7 @@ void categorize(Word16 number_of_available_bits,
{
number_of_available_bits = sub(number_of_available_bits,frame_size);
number_of_available_bits = extract_l(L_mult0(number_of_available_bits,5));
- number_of_available_bits = shr(number_of_available_bits,3);
+ number_of_available_bits = shr_nocheck(number_of_available_bits,3);
number_of_available_bits = add(number_of_available_bits,frame_size);
}
@@ -207,7 +207,7 @@ void comp_powercat_and_catbalance(Word16 *power_categories,
for (j=0; j<num_categorization_control_possibilities-1; j++)
{
min_plus_max = add(max,min);
- two_x_number_of_available_bits = shl(number_of_available_bits,1);
+ two_x_number_of_available_bits = shl_nocheck(number_of_available_bits,1);
temp = sub(min_plus_max,two_x_number_of_available_bits);
test();
@@ -222,7 +222,7 @@ void comp_powercat_and_catbalance(Word16 *power_categories,
test();
if (max_rate_categories[region] > 0)
{
- itemp0 = shl(max_rate_categories[region],1);
+ itemp0 = shl_nocheck(max_rate_categories[region],1);
itemp1 = sub(offset,rms_index[region]);
itemp0 = sub(itemp1,itemp0);
@@ -258,7 +258,7 @@ void comp_powercat_and_catbalance(Word16 *power_categories,
test();
if (temp < 0)
{
- itemp0 = shl(min_rate_categories[region],1);
+ itemp0 = shl_nocheck(min_rate_categories[region],1);
itemp1 = sub(offset,rms_index[region]);
itemp0 = sub(itemp1,itemp0);
@@ -356,7 +356,7 @@ Word16 calc_offset(Word16 *rms_index,Word16 number_of_regions,Word16 available_b
for (region=0; region<number_of_regions; region++)
{
j = sub(test_offset,rms_index[region]);
- j = shr(j,1);
+ j = shr_nocheck(j,1);
/* Ensure j is between 0 and NUM_CAT-1 */
test();
@@ -391,7 +391,7 @@ Word16 calc_offset(Word16 *rms_index,Word16 number_of_regions,Word16 available_b
answer = test_offset;
move16();
}
- delta = shr(delta,1);
+ delta = shr_nocheck(delta,1);
test(); /* for the while loop */
} while (delta > 0);
@@ -440,7 +440,7 @@ void compute_raw_pow_categories(Word16 *power_categories,Word16 *rms_index,Word1
for (region=0; region<number_of_regions; region++)
{
j = sub(offset,rms_index[region]);
- j = shr(j,1);
+ j = shr_nocheck(j,1);
/* make sure j is between 0 and NUM_CAT-1 */
test();
diff --git a/third_party/g7221/common/stl-files/basop32.c b/third_party/g7221/common/stl-files/basop32.c
index 9eb4f380..efd5c204 100644
--- a/third_party/g7221/common/stl-files/basop32.c
+++ b/third_party/g7221/common/stl-files/basop32.c
@@ -79,134 +79,29 @@ extern int currCounter;
/*___________________________________________________________________________
| |
- | Local Functions |
- |___________________________________________________________________________|
-*/
-Word16 saturate (Word32 L_var1);
-
-/*___________________________________________________________________________
- | |
| Constants and Globals |
|___________________________________________________________________________|
*/
-Flag Overflow = 0;
-Flag Carry = 0;
-
-/*___________________________________________________________________________
- | |
- | Functions |
- |___________________________________________________________________________|
-*/
-
-/*___________________________________________________________________________
- | |
- | Function Name : saturate |
- | |
- | Purpose : |
- | |
- | Limit the 32 bit input to the range of a 16 bit word. |
- | |
- | 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 : |
- | |
- | var_out |
- | 16 bit short signed integer (Word16) whose value falls in the |
- | range : 0xffff 8000 <= var_out <= 0x0000 7fff. |
- |___________________________________________________________________________|
-*/
-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--;
+#if INCLUDE_UNSAFE
+Flag g7221_Overflow = 0;
+Flag g7221_Carry = 0;
#endif
- }
-
- return (var_out);
-}
-/* ------------------------- End of saturate() ------------------------- */
-
/*___________________________________________________________________________
| |
- | Function Name : add |
- | |
- | Purpose : |
- | |
- | Performs the addition (var1+var2) with overflow control and saturation;|
- | the 16 bit result is set at +32767 when overflow occurs or at -32768 |
- | when underflow occurs. |
- | |
- | Complexity weight : 1 |
- | |
- | Inputs : |
- | |
- | 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 <= var1 <= 0x0000 7fff. |
- | |
- | Outputs : |
- | |
- | none |
- | |
- | Return Value : |
- | |
- | var_out |
- | 16 bit short signed integer (Word16) whose value falls in the |
- | range : 0xffff 8000 <= var_out <= 0x0000 7fff. |
+ | Functions |
|___________________________________________________________________________|
*/
-Word16 add (Word16 var1, Word16 var2)
-{
- Word16 var_out;
- Word32 L_sum;
-
- L_sum = (Word32) var1 + var2;
- var_out = saturate (L_sum);
-#if (WMOPS)
- multiCounter[currCounter].add++;
-#endif
- return (var_out);
-}
-/* ------------------------- End of add() ------------------------- */
-
-
/*___________________________________________________________________________
| |
- | Function Name : sub |
+ | Function Name : shr |
| |
| Purpose : |
| |
- | Performs the subtraction (var1+var2) with overflow control and satu- |
- | ration; the 16 bit result is set at +32767 when overflow occurs or at |
- | -32768 when underflow occurs. |
+ | Arithmetically shift the 16 bit input var1 right var2 positions with |
+ | sign extension. If var2 is negative, arithmetically shift var1 left by |
+ | -var2 with sign extension. Saturate the result in case of underflows or |
+ | overflows. |
| |
| Complexity weight : 1 |
| |
@@ -231,73 +126,20 @@ 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;
-
- L_diff = (Word32) var1 - var2;
- var_out = saturate (L_diff);
-#if (WMOPS)
- multiCounter[currCounter].sub++;
-#endif
- return (var_out);
-}
-/* ------------------------- End of sub() ------------------------- */
-
-
-/*___________________________________________________________________________
- | |
- | Function Name : abs_s |
- | |
- | Purpose : |
- | |
- | Absolute value of var1; abs_s(-32768) = 32767. |
- | |
- | Complexity weight : 1 |
- | |
- | Inputs : |
- | |
- | var1 |
- | 16 bit short signed integer (Word16) whose value falls in the |
- | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
- | |
- | Outputs : |
- | |
- | none |
- | |
- | Return Value : |
- | |
- | var_out |
- | 16 bit short signed integer (Word16) whose value falls in the |
- | range : 0x0000 0000 <= var_out <= 0x0000 7fff. |
- |___________________________________________________________________________|
-*/
-Word16 abs_s (Word16 var1)
+Word16 shr (Word16 var1, Word16 var2)
{
- Word16 var_out;
-
- if (var1 == (Word16) 0X8000)
+ if (var2 < 0)
{
- var_out = MAX_16;
+ if (var2 < -16)
+ var2 = -16;
+ return shl_nocheck(var1, (Word16) -var2);
}
else
{
- if (var1 < 0)
- {
- var_out = -var1;
- }
- else
- {
- var_out = var1;
- }
+ return shr_nocheck(var1, var2);
}
-#if (WMOPS)
- multiCounter[currCounter].abs_s++;
-#endif
- return (var_out);
}
-/* ------------------------- End of abs_s() ------------------------- */
+/* ------------------------- End of shr() ------------------------- */
/*___________________________________________________________________________
@@ -336,116 +178,18 @@ Word16 abs_s (Word16 var1)
*/
Word16 shl (Word16 var1, Word16 var2)
{
- Word16 var_out;
- Word32 result;
-
if (var2 < 0)
{
- if (var2 < -16)
- var2 = -16;
- var_out = shr (var1, (Word16) -var2);
-#if (WMOPS)
- multiCounter[currCounter].shr--;
-#endif
+ return shr_nocheck(var1, (Word16) -var2);
}
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);
-#if (WMOPS)
- multiCounter[currCounter].extract_l--;
-#endif
- }
+ return shl_nocheck(var1, var2);
}
-#if (WMOPS)
- multiCounter[currCounter].shl++;
-#endif
- return (var_out);
}
/* ------------------------- End of shl() ------------------------- */
-/*___________________________________________________________________________
- | |
- | Function Name : shr |
- | |
- | Purpose : |
- | |
- | Arithmetically shift the 16 bit input var1 right var2 positions with |
- | sign extension. If var2 is negative, arithmetically shift var1 left by |
- | -var2 with sign extension. Saturate the result in case of underflows or |
- | overflows. |
- | |
- | Complexity weight : 1 |
- | |
- | Inputs : |
- | |
- | 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 <= var1 <= 0x0000 7fff. |
- | |
- | 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 shr (Word16 var1, Word16 var2)
-{
- Word16 var_out;
-
- if (var2 < 0)
- {
- if (var2 < -16)
- var2 = -16;
- var_out = shl (var1, (Word16) -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;
- }
- }
- }
-
-#if (WMOPS)
- multiCounter[currCounter].shr++;
-#endif
- return (var_out);
-}
-/* ------------------------- End of shr() ------------------------- */
-
/*___________________________________________________________________________
| |
@@ -504,289 +248,6 @@ Word16 mult (Word16 var1, Word16 var2)
/*___________________________________________________________________________
| |
- | Function Name : L_mult |
- | |
- | Purpose : |
- | |
- | L_mult is the 32 bit result of the multiplication of var1 times var2 |
- | with one shift left i.e.: |
- | L_mult(var1,var2) = L_shl((var1 times var2),1) and |
- | L_mult(-32768,-32768) = 2147483647. |
- | |
- | Complexity weight : 1 |
- | |
- | Inputs : |
- | |
- | 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 <= var1 <= 0x0000 7fff. |
- | |
- | 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 L_mult (Word16 var1, Word16 var2)
-{
- Word32 L_var_out;
-
- 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 (WMOPS)
- multiCounter[currCounter].L_mult++;
-#endif
- return (L_var_out);
-}
-/* ------------------------- End of L_mult() ------------------------- */
-
-
-/*___________________________________________________________________________
- | |
- | Function Name : negate |
- | |
- | Purpose : |
- | |
- | Negate var1 with saturation, saturate in the case where input is -32768:|
- | negate(var1) = sub(0,var1). |
- | |
- | Complexity weight : 1 |
- | |
- | Inputs : |
- | |
- | var1 |
- | 16 bit short signed integer (Word16) whose value falls in the |
- | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
- | |
- | 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 negate (Word16 var1)
-{
- Word16 var_out;
-
- var_out = (var1 == MIN_16) ? MAX_16 : -var1;
-#if (WMOPS)
- multiCounter[currCounter].negate++;
-#endif
- return (var_out);
-}
-/* ------------------------- End of negate() ------------------------- */
-
-
-/*___________________________________________________________________________
- | |
- | Function Name : extract_h |
- | |
- | Purpose : |
- | |
- | Return the 16 MSB of L_var1. |
- | |
- | 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 : |
- | |
- | var_out |
- | 16 bit short signed integer (Word16) whose value falls in the |
- | range : 0xffff 8000 <= var_out <= 0x0000 7fff. |
- |___________________________________________________________________________|
-*/
-Word16 extract_h (Word32 L_var1)
-{
- Word16 var_out;
-
- var_out = (Word16) (L_var1 >> 16);
-#if (WMOPS)
- multiCounter[currCounter].extract_h++;
-#endif
- return (var_out);
-}
-/* ------------------------- End of extract_h() ------------------------- */
-
-
-/*___________________________________________________________________________
- | |
- | Function Name : extract_l |
- | |
- | Purpose : |
- | |
- | Return the 16 LSB of L_var1. |
- | |
- | 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 : |
- | |
- | var_out |
- | 16 bit short signed integer (Word16) whose value falls in the |
- | range : 0xffff 8000 <= var_out <= 0x0000 7fff. |
- |___________________________________________________________________________|
-*/
-Word16 extract_l (Word32 L_var1)
-{
- Word16 var_out;
-
- var_out = (Word16) L_var1;
-#if (WMOPS)
- multiCounter[currCounter].extract_l++;
-#endif
- return (var_out);
-}
-/* ------------------------- End of extract_l() ------------------------- */
-
-
-/*___________________________________________________________________________
- | |
- | Function Name : round |
- | |
- | Purpose : |
- | |
- | Round the lower 16 bits of the 32 bit input number into the MS 16 bits |
- | with saturation. Shift the resulting bits right by 16 and return the 16 |
- | bit number: |
- | round(L_var1) = extract_h(L_add(L_var1,32768)) |
- | |
- | 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 : |
- | |
- | var_out |
- | 16 bit short signed integer (Word16) whose value falls in the |
- | range : 0xffff 8000 <= var_out <= 0x0000 7fff. |
- |___________________________________________________________________________|
-*/
-Word16 itu_round (Word32 L_var1)
-{
- Word16 var_out;
- Word32 L_rounded;
-
- L_rounded = L_add (L_var1, (Word32) 0x00008000L);
-#if (WMOPS)
- multiCounter[currCounter].L_add--;
-#endif
- var_out = extract_h (L_rounded);
-#if (WMOPS)
- multiCounter[currCounter].extract_h--;
- multiCounter[currCounter].round++;
-#endif
- return (var_out);
-}
-/* ------------------------- End of round() ------------------------- */
-
-
-/*___________________________________________________________________________
- | |
- | Function Name : L_mac |
- | |
- | Purpose : |
- | |
- | Multiply var1 by var2 and shift the result left by 1. Add the 32 bit |
- | result to L_var3 with saturation, return a 32 bit result: |
- | L_mac(L_var3,var1,var2) = L_add(L_var3,L_mult(var1,var2)). |
- | |
- | Complexity weight : 1 |
- | |
- | Inputs : |
- | |
- | L_var3 32 bit long signed integer (Word32) whose value falls in the |
- | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. |
- | |
- | 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 <= var1 <= 0x0000 7fff. |
- | |
- | 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 L_mac (Word32 L_var3, Word16 var1, Word16 var2)
-{
- Word32 L_var_out;
- Word32 L_product;
-
- L_product = L_mult (var1, var2);
-#if (WMOPS)
- multiCounter[currCounter].L_mult--;
-#endif
- L_var_out = L_add (L_var3, L_product);
-#if (WMOPS)
- multiCounter[currCounter].L_add--;
- multiCounter[currCounter].L_mac++;
-#endif
- return (L_var_out);
-}
-/* ------------------------- End of L_mac() ------------------------- */
-
-
-/*___________________________________________________________________________
- | |
| Function Name : L_msu |
| |
| Purpose : |
@@ -839,7 +300,7 @@ Word32 L_msu (Word32 L_var3, Word16 var1, Word16 var2)
}
/* ------------------------- End of L_msu() ------------------------- */
-
+#if INCLUDE_UNSAFE
/*___________________________________________________________________________
| |
| Function Name : L_macNs |
@@ -897,9 +358,10 @@ Word32 L_macNs (Word32 L_var3, Word16 var1, Word16 var2)
#endif
return (L_var_out);
}
+#endif
/* ------------------------- End of L_macNs() ------------------------- */
-
+#if INCLUDE_UNSAFE
/*___________________________________________________________________________
| |
| Function Name : L_msuNs |
@@ -957,115 +419,12 @@ Word32 L_msuNs (Word32 L_var3, Word16 var1, Word16 var2)
#endif
return (L_var_out);
}
-/* ------------------------- End of L_msuNs() ------------------------- */
-
-
-/*___________________________________________________________________________
- | |
- | Function Name : L_add |
- | |
- | Purpose : |
- | |
- | 32 bits addition of the two 32 bits variables (L_var1+L_var2) with |
- | overflow control and saturation; the result is set at +2147483647 when |
- | overflow occurs or at -2147483648 when underflow occurs. |
- | |
- | Complexity weight : 2 |
- | |
- | Inputs : |
- | |
- | L_var1 32 bit long signed integer (Word32) whose value falls in the |
- | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. |
- | |
- | L_var2 32 bit long signed integer (Word32) whose value falls in the |
- | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. |
- | |
- | 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 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;
- }
- }
-#if (WMOPS)
- multiCounter[currCounter].L_add++;
#endif
- return (L_var_out);
-}
-/* ------------------------- End of L_add() ------------------------- */
-
-
-/*___________________________________________________________________________
- | |
- | Function Name : L_sub |
- | |
- | Purpose : |
- | |
- | 32 bits subtraction of the two 32 bits variables (L_var1-L_var2) with |
- | overflow control and saturation; the result is set at +2147483647 when |
- | overflow occurs or at -2147483648 when underflow occurs. |
- | |
- | Complexity weight : 2 |
- | |
- | Inputs : |
- | |
- | L_var1 32 bit long signed integer (Word32) whose value falls in the |
- | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. |
- | |
- | L_var2 32 bit long signed integer (Word32) whose value falls in the |
- | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. |
- | |
- | 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 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;
- }
- }
-#if (WMOPS)
- multiCounter[currCounter].L_sub++;
-#endif
- return (L_var_out);
-}
-/* ------------------------- End of L_sub() ------------------------- */
+/* ------------------------- End of L_msuNs() ------------------------- */
+#if INCLUDE_UNSAFE
/*___________________________________________________________________________
| |
| Function Name : L_add_c |
@@ -1109,13 +468,13 @@ Word32 L_add_c (Word32 L_var1, Word32 L_var2)
Word32 L_test;
Flag carry_int = 0;
- L_var_out = L_var1 + L_var2 + Carry;
+ L_var_out = L_var1 + L_var2 + GET_CARRY();
L_test = L_var1 + L_var2;
if ((L_var1 > 0) && (L_var2 > 0) && (L_test < 0))
{
- Overflow = 1;
+ SET_OVERFLOW(1);
carry_int = 0;
}
else
@@ -1124,12 +483,12 @@ Word32 L_add_c (Word32 L_var1, Word32 L_var2)
{
if (L_test >= 0)
{
- Overflow = 1;
+ SET_OVERFLOW(1);
carry_int = 1;
}
else
{
- Overflow = 0;
+ SET_OVERFLOW(0);
carry_int = 1;
}
}
@@ -1137,39 +496,39 @@ Word32 L_add_c (Word32 L_var1, Word32 L_var2)
{
if (((L_var1 ^ L_var2) < 0) && (L_test >= 0))
{
- Overflow = 0;
+ SET_OVERFLOW(0);
carry_int = 1;
}
else
{
- Overflow = 0;
+ SET_OVERFLOW(0);
carry_int = 0;
}
}
}
- if (Carry)
+ if (GET_CARRY())
{
if (L_test == MAX_32)
{
- Overflow = 1;
- Carry = carry_int;
+ SET_OVERFLOW(1);
+ SET_CARRY(carry_int);
}
else
{
if (L_test == (Word32) 0xFFFFFFFFL)
{
- Carry = 1;
+ SET_CARRY(1);
}
else
{
- Carry = carry_int;
+ SET_CARRY(carry_int);
}
}
}
else
{
- Carry = carry_int;
+ SET_CARRY(carry_int);
}
#if (WMOPS)
@@ -1177,9 +536,11 @@ Word32 L_add_c (Word32 L_var1, Word32 L_var2)
#endif
return (L_var_out);
}
-/* ------------------------- End of L_add_c() ------------------------- */
+#endif
+/* ------------------------- End of L_add_c() ------------------------- */
+#if INCLUDE_UNSAFE
/*___________________________________________________________________________
| |
| Function Name : L_sub_c |
@@ -1223,9 +584,9 @@ Word32 L_sub_c (Word32 L_var1, Word32 L_var2)
Word32 L_test;
Flag carry_int = 0;
- if (Carry)
+ if (GET_CARRY())
{
- Carry = 0;
+ SET_CARRY(0);
if (L_var2 != MIN_32)
{
L_var_out = L_add_c (L_var1, -L_var2);
@@ -1238,8 +599,8 @@ Word32 L_sub_c (Word32 L_var1, Word32 L_var2)
L_var_out = L_var1 - L_var2;
if (L_var1 > 0L)
{
- Overflow = 1;
- Carry = 0;
+ SET_OVERFLOW(1);
+ SET_CARRY(0);
}
}
}
@@ -1250,27 +611,27 @@ Word32 L_sub_c (Word32 L_var1, Word32 L_var2)
if ((L_test < 0) && (L_var1 > 0) && (L_var2 < 0))
{
- Overflow = 1;
+ SET_OVERFLOW(1);
carry_int = 0;
}
else if ((L_test > 0) && (L_var1 < 0) && (L_var2 > 0))
{
- Overflow = 1;
+ SET_OVERFLOW(1);
carry_int = 1;
}
else if ((L_test > 0) && ((L_var1 ^ L_var2) > 0))
{
- Overflow = 0;
+ SET_OVERFLOW(0);
carry_int = 1;
}
if (L_test == MIN_32)
{
- Overflow = 1;
- Carry = carry_int;
+ SET_OVERFLOW(1);
+ SET_CARRY(carry_int);
}
else
{
- Carry = carry_int;
+ SET_CARRY(carry_int);
}
}
@@ -1279,6 +640,7 @@ Word32 L_sub_c (Word32 L_var1, Word32 L_var2)
#endif
return (L_var_out);
}
+#endif
/* ------------------------- End of L_sub_c() ------------------------- */
@@ -1378,154 +740,6 @@ Word16 mult_r (Word16 var1, Word16 var2)
/* ------------------------- End of mult_r() ------------------------- */
-/*___________________________________________________________________________
- | |
- | Function Name : L_shl |
- | |
- | Purpose : |
- | |
- | Arithmetically shift the 32 bit input L_var1 left var2 positions. Zero |
- | fill the var2 LSB of the result. If var2 is negative, arithmetically |
- | shift L_var1 right by -var2 with sign extension. Saturate the result in |
- | case of underflows or overflows. |
- | |
- | Complexity weight : 2 |
- | |
- | Inputs : |
- | |
- | L_var1 32 bit long signed integer (Word32) whose value falls in the |
- | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. |
- | |
- | var2 |
- | 16 bit short signed integer (Word16) whose value falls in the |
- | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
- | |
- | 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 L_shl (Word32 L_var1, Word16 var2)
-{
- Word32 L_var_out;
-
- if (var2 <= 0)
- {
- if (var2 < -32)
- var2 = -32;
- L_var_out = L_shr (L_var1, (Word16) -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;
- }
- }
-#if (WMOPS)
- multiCounter[currCounter].L_shl++;
-#endif
- return (L_var_out);
-}
-/* ------------------------- End of L_shl() ------------------------- */
-
-
-/*___________________________________________________________________________
- | |
- | Function Name : L_shr |
- | |
- | Purpose : |
- | |
- | Arithmetically shift the 32 bit input L_var1 right var2 positions with |
- | sign extension. If var2 is negative, arithmetically shift L_var1 left |
- | by -var2 and zero fill the -var2 LSB of the result. Saturate the result |
- | in case of underflows or overflows. |
- | |
- | Complexity weight : 2 |
- | |
- | Inputs : |
- | |
- | L_var1 32 bit long signed integer (Word32) whose value falls in the |
- | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. |
- | |
- | var2 |
- | 16 bit short signed integer (Word16) whose value falls in the |
- | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
- | |
- | 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 L_shr (Word32 L_var1, Word16 var2)
-{
- Word32 L_var_out;
-
- if (var2 < 0)
- {
- if (var2 < -32)
- var2 = -32;
- L_var_out = L_shl (L_var1, (Word16) -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;
- }
- }
- }
-#if (WMOPS)
- multiCounter[currCounter].L_shr++;
-#endif
- return (L_var_out);
-}
-/* ------------------------- End of L_shr() ------------------------- */
-
/*___________________________________________________________________________
| |
@@ -1930,65 +1144,6 @@ Word32 L_abs (Word32 L_var1)
/*___________________________________________________________________________
| |
- | Function Name : L_sat |
- | |
- | Purpose : |
- | |
- | 32 bit L_var1 is set to 2147483647 if an overflow occured or to |
- | -2147483648 if an underflow occured on the most recent L_add_c, |
- | L_sub_c, L_macNs or L_msuNs operations. The carry and overflow values |
- | are binary values which can be tested and assigned values. |
- | |
- | Complexity weight : 4 |
- | |
- | Inputs : |
- | |
- | L_var1 |
- | 32 bit long signed integer (Word32) whose value falls in the |
- | range : 0x8000 0000 <= var1 <= 0x7fff ffff. |
- | |
- | Outputs : |
- | |
- | none |
- | |
- | Return Value : |
- | |
- | L_var_out |
- | 32 bit long signed integer (Word32) whose value falls in the |
- | range : 0x8000 0000 <= var_out <= 0x7fff ffff. |
- |___________________________________________________________________________|
-*/
-Word32 L_sat (Word32 L_var1)
-{
- Word32 L_var_out;
-
- L_var_out = L_var1;
-
- if (Overflow)
- {
-
- if (Carry)
- {
- L_var_out = MIN_32;
- }
- else
- {
- L_var_out = MAX_32;
- }
-
- Carry = 0;
- Overflow = 0;
- }
-#if (WMOPS)
- multiCounter[currCounter].L_sat++;
-#endif
- return (L_var_out);
-}
-/* ------------------------- End of L_sat() ------------------------- */
-
-
-/*___________________________________________________________________________
- | |
| Function Name : norm_s |
| |
| Purpose : |
@@ -2275,7 +1430,7 @@ Word32 L_mls (Word32 Lv, Word16 v)
Temp = Lv & (Word32) 0x0000ffff ;
Temp = Temp * (Word32) v ;
- Temp = L_shr( Temp, (Word16) 15 ) ;
+ Temp = L_shr_nocheck( Temp, (Word16) 15 ) ;
Temp = L_mac( Temp, v, extract_h(Lv) ) ;
#if (WMOPS)
@@ -2357,14 +1512,14 @@ Word16 div_l (Word32 L_num, Word16 den)
return MAX_16 ;
}
else {
- L_num = L_shr(L_num, (Word16)1) ;
- L_den = L_shr(L_den, (Word16)1);
+ L_num = L_shr_nocheck(L_num, (Word16)1) ;
+ L_den = L_shr_nocheck(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);
+ var_out = shl_nocheck( var_out, (Word16)1);
+ L_num = L_shl_nocheck( L_num, (Word16)1);
#if (WMOPS)
multiCounter[currCounter].shl--;
multiCounter[currCounter].L_shl--;
@@ -2628,7 +1783,7 @@ UWord32 LU_shl (UWord32 L_var1, Word16 var2)
{
if (L_var1 > (UWord32) 0X7fffffffL)
{
- Overflow = 1;
+ SET_OVERFLOW(1);
L_var_out = UMAX_32;
break;
}
@@ -2636,7 +1791,7 @@ UWord32 LU_shl (UWord32 L_var1, Word16 var2)
{
if (L_var1 < (UWord32) 0x00000001L)
{
- Overflow = 1;
+ SET_OVERFLOW(1);
L_var_out = MIN_32;
break;
}
diff --git a/third_party/g7221/common/stl-files/basop32.h b/third_party/g7221/common/stl-files/basop32.h
index 308f8d32..14da776d 100644
--- a/third_party/g7221/common/stl-files/basop32.h
+++ b/third_party/g7221/common/stl-files/basop32.h
@@ -33,7 +33,7 @@ extern Flag Carry;
#define MIN_32 (Word32)0x80000000L
#define MAX_16 (Word16)0x7fff
-#define MIN_16 (Word16)0x8000
+#define MIN_16 ((Word16)0x8000)
#define UMAX_32 (Word32)0xffffffffL
#define UMIN_32 (Word32)0x00000000L
@@ -44,31 +44,33 @@ 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 */
+PJ_INLINE(Word16) add (Word16 var1, Word16 var2); /* Short add, 1 */
+PJ_INLINE(Word16) sub (Word16 var1, Word16 var2); /* Short sub, 1 */
+PJ_INLINE(Word16) abs_s (Word16 var1); /* Short abs, 1 */
Word16 shl (Word16 var1, Word16 var2); /* Short shift left, 1 */
+PJ_INLINE(Word16) shl_nocheck(Word16 var1, Word16 var2);
Word16 shr (Word16 var1, Word16 var2); /* Short shift right, 1 */
+PJ_INLINE(Word16) shr_nocheck(Word16 var1, Word16 var2);
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 itu_round (Word32 L_var1); /* Round, 1 */
-Word32 L_mac (Word32 L_var3, Word16 var1, Word16 var2); /* Mac, 1 */
+PJ_INLINE(Word32) L_mult (Word16 var1, Word16 var2); /* Long mult, 1 */
+PJ_INLINE(Word16) negate (Word16 var1); /* Short negate, 1 */
+PJ_INLINE(Word16) extract_h (Word32 L_var1); /* Extract high, 1 */
+PJ_INLINE(Word16) extract_l (Word32 L_var1); /* Extract low, 1 */
+PJ_INLINE(Word16) itu_round (Word32 L_var1); /* Round, 1 */
+PJ_INLINE(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, 2 */
-Word32 L_sub (Word32 L_var1, Word32 L_var2); /* Long sub, 2 */
+//PJ_INLINE(Word32) L_add (Word32 L_var1, Word32 L_var2); /* Long add, 2 */
+PJ_INLINE(Word32) L_sub (Word32 L_var1, Word32 L_var2); /* Long sub, 2 */
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, 2 */
Word16 mult_r (Word16 var1, Word16 var2); /* Mult with round, 2 */
-Word32 L_shl (Word32 L_var1, Word16 var2); /* Long shift left, 2 */
-Word32 L_shr (Word32 L_var1, Word16 var2); /* Long shift right, 2*/
+PJ_INLINE(Word32) L_shl (Word32 L_var1, Word16 var2); /* Long shift left, 2 */
+PJ_INLINE(Word32) L_shr (Word32 L_var1, Word16 var2); /* Long shift right, 2*/
Word16 shr_r (Word16 var1, Word16 var2); /* Shift right with
round, 2 */
Word16 mac_r (Word32 L_var3, Word16 var1, Word16 var2); /* Mac with
@@ -105,6 +107,29 @@ Word32 L_msu0(Word32 L_v3, Word16 v1, Word16 v2); /* 32-bit Msu w/o shift 1 */
*/
UWord32 LU_shl (UWord32 L_var1, Word16 var2);
UWord32 LU_shr (UWord32 L_var1, Word16 var2);
+
+#define INCLUDE_UNSAFE 0
+
+/* Local */
+PJ_INLINE(Word16) saturate (Word32 L_var1);
+
+#if INCLUDE_UNSAFE
+ extern Flag g7221_Overflow;
+ extern Flag g7221_Carry;
+# define SET_OVERFLOW(n) g7221_Overflow = n
+# define SET_CARRY(n) g7221_Carry = n
+
+#else
+# define SET_OVERFLOW(n)
+# define SET_CARRY(n)
+# define GET_OVERFLOW() 0
+# define GET_CARRY() 0
+#endif
+
+#include "basop32_i.h"
+
+
+
#endif /* BASOP_H_DEFINED */
diff --git a/third_party/g7221/common/stl-files/basop32_i.h b/third_party/g7221/common/stl-files/basop32_i.h
new file mode 100644
index 00000000..ca61ed0b
--- /dev/null
+++ b/third_party/g7221/common/stl-files/basop32_i.h
@@ -0,0 +1,730 @@
+/*___________________________________________________________________________
+ | |
+ | Function Name : extract_h |
+ | |
+ | Purpose : |
+ | |
+ | Return the 16 MSB of L_var1. |
+ | |
+ | 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 : |
+ | |
+ | var_out |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var_out <= 0x0000 7fff. |
+ |___________________________________________________________________________|
+*/
+PJ_INLINE(Word16) extract_h (Word32 L_var1)
+{
+ return (Word16) (L_var1 >> 16);
+}
+/* ------------------------- End of extract_h() ------------------------- */
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : extract_l |
+ | |
+ | Purpose : |
+ | |
+ | Return the 16 LSB of L_var1. |
+ | |
+ | 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 : |
+ | |
+ | var_out |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var_out <= 0x0000 7fff. |
+ |___________________________________________________________________________|
+*/
+PJ_INLINE(Word16) extract_l (Word32 L_var1)
+{
+ return (Word16) L_var1;
+}
+
+/* ------------------------- End of extract_l() ------------------------- */
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : saturate |
+ | |
+ | Purpose : |
+ | |
+ | Limit the 32 bit input to the range of a 16 bit word. |
+ | |
+ | 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 : |
+ | |
+ | var_out |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var_out <= 0x0000 7fff. |
+ |___________________________________________________________________________|
+*/
+PJ_INLINE(Word16) saturate (Word32 L_var1)
+{
+ Word16 val16 = (Word16) L_var1;
+
+ if (val16 == L_var1)
+ return val16;
+
+ if (val16 > MAX_16)
+ return MAX_16;
+ return MIN_16;
+}
+/* ------------------------- End of saturate() ------------------------- */
+
+
+#if PJ_HAS_INT64
+PJ_INLINE(Word32) L_saturate (pj_int64_t LL_var1)
+{
+ pj_int32_t L_var1 = (pj_int32_t)LL_var1;
+ if (LL_var1 == L_var1)
+ return L_var1;
+ else if (LL_var1 > MAX_32)
+ return MAX_32;
+ else
+ return MIN_32;
+}
+#endif
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : add |
+ | |
+ | Purpose : |
+ | |
+ | Performs the addition (var1+var2) with overflow control and saturation;|
+ | the 16 bit result is set at +32767 when overflow occurs or at -32768 |
+ | when underflow occurs. |
+ | |
+ | Complexity weight : 1 |
+ | |
+ | Inputs : |
+ | |
+ | 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 <= var1 <= 0x0000 7fff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | var_out |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var_out <= 0x0000 7fff. |
+ |___________________________________________________________________________|
+*/
+PJ_INLINE(Word16) add (Word16 var1, Word16 var2)
+{
+ return saturate (var1 + var2);
+}
+/* ------------------------- End of add() ------------------------- */
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : sub |
+ | |
+ | Purpose : |
+ | |
+ | Performs the subtraction (var1+var2) with overflow control and satu- |
+ | ration; the 16 bit result is set at +32767 when overflow occurs or at |
+ | -32768 when underflow occurs. |
+ | |
+ | Complexity weight : 1 |
+ | |
+ | Inputs : |
+ | |
+ | 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 <= var1 <= 0x0000 7fff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | var_out |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var_out <= 0x0000 7fff. |
+ |___________________________________________________________________________|
+*/
+PJ_INLINE(Word16) sub (Word16 var1, Word16 var2)
+{
+ return saturate ((Word32) var1 - var2);
+}
+/* ------------------------- End of sub() ------------------------- */
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : negate |
+ | |
+ | Purpose : |
+ | |
+ | Negate var1 with saturation, saturate in the case where input is -32768:|
+ | negate(var1) = sub(0,var1). |
+ | |
+ | Complexity weight : 1 |
+ | |
+ | Inputs : |
+ | |
+ | var1 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | var_out |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var_out <= 0x0000 7fff. |
+ |___________________________________________________________________________|
+*/
+PJ_INLINE(Word16) negate (Word16 var1)
+{
+ return (Word16)((var1 == MIN_16) ? MAX_16 : -var1);
+}
+/* ------------------------- End of negate() ------------------------- */
+
+
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : L_add |
+ | |
+ | Purpose : |
+ | |
+ | 32 bits addition of the two 32 bits variables (L_var1+L_var2) with |
+ | overflow control and saturation; the result is set at +2147483647 when |
+ | overflow occurs or at -2147483648 when underflow occurs. |
+ | |
+ | Complexity weight : 2 |
+ | |
+ | Inputs : |
+ | |
+ | L_var1 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. |
+ | |
+ | L_var2 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. |
+ | |
+ | 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. |
+ |___________________________________________________________________________|
+*/
+PJ_INLINE(Word32) L_add (Word32 L_var1, Word32 L_var2)
+{
+#if PJ_HAS_INT64
+ return L_saturate(((pj_int64_t)L_var1) + L_var2);
+#else
+ 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)
+ {
+ SET_OVERFLOW(1);
+ L_var_out = (L_var1 < 0) ? MIN_32 : MAX_32;
+ }
+ }
+ return (L_var_out);
+#endif
+}
+
+/* ------------------------- End of L_add() ------------------------- */
+
+
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : L_sub |
+ | |
+ | Purpose : |
+ | |
+ | 32 bits subtraction of the two 32 bits variables (L_var1-L_var2) with |
+ | overflow control and saturation; the result is set at +2147483647 when |
+ | overflow occurs or at -2147483648 when underflow occurs. |
+ | |
+ | Complexity weight : 2 |
+ | |
+ | Inputs : |
+ | |
+ | L_var1 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. |
+ | |
+ | L_var2 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. |
+ | |
+ | 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. |
+ |___________________________________________________________________________|
+*/
+PJ_INLINE(Word32) L_sub (Word32 L_var1, Word32 L_var2)
+{
+#if PJ_HAS_INT64
+ return L_saturate((pj_int64_t)L_var1 - L_var2);
+#else
+ 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;
+ SET_OVERFLOW(1);
+ }
+ }
+ return (L_var_out);
+#endif
+}
+/* ------------------------- End of L_sub() ------------------------- */
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : L_mult |
+ | |
+ | Purpose : |
+ | |
+ | L_mult is the 32 bit result of the multiplication of var1 times var2 |
+ | with one shift left i.e.: |
+ | L_mult(var1,var2) = L_shl((var1 times var2),1) and |
+ | L_mult(-32768,-32768) = 2147483647. |
+ | |
+ | Complexity weight : 1 |
+ | |
+ | Inputs : |
+ | |
+ | 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 <= var1 <= 0x0000 7fff. |
+ | |
+ | 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. |
+ |___________________________________________________________________________|
+*/
+PJ_INLINE(Word32) L_mult (Word16 var1, Word16 var2)
+{
+ Word32 L_var_out;
+
+ L_var_out = (Word32) var1 *(Word32) var2;
+
+ if (L_var_out != (Word32) 0x40000000L)
+ {
+ return L_var_out << 1;
+ }
+ else
+ {
+ SET_OVERFLOW(1);
+ return MAX_32;
+ }
+}
+/* ------------------------- End of L_mult() ------------------------- */
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : L_mac |
+ | |
+ | Purpose : |
+ | |
+ | Multiply var1 by var2 and shift the result left by 1. Add the 32 bit |
+ | result to L_var3 with saturation, return a 32 bit result: |
+ | L_mac(L_var3,var1,var2) = L_add(L_var3,L_mult(var1,var2)). |
+ | |
+ | Complexity weight : 1 |
+ | |
+ | Inputs : |
+ | |
+ | L_var3 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. |
+ | |
+ | 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 <= var1 <= 0x0000 7fff. |
+ | |
+ | 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. |
+ |___________________________________________________________________________|
+*/
+PJ_INLINE(Word32) L_mac (Word32 L_var3, Word16 var1, Word16 var2)
+{
+ return L_add (L_var3, L_mult (var1, var2));
+}
+/* ------------------------- End of L_mac() ------------------------- */
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : round |
+ | |
+ | Purpose : |
+ | |
+ | Round the lower 16 bits of the 32 bit input number into the MS 16 bits |
+ | with saturation. Shift the resulting bits right by 16 and return the 16 |
+ | bit number: |
+ | round(L_var1) = extract_h(L_add(L_var1,32768)) |
+ | |
+ | 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 : |
+ | |
+ | var_out |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var_out <= 0x0000 7fff. |
+ |___________________________________________________________________________|
+*/
+PJ_INLINE(Word16) itu_round (Word32 L_var1)
+{
+ return extract_h (L_add (L_var1, (Word32) 0x00008000L));
+}
+/* ------------------------- End of round() ------------------------- */
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : L_shr |
+ | |
+ | Purpose : |
+ | |
+ | Arithmetically shift the 32 bit input L_var1 right var2 positions with |
+ | sign extension. If var2 is negative, arithmetically shift L_var1 left |
+ | by -var2 and zero fill the -var2 LSB of the result. Saturate the result |
+ | in case of underflows or overflows. |
+ | |
+ | Complexity weight : 2 |
+ | |
+ | Inputs : |
+ | |
+ | L_var1 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. |
+ | |
+ | var2 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+ | |
+ | 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. |
+ |___________________________________________________________________________|
+*/
+PJ_INLINE(Word32) L_shr_nocheck(Word32 L_var1, Word16 var2)
+{
+#if 1
+ return L_var1 >> var2;
+#else
+ if (var2 >= 31)
+ {
+ return (L_var1 < 0L) ? -1 : 0;
+ }
+ else
+ {
+ if (L_var1 < 0)
+ {
+ return ~((~L_var1) >> var2);
+ }
+ else
+ {
+ return L_var1 >> var2;
+ }
+ }
+#endif
+}
+
+PJ_INLINE(Word32) L_shl_nocheck (Word32 L_var1, Word16 var2)
+{
+#if PJ_HAS_INT64
+ return L_saturate( ((pj_int64_t)L_var1) << var2 );
+#else
+ for (; var2 > 0; var2--)
+ {
+ if (L_var1 > (Word32) 0X3fffffffL)
+ {
+ SET_OVERFLOW(1);
+ return MAX_32;
+ }
+ else
+ {
+ if (L_var1 < (Word32) 0xc0000000L)
+ {
+ SET_OVERFLOW(1);
+ return MIN_32;
+ }
+ }
+ L_var1 <<= 1;
+ }
+ return (L_var1);
+#endif
+}
+
+PJ_INLINE(Word32) L_shr (Word32 L_var1, Word16 var2)
+{
+ if (var2 < 0)
+ {
+ if (var2 < -32)
+ var2 = -32;
+ return L_shl_nocheck (L_var1, (Word16) -var2);
+ }
+ else
+ {
+ return L_shr_nocheck(L_var1, var2);
+ }
+}
+/* ------------------------- End of L_shr() ------------------------- */
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : L_shl |
+ | |
+ | Purpose : |
+ | |
+ | Arithmetically shift the 32 bit input L_var1 left var2 positions. Zero |
+ | fill the var2 LSB of the result. If var2 is negative, arithmetically |
+ | shift L_var1 right by -var2 with sign extension. Saturate the result in |
+ | case of underflows or overflows. |
+ | |
+ | Complexity weight : 2 |
+ | |
+ | Inputs : |
+ | |
+ | L_var1 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. |
+ | |
+ | var2 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+ | |
+ | 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. |
+ |___________________________________________________________________________|
+*/
+PJ_INLINE(Word32) L_shl (Word32 L_var1, Word16 var2)
+{
+ if (var2 <= 0)
+ {
+ if (var2 < -32)
+ var2 = -32;
+ return L_shr_nocheck(L_var1, (Word16) -var2);
+ }
+ else
+ {
+ return L_shl_nocheck(L_var1, var2);
+ }
+}
+/* ------------------------- End of L_shl() ------------------------- */
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : abs_s |
+ | |
+ | Purpose : |
+ | |
+ | Absolute value of var1; abs_s(-32768) = 32767. |
+ | |
+ | Complexity weight : 1 |
+ | |
+ | Inputs : |
+ | |
+ | var1 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | var_out |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0x0000 0000 <= var_out <= 0x0000 7fff. |
+ |___________________________________________________________________________|
+*/
+PJ_INLINE(Word16) abs_s (Word16 var1)
+{
+#if 1
+ if (var1 >= 0)
+ return var1;
+ else if (var1 == (Word16)0x8000)
+ return MAX_16;
+ else
+ return (Word16)-var1;
+#else
+ if (var1 == (Word16) 0x8000)
+ {
+ return MAX_16;
+ }
+ else
+ {
+ if (var1 < 0)
+ {
+ return (Word16)-var1;
+ }
+ else
+ {
+ return var1;
+ }
+ }
+#endif
+}
+/* ------------------------- End of abs_s() ------------------------- */
+
+
+PJ_INLINE(Word16) shl_nocheck(Word16 var1, Word16 var2)
+{
+#if 1
+ /* blp: this should be more optimized */
+ return saturate (((Word32)var1) << var2);
+#else
+ /* Original algorithm */
+ Word32 result = (Word32) var1 *((Word32) 1 << var2);
+
+ if ((var2 > 15 && var1 != 0) || (result != (Word32) ((Word16) result)))
+ {
+ SET_OVERFLOW(1);
+ return (Word16) ((var1 > 0) ? MAX_16 : MIN_16);
+ }
+ else
+ {
+ return extract_l (result);
+ }
+#endif
+}
+
+PJ_INLINE(Word16) shr_nocheck(Word16 var1, Word16 var2)
+{
+#if 1
+ /* blp: this should yield the same value */
+ return (Word16) (var1 >> var2);
+#else
+ /* Original algorithm */
+ if (var2 >= 15)
+ {
+ return (Word16)((var1 < 0) ? -1 : 0);
+ }
+ else
+ {
+ if (var1 < 0)
+ {
+ return (Word16) (~((~var1) >> var2));
+ }
+ else
+ {
+ return (Word16)(var1 >> var2);
+ }
+ }
+#endif
+}
diff --git a/third_party/g7221/common/stl-files/count.c b/third_party/g7221/common/stl-files/count.c
deleted file mode 100644
index 17ce4b32..00000000
--- a/third_party/g7221/common/stl-files/count.c
+++ /dev/null
@@ -1,303 +0,0 @@
-/*
- ***************************************************************************
- *
- * This file contains functions for the automatic complexity calculation
- * $Id $
- ***************************************************************************
-*/
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include "typedef.h"
-#include "count.h"
-
-/* Global counter variable for calculation of complexity weight */
-
-BASIC_OP multiCounter[MAXCOUNTERS];
-int currCounter=0; /* Zero equals global counter */
-
-/*BASIC_OP counter;*/
-const BASIC_OP op_weight =
-{
- /* G.729 & G.723.1 common operators */
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 3, 3, 3, 4, 15, 18, 30, 1, 2, 1, 2, 2,
- /* G.723.1 exclusives */
- 6, 1, 1,
- /* shiftless 32-bit operators */
- 1, 1, 1,
- /* G.722.1 exclusives */
- 1, 1
-};
-
-/* function prototypes */
-Word32 TotalWeightedOperation (void);
-Word32 DeltaWeightedOperation (void);
-
-/* local variable */
-#if WMOPS
-
-/* Counters for separating counting for different objects */
-static int maxCounter=0;
-static char* objectName[MAXCOUNTERS+1];
-static Word16 fwc_corr[MAXCOUNTERS+1];
-
-#define NbFuncMax 1024
-
-static Word16 funcid[MAXCOUNTERS], nbframe[MAXCOUNTERS];
-static Word32 glob_wc[MAXCOUNTERS], wc[MAXCOUNTERS][NbFuncMax];
-static float total_wmops[MAXCOUNTERS];
-
-static Word32 LastWOper[MAXCOUNTERS];
-
-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
-
-int getCounterId(char *objectNameArg)
-{
-#if WMOPS
- if(maxCounter>=MAXCOUNTERS-1) return 0;
- objectName[++maxCounter]=my_strdup(objectNameArg);
- return maxCounter;
-#else
- return 0; /* Dummy */
-#endif
-}
-
-void setCounter(int counterId)
-{
-#if WMOPS
- if(counterId>maxCounter || counterId<0)
- {
- currCounter=0;
- return;
- }
- currCounter=counterId;
-#endif
-}
-
-#if WMOPS
-static Word32 WMOPS_frameStat()
-/* 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;
-
- /* 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;
-}
-
-static void WMOPS_clearMultiCounter()
-{
- Word16 i;
-
- Word32 *ptr = (Word32 *) &multiCounter[currCounter];
- for (i = 0; i < (sizeof (multiCounter[currCounter])/ sizeof (Word32)); i++)
- {
- *ptr++ = 0;
- }
-}
-#endif
-
-Word32 TotalWeightedOperation ()
-{
-#if WMOPS
- Word16 i;
- Word32 tot, *ptr, *ptr2;
-
- tot = 0;
- ptr = (Word32 *) &multiCounter[currCounter];
- ptr2 = (Word32 *) &op_weight;
- for (i = 0; i < (sizeof (multiCounter[currCounter])/ sizeof (Word32)); i++)
- {
- tot += ((*ptr++) * (*ptr2++));
- }
-
- return ((Word32) tot);
-#else
- return 0; /* Dummy */
-#endif
-}
-
-Word32 DeltaWeightedOperation ()
-{
-#if WMOPS
- Word32 NewWOper, delta;
-
- NewWOper = TotalWeightedOperation ();
- delta = NewWOper - LastWOper[currCounter];
- LastWOper[currCounter] = NewWOper;
- return (delta);
-#else
- return 0; /* Dummy */
-#endif
-}
-
-void move16 (void)
-{
-#if WMOPS
- multiCounter[currCounter].DataMove16++;
-#endif
-}
-
-void move32 (void)
-{
-#if WMOPS
- multiCounter[currCounter].DataMove32++;
-#endif
-}
-
-void test (void)
-{
-#if WMOPS
- multiCounter[currCounter].Test++;
-#endif
-}
-
-void logic16 (void)
-{
-#if WMOPS
- multiCounter[currCounter].Logic16++;
-#endif
-}
-
-void logic32 (void)
-{
-#if WMOPS
- multiCounter[currCounter].Logic32++;
-#endif
-}
-
-void Init_WMOPS_counter (void)
-{
-#if 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;
-
- /* initially clear all counters */
- WMOPS_clearMultiCounter();
- LastWOper[currCounter] = 0;
- funcid[currCounter] = 0;
-#endif
-}
-
-
-void Reset_WMOPS_counter (void)
-{
-#if WMOPS
- Word32 tot = WMOPS_frameStat();
-
- /* 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) * 0.00005;
-
- /* clear counter before new frame starts */
- WMOPS_clearMultiCounter();
- LastWOper[currCounter] = 0;
- funcid[currCounter] = 0; /* new frame, set function id to zero */
-#endif
-}
-
-Word32 fwc (void) /* function worst case */
-{
-#if WMOPS
- Word32 tot;
-
- tot = DeltaWeightedOperation ();
- if (tot > wc[currCounter][funcid[currCounter]])
- wc[currCounter][funcid[currCounter]] = tot;
-
- funcid[currCounter]++;
-
- return (tot);
-#else
- return 0; /* Dummy */
-#endif
-}
-
-void WMOPS_output (Word16 dtx_mode)
-{
-#if 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 = total_wmops[currCounter] + ((float) tot) * 0.00005;
-
- fprintf (stdout, "%10s:WMOPS=%.3f",
- objectName[currCounter]?objectName[currCounter]:"",
- ((float) tot) * 0.00005);
-
- if (nbframe[currCounter] != 0)
- fprintf (stdout, " Average=%.3f",
- tot_wm / (float) nbframe[currCounter]);
-
- fprintf (stdout, " WorstCase=%.3f",
- ((float) glob_wc[currCounter]) * 0.00005);
-
- /* 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) * 0.00005);
- }
- fprintf (stdout, " (%d frames)\n", nbframe[currCounter]);
-
-#endif
-}
diff --git a/third_party/g7221/common/stl-files/count.h b/third_party/g7221/common/stl-files/count.h
index 5f2227ef..34c04610 100644
--- a/third_party/g7221/common/stl-files/count.h
+++ b/third_party/g7221/common/stl-files/count.h
@@ -35,6 +35,7 @@
operators L_mult0(), L_mac0(), L_msu0()
===========================================================================
*/
+#if 0
#ifndef COUNT_H
#define COUNT_H "$Id $"
@@ -71,7 +72,23 @@ void WMOPS_output (Word16 notPrintWorstWorstCase);
*
*/
-Word32 fwc (void);
+PJ_INLINE(Word32) fwc (void)
+{
+#if WMOPS
+ Word32 tot;
+
+ tot = DeltaWeightedOperation ();
+ if (tot > wc[currCounter][funcid[currCounter]])
+ wc[currCounter][funcid[currCounter]] = tot;
+
+ funcid[currCounter]++;
+
+ return (tot);
+#else
+ return 0; /* Dummy */
+#endif
+}
+
/*
* worst worst case counter.
*
@@ -82,12 +99,42 @@ Word32 fwc (void);
*
* The WMOPS_output function add together all parts and presents the sum.
*/
+PJ_INLINE(void) move16 (void)
+{
+#if WMOPS
+ multiCounter[currCounter].DataMove16++;
+#endif
+}
+
+PJ_INLINE(void) move32 (void)
+{
+#if WMOPS
+ multiCounter[currCounter].DataMove32++;
+#endif
+}
+
+PJ_INLINE(void )logic16 (void)
+{
+#if WMOPS
+ multiCounter[currCounter].Logic16++;
+#endif
+}
+
+PJ_INLINE(void) logic32 (void)
+{
+#if WMOPS
+ multiCounter[currCounter].Logic32++;
+#endif
+}
+
+PJ_INLINE(void) test (void)
+{
+#if WMOPS
+ multiCounter[currCounter].Test++;
+#endif
+}
+
-void move16 (void);
-void move32 (void);
-void logic16 (void);
-void logic32 (void);
-void test (void);
/*
* The functions above increases the corresponding operation counter for
* the current counter group.
@@ -205,3 +252,12 @@ int main()
#endif /* Example */
#endif /* COUNT_H */
+#else
+
+#define move16()
+#define move32()
+#define logic16()
+#define logic32()
+#define test()
+
+#endif
diff --git a/third_party/g7221/decode/coef2sam.c b/third_party/g7221/decode/coef2sam.c
index a52095d1..87deab0e 100644
--- a/third_party/g7221/decode/coef2sam.c
+++ b/third_party/g7221/decode/coef2sam.c
@@ -88,7 +88,7 @@ void rmlt_coefs_to_samples(Word16 *coefs,
- half_dct_size = shr(dct_length,1);
+ half_dct_size = shr_nocheck(dct_length,1);
/* Perform a Type IV (inverse) DCT on the coefficients */
dct_type_iv_s(coefs, new_samples, dct_length);
@@ -98,7 +98,7 @@ void rmlt_coefs_to_samples(Word16 *coefs,
{
for(index=0;index<dct_length;index++)
{
- new_samples[index] = shr(new_samples[index],mag_shift);
+ new_samples[index] = shr_nocheck(new_samples[index],mag_shift);
move16();
}
}
@@ -110,7 +110,7 @@ void rmlt_coefs_to_samples(Word16 *coefs,
mag_shift = negate(mag_shift);
for(index=0;index<dct_length;index++)
{
- new_samples[index] = shl(new_samples[index],mag_shift);
+ new_samples[index] = shl_nocheck(new_samples[index],mag_shift);
move16();
}
}
@@ -147,7 +147,7 @@ void rmlt_coefs_to_samples(Word16 *coefs,
move32();
sum = L_mac(sum,*win_new++, *--new_ptr);
sum = L_mac(sum,*--win_old, *old_ptr++);
- *out_ptr++ = itu_round(L_shl(sum,2));
+ *out_ptr++ = itu_round(L_shl_nocheck(sum,2));
move16();
}
@@ -160,7 +160,7 @@ void rmlt_coefs_to_samples(Word16 *coefs,
move32();
sum = L_mac(sum,*win_new++, *new_ptr++);
sum = L_mac(sum,negate(*--win_old), *--old_ptr);
- *out_ptr++ = itu_round(L_shl(sum,2));
+ *out_ptr++ = itu_round(L_shl_nocheck(sum,2));
move16();
}
diff --git a/third_party/g7221/decode/dct4_s.c b/third_party/g7221/decode/dct4_s.c
index 82405a31..0123a13b 100644
--- a/third_party/g7221/decode/dct4_s.c
+++ b/third_party/g7221/decode/dct4_s.c
@@ -140,9 +140,9 @@ void dct_type_iv_s (Word16 *input,Word16 *output,Word16 dct_length)
/*===========================================================*/
/* set_span = 1 << (DCT_LENGTH_LOG - set_count_log); */
- set_span = shr(dct_length,set_count_log);
+ set_span = shr_nocheck(dct_length,set_count_log);
- set_count = shl(1,set_count_log);
+ set_count = shl_nocheck(1,set_count_log);
in_ptr = in_buffer;
move16();
next_out_base = out_buffer;
@@ -185,12 +185,18 @@ void dct_type_iv_s (Word16 *input,Word16 *output,Word16 dct_length)
/* IF THIS WORKS, IT'S PREFERABLE */
dummy = add(in_val_low,dither_ptr[i++]);
- acca = L_add(dummy,in_val_high);
- out_val_low = extract_l(L_shr(acca,1));
+ // blp: addition of two 16bits vars, there's no way
+ // they'll overflow a 32bit var
+ //acca = L_add(dummy,in_val_high);
+ acca = dummy + in_val_high;
+ out_val_low = extract_l(L_shr_nocheck(acca,1));
dummy = add(in_val_low,dither_ptr[i++]);
- acca = L_add(dummy,-in_val_high);
- out_val_high = extract_l(L_shr(acca,1));
+ // blp: addition of two 16bits vars, there's no way
+ // they'll overflow a 32bit var
+ //acca = L_add(dummy,-in_val_high);
+ acca = dummy - in_val_high;
+ out_val_high = extract_l(L_shr_nocheck(acca,1));
*out_ptr_low++ = out_val_low;
move16();
@@ -284,6 +290,17 @@ void dct_type_iv_s (Word16 *input,Word16 *output,Word16 dct_length)
{
for ( k=0; k<CORE_SIZE; k++ )
{
+#if PJ_HAS_INT64
+ /* blp: danger danger! not really compatible but faster */
+ pj_int64_t sum64=0;
+ move32();
+
+ for ( i=0; i<CORE_SIZE; i++ )
+ {
+ sum64 += L_mult(pair_ptr[i], dct_core_s[i][k]);
+ }
+ sum = L_saturate(sum64);
+#else
sum=0L;
move32();
@@ -291,6 +308,7 @@ void dct_type_iv_s (Word16 *input,Word16 *output,Word16 dct_length)
{
sum = L_mac(sum, pair_ptr[i],dct_core_s[i][k]);
}
+#endif
buffer_swap[k] = itu_round(sum);
}
@@ -323,9 +341,9 @@ void dct_type_iv_s (Word16 *input,Word16 *output,Word16 dct_length)
/*===========================================================*/
/* set_span = 1 << (DCT_LENGTH_LOG - set_count_log); */
- set_span = shr(dct_length,set_count_log);
+ set_span = shr_nocheck(dct_length,set_count_log);
- set_count = shl(1,set_count_log);
+ set_count = shl_nocheck(1,set_count_log);
next_in_base = in_buffer;
move16();
test();
@@ -354,7 +372,7 @@ void dct_type_iv_s (Word16 *input,Word16 *output,Word16 dct_length)
in_ptr_low = next_in_base;
move16();
- temp = shr(set_span,1);
+ temp = shr_nocheck(set_span,1);
in_ptr_high = in_ptr_low + temp;
move16();
@@ -401,25 +419,25 @@ void dct_type_iv_s (Word16 *input,Word16 *output,Word16 dct_length)
sum = L_mac(sum,cos_even,in_low_even);
sum = L_mac(sum,negate(msin_even),in_high_even);
- out_low_even = itu_round(L_shl(sum,1));
+ out_low_even = itu_round(L_shl_nocheck(sum,1));
sum = 0L;
move32();
sum = L_mac(sum,msin_even,in_low_even);
sum = L_mac(sum,cos_even,in_high_even);
- out_high_even = itu_round(L_shl(sum,1));
+ out_high_even = itu_round(L_shl_nocheck(sum,1));
sum = 0L;
move32();
sum = L_mac(sum,cos_odd,in_low_odd);
sum = L_mac(sum,msin_odd,in_high_odd);
- out_low_odd = itu_round(L_shl(sum,1));
+ out_low_odd = itu_round(L_shl_nocheck(sum,1));
sum = 0L;
move32();
sum = L_mac(sum,msin_odd,in_low_odd);
sum = L_mac(sum,negate(cos_odd),in_high_odd);
- out_high_odd = itu_round(L_shl(sum,1));
+ out_high_odd = itu_round(L_shl_nocheck(sum,1));
*out_ptr_low++ = out_low_even;
move16();
@@ -458,7 +476,10 @@ void dct_type_iv_s (Word16 *input,Word16 *output,Word16 dct_length)
{
for(i=0;i<320;i++)
{
- sum = L_add(output[i],syn_bias_7khz[i]);
+ // blp: addition of two 16bits vars, there's no way
+ // they'll overflow a 32bit var
+ //sum = L_add(output[i],syn_bias_7khz[i]);
+ sum = output[i] + syn_bias_7khz[i];
acca = L_sub(sum,32767);
test();
if (acca > 0)
@@ -466,7 +487,10 @@ void dct_type_iv_s (Word16 *input,Word16 *output,Word16 dct_length)
sum = 32767L;
move32();
}
- acca = L_add(sum,32768L);
+ // blp: addition of two 16bits vars, there's no way
+ // they'll overflow 32bit var
+ //acca = L_add(sum,32768L);
+ acca = sum + 32768;
test();
if (acca < 0)
{
diff --git a/third_party/g7221/decode/decoder.c b/third_party/g7221/decode/decoder.c
index c6b8c065..d642a910 100644
--- a/third_party/g7221/decode/decoder.c
+++ b/third_party/g7221/decode/decoder.c
@@ -136,7 +136,7 @@ void decoder(Bit_Obj *bitobj,
for (i=0; i<num_categorization_control_bits; i++)
{
get_next_bit(bitobj);
- categorization_control = shl(categorization_control,1);
+ categorization_control = shl_nocheck(categorization_control,1);
categorization_control = add(categorization_control,bitobj->next_bit);
}
@@ -246,7 +246,7 @@ void decode_envelope(Bit_Obj *bitobj,
for (i=0; i<5; i++)
{
get_next_bit(bitobj);
- index = shl(index,1);
+ index = shl_nocheck(index,1);
index = add(index,bitobj->next_bit);
}
bitobj->number_of_bits_left = sub(bitobj->number_of_bits_left,5);
@@ -332,7 +332,7 @@ void decode_envelope(Bit_Obj *bitobj,
while ((i >= 0) && ((temp1 >= 0) || (temp2 > 0)))
{
i = sub(i,1);
- temp = shr(temp,1);
+ temp = shr_nocheck(temp,1);
max_index = sub(max_index,2);
temp1 = sub(temp,8);
temp2 = sub(max_index,28);
@@ -530,13 +530,13 @@ void decode_vector_quantized_mlt_indices(Bit_Obj *bitobj,
test();
if (bitobj->next_bit == 0)
{
- temp = shl(index,1);
+ temp = shl_nocheck(index,1);
index = (Word16)*(decoder_table_ptr + temp);
move16();
}
else
{
- temp = shl(index,1);
+ temp = shl_nocheck(index,1);
index = (Word16)*(decoder_table_ptr + temp + 1);
move16();
}
@@ -567,18 +567,18 @@ void decode_vector_quantized_mlt_indices(Bit_Obj *bitobj,
for (j=0; j<num_sign_bits; j++)
{
get_next_bit(bitobj);
- signs_index = shl(signs_index,1);
+ signs_index = shl_nocheck(signs_index,1);
signs_index = add(signs_index,bitobj->next_bit);
bitobj->number_of_bits_left = sub(bitobj->number_of_bits_left,1);
}
temp = sub(num_sign_bits,1);
- bit = shl(1,(temp));
+ bit = shl_nocheck(1,(temp));
}
for (j=0; j<vec_dim; j++)
{
acca = L_mult0(standard_deviation,mlt_quant_centroid[category][k[j]]);
- acca = L_shr(acca,12);
+ acca = L_shr_nocheck(acca,12);
decoder_mlt_value = extract_l(acca);
test();
@@ -587,7 +587,7 @@ void decode_vector_quantized_mlt_indices(Bit_Obj *bitobj,
test();
if ((signs_index & bit) == 0)
decoder_mlt_value = negate(decoder_mlt_value);
- bit = shr(bit,1);
+ bit = shr_nocheck(bit,1);
}
*decoder_mlt_ptr++ = decoder_mlt_value;
move16();
@@ -652,7 +652,7 @@ void decode_vector_quantized_mlt_indices(Bit_Obj *bitobj,
}
*decoder_mlt_ptr = temp1;
move16();
- random_word = shr(random_word,1);
+ random_word = shr_nocheck(random_word,1);
}
/* pointer arithmetic */
decoder_mlt_ptr++;
@@ -677,7 +677,7 @@ void decode_vector_quantized_mlt_indices(Bit_Obj *bitobj,
}
*decoder_mlt_ptr = temp1;
move16();
- random_word = shr(random_word,1);
+ random_word = shr_nocheck(random_word,1);
}
/* pointer arithmetic */
decoder_mlt_ptr++;
@@ -710,7 +710,7 @@ void decode_vector_quantized_mlt_indices(Bit_Obj *bitobj,
}
*decoder_mlt_ptr++ = temp1;
move16();
- random_word = shr(random_word,1);
+ random_word = shr_nocheck(random_word,1);
}
random_word = get_rand(randobj);
for (j=0; j<10; j++)
@@ -730,7 +730,7 @@ void decode_vector_quantized_mlt_indices(Bit_Obj *bitobj,
*decoder_mlt_ptr++ = temp1;
move16();
- random_word = shr(random_word,1);
+ random_word = shr_nocheck(random_word,1);
}
}
}
@@ -1059,7 +1059,7 @@ void get_next_bit(Bit_Obj *bitobj)
move16();
}
bitobj->code_bit_count = sub(bitobj->code_bit_count,1);
- temp = shr(bitobj->current_word,bitobj->code_bit_count);
+ temp = shr_nocheck(bitobj->current_word,bitobj->code_bit_count);
logic16();
bitobj->next_bit = (Word16 )(temp & 1);
diff --git a/third_party/g7221/encode/dct4_a.c b/third_party/g7221/encode/dct4_a.c
index 4d7c7650..94ddf9fe 100644
--- a/third_party/g7221/encode/dct4_a.c
+++ b/third_party/g7221/encode/dct4_a.c
@@ -135,9 +135,9 @@ void dct_type_iv_a (Word16 *input,Word16 *output,Word16 dct_length)
/*===========================================================*/
/* set_span = 1 << (DCT_LENGTH_LOG - set_count_log); */
- set_span = shr(dct_length,set_count_log);
+ set_span = shr_nocheck(dct_length,set_count_log);
- set_count = shl(1,set_count_log);
+ set_count = shl_nocheck(1,set_count_log);
in_ptr = in_buffer;
move16();
@@ -168,12 +168,15 @@ void dct_type_iv_a (Word16 *input,Word16 *output,Word16 dct_length)
{
in_val_low = *in_ptr++;
in_val_high = *in_ptr++;
- acca = L_add(in_val_low,in_val_high);
- acca = L_shr(acca,1);
+ // blp: addition of two 16bits vars, there's no way
+ // they'll overflow a 32bit var
+ //acca = L_add(in_val_low,in_val_high);
+ acca = (in_val_low + in_val_high);
+ acca = L_shr_nocheck(acca,1);
out_val_low = extract_l(acca);
acca = L_sub(in_val_low,in_val_high);
- acca = L_shr(acca,1);
+ acca = L_shr_nocheck(acca,1);
out_val_high = extract_l(acca);
*out_ptr_low++ = out_val_low;
@@ -213,18 +216,30 @@ void dct_type_iv_a (Word16 *input,Word16 *output,Word16 dct_length)
move16();
temp = sub(dct_length_log,1);
- temp = shl(1,temp);
+ temp = shl_nocheck(1,temp);
for (pairs_left=temp; pairs_left > 0; pairs_left--)
{
for ( k=0; k<CORE_SIZE; k++ )
{
+#if PJ_HAS_INT64
+ /* blp: danger danger! not really compatible but faster */
+ pj_int64_t sum64=0;
+ move32();
+
+ for ( i=0; i<CORE_SIZE; i++ )
+ {
+ sum64 += L_mult(pair_ptr[i], dct_core_a[i][k]);
+ }
+ sum = L_saturate(sum64);
+#else
sum=0L;
move32();
for ( i=0; i<CORE_SIZE; i++ )
{
sum = L_mac(sum, pair_ptr[i],dct_core_a[i][k]);
}
+#endif
buffer_swap[k] = itu_round(sum);
}
/* address arithmetic */
@@ -250,9 +265,9 @@ void dct_type_iv_a (Word16 *input,Word16 *output,Word16 dct_length)
/* Initialization for the loop over sets at the current size */
/*===========================================================*/
/* set_span = 1 << (DCT_LENGTH_LOG - set_count_log); */
- set_span = shr(dct_length,set_count_log);
+ set_span = shr_nocheck(dct_length,set_count_log);
- set_count = shl(1,set_count_log);
+ set_count = shl_nocheck(1,set_count_log);
next_in_base = in_buffer;
move16();
@@ -277,7 +292,7 @@ void dct_type_iv_a (Word16 *input,Word16 *output,Word16 dct_length)
/*|||||||||||||||||||||||||||||||||||||||||*/
in_ptr_low = next_in_base;
move16();
- temp = shr(set_span,1);
+ temp = shr_nocheck(set_span,1);
/* address arithmetic */
in_ptr_high = in_ptr_low + temp;
diff --git a/third_party/g7221/encode/encoder.c b/third_party/g7221/encode/encoder.c
index 0ec8cf85..82fad3e1 100644
--- a/third_party/g7221/encode/encoder.c
+++ b/third_party/g7221/encode/encoder.c
@@ -140,7 +140,7 @@ void encoder(Word16 number_of_available_bits,
This assumes that REGION_POWER_STEPSIZE_DB is defined
to be exactly 3.010299957 or 20.0 times log base 10
of square root of 2. */
- temp = shl(mag_shift,1);
+ temp = shl_nocheck(mag_shift,1);
mag_shift_offset = add(temp,REGION_POWER_TABLE_NUM_NEGATIVES);
for (region=0; region<number_of_regions; region++)
@@ -258,7 +258,7 @@ void bits_to_words(UWord32 *region_mlt_bits,
test();
if (j >= 0)
{
- temp = extract_l(L_shr(current_word,j));
+ temp = extract_l(L_shr_nocheck(current_word,j));
out_word = add(out_word,temp);
out_words[out_word_index++] = out_word;
@@ -290,12 +290,12 @@ void bits_to_words(UWord32 *region_mlt_bits,
for (region=0;region<number_of_regions; region++)
{
accb = L_deposit_l(out_word_index);
- accb = L_shl(accb,4);
+ accb = L_shl_nocheck(accb,4);
accb = L_sub(accb,number_of_bits_per_frame);
test();
if(accb < 0)
{
- temp = shl(region,2);
+ temp = shl_nocheck(region,2);
in_word_ptr = &region_mlt_bits[temp];
region_bit_count = region_mlt_bit_counts[region];
move16();
@@ -310,7 +310,7 @@ void bits_to_words(UWord32 *region_mlt_bits,
current_word = *in_word_ptr++;
acca = L_deposit_l(out_word_index);
- acca = L_shl(acca,4);
+ acca = L_shl_nocheck(acca,4);
acca = L_sub(acca,number_of_bits_per_frame);
/* from while loop */
@@ -381,11 +381,11 @@ void bits_to_words(UWord32 *region_mlt_bits,
}
acca = L_deposit_l(out_word_index);
- acca = L_shl(acca,4);
+ acca = L_shl_nocheck(acca,4);
acca = L_sub(acca,number_of_bits_per_frame);
}
accb = L_deposit_l(out_word_index);
- accb = L_shl(accb,4);
+ accb = L_shl_nocheck(accb,4);
accb = L_sub(accb,number_of_bits_per_frame);
}
}
@@ -414,7 +414,7 @@ void bits_to_words(UWord32 *region_mlt_bits,
move16();
acca = L_deposit_l(out_word_index);
- acca = L_shl(acca,4);
+ acca = L_shl_nocheck(acca,4);
acca = L_sub(acca,number_of_bits_per_frame);
}
}
@@ -461,7 +461,7 @@ void adjust_abs_region_power_index(Word16 *absolute_region_power_index,Word16 *m
for (region=0; region<number_of_regions; region++)
{
n = sub(absolute_region_power_index[region],39);
- n = shr(n,1);
+ n = shr_nocheck(n,1);
test();
if (n > 0)
@@ -472,14 +472,14 @@ void adjust_abs_region_power_index(Word16 *absolute_region_power_index,Word16 *m
for (i=0; i<REGION_SIZE; i++)
{
- acca = L_shl(*raw_mlt_ptr,16);
+ acca = L_shl_nocheck(*raw_mlt_ptr,16);
acca = L_add(acca,32768L);
- acca = L_shr(acca,n);
- acca = L_shr(acca,16);
+ acca = L_shr_nocheck(acca,n);
+ acca = L_shr_nocheck(acca,16);
*raw_mlt_ptr++ = extract_l(acca);
}
- temp = shl(n,1);
+ temp = shl_nocheck(n,1);
temp = sub(absolute_region_power_index[region],temp);
absolute_region_power_index[region] = temp;
move16();
@@ -567,7 +567,7 @@ Word16 compute_region_powers(Word16 *mlt_coefs,
while (acca > 0)
{
test();
- long_accumulator = L_shr(long_accumulator,1);
+ long_accumulator = L_shr_nocheck(long_accumulator,1);
acca = (long_accumulator & 0x7fff0000L);
logic32();
@@ -587,12 +587,12 @@ Word16 compute_region_powers(Word16 *mlt_coefs,
test();
logic16();
- long_accumulator = L_shl(long_accumulator,1);
+ long_accumulator = L_shl_nocheck(long_accumulator,1);
acca = L_sub(long_accumulator,32767);
power_shift--;
temp = add(power_shift,15);
}
- long_accumulator = L_shr(long_accumulator,1);
+ long_accumulator = L_shr_nocheck(long_accumulator,1);
/* 28963 corresponds to square root of 2 times REGION_SIZE(20). */
acca = L_sub(long_accumulator,28963);
@@ -601,7 +601,7 @@ Word16 compute_region_powers(Word16 *mlt_coefs,
power_shift = add(power_shift,1);
acca = L_deposit_l(mag_shift);
- acca = L_shl(acca,1);
+ acca = L_shl_nocheck(acca,1);
acca = L_sub(power_shift,acca);
acca = L_add(35,acca);
acca = L_sub(acca,REGION_POWER_TABLE_NUM_NEGATIVES);
@@ -785,7 +785,7 @@ void vector_quantize_mlts(Word16 number_of_available_bits,
Word16 temp2;
/* Start in the middle of the categorization control range. */
- temp = shr(num_categorization_control_possibilities,1);
+ temp = shr_nocheck(num_categorization_control_possibilities,1);
temp = sub(temp,1);
for (*p_categorization_control = 0; *p_categorization_control < temp; (*p_categorization_control)++)
{
@@ -808,7 +808,7 @@ void vector_quantize_mlts(Word16 number_of_available_bits,
{
region_mlt_bit_counts[region] =
vector_huffman(category, absolute_region_power_index[region],raw_mlt_ptr,
- &region_mlt_bits[shl(region,2)]);
+ &region_mlt_bits[shl_nocheck(region,2)]);
}
else
{
@@ -849,7 +849,7 @@ void vector_quantize_mlts(Word16 number_of_available_bits,
{
region_mlt_bit_counts[region] =
vector_huffman(category, absolute_region_power_index[region],raw_mlt_ptr,
- &region_mlt_bits[shl(region,2)]);
+ &region_mlt_bits[shl_nocheck(region,2)]);
}
else
{
@@ -895,7 +895,7 @@ void vector_quantize_mlts(Word16 number_of_available_bits,
{
region_mlt_bit_counts[region] =
vector_huffman(category, absolute_region_power_index[region],raw_mlt_ptr,
- &region_mlt_bits[shl(region,2)]);
+ &region_mlt_bits[shl_nocheck(region,2)]);
}
else
{
@@ -1002,16 +1002,16 @@ Word16 vector_huffman(Word16 category,
/* compute inverse of step size * standard deviation */
acca = L_mult(step_size_inverse_table[category],standard_deviation_inverse_table[power_index]);
- acca = L_shr(acca,1);
+ acca = L_shr_nocheck(acca,1);
acca = L_add(acca,4096);
- acca = L_shr(acca,13);
+ acca = L_shr_nocheck(acca,13);
/*
* The next two lines are new to Release 1.2
*/
mytemp = acca & 0x3;
- acca = L_shr(acca,2);
+ acca = L_shr_nocheck(acca,2);
inv_of_step_size_times_std_dev = extract_l(acca);
@@ -1032,16 +1032,16 @@ Word16 vector_huffman(Word16 category,
k = abs_s(*raw_mlt_ptr);
acca = L_mult(k,inv_of_step_size_times_std_dev);
- acca = L_shr(acca,1);
+ acca = L_shr_nocheck(acca,1);
/*
* The next four lines are new to Release 1.2
*/
myacca = (Word16)L_mult(k,mytemp);
- myacca = (Word16)L_shr(myacca,1);
+ myacca = (Word16)L_shr_nocheck(myacca,1);
myacca = (Word16)L_add(myacca,int_dead_zone_low_bits[category]);
- myacca = (Word16)L_shr(myacca,2);
+ myacca = (Word16)L_shr_nocheck(myacca,2);
acca = L_add(acca,int_dead_zone[category]);
@@ -1050,7 +1050,7 @@ Word16 vector_huffman(Word16 category,
*/
acca = L_add(acca,myacca);
- acca = L_shr(acca,13);
+ acca = L_shr_nocheck(acca,13);
k = extract_l(acca);
@@ -1058,7 +1058,7 @@ Word16 vector_huffman(Word16 category,
if (k != 0)
{
number_of_non_zero = add(number_of_non_zero,1);
- signs_index = shl(signs_index,1);
+ signs_index = shl_nocheck(signs_index,1);
test();
if (*raw_mlt_ptr > 0)
@@ -1074,7 +1074,7 @@ Word16 vector_huffman(Word16 category,
move16();
}
}
- acca = L_shr(L_mult(index,(kmax_plus_one)),1);
+ acca = L_shr_nocheck(L_mult(index,(kmax_plus_one)),1);
index = extract_l(acca);
index = add(index,k);
raw_mlt_ptr++;
@@ -1104,7 +1104,7 @@ Word16 vector_huffman(Word16 category,
else
{
j = negate(j);
- acca = L_shr(code_bits,j);
+ acca = L_shr_nocheck(code_bits,j);
current_word = L_add(current_word,acca);
*word_ptr++ = current_word;
diff --git a/third_party/g7221/encode/sam2coef.c b/third_party/g7221/encode/sam2coef.c
index 57c8fce8..fc369e0c 100644
--- a/third_party/g7221/encode/sam2coef.c
+++ b/third_party/g7221/encode/sam2coef.c
@@ -84,7 +84,7 @@ Word16 samples_to_rmlt_coefs(Word16 *new_samples,Word16 *old_samples,Word16 *coe
Word16 temp2;
Word16 temp5;
- half_dct_size = shr(dct_length,1);
+ half_dct_size = shr_nocheck(dct_length,1);
/*++++++++++++++++++++++++++++++++++++++++++++*/
/* Get the first half of the windowed samples */
@@ -208,7 +208,7 @@ Word16 samples_to_rmlt_coefs(Word16 *new_samples,Word16 *old_samples,Word16 *coe
move16();
}
accb = L_mult(temp,9587);
- acca = L_shr(accb,20);
+ acca = L_shr_nocheck(accb,20);
temp5 = extract_l(acca);
temp = norm_s(temp5);
test();
@@ -230,7 +230,7 @@ Word16 samples_to_rmlt_coefs(Word16 *new_samples,Word16 *old_samples,Word16 *coe
acca = L_add(acca,temp);
}
- acca = L_shr(acca,7);
+ acca = L_shr_nocheck(acca,7);
test();
if (temp1 < acca)
@@ -243,7 +243,7 @@ Word16 samples_to_rmlt_coefs(Word16 *new_samples,Word16 *old_samples,Word16 *coe
{
for(index=0;index<dct_length;index++)
{
- windowed_data[index] = shl(windowed_data[index],mag_shift);
+ windowed_data[index] = shl_nocheck(windowed_data[index],mag_shift);
}
}
else
@@ -254,7 +254,7 @@ Word16 samples_to_rmlt_coefs(Word16 *new_samples,Word16 *old_samples,Word16 *coe
n = negate(mag_shift);
for(index=0;index<dct_length;index++)
{
- windowed_data[index] = shr(windowed_data[index],n);
+ windowed_data[index] = shr_nocheck(windowed_data[index],n);
move16();
}
}