Mercurial > mplayer.hg
annotate libfaad2/ssr.c @ 14512:68e5e1122a91
sync:
1.854: better vf_lavcdeint description
1.855: Force linebreak (png)
author | kraymer |
---|---|
date | Sun, 16 Jan 2005 11:41:39 +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: ssr.c,v 1.3 2004/06/02 22:59:03 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 #ifdef SSR_DEC | |
34 | |
35 #include "syntax.h" | |
36 #include "filtbank.h" | |
37 #include "ssr.h" | |
38 #include "ssr_fb.h" | |
39 | |
40 void ssr_decode(ssr_info *ssr, fb_info *fb, uint8_t window_sequence, | |
41 uint8_t window_shape, uint8_t window_shape_prev, | |
42 real_t *freq_in, real_t *time_out, real_t *overlap, | |
43 real_t ipqf_buffer[SSR_BANDS][96/4], | |
44 real_t *prev_fmd, uint16_t frame_len) | |
45 { | |
46 uint8_t band; | |
47 uint16_t ssr_frame_len = frame_len/SSR_BANDS; | |
12527 | 48 real_t time_tmp[2048] = {0}; |
49 real_t output[1024] = {0}; | |
10725 | 50 |
51 for (band = 0; band < SSR_BANDS; band++) | |
52 { | |
53 int16_t j; | |
54 | |
55 /* uneven bands have inverted frequency scale */ | |
56 if (band == 1 || band == 3) | |
57 { | |
58 for (j = 0; j < ssr_frame_len/2; j++) | |
59 { | |
60 real_t tmp; | |
61 tmp = freq_in[j + ssr_frame_len*band]; | |
62 freq_in[j + ssr_frame_len*band] = | |
63 freq_in[ssr_frame_len - j - 1 + ssr_frame_len*band]; | |
64 freq_in[ssr_frame_len - j - 1 + ssr_frame_len*band] = tmp; | |
65 } | |
66 } | |
67 | |
68 /* non-overlapping inverse filterbank for SSR */ | |
69 ssr_ifilter_bank(fb, window_sequence, window_shape, window_shape_prev, | |
70 freq_in + band*ssr_frame_len, time_tmp + band*ssr_frame_len, | |
71 ssr_frame_len); | |
72 | |
73 /* gain control */ | |
74 ssr_gain_control(ssr, time_tmp, output, overlap, prev_fmd, | |
75 band, window_sequence, ssr_frame_len); | |
76 } | |
77 | |
78 /* inverse pqf to bring subbands together again */ | |
79 ssr_ipqf(ssr, output, time_out, ipqf_buffer, frame_len, SSR_BANDS); | |
80 } | |
81 | |
82 static void ssr_gain_control(ssr_info *ssr, real_t *data, real_t *output, | |
83 real_t *overlap, real_t *prev_fmd, uint8_t band, | |
84 uint8_t window_sequence, uint16_t frame_len) | |
85 { | |
86 uint16_t i; | |
87 real_t gc_function[2*1024/SSR_BANDS]; | |
88 | |
89 if (window_sequence != EIGHT_SHORT_SEQUENCE) | |
90 { | |
91 ssr_gc_function(ssr, &prev_fmd[band * frame_len*2], | |
12527 | 92 gc_function, window_sequence, band, frame_len); |
10725 | 93 |
94 for (i = 0; i < frame_len*2; i++) | |
95 data[band * frame_len*2 + i] *= gc_function[i]; | |
96 for (i = 0; i < frame_len; i++) | |
97 { | |
98 output[band*frame_len + i] = overlap[band*frame_len + i] + | |
99 data[band*frame_len*2 + i]; | |
100 } | |
101 for (i = 0; i < frame_len; i++) | |
102 { | |
103 overlap[band*frame_len + i] = | |
104 data[band*frame_len*2 + frame_len + i]; | |
105 } | |
106 } else { | |
107 uint8_t w; | |
108 for (w = 0; w < 8; w++) | |
109 { | |
110 uint16_t frame_len8 = frame_len/8; | |
111 uint16_t frame_len16 = frame_len/16; | |
112 | |
113 ssr_gc_function(ssr, &prev_fmd[band*frame_len*2 + w*frame_len*2/8], | |
114 gc_function, window_sequence, frame_len); | |
115 | |
116 for (i = 0; i < frame_len8*2; i++) | |
117 data[band*frame_len*2 + w*frame_len8*2+i] *= gc_function[i]; | |
118 for (i = 0; i < frame_len8; i++) | |
119 { | |
120 overlap[band*frame_len + i + 7*frame_len16 + w*frame_len8] += | |
121 data[band*frame_len*2 + 2*w*frame_len8 + i]; | |
122 } | |
123 for (i = 0; i < frame_len8; i++) | |
124 { | |
125 overlap[band*frame_len + i + 7*frame_len16 + (w+1)*frame_len8] = | |
126 data[band*frame_len*2 + 2*w*frame_len8 + frame_len8 + i]; | |
127 } | |
128 } | |
129 for (i = 0; i < frame_len; i++) | |
130 output[band*frame_len + i] = overlap[band*frame_len + i]; | |
131 for (i = 0; i < frame_len; i++) | |
132 overlap[band*frame_len + i] = overlap[band*frame_len + i + frame_len]; | |
133 } | |
134 } | |
135 | |
136 static void ssr_gc_function(ssr_info *ssr, real_t *prev_fmd, | |
137 real_t *gc_function, uint8_t window_sequence, | |
12527 | 138 uint8_t band, uint16_t frame_len) |
10725 | 139 { |
140 uint16_t i; | |
141 uint16_t len_area1, len_area2; | |
142 int32_t aloc[10]; | |
143 real_t alev[10]; | |
144 | |
145 switch (window_sequence) | |
146 { | |
147 case ONLY_LONG_SEQUENCE: | |
148 len_area1 = frame_len/SSR_BANDS; | |
149 len_area2 = 0; | |
150 break; | |
151 case LONG_START_SEQUENCE: | |
152 len_area1 = (frame_len/SSR_BANDS)*7/32; | |
153 len_area2 = (frame_len/SSR_BANDS)/16; | |
154 break; | |
155 case EIGHT_SHORT_SEQUENCE: | |
156 len_area1 = (frame_len/8)/SSR_BANDS; | |
157 len_area2 = 0; | |
158 break; | |
159 case LONG_STOP_SEQUENCE: | |
160 len_area1 = (frame_len/SSR_BANDS); | |
161 len_area2 = 0; | |
162 break; | |
163 } | |
164 | |
165 /* decode bitstream information */ | |
166 | |
167 /* build array M */ | |
168 | |
169 | |
170 for (i = 0; i < frame_len*2; i++) | |
171 gc_function[i] = 1; | |
172 } | |
173 | |
174 #endif |