]> git.pld-linux.org Git - packages/waili.git/blob - waili-various_code.patch
- updated Debian patches
[packages/waili.git] / waili-various_code.patch
1 --- waili-19990723.orig/include/waili/Lifting.h
2 +++ waili-19990723/include/waili/Lifting.h
3 @@ -35,6 +35,10 @@ class Lifting {
4      public:
5         virtual ~Lifting();
6  
7 +
8 +       virtual void Lift_bin(int type)   const = 0;
9 +       virtual void ILift_bin(int type)   const = 0;
10 +
11         // Lifting Steps (Full Rounding)
12         virtual void Lift_L1R1_FR(int primal, const s16 b[2], const u16 a)
13             const = 0;
14 @@ -109,6 +113,12 @@ class LiftChannelR : public Lifting {
15         LiftChannelR(NTChannel *lowpass, NTChannel *highpass);
16         virtual ~LiftChannelR();
17  
18 +
19 +
20 +       virtual void Lift_bin(int type)   const ;
21 +       virtual void ILift_bin(int type)   const ;
22 +
23 +
24         // Lifting Steps (Full Rounding)
25         virtual void Lift_L1R1_FR(int primal, const s16 b[2], const u16 a)
26             const;
27 @@ -179,6 +189,14 @@ class LiftChannelC : public Lifting {
28         LiftChannelC(NTChannel *lowpass, NTChannel *highpass);
29         virtual ~LiftChannelC();
30  
31 +
32 +
33 +
34 +       virtual void Lift_bin(int type)   const;
35 +       virtual void ILift_bin(int type)   const;
36 +
37 +
38 +
39         // Lifting Steps (Full Rounding)
40         virtual void Lift_L1R1_FR(int primal, const s16 b[2], const u16 a)
41             const;
42 --- waili-19990723.orig/include/waili/Wavelet.h
43 +++ waili-19990723/include/waili/Wavelet.h
44 @@ -34,6 +34,16 @@
45  #define LIFTING_OPTIMIZE_STEPS 1       // Use optimized lifting steps
46  
47  
48 +// Unique private IDs
49 +enum Wavelet_ID {
50 +  ID_Lazy = 0,
51 +  ID_CDF_1_1 = 1, ID_CDF_1_3 = 2, ID_CDF_1_5 = 3,
52 +  ID_CDF_2_2 = 4, ID_CDF_2_4 = 5, ID_CDF_2_6 = 6,
53 +  ID_CDF_4_2 = 7, ID_CDF_4_4 = 8, ID_CDF_4_6 = 9,
54 +  ID_CRF_13_7 = 100, ID_SWE_13_7 = 101
55 +};
56 +
57 +
58  
59  // ----------------------------------------------------------------------------
60  //
61 @@ -62,29 +72,21 @@ class Wavelet {
62         int GetShiftH(void) const;
63  
64         // Unique private IDs for different Wavelets
65 -       u8 GetID(void) const;
66 -       static Wavelet *CreateFromID(u8 id);
67 +       Wavelet_ID GetID(void) const {    return ID; };
68 +
69 +       static Wavelet *CreateFromID(Wavelet_ID id);
70  
71      protected:
72         int GStart, GEnd, HStart, HEnd;
73         // Normalization
74         int ShiftL, ShiftH;
75  
76 -       // Unique private IDs
77 -       enum Wavelet_IDs {
78 -           ID_Lazy = 0,
79 -           ID_CDF_1_1 = 1, ID_CDF_1_3 = 2, ID_CDF_1_5 = 3,
80 -           ID_CDF_2_2 = 4, ID_CDF_2_4 = 5, ID_CDF_2_6 = 6,
81 -           ID_CDF_4_2 = 7, ID_CDF_4_4 = 8, ID_CDF_4_6 = 9,
82 -           ID_CRF_13_7 = 100, ID_SWE_13_7 = 101
83 -       };
84 -       u8 ID;
85 +       Wavelet_ID ID;
86  
87      private:
88         static const char *rcsid;
89  };
90  
91 -
92  // ----------------------------------------------------------------------------
93  
94  
95 @@ -337,7 +339,6 @@ class Wavelet_CRF_13_7 : public Wavelet
96         // Lifting steps on Channels
97         virtual void CakeWalk(Lifting &lifting) const;
98         virtual void ICakeWalk(Lifting &lifting) const;
99 -
100      protected:
101         static const s16 D1b[4];
102         static const u16 D1a;
103 @@ -367,6 +368,9 @@ class Wavelet_SWE_13_7 : public Wavelet
104         static const char *rcsid;
105  };
106  
107 +/////////////////////////////////////////////////////////////
108 +
109 +#include "waili/Wavelet_bin.h"
110  
111  /////////////////////////////////////////////////////////////////////////////
112  //
113 @@ -405,11 +409,6 @@ inline int Wavelet::GetShiftH(void) cons
114      return(ShiftH);
115  }
116  
117 -inline u8 Wavelet::GetID(void) const
118 -{
119 -    return ID;
120 -}
121 -
122  inline Wavelet_Lazy::Wavelet_Lazy()
123  {
124      HStart = 0;
125 --- waili-19990723.orig/include/waili/Blit.h
126 +++ waili-19990723/include/waili/Blit.h
127 @@ -102,7 +102,7 @@ inline void FillRect(Type *dst, u_int dw
128  
129  template <class Type>
130  inline void FillRect(Type *dst, u_int dw, u_int dx, u_int dy, u_int cols,
131 -                    u_int rows, Type value)
132 +                    u_int rows, Type value )
133  {
134      FillRect(dst+dy*dw+dx, dw, cols, rows, value);
135  }
136 @@ -121,7 +121,7 @@ inline void ClearRect(Type *dst, u_int d
137  
138  template <class Type>
139  inline void ClearRect(Type *dst, u_int dw, u_int dx, u_int dy, u_int cols,
140 -                     u_int rows)
141 +                     u_int rows, Type value)
142  {
143      ClearRect(dst+dy*dw+dx, dw, cols, rows, value);
144  }
145 --- waili-19990723.orig/include/waili/Storage.h
146 +++ waili-19990723/include/waili/Storage.h
147 @@ -87,6 +87,7 @@ class Stream {
148         void Write(const f32 &x);
149         void Write(const f64 &x);
150  
151 +        int Feof() { return feof(File);        };
152         void Puts(const char *s);
153         void Printf(const char *fmt, ...)
154  #ifdef __GNUG__
155 @@ -94,8 +95,9 @@ class Stream {
156  #endif // __GNUG__
157  ;
158  
159 +  
160      protected:
161 -       FILE *File;
162 +        FILE *File;
163         char *Name;
164         char *Mode;
165         u_int Compressed;
166 --- /dev/null
167 +++ waili-19990723/include/waili/Wavelet_gain.h
168 @@ -0,0 +1,7 @@
169 +
170 +double *wavelet_gaussian_variance_gain_by_type(TransformType  type);
171 +
172 +double *wavelet_gaussian_variance_gain(Channel *C);
173 +
174 +double *wavelet_uniform_maximum_gain_by_type(int type);
175 +
176 --- waili-19990723.orig/include/waili/Channel.h
177 +++ waili-19990723/include/waili/Channel.h
178 @@ -34,8 +34,8 @@ enum TransformType {
179  };
180  
181  struct TransformDescriptor {
182 -    u8 type;   // TransformType
183 -    u8 filter; // Wavelet_IDs
184 +    TransformType type;        // TransformType
185 +    Wavelet_ID filter; // Wavelet_IDs
186  };
187  
188  
189 @@ -62,13 +62,16 @@ class Channel {
190  
191         // Properties
192         u_int GetCols(void) const;
193 -       u_int GetRows(void) const;
194 +       u_int GetRows(void) const;      
195         int GetOffsetX(void) const;
196         int GetOffsetY(void) const;
197         virtual void GetMask(u_int &maskx, u_int &masky) const = 0;
198         virtual u_int GetDepth(void) const = 0;
199 +       virtual u_int GetSubbands(void) const = 0;
200         virtual double Psnr(const Channel &channel, PixType maxval = 255)
201             const;
202 +       virtual double MSE(const Channel &channel)
203 +           const;
204         virtual u64 *FullHistogram(PixType &min, PixType &max, u64 &numpixels)
205             const = 0;
206         double Entropy(void) const;
207 @@ -76,6 +79,7 @@ class Channel {
208         // Manipulation
209         virtual PixType &operator()(u_int c, u_int r) = 0;
210         virtual PixType operator()(u_int c, u_int r) const = 0;
211 +       virtual PixType *pixaddr(u_int c, u_int r) = 0;
212         virtual void Clear(void) = 0;
213         virtual void Resize(u_int cols, u_int rows);
214         virtual Channel *Clone(void) const = 0;
215 --- waili-19990723.orig/include/waili/NTChannel.h
216 +++ waili-19990723/include/waili/NTChannel.h
217 @@ -49,6 +49,7 @@ class NTChannel : public Channel {
218         // Properties
219         virtual void GetMask(u_int &maskx, u_int &masky) const;
220         virtual u_int GetDepth(void) const;
221 +       u_int GetSubbands(void) const { return 0; };
222         void GetMinMax(PixType &min, PixType &max, u_int smoothing = 0) const;
223         u64 *Histogram(PixType min, PixType max) const;
224         virtual u64 *FullHistogram(PixType &min, PixType &max, u64 &numpixels)
225 @@ -57,6 +58,7 @@ class NTChannel : public Channel {
226         // Manipulation
227         virtual PixType &operator()(u_int c, u_int r);
228         virtual PixType operator()(u_int c, u_int r) const;
229 +       PixType *pixaddr(u_int c, u_int r);
230         virtual void Clear(void);
231         virtual void Resize(u_int cols, u_int rows);
232         virtual NTChannel *Clone(void) const;
233 @@ -151,6 +153,16 @@ inline PixType &NTChannel::operator()(u_
234      return(Data[r*Cols+c]);
235  }
236  
237 +inline PixType *NTChannel::pixaddr(u_int c, u_int r)
238 +{
239 +#ifdef BOUNDS_CHECK
240 +    assert(Data != NULL);
241 +    assert(c < Cols);
242 +    assert(r < Rows);
243 +#endif // BOUNDS_CHECK
244 +    return( &(Data[r*Cols+c]));
245 +}
246 +
247  inline PixType NTChannel::operator()(u_int c, u_int r) const
248  {
249  #ifdef BOUNDS_CHECK
250 --- waili-19990723.orig/include/waili/Util.h
251 +++ waili-19990723/include/waili/Util.h
252 @@ -63,7 +63,7 @@ void DumpMemoryStatus(void);
253  template <class Type>
254  inline Type Min(Type x, Type y)
255  {
256 -#ifdef __GNUG__
257 +#ifdef __GNUG_DEPRECATED__
258      return(x <? y);
259  #else /* !__GNUG__ */
260      return(x < y ? x : y);
261 @@ -73,7 +73,7 @@ inline Type Min(Type x, Type y)
262  template <class Type>
263  inline Type Max(Type x, Type y)
264  {
265 -#ifdef __GNUG__
266 +#ifdef __GNUG_DEPRECATED__
267      return(x >? y);
268  #else /* !__GNUG__ */
269      return(x > y ? x : y);
270 --- /dev/null
271 +++ waili-19990723/include/waili/Wavelet_bin.h
272 @@ -0,0 +1,15 @@
273 +
274 +
275 +class Wavelet_Binary : public Wavelet {
276 +public:
277 +  Wavelet_Binary();
278 +  
279 +  // Lifting steps on Channels
280 +  void CakeWalk(Lifting &lifting) const ;
281 +  void ICakeWalk(Lifting &lifting) const ;
282 +  Wavelet_Binary *Clone(void) const;
283 +
284 +private:
285 +  static const char *rcsid;
286 +};
287 +
288 --- waili-19990723.orig/include/waili/Image.h
289 +++ waili-19990723/include/waili/Image.h
290 @@ -24,7 +24,7 @@
291  #define WAILI_IMAGE_H
292  
293  #include <assert.h>
294 -#include <stream.h>
295 +#include <sstream>
296  
297  #include "Channel.h"
298  #include "Util.h"
299 @@ -76,7 +76,7 @@ class Image {
300  
301         // Manipulation
302         Channel*& operator[](u_int channel);
303 -       const Channel*& operator[](u_int channel) const;
304 +       Channel*& operator[](u_int channel) const;
305         PixType& operator()(u_int c, u_int r, u_int ch = 0);
306         const PixType operator()(u_int c, u_int r, u_int ch = 0) const;
307  
308 @@ -136,12 +136,12 @@ inline Image::Image()
309  inline Image::Image(u_int channels)
310      : NumChannels(channels), Channels(NULL)
311  {
312 -    Channels = new (Channel *)[NumChannels];
313 +    Channels = new Channel *[NumChannels];
314      ::Clear(Channels, NumChannels);
315  }
316  
317  
318 -inline Channel*& Image::operator[](u_int channel)
319 +inline Channel*& Image::operator[](u_int channel) const
320  {
321  #ifdef BOUNDS_CHECK
322      assert(channel < NumChannels);
323 @@ -149,7 +149,7 @@ inline Channel*& Image::operator[](u_int
324      return(Channels[channel]);
325  }
326  
327 -inline const Channel*& Image::operator[](u_int channel) const
328 +inline Channel*& Image::operator[](u_int channel)
329  {
330  #ifdef BOUNDS_CHECK
331      assert(channel < NumChannels);
332 --- waili-19990723.orig/include/waili/LChannel.h
333 +++ waili-19990723/include/waili/LChannel.h
334 @@ -54,6 +54,7 @@ class LChannel : public Channel {
335  
336         // Properties
337         virtual u_int GetDepth(void) const;
338 +       u_int GetSubbands(void) const;
339         virtual TransformType GetTransformType(void) const = 0;
340         TransformDescriptor *GetTransform(void) const;
341         virtual u64 *FullHistogram(PixType &min, PixType &max, u64 &numpixels)
342 @@ -64,7 +65,7 @@ class LChannel : public Channel {
343         // Manipulation
344         virtual void Clear(void);
345         Channel* &operator[](SubBand band);
346 -       const Channel* &operator[](SubBand band) const;
347 +       Channel* &operator[](SubBand band) const;
348         virtual LChannel *Clone(void) const = 0;
349  
350         // Wavelet Transforms
351 @@ -140,6 +141,11 @@ inline u_int LChannel::GetDepth(void) co
352      return(1+SubBands[0]->GetDepth());
353  }
354  
355 +inline  u_int LChannel::GetSubbands(void) const
356 +{
357 +  return NumSubBands;
358 +}
359 +
360  inline int LChannel::GetShift(SubBand band)
361  {
362      assert((u_int)band < NumSubBands);
363 @@ -149,14 +155,14 @@ inline int LChannel::GetShift(SubBand ba
364  inline Channel* &LChannel::operator[](SubBand band)
365  {
366      assert((u_int)band < NumSubBands);
367 -    assert(SubBands[band] != NULL);
368 +    //assert(SubBands[band] != NULL);
369      return(SubBands[band]);
370  }
371  
372 -inline const Channel* &LChannel::operator[](SubBand band) const
373 +inline Channel* &LChannel::operator[](SubBand band) const
374  {
375      assert((u_int)band < NumSubBands);
376 -    assert(SubBands[band] != NULL);
377 +    //assert(SubBands[band] != NULL);
378      return(SubBands[band]);
379  }
380  
381 --- waili-19990723.orig/include/waili/LChannelCR.h
382 +++ waili-19990723/include/waili/LChannelCR.h
383 @@ -53,6 +53,8 @@ class LChannelCR : public LChannel {
384         // Manipulation
385         virtual PixType &operator()(u_int c, u_int r);
386         virtual PixType operator()(u_int c, u_int r) const;
387 +       PixType *pixaddr(u_int c, u_int r);
388 +
389         virtual void Resize(u_int cols, u_int rows);
390         virtual LChannelCR *Clone(void) const;
391         virtual void SetOffsetX(int offx);
392 @@ -184,6 +186,29 @@ inline PixType LChannelCR::operator()(u_
393      return((*channel)(c, r));
394  }
395  
396 +inline PixType *LChannelCR::pixaddr(u_int c, u_int r)
397 +{
398 +    u_int band = SubBand_LL;
399 +    Channel *channel;
400 +#ifdef BOUNDS_CHECK
401 +    assert(c < Cols);
402 +    assert(r < Rows);
403 +#endif // BOUNDS_CHECK
404 +    if (r >= GetRlow()) {
405 +       r -= GetRlow();
406 +       band += SubBand_HL;
407 +    }
408 +    if (c >= GetClow()) {
409 +       c -= GetClow();
410 +       band += SubBand_LH;
411 +    }
412 +    channel = SubBands[band];
413 +#ifdef BOUNDS_CHECK
414 +    assert(channel != NULL);
415 +#endif // BOUNDS_CHECK
416 +    return channel->pixaddr(c, r);
417 +}
418 +
419  inline LChannelCR *LChannelCR::Clone(void) const
420  {
421      return(new LChannelCR(*this));
422 --- waili-19990723.orig/include/waili/LChannelC.h
423 +++ waili-19990723/include/waili/LChannelC.h
424 @@ -49,6 +49,8 @@ class LChannelC : public LChannel {
425         // Manipulation
426         virtual PixType &operator()(u_int c, u_int r);
427         virtual PixType operator()(u_int c, u_int r) const;
428 +       PixType *pixaddr(u_int c, u_int r);
429 +
430         virtual void Resize(u_int cols, u_int rows);
431         virtual LChannelC *Clone(void) const;
432         virtual void SetOffsetX(int offx);
433 @@ -156,6 +158,25 @@ inline PixType LChannelC::operator()(u_i
434      return((*channel)(c, r));
435  }
436  
437 +inline PixType *LChannelC::pixaddr(u_int c, u_int r) 
438 +{
439 +    Channel *channel;
440 +#ifdef BOUNDS_CHECK
441 +    assert(c < Cols);
442 +    assert(r < Rows);
443 +#endif // BOUNDS_CHECK
444 +    if (r < GetRlow())
445 +       channel = SubBands[0];
446 +    else {
447 +       r -= GetRlow();
448 +       channel = SubBands[1];
449 +    }
450 +#ifdef BOUNDS_CHECK
451 +    assert(channel != NULL);
452 +#endif // BOUNDS_CHECK
453 +    return channel->pixaddr(c, r);
454 +}
455 +
456  inline LChannelC *LChannelC::Clone(void) const
457  {
458      return(new LChannelC(*this));
459 --- waili-19990723.orig/include/waili/Makefile
460 +++ waili-19990723/include/waili/Makefile
461 @@ -39,7 +39,8 @@ RCSOBJS =     Blit.h \
462                 Timer.h \
463                 Types.h \
464                 Util.h \
465 -               Wavelet.h
466 +               Wavelet.h \
467 +               Wavelet_bin.h
468  
469  All:           $(RCSOBJS)
470  
471 @@ -48,3 +49,10 @@ depend:              $(RCSOBJS)
472  clean:
473  
474  include ../../Rules.make
475 +
476 +# ----------------------------------------- Installation
477 +#added for Debian     
478 +# You're going to have to be root to do this!
479 +install:        All
480 +       $(INSTALL) -d  $(DESTDIR)$(PREFIX)/include/waili
481 +       $(INSTALL) -m 644 $(RCSOBJS) $(DESTDIR)$(PREFIX)/include/waili
482 --- waili-19990723.orig/include/waili/LChannelR.h
483 +++ waili-19990723/include/waili/LChannelR.h
484 @@ -49,6 +49,8 @@ class LChannelR : public LChannel {
485         // Manipulation
486         virtual PixType &operator()(u_int c, u_int r);
487         virtual PixType operator()(u_int c, u_int r) const;
488 +       PixType *pixaddr(u_int c, u_int r);
489 +
490         virtual void Resize(u_int cols, u_int rows);
491         virtual LChannelR *Clone(void) const;
492         virtual void SetOffsetX(int offx);
493 @@ -156,6 +158,27 @@ inline PixType LChannelR::operator()(u_i
494      return((*channel)(c, r));
495  }
496  
497 +
498 +inline PixType *LChannelR::pixaddr(u_int c, u_int r)
499 +{
500 +    Channel *channel;
501 +#ifdef BOUNDS_CHECK
502 +    assert(c < Cols);
503 +    assert(r < Rows);
504 +#endif // BOUNDS_CHECK
505 +    if (c < GetClow())
506 +       channel = SubBands[0];
507 +    else {
508 +       c -= GetClow();
509 +       channel = SubBands[1];
510 +    }
511 +#ifdef BOUNDS_CHECK
512 +    assert(channel != NULL);
513 +#endif // BOUNDS_CHECK
514 +    return channel->pixaddr(c, r);
515 +}
516 +
517 +
518  inline LChannelR *LChannelR::Clone(void) const
519  {
520      return(new LChannelR(*this));
521 --- waili-19990723.orig/include/waili/Types.h
522 +++ waili-19990723/include/waili/Types.h
523 @@ -58,5 +58,8 @@ typedef double                        f64;    /* 64 bit floating
524  
525  typedef s16                    PixType;
526  
527 +#ifdef __WIN32__
528 +typedef unsigned int    u_int;
529 +#endif
530  
531  #endif // WAILI_TYPES_H
532 --- waili-19990723.orig/test/Proof.C
533 +++ waili-19990723/test/Proof.C
534 @@ -131,7 +131,7 @@ int main(int argc, char *argv[])
535         Usage();
536      im1.Import(infile);
537      Wavelet *wavelet = Wavelet::CreateCDF(np, nd);
538 -    u8 id = wavelet->GetID();
539 +    Wavelet_ID id = wavelet->GetID();
540      delete wavelet;
541      channels = im1.GetChannels();
542      if (channels != 1)
543 --- waili-19990723.orig/test/Demo.C
544 +++ waili-19990723/test/Demo.C
545 @@ -1,7 +1,7 @@
546  //
547  //     Simple Interactive Demo
548  //
549 -//  $Id: Demo.C,v 4.6.2.3.2.1 1999/07/20 16:16:19 geert Exp $
550 +//  $Id: Demo.C,v 1.1 2001/05/21 15:33:03 andrea Exp andrea $
551  //
552  //  Copyright (C) 1996-1999 Department of Computer Science, K.U.Leuven, Belgium
553  //
554 @@ -172,7 +172,7 @@ static void DeleteArgs(int argc, const c
555  
556  
557      /*
558 -     *  Partial strcasecmp() (s1 may be an abbreviation for s2)
559 +     *  Partial strcasecmp () (s1 may be an abbreviation for s2)
560       */
561  
562  static int PartStrCaseCmp(const char *s1, const char *s2)
563 @@ -193,16 +193,46 @@ static int PartStrCaseCmp(const char *s1
564  }
565  
566  
567 +static int do_it(const struct Command &c , int argc, const char *argv[])
568 +{
569 +  try {
570 +    try {
571 +      try {
572 +       c.Function(argc-1, argv+1);
573 +      }
574 +      catch (char *message) { fprintf(stderr,"EXCEPTION %s\n",message); } 
575 +    }
576 +    catch (char message[]) { fprintf(stderr,"EXCEPTION %s\n",message); } 
577 +  }
578 +  catch (std::exception e) { fprintf(stderr,"EXCEPTION %s\n",e.what());};
579 +  return 1;
580 +}
581 +
582  static int ExecCommand(const struct Command commands[], u_int numcommands,
583                        int argc, const char *argv[])
584  {
585 -    if (argc)
586 -       for (u_int i = 0; i < numcommands; i++)
587 -           if (PartStrCaseCmp(argv[0], commands[i].Name)) {
588 -               commands[i].Function(argc-1, argv+1);
589 -               return 1;
590 -           }
591 -    return 0;
592 +
593 +  int ci=-1;
594 +  if (argc) {
595 +    for (u_int i = 0; i < numcommands; i++)   {
596 +      /* exact match, for short commands */
597 +      if ( strcmp(argv[0], commands[i].Name) == 0)  {  
598 +       return do_it(commands[i],argc,argv);
599 +      }
600 +      if (PartStrCaseCmp(argv[0], commands[i].Name)) {
601 +       if(ci>=0)       {
602 +         fprintf(stderr,
603 +                 "Command abbreviation is ambiguous: '%s' or '%s'?\n",
604 +                 commands[ci].Name,commands[i].Name    );
605 +         return 1;
606 +       }
607 +       ci=i;
608 +      } }
609 +    if(ci>=0) {
610 +      return do_it(commands[ci],argc,argv);
611 +    }   
612 +  }
613 +  return 0;
614  }
615  
616  static void Do_NotYetImplemented(int, const char **)
617 @@ -245,9 +275,11 @@ static int NoWavelet(void)
618  
619  void Do_Help(int, const char **)
620  {
621 -    fputs("\nDemo\n\n"
622 +    fputs("\n\n"
623          "    Help, ?            Display this help\n"
624          "    Quit, eXit         Terminate program\n"
625 +        "    New <width> <height> <channels>\n"
626 +         "                       Creates a new empty image\n"
627          "    Load <image>       Load an image\n"
628          "    Save <image>       Save an image\n"
629          "    View               View the current image\n"
630 @@ -269,7 +301,9 @@ void Do_Help(int, const char **)
631          "    Histogram <level> <subband> <channel>\n"
632          "                       View the histogram of a subband\n"
633          "    Entropy            Calculate the first-order entropy in bits per pixel\n"
634 -        "    Yuv                Convert from RGB to YUVr (or vice versa)\n"
635 +        "    Yuv                Convert from RGB to YUVr\n"
636 +        "    Rgb                Convert from YUVr to RGB\n"
637 +        "    Quantize <lev>..   Quantizes the channels  \n"
638          "\n", stderr);
639  }
640  
641 @@ -293,8 +327,33 @@ void Do_Load(int argc, const char *argv[
642      ImageLoaded = 1;
643  }
644  
645 +
646 +void Do_New(int argc, const char *argv[])
647 +{
648 +  if (argc < 3) {
649 +    fputs("Invalid arguments\n", stderr);
650 +    return;
651 +  }
652 +  u_int w  = atoi(argv[0]);
653 +  u_int h  = atoi(argv[1]);
654 +  u_int ch = atoi(argv[2]);
655 +
656 +  /* DONT DO THIS : 
657 +     if(ImageLoaded)     MyImage.~Image();
658 +     the operator= 
659 +     here below will automatically free the memory in 
660 +     MyImage before doing the =
661 +  */
662 +  MyImage=Image(w,h,ch);
663 +  MyImage.Clear();
664 +  ImageLoaded=1;
665 +}
666 +
667 +
668  void Do_Save(int argc, const char *argv[])
669  {
670 + if (NoImage())
671 +      return;
672      if (argc > 0) {
673         delete File;
674         File = new char[strlen(argv[0])+1];
675 @@ -307,15 +366,93 @@ void Do_Save(int argc, const char *argv[
676      MyImage.Export(File);
677  }
678  
679 +
680 +void Do_Quantize(int argc, const char *argv[])
681 +{
682 + if (NoImage())
683 +      return;
684 +
685 +  if (argc >= MyImage.GetChannels()) { 
686 +    for (u_int ch = 0; ch < MyImage.GetChannels(); ch++) {
687 +      int levels=(int)atof(argv[ch]); 
688 +      if (levels <= 0) {
689 +       fputs("Specify positive number\n", stderr);
690 +       return;
691 +      }
692 +      for (u_int r = 0; r < MyImage[ch]->GetRows(); r++)
693 +       for (u_int c = 0; c < MyImage[ch]->GetCols(); c++)
694 +         {
695 +           (*MyImage[ch])(c, r) = 
696 +             levels * (s16)rint ( (*MyImage[ch])(c, r) /levels  )  ;
697 +         }
698 +    }
699 +  }
700 +  else
701 +    {
702 +      fputs("Specify number(s) for quantization of channels\n", stderr);
703 +      return;
704 +    }
705 +}
706 +
707 +#ifdef COMPRESS
708 +#include "sol/Compress.H"
709 +
710 +void Do_Compress(int argc, const char *argv[])
711 +{
712 +  int q=1;
713 +  if (NoImage())
714 +    return;
715 +  
716 +  if (argc <= 0) {
717 +    fputs("Specify file and quantization\n", stderr);
718 +    return;
719 +  }
720 +
721 +  delete File;
722 +  File = new char[strlen(argv[0])+1];
723 +  strcpy(File, argv[0]);
724 +
725 +  if (argc>1)
726 +    q=(int)atof(argv[1]);
727 +
728 +  Compress(&MyImage,File,q);
729 +}
730 +
731 +void Do_Decompress(int argc, const char *argv[])
732 +{
733
734 +  if (argc <= 0) {
735 +    fputs("Specify file\n", stderr);
736 +    return;
737 +  }
738 +  
739 +  delete File;
740 +  File = new char[strlen(argv[0])+1];
741 +  strcpy(File, argv[0]);
742 +
743 +
744 +  /* DONT DO THIS : 
745 +     if(ImageLoaded)   MyImage.~Image();
746 +     the operator= 
747 +     here below will automatically free the memory in 
748 +     MyImage before doing the =
749 +  */
750 +    
751 +  Decompress(File,&  MyImage);
752 +  ImageLoaded=1;
753 +}
754 +#endif
755 +
756  void Do_View(int, const char **)
757  {
758 -    char command[32];
759 +  /* WHO THE HELL MADE THIS STRING SIZE =32!!!!! I LOST 3 DAYS ON THIS!!!*/
760 +    char command[512];
761      if (NoImage())
762 -       return;
763 -
764 +      return;
765 +    
766      const char *filename = TmpFileName();
767      MyImage.Export(filename);
768 -    sprintf(command, "xv %s &", filename);
769 +    sprintf(command, "if which xv >/dev/null ; then xv %s & else display %s & fi", filename,filename);
770      system(command);
771  }
772  
773 @@ -530,7 +667,7 @@ void Do_Psnr(int, const char **)
774      }
775  
776      for (u_int ch = 0; ch < MyImage.GetChannels(); ch++)
777 -       printf("Channel %d: %f dB\n", ch, MyImage[ch]->Psnr(*(*Backup)[ch]));
778 +       printf("Channel %d: %g dB\n", ch, MyImage[ch]->Psnr(*(*Backup)[ch]));
779  }
780  
781  void Do_Threshold(int argc, const char *argv[])
782 @@ -601,7 +738,7 @@ void Do_Histogram(int argc, const char *
783      Channel *channel = MyImage[ch];
784      if (level == 0) {
785         if (subband != SubBand_LL) {
786 -           fputs("Subband must be 0 for this level\n", stderr);
787 +           fprintf(stderr,"Subband must be %d for this level\n",SubBand_LL );
788             return;
789         }
790      } else {
791 @@ -646,7 +783,7 @@ void Do_Histogram(int argc, const char *
792      stream.Printf("plot [%d:%d]\"%s\" title \"Level %d Subband %d [%d:%d]\" "
793                   "with impulses\n",
794                   min, max, plotdata, level, subband, min, max);
795 -    stream.Puts("pause -1\n");
796 +    stream.Puts("pause 120\n");
797      stream.Close();
798      char command[160];
799      sprintf(command, "xterm -iconic -ut -T gnuplot -e gnuplot -name \"Level "
800 @@ -665,16 +802,29 @@ void Do_Entropy(int, const char **)
801  
802  static bool is_yuv = false;
803  
804 +void Do_RGB(int, const char **)
805 +{
806 +    if (NoImage())
807 +       return;
808 +
809 +    if (is_yuv)
810 +      { MyImage.Convert(IT_RGB, IT_YUVr);     is_yuv = false; }
811 +    else
812 +      printf("Image is already rgb\n");
813 +}
814 +
815  void Do_YUV(int, const char **)
816  {
817      if (NoImage())
818         return;
819  
820      if (is_yuv)
821 -       MyImage.Convert(IT_RGB, IT_YUVr);
822 +      printf("Image is already yuv\n");
823      else
824 +      {
825         MyImage.Convert(IT_YUVr, IT_RGB);
826 -    is_yuv = !is_yuv;
827 +       is_yuv = !false;
828 +      }
829  }
830  
831  const struct Command Commands[] = {
832 @@ -684,6 +834,7 @@ const struct Command Commands[] = {
833      { "exit", Do_Quit },
834      { "x", Do_Quit },
835      { "load", Do_Load },
836 +    { "new",  Do_New },
837      { "save", Do_Save },
838      { "view", Do_View },
839      { "wavelet", Do_Wavelet },
840 @@ -699,6 +850,14 @@ const struct Command Commands[] = {
841      { "histogram", Do_Histogram },
842      { "entropy", Do_Entropy },
843      { "yuv", Do_YUV },
844 +    { "rgb", Do_RGB },
845 +    { "quantize", Do_Quantize}
846 +
847 +#ifdef COMPRESS
848 +    ,
849 +    { "compress", Do_Compress },
850 +    { "decompress", Do_Decompress }
851 +#endif
852  };
853  
854  
855 @@ -717,17 +876,66 @@ static void ParseCommandLine(char *line)
856      DeleteArgs(argc, argv);
857  }
858  
859 -
860 +#include <sys/ioctl.h>
861 +#include <sys/termios.h>
862 +#include "readline/readline.h"
863 +#include "readline/history.h"
864  int main(void)
865  {
866 -    char *line;
867 +    char *line=NULL;
868 +    char prompt=1;
869 +    struct termios ti;
870 +
871 +    srand48(1);
872 +
873 +    if( ioctl(0, TCGETS, &ti))
874 +      prompt=0;
875 +
876 +#ifdef RL_READLINE_VERSION
877 +    if(prompt) {
878 +      using_history ();
879 +      read_history (".wailiDemo_history");
880 +    }
881 +#endif
882 +
883 +    if(prompt)
884 +      fputs("Please enter your commands (`help' for help)\n\n", stdout);
885  
886 -    fputs("Please enter your commands (`help' for help)\n\n", stderr);
887 +    /* main interactive loop */
888      do {
889 -       fprintf(stderr, "demo> ");
890 -       line = ReadCommandLine();
891 -       ParseCommandLine(line);
892 -    } while (!ExitFlag);
893 +#ifdef RL_READLINE_VERSION
894 +      if(prompt) {
895 +       line = readline("demo> ");
896 +       if (line && line[0]) 
897 +         add_history (line);
898 +      }
899 +      else {
900 +       line=(char *)calloc( MAX_CMD_LINE,1);
901 +       fgets(line, MAX_CMD_LINE, stdin);
902 +      }
903 +#else
904 +      if(prompt) 
905 +        fprintf(stdout, "demo> ");       
906 +      line=(char *)calloc( MAX_CMD_LINE,1);
907 +      fgets(line, MAX_CMD_LINE, stdin);
908 +#endif      
909 +      if(line && line[0]) {
910 +       int l=strlen(line);
911 +       char *tok; char *stringp=line;
912 +       if (line[l-1]=='\n')
913 +         line[l-1]=0;
914 +       do {
915 +         tok=strsep(&stringp,";");
916 +         ParseCommandLine(tok);
917 +       } while (stringp);
918 +         
919 +      }
920 +      free(line);
921 +    } while (!ExitFlag && line);
922      CleanUp();
923 +#ifdef RL_READLINE_VERSION
924 +    if(prompt)
925 +      write_history (".wailiDemo_history");
926 +#endif
927      exit(0);
928  }
929 --- waili-19990723.orig/test/Example.C
930 +++ waili-19990723/test/Example.C
931 @@ -39,7 +39,7 @@ int main(void)
932      // Transform the image using the Cohen-Daubechies-Feauveau
933      // (2, 2) biorthogonal wavelets
934      Wavelet *wavelet = Wavelet::CreateCDF(2, 2);
935 -    u8 id = wavelet->GetID();
936 +    Wavelet_ID id = wavelet->GetID();
937      delete wavelet;
938      TransformDescriptor transform[] = {
939         { TT_ColsRows, id },
940 --- waili-19990723.orig/test/Test.C
941 +++ waili-19990723/test/Test.C
942 @@ -117,7 +117,7 @@ int main(int argc, char *argv[])
943      im1.Import(infile);
944      im2 = im1.Clone();
945      Wavelet *wavelet = Wavelet::CreateCDF(np, nd);
946 -    u8 id = wavelet->GetID();
947 +    Wavelet_ID id = wavelet->GetID();
948      delete wavelet;
949      channels = im1.GetChannels();
950      printf("%dx%dx%d picture\n", im1.GetCols(0), im1.GetRows(0), channels);
951 --- waili-19990723.orig/test/Makefile
952 +++ waili-19990723/test/Makefile
953 @@ -28,31 +28,39 @@ ALL =               Example Demo Proof Rangecheck Tes
954  All:           $(ALL)
955  
956  Example:       Example.o $(DEPLIBS)
957 -               $(CXX) -o Example Example.o $(LFLAGS)
958 +               $(LIBTOOLLD) $(CXX) -o Example Example.o $(LFLAGS)
959  
960  Demo:          Demo.o $(DEPLIBS)
961 -               $(CXX) -o Demo Demo.o $(LFLAGS)
962 +               $(LIBTOOLLD) $(CXX) -lreadline -o Demo Demo.o $(LFLAGS)
963  
964  Proof:         Proof.o $(DEPLIBS)
965 -               $(CXX) -o Proof Proof.o $(LFLAGS)
966 +               $(LIBTOOLLD) $(CXX) -o Proof Proof.o $(LFLAGS)
967  
968  Test:          Test.o $(DEPLIBS)
969 -               $(CXX) -o Test Test.o $(LFLAGS)
970 +               $(LIBTOOLLD) $(CXX) -o Test Test.o $(LFLAGS)
971  
972  Rangecheck:    Rangecheck.o $(DEPLIBS)
973 -               $(CXX) -o Rangecheck Rangecheck.o $(LFLAGS)
974 +               $(LIBTOOLLD) $(CXX) -o Rangecheck Rangecheck.o $(LFLAGS)
975  
976  Histogram:     Histogram.o $(DEPLIBS)
977 -               $(CXX) -o Histogram Histogram.o $(LFLAGS)
978 +               $(LIBTOOLLD) $(CXX) -o Histogram Histogram.o $(LFLAGS)
979  
980  
981 -depend:
982 -               rm -f .depend
983 -               $(CXX) $(CFLAGS) -M -E *.C > .depend
984 +depend: $(ALL:=.d)
985 +
986 +include $(ALL:=.d)
987 +
988  
989  clean:
990 -               rm -f .depend *.o $(ALL) result.pgm out.pgm out.ppm reco.pgm \
991 -               reco.ppm
992 +               rm -f .depend *.o *.d $(ALL) .wailiDemo_history \
993 +                       result.pgm out.pgm out.ppm reco.pgm reco.ppm 
994 +               rm -rf .libs
995 +               rm -f *.lo
996  
997  
998  include ../Rules.make
999 +
1000 +#added for Debian
1001 +install:
1002 +       $(INSTALL) -d $(DESTDIR)$(PREFIX)/lib/$(PACKAGE)/test/
1003 +       $(LIBTOOLINSTALL) $(INSTALL)  $(ALL) $(DESTDIR)$(PREFIX)/lib/$(PACKAGE)/test/
1004 --- waili-19990723.orig/lib/LChannel.C
1005 +++ waili-19990723/lib/LChannel.C
1006 @@ -20,12 +20,13 @@
1007  //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
1008  //
1009  
1010 -#include <waili/Channel.h>
1011 +
1012  #include <stdio.h>
1013 -#include <stream.h>
1014 +#include <iostream>
1015  #include <math.h>
1016  
1017 -#include <waili/Util.h>
1018 +#include "waili/Channel.h"
1019 +#include "waili/Util.h"
1020  
1021  
1022  const char *LChannel::rcsid = "$Id: LChannel.C,v 4.5.2.2.2.1 1999/07/20 16:15:49 geert Exp $";
1023 --- waili-19990723.orig/lib/Wavelet_CDF_1_x.C
1024 +++ waili-19990723/lib/Wavelet_CDF_1_x.C
1025 @@ -22,8 +22,8 @@
1026  //  $Id: Wavelet_CDF_1_x.C,v 4.1.4.1 1999/07/20 16:15:52 geert Exp $
1027  //
1028  
1029 -#include <waili/Util.h>
1030 -#include <waili/Channel.h>
1031 +#include "waili/Util.h"
1032 +#include "waili/Channel.h"
1033  
1034  
1035  const char *Wavelet_CDF_1_x::rcsid = "$Id: Wavelet_CDF_1_x.C,v 4.1.4.1 1999/07/20 16:15:52 geert Exp $";
1036 --- /dev/null
1037 +++ waili-19990723/lib/myLifting.C
1038 @@ -0,0 +1,79 @@
1039 +
1040 +#include "waili/Channel.h"
1041 +#include "waili/Util.h"
1042 +
1043 +
1044 +#define XOR(A,B) ((( (A) +128) ^ ( (B) +128)) -128)
1045 +
1046 +void LiftChannelR::Lift_bin(int type ) const
1047 +{
1048 +  PixType *even = Even,   *odd = Odd, b;
1049 +  
1050 +  for (u_int i = 0; i < Rows; i++) {    
1051 +    if( 1 ) {
1052 +      for (u_int j = 0; j < Codd; j++) {
1053 +       //even[j] = even[j]  ;
1054 +       odd[j] = XOR(even[j], odd[j]) ;
1055 +      }
1056 +    } else {
1057 +      for (u_int j = 0; j < Codd; j++) {
1058 +       b=XOR(even[j],  odd[j]);
1059 +       even[j] = odd[j] ;
1060 +       odd[j] =b;
1061 +      }}
1062 +     
1063 +    even += Ceven;
1064 +    odd += Codd;
1065 +  }
1066 +}
1067 +
1068 +
1069 +
1070 +void LiftChannelR::ILift_bin(int type ) const
1071 +{
1072 +  PixType *even = Even, b;
1073 +  PixType *odd = Odd;
1074 +  
1075 +  for (u_int i = 0; i < Rows; i++) {    
1076 +    if( 1 ) {
1077 +      for (u_int j = 0; j < Codd; j++) {  
1078 +       //odd[j] = even[j]  ^ odd[j] ;
1079 +       odd[j] = XOR(even[j], odd[j]) ;
1080 +      }} else {
1081 +       for (u_int j = 0; j < Codd; j++) {
1082 +         b=XOR(even[j], odd[j]) ;
1083 +         odd[j] = even[j] ;
1084 +         even[j] = b;
1085 +       }}
1086 +    even += Ceven;
1087 +    odd += Codd;
1088 +  }
1089 +}
1090 +
1091 +void LiftChannelC::Lift_bin(int type ) const
1092 +{
1093 +  PixType *even = Even;
1094 +  PixType *odd = Odd;
1095 +  
1096 +  for (u_int i = 0; i < Rodd; i++) {    
1097 +    for (u_int j = 0; j < Cols; j++)
1098 +      odd[j] = XOR(even[j], odd[j]) ; 
1099 +    even += Cols;
1100 +    odd += Cols;
1101 +  }
1102 +}
1103 +
1104 +void LiftChannelC::ILift_bin(int type ) const
1105 +{
1106 +  PixType *even = Even;
1107 +  PixType *odd = Odd;
1108 +  
1109 +  for (u_int i = 0; i < Rodd; i++) {    
1110 +    for (u_int j = 0; j < Cols; j++)
1111 +      odd[j] = XOR(even[j], odd[j]) ;
1112 +    even += Cols;
1113 +    odd += Cols;
1114 +  }
1115 +}
1116 +
1117 +
1118 --- waili-19990723.orig/lib/LChannelR.C
1119 +++ waili-19990723/lib/LChannelR.C
1120 @@ -20,12 +20,13 @@
1121  //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
1122  //
1123  
1124 -#include <waili/Channel.h>
1125 -#include <waili/Util.h>
1126  #include <stdio.h>
1127 -#include <stream.h>
1128 +#include <iostream>
1129  #include <math.h>
1130  
1131 +#include "waili/Channel.h"
1132 +#include "waili/Util.h"
1133 +
1134  
1135  const char *LChannelR::rcsid = "$Id: LChannelR.C,v 4.6.2.1.2.1 1999/07/20 16:15:51 geert Exp $";
1136  
1137 --- waili-19990723.orig/lib/Image.C
1138 +++ waili-19990723/lib/Image.C
1139 @@ -22,13 +22,15 @@
1140  
1141  #include <string.h>
1142  
1143 -#include <waili/Image.h>
1144 -#include <waili/Util.h>
1145 -#include <waili/Blit.h>
1146 -
1147 -#include <waili/Timer.h>
1148 -#include <waili/Storage.h>
1149 -#include <waili/Color.h>
1150 +#include <fstream>
1151 +
1152 +#include "waili/Image.h"
1153 +#include "waili/Util.h"
1154 +#include "waili/Blit.h"
1155 +
1156 +#include "waili/Timer.h"
1157 +#include "waili/Storage.h"
1158 +#include "waili/Color.h"
1159  
1160  #include <errno.h>
1161  
1162 @@ -43,7 +45,7 @@ const char *Image::rcsid = "$Id: Image.C
1163  Image::Image(u_int cols, u_int rows, u_int channels)
1164      : NumChannels(channels), Channels(NULL)
1165  {
1166 -    Channels = new (Channel *)[NumChannels];
1167 +    Channels = new Channel *[NumChannels];
1168      for (u_int ch = 0; ch < NumChannels; ch++)
1169         Channels[ch] = new NTChannel(cols, rows);
1170  }
1171 @@ -51,15 +53,15 @@ Image::Image(u_int cols, u_int rows, u_i
1172  Image::Image(const u_int cols[], const u_int rows[], u_int channels)
1173      : NumChannels(channels), Channels(NULL)
1174  {
1175 -    Channels = new (Channel *)[NumChannels];
1176 +    Channels = new Channel *[NumChannels];
1177      for (u_int ch = 0; ch < NumChannels; ch++)
1178         Channels[ch] = new NTChannel(cols[ch], rows[ch]);
1179  }
1180  
1181 -Image::Image(const Channel &channel, u_int channels = 1)
1182 +Image::Image(const Channel &channel, u_int channels)
1183      : NumChannels(channels), Channels(NULL)
1184  {
1185 -    Channels = new (Channel *)[NumChannels];
1186 +    Channels = new Channel *[NumChannels];
1187      for (u_int ch = 0; ch < NumChannels; ch++)
1188         Channels[ch] = channel.Clone();
1189  }
1190 @@ -67,7 +69,7 @@ Image::Image(const Channel &channel, u_i
1191  Image::Image(const Channel *channel[], u_int channels)
1192      : NumChannels(channels), Channels(NULL)
1193  {
1194 -    Channels = new (Channel *)[NumChannels];
1195 +    Channels = new Channel *[NumChannels];
1196      for (u_int ch = 0; ch < NumChannels; ch++)
1197         Channels[ch] = channel[ch]->Clone();
1198  }
1199 @@ -75,7 +77,7 @@ Image::Image(const Channel *channel[], u
1200  Image::Image(const Image &im)
1201      : NumChannels(im.NumChannels), Channels(NULL)
1202  {
1203 -    Channels = new (Channel *)[NumChannels];
1204 +    Channels = new Channel *[NumChannels];
1205      for (u_int ch = 0; ch < NumChannels; ch++)
1206         Channels[ch] = im.Channels[ch]->Clone();
1207  }
1208 @@ -84,7 +86,7 @@ Image::Image(u_int cols, u_int rows, con
1209              u_int depth, u_int channels)
1210      : NumChannels(channels), Channels(NULL)
1211  {
1212 -    Channels = new (Channel *)[NumChannels];
1213 +    Channels = new Channel *[NumChannels];
1214      for (u_int ch = 0; ch < NumChannels; ch++)
1215         Channels[ch] = Channel::CreateFromDescriptor(cols, rows, transform,
1216                                                      depth);
1217 @@ -165,8 +167,8 @@ void Image::Export(const char *filename,
1218  
1219      //  Static Routines
1220  
1221 -static u8 GetRealChar(Stream &stream);
1222 -static u_int GetNumber(Stream &stream);
1223 +//static u8 GetRealChar(std::ifstream &stream);
1224 +//static u_int GetNumber(std::ifstream &stream);
1225  
1226  
1227      //  Import an Image from a File in the PNM (PGM or PPM) Format
1228 @@ -174,16 +176,17 @@ static u_int GetNumber(Stream &stream);
1229  ImageType Image::ImportPNM(const char *filename)
1230  {
1231      ImageType res;
1232 -    Stream stream(filename, "r");
1233 +    std::ifstream stream(filename, std::ios::in | std::ios::binary);
1234      u_int cols, rows, channels;
1235      u_int c, r, ch;
1236 -    u8 d, magic;
1237 +    unsigned char d, magic;
1238      int raw = 0;
1239 -
1240 -    stream.Read(magic);
1241 -    if (magic != 'P')
1242 -       Die("%s: Not a PNM file\n", __FUNCTION__);
1243 -    stream.Read(magic);
1244 +    char str[256];
1245 +        
1246 +    stream.getline(str,5);
1247 +    if (str[0] != 'P')
1248 +       Die("%s: Not a PNM file, magic is '%c' \n", __FUNCTION__,str[0]);
1249 +    magic=str[1];
1250      switch (magic) {
1251         case '1':       // PBM ASCII
1252         case '4':       // PBM Raw
1253 @@ -208,22 +211,33 @@ ImageType Image::ImportPNM(const char *f
1254             Die("%s: Not a PNM file\n", __FUNCTION__);
1255             break;
1256      }
1257 -    cols = GetNumber(stream);
1258 -    rows = GetNumber(stream);
1259 -    GetNumber(stream);
1260 +    stream.getline(str,255);
1261 +    while(str[0]=='#' || str[0] == '\n' )
1262 +      stream.getline(str,255);
1263 +
1264 +    sscanf(str,"%d %d",        &cols,   &rows);
1265 +
1266 +    stream.getline(str,255);
1267 +    while(str[0]=='#' || str[0] == '\n' )
1268 +      stream.getline(str,255);
1269 +
1270 +    if ( strcmp(str,"255") &&  strcmp(str,"255\n") )
1271 +      Die("%s: PNM file has '%s' != '255' \n", __FUNCTION__,str);
1272 +
1273      Resize(cols, rows, channels);
1274      if (raw)
1275         for (r = 0; r < rows; r++)
1276             for (c = 0; c < cols; c++)
1277                 for (ch = 0; ch < channels; ch++) {
1278 -                   stream.Read(d);
1279 +                 d=stream.get();
1280                     (*this)(c, r, ch) = (PixType)(d-128);
1281                 }
1282      else
1283 -       for (r = 0; r < rows; r++)
1284 -           for (c = 0; c < cols; c++)
1285 -               for (ch = 0; ch < channels; ch++)
1286 -                   (*this)(c, r, ch) = (PixType)(GetNumber(stream)-128);
1287 +      Die(" ascii PNM not implemented");
1288 +    // for (r = 0; r < rows; r++)
1289 +    //     for (c = 0; c < cols; c++)
1290 +    //         for (ch = 0; ch < channels; ch++)
1291 +    //             (*this)(c, r, ch) = (PixType)(GetNumber(stream)-128);
1292      return(res);
1293  }
1294  
1295 @@ -380,8 +394,8 @@ ImageType Image::ImportTIFF(const char *
1296  
1297  void Image::ExportPNM(const char *filename, int raw)
1298  {
1299 -    Stream stream(filename, "w");
1300 -    u8 magic, d;
1301 +    std::fstream stream(filename, std::ios::binary | std::ios::out);
1302 +    unsigned char magic, d;
1303      PixType val;
1304      u_int cols = GetCols(0);
1305      u_int rows = GetRows(0);
1306 @@ -406,9 +420,8 @@ void Image::ExportPNM(const char *filena
1307      if (raw)
1308         magic += 3;
1309  
1310 -    stream.Printf("P%c\n%d %d\n255", magic, cols, rows);
1311 +    stream << 'P' << magic << "\n" << cols << ' ' << rows << "\n255\n";
1312      if (raw) {
1313 -       stream.Write((u8)'\n');
1314         for (u_int r = 0; r < rows; r++)
1315             for (u_int c = 0; c < cols; c++)
1316                 for (u_int ch = 0; ch < channels; ch++) {
1317 @@ -419,7 +432,7 @@ void Image::ExportPNM(const char *filena
1318                         d = 255;
1319                     else
1320                         d = (u8)val;
1321 -                   stream.Write(d);
1322 +                   stream << d;
1323                 }
1324      } else {
1325         u_int l = 70;
1326 @@ -434,13 +447,13 @@ void Image::ExportPNM(const char *filena
1327                     else
1328                         d = (u8)val;
1329                     l += 4;
1330 +                   stream <<  (u_int)d;
1331                     if (l >= 70) {
1332 -                       stream.Printf("\n%4d", (u_int)d);
1333 +                     stream << "\n";
1334                         l = 3;
1335 -                   } else
1336 -                       stream.Printf(" %4d", (u_int)d);
1337 +                   }
1338                 }
1339 -       stream.Write((u8)'\n');
1340 +       stream << '\n';
1341      }
1342  }
1343  
1344 @@ -719,42 +732,42 @@ conversion_not_supported:
1345  }
1346  
1347  
1348 -    //  Read the Next Character from a PNM File and Care about Comments
1349 +//     //  Read the Next Character from a PNM File and Care about Comments
1350  
1351 -static u8 GetRealChar(Stream &stream)
1352 -{
1353 -    u8 c;
1354 -
1355 -    for (stream.Read(c); c == '#'; stream.Read(c))
1356 -       do
1357 -           stream.Read(c);
1358 -       while (c != '\n');
1359 -    return(c);
1360 -}
1361 -
1362 -
1363 -    //  Skip Leading Whitespace and Read an ASCII Number from a PNM File
1364 -
1365 -static u_int GetNumber(Stream &stream)
1366 -{
1367 -    u_int value = 0;
1368 -    u8 c;
1369 -
1370 -    do
1371 -       c = GetRealChar(stream);
1372 -    while ((c == ' ') || (c == '\t') || (c == '\r') || (c == '\n'));
1373 -    while (1) {
1374 -       if ((c >= '0') && (c <= '9')) {
1375 -           value = 10*value+(c-'0');
1376 -           c = GetRealChar(stream);
1377 -           continue;
1378 -       }
1379 -       if ((c == ' ') || (c == '\t') || (c == '\r') || (c == '\n'))
1380 -           break;
1381 -       Die("%s: Not a number\n", __FUNCTION__);
1382 -    }
1383 -    return(value);
1384 -}
1385 +// static u8 GetRealChar(std::ifstream &stream)
1386 +// {
1387 +//     unsigned int c;
1388 +
1389 +//     for (c=stream.get(); c == '#'; )
1390 +//     do
1391 +//       c=stream.get();
1392 +//     while (c != '\n');
1393 +//     return(c);
1394 +// }
1395 +
1396 +
1397 +//     //  Skip Leading Whitespace and Read an ASCII Number from a PNM File
1398 +
1399 +// static u_int GetNumber(std::ifstream &stream)
1400 +// {
1401 +//     u_int value = 0;
1402 +//     u8 c;
1403 +
1404 +//     do
1405 +//     c = GetRealChar(stream);
1406 +//     while ((c == ' ') || (c == '\t') || (c == '\r') || (c == '\n'));
1407 +//     while (1) {
1408 +//     if ((c >= '0') && (c <= '9')) {
1409 +//         value = 10*value+(c-'0');
1410 +//         c = GetRealChar(stream);
1411 +//         continue;
1412 +//     }
1413 +//     if ((c == ' ') || (c == '\t') || (c == '\r') || (c == '\n'))
1414 +//         break;
1415 +//     Die("%s: Not a number\n", __FUNCTION__);
1416 +//     }
1417 +//     return(value);
1418 +// }
1419  
1420  
1421  // ---------------------------------------------------------------------------
1422 @@ -769,7 +782,7 @@ void Image::Resize(u_int cols, u_int row
1423         delete Channels[ch];
1424      delete[] Channels;
1425      NumChannels = channels;
1426 -    Channels = new (Channel *)[NumChannels];
1427 +    Channels = new Channel *[NumChannels];
1428      for (u_int ch = 0; ch < NumChannels; ch++)
1429         Channels[ch] = new NTChannel(cols, rows);
1430  }
1431 @@ -781,7 +794,7 @@ Image& Image::operator=(const Image &im)
1432             delete Channels[ch];
1433         delete[] Channels;
1434         NumChannels = im.NumChannels;
1435 -       Channels = new (Channel *)[NumChannels];
1436 +       Channels = new Channel *[NumChannels];
1437         for (u_int ch = 0; ch < NumChannels; ch++)
1438             Channels[ch] = im[ch]->Clone();
1439      }
1440 @@ -790,7 +803,7 @@ Image& Image::operator=(const Image &im)
1441  
1442  void Image::InsertChannel(const Channel &data, u_int channel)
1443  {
1444 -    Channel **newChannels = new (Channel *)[++NumChannels];
1445 +    Channel **newChannels = new Channel *[++NumChannels];
1446      for (u_int ch = 0; ch < channel; ch++)
1447         newChannels[ch] = Channels[ch];
1448      for (u_int ch = channel+1; ch < NumChannels; ch++)
1449 @@ -802,7 +815,7 @@ void Image::InsertChannel(const Channel
1450  
1451  void Image::DeleteChannel(u_int channel)
1452  {
1453 -    Channel **newChannels = new (Channel *)[--NumChannels];
1454 +    Channel **newChannels = new Channel *[--NumChannels];
1455      for (u_int ch = 0; ch < channel; ch++)
1456         newChannels[ch] = Channels[ch];
1457      for (u_int ch = channel; ch < NumChannels; ch++)
1458 --- waili-19990723.orig/lib/Color.C
1459 +++ waili-19990723/lib/Color.C
1460 @@ -22,8 +22,8 @@
1461  
1462  #include <math.h>
1463  
1464 -#include <waili/Color.h>
1465 -#include <waili/Util.h>
1466 +#include "waili/Color.h"
1467 +#include "waili/Util.h"
1468  
1469  
1470  const char *ColorSpace::rcsid = "$Id: Color.C,v 4.0.2.1.2.1 1999/07/20 16:15:49 geert Exp $";
1471 --- waili-19990723.orig/lib/Channel.C
1472 +++ waili-19990723/lib/Channel.C
1473 @@ -20,11 +20,14 @@
1474  //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
1475  //
1476  
1477 -#include <waili/Channel.h>
1478 +#include "waili/Channel.h"
1479  #include <stdio.h>
1480 -#include <iostream.h>
1481 +#include <iostream>
1482  #include <math.h>
1483  
1484 +/* needed on  Debian > 2.2 */
1485 +#include <float.h>
1486 +
1487  
1488  const char *Channel::rcsid = "$Id: Channel.C,v 4.4.2.2.2.1 1999/07/20 16:15:49 geert Exp $";
1489  
1490 @@ -75,17 +78,26 @@ double Channel::Psnr(const Channel &chan
1491      if (Cols != channel.GetCols() || Rows != channel.GetRows())
1492         return(-DBL_MAX);
1493  
1494 +    double mse=MSE(channel);
1495 +    if (mse == 0)
1496 +       return(DBL_MAX);
1497 +    double rmse=sqrt(mse);
1498 +    double psnr = 20.0*log10(maxval/rmse);
1499 +    return(psnr);
1500 +}
1501 +
1502 +double Channel::MSE(const Channel &channel) const
1503 +{
1504 +    if (Cols != channel.GetCols() || Rows != channel.GetRows())
1505 +       return(-1);
1506 +
1507      u64 ss = 0;
1508      for (u_int r = 0; r < Rows; r++)
1509         for (u_int c = 0; c < Cols; c++) {
1510             int d = (*this)(c, r)-channel(c, r);
1511             ss += d*d;
1512         }
1513 -    if (ss == 0)
1514 -       return(DBL_MAX);
1515 -    double rmse = sqrt((double)ss/(double)(Cols*Rows));
1516 -    double psnr = 20.0*log10(maxval/rmse);
1517 -    return(psnr);
1518 +    return ((double)ss/(double)(Cols*Rows));
1519  }
1520  
1521  double Channel::Entropy(void) const
1522 --- /dev/null
1523 +++ waili-19990723/lib/Wavelet_bin.C
1524 @@ -0,0 +1,27 @@
1525 +
1526 +
1527 +#include <math.h>
1528 +#include <limits.h>
1529 +
1530 +#include "waili/Lifting.h"
1531 +#include "waili/Wavelet.h"
1532 +
1533 +void Wavelet_Binary::CakeWalk(Lifting &lifting) const
1534 +{
1535 +  lifting.Lift_bin(0);
1536 +}
1537 +
1538 +void Wavelet_Binary::ICakeWalk(Lifting &lifting) const
1539 +{
1540 +  lifting.ILift_bin(0);
1541 +}
1542 +
1543 +Wavelet_Binary::Wavelet_Binary()
1544 +{
1545 +
1546 +}
1547 +
1548 +Wavelet_Binary *Wavelet_Binary::Clone(void) const
1549 +{
1550 +    return(new Wavelet_Binary(*this));
1551 +}
1552 --- waili-19990723.orig/lib/Storage.C
1553 +++ waili-19990723/lib/Storage.C
1554 @@ -22,12 +22,19 @@
1555  
1556  #include <stdarg.h>
1557  #include <errno.h>
1558 +
1559 +#ifdef __WIN32__
1560 +#include "winsock.h"
1561 +#else
1562  #include <netinet/in.h>
1563 +#endif
1564  
1565 -#include <waili/Util.h>
1566 -#include <waili/Storage.h>
1567 +#include <sys/param.h>
1568  
1569  
1570 +#include "waili/Storage.h"
1571 +#include "waili/Util.h"
1572 +
1573  const char *Stream::rcsid = "$Id: Storage.C,v 4.0.2.2.2.1 1999/07/20 16:15:52 geert Exp $";
1574  
1575  
1576 @@ -144,6 +151,9 @@ void Stream::Printf(const char *fmt, ...
1577  
1578      //  Endianness-aware Routines
1579  
1580 +
1581 +
1582 +
1583  #if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && defined(LITTLE_ENDIAN)
1584      #if BYTE_ORDER == BIG_ENDIAN
1585         #define WAILI_BIG_ENDIAN
1586 @@ -154,6 +164,7 @@ void Stream::Printf(const char *fmt, ...
1587      #define WAILI_BIG_ENDIAN
1588  #elif defined(__LITTLE_ENDIAN) || defined(_LITTLE_ENDIAN)
1589      #define WAILI_LITTLE_ENDIAN
1590 +
1591  #endif
1592  #if !defined(WAILI_BIG_ENDIAN) && !defined(WAILI_LITTLE_ENDIAN)
1593  #error Please fix me
1594 --- waili-19990723.orig/lib/Wavelet_CDF_2_x.C
1595 +++ waili-19990723/lib/Wavelet_CDF_2_x.C
1596 @@ -22,8 +22,8 @@
1597  //  $Id: Wavelet_CDF_2_x.C,v 4.2.2.1.2.1 1999/07/20 16:15:52 geert Exp $
1598  //
1599  
1600 -#include <waili/Util.h>
1601 -#include <waili/Channel.h>
1602 +#include "waili/Util.h"
1603 +#include "waili/Channel.h"
1604  
1605  
1606  const char *Wavelet_CDF_2_x::rcsid = "$Id: Wavelet_CDF_2_x.C,v 4.2.2.1.2.1 1999/07/20 16:15:52 geert Exp $";
1607 --- waili-19990723.orig/lib/LChannelCR.C
1608 +++ waili-19990723/lib/LChannelCR.C
1609 @@ -20,12 +20,14 @@
1610  //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
1611  //
1612  
1613 -#include <waili/Channel.h>
1614 -#include <waili/Util.h>
1615  #include <stdio.h>
1616 -#include <stream.h>
1617 +#include <iostream>
1618  #include <math.h>
1619  
1620 +#include "waili/Channel.h"
1621 +#include "waili/Util.h"
1622 +
1623 +
1624  
1625  const char *LChannelCR::rcsid = "$Id: LChannelCR.C,v 4.6.2.1.2.1 1999/07/20 16:15:50 geert Exp $";
1626  
1627 --- waili-19990723.orig/lib/Wavelet_CDF_4_x.C
1628 +++ waili-19990723/lib/Wavelet_CDF_4_x.C
1629 @@ -22,8 +22,8 @@
1630  //  $Id: Wavelet_CDF_4_x.C,v 4.2.2.1.2.1 1999/07/20 16:15:52 geert Exp $
1631  //
1632  
1633 -#include <waili/Util.h>
1634 -#include <waili/Channel.h>
1635 +#include "waili/Util.h"
1636 +#include "waili/Channel.h"
1637  
1638  
1639  const char *Wavelet_CDF_4_x::rcsid = "$Id: Wavelet_CDF_4_x.C,v 4.2.2.1.2.1 1999/07/20 16:15:52 geert Exp $";
1640 --- waili-19990723.orig/lib/Wavelet_JPEG2000.C
1641 +++ waili-19990723/lib/Wavelet_JPEG2000.C
1642 @@ -22,7 +22,7 @@
1643  //  $Id: Wavelet_JPEG2000.C,v 5.1.2.1.2.1 1999/07/20 16:15:53 geert Exp $
1644  //
1645  
1646 -#include <waili/Wavelet.h>
1647 +#include "waili/Wavelet.h"
1648  
1649  
1650      //  Biorthogonal CRF (13, 7)
1651 --- waili-19990723.orig/lib/Wavelet.C
1652 +++ waili-19990723/lib/Wavelet.C
1653 @@ -20,8 +20,8 @@
1654  //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
1655  //
1656  
1657 -#include <waili/Util.h>
1658 -#include <waili/Channel.h>
1659 +#include "waili/Util.h"
1660 +#include "waili/Channel.h"
1661  
1662  
1663  //
1664 @@ -483,7 +483,7 @@ Wavelet *Wavelet::CreateCDF(u_int np, u_
1665  
1666      //  Create a Wavelet from an ID
1667  
1668 -Wavelet *Wavelet::CreateFromID(u8 id)
1669 +Wavelet *Wavelet::CreateFromID(Wavelet_ID id)
1670  {
1671      switch (id) {
1672         case ID_CDF_1_1:
1673 --- waili-19990723.orig/lib/Util.C
1674 +++ waili-19990723/lib/Util.C
1675 @@ -23,21 +23,32 @@
1676  #include <stdarg.h>
1677  #include <stdio.h>
1678  #include <stdlib.h>
1679 +#include <string.h>
1680  
1681 -#include <waili/Types.h>
1682 -#include <waili/Util.h>
1683 +#include "waili/Types.h"
1684 +#include "waili/Util.h"
1685  
1686 +#include "exception"
1687  
1688      //  Program Failure
1689  
1690 +static char ERRSTR[512];
1691 +
1692  void Die(const char *fmt, ...)
1693  {
1694 +    ERRSTR[0]=0;
1695 +    
1696      va_list args;
1697 -
1698 +  
1699      va_start(args, fmt);
1700 -    vfprintf(stderr, fmt, args);
1701 +    vsnprintf(ERRSTR+strlen(ERRSTR), 512, fmt, args);
1702      va_end(args);
1703 -    exit(1);
1704 +    fprintf(stderr,ERRSTR);
1705 +    //exception e;//=new exception();
1706 +    //e->what=ERRSTR;
1707 +    char *e=ERRSTR;
1708 +    throw e;
1709 +    
1710  }
1711  
1712  
1713 --- /dev/null
1714 +++ waili-19990723/lib/myLifting.C,v
1715 @@ -0,0 +1,99 @@
1716 +head   1.1;
1717 +access;
1718 +symbols;
1719 +locks
1720 +       andrea:1.1; strict;
1721 +comment        @ * @;
1722 +
1723 +
1724 +1.1
1725 +date   2001.09.16.20.24.12;    author andrea;  state Exp;
1726 +branches;
1727 +next   ;
1728 +
1729 +
1730 +desc
1731 +@@
1732 +
1733 +
1734 +1.1
1735 +log
1736 +@Initial revision
1737 +@
1738 +text
1739 +@
1740 +
1741 +void LiftChannelR::Lift_bin(int type ) const
1742 +{
1743 +  PixType *even = Even,   *odd = Odd, b;
1744 +  
1745 +  for (u_int i = 0; i < Rows; i++) {    
1746 +    if( i & 1 ) {
1747 +      for (u_int j = 0; j < Codd; j++) {
1748 +       //even[j] = even[j]  ;
1749 +       odd[j] = even[j]  ^ odd[j] ;
1750 +      }
1751 +    } else {
1752 +      for (u_int j = 0; j < Codd; j++) {
1753 +       b=even[j]  ^  odd[j];
1754 +       even[j] = odd[j] ;
1755 +       odd[j] =b;
1756 +      }}
1757 +     
1758 +    even += Ceven;
1759 +    odd += Codd;
1760 +  }
1761 +}
1762 +
1763 +
1764 +
1765 +void LiftChannelR::ILift_bin(int type ) const
1766 +{
1767 +  PixType *even = Even, b;
1768 +  PixType *odd = Odd;
1769 +  
1770 +  for (u_int i = 0; i < Rows; i++) {    
1771 +    if( i & 1 ) {
1772 +      for (u_int j = 0; j < Codd; j++) {  
1773 +       odd[j] = even[j]  ^ odd[j] ;
1774 +      }} else {
1775 +       for (u_int j = 0; j < Codd; j++) {
1776 +         b=even[j]  ^  odd[j]; 
1777 +         odd[j] = even[j] ;
1778 +         even[j] = b;
1779 +       }}
1780 +    even += Ceven;
1781 +    odd += Codd;
1782 +  }
1783 +}
1784 +
1785 +void LiftChannelC::Lift_bin(int type ) const
1786 +{
1787 +  PixType *even = Even;
1788 +  PixType *odd = Odd;
1789 +  
1790 +  for (u_int i = 0; i < Rodd; i++) {    
1791 +    for (u_int j = 0; j < Cols; j++)
1792 +      odd[j] = 64 * ( (even[j] >0) ^ (odd[j] >0));
1793 +    for (u_int j = 0; j < Cols; j++)
1794 +      even[j] = 64 * ( (even[j] >0) );
1795 +    even += Cols;
1796 +    odd += Cols;
1797 +  }
1798 +}
1799 +
1800 +void LiftChannelC::ILift_bin(int type ) const
1801 +{
1802 +  PixType *even = Even;
1803 +  PixType *odd = Odd;
1804 +  
1805 +  for (u_int i = 0; i < Rodd; i++) {    
1806 +    for (u_int j = 0; j < Cols; j++)
1807 +      odd[j] = 64 * ( (even[j] >0) ^ (odd[j] >0));
1808 +    even += Cols;
1809 +    odd += Cols;
1810 +  }
1811 +}
1812 +
1813 +
1814 +@
1815 --- waili-19990723.orig/lib/NTChannel.C
1816 +++ waili-19990723/lib/NTChannel.C
1817 @@ -20,12 +20,13 @@
1818  //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
1819  //
1820  
1821 -#include <waili/Channel.h>
1822 -#include <waili/Util.h>
1823  #include <stdio.h>
1824 -#include <stream.h>
1825 +#include <iostream>
1826  #include <math.h>
1827  
1828 +#include "waili/Channel.h"
1829 +#include "waili/Util.h"
1830 +
1831  
1832  const char *NTChannel::rcsid = "$Id: NTChannel.C,v 4.12.2.3.2.1 1999/07/20 16:15:51 geert Exp $";
1833  
1834 @@ -163,8 +164,10 @@ s32 *NTChannel::Correlate(const NTChanne
1835  void NTChannel::Enhance(f32 m)
1836  {
1837      for (u_int r = 0; r < Rows; r++)
1838 -       for (u_int c = 0; c < Cols; c++)
1839 -          (*this)(c, r) = PixType(m*(*this)(c, r));
1840 +      for (u_int c = 0; c < Cols; c++) {
1841 +       f32 v=(*this)(c, r);
1842 +       (*this)(c, r) = PixType( floor(m*v+0.5) );
1843 +      }
1844  }
1845  
1846  void NTChannel::Enhance(int m, u_int shift)
1847 @@ -391,7 +394,7 @@ void NTChannel::Destroy(void)
1848      Cols = Rows = OffsetX = OffsetY = 0;
1849  }
1850  
1851 -void NTChannel::GetMinMax(PixType &min, PixType &max, u_int smoothing = 0) const
1852 +void NTChannel::GetMinMax(PixType &min, PixType &max, u_int smoothing) const
1853  {
1854      if (smoothing != 0)
1855         Die("%s: Smoothing isn't implemented yet!\n", __FUNCTION__);
1856 --- waili-19990723.orig/lib/LChannelC.C
1857 +++ waili-19990723/lib/LChannelC.C
1858 @@ -20,12 +20,13 @@
1859  //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
1860  //
1861  
1862 -#include <waili/Channel.h>
1863 -#include <waili/Util.h>
1864  #include <stdio.h>
1865 -#include <stream.h>
1866 +#include <iostream>
1867  #include <math.h>
1868  
1869 +#include "waili/Channel.h"
1870 +#include "waili/Util.h"
1871 +
1872  
1873  const char *LChannelC::rcsid = "$Id: LChannelC.C,v 4.6.2.1.2.1 1999/07/20 16:15:49 geert Exp $";
1874  
1875 --- /dev/null
1876 +++ waili-19990723/lib/Wavelet_gain.C
1877 @@ -0,0 +1,66 @@
1878 +
1879 +#include "waili/Wavelet.h"
1880 +#include "waili/Channel.h"
1881 +#include <stdlib.h>
1882 +
1883 +double *wavelet_gaussian_variance_gain_by_type(u8  type)
1884 +{ 
1885 +  switch(type) {
1886 +  case 100: 
1887 +  case 101: 
1888 +    { static double g[2]={ 0.647, 1.647  }; return g;}
1889 +  case 1:
1890 +  case 2:
1891 +  case 3:
1892 +    { static double g[2]={ 0.50, 2.00 };return g;}
1893 +  case 4:
1894 +  case 5:
1895 +  case 6:
1896 +    { static double g[2]={ 0.71, 1.50 };return g;}
1897 +  case 7:
1898 +    { static double g[2]={ 1.90, 4.43 };return g;}
1899 +  case 8:
1900 +  case 9:
1901 +    { static double g[2]={ 1.63, 4.43 };return g;}
1902 +  default: { abort(); static double g[2]={ 1.0, 1.0  }; return g;}
1903 +  }
1904 +}
1905 +
1906 +
1907 +double *wavelet_gaussian_variance_gain(Channel *C)
1908 +{  
1909 +  TransformType  t= ((LChannel *)C)->GetTransformType();
1910 +  TransformDescriptor *td=((LChannel *)C)->GetTransform();
1911 +  //assert ( t == td->type);
1912 +  double *gg=wavelet_gaussian_variance_gain_by_type(td->filter);
1913 +  if ( t == TT_ColsRows) {
1914 +    double *g=new double[4];
1915 +    g[0]= gg[0] * gg[0]; g[1]=g[2]= (gg[0]*gg[1]); g[3]= gg[1] * gg[1];
1916 +    return g;
1917 +  } else { double *g=new double[4]; g[0]= gg[0]; g[1]=gg[1]; return g;}
1918 +}
1919 +
1920 +double *wavelet_uniform_maximum_gain(int type)
1921 +{ 
1922 +  switch(type) {
1923 +  case 100: //ID_CRF_13_7
1924 +  case 101: //ID_SWE_13_7
1925 +    {  static double g[2]={ 1.45, 2.2  }; return g;}
1926 +  case 1://ID_CDF_1_1
1927 +  case 2:// ID_CDF_1_
1928 +  case 3://ID_CDF_1_5
1929 +    {  static double g[2]={ 1.2, 2.0 };return g;}
1930 +  case 4://ID_CDF_2_2 = 4
1931 +  case 5://ID_CDF_2_4
1932 +  case 6://ID_CDF_2_6
1933 +    {  static double g[2]={ 1.5, 2.0 };return g;}
1934 +  case 7://ID_CDF_4_2
1935 +    {  static double g[2]={ 2.2, 3.8 };return g;}
1936 +  case 8://ID_CDF_4_4
1937 +  case 9://ID_CDF_4_6
1938 +    {  static double g[2]={ 2.3, 3.8 };return g;}
1939 +  default: {  static double g[2]={ 1.0, 1.0  }; return g;}
1940 +  }
1941 +}
1942 +
1943 +
1944 --- waili-19990723.orig/lib/Timer.C
1945 +++ waili-19990723/lib/Timer.C
1946 @@ -24,11 +24,11 @@
1947  #include <sys/times.h>
1948  #include <assert.h>
1949  
1950 -#include <waili/Timer.h>
1951 +#include "waili/Timer.h"
1952  
1953  
1954 -#if defined(sun) && !defined(CLK_TCK)  // SunOS
1955 -#define CLK_TCK        60
1956 +#if defined(sun) && !defined(CLOCKS_PER_SEC)   // SunOS
1957 +#define CLOCKS_PER_SEC 60
1958  #endif
1959  
1960  
1961 @@ -100,7 +100,7 @@ f32 Timer::GetReal(void) const
1962      } else
1963         real = Real;
1964  
1965 -    return((f32)real/CLK_TCK);
1966 +    return((f32)real/CLOCKS_PER_SEC);
1967  }
1968  
1969  
1970 @@ -116,7 +116,7 @@ f32 Timer::GetUser(void) const
1971      } else
1972         user = User;
1973  
1974 -    return((f32)user/CLK_TCK);
1975 +    return((f32)user/CLOCKS_PER_SEC);
1976  }
1977  
1978  
1979 @@ -132,7 +132,7 @@ f32 Timer::GetSystem(void) const
1980      } else
1981         system = System;
1982  
1983 -    return((f32)system/CLK_TCK);
1984 +    return((f32)system/CLOCKS_PER_SEC);
1985  }
1986  
1987  
1988 @@ -175,8 +175,8 @@ void Timer::Toc(void)
1989      t = GetStamp();
1990  
1991      fprintf(stderr, "Real = %10.3f   User = %10.3f   System = %10.3f\n",
1992 -             (f32)t.Real/CLK_TCK, (f32)t.User/CLK_TCK,
1993 -             (f32)t.System/CLK_TCK);
1994 +             (f32)t.Real/CLOCKS_PER_SEC, (f32)t.User/CLOCKS_PER_SEC,
1995 +             (f32)t.System/CLOCKS_PER_SEC);
1996  }
1997  
1998  
1999 --- waili-19990723.orig/lib/Lifting.C
2000 +++ waili-19990723/lib/Lifting.C
2001 @@ -20,7 +20,8 @@
2002  //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
2003  //
2004  
2005 -#include <waili/Channel.h>
2006 +#include "waili/Channel.h"
2007 +#include "waili/Util.h"
2008  
2009  
2010  const char *Lifting::rcsid = "$Id: Lifting.C,v 4.5.2.1.2.1 1999/07/20 16:15:51 geert Exp $";
This page took 1.45938 seconds and 3 git commands to generate.