MCPcopy Create free account
hub / github.com/darktable-org/rawspeed / setTable

Method setTable

src/librawspeed/common/TableLookUp.cpp:44–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42}
43
44void TableLookUp::setTable(int ntable, const std::vector<uint16_t>& table) {
45 assert(!table.empty());
46
47 const int nfilled = table.size();
48 if (nfilled > TABLE_MAX_ELTS)
49 ThrowRDE("Table lookup with %i entries is unsupported", nfilled);
50
51 if (ntable > ntables) {
52 ThrowRDE("Table lookup with number greater than number of tables.");
53 }
54 uint16_t* t = &tables[ntable * TABLE_SIZE];
55 if (!dither) {
56 for (int i = 0; i < TABLE_MAX_ELTS; i++) {
57 t[i] = (i < nfilled) ? table[i] : table[nfilled - 1];
58 }
59 return;
60 }
61 for (int i = 0; i < nfilled; i++) {
62 int center = table[i];
63 int lower = i > 0 ? table[i - 1] : center;
64 int upper = i < (nfilled - 1) ? table[i + 1] : center;
65 int delta = upper - lower;
66 t[i * 2] = clampBits(center - ((upper - lower + 2) / 4), 16);
67 t[i * 2 + 1] = uint16_t(delta);
68 // FIXME: this is completely broken when the curve is non-monotonic.
69 }
70
71 for (int i = nfilled; i < TABLE_MAX_ELTS; i++) {
72 t[i * 2] = table[nfilled - 1];
73 t[i * 2 + 1] = 0;
74 }
75 t[0] = t[1];
76 t[TABLE_SIZE - 1] = t[TABLE_SIZE - 2];
77}
78
79uint16_t* TableLookUp::getTable(int n) {
80 if (n > ntables) {

Callers

nothing calls this directly

Calls 2

clampBitsFunction · 0.85
emptyMethod · 0.80

Tested by

no test coverage detected