You can have a look at how this is done on other quantizers.