From 025e660b290bff9153aa79191349fdb894caf72e Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Thu, 30 Sep 2010 09:19:15 +0000 Subject: [PATCH] Revert commit 3784 as it was incorrect. A "Pixel" is always expected to be in native endian, and hence requires no swapping. The code in tightEncode.h however is working on pixel buffers, not Pixel arrays, so that's where the real bug was and is hereby properly fixed. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4151 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- common/rfb/PixelFormat.inl | 9 --------- common/rfb/tightEncode.h | 2 +- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/common/rfb/PixelFormat.inl b/common/rfb/PixelFormat.inl index ca83a305..90d8e6da 100644 --- a/common/rfb/PixelFormat.inl +++ b/common/rfb/PixelFormat.inl @@ -75,16 +75,9 @@ inline void PixelFormat::bufferFromPixel(rdr::U8* buffer, Pixel p) const } -#define _rfb_bswap_32(x) \ - ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \ - (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)) - - inline void PixelFormat::rgbFromPixel(Pixel p, ColourMap* cm, rdr::U16 *r, rdr::U16 *g, rdr::U16 *b) const { if (trueColour) { - if (endianMismatch) - p = _rfb_bswap_32(p); /* We don't need to mask since we shift out unwanted bits */ *r = (p >> redShift) << redConvShift; *g = (p >> greenShift) << greenConvShift; @@ -107,8 +100,6 @@ inline void PixelFormat::rgbFromPixel(Pixel p, ColourMap* cm, rdr::U16 *r, rdr:: inline void PixelFormat::rgbFromPixel(Pixel p, ColourMap* cm, rdr::U8 *r, rdr::U8 *g, rdr::U8 *b) const { if (trueColour) { - if (endianMismatch) - p = _rfb_bswap_32(p); *r = (p >> redShift) << (redConvShift - 8); *g = (p >> greenShift) << (greenConvShift - 8); *b = (p >> blueShift) << (blueConvShift - 8); diff --git a/common/rfb/tightEncode.h b/common/rfb/tightEncode.h index aa6e63aa..0c6b364c 100644 --- a/common/rfb/tightEncode.h +++ b/common/rfb/tightEncode.h @@ -282,7 +282,7 @@ static inline unsigned int PACK_PIXELS (PIXEL_T *buf, unsigned int count, rdr::U8 *dst = (rdr::U8 *)buf; for (unsigned int i = 0; i < count; i++) { pix = *buf++; - pf.rgbFromPixel(pix, NULL, &dst[0], &dst[1], &dst[2]); + pf.rgbFromBuffer(dst, (rdr::U8*)&pix, 1, NULL); dst += 3; } return count * 3; -- 2.39.5