Skip to content

Commit 9c05148

Browse files
author
Cam K.
committed
Clean up interleaver
1 parent de2c20f commit 9c05148

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

lib/interleaver.c

+22-16
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,21 @@
88
void cats_interleave(uint8_t* data, size_t len)
99
{
1010
uint8_t buf[len];
11-
int bitIndex = 0;
11+
int bit_index = 0;
1212
for(int i = 0; i < 32; i++) {
13-
for(int j = 0; j < len*8; j += 32) {
14-
if(i+j >= len*8)
13+
for(int j = 0; j < len * 8; j += 32) {
14+
if(i+j >= len * 8) {
1515
continue;
16+
}
1617

17-
if(GET_BIT(data[(i+j)/8], (i+j)%8))
18-
SET_BIT(buf[bitIndex/8], bitIndex%8);
19-
else
20-
CLEAR_BIT(buf[bitIndex/8], bitIndex%8);
18+
if(GET_BIT(data[(i+j) / 8], (i+j) % 8)) {
19+
SET_BIT(buf[bit_index / 8], bit_index % 8);
20+
}
21+
else {
22+
CLEAR_BIT(buf[bit_index / 8], bit_index % 8);
23+
}
2124

22-
bitIndex++;
25+
bit_index++;
2326
}
2427
}
2528
memcpy(data, buf, len);
@@ -28,18 +31,21 @@ void cats_interleave(uint8_t* data, size_t len)
2831
void cats_deinterleave(uint8_t* data, size_t len)
2932
{
3033
uint8_t buf[len];
31-
int bitIndex = 0;
34+
int bit_index = 0;
3235
for(int i = 0; i < 32; i++) {
33-
for(int j = 0; j < len*8; j+= 32) {
34-
if(i+j >= len*8)
36+
for(int j = 0; j < len * 8; j+= 32) {
37+
if(i+j >= len * 8) {
3538
continue;
39+
}
3640

37-
if(GET_BIT(data[bitIndex/8], bitIndex%8))
38-
SET_BIT(buf[(i+j)/8], (i+j)%8);
39-
else
40-
CLEAR_BIT(buf[(i+j)/8], (i+j)%8);
41+
if(GET_BIT(data[bit_index / 8], bit_index % 8)) {
42+
SET_BIT(buf[(i+j) / 8], (i+j) % 8);
43+
}
44+
else {
45+
CLEAR_BIT(buf[(i+j) / 8], (i+j) % 8);
46+
}
4147

42-
bitIndex++;
48+
bit_index++;
4349
}
4450
}
4551
memcpy(data, buf, len);

0 commit comments

Comments
 (0)