#include <fftCompressor.h>
Public Member Functions | |
FFTCompressor () | |
Constructs a new compressor object with default parameters. | |
void | set_quality (int quality) |
Sets the quality factor for the compression. | |
int | get_quality () const |
Returns the quality number that was previously set via set_quality(). | |
void | set_transpose_quats (bool flag) |
Sets the transpose_quats flag. | |
bool | get_transpose_quats () const |
Returns the transpose_quats flag. | |
void | write_header (Datagram &datagram) |
Writes the compression parameters to the indicated datagram. | |
void | write_reals (Datagram &datagram, const float *array, int length) |
Writes an array of floating-point numbers to the indicated datagram. | |
void | write_hprs (Datagram &datagram, const LVecBase3f *array, int length) |
Writes an array of HPR angles to the indicated datagram. | |
bool | read_header (DatagramIterator &di) |
Reads the compression header that was written previously. | |
bool | read_reals (DatagramIterator &di, vector_float &array) |
Reads an array of floating-point numbers. | |
bool | read_hprs (DatagramIterator &di, vector_LVecBase3f &array) |
Reads an array of HPR angles. | |
Static Public Member Functions | |
bool | is_compression_available () |
Returns true if the FFTW library is compiled in, so that this class is actually capable of doing useful compression/decompression work. | |
void | free_storage () |
Frees memory that has been allocated during past runs of the FFTCompressor. | |
Private Types | |
enum | RunWidth { RW_width_mask = 0xc0, RW_length_mask = 0x3f, RW_0 = 0x00, RW_8 = 0x40, RW_16 = 0x80, RW_32 = 0xc0, RW_double = 0xff, RW_invalid = 0x01 } |
Private Member Functions | |
int | write_run (Datagram &datagram, RunWidth run_width, const vector_double &run) |
Writes a sequence of integers that all require the same number of bits. | |
int | read_run (DatagramIterator &di, vector_double &run) |
Reads a sequence of integers that all require the same number of bits. | |
double | get_scale_factor (int i, int length) const |
Returns the appropriate scaling for the given position within the halfcomplex array. | |
Static Private Member Functions | |
double | interpolate (double t, double a, double b) |
Returns a number between a and b, inclusive, according to the value of t between 0 and 1, inclusive. | |
Private Attributes | |
int | _quality |
double | _fft_offset |
double | _fft_factor |
double | _fft_exponent |
bool | _transpose_quats |
Actually, it doesn't do any real compression on its own; it just outputs a stream of integers that should compress much tighter via gzip than the original stream of floats would have.
This class depends on the external FFTW library; without it, it will fall back on lossless output of the original data.
Definition at line 66 of file fftCompressor.h.
|
Definition at line 89 of file fftCompressor.h. Referenced by write_header(). |
|
Constructs a new compressor object with default parameters.
Definition at line 56 of file fftCompressor.cxx. |
|
Frees memory that has been allocated during past runs of the FFTCompressor. This is an optional call, but it may be made from time to time to empty the global cache that the compressor objects keep to facilitate fast compression/decompression. Definition at line 814 of file fftCompressor.cxx. |
|
Returns the quality number that was previously set via set_quality().
Definition at line 201 of file fftCompressor.cxx. |
|
Returns the appropriate scaling for the given position within the halfcomplex array.
Definition at line 1013 of file fftCompressor.cxx. Referenced by write_header(). |
|
Returns the transpose_quats flag. Definition at line 235 of file fftCompressor.cxx. References Datagram::add_float32(), and length. |
|
Returns a number between a and b, inclusive, according to the value of t between 0 and 1, inclusive.
Definition at line 1035 of file fftCompressor.cxx. Referenced by is_compression_available(). |
|
Returns true if the FFTW library is compiled in, so that this class is actually capable of doing useful compression/decompression work. Returns false otherwise, in which case any attempt to write a compressed stream will actually write an uncompressed stream, and any attempt to read a compressed stream will fail. Definition at line 82 of file fftCompressor.cxx. References _fft_exponent, _fft_factor, _fft_offset, _quality, fft_exponent, fft_factor, fft_offset, interpolate(), and t. |
|
Reads the compression header that was written previously. This fills in the compression parameters necessary to correctly decompress the following data. Returns true if the header is read successfully, false otherwise. Definition at line 553 of file fftCompressor.cxx. |
|
Reads an array of HPR angles. The result is pushed onto the end of the indicated vector, which is not cleared first; it is the user's responsibility to ensure that the array is initially empty. Definition at line 674 of file fftCompressor.cxx. References _quality. |
|
Reads an array of floating-point numbers. The result is pushed onto the end of the indicated vector, which is not cleared first; it is the user's responsibility to ensure that the array is initially empty. Returns true if the data is read correctly, false if there is an error. Definition at line 599 of file fftCompressor.cxx. Referenced by AnimChannelMatrixXfmTable::fillin(). |
|
Reads a sequence of integers that all require the same number of bits. Returns the number of integers read. It is the responsibility of the user to clear the vector before calling this function, or the numbers read will be appended to the end. Definition at line 938 of file fftCompressor.cxx. |
|
Sets the quality factor for the compression. This is an integer in the range 0 - 100 that roughly controls how aggressively the reals are compressed; lower numbers mean smaller output, and more data loss. There are a few special cases. Quality -1 means to use whatever individual parameters are set in the user's Configrc file, rather than the single quality dial. Quality 101 or higher means to generate lossless output (this is the default if libfftw is not available). Quality 102 writes all four components of quaternions to the output file, rather than just three, quality 103 converts hpr to matrix (instead of quat) and writes a 9-component matrix, and quality 104 just writes out hpr directly. Quality levels 102 and greater are strictly for debugging purposes, and are only available if NDEBUG is not defined. Definition at line 135 of file fftCompressor.cxx. References _fft_exponent, _fft_factor, and _fft_offset. |
|
Sets the transpose_quats flag. This is provided mainly for backward compatibility with old bam files that were written out with the quaternions inadvertently transposed. Definition at line 220 of file fftCompressor.cxx. |
|
Writes the compression parameters to the indicated datagram. It is necessary to call this before writing anything else to the datagram, since these parameters will be necessary to correctly decompress the data later. Definition at line 256 of file fftCompressor.cxx. References cfloor(), get_scale_factor(), length, RunWidth, RW_0, RW_invalid, and scale_factor. |
|
Writes an array of HPR angles to the indicated datagram.
Definition at line 386 of file fftCompressor.cxx. References length. |
|
Writes an array of floating-point numbers to the indicated datagram.
Definition at line 276 of file fftCompressor.cxx. Referenced by AnimChannelMatrixXfmTable::write_datagram(). |
|
Writes a sequence of integers that all require the same number of bits. Returns the number of integers written, i.e. run.size(). Definition at line 846 of file fftCompressor.cxx. References DatagramIterator::get_uint16(), and length. |
|
Definition at line 113 of file fftCompressor.h. Referenced by is_compression_available(), and set_quality(). |
|
Definition at line 112 of file fftCompressor.h. Referenced by is_compression_available(), and set_quality(). |
|
Definition at line 111 of file fftCompressor.h. Referenced by is_compression_available(), and set_quality(). |
|
Definition at line 110 of file fftCompressor.h. Referenced by is_compression_available(), and read_hprs(). |
|
Definition at line 114 of file fftCompressor.h. |