26 int size =
sizeof(BOOL);
28 &size, TID_BOOL,
TRUE);
33 int num_words = input_size/9;
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++) {
41 int timestamp = (input[j*9+0] << 12) |
45 if(timestamp != last_timestamp + 1 || run_length == 255) {
46 if(island_timestamp != -1) {
51 island_timestamp = timestamp;
55 last_timestamp = timestamp;
60 if(island_timestamp != -1) {
67 for(
int j = 0; j < num_words; j++) {
70 bool overflowB0 = ((input[j*9+2] & 0x08) != 0);
71 bool overflowA0 = ((input[j*9+2] & 0x04) != 0);
72 bool overflowB1 = ((input[j*9+2] & 0x02) != 0);
73 bool overflowA1 = ((input[j*9+2] & 0x01) != 0);
74 sample[3] = (overflowB0 << 12) |
77 sample[2] = (overflowA0 << 12) |
78 ((input[j*9+4] & 0xf) << 8) |
80 sample[1] = (overflowB1 << 12) |
83 sample[0] = (overflowA1 << 12) |
84 ((input[j*9+7] & 0xf) << 8) |
87 for(
int k = 0; k < 4; k++) {
88 int diff = sample[k] - lastSample;
89 lastSample = sample[k];
92 if(diff <= 7 && diff >= -7) {
109 int *uncompressed_size_p = (
int *) output;
110 *uncompressed_size_p = input_size;
111 output +=
sizeof(int);
115 int compressed_size =
encode_n2fadc_tpc(input, input_size, &output_buffer, userParam);
116 output += compressed_size;
118 return compressed_size +
sizeof(int);
123 int num_fadc_words = input_size/9;
127 while(j < num_fadc_words) {
132 for(
int k = 0; k < run_length; k++) {
133 int t2 = timestamp + k;
134 output[(j+k)*9+0] = (t2 >> 12) & 0xff;
135 output[(j+k)*9+1] = (t2 >> 4) & 0xff;
136 output[(j+k)*9+2] = (t2 & 0xf) << 4;
144 for(
int j = 0; j < num_fadc_words; j++) {
146 for(
int k = 0; k < 4; k++) {
148 if(encodedDiff == 0) {
151 sample[k] = lastSample + encodedDiff - 8;
153 lastSample = sample[k];
156 int overflows = ((sample[0] & 0x1000) ? 0x01 : 0) |
157 ((sample[1] & 0x1000) ? 0x02 : 0) |
158 ((sample[2] & 0x1000) ? 0x04 : 0) |
159 ((sample[3] & 0x1000) ? 0x08 : 0);
160 output[j*9+2] |= overflows;
161 output[j*9+3] = (sample[3] >> 4) & 0xff;
162 output[j*9+4] = ((sample[3] & 0xf) << 4) | ((sample[2] >> 8) & 0xf);
163 output[j*9+5] = (sample[2] & 0xff);
164 output[j*9+6] = (sample[1] >> 4) & 0xff;
165 output[j*9+7] = ((sample[1] & 0xf) << 4) | ((sample[0] >> 8) & 0xf);
166 output[j*9+8] = (sample[0] & 0xff);
172 int n2fadc_tpc_expand(
unsigned char *input,
int input_size,
unsigned char * output,
int userParam)
179 int *uncompressed_size_p = (
int *) input;
180 int uncompressed_size = *uncompressed_size_p;
181 input +=
sizeof(int);
182 input_size -=
sizeof(int);
189 return uncompressed_size;
194 for(
int i = 0;
i < num_fadc_words;
i++) {
196 for(
int j = 0; j < 9; j++) {