[MPlayer-dev-eng] Fwd: [MPlayer-users] Work done twice: problems in libswscale assembly optimization codes

Reimar Doeffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Fri Jan 19 10:58:38 CET 2007


Hello,
[...]
On Thu, Jan 18, 2007 at 11:10:52PM +0100, Guillaume POIRIER wrote:
> If HAVE_MMX is defined, the code equals to:
> 
> static inline void RENAME(rgb32to24)(const uint8_t *src,uint8_t
> *dst,long src_size)
> {
>  uint8_t *dest = dst;
>  const uint8_t *s = src;
>  const uint8_t *end;
>  const uint8_t *mm_end;
>  end = s + src_size;
>  // ...MMX Codes...
>  while(s < end)
>  {
> #ifdef WORDS_BIGENDIAN
>    /* RGB32 (= A,B,G,R) -> RGB24 (= R,G,B) */
>    s++;
>    dest[2] = *s++;
>    dest[1] = *s++;
>    dest[0] = *s++;
>    dest += 3;
> #else
>    *dest++ = *s++;
>    *dest++ = *s++;
>    *dest++ = *s++;
>    s++;
> #endif
>  }
> }
> 
> So the work are done *TWICE*. Am I too stupid?

MMX code can only work on certain multiples, so it does e.g. the first
(n / 16) * 16 iterations and the C code does the remaining n % 16.
At least if it is some commonly used code you can be sure it would have
been noticed if it was doing the work twice (though rgb32to24 is
probably not used much).
Just check that s is incremented correctly in the MMX code.

Greetings,
Reimar Döffinger



More information about the MPlayer-dev-eng mailing list