Mercurial > mplayer.hg
annotate libfaad2/ssr.c @ 16528:c1267de1d7d9
Make frameno.avi not turn on by default. this is deprecated and this entire
feature should be removed anyway. manpage update in a bit...
author | ods15 |
---|---|
date | Mon, 19 Sep 2005 19:23:38 +0000 |
parents | 2ae5ab4331ca |
children | 59b6fa5b4201 |
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 ** | |
14727
2ae5ab4331ca
Remove modification notice from files that have not been locally modified.
diego
parents:
12625
diff
changeset
|
25 ** $Id: ssr.c,v 1.13 2004/02/26 09:29:28 menno Exp $ |
10725 | 26 **/ |
27 | |
28 #include "common.h" | |
29 #include "structs.h" | |
30 | |
31 #ifdef SSR_DEC | |
32 | |
33 #include "syntax.h" | |
34 #include "filtbank.h" | |
35 #include "ssr.h" | |
36 #include "ssr_fb.h" | |
37 | |
38 void ssr_decode(ssr_info *ssr, fb_info *fb, uint8_t window_sequence, | |
39 uint8_t window_shape, uint8_t window_shape_prev, | |
40 real_t *freq_in, real_t *time_out, real_t *overlap, | |
41 real_t ipqf_buffer[SSR_BANDS][96/4], | |
42 real_t *prev_fmd, uint16_t frame_len) | |
43 { | |
44 uint8_t band; | |
45 uint16_t ssr_frame_len = frame_len/SSR_BANDS; | |
12527 | 46 real_t time_tmp[2048] = {0}; |
47 real_t output[1024] = {0}; | |
10725 | 48 |
49 for (band = 0; band < SSR_BANDS; band++) | |
50 { | |
51 int16_t j; | |
52 | |
53 /* uneven bands have inverted frequency scale */ | |
54 if (band == 1 || band == 3) | |
55 { | |
56 for (j = 0; j < ssr_frame_len/2; j++) | |
57 { | |
58 real_t tmp; | |
59 tmp = freq_in[j + ssr_frame_len*band]; | |
60 freq_in[j + ssr_frame_len*band] = | |
61 freq_in[ssr_frame_len - j - 1 + ssr_frame_len*band]; | |
62 freq_in[ssr_frame_len - j - 1 + ssr_frame_len*band] = tmp; | |
63 } | |
64 } | |
65 | |
66 /* non-overlapping inverse filterbank for SSR */ | |
67 ssr_ifilter_bank(fb, window_sequence, window_shape, window_shape_prev, | |
68 freq_in + band*ssr_frame_len, time_tmp + band*ssr_frame_len, | |
69 ssr_frame_len); | |
70 | |
71 /* gain control */ | |
72 ssr_gain_control(ssr, time_tmp, output, overlap, prev_fmd, | |
73 band, window_sequence, ssr_frame_len); | |
74 } | |
75 | |
76 /* inverse pqf to bring subbands together again */ | |
77 ssr_ipqf(ssr, output, time_out, ipqf_buffer, frame_len, SSR_BANDS); | |
78 } | |
79 | |
80 static void ssr_gain_control(ssr_info *ssr, real_t *data, real_t *output, | |
81 real_t *overlap, real_t *prev_fmd, uint8_t band, | |
82 uint8_t window_sequence, uint16_t frame_len) | |
83 { | |
84 uint16_t i; | |
85 real_t gc_function[2*1024/SSR_BANDS]; | |
86 | |
87 if (window_sequence != EIGHT_SHORT_SEQUENCE) | |
88 { | |
89 ssr_gc_function(ssr, &prev_fmd[band * frame_len*2], | |
12527 | 90 gc_function, window_sequence, band, frame_len); |
10725 | 91 |
92 for (i = 0; i < frame_len*2; i++) | |
93 data[band * frame_len*2 + i] *= gc_function[i]; | |
94 for (i = 0; i < frame_len; i++) | |
95 { | |
96 output[band*frame_len + i] = overlap[band*frame_len + i] + | |
97 data[band*frame_len*2 + i]; | |
98 } | |
99 for (i = 0; i < frame_len; i++) | |
100 { | |
101 overlap[band*frame_len + i] = | |
102 data[band*frame_len*2 + frame_len + i]; | |
103 } | |
104 } else { | |
105 uint8_t w; | |
106 for (w = 0; w < 8; w++) | |
107 { | |
108 uint16_t frame_len8 = frame_len/8; | |
109 uint16_t frame_len16 = frame_len/16; | |
110 | |
111 ssr_gc_function(ssr, &prev_fmd[band*frame_len*2 + w*frame_len*2/8], | |
112 gc_function, window_sequence, frame_len); | |
113 | |
114 for (i = 0; i < frame_len8*2; i++) | |
115 data[band*frame_len*2 + w*frame_len8*2+i] *= gc_function[i]; | |
116 for (i = 0; i < frame_len8; i++) | |
117 { | |
118 overlap[band*frame_len + i + 7*frame_len16 + w*frame_len8] += | |
119 data[band*frame_len*2 + 2*w*frame_len8 + i]; | |
120 } | |
121 for (i = 0; i < frame_len8; i++) | |
122 { | |
123 overlap[band*frame_len + i + 7*frame_len16 + (w+1)*frame_len8] = | |
124 data[band*frame_len*2 + 2*w*frame_len8 + frame_len8 + i]; | |
125 } | |
126 } | |
127 for (i = 0; i < frame_len; i++) | |
128 output[band*frame_len + i] = overlap[band*frame_len + i]; | |
129 for (i = 0; i < frame_len; i++) | |
130 overlap[band*frame_len + i] = overlap[band*frame_len + i + frame_len]; | |
131 } | |
132 } | |
133 | |
134 static void ssr_gc_function(ssr_info *ssr, real_t *prev_fmd, | |
135 real_t *gc_function, uint8_t window_sequence, | |
12527 | 136 uint8_t band, uint16_t frame_len) |
10725 | 137 { |
138 uint16_t i; | |
139 uint16_t len_area1, len_area2; | |
140 int32_t aloc[10]; | |
141 real_t alev[10]; | |
142 | |
143 switch (window_sequence) | |
144 { | |
145 case ONLY_LONG_SEQUENCE: | |
146 len_area1 = frame_len/SSR_BANDS; | |
147 len_area2 = 0; | |
148 break; | |
149 case LONG_START_SEQUENCE: | |
150 len_area1 = (frame_len/SSR_BANDS)*7/32; | |
151 len_area2 = (frame_len/SSR_BANDS)/16; | |
152 break; | |
153 case EIGHT_SHORT_SEQUENCE: | |
154 len_area1 = (frame_len/8)/SSR_BANDS; | |
155 len_area2 = 0; | |
156 break; | |
157 case LONG_STOP_SEQUENCE: | |
158 len_area1 = (frame_len/SSR_BANDS); | |
159 len_area2 = 0; | |
160 break; | |
161 } | |
162 | |
163 /* decode bitstream information */ | |
164 | |
165 /* build array M */ | |
166 | |
167 | |
168 for (i = 0; i < frame_len*2; i++) | |
169 gc_function[i] = 1; | |
170 } | |
171 | |
172 #endif |