1 /*
2 * LPC utility functions
3 * Copyright (c) 2006 Justin Ruggles <justin.ruggles@gmail.com>
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #ifndef AVCODEC_LPC_FUNCTIONS_H
23 #define AVCODEC_LPC_FUNCTIONS_H
24
26
27 #ifndef LPC_USE_FIXED
28 #define LPC_USE_FIXED 0
29 #endif
30
31 #if LPC_USE_FIXED
34 #else
35 #ifndef LPC_SRA_R
36 #define LPC_SRA_R(x, y) (x)
37 #define LPC_MUL26(x, y) ((x) * (y))
38 #define LPC_FIXR(x) ((float)(x))
39 #endif
40
41 #ifdef LPC_USE_DOUBLE
44 #else
47 #endif
48 #endif // USE_FIXED
49
50 /**
51 * Levinson-Durbin recursion.
52 * Produce LPC coefficients from autocorrelation data.
53 */
57 {
60
62
65 err = *autoc++;
66 else {
67 err = *err_ptr;
68 }
69 }
70
71 if (
fail && (autoc[max_order - 1] == 0 || err <= 0))
72 return -1;
73
74 for( ;
i < max_order;
i++) {
76
78 for(
int j = 0; j <
i; j++)
79 r -= lpc_last[j] * autoc[
i-j-1];
80
81 if (err)
84 }
85
87
88 for(
int j = 0; j < (
i + 1) >> 1; j++) {
93 }
94
96 return -1;
97
98 lpc_last = lpc;
99 lpc += lpc_stride;
100 }
101
102 if (err_ptr)
103 *err_ptr = err;
104
105 return 0;
106 }
107
108 #endif /* AVCODEC_LPC_FUNCTIONS_H */