00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef FFTCOMPRESSOR_H
00020 #define FFTCOMPRESSOR_H
00021
00022 #include <pandabase.h>
00023
00024 #include <pointerToArray.h>
00025 #include <vector_float.h>
00026 #include <vector_double.h>
00027 #include <vector_LVecBase3f.h>
00028
00029 class Datagram;
00030 class DatagramIterator;
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 class EXPCL_PANDA FFTCompressor {
00049 public:
00050 FFTCompressor();
00051
00052 static bool is_compression_available();
00053
00054 void set_quality(int quality);
00055 int get_quality() const;
00056
00057 void set_transpose_quats(bool flag);
00058 bool get_transpose_quats() const;
00059
00060 void write_header(Datagram &datagram);
00061 void write_reals(Datagram &datagram, const float *array, int length);
00062 void write_hprs(Datagram &datagram, const LVecBase3f *array, int length);
00063
00064 bool read_header(DatagramIterator &di);
00065 bool read_reals(DatagramIterator &di, vector_float &array);
00066 bool read_hprs(DatagramIterator &di, vector_LVecBase3f &array);
00067
00068 static void free_storage();
00069
00070 private:
00071 enum RunWidth {
00072
00073
00074
00075
00076 RW_width_mask = 0xc0,
00077 RW_length_mask = 0x3f,
00078 RW_0 = 0x00,
00079 RW_8 = 0x40,
00080 RW_16 = 0x80,
00081 RW_32 = 0xc0,
00082 RW_double = 0xff,
00083 RW_invalid = 0x01
00084 };
00085
00086 int write_run(Datagram &datagram, RunWidth run_width,
00087 const vector_double &run);
00088 int read_run(DatagramIterator &di, vector_double &run);
00089 double get_scale_factor(int i, int length) const;
00090 static double interpolate(double t, double a, double b);
00091
00092 int _quality;
00093 double _fft_offset;
00094 double _fft_factor;
00095 double _fft_exponent;
00096 bool _transpose_quats;
00097 };
00098
00099 #endif
00100