Coverage Report

Created: 2026-02-14 07:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libvncserver/src/libvncserver/tableinitcmtemplate.c
Line
Count
Source
1
/*
2
 * tableinitcmtemplate.c - template for initialising lookup tables for
3
 * translation from a colour map to true colour.
4
 *
5
 * This file shouldn't be compiled.  It is included multiple times by
6
 * translate.c, each time with a different definition of the macro OUT.
7
 * For each value of OUT, this file defines a function which allocates an
8
 * appropriately sized lookup table and initialises it.
9
 *
10
 * I know this code isn't nice to read because of all the macros, but
11
 * efficiency is important here.
12
 */
13
14
/*
15
 *  OSXvnc Copyright (C) 2001 Dan McGuirk <mcguirk@incompleteness.net>.
16
 *  Original Xvnc code Copyright (C) 1999 AT&T Laboratories Cambridge.  
17
 *  All Rights Reserved.
18
 *
19
 *  This is free software; you can redistribute it and/or modify
20
 *  it under the terms of the GNU General Public License as published by
21
 *  the Free Software Foundation; either version 2 of the License, or
22
 *  (at your option) any later version.
23
 *
24
 *  This software is distributed in the hope that it will be useful,
25
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
26
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27
 *  GNU General Public License for more details.
28
 *
29
 *  You should have received a copy of the GNU General Public License
30
 *  along with this software; if not, write to the Free Software
31
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
32
 *  USA.
33
 */
34
35
#if !defined(OUT)
36
#error "This file shouldn't be compiled."
37
#error "It is included as part of translate.c"
38
#endif
39
40
0
#define OUT_T CONCAT3E(uint,OUT,_t)
41
0
#define SwapOUT(x) CONCAT2E(Swap,OUT(x))
42
#define rfbInitColourMapSingleTableOUT \
43
                                CONCAT2E(rfbInitColourMapSingleTable,OUT)
44
45
static void
46
rfbInitColourMapSingleTableOUT(char **table, rfbPixelFormat *in,
47
                            rfbPixelFormat *out,rfbColourMap* colourMap)
48
0
{
49
0
    uint32_t i, r, g, b;
50
0
    OUT_T *t;
51
0
    uint32_t nEntries = 1 << in->bitsPerPixel;
52
0
    int shift = colourMap->is16?16:8;
53
54
0
    if (*table) free(*table);
55
0
    *table = (char *)malloc(nEntries * sizeof(OUT_T));
56
0
    t = (OUT_T *)*table;
57
58
0
    for (i = 0; i < nEntries; i++) {
59
0
        r = g = b = 0;
60
0
  if(i < colourMap->count) {
61
0
    if(colourMap->is16) {
62
0
      r = colourMap->data.shorts[3*i+0];
63
0
      g = colourMap->data.shorts[3*i+1];
64
0
      b = colourMap->data.shorts[3*i+2];
65
0
    } else {
66
0
      r = colourMap->data.bytes[3*i+0];
67
0
      g = colourMap->data.bytes[3*i+1];
68
0
      b = colourMap->data.bytes[3*i+2];
69
0
    }
70
0
  }
71
0
        t[i] = ((((r * (1 + out->redMax)) >> shift) << out->redShift) |
72
0
                (((g * (1 + out->greenMax)) >> shift) << out->greenShift) |
73
0
                (((b * (1 + out->blueMax)) >> shift) << out->blueShift));
74
#if (OUT != 8)
75
0
        if (out->bigEndian != in->bigEndian) {
76
0
            t[i] = SwapOUT(t[i]);
77
0
        }
78
#endif
79
0
    }
80
0
}
Unexecuted instantiation: translate.c:rfbInitColourMapSingleTable8
Unexecuted instantiation: translate.c:rfbInitColourMapSingleTable16
Unexecuted instantiation: translate.c:rfbInitColourMapSingleTable32
81
82
#undef OUT_T
83
#undef SwapOUT
84
#undef rfbInitColourMapSingleTableOUT