22 save_huffman(
"/Compression/Lossless/CAEN/Huffman/Channel", &caen_channel_huffman);
28 load_huffman(
"/Compression/Lossless/CAEN/Huffman/Channel", &caen_channel_huffman);
30 int size =
sizeof(BOOL);
32 &size, TID_BOOL,
TRUE);
35 db_get_value(
hDB, 0,
"/Compression/Lossless/CAEN/Strip trailing edge",
39 db_get_value(
hDB, 0,
"/Compression/Lossless/CAEN/Strip R1",
44 int *uncompressed_size_p)
58 int uncompressed_size = 0;
63 for (
int i = 0;
i < input_size;
i++) {
66 if (input[
i].r2 != 0 || input[
i].start) {
68 printf(
"in datum %d : r1 %d channel %d start %d r2 %d edge %d time %d\n",
69 i, input[
i].r1, input[
i].channel, input[
i].start, input[
i].r2,
70 input[
i].edge, input[
i].
time);
73 }
else if (strip_trailing_edge && input[
i].edge == 0) {
80 int verbatim = *((
int *) &input[
i]);
89 if (!strip_trailing_edge) {
93 int time_diff = input[
i].
time - prev_time;
95 if (time_diff < 32 && time_diff >= -32) {
98 }
else if (time_diff < 512 && time_diff >= -512) {
106 prev_time = input[
i].
time;
112 *uncompressed_size_p = uncompressed_size;
127 int *uncompressed_size_p = (
int *) output;
128 output +=
sizeof(int);
131 int *compressed_time_size_p = (
int *) output;
132 output +=
sizeof(int);
136 int compressed_time_size =
137 encode_caen(input, input_size, &output_buffer, uncompressed_size_p);
138 output += compressed_time_size;
141 *compressed_time_size_p = compressed_time_size;
143 return compressed_time_size + 2 *
sizeof(int);
148 int sign_bit = (1 << (bits-1));
150 return in | ~(sign_bit - 1);
172 if (channel == 128) {
176 int verbatim = v2 | (v1 << 16);
189 if (!strip_trailing_edge) {
197 if (time_length_flag1 == 0) {
202 if (time_length_flag2 == 0) {
211 output[
i].
time = (prev_time + time_diff) & 0xfffff;
212 prev_time = output[
i].
time;
228 int *uncompressed_size_p = (
int *) input;
229 int uncompressed_size = *uncompressed_size_p;
230 input +=
sizeof(int);
231 input_size -=
sizeof(int);
234 int *compressed_time_size_p = (
int *) input;
235 int compressed_time_size = *compressed_time_size_p;
236 input +=
sizeof(int);
237 input_size -=
sizeof(int);
243 input += compressed_time_size;
244 input_size -= compressed_time_size;
246 return uncompressed_size *
sizeof(
caen_word);