Ignore:
Timestamp:
Jul 26, 2006 5:04:54 PM (18 years ago)
Author:
bennylp
Message:
  • Bring speex codec up to date with their SVN trunk
  • Speex codec should work in FIXED_POINT mode when PJ_HAS_FLOATING_POINT is set to zero.
  • ulaw2linear will return zero if zero is given (this would make the VAD works better, and it also fixed click noise when call is established/hangup).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia-codec/speex/cb_search.c

    r278 r628  
    7171            resj = MAC16_16(resj,shape[k],r[j-k]); 
    7272#ifdef FIXED_POINT 
    73          res16 = EXTRACT16(SHR32(resj, 11)); 
     73         res16 = EXTRACT16(SHR32(resj, 13)); 
    7474#else 
    7575         res16 = 0.03125f*resj; 
     
    8989{ 
    9090   int n; 
    91    int q=0; 
    92    for (n=0;n<len;n++,q++) 
    93       t[n] = SUB32(t[n],MULT16_16_Q11_32(g,r[q])); 
     91   for (n=0;n<len;n++) 
     92      t[n] = SUB16(t[n],PSHR32(MULT16_16(g,r[n]),13)); 
    9493} 
    9594#endif 
     
    9897 
    9998static void split_cb_search_shape_sign_N1( 
    100 spx_sig_t target[],                     /* target vector */ 
     99spx_word16_t target[],                  /* target vector */ 
    101100spx_coef_t ak[],                        /* LPCs for this subframe */ 
    102101spx_coef_t awk1[],                      /* Weighted LPCs for this subframe */ 
     
    114113{ 
    115114   int i,j,m,q; 
    116 #ifndef FIXED_POINT 
    117    int n; 
    118 #endif 
    119115   VARDECL(spx_word16_t *resp); 
    120116#ifdef _USE_SSE 
     
    159155   /* FIXME: make that adaptive? */ 
    160156   for (i=0;i<nsf;i++) 
    161       t[i]=EXTRACT16(PSHR32(target[i],6)); 
     157      t[i]=target[i]; 
    162158 
    163159   compute_weighted_codebook(shape_cb, r, resp, resp2, E, shape_cb_size, subvect_size, stack); 
     
    223219#ifdef FIXED_POINT 
    224220         g=sign*shape_cb[rind*subvect_size+m]; 
     221#else 
     222         g=sign*0.03125*shape_cb[rind*subvect_size+m]; 
     223#endif 
    225224         target_update(t+subvect_size*(i+1), g, r+q, nsf-subvect_size*(i+1)); 
    226 #else 
    227          g=sign*0.03125*shape_cb[rind*subvect_size+m]; 
    228          /*FIXME: I think that one too can be replaced by target_update */ 
    229          for (n=subvect_size*(i+1);n<nsf;n++,q++) 
    230             t[n] = SUB32(t[n],g*r[q]); 
    231 #endif 
    232225      } 
    233226   } 
     
    245238      syn_percep_zero(e, ak, awk1, awk2, r2, nsf,p, stack); 
    246239      for (j=0;j<nsf;j++) 
    247          target[j]=SUB32(target[j],r2[j]); 
     240         target[j]=SUB16(target[j],EXTRACT16(PSHR32(r2[j],8))); 
    248241   } 
    249242} 
     
    252245 
    253246void split_cb_search_shape_sign( 
    254 spx_sig_t target[],                     /* target vector */ 
     247spx_word16_t target[],                  /* target vector */ 
    255248spx_coef_t ak[],                        /* LPCs for this subframe */ 
    256249spx_coef_t awk1[],                      /* Weighted LPCs for this subframe */ 
     
    357350   /* FIXME: make that adaptive? */ 
    358351   for (i=0;i<nsf;i++) 
    359       t[i]=EXTRACT16(PSHR32(target[i],6)); 
     352      t[i]=target[i]; 
    360353 
    361354   for (j=0;j<N;j++) 
     
    445438#ifdef FIXED_POINT 
    446439            g=sign*shape_cb[rind*subvect_size+m]; 
     440#else 
     441            g=sign*0.03125*shape_cb[rind*subvect_size+m]; 
     442#endif 
    447443            target_update(nt[j]+subvect_size*(i+1), g, r+q, nsf-subvect_size*(i+1)); 
    448 #else 
    449             g=sign*0.03125*shape_cb[rind*subvect_size+m]; 
    450             /*FIXME: I think that one too can be replaced by target_update */ 
    451             for (n=subvect_size*(i+1);n<nsf;n++,q++) 
    452                nt[j][n] = SUB32(nt[j][n],g*r[q]); 
    453 #endif 
    454444         } 
    455445 
     
    515505      syn_percep_zero(e, ak, awk1, awk2, r2, nsf,p, stack); 
    516506      for (j=0;j<nsf;j++) 
    517          target[j]=SUB32(target[j],r2[j]); 
     507         target[j]=SUB16(target[j],EXTRACT16(PSHR32(r2[j],8))); 
    518508   } 
    519509} 
     
    578568 
    579569void noise_codebook_quant( 
    580 spx_sig_t target[],                     /* target vector */ 
     570spx_word16_t target[],                  /* target vector */ 
    581571spx_coef_t ak[],                        /* LPCs for this subframe */ 
    582572spx_coef_t awk1[],                      /* Weighted LPCs for this subframe */ 
     
    596586   VARDECL(spx_sig_t *tmp); 
    597587   ALLOC(tmp, nsf, spx_sig_t); 
    598    residue_percep_zero(target, ak, awk1, awk2, tmp, nsf, p, stack); 
     588   for (i=0;i<nsf;i++) 
     589      tmp[i]=PSHR32(EXTEND32(target[i]),SIG_SHIFT); 
     590   residue_percep_zero(tmp, ak, awk1, awk2, tmp, nsf, p, stack); 
    599591 
    600592   for (i=0;i<nsf;i++) 
     
    602594   for (i=0;i<nsf;i++) 
    603595      target[i]=0; 
    604  
    605596} 
    606597 
     
    614605) 
    615606{ 
    616    speex_rand_vec(1, exc, nsf); 
     607   int i; 
     608   /* FIXME: This is bad, but I don't think the function ever gets called anyway */ 
     609   spx_int32_t seed = 0; 
     610   for (i=0;i<nsf;i++) 
     611      exc[i]=SHL32(EXTEND32(speex_rand(1, &seed)),SIG_SHIFT); 
    617612} 
Note: See TracChangeset for help on using the changeset viewer.