/*
* 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.
*/
FILE *fpin,*fpOut ;
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, fpOut);
}
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;
fpin= fopen("YourInputFile,"rb");
fpOut= fopen("YouOutFile","arw+"); while (fread(in_buf, in_size, 1, fpin) == 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);
}
* 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.
*/
FILE *fpin,*fpOut ;
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, fpOut);
}
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;
fpin= fopen("YourInputFile,"rb");
fpOut= fopen("YouOutFile","arw+"); while (fread(in_buf, in_size, 1, fpin) == 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);
}
解决方案 »
- 此人太邪恶
- (高分请教)动态创建activex后, 再activex窗口上呼叫菜单报错??
- 怎样解决对话框背景brush会覆盖文本框等控件的背景
- Socket客户端的问题...
- 请问哪里有inside ole2下载呀?
- 如何获得保存在密码列表中的密码和用户名?
- 关于BCGControlBar 6.5 pro的静态库使用的问题
- 奇怪了,我编译连接我dll程序后没有.lib文件,我的.def文件里有输出函数啊?
- HBITMAP hBmp=(HBITMAP)LoadImage(NULL,"bitmap.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);在以前用的很顺,但在自己定义的函数里使用(参
- 有经常出差的程序员吗
- 一个包含了可连接对象的COM,加进COM+后,可连接对象不能回调客户接收器了。
- 有没有API能改变系统的光标形状?
你还在呀
不是说你要到现场吗?你上面的还不是一样跟那个demo一样吗
你收到我的信没有?我如下录音////////////////参数初始化 m_BufferIndex=0;
m_BufferLength=960;
for (i=0;i<5;i++)
{
m_lpAudioData[i]=(LPSTR)GlobalAllocPtr(GMEM_MOVEABLE|GMEM_SHARE|GMEM_ZEROINIT,m_BufferLength);
m_lpAudioHdr[i]=(LPWAVEHDR)GlobalAllocPtr(GMEM_MOVEABLE|GMEM_SHARE|GMEM_ZEROINIT,sizeof(WAVEHDR));
}
m_pwfx=(LPWAVEFORMATEX)GlobalAllocPtr(GHND,sizeof(WAVEFORMATEX));
memset(m_pwfx,0,sizeof(WAVEFORMATEX));
m_pwfx->cbSize=0;
m_pwfx->wFormatTag=WAVE_FORMAT_PCM;
m_pwfx->nChannels=1;
m_pwfx->nSamplesPerSec=8000;
m_pwfx->wBitsPerSample=8;
m_pwfx->nBlockAlign=1;
m_pwfx->nAvgBytesPerSec=8000;
////////////////录音
waveInOpen((LPHWAVEIN)&m_hWaveIn,(WORD)WAVE_MAPPER,m_pwfx,(LONG)m_hWnd,0L,CALLBACK_WINDOW);
for (i=0;i<5;i++)
{
m_lpAudioHdr[i]->lpData=(LPSTR)m_lpAudioData[i];
m_lpAudioHdr[i]->dwBufferLength=(DWORD)m_BufferLength;
m_lpAudioHdr[i]->dwFlags=0L;
m_lpAudioHdr[i]->dwLoops=0L;
waveInPrepareHeader(m_hWaveIn,m_lpAudioHdr[i],sizeof(WAVEHDR));
}
waveInAddBuffer(m_hWaveIn,m_lpAudioHdr[m_BufferIndex],sizeof(WAVEHDR));
waveInStart(m_hWaveIn);
////////////接下来我要压缩我该怎么做或
怎样直到现在已经录音了多少数据
{
code = g721_encoder(m_lpAudioHdr[Processed/*已处理数据*/]->lpData,AUDIO_ENCODING_ALAW,&state);
resid = pack_output(code, enc_bits);
while (resid) {
resid = pack_output(0, enc_bits);
}char OutData[MAX_BUFFER]; //压缩后数据区 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;
OutData[Process++]=out_byte; //这里换成写内存
//OutData(&out_byte, sizeof (char), 1, fpOut);
}
return (out_bits > 0);
}
while(recodeing==true) //仍在录音
{
code = g721_encoder(m_lpAudioHdr[Processed++/*已处理数据 更正上面的*/]->lpData,AUDIO_ENCODING_ALAW,&state);
resid = pack_output(code, enc_bits);
while (resid) {
resid = pack_output(0, enc_bits);
}
//输出部分
char OutData[MAX_BUFFER]; //压缩后数据区 int pack_output(unsigned code,int bits)
{
static unsigned int out_buffer = 0;
static int Writed = 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;
OutData[Writed++]=out_byte; //这里换成写内存[还要判断越界等处理]
//OutData(&out_byte, sizeof (char), 1, fpOut);
}
return (out_bits > 0);
}
在吗
我给你的信收到了吗
在10M局域网上没问题
当然你可以在本机上试
注意思改好个IP
我也在做这方面的实验。
[email protected]
要下班了吗
晚上抽点时帮我
明天见