高分请教关于G.723系列的问题--分数可以另给 唉,刚刚在论坛里面仔细搜索了一遍,直看得我胆战心寒,源代码也下载了几分,但是却看不懂,还望哪位兄弟能够提供相应的任何文档和源代码。小弟留下mail地址先 : [email protected] 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 声音标准压缩、解压缩G711_G721_G723代码:/* * decode.c 文件内容: * * CCITT ADPCM decoder * * Usage : decode [-3|4|5] [-a|u|l] < infile > outfile */#include <stdio.h>#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. */intunpack_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);}--------------------------------------------------------------------------------/* * encode.c文件内容 * * CCITT ADPCM encoder * * Usage : encode [-3|4|5] [-a|u|l] < infile > outfile */#include <stdio.h>#include "g72x.h"/* * Pack output codes into bytes and write them to stdout. * Returns 1 if there is residual output, else returns 0. */intpack_output(unsigned code,int bits){static unsigned int out_buffer = 0;static int out_bits = 0;unsigned char out_byte;out_buffer |= (code << out_bits);out_bits += bits;if (out_bits >= 8) {out_byte = out_buffer & 0xff;out_bits -= 8;out_buffer >>= 8;fwrite(&out_byte, sizeof (char), 1, stdout);}return (out_bits > 0);}main(int argc,char **argv){struct g72x_state state;unsigned char sample_char;short sample_short;unsigned char code;int resid;int in_coding;int in_size;unsigned *in_buf;int (*enc_routine)();int enc_bits;g72x_init_state(&state);/* Set defaults to u-law input, G.721 output */in_coding = AUDIO_ENCODING_ULAW;in_size = sizeof (char);in_buf = (unsigned *)&sample_char;enc_routine = g721_encoder;enc_bits = 4;/* Process encoding argument, if any */while ((argc > 1) && (argv[1][0] == '-')) {switch (argv[1][1]) {case '3':enc_routine = g723_24_encoder;enc_bits = 3;break;case '4':enc_routine = g721_encoder;enc_bits = 4;break;case '5':enc_routine = g723_40_encoder;enc_bits = 5;break;case 'u':in_coding = AUDIO_ENCODING_ULAW;in_size = sizeof (char);in_buf = (unsigned *)&sample_char;break;case 'a':in_coding = AUDIO_ENCODING_ALAW;in_size = sizeof (char);in_buf = (unsigned *)&sample_char;break;case 'l':in_coding = AUDIO_ENCODING_LINEAR;in_size = sizeof (short);in_buf = (unsigned *)&sample_short;break;default:fprintf(stderr, "CCITT ADPCM Encoder -- usage:\n");fprintf(stderr, "\tencode [-3|4|5] [-a|u|l] < infile > outfile\n");fprintf(stderr, "where:\n");fprintf(stderr, "\t-3\tGenerate G.723 24kbps (3-bit) data\n");fprintf(stderr, "\t-4\tGenerate G.721 32kbps (4-bit) data [default]\n");fprintf(stderr, "\t-5\tGenerate G.723 40kbps (5-bit) data\n");fprintf(stderr, "\t-a\tProcess 8-bit A-law input data\n");fprintf(stderr, "\t-u\tProcess 8-bit u-law input data [default]\n");fprintf(stderr, "\t-l\tProcess 16-bit linear PCM input data\n");exit(1);}argc--;argv++;}/* Read input file and process */while (fread(in_buf, in_size, 1, stdin) == 1) {code = (*enc_routine)(in_size == 2 ? sample_short : sample_char, in_coding, &state);resid = pack_output(code, enc_bits);}/* Write zero codes until all residual codes are written out */while (resid) {resid = pack_output(0, enc_bits);}fclose(stdout);} 5555555555555555~~~~~~~~~~~~~~~~Nobody??? 再来一次吧!!!我听说有一个G723EX地控件(OCX)可以播放G.723的东东,请问有谁知道在哪里?分数立刻送上。 百度IE工具栏问题 高份求:lotus notes 提供的ocx是哪个?怎么找? 怎么设置整个工程的全局变量 女友生病,基本康复了!谢谢大家的祝福!!!! 散分............... 怎样用Delphi取得宏里面的数据? 【各位帮忙,学习delphi的方法和方向!】 AssignFile一定要是文件名吗? 那位高手会用MS Agent编写动画精灵呀?高分求助! bevel1是什么控件?有什么用? 请问delphi+ado操作dbf数据库时如何使用临时表? 如何为Excel的最后一行加上统计行? 这个问题居然没人回答?
* decode.c 文件内容:
*
* CCITT ADPCM decoder
*
* Usage : decode [-3|4|5] [-a|u|l] < infile > outfile
*/
#include <stdio.h>
#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);
}
--------------------------------------------------------------------------------/*
* encode.c文件内容
*
* CCITT ADPCM encoder
*
* Usage : encode [-3|4|5] [-a|u|l] < infile > outfile
*/
#include <stdio.h>
#include "g72x.h"
/*
* Pack output codes into bytes and write them to stdout.
* Returns 1 if there is residual output, else returns 0.
*/
int
pack_output(
unsigned code,
int bits)
{
static unsigned int out_buffer = 0;
static int out_bits = 0;
unsigned char out_byte;out_buffer |= (code << out_bits);
out_bits += bits;
if (out_bits >= 8) {
out_byte = out_buffer & 0xff;
out_bits -= 8;
out_buffer >>= 8;
fwrite(&out_byte, sizeof (char), 1, stdout);
}
return (out_bits > 0);
}
main(
int argc,
char **argv)
{
struct g72x_state state;
unsigned char sample_char;
short sample_short;
unsigned char code;
int resid;
int in_coding;
int in_size;
unsigned *in_buf;
int (*enc_routine)();
int enc_bits;g72x_init_state(&state);/* Set defaults to u-law input, G.721 output */
in_coding = AUDIO_ENCODING_ULAW;
in_size = sizeof (char);
in_buf = (unsigned *)&sample_char;
enc_routine = g721_encoder;
enc_bits = 4;/* Process encoding argument, if any */
while ((argc > 1) && (argv[1][0] == '-')) {
switch (argv[1][1]) {
case '3':
enc_routine = g723_24_encoder;
enc_bits = 3;
break;
case '4':
enc_routine = g721_encoder;
enc_bits = 4;
break;
case '5':
enc_routine = g723_40_encoder;
enc_bits = 5;
break;
case 'u':
in_coding = AUDIO_ENCODING_ULAW;
in_size = sizeof (char);
in_buf = (unsigned *)&sample_char;
break;
case 'a':
in_coding = AUDIO_ENCODING_ALAW;
in_size = sizeof (char);
in_buf = (unsigned *)&sample_char;
break;
case 'l':
in_coding = AUDIO_ENCODING_LINEAR;
in_size = sizeof (short);
in_buf = (unsigned *)&sample_short;
break;
default:
fprintf(stderr, "CCITT ADPCM Encoder -- usage:\n");
fprintf(stderr, "\tencode [-3|4|5] [-a|u|l] < infile > outfile\n");
fprintf(stderr, "where:\n");
fprintf(stderr, "\t-3\tGenerate G.723 24kbps (3-bit) data\n");
fprintf(stderr, "\t-4\tGenerate G.721 32kbps (4-bit) data [default]\n");
fprintf(stderr, "\t-5\tGenerate G.723 40kbps (5-bit) data\n");
fprintf(stderr, "\t-a\tProcess 8-bit A-law input data\n");
fprintf(stderr, "\t-u\tProcess 8-bit u-law input data [default]\n");
fprintf(stderr, "\t-l\tProcess 16-bit linear PCM input data\n");
exit(1);
}
argc--;
argv++;
}/* Read input file and process */
while (fread(in_buf, in_size, 1, stdin) == 1) {
code = (*enc_routine)(in_size == 2 ? sample_short : sample_char,
in_coding, &state);
resid = pack_output(code, enc_bits);
}/* Write zero codes until all residual codes are written out */
while (resid) {
resid = pack_output(0, enc_bits);
}
fclose(stdout);
}