Index: pjproject/trunk/aconfigure
===================================================================
--- pjproject/trunk/aconfigure	(revision 1870)
+++ pjproject/trunk/aconfigure	(revision 1871)
@@ -309,5 +309,5 @@
 #endif"
 
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CXX CXXFLAGS ac_ct_CXX ac_pjdir CPP EGREP ac_os_objs ac_pjmedia_snd ac_pa_cflags ac_pa_use_alsa ac_pa_use_oss ac_no_small_filter ac_no_large_filter ac_no_speex_aec ac_no_g711_codec ac_no_l16_codec ac_no_gsm_codec ac_no_speex_codec ac_no_ilbc_codec ac_no_ssl openssl_h_present libssl_present libcrypto_present ac_cross_compile ac_linux_poll ac_host ac_main_obj LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CXX CXXFLAGS ac_ct_CXX ac_pjdir CPP EGREP ac_os_objs ac_pjmedia_snd ac_pa_cflags ac_pa_use_alsa ac_pa_use_oss ac_no_small_filter ac_no_large_filter ac_no_speex_aec ac_no_g711_codec ac_no_l16_codec ac_no_gsm_codec ac_no_g722_codec ac_no_speex_codec ac_no_ilbc_codec ac_no_ssl openssl_h_present libssl_present libcrypto_present ac_cross_compile ac_linux_poll ac_host ac_main_obj LIBOBJS LTLIBOBJS'
 ac_subst_files=''
 
@@ -866,4 +866,5 @@
   --disable-l16-codec     Exclude Linear/L16 codec family from the build
   --disable-gsm-codec     Exclude GSM codec in the build
+  --disable-g722-codec    Exclude G.722 codec in the build
   --disable-speex-codec   Exclude Speex codecs in the build
   --disable-ilbc-codec    Exclude iLBC codec in the build
@@ -10472,4 +10473,22 @@
   echo "$as_me:$LINENO: result: Checking if GSM codec is disabled...no" >&5
 echo "${ECHO_T}Checking if GSM codec is disabled...no" >&6
+fi;
+
+
+# Check whether --enable-g722-codec or --disable-g722-codec was given.
+if test "${enable_g722_codec+set}" = set; then
+  enableval="$enable_g722_codec"
+  if test "$enable_g722_codec" = "no"; then
+		ac_no_g722_codec=1
+		cat >>confdefs.h <<\_ACEOF
+#define PJMEDIA_HAS_G722_CODEC 0
+_ACEOF
+
+		echo "$as_me:$LINENO: result: Checking if G.722 codec is disabled...yes" >&5
+echo "${ECHO_T}Checking if G.722 codec is disabled...yes" >&6
+	       fi
+else
+  echo "$as_me:$LINENO: result: Checking if G.722 codec is disabled...no" >&5
+echo "${ECHO_T}Checking if G.722 codec is disabled...no" >&6
 fi;
 
@@ -11678,4 +11697,5 @@
 s,@ac_no_l16_codec@,$ac_no_l16_codec,;t t
 s,@ac_no_gsm_codec@,$ac_no_gsm_codec,;t t
+s,@ac_no_g722_codec@,$ac_no_g722_codec,;t t
 s,@ac_no_speex_codec@,$ac_no_speex_codec,;t t
 s,@ac_no_ilbc_codec@,$ac_no_ilbc_codec,;t t
Index: pjproject/trunk/aconfigure.ac
===================================================================
--- pjproject/trunk/aconfigure.ac	(revision 1870)
+++ pjproject/trunk/aconfigure.ac	(revision 1871)
@@ -476,4 +476,16 @@
 	      AC_MSG_RESULT([Checking if GSM codec is disabled...no]))
 
+dnl # Include G.722 codec
+AC_SUBST(ac_no_g722_codec)
+AC_ARG_ENABLE(g722-codec,
+	      AC_HELP_STRING([--disable-g722-codec],
+			     [Exclude G.722 codec in the build]),
+	      [if test "$enable_g722_codec" = "no"; then
+		[ac_no_g722_codec=1]
+		AC_DEFINE(PJMEDIA_HAS_G722_CODEC,0)
+		AC_MSG_RESULT([Checking if G.722 codec is disabled...yes])
+	       fi],
+	      AC_MSG_RESULT([Checking if G.722 codec is disabled...no]))
+
 dnl # Include Speex codec
 AC_SUBST(ac_no_speex_codec)
Index: pjproject/trunk/pjmedia/build/os-auto.mak.in
===================================================================
--- pjproject/trunk/pjmedia/build/os-auto.mak.in	(revision 1870)
+++ pjproject/trunk/pjmedia/build/os-auto.mak.in	(revision 1871)
@@ -27,4 +27,5 @@
 AC_NO_SPEEX_CODEC=@ac_no_speex_codec@
 AC_NO_ILBC_CODEC=@ac_no_ilbc_codec@
+AC_NO_G722_CODEC=@ac_no_g722_codec@
 
 export CODEC_OBJS=
@@ -66,4 +67,10 @@
 endif
 
+ifeq ($(AC_NO_G722_CODEC),1)
+export CFLAGS += -DPJMEDIA_HAS_G722_CODEC=0
+else
+export CODEC_OBJS += g722.o g722/g722_enc.o g722/g722_dec.o
+endif
+
 
 #
Index: pjproject/trunk/pjmedia/build/os-darwinos.mak
===================================================================
--- pjproject/trunk/pjmedia/build/os-darwinos.mak	(revision 1870)
+++ pjproject/trunk/pjmedia/build/os-darwinos.mak	(revision 1871)
@@ -24,4 +24,5 @@
 AC_NO_SPEEX_CODEC=0
 AC_NO_ILBC_CODEC=0
+AC_NO_G722_CODEC=0
 
 export CODEC_OBJS=
@@ -64,4 +65,10 @@
 endif
 
+ifeq ($(AC_NO_G722_CODEC),1)
+export CFLAGS += -DPJMEDIA_HAS_G722_CODEC=0
+else
+export CODEC_OBJS += g722.o g722/g722_enc.o g722/g722_dec.o
+endif
+
 
 #
Index: pjproject/trunk/pjmedia/build/os-linux.mak
===================================================================
--- pjproject/trunk/pjmedia/build/os-linux.mak	(revision 1870)
+++ pjproject/trunk/pjmedia/build/os-linux.mak	(revision 1871)
@@ -19,4 +19,5 @@
 AC_NO_SPEEX_CODEC=0
 AC_NO_ILBC_CODEC=0
+AC_NO_G722_CODEC=0
 
 export CODEC_OBJS=
@@ -58,4 +59,10 @@
 endif
 
+ifeq ($(AC_NO_G722_CODEC),1)
+export CFLAGS += -DPJMEDIA_HAS_G722_CODEC=0
+else
+export CODEC_OBJS += g722.o g722/g722_enc.o g722/g722_dec.o
+endif
+
 
 #
Index: pjproject/trunk/pjmedia/build/os-win32.mak
===================================================================
--- pjproject/trunk/pjmedia/build/os-win32.mak	(revision 1870)
+++ pjproject/trunk/pjmedia/build/os-win32.mak	(revision 1871)
@@ -20,4 +20,5 @@
 AC_NO_SPEEX_CODEC=0
 AC_NO_ILBC_CODEC=0
+AC_NO_G722_CODEC=0
 
 export CODEC_OBJS=
@@ -60,4 +61,10 @@
 endif
 
+ifeq ($(AC_NO_G722_CODEC),1)
+export CFLAGS += -DPJMEDIA_HAS_G722_CODEC=0
+else
+export CODEC_OBJS += g722.o g722/g722_enc.o g722/g722_dec.o
+endif
+
 
 #
Index: pjproject/trunk/pjmedia/include/pjmedia-codec/config_auto.h.in
===================================================================
--- pjproject/trunk/pjmedia/include/pjmedia-codec/config_auto.h.in	(revision 1870)
+++ pjproject/trunk/pjmedia/include/pjmedia-codec/config_auto.h.in	(revision 1871)
@@ -55,4 +55,10 @@
 
 
+/* G722 codec */
+#ifndef PJMEDIA_HAS_G722_CODEC
+#undef PJMEDIA_HAS_G722_CODEC
+#endif
+
+
 #endif	/* __PJMEDIA_CODEC_CONFIG_AUTO_H_ */
 
Index: pjproject/trunk/pjmedia/src/pjmedia-codec/g722/g722_enc.c
===================================================================
--- pjproject/trunk/pjmedia/src/pjmedia-codec/g722/g722_enc.c	(revision 1870)
+++ pjproject/trunk/pjmedia/src/pjmedia-codec/g722/g722_enc.c	(revision 1871)
@@ -77,5 +77,5 @@
     sil = el >> 15 ;
     if (sil == 0 )  wd = el ;
-    else wd = 32767 - el & 32767 ;
+    else wd = 32767 - (el & 32767) ;
 
     mil = 1 ;
@@ -305,5 +305,5 @@
     sih = eh >> 15 ;
     if (sih == 0 )  wd = eh ;
-    else wd = 32767 - eh & 32767 ;
+    else wd = 32767 - (eh & 32767) ;
 
     hdu = (564 << 3) * deth;
