Mercurial > mplayer.hg
annotate libfaad2/drc.c @ 14242:4eaf67d3fa8f
Demuxer was fixed, so do not skip the first frame anymore
author | reimar |
---|---|
date | Sun, 26 Dec 2004 11:54:01 +0000 |
parents | d81145997036 |
children | 2ae5ab4331ca |
rev | line source |
---|---|
10725 | 1 /* |
2 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding | |
12527 | 3 ** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com |
10725 | 4 ** |
5 ** This program is free software; you can redistribute it and/or modify | |
6 ** it under the terms of the GNU General Public License as published by | |
7 ** the Free Software Foundation; either version 2 of the License, or | |
8 ** (at your option) any later version. | |
9 ** | |
10 ** This program is distributed in the hope that it will be useful, | |
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 ** GNU General Public License for more details. | |
14 ** | |
15 ** You should have received a copy of the GNU General Public License | |
16 ** along with this program; if not, write to the Free Software | |
17 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
18 ** | |
19 ** Any non-GPL usage of this software or parts of this software is strictly | |
20 ** forbidden. | |
21 ** | |
22 ** Commercial non-GPL licensing of this software is possible. | |
23 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | |
24 ** | |
12625
d81145997036
More information about modifications to comply more closely with GPL 2a.
diego
parents:
12527
diff
changeset
|
25 ** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30 |
d81145997036
More information about modifications to comply more closely with GPL 2a.
diego
parents:
12527
diff
changeset
|
26 ** $Id: drc.c,v 1.3 2004/06/02 22:59:02 diego Exp $ |
d81145997036
More information about modifications to comply more closely with GPL 2a.
diego
parents:
12527
diff
changeset
|
27 ** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/ |
10725 | 28 **/ |
29 | |
30 #include "common.h" | |
31 #include "structs.h" | |
32 | |
33 #include <stdlib.h> | |
34 #include <string.h> | |
35 #include "syntax.h" | |
36 #include "drc.h" | |
37 | |
38 drc_info *drc_init(real_t cut, real_t boost) | |
39 { | |
12527 | 40 drc_info *drc = (drc_info*)faad_malloc(sizeof(drc_info)); |
10725 | 41 memset(drc, 0, sizeof(drc_info)); |
42 | |
43 drc->ctrl1 = cut; | |
44 drc->ctrl2 = boost; | |
45 | |
46 drc->num_bands = 1; | |
47 drc->band_top[0] = 1024/4 - 1; | |
48 drc->dyn_rng_sgn[0] = 1; | |
49 drc->dyn_rng_ctl[0] = 0; | |
50 | |
51 return drc; | |
52 } | |
53 | |
54 void drc_end(drc_info *drc) | |
55 { | |
12527 | 56 if (drc) faad_free(drc); |
10725 | 57 } |
58 | |
59 #ifdef FIXED_POINT | |
60 static real_t drc_pow2_table[] = | |
61 { | |
62 COEF_CONST(0.5146511183), | |
63 COEF_CONST(0.5297315472), | |
64 COEF_CONST(0.5452538663), | |
65 COEF_CONST(0.5612310242), | |
66 COEF_CONST(0.5776763484), | |
67 COEF_CONST(0.5946035575), | |
68 COEF_CONST(0.6120267717), | |
69 COEF_CONST(0.6299605249), | |
70 COEF_CONST(0.6484197773), | |
71 COEF_CONST(0.6674199271), | |
72 COEF_CONST(0.6869768237), | |
73 COEF_CONST(0.7071067812), | |
74 COEF_CONST(0.7278265914), | |
75 COEF_CONST(0.7491535384), | |
76 COEF_CONST(0.7711054127), | |
77 COEF_CONST(0.7937005260), | |
78 COEF_CONST(0.8169577266), | |
79 COEF_CONST(0.8408964153), | |
80 COEF_CONST(0.8655365610), | |
81 COEF_CONST(0.8908987181), | |
82 COEF_CONST(0.9170040432), | |
83 COEF_CONST(0.9438743127), | |
84 COEF_CONST(0.9715319412), | |
85 COEF_CONST(1.0000000000), | |
86 COEF_CONST(1.0293022366), | |
87 COEF_CONST(1.0594630944), | |
88 COEF_CONST(1.0905077327), | |
89 COEF_CONST(1.1224620483), | |
90 COEF_CONST(1.1553526969), | |
91 COEF_CONST(1.1892071150), | |
92 COEF_CONST(1.2240535433), | |
93 COEF_CONST(1.2599210499), | |
94 COEF_CONST(1.2968395547), | |
95 COEF_CONST(1.3348398542), | |
96 COEF_CONST(1.3739536475), | |
97 COEF_CONST(1.4142135624), | |
98 COEF_CONST(1.4556531828), | |
99 COEF_CONST(1.4983070769), | |
100 COEF_CONST(1.5422108254), | |
101 COEF_CONST(1.5874010520), | |
102 COEF_CONST(1.6339154532), | |
103 COEF_CONST(1.6817928305), | |
104 COEF_CONST(1.7310731220), | |
105 COEF_CONST(1.7817974363), | |
106 COEF_CONST(1.8340080864), | |
107 COEF_CONST(1.8877486254), | |
108 COEF_CONST(1.9430638823) | |
109 }; | |
110 #endif | |
111 | |
112 void drc_decode(drc_info *drc, real_t *spec) | |
113 { | |
114 uint16_t i, bd, top; | |
115 #ifdef FIXED_POINT | |
116 int32_t exp, frac; | |
117 #else | |
118 real_t factor, exp; | |
119 #endif | |
120 uint16_t bottom = 0; | |
121 | |
122 if (drc->num_bands == 1) | |
123 drc->band_top[0] = 1024/4 - 1; | |
124 | |
125 for (bd = 0; bd < drc->num_bands; bd++) | |
126 { | |
127 top = 4 * (drc->band_top[bd] + 1); | |
128 | |
129 #ifndef FIXED_POINT | |
130 /* Decode DRC gain factor */ | |
131 if (drc->dyn_rng_sgn[bd]) /* compress */ | |
10989 | 132 exp = -drc->ctrl1 * (drc->dyn_rng_ctl[bd] - (DRC_REF_LEVEL - drc->prog_ref_level))/REAL_CONST(24.0); |
10725 | 133 else /* boost */ |
10989 | 134 exp = drc->ctrl2 * (drc->dyn_rng_ctl[bd] - (DRC_REF_LEVEL - drc->prog_ref_level))/REAL_CONST(24.0); |
10725 | 135 factor = (real_t)pow(2.0, exp); |
136 | |
137 /* Apply gain factor */ | |
138 for (i = bottom; i < top; i++) | |
139 spec[i] *= factor; | |
140 #else | |
141 /* Decode DRC gain factor */ | |
142 if (drc->dyn_rng_sgn[bd]) /* compress */ | |
143 { | |
144 exp = -1 * (drc->dyn_rng_ctl[bd] - (DRC_REF_LEVEL - drc->prog_ref_level))/ 24; | |
145 frac = -1 * (drc->dyn_rng_ctl[bd] - (DRC_REF_LEVEL - drc->prog_ref_level)) % 24; | |
146 } else { /* boost */ | |
147 exp = (drc->dyn_rng_ctl[bd] - (DRC_REF_LEVEL - drc->prog_ref_level))/ 24; | |
148 frac = (drc->dyn_rng_ctl[bd] - (DRC_REF_LEVEL - drc->prog_ref_level)) % 24; | |
149 } | |
150 | |
151 /* Apply gain factor */ | |
152 if (exp < 0) | |
153 { | |
154 for (i = bottom; i < top; i++) | |
155 { | |
156 spec[i] >>= -exp; | |
157 if (frac) | |
12527 | 158 spec[i] = MUL_R(spec[i],drc_pow2_table[frac+23]); |
10725 | 159 } |
160 } else { | |
161 for (i = bottom; i < top; i++) | |
162 { | |
163 spec[i] <<= exp; | |
164 if (frac) | |
12527 | 165 spec[i] = MUL_R(spec[i],drc_pow2_table[frac+23]); |
10725 | 166 } |
167 } | |
168 #endif | |
169 | |
170 bottom = top; | |
171 } | |
172 } |