/src/mpg123/src/libmpg123/synth_ntom.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | |
3 | | |
4 | | This header is used multiple times to create different variants of this function. |
5 | | Hint: MONO_NAME, MONO2STEREO_NAME, SYNTH_NAME and SAMPLE_T as well as WRITE_SAMPLE do vary. |
6 | | |
7 | | copyright 1995-2008 by the mpg123 project - free software under the terms of the LGPL 2.1 |
8 | | see COPYING and AUTHORS files in distribution or http://mpg123.org |
9 | | initially written by Michael Hipp, generalized by Thomas Orgis |
10 | | |
11 | | Well, this is very simple resampling... you may or may not like what you hear. |
12 | | But it's cheap. |
13 | | But still, we don't implement a non-autoincrement version of this one. |
14 | | */ |
15 | | |
16 | | /* Note: These mono functions would also work generically, |
17 | | it's just that they need a runtime calculation for the conversion loop... |
18 | | The fixed XtoY functions have the chance for loop unrolling... */ |
19 | | |
20 | | int MONO_NAME(real *bandPtr, mpg123_handle *fr) |
21 | 0 | { |
22 | 0 | SAMPLE_T samples_tmp[8*64]; |
23 | 0 | SAMPLE_T *tmp1 = samples_tmp; |
24 | 0 | size_t i; |
25 | 0 | int ret; |
26 | |
|
27 | 0 | size_t pnt = fr->buffer.fill; |
28 | 0 | unsigned char *samples = fr->buffer.data; |
29 | 0 | fr->buffer.data = (unsigned char*) samples_tmp; |
30 | 0 | fr->buffer.fill = 0; |
31 | 0 | ret = SYNTH_NAME(bandPtr, 0, fr, 1); |
32 | 0 | fr->buffer.data = samples; |
33 | |
|
34 | 0 | samples += pnt; |
35 | 0 | for(i=0;i<(fr->buffer.fill/(2*sizeof(SAMPLE_T)));i++) |
36 | 0 | { |
37 | 0 | *( (SAMPLE_T *)samples) = *tmp1; |
38 | 0 | samples += sizeof(SAMPLE_T); |
39 | 0 | tmp1 += 2; |
40 | 0 | } |
41 | 0 | fr->buffer.fill = pnt + (fr->buffer.fill/2); |
42 | |
|
43 | 0 | return ret; |
44 | 0 | } Unexecuted instantiation: INT123_synth_ntom_8bit_mono Unexecuted instantiation: INT123_synth_ntom_mono Unexecuted instantiation: INT123_synth_ntom_s32_mono Unexecuted instantiation: INT123_synth_ntom_real_mono |
45 | | |
46 | | |
47 | | int MONO2STEREO_NAME(real *bandPtr, mpg123_handle *fr) |
48 | 0 | { |
49 | 0 | size_t i; |
50 | 0 | int ret; |
51 | 0 | size_t pnt1 = fr->buffer.fill; |
52 | 0 | unsigned char *samples = fr->buffer.data + pnt1; |
53 | |
|
54 | 0 | ret = SYNTH_NAME(bandPtr, 0, fr, 1); |
55 | |
|
56 | 0 | for(i=0;i<((fr->buffer.fill-pnt1)/(2*sizeof(SAMPLE_T)));i++) |
57 | 0 | { |
58 | 0 | ((SAMPLE_T *)samples)[1] = ((SAMPLE_T *)samples)[0]; |
59 | 0 | samples+=2*sizeof(SAMPLE_T); |
60 | 0 | } |
61 | |
|
62 | 0 | return ret; |
63 | 0 | } Unexecuted instantiation: INT123_synth_ntom_8bit_m2s Unexecuted instantiation: INT123_synth_ntom_m2s Unexecuted instantiation: INT123_synth_ntom_s32_m2s Unexecuted instantiation: INT123_synth_ntom_real_m2s |
64 | | |
65 | | |
66 | | int SYNTH_NAME(real *bandPtr,int channel, mpg123_handle *fr, int final) |
67 | 0 | { |
68 | 0 | static const int step = 2; |
69 | 0 | SAMPLE_T *samples = (SAMPLE_T *) (fr->buffer.data + fr->buffer.fill); |
70 | |
|
71 | 0 | real *b0, **buf; /* (*buf)[0x110]; */ |
72 | 0 | int clip = 0; |
73 | 0 | int bo1; |
74 | 0 | int ntom; |
75 | 0 | #ifndef NO_EQUALIZER |
76 | 0 | if(fr->have_eq_settings) INT123_do_equalizer(bandPtr,channel,fr->equalizer); |
77 | 0 | #endif |
78 | 0 | if(!channel) |
79 | 0 | { |
80 | 0 | fr->bo--; |
81 | 0 | fr->bo &= 0xf; |
82 | 0 | buf = fr->real_buffs[0]; |
83 | 0 | ntom = fr->INT123_ntom_val[1] = fr->INT123_ntom_val[0]; |
84 | 0 | } |
85 | 0 | else |
86 | 0 | { |
87 | 0 | samples++; |
88 | 0 | buf = fr->real_buffs[1]; |
89 | 0 | ntom = fr->INT123_ntom_val[1]; |
90 | 0 | } |
91 | |
|
92 | 0 | if(fr->bo & 0x1) |
93 | 0 | { |
94 | 0 | b0 = buf[0]; |
95 | 0 | bo1 = fr->bo; |
96 | 0 | INT123_dct64(buf[1]+((fr->bo+1)&0xf),buf[0]+fr->bo,bandPtr); |
97 | 0 | } |
98 | 0 | else |
99 | 0 | { |
100 | 0 | b0 = buf[1]; |
101 | 0 | bo1 = fr->bo+1; |
102 | 0 | INT123_dct64(buf[0]+fr->bo,buf[1]+fr->bo+1,bandPtr); |
103 | 0 | } |
104 | |
|
105 | 0 | { |
106 | 0 | register int j; |
107 | 0 | real *window = fr->decwin + 16 - bo1; |
108 | |
|
109 | 0 | for (j=16;j;j--,window+=0x10) |
110 | 0 | { |
111 | 0 | real sum; |
112 | |
|
113 | 0 | ntom += fr->ntom_step; |
114 | 0 | if(ntom < NTOM_MUL) |
115 | 0 | { |
116 | 0 | window += 16; |
117 | 0 | b0 += 16; |
118 | 0 | continue; |
119 | 0 | } |
120 | | |
121 | 0 | sum = REAL_MUL_SYNTH(*window++, *b0++); |
122 | 0 | sum -= REAL_MUL_SYNTH(*window++, *b0++); |
123 | 0 | sum += REAL_MUL_SYNTH(*window++, *b0++); |
124 | 0 | sum -= REAL_MUL_SYNTH(*window++, *b0++); |
125 | 0 | sum += REAL_MUL_SYNTH(*window++, *b0++); |
126 | 0 | sum -= REAL_MUL_SYNTH(*window++, *b0++); |
127 | 0 | sum += REAL_MUL_SYNTH(*window++, *b0++); |
128 | 0 | sum -= REAL_MUL_SYNTH(*window++, *b0++); |
129 | 0 | sum += REAL_MUL_SYNTH(*window++, *b0++); |
130 | 0 | sum -= REAL_MUL_SYNTH(*window++, *b0++); |
131 | 0 | sum += REAL_MUL_SYNTH(*window++, *b0++); |
132 | 0 | sum -= REAL_MUL_SYNTH(*window++, *b0++); |
133 | 0 | sum += REAL_MUL_SYNTH(*window++, *b0++); |
134 | 0 | sum -= REAL_MUL_SYNTH(*window++, *b0++); |
135 | 0 | sum += REAL_MUL_SYNTH(*window++, *b0++); |
136 | 0 | sum -= REAL_MUL_SYNTH(*window++, *b0++); |
137 | |
|
138 | 0 | while(ntom >= NTOM_MUL) |
139 | 0 | { |
140 | 0 | WRITE_SAMPLE(samples,sum,clip); |
141 | 0 | samples += step; |
142 | 0 | ntom -= NTOM_MUL; |
143 | 0 | } |
144 | 0 | } |
145 | |
|
146 | 0 | ntom += fr->ntom_step; |
147 | 0 | if(ntom >= NTOM_MUL) |
148 | 0 | { |
149 | 0 | real sum; |
150 | 0 | sum = REAL_MUL_SYNTH(window[0x0], b0[0x0]); |
151 | 0 | sum += REAL_MUL_SYNTH(window[0x2], b0[0x2]); |
152 | 0 | sum += REAL_MUL_SYNTH(window[0x4], b0[0x4]); |
153 | 0 | sum += REAL_MUL_SYNTH(window[0x6], b0[0x6]); |
154 | 0 | sum += REAL_MUL_SYNTH(window[0x8], b0[0x8]); |
155 | 0 | sum += REAL_MUL_SYNTH(window[0xA], b0[0xA]); |
156 | 0 | sum += REAL_MUL_SYNTH(window[0xC], b0[0xC]); |
157 | 0 | sum += REAL_MUL_SYNTH(window[0xE], b0[0xE]); |
158 | |
|
159 | 0 | while(ntom >= NTOM_MUL) |
160 | 0 | { |
161 | 0 | WRITE_SAMPLE(samples,sum,clip); |
162 | 0 | samples += step; |
163 | 0 | ntom -= NTOM_MUL; |
164 | 0 | } |
165 | 0 | } |
166 | |
|
167 | 0 | b0-=0x10,window-=0x20; |
168 | 0 | window += bo1<<1; |
169 | |
|
170 | 0 | for (j=15;j;j--,b0-=0x20,window-=0x10) |
171 | 0 | { |
172 | 0 | real sum; |
173 | |
|
174 | 0 | ntom += fr->ntom_step; |
175 | 0 | if(ntom < NTOM_MUL) |
176 | 0 | { |
177 | 0 | window -= 16; |
178 | 0 | b0 += 16; |
179 | 0 | continue; |
180 | 0 | } |
181 | | |
182 | 0 | sum = REAL_MUL_SYNTH(-*(--window), *b0++); |
183 | 0 | sum -= REAL_MUL_SYNTH(*(--window), *b0++); |
184 | 0 | sum -= REAL_MUL_SYNTH(*(--window), *b0++); |
185 | 0 | sum -= REAL_MUL_SYNTH(*(--window), *b0++); |
186 | 0 | sum -= REAL_MUL_SYNTH(*(--window), *b0++); |
187 | 0 | sum -= REAL_MUL_SYNTH(*(--window), *b0++); |
188 | 0 | sum -= REAL_MUL_SYNTH(*(--window), *b0++); |
189 | 0 | sum -= REAL_MUL_SYNTH(*(--window), *b0++); |
190 | 0 | sum -= REAL_MUL_SYNTH(*(--window), *b0++); |
191 | 0 | sum -= REAL_MUL_SYNTH(*(--window), *b0++); |
192 | 0 | sum -= REAL_MUL_SYNTH(*(--window), *b0++); |
193 | 0 | sum -= REAL_MUL_SYNTH(*(--window), *b0++); |
194 | 0 | sum -= REAL_MUL_SYNTH(*(--window), *b0++); |
195 | 0 | sum -= REAL_MUL_SYNTH(*(--window), *b0++); |
196 | 0 | sum -= REAL_MUL_SYNTH(*(--window), *b0++); |
197 | 0 | sum -= REAL_MUL_SYNTH(*(--window), *b0++); |
198 | |
|
199 | 0 | while(ntom >= NTOM_MUL) |
200 | 0 | { |
201 | 0 | WRITE_SAMPLE(samples,sum,clip); |
202 | 0 | samples += step; |
203 | 0 | ntom -= NTOM_MUL; |
204 | 0 | } |
205 | 0 | } |
206 | 0 | } |
207 | |
|
208 | 0 | fr->INT123_ntom_val[channel] = ntom; |
209 | 0 | if(final) fr->buffer.fill = ((unsigned char *) samples - fr->buffer.data - (channel ? sizeof(SAMPLE_T) : 0)); |
210 | |
|
211 | 0 | return clip; |
212 | 0 | } Unexecuted instantiation: INT123_synth_ntom_8bit Unexecuted instantiation: INT123_synth_ntom Unexecuted instantiation: INT123_synth_ntom_s32 Unexecuted instantiation: INT123_synth_ntom_real |
213 | | |