Multistage trellis quantization and its applications