summaryrefslogtreecommitdiffstats
path: root/tksao/fitsy++/compress.h
blob: 938de7b9b5490467c7e6fb9045a020a7c4adacc3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// Copyright (C) 1999-2016
// Smithsonian Astrophysical Observatory, Cambridge, MA, USA
// For conditions of distribution and use, see copyright notice in "copyright"

#ifndef __fitscompress_h__
#define __fitscompress_h__

#include "file.h"

class FitsCompress : public FitsFile {
 public:
  enum QuantMethod {NODITHER,SUBDITHER1,SUBDITHER2};

 protected:
  int bitpix_;
  char* type_;
  int width_;
  int height_;
  int depth_;
  int ww_;
  int hh_;
  int dd_;
  double bscale_;
  double bzero_;
  unsigned int blank_;
  char* zmaskcmp_;
  
  size_t tilesize_;
  size_t size_;

  FitsColumn* gzcompress_;
  FitsColumn* compress_;
  FitsColumn* uncompress_;
  FitsColumn* zscale_;
  FitsColumn* zzero_;
  FitsColumn* zblank_;
  FitsColumn* null_;

  int hasScaling_;
  int hasBlank_;

  QuantMethod quantize_;
  int quantOffset_;

  int numRandom_;
  float* random_;
  int randSeed_;
  int randNext_;

 protected:
  int initHeader(FitsFile*);
  void initRandom(int);

  double unquantize(double, double, double);
  double unquantizeZero(double, double, double);

 public:
  FitsCompress(FitsFile*);
  virtual ~FitsCompress();
};

template<class T>
class FitsCompressm : public FitsCompress {
 private:
  int inflate(FitsFile*);
  void swapBytes();

 protected:
  T swap(T* ptr);

 protected:
  void uncompress(FitsFile* fits);
  int gzcompressed(T*, char*, char*, int, int, int, int, int, int);
  virtual int compressed(T*, char*, char*, int, int, int, int, int, int) =0;
  int uncompressed(T*, char*, char*, int, int, int, int, int, int);

  T getValue(char*, double, double, int);
  T getValue(short*, double, double, int);
  T getValue(int*, double, double, int);
  T getValue(long long*, double, double, int);
  T getValue(float*, double, double, int);
  T getValue(double*, double, double, int);

 public:
  FitsCompressm(FitsFile*);
};

class FitsPostNext : public FitsFile {
public:
  FitsPostNext(FitsFile* prev);
};

#endif