void code_dim uint8_t offset unsigned long int part new unsigned long

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
void code_dim(uint8_t offset) {
unsigned long int *part = new unsigned long int;
unsigned long int *last = new unsigned long int;
int8_t i=0, k=0;
in->ReadBitField(&part, len);
if(part==NULL) return;
*last = *part;
while(1) {
i=0;
while(*part == *last && i<(SIZE-2) ) {
in->ReadBitField(&part, len);
i++;
if(part==NULL) goto exit;
}
if(i==1 && k < (SIZE-2) ) {
buf[k++] = *last;
}
else {
if(k>0) {
out->WriteBitField((unsigned long)(-k), SERIA_BITS);
for(int8_t j = 0; j<k; j++) {
out->WriteBitField((unsigned long)buf[j], len);
}
k=0;
}
out->WriteBitField((unsigned long)(i), SERIA_BITS);
out->WriteBitField((unsigned long)(*last), len);
}
*last = *part;
}
exit:
if(k>0) {
out->WriteBitField((unsigned long)(-k), SERIA_BITS);
for(int8_t j = 0; j<k; j++) {
out->WriteBitField((unsigned long)buf[j], len);
}
}
out->WriteBitField((unsigned long)(i), SERIA_BITS);
out->WriteBitField((unsigned long)(*last), len);
return;
}