hard quantization using nearest codeword