G.711 implementation of A-law

I am implementing the ITU-T G.711 standard, and I decided to start with the reference code in G.191.

Running some A-law compression tests made me doubt the algorithm was correct.

According to G.711, input range 0-63 should be located on the first segment in two-step increments. The sample code in G.191 displays this range as follows:

  • 0 to 15 on segment 0 with step size 1
  • 16 to 31 on segment 1 with step size 1
  • 32 to 63 on segment 2 with step size 2

We not only get the offset of 1 segment when comparing the output with the value in the table, but the range also decreases by half, so the compressed FF corresponds to a uniform 2047.

How do I work to have a G.711 compatible codec?

+4
source share
1 answer

The code is commensurate with the standard.

Note that the standard assumes 13-bit input (but always quantizes lsb), the code assumes 16-bit and immediately discards everything except 12 msbs. So, the 12-bit terms in table 1a in G.711 do say:

  • Segment 1: input values ​​0 → 31 (step size 1)
  • Segment 2: input values ​​32 → 63 (step 2)
  • ...

The only remaining inconsistency is that the first segment appears to be divided into two in the code. This is not entirely true; note that the segments do not match the metrics; Segment 1 covers both 000and 001. The code refers exclusively to exhibitors.

+5
source

All Articles