Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/external/source/vncdll/winvnc/tabletranstemplate.cpp
Views: 11780
/*1* tabletranstemplate.c - template for translation using lookup tables.2*3* This file shouldn't be compiled. It is included multiple times by4* translate.c, each time with different definitions of the macros INBPP and OUTBPP.5*6* For each pair of values INBPP and OUTBPP, this file defines two functions for7* translating a given rectangle of pixel data. One uses a single lookup8* table, and the other uses three separate lookup tables for the red, green9* and blue values.10*11* I know this code isn't nice to read because of all the macros, but12* efficiency is important here.13*/1415#if !defined(INBPP) || !defined(OUTBPP)16#error "This file shouldn't be compiled."17#error "It is included as part of translate.c"18#endif1920#define IN_T CONCAT2E(CARD,INBPP)21#define OUT_T CONCAT2E(CARD,OUTBPP)22#define rfbTranslateWithSingleTableINtoOUT \23CONCAT4E(rfbTranslateWithSingleTable,INBPP,to,OUTBPP)24#define rfbTranslateWithRGBTablesINtoOUT \25CONCAT4E(rfbTranslateWithRGBTables,INBPP,to,OUTBPP)2627/*28* rfbTranslateWithSingleTableINtoOUT translates a rectangle of pixel data29* using a single lookup table.30*/3132static void33rfbTranslateWithSingleTableINtoOUT (char *table, rfbPixelFormat *in,34rfbPixelFormat *out,35char *iptr, char *optr,36int bytesBetweenInputLines,37int width, int height)38{39IN_T *ip = (IN_T *)iptr;40OUT_T *op = (OUT_T *)optr;41int ipextra = bytesBetweenInputLines / sizeof(IN_T) - width;42OUT_T *opLineEnd;43OUT_T *t = (OUT_T *)table;4445while (height > 0) {46opLineEnd = op + width;4748while (op < opLineEnd) {49*(op++) = t[*(ip++)];50}5152ip += ipextra;53height--;54}55}565758/*59* rfbTranslateWithRGBTablesINtoOUT translates a rectangle of pixel data60* using three separate lookup tables for the red, green and blue values.61*/6263static void64rfbTranslateWithRGBTablesINtoOUT (char *table, rfbPixelFormat *in,65rfbPixelFormat *out,66char *iptr, char *optr,67int bytesBetweenInputLines,68int width, int height)69{70IN_T *ip = (IN_T *)iptr;71OUT_T *op = (OUT_T *)optr;72int ipextra = bytesBetweenInputLines / sizeof(IN_T) - width;73OUT_T *opLineEnd;74OUT_T *redTable = (OUT_T *)table;75OUT_T *greenTable = redTable + in->redMax + 1;76OUT_T *blueTable = greenTable + in->greenMax + 1;77IN_T in_pix;78OUT_T out_pix;7980while (height > 0) {81opLineEnd = op + width;8283while (op < opLineEnd) {84in_pix = *ip++;85out_pix = redTable[(in_pix >> in->redShift) & in->redMax];86out_pix |= greenTable[(in_pix >> in->greenShift) & in->greenMax];87out_pix |= blueTable[(in_pix >> in->blueShift) & in->blueMax];88*op++ = out_pix;89}90ip += ipextra;91height--;92}93}9495#undef IN_T96#undef OUT_T97#undef rfbTranslateWithSingleTableINtoOUT98#undef rfbTranslateWithRGBTablesINtoOUT99100101