Coverage Report

Created: 2026-01-17 07:45

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/opus/celt/celt_lpc.c
Line
Count
Source
1
/* Copyright (c) 2009-2010 Xiph.Org Foundation
2
   Written by Jean-Marc Valin */
3
/*
4
   Redistribution and use in source and binary forms, with or without
5
   modification, are permitted provided that the following conditions
6
   are met:
7
8
   - Redistributions of source code must retain the above copyright
9
   notice, this list of conditions and the following disclaimer.
10
11
   - Redistributions in binary form must reproduce the above copyright
12
   notice, this list of conditions and the following disclaimer in the
13
   documentation and/or other materials provided with the distribution.
14
15
   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16
   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17
   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18
   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
19
   OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20
   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21
   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22
   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23
   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24
   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
*/
27
28
#ifdef HAVE_CONFIG_H
29
#include "config.h"
30
#endif
31
32
#include "celt_lpc.h"
33
#include "stack_alloc.h"
34
#include "mathops.h"
35
#include "pitch.h"
36
37
void _celt_lpc(
38
      opus_val16       *_lpc, /* out: [0...p-1] LPC coefficients      */
39
const opus_val32 *ac,  /* in:  [0...p] autocorrelation values  */
40
int          p
41
)
42
6.03M
{
43
6.03M
   int i, j;
44
6.03M
   opus_val32 r;
45
6.03M
   opus_val32 error = ac[0];
46
#ifdef FIXED_POINT
47
   opus_val32 lpc[CELT_LPC_ORDER];
48
#else
49
   float *lpc = _lpc;
50
#endif
51
52
6.03M
   OPUS_CLEAR(lpc, p);
53
#ifdef FIXED_POINT
54
5.11M
   if (ac[0] != 0)
55
#else
56
916k
   if (ac[0] > 1e-10f)
57
912k
#endif
58
6.03M
   {
59
31.9M
      for (i = 0; i < p; i++) {
60
         /* Sum up this iteration's reflection coefficient */
61
25.9M
         opus_val32 rr = 0;
62
#if defined (FIXED_POINT) && OPUS_FAST_INT64
63
         opus_int64 acc = 0;
64
70.7M
         for (j = 0; j < i; j++)
65
48.9M
            acc += (opus_int64)(lpc[j]) * (opus_int64)(ac[i - j]);
66
21.8M
         rr = (opus_val32)SHR(acc, 31);
67
#else
68
17.4M
         for (j = 0; j < i; j++)
69
13.2M
            rr += MULT32_32_Q31(lpc[j],ac[i - j]);
70
#endif
71
25.9M
         rr += SHR32(ac[i + 1],6);
72
25.9M
         r = -frac_div32(SHL32(rr,6), error);
73
         /*  Update LPC coefficients and total error */
74
25.9M
         lpc[i] = SHR32(r,6);
75
63.5M
         for (j = 0; j < (i+1)>>1; j++)
76
37.5M
         {
77
37.5M
            opus_val32 tmp1, tmp2;
78
37.5M
            tmp1 = lpc[j];
79
37.5M
            tmp2 = lpc[i-1-j];
80
37.5M
            lpc[j]     = tmp1 + MULT32_32_Q31(r,tmp2);
81
37.5M
            lpc[i-1-j] = tmp2 + MULT32_32_Q31(r,tmp1);
82
37.5M
         }
83
84
25.9M
         error = error - MULT32_32_Q31(MULT32_32_Q31(r,r),error);
85
         /* Bail out once we get 30 dB gain */
86
#ifdef FIXED_POINT
87
21.8M
         if (error<=SHR32(ac[0],10))
88
27.9k
            break;
89
#else
90
4.19M
         if (error<=.001f*ac[0])
91
38.2k
            break;
92
#endif
93
25.9M
      }
94
6.03M
   }
95
#ifdef FIXED_POINT
96
   {
97
      /* Convert the int32 lpcs to int16 and ensure there are no wrap-arounds.
98
         This reuses the logic in silk_LPC_fit() and silk_bwexpander_32(). Any bug
99
         fixes should also be applied there. */
100
      int iter, idx = 0;
101
      opus_val32 maxabs, absval, chirp_Q16, chirp_minus_one_Q16;
102
103
5.11M
      for (iter = 0; iter < 10; iter++) {
104
5.11M
         maxabs = 0;
105
27.4M
         for (i = 0; i < p; i++) {
106
22.3M
            absval = ABS32(lpc[i]);
107
22.3M
            if (absval > maxabs) {
108
7.70M
               maxabs = absval;
109
7.70M
               idx = i;
110
7.70M
            }
111
22.3M
         }
112
5.11M
         maxabs = PSHR32(maxabs, 13);  /* Q25->Q12 */
113
114
5.11M
         if (maxabs > 32767) {
115
0
            maxabs = MIN32(maxabs, 163838);
116
0
            chirp_Q16 = QCONST32(0.999, 16) - DIV32(SHL32(maxabs - 32767, 14),
117
0
                                                    SHR32(MULT32_32_32(maxabs, idx + 1), 2));
118
0
            chirp_minus_one_Q16 = chirp_Q16 - 65536;
119
120
            /* Apply bandwidth expansion. */
121
0
            for (i = 0; i < p - 1; i++) {
122
0
               lpc[i] = MULT32_32_Q16(chirp_Q16, lpc[i]);
123
0
               chirp_Q16 += PSHR32(MULT32_32_32(chirp_Q16, chirp_minus_one_Q16), 16);
124
0
            }
125
0
            lpc[p - 1] = MULT32_32_Q16(chirp_Q16, lpc[p - 1]);
126
5.11M
         } else {
127
5.11M
            break;
128
5.11M
         }
129
5.11M
      }
130
131
5.11M
      if (iter == 10) {
132
         /* If the coeffs still do not fit into the 16 bit range after 10 iterations,
133
            fall back to the A(z)=1 filter. */
134
0
         OPUS_CLEAR(lpc, p);
135
0
         _lpc[0] = 4096;  /* Q12 */
136
5.11M
      } else {
137
27.4M
         for (i = 0; i < p; i++) {
138
22.3M
            _lpc[i] = EXTRACT16(PSHR32(lpc[i], 13));  /* Q25->Q12 */
139
22.3M
         }
140
5.11M
      }
141
   }
142
#endif
143
6.03M
}
_celt_lpc
Line
Count
Source
42
5.11M
{
43
5.11M
   int i, j;
44
5.11M
   opus_val32 r;
45
5.11M
   opus_val32 error = ac[0];
46
5.11M
#ifdef FIXED_POINT
47
5.11M
   opus_val32 lpc[CELT_LPC_ORDER];
48
#else
49
   float *lpc = _lpc;
50
#endif
51
52
5.11M
   OPUS_CLEAR(lpc, p);
53
5.11M
#ifdef FIXED_POINT
54
5.11M
   if (ac[0] != 0)
55
#else
56
   if (ac[0] > 1e-10f)
57
#endif
58
5.11M
   {
59
26.8M
      for (i = 0; i < p; i++) {
60
         /* Sum up this iteration's reflection coefficient */
61
21.8M
         opus_val32 rr = 0;
62
21.8M
#if defined (FIXED_POINT) && OPUS_FAST_INT64
63
21.8M
         opus_int64 acc = 0;
64
70.7M
         for (j = 0; j < i; j++)
65
48.9M
            acc += (opus_int64)(lpc[j]) * (opus_int64)(ac[i - j]);
66
21.8M
         rr = (opus_val32)SHR(acc, 31);
67
#else
68
         for (j = 0; j < i; j++)
69
            rr += MULT32_32_Q31(lpc[j],ac[i - j]);
70
#endif
71
21.8M
         rr += SHR32(ac[i + 1],6);
72
21.8M
         r = -frac_div32(SHL32(rr,6), error);
73
         /*  Update LPC coefficients and total error */
74
21.8M
         lpc[i] = SHR32(r,6);
75
51.7M
         for (j = 0; j < (i+1)>>1; j++)
76
29.9M
         {
77
29.9M
            opus_val32 tmp1, tmp2;
78
29.9M
            tmp1 = lpc[j];
79
29.9M
            tmp2 = lpc[i-1-j];
80
29.9M
            lpc[j]     = tmp1 + MULT32_32_Q31(r,tmp2);
81
29.9M
            lpc[i-1-j] = tmp2 + MULT32_32_Q31(r,tmp1);
82
29.9M
         }
83
84
21.8M
         error = error - MULT32_32_Q31(MULT32_32_Q31(r,r),error);
85
         /* Bail out once we get 30 dB gain */
86
21.8M
#ifdef FIXED_POINT
87
21.8M
         if (error<=SHR32(ac[0],10))
88
27.9k
            break;
89
#else
90
         if (error<=.001f*ac[0])
91
            break;
92
#endif
93
21.8M
      }
94
5.11M
   }
95
5.11M
#ifdef FIXED_POINT
96
5.11M
   {
97
      /* Convert the int32 lpcs to int16 and ensure there are no wrap-arounds.
98
         This reuses the logic in silk_LPC_fit() and silk_bwexpander_32(). Any bug
99
         fixes should also be applied there. */
100
5.11M
      int iter, idx = 0;
101
5.11M
      opus_val32 maxabs, absval, chirp_Q16, chirp_minus_one_Q16;
102
103
5.11M
      for (iter = 0; iter < 10; iter++) {
104
5.11M
         maxabs = 0;
105
27.4M
         for (i = 0; i < p; i++) {
106
22.3M
            absval = ABS32(lpc[i]);
107
22.3M
            if (absval > maxabs) {
108
7.70M
               maxabs = absval;
109
7.70M
               idx = i;
110
7.70M
            }
111
22.3M
         }
112
5.11M
         maxabs = PSHR32(maxabs, 13);  /* Q25->Q12 */
113
114
5.11M
         if (maxabs > 32767) {
115
0
            maxabs = MIN32(maxabs, 163838);
116
0
            chirp_Q16 = QCONST32(0.999, 16) - DIV32(SHL32(maxabs - 32767, 14),
117
0
                                                    SHR32(MULT32_32_32(maxabs, idx + 1), 2));
118
0
            chirp_minus_one_Q16 = chirp_Q16 - 65536;
119
120
            /* Apply bandwidth expansion. */
121
0
            for (i = 0; i < p - 1; i++) {
122
0
               lpc[i] = MULT32_32_Q16(chirp_Q16, lpc[i]);
123
0
               chirp_Q16 += PSHR32(MULT32_32_32(chirp_Q16, chirp_minus_one_Q16), 16);
124
0
            }
125
0
            lpc[p - 1] = MULT32_32_Q16(chirp_Q16, lpc[p - 1]);
126
5.11M
         } else {
127
5.11M
            break;
128
5.11M
         }
129
5.11M
      }
130
131
5.11M
      if (iter == 10) {
132
         /* If the coeffs still do not fit into the 16 bit range after 10 iterations,
133
            fall back to the A(z)=1 filter. */
134
0
         OPUS_CLEAR(lpc, p);
135
0
         _lpc[0] = 4096;  /* Q12 */
136
5.11M
      } else {
137
27.4M
         for (i = 0; i < p; i++) {
138
22.3M
            _lpc[i] = EXTRACT16(PSHR32(lpc[i], 13));  /* Q25->Q12 */
139
22.3M
         }
140
5.11M
      }
141
5.11M
   }
142
5.11M
#endif
143
5.11M
}
_celt_lpc
Line
Count
Source
42
916k
{
43
916k
   int i, j;
44
916k
   opus_val32 r;
45
916k
   opus_val32 error = ac[0];
46
#ifdef FIXED_POINT
47
   opus_val32 lpc[CELT_LPC_ORDER];
48
#else
49
916k
   float *lpc = _lpc;
50
916k
#endif
51
52
916k
   OPUS_CLEAR(lpc, p);
53
#ifdef FIXED_POINT
54
   if (ac[0] != 0)
55
#else
56
916k
   if (ac[0] > 1e-10f)
57
912k
#endif
58
912k
   {
59
5.06M
      for (i = 0; i < p; i++) {
60
         /* Sum up this iteration's reflection coefficient */
61
4.19M
         opus_val32 rr = 0;
62
#if defined (FIXED_POINT) && OPUS_FAST_INT64
63
         opus_int64 acc = 0;
64
         for (j = 0; j < i; j++)
65
            acc += (opus_int64)(lpc[j]) * (opus_int64)(ac[i - j]);
66
         rr = (opus_val32)SHR(acc, 31);
67
#else
68
17.4M
         for (j = 0; j < i; j++)
69
13.2M
            rr += MULT32_32_Q31(lpc[j],ac[i - j]);
70
4.19M
#endif
71
4.19M
         rr += SHR32(ac[i + 1],6);
72
4.19M
         r = -frac_div32(SHL32(rr,6), error);
73
         /*  Update LPC coefficients and total error */
74
4.19M
         lpc[i] = SHR32(r,6);
75
11.8M
         for (j = 0; j < (i+1)>>1; j++)
76
7.66M
         {
77
7.66M
            opus_val32 tmp1, tmp2;
78
7.66M
            tmp1 = lpc[j];
79
7.66M
            tmp2 = lpc[i-1-j];
80
7.66M
            lpc[j]     = tmp1 + MULT32_32_Q31(r,tmp2);
81
7.66M
            lpc[i-1-j] = tmp2 + MULT32_32_Q31(r,tmp1);
82
7.66M
         }
83
84
4.19M
         error = error - MULT32_32_Q31(MULT32_32_Q31(r,r),error);
85
         /* Bail out once we get 30 dB gain */
86
#ifdef FIXED_POINT
87
         if (error<=SHR32(ac[0],10))
88
            break;
89
#else
90
4.19M
         if (error<=.001f*ac[0])
91
38.2k
            break;
92
4.19M
#endif
93
4.19M
      }
94
912k
   }
95
#ifdef FIXED_POINT
96
   {
97
      /* Convert the int32 lpcs to int16 and ensure there are no wrap-arounds.
98
         This reuses the logic in silk_LPC_fit() and silk_bwexpander_32(). Any bug
99
         fixes should also be applied there. */
100
      int iter, idx = 0;
101
      opus_val32 maxabs, absval, chirp_Q16, chirp_minus_one_Q16;
102
103
      for (iter = 0; iter < 10; iter++) {
104
         maxabs = 0;
105
         for (i = 0; i < p; i++) {
106
            absval = ABS32(lpc[i]);
107
            if (absval > maxabs) {
108
               maxabs = absval;
109
               idx = i;
110
            }
111
         }
112
         maxabs = PSHR32(maxabs, 13);  /* Q25->Q12 */
113
114
         if (maxabs > 32767) {
115
            maxabs = MIN32(maxabs, 163838);
116
            chirp_Q16 = QCONST32(0.999, 16) - DIV32(SHL32(maxabs - 32767, 14),
117
                                                    SHR32(MULT32_32_32(maxabs, idx + 1), 2));
118
            chirp_minus_one_Q16 = chirp_Q16 - 65536;
119
120
            /* Apply bandwidth expansion. */
121
            for (i = 0; i < p - 1; i++) {
122
               lpc[i] = MULT32_32_Q16(chirp_Q16, lpc[i]);
123
               chirp_Q16 += PSHR32(MULT32_32_32(chirp_Q16, chirp_minus_one_Q16), 16);
124
            }
125
            lpc[p - 1] = MULT32_32_Q16(chirp_Q16, lpc[p - 1]);
126
         } else {
127
            break;
128
         }
129
      }
130
131
      if (iter == 10) {
132
         /* If the coeffs still do not fit into the 16 bit range after 10 iterations,
133
            fall back to the A(z)=1 filter. */
134
         OPUS_CLEAR(lpc, p);
135
         _lpc[0] = 4096;  /* Q12 */
136
      } else {
137
         for (i = 0; i < p; i++) {
138
            _lpc[i] = EXTRACT16(PSHR32(lpc[i], 13));  /* Q25->Q12 */
139
         }
140
      }
141
   }
142
#endif
143
916k
}
144
145
146
void celt_fir_c(
147
         const opus_val16 *x,
148
         const opus_val16 *num,
149
         opus_val16 *y,
150
         int N,
151
         int ord,
152
         int arch)
153
114k
{
154
114k
   int i,j;
155
114k
   VARDECL(opus_val16, rnum);
156
114k
   SAVE_STACK;
157
114k
   celt_assert(x != y);
158
114k
   ALLOC(rnum, ord, opus_val16);
159
2.86M
   for(i=0;i<ord;i++)
160
2.74M
      rnum[i] = num[ord-i-1];
161
15.7M
   for (i=0;i<N-3;i+=4)
162
15.6M
   {
163
15.6M
      opus_val32 sum[4];
164
15.6M
      sum[0] = SHL32(EXTEND32(x[i  ]), SIG_SHIFT);
165
15.6M
      sum[1] = SHL32(EXTEND32(x[i+1]), SIG_SHIFT);
166
15.6M
      sum[2] = SHL32(EXTEND32(x[i+2]), SIG_SHIFT);
167
15.6M
      sum[3] = SHL32(EXTEND32(x[i+3]), SIG_SHIFT);
168
#if defined(OPUS_CHECK_ASM) && defined(FIXED_POINT)
169
      {
170
         opus_val32 sum_c[4];
171
         memcpy(sum_c, sum, sizeof(sum_c));
172
         xcorr_kernel_c(rnum, x+i-ord, sum_c, ord);
173
#endif
174
15.6M
         xcorr_kernel(rnum, x+i-ord, sum, ord, arch);
175
#if defined(OPUS_CHECK_ASM) && defined(FIXED_POINT)
176
0
         celt_assert(memcmp(sum, sum_c, sizeof(sum)) == 0);
177
0
      }
178
0
#endif
179
15.6M
      y[i  ] = SROUND16(sum[0], SIG_SHIFT);
180
15.6M
      y[i+1] = SROUND16(sum[1], SIG_SHIFT);
181
15.6M
      y[i+2] = SROUND16(sum[2], SIG_SHIFT);
182
15.6M
      y[i+3] = SROUND16(sum[3], SIG_SHIFT);
183
0
   }
184
162k
   for (;i<N;i++)
185
47.7k
   {
186
47.7k
      opus_val32 sum = SHL32(EXTEND32(x[i]), SIG_SHIFT);
187
1.19M
      for (j=0;j<ord;j++)
188
1.14M
         sum = MAC16_16(sum,rnum[j],x[i+j-ord]);
189
47.7k
      y[i] = SROUND16(sum, SIG_SHIFT);
190
47.7k
   }
191
0
   RESTORE_STACK;
192
0
}
Unexecuted instantiation: celt_fir_c
celt_fir_c
Line
Count
Source
153
114k
{
154
114k
   int i,j;
155
114k
   VARDECL(opus_val16, rnum);
156
114k
   SAVE_STACK;
157
114k
   celt_assert(x != y);
158
114k
   ALLOC(rnum, ord, opus_val16);
159
2.86M
   for(i=0;i<ord;i++)
160
2.74M
      rnum[i] = num[ord-i-1];
161
15.7M
   for (i=0;i<N-3;i+=4)
162
15.6M
   {
163
15.6M
      opus_val32 sum[4];
164
15.6M
      sum[0] = SHL32(EXTEND32(x[i  ]), SIG_SHIFT);
165
15.6M
      sum[1] = SHL32(EXTEND32(x[i+1]), SIG_SHIFT);
166
15.6M
      sum[2] = SHL32(EXTEND32(x[i+2]), SIG_SHIFT);
167
15.6M
      sum[3] = SHL32(EXTEND32(x[i+3]), SIG_SHIFT);
168
#if defined(OPUS_CHECK_ASM) && defined(FIXED_POINT)
169
      {
170
         opus_val32 sum_c[4];
171
         memcpy(sum_c, sum, sizeof(sum_c));
172
         xcorr_kernel_c(rnum, x+i-ord, sum_c, ord);
173
#endif
174
15.6M
         xcorr_kernel(rnum, x+i-ord, sum, ord, arch);
175
#if defined(OPUS_CHECK_ASM) && defined(FIXED_POINT)
176
         celt_assert(memcmp(sum, sum_c, sizeof(sum)) == 0);
177
      }
178
#endif
179
15.6M
      y[i  ] = SROUND16(sum[0], SIG_SHIFT);
180
15.6M
      y[i+1] = SROUND16(sum[1], SIG_SHIFT);
181
15.6M
      y[i+2] = SROUND16(sum[2], SIG_SHIFT);
182
15.6M
      y[i+3] = SROUND16(sum[3], SIG_SHIFT);
183
15.6M
   }
184
162k
   for (;i<N;i++)
185
47.7k
   {
186
47.7k
      opus_val32 sum = SHL32(EXTEND32(x[i]), SIG_SHIFT);
187
1.19M
      for (j=0;j<ord;j++)
188
1.14M
         sum = MAC16_16(sum,rnum[j],x[i+j-ord]);
189
47.7k
      y[i] = SROUND16(sum, SIG_SHIFT);
190
47.7k
   }
191
114k
   RESTORE_STACK;
192
114k
}
193
194
void celt_iir(const opus_val32 *_x,
195
         const opus_val16 *den,
196
         opus_val32 *_y,
197
         int N,
198
         int ord,
199
         opus_val16 *mem,
200
         int arch)
201
273k
{
202
#ifdef SMALL_FOOTPRINT
203
   int i,j;
204
   (void)arch;
205
   for (i=0;i<N;i++)
206
   {
207
      opus_val32 sum = _x[i];
208
      for (j=0;j<ord;j++)
209
      {
210
         sum -= MULT16_16(den[j],mem[j]);
211
      }
212
      for (j=ord-1;j>=1;j--)
213
      {
214
         mem[j]=mem[j-1];
215
      }
216
      mem[0] = SROUND16(sum, SIG_SHIFT);
217
      _y[i] = sum;
218
   }
219
#else
220
273k
   int i,j;
221
273k
   VARDECL(opus_val16, rden);
222
273k
   VARDECL(opus_val16, y);
223
273k
   SAVE_STACK;
224
225
273k
   celt_assert((ord&3)==0);
226
273k
   ALLOC(rden, ord, opus_val16);
227
273k
   ALLOC(y, N+ord, opus_val16);
228
6.83M
   for(i=0;i<ord;i++)
229
6.56M
      rden[i] = den[ord-i-1];
230
6.83M
   for(i=0;i<ord;i++)
231
6.56M
      y[i] = -mem[ord-i-1];
232
98.3M
   for(;i<N+ord;i++)
233
98.0M
      y[i]=0;
234
24.7M
   for (i=0;i<N-3;i+=4)
235
24.5M
   {
236
      /* Unroll by 4 as if it were an FIR filter */
237
24.5M
      opus_val32 sum[4];
238
24.5M
      sum[0]=_x[i];
239
24.5M
      sum[1]=_x[i+1];
240
24.5M
      sum[2]=_x[i+2];
241
24.5M
      sum[3]=_x[i+3];
242
#if defined(OPUS_CHECK_ASM) && defined(FIXED_POINT)
243
      {
244
         opus_val32 sum_c[4];
245
         memcpy(sum_c, sum, sizeof(sum_c));
246
         xcorr_kernel_c(rden, y+i, sum_c, ord);
247
#endif
248
24.5M
         xcorr_kernel(rden, y+i, sum, ord, arch);
249
#if defined(OPUS_CHECK_ASM) && defined(FIXED_POINT)
250
13.6M
         celt_assert(memcmp(sum, sum_c, sizeof(sum)) == 0);
251
13.6M
      }
252
0
#endif
253
      /* Patch up the result to compensate for the fact that this is an IIR */
254
24.5M
      y[i+ord  ] = -SROUND16(sum[0],SIG_SHIFT);
255
13.6M
      _y[i  ] = sum[0];
256
24.5M
      sum[1] = MAC16_16(sum[1], y[i+ord  ], den[0]);
257
24.5M
      y[i+ord+1] = -SROUND16(sum[1],SIG_SHIFT);
258
13.6M
      _y[i+1] = sum[1];
259
24.5M
      sum[2] = MAC16_16(sum[2], y[i+ord+1], den[0]);
260
24.5M
      sum[2] = MAC16_16(sum[2], y[i+ord  ], den[1]);
261
24.5M
      y[i+ord+2] = -SROUND16(sum[2],SIG_SHIFT);
262
13.6M
      _y[i+2] = sum[2];
263
264
24.5M
      sum[3] = MAC16_16(sum[3], y[i+ord+2], den[0]);
265
24.5M
      sum[3] = MAC16_16(sum[3], y[i+ord+1], den[1]);
266
24.5M
      sum[3] = MAC16_16(sum[3], y[i+ord  ], den[2]);
267
24.5M
      y[i+ord+3] = -SROUND16(sum[3],SIG_SHIFT);
268
13.6M
      _y[i+3] = sum[3];
269
13.6M
   }
270
273k
   for (;i<N;i++)
271
0
   {
272
0
      opus_val32 sum = _x[i];
273
0
      for (j=0;j<ord;j++)
274
0
         sum -= MULT16_16(rden[j],y[i+j]);
275
0
      y[i+ord] = SROUND16(sum,SIG_SHIFT);
276
0
      _y[i] = sum;
277
0
   }
278
6.83M
   for(i=0;i<ord;i++)
279
6.56M
      mem[i] = _y[N-i-1];
280
158k
   RESTORE_STACK;
281
158k
#endif
282
158k
}
celt_iir
Line
Count
Source
201
158k
{
202
#ifdef SMALL_FOOTPRINT
203
   int i,j;
204
   (void)arch;
205
   for (i=0;i<N;i++)
206
   {
207
      opus_val32 sum = _x[i];
208
      for (j=0;j<ord;j++)
209
      {
210
         sum -= MULT16_16(den[j],mem[j]);
211
      }
212
      for (j=ord-1;j>=1;j--)
213
      {
214
         mem[j]=mem[j-1];
215
      }
216
      mem[0] = SROUND16(sum, SIG_SHIFT);
217
      _y[i] = sum;
218
   }
219
#else
220
158k
   int i,j;
221
158k
   VARDECL(opus_val16, rden);
222
158k
   VARDECL(opus_val16, y);
223
158k
   SAVE_STACK;
224
225
158k
   celt_assert((ord&3)==0);
226
158k
   ALLOC(rden, ord, opus_val16);
227
158k
   ALLOC(y, N+ord, opus_val16);
228
3.97M
   for(i=0;i<ord;i++)
229
3.81M
      rden[i] = den[ord-i-1];
230
3.97M
   for(i=0;i<ord;i++)
231
3.81M
      y[i] = -mem[ord-i-1];
232
54.8M
   for(;i<N+ord;i++)
233
54.6M
      y[i]=0;
234
13.8M
   for (i=0;i<N-3;i+=4)
235
13.6M
   {
236
      /* Unroll by 4 as if it were an FIR filter */
237
13.6M
      opus_val32 sum[4];
238
13.6M
      sum[0]=_x[i];
239
13.6M
      sum[1]=_x[i+1];
240
13.6M
      sum[2]=_x[i+2];
241
13.6M
      sum[3]=_x[i+3];
242
13.6M
#if defined(OPUS_CHECK_ASM) && defined(FIXED_POINT)
243
13.6M
      {
244
13.6M
         opus_val32 sum_c[4];
245
13.6M
         memcpy(sum_c, sum, sizeof(sum_c));
246
13.6M
         xcorr_kernel_c(rden, y+i, sum_c, ord);
247
13.6M
#endif
248
13.6M
         xcorr_kernel(rden, y+i, sum, ord, arch);
249
13.6M
#if defined(OPUS_CHECK_ASM) && defined(FIXED_POINT)
250
13.6M
         celt_assert(memcmp(sum, sum_c, sizeof(sum)) == 0);
251
13.6M
      }
252
0
#endif
253
      /* Patch up the result to compensate for the fact that this is an IIR */
254
13.6M
      y[i+ord  ] = -SROUND16(sum[0],SIG_SHIFT);
255
13.6M
      _y[i  ] = sum[0];
256
13.6M
      sum[1] = MAC16_16(sum[1], y[i+ord  ], den[0]);
257
13.6M
      y[i+ord+1] = -SROUND16(sum[1],SIG_SHIFT);
258
13.6M
      _y[i+1] = sum[1];
259
13.6M
      sum[2] = MAC16_16(sum[2], y[i+ord+1], den[0]);
260
13.6M
      sum[2] = MAC16_16(sum[2], y[i+ord  ], den[1]);
261
13.6M
      y[i+ord+2] = -SROUND16(sum[2],SIG_SHIFT);
262
13.6M
      _y[i+2] = sum[2];
263
264
13.6M
      sum[3] = MAC16_16(sum[3], y[i+ord+2], den[0]);
265
13.6M
      sum[3] = MAC16_16(sum[3], y[i+ord+1], den[1]);
266
13.6M
      sum[3] = MAC16_16(sum[3], y[i+ord  ], den[2]);
267
13.6M
      y[i+ord+3] = -SROUND16(sum[3],SIG_SHIFT);
268
13.6M
      _y[i+3] = sum[3];
269
13.6M
   }
270
158k
   for (;i<N;i++)
271
0
   {
272
0
      opus_val32 sum = _x[i];
273
0
      for (j=0;j<ord;j++)
274
0
         sum -= MULT16_16(rden[j],y[i+j]);
275
0
      y[i+ord] = SROUND16(sum,SIG_SHIFT);
276
0
      _y[i] = sum;
277
0
   }
278
3.97M
   for(i=0;i<ord;i++)
279
3.81M
      mem[i] = _y[N-i-1];
280
158k
   RESTORE_STACK;
281
158k
#endif
282
158k
}
celt_iir
Line
Count
Source
201
114k
{
202
#ifdef SMALL_FOOTPRINT
203
   int i,j;
204
   (void)arch;
205
   for (i=0;i<N;i++)
206
   {
207
      opus_val32 sum = _x[i];
208
      for (j=0;j<ord;j++)
209
      {
210
         sum -= MULT16_16(den[j],mem[j]);
211
      }
212
      for (j=ord-1;j>=1;j--)
213
      {
214
         mem[j]=mem[j-1];
215
      }
216
      mem[0] = SROUND16(sum, SIG_SHIFT);
217
      _y[i] = sum;
218
   }
219
#else
220
114k
   int i,j;
221
114k
   VARDECL(opus_val16, rden);
222
114k
   VARDECL(opus_val16, y);
223
114k
   SAVE_STACK;
224
225
114k
   celt_assert((ord&3)==0);
226
114k
   ALLOC(rden, ord, opus_val16);
227
114k
   ALLOC(y, N+ord, opus_val16);
228
2.86M
   for(i=0;i<ord;i++)
229
2.74M
      rden[i] = den[ord-i-1];
230
2.86M
   for(i=0;i<ord;i++)
231
2.74M
      y[i] = -mem[ord-i-1];
232
43.4M
   for(;i<N+ord;i++)
233
43.3M
      y[i]=0;
234
10.9M
   for (i=0;i<N-3;i+=4)
235
10.8M
   {
236
      /* Unroll by 4 as if it were an FIR filter */
237
10.8M
      opus_val32 sum[4];
238
10.8M
      sum[0]=_x[i];
239
10.8M
      sum[1]=_x[i+1];
240
10.8M
      sum[2]=_x[i+2];
241
10.8M
      sum[3]=_x[i+3];
242
#if defined(OPUS_CHECK_ASM) && defined(FIXED_POINT)
243
      {
244
         opus_val32 sum_c[4];
245
         memcpy(sum_c, sum, sizeof(sum_c));
246
         xcorr_kernel_c(rden, y+i, sum_c, ord);
247
#endif
248
10.8M
         xcorr_kernel(rden, y+i, sum, ord, arch);
249
#if defined(OPUS_CHECK_ASM) && defined(FIXED_POINT)
250
         celt_assert(memcmp(sum, sum_c, sizeof(sum)) == 0);
251
      }
252
#endif
253
      /* Patch up the result to compensate for the fact that this is an IIR */
254
10.8M
      y[i+ord  ] = -SROUND16(sum[0],SIG_SHIFT);
255
10.8M
      _y[i  ] = sum[0];
256
10.8M
      sum[1] = MAC16_16(sum[1], y[i+ord  ], den[0]);
257
10.8M
      y[i+ord+1] = -SROUND16(sum[1],SIG_SHIFT);
258
10.8M
      _y[i+1] = sum[1];
259
10.8M
      sum[2] = MAC16_16(sum[2], y[i+ord+1], den[0]);
260
10.8M
      sum[2] = MAC16_16(sum[2], y[i+ord  ], den[1]);
261
10.8M
      y[i+ord+2] = -SROUND16(sum[2],SIG_SHIFT);
262
10.8M
      _y[i+2] = sum[2];
263
264
10.8M
      sum[3] = MAC16_16(sum[3], y[i+ord+2], den[0]);
265
10.8M
      sum[3] = MAC16_16(sum[3], y[i+ord+1], den[1]);
266
10.8M
      sum[3] = MAC16_16(sum[3], y[i+ord  ], den[2]);
267
10.8M
      y[i+ord+3] = -SROUND16(sum[3],SIG_SHIFT);
268
10.8M
      _y[i+3] = sum[3];
269
10.8M
   }
270
114k
   for (;i<N;i++)
271
0
   {
272
0
      opus_val32 sum = _x[i];
273
0
      for (j=0;j<ord;j++)
274
0
         sum -= MULT16_16(rden[j],y[i+j]);
275
0
      y[i+ord] = SROUND16(sum,SIG_SHIFT);
276
0
      _y[i] = sum;
277
0
   }
278
2.86M
   for(i=0;i<ord;i++)
279
2.74M
      mem[i] = _y[N-i-1];
280
114k
   RESTORE_STACK;
281
114k
#endif
282
114k
}
283
284
int _celt_autocorr(
285
                   const opus_val16 *x,   /*  in: [0...n-1] samples x   */
286
                   opus_val32       *ac,  /* out: [0...lag-1] ac values */
287
                   const celt_coef  *window,
288
                   int          overlap,
289
                   int          lag,
290
                   int          n,
291
                   int          arch
292
                  )
293
170M
{
294
170M
   opus_val32 d;
295
170M
   int i, k;
296
170M
   int fastN=n-lag;
297
170M
   int shift;
298
170M
   const opus_val16 *xptr;
299
170M
   VARDECL(opus_val16, xx);
300
170M
   SAVE_STACK;
301
170M
   ALLOC(xx, n, opus_val16);
302
170M
   celt_assert(n>0);
303
170M
   celt_assert(overlap>=0);
304
170M
   if (overlap == 0)
305
169M
   {
306
169M
      xptr = x;
307
169M
   } else {
308
283M
      for (i=0;i<n;i++)
309
283M
         xx[i] = x[i];
310
33.5M
      for (i=0;i<overlap;i++)
311
33.2M
      {
312
33.2M
         opus_val16 w = COEF2VAL16(window[i]);
313
33.2M
         xx[i] = MULT16_16_Q15(x[i],w);
314
33.2M
         xx[n-i-1] = MULT16_16_Q15(x[n-i-1],w);
315
33.2M
      }
316
249k
      xptr = xx;
317
249k
   }
318
170M
   shift=0;
319
#ifdef FIXED_POINT
320
   {
321
      opus_val32 ac0;
322
      int ac0_shift = celt_ilog2(n + (n>>4));
323
      ac0 = 1+(n<<7);
324
169M
      if (n&1) ac0 += SHR32(MULT16_16(xptr[0],xptr[0]),ac0_shift);
325
17.3G
      for(i=(n&1);i<n;i+=2)
326
17.2G
      {
327
17.2G
         ac0 += SHR32(MULT16_16(xptr[i],xptr[i]),ac0_shift);
328
17.2G
         ac0 += SHR32(MULT16_16(xptr[i+1],xptr[i+1]),ac0_shift);
329
17.2G
      }
330
      /* Consider the effect of rounding-to-nearest when scaling the signal. */
331
169M
      ac0 += SHR32(ac0,7);
332
333
      shift = celt_ilog2(ac0)-30+ac0_shift+1;
334
      shift = (shift)/2;
335
169M
      if (shift>0)
336
3.71M
      {
337
758M
         for(i=0;i<n;i++)
338
754M
            xx[i] = PSHR32(xptr[i], shift);
339
3.71M
         xptr = xx;
340
3.71M
      } else
341
165M
         shift = 0;
342
   }
343
#endif
344
170M
   celt_pitch_xcorr(xptr, xptr, ac, fastN, lag+1, arch);
345
2.14G
   for (k=0;k<=lag;k++)
346
1.97G
   {
347
13.2G
      for (i = k+fastN, d = 0; i < n; i++)
348
11.2G
         d = MAC16_16(d, xptr[i], xptr[i-k]);
349
1.97G
      ac[k] += d;
350
1.97G
   }
351
#ifdef FIXED_POINT
352
   shift = 2*shift;
353
169M
   if (shift<=0)
354
165M
      ac[0] += SHL32((opus_int32)1, -shift);
355
169M
   if (ac[0] < 268435456)
356
164M
   {
357
164M
      int shift2 = 29 - EC_ILOG(ac[0]);
358
2.07G
      for (i=0;i<=lag;i++)
359
1.91G
         ac[i] = SHL32(ac[i], shift2);
360
164M
      shift -= shift2;
361
164M
   } else if (ac[0] >= 536870912)
362
4.43M
   {
363
4.43M
      int shift2=1;
364
4.43M
      if (ac[0] >= 1073741824)
365
2.00M
         shift2++;
366
56.0M
      for (i=0;i<=lag;i++)
367
51.6M
         ac[i] = SHR32(ac[i], shift2);
368
4.43M
      shift += shift2;
369
4.43M
   }
370
#endif
371
372
170M
   RESTORE_STACK;
373
170M
   return shift;
374
170M
}
_celt_autocorr
Line
Count
Source
293
84.6M
{
294
84.6M
   opus_val32 d;
295
84.6M
   int i, k;
296
84.6M
   int fastN=n-lag;
297
84.6M
   int shift;
298
84.6M
   const opus_val16 *xptr;
299
84.6M
   VARDECL(opus_val16, xx);
300
84.6M
   SAVE_STACK;
301
84.6M
   ALLOC(xx, n, opus_val16);
302
84.6M
   celt_assert(n>0);
303
84.6M
   celt_assert(overlap>=0);
304
84.6M
   if (overlap == 0)
305
84.5M
   {
306
84.5M
      xptr = x;
307
84.5M
   } else {
308
103M
      for (i=0;i<n;i++)
309
103M
         xx[i] = x[i];
310
12.1M
      for (i=0;i<overlap;i++)
311
12.1M
      {
312
12.1M
         opus_val16 w = COEF2VAL16(window[i]);
313
12.1M
         xx[i] = MULT16_16_Q15(x[i],w);
314
12.1M
         xx[n-i-1] = MULT16_16_Q15(x[n-i-1],w);
315
12.1M
      }
316
91.5k
      xptr = xx;
317
91.5k
   }
318
84.6M
   shift=0;
319
84.6M
#ifdef FIXED_POINT
320
84.6M
   {
321
84.6M
      opus_val32 ac0;
322
84.6M
      int ac0_shift = celt_ilog2(n + (n>>4));
323
84.6M
      ac0 = 1+(n<<7);
324
84.6M
      if (n&1) ac0 += SHR32(MULT16_16(xptr[0],xptr[0]),ac0_shift);
325
8.68G
      for(i=(n&1);i<n;i+=2)
326
8.60G
      {
327
8.60G
         ac0 += SHR32(MULT16_16(xptr[i],xptr[i]),ac0_shift);
328
8.60G
         ac0 += SHR32(MULT16_16(xptr[i+1],xptr[i+1]),ac0_shift);
329
8.60G
      }
330
      /* Consider the effect of rounding-to-nearest when scaling the signal. */
331
84.6M
      ac0 += SHR32(ac0,7);
332
333
84.6M
      shift = celt_ilog2(ac0)-30+ac0_shift+1;
334
84.6M
      shift = (shift)/2;
335
84.6M
      if (shift>0)
336
1.85M
      {
337
379M
         for(i=0;i<n;i++)
338
377M
            xx[i] = PSHR32(xptr[i], shift);
339
1.85M
         xptr = xx;
340
1.85M
      } else
341
82.7M
         shift = 0;
342
84.6M
   }
343
84.6M
#endif
344
84.6M
   celt_pitch_xcorr(xptr, xptr, ac, fastN, lag+1, arch);
345
1.06G
   for (k=0;k<=lag;k++)
346
982M
   {
347
6.58G
      for (i = k+fastN, d = 0; i < n; i++)
348
5.60G
         d = MAC16_16(d, xptr[i], xptr[i-k]);
349
982M
      ac[k] += d;
350
982M
   }
351
84.6M
#ifdef FIXED_POINT
352
84.6M
   shift = 2*shift;
353
84.6M
   if (shift<=0)
354
82.7M
      ac[0] += SHL32((opus_int32)1, -shift);
355
84.6M
   if (ac[0] < 268435456)
356
82.2M
   {
357
82.2M
      int shift2 = 29 - EC_ILOG(ac[0]);
358
1.03G
      for (i=0;i<=lag;i++)
359
955M
         ac[i] = SHL32(ac[i], shift2);
360
82.2M
      shift -= shift2;
361
82.2M
   } else if (ac[0] >= 536870912)
362
2.21M
   {
363
2.21M
      int shift2=1;
364
2.21M
      if (ac[0] >= 1073741824)
365
1.00M
         shift2++;
366
28.0M
      for (i=0;i<=lag;i++)
367
25.8M
         ac[i] = SHR32(ac[i], shift2);
368
2.21M
      shift += shift2;
369
2.21M
   }
370
84.6M
#endif
371
372
84.6M
   RESTORE_STACK;
373
84.6M
   return shift;
374
84.6M
}
_celt_autocorr
Line
Count
Source
293
84.6M
{
294
84.6M
   opus_val32 d;
295
84.6M
   int i, k;
296
84.6M
   int fastN=n-lag;
297
84.6M
   int shift;
298
84.6M
   const opus_val16 *xptr;
299
84.6M
   VARDECL(opus_val16, xx);
300
84.6M
   SAVE_STACK;
301
84.6M
   ALLOC(xx, n, opus_val16);
302
84.6M
   celt_assert(n>0);
303
84.6M
   celt_assert(overlap>=0);
304
84.6M
   if (overlap == 0)
305
84.5M
   {
306
84.5M
      xptr = x;
307
84.5M
   } else {
308
103M
      for (i=0;i<n;i++)
309
103M
         xx[i] = x[i];
310
12.1M
      for (i=0;i<overlap;i++)
311
12.1M
      {
312
12.1M
         opus_val16 w = COEF2VAL16(window[i]);
313
12.1M
         xx[i] = MULT16_16_Q15(x[i],w);
314
12.1M
         xx[n-i-1] = MULT16_16_Q15(x[n-i-1],w);
315
12.1M
      }
316
91.5k
      xptr = xx;
317
91.5k
   }
318
84.6M
   shift=0;
319
84.6M
#ifdef FIXED_POINT
320
84.6M
   {
321
84.6M
      opus_val32 ac0;
322
84.6M
      int ac0_shift = celt_ilog2(n + (n>>4));
323
84.6M
      ac0 = 1+(n<<7);
324
84.6M
      if (n&1) ac0 += SHR32(MULT16_16(xptr[0],xptr[0]),ac0_shift);
325
8.68G
      for(i=(n&1);i<n;i+=2)
326
8.60G
      {
327
8.60G
         ac0 += SHR32(MULT16_16(xptr[i],xptr[i]),ac0_shift);
328
8.60G
         ac0 += SHR32(MULT16_16(xptr[i+1],xptr[i+1]),ac0_shift);
329
8.60G
      }
330
      /* Consider the effect of rounding-to-nearest when scaling the signal. */
331
84.6M
      ac0 += SHR32(ac0,7);
332
333
84.6M
      shift = celt_ilog2(ac0)-30+ac0_shift+1;
334
84.6M
      shift = (shift)/2;
335
84.6M
      if (shift>0)
336
1.85M
      {
337
379M
         for(i=0;i<n;i++)
338
377M
            xx[i] = PSHR32(xptr[i], shift);
339
1.85M
         xptr = xx;
340
1.85M
      } else
341
82.7M
         shift = 0;
342
84.6M
   }
343
84.6M
#endif
344
84.6M
   celt_pitch_xcorr(xptr, xptr, ac, fastN, lag+1, arch);
345
1.06G
   for (k=0;k<=lag;k++)
346
982M
   {
347
6.58G
      for (i = k+fastN, d = 0; i < n; i++)
348
5.60G
         d = MAC16_16(d, xptr[i], xptr[i-k]);
349
982M
      ac[k] += d;
350
982M
   }
351
84.6M
#ifdef FIXED_POINT
352
84.6M
   shift = 2*shift;
353
84.6M
   if (shift<=0)
354
82.7M
      ac[0] += SHL32((opus_int32)1, -shift);
355
84.6M
   if (ac[0] < 268435456)
356
82.2M
   {
357
82.2M
      int shift2 = 29 - EC_ILOG(ac[0]);
358
1.03G
      for (i=0;i<=lag;i++)
359
955M
         ac[i] = SHL32(ac[i], shift2);
360
82.2M
      shift -= shift2;
361
82.2M
   } else if (ac[0] >= 536870912)
362
2.21M
   {
363
2.21M
      int shift2=1;
364
2.21M
      if (ac[0] >= 1073741824)
365
1.00M
         shift2++;
366
28.0M
      for (i=0;i<=lag;i++)
367
25.8M
         ac[i] = SHR32(ac[i], shift2);
368
2.21M
      shift += shift2;
369
2.21M
   }
370
84.6M
#endif
371
372
84.6M
   RESTORE_STACK;
373
84.6M
   return shift;
374
84.6M
}
_celt_autocorr
Line
Count
Source
293
916k
{
294
916k
   opus_val32 d;
295
916k
   int i, k;
296
916k
   int fastN=n-lag;
297
916k
   int shift;
298
916k
   const opus_val16 *xptr;
299
916k
   VARDECL(opus_val16, xx);
300
916k
   SAVE_STACK;
301
916k
   ALLOC(xx, n, opus_val16);
302
916k
   celt_assert(n>0);
303
916k
   celt_assert(overlap>=0);
304
916k
   if (overlap == 0)
305
849k
   {
306
849k
      xptr = x;
307
849k
   } else {
308
77.2M
      for (i=0;i<n;i++)
309
77.1M
         xx[i] = x[i];
310
9.10M
      for (i=0;i<overlap;i++)
311
9.04M
      {
312
9.04M
         opus_val16 w = COEF2VAL16(window[i]);
313
9.04M
         xx[i] = MULT16_16_Q15(x[i],w);
314
9.04M
         xx[n-i-1] = MULT16_16_Q15(x[n-i-1],w);
315
9.04M
      }
316
66.1k
      xptr = xx;
317
66.1k
   }
318
916k
   shift=0;
319
#ifdef FIXED_POINT
320
   {
321
      opus_val32 ac0;
322
      int ac0_shift = celt_ilog2(n + (n>>4));
323
      ac0 = 1+(n<<7);
324
      if (n&1) ac0 += SHR32(MULT16_16(xptr[0],xptr[0]),ac0_shift);
325
      for(i=(n&1);i<n;i+=2)
326
      {
327
         ac0 += SHR32(MULT16_16(xptr[i],xptr[i]),ac0_shift);
328
         ac0 += SHR32(MULT16_16(xptr[i+1],xptr[i+1]),ac0_shift);
329
      }
330
      /* Consider the effect of rounding-to-nearest when scaling the signal. */
331
      ac0 += SHR32(ac0,7);
332
333
      shift = celt_ilog2(ac0)-30+ac0_shift+1;
334
      shift = (shift)/2;
335
      if (shift>0)
336
      {
337
         for(i=0;i<n;i++)
338
            xx[i] = PSHR32(xptr[i], shift);
339
         xptr = xx;
340
      } else
341
         shift = 0;
342
   }
343
#endif
344
916k
   celt_pitch_xcorr(xptr, xptr, ac, fastN, lag+1, arch);
345
6.81M
   for (k=0;k<=lag;k++)
346
5.90M
   {
347
34.2M
      for (i = k+fastN, d = 0; i < n; i++)
348
28.3M
         d = MAC16_16(d, xptr[i], xptr[i-k]);
349
5.90M
      ac[k] += d;
350
5.90M
   }
351
#ifdef FIXED_POINT
352
   shift = 2*shift;
353
   if (shift<=0)
354
      ac[0] += SHL32((opus_int32)1, -shift);
355
   if (ac[0] < 268435456)
356
   {
357
      int shift2 = 29 - EC_ILOG(ac[0]);
358
      for (i=0;i<=lag;i++)
359
         ac[i] = SHL32(ac[i], shift2);
360
      shift -= shift2;
361
   } else if (ac[0] >= 536870912)
362
   {
363
      int shift2=1;
364
      if (ac[0] >= 1073741824)
365
         shift2++;
366
      for (i=0;i<=lag;i++)
367
         ac[i] = SHR32(ac[i], shift2);
368
      shift += shift2;
369
   }
370
#endif
371
372
916k
   RESTORE_STACK;
373
916k
   return shift;
374
916k
}