1 /*****************************************************************************
2 * ac3_exponent.h: ac3 exponent calculations
3 *****************************************************************************
4 * Copyright (C) 1999, 2000 VideoLAN
5 * $Id: ac3_exponent.h,v 1.5 2001/05/15 16:19:42 sam Exp $
7 * Authors: Michel Kaempf <maxx@via.ecp.fr>
8 * Michel Lespinasse <walken@zoy.org>
9 * Aaron Holtzman <aholtzma@engr.uvic.ca>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
24 *****************************************************************************/
26 static const s16 exps_1[128] =
28 -2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,
29 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
30 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
31 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
32 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
36 static const s16 exps_2[128] =
38 -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
39 -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
40 -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
41 -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
42 -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
46 static const s16 exps_3[128] =
48 -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,
49 -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,
50 -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,
51 -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,
52 -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,
60 static __inline__ int exp_unpack_ch (ac3dec_t * p_ac3dec, u16 type,
61 u16 expstr, u16 ngrps, u16 initial_exp,
62 u16 exps[], u16 * dest)
67 if (expstr == EXP_REUSE)
72 /* Handle the initial absolute exponent */
73 exp_acc = initial_exp;
76 /* In the case of a fbw channel then the initial absolute values is
78 if (type != UNPACK_CPL)
83 /* Loop through the groups and fill the dest array appropriately */
87 for (i = 0; i < ngrps; i++)
91 intf_ErrMsg ( "ac3dec error: invalid exponent" );
94 exp_acc += (exps_1[exps[i]] /*- 2*/);
96 exp_acc += (exps_2[exps[i]] /*- 2*/);
98 exp_acc += (exps_3[exps[i]] /*- 2*/);
103 case EXP_D25: /* 2 */
104 for (i = 0; i < ngrps; i++)
108 intf_ErrMsg ( "ac3dec error: invalid exponent" );
111 exp_acc += (exps_1[exps[i]] /*- 2*/);
114 exp_acc += (exps_2[exps[i]] /*- 2*/);
117 exp_acc += (exps_3[exps[i]] /*- 2*/);
123 case EXP_D45: /* 3 */
124 for (i = 0; i < ngrps; i++)
128 intf_ErrMsg ( "ac3dec error: invalid exponent" );
131 exp_acc += (exps_1[exps[i]] /*- 2*/);
136 exp_acc += (exps_2[exps[i]] /*- 2*/);
141 exp_acc += (exps_3[exps[i]] /*- 2*/);