corrade-vassal – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | vero | 1 | /* |
2 | * CVS identifier: |
||
3 | * |
||
4 | * $Id: AnWTFilterFloatLift9x7.java,v 1.18 2002/01/22 13:31:31 grosbois Exp $ |
||
5 | * |
||
6 | * Class: AnWTFilterFloatLift9x7 |
||
7 | * |
||
8 | * Description: An analyzing wavelet filter implementing the |
||
9 | * lifting 9x7 transform. |
||
10 | * |
||
11 | * |
||
12 | * |
||
13 | * COPYRIGHT: |
||
14 | * |
||
15 | * This software module was originally developed by Raphaël Grosbois and |
||
16 | * Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel |
||
17 | * Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David |
||
18 | * Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research |
||
19 | * Centre France S.A) in the course of development of the JPEG2000 |
||
20 | * standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This |
||
21 | * software module is an implementation of a part of the JPEG 2000 |
||
22 | * Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio |
||
23 | * Systems AB and Canon Research Centre France S.A (collectively JJ2000 |
||
24 | * Partners) agree not to assert against ISO/IEC and users of the JPEG |
||
25 | * 2000 Standard (Users) any of their rights under the copyright, not |
||
26 | * including other intellectual property rights, for this software module |
||
27 | * with respect to the usage by ISO/IEC and Users of this software module |
||
28 | * or modifications thereof for use in hardware or software products |
||
29 | * claiming conformance to the JPEG 2000 Standard. Those intending to use |
||
30 | * this software module in hardware or software products are advised that |
||
31 | * their use may infringe existing patents. The original developers of |
||
32 | * this software module, JJ2000 Partners and ISO/IEC assume no liability |
||
33 | * for use of this software module or modifications thereof. No license |
||
34 | * or right to this software module is granted for non JPEG 2000 Standard |
||
35 | * conforming products. JJ2000 Partners have full right to use this |
||
36 | * software module for his/her own purpose, assign or donate this |
||
37 | * software module to any third party and to inhibit third parties from |
||
38 | * using this software module for non JPEG 2000 Standard conforming |
||
39 | * products. This copyright notice must be included in all copies or |
||
40 | * derivative works of this software module. |
||
41 | * |
||
42 | * Copyright (c) 1999/2000 JJ2000 Partners. |
||
43 | * */ |
||
44 | using System; |
||
45 | using CSJ2K.j2k.wavelet; |
||
46 | using CSJ2K.j2k.image; |
||
47 | using CSJ2K.j2k; |
||
48 | using CSJ2K.j2k.codestream.writer; |
||
49 | namespace CSJ2K.j2k.wavelet.analysis |
||
50 | { |
||
51 | |||
52 | /// <summary> This class inherits from the analysis wavelet filter definition |
||
53 | /// for int data. It implements the forward wavelet transform |
||
54 | /// specifically for the 9x7 filter. The implementation is based on |
||
55 | /// the lifting scheme. |
||
56 | /// |
||
57 | /// <P>See the AnWTFilter class for details such as |
||
58 | /// normalization, how to split odd-length signals, etc. In particular, |
||
59 | /// this method assumes that the low-pass coefficient is computed first. |
||
60 | /// |
||
61 | /// </summary> |
||
62 | /// <seealso cref="AnWTFilter"> |
||
63 | /// </seealso> |
||
64 | /// <seealso cref="AnWTFilterFloat"> |
||
65 | /// |
||
66 | /// </seealso> |
||
67 | public class AnWTFilterFloatLift9x7:AnWTFilterFloat |
||
68 | { |
||
69 | /// <summary> Returns the negative support of the low-pass analysis |
||
70 | /// filter. That is the number of taps of the filter in the |
||
71 | /// negative direction. |
||
72 | /// |
||
73 | /// </summary> |
||
74 | /// <returns> 2 |
||
75 | /// |
||
76 | /// </returns> |
||
77 | override public int AnLowNegSupport |
||
78 | { |
||
79 | get |
||
80 | { |
||
81 | return 4; |
||
82 | } |
||
83 | |||
84 | } |
||
85 | /// <summary> Returns the positive support of the low-pass analysis |
||
86 | /// filter. That is the number of taps of the filter in the |
||
87 | /// negative direction. |
||
88 | /// |
||
89 | /// </summary> |
||
90 | /// <returns> The number of taps of the low-pass analysis filter in |
||
91 | /// the positive direction |
||
92 | /// |
||
93 | /// </returns> |
||
94 | override public int AnLowPosSupport |
||
95 | { |
||
96 | get |
||
97 | { |
||
98 | return 4; |
||
99 | } |
||
100 | |||
101 | } |
||
102 | /// <summary> Returns the negative support of the high-pass analysis |
||
103 | /// filter. That is the number of taps of the filter in the |
||
104 | /// negative direction. |
||
105 | /// |
||
106 | /// </summary> |
||
107 | /// <returns> The number of taps of the high-pass analysis filter in |
||
108 | /// the negative direction |
||
109 | /// |
||
110 | /// </returns> |
||
111 | override public int AnHighNegSupport |
||
112 | { |
||
113 | get |
||
114 | { |
||
115 | return 3; |
||
116 | } |
||
117 | |||
118 | } |
||
119 | /// <summary> Returns the positive support of the high-pass analysis |
||
120 | /// filter. That is the number of taps of the filter in the |
||
121 | /// negative direction. |
||
122 | /// |
||
123 | /// </summary> |
||
124 | /// <returns> The number of taps of the high-pass analysis filter in |
||
125 | /// the positive direction |
||
126 | /// |
||
127 | /// </returns> |
||
128 | override public int AnHighPosSupport |
||
129 | { |
||
130 | get |
||
131 | { |
||
132 | return 3; |
||
133 | } |
||
134 | |||
135 | } |
||
136 | /// <summary> Returns the negative support of the low-pass synthesis |
||
137 | /// filter. That is the number of taps of the filter in the |
||
138 | /// negative direction. |
||
139 | /// |
||
140 | /// <P>A MORE PRECISE DEFINITION IS NEEDED |
||
141 | /// |
||
142 | /// </summary> |
||
143 | /// <returns> The number of taps of the low-pass synthesis filter in |
||
144 | /// the negative direction |
||
145 | /// |
||
146 | /// </returns> |
||
147 | override public int SynLowNegSupport |
||
148 | { |
||
149 | get |
||
150 | { |
||
151 | return 3; |
||
152 | } |
||
153 | |||
154 | } |
||
155 | /// <summary> Returns the positive support of the low-pass synthesis |
||
156 | /// filter. That is the number of taps of the filter in the |
||
157 | /// negative direction. |
||
158 | /// |
||
159 | /// <P>A MORE PRECISE DEFINITION IS NEEDED |
||
160 | /// |
||
161 | /// </summary> |
||
162 | /// <returns> The number of taps of the low-pass synthesis filter in |
||
163 | /// the positive direction |
||
164 | /// |
||
165 | /// </returns> |
||
166 | override public int SynLowPosSupport |
||
167 | { |
||
168 | get |
||
169 | { |
||
170 | return 3; |
||
171 | } |
||
172 | |||
173 | } |
||
174 | /// <summary> Returns the negative support of the high-pass synthesis |
||
175 | /// filter. That is the number of taps of the filter in the |
||
176 | /// negative direction. |
||
177 | /// |
||
178 | /// <P>A MORE PRECISE DEFINITION IS NEEDED |
||
179 | /// |
||
180 | /// </summary> |
||
181 | /// <returns> The number of taps of the high-pass synthesis filter in |
||
182 | /// the negative direction |
||
183 | /// |
||
184 | /// </returns> |
||
185 | override public int SynHighNegSupport |
||
186 | { |
||
187 | get |
||
188 | { |
||
189 | return 4; |
||
190 | } |
||
191 | |||
192 | } |
||
193 | /// <summary> Returns the positive support of the high-pass synthesis |
||
194 | /// filter. That is the number of taps of the filter in the |
||
195 | /// negative direction. |
||
196 | /// |
||
197 | /// <P>A MORE PRECISE DEFINITION IS NEEDED |
||
198 | /// |
||
199 | /// </summary> |
||
200 | /// <returns> The number of taps of the high-pass synthesis filter in |
||
201 | /// the positive direction |
||
202 | /// |
||
203 | /// </returns> |
||
204 | override public int SynHighPosSupport |
||
205 | { |
||
206 | get |
||
207 | { |
||
208 | return 4; |
||
209 | } |
||
210 | |||
211 | } |
||
212 | /// <summary> Returns the implementation type of this filter, as defined in |
||
213 | /// this class, such as WT_FILTER_INT_LIFT, WT_FILTER_FLOAT_LIFT, |
||
214 | /// WT_FILTER_FLOAT_CONVOL. |
||
215 | /// |
||
216 | /// </summary> |
||
217 | /// <returns> WT_FILTER_INT_LIFT. |
||
218 | /// |
||
219 | /// </returns> |
||
220 | override public int ImplType |
||
221 | { |
||
222 | get |
||
223 | { |
||
224 | return CSJ2K.j2k.wavelet.WaveletFilter_Fields.WT_FILTER_FLOAT_LIFT; |
||
225 | } |
||
226 | |||
227 | } |
||
228 | /// <summary> Returns the reversibility of the filter. A filter is considered |
||
229 | /// reversible if it is suitable for lossless coding. |
||
230 | /// |
||
231 | /// </summary> |
||
232 | /// <returns> true since the 9x7 is reversible, provided the appropriate |
||
233 | /// rounding is performed. |
||
234 | /// |
||
235 | /// </returns> |
||
236 | override public bool Reversible |
||
237 | { |
||
238 | get |
||
239 | { |
||
240 | return false; |
||
241 | } |
||
242 | |||
243 | } |
||
244 | /// <summary> Returns the type of filter used according to the FilterTypes |
||
245 | /// interface(W9x7). |
||
246 | /// |
||
247 | /// </summary> |
||
248 | /// <seealso cref="FilterTypes"> |
||
249 | /// |
||
250 | /// </seealso> |
||
251 | /// <returns> The filter type. |
||
252 | /// |
||
253 | /// </returns> |
||
254 | override public int FilterType |
||
255 | { |
||
256 | get |
||
257 | { |
||
258 | return CSJ2K.j2k.wavelet.FilterTypes_Fields.W9X7; |
||
259 | } |
||
260 | |||
261 | } |
||
262 | |||
263 | /// <summary>The low-pass synthesis filter of the 9x7 wavelet transform </summary> |
||
264 | //UPGRADE_NOTE: Final was removed from the declaration of 'LPSynthesisFilter'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'" |
||
265 | private static readonly float[] LPSynthesisFilter = new float[]{- 0.091272f, - 0.057544f, 0.591272f, 1.115087f, 0.591272f, - 0.057544f, - 0.091272f}; |
||
266 | |||
267 | /// <summary>The high-pass synthesis filter of the 9x7 wavelet transform </summary> |
||
268 | //UPGRADE_NOTE: Final was removed from the declaration of 'HPSynthesisFilter'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'" |
||
269 | private static readonly float[] HPSynthesisFilter = new float[]{0.026749f, 0.016864f, - 0.078223f, - 0.266864f, 0.602949f, - 0.266864f, - 0.078223f, 0.016864f, 0.026749f}; |
||
270 | |||
271 | /// <summary>The value of the first lifting step coefficient </summary> |
||
272 | public const float ALPHA = - 1.586134342f; |
||
273 | |||
274 | /// <summary>The value of the second lifting step coefficient </summary> |
||
275 | public const float BETA = - 0.05298011854f; |
||
276 | |||
277 | /// <summary>The value of the third lifting step coefficient </summary> |
||
278 | public const float GAMMA = 0.8829110762f; |
||
279 | |||
280 | /// <summary>The value of the fourth lifting step coefficient </summary> |
||
281 | public const float DELTA = 0.4435068522f; |
||
282 | |||
283 | /// <summary>The value of the low-pass subband normalization factor </summary> |
||
284 | public const float KL = 0.8128930655f; |
||
285 | |||
286 | /// <summary>The value of the high-pass subband normalization factor </summary> |
||
287 | public const float KH = 1.230174106f; |
||
288 | |||
289 | /// <summary> An implementation of the analyze_lpf() method that works on int |
||
290 | /// data, for the forward 9x7 wavelet transform using the |
||
291 | /// lifting scheme. See the general description of the analyze_lpf() |
||
292 | /// method in the AnWTFilter class for more details. |
||
293 | /// |
||
294 | /// <P>The coefficients of the first lifting step are [ALPHA 1 ALPHA]. |
||
295 | /// |
||
296 | /// <P>The coefficients of the second lifting step are [BETA 1 BETA]. |
||
297 | /// |
||
298 | /// <P>The coefficients of the third lifting step are [GAMMA 1 GAMMA]. |
||
299 | /// |
||
300 | /// <P>The coefficients of the fourth lifting step are [DELTA 1 DELTA]. |
||
301 | /// |
||
302 | /// <P>The low-pass and high-pass subbands are normalized by respectively |
||
303 | /// a factor of KL and a factor of KH |
||
304 | /// |
||
305 | /// </summary> |
||
306 | /// <param name="inSig">This is the array that contains the input |
||
307 | /// signal. |
||
308 | /// |
||
309 | /// </param> |
||
310 | /// <param name="inOff">This is the index in inSig of the first sample to |
||
311 | /// filter. |
||
312 | /// |
||
313 | /// </param> |
||
314 | /// <param name="inLen">This is the number of samples in the input signal |
||
315 | /// to filter. |
||
316 | /// |
||
317 | /// </param> |
||
318 | /// <param name="inStep">This is the step, or interleave factor, of the |
||
319 | /// input signal samples in the inSig array. |
||
320 | /// |
||
321 | /// </param> |
||
322 | /// <param name="lowSig">This is the array where the low-pass output |
||
323 | /// signal is placed. |
||
324 | /// |
||
325 | /// </param> |
||
326 | /// <param name="lowOff">This is the index in lowSig of the element where |
||
327 | /// to put the first low-pass output sample. |
||
328 | /// |
||
329 | /// </param> |
||
330 | /// <param name="lowStep">This is the step, or interleave factor, of the |
||
331 | /// low-pass output samples in the lowSig array. |
||
332 | /// |
||
333 | /// </param> |
||
334 | /// <param name="highSig">This is the array where the high-pass output |
||
335 | /// signal is placed. |
||
336 | /// |
||
337 | /// </param> |
||
338 | /// <param name="highOff">This is the index in highSig of the element where |
||
339 | /// to put the first high-pass output sample. |
||
340 | /// |
||
341 | /// </param> |
||
342 | /// <param name="highStep">This is the step, or interleave factor, of the |
||
343 | /// high-pass output samples in the highSig array. |
||
344 | /// |
||
345 | /// </param> |
||
346 | public override void analyze_lpf(float[] inSig, int inOff, int inLen, int inStep, float[] lowSig, int lowOff, int lowStep, float[] highSig, int highOff, int highStep) |
||
347 | { |
||
348 | int i, maxi; |
||
349 | int iStep = 2 * inStep; //Subsampling in inSig |
||
350 | int ik; //Indexing inSig |
||
351 | int lk; //Indexing lowSig |
||
352 | int hk; //Indexing highSig |
||
353 | |||
354 | // Generate intermediate high frequency subband |
||
355 | |||
356 | //Initialize counters |
||
357 | ik = inOff + inStep; |
||
358 | lk = lowOff; |
||
359 | hk = highOff; |
||
360 | |||
361 | //Apply first lifting step to each "inner" sample |
||
362 | for (i = 1, maxi = inLen - 1; i < maxi; i += 2) |
||
363 | { |
||
364 | highSig[hk] = inSig[ik] + ALPHA * (inSig[ik - inStep] + inSig[ik + inStep]); |
||
365 | |||
366 | ik += iStep; |
||
367 | hk += highStep; |
||
368 | } |
||
369 | |||
370 | //Handle head boundary effect if input signal has even length |
||
371 | if (inLen % 2 == 0) |
||
372 | { |
||
373 | highSig[hk] = inSig[ik] + 2 * ALPHA * inSig[ik - inStep]; |
||
374 | } |
||
375 | |||
376 | // Generate intermediate low frequency subband |
||
377 | |||
378 | //Initialize counters |
||
379 | ik = inOff; |
||
380 | lk = lowOff; |
||
381 | hk = highOff; |
||
382 | |||
383 | if (inLen > 1) |
||
384 | { |
||
385 | lowSig[lk] = inSig[ik] + 2 * BETA * highSig[hk]; |
||
386 | } |
||
387 | else |
||
388 | { |
||
389 | lowSig[lk] = inSig[ik]; |
||
390 | } |
||
391 | |||
392 | ik += iStep; |
||
393 | lk += lowStep; |
||
394 | hk += highStep; |
||
395 | |||
396 | //Apply lifting step to each "inner" sample |
||
397 | for (i = 2, maxi = inLen - 1; i < maxi; i += 2) |
||
398 | { |
||
399 | lowSig[lk] = inSig[ik] + BETA * (highSig[hk - highStep] + highSig[hk]); |
||
400 | |||
401 | ik += iStep; |
||
402 | lk += lowStep; |
||
403 | hk += highStep; |
||
404 | } |
||
405 | |||
406 | //Handle head boundary effect if input signal has odd length |
||
407 | if ((inLen % 2 == 1) && (inLen > 2)) |
||
408 | { |
||
409 | lowSig[lk] = inSig[ik] + 2 * BETA * highSig[hk - highStep]; |
||
410 | } |
||
411 | |||
412 | // Generate high frequency subband |
||
413 | |||
414 | //Initialize counters |
||
415 | lk = lowOff; |
||
416 | hk = highOff; |
||
417 | |||
418 | //Apply first lifting step to each "inner" sample |
||
419 | for (i = 1, maxi = inLen - 1; i < maxi; i += 2) |
||
420 | { |
||
421 | highSig[hk] += GAMMA * (lowSig[lk] + lowSig[lk + lowStep]); |
||
422 | |||
423 | lk += lowStep; |
||
424 | hk += highStep; |
||
425 | } |
||
426 | |||
427 | //Handle head boundary effect if input signal has even length |
||
428 | if (inLen % 2 == 0) |
||
429 | { |
||
430 | highSig[hk] += 2 * GAMMA * lowSig[lk]; |
||
431 | } |
||
432 | |||
433 | // Generate low frequency subband |
||
434 | |||
435 | //Initialize counters |
||
436 | lk = lowOff; |
||
437 | hk = highOff; |
||
438 | |||
439 | //Handle tail boundary effect |
||
440 | //If access the overlap then perform the lifting step |
||
441 | if (inLen > 1) |
||
442 | { |
||
443 | lowSig[lk] += 2 * DELTA * highSig[hk]; |
||
444 | } |
||
445 | |||
446 | lk += lowStep; |
||
447 | hk += highStep; |
||
448 | |||
449 | //Apply lifting step to each "inner" sample |
||
450 | for (i = 2, maxi = inLen - 1; i < maxi; i += 2) |
||
451 | { |
||
452 | lowSig[lk] += DELTA * (highSig[hk - highStep] + highSig[hk]); |
||
453 | |||
454 | lk += lowStep; |
||
455 | hk += highStep; |
||
456 | } |
||
457 | |||
458 | //Handle head boundary effect if input signal has odd length |
||
459 | if ((inLen % 2 == 1) && (inLen > 2)) |
||
460 | { |
||
461 | lowSig[lk] += 2 * DELTA * highSig[hk - highStep]; |
||
462 | } |
||
463 | |||
464 | // Normalize low and high frequency subbands |
||
465 | |||
466 | //Re-initialize counters |
||
467 | lk = lowOff; |
||
468 | hk = highOff; |
||
469 | |||
470 | //Normalize each sample |
||
471 | for (i = 0; i < (inLen >> 1); i++) |
||
472 | { |
||
473 | lowSig[lk] *= KL; |
||
474 | highSig[hk] *= KH; |
||
475 | lk += lowStep; |
||
476 | hk += highStep; |
||
477 | } |
||
478 | //If the input signal has odd length then normalize the last low-pass |
||
479 | //coefficient (if input signal is length one filter is identity) |
||
480 | if (inLen % 2 == 1 && inLen != 1) |
||
481 | { |
||
482 | lowSig[lk] *= KL; |
||
483 | } |
||
484 | } |
||
485 | |||
486 | /// <summary> An implementation of the analyze_hpf() method that works on int |
||
487 | /// data, for the forward 9x7 wavelet transform using the |
||
488 | /// lifting scheme. See the general description of the analyze_hpf() method |
||
489 | /// in the AnWTFilter class for more details. |
||
490 | /// |
||
491 | /// <P>The coefficients of the first lifting step are [ALPHA 1 ALPHA]. |
||
492 | /// |
||
493 | /// <P>The coefficients of the second lifting step are [BETA 1 BETA]. |
||
494 | /// |
||
495 | /// <P>The coefficients of the third lifting step are [GAMMA 1 GAMMA]. |
||
496 | /// |
||
497 | /// <P>The coefficients of the fourth lifting step are [DELTA 1 DELTA]. |
||
498 | /// |
||
499 | /// <P>The low-pass and high-pass subbands are normalized by respectively |
||
500 | /// a factor of KL and a factor of KH |
||
501 | /// |
||
502 | /// </summary> |
||
503 | /// <param name="inSig">This is the array that contains the input |
||
504 | /// signal. |
||
505 | /// |
||
506 | /// </param> |
||
507 | /// <param name="inOff">This is the index in inSig of the first sample to |
||
508 | /// filter. |
||
509 | /// |
||
510 | /// </param> |
||
511 | /// <param name="inLen">This is the number of samples in the input signal |
||
512 | /// to filter. |
||
513 | /// |
||
514 | /// </param> |
||
515 | /// <param name="inStep">This is the step, or interleave factor, of the |
||
516 | /// input signal samples in the inSig array. |
||
517 | /// |
||
518 | /// </param> |
||
519 | /// <param name="lowSig">This is the array where the low-pass output |
||
520 | /// signal is placed. |
||
521 | /// |
||
522 | /// </param> |
||
523 | /// <param name="lowOff">This is the index in lowSig of the element where |
||
524 | /// to put the first low-pass output sample. |
||
525 | /// |
||
526 | /// </param> |
||
527 | /// <param name="lowStep">This is the step, or interleave factor, of the |
||
528 | /// low-pass output samples in the lowSig array. |
||
529 | /// |
||
530 | /// </param> |
||
531 | /// <param name="highSig">This is the array where the high-pass output |
||
532 | /// signal is placed. |
||
533 | /// |
||
534 | /// </param> |
||
535 | /// <param name="highOff">This is the index in highSig of the element where |
||
536 | /// to put the first high-pass output sample. |
||
537 | /// |
||
538 | /// </param> |
||
539 | /// <param name="highStep">This is the step, or interleave factor, of the |
||
540 | /// high-pass output samples in the highSig array. |
||
541 | /// |
||
542 | /// </param> |
||
543 | /// <seealso cref="AnWTFilter.analyze_hpf"> |
||
544 | /// |
||
545 | /// </seealso> |
||
546 | public override void analyze_hpf(float[] inSig, int inOff, int inLen, int inStep, float[] lowSig, int lowOff, int lowStep, float[] highSig, int highOff, int highStep) |
||
547 | { |
||
548 | |||
549 | int i; // maxi removed |
||
550 | int iStep = 2 * inStep; //Subsampling in inSig |
||
551 | int ik; //Indexing inSig |
||
552 | int lk; //Indexing lowSig |
||
553 | int hk; //Indexing highSig |
||
554 | |||
555 | // Generate intermediate high frequency subband |
||
556 | |||
557 | //Initialize counters |
||
558 | ik = inOff; |
||
559 | lk = lowOff; |
||
560 | hk = highOff; |
||
561 | |||
562 | if (inLen > 1) |
||
563 | { |
||
564 | // apply symmetric extension. |
||
565 | highSig[hk] = inSig[ik] + 2 * ALPHA * inSig[ik + inStep]; |
||
566 | } |
||
567 | else |
||
568 | { |
||
569 | // Normalize for Nyquist gain |
||
570 | highSig[hk] = inSig[ik] * 2; |
||
571 | } |
||
572 | |||
573 | ik += iStep; |
||
574 | hk += highStep; |
||
575 | |||
576 | //Apply first lifting step to each "inner" sample |
||
577 | for (i = 2; i < inLen - 1; i += 2) |
||
578 | { |
||
579 | highSig[hk] = inSig[ik] + ALPHA * (inSig[ik - inStep] + inSig[ik + inStep]); |
||
580 | ik += iStep; |
||
581 | hk += highStep; |
||
582 | } |
||
583 | |||
584 | //If input signal has odd length then we perform the lifting step |
||
585 | // i.e. apply a symmetric extension. |
||
586 | if ((inLen % 2 == 1) && (inLen > 1)) |
||
587 | { |
||
588 | highSig[hk] = inSig[ik] + 2 * ALPHA * inSig[ik - inStep]; |
||
589 | } |
||
590 | |||
591 | // Generate intermediate low frequency subband |
||
592 | |||
593 | //Initialize counters |
||
594 | //ik = inOff + inStep; |
||
595 | ik = inOff + inStep; |
||
596 | lk = lowOff; |
||
597 | hk = highOff; |
||
598 | |||
599 | //Apply lifting step to each "inner" sample |
||
600 | // we are at the component boundary |
||
601 | for (i = 1; i < inLen - 1; i += 2) |
||
602 | { |
||
603 | lowSig[lk] = inSig[ik] + BETA * (highSig[hk] + highSig[hk + highStep]); |
||
604 | |||
605 | ik += iStep; |
||
606 | lk += lowStep; |
||
607 | hk += highStep; |
||
608 | } |
||
609 | if (inLen > 1 && inLen % 2 == 0) |
||
610 | { |
||
611 | // symetric extension |
||
612 | lowSig[lk] = inSig[ik] + 2 * BETA * highSig[hk]; |
||
613 | } |
||
614 | |||
615 | // Generate high frequency subband |
||
616 | |||
617 | //Initialize counters |
||
618 | lk = lowOff; |
||
619 | hk = highOff; |
||
620 | |||
621 | if (inLen > 1) |
||
622 | { |
||
623 | // symmetric extension. |
||
624 | highSig[hk] += GAMMA * 2 * lowSig[lk]; |
||
625 | } |
||
626 | //lk += lowStep; |
||
627 | hk += highStep; |
||
628 | |||
629 | //Apply first lifting step to each "inner" sample |
||
630 | for (i = 2; i < inLen - 1; i += 2) |
||
631 | { |
||
632 | highSig[hk] += GAMMA * (lowSig[lk] + lowSig[lk + lowStep]); |
||
633 | lk += lowStep; |
||
634 | hk += highStep; |
||
635 | } |
||
636 | |||
637 | //Handle head boundary effect |
||
638 | if (inLen > 1 && inLen % 2 == 1) |
||
639 | { |
||
640 | // symmetric extension. |
||
641 | highSig[hk] += GAMMA * 2 * lowSig[lk]; |
||
642 | } |
||
643 | |||
644 | // Generate low frequency subband |
||
645 | |||
646 | //Initialize counters |
||
647 | lk = lowOff; |
||
648 | hk = highOff; |
||
649 | |||
650 | // we are at the component boundary |
||
651 | for (i = 1; i < inLen - 1; i += 2) |
||
652 | { |
||
653 | lowSig[lk] += DELTA * (highSig[hk] + highSig[hk + highStep]); |
||
654 | lk += lowStep; |
||
655 | hk += highStep; |
||
656 | } |
||
657 | |||
658 | if (inLen > 1 && inLen % 2 == 0) |
||
659 | { |
||
660 | lowSig[lk] += DELTA * 2 * highSig[hk]; |
||
661 | } |
||
662 | |||
663 | // Normalize low and high frequency subbands |
||
664 | |||
665 | //Re-initialize counters |
||
666 | lk = lowOff; |
||
667 | hk = highOff; |
||
668 | |||
669 | //Normalize each sample |
||
670 | for (i = 0; i < (inLen >> 1); i++) |
||
671 | { |
||
672 | lowSig[lk] *= KL; |
||
673 | highSig[hk] *= KH; |
||
674 | lk += lowStep; |
||
675 | hk += highStep; |
||
676 | } |
||
677 | //If the input signal has odd length then normalize the last high-pass |
||
678 | //coefficient (if input signal is length one filter is identity) |
||
679 | if (inLen % 2 == 1 && inLen != 1) |
||
680 | { |
||
681 | highSig[hk] *= KH; |
||
682 | } |
||
683 | } |
||
684 | |||
685 | /// <summary> Returns the time-reversed low-pass synthesis waveform of the |
||
686 | /// filter, which is the low-pass filter. This is the time-reversed |
||
687 | /// impulse response of the low-pass synthesis filter. It is used |
||
688 | /// to calculate the L2-norm of the synthesis basis functions for a |
||
689 | /// particular subband (also called energy weight). |
||
690 | /// |
||
691 | /// <P>The returned array may not be modified (i.e. a reference to |
||
692 | /// the internal array may be returned by the implementation of |
||
693 | /// this method). |
||
694 | /// |
||
695 | /// </summary> |
||
696 | /// <returns> The time-reversed low-pass synthesis waveform of the |
||
697 | /// filter. |
||
698 | /// |
||
699 | /// </returns> |
||
700 | public override float[] getLPSynthesisFilter() |
||
701 | { |
||
702 | return LPSynthesisFilter; |
||
703 | } |
||
704 | |||
705 | /// <summary> Returns the time-reversed high-pass synthesis waveform of the |
||
706 | /// filter, which is the high-pass filter. This is the |
||
707 | /// time-reversed impulse response of the high-pass synthesis |
||
708 | /// filter. It is used to calculate the L2-norm of the synthesis |
||
709 | /// basis functions for a particular subband (also called energy |
||
710 | /// weight). |
||
711 | /// |
||
712 | /// <P>The returned array may not be modified (i.e. a reference to |
||
713 | /// the internal array may be returned by the implementation of |
||
714 | /// this method). |
||
715 | /// |
||
716 | /// </summary> |
||
717 | /// <returns> The time-reversed high-pass synthesis waveform of the |
||
718 | /// filter. |
||
719 | /// |
||
720 | /// </returns> |
||
721 | public override float[] getHPSynthesisFilter() |
||
722 | { |
||
723 | return HPSynthesisFilter; |
||
724 | } |
||
725 | |||
726 | /// <summary> Returns true if the wavelet filter computes or uses the |
||
727 | /// same "inner" subband coefficient as the full frame wavelet transform, |
||
728 | /// and false otherwise. In particular, for block based transforms with |
||
729 | /// reduced overlap, this method should return false. The term "inner" |
||
730 | /// indicates that this applies only with respect to the coefficient that |
||
731 | /// are not affected by image boundaries processings such as symmetric |
||
732 | /// extension, since there is not reference method for this. |
||
733 | /// |
||
734 | /// <P>The result depends on the length of the allowed overlap when |
||
735 | /// compared to the overlap required by the wavelet filter. It also |
||
736 | /// depends on how overlap processing is implemented in the wavelet |
||
737 | /// filter. |
||
738 | /// |
||
739 | /// </summary> |
||
740 | /// <param name="tailOvrlp">This is the number of samples in the input |
||
741 | /// signal before the first sample to filter that can be used for |
||
742 | /// overlap. |
||
743 | /// |
||
744 | /// </param> |
||
745 | /// <param name="headOvrlp">This is the number of samples in the input |
||
746 | /// signal after the last sample to filter that can be used for |
||
747 | /// overlap. |
||
748 | /// |
||
749 | /// </param> |
||
750 | /// <param name="inLen">This is the lenght of the input signal to filter.The |
||
751 | /// required number of samples in the input signal after the last sample |
||
752 | /// depends on the length of the input signal. |
||
753 | /// |
||
754 | /// </param> |
||
755 | /// <returns> true if both overlaps are greater than 2, and correct |
||
756 | /// processing is applied in the analyze() method. |
||
757 | /// |
||
758 | /// </returns> |
||
759 | public override bool isSameAsFullWT(int tailOvrlp, int headOvrlp, int inLen) |
||
760 | { |
||
761 | |||
762 | //If the input signal has even length. |
||
763 | if (inLen % 2 == 0) |
||
764 | { |
||
765 | if (tailOvrlp >= 4 && headOvrlp >= 3) |
||
766 | return true; |
||
767 | else |
||
768 | return false; |
||
769 | } |
||
770 | //Else if the input signal has odd length. |
||
771 | else |
||
772 | { |
||
773 | if (tailOvrlp >= 4 && headOvrlp >= 4) |
||
774 | return true; |
||
775 | else |
||
776 | return false; |
||
777 | } |
||
778 | } |
||
779 | |||
780 | /// <summary> Tests if the 'obj' object is the same filter as this one. Two filters |
||
781 | /// are the same if the same filter code should be output for both filters |
||
782 | /// by the encodeFilterCode() method. |
||
783 | /// |
||
784 | /// <P>Currently the implementation of this method only tests if 'obj' is |
||
785 | /// also of the class AnWTFilterFloatLift9x7 |
||
786 | /// |
||
787 | /// </summary> |
||
788 | /// <param name="The">object against which to test inequality. |
||
789 | /// |
||
790 | /// </param> |
||
791 | public override bool Equals(System.Object obj) |
||
792 | { |
||
793 | // To spped up test, first test for reference equality |
||
794 | return obj == this || obj is AnWTFilterFloatLift9x7; |
||
795 | } |
||
796 | |||
797 | /// <summary>Debugging method </summary> |
||
798 | public override System.String ToString() |
||
799 | { |
||
800 | return "w9x7"; |
||
801 | } |
||
802 | //UPGRADE_NOTE: The following method implementation was automatically added to preserve functionality. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1306'" |
||
803 | public override int GetHashCode() |
||
804 | { |
||
805 | return base.GetHashCode(); |
||
806 | } |
||
807 | } |
||
808 | } |