网上关于A律压缩的资料很多,但u律的就很少了,最近遇到一个问题就是u律的段落码、电平码该怎么计算阿?每个段落的量化间隔又怎么计算?为什么在进行u律压缩时要价0x84偏移量 比如下面这段程序 #define BIAS (0x84) /* Bias for linear code. */ unsigned char linear2ulaw( int pcm_val) /* 2's complement (16-bit range) */ { int mask; int seg; unsigned char uval;
/* Get the sign and the magnitude of the value. */ if (pcm_val < 0) { pcm_val = BIAS - pcm_val; mask = 0x7F; } else { pcm_val += BIAS; mask = 0xFF; }
/* Convert the scaled magnitude to segment number. */ seg = search(pcm_val, seg_end, 8);
/* * Combine the sign, segment, quantization bits; * and complement the code word. */ if (seg >= 8) /* out of range, return maximum value. */ return (0x7F ^ mask); else { uval = (seg << 4) | ((pcm_val >> (seg + 3)) & 0xF); return (uval ^ mask); }
} 有知道的告诉一声啊 谢谢了 |