1 /*
2 * TwinVQ decoder
3 * Copyright (c) 2009 Vitor Sessak
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_TWINVQ_H
23 #define AVCODEC_TWINVQ_H
24
25 #include <math.h>
26 #include <stdint.h>
27
33
37 };
38
44 };
45
46 #define TWINVQ_PPC_SHAPE_CB_SIZE 64
47 #define TWINVQ_PPC_SHAPE_LEN_MAX 60
48 #define TWINVQ_SUB_AMP_MAX 4500.0
49 #define TWINVQ_MULAW_MU 100.0
50 #define TWINVQ_GAIN_BITS 8
51 #define TWINVQ_AMP_MAX 13000.0
52 #define TWINVQ_SUB_GAIN_BITS 5
53 #define TWINVQ_WINDOW_TYPE_BITS 4
54 #define TWINVQ_PGAIN_MU 200
55 #define TWINVQ_LSP_COEFS_MAX 20
56 #define TWINVQ_LSP_SPLIT_MAX 4
57 #define TWINVQ_CHANNELS_MAX 2
58 #define TWINVQ_SUBBLOCKS_MAX 16
59 #define TWINVQ_BARK_N_COEF_MAX 4
60
61 /**
62 * Parameters and tables that are different for each frame type
63 */
67
68 /** number of distinct bark scale envelope values */
70
71 const int16_t *
bark_cb;
///< codebook for the bark scale envelope (BSE)
74
75 //@{
76 /** main codebooks for spectrum data */
79 //@}
80
82 };
83
87
90
93
96
100
104
105 /**
106 * Parameters and tables that are different for every combination of
107 * bitrate/sample rate
108 */
111
112 uint16_t
size;
///< frame size in samples
115
116 /* number of bits of the different LSP CB coefficients */
120
123
124 /** number of the bits for the PPC period value */
126
130
131 /** constant for peak period to peak width conversion */
134
139
141
142 // history
143 float lsp_hist[2][20];
///< LSP coefficients of the last frame
144 float bark_hist[3][2][40];
///< BSE coefficients of last frame
145
146 // bitstream parameters
153
159
161
162 // scratch buffers
164
166
168
172 int use_hist,
int ch,
float *
out,
float gain,
175 const float *shape, float *speech);
177
179
180 /** @note not speed critical, hence not optimized */
182 {
183 while (size--)
185 }
186
188 {
189 y = av_clipf(y / clip, -1, 1);
190 return clip *
FFSIGN(y) * (exp(log(1 + mu) * fabs(y)) - 1) / mu;
191 }
192
194 int *got_frame_ptr,
AVPacket *avpkt);
197
198 #endif /* AVCODEC_TWINVQ_DATA_H */