linux下音频编解码该如何调用函数
我想在linux下写一个音频的编解码程序,采集的数据保存在char* 变量中,压缩时就不知道怎么调用函数编码方式采用a-law方式在网上下了一个G.711的音频编解码源码,但是编码函数的参数是一个16位的整型,而我要编码的音频数据是字符串。不知道如何能够调用源码中的编码函数进行音频数据的压缩,源码中的编码函数如下所示:
/*
* linear2alaw() - Convert a 16-bit linear PCM value to 8-bit A-law
*
* linear2alaw() accepts an 16-bit integer and encodes it as A-law data.
*
*Linear Input CodeCompressed Code
*---------------------------------------
*0000000wxyza000wxyz
*0000001wxyza001wxyz
*000001wxyzab010wxyz
*00001wxyzabc011wxyz
*0001wxyzabcd100wxyz
*001wxyzabcde101wxyz
*01wxyzabcdef110wxyz
*1wxyzabcdefg111wxyz
*
* For further information see John C. Bellamy's Digital Telephony, 1982,
* John Wiley & Sons, pps 98-111 and 472-476.
*/
unsigned char
linear2alaw(
intpcm_val)/* 2's complement (16-bit range) */
{
intmask;
intseg;
unsigned charaval;
if (pcm_val >= 0) {
mask = 0xD5;/* sign (7th) bit = 1 */
} else {
mask = 0x55;/* sign bit = 0 */
pcm_val = -pcm_val - 8;
}
/* Convert the scaled magnitude to segment number. */
seg = search(pcm_val, seg_end, 8);
/* Combine the sign, segment, and quantization bits. */
if (seg >= 8)/* out of range, return maximum value. */
return (0x7F ^ mask);
else {
aval = seg << SEG_SHIFT;
if (seg < 2)
aval |= (pcm_val >> 4) & QUANT_MASK;
else
aval |= (pcm_val >> (seg + 3)) & QUANT_MASK;
return (aval ^ mask);
}
}
那位大侠知道如何处理的帮我解决下,谢谢啦!
[解决办法]
该回复于2011-03-30 13:10:47被版主删除
[解决办法]
现在问题解决了没?
[解决办法]
现在问题解决了没?