您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ EXTRACT16函数代码示例

51自学网 2021-06-01 20:36:33
  C++
这篇教程C++ EXTRACT16函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中EXTRACT16函数的典型用法代码示例。如果您正苦于以下问题:C++ EXTRACT16函数的具体用法?C++ EXTRACT16怎么用?C++ EXTRACT16使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了EXTRACT16函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: speex_decode_stereo_int

void speex_decode_stereo_int(spx_int16_t *data, int frame_size, SpeexStereoState *_stereo){   int i;   spx_word32_t balance;   spx_word16_t e_left, e_right, e_ratio;   RealSpeexStereoState *stereo = (RealSpeexStereoState*)_stereo;   /* COMPATIBILITY_HACK(stereo); */      balance=stereo->balance;   e_ratio=stereo->e_ratio;      /* These two are Q14, with max value just below 2. */   e_right = DIV32(QCONST32(1., 22), spx_sqrt(MULT16_32_Q15(e_ratio, ADD32(QCONST32(1., 16), balance))));   e_left = SHR32(MULT16_16(spx_sqrt(balance), e_right), 8);   for (i=frame_size-1;i>=0;i--)   {      spx_int16_t tmp=data[i];      stereo->smooth_left = EXTRACT16(PSHR32(MAC16_16(MULT16_16(stereo->smooth_left, QCONST16(0.98, 15)), e_left, QCONST16(0.02, 15)), 15));      stereo->smooth_right = EXTRACT16(PSHR32(MAC16_16(MULT16_16(stereo->smooth_right, QCONST16(0.98, 15)), e_right, QCONST16(0.02, 15)), 15));      data[2*i] = (spx_int16_t)MULT16_16_P14(stereo->smooth_left, tmp);      data[2*i+1] = (spx_int16_t)MULT16_16_P14(stereo->smooth_right, tmp);   }}
开发者ID:4nykey,项目名称:rockbox,代码行数:25,


示例2: tansig_approx

static inline opus_val16 tansig_approx(opus_val32 _x){				/* Q19 */	int i;	opus_val16 xx;		/* Q11 */	/*double x, y; */	opus_val16 dy, yy;	/* Q14 */	/*x = 1.9073e-06*_x; */	if (_x >= QCONST32(8, 19))		return QCONST32(1., 14);	if (_x <= -QCONST32(8, 19))		return -QCONST32(1., 14);	xx = EXTRACT16(SHR32(_x, 8));	/*i = lrint(25*x); */	i = SHR32(ADD32(1024, MULT16_16(25, xx)), 11);	/*x -= .04*i; */	xx -= EXTRACT16(SHR32(MULT16_16(20972, i), 8));	/*x = xx*(1./2048); */	/*y = tansig_table[250+i]; */	yy = tansig_table[250 + i];	/*y = yy*(1./16384); */	dy = 16384 - MULT16_16_Q14(yy, yy);	yy = yy + MULT16_16_Q14(MULT16_16_Q11(xx, dy),				(16384 - MULT16_16_Q11(yy, xx)));	return yy;}
开发者ID:CEPBEP,项目名称:onion-phone,代码行数:25,


示例3: exp_rotation1

static void exp_rotation1(celt_norm *X, int len, int stride, opus_val16 c, opus_val16 s){    int i;    opus_val16 ms;    celt_norm *Xptr;    Xptr = X;    ms = NEG16(s);    for (i=0; i<len-stride; i++)    {        celt_norm x1, x2;        x1 = Xptr[0];        x2 = Xptr[stride];        Xptr[stride] = EXTRACT16(PSHR32(MAC16_16(MULT16_16(c, x2),  s, x1), 15));        *Xptr++      = EXTRACT16(PSHR32(MAC16_16(MULT16_16(c, x1), ms, x2), 15));    }    Xptr = &X[len-2*stride-1];    for (i=len-2*stride-1; i>=0; i--)    {        celt_norm x1, x2;        x1 = Xptr[0];        x2 = Xptr[stride];        Xptr[stride] = EXTRACT16(PSHR32(MAC16_16(MULT16_16(c, x2),  s, x1), 15));        *Xptr--      = EXTRACT16(PSHR32(MAC16_16(MULT16_16(c, x1), ms, x2), 15));    }}
开发者ID:carriercomm,项目名称:opus,代码行数:25,


示例4: mdf_adjust_prop

static inline void mdf_adjust_prop(const spx_word32_t *W, int N, int M, int P, spx_word16_t *prop){   int i, j, p;   spx_word16_t max_sum = 1;   spx_word32_t prop_sum = 1;   for (i=0;i<M;i++)   {      spx_word32_t tmp = 1;      for (p=0;p<P;p++)         for (j=0;j<N;j++)            tmp += MULT16_16(EXTRACT16(SHR32(W[p*N*M + i*N+j],18)), EXTRACT16(SHR32(W[p*N*M + i*N+j],18)));#ifdef FIXED_POINT      /* Just a security in case an overflow were to occur */      tmp = MIN32(ABS32(tmp), 536870912);#endif      prop[i] = spx_sqrt(tmp);      if (prop[i] > max_sum)         max_sum = prop[i];   }   for (i=0;i<M;i++)   {      prop[i] += MULT16_16_Q15(QCONST16(.1f,15),max_sum);      prop_sum += EXTEND32(prop[i]);   }   for (i=0;i<M;i++)   {      prop[i] = DIV32(MULT16_16(QCONST16(.99f,15), prop[i]),prop_sum);      /*printf ("%f ", prop[i]);*/   }   /*printf ("/n");*/}
开发者ID:FreshLeaf8865,项目名称:mumble,代码行数:31,


示例5: compute_band_energies

/* Compute the amplitude (sqrt energy) in each of the bands */void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *bandE, int end, int C, int M){   int i, c, N;   const opus_int16 *eBands = m->eBands;   N = M*m->shortMdctSize;   c=0; do {      for (i=0;i<end;i++)      {         int j;         opus_val32 maxval=0;         opus_val32 sum = 0;         j=M*eBands[i]; do {            maxval = MAX32(maxval, X[j+c*N]);            maxval = MAX32(maxval, -X[j+c*N]);         } while (++j<M*eBands[i+1]);         if (maxval > 0)         {            int shift = celt_ilog2(maxval)-10;            j=M*eBands[i]; do {               sum = MAC16_16(sum, EXTRACT16(VSHR32(X[j+c*N],shift)),                                   EXTRACT16(VSHR32(X[j+c*N],shift)));            } while (++j<M*eBands[i+1]);            /* We're adding one here to make damn sure we never end up with a pitch vector that's               larger than unity norm */            bandE[i+c*m->nbEBands] = EPSILON+VSHR32(EXTEND32(celt_sqrt(sum)),-shift);         } else {            bandE[i+c*m->nbEBands] = EPSILON;         }         /*printf ("%f ", bandE[i+c*m->nbEBands]);*/      }   } while (++c<C);   /*printf ("/n");*/}
开发者ID:oneman,项目名称:opus-oneman,代码行数:36,


示例6: forced_pitch_quant

/** Forced pitch delay and gain */int forced_pitch_quant(spx_word16_t target[],	/* Target vector */		       spx_word16_t * sw, spx_coef_t ak[],	/* LPCs for this subframe */		       spx_coef_t awk1[],	/* Weighted LPCs #1 for this subframe */		       spx_coef_t awk2[],	/* Weighted LPCs #2 for this subframe */		       spx_sig_t exc[],	/* Excitation */		       const void *par, int start,	/* Smallest pitch value allowed */		       int end,	/* Largest pitch value allowed */		       spx_word16_t pitch_coef,	/* Voicing (pitch) coefficient */		       int p,	/* Number of LPC coeffs */		       int nsf,	/* Number of samples in subframe */		       SpeexBits * bits,		       char *stack,		       spx_word16_t * exc2,		       spx_word16_t * r,		       int complexity,		       int cdbk_offset,		       int plc_tuning, spx_word32_t * cumul_gain){	(void)sw;	(void)par;	(void)end;	(void)bits;	(void)r;	(void)complexity;	(void)cdbk_offset;	(void)plc_tuning;	(void)cumul_gain;	int i;	spx_word16_t res[nsf];#ifdef FIXED_POINT	if (pitch_coef > 63)		pitch_coef = 63;#else	if (pitch_coef > .99)		pitch_coef = .99;#endif	for (i = 0; i < nsf && i < start; i++) {		exc[i] = MULT16_16(SHL16(pitch_coef, 7), exc2[i - start]);	}	for (; i < nsf; i++) {		exc[i] = MULT16_32_Q15(SHL16(pitch_coef, 9), exc[i - start]);	}	for (i = 0; i < nsf; i++)		res[i] = EXTRACT16(PSHR32(exc[i], SIG_SHIFT - 1));	syn_percep_zero16(res, ak, awk1, awk2, res, nsf, p, stack);	for (i = 0; i < nsf; i++)		target[i] =		    EXTRACT16(SATURATE			      (SUB32(EXTEND32(target[i]), EXTEND32(res[i])),			       32700));	return start;}
开发者ID:CEPBEP,项目名称:onion-phone,代码行数:53,


示例7: speex_rand

spx_word32_t speex_rand(spx_word16_t std, spx_int32_t *seed){   spx_word32_t res;   *seed = 1664525 * *seed + 1013904223;   res = MULT16_16(EXTRACT16(SHR32(*seed,16)),std);   return SUB32(res, SHR(res, 3));}
开发者ID:Caboose1543,项目名称:LUNIServerProject,代码行数:7,


示例8: compute_weighted_codebook

static void compute_weighted_codebook(const signed char *shape_cb, const spx_word16_t *r, spx_word16_t *resp, spx_word16_t *resp2, spx_word32_t *E, int shape_cb_size, int subvect_size, char *stack){   int i, j, k;   VARDECL(spx_word16_t *shape);   ALLOC(shape, subvect_size, spx_word16_t);   for (i=0;i<shape_cb_size;i++)   {      spx_word16_t *res;            res = resp+i*subvect_size;      for (k=0;k<subvect_size;k++)         shape[k] = (spx_word16_t)shape_cb[i*subvect_size+k];      E[i]=0;      /* Compute codeword response using convolution with impulse response */      for(j=0;j<subvect_size;j++)      {         spx_word32_t resj=0;         spx_word16_t res16;         for (k=0;k<=j;k++)            resj = MAC16_16(resj,shape[k],r[j-k]);#ifdef FIXED_POINT         res16 = EXTRACT16(SHR32(resj, 13));#else         res16 = 0.03125f*resj;#endif         /* Compute codeword energy */         E[i]=MAC16_16(E[i],res16,res16);         res[j] = res16;         /*printf ("%d/n", (int)res[j]);*/      }   }}
开发者ID:TomDataworks,项目名称:whisper_client,代码行数:34,


示例9: find_best_pitch

static void find_best_pitch(opus_val32 *xcorr, opus_val16 *y, int len,                            int max_pitch, int *best_pitch#ifdef FIXED_POINT                            , int yshift, opus_val32 maxcorr#endif                            ){   int i, j;   opus_val32 Syy=1;   opus_val16 best_num[2];   opus_val32 best_den[2];#ifdef FIXED_POINT   int xshift;   xshift = celt_ilog2(maxcorr)-14;#endif   best_num[0] = -1;   best_num[1] = -1;   best_den[0] = 0;   best_den[1] = 0;   best_pitch[0] = 0;   best_pitch[1] = 1;   for (j=0;j<len;j++)      Syy = ADD32(Syy, SHR32(MULT16_16(y[j],y[j]), yshift));   for (i=0;i<max_pitch;i++)   {      if (xcorr[i]>0)      {         opus_val16 num;         opus_val32 xcorr16;         xcorr16 = EXTRACT16(VSHR32(xcorr[i], xshift));#ifndef FIXED_POINT         /* Considering the range of xcorr16, this should avoid both underflows            and overflows (inf) when squaring xcorr16 */         xcorr16 *= 1e-12f;#endif         num = MULT16_16_Q15(xcorr16,xcorr16);         if (MULT16_32_Q15(num,best_den[1]) > MULT16_32_Q15(best_num[1],Syy))         {            if (MULT16_32_Q15(num,best_den[0]) > MULT16_32_Q15(best_num[0],Syy))            {               best_num[1] = best_num[0];               best_den[1] = best_den[0];               best_pitch[1] = best_pitch[0];               best_num[0] = num;               best_den[0] = Syy;               best_pitch[0] = i;            } else {               best_num[1] = num;               best_den[1] = Syy;               best_pitch[1] = i;            }         }      }      Syy += SHR32(MULT16_16(y[i+len],y[i+len]),yshift) - SHR32(MULT16_16(y[i],y[i]),yshift);      Syy = MAX32(1, Syy);   }}
开发者ID:93i,项目名称:godot,代码行数:59,


示例10: speex_echo_ctl

EXPORT int speex_echo_ctl(SpeexEchoState *st, int request, void *ptr){   switch(request)   {            case SPEEX_ECHO_GET_FRAME_SIZE:         (*(int*)ptr) = st->frame_size;         break;      case SPEEX_ECHO_SET_SAMPLING_RATE:         st->sampling_rate = (*(int*)ptr);         st->spec_average = DIV32_16(SHL32(EXTEND32(st->frame_size), 15), st->sampling_rate);#ifdef FIXED_POINT         st->beta0 = DIV32_16(SHL32(EXTEND32(st->frame_size), 16), st->sampling_rate);         st->beta_max = DIV32_16(SHL32(EXTEND32(st->frame_size), 14), st->sampling_rate);#else         st->beta0 = (2.0f*st->frame_size)/st->sampling_rate;         st->beta_max = (.5f*st->frame_size)/st->sampling_rate;#endif         if (st->sampling_rate<12000)            st->notch_radius = QCONST16(.9, 15);         else if (st->sampling_rate<24000)            st->notch_radius = QCONST16(.982, 15);         else            st->notch_radius = QCONST16(.992, 15);         break;      case SPEEX_ECHO_GET_SAMPLING_RATE:         (*(int*)ptr) = st->sampling_rate;         break;      case SPEEX_ECHO_GET_IMPULSE_RESPONSE_SIZE:         /*FIXME: Implement this for multiple channels */         *((spx_int32_t *)ptr) = st->M * st->frame_size;         break;      case SPEEX_ECHO_GET_IMPULSE_RESPONSE:      {         int M = st->M, N = st->window_size, n = st->frame_size, i, j;         spx_int32_t *filt = (spx_int32_t *) ptr;         for(j=0;j<M;j++)         {            /*FIXME: Implement this for multiple channels */#ifdef FIXED_POINT            for (i=0;i<N;i++)               st->wtmp2[i] = EXTRACT16(PSHR32(st->W[j*N+i],16+NORMALIZE_SCALEDOWN));            spx_ifft(st->fft_table, st->wtmp2, st->wtmp);#else            spx_ifft(st->fft_table, &st->W[j*N], st->wtmp);#endif            for(i=0;i<n;i++)               filt[j*n+i] = PSHR32(MULT16_16(32767,st->wtmp[i]), WEIGHT_SHIFT-NORMALIZE_SCALEDOWN);         }      }         break;      default:         speex_warning_int("Unknown speex_echo_ctl request: ", request);         return -1;   }   return 0;}
开发者ID:FreshLeaf8865,项目名称:mumble,代码行数:57,


示例11: SIG2WORD16

static __inline celt_word16_t SIG2WORD16(celt_sig_t x){#ifdef FIXED_POINT   x = PSHR32(x, SIG_SHIFT);   x = MAX32(x, -32768);   x = MIN32(x, 32767);   return EXTRACT16(x);#else   return (celt_word16_t)x;#endif}
开发者ID:tzhuan,项目名称:llcon,代码行数:11,


示例12: find_best_pitch

static void find_best_pitch(opus_val32 *xcorr, opus_val16 *y, int len,                            int max_pitch, int *best_pitch#ifdef FIXED_POINT                            , int yshift, opus_val32 maxcorr#endif                            ){   int i, j;   opus_val32 Syy=1;   opus_val16 best_num[2];   opus_val32 best_den[2];#ifdef FIXED_POINT   int xshift;   xshift = celt_ilog2(maxcorr)-14;#endif   best_num[0] = -1;   best_num[1] = -1;   best_den[0] = 0;   best_den[1] = 0;   best_pitch[0] = 0;   best_pitch[1] = 1;   for (j=0;j<len;j++)      Syy = MAC16_16(Syy, y[j],y[j]);   for (i=0;i<max_pitch;i++)   {      if (xcorr[i]>0)      {         opus_val16 num;         opus_val32 xcorr16;         xcorr16 = EXTRACT16(VSHR32(xcorr[i], xshift));         num = MULT16_16_Q15(xcorr16,xcorr16);         if (MULT16_32_Q15(num,best_den[1]) > MULT16_32_Q15(best_num[1],Syy))         {            if (MULT16_32_Q15(num,best_den[0]) > MULT16_32_Q15(best_num[0],Syy))            {               best_num[1] = best_num[0];               best_den[1] = best_den[0];               best_pitch[1] = best_pitch[0];               best_num[0] = num;               best_den[0] = Syy;               best_pitch[0] = i;            } else {               best_num[1] = num;               best_den[1] = Syy;               best_pitch[1] = i;            }         }      }      Syy += SHR32(MULT16_16(y[i+len],y[i+len]),yshift) - SHR32(MULT16_16(y[i],y[i]),yshift);      Syy = MAX32(1, Syy);   }}
开发者ID:oneman,项目名称:opus-oneman,代码行数:54,


示例13: SIG2WORD16

static inline opus_val16 SIG2WORD16(celt_sig x){#ifdef FIXED_POINT   x = PSHR32(x, SIG_SHIFT);   x = MAX32(x, -32768);   x = MIN32(x, 32767);   return EXTRACT16(x);#else   return (opus_val16)x;#endif}
开发者ID:Sciumo,项目名称:opus,代码行数:11,


示例14: filterbank_compute_psd16

void filterbank_compute_psd16(FilterBank *bank, spx_word16_t *mel, spx_word16_t *ps){   int i;   for (i=0;i<bank->len;i++)   {      spx_word32_t tmp;      int id1, id2;      id1 = bank->bank_left[i];      id2 = bank->bank_right[i];      tmp = MULT16_16(mel[id1],bank->filter_left[i]);      tmp += MULT16_16(mel[id2],bank->filter_right[i]);      ps[i] = EXTRACT16(PSHR32(tmp,15));   }}
开发者ID:03050903,项目名称:godot,代码行数:14,


示例15: compute_band_energies

/* Compute the amplitude (sqrt energy) in each of the bands */void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *bank, int _C){   int i, c, N;   const celt_int16 *eBands = m->eBands;   const int C = CHANNELS(_C);   N = FRAMESIZE(m);   for (c=0;c<C;c++)   {      for (i=0;i<m->nbEBands;i++)      {         int j;         celt_word32 maxval=0;         celt_word32 sum = 0;                  j=eBands[i]; do {            maxval = MAX32(maxval, X[j+c*N]);            maxval = MAX32(maxval, -X[j+c*N]);         } while (++j<eBands[i+1]);                  if (maxval > 0)         {            int shift = celt_ilog2(maxval)-10;            j=eBands[i]; do {               sum = MAC16_16(sum, EXTRACT16(VSHR32(X[j+c*N],shift)),                                   EXTRACT16(VSHR32(X[j+c*N],shift)));            } while (++j<eBands[i+1]);            /* We're adding one here to make damn sure we never end up with a pitch vector that's               larger than unity norm */            bank[i+c*m->nbEBands] = EPSILON+VSHR32(EXTEND32(celt_sqrt(sum)),-shift);         } else {            bank[i+c*m->nbEBands] = EPSILON;         }         /*printf ("%f ", bank[i+c*m->nbEBands]);*/      }   }   /*printf ("/n");*/}
开发者ID:FreshLeaf8865,项目名称:mumble,代码行数:38,


示例16: cubic_coef

static void cubic_coef(spx_word16_t x, spx_word16_t interp[4]){   /* Compute interpolation coefficients. I'm not sure whether this corresponds to cubic interpolation   but I know it's MMSE-optimal on a sinc */   spx_word16_t x2, x3;   x2 = MULT16_16_P15(x, x);   x3 = MULT16_16_P15(x, x2);   interp[0] = PSHR32(MULT16_16(QCONST16(-0.16667f, 15),x) + MULT16_16(QCONST16(0.16667f, 15),x3),15);   interp[1] = EXTRACT16(EXTEND32(x) + SHR32(SUB32(EXTEND32(x2),EXTEND32(x3)),1));   interp[3] = PSHR32(MULT16_16(QCONST16(-0.33333f, 15),x) + MULT16_16(QCONST16(.5f,15),x2) - MULT16_16(QCONST16(0.16667f, 15),x3),15);   /* Just to make sure we don't have rounding problems */   interp[2] = Q15_ONE-interp[0]-interp[1]-interp[3];   if (interp[2]<32767)      interp[2]+=1;}
开发者ID:CharaD7,项目名称:wireshark,代码行数:15,


示例17: mlp_process

void mlp_process(const MLP * m, const opus_val16 * in, opus_val16 * out){	int j;	opus_val16 hidden[MAX_NEURONS];	const opus_val16 *W = m->weights;	/* Copy to tmp_in */	for (j = 0; j < m->topo[1]; j++) {		int k;		opus_val32 sum = SHL32(EXTEND32(*W++), 8);		for (k = 0; k < m->topo[0]; k++)			sum = MAC16_16(sum, in[k], *W++);		hidden[j] = tansig_approx(sum);	}	for (j = 0; j < m->topo[2]; j++) {		int k;		opus_val32 sum = SHL32(EXTEND32(*W++), 14);		for (k = 0; k < m->topo[1]; k++)			sum = MAC16_16(sum, hidden[k], *W++);		out[j] = tansig_approx(EXTRACT16(PSHR32(sum, 17)));	}}
开发者ID:CEPBEP,项目名称:onion-phone,代码行数:21,


示例18: split_cb_search_shape_sign

void split_cb_search_shape_sign(spx_word16_t target[],			/* target vector */spx_coef_t ak[],			/* LPCs for this subframe */spx_coef_t awk1[],			/* Weighted LPCs for this subframe */spx_coef_t awk2[],			/* Weighted LPCs for this subframe */const void *par,                      /* Codebook/search parameters*/int   p,                        /* number of LPC coeffs */int   nsf,                      /* number of samples in subframe */spx_sig_t *exc,spx_word16_t *r,SpeexBits *bits,char *stack,int   complexity,int   update_target){   int i,j,m,q;   const signed char *shape_cb;   int shape_cb_size = 32, subvect_size = 10;   int best_index;   spx_word32_t best_dist;   spx_word16_t resp[320];   spx_word16_t *resp2 = resp;   spx_word32_t E[32];   spx_word16_t t[40];   spx_sig_t  e[40];   shape_cb=exc_10_32_table;      /* FIXME: Do we still need to copy the target? */   SPEEX_COPY(t, target, nsf);   //compute_weighted_codebook   {     int i, k;     spx_word16_t shape[10];	 for (i=0;i<shape_cb_size;i++)     {       spx_word16_t *res;             res = resp+i*subvect_size;       for (k=0;k<subvect_size;k++)          shape[k] = (spx_word16_t)shape_cb[i*subvect_size+k];       E[i]=0;       /* Compute codeword response using convolution with impulse response */       {	     spx_word32_t resj;         spx_word16_t res16;	  	 		 // 0                   resj = MULT16_16(shape[0],r[0]);		 res16 = EXTRACT16(SHR32(resj, 13));         // Compute codeword energy          E[i]=MAC16_16(E[i],res16,res16);         res[0] = res16;         //++++++++++++++++++++++++++         		 // 1                   resj = MULT16_16(shape[0],r[1]);    		 resj = MAC16_16(resj,shape[1],r[0]);         res16 = EXTRACT16(SHR32(resj, 13));         // Compute codeword energy          E[i]=MAC16_16(E[i],res16,res16);         res[1] = res16;         //++++++++++++++++++++++++++                  // 2                  resj = MULT16_16(shape[0],r[2]);    		 resj = MAC16_16(resj,shape[1],r[1]);         resj = MAC16_16(resj,shape[2],r[0]);         res16 = EXTRACT16(SHR32(resj, 13));         // Compute codeword energy          E[i]=MAC16_16(E[i],res16,res16);         res[2] = res16;         //++++++++++++++++++++++++++                  // 3                   resj = MULT16_16(shape[0],r[3]);         resj = MAC16_16(resj,shape[1],r[2]);         resj = MAC16_16(resj,shape[2],r[1]);		 resj = MAC16_16(resj,shape[3],r[0]);         res16 = EXTRACT16(SHR32(resj, 13));         // Compute codeword energy          E[i]=MAC16_16(E[i],res16,res16);         res[3] = res16;         //++++++++++++++++++++++++++                  // 4                 resj = MULT16_16(shape[0],r[4]);         resj = MAC16_16(resj,shape[1],r[3]);         resj = MAC16_16(resj,shape[2],r[2]);         resj = MAC16_16(resj,shape[3],r[1]);		 resj = MAC16_16(resj,shape[4],r[0]);         res16 = EXTRACT16(SHR32(resj, 13));         // Compute codeword energy          E[i]=MAC16_16(E[i],res16,res16);         res[4] = res16;         //++++++++++++++++++++++++++         //.........这里部分代码省略.........
开发者ID:thaidao,项目名称:Workspace_Ex,代码行数:101,


示例19: pitch_gain_search_3tap

//.........这里部分代码省略.........#endif        ALLOC(t, nsf, spx_word16_t);        for (j=0; j<3; j++)        {            for (i=0; i<nsf; i++)            {                spx_sig_t tmp = x[j][i];                if (tmp<0)                    tmp = -tmp;                if (tmp > max_val)                    max_val = tmp;            }        }        for (i=0; i<nsf; i++)        {            spx_sig_t tmp = target[i];            if (tmp<0)                tmp = -tmp;            if (tmp > max_val)                max_val = tmp;        }        sig_shift=0;        while (max_val>16384)        {            sig_shift++;            max_val >>= 1;        }        for (j=0; j<3; j++)        {            for (i=0; i<nsf; i++)            {                y[j][i] = EXTRACT16(SHR32(x[j][i],sig_shift));            }        }        for (i=0; i<nsf; i++)        {            t[i] = EXTRACT16(SHR32(target[i],sig_shift));        }        for (i=0; i<3; i++)            corr[i]=inner_prod(y[i],t,nsf);        for (i=0; i<3; i++)            for (j=0; j<=i; j++)                A[i][j]=A[j][i]=inner_prod(y[i],y[j],nsf);    }#else    {        for (i=0; i<3; i++)            corr[i]=inner_prod(x[i],target,nsf);        for (i=0; i<3; i++)            for (j=0; j<=i; j++)                A[i][j]=A[j][i]=inner_prod(x[i],x[j],nsf);    }#endif    {        spx_word32_t C[9];        const signed char *ptr=gain_cdbk;        int best_cdbk=0;        spx_word32_t best_sum=0;        C[0]=corr[2];        C[1]=corr[1];
开发者ID:Affix,项目名称:fgcom,代码行数:67,


示例20: split_cb_search_shape_sign

//.........这里部分代码省略.........         }         if (i==0)            break;      }      for (j=0;j<N;j++)      {         /*previous target (we don't care what happened before*/         for (m=(i+1)*subvect_size;m<nsf;m++)            nt[j][m]=ot[best_ntarget[j]][m];                  /* New code: update the rest of the target only if it's worth it */         for (m=0;m<subvect_size;m++)         {            spx_word16_t g;            int rind;            spx_word16_t sign=1;            rind = best_nind[j];            if (rind>=shape_cb_size)            {               sign=-1;               rind-=shape_cb_size;            }            q=subvect_size-m;#ifdef FIXED_POINT            g=sign*shape_cb[rind*subvect_size+m];#else            g=sign*0.03125*shape_cb[rind*subvect_size+m];#endif            target_update(nt[j]+subvect_size*(i+1), g, r+q, nsf-subvect_size*(i+1));         }         for (q=0;q<nb_subvect;q++)            nind[j][q]=oind[best_ntarget[j]][q];         nind[j][i]=best_nind[j];      }      /*update old-new data*/      /* just swap pointers instead of a long copy */      {         spx_word16_t **tmp2;         tmp2=ot;         ot=nt;         nt=tmp2;      }      for (j=0;j<N;j++)         for (m=0;m<nb_subvect;m++)            oind[j][m]=nind[j][m];      for (j=0;j<N;j++)         odist[j]=ndist[j];   }   /*save indices*/   for (i=0;i<nb_subvect;i++)   {      ind[i]=nind[0][i];      speex_bits_pack(bits,ind[i],params->shape_bits+have_sign);   }      /* Put everything back together */   for (i=0;i<nb_subvect;i++)   {      int rind;      spx_word16_t sign=1;      rind = ind[i];      if (rind>=shape_cb_size)      {         sign=-1;         rind-=shape_cb_size;      }#ifdef FIXED_POINT      if (sign==1)      {         for (j=0;j<subvect_size;j++)            e[subvect_size*i+j]=SHL32(EXTEND32(shape_cb[rind*subvect_size+j]),SIG_SHIFT-5);      } else {         for (j=0;j<subvect_size;j++)            e[subvect_size*i+j]=NEG32(SHL32(EXTEND32(shape_cb[rind*subvect_size+j]),SIG_SHIFT-5));      }#else      for (j=0;j<subvect_size;j++)         e[subvect_size*i+j]=sign*0.03125*shape_cb[rind*subvect_size+j];#endif   }      /* Update excitation */   for (j=0;j<nsf;j++)      exc[j]=ADD32(exc[j],e[j]);      /* Update target: only update target if necessary */   if (update_target)   {      VARDECL(spx_word16_t *r2);      ALLOC(r2, nsf, spx_word16_t);      for (j=0;j<nsf;j++)         r2[j] = EXTRACT16(PSHR32(e[j] ,6));      syn_percep_zero16(r2, ak, awk1, awk2, r2, nsf,p, stack);      for (j=0;j<nsf;j++)         target[j]=SUB16(target[j],PSHR16(r2[j],2));   }}
开发者ID:TomDataworks,项目名称:whisper_client,代码行数:101,


示例21: split_cb_search_shape_sign_N1

//.........这里部分代码省略.........   ALLOC(resp2, (shape_cb_size*subvect_size)>>2, __m128);   ALLOC(E, shape_cb_size>>2, __m128);#else   resp2 = resp;   ALLOC(E, shape_cb_size, spx_word32_t);#endif   ALLOC(t, nsf, spx_word16_t);   ALLOC(e, nsf, spx_sig_t);      /* FIXME: Do we still need to copy the target? */   SPEEX_COPY(t, target, nsf);   compute_weighted_codebook(shape_cb, r, resp, resp2, E, shape_cb_size, subvect_size, stack);   for (i=0;i<nb_subvect;i++)   {      spx_word16_t *x=t+subvect_size*i;      /*Find new n-best based on previous n-best j*/#ifndef DISABLE_WIDEBAND      if (have_sign)         vq_nbest_sign(x, resp2, subvect_size, shape_cb_size, E, 1, &best_index, &best_dist, stack);      else#endif /* DISABLE_WIDEBAND */         vq_nbest(x, resp2, subvect_size, shape_cb_size, E, 1, &best_index, &best_dist, stack);            speex_bits_pack(bits,best_index,params->shape_bits+have_sign);            {         int rind;         spx_word16_t *res;         spx_word16_t sign=1;         rind = best_index;         if (rind>=shape_cb_size)         {            sign=-1;            rind-=shape_cb_size;         }         res = resp+rind*subvect_size;         if (sign>0)            for (m=0;m<subvect_size;m++)               t[subvect_size*i+m] = SUB16(t[subvect_size*i+m], res[m]);         else            for (m=0;m<subvect_size;m++)               t[subvect_size*i+m] = ADD16(t[subvect_size*i+m], res[m]);#ifdef FIXED_POINT         if (sign==1)         {            for (j=0;j<subvect_size;j++)               e[subvect_size*i+j]=SHL32(EXTEND32(shape_cb[rind*subvect_size+j]),SIG_SHIFT-5);         } else {            for (j=0;j<subvect_size;j++)               e[subvect_size*i+j]=NEG32(SHL32(EXTEND32(shape_cb[rind*subvect_size+j]),SIG_SHIFT-5));         }#else         for (j=0;j<subvect_size;j++)            e[subvect_size*i+j]=sign*0.03125*shape_cb[rind*subvect_size+j];#endif            }                  for (m=0;m<subvect_size;m++)      {         spx_word16_t g;         int rind;         spx_word16_t sign=1;         rind = best_index;         if (rind>=shape_cb_size)         {            sign=-1;            rind-=shape_cb_size;         }                  q=subvect_size-m;#ifdef FIXED_POINT         g=sign*shape_cb[rind*subvect_size+m];#else         g=sign*0.03125*shape_cb[rind*subvect_size+m];#endif         target_update(t+subvect_size*(i+1), g, r+q, nsf-subvect_size*(i+1));      }   }   /* Update excitation */   /* FIXME: We could update the excitation directly above */   for (j=0;j<nsf;j++)      exc[j]=ADD32(exc[j],e[j]);      /* Update target: only update target if necessary */   if (update_target)   {      VARDECL(spx_word16_t *r2);      ALLOC(r2, nsf, spx_word16_t);      for (j=0;j<nsf;j++)         r2[j] = EXTRACT16(PSHR32(e[j] ,6));      syn_percep_zero16(r2, ak, awk1, awk2, r2, nsf,p, stack);      for (j=0;j<nsf;j++)         target[j]=SUB16(target[j],PSHR16(r2[j],2));   }}
开发者ID:TomDataworks,项目名称:whisper_client,代码行数:101,


示例22: DIV32

FilterBank *filterbank_new(int banks, spx_word32_t sampling, int len, int type){   FilterBank *bank;   spx_word32_t df;   spx_word32_t max_mel, mel_interval;   int i;   int id1;   int id2;   df = DIV32(SHL32(sampling,15),MULT16_16(2,len));   max_mel = toBARK(EXTRACT16(sampling/2));   mel_interval = PDIV32(max_mel,banks-1);      bank = (FilterBank*)speex_alloc(sizeof(FilterBank));   bank->nb_banks = banks;   bank->len = len;   bank->bank_left = (int*)speex_alloc(len*sizeof(int));   bank->bank_right = (int*)speex_alloc(len*sizeof(int));   bank->filter_left = (spx_word16_t*)speex_alloc(len*sizeof(spx_word16_t));   bank->filter_right = (spx_word16_t*)speex_alloc(len*sizeof(spx_word16_t));   /* Think I can safely disable normalisation that for fixed-point (and probably float as well) */#ifndef FIXED_POINT   bank->scaling = (float*)speex_alloc(banks*sizeof(float));#endif   for (i=0;i<len;i++)   {      spx_word16_t curr_freq;      spx_word32_t mel;      spx_word16_t val;      curr_freq = EXTRACT16(MULT16_32_P15(i,df));      mel = toBARK(curr_freq);      if (mel > max_mel)         break;#ifdef FIXED_POINT      id1 = DIV32(mel,mel_interval);#else            id1 = (int)(floor(mel/mel_interval));#endif      if (id1>banks-2)      {         id1 = banks-2;         val = Q15_ONE;      } else {         val = DIV32_16(mel - id1*mel_interval,EXTRACT16(PSHR32(mel_interval,15)));      }      id2 = id1+1;      bank->bank_left[i] = id1;      bank->filter_left[i] = SUB16(Q15_ONE,val);      bank->bank_right[i] = id2;      bank->filter_right[i] = val;   }      /* Think I can safely disable normalisation for fixed-point (and probably float as well) */#ifndef FIXED_POINT   for (i=0;i<bank->nb_banks;i++)      bank->scaling[i] = 0;   for (i=0;i<bank->len;i++)   {      int id = bank->bank_left[i];      bank->scaling[id] += bank->filter_left[i];      id = bank->bank_right[i];      bank->scaling[id] += bank->filter_right[i];   }   for (i=0;i<bank->nb_banks;i++)      bank->scaling[i] = Q15_ONE/(bank->scaling[i]);#endif   return bank;}
开发者ID:03050903,项目名称:godot,代码行数:67,


示例23: quant_coarse_energy_impl

static int quant_coarse_energy_impl(const CELTMode *m, int start, int end,      const opus_val16 *eBands, opus_val16 *oldEBands,      opus_int32 budget, opus_int32 tell,      const unsigned char *prob_model, opus_val16 *error, ec_enc *enc,      int C, int LM, int intra, opus_val16 max_decay){   int i, c;   int badness = 0;   opus_val32 prev[2] = {0,0};   opus_val16 coef;   opus_val16 beta;   if (tell+3 <= budget)      ec_enc_bit_logp(enc, intra, 3);   if (intra)   {      coef = 0;      beta = beta_intra;   } else {      beta = beta_coef[LM];      coef = pred_coef[LM];   }   /* Encode at a fixed coarse resolution */   for (i=start;i<end;i++)   {      c=0;      do {         int bits_left;         int qi, qi0;         opus_val32 q;         opus_val16 x;         opus_val32 f, tmp;         opus_val16 oldE;         opus_val16 decay_bound;         x = eBands[i+c*m->nbEBands];         oldE = MAX16(-QCONST16(9.f,DB_SHIFT), oldEBands[i+c*m->nbEBands]);#ifdef FIXED_POINT         f = SHL32(EXTEND32(x),7) - PSHR32(MULT16_16(coef,oldE), 8) - prev[c];         /* Rounding to nearest integer here is really important! */         qi = (f+QCONST32(.5f,DB_SHIFT+7))>>(DB_SHIFT+7);         decay_bound = EXTRACT16(MAX32(-QCONST16(28.f,DB_SHIFT),               SUB32((opus_val32)oldEBands[i+c*m->nbEBands],max_decay)));#else         f = x-coef*oldE-prev[c];         /* Rounding to nearest integer here is really important! */         qi = (int)floor(.5f+f);         decay_bound = MAX16(-QCONST16(28.f,DB_SHIFT), oldEBands[i+c*m->nbEBands]) - max_decay;#endif         /* Prevent the energy from going down too quickly (e.g. for bands            that have just one bin) */         if (qi < 0 && x < decay_bound)         {            qi += (int)SHR16(SUB16(decay_bound,x), DB_SHIFT);            if (qi > 0)               qi = 0;         }         qi0 = qi;         /* If we don't have enough bits to encode all the energy, just assume             something safe. */         tell = ec_tell(enc);         bits_left = budget-tell-3*C*(end-i);         if (i!=start && bits_left < 30)         {            if (bits_left < 24)               qi = IMIN(1, qi);            if (bits_left < 16)               qi = IMAX(-1, qi);         }         if (budget-tell >= 15)         {            int pi;            pi = 2*IMIN(i,20);            ec_laplace_encode(enc, &qi,                  prob_model[pi]<<7, prob_model[pi+1]<<6);         }         else if(budget-tell >= 2)         {            qi = IMAX(-1, IMIN(qi, 1));            ec_enc_icdf(enc, 2*qi^-(qi<0), small_energy_icdf, 2);         }         else if(budget-tell >= 1)         {            qi = IMIN(0, qi);            ec_enc_bit_logp(enc, -qi, 1);         }         else            qi = -1;         error[i+c*m->nbEBands] = PSHR32(f,7) - SHL16(qi,DB_SHIFT);         badness += abs(qi0-qi);         q = (opus_val32)SHL32(EXTEND32(qi),DB_SHIFT);         tmp = PSHR32(MULT16_16(coef,oldE),8) + prev[c] + SHL32(q,7);#ifdef FIXED_POINT         tmp = MAX32(-QCONST32(28.f, DB_SHIFT+7), tmp);#endif         oldEBands[i+c*m->nbEBands] = PSHR32(tmp, 7);         prev[c] = prev[c] + SHL32(q,7) - MULT16_16(beta,PSHR32(q,8));      } while (++c < C);   }//.........这里部分代码省略.........
开发者ID:AdaDoom3,项目名称:AdaDoom3Libraries,代码行数:101,


示例24: sb_encode

int sb_encode(void *state, void *vin, SpeexBits *bits){   SBEncState *st;   int i, roots, sub;   char *stack;   VARDECL(spx_mem_t *mem);   VARDECL(spx_sig_t *innov);   VARDECL(spx_word16_t *target);   VARDECL(spx_word16_t *syn_resp);   VARDECL(spx_word32_t *low_pi_gain);   spx_word16_t *low;   spx_word16_t *high;   VARDECL(spx_word16_t *low_exc_rms);   VARDECL(spx_word16_t *low_innov_rms);   const SpeexSBMode *mode;   spx_int32_t dtx;   spx_word16_t *in = (spx_word16_t*)vin;   spx_word16_t e_low=0, e_high=0;   VARDECL(spx_coef_t *lpc);   VARDECL(spx_coef_t *interp_lpc);   VARDECL(spx_coef_t *bw_lpc1);   VARDECL(spx_coef_t *bw_lpc2);   VARDECL(spx_lsp_t *lsp);   VARDECL(spx_lsp_t *qlsp);   VARDECL(spx_lsp_t *interp_lsp);   VARDECL(spx_lsp_t *interp_qlsp);         st = (SBEncState*)state;   stack=st->stack;   mode = (const SpeexSBMode*)(st->mode->mode);   low = in;   high = in+st->frame_size;      /* High-band buffering / sync with low band */   /* Compute the two sub-bands by filtering with QMF h0*/   qmf_decomp(in, h0, low, high, st->full_frame_size, QMF_ORDER, st->h0_mem, stack);   #ifndef DISABLE_VBR   if (st->vbr_enabled || st->vad_enabled)   {      /* Need to compute things here before the signal is trashed by the encoder */      /*FIXME: Are the two signals (low, high) in sync? */      e_low = compute_rms16(low, st->frame_size);      e_high = compute_rms16(high, st->frame_size);   }#endif /* #ifndef DISABLE_VBR */   ALLOC(low_innov_rms, st->nbSubframes, spx_word16_t);   speex_encoder_ctl(st->st_low, SPEEX_SET_INNOVATION_SAVE, low_innov_rms);   /* Encode the narrowband part*/   speex_encode_native(st->st_low, low, bits);   high = high - (st->windowSize-st->frame_size);   SPEEX_COPY(high, st->high, st->windowSize-st->frame_size);   SPEEX_COPY(st->high, &high[st->frame_size], st->windowSize-st->frame_size);      ALLOC(low_pi_gain, st->nbSubframes, spx_word32_t);   ALLOC(low_exc_rms, st->nbSubframes, spx_word16_t);   speex_encoder_ctl(st->st_low, SPEEX_GET_PI_GAIN, low_pi_gain);   speex_encoder_ctl(st->st_low, SPEEX_GET_EXC, low_exc_rms);      speex_encoder_ctl(st->st_low, SPEEX_GET_LOW_MODE, &dtx);   if (dtx==0)      dtx=1;   else      dtx=0;   ALLOC(lpc, st->lpcSize, spx_coef_t);   ALLOC(interp_lpc, st->lpcSize, spx_coef_t);   ALLOC(bw_lpc1, st->lpcSize, spx_coef_t);   ALLOC(bw_lpc2, st->lpcSize, spx_coef_t);      ALLOC(lsp, st->lpcSize, spx_lsp_t);   ALLOC(qlsp, st->lpcSize, spx_lsp_t);   ALLOC(interp_lsp, st->lpcSize, spx_lsp_t);   ALLOC(interp_qlsp, st->lpcSize, spx_lsp_t);      {      VARDECL(spx_word16_t *autocorr);      VARDECL(spx_word16_t *w_sig);      ALLOC(autocorr, st->lpcSize+1, spx_word16_t);      ALLOC(w_sig, st->windowSize, spx_word16_t);      /* Window for analysis */      /* FIXME: This is a kludge */      if (st->subframeSize==80)      {         for (i=0;i<st->windowSize;i++)            w_sig[i] = EXTRACT16(SHR32(MULT16_16(high[i],st->window[i>>1]),SIG_SHIFT));      } else {         for (i=0;i<st->windowSize;i++)            w_sig[i] = EXTRACT16(SHR32(MULT16_16(high[i],st->window[i]),SIG_SHIFT));      }      /* Compute auto-correlation */      _spx_autocorr(w_sig, autocorr, st->lpcSize+1, st->windowSize);      autocorr[0] = ADD16(autocorr[0],MULT16_16_Q15(autocorr[0],st->lpc_floor)); /* Noise floor in auto-correlation domain */      /* Lag windowing: equivalent to filtering in the power-spectrum domain */      for (i=0;i<st->lpcSize+1;i++)//.........这里部分代码省略.........
开发者ID:AstralSerpent,项目名称:QtZ,代码行数:101,


示例25: split_cb_search_shape_sign

//.........这里部分代码省略.........#else   resp2 = resp;   ALLOC(E, shape_cb_size, spx_word32_t);#endif   ALLOC(t, nsf, spx_word16_t);   ALLOC(e, nsf, spx_sig_t);   ALLOC(r2, nsf, spx_sig_t);   ALLOC(ind, nb_subvect, int);   ALLOC(tmp, 2*N*nsf, spx_word16_t);   for (i=0;i<N;i++)   {      ot2[i]=tmp+2*i*nsf;      nt2[i]=tmp+(2*i+1)*nsf;   }   ot=ot2;   nt=nt2;   ALLOC(best_index, N, int);   ALLOC(best_dist, N, spx_word32_t);   ALLOC(ndist, N, spx_word32_t);   ALLOC(odist, N, spx_word32_t);      ALLOC(itmp, 2*N*nb_subvect, int);   for (i=0;i<N;i++)   {      nind[i]=itmp+2*i*nb_subvect;      oind[i]=itmp+(2*i+1)*nb_subvect;      for (j=0;j<nb_subvect;j++)         nind[i][j]=oind[i][j]=-1;   }      /* FIXME: make that adaptive? */   for (i=0;i<nsf;i++)      t[i]=EXTRACT16(PSHR32(target[i],6));   for (j=0;j<N;j++)      for (i=0;i<nsf;i++)         ot[j][i]=t[i];   /*for (i=0;i<nsf;i++)     printf ("%d/n", (int)t[i]);*/   /* Pre-compute codewords response and energy */   compute_weighted_codebook(shape_cb, r, resp, resp2, E, shape_cb_size, subvect_size, stack);   for (j=0;j<N;j++)      odist[j]=0;   /*For all subvectors*/   for (i=0;i<nb_subvect;i++)   {      /*"erase" nbest list*/      for (j=0;j<N;j++)         ndist[j]=-2;      /*For all n-bests of previous subvector*/      for (j=0;j<N;j++)      {         spx_word16_t *x=ot[j]+subvect_size*i;         /*Find new n-best based on previous n-best j*/         if (have_sign)            vq_nbest_sign(x, resp2, subvect_size, shape_cb_size, E, N, best_index, best_dist, stack);         else            vq_nbest(x, resp2, subvect_size, shape_cb_size, E, N, best_index, best_dist, stack);         /*For all new n-bests*/         for (k=0;k<N;k++)
开发者ID:Balaji12341234,项目名称:fgcom,代码行数:67,


示例26: lsp_to_lpc

void lsp_to_lpc(spx_lsp_t *freq,spx_coef_t *ak,int lpcrdr, char *stack)/*  float *freq 	array of LSP frequencies in the x domain	*//*  float *ak 		array of LPC coefficients 			*//*  int lpcrdr  	order of LPC coefficients 			*/{    int i,j;    spx_word32_t xout1,xout2,xin1,xin2;    VARDECL(spx_word32_t *Wp);    spx_word32_t *pw,*n1,*n2,*n3,*n4=NULL;    VARDECL(spx_word16_t *freqn);    int m = lpcrdr>>1;        ALLOC(freqn, lpcrdr, spx_word16_t);    for (i=0;i<lpcrdr;i++)       freqn[i] = ANGLE2X(freq[i]);    ALLOC(Wp, 4*m+2, spx_word32_t);    pw = Wp;    /* initialise contents of array */    for(i=0;i<=4*m+1;i++){       	/* set contents of buffer to 0 */	*pw++ = 0;    }    /* Set pointers up */    pw = Wp;    xin1 = 1048576;    xin2 = 1048576;    /* reconstruct P(z) and Q(z) by  cascading second order      polynomials in form 1 - 2xz(-1) +z(-2), where x is the      LSP coefficient */    for(j=0;j<=lpcrdr;j++){       spx_word16_t *fr=freqn;	for(i=0;i<m;i++){	    n1 = pw+(i<<2);	    n2 = n1 + 1;	    n3 = n2 + 1;	    n4 = n3 + 1;	    xout1 = ADD32(SUB32(xin1, MULT16_32_Q14(*fr,*n1)), *n2);            fr++;            xout2 = ADD32(SUB32(xin2, MULT16_32_Q14(*fr,*n3)), *n4);            fr++;	    *n2 = *n1;	    *n4 = *n3;	    *n1 = xin1;	    *n3 = xin2;	    xin1 = xout1;	    xin2 = xout2;	}	xout1 = xin1 + *(n4+1);	xout2 = xin2 - *(n4+2);        /* FIXME: perhaps apply bandwidth expansion in case of overflow? */        /*FIXME: Is it OK to have a long constant? */        if (xout1 + xout2>SHL(32766,8))           ak[j] = 32767;        else if (xout1 + xout2 < -SHL(32766,8))           ak[j] = -32767;        else           ak[j] = EXTRACT16(PSHR32(ADD32(xout1,xout2),8));	*(n4+1) = xin1;	*(n4+2) = xin2;	xin1 = 0;	xin2 = 0;    }}
开发者ID:VoxOx,项目名称:VoxOx,代码行数:73,


示例27: speex_encode_stereo_int

EXPORT void speex_encode_stereo_int(spx_int16_t * data, int frame_size,				    SpeexBits * bits){	int i, tmp;	spx_word32_t e_left = 0, e_right = 0, e_tot = 0;	spx_word32_t balance, e_ratio;	spx_word32_t largest, smallest;	int balance_id;#ifdef FIXED_POINT	int shift;#endif	/* In band marker */	speex_bits_pack(bits, 14, 5);	/* Stereo marker */	speex_bits_pack(bits, SPEEX_INBAND_STEREO, 4);	for (i = 0; i < frame_size; i++) {		e_left += SHR32(MULT16_16(data[2 * i], data[2 * i]), 8);		e_right +=		    SHR32(MULT16_16(data[2 * i + 1], data[2 * i + 1]), 8);#ifdef FIXED_POINT		/* I think this is actually unbiased */		data[i] = SHR16(data[2 * i], 1) + PSHR16(data[2 * i + 1], 1);#else		data[i] = .5 * (((float)data[2 * i]) + data[2 * i + 1]);#endif		e_tot += SHR32(MULT16_16(data[i], data[i]), 8);	}	if (e_left > e_right) {		speex_bits_pack(bits, 0, 1);		largest = e_left;		smallest = e_right;	} else {		speex_bits_pack(bits, 1, 1);		largest = e_right;		smallest = e_left;	}	/* Balance quantization */#ifdef FIXED_POINT	shift = spx_ilog2(largest) - 15;	largest = VSHR32(largest, shift - 4);	smallest = VSHR32(smallest, shift);	balance = DIV32(largest, ADD32(smallest, 1));	if (balance > 32767)		balance = 32767;	balance_id = scal_quant(EXTRACT16(balance), balance_bounds, 32);#else	balance = (largest + 1.) / (smallest + 1.);	balance = 4 * log(balance);	balance_id = floor(.5 + fabs(balance));	if (balance_id > 30)		balance_id = 31;#endif	speex_bits_pack(bits, balance_id, 5);	/* "coherence" quantisation */#ifdef FIXED_POINT	shift = spx_ilog2(e_tot);	e_tot = VSHR32(e_tot, shift - 25);	e_left = VSHR32(e_left, shift - 10);	e_right = VSHR32(e_right, shift - 10);	e_ratio = DIV32(e_tot, e_left + e_right + 1);#else	e_ratio = e_tot / (1. + e_left + e_right);#endif	tmp = scal_quant(EXTRACT16(e_ratio), e_ratio_quant_bounds, 4);	/*fprintf (stderr, "%d %d %d %d/n", largest, smallest, balance_id, e_ratio); */	speex_bits_pack(bits, tmp, 2);}
开发者ID:CEPBEP,项目名称:onion-phone,代码行数:73,


示例28: speex_echo_cancellation

/** Performs echo cancellation on a frame */EXPORT void speex_echo_cancellation(SpeexEchoState *st, const spx_int16_t *in, const spx_int16_t *far_end, spx_int16_t *out){   int i,j, chan, speak;   int N,M, C, K;   spx_word32_t Syy,See,Sxx,Sdd, Sff;#ifdef TWO_PATH   spx_word32_t Dbf;   int update_foreground;#endif   spx_word32_t Sey;   spx_word16_t ss, ss_1;   spx_float_t Pey = FLOAT_ONE, Pyy=FLOAT_ONE;   spx_float_t alpha, alpha_1;   spx_word16_t RER;   spx_word32_t tmp32;      N = st->window_size;   M = st->M;   C = st->C;   K = st->K;   st->cancel_count++;#ifdef FIXED_POINT   ss=DIV32_16(11469,M);   ss_1 = SUB16(32767,ss);#else   ss=.35/M;   ss_1 = 1-ss;#endif   for (chan = 0; chan < C; chan++)   {      /* Apply a notch filter to make sure DC doesn't end up causing problems */      filter_dc_notch16(in+chan, st->notch_radius, st->input+chan*st->frame_size, st->frame_size, st->notch_mem+2*chan, C);      /* Copy input data to buffer and apply pre-emphasis */      /* Copy input data to buffer */      for (i=0;i<st->frame_size;i++)      {         spx_word32_t tmp32;         /* FIXME: This core has changed a bit, need to merge properly */         tmp32 = SUB32(EXTEND32(st->input[chan*st->frame_size+i]), EXTEND32(MULT16_16_P15(st->preemph, st->memD[chan])));#ifdef FIXED_POINT         if (tmp32 > 32767)         {            tmp32 = 32767;            if (st->saturated == 0)               st->saturated = 1;         }               if (tmp32 < -32767)         {            tmp32 = -32767;            if (st->saturated == 0)               st->saturated = 1;         }#endif         st->memD[chan] = st->input[chan*st->frame_size+i];         st->input[chan*st->frame_size+i] = EXTRACT16(tmp32);      }   }   for (speak = 0; speak < K; speak++)   {      for (i=0;i<st->frame_size;i++)      {         spx_word32_t tmp32;         st->x[speak*N+i] = st->x[speak*N+i+st->frame_size];         tmp32 = SUB32(EXTEND32(far_end[i*K+speak]), EXTEND32(MULT16_16_P15(st->preemph, st->memX[speak])));#ifdef FIXED_POINT         /*FIXME: If saturation occurs here, we need to freeze adaptation for M frames (not just one) */         if (tmp32 > 32767)         {            tmp32 = 32767;            st->saturated = M+1;         }               if (tmp32 < -32767)         {            tmp32 = -32767;            st->saturated = M+1;         }      #endif         st->x[speak*N+i+st->frame_size] = EXTRACT16(tmp32);         st->memX[speak] = far_end[i*K+speak];      }   }         for (speak = 0; speak < K; speak++)   {      /* Shift memory: this could be optimized eventually*/      for (j=M-1;j>=0;j--)      {         for (i=0;i<N;i++)            st->X[(j+1)*N*K+speak*N+i] = st->X[j*N*K+speak*N+i];      }      /* Convert x (echo input) to frequency domain */      spx_fft(st->fft_table, st->x+speak*N, &st->X[speak*N]);   }      Sxx = 0;   for (speak = 0; speak < K; speak++)//.........这里部分代码省略.........
开发者ID:FreshLeaf8865,项目名称:mumble,代码行数:101,



注:本文中的EXTRACT16函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ EXTRACT_16BITS函数代码示例
C++ EXTI_Init函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。