author | llornkcor <llornkcor> | 2005-11-08 23:16:03 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2005-11-08 23:16:03 (UTC) |
commit | 6bd52d3658f01c966d690b12235592a5473a4d57 (patch) (unidiff) | |
tree | 76e25003b738fde6ebbea5d338b7cf76b82f47fa /core/multimedia/opieplayer/libmad/mad.h | |
parent | a8063e0797d6edf2ead22fc8c5346ddf187f0b5d (diff) | |
download | opie-6bd52d3658f01c966d690b12235592a5473a4d57.zip opie-6bd52d3658f01c966d690b12235592a5473a4d57.tar.gz opie-6bd52d3658f01c966d690b12235592a5473a4d57.tar.bz2 |
update libmad and add 64bit define
Diffstat (limited to 'core/multimedia/opieplayer/libmad/mad.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/libmad/mad.h | 376 |
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,4 +1,4 @@ | |||
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 | * |
@@ -19,5 +19,13 @@ | |||
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 | ||
24 | extern "C" { | ||
25 | # endif | ||
26 | |||
27 | # define FPM_INTEL | ||
28 | |||
29 | |||
30 | |||
23 | # define SIZEOF_INT 4 | 31 | # define SIZEOF_INT 4 |
@@ -26,3 +34,4 @@ | |||
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 | ||
@@ -32,4 +41,4 @@ | |||
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)" |
@@ -44,5 +53,5 @@ | |||
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 | ||
@@ -55,3 +64,3 @@ extern char const mad_build[]; | |||
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 | ||
@@ -72,2 +81,14 @@ typedef unsigned long mad_fixed64lo_t; | |||
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) | ||
89 | typedef double mad_sample_t; | ||
90 | # else | ||
91 | typedef mad_fixed_t mad_sample_t; | ||
92 | # endif | ||
93 | |||
73 | /* | 94 | /* |
@@ -132,7 +153,18 @@ typedef unsigned long mad_fixed64lo_t; | |||
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 | */ |
@@ -141,3 +173,3 @@ typedef unsigned long mad_fixed64lo_t; | |||
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)) |
@@ -145,3 +177,3 @@ typedef unsigned long mad_fixed64lo_t; | |||
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 |
@@ -154,2 +186,25 @@ typedef unsigned long mad_fixed64lo_t; | |||
154 | 186 | ||
187 | # if defined(_MSC_VER) | ||
188 | # pragma warning(push) | ||
189 | # pragma warning(disable: 4035) /* no return value */ | ||
190 | static __forceinline | ||
191 | mad_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 | /* |
@@ -158,3 +213,3 @@ typedef unsigned long mad_fixed64lo_t; | |||
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" \ |
@@ -164,3 +219,3 @@ typedef unsigned long mad_fixed64lo_t; | |||
164 | 219 | ||
165 | # if defined(OPT_ACCURACY) | 220 | # if defined(OPT_ACCURACY) |
166 | /* | 221 | /* |
@@ -168,3 +223,3 @@ typedef unsigned long mad_fixed64lo_t; | |||
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; \ |
@@ -178,5 +233,5 @@ typedef unsigned long mad_fixed64lo_t; | |||
178 | }) | 233 | }) |
179 | # endif /* OPT_ACCURACY */ | 234 | # endif /* OPT_ACCURACY */ |
180 | 235 | ||
181 | # if defined(OPT_ACCURACY) | 236 | # if defined(OPT_ACCURACY) |
182 | /* | 237 | /* |
@@ -184,3 +239,3 @@ typedef unsigned long mad_fixed64lo_t; | |||
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_; \ |
@@ -200,4 +255,19 @@ typedef unsigned long mad_fixed64lo_t; | |||
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; \ |
@@ -209,5 +279,6 @@ typedef unsigned long mad_fixed64lo_t; | |||
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 | ||
@@ -223,8 +294,4 @@ typedef unsigned long mad_fixed64lo_t; | |||
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 | */ |
@@ -255,2 +322,9 @@ typedef unsigned long mad_fixed64lo_t; | |||
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) \ |
@@ -259,3 +333,3 @@ typedef unsigned long mad_fixed64lo_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), \ |
@@ -327,14 +401,21 @@ typedef unsigned long mad_fixed64lo_t; | |||
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; \ |
@@ -342,7 +423,10 @@ typedef unsigned long mad_fixed64lo_t; | |||
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 | ||
@@ -350,20 +434,19 @@ typedef unsigned long mad_fixed64lo_t; | |||
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 | }) |
@@ -372,9 +455,11 @@ typedef unsigned long mad_fixed64lo_t; | |||
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 | ||
@@ -395,4 +480,8 @@ typedef unsigned long mad_fixed64lo_t; | |||
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 | ||
@@ -408,4 +497,4 @@ typedef unsigned long mad_fixed64lo_t; | |||
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)); \ |
@@ -418,2 +507,3 @@ typedef unsigned long mad_fixed64lo_t; | |||
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)) |
@@ -425,2 +515,6 @@ typedef unsigned long mad_fixed64lo_t; | |||
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) |
@@ -444,5 +538,6 @@ typedef unsigned long mad_fixed64lo_t; | |||
444 | 538 | ||
445 | /* miscellaneous C routines */ | 539 | /* C routines */ |
446 | 540 | ||
447 | mad_fixed_t mad_f_abs(mad_fixed_t); | 541 | mad_fixed_t mad_f_abs(mad_fixed_t); |
542 | mad_fixed_t mad_f_div(mad_fixed_t, mad_fixed_t); | ||
448 | 543 | ||
@@ -450,3 +545,3 @@ mad_fixed_t mad_f_abs(mad_fixed_t); | |||
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 | ||
@@ -479,3 +574,3 @@ unsigned short mad_bit_crc(struct mad_bitptr, unsigned int, unsigned short); | |||
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 | ||
@@ -541,3 +636,3 @@ enum mad_units { | |||
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 | ||
@@ -561,3 +656,3 @@ void mad_timer_string(mad_timer_t, char *, char const *, | |||
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 | ||
@@ -566,2 +661,3 @@ void mad_timer_string(mad_timer_t, char *, char const *, | |||
566 | 661 | ||
662 | |||
567 | # define MAD_BUFFER_GUARD8 | 663 | # define MAD_BUFFER_GUARD8 |
@@ -570,2 +666,4 @@ void mad_timer_string(mad_timer_t, char *, char const *, | |||
570 | enum mad_error { | 666 | enum 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) */ |
@@ -584,2 +682,3 @@ enum mad_error { | |||
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 */ |
@@ -622,3 +721,3 @@ enum { | |||
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 */ |
@@ -626,3 +725,3 @@ enum { | |||
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 |
@@ -633,3 +732,4 @@ void 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 | ||
@@ -641,5 +741,7 @@ int mad_stream_sync(struct mad_stream *); | |||
641 | 741 | ||
742 | char 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 | ||
@@ -648,2 +750,3 @@ int mad_stream_sync(struct mad_stream *); | |||
648 | 750 | ||
751 | |||
649 | enum mad_layer { | 752 | enum mad_layer { |
@@ -664,23 +767,26 @@ enum mad_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 | ||
668 | struct mad_frame { | 772 | struct 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 */ | 790 | struct mad_frame { |
685 | } header; | 791 | struct mad_header header; /* MPEG audio header */ |
686 | 792 | ||
@@ -699,17 +805,17 @@ struct mad_frame { | |||
699 | enum { | 805 | enum { |
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 | }; |
@@ -717,4 +823,4 @@ enum { | |||
717 | enum { | 823 | enum { |
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 | }; |
@@ -736,3 +842,3 @@ void mad_frame_mute(struct mad_frame *); | |||
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 | ||
@@ -741,2 +847,10 @@ void mad_frame_mute(struct mad_frame *); | |||
741 | 847 | ||
848 | |||
849 | struct 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 | |||
742 | struct mad_synth { | 856 | struct mad_synth { |
@@ -747,8 +861,20 @@ struct mad_synth { | |||
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 */ | 866 | enum { |
753 | } pcm; | 867 | MAD_PCM_CHANNEL_SINGLE = 0 |
868 | }; | ||
869 | |||
870 | /* dual channel PCM selector */ | ||
871 | enum { | ||
872 | MAD_PCM_CHANNEL_DUAL_1 = 0, | ||
873 | MAD_PCM_CHANNEL_DUAL_2 = 1 | ||
874 | }; | ||
875 | |||
876 | /* stereo PCM selector */ | ||
877 | enum { | ||
878 | MAD_PCM_CHANNEL_STEREO_LEFT = 0, | ||
879 | MAD_PCM_CHANNEL_STEREO_RIGHT = 1 | ||
754 | }; | 880 | }; |
@@ -765,3 +891,3 @@ void mad_synth_frame(struct mad_synth *, struct mad_frame const *); | |||
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 | ||
@@ -770,2 +896,3 @@ void mad_synth_frame(struct mad_synth *, struct mad_frame const *); | |||
770 | 896 | ||
897 | |||
771 | enum mad_decoder_mode { | 898 | enum mad_decoder_mode { |
@@ -776,6 +903,6 @@ enum mad_decoder_mode { | |||
776 | enum mad_flow { | 903 | enum 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 | }; |
@@ -803,3 +930,4 @@ struct mad_decoder { | |||
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 *, |
@@ -813,3 +941,5 @@ void mad_decoder_init(struct mad_decoder *, void *, | |||
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 *, |
@@ -823,3 +953,4 @@ int 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 | ||
@@ -830 +961,4 @@ int mad_decoder_message(struct mad_decoder *, void *, unsigned int *); | |||
830 | 961 | ||
962 | # ifdef __cplusplus | ||
963 | } | ||
964 | # endif | ||