initial commit

This commit is contained in:
Dan Bastone committed 2021-10-29 14:41:03 -04:00
commit 636959b37b
2474 files changed
+1343178

No files matched your search

File diff suppressed because it is too large. Load diff
+117
View File
@@ -0,0 +1,117 @@
#ifndef __BASIC_OP_H__
#define __BASIC_OP_H__
#include "config.h"
/*___________________________________________________________________________
| |
| Constants and Globals |
|___________________________________________________________________________|
*/
#define MAX_32 (Word32)0x7fffffffL
#define MIN_32 (Word32)0x80000000L
#define MAX_16 (Word16)0x7fff
#define MIN_16 (Word16)(pj_uint16_t)0x8000
#define UMAX_32 (UWord32)0xffffffffL
#define UMIN_32 (UWord32)0x00000000L
/*___________________________________________________________________________
| |
| Prototypes for basic arithmetic operators |
|___________________________________________________________________________|
*/
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 */
LIBG7221_DECL(Word16) shl (Word16 var1, Word16 var2); /* Short shift left, 1 */
PJ_INLINE(Word16) shl_nocheck(Word16 var1, Word16 var2);
LIBG7221_DECL(Word16) shr (Word16 var1, Word16 var2); /* Short shift right, 1 */
PJ_INLINE(Word16) shr_nocheck(Word16 var1, Word16 var2);
LIBG7221_DECL(Word16) mult (Word16 var1, Word16 var2); /* Short mult, 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 */
LIBG7221_DECL(Word32) L_msu (Word32 L_var3, Word16 var1, Word16 var2); /* Msu, 1 */
LIBG7221_DECL(Word32) L_macNs (Word32 L_var3, Word16 var1, Word16 var2); /* Mac without
sat, 1 */
LIBG7221_DECL(Word32) L_msuNs (Word32 L_var3, Word16 var1, Word16 var2); /* Msu without
sat, 1 */
//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 */
LIBG7221_DECL(Word32) L_add_c (Word32 L_var1, Word32 L_var2); /* Long add with c, 2 */
LIBG7221_DECL(Word32) L_sub_c (Word32 L_var1, Word32 L_var2); /* Long sub with c, 2 */
LIBG7221_DECL(Word32) L_negate (Word32 L_var1); /* Long negate, 2 */
LIBG7221_DECL(Word16) mult_r (Word16 var1, Word16 var2); /* Mult with round, 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*/
LIBG7221_DECL(Word16) shr_r (Word16 var1, Word16 var2); /* Shift right with
round, 2 */
LIBG7221_DECL(Word16) mac_r (Word32 L_var3, Word16 var1, Word16 var2); /* Mac with
rounding,2 */
LIBG7221_DECL(Word16) msu_r (Word32 L_var3, Word16 var1, Word16 var2); /* Msu with
rounding,2 */
LIBG7221_DECL(Word32) L_deposit_h (Word16 var1); /* 16 bit var1 -> MSB, 2 */
LIBG7221_DECL(Word32) L_deposit_l (Word16 var1); /* 16 bit var1 -> LSB, 2 */
LIBG7221_DECL(Word32) L_shr_r (Word32 L_var1, Word16 var2); /* Long shift right with
round, 3 */
LIBG7221_DECL(Word32) L_abs (Word32 L_var1); /* Long abs, 3 */
LIBG7221_DECL(Word32) L_sat (Word32 L_var1); /* Long saturation, 4 */
LIBG7221_DECL(Word16) norm_s (Word16 var1); /* Short norm, 15 */
LIBG7221_DECL(Word16) div_s (Word16 var1, Word16 var2); /* Short division, 18 */
LIBG7221_DECL(Word16) norm_l (Word32 L_var1); /* Long norm, 30 */
/*
Additional G.723.1 operators
*/
LIBG7221_DECL(Word32) L_mls( Word32, Word16 ) ; /* Weight FFS; currently assigned 1 */
LIBG7221_DECL(Word16) div_l( Word32, Word16 ) ; /* Weight FFS; currently assigned 1 */
LIBG7221_DECL(Word16) i_mult(Word16 a, Word16 b); /* Weight FFS; currently assigned 1 */
/*
New shiftless operators, not used in G.729/G.723.1
*/
LIBG7221_DECL(Word32) L_mult0(Word16 v1, Word16 v2); /* 32-bit Multiply w/o shift 1 */
LIBG7221_DECL(Word32) L_mac0(Word32 L_v3, Word16 v1, Word16 v2); /* 32-bit Mac w/o shift 1 */
LIBG7221_DECL(Word32) L_msu0(Word32 L_v3, Word16 v1, Word16 v2); /* 32-bit Msu w/o shift 1 */
/*
Additional G.722.1 operators
*/
LIBG7221_DECL(UWord32) LU_shl (UWord32 L_var1, Word16 var2);
LIBG7221_DECL(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 "basic_op_i.h"
#if PJMEDIA_LIBG7221_FUNCS_INLINED
# include "basic_op.c"
#endif
#endif /* __BASIC_OP_H__ */
+730
View File
@@ -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 (L_var1 > 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 == MIN_16)
return MAX_16;
else
return (Word16)-var1;
#else
if (var1 == MIN_16)
{
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
}
+461
View File
@@ -0,0 +1,461 @@
/****************************************************************************************
**
** ITU-T G.722.1 (2005-05) - Fixed point implementation for main body and Annex C
** > Software Release 2.1 (2008-06)
** (Simple repackaging; no change from 2005-05 Release 2.0 code)
**
** © 2004 Polycom, Inc.
**
** All rights reserved.
**
****************************************************************************************/
/****************************************************************************************
Filename: common.c
Purpose: Contains the functions used for both G.722.1 Annex C encoder and decoder
Design Notes:
****************************************************************************************/
/****************************************************************************************
Include files
****************************************************************************************/
#include "defs.h"
#include "huff_def.h"
#include "huff_tab.h"
#include "tables.h"
#include "count.h"
/****************************************************************************************
Function: categorize
Syntax: void categorize(Word16 number_of_available_bits,
Word16 number_of_regions,
Word16 num_categorization_control_possibilities,
Word16 rms_index,
Word16 power_categories,
Word16 category_balances)
inputs: number_of_regions
num_categorization_control_possibilities
number_of_available_bits
rms_index[MAX_NUMBER_OF_REGIONS]
outputs: power_categories[MAX_NUMBER_OF_REGIONS]
category_balances[MAX_NUM_CATEGORIZATION_CONTROL_POSSIBILITIES-1]
Description: Computes a series of categorizations
WMOPS: 7kHz | 24kbit | 32kbit
-------|--------------|----------------
AVG | 0.14 | 0.14
-------|--------------|----------------
MAX | 0.15 | 0.15
-------|--------------|----------------
14kHz | 24kbit | 32kbit | 48kbit
-------|--------------|----------------|----------------
AVG | 0.42 | 0.45 | 0.48
-------|--------------|----------------|----------------
MAX | 0.47 | 0.52 | 0.52
-------|--------------|----------------|----------------
****************************************************************************************/
void categorize(Word16 number_of_available_bits,
Word16 number_of_regions,
Word16 num_categorization_control_possibilities,
Word16 *rms_index,
Word16 *power_categories,
Word16 *category_balances)
{
Word16 offset;
Word16 temp;
Word16 frame_size;
/* At higher bit rates, there is an increase for most categories in average bit
consumption per region. We compensate for this by pretending we have fewer
available bits. */
test();
if (number_of_regions == NUMBER_OF_REGIONS)
{
frame_size = DCT_LENGTH;
}
else
{
frame_size = MAX_DCT_LENGTH;
}
temp = sub(number_of_available_bits,frame_size);
test();
if (temp > 0)
{
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_nocheck(number_of_available_bits,3);
number_of_available_bits = add(number_of_available_bits,frame_size);
}
/* calculate the offset using the original category assignments */
offset = calc_offset(rms_index,number_of_regions,number_of_available_bits);
/* compute the power categories based on the uniform offset */
compute_raw_pow_categories(power_categories,rms_index,number_of_regions,offset);
/* adjust the category assignments */
/* compute the new power categories and category balances */
comp_powercat_and_catbalance(power_categories,category_balances,rms_index,number_of_available_bits,number_of_regions,num_categorization_control_possibilities,offset);
}
/***************************************************************************
Function: comp_powercat_and_catbalance
Syntax: void comp_powercat_and_catbalance(Word16 *power_categories,
Word16 *category_balances,
Word16 *rms_index,
Word16 number_of_available_bits,
Word16 number_of_regions,
Word16 num_categorization_control_possibilities,
Word16 offset)
inputs: *rms_index
number_of_available_bits
number_of_regions
num_categorization_control_possibilities
offset
outputs: *power_categories
*category_balances
Description: Computes the power_categories and the category balances
WMOPS: 7kHz | 24kbit | 32kbit
-------|--------------|----------------
AVG | 0.10 | 0.10
-------|--------------|----------------
MAX | 0.11 | 0.11
-------|--------------|----------------
14kHz | 24kbit | 32kbit | 48kbit
-------|--------------|----------------|----------------
AVG | 0.32 | 0.35 | 0.38
-------|--------------|----------------|----------------
MAX | 0.38 | 0.42 | 0.43
-------|--------------|----------------|----------------
***************************************************************************/
void comp_powercat_and_catbalance(Word16 *power_categories,
Word16 *category_balances,
Word16 *rms_index,
Word16 number_of_available_bits,
Word16 number_of_regions,
Word16 num_categorization_control_possibilities,
Word16 offset)
{
Word16 expected_number_of_code_bits;
Word16 region;
Word16 max_region;
Word16 j;
Word16 max_rate_categories[MAX_NUMBER_OF_REGIONS];
Word16 min_rate_categories[MAX_NUMBER_OF_REGIONS];
Word16 temp_category_balances[2*MAX_NUM_CATEGORIZATION_CONTROL_POSSIBILITIES];
Word16 raw_max, raw_min;
Word16 raw_max_index=0, raw_min_index=0;
Word16 max_rate_pointer, min_rate_pointer;
Word16 max, min;
Word16 itemp0;
Word16 itemp1;
Word16 min_plus_max;
Word16 two_x_number_of_available_bits;
Word16 temp;
expected_number_of_code_bits = 0;
move16();
for (region=0; region<number_of_regions; region++)
expected_number_of_code_bits = add(expected_number_of_code_bits,expected_bits_table[power_categories[region]]);
for (region=0; region<number_of_regions; region++)
{
max_rate_categories[region] = power_categories[region];
move16();
min_rate_categories[region] = power_categories[region];
move16();
}
max = expected_number_of_code_bits;
move16();
min = expected_number_of_code_bits;
move16();
max_rate_pointer = num_categorization_control_possibilities;
move16();
min_rate_pointer = num_categorization_control_possibilities;
move16();
for (j=0; j<num_categorization_control_possibilities-1; j++)
{
min_plus_max = add(max,min);
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();
if (temp <= 0)
{
raw_min = 99;
move16();
/* Search from lowest freq regions to highest for best */
/* region to reassign to a higher bit rate category. */
for (region=0; region<number_of_regions; region++)
{
test();
if (max_rate_categories[region] > 0)
{
itemp0 = shl_nocheck(max_rate_categories[region],1);
itemp1 = sub(offset,rms_index[region]);
itemp0 = sub(itemp1,itemp0);
temp = sub(itemp0,raw_min);
test();
if (temp < 0)
{
raw_min = itemp0;
raw_min_index = region;
}
}
}
max_rate_pointer = sub(max_rate_pointer,1);
temp_category_balances[max_rate_pointer] = raw_min_index;
move16();
max = sub(max,expected_bits_table[max_rate_categories[raw_min_index]]);
max_rate_categories[raw_min_index] = sub(max_rate_categories[raw_min_index],1);
move16();
max = add(max,expected_bits_table[max_rate_categories[raw_min_index]]);
}
else
{
raw_max = -99;
move16();
/* Search from highest freq regions to lowest for best region to reassign to
a lower bit rate category. */
max_region = sub(number_of_regions,1);
for (region= max_region; region >= 0; region--)
{
temp = sub(min_rate_categories[region],(NUM_CATEGORIES-1));
test();
if (temp < 0)
{
itemp0 = shl_nocheck(min_rate_categories[region],1);
itemp1 = sub(offset,rms_index[region]);
itemp0 = sub(itemp1,itemp0);
temp = sub(itemp0,raw_max);
test();
if (temp > 0)
{
raw_max = itemp0;
move16();
raw_max_index = region;
move16();
}
}
}
temp_category_balances[min_rate_pointer] = raw_max_index;
move16();
min_rate_pointer = add(min_rate_pointer,1);
min = sub(min,expected_bits_table[min_rate_categories[raw_max_index]]);
min_rate_categories[raw_max_index] = add(min_rate_categories[raw_max_index],1);
move16();
min = add(min,expected_bits_table[min_rate_categories[raw_max_index]]);
}
}
for (region=0; region<number_of_regions; region++)
{
power_categories[region] = max_rate_categories[region];
move16();
}
for (j=0; j<num_categorization_control_possibilities-1; j++)
{
category_balances[j] = temp_category_balances[max_rate_pointer++];
move16();
}
}
/***************************************************************************
Function: calc_offset
Syntax: offset=calc_offset(Word16 *rms_index,Word16 number_of_regions,Word16 available_bits)
input: Word16 *rms_index
Word16 number_of_regions
Word16 available_bits
output: Word16 offset
Description: Calculates the the category offset. This is the shift required
To get the most out of the number of available bits. A binary
type search is used to find the offset.
WMOPS: 7kHz | 24kbit | 32kbit
-------|--------------|----------------
AVG | 0.04 | 0.04
-------|--------------|----------------
MAX | 0.04 | 0.04
-------|--------------|----------------
14kHz | 24kbit | 32kbit | 48kbit
-------|--------------|----------------|----------------
AVG | 0.08 | 0.08 | 0.08
-------|--------------|----------------|----------------
MAX | 0.09 | 0.09 | 0.09
-------|--------------|----------------|----------------
***************************************************************************/
Word16 calc_offset(Word16 *rms_index,Word16 number_of_regions,Word16 available_bits)
{
Word16 answer;
Word16 delta;
Word16 test_offset;
Word16 region,j;
Word16 power_cats[MAX_NUMBER_OF_REGIONS];
Word16 bits;
Word16 offset;
Word16 temp;
/* initialize vars */
answer = -32;
move16();
delta = 32;
move16();
do
{
test_offset = add(answer,delta);
/* obtain a category for each region */
/* using the test offset */
for (region=0; region<number_of_regions; region++)
{
j = sub(test_offset,rms_index[region]);
j = shr_nocheck(j,1);
/* Ensure j is between 0 and NUM_CAT-1 */
test();
if (j < 0)
{
j = 0;
move16();
}
temp = sub(j,NUM_CATEGORIES-1);
test();
if (temp > 0)
{
j = sub(NUM_CATEGORIES,1);
move16();
}
power_cats[region] = j;
move16();
}
bits = 0;
move16();
/* compute the number of bits that will be used given the cat assignments */
for (region=0; region<number_of_regions; region++)
bits = add(bits,expected_bits_table[power_cats[region]]);
/* if (bits > available_bits - 32) then divide the offset region for the bin search */
offset = sub(available_bits,32);
temp = sub(bits,offset);
test();
if (temp >= 0)
{
answer = test_offset;
move16();
}
delta = shr_nocheck(delta,1);
test(); /* for the while loop */
} while (delta > 0);
return(answer);
}
/***************************************************************************
Function: compute_raw_pow_categories
Syntax: void compute_raw_pow_categories(Word16 *power_categories,
Word16 *rms_index,
Word16 number_of_regions,
Word16 offset)
inputs: *rms_index
number_of_regions
offset
outputs: *power_categories
Description: This function computes the power categories given the offset
This is kind of redundant since they were already computed
in calc_offset to determine the offset.
WMOPS: | 24kbit | 32kbit
-------|--------------|----------------
AVG | 0.01 | 0.01
-------|--------------|----------------
MAX | 0.01 | 0.01
-------|--------------|----------------
14kHz | 24kbit | 32kbit | 48kbit
-------|--------------|----------------|----------------
AVG | 0.01 | 0.01 | 0.01
-------|--------------|----------------|----------------
MAX | 0.01 | 0.01 | 0.01
-------|--------------|----------------|----------------
***************************************************************************/
void compute_raw_pow_categories(Word16 *power_categories,Word16 *rms_index,Word16 number_of_regions,Word16 offset)
{
Word16 region;
Word16 j;
Word16 temp;
for (region=0; region<number_of_regions; region++)
{
j = sub(offset,rms_index[region]);
j = shr_nocheck(j,1);
/* make sure j is between 0 and NUM_CAT-1 */
test();
if (j < 0)
{
j = 0;
move16();
}
temp = sub(j,(NUM_CATEGORIES-1));
test();
if (temp > 0)
j = sub(NUM_CATEGORIES,1);
power_categories[region] = j;
move16();
}
}
+27
View File
@@ -0,0 +1,27 @@
#ifndef __LIBG7221_CONFIG_H__
#define __LIBG7221_CONFIG_H__
#include <pj/config.h>
/**
* Expand all basic operation functions as inline. Even if this is set to
* zero, some critical functions would still be expanded as inline. Note
* also that enabling this may generate some warning messages about functions
* not being referenced (with gcc).
*
* Default: 0 (no)
*/
#ifndef PJMEDIA_LIBG7221_FUNCS_INLINED
# define PJMEDIA_LIBG7221_FUNCS_INLINED 0
#endif
/* Declare/define a function that may be expanded as inline. */
#if PJMEDIA_LIBG7221_FUNCS_INLINED
# define LIBG7221_DECL(type) PJ_INLINE(type)
# define LIBG7221_DEF(type) PJ_INLINE(type)
#else
# define LIBG7221_DECL(type) PJ_DECL(type)
# define LIBG7221_DEF(type) PJ_DEF(type)
#endif
#endif /* __LIBG7221_CONFIG_H__ */
+28
View File
@@ -0,0 +1,28 @@
/* $Id$ */
/*
* Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef COUNT_H
#define COUNT_H
#define move16()
#define move32()
#define logic16()
#define logic32()
#define test()
#endif
+205
View File
@@ -0,0 +1,205 @@
/***********************************************************************
**
** ITU-T G.722.1 (2005-05) - Fixed point implementation for main body and Annex C
** > Software Release 2.1 (2008-06)
** (Simple repackaging; no change from 2005-05 Release 2.0 code)
**
** © 2004 Polycom, Inc.
**
** All rights reserved.
**
***********************************************************************/
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include "g7221/common/typedef.h"
#include "g7221/common/basic_op.h"
#define PI 3.141592653589793238462
#define MAX_DCT_LENGTH 640
#define DCT_LENGTH 320
#define DCT_LENGTH_DIV_2 160
#define DCT_LENGTH_DIV_4 80
#define DCT_LENGTH_DIV_8 40
#define DCT_LENGTH_DIV_16 20
#define DCT_LENGTH_DIV_32 10
#define DCT_LENGTH_DIV_64 5
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a < b ? a : b)
#define NUM_CATEGORIES 8
#define NUM_CATEGORIZATION_CONTROL_BITS 4
#define NUM_CATEGORIZATION_CONTROL_POSSIBILITIES 16
#define CORE_SIZE 10
#define DCT_LENGTH_LOG 6
#define MAX_DCT_LENGTH_LOG 7
/* region_size = (BLOCK_SIZE * 0.875)/NUM_REGIONS; */
#define NUMBER_OF_REGIONS 14
#define MAX_NUMBER_OF_REGIONS 28
#define REGION_SIZE 20
#define NUMBER_OF_VALID_COEFS (NUMBER_OF_REGIONS * REGION_SIZE)
#define MAX_NUMBER_OF_VALID_COEFS (MAX_NUMBER_OF_REGIONS * REGION_SIZE)
#define REGION_POWER_TABLE_SIZE 64
#define REGION_POWER_TABLE_NUM_NEGATIVES 24
#define MAX_NUM_CATEGORIZATION_CONTROL_BITS 5
#define MAX_NUM_CATEGORIZATION_CONTROL_POSSIBILITIES 32
#define ENCODER_SCALE_FACTOR 18318.0
/* The MLT output is incorrectly scaled by the factor
product of ENCODER_SCALE_FACTOR and sqrt(160.)
This is now (9/30/96) 1.0/2^(4.5) or 1/22.627.
In the current implementation this
must be an integer power of sqrt(2). The
integer power is ESF_ADJUSTMENT_TO_RMS_INDEX.
The -2 is to conform with the range defined in the spec. */
#define ESF_ADJUSTMENT_TO_RMS_INDEX (9-2)
#define INTERMEDIATE_FILES_FLAG 0
/* Max bit rate is 48000 bits/sec. */
#define MAX_BITS_PER_FRAME 960
/***************************************************************************/
/* Type definitions */
/***************************************************************************/
typedef struct
{
Word16 code_bit_count; /* bit count of the current word */
Word16 current_word; /* current word in the bitstream being processed */
Word16 *code_word_ptr; /* pointer to the bitstream */
Word16 number_of_bits_left; /* number of bits left in the current word */
Word16 next_bit; /* next bit in the current word */
}Bit_Obj;
typedef struct
{
Word16 seed0;
Word16 seed1;
Word16 seed2;
Word16 seed3;
}Rand_Obj;
/***************************************************************************/
/* Function definitions */
/***************************************************************************/
extern Word16 compute_region_powers(Word16 *mlt_coefs,
Word16 mag_shift,
Word16 *drp_num_bits,
UWord16 *drp_code_bits,
Word16 *absolute_region_power_index,
Word16 number_of_regions);
void vector_quantize_mlts(Word16 number_of_available_bits,
Word16 number_of_regions,
Word16 num_categorization_control_possibilities,
Word16 *mlt_coefs,
Word16 *absolute_region_power_index,
Word16 *power_categories,
Word16 *category_balances,
Word16 *p_categorization_control,
Word16 *region_mlt_bit_counts,
UWord32 *region_mlt_bits);
Word16 vector_huffman(Word16 category,
Word16 power_index,
Word16 *raw_mlt_ptr,
UWord32 *word_ptr);
void adjust_abs_region_power_index(Word16 *absolute_region_power_index,Word16 *mlt_coefs,Word16 number_of_regions);
void bits_to_words(UWord32 *region_mlt_bits,Word16 *region_mlt_bit_counts,
Word16 *drp_num_bits,UWord16 *drp_code_bits,Word16 *out_words,
Word16 categorization_control, Word16 number_of_regions,
Word16 num_categorization_control_bits, Word16 number_of_bits_per_frame);
void encoder(Word16 number_of_available_bits,
Word16 number_of_regions,
Word16 *mlt_coefs,
Word16 mag_shift,
Word16 *out_words);
void decoder(Bit_Obj *bitobj,
Rand_Obj *randobj,
Word16 number_of_regions,
Word16 *decoder_mlt_coefs,
Word16 *p_mag_shift,
Word16 *p_old_mag_shift,
Word16 *old_decoder_mlt_coefs,
Word16 frame_error_flag);
Word16 samples_to_rmlt_coefs(const Word16 *new_samples,Word16 *history,Word16 *coefs,Word16 dct_length);
void rmlt_coefs_to_samples(Word16 *coefs,
Word16 *old_samples,
Word16 *out_samples,
Word16 dct_length,
Word16 mag_shift);
Word16 index_to_array(Word16 index,Word16 *array,Word16 category);
void categorize(Word16 number_of_available_bits,
Word16 number_of_regions,
Word16 num_categorization_control_possibilities,
Word16 *rms_index,
Word16 *power_categories,
Word16 *category_balances);
Word16 calc_offset(Word16 *rms_index,Word16 number_of_regions,Word16 available_bits);
void compute_raw_pow_categories(Word16 *power_categories,Word16 *rms_index,Word16 number_of_regions,Word16 offset);
void comp_powercat_and_catbalance(Word16 *power_categories,
Word16 *category_balances,
Word16 *rms_index,
Word16 number_of_available_bits,
Word16 number_of_regions,
Word16 num_categorization_control_possibilities,
Word16 offset);
void dct_type_iv_a (Word16 *input,Word16 *output,Word16 dct_length);
void dct_type_iv_s(Word16 *input,Word16 *output,Word16 dct_length);
void decode_envelope(Bit_Obj *bitobj,
Word16 number_of_regions,
Word16 *decoder_region_standard_deviation,
Word16 *absolute_region_power_index,
Word16 *p_mag_shift);
void decode_vector_quantized_mlt_indices(Bit_Obj *bitobj,
Rand_Obj *randobj,
Word16 number_of_regions,
Word16 *decoder_region_standard_deviation,
Word16 *dedecoder_power_categories,
Word16 *dedecoder_mlt_coefs);
void rate_adjust_categories(Word16 categorization_control,
Word16 *decoder_power_categories,
Word16 *decoder_category_balances);
void get_next_bit(Bit_Obj *bitobj);
Word16 get_rand(Rand_Obj *randobj);
void test_4_frame_errors(Bit_Obj *bitobj,
Word16 number_of_regions,
Word16 num_categorization_control_possibilities,
Word16 *frame_error_flag,
Word16 categorization_control,
Word16 *absolute_region_power_index);
void error_handling(Word16 number_of_coefs,
Word16 number_of_valid_coefs,
Word16 *frame_error_flag,
Word16 *decoder_mlt_coefs,
Word16 *old_decoder_mlt_coefs,
Word16 *p_mag_shift,
Word16 *p_old_mag_shift);
+53
View File
@@ -0,0 +1,53 @@
/***********************************************************************
**
** ITU-T G.722.1 (2005-05) - Fixed point implementation for main body and Annex C
** > Software Release 2.1 (2008-06)
** (Simple repackaging; no change from 2005-05 Release 2.0 code)
**
** © 2004 Polycom, Inc.
**
** All rights reserved.
**
***********************************************************************/
#define REGION_POWER_STEPSIZE_DB 3.010299957
#define ABS_REGION_POWER_LEVELS 32
#define DIFF_REGION_POWER_LEVELS 24
#define DRP_DIFF_MIN -12
#define DRP_DIFF_MAX 11
#define MAX_NUM_BINS 16
#define MAX_VECTOR_INDICES 625
#define MAX_VECTOR_DIMENSION 5
extern Word16 differential_region_power_bits[MAX_NUMBER_OF_REGIONS][DIFF_REGION_POWER_LEVELS];
extern UWord16 differential_region_power_codes[MAX_NUMBER_OF_REGIONS][DIFF_REGION_POWER_LEVELS];
extern Word16 differential_region_power_decoder_tree[MAX_NUMBER_OF_REGIONS][DIFF_REGION_POWER_LEVELS-1][2];
extern Word16 mlt_quant_centroid[NUM_CATEGORIES][MAX_NUM_BINS];
extern Word16 expected_bits_table[NUM_CATEGORIES];
extern Word16 mlt_sqvh_bitcount_category_0[196];
extern UWord16 mlt_sqvh_code_category_0[196];
extern Word16 mlt_sqvh_bitcount_category_1[100];
extern UWord16 mlt_sqvh_code_category_1[100];
extern Word16 mlt_sqvh_bitcount_category_2[49];
extern UWord16 mlt_sqvh_code_category_2[49];
extern Word16 mlt_sqvh_bitcount_category_3[625];
extern UWord16 mlt_sqvh_code_category_3[625];
extern Word16 mlt_sqvh_bitcount_category_4[256];
extern UWord16 mlt_sqvh_code_category_4[256];
extern Word16 mlt_sqvh_bitcount_category_5[243];
extern UWord16 mlt_sqvh_code_category_5[243];
extern Word16 mlt_sqvh_bitcount_category_6[32];
extern UWord16 mlt_sqvh_code_category_6[32];
extern Word16 *table_of_bitcount_tables[NUM_CATEGORIES-1];
extern UWord16 *table_of_code_tables[NUM_CATEGORIES-1];
extern Word16 mlt_decoder_tree_category_0[180][2];
extern Word16 mlt_decoder_tree_category_1[93][2];
extern Word16 mlt_decoder_tree_category_2[47][2];
extern Word16 mlt_decoder_tree_category_3[519][2];
extern Word16 mlt_decoder_tree_category_4[208][2];
extern Word16 mlt_decoder_tree_category_5[191][2];
extern Word16 mlt_decoder_tree_category_6[31][2];
extern Word16 *table_of_decoder_tables[NUM_CATEGORIES-1];
+528
View File
@@ -0,0 +1,528 @@
/***********************************************************************
**
** ITU-T G.722.1 (2005-05) - Fixed point implementation for main body and Annex C
** > Software Release 2.1 (2008-06)
** (Simple repackaging; no change from 2005-05 Release 2.0 code)
**
** © 2004 Polycom, Inc.
**
** All rights reserved.
**
***********************************************************************/
#include "defs.h"
#include "huff_def.h"
Word16 differential_region_power_bits[MAX_NUMBER_OF_REGIONS][DIFF_REGION_POWER_LEVELS] = {
{99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99},
{ 4, 6, 5, 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 4, 5, 7, 8, 9,11,11,12,12,12,12},
{10, 8, 6, 5, 5, 4, 3, 3, 3, 3, 3, 3, 4, 5, 7, 9,11,12,13,15,15,15,16,16},
{12,10, 8, 6, 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 4, 4, 5, 5, 7, 9,11,13,14,14},
{13,10, 9, 9, 7, 7, 5, 5, 4, 3, 3, 3, 3, 3, 4, 4, 4, 5, 7, 9,11,13,13,13},
{12,13,10, 8, 6, 6, 5, 5, 4, 4, 3, 3, 3, 3, 3, 4, 5, 5, 6, 7, 9,11,14,14},
{12,11, 9, 8, 8, 7, 5, 4, 4, 3, 3, 3, 3, 3, 4, 4, 5, 5, 7, 8,10,13,14,14},
{15,16,15,12,10, 8, 6, 5, 4, 3, 3, 3, 2, 3, 4, 5, 5, 7, 9,11,13,16,16,16},
{14,14,11,10, 9, 7, 7, 5, 5, 4, 3, 3, 2, 3, 3, 4, 5, 7, 9, 9,12,14,15,15},
{ 9, 9, 9, 8, 7, 6, 5, 4, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8,10,11,12,13,13},
{14,12,10, 8, 6, 6, 5, 4, 3, 3, 3, 3, 3, 3, 4, 5, 6, 8, 8, 9,11,14,14,14},
{13,10, 9, 8, 6, 6, 5, 4, 4, 4, 3, 3, 2, 3, 4, 5, 6, 8, 9, 9,11,12,14,14},
{16,13,12,11, 9, 6, 5, 5, 4, 4, 4, 3, 2, 3, 3, 4, 5, 7, 8,10,14,16,16,16},
{13,14,14,14,10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9,11,14,14,14},
{13,14,14,14,10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9,11,14,14,14},
{13,14,14,14,10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9,11,14,14,14},
{13,14,14,14,10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9,11,14,14,14},
{13,14,14,14,10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9,11,14,14,14},
{13,14,14,14,10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9,11,14,14,14},
{13,14,14,14,10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9,11,14,14,14},
{13,14,14,14,10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9,11,14,14,14},
{13,14,14,14,10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9,11,14,14,14},
{13,14,14,14,10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9,11,14,14,14},
{13,14,14,14,10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9,11,14,14,14},
{13,14,14,14,10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9,11,14,14,14},
{13,14,14,14,10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9,11,14,14,14},
{13,14,14,14,10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9,11,14,14,14},
{13,14,14,14,10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9,11,14,14,14}};
UWord16 differential_region_power_codes[MAX_NUMBER_OF_REGIONS][DIFF_REGION_POWER_LEVELS] = {
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 8,38,18,10, 7, 6, 3, 2, 0, 1, 7, 6, 5, 4,11,78,158,318,1278,1279,2552,2553,2554,2555},
{36, 8, 3, 5, 0, 1, 7, 6, 4, 3, 2, 5, 3, 4, 5,19,74,150,302,1213,1214,1215,2424,2425},
{2582,644,160,41, 5,11, 7, 5, 4, 1, 0, 6, 4, 7, 3, 6, 4,21,81,323,1290,5167,10332,10333},
{2940,366,181,180,47,46,27,10, 8, 5, 1, 0, 3, 7, 4, 9,12,26,44,182,734,2941,2942,2943},
{3982,7967,994,249,63,26,19,18,14, 8, 6, 1, 0, 2, 5, 7,12,30,27,125,496,1990,15932,15933},
{3254,1626,407,206,202,100,30,14, 3, 5, 3, 0, 2, 4, 2,13,24,31,102,207,812,6511,13020,13021},
{1110,2216,1111,139,35, 9, 3,20,11, 4, 2, 1, 3, 3, 1, 0,21, 5,16,68,276,2217,2218,2219},
{1013,1014,127,62,29, 6, 4,16, 0, 1, 3, 2, 3, 1, 5, 9,17, 5,28,30,252,1015,2024,2025},
{381,380,372,191,94,44,16,10, 7, 3, 1, 0, 2, 6, 9,17,45,92,187,746,1494,2991,5980,5981},
{3036,758,188,45,43,10, 4, 3, 6, 4, 2, 0, 3, 7,11,20,42,44,46,95,378,3037,3038,3039},
{751,92,45,20,26, 4,12, 7, 4, 0, 4, 1, 3, 5, 5, 3,27,21,44,47,186,374,1500,1501},
{45572U,5697,2849,1425,357,45,23, 6,10, 7, 2, 2, 3, 0, 4, 6, 7,88,179,713,11392,45573U,45574U,45575U},
{2511,5016,5018,5017,312,79,38,36,30,14, 6, 0, 2, 1, 3, 5, 8,31,37,157,626,5019,5020,5021},
{2511,5016,5018,5017,312,79,38,36,30,14, 6, 0, 2, 1, 3, 5, 8,31,37,157,626,5019,5020,5021},
{2511,5016,5018,5017,312,79,38,36,30,14, 6, 0, 2, 1, 3, 5, 8,31,37,157,626,5019,5020,5021},
{2511,5016,5018,5017,312,79,38,36,30,14, 6, 0, 2, 1, 3, 5, 8,31,37,157,626,5019,5020,5021},
{2511,5016,5018,5017,312,79,38,36,30,14, 6, 0, 2, 1, 3, 5, 8,31,37,157,626,5019,5020,5021},
{2511,5016,5018,5017,312,79,38,36,30,14, 6, 0, 2, 1, 3, 5, 8,31,37,157,626,5019,5020,5021},
{2511,5016,5018,5017,312,79,38,36,30,14, 6, 0, 2, 1, 3, 5, 8,31,37,157,626,5019,5020,5021},
{2511,5016,5018,5017,312,79,38,36,30,14, 6, 0, 2, 1, 3, 5, 8,31,37,157,626,5019,5020,5021},
{2511,5016,5018,5017,312,79,38,36,30,14, 6, 0, 2, 1, 3, 5, 8,31,37,157,626,5019,5020,5021},
{2511,5016,5018,5017,312,79,38,36,30,14, 6, 0, 2, 1, 3, 5, 8,31,37,157,626,5019,5020,5021},
{2511,5016,5018,5017,312,79,38,36,30,14, 6, 0, 2, 1, 3, 5, 8,31,37,157,626,5019,5020,5021},
{2511,5016,5018,5017,312,79,38,36,30,14, 6, 0, 2, 1, 3, 5, 8,31,37,157,626,5019,5020,5021},
{2511,5016,5018,5017,312,79,38,36,30,14, 6, 0, 2, 1, 3, 5, 8,31,37,157,626,5019,5020,5021},
{2511,5016,5018,5017,312,79,38,36,30,14, 6, 0, 2, 1, 3, 5, 8,31,37,157,626,5019,5020,5021},
{2511,5016,5018,5017,312,79,38,36,30,14, 6, 0, 2, 1, 3, 5, 8,31,37,157,626,5019,5020,5021}};
Word16 differential_region_power_decoder_tree[MAX_NUMBER_OF_REGIONS][DIFF_REGION_POWER_LEVELS-1][2] = {
{{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0}},
{{ 1, 2},{ 3, 4},{ 5, 6},{ 7, 8},{ 9, 10},{ 11,-12},{-11,-10},{ -8, -9},{ -7, -6},{-13, 12},{ -5, -4},{ 0, 13},{ -3,-14},{ -2, 14},{ -1, 15},{-15, 16},{-16, 17},{-17, 18},{ 19, 20},{ 21, 22},{-18,-19},{-20,-21},{-22,-23}},
{{ 1, 2},{ 3, 4},{ 5, 6},{ 7, 8},{-10, -9},{ -8,-11},{ -7, -6},{ 9, -5},{ 10,-12},{ -4, 11},{-13, -3},{ 12, -2},{ 13,-14},{ -1, 14},{ 15,-15},{ 0, 16},{-16, 17},{-17, 18},{-18, 19},{ 20, 21},{ 22,-19},{-20,-21},{-22,-23}},
{{ 1, 2},{ 3, 4},{ 5, 6},{ 7, 8},{ 9, 10},{-12, 11},{-11,-13},{-10, -9},{ 12,-14},{ -8, -7},{-15, -6},{ 13, -5},{-16, -4},{ 14,-17},{ 15, -3},{ 16,-18},{ -2, 17},{ 18,-19},{ -1, 19},{-20, 20},{ 0, 21},{ 22,-21},{-22,-23}},
{{ 1, 2},{ 3, 4},{ 5, 6},{-11,-10},{ 7,-12},{ 8, -9},{ 9,-13},{-14, 10},{ -8,-15},{-16, 11},{ -7, 12},{-17, -6},{ 13, 14},{-18, 15},{ -5, -4},{ 16, 17},{ -3, -2},{-19, 18},{ -1, 19},{-20, 20},{ 21, 22},{ 0,-21},{-22,-23}},
{{ 1, 2},{ 3, 4},{ 5, 6},{-12,-11},{-13, 7},{ 8,-14},{-10, 9},{ 10,-15},{ -9, 11},{ -8, 12},{-16, 13},{ -7, -6},{-17, 14},{ -5,-18},{ 15, -4},{ 16,-19},{ 17, -3},{-20, 18},{ -2, 19},{-21, 20},{ 0, 21},{ 22, -1},{-22,-23}},
{{ 1, 2},{ 3, 4},{ 5, 6},{-11, 7},{-12,-10},{-13, -9},{ 8, 9},{-14, -8},{ 10,-15},{ -7, 11},{-16, 12},{ -6,-17},{ 13, 14},{ -5, 15},{-18, 16},{ -4, 17},{ -3,-19},{ 18, -2},{-20, 19},{ -1, 20},{ 0, 21},{ 22,-21},{-22,-23}},
{{ 1, 2},{ 3, 4},{ 5,-12},{ 6,-11},{-10,-13},{ -9, 7},{ 8,-14},{ 9, -8},{-15, 10},{ -7,-16},{ 11, -6},{ 12,-17},{ 13, -5},{-18, 14},{ 15, -4},{-19, 16},{ 17, -3},{-20, 18},{ 19, 20},{ 21, 22},{ 0, -2},{ -1,-21},{-22,-23}},
{{ 1, 2},{ 3, 4},{ 5,-12},{ 6,-13},{-11,-10},{ 7,-14},{ 8, -9},{ 9,-15},{ -8, 10},{ -7,-16},{ 11, 12},{ -6,-17},{ -5, 13},{ 14, 15},{-18, -4},{-19, 16},{ -3, 17},{ 18, -2},{-20, 19},{ 20, 21},{ 22, 0},{ -1,-21},{-22,-23}},
{{ 1, 2},{ 3, 4},{ 5, 6},{-11,-10},{-12, -9},{ 7, 8},{-13, -8},{ 9,-14},{ -7, 10},{ -6,-15},{ 11, 12},{ -5,-16},{ 13, 14},{-17, 15},{ -4, 16},{ 17,-18},{ 18, -3},{ -2, 19},{ -1, 0},{-19, 20},{-20, 21},{ 22,-21},{-22,-23}},
{{ 1, 2},{ 3, 4},{ 5, 6},{-11, 7},{-10,-12},{ -9, 8},{ -8,-13},{ 9, -7},{ 10,-14},{ -6, 11},{-15, 12},{ -5, 13},{-16, -4},{ 14, 15},{-17, -3},{-18, 16},{ 17,-19},{ -2, 18},{-20, 19},{ -1, 20},{ 21, 22},{ 0,-21},{-22,-23}},
{{ 1, 2},{ 3, 4},{ 5,-12},{ 6,-11},{ 7, 8},{-10,-13},{ -9, 9},{ -8,-14},{ 10, -7},{ 11,-15},{ -6, 12},{ -5, 13},{ -4,-16},{ 14, 15},{ -3,-17},{ 16, 17},{-18, -2},{ 18,-19},{ -1, 19},{-20, 20},{-21, 21},{ 22, 0},{-22,-23}},
{{ 1, 2},{ 3, 4},{ 5,-12},{-13, 6},{-11, 7},{-14, 8},{-10, 9},{-15, -9},{ -8, 10},{ -7,-16},{ 11, -6},{ 12, -5},{-17, 13},{ 14,-18},{ 15, -4},{ 16,-19},{ 17, -3},{ 18, -2},{ 19, -1},{-20, 20},{ 21, 22},{ 0,-21},{-22,-23}},
{{ 1, 2},{ 3, 4},{-12, 5},{-11,-13},{ 6,-14},{-10, 7},{ 8,-15},{ -9, 9},{-16, 10},{ -8,-17},{ 11, 12},{ -7,-18},{ -6, 13},{ 14, -5},{ 15,-19},{ -4, 16},{-20, 17},{ 18, 19},{ 20, 21},{ 22, 0},{ -1, -3},{ -2,-21},{-22,-23}},
{{ 1, 2},{ 3, 4},{-12, 5},{-11,-13},{ 6,-14},{-10, 7},{ 8,-15},{ -9, 9},{-16, 10},{ -8,-17},{ 11, 12},{ -7,-18},{ -6, 13},{ 14, -5},{ 15,-19},{ -4, 16},{-20, 17},{ 18, 19},{ 20, 21},{ 22, 0},{ -1, -3},{ -2,-21},{-22,-23}},
{{ 1, 2},{ 3, 4},{-12, 5},{-11,-13},{ 6,-14},{-10, 7},{ 8,-15},{ -9, 9},{-16, 10},{ -8,-17},{ 11, 12},{ -7,-18},{ -6, 13},{ 14, -5},{ 15,-19},{ -4, 16},{-20, 17},{ 18, 19},{ 20, 21},{ 22, 0},{ -1, -3},{ -2,-21},{-22,-23}},
{{ 1, 2},{ 3, 4},{-12, 5},{-11,-13},{ 6,-14},{-10, 7},{ 8,-15},{ -9, 9},{-16, 10},{ -8,-17},{ 11, 12},{ -7,-18},{ -6, 13},{ 14, -5},{ 15,-19},{ -4, 16},{-20, 17},{ 18, 19},{ 20, 21},{ 22, 0},{ -1, -3},{ -2,-21},{-22,-23}},
{{ 1, 2},{ 3, 4},{-12, 5},{-11,-13},{ 6,-14},{-10, 7},{ 8,-15},{ -9, 9},{-16, 10},{ -8,-17},{ 11, 12},{ -7,-18},{ -6, 13},{ 14, -5},{ 15,-19},{ -4, 16},{-20, 17},{ 18, 19},{ 20, 21},{ 22, 0},{ -1, -3},{ -2,-21},{-22,-23}},
{{ 1, 2},{ 3, 4},{-12, 5},{-11,-13},{ 6,-14},{-10, 7},{ 8,-15},{ -9, 9},{-16, 10},{ -8,-17},{ 11, 12},{ -7,-18},{ -6, 13},{ 14, -5},{ 15,-19},{ -4, 16},{-20, 17},{ 18, 19},{ 20, 21},{ 22, 0},{ -1, -3},{ -2,-21},{-22,-23}},
{{ 1, 2},{ 3, 4},{-12, 5},{-11,-13},{ 6,-14},{-10, 7},{ 8,-15},{ -9, 9},{-16, 10},{ -8,-17},{ 11, 12},{ -7,-18},{ -6, 13},{ 14, -5},{ 15,-19},{ -4, 16},{-20, 17},{ 18, 19},{ 20, 21},{ 22, 0},{ -1, -3},{ -2,-21},{-22,-23}},
{{ 1, 2},{ 3, 4},{-12, 5},{-11,-13},{ 6,-14},{-10, 7},{ 8,-15},{ -9, 9},{-16, 10},{ -8,-17},{ 11, 12},{ -7,-18},{ -6, 13},{ 14, -5},{ 15,-19},{ -4, 16},{-20, 17},{ 18, 19},{ 20, 21},{ 22, 0},{ -1, -3},{ -2,-21},{-22,-23}},
{{ 1, 2},{ 3, 4},{-12, 5},{-11,-13},{ 6,-14},{-10, 7},{ 8,-15},{ -9, 9},{-16, 10},{ -8,-17},{ 11, 12},{ -7,-18},{ -6, 13},{ 14, -5},{ 15,-19},{ -4, 16},{-20, 17},{ 18, 19},{ 20, 21},{ 22, 0},{ -1, -3},{ -2,-21},{-22,-23}},
{{ 1, 2},{ 3, 4},{-12, 5},{-11,-13},{ 6,-14},{-10, 7},{ 8,-15},{ -9, 9},{-16, 10},{ -8,-17},{ 11, 12},{ -7,-18},{ -6, 13},{ 14, -5},{ 15,-19},{ -4, 16},{-20, 17},{ 18, 19},{ 20, 21},{ 22, 0},{ -1, -3},{ -2,-21},{-22,-23}},
{{ 1, 2},{ 3, 4},{-12, 5},{-11,-13},{ 6,-14},{-10, 7},{ 8,-15},{ -9, 9},{-16, 10},{ -8,-17},{ 11, 12},{ -7,-18},{ -6, 13},{ 14, -5},{ 15,-19},{ -4, 16},{-20, 17},{ 18, 19},{ 20, 21},{ 22, 0},{ -1, -3},{ -2,-21},{-22,-23}},
{{ 1, 2},{ 3, 4},{-12, 5},{-11,-13},{ 6,-14},{-10, 7},{ 8,-15},{ -9, 9},{-16, 10},{ -8,-17},{ 11, 12},{ -7,-18},{ -6, 13},{ 14, -5},{ 15,-19},{ -4, 16},{-20, 17},{ 18, 19},{ 20, 21},{ 22, 0},{ -1, -3},{ -2,-21},{-22,-23}},
{{ 1, 2},{ 3, 4},{-12, 5},{-11,-13},{ 6,-14},{-10, 7},{ 8,-15},{ -9, 9},{-16, 10},{ -8,-17},{ 11, 12},{ -7,-18},{ -6, 13},{ 14, -5},{ 15,-19},{ -4, 16},{-20, 17},{ 18, 19},{ 20, 21},{ 22, 0},{ -1, -3},{ -2,-21},{-22,-23}},
{{ 1, 2},{ 3, 4},{-12, 5},{-11,-13},{ 6,-14},{-10, 7},{ 8,-15},{ -9, 9},{-16, 10},{ -8,-17},{ 11, 12},{ -7,-18},{ -6, 13},{ 14, -5},{ 15,-19},{ -4, 16},{-20, 17},{ 18, 19},{ 20, 21},{ 22, 0},{ -1, -3},{ -2,-21},{-22,-23}},
{{ 1, 2},{ 3, 4},{-12, 5},{-11,-13},{ 6,-14},{-10, 7},{ 8,-15},{ -9, 9},{-16, 10},{ -8,-17},{ 11, 12},{ -7,-18},{ -6, 13},{ 14, -5},{ 15,-19},{ -4, 16},{-20, 17},{ 18, 19},{ 20, 21},{ 22, 0},{ -1, -3},{ -2,-21},{-22,-23}}};
Word16 mlt_quant_centroid[NUM_CATEGORIES][MAX_NUM_BINS] = {
{ 0, 1606, 3119, 4586, 6049, 7502, 8941,10406,11851,13292,14736,16146,17566,19351, 0, 0},
{ 0, 2229, 4341, 6401, 8471,10531,12583,14588,16673,18924, 0, 0, 0, 0, 0, 0},
{ 0, 3055, 5998, 8929,11806,14680,17680, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 4121, 8192,12259,16322, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 5413,11071,16315, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 6785,14300, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 8044, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 8019, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
Word16 expected_bits_table[NUM_CATEGORIES] = {52, 47, 43, 37, 29, 22, 16, 0};
Word16 mlt_sqvh_bitcount_category_0[196] = {
1, 4, 6, 6, 7, 7, 8, 8, 8, 9, 9,10,11,11, 4, 5,
6, 7, 7, 8, 8, 9, 9, 9, 9,10,11,11, 5, 6, 7, 8,
8, 9, 9, 9, 9,10,10,10,11,12, 6, 7, 8, 9, 9, 9,
9,10,10,10,10,11,12,13, 7, 7, 8, 9, 9, 9,10,10,
10,10,11,11,12,13, 8, 8, 9, 9, 9,10,10,10,10,11,
11,12,13,14, 8, 8, 9, 9,10,10,11,11,11,12,12,13,
13,15, 8, 8, 9, 9,10,10,11,11,11,12,12,13,14,15,
9, 9, 9,10,10,10,11,11,12,13,12,14,15,16, 9, 9,
10,10,10,10,11,12,12,14,14,16,16,16, 9, 9,10,10,
11,11,12,13,13,14,14,15,15,16,10,10,10,11,11,12,
12,13,15,15,16,14,15,15,11,11,11,12,13,13,13,15,
16,16,16,16,14,15,11,11,12,13,13,14,15,16,16,16,
16,16,16,14};
UWord16 mlt_sqvh_code_category_0[196] = {
1, 2, 1, 24, 14, 51, 9, 68, 110, 26, 218, 54, 154, 761, 3, 10,
22, 8, 58, 22, 71, 16, 30, 50, 213, 75, 94, 632, 15, 18, 52, 23,
107, 5, 54, 63, 239, 46, 276, 271, 851, 252, 28, 10, 12, 1, 22, 133,
191, 55, 105, 278, 317, 554, 310, 276, 32, 50, 94, 20, 187, 219, 13, 268,
473, 445, 145, 849, 1277, 623, 1, 14, 0, 55, 238, 121, 120, 269, 318, 530,
639, 1117, 509, 556, 24, 78, 51, 153, 62, 308, 16, 25, 68, 1058, 428, 277,
2233, 1114, 92, 108, 141, 223, 270, 381, 24, 212, 760, 35, 1063, 279, 1717, 3439,
7, 21, 152, 73, 309, 310, 95, 944, 1890, 2232, 1891, 5107,10213, 4981, 61, 62,
9, 79, 474, 475, 848, 1059, 1056, 1716, 139, 4978, 4983, 4983, 140, 186, 76, 444,
144, 633, 1057, 838, 2237, 4472, 4473,10212,10212, 4983, 74, 78, 311, 213, 850, 1062,
1119, 508, 276, 277, 4982, 4473,10212,10212, 208, 70, 555, 418, 68, 510, 2552, 1115,
4980, 4979, 4982, 4982, 4473,10212, 215, 71, 253, 511, 839, 1718, 2488, 6876, 6877, 4979,
4979, 4982, 4982, 4473};
Word16 mlt_sqvh_bitcount_category_1[100] = {
1, 4, 5, 6, 7, 8, 8, 9,10,10, 4, 5, 6, 7, 7, 8,
8, 9, 9,11, 5, 5, 6, 7, 8, 8, 9, 9,10,11, 6, 6,
7, 8, 8, 9, 9,10,11,12, 7, 7, 8, 8, 9, 9,10,11,
11,13, 8, 8, 8, 9, 9,10,10,11,12,14, 8, 8, 8, 9,
10,11,11,12,13,15, 9, 9, 9,10,11,12,12,14,14,14,
9, 9, 9,10,11,12,14,16,14,14,10,10,11,12,13,14,
16,16,16,14};
UWord16 mlt_sqvh_code_category_1[100] = {
1, 2, 11, 27, 31, 9, 120, 31, 275, 310, 1, 0, 12, 5, 33, 54,
102, 111, 246, 448, 10, 14, 31, 39, 59, 100, 114, 202, 485, 969, 24, 26,
36, 52, 103, 30, 120, 242, 69, 1244, 35, 32, 14, 61, 113, 117, 233, 486,
487, 2491, 13, 12, 69, 110, 149, 35, 495, 449, 1978, 7751, 76, 75, 122, 136,
213, 68, 623, 930, 3959, 9961, 115, 16, 107, 225, 424, 850, 1936, 7916, 4981, 4981,
148, 154, 243, 407, 988, 851, 7750,19920, 7916, 4981, 406, 274, 464, 931, 3874, 7917,
19921,19920,19920, 7916};
Word16 mlt_sqvh_bitcount_category_2[49] = {
1, 4, 5, 7, 8, 9,10, 3, 4, 5, 7, 8, 9,10, 5, 5,
6, 7, 8,10,10, 7, 6, 7, 8, 9,10,12, 8, 8, 8, 9,
10,12,14, 8, 9, 9,10,11,15,16, 9,10,11,12,13,16,
15};
UWord16 mlt_sqvh_code_category_2[49] = {
1, 0, 10, 11, 28, 62, 363, 3, 2, 9, 8, 24, 53, 352, 7, 8,
13, 25, 89, 74, 355, 10, 23, 24, 29, 55, 354, 1449, 25, 19, 30, 52,
108, 438, 5793, 91, 36, 63, 353, 725,11584,23170, 180, 75, 218, 439, 2897,23171,
11584};
Word16 mlt_sqvh_bitcount_category_3[625] = {
2, 4, 6, 8,10, 5, 5, 6, 8,10, 7, 8, 8,10,12, 9,
9,10,12,15,10,11,13,16,16, 5, 6, 8,10,11, 5, 6,
8,10,12, 7, 7, 8,10,13, 9, 9,10,12,15,12,11,13,
16,16, 7, 9,10,12,15, 7, 8,10,12,13, 9, 9,11,13,
16,11,11,12,14,16,12,12,14,16,14, 9,11,12,16,16,
9,10,13,15,16,10,11,12,16,16,13,13,16,16,16,16,
16,15,16,16,11,13,16,16,15,11,13,15,16,16,13,13,
16,16,16,14,16,16,16,16,16,16,16,16,16, 4, 6, 8,
10,13, 6, 6, 8,10,13, 9, 8,10,12,16,10,10,11,15,
16,13,12,14,16,16, 5, 6, 8,11,13, 6, 6, 8,10,13,
8, 8, 9,11,14,10,10,12,12,16,13,12,13,15,16, 7,
8, 9,12,16, 7, 8,10,12,14, 9, 9,10,13,16,11,10,
12,15,16,13,13,16,16,15, 9,11,13,16,16, 9,10,12,
15,16,10,11,13,16,16,13,12,16,16,16,16,16,16,16,
16,11,13,16,16,16,11,13,16,16,16,12,13,15,16,16,
16,16,16,16,16,16,16,16,16,16, 6, 8,11,13,16, 8,
8,10,12,16,11,10,11,13,16,12,13,13,15,16,16,16,
14,16,15, 6, 8,10,13,16, 8, 8,10,12,16,10,10,11,
13,16,13,12,13,16,16,14,14,14,16,16, 8, 9,11,13,
16, 8, 9,11,16,14,10,10,12,15,16,12,12,13,16,16,
15,16,16,16,16,10,12,15,16,16,10,12,12,14,16,12,
12,13,16,16,14,15,16,16,16,16,16,16,16,16,12,15,
15,16,16,13,13,16,16,14,14,16,16,16,16,16,16,16,
16,16,14,15,16,16,16, 8,10,13,15,16,10,11,13,16,
16,13,13,14,16,16,16,16,16,16,16,16,16,16,16,16,
8,10,11,15,16, 9,10,12,16,16,12,12,15,16,16,16,
14,16,16,16,16,16,16,16,16, 9,11,14,16,16,10,11,
13,16,16,14,13,14,16,16,16,15,15,16,16,16,16,16,
16,16,11,13,16,16,16,11,13,15,16,16,13,16,16,16,
16,16,16,16,16,16,16,16,16,16,16,15,16,16,16,16,
14,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
16,16,16,16, 9,13,16,16,16,11,13,16,16,16,14,15,
16,16,16,15,16,16,16,16,16,16,16,16,16, 9,13,15,
15,16,12,13,14,16,16,16,15,16,16,16,16,16,16,16,
16,16,16,16,16,16,11,13,15,16,16,12,14,16,16,16,
16,16,16,16,16,16,16,16,16,16,16,15,15,16,16,16,
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,15,
16,16,13,16,16,16,16,16,16,16,16,16,16,16,16,16,
16};
UWord16 mlt_sqvh_code_category_3[625] = {
3, 8, 46, 145, 228, 4, 8, 47, 28, 455, 89, 2, 180, 5, 1335, 250,
12, 644, 1311, 139, 729, 251, 870, 2172, 2211, 5, 23, 112, 334, 1469, 21, 3,
5, 111, 2014, 88, 79, 152, 124, 2685, 297, 48, 110, 1310, 149, 501, 1231, 153,
2267, 2569, 57, 13, 653, 2587, 143, 75, 124, 118, 2611, 5242, 61, 50, 253, 3633,
2216, 476, 39, 57, 1926, 2236, 2586, 1329, 1920, 2566, 1926, 296, 233, 2590, 2240, 2217,
253, 613, 867, 144, 318, 614, 252, 2589, 2242, 2218, 872, 866, 2187, 2296, 2155, 2568,
2227, 150, 2567, 2296, 199, 2686, 2160, 2290,19145, 232, 2680, 128, 2192, 2212, 2684, 793,
2281, 2223, 2242, 1934, 2165, 2146, 2291, 2296, 2222, 2189, 2187, 2296, 2296, 6, 4, 82,
725, 3632, 15, 21, 56, 599, 148, 3, 162, 42, 411, 2301, 735, 654, 930, 137,
2586, 869, 1334, 1931, 2300, 2213, 9, 22, 146, 1290, 5240, 5, 12, 53, 630, 875,
80, 9, 8, 86, 2002, 210, 117, 56, 2019, 2162, 146, 397, 868, 131, 2151, 77,
160, 365, 2610, 2252, 59, 54, 41, 2591, 1928, 226, 14, 121, 5792, 2295, 1197, 728,
408, 130, 2157, 3635, 155, 2573, 2587, 130, 314, 64, 144, 2173, 2176, 115, 30, 409,
153, 2590, 631, 26, 4787, 2221, 2174, 2683, 1863, 2572, 319, 2150, 2177, 2194, 2571, 2257,
319, 65, 145, 2251, 2156, 2161, 909, 864, 2193, 2197, 2246, 2588, 5797, 156, 2258, 2221,
2158, 2199, 2214, 2152, 319, 2188, 2264, 2572, 319, 319, 30, 117, 219, 865, 2263, 147,
127, 239, 410, 2247, 27, 324, 1468, 2681, 2180, 1328, 5241, 147, 142, 2237, 2241, 2245,
1921, 2262, 142, 41, 11, 505, 2682, 2591, 0, 26, 229, 2015, 2577, 464, 98, 87,
5243, 2166, 149, 2016, 5244, 2190, 2198, 9573,11598,11599, 2235, 2190, 144, 298, 1004, 5245,
2277, 156, 104, 254, 2560, 1922, 612, 325, 2017, 129, 2588, 2608, 1330, 871, 2144, 2145,
132, 2147, 2148, 2149, 2144, 119, 1331, 133, 2153, 2154, 211, 58, 2609, 1923, 2159, 510,
163, 5246, 2163, 2164, 1924, 134, 2167, 2168, 2168, 2169, 2170, 2171, 2168, 2168, 1332, 135,
136, 2175, 2153, 150, 873, 2178, 2179, 1923, 1925, 2181, 2182, 2183, 2163, 2184, 2185, 2186,
2168, 2168, 1924, 134, 2167, 2168, 2168, 58, 326, 2687, 138, 2191, 31, 66, 874, 2195,
2196, 151, 152, 1927, 2200, 2201, 2202, 2203, 2204, 2205, 2206, 2207, 2208, 2209, 2210, 2205,
55, 103, 1230, 140, 2215, 118, 15, 1333, 2219, 2220, 2018, 511, 141, 2224, 2225, 2226,
1929, 2228, 2229, 2230, 2231, 2232, 2233, 2234, 2229, 366, 1005, 1930, 2238, 2239, 12, 1006,
5247, 2243, 2244, 1932, 3634, 1933, 2248, 2249, 2250, 145, 146, 2253, 2253, 2254, 2255, 2256,
2253, 2253, 1291, 5793, 2259, 2260, 2261, 477, 5794, 147, 2265, 2266, 5795, 2268, 2269, 2270,
2270, 2271, 2272, 2273, 2274, 2274, 2275, 2276, 2273, 2274, 2274, 148, 2278, 2279, 2280, 2260,
1935, 2282, 2283, 2284, 2265, 2285, 2286, 2287, 2270, 2270, 2288, 2289, 2273, 2274, 2274, 2271,
2272, 2273, 2274, 2274, 233, 5796, 2292, 2293, 2294, 1292, 3724, 2297, 2298, 2299, 2000, 151,
2302, 2303, 2200, 152, 2561, 2562, 2563, 2205, 2564, 2565, 2204, 2205, 2205, 363, 154, 154,
155, 2570, 59, 3725, 2001, 2574, 2575, 2576, 157, 2578, 2579, 2224, 2580, 2581, 2582, 2583,
2229, 2584, 2585, 2228, 2229, 2229, 654, 5798, 158, 2589, 2238, 2392, 2003, 2592, 2593, 2243,
2594, 2595, 2596, 2597, 2248, 2598, 2599, 2600, 2253, 2253, 2250, 145, 146, 2253, 2253, 2601,
2602, 2603, 2604, 2260, 2605, 2606, 2607, 6336, 2265, 6337, 6338, 6339, 2270, 2270, 6340, 6341,
2273, 2274, 2274, 2271, 2272, 2273, 2274, 2274, 6342, 6343, 2259, 2260, 2260,38288U,38289U, 147,
2265, 2265, 5795, 2268, 2269, 2270, 2270, 2271, 2272, 2273, 2274, 2274, 2271, 2272, 2273, 2274,
2274};
Word16 mlt_sqvh_bitcount_category_4[256] = {
2, 4, 7,10, 4, 5, 7,10, 7, 8,10,14,11,11,15,15,
4, 5, 9,12, 5, 5, 8,12, 8, 7,10,15,11,11,15,15,
7, 9,12,15, 8, 8,12,15,10,10,13,15,14,14,15,13,
11,13,15,15,11,13,15,15,14,15,15,13,15,15,13,13,
4, 5, 9,13, 5, 6, 9,13, 9, 9,11,15,14,13,15,15,
4, 6, 9,12, 5, 6, 9,13, 9, 8,11,15,13,12,15,15,
7, 9,12,15, 7, 8,11,15,10,10,14,15,14,15,15,14,
10,12,15,15,11,13,15,15,15,15,15,14,15,15,14,14,
6, 9,13,14, 8, 9,12,15,12,12,15,15,15,15,15,15,
7, 9,13,15, 8, 9,12,15,11,12,15,15,15,15,15,15,
9,11,15,15, 9,11,15,15,14,14,15,15,15,15,15,15,
14,15,15,15,14,15,15,15,15,15,15,15,14,14,15,15,
9,12,15,15,12,13,15,15,15,15,15,15,15,15,15,15,
10,12,15,15,12,14,15,15,15,15,15,15,15,15,15,15,
14,15,15,15,15,15,15,15,15,15,15,15,14,14,15,15,
15,15,15,15,15,15,15,15,14,14,15,15,14,14,15,15};
UWord16 mlt_sqvh_code_category_4[256] = {
1, 2, 4, 572, 10, 0, 69, 712, 91, 10, 46, 9182, 1426, 1430,30172,30194,
9, 28, 22, 2258, 16, 25, 142, 2179, 15, 111, 719, 1521, 1131, 1437, 1520,30196,
88, 283, 3803,30193, 13, 236, 2856,30166, 545, 951, 5709, 1522, 3241, 9180,30179, 5709,
1088, 4356,30410,30175, 1146, 377,30162,30163, 8715,30176,30165, 5709,30197,30184, 5709, 5709,
1, 23, 28, 5710, 26, 14, 29, 7538, 102, 103, 1429, 1524, 3237, 7060,30401,30201,
15, 13, 470, 3768, 24, 15, 281, 5747, 24, 181, 1128,30206, 5711, 3531,30156,30158,
116, 100, 2260,30187, 119, 234, 1764,30171, 716, 883, 9183,30164, 3236, 1528,30180, 9183,
885, 2870, 1532,30160, 1431, 5708,30192,30205,30402,30168,30173, 9183,30157,30161, 9183, 9183,
54, 25, 1621,15211, 180, 287, 2261,30198, 808, 811,30411,30413,30414,22986,22987,30411,
24, 273, 376,30159, 137, 280, 2871, 1523, 1768, 2259, 1525,30167, 1526,30169,30170, 1525,
443, 1434, 1527,30174, 474, 1769,30177,30178, 3238, 3239,30181,30181,30182,30183,30181,30181,
3240,30185,30186, 1527, 9181,30188,30189,30177,30190,30191,30181,30181, 3238, 3239,30181,30181,
440, 2857, 1529,30195, 2294, 7061, 1530,30199,30200, 1531,30202,30411,30203,30204,30411,30411,
203, 2872,30207,30400, 189,11492,30403,30404,30405,30406,30407, 1525,30408,30409, 1525, 1525,
8714, 1533,30412, 1527, 1534, 1535,30415,30177,30416,30417,30181,30181, 3238, 3239,30181,30181,
30418,30419, 1527, 1527,30420,30421,30177,30177, 3238, 3239,30181,30181, 3238, 3239,30181,30181};
Word16 mlt_sqvh_bitcount_category_5[243] = {
2, 4, 8, 4, 5, 9, 9,10,14, 4, 6,11, 5, 6,12,10,
11,15, 9,11,15,10,13,15,14,15, 6, 4, 6,12, 6, 7,
12,12,12,15, 5, 7,13, 6, 7,13,12,13,15,10,12,15,
11,13,15,15,15, 7, 8,13,15,11,12,15,15,15, 7,10,
13,15,12,15,15,15,15, 7,15,15, 7,15,15, 7, 6, 7,
7, 4, 5,11, 5, 7,12,11,12,15, 6, 7,13, 7, 8,14,
12,14,15,11,13,15,12,13,15,15,15, 8, 5, 6,13, 7,
8,15,12,14,15, 6, 8,14, 7, 8,15,14,15,15,12,12,
15,12,13,15,15,15, 8, 9,13,15,12,13,15,15,15, 8,
11,13,15,13,13,15,15,15, 8,14,15, 8,15,15, 8, 7,
8, 8, 8,10,15,11,12,15,15,15, 7,10,12,15,12,13,
15,15,15, 8,14,15, 7,15,15, 8, 7, 8, 8, 8,12,15,
12,13,15,15,15, 8,11,13,15,13,15,15,15,15, 8,15,
15, 8,15,15, 8, 7, 8, 8,14,15, 6,15,15, 8, 7, 8,
8,15,15, 8,15,15, 8, 7, 8, 8, 6, 8, 8, 7, 8, 8,
7, 8, 8};
UWord16 mlt_sqvh_code_category_5[243] = {
0, 5, 220, 10, 16, 443, 390, 391,14333, 11, 26, 1566, 26, 54, 3135, 508,
1558,28581, 255, 1782,28599, 885, 6208,28578,14335,28579, 54, 9, 35, 3129, 27, 68,
3537, 1562, 3568,28610, 25, 62, 4078, 58, 118, 7763, 3107, 7758,28563, 778, 3131,28598,
780, 7123,28630,28593,28586, 118, 243, 6210,28614, 1018, 3567,28601,28611,28570, 68, 388,
6256,28619, 1559,28562,28606,28565,28591, 118,28594,28571, 62,28618,28590, 118, 58, 118,
118, 4, 28, 1781, 31, 60, 3134, 1938, 3882,28574, 25, 96, 7757, 49, 126,14244,
3883,14334,28613, 1769, 4077,28602, 3106, 7756,28582,28621,28566, 126, 14, 61, 4079, 61,
138,28491, 3536, 8153,28573, 49, 96,12442, 119, 240,28490,12443,28560,28561, 3111, 3580,
28564, 3130, 7759,28567,28568,28569, 240, 444, 6209,28572, 3569, 6211,28575,28576,28577, 138,
778, 7760,28580, 7761, 7762,28583,28584,28585, 240,14319,28587, 96,28588,28589, 240, 119,
240, 240, 139, 968,28592, 1554, 3581,28595,28596,28597, 60, 971, 3560,28600, 3582, 7132,
28603,28604,28605, 126,14332,28607, 96,28608,28609, 126, 49, 126, 126, 241, 1558,28612,
1563, 6257,28615,28616,28617, 138, 1559, 7133,28620, 6220,28622,28623,28624,28625, 240,28626,
28627, 96,28628,28629, 240, 119, 240, 240, 8152,28631, 61,28632,28633, 138, 61, 138,
138,28634,28635, 96,28636,28637, 240, 119, 240, 240, 49, 96, 96, 119, 240, 240,
119, 240, 240};
Word16 mlt_sqvh_bitcount_category_6[32] = {
1, 4, 4, 6, 4, 6, 6, 8, 4, 6, 6, 8, 6, 9, 8,10,
4, 6, 7, 8, 6, 9, 8,11, 6, 9, 8,10, 8,10, 9,11};
UWord16 mlt_sqvh_code_category_6[32] = {
1, 2, 4, 2, 5, 29, 24, 101, 3, 31, 28, 105, 3, 5, 102, 424,
1, 30, 0, 107, 27, 200, 103, 806, 1, 4, 104, 402, 3, 425, 213, 807};
Word16 *table_of_bitcount_tables[NUM_CATEGORIES-1] = {
mlt_sqvh_bitcount_category_0,
mlt_sqvh_bitcount_category_1,
mlt_sqvh_bitcount_category_2,
mlt_sqvh_bitcount_category_3,
mlt_sqvh_bitcount_category_4,
mlt_sqvh_bitcount_category_5,
mlt_sqvh_bitcount_category_6
};
UWord16 *table_of_code_tables[NUM_CATEGORIES-1] = {
(UWord16 *)mlt_sqvh_code_category_0,
(UWord16 *)mlt_sqvh_code_category_1,
(UWord16 *)mlt_sqvh_code_category_2,
(UWord16 *)mlt_sqvh_code_category_3,
(UWord16 *)mlt_sqvh_code_category_4,
(UWord16 *)mlt_sqvh_code_category_5,
(UWord16 *)mlt_sqvh_code_category_6
};
Word16 mlt_decoder_tree_category_0[180][2] = {
{ 1, 0},{ 2, 3},{ 4, 5},{ 6, 7},{ 8, 9},{ -1, -14},{ 10, 11},{ 12, 13},
{ 14, 15},{ 16, 17},{ 18, 19},{ -15, 20},{ 21, 22},{ 23, -28},{ 24, -2},{ 25, 26},
{ 27, 28},{ 29, 30},{ 31, 32},{ -29, 33},{ -16, 34},{ -3, 35},{ 36, 37},{ -42, 38},
{ 39, 40},{ 41, 42},{ 43, 44},{ -17, 45},{ -43, 46},{ 47, 48},{ -4, 49},{ -56, 50},
{ 51, 52},{ 53, 54},{ 55, 56},{ -57, -5},{ -30, 57},{ 58, 59},{ -18, 60},{ 61, -70},
{ 62, 63},{ 64, -6},{ 65, 66},{ -44, 67},{ -71, 68},{ 69, 70},{ -19, -31},{ -84, 71},
{ 72, 73},{ 74, 75},{ 76, 77},{ -7, 78},{ 79, -20},{ 80, 81},{ -85, 82},{ -98, 83},
{ -58, 84},{ 85, -32},{ -99, 86},{ -8, 87},{ 88, 89},{ -72, -45},{ 90, -33},{ 91,-112},
{ -21, 92},{ -59,-113},{ -46, 93},{ -9, 94},{ -22, 95},{ 96, 97},{ 98, 99},{ -23, -86},
{ 100, 101},{ -34, -73},{ 102,-126},{-127, -35},{ 103, -47},{ 104, 105},{ 106, 107},{-140,-100},
{-114, -87},{ 108, 109},{ 110, 111},{-141, -60},{ 112, -48},{ 113, -24},{ -10, -61},{ 114,-101},
{ 115, 116},{ -74, -36},{ 117,-128},{ 118, -62},{ 119, 120},{ -37, 121},{ -11, -49},{ -88, 122},
{ 123,-115},{-154, -25},{-142, 124},{-155,-129},{ 125, -50},{ 126, 127},{ -76, -75},{ 128, 129},
{ -63, -77},{-102, -39},{ -38, 130},{ -51, 131},{ -89,-116},{-117,-156},{ 132, -52},{ -78, 133},
{ 134,-103},{ 135, 136},{-143, -65},{ 137, -64},{-130,-131},{ -90, 138},{-104, -91},{ -92, 139},
{-169,-183},{ -26,-118},{ 140, 141},{-144, -66},{ -12, 142},{-168, 143},{-105,-157},{ 144,-182},
{ 145, 146},{ -79, 147},{ -53,-170},{ 148, 149},{ -27,-145},{ 150, -80},{-106, -13},{-132, -67},
{-158, -40},{-119, 151},{ 152,-107},{ 153, 154},{ -41,-184},{ 155, 156},{ -54, 157},{-171, 158},
{ -94, 159},{-134,-146},{ -93,-133},{-159,-108},{ 160, -81},{ 161,-160},{ 162, -68},{-120,-122},
{-172, 163},{ -55, -95},{ 164,-109},{-161, -82},{-173,-185},{ 165, -69},{-147,-186},{ 166, 167},
{-121, -96},{ 168,-148},{-174, 169},{ 170,-136},{ -83, 171},{ 172, 173},{-135,-110},{-187, 174},
{-149,-150},{ 175,-123},{-162,-163},{ -97,-175},{-188, 176},{ 177, 178},{ 179,-111},{-151,-124},
{-137,-177},{-176,-125},{-164,-138},{-189,-190},};
Word16 mlt_decoder_tree_category_1[93][2] = {
{ 1, 0},{ 2, 3},{ 4, 5},{ 6, 7},{ 8, -10},{ -1, 9},{ 10, 11},{ 12, 13},
{ -11, 14},{ 15, 16},{ 17, 18},{ -20, -2},{ 19, 20},{ -21, 21},{ 22, 23},{ -12, 24},
{ 25, 26},{ 27, 28},{ 29, 30},{ -30, 31},{ -31, -3},{ 32, -22},{ 33, -13},{ 34, 35},
{ 36, 37},{ 38, 39},{ 40, -4},{ -41, -14},{ 41, -40},{ -32, 42},{ 43, -23},{ 44, 45},
{ 46, 47},{ 48, -5},{ -51, -50},{ -42, 49},{ -33, 50},{ -15, 51},{ 52, 53},{ 54, -24},
{ 55, -43},{ 56, -52},{ 57, -61},{ -60, 58},{ -25, 59},{ -16, -34},{ -6, 60},{ -62, 61},
{ -71, 62},{ -35, -7},{ 63, -72},{ -53, -17},{ 64, -44},{ -26, -70},{ 65, -45},{ -36, 66},
{ -63, 67},{ -80, -54},{ -81, 68},{ -27, 69},{ 70, -82},{ -18, 71},{ 72, -55},{ 73, -64},
{ 74, -73},{ 75, -46},{ -37, 76},{ -91, -8},{ -9, 77},{ -90, -83},{ 78, -28},{ 79, -56},
{ -65, -38},{ -74, 80},{ -19, -57},{ -92, 81},{ -47, -48},{ 82, -66},{ 83, -29},{ -84, 84},
{ -75, -85},{ -67, -93},{ -39, 85},{ -76, 86},{ -58, 87},{ 88, -49},{ -94, 89},{ 90, -68},
{ 91, -78},{ -86, -59},{ -77, -95},{ 92, -69},{ -87, -96},};
Word16 mlt_decoder_tree_category_2[47][2] = {
{ 1, 0},{ 2, 3},{ 4, 5},{ 6, -7},{ -1, 7},{ -8, 8},{ 9, 10},{ 11, 12},
{ 13, -14},{ -15, -9},{ -2, 14},{ 15, 16},{ 17, 18},{ 19, -16},{ 20, -22},{ -10, 21},
{ -21, -3},{ 22, 23},{ 24, 25},{ -23, -17},{ 26, 27},{ 28, -29},{ -11, -28},{ 29, 30},
{ -4, -24},{ -30, 31},{ 32, -18},{ 33, -35},{ -36, 34},{ -31, -12},{ 35, -25},{ -5, -37},
{ 36, 37},{ -42, 38},{ -19, -43},{ -32, 39},{ -13, -38},{ -26, -20},{ 40, -6},{ -44, 41},
{ 42, -39},{ -33, -45},{ 43, -27},{ 44, -46},{ 45, -34},{ -40, 46},{ -41, -47},};
Word16 mlt_decoder_tree_category_3[519][2] = {
{ 1, 2},{ 3, 4},{ 5, 0},{ 6, 7},{ 8, 9},{ 10, 11},{ 12, 13},{ 14, 15},
{ 16, 17},{-125, 18},{ -1, 19},{ 20, 21},{ 22, 23},{ 24, 25},{ -5, -25},{ 26, 27},
{ -6,-150},{ 28, 29},{ 30, 31},{ 32, 33},{ 34, -30},{ 35, 36},{ 37, 38},{ 39, -31},
{-126,-155},{ 40, 41},{-156, 42},{ 43,-130},{ 44,-131},{-151, -26},{ 45, 46},{-250, 47},
{ 48, 49},{ 50, 51},{ 52,-275},{ 53, 54},{ -2, -7},{ 55, 56},{ 57, 58},{ 59, 60},
{ 61, 62},{ 63, 64},{ 65, 66},{ 67, 68},{ 69, 70},{ 71, -50},{ 72,-180},{ 73, 74},
{ 75, 76},{ 77, -55},{ 78,-175},{ 79, -36},{ 80, 81},{ -35, -10},{ 82, 83},{-280, 84},
{ -11, 85},{ 86, -32},{ 87, 88},{ 89,-161},{ 90,-276},{ 91, 92},{-281, 93},{ -8, 94},
{ 95, 96},{ 97,-157},{-181,-400},{-132, 98},{-375, 99},{-160, 100},{-127, 101},{ -27, 102},
{ 103,-251},{ -56, 104},{ 105,-256},{-300, -3},{-152,-255},{ 106, 107},{ -37, 108},{-305, 109},
{-176, 110},{-136, 111},{ -12, 112},{ 113, 114},{ 115,-135},{ 116, 117},{-162, 118},{ -16, -51},
{-186, 119},{ 120, 121},{ 122, 123},{ -41, 124},{ -61, 125},{ 126, 127},{ 128, 129},{ 130, -60},
{ 131, 132},{-306, 133},{ 134,-205},{-405, 135},{ 136, 137},{ 138, 139},{-185, 140},{ 141,-500},
{ -15, 142},{ 143, -80},{ -75, -40},{-301, 144},{ 145, 146},{-200, 147},{ 148, 149},{ 150, 151},
{ 152,-525},{ 153,-177},{-425, 154},{ 155, -13},{-430, 156},{ 157,-406},{ 158, 159},{-206,-380},
{ 160, 161},{ 162, 163},{ 164,-182},{-137, 165},{-286, 166},{ 167,-401},{ 168, 169},{ -42, -33},
{ 170,-166},{ -57,-325},{ 171,-187},{ -38, 172},{ 173, 174},{-165,-330},{ -4,-282},{ 175,-257},
{-261,-311},{-376, 176},{ 177, 178},{ -28, 179},{ 180, -9},{-285, 181},{ 182, 183},{ 184,-277},
{ 185,-133},{-310, -81},{ -85, 186},{-158,-210},{ -17, 187},{ 188, 189},{ 190, -52},{-141, 191},
{ 192,-128},{-191, -20},{ 193,-140},{ 194, 195},{-211,-260},{ 196, 197},{ 198, 199},{ 200, -66},
{-201,-225},{-381, 201},{ 202, 203},{ 204, 205},{ 206, 207},{-163,-287},{ 208,-100},{ 209, 210},
{ 211, 212},{ 213,-252},{-105, -76},{ 214, 215},{ 216, -21},{ -86, -62},{-307, 217},{ -65,-455},
{-550, 218},{ 219, 220},{ 221, 222},{ 223, 224},{ 225,-230},{-142, 226},{-302,-426},{-431, 227},
{ 228, 229},{ 230,-190},{-402, -46},{-153,-450},{-505, 231},{ 232, 233},{ 234, 235},{ 236, 237},
{ 238, 239},{-262, -29},{ 240, 241},{ 242, 243},{-167, -67},{-331,-530},{ 244, 245},{ 246, 247},
{ 248, 249},{ 250, 251},{ 252, 253},{ 254, 255},{ 256, 257},{ 258, 259},{ 260, 261},{ 262,-336},
{ 263,-171},{-192,-207},{-258,-138},{ 264, 265},{ 266, 267},{ 268, 269},{ 270, 271},{ 272, 273},
{ 274, -45},{-335,-411},{ -43, -18},{-265, -71},{-316,-326},{-350,-407},{-146, -14},{ 275, 276},
{ 277, 278},{ 279, 280},{ 281,-216},{ -34,-283},{-291,-312},{-410,-168},{-555, 282},{ -70, -53},
{-235, -87},{ -77,-183},{-315,-332},{-178, -58},{ 283, 284},{ 285, 286},{ 287, 288},{ 289, 290},
{ 291, 292},{ 293, 294},{ 295, 296},{ 297, 298},{-202,-226},{-170,-267},{-134,-290},{-355,-385},
{-386, -47},{-526,-196},{ 299, 300},{ 301, 302},{ 303, 304},{ 305, 306},{ 307, 308},{ 309, 310},
{ 311, 312},{ 313, 314},{ 315, 316},{ 317, 318},{ 319, 320},{ 321, 322},{ 323, 324},{ 325,-111},
{-231,-253},{ -91, -82},{-172,-145},{ -22,-317},{ -90,-356},{-382,-159},{ 326, 327},{ 328, 329},
{ 330, 331},{ 332, 333},{ 334, 335},{-106,-263},{-278,-215},{-110, -39},{-101,-377},{-129, -63},
{-436,-195},{-506,-531},{ 336,-212},{-154,-266},{ -59,-288},{-292,-303},{-337,-432},{-188,-451},
{-456,-460},{-501,-236},{-551, 337},{ 338, 339},{ 340, 341},{ 342, 343},{ 344, 345},{ 346, 347},
{ 348, 349},{ 350, 351},{ 352, 353},{ 354, 355},{ 356, 357},{ 358, 359},{ 360, 361},{ 362, 363},
{ 364, 365},{ 366, 367},{ 368, 369},{ 370, 371},{ 372, 373},{ 374, 375},{ 376, 377},{ 378, 379},
{ 380, 381},{ 382, 383},{ 384, 385},{ 386, 387},{ 388, 389},{ 390, 391},{ 392, 393},{ 394, 395},
{ 396, 397},{ 398, 399},{ 400, 401},{ 402, 403},{ 404, 405},{ 406, 407},{ -72,-272},{-309,-333},
{-340,-360},{ -68,-387},{-184,-416},{-427,-147},{-435,-437},{-115,-480},{-510,-532},{-164,-556},
{ 408,-295},{-296,-297},{-107,-313},{-193,-173},{-320,-327},{-341,-351},{-352,-143},{-378, -19},
{-403,-412},{-268, -54},{ -83,-441},{-442,-457},{-475, -44},{ -97,-511},{-515,-208},{-527,-528},
{-237,-536},{-552, 409},{ 410, 411},{ 412, 413},{ 414, 415},{ 416, 417},{ 418, 419},{ 420, 421},
{ 422, 423},{ 424, 425},{ 426, 427},{ 428, 429},{ 430, 431},{ 432, 433},{ 434, 435},{ 436, 437},
{ 438, 439},{ 440, 441},{ 442, 443},{ 444, 445},{ 446, 447},{ 448, 449},{ 450, 451},{ 452, 453},
{ 454, 455},{ 456, 457},{ 458, 459},{ 460, 461},{ 462, 463},{ 464, 465},{ 466, 467},{ 468, 469},
{ 470, 471},{ 472, 473},{ 474, 475},{ 476, 477},{ 478, 479},{ 480, 481},{ 482, 483},{ 484, 485},
{ 486, 487},{ 488, 489},{ 490, 491},{ 492, 493},{ 494, 495},{ 496, 497},{ 498, 499},{ 500, 501},
{ 502, 503},{ 504, 505},{ 506, 507},{ 508, 509},{ 510, 511},{ 512, 513},{ 514, 515},{ 516, 517},
{ 518,-104},{ -84,-218},{-318,-319},{-117,-321},{-322,-323},{-219,-174},{-243,-328},{-329, -94},
{-228,-194},{-240,-334},{-102,-229},{-169,-338},{-339,-116},{-289,-342},{-343,-345},{-346,-347},
{ -23,-203},{-214,-353},{-204,-220},{-357,-358},{-264,-361},{-362,-363},{-365,-366},{-367, -92},
{-245,-121},{-293,-379},{-108,-232},{-221,-383},{-384,-233},{-294,-241},{-388,-389},{-390,-391},
{-392,-393},{-394,-395},{-396,-397},{-398, -24},{-109,-149},{-242,-404},{ -64, -79},{ -89,-408},
{-409,-213},{-120,-113},{-413,-414},{-415, -96},{-417,-418},{-419,-420},{-421,-422},{-423,-298},
{ -69,-269},{-428,-429},{ -78,-270},{ -88,-433},{-434,-271},{-234,-259},{-438,-439},{-440,-227},
{-179,-443},{-445,-446},{-447,-223},{-238,-452},{-453,-454},{-273,-254},{-246,-458},{-459, -48},
{-461,-462},{-463,-465},{-466,-467},{-468,-470},{-471,-304},{-476,-477},{-478,-112},{-481,-482},
{-483,-485},{-486,-487},{-490,-491},{-103,-118},{-502,-503},{-504,-189},{ -93,-507},{-508,-509},
{-148,-139},{-512,-513},{-308,-516},{-517,-518},{-520,-521},{ -73, -98},{ -95, -49},{-529,-222},
{-217,-197},{-533,-534},{-535,-284},{-537,-538},{-540,-541},{-542,-543},{-545,-546},{-144,-198},
{-314,-553},{-209,-279},{-557,-558},{-560,-561},{-562,-563},{-565,-566},{-567,-575},{-576,-577},
{-578,-580},{-581,-582},{-583,-585},{-586,-587},{-590,-591},{-600,-601},{-605,-606},};
Word16 mlt_decoder_tree_category_4[208][2] = {
{ 1, 2},{ 3, 0},{ 4, 5},{ 6, 7},{ 8, 9},{ 10, 11},{ 12, -64},{ -1, 13},
{ 14, -16},{ -4, 15},{ 16, 17},{ 18, -80},{ -5, 19},{ 20, 21},{ -20, 22},{ 23, -65},
{ -84, -21},{ -68, 24},{ -17, 25},{ 26, 27},{ 28, -81},{ -69, -85},{ 29, 30},{ 31, 32},
{-128, 33},{ 34, 35},{ -2, 36},{ 37, 38},{-144, 39},{ 40, -6},{ 41, 42},{ -32, 43},
{ 44, -8},{ 45, -25},{ -96, 46},{ 47,-100},{ -9, 48},{ 49, -36},{ 50, -24},{ 51, 52},
{ 53,-148},{ 54, 55},{ -22, 56},{ 57, 58},{-132, -89},{ 59, 60},{-101, 61},{ -37, 62},
{ -18, 63},{ -88,-129},{ -66, -70},{ -97, 64},{ -72, -73},{ 65,-145},{-149, -86},{ 66, -33},
{ 67,-133},{ 68, 69},{ 70, 71},{-192, 72},{ 73,-160},{ -82, 74},{-164, 75},{ -10, 76},
{ 77,-208},{ 78, -40},{ 79, 80},{ -3, 81},{ -7, 82},{ 83, 84},{-104, 85},{ 86, -26},
{ 87,-105},{ 88,-112},{ 89, 90},{ 91, -41},{ 92, 93},{ 94, 95},{ -48, 96},{ -90, 97},
{ 98, -28},{ -52, 99},{ -12, 100},{ 101, -74},{ -13,-116},{-161, 102},{ 103, -29},{-102, 104},
{-152,-165},{ 105, 106},{ 107, 108},{ 109, 110},{ 111,-212},{ 112, 113},{-136, 114},{ 115,-137},
{ 116, -23},{ -19,-153},{ -98,-134},{-196, 117},{ 118, 119},{ -38,-193},{-113,-150},{-209, 120},
{ 121, -93},{ -83, 122},{ 123, 124},{ 125, 126},{ 127, 128},{ 129, 130},{ 131, -34},{-146, -53},
{ 132, 133},{ 134, 135},{ 136, 137},{ 138,-130},{ -49, 139},{ 140, 141},{-117, -42},{ -67, -92},
{ 142, -87},{ -77,-197},{ -71, 143},{ 144, 145},{ 146, 147},{ 148, 149},{ 150, 151},{ 152, 153},
{ 154, 155},{ 156, 157},{ 158, 159},{ 160, 161},{ 162, 163},{ 164, 165},{ 166, 167},{ 168, 169},
{-108, -76},{-168,-169},{-176, -44},{-224, -56},{ -45,-180},{ -11,-106},{-213, 170},{ 171, 172},
{ 173, 174},{ 175, 176},{ 177, 178},{ 179, 180},{ 181, 182},{ 183, 184},{ 185, 186},{ 187, 188},
{ 189, 190},{ 191, 192},{ 193, 194},{ 195, 196},{ 197, 198},{ 199, 200},{ 201, 202},{ 203, 204},
{ 205, 206},{ 207,-131},{ -30, -27},{ -43,-151},{ -75,-154},{-156,-162},{-109,-194},{-198,-201},
{-114,-225},{-228,-229},{-141,-142},{ -94,-124},{ -95,-147},{-115,-125},{ -54, -55},{-107, -58},
{ -39,-155},{-121,-157},{-158,-103},{ -14,-122},{-163, -51},{ -57,-166},{-167, -46},{-110,-170},
{-172,-173},{ -61,-177},{-178, -99},{-181,-182},{-184,-185},{-118, -35},{ -15,-195},{ -31, -60},
{-135,-199},{-200, -79},{-202,-204},{-205,-119},{ -91,-210},{-211, -78},{-120,-214},{-215,-216},
{-217,-218},{-220,-221},{ -50,-138},{-226,-139},{-140,-230},{-232,-233},{-240,-241},{-244,-245},
};
Word16 mlt_decoder_tree_category_5[191][2] = {
{ 1, 2},{ 0, 3},{ 4, 5},{ 6, 7},{ 8, 9},{ 10, 11},{ -81, -1},{ 12, 13},
{ 14, -27},{ -3, -9},{ 15, 16},{ 17, 18},{ 19, 20},{-108, 21},{ -4, 22},{ 23, -36},
{ -12, 24},{ -82, 25},{ 26, -84},{ 27, -90},{ -10, -30},{ 28, 29},{ 30, -28},{ 31,-117},
{ -13, 32},{ -39, 33},{ 34,-109},{ 35, -93},{ -85,-111},{ -37, 36},{ -31, 37},{ -91, 38},
{ 39, 40},{ -40,-120},{ 41, 42},{-118, 43},{ -94, 44},{-112,-162},{ 45, 46},{ -2, 47},
{ 48, 49},{-121,-189},{ 50, -54},{ 51, 52},{ 53, -18},{ 54, 55},{ -6, 56},{ 57, -5},
{-135, 58},{ 59, 60},{ 61, 62},{ -63, 63},{ 64, -7},{ -15, 65},{ 66, 67},{ -45, 68},
{ 69, 70},{ 71, -21},{ 72, 73},{ 74, 75},{ 76, 77},{-163, 78},{ 79,-171},{-144, 80},
{ -48, 81},{ -57, 82},{ 83, 84},{-165, 85},{ -16,-198},{ 86, 87},{ -11, 88},{ 89, -99},
{ 90, -83},{ -19, 91},{ 92, 93},{ 94, 95},{ 96, 97},{ 98, 99},{ -87, 100},{ 101, 102},
{-190, -66},{ -33,-192},{ 103, 104},{ 105, 106},{-102, -42},{ 107,-126},{ 108, -29},{-129, -46},
{ -86, -14},{-114, -32},{-172, 109},{ 110, -58},{ -34,-138},{ 111, 112},{ 113, 114},{ 115, 116},
{ 117, 118},{ 119, 120},{-127,-166},{-174, 121},{ 122, 123},{ 124, 125},{ -88, -96},{ 126,-100},
{ -38,-110},{ -22,-136},{ -55,-139},{-201, 127},{ -64,-193},{ 128, -49},{-175,-199},{ 129, 130},
{ 131, 132},{ 133, 134},{ 135, 136},{ 137, 138},{ 139, 140},{ 141, 142},{ 143, 144},{ 145, 146},
{ 147, 148},{ 149, 150},{-103, -92},{ -43,-130},{-145,-147},{-148, -41},{-216,-115},{-119,-123},
{ -95, 151},{ 152, 153},{ 154, 155},{ 156, 157},{ 158, 159},{ 160, 161},{ 162, 163},{ 164, 165},
{ 166, 167},{ 168, 169},{ 170, 171},{ 172, 173},{ 174, 175},{ 176, 177},{ 178, 179},{ 180, 181},
{ 182, 183},{ 184, 185},{ 186, 187},{ 188, 189},{ 190,-153},{-180, -8},{ -97, -24},{-122,-113},
{-124,-125},{ -67, -44},{-128, -69},{-106,-131},{-132,-133},{ -61, -73},{-137,-116},{ -89,-140},
{-141,-142},{ -23, -25},{-146, -17},{-104,-149},{-150,-151},{ -52,-154},{-156,-157},{ -76, -70},
{-164, -51},{ -72,-167},{-168,-169},{ -47, -20},{-173, -59},{-101,-176},{-177,-178},{ -68,-181},
{-183,-184},{ -35, -60},{-191, -98},{ -56,-194},{-195,-196},{ -75, -65},{-200,-105},{-202,-203},
{-204,-205},{-207,-208},{-210,-211},{ -50,-217},{-219,-220},{-225,-226},{-228,-229},};
Word16 mlt_decoder_tree_category_6[31][2] = {
{ 1, 0},{ 2, 3},{ 4, 5},{ 6, 7},{ 8, -16},{ -1, -8},{ -2, -4},{ 9, 10},
{ 11, 12},{ 13, 14},{ 15, 16},{ 17, -24},{ -3, -12},{ -6, 18},{ 19, -20},{ -10, -5},
{ -17, -9},{ -18, 20},{ 21, 22},{ 23, 24},{ 25, -28},{ 26, -7},{ -14, -22},{ -26, -11},
{ 27, -19},{ -25, -13},{ -21, 28},{ 29, -30},{ -27, 30},{ -15, -29},{ -23, -31},};
Word16 *table_of_decoder_tables[NUM_CATEGORIES-1] = {
(Word16 *)mlt_decoder_tree_category_0,
(Word16 *)mlt_decoder_tree_category_1,
(Word16 *)mlt_decoder_tree_category_2,
(Word16 *)mlt_decoder_tree_category_3,
(Word16 *)mlt_decoder_tree_category_4,
(Word16 *)mlt_decoder_tree_category_5,
(Word16 *)mlt_decoder_tree_category_6,
};
+42
View File
@@ -0,0 +1,42 @@
/***********************************************************************
**
** ITU-T G.722.1 (2005-05) - Fixed point implementation for main body and Annex C
** > Software Release 2.1 (2008-06)
** (Simple repackaging; no change from 2005-05 Release 2.0 code)
**
** © 2004 Polycom, Inc.
**
** All rights reserved.
**
***********************************************************************/
extern Word16 differential_region_power_bits[MAX_NUMBER_OF_REGIONS][DIFF_REGION_POWER_LEVELS];
extern UWord16 differential_region_power_codes[MAX_NUMBER_OF_REGIONS][DIFF_REGION_POWER_LEVELS];
extern Word16 differential_region_power_decoder_tree[MAX_NUMBER_OF_REGIONS][DIFF_REGION_POWER_LEVELS-1][2];
extern Word16 mlt_quant_centroid[NUM_CATEGORIES][MAX_NUM_BINS];
extern Word16 expected_bits_table[NUM_CATEGORIES];
extern Word16 mlt_sqvh_bitcount_category_0[196];
extern UWord16 mlt_sqvh_code_category_0[196];
extern Word16 mlt_sqvh_bitcount_category_1[100];
extern UWord16 mlt_sqvh_code_category_1[100];
extern Word16 mlt_sqvh_bitcount_category_2[49];
extern UWord16 mlt_sqvh_code_category_2[49];
extern Word16 mlt_sqvh_bitcount_category_3[625];
extern UWord16 mlt_sqvh_code_category_3[625];
extern Word16 mlt_sqvh_bitcount_category_4[256];
extern UWord16 mlt_sqvh_code_category_4[256];
extern Word16 mlt_sqvh_bitcount_category_5[243];
extern UWord16 mlt_sqvh_code_category_5[243];
extern Word16 mlt_sqvh_bitcount_category_6[32];
extern UWord16 mlt_sqvh_code_category_6[32];
extern Word16 *table_of_bitcount_tables[NUM_CATEGORIES-1];
extern UWord16 *table_of_code_tables[NUM_CATEGORIES-1];
extern Word16 mlt_decoder_tree_category_0[180][2];
extern Word16 mlt_decoder_tree_category_1[93][2];
extern Word16 mlt_decoder_tree_category_2[47][2];
extern Word16 mlt_decoder_tree_category_3[519][2];
extern Word16 mlt_decoder_tree_category_4[208][2];
extern Word16 mlt_decoder_tree_category_5[191][2];
extern Word16 mlt_decoder_tree_category_6[31][2];
extern Word16 *table_of_decoder_tables[NUM_CATEGORIES-1];
+298
View File
@@ -0,0 +1,298 @@
/****************************************************************************
**
** ITU-T G.722.1 (2005-05) - Fixed point implementation for main body and Annex C
** > Software Release 2.1 (2008-06)
** (Simple repackaging; no change from 2005-05 Release 2.0 code)
**
** © 2004 Polycom, Inc.
**
** All rights reserved.
**
****************************************************************************/
/****************************************************************************
Filename: tables.c
Purpose: Contains tables used by G.722.1 Annex C
Design Notes:
****************************************************************************/
/***************************************************************************
Include files
***************************************************************************/
#include "defs.h"
Word16 int_region_standard_deviation_table[REGION_POWER_TABLE_SIZE] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 1, 1, 1, 2, 3, 4, 6,
8, 11, 16, 23, 32, 45, 64, 91, 128, 181,
256, 362, 512, 724, 1024, 1448, 2048, 2896, 4096, 5793,
8192, 11585, 16384, 23170, 0,0,0,0,0,0,
0,0,0,0};
Word16 standard_deviation_inverse_table[REGION_POWER_TABLE_SIZE] = {
32767, 32767, 32767, 32767, 32767, 32767, 32767, 32767, 32767, 32767,
32767, 32767, 32767, 32767, 32767, 32767, 32767, 32767, 32767, 32767,
32767, 32767, 32767, 32767, 32767, 23170, 16384, 11585, 8192, 5793,
4096, 2896, 2048, 1448, 1024, 724, 512, 362, 256, 181,
128, 91, 64, 45, 32, 23, 16, 11, 8, 6,
4, 3, 2, 1, 1, 1, 1, 0, 0, 0,
0, 0, 0, 0};
Word16 step_size_inverse_table[NUM_CATEGORIES]={
23167,16384,11585,8192,5793,4096,2896,2896
};
Word16 vector_dimension[NUM_CATEGORIES] = { 2, 2, 2, 4, 4, 5, 5, 1};
Word16 number_of_vectors[NUM_CATEGORIES] = {10,10,10, 5, 5, 4, 4,20};
/* The last category isn't really coded with scalar quantization. */
Word16 max_bin[NUM_CATEGORIES] = {13, 9, 6, 4, 3, 2, 1, 1};
Word16 max_bin_plus_one_inverse[NUM_CATEGORIES] =
{
2341,3277,4682,6554,8193,10923,16385,16385
};
/*
* Release 1.2.
* Add new version of int_dead_zone[] to go with
* changes to vector_huffman() in encoder.c.
*
*/
/************** See new version of table below
Word16 int_dead_zone[NUM_CATEGORIES]=
{
9830,10813,11796,12780,13763,14746,16384,16384
};
***************/
/******** New version of table added in Release 1.2 ********/
Word16 int_dead_zone[NUM_CATEGORIES]=
{
2457, 2703, 2949, 3195, 3440, 3686, 4096, 4096
};
/*
* Release 1.2.
* Added this new table to go with
* changes to vector_huffman() in encoder.c,
* accompanies the new table for int_dead_zone[].
*/
Word16 int_dead_zone_low_bits[NUM_CATEGORIES]=
{
2, 1, 0, 0, 3, 2, 0, 0
};
Word16 samples_to_rmlt_window[DCT_LENGTH]=
{ 44, 134, 224, 314, 404, 494, 584, 674, 764, 853,
943, 1033, 1123, 1213, 1302, 1392, 1482, 1571, 1661, 1750,
1840, 1929, 2019, 2108, 2197, 2286, 2376, 2465, 2554, 2643,
2732, 2821, 2909, 2998, 3087, 3175, 3264, 3352, 3441, 3529,
3617, 3705, 3793, 3881, 3969, 4057, 4144, 4232, 4319, 4407,
4494, 4581, 4668, 4755, 4842, 4928, 5015, 5101, 5188, 5274,
5360, 5446, 5532, 5617, 5703, 5788, 5873, 5959, 6043, 6128,
6213, 6297, 6382, 6466, 6550, 6634, 6718, 6801, 6885, 6968,
7051, 7134, 7217, 7299, 7382, 7464, 7546, 7628, 7709, 7791,
7872, 7953, 8034, 8115, 8195, 8276, 8356, 8436, 8515, 8595,
8674, 8753, 8832, 8911, 8989, 9068, 9146, 9223, 9301, 9378,
9455, 9532, 9609, 9685, 9762, 9838, 9913, 9989, 10064, 10139,
10214, 10288, 10363, 10437, 10510, 10584, 10657, 10730, 10803, 10875,
10948, 11020, 11091, 11163, 11234, 11305, 11375, 11446, 11516, 11586,
11655, 11724, 11793, 11862, 11930, 11998, 12066, 12134, 12201, 12268,
12334, 12401, 12467, 12532, 12598, 12663, 12728, 12792, 12857, 12920,
12984, 13047, 13110, 13173, 13235, 13297, 13359, 13420, 13481, 13542,
13602, 13662, 13722, 13782, 13841, 13899, 13958, 14016, 14074, 14131,
14188, 14245, 14301, 14357, 14413, 14468, 14523, 14578, 14632, 14686,
14739, 14793, 14845, 14898, 14950, 15002, 15053, 15104, 15155, 15205,
15255, 15305, 15354, 15403, 15451, 15500, 15547, 15595, 15642, 15688,
15734, 15780, 15826, 15871, 15916, 15960, 16004, 16047, 16091, 16133,
16176, 16218, 16259, 16300, 16341, 16382, 16422, 16461, 16501, 16540,
16578, 16616, 16654, 16691, 16728, 16764, 16800, 16836, 16871, 16906,
16940, 16974, 17008, 17041, 17074, 17106, 17138, 17170, 17201, 17232,
17262, 17292, 17321, 17350, 17379, 17407, 17435, 17462, 17489, 17516,
17542, 17567, 17593, 17617, 17642, 17666, 17689, 17713, 17735, 17758,
17779, 17801, 17822, 17842, 17863, 17882, 17901, 17920, 17939, 17957,
17974, 17991, 18008, 18024, 18040, 18055, 18070, 18085, 18099, 18113,
18126, 18139, 18151, 18163, 18174, 18185, 18196, 18206, 18216, 18225,
18234, 18242, 18250, 18257, 18265, 18271, 18277, 18283, 18288, 18293,
18298, 18302, 18305, 18308, 18311, 18313, 18315, 18316, 18317, 18317,
};
Word16 rmlt_to_samples_window[DCT_LENGTH]=
{ 44, 133, 222, 310, 399, 488, 577, 666, 754, 843,
932, 1020, 1109, 1198, 1286, 1375, 1464, 1552, 1641, 1729,
1817, 1906, 1994, 2082, 2171, 2259, 2347, 2435, 2523, 2611,
2699, 2786, 2874, 2962, 3049, 3137, 3224, 3312, 3399, 3486,
3573, 3660, 3747, 3834, 3921, 4008, 4094, 4181, 4267, 4353,
4439, 4526, 4611, 4697, 4783, 4869, 4954, 5040, 5125, 5210,
5295, 5380, 5465, 5549, 5634, 5718, 5802, 5886, 5970, 6054,
6138, 6221, 6304, 6388, 6471, 6553, 6636, 6719, 6801, 6883,
6965, 7047, 7129, 7211, 7292, 7373, 7454, 7535, 7616, 7696,
7777, 7857, 7937, 8016, 8096, 8175, 8254, 8333, 8412, 8491,
8569, 8647, 8725, 8803, 8880, 8957, 9035, 9111, 9188, 9264,
9341, 9417, 9492, 9568, 9643, 9718, 9793, 9868, 9942, 10016,
10090, 10163, 10237, 10310, 10383, 10455, 10528, 10600, 10672, 10743,
10815, 10886, 10957, 11027, 11098, 11168, 11237, 11307, 11376, 11445,
11514, 11582, 11650, 11718, 11785, 11853, 11920, 11986, 12053, 12119,
12185, 12250, 12315, 12380, 12445, 12509, 12573, 12637, 12701, 12764,
12826, 12889, 12951, 13013, 13075, 13136, 13197, 13257, 13318, 13378,
13437, 13497, 13556, 13614, 13673, 13731, 13788, 13846, 13903, 13959,
14016, 14072, 14128, 14183, 14238, 14292, 14347, 14401, 14454, 14508,
14561, 14613, 14665, 14717, 14769, 14820, 14871, 14921, 14971, 15021,
15070, 15119, 15168, 15216, 15264, 15311, 15359, 15405, 15452, 15498,
15544, 15589, 15634, 15678, 15722, 15766, 15810, 15853, 15895, 15938,
15979, 16021, 16062, 16103, 16143, 16183, 16223, 16262, 16300, 16339,
16377, 16414, 16452, 16488, 16525, 16561, 16596, 16632, 16666, 16701,
16735, 16768, 16801, 16834, 16867, 16899, 16930, 16961, 16992, 17022,
17052, 17082, 17111, 17140, 17168, 17196, 17223, 17250, 17277, 17303,
17329, 17354, 17379, 17404, 17428, 17452, 17475, 17498, 17520, 17542,
17564, 17585, 17606, 17626, 17646, 17665, 17684, 17703, 17721, 17739,
17756, 17773, 17790, 17806, 17821, 17836, 17851, 17865, 17879, 17893,
17906, 17918, 17931, 17942, 17954, 17965, 17975, 17985, 17995, 18004,
18012, 18021, 18028, 18036, 18043, 18049, 18055, 18061, 18066, 18071,
18076, 18079, 18083, 18086, 18089, 18091, 18093, 18094, 18095, 18095,
};
Word16 max_samples_to_rmlt_window[MAX_DCT_LENGTH]={
0, 43, 89, 133, 178, 222, 268, 314, 357, 403,
447, 493, 538, 582, 628, 671, 717, 763, 807, 853,
896, 942, 987, 1031, 1077, 1121, 1166, 1212, 1256, 1301,
1345, 1390, 1436, 1480, 1526, 1569, 1615, 1660, 1704, 1749,
1793, 1838, 1884, 1928, 1973, 2016, 2062, 2107, 2151, 2196,
2239, 2285, 2331, 2374, 2419, 2463, 2508, 2553, 2597, 2642,
2685, 2730, 2776, 2819, 2864, 2908, 2952, 2998, 3041, 3086,
3129, 3174, 3219, 3263, 3307, 3350, 3396, 3440, 3483, 3528,
3571, 3616, 3661, 3704, 3748, 3791, 3836, 3881, 3923, 3968,
4011, 4055, 4100, 4143, 4187, 4230, 4274, 4318, 4362, 4406,
4448, 4493, 4537, 4580, 4624, 4666, 4710, 4755, 4797, 4841,
4883, 4927, 4971, 5013, 5057, 5099, 5144, 5187, 5229, 5273,
5315, 5359, 5402, 5444, 5488, 5530, 5573, 5617, 5658, 5702,
5743, 5787, 5830, 5871, 5915, 5956, 6000, 6043, 6084, 6127,
6169, 6211, 6254, 6296, 6339, 6380, 6423, 6465, 6507, 6549,
6590, 6633, 6675, 6716, 6759, 6799, 6842, 6884, 6925, 6967,
7007, 7050, 7092, 7132, 7175, 7215, 7257, 7299, 7339, 7381,
7421, 7462, 7504, 7544, 7586, 7626, 7667, 7709, 7749, 7790,
7830, 7871, 7912, 7952, 7993, 8032, 8073, 8114, 8153, 8194,
8234, 8275, 8315, 8355, 8395, 8434, 8474, 8515, 8554, 8594,
8632, 8673, 8713, 8752, 8792, 8830, 8871, 8910, 8949, 8989,
9027, 9066, 9106, 9144, 9184, 9221, 9261, 9300, 9338, 9378,
9415, 9454, 9493, 9531, 9570, 9607, 9646, 9685, 9722, 9761,
9798, 9836, 9875, 9912, 9950, 9987, 10025, 10064, 10100, 10138,
10175, 10213, 10250, 10287, 10325, 10361, 10398, 10436, 10472, 10510,
10545, 10583, 10620, 10656, 10692, 10728, 10766, 10803, 10838, 10874,
10910, 10947, 10983, 11018, 11055, 11089, 11126, 11162, 11197, 11233,
11268, 11303, 11340, 11374, 11410, 11444, 11480, 11515, 11549, 11585,
11619, 11654, 11689, 11723, 11758, 11791, 11826, 11861, 11895, 11930,
11963, 11997, 12032, 12065, 12099, 12132, 12166, 12201, 12233, 12267,
12300, 12333, 12367, 12400, 12433, 12465, 12499, 12532, 12563, 12597,
12629, 12662, 12695, 12727, 12759, 12790, 12823, 12856, 12887, 12920,
12951, 12983, 13016, 13046, 13078, 13109, 13141, 13173, 13203, 13235,
13266, 13296, 13328, 13358, 13389, 13419, 13450, 13481, 13510, 13541,
13571, 13602, 13632, 13661, 13692, 13721, 13751, 13781, 13810, 13840,
13869, 13898, 13929, 13957, 13986, 14015, 14044, 14073, 14101, 14130,
14158, 14187, 14216, 14244, 14272, 14300, 14328, 14357, 14384, 14412,
14439, 14468, 14495, 14522, 14550, 14577, 14604, 14632, 14658, 14686,
14711, 14739, 14765, 14792, 14819, 14844, 14871, 14897, 14923, 14949,
14975, 15001, 15027, 15053, 15079, 15103, 15129, 15155, 15180, 15205,
15229, 15255, 15280, 15304, 15329, 15353, 15378, 15403, 15426, 15451,
15475, 15499, 15523, 15546, 15570, 15594, 15618, 15641, 15664, 15688,
15711, 15734, 15757, 15780, 15802, 15825, 15848, 15871, 15892, 15915,
15937, 15960, 15982, 16003, 16026, 16047, 16069, 16090, 16112, 16133,
16154, 16175, 16197, 16217, 16239, 16259, 16279, 16301, 16320, 16341,
16361, 16382, 16402, 16421, 16441, 16461, 16481, 16501, 16520, 16539,
16558, 16578, 16597, 16615, 16635, 16653, 16672, 16691, 16709, 16728,
16746, 16764, 16782, 16800, 16818, 16835, 16853, 16871, 16888, 16905,
16923, 16940, 16957, 16974, 16991, 17008, 17024, 17041, 17057, 17074,
17090, 17106, 17122, 17138, 17154, 17169, 17185, 17201, 17216, 17231,
17246, 17262, 17277, 17291, 17306, 17321, 17336, 17350, 17364, 17379,
17393, 17407, 17421, 17435, 17449, 17462, 17476, 17490, 17502, 17515,
17528, 17542, 17554, 17567, 17580, 17592, 17605, 17618, 17629, 17642,
17653, 17666, 17678, 17689, 17701, 17712, 17724, 17736, 17746, 17757,
17768, 17779, 17790, 17800, 17811, 17822, 17832, 17842, 17852, 17862,
17872, 17882, 17892, 17902, 17911, 17920, 17930, 17938, 17947, 17956,
17965, 17974, 17983, 17991, 17999, 18008, 18016, 18025, 18032, 18040,
18047, 18055, 18063, 18070, 18078, 18085, 18092, 18099, 18106, 18112,
18119, 18126, 18132, 18138, 18144, 18151, 18157, 18163, 18168, 18174,
18179, 18185, 18191, 18196, 18201, 18206, 18211, 18216, 18220, 18225,
18229, 18234, 18238, 18242, 18246, 18250, 18254, 18257, 18260, 18264,
18268, 18271, 18274, 18277, 18280, 18283, 18286, 18288, 18291, 18293,
18295, 18297, 18300, 18301, 18303, 18305, 18306, 18308, 18309, 18311,
18312, 18312, 18314, 18315, 18315, 18316, 18316, 18317, 18317, 18317
};
Word16 max_rmlt_to_samples_window[MAX_DCT_LENGTH]={
0, 43, 88, 131, 176, 219, 265, 310, 353, 398,
442, 487, 532, 575, 620, 663, 709, 754, 797, 842,
885, 931, 975, 1019, 1064, 1107, 1152, 1197, 1240, 1286,
1329, 1373, 1419, 1462, 1507, 1550, 1595, 1640, 1683, 1728,
1771, 1816, 1861, 1904, 1949, 1992, 2037, 2081, 2125, 2170,
2212, 2258, 2302, 2345, 2390, 2433, 2477, 2522, 2565, 2610,
2652, 2697, 2742, 2784, 2829, 2872, 2916, 2961, 3004, 3048,
3091, 3136, 3180, 3223, 3267, 3310, 3354, 3399, 3441, 3485,
3528, 3572, 3616, 3659, 3703, 3745, 3790, 3834, 3876, 3920,
3962, 4006, 4050, 4093, 4136, 4179, 4222, 4266, 4309, 4352,
4394, 4438, 4482, 4524, 4568, 4610, 4653, 4697, 4739, 4782,
4824, 4867, 4911, 4953, 4996, 5038, 5081, 5124, 5166, 5209,
5251, 5294, 5337, 5378, 5421, 5463, 5506, 5548, 5590, 5633,
5674, 5717, 5759, 5800, 5843, 5884, 5927, 5970, 6011, 6053,
6094, 6136, 6178, 6219, 6262, 6302, 6345, 6387, 6428, 6470,
6510, 6552, 6594, 6635, 6677, 6717, 6759, 6801, 6841, 6883,
6922, 6964, 7006, 7046, 7087, 7127, 7169, 7210, 7250, 7291,
7331, 7372, 7413, 7453, 7494, 7533, 7574, 7615, 7655, 7695,
7735, 7776, 7816, 7855, 7896, 7935, 7975, 8016, 8054, 8095,
8134, 8174, 8214, 8253, 8293, 8332, 8371, 8412, 8450, 8490,
8528, 8568, 8607, 8646, 8685, 8723, 8763, 8802, 8840, 8879,
8917, 8956, 8995, 9033, 9072, 9109, 9148, 9187, 9225, 9264,
9301, 9340, 9378, 9415, 9454, 9491, 9529, 9567, 9604, 9642,
9679, 9717, 9755, 9791, 9829, 9866, 9903, 9941, 9977, 10015,
10051, 10089, 10126, 10162, 10199, 10235, 10272, 10309, 10345, 10382,
10417, 10454, 10491, 10526, 10563, 10598, 10635, 10672, 10706, 10742,
10778, 10814, 10850, 10885, 10921, 10955, 10991, 11027, 11061, 11097,
11131, 11166, 11202, 11236, 11271, 11305, 11340, 11376, 11409, 11444,
11478, 11513, 11547, 11580, 11615, 11648, 11683, 11717, 11751, 11785,
11817, 11852, 11886, 11918, 11952, 11985, 12018, 12053, 12085, 12118,
12150, 12184, 12217, 12249, 12282, 12314, 12347, 12380, 12411, 12444,
12476, 12508, 12541, 12572, 12604, 12635, 12668, 12700, 12731, 12763,
12794, 12826, 12858, 12888, 12920, 12950, 12982, 13013, 13043, 13074,
13105, 13135, 13166, 13196, 13227, 13257, 13287, 13317, 13347, 13377,
13407, 13437, 13467, 13496, 13525, 13555, 13585, 13614, 13643, 13672,
13701, 13730, 13760, 13787, 13817, 13845, 13873, 13903, 13930, 13959,
13987, 14015, 14043, 14071, 14099, 14126, 14154, 14183, 14209, 14237,
14264, 14292, 14319, 14346, 14373, 14400, 14427, 14454, 14480, 14507,
14533, 14560, 14586, 14612, 14639, 14664, 14691, 14717, 14742, 14768,
14793, 14819, 14845, 14870, 14896, 14920, 14945, 14971, 14996, 15020,
15044, 15070, 15094, 15118, 15143, 15167, 15192, 15216, 15239, 15263,
15287, 15311, 15335, 15358, 15382, 15405, 15428, 15452, 15474, 15498,
15520, 15543, 15566, 15588, 15611, 15633, 15656, 15678, 15700, 15722,
15744, 15766, 15788, 15809, 15831, 15852, 15874, 15895, 15916, 15937,
15958, 15979, 16000, 16020, 16041, 16061, 16082, 16103, 16122, 16143,
16162, 16183, 16203, 16222, 16242, 16261, 16281, 16300, 16319, 16339,
16357, 16377, 16396, 16414, 16433, 16451, 16470, 16488, 16506, 16525,
16542, 16561, 16579, 16596, 16614, 16631, 16649, 16667, 16683, 16700,
16717, 16735, 16752, 16768, 16785, 16801, 16818, 16834, 16850, 16867,
16883, 16899, 16915, 16930, 16945, 16961, 16977, 16992, 17007, 17022,
17037, 17052, 17067, 17081, 17096, 17111, 17126, 17140, 17154, 17168,
17182, 17196, 17209, 17223, 17237, 17250, 17264, 17277, 17290, 17303,
17315, 17329, 17341, 17354, 17367, 17379, 17391, 17404, 17415, 17428,
17439, 17451, 17463, 17475, 17486, 17497, 17509, 17520, 17531, 17542,
17552, 17563, 17574, 17584, 17595, 17605, 17616, 17626, 17636, 17646,
17655, 17665, 17675, 17684, 17694, 17703, 17712, 17721, 17730, 17739,
17747, 17756, 17764, 17773, 17781, 17789, 17798, 17806, 17813, 17821,
17829, 17836, 17843, 17851, 17858, 17866, 17872, 17879, 17886, 17893,
17899, 17906, 17912, 17918, 17924, 17931, 17937, 17942, 17948, 17953,
17959, 17964, 17970, 17975, 17980, 17985, 17990, 17995, 17999, 18004,
18008, 18012, 18016, 18021, 18025, 18028, 18032, 18036, 18039, 18043,
18046, 18049, 18052, 18055, 18058, 18061, 18064, 18067, 18069, 18071,
18073, 18075, 18078, 18079, 18081, 18083, 18084, 18086, 18087, 18089,
18090, 18090, 18091, 18092, 18093, 18094, 18094, 18095, 18095, 18095
};
+47
View File
@@ -0,0 +1,47 @@
/***********************************************************************
**
** ITU-T G.722.1 (2005-05) - Fixed point implementation for main body and Annex C
** > Software Release 2.1 (2008-06)
** (Simple repackaging; no change from 2005-05 Release 2.0 code)
**
** © 1999 PictureTel Coporation
** Andover, MA, USA
**
** All rights reserved.
**
***********************************************************************/
/***********************************************************************
Filename: tables.h
Purpose: Contains table definitions used by G.722.1 Annex C
Design Notes:
***********************************************************************/
/***********************************************************************
Include files
***********************************************************************/
#define REGION_POWER_TABLE_SIZE 64
#define NUM_CATEGORIES 8
#define DCT_LENGTH 320
#define MAX_DCT_LENGTH 640
extern Word16 int_region_standard_deviation_table[REGION_POWER_TABLE_SIZE];
extern Word16 standard_deviation_inverse_table[REGION_POWER_TABLE_SIZE];
extern Word16 step_size_inverse_table[NUM_CATEGORIES];
extern Word16 vector_dimension[NUM_CATEGORIES];
extern Word16 number_of_vectors[NUM_CATEGORIES];
/* The last category isn't really coded with scalar quantization. */
extern Word16 max_bin[NUM_CATEGORIES];
extern Word16 max_bin_plus_one_inverse[NUM_CATEGORIES];
extern Word16 int_dead_zone[NUM_CATEGORIES];
extern Word16 samples_to_rmlt_window[DCT_LENGTH];
extern Word16 rmlt_to_samples_window[DCT_LENGTH];
/* Add next line in Release 1.2 */
extern Word16 int_dead_zone_low_bits[NUM_CATEGORIES];
extern Word16 max_samples_to_rmlt_window[MAX_DCT_LENGTH];
extern Word16 max_rmlt_to_samples_window[MAX_DCT_LENGTH];
+32
View File
@@ -0,0 +1,32 @@
/* $Id$ */
/*
* Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef TYPEDEF_H
#define TYPEDEF_H
#include <pj/types.h>
typedef pj_int8_t Word8;
typedef pj_int16_t Word16;
typedef pj_int32_t Word32;
typedef pj_uint16_t UWord16;
typedef pj_uint32_t UWord32;
typedef int Flag;
#endif /* TYPEDEF_H */