资源简介
G.7XX系列声音压缩标准在窄带环境下实现语音的传送
,此代码实现了该标准的压缩与解压过程。
,此代码实现了该标准的压缩与解压过程。
代码片段和文件信息
/*
* decode.c
*
* CCITT ADPCM decoder
*
* Usage : decode [-3|4|5] [-a|u|l] < infile > outfile
*/
#include
#include “g72x.h“
/*
* Unpack input codes and pass them back as bytes.
* Returns 1 if there is residual input returns -1 if eof else returns 0.
*/
int
unpack_input(
unsigned char *code
int bits)
{
static unsigned int in_buffer = 0;
static int in_bits = 0;
unsigned char in_byte;
if (in_bits < bits) {
if (fread(&in_byte sizeof (char) 1 stdin) != 1) {
*code = 0;
return (-1);
}
in_buffer |= (in_byte << in_bits);
in_bits += 8;
}
*code = in_buffer & ((1 << bits) - 1);
in_buffer >>= bits;
in_bits -= bits;
return (in_bits > 0);
}
main(
int argc
char **argv)
{
short sample;
unsigned char code;
int n;
struct g72x_state state;
int out_coding;
int out_size;
int (*dec_routine)();
int dec_bits;
g72x_init_state(&state);
out_coding = AUDIO_ENCODING_ULAW;
out_size = sizeof (char);
dec_routine = g721_decoder;
dec_bits = 4;
/* Process encoding argument if any */
while ((argc > 1) && (argv[1][0] == ‘-‘)) {
switch (argv[1][1]) {
case ‘3‘:
dec_routine = g723_24_decoder;
dec_bits = 3;
break;
case ‘4‘:
dec_routine = g721_decoder;
dec_bits = 4;
break;
case ‘5‘:
dec_routine = g723_40_decoder;
dec_bits = 5;
break;
case ‘u‘:
out_coding = AUDIO_ENCODING_ULAW;
out_size = sizeof (char);
break;
case ‘a‘:
out_coding = AUDIO_ENCODING_ALAW;
out_size = sizeof (char);
break;
case ‘l‘:
out_coding = AUDIO_ENCODING_LINEAR;
out_size = sizeof (short);
break;
default:
fprintf(stderr “CCITT ADPCM Decoder -- usage:\n“);
fprintf(stderr “\tdecode [-3|4|5] [-a|u|l] < infile > outfile\n“);
fprintf(stderr “where:\n“);
fprintf(stderr “\t-3\tProcess G.723 24kbps (3-bit) input data\n“);
fprintf(stderr “\t-4\tProcess G.721 32kbps (4-bit) input data [default]\n“);
fprintf(stderr “\t-5\tProcess G.723 40kbps (5-bit) input data\n“);
fprintf(stderr “\t-a\tGenerate 8-bit A-law data\n“);
fprintf(stderr “\t-u\tGenerate 8-bit u-law data [default]\n“);
fprintf(stderr “\t-l\tGenerate 16-bit linear PCM data\n“);
exit(1);
}
argc--;
argv++;
}
/* Read and unpack input codes and process them */
while (unpack_input(&code dec_bits) >= 0) {
sample = (*dec_routine)(code out_coding &state);
if (out_size == 2) {
fwrite(&sample out_size 1 stdout);
} else {
code = (unsigned char)sample;
fwrite(&code out_size 1 stdout);
}
}
fclose(stdout);
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2640 1992-09-01 06:09 G.711 G.721 G.723声音压缩标准压缩、解压代码\decode.c
文件 2866 1992-09-01 06:09 G.711 G.721 G.723声音压缩标准压缩、解压代码\encode.c
文件 7804 1992-09-01 06:09 G.711 G.721 G.723声音压缩标准压缩、解压代码\g711.c
文件 5430 1992-09-01 06:09 G.711 G.721 G.723声音压缩标准压缩、解压代码\g721.c
文件 4795 1992-09-01 06:09 G.711 G.721 G.723声音压缩标准压缩、解压代码\g723_24.c
文件 5707 1992-09-01 06:09 G.711 G.721 G.723声音压缩标准压缩、解压代码\g723_40.c
文件 14948 1992-09-01 06:09 G.711 G.721 G.723声音压缩标准压缩、解压代码\g72x.c
文件 3438 1992-09-01 06:09 G.711 G.721 G.723声音压缩标准压缩、解压代码\g72x.h
文件 603 1992-09-01 06:09 G.711 G.721 G.723声音压缩标准压缩、解压代码\Makefile
文件 3311 1992-09-01 06:09 G.711 G.721 G.723声音压缩标准压缩、解压代码\README
目录 0 2004-06-09 10:15 G.711 G.721 G.723声音压缩标准压缩、解压代码
文件 3189 2004-04-19 10:52 代码中国.txt
文件 126 2004-04-03 17:45 代码中国.url
文件 3930 2003-11-05 18:50 说明.htm
----------- --------- ---------- ----- ----
58787 14
评论
共有 条评论