C version of the reproject routine, including the parallel one.