filter.c: Fix endianness bug in sr_filter_probes
This commit is contained in:
parent
c1e45c6511
commit
764e7bbfec
13
filter.c
13
filter.c
|
@ -106,7 +106,7 @@ SR_API int sr_filter_probes(unsigned int in_unitsize, unsigned int out_unitsize,
|
|||
unsigned int in_offset, out_offset;
|
||||
int *probelist, out_bit;
|
||||
unsigned int i;
|
||||
uint64_t sample_in, sample_out;
|
||||
uint8_t *sample_in, *sample_out;
|
||||
|
||||
if (!probe_array) {
|
||||
sr_err("%s: probe_array was NULL", __func__);
|
||||
|
@ -151,14 +151,15 @@ SR_API int sr_filter_probes(unsigned int in_unitsize, unsigned int out_unitsize,
|
|||
/* If we reached this point, not all probes are used, so "compress". */
|
||||
in_offset = out_offset = 0;
|
||||
while (in_offset <= length_in - in_unitsize) {
|
||||
memcpy(&sample_in, data_in + in_offset, in_unitsize);
|
||||
sample_out = out_bit = 0;
|
||||
sample_in = data_in + in_offset;
|
||||
sample_out = (*data_out) + out_offset;
|
||||
memset(sample_out, 0, out_unitsize);
|
||||
out_bit = 0;
|
||||
for (i = 0; i < probe_array->len; i++) {
|
||||
if (sample_in & (1 << (probelist[i])))
|
||||
sample_out |= (1 << out_bit);
|
||||
if (sample_in[probelist[i]>>3] & (1 << (probelist[i]&7)))
|
||||
sample_out[out_bit>>3] |= (1 << (out_bit&7));
|
||||
out_bit++;
|
||||
}
|
||||
memcpy((*data_out) + out_offset, &sample_out, out_unitsize);
|
||||
in_offset += in_unitsize;
|
||||
out_offset += out_unitsize;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue