Browse Source

Code optimizations in the old version of the Hextile encoder. The

hextileTestTileType* function has been optimized using GNU profiler.


git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@320 3789f03b-4d11-0410-bbf8-ca57d06f2519
tags/v0.0.90
Constantin Kaplinsky 19 years ago
parent
commit
d8bbc0d5f9
1 changed files with 24 additions and 42 deletions
  1. 24
    42
      rfb/hextileEncode.h

+ 24
- 42
rfb/hextileEncode.h View File

/* Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved. /* Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved.
* Copyright (C) 2005 Constantin Kaplinsky. All Rights Reserved.
* *
* This is free software; you can redistribute it and/or modify * This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
while (sh < h-y) { while (sh < h-y) {
eol = ptr + sw; eol = ptr + sw;
while (ptr < eol) while (ptr < eol)
if (*ptr++ != *data) goto endOfHorizSubrect;
if (*ptr++ != *data) goto endOfSubrect;
ptr += w - sw; ptr += w - sw;
sh++; sh++;
} }
endOfHorizSubrect:

// Find vertical subrect
int vh;
for (vh = sh; vh < h-y; vh++)
if (data[vh*w] != *data) break;

if (vh != sh) {
ptr = data+1;
int vw;
for (vw = 1; vw < sw; vw++) {
for (int i = 0; i < vh; i++)
if (ptr[i*w] != *data) goto endOfVertSubrect;
ptr++;
}
endOfVertSubrect:

// If vertical subrect bigger than horizontal then use that.
if (sw*sh < vw*vh) {
sw = vw;
sh = vh;
}
}
endOfSubrect:


(*nSubrectsPtr)++; (*nSubrectsPtr)++;




int TEST_TILE_TYPE (PIXEL_T* data, int w, int h, PIXEL_T* bg, PIXEL_T* fg) int TEST_TILE_TYPE (PIXEL_T* data, int w, int h, PIXEL_T* bg, PIXEL_T* fg)
{ {
int tileType = 0;
PIXEL_T pix1 = *data, pix2 = 0;
int count1 = 0, count2 = 0;
PIXEL_T* end = data + w*h;
PIXEL_T pix1 = *data;
PIXEL_T* end = data + w * h;


for (PIXEL_T* ptr = data; ptr < end; ptr++) {
if (*ptr == pix1) {
count1++;
continue;
}
PIXEL_T* ptr = data + 1;
while (ptr < end && *ptr == pix1)
ptr++;


if (count2 == 0) {
tileType |= hextileAnySubrects;
pix2 = *ptr;
}
if (ptr == end) {
*bg = pix1;
return 0; // solid-color tile
}

int count1 = ptr - data;
int count2 = 1;
PIXEL_T pix2 = *ptr++;
int tileType = hextileAnySubrects;


if (*ptr == pix2) {
for (; ptr < end; ptr++) {
if (*ptr == pix1) {
count1++;
} else if (*ptr == pix2) {
count2++; count2++;
continue;
} else {
tileType |= hextileSubrectsColoured;
break;
} }

tileType |= hextileSubrectsColoured;
break;
} }


if (count1 >= count2) { if (count1 >= count2) {

Loading…
Cancel
Save