The code is commensurate with the standard.
Note first that the standard assumes 13-bit input (but always quantises the lsb), the code assumes 16-bit, and immediately discards all but the 12 msbs. So in 12-bit terms, Table 1a in G.711 is really saying:
- Segment 1: input values 0 -> 31 (step-size 1)
- Segment 2: input values 32 -> 63 (step-size 2)
- ...
The only remaining discrepancy is that the first segment is apparently split in two in the code. It's not really; note that the segments are not the same as exponents; Segment 1 encompasses both exponents 000
and 001
. The code deals exclusively with exponents.