Browse Source

Consistent use of stride vs pitch

Consistently use the term stride rather than pitch. Also
consistently represent the stride in number of pixels rather
than number of bytes. There is so much code that assumes
proper alignment already that we do not need the extra resolution.
tags/v1.3.90
Pierre Ossman 10 years ago
parent
commit
a10d8fec7f

+ 6
- 5
common/rfb/JpegCompressor.cxx View File

@@ -142,7 +142,7 @@ JpegCompressor::~JpegCompressor(void)
delete cinfo;
}

void JpegCompressor::compress(const rdr::U8 *buf, int pitch, const Rect& r,
void JpegCompressor::compress(const rdr::U8 *buf, int stride, const Rect& r,
const PixelFormat& pf, int quality, int subsamp)
{
int w = r.width();
@@ -196,13 +196,14 @@ void JpegCompressor::compress(const rdr::U8 *buf, int pitch, const Rect& r,
}
#endif

if (pitch == 0) pitch = w * pf.bpp / 8;
if (stride == 0)
stride = w;

if (cinfo->in_color_space == JCS_RGB) {
srcBuf = new rdr::U8[w * h * pixelsize];
srcBufIsTemp = true;
pf.rgbFromBuffer(srcBuf, (const rdr::U8 *)buf, w, pitch, h);
pitch = w * pixelsize;
pf.rgbFromBuffer(srcBuf, (const rdr::U8 *)buf, w, stride, h);
stride = w;
}

cinfo->input_components = pixelsize;
@@ -238,7 +239,7 @@ void JpegCompressor::compress(const rdr::U8 *buf, int pitch, const Rect& r,

rowPointer = new JSAMPROW[h];
for (int dy = 0; dy < h; dy++)
rowPointer[dy] = (JSAMPROW)(&srcBuf[dy * pitch]);
rowPointer[dy] = (JSAMPROW)(&srcBuf[dy * stride * pixelsize]);

jpeg_start_compress(cinfo, TRUE);
while (cinfo->next_scanline < cinfo->image_height)

+ 8
- 7
common/rfb/JpegDecompressor.cxx View File

@@ -139,12 +139,12 @@ JpegDecompressor::~JpegDecompressor(void)
}

void JpegDecompressor::decompress(const rdr::U8 *jpegBuf, int jpegBufLen,
rdr::U8 *buf, int pitch, const Rect& r, const PixelFormat& pf)
rdr::U8 *buf, int stride, const Rect& r, const PixelFormat& pf)
{
int w = r.width();
int h = r.height();
int pixelsize;
int dstBufPitch;
int dstBufStride;
rdr::U8 *dstBuf = NULL;
bool dstBufIsTemp = false;
JSAMPROW *rowPointer = NULL;
@@ -163,8 +163,9 @@ void JpegDecompressor::decompress(const rdr::U8 *jpegBuf, int jpegBufLen,
jpeg_read_header(dinfo, TRUE);
dinfo->out_color_space = JCS_RGB;
pixelsize = 3;
if (pitch == 0) pitch = w * pf.bpp / 8;
dstBufPitch = pitch;
if (stride == 0)
stride = w;
dstBufStride = stride;

#ifdef JCS_EXTENSIONS
// Try to have libjpeg output directly to our native format
@@ -201,12 +202,12 @@ void JpegDecompressor::decompress(const rdr::U8 *jpegBuf, int jpegBufLen,
if (dinfo->out_color_space == JCS_RGB) {
dstBuf = new rdr::U8[w * h * pixelsize];
dstBufIsTemp = true;
dstBufPitch = w * pixelsize;
dstBufStride = w;
}

rowPointer = new JSAMPROW[h];
for (int dy = 0; dy < h; dy++)
rowPointer[dy] = (JSAMPROW)(&dstBuf[dy * dstBufPitch]);
rowPointer[dy] = (JSAMPROW)(&dstBuf[dy * dstBufStride * pixelsize]);

jpeg_start_decompress(dinfo);

@@ -225,7 +226,7 @@ void JpegDecompressor::decompress(const rdr::U8 *jpegBuf, int jpegBufLen,
}

if (dinfo->out_color_space == JCS_RGB)
pf.bufferFromRGB((rdr::U8*)buf, dstBuf, w, pitch, h);
pf.bufferFromRGB((rdr::U8*)buf, dstBuf, w, stride, h);

jpeg_finish_decompress(dinfo);


+ 6
- 6
common/rfb/PixelFormat.cxx View File

@@ -180,7 +180,7 @@ void PixelFormat::bufferFromRGB(rdr::U8 *dst, const rdr::U8* src,
}

void PixelFormat::bufferFromRGB(rdr::U8 *dst, const rdr::U8* src,
int w, int pitch, int h, ColourMap* cm) const
int w, int stride, int h, ColourMap* cm) const
{
if (is888()) {
// Optimised common case
@@ -198,7 +198,7 @@ void PixelFormat::bufferFromRGB(rdr::U8 *dst, const rdr::U8* src,
x = dst + (48 - redShift - greenShift - blueShift)/8;
}

int dstPad = pitch - w * 4;
int dstPad = (stride - w) * 4;
while (h--) {
int w_ = w;
while (w_--) {
@@ -218,7 +218,7 @@ void PixelFormat::bufferFromRGB(rdr::U8 *dst, const rdr::U8* src,
}
} else {
// Generic code
int dstPad = pitch - w * 4;
int dstPad = (stride - w) * 4;
while (h--) {
int w_ = w;
while (w_--) {
@@ -295,7 +295,7 @@ void PixelFormat::rgbFromBuffer(rdr::U8* dst, const rdr::U8* src, int pixels, Co


void PixelFormat::rgbFromBuffer(rdr::U8* dst, const rdr::U8* src,
int w, int pitch, int h, ColourMap* cm) const
int w, int stride, int h, ColourMap* cm) const
{
if (is888()) {
// Optimised common case
@@ -311,7 +311,7 @@ void PixelFormat::rgbFromBuffer(rdr::U8* dst, const rdr::U8* src,
b = src + blueShift/8;
}

int srcPad = pitch - w * 4;
int srcPad = (stride - w) * 4;
while (h--) {
int w_ = w;
while (w_--) {
@@ -328,7 +328,7 @@ void PixelFormat::rgbFromBuffer(rdr::U8* dst, const rdr::U8* src,
}
} else {
// Generic code
int srcPad = pitch - w * bpp/8;
int srcPad = (stride - w) * bpp/8;
while (h--) {
int w_ = w;
while (w_--) {

+ 2
- 2
common/rfb/PixelFormat.h View File

@@ -63,7 +63,7 @@ namespace rfb {
inline Pixel pixelFromRGB(rdr::U8 red, rdr::U8 green, rdr::U8 blue, ColourMap* cm=0) const;

void bufferFromRGB(rdr::U8 *dst, const rdr::U8* src, int pixels, ColourMap* cm=0) const;
void bufferFromRGB(rdr::U8 *dst, const rdr::U8* src, int w, int pitch,
void bufferFromRGB(rdr::U8 *dst, const rdr::U8* src, int w, int stride,
int h, ColourMap* cm=0) const;

void rgbFromPixel(Pixel pix, ColourMap* cm, Colour* rgb) const;
@@ -71,7 +71,7 @@ namespace rfb {
inline void rgbFromPixel(Pixel pix, ColourMap* cm, rdr::U8 *r, rdr::U8 *g, rdr::U8 *b) const;

void rgbFromBuffer(rdr::U8* dst, const rdr::U8* src, int pixels, ColourMap* cm=0) const;
void rgbFromBuffer(rdr::U8* dst, const rdr::U8* src, int w, int pitch,
void rgbFromBuffer(rdr::U8* dst, const rdr::U8* src, int w, int stride,
int h, ColourMap* cm=0) const;

void print(char* str, int len) const;

+ 1
- 2
common/rfb/tightDecode.h View File

@@ -257,8 +257,7 @@ DECOMPRESS_JPEG_RECT(const Rect& r)
// We always use direct decoding with JPEG images
int stride;
rdr::U8 *buf = handler->getRawBufferRW(r, &stride);
jd.decompress(netbuf, compressedLen, buf, stride * clientpf.bpp / 8, r,
clientpf);
jd.decompress(netbuf, compressedLen, buf, stride, r, clientpf);
handler->releaseRawBuffer(r);

delete [] netbuf;

+ 1
- 1
common/rfb/tightEncode.h View File

@@ -412,7 +412,7 @@ void ENCODE_JPEG_RECT (PIXEL_T *buf, int stride, const Rect& r,
rdr::OutStream *os)
{
jc.clear();
jc.compress((rdr::U8 *)buf, stride * clientpf.bpp / 8, r, clientpf,
jc.compress((rdr::U8 *)buf, stride, r, clientpf,
jpegQuality, jpegSubsampling);
os->writeU8(0x09 << 4);
os->writeCompactLength(jc.length());

Loading…
Cancel
Save