[vorbis-dev] vorbis on playstation 2

David Etherton etherton at rockstarsandiego.com
Fri Feb 7 09:37:05 PST 2003



I did some optimization work in a few obvious places and my cycle counts for
the particular test case went from 864M (higher than last night because it's
on a different network) down to 744M, which is about where I could get the
_LOW_ACCURACY_ version down to.  Binary compares on the resulting wav files
are identical.

For example:
static __inline void XPROD31(ogg_int32_t  a, ogg_int32_t  b,
      ogg_int32_t  t, ogg_int32_t  v,
      ogg_int32_t *x, ogg_int32_t *y)
{
#ifdef R5900
 ogg_int32_t m0, m1;
 __asm__("mult %2, %3; mult1 %4, %5; mfhi %0; mfhi1 %1;" : "=r"(m0),
"=r"(m1) : "r"(a), "r"(t), "r"(b), "r"(v));
 *x = (m0 + m1) << 1;
 __asm__("mult %2, %3; mult1 %4, %5; mfhi %0; mfhi1 %1;" : "=r"(m0),
"=r"(m1) : "r"(b), "r"(t), "r"(a), "r"(v));
 *y = (m0 - m1) << 1;
#else
  *x = MULT31(a, t) + MULT31(b, v);
  *y = MULT31(b, t) - MULT31(a, v);
#endif
}

and in the window code:

tatic __inline void MULT31x2(ogg_int32_t *d0,ogg_int32_t *d1,ogg_int32_t
w0,ogg_int32_t w1) {
#ifdef R5900
 ogg_int32_t m0, m1;
 __asm__("mult %2, %3; mult1 %4, %5; mfhi %0; mfhi1 %1" : "=r"(m0), "=r"(m1)
: "r"(*d0), "r"(w0), "r"(*d1), "r"(w1));
 *d0 = m0 << 1;
 *d1 = m1 << 1;
#else
 *d0 = MULT31(*d0, w0);
 *d1 = MULT31(*d1, w1);
#endif
}

void _vorbis_apply_window(ogg_int32_t *d,const void *window_p[2],
     long *blocksizes,
     int lW,int W,int nW){

  LOOKUP_T *window[2]={(LOOKUP_T*)window_p[0],(LOOKUP_T*)window_p[1]};
  long n=blocksizes[W];
  long ln=blocksizes[lW];
  long rn=blocksizes[nW];

  long leftbegin=n/4-ln/4;
  long leftend=leftbegin+ln/2;

  long rightbegin=n/2+n/4-rn/4;
  long rightend=rightbegin+rn/2;

  int i,p;

  for(i=0;i<leftbegin;i++)
    d[i]=0;

  for(p=0;i<leftend;i+=2,p+=2)
 MULT31x2(&d[i],&d[i+1],window[lW][p],window[lW][p+1]);

  for(i=rightbegin,p=rn/2-2;i<rightend;i+=2,p-=2)
 MULT31x2(&d[i],&d[i+1],window[nW][p+1],window[nW][p]);

  for(;i<n;i++)
    d[i]=0;
}

I need to clean up the constraints a little bit so that I can break the asm
into multiple lines so the compiler can interleave more loads and stores.

-Dave

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'vorbis-dev-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the Vorbis-dev mailing list