summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/codecs/libwmavoice/acelp_filters.c145
-rw-r--r--apps/codecs/libwmavoice/acelp_filters.h120
-rw-r--r--apps/codecs/libwmavoice/avcodec.h4044
-rw-r--r--apps/codecs/libwmavoice/avfft.c142
-rw-r--r--apps/codecs/libwmavoice/avfft.h99
-rw-r--r--apps/codecs/libwmavoice/bitstream.c341
-rw-r--r--apps/codecs/libwmavoice/celp_filters.c210
-rw-r--r--apps/codecs/libwmavoice/celp_filters.h119
-rw-r--r--apps/codecs/libwmavoice/celp_math.c208
-rw-r--r--apps/codecs/libwmavoice/celp_math.h76
-rw-r--r--apps/codecs/libwmavoice/dsputil.c4535
-rw-r--r--apps/codecs/libwmavoice/dsputil.h800
-rw-r--r--apps/codecs/libwmavoice/fft.c296
-rw-r--r--apps/codecs/libwmavoice/fft.h244
-rw-r--r--apps/codecs/libwmavoice/get_bits.h691
-rw-r--r--apps/codecs/libwmavoice/internal.h53
-rw-r--r--apps/codecs/libwmavoice/libavutil/attributes.h121
-rw-r--r--apps/codecs/libwmavoice/libavutil/avutil.h89
-rw-r--r--apps/codecs/libwmavoice/libavutil/bswap.h124
-rw-r--r--apps/codecs/libwmavoice/libavutil/common.h346
-rw-r--r--apps/codecs/libwmavoice/libavutil/internal.h234
-rw-r--r--apps/codecs/libwmavoice/libavutil/intreadwrite.h522
-rw-r--r--apps/codecs/libwmavoice/libavutil/log.c150
-rw-r--r--apps/codecs/libwmavoice/libavutil/log.h138
-rw-r--r--apps/codecs/libwmavoice/libavutil/lzo.c279
-rw-r--r--apps/codecs/libwmavoice/libavutil/lzo.h66
-rw-r--r--apps/codecs/libwmavoice/libavutil/mathematics.c181
-rw-r--r--apps/codecs/libwmavoice/libavutil/mathematics.h112
-rw-r--r--apps/codecs/libwmavoice/libavutil/mem.c176
-rw-r--r--apps/codecs/libwmavoice/libavutil/mem.h126
-rw-r--r--apps/codecs/libwmavoice/lsp.c174
-rw-r--r--apps/codecs/libwmavoice/lsp.h120
-rw-r--r--apps/codecs/libwmavoice/mdct.c234
-rw-r--r--apps/codecs/libwmavoice/put_bits.h343
-rw-r--r--apps/codecs/libwmavoice/wmavoice.c2031
-rw-r--r--apps/codecs/libwmavoice/wmavoice_data.h3259
36 files changed, 20948 insertions, 0 deletions
diff --git a/apps/codecs/libwmavoice/acelp_filters.c b/apps/codecs/libwmavoice/acelp_filters.c
new file mode 100644
index 0000000000..31f0e86f5b
--- /dev/null
+++ b/apps/codecs/libwmavoice/acelp_filters.c
@@ -0,0 +1,145 @@
1/*
2 * various filters for ACELP-based codecs
3 *
4 * Copyright (c) 2008 Vladimir Voroshilov
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23#include <inttypes.h>
24
25#include "avcodec.h"
26#include "acelp_filters.h"
27
28const int16_t ff_acelp_interp_filter[61] = { /* (0.15) */
29 29443, 28346, 25207, 20449, 14701, 8693,
30 3143, -1352, -4402, -5865, -5850, -4673,
31 -2783, -672, 1211, 2536, 3130, 2991,
32 2259, 1170, 0, -1001, -1652, -1868,
33 -1666, -1147, -464, 218, 756, 1060,
34 1099, 904, 550, 135, -245, -514,
35 -634, -602, -451, -231, 0, 191,
36 308, 340, 296, 198, 78, -36,
37 -120, -163, -165, -132, -79, -19,
38 34, 73, 91, 89, 70, 38,
39 0,
40};
41
42void ff_acelp_interpolate(int16_t* out, const int16_t* in,
43 const int16_t* filter_coeffs, int precision,
44 int frac_pos, int filter_length, int length)
45{
46 int n, i;
47
48 assert(frac_pos >= 0 && frac_pos < precision);
49
50 for (n = 0; n < length; n++) {
51 int idx = 0;
52 int v = 0x4000;
53
54 for (i = 0; i < filter_length;) {
55
56 /* The reference G.729 and AMR fixed point code performs clipping after
57 each of the two following accumulations.
58 Since clipping affects only the synthetic OVERFLOW test without
59 causing an int type overflow, it was moved outside the loop. */
60
61 /* R(x):=ac_v[-k+x]
62 v += R(n-i)*ff_acelp_interp_filter(t+6i)
63 v += R(n+i+1)*ff_acelp_interp_filter(6-t+6i) */
64
65 v += in[n + i] * filter_coeffs[idx + frac_pos];
66 idx += precision;
67 i++;
68 v += in[n - i] * filter_coeffs[idx - frac_pos];
69 }
70 if (av_clip_int16(v >> 15) != (v >> 15))
71 av_log(NULL, AV_LOG_WARNING, "overflow that would need cliping in ff_acelp_interpolate()\n");
72 out[n] = v >> 15;
73 }
74}
75
76void ff_acelp_interpolatef(float *out, const float *in,
77 const float *filter_coeffs, int precision,
78 int frac_pos, int filter_length, int length)
79{
80 int n, i;
81
82 for (n = 0; n < length; n++) {
83 int idx = 0;
84 float v = 0;
85
86 for (i = 0; i < filter_length;) {
87 v += in[n + i] * filter_coeffs[idx + frac_pos];
88 idx += precision;
89 i++;
90 v += in[n - i] * filter_coeffs[idx - frac_pos];
91 }
92 out[n] = v;
93 }
94}
95
96
97void ff_acelp_high_pass_filter(int16_t* out, int hpf_f[2],
98 const int16_t* in, int length)
99{
100 int i;
101 int tmp;
102
103 for (i = 0; i < length; i++) {
104 tmp = (hpf_f[0]* 15836LL) >> 13;
105 tmp += (hpf_f[1]* -7667LL) >> 13;
106 tmp += 7699 * (in[i] - 2*in[i-1] + in[i-2]);
107
108 /* With "+0x800" rounding, clipping is needed
109 for ALGTHM and SPEECH tests. */
110 out[i] = av_clip_int16((tmp + 0x800) >> 12);
111
112 hpf_f[1] = hpf_f[0];
113 hpf_f[0] = tmp;
114 }
115}
116
117void ff_acelp_apply_order_2_transfer_function(float *out, const float *in,
118 const float zero_coeffs[2],
119 const float pole_coeffs[2],
120 float gain, float mem[2], int n)
121{
122 int i;
123 float tmp;
124
125 for (i = 0; i < n; i++) {
126 tmp = gain * in[i] - pole_coeffs[0] * mem[0] - pole_coeffs[1] * mem[1];
127 out[i] = tmp + zero_coeffs[0] * mem[0] + zero_coeffs[1] * mem[1];
128
129 mem[1] = mem[0];
130 mem[0] = tmp;
131 }
132}
133
134void ff_tilt_compensation(float *mem, float tilt, float *samples, int size)
135{
136 float new_tilt_mem = samples[size - 1];
137 int i;
138
139 for (i = size - 1; i > 0; i--)
140 samples[i] -= tilt * samples[i - 1];
141
142 samples[0] -= tilt * *mem;
143 *mem = new_tilt_mem;
144}
145
diff --git a/apps/codecs/libwmavoice/acelp_filters.h b/apps/codecs/libwmavoice/acelp_filters.h
new file mode 100644
index 0000000000..0b1ccf4e71
--- /dev/null
+++ b/apps/codecs/libwmavoice/acelp_filters.h
@@ -0,0 +1,120 @@
1/*
2 * various filters for ACELP-based codecs
3 *
4 * Copyright (c) 2008 Vladimir Voroshilov
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23#ifndef AVCODEC_ACELP_FILTERS_H
24#define AVCODEC_ACELP_FILTERS_H
25
26#include <stdint.h>
27
28/**
29 * low-pass Finite Impulse Response filter coefficients.
30 *
31 * Hamming windowed sinc filter with cutoff freq 3/40 of the sampling freq,
32 * the coefficients are scaled by 2^15.
33 * This array only contains the right half of the filter.
34 * This filter is likely identical to the one used in G.729, though this
35 * could not be determined from the original comments with certainity.
36 */
37extern const int16_t ff_acelp_interp_filter[61];
38
39/**
40 * Generic FIR interpolation routine.
41 * @param[out] out buffer for interpolated data
42 * @param in input data
43 * @param filter_coeffs interpolation filter coefficients (0.15)
44 * @param precision sub sample factor, that is the precision of the position
45 * @param frac_pos fractional part of position [0..precision-1]
46 * @param filter_length filter length
47 * @param length length of output
48 *
49 * filter_coeffs contains coefficients of the right half of the symmetric
50 * interpolation filter. filter_coeffs[0] should the central (unpaired) coefficient.
51 * See ff_acelp_interp_filter for an example.
52 *
53 */
54void ff_acelp_interpolate(int16_t* out, const int16_t* in,
55 const int16_t* filter_coeffs, int precision,
56 int frac_pos, int filter_length, int length);
57
58/**
59 * Floating point version of ff_acelp_interpolate()
60 */
61void ff_acelp_interpolatef(float *out, const float *in,
62 const float *filter_coeffs, int precision,
63 int frac_pos, int filter_length, int length);
64
65
66/**
67 * high-pass filtering and upscaling (4.2.5 of G.729).
68 * @param[out] out output buffer for filtered speech data
69 * @param[in,out] hpf_f past filtered data from previous (2 items long)
70 * frames (-0x20000000 <= (14.13) < 0x20000000)
71 * @param in speech data to process
72 * @param length input data size
73 *
74 * out[i] = 0.93980581 * in[i] - 1.8795834 * in[i-1] + 0.93980581 * in[i-2] +
75 * 1.9330735 * out[i-1] - 0.93589199 * out[i-2]
76 *
77 * The filter has a cut-off frequency of 1/80 of the sampling freq
78 *
79 * @note Two items before the top of the out buffer must contain two items from the
80 * tail of the previous subframe.
81 *
82 * @remark It is safe to pass the same array in in and out parameters.
83 *
84 * @remark AMR uses mostly the same filter (cut-off frequency 60Hz, same formula,
85 * but constants differs in 5th sign after comma). Fortunately in
86 * fixed-point all coefficients are the same as in G.729. Thus this
87 * routine can be used for the fixed-point AMR decoder, too.
88 */
89void ff_acelp_high_pass_filter(int16_t* out, int hpf_f[2],
90 const int16_t* in, int length);
91
92/**
93 * Apply an order 2 rational transfer function in-place.
94 *
95 * @param out output buffer for filtered speech samples
96 * @param in input buffer containing speech data (may be the same as out)
97 * @param zero_coeffs z^-1 and z^-2 coefficients of the numerator
98 * @param pole_coeffs z^-1 and z^-2 coefficients of the denominator
99 * @param gain scale factor for final output
100 * @param mem intermediate values used by filter (should be 0 initially)
101 * @param n number of samples
102 */
103void ff_acelp_apply_order_2_transfer_function(float *out, const float *in,
104 const float zero_coeffs[2],
105 const float pole_coeffs[2],
106 float gain,
107 float mem[2], int n);
108
109/**
110 * Apply tilt compensation filter, 1 - tilt * z-1.
111 *
112 * @param mem pointer to the filter's state (one single float)
113 * @param tilt tilt factor
114 * @param samples array where the filter is applied
115 * @param size the size of the samples array
116 */
117void ff_tilt_compensation(float *mem, float tilt, float *samples, int size);
118
119
120#endif /* AVCODEC_ACELP_FILTERS_H */
diff --git a/apps/codecs/libwmavoice/avcodec.h b/apps/codecs/libwmavoice/avcodec.h
new file mode 100644
index 0000000000..9186bf52f3
--- /dev/null
+++ b/apps/codecs/libwmavoice/avcodec.h
@@ -0,0 +1,4044 @@
1/*
2 * copyright (c) 2001 Fabrice Bellard
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#ifndef AVCODEC_AVCODEC_H
22#define AVCODEC_AVCODEC_H
23
24/**
25 * @file
26 * external API header
27 */
28
29#include <errno.h>
30#include "libavutil/avutil.h"
31
32#define LIBAVCODEC_VERSION_MAJOR 52
33#define LIBAVCODEC_VERSION_MINOR 84
34#define LIBAVCODEC_VERSION_MICRO 3
35
36#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
37 LIBAVCODEC_VERSION_MINOR, \
38 LIBAVCODEC_VERSION_MICRO)
39#define LIBAVCODEC_VERSION AV_VERSION(LIBAVCODEC_VERSION_MAJOR, \
40 LIBAVCODEC_VERSION_MINOR, \
41 LIBAVCODEC_VERSION_MICRO)
42#define LIBAVCODEC_BUILD LIBAVCODEC_VERSION_INT
43
44#define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION)
45
46#define AV_NOPTS_VALUE INT64_C(0x8000000000000000)
47#define AV_TIME_BASE 1000000
48#define AV_TIME_BASE_Q (AVRational){1, AV_TIME_BASE}
49
50/**
51 * Identify the syntax and semantics of the bitstream.
52 * The principle is roughly:
53 * Two decoders with the same ID can decode the same streams.
54 * Two encoders with the same ID can encode compatible streams.
55 * There may be slight deviations from the principle due to implementation
56 * details.
57 *
58 * If you add a codec ID to this list, add it so that
59 * 1. no value of a existing codec ID changes (that would break ABI),
60 * 2. it is as close as possible to similar codecs.
61 */
62enum CodecID {
63 CODEC_ID_NONE,
64
65 /* video codecs */
66 CODEC_ID_MPEG1VIDEO,
67 CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decoding
68 CODEC_ID_MPEG2VIDEO_XVMC,
69 CODEC_ID_H261,
70 CODEC_ID_H263,
71 CODEC_ID_RV10,
72 CODEC_ID_RV20,
73 CODEC_ID_MJPEG,
74 CODEC_ID_MJPEGB,
75 CODEC_ID_LJPEG,
76 CODEC_ID_SP5X,
77 CODEC_ID_JPEGLS,
78 CODEC_ID_MPEG4,
79 CODEC_ID_RAWVIDEO,
80 CODEC_ID_MSMPEG4V1,
81 CODEC_ID_MSMPEG4V2,
82 CODEC_ID_MSMPEG4V3,
83 CODEC_ID_WMV1,
84 CODEC_ID_WMV2,
85 CODEC_ID_H263P,
86 CODEC_ID_H263I,
87 CODEC_ID_FLV1,
88 CODEC_ID_SVQ1,
89 CODEC_ID_SVQ3,
90 CODEC_ID_DVVIDEO,
91 CODEC_ID_HUFFYUV,
92 CODEC_ID_CYUV,
93 CODEC_ID_H264,
94 CODEC_ID_INDEO3,
95 CODEC_ID_VP3,
96 CODEC_ID_THEORA,
97 CODEC_ID_ASV1,
98 CODEC_ID_ASV2,
99 CODEC_ID_FFV1,
100 CODEC_ID_4XM,
101 CODEC_ID_VCR1,
102 CODEC_ID_CLJR,
103 CODEC_ID_MDEC,
104 CODEC_ID_ROQ,
105 CODEC_ID_INTERPLAY_VIDEO,
106 CODEC_ID_XAN_WC3,
107 CODEC_ID_XAN_WC4,
108 CODEC_ID_RPZA,
109 CODEC_ID_CINEPAK,
110 CODEC_ID_WS_VQA,
111 CODEC_ID_MSRLE,
112 CODEC_ID_MSVIDEO1,
113 CODEC_ID_IDCIN,
114 CODEC_ID_8BPS,
115 CODEC_ID_SMC,
116 CODEC_ID_FLIC,
117 CODEC_ID_TRUEMOTION1,
118 CODEC_ID_VMDVIDEO,
119 CODEC_ID_MSZH,
120 CODEC_ID_ZLIB,
121 CODEC_ID_QTRLE,
122 CODEC_ID_SNOW,
123 CODEC_ID_TSCC,
124 CODEC_ID_ULTI,
125 CODEC_ID_QDRAW,
126 CODEC_ID_VIXL,
127 CODEC_ID_QPEG,
128#if LIBAVCODEC_VERSION_MAJOR < 53
129 CODEC_ID_XVID,
130#endif
131 CODEC_ID_PNG,
132 CODEC_ID_PPM,
133 CODEC_ID_PBM,
134 CODEC_ID_PGM,
135 CODEC_ID_PGMYUV,
136 CODEC_ID_PAM,
137 CODEC_ID_FFVHUFF,
138 CODEC_ID_RV30,
139 CODEC_ID_RV40,
140 CODEC_ID_VC1,
141 CODEC_ID_WMV3,
142 CODEC_ID_LOCO,
143 CODEC_ID_WNV1,
144 CODEC_ID_AASC,
145 CODEC_ID_INDEO2,
146 CODEC_ID_FRAPS,
147 CODEC_ID_TRUEMOTION2,
148 CODEC_ID_BMP,
149 CODEC_ID_CSCD,
150 CODEC_ID_MMVIDEO,
151 CODEC_ID_ZMBV,
152 CODEC_ID_AVS,
153 CODEC_ID_SMACKVIDEO,
154 CODEC_ID_NUV,
155 CODEC_ID_KMVC,
156 CODEC_ID_FLASHSV,
157 CODEC_ID_CAVS,
158 CODEC_ID_JPEG2000,
159 CODEC_ID_VMNC,
160 CODEC_ID_VP5,
161 CODEC_ID_VP6,
162 CODEC_ID_VP6F,
163 CODEC_ID_TARGA,
164 CODEC_ID_DSICINVIDEO,
165 CODEC_ID_TIERTEXSEQVIDEO,
166 CODEC_ID_TIFF,
167 CODEC_ID_GIF,
168 CODEC_ID_FFH264,
169 CODEC_ID_DXA,
170 CODEC_ID_DNXHD,
171 CODEC_ID_THP,
172 CODEC_ID_SGI,
173 CODEC_ID_C93,
174 CODEC_ID_BETHSOFTVID,
175 CODEC_ID_PTX,
176 CODEC_ID_TXD,
177 CODEC_ID_VP6A,
178 CODEC_ID_AMV,
179 CODEC_ID_VB,
180 CODEC_ID_PCX,
181 CODEC_ID_SUNRAST,
182 CODEC_ID_INDEO4,
183 CODEC_ID_INDEO5,
184 CODEC_ID_MIMIC,
185 CODEC_ID_RL2,
186 CODEC_ID_8SVX_EXP,
187 CODEC_ID_8SVX_FIB,
188 CODEC_ID_ESCAPE124,
189 CODEC_ID_DIRAC,
190 CODEC_ID_BFI,
191 CODEC_ID_CMV,
192 CODEC_ID_MOTIONPIXELS,
193 CODEC_ID_TGV,
194 CODEC_ID_TGQ,
195 CODEC_ID_TQI,
196 CODEC_ID_AURA,
197 CODEC_ID_AURA2,
198 CODEC_ID_V210X,
199 CODEC_ID_TMV,
200 CODEC_ID_V210,
201 CODEC_ID_DPX,
202 CODEC_ID_MAD,
203 CODEC_ID_FRWU,
204 CODEC_ID_FLASHSV2,
205 CODEC_ID_CDGRAPHICS,
206 CODEC_ID_R210,
207 CODEC_ID_ANM,
208 CODEC_ID_BINKVIDEO,
209 CODEC_ID_IFF_ILBM,
210 CODEC_ID_IFF_BYTERUN1,
211 CODEC_ID_KGV1,
212 CODEC_ID_YOP,
213 CODEC_ID_VP8,
214 CODEC_ID_PICTOR,
215 CODEC_ID_ANSI,
216
217 /* various PCM "codecs" */
218 CODEC_ID_PCM_S16LE= 0x10000,
219 CODEC_ID_PCM_S16BE,
220 CODEC_ID_PCM_U16LE,
221 CODEC_ID_PCM_U16BE,
222 CODEC_ID_PCM_S8,
223 CODEC_ID_PCM_U8,
224 CODEC_ID_PCM_MULAW,
225 CODEC_ID_PCM_ALAW,
226 CODEC_ID_PCM_S32LE,
227 CODEC_ID_PCM_S32BE,
228 CODEC_ID_PCM_U32LE,
229 CODEC_ID_PCM_U32BE,
230 CODEC_ID_PCM_S24LE,
231 CODEC_ID_PCM_S24BE,
232 CODEC_ID_PCM_U24LE,
233 CODEC_ID_PCM_U24BE,
234 CODEC_ID_PCM_S24DAUD,
235 CODEC_ID_PCM_ZORK,
236 CODEC_ID_PCM_S16LE_PLANAR,
237 CODEC_ID_PCM_DVD,
238 CODEC_ID_PCM_F32BE,
239 CODEC_ID_PCM_F32LE,
240 CODEC_ID_PCM_F64BE,
241 CODEC_ID_PCM_F64LE,
242 CODEC_ID_PCM_BLURAY,
243
244 /* various ADPCM codecs */
245 CODEC_ID_ADPCM_IMA_QT= 0x11000,
246 CODEC_ID_ADPCM_IMA_WAV,
247 CODEC_ID_ADPCM_IMA_DK3,
248 CODEC_ID_ADPCM_IMA_DK4,
249 CODEC_ID_ADPCM_IMA_WS,
250 CODEC_ID_ADPCM_IMA_SMJPEG,
251 CODEC_ID_ADPCM_MS,
252 CODEC_ID_ADPCM_4XM,
253 CODEC_ID_ADPCM_XA,
254 CODEC_ID_ADPCM_ADX,
255 CODEC_ID_ADPCM_EA,
256 CODEC_ID_ADPCM_G726,
257 CODEC_ID_ADPCM_CT,
258 CODEC_ID_ADPCM_SWF,
259 CODEC_ID_ADPCM_YAMAHA,
260 CODEC_ID_ADPCM_SBPRO_4,
261 CODEC_ID_ADPCM_SBPRO_3,
262 CODEC_ID_ADPCM_SBPRO_2,
263 CODEC_ID_ADPCM_THP,
264 CODEC_ID_ADPCM_IMA_AMV,
265 CODEC_ID_ADPCM_EA_R1,
266 CODEC_ID_ADPCM_EA_R3,
267 CODEC_ID_ADPCM_EA_R2,
268 CODEC_ID_ADPCM_IMA_EA_SEAD,
269 CODEC_ID_ADPCM_IMA_EA_EACS,
270 CODEC_ID_ADPCM_EA_XAS,
271 CODEC_ID_ADPCM_EA_MAXIS_XA,
272 CODEC_ID_ADPCM_IMA_ISS,
273
274 /* AMR */
275 CODEC_ID_AMR_NB= 0x12000,
276 CODEC_ID_AMR_WB,
277
278 /* RealAudio codecs*/
279 CODEC_ID_RA_144= 0x13000,
280 CODEC_ID_RA_288,
281
282 /* various DPCM codecs */
283 CODEC_ID_ROQ_DPCM= 0x14000,
284 CODEC_ID_INTERPLAY_DPCM,
285 CODEC_ID_XAN_DPCM,
286 CODEC_ID_SOL_DPCM,
287
288 /* audio codecs */
289 CODEC_ID_MP2= 0x15000,
290 CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3
291 CODEC_ID_AAC,
292 CODEC_ID_AC3,
293 CODEC_ID_DTS,
294 CODEC_ID_VORBIS,
295 CODEC_ID_DVAUDIO,
296 CODEC_ID_WMAV1,
297 CODEC_ID_WMAV2,
298 CODEC_ID_MACE3,
299 CODEC_ID_MACE6,
300 CODEC_ID_VMDAUDIO,
301 CODEC_ID_SONIC,
302 CODEC_ID_SONIC_LS,
303 CODEC_ID_FLAC,
304 CODEC_ID_MP3ADU,
305 CODEC_ID_MP3ON4,
306 CODEC_ID_SHORTEN,
307 CODEC_ID_ALAC,
308 CODEC_ID_WESTWOOD_SND1,
309 CODEC_ID_GSM, ///< as in Berlin toast format
310 CODEC_ID_QDM2,
311 CODEC_ID_COOK,
312 CODEC_ID_TRUESPEECH,
313 CODEC_ID_TTA,
314 CODEC_ID_SMACKAUDIO,
315 CODEC_ID_QCELP,
316 CODEC_ID_WAVPACK,
317 CODEC_ID_DSICINAUDIO,
318 CODEC_ID_IMC,
319 CODEC_ID_MUSEPACK7,
320 CODEC_ID_MLP,
321 CODEC_ID_GSM_MS, /* as found in WAV */
322 CODEC_ID_ATRAC3,
323 CODEC_ID_VOXWARE,
324 CODEC_ID_APE,
325 CODEC_ID_NELLYMOSER,
326 CODEC_ID_MUSEPACK8,
327 CODEC_ID_SPEEX,
328 CODEC_ID_WMAVOICE,
329 CODEC_ID_WMAPRO,
330 CODEC_ID_WMALOSSLESS,
331 CODEC_ID_ATRAC3P,
332 CODEC_ID_EAC3,
333 CODEC_ID_SIPR,
334 CODEC_ID_MP1,
335 CODEC_ID_TWINVQ,
336 CODEC_ID_TRUEHD,
337 CODEC_ID_MP4ALS,
338 CODEC_ID_ATRAC1,
339 CODEC_ID_BINKAUDIO_RDFT,
340 CODEC_ID_BINKAUDIO_DCT,
341
342 /* subtitle codecs */
343 CODEC_ID_DVD_SUBTITLE= 0x17000,
344 CODEC_ID_DVB_SUBTITLE,
345 CODEC_ID_TEXT, ///< raw UTF-8 text
346 CODEC_ID_XSUB,
347 CODEC_ID_SSA,
348 CODEC_ID_MOV_TEXT,
349 CODEC_ID_HDMV_PGS_SUBTITLE,
350 CODEC_ID_DVB_TELETEXT,
351 CODEC_ID_SRT,
352
353 /* other specific kind of codecs (generally used for attachments) */
354 CODEC_ID_TTF= 0x18000,
355
356 CODEC_ID_PROBE= 0x19000, ///< codec_id is not known (like CODEC_ID_NONE) but lavf should attempt to identify it
357
358 CODEC_ID_MPEG2TS= 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS
359 * stream (only used by libavformat) */
360};
361
362#if LIBAVCODEC_VERSION_MAJOR < 53
363#define CodecType AVMediaType
364
365#define CODEC_TYPE_UNKNOWN AVMEDIA_TYPE_UNKNOWN
366#define CODEC_TYPE_VIDEO AVMEDIA_TYPE_VIDEO
367#define CODEC_TYPE_AUDIO AVMEDIA_TYPE_AUDIO
368#define CODEC_TYPE_DATA AVMEDIA_TYPE_DATA
369#define CODEC_TYPE_SUBTITLE AVMEDIA_TYPE_SUBTITLE
370#define CODEC_TYPE_ATTACHMENT AVMEDIA_TYPE_ATTACHMENT
371#define CODEC_TYPE_NB AVMEDIA_TYPE_NB
372#endif
373
374/**
375 * all in native-endian format
376 */
377enum SampleFormat {
378 SAMPLE_FMT_NONE = -1,
379 SAMPLE_FMT_U8, ///< unsigned 8 bits
380 SAMPLE_FMT_S16, ///< signed 16 bits
381 SAMPLE_FMT_S32, ///< signed 32 bits
382 SAMPLE_FMT_FLT, ///< float
383 SAMPLE_FMT_DBL, ///< double
384 SAMPLE_FMT_NB ///< Number of sample formats. DO NOT USE if dynamically linking to libavcodec
385};
386
387/* Audio channel masks */
388#define CH_FRONT_LEFT 0x00000001
389#define CH_FRONT_RIGHT 0x00000002
390#define CH_FRONT_CENTER 0x00000004
391#define CH_LOW_FREQUENCY 0x00000008
392#define CH_BACK_LEFT 0x00000010
393#define CH_BACK_RIGHT 0x00000020
394#define CH_FRONT_LEFT_OF_CENTER 0x00000040
395#define CH_FRONT_RIGHT_OF_CENTER 0x00000080
396#define CH_BACK_CENTER 0x00000100
397#define CH_SIDE_LEFT 0x00000200
398#define CH_SIDE_RIGHT 0x00000400
399#define CH_TOP_CENTER 0x00000800
400#define CH_TOP_FRONT_LEFT 0x00001000
401#define CH_TOP_FRONT_CENTER 0x00002000
402#define CH_TOP_FRONT_RIGHT 0x00004000
403#define CH_TOP_BACK_LEFT 0x00008000
404#define CH_TOP_BACK_CENTER 0x00010000
405#define CH_TOP_BACK_RIGHT 0x00020000
406#define CH_STEREO_LEFT 0x20000000 ///< Stereo downmix.
407#define CH_STEREO_RIGHT 0x40000000 ///< See CH_STEREO_LEFT.
408
409/** Channel mask value used for AVCodecContext.request_channel_layout
410 to indicate that the user requests the channel order of the decoder output
411 to be the native codec channel order. */
412#define CH_LAYOUT_NATIVE 0x8000000000000000LL
413
414/* Audio channel convenience macros */
415#define CH_LAYOUT_MONO (CH_FRONT_CENTER)
416#define CH_LAYOUT_STEREO (CH_FRONT_LEFT|CH_FRONT_RIGHT)
417#define CH_LAYOUT_2_1 (CH_LAYOUT_STEREO|CH_BACK_CENTER)
418#define CH_LAYOUT_SURROUND (CH_LAYOUT_STEREO|CH_FRONT_CENTER)
419#define CH_LAYOUT_4POINT0 (CH_LAYOUT_SURROUND|CH_BACK_CENTER)
420#define CH_LAYOUT_2_2 (CH_LAYOUT_STEREO|CH_SIDE_LEFT|CH_SIDE_RIGHT)
421#define CH_LAYOUT_QUAD (CH_LAYOUT_STEREO|CH_BACK_LEFT|CH_BACK_RIGHT)
422#define CH_LAYOUT_5POINT0 (CH_LAYOUT_SURROUND|CH_SIDE_LEFT|CH_SIDE_RIGHT)
423#define CH_LAYOUT_5POINT1 (CH_LAYOUT_5POINT0|CH_LOW_FREQUENCY)
424#define CH_LAYOUT_5POINT0_BACK (CH_LAYOUT_SURROUND|CH_BACK_LEFT|CH_BACK_RIGHT)
425#define CH_LAYOUT_5POINT1_BACK (CH_LAYOUT_5POINT0_BACK|CH_LOW_FREQUENCY)
426#define CH_LAYOUT_7POINT0 (CH_LAYOUT_5POINT0|CH_BACK_LEFT|CH_BACK_RIGHT)
427#define CH_LAYOUT_7POINT1 (CH_LAYOUT_5POINT1|CH_BACK_LEFT|CH_BACK_RIGHT)
428#define CH_LAYOUT_7POINT1_WIDE (CH_LAYOUT_5POINT1_BACK|\
429 CH_FRONT_LEFT_OF_CENTER|CH_FRONT_RIGHT_OF_CENTER)
430#define CH_LAYOUT_STEREO_DOWNMIX (CH_STEREO_LEFT|CH_STEREO_RIGHT)
431
432/* in bytes */
433#define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio
434
435/**
436 * Required number of additionally allocated bytes at the end of the input bitstream for decoding.
437 * This is mainly needed because some optimized bitstream readers read
438 * 32 or 64 bit at once and could read over the end.<br>
439 * Note: If the first 23 bits of the additional bytes are not 0, then damaged
440 * MPEG bitstreams could cause overread and segfault.
441 */
442#define FF_INPUT_BUFFER_PADDING_SIZE 8
443
444/**
445 * minimum encoding buffer size
446 * Used to avoid some checks during header writing.
447 */
448#define FF_MIN_BUFFER_SIZE 16384
449
450
451/**
452 * motion estimation type.
453 */
454enum Motion_Est_ID {
455 ME_ZERO = 1, ///< no search, that is use 0,0 vector whenever one is needed
456 ME_FULL,
457 ME_LOG,
458 ME_PHODS,
459 ME_EPZS, ///< enhanced predictive zonal search
460 ME_X1, ///< reserved for experiments
461 ME_HEX, ///< hexagon based search
462 ME_UMH, ///< uneven multi-hexagon search
463 ME_ITER, ///< iterative search
464 ME_TESA, ///< transformed exhaustive search algorithm
465};
466
467enum AVDiscard{
468 /* We leave some space between them for extensions (drop some
469 * keyframes for intra-only or drop just some bidir frames). */
470 AVDISCARD_NONE =-16, ///< discard nothing
471 AVDISCARD_DEFAULT= 0, ///< discard useless packets like 0 size packets in avi
472 AVDISCARD_NONREF = 8, ///< discard all non reference
473 AVDISCARD_BIDIR = 16, ///< discard all bidirectional frames
474 AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes
475 AVDISCARD_ALL = 48, ///< discard all
476};
477
478enum AVColorPrimaries{
479 AVCOL_PRI_BT709 =1, ///< also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B
480 AVCOL_PRI_UNSPECIFIED=2,
481 AVCOL_PRI_BT470M =4,
482 AVCOL_PRI_BT470BG =5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
483 AVCOL_PRI_SMPTE170M =6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
484 AVCOL_PRI_SMPTE240M =7, ///< functionally identical to above
485 AVCOL_PRI_FILM =8,
486 AVCOL_PRI_NB , ///< Not part of ABI
487};
488
489enum AVColorTransferCharacteristic{
490 AVCOL_TRC_BT709 =1, ///< also ITU-R BT1361
491 AVCOL_TRC_UNSPECIFIED=2,
492 AVCOL_TRC_GAMMA22 =4, ///< also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM
493 AVCOL_TRC_GAMMA28 =5, ///< also ITU-R BT470BG
494 AVCOL_TRC_NB , ///< Not part of ABI
495};
496
497enum AVColorSpace{
498 AVCOL_SPC_RGB =0,
499 AVCOL_SPC_BT709 =1, ///< also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
500 AVCOL_SPC_UNSPECIFIED=2,
501 AVCOL_SPC_FCC =4,
502 AVCOL_SPC_BT470BG =5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
503 AVCOL_SPC_SMPTE170M =6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above
504 AVCOL_SPC_SMPTE240M =7,
505 AVCOL_SPC_NB , ///< Not part of ABI
506};
507
508enum AVColorRange{
509 AVCOL_RANGE_UNSPECIFIED=0,
510 AVCOL_RANGE_MPEG =1, ///< the normal 219*2^(n-8) "MPEG" YUV ranges
511 AVCOL_RANGE_JPEG =2, ///< the normal 2^n-1 "JPEG" YUV ranges
512 AVCOL_RANGE_NB , ///< Not part of ABI
513};
514
515/**
516 * X X 3 4 X X are luma samples,
517 * 1 2 1-6 are possible chroma positions
518 * X X 5 6 X 0 is undefined/unknown position
519 */
520enum AVChromaLocation{
521 AVCHROMA_LOC_UNSPECIFIED=0,
522 AVCHROMA_LOC_LEFT =1, ///< mpeg2/4, h264 default
523 AVCHROMA_LOC_CENTER =2, ///< mpeg1, jpeg, h263
524 AVCHROMA_LOC_TOPLEFT =3, ///< DV
525 AVCHROMA_LOC_TOP =4,
526 AVCHROMA_LOC_BOTTOMLEFT =5,
527 AVCHROMA_LOC_BOTTOM =6,
528 AVCHROMA_LOC_NB , ///< Not part of ABI
529};
530
531/**
532 * LPC analysis type
533 */
534enum AVLPCType {
535 AV_LPC_TYPE_DEFAULT = -1, ///< use the codec default LPC type
536 AV_LPC_TYPE_NONE = 0, ///< do not use LPC prediction or use all zero coefficients
537 AV_LPC_TYPE_FIXED = 1, ///< fixed LPC coefficients
538 AV_LPC_TYPE_LEVINSON = 2, ///< Levinson-Durbin recursion
539 AV_LPC_TYPE_CHOLESKY = 3, ///< Cholesky factorization
540 AV_LPC_TYPE_NB , ///< Not part of ABI
541};
542
543typedef struct RcOverride{
544 int start_frame;
545 int end_frame;
546 int qscale; // If this is 0 then quality_factor will be used instead.
547 float quality_factor;
548} RcOverride;
549
550#define FF_MAX_B_FRAMES 16
551
552/* encoding support
553 These flags can be passed in AVCodecContext.flags before initialization.
554 Note: Not everything is supported yet.
555*/
556
557#define CODEC_FLAG_QSCALE 0x0002 ///< Use fixed qscale.
558#define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed / advanced prediction for H.263.
559#define CODEC_FLAG_QPEL 0x0010 ///< Use qpel MC.
560#define CODEC_FLAG_GMC 0x0020 ///< Use GMC.
561#define CODEC_FLAG_MV0 0x0040 ///< Always try a MB with MV=<0,0>.
562#define CODEC_FLAG_PART 0x0080 ///< Use data partitioning.
563/**
564 * The parent program guarantees that the input for B-frames containing
565 * streams is not written to for at least s->max_b_frames+1 frames, if
566 * this is not set the input will be copied.
567 */
568#define CODEC_FLAG_INPUT_PRESERVED 0x0100
569#define CODEC_FLAG_PASS1 0x0200 ///< Use internal 2pass ratecontrol in first pass mode.
570#define CODEC_FLAG_PASS2 0x0400 ///< Use internal 2pass ratecontrol in second pass mode.
571#define CODEC_FLAG_EXTERN_HUFF 0x1000 ///< Use external Huffman table (for MJPEG).
572#define CODEC_FLAG_GRAY 0x2000 ///< Only decode/encode grayscale.
573#define CODEC_FLAG_EMU_EDGE 0x4000 ///< Don't draw edges.
574#define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding.
575#define CODEC_FLAG_TRUNCATED 0x00010000 /** Input bitstream might be truncated at a random
576 location instead of only at frame boundaries. */
577#define CODEC_FLAG_NORMALIZE_AQP 0x00020000 ///< Normalize adaptive quantization.
578#define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< Use interlaced DCT.
579#define CODEC_FLAG_LOW_DELAY 0x00080000 ///< Force low delay.
580#define CODEC_FLAG_ALT_SCAN 0x00100000 ///< Use alternate scan.
581#define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< Place global headers in extradata instead of every keyframe.
582#define CODEC_FLAG_BITEXACT 0x00800000 ///< Use only bitexact stuff (except (I)DCT).
583/* Fx : Flag for h263+ extra options */
584#define CODEC_FLAG_AC_PRED 0x01000000 ///< H.263 advanced intra coding / MPEG-4 AC prediction
585#define CODEC_FLAG_H263P_UMV 0x02000000 ///< unlimited motion vector
586#define CODEC_FLAG_CBP_RD 0x04000000 ///< Use rate distortion optimization for cbp.
587#define CODEC_FLAG_QP_RD 0x08000000 ///< Use rate distortion optimization for qp selectioon.
588#define CODEC_FLAG_H263P_AIV 0x00000008 ///< H.263 alternative inter VLC
589#define CODEC_FLAG_OBMC 0x00000001 ///< OBMC
590#define CODEC_FLAG_LOOP_FILTER 0x00000800 ///< loop filter
591#define CODEC_FLAG_H263P_SLICE_STRUCT 0x10000000
592#define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation
593#define CODEC_FLAG_SVCD_SCAN_OFFSET 0x40000000 ///< Will reserve space for SVCD scan offset user data.
594#define CODEC_FLAG_CLOSED_GOP 0x80000000
595#define CODEC_FLAG2_FAST 0x00000001 ///< Allow non spec compliant speedup tricks.
596#define CODEC_FLAG2_STRICT_GOP 0x00000002 ///< Strictly enforce GOP size.
597#define CODEC_FLAG2_NO_OUTPUT 0x00000004 ///< Skip bitstream encoding.
598#define CODEC_FLAG2_LOCAL_HEADER 0x00000008 ///< Place global headers at every keyframe instead of in extradata.
599#define CODEC_FLAG2_BPYRAMID 0x00000010 ///< H.264 allow B-frames to be used as references.
600#define CODEC_FLAG2_WPRED 0x00000020 ///< H.264 weighted biprediction for B-frames
601#define CODEC_FLAG2_MIXED_REFS 0x00000040 ///< H.264 one reference per partition, as opposed to one reference per macroblock
602#define CODEC_FLAG2_8X8DCT 0x00000080 ///< H.264 high profile 8x8 transform
603#define CODEC_FLAG2_FASTPSKIP 0x00000100 ///< H.264 fast pskip
604#define CODEC_FLAG2_AUD 0x00000200 ///< H.264 access unit delimiters
605#define CODEC_FLAG2_BRDO 0x00000400 ///< B-frame rate-distortion optimization
606#define CODEC_FLAG2_INTRA_VLC 0x00000800 ///< Use MPEG-2 intra VLC table.
607#define CODEC_FLAG2_MEMC_ONLY 0x00001000 ///< Only do ME/MC (I frames -> ref, P frame -> ME+MC).
608#define CODEC_FLAG2_DROP_FRAME_TIMECODE 0x00002000 ///< timecode is in drop frame format.
609#define CODEC_FLAG2_SKIP_RD 0x00004000 ///< RD optimal MB level residual skipping
610#define CODEC_FLAG2_CHUNKS 0x00008000 ///< Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries.
611#define CODEC_FLAG2_NON_LINEAR_QUANT 0x00010000 ///< Use MPEG-2 nonlinear quantizer.
612#define CODEC_FLAG2_BIT_RESERVOIR 0x00020000 ///< Use a bit reservoir when encoding if possible
613#define CODEC_FLAG2_MBTREE 0x00040000 ///< Use macroblock tree ratecontrol (x264 only)
614#define CODEC_FLAG2_PSY 0x00080000 ///< Use psycho visual optimizations.
615#define CODEC_FLAG2_SSIM 0x00100000 ///< Compute SSIM during encoding, error[] values are undefined.
616#define CODEC_FLAG2_INTRA_REFRESH 0x00200000 ///< Use periodic insertion of intra blocks instead of keyframes.
617
618/* Unsupported options :
619 * Syntax Arithmetic coding (SAC)
620 * Reference Picture Selection
621 * Independent Segment Decoding */
622/* /Fx */
623/* codec capabilities */
624
625#define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< Decoder can use draw_horiz_band callback.
626/**
627 * Codec uses get_buffer() for allocating buffers and supports custom allocators.
628 * If not set, it might not use get_buffer() at all or use operations that
629 * assume the buffer was allocated by avcodec_default_get_buffer.
630 */
631#define CODEC_CAP_DR1 0x0002
632/* If 'parse_only' field is true, then avcodec_parse_frame() can be used. */
633#define CODEC_CAP_PARSE_ONLY 0x0004
634#define CODEC_CAP_TRUNCATED 0x0008
635/* Codec can export data for HW decoding (XvMC). */
636#define CODEC_CAP_HWACCEL 0x0010
637/**
638 * Codec has a nonzero delay and needs to be fed with NULL at the end to get the delayed data.
639 * If this is not set, the codec is guaranteed to never be fed with NULL data.
640 */
641#define CODEC_CAP_DELAY 0x0020
642/**
643 * Codec can be fed a final frame with a smaller size.
644 * This can be used to prevent truncation of the last audio samples.
645 */
646#define CODEC_CAP_SMALL_LAST_FRAME 0x0040
647/**
648 * Codec can export data for HW decoding (VDPAU).
649 */
650#define CODEC_CAP_HWACCEL_VDPAU 0x0080
651/**
652 * Codec can output multiple frames per AVPacket
653 * Normally demuxers return one frame at a time, demuxers which do not do
654 * are connected to a parser to split what they return into proper frames.
655 * This flag is reserved to the very rare category of codecs which have a
656 * bitstream that cannot be split into frames without timeconsuming
657 * operations like full decoding. Demuxers carring such bitstreams thus
658 * may return multiple frames in a packet. This has many disadvantages like
659 * prohibiting stream copy in many cases thus it should only be considered
660 * as a last resort.
661 */
662#define CODEC_CAP_SUBFRAMES 0x0100
663/**
664 * Codec is experimental and is thus avoided in favor of non experimental
665 * encoders
666 */
667#define CODEC_CAP_EXPERIMENTAL 0x0200
668
669//The following defines may change, don't expect compatibility if you use them.
670#define MB_TYPE_INTRA4x4 0x0001
671#define MB_TYPE_INTRA16x16 0x0002 //FIXME H.264-specific
672#define MB_TYPE_INTRA_PCM 0x0004 //FIXME H.264-specific
673#define MB_TYPE_16x16 0x0008
674#define MB_TYPE_16x8 0x0010
675#define MB_TYPE_8x16 0x0020
676#define MB_TYPE_8x8 0x0040
677#define MB_TYPE_INTERLACED 0x0080
678#define MB_TYPE_DIRECT2 0x0100 //FIXME
679#define MB_TYPE_ACPRED 0x0200
680#define MB_TYPE_GMC 0x0400
681#define MB_TYPE_SKIP 0x0800
682#define MB_TYPE_P0L0 0x1000
683#define MB_TYPE_P1L0 0x2000
684#define MB_TYPE_P0L1 0x4000
685#define MB_TYPE_P1L1 0x8000
686#define MB_TYPE_L0 (MB_TYPE_P0L0 | MB_TYPE_P1L0)
687#define MB_TYPE_L1 (MB_TYPE_P0L1 | MB_TYPE_P1L1)
688#define MB_TYPE_L0L1 (MB_TYPE_L0 | MB_TYPE_L1)
689#define MB_TYPE_QUANT 0x00010000
690#define MB_TYPE_CBP 0x00020000
691//Note bits 24-31 are reserved for codec specific use (h264 ref0, mpeg1 0mv, ...)
692
693/**
694 * Pan Scan area.
695 * This specifies the area which should be displayed.
696 * Note there may be multiple such areas for one frame.
697 */
698typedef struct AVPanScan{
699 /**
700 * id
701 * - encoding: Set by user.
702 * - decoding: Set by libavcodec.
703 */
704 int id;
705
706 /**
707 * width and height in 1/16 pel
708 * - encoding: Set by user.
709 * - decoding: Set by libavcodec.
710 */
711 int width;
712 int height;
713
714 /**
715 * position of the top left corner in 1/16 pel for up to 3 fields/frames
716 * - encoding: Set by user.
717 * - decoding: Set by libavcodec.
718 */
719 int16_t position[3][2];
720}AVPanScan;
721
722#define FF_COMMON_FRAME \
723 /**\
724 * pointer to the picture planes.\
725 * This might be different from the first allocated byte\
726 * - encoding: \
727 * - decoding: \
728 */\
729 uint8_t *data[4];\
730 int linesize[4];\
731 /**\
732 * pointer to the first allocated byte of the picture. Can be used in get_buffer/release_buffer.\
733 * This isn't used by libavcodec unless the default get/release_buffer() is used.\
734 * - encoding: \
735 * - decoding: \
736 */\
737 uint8_t *base[4];\
738 /**\
739 * 1 -> keyframe, 0-> not\
740 * - encoding: Set by libavcodec.\
741 * - decoding: Set by libavcodec.\
742 */\
743 int key_frame;\
744\
745 /**\
746 * Picture type of the frame, see ?_TYPE below.\
747 * - encoding: Set by libavcodec. for coded_picture (and set by user for input).\
748 * - decoding: Set by libavcodec.\
749 */\
750 int pict_type;\
751\
752 /**\
753 * presentation timestamp in time_base units (time when frame should be shown to user)\
754 * If AV_NOPTS_VALUE then frame_rate = 1/time_base will be assumed.\
755 * - encoding: MUST be set by user.\
756 * - decoding: Set by libavcodec.\
757 */\
758 int64_t pts;\
759\
760 /**\
761 * picture number in bitstream order\
762 * - encoding: set by\
763 * - decoding: Set by libavcodec.\
764 */\
765 int coded_picture_number;\
766 /**\
767 * picture number in display order\
768 * - encoding: set by\
769 * - decoding: Set by libavcodec.\
770 */\
771 int display_picture_number;\
772\
773 /**\
774 * quality (between 1 (good) and FF_LAMBDA_MAX (bad)) \
775 * - encoding: Set by libavcodec. for coded_picture (and set by user for input).\
776 * - decoding: Set by libavcodec.\
777 */\
778 int quality; \
779\
780 /**\
781 * buffer age (1->was last buffer and dint change, 2->..., ...).\
782 * Set to INT_MAX if the buffer has not been used yet.\
783 * - encoding: unused\
784 * - decoding: MUST be set by get_buffer().\
785 */\
786 int age;\
787\
788 /**\
789 * is this picture used as reference\
790 * The values for this are the same as the MpegEncContext.picture_structure\
791 * variable, that is 1->top field, 2->bottom field, 3->frame/both fields.\
792 * Set to 4 for delayed, non-reference frames.\
793 * - encoding: unused\
794 * - decoding: Set by libavcodec. (before get_buffer() call)).\
795 */\
796 int reference;\
797\
798 /**\
799 * QP table\
800 * - encoding: unused\
801 * - decoding: Set by libavcodec.\
802 */\
803 int8_t *qscale_table;\
804 /**\
805 * QP store stride\
806 * - encoding: unused\
807 * - decoding: Set by libavcodec.\
808 */\
809 int qstride;\
810\
811 /**\
812 * mbskip_table[mb]>=1 if MB didn't change\
813 * stride= mb_width = (width+15)>>4\
814 * - encoding: unused\
815 * - decoding: Set by libavcodec.\
816 */\
817 uint8_t *mbskip_table;\
818\
819 /**\
820 * motion vector table\
821 * @code\
822 * example:\
823 * int mv_sample_log2= 4 - motion_subsample_log2;\
824 * int mb_width= (width+15)>>4;\
825 * int mv_stride= (mb_width << mv_sample_log2) + 1;\
826 * motion_val[direction][x + y*mv_stride][0->mv_x, 1->mv_y];\
827 * @endcode\
828 * - encoding: Set by user.\
829 * - decoding: Set by libavcodec.\
830 */\
831 int16_t (*motion_val[2])[2];\
832\
833 /**\
834 * macroblock type table\
835 * mb_type_base + mb_width + 2\
836 * - encoding: Set by user.\
837 * - decoding: Set by libavcodec.\
838 */\
839 uint32_t *mb_type;\
840\
841 /**\
842 * log2 of the size of the block which a single vector in motion_val represents: \
843 * (4->16x16, 3->8x8, 2-> 4x4, 1-> 2x2)\
844 * - encoding: unused\
845 * - decoding: Set by libavcodec.\
846 */\
847 uint8_t motion_subsample_log2;\
848\
849 /**\
850 * for some private data of the user\
851 * - encoding: unused\
852 * - decoding: Set by user.\
853 */\
854 void *opaque;\
855\
856 /**\
857 * error\
858 * - encoding: Set by libavcodec. if flags&CODEC_FLAG_PSNR.\
859 * - decoding: unused\
860 */\
861 uint64_t error[4];\
862\
863 /**\
864 * type of the buffer (to keep track of who has to deallocate data[*])\
865 * - encoding: Set by the one who allocates it.\
866 * - decoding: Set by the one who allocates it.\
867 * Note: User allocated (direct rendering) & internal buffers cannot coexist currently.\
868 */\
869 int type;\
870 \
871 /**\
872 * When decoding, this signals how much the picture must be delayed.\
873 * extra_delay = repeat_pict / (2*fps)\
874 * - encoding: unused\
875 * - decoding: Set by libavcodec.\
876 */\
877 int repeat_pict;\
878 \
879 /**\
880 * \
881 */\
882 int qscale_type;\
883 \
884 /**\
885 * The content of the picture is interlaced.\
886 * - encoding: Set by user.\
887 * - decoding: Set by libavcodec. (default 0)\
888 */\
889 int interlaced_frame;\
890 \
891 /**\
892 * If the content is interlaced, is top field displayed first.\
893 * - encoding: Set by user.\
894 * - decoding: Set by libavcodec.\
895 */\
896 int top_field_first;\
897 \
898 /**\
899 * Pan scan.\
900 * - encoding: Set by user.\
901 * - decoding: Set by libavcodec.\
902 */\
903 AVPanScan *pan_scan;\
904 \
905 /**\
906 * Tell user application that palette has changed from previous frame.\
907 * - encoding: ??? (no palette-enabled encoder yet)\
908 * - decoding: Set by libavcodec. (default 0).\
909 */\
910 int palette_has_changed;\
911 \
912 /**\
913 * codec suggestion on buffer type if != 0\
914 * - encoding: unused\
915 * - decoding: Set by libavcodec. (before get_buffer() call)).\
916 */\
917 int buffer_hints;\
918\
919 /**\
920 * DCT coefficients\
921 * - encoding: unused\
922 * - decoding: Set by libavcodec.\
923 */\
924 short *dct_coeff;\
925\
926 /**\
927 * motion reference frame index\
928 * the order in which these are stored can depend on the codec.\
929 * - encoding: Set by user.\
930 * - decoding: Set by libavcodec.\
931 */\
932 int8_t *ref_index[2];\
933\
934 /**\
935 * reordered opaque 64bit number (generally a PTS) from AVCodecContext.reordered_opaque\
936 * output in AVFrame.reordered_opaque\
937 * - encoding: unused\
938 * - decoding: Read by user.\
939 */\
940 int64_t reordered_opaque;\
941\
942 /**\
943 * hardware accelerator private data (FFmpeg allocated)\
944 * - encoding: unused\
945 * - decoding: Set by libavcodec\
946 */\
947 void *hwaccel_picture_private;\
948
949
950#define FF_QSCALE_TYPE_MPEG1 0
951#define FF_QSCALE_TYPE_MPEG2 1
952#define FF_QSCALE_TYPE_H264 2
953#define FF_QSCALE_TYPE_VP56 3
954
955#define FF_BUFFER_TYPE_INTERNAL 1
956#define FF_BUFFER_TYPE_USER 2 ///< direct rendering buffers (image is (de)allocated by user)
957#define FF_BUFFER_TYPE_SHARED 4 ///< Buffer from somewhere else; don't deallocate image (data/base), all other tables are not shared.
958#define FF_BUFFER_TYPE_COPY 8 ///< Just a (modified) copy of some other buffer, don't deallocate anything.
959
960
961#define FF_I_TYPE 1 ///< Intra
962#define FF_P_TYPE 2 ///< Predicted
963#define FF_B_TYPE 3 ///< Bi-dir predicted
964#define FF_S_TYPE 4 ///< S(GMC)-VOP MPEG4
965#define FF_SI_TYPE 5 ///< Switching Intra
966#define FF_SP_TYPE 6 ///< Switching Predicted
967#define FF_BI_TYPE 7
968
969#define FF_BUFFER_HINTS_VALID 0x01 // Buffer hints value is meaningful (if 0 ignore).
970#define FF_BUFFER_HINTS_READABLE 0x02 // Codec will read from buffer.
971#define FF_BUFFER_HINTS_PRESERVE 0x04 // User must not alter buffer content.
972#define FF_BUFFER_HINTS_REUSABLE 0x08 // Codec will reuse the buffer (update).
973
974typedef struct AVPacket {
975 /**
976 * Presentation timestamp in AVStream->time_base units; the time at which
977 * the decompressed packet will be presented to the user.
978 * Can be AV_NOPTS_VALUE if it is not stored in the file.
979 * pts MUST be larger or equal to dts as presentation cannot happen before
980 * decompression, unless one wants to view hex dumps. Some formats misuse
981 * the terms dts and pts/cts to mean something different. Such timestamps
982 * must be converted to true pts/dts before they are stored in AVPacket.
983 */
984 int64_t pts;
985 /**
986 * Decompression timestamp in AVStream->time_base units; the time at which
987 * the packet is decompressed.
988 * Can be AV_NOPTS_VALUE if it is not stored in the file.
989 */
990 int64_t dts;
991 uint8_t *data;
992 int size;
993 int stream_index;
994 int flags;
995 /**
996 * Duration of this packet in AVStream->time_base units, 0 if unknown.
997 * Equals next_pts - this_pts in presentation order.
998 */
999 int duration;
1000 void (*destruct)(struct AVPacket *);
1001 void *priv;
1002 int64_t pos; ///< byte position in stream, -1 if unknown
1003
1004 /**
1005 * Time difference in AVStream->time_base units from the pts of this
1006 * packet to the point at which the output from the decoder has converged
1007 * independent from the availability of previous frames. That is, the
1008 * frames are virtually identical no matter if decoding started from
1009 * the very first frame or from this keyframe.
1010 * Is AV_NOPTS_VALUE if unknown.
1011 * This field is not the display duration of the current packet.
1012 * This field has no meaning if the packet does not have AV_PKT_FLAG_KEY
1013 * set.
1014 *
1015 * The purpose of this field is to allow seeking in streams that have no
1016 * keyframes in the conventional sense. It corresponds to the
1017 * recovery point SEI in H.264 and match_time_delta in NUT. It is also
1018 * essential for some types of subtitle streams to ensure that all
1019 * subtitles are correctly displayed after seeking.
1020 */
1021 int64_t convergence_duration;
1022} AVPacket;
1023#define AV_PKT_FLAG_KEY 0x0001
1024#if LIBAVCODEC_VERSION_MAJOR < 53
1025#define PKT_FLAG_KEY AV_PKT_FLAG_KEY
1026#endif
1027
1028/**
1029 * Audio Video Frame.
1030 * New fields can be added to the end of FF_COMMON_FRAME with minor version
1031 * bumps.
1032 * Removal, reordering and changes to existing fields require a major
1033 * version bump. No fields should be added into AVFrame before or after
1034 * FF_COMMON_FRAME!
1035 * sizeof(AVFrame) must not be used outside libav*.
1036 */
1037typedef struct AVFrame {
1038 FF_COMMON_FRAME
1039} AVFrame;
1040
1041/**
1042 * main external API structure.
1043 * New fields can be added to the end with minor version bumps.
1044 * Removal, reordering and changes to existing fields require a major
1045 * version bump.
1046 * sizeof(AVCodecContext) must not be used outside libav*.
1047 */
1048typedef struct AVCodecContext {
1049 /**
1050 * information on struct for av_log
1051 * - set by avcodec_alloc_context
1052 */
1053 const AVClass *av_class;
1054 /**
1055 * the average bitrate
1056 * - encoding: Set by user; unused for constant quantizer encoding.
1057 * - decoding: Set by libavcodec. 0 or some bitrate if this info is available in the stream.
1058 */
1059 int bit_rate;
1060
1061 /**
1062 * number of bits the bitstream is allowed to diverge from the reference.
1063 * the reference can be CBR (for CBR pass1) or VBR (for pass2)
1064 * - encoding: Set by user; unused for constant quantizer encoding.
1065 * - decoding: unused
1066 */
1067 int bit_rate_tolerance;
1068
1069 /**
1070 * CODEC_FLAG_*.
1071 * - encoding: Set by user.
1072 * - decoding: Set by user.
1073 */
1074 int flags;
1075
1076 /**
1077 * Some codecs need additional format info. It is stored here.
1078 * If any muxer uses this then ALL demuxers/parsers AND encoders for the
1079 * specific codec MUST set it correctly otherwise stream copy breaks.
1080 * In general use of this field by muxers is not recommanded.
1081 * - encoding: Set by libavcodec.
1082 * - decoding: Set by libavcodec. (FIXME: Is this OK?)
1083 */
1084 int sub_id;
1085
1086 /**
1087 * Motion estimation algorithm used for video coding.
1088 * 1 (zero), 2 (full), 3 (log), 4 (phods), 5 (epzs), 6 (x1), 7 (hex),
1089 * 8 (umh), 9 (iter), 10 (tesa) [7, 8, 10 are x264 specific, 9 is snow specific]
1090 * - encoding: MUST be set by user.
1091 * - decoding: unused
1092 */
1093 int me_method;
1094
1095 /**
1096 * some codecs need / can use extradata like Huffman tables.
1097 * mjpeg: Huffman tables
1098 * rv10: additional flags
1099 * mpeg4: global headers (they can be in the bitstream or here)
1100 * The allocated memory should be FF_INPUT_BUFFER_PADDING_SIZE bytes larger
1101 * than extradata_size to avoid prolems if it is read with the bitstream reader.
1102 * The bytewise contents of extradata must not depend on the architecture or CPU endianness.
1103 * - encoding: Set/allocated/freed by libavcodec.
1104 * - decoding: Set/allocated/freed by user.
1105 */
1106 uint8_t *extradata;
1107 int extradata_size;
1108
1109 /**
1110 * This is the fundamental unit of time (in seconds) in terms
1111 * of which frame timestamps are represented. For fixed-fps content,
1112 * timebase should be 1/framerate and timestamp increments should be
1113 * identically 1.
1114 * - encoding: MUST be set by user.
1115 * - decoding: Set by libavcodec.
1116 */
1117 AVRational time_base;
1118
1119 /* video only */
1120 /**
1121 * picture width / height.
1122 * - encoding: MUST be set by user.
1123 * - decoding: Set by libavcodec.
1124 * Note: For compatibility it is possible to set this instead of
1125 * coded_width/height before decoding.
1126 */
1127 int width, height;
1128
1129#define FF_ASPECT_EXTENDED 15
1130
1131 /**
1132 * the number of pictures in a group of pictures, or 0 for intra_only
1133 * - encoding: Set by user.
1134 * - decoding: unused
1135 */
1136 int gop_size;
1137
1138 /**
1139 * Pixel format, see PIX_FMT_xxx.
1140 * May be set by the demuxer if known from headers.
1141 * May be overriden by the decoder if it knows better.
1142 * - encoding: Set by user.
1143 * - decoding: Set by user if known, overridden by libavcodec if known
1144 */
1145 enum PixelFormat pix_fmt;
1146
1147 /**
1148 * Frame rate emulation. If not zero, the lower layer (i.e. format handler)
1149 * has to read frames at native frame rate.
1150 * - encoding: Set by user.
1151 * - decoding: unused
1152 */
1153 int rate_emu;
1154
1155 /**
1156 * If non NULL, 'draw_horiz_band' is called by the libavcodec
1157 * decoder to draw a horizontal band. It improves cache usage. Not
1158 * all codecs can do that. You must check the codec capabilities
1159 * beforehand.
1160 * The function is also used by hardware acceleration APIs.
1161 * It is called at least once during frame decoding to pass
1162 * the data needed for hardware render.
1163 * In that mode instead of pixel data, AVFrame points to
1164 * a structure specific to the acceleration API. The application
1165 * reads the structure and can change some fields to indicate progress
1166 * or mark state.
1167 * - encoding: unused
1168 * - decoding: Set by user.
1169 * @param height the height of the slice
1170 * @param y the y position of the slice
1171 * @param type 1->top field, 2->bottom field, 3->frame
1172 * @param offset offset into the AVFrame.data from which the slice should be read
1173 */
1174 void (*draw_horiz_band)(struct AVCodecContext *s,
1175 const AVFrame *src, int offset[4],
1176 int y, int type, int height);
1177
1178 /* audio only */
1179 int sample_rate; ///< samples per second
1180 int channels; ///< number of audio channels
1181
1182 /**
1183 * audio sample format
1184 * - encoding: Set by user.
1185 * - decoding: Set by libavcodec.
1186 */
1187 enum SampleFormat sample_fmt; ///< sample format
1188
1189 /* The following data should not be initialized. */
1190 /**
1191 * Samples per packet, initialized when calling 'init'.
1192 */
1193 int frame_size;
1194 int frame_number; ///< audio or video frame number
1195#if LIBAVCODEC_VERSION_MAJOR < 53
1196 int real_pict_num; ///< Returns the real picture number of previous encoded frame.
1197#endif
1198
1199 /**
1200 * Number of frames the decoded output will be delayed relative to
1201 * the encoded input.
1202 * - encoding: Set by libavcodec.
1203 * - decoding: unused
1204 */
1205 int delay;
1206
1207 /* - encoding parameters */
1208 float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0)
1209 float qblur; ///< amount of qscale smoothing over time (0.0-1.0)
1210
1211 /**
1212 * minimum quantizer
1213 * - encoding: Set by user.
1214 * - decoding: unused
1215 */
1216 int qmin;
1217
1218 /**
1219 * maximum quantizer
1220 * - encoding: Set by user.
1221 * - decoding: unused
1222 */
1223 int qmax;
1224
1225 /**
1226 * maximum quantizer difference between frames
1227 * - encoding: Set by user.
1228 * - decoding: unused
1229 */
1230 int max_qdiff;
1231
1232 /**
1233 * maximum number of B-frames between non-B-frames
1234 * Note: The output will be delayed by max_b_frames+1 relative to the input.
1235 * - encoding: Set by user.
1236 * - decoding: unused
1237 */
1238 int max_b_frames;
1239
1240 /**
1241 * qscale factor between IP and B-frames
1242 * If > 0 then the last P-frame quantizer will be used (q= lastp_q*factor+offset).
1243 * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
1244 * - encoding: Set by user.
1245 * - decoding: unused
1246 */
1247 float b_quant_factor;
1248
1249 /** obsolete FIXME remove */
1250 int rc_strategy;
1251#define FF_RC_STRATEGY_XVID 1
1252
1253 int b_frame_strategy;
1254
1255 /**
1256 * hurry up amount
1257 * - encoding: unused
1258 * - decoding: Set by user. 1-> Skip B-frames, 2-> Skip IDCT/dequant too, 5-> Skip everything except header
1259 * @deprecated Deprecated in favor of skip_idct and skip_frame.
1260 */
1261 int hurry_up;
1262
1263 struct AVCodec *codec;
1264
1265 void *priv_data;
1266
1267 int rtp_payload_size; /* The size of the RTP payload: the coder will */
1268 /* do its best to deliver a chunk with size */
1269 /* below rtp_payload_size, the chunk will start */
1270 /* with a start code on some codecs like H.263. */
1271 /* This doesn't take account of any particular */
1272 /* headers inside the transmitted RTP payload. */
1273
1274
1275 /* The RTP callback: This function is called */
1276 /* every time the encoder has a packet to send. */
1277 /* It depends on the encoder if the data starts */
1278 /* with a Start Code (it should). H.263 does. */
1279 /* mb_nb contains the number of macroblocks */
1280 /* encoded in the RTP payload. */
1281 void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int mb_nb);
1282
1283 /* statistics, used for 2-pass encoding */
1284 int mv_bits;
1285 int header_bits;
1286 int i_tex_bits;
1287 int p_tex_bits;
1288 int i_count;
1289 int p_count;
1290 int skip_count;
1291 int misc_bits;
1292
1293 /**
1294 * number of bits used for the previously encoded frame
1295 * - encoding: Set by libavcodec.
1296 * - decoding: unused
1297 */
1298 int frame_bits;
1299
1300 /**
1301 * Private data of the user, can be used to carry app specific stuff.
1302 * - encoding: Set by user.
1303 * - decoding: Set by user.
1304 */
1305 void *opaque;
1306
1307 char codec_name[32];
1308 enum AVMediaType codec_type; /* see AVMEDIA_TYPE_xxx */
1309 enum CodecID codec_id; /* see CODEC_ID_xxx */
1310
1311 /**
1312 * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
1313 * This is used to work around some encoder bugs.
1314 * A demuxer should set this to what is stored in the field used to identify the codec.
1315 * If there are multiple such fields in a container then the demuxer should choose the one
1316 * which maximizes the information about the used codec.
1317 * If the codec tag field in a container is larger then 32 bits then the demuxer should
1318 * remap the longer ID to 32 bits with a table or other structure. Alternatively a new
1319 * extra_codec_tag + size could be added but for this a clear advantage must be demonstrated
1320 * first.
1321 * - encoding: Set by user, if not then the default based on codec_id will be used.
1322 * - decoding: Set by user, will be converted to uppercase by libavcodec during init.
1323 */
1324 unsigned int codec_tag;
1325
1326 /**
1327 * Work around bugs in encoders which sometimes cannot be detected automatically.
1328 * - encoding: Set by user
1329 * - decoding: Set by user
1330 */
1331 int workaround_bugs;
1332#define FF_BUG_AUTODETECT 1 ///< autodetection
1333#define FF_BUG_OLD_MSMPEG4 2
1334#define FF_BUG_XVID_ILACE 4
1335#define FF_BUG_UMP4 8
1336#define FF_BUG_NO_PADDING 16
1337#define FF_BUG_AMV 32
1338#define FF_BUG_AC_VLC 0 ///< Will be removed, libavcodec can now handle these non-compliant files by default.
1339#define FF_BUG_QPEL_CHROMA 64
1340#define FF_BUG_STD_QPEL 128
1341#define FF_BUG_QPEL_CHROMA2 256
1342#define FF_BUG_DIRECT_BLOCKSIZE 512
1343#define FF_BUG_EDGE 1024
1344#define FF_BUG_HPEL_CHROMA 2048
1345#define FF_BUG_DC_CLIP 4096
1346#define FF_BUG_MS 8192 ///< Work around various bugs in Microsoft's broken decoders.
1347#define FF_BUG_TRUNCATED 16384
1348//#define FF_BUG_FAKE_SCALABILITY 16 //Autodetection should work 100%.
1349
1350 /**
1351 * luma single coefficient elimination threshold
1352 * - encoding: Set by user.
1353 * - decoding: unused
1354 */
1355 int luma_elim_threshold;
1356
1357 /**
1358 * chroma single coeff elimination threshold
1359 * - encoding: Set by user.
1360 * - decoding: unused
1361 */
1362 int chroma_elim_threshold;
1363
1364 /**
1365 * strictly follow the standard (MPEG4, ...).
1366 * - encoding: Set by user.
1367 * - decoding: Set by user.
1368 * Setting this to STRICT or higher means the encoder and decoder will
1369 * generally do stupid things, whereas setting it to unofficial or lower
1370 * will mean the encoder might produce output that is not supported by all
1371 * spec-compliant decoders. Decoders don't differentiate between normal,
1372 * unofficial and experimental (that is, they always try to decode things
1373 * when they can) unless they are explicitly asked to behave stupidly
1374 * (=strictly conform to the specs)
1375 */
1376 int strict_std_compliance;
1377#define FF_COMPLIANCE_VERY_STRICT 2 ///< Strictly conform to an older more strict version of the spec or reference software.
1378#define FF_COMPLIANCE_STRICT 1 ///< Strictly conform to all the things in the spec no matter what consequences.
1379#define FF_COMPLIANCE_NORMAL 0
1380#if LIBAVCODEC_VERSION_MAJOR < 53
1381#define FF_COMPLIANCE_INOFFICIAL -1 ///< Allow inofficial extensions (deprecated - use FF_COMPLIANCE_UNOFFICIAL instead).
1382#endif
1383#define FF_COMPLIANCE_UNOFFICIAL -1 ///< Allow unofficial extensions
1384#define FF_COMPLIANCE_EXPERIMENTAL -2 ///< Allow nonstandardized experimental things.
1385
1386 /**
1387 * qscale offset between IP and B-frames
1388 * - encoding: Set by user.
1389 * - decoding: unused
1390 */
1391 float b_quant_offset;
1392
1393 /**
1394 * Error recognization; higher values will detect more errors but may
1395 * misdetect some more or less valid parts as errors.
1396 * - encoding: unused
1397 * - decoding: Set by user.
1398 */
1399 int error_recognition;
1400#define FF_ER_CAREFUL 1
1401#define FF_ER_COMPLIANT 2
1402#define FF_ER_AGGRESSIVE 3
1403#define FF_ER_VERY_AGGRESSIVE 4
1404
1405 /**
1406 * Called at the beginning of each frame to get a buffer for it.
1407 * If pic.reference is set then the frame will be read later by libavcodec.
1408 * avcodec_align_dimensions2() should be used to find the required width and
1409 * height, as they normally need to be rounded up to the next multiple of 16.
1410 * if CODEC_CAP_DR1 is not set then get_buffer() must call
1411 * avcodec_default_get_buffer() instead of providing buffers allocated by
1412 * some other means.
1413 * - encoding: unused
1414 * - decoding: Set by libavcodec, user can override.
1415 */
1416 int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
1417
1418 /**
1419 * Called to release buffers which were allocated with get_buffer.
1420 * A released buffer can be reused in get_buffer().
1421 * pic.data[*] must be set to NULL.
1422 * - encoding: unused
1423 * - decoding: Set by libavcodec, user can override.
1424 */
1425 void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
1426
1427 /**
1428 * Size of the frame reordering buffer in the decoder.
1429 * For MPEG-2 it is 1 IPB or 0 low delay IP.
1430 * - encoding: Set by libavcodec.
1431 * - decoding: Set by libavcodec.
1432 */
1433 int has_b_frames;
1434
1435 /**
1436 * number of bytes per packet if constant and known or 0
1437 * Used by some WAV based audio codecs.
1438 */
1439 int block_align;
1440
1441 int parse_only; /* - decoding only: If true, only parsing is done
1442 (function avcodec_parse_frame()). The frame
1443 data is returned. Only MPEG codecs support this now. */
1444
1445 /**
1446 * 0-> h263 quant 1-> mpeg quant
1447 * - encoding: Set by user.
1448 * - decoding: unused
1449 */
1450 int mpeg_quant;
1451
1452 /**
1453 * pass1 encoding statistics output buffer
1454 * - encoding: Set by libavcodec.
1455 * - decoding: unused
1456 */
1457 char *stats_out;
1458
1459 /**
1460 * pass2 encoding statistics input buffer
1461 * Concatenated stuff from stats_out of pass1 should be placed here.
1462 * - encoding: Allocated/set/freed by user.
1463 * - decoding: unused
1464 */
1465 char *stats_in;
1466
1467 /**
1468 * ratecontrol qmin qmax limiting method
1469 * 0-> clipping, 1-> use a nice continous function to limit qscale wthin qmin/qmax.
1470 * - encoding: Set by user.
1471 * - decoding: unused
1472 */
1473 float rc_qsquish;
1474
1475 float rc_qmod_amp;
1476 int rc_qmod_freq;
1477
1478 /**
1479 * ratecontrol override, see RcOverride
1480 * - encoding: Allocated/set/freed by user.
1481 * - decoding: unused
1482 */
1483 RcOverride *rc_override;
1484 int rc_override_count;
1485
1486 /**
1487 * rate control equation
1488 * - encoding: Set by user
1489 * - decoding: unused
1490 */
1491 const char *rc_eq;
1492
1493 /**
1494 * maximum bitrate
1495 * - encoding: Set by user.
1496 * - decoding: unused
1497 */
1498 int rc_max_rate;
1499
1500 /**
1501 * minimum bitrate
1502 * - encoding: Set by user.
1503 * - decoding: unused
1504 */
1505 int rc_min_rate;
1506
1507 /**
1508 * decoder bitstream buffer size
1509 * - encoding: Set by user.
1510 * - decoding: unused
1511 */
1512 int rc_buffer_size;
1513 float rc_buffer_aggressivity;
1514
1515 /**
1516 * qscale factor between P and I-frames
1517 * If > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset).
1518 * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
1519 * - encoding: Set by user.
1520 * - decoding: unused
1521 */
1522 float i_quant_factor;
1523
1524 /**
1525 * qscale offset between P and I-frames
1526 * - encoding: Set by user.
1527 * - decoding: unused
1528 */
1529 float i_quant_offset;
1530
1531 /**
1532 * initial complexity for pass1 ratecontrol
1533 * - encoding: Set by user.
1534 * - decoding: unused
1535 */
1536 float rc_initial_cplx;
1537
1538 /**
1539 * DCT algorithm, see FF_DCT_* below
1540 * - encoding: Set by user.
1541 * - decoding: unused
1542 */
1543 int dct_algo;
1544#define FF_DCT_AUTO 0
1545#define FF_DCT_FASTINT 1
1546#define FF_DCT_INT 2
1547#define FF_DCT_MMX 3
1548#define FF_DCT_MLIB 4
1549#define FF_DCT_ALTIVEC 5
1550#define FF_DCT_FAAN 6
1551
1552 /**
1553 * luminance masking (0-> disabled)
1554 * - encoding: Set by user.
1555 * - decoding: unused
1556 */
1557 float lumi_masking;
1558
1559 /**
1560 * temporary complexity masking (0-> disabled)
1561 * - encoding: Set by user.
1562 * - decoding: unused
1563 */
1564 float temporal_cplx_masking;
1565
1566 /**
1567 * spatial complexity masking (0-> disabled)
1568 * - encoding: Set by user.
1569 * - decoding: unused
1570 */
1571 float spatial_cplx_masking;
1572
1573 /**
1574 * p block masking (0-> disabled)
1575 * - encoding: Set by user.
1576 * - decoding: unused
1577 */
1578 float p_masking;
1579
1580 /**
1581 * darkness masking (0-> disabled)
1582 * - encoding: Set by user.
1583 * - decoding: unused
1584 */
1585 float dark_masking;
1586
1587 /**
1588 * IDCT algorithm, see FF_IDCT_* below.
1589 * - encoding: Set by user.
1590 * - decoding: Set by user.
1591 */
1592 int idct_algo;
1593#define FF_IDCT_AUTO 0
1594#define FF_IDCT_INT 1
1595#define FF_IDCT_SIMPLE 2
1596#define FF_IDCT_SIMPLEMMX 3
1597#define FF_IDCT_LIBMPEG2MMX 4
1598#define FF_IDCT_PS2 5
1599#define FF_IDCT_MLIB 6
1600#define FF_IDCT_ARM 7
1601#define FF_IDCT_ALTIVEC 8
1602#define FF_IDCT_SH4 9
1603#define FF_IDCT_SIMPLEARM 10
1604#define FF_IDCT_H264 11
1605#define FF_IDCT_VP3 12
1606#define FF_IDCT_IPP 13
1607#define FF_IDCT_XVIDMMX 14
1608#define FF_IDCT_CAVS 15
1609#define FF_IDCT_SIMPLEARMV5TE 16
1610#define FF_IDCT_SIMPLEARMV6 17
1611#define FF_IDCT_SIMPLEVIS 18
1612#define FF_IDCT_WMV2 19
1613#define FF_IDCT_FAAN 20
1614#define FF_IDCT_EA 21
1615#define FF_IDCT_SIMPLENEON 22
1616#define FF_IDCT_SIMPLEALPHA 23
1617#define FF_IDCT_BINK 24
1618
1619 /**
1620 * slice count
1621 * - encoding: Set by libavcodec.
1622 * - decoding: Set by user (or 0).
1623 */
1624 int slice_count;
1625 /**
1626 * slice offsets in the frame in bytes
1627 * - encoding: Set/allocated by libavcodec.
1628 * - decoding: Set/allocated by user (or NULL).
1629 */
1630 int *slice_offset;
1631
1632 /**
1633 * error concealment flags
1634 * - encoding: unused
1635 * - decoding: Set by user.
1636 */
1637 int error_concealment;
1638#define FF_EC_GUESS_MVS 1
1639#define FF_EC_DEBLOCK 2
1640
1641 /**
1642 * dsp_mask could be add used to disable unwanted CPU features
1643 * CPU features (i.e. MMX, SSE. ...)
1644 *
1645 * With the FORCE flag you may instead enable given CPU features.
1646 * (Dangerous: Usable in case of misdetection, improper usage however will
1647 * result into program crash.)
1648 */
1649 unsigned dsp_mask;
1650#define FF_MM_FORCE 0x80000000 /* Force usage of selected flags (OR) */
1651 /* lower 16 bits - CPU features */
1652#define FF_MM_MMX 0x0001 ///< standard MMX
1653#define FF_MM_3DNOW 0x0004 ///< AMD 3DNOW
1654#if LIBAVCODEC_VERSION_MAJOR < 53
1655#define FF_MM_MMXEXT 0x0002 ///< SSE integer functions or AMD MMX ext
1656#endif
1657#define FF_MM_MMX2 0x0002 ///< SSE integer functions or AMD MMX ext
1658#define FF_MM_SSE 0x0008 ///< SSE functions
1659#define FF_MM_SSE2 0x0010 ///< PIV SSE2 functions
1660#define FF_MM_SSE2SLOW 0x40000000 ///< SSE2 supported, but usually not faster
1661 ///< than regular MMX/SSE (e.g. Core1)
1662#define FF_MM_3DNOWEXT 0x0020 ///< AMD 3DNowExt
1663#define FF_MM_SSE3 0x0040 ///< Prescott SSE3 functions
1664#define FF_MM_SSE3SLOW 0x20000000 ///< SSE3 supported, but usually not faster
1665 ///< than regular MMX/SSE (e.g. Core1)
1666#define FF_MM_SSSE3 0x0080 ///< Conroe SSSE3 functions
1667#define FF_MM_SSE4 0x0100 ///< Penryn SSE4.1 functions
1668#define FF_MM_SSE42 0x0200 ///< Nehalem SSE4.2 functions
1669#define FF_MM_IWMMXT 0x0100 ///< XScale IWMMXT
1670#define FF_MM_ALTIVEC 0x0001 ///< standard AltiVec
1671
1672 /**
1673 * bits per sample/pixel from the demuxer (needed for huffyuv).
1674 * - encoding: Set by libavcodec.
1675 * - decoding: Set by user.
1676 */
1677 int bits_per_coded_sample;
1678
1679 /**
1680 * prediction method (needed for huffyuv)
1681 * - encoding: Set by user.
1682 * - decoding: unused
1683 */
1684 int prediction_method;
1685#define FF_PRED_LEFT 0
1686#define FF_PRED_PLANE 1
1687#define FF_PRED_MEDIAN 2
1688
1689 /**
1690 * sample aspect ratio (0 if unknown)
1691 * That is the width of a pixel divided by the height of the pixel.
1692 * Numerator and denominator must be relatively prime and smaller than 256 for some video standards.
1693 * - encoding: Set by user.
1694 * - decoding: Set by libavcodec.
1695 */
1696 AVRational sample_aspect_ratio;
1697
1698 /**
1699 * the picture in the bitstream
1700 * - encoding: Set by libavcodec.
1701 * - decoding: Set by libavcodec.
1702 */
1703 AVFrame *coded_frame;
1704
1705 /**
1706 * debug
1707 * - encoding: Set by user.
1708 * - decoding: Set by user.
1709 */
1710 int debug;
1711#define FF_DEBUG_PICT_INFO 1
1712#define FF_DEBUG_RC 2
1713#define FF_DEBUG_BITSTREAM 4
1714#define FF_DEBUG_MB_TYPE 8
1715#define FF_DEBUG_QP 16
1716#define FF_DEBUG_MV 32
1717#define FF_DEBUG_DCT_COEFF 0x00000040
1718#define FF_DEBUG_SKIP 0x00000080
1719#define FF_DEBUG_STARTCODE 0x00000100
1720#define FF_DEBUG_PTS 0x00000200
1721#define FF_DEBUG_ER 0x00000400
1722#define FF_DEBUG_MMCO 0x00000800
1723#define FF_DEBUG_BUGS 0x00001000
1724#define FF_DEBUG_VIS_QP 0x00002000
1725#define FF_DEBUG_VIS_MB_TYPE 0x00004000
1726#define FF_DEBUG_BUFFERS 0x00008000
1727
1728 /**
1729 * debug
1730 * - encoding: Set by user.
1731 * - decoding: Set by user.
1732 */
1733 int debug_mv;
1734#define FF_DEBUG_VIS_MV_P_FOR 0x00000001 //visualize forward predicted MVs of P frames
1735#define FF_DEBUG_VIS_MV_B_FOR 0x00000002 //visualize forward predicted MVs of B frames
1736#define FF_DEBUG_VIS_MV_B_BACK 0x00000004 //visualize backward predicted MVs of B frames
1737
1738 /**
1739 * error
1740 * - encoding: Set by libavcodec if flags&CODEC_FLAG_PSNR.
1741 * - decoding: unused
1742 */
1743 uint64_t error[4];
1744
1745 /**
1746 * minimum MB quantizer
1747 * - encoding: unused
1748 * - decoding: unused
1749 */
1750 int mb_qmin;
1751
1752 /**
1753 * maximum MB quantizer
1754 * - encoding: unused
1755 * - decoding: unused
1756 */
1757 int mb_qmax;
1758
1759 /**
1760 * motion estimation comparison function
1761 * - encoding: Set by user.
1762 * - decoding: unused
1763 */
1764 int me_cmp;
1765 /**
1766 * subpixel motion estimation comparison function
1767 * - encoding: Set by user.
1768 * - decoding: unused
1769 */
1770 int me_sub_cmp;
1771 /**
1772 * macroblock comparison function (not supported yet)
1773 * - encoding: Set by user.
1774 * - decoding: unused
1775 */
1776 int mb_cmp;
1777 /**
1778 * interlaced DCT comparison function
1779 * - encoding: Set by user.
1780 * - decoding: unused
1781 */
1782 int ildct_cmp;
1783#define FF_CMP_SAD 0
1784#define FF_CMP_SSE 1
1785#define FF_CMP_SATD 2
1786#define FF_CMP_DCT 3
1787#define FF_CMP_PSNR 4
1788#define FF_CMP_BIT 5
1789#define FF_CMP_RD 6
1790#define FF_CMP_ZERO 7
1791#define FF_CMP_VSAD 8
1792#define FF_CMP_VSSE 9
1793#define FF_CMP_NSSE 10
1794#define FF_CMP_W53 11
1795#define FF_CMP_W97 12
1796#define FF_CMP_DCTMAX 13
1797#define FF_CMP_DCT264 14
1798#define FF_CMP_CHROMA 256
1799
1800 /**
1801 * ME diamond size & shape
1802 * - encoding: Set by user.
1803 * - decoding: unused
1804 */
1805 int dia_size;
1806
1807 /**
1808 * amount of previous MV predictors (2a+1 x 2a+1 square)
1809 * - encoding: Set by user.
1810 * - decoding: unused
1811 */
1812 int last_predictor_count;
1813
1814 /**
1815 * prepass for motion estimation
1816 * - encoding: Set by user.
1817 * - decoding: unused
1818 */
1819 int pre_me;
1820
1821 /**
1822 * motion estimation prepass comparison function
1823 * - encoding: Set by user.
1824 * - decoding: unused
1825 */
1826 int me_pre_cmp;
1827
1828 /**
1829 * ME prepass diamond size & shape
1830 * - encoding: Set by user.
1831 * - decoding: unused
1832 */
1833 int pre_dia_size;
1834
1835 /**
1836 * subpel ME quality
1837 * - encoding: Set by user.
1838 * - decoding: unused
1839 */
1840 int me_subpel_quality;
1841
1842 /**
1843 * callback to negotiate the pixelFormat
1844 * @param fmt is the list of formats which are supported by the codec,
1845 * it is terminated by -1 as 0 is a valid format, the formats are ordered by quality.
1846 * The first is always the native one.
1847 * @return the chosen format
1848 * - encoding: unused
1849 * - decoding: Set by user, if not set the native format will be chosen.
1850 */
1851 enum PixelFormat (*get_format)(struct AVCodecContext *s, const enum PixelFormat * fmt);
1852
1853 /**
1854 * DTG active format information (additional aspect ratio
1855 * information only used in DVB MPEG-2 transport streams)
1856 * 0 if not set.
1857 *
1858 * - encoding: unused
1859 * - decoding: Set by decoder.
1860 */
1861 int dtg_active_format;
1862#define FF_DTG_AFD_SAME 8
1863#define FF_DTG_AFD_4_3 9
1864#define FF_DTG_AFD_16_9 10
1865#define FF_DTG_AFD_14_9 11
1866#define FF_DTG_AFD_4_3_SP_14_9 13
1867#define FF_DTG_AFD_16_9_SP_14_9 14
1868#define FF_DTG_AFD_SP_4_3 15
1869
1870 /**
1871 * maximum motion estimation search range in subpel units
1872 * If 0 then no limit.
1873 *
1874 * - encoding: Set by user.
1875 * - decoding: unused
1876 */
1877 int me_range;
1878
1879 /**
1880 * intra quantizer bias
1881 * - encoding: Set by user.
1882 * - decoding: unused
1883 */
1884 int intra_quant_bias;
1885#define FF_DEFAULT_QUANT_BIAS 999999
1886
1887 /**
1888 * inter quantizer bias
1889 * - encoding: Set by user.
1890 * - decoding: unused
1891 */
1892 int inter_quant_bias;
1893
1894 /**
1895 * color table ID
1896 * - encoding: unused
1897 * - decoding: Which clrtable should be used for 8bit RGB images.
1898 * Tables have to be stored somewhere. FIXME
1899 */
1900 int color_table_id;
1901
1902 /**
1903 * internal_buffer count
1904 * Don't touch, used by libavcodec default_get_buffer().
1905 */
1906 int internal_buffer_count;
1907
1908 /**
1909 * internal_buffers
1910 * Don't touch, used by libavcodec default_get_buffer().
1911 */
1912 void *internal_buffer;
1913
1914#define FF_LAMBDA_SHIFT 7
1915#define FF_LAMBDA_SCALE (1<<FF_LAMBDA_SHIFT)
1916#define FF_QP2LAMBDA 118 ///< factor to convert from H.263 QP to lambda
1917#define FF_LAMBDA_MAX (256*128-1)
1918
1919#define FF_QUALITY_SCALE FF_LAMBDA_SCALE //FIXME maybe remove
1920 /**
1921 * Global quality for codecs which cannot change it per frame.
1922 * This should be proportional to MPEG-1/2/4 qscale.
1923 * - encoding: Set by user.
1924 * - decoding: unused
1925 */
1926 int global_quality;
1927
1928#define FF_CODER_TYPE_VLC 0
1929#define FF_CODER_TYPE_AC 1
1930#define FF_CODER_TYPE_RAW 2
1931#define FF_CODER_TYPE_RLE 3
1932#define FF_CODER_TYPE_DEFLATE 4
1933 /**
1934 * coder type
1935 * - encoding: Set by user.
1936 * - decoding: unused
1937 */
1938 int coder_type;
1939
1940 /**
1941 * context model
1942 * - encoding: Set by user.
1943 * - decoding: unused
1944 */
1945 int context_model;
1946#if 0
1947 /**
1948 *
1949 * - encoding: unused
1950 * - decoding: Set by user.
1951 */
1952 uint8_t * (*realloc)(struct AVCodecContext *s, uint8_t *buf, int buf_size);
1953#endif
1954
1955 /**
1956 * slice flags
1957 * - encoding: unused
1958 * - decoding: Set by user.
1959 */
1960 int slice_flags;
1961#define SLICE_FLAG_CODED_ORDER 0x0001 ///< draw_horiz_band() is called in coded order instead of display
1962#define SLICE_FLAG_ALLOW_FIELD 0x0002 ///< allow draw_horiz_band() with field slices (MPEG2 field pics)
1963#define SLICE_FLAG_ALLOW_PLANE 0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1)
1964
1965 /**
1966 * XVideo Motion Acceleration
1967 * - encoding: forbidden
1968 * - decoding: set by decoder
1969 */
1970 int xvmc_acceleration;
1971
1972 /**
1973 * macroblock decision mode
1974 * - encoding: Set by user.
1975 * - decoding: unused
1976 */
1977 int mb_decision;
1978#define FF_MB_DECISION_SIMPLE 0 ///< uses mb_cmp
1979#define FF_MB_DECISION_BITS 1 ///< chooses the one which needs the fewest bits
1980#define FF_MB_DECISION_RD 2 ///< rate distortion
1981
1982 /**
1983 * custom intra quantization matrix
1984 * - encoding: Set by user, can be NULL.
1985 * - decoding: Set by libavcodec.
1986 */
1987 uint16_t *intra_matrix;
1988
1989 /**
1990 * custom inter quantization matrix
1991 * - encoding: Set by user, can be NULL.
1992 * - decoding: Set by libavcodec.
1993 */
1994 uint16_t *inter_matrix;
1995
1996 /**
1997 * fourcc from the AVI stream header (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
1998 * This is used to work around some encoder bugs.
1999 * - encoding: unused
2000 * - decoding: Set by user, will be converted to uppercase by libavcodec during init.
2001 */
2002 unsigned int stream_codec_tag;
2003
2004 /**
2005 * scene change detection threshold
2006 * 0 is default, larger means fewer detected scene changes.
2007 * - encoding: Set by user.
2008 * - decoding: unused
2009 */
2010 int scenechange_threshold;
2011
2012 /**
2013 * minimum Lagrange multipler
2014 * - encoding: Set by user.
2015 * - decoding: unused
2016 */
2017 int lmin;
2018
2019 /**
2020 * maximum Lagrange multipler
2021 * - encoding: Set by user.
2022 * - decoding: unused
2023 */
2024 int lmax;
2025
2026 /**
2027 * palette control structure
2028 * - encoding: ??? (no palette-enabled encoder yet)
2029 * - decoding: Set by user.
2030 */
2031 struct AVPaletteControl *palctrl;
2032
2033 /**
2034 * noise reduction strength
2035 * - encoding: Set by user.
2036 * - decoding: unused
2037 */
2038 int noise_reduction;
2039
2040 /**
2041 * Called at the beginning of a frame to get cr buffer for it.
2042 * Buffer type (size, hints) must be the same. libavcodec won't check it.
2043 * libavcodec will pass previous buffer in pic, function should return
2044 * same buffer or new buffer with old frame "painted" into it.
2045 * If pic.data[0] == NULL must behave like get_buffer().
2046 * if CODEC_CAP_DR1 is not set then reget_buffer() must call
2047 * avcodec_default_reget_buffer() instead of providing buffers allocated by
2048 * some other means.
2049 * - encoding: unused
2050 * - decoding: Set by libavcodec, user can override.
2051 */
2052 int (*reget_buffer)(struct AVCodecContext *c, AVFrame *pic);
2053
2054 /**
2055 * Number of bits which should be loaded into the rc buffer before decoding starts.
2056 * - encoding: Set by user.
2057 * - decoding: unused
2058 */
2059 int rc_initial_buffer_occupancy;
2060
2061 /**
2062 *
2063 * - encoding: Set by user.
2064 * - decoding: unused
2065 */
2066 int inter_threshold;
2067
2068 /**
2069 * CODEC_FLAG2_*
2070 * - encoding: Set by user.
2071 * - decoding: Set by user.
2072 */
2073 int flags2;
2074
2075 /**
2076 * Simulates errors in the bitstream to test error concealment.
2077 * - encoding: Set by user.
2078 * - decoding: unused
2079 */
2080 int error_rate;
2081
2082 /**
2083 * MP3 antialias algorithm, see FF_AA_* below.
2084 * - encoding: unused
2085 * - decoding: Set by user.
2086 */
2087 int antialias_algo;
2088#define FF_AA_AUTO 0
2089#define FF_AA_FASTINT 1 //not implemented yet
2090#define FF_AA_INT 2
2091#define FF_AA_FLOAT 3
2092 /**
2093 * quantizer noise shaping
2094 * - encoding: Set by user.
2095 * - decoding: unused
2096 */
2097 int quantizer_noise_shaping;
2098
2099 /**
2100 * thread count
2101 * is used to decide how many independent tasks should be passed to execute()
2102 * - encoding: Set by user.
2103 * - decoding: Set by user.
2104 */
2105 int thread_count;
2106
2107 /**
2108 * The codec may call this to execute several independent things.
2109 * It will return only after finishing all tasks.
2110 * The user may replace this with some multithreaded implementation,
2111 * the default implementation will execute the parts serially.
2112 * @param count the number of things to execute
2113 * - encoding: Set by libavcodec, user can override.
2114 * - decoding: Set by libavcodec, user can override.
2115 */
2116 int (*execute)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size);
2117
2118 /**
2119 * thread opaque
2120 * Can be used by execute() to store some per AVCodecContext stuff.
2121 * - encoding: set by execute()
2122 * - decoding: set by execute()
2123 */
2124 void *thread_opaque;
2125
2126 /**
2127 * Motion estimation threshold below which no motion estimation is
2128 * performed, but instead the user specified motion vectors are used.
2129 *
2130 * - encoding: Set by user.
2131 * - decoding: unused
2132 */
2133 int me_threshold;
2134
2135 /**
2136 * Macroblock threshold below which the user specified macroblock types will be used.
2137 * - encoding: Set by user.
2138 * - decoding: unused
2139 */
2140 int mb_threshold;
2141
2142 /**
2143 * precision of the intra DC coefficient - 8
2144 * - encoding: Set by user.
2145 * - decoding: unused
2146 */
2147 int intra_dc_precision;
2148
2149 /**
2150 * noise vs. sse weight for the nsse comparsion function
2151 * - encoding: Set by user.
2152 * - decoding: unused
2153 */
2154 int nsse_weight;
2155
2156 /**
2157 * Number of macroblock rows at the top which are skipped.
2158 * - encoding: unused
2159 * - decoding: Set by user.
2160 */
2161 int skip_top;
2162
2163 /**
2164 * Number of macroblock rows at the bottom which are skipped.
2165 * - encoding: unused
2166 * - decoding: Set by user.
2167 */
2168 int skip_bottom;
2169
2170 /**
2171 * profile
2172 * - encoding: Set by user.
2173 * - decoding: Set by libavcodec.
2174 */
2175 int profile;
2176#define FF_PROFILE_UNKNOWN -99
2177
2178#define FF_PROFILE_AAC_MAIN 0
2179#define FF_PROFILE_AAC_LOW 1
2180#define FF_PROFILE_AAC_SSR 2
2181#define FF_PROFILE_AAC_LTP 3
2182
2183#define FF_PROFILE_H264_BASELINE 66
2184#define FF_PROFILE_H264_MAIN 77
2185#define FF_PROFILE_H264_EXTENDED 88
2186#define FF_PROFILE_H264_HIGH 100
2187#define FF_PROFILE_H264_HIGH_10 110
2188#define FF_PROFILE_H264_HIGH_422 122
2189#define FF_PROFILE_H264_HIGH_444 244
2190#define FF_PROFILE_H264_CAVLC_444 44
2191
2192 /**
2193 * level
2194 * - encoding: Set by user.
2195 * - decoding: Set by libavcodec.
2196 */
2197 int level;
2198#define FF_LEVEL_UNKNOWN -99
2199
2200 /**
2201 * low resolution decoding, 1-> 1/2 size, 2->1/4 size
2202 * - encoding: unused
2203 * - decoding: Set by user.
2204 */
2205 int lowres;
2206
2207 /**
2208 * Bitstream width / height, may be different from width/height if lowres
2209 * or other things are used.
2210 * - encoding: unused
2211 * - decoding: Set by user before init if known. Codec should override / dynamically change if needed.
2212 */
2213 int coded_width, coded_height;
2214
2215 /**
2216 * frame skip threshold
2217 * - encoding: Set by user.
2218 * - decoding: unused
2219 */
2220 int frame_skip_threshold;
2221
2222 /**
2223 * frame skip factor
2224 * - encoding: Set by user.
2225 * - decoding: unused
2226 */
2227 int frame_skip_factor;
2228
2229 /**
2230 * frame skip exponent
2231 * - encoding: Set by user.
2232 * - decoding: unused
2233 */
2234 int frame_skip_exp;
2235
2236 /**
2237 * frame skip comparison function
2238 * - encoding: Set by user.
2239 * - decoding: unused
2240 */
2241 int frame_skip_cmp;
2242
2243 /**
2244 * Border processing masking, raises the quantizer for mbs on the borders
2245 * of the picture.
2246 * - encoding: Set by user.
2247 * - decoding: unused
2248 */
2249 float border_masking;
2250
2251 /**
2252 * minimum MB lagrange multipler
2253 * - encoding: Set by user.
2254 * - decoding: unused
2255 */
2256 int mb_lmin;
2257
2258 /**
2259 * maximum MB lagrange multipler
2260 * - encoding: Set by user.
2261 * - decoding: unused
2262 */
2263 int mb_lmax;
2264
2265 /**
2266 *
2267 * - encoding: Set by user.
2268 * - decoding: unused
2269 */
2270 int me_penalty_compensation;
2271
2272 /**
2273 *
2274 * - encoding: unused
2275 * - decoding: Set by user.
2276 */
2277 enum AVDiscard skip_loop_filter;
2278
2279 /**
2280 *
2281 * - encoding: unused
2282 * - decoding: Set by user.
2283 */
2284 enum AVDiscard skip_idct;
2285
2286 /**
2287 *
2288 * - encoding: unused
2289 * - decoding: Set by user.
2290 */
2291 enum AVDiscard skip_frame;
2292
2293 /**
2294 *
2295 * - encoding: Set by user.
2296 * - decoding: unused
2297 */
2298 int bidir_refine;
2299
2300 /**
2301 *
2302 * - encoding: Set by user.
2303 * - decoding: unused
2304 */
2305 int brd_scale;
2306
2307 /**
2308 * constant rate factor - quality-based VBR - values ~correspond to qps
2309 * - encoding: Set by user.
2310 * - decoding: unused
2311 */
2312 float crf;
2313
2314 /**
2315 * constant quantization parameter rate control method
2316 * - encoding: Set by user.
2317 * - decoding: unused
2318 */
2319 int cqp;
2320
2321 /**
2322 * minimum GOP size
2323 * - encoding: Set by user.
2324 * - decoding: unused
2325 */
2326 int keyint_min;
2327
2328 /**
2329 * number of reference frames
2330 * - encoding: Set by user.
2331 * - decoding: Set by lavc.
2332 */
2333 int refs;
2334
2335 /**
2336 * chroma qp offset from luma
2337 * - encoding: Set by user.
2338 * - decoding: unused
2339 */
2340 int chromaoffset;
2341
2342 /**
2343 * Influences how often B-frames are used.
2344 * - encoding: Set by user.
2345 * - decoding: unused
2346 */
2347 int bframebias;
2348
2349 /**
2350 * trellis RD quantization
2351 * - encoding: Set by user.
2352 * - decoding: unused
2353 */
2354 int trellis;
2355
2356 /**
2357 * Reduce fluctuations in qp (before curve compression).
2358 * - encoding: Set by user.
2359 * - decoding: unused
2360 */
2361 float complexityblur;
2362
2363 /**
2364 * in-loop deblocking filter alphac0 parameter
2365 * alpha is in the range -6...6
2366 * - encoding: Set by user.
2367 * - decoding: unused
2368 */
2369 int deblockalpha;
2370
2371 /**
2372 * in-loop deblocking filter beta parameter
2373 * beta is in the range -6...6
2374 * - encoding: Set by user.
2375 * - decoding: unused
2376 */
2377 int deblockbeta;
2378
2379 /**
2380 * macroblock subpartition sizes to consider - p8x8, p4x4, b8x8, i8x8, i4x4
2381 * - encoding: Set by user.
2382 * - decoding: unused
2383 */
2384 int partitions;
2385#define X264_PART_I4X4 0x001 /* Analyze i4x4 */
2386#define X264_PART_I8X8 0x002 /* Analyze i8x8 (requires 8x8 transform) */
2387#define X264_PART_P8X8 0x010 /* Analyze p16x8, p8x16 and p8x8 */
2388#define X264_PART_P4X4 0x020 /* Analyze p8x4, p4x8, p4x4 */
2389#define X264_PART_B8X8 0x100 /* Analyze b16x8, b8x16 and b8x8 */
2390
2391 /**
2392 * direct MV prediction mode - 0 (none), 1 (spatial), 2 (temporal), 3 (auto)
2393 * - encoding: Set by user.
2394 * - decoding: unused
2395 */
2396 int directpred;
2397
2398 /**
2399 * Audio cutoff bandwidth (0 means "automatic")
2400 * - encoding: Set by user.
2401 * - decoding: unused
2402 */
2403 int cutoff;
2404
2405 /**
2406 * Multiplied by qscale for each frame and added to scene_change_score.
2407 * - encoding: Set by user.
2408 * - decoding: unused
2409 */
2410 int scenechange_factor;
2411
2412 /**
2413 *
2414 * Note: Value depends upon the compare function used for fullpel ME.
2415 * - encoding: Set by user.
2416 * - decoding: unused
2417 */
2418 int mv0_threshold;
2419
2420 /**
2421 * Adjusts sensitivity of b_frame_strategy 1.
2422 * - encoding: Set by user.
2423 * - decoding: unused
2424 */
2425 int b_sensitivity;
2426
2427 /**
2428 * - encoding: Set by user.
2429 * - decoding: unused
2430 */
2431 int compression_level;
2432#define FF_COMPRESSION_DEFAULT -1
2433
2434#if LIBAVCODEC_VERSION_MAJOR < 53
2435 /**
2436 * Sets whether to use LPC mode - used by FLAC encoder.
2437 * - encoding: Set by user.
2438 * - decoding: unused
2439 * @deprecated Deprecated in favor of lpc_type and lpc_passes.
2440 */
2441 int use_lpc;
2442#endif
2443
2444 /**
2445 * LPC coefficient precision - used by FLAC encoder
2446 * - encoding: Set by user.
2447 * - decoding: unused
2448 */
2449 int lpc_coeff_precision;
2450
2451 /**
2452 * - encoding: Set by user.
2453 * - decoding: unused
2454 */
2455 int min_prediction_order;
2456
2457 /**
2458 * - encoding: Set by user.
2459 * - decoding: unused
2460 */
2461 int max_prediction_order;
2462
2463 /**
2464 * search method for selecting prediction order
2465 * - encoding: Set by user.
2466 * - decoding: unused
2467 */
2468 int prediction_order_method;
2469
2470 /**
2471 * - encoding: Set by user.
2472 * - decoding: unused
2473 */
2474 int min_partition_order;
2475
2476 /**
2477 * - encoding: Set by user.
2478 * - decoding: unused
2479 */
2480 int max_partition_order;
2481
2482 /**
2483 * GOP timecode frame start number, in non drop frame format
2484 * - encoding: Set by user.
2485 * - decoding: unused
2486 */
2487 int64_t timecode_frame_start;
2488
2489#if LIBAVCODEC_VERSION_MAJOR < 53
2490 /**
2491 * Decoder should decode to this many channels if it can (0 for default)
2492 * - encoding: unused
2493 * - decoding: Set by user.
2494 * @deprecated Deprecated in favor of request_channel_layout.
2495 */
2496 int request_channels;
2497#endif
2498
2499 /**
2500 * Percentage of dynamic range compression to be applied by the decoder.
2501 * The default value is 1.0, corresponding to full compression.
2502 * - encoding: unused
2503 * - decoding: Set by user.
2504 */
2505 float drc_scale;
2506
2507 /**
2508 * opaque 64bit number (generally a PTS) that will be reordered and
2509 * output in AVFrame.reordered_opaque
2510 * - encoding: unused
2511 * - decoding: Set by user.
2512 */
2513 int64_t reordered_opaque;
2514
2515 /**
2516 * Bits per sample/pixel of internal libavcodec pixel/sample format.
2517 * This field is applicable only when sample_fmt is SAMPLE_FMT_S32.
2518 * - encoding: set by user.
2519 * - decoding: set by libavcodec.
2520 */
2521 int bits_per_raw_sample;
2522
2523 /**
2524 * Audio channel layout.
2525 * - encoding: set by user.
2526 * - decoding: set by libavcodec.
2527 */
2528 int64_t channel_layout;
2529
2530 /**
2531 * Request decoder to use this channel layout if it can (0 for default)
2532 * - encoding: unused
2533 * - decoding: Set by user.
2534 */
2535 int64_t request_channel_layout;
2536
2537 /**
2538 * Ratecontrol attempt to use, at maximum, <value> of what can be used without an underflow.
2539 * - encoding: Set by user.
2540 * - decoding: unused.
2541 */
2542 float rc_max_available_vbv_use;
2543
2544 /**
2545 * Ratecontrol attempt to use, at least, <value> times the amount needed to prevent a vbv overflow.
2546 * - encoding: Set by user.
2547 * - decoding: unused.
2548 */
2549 float rc_min_vbv_overflow_use;
2550
2551 /**
2552 * Hardware accelerator in use
2553 * - encoding: unused.
2554 * - decoding: Set by libavcodec
2555 */
2556 struct AVHWAccel *hwaccel;
2557
2558 /**
2559 * For some codecs, the time base is closer to the field rate than the frame rate.
2560 * Most notably, H.264 and MPEG-2 specify time_base as half of frame duration
2561 * if no telecine is used ...
2562 *
2563 * Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2.
2564 */
2565 int ticks_per_frame;
2566
2567 /**
2568 * Hardware accelerator context.
2569 * For some hardware accelerators, a global context needs to be
2570 * provided by the user. In that case, this holds display-dependent
2571 * data FFmpeg cannot instantiate itself. Please refer to the
2572 * FFmpeg HW accelerator documentation to know how to fill this
2573 * is. e.g. for VA API, this is a struct vaapi_context.
2574 * - encoding: unused
2575 * - decoding: Set by user
2576 */
2577 void *hwaccel_context;
2578
2579 /**
2580 * Chromaticity coordinates of the source primaries.
2581 * - encoding: Set by user
2582 * - decoding: Set by libavcodec
2583 */
2584 enum AVColorPrimaries color_primaries;
2585
2586 /**
2587 * Color Transfer Characteristic.
2588 * - encoding: Set by user
2589 * - decoding: Set by libavcodec
2590 */
2591 enum AVColorTransferCharacteristic color_trc;
2592
2593 /**
2594 * YUV colorspace type.
2595 * - encoding: Set by user
2596 * - decoding: Set by libavcodec
2597 */
2598 enum AVColorSpace colorspace;
2599
2600 /**
2601 * MPEG vs JPEG YUV range.
2602 * - encoding: Set by user
2603 * - decoding: Set by libavcodec
2604 */
2605 enum AVColorRange color_range;
2606
2607 /**
2608 * This defines the location of chroma samples.
2609 * - encoding: Set by user
2610 * - decoding: Set by libavcodec
2611 */
2612 enum AVChromaLocation chroma_sample_location;
2613
2614 /**
2615 * The codec may call this to execute several independent things.
2616 * It will return only after finishing all tasks.
2617 * The user may replace this with some multithreaded implementation,
2618 * the default implementation will execute the parts serially.
2619 * Also see avcodec_thread_init and e.g. the --enable-pthread configure option.
2620 * @param c context passed also to func
2621 * @param count the number of things to execute
2622 * @param arg2 argument passed unchanged to func
2623 * @param ret return values of executed functions, must have space for "count" values. May be NULL.
2624 * @param func function that will be called count times, with jobnr from 0 to count-1.
2625 * threadnr will be in the range 0 to c->thread_count-1 < MAX_THREADS and so that no
2626 * two instances of func executing at the same time will have the same threadnr.
2627 * @return always 0 currently, but code should handle a future improvement where when any call to func
2628 * returns < 0 no further calls to func may be done and < 0 is returned.
2629 * - encoding: Set by libavcodec, user can override.
2630 * - decoding: Set by libavcodec, user can override.
2631 */
2632 int (*execute2)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count);
2633
2634 /**
2635 * explicit P-frame weighted prediction analysis method
2636 * 0: off
2637 * 1: fast blind weighting (one reference duplicate with -1 offset)
2638 * 2: smart weighting (full fade detection analysis)
2639 * - encoding: Set by user.
2640 * - decoding: unused
2641 */
2642 int weighted_p_pred;
2643
2644 /**
2645 * AQ mode
2646 * 0: Disabled
2647 * 1: Variance AQ (complexity mask)
2648 * 2: Auto-variance AQ (experimental)
2649 * - encoding: Set by user
2650 * - decoding: unused
2651 */
2652 int aq_mode;
2653
2654 /**
2655 * AQ strength
2656 * Reduces blocking and blurring in flat and textured areas.
2657 * - encoding: Set by user
2658 * - decoding: unused
2659 */
2660 float aq_strength;
2661
2662 /**
2663 * PSY RD
2664 * Strength of psychovisual optimization
2665 * - encoding: Set by user
2666 * - decoding: unused
2667 */
2668 float psy_rd;
2669
2670 /**
2671 * PSY trellis
2672 * Strength of psychovisual optimization
2673 * - encoding: Set by user
2674 * - decoding: unused
2675 */
2676 float psy_trellis;
2677
2678 /**
2679 * RC lookahead
2680 * Number of frames for frametype and ratecontrol lookahead
2681 * - encoding: Set by user
2682 * - decoding: unused
2683 */
2684 int rc_lookahead;
2685
2686 /**
2687 * Constant rate factor maximum
2688 * With CRF encoding mode and VBV restrictions enabled, prevents quality from being worse
2689 * than crf_max, even if doing so would violate VBV restrictions.
2690 * - encoding: Set by user.
2691 * - decoding: unused
2692 */
2693 float crf_max;
2694
2695 int log_level_offset;
2696
2697 /**
2698 * Determines which LPC analysis algorithm to use.
2699 * - encoding: Set by user
2700 * - decoding: unused
2701 */
2702 enum AVLPCType lpc_type;
2703
2704 /**
2705 * Number of passes to use for Cholesky factorization during LPC analysis
2706 * - encoding: Set by user
2707 * - decoding: unused
2708 */
2709 int lpc_passes;
2710} AVCodecContext;
2711
2712/**
2713 * AVCodec.
2714 */
2715typedef struct AVCodec {
2716 /**
2717 * Name of the codec implementation.
2718 * The name is globally unique among encoders and among decoders (but an
2719 * encoder and a decoder can share the same name).
2720 * This is the primary way to find a codec from the user perspective.
2721 */
2722 const char *name;
2723 enum AVMediaType type;
2724 enum CodecID id;
2725 int priv_data_size;
2726 int (*init)(AVCodecContext *);
2727 int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data);
2728 int (*close)(AVCodecContext *);
2729 int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, AVPacket *avpkt);
2730 /**
2731 * Codec capabilities.
2732 * see CODEC_CAP_*
2733 */
2734 int capabilities;
2735 struct AVCodec *next;
2736 /**
2737 * Flush buffers.
2738 * Will be called when seeking
2739 */
2740 void (*flush)(AVCodecContext *);
2741 const AVRational *supported_framerates; ///< array of supported framerates, or NULL if any, array is terminated by {0,0}
2742 const enum PixelFormat *pix_fmts; ///< array of supported pixel formats, or NULL if unknown, array is terminated by -1
2743 /**
2744 * Descriptive name for the codec, meant to be more human readable than name.
2745 * You should use the NULL_IF_CONFIG_SMALL() macro to define it.
2746 */
2747 const char *long_name;
2748 const int *supported_samplerates; ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0
2749 const enum SampleFormat *sample_fmts; ///< array of supported sample formats, or NULL if unknown, array is terminated by -1
2750 const int64_t *channel_layouts; ///< array of support channel layouts, or NULL if unknown. array is terminated by 0
2751 uint8_t max_lowres; ///< maximum value for lowres supported by the decoder
2752} AVCodec;
2753
2754/**
2755 * AVHWAccel.
2756 */
2757typedef struct AVHWAccel {
2758 /**
2759 * Name of the hardware accelerated codec.
2760 * The name is globally unique among encoders and among decoders (but an
2761 * encoder and a decoder can share the same name).
2762 */
2763 const char *name;
2764
2765 /**
2766 * Type of codec implemented by the hardware accelerator.
2767 *
2768 * See AVMEDIA_TYPE_xxx
2769 */
2770 enum AVMediaType type;
2771
2772 /**
2773 * Codec implemented by the hardware accelerator.
2774 *
2775 * See CODEC_ID_xxx
2776 */
2777 enum CodecID id;
2778
2779 /**
2780 * Supported pixel format.
2781 *
2782 * Only hardware accelerated formats are supported here.
2783 */
2784 enum PixelFormat pix_fmt;
2785
2786 /**
2787 * Hardware accelerated codec capabilities.
2788 * see FF_HWACCEL_CODEC_CAP_*
2789 */
2790 int capabilities;
2791
2792 struct AVHWAccel *next;
2793
2794 /**
2795 * Called at the beginning of each frame or field picture.
2796 *
2797 * Meaningful frame information (codec specific) is guaranteed to
2798 * be parsed at this point. This function is mandatory.
2799 *
2800 * Note that buf can be NULL along with buf_size set to 0.
2801 * Otherwise, this means the whole frame is available at this point.
2802 *
2803 * @param avctx the codec context
2804 * @param buf the frame data buffer base
2805 * @param buf_size the size of the frame in bytes
2806 * @return zero if successful, a negative value otherwise
2807 */
2808 int (*start_frame)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size);
2809
2810 /**
2811 * Callback for each slice.
2812 *
2813 * Meaningful slice information (codec specific) is guaranteed to
2814 * be parsed at this point. This function is mandatory.
2815 *
2816 * @param avctx the codec context
2817 * @param buf the slice data buffer base
2818 * @param buf_size the size of the slice in bytes
2819 * @return zero if successful, a negative value otherwise
2820 */
2821 int (*decode_slice)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size);
2822
2823 /**
2824 * Called at the end of each frame or field picture.
2825 *
2826 * The whole picture is parsed at this point and can now be sent
2827 * to the hardware accelerator. This function is mandatory.
2828 *
2829 * @param avctx the codec context
2830 * @return zero if successful, a negative value otherwise
2831 */
2832 int (*end_frame)(AVCodecContext *avctx);
2833
2834 /**
2835 * Size of HW accelerator private data.
2836 *
2837 * Private data is allocated with av_mallocz() before
2838 * AVCodecContext.get_buffer() and deallocated after
2839 * AVCodecContext.release_buffer().
2840 */
2841 int priv_data_size;
2842} AVHWAccel;
2843
2844/**
2845 * four components are given, that's all.
2846 * the last component is alpha
2847 */
2848typedef struct AVPicture {
2849 uint8_t *data[4];
2850 int linesize[4]; ///< number of bytes per line
2851} AVPicture;
2852
2853#if LIBAVCODEC_VERSION_MAJOR < 53
2854/**
2855 * AVPaletteControl
2856 * This structure defines a method for communicating palette changes
2857 * between and demuxer and a decoder.
2858 *
2859 * @deprecated Use AVPacket to send palette changes instead.
2860 * This is totally broken.
2861 */
2862#define AVPALETTE_SIZE 1024
2863#define AVPALETTE_COUNT 256
2864typedef struct AVPaletteControl {
2865
2866 /* Demuxer sets this to 1 to indicate the palette has changed;
2867 * decoder resets to 0. */
2868 int palette_changed;
2869
2870 /* 4-byte ARGB palette entries, stored in native byte order; note that
2871 * the individual palette components should be on a 8-bit scale; if
2872 * the palette data comes from an IBM VGA native format, the component
2873 * data is probably 6 bits in size and needs to be scaled. */
2874 unsigned int palette[AVPALETTE_COUNT];
2875
2876} AVPaletteControl attribute_deprecated;
2877#endif
2878
2879enum AVSubtitleType {
2880 SUBTITLE_NONE,
2881
2882 SUBTITLE_BITMAP, ///< A bitmap, pict will be set
2883
2884 /**
2885 * Plain text, the text field must be set by the decoder and is
2886 * authoritative. ass and pict fields may contain approximations.
2887 */
2888 SUBTITLE_TEXT,
2889
2890 /**
2891 * Formatted text, the ass field must be set by the decoder and is
2892 * authoritative. pict and text fields may contain approximations.
2893 */
2894 SUBTITLE_ASS,
2895};
2896
2897typedef struct AVSubtitleRect {
2898 int x; ///< top left corner of pict, undefined when pict is not set
2899 int y; ///< top left corner of pict, undefined when pict is not set
2900 int w; ///< width of pict, undefined when pict is not set
2901 int h; ///< height of pict, undefined when pict is not set
2902 int nb_colors; ///< number of colors in pict, undefined when pict is not set
2903
2904 /**
2905 * data+linesize for the bitmap of this subtitle.
2906 * can be set for text/ass as well once they where rendered
2907 */
2908 AVPicture pict;
2909 enum AVSubtitleType type;
2910
2911 char *text; ///< 0 terminated plain UTF-8 text
2912
2913 /**
2914 * 0 terminated ASS/SSA compatible event line.
2915 * The pressentation of this is unaffected by the other values in this
2916 * struct.
2917 */
2918 char *ass;
2919} AVSubtitleRect;
2920
2921typedef struct AVSubtitle {
2922 uint16_t format; /* 0 = graphics */
2923 uint32_t start_display_time; /* relative to packet pts, in ms */
2924 uint32_t end_display_time; /* relative to packet pts, in ms */
2925 unsigned num_rects;
2926 AVSubtitleRect **rects;
2927 int64_t pts; ///< Same as packet pts, in AV_TIME_BASE
2928} AVSubtitle;
2929
2930/* packet functions */
2931
2932/**
2933 * @deprecated use NULL instead
2934 */
2935attribute_deprecated void av_destruct_packet_nofree(AVPacket *pkt);
2936
2937/**
2938 * Default packet destructor.
2939 */
2940void av_destruct_packet(AVPacket *pkt);
2941
2942/**
2943 * Initialize optional fields of a packet with default values.
2944 *
2945 * @param pkt packet
2946 */
2947void av_init_packet(AVPacket *pkt);
2948
2949/**
2950 * Allocate the payload of a packet and initialize its fields with
2951 * default values.
2952 *
2953 * @param pkt packet
2954 * @param size wanted payload size
2955 * @return 0 if OK, AVERROR_xxx otherwise
2956 */
2957int av_new_packet(AVPacket *pkt, int size);
2958
2959/**
2960 * Reduce packet size, correctly zeroing padding
2961 *
2962 * @param pkt packet
2963 * @param size new size
2964 */
2965void av_shrink_packet(AVPacket *pkt, int size);
2966
2967/**
2968 * @warning This is a hack - the packet memory allocation stuff is broken. The
2969 * packet is allocated if it was not really allocated.
2970 */
2971int av_dup_packet(AVPacket *pkt);
2972
2973/**
2974 * Free a packet.
2975 *
2976 * @param pkt packet to free
2977 */
2978void av_free_packet(AVPacket *pkt);
2979
2980/* resample.c */
2981
2982struct ReSampleContext;
2983struct AVResampleContext;
2984
2985typedef struct ReSampleContext ReSampleContext;
2986
2987#if LIBAVCODEC_VERSION_MAJOR < 53
2988/**
2989 * @deprecated Use av_audio_resample_init() instead.
2990 */
2991attribute_deprecated ReSampleContext *audio_resample_init(int output_channels, int input_channels,
2992 int output_rate, int input_rate);
2993#endif
2994/**
2995 * Initialize audio resampling context
2996 *
2997 * @param output_channels number of output channels
2998 * @param input_channels number of input channels
2999 * @param output_rate output sample rate
3000 * @param input_rate input sample rate
3001 * @param sample_fmt_out requested output sample format
3002 * @param sample_fmt_in input sample format
3003 * @param filter_length length of each FIR filter in the filterbank relative to the cutoff freq
3004 * @param log2_phase_count log2 of the number of entries in the polyphase filterbank
3005 * @param linear If 1 then the used FIR filter will be linearly interpolated
3006 between the 2 closest, if 0 the closest will be used
3007 * @param cutoff cutoff frequency, 1.0 corresponds to half the output sampling rate
3008 * @return allocated ReSampleContext, NULL if error occured
3009 */
3010ReSampleContext *av_audio_resample_init(int output_channels, int input_channels,
3011 int output_rate, int input_rate,
3012 enum SampleFormat sample_fmt_out,
3013 enum SampleFormat sample_fmt_in,
3014 int filter_length, int log2_phase_count,
3015 int linear, double cutoff);
3016
3017int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
3018void audio_resample_close(ReSampleContext *s);
3019
3020
3021/**
3022 * Initialize an audio resampler.
3023 * Note, if either rate is not an integer then simply scale both rates up so they are.
3024 * @param filter_length length of each FIR filter in the filterbank relative to the cutoff freq
3025 * @param log2_phase_count log2 of the number of entries in the polyphase filterbank
3026 * @param linear If 1 then the used FIR filter will be linearly interpolated
3027 between the 2 closest, if 0 the closest will be used
3028 * @param cutoff cutoff frequency, 1.0 corresponds to half the output sampling rate
3029 */
3030struct AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_length, int log2_phase_count, int linear, double cutoff);
3031
3032/**
3033 * Resample an array of samples using a previously configured context.
3034 * @param src an array of unconsumed samples
3035 * @param consumed the number of samples of src which have been consumed are returned here
3036 * @param src_size the number of unconsumed samples available
3037 * @param dst_size the amount of space in samples available in dst
3038 * @param update_ctx If this is 0 then the context will not be modified, that way several channels can be resampled with the same context.
3039 * @return the number of samples written in dst or -1 if an error occurred
3040 */
3041int av_resample(struct AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx);
3042
3043
3044/**
3045 * Compensate samplerate/timestamp drift. The compensation is done by changing
3046 * the resampler parameters, so no audible clicks or similar distortions occur
3047 * @param compensation_distance distance in output samples over which the compensation should be performed
3048 * @param sample_delta number of output samples which should be output less
3049 *
3050 * example: av_resample_compensate(c, 10, 500)
3051 * here instead of 510 samples only 500 samples would be output
3052 *
3053 * note, due to rounding the actual compensation might be slightly different,
3054 * especially if the compensation_distance is large and the in_rate used during init is small
3055 */
3056void av_resample_compensate(struct AVResampleContext *c, int sample_delta, int compensation_distance);
3057void av_resample_close(struct AVResampleContext *c);
3058
3059/**
3060 * Allocate memory for a picture. Call avpicture_free to free it.
3061 *
3062 * @param picture the picture to be filled in
3063 * @param pix_fmt the format of the picture
3064 * @param width the width of the picture
3065 * @param height the height of the picture
3066 * @return zero if successful, a negative value if not
3067 */
3068int avpicture_alloc(AVPicture *picture, enum PixelFormat pix_fmt, int width, int height);
3069
3070/**
3071 * Free a picture previously allocated by avpicture_alloc().
3072 *
3073 * @param picture the AVPicture to be freed
3074 */
3075void avpicture_free(AVPicture *picture);
3076
3077/**
3078 * Fill in the AVPicture fields.
3079 * The fields of the given AVPicture are filled in by using the 'ptr' address
3080 * which points to the image data buffer. Depending on the specified picture
3081 * format, one or multiple image data pointers and line sizes will be set.
3082 * If a planar format is specified, several pointers will be set pointing to
3083 * the different picture planes and the line sizes of the different planes
3084 * will be stored in the lines_sizes array.
3085 * Call with ptr == NULL to get the required size for the ptr buffer.
3086 *
3087 * @param picture AVPicture whose fields are to be filled in
3088 * @param ptr Buffer which will contain or contains the actual image data
3089 * @param pix_fmt The format in which the picture data is stored.
3090 * @param width the width of the image in pixels
3091 * @param height the height of the image in pixels
3092 * @return size of the image data in bytes
3093 */
3094int avpicture_fill(AVPicture *picture, uint8_t *ptr,
3095 enum PixelFormat pix_fmt, int width, int height);
3096int avpicture_layout(const AVPicture* src, enum PixelFormat pix_fmt, int width, int height,
3097 unsigned char *dest, int dest_size);
3098
3099/**
3100 * Calculate the size in bytes that a picture of the given width and height
3101 * would occupy if stored in the given picture format.
3102 * Note that this returns the size of a compact representation as generated
3103 * by avpicture_layout, which can be smaller than the size required for e.g.
3104 * avpicture_fill.
3105 *
3106 * @param pix_fmt the given picture format
3107 * @param width the width of the image
3108 * @param height the height of the image
3109 * @return Image data size in bytes or -1 on error (e.g. too large dimensions).
3110 */
3111int avpicture_get_size(enum PixelFormat pix_fmt, int width, int height);
3112void avcodec_get_chroma_sub_sample(enum PixelFormat pix_fmt, int *h_shift, int *v_shift);
3113const char *avcodec_get_pix_fmt_name(enum PixelFormat pix_fmt);
3114void avcodec_set_dimensions(AVCodecContext *s, int width, int height);
3115
3116#if LIBAVCODEC_VERSION_MAJOR < 53
3117/**
3118 * Return the pixel format corresponding to the name name.
3119 *
3120 * If there is no pixel format with name name, then look for a
3121 * pixel format with the name corresponding to the native endian
3122 * format of name.
3123 * For example in a little-endian system, first look for "gray16",
3124 * then for "gray16le".
3125 *
3126 * Finally if no pixel format has been found, return PIX_FMT_NONE.
3127 *
3128 * @deprecated Deprecated in favor of av_get_pix_fmt().
3129 */
3130attribute_deprecated enum PixelFormat avcodec_get_pix_fmt(const char* name);
3131#endif
3132
3133/**
3134 * Return a value representing the fourCC code associated to the
3135 * pixel format pix_fmt, or 0 if no associated fourCC code can be
3136 * found.
3137 */
3138unsigned int avcodec_pix_fmt_to_codec_tag(enum PixelFormat pix_fmt);
3139
3140/**
3141 * Put a string representing the codec tag codec_tag in buf.
3142 *
3143 * @param buf_size size in bytes of buf
3144 * @return the length of the string that would have been generated if
3145 * enough space had been available, excluding the trailing null
3146 */
3147size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag);
3148
3149#define FF_LOSS_RESOLUTION 0x0001 /**< loss due to resolution change */
3150#define FF_LOSS_DEPTH 0x0002 /**< loss due to color depth change */
3151#define FF_LOSS_COLORSPACE 0x0004 /**< loss due to color space conversion */
3152#define FF_LOSS_ALPHA 0x0008 /**< loss of alpha bits */
3153#define FF_LOSS_COLORQUANT 0x0010 /**< loss due to color quantization */
3154#define FF_LOSS_CHROMA 0x0020 /**< loss of chroma (e.g. RGB to gray conversion) */
3155
3156/**
3157 * Compute what kind of losses will occur when converting from one specific
3158 * pixel format to another.
3159 * When converting from one pixel format to another, information loss may occur.
3160 * For example, when converting from RGB24 to GRAY, the color information will
3161 * be lost. Similarly, other losses occur when converting from some formats to
3162 * other formats. These losses can involve loss of chroma, but also loss of
3163 * resolution, loss of color depth, loss due to the color space conversion, loss
3164 * of the alpha bits or loss due to color quantization.
3165 * avcodec_get_fix_fmt_loss() informs you about the various types of losses
3166 * which will occur when converting from one pixel format to another.
3167 *
3168 * @param[in] dst_pix_fmt destination pixel format
3169 * @param[in] src_pix_fmt source pixel format
3170 * @param[in] has_alpha Whether the source pixel format alpha channel is used.
3171 * @return Combination of flags informing you what kind of losses will occur.
3172 */
3173int avcodec_get_pix_fmt_loss(enum PixelFormat dst_pix_fmt, enum PixelFormat src_pix_fmt,
3174 int has_alpha);
3175
3176/**
3177 * Find the best pixel format to convert to given a certain source pixel
3178 * format. When converting from one pixel format to another, information loss
3179 * may occur. For example, when converting from RGB24 to GRAY, the color
3180 * information will be lost. Similarly, other losses occur when converting from
3181 * some formats to other formats. avcodec_find_best_pix_fmt() searches which of
3182 * the given pixel formats should be used to suffer the least amount of loss.
3183 * The pixel formats from which it chooses one, are determined by the
3184 * pix_fmt_mask parameter.
3185 *
3186 * @code
3187 * src_pix_fmt = PIX_FMT_YUV420P;
3188 * pix_fmt_mask = (1 << PIX_FMT_YUV422P) || (1 << PIX_FMT_RGB24);
3189 * dst_pix_fmt = avcodec_find_best_pix_fmt(pix_fmt_mask, src_pix_fmt, alpha, &loss);
3190 * @endcode
3191 *
3192 * @param[in] pix_fmt_mask bitmask determining which pixel format to choose from
3193 * @param[in] src_pix_fmt source pixel format
3194 * @param[in] has_alpha Whether the source pixel format alpha channel is used.
3195 * @param[out] loss_ptr Combination of flags informing you what kind of losses will occur.
3196 * @return The best pixel format to convert to or -1 if none was found.
3197 */
3198enum PixelFormat avcodec_find_best_pix_fmt(int64_t pix_fmt_mask, enum PixelFormat src_pix_fmt,
3199 int has_alpha, int *loss_ptr);
3200
3201
3202/**
3203 * Print in buf the string corresponding to the pixel format with
3204 * number pix_fmt, or an header if pix_fmt is negative.
3205 *
3206 * @param[in] buf the buffer where to write the string
3207 * @param[in] buf_size the size of buf
3208 * @param[in] pix_fmt the number of the pixel format to print the corresponding info string, or
3209 * a negative value to print the corresponding header.
3210 * Meaningful values for obtaining a pixel format info vary from 0 to PIX_FMT_NB -1.
3211 */
3212void avcodec_pix_fmt_string (char *buf, int buf_size, enum PixelFormat pix_fmt);
3213
3214#define FF_ALPHA_TRANSP 0x0001 /* image has some totally transparent pixels */
3215#define FF_ALPHA_SEMI_TRANSP 0x0002 /* image has some transparent pixels */
3216
3217/**
3218 * Tell if an image really has transparent alpha values.
3219 * @return ored mask of FF_ALPHA_xxx constants
3220 */
3221int img_get_alpha_info(const AVPicture *src,
3222 enum PixelFormat pix_fmt, int width, int height);
3223
3224/* deinterlace a picture */
3225/* deinterlace - if not supported return -1 */
3226int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
3227 enum PixelFormat pix_fmt, int width, int height);
3228
3229/* external high level API */
3230
3231/**
3232 * If c is NULL, returns the first registered codec,
3233 * if c is non-NULL, returns the next registered codec after c,
3234 * or NULL if c is the last one.
3235 */
3236AVCodec *av_codec_next(AVCodec *c);
3237
3238/**
3239 * Return the LIBAVCODEC_VERSION_INT constant.
3240 */
3241unsigned avcodec_version(void);
3242
3243/**
3244 * Return the libavcodec build-time configuration.
3245 */
3246const char *avcodec_configuration(void);
3247
3248/**
3249 * Return the libavcodec license.
3250 */
3251const char *avcodec_license(void);
3252
3253/**
3254 * Initialize libavcodec.
3255 *
3256 * @warning This function must be called before any other libavcodec
3257 * function.
3258 */
3259void avcodec_init(void);
3260
3261#if LIBAVCODEC_VERSION_MAJOR < 53
3262/**
3263 * @deprecated Deprecated in favor of avcodec_register().
3264 */
3265attribute_deprecated void register_avcodec(AVCodec *codec);
3266#endif
3267
3268/**
3269 * Register the codec codec and initialize libavcodec.
3270 *
3271 * @see avcodec_init()
3272 */
3273void avcodec_register(AVCodec *codec);
3274
3275/**
3276 * Find a registered encoder with a matching codec ID.
3277 *
3278 * @param id CodecID of the requested encoder
3279 * @return An encoder if one was found, NULL otherwise.
3280 */
3281AVCodec *avcodec_find_encoder(enum CodecID id);
3282
3283/**
3284 * Find a registered encoder with the specified name.
3285 *
3286 * @param name name of the requested encoder
3287 * @return An encoder if one was found, NULL otherwise.
3288 */
3289AVCodec *avcodec_find_encoder_by_name(const char *name);
3290
3291/**
3292 * Find a registered decoder with a matching codec ID.
3293 *
3294 * @param id CodecID of the requested decoder
3295 * @return A decoder if one was found, NULL otherwise.
3296 */
3297AVCodec *avcodec_find_decoder(enum CodecID id);
3298
3299/**
3300 * Find a registered decoder with the specified name.
3301 *
3302 * @param name name of the requested decoder
3303 * @return A decoder if one was found, NULL otherwise.
3304 */
3305AVCodec *avcodec_find_decoder_by_name(const char *name);
3306void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
3307
3308/**
3309 * Set the fields of the given AVCodecContext to default values.
3310 *
3311 * @param s The AVCodecContext of which the fields should be set to default values.
3312 */
3313void avcodec_get_context_defaults(AVCodecContext *s);
3314
3315/** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
3316 * we WILL change its arguments and name a few times! */
3317void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType);
3318
3319/**
3320 * Allocate an AVCodecContext and set its fields to default values. The
3321 * resulting struct can be deallocated by simply calling av_free().
3322 *
3323 * @return An AVCodecContext filled with default values or NULL on failure.
3324 * @see avcodec_get_context_defaults
3325 */
3326AVCodecContext *avcodec_alloc_context(void);
3327
3328/** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
3329 * we WILL change its arguments and name a few times! */
3330AVCodecContext *avcodec_alloc_context2(enum AVMediaType);
3331
3332/**
3333 * Copy the settings of the source AVCodecContext into the destination
3334 * AVCodecContext. The resulting destination codec context will be
3335 * unopened, i.e. you are required to call avcodec_open() before you
3336 * can use this AVCodecContext to decode/encode video/audio data.
3337 *
3338 * @param dest target codec context, should be initialized with
3339 * avcodec_alloc_context(), but otherwise uninitialized
3340 * @param src source codec context
3341 * @return AVERROR() on error (e.g. memory allocation error), 0 on success
3342 */
3343int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src);
3344
3345/**
3346 * Set the fields of the given AVFrame to default values.
3347 *
3348 * @param pic The AVFrame of which the fields should be set to default values.
3349 */
3350void avcodec_get_frame_defaults(AVFrame *pic);
3351
3352/**
3353 * Allocate an AVFrame and set its fields to default values. The resulting
3354 * struct can be deallocated by simply calling av_free().
3355 *
3356 * @return An AVFrame filled with default values or NULL on failure.
3357 * @see avcodec_get_frame_defaults
3358 */
3359AVFrame *avcodec_alloc_frame(void);
3360
3361int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
3362void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
3363int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic);
3364
3365/**
3366 * Return the amount of padding in pixels which the get_buffer callback must
3367 * provide around the edge of the image for codecs which do not have the
3368 * CODEC_FLAG_EMU_EDGE flag.
3369 *
3370 * @return Required padding in pixels.
3371 */
3372unsigned avcodec_get_edge_width(void);
3373/**
3374 * Modify width and height values so that they will result in a memory
3375 * buffer that is acceptable for the codec if you do not use any horizontal
3376 * padding.
3377 *
3378 * May only be used if a codec with CODEC_CAP_DR1 has been opened.
3379 * If CODEC_FLAG_EMU_EDGE is not set, the dimensions must have been increased
3380 * according to avcodec_get_edge_width() before.
3381 */
3382void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height);
3383/**
3384 * Modify width and height values so that they will result in a memory
3385 * buffer that is acceptable for the codec if you also ensure that all
3386 * line sizes are a multiple of the respective linesize_align[i].
3387 *
3388 * May only be used if a codec with CODEC_CAP_DR1 has been opened.
3389 * If CODEC_FLAG_EMU_EDGE is not set, the dimensions must have been increased
3390 * according to avcodec_get_edge_width() before.
3391 */
3392void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
3393 int linesize_align[4]);
3394
3395#if LIBAVCODEC_VERSION_MAJOR < 53
3396/**
3397 * @deprecated Deprecated in favor of av_check_image_size().
3398 */
3399attribute_deprecated
3400int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h);
3401#endif
3402
3403enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt);
3404
3405int avcodec_thread_init(AVCodecContext *s, int thread_count);
3406void avcodec_thread_free(AVCodecContext *s);
3407int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size);
3408int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int, int),void *arg, int *ret, int count);
3409//FIXME func typedef
3410
3411/**
3412 * Initialize the AVCodecContext to use the given AVCodec. Prior to using this
3413 * function the context has to be allocated.
3414 *
3415 * The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(),
3416 * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for
3417 * retrieving a codec.
3418 *
3419 * @warning This function is not thread safe!
3420 *
3421 * @code
3422 * avcodec_register_all();
3423 * codec = avcodec_find_decoder(CODEC_ID_H264);
3424 * if (!codec)
3425 * exit(1);
3426 *
3427 * context = avcodec_alloc_context();
3428 *
3429 * if (avcodec_open(context, codec) < 0)
3430 * exit(1);
3431 * @endcode
3432 *
3433 * @param avctx The context which will be set up to use the given codec.
3434 * @param codec The codec to use within the context.
3435 * @return zero on success, a negative value on error
3436 * @see avcodec_alloc_context, avcodec_find_decoder, avcodec_find_encoder
3437 */
3438int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
3439
3440#if LIBAVCODEC_VERSION_MAJOR < 53
3441/**
3442 * Decode an audio frame from buf into samples.
3443 * Wrapper function which calls avcodec_decode_audio3.
3444 *
3445 * @deprecated Use avcodec_decode_audio3 instead.
3446 * @param avctx the codec context
3447 * @param[out] samples the output buffer
3448 * @param[in,out] frame_size_ptr the output buffer size in bytes
3449 * @param[in] buf the input buffer
3450 * @param[in] buf_size the input buffer size in bytes
3451 * @return On error a negative value is returned, otherwise the number of bytes
3452 * used or zero if no frame could be decompressed.
3453 */
3454attribute_deprecated int avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples,
3455 int *frame_size_ptr,
3456 const uint8_t *buf, int buf_size);
3457#endif
3458
3459/**
3460 * Decode the audio frame of size avpkt->size from avpkt->data into samples.
3461 * Some decoders may support multiple frames in a single AVPacket, such
3462 * decoders would then just decode the first frame. In this case,
3463 * avcodec_decode_audio3 has to be called again with an AVPacket that contains
3464 * the remaining data in order to decode the second frame etc.
3465 * If no frame
3466 * could be outputted, frame_size_ptr is zero. Otherwise, it is the
3467 * decompressed frame size in bytes.
3468 *
3469 * @warning You must set frame_size_ptr to the allocated size of the
3470 * output buffer before calling avcodec_decode_audio3().
3471 *
3472 * @warning The input buffer must be FF_INPUT_BUFFER_PADDING_SIZE larger than
3473 * the actual read bytes because some optimized bitstream readers read 32 or 64
3474 * bits at once and could read over the end.
3475 *
3476 * @warning The end of the input buffer avpkt->data should be set to 0 to ensure that
3477 * no overreading happens for damaged MPEG streams.
3478 *
3479 * @note You might have to align the input buffer avpkt->data and output buffer
3480 * samples. The alignment requirements depend on the CPU: On some CPUs it isn't
3481 * necessary at all, on others it won't work at all if not aligned and on others
3482 * it will work but it will have an impact on performance.
3483 *
3484 * In practice, avpkt->data should have 4 byte alignment at minimum and
3485 * samples should be 16 byte aligned unless the CPU doesn't need it
3486 * (AltiVec and SSE do).
3487 *
3488 * @param avctx the codec context
3489 * @param[out] samples the output buffer, sample type in avctx->sample_fmt
3490 * @param[in,out] frame_size_ptr the output buffer size in bytes
3491 * @param[in] avpkt The input AVPacket containing the input buffer.
3492 * You can create such packet with av_init_packet() and by then setting
3493 * data and size, some decoders might in addition need other fields.
3494 * All decoders are designed to use the least fields possible though.
3495 * @return On error a negative value is returned, otherwise the number of bytes
3496 * used or zero if no frame data was decompressed (used) from the input AVPacket.
3497 */
3498int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples,
3499 int *frame_size_ptr,
3500 AVPacket *avpkt);
3501
3502#if LIBAVCODEC_VERSION_MAJOR < 53
3503/**
3504 * Decode a video frame from buf into picture.
3505 * Wrapper function which calls avcodec_decode_video2.
3506 *
3507 * @deprecated Use avcodec_decode_video2 instead.
3508 * @param avctx the codec context
3509 * @param[out] picture The AVFrame in which the decoded video frame will be stored.
3510 * @param[in] buf the input buffer
3511 * @param[in] buf_size the size of the input buffer in bytes
3512 * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero.
3513 * @return On error a negative value is returned, otherwise the number of bytes
3514 * used or zero if no frame could be decompressed.
3515 */
3516attribute_deprecated int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
3517 int *got_picture_ptr,
3518 const uint8_t *buf, int buf_size);
3519#endif
3520
3521/**
3522 * Decode the video frame of size avpkt->size from avpkt->data into picture.
3523 * Some decoders may support multiple frames in a single AVPacket, such
3524 * decoders would then just decode the first frame.
3525 *
3526 * @warning The input buffer must be FF_INPUT_BUFFER_PADDING_SIZE larger than
3527 * the actual read bytes because some optimized bitstream readers read 32 or 64
3528 * bits at once and could read over the end.
3529 *
3530 * @warning The end of the input buffer buf should be set to 0 to ensure that
3531 * no overreading happens for damaged MPEG streams.
3532 *
3533 * @note You might have to align the input buffer avpkt->data.
3534 * The alignment requirements depend on the CPU: on some CPUs it isn't
3535 * necessary at all, on others it won't work at all if not aligned and on others
3536 * it will work but it will have an impact on performance.
3537 *
3538 * In practice, avpkt->data should have 4 byte alignment at minimum.
3539 *
3540 * @note Some codecs have a delay between input and output, these need to be
3541 * fed with avpkt->data=NULL, avpkt->size=0 at the end to return the remaining frames.
3542 *
3543 * @param avctx the codec context
3544 * @param[out] picture The AVFrame in which the decoded video frame will be stored.
3545 * Use avcodec_alloc_frame to get an AVFrame, the codec will
3546 * allocate memory for the actual bitmap.
3547 * with default get/release_buffer(), the decoder frees/reuses the bitmap as it sees fit.
3548 * with overridden get/release_buffer() (needs CODEC_CAP_DR1) the user decides into what buffer the decoder
3549 * decodes and the decoder tells the user once it does not need the data anymore,
3550 * the user app can at this point free/reuse/keep the memory as it sees fit.
3551 *
3552 * @param[in] avpkt The input AVpacket containing the input buffer.
3553 * You can create such packet with av_init_packet() and by then setting
3554 * data and size, some decoders might in addition need other fields like
3555 * flags&AV_PKT_FLAG_KEY. All decoders are designed to use the least
3556 * fields possible.
3557 * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero.
3558 * @return On error a negative value is returned, otherwise the number of bytes
3559 * used or zero if no frame could be decompressed.
3560 */
3561int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
3562 int *got_picture_ptr,
3563 AVPacket *avpkt);
3564
3565#if LIBAVCODEC_VERSION_MAJOR < 53
3566/* Decode a subtitle message. Return -1 if error, otherwise return the
3567 * number of bytes used. If no subtitle could be decompressed,
3568 * got_sub_ptr is zero. Otherwise, the subtitle is stored in *sub. */
3569attribute_deprecated int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub,
3570 int *got_sub_ptr,
3571 const uint8_t *buf, int buf_size);
3572#endif
3573
3574/**
3575 * Decode a subtitle message.
3576 * Return a negative value on error, otherwise return the number of bytes used.
3577 * If no subtitle could be decompressed, got_sub_ptr is zero.
3578 * Otherwise, the subtitle is stored in *sub.
3579 * Note that CODEC_CAP_DR1 is not available for subtitle codecs. This is for
3580 * simplicity, because the performance difference is expect to be negligible
3581 * and reusing a get_buffer written for video codecs would probably perform badly
3582 * due to a potentially very different allocation pattern.
3583 *
3584 * @param avctx the codec context
3585 * @param[out] sub The AVSubtitle in which the decoded subtitle will be stored, must be
3586 freed with avsubtitle_free if *got_sub_ptr is set.
3587 * @param[in,out] got_sub_ptr Zero if no subtitle could be decompressed, otherwise, it is nonzero.
3588 * @param[in] avpkt The input AVPacket containing the input buffer.
3589 */
3590int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
3591 int *got_sub_ptr,
3592 AVPacket *avpkt);
3593
3594/**
3595 * Frees all allocated data in the given subtitle struct.
3596 *
3597 * @param sub AVSubtitle to free.
3598 */
3599void avsubtitle_free(AVSubtitle *sub);
3600
3601int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata,
3602 int *data_size_ptr,
3603 uint8_t *buf, int buf_size);
3604
3605/**
3606 * Encode an audio frame from samples into buf.
3607 *
3608 * @note The output buffer should be at least FF_MIN_BUFFER_SIZE bytes large.
3609 * However, for PCM audio the user will know how much space is needed
3610 * because it depends on the value passed in buf_size as described
3611 * below. In that case a lower value can be used.
3612 *
3613 * @param avctx the codec context
3614 * @param[out] buf the output buffer
3615 * @param[in] buf_size the output buffer size
3616 * @param[in] samples the input buffer containing the samples
3617 * The number of samples read from this buffer is frame_size*channels,
3618 * both of which are defined in avctx.
3619 * For PCM audio the number of samples read from samples is equal to
3620 * buf_size * input_sample_size / output_sample_size.
3621 * @return On error a negative value is returned, on success zero or the number
3622 * of bytes used to encode the data read from the input buffer.
3623 */
3624int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size,
3625 const short *samples);
3626
3627/**
3628 * Encode a video frame from pict into buf.
3629 * The input picture should be
3630 * stored using a specific format, namely avctx.pix_fmt.
3631 *
3632 * @param avctx the codec context
3633 * @param[out] buf the output buffer for the bitstream of encoded frame
3634 * @param[in] buf_size the size of the output buffer in bytes
3635 * @param[in] pict the input picture to encode
3636 * @return On error a negative value is returned, on success zero or the number
3637 * of bytes used from the output buffer.
3638 */
3639int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
3640 const AVFrame *pict);
3641int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
3642 const AVSubtitle *sub);
3643
3644int avcodec_close(AVCodecContext *avctx);
3645
3646/**
3647 * Register all the codecs, parsers and bitstream filters which were enabled at
3648 * configuration time. If you do not call this function you can select exactly
3649 * which formats you want to support, by using the individual registration
3650 * functions.
3651 *
3652 * @see avcodec_register
3653 * @see av_register_codec_parser
3654 * @see av_register_bitstream_filter
3655 */
3656void avcodec_register_all(void);
3657
3658/**
3659 * Flush buffers, should be called when seeking or when switching to a different stream.
3660 */
3661void avcodec_flush_buffers(AVCodecContext *avctx);
3662
3663void avcodec_default_free_buffers(AVCodecContext *s);
3664
3665/* misc useful functions */
3666
3667/**
3668 * Return a single letter to describe the given picture type pict_type.
3669 *
3670 * @param[in] pict_type the picture type
3671 * @return A single character representing the picture type.
3672 */
3673char av_get_pict_type_char(int pict_type);
3674
3675/**
3676 * Return codec bits per sample.
3677 *
3678 * @param[in] codec_id the codec
3679 * @return Number of bits per sample or zero if unknown for the given codec.
3680 */
3681int av_get_bits_per_sample(enum CodecID codec_id);
3682
3683/**
3684 * Return sample format bits per sample.
3685 *
3686 * @param[in] sample_fmt the sample format
3687 * @return Number of bits per sample or zero if unknown for the given sample format.
3688 */
3689int av_get_bits_per_sample_format(enum SampleFormat sample_fmt);
3690
3691/* frame parsing */
3692typedef struct AVCodecParserContext {
3693 void *priv_data;
3694 struct AVCodecParser *parser;
3695 int64_t frame_offset; /* offset of the current frame */
3696 int64_t cur_offset; /* current offset
3697 (incremented by each av_parser_parse()) */
3698 int64_t next_frame_offset; /* offset of the next frame */
3699 /* video info */
3700 int pict_type; /* XXX: Put it back in AVCodecContext. */
3701 /**
3702 * This field is used for proper frame duration computation in lavf.
3703 * It signals, how much longer the frame duration of the current frame
3704 * is compared to normal frame duration.
3705 *
3706 * frame_duration = (1 + repeat_pict) * time_base
3707 *
3708 * It is used by codecs like H.264 to display telecined material.
3709 */
3710 int repeat_pict; /* XXX: Put it back in AVCodecContext. */
3711 int64_t pts; /* pts of the current frame */
3712 int64_t dts; /* dts of the current frame */
3713
3714 /* private data */
3715 int64_t last_pts;
3716 int64_t last_dts;
3717 int fetch_timestamp;
3718
3719#define AV_PARSER_PTS_NB 4
3720 int cur_frame_start_index;
3721 int64_t cur_frame_offset[AV_PARSER_PTS_NB];
3722 int64_t cur_frame_pts[AV_PARSER_PTS_NB];
3723 int64_t cur_frame_dts[AV_PARSER_PTS_NB];
3724
3725 int flags;
3726#define PARSER_FLAG_COMPLETE_FRAMES 0x0001
3727#define PARSER_FLAG_ONCE 0x0002
3728
3729 int64_t offset; ///< byte offset from starting packet start
3730 int64_t cur_frame_end[AV_PARSER_PTS_NB];
3731
3732 /*!
3733 * Set by parser to 1 for key frames and 0 for non-key frames.
3734 * It is initialized to -1, so if the parser doesn't set this flag,
3735 * old-style fallback using FF_I_TYPE picture type as key frames
3736 * will be used.
3737 */
3738 int key_frame;
3739
3740 /**
3741 * Time difference in stream time base units from the pts of this
3742 * packet to the point at which the output from the decoder has converged
3743 * independent from the availability of previous frames. That is, the
3744 * frames are virtually identical no matter if decoding started from
3745 * the very first frame or from this keyframe.
3746 * Is AV_NOPTS_VALUE if unknown.
3747 * This field is not the display duration of the current frame.
3748 * This field has no meaning if the packet does not have AV_PKT_FLAG_KEY
3749 * set.
3750 *
3751 * The purpose of this field is to allow seeking in streams that have no
3752 * keyframes in the conventional sense. It corresponds to the
3753 * recovery point SEI in H.264 and match_time_delta in NUT. It is also
3754 * essential for some types of subtitle streams to ensure that all
3755 * subtitles are correctly displayed after seeking.
3756 */
3757 int64_t convergence_duration;
3758
3759 // Timestamp generation support:
3760 /**
3761 * Synchronization point for start of timestamp generation.
3762 *
3763 * Set to >0 for sync point, 0 for no sync point and <0 for undefined
3764 * (default).
3765 *
3766 * For example, this corresponds to presence of H.264 buffering period
3767 * SEI message.
3768 */
3769 int dts_sync_point;
3770
3771 /**
3772 * Offset of the current timestamp against last timestamp sync point in
3773 * units of AVCodecContext.time_base.
3774 *
3775 * Set to INT_MIN when dts_sync_point unused. Otherwise, it must
3776 * contain a valid timestamp offset.
3777 *
3778 * Note that the timestamp of sync point has usually a nonzero
3779 * dts_ref_dts_delta, which refers to the previous sync point. Offset of
3780 * the next frame after timestamp sync point will be usually 1.
3781 *
3782 * For example, this corresponds to H.264 cpb_removal_delay.
3783 */
3784 int dts_ref_dts_delta;
3785
3786 /**
3787 * Presentation delay of current frame in units of AVCodecContext.time_base.
3788 *
3789 * Set to INT_MIN when dts_sync_point unused. Otherwise, it must
3790 * contain valid non-negative timestamp delta (presentation time of a frame
3791 * must not lie in the past).
3792 *
3793 * This delay represents the difference between decoding and presentation
3794 * time of the frame.
3795 *
3796 * For example, this corresponds to H.264 dpb_output_delay.
3797 */
3798 int pts_dts_delta;
3799
3800 /**
3801 * Position of the packet in file.
3802 *
3803 * Analogous to cur_frame_pts/dts
3804 */
3805 int64_t cur_frame_pos[AV_PARSER_PTS_NB];
3806
3807 /**
3808 * Byte position of currently parsed frame in stream.
3809 */
3810 int64_t pos;
3811
3812 /**
3813 * Previous frame byte position.
3814 */
3815 int64_t last_pos;
3816} AVCodecParserContext;
3817
3818typedef struct AVCodecParser {
3819 int codec_ids[5]; /* several codec IDs are permitted */
3820 int priv_data_size;
3821 int (*parser_init)(AVCodecParserContext *s);
3822 int (*parser_parse)(AVCodecParserContext *s,
3823 AVCodecContext *avctx,
3824 const uint8_t **poutbuf, int *poutbuf_size,
3825 const uint8_t *buf, int buf_size);
3826 void (*parser_close)(AVCodecParserContext *s);
3827 int (*split)(AVCodecContext *avctx, const uint8_t *buf, int buf_size);
3828 struct AVCodecParser *next;
3829} AVCodecParser;
3830
3831AVCodecParser *av_parser_next(AVCodecParser *c);
3832
3833void av_register_codec_parser(AVCodecParser *parser);
3834AVCodecParserContext *av_parser_init(int codec_id);
3835
3836#if LIBAVCODEC_VERSION_MAJOR < 53
3837attribute_deprecated
3838int av_parser_parse(AVCodecParserContext *s,
3839 AVCodecContext *avctx,
3840 uint8_t **poutbuf, int *poutbuf_size,
3841 const uint8_t *buf, int buf_size,
3842 int64_t pts, int64_t dts);
3843#endif
3844
3845/**
3846 * Parse a packet.
3847 *
3848 * @param s parser context.
3849 * @param avctx codec context.
3850 * @param poutbuf set to pointer to parsed buffer or NULL if not yet finished.
3851 * @param poutbuf_size set to size of parsed buffer or zero if not yet finished.
3852 * @param buf input buffer.
3853 * @param buf_size input length, to signal EOF, this should be 0 (so that the last frame can be output).
3854 * @param pts input presentation timestamp.
3855 * @param dts input decoding timestamp.
3856 * @param pos input byte position in stream.
3857 * @return the number of bytes of the input bitstream used.
3858 *
3859 * Example:
3860 * @code
3861 * while(in_len){
3862 * len = av_parser_parse2(myparser, AVCodecContext, &data, &size,
3863 * in_data, in_len,
3864 * pts, dts, pos);
3865 * in_data += len;
3866 * in_len -= len;
3867 *
3868 * if(size)
3869 * decode_frame(data, size);
3870 * }
3871 * @endcode
3872 */
3873int av_parser_parse2(AVCodecParserContext *s,
3874 AVCodecContext *avctx,
3875 uint8_t **poutbuf, int *poutbuf_size,
3876 const uint8_t *buf, int buf_size,
3877 int64_t pts, int64_t dts,
3878 int64_t pos);
3879
3880int av_parser_change(AVCodecParserContext *s,
3881 AVCodecContext *avctx,
3882 uint8_t **poutbuf, int *poutbuf_size,
3883 const uint8_t *buf, int buf_size, int keyframe);
3884void av_parser_close(AVCodecParserContext *s);
3885
3886
3887typedef struct AVBitStreamFilterContext {
3888 void *priv_data;
3889 struct AVBitStreamFilter *filter;
3890 AVCodecParserContext *parser;
3891 struct AVBitStreamFilterContext *next;
3892} AVBitStreamFilterContext;
3893
3894
3895typedef struct AVBitStreamFilter {
3896 const char *name;
3897 int priv_data_size;
3898 int (*filter)(AVBitStreamFilterContext *bsfc,
3899 AVCodecContext *avctx, const char *args,
3900 uint8_t **poutbuf, int *poutbuf_size,
3901 const uint8_t *buf, int buf_size, int keyframe);
3902 void (*close)(AVBitStreamFilterContext *bsfc);
3903 struct AVBitStreamFilter *next;
3904} AVBitStreamFilter;
3905
3906void av_register_bitstream_filter(AVBitStreamFilter *bsf);
3907AVBitStreamFilterContext *av_bitstream_filter_init(const char *name);
3908int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc,
3909 AVCodecContext *avctx, const char *args,
3910 uint8_t **poutbuf, int *poutbuf_size,
3911 const uint8_t *buf, int buf_size, int keyframe);
3912void av_bitstream_filter_close(AVBitStreamFilterContext *bsf);
3913
3914AVBitStreamFilter *av_bitstream_filter_next(AVBitStreamFilter *f);
3915
3916/* memory */
3917
3918/**
3919 * Reallocate the given block if it is not large enough, otherwise do nothing.
3920 *
3921 * @see av_realloc
3922 */
3923void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size);
3924
3925/**
3926 * Allocate a buffer, reusing the given one if large enough.
3927 *
3928 * Contrary to av_fast_realloc the current buffer contents might not be
3929 * preserved and on error the old buffer is freed, thus no special
3930 * handling to avoid memleaks is necessary.
3931 *
3932 * @param ptr pointer to pointer to already allocated buffer, overwritten with pointer to new buffer
3933 * @param size size of the buffer *ptr points to
3934 * @param min_size minimum size of *ptr buffer after returning, *ptr will be NULL and
3935 * *size 0 if an error occurred.
3936 */
3937void av_fast_malloc(void *ptr, unsigned int *size, unsigned int min_size);
3938
3939/**
3940 * Copy image 'src' to 'dst'.
3941 */
3942void av_picture_copy(AVPicture *dst, const AVPicture *src,
3943 enum PixelFormat pix_fmt, int width, int height);
3944
3945/**
3946 * Crop image top and left side.
3947 */
3948int av_picture_crop(AVPicture *dst, const AVPicture *src,
3949 enum PixelFormat pix_fmt, int top_band, int left_band);
3950
3951/**
3952 * Pad image.
3953 */
3954int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, enum PixelFormat pix_fmt,
3955 int padtop, int padbottom, int padleft, int padright, int *color);
3956
3957/**
3958 * Encode extradata length to a buffer. Used by xiph codecs.
3959 *
3960 * @param s buffer to write to; must be at least (v/255+1) bytes long
3961 * @param v size of extradata in bytes
3962 * @return number of bytes written to the buffer.
3963 */
3964unsigned int av_xiphlacing(unsigned char *s, unsigned int v);
3965
3966#if LIBAVCODEC_VERSION_MAJOR < 53
3967/**
3968 * Parse str and put in width_ptr and height_ptr the detected values.
3969 *
3970 * @deprecated Deprecated in favor of av_parse_video_size().
3971 */
3972attribute_deprecated int av_parse_video_frame_size(int *width_ptr, int *height_ptr, const char *str);
3973
3974/**
3975 * Parse str and store the detected values in *frame_rate.
3976 *
3977 * @deprecated Deprecated in favor of av_parse_video_rate().
3978 */
3979attribute_deprecated int av_parse_video_frame_rate(AVRational *frame_rate, const char *str);
3980#endif
3981
3982/**
3983 * Logs a generic warning message about a missing feature. This function is
3984 * intended to be used internally by FFmpeg (libavcodec, libavformat, etc.)
3985 * only, and would normally not be used by applications.
3986 * @param[in] avc a pointer to an arbitrary struct of which the first field is
3987 * a pointer to an AVClass struct
3988 * @param[in] feature string containing the name of the missing feature
3989 * @param[in] want_sample indicates if samples are wanted which exhibit this feature.
3990 * If want_sample is non-zero, additional verbage will be added to the log
3991 * message which tells the user how to report samples to the development
3992 * mailing list.
3993 */
3994void av_log_missing_feature(void *avc, const char *feature, int want_sample);
3995
3996/**
3997 * Log a generic warning message asking for a sample. This function is
3998 * intended to be used internally by FFmpeg (libavcodec, libavformat, etc.)
3999 * only, and would normally not be used by applications.
4000 * @param[in] avc a pointer to an arbitrary struct of which the first field is
4001 * a pointer to an AVClass struct
4002 * @param[in] msg string containing an optional message, or NULL if no message
4003 */
4004void av_log_ask_for_sample(void *avc, const char *msg);
4005
4006/**
4007 * Register the hardware accelerator hwaccel.
4008 */
4009void av_register_hwaccel(AVHWAccel *hwaccel);
4010
4011/**
4012 * If hwaccel is NULL, returns the first registered hardware accelerator,
4013 * if hwaccel is non-NULL, returns the next registered hardware accelerator
4014 * after hwaccel, or NULL if hwaccel is the last one.
4015 */
4016AVHWAccel *av_hwaccel_next(AVHWAccel *hwaccel);
4017
4018
4019/**
4020 * Lock operation used by lockmgr
4021 */
4022enum AVLockOp {
4023 AV_LOCK_CREATE, ///< Create a mutex
4024 AV_LOCK_OBTAIN, ///< Lock the mutex
4025 AV_LOCK_RELEASE, ///< Unlock the mutex
4026 AV_LOCK_DESTROY, ///< Free mutex resources
4027};
4028
4029/**
4030 * Register a user provided lock manager supporting the operations
4031 * specified by AVLockOp. mutex points to a (void *) where the
4032 * lockmgr should store/get a pointer to a user allocated mutex. It's
4033 * NULL upon AV_LOCK_CREATE and != NULL for all other ops.
4034 *
4035 * @param cb User defined callback. Note: FFmpeg may invoke calls to this
4036 * callback during the call to av_lockmgr_register().
4037 * Thus, the application must be prepared to handle that.
4038 * If cb is set to NULL the lockmgr will be unregistered.
4039 * Also note that during unregistration the previously registered
4040 * lockmgr callback may also be invoked.
4041 */
4042int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op));
4043
4044#endif /* AVCODEC_AVCODEC_H */
diff --git a/apps/codecs/libwmavoice/avfft.c b/apps/codecs/libwmavoice/avfft.c
new file mode 100644
index 0000000000..7d5d08390f
--- /dev/null
+++ b/apps/codecs/libwmavoice/avfft.c
@@ -0,0 +1,142 @@
1/*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#include "libavutil/mem.h"
20#include "avfft.h"
21#include "fft.h"
22
23/* FFT */
24
25FFTContext *av_fft_init(int nbits, int inverse)
26{
27 FFTContext *s = av_malloc(sizeof(*s));
28
29 if (s && ff_fft_init(s, nbits, inverse))
30 av_freep(&s);
31
32 return s;
33}
34
35void av_fft_permute(FFTContext *s, FFTComplex *z)
36{
37 s->fft_permute(s, z);
38}
39
40void av_fft_calc(FFTContext *s, FFTComplex *z)
41{
42 s->fft_calc(s, z);
43}
44
45void av_fft_end(FFTContext *s)
46{
47 if (s) {
48 ff_fft_end(s);
49 av_free(s);
50 }
51}
52
53#if CONFIG_MDCT
54
55FFTContext *av_mdct_init(int nbits, int inverse, double scale)
56{
57 FFTContext *s = av_malloc(sizeof(*s));
58
59 if (s && ff_mdct_init(s, nbits, inverse, scale))
60 av_freep(&s);
61
62 return s;
63}
64
65void av_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input)
66{
67 s->imdct_calc(s, output, input);
68}
69
70void av_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input)
71{
72 s->imdct_half(s, output, input);
73}
74
75void av_mdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input)
76{
77 s->mdct_calc(s, output, input);
78}
79
80void av_mdct_end(FFTContext *s)
81{
82 if (s) {
83 ff_mdct_end(s);
84 av_free(s);
85 }
86}
87
88#endif /* CONFIG_MDCT */
89
90#if CONFIG_RDFT
91
92RDFTContext *av_rdft_init(int nbits, enum RDFTransformType trans)
93{
94 RDFTContext *s = av_malloc(sizeof(*s));
95
96 if (s && ff_rdft_init(s, nbits, trans))
97 av_freep(&s);
98
99 return s;
100}
101
102void av_rdft_calc(RDFTContext *s, FFTSample *data)
103{
104 ff_rdft_calc(s, data);
105}
106
107void av_rdft_end(RDFTContext *s)
108{
109 if (s) {
110 ff_rdft_end(s);
111 av_free(s);
112 }
113}
114
115#endif /* CONFIG_RDFT */
116
117#if CONFIG_DCT
118
119DCTContext *av_dct_init(int nbits, enum DCTTransformType inverse)
120{
121 DCTContext *s = av_malloc(sizeof(*s));
122
123 if (s && ff_dct_init(s, nbits, inverse))
124 av_freep(&s);
125
126 return s;
127}
128
129void av_dct_calc(DCTContext *s, FFTSample *data)
130{
131 ff_dct_calc(s, data);
132}
133
134void av_dct_end(DCTContext *s)
135{
136 if (s) {
137 ff_dct_end(s);
138 av_free(s);
139 }
140}
141
142#endif /* CONFIG_DCT */
diff --git a/apps/codecs/libwmavoice/avfft.h b/apps/codecs/libwmavoice/avfft.h
new file mode 100644
index 0000000000..be2d9c7e10
--- /dev/null
+++ b/apps/codecs/libwmavoice/avfft.h
@@ -0,0 +1,99 @@
1/*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#ifndef AVCODEC_AVFFT_H
20#define AVCODEC_AVFFT_H
21
22typedef float FFTSample;
23
24typedef struct FFTComplex {
25 FFTSample re, im;
26} FFTComplex;
27
28typedef struct FFTContext FFTContext;
29
30/**
31 * Set up a complex FFT.
32 * @param nbits log2 of the length of the input array
33 * @param inverse if 0 perform the forward transform, if 1 perform the inverse
34 */
35FFTContext *av_fft_init(int nbits, int inverse);
36
37/**
38 * Do the permutation needed BEFORE calling ff_fft_calc().
39 */
40void av_fft_permute(FFTContext *s, FFTComplex *z);
41
42/**
43 * Do a complex FFT with the parameters defined in av_fft_init(). The
44 * input data must be permuted before. No 1.0/sqrt(n) normalization is done.
45 */
46void av_fft_calc(FFTContext *s, FFTComplex *z);
47
48void av_fft_end(FFTContext *s);
49
50FFTContext *av_mdct_init(int nbits, int inverse, double scale);
51void av_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input);
52void av_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input);
53void av_mdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input);
54void av_mdct_end(FFTContext *s);
55
56/* Real Discrete Fourier Transform */
57
58enum RDFTransformType {
59 DFT_R2C,
60 IDFT_C2R,
61 IDFT_R2C,
62 DFT_C2R,
63};
64
65typedef struct RDFTContext RDFTContext;
66
67/**
68 * Set up a real FFT.
69 * @param nbits log2 of the length of the input array
70 * @param trans the type of transform
71 */
72RDFTContext *av_rdft_init(int nbits, enum RDFTransformType trans);
73void av_rdft_calc(RDFTContext *s, FFTSample *data);
74void av_rdft_end(RDFTContext *s);
75
76/* Discrete Cosine Transform */
77
78typedef struct DCTContext DCTContext;
79
80enum DCTTransformType {
81 DCT_II = 0,
82 DCT_III,
83 DCT_I,
84 DST_I,
85};
86
87/**
88 * Set up DCT.
89 * @param nbits size of the input array:
90 * (1 << nbits) for DCT-II, DCT-III and DST-I
91 * (1 << nbits) + 1 for DCT-I
92 *
93 * @note the first element of the input of DST-I is ignored
94 */
95DCTContext *av_dct_init(int nbits, enum DCTTransformType type);
96void av_dct_calc(DCTContext *s, FFTSample *data);
97void av_dct_end (DCTContext *s);
98
99#endif /* AVCODEC_AVFFT_H */
diff --git a/apps/codecs/libwmavoice/bitstream.c b/apps/codecs/libwmavoice/bitstream.c
new file mode 100644
index 0000000000..83f30f9799
--- /dev/null
+++ b/apps/codecs/libwmavoice/bitstream.c
@@ -0,0 +1,341 @@
1/*
2 * Common bit i/o utils
3 * Copyright (c) 2000, 2001 Fabrice Bellard
4 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
5 * Copyright (c) 2010 Loren Merritt
6 *
7 * alternative bitstream reader & writer by Michael Niedermayer <michaelni@gmx.at>
8 *
9 * This file is part of FFmpeg.
10 *
11 * FFmpeg is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
15 *
16 * FFmpeg is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with FFmpeg; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 */
25
26/**
27 * @file
28 * bitstream api.
29 */
30
31#include "avcodec.h"
32#include "get_bits.h"
33#include "put_bits.h"
34
35const uint8_t ff_log2_run[32]={
36 0, 0, 0, 0, 1, 1, 1, 1,
37 2, 2, 2, 2, 3, 3, 3, 3,
38 4, 4, 5, 5, 6, 6, 7, 7,
39 8, 9,10,11,12,13,14,15
40};
41
42void align_put_bits(PutBitContext *s)
43{
44#ifdef ALT_BITSTREAM_WRITER
45 put_bits(s,( - s->index) & 7,0);
46#else
47 put_bits(s,s->bit_left & 7,0);
48#endif
49}
50
51void ff_put_string(PutBitContext *pb, const char *string, int terminate_string)
52{
53 while(*string){
54 put_bits(pb, 8, *string);
55 string++;
56 }
57 if(terminate_string)
58 put_bits(pb, 8, 0);
59}
60
61void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length)
62{
63 int words= length>>4;
64 int bits= length&15;
65 int i;
66
67 if(length==0) return;
68
69 if(CONFIG_SMALL || words < 16 || put_bits_count(pb)&7){
70 for(i=0; i<words; i++) put_bits(pb, 16, AV_RB16(src + 2*i));
71 }else{
72 for(i=0; put_bits_count(pb)&31; i++)
73 put_bits(pb, 8, src[i]);
74 flush_put_bits(pb);
75 memcpy(put_bits_ptr(pb), src+i, 2*words-i);
76 skip_put_bytes(pb, 2*words-i);
77 }
78
79 put_bits(pb, bits, AV_RB16(src + 2*words)>>(16-bits));
80}
81
82/* VLC decoding */
83
84//#define DEBUG_VLC
85
86#define GET_DATA(v, table, i, wrap, size) \
87{\
88 const uint8_t *ptr = (const uint8_t *)table + i * wrap;\
89 switch(size) {\
90 case 1:\
91 v = *(const uint8_t *)ptr;\
92 break;\
93 case 2:\
94 v = *(const uint16_t *)ptr;\
95 break;\
96 default:\
97 v = *(const uint32_t *)ptr;\
98 break;\
99 }\
100}
101
102
103static int alloc_table(VLC *vlc, int size, int use_static)
104{
105 int index;
106 index = vlc->table_size;
107 vlc->table_size += size;
108 if (vlc->table_size > vlc->table_allocated) {
109 if(use_static)
110 abort(); //cant do anything, init_vlc() is used with too little memory
111 vlc->table_allocated += (1 << vlc->bits);
112 vlc->table = av_realloc(vlc->table,
113 sizeof(VLC_TYPE) * 2 * vlc->table_allocated);
114 if (!vlc->table)
115 return -1;
116 }
117 return index;
118}
119
120static av_always_inline uint32_t bitswap_32(uint32_t x) {
121 return av_reverse[x&0xFF]<<24
122 | av_reverse[(x>>8)&0xFF]<<16
123 | av_reverse[(x>>16)&0xFF]<<8
124 | av_reverse[x>>24];
125}
126
127typedef struct {
128 uint8_t bits;
129 uint16_t symbol;
130 /** codeword, with the first bit-to-be-read in the msb
131 * (even if intended for a little-endian bitstream reader) */
132 uint32_t code;
133} VLCcode;
134
135static int compare_vlcspec(const void *a, const void *b)
136{
137 const VLCcode *sa=a, *sb=b;
138 return (sa->code >> 1) - (sb->code >> 1);
139}
140
141/**
142 * Build VLC decoding tables suitable for use with get_vlc().
143 *
144 * @param vlc the context to be initted
145 *
146 * @param table_nb_bits max length of vlc codes to store directly in this table
147 * (Longer codes are delegated to subtables.)
148 *
149 * @param nb_codes number of elements in codes[]
150 *
151 * @param codes descriptions of the vlc codes
152 * These must be ordered such that codes going into the same subtable are contiguous.
153 * Sorting by VLCcode.code is sufficient, though not necessary.
154 */
155static int build_table(VLC *vlc, int table_nb_bits, int nb_codes,
156 VLCcode *codes, int flags)
157{
158 int table_size, table_index, index, code_prefix, symbol, subtable_bits;
159 int i, j, k, n, nb, inc;
160 uint32_t code;
161 VLC_TYPE (*table)[2];
162
163 table_size = 1 << table_nb_bits;
164 table_index = alloc_table(vlc, table_size, flags & INIT_VLC_USE_NEW_STATIC);
165#ifdef DEBUG_VLC
166 av_log(NULL,AV_LOG_DEBUG,"new table index=%d size=%d\n",
167 table_index, table_size);
168#endif
169 if (table_index < 0)
170 return -1;
171 table = &vlc->table[table_index];
172
173 for (i = 0; i < table_size; i++) {
174 table[i][1] = 0; //bits
175 table[i][0] = -1; //codes
176 }
177
178 /* first pass: map codes and compute auxillary table sizes */
179 for (i = 0; i < nb_codes; i++) {
180 n = codes[i].bits;
181 code = codes[i].code;
182 symbol = codes[i].symbol;
183#if defined(DEBUG_VLC) && 0
184 av_log(NULL,AV_LOG_DEBUG,"i=%d n=%d code=0x%x\n", i, n, code);
185#endif
186 if (n <= table_nb_bits) {
187 /* no need to add another table */
188 j = code >> (32 - table_nb_bits);
189 nb = 1 << (table_nb_bits - n);
190 inc = 1;
191 if (flags & INIT_VLC_LE) {
192 j = bitswap_32(code);
193 inc = 1 << n;
194 }
195 for (k = 0; k < nb; k++) {
196#ifdef DEBUG_VLC
197 av_log(NULL, AV_LOG_DEBUG, "%4x: code=%d n=%d\n",
198 j, i, n);
199#endif
200 if (table[j][1] /*bits*/ != 0) {
201 av_log(NULL, AV_LOG_ERROR, "incorrect codes\n");
202 return -1;
203 }
204 table[j][1] = n; //bits
205 table[j][0] = symbol;
206 j += inc;
207 }
208 } else {
209 /* fill auxiliary table recursively */
210 n -= table_nb_bits;
211 code_prefix = code >> (32 - table_nb_bits);
212 subtable_bits = n;
213 codes[i].bits = n;
214 codes[i].code = code << table_nb_bits;
215 for (k = i+1; k < nb_codes; k++) {
216 n = codes[k].bits - table_nb_bits;
217 if (n <= 0)
218 break;
219 code = codes[k].code;
220 if (code >> (32 - table_nb_bits) != code_prefix)
221 break;
222 codes[k].bits = n;
223 codes[k].code = code << table_nb_bits;
224 subtable_bits = FFMAX(subtable_bits, n);
225 }
226 subtable_bits = FFMIN(subtable_bits, table_nb_bits);
227 j = (flags & INIT_VLC_LE) ? bitswap_32(code_prefix) >> (32 - table_nb_bits) : code_prefix;
228 table[j][1] = -subtable_bits;
229#ifdef DEBUG_VLC
230 av_log(NULL,AV_LOG_DEBUG,"%4x: n=%d (subtable)\n",
231 j, codes[i].bits + table_nb_bits);
232#endif
233 index = build_table(vlc, subtable_bits, k-i, codes+i, flags);
234 if (index < 0)
235 return -1;
236 /* note: realloc has been done, so reload tables */
237 table = &vlc->table[table_index];
238 table[j][0] = index; //code
239 i = k-1;
240 }
241 }
242 return table_index;
243}
244
245
246/* Build VLC decoding tables suitable for use with get_vlc().
247
248 'nb_bits' set thee decoding table size (2^nb_bits) entries. The
249 bigger it is, the faster is the decoding. But it should not be too
250 big to save memory and L1 cache. '9' is a good compromise.
251
252 'nb_codes' : number of vlcs codes
253
254 'bits' : table which gives the size (in bits) of each vlc code.
255
256 'codes' : table which gives the bit pattern of of each vlc code.
257
258 'symbols' : table which gives the values to be returned from get_vlc().
259
260 'xxx_wrap' : give the number of bytes between each entry of the
261 'bits' or 'codes' tables.
262
263 'xxx_size' : gives the number of bytes of each entry of the 'bits'
264 or 'codes' tables.
265
266 'wrap' and 'size' allows to use any memory configuration and types
267 (byte/word/long) to store the 'bits', 'codes', and 'symbols' tables.
268
269 'use_static' should be set to 1 for tables, which should be freed
270 with av_free_static(), 0 if free_vlc() will be used.
271*/
272int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes,
273 const void *bits, int bits_wrap, int bits_size,
274 const void *codes, int codes_wrap, int codes_size,
275 const void *symbols, int symbols_wrap, int symbols_size,
276 int flags)
277{
278 VLCcode *buf;
279 int i, j, ret;
280
281 vlc->bits = nb_bits;
282 if(flags & INIT_VLC_USE_NEW_STATIC){
283 if(vlc->table_size && vlc->table_size == vlc->table_allocated){
284 return 0;
285 }else if(vlc->table_size){
286 abort(); // fatal error, we are called on a partially initialized table
287 }
288 }else {
289 vlc->table = NULL;
290 vlc->table_allocated = 0;
291 vlc->table_size = 0;
292 }
293
294#ifdef DEBUG_VLC
295 av_log(NULL,AV_LOG_DEBUG,"build table nb_codes=%d\n", nb_codes);
296#endif
297
298 buf = av_malloc((nb_codes+1)*sizeof(VLCcode));
299
300 assert(symbols_size <= 2 || !symbols);
301 j = 0;
302#define COPY(condition)\
303 for (i = 0; i < nb_codes; i++) {\
304 GET_DATA(buf[j].bits, bits, i, bits_wrap, bits_size);\
305 if (!(condition))\
306 continue;\
307 GET_DATA(buf[j].code, codes, i, codes_wrap, codes_size);\
308 if (flags & INIT_VLC_LE)\
309 buf[j].code = bitswap_32(buf[j].code);\
310 else\
311 buf[j].code <<= 32 - buf[j].bits;\
312 if (symbols)\
313 GET_DATA(buf[j].symbol, symbols, i, symbols_wrap, symbols_size)\
314 else\
315 buf[j].symbol = i;\
316 j++;\
317 }
318 COPY(buf[j].bits > nb_bits);
319 // qsort is the slowest part of init_vlc, and could probably be improved or avoided
320 qsort(buf, j, sizeof(VLCcode), compare_vlcspec);
321 COPY(buf[j].bits && buf[j].bits <= nb_bits);
322 nb_codes = j;
323
324 ret = build_table(vlc, nb_bits, nb_codes, buf, flags);
325
326 av_free(buf);
327 if (ret < 0) {
328 av_freep(&vlc->table);
329 return -1;
330 }
331 if((flags & INIT_VLC_USE_NEW_STATIC) && vlc->table_size != vlc->table_allocated)
332 av_log(NULL, AV_LOG_ERROR, "needed %d had %d\n", vlc->table_size, vlc->table_allocated);
333 return 0;
334}
335
336
337void free_vlc(VLC *vlc)
338{
339 av_freep(&vlc->table);
340}
341
diff --git a/apps/codecs/libwmavoice/celp_filters.c b/apps/codecs/libwmavoice/celp_filters.c
new file mode 100644
index 0000000000..26a62eed14
--- /dev/null
+++ b/apps/codecs/libwmavoice/celp_filters.c
@@ -0,0 +1,210 @@
1/*
2 * various filters for ACELP-based codecs
3 *
4 * Copyright (c) 2008 Vladimir Voroshilov
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23#include <inttypes.h>
24
25#include "avcodec.h"
26#include "celp_filters.h"
27
28void ff_celp_convolve_circ(int16_t* fc_out, const int16_t* fc_in,
29 const int16_t* filter, int len)
30{
31 int i, k;
32
33 memset(fc_out, 0, len * sizeof(int16_t));
34
35 /* Since there are few pulses over an entire subframe (i.e. almost
36 all fc_in[i] are zero) it is faster to loop over fc_in first. */
37 for (i = 0; i < len; i++) {
38 if (fc_in[i]) {
39 for (k = 0; k < i; k++)
40 fc_out[k] += (fc_in[i] * filter[len + k - i]) >> 15;
41
42 for (k = i; k < len; k++)
43 fc_out[k] += (fc_in[i] * filter[ k - i]) >> 15;
44 }
45 }
46}
47
48void ff_celp_circ_addf(float *out, const float *in,
49 const float *lagged, int lag, float fac, int n)
50{
51 int k;
52 for (k = 0; k < lag; k++)
53 out[k] = in[k] + fac * lagged[n + k - lag];
54 for (; k < n; k++)
55 out[k] = in[k] + fac * lagged[ k - lag];
56}
57
58int ff_celp_lp_synthesis_filter(int16_t *out, const int16_t *filter_coeffs,
59 const int16_t *in, int buffer_length,
60 int filter_length, int stop_on_overflow,
61 int rounder)
62{
63 int i,n;
64
65 for (n = 0; n < buffer_length; n++) {
66 int sum = rounder;
67 for (i = 1; i <= filter_length; i++)
68 sum -= filter_coeffs[i-1] * out[n-i];
69
70 sum = (sum >> 12) + in[n];
71
72 if (sum + 0x8000 > 0xFFFFU) {
73 if (stop_on_overflow)
74 return 1;
75 sum = (sum >> 31) ^ 32767;
76 }
77 out[n] = sum;
78 }
79
80 return 0;
81}
82
83void ff_celp_lp_synthesis_filterf(float *out, const float *filter_coeffs,
84 const float* in, int buffer_length,
85 int filter_length)
86{
87 int i,n;
88
89#if 0 // Unoptimized code path for improved readability
90 for (n = 0; n < buffer_length; n++) {
91 out[n] = in[n];
92 for (i = 1; i <= filter_length; i++)
93 out[n] -= filter_coeffs[i-1] * out[n-i];
94 }
95#else
96 float out0, out1, out2, out3;
97 float old_out0, old_out1, old_out2, old_out3;
98 float a,b,c;
99
100 a = filter_coeffs[0];
101 b = filter_coeffs[1];
102 c = filter_coeffs[2];
103 b -= filter_coeffs[0] * filter_coeffs[0];
104 c -= filter_coeffs[1] * filter_coeffs[0];
105 c -= filter_coeffs[0] * b;
106
107 old_out0 = out[-4];
108 old_out1 = out[-3];
109 old_out2 = out[-2];
110 old_out3 = out[-1];
111 for (n = 0; n <= buffer_length - 4; n+=4) {
112 float tmp0,tmp1,tmp2,tmp3;
113 float val;
114
115 out0 = in[0];
116 out1 = in[1];
117 out2 = in[2];
118 out3 = in[3];
119
120 out0 -= filter_coeffs[2] * old_out1;
121 out1 -= filter_coeffs[2] * old_out2;
122 out2 -= filter_coeffs[2] * old_out3;
123
124 out0 -= filter_coeffs[1] * old_out2;
125 out1 -= filter_coeffs[1] * old_out3;
126
127 out0 -= filter_coeffs[0] * old_out3;
128
129 val = filter_coeffs[3];
130
131 out0 -= val * old_out0;
132 out1 -= val * old_out1;
133 out2 -= val * old_out2;
134 out3 -= val * old_out3;
135
136 old_out3 = out[-5];
137
138 for (i = 5; i <= filter_length; i += 2) {
139 val = filter_coeffs[i-1];
140
141 out0 -= val * old_out3;
142 out1 -= val * old_out0;
143 out2 -= val * old_out1;
144 out3 -= val * old_out2;
145
146 old_out2 = out[-i-1];
147
148 val = filter_coeffs[i];
149
150 out0 -= val * old_out2;
151 out1 -= val * old_out3;
152 out2 -= val * old_out0;
153 out3 -= val * old_out1;
154
155 FFSWAP(float, old_out0, old_out2);
156 old_out1 = old_out3;
157 old_out3 = out[-i-2];
158 }
159
160 tmp0 = out0;
161 tmp1 = out1;
162 tmp2 = out2;
163 tmp3 = out3;
164
165 out3 -= a * tmp2;
166 out2 -= a * tmp1;
167 out1 -= a * tmp0;
168
169 out3 -= b * tmp1;
170 out2 -= b * tmp0;
171
172 out3 -= c * tmp0;
173
174
175 out[0] = out0;
176 out[1] = out1;
177 out[2] = out2;
178 out[3] = out3;
179
180 old_out0 = out0;
181 old_out1 = out1;
182 old_out2 = out2;
183 old_out3 = out3;
184
185 out += 4;
186 in += 4;
187 }
188
189 out -= n;
190 in -= n;
191 for (; n < buffer_length; n++) {
192 out[n] = in[n];
193 for (i = 1; i <= filter_length; i++)
194 out[n] -= filter_coeffs[i-1] * out[n-i];
195 }
196#endif
197}
198
199void ff_celp_lp_zero_synthesis_filterf(float *out, const float *filter_coeffs,
200 const float *in, int buffer_length,
201 int filter_length)
202{
203 int i,n;
204
205 for (n = 0; n < buffer_length; n++) {
206 out[n] = in[n];
207 for (i = 1; i <= filter_length; i++)
208 out[n] += filter_coeffs[i-1] * in[n-i];
209 }
210}
diff --git a/apps/codecs/libwmavoice/celp_filters.h b/apps/codecs/libwmavoice/celp_filters.h
new file mode 100644
index 0000000000..145e3d3346
--- /dev/null
+++ b/apps/codecs/libwmavoice/celp_filters.h
@@ -0,0 +1,119 @@
1/*
2 * various filters for CELP-based codecs
3 *
4 * Copyright (c) 2008 Vladimir Voroshilov
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23#ifndef AVCODEC_CELP_FILTERS_H
24#define AVCODEC_CELP_FILTERS_H
25
26#include <stdint.h>
27
28/**
29 * Circularly convolve fixed vector with a phase dispersion impulse
30 * response filter (D.6.2 of G.729 and 6.1.5 of AMR).
31 * @param fc_out vector with filter applied
32 * @param fc_in source vector
33 * @param filter phase filter coefficients
34 *
35 * fc_out[n] = sum(i,0,len-1){ fc_in[i] * filter[(len + n - i)%len] }
36 *
37 * \note fc_in and fc_out should not overlap!
38 */
39void ff_celp_convolve_circ(int16_t *fc_out, const int16_t *fc_in,
40 const int16_t *filter, int len);
41
42/**
43 * Add an array to a rotated array.
44 *
45 * out[k] = in[k] + fac * lagged[k-lag] with wrap-around
46 *
47 * @param out result vector
48 * @param in samples to be added unfiltered
49 * @param lagged samples to be rotated, multiplied and added
50 * @param lag lagged vector delay in the range [0, n]
51 * @param fac scalefactor for lagged samples
52 * @param n number of samples
53 */
54void ff_celp_circ_addf(float *out, const float *in,
55 const float *lagged, int lag, float fac, int n);
56
57/**
58 * LP synthesis filter.
59 * @param[out] out pointer to output buffer
60 * @param filter_coeffs filter coefficients (-0x8000 <= (3.12) < 0x8000)
61 * @param in input signal
62 * @param buffer_length amount of data to process
63 * @param filter_length filter length (10 for 10th order LP filter)
64 * @param stop_on_overflow 1 - return immediately if overflow occurs
65 * 0 - ignore overflows
66 * @param rounder the amount to add for rounding (usually 0x800 or 0xfff)
67 *
68 * @return 1 if overflow occurred, 0 - otherwise
69 *
70 * @note Output buffer must contain filter_length samples of past
71 * speech data before pointer.
72 *
73 * Routine applies 1/A(z) filter to given speech data.
74 */
75int ff_celp_lp_synthesis_filter(int16_t *out, const int16_t *filter_coeffs,
76 const int16_t *in, int buffer_length,
77 int filter_length, int stop_on_overflow,
78 int rounder);
79
80/**
81 * LP synthesis filter.
82 * @param[out] out pointer to output buffer
83 * - the array out[-filter_length, -1] must
84 * contain the previous result of this filter
85 * @param filter_coeffs filter coefficients.
86 * @param in input signal
87 * @param buffer_length amount of data to process
88 * @param filter_length filter length (10 for 10th order LP filter). Must be
89 * greater than 4 and even.
90 *
91 * @note Output buffer must contain filter_length samples of past
92 * speech data before pointer.
93 *
94 * Routine applies 1/A(z) filter to given speech data.
95 */
96void ff_celp_lp_synthesis_filterf(float *out, const float *filter_coeffs,
97 const float *in, int buffer_length,
98 int filter_length);
99
100/**
101 * LP zero synthesis filter.
102 * @param[out] out pointer to output buffer
103 * @param filter_coeffs filter coefficients.
104 * @param in input signal
105 * - the array in[-filter_length, -1] must
106 * contain the previous input of this filter
107 * @param buffer_length amount of data to process
108 * @param filter_length filter length (10 for 10th order LP filter)
109 *
110 * @note Output buffer must contain filter_length samples of past
111 * speech data before pointer.
112 *
113 * Routine applies A(z) filter to given speech data.
114 */
115void ff_celp_lp_zero_synthesis_filterf(float *out, const float *filter_coeffs,
116 const float *in, int buffer_length,
117 int filter_length);
118
119#endif /* AVCODEC_CELP_FILTERS_H */
diff --git a/apps/codecs/libwmavoice/celp_math.c b/apps/codecs/libwmavoice/celp_math.c
new file mode 100644
index 0000000000..09111da819
--- /dev/null
+++ b/apps/codecs/libwmavoice/celp_math.c
@@ -0,0 +1,208 @@
1/*
2 * Various fixed-point math operations
3 *
4 * Copyright (c) 2008 Vladimir Voroshilov
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23#include <inttypes.h>
24#include <limits.h>
25#include <assert.h>
26
27#include "avcodec.h"
28#include "celp_math.h"
29
30#ifdef G729_BITEXACT
31/**
32 * Cosine table: base_cos[i] = (1<<15) * cos(i*PI/64)
33 */
34static const int16_t base_cos[64] =
35{
36 32767, 32729, 32610, 32413, 32138, 31786, 31357, 30853,
37 30274, 29622, 28899, 28106, 27246, 26320, 25330, 24279,
38 23170, 22006, 20788, 19520, 18205, 16846, 15447, 14010,
39 12540, 11039, 9512, 7962, 6393, 4808, 3212, 1608,
40 0, -1608, -3212, -4808, -6393, -7962, -9512, -11039,
41 -12540, -14010, -15447, -16846, -18205, -19520, -20788, -22006,
42 -23170, -24279, -25330, -26320, -27246, -28106, -28899, -29622,
43 -30274, -30853, -31357, -31786, -32138, -32413, -32610, -32729
44};
45
46/**
47 * Slope used to compute cos(x)
48 *
49 * cos(ind*64+offset) = base_cos[ind]+offset*slope_cos[ind]
50 * values multiplied by 1<<19
51 */
52static const int16_t slope_cos[64] =
53{
54 -632, -1893, -3150, -4399, -5638, -6863, -8072, -9261,
55 -10428, -11570, -12684, -13767, -14817, -15832, -16808, -17744,
56 -18637, -19486, -20287, -21039, -21741, -22390, -22986, -23526,
57 -24009, -24435, -24801, -25108, -25354, -25540, -25664, -25726,
58 -25726, -25664, -25540, -25354, -25108, -24801, -24435, -24009,
59 -23526, -22986, -22390, -21741, -21039, -20287, -19486, -18637,
60 -17744, -16808, -15832, -14817, -13767, -12684, -11570, -10428,
61 -9261, -8072, -6863, -5638, -4399, -3150, -1893, -632
62};
63
64/**
65 * Table used to compute exp2(x)
66 *
67 * tab_exp2[i] = (1<<14) * exp2(i/32) = 2^(i/32) i=0..32
68 */
69static const uint16_t tab_exp2[33] =
70{
71 16384, 16743, 17109, 17484, 17867, 18258, 18658, 19066, 19484, 19911,
72 20347, 20792, 21247, 21713, 22188, 22674, 23170, 23678, 24196, 24726,
73 25268, 25821, 26386, 26964, 27554, 28158, 28774, 29405, 30048, 30706,
74 31379, 32066, 32767
75};
76
77int16_t ff_cos(uint16_t arg)
78{
79 uint8_t offset= arg;
80 uint8_t ind = arg >> 8;
81
82 assert(arg < 0x4000);
83
84 return FFMAX(base_cos[ind] + ((slope_cos[ind] * offset) >> 12), -0x8000);
85}
86
87int ff_exp2(uint16_t power)
88{
89 uint16_t frac_x0;
90 uint16_t frac_dx;
91 int result;
92
93 assert(power <= 0x7fff);
94
95 frac_x0 = power >> 10;
96 frac_dx = (power & 0x03ff) << 5;
97
98 result = tab_exp2[frac_x0] << 15;
99 result += frac_dx * (tab_exp2[frac_x0+1] - tab_exp2[frac_x0]);
100
101 return result >> 10;
102}
103
104#else // G729_BITEXACT
105
106/**
107 * Cosine table: base_cos[i] = (1<<15) * cos(i*PI/64)
108 */
109static const int16_t tab_cos[65] =
110{
111 32767, 32738, 32617, 32421, 32145, 31793, 31364, 30860,
112 30280, 29629, 28905, 28113, 27252, 26326, 25336, 24285,
113 23176, 22011, 20793, 19525, 18210, 16851, 15451, 14014,
114 12543, 11043, 9515, 7965, 6395, 4810, 3214, 1609,
115 1, -1607, -3211, -4808, -6393, -7962, -9513, -11040,
116 -12541, -14012, -15449, -16848, -18207, -19523, -20791, -22009,
117 -23174, -24283, -25334, -26324, -27250, -28111, -28904, -29627,
118 -30279, -30858, -31363, -31792, -32144, -32419, -32616, -32736, -32768,
119};
120
121static const uint16_t exp2a[]=
122{
123 0, 1435, 2901, 4400, 5931, 7496, 9096, 10730,
124 12400, 14106, 15850, 17632, 19454, 21315, 23216, 25160,
125 27146, 29175, 31249, 33368, 35534, 37747, 40009, 42320,
126 44682, 47095, 49562, 52082, 54657, 57289, 59979, 62727,
127};
128
129static const uint16_t exp2b[]=
130{
131 3, 712, 1424, 2134, 2845, 3557, 4270, 4982,
132 5696, 6409, 7124, 7839, 8554, 9270, 9986, 10704,
133 11421, 12138, 12857, 13576, 14295, 15014, 15734, 16455,
134 17176, 17898, 18620, 19343, 20066, 20790, 21514, 22238,
135};
136
137int16_t ff_cos(uint16_t arg)
138{
139 uint8_t offset= arg;
140 uint8_t ind = arg >> 8;
141
142 assert(arg <= 0x3fff);
143
144 return tab_cos[ind] + (offset * (tab_cos[ind+1] - tab_cos[ind]) >> 8);
145}
146
147int ff_exp2(uint16_t power)
148{
149 unsigned int result= exp2a[power>>10] + 0x10000;
150
151 assert(power <= 0x7fff);
152
153 result= (result<<3) + ((result*exp2b[(power>>5)&31])>>17);
154 return result + ((result*(power&31)*89)>>22);
155}
156
157#endif // else G729_BITEXACT
158
159/**
160 * Table used to compute log2(x)
161 *
162 * tab_log2[i] = (1<<15) * log2(1 + i/32), i=0..32
163 */
164static const uint16_t tab_log2[33] =
165{
166#ifdef G729_BITEXACT
167 0, 1455, 2866, 4236, 5568, 6863, 8124, 9352,
168 10549, 11716, 12855, 13967, 15054, 16117, 17156, 18172,
169 19167, 20142, 21097, 22033, 22951, 23852, 24735, 25603,
170 26455, 27291, 28113, 28922, 29716, 30497, 31266, 32023, 32767,
171#else
172 4, 1459, 2870, 4240, 5572, 6867, 8127, 9355,
173 10552, 11719, 12858, 13971, 15057, 16120, 17158, 18175,
174 19170, 20145, 21100, 22036, 22954, 23854, 24738, 25605,
175 26457, 27294, 28116, 28924, 29719, 30500, 31269, 32025, 32769,
176#endif
177};
178
179int ff_log2(uint32_t value)
180{
181 uint8_t power_int;
182 uint8_t frac_x0;
183 uint16_t frac_dx;
184
185 // Stripping zeros from beginning
186 power_int = av_log2(value);
187 value <<= (31 - power_int);
188
189 // b31 is always non-zero now
190 frac_x0 = (value & 0x7c000000) >> 26; // b26-b31 and [32..63] -> [0..31]
191 frac_dx = (value & 0x03fff800) >> 11;
192
193 value = tab_log2[frac_x0];
194 value += (frac_dx * (tab_log2[frac_x0+1] - tab_log2[frac_x0])) >> 15;
195
196 return (power_int << 15) + value;
197}
198
199float ff_dot_productf(const float* a, const float* b, int length)
200{
201 float sum = 0;
202 int i;
203
204 for(i=0; i<length; i++)
205 sum += a[i] * b[i];
206
207 return sum;
208}
diff --git a/apps/codecs/libwmavoice/celp_math.h b/apps/codecs/libwmavoice/celp_math.h
new file mode 100644
index 0000000000..4cf656fb7e
--- /dev/null
+++ b/apps/codecs/libwmavoice/celp_math.h
@@ -0,0 +1,76 @@
1/*
2 * Various fixed-point math operations
3 *
4 * Copyright (c) 2008 Vladimir Voroshilov
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23#ifndef AVCODEC_CELP_MATH_H
24#define AVCODEC_CELP_MATH_H
25
26#include <stdint.h>
27
28/**
29 * fixed-point implementation of cosine in [0; PI) domain.
30 * @param arg fixed-point cosine argument, 0 <= arg < 0x4000
31 *
32 * @return value of (1<<15) * cos(arg * PI / (1<<14)), -0x8000 <= result <= 0x7fff
33 */
34int16_t ff_cos(uint16_t arg);
35
36/**
37 * fixed-point implementation of exp2(x) in [0; 1] domain.
38 * @param power argument to exp2, 0 <= power <= 0x7fff
39 *
40 * @return value of (1<<20) * exp2(power / (1<<15))
41 * 0x8000c <= result <= 0xfffea
42 */
43int ff_exp2(uint16_t power);
44
45/**
46 * Calculate log2(x).
47 * @param value function argument, 0 < value <= 7fff ffff
48 *
49 * @return value of (1<<15) * log2(value)
50 */
51int ff_log2(uint32_t value);
52
53/**
54 * Shift value left or right depending on sign of offset parameter.
55 * @param value value to shift
56 * @param offset shift offset
57 *
58 * @return value << offset, if offset>=0; value >> -offset - otherwise
59 */
60static inline int bidir_sal(int value, int offset)
61{
62 if(offset < 0) return value >> -offset;
63 else return value << offset;
64}
65
66/**
67 * returns the dot product.
68 * @param a input data array
69 * @param b input data array
70 * @param length number of elements
71 *
72 * @return dot product = sum of elementwise products
73 */
74float ff_dot_productf(const float* a, const float* b, int length);
75
76#endif /* AVCODEC_CELP_MATH_H */
diff --git a/apps/codecs/libwmavoice/dsputil.c b/apps/codecs/libwmavoice/dsputil.c
new file mode 100644
index 0000000000..534f03f885
--- /dev/null
+++ b/apps/codecs/libwmavoice/dsputil.c
@@ -0,0 +1,4535 @@
1/*
2 * DSP utils
3 * Copyright (c) 2000, 2001 Fabrice Bellard
4 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
5 *
6 * gmc & q-pel & 32/64 bit based MC by Michael Niedermayer <michaelni@gmx.at>
7 *
8 * This file is part of FFmpeg.
9 *
10 * FFmpeg is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * FFmpeg is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with FFmpeg; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 */
24
25/**
26 * @file
27 * DSP utils
28 */
29
30#include "avcodec.h"
31#include "dsputil.h"
32#include "simple_idct.h"
33#include "faandct.h"
34#include "faanidct.h"
35#include "mathops.h"
36#include "mpegvideo.h"
37#include "config.h"
38#include "lpc.h"
39#include "ac3dec.h"
40#include "vorbis.h"
41#include "png.h"
42#include "vp8dsp.h"
43
44uint8_t ff_cropTbl[256 + 2 * MAX_NEG_CROP] = {0, };
45uint32_t ff_squareTbl[512] = {0, };
46
47// 0x7f7f7f7f or 0x7f7f7f7f7f7f7f7f or whatever, depending on the cpu's native arithmetic size
48#define pb_7f (~0UL/255 * 0x7f)
49#define pb_80 (~0UL/255 * 0x80)
50
51const uint8_t ff_zigzag_direct[64] = {
52 0, 1, 8, 16, 9, 2, 3, 10,
53 17, 24, 32, 25, 18, 11, 4, 5,
54 12, 19, 26, 33, 40, 48, 41, 34,
55 27, 20, 13, 6, 7, 14, 21, 28,
56 35, 42, 49, 56, 57, 50, 43, 36,
57 29, 22, 15, 23, 30, 37, 44, 51,
58 58, 59, 52, 45, 38, 31, 39, 46,
59 53, 60, 61, 54, 47, 55, 62, 63
60};
61
62/* Specific zigzag scan for 248 idct. NOTE that unlike the
63 specification, we interleave the fields */
64const uint8_t ff_zigzag248_direct[64] = {
65 0, 8, 1, 9, 16, 24, 2, 10,
66 17, 25, 32, 40, 48, 56, 33, 41,
67 18, 26, 3, 11, 4, 12, 19, 27,
68 34, 42, 49, 57, 50, 58, 35, 43,
69 20, 28, 5, 13, 6, 14, 21, 29,
70 36, 44, 51, 59, 52, 60, 37, 45,
71 22, 30, 7, 15, 23, 31, 38, 46,
72 53, 61, 54, 62, 39, 47, 55, 63,
73};
74
75/* not permutated inverse zigzag_direct + 1 for MMX quantizer */
76DECLARE_ALIGNED(16, uint16_t, inv_zigzag_direct16)[64];
77
78const uint8_t ff_alternate_horizontal_scan[64] = {
79 0, 1, 2, 3, 8, 9, 16, 17,
80 10, 11, 4, 5, 6, 7, 15, 14,
81 13, 12, 19, 18, 24, 25, 32, 33,
82 26, 27, 20, 21, 22, 23, 28, 29,
83 30, 31, 34, 35, 40, 41, 48, 49,
84 42, 43, 36, 37, 38, 39, 44, 45,
85 46, 47, 50, 51, 56, 57, 58, 59,
86 52, 53, 54, 55, 60, 61, 62, 63,
87};
88
89const uint8_t ff_alternate_vertical_scan[64] = {
90 0, 8, 16, 24, 1, 9, 2, 10,
91 17, 25, 32, 40, 48, 56, 57, 49,
92 41, 33, 26, 18, 3, 11, 4, 12,
93 19, 27, 34, 42, 50, 58, 35, 43,
94 51, 59, 20, 28, 5, 13, 6, 14,
95 21, 29, 36, 44, 52, 60, 37, 45,
96 53, 61, 22, 30, 7, 15, 23, 31,
97 38, 46, 54, 62, 39, 47, 55, 63,
98};
99
100/* Input permutation for the simple_idct_mmx */
101static const uint8_t simple_mmx_permutation[64]={
102 0x00, 0x08, 0x04, 0x09, 0x01, 0x0C, 0x05, 0x0D,
103 0x10, 0x18, 0x14, 0x19, 0x11, 0x1C, 0x15, 0x1D,
104 0x20, 0x28, 0x24, 0x29, 0x21, 0x2C, 0x25, 0x2D,
105 0x12, 0x1A, 0x16, 0x1B, 0x13, 0x1E, 0x17, 0x1F,
106 0x02, 0x0A, 0x06, 0x0B, 0x03, 0x0E, 0x07, 0x0F,
107 0x30, 0x38, 0x34, 0x39, 0x31, 0x3C, 0x35, 0x3D,
108 0x22, 0x2A, 0x26, 0x2B, 0x23, 0x2E, 0x27, 0x2F,
109 0x32, 0x3A, 0x36, 0x3B, 0x33, 0x3E, 0x37, 0x3F,
110};
111
112static const uint8_t idct_sse2_row_perm[8] = {0, 4, 1, 5, 2, 6, 3, 7};
113
114void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable){
115 int i;
116 int end;
117
118 st->scantable= src_scantable;
119
120 for(i=0; i<64; i++){
121 int j;
122 j = src_scantable[i];
123 st->permutated[i] = permutation[j];
124#if ARCH_PPC
125 st->inverse[j] = i;
126#endif
127 }
128
129 end=-1;
130 for(i=0; i<64; i++){
131 int j;
132 j = st->permutated[i];
133 if(j>end) end=j;
134 st->raster_end[i]= end;
135 }
136}
137
138static int pix_sum_c(uint8_t * pix, int line_size)
139{
140 int s, i, j;
141
142 s = 0;
143 for (i = 0; i < 16; i++) {
144 for (j = 0; j < 16; j += 8) {
145 s += pix[0];
146 s += pix[1];
147 s += pix[2];
148 s += pix[3];
149 s += pix[4];
150 s += pix[5];
151 s += pix[6];
152 s += pix[7];
153 pix += 8;
154 }
155 pix += line_size - 16;
156 }
157 return s;
158}
159
160static int pix_norm1_c(uint8_t * pix, int line_size)
161{
162 int s, i, j;
163 uint32_t *sq = ff_squareTbl + 256;
164
165 s = 0;
166 for (i = 0; i < 16; i++) {
167 for (j = 0; j < 16; j += 8) {
168#if 0
169 s += sq[pix[0]];
170 s += sq[pix[1]];
171 s += sq[pix[2]];
172 s += sq[pix[3]];
173 s += sq[pix[4]];
174 s += sq[pix[5]];
175 s += sq[pix[6]];
176 s += sq[pix[7]];
177#else
178#if LONG_MAX > 2147483647
179 register uint64_t x=*(uint64_t*)pix;
180 s += sq[x&0xff];
181 s += sq[(x>>8)&0xff];
182 s += sq[(x>>16)&0xff];
183 s += sq[(x>>24)&0xff];
184 s += sq[(x>>32)&0xff];
185 s += sq[(x>>40)&0xff];
186 s += sq[(x>>48)&0xff];
187 s += sq[(x>>56)&0xff];
188#else
189 register uint32_t x=*(uint32_t*)pix;
190 s += sq[x&0xff];
191 s += sq[(x>>8)&0xff];
192 s += sq[(x>>16)&0xff];
193 s += sq[(x>>24)&0xff];
194 x=*(uint32_t*)(pix+4);
195 s += sq[x&0xff];
196 s += sq[(x>>8)&0xff];
197 s += sq[(x>>16)&0xff];
198 s += sq[(x>>24)&0xff];
199#endif
200#endif
201 pix += 8;
202 }
203 pix += line_size - 16;
204 }
205 return s;
206}
207
208static void bswap_buf(uint32_t *dst, const uint32_t *src, int w){
209 int i;
210
211 for(i=0; i+8<=w; i+=8){
212 dst[i+0]= av_bswap32(src[i+0]);
213 dst[i+1]= av_bswap32(src[i+1]);
214 dst[i+2]= av_bswap32(src[i+2]);
215 dst[i+3]= av_bswap32(src[i+3]);
216 dst[i+4]= av_bswap32(src[i+4]);
217 dst[i+5]= av_bswap32(src[i+5]);
218 dst[i+6]= av_bswap32(src[i+6]);
219 dst[i+7]= av_bswap32(src[i+7]);
220 }
221 for(;i<w; i++){
222 dst[i+0]= av_bswap32(src[i+0]);
223 }
224}
225
226static int sse4_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h)
227{
228 int s, i;
229 uint32_t *sq = ff_squareTbl + 256;
230
231 s = 0;
232 for (i = 0; i < h; i++) {
233 s += sq[pix1[0] - pix2[0]];
234 s += sq[pix1[1] - pix2[1]];
235 s += sq[pix1[2] - pix2[2]];
236 s += sq[pix1[3] - pix2[3]];
237 pix1 += line_size;
238 pix2 += line_size;
239 }
240 return s;
241}
242
243static int sse8_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h)
244{
245 int s, i;
246 uint32_t *sq = ff_squareTbl + 256;
247
248 s = 0;
249 for (i = 0; i < h; i++) {
250 s += sq[pix1[0] - pix2[0]];
251 s += sq[pix1[1] - pix2[1]];
252 s += sq[pix1[2] - pix2[2]];
253 s += sq[pix1[3] - pix2[3]];
254 s += sq[pix1[4] - pix2[4]];
255 s += sq[pix1[5] - pix2[5]];
256 s += sq[pix1[6] - pix2[6]];
257 s += sq[pix1[7] - pix2[7]];
258 pix1 += line_size;
259 pix2 += line_size;
260 }
261 return s;
262}
263
264static int sse16_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
265{
266 int s, i;
267 uint32_t *sq = ff_squareTbl + 256;
268
269 s = 0;
270 for (i = 0; i < h; i++) {
271 s += sq[pix1[ 0] - pix2[ 0]];
272 s += sq[pix1[ 1] - pix2[ 1]];
273 s += sq[pix1[ 2] - pix2[ 2]];
274 s += sq[pix1[ 3] - pix2[ 3]];
275 s += sq[pix1[ 4] - pix2[ 4]];
276 s += sq[pix1[ 5] - pix2[ 5]];
277 s += sq[pix1[ 6] - pix2[ 6]];
278 s += sq[pix1[ 7] - pix2[ 7]];
279 s += sq[pix1[ 8] - pix2[ 8]];
280 s += sq[pix1[ 9] - pix2[ 9]];
281 s += sq[pix1[10] - pix2[10]];
282 s += sq[pix1[11] - pix2[11]];
283 s += sq[pix1[12] - pix2[12]];
284 s += sq[pix1[13] - pix2[13]];
285 s += sq[pix1[14] - pix2[14]];
286 s += sq[pix1[15] - pix2[15]];
287
288 pix1 += line_size;
289 pix2 += line_size;
290 }
291 return s;
292}
293
294/* draw the edges of width 'w' of an image of size width, height */
295//FIXME check that this is ok for mpeg4 interlaced
296static void draw_edges_c(uint8_t *buf, int wrap, int width, int height, int w)
297{
298 uint8_t *ptr, *last_line;
299 int i;
300
301 last_line = buf + (height - 1) * wrap;
302 for(i=0;i<w;i++) {
303 /* top and bottom */
304 memcpy(buf - (i + 1) * wrap, buf, width);
305 memcpy(last_line + (i + 1) * wrap, last_line, width);
306 }
307 /* left and right */
308 ptr = buf;
309 for(i=0;i<height;i++) {
310 memset(ptr - w, ptr[0], w);
311 memset(ptr + width, ptr[width-1], w);
312 ptr += wrap;
313 }
314 /* corners */
315 for(i=0;i<w;i++) {
316 memset(buf - (i + 1) * wrap - w, buf[0], w); /* top left */
317 memset(buf - (i + 1) * wrap + width, buf[width-1], w); /* top right */
318 memset(last_line + (i + 1) * wrap - w, last_line[0], w); /* top left */
319 memset(last_line + (i + 1) * wrap + width, last_line[width-1], w); /* top right */
320 }
321}
322
323/**
324 * Copy a rectangular area of samples to a temporary buffer and replicate the border samples.
325 * @param buf destination buffer
326 * @param src source buffer
327 * @param linesize number of bytes between 2 vertically adjacent samples in both the source and destination buffers
328 * @param block_w width of block
329 * @param block_h height of block
330 * @param src_x x coordinate of the top left sample of the block in the source buffer
331 * @param src_y y coordinate of the top left sample of the block in the source buffer
332 * @param w width of the source buffer
333 * @param h height of the source buffer
334 */
335void ff_emulated_edge_mc(uint8_t *buf, const uint8_t *src, int linesize, int block_w, int block_h,
336 int src_x, int src_y, int w, int h){
337 int x, y;
338 int start_y, start_x, end_y, end_x;
339
340 if(src_y>= h){
341 src+= (h-1-src_y)*linesize;
342 src_y=h-1;
343 }else if(src_y<=-block_h){
344 src+= (1-block_h-src_y)*linesize;
345 src_y=1-block_h;
346 }
347 if(src_x>= w){
348 src+= (w-1-src_x);
349 src_x=w-1;
350 }else if(src_x<=-block_w){
351 src+= (1-block_w-src_x);
352 src_x=1-block_w;
353 }
354
355 start_y= FFMAX(0, -src_y);
356 start_x= FFMAX(0, -src_x);
357 end_y= FFMIN(block_h, h-src_y);
358 end_x= FFMIN(block_w, w-src_x);
359
360 // copy existing part
361 for(y=start_y; y<end_y; y++){
362 for(x=start_x; x<end_x; x++){
363 buf[x + y*linesize]= src[x + y*linesize];
364 }
365 }
366
367 //top
368 for(y=0; y<start_y; y++){
369 for(x=start_x; x<end_x; x++){
370 buf[x + y*linesize]= buf[x + start_y*linesize];
371 }
372 }
373
374 //bottom
375 for(y=end_y; y<block_h; y++){
376 for(x=start_x; x<end_x; x++){
377 buf[x + y*linesize]= buf[x + (end_y-1)*linesize];
378 }
379 }
380
381 for(y=0; y<block_h; y++){
382 //left
383 for(x=0; x<start_x; x++){
384 buf[x + y*linesize]= buf[start_x + y*linesize];
385 }
386
387 //right
388 for(x=end_x; x<block_w; x++){
389 buf[x + y*linesize]= buf[end_x - 1 + y*linesize];
390 }
391 }
392}
393
394static void get_pixels_c(DCTELEM *restrict block, const uint8_t *pixels, int line_size)
395{
396 int i;
397
398 /* read the pixels */
399 for(i=0;i<8;i++) {
400 block[0] = pixels[0];
401 block[1] = pixels[1];
402 block[2] = pixels[2];
403 block[3] = pixels[3];
404 block[4] = pixels[4];
405 block[5] = pixels[5];
406 block[6] = pixels[6];
407 block[7] = pixels[7];
408 pixels += line_size;
409 block += 8;
410 }
411}
412
413static void diff_pixels_c(DCTELEM *restrict block, const uint8_t *s1,
414 const uint8_t *s2, int stride){
415 int i;
416
417 /* read the pixels */
418 for(i=0;i<8;i++) {
419 block[0] = s1[0] - s2[0];
420 block[1] = s1[1] - s2[1];
421 block[2] = s1[2] - s2[2];
422 block[3] = s1[3] - s2[3];
423 block[4] = s1[4] - s2[4];
424 block[5] = s1[5] - s2[5];
425 block[6] = s1[6] - s2[6];
426 block[7] = s1[7] - s2[7];
427 s1 += stride;
428 s2 += stride;
429 block += 8;
430 }
431}
432
433
434static void put_pixels_clamped_c(const DCTELEM *block, uint8_t *restrict pixels,
435 int line_size)
436{
437 int i;
438 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
439
440 /* read the pixels */
441 for(i=0;i<8;i++) {
442 pixels[0] = cm[block[0]];
443 pixels[1] = cm[block[1]];
444 pixels[2] = cm[block[2]];
445 pixels[3] = cm[block[3]];
446 pixels[4] = cm[block[4]];
447 pixels[5] = cm[block[5]];
448 pixels[6] = cm[block[6]];
449 pixels[7] = cm[block[7]];
450
451 pixels += line_size;
452 block += 8;
453 }
454}
455
456static void put_pixels_clamped4_c(const DCTELEM *block, uint8_t *restrict pixels,
457 int line_size)
458{
459 int i;
460 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
461
462 /* read the pixels */
463 for(i=0;i<4;i++) {
464 pixels[0] = cm[block[0]];
465 pixels[1] = cm[block[1]];
466 pixels[2] = cm[block[2]];
467 pixels[3] = cm[block[3]];
468
469 pixels += line_size;
470 block += 8;
471 }
472}
473
474static void put_pixels_clamped2_c(const DCTELEM *block, uint8_t *restrict pixels,
475 int line_size)
476{
477 int i;
478 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
479
480 /* read the pixels */
481 for(i=0;i<2;i++) {
482 pixels[0] = cm[block[0]];
483 pixels[1] = cm[block[1]];
484
485 pixels += line_size;
486 block += 8;
487 }
488}
489
490static void put_signed_pixels_clamped_c(const DCTELEM *block,
491 uint8_t *restrict pixels,
492 int line_size)
493{
494 int i, j;
495
496 for (i = 0; i < 8; i++) {
497 for (j = 0; j < 8; j++) {
498 if (*block < -128)
499 *pixels = 0;
500 else if (*block > 127)
501 *pixels = 255;
502 else
503 *pixels = (uint8_t)(*block + 128);
504 block++;
505 pixels++;
506 }
507 pixels += (line_size - 8);
508 }
509}
510
511static void put_pixels_nonclamped_c(const DCTELEM *block, uint8_t *restrict pixels,
512 int line_size)
513{
514 int i;
515
516 /* read the pixels */
517 for(i=0;i<8;i++) {
518 pixels[0] = block[0];
519 pixels[1] = block[1];
520 pixels[2] = block[2];
521 pixels[3] = block[3];
522 pixels[4] = block[4];
523 pixels[5] = block[5];
524 pixels[6] = block[6];
525 pixels[7] = block[7];
526
527 pixels += line_size;
528 block += 8;
529 }
530}
531
532static void add_pixels_clamped_c(const DCTELEM *block, uint8_t *restrict pixels,
533 int line_size)
534{
535 int i;
536 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
537
538 /* read the pixels */
539 for(i=0;i<8;i++) {
540 pixels[0] = cm[pixels[0] + block[0]];
541 pixels[1] = cm[pixels[1] + block[1]];
542 pixels[2] = cm[pixels[2] + block[2]];
543 pixels[3] = cm[pixels[3] + block[3]];
544 pixels[4] = cm[pixels[4] + block[4]];
545 pixels[5] = cm[pixels[5] + block[5]];
546 pixels[6] = cm[pixels[6] + block[6]];
547 pixels[7] = cm[pixels[7] + block[7]];
548 pixels += line_size;
549 block += 8;
550 }
551}
552
553static void add_pixels_clamped4_c(const DCTELEM *block, uint8_t *restrict pixels,
554 int line_size)
555{
556 int i;
557 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
558
559 /* read the pixels */
560 for(i=0;i<4;i++) {
561 pixels[0] = cm[pixels[0] + block[0]];
562 pixels[1] = cm[pixels[1] + block[1]];
563 pixels[2] = cm[pixels[2] + block[2]];
564 pixels[3] = cm[pixels[3] + block[3]];
565 pixels += line_size;
566 block += 8;
567 }
568}
569
570static void add_pixels_clamped2_c(const DCTELEM *block, uint8_t *restrict pixels,
571 int line_size)
572{
573 int i;
574 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
575
576 /* read the pixels */
577 for(i=0;i<2;i++) {
578 pixels[0] = cm[pixels[0] + block[0]];
579 pixels[1] = cm[pixels[1] + block[1]];
580 pixels += line_size;
581 block += 8;
582 }
583}
584
585static void add_pixels8_c(uint8_t *restrict pixels, DCTELEM *block, int line_size)
586{
587 int i;
588 for(i=0;i<8;i++) {
589 pixels[0] += block[0];
590 pixels[1] += block[1];
591 pixels[2] += block[2];
592 pixels[3] += block[3];
593 pixels[4] += block[4];
594 pixels[5] += block[5];
595 pixels[6] += block[6];
596 pixels[7] += block[7];
597 pixels += line_size;
598 block += 8;
599 }
600}
601
602static void add_pixels4_c(uint8_t *restrict pixels, DCTELEM *block, int line_size)
603{
604 int i;
605 for(i=0;i<4;i++) {
606 pixels[0] += block[0];
607 pixels[1] += block[1];
608 pixels[2] += block[2];
609 pixels[3] += block[3];
610 pixels += line_size;
611 block += 4;
612 }
613}
614
615static int sum_abs_dctelem_c(DCTELEM *block)
616{
617 int sum=0, i;
618 for(i=0; i<64; i++)
619 sum+= FFABS(block[i]);
620 return sum;
621}
622
623static void fill_block16_c(uint8_t *block, uint8_t value, int line_size, int h)
624{
625 int i;
626
627 for (i = 0; i < h; i++) {
628 memset(block, value, 16);
629 block += line_size;
630 }
631}
632
633static void fill_block8_c(uint8_t *block, uint8_t value, int line_size, int h)
634{
635 int i;
636
637 for (i = 0; i < h; i++) {
638 memset(block, value, 8);
639 block += line_size;
640 }
641}
642
643static void scale_block_c(const uint8_t src[64]/*align 8*/, uint8_t *dst/*align 8*/, int linesize)
644{
645 int i, j;
646 uint16_t *dst1 = (uint16_t *) dst;
647 uint16_t *dst2 = (uint16_t *)(dst + linesize);
648
649 for (j = 0; j < 8; j++) {
650 for (i = 0; i < 8; i++) {
651 dst1[i] = dst2[i] = src[i] * 0x0101;
652 }
653 src += 8;
654 dst1 += linesize;
655 dst2 += linesize;
656 }
657}
658
659#if 0
660
661#define PIXOP2(OPNAME, OP) \
662static void OPNAME ## _pixels(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
663{\
664 int i;\
665 for(i=0; i<h; i++){\
666 OP(*((uint64_t*)block), AV_RN64(pixels));\
667 pixels+=line_size;\
668 block +=line_size;\
669 }\
670}\
671\
672static void OPNAME ## _no_rnd_pixels_x2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
673{\
674 int i;\
675 for(i=0; i<h; i++){\
676 const uint64_t a= AV_RN64(pixels );\
677 const uint64_t b= AV_RN64(pixels+1);\
678 OP(*((uint64_t*)block), (a&b) + (((a^b)&0xFEFEFEFEFEFEFEFEULL)>>1));\
679 pixels+=line_size;\
680 block +=line_size;\
681 }\
682}\
683\
684static void OPNAME ## _pixels_x2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
685{\
686 int i;\
687 for(i=0; i<h; i++){\
688 const uint64_t a= AV_RN64(pixels );\
689 const uint64_t b= AV_RN64(pixels+1);\
690 OP(*((uint64_t*)block), (a|b) - (((a^b)&0xFEFEFEFEFEFEFEFEULL)>>1));\
691 pixels+=line_size;\
692 block +=line_size;\
693 }\
694}\
695\
696static void OPNAME ## _no_rnd_pixels_y2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
697{\
698 int i;\
699 for(i=0; i<h; i++){\
700 const uint64_t a= AV_RN64(pixels );\
701 const uint64_t b= AV_RN64(pixels+line_size);\
702 OP(*((uint64_t*)block), (a&b) + (((a^b)&0xFEFEFEFEFEFEFEFEULL)>>1));\
703 pixels+=line_size;\
704 block +=line_size;\
705 }\
706}\
707\
708static void OPNAME ## _pixels_y2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
709{\
710 int i;\
711 for(i=0; i<h; i++){\
712 const uint64_t a= AV_RN64(pixels );\
713 const uint64_t b= AV_RN64(pixels+line_size);\
714 OP(*((uint64_t*)block), (a|b) - (((a^b)&0xFEFEFEFEFEFEFEFEULL)>>1));\
715 pixels+=line_size;\
716 block +=line_size;\
717 }\
718}\
719\
720static void OPNAME ## _pixels_xy2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
721{\
722 int i;\
723 const uint64_t a= AV_RN64(pixels );\
724 const uint64_t b= AV_RN64(pixels+1);\
725 uint64_t l0= (a&0x0303030303030303ULL)\
726 + (b&0x0303030303030303ULL)\
727 + 0x0202020202020202ULL;\
728 uint64_t h0= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\
729 + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\
730 uint64_t l1,h1;\
731\
732 pixels+=line_size;\
733 for(i=0; i<h; i+=2){\
734 uint64_t a= AV_RN64(pixels );\
735 uint64_t b= AV_RN64(pixels+1);\
736 l1= (a&0x0303030303030303ULL)\
737 + (b&0x0303030303030303ULL);\
738 h1= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\
739 + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\
740 OP(*((uint64_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0F0F0F0F0FULL));\
741 pixels+=line_size;\
742 block +=line_size;\
743 a= AV_RN64(pixels );\
744 b= AV_RN64(pixels+1);\
745 l0= (a&0x0303030303030303ULL)\
746 + (b&0x0303030303030303ULL)\
747 + 0x0202020202020202ULL;\
748 h0= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\
749 + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\
750 OP(*((uint64_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0F0F0F0F0FULL));\
751 pixels+=line_size;\
752 block +=line_size;\
753 }\
754}\
755\
756static void OPNAME ## _no_rnd_pixels_xy2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
757{\
758 int i;\
759 const uint64_t a= AV_RN64(pixels );\
760 const uint64_t b= AV_RN64(pixels+1);\
761 uint64_t l0= (a&0x0303030303030303ULL)\
762 + (b&0x0303030303030303ULL)\
763 + 0x0101010101010101ULL;\
764 uint64_t h0= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\
765 + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\
766 uint64_t l1,h1;\
767\
768 pixels+=line_size;\
769 for(i=0; i<h; i+=2){\
770 uint64_t a= AV_RN64(pixels );\
771 uint64_t b= AV_RN64(pixels+1);\
772 l1= (a&0x0303030303030303ULL)\
773 + (b&0x0303030303030303ULL);\
774 h1= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\
775 + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\
776 OP(*((uint64_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0F0F0F0F0FULL));\
777 pixels+=line_size;\
778 block +=line_size;\
779 a= AV_RN64(pixels );\
780 b= AV_RN64(pixels+1);\
781 l0= (a&0x0303030303030303ULL)\
782 + (b&0x0303030303030303ULL)\
783 + 0x0101010101010101ULL;\
784 h0= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\
785 + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\
786 OP(*((uint64_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0F0F0F0F0FULL));\
787 pixels+=line_size;\
788 block +=line_size;\
789 }\
790}\
791\
792CALL_2X_PIXELS(OPNAME ## _pixels16_c , OPNAME ## _pixels_c , 8)\
793CALL_2X_PIXELS(OPNAME ## _pixels16_x2_c , OPNAME ## _pixels_x2_c , 8)\
794CALL_2X_PIXELS(OPNAME ## _pixels16_y2_c , OPNAME ## _pixels_y2_c , 8)\
795CALL_2X_PIXELS(OPNAME ## _pixels16_xy2_c, OPNAME ## _pixels_xy2_c, 8)\
796CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_x2_c , OPNAME ## _no_rnd_pixels_x2_c , 8)\
797CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_y2_c , OPNAME ## _no_rnd_pixels_y2_c , 8)\
798CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_xy2_c, OPNAME ## _no_rnd_pixels_xy2_c, 8)
799
800#define op_avg(a, b) a = ( ((a)|(b)) - ((((a)^(b))&0xFEFEFEFEFEFEFEFEULL)>>1) )
801#else // 64 bit variant
802
803#define PIXOP2(OPNAME, OP) \
804static void OPNAME ## _pixels2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
805 int i;\
806 for(i=0; i<h; i++){\
807 OP(*((uint16_t*)(block )), AV_RN16(pixels ));\
808 pixels+=line_size;\
809 block +=line_size;\
810 }\
811}\
812static void OPNAME ## _pixels4_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
813 int i;\
814 for(i=0; i<h; i++){\
815 OP(*((uint32_t*)(block )), AV_RN32(pixels ));\
816 pixels+=line_size;\
817 block +=line_size;\
818 }\
819}\
820static void OPNAME ## _pixels8_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
821 int i;\
822 for(i=0; i<h; i++){\
823 OP(*((uint32_t*)(block )), AV_RN32(pixels ));\
824 OP(*((uint32_t*)(block+4)), AV_RN32(pixels+4));\
825 pixels+=line_size;\
826 block +=line_size;\
827 }\
828}\
829static inline void OPNAME ## _no_rnd_pixels8_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
830 OPNAME ## _pixels8_c(block, pixels, line_size, h);\
831}\
832\
833static inline void OPNAME ## _no_rnd_pixels8_l2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
834 int src_stride1, int src_stride2, int h){\
835 int i;\
836 for(i=0; i<h; i++){\
837 uint32_t a,b;\
838 a= AV_RN32(&src1[i*src_stride1 ]);\
839 b= AV_RN32(&src2[i*src_stride2 ]);\
840 OP(*((uint32_t*)&dst[i*dst_stride ]), no_rnd_avg32(a, b));\
841 a= AV_RN32(&src1[i*src_stride1+4]);\
842 b= AV_RN32(&src2[i*src_stride2+4]);\
843 OP(*((uint32_t*)&dst[i*dst_stride+4]), no_rnd_avg32(a, b));\
844 }\
845}\
846\
847static inline void OPNAME ## _pixels8_l2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
848 int src_stride1, int src_stride2, int h){\
849 int i;\
850 for(i=0; i<h; i++){\
851 uint32_t a,b;\
852 a= AV_RN32(&src1[i*src_stride1 ]);\
853 b= AV_RN32(&src2[i*src_stride2 ]);\
854 OP(*((uint32_t*)&dst[i*dst_stride ]), rnd_avg32(a, b));\
855 a= AV_RN32(&src1[i*src_stride1+4]);\
856 b= AV_RN32(&src2[i*src_stride2+4]);\
857 OP(*((uint32_t*)&dst[i*dst_stride+4]), rnd_avg32(a, b));\
858 }\
859}\
860\
861static inline void OPNAME ## _pixels4_l2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
862 int src_stride1, int src_stride2, int h){\
863 int i;\
864 for(i=0; i<h; i++){\
865 uint32_t a,b;\
866 a= AV_RN32(&src1[i*src_stride1 ]);\
867 b= AV_RN32(&src2[i*src_stride2 ]);\
868 OP(*((uint32_t*)&dst[i*dst_stride ]), rnd_avg32(a, b));\
869 }\
870}\
871\
872static inline void OPNAME ## _pixels2_l2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
873 int src_stride1, int src_stride2, int h){\
874 int i;\
875 for(i=0; i<h; i++){\
876 uint32_t a,b;\
877 a= AV_RN16(&src1[i*src_stride1 ]);\
878 b= AV_RN16(&src2[i*src_stride2 ]);\
879 OP(*((uint16_t*)&dst[i*dst_stride ]), rnd_avg32(a, b));\
880 }\
881}\
882\
883static inline void OPNAME ## _pixels16_l2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
884 int src_stride1, int src_stride2, int h){\
885 OPNAME ## _pixels8_l2(dst , src1 , src2 , dst_stride, src_stride1, src_stride2, h);\
886 OPNAME ## _pixels8_l2(dst+8, src1+8, src2+8, dst_stride, src_stride1, src_stride2, h);\
887}\
888\
889static inline void OPNAME ## _no_rnd_pixels16_l2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
890 int src_stride1, int src_stride2, int h){\
891 OPNAME ## _no_rnd_pixels8_l2(dst , src1 , src2 , dst_stride, src_stride1, src_stride2, h);\
892 OPNAME ## _no_rnd_pixels8_l2(dst+8, src1+8, src2+8, dst_stride, src_stride1, src_stride2, h);\
893}\
894\
895static inline void OPNAME ## _no_rnd_pixels8_x2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
896 OPNAME ## _no_rnd_pixels8_l2(block, pixels, pixels+1, line_size, line_size, line_size, h);\
897}\
898\
899static inline void OPNAME ## _pixels8_x2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
900 OPNAME ## _pixels8_l2(block, pixels, pixels+1, line_size, line_size, line_size, h);\
901}\
902\
903static inline void OPNAME ## _no_rnd_pixels8_y2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
904 OPNAME ## _no_rnd_pixels8_l2(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\
905}\
906\
907static inline void OPNAME ## _pixels8_y2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
908 OPNAME ## _pixels8_l2(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\
909}\
910\
911static inline void OPNAME ## _pixels8_l4(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, const uint8_t *src3, const uint8_t *src4,\
912 int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
913 int i;\
914 for(i=0; i<h; i++){\
915 uint32_t a, b, c, d, l0, l1, h0, h1;\
916 a= AV_RN32(&src1[i*src_stride1]);\
917 b= AV_RN32(&src2[i*src_stride2]);\
918 c= AV_RN32(&src3[i*src_stride3]);\
919 d= AV_RN32(&src4[i*src_stride4]);\
920 l0= (a&0x03030303UL)\
921 + (b&0x03030303UL)\
922 + 0x02020202UL;\
923 h0= ((a&0xFCFCFCFCUL)>>2)\
924 + ((b&0xFCFCFCFCUL)>>2);\
925 l1= (c&0x03030303UL)\
926 + (d&0x03030303UL);\
927 h1= ((c&0xFCFCFCFCUL)>>2)\
928 + ((d&0xFCFCFCFCUL)>>2);\
929 OP(*((uint32_t*)&dst[i*dst_stride]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
930 a= AV_RN32(&src1[i*src_stride1+4]);\
931 b= AV_RN32(&src2[i*src_stride2+4]);\
932 c= AV_RN32(&src3[i*src_stride3+4]);\
933 d= AV_RN32(&src4[i*src_stride4+4]);\
934 l0= (a&0x03030303UL)\
935 + (b&0x03030303UL)\
936 + 0x02020202UL;\
937 h0= ((a&0xFCFCFCFCUL)>>2)\
938 + ((b&0xFCFCFCFCUL)>>2);\
939 l1= (c&0x03030303UL)\
940 + (d&0x03030303UL);\
941 h1= ((c&0xFCFCFCFCUL)>>2)\
942 + ((d&0xFCFCFCFCUL)>>2);\
943 OP(*((uint32_t*)&dst[i*dst_stride+4]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
944 }\
945}\
946\
947static inline void OPNAME ## _pixels4_x2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
948 OPNAME ## _pixels4_l2(block, pixels, pixels+1, line_size, line_size, line_size, h);\
949}\
950\
951static inline void OPNAME ## _pixels4_y2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
952 OPNAME ## _pixels4_l2(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\
953}\
954\
955static inline void OPNAME ## _pixels2_x2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
956 OPNAME ## _pixels2_l2(block, pixels, pixels+1, line_size, line_size, line_size, h);\
957}\
958\
959static inline void OPNAME ## _pixels2_y2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
960 OPNAME ## _pixels2_l2(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\
961}\
962\
963static inline void OPNAME ## _no_rnd_pixels8_l4(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, const uint8_t *src3, const uint8_t *src4,\
964 int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
965 int i;\
966 for(i=0; i<h; i++){\
967 uint32_t a, b, c, d, l0, l1, h0, h1;\
968 a= AV_RN32(&src1[i*src_stride1]);\
969 b= AV_RN32(&src2[i*src_stride2]);\
970 c= AV_RN32(&src3[i*src_stride3]);\
971 d= AV_RN32(&src4[i*src_stride4]);\
972 l0= (a&0x03030303UL)\
973 + (b&0x03030303UL)\
974 + 0x01010101UL;\
975 h0= ((a&0xFCFCFCFCUL)>>2)\
976 + ((b&0xFCFCFCFCUL)>>2);\
977 l1= (c&0x03030303UL)\
978 + (d&0x03030303UL);\
979 h1= ((c&0xFCFCFCFCUL)>>2)\
980 + ((d&0xFCFCFCFCUL)>>2);\
981 OP(*((uint32_t*)&dst[i*dst_stride]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
982 a= AV_RN32(&src1[i*src_stride1+4]);\
983 b= AV_RN32(&src2[i*src_stride2+4]);\
984 c= AV_RN32(&src3[i*src_stride3+4]);\
985 d= AV_RN32(&src4[i*src_stride4+4]);\
986 l0= (a&0x03030303UL)\
987 + (b&0x03030303UL)\
988 + 0x01010101UL;\
989 h0= ((a&0xFCFCFCFCUL)>>2)\
990 + ((b&0xFCFCFCFCUL)>>2);\
991 l1= (c&0x03030303UL)\
992 + (d&0x03030303UL);\
993 h1= ((c&0xFCFCFCFCUL)>>2)\
994 + ((d&0xFCFCFCFCUL)>>2);\
995 OP(*((uint32_t*)&dst[i*dst_stride+4]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
996 }\
997}\
998static inline void OPNAME ## _pixels16_l4(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, const uint8_t *src3, const uint8_t *src4,\
999 int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
1000 OPNAME ## _pixels8_l4(dst , src1 , src2 , src3 , src4 , dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\
1001 OPNAME ## _pixels8_l4(dst+8, src1+8, src2+8, src3+8, src4+8, dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\
1002}\
1003static inline void OPNAME ## _no_rnd_pixels16_l4(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, const uint8_t *src3, const uint8_t *src4,\
1004 int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
1005 OPNAME ## _no_rnd_pixels8_l4(dst , src1 , src2 , src3 , src4 , dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\
1006 OPNAME ## _no_rnd_pixels8_l4(dst+8, src1+8, src2+8, src3+8, src4+8, dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\
1007}\
1008\
1009static inline void OPNAME ## _pixels2_xy2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
1010{\
1011 int i, a0, b0, a1, b1;\
1012 a0= pixels[0];\
1013 b0= pixels[1] + 2;\
1014 a0 += b0;\
1015 b0 += pixels[2];\
1016\
1017 pixels+=line_size;\
1018 for(i=0; i<h; i+=2){\
1019 a1= pixels[0];\
1020 b1= pixels[1];\
1021 a1 += b1;\
1022 b1 += pixels[2];\
1023\
1024 block[0]= (a1+a0)>>2; /* FIXME non put */\
1025 block[1]= (b1+b0)>>2;\
1026\
1027 pixels+=line_size;\
1028 block +=line_size;\
1029\
1030 a0= pixels[0];\
1031 b0= pixels[1] + 2;\
1032 a0 += b0;\
1033 b0 += pixels[2];\
1034\
1035 block[0]= (a1+a0)>>2;\
1036 block[1]= (b1+b0)>>2;\
1037 pixels+=line_size;\
1038 block +=line_size;\
1039 }\
1040}\
1041\
1042static inline void OPNAME ## _pixels4_xy2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
1043{\
1044 int i;\
1045 const uint32_t a= AV_RN32(pixels );\
1046 const uint32_t b= AV_RN32(pixels+1);\
1047 uint32_t l0= (a&0x03030303UL)\
1048 + (b&0x03030303UL)\
1049 + 0x02020202UL;\
1050 uint32_t h0= ((a&0xFCFCFCFCUL)>>2)\
1051 + ((b&0xFCFCFCFCUL)>>2);\
1052 uint32_t l1,h1;\
1053\
1054 pixels+=line_size;\
1055 for(i=0; i<h; i+=2){\
1056 uint32_t a= AV_RN32(pixels );\
1057 uint32_t b= AV_RN32(pixels+1);\
1058 l1= (a&0x03030303UL)\
1059 + (b&0x03030303UL);\
1060 h1= ((a&0xFCFCFCFCUL)>>2)\
1061 + ((b&0xFCFCFCFCUL)>>2);\
1062 OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
1063 pixels+=line_size;\
1064 block +=line_size;\
1065 a= AV_RN32(pixels );\
1066 b= AV_RN32(pixels+1);\
1067 l0= (a&0x03030303UL)\
1068 + (b&0x03030303UL)\
1069 + 0x02020202UL;\
1070 h0= ((a&0xFCFCFCFCUL)>>2)\
1071 + ((b&0xFCFCFCFCUL)>>2);\
1072 OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
1073 pixels+=line_size;\
1074 block +=line_size;\
1075 }\
1076}\
1077\
1078static inline void OPNAME ## _pixels8_xy2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
1079{\
1080 int j;\
1081 for(j=0; j<2; j++){\
1082 int i;\
1083 const uint32_t a= AV_RN32(pixels );\
1084 const uint32_t b= AV_RN32(pixels+1);\
1085 uint32_t l0= (a&0x03030303UL)\
1086 + (b&0x03030303UL)\
1087 + 0x02020202UL;\
1088 uint32_t h0= ((a&0xFCFCFCFCUL)>>2)\
1089 + ((b&0xFCFCFCFCUL)>>2);\
1090 uint32_t l1,h1;\
1091\
1092 pixels+=line_size;\
1093 for(i=0; i<h; i+=2){\
1094 uint32_t a= AV_RN32(pixels );\
1095 uint32_t b= AV_RN32(pixels+1);\
1096 l1= (a&0x03030303UL)\
1097 + (b&0x03030303UL);\
1098 h1= ((a&0xFCFCFCFCUL)>>2)\
1099 + ((b&0xFCFCFCFCUL)>>2);\
1100 OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
1101 pixels+=line_size;\
1102 block +=line_size;\
1103 a= AV_RN32(pixels );\
1104 b= AV_RN32(pixels+1);\
1105 l0= (a&0x03030303UL)\
1106 + (b&0x03030303UL)\
1107 + 0x02020202UL;\
1108 h0= ((a&0xFCFCFCFCUL)>>2)\
1109 + ((b&0xFCFCFCFCUL)>>2);\
1110 OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
1111 pixels+=line_size;\
1112 block +=line_size;\
1113 }\
1114 pixels+=4-line_size*(h+1);\
1115 block +=4-line_size*h;\
1116 }\
1117}\
1118\
1119static inline void OPNAME ## _no_rnd_pixels8_xy2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
1120{\
1121 int j;\
1122 for(j=0; j<2; j++){\
1123 int i;\
1124 const uint32_t a= AV_RN32(pixels );\
1125 const uint32_t b= AV_RN32(pixels+1);\
1126 uint32_t l0= (a&0x03030303UL)\
1127 + (b&0x03030303UL)\
1128 + 0x01010101UL;\
1129 uint32_t h0= ((a&0xFCFCFCFCUL)>>2)\
1130 + ((b&0xFCFCFCFCUL)>>2);\
1131 uint32_t l1,h1;\
1132\
1133 pixels+=line_size;\
1134 for(i=0; i<h; i+=2){\
1135 uint32_t a= AV_RN32(pixels );\
1136 uint32_t b= AV_RN32(pixels+1);\
1137 l1= (a&0x03030303UL)\
1138 + (b&0x03030303UL);\
1139 h1= ((a&0xFCFCFCFCUL)>>2)\
1140 + ((b&0xFCFCFCFCUL)>>2);\
1141 OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
1142 pixels+=line_size;\
1143 block +=line_size;\
1144 a= AV_RN32(pixels );\
1145 b= AV_RN32(pixels+1);\
1146 l0= (a&0x03030303UL)\
1147 + (b&0x03030303UL)\
1148 + 0x01010101UL;\
1149 h0= ((a&0xFCFCFCFCUL)>>2)\
1150 + ((b&0xFCFCFCFCUL)>>2);\
1151 OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
1152 pixels+=line_size;\
1153 block +=line_size;\
1154 }\
1155 pixels+=4-line_size*(h+1);\
1156 block +=4-line_size*h;\
1157 }\
1158}\
1159\
1160CALL_2X_PIXELS(OPNAME ## _pixels16_c , OPNAME ## _pixels8_c , 8)\
1161CALL_2X_PIXELS(OPNAME ## _pixels16_x2_c , OPNAME ## _pixels8_x2_c , 8)\
1162CALL_2X_PIXELS(OPNAME ## _pixels16_y2_c , OPNAME ## _pixels8_y2_c , 8)\
1163CALL_2X_PIXELS(OPNAME ## _pixels16_xy2_c, OPNAME ## _pixels8_xy2_c, 8)\
1164CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_c , OPNAME ## _pixels8_c , 8)\
1165CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_x2_c , OPNAME ## _no_rnd_pixels8_x2_c , 8)\
1166CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_y2_c , OPNAME ## _no_rnd_pixels8_y2_c , 8)\
1167CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_xy2_c, OPNAME ## _no_rnd_pixels8_xy2_c, 8)\
1168
1169#define op_avg(a, b) a = rnd_avg32(a, b)
1170#endif
1171#define op_put(a, b) a = b
1172
1173PIXOP2(avg, op_avg)
1174PIXOP2(put, op_put)
1175#undef op_avg
1176#undef op_put
1177
1178#define avg2(a,b) ((a+b+1)>>1)
1179#define avg4(a,b,c,d) ((a+b+c+d+2)>>2)
1180
1181static void put_no_rnd_pixels16_l2_c(uint8_t *dst, const uint8_t *a, const uint8_t *b, int stride, int h){
1182 put_no_rnd_pixels16_l2(dst, a, b, stride, stride, stride, h);
1183}
1184
1185static void put_no_rnd_pixels8_l2_c(uint8_t *dst, const uint8_t *a, const uint8_t *b, int stride, int h){
1186 put_no_rnd_pixels8_l2(dst, a, b, stride, stride, stride, h);
1187}
1188
1189static void gmc1_c(uint8_t *dst, uint8_t *src, int stride, int h, int x16, int y16, int rounder)
1190{
1191 const int A=(16-x16)*(16-y16);
1192 const int B=( x16)*(16-y16);
1193 const int C=(16-x16)*( y16);
1194 const int D=( x16)*( y16);
1195 int i;
1196
1197 for(i=0; i<h; i++)
1198 {
1199 dst[0]= (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1] + rounder)>>8;
1200 dst[1]= (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2] + rounder)>>8;
1201 dst[2]= (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3] + rounder)>>8;
1202 dst[3]= (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4] + rounder)>>8;
1203 dst[4]= (A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5] + rounder)>>8;
1204 dst[5]= (A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6] + rounder)>>8;
1205 dst[6]= (A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7] + rounder)>>8;
1206 dst[7]= (A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8] + rounder)>>8;
1207 dst+= stride;
1208 src+= stride;
1209 }
1210}
1211
1212void ff_gmc_c(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy,
1213 int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height)
1214{
1215 int y, vx, vy;
1216 const int s= 1<<shift;
1217
1218 width--;
1219 height--;
1220
1221 for(y=0; y<h; y++){
1222 int x;
1223
1224 vx= ox;
1225 vy= oy;
1226 for(x=0; x<8; x++){ //XXX FIXME optimize
1227 int src_x, src_y, frac_x, frac_y, index;
1228
1229 src_x= vx>>16;
1230 src_y= vy>>16;
1231 frac_x= src_x&(s-1);
1232 frac_y= src_y&(s-1);
1233 src_x>>=shift;
1234 src_y>>=shift;
1235
1236 if((unsigned)src_x < width){
1237 if((unsigned)src_y < height){
1238 index= src_x + src_y*stride;
1239 dst[y*stride + x]= ( ( src[index ]*(s-frac_x)
1240 + src[index +1]* frac_x )*(s-frac_y)
1241 + ( src[index+stride ]*(s-frac_x)
1242 + src[index+stride+1]* frac_x )* frac_y
1243 + r)>>(shift*2);
1244 }else{
1245 index= src_x + av_clip(src_y, 0, height)*stride;
1246 dst[y*stride + x]= ( ( src[index ]*(s-frac_x)
1247 + src[index +1]* frac_x )*s
1248 + r)>>(shift*2);
1249 }
1250 }else{
1251 if((unsigned)src_y < height){
1252 index= av_clip(src_x, 0, width) + src_y*stride;
1253 dst[y*stride + x]= ( ( src[index ]*(s-frac_y)
1254 + src[index+stride ]* frac_y )*s
1255 + r)>>(shift*2);
1256 }else{
1257 index= av_clip(src_x, 0, width) + av_clip(src_y, 0, height)*stride;
1258 dst[y*stride + x]= src[index ];
1259 }
1260 }
1261
1262 vx+= dxx;
1263 vy+= dyx;
1264 }
1265 ox += dxy;
1266 oy += dyy;
1267 }
1268}
1269
1270static inline void put_tpel_pixels_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
1271 switch(width){
1272 case 2: put_pixels2_c (dst, src, stride, height); break;
1273 case 4: put_pixels4_c (dst, src, stride, height); break;
1274 case 8: put_pixels8_c (dst, src, stride, height); break;
1275 case 16:put_pixels16_c(dst, src, stride, height); break;
1276 }
1277}
1278
1279static inline void put_tpel_pixels_mc10_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
1280 int i,j;
1281 for (i=0; i < height; i++) {
1282 for (j=0; j < width; j++) {
1283 dst[j] = (683*(2*src[j] + src[j+1] + 1)) >> 11;
1284 }
1285 src += stride;
1286 dst += stride;
1287 }
1288}
1289
1290static inline void put_tpel_pixels_mc20_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
1291 int i,j;
1292 for (i=0; i < height; i++) {
1293 for (j=0; j < width; j++) {
1294 dst[j] = (683*(src[j] + 2*src[j+1] + 1)) >> 11;
1295 }
1296 src += stride;
1297 dst += stride;
1298 }
1299}
1300
1301static inline void put_tpel_pixels_mc01_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
1302 int i,j;
1303 for (i=0; i < height; i++) {
1304 for (j=0; j < width; j++) {
1305 dst[j] = (683*(2*src[j] + src[j+stride] + 1)) >> 11;
1306 }
1307 src += stride;
1308 dst += stride;
1309 }
1310}
1311
1312static inline void put_tpel_pixels_mc11_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
1313 int i,j;
1314 for (i=0; i < height; i++) {
1315 for (j=0; j < width; j++) {
1316 dst[j] = (2731*(4*src[j] + 3*src[j+1] + 3*src[j+stride] + 2*src[j+stride+1] + 6)) >> 15;
1317 }
1318 src += stride;
1319 dst += stride;
1320 }
1321}
1322
1323static inline void put_tpel_pixels_mc12_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
1324 int i,j;
1325 for (i=0; i < height; i++) {
1326 for (j=0; j < width; j++) {
1327 dst[j] = (2731*(3*src[j] + 2*src[j+1] + 4*src[j+stride] + 3*src[j+stride+1] + 6)) >> 15;
1328 }
1329 src += stride;
1330 dst += stride;
1331 }
1332}
1333
1334static inline void put_tpel_pixels_mc02_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
1335 int i,j;
1336 for (i=0; i < height; i++) {
1337 for (j=0; j < width; j++) {
1338 dst[j] = (683*(src[j] + 2*src[j+stride] + 1)) >> 11;
1339 }
1340 src += stride;
1341 dst += stride;
1342 }
1343}
1344
1345static inline void put_tpel_pixels_mc21_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
1346 int i,j;
1347 for (i=0; i < height; i++) {
1348 for (j=0; j < width; j++) {
1349 dst[j] = (2731*(3*src[j] + 4*src[j+1] + 2*src[j+stride] + 3*src[j+stride+1] + 6)) >> 15;
1350 }
1351 src += stride;
1352 dst += stride;
1353 }
1354}
1355
1356static inline void put_tpel_pixels_mc22_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
1357 int i,j;
1358 for (i=0; i < height; i++) {
1359 for (j=0; j < width; j++) {
1360 dst[j] = (2731*(2*src[j] + 3*src[j+1] + 3*src[j+stride] + 4*src[j+stride+1] + 6)) >> 15;
1361 }
1362 src += stride;
1363 dst += stride;
1364 }
1365}
1366
1367static inline void avg_tpel_pixels_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
1368 switch(width){
1369 case 2: avg_pixels2_c (dst, src, stride, height); break;
1370 case 4: avg_pixels4_c (dst, src, stride, height); break;
1371 case 8: avg_pixels8_c (dst, src, stride, height); break;
1372 case 16:avg_pixels16_c(dst, src, stride, height); break;
1373 }
1374}
1375
1376static inline void avg_tpel_pixels_mc10_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
1377 int i,j;
1378 for (i=0; i < height; i++) {
1379 for (j=0; j < width; j++) {
1380 dst[j] = (dst[j] + ((683*(2*src[j] + src[j+1] + 1)) >> 11) + 1) >> 1;
1381 }
1382 src += stride;
1383 dst += stride;
1384 }
1385}
1386
1387static inline void avg_tpel_pixels_mc20_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
1388 int i,j;
1389 for (i=0; i < height; i++) {
1390 for (j=0; j < width; j++) {
1391 dst[j] = (dst[j] + ((683*(src[j] + 2*src[j+1] + 1)) >> 11) + 1) >> 1;
1392 }
1393 src += stride;
1394 dst += stride;
1395 }
1396}
1397
1398static inline void avg_tpel_pixels_mc01_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
1399 int i,j;
1400 for (i=0; i < height; i++) {
1401 for (j=0; j < width; j++) {
1402 dst[j] = (dst[j] + ((683*(2*src[j] + src[j+stride] + 1)) >> 11) + 1) >> 1;
1403 }
1404 src += stride;
1405 dst += stride;
1406 }
1407}
1408
1409static inline void avg_tpel_pixels_mc11_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
1410 int i,j;
1411 for (i=0; i < height; i++) {
1412 for (j=0; j < width; j++) {
1413 dst[j] = (dst[j] + ((2731*(4*src[j] + 3*src[j+1] + 3*src[j+stride] + 2*src[j+stride+1] + 6)) >> 15) + 1) >> 1;
1414 }
1415 src += stride;
1416 dst += stride;
1417 }
1418}
1419
1420static inline void avg_tpel_pixels_mc12_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
1421 int i,j;
1422 for (i=0; i < height; i++) {
1423 for (j=0; j < width; j++) {
1424 dst[j] = (dst[j] + ((2731*(3*src[j] + 2*src[j+1] + 4*src[j+stride] + 3*src[j+stride+1] + 6)) >> 15) + 1) >> 1;
1425 }
1426 src += stride;
1427 dst += stride;
1428 }
1429}
1430
1431static inline void avg_tpel_pixels_mc02_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
1432 int i,j;
1433 for (i=0; i < height; i++) {
1434 for (j=0; j < width; j++) {
1435 dst[j] = (dst[j] + ((683*(src[j] + 2*src[j+stride] + 1)) >> 11) + 1) >> 1;
1436 }
1437 src += stride;
1438 dst += stride;
1439 }
1440}
1441
1442static inline void avg_tpel_pixels_mc21_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
1443 int i,j;
1444 for (i=0; i < height; i++) {
1445 for (j=0; j < width; j++) {
1446 dst[j] = (dst[j] + ((2731*(3*src[j] + 4*src[j+1] + 2*src[j+stride] + 3*src[j+stride+1] + 6)) >> 15) + 1) >> 1;
1447 }
1448 src += stride;
1449 dst += stride;
1450 }
1451}
1452
1453static inline void avg_tpel_pixels_mc22_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
1454 int i,j;
1455 for (i=0; i < height; i++) {
1456 for (j=0; j < width; j++) {
1457 dst[j] = (dst[j] + ((2731*(2*src[j] + 3*src[j+1] + 3*src[j+stride] + 4*src[j+stride+1] + 6)) >> 15) + 1) >> 1;
1458 }
1459 src += stride;
1460 dst += stride;
1461 }
1462}
1463#if 0
1464#define TPEL_WIDTH(width)\
1465static void put_tpel_pixels ## width ## _mc00_c(uint8_t *dst, const uint8_t *src, int stride, int height){\
1466 void put_tpel_pixels_mc00_c(dst, src, stride, width, height);}\
1467static void put_tpel_pixels ## width ## _mc10_c(uint8_t *dst, const uint8_t *src, int stride, int height){\
1468 void put_tpel_pixels_mc10_c(dst, src, stride, width, height);}\
1469static void put_tpel_pixels ## width ## _mc20_c(uint8_t *dst, const uint8_t *src, int stride, int height){\
1470 void put_tpel_pixels_mc20_c(dst, src, stride, width, height);}\
1471static void put_tpel_pixels ## width ## _mc01_c(uint8_t *dst, const uint8_t *src, int stride, int height){\
1472 void put_tpel_pixels_mc01_c(dst, src, stride, width, height);}\
1473static void put_tpel_pixels ## width ## _mc11_c(uint8_t *dst, const uint8_t *src, int stride, int height){\
1474 void put_tpel_pixels_mc11_c(dst, src, stride, width, height);}\
1475static void put_tpel_pixels ## width ## _mc21_c(uint8_t *dst, const uint8_t *src, int stride, int height){\
1476 void put_tpel_pixels_mc21_c(dst, src, stride, width, height);}\
1477static void put_tpel_pixels ## width ## _mc02_c(uint8_t *dst, const uint8_t *src, int stride, int height){\
1478 void put_tpel_pixels_mc02_c(dst, src, stride, width, height);}\
1479static void put_tpel_pixels ## width ## _mc12_c(uint8_t *dst, const uint8_t *src, int stride, int height){\
1480 void put_tpel_pixels_mc12_c(dst, src, stride, width, height);}\
1481static void put_tpel_pixels ## width ## _mc22_c(uint8_t *dst, const uint8_t *src, int stride, int height){\
1482 void put_tpel_pixels_mc22_c(dst, src, stride, width, height);}
1483#endif
1484
1485#define H264_CHROMA_MC(OPNAME, OP)\
1486static void OPNAME ## h264_chroma_mc2_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){\
1487 const int A=(8-x)*(8-y);\
1488 const int B=( x)*(8-y);\
1489 const int C=(8-x)*( y);\
1490 const int D=( x)*( y);\
1491 int i;\
1492 \
1493 assert(x<8 && y<8 && x>=0 && y>=0);\
1494\
1495 if(D){\
1496 for(i=0; i<h; i++){\
1497 OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
1498 OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
1499 dst+= stride;\
1500 src+= stride;\
1501 }\
1502 }else{\
1503 const int E= B+C;\
1504 const int step= C ? stride : 1;\
1505 for(i=0; i<h; i++){\
1506 OP(dst[0], (A*src[0] + E*src[step+0]));\
1507 OP(dst[1], (A*src[1] + E*src[step+1]));\
1508 dst+= stride;\
1509 src+= stride;\
1510 }\
1511 }\
1512}\
1513\
1514static void OPNAME ## h264_chroma_mc4_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){\
1515 const int A=(8-x)*(8-y);\
1516 const int B=( x)*(8-y);\
1517 const int C=(8-x)*( y);\
1518 const int D=( x)*( y);\
1519 int i;\
1520 \
1521 assert(x<8 && y<8 && x>=0 && y>=0);\
1522\
1523 if(D){\
1524 for(i=0; i<h; i++){\
1525 OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
1526 OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
1527 OP(dst[2], (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3]));\
1528 OP(dst[3], (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4]));\
1529 dst+= stride;\
1530 src+= stride;\
1531 }\
1532 }else{\
1533 const int E= B+C;\
1534 const int step= C ? stride : 1;\
1535 for(i=0; i<h; i++){\
1536 OP(dst[0], (A*src[0] + E*src[step+0]));\
1537 OP(dst[1], (A*src[1] + E*src[step+1]));\
1538 OP(dst[2], (A*src[2] + E*src[step+2]));\
1539 OP(dst[3], (A*src[3] + E*src[step+3]));\
1540 dst+= stride;\
1541 src+= stride;\
1542 }\
1543 }\
1544}\
1545\
1546static void OPNAME ## h264_chroma_mc8_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){\
1547 const int A=(8-x)*(8-y);\
1548 const int B=( x)*(8-y);\
1549 const int C=(8-x)*( y);\
1550 const int D=( x)*( y);\
1551 int i;\
1552 \
1553 assert(x<8 && y<8 && x>=0 && y>=0);\
1554\
1555 if(D){\
1556 for(i=0; i<h; i++){\
1557 OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
1558 OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
1559 OP(dst[2], (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3]));\
1560 OP(dst[3], (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4]));\
1561 OP(dst[4], (A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5]));\
1562 OP(dst[5], (A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6]));\
1563 OP(dst[6], (A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7]));\
1564 OP(dst[7], (A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8]));\
1565 dst+= stride;\
1566 src+= stride;\
1567 }\
1568 }else{\
1569 const int E= B+C;\
1570 const int step= C ? stride : 1;\
1571 for(i=0; i<h; i++){\
1572 OP(dst[0], (A*src[0] + E*src[step+0]));\
1573 OP(dst[1], (A*src[1] + E*src[step+1]));\
1574 OP(dst[2], (A*src[2] + E*src[step+2]));\
1575 OP(dst[3], (A*src[3] + E*src[step+3]));\
1576 OP(dst[4], (A*src[4] + E*src[step+4]));\
1577 OP(dst[5], (A*src[5] + E*src[step+5]));\
1578 OP(dst[6], (A*src[6] + E*src[step+6]));\
1579 OP(dst[7], (A*src[7] + E*src[step+7]));\
1580 dst+= stride;\
1581 src+= stride;\
1582 }\
1583 }\
1584}
1585
1586#define op_avg(a, b) a = (((a)+(((b) + 32)>>6)+1)>>1)
1587#define op_put(a, b) a = (((b) + 32)>>6)
1588
1589H264_CHROMA_MC(put_ , op_put)
1590H264_CHROMA_MC(avg_ , op_avg)
1591#undef op_avg
1592#undef op_put
1593
1594static void put_no_rnd_vc1_chroma_mc8_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){
1595 const int A=(8-x)*(8-y);
1596 const int B=( x)*(8-y);
1597 const int C=(8-x)*( y);
1598 const int D=( x)*( y);
1599 int i;
1600
1601 assert(x<8 && y<8 && x>=0 && y>=0);
1602
1603 for(i=0; i<h; i++)
1604 {
1605 dst[0] = (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1] + 32 - 4) >> 6;
1606 dst[1] = (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2] + 32 - 4) >> 6;
1607 dst[2] = (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3] + 32 - 4) >> 6;
1608 dst[3] = (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4] + 32 - 4) >> 6;
1609 dst[4] = (A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5] + 32 - 4) >> 6;
1610 dst[5] = (A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6] + 32 - 4) >> 6;
1611 dst[6] = (A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7] + 32 - 4) >> 6;
1612 dst[7] = (A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8] + 32 - 4) >> 6;
1613 dst+= stride;
1614 src+= stride;
1615 }
1616}
1617
1618static void avg_no_rnd_vc1_chroma_mc8_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){
1619 const int A=(8-x)*(8-y);
1620 const int B=( x)*(8-y);
1621 const int C=(8-x)*( y);
1622 const int D=( x)*( y);
1623 int i;
1624
1625 assert(x<8 && y<8 && x>=0 && y>=0);
1626
1627 for(i=0; i<h; i++)
1628 {
1629 dst[0] = avg2(dst[0], ((A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1] + 32 - 4) >> 6));
1630 dst[1] = avg2(dst[1], ((A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2] + 32 - 4) >> 6));
1631 dst[2] = avg2(dst[2], ((A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3] + 32 - 4) >> 6));
1632 dst[3] = avg2(dst[3], ((A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4] + 32 - 4) >> 6));
1633 dst[4] = avg2(dst[4], ((A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5] + 32 - 4) >> 6));
1634 dst[5] = avg2(dst[5], ((A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6] + 32 - 4) >> 6));
1635 dst[6] = avg2(dst[6], ((A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7] + 32 - 4) >> 6));
1636 dst[7] = avg2(dst[7], ((A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8] + 32 - 4) >> 6));
1637 dst+= stride;
1638 src+= stride;
1639 }
1640}
1641
1642#define QPEL_MC(r, OPNAME, RND, OP) \
1643static void OPNAME ## mpeg4_qpel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
1644 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
1645 int i;\
1646 for(i=0; i<h; i++)\
1647 {\
1648 OP(dst[0], (src[0]+src[1])*20 - (src[0]+src[2])*6 + (src[1]+src[3])*3 - (src[2]+src[4]));\
1649 OP(dst[1], (src[1]+src[2])*20 - (src[0]+src[3])*6 + (src[0]+src[4])*3 - (src[1]+src[5]));\
1650 OP(dst[2], (src[2]+src[3])*20 - (src[1]+src[4])*6 + (src[0]+src[5])*3 - (src[0]+src[6]));\
1651 OP(dst[3], (src[3]+src[4])*20 - (src[2]+src[5])*6 + (src[1]+src[6])*3 - (src[0]+src[7]));\
1652 OP(dst[4], (src[4]+src[5])*20 - (src[3]+src[6])*6 + (src[2]+src[7])*3 - (src[1]+src[8]));\
1653 OP(dst[5], (src[5]+src[6])*20 - (src[4]+src[7])*6 + (src[3]+src[8])*3 - (src[2]+src[8]));\
1654 OP(dst[6], (src[6]+src[7])*20 - (src[5]+src[8])*6 + (src[4]+src[8])*3 - (src[3]+src[7]));\
1655 OP(dst[7], (src[7]+src[8])*20 - (src[6]+src[8])*6 + (src[5]+src[7])*3 - (src[4]+src[6]));\
1656 dst+=dstStride;\
1657 src+=srcStride;\
1658 }\
1659}\
1660\
1661static void OPNAME ## mpeg4_qpel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
1662 const int w=8;\
1663 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
1664 int i;\
1665 for(i=0; i<w; i++)\
1666 {\
1667 const int src0= src[0*srcStride];\
1668 const int src1= src[1*srcStride];\
1669 const int src2= src[2*srcStride];\
1670 const int src3= src[3*srcStride];\
1671 const int src4= src[4*srcStride];\
1672 const int src5= src[5*srcStride];\
1673 const int src6= src[6*srcStride];\
1674 const int src7= src[7*srcStride];\
1675 const int src8= src[8*srcStride];\
1676 OP(dst[0*dstStride], (src0+src1)*20 - (src0+src2)*6 + (src1+src3)*3 - (src2+src4));\
1677 OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*6 + (src0+src4)*3 - (src1+src5));\
1678 OP(dst[2*dstStride], (src2+src3)*20 - (src1+src4)*6 + (src0+src5)*3 - (src0+src6));\
1679 OP(dst[3*dstStride], (src3+src4)*20 - (src2+src5)*6 + (src1+src6)*3 - (src0+src7));\
1680 OP(dst[4*dstStride], (src4+src5)*20 - (src3+src6)*6 + (src2+src7)*3 - (src1+src8));\
1681 OP(dst[5*dstStride], (src5+src6)*20 - (src4+src7)*6 + (src3+src8)*3 - (src2+src8));\
1682 OP(dst[6*dstStride], (src6+src7)*20 - (src5+src8)*6 + (src4+src8)*3 - (src3+src7));\
1683 OP(dst[7*dstStride], (src7+src8)*20 - (src6+src8)*6 + (src5+src7)*3 - (src4+src6));\
1684 dst++;\
1685 src++;\
1686 }\
1687}\
1688\
1689static void OPNAME ## mpeg4_qpel16_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
1690 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
1691 int i;\
1692 \
1693 for(i=0; i<h; i++)\
1694 {\
1695 OP(dst[ 0], (src[ 0]+src[ 1])*20 - (src[ 0]+src[ 2])*6 + (src[ 1]+src[ 3])*3 - (src[ 2]+src[ 4]));\
1696 OP(dst[ 1], (src[ 1]+src[ 2])*20 - (src[ 0]+src[ 3])*6 + (src[ 0]+src[ 4])*3 - (src[ 1]+src[ 5]));\
1697 OP(dst[ 2], (src[ 2]+src[ 3])*20 - (src[ 1]+src[ 4])*6 + (src[ 0]+src[ 5])*3 - (src[ 0]+src[ 6]));\
1698 OP(dst[ 3], (src[ 3]+src[ 4])*20 - (src[ 2]+src[ 5])*6 + (src[ 1]+src[ 6])*3 - (src[ 0]+src[ 7]));\
1699 OP(dst[ 4], (src[ 4]+src[ 5])*20 - (src[ 3]+src[ 6])*6 + (src[ 2]+src[ 7])*3 - (src[ 1]+src[ 8]));\
1700 OP(dst[ 5], (src[ 5]+src[ 6])*20 - (src[ 4]+src[ 7])*6 + (src[ 3]+src[ 8])*3 - (src[ 2]+src[ 9]));\
1701 OP(dst[ 6], (src[ 6]+src[ 7])*20 - (src[ 5]+src[ 8])*6 + (src[ 4]+src[ 9])*3 - (src[ 3]+src[10]));\
1702 OP(dst[ 7], (src[ 7]+src[ 8])*20 - (src[ 6]+src[ 9])*6 + (src[ 5]+src[10])*3 - (src[ 4]+src[11]));\
1703 OP(dst[ 8], (src[ 8]+src[ 9])*20 - (src[ 7]+src[10])*6 + (src[ 6]+src[11])*3 - (src[ 5]+src[12]));\
1704 OP(dst[ 9], (src[ 9]+src[10])*20 - (src[ 8]+src[11])*6 + (src[ 7]+src[12])*3 - (src[ 6]+src[13]));\
1705 OP(dst[10], (src[10]+src[11])*20 - (src[ 9]+src[12])*6 + (src[ 8]+src[13])*3 - (src[ 7]+src[14]));\
1706 OP(dst[11], (src[11]+src[12])*20 - (src[10]+src[13])*6 + (src[ 9]+src[14])*3 - (src[ 8]+src[15]));\
1707 OP(dst[12], (src[12]+src[13])*20 - (src[11]+src[14])*6 + (src[10]+src[15])*3 - (src[ 9]+src[16]));\
1708 OP(dst[13], (src[13]+src[14])*20 - (src[12]+src[15])*6 + (src[11]+src[16])*3 - (src[10]+src[16]));\
1709 OP(dst[14], (src[14]+src[15])*20 - (src[13]+src[16])*6 + (src[12]+src[16])*3 - (src[11]+src[15]));\
1710 OP(dst[15], (src[15]+src[16])*20 - (src[14]+src[16])*6 + (src[13]+src[15])*3 - (src[12]+src[14]));\
1711 dst+=dstStride;\
1712 src+=srcStride;\
1713 }\
1714}\
1715\
1716static void OPNAME ## mpeg4_qpel16_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
1717 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
1718 int i;\
1719 const int w=16;\
1720 for(i=0; i<w; i++)\
1721 {\
1722 const int src0= src[0*srcStride];\
1723 const int src1= src[1*srcStride];\
1724 const int src2= src[2*srcStride];\
1725 const int src3= src[3*srcStride];\
1726 const int src4= src[4*srcStride];\
1727 const int src5= src[5*srcStride];\
1728 const int src6= src[6*srcStride];\
1729 const int src7= src[7*srcStride];\
1730 const int src8= src[8*srcStride];\
1731 const int src9= src[9*srcStride];\
1732 const int src10= src[10*srcStride];\
1733 const int src11= src[11*srcStride];\
1734 const int src12= src[12*srcStride];\
1735 const int src13= src[13*srcStride];\
1736 const int src14= src[14*srcStride];\
1737 const int src15= src[15*srcStride];\
1738 const int src16= src[16*srcStride];\
1739 OP(dst[ 0*dstStride], (src0 +src1 )*20 - (src0 +src2 )*6 + (src1 +src3 )*3 - (src2 +src4 ));\
1740 OP(dst[ 1*dstStride], (src1 +src2 )*20 - (src0 +src3 )*6 + (src0 +src4 )*3 - (src1 +src5 ));\
1741 OP(dst[ 2*dstStride], (src2 +src3 )*20 - (src1 +src4 )*6 + (src0 +src5 )*3 - (src0 +src6 ));\
1742 OP(dst[ 3*dstStride], (src3 +src4 )*20 - (src2 +src5 )*6 + (src1 +src6 )*3 - (src0 +src7 ));\
1743 OP(dst[ 4*dstStride], (src4 +src5 )*20 - (src3 +src6 )*6 + (src2 +src7 )*3 - (src1 +src8 ));\
1744 OP(dst[ 5*dstStride], (src5 +src6 )*20 - (src4 +src7 )*6 + (src3 +src8 )*3 - (src2 +src9 ));\
1745 OP(dst[ 6*dstStride], (src6 +src7 )*20 - (src5 +src8 )*6 + (src4 +src9 )*3 - (src3 +src10));\
1746 OP(dst[ 7*dstStride], (src7 +src8 )*20 - (src6 +src9 )*6 + (src5 +src10)*3 - (src4 +src11));\
1747 OP(dst[ 8*dstStride], (src8 +src9 )*20 - (src7 +src10)*6 + (src6 +src11)*3 - (src5 +src12));\
1748 OP(dst[ 9*dstStride], (src9 +src10)*20 - (src8 +src11)*6 + (src7 +src12)*3 - (src6 +src13));\
1749 OP(dst[10*dstStride], (src10+src11)*20 - (src9 +src12)*6 + (src8 +src13)*3 - (src7 +src14));\
1750 OP(dst[11*dstStride], (src11+src12)*20 - (src10+src13)*6 + (src9 +src14)*3 - (src8 +src15));\
1751 OP(dst[12*dstStride], (src12+src13)*20 - (src11+src14)*6 + (src10+src15)*3 - (src9 +src16));\
1752 OP(dst[13*dstStride], (src13+src14)*20 - (src12+src15)*6 + (src11+src16)*3 - (src10+src16));\
1753 OP(dst[14*dstStride], (src14+src15)*20 - (src13+src16)*6 + (src12+src16)*3 - (src11+src15));\
1754 OP(dst[15*dstStride], (src15+src16)*20 - (src14+src16)*6 + (src13+src15)*3 - (src12+src14));\
1755 dst++;\
1756 src++;\
1757 }\
1758}\
1759\
1760static void OPNAME ## qpel8_mc00_c (uint8_t *dst, uint8_t *src, int stride){\
1761 OPNAME ## pixels8_c(dst, src, stride, 8);\
1762}\
1763\
1764static void OPNAME ## qpel8_mc10_c(uint8_t *dst, uint8_t *src, int stride){\
1765 uint8_t half[64];\
1766 put ## RND ## mpeg4_qpel8_h_lowpass(half, src, 8, stride, 8);\
1767 OPNAME ## pixels8_l2(dst, src, half, stride, stride, 8, 8);\
1768}\
1769\
1770static void OPNAME ## qpel8_mc20_c(uint8_t *dst, uint8_t *src, int stride){\
1771 OPNAME ## mpeg4_qpel8_h_lowpass(dst, src, stride, stride, 8);\
1772}\
1773\
1774static void OPNAME ## qpel8_mc30_c(uint8_t *dst, uint8_t *src, int stride){\
1775 uint8_t half[64];\
1776 put ## RND ## mpeg4_qpel8_h_lowpass(half, src, 8, stride, 8);\
1777 OPNAME ## pixels8_l2(dst, src+1, half, stride, stride, 8, 8);\
1778}\
1779\
1780static void OPNAME ## qpel8_mc01_c(uint8_t *dst, uint8_t *src, int stride){\
1781 uint8_t full[16*9];\
1782 uint8_t half[64];\
1783 copy_block9(full, src, 16, stride, 9);\
1784 put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16);\
1785 OPNAME ## pixels8_l2(dst, full, half, stride, 16, 8, 8);\
1786}\
1787\
1788static void OPNAME ## qpel8_mc02_c(uint8_t *dst, uint8_t *src, int stride){\
1789 uint8_t full[16*9];\
1790 copy_block9(full, src, 16, stride, 9);\
1791 OPNAME ## mpeg4_qpel8_v_lowpass(dst, full, stride, 16);\
1792}\
1793\
1794static void OPNAME ## qpel8_mc03_c(uint8_t *dst, uint8_t *src, int stride){\
1795 uint8_t full[16*9];\
1796 uint8_t half[64];\
1797 copy_block9(full, src, 16, stride, 9);\
1798 put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16);\
1799 OPNAME ## pixels8_l2(dst, full+16, half, stride, 16, 8, 8);\
1800}\
1801void ff_ ## OPNAME ## qpel8_mc11_old_c(uint8_t *dst, uint8_t *src, int stride){\
1802 uint8_t full[16*9];\
1803 uint8_t halfH[72];\
1804 uint8_t halfV[64];\
1805 uint8_t halfHV[64];\
1806 copy_block9(full, src, 16, stride, 9);\
1807 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
1808 put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16);\
1809 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
1810 OPNAME ## pixels8_l4(dst, full, halfH, halfV, halfHV, stride, 16, 8, 8, 8, 8);\
1811}\
1812static void OPNAME ## qpel8_mc11_c(uint8_t *dst, uint8_t *src, int stride){\
1813 uint8_t full[16*9];\
1814 uint8_t halfH[72];\
1815 uint8_t halfHV[64];\
1816 copy_block9(full, src, 16, stride, 9);\
1817 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
1818 put ## RND ## pixels8_l2(halfH, halfH, full, 8, 8, 16, 9);\
1819 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
1820 OPNAME ## pixels8_l2(dst, halfH, halfHV, stride, 8, 8, 8);\
1821}\
1822void ff_ ## OPNAME ## qpel8_mc31_old_c(uint8_t *dst, uint8_t *src, int stride){\
1823 uint8_t full[16*9];\
1824 uint8_t halfH[72];\
1825 uint8_t halfV[64];\
1826 uint8_t halfHV[64];\
1827 copy_block9(full, src, 16, stride, 9);\
1828 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
1829 put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full+1, 8, 16);\
1830 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
1831 OPNAME ## pixels8_l4(dst, full+1, halfH, halfV, halfHV, stride, 16, 8, 8, 8, 8);\
1832}\
1833static void OPNAME ## qpel8_mc31_c(uint8_t *dst, uint8_t *src, int stride){\
1834 uint8_t full[16*9];\
1835 uint8_t halfH[72];\
1836 uint8_t halfHV[64];\
1837 copy_block9(full, src, 16, stride, 9);\
1838 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
1839 put ## RND ## pixels8_l2(halfH, halfH, full+1, 8, 8, 16, 9);\
1840 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
1841 OPNAME ## pixels8_l2(dst, halfH, halfHV, stride, 8, 8, 8);\
1842}\
1843void ff_ ## OPNAME ## qpel8_mc13_old_c(uint8_t *dst, uint8_t *src, int stride){\
1844 uint8_t full[16*9];\
1845 uint8_t halfH[72];\
1846 uint8_t halfV[64];\
1847 uint8_t halfHV[64];\
1848 copy_block9(full, src, 16, stride, 9);\
1849 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
1850 put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16);\
1851 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
1852 OPNAME ## pixels8_l4(dst, full+16, halfH+8, halfV, halfHV, stride, 16, 8, 8, 8, 8);\
1853}\
1854static void OPNAME ## qpel8_mc13_c(uint8_t *dst, uint8_t *src, int stride){\
1855 uint8_t full[16*9];\
1856 uint8_t halfH[72];\
1857 uint8_t halfHV[64];\
1858 copy_block9(full, src, 16, stride, 9);\
1859 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
1860 put ## RND ## pixels8_l2(halfH, halfH, full, 8, 8, 16, 9);\
1861 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
1862 OPNAME ## pixels8_l2(dst, halfH+8, halfHV, stride, 8, 8, 8);\
1863}\
1864void ff_ ## OPNAME ## qpel8_mc33_old_c(uint8_t *dst, uint8_t *src, int stride){\
1865 uint8_t full[16*9];\
1866 uint8_t halfH[72];\
1867 uint8_t halfV[64];\
1868 uint8_t halfHV[64];\
1869 copy_block9(full, src, 16, stride, 9);\
1870 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full , 8, 16, 9);\
1871 put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full+1, 8, 16);\
1872 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
1873 OPNAME ## pixels8_l4(dst, full+17, halfH+8, halfV, halfHV, stride, 16, 8, 8, 8, 8);\
1874}\
1875static void OPNAME ## qpel8_mc33_c(uint8_t *dst, uint8_t *src, int stride){\
1876 uint8_t full[16*9];\
1877 uint8_t halfH[72];\
1878 uint8_t halfHV[64];\
1879 copy_block9(full, src, 16, stride, 9);\
1880 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
1881 put ## RND ## pixels8_l2(halfH, halfH, full+1, 8, 8, 16, 9);\
1882 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
1883 OPNAME ## pixels8_l2(dst, halfH+8, halfHV, stride, 8, 8, 8);\
1884}\
1885static void OPNAME ## qpel8_mc21_c(uint8_t *dst, uint8_t *src, int stride){\
1886 uint8_t halfH[72];\
1887 uint8_t halfHV[64];\
1888 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);\
1889 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
1890 OPNAME ## pixels8_l2(dst, halfH, halfHV, stride, 8, 8, 8);\
1891}\
1892static void OPNAME ## qpel8_mc23_c(uint8_t *dst, uint8_t *src, int stride){\
1893 uint8_t halfH[72];\
1894 uint8_t halfHV[64];\
1895 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);\
1896 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
1897 OPNAME ## pixels8_l2(dst, halfH+8, halfHV, stride, 8, 8, 8);\
1898}\
1899void ff_ ## OPNAME ## qpel8_mc12_old_c(uint8_t *dst, uint8_t *src, int stride){\
1900 uint8_t full[16*9];\
1901 uint8_t halfH[72];\
1902 uint8_t halfV[64];\
1903 uint8_t halfHV[64];\
1904 copy_block9(full, src, 16, stride, 9);\
1905 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
1906 put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16);\
1907 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
1908 OPNAME ## pixels8_l2(dst, halfV, halfHV, stride, 8, 8, 8);\
1909}\
1910static void OPNAME ## qpel8_mc12_c(uint8_t *dst, uint8_t *src, int stride){\
1911 uint8_t full[16*9];\
1912 uint8_t halfH[72];\
1913 copy_block9(full, src, 16, stride, 9);\
1914 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
1915 put ## RND ## pixels8_l2(halfH, halfH, full, 8, 8, 16, 9);\
1916 OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8);\
1917}\
1918void ff_ ## OPNAME ## qpel8_mc32_old_c(uint8_t *dst, uint8_t *src, int stride){\
1919 uint8_t full[16*9];\
1920 uint8_t halfH[72];\
1921 uint8_t halfV[64];\
1922 uint8_t halfHV[64];\
1923 copy_block9(full, src, 16, stride, 9);\
1924 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
1925 put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full+1, 8, 16);\
1926 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
1927 OPNAME ## pixels8_l2(dst, halfV, halfHV, stride, 8, 8, 8);\
1928}\
1929static void OPNAME ## qpel8_mc32_c(uint8_t *dst, uint8_t *src, int stride){\
1930 uint8_t full[16*9];\
1931 uint8_t halfH[72];\
1932 copy_block9(full, src, 16, stride, 9);\
1933 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
1934 put ## RND ## pixels8_l2(halfH, halfH, full+1, 8, 8, 16, 9);\
1935 OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8);\
1936}\
1937static void OPNAME ## qpel8_mc22_c(uint8_t *dst, uint8_t *src, int stride){\
1938 uint8_t halfH[72];\
1939 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);\
1940 OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8);\
1941}\
1942static void OPNAME ## qpel16_mc00_c (uint8_t *dst, uint8_t *src, int stride){\
1943 OPNAME ## pixels16_c(dst, src, stride, 16);\
1944}\
1945\
1946static void OPNAME ## qpel16_mc10_c(uint8_t *dst, uint8_t *src, int stride){\
1947 uint8_t half[256];\
1948 put ## RND ## mpeg4_qpel16_h_lowpass(half, src, 16, stride, 16);\
1949 OPNAME ## pixels16_l2(dst, src, half, stride, stride, 16, 16);\
1950}\
1951\
1952static void OPNAME ## qpel16_mc20_c(uint8_t *dst, uint8_t *src, int stride){\
1953 OPNAME ## mpeg4_qpel16_h_lowpass(dst, src, stride, stride, 16);\
1954}\
1955\
1956static void OPNAME ## qpel16_mc30_c(uint8_t *dst, uint8_t *src, int stride){\
1957 uint8_t half[256];\
1958 put ## RND ## mpeg4_qpel16_h_lowpass(half, src, 16, stride, 16);\
1959 OPNAME ## pixels16_l2(dst, src+1, half, stride, stride, 16, 16);\
1960}\
1961\
1962static void OPNAME ## qpel16_mc01_c(uint8_t *dst, uint8_t *src, int stride){\
1963 uint8_t full[24*17];\
1964 uint8_t half[256];\
1965 copy_block17(full, src, 24, stride, 17);\
1966 put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24);\
1967 OPNAME ## pixels16_l2(dst, full, half, stride, 24, 16, 16);\
1968}\
1969\
1970static void OPNAME ## qpel16_mc02_c(uint8_t *dst, uint8_t *src, int stride){\
1971 uint8_t full[24*17];\
1972 copy_block17(full, src, 24, stride, 17);\
1973 OPNAME ## mpeg4_qpel16_v_lowpass(dst, full, stride, 24);\
1974}\
1975\
1976static void OPNAME ## qpel16_mc03_c(uint8_t *dst, uint8_t *src, int stride){\
1977 uint8_t full[24*17];\
1978 uint8_t half[256];\
1979 copy_block17(full, src, 24, stride, 17);\
1980 put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24);\
1981 OPNAME ## pixels16_l2(dst, full+24, half, stride, 24, 16, 16);\
1982}\
1983void ff_ ## OPNAME ## qpel16_mc11_old_c(uint8_t *dst, uint8_t *src, int stride){\
1984 uint8_t full[24*17];\
1985 uint8_t halfH[272];\
1986 uint8_t halfV[256];\
1987 uint8_t halfHV[256];\
1988 copy_block17(full, src, 24, stride, 17);\
1989 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
1990 put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24);\
1991 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
1992 OPNAME ## pixels16_l4(dst, full, halfH, halfV, halfHV, stride, 24, 16, 16, 16, 16);\
1993}\
1994static void OPNAME ## qpel16_mc11_c(uint8_t *dst, uint8_t *src, int stride){\
1995 uint8_t full[24*17];\
1996 uint8_t halfH[272];\
1997 uint8_t halfHV[256];\
1998 copy_block17(full, src, 24, stride, 17);\
1999 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
2000 put ## RND ## pixels16_l2(halfH, halfH, full, 16, 16, 24, 17);\
2001 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
2002 OPNAME ## pixels16_l2(dst, halfH, halfHV, stride, 16, 16, 16);\
2003}\
2004void ff_ ## OPNAME ## qpel16_mc31_old_c(uint8_t *dst, uint8_t *src, int stride){\
2005 uint8_t full[24*17];\
2006 uint8_t halfH[272];\
2007 uint8_t halfV[256];\
2008 uint8_t halfHV[256];\
2009 copy_block17(full, src, 24, stride, 17);\
2010 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
2011 put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full+1, 16, 24);\
2012 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
2013 OPNAME ## pixels16_l4(dst, full+1, halfH, halfV, halfHV, stride, 24, 16, 16, 16, 16);\
2014}\
2015static void OPNAME ## qpel16_mc31_c(uint8_t *dst, uint8_t *src, int stride){\
2016 uint8_t full[24*17];\
2017 uint8_t halfH[272];\
2018 uint8_t halfHV[256];\
2019 copy_block17(full, src, 24, stride, 17);\
2020 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
2021 put ## RND ## pixels16_l2(halfH, halfH, full+1, 16, 16, 24, 17);\
2022 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
2023 OPNAME ## pixels16_l2(dst, halfH, halfHV, stride, 16, 16, 16);\
2024}\
2025void ff_ ## OPNAME ## qpel16_mc13_old_c(uint8_t *dst, uint8_t *src, int stride){\
2026 uint8_t full[24*17];\
2027 uint8_t halfH[272];\
2028 uint8_t halfV[256];\
2029 uint8_t halfHV[256];\
2030 copy_block17(full, src, 24, stride, 17);\
2031 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
2032 put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24);\
2033 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
2034 OPNAME ## pixels16_l4(dst, full+24, halfH+16, halfV, halfHV, stride, 24, 16, 16, 16, 16);\
2035}\
2036static void OPNAME ## qpel16_mc13_c(uint8_t *dst, uint8_t *src, int stride){\
2037 uint8_t full[24*17];\
2038 uint8_t halfH[272];\
2039 uint8_t halfHV[256];\
2040 copy_block17(full, src, 24, stride, 17);\
2041 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
2042 put ## RND ## pixels16_l2(halfH, halfH, full, 16, 16, 24, 17);\
2043 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
2044 OPNAME ## pixels16_l2(dst, halfH+16, halfHV, stride, 16, 16, 16);\
2045}\
2046void ff_ ## OPNAME ## qpel16_mc33_old_c(uint8_t *dst, uint8_t *src, int stride){\
2047 uint8_t full[24*17];\
2048 uint8_t halfH[272];\
2049 uint8_t halfV[256];\
2050 uint8_t halfHV[256];\
2051 copy_block17(full, src, 24, stride, 17);\
2052 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full , 16, 24, 17);\
2053 put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full+1, 16, 24);\
2054 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
2055 OPNAME ## pixels16_l4(dst, full+25, halfH+16, halfV, halfHV, stride, 24, 16, 16, 16, 16);\
2056}\
2057static void OPNAME ## qpel16_mc33_c(uint8_t *dst, uint8_t *src, int stride){\
2058 uint8_t full[24*17];\
2059 uint8_t halfH[272];\
2060 uint8_t halfHV[256];\
2061 copy_block17(full, src, 24, stride, 17);\
2062 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
2063 put ## RND ## pixels16_l2(halfH, halfH, full+1, 16, 16, 24, 17);\
2064 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
2065 OPNAME ## pixels16_l2(dst, halfH+16, halfHV, stride, 16, 16, 16);\
2066}\
2067static void OPNAME ## qpel16_mc21_c(uint8_t *dst, uint8_t *src, int stride){\
2068 uint8_t halfH[272];\
2069 uint8_t halfHV[256];\
2070 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);\
2071 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
2072 OPNAME ## pixels16_l2(dst, halfH, halfHV, stride, 16, 16, 16);\
2073}\
2074static void OPNAME ## qpel16_mc23_c(uint8_t *dst, uint8_t *src, int stride){\
2075 uint8_t halfH[272];\
2076 uint8_t halfHV[256];\
2077 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);\
2078 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
2079 OPNAME ## pixels16_l2(dst, halfH+16, halfHV, stride, 16, 16, 16);\
2080}\
2081void ff_ ## OPNAME ## qpel16_mc12_old_c(uint8_t *dst, uint8_t *src, int stride){\
2082 uint8_t full[24*17];\
2083 uint8_t halfH[272];\
2084 uint8_t halfV[256];\
2085 uint8_t halfHV[256];\
2086 copy_block17(full, src, 24, stride, 17);\
2087 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
2088 put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24);\
2089 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
2090 OPNAME ## pixels16_l2(dst, halfV, halfHV, stride, 16, 16, 16);\
2091}\
2092static void OPNAME ## qpel16_mc12_c(uint8_t *dst, uint8_t *src, int stride){\
2093 uint8_t full[24*17];\
2094 uint8_t halfH[272];\
2095 copy_block17(full, src, 24, stride, 17);\
2096 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
2097 put ## RND ## pixels16_l2(halfH, halfH, full, 16, 16, 24, 17);\
2098 OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16);\
2099}\
2100void ff_ ## OPNAME ## qpel16_mc32_old_c(uint8_t *dst, uint8_t *src, int stride){\
2101 uint8_t full[24*17];\
2102 uint8_t halfH[272];\
2103 uint8_t halfV[256];\
2104 uint8_t halfHV[256];\
2105 copy_block17(full, src, 24, stride, 17);\
2106 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
2107 put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full+1, 16, 24);\
2108 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
2109 OPNAME ## pixels16_l2(dst, halfV, halfHV, stride, 16, 16, 16);\
2110}\
2111static void OPNAME ## qpel16_mc32_c(uint8_t *dst, uint8_t *src, int stride){\
2112 uint8_t full[24*17];\
2113 uint8_t halfH[272];\
2114 copy_block17(full, src, 24, stride, 17);\
2115 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
2116 put ## RND ## pixels16_l2(halfH, halfH, full+1, 16, 16, 24, 17);\
2117 OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16);\
2118}\
2119static void OPNAME ## qpel16_mc22_c(uint8_t *dst, uint8_t *src, int stride){\
2120 uint8_t halfH[272];\
2121 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);\
2122 OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16);\
2123}
2124
2125#define op_avg(a, b) a = (((a)+cm[((b) + 16)>>5]+1)>>1)
2126#define op_avg_no_rnd(a, b) a = (((a)+cm[((b) + 15)>>5])>>1)
2127#define op_put(a, b) a = cm[((b) + 16)>>5]
2128#define op_put_no_rnd(a, b) a = cm[((b) + 15)>>5]
2129
2130QPEL_MC(0, put_ , _ , op_put)
2131QPEL_MC(1, put_no_rnd_, _no_rnd_, op_put_no_rnd)
2132QPEL_MC(0, avg_ , _ , op_avg)
2133//QPEL_MC(1, avg_no_rnd , _ , op_avg)
2134#undef op_avg
2135#undef op_avg_no_rnd
2136#undef op_put
2137#undef op_put_no_rnd
2138
2139#if 1
2140#define H264_LOWPASS(OPNAME, OP, OP2) \
2141static av_unused void OPNAME ## h264_qpel2_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
2142 const int h=2;\
2143 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
2144 int i;\
2145 for(i=0; i<h; i++)\
2146 {\
2147 OP(dst[0], (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]));\
2148 OP(dst[1], (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]));\
2149 dst+=dstStride;\
2150 src+=srcStride;\
2151 }\
2152}\
2153\
2154static av_unused void OPNAME ## h264_qpel2_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
2155 const int w=2;\
2156 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
2157 int i;\
2158 for(i=0; i<w; i++)\
2159 {\
2160 const int srcB= src[-2*srcStride];\
2161 const int srcA= src[-1*srcStride];\
2162 const int src0= src[0 *srcStride];\
2163 const int src1= src[1 *srcStride];\
2164 const int src2= src[2 *srcStride];\
2165 const int src3= src[3 *srcStride];\
2166 const int src4= src[4 *srcStride];\
2167 OP(dst[0*dstStride], (src0+src1)*20 - (srcA+src2)*5 + (srcB+src3));\
2168 OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*5 + (srcA+src4));\
2169 dst++;\
2170 src++;\
2171 }\
2172}\
2173\
2174static av_unused void OPNAME ## h264_qpel2_hv_lowpass(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
2175 const int h=2;\
2176 const int w=2;\
2177 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
2178 int i;\
2179 src -= 2*srcStride;\
2180 for(i=0; i<h+5; i++)\
2181 {\
2182 tmp[0]= (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]);\
2183 tmp[1]= (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]);\
2184 tmp+=tmpStride;\
2185 src+=srcStride;\
2186 }\
2187 tmp -= tmpStride*(h+5-2);\
2188 for(i=0; i<w; i++)\
2189 {\
2190 const int tmpB= tmp[-2*tmpStride];\
2191 const int tmpA= tmp[-1*tmpStride];\
2192 const int tmp0= tmp[0 *tmpStride];\
2193 const int tmp1= tmp[1 *tmpStride];\
2194 const int tmp2= tmp[2 *tmpStride];\
2195 const int tmp3= tmp[3 *tmpStride];\
2196 const int tmp4= tmp[4 *tmpStride];\
2197 OP2(dst[0*dstStride], (tmp0+tmp1)*20 - (tmpA+tmp2)*5 + (tmpB+tmp3));\
2198 OP2(dst[1*dstStride], (tmp1+tmp2)*20 - (tmp0+tmp3)*5 + (tmpA+tmp4));\
2199 dst++;\
2200 tmp++;\
2201 }\
2202}\
2203static void OPNAME ## h264_qpel4_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
2204 const int h=4;\
2205 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
2206 int i;\
2207 for(i=0; i<h; i++)\
2208 {\
2209 OP(dst[0], (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]));\
2210 OP(dst[1], (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]));\
2211 OP(dst[2], (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5]));\
2212 OP(dst[3], (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6]));\
2213 dst+=dstStride;\
2214 src+=srcStride;\
2215 }\
2216}\
2217\
2218static void OPNAME ## h264_qpel4_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
2219 const int w=4;\
2220 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
2221 int i;\
2222 for(i=0; i<w; i++)\
2223 {\
2224 const int srcB= src[-2*srcStride];\
2225 const int srcA= src[-1*srcStride];\
2226 const int src0= src[0 *srcStride];\
2227 const int src1= src[1 *srcStride];\
2228 const int src2= src[2 *srcStride];\
2229 const int src3= src[3 *srcStride];\
2230 const int src4= src[4 *srcStride];\
2231 const int src5= src[5 *srcStride];\
2232 const int src6= src[6 *srcStride];\
2233 OP(dst[0*dstStride], (src0+src1)*20 - (srcA+src2)*5 + (srcB+src3));\
2234 OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*5 + (srcA+src4));\
2235 OP(dst[2*dstStride], (src2+src3)*20 - (src1+src4)*5 + (src0+src5));\
2236 OP(dst[3*dstStride], (src3+src4)*20 - (src2+src5)*5 + (src1+src6));\
2237 dst++;\
2238 src++;\
2239 }\
2240}\
2241\
2242static void OPNAME ## h264_qpel4_hv_lowpass(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
2243 const int h=4;\
2244 const int w=4;\
2245 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
2246 int i;\
2247 src -= 2*srcStride;\
2248 for(i=0; i<h+5; i++)\
2249 {\
2250 tmp[0]= (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]);\
2251 tmp[1]= (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]);\
2252 tmp[2]= (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5]);\
2253 tmp[3]= (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6]);\
2254 tmp+=tmpStride;\
2255 src+=srcStride;\
2256 }\
2257 tmp -= tmpStride*(h+5-2);\
2258 for(i=0; i<w; i++)\
2259 {\
2260 const int tmpB= tmp[-2*tmpStride];\
2261 const int tmpA= tmp[-1*tmpStride];\
2262 const int tmp0= tmp[0 *tmpStride];\
2263 const int tmp1= tmp[1 *tmpStride];\
2264 const int tmp2= tmp[2 *tmpStride];\
2265 const int tmp3= tmp[3 *tmpStride];\
2266 const int tmp4= tmp[4 *tmpStride];\
2267 const int tmp5= tmp[5 *tmpStride];\
2268 const int tmp6= tmp[6 *tmpStride];\
2269 OP2(dst[0*dstStride], (tmp0+tmp1)*20 - (tmpA+tmp2)*5 + (tmpB+tmp3));\
2270 OP2(dst[1*dstStride], (tmp1+tmp2)*20 - (tmp0+tmp3)*5 + (tmpA+tmp4));\
2271 OP2(dst[2*dstStride], (tmp2+tmp3)*20 - (tmp1+tmp4)*5 + (tmp0+tmp5));\
2272 OP2(dst[3*dstStride], (tmp3+tmp4)*20 - (tmp2+tmp5)*5 + (tmp1+tmp6));\
2273 dst++;\
2274 tmp++;\
2275 }\
2276}\
2277\
2278static void OPNAME ## h264_qpel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
2279 const int h=8;\
2280 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
2281 int i;\
2282 for(i=0; i<h; i++)\
2283 {\
2284 OP(dst[0], (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3 ]));\
2285 OP(dst[1], (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4 ]));\
2286 OP(dst[2], (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5 ]));\
2287 OP(dst[3], (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6 ]));\
2288 OP(dst[4], (src[4]+src[5])*20 - (src[3 ]+src[6])*5 + (src[2 ]+src[7 ]));\
2289 OP(dst[5], (src[5]+src[6])*20 - (src[4 ]+src[7])*5 + (src[3 ]+src[8 ]));\
2290 OP(dst[6], (src[6]+src[7])*20 - (src[5 ]+src[8])*5 + (src[4 ]+src[9 ]));\
2291 OP(dst[7], (src[7]+src[8])*20 - (src[6 ]+src[9])*5 + (src[5 ]+src[10]));\
2292 dst+=dstStride;\
2293 src+=srcStride;\
2294 }\
2295}\
2296\
2297static void OPNAME ## h264_qpel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
2298 const int w=8;\
2299 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
2300 int i;\
2301 for(i=0; i<w; i++)\
2302 {\
2303 const int srcB= src[-2*srcStride];\
2304 const int srcA= src[-1*srcStride];\
2305 const int src0= src[0 *srcStride];\
2306 const int src1= src[1 *srcStride];\
2307 const int src2= src[2 *srcStride];\
2308 const int src3= src[3 *srcStride];\
2309 const int src4= src[4 *srcStride];\
2310 const int src5= src[5 *srcStride];\
2311 const int src6= src[6 *srcStride];\
2312 const int src7= src[7 *srcStride];\
2313 const int src8= src[8 *srcStride];\
2314 const int src9= src[9 *srcStride];\
2315 const int src10=src[10*srcStride];\
2316 OP(dst[0*dstStride], (src0+src1)*20 - (srcA+src2)*5 + (srcB+src3));\
2317 OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*5 + (srcA+src4));\
2318 OP(dst[2*dstStride], (src2+src3)*20 - (src1+src4)*5 + (src0+src5));\
2319 OP(dst[3*dstStride], (src3+src4)*20 - (src2+src5)*5 + (src1+src6));\
2320 OP(dst[4*dstStride], (src4+src5)*20 - (src3+src6)*5 + (src2+src7));\
2321 OP(dst[5*dstStride], (src5+src6)*20 - (src4+src7)*5 + (src3+src8));\
2322 OP(dst[6*dstStride], (src6+src7)*20 - (src5+src8)*5 + (src4+src9));\
2323 OP(dst[7*dstStride], (src7+src8)*20 - (src6+src9)*5 + (src5+src10));\
2324 dst++;\
2325 src++;\
2326 }\
2327}\
2328\
2329static void OPNAME ## h264_qpel8_hv_lowpass(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
2330 const int h=8;\
2331 const int w=8;\
2332 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
2333 int i;\
2334 src -= 2*srcStride;\
2335 for(i=0; i<h+5; i++)\
2336 {\
2337 tmp[0]= (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3 ]);\
2338 tmp[1]= (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4 ]);\
2339 tmp[2]= (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5 ]);\
2340 tmp[3]= (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6 ]);\
2341 tmp[4]= (src[4]+src[5])*20 - (src[3 ]+src[6])*5 + (src[2 ]+src[7 ]);\
2342 tmp[5]= (src[5]+src[6])*20 - (src[4 ]+src[7])*5 + (src[3 ]+src[8 ]);\
2343 tmp[6]= (src[6]+src[7])*20 - (src[5 ]+src[8])*5 + (src[4 ]+src[9 ]);\
2344 tmp[7]= (src[7]+src[8])*20 - (src[6 ]+src[9])*5 + (src[5 ]+src[10]);\
2345 tmp+=tmpStride;\
2346 src+=srcStride;\
2347 }\
2348 tmp -= tmpStride*(h+5-2);\
2349 for(i=0; i<w; i++)\
2350 {\
2351 const int tmpB= tmp[-2*tmpStride];\
2352 const int tmpA= tmp[-1*tmpStride];\
2353 const int tmp0= tmp[0 *tmpStride];\
2354 const int tmp1= tmp[1 *tmpStride];\
2355 const int tmp2= tmp[2 *tmpStride];\
2356 const int tmp3= tmp[3 *tmpStride];\
2357 const int tmp4= tmp[4 *tmpStride];\
2358 const int tmp5= tmp[5 *tmpStride];\
2359 const int tmp6= tmp[6 *tmpStride];\
2360 const int tmp7= tmp[7 *tmpStride];\
2361 const int tmp8= tmp[8 *tmpStride];\
2362 const int tmp9= tmp[9 *tmpStride];\
2363 const int tmp10=tmp[10*tmpStride];\
2364 OP2(dst[0*dstStride], (tmp0+tmp1)*20 - (tmpA+tmp2)*5 + (tmpB+tmp3));\
2365 OP2(dst[1*dstStride], (tmp1+tmp2)*20 - (tmp0+tmp3)*5 + (tmpA+tmp4));\
2366 OP2(dst[2*dstStride], (tmp2+tmp3)*20 - (tmp1+tmp4)*5 + (tmp0+tmp5));\
2367 OP2(dst[3*dstStride], (tmp3+tmp4)*20 - (tmp2+tmp5)*5 + (tmp1+tmp6));\
2368 OP2(dst[4*dstStride], (tmp4+tmp5)*20 - (tmp3+tmp6)*5 + (tmp2+tmp7));\
2369 OP2(dst[5*dstStride], (tmp5+tmp6)*20 - (tmp4+tmp7)*5 + (tmp3+tmp8));\
2370 OP2(dst[6*dstStride], (tmp6+tmp7)*20 - (tmp5+tmp8)*5 + (tmp4+tmp9));\
2371 OP2(dst[7*dstStride], (tmp7+tmp8)*20 - (tmp6+tmp9)*5 + (tmp5+tmp10));\
2372 dst++;\
2373 tmp++;\
2374 }\
2375}\
2376\
2377static void OPNAME ## h264_qpel16_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
2378 OPNAME ## h264_qpel8_v_lowpass(dst , src , dstStride, srcStride);\
2379 OPNAME ## h264_qpel8_v_lowpass(dst+8, src+8, dstStride, srcStride);\
2380 src += 8*srcStride;\
2381 dst += 8*dstStride;\
2382 OPNAME ## h264_qpel8_v_lowpass(dst , src , dstStride, srcStride);\
2383 OPNAME ## h264_qpel8_v_lowpass(dst+8, src+8, dstStride, srcStride);\
2384}\
2385\
2386static void OPNAME ## h264_qpel16_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
2387 OPNAME ## h264_qpel8_h_lowpass(dst , src , dstStride, srcStride);\
2388 OPNAME ## h264_qpel8_h_lowpass(dst+8, src+8, dstStride, srcStride);\
2389 src += 8*srcStride;\
2390 dst += 8*dstStride;\
2391 OPNAME ## h264_qpel8_h_lowpass(dst , src , dstStride, srcStride);\
2392 OPNAME ## h264_qpel8_h_lowpass(dst+8, src+8, dstStride, srcStride);\
2393}\
2394\
2395static void OPNAME ## h264_qpel16_hv_lowpass(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
2396 OPNAME ## h264_qpel8_hv_lowpass(dst , tmp , src , dstStride, tmpStride, srcStride);\
2397 OPNAME ## h264_qpel8_hv_lowpass(dst+8, tmp+8, src+8, dstStride, tmpStride, srcStride);\
2398 src += 8*srcStride;\
2399 dst += 8*dstStride;\
2400 OPNAME ## h264_qpel8_hv_lowpass(dst , tmp , src , dstStride, tmpStride, srcStride);\
2401 OPNAME ## h264_qpel8_hv_lowpass(dst+8, tmp+8, src+8, dstStride, tmpStride, srcStride);\
2402}\
2403
2404#define H264_MC(OPNAME, SIZE) \
2405static void OPNAME ## h264_qpel ## SIZE ## _mc00_c (uint8_t *dst, uint8_t *src, int stride){\
2406 OPNAME ## pixels ## SIZE ## _c(dst, src, stride, SIZE);\
2407}\
2408\
2409static void OPNAME ## h264_qpel ## SIZE ## _mc10_c(uint8_t *dst, uint8_t *src, int stride){\
2410 uint8_t half[SIZE*SIZE];\
2411 put_h264_qpel ## SIZE ## _h_lowpass(half, src, SIZE, stride);\
2412 OPNAME ## pixels ## SIZE ## _l2(dst, src, half, stride, stride, SIZE, SIZE);\
2413}\
2414\
2415static void OPNAME ## h264_qpel ## SIZE ## _mc20_c(uint8_t *dst, uint8_t *src, int stride){\
2416 OPNAME ## h264_qpel ## SIZE ## _h_lowpass(dst, src, stride, stride);\
2417}\
2418\
2419static void OPNAME ## h264_qpel ## SIZE ## _mc30_c(uint8_t *dst, uint8_t *src, int stride){\
2420 uint8_t half[SIZE*SIZE];\
2421 put_h264_qpel ## SIZE ## _h_lowpass(half, src, SIZE, stride);\
2422 OPNAME ## pixels ## SIZE ## _l2(dst, src+1, half, stride, stride, SIZE, SIZE);\
2423}\
2424\
2425static void OPNAME ## h264_qpel ## SIZE ## _mc01_c(uint8_t *dst, uint8_t *src, int stride){\
2426 uint8_t full[SIZE*(SIZE+5)];\
2427 uint8_t * const full_mid= full + SIZE*2;\
2428 uint8_t half[SIZE*SIZE];\
2429 copy_block ## SIZE (full, src - stride*2, SIZE, stride, SIZE + 5);\
2430 put_h264_qpel ## SIZE ## _v_lowpass(half, full_mid, SIZE, SIZE);\
2431 OPNAME ## pixels ## SIZE ## _l2(dst, full_mid, half, stride, SIZE, SIZE, SIZE);\
2432}\
2433\
2434static void OPNAME ## h264_qpel ## SIZE ## _mc02_c(uint8_t *dst, uint8_t *src, int stride){\
2435 uint8_t full[SIZE*(SIZE+5)];\
2436 uint8_t * const full_mid= full + SIZE*2;\
2437 copy_block ## SIZE (full, src - stride*2, SIZE, stride, SIZE + 5);\
2438 OPNAME ## h264_qpel ## SIZE ## _v_lowpass(dst, full_mid, stride, SIZE);\
2439}\
2440\
2441static void OPNAME ## h264_qpel ## SIZE ## _mc03_c(uint8_t *dst, uint8_t *src, int stride){\
2442 uint8_t full[SIZE*(SIZE+5)];\
2443 uint8_t * const full_mid= full + SIZE*2;\
2444 uint8_t half[SIZE*SIZE];\
2445 copy_block ## SIZE (full, src - stride*2, SIZE, stride, SIZE + 5);\
2446 put_h264_qpel ## SIZE ## _v_lowpass(half, full_mid, SIZE, SIZE);\
2447 OPNAME ## pixels ## SIZE ## _l2(dst, full_mid+SIZE, half, stride, SIZE, SIZE, SIZE);\
2448}\
2449\
2450static void OPNAME ## h264_qpel ## SIZE ## _mc11_c(uint8_t *dst, uint8_t *src, int stride){\
2451 uint8_t full[SIZE*(SIZE+5)];\
2452 uint8_t * const full_mid= full + SIZE*2;\
2453 uint8_t halfH[SIZE*SIZE];\
2454 uint8_t halfV[SIZE*SIZE];\
2455 put_h264_qpel ## SIZE ## _h_lowpass(halfH, src, SIZE, stride);\
2456 copy_block ## SIZE (full, src - stride*2, SIZE, stride, SIZE + 5);\
2457 put_h264_qpel ## SIZE ## _v_lowpass(halfV, full_mid, SIZE, SIZE);\
2458 OPNAME ## pixels ## SIZE ## _l2(dst, halfH, halfV, stride, SIZE, SIZE, SIZE);\
2459}\
2460\
2461static void OPNAME ## h264_qpel ## SIZE ## _mc31_c(uint8_t *dst, uint8_t *src, int stride){\
2462 uint8_t full[SIZE*(SIZE+5)];\
2463 uint8_t * const full_mid= full + SIZE*2;\
2464 uint8_t halfH[SIZE*SIZE];\
2465 uint8_t halfV[SIZE*SIZE];\
2466 put_h264_qpel ## SIZE ## _h_lowpass(halfH, src, SIZE, stride);\
2467 copy_block ## SIZE (full, src - stride*2 + 1, SIZE, stride, SIZE + 5);\
2468 put_h264_qpel ## SIZE ## _v_lowpass(halfV, full_mid, SIZE, SIZE);\
2469 OPNAME ## pixels ## SIZE ## _l2(dst, halfH, halfV, stride, SIZE, SIZE, SIZE);\
2470}\
2471\
2472static void OPNAME ## h264_qpel ## SIZE ## _mc13_c(uint8_t *dst, uint8_t *src, int stride){\
2473 uint8_t full[SIZE*(SIZE+5)];\
2474 uint8_t * const full_mid= full + SIZE*2;\
2475 uint8_t halfH[SIZE*SIZE];\
2476 uint8_t halfV[SIZE*SIZE];\
2477 put_h264_qpel ## SIZE ## _h_lowpass(halfH, src + stride, SIZE, stride);\
2478 copy_block ## SIZE (full, src - stride*2, SIZE, stride, SIZE + 5);\
2479 put_h264_qpel ## SIZE ## _v_lowpass(halfV, full_mid, SIZE, SIZE);\
2480 OPNAME ## pixels ## SIZE ## _l2(dst, halfH, halfV, stride, SIZE, SIZE, SIZE);\
2481}\
2482\
2483static void OPNAME ## h264_qpel ## SIZE ## _mc33_c(uint8_t *dst, uint8_t *src, int stride){\
2484 uint8_t full[SIZE*(SIZE+5)];\
2485 uint8_t * const full_mid= full + SIZE*2;\
2486 uint8_t halfH[SIZE*SIZE];\
2487 uint8_t halfV[SIZE*SIZE];\
2488 put_h264_qpel ## SIZE ## _h_lowpass(halfH, src + stride, SIZE, stride);\
2489 copy_block ## SIZE (full, src - stride*2 + 1, SIZE, stride, SIZE + 5);\
2490 put_h264_qpel ## SIZE ## _v_lowpass(halfV, full_mid, SIZE, SIZE);\
2491 OPNAME ## pixels ## SIZE ## _l2(dst, halfH, halfV, stride, SIZE, SIZE, SIZE);\
2492}\
2493\
2494static void OPNAME ## h264_qpel ## SIZE ## _mc22_c(uint8_t *dst, uint8_t *src, int stride){\
2495 int16_t tmp[SIZE*(SIZE+5)];\
2496 OPNAME ## h264_qpel ## SIZE ## _hv_lowpass(dst, tmp, src, stride, SIZE, stride);\
2497}\
2498\
2499static void OPNAME ## h264_qpel ## SIZE ## _mc21_c(uint8_t *dst, uint8_t *src, int stride){\
2500 int16_t tmp[SIZE*(SIZE+5)];\
2501 uint8_t halfH[SIZE*SIZE];\
2502 uint8_t halfHV[SIZE*SIZE];\
2503 put_h264_qpel ## SIZE ## _h_lowpass(halfH, src, SIZE, stride);\
2504 put_h264_qpel ## SIZE ## _hv_lowpass(halfHV, tmp, src, SIZE, SIZE, stride);\
2505 OPNAME ## pixels ## SIZE ## _l2(dst, halfH, halfHV, stride, SIZE, SIZE, SIZE);\
2506}\
2507\
2508static void OPNAME ## h264_qpel ## SIZE ## _mc23_c(uint8_t *dst, uint8_t *src, int stride){\
2509 int16_t tmp[SIZE*(SIZE+5)];\
2510 uint8_t halfH[SIZE*SIZE];\
2511 uint8_t halfHV[SIZE*SIZE];\
2512 put_h264_qpel ## SIZE ## _h_lowpass(halfH, src + stride, SIZE, stride);\
2513 put_h264_qpel ## SIZE ## _hv_lowpass(halfHV, tmp, src, SIZE, SIZE, stride);\
2514 OPNAME ## pixels ## SIZE ## _l2(dst, halfH, halfHV, stride, SIZE, SIZE, SIZE);\
2515}\
2516\
2517static void OPNAME ## h264_qpel ## SIZE ## _mc12_c(uint8_t *dst, uint8_t *src, int stride){\
2518 uint8_t full[SIZE*(SIZE+5)];\
2519 uint8_t * const full_mid= full + SIZE*2;\
2520 int16_t tmp[SIZE*(SIZE+5)];\
2521 uint8_t halfV[SIZE*SIZE];\
2522 uint8_t halfHV[SIZE*SIZE];\
2523 copy_block ## SIZE (full, src - stride*2, SIZE, stride, SIZE + 5);\
2524 put_h264_qpel ## SIZE ## _v_lowpass(halfV, full_mid, SIZE, SIZE);\
2525 put_h264_qpel ## SIZE ## _hv_lowpass(halfHV, tmp, src, SIZE, SIZE, stride);\
2526 OPNAME ## pixels ## SIZE ## _l2(dst, halfV, halfHV, stride, SIZE, SIZE, SIZE);\
2527}\
2528\
2529static void OPNAME ## h264_qpel ## SIZE ## _mc32_c(uint8_t *dst, uint8_t *src, int stride){\
2530 uint8_t full[SIZE*(SIZE+5)];\
2531 uint8_t * const full_mid= full + SIZE*2;\
2532 int16_t tmp[SIZE*(SIZE+5)];\
2533 uint8_t halfV[SIZE*SIZE];\
2534 uint8_t halfHV[SIZE*SIZE];\
2535 copy_block ## SIZE (full, src - stride*2 + 1, SIZE, stride, SIZE + 5);\
2536 put_h264_qpel ## SIZE ## _v_lowpass(halfV, full_mid, SIZE, SIZE);\
2537 put_h264_qpel ## SIZE ## _hv_lowpass(halfHV, tmp, src, SIZE, SIZE, stride);\
2538 OPNAME ## pixels ## SIZE ## _l2(dst, halfV, halfHV, stride, SIZE, SIZE, SIZE);\
2539}\
2540
2541#define op_avg(a, b) a = (((a)+cm[((b) + 16)>>5]+1)>>1)
2542//#define op_avg2(a, b) a = (((a)*w1+cm[((b) + 16)>>5]*w2 + o + 64)>>7)
2543#define op_put(a, b) a = cm[((b) + 16)>>5]
2544#define op2_avg(a, b) a = (((a)+cm[((b) + 512)>>10]+1)>>1)
2545#define op2_put(a, b) a = cm[((b) + 512)>>10]
2546
2547H264_LOWPASS(put_ , op_put, op2_put)
2548H264_LOWPASS(avg_ , op_avg, op2_avg)
2549H264_MC(put_, 2)
2550H264_MC(put_, 4)
2551H264_MC(put_, 8)
2552H264_MC(put_, 16)
2553H264_MC(avg_, 4)
2554H264_MC(avg_, 8)
2555H264_MC(avg_, 16)
2556
2557#undef op_avg
2558#undef op_put
2559#undef op2_avg
2560#undef op2_put
2561#endif
2562
2563static void wmv2_mspel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){
2564 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
2565 int i;
2566
2567 for(i=0; i<h; i++){
2568 dst[0]= cm[(9*(src[0] + src[1]) - (src[-1] + src[2]) + 8)>>4];
2569 dst[1]= cm[(9*(src[1] + src[2]) - (src[ 0] + src[3]) + 8)>>4];
2570 dst[2]= cm[(9*(src[2] + src[3]) - (src[ 1] + src[4]) + 8)>>4];
2571 dst[3]= cm[(9*(src[3] + src[4]) - (src[ 2] + src[5]) + 8)>>4];
2572 dst[4]= cm[(9*(src[4] + src[5]) - (src[ 3] + src[6]) + 8)>>4];
2573 dst[5]= cm[(9*(src[5] + src[6]) - (src[ 4] + src[7]) + 8)>>4];
2574 dst[6]= cm[(9*(src[6] + src[7]) - (src[ 5] + src[8]) + 8)>>4];
2575 dst[7]= cm[(9*(src[7] + src[8]) - (src[ 6] + src[9]) + 8)>>4];
2576 dst+=dstStride;
2577 src+=srcStride;
2578 }
2579}
2580
2581#if CONFIG_CAVS_DECODER
2582/* AVS specific */
2583void ff_put_cavs_qpel8_mc00_c(uint8_t *dst, uint8_t *src, int stride) {
2584 put_pixels8_c(dst, src, stride, 8);
2585}
2586void ff_avg_cavs_qpel8_mc00_c(uint8_t *dst, uint8_t *src, int stride) {
2587 avg_pixels8_c(dst, src, stride, 8);
2588}
2589void ff_put_cavs_qpel16_mc00_c(uint8_t *dst, uint8_t *src, int stride) {
2590 put_pixels16_c(dst, src, stride, 16);
2591}
2592void ff_avg_cavs_qpel16_mc00_c(uint8_t *dst, uint8_t *src, int stride) {
2593 avg_pixels16_c(dst, src, stride, 16);
2594}
2595#endif /* CONFIG_CAVS_DECODER */
2596
2597#if CONFIG_VC1_DECODER
2598/* VC-1 specific */
2599void ff_put_vc1_mspel_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) {
2600 put_pixels8_c(dst, src, stride, 8);
2601}
2602void ff_avg_vc1_mspel_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) {
2603 avg_pixels8_c(dst, src, stride, 8);
2604}
2605#endif /* CONFIG_VC1_DECODER */
2606
2607#if CONFIG_RV40_DECODER
2608static void put_rv40_qpel16_mc33_c(uint8_t *dst, uint8_t *src, int stride){
2609 put_pixels16_xy2_c(dst, src, stride, 16);
2610}
2611static void avg_rv40_qpel16_mc33_c(uint8_t *dst, uint8_t *src, int stride){
2612 avg_pixels16_xy2_c(dst, src, stride, 16);
2613}
2614static void put_rv40_qpel8_mc33_c(uint8_t *dst, uint8_t *src, int stride){
2615 put_pixels8_xy2_c(dst, src, stride, 8);
2616}
2617static void avg_rv40_qpel8_mc33_c(uint8_t *dst, uint8_t *src, int stride){
2618 avg_pixels8_xy2_c(dst, src, stride, 8);
2619}
2620#endif /* CONFIG_RV40_DECODER */
2621
2622static void wmv2_mspel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int w){
2623 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
2624 int i;
2625
2626 for(i=0; i<w; i++){
2627 const int src_1= src[ -srcStride];
2628 const int src0 = src[0 ];
2629 const int src1 = src[ srcStride];
2630 const int src2 = src[2*srcStride];
2631 const int src3 = src[3*srcStride];
2632 const int src4 = src[4*srcStride];
2633 const int src5 = src[5*srcStride];
2634 const int src6 = src[6*srcStride];
2635 const int src7 = src[7*srcStride];
2636 const int src8 = src[8*srcStride];
2637 const int src9 = src[9*srcStride];
2638 dst[0*dstStride]= cm[(9*(src0 + src1) - (src_1 + src2) + 8)>>4];
2639 dst[1*dstStride]= cm[(9*(src1 + src2) - (src0 + src3) + 8)>>4];
2640 dst[2*dstStride]= cm[(9*(src2 + src3) - (src1 + src4) + 8)>>4];
2641 dst[3*dstStride]= cm[(9*(src3 + src4) - (src2 + src5) + 8)>>4];
2642 dst[4*dstStride]= cm[(9*(src4 + src5) - (src3 + src6) + 8)>>4];
2643 dst[5*dstStride]= cm[(9*(src5 + src6) - (src4 + src7) + 8)>>4];
2644 dst[6*dstStride]= cm[(9*(src6 + src7) - (src5 + src8) + 8)>>4];
2645 dst[7*dstStride]= cm[(9*(src7 + src8) - (src6 + src9) + 8)>>4];
2646 src++;
2647 dst++;
2648 }
2649}
2650
2651static void put_mspel8_mc00_c (uint8_t *dst, uint8_t *src, int stride){
2652 put_pixels8_c(dst, src, stride, 8);
2653}
2654
2655static void put_mspel8_mc10_c(uint8_t *dst, uint8_t *src, int stride){
2656 uint8_t half[64];
2657 wmv2_mspel8_h_lowpass(half, src, 8, stride, 8);
2658 put_pixels8_l2(dst, src, half, stride, stride, 8, 8);
2659}
2660
2661static void put_mspel8_mc20_c(uint8_t *dst, uint8_t *src, int stride){
2662 wmv2_mspel8_h_lowpass(dst, src, stride, stride, 8);
2663}
2664
2665static void put_mspel8_mc30_c(uint8_t *dst, uint8_t *src, int stride){
2666 uint8_t half[64];
2667 wmv2_mspel8_h_lowpass(half, src, 8, stride, 8);
2668 put_pixels8_l2(dst, src+1, half, stride, stride, 8, 8);
2669}
2670
2671static void put_mspel8_mc02_c(uint8_t *dst, uint8_t *src, int stride){
2672 wmv2_mspel8_v_lowpass(dst, src, stride, stride, 8);
2673}
2674
2675static void put_mspel8_mc12_c(uint8_t *dst, uint8_t *src, int stride){
2676 uint8_t halfH[88];
2677 uint8_t halfV[64];
2678 uint8_t halfHV[64];
2679 wmv2_mspel8_h_lowpass(halfH, src-stride, 8, stride, 11);
2680 wmv2_mspel8_v_lowpass(halfV, src, 8, stride, 8);
2681 wmv2_mspel8_v_lowpass(halfHV, halfH+8, 8, 8, 8);
2682 put_pixels8_l2(dst, halfV, halfHV, stride, 8, 8, 8);
2683}
2684static void put_mspel8_mc32_c(uint8_t *dst, uint8_t *src, int stride){
2685 uint8_t halfH[88];
2686 uint8_t halfV[64];
2687 uint8_t halfHV[64];
2688 wmv2_mspel8_h_lowpass(halfH, src-stride, 8, stride, 11);
2689 wmv2_mspel8_v_lowpass(halfV, src+1, 8, stride, 8);
2690 wmv2_mspel8_v_lowpass(halfHV, halfH+8, 8, 8, 8);
2691 put_pixels8_l2(dst, halfV, halfHV, stride, 8, 8, 8);
2692}
2693static void put_mspel8_mc22_c(uint8_t *dst, uint8_t *src, int stride){
2694 uint8_t halfH[88];
2695 wmv2_mspel8_h_lowpass(halfH, src-stride, 8, stride, 11);
2696 wmv2_mspel8_v_lowpass(dst, halfH+8, stride, 8, 8);
2697}
2698
2699static void h263_v_loop_filter_c(uint8_t *src, int stride, int qscale){
2700 if(CONFIG_H263_DECODER || CONFIG_H263_ENCODER) {
2701 int x;
2702 const int strength= ff_h263_loop_filter_strength[qscale];
2703
2704 for(x=0; x<8; x++){
2705 int d1, d2, ad1;
2706 int p0= src[x-2*stride];
2707 int p1= src[x-1*stride];
2708 int p2= src[x+0*stride];
2709 int p3= src[x+1*stride];
2710 int d = (p0 - p3 + 4*(p2 - p1)) / 8;
2711
2712 if (d<-2*strength) d1= 0;
2713 else if(d<- strength) d1=-2*strength - d;
2714 else if(d< strength) d1= d;
2715 else if(d< 2*strength) d1= 2*strength - d;
2716 else d1= 0;
2717
2718 p1 += d1;
2719 p2 -= d1;
2720 if(p1&256) p1= ~(p1>>31);
2721 if(p2&256) p2= ~(p2>>31);
2722
2723 src[x-1*stride] = p1;
2724 src[x+0*stride] = p2;
2725
2726 ad1= FFABS(d1)>>1;
2727
2728 d2= av_clip((p0-p3)/4, -ad1, ad1);
2729
2730 src[x-2*stride] = p0 - d2;
2731 src[x+ stride] = p3 + d2;
2732 }
2733 }
2734}
2735
2736static void h263_h_loop_filter_c(uint8_t *src, int stride, int qscale){
2737 if(CONFIG_H263_DECODER || CONFIG_H263_ENCODER) {
2738 int y;
2739 const int strength= ff_h263_loop_filter_strength[qscale];
2740
2741 for(y=0; y<8; y++){
2742 int d1, d2, ad1;
2743 int p0= src[y*stride-2];
2744 int p1= src[y*stride-1];
2745 int p2= src[y*stride+0];
2746 int p3= src[y*stride+1];
2747 int d = (p0 - p3 + 4*(p2 - p1)) / 8;
2748
2749 if (d<-2*strength) d1= 0;
2750 else if(d<- strength) d1=-2*strength - d;
2751 else if(d< strength) d1= d;
2752 else if(d< 2*strength) d1= 2*strength - d;
2753 else d1= 0;
2754
2755 p1 += d1;
2756 p2 -= d1;
2757 if(p1&256) p1= ~(p1>>31);
2758 if(p2&256) p2= ~(p2>>31);
2759
2760 src[y*stride-1] = p1;
2761 src[y*stride+0] = p2;
2762
2763 ad1= FFABS(d1)>>1;
2764
2765 d2= av_clip((p0-p3)/4, -ad1, ad1);
2766
2767 src[y*stride-2] = p0 - d2;
2768 src[y*stride+1] = p3 + d2;
2769 }
2770 }
2771}
2772
2773static void h261_loop_filter_c(uint8_t *src, int stride){
2774 int x,y,xy,yz;
2775 int temp[64];
2776
2777 for(x=0; x<8; x++){
2778 temp[x ] = 4*src[x ];
2779 temp[x + 7*8] = 4*src[x + 7*stride];
2780 }
2781 for(y=1; y<7; y++){
2782 for(x=0; x<8; x++){
2783 xy = y * stride + x;
2784 yz = y * 8 + x;
2785 temp[yz] = src[xy - stride] + 2*src[xy] + src[xy + stride];
2786 }
2787 }
2788
2789 for(y=0; y<8; y++){
2790 src[ y*stride] = (temp[ y*8] + 2)>>2;
2791 src[7+y*stride] = (temp[7+y*8] + 2)>>2;
2792 for(x=1; x<7; x++){
2793 xy = y * stride + x;
2794 yz = y * 8 + x;
2795 src[xy] = (temp[yz-1] + 2*temp[yz] + temp[yz+1] + 8)>>4;
2796 }
2797 }
2798}
2799
2800static inline int pix_abs16_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
2801{
2802 int s, i;
2803
2804 s = 0;
2805 for(i=0;i<h;i++) {
2806 s += abs(pix1[0] - pix2[0]);
2807 s += abs(pix1[1] - pix2[1]);
2808 s += abs(pix1[2] - pix2[2]);
2809 s += abs(pix1[3] - pix2[3]);
2810 s += abs(pix1[4] - pix2[4]);
2811 s += abs(pix1[5] - pix2[5]);
2812 s += abs(pix1[6] - pix2[6]);
2813 s += abs(pix1[7] - pix2[7]);
2814 s += abs(pix1[8] - pix2[8]);
2815 s += abs(pix1[9] - pix2[9]);
2816 s += abs(pix1[10] - pix2[10]);
2817 s += abs(pix1[11] - pix2[11]);
2818 s += abs(pix1[12] - pix2[12]);
2819 s += abs(pix1[13] - pix2[13]);
2820 s += abs(pix1[14] - pix2[14]);
2821 s += abs(pix1[15] - pix2[15]);
2822 pix1 += line_size;
2823 pix2 += line_size;
2824 }
2825 return s;
2826}
2827
2828static int pix_abs16_x2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
2829{
2830 int s, i;
2831
2832 s = 0;
2833 for(i=0;i<h;i++) {
2834 s += abs(pix1[0] - avg2(pix2[0], pix2[1]));
2835 s += abs(pix1[1] - avg2(pix2[1], pix2[2]));
2836 s += abs(pix1[2] - avg2(pix2[2], pix2[3]));
2837 s += abs(pix1[3] - avg2(pix2[3], pix2[4]));
2838 s += abs(pix1[4] - avg2(pix2[4], pix2[5]));
2839 s += abs(pix1[5] - avg2(pix2[5], pix2[6]));
2840 s += abs(pix1[6] - avg2(pix2[6], pix2[7]));
2841 s += abs(pix1[7] - avg2(pix2[7], pix2[8]));
2842 s += abs(pix1[8] - avg2(pix2[8], pix2[9]));
2843 s += abs(pix1[9] - avg2(pix2[9], pix2[10]));
2844 s += abs(pix1[10] - avg2(pix2[10], pix2[11]));
2845 s += abs(pix1[11] - avg2(pix2[11], pix2[12]));
2846 s += abs(pix1[12] - avg2(pix2[12], pix2[13]));
2847 s += abs(pix1[13] - avg2(pix2[13], pix2[14]));
2848 s += abs(pix1[14] - avg2(pix2[14], pix2[15]));
2849 s += abs(pix1[15] - avg2(pix2[15], pix2[16]));
2850 pix1 += line_size;
2851 pix2 += line_size;
2852 }
2853 return s;
2854}
2855
2856static int pix_abs16_y2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
2857{
2858 int s, i;
2859 uint8_t *pix3 = pix2 + line_size;
2860
2861 s = 0;
2862 for(i=0;i<h;i++) {
2863 s += abs(pix1[0] - avg2(pix2[0], pix3[0]));
2864 s += abs(pix1[1] - avg2(pix2[1], pix3[1]));
2865 s += abs(pix1[2] - avg2(pix2[2], pix3[2]));
2866 s += abs(pix1[3] - avg2(pix2[3], pix3[3]));
2867 s += abs(pix1[4] - avg2(pix2[4], pix3[4]));
2868 s += abs(pix1[5] - avg2(pix2[5], pix3[5]));
2869 s += abs(pix1[6] - avg2(pix2[6], pix3[6]));
2870 s += abs(pix1[7] - avg2(pix2[7], pix3[7]));
2871 s += abs(pix1[8] - avg2(pix2[8], pix3[8]));
2872 s += abs(pix1[9] - avg2(pix2[9], pix3[9]));
2873 s += abs(pix1[10] - avg2(pix2[10], pix3[10]));
2874 s += abs(pix1[11] - avg2(pix2[11], pix3[11]));
2875 s += abs(pix1[12] - avg2(pix2[12], pix3[12]));
2876 s += abs(pix1[13] - avg2(pix2[13], pix3[13]));
2877 s += abs(pix1[14] - avg2(pix2[14], pix3[14]));
2878 s += abs(pix1[15] - avg2(pix2[15], pix3[15]));
2879 pix1 += line_size;
2880 pix2 += line_size;
2881 pix3 += line_size;
2882 }
2883 return s;
2884}
2885
2886static int pix_abs16_xy2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
2887{
2888 int s, i;
2889 uint8_t *pix3 = pix2 + line_size;
2890
2891 s = 0;
2892 for(i=0;i<h;i++) {
2893 s += abs(pix1[0] - avg4(pix2[0], pix2[1], pix3[0], pix3[1]));
2894 s += abs(pix1[1] - avg4(pix2[1], pix2[2], pix3[1], pix3[2]));
2895 s += abs(pix1[2] - avg4(pix2[2], pix2[3], pix3[2], pix3[3]));
2896 s += abs(pix1[3] - avg4(pix2[3], pix2[4], pix3[3], pix3[4]));
2897 s += abs(pix1[4] - avg4(pix2[4], pix2[5], pix3[4], pix3[5]));
2898 s += abs(pix1[5] - avg4(pix2[5], pix2[6], pix3[5], pix3[6]));
2899 s += abs(pix1[6] - avg4(pix2[6], pix2[7], pix3[6], pix3[7]));
2900 s += abs(pix1[7] - avg4(pix2[7], pix2[8], pix3[7], pix3[8]));
2901 s += abs(pix1[8] - avg4(pix2[8], pix2[9], pix3[8], pix3[9]));
2902 s += abs(pix1[9] - avg4(pix2[9], pix2[10], pix3[9], pix3[10]));
2903 s += abs(pix1[10] - avg4(pix2[10], pix2[11], pix3[10], pix3[11]));
2904 s += abs(pix1[11] - avg4(pix2[11], pix2[12], pix3[11], pix3[12]));
2905 s += abs(pix1[12] - avg4(pix2[12], pix2[13], pix3[12], pix3[13]));
2906 s += abs(pix1[13] - avg4(pix2[13], pix2[14], pix3[13], pix3[14]));
2907 s += abs(pix1[14] - avg4(pix2[14], pix2[15], pix3[14], pix3[15]));
2908 s += abs(pix1[15] - avg4(pix2[15], pix2[16], pix3[15], pix3[16]));
2909 pix1 += line_size;
2910 pix2 += line_size;
2911 pix3 += line_size;
2912 }
2913 return s;
2914}
2915
2916static inline int pix_abs8_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
2917{
2918 int s, i;
2919
2920 s = 0;
2921 for(i=0;i<h;i++) {
2922 s += abs(pix1[0] - pix2[0]);
2923 s += abs(pix1[1] - pix2[1]);
2924 s += abs(pix1[2] - pix2[2]);
2925 s += abs(pix1[3] - pix2[3]);
2926 s += abs(pix1[4] - pix2[4]);
2927 s += abs(pix1[5] - pix2[5]);
2928 s += abs(pix1[6] - pix2[6]);
2929 s += abs(pix1[7] - pix2[7]);
2930 pix1 += line_size;
2931 pix2 += line_size;
2932 }
2933 return s;
2934}
2935
2936static int pix_abs8_x2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
2937{
2938 int s, i;
2939
2940 s = 0;
2941 for(i=0;i<h;i++) {
2942 s += abs(pix1[0] - avg2(pix2[0], pix2[1]));
2943 s += abs(pix1[1] - avg2(pix2[1], pix2[2]));
2944 s += abs(pix1[2] - avg2(pix2[2], pix2[3]));
2945 s += abs(pix1[3] - avg2(pix2[3], pix2[4]));
2946 s += abs(pix1[4] - avg2(pix2[4], pix2[5]));
2947 s += abs(pix1[5] - avg2(pix2[5], pix2[6]));
2948 s += abs(pix1[6] - avg2(pix2[6], pix2[7]));
2949 s += abs(pix1[7] - avg2(pix2[7], pix2[8]));
2950 pix1 += line_size;
2951 pix2 += line_size;
2952 }
2953 return s;
2954}
2955
2956static int pix_abs8_y2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
2957{
2958 int s, i;
2959 uint8_t *pix3 = pix2 + line_size;
2960
2961 s = 0;
2962 for(i=0;i<h;i++) {
2963 s += abs(pix1[0] - avg2(pix2[0], pix3[0]));
2964 s += abs(pix1[1] - avg2(pix2[1], pix3[1]));
2965 s += abs(pix1[2] - avg2(pix2[2], pix3[2]));
2966 s += abs(pix1[3] - avg2(pix2[3], pix3[3]));
2967 s += abs(pix1[4] - avg2(pix2[4], pix3[4]));
2968 s += abs(pix1[5] - avg2(pix2[5], pix3[5]));
2969 s += abs(pix1[6] - avg2(pix2[6], pix3[6]));
2970 s += abs(pix1[7] - avg2(pix2[7], pix3[7]));
2971 pix1 += line_size;
2972 pix2 += line_size;
2973 pix3 += line_size;
2974 }
2975 return s;
2976}
2977
2978static int pix_abs8_xy2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
2979{
2980 int s, i;
2981 uint8_t *pix3 = pix2 + line_size;
2982
2983 s = 0;
2984 for(i=0;i<h;i++) {
2985 s += abs(pix1[0] - avg4(pix2[0], pix2[1], pix3[0], pix3[1]));
2986 s += abs(pix1[1] - avg4(pix2[1], pix2[2], pix3[1], pix3[2]));
2987 s += abs(pix1[2] - avg4(pix2[2], pix2[3], pix3[2], pix3[3]));
2988 s += abs(pix1[3] - avg4(pix2[3], pix2[4], pix3[3], pix3[4]));
2989 s += abs(pix1[4] - avg4(pix2[4], pix2[5], pix3[4], pix3[5]));
2990 s += abs(pix1[5] - avg4(pix2[5], pix2[6], pix3[5], pix3[6]));
2991 s += abs(pix1[6] - avg4(pix2[6], pix2[7], pix3[6], pix3[7]));
2992 s += abs(pix1[7] - avg4(pix2[7], pix2[8], pix3[7], pix3[8]));
2993 pix1 += line_size;
2994 pix2 += line_size;
2995 pix3 += line_size;
2996 }
2997 return s;
2998}
2999
3000static int nsse16_c(void *v, uint8_t *s1, uint8_t *s2, int stride, int h){
3001 MpegEncContext *c = v;
3002 int score1=0;
3003 int score2=0;
3004 int x,y;
3005
3006 for(y=0; y<h; y++){
3007 for(x=0; x<16; x++){
3008 score1+= (s1[x ] - s2[x ])*(s1[x ] - s2[x ]);
3009 }
3010 if(y+1<h){
3011 for(x=0; x<15; x++){
3012 score2+= FFABS( s1[x ] - s1[x +stride]
3013 - s1[x+1] + s1[x+1+stride])
3014 -FFABS( s2[x ] - s2[x +stride]
3015 - s2[x+1] + s2[x+1+stride]);
3016 }
3017 }
3018 s1+= stride;
3019 s2+= stride;
3020 }
3021
3022 if(c) return score1 + FFABS(score2)*c->avctx->nsse_weight;
3023 else return score1 + FFABS(score2)*8;
3024}
3025
3026static int nsse8_c(void *v, uint8_t *s1, uint8_t *s2, int stride, int h){
3027 MpegEncContext *c = v;
3028 int score1=0;
3029 int score2=0;
3030 int x,y;
3031
3032 for(y=0; y<h; y++){
3033 for(x=0; x<8; x++){
3034 score1+= (s1[x ] - s2[x ])*(s1[x ] - s2[x ]);
3035 }
3036 if(y+1<h){
3037 for(x=0; x<7; x++){
3038 score2+= FFABS( s1[x ] - s1[x +stride]
3039 - s1[x+1] + s1[x+1+stride])
3040 -FFABS( s2[x ] - s2[x +stride]
3041 - s2[x+1] + s2[x+1+stride]);
3042 }
3043 }
3044 s1+= stride;
3045 s2+= stride;
3046 }
3047
3048 if(c) return score1 + FFABS(score2)*c->avctx->nsse_weight;
3049 else return score1 + FFABS(score2)*8;
3050}
3051
3052static int try_8x8basis_c(int16_t rem[64], int16_t weight[64], int16_t basis[64], int scale){
3053 int i;
3054 unsigned int sum=0;
3055
3056 for(i=0; i<8*8; i++){
3057 int b= rem[i] + ((basis[i]*scale + (1<<(BASIS_SHIFT - RECON_SHIFT-1)))>>(BASIS_SHIFT - RECON_SHIFT));
3058 int w= weight[i];
3059 b>>= RECON_SHIFT;
3060 assert(-512<b && b<512);
3061
3062 sum += (w*b)*(w*b)>>4;
3063 }
3064 return sum>>2;
3065}
3066
3067static void add_8x8basis_c(int16_t rem[64], int16_t basis[64], int scale){
3068 int i;
3069
3070 for(i=0; i<8*8; i++){
3071 rem[i] += (basis[i]*scale + (1<<(BASIS_SHIFT - RECON_SHIFT-1)))>>(BASIS_SHIFT - RECON_SHIFT);
3072 }
3073}
3074
3075/**
3076 * permutes an 8x8 block.
3077 * @param block the block which will be permuted according to the given permutation vector
3078 * @param permutation the permutation vector
3079 * @param last the last non zero coefficient in scantable order, used to speed the permutation up
3080 * @param scantable the used scantable, this is only used to speed the permutation up, the block is not
3081 * (inverse) permutated to scantable order!
3082 */
3083void ff_block_permute(DCTELEM *block, uint8_t *permutation, const uint8_t *scantable, int last)
3084{
3085 int i;
3086 DCTELEM temp[64];
3087
3088 if(last<=0) return;
3089 //if(permutation[1]==1) return; //FIXME it is ok but not clean and might fail for some permutations
3090
3091 for(i=0; i<=last; i++){
3092 const int j= scantable[i];
3093 temp[j]= block[j];
3094 block[j]=0;
3095 }
3096
3097 for(i=0; i<=last; i++){
3098 const int j= scantable[i];
3099 const int perm_j= permutation[j];
3100 block[perm_j]= temp[j];
3101 }
3102}
3103
3104static int zero_cmp(void *s, uint8_t *a, uint8_t *b, int stride, int h){
3105 return 0;
3106}
3107
3108void ff_set_cmp(DSPContext* c, me_cmp_func *cmp, int type){
3109 int i;
3110
3111 memset(cmp, 0, sizeof(void*)*6);
3112
3113 for(i=0; i<6; i++){
3114 switch(type&0xFF){
3115 case FF_CMP_SAD:
3116 cmp[i]= c->sad[i];
3117 break;
3118 case FF_CMP_SATD:
3119 cmp[i]= c->hadamard8_diff[i];
3120 break;
3121 case FF_CMP_SSE:
3122 cmp[i]= c->sse[i];
3123 break;
3124 case FF_CMP_DCT:
3125 cmp[i]= c->dct_sad[i];
3126 break;
3127 case FF_CMP_DCT264:
3128 cmp[i]= c->dct264_sad[i];
3129 break;
3130 case FF_CMP_DCTMAX:
3131 cmp[i]= c->dct_max[i];
3132 break;
3133 case FF_CMP_PSNR:
3134 cmp[i]= c->quant_psnr[i];
3135 break;
3136 case FF_CMP_BIT:
3137 cmp[i]= c->bit[i];
3138 break;
3139 case FF_CMP_RD:
3140 cmp[i]= c->rd[i];
3141 break;
3142 case FF_CMP_VSAD:
3143 cmp[i]= c->vsad[i];
3144 break;
3145 case FF_CMP_VSSE:
3146 cmp[i]= c->vsse[i];
3147 break;
3148 case FF_CMP_ZERO:
3149 cmp[i]= zero_cmp;
3150 break;
3151 case FF_CMP_NSSE:
3152 cmp[i]= c->nsse[i];
3153 break;
3154#if CONFIG_DWT
3155 case FF_CMP_W53:
3156 cmp[i]= c->w53[i];
3157 break;
3158 case FF_CMP_W97:
3159 cmp[i]= c->w97[i];
3160 break;
3161#endif
3162 default:
3163 av_log(NULL, AV_LOG_ERROR,"internal error in cmp function selection\n");
3164 }
3165 }
3166}
3167
3168static void clear_block_c(DCTELEM *block)
3169{
3170 memset(block, 0, sizeof(DCTELEM)*64);
3171}
3172
3173/**
3174 * memset(blocks, 0, sizeof(DCTELEM)*6*64)
3175 */
3176static void clear_blocks_c(DCTELEM *blocks)
3177{
3178 memset(blocks, 0, sizeof(DCTELEM)*6*64);
3179}
3180
3181static void add_bytes_c(uint8_t *dst, uint8_t *src, int w){
3182 long i;
3183 for(i=0; i<=w-sizeof(long); i+=sizeof(long)){
3184 long a = *(long*)(src+i);
3185 long b = *(long*)(dst+i);
3186 *(long*)(dst+i) = ((a&pb_7f) + (b&pb_7f)) ^ ((a^b)&pb_80);
3187 }
3188 for(; i<w; i++)
3189 dst[i+0] += src[i+0];
3190}
3191
3192static void add_bytes_l2_c(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w){
3193 long i;
3194 for(i=0; i<=w-sizeof(long); i+=sizeof(long)){
3195 long a = *(long*)(src1+i);
3196 long b = *(long*)(src2+i);
3197 *(long*)(dst+i) = ((a&pb_7f) + (b&pb_7f)) ^ ((a^b)&pb_80);
3198 }
3199 for(; i<w; i++)
3200 dst[i] = src1[i]+src2[i];
3201}
3202
3203static void diff_bytes_c(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w){
3204 long i;
3205#if !HAVE_FAST_UNALIGNED
3206 if((long)src2 & (sizeof(long)-1)){
3207 for(i=0; i+7<w; i+=8){
3208 dst[i+0] = src1[i+0]-src2[i+0];
3209 dst[i+1] = src1[i+1]-src2[i+1];
3210 dst[i+2] = src1[i+2]-src2[i+2];
3211 dst[i+3] = src1[i+3]-src2[i+3];
3212 dst[i+4] = src1[i+4]-src2[i+4];
3213 dst[i+5] = src1[i+5]-src2[i+5];
3214 dst[i+6] = src1[i+6]-src2[i+6];
3215 dst[i+7] = src1[i+7]-src2[i+7];
3216 }
3217 }else
3218#endif
3219 for(i=0; i<=w-sizeof(long); i+=sizeof(long)){
3220 long a = *(long*)(src1+i);
3221 long b = *(long*)(src2+i);
3222 *(long*)(dst+i) = ((a|pb_80) - (b&pb_7f)) ^ ((a^b^pb_80)&pb_80);
3223 }
3224 for(; i<w; i++)
3225 dst[i+0] = src1[i+0]-src2[i+0];
3226}
3227
3228static void add_hfyu_median_prediction_c(uint8_t *dst, const uint8_t *src1, const uint8_t *diff, int w, int *left, int *left_top){
3229 int i;
3230 uint8_t l, lt;
3231
3232 l= *left;
3233 lt= *left_top;
3234
3235 for(i=0; i<w; i++){
3236 l= mid_pred(l, src1[i], (l + src1[i] - lt)&0xFF) + diff[i];
3237 lt= src1[i];
3238 dst[i]= l;
3239 }
3240
3241 *left= l;
3242 *left_top= lt;
3243}
3244
3245static void sub_hfyu_median_prediction_c(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int w, int *left, int *left_top){
3246 int i;
3247 uint8_t l, lt;
3248
3249 l= *left;
3250 lt= *left_top;
3251
3252 for(i=0; i<w; i++){
3253 const int pred= mid_pred(l, src1[i], (l + src1[i] - lt)&0xFF);
3254 lt= src1[i];
3255 l= src2[i];
3256 dst[i]= l - pred;
3257 }
3258
3259 *left= l;
3260 *left_top= lt;
3261}
3262
3263static int add_hfyu_left_prediction_c(uint8_t *dst, const uint8_t *src, int w, int acc){
3264 int i;
3265
3266 for(i=0; i<w-1; i++){
3267 acc+= src[i];
3268 dst[i]= acc;
3269 i++;
3270 acc+= src[i];
3271 dst[i]= acc;
3272 }
3273
3274 for(; i<w; i++){
3275 acc+= src[i];
3276 dst[i]= acc;
3277 }
3278
3279 return acc;
3280}
3281
3282#if HAVE_BIGENDIAN
3283#define B 3
3284#define G 2
3285#define R 1
3286#define A 0
3287#else
3288#define B 0
3289#define G 1
3290#define R 2
3291#define A 3
3292#endif
3293static void add_hfyu_left_prediction_bgr32_c(uint8_t *dst, const uint8_t *src, int w, int *red, int *green, int *blue, int *alpha){
3294 int i;
3295 int r,g,b,a;
3296 r= *red;
3297 g= *green;
3298 b= *blue;
3299 a= *alpha;
3300
3301 for(i=0; i<w; i++){
3302 b+= src[4*i+B];
3303 g+= src[4*i+G];
3304 r+= src[4*i+R];
3305 a+= src[4*i+A];
3306
3307 dst[4*i+B]= b;
3308 dst[4*i+G]= g;
3309 dst[4*i+R]= r;
3310 dst[4*i+A]= a;
3311 }
3312
3313 *red= r;
3314 *green= g;
3315 *blue= b;
3316 *alpha= a;
3317}
3318#undef B
3319#undef G
3320#undef R
3321#undef A
3322
3323#define BUTTERFLY2(o1,o2,i1,i2) \
3324o1= (i1)+(i2);\
3325o2= (i1)-(i2);
3326
3327#define BUTTERFLY1(x,y) \
3328{\
3329 int a,b;\
3330 a= x;\
3331 b= y;\
3332 x= a+b;\
3333 y= a-b;\
3334}
3335
3336#define BUTTERFLYA(x,y) (FFABS((x)+(y)) + FFABS((x)-(y)))
3337
3338static int hadamard8_diff8x8_c(/*MpegEncContext*/ void *s, uint8_t *dst, uint8_t *src, int stride, int h){
3339 int i;
3340 int temp[64];
3341 int sum=0;
3342
3343 assert(h==8);
3344
3345 for(i=0; i<8; i++){
3346 //FIXME try pointer walks
3347 BUTTERFLY2(temp[8*i+0], temp[8*i+1], src[stride*i+0]-dst[stride*i+0],src[stride*i+1]-dst[stride*i+1]);
3348 BUTTERFLY2(temp[8*i+2], temp[8*i+3], src[stride*i+2]-dst[stride*i+2],src[stride*i+3]-dst[stride*i+3]);
3349 BUTTERFLY2(temp[8*i+4], temp[8*i+5], src[stride*i+4]-dst[stride*i+4],src[stride*i+5]-dst[stride*i+5]);
3350 BUTTERFLY2(temp[8*i+6], temp[8*i+7], src[stride*i+6]-dst[stride*i+6],src[stride*i+7]-dst[stride*i+7]);
3351
3352 BUTTERFLY1(temp[8*i+0], temp[8*i+2]);
3353 BUTTERFLY1(temp[8*i+1], temp[8*i+3]);
3354 BUTTERFLY1(temp[8*i+4], temp[8*i+6]);
3355 BUTTERFLY1(temp[8*i+5], temp[8*i+7]);
3356
3357 BUTTERFLY1(temp[8*i+0], temp[8*i+4]);
3358 BUTTERFLY1(temp[8*i+1], temp[8*i+5]);
3359 BUTTERFLY1(temp[8*i+2], temp[8*i+6]);
3360 BUTTERFLY1(temp[8*i+3], temp[8*i+7]);
3361 }
3362
3363 for(i=0; i<8; i++){
3364 BUTTERFLY1(temp[8*0+i], temp[8*1+i]);
3365 BUTTERFLY1(temp[8*2+i], temp[8*3+i]);
3366 BUTTERFLY1(temp[8*4+i], temp[8*5+i]);
3367 BUTTERFLY1(temp[8*6+i], temp[8*7+i]);
3368
3369 BUTTERFLY1(temp[8*0+i], temp[8*2+i]);
3370 BUTTERFLY1(temp[8*1+i], temp[8*3+i]);
3371 BUTTERFLY1(temp[8*4+i], temp[8*6+i]);
3372 BUTTERFLY1(temp[8*5+i], temp[8*7+i]);
3373
3374 sum +=
3375 BUTTERFLYA(temp[8*0+i], temp[8*4+i])
3376 +BUTTERFLYA(temp[8*1+i], temp[8*5+i])
3377 +BUTTERFLYA(temp[8*2+i], temp[8*6+i])
3378 +BUTTERFLYA(temp[8*3+i], temp[8*7+i]);
3379 }
3380#if 0
3381static int maxi=0;
3382if(sum>maxi){
3383 maxi=sum;
3384 printf("MAX:%d\n", maxi);
3385}
3386#endif
3387 return sum;
3388}
3389
3390static int hadamard8_intra8x8_c(/*MpegEncContext*/ void *s, uint8_t *src, uint8_t *dummy, int stride, int h){
3391 int i;
3392 int temp[64];
3393 int sum=0;
3394
3395 assert(h==8);
3396
3397 for(i=0; i<8; i++){
3398 //FIXME try pointer walks
3399 BUTTERFLY2(temp[8*i+0], temp[8*i+1], src[stride*i+0],src[stride*i+1]);
3400 BUTTERFLY2(temp[8*i+2], temp[8*i+3], src[stride*i+2],src[stride*i+3]);
3401 BUTTERFLY2(temp[8*i+4], temp[8*i+5], src[stride*i+4],src[stride*i+5]);
3402 BUTTERFLY2(temp[8*i+6], temp[8*i+7], src[stride*i+6],src[stride*i+7]);
3403
3404 BUTTERFLY1(temp[8*i+0], temp[8*i+2]);
3405 BUTTERFLY1(temp[8*i+1], temp[8*i+3]);
3406 BUTTERFLY1(temp[8*i+4], temp[8*i+6]);
3407 BUTTERFLY1(temp[8*i+5], temp[8*i+7]);
3408
3409 BUTTERFLY1(temp[8*i+0], temp[8*i+4]);
3410 BUTTERFLY1(temp[8*i+1], temp[8*i+5]);
3411 BUTTERFLY1(temp[8*i+2], temp[8*i+6]);
3412 BUTTERFLY1(temp[8*i+3], temp[8*i+7]);
3413 }
3414
3415 for(i=0; i<8; i++){
3416 BUTTERFLY1(temp[8*0+i], temp[8*1+i]);
3417 BUTTERFLY1(temp[8*2+i], temp[8*3+i]);
3418 BUTTERFLY1(temp[8*4+i], temp[8*5+i]);
3419 BUTTERFLY1(temp[8*6+i], temp[8*7+i]);
3420
3421 BUTTERFLY1(temp[8*0+i], temp[8*2+i]);
3422 BUTTERFLY1(temp[8*1+i], temp[8*3+i]);
3423 BUTTERFLY1(temp[8*4+i], temp[8*6+i]);
3424 BUTTERFLY1(temp[8*5+i], temp[8*7+i]);
3425
3426 sum +=
3427 BUTTERFLYA(temp[8*0+i], temp[8*4+i])
3428 +BUTTERFLYA(temp[8*1+i], temp[8*5+i])
3429 +BUTTERFLYA(temp[8*2+i], temp[8*6+i])
3430 +BUTTERFLYA(temp[8*3+i], temp[8*7+i]);
3431 }
3432
3433 sum -= FFABS(temp[8*0] + temp[8*4]); // -mean
3434
3435 return sum;
3436}
3437
3438static int dct_sad8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){
3439 MpegEncContext * const s= (MpegEncContext *)c;
3440 LOCAL_ALIGNED_16(DCTELEM, temp, [64]);
3441
3442 assert(h==8);
3443
3444 s->dsp.diff_pixels(temp, src1, src2, stride);
3445 s->dsp.fdct(temp);
3446 return s->dsp.sum_abs_dctelem(temp);
3447}
3448
3449#if CONFIG_GPL
3450#define DCT8_1D {\
3451 const int s07 = SRC(0) + SRC(7);\
3452 const int s16 = SRC(1) + SRC(6);\
3453 const int s25 = SRC(2) + SRC(5);\
3454 const int s34 = SRC(3) + SRC(4);\
3455 const int a0 = s07 + s34;\
3456 const int a1 = s16 + s25;\
3457 const int a2 = s07 - s34;\
3458 const int a3 = s16 - s25;\
3459 const int d07 = SRC(0) - SRC(7);\
3460 const int d16 = SRC(1) - SRC(6);\
3461 const int d25 = SRC(2) - SRC(5);\
3462 const int d34 = SRC(3) - SRC(4);\
3463 const int a4 = d16 + d25 + (d07 + (d07>>1));\
3464 const int a5 = d07 - d34 - (d25 + (d25>>1));\
3465 const int a6 = d07 + d34 - (d16 + (d16>>1));\
3466 const int a7 = d16 - d25 + (d34 + (d34>>1));\
3467 DST(0, a0 + a1 ) ;\
3468 DST(1, a4 + (a7>>2)) ;\
3469 DST(2, a2 + (a3>>1)) ;\
3470 DST(3, a5 + (a6>>2)) ;\
3471 DST(4, a0 - a1 ) ;\
3472 DST(5, a6 - (a5>>2)) ;\
3473 DST(6, (a2>>1) - a3 ) ;\
3474 DST(7, (a4>>2) - a7 ) ;\
3475}
3476
3477static int dct264_sad8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){
3478 MpegEncContext * const s= (MpegEncContext *)c;
3479 DCTELEM dct[8][8];
3480 int i;
3481 int sum=0;
3482
3483 s->dsp.diff_pixels(dct[0], src1, src2, stride);
3484
3485#define SRC(x) dct[i][x]
3486#define DST(x,v) dct[i][x]= v
3487 for( i = 0; i < 8; i++ )
3488 DCT8_1D
3489#undef SRC
3490#undef DST
3491
3492#define SRC(x) dct[x][i]
3493#define DST(x,v) sum += FFABS(v)
3494 for( i = 0; i < 8; i++ )
3495 DCT8_1D
3496#undef SRC
3497#undef DST
3498 return sum;
3499}
3500#endif
3501
3502static int dct_max8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){
3503 MpegEncContext * const s= (MpegEncContext *)c;
3504 LOCAL_ALIGNED_16(DCTELEM, temp, [64]);
3505 int sum=0, i;
3506
3507 assert(h==8);
3508
3509 s->dsp.diff_pixels(temp, src1, src2, stride);
3510 s->dsp.fdct(temp);
3511
3512 for(i=0; i<64; i++)
3513 sum= FFMAX(sum, FFABS(temp[i]));
3514
3515 return sum;
3516}
3517
3518static int quant_psnr8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){
3519 MpegEncContext * const s= (MpegEncContext *)c;
3520 LOCAL_ALIGNED_16(DCTELEM, temp, [64*2]);
3521 DCTELEM * const bak = temp+64;
3522 int sum=0, i;
3523
3524 assert(h==8);
3525 s->mb_intra=0;
3526
3527 s->dsp.diff_pixels(temp, src1, src2, stride);
3528
3529 memcpy(bak, temp, 64*sizeof(DCTELEM));
3530
3531 s->block_last_index[0/*FIXME*/]= s->fast_dct_quantize(s, temp, 0/*FIXME*/, s->qscale, &i);
3532 s->dct_unquantize_inter(s, temp, 0, s->qscale);
3533 ff_simple_idct(temp); //FIXME
3534
3535 for(i=0; i<64; i++)
3536 sum+= (temp[i]-bak[i])*(temp[i]-bak[i]);
3537
3538 return sum;
3539}
3540
3541static int rd8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){
3542 MpegEncContext * const s= (MpegEncContext *)c;
3543 const uint8_t *scantable= s->intra_scantable.permutated;
3544 LOCAL_ALIGNED_16(DCTELEM, temp, [64]);
3545 LOCAL_ALIGNED_16(uint8_t, lsrc1, [64]);
3546 LOCAL_ALIGNED_16(uint8_t, lsrc2, [64]);
3547 int i, last, run, bits, level, distortion, start_i;
3548 const int esc_length= s->ac_esc_length;
3549 uint8_t * length;
3550 uint8_t * last_length;
3551
3552 assert(h==8);
3553
3554 copy_block8(lsrc1, src1, 8, stride, 8);
3555 copy_block8(lsrc2, src2, 8, stride, 8);
3556
3557 s->dsp.diff_pixels(temp, lsrc1, lsrc2, 8);
3558
3559 s->block_last_index[0/*FIXME*/]= last= s->fast_dct_quantize(s, temp, 0/*FIXME*/, s->qscale, &i);
3560
3561 bits=0;
3562
3563 if (s->mb_intra) {
3564 start_i = 1;
3565 length = s->intra_ac_vlc_length;
3566 last_length= s->intra_ac_vlc_last_length;
3567 bits+= s->luma_dc_vlc_length[temp[0] + 256]; //FIXME chroma
3568 } else {
3569 start_i = 0;
3570 length = s->inter_ac_vlc_length;
3571 last_length= s->inter_ac_vlc_last_length;
3572 }
3573
3574 if(last>=start_i){
3575 run=0;
3576 for(i=start_i; i<last; i++){
3577 int j= scantable[i];
3578 level= temp[j];
3579
3580 if(level){
3581 level+=64;
3582 if((level&(~127)) == 0){
3583 bits+= length[UNI_AC_ENC_INDEX(run, level)];
3584 }else
3585 bits+= esc_length;
3586 run=0;
3587 }else
3588 run++;
3589 }
3590 i= scantable[last];
3591
3592 level= temp[i] + 64;
3593
3594 assert(level - 64);
3595
3596 if((level&(~127)) == 0){
3597 bits+= last_length[UNI_AC_ENC_INDEX(run, level)];
3598 }else
3599 bits+= esc_length;
3600
3601 }
3602
3603 if(last>=0){
3604 if(s->mb_intra)
3605 s->dct_unquantize_intra(s, temp, 0, s->qscale);
3606 else
3607 s->dct_unquantize_inter(s, temp, 0, s->qscale);
3608 }
3609
3610 s->dsp.idct_add(lsrc2, 8, temp);
3611
3612 distortion= s->dsp.sse[1](NULL, lsrc2, lsrc1, 8, 8);
3613
3614 return distortion + ((bits*s->qscale*s->qscale*109 + 64)>>7);
3615}
3616
3617static int bit8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){
3618 MpegEncContext * const s= (MpegEncContext *)c;
3619 const uint8_t *scantable= s->intra_scantable.permutated;
3620 LOCAL_ALIGNED_16(DCTELEM, temp, [64]);
3621 int i, last, run, bits, level, start_i;
3622 const int esc_length= s->ac_esc_length;
3623 uint8_t * length;
3624 uint8_t * last_length;
3625
3626 assert(h==8);
3627
3628 s->dsp.diff_pixels(temp, src1, src2, stride);
3629
3630 s->block_last_index[0/*FIXME*/]= last= s->fast_dct_quantize(s, temp, 0/*FIXME*/, s->qscale, &i);
3631
3632 bits=0;
3633
3634 if (s->mb_intra) {
3635 start_i = 1;
3636 length = s->intra_ac_vlc_length;
3637 last_length= s->intra_ac_vlc_last_length;
3638 bits+= s->luma_dc_vlc_length[temp[0] + 256]; //FIXME chroma
3639 } else {
3640 start_i = 0;
3641 length = s->inter_ac_vlc_length;
3642 last_length= s->inter_ac_vlc_last_length;
3643 }
3644
3645 if(last>=start_i){
3646 run=0;
3647 for(i=start_i; i<last; i++){
3648 int j= scantable[i];
3649 level= temp[j];
3650
3651 if(level){
3652 level+=64;
3653 if((level&(~127)) == 0){
3654 bits+= length[UNI_AC_ENC_INDEX(run, level)];
3655 }else
3656 bits+= esc_length;
3657 run=0;
3658 }else
3659 run++;
3660 }
3661 i= scantable[last];
3662
3663 level= temp[i] + 64;
3664
3665 assert(level - 64);
3666
3667 if((level&(~127)) == 0){
3668 bits+= last_length[UNI_AC_ENC_INDEX(run, level)];
3669 }else
3670 bits+= esc_length;
3671 }
3672
3673 return bits;
3674}
3675
3676#define VSAD_INTRA(size) \
3677static int vsad_intra##size##_c(/*MpegEncContext*/ void *c, uint8_t *s, uint8_t *dummy, int stride, int h){ \
3678 int score=0; \
3679 int x,y; \
3680 \
3681 for(y=1; y<h; y++){ \
3682 for(x=0; x<size; x+=4){ \
3683 score+= FFABS(s[x ] - s[x +stride]) + FFABS(s[x+1] - s[x+1+stride]) \
3684 +FFABS(s[x+2] - s[x+2+stride]) + FFABS(s[x+3] - s[x+3+stride]); \
3685 } \
3686 s+= stride; \
3687 } \
3688 \
3689 return score; \
3690}
3691VSAD_INTRA(8)
3692VSAD_INTRA(16)
3693
3694static int vsad16_c(/*MpegEncContext*/ void *c, uint8_t *s1, uint8_t *s2, int stride, int h){
3695 int score=0;
3696 int x,y;
3697
3698 for(y=1; y<h; y++){
3699 for(x=0; x<16; x++){
3700 score+= FFABS(s1[x ] - s2[x ] - s1[x +stride] + s2[x +stride]);
3701 }
3702 s1+= stride;
3703 s2+= stride;
3704 }
3705
3706 return score;
3707}
3708
3709#define SQ(a) ((a)*(a))
3710#define VSSE_INTRA(size) \
3711static int vsse_intra##size##_c(/*MpegEncContext*/ void *c, uint8_t *s, uint8_t *dummy, int stride, int h){ \
3712 int score=0; \
3713 int x,y; \
3714 \
3715 for(y=1; y<h; y++){ \
3716 for(x=0; x<size; x+=4){ \
3717 score+= SQ(s[x ] - s[x +stride]) + SQ(s[x+1] - s[x+1+stride]) \
3718 +SQ(s[x+2] - s[x+2+stride]) + SQ(s[x+3] - s[x+3+stride]); \
3719 } \
3720 s+= stride; \
3721 } \
3722 \
3723 return score; \
3724}
3725VSSE_INTRA(8)
3726VSSE_INTRA(16)
3727
3728static int vsse16_c(/*MpegEncContext*/ void *c, uint8_t *s1, uint8_t *s2, int stride, int h){
3729 int score=0;
3730 int x,y;
3731
3732 for(y=1; y<h; y++){
3733 for(x=0; x<16; x++){
3734 score+= SQ(s1[x ] - s2[x ] - s1[x +stride] + s2[x +stride]);
3735 }
3736 s1+= stride;
3737 s2+= stride;
3738 }
3739
3740 return score;
3741}
3742
3743static int ssd_int8_vs_int16_c(const int8_t *pix1, const int16_t *pix2,
3744 int size){
3745 int score=0;
3746 int i;
3747 for(i=0; i<size; i++)
3748 score += (pix1[i]-pix2[i])*(pix1[i]-pix2[i]);
3749 return score;
3750}
3751
3752WRAPPER8_16_SQ(hadamard8_diff8x8_c, hadamard8_diff16_c)
3753WRAPPER8_16_SQ(hadamard8_intra8x8_c, hadamard8_intra16_c)
3754WRAPPER8_16_SQ(dct_sad8x8_c, dct_sad16_c)
3755#if CONFIG_GPL
3756WRAPPER8_16_SQ(dct264_sad8x8_c, dct264_sad16_c)
3757#endif
3758WRAPPER8_16_SQ(dct_max8x8_c, dct_max16_c)
3759WRAPPER8_16_SQ(quant_psnr8x8_c, quant_psnr16_c)
3760WRAPPER8_16_SQ(rd8x8_c, rd16_c)
3761WRAPPER8_16_SQ(bit8x8_c, bit16_c)
3762
3763static void vector_fmul_c(float *dst, const float *src, int len){
3764 int i;
3765 for(i=0; i<len; i++)
3766 dst[i] *= src[i];
3767}
3768
3769static void vector_fmul_reverse_c(float *dst, const float *src0, const float *src1, int len){
3770 int i;
3771 src1 += len-1;
3772 for(i=0; i<len; i++)
3773 dst[i] = src0[i] * src1[-i];
3774}
3775
3776static void vector_fmul_add_c(float *dst, const float *src0, const float *src1, const float *src2, int len){
3777 int i;
3778 for(i=0; i<len; i++)
3779 dst[i] = src0[i] * src1[i] + src2[i];
3780}
3781
3782void ff_vector_fmul_window_c(float *dst, const float *src0, const float *src1, const float *win, float add_bias, int len){
3783 int i,j;
3784 dst += len;
3785 win += len;
3786 src0+= len;
3787 for(i=-len, j=len-1; i<0; i++, j--) {
3788 float s0 = src0[i];
3789 float s1 = src1[j];
3790 float wi = win[i];
3791 float wj = win[j];
3792 dst[i] = s0*wj - s1*wi + add_bias;
3793 dst[j] = s0*wi + s1*wj + add_bias;
3794 }
3795}
3796
3797static void vector_fmul_scalar_c(float *dst, const float *src, float mul,
3798 int len)
3799{
3800 int i;
3801 for (i = 0; i < len; i++)
3802 dst[i] = src[i] * mul;
3803}
3804
3805static void vector_fmul_sv_scalar_2_c(float *dst, const float *src,
3806 const float **sv, float mul, int len)
3807{
3808 int i;
3809 for (i = 0; i < len; i += 2, sv++) {
3810 dst[i ] = src[i ] * sv[0][0] * mul;
3811 dst[i+1] = src[i+1] * sv[0][1] * mul;
3812 }
3813}
3814
3815static void vector_fmul_sv_scalar_4_c(float *dst, const float *src,
3816 const float **sv, float mul, int len)
3817{
3818 int i;
3819 for (i = 0; i < len; i += 4, sv++) {
3820 dst[i ] = src[i ] * sv[0][0] * mul;
3821 dst[i+1] = src[i+1] * sv[0][1] * mul;
3822 dst[i+2] = src[i+2] * sv[0][2] * mul;
3823 dst[i+3] = src[i+3] * sv[0][3] * mul;
3824 }
3825}
3826
3827static void sv_fmul_scalar_2_c(float *dst, const float **sv, float mul,
3828 int len)
3829{
3830 int i;
3831 for (i = 0; i < len; i += 2, sv++) {
3832 dst[i ] = sv[0][0] * mul;
3833 dst[i+1] = sv[0][1] * mul;
3834 }
3835}
3836
3837static void sv_fmul_scalar_4_c(float *dst, const float **sv, float mul,
3838 int len)
3839{
3840 int i;
3841 for (i = 0; i < len; i += 4, sv++) {
3842 dst[i ] = sv[0][0] * mul;
3843 dst[i+1] = sv[0][1] * mul;
3844 dst[i+2] = sv[0][2] * mul;
3845 dst[i+3] = sv[0][3] * mul;
3846 }
3847}
3848
3849static void butterflies_float_c(float *restrict v1, float *restrict v2,
3850 int len)
3851{
3852 int i;
3853 for (i = 0; i < len; i++) {
3854 float t = v1[i] - v2[i];
3855 v1[i] += v2[i];
3856 v2[i] = t;
3857 }
3858}
3859
3860static float scalarproduct_float_c(const float *v1, const float *v2, int len)
3861{
3862 float p = 0.0;
3863 int i;
3864
3865 for (i = 0; i < len; i++)
3866 p += v1[i] * v2[i];
3867
3868 return p;
3869}
3870
3871static void int32_to_float_fmul_scalar_c(float *dst, const int *src, float mul, int len){
3872 int i;
3873 for(i=0; i<len; i++)
3874 dst[i] = src[i] * mul;
3875}
3876
3877static inline uint32_t clipf_c_one(uint32_t a, uint32_t mini,
3878 uint32_t maxi, uint32_t maxisign)
3879{
3880
3881 if(a > mini) return mini;
3882 else if((a^(1<<31)) > maxisign) return maxi;
3883 else return a;
3884}
3885
3886static void vector_clipf_c_opposite_sign(float *dst, const float *src, float *min, float *max, int len){
3887 int i;
3888 uint32_t mini = *(uint32_t*)min;
3889 uint32_t maxi = *(uint32_t*)max;
3890 uint32_t maxisign = maxi ^ (1<<31);
3891 uint32_t *dsti = (uint32_t*)dst;
3892 const uint32_t *srci = (const uint32_t*)src;
3893 for(i=0; i<len; i+=8) {
3894 dsti[i + 0] = clipf_c_one(srci[i + 0], mini, maxi, maxisign);
3895 dsti[i + 1] = clipf_c_one(srci[i + 1], mini, maxi, maxisign);
3896 dsti[i + 2] = clipf_c_one(srci[i + 2], mini, maxi, maxisign);
3897 dsti[i + 3] = clipf_c_one(srci[i + 3], mini, maxi, maxisign);
3898 dsti[i + 4] = clipf_c_one(srci[i + 4], mini, maxi, maxisign);
3899 dsti[i + 5] = clipf_c_one(srci[i + 5], mini, maxi, maxisign);
3900 dsti[i + 6] = clipf_c_one(srci[i + 6], mini, maxi, maxisign);
3901 dsti[i + 7] = clipf_c_one(srci[i + 7], mini, maxi, maxisign);
3902 }
3903}
3904static void vector_clipf_c(float *dst, const float *src, float min, float max, int len){
3905 int i;
3906 if(min < 0 && max > 0) {
3907 vector_clipf_c_opposite_sign(dst, src, &min, &max, len);
3908 } else {
3909 for(i=0; i < len; i+=8) {
3910 dst[i ] = av_clipf(src[i ], min, max);
3911 dst[i + 1] = av_clipf(src[i + 1], min, max);
3912 dst[i + 2] = av_clipf(src[i + 2], min, max);
3913 dst[i + 3] = av_clipf(src[i + 3], min, max);
3914 dst[i + 4] = av_clipf(src[i + 4], min, max);
3915 dst[i + 5] = av_clipf(src[i + 5], min, max);
3916 dst[i + 6] = av_clipf(src[i + 6], min, max);
3917 dst[i + 7] = av_clipf(src[i + 7], min, max);
3918 }
3919 }
3920}
3921
3922static av_always_inline int float_to_int16_one(const float *src){
3923 int_fast32_t tmp = *(const int32_t*)src;
3924 if(tmp & 0xf0000){
3925 tmp = (0x43c0ffff - tmp)>>31;
3926 // is this faster on some gcc/cpu combinations?
3927// if(tmp > 0x43c0ffff) tmp = 0xFFFF;
3928// else tmp = 0;
3929 }
3930 return tmp - 0x8000;
3931}
3932
3933void ff_float_to_int16_c(int16_t *dst, const float *src, long len){
3934 int i;
3935 for(i=0; i<len; i++)
3936 dst[i] = float_to_int16_one(src+i);
3937}
3938
3939void ff_float_to_int16_interleave_c(int16_t *dst, const float **src, long len, int channels){
3940 int i,j,c;
3941 if(channels==2){
3942 for(i=0; i<len; i++){
3943 dst[2*i] = float_to_int16_one(src[0]+i);
3944 dst[2*i+1] = float_to_int16_one(src[1]+i);
3945 }
3946 }else{
3947 for(c=0; c<channels; c++)
3948 for(i=0, j=c; i<len; i++, j+=channels)
3949 dst[j] = float_to_int16_one(src[c]+i);
3950 }
3951}
3952
3953static int32_t scalarproduct_int16_c(const int16_t * v1, const int16_t * v2, int order, int shift)
3954{
3955 int res = 0;
3956
3957 while (order--)
3958 res += (*v1++ * *v2++) >> shift;
3959
3960 return res;
3961}
3962
3963static int32_t scalarproduct_and_madd_int16_c(int16_t *v1, const int16_t *v2, const int16_t *v3, int order, int mul)
3964{
3965 int res = 0;
3966 while (order--) {
3967 res += *v1 * *v2++;
3968 *v1++ += mul * *v3++;
3969 }
3970 return res;
3971}
3972
3973#define W0 2048
3974#define W1 2841 /* 2048*sqrt (2)*cos (1*pi/16) */
3975#define W2 2676 /* 2048*sqrt (2)*cos (2*pi/16) */
3976#define W3 2408 /* 2048*sqrt (2)*cos (3*pi/16) */
3977#define W4 2048 /* 2048*sqrt (2)*cos (4*pi/16) */
3978#define W5 1609 /* 2048*sqrt (2)*cos (5*pi/16) */
3979#define W6 1108 /* 2048*sqrt (2)*cos (6*pi/16) */
3980#define W7 565 /* 2048*sqrt (2)*cos (7*pi/16) */
3981
3982static void wmv2_idct_row(short * b)
3983{
3984 int s1,s2;
3985 int a0,a1,a2,a3,a4,a5,a6,a7;
3986 /*step 1*/
3987 a1 = W1*b[1]+W7*b[7];
3988 a7 = W7*b[1]-W1*b[7];
3989 a5 = W5*b[5]+W3*b[3];
3990 a3 = W3*b[5]-W5*b[3];
3991 a2 = W2*b[2]+W6*b[6];
3992 a6 = W6*b[2]-W2*b[6];
3993 a0 = W0*b[0]+W0*b[4];
3994 a4 = W0*b[0]-W0*b[4];
3995 /*step 2*/
3996 s1 = (181*(a1-a5+a7-a3)+128)>>8;//1,3,5,7,
3997 s2 = (181*(a1-a5-a7+a3)+128)>>8;
3998 /*step 3*/
3999 b[0] = (a0+a2+a1+a5 + (1<<7))>>8;
4000 b[1] = (a4+a6 +s1 + (1<<7))>>8;
4001 b[2] = (a4-a6 +s2 + (1<<7))>>8;
4002 b[3] = (a0-a2+a7+a3 + (1<<7))>>8;
4003 b[4] = (a0-a2-a7-a3 + (1<<7))>>8;
4004 b[5] = (a4-a6 -s2 + (1<<7))>>8;
4005 b[6] = (a4+a6 -s1 + (1<<7))>>8;
4006 b[7] = (a0+a2-a1-a5 + (1<<7))>>8;
4007}
4008static void wmv2_idct_col(short * b)
4009{
4010 int s1,s2;
4011 int a0,a1,a2,a3,a4,a5,a6,a7;
4012 /*step 1, with extended precision*/
4013 a1 = (W1*b[8*1]+W7*b[8*7] + 4)>>3;
4014 a7 = (W7*b[8*1]-W1*b[8*7] + 4)>>3;
4015 a5 = (W5*b[8*5]+W3*b[8*3] + 4)>>3;
4016 a3 = (W3*b[8*5]-W5*b[8*3] + 4)>>3;
4017 a2 = (W2*b[8*2]+W6*b[8*6] + 4)>>3;
4018 a6 = (W6*b[8*2]-W2*b[8*6] + 4)>>3;
4019 a0 = (W0*b[8*0]+W0*b[8*4] )>>3;
4020 a4 = (W0*b[8*0]-W0*b[8*4] )>>3;
4021 /*step 2*/
4022 s1 = (181*(a1-a5+a7-a3)+128)>>8;
4023 s2 = (181*(a1-a5-a7+a3)+128)>>8;
4024 /*step 3*/
4025 b[8*0] = (a0+a2+a1+a5 + (1<<13))>>14;
4026 b[8*1] = (a4+a6 +s1 + (1<<13))>>14;
4027 b[8*2] = (a4-a6 +s2 + (1<<13))>>14;
4028 b[8*3] = (a0-a2+a7+a3 + (1<<13))>>14;
4029
4030 b[8*4] = (a0-a2-a7-a3 + (1<<13))>>14;
4031 b[8*5] = (a4-a6 -s2 + (1<<13))>>14;
4032 b[8*6] = (a4+a6 -s1 + (1<<13))>>14;
4033 b[8*7] = (a0+a2-a1-a5 + (1<<13))>>14;
4034}
4035void ff_wmv2_idct_c(short * block){
4036 int i;
4037
4038 for(i=0;i<64;i+=8){
4039 wmv2_idct_row(block+i);
4040 }
4041 for(i=0;i<8;i++){
4042 wmv2_idct_col(block+i);
4043 }
4044}
4045/* XXX: those functions should be suppressed ASAP when all IDCTs are
4046 converted */
4047static void ff_wmv2_idct_put_c(uint8_t *dest, int line_size, DCTELEM *block)
4048{
4049 ff_wmv2_idct_c(block);
4050 put_pixels_clamped_c(block, dest, line_size);
4051}
4052static void ff_wmv2_idct_add_c(uint8_t *dest, int line_size, DCTELEM *block)
4053{
4054 ff_wmv2_idct_c(block);
4055 add_pixels_clamped_c(block, dest, line_size);
4056}
4057static void ff_jref_idct_put(uint8_t *dest, int line_size, DCTELEM *block)
4058{
4059 j_rev_dct (block);
4060 put_pixels_clamped_c(block, dest, line_size);
4061}
4062static void ff_jref_idct_add(uint8_t *dest, int line_size, DCTELEM *block)
4063{
4064 j_rev_dct (block);
4065 add_pixels_clamped_c(block, dest, line_size);
4066}
4067
4068static void ff_jref_idct4_put(uint8_t *dest, int line_size, DCTELEM *block)
4069{
4070 j_rev_dct4 (block);
4071 put_pixels_clamped4_c(block, dest, line_size);
4072}
4073static void ff_jref_idct4_add(uint8_t *dest, int line_size, DCTELEM *block)
4074{
4075 j_rev_dct4 (block);
4076 add_pixels_clamped4_c(block, dest, line_size);
4077}
4078
4079static void ff_jref_idct2_put(uint8_t *dest, int line_size, DCTELEM *block)
4080{
4081 j_rev_dct2 (block);
4082 put_pixels_clamped2_c(block, dest, line_size);
4083}
4084static void ff_jref_idct2_add(uint8_t *dest, int line_size, DCTELEM *block)
4085{
4086 j_rev_dct2 (block);
4087 add_pixels_clamped2_c(block, dest, line_size);
4088}
4089
4090static void ff_jref_idct1_put(uint8_t *dest, int line_size, DCTELEM *block)
4091{
4092 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
4093
4094 dest[0] = cm[(block[0] + 4)>>3];
4095}
4096static void ff_jref_idct1_add(uint8_t *dest, int line_size, DCTELEM *block)
4097{
4098 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
4099
4100 dest[0] = cm[dest[0] + ((block[0] + 4)>>3)];
4101}
4102
4103static void just_return(void *mem av_unused, int stride av_unused, int h av_unused) { return; }
4104
4105/* init static data */
4106av_cold void dsputil_static_init(void)
4107{
4108 int i;
4109
4110 for(i=0;i<256;i++) ff_cropTbl[i + MAX_NEG_CROP] = i;
4111 for(i=0;i<MAX_NEG_CROP;i++) {
4112 ff_cropTbl[i] = 0;
4113 ff_cropTbl[i + MAX_NEG_CROP + 256] = 255;
4114 }
4115
4116 for(i=0;i<512;i++) {
4117 ff_squareTbl[i] = (i - 256) * (i - 256);
4118 }
4119
4120 for(i=0; i<64; i++) inv_zigzag_direct16[ff_zigzag_direct[i]]= i+1;
4121}
4122
4123int ff_check_alignment(void){
4124 static int did_fail=0;
4125 DECLARE_ALIGNED(16, int, aligned);
4126
4127 if((intptr_t)&aligned & 15){
4128 if(!did_fail){
4129#if HAVE_MMX || HAVE_ALTIVEC
4130 av_log(NULL, AV_LOG_ERROR,
4131 "Compiler did not align stack variables. Libavcodec has been miscompiled\n"
4132 "and may be very slow or crash. This is not a bug in libavcodec,\n"
4133 "but in the compiler. You may try recompiling using gcc >= 4.2.\n"
4134 "Do not report crashes to FFmpeg developers.\n");
4135#endif
4136 did_fail=1;
4137 }
4138 return -1;
4139 }
4140 return 0;
4141}
4142
4143av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx)
4144{
4145 int i;
4146
4147 ff_check_alignment();
4148
4149#if CONFIG_ENCODERS
4150 if(avctx->dct_algo==FF_DCT_FASTINT) {
4151 c->fdct = fdct_ifast;
4152 c->fdct248 = fdct_ifast248;
4153 }
4154 else if(avctx->dct_algo==FF_DCT_FAAN) {
4155 c->fdct = ff_faandct;
4156 c->fdct248 = ff_faandct248;
4157 }
4158 else {
4159 c->fdct = ff_jpeg_fdct_islow; //slow/accurate/default
4160 c->fdct248 = ff_fdct248_islow;
4161 }
4162#endif //CONFIG_ENCODERS
4163
4164 if(avctx->lowres==1){
4165 if(avctx->idct_algo==FF_IDCT_INT || avctx->idct_algo==FF_IDCT_AUTO || !CONFIG_H264_DECODER){
4166 c->idct_put= ff_jref_idct4_put;
4167 c->idct_add= ff_jref_idct4_add;
4168 }else{
4169 c->idct_put= ff_h264_lowres_idct_put_c;
4170 c->idct_add= ff_h264_lowres_idct_add_c;
4171 }
4172 c->idct = j_rev_dct4;
4173 c->idct_permutation_type= FF_NO_IDCT_PERM;
4174 }else if(avctx->lowres==2){
4175 c->idct_put= ff_jref_idct2_put;
4176 c->idct_add= ff_jref_idct2_add;
4177 c->idct = j_rev_dct2;
4178 c->idct_permutation_type= FF_NO_IDCT_PERM;
4179 }else if(avctx->lowres==3){
4180 c->idct_put= ff_jref_idct1_put;
4181 c->idct_add= ff_jref_idct1_add;
4182 c->idct = j_rev_dct1;
4183 c->idct_permutation_type= FF_NO_IDCT_PERM;
4184 }else{
4185 if(avctx->idct_algo==FF_IDCT_INT){
4186 c->idct_put= ff_jref_idct_put;
4187 c->idct_add= ff_jref_idct_add;
4188 c->idct = j_rev_dct;
4189 c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM;
4190 }else if((CONFIG_VP3_DECODER || CONFIG_VP5_DECODER || CONFIG_VP6_DECODER ) &&
4191 avctx->idct_algo==FF_IDCT_VP3){
4192 c->idct_put= ff_vp3_idct_put_c;
4193 c->idct_add= ff_vp3_idct_add_c;
4194 c->idct = ff_vp3_idct_c;
4195 c->idct_permutation_type= FF_NO_IDCT_PERM;
4196 }else if(avctx->idct_algo==FF_IDCT_WMV2){
4197 c->idct_put= ff_wmv2_idct_put_c;
4198 c->idct_add= ff_wmv2_idct_add_c;
4199 c->idct = ff_wmv2_idct_c;
4200 c->idct_permutation_type= FF_NO_IDCT_PERM;
4201 }else if(avctx->idct_algo==FF_IDCT_FAAN){
4202 c->idct_put= ff_faanidct_put;
4203 c->idct_add= ff_faanidct_add;
4204 c->idct = ff_faanidct;
4205 c->idct_permutation_type= FF_NO_IDCT_PERM;
4206 }else if(CONFIG_EATGQ_DECODER && avctx->idct_algo==FF_IDCT_EA) {
4207 c->idct_put= ff_ea_idct_put_c;
4208 c->idct_permutation_type= FF_NO_IDCT_PERM;
4209 }else if(CONFIG_BINK_DECODER && avctx->idct_algo==FF_IDCT_BINK) {
4210 c->idct = ff_bink_idct_c;
4211 c->idct_add = ff_bink_idct_add_c;
4212 c->idct_put = ff_bink_idct_put_c;
4213 c->idct_permutation_type = FF_NO_IDCT_PERM;
4214 }else{ //accurate/default
4215 c->idct_put= ff_simple_idct_put;
4216 c->idct_add= ff_simple_idct_add;
4217 c->idct = ff_simple_idct;
4218 c->idct_permutation_type= FF_NO_IDCT_PERM;
4219 }
4220 }
4221
4222 c->get_pixels = get_pixels_c;
4223 c->diff_pixels = diff_pixels_c;
4224 c->put_pixels_clamped = put_pixels_clamped_c;
4225 c->put_signed_pixels_clamped = put_signed_pixels_clamped_c;
4226 c->put_pixels_nonclamped = put_pixels_nonclamped_c;
4227 c->add_pixels_clamped = add_pixels_clamped_c;
4228 c->add_pixels8 = add_pixels8_c;
4229 c->add_pixels4 = add_pixels4_c;
4230 c->sum_abs_dctelem = sum_abs_dctelem_c;
4231 c->gmc1 = gmc1_c;
4232 c->gmc = ff_gmc_c;
4233 c->clear_block = clear_block_c;
4234 c->clear_blocks = clear_blocks_c;
4235 c->pix_sum = pix_sum_c;
4236 c->pix_norm1 = pix_norm1_c;
4237
4238 c->fill_block_tab[0] = fill_block16_c;
4239 c->fill_block_tab[1] = fill_block8_c;
4240 c->scale_block = scale_block_c;
4241
4242 /* TODO [0] 16 [1] 8 */
4243 c->pix_abs[0][0] = pix_abs16_c;
4244 c->pix_abs[0][1] = pix_abs16_x2_c;
4245 c->pix_abs[0][2] = pix_abs16_y2_c;
4246 c->pix_abs[0][3] = pix_abs16_xy2_c;
4247 c->pix_abs[1][0] = pix_abs8_c;
4248 c->pix_abs[1][1] = pix_abs8_x2_c;
4249 c->pix_abs[1][2] = pix_abs8_y2_c;
4250 c->pix_abs[1][3] = pix_abs8_xy2_c;
4251
4252#define dspfunc(PFX, IDX, NUM) \
4253 c->PFX ## _pixels_tab[IDX][0] = PFX ## _pixels ## NUM ## _c; \
4254 c->PFX ## _pixels_tab[IDX][1] = PFX ## _pixels ## NUM ## _x2_c; \
4255 c->PFX ## _pixels_tab[IDX][2] = PFX ## _pixels ## NUM ## _y2_c; \
4256 c->PFX ## _pixels_tab[IDX][3] = PFX ## _pixels ## NUM ## _xy2_c
4257
4258 dspfunc(put, 0, 16);
4259 dspfunc(put_no_rnd, 0, 16);
4260 dspfunc(put, 1, 8);
4261 dspfunc(put_no_rnd, 1, 8);
4262 dspfunc(put, 2, 4);
4263 dspfunc(put, 3, 2);
4264
4265 dspfunc(avg, 0, 16);
4266 dspfunc(avg_no_rnd, 0, 16);
4267 dspfunc(avg, 1, 8);
4268 dspfunc(avg_no_rnd, 1, 8);
4269 dspfunc(avg, 2, 4);
4270 dspfunc(avg, 3, 2);
4271#undef dspfunc
4272
4273 c->put_no_rnd_pixels_l2[0]= put_no_rnd_pixels16_l2_c;
4274 c->put_no_rnd_pixels_l2[1]= put_no_rnd_pixels8_l2_c;
4275
4276 c->put_tpel_pixels_tab[ 0] = put_tpel_pixels_mc00_c;
4277 c->put_tpel_pixels_tab[ 1] = put_tpel_pixels_mc10_c;
4278 c->put_tpel_pixels_tab[ 2] = put_tpel_pixels_mc20_c;
4279 c->put_tpel_pixels_tab[ 4] = put_tpel_pixels_mc01_c;
4280 c->put_tpel_pixels_tab[ 5] = put_tpel_pixels_mc11_c;
4281 c->put_tpel_pixels_tab[ 6] = put_tpel_pixels_mc21_c;
4282 c->put_tpel_pixels_tab[ 8] = put_tpel_pixels_mc02_c;
4283 c->put_tpel_pixels_tab[ 9] = put_tpel_pixels_mc12_c;
4284 c->put_tpel_pixels_tab[10] = put_tpel_pixels_mc22_c;
4285
4286 c->avg_tpel_pixels_tab[ 0] = avg_tpel_pixels_mc00_c;
4287 c->avg_tpel_pixels_tab[ 1] = avg_tpel_pixels_mc10_c;
4288 c->avg_tpel_pixels_tab[ 2] = avg_tpel_pixels_mc20_c;
4289 c->avg_tpel_pixels_tab[ 4] = avg_tpel_pixels_mc01_c;
4290 c->avg_tpel_pixels_tab[ 5] = avg_tpel_pixels_mc11_c;
4291 c->avg_tpel_pixels_tab[ 6] = avg_tpel_pixels_mc21_c;
4292 c->avg_tpel_pixels_tab[ 8] = avg_tpel_pixels_mc02_c;
4293 c->avg_tpel_pixels_tab[ 9] = avg_tpel_pixels_mc12_c;
4294 c->avg_tpel_pixels_tab[10] = avg_tpel_pixels_mc22_c;
4295
4296#define dspfunc(PFX, IDX, NUM) \
4297 c->PFX ## _pixels_tab[IDX][ 0] = PFX ## NUM ## _mc00_c; \
4298 c->PFX ## _pixels_tab[IDX][ 1] = PFX ## NUM ## _mc10_c; \
4299 c->PFX ## _pixels_tab[IDX][ 2] = PFX ## NUM ## _mc20_c; \
4300 c->PFX ## _pixels_tab[IDX][ 3] = PFX ## NUM ## _mc30_c; \
4301 c->PFX ## _pixels_tab[IDX][ 4] = PFX ## NUM ## _mc01_c; \
4302 c->PFX ## _pixels_tab[IDX][ 5] = PFX ## NUM ## _mc11_c; \
4303 c->PFX ## _pixels_tab[IDX][ 6] = PFX ## NUM ## _mc21_c; \
4304 c->PFX ## _pixels_tab[IDX][ 7] = PFX ## NUM ## _mc31_c; \
4305 c->PFX ## _pixels_tab[IDX][ 8] = PFX ## NUM ## _mc02_c; \
4306 c->PFX ## _pixels_tab[IDX][ 9] = PFX ## NUM ## _mc12_c; \
4307 c->PFX ## _pixels_tab[IDX][10] = PFX ## NUM ## _mc22_c; \
4308 c->PFX ## _pixels_tab[IDX][11] = PFX ## NUM ## _mc32_c; \
4309 c->PFX ## _pixels_tab[IDX][12] = PFX ## NUM ## _mc03_c; \
4310 c->PFX ## _pixels_tab[IDX][13] = PFX ## NUM ## _mc13_c; \
4311 c->PFX ## _pixels_tab[IDX][14] = PFX ## NUM ## _mc23_c; \
4312 c->PFX ## _pixels_tab[IDX][15] = PFX ## NUM ## _mc33_c
4313
4314 dspfunc(put_qpel, 0, 16);
4315 dspfunc(put_no_rnd_qpel, 0, 16);
4316
4317 dspfunc(avg_qpel, 0, 16);
4318 /* dspfunc(avg_no_rnd_qpel, 0, 16); */
4319
4320 dspfunc(put_qpel, 1, 8);
4321 dspfunc(put_no_rnd_qpel, 1, 8);
4322
4323 dspfunc(avg_qpel, 1, 8);
4324 /* dspfunc(avg_no_rnd_qpel, 1, 8); */
4325
4326 dspfunc(put_h264_qpel, 0, 16);
4327 dspfunc(put_h264_qpel, 1, 8);
4328 dspfunc(put_h264_qpel, 2, 4);
4329 dspfunc(put_h264_qpel, 3, 2);
4330 dspfunc(avg_h264_qpel, 0, 16);
4331 dspfunc(avg_h264_qpel, 1, 8);
4332 dspfunc(avg_h264_qpel, 2, 4);
4333
4334#undef dspfunc
4335 c->put_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_c;
4336 c->put_h264_chroma_pixels_tab[1]= put_h264_chroma_mc4_c;
4337 c->put_h264_chroma_pixels_tab[2]= put_h264_chroma_mc2_c;
4338 c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_c;
4339 c->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_c;
4340 c->avg_h264_chroma_pixels_tab[2]= avg_h264_chroma_mc2_c;
4341 c->put_no_rnd_vc1_chroma_pixels_tab[0]= put_no_rnd_vc1_chroma_mc8_c;
4342 c->avg_no_rnd_vc1_chroma_pixels_tab[0]= avg_no_rnd_vc1_chroma_mc8_c;
4343
4344 c->draw_edges = draw_edges_c;
4345
4346#if CONFIG_MLP_DECODER || CONFIG_TRUEHD_DECODER
4347 ff_mlp_init(c, avctx);
4348#endif
4349#if CONFIG_VC1_DECODER
4350 ff_vc1dsp_init(c,avctx);
4351#endif
4352#if CONFIG_WMV2_DECODER || CONFIG_VC1_DECODER
4353 ff_intrax8dsp_init(c,avctx);
4354#endif
4355#if CONFIG_RV30_DECODER
4356 ff_rv30dsp_init(c,avctx);
4357#endif
4358#if CONFIG_RV40_DECODER
4359 ff_rv40dsp_init(c,avctx);
4360 c->put_rv40_qpel_pixels_tab[0][15] = put_rv40_qpel16_mc33_c;
4361 c->avg_rv40_qpel_pixels_tab[0][15] = avg_rv40_qpel16_mc33_c;
4362 c->put_rv40_qpel_pixels_tab[1][15] = put_rv40_qpel8_mc33_c;
4363 c->avg_rv40_qpel_pixels_tab[1][15] = avg_rv40_qpel8_mc33_c;
4364#endif
4365
4366 c->put_mspel_pixels_tab[0]= put_mspel8_mc00_c;
4367 c->put_mspel_pixels_tab[1]= put_mspel8_mc10_c;
4368 c->put_mspel_pixels_tab[2]= put_mspel8_mc20_c;
4369 c->put_mspel_pixels_tab[3]= put_mspel8_mc30_c;
4370 c->put_mspel_pixels_tab[4]= put_mspel8_mc02_c;
4371 c->put_mspel_pixels_tab[5]= put_mspel8_mc12_c;
4372 c->put_mspel_pixels_tab[6]= put_mspel8_mc22_c;
4373 c->put_mspel_pixels_tab[7]= put_mspel8_mc32_c;
4374
4375#define SET_CMP_FUNC(name) \
4376 c->name[0]= name ## 16_c;\
4377 c->name[1]= name ## 8x8_c;
4378
4379 SET_CMP_FUNC(hadamard8_diff)
4380 c->hadamard8_diff[4]= hadamard8_intra16_c;
4381 c->hadamard8_diff[5]= hadamard8_intra8x8_c;
4382 SET_CMP_FUNC(dct_sad)
4383 SET_CMP_FUNC(dct_max)
4384#if CONFIG_GPL
4385 SET_CMP_FUNC(dct264_sad)
4386#endif
4387 c->sad[0]= pix_abs16_c;
4388 c->sad[1]= pix_abs8_c;
4389 c->sse[0]= sse16_c;
4390 c->sse[1]= sse8_c;
4391 c->sse[2]= sse4_c;
4392 SET_CMP_FUNC(quant_psnr)
4393 SET_CMP_FUNC(rd)
4394 SET_CMP_FUNC(bit)
4395 c->vsad[0]= vsad16_c;
4396 c->vsad[4]= vsad_intra16_c;
4397 c->vsad[5]= vsad_intra8_c;
4398 c->vsse[0]= vsse16_c;
4399 c->vsse[4]= vsse_intra16_c;
4400 c->vsse[5]= vsse_intra8_c;
4401 c->nsse[0]= nsse16_c;
4402 c->nsse[1]= nsse8_c;
4403#if CONFIG_DWT
4404 ff_dsputil_init_dwt(c);
4405#endif
4406
4407 c->ssd_int8_vs_int16 = ssd_int8_vs_int16_c;
4408
4409 c->add_bytes= add_bytes_c;
4410 c->add_bytes_l2= add_bytes_l2_c;
4411 c->diff_bytes= diff_bytes_c;
4412 c->add_hfyu_median_prediction= add_hfyu_median_prediction_c;
4413 c->sub_hfyu_median_prediction= sub_hfyu_median_prediction_c;
4414 c->add_hfyu_left_prediction = add_hfyu_left_prediction_c;
4415 c->add_hfyu_left_prediction_bgr32 = add_hfyu_left_prediction_bgr32_c;
4416 c->bswap_buf= bswap_buf;
4417#if CONFIG_PNG_DECODER
4418 c->add_png_paeth_prediction= ff_add_png_paeth_prediction;
4419#endif
4420
4421 if (CONFIG_H263_DECODER || CONFIG_H263_ENCODER) {
4422 c->h263_h_loop_filter= h263_h_loop_filter_c;
4423 c->h263_v_loop_filter= h263_v_loop_filter_c;
4424 }
4425
4426 if (CONFIG_VP3_DECODER) {
4427 c->vp3_h_loop_filter= ff_vp3_h_loop_filter_c;
4428 c->vp3_v_loop_filter= ff_vp3_v_loop_filter_c;
4429 c->vp3_idct_dc_add= ff_vp3_idct_dc_add_c;
4430 }
4431 if (CONFIG_VP6_DECODER) {
4432 c->vp6_filter_diag4= ff_vp6_filter_diag4_c;
4433 }
4434
4435 c->h261_loop_filter= h261_loop_filter_c;
4436
4437 c->try_8x8basis= try_8x8basis_c;
4438 c->add_8x8basis= add_8x8basis_c;
4439
4440#if CONFIG_VORBIS_DECODER
4441 c->vorbis_inverse_coupling = vorbis_inverse_coupling;
4442#endif
4443#if CONFIG_AC3_DECODER
4444 c->ac3_downmix = ff_ac3_downmix_c;
4445#endif
4446#if CONFIG_LPC
4447 c->lpc_compute_autocorr = ff_lpc_compute_autocorr;
4448#endif
4449 c->vector_fmul = vector_fmul_c;
4450 c->vector_fmul_reverse = vector_fmul_reverse_c;
4451 c->vector_fmul_add = vector_fmul_add_c;
4452 c->vector_fmul_window = ff_vector_fmul_window_c;
4453 c->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_c;
4454 c->vector_clipf = vector_clipf_c;
4455 c->float_to_int16 = ff_float_to_int16_c;
4456 c->float_to_int16_interleave = ff_float_to_int16_interleave_c;
4457 c->scalarproduct_int16 = scalarproduct_int16_c;
4458 c->scalarproduct_and_madd_int16 = scalarproduct_and_madd_int16_c;
4459 c->scalarproduct_float = scalarproduct_float_c;
4460 c->butterflies_float = butterflies_float_c;
4461 c->vector_fmul_scalar = vector_fmul_scalar_c;
4462
4463 c->vector_fmul_sv_scalar[0] = vector_fmul_sv_scalar_2_c;
4464 c->vector_fmul_sv_scalar[1] = vector_fmul_sv_scalar_4_c;
4465
4466 c->sv_fmul_scalar[0] = sv_fmul_scalar_2_c;
4467 c->sv_fmul_scalar[1] = sv_fmul_scalar_4_c;
4468
4469 c->shrink[0]= ff_img_copy_plane;
4470 c->shrink[1]= ff_shrink22;
4471 c->shrink[2]= ff_shrink44;
4472 c->shrink[3]= ff_shrink88;
4473
4474 c->prefetch= just_return;
4475
4476 memset(c->put_2tap_qpel_pixels_tab, 0, sizeof(c->put_2tap_qpel_pixels_tab));
4477 memset(c->avg_2tap_qpel_pixels_tab, 0, sizeof(c->avg_2tap_qpel_pixels_tab));
4478
4479 if (HAVE_MMX) dsputil_init_mmx (c, avctx);
4480 if (ARCH_ARM) dsputil_init_arm (c, avctx);
4481 if (CONFIG_MLIB) dsputil_init_mlib (c, avctx);
4482 if (HAVE_VIS) dsputil_init_vis (c, avctx);
4483 if (ARCH_ALPHA) dsputil_init_alpha (c, avctx);
4484 if (ARCH_PPC) dsputil_init_ppc (c, avctx);
4485 if (HAVE_MMI) dsputil_init_mmi (c, avctx);
4486 if (ARCH_SH4) dsputil_init_sh4 (c, avctx);
4487 if (ARCH_BFIN) dsputil_init_bfin (c, avctx);
4488
4489 for(i=0; i<64; i++){
4490 if(!c->put_2tap_qpel_pixels_tab[0][i])
4491 c->put_2tap_qpel_pixels_tab[0][i]= c->put_h264_qpel_pixels_tab[0][i];
4492 if(!c->avg_2tap_qpel_pixels_tab[0][i])
4493 c->avg_2tap_qpel_pixels_tab[0][i]= c->avg_h264_qpel_pixels_tab[0][i];
4494 }
4495
4496 c->put_rv30_tpel_pixels_tab[0][0] = c->put_h264_qpel_pixels_tab[0][0];
4497 c->put_rv30_tpel_pixels_tab[1][0] = c->put_h264_qpel_pixels_tab[1][0];
4498 c->avg_rv30_tpel_pixels_tab[0][0] = c->avg_h264_qpel_pixels_tab[0][0];
4499 c->avg_rv30_tpel_pixels_tab[1][0] = c->avg_h264_qpel_pixels_tab[1][0];
4500
4501 c->put_rv40_qpel_pixels_tab[0][0] = c->put_h264_qpel_pixels_tab[0][0];
4502 c->put_rv40_qpel_pixels_tab[1][0] = c->put_h264_qpel_pixels_tab[1][0];
4503 c->avg_rv40_qpel_pixels_tab[0][0] = c->avg_h264_qpel_pixels_tab[0][0];
4504 c->avg_rv40_qpel_pixels_tab[1][0] = c->avg_h264_qpel_pixels_tab[1][0];
4505
4506 switch(c->idct_permutation_type){
4507 case FF_NO_IDCT_PERM:
4508 for(i=0; i<64; i++)
4509 c->idct_permutation[i]= i;
4510 break;
4511 case FF_LIBMPEG2_IDCT_PERM:
4512 for(i=0; i<64; i++)
4513 c->idct_permutation[i]= (i & 0x38) | ((i & 6) >> 1) | ((i & 1) << 2);
4514 break;
4515 case FF_SIMPLE_IDCT_PERM:
4516 for(i=0; i<64; i++)
4517 c->idct_permutation[i]= simple_mmx_permutation[i];
4518 break;
4519 case FF_TRANSPOSE_IDCT_PERM:
4520 for(i=0; i<64; i++)
4521 c->idct_permutation[i]= ((i&7)<<3) | (i>>3);
4522 break;
4523 case FF_PARTTRANS_IDCT_PERM:
4524 for(i=0; i<64; i++)
4525 c->idct_permutation[i]= (i&0x24) | ((i&3)<<3) | ((i>>3)&3);
4526 break;
4527 case FF_SSE2_IDCT_PERM:
4528 for(i=0; i<64; i++)
4529 c->idct_permutation[i]= (i&0x38) | idct_sse2_row_perm[i&7];
4530 break;
4531 default:
4532 av_log(avctx, AV_LOG_ERROR, "Internal error, IDCT permutation not set\n");
4533 }
4534}
4535
diff --git a/apps/codecs/libwmavoice/dsputil.h b/apps/codecs/libwmavoice/dsputil.h
new file mode 100644
index 0000000000..9ef0270ade
--- /dev/null
+++ b/apps/codecs/libwmavoice/dsputil.h
@@ -0,0 +1,800 @@
1/*
2 * DSP utils
3 * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
4 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23/**
24 * @file
25 * DSP utils.
26 * note, many functions in here may use MMX which trashes the FPU state, it is
27 * absolutely necessary to call emms_c() between dsp & float/double code
28 */
29
30#ifndef AVCODEC_DSPUTIL_H
31#define AVCODEC_DSPUTIL_H
32
33#include "libavutil/intreadwrite.h"
34#include "avcodec.h"
35
36
37//#define DEBUG
38/* dct code */
39typedef short DCTELEM;
40
41void fdct_ifast (DCTELEM *data);
42void fdct_ifast248 (DCTELEM *data);
43void ff_jpeg_fdct_islow (DCTELEM *data);
44void ff_fdct248_islow (DCTELEM *data);
45
46void j_rev_dct (DCTELEM *data);
47void j_rev_dct4 (DCTELEM *data);
48void j_rev_dct2 (DCTELEM *data);
49void j_rev_dct1 (DCTELEM *data);
50void ff_wmv2_idct_c(DCTELEM *data);
51
52void ff_fdct_mmx(DCTELEM *block);
53void ff_fdct_mmx2(DCTELEM *block);
54void ff_fdct_sse2(DCTELEM *block);
55
56void ff_h264_idct8_add_c(uint8_t *dst, DCTELEM *block, int stride);
57void ff_h264_idct_add_c(uint8_t *dst, DCTELEM *block, int stride);
58void ff_h264_idct8_dc_add_c(uint8_t *dst, DCTELEM *block, int stride);
59void ff_h264_idct_dc_add_c(uint8_t *dst, DCTELEM *block, int stride);
60void ff_h264_lowres_idct_add_c(uint8_t *dst, int stride, DCTELEM *block);
61void ff_h264_lowres_idct_put_c(uint8_t *dst, int stride, DCTELEM *block);
62void ff_h264_idct_add16_c(uint8_t *dst, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
63void ff_h264_idct_add16intra_c(uint8_t *dst, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
64void ff_h264_idct8_add4_c(uint8_t *dst, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
65void ff_h264_idct_add8_c(uint8_t **dest, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
66
67void ff_vector_fmul_window_c(float *dst, const float *src0, const float *src1,
68 const float *win, float add_bias, int len);
69void ff_float_to_int16_c(int16_t *dst, const float *src, long len);
70void ff_float_to_int16_interleave_c(int16_t *dst, const float **src, long len, int channels);
71
72/* encoding scans */
73extern const uint8_t ff_alternate_horizontal_scan[64];
74extern const uint8_t ff_alternate_vertical_scan[64];
75extern const uint8_t ff_zigzag_direct[64];
76extern const uint8_t ff_zigzag248_direct[64];
77
78/* pixel operations */
79#define MAX_NEG_CROP 1024
80
81/* temporary */
82extern uint32_t ff_squareTbl[512];
83extern uint8_t ff_cropTbl[256 + 2 * MAX_NEG_CROP];
84
85/* VP3 DSP functions */
86void ff_vp3_idct_c(DCTELEM *block/* align 16*/);
87void ff_vp3_idct_put_c(uint8_t *dest/*align 8*/, int line_size, DCTELEM *block/*align 16*/);
88void ff_vp3_idct_add_c(uint8_t *dest/*align 8*/, int line_size, DCTELEM *block/*align 16*/);
89void ff_vp3_idct_dc_add_c(uint8_t *dest/*align 8*/, int line_size, const DCTELEM *block/*align 16*/);
90
91void ff_vp3_v_loop_filter_c(uint8_t *src, int stride, int *bounding_values);
92void ff_vp3_h_loop_filter_c(uint8_t *src, int stride, int *bounding_values);
93
94/* VP6 DSP functions */
95void ff_vp6_filter_diag4_c(uint8_t *dst, uint8_t *src, int stride,
96 const int16_t *h_weights, const int16_t *v_weights);
97
98/* Bink functions */
99void ff_bink_idct_c (DCTELEM *block);
100void ff_bink_idct_add_c(uint8_t *dest, int linesize, DCTELEM *block);
101void ff_bink_idct_put_c(uint8_t *dest, int linesize, DCTELEM *block);
102
103/* CAVS functions */
104void ff_put_cavs_qpel8_mc00_c(uint8_t *dst, uint8_t *src, int stride);
105void ff_avg_cavs_qpel8_mc00_c(uint8_t *dst, uint8_t *src, int stride);
106void ff_put_cavs_qpel16_mc00_c(uint8_t *dst, uint8_t *src, int stride);
107void ff_avg_cavs_qpel16_mc00_c(uint8_t *dst, uint8_t *src, int stride);
108
109/* VC1 functions */
110void ff_put_vc1_mspel_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int rnd);
111void ff_avg_vc1_mspel_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int rnd);
112
113/* EA functions */
114void ff_ea_idct_put_c(uint8_t *dest, int linesize, DCTELEM *block);
115
116/* 1/2^n downscaling functions from imgconvert.c */
117void ff_img_copy_plane(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
118void ff_shrink22(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
119void ff_shrink44(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
120void ff_shrink88(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
121
122void ff_gmc_c(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy,
123 int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height);
124
125/* minimum alignment rules ;)
126If you notice errors in the align stuff, need more alignment for some ASM code
127for some CPU or need to use a function with less aligned data then send a mail
128to the ffmpeg-devel mailing list, ...
129
130!warning These alignments might not match reality, (missing attribute((align))
131stuff somewhere possible).
132I (Michael) did not check them, these are just the alignments which I think
133could be reached easily ...
134
135!future video codecs might need functions with less strict alignment
136*/
137
138/*
139void get_pixels_c(DCTELEM *block, const uint8_t *pixels, int line_size);
140void diff_pixels_c(DCTELEM *block, const uint8_t *s1, const uint8_t *s2, int stride);
141void put_pixels_clamped_c(const DCTELEM *block, uint8_t *pixels, int line_size);
142void add_pixels_clamped_c(const DCTELEM *block, uint8_t *pixels, int line_size);
143void clear_blocks_c(DCTELEM *blocks);
144*/
145
146/* add and put pixel (decoding) */
147// blocksizes for op_pixels_func are 8x4,8x8 16x8 16x16
148//h for op_pixels_func is limited to {width/2, width} but never larger than 16 and never smaller then 4
149typedef void (*op_pixels_func)(uint8_t *block/*align width (8 or 16)*/, const uint8_t *pixels/*align 1*/, int line_size, int h);
150typedef void (*tpel_mc_func)(uint8_t *block/*align width (8 or 16)*/, const uint8_t *pixels/*align 1*/, int line_size, int w, int h);
151typedef void (*qpel_mc_func)(uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, int stride);
152typedef void (*h264_chroma_mc_func)(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int srcStride, int h, int x, int y);
153
154typedef void (*op_fill_func)(uint8_t *block/*align width (8 or 16)*/, uint8_t value, int line_size, int h);
155
156#define DEF_OLD_QPEL(name)\
157void ff_put_ ## name (uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, int stride);\
158void ff_put_no_rnd_ ## name (uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, int stride);\
159void ff_avg_ ## name (uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, int stride);
160
161DEF_OLD_QPEL(qpel16_mc11_old_c)
162DEF_OLD_QPEL(qpel16_mc31_old_c)
163DEF_OLD_QPEL(qpel16_mc12_old_c)
164DEF_OLD_QPEL(qpel16_mc32_old_c)
165DEF_OLD_QPEL(qpel16_mc13_old_c)
166DEF_OLD_QPEL(qpel16_mc33_old_c)
167DEF_OLD_QPEL(qpel8_mc11_old_c)
168DEF_OLD_QPEL(qpel8_mc31_old_c)
169DEF_OLD_QPEL(qpel8_mc12_old_c)
170DEF_OLD_QPEL(qpel8_mc32_old_c)
171DEF_OLD_QPEL(qpel8_mc13_old_c)
172DEF_OLD_QPEL(qpel8_mc33_old_c)
173
174#define CALL_2X_PIXELS(a, b, n)\
175static void a(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
176 b(block , pixels , line_size, h);\
177 b(block+n, pixels+n, line_size, h);\
178}
179
180/* motion estimation */
181// h is limited to {width/2, width, 2*width} but never larger than 16 and never smaller then 2
182// although currently h<4 is not used as functions with width <8 are neither used nor implemented
183typedef int (*me_cmp_func)(void /*MpegEncContext*/ *s, uint8_t *blk1/*align width (8 or 16)*/, uint8_t *blk2/*align 1*/, int line_size, int h)/* __attribute__ ((const))*/;
184
185/**
186 * Scantable.
187 */
188typedef struct ScanTable{
189 const uint8_t *scantable;
190 uint8_t permutated[64];
191 uint8_t raster_end[64];
192#if ARCH_PPC
193 /** Used by dct_quantize_altivec to find last-non-zero */
194 DECLARE_ALIGNED(16, uint8_t, inverse)[64];
195#endif
196} ScanTable;
197
198void ff_init_scantable(uint8_t *, ScanTable *st, const uint8_t *src_scantable);
199
200void ff_emulated_edge_mc(uint8_t *buf, const uint8_t *src, int linesize,
201 int block_w, int block_h,
202 int src_x, int src_y, int w, int h);
203
204/**
205 * DSPContext.
206 */
207typedef struct DSPContext {
208 /* pixel ops : interface with DCT */
209 void (*get_pixels)(DCTELEM *block/*align 16*/, const uint8_t *pixels/*align 8*/, int line_size);
210 void (*diff_pixels)(DCTELEM *block/*align 16*/, const uint8_t *s1/*align 8*/, const uint8_t *s2/*align 8*/, int stride);
211 void (*put_pixels_clamped)(const DCTELEM *block/*align 16*/, uint8_t *pixels/*align 8*/, int line_size);
212 void (*put_signed_pixels_clamped)(const DCTELEM *block/*align 16*/, uint8_t *pixels/*align 8*/, int line_size);
213 void (*put_pixels_nonclamped)(const DCTELEM *block/*align 16*/, uint8_t *pixels/*align 8*/, int line_size);
214 void (*add_pixels_clamped)(const DCTELEM *block/*align 16*/, uint8_t *pixels/*align 8*/, int line_size);
215 void (*add_pixels8)(uint8_t *pixels, DCTELEM *block, int line_size);
216 void (*add_pixels4)(uint8_t *pixels, DCTELEM *block, int line_size);
217 int (*sum_abs_dctelem)(DCTELEM *block/*align 16*/);
218 /**
219 * translational global motion compensation.
220 */
221 void (*gmc1)(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int srcStride, int h, int x16, int y16, int rounder);
222 /**
223 * global motion compensation.
224 */
225 void (*gmc )(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int ox, int oy,
226 int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height);
227 void (*clear_block)(DCTELEM *block/*align 16*/);
228 void (*clear_blocks)(DCTELEM *blocks/*align 16*/);
229 int (*pix_sum)(uint8_t * pix, int line_size);
230 int (*pix_norm1)(uint8_t * pix, int line_size);
231// 16x16 8x8 4x4 2x2 16x8 8x4 4x2 8x16 4x8 2x4
232
233 me_cmp_func sad[6]; /* identical to pix_absAxA except additional void * */
234 me_cmp_func sse[6];
235 me_cmp_func hadamard8_diff[6];
236 me_cmp_func dct_sad[6];
237 me_cmp_func quant_psnr[6];
238 me_cmp_func bit[6];
239 me_cmp_func rd[6];
240 me_cmp_func vsad[6];
241 me_cmp_func vsse[6];
242 me_cmp_func nsse[6];
243 me_cmp_func w53[6];
244 me_cmp_func w97[6];
245 me_cmp_func dct_max[6];
246 me_cmp_func dct264_sad[6];
247
248 me_cmp_func me_pre_cmp[6];
249 me_cmp_func me_cmp[6];
250 me_cmp_func me_sub_cmp[6];
251 me_cmp_func mb_cmp[6];
252 me_cmp_func ildct_cmp[6]; //only width 16 used
253 me_cmp_func frame_skip_cmp[6]; //only width 8 used
254
255 int (*ssd_int8_vs_int16)(const int8_t *pix1, const int16_t *pix2,
256 int size);
257
258 /**
259 * Halfpel motion compensation with rounding (a+b+1)>>1.
260 * this is an array[4][4] of motion compensation functions for 4
261 * horizontal blocksizes (8,16) and the 4 halfpel positions<br>
262 * *pixels_tab[ 0->16xH 1->8xH ][ xhalfpel + 2*yhalfpel ]
263 * @param block destination where the result is stored
264 * @param pixels source
265 * @param line_size number of bytes in a horizontal line of block
266 * @param h height
267 */
268 op_pixels_func put_pixels_tab[4][4];
269
270 /**
271 * Halfpel motion compensation with rounding (a+b+1)>>1.
272 * This is an array[4][4] of motion compensation functions for 4
273 * horizontal blocksizes (8,16) and the 4 halfpel positions<br>
274 * *pixels_tab[ 0->16xH 1->8xH ][ xhalfpel + 2*yhalfpel ]
275 * @param block destination into which the result is averaged (a+b+1)>>1
276 * @param pixels source
277 * @param line_size number of bytes in a horizontal line of block
278 * @param h height
279 */
280 op_pixels_func avg_pixels_tab[4][4];
281
282 /**
283 * Halfpel motion compensation with no rounding (a+b)>>1.
284 * this is an array[2][4] of motion compensation functions for 2
285 * horizontal blocksizes (8,16) and the 4 halfpel positions<br>
286 * *pixels_tab[ 0->16xH 1->8xH ][ xhalfpel + 2*yhalfpel ]
287 * @param block destination where the result is stored
288 * @param pixels source
289 * @param line_size number of bytes in a horizontal line of block
290 * @param h height
291 */
292 op_pixels_func put_no_rnd_pixels_tab[4][4];
293
294 /**
295 * Halfpel motion compensation with no rounding (a+b)>>1.
296 * this is an array[2][4] of motion compensation functions for 2
297 * horizontal blocksizes (8,16) and the 4 halfpel positions<br>
298 * *pixels_tab[ 0->16xH 1->8xH ][ xhalfpel + 2*yhalfpel ]
299 * @param block destination into which the result is averaged (a+b)>>1
300 * @param pixels source
301 * @param line_size number of bytes in a horizontal line of block
302 * @param h height
303 */
304 op_pixels_func avg_no_rnd_pixels_tab[4][4];
305
306 void (*put_no_rnd_pixels_l2[2])(uint8_t *block/*align width (8 or 16)*/, const uint8_t *a/*align 1*/, const uint8_t *b/*align 1*/, int line_size, int h);
307
308 /**
309 * Thirdpel motion compensation with rounding (a+b+1)>>1.
310 * this is an array[12] of motion compensation functions for the 9 thirdpe
311 * positions<br>
312 * *pixels_tab[ xthirdpel + 4*ythirdpel ]
313 * @param block destination where the result is stored
314 * @param pixels source
315 * @param line_size number of bytes in a horizontal line of block
316 * @param h height
317 */
318 tpel_mc_func put_tpel_pixels_tab[11]; //FIXME individual func ptr per width?
319 tpel_mc_func avg_tpel_pixels_tab[11]; //FIXME individual func ptr per width?
320
321 qpel_mc_func put_qpel_pixels_tab[2][16];
322 qpel_mc_func avg_qpel_pixels_tab[2][16];
323 qpel_mc_func put_no_rnd_qpel_pixels_tab[2][16];
324 qpel_mc_func avg_no_rnd_qpel_pixels_tab[2][16];
325 qpel_mc_func put_mspel_pixels_tab[8];
326
327 /**
328 * h264 Chroma MC
329 */
330 h264_chroma_mc_func put_h264_chroma_pixels_tab[3];
331 h264_chroma_mc_func avg_h264_chroma_pixels_tab[3];
332 /* This is really one func used in VC-1 decoding */
333 h264_chroma_mc_func put_no_rnd_vc1_chroma_pixels_tab[3];
334 h264_chroma_mc_func avg_no_rnd_vc1_chroma_pixels_tab[3];
335
336 qpel_mc_func put_h264_qpel_pixels_tab[4][16];
337 qpel_mc_func avg_h264_qpel_pixels_tab[4][16];
338
339 qpel_mc_func put_2tap_qpel_pixels_tab[4][16];
340 qpel_mc_func avg_2tap_qpel_pixels_tab[4][16];
341
342 me_cmp_func pix_abs[2][4];
343
344 /* huffyuv specific */
345 void (*add_bytes)(uint8_t *dst/*align 16*/, uint8_t *src/*align 16*/, int w);
346 void (*add_bytes_l2)(uint8_t *dst/*align 16*/, uint8_t *src1/*align 16*/, uint8_t *src2/*align 16*/, int w);
347 void (*diff_bytes)(uint8_t *dst/*align 16*/, uint8_t *src1/*align 16*/, uint8_t *src2/*align 1*/,int w);
348 /**
349 * subtract huffyuv's variant of median prediction
350 * note, this might read from src1[-1], src2[-1]
351 */
352 void (*sub_hfyu_median_prediction)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int w, int *left, int *left_top);
353 void (*add_hfyu_median_prediction)(uint8_t *dst, const uint8_t *top, const uint8_t *diff, int w, int *left, int *left_top);
354 int (*add_hfyu_left_prediction)(uint8_t *dst, const uint8_t *src, int w, int left);
355 void (*add_hfyu_left_prediction_bgr32)(uint8_t *dst, const uint8_t *src, int w, int *red, int *green, int *blue, int *alpha);
356 /* this might write to dst[w] */
357 void (*add_png_paeth_prediction)(uint8_t *dst, uint8_t *src, uint8_t *top, int w, int bpp);
358 void (*bswap_buf)(uint32_t *dst, const uint32_t *src, int w);
359
360 void (*h263_v_loop_filter)(uint8_t *src, int stride, int qscale);
361 void (*h263_h_loop_filter)(uint8_t *src, int stride, int qscale);
362
363 void (*h261_loop_filter)(uint8_t *src, int stride);
364
365 void (*x8_v_loop_filter)(uint8_t *src, int stride, int qscale);
366 void (*x8_h_loop_filter)(uint8_t *src, int stride, int qscale);
367
368 void (*vp3_idct_dc_add)(uint8_t *dest/*align 8*/, int line_size, const DCTELEM *block/*align 16*/);
369 void (*vp3_v_loop_filter)(uint8_t *src, int stride, int *bounding_values);
370 void (*vp3_h_loop_filter)(uint8_t *src, int stride, int *bounding_values);
371
372 void (*vp6_filter_diag4)(uint8_t *dst, uint8_t *src, int stride,
373 const int16_t *h_weights,const int16_t *v_weights);
374
375 /* assume len is a multiple of 4, and arrays are 16-byte aligned */
376 void (*vorbis_inverse_coupling)(float *mag, float *ang, int blocksize);
377 void (*ac3_downmix)(float (*samples)[256], float (*matrix)[2], int out_ch, int in_ch, int len);
378 /* no alignment needed */
379 void (*lpc_compute_autocorr)(const int32_t *data, int len, int lag, double *autoc);
380 /* assume len is a multiple of 8, and arrays are 16-byte aligned */
381 void (*vector_fmul)(float *dst, const float *src, int len);
382 void (*vector_fmul_reverse)(float *dst, const float *src0, const float *src1, int len);
383 /* assume len is a multiple of 8, and src arrays are 16-byte aligned */
384 void (*vector_fmul_add)(float *dst, const float *src0, const float *src1, const float *src2, int len);
385 /* assume len is a multiple of 4, and arrays are 16-byte aligned */
386 void (*vector_fmul_window)(float *dst, const float *src0, const float *src1, const float *win, float add_bias, int len);
387 /* assume len is a multiple of 8, and arrays are 16-byte aligned */
388 void (*int32_to_float_fmul_scalar)(float *dst, const int *src, float mul, int len);
389 void (*vector_clipf)(float *dst /* align 16 */, const float *src /* align 16 */, float min, float max, int len /* align 16 */);
390 /**
391 * Multiply a vector of floats by a scalar float. Source and
392 * destination vectors must overlap exactly or not at all.
393 * @param dst result vector, 16-byte aligned
394 * @param src input vector, 16-byte aligned
395 * @param mul scalar value
396 * @param len length of vector, multiple of 4
397 */
398 void (*vector_fmul_scalar)(float *dst, const float *src, float mul,
399 int len);
400 /**
401 * Multiply a vector of floats by concatenated short vectors of
402 * floats and by a scalar float. Source and destination vectors
403 * must overlap exactly or not at all.
404 * [0]: short vectors of length 2, 8-byte aligned
405 * [1]: short vectors of length 4, 16-byte aligned
406 * @param dst output vector, 16-byte aligned
407 * @param src input vector, 16-byte aligned
408 * @param sv array of pointers to short vectors
409 * @param mul scalar value
410 * @param len number of elements in src and dst, multiple of 4
411 */
412 void (*vector_fmul_sv_scalar[2])(float *dst, const float *src,
413 const float **sv, float mul, int len);
414 /**
415 * Multiply short vectors of floats by a scalar float, store
416 * concatenated result.
417 * [0]: short vectors of length 2, 8-byte aligned
418 * [1]: short vectors of length 4, 16-byte aligned
419 * @param dst output vector, 16-byte aligned
420 * @param sv array of pointers to short vectors
421 * @param mul scalar value
422 * @param len number of output elements, multiple of 4
423 */
424 void (*sv_fmul_scalar[2])(float *dst, const float **sv,
425 float mul, int len);
426 /**
427 * Calculate the scalar product of two vectors of floats.
428 * @param v1 first vector, 16-byte aligned
429 * @param v2 second vector, 16-byte aligned
430 * @param len length of vectors, multiple of 4
431 */
432 float (*scalarproduct_float)(const float *v1, const float *v2, int len);
433 /**
434 * Calculate the sum and difference of two vectors of floats.
435 * @param v1 first input vector, sum output, 16-byte aligned
436 * @param v2 second input vector, difference output, 16-byte aligned
437 * @param len length of vectors, multiple of 4
438 */
439 void (*butterflies_float)(float *restrict v1, float *restrict v2, int len);
440
441 /* C version: convert floats from the range [384.0,386.0] to ints in [-32768,32767]
442 * simd versions: convert floats from [-32768.0,32767.0] without rescaling and arrays are 16byte aligned */
443 void (*float_to_int16)(int16_t *dst, const float *src, long len);
444 void (*float_to_int16_interleave)(int16_t *dst, const float **src, long len, int channels);
445
446 /* (I)DCT */
447 void (*fdct)(DCTELEM *block/* align 16*/);
448 void (*fdct248)(DCTELEM *block/* align 16*/);
449
450 /* IDCT really*/
451 void (*idct)(DCTELEM *block/* align 16*/);
452
453 /**
454 * block -> idct -> clip to unsigned 8 bit -> dest.
455 * (-1392, 0, 0, ...) -> idct -> (-174, -174, ...) -> put -> (0, 0, ...)
456 * @param line_size size in bytes of a horizontal line of dest
457 */
458 void (*idct_put)(uint8_t *dest/*align 8*/, int line_size, DCTELEM *block/*align 16*/);
459
460 /**
461 * block -> idct -> add dest -> clip to unsigned 8 bit -> dest.
462 * @param line_size size in bytes of a horizontal line of dest
463 */
464 void (*idct_add)(uint8_t *dest/*align 8*/, int line_size, DCTELEM *block/*align 16*/);
465
466 /**
467 * idct input permutation.
468 * several optimized IDCTs need a permutated input (relative to the normal order of the reference
469 * IDCT)
470 * this permutation must be performed before the idct_put/add, note, normally this can be merged
471 * with the zigzag/alternate scan<br>
472 * an example to avoid confusion:
473 * - (->decode coeffs -> zigzag reorder -> dequant -> reference idct ->...)
474 * - (x -> referece dct -> reference idct -> x)
475 * - (x -> referece dct -> simple_mmx_perm = idct_permutation -> simple_idct_mmx -> x)
476 * - (->decode coeffs -> zigzag reorder -> simple_mmx_perm -> dequant -> simple_idct_mmx ->...)
477 */
478 uint8_t idct_permutation[64];
479 int idct_permutation_type;
480#define FF_NO_IDCT_PERM 1
481#define FF_LIBMPEG2_IDCT_PERM 2
482#define FF_SIMPLE_IDCT_PERM 3
483#define FF_TRANSPOSE_IDCT_PERM 4
484#define FF_PARTTRANS_IDCT_PERM 5
485#define FF_SSE2_IDCT_PERM 6
486
487 int (*try_8x8basis)(int16_t rem[64], int16_t weight[64], int16_t basis[64], int scale);
488 void (*add_8x8basis)(int16_t rem[64], int16_t basis[64], int scale);
489#define BASIS_SHIFT 16
490#define RECON_SHIFT 6
491
492 void (*draw_edges)(uint8_t *buf, int wrap, int width, int height, int w);
493#define EDGE_WIDTH 16
494
495 void (*prefetch)(void *mem, int stride, int h);
496
497 void (*shrink[4])(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
498
499 /* mlp/truehd functions */
500 void (*mlp_filter_channel)(int32_t *state, const int32_t *coeff,
501 int firorder, int iirorder,
502 unsigned int filter_shift, int32_t mask, int blocksize,
503 int32_t *sample_buffer);
504
505 /* vc1 functions */
506 void (*vc1_inv_trans_8x8)(DCTELEM *b);
507 void (*vc1_inv_trans_8x4)(uint8_t *dest, int line_size, DCTELEM *block);
508 void (*vc1_inv_trans_4x8)(uint8_t *dest, int line_size, DCTELEM *block);
509 void (*vc1_inv_trans_4x4)(uint8_t *dest, int line_size, DCTELEM *block);
510 void (*vc1_inv_trans_8x8_dc)(uint8_t *dest, int line_size, DCTELEM *block);
511 void (*vc1_inv_trans_8x4_dc)(uint8_t *dest, int line_size, DCTELEM *block);
512 void (*vc1_inv_trans_4x8_dc)(uint8_t *dest, int line_size, DCTELEM *block);
513 void (*vc1_inv_trans_4x4_dc)(uint8_t *dest, int line_size, DCTELEM *block);
514 void (*vc1_v_overlap)(uint8_t* src, int stride);
515 void (*vc1_h_overlap)(uint8_t* src, int stride);
516 void (*vc1_v_loop_filter4)(uint8_t *src, int stride, int pq);
517 void (*vc1_h_loop_filter4)(uint8_t *src, int stride, int pq);
518 void (*vc1_v_loop_filter8)(uint8_t *src, int stride, int pq);
519 void (*vc1_h_loop_filter8)(uint8_t *src, int stride, int pq);
520 void (*vc1_v_loop_filter16)(uint8_t *src, int stride, int pq);
521 void (*vc1_h_loop_filter16)(uint8_t *src, int stride, int pq);
522 /* put 8x8 block with bicubic interpolation and quarterpel precision
523 * last argument is actually round value instead of height
524 */
525 op_pixels_func put_vc1_mspel_pixels_tab[16];
526 op_pixels_func avg_vc1_mspel_pixels_tab[16];
527
528 /* intrax8 functions */
529 void (*x8_spatial_compensation[12])(uint8_t *src , uint8_t *dst, int linesize);
530 void (*x8_setup_spatial_compensation)(uint8_t *src, uint8_t *dst, int linesize,
531 int * range, int * sum, int edges);
532
533 /**
534 * Calculate scalar product of two vectors.
535 * @param len length of vectors, should be multiple of 16
536 * @param shift number of bits to discard from product
537 */
538 int32_t (*scalarproduct_int16)(const int16_t *v1, const int16_t *v2/*align 16*/, int len, int shift);
539 /* ape functions */
540 /**
541 * Calculate scalar product of v1 and v2,
542 * and v1[i] += v3[i] * mul
543 * @param len length of vectors, should be multiple of 16
544 */
545 int32_t (*scalarproduct_and_madd_int16)(int16_t *v1/*align 16*/, const int16_t *v2, const int16_t *v3, int len, int mul);
546
547 /* rv30 functions */
548 qpel_mc_func put_rv30_tpel_pixels_tab[4][16];
549 qpel_mc_func avg_rv30_tpel_pixels_tab[4][16];
550
551 /* rv40 functions */
552 qpel_mc_func put_rv40_qpel_pixels_tab[4][16];
553 qpel_mc_func avg_rv40_qpel_pixels_tab[4][16];
554 h264_chroma_mc_func put_rv40_chroma_pixels_tab[3];
555 h264_chroma_mc_func avg_rv40_chroma_pixels_tab[3];
556
557 /* bink functions */
558 op_fill_func fill_block_tab[2];
559 void (*scale_block)(const uint8_t src[64]/*align 8*/, uint8_t *dst/*align 8*/, int linesize);
560} DSPContext;
561
562void dsputil_static_init(void);
563void dsputil_init(DSPContext* p, AVCodecContext *avctx);
564
565int ff_check_alignment(void);
566
567/**
568 * permute block according to permuatation.
569 * @param last last non zero element in scantable order
570 */
571void ff_block_permute(DCTELEM *block, uint8_t *permutation, const uint8_t *scantable, int last);
572
573void ff_set_cmp(DSPContext* c, me_cmp_func *cmp, int type);
574
575#define BYTE_VEC32(c) ((c)*0x01010101UL)
576
577static inline uint32_t rnd_avg32(uint32_t a, uint32_t b)
578{
579 return (a | b) - (((a ^ b) & ~BYTE_VEC32(0x01)) >> 1);
580}
581
582static inline uint32_t no_rnd_avg32(uint32_t a, uint32_t b)
583{
584 return (a & b) + (((a ^ b) & ~BYTE_VEC32(0x01)) >> 1);
585}
586
587static inline int get_penalty_factor(int lambda, int lambda2, int type){
588 switch(type&0xFF){
589 default:
590 case FF_CMP_SAD:
591 return lambda>>FF_LAMBDA_SHIFT;
592 case FF_CMP_DCT:
593 return (3*lambda)>>(FF_LAMBDA_SHIFT+1);
594 case FF_CMP_W53:
595 return (4*lambda)>>(FF_LAMBDA_SHIFT);
596 case FF_CMP_W97:
597 return (2*lambda)>>(FF_LAMBDA_SHIFT);
598 case FF_CMP_SATD:
599 case FF_CMP_DCT264:
600 return (2*lambda)>>FF_LAMBDA_SHIFT;
601 case FF_CMP_RD:
602 case FF_CMP_PSNR:
603 case FF_CMP_SSE:
604 case FF_CMP_NSSE:
605 return lambda2>>FF_LAMBDA_SHIFT;
606 case FF_CMP_BIT:
607 return 1;
608 }
609}
610
611/**
612 * Empty mmx state.
613 * this must be called between any dsp function and float/double code.
614 * for example sin(); dsp->idct_put(); emms_c(); cos()
615 */
616#define emms_c()
617
618/* should be defined by architectures supporting
619 one or more MultiMedia extension */
620int mm_support(void);
621extern int mm_flags;
622
623void dsputil_init_alpha(DSPContext* c, AVCodecContext *avctx);
624void dsputil_init_arm(DSPContext* c, AVCodecContext *avctx);
625void dsputil_init_bfin(DSPContext* c, AVCodecContext *avctx);
626void dsputil_init_mlib(DSPContext* c, AVCodecContext *avctx);
627void dsputil_init_mmi(DSPContext* c, AVCodecContext *avctx);
628void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx);
629void dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx);
630void dsputil_init_sh4(DSPContext* c, AVCodecContext *avctx);
631void dsputil_init_vis(DSPContext* c, AVCodecContext *avctx);
632
633void ff_dsputil_init_dwt(DSPContext *c);
634void ff_rv30dsp_init(DSPContext* c, AVCodecContext *avctx);
635void ff_rv40dsp_init(DSPContext* c, AVCodecContext *avctx);
636void ff_vc1dsp_init(DSPContext* c, AVCodecContext *avctx);
637void ff_intrax8dsp_init(DSPContext* c, AVCodecContext *avctx);
638void ff_mlp_init(DSPContext* c, AVCodecContext *avctx);
639void ff_mlp_init_x86(DSPContext* c, AVCodecContext *avctx);
640
641#if HAVE_MMX
642
643#undef emms_c
644
645static inline void emms(void)
646{
647 __asm__ volatile ("emms;":::"memory");
648}
649
650
651#define emms_c() \
652{\
653 if (mm_flags & FF_MM_MMX)\
654 emms();\
655}
656
657#elif ARCH_ARM
658
659#if HAVE_NEON
660# define STRIDE_ALIGN 16
661#endif
662
663#elif ARCH_PPC
664
665#define STRIDE_ALIGN 16
666
667#elif HAVE_MMI
668
669#define STRIDE_ALIGN 16
670
671#else
672
673#define mm_flags 0
674#define mm_support() 0
675
676#endif
677
678#ifndef STRIDE_ALIGN
679# define STRIDE_ALIGN 8
680#endif
681
682#define LOCAL_ALIGNED(a, t, v, s, ...) \
683 uint8_t la_##v[sizeof(t s __VA_ARGS__) + (a)]; \
684 t (*v) __VA_ARGS__ = (void *)FFALIGN((uintptr_t)la_##v, a)
685
686#if HAVE_LOCAL_ALIGNED_8
687# define LOCAL_ALIGNED_8(t, v, s, ...) DECLARE_ALIGNED(8, t, v) s __VA_ARGS__
688#else
689# define LOCAL_ALIGNED_8(t, v, s, ...) LOCAL_ALIGNED(8, t, v, s, __VA_ARGS__)
690#endif
691
692#if HAVE_LOCAL_ALIGNED_16
693# define LOCAL_ALIGNED_16(t, v, s, ...) DECLARE_ALIGNED(16, t, v) s __VA_ARGS__
694#else
695# define LOCAL_ALIGNED_16(t, v, s, ...) LOCAL_ALIGNED(16, t, v, s, __VA_ARGS__)
696#endif
697
698/* PSNR */
699void get_psnr(uint8_t *orig_image[3], uint8_t *coded_image[3],
700 int orig_linesize[3], int coded_linesize,
701 AVCodecContext *avctx);
702
703#define WRAPPER8_16(name8, name16)\
704static int name16(void /*MpegEncContext*/ *s, uint8_t *dst, uint8_t *src, int stride, int h){\
705 return name8(s, dst , src , stride, h)\
706 +name8(s, dst+8 , src+8 , stride, h);\
707}
708
709#define WRAPPER8_16_SQ(name8, name16)\
710static int name16(void /*MpegEncContext*/ *s, uint8_t *dst, uint8_t *src, int stride, int h){\
711 int score=0;\
712 score +=name8(s, dst , src , stride, 8);\
713 score +=name8(s, dst+8 , src+8 , stride, 8);\
714 if(h==16){\
715 dst += 8*stride;\
716 src += 8*stride;\
717 score +=name8(s, dst , src , stride, 8);\
718 score +=name8(s, dst+8 , src+8 , stride, 8);\
719 }\
720 return score;\
721}
722
723
724static inline void copy_block2(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
725{
726 int i;
727 for(i=0; i<h; i++)
728 {
729 AV_WN16(dst , AV_RN16(src ));
730 dst+=dstStride;
731 src+=srcStride;
732 }
733}
734
735static inline void copy_block4(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
736{
737 int i;
738 for(i=0; i<h; i++)
739 {
740 AV_WN32(dst , AV_RN32(src ));
741 dst+=dstStride;
742 src+=srcStride;
743 }
744}
745
746static inline void copy_block8(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
747{
748 int i;
749 for(i=0; i<h; i++)
750 {
751 AV_WN32(dst , AV_RN32(src ));
752 AV_WN32(dst+4 , AV_RN32(src+4 ));
753 dst+=dstStride;
754 src+=srcStride;
755 }
756}
757
758static inline void copy_block9(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
759{
760 int i;
761 for(i=0; i<h; i++)
762 {
763 AV_WN32(dst , AV_RN32(src ));
764 AV_WN32(dst+4 , AV_RN32(src+4 ));
765 dst[8]= src[8];
766 dst+=dstStride;
767 src+=srcStride;
768 }
769}
770
771static inline void copy_block16(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
772{
773 int i;
774 for(i=0; i<h; i++)
775 {
776 AV_WN32(dst , AV_RN32(src ));
777 AV_WN32(dst+4 , AV_RN32(src+4 ));
778 AV_WN32(dst+8 , AV_RN32(src+8 ));
779 AV_WN32(dst+12, AV_RN32(src+12));
780 dst+=dstStride;
781 src+=srcStride;
782 }
783}
784
785static inline void copy_block17(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
786{
787 int i;
788 for(i=0; i<h; i++)
789 {
790 AV_WN32(dst , AV_RN32(src ));
791 AV_WN32(dst+4 , AV_RN32(src+4 ));
792 AV_WN32(dst+8 , AV_RN32(src+8 ));
793 AV_WN32(dst+12, AV_RN32(src+12));
794 dst[16]= src[16];
795 dst+=dstStride;
796 src+=srcStride;
797 }
798}
799
800#endif /* AVCODEC_DSPUTIL_H */
diff --git a/apps/codecs/libwmavoice/fft.c b/apps/codecs/libwmavoice/fft.c
new file mode 100644
index 0000000000..81765510e3
--- /dev/null
+++ b/apps/codecs/libwmavoice/fft.c
@@ -0,0 +1,296 @@
1/*
2 * FFT/IFFT transforms
3 * Copyright (c) 2008 Loren Merritt
4 * Copyright (c) 2002 Fabrice Bellard
5 * Partly based on libdjbfft by D. J. Bernstein
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/**
25 * @file
26 * FFT/IFFT transforms.
27 */
28
29#include <stdlib.h>
30#include <string.h>
31#include "libavutil/mathematics.h"
32#include "fft.h"
33
34/* cos(2*pi*x/n) for 0<=x<=n/4, followed by its reverse */
35#if !CONFIG_HARDCODED_TABLES
36COSTABLE(16);
37COSTABLE(32);
38COSTABLE(64);
39COSTABLE(128);
40COSTABLE(256);
41COSTABLE(512);
42COSTABLE(1024);
43COSTABLE(2048);
44COSTABLE(4096);
45COSTABLE(8192);
46COSTABLE(16384);
47COSTABLE(32768);
48COSTABLE(65536);
49#endif
50COSTABLE_CONST FFTSample * const ff_cos_tabs[] = {
51 NULL, NULL, NULL, NULL,
52 ff_cos_16, ff_cos_32, ff_cos_64, ff_cos_128, ff_cos_256, ff_cos_512, ff_cos_1024,
53 ff_cos_2048, ff_cos_4096, ff_cos_8192, ff_cos_16384, ff_cos_32768, ff_cos_65536,
54};
55
56static int split_radix_permutation(int i, int n, int inverse)
57{
58 int m;
59 if(n <= 2) return i&1;
60 m = n >> 1;
61 if(!(i&m)) return split_radix_permutation(i, m, inverse)*2;
62 m >>= 1;
63 if(inverse == !(i&m)) return split_radix_permutation(i, m, inverse)*4 + 1;
64 else return split_radix_permutation(i, m, inverse)*4 - 1;
65}
66
67av_cold void ff_init_ff_cos_tabs(int index)
68{
69#if !CONFIG_HARDCODED_TABLES
70 int i;
71 int m = 1<<index;
72 double freq = 2*M_PI/m;
73 FFTSample *tab = ff_cos_tabs[index];
74 for(i=0; i<=m/4; i++)
75 tab[i] = cos(i*freq);
76 for(i=1; i<m/4; i++)
77 tab[m/2-i] = tab[i];
78#endif
79}
80
81av_cold int ff_fft_init(FFTContext *s, int nbits, int inverse)
82{
83 int i, j, n;
84
85 if (nbits < 2 || nbits > 16)
86 goto fail;
87 s->nbits = nbits;
88 n = 1 << nbits;
89
90 s->revtab = av_malloc(n * sizeof(uint16_t));
91 if (!s->revtab)
92 goto fail;
93 s->tmp_buf = av_malloc(n * sizeof(FFTComplex));
94 if (!s->tmp_buf)
95 goto fail;
96 s->inverse = inverse;
97
98 s->fft_permute = ff_fft_permute_c;
99 s->fft_calc = ff_fft_calc_c;
100#if CONFIG_MDCT
101 s->imdct_calc = ff_imdct_calc_c;
102 s->imdct_half = ff_imdct_half_c;
103 s->mdct_calc = ff_mdct_calc_c;
104#endif
105
106 if (ARCH_ARM) ff_fft_init_arm(s);
107 if (HAVE_ALTIVEC) ff_fft_init_altivec(s);
108 if (HAVE_MMX) ff_fft_init_mmx(s);
109
110 for(j=4; j<=nbits; j++) {
111 ff_init_ff_cos_tabs(j);
112 }
113 for(i=0; i<n; i++)
114 s->revtab[-split_radix_permutation(i, n, s->inverse) & (n-1)] = i;
115
116 return 0;
117 fail:
118 av_freep(&s->revtab);
119 av_freep(&s->tmp_buf);
120 return -1;
121}
122
123void ff_fft_permute_c(FFTContext *s, FFTComplex *z)
124{
125 int j, np;
126 const uint16_t *revtab = s->revtab;
127 np = 1 << s->nbits;
128 /* TODO: handle split-radix permute in a more optimal way, probably in-place */
129 for(j=0;j<np;j++) s->tmp_buf[revtab[j]] = z[j];
130 memcpy(z, s->tmp_buf, np * sizeof(FFTComplex));
131}
132
133av_cold void ff_fft_end(FFTContext *s)
134{
135 av_freep(&s->revtab);
136 av_freep(&s->tmp_buf);
137}
138
139#define sqrthalf (float)M_SQRT1_2
140
141#define BF(x,y,a,b) {\
142 x = a - b;\
143 y = a + b;\
144}
145
146#define BUTTERFLIES(a0,a1,a2,a3) {\
147 BF(t3, t5, t5, t1);\
148 BF(a2.re, a0.re, a0.re, t5);\
149 BF(a3.im, a1.im, a1.im, t3);\
150 BF(t4, t6, t2, t6);\
151 BF(a3.re, a1.re, a1.re, t4);\
152 BF(a2.im, a0.im, a0.im, t6);\
153}
154
155// force loading all the inputs before storing any.
156// this is slightly slower for small data, but avoids store->load aliasing
157// for addresses separated by large powers of 2.
158#define BUTTERFLIES_BIG(a0,a1,a2,a3) {\
159 FFTSample r0=a0.re, i0=a0.im, r1=a1.re, i1=a1.im;\
160 BF(t3, t5, t5, t1);\
161 BF(a2.re, a0.re, r0, t5);\
162 BF(a3.im, a1.im, i1, t3);\
163 BF(t4, t6, t2, t6);\
164 BF(a3.re, a1.re, r1, t4);\
165 BF(a2.im, a0.im, i0, t6);\
166}
167
168#define TRANSFORM(a0,a1,a2,a3,wre,wim) {\
169 t1 = a2.re * wre + a2.im * wim;\
170 t2 = a2.im * wre - a2.re * wim;\
171 t5 = a3.re * wre - a3.im * wim;\
172 t6 = a3.im * wre + a3.re * wim;\
173 BUTTERFLIES(a0,a1,a2,a3)\
174}
175
176#define TRANSFORM_ZERO(a0,a1,a2,a3) {\
177 t1 = a2.re;\
178 t2 = a2.im;\
179 t5 = a3.re;\
180 t6 = a3.im;\
181 BUTTERFLIES(a0,a1,a2,a3)\
182}
183
184/* z[0...8n-1], w[1...2n-1] */
185#define PASS(name)\
186static void name(FFTComplex *z, const FFTSample *wre, unsigned int n)\
187{\
188 FFTSample t1, t2, t3, t4, t5, t6;\
189 int o1 = 2*n;\
190 int o2 = 4*n;\
191 int o3 = 6*n;\
192 const FFTSample *wim = wre+o1;\
193 n--;\
194\
195 TRANSFORM_ZERO(z[0],z[o1],z[o2],z[o3]);\
196 TRANSFORM(z[1],z[o1+1],z[o2+1],z[o3+1],wre[1],wim[-1]);\
197 do {\
198 z += 2;\
199 wre += 2;\
200 wim -= 2;\
201 TRANSFORM(z[0],z[o1],z[o2],z[o3],wre[0],wim[0]);\
202 TRANSFORM(z[1],z[o1+1],z[o2+1],z[o3+1],wre[1],wim[-1]);\
203 } while(--n);\
204}
205
206PASS(pass)
207#undef BUTTERFLIES
208#define BUTTERFLIES BUTTERFLIES_BIG
209PASS(pass_big)
210
211#define DECL_FFT(n,n2,n4)\
212static void fft##n(FFTComplex *z)\
213{\
214 fft##n2(z);\
215 fft##n4(z+n4*2);\
216 fft##n4(z+n4*3);\
217 pass(z,ff_cos_##n,n4/2);\
218}
219
220static void fft4(FFTComplex *z)
221{
222 FFTSample t1, t2, t3, t4, t5, t6, t7, t8;
223
224 BF(t3, t1, z[0].re, z[1].re);
225 BF(t8, t6, z[3].re, z[2].re);
226 BF(z[2].re, z[0].re, t1, t6);
227 BF(t4, t2, z[0].im, z[1].im);
228 BF(t7, t5, z[2].im, z[3].im);
229 BF(z[3].im, z[1].im, t4, t8);
230 BF(z[3].re, z[1].re, t3, t7);
231 BF(z[2].im, z[0].im, t2, t5);
232}
233
234static void fft8(FFTComplex *z)
235{
236 FFTSample t1, t2, t3, t4, t5, t6, t7, t8;
237
238 fft4(z);
239
240 BF(t1, z[5].re, z[4].re, -z[5].re);
241 BF(t2, z[5].im, z[4].im, -z[5].im);
242 BF(t3, z[7].re, z[6].re, -z[7].re);
243 BF(t4, z[7].im, z[6].im, -z[7].im);
244 BF(t8, t1, t3, t1);
245 BF(t7, t2, t2, t4);
246 BF(z[4].re, z[0].re, z[0].re, t1);
247 BF(z[4].im, z[0].im, z[0].im, t2);
248 BF(z[6].re, z[2].re, z[2].re, t7);
249 BF(z[6].im, z[2].im, z[2].im, t8);
250
251 TRANSFORM(z[1],z[3],z[5],z[7],sqrthalf,sqrthalf);
252}
253
254#if !CONFIG_SMALL
255static void fft16(FFTComplex *z)
256{
257 FFTSample t1, t2, t3, t4, t5, t6;
258
259 fft8(z);
260 fft4(z+8);
261 fft4(z+12);
262
263 TRANSFORM_ZERO(z[0],z[4],z[8],z[12]);
264 TRANSFORM(z[2],z[6],z[10],z[14],sqrthalf,sqrthalf);
265 TRANSFORM(z[1],z[5],z[9],z[13],ff_cos_16[1],ff_cos_16[3]);
266 TRANSFORM(z[3],z[7],z[11],z[15],ff_cos_16[3],ff_cos_16[1]);
267}
268#else
269DECL_FFT(16,8,4)
270#endif
271DECL_FFT(32,16,8)
272DECL_FFT(64,32,16)
273DECL_FFT(128,64,32)
274DECL_FFT(256,128,64)
275DECL_FFT(512,256,128)
276#if !CONFIG_SMALL
277#define pass pass_big
278#endif
279DECL_FFT(1024,512,256)
280DECL_FFT(2048,1024,512)
281DECL_FFT(4096,2048,1024)
282DECL_FFT(8192,4096,2048)
283DECL_FFT(16384,8192,4096)
284DECL_FFT(32768,16384,8192)
285DECL_FFT(65536,32768,16384)
286
287static void (* const fft_dispatch[])(FFTComplex*) = {
288 fft4, fft8, fft16, fft32, fft64, fft128, fft256, fft512, fft1024,
289 fft2048, fft4096, fft8192, fft16384, fft32768, fft65536,
290};
291
292void ff_fft_calc_c(FFTContext *s, FFTComplex *z)
293{
294 fft_dispatch[s->nbits-2](z);
295}
296
diff --git a/apps/codecs/libwmavoice/fft.h b/apps/codecs/libwmavoice/fft.h
new file mode 100644
index 0000000000..eb6714fe95
--- /dev/null
+++ b/apps/codecs/libwmavoice/fft.h
@@ -0,0 +1,244 @@
1/*
2 * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
3 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
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_FFT_H
23#define AVCODEC_FFT_H
24
25#include <stdint.h>
26#include "config.h"
27#include "libavutil/mem.h"
28#include "avfft.h"
29
30/* FFT computation */
31
32struct FFTContext {
33 int nbits;
34 int inverse;
35 uint16_t *revtab;
36 FFTComplex *tmp_buf;
37 int mdct_size; /* size of MDCT (i.e. number of input data * 2) */
38 int mdct_bits; /* n = 2^nbits */
39 /* pre/post rotation tables */
40 FFTSample *tcos;
41 FFTSample *tsin;
42 void (*fft_permute)(struct FFTContext *s, FFTComplex *z);
43 void (*fft_calc)(struct FFTContext *s, FFTComplex *z);
44 void (*imdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input);
45 void (*imdct_half)(struct FFTContext *s, FFTSample *output, const FFTSample *input);
46 void (*mdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input);
47 int permutation;
48#define FF_MDCT_PERM_NONE 0
49#define FF_MDCT_PERM_INTERLEAVE 1
50};
51
52#if CONFIG_HARDCODED_TABLES
53#define COSTABLE_CONST const
54#define SINTABLE_CONST const
55#define SINETABLE_CONST const
56#else
57#define COSTABLE_CONST
58#define SINTABLE_CONST
59#define SINETABLE_CONST
60#endif
61
62#define COSTABLE(size) \
63 COSTABLE_CONST DECLARE_ALIGNED(16, FFTSample, ff_cos_##size)[size/2]
64#define SINTABLE(size) \
65 SINTABLE_CONST DECLARE_ALIGNED(16, FFTSample, ff_sin_##size)[size/2]
66#define SINETABLE(size) \
67 SINETABLE_CONST DECLARE_ALIGNED(16, float, ff_sine_##size)[size]
68extern COSTABLE(16);
69extern COSTABLE(32);
70extern COSTABLE(64);
71extern COSTABLE(128);
72extern COSTABLE(256);
73extern COSTABLE(512);
74extern COSTABLE(1024);
75extern COSTABLE(2048);
76extern COSTABLE(4096);
77extern COSTABLE(8192);
78extern COSTABLE(16384);
79extern COSTABLE(32768);
80extern COSTABLE(65536);
81extern COSTABLE_CONST FFTSample* const ff_cos_tabs[17];
82
83/**
84 * Initialize the cosine table in ff_cos_tabs[index]
85 * \param index index in ff_cos_tabs array of the table to initialize
86 */
87void ff_init_ff_cos_tabs(int index);
88
89extern SINTABLE(16);
90extern SINTABLE(32);
91extern SINTABLE(64);
92extern SINTABLE(128);
93extern SINTABLE(256);
94extern SINTABLE(512);
95extern SINTABLE(1024);
96extern SINTABLE(2048);
97extern SINTABLE(4096);
98extern SINTABLE(8192);
99extern SINTABLE(16384);
100extern SINTABLE(32768);
101extern SINTABLE(65536);
102
103/**
104 * Set up a complex FFT.
105 * @param nbits log2 of the length of the input array
106 * @param inverse if 0 perform the forward transform, if 1 perform the inverse
107 */
108int ff_fft_init(FFTContext *s, int nbits, int inverse);
109void ff_fft_permute_c(FFTContext *s, FFTComplex *z);
110void ff_fft_calc_c(FFTContext *s, FFTComplex *z);
111
112void ff_fft_init_altivec(FFTContext *s);
113void ff_fft_init_mmx(FFTContext *s);
114void ff_fft_init_arm(FFTContext *s);
115void ff_dct_init_mmx(DCTContext *s);
116
117/**
118 * Do the permutation needed BEFORE calling ff_fft_calc().
119 */
120static inline void ff_fft_permute(FFTContext *s, FFTComplex *z)
121{
122 s->fft_permute(s, z);
123}
124/**
125 * Do a complex FFT with the parameters defined in ff_fft_init(). The
126 * input data must be permuted before. No 1.0/sqrt(n) normalization is done.
127 */
128static inline void ff_fft_calc(FFTContext *s, FFTComplex *z)
129{
130 s->fft_calc(s, z);
131}
132void ff_fft_end(FFTContext *s);
133
134/* MDCT computation */
135
136static inline void ff_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input)
137{
138 s->imdct_calc(s, output, input);
139}
140static inline void ff_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input)
141{
142 s->imdct_half(s, output, input);
143}
144
145static inline void ff_mdct_calc(FFTContext *s, FFTSample *output,
146 const FFTSample *input)
147{
148 s->mdct_calc(s, output, input);
149}
150
151/**
152 * Maximum window size for ff_kbd_window_init.
153 */
154#define FF_KBD_WINDOW_MAX 1024
155
156/**
157 * Generate a Kaiser-Bessel Derived Window.
158 * @param window pointer to half window
159 * @param alpha determines window shape
160 * @param n size of half window, max FF_KBD_WINDOW_MAX
161 */
162void ff_kbd_window_init(float *window, float alpha, int n);
163
164/**
165 * Generate a sine window.
166 * @param window pointer to half window
167 * @param n size of half window
168 */
169void ff_sine_window_init(float *window, int n);
170
171/**
172 * initialize the specified entry of ff_sine_windows
173 */
174void ff_init_ff_sine_windows(int index);
175extern SINETABLE( 32);
176extern SINETABLE( 64);
177extern SINETABLE( 128);
178extern SINETABLE( 256);
179extern SINETABLE( 512);
180extern SINETABLE(1024);
181extern SINETABLE(2048);
182extern SINETABLE(4096);
183extern SINETABLE_CONST float * const ff_sine_windows[13];
184
185int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale);
186void ff_imdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input);
187void ff_imdct_half_c(FFTContext *s, FFTSample *output, const FFTSample *input);
188void ff_mdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input);
189void ff_mdct_end(FFTContext *s);
190
191/* Real Discrete Fourier Transform */
192
193struct RDFTContext {
194 int nbits;
195 int inverse;
196 int sign_convention;
197
198 /* pre/post rotation tables */
199 const FFTSample *tcos;
200 SINTABLE_CONST FFTSample *tsin;
201 FFTContext fft;
202 void (*rdft_calc)(struct RDFTContext *s, FFTSample *z);
203};
204
205/**
206 * Set up a real FFT.
207 * @param nbits log2 of the length of the input array
208 * @param trans the type of transform
209 */
210int ff_rdft_init(RDFTContext *s, int nbits, enum RDFTransformType trans);
211void ff_rdft_end(RDFTContext *s);
212
213void ff_rdft_init_arm(RDFTContext *s);
214
215static av_always_inline void ff_rdft_calc(RDFTContext *s, FFTSample *data)
216{
217 s->rdft_calc(s, data);
218}
219
220/* Discrete Cosine Transform */
221
222struct DCTContext {
223 int nbits;
224 int inverse;
225 RDFTContext rdft;
226 const float *costab;
227 FFTSample *csc2;
228 void (*dct_calc)(struct DCTContext *s, FFTSample *data);
229 void (*dct32)(FFTSample *out, const FFTSample *in);
230};
231
232/**
233 * Set up DCT.
234 * @param nbits size of the input array:
235 * (1 << nbits) for DCT-II, DCT-III and DST-I
236 * (1 << nbits) + 1 for DCT-I
237 *
238 * @note the first element of the input of DST-I is ignored
239 */
240int ff_dct_init(DCTContext *s, int nbits, enum DCTTransformType type);
241void ff_dct_calc(DCTContext *s, FFTSample *data);
242void ff_dct_end (DCTContext *s);
243
244#endif /* AVCODEC_FFT_H */
diff --git a/apps/codecs/libwmavoice/get_bits.h b/apps/codecs/libwmavoice/get_bits.h
new file mode 100644
index 0000000000..f4b3646e69
--- /dev/null
+++ b/apps/codecs/libwmavoice/get_bits.h
@@ -0,0 +1,691 @@
1/*
2 * copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21/**
22 * @file
23 * bitstream reader API header.
24 */
25
26#ifndef AVCODEC_GET_BITS_H
27#define AVCODEC_GET_BITS_H
28
29#include <stdint.h>
30#include <stdlib.h>
31#include <assert.h>
32#include "libavutil/bswap.h"
33#include "libavutil/common.h"
34#include "libavutil/intreadwrite.h"
35#include "libavutil/log.h"
36#include "mathops.h"
37
38#if defined(ALT_BITSTREAM_READER_LE) && !defined(ALT_BITSTREAM_READER)
39# define ALT_BITSTREAM_READER
40#endif
41
42#if !defined(LIBMPEG2_BITSTREAM_READER) && !defined(A32_BITSTREAM_READER) && !defined(ALT_BITSTREAM_READER)
43# if ARCH_ARM && !HAVE_FAST_UNALIGNED
44# define A32_BITSTREAM_READER
45# else
46# define ALT_BITSTREAM_READER
47//#define LIBMPEG2_BITSTREAM_READER
48//#define A32_BITSTREAM_READER
49# endif
50#endif
51
52/* bit input */
53/* buffer, buffer_end and size_in_bits must be present and used by every reader */
54typedef struct GetBitContext {
55 const uint8_t *buffer, *buffer_end;
56#ifdef ALT_BITSTREAM_READER
57 int index;
58#elif defined LIBMPEG2_BITSTREAM_READER
59 uint8_t *buffer_ptr;
60 uint32_t cache;
61 int bit_count;
62#elif defined A32_BITSTREAM_READER
63 uint32_t *buffer_ptr;
64 uint32_t cache0;
65 uint32_t cache1;
66 int bit_count;
67#endif
68 int size_in_bits;
69} GetBitContext;
70
71#define VLC_TYPE int16_t
72
73typedef struct VLC {
74 int bits;
75 VLC_TYPE (*table)[2]; ///< code, bits
76 int table_size, table_allocated;
77} VLC;
78
79typedef struct RL_VLC_ELEM {
80 int16_t level;
81 int8_t len;
82 uint8_t run;
83} RL_VLC_ELEM;
84
85/* Bitstream reader API docs:
86name
87 arbitrary name which is used as prefix for the internal variables
88
89gb
90 getbitcontext
91
92OPEN_READER(name, gb)
93 loads gb into local variables
94
95CLOSE_READER(name, gb)
96 stores local vars in gb
97
98UPDATE_CACHE(name, gb)
99 refills the internal cache from the bitstream
100 after this call at least MIN_CACHE_BITS will be available,
101
102GET_CACHE(name, gb)
103 will output the contents of the internal cache, next bit is MSB of 32 or 64 bit (FIXME 64bit)
104
105SHOW_UBITS(name, gb, num)
106 will return the next num bits
107
108SHOW_SBITS(name, gb, num)
109 will return the next num bits and do sign extension
110
111SKIP_BITS(name, gb, num)
112 will skip over the next num bits
113 note, this is equivalent to SKIP_CACHE; SKIP_COUNTER
114
115SKIP_CACHE(name, gb, num)
116 will remove the next num bits from the cache (note SKIP_COUNTER MUST be called before UPDATE_CACHE / CLOSE_READER)
117
118SKIP_COUNTER(name, gb, num)
119 will increment the internal bit counter (see SKIP_CACHE & SKIP_BITS)
120
121LAST_SKIP_CACHE(name, gb, num)
122 will remove the next num bits from the cache if it is needed for UPDATE_CACHE otherwise it will do nothing
123
124LAST_SKIP_BITS(name, gb, num)
125 is equivalent to LAST_SKIP_CACHE; SKIP_COUNTER
126
127for examples see get_bits, show_bits, skip_bits, get_vlc
128*/
129
130#ifdef ALT_BITSTREAM_READER
131# define MIN_CACHE_BITS 25
132
133# define OPEN_READER(name, gb)\
134 unsigned int name##_index= (gb)->index;\
135 int name##_cache= 0;\
136
137# define CLOSE_READER(name, gb)\
138 (gb)->index= name##_index;\
139
140# ifdef ALT_BITSTREAM_READER_LE
141# define UPDATE_CACHE(name, gb)\
142 name##_cache= AV_RL32( ((const uint8_t *)(gb)->buffer)+(name##_index>>3) ) >> (name##_index&0x07);\
143
144# define SKIP_CACHE(name, gb, num)\
145 name##_cache >>= (num);
146# else
147# define UPDATE_CACHE(name, gb)\
148 name##_cache= AV_RB32( ((const uint8_t *)(gb)->buffer)+(name##_index>>3) ) << (name##_index&0x07);\
149
150# define SKIP_CACHE(name, gb, num)\
151 name##_cache <<= (num);
152# endif
153
154// FIXME name?
155# define SKIP_COUNTER(name, gb, num)\
156 name##_index += (num);\
157
158# define SKIP_BITS(name, gb, num)\
159 {\
160 SKIP_CACHE(name, gb, num)\
161 SKIP_COUNTER(name, gb, num)\
162 }\
163
164# define LAST_SKIP_BITS(name, gb, num) SKIP_COUNTER(name, gb, num)
165# define LAST_SKIP_CACHE(name, gb, num) ;
166
167# ifdef ALT_BITSTREAM_READER_LE
168# define SHOW_UBITS(name, gb, num)\
169 zero_extend(name##_cache, num)
170
171# define SHOW_SBITS(name, gb, num)\
172 sign_extend(name##_cache, num)
173# else
174# define SHOW_UBITS(name, gb, num)\
175 NEG_USR32(name##_cache, num)
176
177# define SHOW_SBITS(name, gb, num)\
178 NEG_SSR32(name##_cache, num)
179# endif
180
181# define GET_CACHE(name, gb)\
182 ((uint32_t)name##_cache)
183
184static inline int get_bits_count(const GetBitContext *s){
185 return s->index;
186}
187
188static inline void skip_bits_long(GetBitContext *s, int n){
189 s->index += n;
190}
191
192#elif defined LIBMPEG2_BITSTREAM_READER
193//libmpeg2 like reader
194
195# define MIN_CACHE_BITS 17
196
197# define OPEN_READER(name, gb)\
198 int name##_bit_count=(gb)->bit_count;\
199 int name##_cache= (gb)->cache;\
200 uint8_t * name##_buffer_ptr=(gb)->buffer_ptr;\
201
202# define CLOSE_READER(name, gb)\
203 (gb)->bit_count= name##_bit_count;\
204 (gb)->cache= name##_cache;\
205 (gb)->buffer_ptr= name##_buffer_ptr;\
206
207# define UPDATE_CACHE(name, gb)\
208 if(name##_bit_count >= 0){\
209 name##_cache+= AV_RB16(name##_buffer_ptr) << name##_bit_count; \
210 name##_buffer_ptr+=2;\
211 name##_bit_count-= 16;\
212 }\
213
214# define SKIP_CACHE(name, gb, num)\
215 name##_cache <<= (num);\
216
217# define SKIP_COUNTER(name, gb, num)\
218 name##_bit_count += (num);\
219
220# define SKIP_BITS(name, gb, num)\
221 {\
222 SKIP_CACHE(name, gb, num)\
223 SKIP_COUNTER(name, gb, num)\
224 }\
225
226# define LAST_SKIP_BITS(name, gb, num) SKIP_BITS(name, gb, num)
227# define LAST_SKIP_CACHE(name, gb, num) SKIP_CACHE(name, gb, num)
228
229# define SHOW_UBITS(name, gb, num)\
230 NEG_USR32(name##_cache, num)
231
232# define SHOW_SBITS(name, gb, num)\
233 NEG_SSR32(name##_cache, num)
234
235# define GET_CACHE(name, gb)\
236 ((uint32_t)name##_cache)
237
238static inline int get_bits_count(const GetBitContext *s){
239 return (s->buffer_ptr - s->buffer)*8 - 16 + s->bit_count;
240}
241
242static inline void skip_bits_long(GetBitContext *s, int n){
243 OPEN_READER(re, s)
244 re_bit_count += n;
245 re_buffer_ptr += 2*(re_bit_count>>4);
246 re_bit_count &= 15;
247 re_cache = ((re_buffer_ptr[-2]<<8) + re_buffer_ptr[-1]) << (16+re_bit_count);
248 UPDATE_CACHE(re, s)
249 CLOSE_READER(re, s)
250}
251
252#elif defined A32_BITSTREAM_READER
253
254# define MIN_CACHE_BITS 32
255
256# define OPEN_READER(name, gb)\
257 int name##_bit_count=(gb)->bit_count;\
258 uint32_t name##_cache0= (gb)->cache0;\
259 uint32_t name##_cache1= (gb)->cache1;\
260 uint32_t * name##_buffer_ptr=(gb)->buffer_ptr;\
261
262# define CLOSE_READER(name, gb)\
263 (gb)->bit_count= name##_bit_count;\
264 (gb)->cache0= name##_cache0;\
265 (gb)->cache1= name##_cache1;\
266 (gb)->buffer_ptr= name##_buffer_ptr;\
267
268# define UPDATE_CACHE(name, gb)\
269 if(name##_bit_count > 0){\
270 const uint32_t next= av_be2ne32( *name##_buffer_ptr );\
271 name##_cache0 |= NEG_USR32(next,name##_bit_count);\
272 name##_cache1 |= next<<name##_bit_count;\
273 name##_buffer_ptr++;\
274 name##_bit_count-= 32;\
275 }\
276
277#if ARCH_X86
278# define SKIP_CACHE(name, gb, num)\
279 __asm__(\
280 "shldl %2, %1, %0 \n\t"\
281 "shll %2, %1 \n\t"\
282 : "+r" (name##_cache0), "+r" (name##_cache1)\
283 : "Ic" ((uint8_t)(num))\
284 );
285#else
286# define SKIP_CACHE(name, gb, num)\
287 name##_cache0 <<= (num);\
288 name##_cache0 |= NEG_USR32(name##_cache1,num);\
289 name##_cache1 <<= (num);
290#endif
291
292# define SKIP_COUNTER(name, gb, num)\
293 name##_bit_count += (num);\
294
295# define SKIP_BITS(name, gb, num)\
296 {\
297 SKIP_CACHE(name, gb, num)\
298 SKIP_COUNTER(name, gb, num)\
299 }\
300
301# define LAST_SKIP_BITS(name, gb, num) SKIP_BITS(name, gb, num)
302# define LAST_SKIP_CACHE(name, gb, num) SKIP_CACHE(name, gb, num)
303
304# define SHOW_UBITS(name, gb, num)\
305 NEG_USR32(name##_cache0, num)
306
307# define SHOW_SBITS(name, gb, num)\
308 NEG_SSR32(name##_cache0, num)
309
310# define GET_CACHE(name, gb)\
311 (name##_cache0)
312
313static inline int get_bits_count(const GetBitContext *s){
314 return ((uint8_t*)s->buffer_ptr - s->buffer)*8 - 32 + s->bit_count;
315}
316
317static inline void skip_bits_long(GetBitContext *s, int n){
318 OPEN_READER(re, s)
319 re_bit_count += n;
320 re_buffer_ptr += re_bit_count>>5;
321 re_bit_count &= 31;
322 re_cache0 = av_be2ne32( re_buffer_ptr[-1] ) << re_bit_count;
323 re_cache1 = 0;
324 UPDATE_CACHE(re, s)
325 CLOSE_READER(re, s)
326}
327
328#endif
329
330/**
331 * read mpeg1 dc style vlc (sign bit + mantisse with no MSB).
332 * if MSB not set it is negative
333 * @param n length in bits
334 * @author BERO
335 */
336static inline int get_xbits(GetBitContext *s, int n){
337 register int sign;
338 register int32_t cache;
339 OPEN_READER(re, s)
340 UPDATE_CACHE(re, s)
341 cache = GET_CACHE(re,s);
342 sign=(~cache)>>31;
343 LAST_SKIP_BITS(re, s, n)
344 CLOSE_READER(re, s)
345 return (NEG_USR32(sign ^ cache, n) ^ sign) - sign;
346}
347
348static inline int get_sbits(GetBitContext *s, int n){
349 register int tmp;
350 OPEN_READER(re, s)
351 UPDATE_CACHE(re, s)
352 tmp= SHOW_SBITS(re, s, n);
353 LAST_SKIP_BITS(re, s, n)
354 CLOSE_READER(re, s)
355 return tmp;
356}
357
358/**
359 * reads 1-17 bits.
360 * Note, the alt bitstream reader can read up to 25 bits, but the libmpeg2 reader can't
361 */
362static inline unsigned int get_bits(GetBitContext *s, int n){
363 register int tmp;
364 OPEN_READER(re, s)
365 UPDATE_CACHE(re, s)
366 tmp= SHOW_UBITS(re, s, n);
367 LAST_SKIP_BITS(re, s, n)
368 CLOSE_READER(re, s)
369 return tmp;
370}
371
372/**
373 * shows 1-17 bits.
374 * Note, the alt bitstream reader can read up to 25 bits, but the libmpeg2 reader can't
375 */
376static inline unsigned int show_bits(GetBitContext *s, int n){
377 register int tmp;
378 OPEN_READER(re, s)
379 UPDATE_CACHE(re, s)
380 tmp= SHOW_UBITS(re, s, n);
381// CLOSE_READER(re, s)
382 return tmp;
383}
384
385static inline void skip_bits(GetBitContext *s, int n){
386 //Note gcc seems to optimize this to s->index+=n for the ALT_READER :))
387 OPEN_READER(re, s)
388 UPDATE_CACHE(re, s)
389 LAST_SKIP_BITS(re, s, n)
390 CLOSE_READER(re, s)
391}
392
393static inline unsigned int get_bits1(GetBitContext *s){
394#ifdef ALT_BITSTREAM_READER
395 unsigned int index= s->index;
396 uint8_t result= s->buffer[ index>>3 ];
397#ifdef ALT_BITSTREAM_READER_LE
398 result>>= (index&0x07);
399 result&= 1;
400#else
401 result<<= (index&0x07);
402 result>>= 8 - 1;
403#endif
404 index++;
405 s->index= index;
406
407 return result;
408#else
409 return get_bits(s, 1);
410#endif
411}
412
413static inline unsigned int show_bits1(GetBitContext *s){
414 return show_bits(s, 1);
415}
416
417static inline void skip_bits1(GetBitContext *s){
418 skip_bits(s, 1);
419}
420
421/**
422 * reads 0-32 bits.
423 */
424static inline unsigned int get_bits_long(GetBitContext *s, int n){
425 if(n<=MIN_CACHE_BITS) return get_bits(s, n);
426 else{
427#ifdef ALT_BITSTREAM_READER_LE
428 int ret= get_bits(s, 16);
429 return ret | (get_bits(s, n-16) << 16);
430#else
431 int ret= get_bits(s, 16) << (n-16);
432 return ret | get_bits(s, n-16);
433#endif
434 }
435}
436
437/**
438 * reads 0-32 bits as a signed integer.
439 */
440static inline int get_sbits_long(GetBitContext *s, int n) {
441 return sign_extend(get_bits_long(s, n), n);
442}
443
444/**
445 * shows 0-32 bits.
446 */
447static inline unsigned int show_bits_long(GetBitContext *s, int n){
448 if(n<=MIN_CACHE_BITS) return show_bits(s, n);
449 else{
450 GetBitContext gb= *s;
451 return get_bits_long(&gb, n);
452 }
453}
454
455static inline int check_marker(GetBitContext *s, const char *msg)
456{
457 int bit= get_bits1(s);
458 if(!bit)
459 av_log(NULL, AV_LOG_INFO, "Marker bit missing %s\n", msg);
460
461 return bit;
462}
463
464/**
465 * init GetBitContext.
466 * @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes larger then the actual read bits
467 * because some optimized bitstream readers read 32 or 64 bit at once and could read over the end
468 * @param bit_size the size of the buffer in bits
469 *
470 * While GetBitContext stores the buffer size, for performance reasons you are
471 * responsible for checking for the buffer end yourself (take advantage of the padding)!
472 */
473static inline void init_get_bits(GetBitContext *s,
474 const uint8_t *buffer, int bit_size)
475{
476 int buffer_size= (bit_size+7)>>3;
477 if(buffer_size < 0 || bit_size < 0) {
478 buffer_size = bit_size = 0;
479 buffer = NULL;
480 }
481
482 s->buffer= buffer;
483 s->size_in_bits= bit_size;
484 s->buffer_end= buffer + buffer_size;
485#ifdef ALT_BITSTREAM_READER
486 s->index=0;
487#elif defined LIBMPEG2_BITSTREAM_READER
488 s->buffer_ptr = (uint8_t*)((intptr_t)buffer&(~1));
489 s->bit_count = 16 + 8*((intptr_t)buffer&1);
490 skip_bits_long(s, 0);
491#elif defined A32_BITSTREAM_READER
492 s->buffer_ptr = (uint32_t*)((intptr_t)buffer&(~3));
493 s->bit_count = 32 + 8*((intptr_t)buffer&3);
494 skip_bits_long(s, 0);
495#endif
496}
497
498static inline void align_get_bits(GetBitContext *s)
499{
500 int n= (-get_bits_count(s)) & 7;
501 if(n) skip_bits(s, n);
502}
503
504#define init_vlc(vlc, nb_bits, nb_codes,\
505 bits, bits_wrap, bits_size,\
506 codes, codes_wrap, codes_size,\
507 flags)\
508 init_vlc_sparse(vlc, nb_bits, nb_codes,\
509 bits, bits_wrap, bits_size,\
510 codes, codes_wrap, codes_size,\
511 NULL, 0, 0, flags)
512
513int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes,
514 const void *bits, int bits_wrap, int bits_size,
515 const void *codes, int codes_wrap, int codes_size,
516 const void *symbols, int symbols_wrap, int symbols_size,
517 int flags);
518#define INIT_VLC_LE 2
519#define INIT_VLC_USE_NEW_STATIC 4
520void free_vlc(VLC *vlc);
521
522#define INIT_VLC_STATIC(vlc, bits, a,b,c,d,e,f,g, static_size)\
523{\
524 static VLC_TYPE table[static_size][2];\
525 (vlc)->table= table;\
526 (vlc)->table_allocated= static_size;\
527 init_vlc(vlc, bits, a,b,c,d,e,f,g, INIT_VLC_USE_NEW_STATIC);\
528}
529
530
531/**
532 *
533 * If the vlc code is invalid and max_depth=1, then no bits will be removed.
534 * If the vlc code is invalid and max_depth>1, then the number of bits removed
535 * is undefined.
536 */
537#define GET_VLC(code, name, gb, table, bits, max_depth)\
538{\
539 int n, nb_bits;\
540 unsigned int index;\
541\
542 index= SHOW_UBITS(name, gb, bits);\
543 code = table[index][0];\
544 n = table[index][1];\
545\
546 if(max_depth > 1 && n < 0){\
547 LAST_SKIP_BITS(name, gb, bits)\
548 UPDATE_CACHE(name, gb)\
549\
550 nb_bits = -n;\
551\
552 index= SHOW_UBITS(name, gb, nb_bits) + code;\
553 code = table[index][0];\
554 n = table[index][1];\
555 if(max_depth > 2 && n < 0){\
556 LAST_SKIP_BITS(name, gb, nb_bits)\
557 UPDATE_CACHE(name, gb)\
558\
559 nb_bits = -n;\
560\
561 index= SHOW_UBITS(name, gb, nb_bits) + code;\
562 code = table[index][0];\
563 n = table[index][1];\
564 }\
565 }\
566 SKIP_BITS(name, gb, n)\
567}
568
569#define GET_RL_VLC(level, run, name, gb, table, bits, max_depth, need_update)\
570{\
571 int n, nb_bits;\
572 unsigned int index;\
573\
574 index= SHOW_UBITS(name, gb, bits);\
575 level = table[index].level;\
576 n = table[index].len;\
577\
578 if(max_depth > 1 && n < 0){\
579 SKIP_BITS(name, gb, bits)\
580 if(need_update){\
581 UPDATE_CACHE(name, gb)\
582 }\
583\
584 nb_bits = -n;\
585\
586 index= SHOW_UBITS(name, gb, nb_bits) + level;\
587 level = table[index].level;\
588 n = table[index].len;\
589 }\
590 run= table[index].run;\
591 SKIP_BITS(name, gb, n)\
592}
593
594
595/**
596 * parses a vlc code, faster then get_vlc()
597 * @param bits is the number of bits which will be read at once, must be
598 * identical to nb_bits in init_vlc()
599 * @param max_depth is the number of times bits bits must be read to completely
600 * read the longest vlc code
601 * = (max_vlc_length + bits - 1) / bits
602 */
603static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE (*table)[2],
604 int bits, int max_depth)
605{
606 int code;
607
608 OPEN_READER(re, s)
609 UPDATE_CACHE(re, s)
610
611 GET_VLC(code, re, s, table, bits, max_depth)
612
613 CLOSE_READER(re, s)
614 return code;
615}
616
617//#define TRACE
618
619#ifdef TRACE
620static inline void print_bin(int bits, int n){
621 int i;
622
623 for(i=n-1; i>=0; i--){
624 av_log(NULL, AV_LOG_DEBUG, "%d", (bits>>i)&1);
625 }
626 for(i=n; i<24; i++)
627 av_log(NULL, AV_LOG_DEBUG, " ");
628}
629
630static inline int get_bits_trace(GetBitContext *s, int n, char *file, const char *func, int line){
631 int r= get_bits(s, n);
632
633 print_bin(r, n);
634 av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d bit @%5d in %s %s:%d\n", r, n, r, get_bits_count(s)-n, file, func, line);
635 return r;
636}
637static inline int get_vlc_trace(GetBitContext *s, VLC_TYPE (*table)[2], int bits, int max_depth, char *file, const char *func, int line){
638 int show= show_bits(s, 24);
639 int pos= get_bits_count(s);
640 int r= get_vlc2(s, table, bits, max_depth);
641 int len= get_bits_count(s) - pos;
642 int bits2= show>>(24-len);
643
644 print_bin(bits2, len);
645
646 av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d vlc @%5d in %s %s:%d\n", bits2, len, r, pos, file, func, line);
647 return r;
648}
649static inline int get_xbits_trace(GetBitContext *s, int n, char *file, const char *func, int line){
650 int show= show_bits(s, n);
651 int r= get_xbits(s, n);
652
653 print_bin(show, n);
654 av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d xbt @%5d in %s %s:%d\n", show, n, r, get_bits_count(s)-n, file, func, line);
655 return r;
656}
657
658#define get_bits(s, n) get_bits_trace(s, n, __FILE__, __PRETTY_FUNCTION__, __LINE__)
659#define get_bits1(s) get_bits_trace(s, 1, __FILE__, __PRETTY_FUNCTION__, __LINE__)
660#define get_xbits(s, n) get_xbits_trace(s, n, __FILE__, __PRETTY_FUNCTION__, __LINE__)
661#define get_vlc(s, vlc) get_vlc_trace(s, (vlc)->table, (vlc)->bits, 3, __FILE__, __PRETTY_FUNCTION__, __LINE__)
662#define get_vlc2(s, tab, bits, max) get_vlc_trace(s, tab, bits, max, __FILE__, __PRETTY_FUNCTION__, __LINE__)
663
664#define tprintf(p, ...) av_log(p, AV_LOG_DEBUG, __VA_ARGS__)
665
666#else //TRACE
667#define tprintf(p, ...) {}
668#endif
669
670static inline int decode012(GetBitContext *gb){
671 int n;
672 n = get_bits1(gb);
673 if (n == 0)
674 return 0;
675 else
676 return get_bits1(gb) + 1;
677}
678
679static inline int decode210(GetBitContext *gb){
680 if (get_bits1(gb))
681 return 0;
682 else
683 return 2 - get_bits1(gb);
684}
685
686static inline int get_bits_left(GetBitContext *gb)
687{
688 return gb->size_in_bits - get_bits_count(gb);
689}
690
691#endif /* AVCODEC_GET_BITS_H */
diff --git a/apps/codecs/libwmavoice/internal.h b/apps/codecs/libwmavoice/internal.h
new file mode 100644
index 0000000000..24aca6b28b
--- /dev/null
+++ b/apps/codecs/libwmavoice/internal.h
@@ -0,0 +1,53 @@
1/*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19/**
20 * @file
21 * common internal api header.
22 */
23
24#ifndef AVCODEC_INTERNAL_H
25#define AVCODEC_INTERNAL_H
26
27#include <stdint.h>
28#include "avcodec.h"
29
30/**
31 * Determine whether pix_fmt is a hardware accelerated format.
32 */
33int ff_is_hwaccel_pix_fmt(enum PixelFormat pix_fmt);
34
35/**
36 * Return the hardware accelerated codec for codec codec_id and
37 * pixel format pix_fmt.
38 *
39 * @param codec_id the codec to match
40 * @param pix_fmt the pixel format to match
41 * @return the hardware accelerated codec, or NULL if none was found.
42 */
43AVHWAccel *ff_find_hwaccel(enum CodecID codec_id, enum PixelFormat pix_fmt);
44
45/**
46 * Return the index into tab at which {a,b} match elements {[0],[1]} of tab.
47 * If there is no such matching pair then size is returned.
48 */
49int ff_match_2uint16(const uint16_t (*tab)[2], int size, int a, int b);
50
51unsigned int ff_toupper4(unsigned int x);
52
53#endif /* AVCODEC_INTERNAL_H */
diff --git a/apps/codecs/libwmavoice/libavutil/attributes.h b/apps/codecs/libwmavoice/libavutil/attributes.h
new file mode 100644
index 0000000000..a95bb02e89
--- /dev/null
+++ b/apps/codecs/libwmavoice/libavutil/attributes.h
@@ -0,0 +1,121 @@
1/*
2 * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21/**
22 * @file
23 * Macro definitions for various function/variable attributes
24 */
25
26#ifndef AVUTIL_ATTRIBUTES_H
27#define AVUTIL_ATTRIBUTES_H
28
29#ifdef __GNUC__
30# define AV_GCC_VERSION_AT_LEAST(x,y) (__GNUC__ > x || __GNUC__ == x && __GNUC_MINOR__ >= y)
31#else
32# define AV_GCC_VERSION_AT_LEAST(x,y) 0
33#endif
34
35#ifndef av_always_inline
36#if AV_GCC_VERSION_AT_LEAST(3,1)
37# define av_always_inline __attribute__((always_inline)) inline
38#else
39# define av_always_inline inline
40#endif
41#endif
42
43#ifndef av_noinline
44#if AV_GCC_VERSION_AT_LEAST(3,1)
45# define av_noinline __attribute__((noinline))
46#else
47# define av_noinline
48#endif
49#endif
50
51#ifndef av_pure
52#if AV_GCC_VERSION_AT_LEAST(3,1)
53# define av_pure __attribute__((pure))
54#else
55# define av_pure
56#endif
57#endif
58
59#ifndef av_const
60#if AV_GCC_VERSION_AT_LEAST(2,6)
61# define av_const __attribute__((const))
62#else
63# define av_const
64#endif
65#endif
66
67#ifndef av_cold
68#if (!defined(__ICC) || __ICC > 1110) && AV_GCC_VERSION_AT_LEAST(4,3)
69# define av_cold __attribute__((cold))
70#else
71# define av_cold
72#endif
73#endif
74
75#ifndef av_flatten
76#if (!defined(__ICC) || __ICC > 1110) && AV_GCC_VERSION_AT_LEAST(4,1)
77# define av_flatten __attribute__((flatten))
78#else
79# define av_flatten
80#endif
81#endif
82
83#ifndef attribute_deprecated
84#if AV_GCC_VERSION_AT_LEAST(3,1)
85# define attribute_deprecated __attribute__((deprecated))
86#else
87# define attribute_deprecated
88#endif
89#endif
90
91#ifndef av_unused
92#if defined(__GNUC__)
93# define av_unused __attribute__((unused))
94#else
95# define av_unused
96#endif
97#endif
98
99#ifndef av_alias
100#if (!defined(__ICC) || __ICC > 1110) && AV_GCC_VERSION_AT_LEAST(3,3)
101# define av_alias __attribute__((may_alias))
102#else
103# define av_alias
104#endif
105#endif
106
107#ifndef av_uninit
108#if defined(__GNUC__) && !defined(__ICC)
109# define av_uninit(x) x=x
110#else
111# define av_uninit(x) x
112#endif
113#endif
114
115#ifdef __GNUC__
116# define av_builtin_constant_p __builtin_constant_p
117#else
118# define av_builtin_constant_p(x) 0
119#endif
120
121#endif /* AVUTIL_ATTRIBUTES_H */
diff --git a/apps/codecs/libwmavoice/libavutil/avutil.h b/apps/codecs/libwmavoice/libavutil/avutil.h
new file mode 100644
index 0000000000..50b29fc4a7
--- /dev/null
+++ b/apps/codecs/libwmavoice/libavutil/avutil.h
@@ -0,0 +1,89 @@
1/*
2 * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#ifndef AVUTIL_AVUTIL_H
22#define AVUTIL_AVUTIL_H
23
24/**
25 * @file
26 * external API header
27 */
28
29
30#define AV_STRINGIFY(s) AV_TOSTRING(s)
31#define AV_TOSTRING(s) #s
32
33#define AV_GLUE(a, b) a ## b
34#define AV_JOIN(a, b) AV_GLUE(a, b)
35
36#define AV_PRAGMA(s) _Pragma(#s)
37
38#define AV_VERSION_INT(a, b, c) (a<<16 | b<<8 | c)
39#define AV_VERSION_DOT(a, b, c) a ##.## b ##.## c
40#define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
41
42#define LIBAVUTIL_VERSION_MAJOR 50
43#define LIBAVUTIL_VERSION_MINOR 23
44#define LIBAVUTIL_VERSION_MICRO 0
45
46#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
47 LIBAVUTIL_VERSION_MINOR, \
48 LIBAVUTIL_VERSION_MICRO)
49#define LIBAVUTIL_VERSION AV_VERSION(LIBAVUTIL_VERSION_MAJOR, \
50 LIBAVUTIL_VERSION_MINOR, \
51 LIBAVUTIL_VERSION_MICRO)
52#define LIBAVUTIL_BUILD LIBAVUTIL_VERSION_INT
53
54#define LIBAVUTIL_IDENT "Lavu" AV_STRINGIFY(LIBAVUTIL_VERSION)
55
56/**
57 * Return the LIBAVUTIL_VERSION_INT constant.
58 */
59unsigned avutil_version(void);
60
61/**
62 * Return the libavutil build-time configuration.
63 */
64const char *avutil_configuration(void);
65
66/**
67 * Return the libavutil license.
68 */
69const char *avutil_license(void);
70
71enum AVMediaType {
72 AVMEDIA_TYPE_UNKNOWN = -1,
73 AVMEDIA_TYPE_VIDEO,
74 AVMEDIA_TYPE_AUDIO,
75 AVMEDIA_TYPE_DATA,
76 AVMEDIA_TYPE_SUBTITLE,
77 AVMEDIA_TYPE_ATTACHMENT,
78 AVMEDIA_TYPE_NB
79};
80
81#include "common.h"
82#include "error.h"
83#include "mathematics.h"
84#include "rational.h"
85#include "intfloat_readwrite.h"
86#include "log.h"
87#include "pixfmt.h"
88
89#endif /* AVUTIL_AVUTIL_H */
diff --git a/apps/codecs/libwmavoice/libavutil/bswap.h b/apps/codecs/libwmavoice/libavutil/bswap.h
new file mode 100644
index 0000000000..303bcf3532
--- /dev/null
+++ b/apps/codecs/libwmavoice/libavutil/bswap.h
@@ -0,0 +1,124 @@
1/*
2 * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21/**
22 * @file
23 * byte swapping routines
24 */
25
26#ifndef AVUTIL_BSWAP_H
27#define AVUTIL_BSWAP_H
28
29#include <stdint.h>
30#include "libavutil/avconfig.h"
31#include "attributes.h"
32
33#ifdef HAVE_AV_CONFIG_H
34
35#include "config.h"
36
37#if ARCH_ARM
38# include "arm/bswap.h"
39#elif ARCH_AVR32
40# include "avr32/bswap.h"
41#elif ARCH_BFIN
42# include "bfin/bswap.h"
43#elif ARCH_SH4
44# include "sh4/bswap.h"
45#elif ARCH_X86
46# include "x86/bswap.h"
47#endif
48
49#endif /* HAVE_AV_CONFIG_H */
50
51#define AV_BSWAP16C(x) (((x) << 8 & 0xff00) | ((x) >> 8 & 0x00ff))
52#define AV_BSWAP32C(x) (AV_BSWAP16C(x) << 16 | AV_BSWAP16C((x) >> 16))
53#define AV_BSWAP64C(x) (AV_BSWAP32C(x) << 32 | AV_BSWAP32C((x) >> 32))
54
55#define AV_BSWAPC(s, x) AV_BSWAP##s##C(x)
56
57#ifndef av_bswap16
58static av_always_inline av_const uint16_t av_bswap16(uint16_t x)
59{
60 x= (x>>8) | (x<<8);
61 return x;
62}
63#endif
64
65#ifndef av_bswap32
66static av_always_inline av_const uint32_t av_bswap32(uint32_t x)
67{
68 x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
69 x= (x>>16) | (x<<16);
70 return x;
71}
72#endif
73
74#ifndef av_bswap64
75static inline uint64_t av_const av_bswap64(uint64_t x)
76{
77#if 0
78 x= ((x<< 8)&0xFF00FF00FF00FF00ULL) | ((x>> 8)&0x00FF00FF00FF00FFULL);
79 x= ((x<<16)&0xFFFF0000FFFF0000ULL) | ((x>>16)&0x0000FFFF0000FFFFULL);
80 return (x>>32) | (x<<32);
81#else
82 union {
83 uint64_t ll;
84 uint32_t l[2];
85 } w, r;
86 w.ll = x;
87 r.l[0] = av_bswap32 (w.l[1]);
88 r.l[1] = av_bswap32 (w.l[0]);
89 return r.ll;
90#endif
91}
92#endif
93
94// be2ne ... big-endian to native-endian
95// le2ne ... little-endian to native-endian
96
97#if AV_HAVE_BIGENDIAN
98#define av_be2ne16(x) (x)
99#define av_be2ne32(x) (x)
100#define av_be2ne64(x) (x)
101#define av_le2ne16(x) av_bswap16(x)
102#define av_le2ne32(x) av_bswap32(x)
103#define av_le2ne64(x) av_bswap64(x)
104#define AV_BE2NEC(s, x) (x)
105#define AV_LE2NEC(s, x) AV_BSWAPC(s, x)
106#else
107#define av_be2ne16(x) av_bswap16(x)
108#define av_be2ne32(x) av_bswap32(x)
109#define av_be2ne64(x) av_bswap64(x)
110#define av_le2ne16(x) (x)
111#define av_le2ne32(x) (x)
112#define av_le2ne64(x) (x)
113#define AV_BE2NEC(s, x) AV_BSWAPC(s, x)
114#define AV_LE2NEC(s, x) (x)
115#endif
116
117#define AV_BE2NE16C(x) AV_BE2NEC(16, x)
118#define AV_BE2NE32C(x) AV_BE2NEC(32, x)
119#define AV_BE2NE64C(x) AV_BE2NEC(64, x)
120#define AV_LE2NE16C(x) AV_LE2NEC(16, x)
121#define AV_LE2NE32C(x) AV_LE2NEC(32, x)
122#define AV_LE2NE64C(x) AV_LE2NEC(64, x)
123
124#endif /* AVUTIL_BSWAP_H */
diff --git a/apps/codecs/libwmavoice/libavutil/common.h b/apps/codecs/libwmavoice/libavutil/common.h
new file mode 100644
index 0000000000..f9c03db559
--- /dev/null
+++ b/apps/codecs/libwmavoice/libavutil/common.h
@@ -0,0 +1,346 @@
1/*
2 * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21/**
22 * @file
23 * common internal and external API header
24 */
25
26#ifndef AVUTIL_COMMON_H
27#define AVUTIL_COMMON_H
28
29#include <ctype.h>
30#include <errno.h>
31#include <inttypes.h>
32#include <limits.h>
33#include <math.h>
34#include <stdio.h>
35#include <stdlib.h>
36#include <string.h>
37#include "attributes.h"
38
39//rounded division & shift
40#define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b))
41/* assume b>0 */
42#define ROUNDED_DIV(a,b) (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b))
43#define FFABS(a) ((a) >= 0 ? (a) : (-(a)))
44#define FFSIGN(a) ((a) > 0 ? 1 : -1)
45
46#define FFMAX(a,b) ((a) > (b) ? (a) : (b))
47#define FFMAX3(a,b,c) FFMAX(FFMAX(a,b),c)
48#define FFMIN(a,b) ((a) > (b) ? (b) : (a))
49#define FFMIN3(a,b,c) FFMIN(FFMIN(a,b),c)
50
51#define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0)
52#define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0]))
53#define FFALIGN(x, a) (((x)+(a)-1)&~((a)-1))
54
55/* misc math functions */
56extern const uint8_t ff_log2_tab[256];
57
58extern const uint8_t av_reverse[256];
59
60static inline av_const int av_log2_c(unsigned int v)
61{
62 int n = 0;
63 if (v & 0xffff0000) {
64 v >>= 16;
65 n += 16;
66 }
67 if (v & 0xff00) {
68 v >>= 8;
69 n += 8;
70 }
71 n += ff_log2_tab[v];
72
73 return n;
74}
75
76static inline av_const int av_log2_16bit_c(unsigned int v)
77{
78 int n = 0;
79 if (v & 0xff00) {
80 v >>= 8;
81 n += 8;
82 }
83 n += ff_log2_tab[v];
84
85 return n;
86}
87
88#ifdef HAVE_AV_CONFIG_H
89# include "config.h"
90# include "intmath.h"
91#endif
92
93/* Pull in unguarded fallback defines at the end of this file. */
94#include "common.h"
95
96/**
97 * Clip a signed integer value into the amin-amax range.
98 * @param a value to clip
99 * @param amin minimum value of the clip range
100 * @param amax maximum value of the clip range
101 * @return clipped value
102 */
103static inline av_const int av_clip_c(int a, int amin, int amax)
104{
105 if (a < amin) return amin;
106 else if (a > amax) return amax;
107 else return a;
108}
109
110/**
111 * Clip a signed integer value into the 0-255 range.
112 * @param a value to clip
113 * @return clipped value
114 */
115static inline av_const uint8_t av_clip_uint8_c(int a)
116{
117 if (a&(~0xFF)) return (-a)>>31;
118 else return a;
119}
120
121/**
122 * Clip a signed integer value into the -128,127 range.
123 * @param a value to clip
124 * @return clipped value
125 */
126static inline av_const int8_t av_clip_int8_c(int a)
127{
128 if ((a+0x80) & ~0xFF) return (a>>31) ^ 0x7F;
129 else return a;
130}
131
132/**
133 * Clip a signed integer value into the 0-65535 range.
134 * @param a value to clip
135 * @return clipped value
136 */
137static inline av_const uint16_t av_clip_uint16_c(int a)
138{
139 if (a&(~0xFFFF)) return (-a)>>31;
140 else return a;
141}
142
143/**
144 * Clip a signed integer value into the -32768,32767 range.
145 * @param a value to clip
146 * @return clipped value
147 */
148static inline av_const int16_t av_clip_int16_c(int a)
149{
150 if ((a+0x8000) & ~0xFFFF) return (a>>31) ^ 0x7FFF;
151 else return a;
152}
153
154/**
155 * Clip a signed 64-bit integer value into the -2147483648,2147483647 range.
156 * @param a value to clip
157 * @return clipped value
158 */
159static inline av_const int32_t av_clipl_int32_c(int64_t a)
160{
161 if ((a+0x80000000u) & ~UINT64_C(0xFFFFFFFF)) return (a>>63) ^ 0x7FFFFFFF;
162 else return a;
163}
164
165/**
166 * Clip a float value into the amin-amax range.
167 * @param a value to clip
168 * @param amin minimum value of the clip range
169 * @param amax maximum value of the clip range
170 * @return clipped value
171 */
172static inline av_const float av_clipf_c(float a, float amin, float amax)
173{
174 if (a < amin) return amin;
175 else if (a > amax) return amax;
176 else return a;
177}
178
179/** Compute ceil(log2(x)).
180 * @param x value used to compute ceil(log2(x))
181 * @return computed ceiling of log2(x)
182 */
183static inline av_const int av_ceil_log2_c(int x)
184{
185 return av_log2((x - 1) << 1);
186}
187
188#define MKTAG(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((d) << 24))
189#define MKBETAG(a,b,c,d) ((d) | ((c) << 8) | ((b) << 16) | ((a) << 24))
190
191/**
192 * Convert a UTF-8 character (up to 4 bytes) to its 32-bit UCS-4 encoded form.
193 *
194 * @param val Output value, must be an lvalue of type uint32_t.
195 * @param GET_BYTE Expression reading one byte from the input.
196 * Evaluated up to 7 times (4 for the currently
197 * assigned Unicode range). With a memory buffer
198 * input, this could be *ptr++.
199 * @param ERROR Expression to be evaluated on invalid input,
200 * typically a goto statement.
201 */
202#define GET_UTF8(val, GET_BYTE, ERROR)\
203 val= GET_BYTE;\
204 {\
205 int ones= 7 - av_log2(val ^ 255);\
206 if(ones==1)\
207 ERROR\
208 val&= 127>>ones;\
209 while(--ones > 0){\
210 int tmp= GET_BYTE - 128;\
211 if(tmp>>6)\
212 ERROR\
213 val= (val<<6) + tmp;\
214 }\
215 }
216
217/**
218 * Convert a UTF-16 character (2 or 4 bytes) to its 32-bit UCS-4 encoded form.
219 *
220 * @param val Output value, must be an lvalue of type uint32_t.
221 * @param GET_16BIT Expression returning two bytes of UTF-16 data converted
222 * to native byte order. Evaluated one or two times.
223 * @param ERROR Expression to be evaluated on invalid input,
224 * typically a goto statement.
225 */
226#define GET_UTF16(val, GET_16BIT, ERROR)\
227 val = GET_16BIT;\
228 {\
229 unsigned int hi = val - 0xD800;\
230 if (hi < 0x800) {\
231 val = GET_16BIT - 0xDC00;\
232 if (val > 0x3FFU || hi > 0x3FFU)\
233 ERROR\
234 val += (hi<<10) + 0x10000;\
235 }\
236 }\
237
238/*!
239 * \def PUT_UTF8(val, tmp, PUT_BYTE)
240 * Convert a 32-bit Unicode character to its UTF-8 encoded form (up to 4 bytes long).
241 * \param val is an input-only argument and should be of type uint32_t. It holds
242 * a UCS-4 encoded Unicode character that is to be converted to UTF-8. If
243 * val is given as a function it is executed only once.
244 * \param tmp is a temporary variable and should be of type uint8_t. It
245 * represents an intermediate value during conversion that is to be
246 * output by PUT_BYTE.
247 * \param PUT_BYTE writes the converted UTF-8 bytes to any proper destination.
248 * It could be a function or a statement, and uses tmp as the input byte.
249 * For example, PUT_BYTE could be "*output++ = tmp;" PUT_BYTE will be
250 * executed up to 4 times for values in the valid UTF-8 range and up to
251 * 7 times in the general case, depending on the length of the converted
252 * Unicode character.
253 */
254#define PUT_UTF8(val, tmp, PUT_BYTE)\
255 {\
256 int bytes, shift;\
257 uint32_t in = val;\
258 if (in < 0x80) {\
259 tmp = in;\
260 PUT_BYTE\
261 } else {\
262 bytes = (av_log2(in) + 4) / 5;\
263 shift = (bytes - 1) * 6;\
264 tmp = (256 - (256 >> bytes)) | (in >> shift);\
265 PUT_BYTE\
266 while (shift >= 6) {\
267 shift -= 6;\
268 tmp = 0x80 | ((in >> shift) & 0x3f);\
269 PUT_BYTE\
270 }\
271 }\
272 }
273
274/*!
275 * \def PUT_UTF16(val, tmp, PUT_16BIT)
276 * Convert a 32-bit Unicode character to its UTF-16 encoded form (2 or 4 bytes).
277 * \param val is an input-only argument and should be of type uint32_t. It holds
278 * a UCS-4 encoded Unicode character that is to be converted to UTF-16. If
279 * val is given as a function it is executed only once.
280 * \param tmp is a temporary variable and should be of type uint16_t. It
281 * represents an intermediate value during conversion that is to be
282 * output by PUT_16BIT.
283 * \param PUT_16BIT writes the converted UTF-16 data to any proper destination
284 * in desired endianness. It could be a function or a statement, and uses tmp
285 * as the input byte. For example, PUT_BYTE could be "*output++ = tmp;"
286 * PUT_BYTE will be executed 1 or 2 times depending on input character.
287 */
288#define PUT_UTF16(val, tmp, PUT_16BIT)\
289 {\
290 uint32_t in = val;\
291 if (in < 0x10000) {\
292 tmp = in;\
293 PUT_16BIT\
294 } else {\
295 tmp = 0xD800 | ((in - 0x10000) >> 10);\
296 PUT_16BIT\
297 tmp = 0xDC00 | ((in - 0x10000) & 0x3FF);\
298 PUT_16BIT\
299 }\
300 }\
301
302
303
304#include "mem.h"
305
306#ifdef HAVE_AV_CONFIG_H
307# include "internal.h"
308#endif /* HAVE_AV_CONFIG_H */
309
310#endif /* AVUTIL_COMMON_H */
311
312/*
313 * The following definitions are outside the multiple inclusion guard
314 * to ensure they are immediately available in intmath.h.
315 */
316
317#ifndef av_log2
318# define av_log2 av_log2_c
319#endif
320#ifndef av_log2_16bit
321# define av_log2_16bit av_log2_16bit_c
322#endif
323#ifndef av_ceil_log2
324# define av_ceil_log2 av_ceil_log2_c
325#endif
326#ifndef av_clip
327# define av_clip av_clip_c
328#endif
329#ifndef av_clip_uint8
330# define av_clip_uint8 av_clip_uint8_c
331#endif
332#ifndef av_clip_int8
333# define av_clip_int8 av_clip_int8_c
334#endif
335#ifndef av_clip_uint16
336# define av_clip_uint16 av_clip_uint16_c
337#endif
338#ifndef av_clip_int16
339# define av_clip_int16 av_clip_int16_c
340#endif
341#ifndef av_clipl_int32
342# define av_clipl_int32 av_clipl_int32_c
343#endif
344#ifndef av_clipf
345# define av_clipf av_clipf_c
346#endif
diff --git a/apps/codecs/libwmavoice/libavutil/internal.h b/apps/codecs/libwmavoice/libavutil/internal.h
new file mode 100644
index 0000000000..53d2b94c50
--- /dev/null
+++ b/apps/codecs/libwmavoice/libavutil/internal.h
@@ -0,0 +1,234 @@
1/*
2 * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21/**
22 * @file
23 * common internal API header
24 */
25
26#ifndef AVUTIL_INTERNAL_H
27#define AVUTIL_INTERNAL_H
28
29#if !defined(DEBUG) && !defined(NDEBUG)
30# define NDEBUG
31#endif
32
33#include <limits.h>
34#include <stdint.h>
35#include <stddef.h>
36#include <assert.h>
37#include "config.h"
38#include "attributes.h"
39#include "timer.h"
40
41#ifndef attribute_align_arg
42#if ARCH_X86_32 && (!defined(__ICC) || __ICC > 1110) && AV_GCC_VERSION_AT_LEAST(4,2)
43# define attribute_align_arg __attribute__((force_align_arg_pointer))
44#else
45# define attribute_align_arg
46#endif
47#endif
48
49
50/**
51 * Mark a variable as used and prevent the compiler from optimizing it away.
52 * This is useful for asm that accesses varibles in ways that the compiler does not
53 * understand
54 */
55#ifndef attribute_used
56#if AV_GCC_VERSION_AT_LEAST(3,1)
57# define attribute_used __attribute__((used))
58#else
59# define attribute_used
60#endif
61#endif
62
63#ifndef INT16_MIN
64#define INT16_MIN (-0x7fff - 1)
65#endif
66
67#ifndef INT16_MAX
68#define INT16_MAX 0x7fff
69#endif
70
71#ifndef INT32_MIN
72#define INT32_MIN (-0x7fffffff - 1)
73#endif
74
75#ifndef INT32_MAX
76#define INT32_MAX 0x7fffffff
77#endif
78
79#ifndef UINT32_MAX
80#define UINT32_MAX 0xffffffff
81#endif
82
83#ifndef INT64_MIN
84#define INT64_MIN (-0x7fffffffffffffffLL - 1)
85#endif
86
87#ifndef INT64_MAX
88#define INT64_MAX INT64_C(9223372036854775807)
89#endif
90
91#ifndef UINT64_MAX
92#define UINT64_MAX UINT64_C(0xFFFFFFFFFFFFFFFF)
93#endif
94
95#ifndef INT_BIT
96# define INT_BIT (CHAR_BIT * sizeof(int))
97#endif
98
99#ifndef offsetof
100# define offsetof(T, F) ((unsigned int)((char *)&((T *)0)->F))
101#endif
102
103/* Use to export labels from asm. */
104#define LABEL_MANGLE(a) EXTERN_PREFIX #a
105
106// Use rip-relative addressing if compiling PIC code on x86-64.
107#if ARCH_X86_64 && defined(PIC)
108# define LOCAL_MANGLE(a) #a "(%%rip)"
109#else
110# define LOCAL_MANGLE(a) #a
111#endif
112
113#define MANGLE(a) EXTERN_PREFIX LOCAL_MANGLE(a)
114
115/* debug stuff */
116
117/* dprintf macros */
118#ifdef DEBUG
119# define dprintf(pctx, ...) av_log(pctx, AV_LOG_DEBUG, __VA_ARGS__)
120#else
121# define dprintf(pctx, ...)
122#endif
123
124#define av_abort() do { av_log(NULL, AV_LOG_ERROR, "Abort at %s:%d\n", __FILE__, __LINE__); abort(); } while (0)
125
126/* math */
127
128#if ARCH_X86
129#define MASK_ABS(mask, level)\
130 __asm__ volatile(\
131 "cltd \n\t"\
132 "xorl %1, %0 \n\t"\
133 "subl %1, %0 \n\t"\
134 : "+a" (level), "=&d" (mask)\
135 );
136#else
137#define MASK_ABS(mask, level)\
138 mask = level >> 31;\
139 level = (level ^ mask) - mask;
140#endif
141
142/* avoid usage of dangerous/inappropriate system functions */
143#undef malloc
144#define malloc please_use_av_malloc
145#undef free
146#define free please_use_av_free
147#undef realloc
148#define realloc please_use_av_realloc
149#undef time
150#define time time_is_forbidden_due_to_security_issues
151#undef rand
152#define rand rand_is_forbidden_due_to_state_trashing_use_av_lfg_get
153#undef srand
154#define srand srand_is_forbidden_due_to_state_trashing_use_av_lfg_init
155#undef random
156#define random random_is_forbidden_due_to_state_trashing_use_av_lfg_get
157#undef sprintf
158#define sprintf sprintf_is_forbidden_due_to_security_issues_use_snprintf
159#undef strcat
160#define strcat strcat_is_forbidden_due_to_security_issues_use_av_strlcat
161#undef exit
162#define exit exit_is_forbidden
163#ifndef LIBAVFORMAT_BUILD
164#undef printf
165#define printf please_use_av_log_instead_of_printf
166#undef fprintf
167#define fprintf please_use_av_log_instead_of_fprintf
168#undef puts
169#define puts please_use_av_log_instead_of_puts
170#undef perror
171#define perror please_use_av_log_instead_of_perror
172#endif
173
174#define FF_ALLOC_OR_GOTO(ctx, p, size, label)\
175{\
176 p = av_malloc(size);\
177 if (p == NULL && (size) != 0) {\
178 av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\
179 goto label;\
180 }\
181}
182
183#define FF_ALLOCZ_OR_GOTO(ctx, p, size, label)\
184{\
185 p = av_mallocz(size);\
186 if (p == NULL && (size) != 0) {\
187 av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\
188 goto label;\
189 }\
190}
191
192#include "libm.h"
193
194/**
195 * Return NULL if CONFIG_SMALL is true, otherwise the argument
196 * without modification. Used to disable the definition of strings
197 * (for example AVCodec long_names).
198 */
199#if CONFIG_SMALL
200# define NULL_IF_CONFIG_SMALL(x) NULL
201#else
202# define NULL_IF_CONFIG_SMALL(x) x
203#endif
204
205
206/**
207 * Define a function with only the non-default version specified.
208 *
209 * On systems with ELF shared libraries, all symbols exported from
210 * FFmpeg libraries are tagged with the name and major version of the
211 * library to which they belong. If a function is moved from one
212 * library to another, a wrapper must be retained in the original
213 * location to preserve binary compatibility.
214 *
215 * Functions defined with this macro will never be used to resolve
216 * symbols by the build-time linker.
217 *
218 * @param type return type of function
219 * @param name name of function
220 * @param args argument list of function
221 * @param ver version tag to assign function
222 */
223#if HAVE_SYMVER_ASM_LABEL
224# define FF_SYMVER(type, name, args, ver) \
225 type ff_##name args __asm__ (EXTERN_PREFIX #name "@" ver); \
226 type ff_##name args
227#elif HAVE_SYMVER_GNU_ASM
228# define FF_SYMVER(type, name, args, ver) \
229 __asm__ (".symver ff_" #name "," EXTERN_PREFIX #name "@" ver); \
230 type ff_##name args; \
231 type ff_##name args
232#endif
233
234#endif /* AVUTIL_INTERNAL_H */
diff --git a/apps/codecs/libwmavoice/libavutil/intreadwrite.h b/apps/codecs/libwmavoice/libavutil/intreadwrite.h
new file mode 100644
index 0000000000..1849a64661
--- /dev/null
+++ b/apps/codecs/libwmavoice/libavutil/intreadwrite.h
@@ -0,0 +1,522 @@
1/*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#ifndef AVUTIL_INTREADWRITE_H
20#define AVUTIL_INTREADWRITE_H
21
22#include <stdint.h>
23#include "libavutil/avconfig.h"
24#include "attributes.h"
25#include "bswap.h"
26
27typedef union {
28 uint64_t u64;
29 uint32_t u32[2];
30 uint16_t u16[4];
31 uint8_t u8 [8];
32 double f64;
33 float f32[2];
34} av_alias av_alias64;
35
36typedef union {
37 uint32_t u32;
38 uint16_t u16[2];
39 uint8_t u8 [4];
40 float f32;
41} av_alias av_alias32;
42
43typedef union {
44 uint16_t u16;
45 uint8_t u8 [2];
46} av_alias av_alias16;
47
48/*
49 * Arch-specific headers can provide any combination of
50 * AV_[RW][BLN](16|24|32|64) and AV_(COPY|SWAP|ZERO)(64|128) macros.
51 * Preprocessor symbols must be defined, even if these are implemented
52 * as inline functions.
53 */
54
55#ifdef HAVE_AV_CONFIG_H
56
57#include "config.h"
58
59#if ARCH_ARM
60# include "arm/intreadwrite.h"
61#elif ARCH_AVR32
62# include "avr32/intreadwrite.h"
63#elif ARCH_MIPS
64# include "mips/intreadwrite.h"
65#elif ARCH_PPC
66# include "ppc/intreadwrite.h"
67#elif ARCH_TOMI
68# include "tomi/intreadwrite.h"
69#elif ARCH_X86
70# include "x86/intreadwrite.h"
71#endif
72
73#endif /* HAVE_AV_CONFIG_H */
74
75/*
76 * Map AV_RNXX <-> AV_R[BL]XX for all variants provided by per-arch headers.
77 */
78
79#if AV_HAVE_BIGENDIAN
80
81# if defined(AV_RN16) && !defined(AV_RB16)
82# define AV_RB16(p) AV_RN16(p)
83# elif !defined(AV_RN16) && defined(AV_RB16)
84# define AV_RN16(p) AV_RB16(p)
85# endif
86
87# if defined(AV_WN16) && !defined(AV_WB16)
88# define AV_WB16(p, v) AV_WN16(p, v)
89# elif !defined(AV_WN16) && defined(AV_WB16)
90# define AV_WN16(p, v) AV_WB16(p, v)
91# endif
92
93# if defined(AV_RN24) && !defined(AV_RB24)
94# define AV_RB24(p) AV_RN24(p)
95# elif !defined(AV_RN24) && defined(AV_RB24)
96# define AV_RN24(p) AV_RB24(p)
97# endif
98
99# if defined(AV_WN24) && !defined(AV_WB24)
100# define AV_WB24(p, v) AV_WN24(p, v)
101# elif !defined(AV_WN24) && defined(AV_WB24)
102# define AV_WN24(p, v) AV_WB24(p, v)
103# endif
104
105# if defined(AV_RN32) && !defined(AV_RB32)
106# define AV_RB32(p) AV_RN32(p)
107# elif !defined(AV_RN32) && defined(AV_RB32)
108# define AV_RN32(p) AV_RB32(p)
109# endif
110
111# if defined(AV_WN32) && !defined(AV_WB32)
112# define AV_WB32(p, v) AV_WN32(p, v)
113# elif !defined(AV_WN32) && defined(AV_WB32)
114# define AV_WN32(p, v) AV_WB32(p, v)
115# endif
116
117# if defined(AV_RN64) && !defined(AV_RB64)
118# define AV_RB64(p) AV_RN64(p)
119# elif !defined(AV_RN64) && defined(AV_RB64)
120# define AV_RN64(p) AV_RB64(p)
121# endif
122
123# if defined(AV_WN64) && !defined(AV_WB64)
124# define AV_WB64(p, v) AV_WN64(p, v)
125# elif !defined(AV_WN64) && defined(AV_WB64)
126# define AV_WN64(p, v) AV_WB64(p, v)
127# endif
128
129#else /* AV_HAVE_BIGENDIAN */
130
131# if defined(AV_RN16) && !defined(AV_RL16)
132# define AV_RL16(p) AV_RN16(p)
133# elif !defined(AV_RN16) && defined(AV_RL16)
134# define AV_RN16(p) AV_RL16(p)
135# endif
136
137# if defined(AV_WN16) && !defined(AV_WL16)
138# define AV_WL16(p, v) AV_WN16(p, v)
139# elif !defined(AV_WN16) && defined(AV_WL16)
140# define AV_WN16(p, v) AV_WL16(p, v)
141# endif
142
143# if defined(AV_RN24) && !defined(AV_RL24)
144# define AV_RL24(p) AV_RN24(p)
145# elif !defined(AV_RN24) && defined(AV_RL24)
146# define AV_RN24(p) AV_RL24(p)
147# endif
148
149# if defined(AV_WN24) && !defined(AV_WL24)
150# define AV_WL24(p, v) AV_WN24(p, v)
151# elif !defined(AV_WN24) && defined(AV_WL24)
152# define AV_WN24(p, v) AV_WL24(p, v)
153# endif
154
155# if defined(AV_RN32) && !defined(AV_RL32)
156# define AV_RL32(p) AV_RN32(p)
157# elif !defined(AV_RN32) && defined(AV_RL32)
158# define AV_RN32(p) AV_RL32(p)
159# endif
160
161# if defined(AV_WN32) && !defined(AV_WL32)
162# define AV_WL32(p, v) AV_WN32(p, v)
163# elif !defined(AV_WN32) && defined(AV_WL32)
164# define AV_WN32(p, v) AV_WL32(p, v)
165# endif
166
167# if defined(AV_RN64) && !defined(AV_RL64)
168# define AV_RL64(p) AV_RN64(p)
169# elif !defined(AV_RN64) && defined(AV_RL64)
170# define AV_RN64(p) AV_RL64(p)
171# endif
172
173# if defined(AV_WN64) && !defined(AV_WL64)
174# define AV_WL64(p, v) AV_WN64(p, v)
175# elif !defined(AV_WN64) && defined(AV_WL64)
176# define AV_WN64(p, v) AV_WL64(p, v)
177# endif
178
179#endif /* !AV_HAVE_BIGENDIAN */
180
181/*
182 * Define AV_[RW]N helper macros to simplify definitions not provided
183 * by per-arch headers.
184 */
185
186#if defined(__GNUC__) && !defined(__TI_COMPILER_VERSION__)
187
188union unaligned_64 { uint64_t l; } __attribute__((packed)) av_alias;
189union unaligned_32 { uint32_t l; } __attribute__((packed)) av_alias;
190union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias;
191
192# define AV_RN(s, p) (((const union unaligned_##s *) (p))->l)
193# define AV_WN(s, p, v) ((((union unaligned_##s *) (p))->l) = (v))
194
195#elif defined(__DECC)
196
197# define AV_RN(s, p) (*((const __unaligned uint##s##_t*)(p)))
198# define AV_WN(s, p, v) (*((__unaligned uint##s##_t*)(p)) = (v))
199
200#elif AV_HAVE_FAST_UNALIGNED
201
202# define AV_RN(s, p) (((const av_alias##s*)(p))->u##s)
203# define AV_WN(s, p, v) (((av_alias##s*)(p))->u##s = (v))
204
205#else
206
207#ifndef AV_RB16
208# define AV_RB16(x) \
209 ((((const uint8_t*)(x))[0] << 8) | \
210 ((const uint8_t*)(x))[1])
211#endif
212#ifndef AV_WB16
213# define AV_WB16(p, d) do { \
214 ((uint8_t*)(p))[1] = (d); \
215 ((uint8_t*)(p))[0] = (d)>>8; \
216 } while(0)
217#endif
218
219#ifndef AV_RL16
220# define AV_RL16(x) \
221 ((((const uint8_t*)(x))[1] << 8) | \
222 ((const uint8_t*)(x))[0])
223#endif
224#ifndef AV_WL16
225# define AV_WL16(p, d) do { \
226 ((uint8_t*)(p))[0] = (d); \
227 ((uint8_t*)(p))[1] = (d)>>8; \
228 } while(0)
229#endif
230
231#ifndef AV_RB32
232# define AV_RB32(x) \
233 ((((const uint8_t*)(x))[0] << 24) | \
234 (((const uint8_t*)(x))[1] << 16) | \
235 (((const uint8_t*)(x))[2] << 8) | \
236 ((const uint8_t*)(x))[3])
237#endif
238#ifndef AV_WB32
239# define AV_WB32(p, d) do { \
240 ((uint8_t*)(p))[3] = (d); \
241 ((uint8_t*)(p))[2] = (d)>>8; \
242 ((uint8_t*)(p))[1] = (d)>>16; \
243 ((uint8_t*)(p))[0] = (d)>>24; \
244 } while(0)
245#endif
246
247#ifndef AV_RL32
248# define AV_RL32(x) \
249 ((((const uint8_t*)(x))[3] << 24) | \
250 (((const uint8_t*)(x))[2] << 16) | \
251 (((const uint8_t*)(x))[1] << 8) | \
252 ((const uint8_t*)(x))[0])
253#endif
254#ifndef AV_WL32
255# define AV_WL32(p, d) do { \
256 ((uint8_t*)(p))[0] = (d); \
257 ((uint8_t*)(p))[1] = (d)>>8; \
258 ((uint8_t*)(p))[2] = (d)>>16; \
259 ((uint8_t*)(p))[3] = (d)>>24; \
260 } while(0)
261#endif
262
263#ifndef AV_RB64
264# define AV_RB64(x) \
265 (((uint64_t)((const uint8_t*)(x))[0] << 56) | \
266 ((uint64_t)((const uint8_t*)(x))[1] << 48) | \
267 ((uint64_t)((const uint8_t*)(x))[2] << 40) | \
268 ((uint64_t)((const uint8_t*)(x))[3] << 32) | \
269 ((uint64_t)((const uint8_t*)(x))[4] << 24) | \
270 ((uint64_t)((const uint8_t*)(x))[5] << 16) | \
271 ((uint64_t)((const uint8_t*)(x))[6] << 8) | \
272 (uint64_t)((const uint8_t*)(x))[7])
273#endif
274#ifndef AV_WB64
275# define AV_WB64(p, d) do { \
276 ((uint8_t*)(p))[7] = (d); \
277 ((uint8_t*)(p))[6] = (d)>>8; \
278 ((uint8_t*)(p))[5] = (d)>>16; \
279 ((uint8_t*)(p))[4] = (d)>>24; \
280 ((uint8_t*)(p))[3] = (d)>>32; \
281 ((uint8_t*)(p))[2] = (d)>>40; \
282 ((uint8_t*)(p))[1] = (d)>>48; \
283 ((uint8_t*)(p))[0] = (d)>>56; \
284 } while(0)
285#endif
286
287#ifndef AV_RL64
288# define AV_RL64(x) \
289 (((uint64_t)((const uint8_t*)(x))[7] << 56) | \
290 ((uint64_t)((const uint8_t*)(x))[6] << 48) | \
291 ((uint64_t)((const uint8_t*)(x))[5] << 40) | \
292 ((uint64_t)((const uint8_t*)(x))[4] << 32) | \
293 ((uint64_t)((const uint8_t*)(x))[3] << 24) | \
294 ((uint64_t)((const uint8_t*)(x))[2] << 16) | \
295 ((uint64_t)((const uint8_t*)(x))[1] << 8) | \
296 (uint64_t)((const uint8_t*)(x))[0])
297#endif
298#ifndef AV_WL64
299# define AV_WL64(p, d) do { \
300 ((uint8_t*)(p))[0] = (d); \
301 ((uint8_t*)(p))[1] = (d)>>8; \
302 ((uint8_t*)(p))[2] = (d)>>16; \
303 ((uint8_t*)(p))[3] = (d)>>24; \
304 ((uint8_t*)(p))[4] = (d)>>32; \
305 ((uint8_t*)(p))[5] = (d)>>40; \
306 ((uint8_t*)(p))[6] = (d)>>48; \
307 ((uint8_t*)(p))[7] = (d)>>56; \
308 } while(0)
309#endif
310
311#if AV_HAVE_BIGENDIAN
312# define AV_RN(s, p) AV_RB##s(p)
313# define AV_WN(s, p, v) AV_WB##s(p, v)
314#else
315# define AV_RN(s, p) AV_RL##s(p)
316# define AV_WN(s, p, v) AV_WL##s(p, v)
317#endif
318
319#endif /* HAVE_FAST_UNALIGNED */
320
321#ifndef AV_RN16
322# define AV_RN16(p) AV_RN(16, p)
323#endif
324
325#ifndef AV_RN32
326# define AV_RN32(p) AV_RN(32, p)
327#endif
328
329#ifndef AV_RN64
330# define AV_RN64(p) AV_RN(64, p)
331#endif
332
333#ifndef AV_WN16
334# define AV_WN16(p, v) AV_WN(16, p, v)
335#endif
336
337#ifndef AV_WN32
338# define AV_WN32(p, v) AV_WN(32, p, v)
339#endif
340
341#ifndef AV_WN64
342# define AV_WN64(p, v) AV_WN(64, p, v)
343#endif
344
345#if AV_HAVE_BIGENDIAN
346# define AV_RB(s, p) AV_RN##s(p)
347# define AV_WB(s, p, v) AV_WN##s(p, v)
348# define AV_RL(s, p) av_bswap##s(AV_RN##s(p))
349# define AV_WL(s, p, v) AV_WN##s(p, av_bswap##s(v))
350#else
351# define AV_RB(s, p) av_bswap##s(AV_RN##s(p))
352# define AV_WB(s, p, v) AV_WN##s(p, av_bswap##s(v))
353# define AV_RL(s, p) AV_RN##s(p)
354# define AV_WL(s, p, v) AV_WN##s(p, v)
355#endif
356
357#define AV_RB8(x) (((const uint8_t*)(x))[0])
358#define AV_WB8(p, d) do { ((uint8_t*)(p))[0] = (d); } while(0)
359
360#define AV_RL8(x) AV_RB8(x)
361#define AV_WL8(p, d) AV_WB8(p, d)
362
363#ifndef AV_RB16
364# define AV_RB16(p) AV_RB(16, p)
365#endif
366#ifndef AV_WB16
367# define AV_WB16(p, v) AV_WB(16, p, v)
368#endif
369
370#ifndef AV_RL16
371# define AV_RL16(p) AV_RL(16, p)
372#endif
373#ifndef AV_WL16
374# define AV_WL16(p, v) AV_WL(16, p, v)
375#endif
376
377#ifndef AV_RB32
378# define AV_RB32(p) AV_RB(32, p)
379#endif
380#ifndef AV_WB32
381# define AV_WB32(p, v) AV_WB(32, p, v)
382#endif
383
384#ifndef AV_RL32
385# define AV_RL32(p) AV_RL(32, p)
386#endif
387#ifndef AV_WL32
388# define AV_WL32(p, v) AV_WL(32, p, v)
389#endif
390
391#ifndef AV_RB64
392# define AV_RB64(p) AV_RB(64, p)
393#endif
394#ifndef AV_WB64
395# define AV_WB64(p, v) AV_WB(64, p, v)
396#endif
397
398#ifndef AV_RL64
399# define AV_RL64(p) AV_RL(64, p)
400#endif
401#ifndef AV_WL64
402# define AV_WL64(p, v) AV_WL(64, p, v)
403#endif
404
405#ifndef AV_RB24
406# define AV_RB24(x) \
407 ((((const uint8_t*)(x))[0] << 16) | \
408 (((const uint8_t*)(x))[1] << 8) | \
409 ((const uint8_t*)(x))[2])
410#endif
411#ifndef AV_WB24
412# define AV_WB24(p, d) do { \
413 ((uint8_t*)(p))[2] = (d); \
414 ((uint8_t*)(p))[1] = (d)>>8; \
415 ((uint8_t*)(p))[0] = (d)>>16; \
416 } while(0)
417#endif
418
419#ifndef AV_RL24
420# define AV_RL24(x) \
421 ((((const uint8_t*)(x))[2] << 16) | \
422 (((const uint8_t*)(x))[1] << 8) | \
423 ((const uint8_t*)(x))[0])
424#endif
425#ifndef AV_WL24
426# define AV_WL24(p, d) do { \
427 ((uint8_t*)(p))[0] = (d); \
428 ((uint8_t*)(p))[1] = (d)>>8; \
429 ((uint8_t*)(p))[2] = (d)>>16; \
430 } while(0)
431#endif
432
433/*
434 * The AV_[RW]NA macros access naturally aligned data
435 * in a type-safe way.
436 */
437
438#define AV_RNA(s, p) (((const av_alias##s*)(p))->u##s)
439#define AV_WNA(s, p, v) (((av_alias##s*)(p))->u##s = (v))
440
441#ifndef AV_RN16A
442# define AV_RN16A(p) AV_RNA(16, p)
443#endif
444
445#ifndef AV_RN32A
446# define AV_RN32A(p) AV_RNA(32, p)
447#endif
448
449#ifndef AV_RN64A
450# define AV_RN64A(p) AV_RNA(64, p)
451#endif
452
453#ifndef AV_WN16A
454# define AV_WN16A(p, v) AV_WNA(16, p, v)
455#endif
456
457#ifndef AV_WN32A
458# define AV_WN32A(p, v) AV_WNA(32, p, v)
459#endif
460
461#ifndef AV_WN64A
462# define AV_WN64A(p, v) AV_WNA(64, p, v)
463#endif
464
465/* Parameters for AV_COPY*, AV_SWAP*, AV_ZERO* must be
466 * naturally aligned. They may be implemented using MMX,
467 * so emms_c() must be called before using any float code
468 * afterwards.
469 */
470
471#define AV_COPY(n, d, s) \
472 (((av_alias##n*)(d))->u##n = ((const av_alias##n*)(s))->u##n)
473
474#ifndef AV_COPY16
475# define AV_COPY16(d, s) AV_COPY(16, d, s)
476#endif
477
478#ifndef AV_COPY32
479# define AV_COPY32(d, s) AV_COPY(32, d, s)
480#endif
481
482#ifndef AV_COPY64
483# define AV_COPY64(d, s) AV_COPY(64, d, s)
484#endif
485
486#ifndef AV_COPY128
487# define AV_COPY128(d, s) \
488 do { \
489 AV_COPY64(d, s); \
490 AV_COPY64((char*)(d)+8, (char*)(s)+8); \
491 } while(0)
492#endif
493
494#define AV_SWAP(n, a, b) FFSWAP(av_alias##n, *(av_alias##n*)(a), *(av_alias##n*)(b))
495
496#ifndef AV_SWAP64
497# define AV_SWAP64(a, b) AV_SWAP(64, a, b)
498#endif
499
500#define AV_ZERO(n, d) (((av_alias##n*)(d))->u##n = 0)
501
502#ifndef AV_ZERO16
503# define AV_ZERO16(d) AV_ZERO(16, d)
504#endif
505
506#ifndef AV_ZERO32
507# define AV_ZERO32(d) AV_ZERO(32, d)
508#endif
509
510#ifndef AV_ZERO64
511# define AV_ZERO64(d) AV_ZERO(64, d)
512#endif
513
514#ifndef AV_ZERO128
515# define AV_ZERO128(d) \
516 do { \
517 AV_ZERO64(d); \
518 AV_ZERO64((char*)(d)+8); \
519 } while(0)
520#endif
521
522#endif /* AVUTIL_INTREADWRITE_H */
diff --git a/apps/codecs/libwmavoice/libavutil/log.c b/apps/codecs/libwmavoice/libavutil/log.c
new file mode 100644
index 0000000000..2e225b3b50
--- /dev/null
+++ b/apps/codecs/libwmavoice/libavutil/log.c
@@ -0,0 +1,150 @@
1/*
2 * log functions
3 * Copyright (c) 2003 Michel Bardiaux
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/**
23 * @file
24 * logging functions
25 */
26
27#include <unistd.h>
28#include <stdlib.h>
29#include "avutil.h"
30#include "log.h"
31
32#if LIBAVUTIL_VERSION_MAJOR > 50
33static
34#endif
35int av_log_level = AV_LOG_INFO;
36
37#if defined(_WIN32) && !defined(__MINGW32CE__)
38#include <windows.h>
39static const uint8_t color[] = {12,12,12,14,7,7,7};
40static int16_t background, attr_orig;
41static HANDLE con;
42#define set_color(x) SetConsoleTextAttribute(con, background | color[x])
43#define reset_color() SetConsoleTextAttribute(con, attr_orig)
44#else
45static const uint8_t color[]={0x41,0x41,0x11,0x03,9,9,9};
46#define set_color(x) fprintf(stderr, "\033[%d;3%dm", color[x]>>4, color[x]&15)
47#define reset_color() fprintf(stderr, "\033[0m")
48#endif
49static int use_color=-1;
50
51#undef fprintf
52static void colored_fputs(int level, const char *str){
53 if(use_color<0){
54#if defined(_WIN32) && !defined(__MINGW32CE__)
55 CONSOLE_SCREEN_BUFFER_INFO con_info;
56 con = GetStdHandle(STD_ERROR_HANDLE);
57 use_color = (con != INVALID_HANDLE_VALUE) && !getenv("NO_COLOR");
58 if (use_color) {
59 GetConsoleScreenBufferInfo(con, &con_info);
60 attr_orig = con_info.wAttributes;
61 background = attr_orig & 0xF0;
62 }
63#elif HAVE_ISATTY
64 use_color= getenv("TERM") && !getenv("NO_COLOR") && isatty(2);
65#else
66 use_color= 0;
67#endif
68 }
69
70 if(use_color){
71 set_color(level);
72 }
73 fputs(str, stderr);
74 if(use_color){
75 reset_color();
76 }
77}
78
79const char* av_default_item_name(void* ptr){
80 return (*(AVClass**)ptr)->class_name;
81}
82
83void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
84{
85 static int print_prefix=1;
86 static int count;
87 static char line[1024], prev[1024];
88 AVClass* avc= ptr ? *(AVClass**)ptr : NULL;
89 if(level>av_log_level)
90 return;
91 line[0]=0;
92#undef fprintf
93 if(print_prefix && avc) {
94 if(avc->version >= (50<<16 | 15<<8 | 3) && avc->parent_log_context_offset){
95 AVClass** parent= *(AVClass***)(((uint8_t*)ptr) + avc->parent_log_context_offset);
96 if(parent && *parent){
97 snprintf(line, sizeof(line), "[%s @ %p] ", (*parent)->item_name(parent), parent);
98 }
99 }
100 snprintf(line + strlen(line), sizeof(line) - strlen(line), "[%s @ %p] ", avc->item_name(ptr), ptr);
101 }
102
103 vsnprintf(line + strlen(line), sizeof(line) - strlen(line), fmt, vl);
104
105 print_prefix= line[strlen(line)-1] == '\n';
106 if(print_prefix && !strcmp(line, prev)){
107 count++;
108 fprintf(stderr, " Last message repeated %d times\r", count);
109 return;
110 }
111 if(count>0){
112 fprintf(stderr, " Last message repeated %d times\n", count);
113 count=0;
114 }
115 colored_fputs(av_clip(level>>3, 0, 6), line);
116 strcpy(prev, line);
117}
118
119static void (*av_log_callback)(void*, int, const char*, va_list) = av_log_default_callback;
120
121void av_log(void* avcl, int level, const char *fmt, ...)
122{
123 AVClass* avc= avcl ? *(AVClass**)avcl : NULL;
124 va_list vl;
125 va_start(vl, fmt);
126 if(avc && avc->version >= (50<<16 | 15<<8 | 2) && avc->log_level_offset_offset && level>=AV_LOG_FATAL)
127 level += *(int*)(((uint8_t*)avcl) + avc->log_level_offset_offset);
128 av_vlog(avcl, level, fmt, vl);
129 va_end(vl);
130}
131
132void av_vlog(void* avcl, int level, const char *fmt, va_list vl)
133{
134 av_log_callback(avcl, level, fmt, vl);
135}
136
137int av_log_get_level(void)
138{
139 return av_log_level;
140}
141
142void av_log_set_level(int level)
143{
144 av_log_level = level;
145}
146
147void av_log_set_callback(void (*callback)(void*, int, const char*, va_list))
148{
149 av_log_callback = callback;
150}
diff --git a/apps/codecs/libwmavoice/libavutil/log.h b/apps/codecs/libwmavoice/libavutil/log.h
new file mode 100644
index 0000000000..831c26eae6
--- /dev/null
+++ b/apps/codecs/libwmavoice/libavutil/log.h
@@ -0,0 +1,138 @@
1/*
2 * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#ifndef AVUTIL_LOG_H
22#define AVUTIL_LOG_H
23
24#include <stdarg.h>
25#include "avutil.h"
26
27/**
28 * Describe the class of an AVClass context structure. That is an
29 * arbitrary struct of which the first field is a pointer to an
30 * AVClass struct (e.g. AVCodecContext, AVFormatContext etc.).
31 */
32typedef struct {
33 /**
34 * The name of the class; usually it is the same name as the
35 * context structure type to which the AVClass is associated.
36 */
37 const char* class_name;
38
39 /**
40 * A pointer to a function which returns the name of a context
41 * instance ctx associated with the class.
42 */
43 const char* (*item_name)(void* ctx);
44
45 /**
46 * a pointer to the first option specified in the class if any or NULL
47 *
48 * @see av_set_default_options()
49 */
50 const struct AVOption *option;
51
52 /**
53 * LIBAVUTIL_VERSION with which this structure was created.
54 * This is used to allow fields to be added without requiring major
55 * version bumps everywhere.
56 */
57
58 int version;
59
60 /**
61 * Offset in the structure where log_level_offset is stored.
62 * 0 means there is no such variable
63 */
64 int log_level_offset_offset;
65
66 /**
67 * Offset in the structure where a pointer to the parent context for loging is stored.
68 * for example a decoder that uses eval.c could pass its AVCodecContext to eval as such
69 * parent context. And a av_log() implementation could then display the parent context
70 * can be NULL of course
71 */
72 int parent_log_context_offset;
73} AVClass;
74
75/* av_log API */
76
77#define AV_LOG_QUIET -8
78
79/**
80 * Something went really wrong and we will crash now.
81 */
82#define AV_LOG_PANIC 0
83
84/**
85 * Something went wrong and recovery is not possible.
86 * For example, no header was found for a format which depends
87 * on headers or an illegal combination of parameters is used.
88 */
89#define AV_LOG_FATAL 8
90
91/**
92 * Something went wrong and cannot losslessly be recovered.
93 * However, not all future data is affected.
94 */
95#define AV_LOG_ERROR 16
96
97/**
98 * Something somehow does not look correct. This may or may not
99 * lead to problems. An example would be the use of '-vstrict -2'.
100 */
101#define AV_LOG_WARNING 24
102
103#define AV_LOG_INFO 32
104#define AV_LOG_VERBOSE 40
105
106/**
107 * Stuff which is only useful for libav* developers.
108 */
109#define AV_LOG_DEBUG 48
110
111/**
112 * Send the specified message to the log if the level is less than or equal
113 * to the current av_log_level. By default, all logging messages are sent to
114 * stderr. This behavior can be altered by setting a different av_vlog callback
115 * function.
116 *
117 * @param avcl A pointer to an arbitrary struct of which the first field is a
118 * pointer to an AVClass struct.
119 * @param level The importance level of the message, lower values signifying
120 * higher importance.
121 * @param fmt The format string (printf-compatible) that specifies how
122 * subsequent arguments are converted to output.
123 * @see av_vlog
124 */
125#ifdef __GNUC__
126void av_log(void *avcl, int level, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 3, 4)));
127#else
128void av_log(void *avcl, int level, const char *fmt, ...);
129#endif
130
131void av_vlog(void *avcl, int level, const char *fmt, va_list);
132int av_log_get_level(void);
133void av_log_set_level(int);
134void av_log_set_callback(void (*)(void*, int, const char*, va_list));
135void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl);
136const char* av_default_item_name(void* ctx);
137
138#endif /* AVUTIL_LOG_H */
diff --git a/apps/codecs/libwmavoice/libavutil/lzo.c b/apps/codecs/libwmavoice/libavutil/lzo.c
new file mode 100644
index 0000000000..a876fc7776
--- /dev/null
+++ b/apps/codecs/libwmavoice/libavutil/lzo.c
@@ -0,0 +1,279 @@
1/*
2 * LZO 1x decompression
3 * Copyright (c) 2006 Reimar Doeffinger
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#include "avutil.h"
23#include "common.h"
24//! Avoid e.g. MPlayers fast_memcpy, it slows things down here.
25#undef memcpy
26#include <string.h>
27#include "lzo.h"
28
29//! Define if we may write up to 12 bytes beyond the output buffer.
30#define OUTBUF_PADDED 1
31//! Define if we may read up to 8 bytes beyond the input buffer.
32#define INBUF_PADDED 1
33typedef struct LZOContext {
34 const uint8_t *in, *in_end;
35 uint8_t *out_start, *out, *out_end;
36 int error;
37} LZOContext;
38
39/**
40 * \brief Reads one byte from the input buffer, avoiding an overrun.
41 * \return byte read
42 */
43static inline int get_byte(LZOContext *c) {
44 if (c->in < c->in_end)
45 return *c->in++;
46 c->error |= AV_LZO_INPUT_DEPLETED;
47 return 1;
48}
49
50#ifdef INBUF_PADDED
51#define GETB(c) (*(c).in++)
52#else
53#define GETB(c) get_byte(&(c))
54#endif
55
56/**
57 * \brief Decodes a length value in the coding used by lzo.
58 * \param x previous byte value
59 * \param mask bits used from x
60 * \return decoded length value
61 */
62static inline int get_len(LZOContext *c, int x, int mask) {
63 int cnt = x & mask;
64 if (!cnt) {
65 while (!(x = get_byte(c))) cnt += 255;
66 cnt += mask + x;
67 }
68 return cnt;
69}
70
71//#define UNALIGNED_LOADSTORE
72#define BUILTIN_MEMCPY
73#ifdef UNALIGNED_LOADSTORE
74#define COPY2(d, s) *(uint16_t *)(d) = *(uint16_t *)(s);
75#define COPY4(d, s) *(uint32_t *)(d) = *(uint32_t *)(s);
76#elif defined(BUILTIN_MEMCPY)
77#define COPY2(d, s) memcpy(d, s, 2);
78#define COPY4(d, s) memcpy(d, s, 4);
79#else
80#define COPY2(d, s) (d)[0] = (s)[0]; (d)[1] = (s)[1];
81#define COPY4(d, s) (d)[0] = (s)[0]; (d)[1] = (s)[1]; (d)[2] = (s)[2]; (d)[3] = (s)[3];
82#endif
83
84/**
85 * \brief Copies bytes from input to output buffer with checking.
86 * \param cnt number of bytes to copy, must be >= 0
87 */
88static inline void copy(LZOContext *c, int cnt) {
89 register const uint8_t *src = c->in;
90 register uint8_t *dst = c->out;
91 if (cnt > c->in_end - src) {
92 cnt = FFMAX(c->in_end - src, 0);
93 c->error |= AV_LZO_INPUT_DEPLETED;
94 }
95 if (cnt > c->out_end - dst) {
96 cnt = FFMAX(c->out_end - dst, 0);
97 c->error |= AV_LZO_OUTPUT_FULL;
98 }
99#if defined(INBUF_PADDED) && defined(OUTBUF_PADDED)
100 COPY4(dst, src);
101 src += 4;
102 dst += 4;
103 cnt -= 4;
104 if (cnt > 0)
105#endif
106 memcpy(dst, src, cnt);
107 c->in = src + cnt;
108 c->out = dst + cnt;
109}
110
111static inline void memcpy_backptr(uint8_t *dst, int back, int cnt);
112
113/**
114 * \brief Copies previously decoded bytes to current position.
115 * \param back how many bytes back we start
116 * \param cnt number of bytes to copy, must be >= 0
117 *
118 * cnt > back is valid, this will copy the bytes we just copied,
119 * thus creating a repeating pattern with a period length of back.
120 */
121static inline void copy_backptr(LZOContext *c, int back, int cnt) {
122 register const uint8_t *src = &c->out[-back];
123 register uint8_t *dst = c->out;
124 if (src < c->out_start || src > dst) {
125 c->error |= AV_LZO_INVALID_BACKPTR;
126 return;
127 }
128 if (cnt > c->out_end - dst) {
129 cnt = FFMAX(c->out_end - dst, 0);
130 c->error |= AV_LZO_OUTPUT_FULL;
131 }
132 memcpy_backptr(dst, back, cnt);
133 c->out = dst + cnt;
134}
135
136static inline void memcpy_backptr(uint8_t *dst, int back, int cnt) {
137 const uint8_t *src = &dst[-back];
138 if (back == 1) {
139 memset(dst, *src, cnt);
140 } else {
141#ifdef OUTBUF_PADDED
142 COPY2(dst, src);
143 COPY2(dst + 2, src + 2);
144 src += 4;
145 dst += 4;
146 cnt -= 4;
147 if (cnt > 0) {
148 COPY2(dst, src);
149 COPY2(dst + 2, src + 2);
150 COPY2(dst + 4, src + 4);
151 COPY2(dst + 6, src + 6);
152 src += 8;
153 dst += 8;
154 cnt -= 8;
155 }
156#endif
157 if (cnt > 0) {
158 int blocklen = back;
159 while (cnt > blocklen) {
160 memcpy(dst, src, blocklen);
161 dst += blocklen;
162 cnt -= blocklen;
163 blocklen <<= 1;
164 }
165 memcpy(dst, src, cnt);
166 }
167 }
168}
169
170void av_memcpy_backptr(uint8_t *dst, int back, int cnt) {
171 memcpy_backptr(dst, back, cnt);
172}
173
174int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen) {
175 int state= 0;
176 int x;
177 LZOContext c;
178 c.in = in;
179 c.in_end = (const uint8_t *)in + *inlen;
180 c.out = c.out_start = out;
181 c.out_end = (uint8_t *)out + * outlen;
182 c.error = 0;
183 x = GETB(c);
184 if (x > 17) {
185 copy(&c, x - 17);
186 x = GETB(c);
187 if (x < 16) c.error |= AV_LZO_ERROR;
188 }
189 if (c.in > c.in_end)
190 c.error |= AV_LZO_INPUT_DEPLETED;
191 while (!c.error) {
192 int cnt, back;
193 if (x > 15) {
194 if (x > 63) {
195 cnt = (x >> 5) - 1;
196 back = (GETB(c) << 3) + ((x >> 2) & 7) + 1;
197 } else if (x > 31) {
198 cnt = get_len(&c, x, 31);
199 x = GETB(c);
200 back = (GETB(c) << 6) + (x >> 2) + 1;
201 } else {
202 cnt = get_len(&c, x, 7);
203 back = (1 << 14) + ((x & 8) << 11);
204 x = GETB(c);
205 back += (GETB(c) << 6) + (x >> 2);
206 if (back == (1 << 14)) {
207 if (cnt != 1)
208 c.error |= AV_LZO_ERROR;
209 break;
210 }
211 }
212 } else if(!state){
213 cnt = get_len(&c, x, 15);
214 copy(&c, cnt + 3);
215 x = GETB(c);
216 if (x > 15)
217 continue;
218 cnt = 1;
219 back = (1 << 11) + (GETB(c) << 2) + (x >> 2) + 1;
220 } else {
221 cnt = 0;
222 back = (GETB(c) << 2) + (x >> 2) + 1;
223 }
224 copy_backptr(&c, back, cnt + 2);
225 state=
226 cnt = x & 3;
227 copy(&c, cnt);
228 x = GETB(c);
229 }
230 *inlen = c.in_end - c.in;
231 if (c.in > c.in_end)
232 *inlen = 0;
233 *outlen = c.out_end - c.out;
234 return c.error;
235}
236
237#ifdef TEST
238#include <stdio.h>
239#include <lzo/lzo1x.h>
240#include "log.h"
241#define MAXSZ (10*1024*1024)
242
243/* Define one of these to 1 if you wish to benchmark liblzo
244 * instead of our native implementation. */
245#define BENCHMARK_LIBLZO_SAFE 0
246#define BENCHMARK_LIBLZO_UNSAFE 0
247
248int main(int argc, char *argv[]) {
249 FILE *in = fopen(argv[1], "rb");
250 uint8_t *orig = av_malloc(MAXSZ + 16);
251 uint8_t *comp = av_malloc(2*MAXSZ + 16);
252 uint8_t *decomp = av_malloc(MAXSZ + 16);
253 size_t s = fread(orig, 1, MAXSZ, in);
254 lzo_uint clen = 0;
255 long tmp[LZO1X_MEM_COMPRESS];
256 int inlen, outlen;
257 int i;
258 av_log_set_level(AV_LOG_DEBUG);
259 lzo1x_999_compress(orig, s, comp, &clen, tmp);
260 for (i = 0; i < 300; i++) {
261START_TIMER
262 inlen = clen; outlen = MAXSZ;
263#if BENCHMARK_LIBLZO_SAFE
264 if (lzo1x_decompress_safe(comp, inlen, decomp, &outlen, NULL))
265#elif BENCHMARK_LIBLZO_UNSAFE
266 if (lzo1x_decompress(comp, inlen, decomp, &outlen, NULL))
267#else
268 if (av_lzo1x_decode(decomp, &outlen, comp, &inlen))
269#endif
270 av_log(NULL, AV_LOG_ERROR, "decompression error\n");
271STOP_TIMER("lzod")
272 }
273 if (memcmp(orig, decomp, s))
274 av_log(NULL, AV_LOG_ERROR, "decompression incorrect\n");
275 else
276 av_log(NULL, AV_LOG_ERROR, "decompression OK\n");
277 return 0;
278}
279#endif
diff --git a/apps/codecs/libwmavoice/libavutil/lzo.h b/apps/codecs/libwmavoice/libavutil/lzo.h
new file mode 100644
index 0000000000..6788054bff
--- /dev/null
+++ b/apps/codecs/libwmavoice/libavutil/lzo.h
@@ -0,0 +1,66 @@
1/*
2 * LZO 1x decompression
3 * copyright (c) 2006 Reimar Doeffinger
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 AVUTIL_LZO_H
23#define AVUTIL_LZO_H
24
25#include <stdint.h>
26
27/** \defgroup errflags Error flags returned by av_lzo1x_decode
28 * \{ */
29//! end of the input buffer reached before decoding finished
30#define AV_LZO_INPUT_DEPLETED 1
31//! decoded data did not fit into output buffer
32#define AV_LZO_OUTPUT_FULL 2
33//! a reference to previously decoded data was wrong
34#define AV_LZO_INVALID_BACKPTR 4
35//! a non-specific error in the compressed bitstream
36#define AV_LZO_ERROR 8
37/** \} */
38
39#define AV_LZO_INPUT_PADDING 8
40#define AV_LZO_OUTPUT_PADDING 12
41
42/**
43 * \brief Decodes LZO 1x compressed data.
44 * \param out output buffer
45 * \param outlen size of output buffer, number of bytes left are returned here
46 * \param in input buffer
47 * \param inlen size of input buffer, number of bytes left are returned here
48 * \return 0 on success, otherwise a combination of the error flags above
49 *
50 * Make sure all buffers are appropriately padded, in must provide
51 * AV_LZO_INPUT_PADDING, out must provide AV_LZO_OUTPUT_PADDING additional bytes.
52 */
53int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen);
54
55/**
56 * \brief deliberately overlapping memcpy implementation
57 * \param dst destination buffer; must be padded with 12 additional bytes
58 * \param back how many bytes back we start (the initial size of the overlapping window)
59 * \param cnt number of bytes to copy, must be >= 0
60 *
61 * cnt > back is valid, this will copy the bytes we just copied,
62 * thus creating a repeating pattern with a period length of back.
63 */
64void av_memcpy_backptr(uint8_t *dst, int back, int cnt);
65
66#endif /* AVUTIL_LZO_H */
diff --git a/apps/codecs/libwmavoice/libavutil/mathematics.c b/apps/codecs/libwmavoice/libavutil/mathematics.c
new file mode 100644
index 0000000000..c6851cb755
--- /dev/null
+++ b/apps/codecs/libwmavoice/libavutil/mathematics.c
@@ -0,0 +1,181 @@
1/*
2 * Copyright (c) 2005 Michael Niedermayer <michaelni@gmx.at>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21/**
22 * @file
23 * miscellaneous math routines and tables
24 */
25
26#include <assert.h>
27#include <stdint.h>
28#include <limits.h>
29#include "mathematics.h"
30
31const uint8_t ff_sqrt_tab[256]={
32 0, 16, 23, 28, 32, 36, 40, 43, 46, 48, 51, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 77, 79, 80, 82, 84, 85, 87, 88, 90,
33 91, 92, 94, 95, 96, 98, 99,100,102,103,104,105,107,108,109,110,111,112,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
34128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,144,145,146,147,148,149,150,151,151,152,153,154,155,156,156,
35157,158,159,160,160,161,162,163,164,164,165,166,167,168,168,169,170,171,171,172,173,174,174,175,176,176,177,178,179,179,180,181,
36182,182,183,184,184,185,186,186,187,188,188,189,190,190,191,192,192,193,194,194,195,196,196,197,198,198,199,200,200,201,202,202,
37203,204,204,205,205,206,207,207,208,208,209,210,210,211,212,212,213,213,214,215,215,216,216,217,218,218,219,219,220,220,221,222,
38222,223,223,224,224,225,226,226,227,227,228,228,229,230,230,231,231,232,232,233,233,234,235,235,236,236,237,237,238,238,239,239,
39240,240,241,242,242,243,243,244,244,245,245,246,246,247,247,248,248,249,249,250,250,251,251,252,252,253,253,254,254,255,255,255
40};
41
42const uint8_t ff_log2_tab[256]={
43 0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
44 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
45 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
46 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
47 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
48 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
49 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
50 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
51};
52
53const uint8_t av_reverse[256]={
540x00,0x80,0x40,0xC0,0x20,0xA0,0x60,0xE0,0x10,0x90,0x50,0xD0,0x30,0xB0,0x70,0xF0,
550x08,0x88,0x48,0xC8,0x28,0xA8,0x68,0xE8,0x18,0x98,0x58,0xD8,0x38,0xB8,0x78,0xF8,
560x04,0x84,0x44,0xC4,0x24,0xA4,0x64,0xE4,0x14,0x94,0x54,0xD4,0x34,0xB4,0x74,0xF4,
570x0C,0x8C,0x4C,0xCC,0x2C,0xAC,0x6C,0xEC,0x1C,0x9C,0x5C,0xDC,0x3C,0xBC,0x7C,0xFC,
580x02,0x82,0x42,0xC2,0x22,0xA2,0x62,0xE2,0x12,0x92,0x52,0xD2,0x32,0xB2,0x72,0xF2,
590x0A,0x8A,0x4A,0xCA,0x2A,0xAA,0x6A,0xEA,0x1A,0x9A,0x5A,0xDA,0x3A,0xBA,0x7A,0xFA,
600x06,0x86,0x46,0xC6,0x26,0xA6,0x66,0xE6,0x16,0x96,0x56,0xD6,0x36,0xB6,0x76,0xF6,
610x0E,0x8E,0x4E,0xCE,0x2E,0xAE,0x6E,0xEE,0x1E,0x9E,0x5E,0xDE,0x3E,0xBE,0x7E,0xFE,
620x01,0x81,0x41,0xC1,0x21,0xA1,0x61,0xE1,0x11,0x91,0x51,0xD1,0x31,0xB1,0x71,0xF1,
630x09,0x89,0x49,0xC9,0x29,0xA9,0x69,0xE9,0x19,0x99,0x59,0xD9,0x39,0xB9,0x79,0xF9,
640x05,0x85,0x45,0xC5,0x25,0xA5,0x65,0xE5,0x15,0x95,0x55,0xD5,0x35,0xB5,0x75,0xF5,
650x0D,0x8D,0x4D,0xCD,0x2D,0xAD,0x6D,0xED,0x1D,0x9D,0x5D,0xDD,0x3D,0xBD,0x7D,0xFD,
660x03,0x83,0x43,0xC3,0x23,0xA3,0x63,0xE3,0x13,0x93,0x53,0xD3,0x33,0xB3,0x73,0xF3,
670x0B,0x8B,0x4B,0xCB,0x2B,0xAB,0x6B,0xEB,0x1B,0x9B,0x5B,0xDB,0x3B,0xBB,0x7B,0xFB,
680x07,0x87,0x47,0xC7,0x27,0xA7,0x67,0xE7,0x17,0x97,0x57,0xD7,0x37,0xB7,0x77,0xF7,
690x0F,0x8F,0x4F,0xCF,0x2F,0xAF,0x6F,0xEF,0x1F,0x9F,0x5F,0xDF,0x3F,0xBF,0x7F,0xFF,
70};
71
72int64_t av_gcd(int64_t a, int64_t b){
73 if(b) return av_gcd(b, a%b);
74 else return a;
75}
76
77int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd){
78 int64_t r=0;
79 assert(c > 0);
80 assert(b >=0);
81 assert((unsigned)rnd<=5 && rnd!=4);
82
83 if(a<0 && a != INT64_MIN) return -av_rescale_rnd(-a, b, c, rnd ^ ((rnd>>1)&1));
84
85 if(rnd==AV_ROUND_NEAR_INF) r= c/2;
86 else if(rnd&1) r= c-1;
87
88 if(b<=INT_MAX && c<=INT_MAX){
89 if(a<=INT_MAX)
90 return (a * b + r)/c;
91 else
92 return a/c*b + (a%c*b + r)/c;
93 }else{
94#if 1
95 uint64_t a0= a&0xFFFFFFFF;
96 uint64_t a1= a>>32;
97 uint64_t b0= b&0xFFFFFFFF;
98 uint64_t b1= b>>32;
99 uint64_t t1= a0*b1 + a1*b0;
100 uint64_t t1a= t1<<32;
101 int i;
102
103 a0 = a0*b0 + t1a;
104 a1 = a1*b1 + (t1>>32) + (a0<t1a);
105 a0 += r;
106 a1 += a0<r;
107
108 for(i=63; i>=0; i--){
109// int o= a1 & 0x8000000000000000ULL;
110 a1+= a1 + ((a0>>i)&1);
111 t1+=t1;
112 if(/*o || */c <= a1){
113 a1 -= c;
114 t1++;
115 }
116 }
117 return t1;
118 }
119#else
120 AVInteger ai;
121 ai= av_mul_i(av_int2i(a), av_int2i(b));
122 ai= av_add_i(ai, av_int2i(r));
123
124 return av_i2int(av_div_i(ai, av_int2i(c)));
125 }
126#endif
127}
128
129int64_t av_rescale(int64_t a, int64_t b, int64_t c){
130 return av_rescale_rnd(a, b, c, AV_ROUND_NEAR_INF);
131}
132
133int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq){
134 int64_t b= bq.num * (int64_t)cq.den;
135 int64_t c= cq.num * (int64_t)bq.den;
136 return av_rescale_rnd(a, b, c, AV_ROUND_NEAR_INF);
137}
138
139int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b){
140 int64_t a= tb_a.num * (int64_t)tb_b.den;
141 int64_t b= tb_b.num * (int64_t)tb_a.den;
142 if (av_rescale_rnd(ts_a, a, b, AV_ROUND_DOWN) < ts_b) return -1;
143 if (av_rescale_rnd(ts_b, b, a, AV_ROUND_DOWN) < ts_a) return 1;
144 return 0;
145}
146
147int64_t av_compare_mod(uint64_t a, uint64_t b, uint64_t mod){
148 int64_t c= (a-b) & (mod-1);
149 if(c > (mod>>1))
150 c-= mod;
151 return c;
152}
153
154#ifdef TEST
155#include "integer.h"
156#undef printf
157int main(void){
158 int64_t a,b,c,d,e;
159
160 for(a=7; a<(1LL<<62); a+=a/3+1){
161 for(b=3; b<(1LL<<62); b+=b/4+1){
162 for(c=9; c<(1LL<<62); c+=(c*2)/5+3){
163 int64_t r= c/2;
164 AVInteger ai;
165 ai= av_mul_i(av_int2i(a), av_int2i(b));
166 ai= av_add_i(ai, av_int2i(r));
167
168 d= av_i2int(av_div_i(ai, av_int2i(c)));
169
170 e= av_rescale(a,b,c);
171
172 if((double)a * (double)b / (double)c > (1LL<<63))
173 continue;
174
175 if(d!=e) printf("%"PRId64"*%"PRId64"/%"PRId64"= %"PRId64"=%"PRId64"\n", a, b, c, d, e);
176 }
177 }
178 }
179 return 0;
180}
181#endif
diff --git a/apps/codecs/libwmavoice/libavutil/mathematics.h b/apps/codecs/libwmavoice/libavutil/mathematics.h
new file mode 100644
index 0000000000..e07d4fe807
--- /dev/null
+++ b/apps/codecs/libwmavoice/libavutil/mathematics.h
@@ -0,0 +1,112 @@
1/*
2 * copyright (c) 2005 Michael Niedermayer <michaelni@gmx.at>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#ifndef AVUTIL_MATHEMATICS_H
22#define AVUTIL_MATHEMATICS_H
23
24#include <stdint.h>
25#include <math.h>
26#include "attributes.h"
27//#include "rational.h"
28
29#ifndef M_E
30#define M_E 2.7182818284590452354 /* e */
31#endif
32#ifndef M_LN2
33#define M_LN2 0.69314718055994530942 /* log_e 2 */
34#endif
35#ifndef M_LN10
36#define M_LN10 2.30258509299404568402 /* log_e 10 */
37#endif
38#ifndef M_LOG2_10
39#define M_LOG2_10 3.32192809488736234787 /* log_2 10 */
40#endif
41#ifndef M_PHI
42#define M_PHI 1.61803398874989484820 /* phi / golden ratio */
43#endif
44#ifndef M_PI
45#define M_PI 3.14159265358979323846 /* pi */
46#endif
47#ifndef M_SQRT1_2
48#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
49#endif
50#ifndef M_SQRT2
51#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
52#endif
53#ifndef NAN
54#define NAN (0.0/0.0)
55#endif
56#ifndef INFINITY
57#define INFINITY (1.0/0.0)
58#endif
59
60enum AVRounding {
61 AV_ROUND_ZERO = 0, ///< Round toward zero.
62 AV_ROUND_INF = 1, ///< Round away from zero.
63 AV_ROUND_DOWN = 2, ///< Round toward -infinity.
64 AV_ROUND_UP = 3, ///< Round toward +infinity.
65 AV_ROUND_NEAR_INF = 5, ///< Round to nearest and halfway cases away from zero.
66};
67
68/**
69 * Return the greatest common divisor of a and b.
70 * If both a and b are 0 or either or both are <0 then behavior is
71 * undefined.
72 */
73int64_t av_const av_gcd(int64_t a, int64_t b);
74
75/**
76 * Rescale a 64-bit integer with rounding to nearest.
77 * A simple a*b/c isn't possible as it can overflow.
78 */
79int64_t av_rescale(int64_t a, int64_t b, int64_t c) av_const;
80
81/**
82 * Rescale a 64-bit integer with specified rounding.
83 * A simple a*b/c isn't possible as it can overflow.
84 */
85int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding) av_const;
86
87/**
88 * Rescale a 64-bit integer by 2 rational numbers.
89 */
90//int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) av_const;
91
92/**
93 * Compare 2 timestamps each in its own timebases.
94 * The result of the function is undefined if one of the timestamps
95 * is outside the int64_t range when represented in the others timebase.
96 * @return -1 if ts_a is before ts_b, 1 if ts_a is after ts_b or 0 if they represent the same position
97 */
98//int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b);
99
100/**
101 * Compare 2 integers modulo mod.
102 * That is we compare integers a and b for which only the least
103 * significant log2(mod) bits are known.
104 *
105 * @param mod must be a power of 2
106 * @return a negative value if a is smaller than b
107 * a positive value if a is greater than b
108 * 0 if a equals b
109 */
110int64_t av_compare_mod(uint64_t a, uint64_t b, uint64_t mod);
111
112#endif /* AVUTIL_MATHEMATICS_H */
diff --git a/apps/codecs/libwmavoice/libavutil/mem.c b/apps/codecs/libwmavoice/libavutil/mem.c
new file mode 100644
index 0000000000..8cad089a7d
--- /dev/null
+++ b/apps/codecs/libwmavoice/libavutil/mem.c
@@ -0,0 +1,176 @@
1/*
2 * default memory allocator for libavutil
3 * Copyright (c) 2002 Fabrice Bellard
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/**
23 * @file
24 * default memory allocator for libavutil
25 */
26
27#include "config.h"
28
29#include <limits.h>
30#include <stdlib.h>
31#include <string.h>
32#if HAVE_MALLOC_H
33#include <malloc.h>
34#endif
35
36#include "avutil.h"
37#include "mem.h"
38
39/* here we can use OS-dependent allocation functions */
40#undef free
41#undef malloc
42#undef realloc
43
44#ifdef MALLOC_PREFIX
45
46#define malloc AV_JOIN(MALLOC_PREFIX, malloc)
47#define memalign AV_JOIN(MALLOC_PREFIX, memalign)
48#define posix_memalign AV_JOIN(MALLOC_PREFIX, posix_memalign)
49#define realloc AV_JOIN(MALLOC_PREFIX, realloc)
50#define free AV_JOIN(MALLOC_PREFIX, free)
51
52void *malloc(size_t size);
53void *memalign(size_t align, size_t size);
54int posix_memalign(void **ptr, size_t align, size_t size);
55void *realloc(void *ptr, size_t size);
56void free(void *ptr);
57
58#endif /* MALLOC_PREFIX */
59
60/* You can redefine av_malloc and av_free in your project to use your
61 memory allocator. You do not need to suppress this file because the
62 linker will do it automatically. */
63
64void *av_malloc(unsigned int size)
65{
66 void *ptr = NULL;
67#if CONFIG_MEMALIGN_HACK
68 long diff;
69#endif
70
71 /* let's disallow possible ambiguous cases */
72 if(size > (INT_MAX-16) )
73 return NULL;
74
75#if CONFIG_MEMALIGN_HACK
76 ptr = malloc(size+16);
77 if(!ptr)
78 return ptr;
79 diff= ((-(long)ptr - 1)&15) + 1;
80 ptr = (char*)ptr + diff;
81 ((char*)ptr)[-1]= diff;
82#elif HAVE_POSIX_MEMALIGN
83 if (posix_memalign(&ptr,16,size))
84 ptr = NULL;
85#elif HAVE_MEMALIGN
86 ptr = memalign(16,size);
87 /* Why 64?
88 Indeed, we should align it:
89 on 4 for 386
90 on 16 for 486
91 on 32 for 586, PPro - K6-III
92 on 64 for K7 (maybe for P3 too).
93 Because L1 and L2 caches are aligned on those values.
94 But I don't want to code such logic here!
95 */
96 /* Why 16?
97 Because some CPUs need alignment, for example SSE2 on P4, & most RISC CPUs
98 it will just trigger an exception and the unaligned load will be done in the
99 exception handler or it will just segfault (SSE2 on P4).
100 Why not larger? Because I did not see a difference in benchmarks ...
101 */
102 /* benchmarks with P3
103 memalign(64)+1 3071,3051,3032
104 memalign(64)+2 3051,3032,3041
105 memalign(64)+4 2911,2896,2915
106 memalign(64)+8 2545,2554,2550
107 memalign(64)+16 2543,2572,2563
108 memalign(64)+32 2546,2545,2571
109 memalign(64)+64 2570,2533,2558
110
111 BTW, malloc seems to do 8-byte alignment by default here.
112 */
113#else
114 ptr = malloc(size);
115#endif
116 return ptr;
117}
118
119void *av_realloc(void *ptr, unsigned int size)
120{
121#if CONFIG_MEMALIGN_HACK
122 int diff;
123#endif
124
125 /* let's disallow possible ambiguous cases */
126 if(size > (INT_MAX-16) )
127 return NULL;
128
129#if CONFIG_MEMALIGN_HACK
130 //FIXME this isn't aligned correctly, though it probably isn't needed
131 if(!ptr) return av_malloc(size);
132 diff= ((char*)ptr)[-1];
133 return (char*)realloc((char*)ptr - diff, size + diff) + diff;
134#else
135 return realloc(ptr, size);
136#endif
137}
138
139void av_free(void *ptr)
140{
141 /* XXX: this test should not be needed on most libcs */
142 if (ptr)
143#if CONFIG_MEMALIGN_HACK
144 free((char*)ptr - ((char*)ptr)[-1]);
145#else
146 free(ptr);
147#endif
148}
149
150void av_freep(void *arg)
151{
152 void **ptr= (void**)arg;
153 av_free(*ptr);
154 *ptr = NULL;
155}
156
157void *av_mallocz(unsigned int size)
158{
159 void *ptr = av_malloc(size);
160 if (ptr)
161 memset(ptr, 0, size);
162 return ptr;
163}
164
165char *av_strdup(const char *s)
166{
167 char *ptr= NULL;
168 if(s){
169 int len = strlen(s) + 1;
170 ptr = av_malloc(len);
171 if (ptr)
172 memcpy(ptr, s, len);
173 }
174 return ptr;
175}
176
diff --git a/apps/codecs/libwmavoice/libavutil/mem.h b/apps/codecs/libwmavoice/libavutil/mem.h
new file mode 100644
index 0000000000..c5ec2ab3c3
--- /dev/null
+++ b/apps/codecs/libwmavoice/libavutil/mem.h
@@ -0,0 +1,126 @@
1/*
2 * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21/**
22 * @file
23 * memory handling functions
24 */
25
26#ifndef AVUTIL_MEM_H
27#define AVUTIL_MEM_H
28
29#include "attributes.h"
30#include "avutil.h"
31
32#if defined(__ICC) && _ICC < 1200 || defined(__SUNPRO_C)
33 #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v
34 #define DECLARE_ASM_CONST(n,t,v) const t __attribute__ ((aligned (n))) v
35#elif defined(__TI_COMPILER_VERSION__)
36 #define DECLARE_ALIGNED(n,t,v) \
37 AV_PRAGMA(DATA_ALIGN(v,n)) \
38 t __attribute__((aligned(n))) v
39 #define DECLARE_ASM_CONST(n,t,v) \
40 AV_PRAGMA(DATA_ALIGN(v,n)) \
41 static const t __attribute__((aligned(n))) v
42#elif defined(__GNUC__)
43 #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v
44 #define DECLARE_ASM_CONST(n,t,v) static const t attribute_used __attribute__ ((aligned (n))) v
45#elif defined(_MSC_VER)
46 #define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v
47 #define DECLARE_ASM_CONST(n,t,v) __declspec(align(n)) static const t v
48#else
49 #define DECLARE_ALIGNED(n,t,v) t v
50 #define DECLARE_ASM_CONST(n,t,v) static const t v
51#endif
52
53#if AV_GCC_VERSION_AT_LEAST(3,1)
54 #define av_malloc_attrib __attribute__((__malloc__))
55#else
56 #define av_malloc_attrib
57#endif
58
59#if (!defined(__ICC) || __ICC > 1110) && AV_GCC_VERSION_AT_LEAST(4,3)
60 #define av_alloc_size(n) __attribute__((alloc_size(n)))
61#else
62 #define av_alloc_size(n)
63#endif
64
65/**
66 * Allocate a block of size bytes with alignment suitable for all
67 * memory accesses (including vectors if available on the CPU).
68 * @param size Size in bytes for the memory block to be allocated.
69 * @return Pointer to the allocated block, NULL if the block cannot
70 * be allocated.
71 * @see av_mallocz()
72 */
73void *av_malloc(unsigned int size) av_malloc_attrib av_alloc_size(1);
74
75/**
76 * Allocate or reallocate a block of memory.
77 * If ptr is NULL and size > 0, allocate a new block. If
78 * size is zero, free the memory block pointed to by ptr.
79 * @param size Size in bytes for the memory block to be allocated or
80 * reallocated.
81 * @param ptr Pointer to a memory block already allocated with
82 * av_malloc(z)() or av_realloc() or NULL.
83 * @return Pointer to a newly reallocated block or NULL if the block
84 * cannot be reallocated or the function is used to free the memory block.
85 * @see av_fast_realloc()
86 */
87void *av_realloc(void *ptr, unsigned int size) av_alloc_size(2);
88
89/**
90 * Free a memory block which has been allocated with av_malloc(z)() or
91 * av_realloc().
92 * @param ptr Pointer to the memory block which should be freed.
93 * @note ptr = NULL is explicitly allowed.
94 * @note It is recommended that you use av_freep() instead.
95 * @see av_freep()
96 */
97void av_free(void *ptr);
98
99/**
100 * Allocate a block of size bytes with alignment suitable for all
101 * memory accesses (including vectors if available on the CPU) and
102 * zero all the bytes of the block.
103 * @param size Size in bytes for the memory block to be allocated.
104 * @return Pointer to the allocated block, NULL if it cannot be allocated.
105 * @see av_malloc()
106 */
107void *av_mallocz(unsigned int size) av_malloc_attrib av_alloc_size(1);
108
109/**
110 * Duplicate the string s.
111 * @param s string to be duplicated
112 * @return Pointer to a newly allocated string containing a
113 * copy of s or NULL if the string cannot be allocated.
114 */
115char *av_strdup(const char *s) av_malloc_attrib;
116
117/**
118 * Free a memory block which has been allocated with av_malloc(z)() or
119 * av_realloc() and set the pointer pointing to it to NULL.
120 * @param ptr Pointer to the pointer to the memory block which should
121 * be freed.
122 * @see av_free()
123 */
124void av_freep(void *ptr);
125
126#endif /* AVUTIL_MEM_H */
diff --git a/apps/codecs/libwmavoice/lsp.c b/apps/codecs/libwmavoice/lsp.c
new file mode 100644
index 0000000000..7112492001
--- /dev/null
+++ b/apps/codecs/libwmavoice/lsp.c
@@ -0,0 +1,174 @@
1/*
2 * LSP routines for ACELP-based codecs
3 *
4 * Copyright (c) 2007 Reynaldo H. Verdejo Pinochet (QCELP decoder)
5 * Copyright (c) 2008 Vladimir Voroshilov
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 <inttypes.h>
25
26#include "avcodec.h"
27#define FRAC_BITS 14
28#include "mathops.h"
29#include "lsp.h"
30#include "celp_math.h"
31
32void ff_acelp_reorder_lsf(int16_t* lsfq, int lsfq_min_distance, int lsfq_min, int lsfq_max, int lp_order)
33{
34 int i, j;
35
36 /* sort lsfq in ascending order. float bubble agorithm,
37 O(n) if data already sorted, O(n^2) - otherwise */
38 for(i=0; i<lp_order-1; i++)
39 for(j=i; j>=0 && lsfq[j] > lsfq[j+1]; j--)
40 FFSWAP(int16_t, lsfq[j], lsfq[j+1]);
41
42 for(i=0; i<lp_order; i++)
43 {
44 lsfq[i] = FFMAX(lsfq[i], lsfq_min);
45 lsfq_min = lsfq[i] + lsfq_min_distance;
46 }
47 lsfq[lp_order-1] = FFMIN(lsfq[lp_order-1], lsfq_max);//Is warning required ?
48}
49
50void ff_set_min_dist_lsf(float *lsf, double min_spacing, int size)
51{
52 int i;
53 float prev = 0.0;
54 for (i = 0; i < size; i++)
55 prev = lsf[i] = FFMAX(lsf[i], prev + min_spacing);
56}
57
58void ff_acelp_lsf2lsp(int16_t *lsp, const int16_t *lsf, int lp_order)
59{
60 int i;
61
62 /* Convert LSF to LSP, lsp=cos(lsf) */
63 for(i=0; i<lp_order; i++)
64 // 20861 = 2.0 / PI in (0.15)
65 lsp[i] = ff_cos(lsf[i] * 20861 >> 15); // divide by PI and (0,13) -> (0,14)
66}
67
68/**
69 * \brief decodes polynomial coefficients from LSP
70 * \param f [out] decoded polynomial coefficients (-0x20000000 <= (3.22) <= 0x1fffffff)
71 * \param lsp LSP coefficients (-0x8000 <= (0.15) <= 0x7fff)
72 */
73static void lsp2poly(int* f, const int16_t* lsp, int lp_half_order)
74{
75 int i, j;
76
77 f[0] = 0x400000; // 1.0 in (3.22)
78 f[1] = -lsp[0] << 8; // *2 and (0.15) -> (3.22)
79
80 for(i=2; i<=lp_half_order; i++)
81 {
82 f[i] = f[i-2];
83 for(j=i; j>1; j--)
84 f[j] -= MULL(f[j-1], lsp[2*i-2], FRAC_BITS) - f[j-2];
85
86 f[1] -= lsp[2*i-2] << 8;
87 }
88}
89
90void ff_acelp_lsp2lpc(int16_t* lp, const int16_t* lsp, int lp_half_order)
91{
92 int i;
93 int f1[MAX_LP_HALF_ORDER+1]; // (3.22)
94 int f2[MAX_LP_HALF_ORDER+1]; // (3.22)
95
96 lsp2poly(f1, lsp , lp_half_order);
97 lsp2poly(f2, lsp+1, lp_half_order);
98
99 /* 3.2.6 of G.729, Equations 25 and 26*/
100 lp[0] = 4096;
101 for(i=1; i<lp_half_order+1; i++)
102 {
103 int ff1 = f1[i] + f1[i-1]; // (3.22)
104 int ff2 = f2[i] - f2[i-1]; // (3.22)
105
106 ff1 += 1 << 10; // for rounding
107 lp[i] = (ff1 + ff2) >> 11; // divide by 2 and (3.22) -> (3.12)
108 lp[(lp_half_order << 1) + 1 - i] = (ff1 - ff2) >> 11; // divide by 2 and (3.22) -> (3.12)
109 }
110}
111
112void ff_acelp_lp_decode(int16_t* lp_1st, int16_t* lp_2nd, const int16_t* lsp_2nd, const int16_t* lsp_prev, int lp_order)
113{
114 int16_t lsp_1st[MAX_LP_ORDER]; // (0.15)
115 int i;
116
117 /* LSP values for first subframe (3.2.5 of G.729, Equation 24)*/
118 for(i=0; i<lp_order; i++)
119#ifdef G729_BITEXACT
120 lsp_1st[i] = (lsp_2nd[i] >> 1) + (lsp_prev[i] >> 1);
121#else
122 lsp_1st[i] = (lsp_2nd[i] + lsp_prev[i]) >> 1;
123#endif
124
125 ff_acelp_lsp2lpc(lp_1st, lsp_1st, lp_order >> 1);
126
127 /* LSP values for second subframe (3.2.5 of G.729)*/
128 ff_acelp_lsp2lpc(lp_2nd, lsp_2nd, lp_order >> 1);
129}
130
131void ff_lsp2polyf(const double *lsp, double *f, int lp_half_order)
132{
133 int i, j;
134
135 f[0] = 1.0;
136 f[1] = -2 * lsp[0];
137 lsp -= 2;
138 for(i=2; i<=lp_half_order; i++)
139 {
140 double val = -2 * lsp[2*i];
141 f[i] = val * f[i-1] + 2*f[i-2];
142 for(j=i-1; j>1; j--)
143 f[j] += f[j-1] * val + f[j-2];
144 f[1] += val;
145 }
146}
147
148void ff_acelp_lspd2lpc(const double *lsp, float *lpc, int lp_half_order)
149{
150 double pa[MAX_LP_HALF_ORDER+1], qa[MAX_LP_HALF_ORDER+1];
151 float *lpc2 = lpc + (lp_half_order << 1) - 1;
152
153 assert(lp_half_order <= MAX_LP_HALF_ORDER);
154
155 ff_lsp2polyf(lsp, pa, lp_half_order);
156 ff_lsp2polyf(lsp + 1, qa, lp_half_order);
157
158 while (lp_half_order--) {
159 double paf = pa[lp_half_order+1] + pa[lp_half_order];
160 double qaf = qa[lp_half_order+1] - qa[lp_half_order];
161
162 lpc [ lp_half_order] = 0.5*(paf+qaf);
163 lpc2[-lp_half_order] = 0.5*(paf-qaf);
164 }
165}
166
167void ff_sort_nearly_sorted_floats(float *vals, int len)
168{
169 int i,j;
170
171 for (i = 0; i < len - 1; i++)
172 for (j = i; j >= 0 && vals[j] > vals[j+1]; j--)
173 FFSWAP(float, vals[j], vals[j+1]);
174}
diff --git a/apps/codecs/libwmavoice/lsp.h b/apps/codecs/libwmavoice/lsp.h
new file mode 100644
index 0000000000..5ee5c277bc
--- /dev/null
+++ b/apps/codecs/libwmavoice/lsp.h
@@ -0,0 +1,120 @@
1/*
2 * LSP computing for ACELP-based codecs
3 *
4 * Copyright (c) 2008 Vladimir Voroshilov
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23#ifndef AVCODEC_LSP_H
24#define AVCODEC_LSP_H
25
26#include <stdint.h>
27
28/**
29 (I.F) means fixed-point value with F fractional and I integer bits
30*/
31
32/**
33 * \brief ensure a minimum distance between LSFs
34 * \param[in,out] lsfq LSF to check and adjust
35 * \param lsfq_min_distance minimum distance between LSFs
36 * \param lsfq_min minimum allowed LSF value
37 * \param lsfq_max maximum allowed LSF value
38 * \param lp_order LP filter order
39 */
40void ff_acelp_reorder_lsf(int16_t* lsfq, int lsfq_min_distance, int lsfq_min, int lsfq_max, int lp_order);
41
42/**
43 * Adjust the quantized LSFs so they are increasing and not too close.
44 *
45 * This step is not mentioned in the AMR spec but is in the reference C decoder.
46 * Omitting this step creates audible distortion on the sinusoidal sweep
47 * test vectors in 3GPP TS 26.074.
48 *
49 * @param[in,out] lsf LSFs in Hertz
50 * @param min_spacing minimum distance between two consecutive lsf values
51 * @param size size of the lsf vector
52 */
53void ff_set_min_dist_lsf(float *lsf, double min_spacing, int size);
54
55/**
56 * \brief Convert LSF to LSP
57 * \param[out] lsp LSP coefficients (-0x8000 <= (0.15) < 0x8000)
58 * \param lsf normalized LSF coefficients (0 <= (2.13) < 0x2000 * PI)
59 * \param lp_order LP filter order
60 *
61 * \remark It is safe to pass the same array into the lsf and lsp parameters.
62 */
63void ff_acelp_lsf2lsp(int16_t *lsp, const int16_t *lsf, int lp_order);
64
65/**
66 * \brief LSP to LP conversion (3.2.6 of G.729)
67 * \param[out] lp decoded LP coefficients (-0x8000 <= (3.12) < 0x8000)
68 * \param lsp LSP coefficients (-0x8000 <= (0.15) < 0x8000)
69 * \param lp_half_order LP filter order, divided by 2
70 */
71void ff_acelp_lsp2lpc(int16_t* lp, const int16_t* lsp, int lp_half_order);
72
73/**
74 * \brief Interpolate LSP for the first subframe and convert LSP -> LP for both subframes (3.2.5 and 3.2.6 of G.729)
75 * \param[out] lp_1st decoded LP coefficients for first subframe (-0x8000 <= (3.12) < 0x8000)
76 * \param[out] lp_2nd decoded LP coefficients for second subframe (-0x8000 <= (3.12) < 0x8000)
77 * \param lsp_2nd LSP coefficients of the second subframe (-0x8000 <= (0.15) < 0x8000)
78 * \param lsp_prev LSP coefficients from the second subframe of the previous frame (-0x8000 <= (0.15) < 0x8000)
79 * \param lp_order LP filter order
80 */
81void ff_acelp_lp_decode(int16_t* lp_1st, int16_t* lp_2nd, const int16_t* lsp_2nd, const int16_t* lsp_prev, int lp_order);
82
83
84#define MAX_LP_HALF_ORDER 8
85#define MAX_LP_ORDER (2*MAX_LP_HALF_ORDER)
86
87/**
88 * Reconstruct LPC coefficients from the line spectral pair frequencies.
89 *
90 * @param lsp line spectral pairs in cosine domain
91 * @param lpc linear predictive coding coefficients
92 * @param lp_half_order half the number of the amount of LPCs to be
93 * reconstructed, need to be smaller or equal to MAX_LP_HALF_ORDER
94 *
95 * @note buffers should have a minimux size of 2*lp_half_order elements.
96 *
97 * TIA/EIA/IS-733 2.4.3.3.5
98 */
99void ff_acelp_lspd2lpc(const double *lsp, float *lpc, int lp_half_order);
100
101/**
102 * Sort values in ascending order.
103 *
104 * @note O(n) if data already sorted, O(n^2) - otherwise
105 */
106void ff_sort_nearly_sorted_floats(float *vals, int len);
107
108/**
109 * Compute the Pa / (1 + z(-1)) or Qa / (1 - z(-1)) coefficients
110 * needed for LSP to LPC conversion.
111 * We only need to calculate the 6 first elements of the polynomial.
112 *
113 * @param lsp line spectral pairs in cosine domain
114 * @param[out] f polynomial input/output as a vector
115 *
116 * TIA/EIA/IS-733 2.4.3.3.5-1/2
117 */
118void ff_lsp2polyf(const double *lsp, double *f, int lp_half_order);
119
120#endif /* AVCODEC_LSP_H */
diff --git a/apps/codecs/libwmavoice/mdct.c b/apps/codecs/libwmavoice/mdct.c
new file mode 100644
index 0000000000..c511188d22
--- /dev/null
+++ b/apps/codecs/libwmavoice/mdct.c
@@ -0,0 +1,234 @@
1/*
2 * MDCT/IMDCT transforms
3 * Copyright (c) 2002 Fabrice Bellard
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#include <stdlib.h>
23#include <string.h>
24#include "libavutil/common.h"
25#include "libavutil/mathematics.h"
26#include "fft.h"
27
28/**
29 * @file
30 * MDCT/IMDCT transforms.
31 */
32
33// Generate a Kaiser-Bessel Derived Window.
34#define BESSEL_I0_ITER 50 // default: 50 iterations of Bessel I0 approximation
35av_cold void ff_kbd_window_init(float *window, float alpha, int n)
36{
37 int i, j;
38 double sum = 0.0, bessel, tmp;
39 double local_window[FF_KBD_WINDOW_MAX];
40 double alpha2 = (alpha * M_PI / n) * (alpha * M_PI / n);
41
42 assert(n <= FF_KBD_WINDOW_MAX);
43
44 for (i = 0; i < n; i++) {
45 tmp = i * (n - i) * alpha2;
46 bessel = 1.0;
47 for (j = BESSEL_I0_ITER; j > 0; j--)
48 bessel = bessel * tmp / (j * j) + 1;
49 sum += bessel;
50 local_window[i] = sum;
51 }
52
53 sum++;
54 for (i = 0; i < n; i++)
55 window[i] = sqrt(local_window[i] / sum);
56}
57
58#include "mdct_tablegen.h"
59
60/**
61 * init MDCT or IMDCT computation.
62 */
63av_cold int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale)
64{
65 int n, n4, i;
66 double alpha, theta;
67 int tstep;
68
69 memset(s, 0, sizeof(*s));
70 n = 1 << nbits;
71 s->mdct_bits = nbits;
72 s->mdct_size = n;
73 n4 = n >> 2;
74 s->permutation = FF_MDCT_PERM_NONE;
75
76 if (ff_fft_init(s, s->mdct_bits - 2, inverse) < 0)
77 goto fail;
78
79 s->tcos = av_malloc(n/2 * sizeof(FFTSample));
80 if (!s->tcos)
81 goto fail;
82
83 switch (s->permutation) {
84 case FF_MDCT_PERM_NONE:
85 s->tsin = s->tcos + n4;
86 tstep = 1;
87 break;
88 case FF_MDCT_PERM_INTERLEAVE:
89 s->tsin = s->tcos + 1;
90 tstep = 2;
91 break;
92 default:
93 goto fail;
94 }
95
96 theta = 1.0 / 8.0 + (scale < 0 ? n4 : 0);
97 scale = sqrt(fabs(scale));
98 for(i=0;i<n4;i++) {
99 alpha = 2 * M_PI * (i + theta) / n;
100 s->tcos[i*tstep] = -cos(alpha) * scale;
101 s->tsin[i*tstep] = -sin(alpha) * scale;
102 }
103 return 0;
104 fail:
105 ff_mdct_end(s);
106 return -1;
107}
108
109/* complex multiplication: p = a * b */
110#define CMUL(pre, pim, are, aim, bre, bim) \
111{\
112 FFTSample _are = (are);\
113 FFTSample _aim = (aim);\
114 FFTSample _bre = (bre);\
115 FFTSample _bim = (bim);\
116 (pre) = _are * _bre - _aim * _bim;\
117 (pim) = _are * _bim + _aim * _bre;\
118}
119
120/**
121 * Compute the middle half of the inverse MDCT of size N = 2^nbits,
122 * thus excluding the parts that can be derived by symmetry
123 * @param output N/2 samples
124 * @param input N/2 samples
125 */
126void ff_imdct_half_c(FFTContext *s, FFTSample *output, const FFTSample *input)
127{
128 int k, n8, n4, n2, n, j;
129 const uint16_t *revtab = s->revtab;
130 const FFTSample *tcos = s->tcos;
131 const FFTSample *tsin = s->tsin;
132 const FFTSample *in1, *in2;
133 FFTComplex *z = (FFTComplex *)output;
134
135 n = 1 << s->mdct_bits;
136 n2 = n >> 1;
137 n4 = n >> 2;
138 n8 = n >> 3;
139
140 /* pre rotation */
141 in1 = input;
142 in2 = input + n2 - 1;
143 for(k = 0; k < n4; k++) {
144 j=revtab[k];
145 CMUL(z[j].re, z[j].im, *in2, *in1, tcos[k], tsin[k]);
146 in1 += 2;
147 in2 -= 2;
148 }
149 ff_fft_calc(s, z);
150
151 /* post rotation + reordering */
152 for(k = 0; k < n8; k++) {
153 FFTSample r0, i0, r1, i1;
154 CMUL(r0, i1, z[n8-k-1].im, z[n8-k-1].re, tsin[n8-k-1], tcos[n8-k-1]);
155 CMUL(r1, i0, z[n8+k ].im, z[n8+k ].re, tsin[n8+k ], tcos[n8+k ]);
156 z[n8-k-1].re = r0;
157 z[n8-k-1].im = i0;
158 z[n8+k ].re = r1;
159 z[n8+k ].im = i1;
160 }
161}
162
163/**
164 * Compute inverse MDCT of size N = 2^nbits
165 * @param output N samples
166 * @param input N/2 samples
167 */
168void ff_imdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input)
169{
170 int k;
171 int n = 1 << s->mdct_bits;
172 int n2 = n >> 1;
173 int n4 = n >> 2;
174
175 ff_imdct_half_c(s, output+n4, input);
176
177 for(k = 0; k < n4; k++) {
178 output[k] = -output[n2-k-1];
179 output[n-k-1] = output[n2+k];
180 }
181}
182
183/**
184 * Compute MDCT of size N = 2^nbits
185 * @param input N samples
186 * @param out N/2 samples
187 */
188void ff_mdct_calc_c(FFTContext *s, FFTSample *out, const FFTSample *input)
189{
190 int i, j, n, n8, n4, n2, n3;
191 FFTSample re, im;
192 const uint16_t *revtab = s->revtab;
193 const FFTSample *tcos = s->tcos;
194 const FFTSample *tsin = s->tsin;
195 FFTComplex *x = (FFTComplex *)out;
196
197 n = 1 << s->mdct_bits;
198 n2 = n >> 1;
199 n4 = n >> 2;
200 n8 = n >> 3;
201 n3 = 3 * n4;
202
203 /* pre rotation */
204 for(i=0;i<n8;i++) {
205 re = -input[2*i+3*n4] - input[n3-1-2*i];
206 im = -input[n4+2*i] + input[n4-1-2*i];
207 j = revtab[i];
208 CMUL(x[j].re, x[j].im, re, im, -tcos[i], tsin[i]);
209
210 re = input[2*i] - input[n2-1-2*i];
211 im = -(input[n2+2*i] + input[n-1-2*i]);
212 j = revtab[n8 + i];
213 CMUL(x[j].re, x[j].im, re, im, -tcos[n8 + i], tsin[n8 + i]);
214 }
215
216 ff_fft_calc(s, x);
217
218 /* post rotation */
219 for(i=0;i<n8;i++) {
220 FFTSample r0, i0, r1, i1;
221 CMUL(i1, r0, x[n8-i-1].re, x[n8-i-1].im, -tsin[n8-i-1], -tcos[n8-i-1]);
222 CMUL(i0, r1, x[n8+i ].re, x[n8+i ].im, -tsin[n8+i ], -tcos[n8+i ]);
223 x[n8-i-1].re = r0;
224 x[n8-i-1].im = i0;
225 x[n8+i ].re = r1;
226 x[n8+i ].im = i1;
227 }
228}
229
230av_cold void ff_mdct_end(FFTContext *s)
231{
232 av_freep(&s->tcos);
233 ff_fft_end(s);
234}
diff --git a/apps/codecs/libwmavoice/put_bits.h b/apps/codecs/libwmavoice/put_bits.h
new file mode 100644
index 0000000000..d301d0afcc
--- /dev/null
+++ b/apps/codecs/libwmavoice/put_bits.h
@@ -0,0 +1,343 @@
1/*
2 * copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21/**
22 * @file
23 * bitstream writer API
24 */
25
26#ifndef AVCODEC_PUT_BITS_H
27#define AVCODEC_PUT_BITS_H
28
29#include <stdint.h>
30#include <stdlib.h>
31#include <assert.h>
32#include "libavutil/bswap.h"
33#include "libavutil/common.h"
34#include "libavutil/intreadwrite.h"
35#include "libavutil/log.h"
36#include "mathops.h"
37
38//#define ALT_BITSTREAM_WRITER
39//#define ALIGNED_BITSTREAM_WRITER
40
41/* buf and buf_end must be present and used by every alternative writer. */
42typedef struct PutBitContext {
43#ifdef ALT_BITSTREAM_WRITER
44 uint8_t *buf, *buf_end;
45 int index;
46#else
47 uint32_t bit_buf;
48 int bit_left;
49 uint8_t *buf, *buf_ptr, *buf_end;
50#endif
51 int size_in_bits;
52} PutBitContext;
53
54/**
55 * Initialize the PutBitContext s.
56 *
57 * @param buffer the buffer where to put bits
58 * @param buffer_size the size in bytes of buffer
59 */
60static inline void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
61{
62 if(buffer_size < 0) {
63 buffer_size = 0;
64 buffer = NULL;
65 }
66
67 s->size_in_bits= 8*buffer_size;
68 s->buf = buffer;
69 s->buf_end = s->buf + buffer_size;
70#ifdef ALT_BITSTREAM_WRITER
71 s->index=0;
72 ((uint32_t*)(s->buf))[0]=0;
73// memset(buffer, 0, buffer_size);
74#else
75 s->buf_ptr = s->buf;
76 s->bit_left=32;
77 s->bit_buf=0;
78#endif
79}
80
81/**
82 * @return the total number of bits written to the bitstream.
83 */
84static inline int put_bits_count(PutBitContext *s)
85{
86#ifdef ALT_BITSTREAM_WRITER
87 return s->index;
88#else
89 return (s->buf_ptr - s->buf) * 8 + 32 - s->bit_left;
90#endif
91}
92
93/**
94 * Pad the end of the output stream with zeros.
95 */
96static inline void flush_put_bits(PutBitContext *s)
97{
98#ifdef ALT_BITSTREAM_WRITER
99 align_put_bits(s);
100#else
101#ifndef BITSTREAM_WRITER_LE
102 s->bit_buf<<= s->bit_left;
103#endif
104 while (s->bit_left < 32) {
105 /* XXX: should test end of buffer */
106#ifdef BITSTREAM_WRITER_LE
107 *s->buf_ptr++=s->bit_buf;
108 s->bit_buf>>=8;
109#else
110 *s->buf_ptr++=s->bit_buf >> 24;
111 s->bit_buf<<=8;
112#endif
113 s->bit_left+=8;
114 }
115 s->bit_left=32;
116 s->bit_buf=0;
117#endif
118}
119
120#if defined(ALT_BITSTREAM_WRITER) || defined(BITSTREAM_WRITER_LE)
121#define align_put_bits align_put_bits_unsupported_here
122#define ff_put_string ff_put_string_unsupported_here
123#define ff_copy_bits ff_copy_bits_unsupported_here
124#else
125/**
126 * Pad the bitstream with zeros up to the next byte boundary.
127 */
128void align_put_bits(PutBitContext *s);
129
130/**
131 * Put the string string in the bitstream.
132 *
133 * @param terminate_string 0-terminates the written string if value is 1
134 */
135void ff_put_string(PutBitContext *pb, const char *string, int terminate_string);
136
137/**
138 * Copy the content of src to the bitstream.
139 *
140 * @param length the number of bits of src to copy
141 */
142void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length);
143#endif
144
145/**
146 * Write up to 31 bits into a bitstream.
147 * Use put_bits32 to write 32 bits.
148 */
149static inline void put_bits(PutBitContext *s, int n, unsigned int value)
150#ifndef ALT_BITSTREAM_WRITER
151{
152 unsigned int bit_buf;
153 int bit_left;
154
155 // printf("put_bits=%d %x\n", n, value);
156 assert(n <= 31 && value < (1U << n));
157
158 bit_buf = s->bit_buf;
159 bit_left = s->bit_left;
160
161 // printf("n=%d value=%x cnt=%d buf=%x\n", n, value, bit_cnt, bit_buf);
162 /* XXX: optimize */
163#ifdef BITSTREAM_WRITER_LE
164 bit_buf |= value << (32 - bit_left);
165 if (n >= bit_left) {
166#if !HAVE_FAST_UNALIGNED
167 if (3 & (intptr_t) s->buf_ptr) {
168 AV_WL32(s->buf_ptr, bit_buf);
169 } else
170#endif
171 *(uint32_t *)s->buf_ptr = av_le2ne32(bit_buf);
172 s->buf_ptr+=4;
173 bit_buf = (bit_left==32)?0:value >> bit_left;
174 bit_left+=32;
175 }
176 bit_left-=n;
177#else
178 if (n < bit_left) {
179 bit_buf = (bit_buf<<n) | value;
180 bit_left-=n;
181 } else {
182 bit_buf<<=bit_left;
183 bit_buf |= value >> (n - bit_left);
184#if !HAVE_FAST_UNALIGNED
185 if (3 & (intptr_t) s->buf_ptr) {
186 AV_WB32(s->buf_ptr, bit_buf);
187 } else
188#endif
189 *(uint32_t *)s->buf_ptr = av_be2ne32(bit_buf);
190 //printf("bitbuf = %08x\n", bit_buf);
191 s->buf_ptr+=4;
192 bit_left+=32 - n;
193 bit_buf = value;
194 }
195#endif
196
197 s->bit_buf = bit_buf;
198 s->bit_left = bit_left;
199}
200#else /* ALT_BITSTREAM_WRITER defined */
201{
202# ifdef ALIGNED_BITSTREAM_WRITER
203# if ARCH_X86
204 __asm__ volatile(
205 "movl %0, %%ecx \n\t"
206 "xorl %%eax, %%eax \n\t"
207 "shrdl %%cl, %1, %%eax \n\t"
208 "shrl %%cl, %1 \n\t"
209 "movl %0, %%ecx \n\t"
210 "shrl $3, %%ecx \n\t"
211 "andl $0xFFFFFFFC, %%ecx \n\t"
212 "bswapl %1 \n\t"
213 "orl %1, (%2, %%ecx) \n\t"
214 "bswapl %%eax \n\t"
215 "addl %3, %0 \n\t"
216 "movl %%eax, 4(%2, %%ecx) \n\t"
217 : "=&r" (s->index), "=&r" (value)
218 : "r" (s->buf), "r" (n), "0" (s->index), "1" (value<<(-n))
219 : "%eax", "%ecx"
220 );
221# else
222 int index= s->index;
223 uint32_t *ptr= ((uint32_t *)s->buf)+(index>>5);
224
225 value<<= 32-n;
226
227 ptr[0] |= av_be2ne32(value>>(index&31));
228 ptr[1] = av_be2ne32(value<<(32-(index&31)));
229//if(n>24) printf("%d %d\n", n, value);
230 index+= n;
231 s->index= index;
232# endif
233# else //ALIGNED_BITSTREAM_WRITER
234# if ARCH_X86
235 __asm__ volatile(
236 "movl $7, %%ecx \n\t"
237 "andl %0, %%ecx \n\t"
238 "addl %3, %%ecx \n\t"
239 "negl %%ecx \n\t"
240 "shll %%cl, %1 \n\t"
241 "bswapl %1 \n\t"
242 "movl %0, %%ecx \n\t"
243 "shrl $3, %%ecx \n\t"
244 "orl %1, (%%ecx, %2) \n\t"
245 "addl %3, %0 \n\t"
246 "movl $0, 4(%%ecx, %2) \n\t"
247 : "=&r" (s->index), "=&r" (value)
248 : "r" (s->buf), "r" (n), "0" (s->index), "1" (value)
249 : "%ecx"
250 );
251# else
252 int index= s->index;
253 uint32_t *ptr= (uint32_t*)(((uint8_t *)s->buf)+(index>>3));
254
255 ptr[0] |= av_be2ne32(value<<(32-n-(index&7) ));
256 ptr[1] = 0;
257//if(n>24) printf("%d %d\n", n, value);
258 index+= n;
259 s->index= index;
260# endif
261# endif //!ALIGNED_BITSTREAM_WRITER
262}
263#endif
264
265static inline void put_sbits(PutBitContext *pb, int n, int32_t value)
266{
267 assert(n >= 0 && n <= 31);
268
269 put_bits(pb, n, value & ((1<<n)-1));
270}
271
272/**
273 * Write exactly 32 bits into a bitstream.
274 */
275static void av_unused put_bits32(PutBitContext *s, uint32_t value)
276{
277 int lo = value & 0xffff;
278 int hi = value >> 16;
279#ifdef BITSTREAM_WRITER_LE
280 put_bits(s, 16, lo);
281 put_bits(s, 16, hi);
282#else
283 put_bits(s, 16, hi);
284 put_bits(s, 16, lo);
285#endif
286}
287
288/**
289 * Return the pointer to the byte where the bitstream writer will put
290 * the next bit.
291 */
292static inline uint8_t* put_bits_ptr(PutBitContext *s)
293{
294#ifdef ALT_BITSTREAM_WRITER
295 return s->buf + (s->index>>3);
296#else
297 return s->buf_ptr;
298#endif
299}
300
301/**
302 * Skip the given number of bytes.
303 * PutBitContext must be flushed & aligned to a byte boundary before calling this.
304 */
305static inline void skip_put_bytes(PutBitContext *s, int n)
306{
307 assert((put_bits_count(s)&7)==0);
308#ifdef ALT_BITSTREAM_WRITER
309 FIXME may need some cleaning of the buffer
310 s->index += n<<3;
311#else
312 assert(s->bit_left==32);
313 s->buf_ptr += n;
314#endif
315}
316
317/**
318 * Skip the given number of bits.
319 * Must only be used if the actual values in the bitstream do not matter.
320 * If n is 0 the behavior is undefined.
321 */
322static inline void skip_put_bits(PutBitContext *s, int n)
323{
324#ifdef ALT_BITSTREAM_WRITER
325 s->index += n;
326#else
327 s->bit_left -= n;
328 s->buf_ptr-= 4*(s->bit_left>>5);
329 s->bit_left &= 31;
330#endif
331}
332
333/**
334 * Change the end of the buffer.
335 *
336 * @param size the new size in bytes of the buffer where to put bits
337 */
338static inline void set_put_bits_buffer_size(PutBitContext *s, int size)
339{
340 s->buf_end= s->buf + size;
341}
342
343#endif /* AVCODEC_PUT_BITS_H */
diff --git a/apps/codecs/libwmavoice/wmavoice.c b/apps/codecs/libwmavoice/wmavoice.c
new file mode 100644
index 0000000000..c4582f35cc
--- /dev/null
+++ b/apps/codecs/libwmavoice/wmavoice.c
@@ -0,0 +1,2031 @@
1/*
2 * Windows Media Audio Voice decoder.
3 * Copyright (c) 2009 Ronald S. Bultje
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/**
23 * @file
24 * @brief Windows Media Audio Voice compatible decoder
25 * @author Ronald S. Bultje <rsbultje@gmail.com>
26 */
27
28#include <math.h>
29#include "avcodec.h"
30#include "get_bits.h"
31#include "put_bits.h"
32#include "wmavoice_data.h"
33#include "celp_math.h"
34#include "celp_filters.h"
35#include "acelp_vectors.h"
36#include "acelp_filters.h"
37#include "lsp.h"
38#include "libavutil/lzo.h"
39#include "avfft.h"
40#include "fft.h"
41
42#define MAX_BLOCKS 8 ///< maximum number of blocks per frame
43#define MAX_LSPS 16 ///< maximum filter order
44#define MAX_LSPS_ALIGN16 16 ///< same as #MAX_LSPS; needs to be multiple
45 ///< of 16 for ASM input buffer alignment
46#define MAX_FRAMES 3 ///< maximum number of frames per superframe
47#define MAX_FRAMESIZE 160 ///< maximum number of samples per frame
48#define MAX_SIGNAL_HISTORY 416 ///< maximum excitation signal history
49#define MAX_SFRAMESIZE (MAX_FRAMESIZE * MAX_FRAMES)
50 ///< maximum number of samples per superframe
51#define SFRAME_CACHE_MAXSIZE 256 ///< maximum cache size for frame data that
52 ///< was split over two packets
53#define VLC_NBITS 6 ///< number of bits to read per VLC iteration
54
55/**
56 * Frame type VLC coding.
57 */
58static VLC frame_type_vlc;
59
60/**
61 * Adaptive codebook types.
62 */
63enum {
64 ACB_TYPE_NONE = 0, ///< no adaptive codebook (only hardcoded fixed)
65 ACB_TYPE_ASYMMETRIC = 1, ///< adaptive codebook with per-frame pitch, which
66 ///< we interpolate to get a per-sample pitch.
67 ///< Signal is generated using an asymmetric sinc
68 ///< window function
69 ///< @note see #wmavoice_ipol1_coeffs
70 ACB_TYPE_HAMMING = 2 ///< Per-block pitch with signal generation using
71 ///< a Hamming sinc window function
72 ///< @note see #wmavoice_ipol2_coeffs
73};
74
75/**
76 * Fixed codebook types.
77 */
78enum {
79 FCB_TYPE_SILENCE = 0, ///< comfort noise during silence
80 ///< generated from a hardcoded (fixed) codebook
81 ///< with per-frame (low) gain values
82 FCB_TYPE_HARDCODED = 1, ///< hardcoded (fixed) codebook with per-block
83 ///< gain values
84 FCB_TYPE_AW_PULSES = 2, ///< Pitch-adaptive window (AW) pulse signals,
85 ///< used in particular for low-bitrate streams
86 FCB_TYPE_EXC_PULSES = 3, ///< Innovation (fixed) codebook pulse sets in
87 ///< combinations of either single pulses or
88 ///< pulse pairs
89};
90
91/**
92 * Description of frame types.
93 */
94static const struct frame_type_desc {
95 uint8_t n_blocks; ///< amount of blocks per frame (each block
96 ///< (contains 160/#n_blocks samples)
97 uint8_t log_n_blocks; ///< log2(#n_blocks)
98 uint8_t acb_type; ///< Adaptive codebook type (ACB_TYPE_*)
99 uint8_t fcb_type; ///< Fixed codebook type (FCB_TYPE_*)
100 uint8_t dbl_pulses; ///< how many pulse vectors have pulse pairs
101 ///< (rather than just one single pulse)
102 ///< only if #fcb_type == #FCB_TYPE_EXC_PULSES
103 uint16_t frame_size; ///< the amount of bits that make up the block
104 ///< data (per frame)
105} frame_descs[17] = {
106 { 1, 0, ACB_TYPE_NONE, FCB_TYPE_SILENCE, 0, 0 },
107 { 2, 1, ACB_TYPE_NONE, FCB_TYPE_HARDCODED, 0, 28 },
108 { 2, 1, ACB_TYPE_ASYMMETRIC, FCB_TYPE_AW_PULSES, 0, 46 },
109 { 2, 1, ACB_TYPE_ASYMMETRIC, FCB_TYPE_EXC_PULSES, 2, 80 },
110 { 2, 1, ACB_TYPE_ASYMMETRIC, FCB_TYPE_EXC_PULSES, 5, 104 },
111 { 4, 2, ACB_TYPE_ASYMMETRIC, FCB_TYPE_EXC_PULSES, 0, 108 },
112 { 4, 2, ACB_TYPE_ASYMMETRIC, FCB_TYPE_EXC_PULSES, 2, 132 },
113 { 4, 2, ACB_TYPE_ASYMMETRIC, FCB_TYPE_EXC_PULSES, 5, 168 },
114 { 2, 1, ACB_TYPE_HAMMING, FCB_TYPE_EXC_PULSES, 0, 64 },
115 { 2, 1, ACB_TYPE_HAMMING, FCB_TYPE_EXC_PULSES, 2, 80 },
116 { 2, 1, ACB_TYPE_HAMMING, FCB_TYPE_EXC_PULSES, 5, 104 },
117 { 4, 2, ACB_TYPE_HAMMING, FCB_TYPE_EXC_PULSES, 0, 108 },
118 { 4, 2, ACB_TYPE_HAMMING, FCB_TYPE_EXC_PULSES, 2, 132 },
119 { 4, 2, ACB_TYPE_HAMMING, FCB_TYPE_EXC_PULSES, 5, 168 },
120 { 8, 3, ACB_TYPE_HAMMING, FCB_TYPE_EXC_PULSES, 0, 176 },
121 { 8, 3, ACB_TYPE_HAMMING, FCB_TYPE_EXC_PULSES, 2, 208 },
122 { 8, 3, ACB_TYPE_HAMMING, FCB_TYPE_EXC_PULSES, 5, 256 }
123};
124
125/**
126 * WMA Voice decoding context.
127 */
128typedef struct {
129 /**
130 * @defgroup struct_global Global values
131 * Global values, specified in the stream header / extradata or used
132 * all over.
133 * @{
134 */
135 GetBitContext gb; ///< packet bitreader. During decoder init,
136 ///< it contains the extradata from the
137 ///< demuxer. During decoding, it contains
138 ///< packet data.
139 int8_t vbm_tree[25]; ///< converts VLC codes to frame type
140
141 int spillover_bitsize; ///< number of bits used to specify
142 ///< #spillover_nbits in the packet header
143 ///< = ceil(log2(ctx->block_align << 3))
144 int history_nsamples; ///< number of samples in history for signal
145 ///< prediction (through ACB)
146
147 /* postfilter specific values */
148 int do_apf; ///< whether to apply the averaged
149 ///< projection filter (APF)
150 int denoise_strength; ///< strength of denoising in Wiener filter
151 ///< [0-11]
152 int denoise_tilt_corr; ///< Whether to apply tilt correction to the
153 ///< Wiener filter coefficients (postfilter)
154 int dc_level; ///< Predicted amount of DC noise, based
155 ///< on which a DC removal filter is used
156
157 int lsps; ///< number of LSPs per frame [10 or 16]
158 int lsp_q_mode; ///< defines quantizer defaults [0, 1]
159 int lsp_def_mode; ///< defines different sets of LSP defaults
160 ///< [0, 1]
161 int frame_lsp_bitsize; ///< size (in bits) of LSPs, when encoded
162 ///< per-frame (independent coding)
163 int sframe_lsp_bitsize; ///< size (in bits) of LSPs, when encoded
164 ///< per superframe (residual coding)
165
166 int min_pitch_val; ///< base value for pitch parsing code
167 int max_pitch_val; ///< max value + 1 for pitch parsing
168 int pitch_nbits; ///< number of bits used to specify the
169 ///< pitch value in the frame header
170 int block_pitch_nbits; ///< number of bits used to specify the
171 ///< first block's pitch value
172 int block_pitch_range; ///< range of the block pitch
173 int block_delta_pitch_nbits; ///< number of bits used to specify the
174 ///< delta pitch between this and the last
175 ///< block's pitch value, used in all but
176 ///< first block
177 int block_delta_pitch_hrange; ///< 1/2 range of the delta (full range is
178 ///< from -this to +this-1)
179 uint16_t block_conv_table[4]; ///< boundaries for block pitch unit/scale
180 ///< conversion
181
182 /**
183 * @}
184 * @defgroup struct_packet Packet values
185 * Packet values, specified in the packet header or related to a packet.
186 * A packet is considered to be a single unit of data provided to this
187 * decoder by the demuxer.
188 * @{
189 */
190 int spillover_nbits; ///< number of bits of the previous packet's
191 ///< last superframe preceeding this
192 ///< packet's first full superframe (useful
193 ///< for re-synchronization also)
194 int has_residual_lsps; ///< if set, superframes contain one set of
195 ///< LSPs that cover all frames, encoded as
196 ///< independent and residual LSPs; if not
197 ///< set, each frame contains its own, fully
198 ///< independent, LSPs
199 int skip_bits_next; ///< number of bits to skip at the next call
200 ///< to #wmavoice_decode_packet() (since
201 ///< they're part of the previous superframe)
202
203 uint8_t sframe_cache[SFRAME_CACHE_MAXSIZE + FF_INPUT_BUFFER_PADDING_SIZE];
204 ///< cache for superframe data split over
205 ///< multiple packets
206 int sframe_cache_size; ///< set to >0 if we have data from an
207 ///< (incomplete) superframe from a previous
208 ///< packet that spilled over in the current
209 ///< packet; specifies the amount of bits in
210 ///< #sframe_cache
211 PutBitContext pb; ///< bitstream writer for #sframe_cache
212
213 /**
214 * @}
215 * @defgroup struct_frame Frame and superframe values
216 * Superframe and frame data - these can change from frame to frame,
217 * although some of them do in that case serve as a cache / history for
218 * the next frame or superframe.
219 * @{
220 */
221 double prev_lsps[MAX_LSPS]; ///< LSPs of the last frame of the previous
222 ///< superframe
223 int last_pitch_val; ///< pitch value of the previous frame
224 int last_acb_type; ///< frame type [0-2] of the previous frame
225 int pitch_diff_sh16; ///< ((cur_pitch_val - #last_pitch_val)
226 ///< << 16) / #MAX_FRAMESIZE
227 float silence_gain; ///< set for use in blocks if #ACB_TYPE_NONE
228
229 int aw_idx_is_ext; ///< whether the AW index was encoded in
230 ///< 8 bits (instead of 6)
231 int aw_pulse_range; ///< the range over which #aw_pulse_set1()
232 ///< can apply the pulse, relative to the
233 ///< value in aw_first_pulse_off. The exact
234 ///< position of the first AW-pulse is within
235 ///< [pulse_off, pulse_off + this], and
236 ///< depends on bitstream values; [16 or 24]
237 int aw_n_pulses[2]; ///< number of AW-pulses in each block; note
238 ///< that this number can be negative (in
239 ///< which case it basically means "zero")
240 int aw_first_pulse_off[2]; ///< index of first sample to which to
241 ///< apply AW-pulses, or -0xff if unset
242 int aw_next_pulse_off_cache; ///< the position (relative to start of the
243 ///< second block) at which pulses should
244 ///< start to be positioned, serves as a
245 ///< cache for pitch-adaptive window pulses
246 ///< between blocks
247
248 int frame_cntr; ///< current frame index [0 - 0xFFFE]; is
249 ///< only used for comfort noise in #pRNG()
250 float gain_pred_err[6]; ///< cache for gain prediction
251 float excitation_history[MAX_SIGNAL_HISTORY];
252 ///< cache of the signal of previous
253 ///< superframes, used as a history for
254 ///< signal generation
255 float synth_history[MAX_LSPS]; ///< see #excitation_history
256 /**
257 * @}
258 * @defgroup post_filter Postfilter values
259 * Varibales used for postfilter implementation, mostly history for
260 * smoothing and so on, and context variables for FFT/iFFT.
261 * @{
262 */
263 RDFTContext rdft, irdft; ///< contexts for FFT-calculation in the
264 ///< postfilter (for denoise filter)
265 DCTContext dct, dst; ///< contexts for phase shift (in Hilbert
266 ///< transform, part of postfilter)
267 float sin[511], cos[511]; ///< 8-bit cosine/sine windows over [-pi,pi]
268 ///< range
269 float postfilter_agc; ///< gain control memory, used in
270 ///< #adaptive_gain_control()
271 float dcf_mem[2]; ///< DC filter history
272 float zero_exc_pf[MAX_SIGNAL_HISTORY + MAX_SFRAMESIZE];
273 ///< zero filter output (i.e. excitation)
274 ///< by postfilter
275 float denoise_filter_cache[MAX_FRAMESIZE];
276 int denoise_filter_cache_size; ///< samples in #denoise_filter_cache
277 DECLARE_ALIGNED(16, float, tilted_lpcs_pf)[0x80];
278 ///< aligned buffer for LPC tilting
279 DECLARE_ALIGNED(16, float, denoise_coeffs_pf)[0x80];
280 ///< aligned buffer for denoise coefficients
281 DECLARE_ALIGNED(16, float, synth_filter_out_buf)[0x80 + MAX_LSPS_ALIGN16];
282 ///< aligned buffer for postfilter speech
283 ///< synthesis
284 /**
285 * @}
286 */
287} WMAVoiceContext;
288
289/**
290 * Set up the variable bit mode (VBM) tree from container extradata.
291 * @param gb bit I/O context.
292 * The bit context (s->gb) should be loaded with byte 23-46 of the
293 * container extradata (i.e. the ones containing the VBM tree).
294 * @param vbm_tree pointer to array to which the decoded VBM tree will be
295 * written.
296 * @return 0 on success, <0 on error.
297 */
298static av_cold int decode_vbmtree(GetBitContext *gb, int8_t vbm_tree[25])
299{
300 static const uint8_t bits[] = {
301 2, 2, 2, 4, 4, 4,
302 6, 6, 6, 8, 8, 8,
303 10, 10, 10, 12, 12, 12,
304 14, 14, 14, 14
305 };
306 static const uint16_t codes[] = {
307 0x0000, 0x0001, 0x0002, // 00/01/10
308 0x000c, 0x000d, 0x000e, // 11+00/01/10
309 0x003c, 0x003d, 0x003e, // 1111+00/01/10
310 0x00fc, 0x00fd, 0x00fe, // 111111+00/01/10
311 0x03fc, 0x03fd, 0x03fe, // 11111111+00/01/10
312 0x0ffc, 0x0ffd, 0x0ffe, // 1111111111+00/01/10
313 0x3ffc, 0x3ffd, 0x3ffe, 0x3fff // 111111111111+xx
314 };
315 int cntr[8], n, res;
316
317 memset(vbm_tree, 0xff, sizeof(vbm_tree));
318 memset(cntr, 0, sizeof(cntr));
319 for (n = 0; n < 17; n++) {
320 res = get_bits(gb, 3);
321 if (cntr[res] > 3) // should be >= 3 + (res == 7))
322 return -1;
323 vbm_tree[res * 3 + cntr[res]++] = n;
324 }
325 INIT_VLC_STATIC(&frame_type_vlc, VLC_NBITS, sizeof(bits),
326 bits, 1, 1, codes, 2, 2, 132);
327 return 0;
328}
329
330/**
331 * Set up decoder with parameters from demuxer (extradata etc.).
332 */
333static av_cold int wmavoice_decode_init(AVCodecContext *ctx)
334{
335 int n, flags, pitch_range, lsp16_flag;
336 WMAVoiceContext *s = ctx->priv_data;
337
338 /**
339 * Extradata layout:
340 * - byte 0-18: WMAPro-in-WMAVoice extradata (see wmaprodec.c),
341 * - byte 19-22: flags field (annoyingly in LE; see below for known
342 * values),
343 * - byte 23-46: variable bitmode tree (really just 17 * 3 bits,
344 * rest is 0).
345 */
346 if (ctx->extradata_size != 46) {
347 av_log(ctx, AV_LOG_ERROR,
348 "Invalid extradata size %d (should be 46)\n",
349 ctx->extradata_size);
350 return -1;
351 }
352 flags = AV_RL32(ctx->extradata + 18);
353 s->spillover_bitsize = 3 + av_ceil_log2(ctx->block_align);
354 s->do_apf = flags & 0x1;
355 if (s->do_apf) {
356 ff_rdft_init(&s->rdft, 7, DFT_R2C);
357 ff_rdft_init(&s->irdft, 7, IDFT_C2R);
358 ff_dct_init(&s->dct, 6, DCT_I);
359 ff_dct_init(&s->dst, 6, DST_I);
360
361 ff_sine_window_init(s->cos, 256);
362 memcpy(&s->sin[255], s->cos, 256 * sizeof(s->cos[0]));
363 for (n = 0; n < 255; n++) {
364 s->sin[n] = -s->sin[510 - n];
365 s->cos[510 - n] = s->cos[n];
366 }
367 }
368 s->denoise_strength = (flags >> 2) & 0xF;
369 if (s->denoise_strength >= 12) {
370 av_log(ctx, AV_LOG_ERROR,
371 "Invalid denoise filter strength %d (max=11)\n",
372 s->denoise_strength);
373 return -1;
374 }
375 s->denoise_tilt_corr = !!(flags & 0x40);
376 s->dc_level = (flags >> 7) & 0xF;
377 s->lsp_q_mode = !!(flags & 0x2000);
378 s->lsp_def_mode = !!(flags & 0x4000);
379 lsp16_flag = flags & 0x1000;
380 if (lsp16_flag) {
381 s->lsps = 16;
382 s->frame_lsp_bitsize = 34;
383 s->sframe_lsp_bitsize = 60;
384 } else {
385 s->lsps = 10;
386 s->frame_lsp_bitsize = 24;
387 s->sframe_lsp_bitsize = 48;
388 }
389 for (n = 0; n < s->lsps; n++)
390 s->prev_lsps[n] = M_PI * (n + 1.0) / (s->lsps + 1.0);
391
392 init_get_bits(&s->gb, ctx->extradata + 22, (ctx->extradata_size - 22) << 3);
393 if (decode_vbmtree(&s->gb, s->vbm_tree) < 0) {
394 av_log(ctx, AV_LOG_ERROR, "Invalid VBM tree; broken extradata?\n");
395 return -1;
396 }
397
398 s->min_pitch_val = ((ctx->sample_rate << 8) / 400 + 50) >> 8;
399 s->max_pitch_val = ((ctx->sample_rate << 8) * 37 / 2000 + 50) >> 8;
400 pitch_range = s->max_pitch_val - s->min_pitch_val;
401 s->pitch_nbits = av_ceil_log2(pitch_range);
402 s->last_pitch_val = 40;
403 s->last_acb_type = ACB_TYPE_NONE;
404 s->history_nsamples = s->max_pitch_val + 8;
405
406 if (s->min_pitch_val < 1 || s->history_nsamples > MAX_SIGNAL_HISTORY) {
407 int min_sr = ((((1 << 8) - 50) * 400) + 0xFF) >> 8,
408 max_sr = ((((MAX_SIGNAL_HISTORY - 8) << 8) + 205) * 2000 / 37) >> 8;
409
410 av_log(ctx, AV_LOG_ERROR,
411 "Unsupported samplerate %d (min=%d, max=%d)\n",
412 ctx->sample_rate, min_sr, max_sr); // 322-22097 Hz
413
414 return -1;
415 }
416
417 s->block_conv_table[0] = s->min_pitch_val;
418 s->block_conv_table[1] = (pitch_range * 25) >> 6;
419 s->block_conv_table[2] = (pitch_range * 44) >> 6;
420 s->block_conv_table[3] = s->max_pitch_val - 1;
421 s->block_delta_pitch_hrange = (pitch_range >> 3) & ~0xF;
422 s->block_delta_pitch_nbits = 1 + av_ceil_log2(s->block_delta_pitch_hrange);
423 s->block_pitch_range = s->block_conv_table[2] +
424 s->block_conv_table[3] + 1 +
425 2 * (s->block_conv_table[1] - 2 * s->min_pitch_val);
426 s->block_pitch_nbits = av_ceil_log2(s->block_pitch_range);
427
428 ctx->sample_fmt = SAMPLE_FMT_FLT;
429
430 return 0;
431}
432
433/**
434 * @defgroup postfilter Postfilter functions
435 * Postfilter functions (gain control, wiener denoise filter, DC filter,
436 * kalman smoothening, plus surrounding code to wrap it)
437 * @{
438 */
439/**
440 * Adaptive gain control (as used in postfilter).
441 *
442 * Identical to #ff_adaptive_gain_control() in acelp_vectors.c, except
443 * that the energy here is calculated using sum(abs(...)), whereas the
444 * other codecs (e.g. AMR-NB, SIPRO) use sqrt(dotproduct(...)).
445 *
446 * @param out output buffer for filtered samples
447 * @param in input buffer containing the samples as they are after the
448 * postfilter steps so far
449 * @param speech_synth input buffer containing speech synth before postfilter
450 * @param size input buffer size
451 * @param alpha exponential filter factor
452 * @param gain_mem pointer to filter memory (single float)
453 */
454static void adaptive_gain_control(float *out, const float *in,
455 const float *speech_synth,
456 int size, float alpha, float *gain_mem)
457{
458 int i;
459 float speech_energy = 0.0, postfilter_energy = 0.0, gain_scale_factor;
460 float mem = *gain_mem;
461
462 for (i = 0; i < size; i++) {
463 speech_energy += fabsf(speech_synth[i]);
464 postfilter_energy += fabsf(in[i]);
465 }
466 gain_scale_factor = (1.0 - alpha) * speech_energy / postfilter_energy;
467
468 for (i = 0; i < size; i++) {
469 mem = alpha * mem + gain_scale_factor;
470 out[i] = in[i] * mem;
471 }
472
473 *gain_mem = mem;
474}
475
476/**
477 * Kalman smoothing function.
478 *
479 * This function looks back pitch +/- 3 samples back into history to find
480 * the best fitting curve (that one giving the optimal gain of the two
481 * signals, i.e. the highest dot product between the two), and then
482 * uses that signal history to smoothen the output of the speech synthesis
483 * filter.
484 *
485 * @param s WMA Voice decoding context
486 * @param pitch pitch of the speech signal
487 * @param in input speech signal
488 * @param out output pointer for smoothened signal
489 * @param size input/output buffer size
490 *
491 * @returns -1 if no smoothening took place, e.g. because no optimal
492 * fit could be found, or 0 on success.
493 */
494static int kalman_smoothen(WMAVoiceContext *s, int pitch,
495 const float *in, float *out, int size)
496{
497 int n;
498 float optimal_gain = 0, dot;
499 const float *ptr = &in[-FFMAX(s->min_pitch_val, pitch - 3)],
500 *end = &in[-FFMIN(s->max_pitch_val, pitch + 3)],
501 *best_hist_ptr;
502
503 /* find best fitting point in history */
504 do {
505 dot = ff_dot_productf(in, ptr, size);
506 if (dot > optimal_gain) {
507 optimal_gain = dot;
508 best_hist_ptr = ptr;
509 }
510 } while (--ptr >= end);
511
512 if (optimal_gain <= 0)
513 return -1;
514 dot = ff_dot_productf(best_hist_ptr, best_hist_ptr, size);
515 if (dot <= 0) // would be 1.0
516 return -1;
517
518 if (optimal_gain <= dot) {
519 dot = dot / (dot + 0.6 * optimal_gain); // 0.625-1.000
520 } else
521 dot = 0.625;
522
523 /* actual smoothing */
524 for (n = 0; n < size; n++)
525 out[n] = best_hist_ptr[n] + dot * (in[n] - best_hist_ptr[n]);
526
527 return 0;
528}
529
530/**
531 * Get the tilt factor of a formant filter from its transfer function
532 * @see #tilt_factor() in amrnbdec.c, which does essentially the same,
533 * but somehow (??) it does a speech synthesis filter in the
534 * middle, which is missing here
535 *
536 * @param lpcs LPC coefficients
537 * @param n_lpcs Size of LPC buffer
538 * @returns the tilt factor
539 */
540static float tilt_factor(const float *lpcs, int n_lpcs)
541{
542 float rh0, rh1;
543
544 rh0 = 1.0 + ff_dot_productf(lpcs, lpcs, n_lpcs);
545 rh1 = lpcs[0] + ff_dot_productf(lpcs, &lpcs[1], n_lpcs - 1);
546
547 return rh1 / rh0;
548}
549
550/**
551 * Derive denoise filter coefficients (in real domain) from the LPCs.
552 */
553static void calc_input_response(WMAVoiceContext *s, float *lpcs,
554 int fcb_type, float *coeffs, int remainder)
555{
556 float last_coeff, min = 15.0, max = -15.0;
557 float irange, angle_mul, gain_mul, range, sq;
558 int n, idx;
559
560 /* Create frequency power spectrum of speech input (i.e. RDFT of LPCs) */
561 ff_rdft_calc(&s->rdft, lpcs);
562#define log_range(var, assign) do { \
563 float tmp = log10f(assign); var = tmp; \
564 max = FFMAX(max, tmp); min = FFMIN(min, tmp); \
565 } while (0)
566 log_range(last_coeff, lpcs[1] * lpcs[1]);
567 for (n = 1; n < 64; n++)
568 log_range(lpcs[n], lpcs[n * 2] * lpcs[n * 2] +
569 lpcs[n * 2 + 1] * lpcs[n * 2 + 1]);
570 log_range(lpcs[0], lpcs[0] * lpcs[0]);
571#undef log_range
572 range = max - min;
573 lpcs[64] = last_coeff;
574
575 /* Now, use this spectrum to pick out these frequencies with higher
576 * (relative) power/energy (which we then take to be "not noise"),
577 * and set up a table (still in lpc[]) of (relative) gains per frequency.
578 * These frequencies will be maintained, while others ("noise") will be
579 * decreased in the filter output. */
580 irange = 64.0 / range; // so irange*(max-value) is in the range [0, 63]
581 gain_mul = range * (fcb_type == FCB_TYPE_HARDCODED ? (5.0 / 13.0) :
582 (5.0 / 14.7));
583 angle_mul = gain_mul * (8.0 * M_LN10 / M_PI);
584 for (n = 0; n <= 64; n++) {
585 float pwr;
586
587 idx = FFMAX(0, lrint((max - lpcs[n]) * irange) - 1);
588 pwr = wmavoice_denoise_power_table[s->denoise_strength][idx];
589 lpcs[n] = angle_mul * pwr;
590
591 /* 70.57 =~ 1/log10(1.0331663) */
592 idx = (pwr * gain_mul - 0.0295) * 70.570526123;
593 if (idx > 127) { // fallback if index falls outside table range
594 coeffs[n] = wmavoice_energy_table[127] *
595 powf(1.0331663, idx - 127);
596 } else
597 coeffs[n] = wmavoice_energy_table[FFMAX(0, idx)];
598 }
599
600 /* calculate the Hilbert transform of the gains, which we do (since this
601 * is a sinus input) by doing a phase shift (in theory, H(sin())=cos()).
602 * Hilbert_Transform(RDFT(x)) = Laplace_Transform(x), which calculates the
603 * "moment" of the LPCs in this filter. */
604 ff_dct_calc(&s->dct, lpcs);
605 ff_dct_calc(&s->dst, lpcs);
606
607 /* Split out the coefficient indexes into phase/magnitude pairs */
608 idx = 255 + av_clip(lpcs[64], -255, 255);
609 coeffs[0] = coeffs[0] * s->cos[idx];
610 idx = 255 + av_clip(lpcs[64] - 2 * lpcs[63], -255, 255);
611 last_coeff = coeffs[64] * s->cos[idx];
612 for (n = 63;; n--) {
613 idx = 255 + av_clip(-lpcs[64] - 2 * lpcs[n - 1], -255, 255);
614 coeffs[n * 2 + 1] = coeffs[n] * s->sin[idx];
615 coeffs[n * 2] = coeffs[n] * s->cos[idx];
616
617 if (!--n) break;
618
619 idx = 255 + av_clip( lpcs[64] - 2 * lpcs[n - 1], -255, 255);
620 coeffs[n * 2 + 1] = coeffs[n] * s->sin[idx];
621 coeffs[n * 2] = coeffs[n] * s->cos[idx];
622 }
623 coeffs[1] = last_coeff;
624
625 /* move into real domain */
626 ff_rdft_calc(&s->irdft, coeffs);
627
628 /* tilt correction and normalize scale */
629 memset(&coeffs[remainder], 0, sizeof(coeffs[0]) * (128 - remainder));
630 if (s->denoise_tilt_corr) {
631 float tilt_mem = 0;
632
633 coeffs[remainder - 1] = 0;
634 ff_tilt_compensation(&tilt_mem,
635 -1.8 * tilt_factor(coeffs, remainder - 1),
636 coeffs, remainder);
637 }
638 sq = (1.0 / 64.0) * sqrtf(1 / ff_dot_productf(coeffs, coeffs, remainder));
639 for (n = 0; n < remainder; n++)
640 coeffs[n] *= sq;
641}
642
643/**
644 * This function applies a Wiener filter on the (noisy) speech signal as
645 * a means to denoise it.
646 *
647 * - take RDFT of LPCs to get the power spectrum of the noise + speech;
648 * - using this power spectrum, calculate (for each frequency) the Wiener
649 * filter gain, which depends on the frequency power and desired level
650 * of noise subtraction (when set too high, this leads to artifacts)
651 * We can do this symmetrically over the X-axis (so 0-4kHz is the inverse
652 * of 4-8kHz);
653 * - by doing a phase shift, calculate the Hilbert transform of this array
654 * of per-frequency filter-gains to get the filtering coefficients;
655 * - smoothen/normalize/de-tilt these filter coefficients as desired;
656 * - take RDFT of noisy sound, apply the coefficients and take its IRDFT
657 * to get the denoised speech signal;
658 * - the leftover (i.e. output of the IRDFT on denoised speech data beyond
659 * the frame boundary) are saved and applied to subsequent frames by an
660 * overlap-add method (otherwise you get clicking-artifacts).
661 *
662 * @param s WMA Voice decoding context
663 * @param fcb_type Frame (codebook) type
664 * @param synth_pf input: the noisy speech signal, output: denoised speech
665 * data; should be 16-byte aligned (for ASM purposes)
666 * @param size size of the speech data
667 * @param lpcs LPCs used to synthesize this frame's speech data
668 */
669static void wiener_denoise(WMAVoiceContext *s, int fcb_type,
670 float *synth_pf, int size,
671 const float *lpcs)
672{
673 int remainder, lim, n;
674
675 if (fcb_type != FCB_TYPE_SILENCE) {
676 float *tilted_lpcs = s->tilted_lpcs_pf,
677 *coeffs = s->denoise_coeffs_pf, tilt_mem = 0;
678
679 tilted_lpcs[0] = 1.0;
680 memcpy(&tilted_lpcs[1], lpcs, sizeof(lpcs[0]) * s->lsps);
681 memset(&tilted_lpcs[s->lsps + 1], 0,
682 sizeof(tilted_lpcs[0]) * (128 - s->lsps - 1));
683 ff_tilt_compensation(&tilt_mem, 0.7 * tilt_factor(lpcs, s->lsps),
684 tilted_lpcs, s->lsps + 2);
685
686 /* The IRDFT output (127 samples for 7-bit filter) beyond the frame
687 * size is applied to the next frame. All input beyond this is zero,
688 * and thus all output beyond this will go towards zero, hence we can
689 * limit to min(size-1, 127-size) as a performance consideration. */
690 remainder = FFMIN(127 - size, size - 1);
691 calc_input_response(s, tilted_lpcs, fcb_type, coeffs, remainder);
692
693 /* apply coefficients (in frequency spectrum domain), i.e. complex
694 * number multiplication */
695 memset(&synth_pf[size], 0, sizeof(synth_pf[0]) * (128 - size));
696 ff_rdft_calc(&s->rdft, synth_pf);
697 ff_rdft_calc(&s->rdft, coeffs);
698 synth_pf[0] *= coeffs[0];
699 synth_pf[1] *= coeffs[1];
700 for (n = 1; n < 64; n++) {
701 float v1 = synth_pf[n * 2], v2 = synth_pf[n * 2 + 1];
702 synth_pf[n * 2] = v1 * coeffs[n * 2] - v2 * coeffs[n * 2 + 1];
703 synth_pf[n * 2 + 1] = v2 * coeffs[n * 2] + v1 * coeffs[n * 2 + 1];
704 }
705 ff_rdft_calc(&s->irdft, synth_pf);
706 }
707
708 /* merge filter output with the history of previous runs */
709 if (s->denoise_filter_cache_size) {
710 lim = FFMIN(s->denoise_filter_cache_size, size);
711 for (n = 0; n < lim; n++)
712 synth_pf[n] += s->denoise_filter_cache[n];
713 s->denoise_filter_cache_size -= lim;
714 memmove(s->denoise_filter_cache, &s->denoise_filter_cache[size],
715 sizeof(s->denoise_filter_cache[0]) * s->denoise_filter_cache_size);
716 }
717
718 /* move remainder of filter output into a cache for future runs */
719 if (fcb_type != FCB_TYPE_SILENCE) {
720 lim = FFMIN(remainder, s->denoise_filter_cache_size);
721 for (n = 0; n < lim; n++)
722 s->denoise_filter_cache[n] += synth_pf[size + n];
723 if (lim < remainder) {
724 memcpy(&s->denoise_filter_cache[lim], &synth_pf[size + lim],
725 sizeof(s->denoise_filter_cache[0]) * (remainder - lim));
726 s->denoise_filter_cache_size = remainder;
727 }
728 }
729}
730
731/**
732 * Averaging projection filter, the postfilter used in WMAVoice.
733 *
734 * This uses the following steps:
735 * - A zero-synthesis filter (generate excitation from synth signal)
736 * - Kalman smoothing on excitation, based on pitch
737 * - Re-synthesized smoothened output
738 * - Iterative Wiener denoise filter
739 * - Adaptive gain filter
740 * - DC filter
741 *
742 * @param s WMAVoice decoding context
743 * @param synth Speech synthesis output (before postfilter)
744 * @param samples Output buffer for filtered samples
745 * @param size Buffer size of synth & samples
746 * @param lpcs Generated LPCs used for speech synthesis
747 * @param zero_exc_pf destination for zero synthesis filter (16-byte aligned)
748 * @param fcb_type Frame type (silence, hardcoded, AW-pulses or FCB-pulses)
749 * @param pitch Pitch of the input signal
750 */
751static void postfilter(WMAVoiceContext *s, const float *synth,
752 float *samples, int size,
753 const float *lpcs, float *zero_exc_pf,
754 int fcb_type, int pitch)
755{
756 float synth_filter_in_buf[MAX_FRAMESIZE / 2],
757 *synth_pf = &s->synth_filter_out_buf[MAX_LSPS_ALIGN16],
758 *synth_filter_in = zero_exc_pf;
759
760 assert(size <= MAX_FRAMESIZE / 2);
761
762 /* generate excitation from input signal */
763 ff_celp_lp_zero_synthesis_filterf(zero_exc_pf, lpcs, synth, size, s->lsps);
764
765 if (fcb_type >= FCB_TYPE_AW_PULSES &&
766 !kalman_smoothen(s, pitch, zero_exc_pf, synth_filter_in_buf, size))
767 synth_filter_in = synth_filter_in_buf;
768
769 /* re-synthesize speech after smoothening, and keep history */
770 ff_celp_lp_synthesis_filterf(synth_pf, lpcs,
771 synth_filter_in, size, s->lsps);
772 memcpy(&synth_pf[-s->lsps], &synth_pf[size - s->lsps],
773 sizeof(synth_pf[0]) * s->lsps);
774
775 wiener_denoise(s, fcb_type, synth_pf, size, lpcs);
776
777 adaptive_gain_control(samples, synth_pf, synth, size, 0.99,
778 &s->postfilter_agc);
779
780 if (s->dc_level > 8) {
781 /* remove ultra-low frequency DC noise / highpass filter;
782 * coefficients are identical to those used in SIPR decoding,
783 * and very closely resemble those used in AMR-NB decoding. */
784 ff_acelp_apply_order_2_transfer_function(samples, samples,
785 (const float[2]) { -1.99997, 1.0 },
786 (const float[2]) { -1.9330735188, 0.93589198496 },
787 0.93980580475, s->dcf_mem, size);
788 }
789}
790/**
791 * @}
792 */
793
794/**
795 * Dequantize LSPs
796 * @param lsps output pointer to the array that will hold the LSPs
797 * @param num number of LSPs to be dequantized
798 * @param values quantized values, contains n_stages values
799 * @param sizes range (i.e. max value) of each quantized value
800 * @param n_stages number of dequantization runs
801 * @param table dequantization table to be used
802 * @param mul_q LSF multiplier
803 * @param base_q base (lowest) LSF values
804 */
805static void dequant_lsps(double *lsps, int num,
806 const uint16_t *values,
807 const uint16_t *sizes,
808 int n_stages, const uint8_t *table,
809 const double *mul_q,
810 const double *base_q)
811{
812 int n, m;
813
814 memset(lsps, 0, num * sizeof(*lsps));
815 for (n = 0; n < n_stages; n++) {
816 const uint8_t *t_off = &table[values[n] * num];
817 double base = base_q[n], mul = mul_q[n];
818
819 for (m = 0; m < num; m++)
820 lsps[m] += base + mul * t_off[m];
821
822 table += sizes[n] * num;
823 }
824}
825
826/**
827 * @defgroup lsp_dequant LSP dequantization routines
828 * LSP dequantization routines, for 10/16LSPs and independent/residual coding.
829 * @note we assume enough bits are available, caller should check.
830 * lsp10i() consumes 24 bits; lsp10r() consumes an additional 24 bits;
831 * lsp16i() consumes 34 bits; lsp16r() consumes an additional 26 bits.
832 * @{
833 */
834/**
835 * Parse 10 independently-coded LSPs.
836 */
837static void dequant_lsp10i(GetBitContext *gb, double *lsps)
838{
839 static const uint16_t vec_sizes[4] = { 256, 64, 32, 32 };
840 static const double mul_lsf[4] = {
841 5.2187144800e-3, 1.4626986422e-3,
842 9.6179549166e-4, 1.1325736225e-3
843 };
844 static const double base_lsf[4] = {
845 M_PI * -2.15522e-1, M_PI * -6.1646e-2,
846 M_PI * -3.3486e-2, M_PI * -5.7408e-2
847 };
848 uint16_t v[4];
849
850 v[0] = get_bits(gb, 8);
851 v[1] = get_bits(gb, 6);
852 v[2] = get_bits(gb, 5);
853 v[3] = get_bits(gb, 5);
854
855 dequant_lsps(lsps, 10, v, vec_sizes, 4, wmavoice_dq_lsp10i,
856 mul_lsf, base_lsf);
857}
858
859/**
860 * Parse 10 independently-coded LSPs, and then derive the tables to
861 * generate LSPs for the other frames from them (residual coding).
862 */
863static void dequant_lsp10r(GetBitContext *gb,
864 double *i_lsps, const double *old,
865 double *a1, double *a2, int q_mode)
866{
867 static const uint16_t vec_sizes[3] = { 128, 64, 64 };
868 static const double mul_lsf[3] = {
869 2.5807601174e-3, 1.2354460219e-3, 1.1763821673e-3
870 };
871 static const double base_lsf[3] = {
872 M_PI * -1.07448e-1, M_PI * -5.2706e-2, M_PI * -5.1634e-2
873 };
874 const float (*ipol_tab)[2][10] = q_mode ?
875 wmavoice_lsp10_intercoeff_b : wmavoice_lsp10_intercoeff_a;
876 uint16_t interpol, v[3];
877 int n;
878
879 dequant_lsp10i(gb, i_lsps);
880
881 interpol = get_bits(gb, 5);
882 v[0] = get_bits(gb, 7);
883 v[1] = get_bits(gb, 6);
884 v[2] = get_bits(gb, 6);
885
886 for (n = 0; n < 10; n++) {
887 double delta = old[n] - i_lsps[n];
888 a1[n] = ipol_tab[interpol][0][n] * delta + i_lsps[n];
889 a1[10 + n] = ipol_tab[interpol][1][n] * delta + i_lsps[n];
890 }
891
892 dequant_lsps(a2, 20, v, vec_sizes, 3, wmavoice_dq_lsp10r,
893 mul_lsf, base_lsf);
894}
895
896/**
897 * Parse 16 independently-coded LSPs.
898 */
899static void dequant_lsp16i(GetBitContext *gb, double *lsps)
900{
901 static const uint16_t vec_sizes[5] = { 256, 64, 128, 64, 128 };
902 static const double mul_lsf[5] = {
903 3.3439586280e-3, 6.9908173703e-4,
904 3.3216608306e-3, 1.0334960326e-3,
905 3.1899104283e-3
906 };
907 static const double base_lsf[5] = {
908 M_PI * -1.27576e-1, M_PI * -2.4292e-2,
909 M_PI * -1.28094e-1, M_PI * -3.2128e-2,
910 M_PI * -1.29816e-1
911 };
912 uint16_t v[5];
913
914 v[0] = get_bits(gb, 8);
915 v[1] = get_bits(gb, 6);
916 v[2] = get_bits(gb, 7);
917 v[3] = get_bits(gb, 6);
918 v[4] = get_bits(gb, 7);
919
920 dequant_lsps( lsps, 5, v, vec_sizes, 2,
921 wmavoice_dq_lsp16i1, mul_lsf, base_lsf);
922 dequant_lsps(&lsps[5], 5, &v[2], &vec_sizes[2], 2,
923 wmavoice_dq_lsp16i2, &mul_lsf[2], &base_lsf[2]);
924 dequant_lsps(&lsps[10], 6, &v[4], &vec_sizes[4], 1,
925 wmavoice_dq_lsp16i3, &mul_lsf[4], &base_lsf[4]);
926}
927
928/**
929 * Parse 16 independently-coded LSPs, and then derive the tables to
930 * generate LSPs for the other frames from them (residual coding).
931 */
932static void dequant_lsp16r(GetBitContext *gb,
933 double *i_lsps, const double *old,
934 double *a1, double *a2, int q_mode)
935{
936 static const uint16_t vec_sizes[3] = { 128, 128, 128 };
937 static const double mul_lsf[3] = {
938 1.2232979501e-3, 1.4062241527e-3, 1.6114744851e-3
939 };
940 static const double base_lsf[3] = {
941 M_PI * -5.5830e-2, M_PI * -5.2908e-2, M_PI * -5.4776e-2
942 };
943 const float (*ipol_tab)[2][16] = q_mode ?
944 wmavoice_lsp16_intercoeff_b : wmavoice_lsp16_intercoeff_a;
945 uint16_t interpol, v[3];
946 int n;
947
948 dequant_lsp16i(gb, i_lsps);
949
950 interpol = get_bits(gb, 5);
951 v[0] = get_bits(gb, 7);
952 v[1] = get_bits(gb, 7);
953 v[2] = get_bits(gb, 7);
954
955 for (n = 0; n < 16; n++) {
956 double delta = old[n] - i_lsps[n];
957 a1[n] = ipol_tab[interpol][0][n] * delta + i_lsps[n];
958 a1[16 + n] = ipol_tab[interpol][1][n] * delta + i_lsps[n];
959 }
960
961 dequant_lsps( a2, 10, v, vec_sizes, 1,
962 wmavoice_dq_lsp16r1, mul_lsf, base_lsf);
963 dequant_lsps(&a2[10], 10, &v[1], &vec_sizes[1], 1,
964 wmavoice_dq_lsp16r2, &mul_lsf[1], &base_lsf[1]);
965 dequant_lsps(&a2[20], 12, &v[2], &vec_sizes[2], 1,
966 wmavoice_dq_lsp16r3, &mul_lsf[2], &base_lsf[2]);
967}
968
969/**
970 * @}
971 * @defgroup aw Pitch-adaptive window coding functions
972 * The next few functions are for pitch-adaptive window coding.
973 * @{
974 */
975/**
976 * Parse the offset of the first pitch-adaptive window pulses, and
977 * the distribution of pulses between the two blocks in this frame.
978 * @param s WMA Voice decoding context private data
979 * @param gb bit I/O context
980 * @param pitch pitch for each block in this frame
981 */
982static void aw_parse_coords(WMAVoiceContext *s, GetBitContext *gb,
983 const int *pitch)
984{
985 static const int16_t start_offset[94] = {
986 -11, -9, -7, -5, -3, -1, 1, 3, 5, 7, 9, 11,
987 13, 15, 18, 17, 19, 20, 21, 22, 23, 24, 25, 26,
988 27, 28, 29, 30, 31, 32, 33, 35, 37, 39, 41, 43,
989 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67,
990 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91,
991 93, 95, 97, 99, 101, 103, 105, 107, 109, 111, 113, 115,
992 117, 119, 121, 123, 125, 127, 129, 131, 133, 135, 137, 139,
993 141, 143, 145, 147, 149, 151, 153, 155, 157, 159
994 };
995 int bits, offset;
996
997 /* position of pulse */
998 s->aw_idx_is_ext = 0;
999 if ((bits = get_bits(gb, 6)) >= 54) {
1000 s->aw_idx_is_ext = 1;
1001 bits += (bits - 54) * 3 + get_bits(gb, 2);
1002 }
1003
1004 /* for a repeated pulse at pulse_off with a pitch_lag of pitch[], count
1005 * the distribution of the pulses in each block contained in this frame. */
1006 s->aw_pulse_range = FFMIN(pitch[0], pitch[1]) > 32 ? 24 : 16;
1007 for (offset = start_offset[bits]; offset < 0; offset += pitch[0]) ;
1008 s->aw_n_pulses[0] = (pitch[0] - 1 + MAX_FRAMESIZE / 2 - offset) / pitch[0];
1009 s->aw_first_pulse_off[0] = offset - s->aw_pulse_range / 2;
1010 offset += s->aw_n_pulses[0] * pitch[0];
1011 s->aw_n_pulses[1] = (pitch[1] - 1 + MAX_FRAMESIZE - offset) / pitch[1];
1012 s->aw_first_pulse_off[1] = offset - (MAX_FRAMESIZE + s->aw_pulse_range) / 2;
1013
1014 /* if continuing from a position before the block, reset position to
1015 * start of block (when corrected for the range over which it can be
1016 * spread in aw_pulse_set1()). */
1017 if (start_offset[bits] < MAX_FRAMESIZE / 2) {
1018 while (s->aw_first_pulse_off[1] - pitch[1] + s->aw_pulse_range > 0)
1019 s->aw_first_pulse_off[1] -= pitch[1];
1020 if (start_offset[bits] < 0)
1021 while (s->aw_first_pulse_off[0] - pitch[0] + s->aw_pulse_range > 0)
1022 s->aw_first_pulse_off[0] -= pitch[0];
1023 }
1024}
1025
1026/**
1027 * Apply second set of pitch-adaptive window pulses.
1028 * @param s WMA Voice decoding context private data
1029 * @param gb bit I/O context
1030 * @param block_idx block index in frame [0, 1]
1031 * @param fcb structure containing fixed codebook vector info
1032 */
1033static void aw_pulse_set2(WMAVoiceContext *s, GetBitContext *gb,
1034 int block_idx, AMRFixed *fcb)
1035{
1036 uint16_t use_mask[7]; // only 5 are used, rest is padding
1037 /* in this function, idx is the index in the 80-bit (+ padding) use_mask
1038 * bit-array. Since use_mask consists of 16-bit values, the lower 4 bits
1039 * of idx are the position of the bit within a particular item in the
1040 * array (0 being the most significant bit, and 15 being the least
1041 * significant bit), and the remainder (>> 4) is the index in the
1042 * use_mask[]-array. This is faster and uses less memory than using a
1043 * 80-byte/80-int array. */
1044 int pulse_off = s->aw_first_pulse_off[block_idx],
1045 pulse_start, n, idx, range, aidx, start_off = 0;
1046
1047 /* set offset of first pulse to within this block */
1048 if (s->aw_n_pulses[block_idx] > 0)
1049 while (pulse_off + s->aw_pulse_range < 1)
1050 pulse_off += fcb->pitch_lag;
1051
1052 /* find range per pulse */
1053 if (s->aw_n_pulses[0] > 0) {
1054 if (block_idx == 0) {
1055 range = 32;
1056 } else /* block_idx = 1 */ {
1057 range = 8;
1058 if (s->aw_n_pulses[block_idx] > 0)
1059 pulse_off = s->aw_next_pulse_off_cache;
1060 }
1061 } else
1062 range = 16;
1063 pulse_start = s->aw_n_pulses[block_idx] > 0 ? pulse_off - range / 2 : 0;
1064
1065 /* aw_pulse_set1() already applies pulses around pulse_off (to be exactly,
1066 * in the range of [pulse_off, pulse_off + s->aw_pulse_range], and thus
1067 * we exclude that range from being pulsed again in this function. */
1068 memset( use_mask, -1, 5 * sizeof(use_mask[0]));
1069 memset(&use_mask[5], 0, 2 * sizeof(use_mask[0]));
1070 if (s->aw_n_pulses[block_idx] > 0)
1071 for (idx = pulse_off; idx < MAX_FRAMESIZE / 2; idx += fcb->pitch_lag) {
1072 int excl_range = s->aw_pulse_range; // always 16 or 24
1073 uint16_t *use_mask_ptr = &use_mask[idx >> 4];
1074 int first_sh = 16 - (idx & 15);
1075 *use_mask_ptr++ &= 0xFFFF << first_sh;
1076 excl_range -= first_sh;
1077 if (excl_range >= 16) {
1078 *use_mask_ptr++ = 0;
1079 *use_mask_ptr &= 0xFFFF >> (excl_range - 16);
1080 } else
1081 *use_mask_ptr &= 0xFFFF >> excl_range;
1082 }
1083
1084 /* find the 'aidx'th offset that is not excluded */
1085 aidx = get_bits(gb, s->aw_n_pulses[0] > 0 ? 5 - 2 * block_idx : 4);
1086 for (n = 0; n <= aidx; pulse_start++) {
1087 for (idx = pulse_start; idx < 0; idx += fcb->pitch_lag) ;
1088 if (idx >= MAX_FRAMESIZE / 2) { // find from zero
1089 if (use_mask[0]) idx = 0x0F;
1090 else if (use_mask[1]) idx = 0x1F;
1091 else if (use_mask[2]) idx = 0x2F;
1092 else if (use_mask[3]) idx = 0x3F;
1093 else if (use_mask[4]) idx = 0x4F;
1094 else return;
1095 idx -= av_log2_16bit(use_mask[idx >> 4]);
1096 }
1097 if (use_mask[idx >> 4] & (0x8000 >> (idx & 15))) {
1098 use_mask[idx >> 4] &= ~(0x8000 >> (idx & 15));
1099 n++;
1100 start_off = idx;
1101 }
1102 }
1103
1104 fcb->x[fcb->n] = start_off;
1105 fcb->y[fcb->n] = get_bits1(gb) ? -1.0 : 1.0;
1106 fcb->n++;
1107
1108 /* set offset for next block, relative to start of that block */
1109 n = (MAX_FRAMESIZE / 2 - start_off) % fcb->pitch_lag;
1110 s->aw_next_pulse_off_cache = n ? fcb->pitch_lag - n : 0;
1111}
1112
1113/**
1114 * Apply first set of pitch-adaptive window pulses.
1115 * @param s WMA Voice decoding context private data
1116 * @param gb bit I/O context
1117 * @param block_idx block index in frame [0, 1]
1118 * @param fcb storage location for fixed codebook pulse info
1119 */
1120static void aw_pulse_set1(WMAVoiceContext *s, GetBitContext *gb,
1121 int block_idx, AMRFixed *fcb)
1122{
1123 int val = get_bits(gb, 12 - 2 * (s->aw_idx_is_ext && !block_idx));
1124 float v;
1125
1126 if (s->aw_n_pulses[block_idx] > 0) {
1127 int n, v_mask, i_mask, sh, n_pulses;
1128
1129 if (s->aw_pulse_range == 24) { // 3 pulses, 1:sign + 3:index each
1130 n_pulses = 3;
1131 v_mask = 8;
1132 i_mask = 7;
1133 sh = 4;
1134 } else { // 4 pulses, 1:sign + 2:index each
1135 n_pulses = 4;
1136 v_mask = 4;
1137 i_mask = 3;
1138 sh = 3;
1139 }
1140
1141 for (n = n_pulses - 1; n >= 0; n--, val >>= sh) {
1142 fcb->y[fcb->n] = (val & v_mask) ? -1.0 : 1.0;
1143 fcb->x[fcb->n] = (val & i_mask) * n_pulses + n +
1144 s->aw_first_pulse_off[block_idx];
1145 while (fcb->x[fcb->n] < 0)
1146 fcb->x[fcb->n] += fcb->pitch_lag;
1147 if (fcb->x[fcb->n] < MAX_FRAMESIZE / 2)
1148 fcb->n++;
1149 }
1150 } else {
1151 int num2 = (val & 0x1FF) >> 1, delta, idx;
1152
1153 if (num2 < 1 * 79) { delta = 1; idx = num2 + 1; }
1154 else if (num2 < 2 * 78) { delta = 3; idx = num2 + 1 - 1 * 77; }
1155 else if (num2 < 3 * 77) { delta = 5; idx = num2 + 1 - 2 * 76; }
1156 else { delta = 7; idx = num2 + 1 - 3 * 75; }
1157 v = (val & 0x200) ? -1.0 : 1.0;
1158
1159 fcb->no_repeat_mask |= 3 << fcb->n;
1160 fcb->x[fcb->n] = idx - delta;
1161 fcb->y[fcb->n] = v;
1162 fcb->x[fcb->n + 1] = idx;
1163 fcb->y[fcb->n + 1] = (val & 1) ? -v : v;
1164 fcb->n += 2;
1165 }
1166}
1167
1168/**
1169 * @}
1170 *
1171 * Generate a random number from frame_cntr and block_idx, which will lief
1172 * in the range [0, 1000 - block_size] (so it can be used as an index in a
1173 * table of size 1000 of which you want to read block_size entries).
1174 *
1175 * @param frame_cntr current frame number
1176 * @param block_num current block index
1177 * @param block_size amount of entries we want to read from a table
1178 * that has 1000 entries
1179 * @return a (non-)random number in the [0, 1000 - block_size] range.
1180 */
1181static int pRNG(int frame_cntr, int block_num, int block_size)
1182{
1183 /* array to simplify the calculation of z:
1184 * y = (x % 9) * 5 + 6;
1185 * z = (49995 * x) / y;
1186 * Since y only has 9 values, we can remove the division by using a
1187 * LUT and using FASTDIV-style divisions. For each of the 9 values
1188 * of y, we can rewrite z as:
1189 * z = x * (49995 / y) + x * ((49995 % y) / y)
1190 * In this table, each col represents one possible value of y, the
1191 * first number is 49995 / y, and the second is the FASTDIV variant
1192 * of 49995 % y / y. */
1193 static const unsigned int div_tbl[9][2] = {
1194 { 8332, 3 * 715827883U }, // y = 6
1195 { 4545, 0 * 390451573U }, // y = 11
1196 { 3124, 11 * 268435456U }, // y = 16
1197 { 2380, 15 * 204522253U }, // y = 21
1198 { 1922, 23 * 165191050U }, // y = 26
1199 { 1612, 23 * 138547333U }, // y = 31
1200 { 1388, 27 * 119304648U }, // y = 36
1201 { 1219, 16 * 104755300U }, // y = 41
1202 { 1086, 39 * 93368855U } // y = 46
1203 };
1204 unsigned int z, y, x = MUL16(block_num, 1877) + frame_cntr;
1205 if (x >= 0xFFFF) x -= 0xFFFF; // max value of x is 8*1877+0xFFFE=0x13AA6,
1206 // so this is effectively a modulo (%)
1207 y = x - 9 * MULH(477218589, x); // x % 9
1208 z = (uint16_t) (x * div_tbl[y][0] + UMULH(x, div_tbl[y][1]));
1209 // z = x * 49995 / (y * 5 + 6)
1210 return z % (1000 - block_size);
1211}
1212
1213/**
1214 * Parse hardcoded signal for a single block.
1215 * @note see #synth_block().
1216 */
1217static void synth_block_hardcoded(WMAVoiceContext *s, GetBitContext *gb,
1218 int block_idx, int size,
1219 const struct frame_type_desc *frame_desc,
1220 float *excitation)
1221{
1222 float gain;
1223 int n, r_idx;
1224
1225 assert(size <= MAX_FRAMESIZE);
1226
1227 /* Set the offset from which we start reading wmavoice_std_codebook */
1228 if (frame_desc->fcb_type == FCB_TYPE_SILENCE) {
1229 r_idx = pRNG(s->frame_cntr, block_idx, size);
1230 gain = s->silence_gain;
1231 } else /* FCB_TYPE_HARDCODED */ {
1232 r_idx = get_bits(gb, 8);
1233 gain = wmavoice_gain_universal[get_bits(gb, 6)];
1234 }
1235
1236 /* Clear gain prediction parameters */
1237 memset(s->gain_pred_err, 0, sizeof(s->gain_pred_err));
1238
1239 /* Apply gain to hardcoded codebook and use that as excitation signal */
1240 for (n = 0; n < size; n++)
1241 excitation[n] = wmavoice_std_codebook[r_idx + n] * gain;
1242}
1243
1244/**
1245 * Parse FCB/ACB signal for a single block.
1246 * @note see #synth_block().
1247 */
1248static void synth_block_fcb_acb(WMAVoiceContext *s, GetBitContext *gb,
1249 int block_idx, int size,
1250 int block_pitch_sh2,
1251 const struct frame_type_desc *frame_desc,
1252 float *excitation)
1253{
1254 static const float gain_coeff[6] = {
1255 0.8169, -0.06545, 0.1726, 0.0185, -0.0359, 0.0458
1256 };
1257 float pulses[MAX_FRAMESIZE / 2], pred_err, acb_gain, fcb_gain;
1258 int n, idx, gain_weight;
1259 AMRFixed fcb;
1260
1261 assert(size <= MAX_FRAMESIZE / 2);
1262 memset(pulses, 0, sizeof(*pulses) * size);
1263
1264 fcb.pitch_lag = block_pitch_sh2 >> 2;
1265 fcb.pitch_fac = 1.0;
1266 fcb.no_repeat_mask = 0;
1267 fcb.n = 0;
1268
1269 /* For the other frame types, this is where we apply the innovation
1270 * (fixed) codebook pulses of the speech signal. */
1271 if (frame_desc->fcb_type == FCB_TYPE_AW_PULSES) {
1272 aw_pulse_set1(s, gb, block_idx, &fcb);
1273 aw_pulse_set2(s, gb, block_idx, &fcb);
1274 } else /* FCB_TYPE_EXC_PULSES */ {
1275 int offset_nbits = 5 - frame_desc->log_n_blocks;
1276
1277 fcb.no_repeat_mask = -1;
1278 /* similar to ff_decode_10_pulses_35bits(), but with single pulses
1279 * (instead of double) for a subset of pulses */
1280 for (n = 0; n < 5; n++) {
1281 float sign;
1282 int pos1, pos2;
1283
1284 sign = get_bits1(gb) ? 1.0 : -1.0;
1285 pos1 = get_bits(gb, offset_nbits);
1286 fcb.x[fcb.n] = n + 5 * pos1;
1287 fcb.y[fcb.n++] = sign;
1288 if (n < frame_desc->dbl_pulses) {
1289 pos2 = get_bits(gb, offset_nbits);
1290 fcb.x[fcb.n] = n + 5 * pos2;
1291 fcb.y[fcb.n++] = (pos1 < pos2) ? -sign : sign;
1292 }
1293 }
1294 }
1295 ff_set_fixed_vector(pulses, &fcb, 1.0, size);
1296
1297 /* Calculate gain for adaptive & fixed codebook signal.
1298 * see ff_amr_set_fixed_gain(). */
1299 idx = get_bits(gb, 7);
1300 fcb_gain = expf(ff_dot_productf(s->gain_pred_err, gain_coeff, 6) -
1301 5.2409161640 + wmavoice_gain_codebook_fcb[idx]);
1302 acb_gain = wmavoice_gain_codebook_acb[idx];
1303 pred_err = av_clipf(wmavoice_gain_codebook_fcb[idx],
1304 -2.9957322736 /* log(0.05) */,
1305 1.6094379124 /* log(5.0) */);
1306
1307 gain_weight = 8 >> frame_desc->log_n_blocks;
1308 memmove(&s->gain_pred_err[gain_weight], s->gain_pred_err,
1309 sizeof(*s->gain_pred_err) * (6 - gain_weight));
1310 for (n = 0; n < gain_weight; n++)
1311 s->gain_pred_err[n] = pred_err;
1312
1313 /* Calculation of adaptive codebook */
1314 if (frame_desc->acb_type == ACB_TYPE_ASYMMETRIC) {
1315 int len;
1316 for (n = 0; n < size; n += len) {
1317 int next_idx_sh16;
1318 int abs_idx = block_idx * size + n;
1319 int pitch_sh16 = (s->last_pitch_val << 16) +
1320 s->pitch_diff_sh16 * abs_idx;
1321 int pitch = (pitch_sh16 + 0x6FFF) >> 16;
1322 int idx_sh16 = ((pitch << 16) - pitch_sh16) * 8 + 0x58000;
1323 idx = idx_sh16 >> 16;
1324 if (s->pitch_diff_sh16) {
1325 if (s->pitch_diff_sh16 > 0) {
1326 next_idx_sh16 = (idx_sh16) &~ 0xFFFF;
1327 } else
1328 next_idx_sh16 = (idx_sh16 + 0x10000) &~ 0xFFFF;
1329 len = av_clip((idx_sh16 - next_idx_sh16) / s->pitch_diff_sh16 / 8,
1330 1, size - n);
1331 } else
1332 len = size;
1333
1334 ff_acelp_interpolatef(&excitation[n], &excitation[n - pitch],
1335 wmavoice_ipol1_coeffs, 17,
1336 idx, 9, len);
1337 }
1338 } else /* ACB_TYPE_HAMMING */ {
1339 int block_pitch = block_pitch_sh2 >> 2;
1340 idx = block_pitch_sh2 & 3;
1341 if (idx) {
1342 ff_acelp_interpolatef(excitation, &excitation[-block_pitch],
1343 wmavoice_ipol2_coeffs, 4,
1344 idx, 8, size);
1345 } else
1346 av_memcpy_backptr((uint8_t *) excitation, sizeof(float) * block_pitch,
1347 sizeof(float) * size);
1348 }
1349
1350 /* Interpolate ACB/FCB and use as excitation signal */
1351 ff_weighted_vector_sumf(excitation, excitation, pulses,
1352 acb_gain, fcb_gain, size);
1353}
1354
1355/**
1356 * Parse data in a single block.
1357 * @note we assume enough bits are available, caller should check.
1358 *
1359 * @param s WMA Voice decoding context private data
1360 * @param gb bit I/O context
1361 * @param block_idx index of the to-be-read block
1362 * @param size amount of samples to be read in this block
1363 * @param block_pitch_sh2 pitch for this block << 2
1364 * @param lsps LSPs for (the end of) this frame
1365 * @param prev_lsps LSPs for the last frame
1366 * @param frame_desc frame type descriptor
1367 * @param excitation target memory for the ACB+FCB interpolated signal
1368 * @param synth target memory for the speech synthesis filter output
1369 * @return 0 on success, <0 on error.
1370 */
1371static void synth_block(WMAVoiceContext *s, GetBitContext *gb,
1372 int block_idx, int size,
1373 int block_pitch_sh2,
1374 const double *lsps, const double *prev_lsps,
1375 const struct frame_type_desc *frame_desc,
1376 float *excitation, float *synth)
1377{
1378 double i_lsps[MAX_LSPS];
1379 float lpcs[MAX_LSPS];
1380 float fac;
1381 int n;
1382
1383 if (frame_desc->acb_type == ACB_TYPE_NONE)
1384 synth_block_hardcoded(s, gb, block_idx, size, frame_desc, excitation);
1385 else
1386 synth_block_fcb_acb(s, gb, block_idx, size, block_pitch_sh2,
1387 frame_desc, excitation);
1388
1389 /* convert interpolated LSPs to LPCs */
1390 fac = (block_idx + 0.5) / frame_desc->n_blocks;
1391 for (n = 0; n < s->lsps; n++) // LSF -> LSP
1392 i_lsps[n] = cos(prev_lsps[n] + fac * (lsps[n] - prev_lsps[n]));
1393 ff_acelp_lspd2lpc(i_lsps, lpcs, s->lsps >> 1);
1394
1395 /* Speech synthesis */
1396 ff_celp_lp_synthesis_filterf(synth, lpcs, excitation, size, s->lsps);
1397}
1398
1399/**
1400 * Synthesize output samples for a single frame.
1401 * @note we assume enough bits are available, caller should check.
1402 *
1403 * @param ctx WMA Voice decoder context
1404 * @param gb bit I/O context (s->gb or one for cross-packet superframes)
1405 * @param frame_idx Frame number within superframe [0-2]
1406 * @param samples pointer to output sample buffer, has space for at least 160
1407 * samples
1408 * @param lsps LSP array
1409 * @param prev_lsps array of previous frame's LSPs
1410 * @param excitation target buffer for excitation signal
1411 * @param synth target buffer for synthesized speech data
1412 * @return 0 on success, <0 on error.
1413 */
1414static int synth_frame(AVCodecContext *ctx, GetBitContext *gb, int frame_idx,
1415 float *samples,
1416 const double *lsps, const double *prev_lsps,
1417 float *excitation, float *synth)
1418{
1419 WMAVoiceContext *s = ctx->priv_data;
1420 int n, n_blocks_x2, log_n_blocks_x2, cur_pitch_val;
1421 int pitch[MAX_BLOCKS], last_block_pitch;
1422
1423 /* Parse frame type ("frame header"), see frame_descs */
1424 int bd_idx = s->vbm_tree[get_vlc2(gb, frame_type_vlc.table, 6, 3)],
1425 block_nsamples = MAX_FRAMESIZE / frame_descs[bd_idx].n_blocks;
1426
1427 if (bd_idx < 0) {
1428 av_log(ctx, AV_LOG_ERROR,
1429 "Invalid frame type VLC code, skipping\n");
1430 return -1;
1431 }
1432
1433 /* Pitch calculation for ACB_TYPE_ASYMMETRIC ("pitch-per-frame") */
1434 if (frame_descs[bd_idx].acb_type == ACB_TYPE_ASYMMETRIC) {
1435 /* Pitch is provided per frame, which is interpreted as the pitch of
1436 * the last sample of the last block of this frame. We can interpolate
1437 * the pitch of other blocks (and even pitch-per-sample) by gradually
1438 * incrementing/decrementing prev_frame_pitch to cur_pitch_val. */
1439 n_blocks_x2 = frame_descs[bd_idx].n_blocks << 1;
1440 log_n_blocks_x2 = frame_descs[bd_idx].log_n_blocks + 1;
1441 cur_pitch_val = s->min_pitch_val + get_bits(gb, s->pitch_nbits);
1442 cur_pitch_val = FFMIN(cur_pitch_val, s->max_pitch_val - 1);
1443 if (s->last_acb_type == ACB_TYPE_NONE ||
1444 20 * abs(cur_pitch_val - s->last_pitch_val) >
1445 (cur_pitch_val + s->last_pitch_val))
1446 s->last_pitch_val = cur_pitch_val;
1447
1448 /* pitch per block */
1449 for (n = 0; n < frame_descs[bd_idx].n_blocks; n++) {
1450 int fac = n * 2 + 1;
1451
1452 pitch[n] = (MUL16(fac, cur_pitch_val) +
1453 MUL16((n_blocks_x2 - fac), s->last_pitch_val) +
1454 frame_descs[bd_idx].n_blocks) >> log_n_blocks_x2;
1455 }
1456
1457 /* "pitch-diff-per-sample" for calculation of pitch per sample */
1458 s->pitch_diff_sh16 =
1459 ((cur_pitch_val - s->last_pitch_val) << 16) / MAX_FRAMESIZE;
1460 }
1461
1462 /* Global gain (if silence) and pitch-adaptive window coordinates */
1463 switch (frame_descs[bd_idx].fcb_type) {
1464 case FCB_TYPE_SILENCE:
1465 s->silence_gain = wmavoice_gain_silence[get_bits(gb, 8)];
1466 break;
1467 case FCB_TYPE_AW_PULSES:
1468 aw_parse_coords(s, gb, pitch);
1469 break;
1470 }
1471
1472 for (n = 0; n < frame_descs[bd_idx].n_blocks; n++) {
1473 int bl_pitch_sh2;
1474
1475 /* Pitch calculation for ACB_TYPE_HAMMING ("pitch-per-block") */
1476 switch (frame_descs[bd_idx].acb_type) {
1477 case ACB_TYPE_HAMMING: {
1478 /* Pitch is given per block. Per-block pitches are encoded as an
1479 * absolute value for the first block, and then delta values
1480 * relative to this value) for all subsequent blocks. The scale of
1481 * this pitch value is semi-logaritmic compared to its use in the
1482 * decoder, so we convert it to normal scale also. */
1483 int block_pitch,
1484 t1 = (s->block_conv_table[1] - s->block_conv_table[0]) << 2,
1485 t2 = (s->block_conv_table[2] - s->block_conv_table[1]) << 1,
1486 t3 = s->block_conv_table[3] - s->block_conv_table[2] + 1;
1487
1488 if (n == 0) {
1489 block_pitch = get_bits(gb, s->block_pitch_nbits);
1490 } else
1491 block_pitch = last_block_pitch - s->block_delta_pitch_hrange +
1492 get_bits(gb, s->block_delta_pitch_nbits);
1493 /* Convert last_ so that any next delta is within _range */
1494 last_block_pitch = av_clip(block_pitch,
1495 s->block_delta_pitch_hrange,
1496 s->block_pitch_range -
1497 s->block_delta_pitch_hrange);
1498
1499 /* Convert semi-log-style scale back to normal scale */
1500 if (block_pitch < t1) {
1501 bl_pitch_sh2 = (s->block_conv_table[0] << 2) + block_pitch;
1502 } else {
1503 block_pitch -= t1;
1504 if (block_pitch < t2) {
1505 bl_pitch_sh2 =
1506 (s->block_conv_table[1] << 2) + (block_pitch << 1);
1507 } else {
1508 block_pitch -= t2;
1509 if (block_pitch < t3) {
1510 bl_pitch_sh2 =
1511 (s->block_conv_table[2] + block_pitch) << 2;
1512 } else
1513 bl_pitch_sh2 = s->block_conv_table[3] << 2;
1514 }
1515 }
1516 pitch[n] = bl_pitch_sh2 >> 2;
1517 break;
1518 }
1519
1520 case ACB_TYPE_ASYMMETRIC: {
1521 bl_pitch_sh2 = pitch[n] << 2;
1522 break;
1523 }
1524
1525 default: // ACB_TYPE_NONE has no pitch
1526 bl_pitch_sh2 = 0;
1527 break;
1528 }
1529
1530 synth_block(s, gb, n, block_nsamples, bl_pitch_sh2,
1531 lsps, prev_lsps, &frame_descs[bd_idx],
1532 &excitation[n * block_nsamples],
1533 &synth[n * block_nsamples]);
1534 }
1535
1536 /* Averaging projection filter, if applicable. Else, just copy samples
1537 * from synthesis buffer */
1538 if (s->do_apf) {
1539 double i_lsps[MAX_LSPS];
1540 float lpcs[MAX_LSPS];
1541
1542 for (n = 0; n < s->lsps; n++) // LSF -> LSP
1543 i_lsps[n] = cos(0.5 * (prev_lsps[n] + lsps[n]));
1544 ff_acelp_lspd2lpc(i_lsps, lpcs, s->lsps >> 1);
1545 postfilter(s, synth, samples, 80, lpcs,
1546 &s->zero_exc_pf[s->history_nsamples + MAX_FRAMESIZE * frame_idx],
1547 frame_descs[bd_idx].fcb_type, pitch[0]);
1548
1549 for (n = 0; n < s->lsps; n++) // LSF -> LSP
1550 i_lsps[n] = cos(lsps[n]);
1551 ff_acelp_lspd2lpc(i_lsps, lpcs, s->lsps >> 1);
1552 postfilter(s, &synth[80], &samples[80], 80, lpcs,
1553 &s->zero_exc_pf[s->history_nsamples + MAX_FRAMESIZE * frame_idx + 80],
1554 frame_descs[bd_idx].fcb_type, pitch[0]);
1555 } else
1556 memcpy(samples, synth, 160 * sizeof(synth[0]));
1557
1558 /* Cache values for next frame */
1559 s->frame_cntr++;
1560 if (s->frame_cntr >= 0xFFFF) s->frame_cntr -= 0xFFFF; // i.e. modulo (%)
1561 s->last_acb_type = frame_descs[bd_idx].acb_type;
1562 switch (frame_descs[bd_idx].acb_type) {
1563 case ACB_TYPE_NONE:
1564 s->last_pitch_val = 0;
1565 break;
1566 case ACB_TYPE_ASYMMETRIC:
1567 s->last_pitch_val = cur_pitch_val;
1568 break;
1569 case ACB_TYPE_HAMMING:
1570 s->last_pitch_val = pitch[frame_descs[bd_idx].n_blocks - 1];
1571 break;
1572 }
1573
1574 return 0;
1575}
1576
1577/**
1578 * Ensure minimum value for first item, maximum value for last value,
1579 * proper spacing between each value and proper ordering.
1580 *
1581 * @param lsps array of LSPs
1582 * @param num size of LSP array
1583 *
1584 * @note basically a double version of #ff_acelp_reorder_lsf(), might be
1585 * useful to put in a generic location later on. Parts are also
1586 * present in #ff_set_min_dist_lsf() + #ff_sort_nearly_sorted_floats(),
1587 * which is in float.
1588 */
1589static void stabilize_lsps(double *lsps, int num)
1590{
1591 int n, m, l;
1592
1593 /* set minimum value for first, maximum value for last and minimum
1594 * spacing between LSF values.
1595 * Very similar to ff_set_min_dist_lsf(), but in double. */
1596 lsps[0] = FFMAX(lsps[0], 0.0015 * M_PI);
1597 for (n = 1; n < num; n++)
1598 lsps[n] = FFMAX(lsps[n], lsps[n - 1] + 0.0125 * M_PI);
1599 lsps[num - 1] = FFMIN(lsps[num - 1], 0.9985 * M_PI);
1600
1601 /* reorder (looks like one-time / non-recursed bubblesort).
1602 * Very similar to ff_sort_nearly_sorted_floats(), but in double. */
1603 for (n = 1; n < num; n++) {
1604 if (lsps[n] < lsps[n - 1]) {
1605 for (m = 1; m < num; m++) {
1606 double tmp = lsps[m];
1607 for (l = m - 1; l >= 0; l--) {
1608 if (lsps[l] <= tmp) break;
1609 lsps[l + 1] = lsps[l];
1610 }
1611 lsps[l + 1] = tmp;
1612 }
1613 break;
1614 }
1615 }
1616}
1617
1618/**
1619 * Test if there's enough bits to read 1 superframe.
1620 *
1621 * @param orig_gb bit I/O context used for reading. This function
1622 * does not modify the state of the bitreader; it
1623 * only uses it to copy the current stream position
1624 * @param s WMA Voice decoding context private data
1625 * @return -1 if unsupported, 1 on not enough bits or 0 if OK.
1626 */
1627static int check_bits_for_superframe(GetBitContext *orig_gb,
1628 WMAVoiceContext *s)
1629{
1630 GetBitContext s_gb, *gb = &s_gb;
1631 int n, need_bits, bd_idx;
1632 const struct frame_type_desc *frame_desc;
1633
1634 /* initialize a copy */
1635 init_get_bits(gb, orig_gb->buffer, orig_gb->size_in_bits);
1636 skip_bits_long(gb, get_bits_count(orig_gb));
1637 assert(get_bits_left(gb) == get_bits_left(orig_gb));
1638
1639 /* superframe header */
1640 if (get_bits_left(gb) < 14)
1641 return 1;
1642 if (!get_bits1(gb))
1643 return -1; // WMAPro-in-WMAVoice superframe
1644 if (get_bits1(gb)) skip_bits(gb, 12); // number of samples in superframe
1645 if (s->has_residual_lsps) { // residual LSPs (for all frames)
1646 if (get_bits_left(gb) < s->sframe_lsp_bitsize)
1647 return 1;
1648 skip_bits_long(gb, s->sframe_lsp_bitsize);
1649 }
1650
1651 /* frames */
1652 for (n = 0; n < MAX_FRAMES; n++) {
1653 int aw_idx_is_ext = 0;
1654
1655 if (!s->has_residual_lsps) { // independent LSPs (per-frame)
1656 if (get_bits_left(gb) < s->frame_lsp_bitsize) return 1;
1657 skip_bits_long(gb, s->frame_lsp_bitsize);
1658 }
1659 bd_idx = s->vbm_tree[get_vlc2(gb, frame_type_vlc.table, 6, 3)];
1660 if (bd_idx < 0)
1661 return -1; // invalid frame type VLC code
1662 frame_desc = &frame_descs[bd_idx];
1663 if (frame_desc->acb_type == ACB_TYPE_ASYMMETRIC) {
1664 if (get_bits_left(gb) < s->pitch_nbits)
1665 return 1;
1666 skip_bits_long(gb, s->pitch_nbits);
1667 }
1668 if (frame_desc->fcb_type == FCB_TYPE_SILENCE) {
1669 skip_bits(gb, 8);
1670 } else if (frame_desc->fcb_type == FCB_TYPE_AW_PULSES) {
1671 int tmp = get_bits(gb, 6);
1672 if (tmp >= 0x36) {
1673 skip_bits(gb, 2);
1674 aw_idx_is_ext = 1;
1675 }
1676 }
1677
1678 /* blocks */
1679 if (frame_desc->acb_type == ACB_TYPE_HAMMING) {
1680 need_bits = s->block_pitch_nbits +
1681 (frame_desc->n_blocks - 1) * s->block_delta_pitch_nbits;
1682 } else if (frame_desc->fcb_type == FCB_TYPE_AW_PULSES) {
1683 need_bits = 2 * !aw_idx_is_ext;
1684 } else
1685 need_bits = 0;
1686 need_bits += frame_desc->frame_size;
1687 if (get_bits_left(gb) < need_bits)
1688 return 1;
1689 skip_bits_long(gb, need_bits);
1690 }
1691
1692 return 0;
1693}
1694
1695/**
1696 * Synthesize output samples for a single superframe. If we have any data
1697 * cached in s->sframe_cache, that will be used instead of whatever is loaded
1698 * in s->gb.
1699 *
1700 * WMA Voice superframes contain 3 frames, each containing 160 audio samples,
1701 * to give a total of 480 samples per frame. See #synth_frame() for frame
1702 * parsing. In addition to 3 frames, superframes can also contain the LSPs
1703 * (if these are globally specified for all frames (residually); they can
1704 * also be specified individually per-frame. See the s->has_residual_lsps
1705 * option), and can specify the number of samples encoded in this superframe
1706 * (if less than 480), usually used to prevent blanks at track boundaries.
1707 *
1708 * @param ctx WMA Voice decoder context
1709 * @param samples pointer to output buffer for voice samples
1710 * @param data_size pointer containing the size of #samples on input, and the
1711 * amount of #samples filled on output
1712 * @return 0 on success, <0 on error or 1 if there was not enough data to
1713 * fully parse the superframe
1714 */
1715static int synth_superframe(AVCodecContext *ctx,
1716 float *samples, int *data_size)
1717{
1718 WMAVoiceContext *s = ctx->priv_data;
1719 GetBitContext *gb = &s->gb, s_gb;
1720 int n, res, n_samples = 480;
1721 double lsps[MAX_FRAMES][MAX_LSPS];
1722 const double *mean_lsf = s->lsps == 16 ?
1723 wmavoice_mean_lsf16[s->lsp_def_mode] : wmavoice_mean_lsf10[s->lsp_def_mode];
1724 float excitation[MAX_SIGNAL_HISTORY + MAX_SFRAMESIZE + 12];
1725 float synth[MAX_LSPS + MAX_SFRAMESIZE];
1726
1727 memcpy(synth, s->synth_history,
1728 s->lsps * sizeof(*synth));
1729 memcpy(excitation, s->excitation_history,
1730 s->history_nsamples * sizeof(*excitation));
1731
1732 if (s->sframe_cache_size > 0) {
1733 gb = &s_gb;
1734 init_get_bits(gb, s->sframe_cache, s->sframe_cache_size);
1735 s->sframe_cache_size = 0;
1736 }
1737
1738 if ((res = check_bits_for_superframe(gb, s)) == 1) return 1;
1739
1740 /* First bit is speech/music bit, it differentiates between WMAVoice
1741 * speech samples (the actual codec) and WMAVoice music samples, which
1742 * are really WMAPro-in-WMAVoice-superframes. I've never seen those in
1743 * the wild yet. */
1744 if (!get_bits1(gb)) {
1745 av_log_missing_feature(ctx, "WMAPro-in-WMAVoice support", 1);
1746 return -1;
1747 }
1748
1749 /* (optional) nr. of samples in superframe; always <= 480 and >= 0 */
1750 if (get_bits1(gb)) {
1751 if ((n_samples = get_bits(gb, 12)) > 480) {
1752 av_log(ctx, AV_LOG_ERROR,
1753 "Superframe encodes >480 samples (%d), not allowed\n",
1754 n_samples);
1755 return -1;
1756 }
1757 }
1758 /* Parse LSPs, if global for the superframe (can also be per-frame). */
1759 if (s->has_residual_lsps) {
1760 double prev_lsps[MAX_LSPS], a1[MAX_LSPS * 2], a2[MAX_LSPS * 2];
1761
1762 for (n = 0; n < s->lsps; n++)
1763 prev_lsps[n] = s->prev_lsps[n] - mean_lsf[n];
1764
1765 if (s->lsps == 10) {
1766 dequant_lsp10r(gb, lsps[2], prev_lsps, a1, a2, s->lsp_q_mode);
1767 } else /* s->lsps == 16 */
1768 dequant_lsp16r(gb, lsps[2], prev_lsps, a1, a2, s->lsp_q_mode);
1769
1770 for (n = 0; n < s->lsps; n++) {
1771 lsps[0][n] = mean_lsf[n] + (a1[n] - a2[n * 2]);
1772 lsps[1][n] = mean_lsf[n] + (a1[s->lsps + n] - a2[n * 2 + 1]);
1773 lsps[2][n] += mean_lsf[n];
1774 }
1775 for (n = 0; n < 3; n++)
1776 stabilize_lsps(lsps[n], s->lsps);
1777 }
1778
1779 /* Parse frames, optionally preceeded by per-frame (independent) LSPs. */
1780 for (n = 0; n < 3; n++) {
1781 if (!s->has_residual_lsps) {
1782 int m;
1783
1784 if (s->lsps == 10) {
1785 dequant_lsp10i(gb, lsps[n]);
1786 } else /* s->lsps == 16 */
1787 dequant_lsp16i(gb, lsps[n]);
1788
1789 for (m = 0; m < s->lsps; m++)
1790 lsps[n][m] += mean_lsf[m];
1791 stabilize_lsps(lsps[n], s->lsps);
1792 }
1793
1794 if ((res = synth_frame(ctx, gb, n,
1795 &samples[n * MAX_FRAMESIZE],
1796 lsps[n], n == 0 ? s->prev_lsps : lsps[n - 1],
1797 &excitation[s->history_nsamples + n * MAX_FRAMESIZE],
1798 &synth[s->lsps + n * MAX_FRAMESIZE])))
1799 return res;
1800 }
1801
1802 /* Statistics? FIXME - we don't check for length, a slight overrun
1803 * will be caught by internal buffer padding, and anything else
1804 * will be skipped, not read. */
1805 if (get_bits1(gb)) {
1806 res = get_bits(gb, 4);
1807 skip_bits(gb, 10 * (res + 1));
1808 }
1809
1810 /* Specify nr. of output samples */
1811 *data_size = n_samples * sizeof(float);
1812
1813 /* Update history */
1814 memcpy(s->prev_lsps, lsps[2],
1815 s->lsps * sizeof(*s->prev_lsps));
1816 memcpy(s->synth_history, &synth[MAX_SFRAMESIZE],
1817 s->lsps * sizeof(*synth));
1818 memcpy(s->excitation_history, &excitation[MAX_SFRAMESIZE],
1819 s->history_nsamples * sizeof(*excitation));
1820 if (s->do_apf)
1821 memmove(s->zero_exc_pf, &s->zero_exc_pf[MAX_SFRAMESIZE],
1822 s->history_nsamples * sizeof(*s->zero_exc_pf));
1823
1824 return 0;
1825}
1826
1827/**
1828 * Parse the packet header at the start of each packet (input data to this
1829 * decoder).
1830 *
1831 * @param s WMA Voice decoding context private data
1832 * @return 1 if not enough bits were available, or 0 on success.
1833 */
1834static int parse_packet_header(WMAVoiceContext *s)
1835{
1836 GetBitContext *gb = &s->gb;
1837 unsigned int res;
1838
1839 if (get_bits_left(gb) < 11)
1840 return 1;
1841 skip_bits(gb, 4); // packet sequence number
1842 s->has_residual_lsps = get_bits1(gb);
1843 do {
1844 res = get_bits(gb, 6); // number of superframes per packet
1845 // (minus first one if there is spillover)
1846 if (get_bits_left(gb) < 6 * (res == 0x3F) + s->spillover_bitsize)
1847 return 1;
1848 } while (res == 0x3F);
1849 s->spillover_nbits = get_bits(gb, s->spillover_bitsize);
1850
1851 return 0;
1852}
1853
1854/**
1855 * Copy (unaligned) bits from gb/data/size to pb.
1856 *
1857 * @param pb target buffer to copy bits into
1858 * @param data source buffer to copy bits from
1859 * @param size size of the source data, in bytes
1860 * @param gb bit I/O context specifying the current position in the source.
1861 * data. This function might use this to align the bit position to
1862 * a whole-byte boundary before calling #ff_copy_bits() on aligned
1863 * source data
1864 * @param nbits the amount of bits to copy from source to target
1865 *
1866 * @note after calling this function, the current position in the input bit
1867 * I/O context is undefined.
1868 */
1869static void copy_bits(PutBitContext *pb,
1870 const uint8_t *data, int size,
1871 GetBitContext *gb, int nbits)
1872{
1873 int rmn_bytes, rmn_bits;
1874
1875 rmn_bits = rmn_bytes = get_bits_left(gb);
1876 if (rmn_bits < nbits)
1877 return;
1878 rmn_bits &= 7; rmn_bytes >>= 3;
1879 if ((rmn_bits = FFMIN(rmn_bits, nbits)) > 0)
1880 put_bits(pb, rmn_bits, get_bits(gb, rmn_bits));
1881 ff_copy_bits(pb, data + size - rmn_bytes,
1882 FFMIN(nbits - rmn_bits, rmn_bytes << 3));
1883}
1884
1885/**
1886 * Packet decoding: a packet is anything that the (ASF) demuxer contains,
1887 * and we expect that the demuxer / application provides it to us as such
1888 * (else you'll probably get garbage as output). Every packet has a size of
1889 * ctx->block_align bytes, starts with a packet header (see
1890 * #parse_packet_header()), and then a series of superframes. Superframe
1891 * boundaries may exceed packets, i.e. superframes can split data over
1892 * multiple (two) packets.
1893 *
1894 * For more information about frames, see #synth_superframe().
1895 */
1896static int wmavoice_decode_packet(AVCodecContext *ctx, void *data,
1897 int *data_size, AVPacket *avpkt)
1898{
1899 WMAVoiceContext *s = ctx->priv_data;
1900 GetBitContext *gb = &s->gb;
1901 int size, res, pos;
1902
1903 if (*data_size < 480 * sizeof(float)) {
1904 av_log(ctx, AV_LOG_ERROR,
1905 "Output buffer too small (%d given - %zu needed)\n",
1906 *data_size, 480 * sizeof(float));
1907 return -1;
1908 }
1909 *data_size = 0;
1910
1911 /* Packets are sometimes a multiple of ctx->block_align, with a packet
1912 * header at each ctx->block_align bytes. However, FFmpeg's ASF demuxer
1913 * feeds us ASF packets, which may concatenate multiple "codec" packets
1914 * in a single "muxer" packet, so we artificially emulate that by
1915 * capping the packet size at ctx->block_align. */
1916 for (size = avpkt->size; size > ctx->block_align; size -= ctx->block_align);
1917 if (!size)
1918 return 0;
1919 init_get_bits(&s->gb, avpkt->data, size << 3);
1920
1921 /* size == ctx->block_align is used to indicate whether we are dealing with
1922 * a new packet or a packet of which we already read the packet header
1923 * previously. */
1924 if (size == ctx->block_align) { // new packet header
1925 if ((res = parse_packet_header(s)) < 0)
1926 return res;
1927
1928 /* If the packet header specifies a s->spillover_nbits, then we want
1929 * to push out all data of the previous packet (+ spillover) before
1930 * continuing to parse new superframes in the current packet. */
1931 if (s->spillover_nbits > 0) {
1932 if (s->sframe_cache_size > 0) {
1933 int cnt = get_bits_count(gb);
1934 copy_bits(&s->pb, avpkt->data, size, gb, s->spillover_nbits);
1935 flush_put_bits(&s->pb);
1936 s->sframe_cache_size += s->spillover_nbits;
1937 if ((res = synth_superframe(ctx, data, data_size)) == 0 &&
1938 *data_size > 0) {
1939 cnt += s->spillover_nbits;
1940 s->skip_bits_next = cnt & 7;
1941 return cnt >> 3;
1942 } else
1943 skip_bits_long (gb, s->spillover_nbits - cnt +
1944 get_bits_count(gb)); // resync
1945 } else
1946 skip_bits_long(gb, s->spillover_nbits); // resync
1947 }
1948 } else if (s->skip_bits_next)
1949 skip_bits(gb, s->skip_bits_next);
1950
1951 /* Try parsing superframes in current packet */
1952 s->sframe_cache_size = 0;
1953 s->skip_bits_next = 0;
1954 pos = get_bits_left(gb);
1955 if ((res = synth_superframe(ctx, data, data_size)) < 0) {
1956 return res;
1957 } else if (*data_size > 0) {
1958 int cnt = get_bits_count(gb);
1959 s->skip_bits_next = cnt & 7;
1960 return cnt >> 3;
1961 } else if ((s->sframe_cache_size = pos) > 0) {
1962 /* rewind bit reader to start of last (incomplete) superframe... */
1963 init_get_bits(gb, avpkt->data, size << 3);
1964 skip_bits_long(gb, (size << 3) - pos);
1965 assert(get_bits_left(gb) == pos);
1966
1967 /* ...and cache it for spillover in next packet */
1968 init_put_bits(&s->pb, s->sframe_cache, SFRAME_CACHE_MAXSIZE);
1969 copy_bits(&s->pb, avpkt->data, size, gb, s->sframe_cache_size);
1970 // FIXME bad - just copy bytes as whole and add use the
1971 // skip_bits_next field
1972 }
1973
1974 return size;
1975}
1976
1977static av_cold int wmavoice_decode_end(AVCodecContext *ctx)
1978{
1979 WMAVoiceContext *s = ctx->priv_data;
1980
1981 if (s->do_apf) {
1982 ff_rdft_end(&s->rdft);
1983 ff_rdft_end(&s->irdft);
1984 ff_dct_end(&s->dct);
1985 ff_dct_end(&s->dst);
1986 }
1987
1988 return 0;
1989}
1990
1991static av_cold void wmavoice_flush(AVCodecContext *ctx)
1992{
1993 WMAVoiceContext *s = ctx->priv_data;
1994 int n;
1995
1996 s->postfilter_agc = 0;
1997 s->sframe_cache_size = 0;
1998 s->skip_bits_next = 0;
1999 for (n = 0; n < s->lsps; n++)
2000 s->prev_lsps[n] = M_PI * (n + 1.0) / (s->lsps + 1.0);
2001 memset(s->excitation_history, 0,
2002 sizeof(*s->excitation_history) * MAX_SIGNAL_HISTORY);
2003 memset(s->synth_history, 0,
2004 sizeof(*s->synth_history) * MAX_LSPS);
2005 memset(s->gain_pred_err, 0,
2006 sizeof(s->gain_pred_err));
2007
2008 if (s->do_apf) {
2009 memset(&s->synth_filter_out_buf[MAX_LSPS_ALIGN16 - s->lsps], 0,
2010 sizeof(*s->synth_filter_out_buf) * s->lsps);
2011 memset(s->dcf_mem, 0,
2012 sizeof(*s->dcf_mem) * 2);
2013 memset(s->zero_exc_pf, 0,
2014 sizeof(*s->zero_exc_pf) * s->history_nsamples);
2015 memset(s->denoise_filter_cache, 0, sizeof(s->denoise_filter_cache));
2016 }
2017}
2018
2019AVCodec wmavoice_decoder = {
2020 "wmavoice",
2021 AVMEDIA_TYPE_AUDIO,
2022 CODEC_ID_WMAVOICE,
2023 sizeof(WMAVoiceContext),
2024 wmavoice_decode_init,
2025 NULL,
2026 wmavoice_decode_end,
2027 wmavoice_decode_packet,
2028 CODEC_CAP_SUBFRAMES,
2029 .flush = wmavoice_flush,
2030 .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio Voice"),
2031};
diff --git a/apps/codecs/libwmavoice/wmavoice_data.h b/apps/codecs/libwmavoice/wmavoice_data.h
new file mode 100644
index 0000000000..cbf65b043e
--- /dev/null
+++ b/apps/codecs/libwmavoice/wmavoice_data.h
@@ -0,0 +1,3259 @@
1/*
2 * Windows Media Voice (WMAVoice) tables.
3 * Copyright (c) 2009 Ronald S. Bultje
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/**
23 * @file
24 * @brief Windows Media Voice (WMAVoice) tables
25 * @author Ronald S. Bultje <rsbultje@gmail.com>
26 */
27
28#ifndef AVCODEC_WMAVOICE_DATA_H
29#define AVCODEC_WMAVOICE_DATA_H
30
31#include <stdint.h>
32
33static const uint8_t wmavoice_dq_lsp10i[0xf00] = {
34 125, 109, 84, 55, 34, 51, 109, 112, 118, 132,
35 122, 102, 78, 80, 132, 119, 132, 132, 125, 131,
36 109, 91, 131, 131, 136, 136, 137, 137, 140, 145,
37 140, 143, 117, 136, 122, 106, 109, 91, 115, 119,
38 133, 117, 103, 80, 55, 117, 123, 102, 93, 80,
39 139, 116, 70, 39, 95, 89, 103, 113, 112, 122,
40 135, 244, 229, 215, 199, 181, 163, 150, 146, 144,
41 143, 173, 171, 154, 155, 154, 151, 148, 145, 143,
42 132, 138, 116, 85, 117, 94, 108, 117, 107, 116,
43 132, 118, 123, 119, 88, 67, 49, 95, 84, 95,
44 121, 103, 74, 70, 179, 164, 141, 126, 107, 112,
45 119, 95, 103, 149, 139, 148, 144, 147, 148, 141,
46 151, 133, 142, 129, 111, 131, 108, 128, 122, 108,
47 121, 96, 115, 138, 116, 93, 105, 115, 115, 123,
48 129, 106, 136, 180, 147, 130, 108, 141, 131, 118,
49 136, 155, 176, 156, 135, 129, 140, 146, 142, 134,
50 141, 130, 109, 80, 52, 38, 18, 47, 118, 134,
51 155, 141, 100, 78, 72, 89, 79, 96, 92, 98,
52 133, 111, 83, 91, 72, 58, 105, 115, 112, 120,
53 145, 127, 135, 113, 113, 105, 105, 85, 69, 61,
54 115, 96, 116, 145, 159, 170, 175, 175, 168, 155,
55 140, 120, 84, 52, 80, 145, 125, 127, 116, 126,
56 128, 108, 101, 198, 227, 200, 178, 159, 147, 148,
57 121, 88, 46, 109, 124, 126, 126, 137, 147, 147,
58 129, 107, 164, 148, 127, 117, 134, 120, 111, 116,
59 120, 103, 98, 73, 66, 61, 70, 115, 116, 125,
60 126, 100, 77, 188, 162, 140, 114, 128, 139, 123,
61 145, 165, 164, 134, 109, 100, 108, 118, 127, 130,
62 156, 182, 190, 173, 167, 165, 162, 157, 152, 147,
63 150, 164, 179, 183, 173, 155, 140, 136, 134, 135,
64 122, 92, 69, 140, 132, 118, 108, 128, 138, 132,
65 123, 127, 148, 137, 150, 149, 139, 127, 124, 130,
66 136, 138, 112, 70, 41, 37, 132, 140, 129, 125,
67 130, 111, 78, 33, 51, 161, 141, 136, 120, 122,
68 126, 110, 87, 106, 85, 68, 48, 81, 112, 113,
69 135, 125, 98, 85, 102, 80, 100, 87, 86, 116,
70 142, 133, 110, 66, 48, 152, 139, 135, 136, 123,
71 128, 116, 89, 102, 128, 99, 83, 61, 105, 124,
72 120, 94, 73, 83, 78, 100, 122, 124, 128, 132,
73 144, 137, 116, 102, 75, 144, 136, 127, 140, 127,
74 154, 144, 118, 99, 90, 90, 89, 75, 68, 83,
75 123, 103, 89, 198, 180, 154, 138, 122, 136, 120,
76 138, 118, 121, 136, 110, 105, 85, 111, 101, 104,
77 121, 126, 139, 115, 99, 101, 107, 110, 123, 126,
78 127, 115, 88, 109, 164, 134, 138, 138, 120, 121,
79 130, 202, 195, 202, 199, 201, 181, 164, 159, 148,
80 120, 116, 194, 199, 186, 171, 154, 142, 137, 133,
81 137, 129, 112, 149, 134, 112, 149, 138, 120, 134,
82 119, 102, 107, 83, 79, 114, 119, 127, 128, 128,
83 144, 148, 165, 155, 161, 150, 135, 122, 116, 115,
84 120, 99, 80, 120, 123, 124, 111, 89, 70, 108,
85 118, 95, 66, 53, 105, 126, 125, 105, 83, 111,
86 129, 197, 191, 197, 206, 213, 216, 208, 196, 169,
87 133, 109, 127, 164, 134, 121, 99, 92, 82, 71,
88 131, 121, 93, 91, 136, 105, 115, 140, 120, 110,
89 150, 164, 139, 108, 87, 81, 93, 92, 104, 116,
90 133, 114, 125, 126, 111, 136, 110, 156, 147, 133,
91 113, 94, 118, 120, 115, 125, 124, 126, 127, 134,
92 116, 131, 161, 158, 166, 157, 150, 150, 144, 141,
93 125, 185, 169, 142, 140, 143, 139, 131, 134, 138,
94 179, 188, 170, 150, 134, 140, 144, 133, 127, 127,
95 150, 177, 204, 184, 192, 194, 190, 193, 177, 158,
96 114, 113, 138, 116, 137, 135, 132, 131, 127, 134,
97 120, 147, 163, 135, 133, 137, 136, 136, 133, 135,
98 137, 120, 95, 73, 46, 48, 111, 97, 97, 123,
99 139, 130, 109, 76, 52, 72, 61, 61, 125, 127,
100 132, 119, 119, 90, 66, 41, 64, 156, 143, 129,
101 131, 106, 58, 25, 99, 115, 122, 136, 129, 132,
102 134, 123, 97, 53, 27, 114, 125, 114, 120, 123,
103 122, 107, 93, 57, 47, 133, 128, 138, 141, 131,
104 145, 132, 122, 110, 79, 57, 30, 73, 153, 144,
105 150, 132, 85, 59, 133, 125, 130, 115, 100, 96,
106 148, 127, 111, 86, 61, 38, 110, 121, 108, 99,
107 157, 143, 105, 77, 116, 118, 115, 131, 122, 122,
108 133, 119, 134, 108, 86, 61, 129, 165, 143, 127,
109 125, 105, 89, 111, 97, 85, 113, 99, 98, 117,
110 149, 131, 101, 106, 88, 95, 79, 119, 123, 120,
111 125, 109, 81, 100, 201, 183, 156, 138, 115, 116,
112 141, 119, 129, 105, 76, 60, 110, 99, 92, 82,
113 150, 156, 129, 95, 69, 115, 115, 113, 134, 125,
114 118, 97, 67, 96, 203, 197, 171, 151, 133, 125,
115 143, 131, 120, 134, 105, 80, 51, 60, 139, 134,
116 129, 160, 223, 219, 219, 212, 197, 173, 157, 146,
117 132, 112, 164, 144, 119, 102, 92, 76, 73, 94,
118 132, 112, 124, 114, 93, 92, 83, 73, 69, 99,
119 129, 103, 188, 163, 142, 132, 127, 101, 82, 59,
120 140, 141, 111, 74, 46, 105, 113, 99, 127, 122,
121 125, 94, 63, 112, 116, 101, 81, 120, 136, 134,
122 133, 190, 224, 193, 179, 158, 146, 143, 140, 136,
123 152, 161, 132, 120, 112, 94, 114, 102, 92, 116,
124 129, 194, 196, 202, 211, 212, 210, 190, 169, 152,
125 166, 166, 145, 111, 91, 132, 133, 128, 136, 130,
126 118, 94, 72, 74, 92, 86, 89, 92, 106, 123,
127 126, 100, 86, 137, 117, 92, 76, 104, 106, 114,
128 133, 109, 204, 192, 166, 148, 138, 128, 111, 81,
129 118, 99, 79, 146, 169, 141, 123, 102, 131, 120,
130 127, 105, 136, 204, 170, 154, 131, 145, 135, 119,
131 117, 95, 64, 83, 141, 136, 118, 96, 99, 126,
132 115, 93, 98, 102, 95, 105, 106, 114, 119, 128,
133 131, 121, 98, 139, 149, 119, 109, 86, 105, 129,
134 134, 119, 104, 169, 185, 155, 141, 122, 107, 127,
135 136, 115, 85, 108, 87, 126, 102, 128, 136, 129,
136 125, 99, 126, 158, 133, 139, 132, 113, 91, 107,
137 141, 122, 128, 161, 130, 127, 105, 120, 118, 106,
138 122, 140, 161, 168, 187, 184, 176, 158, 144, 140,
139 127, 111, 89, 130, 132, 105, 134, 121, 100, 122,
140 129, 110, 128, 115, 129, 116, 132, 118, 114, 119,
141 138, 133, 132, 188, 183, 159, 161, 147, 134, 140,
142 132, 113, 84, 167, 147, 132, 124, 109, 133, 121,
143 132, 128, 116, 121, 98, 101, 145, 129, 128, 129,
144 124, 112, 152, 158, 136, 161, 139, 165, 158, 142,
145 139, 138, 110, 127, 148, 117, 126, 118, 101, 116,
146 155, 168, 154, 128, 120, 152, 150, 141, 140, 135,
147 127, 111, 109, 134, 104, 133, 110, 112, 132, 114,
148 111, 87, 68, 89, 107, 121, 121, 126, 126, 129,
149 120, 148, 169, 163, 173, 178, 185, 188, 178, 163,
150 122, 97, 86, 117, 101, 138, 118, 142, 155, 139,
151 125, 114, 131, 138, 153, 149, 163, 150, 143, 141,
152 157, 161, 138, 152, 134, 121, 122, 109, 110, 124,
153 151, 171, 196, 168, 145, 139, 147, 151, 146, 139,
154 134, 169, 179, 170, 175, 178, 177, 173, 165, 154,
155 120, 151, 118, 107, 125, 129, 133, 133, 136, 139,
156 119, 141, 159, 151, 160, 165, 168, 169, 162, 152,
157 115, 111, 119, 94, 117, 121, 127, 127, 132, 136,
158 134, 153, 147, 142, 142, 147, 159, 159, 154, 147,
159 110, 106, 139, 135, 143, 142, 147, 146, 147, 147,
160 115, 133, 151, 133, 141, 142, 151, 152, 147, 144,
161 115, 132, 144, 131, 125, 126, 128, 130, 131, 136,
162 138, 118, 96, 71, 48, 26, 43, 130, 125, 125,
163 134, 122, 98, 54, 28, 84, 77, 73, 109, 125,
164 133, 112, 67, 48, 141, 129, 126, 113, 112, 118,
165 143, 123, 89, 54, 71, 73, 75, 131, 123, 123,
166 126, 109, 81, 31, 15, 94, 110, 109, 119, 128,
167 132, 122, 97, 92, 73, 50, 27, 22, 104, 133,
168 133, 119, 94, 48, 34, 168, 160, 154, 151, 130,
169 147, 133, 90, 54, 71, 123, 106, 105, 93, 117,
170 143, 132, 107, 69, 45, 78, 178, 169, 150, 139,
171 138, 123, 116, 96, 69, 49, 32, 113, 103, 112,
172 154, 151, 125, 79, 60, 152, 160, 154, 155, 137,
173 142, 151, 124, 88, 66, 59, 94, 87, 95, 119,
174 166, 154, 122, 92, 138, 132, 124, 114, 97, 97,
175 122, 99, 98, 219, 191, 176, 165, 159, 153, 131,
176 130, 119, 91, 51, 24, 41, 144, 156, 147, 139,
177 139, 122, 81, 65, 124, 111, 104, 90, 94, 98,
178 138, 120, 112, 91, 63, 65, 89, 75, 78, 106,
179 126, 107, 91, 85, 69, 95, 90, 84, 108, 120,
180 155, 139, 100, 78, 120, 110, 109, 91, 77, 73,
181 144, 130, 135, 112, 88, 65, 62, 142, 129, 126,
182 170, 154, 150, 131, 121, 116, 100, 92, 83, 86,
183 131, 122, 98, 107, 102, 75, 54, 38, 117, 130,
184 146, 139, 117, 107, 86, 66, 44, 30, 97, 128,
185 129, 116, 100, 59, 108, 127, 119, 139, 129, 129,
186 124, 106, 79, 49, 154, 190, 166, 152, 133, 123,
187 141, 149, 123, 89, 61, 70, 143, 132, 125, 126,
188 136, 113, 177, 166, 141, 123, 109, 108, 105, 93,
189 137, 117, 147, 123, 99, 85, 109, 98, 91, 75,
190 129, 121, 102, 78, 53, 90, 149, 136, 134, 135,
191 144, 136, 126, 90, 114, 152, 137, 152, 138, 128,
192 133, 115, 107, 129, 99, 78, 60, 129, 125, 118,
193 147, 141, 119, 124, 110, 91, 79, 64, 106, 117,
194 134, 111, 164, 143, 123, 113, 116, 95, 76, 56,
195 147, 159, 140, 109, 83, 84, 140, 135, 127, 129,
196 123, 104, 116, 99, 91, 87, 80, 110, 113, 121,
197 124, 106, 174, 174, 152, 141, 132, 134, 126, 124,
198 140, 190, 240, 215, 212, 189, 173, 158, 144, 137,
199 123, 97, 79, 102, 110, 111, 90, 75, 126, 124,
200 134, 121, 104, 145, 127, 100, 77, 65, 120, 118,
201 123, 106, 87, 41, 68, 119, 106, 115, 109, 119,
202 137, 232, 241, 225, 217, 202, 183, 169, 156, 145,
203 161, 146, 127, 110, 97, 107, 88, 114, 108, 106,
204 141, 244, 216, 192, 172, 163, 148, 143, 144, 144,
205 128, 127, 109, 89, 77, 68, 124, 120, 121, 125,
206 125, 94, 48, 71, 116, 113, 104, 120, 142, 137,
207 133, 129, 115, 82, 68, 120, 99, 133, 134, 124,
208 130, 106, 108, 160, 130, 111, 89, 129, 124, 119,
209 134, 120, 149, 143, 116, 95, 87, 142, 132, 122,
210 126, 114, 108, 107, 80, 141, 133, 123, 137, 124,
211 117, 95, 69, 43, 62, 98, 114, 116, 112, 120,
212 122, 99, 87, 164, 145, 123, 99, 95, 118, 105,
213 126, 101, 102, 120, 113, 110, 92, 139, 134, 126,
214 148, 194, 241, 219, 221, 215, 200, 193, 174, 151,
215 127, 104, 122, 136, 113, 106, 110, 95, 78, 106,
216 131, 163, 217, 199, 194, 175, 164, 155, 142, 138,
217 139, 124, 88, 57, 161, 161, 145, 139, 124, 116,
218 127, 110, 91, 98, 126, 104, 113, 98, 94, 94,
219 145, 138, 114, 90, 75, 130, 117, 107, 99, 90,
220 119, 98, 86, 101, 148, 133, 103, 83, 124, 131,
221 143, 168, 169, 133, 110, 117, 139, 149, 147, 137,
222 124, 106, 80, 138, 194, 163, 142, 119, 106, 130,
223 136, 125, 105, 114, 87, 113, 101, 89, 108, 102,
224 114, 90, 53, 46, 105, 116, 126, 122, 118, 122,
225 124, 102, 92, 195, 167, 160, 144, 154, 154, 132,
226 118, 97, 88, 72, 98, 120, 112, 98, 79, 117,
227 114, 107, 185, 191, 191, 188, 175, 165, 153, 143,
228 119, 97, 90, 89, 120, 151, 136, 113, 99, 112,
229 141, 121, 144, 122, 125, 113, 133, 111, 92, 69,
230 120, 98, 78, 109, 151, 145, 157, 157, 151, 143,
231 130, 110, 120, 188, 159, 141, 119, 112, 109, 98,
232 126, 112, 83, 110, 169, 139, 127, 105, 93, 123,
233 141, 145, 117, 106, 91, 78, 123, 107, 101, 125,
234 117, 95, 71, 147, 176, 153, 148, 133, 135, 127,
235 124, 106, 79, 64, 115, 96, 108, 115, 106, 105,
236 127, 115, 90, 98, 105, 81, 144, 135, 117, 125,
237 126, 104, 98, 165, 138, 136, 112, 149, 148, 131,
238 119, 144, 186, 185, 204, 202, 209, 200, 182, 161,
239 123, 153, 190, 189, 199, 194, 191, 176, 157, 147,
240 121, 103, 119, 98, 100, 120, 106, 97, 95, 126,
241 137, 130, 102, 117, 117, 92, 126, 114, 101, 118,
242 131, 219, 190, 167, 153, 151, 144, 140, 142, 143,
243 114, 102, 151, 152, 132, 120, 112, 120, 127, 131,
244 138, 122, 91, 143, 118, 120, 114, 104, 124, 117,
245 148, 142, 117, 126, 97, 125, 108, 116, 142, 125,
246 126, 106, 91, 169, 208, 178, 158, 138, 127, 135,
247 133, 126, 101, 83, 147, 130, 125, 117, 114, 117,
248 120, 103, 94, 149, 136, 129, 139, 118, 133, 133,
249 147, 152, 126, 132, 119, 97, 132, 129, 114, 126,
250 112, 107, 148, 125, 112, 114, 124, 125, 129, 135,
251 139, 121, 157, 151, 131, 140, 118, 147, 136, 121,
252 115, 105, 159, 167, 185, 191, 196, 190, 176, 160,
253 124, 106, 104, 122, 130, 114, 152, 144, 134, 136,
254 136, 152, 159, 153, 131, 114, 116, 126, 129, 129,
255 124, 109, 87, 131, 107, 115, 130, 107, 144, 131,
256 126, 162, 176, 175, 180, 176, 160, 141, 134, 134,
257 136, 127, 108, 161, 162, 133, 141, 124, 112, 128,
258 130, 115, 110, 140, 107, 155, 134, 131, 156, 137,
259 122, 106, 116, 127, 118, 161, 150, 170, 167, 152,
260 139, 177, 203, 176, 155, 139, 130, 128, 129, 132,
261 137, 119, 125, 103, 110, 123, 107, 120, 108, 101,
262 113, 107, 160, 154, 160, 166, 169, 176, 168, 156,
263 115, 90, 65, 115, 115, 104, 120, 112, 109, 124,
264 131, 123, 100, 109, 185, 158, 141, 132, 116, 119,
265 139, 130, 119, 156, 124, 138, 127, 116, 141, 128,
266 133, 118, 115, 180, 149, 151, 135, 130, 147, 129,
267 117, 90, 80, 119, 124, 128, 132, 130, 128, 135,
268 112, 97, 142, 161, 167, 165, 154, 142, 136, 135,
269 118, 141, 193, 172, 157, 152, 148, 145, 146, 141,
270 125, 147, 165, 166, 149, 133, 123, 122, 128, 131,
271 128, 193, 177, 174, 182, 186, 197, 193, 191, 173,
272 124, 144, 162, 133, 113, 113, 123, 128, 129, 130,
273 117, 98, 121, 122, 137, 132, 110, 97, 111, 130,
274 128, 176, 151, 125, 126, 134, 130, 121, 127, 130,
275 122, 151, 142, 111, 106, 121, 126, 126, 130, 134,
276 148, 167, 186, 153, 129, 122, 124, 128, 130, 128,
277 148, 172, 206, 178, 171, 182, 169, 180, 172, 156,
278 133, 164, 174, 160, 155, 163, 163, 172, 169, 158,
279 132, 150, 147, 142, 152, 140, 140, 140, 134, 135,
280 137, 158, 167, 172, 163, 153, 169, 158, 146, 147,
281 150, 161, 162, 172, 153, 133, 140, 144, 136, 135,
282 109, 84, 101, 120, 129, 134, 133, 136, 137, 143,
283 112, 114, 157, 147, 141, 136, 135, 133, 135, 138,
284 121, 154, 161, 150, 149, 154, 151, 144, 146, 144,
285 111, 117, 125, 125, 130, 131, 135, 137, 143, 148,
286 121, 141, 146, 131, 138, 126, 118, 111, 119, 130,
287 120, 135, 145, 121, 140, 134, 138, 137, 131, 134,
288 115, 137, 132, 137, 139, 138, 138, 139, 145, 149,
289 131, 149, 147, 133, 132, 126, 131, 134, 130, 133,
290 110, 98, 84, 141, 107, 169, 169, 123, 125, 126,
291 118, 210, 98, 126, 132, 138, 128, 139, 156, 157,
292 140, 142, 129, 95, 192, 178, 182, 186, 183, 159,
293 135, 134, 144, 124, 100, 228, 203, 161, 122, 104,
294 139, 159, 134, 161, 121, 126, 192, 152, 218, 180,
295 132, 132, 119, 99, 96, 97, 80, 53, 134, 143,
296 102, 114, 133, 114, 127, 83, 77, 126, 85, 107,
297 110, 114, 194, 186, 139, 116, 147, 104, 129, 138,
298 126, 133, 109, 144, 115, 45, 130, 97, 159, 155,
299 157, 162, 189, 185, 168, 163, 151, 151, 142, 135,
300 144, 147, 120, 74, 192, 186, 149, 118, 71, 84,
301 143, 156, 133, 178, 168, 107, 119, 149, 105, 112,
302 182, 184, 158, 118, 118, 148, 128, 177, 171, 152,
303 139, 135, 126, 209, 171, 150, 123, 100, 190, 158,
304 166, 97, 136, 123, 136, 139, 128, 138, 126, 121,
305 132, 131, 128, 95, 60, 168, 127, 140, 208, 161,
306 109, 102, 119, 162, 150, 137, 107, 200, 156, 136,
307 136, 128, 103, 95, 74, 91, 220, 173, 152, 138,
308 139, 129, 140, 136, 122, 82, 180, 115, 53, 90,
309 121, 107, 99, 148, 116, 139, 100, 63, 191, 155,
310 130, 129, 163, 155, 98, 175, 95, 151, 127, 107,
311 124, 124, 116, 88, 71, 164, 148, 96, 57, 89,
312 125, 117, 77, 63, 162, 144, 113, 109, 137, 134,
313 134, 130, 149, 174, 158, 158, 130, 81, 28, 67,
314 142, 139, 129, 100, 194, 134, 68, 175, 131, 103,
315 136, 132, 122, 96, 119, 82, 115, 249, 215, 168,
316 125, 139, 199, 96, 146, 123, 136, 179, 142, 137,
317 181, 166, 106, 86, 122, 106, 123, 131, 106, 119,
318 129, 189, 188, 147, 126, 110, 101, 114, 147, 136,
319 132, 106, 72, 175, 148, 99, 130, 153, 125, 136,
320 123, 119, 147, 170, 157, 126, 209, 188, 158, 152,
321 101, 89, 142, 131, 161, 150, 148, 124, 89, 119,
322 141, 137, 131, 103, 81, 85, 64, 175, 129, 121,
323 137, 144, 142, 145, 119, 205, 148, 80, 165, 138,
324 143, 137, 167, 165, 148, 149, 110, 234, 217, 170,
325 167, 152, 75, 140, 155, 155, 175, 129, 136, 134,
326 136, 152, 161, 131, 140, 121, 91, 79, 255, 209,
327 132, 147, 120, 114, 177, 128, 110, 61, 89, 131,
328 125, 127, 93, 87, 167, 115, 186, 162, 107, 106,
329 134, 162, 151, 100, 79, 67, 151, 116, 130, 142,
330 162, 153, 155, 143, 122, 85, 202, 187, 135, 125,
331 158, 155, 103, 129, 74, 149, 130, 98, 129, 126,
332 148, 152, 153, 133, 118, 94, 80, 70, 47, 90,
333 124, 118, 143, 184, 158, 126, 70, 82, 111, 113,
334 126, 135, 175, 141, 203, 166, 123, 123, 134, 133,
335 113, 111, 128, 76, 128, 177, 151, 178, 134, 125,
336 120, 120, 193, 106, 98, 134, 101, 86, 101, 114,
337 136, 127, 134, 196, 86, 105, 145, 128, 119, 137,
338 138, 126, 230, 161, 141, 128, 129, 136, 88, 83,
339 103, 118, 178, 123, 89, 101, 161, 173, 165, 147,
340 130, 123, 171, 158, 131, 81, 50, 177, 162, 136,
341 125, 115, 82, 173, 195, 168, 130, 112, 112, 121,
342 152, 148, 167, 87, 82, 161, 142, 147, 98, 89,
343 168, 138, 97, 157, 132, 114, 74, 126, 161, 141,
344 135, 123, 68, 137, 124, 118, 112, 92, 65, 96,
345 191, 181, 161, 151, 141, 145, 129, 102, 97, 111,
346 144, 128, 55, 128, 115, 155, 129, 184, 167, 147,
347 131, 141, 125, 33, 127, 111, 127, 131, 125, 130,
348 137, 130, 121, 195, 172, 177, 176, 149, 98, 97,
349 126, 106, 168, 159, 144, 185, 156, 151, 182, 158,
350 123, 93, 110, 116, 98, 99, 125, 136, 139, 148,
351 79, 112, 149, 128, 147, 136, 118, 105, 166, 152,
352 117, 115, 92, 128, 148, 132, 170, 143, 226, 190,
353 122, 192, 165, 121, 143, 144, 174, 124, 113, 124,
354 122, 135, 34, 93, 118, 111, 111, 136, 123, 116,
355 99, 195, 139, 99, 114, 102, 96, 108, 111, 112,
356 113, 129, 172, 137, 105, 139, 154, 86, 113, 108,
357 132, 79, 63, 120, 93, 162, 90, 103, 94, 95,
358 117, 127, 104, 100, 142, 129, 93, 27, 196, 153,
359 113, 91, 101, 90, 84, 68, 138, 38, 118, 148,
360 87, 103, 125, 109, 96, 152, 100, 56, 31, 62,
361 176, 129, 124, 115, 103, 92, 100, 121, 130, 125,
362 128, 71, 82, 71, 152, 85, 107, 116, 138, 133,
363 103, 116, 139, 144, 72, 37, 118, 141, 109, 95,
364 86, 92, 121, 167, 156, 104, 92, 91, 122, 114,
365 89, 61, 172, 128, 95, 103, 84, 101, 88, 84,
366 116, 125, 108, 62, 74, 108, 160, 143, 189, 164,
367 91, 115, 144, 43, 116, 79, 106, 108, 74, 83,
368 87, 90, 61, 71, 76, 76, 95, 130, 89, 94,
369 114, 107, 101, 145, 161, 147, 143, 163, 147, 129,
370 101, 73, 111, 108, 93, 104, 186, 141, 99, 89,
371 112, 126, 111, 113, 152, 41, 159, 115, 131, 124,
372 117, 101, 115, 130, 124, 87, 59, 177, 63, 85,
373 109, 116, 103, 68, 145, 132, 29, 119, 96, 89,
374 117, 90, 181, 103, 101, 111, 97, 96, 199, 171,
375 113, 120, 93, 119, 101, 64, 56, 55, 63, 90,
376 105, 101, 86, 45, 136, 179, 142, 102, 115, 114,
377 113, 108, 121, 84, 23, 125, 76, 102, 119, 107,
378 120, 104, 73, 177, 83, 114, 128, 85, 152, 126,
379 137, 115, 149, 109, 163, 133, 110, 98, 54, 61,
380 95, 111, 135, 103, 88, 164, 115, 187, 122, 98,
381 129, 132, 95, 86, 71, 119, 146, 111, 38, 67,
382 102, 100, 66, 148, 137, 103, 145, 95, 35, 85,
383 44, 136, 102, 111, 108, 115, 136, 105, 120, 110,
384 108, 147, 112, 169, 116, 146, 81, 120, 94, 84,
385 93, 97, 90, 119, 102, 91, 48, 147, 204, 151,
386 148, 160, 144, 131, 144, 175, 158, 133, 212, 163,
387 172, 152, 151, 112, 148, 151, 145, 179, 160, 124,
388 164, 164, 167, 161, 141, 120, 131, 141, 198, 177,
389 169, 156, 146, 156, 124, 185, 164, 195, 181, 193,
390 201, 147, 148, 168, 165, 159, 162, 148, 150, 148,
391 146, 157, 158, 149, 164, 129, 160, 214, 174, 166,
392 154, 176, 146, 141, 155, 140, 140, 169, 106, 155,
393 166, 162, 134, 193, 157, 155, 146, 196, 171, 107,
394 177, 174, 163, 155, 147, 203, 162, 146, 150, 83,
395 157, 170, 180, 178, 159, 157, 151, 117, 115, 183,
396 170, 180, 174, 150, 177, 173, 136, 181, 196, 184,
397 164, 168, 165, 148, 175, 168, 209, 189, 159, 114,
398 157, 158, 141, 168, 170, 139, 175, 128, 151, 39,
399 128, 154, 159, 161, 148, 180, 131, 165, 159, 131,
400 163, 150, 174, 178, 178, 198, 172, 138, 184, 191,
401 143, 164, 161, 163, 210, 171, 155, 168, 150, 116,
402 182, 170, 145, 152, 141, 139, 191, 149, 160, 202,
403 145, 169, 145, 181, 148, 183, 197, 165, 146, 171,
404 161, 153, 157, 170, 164, 149, 183, 167, 246, 235,
405 162, 144, 170, 152, 173, 150, 113, 135, 156, 154,
406 158, 148, 178, 159, 161, 114, 180, 156, 116, 163,
407 164, 161, 122, 164, 164, 183, 135, 135, 144, 182,
408 160, 147, 163, 152, 169, 185, 159, 177, 99, 211,
409 168, 167, 215, 170, 150, 157, 154, 176, 154, 143,
410 163, 117, 178, 160, 163, 165, 164, 166, 174, 136,
411 159, 169, 152, 123, 199, 149, 169, 140, 159, 208,
412 155, 161, 186, 122, 134, 167, 171, 145, 148, 176,
413 148, 137, 114, 160, 166, 153, 162, 156, 164, 172,
414 155, 148, 155, 182, 114, 150, 157, 154, 140, 159,
415 166, 160, 169, 206, 182, 145, 157, 165, 147, 202,
416 131, 154, 193, 162, 162, 149, 167, 157, 191, 188,
417 149, 205, 147, 166, 150, 150, 159, 153, 171, 160
418};
419
420static const uint8_t wmavoice_dq_lsp16i1[0x640] = {
421 142, 121, 141, 112, 99, 119, 92, 122, 183, 155,
422 122, 98, 75, 78, 85, 101, 108, 134, 128, 123,
423 115, 90, 79, 58, 73, 127, 106, 60, 97, 107,
424 141, 163, 130, 123, 136, 156, 201, 189, 204, 206,
425 140, 116, 69, 60, 117, 123, 106, 124, 91, 63,
426 150, 144, 110, 80, 63, 112, 80, 70, 76, 63,
427 114, 86, 147, 165, 137, 125, 120, 140, 115, 101,
428 101, 99, 166, 158, 158, 104, 126, 131, 134, 143,
429 121, 102, 73, 36, 83, 132, 113, 76, 38, 20,
430 132, 111, 78, 73, 51, 131, 108, 131, 105, 80,
431 148, 138, 101, 65, 47, 115, 86, 50, 124, 129,
432 116, 89, 85, 87, 64, 111, 74, 39, 115, 113,
433 112, 83, 75, 122, 127, 114, 91, 106, 125, 130,
434 131, 108, 79, 136, 112, 110, 147, 164, 144, 124,
435 121, 236, 218, 190, 168, 106, 101, 160, 172, 191,
436 113, 138, 102, 91, 109, 100, 71, 85, 112, 119,
437 121, 96, 51, 64, 126, 135, 114, 76, 34, 104,
438 145, 127, 90, 56, 131, 142, 131, 92, 123, 102,
439 128, 105, 63, 24, 95, 115, 87, 49, 156, 174,
440 123, 105, 88, 58, 55, 141, 119, 99, 75, 81,
441 137, 117, 114, 80, 56, 119, 91, 106, 166, 135,
442 114, 84, 38, 93, 116, 129, 103, 97, 87, 97,
443 115, 184, 193, 173, 157, 117, 88, 114, 151, 121,
444 126, 111, 75, 129, 133, 130, 107, 71, 115, 92,
445 128, 108, 120, 100, 97, 111, 80, 119, 122, 91,
446 114, 94, 149, 129, 136, 114, 88, 132, 110, 85,
447 116, 99, 101, 71, 71, 110, 140, 142, 131, 110,
448 122, 98, 83, 127, 100, 106, 130, 123, 114, 103,
449 113, 87, 140, 116, 113, 140, 161, 171, 145, 129,
450 115, 178, 158, 161, 160, 118, 195, 209, 221, 228,
451 99, 83, 140, 134, 140, 127, 186, 168, 187, 187,
452 107, 114, 100, 111, 111, 104, 130, 131, 116, 128,
453 128, 104, 64, 18, 49, 126, 107, 69, 56, 153,
454 154, 142, 110, 113, 89, 120, 93, 73, 190, 172,
455 119, 96, 57, 21, 60, 126, 122, 81, 99, 117,
456 159, 141, 108, 88, 120, 144, 125, 89, 44, 94,
457 147, 131, 93, 81, 61, 133, 113, 85, 47, 62,
458 123, 121, 87, 53, 90, 120, 94, 76, 70, 48,
459 125, 103, 93, 64, 35, 140, 129, 88, 47, 30,
460 127, 104, 58, 51, 103, 124, 100, 102, 76, 47,
461 115, 87, 54, 46, 77, 182, 218, 174, 163, 145,
462 140, 126, 89, 105, 82, 125, 119, 101, 69, 58,
463 125, 107, 172, 145, 128, 138, 113, 109, 92, 90,
464 117, 93, 83, 93, 132, 125, 102, 67, 148, 161,
465 131, 110, 96, 99, 74, 119, 92, 54, 84, 81,
466 110, 152, 120, 106, 131, 108, 74, 68, 99, 107,
467 121, 97, 120, 101, 78, 132, 110, 127, 164, 134,
468 111, 159, 204, 189, 178, 158, 183, 146, 144, 137,
469 123, 106, 136, 108, 135, 117, 91, 163, 135, 113,
470 119, 177, 134, 122, 121, 132, 109, 157, 131, 113,
471 115, 87, 87, 100, 92, 120, 95, 59, 146, 139,
472 129, 101, 135, 122, 101, 119, 100, 112, 88, 99,
473 118, 90, 123, 125, 107, 121, 98, 73, 104, 80,
474 112, 79, 86, 122, 96, 104, 81, 107, 90, 93,
475 112, 150, 140, 109, 115, 113, 86, 73, 76, 112,
476 130, 111, 101, 112, 84, 123, 97, 63, 134, 115,
477 109, 77, 128, 141, 119, 125, 101, 108, 147, 119,
478 134, 149, 150, 127, 115, 136, 244, 220, 210, 189,
479 105, 138, 171, 156, 174, 117, 162, 133, 146, 141,
480 115, 93, 119, 98, 122, 114, 106, 154, 145, 162,
481 107, 131, 189, 165, 152, 101, 107, 129, 114, 139,
482 116, 186, 186, 161, 180, 100, 89, 137, 116, 116,
483 106, 130, 194, 196, 207, 110, 156, 157, 138, 149,
484 102, 93, 159, 138, 120, 109, 132, 105, 122, 135,
485 148, 128, 85, 76, 102, 168, 154, 141, 117, 100,
486 125, 106, 62, 101, 146, 124, 102, 65, 25, 15,
487 120, 94, 46, 21, 94, 149, 128, 115, 85, 92,
488 119, 93, 70, 52, 30, 162, 151, 123, 91, 80,
489 126, 112, 84, 47, 33, 138, 114, 73, 60, 87,
490 126, 211, 174, 158, 143, 129, 106, 65, 31, 133,
491 119, 95, 52, 99, 173, 123, 96, 119, 206, 178,
492 127, 104, 60, 61, 67, 152, 136, 104, 63, 83,
493 133, 130, 92, 64, 45, 120, 96, 53, 30, 130,
494 128, 103, 74, 59, 35, 135, 114, 77, 30, 57,
495 108, 130, 123, 90, 87, 143, 125, 93, 54, 60,
496 133, 118, 79, 87, 95, 115, 89, 111, 88, 65,
497 124, 102, 70, 40, 47, 148, 131, 123, 130, 104,
498 127, 109, 87, 56, 121, 147, 123, 121, 107, 85,
499 178, 237, 200, 193, 170, 139, 118, 100, 75, 110,
500 133, 121, 81, 73, 68, 120, 195, 157, 141, 131,
501 127, 102, 107, 88, 60, 136, 113, 100, 69, 45,
502 128, 105, 93, 77, 67, 131, 116, 149, 184, 156,
503 115, 85, 35, 45, 112, 128, 108, 68, 73, 111,
504 118, 93, 187, 162, 139, 136, 115, 84, 57, 37,
505 131, 133, 125, 98, 85, 138, 115, 92, 86, 61,
506 116, 96, 70, 52, 110, 115, 109, 135, 104, 88,
507 136, 159, 122, 109, 115, 122, 110, 98, 70, 95,
508 112, 81, 68, 85, 90, 124, 101, 87, 56, 89,
509 109, 82, 98, 100, 115, 124, 102, 76, 88, 63,
510 111, 78, 42, 78, 102, 110, 71, 64, 131, 111,
511 125, 104, 107, 87, 123, 129, 131, 99, 85, 68,
512 147, 137, 102, 99, 75, 120, 155, 142, 109, 91,
513 132, 109, 131, 141, 113, 136, 119, 94, 152, 128,
514 127, 102, 79, 159, 134, 111, 78, 98, 109, 80,
515 115, 86, 51, 63, 103, 116, 86, 170, 149, 123,
516 135, 178, 159, 125, 114, 113, 189, 226, 203, 202,
517 140, 117, 116, 94, 70, 128, 103, 94, 174, 149,
518 118, 98, 83, 84, 106, 115, 157, 120, 94, 95,
519 131, 112, 75, 96, 74, 121, 97, 144, 117, 95,
520 120, 90, 140, 138, 110, 119, 93, 55, 92, 114,
521 114, 87, 151, 125, 100, 111, 82, 83, 160, 139,
522 114, 86, 56, 90, 138, 104, 109, 101, 77, 118,
523 140, 142, 143, 148, 126, 121, 102, 129, 107, 111,
524 113, 79, 58, 111, 91, 120, 94, 63, 115, 98,
525 121, 94, 99, 97, 78, 120, 92, 68, 173, 148,
526 122, 114, 109, 87, 82, 132, 229, 192, 176, 155,
527 137, 116, 123, 97, 115, 132, 115, 86, 120, 95,
528 135, 116, 101, 136, 108, 109, 74, 100, 125, 115,
529 112, 158, 144, 124, 134, 114, 83, 73, 147, 120,
530 120, 104, 150, 122, 116, 110, 104, 192, 183, 174,
531 134, 112, 116, 120, 93, 121, 101, 93, 110, 90,
532 121, 93, 147, 152, 122, 115, 153, 171, 161, 142,
533 123, 95, 116, 114, 93, 113, 89, 96, 77, 93,
534 113, 174, 180, 143, 138, 116, 86, 100, 135, 106,
535 103, 121, 149, 115, 103, 121, 95, 82, 149, 121,
536 117, 92, 93, 111, 114, 123, 209, 196, 193, 183,
537 125, 102, 107, 130, 104, 115, 91, 113, 103, 99,
538 114, 86, 68, 108, 110, 111, 159, 162, 125, 113,
539 125, 235, 234, 225, 214, 99, 74, 118, 121, 127,
540 104, 123, 158, 128, 127, 113, 96, 116, 136, 158,
541 100, 80, 138, 155, 166, 118, 143, 115, 125, 114,
542 119, 137, 133, 136, 139, 151, 188, 172, 174, 173,
543 138, 161, 158, 158, 155, 121, 198, 194, 211, 202,
544 100, 90, 112, 110, 122, 100, 91, 122, 128, 135,
545 101, 109, 127, 101, 114, 105, 126, 160, 147, 143,
546 109, 138, 142, 158, 163, 113, 174, 185, 188, 206,
547 112, 154, 166, 176, 183, 101, 108, 140, 140, 143,
548 106, 135, 130, 137, 126, 103, 114, 115, 128, 126,
549 107, 86, 21, 115, 75, 117, 139, 97, 65, 105,
550 64, 191, 101, 106, 139, 107, 98, 218, 132, 104,
551 73, 136, 165, 84, 118, 150, 111, 58, 130, 107,
552 99, 136, 132, 56, 52, 102, 136, 69, 78, 163,
553 85, 173, 148, 138, 85, 69, 106, 128, 133, 155,
554 104, 91, 149, 56, 104, 103, 101, 172, 96, 57,
555 104, 97, 125, 197, 166, 107, 169, 47, 120, 103,
556 150, 89, 99, 139, 162, 101, 69, 137, 158, 126,
557 191, 173, 127, 79, 155, 51, 131, 112, 86, 74,
558 135, 61, 114, 81, 125, 117, 112, 72, 175, 72,
559 127, 123, 142, 132, 78, 116, 158, 111, 121, 143,
560 108, 102, 89, 20, 194, 81, 99, 107, 65, 150,
561 103, 78, 91, 69, 96, 104, 116, 116, 103, 105,
562 107, 117, 110, 130, 28, 88, 103, 62, 72, 85,
563 125, 126, 141, 126, 178, 121, 102, 57, 46, 124,
564 97, 91, 89, 138, 95, 98, 143, 99, 169, 123,
565 140, 119, 113, 82, 140, 118, 112, 91, 92, 241,
566 134, 89, 95, 112, 78, 167, 140, 145, 121, 100,
567 109, 205, 144, 91, 100, 113, 103, 142, 175, 95,
568 117, 121, 35, 121, 127, 159, 129, 85, 64, 75,
569 116, 98, 103, 127, 129, 66, 68, 110, 96, 86,
570 79, 100, 156, 133, 92, 135, 96, 164, 132, 121,
571 93, 163, 134, 91, 208, 104, 77, 126, 116, 58,
572 136, 118, 132, 81, 61, 73, 115, 66, 129, 123,
573 111, 85, 42, 178, 134, 108, 132, 159, 45, 157,
574 105, 164, 100, 94, 60, 96, 57, 154, 105, 102,
575 103, 114, 96, 12, 91, 119, 115, 67, 92, 64,
576 94, 61, 106, 106, 165, 105, 94, 98, 68, 30,
577 146, 130, 107, 173, 140, 102, 90, 163, 106, 184,
578 100, 53, 68, 131, 92, 105, 111, 68, 153, 186,
579 101, 82, 48, 99, 147, 122, 136, 176, 96, 96,
580 104, 132, 167, 149, 136, 138, 144, 97, 120, 92
581};
582
583static const uint8_t wmavoice_dq_lsp16i2[0x3c0] = {
584 23, 12, 107, 119, 110, 205, 214, 212, 208, 201,
585 102, 95, 69, 117, 107, 118, 123, 118, 123, 121,
586 82, 58, 83, 95, 84, 139, 145, 153, 161, 169,
587 102, 100, 138, 121, 101, 129, 130, 138, 150, 139,
588 76, 104, 86, 112, 133, 113, 91, 63, 73, 129,
589 199, 193, 182, 181, 172, 119, 101, 83, 94, 76,
590 161, 157, 152, 157, 158, 110, 90, 121, 96, 79,
591 124, 107, 114, 88, 73, 152, 137, 121, 107, 99,
592 57, 50, 100, 81, 74, 115, 96, 72, 49, 69,
593 83, 68, 40, 53, 103, 36, 131, 107, 84, 64,
594 236, 245, 242, 231, 213, 95, 109, 88, 69, 110,
595 228, 221, 204, 182, 170, 129, 110, 97, 118, 104,
596 98, 76, 98, 75, 61, 93, 77, 113, 91, 72,
597 116, 94, 106, 134, 118, 177, 188, 169, 162, 153,
598 163, 149, 131, 131, 132, 177, 163, 173, 168, 158,
599 113, 131, 107, 113, 100, 132, 143, 131, 134, 142,
600 45, 36, 121, 113, 102, 43, 95, 84, 67, 56,
601 76, 82, 68, 48, 33, 55, 58, 59, 43, 65,
602 66, 85, 66, 81, 94, 102, 82, 54, 33, 94,
603 113, 111, 89, 60, 34, 138, 120, 101, 101, 86,
604 88, 73, 55, 114, 115, 92, 74, 93, 77, 123,
605 90, 117, 99, 79, 59, 97, 75, 97, 122, 104,
606 233, 237, 227, 208, 190, 209, 230, 233, 240, 241,
607 195, 197, 188, 167, 147, 204, 185, 168, 162, 157,
608 142, 124, 119, 123, 106, 117, 110, 81, 121, 123,
609 74, 116, 124, 119, 120, 178, 168, 146, 132, 125,
610 102, 104, 105, 110, 114, 104, 82, 78, 100, 86,
611 120, 102, 105, 93, 143, 127, 108, 128, 106, 88,
612 177, 189, 203, 207, 215, 101, 131, 119, 95, 73,
613 149, 139, 135, 147, 153, 160, 167, 165, 174, 177,
614 120, 109, 134, 140, 145, 131, 130, 142, 139, 161,
615 143, 158, 148, 145, 145, 123, 142, 132, 116, 102,
616 40, 23, 79, 82, 84, 26, 83, 141, 130, 122,
617 65, 46, 43, 89, 86, 28, 75, 80, 79, 98,
618 84, 65, 47, 26, 44, 49, 112, 101, 100, 94,
619 88, 76, 75, 48, 82, 104, 100, 75, 45, 15,
620 99, 83, 63, 34, 30, 66, 55, 94, 118, 113,
621 122, 106, 91, 68, 60, 135, 122, 104, 77, 59,
622 82, 102, 84, 62, 46, 92, 74, 55, 82, 71,
623 145, 134, 118, 93, 75, 79, 62, 83, 65, 55,
624 91, 94, 64, 70, 98, 89, 117, 110, 87, 97,
625 210, 223, 225, 223, 213, 83, 103, 86, 101, 85,
626 126, 106, 81, 79, 105, 216, 219, 217, 199, 179,
627 86, 78, 115, 138, 135, 102, 84, 87, 59, 46,
628 219, 206, 184, 167, 158, 201, 188, 165, 145, 135,
629 87, 113, 142, 152, 155, 190, 170, 153, 149, 146,
630 205, 208, 201, 185, 167, 84, 73, 124, 104, 96,
631 76, 88, 99, 74, 80, 110, 125, 122, 99, 112,
632 108, 84, 70, 130, 137, 161, 152, 136, 119, 105,
633 110, 91, 101, 74, 96, 111, 101, 93, 153, 149,
634 133, 124, 102, 97, 120, 101, 93, 75, 81, 64,
635 111, 94, 107, 79, 58, 188, 206, 215, 221, 232,
636 163, 175, 165, 150, 136, 103, 106, 123, 133, 132,
637 168, 184, 191, 183, 170, 110, 117, 90, 98, 93,
638 104, 87, 122, 98, 127, 129, 110, 127, 113, 125,
639 134, 118, 102, 140, 132, 186, 199, 202, 198, 188,
640 149, 147, 175, 185, 186, 117, 93, 99, 112, 93,
641 107, 138, 138, 129, 128, 96, 129, 104, 118, 134,
642 145, 136, 115, 121, 129, 138, 155, 148, 134, 120,
643 170, 151, 150, 145, 138, 168, 173, 185, 194, 200,
644 144, 159, 172, 168, 156, 121, 121, 138, 173, 168,
645 126, 111, 140, 139, 117, 149, 133, 142, 137, 130,
646 143, 139, 158, 158, 146, 119, 128, 121, 132, 145,
647 122, 136, 159, 153, 141, 133, 133, 130, 129, 126,
648 120, 76, 50, 149, 109, 92, 155, 118, 90, 66,
649 132, 117, 87, 156, 117, 119, 102, 44, 83, 91,
650 109, 73, 106, 84, 29, 55, 130, 112, 81, 241,
651 75, 40, 91, 89, 67, 112, 90, 149, 81, 72,
652 128, 90, 71, 28, 160, 73, 157, 123, 143, 108,
653 63, 88, 70, 81, 97, 75, 111, 149, 113, 96,
654 78, 104, 83, 179, 95, 105, 106, 65, 130, 66,
655 51, 118, 92, 53, 68, 105, 75, 176, 151, 115,
656 94, 75, 68, 95, 220, 103, 125, 105, 43, 95,
657 39, 114, 65, 145, 135, 33, 142, 138, 103, 52,
658 82, 85, 117, 110, 67, 102, 74, 42, 62, 118,
659 144, 121, 82, 57, 102, 67, 75, 44, 129, 96,
660 75, 63, 88, 48, 116, 135, 94, 85, 102, 66,
661 122, 77, 105, 122, 152, 120, 56, 90, 83, 100,
662 90, 128, 63, 80, 103, 126, 117, 103, 80, 193,
663 42, 73, 117, 93, 91, 95, 128, 100, 128, 162,
664 70, 120, 126, 73, 123, 99, 99, 91, 75, 135,
665 81, 125, 111, 77, 13, 94, 78, 85, 187, 157,
666 11, 143, 109, 99, 119, 53, 141, 82, 122, 68,
667 132, 89, 136, 119, 88, 75, 49, 174, 119, 70,
668 138, 121, 108, 78, 52, 104, 90, 96, 93, 93,
669 114, 90, 78, 46, 58, 62, 114, 69, 44, 162,
670 103, 58, 98, 141, 83, 137, 95, 119, 73, 111,
671 81, 46, 126, 111, 123, 107, 117, 122, 121, 54,
672 106, 104, 59, 110, 148, 97, 155, 97, 83, 133,
673 97, 71, 57, 91, 58, 52, 79, 127, 152, 109,
674 96, 92, 145, 107, 149, 102, 61, 125, 61, 170,
675 56, 89, 77, 106, 38, 147, 96, 77, 105, 123,
676 85, 83, 117, 63, 69, 126, 133, 93, 107, 92,
677 77, 115, 95, 111, 103, 61, 87, 103, 98, 155,
678 94, 111, 80, 78, 54, 117, 128, 130, 99, 109,
679 106, 99, 113, 133, 115, 89, 65, 74, 112, 127
680};
681
682static const uint8_t wmavoice_dq_lsp16i3[0x300] = {
683 70, 100, 121, 129, 132, 132, 201, 188, 165, 145, 144, 136,
684 112, 127, 116, 125, 130, 129, 124, 135, 135, 146, 129, 128,
685 162, 158, 144, 151, 135, 129, 103, 86, 111, 113, 112, 122,
686 90, 139, 129, 117, 126, 129, 142, 145, 167, 147, 124, 124,
687 230, 209, 189, 175, 156, 141, 64, 80, 86, 108, 121, 129,
688 44, 79, 115, 113, 115, 128, 133, 106, 79, 109, 125, 127,
689 171, 156, 132, 109, 103, 115, 106, 70, 93, 145, 141, 128,
690 148, 125, 122, 107, 110, 117, 146, 145, 128, 110, 98, 111,
691 237, 212, 185, 156, 139, 133, 84, 55, 26, 77, 114, 127,
692 172, 170, 171, 168, 162, 143, 82, 82, 76, 70, 104, 126,
693 17, 95, 109, 111, 120, 132, 81, 74, 57, 126, 141, 131,
694 110, 127, 162, 148, 129, 123, 177, 172, 155, 151, 145, 134,
695 144, 123, 90, 66, 109, 130, 82, 127, 103, 123, 132, 131,
696 127, 97, 97, 142, 140, 128, 159, 134, 136, 123, 113, 117,
697 131, 140, 154, 169, 158, 134, 96, 109, 150, 122, 105, 120,
698 120, 150, 152, 122, 119, 125, 123, 126, 124, 107, 100, 113,
699 248, 233, 216, 189, 160, 142, 58, 24, 13, 77, 111, 127,
700 183, 189, 182, 157, 140, 131, 96, 83, 59, 43, 73, 119,
701 222, 196, 171, 146, 129, 128, 32, 13, 53, 101, 114, 127,
702 119, 101, 70, 70, 110, 127, 77, 86, 161, 148, 130, 118,
703 199, 183, 170, 167, 156, 141, 30, 115, 142, 133, 131, 130,
704 101, 103, 181, 176, 152, 126, 66, 44, 73, 94, 111, 128,
705 150, 122, 100, 101, 104, 118, 61, 110, 87, 76, 93, 125,
706 190, 170, 150, 134, 135, 129, 112, 89, 63, 123, 141, 132,
707 175, 154, 136, 142, 140, 132, 117, 143, 129, 128, 136, 132,
708 168, 142, 112, 113, 128, 128, 155, 169, 159, 144, 139, 131,
709 61, 136, 144, 124, 112, 123, 86, 81, 104, 121, 129, 130,
710 160, 127, 118, 150, 151, 134, 126, 115, 121, 132, 134, 131,
711 137, 148, 144, 139, 140, 134, 106, 102, 105, 90, 87, 113,
712 134, 129, 128, 121, 121, 123, 153, 151, 129, 139, 142, 134,
713 150, 142, 141, 148, 149, 141, 100, 121, 133, 147, 150, 134,
714 163, 158, 147, 132, 141, 132, 142, 127, 141, 136, 136, 132,
715 232, 218, 205, 189, 169, 146, 243, 224, 201, 171, 147, 138,
716 224, 196, 169, 162, 154, 140, 51, 20, 59, 111, 121, 128,
717 203, 197, 193, 177, 162, 145, 75, 40, 47, 122, 130, 129,
718 102, 77, 47, 83, 121, 129, 111, 108, 84, 56, 63, 114,
719 211, 181, 154, 137, 126, 125, 213, 198, 186, 162, 144, 138,
720 41, 45, 90, 110, 118, 130, 83, 63, 130, 164, 153, 128,
721 195, 167, 142, 123, 113, 119, 19, 42, 105, 113, 120, 132,
722 50, 63, 49, 64, 112, 128, 114, 90, 132, 171, 162, 134,
723 129, 128, 107, 83, 74, 110, 50, 116, 109, 120, 128, 132,
724 94, 59, 73, 111, 117, 126, 197, 170, 166, 153, 138, 132,
725 65, 48, 109, 133, 131, 128, 170, 163, 172, 158, 138, 130,
726 66, 126, 147, 160, 151, 132, 42, 129, 117, 95, 91, 120,
727 97, 165, 164, 142, 133, 125, 163, 142, 114, 88, 97, 122,
728 104, 77, 142, 143, 128, 120, 136, 160, 188, 169, 149, 130,
729 113, 83, 85, 102, 114, 125, 164, 169, 142, 120, 122, 124,
730 98, 152, 132, 105, 92, 117, 42, 71, 125, 155, 151, 137,
731 94, 105, 81, 107, 118, 126, 84, 56, 123, 117, 108, 122,
732 174, 179, 166, 137, 118, 121, 130, 103, 147, 152, 134, 124,
733 148, 127, 94, 117, 144, 134, 129, 106, 102, 95, 106, 118,
734 147, 157, 153, 125, 103, 117, 155, 128, 113, 132, 120, 122,
735 181, 151, 136, 126, 122, 122, 110, 111, 109, 108, 120, 124,
736 97, 130, 103, 89, 107, 124, 179, 158, 158, 142, 131, 128,
737 142, 111, 115, 122, 126, 125, 145, 145, 134, 115, 129, 128,
738 130, 139, 112, 99, 121, 125, 79, 104, 119, 102, 105, 123,
739 116, 121, 136, 125, 126, 127, 124, 100, 122, 119, 111, 119,
740 159, 140, 139, 128, 138, 131, 105, 100, 116, 128, 135, 132,
741 159, 142, 156, 147, 140, 134, 130, 150, 129, 126, 114, 120,
742 138, 124, 146, 131, 109, 119, 93, 115, 125, 131, 125, 129,
743 125, 121, 101, 119, 114, 120, 163, 154, 151, 153, 153, 139,
744 166, 153, 150, 133, 119, 121, 159, 151, 128, 130, 122, 123,
745 147, 154, 144, 133, 128, 127, 129, 131, 134, 140, 148, 138,
746 138, 136, 120, 131, 135, 131, 150, 140, 137, 144, 129, 129
747};
748
749static const uint8_t wmavoice_dq_lsp10r[0x1400] = {
750 128, 128, 129, 129, 130, 130, 131, 130, 129, 129,
751 134, 133, 127, 125, 136, 135, 135, 134, 173, 172,
752 133, 139, 136, 165, 133, 176, 137, 159, 135, 152,
753 147, 161, 147, 152, 149, 156, 146, 146, 140, 136,
754 134, 135, 136, 140, 139, 155, 123, 133, 132, 142,
755 132, 148, 143, 177, 124, 143, 123, 136, 126, 134,
756 126, 125, 125, 124, 129, 128, 123, 123, 133, 133,
757 116, 116, 121, 121, 121, 120, 129, 128, 131, 131,
758 132, 133, 132, 129, 138, 124, 138, 124, 132, 100,
759 135, 94, 149, 111, 152, 115, 150, 128, 141, 133,
760 129, 129, 130, 129, 147, 145, 136, 137, 120, 122,
761 120, 122, 127, 129, 104, 108, 113, 115, 124, 124,
762 140, 139, 147, 145, 132, 130, 184, 177, 201, 196,
763 170, 171, 160, 161, 145, 147, 137, 145, 131, 131,
764 130, 130, 130, 130, 130, 130, 132, 134, 131, 132,
765 131, 133, 141, 144, 142, 149, 84, 93, 103, 104,
766 139, 139, 142, 140, 147, 147, 172, 165, 122, 121,
767 98, 100, 101, 106, 112, 117, 122, 124, 124, 124,
768 134, 133, 133, 133, 146, 142, 147, 145, 156, 156,
769 143, 146, 119, 124, 129, 132, 151, 149, 136, 135,
770 147, 148, 181, 180, 199, 188, 190, 173, 166, 161,
771 147, 142, 153, 149, 154, 146, 150, 146, 138, 134,
772 131, 135, 96, 136, 48, 138, 56, 131, 63, 124,
773 85, 128, 103, 132, 117, 134, 120, 132, 125, 129,
774 131, 130, 129, 128, 129, 128, 163, 168, 117, 120,
775 121, 121, 136, 138, 131, 132, 135, 136, 131, 133,
776 133, 133, 133, 134, 117, 118, 105, 109, 142, 151,
777 144, 159, 131, 138, 121, 126, 123, 123, 121, 124,
778 131, 131, 129, 129, 141, 140, 142, 134, 87, 90,
779 109, 109, 130, 127, 139, 143, 133, 131, 127, 126,
780 134, 135, 134, 136, 97, 98, 130, 132, 134, 137,
781 115, 119, 125, 130, 107, 109, 119, 118, 126, 127,
782 134, 135, 127, 132, 172, 203, 160, 196, 152, 179,
783 152, 172, 148, 168, 153, 172, 145, 156, 137, 140,
784 102, 116, 42, 56, 74, 61, 82, 70, 86, 78,
785 101, 97, 104, 100, 115, 108, 116, 108, 123, 118,
786 149, 143, 166, 129, 168, 96, 142, 95, 135, 98,
787 117, 86, 116, 93, 121, 108, 119, 107, 121, 117,
788 135, 135, 127, 138, 72, 132, 99, 136, 112, 147,
789 120, 152, 136, 155, 138, 146, 140, 142, 134, 139,
790 163, 145, 192, 130, 147, 124, 147, 125, 133, 125,
791 127, 124, 128, 123, 129, 122, 130, 122, 130, 125,
792 130, 137, 135, 180, 124, 133, 130, 129, 132, 133,
793 124, 124, 131, 130, 132, 136, 126, 124, 127, 125,
794 132, 132, 133, 133, 144, 140, 143, 142, 137, 135,
795 143, 138, 152, 149, 221, 219, 158, 161, 143, 141,
796 130, 129, 140, 135, 170, 145, 193, 156, 186, 152,
797 167, 139, 151, 131, 142, 127, 134, 120, 131, 125,
798 135, 133, 141, 125, 199, 109, 137, 126, 134, 123,
799 130, 129, 132, 123, 128, 125, 122, 126, 125, 125,
800 130, 128, 91, 89, 138, 135, 139, 134, 133, 129,
801 132, 130, 125, 128, 136, 135, 129, 127, 126, 126,
802 132, 131, 133, 131, 128, 120, 132, 126, 126, 119,
803 134, 130, 131, 123, 104, 95, 140, 141, 136, 137,
804 133, 133, 133, 134, 117, 98, 74, 49, 112, 111,
805 123, 122, 126, 127, 131, 131, 127, 126, 128, 129,
806 130, 131, 124, 127, 101, 107, 108, 109, 115, 115,
807 100, 99, 130, 128, 134, 136, 125, 127, 128, 130,
808 136, 137, 145, 150, 149, 164, 136, 151, 114, 111,
809 124, 125, 143, 150, 162, 174, 158, 169, 136, 137,
810 131, 131, 131, 131, 132, 133, 111, 110, 122, 121,
811 136, 136, 134, 133, 131, 132, 127, 127, 125, 125,
812 128, 129, 129, 130, 125, 127, 140, 140, 148, 149,
813 133, 136, 146, 153, 110, 118, 127, 129, 128, 129,
814 131, 133, 127, 131, 140, 161, 167, 224, 131, 139,
815 136, 143, 135, 139, 138, 143, 149, 155, 141, 143,
816 134, 132, 120, 111, 83, 83, 121, 126, 102, 107,
817 112, 115, 97, 104, 120, 115, 129, 123, 122, 122,
818 134, 135, 122, 131, 102, 124, 114, 119, 93, 103,
819 78, 79, 67, 72, 66, 73, 78, 82, 103, 102,
820 144, 135, 165, 139, 165, 129, 160, 126, 153, 127,
821 161, 134, 160, 142, 160, 143, 148, 140, 138, 135,
822 138, 95, 147, 54, 143, 78, 140, 112, 142, 113,
823 140, 121, 135, 117, 135, 122, 136, 131, 131, 132,
824 147, 159, 140, 156, 127, 81, 142, 128, 146, 127,
825 144, 125, 146, 128, 149, 130, 144, 135, 133, 128,
826 130, 131, 131, 131, 134, 139, 126, 134, 141, 154,
827 168, 205, 153, 176, 148, 163, 147, 158, 141, 143,
828 131, 135, 126, 146, 108, 157, 107, 156, 119, 146,
829 100, 138, 104, 125, 119, 134, 101, 122, 113, 122,
830 95, 133, 52, 140, 83, 136, 110, 133, 114, 131,
831 123, 131, 133, 131, 138, 135, 132, 132, 127, 127,
832 129, 128, 124, 122, 128, 126, 145, 170, 143, 172,
833 141, 163, 143, 176, 138, 164, 139, 155, 135, 145,
834 135, 136, 136, 127, 132, 76, 128, 76, 127, 63,
835 125, 66, 123, 67, 120, 71, 124, 92, 122, 111,
836 133, 133, 135, 136, 139, 140, 147, 147, 150, 144,
837 156, 147, 150, 145, 154, 146, 120, 123, 123, 124,
838 137, 133, 170, 141, 124, 124, 135, 134, 134, 135,
839 132, 132, 129, 129, 130, 130, 136, 136, 130, 132,
840 147, 159, 135, 158, 115, 146, 120, 148, 117, 136,
841 115, 137, 113, 132, 133, 142, 140, 144, 132, 134,
842 134, 135, 134, 137, 137, 147, 162, 178, 136, 147,
843 134, 144, 123, 132, 111, 113, 113, 113, 124, 124,
844 132, 131, 126, 126, 117, 114, 100, 95, 130, 125,
845 157, 145, 164, 156, 163, 158, 145, 145, 133, 134,
846 134, 134, 127, 126, 113, 102, 136, 130, 124, 122,
847 143, 145, 127, 131, 135, 143, 133, 137, 132, 132,
848 92, 94, 122, 125, 128, 129, 131, 130, 134, 135,
849 132, 128, 129, 127, 132, 132, 131, 129, 127, 127,
850 129, 129, 132, 131, 139, 131, 137, 132, 216, 178,
851 146, 134, 147, 137, 151, 142, 148, 139, 144, 138,
852 128, 127, 129, 129, 123, 131, 71, 91, 126, 128,
853 130, 134, 117, 123, 125, 125, 135, 140, 129, 132,
854 132, 132, 133, 134, 124, 130, 127, 133, 133, 138,
855 142, 149, 135, 141, 145, 149, 154, 164, 135, 138,
856 135, 135, 141, 142, 138, 137, 116, 96, 105, 86,
857 127, 118, 128, 120, 124, 117, 125, 117, 125, 121,
858 131, 131, 132, 134, 144, 145, 112, 112, 121, 123,
859 113, 116, 121, 123, 139, 138, 128, 128, 131, 131,
860 134, 132, 132, 132, 125, 128, 127, 130, 125, 131,
861 120, 128, 90, 119, 68, 98, 99, 112, 115, 124,
862 135, 135, 134, 134, 128, 129, 137, 137, 137, 138,
863 110, 114, 129, 130, 144, 145, 123, 125, 129, 129,
864 132, 133, 129, 130, 168, 187, 140, 149, 137, 144,
865 129, 130, 129, 134, 133, 138, 118, 118, 122, 120,
866 131, 130, 129, 128, 133, 133, 125, 125, 124, 123,
867 181, 179, 129, 129, 131, 127, 139, 136, 130, 128,
868 133, 133, 132, 132, 121, 120, 122, 119, 132, 129,
869 129, 125, 107, 96, 136, 137, 150, 146, 135, 134,
870 131, 131, 130, 130, 126, 123, 126, 123, 128, 125,
871 130, 123, 134, 127, 183, 159, 143, 135, 137, 134,
872 129, 129, 128, 128, 134, 133, 139, 138, 133, 132,
873 129, 127, 154, 151, 150, 144, 146, 146, 141, 142,
874 132, 132, 131, 131, 130, 130, 132, 133, 114, 115,
875 132, 132, 122, 122, 132, 131, 115, 117, 120, 120,
876 129, 129, 130, 130, 130, 129, 130, 131, 129, 131,
877 130, 130, 129, 129, 133, 132, 143, 144, 91, 91,
878 137, 136, 118, 107, 60, 45, 56, 49, 57, 52,
879 60, 56, 71, 75, 77, 80, 92, 97, 106, 106,
880 112, 131, 58, 121, 19, 65, 84, 101, 108, 122,
881 121, 127, 112, 117, 106, 112, 117, 124, 126, 127,
882 130, 129, 138, 133, 166, 155, 192, 179, 192, 177,
883 208, 191, 204, 192, 186, 179, 163, 163, 138, 142,
884 134, 134, 144, 142, 243, 236, 148, 146, 141, 137,
885 145, 141, 151, 144, 147, 143, 135, 139, 134, 133,
886 134, 128, 138, 88, 142, 10, 127, 76, 130, 96,
887 129, 102, 128, 108, 123, 111, 127, 119, 127, 124,
888 136, 136, 139, 139, 142, 140, 246, 241, 158, 167,
889 143, 145, 146, 149, 143, 145, 148, 152, 133, 134,
890 139, 135, 135, 136, 99, 137, 95, 133, 75, 138,
891 67, 135, 73, 128, 83, 132, 96, 126, 115, 127,
892 130, 132, 137, 136, 140, 135, 134, 130, 137, 131,
893 159, 151, 215, 197, 181, 170, 160, 149, 150, 143,
894 145, 148, 186, 207, 141, 147, 135, 137, 122, 122,
895 126, 125, 128, 126, 127, 127, 134, 126, 131, 123,
896 133, 133, 126, 122, 128, 122, 99, 93, 59, 60,
897 82, 82, 106, 107, 119, 123, 124, 128, 128, 129,
898 134, 137, 133, 139, 133, 136, 141, 132, 139, 122,
899 142, 97, 130, 81, 128, 89, 129, 101, 125, 112,
900 137, 140, 129, 148, 101, 159, 118, 180, 122, 178,
901 120, 178, 116, 168, 118, 153, 127, 151, 126, 136,
902 132, 134, 125, 126, 118, 105, 156, 124, 180, 132,
903 163, 124, 148, 121, 131, 112, 127, 115, 125, 122,
904 129, 131, 128, 129, 136, 134, 142, 141, 165, 158,
905 203, 182, 141, 136, 132, 130, 135, 135, 130, 130,
906 133, 133, 132, 132, 127, 126, 106, 105, 112, 110,
907 106, 105, 80, 84, 100, 101, 122, 125, 126, 128,
908 101, 109, 46, 59, 114, 112, 119, 119, 126, 121,
909 129, 124, 128, 125, 125, 122, 123, 120, 125, 122,
910 135, 134, 121, 134, 56, 139, 131, 145, 135, 138,
911 136, 139, 126, 130, 122, 132, 126, 129, 124, 129,
912 153, 169, 146, 179, 138, 139, 151, 143, 148, 138,
913 153, 137, 142, 129, 144, 126, 140, 128, 133, 126,
914 136, 134, 154, 149, 173, 157, 152, 144, 149, 141,
915 137, 136, 127, 121, 123, 121, 121, 126, 120, 123,
916 157, 143, 166, 135, 120, 122, 112, 118, 102, 118,
917 111, 124, 134, 131, 141, 138, 135, 134, 126, 129,
918 140, 123, 152, 76, 131, 116, 138, 136, 126, 134,
919 130, 142, 126, 136, 120, 132, 126, 128, 124, 127,
920 131, 138, 80, 147, 126, 138, 130, 140, 129, 134,
921 133, 135, 131, 132, 126, 127, 127, 125, 125, 123,
922 132, 132, 130, 132, 123, 130, 102, 102, 107, 110,
923 116, 127, 132, 152, 142, 160, 143, 151, 142, 146,
924 132, 132, 132, 132, 125, 126, 132, 140, 158, 199,
925 135, 149, 134, 140, 135, 131, 129, 120, 127, 121,
926 129, 130, 122, 123, 125, 124, 138, 138, 138, 135,
927 140, 141, 101, 94, 105, 98, 121, 122, 127, 128,
928 126, 127, 119, 121, 133, 156, 132, 159, 130, 148,
929 137, 164, 127, 138, 130, 137, 135, 140, 126, 126,
930 128, 129, 129, 129, 126, 124, 130, 128, 143, 138,
931 149, 143, 185, 170, 129, 127, 138, 133, 138, 135,
932 132, 134, 137, 144, 139, 183, 131, 145, 127, 128,
933 128, 127, 128, 122, 129, 125, 145, 139, 135, 131,
934 132, 133, 132, 130, 152, 96, 159, 85, 150, 105,
935 154, 115, 143, 120, 138, 126, 134, 124, 130, 126,
936 128, 127, 121, 123, 122, 123, 116, 125, 84, 87,
937 133, 135, 129, 131, 123, 126, 133, 135, 131, 130,
938 136, 134, 129, 119, 79, 63, 116, 116, 136, 133,
939 133, 130, 140, 143, 127, 127, 124, 125, 127, 128,
940 128, 126, 124, 120, 139, 128, 153, 134, 151, 134,
941 174, 145, 159, 136, 165, 144, 171, 149, 143, 135,
942 134, 134, 133, 133, 121, 119, 177, 162, 166, 154,
943 127, 130, 132, 132, 136, 137, 142, 143, 138, 137,
944 167, 151, 162, 142, 128, 136, 142, 148, 128, 143,
945 145, 153, 140, 149, 132, 141, 128, 139, 127, 133,
946 156, 169, 131, 129, 126, 120, 127, 125, 129, 120,
947 131, 126, 126, 123, 124, 121, 122, 121, 123, 123,
948 138, 140, 149, 156, 145, 152, 105, 102, 131, 126,
949 151, 146, 147, 139, 144, 137, 143, 133, 135, 130,
950 132, 130, 131, 129, 126, 130, 126, 129, 110, 135,
951 115, 139, 108, 146, 105, 147, 121, 134, 124, 133,
952 137, 137, 135, 134, 143, 142, 146, 146, 120, 121,
953 139, 137, 133, 129, 149, 145, 139, 133, 130, 127,
954 134, 134, 134, 134, 125, 124, 117, 119, 120, 113,
955 84, 80, 122, 125, 108, 112, 97, 102, 118, 120,
956 124, 123, 115, 116, 110, 111, 98, 97, 127, 124,
957 129, 127, 120, 117, 114, 109, 106, 104, 116, 116,
958 138, 138, 139, 141, 142, 146, 127, 125, 133, 130,
959 134, 128, 134, 127, 116, 91, 105, 84, 114, 106,
960 128, 128, 126, 126, 131, 137, 126, 129, 133, 139,
961 134, 145, 132, 143, 150, 192, 131, 142, 138, 141,
962 132, 130, 132, 130, 149, 138, 196, 152, 137, 125,
963 134, 125, 139, 128, 133, 125, 141, 134, 134, 135,
964 134, 135, 134, 135, 131, 130, 136, 133, 110, 106,
965 142, 144, 153, 162, 131, 129, 134, 132, 131, 130,
966 126, 125, 132, 130, 168, 153, 126, 124, 130, 126,
967 140, 135, 140, 134, 138, 133, 145, 137, 135, 134,
968 130, 130, 132, 131, 133, 132, 129, 129, 125, 128,
969 128, 130, 133, 139, 143, 152, 193, 215, 152, 160,
970 130, 131, 129, 131, 130, 131, 135, 136, 136, 141,
971 83, 81, 121, 120, 136, 130, 150, 145, 147, 145,
972 134, 133, 135, 133, 146, 142, 135, 131, 127, 128,
973 134, 135, 93, 102, 126, 132, 131, 133, 127, 129,
974 124, 125, 120, 122, 103, 106, 128, 129, 139, 138,
975 127, 128, 134, 134, 143, 138, 139, 134, 135, 133,
976 131, 130, 133, 131, 139, 134, 138, 136, 166, 156,
977 119, 116, 121, 122, 126, 124, 116, 117, 123, 124,
978 131, 131, 129, 129, 130, 128, 141, 138, 135, 132,
979 154, 145, 137, 129, 131, 125, 146, 137, 138, 135,
980 131, 131, 131, 132, 129, 130, 134, 138, 111, 116,
981 113, 118, 123, 125, 122, 124, 143, 147, 138, 140,
982 116, 113, 114, 112, 130, 126, 117, 115, 127, 126,
983 139, 137, 141, 139, 131, 132, 143, 144, 139, 140,
984 130, 130, 129, 128, 136, 134, 119, 117, 152, 143,
985 155, 143, 120, 119, 142, 139, 124, 130, 126, 128,
986 112, 110, 112, 109, 136, 132, 125, 118, 121, 115,
987 103, 101, 109, 100, 125, 120, 121, 117, 122, 121,
988 128, 128, 127, 127, 124, 124, 128, 127, 131, 129,
989 142, 138, 147, 141, 115, 108, 113, 109, 122, 119,
990 136, 133, 150, 139, 142, 131, 119, 111, 151, 137,
991 121, 116, 146, 134, 137, 129, 121, 123, 127, 129,
992 130, 130, 130, 130, 136, 137, 126, 126, 136, 136,
993 133, 133, 139, 139, 142, 143, 119, 120, 134, 134,
994 132, 132, 133, 133, 135, 138, 129, 131, 133, 134,
995 135, 138, 126, 130, 117, 118, 131, 132, 135, 135,
996 129, 129, 128, 128, 126, 129, 127, 129, 123, 125,
997 115, 117, 156, 157, 127, 131, 129, 129, 128, 129,
998 129, 130, 131, 131, 126, 127, 135, 134, 136, 135,
999 140, 136, 117, 113, 132, 128, 104, 97, 109, 106,
1000 131, 131, 131, 131, 121, 123, 124, 125, 126, 127,
1001 127, 127, 135, 135, 128, 128, 130, 130, 141, 140,
1002 129, 129, 129, 129, 129, 127, 127, 125, 149, 146,
1003 125, 123, 134, 133, 134, 132, 152, 150, 138, 138,
1004 128, 128, 126, 125, 132, 133, 141, 143, 136, 136,
1005 126, 127, 126, 127, 129, 131, 128, 129, 135, 134,
1006 176, 139, 192, 135, 145, 122, 149, 117, 155, 134,
1007 169, 133, 157, 139, 142, 136, 151, 152, 142, 147,
1008 166, 174, 103, 107, 141, 134, 140, 136, 144, 135,
1009 147, 135, 156, 131, 153, 127, 133, 126, 130, 124,
1010 127, 130, 123, 124, 114, 105, 195, 193, 156, 157,
1011 165, 158, 126, 122, 149, 141, 174, 173, 152, 147,
1012 136, 139, 131, 138, 163, 169, 103, 124, 80, 102,
1013 153, 186, 121, 151, 134, 161, 156, 190, 141, 151,
1014 121, 123, 124, 127, 119, 127, 133, 134, 157, 156,
1015 81, 69, 136, 134, 160, 169, 118, 114, 135, 128,
1016 114, 116, 97, 97, 117, 122, 152, 161, 115, 121,
1017 106, 122, 135, 137, 111, 113, 125, 135, 141, 145,
1018 143, 146, 143, 150, 132, 136, 142, 150, 151, 167,
1019 101, 107, 155, 173, 112, 124, 105, 100, 128, 126,
1020 127, 130, 133, 134, 142, 121, 131, 116, 176, 145,
1021 161, 120, 209, 150, 196, 133, 147, 115, 149, 130,
1022 144, 145, 144, 145, 120, 119, 163, 160, 117, 118,
1023 123, 117, 154, 119, 193, 98, 149, 101, 137, 116,
1024 133, 135, 140, 143, 144, 156, 131, 146, 186, 201,
1025 140, 139, 123, 125, 158, 169, 157, 166, 142, 143,
1026 130, 131, 132, 132, 128, 128, 141, 142, 147, 149,
1027 145, 148, 137, 139, 129, 129, 107, 108, 157, 157,
1028 120, 121, 119, 119, 140, 132, 137, 131, 118, 113,
1029 143, 136, 134, 135, 164, 158, 133, 125, 127, 124,
1030 148, 122, 197, 130, 173, 145, 110, 139, 123, 165,
1031 83, 158, 90, 167, 93, 142, 136, 169, 134, 152,
1032 130, 126, 154, 138, 227, 150, 156, 114, 147, 114,
1033 142, 109, 135, 110, 166, 135, 176, 150, 152, 142,
1034 132, 132, 136, 136, 130, 135, 143, 152, 136, 144,
1035 152, 160, 177, 185, 112, 112, 165, 166, 160, 161,
1036 145, 145, 138, 139, 116, 118, 127, 131, 66, 80,
1037 132, 142, 119, 127, 101, 108, 120, 130, 126, 130,
1038 135, 135, 142, 139, 153, 137, 55, 30, 142, 139,
1039 139, 143, 135, 133, 129, 133, 109, 108, 129, 129,
1040 136, 135, 134, 131, 129, 132, 132, 134, 135, 149,
1041 79, 206, 123, 137, 135, 143, 130, 140, 131, 134,
1042 100, 99, 165, 164, 142, 123, 148, 133, 133, 122,
1043 142, 133, 138, 125, 119, 111, 129, 123, 137, 130,
1044 131, 132, 123, 129, 174, 185, 196, 181, 127, 111,
1045 156, 141, 132, 114, 129, 106, 132, 107, 126, 117,
1046 134, 140, 131, 136, 119, 146, 92, 246, 128, 132,
1047 125, 129, 132, 140, 128, 141, 126, 145, 137, 142,
1048 130, 130, 110, 115, 124, 139, 127, 151, 118, 152,
1049 98, 146, 36, 108, 126, 158, 112, 146, 112, 130,
1050 138, 136, 145, 138, 153, 145, 116, 125, 90, 103,
1051 137, 138, 189, 185, 141, 151, 86, 93, 111, 111,
1052 133, 171, 125, 209, 140, 132, 130, 134, 129, 101,
1053 142, 120, 142, 132, 135, 126, 141, 140, 140, 134,
1054 128, 123, 131, 123, 138, 118, 163, 133, 240, 197,
1055 176, 151, 126, 123, 81, 94, 109, 118, 124, 133,
1056 135, 133, 137, 134, 154, 135, 140, 155, 69, 190,
1057 119, 149, 141, 151, 142, 123, 135, 125, 129, 130,
1058 127, 125, 132, 127, 107, 80, 123, 103, 145, 131,
1059 133, 107, 140, 103, 135, 106, 170, 145, 159, 143,
1060 136, 137, 127, 130, 105, 119, 129, 134, 141, 151,
1061 116, 127, 119, 140, 75, 119, 152, 162, 149, 152,
1062 72, 138, 9, 143, 118, 160, 126, 134, 141, 147,
1063 135, 131, 129, 129, 135, 129, 136, 126, 133, 125,
1064 137, 135, 146, 141, 145, 139, 141, 140, 133, 130,
1065 213, 208, 139, 130, 139, 136, 117, 117, 126, 125,
1066 133, 130, 138, 131, 141, 100, 145, 93, 159, 121,
1067 144, 132, 117, 160, 102, 187, 99, 162, 117, 144,
1068 132, 132, 134, 134, 140, 141, 127, 126, 128, 131,
1069 116, 116, 121, 127, 119, 126, 114, 114, 99, 100,
1070 141, 144, 148, 159, 179, 224, 95, 131, 100, 125,
1071 87, 110, 112, 132, 134, 147, 111, 125, 122, 122,
1072 137, 140, 141, 129, 169, 12, 144, 132, 133, 144,
1073 141, 146, 137, 147, 136, 122, 133, 130, 131, 128,
1074 141, 142, 128, 139, 15, 69, 160, 159, 142, 130,
1075 137, 126, 159, 141, 145, 143, 128, 125, 134, 128,
1076 131, 130, 127, 127, 114, 104, 119, 98, 83, 68,
1077 139, 120, 173, 142, 199, 154, 191, 153, 158, 145,
1078 128, 130, 127, 127, 148, 150, 110, 99, 119, 109,
1079 120, 113, 163, 154, 110, 90, 138, 129, 149, 144,
1080 131, 134, 124, 142, 76, 217, 130, 129, 140, 138,
1081 133, 135, 145, 150, 136, 138, 127, 130, 130, 134,
1082 144, 119, 178, 70, 143, 130, 115, 136, 139, 138,
1083 129, 109, 136, 116, 147, 122, 126, 112, 126, 123,
1084 132, 139, 128, 144, 107, 156, 75, 163, 120, 164,
1085 151, 136, 151, 99, 160, 112, 159, 126, 143, 126,
1086 140, 138, 137, 135, 152, 108, 251, 85, 138, 116,
1087 137, 118, 141, 119, 136, 121, 150, 134, 138, 131,
1088 137, 137, 143, 144, 150, 153, 148, 154, 152, 151,
1089 117, 104, 124, 96, 93, 67, 146, 138, 149, 148,
1090 149, 153, 172, 193, 108, 114, 125, 128, 145, 165,
1091 149, 160, 121, 130, 115, 120, 110, 112, 121, 118,
1092 145, 146, 141, 142, 127, 127, 103, 95, 138, 143,
1093 114, 126, 109, 115, 143, 136, 153, 149, 144, 142,
1094 140, 138, 150, 144, 128, 116, 142, 136, 135, 122,
1095 93, 88, 164, 163, 141, 142, 171, 182, 154, 160,
1096 124, 125, 122, 123, 158, 155, 111, 97, 138, 130,
1097 157, 134, 101, 65, 129, 118, 121, 114, 124, 119,
1098 131, 133, 125, 129, 136, 147, 135, 152, 131, 133,
1099 110, 115, 118, 114, 161, 159, 233, 218, 172, 166,
1100 140, 107, 125, 0, 140, 103, 140, 115, 125, 113,
1101 132, 135, 128, 133, 138, 146, 131, 145, 127, 133,
1102 131, 131, 122, 122, 135, 132, 126, 124, 132, 133,
1103 164, 167, 121, 127, 117, 120, 167, 162, 145, 143,
1104 135, 134, 136, 134, 156, 146, 195, 177, 127, 139,
1105 108, 140, 141, 173, 141, 178, 131, 155, 129, 141,
1106 134, 134, 119, 114, 184, 184, 127, 126, 147, 151,
1107 130, 140, 146, 159, 134, 145, 131, 136, 137, 142,
1108 135, 137, 128, 136, 83, 108, 97, 98, 152, 119,
1109 207, 144, 142, 121, 144, 129, 131, 127, 130, 132,
1110 124, 125, 108, 107, 94, 116, 81, 114, 139, 173,
1111 131, 158, 145, 177, 141, 163, 136, 140, 143, 144,
1112 135, 141, 132, 136, 134, 142, 142, 136, 173, 50,
1113 143, 106, 142, 127, 134, 139, 127, 133, 125, 125,
1114 129, 130, 131, 133, 132, 148, 110, 138, 113, 135,
1115 138, 175, 108, 151, 55, 119, 51, 100, 93, 116,
1116 121, 121, 146, 151, 99, 120, 127, 137, 107, 122,
1117 125, 139, 110, 132, 135, 156, 141, 156, 148, 157,
1118 137, 137, 141, 140, 139, 137, 130, 128, 138, 136,
1119 132, 134, 115, 110, 177, 179, 81, 86, 100, 98,
1120 84, 83, 121, 121, 148, 157, 127, 133, 146, 156,
1121 127, 136, 143, 151, 135, 139, 138, 142, 136, 136,
1122 201, 164, 151, 129, 123, 136, 147, 148, 127, 142,
1123 128, 143, 101, 126, 119, 133, 114, 131, 116, 126,
1124 132, 133, 140, 140, 126, 125, 156, 153, 142, 129,
1125 140, 130, 77, 69, 134, 132, 146, 148, 135, 136,
1126 133, 132, 123, 116, 116, 103, 150, 135, 144, 127,
1127 130, 117, 136, 122, 122, 106, 48, 38, 81, 78,
1128 145, 146, 135, 136, 123, 122, 126, 133, 133, 138,
1129 145, 145, 144, 150, 160, 181, 142, 139, 150, 150,
1130 136, 136, 139, 139, 133, 133, 139, 135, 134, 129,
1131 140, 137, 153, 145, 132, 131, 151, 144, 68, 66,
1132 137, 137, 139, 139, 146, 146, 142, 139, 129, 128,
1133 131, 129, 133, 132, 135, 134, 135, 134, 201, 200,
1134 137, 136, 146, 143, 155, 153, 157, 158, 131, 138,
1135 140, 139, 143, 144, 128, 123, 216, 192, 159, 150,
1136 137, 138, 136, 142, 145, 148, 126, 162, 140, 170,
1137 186, 95, 131, 140, 143, 148, 133, 128, 130, 133,
1138 141, 139, 153, 150, 122, 122, 134, 144, 124, 130,
1139 159, 166, 133, 139, 151, 150, 138, 139, 131, 134,
1140 121, 121, 131, 129, 148, 180, 121, 135, 118, 131,
1141 124, 148, 119, 119, 129, 126, 150, 156, 155, 160,
1142 40, 154, 115, 157, 133, 129, 140, 133, 143, 133,
1143 143, 132, 144, 130, 141, 131, 134, 130, 137, 133,
1144 134, 136, 141, 140, 145, 137, 152, 124, 183, 91,
1145 118, 154, 123, 158, 136, 134, 140, 142, 138, 142,
1146 138, 135, 131, 131, 138, 129, 121, 128, 146, 219,
1147 124, 123, 125, 135, 120, 126, 127, 141, 133, 136,
1148 127, 124, 120, 107, 152, 125, 149, 108, 158, 144,
1149 196, 185, 174, 164, 151, 149, 138, 131, 140, 137,
1150 149, 148, 144, 145, 143, 145, 140, 143, 141, 147,
1151 112, 125, 113, 113, 149, 155, 143, 149, 146, 151,
1152 138, 138, 141, 138, 144, 129, 134, 125, 143, 140,
1153 153, 154, 142, 123, 162, 42, 154, 106, 153, 130,
1154 153, 153, 137, 137, 144, 144, 142, 140, 165, 151,
1155 161, 140, 144, 134, 156, 124, 167, 143, 166, 155,
1156 132, 132, 137, 138, 137, 132, 124, 127, 140, 144,
1157 134, 140, 162, 180, 127, 131, 152, 169, 145, 156,
1158 133, 134, 131, 133, 130, 132, 147, 149, 125, 117,
1159 127, 118, 159, 155, 147, 142, 122, 117, 145, 144,
1160 138, 137, 130, 133, 113, 149, 168, 224, 166, 201,
1161 129, 151, 147, 154, 136, 135, 140, 136, 152, 141,
1162 120, 112, 140, 127, 161, 100, 132, 115, 118, 125,
1163 115, 133, 115, 157, 144, 146, 114, 135, 127, 139,
1164 138, 141, 135, 135, 137, 136, 147, 142, 143, 144,
1165 139, 152, 142, 136, 147, 143, 177, 39, 125, 71,
1166 147, 143, 66, 88, 132, 158, 123, 126, 116, 135,
1167 119, 124, 128, 135, 133, 140, 137, 126, 137, 130,
1168 155, 38, 149, 103, 130, 135, 139, 143, 127, 137,
1169 135, 141, 138, 148, 131, 148, 136, 147, 132, 139,
1170 136, 140, 115, 129, 115, 151, 136, 160, 87, 131,
1171 157, 176, 150, 164, 140, 141, 135, 119, 137, 133,
1172 141, 140, 140, 139, 134, 134, 142, 144, 131, 132,
1173 131, 134, 131, 132, 116, 114, 129, 133, 205, 207,
1174 130, 133, 160, 170, 137, 127, 124, 112, 158, 146,
1175 155, 137, 134, 136, 137, 142, 177, 184, 149, 152,
1176 135, 134, 133, 132, 135, 129, 144, 136, 139, 134,
1177 161, 155, 126, 109, 215, 186, 177, 153, 160, 149,
1178 139, 139, 136, 140, 140, 142, 186, 71, 129, 144,
1179 131, 165, 142, 152, 140, 151, 141, 143, 137, 139,
1180 144, 138, 150, 135, 133, 126, 136, 143, 99, 152,
1181 139, 131, 190, 118, 122, 147, 134, 155, 136, 143,
1182 138, 135, 137, 132, 147, 144, 150, 144, 138, 134,
1183 129, 133, 130, 138, 56, 175, 129, 166, 147, 165,
1184 140, 138, 144, 137, 141, 133, 150, 139, 129, 135,
1185 40, 83, 126, 130, 110, 120, 100, 110, 126, 128,
1186 141, 142, 217, 175, 172, 151, 146, 153, 125, 132,
1187 128, 137, 141, 141, 145, 145, 140, 133, 132, 131,
1188 129, 144, 128, 177, 133, 195, 147, 120, 138, 131,
1189 161, 114, 166, 134, 162, 118, 161, 115, 155, 129,
1190 137, 136, 141, 129, 141, 132, 55, 168, 121, 126,
1191 136, 139, 120, 133, 149, 147, 132, 141, 131, 136,
1192 147, 150, 151, 132, 101, 31, 117, 101, 129, 132,
1193 122, 138, 128, 137, 140, 170, 131, 143, 131, 134,
1194 149, 192, 122, 158, 136, 146, 133, 166, 143, 141,
1195 141, 136, 141, 129, 125, 155, 140, 138, 137, 131,
1196 111, 112, 131, 132, 120, 127, 149, 148, 151, 141,
1197 156, 148, 133, 129, 127, 124, 144, 137, 142, 139,
1198 134, 133, 141, 138, 133, 135, 124, 96, 226, 152,
1199 116, 108, 128, 105, 155, 130, 153, 138, 144, 139,
1200 142, 141, 137, 135, 142, 143, 156, 162, 136, 89,
1201 188, 145, 181, 152, 138, 146, 146, 154, 145, 149,
1202 152, 133, 158, 133, 42, 153, 117, 144, 149, 139,
1203 125, 139, 134, 128, 150, 128, 143, 125, 135, 132,
1204 143, 141, 143, 141, 164, 173, 141, 142, 156, 155,
1205 154, 154, 169, 170, 77, 80, 112, 105, 135, 134,
1206 126, 143, 120, 172, 111, 144, 120, 154, 107, 153,
1207 95, 134, 104, 134, 128, 116, 163, 131, 151, 136,
1208 135, 133, 142, 143, 152, 204, 149, 112, 156, 128,
1209 150, 126, 127, 129, 139, 175, 143, 141, 138, 135,
1210 168, 148, 152, 105, 164, 121, 134, 122, 119, 109,
1211 122, 148, 136, 143, 153, 132, 158, 148, 149, 150,
1212 133, 131, 142, 141, 150, 149, 156, 173, 138, 155,
1213 129, 144, 111, 107, 130, 129, 96, 89, 106, 104,
1214 135, 135, 144, 146, 131, 153, 134, 154, 146, 166,
1215 117, 138, 163, 187, 190, 216, 149, 156, 149, 152,
1216 142, 142, 153, 154, 109, 145, 40, 102, 116, 126,
1217 137, 139, 149, 157, 108, 124, 139, 146, 142, 147,
1218 130, 126, 120, 111, 172, 146, 169, 136, 150, 135,
1219 126, 96, 159, 143, 150, 122, 162, 129, 156, 142,
1220 135, 142, 144, 138, 222, 109, 137, 145, 144, 142,
1221 141, 143, 138, 136, 124, 150, 133, 144, 137, 145,
1222 141, 144, 139, 144, 134, 154, 114, 136, 145, 173,
1223 151, 215, 110, 115, 127, 134, 145, 150, 145, 144,
1224 144, 142, 139, 131, 147, 132, 141, 119, 143, 106,
1225 165, 41, 147, 129, 129, 144, 138, 135, 138, 140,
1226 128, 150, 89, 163, 154, 115, 141, 127, 132, 145,
1227 135, 157, 143, 145, 140, 141, 127, 135, 127, 129,
1228 142, 147, 116, 147, 104, 162, 153, 143, 146, 130,
1229 144, 110, 133, 123, 130, 137, 118, 198, 126, 152,
1230 154, 146, 139, 127, 147, 112, 207, 151, 156, 136,
1231 162, 137, 108, 121, 130, 135, 125, 131, 131, 134,
1232 134, 134, 141, 144, 107, 143, 137, 144, 124, 136,
1233 115, 147, 130, 157, 119, 167, 71, 144, 97, 128,
1234 134, 138, 132, 133, 138, 138, 146, 146, 147, 131,
1235 141, 138, 185, 65, 145, 123, 139, 130, 142, 128,
1236 139, 136, 157, 147, 124, 119, 164, 148, 170, 154,
1237 133, 130, 157, 148, 140, 141, 130, 135, 134, 137,
1238 136, 137, 143, 144, 144, 144, 178, 186, 71, 73,
1239 120, 118, 127, 124, 152, 151, 155, 146, 141, 138,
1240 142, 143, 139, 143, 133, 134, 139, 140, 138, 135,
1241 146, 141, 78, 198, 129, 139, 141, 141, 134, 141,
1242 137, 136, 120, 120, 124, 118, 143, 148, 148, 152,
1243 131, 143, 129, 137, 152, 158, 157, 160, 175, 178,
1244 137, 139, 131, 133, 146, 152, 121, 147, 142, 143,
1245 129, 136, 149, 145, 197, 114, 103, 141, 124, 140,
1246 141, 140, 129, 129, 127, 130, 131, 124, 123, 117,
1247 150, 139, 120, 109, 119, 120, 163, 163, 117, 121,
1248 139, 139, 136, 136, 94, 74, 150, 145, 126, 127,
1249 147, 150, 158, 162, 84, 74, 136, 129, 140, 132,
1250 136, 135, 146, 145, 124, 116, 129, 120, 130, 129,
1251 130, 109, 122, 111, 160, 141, 135, 113, 131, 121,
1252 136, 135, 135, 135, 147, 147, 140, 140, 144, 145,
1253 139, 142, 131, 137, 145, 145, 143, 153, 48, 49,
1254 145, 143, 151, 147, 158, 146, 135, 124, 124, 116,
1255 159, 140, 131, 126, 123, 120, 103, 117, 113, 119,
1256 148, 146, 128, 124, 123, 126, 123, 120, 158, 141,
1257 148, 137, 146, 143, 125, 143, 89, 107, 116, 123,
1258 149, 147, 141, 139, 149, 153, 118, 121, 139, 138,
1259 105, 119, 168, 147, 139, 141, 143, 138, 133, 130,
1260 126, 126, 143, 142, 146, 144, 124, 123, 143, 145,
1261 149, 148, 147, 141, 151, 143, 118, 113, 175, 171
1262};
1263
1264static const uint8_t wmavoice_dq_lsp16r1[0x500] = {
1265 147, 145, 193, 168, 188, 156, 141, 145, 141, 139,
1266 148, 149, 148, 149, 153, 157, 144, 144, 152, 152,
1267 141, 145, 153, 143, 243, 134, 151, 133, 166, 135,
1268 150, 149, 135, 132, 32, 39, 110, 111, 109, 114,
1269 126, 127, 147, 146, 177, 169, 162, 156, 210, 187,
1270 141, 147, 95, 150, 127, 155, 108, 133, 139, 148,
1271 138, 138, 140, 140, 147, 146, 134, 130, 136, 134,
1272 147, 146, 142, 150, 62, 174, 126, 151, 122, 156,
1273 154, 156, 179, 184, 115, 107, 105, 99, 127, 124,
1274 146, 131, 140, 44, 132, 125, 156, 146, 153, 153,
1275 136, 137, 145, 144, 141, 139, 158, 152, 138, 132,
1276 145, 145, 147, 145, 146, 141, 144, 140, 110, 97,
1277 140, 141, 143, 142, 130, 123, 127, 117, 126, 120,
1278 147, 146, 161, 155, 169, 135, 122, 117, 166, 155,
1279 144, 144, 142, 142, 125, 122, 137, 128, 194, 172,
1280 127, 85, 148, 143, 153, 141, 147, 147, 140, 143,
1281 118, 140, 0, 69, 51, 60, 111, 123, 137, 135,
1282 146, 146, 164, 165, 207, 214, 145, 143, 149, 147,
1283 178, 168, 197, 170, 134, 154, 148, 159, 115, 140,
1284 103, 118, 13, 38, 139, 138, 135, 138, 140, 141,
1285 144, 144, 140, 140, 150, 150, 156, 157, 164, 171,
1286 143, 143, 140, 142, 118, 120, 172, 172, 160, 163,
1287 146, 147, 150, 151, 176, 176, 230, 237, 153, 153,
1288 168, 156, 173, 149, 164, 148, 162, 146, 178, 158,
1289 147, 145, 143, 145, 111, 126, 111, 130, 89, 118,
1290 153, 158, 122, 120, 142, 125, 124, 105, 148, 138,
1291 145, 144, 156, 151, 193, 154, 146, 147, 119, 135,
1292 142, 141, 145, 145, 152, 147, 142, 141, 146, 146,
1293 139, 138, 154, 154, 148, 150, 147, 149, 144, 145,
1294 134, 134, 141, 140, 135, 134, 145, 147, 160, 163,
1295 144, 145, 149, 146, 115, 67, 127, 119, 141, 135,
1296 145, 141, 130, 124, 143, 144, 151, 165, 141, 144,
1297 154, 152, 160, 136, 115, 82, 64, 71, 64, 65,
1298 143, 143, 151, 149, 240, 251, 165, 173, 173, 179,
1299 148, 134, 156, 55, 160, 105, 133, 91, 129, 96,
1300 149, 149, 145, 144, 160, 154, 171, 159, 140, 142,
1301 154, 163, 178, 244, 147, 140, 153, 150, 137, 121,
1302 145, 144, 145, 146, 138, 139, 149, 152, 189, 198,
1303 148, 148, 156, 158, 168, 182, 165, 182, 172, 201,
1304 143, 142, 99, 92, 152, 152, 143, 143, 127, 127,
1305 165, 148, 173, 124, 113, 122, 134, 142, 127, 142,
1306 124, 126, 137, 137, 131, 132, 144, 142, 141, 138,
1307 172, 176, 138, 111, 152, 136, 167, 154, 156, 137,
1308 140, 150, 78, 145, 158, 157, 161, 154, 155, 147,
1309 153, 164, 156, 191, 129, 109, 153, 146, 153, 141,
1310 138, 137, 141, 138, 115, 94, 144, 141, 155, 147,
1311 144, 142, 144, 137, 168, 113, 141, 134, 145, 137,
1312 146, 144, 150, 148, 140, 155, 103, 178, 137, 149,
1313 145, 147, 148, 153, 175, 201, 138, 146, 110, 108,
1314 143, 146, 124, 134, 124, 127, 164, 158, 127, 135,
1315 145, 146, 150, 150, 145, 147, 95, 80, 150, 151,
1316 149, 149, 162, 162, 144, 152, 170, 169, 145, 154,
1317 145, 149, 143, 146, 142, 145, 152, 146, 160, 98,
1318 141, 141, 153, 153, 140, 137, 131, 131, 145, 146,
1319 133, 132, 127, 124, 158, 150, 173, 164, 178, 167,
1320 146, 146, 154, 155, 117, 127, 143, 147, 147, 156,
1321 142, 143, 144, 145, 146, 152, 170, 199, 151, 165,
1322 146, 147, 139, 140, 147, 149, 132, 134, 147, 149,
1323 138, 139, 142, 143, 162, 188, 145, 149, 160, 164,
1324 150, 150, 139, 139, 143, 142, 146, 146, 137, 138,
1325 142, 142, 141, 140, 152, 153, 164, 171, 110, 112,
1326 139, 139, 143, 143, 138, 138, 142, 142, 143, 143,
1327 137, 140, 142, 142, 145, 141, 149, 141, 182, 135,
1328 146, 146, 150, 150, 144, 145, 150, 151, 135, 137,
1329 137, 145, 51, 62, 68, 54, 69, 57, 62, 41,
1330 137, 139, 139, 144, 135, 150, 225, 232, 208, 197,
1331 136, 135, 141, 143, 145, 150, 160, 169, 213, 247,
1332 142, 137, 72, 54, 110, 107, 105, 107, 127, 130,
1333 145, 143, 169, 155, 219, 174, 195, 164, 183, 157,
1334 155, 157, 239, 232, 169, 164, 170, 172, 156, 159,
1335 142, 143, 136, 144, 59, 100, 139, 142, 130, 138,
1336 147, 146, 150, 161, 128, 235, 143, 155, 146, 167,
1337 154, 149, 128, 151, 42, 149, 55, 136, 59, 127,
1338 128, 126, 74, 92, 143, 153, 140, 150, 166, 176,
1339 146, 152, 150, 145, 140, 100, 140, 105, 124, 59,
1340 195, 191, 146, 148, 144, 136, 136, 133, 129, 122,
1341 133, 148, 40, 147, 102, 140, 123, 148, 118, 136,
1342 143, 143, 150, 148, 184, 153, 160, 147, 166, 149,
1343 58, 68, 127, 135, 141, 145, 143, 147, 150, 151,
1344 140, 143, 137, 137, 120, 114, 71, 65, 125, 123,
1345 153, 148, 215, 159, 136, 135, 150, 146, 150, 150,
1346 148, 138, 166, 94, 150, 145, 145, 139, 147, 145,
1347 146, 147, 150, 139, 171, 63, 158, 142, 153, 133,
1348 147, 148, 143, 143, 76, 72, 155, 159, 164, 176,
1349 149, 149, 173, 195, 145, 165, 138, 144, 150, 167,
1350 180, 169, 146, 151, 146, 166, 147, 166, 149, 171,
1351 157, 156, 168, 166, 147, 149, 121, 122, 116, 124,
1352 145, 145, 147, 148, 172, 189, 168, 180, 144, 146,
1353 139, 145, 141, 150, 115, 172, 141, 146, 143, 148,
1354 145, 145, 142, 143, 145, 147, 138, 143, 58, 73,
1355 141, 142, 146, 145, 163, 149, 218, 161, 147, 132,
1356 152, 147, 146, 147, 140, 150, 141, 152, 89, 150,
1357 78, 134, 135, 137, 139, 142, 140, 137, 137, 130,
1358 144, 144, 152, 151, 145, 140, 181, 170, 191, 168,
1359 164, 166, 136, 148, 112, 124, 139, 144, 146, 149,
1360 142, 151, 113, 182, 137, 150, 143, 156, 138, 147,
1361 154, 156, 108, 102, 118, 119, 133, 139, 113, 111,
1362 145, 144, 150, 147, 175, 151, 104, 106, 116, 114,
1363 143, 144, 151, 157, 151, 191, 135, 113, 138, 123,
1364 146, 146, 155, 157, 106, 145, 132, 127, 140, 125,
1365 161, 165, 146, 150, 151, 154, 139, 140, 142, 143,
1366 144, 148, 145, 149, 147, 138, 168, 104, 146, 136,
1367 138, 140, 91, 108, 111, 110, 145, 140, 158, 154,
1368 130, 112, 122, 118, 136, 135, 119, 118, 141, 140,
1369 147, 146, 146, 145, 138, 138, 182, 188, 132, 132,
1370 144, 144, 156, 155, 168, 172, 123, 128, 144, 151,
1371 142, 140, 145, 145, 137, 144, 141, 152, 128, 188,
1372 149, 149, 160, 161, 160, 160, 166, 163, 130, 107,
1373 143, 143, 142, 142, 149, 149, 132, 132, 170, 174,
1374 148, 148, 154, 153, 118, 111, 157, 155, 114, 109,
1375 140, 139, 138, 137, 205, 187, 137, 133, 147, 144,
1376 144, 145, 147, 149, 105, 125, 108, 117, 155, 162,
1377 146, 146, 162, 157, 144, 122, 154, 143, 161, 139,
1378 141, 142, 130, 131, 144, 144, 142, 141, 144, 142,
1379 132, 132, 141, 141, 150, 151, 139, 141, 151, 153,
1380 142, 142, 154, 154, 150, 150, 148, 148, 166, 165,
1381 143, 142, 144, 144, 132, 132, 142, 144, 130, 128,
1382 142, 142, 143, 143, 153, 153, 147, 142, 129, 125,
1383 142, 141, 143, 142, 143, 147, 105, 122, 135, 140,
1384 141, 140, 140, 140, 151, 151, 156, 155, 146, 146,
1385 133, 134, 140, 142, 142, 145, 141, 146, 112, 133,
1386 142, 142, 145, 145, 137, 138, 155, 157, 149, 150,
1387 144, 144, 139, 138, 130, 128, 132, 131, 147, 147,
1388 139, 140, 142, 143, 115, 121, 141, 143, 137, 141,
1389 146, 146, 150, 150, 145, 144, 133, 133, 133, 135,
1390 143, 144, 144, 144, 166, 167, 139, 142, 139, 140,
1391 150, 149, 138, 138, 142, 140, 148, 147, 160, 155,
1392 146, 146, 147, 147, 138, 137, 143, 142, 151, 150
1393};
1394
1395static const uint8_t wmavoice_dq_lsp16r2[0x500] = {
1396 98, 98, 119, 121, 109, 112, 128, 135, 115, 121,
1397 159, 113, 113, 106, 127, 114, 101, 102, 105, 111,
1398 161, 162, 137, 138, 161, 159, 152, 150, 150, 148,
1399 128, 79, 131, 102, 142, 120, 133, 119, 130, 117,
1400 121, 115, 142, 133, 186, 155, 179, 144, 169, 135,
1401 107, 103, 106, 106, 122, 122, 111, 112, 112, 115,
1402 127, 123, 118, 115, 128, 125, 123, 119, 115, 109,
1403 124, 130, 117, 126, 121, 133, 84, 144, 99, 114,
1404 122, 125, 123, 131, 124, 135, 176, 200, 158, 176,
1405 68, 74, 86, 87, 117, 115, 119, 116, 135, 128,
1406 115, 116, 102, 104, 119, 123, 133, 148, 102, 109,
1407 71, 121, 106, 117, 107, 127, 106, 122, 100, 110,
1408 117, 115, 129, 128, 87, 84, 116, 116, 151, 157,
1409 116, 128, 110, 117, 119, 134, 100, 114, 120, 129,
1410 142, 141, 146, 151, 94, 91, 114, 114, 118, 118,
1411 114, 112, 112, 109, 115, 112, 123, 123, 147, 148,
1412 110, 164, 106, 152, 110, 158, 106, 151, 105, 135,
1413 85, 51, 71, 27, 71, 34, 74, 45, 85, 53,
1414 145, 134, 140, 130, 136, 134, 118, 122, 118, 126,
1415 117, 84, 121, 81, 106, 80, 109, 106, 121, 127,
1416 95, 94, 112, 110, 90, 94, 109, 107, 114, 109,
1417 117, 118, 118, 123, 107, 107, 86, 93, 29, 31,
1418 125, 112, 104, 60, 121, 111, 127, 116, 133, 130,
1419 118, 117, 148, 145, 122, 126, 124, 127, 90, 91,
1420 113, 110, 119, 118, 152, 147, 115, 112, 132, 131,
1421 129, 140, 98, 112, 73, 85, 109, 115, 122, 126,
1422 123, 122, 122, 122, 126, 125, 137, 140, 203, 210,
1423 164, 176, 114, 114, 125, 122, 119, 112, 125, 120,
1424 124, 122, 118, 115, 95, 96, 141, 144, 132, 131,
1425 127, 130, 132, 134, 116, 114, 122, 123, 137, 134,
1426 111, 111, 112, 116, 106, 118, 77, 101, 104, 115,
1427 111, 111, 125, 126, 118, 121, 113, 115, 113, 113,
1428 171, 170, 202, 199, 221, 206, 199, 184, 177, 167,
1429 73, 90, 61, 93, 43, 74, 51, 71, 51, 72,
1430 130, 130, 140, 137, 134, 132, 164, 160, 118, 111,
1431 123, 136, 133, 154, 130, 158, 106, 110, 110, 114,
1432 97, 97, 91, 94, 70, 69, 125, 123, 141, 140,
1433 119, 100, 116, 77, 111, 67, 105, 52, 95, 34,
1434 100, 122, 90, 124, 68, 120, 43, 117, 50, 112,
1435 130, 129, 192, 188, 123, 118, 124, 117, 121, 115,
1436 122, 111, 129, 111, 157, 85, 125, 109, 125, 119,
1437 143, 152, 119, 128, 114, 116, 129, 136, 148, 157,
1438 119, 117, 115, 115, 150, 148, 163, 154, 109, 102,
1439 120, 126, 73, 119, 106, 121, 102, 122, 96, 113,
1440 84, 83, 117, 115, 122, 117, 154, 143, 159, 142,
1441 118, 122, 114, 117, 115, 122, 114, 130, 99, 156,
1442 123, 120, 122, 116, 100, 81, 99, 91, 121, 112,
1443 139, 131, 164, 142, 132, 119, 145, 133, 157, 141,
1444 112, 109, 118, 116, 142, 134, 108, 110, 96, 99,
1445 111, 110, 113, 112, 111, 104, 98, 94, 131, 131,
1446 115, 114, 121, 118, 120, 115, 173, 148, 123, 117,
1447 121, 124, 122, 124, 140, 146, 78, 82, 96, 93,
1448 86, 90, 124, 125, 121, 123, 105, 106, 134, 135,
1449 107, 109, 132, 141, 100, 95, 113, 114, 102, 105,
1450 113, 130, 98, 145, 116, 115, 124, 117, 115, 105,
1451 120, 123, 89, 87, 109, 108, 102, 101, 117, 117,
1452 113, 122, 132, 138, 77, 116, 86, 99, 118, 126,
1453 123, 120, 117, 111, 124, 119, 129, 118, 63, 58,
1454 141, 135, 108, 106, 109, 111, 108, 110, 135, 138,
1455 117, 114, 134, 127, 139, 129, 138, 130, 126, 122,
1456 121, 118, 124, 121, 133, 130, 98, 85, 130, 123,
1457 147, 129, 118, 112, 148, 130, 136, 123, 148, 131,
1458 113, 112, 123, 118, 123, 115, 147, 95, 117, 110,
1459 118, 119, 112, 113, 112, 113, 119, 119, 120, 120,
1460 158, 133, 198, 145, 188, 129, 197, 137, 195, 133,
1461 132, 140, 140, 139, 158, 156, 223, 217, 233, 233,
1462 48, 56, 34, 37, 82, 84, 102, 102, 108, 110,
1463 120, 142, 136, 169, 146, 195, 136, 186, 140, 182,
1464 196, 186, 158, 155, 142, 134, 132, 125, 120, 119,
1465 97, 105, 72, 75, 82, 85, 81, 84, 107, 109,
1466 67, 121, 43, 119, 69, 124, 87, 129, 88, 128,
1467 53, 57, 93, 98, 91, 94, 93, 98, 104, 104,
1468 124, 123, 133, 133, 182, 181, 119, 121, 114, 116,
1469 128, 105, 134, 112, 131, 72, 119, 59, 111, 84,
1470 132, 142, 145, 180, 124, 132, 131, 143, 122, 134,
1471 88, 85, 103, 103, 136, 140, 131, 143, 114, 132,
1472 116, 57, 113, 57, 121, 76, 126, 80, 118, 86,
1473 127, 112, 127, 97, 131, 100, 149, 91, 163, 86,
1474 122, 119, 128, 121, 128, 116, 142, 127, 173, 139,
1475 162, 116, 166, 107, 149, 103, 152, 107, 141, 108,
1476 114, 113, 118, 116, 56, 43, 90, 90, 105, 105,
1477 132, 134, 110, 107, 106, 105, 82, 84, 84, 84,
1478 102, 106, 79, 89, 99, 99, 127, 129, 114, 118,
1479 139, 157, 116, 123, 116, 123, 87, 89, 110, 113,
1480 119, 126, 97, 97, 155, 163, 142, 153, 143, 146,
1481 117, 114, 66, 67, 125, 126, 127, 128, 114, 113,
1482 111, 114, 127, 133, 123, 132, 143, 162, 133, 148,
1483 105, 108, 114, 114, 110, 109, 57, 48, 109, 106,
1484 113, 130, 104, 131, 88, 139, 102, 169, 100, 172,
1485 129, 114, 150, 97, 114, 112, 117, 119, 109, 116,
1486 92, 107, 96, 116, 90, 125, 101, 122, 125, 140,
1487 125, 133, 122, 129, 136, 153, 125, 135, 131, 139,
1488 84, 71, 129, 123, 135, 120, 114, 103, 112, 101,
1489 108, 121, 115, 156, 106, 123, 116, 131, 127, 139,
1490 137, 147, 109, 117, 119, 126, 135, 144, 117, 119,
1491 120, 127, 76, 105, 111, 116, 120, 125, 141, 138,
1492 107, 104, 162, 155, 135, 130, 127, 123, 127, 121,
1493 102, 104, 84, 87, 112, 115, 97, 102, 78, 82,
1494 119, 118, 120, 123, 91, 105, 114, 119, 119, 126,
1495 130, 126, 134, 126, 158, 134, 133, 99, 116, 100,
1496 125, 122, 145, 143, 126, 117, 98, 96, 121, 120,
1497 152, 148, 131, 126, 130, 129, 126, 119, 87, 87,
1498 131, 131, 139, 137, 101, 102, 104, 105, 86, 83,
1499 92, 89, 111, 105, 121, 115, 137, 124, 96, 84,
1500 100, 96, 122, 119, 107, 108, 93, 96, 79, 82,
1501 128, 123, 108, 106, 123, 120, 150, 150, 143, 140,
1502 121, 120, 97, 99, 79, 80, 116, 116, 88, 90,
1503 128, 131, 101, 97, 140, 140, 117, 116, 116, 118,
1504 137, 135, 100, 91, 115, 112, 134, 121, 107, 99,
1505 120, 122, 122, 125, 124, 126, 136, 141, 89, 95,
1506 103, 119, 103, 116, 122, 139, 125, 137, 152, 170,
1507 121, 122, 124, 124, 98, 97, 137, 140, 96, 92,
1508 115, 113, 136, 136, 128, 132, 122, 124, 151, 158,
1509 100, 107, 121, 131, 131, 158, 119, 130, 113, 114,
1510 114, 109, 148, 130, 103, 95, 127, 116, 137, 120,
1511 103, 108, 97, 97, 133, 128, 113, 109, 136, 128,
1512 125, 124, 118, 118, 122, 121, 101, 99, 157, 152,
1513 138, 134, 124, 115, 113, 101, 123, 112, 124, 110,
1514 116, 113, 128, 121, 119, 110, 124, 113, 128, 67,
1515 114, 118, 114, 123, 109, 121, 102, 123, 56, 116,
1516 117, 111, 112, 99, 124, 114, 112, 79, 114, 88,
1517 112, 113, 115, 117, 126, 127, 130, 132, 123, 122,
1518 111, 104, 111, 102, 112, 102, 129, 118, 129, 115,
1519 123, 124, 130, 133, 114, 117, 125, 127, 112, 117,
1520 124, 125, 119, 120, 117, 116, 105, 104, 110, 110,
1521 125, 124, 118, 116, 124, 123, 124, 121, 133, 132,
1522 111, 111, 124, 124, 120, 119, 116, 116, 134, 130,
1523 114, 116, 112, 113, 109, 111, 116, 118, 95, 98
1524};
1525
1526static const uint8_t wmavoice_dq_lsp16r3[0x600] = {
1527 84, 82, 95, 94, 125, 131, 98, 102, 94, 93, 104, 104,
1528 127, 113, 87, 77, 125, 114, 109, 94, 94, 91, 106, 105,
1529 168, 125, 163, 120, 128, 100, 119, 99, 108, 97, 108, 106,
1530 86, 85, 128, 125, 79, 73, 103, 102, 123, 123, 116, 117,
1531 84, 76, 135, 131, 133, 133, 129, 130, 125, 123, 115, 114,
1532 94, 97, 79, 81, 115, 115, 94, 93, 128, 127, 126, 125,
1533 124, 111, 105, 114, 104, 117, 109, 110, 124, 125, 118, 117,
1534 107, 110, 106, 110, 93, 93, 149, 148, 118, 119, 111, 110,
1535 147, 157, 143, 156, 134, 136, 118, 121, 106, 107, 105, 105,
1536 114, 83, 114, 46, 106, 53, 110, 83, 107, 94, 105, 103,
1537 92, 90, 109, 106, 172, 160, 114, 110, 109, 110, 110, 109,
1538 90, 98, 98, 109, 102, 98, 97, 92, 100, 100, 101, 102,
1539 123, 117, 124, 98, 82, 80, 117, 115, 112, 110, 109, 108,
1540 107, 111, 100, 115, 105, 120, 104, 105, 83, 82, 95, 96,
1541 109, 120, 72, 71, 97, 104, 69, 74, 99, 102, 118, 117,
1542 137, 133, 142, 135, 105, 110, 121, 121, 125, 122, 114, 112,
1543 151, 186, 115, 132, 103, 111, 100, 104, 99, 101, 104, 105,
1544 18, 38, 56, 65, 76, 83, 85, 91, 101, 103, 108, 110,
1545 144, 135, 126, 121, 115, 113, 79, 80, 118, 117, 117, 117,
1546 117, 124, 115, 115, 126, 113, 130, 116, 112, 106, 108, 105,
1547 77, 76, 76, 80, 109, 109, 125, 129, 130, 133, 116, 118,
1548 96, 86, 109, 99, 102, 69, 84, 69, 107, 103, 114, 113,
1549 78, 118, 82, 114, 84, 129, 69, 112, 78, 98, 96, 103,
1550 89, 137, 96, 111, 105, 97, 93, 93, 101, 105, 105, 105,
1551 141, 123, 102, 93, 91, 79, 87, 81, 102, 99, 109, 108,
1552 94, 92, 124, 123, 130, 134, 100, 107, 71, 75, 92, 91,
1553 94, 104, 107, 83, 106, 101, 113, 114, 122, 122, 114, 114,
1554 118, 124, 103, 106, 95, 116, 90, 93, 107, 104, 109, 107,
1555 116, 118, 76, 72, 88, 88, 132, 132, 140, 141, 116, 116,
1556 90, 81, 111, 95, 139, 97, 123, 96, 112, 100, 110, 108,
1557 112, 116, 133, 140, 112, 120, 80, 85, 55, 55, 85, 84,
1558 125, 94, 111, 104, 116, 103, 112, 86, 93, 84, 99, 98,
1559 180, 179, 197, 197, 169, 163, 149, 146, 130, 124, 116, 115,
1560 76, 47, 36, 11, 43, 28, 66, 53, 82, 80, 102, 99,
1561 119, 123, 176, 201, 113, 120, 112, 111, 103, 105, 106, 110,
1562 145, 114, 112, 89, 120, 93, 123, 104, 131, 123, 113, 111,
1563 97, 109, 82, 106, 75, 104, 103, 115, 120, 124, 111, 114,
1564 114, 111, 113, 105, 34, 33, 63, 63, 105, 106, 122, 122,
1565 51, 41, 96, 92, 125, 125, 118, 118, 118, 119, 113, 113,
1566 111, 180, 108, 178, 107, 171, 110, 160, 105, 136, 102, 117,
1567 76, 79, 90, 92, 80, 88, 88, 93, 123, 124, 122, 122,
1568 131, 128, 123, 122, 151, 158, 108, 107, 129, 128, 119, 119,
1569 97, 99, 114, 120, 121, 125, 151, 157, 82, 89, 95, 96,
1570 128, 94, 130, 95, 149, 113, 149, 120, 127, 115, 113, 109,
1571 167, 171, 83, 80, 84, 79, 106, 106, 112, 110, 107, 108,
1572 130, 139, 81, 88, 107, 106, 112, 112, 119, 118, 114, 112,
1573 108, 105, 100, 98, 120, 116, 122, 117, 38, 37, 72, 73,
1574 118, 125, 110, 120, 114, 126, 135, 142, 139, 142, 118, 119,
1575 119, 119, 156, 145, 78, 75, 94, 94, 112, 110, 113, 113,
1576 101, 108, 98, 104, 103, 109, 117, 118, 167, 167, 132, 132,
1577 116, 108, 118, 111, 149, 136, 85, 74, 95, 92, 113, 112,
1578 74, 69, 104, 107, 96, 100, 117, 121, 103, 105, 103, 103,
1579 110, 106, 111, 101, 82, 72, 96, 92, 132, 130, 120, 121,
1580 116, 113, 138, 139, 104, 103, 131, 131, 68, 69, 92, 92,
1581 97, 97, 146, 151, 122, 132, 97, 95, 117, 116, 115, 116,
1582 139, 134, 110, 110, 124, 129, 100, 110, 86, 91, 100, 102,
1583 116, 136, 88, 90, 137, 139, 103, 114, 114, 117, 111, 110,
1584 82, 83, 104, 102, 97, 99, 97, 97, 58, 56, 84, 84,
1585 83, 122, 76, 105, 112, 126, 120, 134, 112, 120, 108, 110,
1586 114, 128, 73, 90, 72, 76, 98, 100, 95, 96, 101, 102,
1587 101, 108, 118, 126, 94, 102, 81, 83, 138, 140, 131, 130,
1588 88, 100, 112, 124, 105, 106, 122, 123, 121, 121, 114, 114,
1589 76, 108, 73, 83, 93, 95, 110, 111, 98, 99, 103, 103,
1590 105, 112, 98, 108, 114, 95, 117, 98, 120, 116, 116, 115,
1591 231, 238, 150, 146, 124, 126, 115, 122, 117, 121, 112, 112,
1592 74, 73, 72, 74, 60, 61, 62, 61, 85, 85, 101, 101,
1593 67, 69, 50, 51, 83, 83, 110, 110, 118, 113, 112, 111,
1594 199, 124, 184, 115, 176, 117, 165, 120, 138, 115, 116, 114,
1595 52, 116, 36, 107, 49, 99, 72, 106, 91, 107, 104, 105,
1596 140, 138, 141, 135, 154, 147, 166, 159, 139, 136, 116, 115,
1597 130, 119, 180, 157, 183, 149, 136, 121, 119, 114, 111, 110,
1598 104, 129, 113, 154, 111, 148, 108, 132, 105, 117, 106, 111,
1599 114, 35, 99, 65, 113, 94, 110, 98, 111, 107, 107, 106,
1600 106, 110, 128, 135, 162, 175, 143, 155, 115, 116, 109, 109,
1601 168, 155, 112, 109, 125, 125, 126, 122, 126, 124, 111, 112,
1602 128, 96, 160, 77, 151, 77, 121, 80, 114, 94, 107, 103,
1603 97, 104, 101, 116, 56, 79, 74, 83, 92, 95, 104, 106,
1604 63, 68, 76, 77, 110, 107, 96, 90, 85, 83, 97, 96,
1605 116, 110, 46, 42, 103, 100, 122, 120, 102, 101, 104, 104,
1606 106, 101, 109, 98, 96, 61, 67, 35, 72, 61, 96, 93,
1607 88, 80, 81, 76, 113, 110, 144, 143, 88, 89, 93, 94,
1608 95, 96, 100, 101, 136, 132, 166, 160, 148, 147, 115, 116,
1609 80, 78, 130, 129, 120, 108, 91, 85, 95, 91, 104, 102,
1610 151, 147, 106, 109, 110, 110, 64, 69, 68, 67, 96, 96,
1611 90, 166, 97, 128, 99, 120, 104, 121, 109, 118, 105, 109,
1612 122, 138, 110, 143, 75, 97, 83, 94, 89, 94, 102, 103,
1613 136, 142, 103, 110, 83, 89, 99, 101, 138, 138, 120, 122,
1614 168, 88, 105, 90, 109, 107, 110, 111, 106, 105, 103, 102,
1615 68, 72, 102, 104, 92, 102, 65, 75, 89, 94, 106, 106,
1616 83, 74, 93, 85, 73, 66, 106, 102, 100, 92, 99, 97,
1617 93, 99, 101, 96, 116, 112, 125, 120, 88, 88, 96, 96,
1618 44, 98, 93, 115, 104, 116, 103, 107, 112, 113, 107, 107,
1619 93, 83, 105, 99, 93, 84, 127, 125, 141, 143, 117, 118,
1620 106, 103, 126, 121, 137, 123, 123, 114, 147, 142, 127, 123,
1621 103, 110, 89, 91, 121, 124, 66, 71, 68, 69, 96, 97,
1622 114, 105, 68, 65, 69, 67, 96, 94, 131, 130, 123, 121,
1623 111, 104, 130, 121, 95, 95, 72, 74, 88, 88, 105, 104,
1624 135, 124, 110, 98, 114, 111, 159, 158, 111, 113, 104, 106,
1625 103, 108, 94, 107, 55, 57, 115, 118, 121, 122, 111, 111,
1626 97, 99, 106, 111, 119, 126, 59, 62, 111, 112, 124, 125,
1627 86, 93, 100, 110, 118, 145, 113, 132, 120, 125, 112, 112,
1628 101, 115, 78, 149, 81, 114, 111, 121, 108, 112, 107, 108,
1629 104, 104, 94, 96, 84, 83, 135, 132, 71, 69, 88, 86,
1630 100, 98, 62, 60, 81, 80, 90, 89, 63, 66, 89, 90,
1631 123, 116, 108, 99, 90, 86, 91, 92, 65, 65, 88, 88,
1632 84, 79, 115, 109, 123, 111, 99, 99, 134, 136, 121, 123,
1633 127, 137, 84, 88, 104, 107, 128, 130, 74, 69, 89, 89,
1634 118, 112, 143, 132, 141, 131, 113, 113, 99, 102, 104, 105,
1635 117, 115, 100, 99, 131, 126, 90, 88, 145, 144, 128, 127,
1636 112, 114, 131, 133, 85, 84, 118, 119, 151, 152, 117, 117,
1637 110, 105, 162, 140, 116, 107, 140, 134, 124, 122, 113, 113,
1638 107, 110, 124, 133, 98, 103, 99, 107, 109, 113, 112, 112,
1639 115, 105, 82, 77, 125, 122, 133, 132, 118, 120, 113, 113,
1640 101, 88, 84, 80, 97, 99, 91, 91, 94, 94, 101, 100,
1641 121, 86, 139, 108, 106, 93, 103, 99, 112, 108, 108, 107,
1642 113, 83, 105, 102, 125, 125, 114, 115, 110, 112, 108, 109,
1643 93, 112, 113, 121, 125, 131, 101, 101, 107, 109, 111, 111,
1644 98, 102, 117, 126, 80, 84, 107, 109, 83, 84, 96, 97,
1645 132, 136, 112, 118, 94, 93, 121, 118, 99, 98, 102, 103,
1646 122, 127, 128, 133, 118, 104, 102, 88, 100, 94, 104, 102,
1647 115, 116, 102, 105, 140, 142, 135, 130, 90, 88, 100, 101,
1648 94, 86, 112, 112, 89, 121, 92, 101, 109, 108, 110, 112,
1649 99, 93, 129, 114, 109, 99, 131, 119, 102, 97, 103, 103,
1650 103, 116, 124, 101, 115, 95, 105, 101, 94, 91, 100, 100,
1651 113, 90, 94, 86, 92, 92, 117, 111, 106, 103, 106, 105,
1652 115, 99, 110, 91, 107, 104, 81, 90, 108, 113, 112, 113,
1653 113, 114, 93, 101, 101, 102, 101, 126, 93, 103, 104, 105,
1654 117, 106, 124, 107, 104, 119, 108, 133, 104, 111, 104, 106
1655};
1656
1657static const float wmavoice_lsp10_intercoeff_a[32][2][10] = {
1658 { { 0.5108627081, 0.0480548441, -1.5099149644, 0.6736935377,
1659 0.7536551058, 0.7651474178, 0.8510628343, 0.6667704582,
1660 0.7576012611, 0.7091397047 },
1661 { 0.1351471841, -0.1965375543, -1.6313457787, 0.3218626380,
1662 0.4132472873, 0.4663473070, 0.5805781186, 0.3962165117,
1663 0.4818550050, 0.4907165468 } },
1664 { { 0.8556320667, 0.7774704993, -0.0175759494, -0.1882298589,
1665 0.1892164350, 0.4850396216, 0.6270319819, 0.6327089071,
1666 0.6513319910, 0.6075088978 },
1667 { 0.4374088347, 0.3505934179, -0.0762144327, -0.2830760479,
1668 -0.0626451969, 0.1500318050, 0.2602472305, 0.2781780064,
1669 0.3167395592, 0.3596626520 } },
1670 { { 0.1899779737, 0.0650856197, 0.1699010432, 0.9122628570,
1671 0.9097705483, 0.7433397174, 0.6304935217, 0.5164704025,
1672 0.4174703658, 0.5215242505 },
1673 { 0.0704856217, 0.0169009864, 0.0188394487, 0.5587704182,
1674 0.5194473267, 0.3539164960, 0.2426626086, 0.1721164286,
1675 0.1371548772, 0.2594856918 } },
1676 { { 0.8858859241, 0.9100474715, 0.8921859264, 0.9332397878,
1677 1.0225475132, 1.0555013716, 1.0983552337, 1.1290244758,
1678 1.0363244414, 0.9277705550 },
1679 { 0.4810934663, 0.5782935023, 0.6835935414, 0.7650781870,
1680 0.9018090069, 0.9996321201, 1.0219936669, 1.0474705994,
1681 0.9109474719, 0.7774704993 } },
1682 { { 0.4359549880, 0.2275702953, 0.0993548632, 0.1763395071,
1683 0.1055856347, 0.1018471718, 0.1170087159, 0.1221317947,
1684 0.1834010482, 0.2988780141 },
1685 { 0.1573702693, 0.1041317880, 0.0506856143, 0.0781702399,
1686 0.0058932900, -0.0026913285, -0.0031067133, 0.0070702136,
1687 0.0116394460, 0.0566394627 } },
1688 { { 0.8528628349, 0.8028782010, 0.4680088460, 0.9055474699,
1689 1.3742399514, 1.1093629301, 0.4122780561, 0.4003703594,
1690 0.6360319853, 0.6415704489 },
1691 { 0.4252934456, 0.3823703527, 0.1676856577, 0.5241550207,
1692 1.1995706558, 0.9088013172, 0.1224087179, 0.0730471611,
1693 0.3071857095, 0.3772472739 } },
1694 { { 0.5508781075, 0.2829549313, -0.0022067130, 0.1042702496,
1695 1.0318244398, 1.3258476257, 1.3550630212, 0.9931936562,
1696 0.7195243239, 0.6807550788 },
1697 { 0.2679318488, 0.0960317850, -0.1357529163, -0.1291759908,
1698 0.6451012194, 0.9968628883, 0.9510321021, 0.6608166099,
1699 0.3799472749, 0.3735780418 } },
1700 { { 0.9967244267, 1.0255244374, 0.9800398052, 0.7939474285,
1701 0.8288397491, 0.8390166759, 0.8660166860, 0.9247936308,
1702 0.9127474725, 0.8684397638 },
1703 { 0.7921474278, 0.9416859448, 0.8547320664, 0.5348165631,
1704 0.6231550574, 0.6703012288, 0.6987550855, 0.8147858977,
1705 0.7406397164, 0.6496012211 } },
1706 { { 0.1439394951, -0.3193529844, -0.2024914026, -0.1854606271,
1707 0.0877240896, 0.1617318094, 0.3087087870, 0.3777318895,
1708 0.3910242021, 0.4797780812 },
1709 { -0.0157067180, -0.1778452396, -0.1554836929, -0.1759760082,
1710 -0.0607759655, -0.0161221027, 0.0393317640, 0.0758856237,
1711 0.1163856387, 0.1947548985 } },
1712 { { 1.1021629274, 0.9958244264, 0.4658626914, 0.3089164793,
1713 0.3740626574, 0.2962472439, 0.3170857131, 0.2420395315,
1714 0.2649549246, 0.2936857045 },
1715 { 0.4700857699, 0.1809087396, 0.0311625302, 0.0106009841,
1716 0.0311625302, 0.0266625285, 0.0221625268, 0.0156548321,
1717 0.0551163852, 0.1010164022 } },
1718 { { 0.2925087810, 0.3418011069, 0.7339243293, 0.7322627902,
1719 0.7288704813, 0.7924935818, 0.7724166512, 0.7819012702,
1720 0.8325782120, 0.7954705060 },
1721 { 0.0559471548, -0.0456144214, -0.0462374985, -0.1005144417,
1722 -0.0511528850, -0.0455451906, -0.0044220984, 0.0451471508,
1723 0.1232394874, 0.2085318267 } },
1724 { { 0.2230702937, -0.9052532017, 1.2441552877, 1.0825706124,
1725 0.9088705480, 0.8797243834, 0.8648397624, 0.8091089725,
1726 0.7633474171, 0.7468704879 },
1727 { -0.2030452490, -1.4167303145, 1.3542322516, 0.8369397521,
1728 0.6148473620, 0.5560704172, 0.5450627208, 0.4978473186,
1729 0.4200319052, 0.4904396236 } },
1730 { { 0.6088242829, 0.5965704322, 0.6547242999, 0.8554936051,
1731 -0.2989298999, 0.2404472232, 0.3573780358, 0.7499166429,
1732 0.7691628039, 0.6824858487 },
1733 { 0.2582395375, 0.2721549273, 0.3462318778, 0.4820626974,
1734 -0.4780299664, -0.0712990463, 0.0200163722, 0.4246703684,
1735 0.4660011530, 0.4172626734 } },
1736 { { 1.1749937236, 1.0773090720, 1.0566782951, 1.0249013603,
1737 0.9947167337, 0.9626628757, 0.9562244117, 0.9072782397,
1738 0.7654243410, 0.6448935270 },
1739 { 1.1595552564, 0.9340013266, 0.3959395885, 0.3693549633,
1740 0.3915780485, 0.3104395568, 0.3499011099, 0.2236933708,
1741 0.1638087332, 0.1811856627 } },
1742 { { 0.9572628736, 0.9389859438, 0.6619243026, 0.6849089265,
1743 0.7276935577, 0.7839781940, 0.7987243533, 0.7748397291,
1744 0.7101089358, 0.7277627885 },
1745 { 0.5809935033, 0.5575934947, 0.3544703424, 0.3636780381,
1746 0.3736472726, 0.4486242235, 0.4684934616, 0.4481396079,
1747 0.3456780314, 0.4478626847 } },
1748 { { 0.1259394884, 1.3096476197, 1.0794552267, 1.0009475052,
1749 0.9061013162, 0.9216782451, 0.8954397738, 0.9160013199,
1750 0.8575012982, 0.7479089499 },
1751 { -0.3689222336, 1.5293861628, 0.7323320210, 0.4102703631,
1752 0.3825780451, 0.2828164697, 0.2644010782, 0.2455010712,
1753 0.2482010722, 0.2335241437 } },
1754 { { 0.5380704105, 0.1600702703, -0.0657605827, -0.2390452623,
1755 -0.3885837793, -0.4150299430, -0.3001760542, -0.1451683044,
1756 0.1312010288, 0.2798395455 },
1757 { 0.2074933648, 0.0560163856, -0.0956682861, -0.2893068194,
1758 -0.3889991641, -0.3918376267, -0.3550068438, -0.2649375796,
1759 -0.0554451942, 0.1167317927 } },
1760 { { 0.6092396677, 0.5101011693, 0.4012011290, 0.5416011810,
1761 0.5715781152, 0.6476627588, 0.6988243163, 0.7306012511,
1762 0.7531704903, 0.6534781456 },
1763 { 0.2060395181, 0.1409625709, 0.1024702489, 0.1834010482,
1764 0.1946856678, 0.2547779977, 0.3134857118, 0.3283011019,
1765 0.3837549686, 0.3501780331 } },
1766 { { 0.4516011477, 0.5351627171, 0.8068243563, 0.7049858570,
1767 0.7165473998, 0.6005858183, 0.4870473146, 0.2500010729,
1768 0.3132087886, 0.4462703764 },
1769 { 0.1053087115, 0.1348702610, 0.4457857609, 0.3499703407,
1770 0.3537780344, 0.2628780007, 0.1665087342, 0.0200856030,
1771 0.0329625309, 0.1525241137 } },
1772 { { 0.7058166265, 0.7305320203, 1.1684860289, 1.4524707496,
1773 1.3212091625, 1.2613245249, 1.1712552607, 1.1154552400,
1774 1.0487167537, 0.9153782427 },
1775 { 0.2286087573, 0.2851703167, 1.2016475797, 1.5154707730,
1776 1.2726091444, 1.1459167898, 0.9801090360, 0.9296397865,
1777 0.8490551412, 0.6772243083 } },
1778 { { 0.6686396897, 0.5728935003, 0.4734780788, 0.6970243156,
1779 0.5852165818, -0.0762836635, -0.2054683268, -0.1380375326,
1780 0.1282933354, 0.3467164934 },
1781 { 0.2925087810, 0.2344933748, 0.1677548885, 0.2747856975,
1782 0.2097087502, -0.2795452774, -0.3761222363, -0.3183837533,
1783 -0.0834836662, 0.1482318044 } },
1784 { { 0.6559704542, 0.7737320364, 0.9867551923, 0.9912551939,
1785 0.9508936405, 0.9114320874, 0.8336859047, 0.7905551195,
1786 0.7672935724, 0.7532397211 },
1787 { 0.1843702793, 0.2565087676, 0.7571858764, 0.7545551062,
1788 0.6793704629, 0.5981627405, 0.5078165531, 0.4282011390,
1789 0.3948318958, 0.4502165318 } },
1790 { { 0.4430857599, 0.6102781296, 0.8485012949, 0.8573628366,
1791 0.9078320861, 0.9979705811, 1.0411013663, 1.0524552166,
1792 1.0194321275, 0.9023628533 },
1793 { 0.0070009828, 0.0084548295, 0.1613856554, 0.3484472632,
1794 0.4385857582, 0.5895088911, 0.6367935240, 0.6736935377,
1795 0.7026320100, 0.5924165845 } },
1796 { { 1.0532859862, 1.1059706211, 1.1311013997, 1.1250783205,
1797 1.0425552130, 0.9993551970, 0.9673013389, 0.9386397898,
1798 0.8836013079, 0.8336859047 },
1799 { 0.9791398048, 1.1481321752, 1.1275706291, 1.0082167387,
1800 0.8809705377, 0.8031551242, 0.7287320197, 0.6496704519,
1801 0.5211088657, 0.4734088480 } },
1802 { { -0.0251221061, -0.0443682671, 0.1282241046, 0.3850703537,
1803 0.4252934456, 0.4547857642, 0.4690473080, 0.4873242378,
1804 0.6001012027, 0.5882627368 },
1805 { -0.0562759638, -0.0246374905, 0.0070009828, 0.0971394777,
1806 0.1232394874, 0.1278779507, 0.1302317977, 0.1462241113,
1807 0.2073549032, 0.2446010709 } },
1808 { { 1.1749244928, 1.1155937016, 0.9236167073, 0.6288319826,
1809 0.6515396833, 0.5391781032, 0.5398011804, 0.4997165501,
1810 0.4066703618, 0.3998857439 },
1811 { 0.9403013289, 0.7346166372, 0.1841625869, 0.1319625676,
1812 0.1395087242, 0.0857856274, 0.0952702463, 0.0860625505,
1813 0.0829471648, 0.1132010221 } },
1814 { { 0.9047167003, 0.9840551913, 0.9933321178, 0.9360090196,
1815 0.9164859354, 0.9213320911, 0.8701705337, 0.8815936148,
1816 0.8414397538, 0.8188012838 },
1817 { 0.0961010158, -0.0147374868, 0.0202240646, 0.1002548635,
1818 0.1407548785, 0.1837472022, 0.1858241260, 0.2064549029,
1819 0.2228626013, 0.2859318554 } },
1820 { { 0.4034165144, 0.1918472052, 2.1959402561, 0.4763165414,
1821 0.6577012241, 0.7036704719, 0.6626858413, 0.7650089562,
1822 0.7702704966, 0.6543781459 },
1823 { 0.0940933228, -0.1222529113, 2.3491480052, 0.1385394931,
1824 0.3052472472, 0.3665857315, 0.3350857198, 0.4722319245,
1825 0.4313857555, 0.3846549690 } },
1826 { { 0.8215012848, 0.8613782227, 1.0399936736, 1.4082322717,
1827 0.4075011313, 0.4091626704, 0.5230473280, 0.6101396680,
1828 0.7510243356, 0.7237474024 },
1829 { 0.4810934663, 0.5670088828, 0.9207782447, 1.3007860780,
1830 0.0453548431, 0.0858548582, 0.1803548932, 0.2790087759,
1831 0.3974626660, 0.4581780732 } },
1832 { { 1.5921784937, 1.4987169206, 1.1321398616, 0.8235089779,
1833 0.6888550818, 0.6621319950, 0.6192089021, 0.6533396840,
1834 0.7196627855, 0.6549319923 },
1835 { 1.5911400318, 1.4768399894, 0.9358705580, 0.4674549997,
1836 0.3522549570, 0.3144549429, 0.2985318601, 0.3559241891,
1837 0.4061857462, 0.3958703578 } },
1838 { { 0.7975474298, 0.8712782264, 0.8974474669, 0.3008164763,
1839 0.5562088788, 0.6655935347, 0.8921166956, 1.0918475389,
1840 0.9544936419, 0.8554936051 },
1841 { 0.3769703507, 0.4930703938, 0.6619243026, -0.0382759571,
1842 0.1766856611, 0.3015780151, 0.5952550471, 0.8903859258,
1843 0.7395320237, 0.6205935180 } },
1844 { { 0.2206472158, 2.4467634261, 1.2920629978, 1.0239321291,
1845 0.9014628530, 0.8552166820, 0.8219859004, 0.9005628526,
1846 0.7614781857, 0.7763628066 },
1847 { -0.2722068131, 2.8967635930, 1.3039706945, 0.7695089579,
1848 0.6132550538, 0.5701242685, 0.5737935007, 0.6533396840,
1849 0.5422934890, 0.5150857866 } },
1850};
1851
1852static const float wmavoice_lsp10_intercoeff_b[32][2][10] = {
1853 { { 0.4881048799, -0.1998192370, -0.3872502148, 0.0109423101,
1854 0.0406953394, 0.1788437665, 0.1673750877, 0.3409781158,
1855 0.4061202109, 0.5221177042 },
1856 { 0.1492218077, -0.1372330189, -0.2683691680, -0.0621950924,
1857 -0.0624572337, -0.0068177581, -0.0076041818, 0.0680235624,
1858 0.1055752933, 0.1199930608 } },
1859 { { 0.7934338748, 0.0012430847, 0.4239458144, 0.5521328747,
1860 0.6497149467, 0.6423749924, 0.7170197070, 0.7169541717,
1861 0.7778364718, 0.8397018015 },
1862 { 0.2768190503, -0.0491535664, -0.0325731337, 0.0261465013,
1863 0.0469867289, 0.0649434030, 0.0781815350, 0.1031504869,
1864 0.1194687784, 0.2451654971 } },
1865 { { 0.7212139666, 0.1658677757, 0.0101558864, 0.5636015534,
1866 1.3175852597, 1.1911676526, 1.1266809106, 0.8230558336,
1867 0.8604109585, 0.8094900250 },
1868 { 0.3658815324, 0.0816549063, -0.2092563212, 0.1946377754,
1869 1.0856558084, 0.9491457641, 0.8461242616, 0.5193652213,
1870 0.5975488424, 0.5293265879 } },
1871 { { 0.9507186115, 0.9078585207, 0.8773190677, 0.8677509129,
1872 0.8024122119, 0.8127667904, 0.8246286809, 0.8779088855,
1873 0.9454102516, 0.9863698184 },
1874 { 0.6883807778, 0.6900191605, 0.7059442401, 0.6552854478,
1875 0.5843107104, 0.5553441048, 0.5887671113, 0.6494528055,
1876 0.7725936472, 0.7792782485 } },
1877 { { 0.2399882078, 0.1938513517, 0.4441962242, 0.4475385249,
1878 0.3055235147, 0.1745184362, 0.1174371839, 0.0679580271,
1879 0.0782470703, 0.1695377529 },
1880 { 0.0170370936, 0.0253600776, 0.2072205544, 0.1907711923,
1881 0.1096384823, 0.0327000320, -0.0134368241, -0.0461389422,
1882 -0.0372916758, -0.0243156850 } },
1883 { { 0.5457104146, 0.3774812818, 0.5235594809, 0.2994287312,
1884 0.2394639254, 0.5731041729, 0.9971176088, 1.1646913886,
1885 0.9028123021, 0.7777709365 },
1886 { 0.2288472056, 0.1181580722, 0.2074171603, 0.0355180502,
1887 -0.0024924278, 0.2596487999, 0.7474936247, 0.9103488624,
1888 0.5927647650, 0.4772915542 } },
1889 { { 0.6541713476, 0.6412608922, 0.7625012100, 0.7826205492,
1890 0.4839106202, 0.3311478198, 0.4577620327, 0.8572652638,
1891 0.9442306161, 0.8282986581 },
1892 { 0.2852075696, 0.2614837885, 0.4221763611, 0.4314823747,
1893 0.1434547007, 0.0435788929, 0.1397191882, 0.5525916219,
1894 0.6752081811, 0.5487250388 } },
1895 { { 0.6742251515, 1.0610800683, 1.0500701368, 0.9570100009,
1896 0.9325653315, 0.9243078828, 0.9148707986, 0.8317720294,
1897 0.7696445584, 0.6784849465 },
1898 { 0.2283884585, 0.9739181101, 0.5336519182, 0.4974764287,
1899 0.3998288214, 0.3674543798, 0.2719694376, 0.2608939707,
1900 0.2087934017, 0.1675716937 } },
1901 { { 0.3736146986, -1.5457833707, 0.9216864705, 0.7959242165,
1902 0.7358283401, 0.7233110964, 0.7271121442, 0.6852350831,
1903 0.6891672015, 0.6589554250 },
1904 { 0.1246460676, -1.7167649865, 0.7037160397, 0.4803061783,
1905 0.4694928527, 0.4654951990, 0.5208069980, 0.5305717587,
1906 0.5288023055, 0.5278192759 } },
1907 { { 1.0116009116, 0.9882703424, 0.8393741250, 0.8889843524,
1908 0.8934407532, 0.8906227350, 0.9222107530, 0.8973073363,
1909 0.9257496595, 0.9306648076 },
1910 { 0.5097970665, -0.0106843412, 0.1419473886, 0.2804890275,
1911 0.3719763160, 0.3694859743, 0.4640534222, 0.5034401417,
1912 0.5592106879, 0.6652468145 } },
1913 { { 0.9718209803, 0.7615181804, 0.2172474563, 0.4920369983,
1914 0.4310891628, 0.5038333535, 0.4668059051, 0.5339140594,
1915 0.4453758597, 0.4050061107 },
1916 { 0.6543679535, 0.1205173433, -0.0050483048, 0.1580035388,
1917 0.1308719218, 0.1700620353, 0.1740596890, 0.2179683447,
1918 0.1967349052, 0.1703897119 } },
1919 { { 0.7663022578, 0.4025157690, 1.3811545074, 1.1642981768,
1920 1.0709758997, 0.9812580645, 1.0092416406, 0.9089070857,
1921 0.7776398659, 0.8189926445 },
1922 { 0.3471384346, 0.0602248609, 1.3968829811, 1.0841484964,
1923 0.8940305710, 0.7313719392, 0.7345176339, 0.5304406881,
1924 0.4076275229, 0.4535677731 } },
1925 { { 0.1300854981, 0.1323136985, 0.7564064264, 0.7335346043,
1926 0.7924508452, 0.6039057672, 0.6896914840, 0.3694859743,
1927 0.2825861573, 0.3179096878 },
1928 { -0.0208423138, -0.0530856848, 0.3449102342, 0.3819376826,
1929 0.4466865659, 0.2807511687, 0.3842969537, 0.1144880950,
1930 0.0617321730, 0.0767397583 } },
1931 { { 0.7559476793, 0.8462553322, 0.6452585459, 1.1308751702,
1932 1.0606868565, 0.9498666525, 0.7425129414, 0.6221901178,
1933 0.6574481130, 0.6976212561 },
1934 { 0.3420922160, 0.4310236275, 0.2800958157, 0.9317133725,
1935 0.8210897744, 0.6144569516, 0.3227593005, 0.2464762032,
1936 0.2769501209, 0.3521846533 } },
1937 { { 0.7609938979, 0.6943444908, 1.1490939856, 0.4350868165,
1938 0.6101971567, 0.6246149242, 0.7370079756, 0.6522052884,
1939 0.6966382265, 0.7565374970 },
1940 { 0.3939306438, 0.3449102342, 0.9874839187, 0.0910919905,
1941 0.2804234922, 0.2888775468, 0.4060546756, 0.3284608722,
1942 0.3483836055, 0.4819445610 } },
1943 { { 0.7828826904, 1.1833034158, 1.9916158915, 0.8667678833,
1944 0.9218830764, 0.8856420517, 0.9373494089, 0.7415299118,
1945 0.7450032830, 0.7074515522 },
1946 { 0.4685098231, 1.1713104546, 1.9853245020, 0.6206828058,
1947 0.6664264500, 0.6033814847, 0.6089519858, 0.3784643114,
1948 0.4212588668, 0.3441893458 } },
1949 { { 0.4671335816, 0.4177199602, 0.0804097354, -0.1836975515,
1950 -0.1802241802, -0.0775958896, -0.0250365734, 0.0884050429,
1951 0.2136430144, 0.3472039700 },
1952 { 0.1187478900, 0.1122598946, -0.0381436348, -0.2284581661,
1953 -0.2302276194, -0.1738672554, -0.1350048184, -0.0547896028,
1954 0.0000634491, 0.0545888245 } },
1955 { { 0.5545576811, 0.4791920781, 0.8204999566, 0.8462553322,
1956 0.9212277234, 0.8946203887, 0.9659883380, 0.9137566984,
1957 0.9225384295, 0.9207034409 },
1958 { 0.1176993251, -0.0429277122, -0.0330318809, 0.0566859543,
1959 0.0983008742, 0.1593797803, 0.1732077301, 0.2320584357,
1960 0.2739354968, 0.3753186166 } },
1961 { { 0.7157745361, 0.6367389560, -1.2036890686, 0.7107283175,
1962 0.6885118484, 0.7332724631, 0.7436270416, 0.7113181353,
1963 0.5935511887, 0.6023984551 },
1964 { 0.3664058149, 0.3280676603, -1.3082178831, 0.3909815550,
1965 0.3641776145, 0.3926854730, 0.3898674548, 0.4086760879,
1966 0.3127979338, 0.3949792087 } },
1967 { { 1.0267395675, 1.0621941686, 1.0415505469, 0.9971176088,
1968 0.9764739871, 0.9904330075, 0.9591071308, 0.9338760376,
1969 0.9026156962, 0.9073997736 },
1970 { 0.9855833948, 1.0548542142, 0.9787021875, 0.8573307991,
1971 0.8360973597, 0.8193203211, 0.7386463583, 0.7038471103,
1972 0.6333966553, 0.6434235573 } },
1973 { { 0.6235008240, 0.7635497749, 0.8094900250, 0.7227212787,
1974 -0.0610809922, -0.1357912421, -0.2359291911, 0.0800165236,
1975 0.3972729445, 0.5078965425 },
1976 { 0.2983146310, 0.4983939230, 0.4145742655, 0.3284608722,
1977 -0.3203386664, -0.3495018780, -0.4734291434, -0.1808139980,
1978 0.1211071610, 0.2001427412 } },
1979 { { 0.8925887942, 0.8804647624, 0.6153089106, 0.6760601401,
1980 0.7887153327, 1.0065546930, 1.0829033256, 1.0347348750,
1981 0.9800128937, 0.9125770628 },
1982 { 0.5955827832, 0.6195687056, 0.2924164534, 0.3553958833,
1983 0.5417127609, 0.8713553548, 0.9977729619, 0.8817754686,
1984 0.7645328045, 0.6604627371 } },
1985 { { 1.1581378579, 1.0359145105, 0.7731179297, 0.6839243770,
1986 0.6839899123, 0.6664264500, 0.6910677254, 0.6579068601,
1987 0.6779606640, 0.6243527830 },
1988 { 1.1508634388, 0.8400294781, 0.2358594835, 0.2542749047,
1989 0.2484422624, 0.2620736063, 0.2676441073, 0.2713796198,
1990 0.3068997562, 0.3223005533 } },
1991 { { 0.1376220584, 1.2572927773, 0.8593623936, 0.6218624413,
1992 0.5128116906, 0.5393534899, 0.4436064065, 0.4334484339,
1993 0.4494390488, 0.4002220333 },
1994 { -0.1159995794, 1.2433337569, 0.4805027843, 0.2632532418,
1995 0.1769432425, 0.1868390739, 0.1555131972, 0.1530228555,
1996 0.1490252018, 0.1559064090 } },
1997 { { 0.1817273200, -0.0085216761, 0.0739872754, 0.1808098257,
1998 0.2770811915, 0.3344901204, 0.4292541742, 0.5404020548,
1999 0.5780193210, 0.5707449019 },
2000 { -0.0035409927, -0.0188107193, -0.0057691932, 0.0132360458,
2001 0.0560961366, 0.0534747243, 0.1002013981, 0.1737320125,
2002 0.1706518531, 0.1637706459 } },
2003 { { 0.9648087025, 1.0030813217, 0.9501943290, 0.8381944895,
2004 0.7545059025, 0.7621735334, 0.7121700943, 0.7328792512,
2005 0.7534573376, 0.7414643764 },
2006 { 0.1872322857, -0.0081939995, 0.0663851798, 0.0963348150,
2007 0.0509188473, 0.0565548837, 0.0471833348, 0.0809340179,
2008 0.1049199402, 0.1751082540 } },
2009 { { 0.6792713702, 0.9521603882, 0.5296542645, 0.3657504618,
2010 0.3905883431, 0.3121425807, 0.2726903260, 0.3156159520,
2011 0.2859284580, 0.3179096878 },
2012 { 0.2307477295, 0.3771536052, 0.0743804872, 0.0260154307,
2013 0.0477731526, 0.0391880274, 0.0228042006, 0.0572757721,
2014 0.0337485969, 0.0492149293 } },
2015 { { 0.8649328947, 0.9505875409, 1.0443030298, 1.1704584956,
2016 1.2709241211, 1.3232212961, 1.2477901578, 1.1513877213,
2017 1.0346038043, 0.9695272446 },
2018 { 0.4620873630, 0.5685822368, 0.8975039423, 1.0476453304,
2019 1.2278674245, 1.2290470600, 1.1962138712, 1.0051129162,
2020 0.8706344664, 0.7477557659 } },
2021 { { 0.4188340604, 0.6011532843, 0.4726385474, 0.6389671564,
2022 0.6753392518, 0.7842589319, 0.6147846282, 0.6708828509,
2023 0.6406055391, 0.5398777723 },
2024 { 0.1012499630, 0.2312064767, 0.1773364544, 0.2800302804,
2025 0.3348177969, 0.4343003929, 0.2822584808, 0.3293128312,
2026 0.3024433553, 0.2401848137 } },
2027 { { 0.5049474537, 0.7943513691, 0.9536021650, 0.9407572448,
2028 0.9823721647, 0.9747045338, 1.0145500004, 0.9629737139,
2029 0.9526191354, 0.9283710718 },
2030 { 0.0566204190, 0.0973178446, 0.5812305510, 0.5687133074,
2031 0.6834000945, 0.6616423726, 0.7611905038, 0.6683925092,
2032 0.6463071108, 0.6118355393 } },
2033 { { 0.8969141245, 0.9359731674, 0.8756151497, 0.8419300020,
2034 0.8353109360, 0.6807131469, 0.3358008265, 0.3386188447,
2035 0.3524467945, 0.4495045841 },
2036 { 0.5298508704, 0.4606455863, 0.4934132397, 0.4415748119,
2037 0.4015327394, 0.2052544951, -0.0329663455, -0.0154684186,
2038 0.0418094397, 0.1631152928 } },
2039 { { 0.6345762908, 2.5209445655, 1.0373562872, 0.9166402519,
2040 0.8865595460, 0.8907538056, 0.8522190452, 0.7290782034,
2041 0.7385808229, 0.6345107555 },
2042 { 0.2641707361, 2.5696372986, 0.8539884984, 0.6532538533,
2043 0.6087553799, 0.5851626694, 0.5276226699, 0.4330552220,
2044 0.3971418738, 0.3599833548 } },
2045};
2046
2047static const float wmavoice_lsp16_intercoeff_a[32][2][16] = {
2048 { { 0.5337238312, 0.4810695648, -0.3766536713, -0.1204767227,
2049 -0.0898437500, -0.0070896149, 0.1134738922, 0.1337728500,
2050 0.3739156723, 0.3849058151, 0.4220180511, 0.5404901505,
2051 0.5224876404, 0.5502910614, 0.5313453674, 0.4405946732 },
2052 { 0.1775283813, 0.1679325104, -0.2702789307, -0.1359367371,
2053 -0.1452455521, -0.0888595581, -0.0256662369, -0.0023736954,
2054 0.1074047089, 0.1431636810, 0.1357412338, 0.2045526505,
2055 0.2686481476, 0.3404531479, 0.3209333420, 0.1493968964 } },
2056 { { 0.7402400970, 0.0838251114, 0.6486282349, 0.6145095825,
2057 0.7331047058, 0.7183008194, 0.7436847687, 0.7627944946,
2058 0.7653779984, 0.7795667648, 0.8399305344, 0.8393154144,
2059 0.8219690323, 0.7474164963, 0.6681070328, 0.6490793228 },
2060 { 0.2850513458, -0.0544128418, -0.0300130844, 0.0204677582,
2061 0.0328931808, 0.0589332581, 0.0796422958, 0.1187639236,
2062 0.1320505142, 0.1539077759, 0.2189874649, 0.2865276337,
2063 0.2973947525, 0.2614307404, 0.2416648865, 0.2428951263 } },
2064 { { 0.6129922867, 0.7300701141, 0.2073822021, 0.5005893707,
2065 0.5713691711, 0.5374965668, 0.6293134689, 0.5639057159,
2066 0.7402811050, 0.6982889175, 0.4668397903, 0.6698703766,
2067 0.8758535385, 0.8678569794, 0.8678569794, 0.7810840607 },
2068 { 0.2986249924, 0.3269615173, 0.0096416473, 0.1800708771,
2069 0.2474060059, 0.2203407288, 0.3007984161, 0.2674179077,
2070 0.4424810410, 0.4046306610, 0.2063980103, 0.4230022430,
2071 0.6222190857, 0.6574449539, 0.6776618958, 0.6604385376 } },
2072 { { 0.7258052826, 0.5073966980, -0.3947381973, 0.5254812241,
2073 1.0561246872, 0.9706230164, 0.9727144241, 0.9185838699,
2074 0.8184833527, 0.9093980789, 0.8645353317, 0.7870302200,
2075 0.6347675323, 0.5123996735, 0.2846002579, 0.3252801895 },
2076 { 0.4306297302, 0.2182903290, -0.4902458191, 0.1783485413,
2077 0.7783365250, 0.7152252197, 0.7404451370, 0.6012639999,
2078 0.5421304703, 0.6619558334, 0.6316919327, 0.5596818924,
2079 0.3952398300, 0.3567333221, 0.1505041122, 0.1290159225 } },
2080 { { 0.3077287674, 0.2543363571, 0.2834520340, 0.5282287598,
2081 0.5350360870, 0.4943971634, 0.4521999359, 0.3086309433,
2082 0.2372770309, 0.0819387436, -0.1385612488, -0.0848407745,
2083 -0.0380916595, 0.1192150116, 0.3228197098, 0.3012905121 },
2084 { 0.0567188263, 0.0196886063, 0.0682420731, 0.2102527618,
2085 0.2452325821, 0.2060699463, 0.1620273590, 0.0784120560,
2086 0.0418329239, -0.0508041382, -0.2193880081, -0.1644783020,
2087 -0.1361827850, -0.0307512283, 0.1486587524, 0.2356367111 } },
2088 { { 0.4387903214, 0.5723943710, 0.6147556305, 0.9973602295,
2089 1.1645498276, 1.1898927689, 1.0326681137, 0.6939010620,
2090 0.6064310074, 0.4686441422, 0.4646663666, 0.4895582199,
2091 0.5654230118, 0.6004848480, 0.6179132462, 0.6439123154 },
2092 { 0.1324195862, 0.2426080704, 0.3132238388, 0.7359752655,
2093 0.9749288559, 0.9535636902, 0.8105278015, 0.4118890762,
2094 0.3013315201, 0.2006158829, 0.2331352234, 0.2535161972,
2095 0.3375005722, 0.4103307724, 0.4102897644, 0.4529380798 } },
2096 { { 0.7335557938, 0.9203472137, 0.4852113724, 0.8646993637,
2097 0.7304391861, 0.7503690720, 0.6289854050, 0.6900463104,
2098 0.6421079636, 0.5184278488, 0.4444904327, 0.2660236359,
2099 0.2143125534, 0.2406396866, 0.4836940765, 0.5597229004 },
2100 { 0.3689947128, 0.4967346191, 0.1176567078, 0.5127687454,
2101 0.3235168457, 0.3426265717, 0.2417469025, 0.3310623169,
2102 0.2629890442, 0.2130823135, 0.1329116821, 0.0468769073,
2103 -0.0081968307, 0.0146446228, 0.2440433502, 0.3408632278 } },
2104 { { 0.9425325394, 0.9597969055, 0.6160678864, 0.7050962448,
2105 0.8063859940, 0.9063224792, 0.9890356064, 1.0038805008,
2106 1.0338163376, 0.9453620911, 0.9634056091, 0.8068370819,
2107 0.6859455109, 0.8909034729, 0.9990415573, 1.0122871399 },
2108 { 0.6895952225, 0.6451835632, 0.3169965744, 0.4268569946,
2109 0.5666122437, 0.7722673416, 0.8845882416, 0.9061584473,
2110 0.9550399780, 0.8118810654, 0.8601064682, 0.6129922867,
2111 0.5069866180, 0.7065315247, 0.7862920761, 0.7766551971 } },
2112 { { 0.5641517639, -0.0941905975, 0.0412998199, 0.1810550690,
2113 0.3459482193, 0.4213209152, 0.4401025772, 0.5397109985,
2114 0.5607891083, 0.6348905563, 0.6861915588, 0.7280607224,
2115 0.7267074585, 0.6447324753, 0.5948257446, 0.5475025177 },
2116 { 0.1906919479, -0.0519113541, -0.0608100891, -0.0018815994,
2117 0.0383062363, 0.0362558365, 0.0529870987, 0.0692672729,
2118 0.0953073502, 0.1327886581, 0.1390628815, 0.1904459000,
2119 0.2362518311, 0.2063980103, 0.2311668396, 0.2291574478 } },
2120 { { 0.9901428223, 0.9589767456, 0.9012374878, 0.8017930984,
2121 0.8929538727, 0.8512077332, 0.8790111542, 0.8832759857,
2122 0.8949632645, 0.9159183502, 0.9293279648, 0.9152622223,
2123 0.9247350693, 0.8753614426, 0.8730239868, 0.8066730499 },
2124 { 0.4230432510, -0.0464572906, 0.0182533264, 0.1159753799,
2125 0.2349395752, 0.2740612030, 0.2987070084, 0.3620643616,
2126 0.3923282623, 0.4694643021, 0.5202322006, 0.5356512070,
2127 0.5564012527, 0.5362663269, 0.4791831970, 0.5046901703 } },
2128 { { 0.9785375595, 0.8820457458, 0.3965110779, 0.4790191650,
2129 0.3907699585, 0.4195575714, 0.2938270569, 0.4091415405,
2130 0.3659191132, 0.4030723572, 0.4168510437, 0.5030908585,
2131 0.5023117065, 0.5511522293, 0.5354051590, 0.5563192368 },
2132 { 0.6592903137, 0.2933759689, 0.0562677383, 0.1286878586,
2133 0.0758285522, 0.1192560196, 0.0508956909, 0.1175336838,
2134 0.0684061050, 0.0988750458, 0.0923957825, 0.1819572449,
2135 0.1965150833, 0.2257537842, 0.3049812317, 0.2993221283 } },
2136 { { 0.7120265961, 0.7847747803, 0.6065950394, 0.7235908508,
2137 0.6740531921, 0.6535081863, 0.3734235764, 0.4788551331,
2138 0.4410867691, 0.6927528381, 1.0758495331, 1.1148891449,
2139 1.0708875656, 0.8896322250, 0.6401805878, 0.5057153702 },
2140 { 0.4210338593, 0.4763126373, 0.3229017258, 0.4079113007,
2141 0.3922462463, 0.3529195786, 0.1258993149, 0.2168960571,
2142 0.2207508087, 0.4605655670, 0.8759355545, 0.9526205063,
2143 0.8843832016, 0.7001342773, 0.4503545761, 0.3484086990 } },
2144 { { 0.5254402161, 0.5349540710, 0.7036199570, 0.6240234375,
2145 0.6464548111, 0.7537727356, 0.8311548233, 0.7334327698,
2146 0.3484907150, 0.1846637726, 0.0894021988, 0.3977823257,
2147 0.7672233582, 0.9224796295, 0.8818407059, 0.7453250885 },
2148 { 0.2587652206, 0.2524499893, 0.4135704041, 0.3129367828,
2149 0.3403711319, 0.4473199844, 0.5330266953, 0.4227561951,
2150 0.1080198288, -0.0044651031, -0.0727024078, 0.1583776474,
2151 0.5302381516, 0.7313823700, 0.6735610962, 0.5630855560 } },
2152 { { 0.7936325073, 0.8551034927, 0.9755849838, 0.8953323364,
2153 0.9345769882, 0.7202281952, 0.8388233185, 0.7941656113,
2154 0.7550849915, 0.7894906998, 0.8590402603, 0.7813711166,
2155 0.8483371735, 0.8652324677, 0.8586711884, 0.9584846497 },
2156 { 0.4781579971, 0.4731960297, 0.8289403915, 0.6175031662,
2157 0.7262973785, 0.3638277054, 0.5544328690, 0.4761896133,
2158 0.4388723373, 0.5021476746, 0.5630445480, 0.4562187195,
2159 0.5190429688, 0.5937595367, 0.6121721268, 0.6973457336 } },
2160 { { 1.0724458694, 1.0449705124, 0.8594503403, 0.7604160309,
2161 0.7837905884, 0.8136444092, 0.7623023987, 0.6098756790,
2162 0.6432561874, 0.6395244598, 0.6853713989, 0.7401580811,
2163 0.7399530411, 0.7652549744, 0.7675104141, 0.7393789291 },
2164 { 0.9382266998, 0.8419809341, 0.3087539673, 0.3620233536,
2165 0.3547649384, 0.4241094589, 0.2857894897, 0.2123851776,
2166 0.2355957031, 0.2794332504, 0.3219995499, 0.3898267746,
2167 0.3937635422, 0.4058198929, 0.4228382111, 0.4181222916 } },
2168 { { 1.0275421143, 1.0940570831, 1.0164289474, 0.9097671509,
2169 0.9400720596, 0.8976287842, 0.9175586700, 0.8900833130,
2170 0.9154262543, 0.9492578506, 1.0011329651, 1.0361537933,
2171 1.0359487534, 0.9320344925, 0.8974237442, 0.8811845779 },
2172 { 1.0046186447, 1.0860195160, 0.9442958832, 0.7473344803,
2173 0.7876043320, 0.7410602570, 0.7422084808, 0.6844692230,
2174 0.7256412506, 0.8455486298, 0.8969316483, 0.9362173080,
2175 0.9092340469, 0.8227071762, 0.7481546402, 0.7088689804 } },
2176 { { 0.2205047607, -0.0129537582, 0.0972347260, 0.1154832840,
2177 0.0951843262, 0.1532516479, 0.1288108826, 0.1749858856,
2178 0.1591157913, 0.2134923935, 0.2477340698, 0.2634811401,
2179 0.3032999039, 0.3272485733, 0.3170785904, 0.3172016144 },
2180 { 0.0032854080, -0.0446119308, 0.0284643173, 0.0155467987,
2181 -0.0063104630, 0.0226001740, 0.0086984634, 0.0262088776,
2182 0.0173921585, 0.0360507965, 0.0366659164, 0.0215339661,
2183 0.0412178040, 0.1047391891, 0.1258172989, 0.0609836578 } },
2184 { { 0.1495609283, 0.3275766373, 0.8598194122, 0.6847562790,
2185 0.7550849915, 0.5662431717, 0.6930398941, 0.7526245117,
2186 0.7300291061, 0.7284708023, 0.6608896255, 0.5224056244,
2187 0.4273900986, 0.5757160187, 0.4625749588, 0.5123586655 },
2188 { -0.0352210999, -0.0428895950, 0.3110914230, 0.2699604034,
2189 0.3307752609, 0.2059469223, 0.2332172394, 0.3204412460,
2190 0.2846412659, 0.3354911804, 0.2448635101, 0.1514062881,
2191 0.1062564850, 0.2613077164, 0.2123441696, 0.3000602722 } },
2192 { { 0.6218910217, 0.6033554077, 0.4551525116, 0.3161764145,
2193 0.2864866257, 0.6195125580, 0.7577505112, 1.0062179565,
2194 0.8485012054, 0.6777849197, 0.7455301285, 0.3630485535,
2195 0.2327661514, 0.5563192368, 0.4448595047, 0.3806819916 },
2196 { 0.2624969482, 0.2679510117, 0.1839666367, 0.0335903168,
2197 0.0294075012, 0.2902593613, 0.4959144592, 0.7905979156,
2198 0.5748548508, 0.3753919601, 0.4855394363, 0.1089630127,
2199 0.0362968445, 0.3632535934, 0.2681150436, 0.2735691071 } },
2200 { { 0.7064495087, 0.4431781769, 0.7628355026, 0.7271585464,
2201 0.7812070847, 0.7806739807, 0.8909854889, 0.8958654404,
2202 0.9126787186, 0.9038209915, 0.9246120453, 0.9624624252,
2203 0.9732475281, 0.7420034409, 0.5060844421, 0.5189199448 },
2204 { 0.3457021713, -0.0149221420, 0.3174476624, 0.3580865860,
2205 0.4243965149, 0.4275541306, 0.5887155533, 0.6478490829,
2206 0.6320610046, 0.6627349854, 0.6868886948, 0.7396659851,
2207 0.7551259995, 0.5275316238, 0.3075237274, 0.3806819916 } },
2208 { { 0.4376831055, 0.4904603958, 0.6262788773, 0.5901098251,
2209 0.4176712036, 0.0221490860, -0.1612796783, -0.2236118317,
2210 -0.1087894440, -0.0022506714, 0.1051902771, 0.3307752609,
2211 0.4167690277, 0.4997692108, 0.4645843506, 0.5228567123 },
2212 { 0.1228237152, 0.1671123505, 0.2931299210, 0.2549924850,
2213 0.1435737610, -0.1124801636, -0.2181987762, -0.2723293304,
2214 -0.1573429108, -0.0837745667, -0.0325555801, 0.1024427414,
2215 0.1938495636, 0.2825498581, 0.2247285843, 0.2879629135 } },
2216 { { 0.6100807190, 0.7900238037, 0.9581155777, 0.8999662399,
2217 0.9277286530, 0.9720993042, 0.9966220856, 0.9630365372,
2218 0.9571723938, 0.8992280960, 0.8370189667, 0.7417984009,
2219 0.7174396515, 0.6122951508, 0.6746683121, 0.7030458450 },
2220 { 0.0859165192, 0.0914115906, 0.6077432632, 0.5471334457,
2221 0.5943746567, 0.6805324554, 0.6680250168, 0.6033554077,
2222 0.6302976608, 0.4874258041, 0.3647298813, 0.2770137787,
2223 0.2544183731, 0.2608156204, 0.3331537247, 0.4950942993 } },
2224 { { 0.4051227570, 1.1022176743, 0.8262338638, 0.6573219299,
2225 0.5948667526, 0.5426225662, 0.4987850189, 0.4370269775,
2226 0.4421119690, 0.3837165833, 0.3728494644, 0.3706760406,
2227 0.4169740677, 0.3559951782, 0.2994041443, 0.3896217346 },
2228 { 0.0716867447, 0.9253911972, 0.2780799866, 0.2460117340,
2229 0.1675224304, 0.1527595520, 0.1278266907, 0.1226596832,
2230 0.1165084839, 0.0982189178, 0.0952253342, 0.1113414764,
2231 0.1498889923, 0.0940361023, 0.0802984238, 0.1560811996 } },
2232 { { 0.7024717331, 0.7363853455, 0.9629545212, 0.9635286331,
2233 1.0819597244, 1.1529855728, 1.2984409332, 1.2693252563,
2234 1.2848672867, 1.2877378464, 1.2133083344, 1.0696573257,
2235 1.0864706039, 0.9851808548, 0.8312368393, 0.8047866821 },
2236 { 0.3001422882, 0.2273120880, 0.6279602051, 0.6936140060,
2237 0.8097076416, 0.9440498352, 1.1028738022, 1.1766471863,
2238 1.1199741364, 1.1608181000, 1.0665817261, 0.8872537613,
2239 0.9082908630, 0.7602519989, 0.6542053223, 0.7317514420 } },
2240 { { 0.0643463135, -0.6808919907, 0.2889881134, 0.6142225266,
2241 0.6356697083, 0.6825828552, 0.6259508133, 0.4945611954,
2242 0.5866651535, 0.6357517242, 0.5208883286, 0.4207878113,
2243 0.5125637054, 0.3758020401, 0.5424175262, 0.6172571182 },
2244 { -0.0636806488, -0.7585611343, 0.0850553513, 0.2996912003,
2245 0.3620643616, 0.4444084167, 0.4597454071, 0.3120756149,
2246 0.4016780853, 0.5026807785, 0.4111919403, 0.3183498383,
2247 0.3666572571, 0.1829824448, 0.3269205093, 0.4095926285 } },
2248 { { 0.9277286530, 0.9651279449, 0.9602069855, 0.9327726364,
2249 0.9208393097, 0.8868436813, 0.9011554718, 0.8569488525,
2250 0.9015245438, 0.8969726562, 0.9367094040, 0.9445009232,
2251 0.8617057800, 0.8215589523, 0.8333692551, 0.7939195633 },
2252 { 0.1719102859, 0.1142530441, 0.1245460510, 0.1646108627,
2253 0.1408672333, 0.0949792862, 0.0271930695, 0.0265779495,
2254 -0.0064334869, -0.0109033585, 0.0152187347, 0.0252656937,
2255 0.0166950226, 0.0736141205, 0.1205682755, 0.1895437241 } },
2256 { { 0.5964250565, 0.6065130234, 0.7228116989, 0.7348270416,
2257 0.0718097687, 0.2369899750, 0.2456426620, 0.4961194992,
2258 0.6410417557, 0.6765956879, 0.6771287918, 0.7285938263,
2259 0.6706905365, 0.5105543137, 0.5068635941, 0.5430326462 },
2260 { 0.2782440186, 0.2620048523, 0.4424400330, 0.4124631882,
2261 -0.1158838272, 0.0186223984, 0.0059919357, 0.1853609085,
2262 0.3568563461, 0.3791646957, 0.4100847244, 0.4654865265,
2263 0.4614677429, 0.3209743500, 0.3199081421, 0.3836755753 } },
2264 { { 0.8051557541, 0.8506336212, 0.9544658661, 0.5584516525,
2265 0.5874032974, 0.5727224350, 0.6177902222, 0.7659521103,
2266 0.9526205063, 1.0424280167, 1.0705595016, 1.0042905807,
2267 0.6005258560, 0.3886785507, 0.4739751816, 0.6542463303 },
2268 { 0.4775428772, 0.5541868210, 0.7128057480, 0.2146816254,
2269 0.2502765656, 0.2488822937, 0.3009214401, 0.4667987823,
2270 0.6929988861, 0.8599834442, 0.8784780502, 0.7463912964,
2271 0.3217535019, 0.1274986267, 0.2767267227, 0.5119485855 } },
2272 { { 0.5978193283, 0.5092830658, 1.0738401413, 0.7688636780,
2273 0.8214769363, 0.7682075500, 0.4970626831, 0.2783260345,
2274 0.2652854919, 0.3625154495, 0.5700569153, 0.5044031143,
2275 0.4003248215, 0.5162544250, 0.5727634430, 0.5538587570 },
2276 { 0.2752094269, 0.1747808456, 0.8557186127, 0.4280872345,
2277 0.5143680573, 0.4139804840, 0.1810960770, 0.0109539032,
2278 0.0317039490, 0.0842351913, 0.3129367828, 0.2614717484,
2279 0.1564092636, 0.2352676392, 0.3249931335, 0.3505821228 } },
2280 { { 0.7093610764, 0.7587757111, 1.8517618179, 1.0092525482,
2281 0.8078622818, 0.8792982101, 0.8210668564, 0.8600654602,
2282 0.6913585663, 0.6436662674, 0.6216859818, 0.6123771667,
2283 0.5940465927, 0.5910940170, 0.6505966187, 0.5801038742 },
2284 { 0.3370904922, 0.4681930542, 1.9236078262, 0.8053607941,
2285 0.5321245193, 0.6342344284, 0.5054693222, 0.5788326263,
2286 0.4400615692, 0.4086904526, 0.3924102783, 0.4220180511,
2287 0.3835115433, 0.4230432510, 0.5190839767, 0.3990535736 } },
2288 { { 0.6277141571, 1.1122236252, 1.0259838104, 0.9486427307,
2289 0.9184608459, 0.9059944153, 0.9080038071, 0.8282022476,
2290 0.8440313339, 0.7887935638, 0.7468013763, 0.6746683121,
2291 0.6319379807, 0.6246795654, 0.7263793945, 0.7349090576 },
2292 { 0.2427721024, 1.0851583481, 0.6180362701, 0.5837125778,
2293 0.4324750900, 0.4684801102, 0.3745307922, 0.3027257919,
2294 0.3646888733, 0.2409267426, 0.2158298492, 0.2052907944,
2295 0.2100887299, 0.2276401520, 0.3409452438, 0.4045896530 } },
2296 { { 0.8391513824, 0.8713426590, 1.1366233826, 1.1440868378,
2297 1.1443738937, 1.0877418518, 1.0516138077, 1.0099496841,
2298 0.9216184616, 0.8990640640, 0.9001302719, 0.8993101120,
2299 0.8055248260, 0.8150796890, 0.7272815704, 0.7196130753 },
2300 { 0.4634771347, 0.5807189941, 1.1287908554, 1.1066875458,
2301 1.0765056610, 0.9287538528, 0.8956193924, 0.8026132584,
2302 0.6725769043, 0.5856809616, 0.5527515411, 0.5183868408,
2303 0.4529380798, 0.5074377060, 0.4632720947, 0.5554990768 } },
2304};
2305
2306static const float wmavoice_lsp16_intercoeff_b[32][2][16] = {
2307 { { 0.5431776047, -0.1212130189, -0.2471650839, 0.0683670044,
2308 0.1418520808, 0.2518971562, 0.3708084226, 0.4141484499,
2309 0.5712364912, 0.5852659345, 0.5670641661, 0.6401320100,
2310 0.6447737217, 0.6726239920, 0.4994724989, 0.5574678183 },
2311 { 0.2040718794, -0.1271064281, -0.2266163826, -0.0406349897,
2312 -0.0145058036, 0.0283126831, 0.0851084590, 0.0913147926,
2313 0.1307432652, 0.1926501393, 0.2310355306, 0.2828245163,
2314 0.3171940446, 0.4424681067, 0.2960716486, 0.3510941863 } },
2315 { { 0.8073900938, 0.0403081179, 0.5392660499, 0.6928597689,
2316 0.6499369740, 0.7328097820, 0.7755761147, 0.7766191959,
2317 0.8820225596, 0.8423333168, 0.8898978233, 0.8488525748,
2318 0.8654375672, 0.6728326082, 0.6169234514, 0.6755967736 },
2319 { 0.3653843999, -0.0846008658, -0.0224332213, 0.1120721102,
2320 0.1020585299, 0.1741876006, 0.2129902244, 0.2160151601,
2321 0.3619422317, 0.4185815454, 0.5455245376, 0.5363975763,
2322 0.5429168344, 0.3505726457, 0.3296067119, 0.3620986938 } },
2323 { { 0.1843576431, 0.0179861784, 0.3122915626, 0.3600125313,
2324 0.2466817498, 0.2172668576, 0.1975526214, 0.1177569032,
2325 0.1196866035, 0.0849519968, 0.0962694287, 0.1591672301,
2326 0.2300446033, 0.3082756996, 0.4047607183, 0.3925045133 },
2327 { -0.0275964737, -0.0794897676, 0.1168181300, 0.1591150761,
2328 0.0915755630, 0.0460972190, 0.0562151074, 0.0084419847,
2329 -0.0095511675, -0.0408957601, -0.0376100540, -0.0166962743,
2330 0.0656028390, 0.1226072311, 0.2293144464, 0.2142419219 } },
2331 { { 0.4781936407, -1.2478972673, 0.4884679914, 0.7755239606,
2332 0.6785174012, 0.6590117812, 0.6177057624, 0.6427918673,
2333 0.5402048230, 0.5512614846, 0.6424267888, 0.4229103327,
2334 0.5106334686, 0.5136062503, 0.4490395188, 0.4753251672 },
2335 { 0.2852236032, -1.3815159798, 0.1904075146, 0.4874770641,
2336 0.4593138695, 0.4182686210, 0.4174863100, 0.4604612589,
2337 0.4089330435, 0.3891666532, 0.4700576067, 0.2383370996,
2338 0.2801646590, 0.3398289084, 0.2766703367, 0.3374298215 } },
2339 { { 0.5925153494, 0.3858809471, 1.0754098296, 0.5752002001,
2340 0.5516265631, 0.4853909016, 0.4719351530, 0.5018194318,
2341 0.3037382960, 0.5154316425, 0.8809794784, 0.7755761147,
2342 0.5941321254, 0.3974069953, 0.5925675035, 0.6097261906 },
2343 { 0.3008176684, 0.0706617832, 0.8484353423, 0.2574254870,
2344 0.2815728188, 0.1930673718, 0.2523665428, 0.2691601515,
2345 0.1271967888, 0.2653007507, 0.6473292708, 0.5275835395,
2346 0.3928174376, 0.2405275702, 0.4008491635, 0.4556109309 } },
2347 { { 0.7339050174, 0.4290645123, 0.6859754324, 0.6349166036,
2348 0.8034263849, 0.8509387374, 0.8591269255, 1.1049811840,
2349 1.3928194642, 1.3423343301, 1.0849018693, 0.8943830729,
2350 0.8579795361, 0.6920774579, 0.5613272190, 0.4303162098 },
2351 { 0.4534726143, 0.0901674032, 0.3465046287, 0.3470261693,
2352 0.5217422843, 0.5874564052, 0.6014336944, 0.9161834717,
2353 1.2823571563, 1.2193550467, 0.8868207335, 0.6514494419,
2354 0.6249030232, 0.4453887343, 0.3665317893, 0.2242033482 } },
2355 { { 0.4293252826, 0.3303368688, 0.6181751490, 0.9884168506,
2356 0.9915460944, 0.7939864993, 0.3019129038, 0.2443348169,
2357 0.4543070793, 0.5617444515, 0.4895110726, 0.6600027084,
2358 0.6290231943, 0.5580936670, 0.5459417701, 0.4647378922 },
2359 { 0.1409133077, -0.0050137639, 0.2551307082, 0.6764833927,
2360 0.7112701535, 0.4648943543, 0.0301380754, -0.0235806108,
2361 0.1018499136, 0.2422486544, 0.2406318784, 0.4000146985,
2362 0.3713299632, 0.3259559274, 0.3820737004, 0.2888743877 } },
2363 { { 0.7733334899, 0.8321111202, 1.3098945022, 1.0331128836,
2364 1.0380675197, 0.9479974508, 0.9740223289, 0.9442945123,
2365 0.8926619887, 0.8719046712, 0.8640815616, 0.8404036164,
2366 0.8359183669, 0.7675965428, 0.6895219088, 0.7266034484 },
2367 { 0.3655408621, 0.4643206596, 1.2171645761, 0.8341451287,
2368 0.8387868404, 0.6713201404, 0.6814901829, 0.6294404268,
2369 0.5172048807, 0.5205948949, 0.5408828259, 0.5298783183,
2370 0.5781729817, 0.5000983477, 0.4727174640, 0.4326109886 } },
2371 { { 0.8902629018, 0.4598354101, 0.6392975450, 0.4483093619,
2372 0.6220867038, 0.6323089004, 0.7063676715, 0.3717993498,
2373 0.6718416810, 0.7876758575, 0.2807383537, 0.3118221760,
2374 0.6703813672, 0.7662405372, 0.7122610807, 0.7851724625 },
2375 { 0.6301705837, 0.1221378446, 0.3532846570, 0.1412783861,
2376 0.3471826315, 0.3435318470, 0.4466925859, 0.1390357614,
2377 0.4092981219, 0.5406742096, 0.0690450072, 0.0829179883,
2378 0.4625995755, 0.5700891018, 0.5542864203, 0.6545265317 } },
2379 { { -0.1100520492, 0.3803526163, 0.8075987101, 0.6903563738,
2380 0.8012359142, 0.7835035324, 0.8195941448, 0.8381088376,
2381 0.8033220768, 0.7511680126, 0.6393496990, 0.6096218824,
2382 0.6934856176, 0.6690253615, 0.6401841640, 0.5600233674 },
2383 { -0.1776958704, -0.0293175578, 0.1520742774, 0.1746048331,
2384 0.2222214937, 0.3052507639, 0.2977927327, 0.3797789216,
2385 0.3395681381, 0.2976884246, 0.2516885400, 0.2403711081,
2386 0.3567789793, 0.3302847147, 0.3368039727, 0.3310148716 } },
2387 { { 0.5587195158, 0.4676063657, 0.1392965317, -0.0990996957,
2388 -0.0816280842, -0.1146416068, -0.0116894841, 0.0521992445,
2389 0.1626615524, 0.2923687100, 0.4029874802, 0.4528989196,
2390 0.4694839120, 0.5058352947, 0.5369191170, 0.5105291605 },
2391 { 0.2193530202, 0.1211469173, 0.0179861784, -0.2022604346,
2392 -0.1409794092, -0.2121175528, -0.1152674556, -0.0594626069,
2393 -0.0122110248, 0.0274260640, 0.1414870024, 0.2044369578,
2394 0.2167974710, 0.2615978122, 0.3348221183, 0.3707562685 } },
2395 { { 0.5948622823, 0.7065241337, 0.9414781928, 0.9340723157,
2396 0.8835350275, 0.9730835557, 0.8503650427, 0.8902629018,
2397 0.8746688366, 0.6910865307, 0.6404449344, 0.6976057887,
2398 0.5916287303, 0.6022160053, 0.7729684114, 0.6096740365 },
2399 { 0.1262058616, 0.1300652623, 0.6594290137, 0.6535877585,
2400 0.5639349222, 0.6982316375, 0.4828875065, 0.5577285886,
2401 0.4591052532, 0.2964367270, 0.2695252299, 0.3324751854,
2402 0.2860580683, 0.2902825475, 0.4623388052, 0.3369604349 } },
2403 { { 0.8821268678, 0.8539636731, 0.2898653150, 0.7478301525,
2404 0.5109463930, 0.8577187657, 0.4884679914, 0.7846509218,
2405 0.7684310079, 0.7032384276, 0.6691296697, 0.8593355417,
2406 0.9383489490, 0.9808023572, 0.6804992557, 0.6403927803 },
2407 { 0.5590324402, 0.4209806323, 0.0259135962, 0.4318808317,
2408 0.2104346752, 0.5453680754, 0.1783599257, 0.4467447400,
2409 0.4352708459, 0.4089330435, 0.3994410038, 0.5984609127,
2410 0.6872792840, 0.7321317792, 0.4408513308, 0.4542027712 } },
2411 { { 0.6371070743, 0.6311093569, 0.7152860165, 0.6929640770,
2412 0.2292101383, 0.3234525323, 0.9644259810, 0.9881039262,
2413 0.8722697496, 0.4370440841, 0.4051779509, 0.4944135547,
2414 0.5392660499, 0.5969484448, 0.4268740416, 0.4990552664 },
2415 { 0.4233797193, 0.3647063971, 0.4345406890, 0.4180078506,
2416 -0.0006328225, 0.0586141944, 0.7620160580, 0.8152132034,
2417 0.6707985997, 0.2095480561, 0.2178405523, 0.2776612639,
2418 0.3142212629, 0.3808741570, 0.2676998377, 0.2804775834 } },
2419 { { 0.4509170651, 0.9490405321, 0.8557890654, 0.8271043301,
2420 0.6915559173, 0.7321839333, 0.6257896423, 0.6274064183,
2421 0.5238284469, 0.5194996595, 0.4116972089, 0.3382642865,
2422 0.3755022883, 0.4867990613, 0.5686287880, 0.5106856227 },
2423 { 0.0989292860, 0.6244857907, 0.4700576067, 0.3905226588,
2424 0.2630059719, 0.3009741306, 0.2150763869, 0.2067838907,
2425 0.1533781290, 0.1815934777, 0.1023714542, 0.0373874903,
2426 0.0897501707, 0.1849313378, 0.2852757573, 0.2625887394 } },
2427 { { 0.9954054952, 0.9554033279, 0.8237664700, 0.9780903459,
2428 0.7261862159, 0.7884581685, 0.7933084965, 0.7393290401,
2429 0.8783196211, 1.0409359932, 1.0217954516, 0.9159227014,
2430 0.8698185086, 0.7057939768, 0.7662926912, 0.7339571714 },
2431 { 0.7913266420, 0.6739278436, 0.5061482191, 0.7058982849,
2432 0.3480692506, 0.4338105321, 0.4428853393, 0.3758152127,
2433 0.5962182879, 0.7925261855, 0.7968549728, 0.6629754901,
2434 0.6325175166, 0.4598354101, 0.5310778618, 0.5518873334 } },
2435 { { 0.4638512731, 0.0604917407, 0.1897295117, 0.3403504491,
2436 0.4708399177, 0.5241413713, 0.6061275601, 0.6446694136,
2437 0.7313494682, 0.7208143473, 0.6268848777, 0.6081094146,
2438 0.4913364649, 0.3529717326, 0.4954566360, 0.5767126679 },
2439 { 0.1353849769, -0.0274400115, 0.0002537966, 0.0272174478,
2440 0.0555371046, 0.0652899146, 0.1010676026, 0.1073260903,
2441 0.1568724513, 0.2207611799, 0.1434167027, 0.2262373567,
2442 0.1177047491, 0.0162650943, 0.2529402375, 0.4087765813 } },
2443 { { 0.9700064659, 0.9917025566, 0.9159227014, 0.9309430718,
2444 0.8991290927, 0.9314124584, 0.9059612751, 0.9473194480,
2445 0.9604622722, 0.9377752542, 0.9197821021, 0.8869771957,
2446 0.8506779671, 0.8594920039, 0.8320589662, 0.8739908338 },
2447 { 0.2892394662, 0.0551198721, 0.0892807841, 0.1158793569,
2448 0.0905846357, 0.0738953352, 0.0395258069, 0.0240360498,
2449 0.0477139950, 0.0751470327, 0.1171310544, 0.1555164456,
2450 0.1384620667, 0.1818542480, 0.2104868293, 0.1288135648 } },
2451 { { 0.4101847410, 0.3326316476, 0.4666675925, 0.5077128410,
2452 0.5892296433, 0.4272912741, 0.0603352785, -0.8668596745,
2453 -1.1103670001, -0.0900248885, 0.1626615524, 0.1487885714,
2454 0.4130010605, 0.5119373202, 0.5820323825, 0.5486016273 },
2455 { 0.0383262634, 0.1300652623, 0.2295230627, 0.2706204653,
2456 0.3722165823, 0.1698066592, -0.0934670568, -0.8677462935,
2457 -1.0724509954, -0.2164463401, -0.0056917667, -0.0301520228,
2458 0.1299088001, 0.2579991817, 0.3482257128, 0.2469425201 } },
2459 { { 0.6031547785, 0.5515222549, 0.4292209744, 0.5027582049,
2460 0.8167778254, 1.0925685167, 0.9878953099, 0.7019345760,
2461 0.2509583831, 0.2475162148, 0.5660732388, 0.5145971775,
2462 0.4824181199, 0.5970005989, 0.5996604562, 0.5384315848 },
2463 { 0.3677313328, 0.2650399804, 0.1585935354, 0.2213348746,
2464 0.5566333532, 0.8425940871, 0.7604514360, 0.4523773789,
2465 0.0681062341, 0.0737388730, 0.3169854283, 0.2868403792,
2466 0.2661873698, 0.3635068536, 0.4300554395, 0.3743027449 } },
2467 { { 0.5017672777, 0.6634970307, 0.6869142056, 0.7066284418,
2468 0.5669598579, 0.0621085167, 0.0634645224, 0.2321307659,
2469 0.8322675824, 0.9855483770, 0.8296598792, 0.6140028238,
2470 0.5462546945, 0.6730412245, 0.6856103539, 0.5975221395 },
2471 { 0.2680649161, 0.3324230313, 0.3688787222, 0.3886451125,
2472 0.2774004936, -0.1695076823, -0.1353467703, 0.0159000158,
2473 0.5895425677, 0.7586781979, 0.5639870763, 0.3687744141,
2474 0.3401418328, 0.4477356672, 0.4782979488, 0.4034568667 } },
2475 { { 0.8838479519, 0.9025712609, 0.7326533198, 0.8124490380,
2476 0.8956347704, 1.1007045507, 1.2731780410, 1.2029786706,
2477 1.0839109421, 0.9664078355, 0.7356782556, 0.6942157745,
2478 0.6917645335, 0.6383587718, 0.6503020525, 0.5989302993 },
2479 { 0.5576764345, 0.4596789479, 0.3790487647, 0.5514179468,
2480 0.7333834767, 0.9612445831, 1.1976589561, 1.1094664335,
2481 0.8868207335, 0.6789346337, 0.4643206596, 0.4029353261,
2482 0.4384522438, 0.3871847987, 0.4326109886, 0.3691916466 } },
2483 { { 0.8520861268, 0.8413423896, 0.7238392830, 0.9103943706,
2484 0.7072542906, 0.6479029655, 0.4557673931, 0.1908247471,
2485 -0.0569070578, -0.1013423204, 0.2517406940, 0.4854952097,
2486 0.5820845366, 0.5886037946, 0.6177579165, 0.6226603985 },
2487 { 0.6160889864, 0.4592095613, 0.4752208591, 0.6685559750,
2488 0.4326109886, 0.4077335000, 0.2314006090, 0.0173603296,
2489 -0.2208272815, -0.3014574647, 0.0321199298, 0.2559130192,
2490 0.3603254557, 0.3466089368, 0.4072119594, 0.4776199460 } },
2491 { { 0.7083495259, 0.9001721740, 0.6795083284, 1.2743254304,
2492 1.3672639728, 1.2563322783, 0.8557369113, 0.8287732601,
2493 0.7942472696, 0.8006622195, 0.7034991980, 0.5479236245,
2494 0.6391932368, 0.6248508692, 0.5495925546, 0.4719351530 },
2495 { 0.4000146985, 0.6493632793, 0.4583229423, 1.1484255195,
2496 1.2521599531, 1.1232351065, 0.6150459051, 0.5347808003,
2497 0.4726653099, 0.5269576907, 0.4278128147, 0.2745841742,
2498 0.3868718743, 0.4183729291, 0.3474434018, 0.3150035739 } },
2499 { { 0.9070043564, 0.7648323774, 0.4281778932, 0.5475063920,
2500 0.4134704471, 0.4706834555, 0.4549329281, 0.4648422003,
2501 0.4572798610, 0.4823138118, 0.4666154385, 0.4841913581,
2502 0.4018922448, 0.4297946692, 0.4646857381, 0.6091003418 },
2503 { 0.4925360084, 0.2065231204, 0.0948612690, 0.1716842055,
2504 0.0992422104, 0.1332988143, 0.1255800128, 0.1257364750,
2505 0.0955392718, 0.1118634939, 0.1372103691, 0.1525958180,
2506 0.0902717113, 0.1591672301, 0.2335910797, 0.3767018318 } },
2507 { { 0.3185500503, 0.8677845001, 0.7776622772, 0.8160476685,
2508 0.8624126315, 0.8057211637, 0.8852561116, 0.8471314907,
2509 0.9145145416, 0.8945916891, 0.8638729453, 0.8531292081,
2510 0.7425104380, 0.6215651631, 0.6501455903, 0.6341864467 },
2511 { -0.0499705672, 0.0687842369, 0.3051464558, 0.3368039727,
2512 0.4942049384, 0.3823344707, 0.5683158636, 0.5044271350,
2513 0.6278236508, 0.5777035952, 0.5745221972, 0.5502184033,
2514 0.4244228005, 0.3163595796, 0.3525545001, 0.3582914472 } },
2515 { { 0.3200625181, 0.9415303469, 0.6067534089, 0.3568832874,
2516 0.1600538492, 0.2938811779, 0.2037589550, 0.3017564416,
2517 0.2572168708, 0.4796018004, 0.6938506961, 0.6847758889,
2518 0.7232134342, 0.6111343503, 0.5159531832, 0.4856516719 },
2519 { 0.0680540800, 0.6285016537, 0.2514277697, 0.0790064335,
2520 -0.0687981844, 0.0521992445, -0.0055874586, 0.0537117124,
2521 0.0188206434, 0.1883213520, 0.4493002892, 0.4300554395,
2522 0.4750122428, 0.3658016324, 0.3119786382, 0.2818335891 } },
2523 { { 0.6864969730, 1.0815640092, 0.9838794470, 0.8845259547,
2524 0.9438772798, 0.8888025880, 0.8178730607, 0.8581881523,
2525 0.7128347754, 0.7120524645, 0.7345308661, 0.7945601940,
2526 0.7854853868, 0.8261655569, 0.6941114664, 0.6646444201 },
2527 { 0.2847542167, 0.9535257816, 0.6691818237, 0.5026538968,
2528 0.5945493579, 0.4125838280, 0.3886451125, 0.3740941286,
2529 0.2453778982, 0.2928902507, 0.3219922185, 0.4065861106,
2530 0.3838469386, 0.4289602041, 0.3910441995, 0.3821780086 } },
2531 { { 1.1335094571, 1.0390062928, 0.7019867301, 0.6203134656,
2532 0.6951545477, 0.4863818288, 0.6171320677, 0.6247465611,
2533 0.5907421112, 0.6711115241, 0.7322882414, 0.7042293549,
2534 0.5635698438, 0.6174449921, 0.6727283001, 0.6431047916 },
2535 { 1.0146503448, 0.7762541175, 0.2200310230, 0.2459515929,
2536 0.2703596950, 0.1376276016, 0.2522100806, 0.2622758150,
2537 0.2389107943, 0.2956544161, 0.3799875379, 0.3653843999,
2538 0.2561216354, 0.2842326760, 0.4034568667, 0.3700782657 } },
2539 { { 0.6342907548, 0.9627570510, 0.5214815140, -0.0226939917,
2540 0.5616401434, 0.7231091261, 0.7417802811, 0.9092991352,
2541 0.9739701748, 0.7804785967, 0.6771092415, 0.6352295280,
2542 0.4660417438, 0.5869870186, 0.6692339778, 0.5986173749 },
2543 { 0.3988673091, 0.6997441053, 0.2316613793, -0.2566571236,
2544 0.2685343027, 0.4484136701, 0.4490395188, 0.6886874437,
2545 0.7703085542, 0.5847443938, 0.4539941549, 0.4098196626,
2546 0.2579991817, 0.3376384377, 0.4754816294, 0.5095382333 } },
2547 { { 0.4443456531, 2.0296727419, 0.6569256186, 0.6439914107,
2548 0.6436263323, 0.5507399440, 0.6095175743, 0.6066491008,
2549 0.5347808003, 0.2529402375, 0.4443978071, 0.7000570297,
2550 0.8259569407, 0.5927761197, 0.5078171492, 0.4418422580 },
2551 { 0.2430831194, 1.9133691788, 0.3723730445, 0.3764410615,
2552 0.3874977231, 0.3212099075, 0.3832210898, 0.4474227428,
2553 0.3644977808, 0.0814055204, 0.2752621770, 0.4647378922,
2554 0.6619845629, 0.4304205179, 0.3143777251, 0.2705683112 } },
2555 { { 0.9740744829, 1.0730628967, 0.9743352532, 0.9098728299,
2556 0.9453375936, 0.9661470652, 0.9270836711, 0.9643738270,
2557 0.9989519715, 0.9627048969, 0.9348546267, 0.9865393043,
2558 0.9399657249, 0.9752218723, 0.8440544009, 0.8819182515 },
2559 { 0.9258319736, 1.0357205868, 0.8463491797, 0.8108844161,
2560 0.8391519189, 0.8566235304, 0.8305986524, 0.8880724311,
2561 0.9181653261, 0.8670021892, 0.8305986524, 0.8995984793,
2562 0.8300249577, 0.8711223602, 0.7195626497, 0.8138571978 } },
2563};
2564
2565static const double wmavoice_mean_lsf10[2][10] = {
2566 { 0.2235394066, 0.4097484909, 0.7025292732, 1.1077160169,
2567 1.3939179044, 1.6741291716, 1.9552949226, 2.2199793918,
2568 2.5103400247, 2.7829212906 },
2569 { 0.1493683393, 0.3714357373, 0.7702730245, 1.0609411394,
2570 1.3270362536, 1.5806033119, 1.8398507524, 2.1116740248,
2571 2.3823505771, 2.6865718527 }
2572};
2573
2574static const double wmavoice_mean_lsf16[2][16] = {
2575 { 0.0999206754, 0.2345933590, 0.4621011210, 0.6772546160,
2576 0.8346396060, 1.0067495130, 1.1571691668, 1.3292508688,
2577 1.4941465650, 1.6600755584, 1.8461284908, 2.0529487333,
2578 2.2690810112, 2.4949894820, 2.7172752965, 2.9164840903 },
2579 { 0.0918298402, 0.2475621892, 0.4782937721, 0.6284774045,
2580 0.7861951264, 0.9303736000, 1.0940441024, 1.2521029300,
2581 1.4434732098, 1.6551410742, 1.8917962963, 2.0967280403,
2582 2.2981430375, 2.4826173497, 2.6827972461, 2.8811350800 }
2583};
2584
2585static const float wmavoice_std_codebook[1000] = {
2586 -0.185013, -0.150405, -0.707267, -0.284100, 0.882898,
2587 -0.788627, 0.061005, 0.374431, 0.053843, -0.909826,
2588 0.543602, 0.219326, 0.285698, 0.154709, -0.455005,
2589 0.426276, -0.868852, -0.952324, -0.550001, 0.813814,
2590 -0.352815, 0.242122, 0.820495, -0.189574, -0.449538,
2591 0.499132, -0.247783, 0.598159, 0.732040, -0.564406,
2592 -0.631788, -0.452973, 0.285189, -0.339055, 0.262927,
2593 0.168087, -0.127682, -0.676067, -0.457481, 0.926161,
2594 -0.585893, -0.913880, 0.145487, 0.699804, 0.240829,
2595 0.690482, 0.126081, 0.371977, 0.738158, 0.576080,
2596 0.185791, -0.614657, -0.181799, 0.006285, 0.195768,
2597 0.368663, -0.494583, 0.947985, -0.033178, -0.762543,
2598 -0.616421, 0.335034, -0.215516, 0.668769, 0.995979,
2599 -0.952588, -0.163144, -0.131704, -0.628655, 0.379374,
2600 -0.205543, -0.214549, 0.465494, 0.939944, -0.514744,
2601 -0.293676, 0.630426, 0.611336, -0.921699, 0.368584,
2602 0.187416, 0.264092, 0.753927, -0.994382, -0.729623,
2603 -0.050304, 0.374280, -0.224205, -0.102319, -0.658897,
2604 0.013252, 0.281260, 0.676137, 0.797736, -0.049971,
2605 0.672115, 0.845148, 0.786885, -0.459588, -0.783507,
2606 0.166259, 0.334869, 0.001944, -0.368247, 0.274813,
2607 0.487200, 0.338077, -0.094761, 0.098536, 0.416378,
2608 -0.726176, -0.714048, -0.319530, -0.972249, -0.708430,
2609 -0.049153, -0.022553, 0.665850, 0.726642, 0.875127,
2610 -0.993047, -0.260106, 0.156387, 0.683090, -0.462370,
2611 -0.893584, 0.355205, -0.617222, 0.893301, 0.895617,
2612 -0.400729, 0.059559, 0.230486, 0.601215, 0.691313,
2613 -0.494701, 0.088415, 0.029390, 0.410539, -0.813049,
2614 -0.554232, 0.684362, -0.527097, 0.126238, 0.712113,
2615 -0.235528, -0.922915, -0.310440, -0.569678, 0.803727,
2616 -0.435313, -0.562725, -0.456380, 0.721075, -0.879635,
2617 0.081250, 0.827491, 0.475570, 0.464029, 0.720792,
2618 0.371187, -0.936700, -0.219649, -0.398327, 0.664515,
2619 -0.528336, 0.106972, -0.247070, 0.501053, -0.482490,
2620 -0.060119, 0.946821, -0.798127, 0.412784, 0.073058,
2621 0.913986, -0.822744, 0.150143, -0.396453, -0.392421,
2622 -0.046130, 0.168234, 0.044854, 0.497490, -0.110691,
2623 0.165219, -0.421259, -0.283200, -0.359212, -0.957231,
2624 -0.562409, -0.988025, -0.893931, 0.217942, -0.386352,
2625 0.770585, 0.689606, 0.720620, -0.476485, 0.190659,
2626 -0.761870, 0.463395, 0.137480, -0.559997, -0.123821,
2627 -0.789461, -0.646011, 0.053435, 0.360682, -0.042464,
2628 0.661014, -0.685448, -0.874230, -0.294133, 0.812042,
2629 0.015078, 0.871086, -0.609218, 0.731878, -0.488126,
2630 -0.566448, -0.830530, -0.476150, -0.460379, 0.387412,
2631 0.137497, -0.689794, 0.077018, -0.141883, -0.166280,
2632 -0.732322, 0.096247, -0.702884, 0.405158, 0.536250,
2633 0.173295, 0.615696, 0.890239, -0.773270, -0.023622,
2634 -0.152226, 0.887744, 0.290930, -0.026456, -0.406389,
2635 0.102972, 0.988622, -0.535303, 0.493754, 0.720500,
2636 -0.023428, 0.927306, 0.889970, 0.500421, -0.533073,
2637 0.277382, -0.362081, -0.222867, -0.645599, 0.496035,
2638 0.610853, -0.377922, -0.407718, 0.907969, -0.972764,
2639 -0.871468, 0.081264, 0.642933, -0.981230, 0.307994,
2640 -0.380689, -0.133456, 0.195738, 0.910241, 0.840088,
2641 0.789349, 0.013213, 0.828710, -0.745954, -0.493033,
2642 0.549210, 0.230618, -0.565727, 0.439180, -0.268961,
2643 -0.098800, -0.283438, 0.368958, 0.678333, 0.070963,
2644 -0.135007, 0.289186, 0.693041, 0.457275, 0.197155,
2645 0.720277, 0.585807, -0.721581, 0.363210, 0.604577,
2646 0.586413, 0.982521, -0.528878, -0.217849, 0.892762,
2647 -0.688791, -0.428500, -0.094025, -0.860081, -0.174454,
2648 0.412942, 0.689129, -0.943836, 0.847215, 0.128309,
2649 -0.212797, -0.251585, 0.844871, -0.843839, -0.573252,
2650 -0.084167, 0.021154, 0.715935, -0.391126, -0.521570,
2651 -0.086910, -0.670848, -0.935763, 0.191509, 0.692361,
2652 0.668814, -0.222078, 0.674882, -0.860064, 0.560073,
2653 0.567644, -0.548855, -0.868427, -0.526382, -0.408936,
2654 -0.042881, 0.886560, -0.719807, 0.013283, 0.733775,
2655 0.408502, 0.800487, -0.517810, 0.253372, 0.956648,
2656 -0.091062, -0.830794, -0.022198, -0.375127, -0.221920,
2657 0.456232, 0.537963, 0.107232, 0.520469, -0.270529,
2658 -0.200406, 0.189284, 0.507393, -0.525524, 0.329220,
2659 0.067466, -0.957881, 0.780365, 0.199039, -0.484262,
2660 -0.628570, -0.843843, -0.597703, -0.348377, 0.169441,
2661 -0.863928, -0.939875, -0.030073, -0.381738, 0.313497,
2662 -0.073425, 0.527200, 0.482703, 0.904377, -0.847927,
2663 -0.739217, 0.360609, 0.690035, 0.368015, -0.118921,
2664 -0.580493, -0.832391, -0.929638, 0.926900, -0.357915,
2665 0.399582, -0.005634, -0.315796, 0.179947, -0.806596,
2666 0.393360, 0.732931, -0.415833, -0.724526, 0.957347,
2667 -0.892887, 0.475366, 0.173583, -0.418554, -0.302536,
2668 0.627315, 0.782000, 0.497542, 0.139082, 0.570111,
2669 0.732375, -0.454643, 0.302218, -0.019505, 0.881778,
2670 -0.057606, 0.273041, 0.414170, -0.503501, -0.079602,
2671 -0.083941, 0.007178, -0.171925, 0.506856, 0.520953,
2672 0.631684, -0.099784, 0.253885, -0.784149, 0.175691,
2673 0.211231, -0.677036, -0.348943, -0.615186, -0.095591,
2674 0.348521, -0.987871, -0.313590, -0.153938, 0.151210,
2675 -0.743479, -0.421562, 0.696567, 0.558739, 0.558933,
2676 0.578346, -0.498867, -0.168026, -0.007485, -0.002368,
2677 0.752372, 0.908575, -0.995190, -0.419553, 0.415430,
2678 0.525763, -0.787869, -0.684353, -0.220353, -0.572018,
2679 0.491337, 0.990879, -0.249054, -0.857606, -0.624307,
2680 0.655355, 0.490915, -0.612178, -0.658235, -0.663023,
2681 0.539032, -0.401714, -0.084585, 0.235599, -0.842975,
2682 -0.525653, -0.186055, -0.341841, 0.306321, 0.806460,
2683 0.655791, 0.058693, 0.715035, 0.660601, 0.639140,
2684 0.130465, 0.186363, 0.851271, 0.446112, 0.966011,
2685 -0.720746, -0.062551, 0.956890, 0.030200, 0.079843,
2686 -0.667418, -0.314445, -0.429243, -0.279596, 0.027320,
2687 -0.092266, -0.740564, 0.625606, 0.823149, 0.495035,
2688 0.782632, -0.702504, -0.691020, -0.559209, 0.603818,
2689 -0.884560, -0.903419, -0.337489, 0.830475, 0.757182,
2690 -0.698349, -0.039060, -0.056455, -0.847078, -0.592948,
2691 -0.090444, -0.567824, 0.344501, -0.133554, 0.462375,
2692 -0.575656, 0.199028, -0.852070, -0.004899, 0.919432,
2693 0.175251, 0.902835, -0.821132, -0.199143, 0.725984,
2694 0.673903, -0.416511, -0.976519, 0.982883, 0.024279,
2695 0.627298, -0.901677, 0.120861, -0.710191, 0.928798,
2696 -0.121958, -0.408540, -0.110261, 0.821588, -0.255618,
2697 0.296790, -0.268856, 0.176557, -0.358709, 0.597589,
2698 -0.361067, 0.065635, -0.203382, -0.213137, -0.939264,
2699 -0.283951, 0.962113, 0.963571, -0.105083, -0.237030,
2700 0.689556, -0.431180, 0.346459, 0.713037, -0.448297,
2701 -0.629262, 0.340335, -0.349973, 0.491599, 0.630144,
2702 -0.421175, -0.630359, -0.778396, 0.468564, -0.808771,
2703 -0.034014, -0.234646, -0.077627, -0.857457, 0.406645,
2704 -0.480038, -0.218524, -0.527720, 0.316580, 0.568338,
2705 -0.466984, -0.967371, 0.530452, -0.503413, -0.072454,
2706 -0.706578, -0.813857, 0.496366, 0.639881, 0.899179,
2707 -0.951931, -0.989381, 0.239514, -0.301904, 0.502218,
2708 -0.130341, 0.276921, 0.871860, 0.091262, -0.254515,
2709 -0.936911, -0.942752, 0.510839, -0.014539, -0.800209,
2710 -0.082516, 0.505423, -0.018733, 0.389763, -0.177997,
2711 -0.450395, 0.922779, -0.145368, -0.919943, -0.580634,
2712 0.782178, -0.626521, -0.394491, 0.278545, -0.986640,
2713 -0.495312, 0.326614, -0.976021, 0.744203, -0.975290,
2714 0.526197, -0.386139, 0.301631, 0.398057, 0.705124,
2715 -0.952884, 0.461146, 0.762372, 0.557954, -0.553393,
2716 0.962163, -0.524562, 0.952030, -0.056570, 0.865202,
2717 -0.225967, 0.493035, 0.787981, 0.628665, 0.573093,
2718 -0.792653, 0.410844, 0.946571, -0.187144, -0.310612,
2719 0.959931, 0.317544, -0.983998, 0.983911, 0.061747,
2720 -0.959287, 0.510108, 0.675608, 0.342344, -0.091835,
2721 0.380731, 0.389460, -0.630689, 0.143103, -0.052586,
2722 -0.184083, 0.105266, 0.422852, -0.232052, -0.951303,
2723 0.288054, 0.541981, 0.541732, 0.076035, 0.170646,
2724 0.114825, 0.283382, -0.418510, 0.061396, -0.903763,
2725 0.270879, 0.021327, 0.413782, 0.286881, 0.005238,
2726 -0.524472, 0.327594, -0.484654, -0.848864, -0.330063,
2727 0.423511, 0.531868, -0.940603, 0.792822, -0.325029,
2728 0.006811, -0.391261, 0.780237, -0.570337, 0.376687,
2729 0.828934, 0.717717, -0.081333, 0.370666, -0.206248,
2730 -0.910686, -0.514510, -0.922867, -0.329196, 0.546886,
2731 -0.826629, 0.941683, -0.431786, 0.587152, 0.228564,
2732 0.573452, -0.937320, -0.443843, -0.911202, -0.786184,
2733 0.226094, 0.512309, 0.745684, 0.285491, 0.305131,
2734 -0.579345, -0.707698, 0.913870, -0.799108, -0.278035,
2735 0.290556, -0.970174, -0.560318, -0.790776, 0.400492,
2736 0.233434, -0.701462, 0.885982, 0.310567, -0.030658,
2737 0.432868, 0.483938, -0.088976, -0.998918, 0.071090,
2738 -0.860412, 0.574534, 0.133770, -0.304255, 0.663332,
2739 0.347586, 0.921839, 0.175641, 0.093270, 0.207330,
2740 -0.519228, 0.513925, 0.499633, -0.605358, 0.714817,
2741 -0.778402, 0.685198, 0.744643, -0.338720, 0.894422,
2742 0.145135, 0.894714, -0.807041, 0.031117, 0.205281,
2743 0.162301, -0.536015, -0.310781, -0.926675, -0.534932,
2744 0.760308, -0.787088, -0.960398, -0.105922, -0.091343,
2745 0.702934, -0.758336, -0.169504, -0.121425, 0.334935,
2746 -0.962173, 0.359347, -0.151140, 0.537460, 0.753989,
2747 -0.436323, 0.759058, 0.439187, -0.691680, -0.579662,
2748 0.333608, 0.453454, -0.684948, 0.526567, -0.515429,
2749 0.520333, -0.311132, -0.051443, -0.790448, -0.237807,
2750 0.413625, 0.969861, -0.024895, 0.453226, -0.136061,
2751 0.883762, 0.156160, 0.105603, -0.285741, -0.965264,
2752 -0.559462, -0.247914, 0.394083, 0.289398, -0.710455,
2753 0.148072, 0.853074, -0.951397, -0.412742, -0.838606,
2754 -0.531059, 0.920866, 0.614848, -0.216007, 0.447434,
2755 -0.900580, -0.695673, -0.863698, 0.047977, -0.486121,
2756 -0.101505, -0.538399, -0.516261, 0.873600, 0.914828,
2757 0.347678, 0.757362, 0.070988, -0.546718, -0.528380,
2758 0.105724, -0.106180, 0.223706, -0.500194, -0.816782,
2759 0.513251, 0.647878, -0.963708, 0.561854, -0.764864,
2760 -0.802314, -0.969205, -0.843997, 0.812534, -0.185212,
2761 0.603436, 0.911954, 0.119114, 0.739738, -0.040069,
2762 0.632993, -0.361767, 0.421532, -0.883268, -0.488168,
2763 0.336360, 0.464411, -0.730806, -0.592652, 0.917693,
2764 -0.259186, 0.513071, -0.188487, 0.964520, -0.987122,
2765 -0.005270, 0.477771, 0.660756, 0.031023, 0.039625,
2766 0.895892, 0.228709, 0.070419, -0.948105, 0.041243,
2767 0.885207, 0.655331, -0.046803, 0.004321, 0.395069,
2768 0.913128, -0.362686, -0.966698, 0.334661, -0.245954,
2769 -0.454865, -0.328980, -0.781543, -0.185671, 0.078368,
2770 -0.863850, 0.555143, -0.408560, -0.052338, 0.519663,
2771 -0.395683, 0.942393, -0.002565, -0.734927, -0.026585,
2772 -0.962941, -0.839035, -0.797876, 0.107479, -0.787140,
2773 0.243367, -0.007314, 0.868191, -0.803435, 0.997007,
2774 0.263261, -0.890307, -0.365679, 0.296563, 0.444354,
2775 0.388367, 0.841698, -0.884626, 0.606824, -0.343973,
2776 0.193743, 0.742974, -0.788830, 0.785182, -0.309364,
2777 0.730833, -0.610500, -0.366971, -0.271732, -0.345427,
2778 0.606444, -0.234673, -0.184462, 0.808568, 0.872806,
2779 0.028398, 0.051936, -0.134508, -0.103410, 0.248500,
2780 -0.137501, -0.840150, 0.358194, 0.496819, 0.456413,
2781 -0.197453, -0.114814, 0.298111, -0.082078, -0.507990,
2782 0.954138, -0.888336, -0.765016, -0.834692, 0.896847,
2783 -0.074380, 0.896141, -0.713654, 0.558649, -0.375591,
2784 -0.059081, 0.165093, 0.389736, 0.756458, -0.026339,
2785 0.262542, -0.215144, -0.974403, -0.871966, 0.681446
2786};
2787
2788static const float wmavoice_gain_silence[256] = {
2789 0.0000188351, 0.0000249147, 0.0000294447, 0.0000365973,
2790 0.0000423193, 0.0000464916, 0.0000498295, 0.0000525713,
2791 0.0000550747, 0.0000574589, 0.0000596046, 0.0000615120,
2792 0.0000634193, 0.0000649691, 0.0000665188, 0.0000679493,
2793 0.0000692606, 0.0000704527, 0.0000716448, 0.0000728369,
2794 0.0000737906, 0.0000747442, 0.0000755787, 0.0000762939,
2795 0.0000770092, 0.0000778437, 0.0000785589, 0.0000792742,
2796 0.0000799894, 0.0000807047, 0.0000814199, 0.0000822544,
2797 0.0000829697, 0.0000838041, 0.0000845194, 0.0000854731,
2798 0.0000865459, 0.0000876188, 0.0000889301, 0.0000904799,
2799 0.0000923872, 0.0000950098, 0.0000988245, 0.0001032352,
2800 0.0001088381, 0.0001147985, 0.0001225471, 0.0001319647,
2801 0.0001431704, 0.0001568794, 0.0001744032, 0.0001952648,
2802 0.0002206564, 0.0002535582, 0.0002965927, 0.0003464222,
2803 0.0004109144, 0.0004891157, 0.0005909204, 0.0007261038,
2804 0.0008867979, 0.0010721684, 0.0012696981, 0.0015079975,
2805 0.0017461777, 0.0019979477, 0.0022052526, 0.0023679733,
2806 0.0025173426, 0.0026556253, 0.0027927160, 0.0029264688,
2807 0.0030447245, 0.0031807423, 0.0033060312, 0.0034313202,
2808 0.0035454035, 0.0036598444, 0.0037686825, 0.0038731098,
2809 0.0039769411, 0.0040702820, 0.0041661263, 0.0042562485,
2810 0.0043400526, 0.0044249296, 0.0045082569, 0.0045900345,
2811 0.0046693087, 0.0047430992, 0.0048171282, 0.0048881769,
2812 0.0049589872, 0.0050252676, 0.0050880909, 0.0051497221,
2813 0.0052082539, 0.0052671432, 0.0053246021, 0.0053800344,
2814 0.0054348707, 0.0054861307, 0.0055367947, 0.0055862665,
2815 0.0056355000, 0.0056805611, 0.0057252645, 0.0057705641,
2816 0.0058110952, 0.0058538914, 0.0058966875, 0.0059366226,
2817 0.0059723854, 0.0060091019, 0.0060437918, 0.0060794353,
2818 0.0061159134, 0.0061485767, 0.0061824322, 0.0062153339,
2819 0.0062497854, 0.0062820911, 0.0063197613, 0.0063550472,
2820 0.0063927174, 0.0064336061, 0.0064769983, 0.0065194368,
2821 0.0065603256, 0.0066006184, 0.0066410303, 0.0066826344,
2822 0.0067234039, 0.0067654848, 0.0068060160, 0.0068466663,
2823 0.0068866014, 0.0069231987, 0.0069609880, 0.0069983006,
2824 0.0070366859, 0.0070750713, 0.0071122646, 0.0071535110,
2825 0.0071973801, 0.0072410107, 0.0072846413, 0.0073343515,
2826 0.0073832273, 0.0074360371, 0.0074878931, 0.0075426102,
2827 0.0076007843, 0.0076560974, 0.0077134371, 0.0077683926,
2828 0.0078265667, 0.0078855753, 0.0079488754, 0.0080170631,
2829 0.0080827475, 0.0081528425, 0.0082212687, 0.0082877874,
2830 0.0083510876, 0.0084129572, 0.0084775686, 0.0085455179,
2831 0.0086110830, 0.0086781979, 0.0087503195, 0.0088242292,
2832 0.0089002848, 0.0089734793, 0.0090423822, 0.0091133118,
2833 0.0091816187, 0.0092473030, 0.0093164444, 0.0093911886,
2834 0.0094678402, 0.0095427036, 0.0096175671, 0.0096931458,
2835 0.0097666979, 0.0098397732, 0.0099166632, 0.0099946260,
2836 0.0100749731, 0.0101612806, 0.0102528334, 0.0103493929,
2837 0.0104434490, 0.0105448961, 0.0106583834, 0.0107737780,
2838 0.0108981133, 0.0110142231, 0.0111318827, 0.0112472773,
2839 0.0113576651, 0.0114786625, 0.0116028786, 0.0117331743,
2840 0.0118676424, 0.0120122433, 0.0121580362, 0.0123010874,
2841 0.0124633312, 0.0126402378, 0.0128232241, 0.0130140781,
2842 0.0132108927, 0.0134289265, 0.0136625767, 0.0138912201,
2843 0.0141364336, 0.0144006014, 0.0146615505, 0.0149335861,
2844 0.0152134895, 0.0155050755, 0.0158376694, 0.0162067413,
2845 0.0165973902, 0.0169926882, 0.0174319744, 0.0179271698,
2846 0.0184448957, 0.0190744400, 0.0197248459, 0.0204203129,
2847 0.0212460756, 0.0221523046, 0.0231562853, 0.0243031979,
2848 0.0256397724, 0.0271918774, 0.0289602280, 0.0310072899,
2849 0.0333702564, 0.0363805294, 0.0401413441, 0.0443998575,
2850 0.0498176813, 0.0562580824, 0.0640066862, 0.0732775927,
2851 0.0836604834, 0.0962959528, 0.1122496128, 0.1335854530,
2852 0.1608980894, 0.1990102530, 0.2616490126, 0.3926030397
2853};
2854
2855static const float wmavoice_gain_universal[64] = {
2856 0.0000000000, 0.0000000000, 0.0000015497, 0.0000015497,
2857 0.0000095367, 0.0000164509, 0.0000379086, 0.0000494719,
2858 0.0000799894, 0.0001058578, 0.0001349449, 0.0001627207,
2859 0.0001972914, 0.0002325773, 0.0002671480, 0.0003106594,
2860 0.0003589392, 0.0004127026, 0.0004582405, 0.0005071163,
2861 0.0005759001, 0.0006588697, 0.0007554293, 0.0008602142,
2862 0.0009772778, 0.0011068583, 0.0012603998, 0.0013889074,
2863 0.0015437603, 0.0016924143, 0.0018980503, 0.0021264553,
2864 0.0023632050, 0.0025693178, 0.0028522015, 0.0031896830,
2865 0.0034654140, 0.0037885904, 0.0041683912, 0.0046081543,
2866 0.0050576925, 0.0055632591, 0.0061818361, 0.0068151951,
2867 0.0073953867, 0.0081818104, 0.0091186762, 0.0102789402,
2868 0.0119919777, 0.0134155750, 0.0154829025, 0.0173798800,
2869 0.0199711323, 0.0229473114, 0.0268185139, 0.0319474936,
2870 0.0393068790, 0.0460114479, 0.0523469448, 0.0637906790,
2871 0.0845471621, 0.1105458736, 0.1499300003, 0.2219169140
2872};
2873
2874static const float wmavoice_gain_codebook_acb[128] = {
2875 0.05, 0.14, 0.16, 0.05, 0.17, 0.25, 0.07, 0.21,
2876 0.12, 0.22, 0.23, 0.13, 0.24, 0.32, 0.14, 0.29,
2877 0.31, 0.41, 0.43, 0.32, 0.43, 0.51, 0.34, 0.48,
2878 0.38, 0.47, 0.49, 0.38, 0.49, 0.57, 0.40, 0.54,
2879 0.49, 0.59, 0.61, 0.50, 0.61, 0.69, 0.52, 0.66,
2880 0.56, 0.65, 0.67, 0.56, 0.67, 0.75, 0.58, 0.72,
2881 0.65, 0.74, 0.76, 0.65, 0.76, 0.84, 0.67, 0.81,
2882 0.71, 0.80, 0.82, 0.71, 0.82, 0.90, 0.73, 0.87,
2883 0.81, 0.90, 0.92, 0.81, 0.93, 1.01, 0.83, 0.97,
2884 0.87, 0.96, 0.98, 0.87, 0.98, 1.06, 0.89, 1.03,
2885 0.92, 1.02, 1.04, 0.93, 1.04, 1.12, 0.95, 1.09,
2886 0.93, 1.02, 1.04, 0.93, 1.04, 1.12, 0.95, 1.09,
2887 0.94, 1.04, 1.05, 0.10, 1.06, 1.14, 0.96, 1.11,
2888 0.98, 1.08, 1.10, 0.99, 1.10, 1.18, 1.01, 1.15,
2889 1.06, 1.15, 1.17, 1.06, 1.17, 1.25, 1.08, 1.22,
2890 1.16, 1.25, 1.27, 1.16, 1.28, 1.36, 1.18, 1.32
2891};
2892
2893static const float wmavoice_gain_codebook_fcb[128] = {
2894 -0.8439700703 /* log(0.430) */, -0.6143360001 /* log(0.541) */,
2895 -0.1531511795 /* log(0.858) */, -0.0998203353 /* log(0.905) */,
2896 0.3213585988 /* log(1.379) */, 0.3777512695 /* log(1.459) */,
2897 0.7158866675 /* log(2.046) */, 1.2700414043 /* log(3.561) */,
2898 -1.6873994539 /* log(0.185) */, -1.2173958247 /* log(0.296) */,
2899 -0.4893903430 /* log(0.613) */, -0.4155154440 /* log(0.660) */,
2900 0.1257512053 /* log(1.134) */, 0.1947440768 /* log(1.215) */,
2901 0.5883420662 /* log(1.801) */, 1.1987592373 /* log(3.316) */,
2902 -1.3586791941 /* log(0.257) */, -0.9996723408 /* log(0.368) */,
2903 -0.3768776513 /* log(0.686) */, -0.3119747650 /* log(0.732) */,
2904 0.1881379421 /* log(1.207) */, 0.2523139286 /* log(1.287) */,
2905 0.6280751838 /* log(1.874) */, 1.2202397768 /* log(3.388) */,
2906 -0.7381445465 /* log(0.478) */, -0.5310283311 /* log(0.588) */,
2907 -0.0987159729 /* log(0.906) */, -0.0491902442 /* log(0.952) */,
2908 0.3555743385 /* log(1.427) */, 0.4101209196 /* log(1.507) */,
2909 0.7390761124 /* log(2.094) */, 1.2831536022 /* log(3.608) */,
2910 -0.2497442331 /* log(0.779) */, -0.1165338163 /* log(0.890) */,
2911 0.1881379421 /* log(1.207) */, 0.2255406759 /* log(1.253) */,
2912 0.5469646704 /* log(1.728) */, 0.5922212620 /* log(1.808) */,
2913 0.8733832309 /* log(2.395) */, 1.3632815868 /* log(3.909) */,
2914 -1.3903023825 /* log(0.249) */, -1.0216512475 /* log(0.360) */,
2915 -0.3900840061 /* log(0.677) */, -0.3229638866 /* log(0.724) */,
2916 0.1806534997 /* log(1.198) */, 0.2460785226 /* log(1.279) */,
2917 0.6232610531 /* log(1.865) */, 1.2178757095 /* log(3.380) */,
2918 -0.6033064766 /* log(0.547) */, -0.4185503477 /* log(0.658) */,
2919 -0.0253178080 /* log(0.975) */, 0.0217614918 /* log(1.022) */,
2920 0.4027948796 /* log(1.496) */, 0.4555243080 /* log(1.577) */,
2921 0.7714961470 /* log(2.163) */, 1.3023691262 /* log(3.678) */,
2922 -1.1056369036 /* log(0.331) */, -0.8164453969 /* log(0.442) */,
2923 -0.2757535016 /* log(0.759) */, -0.2156715365 /* log(0.806) */,
2924 0.2468600779 /* log(1.280) */, 0.3082197237 /* log(1.361) */,
2925 0.6662897264 /* log(1.947) */, 1.2418464568 /* log(3.462) */,
2926 -0.5395680926 /* log(0.583) */, -0.3652833185 /* log(0.694) */,
2927 0.0109399400 /* log(1.011) */, 0.0554347069 /* log(1.057) */,
2928 0.4265740713 /* log(1.532) */, 0.4774756441 /* log(1.612) */,
2929 0.7880027116 /* log(2.199) */, 1.3118401752 /* log(3.713) */,
2930 -0.9571127264 /* log(0.384) */, -0.7031975164 /* log(0.495) */,
2931 -0.2082549388 /* log(0.812) */, -0.1519863570 /* log(0.859) */,
2932 0.2874320412 /* log(1.333) */, 0.3464225675 /* log(1.414) */,
2933 0.6931471806 /* log(2.000) */, 1.2570395253 /* log(3.515) */,
2934 -0.2420715612 /* log(0.785) */, -0.1098148660 /* log(0.896) */,
2935 0.1930966300 /* log(1.213) */, 0.2311117210 /* log(1.260) */,
2936 0.5504308784 /* log(1.734) */, 0.5960854677 /* log(1.815) */,
2937 0.8758853172 /* log(2.401) */, 1.3650707247 /* log(3.916) */,
2938 0.6564831962 /* log(1.928) */, 0.7124594916 /* log(2.039) */,
2939 0.8569652658 /* log(2.356) */, 0.8767179568 /* log(2.403) */,
2940 1.0567480846 /* log(2.877) */, 1.0841752409 /* log(2.957) */,
2941 1.2652560327 /* log(3.544) */, 1.6211688353 /* log(5.059) */,
2942 -1.5417792640 /* log(0.214) */, -1.1239300967 /* log(0.325) */,
2943 -0.4431669753 /* log(0.642) */, -5.2983173665 /* log(0.005) */,
2944 0.1510028735 /* log(1.163) */, 0.2183319943 /* log(1.244) */,
2945 0.6043159669 /* log(1.830) */, 1.2074666936 /* log(3.345) */,
2946 -0.5124936809 /* log(0.599) */, -0.3424903089 /* log(0.710) */,
2947 0.0266419309 /* log(1.027) */, 0.0713899961 /* log(1.074) */,
2948 0.4369637752 /* log(1.548) */, 0.4879663296 /* log(1.629) */,
2949 0.7952524035 /* log(2.215) */, 1.3164082337 /* log(3.730) */,
2950 -0.8867319296 /* log(0.412) */, -0.6481738149 /* log(0.523) */,
2951 -0.1743533871 /* log(0.840) */, -0.1199102967 /* log(0.887) */,
2952 0.3089542077 /* log(1.362) */, 0.3660310389 /* log(1.442) */,
2953 0.7075430608 /* log(2.029) */, 1.2649738259 /* log(3.543) */,
2954 -0.0943106795 /* log(0.910) */, 0.0207825392 /* log(1.021) */,
2955 0.2911759617 /* log(1.338) */, 0.3249778572 /* log(1.384) */,
2956 0.6200387087 /* log(1.859) */, 0.6621723763 /* log(1.939) */,
2957 0.9266370239 /* log(2.526) */, 1.3962446920 /* log(4.040) */
2958};
2959
2960static const float wmavoice_ipol1_coeffs[17*9] = {
2961 0,
2962 0.6308171151, 0.7613050340, 0.8632577061, 0.9280143976,
2963 0.9499985575, 0.9273047447, 0.8618999123, 0.7594153284,
2964 -0.1791058179, -0.1351341452, -0.0589959878, 0.0472882274,
2965 0.1784339990, 0.3262237605, 0.4801855979, 0.6285545824,
2966 0,
2967 -0.1921342459, -0.1786532696, -0.1341681625, -0.0575229186,
2968 0.0492091286, 0.1806929555, 0.3286687729, 0.4826357064,
2969 0.0807464118, 0.0506337392, 0.0080115446, -0.0428523305,
2970 -0.0958572026, -0.1436148431, -0.1782128509, -0.1921164688,
2971 0,
2972 0.0960653644, 0.0803771760, 0.0500416081, 0.0072485465,
2973 -0.0437018941, -0.0966834794, -0.1442930843, -0.1786170151,
2974 -0.0391932014, -0.0189622506, 0.0070230183, 0.0356589290,
2975 0.0630142610, 0.0847979258, 0.0969368290, 0.0961942221,
2976 0,
2977 -0.0515680681, -0.0389267015, -0.0185848991, 0.0074699190,
2978 0.0361179407, 0.0634181346, 0.0850781347, 0.0970333587,
2979 0.0178811825, 0.0048708571, -0.0108041526, -0.0271167825,
2980 -0.0416534986, -0.0519338618, -0.0557823736, -0.0517020743,
2981 0,
2982 0.0267091128, 0.0177022810, 0.0046363524, -0.0110662053,
2983 -0.0273700613, -0.0418578978, -0.0520511451, -0.0557823028,
2984 -0.0069270437, 0.0008217385, 0.0097293532, 0.0185749526,
2985 0.0259542684, 0.0304777338, 0.0309953480, 0.0268154419,
2986 0,
2987 -0.0125539196, -0.0068173436, 0.0009580161, 0.0098749646,
2988 0.0187084037, 0.0260526291, 0.0305201071, 0.0309665180,
2989 0.0019149571, -0.0022503408, -0.0068592466, -0.0112465904,
2990 -0.0146595868, -0.0163685936, -0.0157934162, -0.0126258885,
2991 0,
2992 0.0050976076, 0.0018546581, -0.0023221741, -0.0069331308,
2993 -0.0113109085, -0.0147021576, -0.0163786146, -0.0157635096,
2994 -0.0001162733, 0.0019313511, 0.0040823850, 0.0060192454,
2995 0.0073876535, 0.0078486321, 0.0071403184, 0.0051400312,
2996 0,
2997 -0.0017920607, -0.0000857157, 0.0019657183, 0.0041159806,
2998 0.0060465694, 0.0074030068, 0.0078470460, 0.0071185785,
2999 -0.0004100171, -0.0015364708, -0.0025490071, -0.0033188616,
3000 -0.0037196307, -0.0036417283, -0.0030119629, -0.0018155784,
3001 0,
3002 0.0006907531, -0.0004282868, -0.0015539061, -0.0025635813,
3003 -0.0033285026, -0.0037224069, -0.0036361245, -0.0029972247,
3004 0, 0, 0, 0, 0, 0, 0, 0
3005};
3006
3007/**
3008 * Hamming-window sinc function (num = 32, x = [ 0, 31 ]):
3009 * (0.54 + 0.46 * cos(2 * M_PI * x / (num - 1))) *
3010 * sin(x * M_PI / 4) / (x * M_PI / 4)
3011 */
3012static const float wmavoice_ipol2_coeffs[32] = {
3013 1, 0.8563459515, 0.5888634918, 0.2648358640,
3014 0, -0.1360490318, -0.1434589471, -0.0758505310,
3015 0, 0.0410402636, 0.0412485781, 0.0200064587,
3016 0, -0.0081391358, -0.0068223253, -0.0029313546,
3017 0, 0.0025864919, 0.0053062555, 0.0055688801,
3018 0, -0.0104795941, -0.0187493577, -0.0160592399,
3019 0, 0.0212381664, 0.0331059131, 0.0251942366,
3020 0, -0.0273968070, -0.0392575669, -0.0276240534
3021};
3022
3023/**
3024 * LUT for 1.071575641632 * pow(1.0331663, n - 127)
3025 */
3026static const float wmavoice_energy_table[128] = {
3027 0.0169982178, 0.0175619858, 0.0181444519, 0.0187462362,
3028 0.0193679795, 0.0200103437, 0.0206740128, 0.0213596933,
3029 0.0220681153, 0.0228000330, 0.0235562258, 0.0243374986,
3030 0.0251446834, 0.0259786395, 0.0268402549, 0.0277304468,
3031 0.0286501631, 0.0296003830, 0.0305821182, 0.0315964139,
3032 0.0326443501, 0.0337270424, 0.0348456436, 0.0360013446,
3033 0.0371953760, 0.0384290090, 0.0397035571, 0.0410203772,
3034 0.0423808713, 0.0437864880, 0.0452387238, 0.0467391249,
3035 0.0482892887, 0.0498908657, 0.0515455612, 0.0532551367,
3036 0.0550214125, 0.0568462692, 0.0587316496, 0.0606795611,
3037 0.0626920777, 0.0647713419, 0.0669195677, 0.0691390421,
3038 0.0714321284, 0.0738012678, 0.0762489827, 0.0787778794,
3039 0.0813906502, 0.0840900769, 0.0868790336, 0.0897604897,
3040 0.0927375130, 0.0958132732, 0.0989910450, 0.1022742117,
3041 0.1056662688, 0.1091708280, 0.1127916204, 0.1165325012,
3042 0.1203974531, 0.1243905911, 0.1285161668, 0.1327785725,
3043 0.1371823465, 0.1417321773, 0.1464329093, 0.1512895470,
3044 0.1563072616, 0.1614913951, 0.1668474671, 0.1723811803,
3045 0.1780984262, 0.1840052921, 0.1901080668, 0.1964132480,
3046 0.2029275487, 0.2096579046, 0.2166114816, 0.2237956830,
3047 0.2312181577, 0.2388868085, 0.2468098001, 0.2549955679,
3048 0.2634528274, 0.2721905830, 0.2812181375, 0.2905451026,
3049 0.3001814086, 0.3101373153, 0.3204234225, 0.3310506819,
3050 0.3420304081, 0.3533742912, 0.3650944090, 0.3772032397,
3051 0.3897136755, 0.4026390362, 0.4159930832, 0.4297900346,
3052 0.4440445799, 0.4587718956, 0.4739876619, 0.4897080789,
3053 0.5059498840, 0.5227303696, 0.5400674019, 0.5579794393,
3054 0.5764855528, 0.5956054456, 0.6153594745, 0.6357686714,
3055 0.6568547659, 0.6786402082, 0.7011481929, 0.7244026842,
3056 0.7484284410, 0.7732510432, 0.7988969192, 0.8253933741,
3057 0.8527686184, 0.8810517982, 0.9102730265, 0.9404634147,
3058 0.9716551065, 1.0038813113, 1.0371763400, 1.0715756416
3059};
3060
3061/**
3062 * LUT for f(x,y) = pow((y + 6.9) / 64, 0.025 * (x + 1)).
3063 */
3064static const float wmavoice_denoise_power_table[12][64] = {
3065 { 0.9458379339, 0.9490436287, 0.9518757236, 0.9544130754,
3066 0.9567118717, 0.9588135761, 0.9607496688, 0.9625446194,
3067 0.9642178285, 0.9657849396, 0.9672587526, 0.9686498743,
3068 0.9699671937, 0.9712182343, 0.9724094211, 0.9735462842,
3069 0.9746336187, 0.9756756090, 0.9766759291, 0.9776378218,
3070 0.9785641645, 0.9794575217, 0.9803201890, 0.9811542296,
3071 0.9819615045, 0.9827436985, 0.9835023412, 0.9842388263,
3072 0.9849544265, 0.9856503078, 0.9863275406, 0.9869871101,
3073 0.9876299254, 0.9882568267, 0.9888685922, 0.9894659445,
3074 0.9900495551, 0.9906200497, 0.9911780119, 0.9917239872,
3075 0.9922584859, 0.9927819864, 0.9932949377, 0.9937977618,
3076 0.9942908555, 0.9947745929, 0.9952493267, 0.9957153901,
3077 0.9961730980, 0.9966227482, 0.9970646231, 0.9974989903,
3078 0.9979261037, 0.9983462046, 0.9987595223, 0.9991662752,
3079 0.9995666709, 0.9999609077, 1.0003491745, 1.0007316515,
3080 1.0011085110, 1.0014799178, 1.0018460292, 1.0022069960 },
3081 { 0.8946093973, 0.9006838092, 0.9060673931, 0.9109043185,
3082 0.9152976055, 0.9193234737, 0.9230399260, 0.9264921443,
3083 0.9297160207, 0.9327405496, 0.9355894944, 0.9382825789,
3084 0.9408363568, 0.9432648587, 0.9455800822, 0.9477923675,
3085 0.9499106907, 0.9519428941, 0.9538958704, 0.9557757107,
3086 0.9575878241, 0.9593370368, 0.9610276730, 0.9626636222,
3087 0.9642483964, 0.9657851769, 0.9672768552, 0.9687260672,
3088 0.9701352224, 0.9715065293, 0.9728420173, 0.9741435556,
3089 0.9754128696, 0.9766515555, 0.9778610927, 0.9790428553,
3090 0.9801981216, 0.9813280829, 0.9824338513, 0.9835164667,
3091 0.9845769028, 0.9856160726, 0.9866348334, 0.9876339913,
3092 0.9886143053, 0.9895764906, 0.9905212223, 0.9914491381,
3093 0.9923608411, 0.9932569022, 0.9941378627, 0.9950042356,
3094 0.9958565084, 0.9966951442, 0.9975205834, 0.9983332454,
3095 0.9991335296, 0.9999218170, 1.0006984708, 1.0014638383,
3096 1.0022182509, 1.0029620257, 1.0036954662, 1.0044188628 },
3097 { 0.8461555040, 0.8547882305, 0.8624635555, 0.8693789920,
3098 0.8756760853, 0.8814598273, 0.8868103032, 0.8917900284,
3099 0.8964487626, 0.9008267754, 0.9049571273, 0.9088673021,
3100 0.9125804007, 0.9161160306, 0.9194909803, 0.9227197376,
3101 0.9258148939, 0.9287874629, 0.9316471355, 0.9344024839,
3102 0.9370611291, 0.9396298766, 0.9421148300, 0.9445214846,
3103 0.9468548060, 0.9491192967, 0.9513190517, 0.9534578074,
3104 0.9555389816, 0.9575657096, 0.9595408742, 0.9614671327,
3105 0.9633469396, 0.9651825670, 0.9669761222, 0.9687295635,
3106 0.9704447142, 0.9721232742, 0.9737668316, 0.9753768718,
3107 0.9769547868, 0.9785018824, 0.9800193854, 0.9815084500,
3108 0.9829701633, 0.9844055505, 0.9858155796, 0.9872011653,
3109 0.9885631734, 0.9899024236, 0.9912196934, 0.9925157203,
3110 0.9937912053, 0.9950468143, 0.9962831814, 0.9975009102,
3111 0.9987005760, 0.9998827277, 1.0010478892, 1.0021965608,
3112 1.0033292209, 1.0044463270, 1.0055483173, 1.0066356112 },
3113 { 0.8003259737, 0.8112313241, 0.8209581209, 0.8297466775,
3114 0.8377697066, 0.8451556492, 0.8520027051, 0.8583876935,
3115 0.8643718792, 0.8700049328, 0.8753277020, 0.8803741979,
3116 0.8851730502, 0.8897485937, 0.8941216918, 0.8983103719,
3117 0.9023303202, 0.9061952736, 0.9099173316, 0.9135072091,
3118 0.9169744409, 0.9203275502, 0.9235741882, 0.9267212496,
3119 0.9297749699, 0.9327410079, 0.9356245146, 0.9384301933,
3120 0.9411623497, 0.9438249364, 0.9464215906, 0.9489556668,
3121 0.9514302661, 0.9538482608, 0.9562123167, 0.9585249126,
3122 0.9607883576, 0.9630048062, 0.9651762722, 0.9673046403,
3123 0.9693916775, 0.9714390425, 0.9734482944, 0.9754209007,
3124 0.9773582446, 0.9792616307, 0.9811322918, 0.9829713934,
3125 0.9847800389, 0.9865592739, 0.9883100900, 0.9900334289,
3126 0.9917301853, 0.9934012104, 0.9950473143, 0.9966692689,
3127 0.9982678100, 0.9998436400, 1.0013974295, 1.0029298194,
3128 1.0044414224, 1.0059328250, 1.0074045889, 1.0088572520 },
3129 { 0.7569786654, 0.7698939195, 0.7814501054, 0.7919210783,
3130 0.8015042240, 0.8103467104, 0.8185613167, 0.8262364557,
3131 0.8334427763, 0.8402376615, 0.8466683811, 0.8527743561,
3132 0.8585888194, 0.8641400582, 0.8694523567, 0.8745467247,
3133 0.8794414652, 0.8841526254, 0.8886943552, 0.8930791981,
3134 0.8973183276, 0.9014217415, 0.9053984227, 0.9092564737,
3135 0.9130032283, 0.9166453478, 0.9201889007, 0.9236394320,
3136 0.9270020224, 0.9302813390, 0.9334816797, 0.9366070112,
3137 0.9396610028, 0.9426470554, 0.9455683275, 0.9484277579,
3138 0.9512280860, 0.9539718690, 0.9566614986, 0.9592992147,
3139 0.9618871182, 0.9644271823, 0.9669212630, 0.9693711079,
3140 0.9717783651, 0.9741445900, 0.9764712529, 0.9787597445,
3141 0.9810113822, 0.9832274148, 0.9854090274, 0.9875573457,
3142 0.9896734398, 0.9917583281, 0.9938129803, 0.9958383209,
3143 0.9978352315, 0.9998045539, 1.0017470919, 1.0036636145,
3144 1.0055548568, 1.0074215229, 1.0092642871, 1.0110837959 },
3145 { 0.7159791370, 0.7306629191, 0.7438433845, 0.7558198318,
3146 0.7668086064, 0.7769714272, 0.7864325139, 0.7952894548,
3147 0.8036203840, 0.8114888792, 0.8189474022, 0.8260397728,
3148 0.8328029877, 0.8392685815, 0.8454636629, 0.8514117142,
3149 0.8571332177, 0.8626461513, 0.8679663850, 0.8731080020,
3150 0.8780835596, 0.8829043049, 0.8875803529, 0.8921208349,
3151 0.8965340237, 0.9008274393, 0.9050079382, 0.9090817905,
3152 0.9130547454, 0.9169320882, 0.9207186893, 0.9244190474,
3153 0.9280373261, 0.9315773876, 0.9350428208, 0.9384369673,
3154 0.9417629433, 0.9450236603, 0.9482218422, 0.9513600421,
3155 0.9544406555, 0.9574659338, 0.9604379957, 0.9633588374,
3156 0.9662303420, 0.9690542879, 0.9718323569, 0.9745661408,
3157 0.9772571477, 0.9799068082, 0.9825164805, 0.9850874551,
3158 0.9876209597, 0.9901181627, 0.9925801775, 0.9950080658,
3159 0.9974028405, 0.9997654692, 1.0020968764, 1.0043979464,
3160 1.0066695255, 1.0089124239, 1.0111274185, 1.0133152537 },
3161 { 0.6772002277, 0.6934309881, 0.7080464599, 0.7213643301,
3162 0.7336148970, 0.7449707526, 0.7555647772, 0.7655015856,
3163 0.7748651015, 0.7837237382, 0.7921340426, 0.8001433220,
3164 0.8077915768, 0.8151129499, 0.8221368310, 0.8288887107,
3165 0.8353908496, 0.8416628090, 0.8477218755, 0.8535834053,
3166 0.8592611049, 0.8647672624, 0.8701129393, 0.8753081305,
3167 0.8803618988, 0.8852824894, 0.8900774261, 0.8947535945,
3168 0.8993173131, 0.9037743949, 0.9081302004, 0.9123896841,
3169 0.9165574352, 0.9206377129, 0.9246344779, 0.9285514202,
3170 0.9323919830, 0.9361593853, 0.9398566405, 0.9434865742,
3171 0.9470518396, 0.9505549317, 0.9539981992, 0.9573838564,
3172 0.9607139933, 0.9639905847, 0.9672154989, 0.9703905051,
3173 0.9735172803, 0.9765974162, 0.9796324243, 0.9826237418,
3174 0.9855727362, 0.9884807098, 0.9913489039, 0.9941785028,
3175 0.9969706369, 0.9997263861, 1.0024467831, 1.0051328157,
3176 1.0077854297, 1.0104055314, 1.0129939892, 1.0155516364 },
3177 { 0.6405216642, 0.6580962612, 0.6739722363, 0.6884795488,
3178 0.7018580813, 0.7142880714, 0.7259086094, 0.7368294324,
3179 0.7471387455, 0.7569085832, 0.7661985859, 0.7750587283,
3180 0.7835313288, 0.7916525600, 0.7994535998, 0.8069615243,
3181 0.8142000068, 0.8211898738, 0.8279495504, 0.8344954211,
3182 0.8408421252, 0.8470027997, 0.8529892811, 0.8588122744,
3183 0.8644814947, 0.8700057878, 0.8753932324, 0.8806512276,
3184 0.8857865684, 0.8908055105, 0.8957138271, 0.9005168576,
3185 0.9052195513, 0.9098265046, 0.9143419945, 0.9187700080,
3186 0.9231142680, 0.9273782568, 0.9315652364, 0.9356782672,
3187 0.9397202245, 0.9436938133, 0.9476015819, 0.9514459336,
3188 0.9552291382, 0.9589533414, 0.9626205741, 0.9662327603,
3189 0.9697917251, 0.9732992008, 0.9767568340, 0.9801661903,
3190 0.9835287605, 0.9868459649, 0.9901191578, 0.9933496315,
3191 0.9965386205, 0.9996873045, 1.0027968119, 1.0058682226,
3192 1.0089025710, 1.0119008485, 1.0148640056, 1.0177929548 },
3193 { 0.6058296875, 0.6245620637, 0.6415378101, 0.6570938835,
3194 0.6714759586, 0.6848691001, 0.6974164561, 0.7092312055,
3195 0.7204044988, 0.7310109103, 0.7411122884, 0.7507605397,
3196 0.7599996842, 0.7688674015, 0.7773962122, 0.7856143935,
3197 0.7935466990, 0.8012149303, 0.8086383963, 0.8158342858,
3198 0.8228179717, 0.8296032631, 0.8362026133, 0.8426272954,
3199 0.8488875492, 0.8549927056, 0.8609512936, 0.8667711307,
3200 0.8724594015, 0.8780227256, 0.8834672161, 0.8887985309,
3201 0.8940219180, 0.8991422543, 0.9041640810, 0.9090916337,
3202 0.9139288704, 0.9186794948, 0.9233469789, 0.9279345818,
3203 0.9324453671, 0.9368822185, 0.9412478543, 0.9455448393,
3204 0.9497755970, 0.9539424198, 0.9580474782, 0.9620928299,
3205 0.9660804271, 0.9700121244, 0.9738896845, 0.9777147851,
3206 0.9814890239, 0.9852139236, 0.9888909370, 0.9925214512,
3207 0.9961067913, 0.9996482244, 1.0031469629, 1.0066041676,
3208 1.0100209506, 1.0133983785, 1.0167374742, 1.0200392198 },
3209 { 0.5730166999, 0.5927366473, 0.6106642672, 0.6271389942,
3210 0.6424090212, 0.6566617910, 0.6700426292, 0.6826666808,
3211 0.6946268614, 0.7059993279, 0.7168473476, 0.7272241023,
3212 0.7371747608, 0.7467380401, 0.7559474006, 0.7648319736,
3213 0.7734172908, 0.7817258650, 0.7897776570, 0.7975904541,
3214 0.8051801811, 0.8125611560, 0.8197463039, 0.8267473349,
3215 0.8335748949, 0.8402386937, 0.8467476129, 0.8531098003,
3216 0.8593327495, 0.8654233698, 0.8713880464, 0.8772326935,
3217 0.8829628002, 0.8885834710, 0.8940994619, 0.8995152120,
3218 0.9048348715, 0.9100623268, 0.9152012229, 0.9202549833,
3219 0.9252268281, 0.9301197899, 0.9349367288, 0.9396803449,
3220 0.9443531909, 0.9489576823, 0.9534961076, 0.9579706374,
3221 0.9623833320, 0.9667361492, 0.9710309512, 0.9752695109,
3222 0.9794535174, 0.9835845813, 0.9876642399, 0.9916939614,
3223 0.9956751493, 0.9996091459, 1.0034972362, 1.0073406510,
3224 1.0111405700, 1.0148981248, 1.0186144013, 1.0222904422 },
3225 { 0.5419809316, 0.5625329386, 0.5812764912, 0.5985496562,
3226 0.6146003370, 0.6296162401, 0.6437432340, 0.6570971404,
3227 0.6697716039, 0.6818435182, 0.6933768712, 0.7044255353,
3228 0.7150353340, 0.7252456009, 0.7350903742, 0.7445993259,
3229 0.7537984929, 0.7627108595, 0.7713568269, 0.7797545943,
3230 0.7879204712, 0.7958691361, 0.8036138516, 0.8111666444,
3231 0.8185384580, 0.8257392814, 0.8327782597, 0.8396637886,
3232 0.8464035955, 0.8530048108, 0.8594740287, 0.8658173611,
3233 0.8720404845, 0.8781486812, 0.8841468762, 0.8900396688,
3234 0.8958313620, 0.9015259874, 0.9071273286, 0.9126389413,
3235 0.9180641715, 0.9234061727, 0.9286679198, 0.9338522236,
3236 0.9389617420, 0.9439989920, 0.9489663591, 0.9538661069,
3237 0.9587003852, 0.9634712378, 0.9681806094, 0.9728303524,
3238 0.9774222323, 0.9819579336, 0.9864390644, 0.9908671615,
3239 0.9952436943, 0.9995700689, 1.0038476318, 1.0080776733,
3240 1.0122614305, 1.0164000906, 1.0204947932, 1.0245466331 },
3241 { 0.5126261246, 0.5338683013, 0.5533029807, 0.5712636181,
3242 0.5879954388, 0.6036845987, 0.6184760989, 0.6324853169,
3243 0.6458057215, 0.6585142011, 0.6706748475, 0.6823417062,
3244 0.6935608163, 0.7043717519, 0.7148088052, 0.7249019070,
3245 0.7346773529, 0.7441583823, 0.7533656456, 0.7623175831,
3246 0.7710307376, 0.7795200117, 0.7877988829, 0.7958795841,
3247 0.8037732557, 0.8114900754, 0.8190393682, 0.8264297018,
3248 0.8336689680, 0.8407644543, 0.8477229049, 0.8545505751,
3249 0.8612532786, 0.8678364291, 0.8743050768, 0.8806639416,
3250 0.8869174414, 0.8930697184, 0.8991246621, 0.9050859297,
3251 0.9109569648, 0.9167410144, 0.9224411436, 0.9280602496,
3252 0.9336010737, 0.9390662129, 0.9444581300, 0.9497791628,
3253 0.9550315328, 0.9602173528, 0.9653386345, 0.9703972943,
3254 0.9753951600, 0.9803339761, 0.9852154088, 0.9900410510,
3255 0.9948124263, 0.9995309934, 1.0041981497, 1.0088152348,
3256 1.0133835335, 1.0179042791, 1.0223786564, 1.0268078035 },
3257};
3258
3259#endif /* AVCODEC_WMAVOICE_DATA_H */