FreeSWITCH API Documentation  1.7.0
A-law and mu-law handling

Lookup tables for A-law and u-law look attractive, until you consider the impact on the CPU cache. If it causes a substantial area of your processor cache to get hit too often, cache sloshing will severely slow things down. The main reason these routines are slow in C, is the lack of direct access to the CPU's "find the first 1" instruction. A little in-line assembler fixes that, and the conversion routines can be faster than lookup tables, in most real world usage. A "find the first 1" instruction is available on most modern CPUs, and is a much underused feature.

If an assembly language method of bit searching is not available, these routines revert to a method that can be a little slow, so the cache thrashing might not seem so bad :(

Feel free to submit patches to add fast "find the first 1" support for your own favorite processor.

Look up tables are used for transcoding between A-law and u-law, since it is difficult to achieve the precise transcoding procedure laid down in the G.711 specification by other means.