Coverage Report

Created: 2026-06-07 08:05

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
407k
{
43
407k
   int i, j;
44
407k
   opus_val32 r;
45
407k
   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
407k
   OPUS_CLEAR(lpc, p);
53
#ifdef FIXED_POINT
54
234k
   if (ac[0] != 0)
55
#else
56
173k
   if (ac[0] > 1e-10f)
57
166k
#endif
58
400k
   {
59
3.74M
      for (i = 0; i < p; i++) {
60
         /* Sum up this iteration's reflection coefficient */
61
3.41M
         opus_val32 rr = 0;
62
#if defined (FIXED_POINT) && OPUS_FAST_INT64
63
         opus_int64 acc = 0;
64
22.0M
         for (j = 0; j < i; j++)
65
19.8M
            acc += (opus_int64)(lpc[j]) * (opus_int64)(ac[i - j]);
66
2.28M
         rr = (opus_val32)SHR64(acc, 31);
67
#else
68
8.96M
         for (j = 0; j < i; j++)
69
7.83M
            rr += MULT32_32_Q31(lpc[j],ac[i - j]);
70
#endif
71
3.41M
         rr += SHR32(ac[i + 1],6);
72
3.41M
         r = -frac_div32(SHL32(rr,6), error);
73
         /*  Update LPC coefficients and total error */
74
3.41M
         lpc[i] = SHR32(r,6);
75
18.0M
         for (j = 0; j < (i+1)>>1; j++)
76
14.6M
         {
77
14.6M
            opus_val32 tmp1, tmp2;
78
14.6M
            tmp1 = lpc[j];
79
14.6M
            tmp2 = lpc[i-1-j];
80
14.6M
            lpc[j]     = tmp1 + MULT32_32_Q31(r,tmp2);
81
14.6M
            lpc[i-1-j] = tmp2 + MULT32_32_Q31(r,tmp1);
82
14.6M
         }
83
84
3.41M
         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
2.28M
         if (error<=SHR32(ac[0],10))
88
26.6k
            break;
89
#else
90
1.13M
         if (error<=.001f*ac[0])
91
43.9k
            break;
92
#endif
93
3.41M
      }
94
400k
   }
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
234k
      for (iter = 0; iter < 10; iter++) {
104
234k
         maxabs = 0;
105
3.00M
         for (i = 0; i < p; i++) {
106
2.76M
            absval = ABS32(lpc[i]);
107
2.76M
            if (absval > maxabs) {
108
259k
               maxabs = absval;
109
259k
               idx = i;
110
259k
            }
111
2.76M
         }
112
234k
         maxabs = PSHR32(maxabs, 13);  /* Q25->Q12 */
113
114
234k
         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
234k
         } else {
127
234k
            break;
128
234k
         }
129
234k
      }
130
131
234k
      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
234k
      } else {
137
3.00M
         for (i = 0; i < p; i++) {
138
2.76M
            _lpc[i] = EXTRACT16(PSHR32(lpc[i], 13));  /* Q25->Q12 */
139
2.76M
         }
140
234k
      }
141
   }
142
#endif
143
407k
}
_celt_lpc
Line
Count
Source
42
234k
{
43
234k
   int i, j;
44
234k
   opus_val32 r;
45
234k
   opus_val32 error = ac[0];
46
234k
#ifdef FIXED_POINT
47
234k
   opus_val32 lpc[CELT_LPC_ORDER];
48
#else
49
   float *lpc = _lpc;
50
#endif
51
52
234k
   OPUS_CLEAR(lpc, p);
53
234k
#ifdef FIXED_POINT
54
234k
   if (ac[0] != 0)
55
#else
56
   if (ac[0] > 1e-10f)
57
#endif
58
234k
   {
59
2.48M
      for (i = 0; i < p; i++) {
60
         /* Sum up this iteration's reflection coefficient */
61
2.28M
         opus_val32 rr = 0;
62
2.28M
#if defined (FIXED_POINT) && OPUS_FAST_INT64
63
2.28M
         opus_int64 acc = 0;
64
22.0M
         for (j = 0; j < i; j++)
65
19.8M
            acc += (opus_int64)(lpc[j]) * (opus_int64)(ac[i - j]);
66
2.28M
         rr = (opus_val32)SHR64(acc, 31);
67
#else
68
         for (j = 0; j < i; j++)
69
            rr += MULT32_32_Q31(lpc[j],ac[i - j]);
70
#endif
71
2.28M
         rr += SHR32(ac[i + 1],6);
72
2.28M
         r = -frac_div32(SHL32(rr,6), error);
73
         /*  Update LPC coefficients and total error */
74
2.28M
         lpc[i] = SHR32(r,6);
75
12.7M
         for (j = 0; j < (i+1)>>1; j++)
76
10.4M
         {
77
10.4M
            opus_val32 tmp1, tmp2;
78
10.4M
            tmp1 = lpc[j];
79
10.4M
            tmp2 = lpc[i-1-j];
80
10.4M
            lpc[j]     = tmp1 + MULT32_32_Q31(r,tmp2);
81
10.4M
            lpc[i-1-j] = tmp2 + MULT32_32_Q31(r,tmp1);
82
10.4M
         }
83
84
2.28M
         error = error - MULT32_32_Q31(MULT32_32_Q31(r,r),error);
85
         /* Bail out once we get 30 dB gain */
86
2.28M
#ifdef FIXED_POINT
87
2.28M
         if (error<=SHR32(ac[0],10))
88
26.6k
            break;
89
#else
90
         if (error<=.001f*ac[0])
91
            break;
92
#endif
93
2.28M
      }
94
234k
   }
95
234k
#ifdef FIXED_POINT
96
234k
   {
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
234k
      int iter, idx = 0;
101
234k
      opus_val32 maxabs, absval, chirp_Q16, chirp_minus_one_Q16;
102
103
234k
      for (iter = 0; iter < 10; iter++) {
104
234k
         maxabs = 0;
105
3.00M
         for (i = 0; i < p; i++) {
106
2.76M
            absval = ABS32(lpc[i]);
107
2.76M
            if (absval > maxabs) {
108
259k
               maxabs = absval;
109
259k
               idx = i;
110
259k
            }
111
2.76M
         }
112
234k
         maxabs = PSHR32(maxabs, 13);  /* Q25->Q12 */
113
114
234k
         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
234k
         } else {
127
234k
            break;
128
234k
         }
129
234k
      }
130
131
234k
      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
234k
      } else {
137
3.00M
         for (i = 0; i < p; i++) {
138
2.76M
            _lpc[i] = EXTRACT16(PSHR32(lpc[i], 13));  /* Q25->Q12 */
139
2.76M
         }
140
234k
      }
141
234k
   }
142
234k
#endif
143
234k
}
_celt_lpc
Line
Count
Source
42
173k
{
43
173k
   int i, j;
44
173k
   opus_val32 r;
45
173k
   opus_val32 error = ac[0];
46
#ifdef FIXED_POINT
47
   opus_val32 lpc[CELT_LPC_ORDER];
48
#else
49
173k
   float *lpc = _lpc;
50
173k
#endif
51
52
173k
   OPUS_CLEAR(lpc, p);
53
#ifdef FIXED_POINT
54
   if (ac[0] != 0)
55
#else
56
173k
   if (ac[0] > 1e-10f)
57
166k
#endif
58
166k
   {
59
1.25M
      for (i = 0; i < p; i++) {
60
         /* Sum up this iteration's reflection coefficient */
61
1.13M
         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)SHR64(acc, 31);
67
#else
68
8.96M
         for (j = 0; j < i; j++)
69
7.83M
            rr += MULT32_32_Q31(lpc[j],ac[i - j]);
70
1.13M
#endif
71
1.13M
         rr += SHR32(ac[i + 1],6);
72
1.13M
         r = -frac_div32(SHL32(rr,6), error);
73
         /*  Update LPC coefficients and total error */
74
1.13M
         lpc[i] = SHR32(r,6);
75
5.33M
         for (j = 0; j < (i+1)>>1; j++)
76
4.19M
         {
77
4.19M
            opus_val32 tmp1, tmp2;
78
4.19M
            tmp1 = lpc[j];
79
4.19M
            tmp2 = lpc[i-1-j];
80
4.19M
            lpc[j]     = tmp1 + MULT32_32_Q31(r,tmp2);
81
4.19M
            lpc[i-1-j] = tmp2 + MULT32_32_Q31(r,tmp1);
82
4.19M
         }
83
84
1.13M
         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
1.13M
         if (error<=.001f*ac[0])
91
43.9k
            break;
92
1.13M
#endif
93
1.13M
      }
94
166k
   }
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
173k
}
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
124k
{
154
124k
   int i,j;
155
124k
   VARDECL(opus_val16, rnum);
156
124k
   SAVE_STACK;
157
124k
   celt_assert(x != y);
158
124k
   ALLOC(rnum, ord, opus_val16);
159
3.11M
   for(i=0;i<ord;i++)
160
2.99M
      rnum[i] = num[ord-i-1];
161
17.5M
   for (i=0;i<N-3;i+=4)
162
17.3M
   {
163
17.3M
      opus_val32 sum[4];
164
17.3M
      sum[0] = SHL32(EXTEND32(x[i  ]), SIG_SHIFT);
165
17.3M
      sum[1] = SHL32(EXTEND32(x[i+1]), SIG_SHIFT);
166
17.3M
      sum[2] = SHL32(EXTEND32(x[i+2]), SIG_SHIFT);
167
17.3M
      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
17.3M
         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
17.3M
      y[i  ] = SROUND16(sum[0], SIG_SHIFT);
180
17.3M
      y[i+1] = SROUND16(sum[1], SIG_SHIFT);
181
17.3M
      y[i+2] = SROUND16(sum[2], SIG_SHIFT);
182
17.3M
      y[i+3] = SROUND16(sum[3], SIG_SHIFT);
183
0
   }
184
177k
   for (;i<N;i++)
185
52.7k
   {
186
52.7k
      opus_val32 sum = SHL32(EXTEND32(x[i]), SIG_SHIFT);
187
1.31M
      for (j=0;j<ord;j++)
188
1.26M
         sum = MAC16_16(sum,rnum[j],x[i+j-ord]);
189
52.7k
      y[i] = SROUND16(sum, SIG_SHIFT);
190
52.7k
   }
191
0
   RESTORE_STACK;
192
0
}
Unexecuted instantiation: celt_fir_c
celt_fir_c
Line
Count
Source
153
124k
{
154
124k
   int i,j;
155
124k
   VARDECL(opus_val16, rnum);
156
124k
   SAVE_STACK;
157
124k
   celt_assert(x != y);
158
124k
   ALLOC(rnum, ord, opus_val16);
159
3.11M
   for(i=0;i<ord;i++)
160
2.99M
      rnum[i] = num[ord-i-1];
161
17.5M
   for (i=0;i<N-3;i+=4)
162
17.3M
   {
163
17.3M
      opus_val32 sum[4];
164
17.3M
      sum[0] = SHL32(EXTEND32(x[i  ]), SIG_SHIFT);
165
17.3M
      sum[1] = SHL32(EXTEND32(x[i+1]), SIG_SHIFT);
166
17.3M
      sum[2] = SHL32(EXTEND32(x[i+2]), SIG_SHIFT);
167
17.3M
      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
17.3M
         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
17.3M
      y[i  ] = SROUND16(sum[0], SIG_SHIFT);
180
17.3M
      y[i+1] = SROUND16(sum[1], SIG_SHIFT);
181
17.3M
      y[i+2] = SROUND16(sum[2], SIG_SHIFT);
182
17.3M
      y[i+3] = SROUND16(sum[3], SIG_SHIFT);
183
17.3M
   }
184
177k
   for (;i<N;i++)
185
52.7k
   {
186
52.7k
      opus_val32 sum = SHL32(EXTEND32(x[i]), SIG_SHIFT);
187
1.31M
      for (j=0;j<ord;j++)
188
1.26M
         sum = MAC16_16(sum,rnum[j],x[i+j-ord]);
189
52.7k
      y[i] = SROUND16(sum, SIG_SHIFT);
190
52.7k
   }
191
124k
   RESTORE_STACK;
192
124k
}
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
285k
{
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
285k
   int i,j;
221
285k
   VARDECL(opus_val16, rden);
222
285k
   VARDECL(opus_val16, y);
223
285k
   SAVE_STACK;
224
225
285k
   celt_assert((ord&3)==0);
226
285k
   ALLOC(rden, ord, opus_val16);
227
285k
   ALLOC(y, N+ord, opus_val16);
228
7.13M
   for(i=0;i<ord;i++)
229
6.84M
      rden[i] = den[ord-i-1];
230
7.13M
   for(i=0;i<ord;i++)
231
6.84M
      y[i] = -mem[ord-i-1];
232
104M
   for(;i<N+ord;i++)
233
104M
      y[i]=0;
234
26.4M
   for (i=0;i<N-3;i+=4)
235
26.1M
   {
236
      /* Unroll by 4 as if it were an FIR filter */
237
26.1M
      opus_val32 sum[4];
238
26.1M
      sum[0]=_x[i];
239
26.1M
      sum[1]=_x[i+1];
240
26.1M
      sum[2]=_x[i+2];
241
26.1M
      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
26.1M
         xcorr_kernel(rden, y+i, sum, ord, arch);
249
#if defined(OPUS_CHECK_ASM) && defined(FIXED_POINT)
250
13.5M
         celt_assert(memcmp(sum, sum_c, sizeof(sum)) == 0);
251
13.5M
      }
252
0
#endif
253
      /* Patch up the result to compensate for the fact that this is an IIR */
254
26.1M
      y[i+ord  ] = -SROUND16(sum[0],SIG_SHIFT);
255
13.5M
      _y[i  ] = sum[0];
256
26.1M
      sum[1] = MAC16_16(sum[1], y[i+ord  ], den[0]);
257
26.1M
      y[i+ord+1] = -SROUND16(sum[1],SIG_SHIFT);
258
13.5M
      _y[i+1] = sum[1];
259
26.1M
      sum[2] = MAC16_16(sum[2], y[i+ord+1], den[0]);
260
26.1M
      sum[2] = MAC16_16(sum[2], y[i+ord  ], den[1]);
261
26.1M
      y[i+ord+2] = -SROUND16(sum[2],SIG_SHIFT);
262
13.5M
      _y[i+2] = sum[2];
263
264
26.1M
      sum[3] = MAC16_16(sum[3], y[i+ord+2], den[0]);
265
26.1M
      sum[3] = MAC16_16(sum[3], y[i+ord+1], den[1]);
266
26.1M
      sum[3] = MAC16_16(sum[3], y[i+ord  ], den[2]);
267
26.1M
      y[i+ord+3] = -SROUND16(sum[3],SIG_SHIFT);
268
13.5M
      _y[i+3] = sum[3];
269
13.5M
   }
270
285k
   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
7.13M
   for(i=0;i<ord;i++)
279
6.84M
      mem[i] = _y[N-i-1];
280
160k
   RESTORE_STACK;
281
160k
#endif
282
160k
}
celt_iir
Line
Count
Source
201
160k
{
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
160k
   int i,j;
221
160k
   VARDECL(opus_val16, rden);
222
160k
   VARDECL(opus_val16, y);
223
160k
   SAVE_STACK;
224
225
160k
   celt_assert((ord&3)==0);
226
160k
   ALLOC(rden, ord, opus_val16);
227
160k
   ALLOC(y, N+ord, opus_val16);
228
4.01M
   for(i=0;i<ord;i++)
229
3.85M
      rden[i] = den[ord-i-1];
230
4.01M
   for(i=0;i<ord;i++)
231
3.85M
      y[i] = -mem[ord-i-1];
232
54.5M
   for(;i<N+ord;i++)
233
54.3M
      y[i]=0;
234
13.7M
   for (i=0;i<N-3;i+=4)
235
13.5M
   {
236
      /* Unroll by 4 as if it were an FIR filter */
237
13.5M
      opus_val32 sum[4];
238
13.5M
      sum[0]=_x[i];
239
13.5M
      sum[1]=_x[i+1];
240
13.5M
      sum[2]=_x[i+2];
241
13.5M
      sum[3]=_x[i+3];
242
13.5M
#if defined(OPUS_CHECK_ASM) && defined(FIXED_POINT)
243
13.5M
      {
244
13.5M
         opus_val32 sum_c[4];
245
13.5M
         memcpy(sum_c, sum, sizeof(sum_c));
246
13.5M
         xcorr_kernel_c(rden, y+i, sum_c, ord);
247
13.5M
#endif
248
13.5M
         xcorr_kernel(rden, y+i, sum, ord, arch);
249
13.5M
#if defined(OPUS_CHECK_ASM) && defined(FIXED_POINT)
250
13.5M
         celt_assert(memcmp(sum, sum_c, sizeof(sum)) == 0);
251
13.5M
      }
252
0
#endif
253
      /* Patch up the result to compensate for the fact that this is an IIR */
254
13.5M
      y[i+ord  ] = -SROUND16(sum[0],SIG_SHIFT);
255
13.5M
      _y[i  ] = sum[0];
256
13.5M
      sum[1] = MAC16_16(sum[1], y[i+ord  ], den[0]);
257
13.5M
      y[i+ord+1] = -SROUND16(sum[1],SIG_SHIFT);
258
13.5M
      _y[i+1] = sum[1];
259
13.5M
      sum[2] = MAC16_16(sum[2], y[i+ord+1], den[0]);
260
13.5M
      sum[2] = MAC16_16(sum[2], y[i+ord  ], den[1]);
261
13.5M
      y[i+ord+2] = -SROUND16(sum[2],SIG_SHIFT);
262
13.5M
      _y[i+2] = sum[2];
263
264
13.5M
      sum[3] = MAC16_16(sum[3], y[i+ord+2], den[0]);
265
13.5M
      sum[3] = MAC16_16(sum[3], y[i+ord+1], den[1]);
266
13.5M
      sum[3] = MAC16_16(sum[3], y[i+ord  ], den[2]);
267
13.5M
      y[i+ord+3] = -SROUND16(sum[3],SIG_SHIFT);
268
13.5M
      _y[i+3] = sum[3];
269
13.5M
   }
270
160k
   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
4.01M
   for(i=0;i<ord;i++)
279
3.85M
      mem[i] = _y[N-i-1];
280
160k
   RESTORE_STACK;
281
160k
#endif
282
160k
}
celt_iir
Line
Count
Source
201
124k
{
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
124k
   int i,j;
221
124k
   VARDECL(opus_val16, rden);
222
124k
   VARDECL(opus_val16, y);
223
124k
   SAVE_STACK;
224
225
124k
   celt_assert((ord&3)==0);
226
124k
   ALLOC(rden, ord, opus_val16);
227
124k
   ALLOC(y, N+ord, opus_val16);
228
3.11M
   for(i=0;i<ord;i++)
229
2.99M
      rden[i] = den[ord-i-1];
230
3.11M
   for(i=0;i<ord;i++)
231
2.99M
      y[i] = -mem[ord-i-1];
232
50.4M
   for(;i<N+ord;i++)
233
50.3M
      y[i]=0;
234
12.7M
   for (i=0;i<N-3;i+=4)
235
12.5M
   {
236
      /* Unroll by 4 as if it were an FIR filter */
237
12.5M
      opus_val32 sum[4];
238
12.5M
      sum[0]=_x[i];
239
12.5M
      sum[1]=_x[i+1];
240
12.5M
      sum[2]=_x[i+2];
241
12.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
12.5M
         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
12.5M
      y[i+ord  ] = -SROUND16(sum[0],SIG_SHIFT);
255
12.5M
      _y[i  ] = sum[0];
256
12.5M
      sum[1] = MAC16_16(sum[1], y[i+ord  ], den[0]);
257
12.5M
      y[i+ord+1] = -SROUND16(sum[1],SIG_SHIFT);
258
12.5M
      _y[i+1] = sum[1];
259
12.5M
      sum[2] = MAC16_16(sum[2], y[i+ord+1], den[0]);
260
12.5M
      sum[2] = MAC16_16(sum[2], y[i+ord  ], den[1]);
261
12.5M
      y[i+ord+2] = -SROUND16(sum[2],SIG_SHIFT);
262
12.5M
      _y[i+2] = sum[2];
263
264
12.5M
      sum[3] = MAC16_16(sum[3], y[i+ord+2], den[0]);
265
12.5M
      sum[3] = MAC16_16(sum[3], y[i+ord+1], den[1]);
266
12.5M
      sum[3] = MAC16_16(sum[3], y[i+ord  ], den[2]);
267
12.5M
      y[i+ord+3] = -SROUND16(sum[3],SIG_SHIFT);
268
12.5M
      _y[i+3] = sum[3];
269
12.5M
   }
270
124k
   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.11M
   for(i=0;i<ord;i++)
279
2.99M
      mem[i] = _y[N-i-1];
280
124k
   RESTORE_STACK;
281
124k
#endif
282
124k
}
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
1.62M
{
294
1.62M
   opus_val32 d;
295
1.62M
   int i, k;
296
1.62M
   int fastN=n-lag;
297
1.62M
   int shift;
298
1.62M
   const opus_val16 *xptr;
299
1.62M
   VARDECL(opus_val16, xx);
300
1.62M
   SAVE_STACK;
301
1.62M
   ALLOC(xx, n, opus_val16);
302
1.62M
   celt_assert(n>0);
303
1.62M
   celt_assert(overlap>=0);
304
1.62M
   if (overlap == 0)
305
1.37M
   {
306
1.37M
      xptr = x;
307
1.37M
   } else {
308
285M
      for (i=0;i<n;i++)
309
285M
         xx[i] = x[i];
310
33.7M
      for (i=0;i<overlap;i++)
311
33.4M
      {
312
33.4M
         opus_val16 w = COEF2VAL16(window[i]);
313
33.4M
         xx[i] = MULT16_16_Q15(x[i],w);
314
33.4M
         xx[n-i-1] = MULT16_16_Q15(x[n-i-1],w);
315
33.4M
      }
316
253k
      xptr = xx;
317
253k
   }
318
1.62M
   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
1.45M
      if (n&1) ac0 += SHR32(MULT16_16(xptr[0],xptr[0]),ac0_shift);
325
306M
      for(i=(n&1);i<n;i+=2)
326
304M
      {
327
304M
         ac0 += SHR32(MULT16_16(xptr[i],xptr[i]),ac0_shift);
328
304M
         ac0 += SHR32(MULT16_16(xptr[i+1],xptr[i+1]),ac0_shift);
329
304M
      }
330
      /* Consider the effect of rounding-to-nearest when scaling the signal. */
331
1.45M
      ac0 += SHR32(ac0,7);
332
333
      shift = celt_ilog2(ac0)-30+ac0_shift+1;
334
      shift = (shift)/2;
335
1.45M
      if (shift>0)
336
305k
      {
337
69.9M
         for(i=0;i<n;i++)
338
69.6M
            xx[i] = PSHR32(xptr[i], shift);
339
305k
         xptr = xx;
340
305k
      } else
341
1.14M
         shift = 0;
342
   }
343
#endif
344
1.62M
   celt_pitch_xcorr(xptr, xptr, ac, fastN, lag+1, arch);
345
21.9M
   for (k=0;k<=lag;k++)
346
20.2M
   {
347
170M
      for (i = k+fastN, d = 0; i < n; i++)
348
150M
         d = MAC16_16(d, xptr[i], xptr[i-k]);
349
20.2M
      ac[k] += d;
350
20.2M
   }
351
#ifdef FIXED_POINT
352
   shift = 2*shift;
353
1.45M
   if (shift<=0)
354
1.14M
      ac[0] += SHL32((opus_int32)1, -shift);
355
1.45M
   if (ac[0] < 268435456)
356
979k
   {
357
979k
      int shift2 = 29 - EC_ILOG(ac[0]);
358
13.1M
      for (i=0;i<=lag;i++)
359
12.1M
         ac[i] = SHL32(ac[i], shift2);
360
979k
      shift -= shift2;
361
979k
   } else if (ac[0] >= 536870912)
362
418k
   {
363
418k
      int shift2=1;
364
418k
      if (ac[0] >= 1073741824)
365
194k
         shift2++;
366
5.64M
      for (i=0;i<=lag;i++)
367
5.22M
         ac[i] = SHR32(ac[i], shift2);
368
418k
      shift += shift2;
369
418k
   }
370
#endif
371
372
1.62M
   RESTORE_STACK;
373
1.62M
   return shift;
374
1.62M
}
_celt_autocorr
Line
Count
Source
293
725k
{
294
725k
   opus_val32 d;
295
725k
   int i, k;
296
725k
   int fastN=n-lag;
297
725k
   int shift;
298
725k
   const opus_val16 *xptr;
299
725k
   VARDECL(opus_val16, xx);
300
725k
   SAVE_STACK;
301
725k
   ALLOC(xx, n, opus_val16);
302
725k
   celt_assert(n>0);
303
725k
   celt_assert(overlap>=0);
304
725k
   if (overlap == 0)
305
633k
   {
306
633k
      xptr = x;
307
633k
   } else {
308
102M
      for (i=0;i<n;i++)
309
102M
         xx[i] = x[i];
310
12.0M
      for (i=0;i<overlap;i++)
311
11.9M
      {
312
11.9M
         opus_val16 w = COEF2VAL16(window[i]);
313
11.9M
         xx[i] = MULT16_16_Q15(x[i],w);
314
11.9M
         xx[n-i-1] = MULT16_16_Q15(x[n-i-1],w);
315
11.9M
      }
316
91.5k
      xptr = xx;
317
91.5k
   }
318
725k
   shift=0;
319
725k
#ifdef FIXED_POINT
320
725k
   {
321
725k
      opus_val32 ac0;
322
725k
      int ac0_shift = celt_ilog2(n + (n>>4));
323
725k
      ac0 = 1+(n<<7);
324
725k
      if (n&1) ac0 += SHR32(MULT16_16(xptr[0],xptr[0]),ac0_shift);
325
153M
      for(i=(n&1);i<n;i+=2)
326
152M
      {
327
152M
         ac0 += SHR32(MULT16_16(xptr[i],xptr[i]),ac0_shift);
328
152M
         ac0 += SHR32(MULT16_16(xptr[i+1],xptr[i+1]),ac0_shift);
329
152M
      }
330
      /* Consider the effect of rounding-to-nearest when scaling the signal. */
331
725k
      ac0 += SHR32(ac0,7);
332
333
725k
      shift = celt_ilog2(ac0)-30+ac0_shift+1;
334
725k
      shift = (shift)/2;
335
725k
      if (shift>0)
336
152k
      {
337
34.9M
         for(i=0;i<n;i++)
338
34.8M
            xx[i] = PSHR32(xptr[i], shift);
339
152k
         xptr = xx;
340
152k
      } else
341
572k
         shift = 0;
342
725k
   }
343
725k
#endif
344
725k
   celt_pitch_xcorr(xptr, xptr, ac, fastN, lag+1, arch);
345
9.72M
   for (k=0;k<=lag;k++)
346
9.00M
   {
347
73.1M
      for (i = k+fastN, d = 0; i < n; i++)
348
64.1M
         d = MAC16_16(d, xptr[i], xptr[i-k]);
349
9.00M
      ac[k] += d;
350
9.00M
   }
351
725k
#ifdef FIXED_POINT
352
725k
   shift = 2*shift;
353
725k
   if (shift<=0)
354
572k
      ac[0] += SHL32((opus_int32)1, -shift);
355
725k
   if (ac[0] < 268435456)
356
489k
   {
357
489k
      int shift2 = 29 - EC_ILOG(ac[0]);
358
6.55M
      for (i=0;i<=lag;i++)
359
6.06M
         ac[i] = SHL32(ac[i], shift2);
360
489k
      shift -= shift2;
361
489k
   } else if (ac[0] >= 536870912)
362
209k
   {
363
209k
      int shift2=1;
364
209k
      if (ac[0] >= 1073741824)
365
97.4k
         shift2++;
366
2.82M
      for (i=0;i<=lag;i++)
367
2.61M
         ac[i] = SHR32(ac[i], shift2);
368
209k
      shift += shift2;
369
209k
   }
370
725k
#endif
371
372
725k
   RESTORE_STACK;
373
725k
   return shift;
374
725k
}
_celt_autocorr
Line
Count
Source
293
725k
{
294
725k
   opus_val32 d;
295
725k
   int i, k;
296
725k
   int fastN=n-lag;
297
725k
   int shift;
298
725k
   const opus_val16 *xptr;
299
725k
   VARDECL(opus_val16, xx);
300
725k
   SAVE_STACK;
301
725k
   ALLOC(xx, n, opus_val16);
302
725k
   celt_assert(n>0);
303
725k
   celt_assert(overlap>=0);
304
725k
   if (overlap == 0)
305
633k
   {
306
633k
      xptr = x;
307
633k
   } else {
308
102M
      for (i=0;i<n;i++)
309
102M
         xx[i] = x[i];
310
12.0M
      for (i=0;i<overlap;i++)
311
11.9M
      {
312
11.9M
         opus_val16 w = COEF2VAL16(window[i]);
313
11.9M
         xx[i] = MULT16_16_Q15(x[i],w);
314
11.9M
         xx[n-i-1] = MULT16_16_Q15(x[n-i-1],w);
315
11.9M
      }
316
91.5k
      xptr = xx;
317
91.5k
   }
318
725k
   shift=0;
319
725k
#ifdef FIXED_POINT
320
725k
   {
321
725k
      opus_val32 ac0;
322
725k
      int ac0_shift = celt_ilog2(n + (n>>4));
323
725k
      ac0 = 1+(n<<7);
324
725k
      if (n&1) ac0 += SHR32(MULT16_16(xptr[0],xptr[0]),ac0_shift);
325
153M
      for(i=(n&1);i<n;i+=2)
326
152M
      {
327
152M
         ac0 += SHR32(MULT16_16(xptr[i],xptr[i]),ac0_shift);
328
152M
         ac0 += SHR32(MULT16_16(xptr[i+1],xptr[i+1]),ac0_shift);
329
152M
      }
330
      /* Consider the effect of rounding-to-nearest when scaling the signal. */
331
725k
      ac0 += SHR32(ac0,7);
332
333
725k
      shift = celt_ilog2(ac0)-30+ac0_shift+1;
334
725k
      shift = (shift)/2;
335
725k
      if (shift>0)
336
152k
      {
337
34.9M
         for(i=0;i<n;i++)
338
34.8M
            xx[i] = PSHR32(xptr[i], shift);
339
152k
         xptr = xx;
340
152k
      } else
341
572k
         shift = 0;
342
725k
   }
343
725k
#endif
344
725k
   celt_pitch_xcorr(xptr, xptr, ac, fastN, lag+1, arch);
345
9.72M
   for (k=0;k<=lag;k++)
346
9.00M
   {
347
73.1M
      for (i = k+fastN, d = 0; i < n; i++)
348
64.1M
         d = MAC16_16(d, xptr[i], xptr[i-k]);
349
9.00M
      ac[k] += d;
350
9.00M
   }
351
725k
#ifdef FIXED_POINT
352
725k
   shift = 2*shift;
353
725k
   if (shift<=0)
354
572k
      ac[0] += SHL32((opus_int32)1, -shift);
355
725k
   if (ac[0] < 268435456)
356
489k
   {
357
489k
      int shift2 = 29 - EC_ILOG(ac[0]);
358
6.55M
      for (i=0;i<=lag;i++)
359
6.06M
         ac[i] = SHL32(ac[i], shift2);
360
489k
      shift -= shift2;
361
489k
   } else if (ac[0] >= 536870912)
362
209k
   {
363
209k
      int shift2=1;
364
209k
      if (ac[0] >= 1073741824)
365
97.4k
         shift2++;
366
2.82M
      for (i=0;i<=lag;i++)
367
2.61M
         ac[i] = SHR32(ac[i], shift2);
368
209k
      shift += shift2;
369
209k
   }
370
725k
#endif
371
372
725k
   RESTORE_STACK;
373
725k
   return shift;
374
725k
}
_celt_autocorr
Line
Count
Source
293
173k
{
294
173k
   opus_val32 d;
295
173k
   int i, k;
296
173k
   int fastN=n-lag;
297
173k
   int shift;
298
173k
   const opus_val16 *xptr;
299
173k
   VARDECL(opus_val16, xx);
300
173k
   SAVE_STACK;
301
173k
   ALLOC(xx, n, opus_val16);
302
173k
   celt_assert(n>0);
303
173k
   celt_assert(overlap>=0);
304
173k
   if (overlap == 0)
305
103k
   {
306
103k
      xptr = x;
307
103k
   } else {
308
81.2M
      for (i=0;i<n;i++)
309
81.1M
         xx[i] = x[i];
310
9.57M
      for (i=0;i<overlap;i++)
311
9.50M
      {
312
9.50M
         opus_val16 w = COEF2VAL16(window[i]);
313
9.50M
         xx[i] = MULT16_16_Q15(x[i],w);
314
9.50M
         xx[n-i-1] = MULT16_16_Q15(x[n-i-1],w);
315
9.50M
      }
316
70.4k
      xptr = xx;
317
70.4k
   }
318
173k
   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
173k
   celt_pitch_xcorr(xptr, xptr, ac, fastN, lag+1, arch);
345
2.44M
   for (k=0;k<=lag;k++)
346
2.27M
   {
347
24.4M
      for (i = k+fastN, d = 0; i < n; i++)
348
22.1M
         d = MAC16_16(d, xptr[i], xptr[i-k]);
349
2.27M
      ac[k] += d;
350
2.27M
   }
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
173k
   RESTORE_STACK;
373
173k
   return shift;
374
173k
}