26 int size =
sizeof(BOOL);
28 &size, TID_BOOL,
TRUE);
33 int num_words = input_size/10;
37 int last_timestamp = -2;
38 int island_timestamp = -1;
39 int last_island_timestamp = 0;
40 for(
int j = 0; j < num_words; j++) {
42 int timestamp = (input[j*10+0] << 20) |
43 (input[j*10+1] << 12) |
44 (input[j*10+2] << 4) |
47 if(timestamp != last_timestamp + 1 || run_length == 255) {
48 if(island_timestamp != -1) {
53 island_timestamp = timestamp;
57 last_timestamp = timestamp;
62 if(island_timestamp != -1) {
69 for(
int j = 0; j < num_words; j++) {
71 bool overflowB0 = ((input[j*10+3] & 0x08) != 0);
72 bool overflowA0 = ((input[j*10+3] & 0x04) != 0);
73 bool overflowB1 = ((input[j*10+3] & 0x02) != 0);
74 bool overflowA1 = ((input[j*10+3] & 0x01) != 0);
75 sample[3] = (overflowB0 << 12) | (input[j*10+4] << 4) | (input[j*10+5] >> 4);
76 sample[2] = (overflowA0 << 12) | ((input[j*10+5] & 0xf) << 8) | (input[j*10+6]);
77 sample[1] = (overflowB1 << 12) | (input[j*10+7] << 4) | (input[j*10+8] >> 4);
78 sample[0] = (overflowA1 << 12) | ((input[j*10+8] & 0xf) << 8) | (input[j*10+9]);
80 for(
int k = 0; k < 4; k++) {
81 int diff = sample[k] - lastSample;
82 lastSample = sample[k];
85 if(diff <= 7 && diff >= -7) {
102 int *uncompressed_size_p = (
int *) output;
103 *uncompressed_size_p = input_size;
104 output +=
sizeof(int);
108 int compressed_size =
encode_n2fadc_ndet(input, input_size, &output_buffer, userParam);
109 output += compressed_size;
111 return compressed_size +
sizeof(int);
116 int num_fadc_words = input_size/10;
120 while(j < num_fadc_words) {
125 for(
int k = 0; k < run_length; k++) {
126 int t2 = timestamp + k;
127 output[(j+k)*10+0] = (t2 >> 20);
128 output[(j+k)*10+1] = (t2 >> 12) & 0xff;
129 output[(j+k)*10+2] = (t2 >> 4) & 0xff;
130 output[(j+k)*10+3] = (t2 & 0xf) << 4;
138 for(
int j = 0; j < num_fadc_words; j++) {
140 for(
int k = 0; k < 4; k++) {
142 if(encodedDiff == 0) {
145 sample[k] = lastSample + encodedDiff - 8;
147 lastSample = sample[k];
150 int overflows = ((sample[0] & 0x1000) ? 0x01 : 0) |
151 ((sample[1] & 0x1000) ? 0x02 : 0) |
152 ((sample[2] & 0x1000) ? 0x04 : 0) |
153 ((sample[3] & 0x1000) ? 0x08 : 0);
154 output[j*10+3] |= overflows;
155 output[j*10+4] = (sample[3] >> 4) & 0xff;
156 output[j*10+5] = ((sample[3] & 0xf) << 4) | ((sample[2] >> 8) & 0xf);
157 output[j*10+6] = (sample[2] & 0xff);
158 output[j*10+7] = (sample[1] >> 4) & 0xff;
159 output[j*10+8] = ((sample[1] & 0xf) << 4) | ((sample[0] >> 8) & 0xf);
160 output[j*10+9] = (sample[0] & 0xff);
173 int *uncompressed_size_p = (
int *) input;
174 int uncompressed_size = *uncompressed_size_p;
175 input +=
sizeof(int);
176 input_size -=
sizeof(int);
183 return uncompressed_size;
188 for(
int i = 0;
i < num_fadc_words;
i++) {
190 for(
int j = 0; j < 10; j++) {