summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/libmad/mad.h
Unidiff
Diffstat (limited to 'core/multimedia/opieplayer/libmad/mad.h') (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/libmad/mad.h376
1 files changed, 255 insertions, 121 deletions
diff --git a/core/multimedia/opieplayer/libmad/mad.h b/core/multimedia/opieplayer/libmad/mad.h
index 9db9da3..9ef6cc8 100644
--- a/core/multimedia/opieplayer/libmad/mad.h
+++ b/core/multimedia/opieplayer/libmad/mad.h
@@ -1,9 +1,9 @@
1/* 1/*
2 * mad - MPEG audio decoder 2 * libmad - MPEG audio decoder library
3 * Copyright (C) 2000-2001 Robert Leslie 3 * Copyright (C) 2000-2004 Underbit Technologies, Inc.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or 7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version. 8 * (at your option) any later version.
9 * 9 *
@@ -14,49 +14,58 @@
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * 18 *
19 * If you would like to negotiate alternate licensing terms, you may do 19 * If you would like to negotiate alternate licensing terms, you may do
20 * so by contacting the author: Robert Leslie <rob@mars.org> 20 * so by contacting: Underbit Technologies, Inc. <info@underbit.com>
21 */ 21 */
22 22
23# ifdef __cplusplus
24extern "C" {
25# endif
26
27# define FPM_INTEL
28
29
30
23# define SIZEOF_INT 4 31# define SIZEOF_INT 4
24# define SIZEOF_LONG 4 32# define SIZEOF_LONG 4
25# define SIZEOF_LONG_LONG 8 33# define SIZEOF_LONG_LONG 8
26 34
27/* Id: version.h,v 1.16 2001/04/05 04:57:11 rob Exp */ 35
36/* Id: version.h,v 1.26 2004/01/23 09:41:33 rob Exp */
28 37
29# ifndef LIBMAD_VERSION_H 38# ifndef LIBMAD_VERSION_H
30# define LIBMAD_VERSION_H 39# define LIBMAD_VERSION_H
31 40
32 # define MAD_VERSION_MAJOR0 41 # define MAD_VERSION_MAJOR0
33 # define MAD_VERSION_MINOR13 42 # define MAD_VERSION_MINOR15
34 # define MAD_VERSION_PATCH0 43 # define MAD_VERSION_PATCH1
35 # define MAD_VERSION_EXTRA" (beta)" 44 # define MAD_VERSION_EXTRA" (beta)"
36 45
37 # define MAD_VERSION_STRINGIZE(str)#str 46 # define MAD_VERSION_STRINGIZE(str)#str
38 # define MAD_VERSION_STRING(num)MAD_VERSION_STRINGIZE(num) 47 # define MAD_VERSION_STRING(num)MAD_VERSION_STRINGIZE(num)
39 48
40 # define MAD_VERSION MAD_VERSION_STRING(MAD_VERSION_MAJOR) "." \ 49 # define MAD_VERSION MAD_VERSION_STRING(MAD_VERSION_MAJOR) "." \
41 MAD_VERSION_STRING(MAD_VERSION_MINOR) "." \ 50 MAD_VERSION_STRING(MAD_VERSION_MINOR) "." \
42 MAD_VERSION_STRING(MAD_VERSION_PATCH) \ 51 MAD_VERSION_STRING(MAD_VERSION_PATCH) \
43 MAD_VERSION_EXTRA 52 MAD_VERSION_EXTRA
44 53
45 # define MAD_PUBLISHYEAR"2000-2001" 54 # define MAD_PUBLISHYEAR"2000-2004"
46 # define MAD_AUTHOR "Robert Leslie" 55 # define MAD_AUTHOR "Underbit Technologies, Inc."
47 # define MAD_EMAIL "rob@mars.org" 56 # define MAD_EMAIL "info@underbit.com"
48 57
49extern char const mad_version[]; 58extern char const mad_version[];
50extern char const mad_copyright[]; 59extern char const mad_copyright[];
51extern char const mad_author[]; 60extern char const mad_author[];
52extern char const mad_build[]; 61extern char const mad_build[];
53 62
54# endif 63# endif
55 64
56/* Id: fixed.h,v 1.23 2001/04/05 04:57:11 rob Exp */ 65/* Id: fixed.h,v 1.38 2004/02/17 02:02:03 rob Exp */
57 66
58# ifndef LIBMAD_FIXED_H 67# ifndef LIBMAD_FIXED_H
59# define LIBMAD_FIXED_H 68# define LIBMAD_FIXED_H
60 69
61# if SIZEOF_INT >= 4 70# if SIZEOF_INT >= 4
62typedef signed int mad_fixed_t; 71typedef signed int mad_fixed_t;
@@ -67,12 +76,24 @@ typedef unsigned int mad_fixed64lo_t;
67typedef signed long mad_fixed_t; 76typedef signed long mad_fixed_t;
68 77
69typedef signed long mad_fixed64hi_t; 78typedef signed long mad_fixed64hi_t;
70typedef unsigned long mad_fixed64lo_t; 79typedef unsigned long mad_fixed64lo_t;
71# endif 80# endif
72 81
82# if defined(_MSC_VER)
83# define mad_fixed64_t signed __int64
84# elif 1 || defined(__GNUC__)
85# define mad_fixed64_t signed long long
86# endif
87
88# if defined(FPM_FLOAT)
89typedef double mad_sample_t;
90# else
91typedef mad_fixed_t mad_sample_t;
92# endif
93
73/* 94/*
74 * Fixed-point format: 0xABBBBBBB 95 * Fixed-point format: 0xABBBBBBB
75 * A == whole part (sign + 3 bits) 96 * A == whole part (sign + 3 bits)
76 * B == fractional part (28 bits) 97 * B == fractional part (28 bits)
77 * 98 *
78 * Values are signed two's complement, so the effective range is: 99 * Values are signed two's complement, so the effective range is:
@@ -127,65 +148,99 @@ typedef unsigned long mad_fixed64lo_t;
127 148
128 # define mad_f_fromint(x)((x) << MAD_F_FRACBITS) 149 # define mad_f_fromint(x)((x) << MAD_F_FRACBITS)
129 150
130 # define mad_f_add(x, y)((x) + (y)) 151 # define mad_f_add(x, y)((x) + (y))
131 # define mad_f_sub(x, y)((x) - (y)) 152 # define mad_f_sub(x, y)((x) - (y))
132 153
133# if defined(FPM_64BIT) 154# if defined(FPM_FLOAT)
155# error "FPM_FLOAT not yet supported"
156
157# undef MAD_F
158 # define MAD_F(x) mad_f_todouble(x)
159
160 # define mad_f_mul(x, y)((x) * (y))
161# define mad_f_scale64
162
163# undef ASO_ZEROCHECK
164
165# elif defined(FPM_64BIT)
134 166
135/* 167/*
136 * This version should be the most accurate if 64-bit (long long) types are 168 * This version should be the most accurate if 64-bit types are supported by
137 * supported by the compiler, although it may not be the most efficient. 169 * the compiler, although it may not be the most efficient.
138 */ 170 */
139# if defined(OPT_ACCURACY) 171# if defined(OPT_ACCURACY)
140# define mad_f_mul(x, y) \ 172# define mad_f_mul(x, y) \
141 ((mad_fixed_t) \ 173 ((mad_fixed_t) \
142 ((((signed long long) (x) * (y)) + \ 174 ((((mad_fixed64_t) (x) * (y)) + \
143 (1L << (MAD_F_SCALEBITS - 1))) >> MAD_F_SCALEBITS)) 175 (1L << (MAD_F_SCALEBITS - 1))) >> MAD_F_SCALEBITS))
144# else 176# else
145# define mad_f_mul(x, y) \ 177# define mad_f_mul(x, y) \
146 ((mad_fixed_t) (((signed long long) (x) * (y)) >> MAD_F_SCALEBITS)) 178 ((mad_fixed_t) (((mad_fixed64_t) (x) * (y)) >> MAD_F_SCALEBITS))
147# endif 179# endif
148 180
149# define MAD_F_SCALEBITS MAD_F_FRACBITS 181# define MAD_F_SCALEBITS MAD_F_FRACBITS
150 182
151/* --- Intel --------------------------------------------------------------- */ 183/* --- Intel --------------------------------------------------------------- */
152 184
153# elif defined(FPM_INTEL) 185# elif defined(FPM_INTEL)
154 186
187# if defined(_MSC_VER)
188# pragma warning(push)
189# pragma warning(disable: 4035) /* no return value */
190static __forceinline
191mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
192{
193 enum {
194 fracbits = MAD_F_FRACBITS
195 };
196
197 __asm {
198 mov eax, x
199 imul y
200 shrd eax, edx, fracbits
201 }
202
203 /* implicit return of eax */
204}
205# pragma warning(pop)
206
207 # define mad_f_mul mad_f_mul_inline
208# define mad_f_scale64
209# else
155/* 210/*
156 * This Intel version is fast and accurate; the disposition of the least 211 * This Intel version is fast and accurate; the disposition of the least
157 * significant bit depends on OPT_ACCURACY via mad_f_scale64(). 212 * significant bit depends on OPT_ACCURACY via mad_f_scale64().
158 */ 213 */
159# define MAD_F_MLX(hi, lo, x, y) \ 214# define MAD_F_MLX(hi, lo, x, y) \
160 asm ("imull %3" \ 215 asm ("imull %3" \
161 : "=a" (lo), "=d" (hi) \ 216 : "=a" (lo), "=d" (hi) \
162 : "%a" (x), "rm" (y) \ 217 : "%a" (x), "rm" (y) \
163 : "cc") 218 : "cc")
164 219
165# if defined(OPT_ACCURACY) 220# if defined(OPT_ACCURACY)
166/* 221/*
167 * This gives best accuracy but is not very fast. 222 * This gives best accuracy but is not very fast.
168 */ 223 */
169# define MAD_F_MLA(hi, lo, x, y) \ 224# define MAD_F_MLA(hi, lo, x, y) \
170 ({ mad_fixed64hi_t __hi; \ 225 ({ mad_fixed64hi_t __hi; \
171 mad_fixed64lo_t __lo; \ 226 mad_fixed64lo_t __lo; \
172 MAD_F_MLX(__hi, __lo, (x), (y)); \ 227 MAD_F_MLX(__hi, __lo, (x), (y)); \
173 asm ("addl %2,%0\n\t" \ 228 asm ("addl %2,%0\n\t" \
174 "adcl %3,%1" \ 229 "adcl %3,%1" \
175 : "=rm" (lo), "=rm" (hi) \ 230 : "=rm" (lo), "=rm" (hi) \
176 : "r" (__lo), "r" (__hi), "0" (lo), "1" (hi) \ 231 : "r" (__lo), "r" (__hi), "0" (lo), "1" (hi) \
177 : "cc"); \ 232 : "cc"); \
178 }) 233 })
179# endif /* OPT_ACCURACY */ 234# endif /* OPT_ACCURACY */
180 235
181# if defined(OPT_ACCURACY) 236# if defined(OPT_ACCURACY)
182/* 237/*
183 * Surprisingly, this is faster than SHRD followed by ADC. 238 * Surprisingly, this is faster than SHRD followed by ADC.
184 */ 239 */
185# define mad_f_scale64(hi, lo) \ 240# define mad_f_scale64(hi, lo) \
186 ({ mad_fixed64hi_t __hi_; \ 241 ({ mad_fixed64hi_t __hi_; \
187 mad_fixed64lo_t __lo_; \ 242 mad_fixed64lo_t __lo_; \
188 mad_fixed_t __result; \ 243 mad_fixed_t __result; \
189 asm ("addl %4,%2\n\t" \ 244 asm ("addl %4,%2\n\t" \
190 "adcl %5,%3" \ 245 "adcl %5,%3" \
191 : "=rm" (__lo_), "=rm" (__hi_) \ 246 : "=rm" (__lo_), "=rm" (__hi_) \
@@ -195,41 +250,53 @@ typedef unsigned long mad_fixed64lo_t;
195 asm ("shrdl %3,%2,%1" \ 250 asm ("shrdl %3,%2,%1" \
196 : "=rm" (__result) \ 251 : "=rm" (__result) \
197 : "0" (__lo_), "r" (__hi_), "I" (MAD_F_SCALEBITS) \ 252 : "0" (__lo_), "r" (__hi_), "I" (MAD_F_SCALEBITS) \
198 : "cc"); \ 253 : "cc"); \
199 __result; \ 254 __result; \
200 }) 255 })
201# else 256# elif defined(OPT_INTEL)
202# define mad_f_scale64(hi, lo) \ 257/*
258 * Alternate Intel scaling that may or may not perform better.
259 */
260# define mad_f_scale64(hi, lo) \
261 ({ mad_fixed_t __result; \
262 asm ("shrl %3,%1\n\t" \
263 "shll %4,%2\n\t" \
264 "orl %2,%1" \
265 : "=rm" (__result) \
266 : "0" (lo), "r" (hi), \
267 "I" (MAD_F_SCALEBITS), "I" (32 - MAD_F_SCALEBITS) \
268 : "cc"); \
269 __result; \
270 })
271# else
272# define mad_f_scale64(hi, lo) \
203 ({ mad_fixed_t __result; \ 273 ({ mad_fixed_t __result; \
204 asm ("shrdl %3,%2,%1" \ 274 asm ("shrdl %3,%2,%1" \
205 : "=rm" (__result) \ 275 : "=rm" (__result) \
206 : "0" (lo), "r" (hi), "I" (MAD_F_SCALEBITS) \ 276 : "0" (lo), "r" (hi), "I" (MAD_F_SCALEBITS) \
207 : "cc"); \ 277 : "cc"); \
208 __result; \ 278 __result; \
209 }) 279 })
210# endif /* OPT_ACCURACY */ 280# endif /* OPT_ACCURACY */
211 281
212# define MAD_F_SCALEBITS MAD_F_FRACBITS 282# define MAD_F_SCALEBITS MAD_F_FRACBITS
283# endif
213 284
214/* --- ARM ----------------------------------------------------------------- */ 285/* --- ARM ----------------------------------------------------------------- */
215 286
216# elif defined(FPM_ARM) 287# elif defined(FPM_ARM)
217 288
218/* 289/*
219 * This ARM V4 version is as accurate as FPM_64BIT but much faster. The 290 * This ARM V4 version is as accurate as FPM_64BIT but much faster. The
220 * least significant bit is properly rounded at no CPU cycle cost! 291 * least significant bit is properly rounded at no CPU cycle cost!
221 */ 292 */
222# if 1 293# if 1
223/* 294/*
224 * There's a bug somewhere, possibly in the compiler, that sometimes makes 295 * This is faster than the default implementation via MAD_F_MLX() and
225 * this necessary instead of the default implementation via MAD_F_MLX and 296 * mad_f_scale64().
226 * mad_f_scale64. It may be related to the use (or lack) of
227 * -finline-functions and/or -fstrength-reduce.
228 *
229 * This is also apparently faster than MAD_F_MLX/mad_f_scale64.
230 */ 297 */
231# define mad_f_mul(x, y) \ 298# define mad_f_mul(x, y) \
232 ({ mad_fixed64hi_t __hi; \ 299 ({ mad_fixed64hi_t __hi; \
233 mad_fixed64lo_t __lo; \ 300 mad_fixed64lo_t __lo; \
234 mad_fixed_t __result; \ 301 mad_fixed_t __result; \
235 asm ("smull%0, %1, %3, %4\n\t" \ 302 asm ("smull%0, %1, %3, %4\n\t" \
@@ -250,17 +317,24 @@ typedef unsigned long mad_fixed64lo_t;
250 317
251# define MAD_F_MLA(hi, lo, x, y) \ 318# define MAD_F_MLA(hi, lo, x, y) \
252 asm ("smlal%0, %1, %2, %3" \ 319 asm ("smlal%0, %1, %2, %3" \
253 : "+r" (lo), "+r" (hi) \ 320 : "+r" (lo), "+r" (hi) \
254 : "%r" (x), "r" (y)) 321 : "%r" (x), "r" (y))
255 322
323# define MAD_F_MLN(hi, lo) \
324 asm ("rsbs%0, %2, #0\n\t" \
325 "rsc%1, %3, #0" \
326 : "=r" (lo), "=r" (hi) \
327 : "0" (lo), "1" (hi) \
328 : "cc")
329
256# define mad_f_scale64(hi, lo) \ 330# define mad_f_scale64(hi, lo) \
257 ({ mad_fixed_t __result; \ 331 ({ mad_fixed_t __result; \
258 asm ("movs%0, %1, lsr %3\n\t" \ 332 asm ("movs%0, %1, lsr %3\n\t" \
259 "adc%0, %0, %2, lsl %4" \ 333 "adc%0, %0, %2, lsl %4" \
260 : "=r" (__result) \ 334 : "=&r" (__result) \
261 : "r" (lo), "r" (hi), \ 335 : "r" (lo), "r" (hi), \
262 "M" (MAD_F_SCALEBITS), "M" (32 - MAD_F_SCALEBITS) \ 336 "M" (MAD_F_SCALEBITS), "M" (32 - MAD_F_SCALEBITS) \
263 : "cc"); \ 337 : "cc"); \
264 __result; \ 338 __result; \
265 }) 339 })
266 340
@@ -322,64 +396,75 @@ typedef unsigned long mad_fixed64lo_t;
322 396
323/* --- PowerPC ------------------------------------------------------------- */ 397/* --- PowerPC ------------------------------------------------------------- */
324 398
325# elif defined(FPM_PPC) 399# elif defined(FPM_PPC)
326 400
327/* 401/*
328 * This PowerPC version is tuned for the 4xx embedded processors. It is 402 * This PowerPC version is fast and accurate; the disposition of the least
329 * effectively a tuned version of FPM_64BIT. It is a little faster and just 403 * significant bit depends on OPT_ACCURACY via mad_f_scale64().
330 * as accurate. The disposition of the least significant bit depends on
331 * OPT_ACCURACY via mad_f_scale64().
332 */ 404 */
333# define MAD_F_MLX(hi, lo, x, y) \ 405# define MAD_F_MLX(hi, lo, x, y) \
334 asm ("mulhw %1, %2, %3\n\t" \ 406 do { \
335 "mullw %0, %2, %3" \ 407 asm ("mullw %0,%1,%2" \
336 : "=&r" (lo), "=&r" (hi) \ 408 : "=r" (lo) \
337 : "%r" (x), "r" (y)) 409 : "%r" (x), "r" (y)); \
410 asm ("mulhw %0,%1,%2" \
411 : "=r" (hi) \
412 : "%r" (x), "r" (y)); \
413 } \
414 while (0)
338 415
339# define MAD_F_MLA(hi, lo, x, y) \ 416# if defined(OPT_ACCURACY)
417/*
418 * This gives best accuracy but is not very fast.
419 */
420# define MAD_F_MLA(hi, lo, x, y) \
340 ({ mad_fixed64hi_t __hi; \ 421 ({ mad_fixed64hi_t __hi; \
341 mad_fixed64lo_t __lo; \ 422 mad_fixed64lo_t __lo; \
342 MAD_F_MLX(__hi, __lo, (x), (y)); \ 423 MAD_F_MLX(__hi, __lo, (x), (y)); \
343 asm ("addc %0, %2, %3\n\t" \ 424 asm ("addc %0,%2,%3\n\t" \
344 "adde %1, %4, %5" \ 425 "adde %1,%4,%5" \
345 : "=r" (lo), "=r" (hi) \ 426 : "=r" (lo), "=r" (hi) \
346 : "%r" (__lo), "0" (lo), "%r" (__hi), "1" (hi)); \ 427 : "%r" (lo), "r" (__lo), \
428 "%r" (hi), "r" (__hi) \
429 : "xer"); \
347 }) 430 })
431# endif
348 432
349# if defined(OPT_ACCURACY) 433# if defined(OPT_ACCURACY)
350/* 434/*
351 * This is accurate and ~2 - 2.5 times slower than the unrounded version. 435 * This is slower than the truncating version below it.
352 *
353 * The __volatile__ improves the generated code by another 5% (fewer spills
354 * to memory); eventually they should be removed.
355 */ 436 */
356# define mad_f_scale64(hi, lo) \ 437# define mad_f_scale64(hi, lo) \
357 ({ mad_fixed_t __result; \ 438 ({ mad_fixed_t __result, __round; \
358 mad_fixed64hi_t __hi_; \ 439 asm ("rotrwi %0,%1,%2" \
359 mad_fixed64lo_t __lo_; \ 440 : "=r" (__result) \
360 asm __volatile__ ("addc %0, %2, %4\n\t" \ 441 : "r" (lo), "i" (MAD_F_SCALEBITS)); \
361 "addze %1, %3" \ 442 asm ("extrwi %0,%1,1,0" \
362 : "=r" (__lo_), "=r" (__hi_) \ 443 : "=r" (__round) \
363 : "r" (lo), "r" (hi), "r" (1 << (MAD_F_SCALEBITS - 1))); \ 444 : "r" (__result)); \
364 asm __volatile__ ("rlwinm %0, %2,32-%3,0,%3-1\n\t" \ 445 asm ("insrwi %0,%1,%2,0" \
365 "rlwimi %0, %1,32-%3,%3,31" \ 446 : "+r" (__result) \
366 : "=&r" (__result) \ 447 : "r" (hi), "i" (MAD_F_SCALEBITS)); \
367 : "r" (__lo_), "r" (__hi_), "I" (MAD_F_SCALEBITS)); \ 448 asm ("add %0,%1,%2" \
368 __result; \ 449 : "=r" (__result) \
450 : "%r" (__result), "r" (__round)); \
451 __result; \
369 }) 452 })
370# else 453# else
371# define mad_f_scale64(hi, lo) \ 454# define mad_f_scale64(hi, lo) \
372 ({ mad_fixed_t __result; \ 455 ({ mad_fixed_t __result; \
373 asm ("rlwinm %0, %2,32-%3,0,%3-1\n\t" \ 456 asm ("rotrwi %0,%1,%2" \
374 "rlwimi %0, %1,32-%3,%3,31" \
375 : "=r" (__result) \ 457 : "=r" (__result) \
376 : "r" (lo), "r" (hi), "I" (MAD_F_SCALEBITS)); \ 458 : "r" (lo), "i" (MAD_F_SCALEBITS)); \
377 __result; \ 459 asm ("insrwi %0,%1,%2,0" \
460 : "+r" (__result) \
461 : "r" (hi), "i" (MAD_F_SCALEBITS)); \
462 __result; \
378 }) 463 })
379# endif /* OPT_ACCURACY */ 464# endif
380 465
381# define MAD_F_SCALEBITS MAD_F_FRACBITS 466# define MAD_F_SCALEBITS MAD_F_FRACBITS
382 467
383/* --- Default ------------------------------------------------------------- */ 468/* --- Default ------------------------------------------------------------- */
384 469
385# elif defined(FPM_DEFAULT) 470# elif defined(FPM_DEFAULT)
@@ -390,42 +475,51 @@ typedef unsigned long mad_fixed64lo_t;
390 * should be taken when ordering operands. 475 * should be taken when ordering operands.
391 * 476 *
392 * The scale factors are constant as this is not used with SSO. 477 * The scale factors are constant as this is not used with SSO.
393 * 478 *
394 * Pre-rounding is required to stay within the limits of compliance. 479 * Pre-rounding is required to stay within the limits of compliance.
395 */ 480 */
396 # define mad_f_mul(x, y)((((x) + (1L << 11)) >> 12) * \ 481# if defined(OPT_SPEED)
482 # define mad_f_mul(x, y)(((x) >> 12) * ((y) >> 16))
483# else
484 # define mad_f_mul(x, y)((((x) + (1L << 11)) >> 12) * \
397 (((y) + (1L << 15)) >> 16)) 485 (((y) + (1L << 15)) >> 16))
486# endif
398 487
399/* ------------------------------------------------------------------------- */ 488/* ------------------------------------------------------------------------- */
400 489
401# else 490# else
402# error "no FPM selected" 491# error "no FPM selected"
403# endif 492# endif
404 493
405/* default implementations */ 494/* default implementations */
406 495
407# if !defined(mad_f_mul) 496# if !defined(mad_f_mul)
408# define mad_f_mul(x, y) \ 497# define mad_f_mul(x, y) \
409 ({ mad_fixed64hi_t __hi; \ 498 ({ register mad_fixed64hi_t __hi; \
410 mad_fixed64lo_t __lo; \ 499 register mad_fixed64lo_t __lo; \
411 MAD_F_MLX(__hi, __lo, (x), (y)); \ 500 MAD_F_MLX(__hi, __lo, (x), (y)); \
412 mad_f_scale64(__hi, __lo); \ 501 mad_f_scale64(__hi, __lo); \
413 }) 502 })
414# endif 503# endif
415 504
416# if !defined(MAD_F_MLA) 505# if !defined(MAD_F_MLA)
417 # define MAD_F_ML0(hi, lo, x, y)((lo) = mad_f_mul((x), (y))) 506 # define MAD_F_ML0(hi, lo, x, y)((lo) = mad_f_mul((x), (y)))
418 # define MAD_F_MLA(hi, lo, x, y)((lo) += mad_f_mul((x), (y))) 507 # define MAD_F_MLA(hi, lo, x, y)((lo) += mad_f_mul((x), (y)))
508 # define MAD_F_MLN(hi, lo) ((lo) = -(lo))
419 # define MAD_F_MLZ(hi, lo) ((void) (hi), (mad_fixed_t) (lo)) 509 # define MAD_F_MLZ(hi, lo) ((void) (hi), (mad_fixed_t) (lo))
420# endif 510# endif
421 511
422# if !defined(MAD_F_ML0) 512# if !defined(MAD_F_ML0)
423 # define MAD_F_ML0(hi, lo, x, y)MAD_F_MLX((hi), (lo), (x), (y)) 513 # define MAD_F_ML0(hi, lo, x, y)MAD_F_MLX((hi), (lo), (x), (y))
424# endif 514# endif
425 515
516# if !defined(MAD_F_MLN)
517 # define MAD_F_MLN(hi, lo) ((hi) = ((lo) = -(lo)) ? ~(hi) : -(hi))
518# endif
519
426# if !defined(MAD_F_MLZ) 520# if !defined(MAD_F_MLZ)
427 # define MAD_F_MLZ(hi, lo) mad_f_scale64((hi), (lo)) 521 # define MAD_F_MLZ(hi, lo) mad_f_scale64((hi), (lo))
428# endif 522# endif
429 523
430# if !defined(mad_f_scale64) 524# if !defined(mad_f_scale64)
431# if defined(OPT_ACCURACY) 525# if defined(OPT_ACCURACY)
@@ -439,19 +533,20 @@ typedef unsigned long mad_fixed64lo_t;
439 (((hi) << (32 - MAD_F_SCALEBITS)) | \ 533 (((hi) << (32 - MAD_F_SCALEBITS)) | \
440 ((lo) >> MAD_F_SCALEBITS))) 534 ((lo) >> MAD_F_SCALEBITS)))
441# endif 535# endif
442# define MAD_F_SCALEBITS MAD_F_FRACBITS 536# define MAD_F_SCALEBITS MAD_F_FRACBITS
443# endif 537# endif
444 538
445/* miscellaneous C routines */ 539/* C routines */
446 540
447mad_fixed_t mad_f_abs(mad_fixed_t); 541mad_fixed_t mad_f_abs(mad_fixed_t);
542mad_fixed_t mad_f_div(mad_fixed_t, mad_fixed_t);
448 543
449# endif 544# endif
450 545
451/* Id: bit.h,v 1.7 2001/04/05 04:57:11 rob Exp */ 546/* Id: bit.h,v 1.12 2004/01/23 09:41:32 rob Exp */
452 547
453# ifndef LIBMAD_BIT_H 548# ifndef LIBMAD_BIT_H
454# define LIBMAD_BIT_H 549# define LIBMAD_BIT_H
455 550
456struct mad_bitptr { 551struct mad_bitptr {
457 unsigned char const *byte; 552 unsigned char const *byte;
@@ -474,13 +569,13 @@ unsigned long mad_bit_read(struct mad_bitptr *, unsigned int);
474void mad_bit_write(struct mad_bitptr *, unsigned int, unsigned long); 569void mad_bit_write(struct mad_bitptr *, unsigned int, unsigned long);
475 570
476unsigned short mad_bit_crc(struct mad_bitptr, unsigned int, unsigned short); 571unsigned short mad_bit_crc(struct mad_bitptr, unsigned int, unsigned short);
477 572
478# endif 573# endif
479 574
480/* Id: timer.h,v 1.10 2001/04/05 04:57:11 rob Exp */ 575/* Id: timer.h,v 1.16 2004/01/23 09:41:33 rob Exp */
481 576
482# ifndef LIBMAD_TIMER_H 577# ifndef LIBMAD_TIMER_H
483# define LIBMAD_TIMER_H 578# define LIBMAD_TIMER_H
484 579
485typedef struct { 580typedef struct {
486 signed long seconds; /* whole seconds */ 581 signed long seconds; /* whole seconds */
@@ -536,13 +631,13 @@ enum mad_units {
536 MAD_UNITS_29_97_FPS = -30, 631 MAD_UNITS_29_97_FPS = -30,
537 MAD_UNITS_47_952_FPS = -48, 632 MAD_UNITS_47_952_FPS = -48,
538 MAD_UNITS_49_95_FPS = -50, 633 MAD_UNITS_49_95_FPS = -50,
539 MAD_UNITS_59_94_FPS = -60 634 MAD_UNITS_59_94_FPS = -60
540}; 635};
541 636
542 # define mad_timer_reset(timer)(*(timer) = mad_timer_zero) 637 # define mad_timer_reset(timer)((void) (*(timer) = mad_timer_zero))
543 638
544int mad_timer_compare(mad_timer_t, mad_timer_t); 639int mad_timer_compare(mad_timer_t, mad_timer_t);
545 640
546 # define mad_timer_sign(timer)mad_timer_compare((timer), mad_timer_zero) 641 # define mad_timer_sign(timer)mad_timer_compare((timer), mad_timer_zero)
547 642
548void mad_timer_negate(mad_timer_t *); 643void mad_timer_negate(mad_timer_t *);
@@ -556,21 +651,24 @@ signed long mad_timer_count(mad_timer_t, enum mad_units);
556unsigned long mad_timer_fraction(mad_timer_t, unsigned long); 651unsigned long mad_timer_fraction(mad_timer_t, unsigned long);
557void mad_timer_string(mad_timer_t, char *, char const *, 652void mad_timer_string(mad_timer_t, char *, char const *,
558 enum mad_units, enum mad_units, unsigned long); 653 enum mad_units, enum mad_units, unsigned long);
559 654
560# endif 655# endif
561 656
562/* Id: stream.h,v 1.12 2001/04/10 05:18:21 rob Exp */ 657/* Id: stream.h,v 1.20 2004/02/05 09:02:39 rob Exp */
563 658
564# ifndef LIBMAD_STREAM_H 659# ifndef LIBMAD_STREAM_H
565# define LIBMAD_STREAM_H 660# define LIBMAD_STREAM_H
566 661
662
567 # define MAD_BUFFER_GUARD8 663 # define MAD_BUFFER_GUARD8
568 # define MAD_BUFFER_MDLEN(511 + 2048 + MAD_BUFFER_GUARD) 664 # define MAD_BUFFER_MDLEN(511 + 2048 + MAD_BUFFER_GUARD)
569 665
570enum mad_error { 666enum mad_error {
667 MAD_ERROR_NONE = 0x0000,/* no error */
668
571 MAD_ERROR_BUFLEN = 0x0001,/* input buffer too small (or EOF) */ 669 MAD_ERROR_BUFLEN = 0x0001,/* input buffer too small (or EOF) */
572 MAD_ERROR_BUFPTR = 0x0002,/* invalid (null) buffer pointer */ 670 MAD_ERROR_BUFPTR = 0x0002,/* invalid (null) buffer pointer */
573 671
574 MAD_ERROR_NOMEM = 0x0031,/* not enough memory */ 672 MAD_ERROR_NOMEM = 0x0031,/* not enough memory */
575 673
576 MAD_ERROR_LOSTSYNC = 0x0101,/* lost synchronization */ 674 MAD_ERROR_LOSTSYNC = 0x0101,/* lost synchronization */
@@ -579,12 +677,13 @@ enum mad_error {
579 MAD_ERROR_BADSAMPLERATE = 0x0104,/* reserved sample frequency value */ 677 MAD_ERROR_BADSAMPLERATE = 0x0104,/* reserved sample frequency value */
580 MAD_ERROR_BADEMPHASIS = 0x0105,/* reserved emphasis value */ 678 MAD_ERROR_BADEMPHASIS = 0x0105,/* reserved emphasis value */
581 679
582 MAD_ERROR_BADCRC = 0x0201,/* CRC check failed */ 680 MAD_ERROR_BADCRC = 0x0201,/* CRC check failed */
583 MAD_ERROR_BADBITALLOC = 0x0211,/* forbidden bit allocation value */ 681 MAD_ERROR_BADBITALLOC = 0x0211,/* forbidden bit allocation value */
584 MAD_ERROR_BADSCALEFACTOR = 0x0221,/* bad scalefactor index */ 682 MAD_ERROR_BADSCALEFACTOR = 0x0221,/* bad scalefactor index */
683 MAD_ERROR_BADMODE = 0x0222,/* bad bitrate/mode combination */
585 MAD_ERROR_BADFRAMELEN = 0x0231,/* bad frame length */ 684 MAD_ERROR_BADFRAMELEN = 0x0231,/* bad frame length */
586 MAD_ERROR_BADBIGVALUES = 0x0232,/* bad big_values count */ 685 MAD_ERROR_BADBIGVALUES = 0x0232,/* bad big_values count */
587 MAD_ERROR_BADBLOCKTYPE = 0x0233,/* reserved block_type */ 686 MAD_ERROR_BADBLOCKTYPE = 0x0233,/* reserved block_type */
588 MAD_ERROR_BADSCFSI = 0x0234,/* bad scalefactor selection info */ 687 MAD_ERROR_BADSCFSI = 0x0234,/* bad scalefactor selection info */
589 MAD_ERROR_BADDATAPTR = 0x0235,/* bad main_data_begin pointer */ 688 MAD_ERROR_BADDATAPTR = 0x0235,/* bad main_data_begin pointer */
590 MAD_ERROR_BADPART3LEN = 0x0236,/* bad audio data length */ 689 MAD_ERROR_BADPART3LEN = 0x0236,/* bad audio data length */
@@ -617,38 +716,42 @@ struct mad_stream {
617 int options; /* decoding options (see below) */ 716 int options; /* decoding options (see below) */
618 enum mad_error error; /* error code (see above) */ 717 enum mad_error error; /* error code (see above) */
619}; 718};
620 719
621enum { 720enum {
622 MAD_OPTION_IGNORECRC = 0x0001,/* ignore CRC errors */ 721 MAD_OPTION_IGNORECRC = 0x0001,/* ignore CRC errors */
623 MAD_OPTION_HALFSAMPLERATE = 0x0002,/* generate PCM at 1/2 sample rate */ 722 MAD_OPTION_HALFSAMPLERATE = 0x0002/* generate PCM at 1/2 sample rate */
624# if 0 /* not yet implemented */ 723# if 0 /* not yet implemented */
625 MAD_OPTION_LEFTCHANNEL = 0x0010,/* decode left channel only */ 724 MAD_OPTION_LEFTCHANNEL = 0x0010,/* decode left channel only */
626 MAD_OPTION_RIGHTCHANNEL = 0x0020,/* decode right channel only */ 725 MAD_OPTION_RIGHTCHANNEL = 0x0020,/* decode right channel only */
627 MAD_OPTION_SINGLECHANNEL = 0x0030,/* combine channels */ 726 MAD_OPTION_SINGLECHANNEL = 0x0030/* combine channels */
628# endif 727# endif
629}; 728};
630 729
631void mad_stream_init(struct mad_stream *); 730void mad_stream_init(struct mad_stream *);
632void mad_stream_finish(struct mad_stream *); 731void mad_stream_finish(struct mad_stream *);
633 732
634# define mad_stream_options(stream, opts) ((stream)->options = (opts)) 733# define mad_stream_options(stream, opts) \
734 ((void) ((stream)->options = (opts)))
635 735
636void mad_stream_buffer(struct mad_stream *, 736void mad_stream_buffer(struct mad_stream *,
637 unsigned char const *, unsigned long); 737 unsigned char const *, unsigned long);
638void mad_stream_skip(struct mad_stream *, unsigned long); 738void mad_stream_skip(struct mad_stream *, unsigned long);
639 739
640int mad_stream_sync(struct mad_stream *); 740int mad_stream_sync(struct mad_stream *);
641 741
742char const *mad_stream_errorstr(struct mad_stream const *);
743
642# endif 744# endif
643 745
644/* Id: frame.h,v 1.13 2001/04/05 04:57:11 rob Exp */ 746/* Id: frame.h,v 1.20 2004/01/23 09:41:32 rob Exp */
645 747
646# ifndef LIBMAD_FRAME_H 748# ifndef LIBMAD_FRAME_H
647# define LIBMAD_FRAME_H 749# define LIBMAD_FRAME_H
648 750
751
649enum mad_layer { 752enum mad_layer {
650 MAD_LAYER_I = 1, /* Layer I */ 753 MAD_LAYER_I = 1, /* Layer I */
651 MAD_LAYER_II = 2, /* Layer II */ 754 MAD_LAYER_II = 2, /* Layer II */
652 MAD_LAYER_III = 3 /* Layer III */ 755 MAD_LAYER_III = 3 /* Layer III */
653}; 756};
654 757
@@ -659,33 +762,36 @@ enum mad_mode {
659 MAD_MODE_STEREO = 3 /* normal LR stereo */ 762 MAD_MODE_STEREO = 3 /* normal LR stereo */
660}; 763};
661 764
662enum mad_emphasis { 765enum mad_emphasis {
663 MAD_EMPHASIS_NONE = 0, /* no emphasis */ 766 MAD_EMPHASIS_NONE = 0, /* no emphasis */
664 MAD_EMPHASIS_50_15_US = 1, /* 50/15 microseconds emphasis */ 767 MAD_EMPHASIS_50_15_US = 1, /* 50/15 microseconds emphasis */
665 MAD_EMPHASIS_CCITT_J_17 = 3 /* CCITT J.17 emphasis */ 768 MAD_EMPHASIS_CCITT_J_17 = 3, /* CCITT J.17 emphasis */
769 MAD_EMPHASIS_RESERVED = 2 /* unknown emphasis */
666}; 770};
667 771
668struct mad_frame { 772struct mad_header {
669 struct mad_header { 773 enum mad_layer layer; /* audio layer (1, 2, or 3) */
670 enum mad_layer layer; /* audio layer (1, 2, or 3) */ 774 enum mad_mode mode; /* channel mode (see above) */
671 enum mad_mode mode; /* channel mode (see above) */ 775 int mode_extension; /* additional mode info */
672 int mode_extension; /* additional mode info */ 776 enum mad_emphasis emphasis; /* de-emphasis to use (see above) */
673 enum mad_emphasis emphasis; /* de-emphasis to use (see above) */ 777
778 unsigned long bitrate; /* stream bitrate (bps) */
779 unsigned int samplerate; /* sampling frequency (Hz) */
674 780
675 unsigned long bitrate; /* stream bitrate (bps) */ 781 unsigned short crc_check; /* frame CRC accumulator */
676 unsigned int samplerate; /* sampling frequency (Hz) */ 782 unsigned short crc_target; /* final target CRC checksum */
677 783
678 unsigned short crc_check; /* frame CRC accumulator */ 784 int flags; /* flags (see below) */
679 unsigned short crc_target; /* final target CRC checksum */ 785 int private_bits; /* private bits (see below) */
680 786
681 int flags; /* flags (see below) */ 787 mad_timer_t duration; /* audio playing time of frame */
682 int private_bits; /* private bits (see below) */ 788};
683 789
684 mad_timer_t duration; /* audio playing time of frame */ 790struct mad_frame {
685 } header; 791 struct mad_header header; /* MPEG audio header */
686 792
687 int options; /* decoding options (from stream) */ 793 int options; /* decoding options (from stream) */
688 794
689 mad_fixed_t sbsample[2][36][32];/* synthesis subband filter samples */ 795 mad_fixed_t sbsample[2][36][32];/* synthesis subband filter samples */
690 mad_fixed_t (*overlap)[2][32][18];/* Layer III block overlap data */ 796 mad_fixed_t (*overlap)[2][32][18];/* Layer III block overlap data */
691}; 797};
@@ -694,32 +800,32 @@ struct mad_frame {
694# define MAD_NSBSAMPLES(header) \ 800# define MAD_NSBSAMPLES(header) \
695 ((header)->layer == MAD_LAYER_I ? 12 : \ 801 ((header)->layer == MAD_LAYER_I ? 12 : \
696 (((header)->layer == MAD_LAYER_III && \ 802 (((header)->layer == MAD_LAYER_III && \
697 ((header)->flags & MAD_FLAG_LSF_EXT)) ? 18 : 36)) 803 ((header)->flags & MAD_FLAG_LSF_EXT)) ? 18 : 36))
698 804
699enum { 805enum {
700 MAD_FLAG_NPRIVATE_III = 0x0007,/* number of Layer III private bits */ 806 MAD_FLAG_NPRIVATE_III = 0x0007,/* number of Layer III private bits */
701 MAD_FLAG_INCOMPLETE = 0x0008,/* header but not data is decoded */ 807 MAD_FLAG_INCOMPLETE = 0x0008,/* header but not data is decoded */
702 808
703 MAD_FLAG_PROTECTION = 0x0010,/* frame has CRC protection */ 809 MAD_FLAG_PROTECTION = 0x0010,/* frame has CRC protection */
704 MAD_FLAG_COPYRIGHT = 0x0020,/* frame is copyright */ 810 MAD_FLAG_COPYRIGHT = 0x0020,/* frame is copyright */
705 MAD_FLAG_ORIGINAL = 0x0040,/* frame is original (else copy) */ 811 MAD_FLAG_ORIGINAL = 0x0040,/* frame is original (else copy) */
706 MAD_FLAG_PADDING = 0x0080,/* frame has additional slot */ 812 MAD_FLAG_PADDING = 0x0080,/* frame has additional slot */
707 813
708 MAD_FLAG_I_STEREO = 0x0100,/* uses intensity joint stereo */ 814 MAD_FLAG_I_STEREO = 0x0100,/* uses intensity joint stereo */
709 MAD_FLAG_MS_STEREO = 0x0200,/* uses middle/side joint stereo */ 815 MAD_FLAG_MS_STEREO = 0x0200,/* uses middle/side joint stereo */
710 MAD_FLAG_FREEFORMAT = 0x0400,/* uses free format bitrate */ 816 MAD_FLAG_FREEFORMAT = 0x0400,/* uses free format bitrate */
711 817
712 MAD_FLAG_LSF_EXT = 0x1000,/* lower sampling freq. extension */ 818 MAD_FLAG_LSF_EXT = 0x1000,/* lower sampling freq. extension */
713 MAD_FLAG_MC_EXT = 0x2000,/* multichannel audio extension */ 819 MAD_FLAG_MC_EXT = 0x2000,/* multichannel audio extension */
714 MAD_FLAG_MPEG_2_5_EXT = 0x4000/* MPEG 2.5 (unofficial) extension */ 820 MAD_FLAG_MPEG_2_5_EXT = 0x4000/* MPEG 2.5 (unofficial) extension */
715}; 821};
716 822
717enum { 823enum {
718 MAD_PRIVATE_HEADER = 0x0100,/* header private bit */ 824 MAD_PRIVATE_HEADER = 0x0100,/* header private bit */
719 MAD_PRIVATE_III = 0x001f/* Layer III private bits (up to 5) */ 825 MAD_PRIVATE_III = 0x001f/* Layer III private bits (up to 5) */
720}; 826};
721 827
722void mad_header_init(struct mad_header *); 828void mad_header_init(struct mad_header *);
723 829
724# define mad_header_finish(header) /* nothing */ 830# define mad_header_finish(header) /* nothing */
725 831
@@ -731,56 +837,77 @@ void mad_frame_finish(struct mad_frame *);
731int mad_frame_decode(struct mad_frame *, struct mad_stream *); 837int mad_frame_decode(struct mad_frame *, struct mad_stream *);
732 838
733void mad_frame_mute(struct mad_frame *); 839void mad_frame_mute(struct mad_frame *);
734 840
735# endif 841# endif
736 842
737/* Id: synth.h,v 1.8 2001/04/05 04:57:11 rob Exp */ 843/* Id: synth.h,v 1.15 2004/01/23 09:41:33 rob Exp */
738 844
739# ifndef LIBMAD_SYNTH_H 845# ifndef LIBMAD_SYNTH_H
740# define LIBMAD_SYNTH_H 846# define LIBMAD_SYNTH_H
741 847
848
849struct mad_pcm {
850 unsigned int samplerate; /* sampling frequency (Hz) */
851 unsigned short channels; /* number of channels */
852 unsigned short length; /* number of samples per channel */
853 mad_fixed_t samples[2][1152]; /* PCM output samples [ch][sample] */
854};
855
742struct mad_synth { 856struct mad_synth {
743 mad_fixed_t filter[2][2][2][16][8];/* polyphase filterbank outputs */ 857 mad_fixed_t filter[2][2][2][16][8];/* polyphase filterbank outputs */
744 /* [ch][eo][peo][s][v] */ 858 /* [ch][eo][peo][s][v] */
745 859
746 unsigned int phase; /* current processing phase */ 860 unsigned int phase; /* current processing phase */
747 861
748 struct mad_pcm { 862 struct mad_pcm pcm; /* PCM output */
749 unsigned int samplerate; /* sampling frequency (Hz) */ 863};
750 unsigned short channels; /* number of channels */ 864
751 unsigned short length; /* number of samples per channel */ 865/* single channel PCM selector */
752 mad_fixed_t samples[2][1152];/* PCM output samples */ 866enum {
753 } pcm; 867 MAD_PCM_CHANNEL_SINGLE = 0
868};
869
870/* dual channel PCM selector */
871enum {
872 MAD_PCM_CHANNEL_DUAL_1 = 0,
873 MAD_PCM_CHANNEL_DUAL_2 = 1
874};
875
876/* stereo PCM selector */
877enum {
878 MAD_PCM_CHANNEL_STEREO_LEFT = 0,
879 MAD_PCM_CHANNEL_STEREO_RIGHT = 1
754}; 880};
755 881
756void mad_synth_init(struct mad_synth *); 882void mad_synth_init(struct mad_synth *);
757 883
758# define mad_synth_finish(synth) /* nothing */ 884# define mad_synth_finish(synth) /* nothing */
759 885
760void mad_synth_mute(struct mad_synth *); 886void mad_synth_mute(struct mad_synth *);
761 887
762void mad_synth_frame(struct mad_synth *, struct mad_frame const *); 888void mad_synth_frame(struct mad_synth *, struct mad_frame const *);
763 889
764# endif 890# endif
765 891
766/* Id: decoder.h,v 1.9 2001/04/05 04:57:11 rob Exp */ 892/* Id: decoder.h,v 1.17 2004/01/23 09:41:32 rob Exp */
767 893
768# ifndef LIBMAD_DECODER_H 894# ifndef LIBMAD_DECODER_H
769# define LIBMAD_DECODER_H 895# define LIBMAD_DECODER_H
770 896
897
771enum mad_decoder_mode { 898enum mad_decoder_mode {
772 MAD_DECODER_MODE_SYNC = 0, 899 MAD_DECODER_MODE_SYNC = 0,
773 MAD_DECODER_MODE_ASYNC 900 MAD_DECODER_MODE_ASYNC
774}; 901};
775 902
776enum mad_flow { 903enum mad_flow {
777 MAD_FLOW_CONTINUE = 0x0000, 904 MAD_FLOW_CONTINUE = 0x0000,/* continue normally */
778 MAD_FLOW_STOP = 0x0010, 905 MAD_FLOW_STOP = 0x0010,/* stop decoding normally */
779 MAD_FLOW_BREAK = 0x0011, 906 MAD_FLOW_BREAK = 0x0011,/* stop decoding and signal an error */
780 MAD_FLOW_IGNORE = 0x0020 907 MAD_FLOW_IGNORE = 0x0020/* ignore the current frame */
781}; 908};
782 909
783struct mad_decoder { 910struct mad_decoder {
784 enum mad_decoder_mode mode; 911 enum mad_decoder_mode mode;
785 912
786 int options; 913 int options;
@@ -798,33 +925,40 @@ struct mad_decoder {
798 } *sync; 925 } *sync;
799 926
800 void *cb_data; 927 void *cb_data;
801 928
802 enum mad_flow (*input_func)(void *, struct mad_stream *); 929 enum mad_flow (*input_func)(void *, struct mad_stream *);
803 enum mad_flow (*header_func)(void *, struct mad_header const *); 930 enum mad_flow (*header_func)(void *, struct mad_header const *);
804 enum mad_flow (*filter_func)(void *, struct mad_frame *); 931 enum mad_flow (*filter_func)(void *,
932 struct mad_stream const *, struct mad_frame *);
805 enum mad_flow (*output_func)(void *, 933 enum mad_flow (*output_func)(void *,
806 struct mad_header const *, struct mad_pcm *); 934 struct mad_header const *, struct mad_pcm *);
807 enum mad_flow (*error_func)(void *, struct mad_stream *, struct mad_frame *); 935 enum mad_flow (*error_func)(void *, struct mad_stream *, struct mad_frame *);
808 enum mad_flow (*message_func)(void *, void *, unsigned int *); 936 enum mad_flow (*message_func)(void *, void *, unsigned int *);
809}; 937};
810 938
811void mad_decoder_init(struct mad_decoder *, void *, 939void mad_decoder_init(struct mad_decoder *, void *,
812 enum mad_flow (*)(void *, struct mad_stream *), 940 enum mad_flow (*)(void *, struct mad_stream *),
813 enum mad_flow (*)(void *, struct mad_header const *), 941 enum mad_flow (*)(void *, struct mad_header const *),
814 enum mad_flow (*)(void *, struct mad_frame *), 942 enum mad_flow (*)(void *,
943 struct mad_stream const *,
944 struct mad_frame *),
815 enum mad_flow (*)(void *, 945 enum mad_flow (*)(void *,
816 struct mad_header const *, 946 struct mad_header const *,
817 struct mad_pcm *), 947 struct mad_pcm *),
818 enum mad_flow (*)(void *, 948 enum mad_flow (*)(void *,
819 struct mad_stream *, 949 struct mad_stream *,
820 struct mad_frame *), 950 struct mad_frame *),
821 enum mad_flow (*)(void *, void *, unsigned int *)); 951 enum mad_flow (*)(void *, void *, unsigned int *));
822int mad_decoder_finish(struct mad_decoder *); 952int mad_decoder_finish(struct mad_decoder *);
823 953
824# define mad_decoder_options(decoder, opts) ((decoder)->options = (opts)) 954# define mad_decoder_options(decoder, opts) \
955 ((void) ((decoder)->options = (opts)))
825 956
826int mad_decoder_run(struct mad_decoder *, enum mad_decoder_mode); 957int mad_decoder_run(struct mad_decoder *, enum mad_decoder_mode);
827int mad_decoder_message(struct mad_decoder *, void *, unsigned int *); 958int mad_decoder_message(struct mad_decoder *, void *, unsigned int *);
828 959
829# endif 960# endif
830 961
962# ifdef __cplusplus
963}
964# endif