Skip to content

Commit

Permalink
Fixed bug #276
Browse files Browse the repository at this point in the history
PlanarPixmapInfoYUV420 is a big endian structure.
Fix contributed by Jean-Charles BERTIN
  • Loading branch information
slouken committed Sep 24, 2006
1 parent 29a90d2 commit 72305ec
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/video/quartz/SDL_QuartzYUV.m
Expand Up @@ -274,6 +274,8 @@ static void QZ_FreeHWYUV (_THIS, SDL_Overlay *overlay) {
return NULL;
}

/* Fix: jc.bertin@free.fr
PlanarPixmapInfoYUV420 is a big-endian struct */
yuv_pixmap = (PlanarPixmapInfoYUV420*)
SDL_malloc (sizeof(PlanarPixmapInfoYUV420) +
(width * height * 2));
Expand All @@ -291,20 +293,20 @@ static void QZ_FreeHWYUV (_THIS, SDL_Overlay *overlay) {
/* CHECK_ALIGN(pixels[0]); */

pitches[0] = width;
yuv_pixmap->componentInfoY.offset = offset;
yuv_pixmap->componentInfoY.rowBytes = width;
yuv_pixmap->componentInfoY.offset = EndianS32_NtoB(offset);
yuv_pixmap->componentInfoY.rowBytes = EndianU32_NtoB(width);

offset += width * height;
pixels[plane2] = (Uint8*)yuv_pixmap + offset;
pitches[plane2] = width / 2;
yuv_pixmap->componentInfoCb.offset = offset;
yuv_pixmap->componentInfoCb.rowBytes = width / 2;
yuv_pixmap->componentInfoCb.offset = EndianS32_NtoB(offset);
yuv_pixmap->componentInfoCb.rowBytes = EndianU32_NtoB(width / 2);

offset += (width * height / 4);
pixels[plane3] = (Uint8*)yuv_pixmap + offset;
pitches[plane3] = width / 2;
yuv_pixmap->componentInfoCr.offset = offset;
yuv_pixmap->componentInfoCr.rowBytes = width / 2;
yuv_pixmap->componentInfoCr.offset = EndianS32_NtoB(offset);
yuv_pixmap->componentInfoCr.rowBytes = EndianU32_NtoB(width / 2);

overlay->pixels = pixels;
overlay->pitches = pitches;
Expand Down

0 comments on commit 72305ec

Please sign in to comment.