Skip to content

Commit

Permalink
Correctly cycle buffers
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-neara authored and FrancescAlted committed Jul 3, 2023
1 parent 0e37517 commit 9da3412
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions blosc/blosc2.c
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,12 @@ static int blosc2_intialize_header_from_context(blosc2_context* context, blosc_h
return 0;
}

void _cycle_buffers(void **src, void **dest, void **tmp) {
void *tmp2 = *src;
*src = *dest;
*dest = *tmp;
*tmp = tmp2;
}

uint8_t* pipeline_forward(struct thread_context* thread_context, const int32_t bsize,
const uint8_t* src, const int32_t offset,
Expand Down Expand Up @@ -948,10 +954,7 @@ uint8_t* pipeline_forward(struct thread_context* thread_context, const int32_t b
// No more filters are required
return _dest;
}
// Cycle buffers
_src = _dest;
_dest = _tmp;
_tmp = _src;
_cycle_buffers(&_src, &_dest, &_tmp);
}

/* Process the filter pipeline */
Expand All @@ -964,9 +967,7 @@ uint8_t* pipeline_forward(struct thread_context* thread_context, const int32_t b
shuffle(typesize, bsize, _src, _dest);
// Cycle filters when required
if (j < filters_meta[i]) {
_src = _dest;
_dest = _tmp;
_tmp = _src;
_cycle_buffers(&_src, &_dest, &_tmp);
}
}
break;
Expand Down Expand Up @@ -1025,9 +1026,7 @@ uint8_t* pipeline_forward(struct thread_context* thread_context, const int32_t b

// Cycle buffers when required
if (filters[i] != BLOSC_NOFILTER) {
_src = _dest;
_dest = _tmp;
_tmp = _src;
_cycle_buffers(&_src, &_dest, &_tmp);
}
}
return _src;
Expand Down Expand Up @@ -1344,9 +1343,7 @@ int pipeline_backward(struct thread_context* thread_context, const int32_t bsize
unshuffle(typesize, bsize, _src, _dest);
// Cycle filters when required
if (j < filters_meta[i]) {
_src = _dest;
_dest = _tmp;
_tmp = _src;
_cycle_buffers(&_src, &_dest, &_tmp);
}
// Check whether we have to copy the intermediate _dest buffer to final destination
if (last_copy_filter && (filters_meta[i] % 2) == 1 && j == filters_meta[i]) {
Expand Down Expand Up @@ -1424,9 +1421,7 @@ int pipeline_backward(struct thread_context* thread_context, const int32_t bsize

// Cycle buffers when required
if ((filters[i] != BLOSC_NOFILTER) && (filters[i] != BLOSC_TRUNC_PREC)) {
_src = _dest;
_dest = _tmp;
_tmp = _src;
_cycle_buffers(&_src, &_dest, &_tmp);
}
if (last_filter_index == i) {
break;
Expand Down

0 comments on commit 9da3412

Please sign in to comment.