From 19853c437ee949f136d377b2f8a016db9bba18ae Mon Sep 17 00:00:00 2001
From: Russell Bryant <russell@russellbryant.com>
Date: Fri, 15 May 2009 17:59:08 +0000
Subject: [PATCH] Shuttle some bits around to address some gain issues with
 G.722.

(closes AST-209)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@194722 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 codecs/g722/g722_decode.c | 6 +++---
 codecs/g722/g722_encode.c | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/codecs/g722/g722_decode.c b/codecs/g722/g722_decode.c
index 1625acc860..3e8f7d0c60 100644
--- a/codecs/g722/g722_decode.c
+++ b/codecs/g722/g722_decode.c
@@ -370,7 +370,7 @@ int g722_decode(g722_decode_state_t *s, int16_t amp[], const uint8_t g722_data[]
         {
             if (s->eight_k)
             {
-                amp[outlen++] = (int16_t) rlow;
+                amp[outlen++] = (int16_t) (rlow << 1);
             }
             else
             {
@@ -387,8 +387,8 @@ int g722_decode(g722_decode_state_t *s, int16_t amp[], const uint8_t g722_data[]
                     xout2 += s->x[2*i]*qmf_coeffs[i];
                     xout1 += s->x[2*i + 1]*qmf_coeffs[11 - i];
                 }
-                amp[outlen++] = (int16_t) (xout1 >> 12);
-                amp[outlen++] = (int16_t) (xout2 >> 12);
+                amp[outlen++] = (int16_t) (xout1 >> 11);
+                amp[outlen++] = (int16_t) (xout2 >> 11);
             }
         }
     }
diff --git a/codecs/g722/g722_encode.c b/codecs/g722/g722_encode.c
index ad7e6b522b..5890fbf24e 100644
--- a/codecs/g722/g722_encode.c
+++ b/codecs/g722/g722_encode.c
@@ -279,7 +279,7 @@ int g722_encode(g722_encode_state_t *s, uint8_t g722_data[], const int16_t amp[]
         {
             if (s->eight_k)
             {
-                xlow = amp[j++];
+                xlow = amp[j++] >> 1;
             }
             else
             {
@@ -298,8 +298,8 @@ int g722_encode(g722_encode_state_t *s, uint8_t g722_data[], const int16_t amp[]
                     sumodd += s->x[2*i]*qmf_coeffs[i];
                     sumeven += s->x[2*i + 1]*qmf_coeffs[11 - i];
                 }
-                xlow = (sumeven + sumodd) >> 13;
-                xhigh = (sumeven - sumodd) >> 13;
+                xlow = (sumeven + sumodd) >> 14;
+                xhigh = (sumeven - sumodd) >> 14;
             }
         }
         /* Block 1L, SUBTRA */
-- 
GitLab