Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 7 additions & 17 deletions src/reconstruct.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,8 @@ ptrdiff_t backward_scan(float *marker, PixelQueue *queue, float *mask,
}

if (marker[q] < marker[p] && marker[q] < mask[q]) {
if (enqueue(queue, p) == 0) {
// In hybrid mode, we don't need to count the changes:
// Instead, we use the return value to signal if we need
// to repeat the scan because the queue filled up.
return -1;
};
enqueue(queue, p);
break;
}
}
}
Expand Down Expand Up @@ -283,10 +279,9 @@ void reconstruct(float *marker, float *mask, ptrdiff_t dims[2]) {

Requires a ptrdiff_t array of the same size as the marker and mask
arrays for use as the backing store of a PixelQueue. The PixelQueue
can only store dims[0]*dims[1] - 1 pixels. In the unlikely event
that it fills up, either during the `backward_scan` step or the
`propagate` step, the `repeat` flag is set, and the process is
repeated to ensure that the algorithm converges.
can only store dims[0]*dims[1] - 1 pixels. In the unlikely event that
it fills up during the `propagate` step, the `repeat` flag is set,
and the process is repeated to ensure that the algorithm converges.
*/
int reconstruct_hybrid(float *marker, ptrdiff_t *queue, float *mask,
ptrdiff_t dims[2]) {
Expand All @@ -299,13 +294,8 @@ int reconstruct_hybrid(float *marker, ptrdiff_t *queue, float *mask,
int32_t repeat = 0;
do {
forward_scan(marker, mask, dims);

repeat = 0;
// Backward scan returns -1 if the queue fills up, in which case
// we need to repeat the scan.
repeat |= (backward_scan(marker, &q, mask, dims) == -1);
repeat |= propagate(marker, &q, mask, dims);

backward_scan(marker, &q, mask, dims);
repeat = propagate(marker, &q, mask, dims);
scans++;
} while (repeat && scans < max_scans);
return (scans == max_scans) && repeat;
Expand Down
Loading