diff options
Diffstat (limited to 'apps/codecs/libFLAC/include/private/lpc.h')
-rw-r--r-- | apps/codecs/libFLAC/include/private/lpc.h | 197 |
1 files changed, 197 insertions, 0 deletions
diff --git a/apps/codecs/libFLAC/include/private/lpc.h b/apps/codecs/libFLAC/include/private/lpc.h new file mode 100644 index 0000000000..37286f5185 --- /dev/null +++ b/apps/codecs/libFLAC/include/private/lpc.h | |||
@@ -0,0 +1,197 @@ | |||
1 | /* libFLAC - Free Lossless Audio Codec library | ||
2 | * Copyright (C) 2000,2001,2002,2003,2004,2005 Josh Coalson | ||
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 | * - Neither the name of the Xiph.org Foundation nor the names of its | ||
16 | * contributors may be used to endorse or promote products derived from | ||
17 | * this software without specific prior written permission. | ||
18 | * | ||
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR | ||
23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
25 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
26 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
30 | */ | ||
31 | |||
32 | #ifndef FLAC__PRIVATE__LPC_H | ||
33 | #define FLAC__PRIVATE__LPC_H | ||
34 | |||
35 | #ifdef HAVE_CONFIG_H | ||
36 | #include <config.h> | ||
37 | #endif | ||
38 | |||
39 | #include "private/float.h" | ||
40 | #include "FLAC/format.h" | ||
41 | |||
42 | #ifndef FLAC__INTEGER_ONLY_LIBRARY | ||
43 | |||
44 | /* | ||
45 | * FLAC__lpc_compute_autocorrelation() | ||
46 | * -------------------------------------------------------------------- | ||
47 | * Compute the autocorrelation for lags between 0 and lag-1. | ||
48 | * Assumes data[] outside of [0,data_len-1] == 0. | ||
49 | * Asserts that lag > 0. | ||
50 | * | ||
51 | * IN data[0,data_len-1] | ||
52 | * IN data_len | ||
53 | * IN 0 < lag <= data_len | ||
54 | * OUT autoc[0,lag-1] | ||
55 | */ | ||
56 | void FLAC__lpc_compute_autocorrelation(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]); | ||
57 | #ifndef FLAC__NO_ASM | ||
58 | # ifdef FLAC__CPU_IA32 | ||
59 | # ifdef FLAC__HAS_NASM | ||
60 | void FLAC__lpc_compute_autocorrelation_asm_ia32(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]); | ||
61 | void FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_4(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]); | ||
62 | void FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_8(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]); | ||
63 | void FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_12(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]); | ||
64 | void FLAC__lpc_compute_autocorrelation_asm_ia32_3dnow(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]); | ||
65 | # endif | ||
66 | # endif | ||
67 | #endif | ||
68 | |||
69 | /* | ||
70 | * FLAC__lpc_compute_lp_coefficients() | ||
71 | * -------------------------------------------------------------------- | ||
72 | * Computes LP coefficients for orders 1..max_order. | ||
73 | * Do not call if autoc[0] == 0.0. This means the signal is zero | ||
74 | * and there is no point in calculating a predictor. | ||
75 | * | ||
76 | * IN autoc[0,max_order] autocorrelation values | ||
77 | * IN 0 < max_order <= FLAC__MAX_LPC_ORDER max LP order to compute | ||
78 | * OUT lp_coeff[0,max_order-1][0,max_order-1] LP coefficients for each order | ||
79 | * *** IMPORTANT: | ||
80 | * *** lp_coeff[0,max_order-1][max_order,FLAC__MAX_LPC_ORDER-1] are untouched | ||
81 | * OUT error[0,max_order-1] error for each order | ||
82 | * | ||
83 | * Example: if max_order is 9, the LP coefficients for order 9 will be | ||
84 | * in lp_coeff[8][0,8], the LP coefficients for order 8 will be | ||
85 | * in lp_coeff[7][0,7], etc. | ||
86 | */ | ||
87 | void FLAC__lpc_compute_lp_coefficients(const FLAC__real autoc[], unsigned max_order, FLAC__real lp_coeff[][FLAC__MAX_LPC_ORDER], FLAC__double error[]); | ||
88 | |||
89 | /* | ||
90 | * FLAC__lpc_quantize_coefficients() | ||
91 | * -------------------------------------------------------------------- | ||
92 | * Quantizes the LP coefficients. NOTE: precision + bits_per_sample | ||
93 | * must be less than 32 (sizeof(FLAC__int32)*8). | ||
94 | * | ||
95 | * IN lp_coeff[0,order-1] LP coefficients | ||
96 | * IN order LP order | ||
97 | * IN FLAC__MIN_QLP_COEFF_PRECISION < precision | ||
98 | * desired precision (in bits, including sign | ||
99 | * bit) of largest coefficient | ||
100 | * OUT qlp_coeff[0,order-1] quantized coefficients | ||
101 | * OUT shift # of bits to shift right to get approximated | ||
102 | * LP coefficients. NOTE: could be negative. | ||
103 | * RETURN 0 => quantization OK | ||
104 | * 1 => coefficients require too much shifting for *shift to | ||
105 | * fit in the LPC subframe header. 'shift' is unset. | ||
106 | * 2 => coefficients are all zero, which is bad. 'shift' is | ||
107 | * unset. | ||
108 | */ | ||
109 | int FLAC__lpc_quantize_coefficients(const FLAC__real lp_coeff[], unsigned order, unsigned precision, FLAC__int32 qlp_coeff[], int *shift); | ||
110 | |||
111 | /* | ||
112 | * FLAC__lpc_compute_residual_from_qlp_coefficients() | ||
113 | * -------------------------------------------------------------------- | ||
114 | * Compute the residual signal obtained from sutracting the predicted | ||
115 | * signal from the original. | ||
116 | * | ||
117 | * IN data[-order,data_len-1] original signal (NOTE THE INDICES!) | ||
118 | * IN data_len length of original signal | ||
119 | * IN qlp_coeff[0,order-1] quantized LP coefficients | ||
120 | * IN order > 0 LP order | ||
121 | * IN lp_quantization quantization of LP coefficients in bits | ||
122 | * OUT residual[0,data_len-1] residual signal | ||
123 | */ | ||
124 | void FLAC__lpc_compute_residual_from_qlp_coefficients(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]); | ||
125 | void FLAC__lpc_compute_residual_from_qlp_coefficients_wide(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]); | ||
126 | #ifndef FLAC__NO_ASM | ||
127 | # ifdef FLAC__CPU_IA32 | ||
128 | # ifdef FLAC__HAS_NASM | ||
129 | void FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]); | ||
130 | void FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32_mmx(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]); | ||
131 | # endif | ||
132 | # endif | ||
133 | #endif | ||
134 | |||
135 | #endif /* !defined FLAC__INTEGER_ONLY_LIBRARY */ | ||
136 | |||
137 | /* | ||
138 | * FLAC__lpc_restore_signal() | ||
139 | * -------------------------------------------------------------------- | ||
140 | * Restore the original signal by summing the residual and the | ||
141 | * predictor. | ||
142 | * | ||
143 | * IN residual[0,data_len-1] residual signal | ||
144 | * IN data_len length of original signal | ||
145 | * IN qlp_coeff[0,order-1] quantized LP coefficients | ||
146 | * IN order > 0 LP order | ||
147 | * IN lp_quantization quantization of LP coefficients in bits | ||
148 | * *** IMPORTANT: the caller must pass in the historical samples: | ||
149 | * IN data[-order,-1] previously-reconstructed historical samples | ||
150 | * OUT data[0,data_len-1] original signal | ||
151 | */ | ||
152 | void FLAC__lpc_restore_signal(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]); | ||
153 | void FLAC__lpc_restore_signal_wide(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]); | ||
154 | #ifndef FLAC__NO_ASM | ||
155 | # ifdef FLAC__CPU_IA32 | ||
156 | # ifdef FLAC__HAS_NASM | ||
157 | void FLAC__lpc_restore_signal_asm_ia32(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]); | ||
158 | void FLAC__lpc_restore_signal_asm_ia32_mmx(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]); | ||
159 | # endif /* FLAC__HAS_NASM */ | ||
160 | # elif defined FLAC__CPU_PPC | ||
161 | void FLAC__lpc_restore_signal_asm_ppc_altivec_16(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]); | ||
162 | void FLAC__lpc_restore_signal_asm_ppc_altivec_16_order8(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]); | ||
163 | # endif/* FLAC__CPU_IA32 || FLAC__CPU_PPC */ | ||
164 | #endif /* FLAC__NO_ASM */ | ||
165 | |||
166 | #ifndef FLAC__INTEGER_ONLY_LIBRARY | ||
167 | |||
168 | /* | ||
169 | * FLAC__lpc_compute_expected_bits_per_residual_sample() | ||
170 | * -------------------------------------------------------------------- | ||
171 | * Compute the expected number of bits per residual signal sample | ||
172 | * based on the LP error (which is related to the residual variance). | ||
173 | * | ||
174 | * IN lpc_error >= 0.0 error returned from calculating LP coefficients | ||
175 | * IN total_samples > 0 # of samples in residual signal | ||
176 | * RETURN expected bits per sample | ||
177 | */ | ||
178 | FLAC__double FLAC__lpc_compute_expected_bits_per_residual_sample(FLAC__double lpc_error, unsigned total_samples); | ||
179 | FLAC__double FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(FLAC__double lpc_error, FLAC__double error_scale); | ||
180 | |||
181 | /* | ||
182 | * FLAC__lpc_compute_best_order() | ||
183 | * -------------------------------------------------------------------- | ||
184 | * Compute the best order from the array of signal errors returned | ||
185 | * during coefficient computation. | ||
186 | * | ||
187 | * IN lpc_error[0,max_order-1] >= 0.0 error returned from calculating LP coefficients | ||
188 | * IN max_order > 0 max LP order | ||
189 | * IN total_samples > 0 # of samples in residual signal | ||
190 | * IN bits_per_signal_sample # of bits per sample in the original signal | ||
191 | * RETURN [1,max_order] best order | ||
192 | */ | ||
193 | unsigned FLAC__lpc_compute_best_order(const FLAC__double lpc_error[], unsigned max_order, unsigned total_samples, unsigned bits_per_signal_sample); | ||
194 | |||
195 | #endif /* !defined FLAC__INTEGER_ONLY_LIBRARY */ | ||
196 | |||
197 | #endif | ||