~ubuntu-branches/debian/wheezy/vlc/wheezy

« back to all changes in this revision

Viewing changes to plugins/ac3_adec/ac3_exponent.h

Tags: upstream-0.7.2.final
ImportĀ upstreamĀ versionĀ 0.7.2.final

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*****************************************************************************
2
 
 * ac3_exponent.h: ac3 exponent calculations
3
 
 *****************************************************************************
4
 
 * Copyright (C) 1999, 2000 VideoLAN
5
 
 * $Id: ac3_exponent.h,v 1.1 2001/11/13 12:09:17 henri Exp $
6
 
 *
7
 
 * Authors: Michel Kaempf <maxx@via.ecp.fr>
8
 
 *          Michel Lespinasse <walken@zoy.org>
9
 
 *          Aaron Holtzman <aholtzma@engr.uvic.ca>
10
 
 *
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.
15
 
 * 
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.
20
 
 *
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
 
 *****************************************************************************/
25
 
 
26
 
static const s16 exps_1[128] =
27
 
{
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,
33
 
     0, 0, 0
34
 
};
35
 
 
36
 
static const s16 exps_2[128] =
37
 
{
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,
43
 
     0, 0, 0
44
 
};
45
 
 
46
 
static const s16 exps_3[128] =
47
 
{
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,
53
 
     0, 0, 0
54
 
};
55
 
 
56
 
#define UNPACK_FBW 1 
57
 
#define UNPACK_CPL 2 
58
 
#define UNPACK_LFE 4
59
 
 
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)
63
 
{
64
 
    u16 i,j;
65
 
    s16 exp_acc;
66
 
 
67
 
    if  (expstr == EXP_REUSE)
68
 
    {
69
 
        return 0;
70
 
    }
71
 
 
72
 
    /* Handle the initial absolute exponent */
73
 
    exp_acc = initial_exp;
74
 
    j = 0;
75
 
 
76
 
    /* In the case of a fbw channel then the initial absolute values is
77
 
     * also an exponent */
78
 
    if (type != UNPACK_CPL)
79
 
    {
80
 
        dest[j++] = exp_acc;
81
 
    }
82
 
 
83
 
    /* Loop through the groups and fill the dest array appropriately */
84
 
    switch (expstr)
85
 
    {
86
 
    case EXP_D15:        /* 1 */
87
 
        for (i = 0; i < ngrps; i++)
88
 
        {
89
 
            if (exps[i] > 124)
90
 
            {
91
 
                intf_ErrMsg ( "ac3dec error: invalid exponent" );
92
 
                return 1;
93
 
            }
94
 
            exp_acc += (exps_1[exps[i]] /*- 2*/);
95
 
            dest[j++] = exp_acc;
96
 
            exp_acc += (exps_2[exps[i]] /*- 2*/);
97
 
            dest[j++] = exp_acc;
98
 
            exp_acc += (exps_3[exps[i]] /*- 2*/);
99
 
            dest[j++] = exp_acc;
100
 
        }
101
 
        break;
102
 
 
103
 
    case EXP_D25:        /* 2 */
104
 
        for (i = 0; i < ngrps; i++)
105
 
        {
106
 
            if (exps[i] > 124)
107
 
            {
108
 
                intf_ErrMsg ( "ac3dec error: invalid exponent" );
109
 
                return 1;
110
 
            }
111
 
            exp_acc += (exps_1[exps[i]] /*- 2*/);
112
 
            dest[j++] = exp_acc;
113
 
            dest[j++] = exp_acc;
114
 
            exp_acc += (exps_2[exps[i]] /*- 2*/);
115
 
            dest[j++] = exp_acc;
116
 
            dest[j++] = exp_acc;
117
 
            exp_acc += (exps_3[exps[i]] /*- 2*/);
118
 
            dest[j++] = exp_acc;
119
 
            dest[j++] = exp_acc;
120
 
        }
121
 
        break;
122
 
 
123
 
    case EXP_D45:        /* 3 */
124
 
        for (i = 0; i < ngrps; i++)
125
 
        {
126
 
            if (exps[i] > 124)
127
 
            {
128
 
                intf_ErrMsg ( "ac3dec error: invalid exponent" );
129
 
                return 1;
130
 
            }
131
 
            exp_acc += (exps_1[exps[i]] /*- 2*/);
132
 
            dest[j++] = exp_acc;
133
 
            dest[j++] = exp_acc;
134
 
            dest[j++] = exp_acc;
135
 
            dest[j++] = exp_acc;
136
 
            exp_acc += (exps_2[exps[i]] /*- 2*/);
137
 
            dest[j++] = exp_acc;
138
 
            dest[j++] = exp_acc;
139
 
            dest[j++] = exp_acc;
140
 
            dest[j++] = exp_acc;
141
 
            exp_acc += (exps_3[exps[i]] /*- 2*/);
142
 
            dest[j++] = exp_acc;
143
 
            dest[j++] = exp_acc;
144
 
            dest[j++] = exp_acc;
145
 
            dest[j++] = exp_acc;
146
 
        }
147
 
        break;
148
 
    }
149
 
 
150
 
    return 0;
151
 
}
152