00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef FFTCOMPRESSOR_H
00016 #define FFTCOMPRESSOR_H
00017
00018 #include "pandabase.h"
00019
00020 #include "pvector.h"
00021 #include "pointerToArray.h"
00022 #include "vector_stdfloat.h"
00023 #include "vector_double.h"
00024 #include "luse.h"
00025
00026 class Datagram;
00027 class DatagramIterator;
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 class EXPCL_PANDA_MATHUTIL FFTCompressor {
00046 public:
00047 FFTCompressor();
00048
00049 static bool is_compression_available();
00050
00051 void set_quality(int quality);
00052 int get_quality() const;
00053
00054 void set_use_error_threshold(bool use_error_threshold);
00055 bool get_use_error_threshold() 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 PN_stdfloat *array, int length);
00062 void write_hprs(Datagram &datagram, const LVecBase3 *array, int length);
00063
00064 bool read_header(DatagramIterator &di, int bam_minor_version);
00065 bool read_reals(DatagramIterator &di, vector_stdfloat &array);
00066 bool read_hprs(DatagramIterator &di, pvector<LVecBase3> &array,
00067 bool new_hpr);
00068 bool read_hprs(DatagramIterator &di, pvector<LVecBase3> &array);
00069
00070 static void free_storage();
00071
00072 private:
00073 enum RunWidth {
00074
00075
00076
00077
00078 RW_width_mask = 0xc0,
00079 RW_length_mask = 0x3f,
00080 RW_0 = 0x00,
00081 RW_8 = 0x40,
00082 RW_16 = 0x80,
00083 RW_32 = 0xc0,
00084 RW_double = 0xff,
00085 RW_invalid = 0x01
00086 };
00087
00088 int write_run(Datagram &datagram, RunWidth run_width,
00089 const vector_double &run);
00090 int read_run(DatagramIterator &di, vector_double &run);
00091 double get_scale_factor(int i, int length) const;
00092 static double interpolate(double t, double a, double b);
00093
00094 PN_stdfloat get_compressability(const PN_stdfloat *data, int length) const;
00095
00096 int _bam_minor_version;
00097 int _quality;
00098 bool _use_error_threshold;
00099 double _fft_offset;
00100 double _fft_factor;
00101 double _fft_exponent;
00102 bool _transpose_quats;
00103 };
00104
00105 #endif
00106