3 * exponents.c Copyright (C) Aaron Holtzman - May 1999
5 * This file is part of libmpeg3
7 * libmpeg3 is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * libmpeg3 is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Make; see the file COPYING. If not, write to
19 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24 #define MIN(x, y) ((x) > (y) ? (y) : (x))
26 #include "mpeg3audio.h"
29 /* Exponent defines */
34 static inline int mpeg3audio_ac3_exp_unpack_ch(unsigned int type
,
37 unsigned int initial_exp
,
38 unsigned short exps
[],
43 int exp_1
, exp_2
, exp_3
;
45 if(expstr
== MPEG3_EXP_REUSE
)
48 /* Handle the initial absolute exponent */
49 exp_acc
= initial_exp
;
52 /* In the case of a fbw channel then the initial absolute value is
54 if(type
!= UNPACK_CPL
)
57 /* Loop through the groups and fill the dest array appropriately */
58 for(i
= 0; i
< ngrps
; i
++)
62 // fprintf(stderr, "mpeg3audio_ac3_exp_unpack_ch: Invalid exponent %d\n", exps[i]);
67 exp_2
= (exps
[i
] % 25) / 5;
68 exp_3
= (exps
[i
] % 25) % 5;
70 exp_acc
+= (exp_1
- 2);
87 exp_acc
+= (exp_2
- 2);
104 exp_acc
+= (exp_3
- 2);
124 int mpeg3audio_ac3_exponent_unpack(mpeg3audio_t
*audio
,
126 mpeg3_ac3audblk_t
*audblk
)
130 for(i
= 0; i
< bsi
->nfchans
; i
++)
131 result
|= mpeg3audio_ac3_exp_unpack_ch(UNPACK_FBW
,
138 if(audblk
->cplinu
&& !result
)
139 result
|= mpeg3audio_ac3_exp_unpack_ch(UNPACK_CPL
,
142 audblk
->cplabsexp
<< 1,
144 &audblk
->cpl_exp
[audblk
->cplstrtmant
]);
146 if(bsi
->lfeon
&& !result
)
147 result
|= mpeg3audio_ac3_exp_unpack_ch(UNPACK_LFE
,