[Speex-dev] Speex optimisation

John Ridges jridges at masque.com
Fri Jul 10 17:02:26 PDT 2009


Hi JM,

I've been profiling Speex and I've found a small optimisation that (at 
least in my test) seemed to make the encoder run about 3% faster. Not 
much I know, but it's such a small change that it may be worth making. 
Once again apologies for not having a proper diff, but what follows is 
the changed function "pitch_gain_search_3tap_vq" from the file ltp.c:

John Ridges

static int pitch_gain_search_3tap_vq(
  const signed char *gain_cdbk,
  int                gain_cdbk_size,
  spx_word16_t      *C16,
  spx_word16_t       max_gain
)
{
  const signed char *ptr=gain_cdbk;
  int                best_cdbk=0;
  spx_word32_t       best_sum=-VERY_LARGE32;
  spx_word32_t       sum=0;
  spx_word16_t       g[3];
  spx_word16_t       pitch_control=64;
  spx_word16_t       gain_sum;
  int                i;

  for (i=0;i<gain_cdbk_size;i++) {
        
    ptr = gain_cdbk+4*i;
    gain_sum = (spx_word16_t)ptr[3];

    if (gain_sum <= max_gain) {
        g[0]=ADD16((spx_word16_t)ptr[0],32);
        g[1]=ADD16((spx_word16_t)ptr[1],32);
        g[2]=ADD16((spx_word16_t)ptr[2],32);
       
        sum = compute_pitch_error(C16, g, pitch_control);
            
        if (sum>best_sum) {
          best_sum=sum;
          best_cdbk=i;
        }
    }
  }

  return best_cdbk;





More information about the Speex-dev mailing list