resample: allocate a large enough output buffer