1 /*
2 * SIPR decoder for the 16k mode
3 *
4 * Copyright (c) 2008 Vladimir Voroshilov
5 * Copyright (c) 2009 Vitor Sessak
6 *
7 * This file is part of FFmpeg.
8 *
9 * FFmpeg is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * FFmpeg is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with FFmpeg; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24 #include <math.h>
25
36
38
39 /**
40 * Convert an lsf vector into an lsp vector.
41 *
42 * @param lsf input lsf vector
43 * @param lsp output lsp vector
44 */
45 static void lsf2lsp(
const float *lsf,
double *lsp)
46 {
48
51 }
52
53 static void dequant(
float *
out,
const int *idx,
const float *
const cbs[])
54 {
56
57 for (
i = 0;
i < 4;
i++)
58 memcpy(
out + 3*
i, cbs[
i] + 3*idx[
i], 3*
sizeof(
float));
59
60 memcpy(
out + 12, cbs[4] + 4*idx[4], 4*
sizeof(
float));
61 }
62
64 const int* parm, int ma_pred)
65 {
68
70
72 isp_new[
i] = (1 -
qu[ma_pred]) * isp_q[
i]
75 }
76
78 }
79
81 {
84 } else
85 return 3 *
index - 690;
86 }
87
90 {
93 pit_min, pit_max - 19);
94 return 3 * pitch_delay_min +
index - 2;
95 } else
97 }
98
101 {
106
109
112
115
118
121
125
129
130
133
135 for (
i = 0,
s = 0;
i < 30;
i++,
s += 1.0/30)
136 out_data[
i] = tmpbuf[
i] +
s * (
synth[
i] - tmpbuf[
i]);
137 }
138
139 /**
140 * Floating point version of ff_acelp_lp_decode().
141 */
143 const double *lsp_2nd, const double *lsp_prev)
144 {
147
148 /* LSP values for first subframe (3.2.5 of G.729, Equation 24) */
150 lsp_1st[
i] = (lsp_2nd[
i] + lsp_prev[
i]) * 0.5;
151
153
154 /* LSP values for second subframe (3.2.5 of G.729) */
156 }
157
158 /**
159 * Floating point version of ff_acelp_decode_gain_code().
160 */
162 float mr_energy, const float *quant_energy,
164 int subframe_size, int ma_pred_order)
165 {
167 ma_pred_order);
168
169 mr_energy = gain_corr_factor *
exp(
M_LN10 / 20. * mr_energy) /
171 return mr_energy;
172 }
173
174 #define DIVIDE_BY_3(x) ((x) * 10923 >> 15)
175
177 float *out_data)
178 {
185 float pitch_fac, gain_code;
186
188 int pitch_delay_3x;
189
191
194
196
198
200
202
205
209 float gain_corr_factor;
210 int pitch_delay_int;
211 int pitch_delay_frac;
212
215 } else
218 ctx->pitch_lag_prev);
219
221 f.pitch_fac =
FFMIN(pitch_fac, 1.0);
223 ctx->pitch_lag_prev =
f.pitch_lag;
224
226 pitch_delay_frac = pitch_delay_3x + 2 - 3*pitch_delay_int;
227
232
233
234 memset(fixed_vector, 0, sizeof(fixed_vector));
235
238
240
242 gain_code = gain_corr_factor *
247
248 ctx->energy_history[1] =
ctx->energy_history[0];
249 ctx->energy_history[0] = 20.0 *
log10f(gain_corr_factor);
250
252 fixed_vector, pitch_fac,
254
258
259 }
262
265
267
269 }
270
272 {
274
277
278 ctx->filt_mem[0] =
ctx->filt_buf[0];
279 ctx->filt_mem[1] =
ctx->filt_buf[1];
280
281 ctx->pitch_lag_prev = 180;
282 }