Debian Codegraph @

external/flac/flac_lpc.c

raw symbols SCIP
1 /* libFLAC - Free Lossless Audio Codec library
2 * Copyright (C) 2000-2009 Josh Coalson
3 * Copyright (C) 2011-2025 Xiph.Org Foundation
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * - Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * - Neither the name of the Xiph.org Foundation nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 //ppgb #ifdef HAVE_CONFIG_H
34 #include "flac_config.h"cxx . . $ `<file>/external/flac/flac_config.h`/
35 //ppgb #endif
36
37 #include <math.h>
38 #include <stdlib.h>
39
40 #include "flac_FLAC_assert.h"cxx . . $ `<file>/external/flac/flac_FLAC_assert.h`/
41 #include "flac_FLAC_format.h"cxx . . $ `<file>/external/flac/flac_FLAC_format.h`/
42 #include "flac_share_compat.h"cxx . . $ `<file>/external/flac/flac_share_compat.h`/
43 #include "flac_private_bitmath.h"cxx . . $ `<file>/external/flac/flac_private_bitmath.h`/
44 #include "flac_private_lpc.h"cxx . . $ `<file>/external/flac/flac_private_lpc.h`/
45 #include "flac_private_macros.h"cxx . . $ `<file>/external/flac/flac_private_macros.h`/
46 #if !defined(NDEBUG) || defined FLAC__OVERFLOW_DETECT || defined FLAC__OVERFLOW_DETECT_VERBOSE
47 #include <stdio.h>
48 #endif
49
50 /* OPT: #undef'ing this may improve the speed on some architectures */
51 #define FLAC__LPC_UNROLLED_FILTER_LOOPScxx . . $ `external/flac/flac_lpc.c:51:9`!
52
53 #ifndef FLAC__INTEGER_ONLY_LIBRARY
54
55 #if defined(_MSC_VER) && (_MSC_VER < 1800)
56 #include <float.h>
57 static inline long int lround(double x) {
58 return (long)(x + _copysign(0.5, x));
59 }
60 #elif !defined(HAVE_LROUNDcxx . . $ `external/flac/flac_config.h:36:9`!) && defined(__GNUC__cxx . . $ `<built-in>:8:9`!)
61 static inline long int lround(double x) {
62 return (long)(x + __builtin_copysign(0.5, x));
63 }
64 /* If this fails, we are in the presence of a mid 90's compiler, move along... */
65 #endif
66
67 void FLAC__lpc_window_datacxx . . $ FLAC__lpc_window_data(a91d881df18cb83f).(const FLAC__int32cxx . . $ FLAC__int32# in[], const FLAC__realcxx . . $ FLAC__real# window[], FLAC__realcxx . . $ FLAC__real# out[], uint32_tcxx . . $ uint32_t# data_len)
68 {
69 uint32_tcxx . . $ uint32_t# i;
70 for(i = 0; i < data_len; i++)
71 out[i] = in[i] * window[i];
72 }
73
74 void FLAC__lpc_window_data_widecxx . . $ FLAC__lpc_window_data_wide(22d68cbc5a3de072).(const FLAC__int64cxx . . $ FLAC__int64# in[], const FLAC__realcxx . . $ FLAC__real# window[], FLAC__realcxx . . $ FLAC__real# out[], uint32_tcxx . . $ uint32_t# data_len)
75 {
76 uint32_tcxx . . $ uint32_t# i;
77 for(i = 0; i < data_len; i++)
78 out[i] = in[i] * window[i];
79 }
80
81 void FLAC__lpc_window_data_partialcxx . . $ FLAC__lpc_window_data_partial(d79a0e23e3ab1270).(const FLAC__int32cxx . . $ FLAC__int32# in[], const FLAC__realcxx . . $ FLAC__real# window[], FLAC__realcxx . . $ FLAC__real# out[], uint32_tcxx . . $ uint32_t# data_len, uint32_tcxx . . $ uint32_t# part_size, uint32_tcxx . . $ uint32_t# data_shift)
82 {
83 uint32_tcxx . . $ uint32_t# i, j;
84 if((part_size + data_shift) < data_len){
85 for(i = 0; i < part_size; i++)
86 out[i] = in[data_shift+i] * window[i];
87 i = flac_mincxx . . $ `external/flac/flac_private_macros.h:67:9`!(i,data_len - part_size - data_shift);
88 for(j = data_len - part_size; j < data_len; i++, j++)
89 out[i] = in[data_shift+i] * window[j];
90 if(i < data_len)
91 out[i] = 0.0f;
92 }
93 }
94
95 void FLAC__lpc_window_data_partial_widecxx . . $ FLAC__lpc_window_data_partial_wide(35421658d24ebfbe).(const FLAC__int64cxx . . $ FLAC__int64# in[], const FLAC__realcxx . . $ FLAC__real# window[], FLAC__realcxx . . $ FLAC__real# out[], uint32_tcxx . . $ uint32_t# data_len, uint32_tcxx . . $ uint32_t# part_size, uint32_tcxx . . $ uint32_t# data_shift)
96 {
97 uint32_tcxx . . $ uint32_t# i, j;
98 if((part_size + data_shift) < data_len){
99 for(i = 0; i < part_size; i++)
100 out[i] = in[data_shift+i] * window[i];
101 i = flac_mincxx . . $ `external/flac/flac_private_macros.h:67:9`!(i,data_len - part_size - data_shift);
102 for(j = data_len - part_size; j < data_len; i++, j++)
103 out[i] = in[data_shift+i] * window[j];
104 if(i < data_len)
105 out[i] = 0.0f;
106 }
107 }
108
109 void FLAC__lpc_compute_autocorrelationcxx . . $ FLAC__lpc_compute_autocorrelation(4cb6553006f49f12).(const FLAC__realcxx . . $ FLAC__real# data[], uint32_tcxx . . $ uint32_t# data_len, uint32_tcxx . . $ uint32_t# lag, double autoc[])
110 {
111 /* a readable, but slower, version */
112 #if 0
113 double d;
114 uint32_t i;
115
116 FLAC__ASSERT(lag > 0);
117 FLAC__ASSERT(lag <= data_len);
118
119 /*
120 * Technically we should subtract the mean first like so:
121 * for(i = 0; i < data_len; i++)
122 * data[i] -= mean;
123 * but it appears not to make enough of a difference to matter, and
124 * most signals are already closely centered around zero
125 */
126 while(lag--) {
127 for(i = lag, d = 0.0; i < data_len; i++)
128 d += data[i] * (double)data[i - lag];
129 autoc[lag] = d;
130 }
131 #endif
132 if (data_len < FLAC__MAX_LPC_ORDERcxx . . $ `external/flac/flac_FLAC_format.h:128:9`! || lag > 16) {
133 /*
134 * this version tends to run faster because of better data locality
135 * ('data_len' is usually much larger than 'lag')
136 */
137 double d;
138 uint32_tcxx . . $ uint32_t# sample, coeff;
139 const uint32_tcxx . . $ uint32_t# limit = data_len - lag;
140
141 FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(lag > 0);
142 FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(lag <= data_len);
143
144 for(coeff = 0; coeff < lag; coeff++)
145 autoc[coeff] = 0.0;
146 for(sample = 0; sample <= limit; sample++) {
147 d = data[sample];
148 for(coeff = 0; coeff < lag; coeff++)
149 autoc[coeff] += d * data[sample+coeff];
150 }
151 for(; sample < data_len; sample++) {
152 d = data[sample];
153 for(coeff = 0; coeff < data_len - sample; coeff++)
154 autoc[coeff] += d * data[sample+coeff];
155 }
156 }
157 else if(lag <= 8) {
158 #undef MAX_LAG
159 #define MAX_LAGcxx . . $ `external/flac/flac_lpc.c:159:11`! 8
160 #include "flac_deduplication_lpc_compute_autocorrelation_intrin_c.h"cxx . . $ `<file>/external/flac/flac_deduplication_lpc_compute_autocorrelation_intrin_c.h`/
161 }
162 else if(lag <= 12) {
163 #undef MAX_LAGcxx . . $ `external/flac/flac_lpc.c:159:11`!
164 #define MAX_LAGcxx . . $ `external/flac/flac_lpc.c:164:11`! 12
165 #include "flac_deduplication_lpc_compute_autocorrelation_intrin_c.h"cxx . . $ `<file>/external/flac/flac_deduplication_lpc_compute_autocorrelation_intrin_c.h`/
166 }
167 else if(lag <= 16) {
168 #undef MAX_LAGcxx . . $ `external/flac/flac_lpc.c:164:11`!
169 #define MAX_LAGcxx . . $ `external/flac/flac_lpc.c:169:11`! 16
170 #include "flac_deduplication_lpc_compute_autocorrelation_intrin_c.h"cxx . . $ `<file>/external/flac/flac_deduplication_lpc_compute_autocorrelation_intrin_c.h`/
171 }
172
173 }
174
175 void FLAC__lpc_compute_lp_coefficientscxx . . $ FLAC__lpc_compute_lp_coefficients(88f1dab8e3894dd1).(const double autoc[], uint32_tcxx . . $ uint32_t# *max_order, FLAC__realcxx . . $ FLAC__real# lp_coeff[][FLAC__MAX_LPC_ORDERcxx . . $ `external/flac/flac_FLAC_format.h:128:9`!], double error[])
176 {
177 uint32_tcxx . . $ uint32_t# i, j;
178 double r, err, lpc[FLAC__MAX_LPC_ORDERcxx . . $ `external/flac/flac_FLAC_format.h:128:9`!];
179
180 FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(0 != max_order);
181 FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(0 < *max_order);
182 FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(*max_order <= FLAC__MAX_LPC_ORDERcxx . . $ `external/flac/flac_FLAC_format.h:128:9`!);
183 FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(autoc[0] != 0.0);
184
185 err = autoc[0];
186
187 for(i = 0; i < *max_order; i++) {
188 /* Sum up this iteration's reflection coefficient. */
189 r = -autoc[i+1];
190 for(j = 0; j < i; j++)
191 r -= lpc[j] * autoc[i-j];
192 r /= err;
193
194 /* Update LPC coefficients and total error. */
195 lpc[i]=r;
196 for(j = 0; j < (i>>1); j++) {
197 double tmp = lpc[j];
198 lpc[j] += r * lpc[i-1-j];
199 lpc[i-1-j] += r * tmp;
200 }
201 if(i & 1)
202 lpc[j] += lpc[j] * r;
203
204 err *= (1.0 - r * r);
205
206 /* save this order */
207 for(j = 0; j <= i; j++)
208 lp_coeff[i][j] = (FLAC__realcxx . . $ FLAC__real#)(-lpc[j]); /* negate FIR filter coeff to get predictor coeff */
209 error[i] = err;
210
211 /* see SF bug https://sourceforge.net/p/flac/bugs/234/ */
212 if(err == 0.0) {
213 *max_order = i+1;
214 return;
215 }
216 }
217 }
218
219 int FLAC__lpc_quantize_coefficientscxx . . $ FLAC__lpc_quantize_coefficients(b706b1983c222402).(const FLAC__realcxx . . $ FLAC__real# lp_coeff[], uint32_tcxx . . $ uint32_t# order, uint32_tcxx . . $ uint32_t# precision, FLAC__int32cxx . . $ FLAC__int32# qlp_coeff[], int *shift)
220 {
221 uint32_tcxx . . $ uint32_t# i;
222 double cmax;
223 FLAC__int32cxx . . $ FLAC__int32# qmax, qmin;
224
225 FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(precision > 0);
226 FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(precision >= FLAC__MIN_QLP_COEFF_PRECISIONcxx . . $ `external/flac/flac_FLAC_format.h:137:9`!);
227
228 /* drop one bit for the sign; from here on out we consider only |lp_coeff[i]| */
229 precision--;
230 qmax = 1 << precision;
231 qmin = -qmax;
232 qmax--;
233
234 /* calc cmax = max( |lp_coeff[i]| ) */
235 cmax = 0.0;
236 for(i = 0; i < order; i++) {
237 const double d = fabs(lp_coeff[i]);
238 if(d > cmax)
239 cmax = d;
240 }
241
242 if(cmax <= 0.0) {
243 /* => coefficients are all 0, which means our constant-detect didn't work */
244 return 2;
245 }
246 else {
247 const int max_shiftlimit = (1 << (FLAC__SUBFRAME_LPC_QLP_SHIFT_LENcxx . . $ FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN.-1)) - 1;
248 const int min_shiftlimit = -max_shiftlimit - 1;
249 int log2cmax;
250
251 (void)frexp(cmax, &log2cmax);
252 log2cmax--;
253 *shift = (int)precision - log2cmax - 1;
254
255 if(*shift > max_shiftlimit)
256 *shift = max_shiftlimit;
257 else if(*shift < min_shiftlimit)
258 return 1;
259 }
260
261 if(*shift >= 0) {
262 double error = 0.0;
263 FLAC__int32cxx . . $ FLAC__int32# q;
264 for(i = 0; i < order; i++) {
265 error += lp_coeff[i] * (1 << *shift);
266 q = lround(error);
267
268 #ifdef FLAC__OVERFLOW_DETECT
269 if(q > qmax+1) /* we expect q==qmax+1 occasionally due to rounding */
270 flac_fprintf(stderr,"FLAC__lpc_quantize_coefficients: quantizer overflow: q>qmax %d>%d shift=%d cmax=%f precision=%u lpc[%u]=%f\n",q,qmax,*shift,cmax,precision+1,i,lp_coeff[i]);
271 else if(q < qmin)
272 flac_fprintf(stderr,"FLAC__lpc_quantize_coefficients: quantizer overflow: q<qmin %d<%d shift=%d cmax=%f precision=%u lpc[%u]=%f\n",q,qmin,*shift,cmax,precision+1,i,lp_coeff[i]);
273 #endif
274 if(q > qmax)
275 q = qmax;
276 else if(q < qmin)
277 q = qmin;
278 error -= q;
279 qlp_coeff[i] = q;
280 }
281 }
282 /* negative shift is very rare but due to design flaw, negative shift is
283 * not allowed in the decoder, so it must be handled specially by scaling
284 * down coeffs
285 */
286 else {
287 const int nshift = -(*shift);
288 double error = 0.0;
289 FLAC__int32cxx . . $ FLAC__int32# q;
290 #ifndef NDEBUG
291 flac_fprintfcxx . . $ `external/flac/flac_share_compat.h:197:9`!(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!,"FLAC__lpc_quantize_coefficients: negative shift=%d order=%u cmax=%f\n", *shift, order, cmax);
292 #endif
293 for(i = 0; i < order; i++) {
294 error += lp_coeff[i] / (1 << nshift);
295 q = lround(error);
296 #ifdef FLAC__OVERFLOW_DETECT
297 if(q > qmax+1) /* we expect q==qmax+1 occasionally due to rounding */
298 flac_fprintf(stderr,"FLAC__lpc_quantize_coefficients: quantizer overflow: q>qmax %d>%d shift=%d cmax=%f precision=%u lpc[%u]=%f\n",q,qmax,*shift,cmax,precision+1,i,lp_coeff[i]);
299 else if(q < qmin)
300 flac_fprintf(stderr,"FLAC__lpc_quantize_coefficients: quantizer overflow: q<qmin %d<%d shift=%d cmax=%f precision=%u lpc[%u]=%f\n",q,qmin,*shift,cmax,precision+1,i,lp_coeff[i]);
301 #endif
302 if(q > qmax)
303 q = qmax;
304 else if(q < qmin)
305 q = qmin;
306 error -= q;
307 qlp_coeff[i] = q;
308 }
309 *shift = 0;
310 }
311
312 return 0;
313 }
314
315 #if defined(_MSC_VER)
316 // silence MSVC warnings about __restrict modifier
317 #pragma warning ( disable : 4028 )
318 #endif
319
320 void FLAC__lpc_compute_residual_from_qlp_coefficientscxx . . $ FLAC__lpc_compute_residual_from_qlp_coefficients(6941aaaa339379f8).(const FLAC__int32cxx . . $ FLAC__int32# * flac_restrictcxx . . $ `external/flac/flac_share_compat.h:97:9`! data, uint32_tcxx . . $ uint32_t# data_len, const FLAC__int32cxx . . $ FLAC__int32# * flac_restrictcxx . . $ `external/flac/flac_share_compat.h:97:9`! qlp_coeff, uint32_tcxx . . $ uint32_t# order, int lp_quantization, FLAC__int32cxx . . $ FLAC__int32# * flac_restrictcxx . . $ `external/flac/flac_share_compat.h:97:9`! residual)
321 #if defined(FLAC__OVERFLOW_DETECT) || !defined(FLAC__LPC_UNROLLED_FILTER_LOOPScxx . . $ `external/flac/flac_lpc.c:51:9`!)
322 {
323 FLAC__int64 sumo;
324 uint32_t i, j;
325 FLAC__int32 sum;
326 const FLAC__int32 *history;
327
328 #ifdef FLAC__OVERFLOW_DETECT_VERBOSE
329 flac_fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients: data_len=%d, order=%u, lpq=%d",data_len,order,lp_quantization);
330 for(i=0;i<order;i++)
331 flac_fprintf(stderr,", q[%u]=%d",i,qlp_coeff[i]);
332 flac_fprintf(stderr,"\n");
333 #endif
334 FLAC__ASSERT(order > 0);
335
336 for(i = 0; i < data_len; i++) {
337 sumo = 0;
338 sum = 0;
339 history = data;
340 for(j = 0; j < order; j++) {
341 sum += qlp_coeff[j] * (*(--history));
342 sumo += (FLAC__int64)qlp_coeff[j] * (FLAC__int64)(*history);
343 if(sumo > 2147483647ll || sumo < -2147483648ll)
344 flac_fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients: OVERFLOW, i=%u, j=%u, c=%d, d=%d, sumo=%" PRId64 "\n",i,j,qlp_coeff[j],*history,sumo);
345 }
346 *(residual++) = *(data++) - (sum >> lp_quantization);
347 }
348
349 /* Here's a slower but clearer version:
350 for(i = 0; i < data_len; i++) {
351 sum = 0;
352 for(j = 0; j < order; j++)
353 sum += qlp_coeff[j] * data[i-j-1];
354 residual[i] = data[i] - (sum >> lp_quantization);
355 }
356 */
357 }
358 #else /* fully unrolled version for normal use */
359 {
360 int i;
361 FLAC__int32cxx . . $ FLAC__int32# sum;
362
363 FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(order > 0);
364 FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(order <= 32);
365
366 /*
367 * We do unique versions up to 12th order since that's the subset limit.
368 * Also they are roughly ordered to match frequency of occurrence to
369 * minimize branching.
370 */
371 if(order <= 12) {
372 if(order > 8) {
373 if(order > 10) {
374 if(order == 12) {
375 for(i = 0; i < (int)data_len; i++) {
376 sum = 0;
377 sum += qlp_coeff[11] * data[i-12];
378 sum += qlp_coeff[10] * data[i-11];
379 sum += qlp_coeff[9] * data[i-10];
380 sum += qlp_coeff[8] * data[i-9];
381 sum += qlp_coeff[7] * data[i-8];
382 sum += qlp_coeff[6] * data[i-7];
383 sum += qlp_coeff[5] * data[i-6];
384 sum += qlp_coeff[4] * data[i-5];
385 sum += qlp_coeff[3] * data[i-4];
386 sum += qlp_coeff[2] * data[i-3];
387 sum += qlp_coeff[1] * data[i-2];
388 sum += qlp_coeff[0] * data[i-1];
389 residual[i] = data[i] - (sum >> lp_quantization);
390 }
391 }
392 else { /* order == 11 */
393 for(i = 0; i < (int)data_len; i++) {
394 sum = 0;
395 sum += qlp_coeff[10] * data[i-11];
396 sum += qlp_coeff[9] * data[i-10];
397 sum += qlp_coeff[8] * data[i-9];
398 sum += qlp_coeff[7] * data[i-8];
399 sum += qlp_coeff[6] * data[i-7];
400 sum += qlp_coeff[5] * data[i-6];
401 sum += qlp_coeff[4] * data[i-5];
402 sum += qlp_coeff[3] * data[i-4];
403 sum += qlp_coeff[2] * data[i-3];
404 sum += qlp_coeff[1] * data[i-2];
405 sum += qlp_coeff[0] * data[i-1];
406 residual[i] = data[i] - (sum >> lp_quantization);
407 }
408 }
409 }
410 else {
411 if(order == 10) {
412 for(i = 0; i < (int)data_len; i++) {
413 sum = 0;
414 sum += qlp_coeff[9] * data[i-10];
415 sum += qlp_coeff[8] * data[i-9];
416 sum += qlp_coeff[7] * data[i-8];
417 sum += qlp_coeff[6] * data[i-7];
418 sum += qlp_coeff[5] * data[i-6];
419 sum += qlp_coeff[4] * data[i-5];
420 sum += qlp_coeff[3] * data[i-4];
421 sum += qlp_coeff[2] * data[i-3];
422 sum += qlp_coeff[1] * data[i-2];
423 sum += qlp_coeff[0] * data[i-1];
424 residual[i] = data[i] - (sum >> lp_quantization);
425 }
426 }
427 else { /* order == 9 */
428 for(i = 0; i < (int)data_len; i++) {
429 sum = 0;
430 sum += qlp_coeff[8] * data[i-9];
431 sum += qlp_coeff[7] * data[i-8];
432 sum += qlp_coeff[6] * data[i-7];
433 sum += qlp_coeff[5] * data[i-6];
434 sum += qlp_coeff[4] * data[i-5];
435 sum += qlp_coeff[3] * data[i-4];
436 sum += qlp_coeff[2] * data[i-3];
437 sum += qlp_coeff[1] * data[i-2];
438 sum += qlp_coeff[0] * data[i-1];
439 residual[i] = data[i] - (sum >> lp_quantization);
440 }
441 }
442 }
443 }
444 else if(order > 4) {
445 if(order > 6) {
446 if(order == 8) {
447 for(i = 0; i < (int)data_len; i++) {
448 sum = 0;
449 sum += qlp_coeff[7] * data[i-8];
450 sum += qlp_coeff[6] * data[i-7];
451 sum += qlp_coeff[5] * data[i-6];
452 sum += qlp_coeff[4] * data[i-5];
453 sum += qlp_coeff[3] * data[i-4];
454 sum += qlp_coeff[2] * data[i-3];
455 sum += qlp_coeff[1] * data[i-2];
456 sum += qlp_coeff[0] * data[i-1];
457 residual[i] = data[i] - (sum >> lp_quantization);
458 }
459 }
460 else { /* order == 7 */
461 for(i = 0; i < (int)data_len; i++) {
462 sum = 0;
463 sum += qlp_coeff[6] * data[i-7];
464 sum += qlp_coeff[5] * data[i-6];
465 sum += qlp_coeff[4] * data[i-5];
466 sum += qlp_coeff[3] * data[i-4];
467 sum += qlp_coeff[2] * data[i-3];
468 sum += qlp_coeff[1] * data[i-2];
469 sum += qlp_coeff[0] * data[i-1];
470 residual[i] = data[i] - (sum >> lp_quantization);
471 }
472 }
473 }
474 else {
475 if(order == 6) {
476 for(i = 0; i < (int)data_len; i++) {
477 sum = 0;
478 sum += qlp_coeff[5] * data[i-6];
479 sum += qlp_coeff[4] * data[i-5];
480 sum += qlp_coeff[3] * data[i-4];
481 sum += qlp_coeff[2] * data[i-3];
482 sum += qlp_coeff[1] * data[i-2];
483 sum += qlp_coeff[0] * data[i-1];
484 residual[i] = data[i] - (sum >> lp_quantization);
485 }
486 }
487 else { /* order == 5 */
488 for(i = 0; i < (int)data_len; i++) {
489 sum = 0;
490 sum += qlp_coeff[4] * data[i-5];
491 sum += qlp_coeff[3] * data[i-4];
492 sum += qlp_coeff[2] * data[i-3];
493 sum += qlp_coeff[1] * data[i-2];
494 sum += qlp_coeff[0] * data[i-1];
495 residual[i] = data[i] - (sum >> lp_quantization);
496 }
497 }
498 }
499 }
500 else {
501 if(order > 2) {
502 if(order == 4) {
503 for(i = 0; i < (int)data_len; i++) {
504 sum = 0;
505 sum += qlp_coeff[3] * data[i-4];
506 sum += qlp_coeff[2] * data[i-3];
507 sum += qlp_coeff[1] * data[i-2];
508 sum += qlp_coeff[0] * data[i-1];
509 residual[i] = data[i] - (sum >> lp_quantization);
510 }
511 }
512 else { /* order == 3 */
513 for(i = 0; i < (int)data_len; i++) {
514 sum = 0;
515 sum += qlp_coeff[2] * data[i-3];
516 sum += qlp_coeff[1] * data[i-2];
517 sum += qlp_coeff[0] * data[i-1];
518 residual[i] = data[i] - (sum >> lp_quantization);
519 }
520 }
521 }
522 else {
523 if(order == 2) {
524 for(i = 0; i < (int)data_len; i++) {
525 sum = 0;
526 sum += qlp_coeff[1] * data[i-2];
527 sum += qlp_coeff[0] * data[i-1];
528 residual[i] = data[i] - (sum >> lp_quantization);
529 }
530 }
531 else { /* order == 1 */
532 for(i = 0; i < (int)data_len; i++)
533 residual[i] = data[i] - ((qlp_coeff[0] * data[i-1]) >> lp_quantization);
534 }
535 }
536 }
537 }
538 else { /* order > 12 */
539 for(i = 0; i < (int)data_len; i++) {
540 sum = 0;
541 switch(order) {
542 case 32: sum += qlp_coeff[31] * data[i-32]; /* Falls through. */
543 case 31: sum += qlp_coeff[30] * data[i-31]; /* Falls through. */
544 case 30: sum += qlp_coeff[29] * data[i-30]; /* Falls through. */
545 case 29: sum += qlp_coeff[28] * data[i-29]; /* Falls through. */
546 case 28: sum += qlp_coeff[27] * data[i-28]; /* Falls through. */
547 case 27: sum += qlp_coeff[26] * data[i-27]; /* Falls through. */
548 case 26: sum += qlp_coeff[25] * data[i-26]; /* Falls through. */
549 case 25: sum += qlp_coeff[24] * data[i-25]; /* Falls through. */
550 case 24: sum += qlp_coeff[23] * data[i-24]; /* Falls through. */
551 case 23: sum += qlp_coeff[22] * data[i-23]; /* Falls through. */
552 case 22: sum += qlp_coeff[21] * data[i-22]; /* Falls through. */
553 case 21: sum += qlp_coeff[20] * data[i-21]; /* Falls through. */
554 case 20: sum += qlp_coeff[19] * data[i-20]; /* Falls through. */
555 case 19: sum += qlp_coeff[18] * data[i-19]; /* Falls through. */
556 case 18: sum += qlp_coeff[17] * data[i-18]; /* Falls through. */
557 case 17: sum += qlp_coeff[16] * data[i-17]; /* Falls through. */
558 case 16: sum += qlp_coeff[15] * data[i-16]; /* Falls through. */
559 case 15: sum += qlp_coeff[14] * data[i-15]; /* Falls through. */
560 case 14: sum += qlp_coeff[13] * data[i-14]; /* Falls through. */
561 case 13: sum += qlp_coeff[12] * data[i-13];
562 sum += qlp_coeff[11] * data[i-12];
563 sum += qlp_coeff[10] * data[i-11];
564 sum += qlp_coeff[ 9] * data[i-10];
565 sum += qlp_coeff[ 8] * data[i- 9];
566 sum += qlp_coeff[ 7] * data[i- 8];
567 sum += qlp_coeff[ 6] * data[i- 7];
568 sum += qlp_coeff[ 5] * data[i- 6];
569 sum += qlp_coeff[ 4] * data[i- 5];
570 sum += qlp_coeff[ 3] * data[i- 4];
571 sum += qlp_coeff[ 2] * data[i- 3];
572 sum += qlp_coeff[ 1] * data[i- 2];
573 sum += qlp_coeff[ 0] * data[i- 1];
574 }
575 residual[i] = data[i] - (sum >> lp_quantization);
576 }
577 }
578 }
579 #endif
580
581 void FLAC__lpc_compute_residual_from_qlp_coefficients_widecxx . . $ FLAC__lpc_compute_residual_from_qlp_coefficients_wide(6941aaaa339379f8).(const FLAC__int32cxx . . $ FLAC__int32# * flac_restrictcxx . . $ `external/flac/flac_share_compat.h:97:9`! data, uint32_tcxx . . $ uint32_t# data_len, const FLAC__int32cxx . . $ FLAC__int32# * flac_restrictcxx . . $ `external/flac/flac_share_compat.h:97:9`! qlp_coeff, uint32_tcxx . . $ uint32_t# order, int lp_quantization, FLAC__int32cxx . . $ FLAC__int32# * flac_restrictcxx . . $ `external/flac/flac_share_compat.h:97:9`! residual)
582 #if defined(FLAC__OVERFLOW_DETECT) || !defined(FLAC__LPC_UNROLLED_FILTER_LOOPScxx . . $ `external/flac/flac_lpc.c:51:9`!)
583 {
584 uint32_t i, j;
585 FLAC__int64 sum;
586 const FLAC__int32 *history;
587
588 #ifdef FLAC__OVERFLOW_DETECT_VERBOSE
589 flac_fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients_wide: data_len=%d, order=%u, lpq=%d",data_len,order,lp_quantization);
590 for(i=0;i<order;i++)
591 flac_fprintf(stderr,", q[%u]=%d",i,qlp_coeff[i]);
592 flac_fprintf(stderr,"\n");
593 #endif
594 FLAC__ASSERT(order > 0);
595
596 for(i = 0; i < data_len; i++) {
597 sum = 0;
598 history = data;
599 for(j = 0; j < order; j++)
600 sum += (FLAC__int64)qlp_coeff[j] * (FLAC__int64)(*(--history));
601 if(FLAC__bitmath_silog2((FLAC__int64)(*data) - (sum >> lp_quantization)) > 32) {
602 flac_fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients_wide: OVERFLOW, i=%u, data=%d, sum=%" PRId64 ", residual=%" PRId64 "\n", i, *data, (int64_t)(sum >> lp_quantization), ((FLAC__int64)(*data) - (sum >> lp_quantization)));
603 break;
604 }
605 *(residual++) = *(data++) - (FLAC__int32)(sum >> lp_quantization);
606 }
607 }
608 #else /* fully unrolled version for normal use */
609 {
610 int i;
611 FLAC__int64cxx . . $ FLAC__int64# sum;
612
613 FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(order > 0);
614 FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(order <= 32);
615
616 /*
617 * We do unique versions up to 12th order since that's the subset limit.
618 * Also they are roughly ordered to match frequency of occurrence to
619 * minimize branching.
620 */
621 if(order <= 12) {
622 if(order > 8) {
623 if(order > 10) {
624 if(order == 12) {
625 for(i = 0; i < (int)data_len; i++) {
626 sum = 0;
627 sum += qlp_coeff[11] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-12];
628 sum += qlp_coeff[10] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-11];
629 sum += qlp_coeff[9] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-10];
630 sum += qlp_coeff[8] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-9];
631 sum += qlp_coeff[7] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-8];
632 sum += qlp_coeff[6] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-7];
633 sum += qlp_coeff[5] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-6];
634 sum += qlp_coeff[4] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-5];
635 sum += qlp_coeff[3] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-4];
636 sum += qlp_coeff[2] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-3];
637 sum += qlp_coeff[1] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-2];
638 sum += qlp_coeff[0] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-1];
639 residual[i] = data[i] - (sum >> lp_quantization);
640 }
641 }
642 else { /* order == 11 */
643 for(i = 0; i < (int)data_len; i++) {
644 sum = 0;
645 sum += qlp_coeff[10] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-11];
646 sum += qlp_coeff[9] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-10];
647 sum += qlp_coeff[8] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-9];
648 sum += qlp_coeff[7] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-8];
649 sum += qlp_coeff[6] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-7];
650 sum += qlp_coeff[5] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-6];
651 sum += qlp_coeff[4] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-5];
652 sum += qlp_coeff[3] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-4];
653 sum += qlp_coeff[2] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-3];
654 sum += qlp_coeff[1] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-2];
655 sum += qlp_coeff[0] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-1];
656 residual[i] = data[i] - (sum >> lp_quantization);
657 }
658 }
659 }
660 else {
661 if(order == 10) {
662 for(i = 0; i < (int)data_len; i++) {
663 sum = 0;
664 sum += qlp_coeff[9] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-10];
665 sum += qlp_coeff[8] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-9];
666 sum += qlp_coeff[7] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-8];
667 sum += qlp_coeff[6] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-7];
668 sum += qlp_coeff[5] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-6];
669 sum += qlp_coeff[4] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-5];
670 sum += qlp_coeff[3] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-4];
671 sum += qlp_coeff[2] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-3];
672 sum += qlp_coeff[1] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-2];
673 sum += qlp_coeff[0] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-1];
674 residual[i] = data[i] - (sum >> lp_quantization);
675 }
676 }
677 else { /* order == 9 */
678 for(i = 0; i < (int)data_len; i++) {
679 sum = 0;
680 sum += qlp_coeff[8] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-9];
681 sum += qlp_coeff[7] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-8];
682 sum += qlp_coeff[6] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-7];
683 sum += qlp_coeff[5] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-6];
684 sum += qlp_coeff[4] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-5];
685 sum += qlp_coeff[3] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-4];
686 sum += qlp_coeff[2] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-3];
687 sum += qlp_coeff[1] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-2];
688 sum += qlp_coeff[0] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-1];
689 residual[i] = data[i] - (sum >> lp_quantization);
690 }
691 }
692 }
693 }
694 else if(order > 4) {
695 if(order > 6) {
696 if(order == 8) {
697 for(i = 0; i < (int)data_len; i++) {
698 sum = 0;
699 sum += qlp_coeff[7] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-8];
700 sum += qlp_coeff[6] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-7];
701 sum += qlp_coeff[5] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-6];
702 sum += qlp_coeff[4] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-5];
703 sum += qlp_coeff[3] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-4];
704 sum += qlp_coeff[2] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-3];
705 sum += qlp_coeff[1] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-2];
706 sum += qlp_coeff[0] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-1];
707 residual[i] = data[i] - (sum >> lp_quantization);
708 }
709 }
710 else { /* order == 7 */
711 for(i = 0; i < (int)data_len; i++) {
712 sum = 0;
713 sum += qlp_coeff[6] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-7];
714 sum += qlp_coeff[5] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-6];
715 sum += qlp_coeff[4] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-5];
716 sum += qlp_coeff[3] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-4];
717 sum += qlp_coeff[2] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-3];
718 sum += qlp_coeff[1] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-2];
719 sum += qlp_coeff[0] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-1];
720 residual[i] = data[i] - (sum >> lp_quantization);
721 }
722 }
723 }
724 else {
725 if(order == 6) {
726 for(i = 0; i < (int)data_len; i++) {
727 sum = 0;
728 sum += qlp_coeff[5] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-6];
729 sum += qlp_coeff[4] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-5];
730 sum += qlp_coeff[3] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-4];
731 sum += qlp_coeff[2] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-3];
732 sum += qlp_coeff[1] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-2];
733 sum += qlp_coeff[0] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-1];
734 residual[i] = data[i] - (sum >> lp_quantization);
735 }
736 }
737 else { /* order == 5 */
738 for(i = 0; i < (int)data_len; i++) {
739 sum = 0;
740 sum += qlp_coeff[4] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-5];
741 sum += qlp_coeff[3] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-4];
742 sum += qlp_coeff[2] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-3];
743 sum += qlp_coeff[1] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-2];
744 sum += qlp_coeff[0] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-1];
745 residual[i] = data[i] - (sum >> lp_quantization);
746 }
747 }
748 }
749 }
750 else {
751 if(order > 2) {
752 if(order == 4) {
753 for(i = 0; i < (int)data_len; i++) {
754 sum = 0;
755 sum += qlp_coeff[3] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-4];
756 sum += qlp_coeff[2] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-3];
757 sum += qlp_coeff[1] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-2];
758 sum += qlp_coeff[0] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-1];
759 residual[i] = data[i] - (sum >> lp_quantization);
760 }
761 }
762 else { /* order == 3 */
763 for(i = 0; i < (int)data_len; i++) {
764 sum = 0;
765 sum += qlp_coeff[2] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-3];
766 sum += qlp_coeff[1] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-2];
767 sum += qlp_coeff[0] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-1];
768 residual[i] = data[i] - (sum >> lp_quantization);
769 }
770 }
771 }
772 else {
773 if(order == 2) {
774 for(i = 0; i < (int)data_len; i++) {
775 sum = 0;
776 sum += qlp_coeff[1] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-2];
777 sum += qlp_coeff[0] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-1];
778 residual[i] = data[i] - (sum >> lp_quantization);
779 }
780 }
781 else { /* order == 1 */
782 for(i = 0; i < (int)data_len; i++)
783 residual[i] = data[i] - ((qlp_coeff[0] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-1]) >> lp_quantization);
784 }
785 }
786 }
787 }
788 else { /* order > 12 */
789 for(i = 0; i < (int)data_len; i++) {
790 sum = 0;
791 switch(order) {
792 case 32: sum += qlp_coeff[31] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-32]; /* Falls through. */
793 case 31: sum += qlp_coeff[30] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-31]; /* Falls through. */
794 case 30: sum += qlp_coeff[29] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-30]; /* Falls through. */
795 case 29: sum += qlp_coeff[28] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-29]; /* Falls through. */
796 case 28: sum += qlp_coeff[27] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-28]; /* Falls through. */
797 case 27: sum += qlp_coeff[26] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-27]; /* Falls through. */
798 case 26: sum += qlp_coeff[25] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-26]; /* Falls through. */
799 case 25: sum += qlp_coeff[24] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-25]; /* Falls through. */
800 case 24: sum += qlp_coeff[23] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-24]; /* Falls through. */
801 case 23: sum += qlp_coeff[22] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-23]; /* Falls through. */
802 case 22: sum += qlp_coeff[21] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-22]; /* Falls through. */
803 case 21: sum += qlp_coeff[20] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-21]; /* Falls through. */
804 case 20: sum += qlp_coeff[19] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-20]; /* Falls through. */
805 case 19: sum += qlp_coeff[18] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-19]; /* Falls through. */
806 case 18: sum += qlp_coeff[17] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-18]; /* Falls through. */
807 case 17: sum += qlp_coeff[16] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-17]; /* Falls through. */
808 case 16: sum += qlp_coeff[15] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-16]; /* Falls through. */
809 case 15: sum += qlp_coeff[14] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-15]; /* Falls through. */
810 case 14: sum += qlp_coeff[13] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-14]; /* Falls through. */
811 case 13: sum += qlp_coeff[12] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-13];
812 sum += qlp_coeff[11] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-12];
813 sum += qlp_coeff[10] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-11];
814 sum += qlp_coeff[ 9] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-10];
815 sum += qlp_coeff[ 8] * (FLAC__int64cxx . . $ FLAC__int64#)data[i- 9];
816 sum += qlp_coeff[ 7] * (FLAC__int64cxx . . $ FLAC__int64#)data[i- 8];
817 sum += qlp_coeff[ 6] * (FLAC__int64cxx . . $ FLAC__int64#)data[i- 7];
818 sum += qlp_coeff[ 5] * (FLAC__int64cxx . . $ FLAC__int64#)data[i- 6];
819 sum += qlp_coeff[ 4] * (FLAC__int64cxx . . $ FLAC__int64#)data[i- 5];
820 sum += qlp_coeff[ 3] * (FLAC__int64cxx . . $ FLAC__int64#)data[i- 4];
821 sum += qlp_coeff[ 2] * (FLAC__int64cxx . . $ FLAC__int64#)data[i- 3];
822 sum += qlp_coeff[ 1] * (FLAC__int64cxx . . $ FLAC__int64#)data[i- 2];
823 sum += qlp_coeff[ 0] * (FLAC__int64cxx . . $ FLAC__int64#)data[i- 1];
824 }
825 residual[i] = data[i] - (sum >> lp_quantization);
826 }
827 }
828 }
829 #endif
830
831 FLAC__boolcxx . . $ FLAC__bool# FLAC__lpc_compute_residual_from_qlp_coefficients_limit_residualcxx . . $ FLAC__lpc_compute_residual_from_qlp_coefficients_limit_residual(d276d4d9b3e1b9ba).(const FLAC__int32cxx . . $ FLAC__int32# * flac_restrictcxx . . $ `external/flac/flac_share_compat.h:97:9`! data, uint32_tcxx . . $ uint32_t# data_len, const FLAC__int32cxx . . $ FLAC__int32# * flac_restrictcxx . . $ `external/flac/flac_share_compat.h:97:9`! qlp_coeff, uint32_tcxx . . $ uint32_t# order, int lp_quantization, FLAC__int32cxx . . $ FLAC__int32# * flac_restrictcxx . . $ `external/flac/flac_share_compat.h:97:9`! residual)
832 {
833 int i;
834 FLAC__int64cxx . . $ FLAC__int64# sum, residual_to_check;
835
836 FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(order > 0);
837 FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(order <= 32);
838
839 for(i = 0; i < (int)data_len; i++) {
840 sum = 0;
841 switch(order) {
842 case 32: sum += qlp_coeff[31] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-32]; /* Falls through. */
843 case 31: sum += qlp_coeff[30] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-31]; /* Falls through. */
844 case 30: sum += qlp_coeff[29] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-30]; /* Falls through. */
845 case 29: sum += qlp_coeff[28] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-29]; /* Falls through. */
846 case 28: sum += qlp_coeff[27] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-28]; /* Falls through. */
847 case 27: sum += qlp_coeff[26] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-27]; /* Falls through. */
848 case 26: sum += qlp_coeff[25] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-26]; /* Falls through. */
849 case 25: sum += qlp_coeff[24] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-25]; /* Falls through. */
850 case 24: sum += qlp_coeff[23] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-24]; /* Falls through. */
851 case 23: sum += qlp_coeff[22] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-23]; /* Falls through. */
852 case 22: sum += qlp_coeff[21] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-22]; /* Falls through. */
853 case 21: sum += qlp_coeff[20] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-21]; /* Falls through. */
854 case 20: sum += qlp_coeff[19] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-20]; /* Falls through. */
855 case 19: sum += qlp_coeff[18] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-19]; /* Falls through. */
856 case 18: sum += qlp_coeff[17] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-18]; /* Falls through. */
857 case 17: sum += qlp_coeff[16] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-17]; /* Falls through. */
858 case 16: sum += qlp_coeff[15] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-16]; /* Falls through. */
859 case 15: sum += qlp_coeff[14] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-15]; /* Falls through. */
860 case 14: sum += qlp_coeff[13] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-14]; /* Falls through. */
861 case 13: sum += qlp_coeff[12] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-13]; /* Falls through. */
862 case 12: sum += qlp_coeff[11] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-12]; /* Falls through. */
863 case 11: sum += qlp_coeff[10] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-11]; /* Falls through. */
864 case 10: sum += qlp_coeff[ 9] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-10]; /* Falls through. */
865 case 9: sum += qlp_coeff[ 8] * (FLAC__int64cxx . . $ FLAC__int64#)data[i- 9]; /* Falls through. */
866 case 8: sum += qlp_coeff[ 7] * (FLAC__int64cxx . . $ FLAC__int64#)data[i- 8]; /* Falls through. */
867 case 7: sum += qlp_coeff[ 6] * (FLAC__int64cxx . . $ FLAC__int64#)data[i- 7]; /* Falls through. */
868 case 6: sum += qlp_coeff[ 5] * (FLAC__int64cxx . . $ FLAC__int64#)data[i- 6]; /* Falls through. */
869 case 5: sum += qlp_coeff[ 4] * (FLAC__int64cxx . . $ FLAC__int64#)data[i- 5]; /* Falls through. */
870 case 4: sum += qlp_coeff[ 3] * (FLAC__int64cxx . . $ FLAC__int64#)data[i- 4]; /* Falls through. */
871 case 3: sum += qlp_coeff[ 2] * (FLAC__int64cxx . . $ FLAC__int64#)data[i- 3]; /* Falls through. */
872 case 2: sum += qlp_coeff[ 1] * (FLAC__int64cxx . . $ FLAC__int64#)data[i- 2]; /* Falls through. */
873 case 1: sum += qlp_coeff[ 0] * (FLAC__int64cxx . . $ FLAC__int64#)data[i- 1];
874 }
875 residual_to_check = data[i] - (sum >> lp_quantization);
876 /* residual must not be INT32_MIN because abs(INT32_MIN) is undefined */
877 if(residual_to_check <= INT32_MINcxx . . $ `<external>/3415975807581488833/stdint.h:107:10`! || residual_to_check > INT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:112:10`!)
878 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
879 else
880 residual[i] = residual_to_check;
881 }
882 return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
883 }
884
885 FLAC__boolcxx . . $ FLAC__bool# FLAC__lpc_compute_residual_from_qlp_coefficients_limit_residual_33bitcxx . . $ FLAC__lpc_compute_residual_from_qlp_coefficients_limit_residual_33bit(bdb3437c885c76ea).(const FLAC__int64cxx . . $ FLAC__int64# * flac_restrictcxx . . $ `external/flac/flac_share_compat.h:97:9`! data, uint32_tcxx . . $ uint32_t# data_len, const FLAC__int32cxx . . $ FLAC__int32# * flac_restrictcxx . . $ `external/flac/flac_share_compat.h:97:9`! qlp_coeff, uint32_tcxx . . $ uint32_t# order, int lp_quantization, FLAC__int32cxx . . $ FLAC__int32# * flac_restrictcxx . . $ `external/flac/flac_share_compat.h:97:9`! residual)
886 {
887 int i;
888 FLAC__int64cxx . . $ FLAC__int64# sum, residual_to_check;
889
890 FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(order > 0);
891 FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(order <= 32);
892
893 for(i = 0; i < (int)data_len; i++) {
894 sum = 0;
895 switch(order) {
896 case 32: sum += qlp_coeff[31] * data[i-32]; /* Falls through. */
897 case 31: sum += qlp_coeff[30] * data[i-31]; /* Falls through. */
898 case 30: sum += qlp_coeff[29] * data[i-30]; /* Falls through. */
899 case 29: sum += qlp_coeff[28] * data[i-29]; /* Falls through. */
900 case 28: sum += qlp_coeff[27] * data[i-28]; /* Falls through. */
901 case 27: sum += qlp_coeff[26] * data[i-27]; /* Falls through. */
902 case 26: sum += qlp_coeff[25] * data[i-26]; /* Falls through. */
903 case 25: sum += qlp_coeff[24] * data[i-25]; /* Falls through. */
904 case 24: sum += qlp_coeff[23] * data[i-24]; /* Falls through. */
905 case 23: sum += qlp_coeff[22] * data[i-23]; /* Falls through. */
906 case 22: sum += qlp_coeff[21] * data[i-22]; /* Falls through. */
907 case 21: sum += qlp_coeff[20] * data[i-21]; /* Falls through. */
908 case 20: sum += qlp_coeff[19] * data[i-20]; /* Falls through. */
909 case 19: sum += qlp_coeff[18] * data[i-19]; /* Falls through. */
910 case 18: sum += qlp_coeff[17] * data[i-18]; /* Falls through. */
911 case 17: sum += qlp_coeff[16] * data[i-17]; /* Falls through. */
912 case 16: sum += qlp_coeff[15] * data[i-16]; /* Falls through. */
913 case 15: sum += qlp_coeff[14] * data[i-15]; /* Falls through. */
914 case 14: sum += qlp_coeff[13] * data[i-14]; /* Falls through. */
915 case 13: sum += qlp_coeff[12] * data[i-13]; /* Falls through. */
916 case 12: sum += qlp_coeff[11] * data[i-12]; /* Falls through. */
917 case 11: sum += qlp_coeff[10] * data[i-11]; /* Falls through. */
918 case 10: sum += qlp_coeff[ 9] * data[i-10]; /* Falls through. */
919 case 9: sum += qlp_coeff[ 8] * data[i- 9]; /* Falls through. */
920 case 8: sum += qlp_coeff[ 7] * data[i- 8]; /* Falls through. */
921 case 7: sum += qlp_coeff[ 6] * data[i- 7]; /* Falls through. */
922 case 6: sum += qlp_coeff[ 5] * data[i- 6]; /* Falls through. */
923 case 5: sum += qlp_coeff[ 4] * data[i- 5]; /* Falls through. */
924 case 4: sum += qlp_coeff[ 3] * data[i- 4]; /* Falls through. */
925 case 3: sum += qlp_coeff[ 2] * data[i- 3]; /* Falls through. */
926 case 2: sum += qlp_coeff[ 1] * data[i- 2]; /* Falls through. */
927 case 1: sum += qlp_coeff[ 0] * data[i- 1];
928 }
929 residual_to_check = data[i] - (sum >> lp_quantization);
930 /* residual must not be INT32_MIN because abs(INT32_MIN) is undefined */
931 if(residual_to_check <= INT32_MINcxx . . $ `<external>/3415975807581488833/stdint.h:107:10`! || residual_to_check > INT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:112:10`!)
932 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
933 else
934 residual[i] = residual_to_check;
935 }
936 return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
937 }
938
939 #endif /* !defined FLAC__INTEGER_ONLY_LIBRARY */
940
941 FLAC__uint64cxx . . $ FLAC__uint64# FLAC__lpc_max_prediction_value_before_shiftcxx . . $ FLAC__lpc_max_prediction_value_before_shift(9e00287f8d149846).(uint32_tcxx . . $ uint32_t# subframe_bps, const FLAC__int32cxx . . $ FLAC__int32# * flac_restrictcxx . . $ `external/flac/flac_share_compat.h:97:9`! qlp_coeff, uint32_tcxx . . $ uint32_t# order)
942 {
943 FLAC__uint64cxx . . $ FLAC__uint64# max_abs_sample_value = (FLAC__uint64cxx . . $ FLAC__uint64#)(1) << (subframe_bps - 1);
944 FLAC__uint32cxx . . $ FLAC__uint32# abs_sum_of_qlp_coeff = 0;
945 uint32_tcxx . . $ uint32_t# i;
946 for(i = 0; i < order; i++)
947 abs_sum_of_qlp_coeff += abscxx . . $ abs(7864480464b09eea).(qlp_coeff[i]);
948 return max_abs_sample_value * abs_sum_of_qlp_coeff;
949 }
950
951 uint32_tcxx . . $ uint32_t# FLAC__lpc_max_prediction_before_shift_bpscxx . . $ FLAC__lpc_max_prediction_before_shift_bps(13291d28cd0ecc60).(uint32_tcxx . . $ uint32_t# subframe_bps, const FLAC__int32cxx . . $ FLAC__int32# * flac_restrictcxx . . $ `external/flac/flac_share_compat.h:97:9`! qlp_coeff, uint32_tcxx . . $ uint32_t# order)
952 {
953 /* This used to be subframe_bps + qlp_coeff_precision + FLAC__bitmath_ilog2(order)
954 * but that treats both the samples as well as the predictor as unknown. The
955 * predictor is known however, so taking the log2 of the sum of the absolute values
956 * of all coefficients is a more accurate representation of the predictor */
957 return FLAC__bitmath_silog2cxx . . $ FLAC__bitmath_silog2(bd267e0bd5a0c68b).(FLAC__lpc_max_prediction_value_before_shiftcxx . . $ FLAC__lpc_max_prediction_value_before_shift(9e00287f8d149846).(subframe_bps, qlp_coeff, order));
958 }
959
960
961 uint32_tcxx . . $ uint32_t# FLAC__lpc_max_residual_bpscxx . . $ FLAC__lpc_max_residual_bps(ecf149867fd69ab7).(uint32_tcxx . . $ uint32_t# subframe_bps, const FLAC__int32cxx . . $ FLAC__int32# * flac_restrictcxx . . $ `external/flac/flac_share_compat.h:97:9`! qlp_coeff, uint32_tcxx . . $ uint32_t# order, int lp_quantization)
962 {
963 FLAC__uint64cxx . . $ FLAC__uint64# max_abs_sample_value = (FLAC__uint64cxx . . $ FLAC__uint64#)(1) << (subframe_bps - 1);
964 FLAC__uint64cxx . . $ FLAC__uint64# max_prediction_value_after_shift = -1 * ((-1 * (FLAC__int64cxx . . $ FLAC__int64#)FLAC__lpc_max_prediction_value_before_shiftcxx . . $ FLAC__lpc_max_prediction_value_before_shift(9e00287f8d149846).(subframe_bps, qlp_coeff, order)) >> lp_quantization);
965 FLAC__uint64cxx . . $ FLAC__uint64# max_residual_value = max_abs_sample_value + max_prediction_value_after_shift;
966 return FLAC__bitmath_silog2cxx . . $ FLAC__bitmath_silog2(bd267e0bd5a0c68b).(max_residual_value);
967 }
968
969 #if defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION) && !defined(FUZZING_BUILD_MODE_FLAC_SANITIZE_SIGNED_INTEGER_OVERFLOW)
970 /* The attribute below is to silence the undefined sanitizer of oss-fuzz.
971 * Because fuzzing feeds bogus predictors and residual samples to the
972 * decoder, having overflows in this section is unavoidable. Also,
973 * because the calculated values are audio path only, there is no
974 * potential for security problems */
975 __attribute__((no_sanitize("signed-integer-overflow")))
976 #endif
977 void FLAC__lpc_restore_signalcxx . . $ FLAC__lpc_restore_signal(6941aaaa339379f8).(const FLAC__int32cxx . . $ FLAC__int32# * flac_restrictcxx . . $ `external/flac/flac_share_compat.h:97:9`! residual, uint32_tcxx . . $ uint32_t# data_len, const FLAC__int32cxx . . $ FLAC__int32# * flac_restrictcxx . . $ `external/flac/flac_share_compat.h:97:9`! qlp_coeff, uint32_tcxx . . $ uint32_t# order, int lp_quantization, FLAC__int32cxx . . $ FLAC__int32# * flac_restrictcxx . . $ `external/flac/flac_share_compat.h:97:9`! data)
978 #if defined(FLAC__OVERFLOW_DETECT) || !defined(FLAC__LPC_UNROLLED_FILTER_LOOPScxx . . $ `external/flac/flac_lpc.c:51:9`!)
979 {
980 FLAC__int64 sumo;
981 uint32_t i, j;
982 FLAC__int32 sum;
983 const FLAC__int32 *r = residual, *history;
984
985 #ifdef FLAC__OVERFLOW_DETECT_VERBOSE
986 flac_fprintf(stderr,"FLAC__lpc_restore_signal: data_len=%d, order=%u, lpq=%d",data_len,order,lp_quantization);
987 for(i=0;i<order;i++)
988 flac_fprintf(stderr,", q[%u]=%d",i,qlp_coeff[i]);
989 flac_fprintf(stderr,"\n");
990 #endif
991 FLAC__ASSERT(order > 0);
992
993 for(i = 0; i < data_len; i++) {
994 sumo = 0;
995 sum = 0;
996 history = data;
997 for(j = 0; j < order; j++) {
998 sum += qlp_coeff[j] * (*(--history));
999 sumo += (FLAC__int64)qlp_coeff[j] * (FLAC__int64)(*history);
1000 #ifdef FLAC__OVERFLOW_DETECT
1001 if(sumo > 2147483647ll || sumo < -2147483648ll)
1002 flac_fprintf(stderr,"FLAC__lpc_restore_signal: OVERFLOW, i=%u, j=%u, c=%d, d=%d, sumo=%" PRId64 "\n",i,j,qlp_coeff[j],*history,sumo);
1003 #endif
1004 }
1005 *(data++) = *(r++) + (sum >> lp_quantization);
1006 }
1007
1008 /* Here's a slower but clearer version:
1009 for(i = 0; i < data_len; i++) {
1010 sum = 0;
1011 for(j = 0; j < order; j++)
1012 sum += qlp_coeff[j] * data[i-j-1];
1013 data[i] = residual[i] + (sum >> lp_quantization);
1014 }
1015 */
1016 }
1017 #else /* fully unrolled version for normal use */
1018 {
1019 int i;
1020 FLAC__int32cxx . . $ FLAC__int32# sum;
1021
1022 FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(order > 0);
1023 FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(order <= 32);
1024
1025 /*
1026 * We do unique versions up to 12th order since that's the subset limit.
1027 * Also they are roughly ordered to match frequency of occurrence to
1028 * minimize branching.
1029 */
1030 if(order <= 12) {
1031 if(order > 8) {
1032 if(order > 10) {
1033 if(order == 12) {
1034 for(i = 0; i < (int)data_len; i++) {
1035 sum = 0;
1036 sum += qlp_coeff[11] * data[i-12];
1037 sum += qlp_coeff[10] * data[i-11];
1038 sum += qlp_coeff[9] * data[i-10];
1039 sum += qlp_coeff[8] * data[i-9];
1040 sum += qlp_coeff[7] * data[i-8];
1041 sum += qlp_coeff[6] * data[i-7];
1042 sum += qlp_coeff[5] * data[i-6];
1043 sum += qlp_coeff[4] * data[i-5];
1044 sum += qlp_coeff[3] * data[i-4];
1045 sum += qlp_coeff[2] * data[i-3];
1046 sum += qlp_coeff[1] * data[i-2];
1047 sum += qlp_coeff[0] * data[i-1];
1048 data[i] = residual[i] + (sum >> lp_quantization);
1049 }
1050 }
1051 else { /* order == 11 */
1052 for(i = 0; i < (int)data_len; i++) {
1053 sum = 0;
1054 sum += qlp_coeff[10] * data[i-11];
1055 sum += qlp_coeff[9] * data[i-10];
1056 sum += qlp_coeff[8] * data[i-9];
1057 sum += qlp_coeff[7] * data[i-8];
1058 sum += qlp_coeff[6] * data[i-7];
1059 sum += qlp_coeff[5] * data[i-6];
1060 sum += qlp_coeff[4] * data[i-5];
1061 sum += qlp_coeff[3] * data[i-4];
1062 sum += qlp_coeff[2] * data[i-3];
1063 sum += qlp_coeff[1] * data[i-2];
1064 sum += qlp_coeff[0] * data[i-1];
1065 data[i] = residual[i] + (sum >> lp_quantization);
1066 }
1067 }
1068 }
1069 else {
1070 if(order == 10) {
1071 for(i = 0; i < (int)data_len; i++) {
1072 sum = 0;
1073 sum += qlp_coeff[9] * data[i-10];
1074 sum += qlp_coeff[8] * data[i-9];
1075 sum += qlp_coeff[7] * data[i-8];
1076 sum += qlp_coeff[6] * data[i-7];
1077 sum += qlp_coeff[5] * data[i-6];
1078 sum += qlp_coeff[4] * data[i-5];
1079 sum += qlp_coeff[3] * data[i-4];
1080 sum += qlp_coeff[2] * data[i-3];
1081 sum += qlp_coeff[1] * data[i-2];
1082 sum += qlp_coeff[0] * data[i-1];
1083 data[i] = residual[i] + (sum >> lp_quantization);
1084 }
1085 }
1086 else { /* order == 9 */
1087 for(i = 0; i < (int)data_len; i++) {
1088 sum = 0;
1089 sum += qlp_coeff[8] * data[i-9];
1090 sum += qlp_coeff[7] * data[i-8];
1091 sum += qlp_coeff[6] * data[i-7];
1092 sum += qlp_coeff[5] * data[i-6];
1093 sum += qlp_coeff[4] * data[i-5];
1094 sum += qlp_coeff[3] * data[i-4];
1095 sum += qlp_coeff[2] * data[i-3];
1096 sum += qlp_coeff[1] * data[i-2];
1097 sum += qlp_coeff[0] * data[i-1];
1098 data[i] = residual[i] + (sum >> lp_quantization);
1099 }
1100 }
1101 }
1102 }
1103 else if(order > 4) {
1104 if(order > 6) {
1105 if(order == 8) {
1106 for(i = 0; i < (int)data_len; i++) {
1107 sum = 0;
1108 sum += qlp_coeff[7] * data[i-8];
1109 sum += qlp_coeff[6] * data[i-7];
1110 sum += qlp_coeff[5] * data[i-6];
1111 sum += qlp_coeff[4] * data[i-5];
1112 sum += qlp_coeff[3] * data[i-4];
1113 sum += qlp_coeff[2] * data[i-3];
1114 sum += qlp_coeff[1] * data[i-2];
1115 sum += qlp_coeff[0] * data[i-1];
1116 data[i] = residual[i] + (sum >> lp_quantization);
1117 }
1118 }
1119 else { /* order == 7 */
1120 for(i = 0; i < (int)data_len; i++) {
1121 sum = 0;
1122 sum += qlp_coeff[6] * data[i-7];
1123 sum += qlp_coeff[5] * data[i-6];
1124 sum += qlp_coeff[4] * data[i-5];
1125 sum += qlp_coeff[3] * data[i-4];
1126 sum += qlp_coeff[2] * data[i-3];
1127 sum += qlp_coeff[1] * data[i-2];
1128 sum += qlp_coeff[0] * data[i-1];
1129 data[i] = residual[i] + (sum >> lp_quantization);
1130 }
1131 }
1132 }
1133 else {
1134 if(order == 6) {
1135 for(i = 0; i < (int)data_len; i++) {
1136 sum = 0;
1137 sum += qlp_coeff[5] * data[i-6];
1138 sum += qlp_coeff[4] * data[i-5];
1139 sum += qlp_coeff[3] * data[i-4];
1140 sum += qlp_coeff[2] * data[i-3];
1141 sum += qlp_coeff[1] * data[i-2];
1142 sum += qlp_coeff[0] * data[i-1];
1143 data[i] = residual[i] + (sum >> lp_quantization);
1144 }
1145 }
1146 else { /* order == 5 */
1147 for(i = 0; i < (int)data_len; i++) {
1148 sum = 0;
1149 sum += qlp_coeff[4] * data[i-5];
1150 sum += qlp_coeff[3] * data[i-4];
1151 sum += qlp_coeff[2] * data[i-3];
1152 sum += qlp_coeff[1] * data[i-2];
1153 sum += qlp_coeff[0] * data[i-1];
1154 data[i] = residual[i] + (sum >> lp_quantization);
1155 }
1156 }
1157 }
1158 }
1159 else {
1160 if(order > 2) {
1161 if(order == 4) {
1162 for(i = 0; i < (int)data_len; i++) {
1163 sum = 0;
1164 sum += qlp_coeff[3] * data[i-4];
1165 sum += qlp_coeff[2] * data[i-3];
1166 sum += qlp_coeff[1] * data[i-2];
1167 sum += qlp_coeff[0] * data[i-1];
1168 data[i] = residual[i] + (sum >> lp_quantization);
1169 }
1170 }
1171 else { /* order == 3 */
1172 for(i = 0; i < (int)data_len; i++) {
1173 sum = 0;
1174 sum += qlp_coeff[2] * data[i-3];
1175 sum += qlp_coeff[1] * data[i-2];
1176 sum += qlp_coeff[0] * data[i-1];
1177 data[i] = residual[i] + (sum >> lp_quantization);
1178 }
1179 }
1180 }
1181 else {
1182 if(order == 2) {
1183 for(i = 0; i < (int)data_len; i++) {
1184 sum = 0;
1185 sum += qlp_coeff[1] * data[i-2];
1186 sum += qlp_coeff[0] * data[i-1];
1187 data[i] = residual[i] + (sum >> lp_quantization);
1188 }
1189 }
1190 else { /* order == 1 */
1191 for(i = 0; i < (int)data_len; i++)
1192 data[i] = residual[i] + ((qlp_coeff[0] * data[i-1]) >> lp_quantization);
1193 }
1194 }
1195 }
1196 }
1197 else { /* order > 12 */
1198 for(i = 0; i < (int)data_len; i++) {
1199 sum = 0;
1200 switch(order) {
1201 case 32: sum += qlp_coeff[31] * data[i-32]; /* Falls through. */
1202 case 31: sum += qlp_coeff[30] * data[i-31]; /* Falls through. */
1203 case 30: sum += qlp_coeff[29] * data[i-30]; /* Falls through. */
1204 case 29: sum += qlp_coeff[28] * data[i-29]; /* Falls through. */
1205 case 28: sum += qlp_coeff[27] * data[i-28]; /* Falls through. */
1206 case 27: sum += qlp_coeff[26] * data[i-27]; /* Falls through. */
1207 case 26: sum += qlp_coeff[25] * data[i-26]; /* Falls through. */
1208 case 25: sum += qlp_coeff[24] * data[i-25]; /* Falls through. */
1209 case 24: sum += qlp_coeff[23] * data[i-24]; /* Falls through. */
1210 case 23: sum += qlp_coeff[22] * data[i-23]; /* Falls through. */
1211 case 22: sum += qlp_coeff[21] * data[i-22]; /* Falls through. */
1212 case 21: sum += qlp_coeff[20] * data[i-21]; /* Falls through. */
1213 case 20: sum += qlp_coeff[19] * data[i-20]; /* Falls through. */
1214 case 19: sum += qlp_coeff[18] * data[i-19]; /* Falls through. */
1215 case 18: sum += qlp_coeff[17] * data[i-18]; /* Falls through. */
1216 case 17: sum += qlp_coeff[16] * data[i-17]; /* Falls through. */
1217 case 16: sum += qlp_coeff[15] * data[i-16]; /* Falls through. */
1218 case 15: sum += qlp_coeff[14] * data[i-15]; /* Falls through. */
1219 case 14: sum += qlp_coeff[13] * data[i-14]; /* Falls through. */
1220 case 13: sum += qlp_coeff[12] * data[i-13];
1221 sum += qlp_coeff[11] * data[i-12];
1222 sum += qlp_coeff[10] * data[i-11];
1223 sum += qlp_coeff[ 9] * data[i-10];
1224 sum += qlp_coeff[ 8] * data[i- 9];
1225 sum += qlp_coeff[ 7] * data[i- 8];
1226 sum += qlp_coeff[ 6] * data[i- 7];
1227 sum += qlp_coeff[ 5] * data[i- 6];
1228 sum += qlp_coeff[ 4] * data[i- 5];
1229 sum += qlp_coeff[ 3] * data[i- 4];
1230 sum += qlp_coeff[ 2] * data[i- 3];
1231 sum += qlp_coeff[ 1] * data[i- 2];
1232 sum += qlp_coeff[ 0] * data[i- 1];
1233 }
1234 data[i] = residual[i] + (sum >> lp_quantization);
1235 }
1236 }
1237 }
1238 #endif
1239
1240 void FLAC__lpc_restore_signal_widecxx . . $ FLAC__lpc_restore_signal_wide(6941aaaa339379f8).(const FLAC__int32cxx . . $ FLAC__int32# * flac_restrictcxx . . $ `external/flac/flac_share_compat.h:97:9`! residual, uint32_tcxx . . $ uint32_t# data_len, const FLAC__int32cxx . . $ FLAC__int32# * flac_restrictcxx . . $ `external/flac/flac_share_compat.h:97:9`! qlp_coeff, uint32_tcxx . . $ uint32_t# order, int lp_quantization, FLAC__int32cxx . . $ FLAC__int32# * flac_restrictcxx . . $ `external/flac/flac_share_compat.h:97:9`! data)
1241 #if defined(FLAC__OVERFLOW_DETECT) || !defined(FLAC__LPC_UNROLLED_FILTER_LOOPScxx . . $ `external/flac/flac_lpc.c:51:9`!)
1242 {
1243 uint32_t i, j;
1244 FLAC__int64 sum;
1245 const FLAC__int32 *r = residual, *history;
1246
1247 #ifdef FLAC__OVERFLOW_DETECT_VERBOSE
1248 flac_fprintf(stderr,"FLAC__lpc_restore_signal_wide: data_len=%d, order=%u, lpq=%d",data_len,order,lp_quantization);
1249 for(i=0;i<order;i++)
1250 flac_fprintf(stderr,", q[%u]=%d",i,qlp_coeff[i]);
1251 flac_fprintf(stderr,"\n");
1252 #endif
1253 FLAC__ASSERT(order > 0);
1254
1255 for(i = 0; i < data_len; i++) {
1256 sum = 0;
1257 history = data;
1258 for(j = 0; j < order; j++)
1259 sum += (FLAC__int64)qlp_coeff[j] * (FLAC__int64)(*(--history));
1260 #ifdef FLAC__OVERFLOW_DETECT
1261 if(FLAC__bitmath_silog2((FLAC__int64)(*r) + (sum >> lp_quantization)) > 32) {
1262 flac_fprintf(stderr,"FLAC__lpc_restore_signal_wide: OVERFLOW, i=%u, residual=%d, sum=%" PRId64 ", data=%" PRId64 "\n", i, *r, (sum >> lp_quantization), ((FLAC__int64)(*r) + (sum >> lp_quantization)));
1263 break;
1264 }
1265 #endif
1266 *(data++) = (FLAC__int32)(*(r++) + (sum >> lp_quantization));
1267 }
1268 }
1269 #else /* fully unrolled version for normal use */
1270 {
1271 int i;
1272 FLAC__int64cxx . . $ FLAC__int64# sum;
1273
1274 FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(order > 0);
1275 FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(order <= 32);
1276
1277 /*
1278 * We do unique versions up to 12th order since that's the subset limit.
1279 * Also they are roughly ordered to match frequency of occurrence to
1280 * minimize branching.
1281 */
1282 if(order <= 12) {
1283 if(order > 8) {
1284 if(order > 10) {
1285 if(order == 12) {
1286 for(i = 0; i < (int)data_len; i++) {
1287 sum = 0;
1288 sum += qlp_coeff[11] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-12];
1289 sum += qlp_coeff[10] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-11];
1290 sum += qlp_coeff[9] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-10];
1291 sum += qlp_coeff[8] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-9];
1292 sum += qlp_coeff[7] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-8];
1293 sum += qlp_coeff[6] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-7];
1294 sum += qlp_coeff[5] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-6];
1295 sum += qlp_coeff[4] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-5];
1296 sum += qlp_coeff[3] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-4];
1297 sum += qlp_coeff[2] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-3];
1298 sum += qlp_coeff[1] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-2];
1299 sum += qlp_coeff[0] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-1];
1300 data[i] = (FLAC__int32cxx . . $ FLAC__int32#) (residual[i] + (sum >> lp_quantization));
1301 }
1302 }
1303 else { /* order == 11 */
1304 for(i = 0; i < (int)data_len; i++) {
1305 sum = 0;
1306 sum += qlp_coeff[10] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-11];
1307 sum += qlp_coeff[9] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-10];
1308 sum += qlp_coeff[8] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-9];
1309 sum += qlp_coeff[7] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-8];
1310 sum += qlp_coeff[6] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-7];
1311 sum += qlp_coeff[5] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-6];
1312 sum += qlp_coeff[4] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-5];
1313 sum += qlp_coeff[3] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-4];
1314 sum += qlp_coeff[2] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-3];
1315 sum += qlp_coeff[1] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-2];
1316 sum += qlp_coeff[0] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-1];
1317 data[i] = (FLAC__int32cxx . . $ FLAC__int32#) (residual[i] + (sum >> lp_quantization));
1318 }
1319 }
1320 }
1321 else {
1322 if(order == 10) {
1323 for(i = 0; i < (int)data_len; i++) {
1324 sum = 0;
1325 sum += qlp_coeff[9] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-10];
1326 sum += qlp_coeff[8] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-9];
1327 sum += qlp_coeff[7] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-8];
1328 sum += qlp_coeff[6] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-7];
1329 sum += qlp_coeff[5] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-6];
1330 sum += qlp_coeff[4] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-5];
1331 sum += qlp_coeff[3] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-4];
1332 sum += qlp_coeff[2] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-3];
1333 sum += qlp_coeff[1] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-2];
1334 sum += qlp_coeff[0] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-1];
1335 data[i] = (FLAC__int32cxx . . $ FLAC__int32#) (residual[i] + (sum >> lp_quantization));
1336 }
1337 }
1338 else { /* order == 9 */
1339 for(i = 0; i < (int)data_len; i++) {
1340 sum = 0;
1341 sum += qlp_coeff[8] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-9];
1342 sum += qlp_coeff[7] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-8];
1343 sum += qlp_coeff[6] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-7];
1344 sum += qlp_coeff[5] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-6];
1345 sum += qlp_coeff[4] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-5];
1346 sum += qlp_coeff[3] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-4];
1347 sum += qlp_coeff[2] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-3];
1348 sum += qlp_coeff[1] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-2];
1349 sum += qlp_coeff[0] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-1];
1350 data[i] = (FLAC__int32cxx . . $ FLAC__int32#) (residual[i] + (sum >> lp_quantization));
1351 }
1352 }
1353 }
1354 }
1355 else if(order > 4) {
1356 if(order > 6) {
1357 if(order == 8) {
1358 for(i = 0; i < (int)data_len; i++) {
1359 sum = 0;
1360 sum += qlp_coeff[7] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-8];
1361 sum += qlp_coeff[6] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-7];
1362 sum += qlp_coeff[5] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-6];
1363 sum += qlp_coeff[4] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-5];
1364 sum += qlp_coeff[3] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-4];
1365 sum += qlp_coeff[2] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-3];
1366 sum += qlp_coeff[1] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-2];
1367 sum += qlp_coeff[0] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-1];
1368 data[i] = (FLAC__int32cxx . . $ FLAC__int32#) (residual[i] + (sum >> lp_quantization));
1369 }
1370 }
1371 else { /* order == 7 */
1372 for(i = 0; i < (int)data_len; i++) {
1373 sum = 0;
1374 sum += qlp_coeff[6] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-7];
1375 sum += qlp_coeff[5] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-6];
1376 sum += qlp_coeff[4] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-5];
1377 sum += qlp_coeff[3] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-4];
1378 sum += qlp_coeff[2] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-3];
1379 sum += qlp_coeff[1] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-2];
1380 sum += qlp_coeff[0] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-1];
1381 data[i] = (FLAC__int32cxx . . $ FLAC__int32#) (residual[i] + (sum >> lp_quantization));
1382 }
1383 }
1384 }
1385 else {
1386 if(order == 6) {
1387 for(i = 0; i < (int)data_len; i++) {
1388 sum = 0;
1389 sum += qlp_coeff[5] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-6];
1390 sum += qlp_coeff[4] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-5];
1391 sum += qlp_coeff[3] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-4];
1392 sum += qlp_coeff[2] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-3];
1393 sum += qlp_coeff[1] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-2];
1394 sum += qlp_coeff[0] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-1];
1395 data[i] = (FLAC__int32cxx . . $ FLAC__int32#) (residual[i] + (sum >> lp_quantization));
1396 }
1397 }
1398 else { /* order == 5 */
1399 for(i = 0; i < (int)data_len; i++) {
1400 sum = 0;
1401 sum += qlp_coeff[4] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-5];
1402 sum += qlp_coeff[3] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-4];
1403 sum += qlp_coeff[2] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-3];
1404 sum += qlp_coeff[1] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-2];
1405 sum += qlp_coeff[0] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-1];
1406 data[i] = (FLAC__int32cxx . . $ FLAC__int32#) (residual[i] + (sum >> lp_quantization));
1407 }
1408 }
1409 }
1410 }
1411 else {
1412 if(order > 2) {
1413 if(order == 4) {
1414 for(i = 0; i < (int)data_len; i++) {
1415 sum = 0;
1416 sum += qlp_coeff[3] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-4];
1417 sum += qlp_coeff[2] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-3];
1418 sum += qlp_coeff[1] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-2];
1419 sum += qlp_coeff[0] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-1];
1420 data[i] = (FLAC__int32cxx . . $ FLAC__int32#) (residual[i] + (sum >> lp_quantization));
1421 }
1422 }
1423 else { /* order == 3 */
1424 for(i = 0; i < (int)data_len; i++) {
1425 sum = 0;
1426 sum += qlp_coeff[2] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-3];
1427 sum += qlp_coeff[1] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-2];
1428 sum += qlp_coeff[0] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-1];
1429 data[i] = (FLAC__int32cxx . . $ FLAC__int32#) (residual[i] + (sum >> lp_quantization));
1430 }
1431 }
1432 }
1433 else {
1434 if(order == 2) {
1435 for(i = 0; i < (int)data_len; i++) {
1436 sum = 0;
1437 sum += qlp_coeff[1] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-2];
1438 sum += qlp_coeff[0] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-1];
1439 data[i] = (FLAC__int32cxx . . $ FLAC__int32#) (residual[i] + (sum >> lp_quantization));
1440 }
1441 }
1442 else { /* order == 1 */
1443 for(i = 0; i < (int)data_len; i++)
1444 data[i] = (FLAC__int32cxx . . $ FLAC__int32#)(residual[i] + ((qlp_coeff[0] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-1]) >> lp_quantization));
1445 }
1446 }
1447 }
1448 }
1449 else { /* order > 12 */
1450 for(i = 0; i < (int)data_len; i++) {
1451 sum = 0;
1452 switch(order) {
1453 case 32: sum += qlp_coeff[31] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-32]; /* Falls through. */
1454 case 31: sum += qlp_coeff[30] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-31]; /* Falls through. */
1455 case 30: sum += qlp_coeff[29] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-30]; /* Falls through. */
1456 case 29: sum += qlp_coeff[28] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-29]; /* Falls through. */
1457 case 28: sum += qlp_coeff[27] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-28]; /* Falls through. */
1458 case 27: sum += qlp_coeff[26] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-27]; /* Falls through. */
1459 case 26: sum += qlp_coeff[25] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-26]; /* Falls through. */
1460 case 25: sum += qlp_coeff[24] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-25]; /* Falls through. */
1461 case 24: sum += qlp_coeff[23] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-24]; /* Falls through. */
1462 case 23: sum += qlp_coeff[22] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-23]; /* Falls through. */
1463 case 22: sum += qlp_coeff[21] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-22]; /* Falls through. */
1464 case 21: sum += qlp_coeff[20] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-21]; /* Falls through. */
1465 case 20: sum += qlp_coeff[19] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-20]; /* Falls through. */
1466 case 19: sum += qlp_coeff[18] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-19]; /* Falls through. */
1467 case 18: sum += qlp_coeff[17] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-18]; /* Falls through. */
1468 case 17: sum += qlp_coeff[16] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-17]; /* Falls through. */
1469 case 16: sum += qlp_coeff[15] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-16]; /* Falls through. */
1470 case 15: sum += qlp_coeff[14] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-15]; /* Falls through. */
1471 case 14: sum += qlp_coeff[13] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-14]; /* Falls through. */
1472 case 13: sum += qlp_coeff[12] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-13];
1473 sum += qlp_coeff[11] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-12];
1474 sum += qlp_coeff[10] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-11];
1475 sum += qlp_coeff[ 9] * (FLAC__int64cxx . . $ FLAC__int64#)data[i-10];
1476 sum += qlp_coeff[ 8] * (FLAC__int64cxx . . $ FLAC__int64#)data[i- 9];
1477 sum += qlp_coeff[ 7] * (FLAC__int64cxx . . $ FLAC__int64#)data[i- 8];
1478 sum += qlp_coeff[ 6] * (FLAC__int64cxx . . $ FLAC__int64#)data[i- 7];
1479 sum += qlp_coeff[ 5] * (FLAC__int64cxx . . $ FLAC__int64#)data[i- 6];
1480 sum += qlp_coeff[ 4] * (FLAC__int64cxx . . $ FLAC__int64#)data[i- 5];
1481 sum += qlp_coeff[ 3] * (FLAC__int64cxx . . $ FLAC__int64#)data[i- 4];
1482 sum += qlp_coeff[ 2] * (FLAC__int64cxx . . $ FLAC__int64#)data[i- 3];
1483 sum += qlp_coeff[ 1] * (FLAC__int64cxx . . $ FLAC__int64#)data[i- 2];
1484 sum += qlp_coeff[ 0] * (FLAC__int64cxx . . $ FLAC__int64#)data[i- 1];
1485 }
1486 data[i] = (FLAC__int32cxx . . $ FLAC__int32#) (residual[i] + (sum >> lp_quantization));
1487 }
1488 }
1489 }
1490 #endif
1491
1492 #if defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION) && !defined(FUZZING_BUILD_MODE_FLAC_SANITIZE_SIGNED_INTEGER_OVERFLOW)
1493 /* The attribute below is to silence the undefined sanitizer of oss-fuzz.
1494 * Because fuzzing feeds bogus predictors and residual samples to the
1495 * decoder, having overflows in this section is unavoidable. Also,
1496 * because the calculated values are audio path only, there is no
1497 * potential for security problems */
1498 __attribute__((no_sanitize("signed-integer-overflow")))
1499 #endif
1500 void FLAC__lpc_restore_signal_wide_33bitcxx . . $ FLAC__lpc_restore_signal_wide_33bit(c5bb7e0cc1ee7103).(const FLAC__int32cxx . . $ FLAC__int32# * flac_restrictcxx . . $ `external/flac/flac_share_compat.h:97:9`! residual, uint32_tcxx . . $ uint32_t# data_len, const FLAC__int32cxx . . $ FLAC__int32# * flac_restrictcxx . . $ `external/flac/flac_share_compat.h:97:9`! qlp_coeff, uint32_tcxx . . $ uint32_t# order, int lp_quantization, FLAC__int64cxx . . $ FLAC__int64# * flac_restrictcxx . . $ `external/flac/flac_share_compat.h:97:9`! data)
1501 #if defined(FLAC__OVERFLOW_DETECT) || !defined(FLAC__LPC_UNROLLED_FILTER_LOOPScxx . . $ `external/flac/flac_lpc.c:51:9`!)
1502 {
1503 uint32_t i, j;
1504 FLAC__int64 sum;
1505 const FLAC__int32 *r = residual;
1506 const FLAC__int64 *history;
1507
1508 FLAC__ASSERT(order > 0);
1509
1510 for(i = 0; i < data_len; i++) {
1511 sum = 0;
1512 history = data;
1513 for(j = 0; j < order; j++)
1514 sum += (FLAC__int64)qlp_coeff[j] * (FLAC__int64)(*(--history));
1515 #ifdef FLAC__OVERFLOW_DETECT
1516 if(FLAC__bitmath_silog2((FLAC__int64)(*r) + (sum >> lp_quantization)) > 33) {
1517 flac_fprintf(stderr,"FLAC__lpc_restore_signal_33bit: OVERFLOW, i=%u, residual=%d, sum=%" PRId64 ", data=%" PRId64 "\n", i, *r, (sum >> lp_quantization), ((FLAC__int64)(*r) + (sum >> lp_quantization)));
1518 break;
1519 }
1520 #endif
1521 *(data++) = (FLAC__int64)(*(r++)) + (sum >> lp_quantization);
1522 }
1523 }
1524 #else /* unrolled version for normal use */
1525 {
1526 int i;
1527 FLAC__int64cxx . . $ FLAC__int64# sum;
1528
1529 FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(order > 0);
1530 FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(order <= 32);
1531
1532 for(i = 0; i < (int)data_len; i++) {
1533 sum = 0;
1534 switch(order) {
1535 case 32: sum += qlp_coeff[31] * data[i-32]; /* Falls through. */
1536 case 31: sum += qlp_coeff[30] * data[i-31]; /* Falls through. */
1537 case 30: sum += qlp_coeff[29] * data[i-30]; /* Falls through. */
1538 case 29: sum += qlp_coeff[28] * data[i-29]; /* Falls through. */
1539 case 28: sum += qlp_coeff[27] * data[i-28]; /* Falls through. */
1540 case 27: sum += qlp_coeff[26] * data[i-27]; /* Falls through. */
1541 case 26: sum += qlp_coeff[25] * data[i-26]; /* Falls through. */
1542 case 25: sum += qlp_coeff[24] * data[i-25]; /* Falls through. */
1543 case 24: sum += qlp_coeff[23] * data[i-24]; /* Falls through. */
1544 case 23: sum += qlp_coeff[22] * data[i-23]; /* Falls through. */
1545 case 22: sum += qlp_coeff[21] * data[i-22]; /* Falls through. */
1546 case 21: sum += qlp_coeff[20] * data[i-21]; /* Falls through. */
1547 case 20: sum += qlp_coeff[19] * data[i-20]; /* Falls through. */
1548 case 19: sum += qlp_coeff[18] * data[i-19]; /* Falls through. */
1549 case 18: sum += qlp_coeff[17] * data[i-18]; /* Falls through. */
1550 case 17: sum += qlp_coeff[16] * data[i-17]; /* Falls through. */
1551 case 16: sum += qlp_coeff[15] * data[i-16]; /* Falls through. */
1552 case 15: sum += qlp_coeff[14] * data[i-15]; /* Falls through. */
1553 case 14: sum += qlp_coeff[13] * data[i-14]; /* Falls through. */
1554 case 13: sum += qlp_coeff[12] * data[i-13]; /* Falls through. */
1555 case 12: sum += qlp_coeff[11] * data[i-12]; /* Falls through. */
1556 case 11: sum += qlp_coeff[10] * data[i-11]; /* Falls through. */
1557 case 10: sum += qlp_coeff[ 9] * data[i-10]; /* Falls through. */
1558 case 9: sum += qlp_coeff[ 8] * data[i- 9]; /* Falls through. */
1559 case 8: sum += qlp_coeff[ 7] * data[i- 8]; /* Falls through. */
1560 case 7: sum += qlp_coeff[ 6] * data[i- 7]; /* Falls through. */
1561 case 6: sum += qlp_coeff[ 5] * data[i- 6]; /* Falls through. */
1562 case 5: sum += qlp_coeff[ 4] * data[i- 5]; /* Falls through. */
1563 case 4: sum += qlp_coeff[ 3] * data[i- 4]; /* Falls through. */
1564 case 3: sum += qlp_coeff[ 2] * data[i- 3]; /* Falls through. */
1565 case 2: sum += qlp_coeff[ 1] * data[i- 2]; /* Falls through. */
1566 case 1: sum += qlp_coeff[ 0] * data[i- 1];
1567 }
1568 data[i] = residual[i] + (sum >> lp_quantization);
1569 }
1570 }
1571 #endif
1572
1573 #if defined(_MSC_VER)
1574 #pragma warning ( default : 4028 )
1575 #endif
1576
1577 #ifndef FLAC__INTEGER_ONLY_LIBRARY
1578
1579 double FLAC__lpc_compute_expected_bits_per_residual_samplecxx . . $ FLAC__lpc_compute_expected_bits_per_residual_sample(19d8e2eb71b44d09).(double lpc_error, uint32_tcxx . . $ uint32_t# total_samples)
1580 {
1581 double error_scale;
1582
1583 FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(total_samples > 0);
1584
1585 error_scale = 0.5 / (double)total_samples;
1586
1587 return FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scalecxx . . $ FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(d8e7e0733fa41c87).(lpc_error, error_scale);
1588 }
1589
1590 double FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scalecxx . . $ FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(d8e7e0733fa41c87).(double lpc_error, double error_scale)
1591 {
1592 if(lpc_error > 0.0) {
1593 double bps = (double)0.5 * log(error_scale * lpc_error) / M_LN2cxx . . $ `<external>/11263917310783833665/math.h:1119:10`!;
1594 if(bps >= 0.0)
1595 return bps;
1596 else
1597 return 0.0;
1598 }
1599 else if(lpc_error < 0.0) { /* error should not be negative but can happen due to inadequate floating-point resolution */
1600 return 1e32;
1601 }
1602 else {
1603 return 0.0;
1604 }
1605 }
1606
1607 uint32_tcxx . . $ uint32_t# FLAC__lpc_compute_best_ordercxx . . $ FLAC__lpc_compute_best_order(24abeaba6b3c016b).(const double lpc_error[], uint32_tcxx . . $ uint32_t# max_order, uint32_tcxx . . $ uint32_t# total_samples, uint32_tcxx . . $ uint32_t# overhead_bits_per_order)
1608 {
1609 uint32_tcxx . . $ uint32_t# order, indx, best_index; /* 'index' the index into lpc_error; index==order-1 since lpc_error[0] is for order==1, lpc_error[1] is for order==2, etc */
1610 double bits, best_bits, error_scale;
1611
1612 FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(max_order > 0);
1613 FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(total_samples > 0);
1614
1615 error_scale = 0.5 / (double)total_samples;
1616
1617 best_index = 0;
1618 best_bits = (uint32_tcxx . . $ uint32_t#)(-1);
1619
1620 for(indx = 0, order = 1; indx < max_order; indx++, order++) {
1621 bits = FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scalecxx . . $ FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(d8e7e0733fa41c87).(lpc_error[indx], error_scale) * (double)(total_samples - order) + (double)(order * overhead_bits_per_order);
1622 if(bits < best_bits) {
1623 best_index = indx;
1624 best_bits = bits;
1625 }
1626 }
1627
1628 return best_index+1; /* +1 since indx of lpc_error[] is order-1 */
1629 }
1630
1631 #endif /* !defined FLAC__INTEGER_ONLY_LIBRARY */