YUY2 -> RGB software conversion broken?

Hello,

  Recently I've tried to add YUV output capability to my application

( movie player ). It was generating pictures in YUY2 format and used
SDL overlay functions to put them on screen. Since I don’t have
accelerating hardware, I used software YUV->RGB. When everything was
ready, the program crashed with segfault inside YUV->RGB conversion
function ( Color16DitherYUY2Mod1X(), src/video/SDL_yuv_sw.c ). I took
a look at its source. It seems to be badly broken! It does anything
but YUY2 to RGB conversion, not to mention that there is almost
obvious buffer overflow in it. The code is the same in versions
1.1.3, 1.1.6 and in current CVS.
From mailing list archive I found out that these functions were
added in April 2000. It’s strange that nobody noticed this problem before…
I checked other YUY2->RGB functions. All of them are broken.
When I rewrote that conversion function, everything started
working.
I can post the source with fixed functions if anyone is
interested in it.–
Best regards,
Eugene mailto:divx at euro.ru

  Recently I've tried to add YUV output capability to my application

( movie player ). It was generating pictures in YUY2 format and used
SDL overlay functions to put them on screen. Since I don’t have
accelerating hardware, I used software YUV->RGB. When everything was
ready, the program crashed with segfault inside YUV->RGB conversion
function ( Color16DitherYUY2Mod1X(), src/video/SDL_yuv_sw.c ). I took
a look at its source. It seems to be badly broken! It does anything
but YUY2 to RGB conversion, not to mention that there is almost
obvious buffer overflow in it. The code is the same in versions
1.1.3, 1.1.6 and in current CVS.

Thank you very much for finding and fixing this bug.
The functions were written without any test code, and nobody until now
has had any way of testing it. :slight_smile:

I see your patch later in the mailing list archives, and I’ll apply it
later today.

Thanks!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software