1b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org/*
2b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *
4b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *  Use of this source code is governed by a BSD-style license
5b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *  that can be found in the LICENSE file in the root of the source
6b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *  tree. An additional intellectual property rights grant can be found
7b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *  in the file PATENTS.  All contributing project authors may
8b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *  be found in the AUTHORS file in the root of the source tree.
9b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org */
10b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
11b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org/******************************************************************
12b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
13b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org iLBC Speech Coder ANSI-C Source Code
14b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
15b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org WebRtcIlbcfix_Smooth.c
16b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
17b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org******************************************************************/
18b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
19b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org#include "defines.h"
20b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org#include "constants.h"
21b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org#include "smooth_out_data.h"
22b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
23b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org/*----------------------------------------------------------------*
24b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org * find the smoothed output data
25b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *---------------------------------------------------------------*/
26b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
27b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.orgvoid WebRtcIlbcfix_Smooth(
28fbda0fcf2f9e82c82bcaac138f44d4e5144f6e0dpbos@webrtc.org    int16_t *odata,   /* (o) smoothed output */
29fbda0fcf2f9e82c82bcaac138f44d4e5144f6e0dpbos@webrtc.org    int16_t *current,  /* (i) the un enhanced residual for
30b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org                                this block */
31fbda0fcf2f9e82c82bcaac138f44d4e5144f6e0dpbos@webrtc.org    int16_t *surround  /* (i) The approximation from the
32b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org                                surrounding sequences */
33b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org                          ) {
34fbda0fcf2f9e82c82bcaac138f44d4e5144f6e0dpbos@webrtc.org  int16_t maxtot, scale, scale1, scale2;
35fbda0fcf2f9e82c82bcaac138f44d4e5144f6e0dpbos@webrtc.org  int16_t A, B, C, denomW16;
36fbda0fcf2f9e82c82bcaac138f44d4e5144f6e0dpbos@webrtc.org  int32_t B_W32, denom, num;
37fbda0fcf2f9e82c82bcaac138f44d4e5144f6e0dpbos@webrtc.org  int32_t errs;
38fbda0fcf2f9e82c82bcaac138f44d4e5144f6e0dpbos@webrtc.org  int32_t w00,w10,w11, endiff, crit;
39fbda0fcf2f9e82c82bcaac138f44d4e5144f6e0dpbos@webrtc.org  int32_t w00prim, w10prim, w11_div_w00;
40fbda0fcf2f9e82c82bcaac138f44d4e5144f6e0dpbos@webrtc.org  int16_t w11prim;
41fbda0fcf2f9e82c82bcaac138f44d4e5144f6e0dpbos@webrtc.org  int16_t bitsw00, bitsw10, bitsw11;
42fbda0fcf2f9e82c82bcaac138f44d4e5144f6e0dpbos@webrtc.org  int32_t w11w00, w10w10, w00w00;
43fbda0fcf2f9e82c82bcaac138f44d4e5144f6e0dpbos@webrtc.org  int16_t max1, max2;
44b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
45b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  /* compute some inner products (ensure no overflow by first calculating proper scale factor) */
46b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
47b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  w00 = w10 = w11 = 0;
48b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
49b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  max1=WebRtcSpl_MaxAbsValueW16(current, ENH_BLOCKL);
50b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  max2=WebRtcSpl_MaxAbsValueW16(surround, ENH_BLOCKL);
51b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  maxtot=WEBRTC_SPL_MAX(max1, max2);
52b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
53b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  scale=WebRtcSpl_GetSizeInBits(maxtot);
54fbda0fcf2f9e82c82bcaac138f44d4e5144f6e0dpbos@webrtc.org  scale = (int16_t)WEBRTC_SPL_MUL_16_16(2,scale)-26;
55b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  scale=WEBRTC_SPL_MAX(0, scale);
56b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
57b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  w00=WebRtcSpl_DotProductWithScale(current,current,ENH_BLOCKL,scale);
58b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  w11=WebRtcSpl_DotProductWithScale(surround,surround,ENH_BLOCKL,scale);
59b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  w10=WebRtcSpl_DotProductWithScale(surround,current,ENH_BLOCKL,scale);
60b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
61b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  if (w00<0) w00 = WEBRTC_SPL_WORD32_MAX;
62b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  if (w11<0) w11 = WEBRTC_SPL_WORD32_MAX;
63b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
64b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  /* Rescale w00 and w11 to w00prim and w11prim, so that w00prim/w11prim
65b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org     is in Q16 */
66b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
67b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  bitsw00 = WebRtcSpl_GetSizeInBits(w00);
68b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  bitsw11 = WebRtcSpl_GetSizeInBits(w11);
69b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  bitsw10 = WebRtcSpl_GetSizeInBits(WEBRTC_SPL_ABS_W32(w10));
70b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  scale1 = 31 - bitsw00;
71b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  scale2 = 15 - bitsw11;
72b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
73b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  if (scale2>(scale1-16)) {
74b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    scale2 = scale1 - 16;
75b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  } else {
76b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    scale1 = scale2 + 16;
77b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  }
78b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
79b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  w00prim = WEBRTC_SPL_LSHIFT_W32(w00, scale1);
80fbda0fcf2f9e82c82bcaac138f44d4e5144f6e0dpbos@webrtc.org  w11prim = (int16_t) WEBRTC_SPL_SHIFT_W32(w11, scale2);
81b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
82b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  /* Perform C = sqrt(w11/w00) (C is in Q11 since (16+6)/2=11) */
83b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  if (w11prim>64) {
84b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    endiff = WEBRTC_SPL_LSHIFT_W32(
85fbda0fcf2f9e82c82bcaac138f44d4e5144f6e0dpbos@webrtc.org        (int32_t)WebRtcSpl_DivW32W16(w00prim, w11prim), 6);
86fbda0fcf2f9e82c82bcaac138f44d4e5144f6e0dpbos@webrtc.org    C = (int16_t)WebRtcSpl_SqrtFloor(endiff); /* C is in Q11 */
87b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  } else {
88b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    C = 1;
89b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  }
90b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
91b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  /* first try enhancement without power-constraint */
92b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
93b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  errs = WebRtcIlbcfix_Smooth_odata(odata, current, surround, C);
94b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
95b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
96b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
97b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  /* if constraint violated by first try, add constraint */
98b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
99b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  if ( (6-scale+scale1) > 31) {
100b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    crit=0;
101b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  } else {
102b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    /* crit = 0.05 * w00 (Result in Q-6) */
103b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    crit = WEBRTC_SPL_SHIFT_W32(
104b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org        WEBRTC_SPL_MUL(ENH_A0, WEBRTC_SPL_RSHIFT_W32(w00prim, 14)),
105b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org        -(6-scale+scale1));
106b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  }
107b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
108b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  if (errs > crit) {
109b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
110b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    if( w00 < 1) {
111b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org      w00=1;
112b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    }
113b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
114b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    /* Calculate w11*w00, w10*w10 and w00*w00 in the same Q domain */
115b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
116b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    scale1 = bitsw00-15;
117b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    scale2 = bitsw11-15;
118b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
119b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    if (scale2>scale1) {
120b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org      scale = scale2;
121b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    } else {
122b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org      scale = scale1;
123b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    }
124b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
125b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    w11w00 = WEBRTC_SPL_MUL_16_16(
126fbda0fcf2f9e82c82bcaac138f44d4e5144f6e0dpbos@webrtc.org        (int16_t)WEBRTC_SPL_SHIFT_W32(w11, -scale),
127fbda0fcf2f9e82c82bcaac138f44d4e5144f6e0dpbos@webrtc.org        (int16_t)WEBRTC_SPL_SHIFT_W32(w00, -scale));
128b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
129b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    w10w10 = WEBRTC_SPL_MUL_16_16(
130fbda0fcf2f9e82c82bcaac138f44d4e5144f6e0dpbos@webrtc.org        (int16_t)WEBRTC_SPL_SHIFT_W32(w10, -scale),
131fbda0fcf2f9e82c82bcaac138f44d4e5144f6e0dpbos@webrtc.org        (int16_t)WEBRTC_SPL_SHIFT_W32(w10, -scale));
132b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
133b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    w00w00 = WEBRTC_SPL_MUL_16_16(
134fbda0fcf2f9e82c82bcaac138f44d4e5144f6e0dpbos@webrtc.org        (int16_t)WEBRTC_SPL_SHIFT_W32(w00, -scale),
135fbda0fcf2f9e82c82bcaac138f44d4e5144f6e0dpbos@webrtc.org        (int16_t)WEBRTC_SPL_SHIFT_W32(w00, -scale));
136b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
137b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    /* Calculate (w11*w00-w10*w10)/(w00*w00) in Q16 */
138b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    if (w00w00>65536) {
139b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org      endiff = (w11w00-w10w10);
140b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org      endiff = WEBRTC_SPL_MAX(0, endiff);
141b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org      /* denom is in Q16 */
142fbda0fcf2f9e82c82bcaac138f44d4e5144f6e0dpbos@webrtc.org      denom = WebRtcSpl_DivW32W16(endiff, (int16_t)WEBRTC_SPL_RSHIFT_W32(w00w00, 16));
143b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    } else {
144b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org      denom = 65536;
145b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    }
146b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
147b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    if( denom > 7){ /* eliminates numerical problems
148b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org                       for if smooth */
149b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
150b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org      scale=WebRtcSpl_GetSizeInBits(denom)-15;
151b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
152b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org      if (scale>0) {
153b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org        /* denomW16 is in Q(16+scale) */
154fbda0fcf2f9e82c82bcaac138f44d4e5144f6e0dpbos@webrtc.org        denomW16=(int16_t)WEBRTC_SPL_RSHIFT_W32(denom, scale);
155b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
156b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org        /* num in Q(34-scale) */
157b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org        num=WEBRTC_SPL_RSHIFT_W32(ENH_A0_MINUS_A0A0DIV4, scale);
158b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org      } else {
159b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org        /* denomW16 is in Q16 */
160fbda0fcf2f9e82c82bcaac138f44d4e5144f6e0dpbos@webrtc.org        denomW16=(int16_t)denom;
161b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
162b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org        /* num in Q34 */
163b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org        num=ENH_A0_MINUS_A0A0DIV4;
164b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org      }
165b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
166b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org      /* A sqrt( (ENH_A0-(ENH_A0^2)/4)*(w00*w00)/(w11*w00 + w10*w10) ) in Q9 */
167fbda0fcf2f9e82c82bcaac138f44d4e5144f6e0dpbos@webrtc.org      A = (int16_t)WebRtcSpl_SqrtFloor(WebRtcSpl_DivW32W16(num, denomW16));
168b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
169b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org      /* B_W32 is in Q30 ( B = 1 - ENH_A0/2 - A * w10/w00 ) */
170b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org      scale1 = 31-bitsw10;
171b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org      scale2 = 21-scale1;
172b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org      w10prim = WEBRTC_SPL_LSHIFT_W32(w10, scale1);
173b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org      w00prim = WEBRTC_SPL_SHIFT_W32(w00, -scale2);
174b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org      scale = bitsw00-scale2-15;
175b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
176b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org      if (scale>0) {
177b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org        w10prim=WEBRTC_SPL_RSHIFT_W32(w10prim, scale);
178b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org        w00prim=WEBRTC_SPL_RSHIFT_W32(w00prim, scale);
179b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org      }
180b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
181b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org      if ((w00prim>0)&&(w10prim>0)) {
182fbda0fcf2f9e82c82bcaac138f44d4e5144f6e0dpbos@webrtc.org        w11_div_w00=WebRtcSpl_DivW32W16(w10prim, (int16_t)w00prim);
183b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
184b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org        if (WebRtcSpl_GetSizeInBits(w11_div_w00)+WebRtcSpl_GetSizeInBits(A)>31) {
185b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org          B_W32 = 0;
186b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org        } else {
187fbda0fcf2f9e82c82bcaac138f44d4e5144f6e0dpbos@webrtc.org          B_W32 = (int32_t)1073741824 - (int32_t)ENH_A0DIV2 -
188b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org              WEBRTC_SPL_MUL(A, w11_div_w00);
189b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org        }
190fbda0fcf2f9e82c82bcaac138f44d4e5144f6e0dpbos@webrtc.org        B = (int16_t)WEBRTC_SPL_RSHIFT_W32(B_W32, 16); /* B in Q14 */
191b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org      } else {
192b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org        /* No smoothing */
193b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org        A = 0;
194b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org        B = 16384; /* 1 in Q14 */
195b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org      }
196b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    }
197b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    else{ /* essentially no difference between cycles;
198b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org             smoothing not needed */
199b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
200b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org      A = 0;
201b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org      B = 16384; /* 1 in Q14 */
202b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    }
203b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
204b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    /* create smoothed sequence */
205b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
206b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    WebRtcSpl_ScaleAndAddVectors(surround, A, 9,
207b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org                                current, B, 14,
208b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org                                odata, ENH_BLOCKL);
209b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  }
210b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  return;
211b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org}
212