summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/libmad/mad.h
Unidiff
Diffstat (limited to 'core/multimedia/opieplayer/libmad/mad.h') (more/less context) (show whitespace changes)
-rw-r--r--core/multimedia/opieplayer/libmad/mad.h292
1 files changed, 213 insertions, 79 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,5 +1,5 @@
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
@@ -18,12 +18,21 @@
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
@@ -31,6 +40,6 @@
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
@@ -43,7 +52,7 @@
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[];
@@ -54,5 +63,5 @@ extern char const mad_build[];
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
@@ -71,4 +80,16 @@ typedef 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
@@ -131,18 +152,29 @@ typedef unsigned long mad_fixed64lo_t;
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
@@ -153,4 +185,27 @@ typedef unsigned long mad_fixed64lo_t;
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
@@ -199,4 +254,19 @@ typedef unsigned long mad_fixed64lo_t;
199 __result; \ 254 __result; \
200 }) 255 })
256# elif defined(OPT_INTEL)
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 })
201# else 271# else
202# define mad_f_scale64(hi, lo) \ 272# define mad_f_scale64(hi, lo) \
@@ -211,4 +281,5 @@ typedef unsigned long mad_fixed64lo_t;
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 ----------------------------------------------------------------- */
@@ -222,10 +293,6 @@ typedef unsigned long mad_fixed64lo_t;
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) \
@@ -254,9 +321,16 @@ typedef unsigned long mad_fixed64lo_t;
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) \
@@ -326,15 +400,22 @@ typedef unsigned long mad_fixed64lo_t;
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
416# if defined(OPT_ACCURACY)
417/*
418 * This gives best accuracy but is not very fast.
419 */
339# define MAD_F_MLA(hi, lo, x, y) \ 420# define MAD_F_MLA(hi, lo, x, y) \
340 ({ mad_fixed64hi_t __hi; \ 421 ({ mad_fixed64hi_t __hi; \
@@ -344,26 +425,28 @@ typedef unsigned long mad_fixed64lo_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" \
449 : "=r" (__result) \
450 : "%r" (__result), "r" (__round)); \
368 __result; \ 451 __result; \
369 }) 452 })
@@ -371,11 +454,13 @@ typedef unsigned long mad_fixed64lo_t;
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)); \
459 asm ("insrwi %0,%1,%2,0" \
460 : "+r" (__result) \
461 : "r" (hi), "i" (MAD_F_SCALEBITS)); \
377 __result; \ 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
@@ -394,6 +479,10 @@ typedef unsigned long mad_fixed64lo_t;
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 */
481# if defined(OPT_SPEED)
482 # define mad_f_mul(x, y)(((x) >> 12) * ((y) >> 16))
483# else
396 # define mad_f_mul(x, y)((((x) + (1L << 11)) >> 12) * \ 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/* ------------------------------------------------------------------------- */
@@ -407,6 +496,6 @@ typedef unsigned long mad_fixed64lo_t;
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); \
@@ -417,4 +506,5 @@ typedef unsigned long mad_fixed64lo_t;
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
@@ -424,4 +514,8 @@ typedef unsigned long mad_fixed64lo_t;
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))
@@ -443,11 +537,12 @@ typedef unsigned long mad_fixed64lo_t;
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
@@ -478,5 +573,5 @@ unsigned short mad_bit_crc(struct mad_bitptr, unsigned int, unsigned short);
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
@@ -540,5 +635,5 @@ enum mad_units {
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);
@@ -560,13 +655,16 @@ void mad_timer_string(mad_timer_t, char *, char const *,
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 */
@@ -583,4 +681,5 @@ enum mad_error {
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 */
@@ -621,9 +720,9 @@ struct mad_stream {
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};
@@ -632,5 +731,6 @@ void 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 *,
@@ -640,11 +740,14 @@ void mad_stream_skip(struct mad_stream *, unsigned long);
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 */
@@ -663,8 +766,8 @@ enum 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 {
669 struct mad_header { 772 struct mad_header {
670 enum mad_layer layer; /* audio layer (1, 2, or 3) */ 773 enum mad_layer layer; /* audio layer (1, 2, or 3) */
@@ -683,5 +786,8 @@ struct mad_frame {
683 786
684 mad_timer_t duration; /* audio playing time of frame */ 787 mad_timer_t duration; /* audio playing time of frame */
685 } header; 788};
789
790struct mad_frame {
791 struct mad_header header; /* MPEG audio header */
686 792
687 int options; /* decoding options (from stream) */ 793 int options; /* decoding options (from stream) */
@@ -735,9 +841,17 @@ void mad_frame_mute(struct mad_frame *);
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 */
@@ -746,10 +860,22 @@ struct mad_synth {
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
@@ -764,9 +890,10 @@ void mad_synth_frame(struct mad_synth *, struct mad_frame const *);
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,
@@ -775,8 +902,8 @@ enum mad_decoder_mode {
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
@@ -802,5 +929,6 @@ struct mad_decoder {
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 *);
@@ -812,5 +940,7 @@ void 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 *,
@@ -822,5 +952,6 @@ void mad_decoder_init(struct mad_decoder *, void *,
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);
@@ -829,2 +960,5 @@ int mad_decoder_message(struct mad_decoder *, void *, unsigned int *);
829# endif 960# endif
830 961
962# ifdef __cplusplus
963}
964# endif