correctly compute out_size and samples number