Nicolai Dufva Nielsen dufva at tele.dtu.dk
Wed Aug 29 11:13:00 PDT 2001

On Wed, 29 Aug 2001, From: Casey King <cking at alchemysemi.com> wrote:

>     SDL_LockYUVOverlay(m_image);
>     memcpy(m_image->pixels[0], ybuf, ysize);
>     memcpy(m_image->pixels[1], vbuf, uvsize);
>     memcpy(m_image->pixels[2], ubuf, uvsize);

This can be dangerous, as you cannot be sure that the buffers are contiguous
in memory.  It seems that if you are not using hardware acceleration, the
buffers are actually contiguous, but I wouldn't rely on it...

Use the m_image->pitches array, i.e. for each component (Y, U and V) do:

if (width != m_image->pitches[c]) {
  for (i = 0; i < height; i++) {
    memcpy(m_image->pixels[c]+i*m_image->pitches[c], buffer, width); 
else {
  memcpy(m_image->pixels[c], buffer, size);

Nicolai Dufva - dufva at tele.dtu.dk
``The ships hung in the sky in much the same way that bricks don't.''

More information about the SDL mailing list