Index: pjproject/trunk/third_party/build/g7221/libg7221codec.vcproj
===================================================================
--- pjproject/trunk/third_party/build/g7221/libg7221codec.vcproj	(revision 2730)
+++ pjproject/trunk/third_party/build/g7221/libg7221codec.vcproj	(revision 2731)
@@ -3217,4 +3217,8 @@
 				</File>
 				<File
+					RelativePath="..\..\g7221\common\config.h"
+					>
+				</File>
+				<File
 					RelativePath="..\..\g7221\common\count.h"
 					>
Index: pjproject/trunk/third_party/g7221/common/basic_op.c
===================================================================
--- pjproject/trunk/third_party/g7221/common/basic_op.c	(revision 2730)
+++ pjproject/trunk/third_party/g7221/common/basic_op.c	(revision 2731)
@@ -1,2 +1,7 @@
+#include "config.h"
+
+#if !PJMEDIA_LIBG7221_FUNCS_INLINED || \
+    (PJMEDIA_LIBG7221_FUNCS_INLINED && defined(__BASIC_OP_H__))
+
 /*___________________________________________________________________________
  |                                                                           |
@@ -73,5 +78,5 @@
  |___________________________________________________________________________|
 */
-Word16 shr (Word16 var1, Word16 var2)
+LIBG7221_DEF(Word16) shr (Word16 var1, Word16 var2)
 {
     if (var2 < 0)
@@ -123,5 +128,5 @@
  |___________________________________________________________________________|
 */
-Word16 shl (Word16 var1, Word16 var2)
+LIBG7221_DEF(Word16) shl (Word16 var1, Word16 var2)
 {
     if (var2 < 0)
@@ -172,5 +177,5 @@
  |___________________________________________________________________________|
 */
-Word16 mult (Word16 var1, Word16 var2)
+LIBG7221_DEF(Word16) mult (Word16 var1, Word16 var2)
 {
     Word16 var_out;
@@ -229,5 +234,5 @@
  |___________________________________________________________________________|
 */
-Word32 L_msu (Word32 L_var3, Word16 var1, Word16 var2)
+LIBG7221_DEF(Word32) L_msu (Word32 L_var3, Word16 var1, Word16 var2)
 {
     Word32 L_var_out;
@@ -290,5 +295,5 @@
  |___________________________________________________________________________|
 */
-Word32 L_macNs (Word32 L_var3, Word16 var1, Word16 var2)
+LIBG7221_DEF(Word32) L_macNs (Word32 L_var3, Word16 var1, Word16 var2)
 {
     Word32 L_var_out;
@@ -351,5 +356,5 @@
  |___________________________________________________________________________|
 */
-Word32 L_msuNs (Word32 L_var3, Word16 var1, Word16 var2)
+LIBG7221_DEF(Word32) L_msuNs (Word32 L_var3, Word16 var1, Word16 var2)
 {
     Word32 L_var_out;
@@ -409,5 +414,5 @@
  |___________________________________________________________________________|
 */
-Word32 L_add_c (Word32 L_var1, Word32 L_var2)
+LIBG7221_DEF(Word32) L_add_c (Word32 L_var1, Word32 L_var2)
 {
     Word32 L_var_out;
@@ -525,5 +530,5 @@
  |___________________________________________________________________________|
 */
-Word32 L_sub_c (Word32 L_var1, Word32 L_var2)
+LIBG7221_DEF(Word32) L_sub_c (Word32 L_var1, Word32 L_var2)
 {
     Word32 L_var_out;
@@ -618,5 +623,5 @@
  |___________________________________________________________________________|
 */
-Word32 L_negate (Word32 L_var1)
+LIBG7221_DEF(Word32) L_negate (Word32 L_var1)
 {
     Word32 L_var_out;
@@ -664,5 +669,5 @@
  |___________________________________________________________________________|
 */
-Word16 mult_r (Word16 var1, Word16 var2)
+LIBG7221_DEF(Word16) mult_r (Word16 var1, Word16 var2)
 {
     Word16 var_out;
@@ -729,5 +734,5 @@
  |___________________________________________________________________________|
 */
-Word16 shr_r (Word16 var1, Word16 var2)
+LIBG7221_DEF(Word16) shr_r (Word16 var1, Word16 var2)
 {
     Word16 var_out;
@@ -798,5 +803,5 @@
  |___________________________________________________________________________|
 */
-Word16 mac_r (Word32 L_var3, Word16 var1, Word16 var2)
+LIBG7221_DEF(Word16) mac_r (Word32 L_var3, Word16 var1, Word16 var2)
 {
     Word16 var_out;
@@ -858,5 +863,5 @@
  |___________________________________________________________________________|
 */
-Word16 msu_r (Word32 L_var3, Word16 var1, Word16 var2)
+LIBG7221_DEF(Word16) msu_r (Word32 L_var3, Word16 var1, Word16 var2)
 {
     Word16 var_out;
@@ -908,5 +913,5 @@
  |___________________________________________________________________________|
 */
-Word32 L_deposit_h (Word16 var1)
+LIBG7221_DEF(Word32) L_deposit_h (Word16 var1)
 {
     Word32 L_var_out;
@@ -949,5 +954,5 @@
  |___________________________________________________________________________|
 */
-Word32 L_deposit_l (Word16 var1)
+LIBG7221_DEF(Word32) L_deposit_l (Word16 var1)
 {
     Word32 L_var_out;
@@ -1003,5 +1008,5 @@
  |___________________________________________________________________________|
 */
-Word32 L_shr_r (Word32 L_var1, Word16 var2)
+LIBG7221_DEF(Word32) L_shr_r (Word32 L_var1, Word16 var2)
 {
     Word32 L_var_out;
@@ -1061,5 +1066,5 @@
  |___________________________________________________________________________|
 */
-Word32 L_abs (Word32 L_var1)
+LIBG7221_DEF(Word32) L_abs (Word32 L_var1)
 {
     Word32 L_var_out;
@@ -1121,5 +1126,5 @@
  |___________________________________________________________________________|
 */
-Word16 norm_s (Word16 var1)
+LIBG7221_DEF(Word16) norm_s (Word16 var1)
 {
     Word16 var_out;
@@ -1131,5 +1136,5 @@
     else
     {
-        if (var1 == (Word16) 0xffff)
+        if (var1 == (UWord16)0xffff)
         {
             var_out = 15;
@@ -1192,5 +1197,5 @@
  |___________________________________________________________________________|
 */
-Word16 div_s (Word16 var1, Word16 var2)
+LIBG7221_DEF(Word16) div_s (Word16 var1, Word16 var2)
 {
     Word16 var_out = 0;
@@ -1292,5 +1297,5 @@
  |___________________________________________________________________________|
 */
-Word16 norm_l (Word32 L_var1)
+LIBG7221_DEF(Word16) norm_l (Word32 L_var1)
 {
     Word16 var_out;
@@ -1373,5 +1378,5 @@
  |___________________________________________________________________________|
 */
-Word32 L_mls (Word32 Lv, Word16 v)
+LIBG7221_DEF(Word32) L_mls (Word32 Lv, Word16 v)
 {
    Word32   Temp  ;
@@ -1432,5 +1437,5 @@
 |___________________________________________________________________________|
 */
-Word16 div_l (Word32  L_num, Word16 den)
+LIBG7221_DEF(Word16) div_l (Word32  L_num, Word16 den)
 {
     Word16   var_out = (Word16)0;
@@ -1520,5 +1525,5 @@
 |___________________________________________________________________________|
 */
-Word16 i_mult (Word16 a, Word16 b)
+LIBG7221_DEF(Word16) i_mult (Word16 a, Word16 b)
 {
 #ifdef ORIGINAL_G7231
@@ -1569,5 +1574,5 @@
  |___________________________________________________________________________
 */
-Word32 L_mult0 (Word16 var1,Word16 var2)
+LIBG7221_DEF(Word32) L_mult0 (Word16 var1,Word16 var2)
 {
   Word32 L_var_out;
@@ -1613,5 +1618,5 @@
  |___________________________________________________________________________
 */
-Word32 L_mac0 (Word32 L_var3, Word16 var1, Word16 var2)
+LIBG7221_DEF(Word32) L_mac0 (Word32 L_var3, Word16 var1, Word16 var2)
 {
   Word32 L_var_out;
@@ -1661,5 +1666,5 @@
  |___________________________________________________________________________
 */
-Word32 L_msu0 (Word32 L_var3, Word16 var1, Word16 var2)
+LIBG7221_DEF(Word32) L_msu0 (Word32 L_var3, Word16 var1, Word16 var2)
 {
   Word32 L_var_out;
@@ -1712,5 +1717,5 @@
  |___________________________________________________________________________|
 */
-UWord32 LU_shl (UWord32 L_var1, Word16 var2)
+LIBG7221_DEF(UWord32) LU_shl (UWord32 L_var1, Word16 var2)
 {
     Word16 neg_var2;
@@ -1743,5 +1748,5 @@
                 {
                     SET_OVERFLOW(1);
-                    L_var_out = MIN_32;
+                    L_var_out = (UWord32)MIN_32;
                     break;
                 }
@@ -1792,5 +1797,5 @@
  |___________________________________________________________________________|
 */
-UWord32 LU_shr (UWord32 L_var1, Word16 var2)
+LIBG7221_DEF(UWord32) LU_shr (UWord32 L_var1, Word16 var2)
 {
     Word16  neg_var2;
@@ -1826,4 +1831,5 @@
 /* ------------------------- End of LU_shr() ------------------------- */
 
+#endif /* PJMEDIA_LIBG7221_FUNCS_INLINED */
 
 /* ************************** END OF BASOP32.C ************************** */
Index: pjproject/trunk/third_party/g7221/common/basic_op.h
===================================================================
--- pjproject/trunk/third_party/g7221/common/basic_op.h	(revision 2730)
+++ pjproject/trunk/third_party/g7221/common/basic_op.h	(revision 2731)
@@ -1,10 +1,10 @@
 #ifndef __BASIC_OP_H__
 #define __BASIC_OP_H__
+
+#include "config.h"
 
 /*___________________________________________________________________________
  |                                                                           |
  |   Constants and Globals                                                   |
- |                                                                           |
- | $Id $
  |___________________________________________________________________________|
 */
@@ -28,9 +28,9 @@
 PJ_INLINE(Word16) sub (Word16 var1, Word16 var2);    /* Short sub,           1   */
 PJ_INLINE(Word16) abs_s (Word16 var1);               /* Short abs,           1   */
-Word16 shl (Word16 var1, Word16 var2);    /* Short shift left,    1   */
+LIBG7221_DECL(Word16) shl (Word16 var1, Word16 var2);    /* Short shift left,    1   */
 PJ_INLINE(Word16) shl_nocheck(Word16 var1, Word16 var2);
-Word16 shr (Word16 var1, Word16 var2);    /* Short shift right,   1   */
+LIBG7221_DECL(Word16) shr (Word16 var1, Word16 var2);    /* Short shift right,   1   */
 PJ_INLINE(Word16) shr_nocheck(Word16 var1, Word16 var2);
-Word16 mult (Word16 var1, Word16 var2);   /* Short mult,          1   */
+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   */
@@ -39,53 +39,53 @@
 PJ_INLINE(Word16) itu_round (Word32 L_var1);         /* Round,               1   */
 PJ_INLINE(Word32) L_mac (Word32 L_var3, Word16 var1, Word16 var2);   /* Mac,  1  */
-Word32 L_msu (Word32 L_var3, Word16 var1, Word16 var2);   /* Msu,  1  */
-Word32 L_macNs (Word32 L_var3, Word16 var1, Word16 var2); /* Mac without
-                                                             sat, 1   */
-Word32 L_msuNs (Word32 L_var3, Word16 var1, Word16 var2); /* Msu without
-                                                             sat, 1   */
+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 */
-Word32 L_add_c (Word32 L_var1, Word32 L_var2);  /* Long add with c, 2 */
-Word32 L_sub_c (Word32 L_var1, Word32 L_var2);  /* Long sub with c, 2 */
-Word32 L_negate (Word32 L_var1);                /* Long negate,     2 */
-Word16 mult_r (Word16 var1, Word16 var2);       /* Mult with round, 2 */
+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*/
-Word16 shr_r (Word16 var1, Word16 var2);        /* Shift right with
-                                                   round, 2           */
-Word16 mac_r (Word32 L_var3, Word16 var1, Word16 var2); /* Mac with
+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 */
-Word16 msu_r (Word32 L_var3, Word16 var1, Word16 var2); /* Msu with
+LIBG7221_DECL(Word16) msu_r (Word32 L_var3, Word16 var1, Word16 var2); /* Msu with
                                                            rounding,2 */
-Word32 L_deposit_h (Word16 var1);        /* 16 bit var1 -> MSB,     2 */
-Word32 L_deposit_l (Word16 var1);        /* 16 bit var1 -> LSB,     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 */
 
-Word32 L_shr_r (Word32 L_var1, Word16 var2); /* Long shift right with
-                                                round,  3             */
-Word32 L_abs (Word32 L_var1);            /* Long abs,              3  */
-Word32 L_sat (Word32 L_var1);            /* Long saturation,       4  */
-Word16 norm_s (Word16 var1);             /* Short norm,           15  */
-Word16 div_s (Word16 var1, Word16 var2); /* Short division,       18  */
-Word16 norm_l (Word32 L_var1);           /* Long norm,            30  */   
+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
 */
-Word32 L_mls( Word32, Word16 ) ;    /* Weight FFS; currently assigned 1 */
-Word16 div_l( Word32, Word16 ) ;    /* Weight FFS; currently assigned 1 */
-Word16 i_mult(Word16 a, Word16 b);  /* Weight FFS; currently assigned 1 */
+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
 */
-Word32 L_mult0(Word16 v1, Word16 v2); /* 32-bit Multiply w/o shift         1 */
-Word32 L_mac0(Word32 L_v3, Word16 v1, Word16 v2); /* 32-bit Mac w/o shift  1 */
-Word32 L_msu0(Word32 L_v3, Word16 v1, Word16 v2); /* 32-bit Msu w/o shift  1 */
+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
 */
-UWord32 LU_shl (UWord32 L_var1, Word16 var2);
-UWord32 LU_shr (UWord32 L_var1, Word16 var2);
+LIBG7221_DECL(UWord32) LU_shl (UWord32 L_var1, Word16 var2);
+LIBG7221_DECL(UWord32) LU_shr (UWord32 L_var1, Word16 var2);
 
 #define INCLUDE_UNSAFE	    0
@@ -109,5 +109,7 @@
 #include "basic_op_i.h"
 
-
+#if PJMEDIA_LIBG7221_FUNCS_INLINED
+#   include "basic_op.c"
+#endif
 
 #endif /* __BASIC_OP_H__ */
Index: pjproject/trunk/third_party/g7221/common/config.h
===================================================================
--- pjproject/trunk/third_party/g7221/common/config.h	(revision 2731)
+++ pjproject/trunk/third_party/g7221/common/config.h	(revision 2731)
@@ -0,0 +1,24 @@
+#ifndef __LIBG7221_CONFIG_H__
+#define __LIBG7221_CONFIG_H__
+
+#include <pj/config.h>
+
+/**
+ * Expand basic operation functions as inline.
+ *
+ * Default: 1 (yes)
+ */
+#ifndef PJMEDIA_LIBG7221_FUNCS_INLINED
+#   define PJMEDIA_LIBG7221_FUNCS_INLINED   1
+#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__ */
