Mercurial > audlegacy-plugins
annotate src/wma/libffwma/dsputil.h @ 1373:85ffec632924
Use InputPlayback.playing properly.
author | William Pitcock <nenolod@atheme-project.org> |
---|---|
date | Wed, 25 Jul 2007 16:48:53 -0500 |
parents | f3ccef1dcd61 |
children |
rev | line source |
---|---|
878 | 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 library 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 of the License, or (at your option) any later version. | |
10 * | |
11 * This library 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 this library; 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 dsputil.h | |
23 * DSP utils. | |
24 * note, many functions in here may use MMX which trashes the FPU state, it is | |
25 * absolutely necessary to call emms_c() between dsp & float/double code | |
26 */ | |
27 | |
28 #ifndef DSPUTIL_H | |
29 #define DSPUTIL_H | |
30 | |
31 #include "common.h" | |
32 #include "avcodec.h" | |
33 | |
34 | |
35 //#define DEBUG | |
36 /* dct code */ | |
37 typedef short DCTELEM; | |
38 | |
39 void fdct_ifast (DCTELEM *data); | |
40 void fdct_ifast248 (DCTELEM *data); | |
41 void ff_jpeg_fdct_islow (DCTELEM *data); | |
42 void ff_fdct248_islow (DCTELEM *data); | |
43 | |
44 void j_rev_dct (DCTELEM *data); | |
45 | |
46 void ff_fdct_mmx(DCTELEM *block); | |
47 void ff_fdct_mmx2(DCTELEM *block); | |
48 void ff_fdct_sse2(DCTELEM *block); | |
49 | |
50 /* encoding scans */ | |
51 extern const uint8_t ff_alternate_horizontal_scan[64]; | |
52 extern const uint8_t ff_alternate_vertical_scan[64]; | |
53 extern const uint8_t ff_zigzag_direct[64]; | |
54 extern const uint8_t ff_zigzag248_direct[64]; | |
55 | |
56 /* pixel operations */ | |
57 #define MAX_NEG_CROP 384 | |
58 | |
59 /* temporary */ | |
60 extern uint32_t squareTbl[512]; | |
61 extern uint8_t cropTbl[256 + 2 * MAX_NEG_CROP]; | |
62 | |
957
f3ccef1dcd61
[svn] Hammer the WMA plugin into shape enough to bolt the following upstream commit on: "WMA decoder improvement, output closer to the dmo binary.
chainsaw
parents:
878
diff
changeset
|
63 #ifdef __GNUC__ |
f3ccef1dcd61
[svn] Hammer the WMA plugin into shape enough to bolt the following upstream commit on: "WMA decoder improvement, output closer to the dmo binary.
chainsaw
parents:
878
diff
changeset
|
64 #define DECLARE_ALIGNED_8(t,v) t v __attribute__ ((aligned (8))) |
f3ccef1dcd61
[svn] Hammer the WMA plugin into shape enough to bolt the following upstream commit on: "WMA decoder improvement, output closer to the dmo binary.
chainsaw
parents:
878
diff
changeset
|
65 #define DECLARE_ALIGNED_16(t,v) t v __attribute__ ((aligned (16))) |
f3ccef1dcd61
[svn] Hammer the WMA plugin into shape enough to bolt the following upstream commit on: "WMA decoder improvement, output closer to the dmo binary.
chainsaw
parents:
878
diff
changeset
|
66 #else |
f3ccef1dcd61
[svn] Hammer the WMA plugin into shape enough to bolt the following upstream commit on: "WMA decoder improvement, output closer to the dmo binary.
chainsaw
parents:
878
diff
changeset
|
67 #define DECLARE_ALIGNED_8(t,v) __declspec(align(8)) t v |
f3ccef1dcd61
[svn] Hammer the WMA plugin into shape enough to bolt the following upstream commit on: "WMA decoder improvement, output closer to the dmo binary.
chainsaw
parents:
878
diff
changeset
|
68 #define DECLARE_ALIGNED_16(t,v) __declspec(align(16)) t v |
f3ccef1dcd61
[svn] Hammer the WMA plugin into shape enough to bolt the following upstream commit on: "WMA decoder improvement, output closer to the dmo binary.
chainsaw
parents:
878
diff
changeset
|
69 #endif |
878 | 70 |
71 /* | |
72 void get_pixels_c(DCTELEM *block, const uint8_t *pixels, int line_size); | |
73 void diff_pixels_c(DCTELEM *block, const uint8_t *s1, const uint8_t *s2, int stride); | |
74 void put_pixels_clamped_c(const DCTELEM *block, uint8_t *pixels, int line_size); | |
75 void add_pixels_clamped_c(const DCTELEM *block, uint8_t *pixels, int line_size); | |
76 void clear_blocks_c(DCTELEM *blocks); | |
77 */ | |
78 | |
79 /* add and put pixel (decoding) */ | |
80 // blocksizes for op_pixels_func are 8x4,8x8 16x8 16x16 | |
81 //h for op_pixels_func is limited to {width/2, width} but never larger than 16 and never smaller then 4 | |
82 typedef void (*op_pixels_func)(uint8_t *block/*align width (8 or 16)*/, const uint8_t *pixels/*align 1*/, int line_size, int h); | |
83 typedef 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); | |
84 typedef void (*qpel_mc_func)(uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, int stride); | |
85 typedef void (*h264_chroma_mc_func)(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int srcStride, int h, int x, int y); | |
86 | |
87 #define DEF_OLD_QPEL(name)\ | |
88 void ff_put_ ## name (uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, int stride);\ | |
89 void ff_put_no_rnd_ ## name (uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, int stride);\ | |
90 void ff_avg_ ## name (uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, int stride); | |
91 | |
92 DEF_OLD_QPEL(qpel16_mc11_old_c) | |
93 DEF_OLD_QPEL(qpel16_mc31_old_c) | |
94 DEF_OLD_QPEL(qpel16_mc12_old_c) | |
95 DEF_OLD_QPEL(qpel16_mc32_old_c) | |
96 DEF_OLD_QPEL(qpel16_mc13_old_c) | |
97 DEF_OLD_QPEL(qpel16_mc33_old_c) | |
98 DEF_OLD_QPEL(qpel8_mc11_old_c) | |
99 DEF_OLD_QPEL(qpel8_mc31_old_c) | |
100 DEF_OLD_QPEL(qpel8_mc12_old_c) | |
101 DEF_OLD_QPEL(qpel8_mc32_old_c) | |
102 DEF_OLD_QPEL(qpel8_mc13_old_c) | |
103 DEF_OLD_QPEL(qpel8_mc33_old_c) | |
104 | |
105 #define CALL_2X_PIXELS(a, b, n)\ | |
106 static void a(uint8_t *block, const uint8_t *pixels, int line_size, int h){\ | |
107 b(block , pixels , line_size, h);\ | |
108 b(block+n, pixels+n, line_size, h);\ | |
109 } | |
110 | |
111 /* motion estimation */ | |
112 // h is limited to {width/2, width, 2*width} but never larger than 16 and never smaller then 2 | |
113 // allthough currently h<4 is not used as functions with width <8 are not used and neither implemented | |
114 typedef 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))*/; | |
115 | |
116 | |
117 /** | |
118 * DSPContext. | |
119 */ | |
120 typedef struct DSPContext { | |
121 /* pixel ops : interface with DCT */ | |
122 void (*get_pixels)(DCTELEM *block/*align 16*/, const uint8_t *pixels/*align 8*/, int line_size); | |
123 void (*diff_pixels)(DCTELEM *block/*align 16*/, const uint8_t *s1/*align 8*/, const uint8_t *s2/*align 8*/, int stride); | |
124 void (*put_pixels_clamped)(const DCTELEM *block/*align 16*/, uint8_t *pixels/*align 8*/, int line_size); | |
125 void (*add_pixels_clamped)(const DCTELEM *block/*align 16*/, uint8_t *pixels/*align 8*/, int line_size); | |
126 /** | |
127 * translational global motion compensation. | |
128 */ | |
129 void (*gmc1)(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int srcStride, int h, int x16, int y16, int rounder); | |
130 /** | |
131 * global motion compensation. | |
132 */ | |
133 void (*gmc )(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int ox, int oy, | |
134 int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height); | |
135 void (*clear_blocks)(DCTELEM *blocks/*align 16*/); | |
136 int (*pix_sum)(uint8_t * pix, int line_size); | |
137 int (*pix_norm1)(uint8_t * pix, int line_size); | |
138 // 16x16 8x8 4x4 2x2 16x8 8x4 4x2 8x16 4x8 2x4 | |
139 | |
140 me_cmp_func sad[5]; /* identical to pix_absAxA except additional void * */ | |
141 me_cmp_func sse[5]; | |
142 me_cmp_func hadamard8_diff[5]; | |
143 me_cmp_func dct_sad[5]; | |
144 me_cmp_func quant_psnr[5]; | |
145 me_cmp_func bit[5]; | |
146 me_cmp_func rd[5]; | |
147 me_cmp_func vsad[5]; | |
148 me_cmp_func vsse[5]; | |
149 | |
150 me_cmp_func me_pre_cmp[5]; | |
151 me_cmp_func me_cmp[5]; | |
152 me_cmp_func me_sub_cmp[5]; | |
153 me_cmp_func mb_cmp[5]; | |
154 me_cmp_func ildct_cmp[5]; //only width 16 used | |
155 | |
156 /** | |
157 * Halfpel motion compensation with rounding (a+b+1)>>1. | |
158 * this is an array[4][4] of motion compensation funcions for 4 | |
159 * horizontal blocksizes (8,16) and the 4 halfpel positions<br> | |
160 * *pixels_tab[ 0->16xH 1->8xH ][ xhalfpel + 2*yhalfpel ] | |
161 * @param block destination where the result is stored | |
162 * @param pixels source | |
163 * @param line_size number of bytes in a horizontal line of block | |
164 * @param h height | |
165 */ | |
166 op_pixels_func put_pixels_tab[4][4]; | |
167 | |
168 /** | |
169 * Halfpel motion compensation with rounding (a+b+1)>>1. | |
170 * This is an array[4][4] of motion compensation functions for 4 | |
171 * horizontal blocksizes (8,16) and the 4 halfpel positions<br> | |
172 * *pixels_tab[ 0->16xH 1->8xH ][ xhalfpel + 2*yhalfpel ] | |
173 * @param block destination into which the result is averaged (a+b+1)>>1 | |
174 * @param pixels source | |
175 * @param line_size number of bytes in a horizontal line of block | |
176 * @param h height | |
177 */ | |
178 op_pixels_func avg_pixels_tab[4][4]; | |
179 | |
180 /** | |
181 * Halfpel motion compensation with no rounding (a+b)>>1. | |
182 * this is an array[2][4] of motion compensation funcions for 2 | |
183 * horizontal blocksizes (8,16) and the 4 halfpel positions<br> | |
184 * *pixels_tab[ 0->16xH 1->8xH ][ xhalfpel + 2*yhalfpel ] | |
185 * @param block destination where the result is stored | |
186 * @param pixels source | |
187 * @param line_size number of bytes in a horizontal line of block | |
188 * @param h height | |
189 */ | |
190 op_pixels_func put_no_rnd_pixels_tab[2][4]; | |
191 | |
192 /** | |
193 * Halfpel motion compensation with no rounding (a+b)>>1. | |
194 * this is an array[2][4] of motion compensation funcions for 2 | |
195 * horizontal blocksizes (8,16) and the 4 halfpel positions<br> | |
196 * *pixels_tab[ 0->16xH 1->8xH ][ xhalfpel + 2*yhalfpel ] | |
197 * @param block destination into which the result is averaged (a+b)>>1 | |
198 * @param pixels source | |
199 * @param line_size number of bytes in a horizontal line of block | |
200 * @param h height | |
201 */ | |
202 op_pixels_func avg_no_rnd_pixels_tab[2][4]; | |
203 | |
204 /** | |
205 * Thirdpel motion compensation with rounding (a+b+1)>>1. | |
206 * this is an array[12] of motion compensation funcions for the 9 thirdpel positions<br> | |
207 * *pixels_tab[ xthirdpel + 4*ythirdpel ] | |
208 * @param block destination where the result is stored | |
209 * @param pixels source | |
210 * @param line_size number of bytes in a horizontal line of block | |
211 * @param h height | |
212 */ | |
213 tpel_mc_func put_tpel_pixels_tab[11]; //FIXME individual func ptr per width? | |
214 tpel_mc_func avg_tpel_pixels_tab[11]; //FIXME individual func ptr per width? | |
215 | |
216 qpel_mc_func put_qpel_pixels_tab[2][16]; | |
217 qpel_mc_func avg_qpel_pixels_tab[2][16]; | |
218 qpel_mc_func put_no_rnd_qpel_pixels_tab[2][16]; | |
219 qpel_mc_func avg_no_rnd_qpel_pixels_tab[2][16]; | |
220 qpel_mc_func put_mspel_pixels_tab[8]; | |
221 | |
222 /** | |
223 * h264 Chram MC | |
224 */ | |
225 h264_chroma_mc_func put_h264_chroma_pixels_tab[3]; | |
226 h264_chroma_mc_func avg_h264_chroma_pixels_tab[3]; | |
227 | |
228 qpel_mc_func put_h264_qpel_pixels_tab[3][16]; | |
229 qpel_mc_func avg_h264_qpel_pixels_tab[3][16]; | |
230 | |
231 me_cmp_func pix_abs[2][4]; | |
232 | |
233 /* huffyuv specific */ | |
234 void (*add_bytes)(uint8_t *dst/*align 16*/, uint8_t *src/*align 16*/, int w); | |
235 void (*diff_bytes)(uint8_t *dst/*align 16*/, uint8_t *src1/*align 16*/, uint8_t *src2/*align 1*/,int w); | |
236 /** | |
237 * subtract huffyuv's variant of median prediction | |
238 * note, this might read from src1[-1], src2[-1] | |
239 */ | |
240 void (*sub_hfyu_median_prediction)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w, int *left, int *left_top); | |
241 void (*bswap_buf)(uint32_t *dst, uint32_t *src, int w); | |
242 | |
243 void (*h263_v_loop_filter)(uint8_t *src, int stride, int qscale); | |
244 void (*h263_h_loop_filter)(uint8_t *src, int stride, int qscale); | |
245 | |
246 /* (I)DCT */ | |
247 void (*fdct)(DCTELEM *block/* align 16*/); | |
248 void (*fdct248)(DCTELEM *block/* align 16*/); | |
249 | |
250 /* IDCT really*/ | |
251 void (*idct)(DCTELEM *block/* align 16*/); | |
252 | |
253 /** | |
254 * block -> idct -> clip to unsigned 8 bit -> dest. | |
255 * (-1392, 0, 0, ...) -> idct -> (-174, -174, ...) -> put -> (0, 0, ...) | |
256 * @param line_size size in bytes of a horizotal line of dest | |
257 */ | |
258 void (*idct_put)(uint8_t *dest/*align 8*/, int line_size, DCTELEM *block/*align 16*/); | |
259 | |
260 /** | |
261 * block -> idct -> add dest -> clip to unsigned 8 bit -> dest. | |
262 * @param line_size size in bytes of a horizotal line of dest | |
263 */ | |
264 void (*idct_add)(uint8_t *dest/*align 8*/, int line_size, DCTELEM *block/*align 16*/); | |
265 | |
266 /** | |
267 * idct input permutation. | |
268 * several optimized IDCTs need a permutated input (relative to the normal order of the reference | |
269 * IDCT) | |
270 * this permutation must be performed before the idct_put/add, note, normally this can be merged | |
271 * with the zigzag/alternate scan<br> | |
272 * an example to avoid confusion: | |
273 * - (->decode coeffs -> zigzag reorder -> dequant -> reference idct ->...) | |
274 * - (x -> referece dct -> reference idct -> x) | |
275 * - (x -> referece dct -> simple_mmx_perm = idct_permutation -> simple_idct_mmx -> x) | |
276 * - (->decode coeffs -> zigzag reorder -> simple_mmx_perm -> dequant -> simple_idct_mmx ->...) | |
277 */ | |
278 uint8_t idct_permutation[64]; | |
279 int idct_permutation_type; | |
280 #define FF_NO_IDCT_PERM 1 | |
281 #define FF_LIBMPEG2_IDCT_PERM 2 | |
282 #define FF_SIMPLE_IDCT_PERM 3 | |
283 #define FF_TRANSPOSE_IDCT_PERM 4 | |
284 | |
285 int (*try_8x8basis)(int16_t rem[64], int16_t weight[64], int16_t basis[64], int scale); | |
286 void (*add_8x8basis)(int16_t rem[64], int16_t basis[64], int scale); | |
287 #define BASIS_SHIFT 16 | |
288 #define RECON_SHIFT 6 | |
289 | |
290 } DSPContext; | |
291 | |
292 void dsputil_static_init(void); | |
293 void dsputil_init(DSPContext* p, AVCodecContext *avctx); | |
294 | |
295 /** | |
296 * permute block according to permuatation. | |
297 * @param last last non zero element in scantable order | |
298 */ | |
299 void ff_block_permute(DCTELEM *block, uint8_t *permutation, const uint8_t *scantable, int last); | |
300 | |
301 void ff_set_cmp(DSPContext* c, me_cmp_func *cmp, int type); | |
302 | |
303 #define BYTE_VEC32(c) ((c)*0x01010101UL) | |
304 | |
305 static inline uint32_t rnd_avg32(uint32_t a, uint32_t b) | |
306 { | |
307 return (a | b) - (((a ^ b) & ~BYTE_VEC32(0x01)) >> 1); | |
308 } | |
309 | |
310 static inline uint32_t no_rnd_avg32(uint32_t a, uint32_t b) | |
311 { | |
312 return (a & b) + (((a ^ b) & ~BYTE_VEC32(0x01)) >> 1); | |
313 } | |
314 | |
315 /** | |
316 * Empty mmx state. | |
317 * this must be called between any dsp function and float/double code. | |
318 * for example sin(); dsp->idct_put(); emms_c(); cos() | |
319 */ | |
320 #define emms_c() | |
321 | |
322 /* should be defined by architectures supporting | |
323 one or more MultiMedia extension */ | |
324 int mm_support(void); | |
325 | |
326 #if defined(HAVE_MMX) | |
327 | |
328 #undef emms_c | |
329 | |
330 #define MM_MMX 0x0001 /* standard MMX */ | |
331 #define MM_3DNOW 0x0004 /* AMD 3DNOW */ | |
332 #define MM_MMXEXT 0x0002 /* SSE integer functions or AMD MMX ext */ | |
333 #define MM_SSE 0x0008 /* SSE functions */ | |
334 #define MM_SSE2 0x0010 /* PIV SSE2 functions */ | |
335 | |
336 extern int mm_flags; | |
337 | |
338 void add_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size); | |
339 void put_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size); | |
340 | |
341 static inline void emms(void) | |
342 { | |
343 __asm __volatile ("emms;":::"memory"); | |
344 } | |
345 | |
346 | |
347 #define emms_c() \ | |
348 {\ | |
349 if (mm_flags & MM_MMX)\ | |
350 emms();\ | |
351 } | |
352 | |
353 #define __align8 __attribute__ ((aligned (8))) | |
354 | |
355 void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx); | |
356 void dsputil_init_pix_mmx(DSPContext* c, AVCodecContext *avctx); | |
357 | |
358 #elif defined(ARCH_ARMV4L) | |
359 | |
360 /* This is to use 4 bytes read to the IDCT pointers for some 'zero' | |
361 line ptimizations */ | |
362 #define __align8 __attribute__ ((aligned (4))) | |
363 | |
364 void dsputil_init_armv4l(DSPContext* c, AVCodecContext *avctx); | |
365 | |
366 #elif defined(HAVE_MLIB) | |
367 | |
368 /* SPARC/VIS IDCT needs 8-byte aligned DCT blocks */ | |
369 #define __align8 __attribute__ ((aligned (8))) | |
370 | |
371 void dsputil_init_mlib(DSPContext* c, AVCodecContext *avctx); | |
372 | |
373 #elif defined(ARCH_ALPHA) | |
374 | |
375 #define __align8 __attribute__ ((aligned (8))) | |
376 | |
377 void dsputil_init_alpha(DSPContext* c, AVCodecContext *avctx); | |
378 | |
379 #elif defined(ARCH_POWERPC) | |
380 | |
381 #define MM_ALTIVEC 0x0001 /* standard AltiVec */ | |
382 | |
383 extern int mm_flags; | |
384 | |
385 #if defined(HAVE_ALTIVEC) && !defined(CONFIG_DARWIN) | |
386 #define pixel altivec_pixel | |
387 #include <altivec.h> | |
388 #undef pixel | |
389 #endif | |
390 | |
391 #define __align8 __attribute__ ((aligned (16))) | |
392 | |
393 void dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx); | |
394 | |
395 #elif defined(HAVE_MMI) | |
396 | |
397 #define __align8 __attribute__ ((aligned (16))) | |
398 | |
399 void dsputil_init_mmi(DSPContext* c, AVCodecContext *avctx); | |
400 | |
401 #elif defined(ARCH_SH4) | |
402 | |
403 #define __align8 __attribute__ ((aligned (8))) | |
404 | |
405 void dsputil_init_sh4(DSPContext* c, AVCodecContext *avctx); | |
406 | |
407 #else | |
408 | |
409 #define __align8 | |
410 | |
411 #endif | |
412 | |
413 #ifdef __GNUC__ | |
414 | |
415 struct unaligned_64 { uint64_t l; } __attribute__((packed)); | |
416 struct unaligned_32 { uint32_t l; } __attribute__((packed)); | |
417 struct unaligned_16 { uint16_t l; } __attribute__((packed)); | |
418 | |
419 #define LD16(a) (((const struct unaligned_16 *) (a))->l) | |
420 #define LD32(a) (((const struct unaligned_32 *) (a))->l) | |
421 #define LD64(a) (((const struct unaligned_64 *) (a))->l) | |
422 | |
423 #define ST32(a, b) (((struct unaligned_32 *) (a))->l) = (b) | |
424 | |
425 #else /* __GNUC__ */ | |
426 | |
427 #define LD16(a) (*((uint16_t*)(a))) | |
428 #define LD32(a) (*((uint32_t*)(a))) | |
429 #define LD64(a) (*((uint64_t*)(a))) | |
430 | |
431 #define ST32(a, b) *((uint32_t*)(a)) = (b) | |
432 | |
433 #endif /* !__GNUC__ */ | |
434 | |
435 /* PSNR */ | |
436 void get_psnr(uint8_t *orig_image[3], uint8_t *coded_image[3], | |
437 int orig_linesize[3], int coded_linesize, | |
438 AVCodecContext *avctx); | |
439 | |
440 /* FFT computation */ | |
441 | |
442 /* NOTE: soon integer code will be added, so you must use the | |
443 FFTSample type */ | |
444 typedef float FFTSample; | |
445 | |
446 typedef struct FFTComplex { | |
447 FFTSample re, im; | |
448 } FFTComplex; | |
449 | |
450 typedef struct FFTContext { | |
451 int nbits; | |
452 int inverse; | |
453 uint16_t *revtab; | |
454 FFTComplex *exptab; | |
455 FFTComplex *exptab1; /* only used by SSE code */ | |
456 void (*fft_calc)(struct FFTContext *s, FFTComplex *z); | |
457 } FFTContext; | |
458 | |
459 int fft_inits(FFTContext *s, int nbits, int inverse); | |
460 void fft_permute(FFTContext *s, FFTComplex *z); | |
461 void fft_calc_c(FFTContext *s, FFTComplex *z); | |
462 void fft_calc_sse(FFTContext *s, FFTComplex *z); | |
463 void fft_calc_altivec(FFTContext *s, FFTComplex *z); | |
464 | |
465 static inline void fft_calc(FFTContext *s, FFTComplex *z) | |
466 { | |
467 s->fft_calc(s, z); | |
468 } | |
469 void fft_end(FFTContext *s); | |
470 | |
471 /* MDCT computation */ | |
472 | |
473 typedef struct MDCTContext { | |
474 int n; /* size of MDCT (i.e. number of input data * 2) */ | |
475 int nbits; /* n = 2^nbits */ | |
476 /* pre/post rotation tables */ | |
477 FFTSample *tcos; | |
478 FFTSample *tsin; | |
479 FFTContext fft; | |
480 } MDCTContext; | |
481 | |
482 int ff_mdct_init(MDCTContext *s, int nbits, int inverse); | |
483 void ff_imdct_calc(MDCTContext *s, FFTSample *output, | |
484 const FFTSample *input, FFTSample *tmp); | |
485 void ff_mdct_calc(MDCTContext *s, FFTSample *out, | |
486 const FFTSample *input, FFTSample *tmp); | |
487 void ff_mdct_end(MDCTContext *s); | |
488 | |
489 #define WARPER8_16(name8, name16)\ | |
490 static int name16(void /*MpegEncContext*/ *s, uint8_t *dst, uint8_t *src, int stride, int h){\ | |
491 return name8(s, dst , src , stride, h)\ | |
492 +name8(s, dst+8 , src+8 , stride, h);\ | |
493 } | |
494 | |
495 #define WARPER8_16_SQ(name8, name16)\ | |
496 static int name16(void /*MpegEncContext*/ *s, uint8_t *dst, uint8_t *src, int stride, int h){\ | |
497 int score=0;\ | |
498 score +=name8(s, dst , src , stride, 8);\ | |
499 score +=name8(s, dst+8 , src+8 , stride, 8);\ | |
500 if(h==16){\ | |
501 dst += 8*stride;\ | |
502 src += 8*stride;\ | |
503 score +=name8(s, dst , src , stride, 8);\ | |
504 score +=name8(s, dst+8 , src+8 , stride, 8);\ | |
505 }\ | |
506 return score;\ | |
507 } | |
508 | |
509 #endif |