Commit | Line | Data |
---|---|---|
60203130 JR |
1 | /* |
2 | * E-AC-3 decoder | |
3 | * Copyright (c) 2007 Bartlomiej Wolowiec <bartek.wolowiec@gmail.com> | |
4 | * Copyright (c) 2008 Justin Ruggles | |
5 | * | |
6 | * This file is part of FFmpeg. | |
7 | * | |
8 | * FFmpeg is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU General Public | |
10 | * License as published by the Free Software Foundation; either | |
11 | * version 2 of the License, or (at your option) any later version. | |
12 | * | |
13 | * FFmpeg is distributed in the hope that it will be useful, | |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 | * General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU General Public | |
19 | * License along with FFmpeg; if not, write to the Free Software | |
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
21 | */ | |
22 | ||
23 | #include "avcodec.h" | |
24 | #include "ac3.h" | |
25 | #include "ac3_parser.h" | |
26 | #include "ac3dec.h" | |
27 | #include "ac3dec_data.h" | |
28 | ||
29 | /** gain adaptive quantization mode */ | |
30 | typedef enum { | |
31 | EAC3_GAQ_NO =0, | |
32 | EAC3_GAQ_12, | |
33 | EAC3_GAQ_14, | |
34 | EAC3_GAQ_124 | |
35 | } EAC3GaqMode; | |
36 | ||
37 | #define EAC3_SR_CODE_REDUCED 3 | |
38 | ||
39 | /** lrint(M_SQRT2*cos(2*M_PI/12)*(1<<23)) */ | |
40 | #define COEFF_0 10273905LL | |
41 | ||
42 | /** lrint(M_SQRT2*cos(0*M_PI/12)*(1<<23)) = lrint(M_SQRT2*(1<<23)) */ | |
43 | #define COEFF_1 11863283LL | |
44 | ||
45 | /** lrint(M_SQRT2*cos(5*M_PI/12)*(1<<23)) */ | |
46 | #define COEFF_2 3070444LL | |
47 | ||
48 | /** | |
49 | * Calculate 6-point IDCT of the pre-mantissas. | |
50 | * All calculations are 24-bit fixed-point. | |
51 | */ | |
52 | static void idct6(int pre_mant[6]) | |
53 | { | |
54 | int tmp; | |
55 | int even0, even1, even2, odd0, odd1, odd2; | |
56 | ||
57 | odd1 = pre_mant[1] - pre_mant[3] - pre_mant[5]; | |
58 | ||
59 | even2 = ( pre_mant[2] * COEFF_0) >> 23; | |
60 | tmp = ( pre_mant[4] * COEFF_1) >> 23; | |
61 | odd0 = ((pre_mant[1] + pre_mant[5]) * COEFF_2) >> 23; | |
62 | ||
63 | even0 = pre_mant[0] + (tmp >> 1); | |
64 | even1 = pre_mant[0] - tmp; | |
65 | ||
66 | tmp = even0; | |
67 | even0 = tmp + even2; | |
68 | even2 = tmp - even2; | |
69 | ||
70 | tmp = odd0; | |
71 | odd0 = tmp + pre_mant[1] + pre_mant[3]; | |
72 | odd2 = tmp + pre_mant[5] - pre_mant[3]; | |
73 | ||
74 | pre_mant[0] = even0 + odd0; | |
75 | pre_mant[1] = even1 + odd1; | |
76 | pre_mant[2] = even2 + odd2; | |
77 | pre_mant[3] = even2 - odd2; | |
78 | pre_mant[4] = even1 - odd1; | |
79 | pre_mant[5] = even0 - odd0; | |
80 | } |