annotate eac3dec.c @ 7679:e27395cc7321 libavcodec

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