本文整理汇总了C++中speex_bits_read_from函数的典型用法代码示例。如果您正苦于以下问题:C++ speex_bits_read_from函数的具体用法?C++ speex_bits_read_from怎么用?C++ speex_bits_read_from使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了speex_bits_read_from函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: decode
void decode(int header) {
FILE * fin = fopen("audiopacket2.spx", "r");
FILE * fout = fopen("decoded_audio.raw", "w");
int i;
short out[FRAME_SIZE];
float output[FRAME_SIZE];
char cbits[331-20];
SpeexBits bits;
void * state;
state = speex_decoder_init(&speex_nb_mode);
speex_bits_init(&bits);
while(1) {
if(feof(fin))
break;
/* on lit 307 octets (un paquet) vers cbits */
fread(cbits, 1, 331-20, fin);
/* on le copie vers une structure bit-stream */
speex_bits_read_from(&bits, cbits+header, 331-20-header);
/* on decode */
speex_decode(state, &bits, output);
for(i=0 ; i< FRAME_SIZE ; i++)
out[i]= output[i];
fwrite(out, sizeof(short), FRAME_SIZE, fout);
}
}
开发者ID:Youx,项目名称:soliloque-client,代码行数:31,代码来源:test.c
示例2: libspeex_decode_frame
static int libspeex_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
LibSpeexContext *s = avctx->priv_data;
int16_t *output = data, *end;
int i, num_samples;
num_samples = s->frame_size * avctx->channels;
end = output + *data_size / sizeof(*output);
speex_bits_read_from(&s->bits, buf, buf_size);
for (i = 0; speex_bits_remaining(&s->bits) && output + num_samples < end; i++) {
int ret = speex_decode_int(s->dec_state, &s->bits, output);
if (ret <= -2) {
av_log(avctx, AV_LOG_ERROR, "Error decoding Speex frame.\n");
return -1;
} else if (ret == -1)
// end of stream
break;
if (avctx->channels == 2)
speex_decode_stereo_int(output, s->frame_size, &s->stereo);
output += num_samples;
}
avctx->frame_size = s->frame_size * i;
*data_size = avctx->channels * avctx->frame_size * sizeof(*output);
return buf_size;
}
开发者ID:FreddyPulikottil,项目名称:ffmpeg-msvc,代码行数:34,代码来源:libspeexdec.c
示例3: voice_play
int voice_play(const char *buf, int length, int codec)
{
if (length <= 0)
return 0;
if (codec == EKG_CODEC_SPEEX) {
#if HAVE_SPEEX
spx_int16_t speex_output[320];
speex_bits_read_from(&speex_dec_bits, buf, length);
speex_decode_int(voice_speex_dec, &speex_dec_bits, speex_output); /* XXX, != 0 return? */
if (write(voice_fd, speex_output, sizeof(speex_output)) != sizeof(speex_output))
return -1;
return 0;
#else
printf("voice_play() received speex packet, but HAVE_SPEEX\n");
return -1;
#endif
}
if (codec == EKG_CODEC_GSM) {
#if HAVE_GSM
const int ramki_dwie = 33 + 33;
gsm_signal gsm_output[160];
const char *pos = buf;
while (pos <= (buf + length - ramki_dwie)) {
switch (codec) {
case EKG_CODEC_GSM:
if (gsm_decode(voice_gsm_dec, (unsigned char *) pos, gsm_output)) return -1;
pos += 33;
break;
}
if (write(voice_fd, gsm_output, 320) != 320)
return -1;
switch (codec) {
case EKG_CODEC_GSM:
if (gsm_decode(voice_gsm_dec, (unsigned char *) pos, gsm_output)) return -1;
pos += 33;
break;
}
if (write(voice_fd, gsm_output, 320) != 320)
return -1;
}
return 0;
#else
printf("voice_play() received gsm packet, but HAVE_GSM\n");
return -1;
#endif
}
return -1;
}
开发者ID:canthar,项目名称:libgadu,代码行数:60,代码来源:voice7.c
示例4: decodeSPEEX
signed short* decodeSPEEX(BYTE *data)
{
speex_bits_read_from(&obits, (char*)data, SPEEX_SIZE);
speex_decode_int(pDec, &obits, out_short);
speex_bits_reset(&obits);
return (signed short*)(&out_short[0]);
}
开发者ID:SrgShv,项目名称:speex_stm32,代码行数:7,代码来源:codec.c
示例5: speex_bits_read_from
/*****************************************************************************
* DecodePacket: decodes a Speex packet.
*****************************************************************************/
static block_t *DecodePacket( decoder_t *p_dec, ogg_packet *p_oggpacket )
{
decoder_sys_t *p_sys = p_dec->p_sys;
if( p_oggpacket->bytes )
{
/* Copy Ogg packet to Speex bitstream */
speex_bits_read_from( &p_sys->bits, (char *)p_oggpacket->packet,
p_oggpacket->bytes );
p_sys->i_frame_in_packet = 0;
}
/* Decode one frame at a time */
if( p_sys->i_frame_in_packet < p_sys->p_header->frames_per_packet )
{
block_t *p_aout_buffer;
if( p_sys->p_header->frame_size == 0 )
return NULL;
p_aout_buffer =
decoder_NewAudioBuffer( p_dec, p_sys->p_header->frame_size );
if( !p_aout_buffer )
{
return NULL;
}
switch( speex_decode_int( p_sys->p_state, &p_sys->bits,
(int16_t *)p_aout_buffer->p_buffer ) )
{
case -2:
msg_Err( p_dec, "decoding error: corrupted stream?" );
case -1: /* End of stream */
return NULL;
}
if( speex_bits_remaining( &p_sys->bits ) < 0 )
{
msg_Err( p_dec, "decoding overflow: corrupted stream?" );
}
if( p_sys->p_header->nb_channels == 2 )
speex_decode_stereo_int( (int16_t *)p_aout_buffer->p_buffer,
p_sys->p_header->frame_size,
&p_sys->stereo );
/* Date management */
p_aout_buffer->i_pts = date_Get( &p_sys->end_date );
p_aout_buffer->i_length =
date_Increment( &p_sys->end_date, p_sys->p_header->frame_size )
- p_aout_buffer->i_pts;
p_sys->i_frame_in_packet++;
return p_aout_buffer;
}
else
{
return NULL;
}
}
开发者ID:12307,项目名称:VLC-for-VS2010,代码行数:63,代码来源:speex.c
示例6: Speex_2_Pcm16
int Speex_2_Pcm16( unsigned char* out_buf, unsigned char* in_buf,
unsigned int size,
unsigned int channels, unsigned int rate, long h_codec )
{
SpeexState* ss;
short* pcm = (short*) out_buf;
int frames_out = 0;
ss = (SpeexState*) h_codec;
if (!ss || channels!=1)
return -1;
speex_bits_read_from(&ss->decoder.bits, (char*)in_buf, size);
/* We don't know where frame boundaries are,
but the minimum frame size is 43 */
while (speex_bits_remaining(&ss->decoder.bits)>40) {
int ret;
ret = speex_decode_int(ss->decoder.state, &ss->decoder.bits, pcm);
pcm+= ss->frame_size;
if (ret==-2) {
ERROR("while calling speex_decode\n");
return -1;
}
if (ret==-1) break;
frames_out++;
}
return frames_out*ss->frame_size*sizeof(short);
}
开发者ID:Chocolatbuddha,项目名称:sems,代码行数:34,代码来源:speex.c
示例7: speex_jitter_get
int speex_jitter_get(SpeexJitter *jitter, spx_int16_t *out, int *current_timestamp, void** userData)
{
int i;
int jbRet; /* results returned by the JB */
int ourRet; /* result that we will return */
spx_int32_t activity;
char data[2048];
JitterBufferPacket packet;
packet.data = data;
packet.len = 2048; /* AAAAARGH: it took a week to find and add this missing line */
if (jitter->valid_bits)
{
/* Try decoding last received packet */
jbRet = speex_decode_int(jitter->dec, &jitter->current_packet, out);
if (jbRet == 0)
{
jitter_buffer_tick(jitter->packets);
return 1;
} else {
jitter->valid_bits = 0;
}
}
jbRet = jitter_buffer_get(jitter->packets, &packet, jitter->frame_size, NULL);
if (jbRet != JITTER_BUFFER_OK)
{
/* no packet found, so no corresponding user-data */
*userData = NULL;
/* No packet found... extrapolate one */
/*fprintf (stderr, "lost/late frame\n");*/
/*Packet is late or lost*/
speex_decode_int(jitter->dec, NULL, out);
ourRet = 2;
} else {
/* found a packet, so there is corresponding user-data */
*userData = (void*)(packet.user_data);
speex_bits_read_from(&jitter->current_packet, packet.data, packet.len);
/* Decode packet */
jbRet = speex_decode_int(jitter->dec, &jitter->current_packet, out);
if (jbRet == 0) {
ourRet = 0;
jitter->valid_bits = 1;
} else {
/* Error while decoding */
ourRet = 3;
for (i=0;i<jitter->frame_size;i++) out[i]=0;
}
}
speex_decoder_ctl(jitter->dec, SPEEX_GET_ACTIVITY, &activity);
if (activity < jitter->activity_threshold)
jitter_buffer_update_delay(jitter->packets, &packet, NULL);
jitter_buffer_tick(jitter->packets);
return ourRet;
}
开发者ID:SergeStinckwich,项目名称:openqwaq,代码行数:60,代码来源:speex_jitter_buffer.c
示例8: main
int main(int argc, char **argv)
{
char *outFile;
FILE *fout;
/*Holds the audio that will be written to file (16 bits per sample)*/
short out[FRAME_SIZE];
/*Speex handle samples as float, so we need an array of floats*/
float output[FRAME_SIZE];
char cbits[200];
int nbBytes;
/*Holds the state of the decoder*/
void *state;
/*Holds bits so they can be read and written to by the Speex routines*/
SpeexBits bits;
int i, tmp;
/*Create a new decoder state in narrowband mode*/
state = speex_decoder_init(&speex_nb_mode);
/*Set the perceptual enhancement on*/
tmp=1;
speex_decoder_ctl(state, SPEEX_SET_ENH, &tmp);
outFile = argv[1];
fout = fopen(outFile, "w");
/*Initialization of the structure that holds the bits*/
speex_bits_init(&bits);
while (1)
{
/*Read the size encoded by sampleenc, this part will likely be
different in your application*/
fread(&nbBytes, sizeof(int), 1, stdin);
fprintf (stderr, "nbBytes: %d\n", nbBytes);
if (feof(stdin))
break;
/*Read the "packet" encoded by sampleenc*/
fread(cbits, 1, nbBytes, stdin);
/*Copy the data into the bit-stream struct*/
speex_bits_read_from(&bits, cbits, nbBytes);
/*Decode the data*/
speex_decode(state, &bits, output);
/*Copy from float to short (16 bits) for output*/
for (i=0;i<FRAME_SIZE;i++)
out[i]=output[i];
/*Write the decoded audio to file*/
fwrite(out, sizeof(short), FRAME_SIZE, fout);
}
/*Destroy the decoder state*/
speex_decoder_destroy(state);
/*Destroy the bit-stream truct*/
speex_bits_destroy(&bits);
fclose(fout);
return 0;
}
开发者ID:Distrotech,项目名称:speex,代码行数:60,代码来源:sampledec.c
示例9: switch_speex_decode
static switch_status_t switch_speex_decode(switch_codec_t *codec,
switch_codec_t *other_codec,
void *encoded_data,
uint32_t encoded_data_len,
uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate,
unsigned int *flag)
{
struct speex_context *context = codec->private_info;
short *buf;
if (!context) {
return SWITCH_STATUS_FALSE;
}
buf = decoded_data;
if (*flag & SWITCH_CODEC_FLAG_SILENCE) {
speex_decode_int(context->decoder_state, NULL, buf);
} else {
speex_bits_read_from(&context->decoder_bits, (char *) encoded_data, (int) encoded_data_len);
speex_decode_int(context->decoder_state, &context->decoder_bits, buf);
}
*decoded_data_len = codec->implementation->decoded_bytes_per_packet;
return SWITCH_STATUS_SUCCESS;
}
开发者ID:AbrahamJewowich,项目名称:FreeSWITCH,代码行数:26,代码来源:mod_speex.c
示例10: qSpeexDecode
int qSpeexDecode(QSpeexCodecPtr handle, void* inputBytes, int inputSize, void* outputSamples, int outputSize)
{
int offset, remaining;
short *out = (short*)outputSamples;
/* If there is no input to read, we certainly can't read it. */
if (inputBytes != NULL) {
speex_bits_read_from(&handle->decBits, inputBytes, inputSize);
}
for (offset=0; offset<outputSize; offset+=handle->frameSize) {
if (inputBytes != NULL) {
if (!speex_bits_remaining(&handle->decBits)) {
// Ran out of input data
return 2;
}
speex_decode_int(handle->decState, &handle->decBits, out+offset);
}
else {
/* Extrapolate output-buffer based on current decoder state. */
speex_decode_int(handle->decState, NULL, out+offset);
}
}
remaining = speex_bits_remaining(&handle->decBits);
if (remaining >= 8) {
/* If less than a byte is left over, that's OK. */
fprintf(stderr, "qSpeexDecode(): %d bits left over\n", remaining);
return 1; // Still have encoded bits left over
}
else return 0; // A-OK!!
}
开发者ID:JupiterSmalltalk,项目名称:openqwaq,代码行数:31,代码来源:qAudioSpeex.c
示例11: decode_audio
static int decode_audio(sh_audio_t *sh, unsigned char *buf,
int minlen, int maxlen) {
double pts;
context_t *ctx = sh->context;
int len, framelen, framesamples;
char *packet;
int i, err;
speex_decoder_ctl(ctx->dec_context, SPEEX_GET_FRAME_SIZE, &framesamples);
framelen = framesamples * ctx->hdr->nb_channels * sizeof(short);
if (maxlen < ctx->hdr->frames_per_packet * framelen) {
mp_msg(MSGT_DECAUDIO, MSGL_V, "maxlen too small in decode_audio\n");
return -1;
}
len = ds_get_packet_pts(sh->ds, (unsigned char **)&packet, &pts);
if (len <= 0) return -1;
if (sh->pts == MP_NOPTS_VALUE)
sh->pts = 0;
if (pts != MP_NOPTS_VALUE) {
sh->pts = pts;
sh->pts_bytes = 0;
}
speex_bits_read_from(&ctx->bits, packet, len);
i = ctx->hdr->frames_per_packet;
do {
err = speex_decode_int(ctx->dec_context, &ctx->bits, (short *)buf);
if (err == -2)
mp_msg(MSGT_DECAUDIO, MSGL_ERR, "Error decoding file.\n");
if (ctx->hdr->nb_channels == 2)
speex_decode_stereo_int((short *)buf, framesamples, &ctx->stereo);
buf = &buf[framelen];
} while (--i > 0);
sh->pts_bytes += ctx->hdr->frames_per_packet * framelen;
return ctx->hdr->frames_per_packet * framelen;
}
开发者ID:Gamer125,项目名称:wiibrowser,代码行数:34,代码来源:ad_speex.c
示例12: qWarning
// renyang - 替音訊解碼
void Call::decodeAudioData(char *buf, int len)
{
#ifdef REN_DEBUG
qWarning("Call::decodeAudioData()");
#endif
if (dec_state)
{
// renyang - Initializes the bit-stream from the data in an area of memory
// renyang - 把一連串的buf轉到bit-stream
speex_bits_read_from(&bits, buf, len);
// renyang - 把bits解碼到outBuffer(為float型態)
// renyang - 當<0表示解碼失敗
if (speex_decode(dec_state, &bits, outBuffer) < 0)
{
emit warning("Warning: wrong decryption key or stream corrupted!");
disableDecrypt();
}
else
{
// renyang - 來到這裡表示解碼成功
// renyang - 把解碼之後的音訊(outBuffer)放到soundBuffer中
putData(outBuffer, frame_size);
}
}
}
开发者ID:nightfly19,项目名称:renyang-learn,代码行数:26,代码来源:Call.cpp
示例13: ms_speex_dec_process
void ms_speex_dec_process(MSSpeexDec *obj)
{
MSFifo *outf=obj->outf[0];
MSQueue *inq=obj->inq[0];
gint16 *output;
gint gran=obj->frame_size*2;
gint i;
MSMessage *m;
g_return_if_fail(inq!=NULL);
g_return_if_fail(outf!=NULL);
m=ms_queue_get(inq);
g_return_if_fail(m!=NULL);
speex_bits_reset(&obj->bits);
ms_fifo_get_write_ptr(outf,gran,(void**)&output);
g_return_if_fail(output!=NULL);
if (m->data!=NULL){
speex_bits_read_from(&obj->bits,m->data,m->size);
/* decode */
speex_decode_int(obj->speex_state,&obj->bits,(short*)output);
}else{
/* we have a missing packet */
speex_decode_int(obj->speex_state,NULL,(short*)output);
}
ms_message_destroy(m);
}
开发者ID:serghei,项目名称:kde3-kdenetwork,代码行数:29,代码来源:msspeexdec.c
示例14: speextolin_framein
/*! \brief convert and store into outbuf */
static int speextolin_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
{
struct speex_coder_pvt *tmp = pvt->pvt;
/* Assuming there's space left, decode into the current buffer at
the tail location. Read in as many frames as there are */
int x;
int res;
int16_t *dst = pvt->outbuf.i16;
/* XXX fout is a temporary buffer, may have different types */
#ifdef _SPEEX_TYPES_H
spx_int16_t fout[1024];
#else
float fout[1024];
#endif
if (f->datalen == 0) { /* Native PLC interpolation */
if (pvt->samples + tmp->framesize > BUFFER_SAMPLES) {
ast_log(LOG_WARNING, "Out of buffer space\n");
return -1;
}
#ifdef _SPEEX_TYPES_H
speex_decode_int(tmp->speex, NULL, dst + pvt->samples);
#else
speex_decode(tmp->speex, NULL, fout);
for (x=0;x<tmp->framesize;x++) {
dst[pvt->samples + x] = (int16_t)fout[x];
}
#endif
pvt->samples += tmp->framesize;
pvt->datalen += 2 * tmp->framesize; /* 2 bytes/sample */
return 0;
}
/* Read in bits */
speex_bits_read_from(&tmp->bits, f->data.ptr, f->datalen);
for (;;) {
#ifdef _SPEEX_TYPES_H
res = speex_decode_int(tmp->speex, &tmp->bits, fout);
#else
res = speex_decode(tmp->speex, &tmp->bits, fout);
#endif
if (res < 0)
break;
if (pvt->samples + tmp->framesize > BUFFER_SAMPLES) {
ast_log(LOG_WARNING, "Out of buffer space\n");
return -1;
}
for (x = 0 ; x < tmp->framesize; x++)
dst[pvt->samples + x] = (int16_t)fout[x];
pvt->samples += tmp->framesize;
pvt->datalen += 2 * tmp->framesize; /* 2 bytes/sample */
}
return 0;
}
开发者ID:mtulio,项目名称:mtulio,代码行数:56,代码来源:codec_speex.c
示例15: Java_com_speex_Speex_decode
JNIEXPORT jint JNICALL Java_com_speex_Speex_decode(JNIEnv *env,
jobject obj, jbyteArray encoded, jshortArray lin, jint size) {
jbyte buffer[dec_frame_size];
jshort output_buffer[size];
jsize encoded_length = size;
int nsamples = (size - 1) / dec_frame_size + 1;
int i, offset = 0, tot_shorts = 0;
if (!codec_open)
return 0;
speex_bits_reset(&dbits);
// 把数据写入buffer
for(i = 0; i < nsamples; i++){
if(offset + i * dec_frame_size + dec_frame_size > size) {
env->GetByteArrayRegion(encoded, offset + i * dec_frame_size,
size - (offset + i * dec_frame_size), buffer);
speex_bits_read_from(&dbits, (char *) buffer, size - (offset + i * dec_frame_size));
} else {
env->GetByteArrayRegion(encoded, offset + i * dec_frame_size,
dec_frame_size, buffer);
speex_bits_read_from(&dbits, (char *) buffer, dec_frame_size);
}
}
// env->GetByteArrayRegion(encoded, 0, encoded_length, buffer);
// // buffer数据写入dbits
// speex_bits_read_fdrom(&dbits, (char *) buffer, encoded_length);
// dbits数据写入output_buffer
speex_decode_int(dec_state, &dbits, output_buffer);
// TODO
env->SetShortArrayRegion(lin, 0, encoded_length, output_buffer);
/*env->SetShortArrayRegion(lin, 0, dec_frame_size, output_buffer);*/
/*return (jint) dec_frame_size;*/
/*return (jint) encoded_length;*/
return (jint) encoded_length;
}
开发者ID:tiny2cui,项目名称:project,代码行数:40,代码来源:speex_jni.cpp
示例16: speex_bits_read_from
Boolean CASpeexDecoder::GenerateFrames()
{
Boolean ret = true;
int result;
mBDCStatus = kBDCStatusOK;
SpeexFramePacket &sfp = mSpeexFPList.front();
speex_bits_read_from(&mSpeexBits, reinterpret_cast<char*> (mBDCBuffer.GetData()), sfp.bytes);
if (sfp.frames > 0 && (sfp.frames - mSpeexHeader.frame_size * mSpeexHeader.frames_per_packet > 0)) {
UInt32 zeroBytes = mOutputFormat.FramesToBytes(sfp.frames - mSpeexHeader.frame_size * mSpeexHeader.frames_per_packet);
memset(mOutBuffer + mOutBufferUsedSize, 0, zeroBytes);
mOutBufferUsedSize += zeroBytes;
}
for (SInt32 i = 0; i < mSpeexHeader.frames_per_packet; i++) {
if (mOutputFormat.mFormatFlags & kAudioFormatFlagsNativeFloatPacked != 0)
result = speex_decode(mSpeexDecoderState, &mSpeexBits, reinterpret_cast<float*> (mOutBuffer + mOutBufferUsedSize));
else
result = speex_decode_int(mSpeexDecoderState, &mSpeexBits, reinterpret_cast<spx_int16_t*> (mOutBuffer + mOutBufferUsedSize));
if (result < 0) {
mBDCStatus = kBDCStatusAbort;
return false;
}
if (mSpeexHeader.nb_channels == 2) {
if (mOutputFormat.mFormatFlags & kAudioFormatFlagsNativeFloatPacked != 0)
speex_decode_stereo(reinterpret_cast<float*> (mOutBuffer + mOutBufferUsedSize), mSpeexHeader.frame_size, &mSpeexStereoState);
else
speex_decode_stereo_int(reinterpret_cast<spx_int16_t*> (mOutBuffer + mOutBufferUsedSize), mSpeexHeader.frame_size, &mSpeexStereoState);
}
mOutBufferUsedSize += mOutputFormat.FramesToBytes(mSpeexHeader.frame_size);
}
if (sfp.frames == 0) {
mNumFrames += mSpeexHeader.frame_size * mSpeexHeader.frames_per_packet;
} else if (sfp.frames > 0) {
mNumFrames += sfp.frames;
if (mSpeexHeader.frame_size * mSpeexHeader.frames_per_packet - sfp.frames != 0)
mOutBufferStart += mOutputFormat.FramesToBytes(mSpeexHeader.frame_size * mSpeexHeader.frames_per_packet - sfp.frames);
} else {
mNumFrames -= sfp.frames;
}
mBDCBuffer.Zap(sfp.bytes);
mSpeexFPList.erase(mSpeexFPList.begin());
return ret;
}
开发者ID:JanX2,项目名称:XiphQT,代码行数:51,代码来源:CASpeexDecoder.cpp
示例17: while
void *os_sound_start_thread(void *_ca)
{
jcall_t *ca = (jcall_t*)_ca;
char data_in[160];
short sp_data_in_s[640];
float sp_data_in_f[640];
int have_more;
int timestamp = 0;
int i;
while (ca->enable_audio != -1)
{
memset(data_in, 0, 160);
/* receive ONE packet */
i = rtp_session_recv_with_ts(ca->rtp_session, data_in, 160, timestamp, &have_more);
speex_bits_reset(&ca->dec_speex_bits);
speex_bits_read_from(&ca->dec_speex_bits, data_in, i);
while(1)
{
int k;
k = speex_decode(ca->speex_dec, &ca->dec_speex_bits, sp_data_in_f);
if (k==-2)
{
exit(0);
}
else if (k==-1)
{
break;
}
else if (k==0)
{
int j;
for (j=0;j<ca->speex_fsize;j++)
{
if (sp_data_in_f[j]>32767)
sp_data_in_f[j]=32767;
if (sp_data_in_f[j]<-32767)
sp_data_in_f[j]=-32767;
sp_data_in_s[j] = (short) sp_data_in_f[j];
}
write(fd, sp_data_in_s, ca->speex_fsize);
}
}
timestamp += 160;
}
return NULL;
}
开发者ID:BackupTheBerlios,项目名称:sfsipua-svn,代码行数:49,代码来源:sound-ortp.c
示例18: Java_org_thoughtcrime_redphone_codec_SpeexCodec_decode
JNIEXPORT jint JNICALL Java_org_thoughtcrime_redphone_codec_SpeexCodec_decode (JNIEnv *env, jobject obj, jbyteArray encArr, jshortArray decArr, jint encLen ){
cenv = env;
if( !initialized ) {
logv(env, "tried to decode without initializing" );
return -1;
}
if (decArr == NULL) {
logv(env, "Speex decode passed a null decode buffer" );
return -1;
}
jint dec_buffer_len = env->GetArrayLength( decArr );
int dec_buffer_idx = 0;
jbyte *jb_enc_stream;
char *enc_stream;
SpeexBits *dbits = NULL; //if this is null, speex will do PLC for us
if( !env->IsSameObject( encArr, NULL ) ) {
jb_enc_stream = env->GetByteArrayElements( encArr, NULL );
enc_stream = (char *)jb_enc_stream;
speex_bits_read_from( &dec_bits, enc_stream, encLen );
env->ReleaseByteArrayElements( encArr, jb_enc_stream, JNI_ABORT );
dbits = &dec_bits;
} else {
// logv( env, "null encArr" );
}
while( 0 == speex_decode_int( dec, dbits, dec_buffer+dec_buffer_idx ) ) {
dec_buffer_idx += dec_frame_size;
if( dec_buffer_idx + dec_frame_size >= dec_buffer_len ) {
logv( env, "out of space in the decArr buffer, idx=%d", dec_buffer_idx );
break;
}
if( dec_buffer_idx + dec_frame_size >= dec_frame_size * MAX_DEC_FRAMES ) {
logv( env, "out of space in the dec_buffer buffer, idx=%d", dec_buffer_idx );
break;
}
if( dbits == NULL ) {
// logv(env, "did PLC" );
break;//only generate one frame for PLC...
}
}
env->SetShortArrayRegion( decArr, 0, dec_buffer_idx, dec_buffer );
return dec_buffer_idx;
}
开发者ID:3141592653589793,项目名称:RedPhone,代码行数:49,代码来源:SpeexCodec.cpp
示例19: gviSpeexDecodeSet
void gviSpeexDecodeSet(GVSample * out, const GVByte * in, GVDecoderData data)
{
int rcode;
int i;
// read the data into the bits
speex_bits_read_from(&gviSpeexBits, (char *)in, gviSpeexEncodedFrameSize);
// decode it
rcode = speex_decode((void *)data, &gviSpeexBits, gviSpeexBuffer);
GS_ASSERT(rcode == 0);
// convert the output from floats
for(i = 0 ; i < gviSpeexSamplesPerFrame ; i++)
out[i] = (GVSample)gviSpeexBuffer[i];
}
开发者ID:gamespy-tech,项目名称:GameSpyOpenSource,代码行数:16,代码来源:gvSpeex.c
示例20: decode
static int decode(struct audec_state *st, int16_t *sampv,
size_t *sampc, const uint8_t *buf, size_t len)
{
const size_t n = st->channels * st->frame_size;
size_t i = 0;
/* Read into bit-stream */
speex_bits_read_from(&st->bits, (char *)buf, (int)len);
/* Handle multiple Speex frames in one RTP packet */
while (speex_bits_remaining(&st->bits) >= MIN_FRAME_SIZE) {
int ret;
if (*sampc < n)
return ENOMEM;
ret = speex_decode_int(st->dec, &st->bits,
(int16_t *)&sampv[i]);
if (ret < 0) {
if (-1 == ret) {
}
else if (-2 == ret) {
warning("speex: decode: corrupt stream\n");
}
else {
warning("speex: decode: speex_decode_int:"
" ret=%d\n", ret);
}
break;
}
/* Transforms a mono frame into a stereo frame
using intensity stereo info */
if (2 == st->channels) {
speex_decode_stereo_int((int16_t *)&sampv[i],
st->frame_size,
&st->stereo);
}
i += n;
*sampc -= n;
}
*sampc = i;
return 0;
}
开发者ID:FOSSRIT,项目名称:baresip,代码行数:47,代码来源:speex.c
注:本文中的speex_bits_read_from函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论