本文整理汇总了C++中speex_bits_unpack_unsigned函数的典型用法代码示例。如果您正苦于以下问题:C++ speex_bits_unpack_unsigned函数的具体用法?C++ speex_bits_unpack_unsigned怎么用?C++ speex_bits_unpack_unsigned使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了speex_bits_unpack_unsigned函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: speex_std_stereo_request_handler
EXPORT int speex_std_stereo_request_handler(SpeexBits * bits, void *state,
void *data)
{
(void)state;
RealSpeexStereoState *stereo;
spx_word16_t sign = 1, dexp;
int tmp;
stereo = (RealSpeexStereoState *) data;
COMPATIBILITY_HACK(stereo);
if (speex_bits_unpack_unsigned(bits, 1))
sign = -1;
dexp = speex_bits_unpack_unsigned(bits, 5);
#ifndef FIXED_POINT
stereo->balance = exp(sign * .25 * dexp);
#else
stereo->balance = spx_exp(MULT16_16(sign, SHL16(dexp, 9)));
#endif
tmp = speex_bits_unpack_unsigned(bits, 2);
stereo->e_ratio = e_ratio_quant[tmp];
return 0;
}
示例2: lsp_unquant_nb
void lsp_unquant_nb(spx_lsp_t *lsp, int order, SpeexBits *bits)
{
int i, id;
for (i=0;i<order;i++)
lsp[i]=LSP_LINEAR(i);
id=speex_bits_unpack_unsigned(bits, 6);
for (i=0;i<10;i++)
lsp[i] = ADD32(lsp[i], LSP_DIV_256(cdbk_nb[id*10+i]));
id=speex_bits_unpack_unsigned(bits, 6);
for (i=0;i<5;i++)
lsp[i] = ADD16(lsp[i], LSP_DIV_512(cdbk_nb_low1[id*5+i]));
id=speex_bits_unpack_unsigned(bits, 6);
for (i=0;i<5;i++)
lsp[i] = ADD32(lsp[i], LSP_DIV_1024(cdbk_nb_low2[id*5+i]));
id=speex_bits_unpack_unsigned(bits, 6);
for (i=0;i<5;i++)
lsp[i+5] = ADD32(lsp[i+5], LSP_DIV_512(cdbk_nb_high1[id*5+i]));
id=speex_bits_unpack_unsigned(bits, 6);
for (i=0;i<5;i++)
lsp[i+5] = ADD32(lsp[i+5], LSP_DIV_1024(cdbk_nb_high2[id*5+i]));
}
示例3: split_cb_shape_sign_unquant
void split_cb_shape_sign_unquant(
spx_sig_t *exc,
const void *par, /* non-overlapping codebook */
int nsf, /* number of samples in subframe */
SpeexBits *bits,
char *stack,
spx_int32_t *seed
)
{
int i,j;
VARDECL(int *ind);
VARDECL(int *signs);
const signed char *shape_cb;
//int shape_cb_size;
int subvect_size, nb_subvect;
const split_cb_params *params;
int have_sign;
params = (const split_cb_params *) par;
subvect_size = params->subvect_size;
nb_subvect = params->nb_subvect;
//shape_cb_size = 1<<params->shape_bits;
shape_cb = params->shape_cb;
have_sign = params->have_sign;
ALLOC(ind, nb_subvect, int);
ALLOC(signs, nb_subvect, int);
/* Decode codewords and gains */
for (i=0;i<nb_subvect;i++)
{
if (have_sign)
signs[i] = speex_bits_unpack_unsigned(bits, 1);
else
signs[i] = 0;
ind[i] = speex_bits_unpack_unsigned(bits, params->shape_bits);
}
/* Compute decoded excitation */
for (i=0;i<nb_subvect;i++)
{
spx_word16_t s=1;
if (signs[i])
s=-1;
#ifdef FIXED_POINT
if (s==1)
{
for (j=0;j<subvect_size;j++)
exc[subvect_size*i+j]=SHL32(EXTEND32(shape_cb[ind[i]*subvect_size+j]),SIG_SHIFT-5);
} else {
for (j=0;j<subvect_size;j++)
exc[subvect_size*i+j]=NEG32(SHL32(EXTEND32(shape_cb[ind[i]*subvect_size+j]),SIG_SHIFT-5));
}
#else
for (j=0;j<subvect_size;j++)
exc[subvect_size*i+j]+=s*0.03125*shape_cb[ind[i]*subvect_size+j];
#endif
}
}
示例4: speex_std_vbr_quality_request_handler
int speex_std_vbr_quality_request_handler(SpeexBits *bits, void *state, void *data)
{
int qual;
qual = speex_bits_unpack_unsigned(bits, 4);
speex_encoder_ctl(data, SPEEX_SET_VBR_QUALITY, &qual);
return 0;
}
示例5: speex_std_enh_request_handler
int speex_std_enh_request_handler(SpeexBits *bits, void *state, void *data)
{
int enh;
enh = speex_bits_unpack_unsigned(bits, 1);
speex_decoder_ctl(data, SPEEX_SET_ENH, &enh);
return 0;
}
示例6: speex_std_high_mode_request_handler
int speex_std_high_mode_request_handler(SpeexBits *bits, void *state, void *data)
{
int m;
m = speex_bits_unpack_unsigned(bits, 4);
speex_encoder_ctl(data, SPEEX_SET_HIGH_MODE, &m);
return 0;
}
示例7: speex_std_char_handler
int speex_std_char_handler(SpeexBits *bits, void *state, void *data)
{
unsigned char ch;
ch = speex_bits_unpack_unsigned(bits, 8);
_speex_putc(ch, data);
return 0;
}
示例8: speex_std_low_mode_request_handler
EXPORT int speex_std_low_mode_request_handler(SpeexBits *bits, void *state, void *data)
{
spx_int32_t m;
m = speex_bits_unpack_unsigned(bits, 4);
speex_encoder_ctl(data, SPEEX_SET_LOW_MODE, &m);
return 0;
}
示例9: speex_std_vbr_request_handler
int speex_std_vbr_request_handler(SpeexBits *bits, void *state, void *data)
{
int vbr;
vbr = speex_bits_unpack_unsigned(bits, 1);
speex_encoder_ctl(data, SPEEX_SET_VBR, &vbr);
return 0;
}
示例10: speex_inband_handler
int speex_inband_handler(SpeexBits *bits, SpeexCallback *callback_list, void *state)
{
int id;
SpeexCallback *callback;
/*speex_bits_advance(bits, 5);*/
id=speex_bits_unpack_unsigned(bits, 4);
callback = callback_list+id;
if (callback->func)
{
return callback->func(bits, state, callback->data);
} else
/*If callback is not registered, skip the right number of bits*/
{
int adv;
if (id<2)
adv = 1;
else if (id<8)
adv = 4;
else if (id<10)
adv = 8;
else if (id<12)
adv = 16;
else if (id<14)
adv = 32;
else
adv = 64;
speex_bits_advance(bits, adv);
}
return 0;
}
示例11: speex_std_char_handler
int speex_std_char_handler(SpeexBits *bits, void *state, void *data)
{
unsigned char ch;
ch = speex_bits_unpack_unsigned(bits, 8);
_speex_putc(ch, data);
/*printf("speex_std_char_handler ch=%x\n", ch);*/
return 0;
}
示例12: lsp_unquant_high
void lsp_unquant_high(spx_lsp_t *lsp, int order, SpeexBits *bits)
{
int i, id;
for (i=0;i<order;i++)
lsp[i]=LSP_LINEAR_HIGH(i);
id=speex_bits_unpack_unsigned(bits, 6);
for (i=0;i<order;i++)
lsp[i] += LSP_DIV_256(high_lsp_cdbk[id*order+i]);
id=speex_bits_unpack_unsigned(bits, 6);
for (i=0;i<order;i++)
lsp[i] += LSP_DIV_512(high_lsp_cdbk2[id*order+i]);
}
示例13: speex_std_stereo_request_handler
int speex_std_stereo_request_handler(SpeexBits *bits, void *state, void *data)
{
SpeexStereoState *stereo;
float sign=1;
int tmp;
stereo = (SpeexStereoState*)data;
if (speex_bits_unpack_unsigned(bits, 1))
sign=-1;
tmp = speex_bits_unpack_unsigned(bits, 5);
stereo->balance = exp(sign*.25*tmp);
tmp = speex_bits_unpack_unsigned(bits, 2);
stereo->e_ratio = e_ratio_quant[tmp];
return 0;
}
示例14: speex_get_next_frame
/* This function will iterate frames & submodes in the Speex bits.
* Returns 0 if a frame found, otherwise returns -1.
*/
int speex_get_next_frame(SpeexBits *bits)
{
static const int inband_skip_table[NB_SUBMODES] =
{1, 1, 4, 4, 4, 4, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64 };
static const int wb_skip_table[SB_SUBMODES] =
{SB_SUBMODE_BITS+1, 36, 112, 192, 352, -1, -1, -1};
unsigned submode;
unsigned nb_count = 0;
while (speex_bits_remaining(bits) >= 5) {
unsigned wb_count = 0;
unsigned bit_ptr = bits->bitPtr;
unsigned char_ptr = bits->charPtr;
/* WB frame */
while ((speex_bits_remaining(bits) >= 4)
&& speex_bits_unpack_unsigned(bits, 1))
{
int advance;
submode = speex_bits_unpack_unsigned(bits, 3);
advance = wb_skip_table[submode];
if (advance < 0) {
TRACE__((THIS_FUNC, "Invalid mode encountered. "
"The stream is corrupted."));
return -1;
}
TRACE__((THIS_FUNC, "WB layer skipped: %d bits", advance));
advance -= (SB_SUBMODE_BITS+1);
speex_bits_advance(bits, advance);
bit_ptr = bits->bitPtr;
char_ptr = bits->charPtr;
/* Consecutive subband frames may not exceed 2 frames */
if (++wb_count > 2)
return -1;
}
/* End of bits, return the frame */
if (speex_bits_remaining(bits) < 4) {
TRACE__((THIS_FUNC, "End of stream"));
return 0;
}
/* Stop iteration, return the frame */
if (nb_count > 0) {
bits->bitPtr = bit_ptr;
bits->charPtr = char_ptr;
return 0;
}
/* Get control bits */
submode = speex_bits_unpack_unsigned(bits, 4);
TRACE__((THIS_FUNC, "Control bits: %d at %d",
submode, bits->charPtr*8+bits->bitPtr));
if (submode == 15) {
TRACE__((THIS_FUNC, "Found submode: terminator"));
return -1;
} else if (submode == 14) {
/* in-band signal; next 4 bits contain signal id */
submode = speex_bits_unpack_unsigned(bits, 4);
TRACE__((THIS_FUNC, "Found submode: in-band %d bits",
inband_skip_table[submode]));
speex_bits_advance(bits, inband_skip_table[submode]);
} else if (submode == 13) {
/* user in-band; next 5 bits contain msg len */
submode = speex_bits_unpack_unsigned(bits, 5);
TRACE__((THIS_FUNC, "Found submode: user-band %d bytes", submode));
speex_bits_advance(bits, submode * 8);
} else if (submode > 8) {
TRACE__((THIS_FUNC, "Unknown sub-mode %d", submode));
return -1;
} else {
/* NB frame */
unsigned int advance = submode;
speex_mode_query(&speex_nb_mode, SPEEX_SUBMODE_BITS_PER_FRAME, &advance);
if (advance < 0) {
TRACE__((THIS_FUNC, "Invalid mode encountered. "
"The stream is corrupted."));
return -1;
}
TRACE__((THIS_FUNC, "Submode %d: %d bits", submode, advance));
advance -= (NB_SUBMODE_BITS+1);
speex_bits_advance(bits, advance);
++nb_count;
}
}
return 0;
}
示例15: pitch_unquant_3tap
void pitch_unquant_3tap(
spx_sig_t exc[], /* Excitation */
int start, /* Smallest pitch value allowed */
int end, /* Largest pitch value allowed */
spx_word16_t pitch_coef, /* Voicing (pitch) coefficient */
const void *par,
int nsf, /* Number of samples in subframe */
int *pitch_val,
spx_word16_t *gain_val,
SpeexBits *bits,
char *stack,
int count_lost,
int subframe_offset,
spx_word16_t last_pitch_gain,
int cdbk_offset
)
{
int i;
int pitch;
int gain_index;
spx_word16_t gain[3];
const signed char *gain_cdbk;
int gain_cdbk_size;
const ltp_params *params;
params = (const ltp_params*) par;
gain_cdbk_size = 1<<params->gain_bits;
gain_cdbk = params->gain_cdbk + 3*gain_cdbk_size*cdbk_offset;
pitch = speex_bits_unpack_unsigned(bits, params->pitch_bits);
pitch += start;
gain_index = speex_bits_unpack_unsigned(bits, params->gain_bits);
/*printf ("decode pitch: %d %d\n", pitch, gain_index);*/
#ifdef FIXED_POINT
gain[0] = 32+(spx_word16_t)gain_cdbk[gain_index*3];
gain[1] = 32+(spx_word16_t)gain_cdbk[gain_index*3+1];
gain[2] = 32+(spx_word16_t)gain_cdbk[gain_index*3+2];
#else
gain[0] = 0.015625*gain_cdbk[gain_index*3]+.5;
gain[1] = 0.015625*gain_cdbk[gain_index*3+1]+.5;
gain[2] = 0.015625*gain_cdbk[gain_index*3+2]+.5;
#endif
if (count_lost && pitch > subframe_offset)
{
float gain_sum;
if (1) {
float tmp = count_lost < 4 ? GAIN_SCALING_1*last_pitch_gain : 0.4 * GAIN_SCALING_1 * last_pitch_gain;
if (tmp>.95)
tmp=.95;
gain_sum = GAIN_SCALING_1*gain_3tap_to_1tap(gain);
if (gain_sum > tmp) {
float fact = tmp/gain_sum;
for (i=0; i<3; i++)
gain[i]*=fact;
}
}
}
*pitch_val = pitch;
gain_val[0]=gain[0];
gain_val[1]=gain[1];
gain_val[2]=gain[2];
{
spx_sig_t *e[3];
VARDECL(spx_sig_t *tmp2);
ALLOC(tmp2, 3*nsf, spx_sig_t);
e[0]=tmp2;
e[1]=tmp2+nsf;
e[2]=tmp2+2*nsf;
for (i=0; i<3; i++)
{
int j;
int pp=pitch+1-i;
#if 0
for (j=0; j<nsf; j++)
{
if (j-pp<0)
e[i][j]=exc[j-pp];
else if (j-pp-pitch<0)
e[i][j]=exc[j-pp-pitch];
else
e[i][j]=0;
}
#else
{
int tmp1, tmp3;
tmp1=nsf;
if (tmp1>pp)
tmp1=pp;
for (j=0; j<tmp1; j++)
e[i][j]=exc[j-pp];
tmp3=nsf;
if (tmp3>pp+pitch)
//.........这里部分代码省略.........