Belle II Software development
ECLDCTCompress Class Reference

ECL waveform compression/decompression to/from the BitStream storage based on the Discrete Cosine Transform (DCT) More...

#include <ECLCompress.h>

Inheritance diagram for ECLDCTCompress:
ECLCompress

Public Member Functions

 ECLDCTCompress (double scale, double c0, width_t *w)
 Constructor for DCT based compression algorithm.
 
void compress (BitStream &out, const int *adc) override
 function to compress
 
void uncompress (BitStream &in, int *adc) override
 function to decompress
 

Protected Attributes

const double m_scale
 Scale factor for quantization.
 
const double m_c0
 Average waveform amplitude.
 
const width_tm_widths
 Bit widths for the DCT coefficients for prefix encoding.
 

Detailed Description

ECL waveform compression/decompression to/from the BitStream storage based on the Discrete Cosine Transform (DCT)

Definition at line 84 of file ECLCompress.h.

Constructor & Destructor Documentation

◆ ECLDCTCompress()

ECLDCTCompress ( double  scale,
double  c0,
width_t w 
)

Constructor for DCT based compression algorithm.

Parameters
scalescale factor for quantization.
c0average waveform amplitude.
wDCT coefficient probability density based bit widths for quantized coefficients

Definition at line 241 of file ECLCompress.cc.

241: m_scale(scale), m_c0(c0), m_widths(w) {}
const width_t * m_widths
Bit widths for the DCT coefficients for prefix encoding.
Definition: ECLCompress.h:103
const double m_scale
Scale factor for quantization.
Definition: ECLCompress.h:101
const double m_c0
Average waveform amplitude.
Definition: ECLCompress.h:102

Member Function Documentation

◆ compress()

void compress ( BitStream out,
const int *  adc 
)
overridevirtual

function to compress

Implements ECLCompress.

Definition at line 243 of file ECLCompress.cc.

244{
245 const int N = EclConfiguration::m_nsmp;
246 double buf[N], out[N];
247 for (int k = 0; k < N; k++) buf[k] = a[k];
248 e10_31(buf, out);
249 for (int k = 0; k < N; k++) out[k] *= 1.0 / (2 * N);
250
251 int km = N;
252 for (; km > 16; --km) if (lrint(out[km - 1]*m_scale) != 0) break;
253 OUT.putNBits(N - km, 4);
254 out[0] -= m_c0;
255 for (int k = 0; k < km; k++) {
256 int t = lrint(out[k] * m_scale);
257 stream_int(OUT, t, m_widths[k]);
258 }
259}
void e10_31(const R *I, R *O)
DCT-II or "the" DCT transformation of 31-point signal This function contains 320 FP additions,...
static constexpr int m_nsmp
number of ADC measurements for signal fitting

◆ uncompress()

void uncompress ( BitStream in,
int *  adc 
)
overridevirtual

function to decompress

Implements ECLCompress.

Definition at line 261 of file ECLCompress.cc.

262{
263 const double iscale = 1 / m_scale;
264 const int N = EclConfiguration::m_nsmp;
265 int nz = in.getNBits(4);
266 for (int i = 0; i < N - nz; i++) adc[i] = fetch_int(in, m_widths[i]);
267 for (int i = N - nz; i < N; i++) adc[i] = 0;
268
269 double c[N], out[N];
270 for (int k = 0; k < N; k++) c[k] = adc[k] * iscale;
271 c[0] += m_c0;
272
273 e01_31(c, out);
274
275 for (int k = 0; k < N; k++) adc[k] = lrint(out[k]);
276}
void e01_31(const R *I, R *O)
DCT-III or "the inverse" DCT transformation of 31-point signal This function contains 320 FP addition...
unsigned int getNBits(unsigned int n)
Fetch n bits.
Definition: BitStream.h:52

Member Data Documentation

◆ m_c0

const double m_c0
protected

Average waveform amplitude.

Definition at line 102 of file ECLCompress.h.

◆ m_scale

const double m_scale
protected

Scale factor for quantization.

Definition at line 101 of file ECLCompress.h.

◆ m_widths

const width_t* m_widths
protected

Bit widths for the DCT coefficients for prefix encoding.

Definition at line 103 of file ECLCompress.h.


The documentation for this class was generated from the following files: