Hi all,

This new version gives approx 70% overall speed increase under MSVC; gcc
version is untested but should be okay, or at least trivial to fix. ;)

We could get a small additional speed increase by rolling some of the "-
0.5"s into adj43[].

#define XRPOW_ASM

#ifdef XRPOW_ASM
# if defined(__GNUC__) && defined(__i386__)
#  define XRPOW_FTOI(src, dest) \
     asm ("fistpl %0 " : "=m"(dest) : "t"((src) - .5) : "st")
# elif defined (_MSC_VER)
#  define XRPOW_FTOI(src, dest) do { \
     FLOAT8 src_ = (src) - .5; \
     int dest_; \
     { \
       __asm fld src_ \
       __asm fistp dest_ \
     } \
     (dest) = dest_; \
   } while (0)
# else
#  define XRPOW_FTOI(src,dest) ((dest) = (int)(src))
# endif
#else
# define XRPOW_FTOI(src,dest) ((dest) = (int)(src))
#endif


#define QUANTFAC_OLD(rx)  0.4054
#define QUANTFAC(rx)  adj43[rx]

void quantize_xrpow( FLOAT8 xr[576], int ix[576], gr_info *cod_info )
{
  /* quantize on xr^(3/4) instead of xr */
  register int j;
  FLOAT8 x,quantizerStepSize;
  FLOAT8 istep_l,istep0,istep1,istep2;
  int rx;

  quantizerStepSize = cod_info->quantizerStepSize;

  istep_l = pow ( 2.0, quantizerStepSize * -0.1875 );

  if ((cod_info->block_type==SHORT_TYPE))
    {
      istep0 = istep_l * pow(2.0,1.5* (FLOAT8) cod_info->subblock_gain[0]);
      istep1 = istep_l * pow(2.0,1.5* (FLOAT8) cod_info->subblock_gain[1]);
      istep2 = istep_l * pow(2.0,1.5* (FLOAT8) cod_info->subblock_gain[2]);
      for (j=192;j>0;j--)
        {
          x = istep0 * *xr++;
          XRPOW_FTOI(x, rx);
          XRPOW_FTOI(x + QUANTFAC(rx), *(ix++));
          x = istep1 * *xr++;
          XRPOW_FTOI(x, rx);
          XRPOW_FTOI(x + QUANTFAC(rx), *(ix++));
          x = istep2 * *xr++;
          XRPOW_FTOI(x, rx);
          XRPOW_FTOI(x + QUANTFAC(rx), *(ix++));
        }
    }
  else
    {
      for (j=576;j>0;j--)
        {
          x = istep_l * *xr++;
          XRPOW_FTOI(x, rx);
          XRPOW_FTOI(x + QUANTFAC(rx), *(ix++));
        }
    }
}

-- Mat.


--
MP3 ENCODER mailing list ( http://geek.rcc.se/mp3encoder/ )

Reply via email to