38 static XMap constructWithUserFunction(uint16_t length, XFunction xFunction, uint16_t offset = 0) {
40 out.xFunction = xFunction;
47 static XMap constructWithLookUpTable(uint16_t length,
const uint16_t *lookUpTable, uint16_t offset = 0) {
48 XMap out =
XMap(length, kLookUpTable);
49 out.mData = lookUpTable;
55 XMap(uint16_t length,
bool is_reverse =
false, uint16_t offset = 0) {
56 type = is_reverse ? kReverse : kLinear;
57 this->length = length;
58 this->mOffset = offset;
63 length = other.length;
64 xFunction = other.xFunction;
66 mLookUpTable = other.mLookUpTable;
67 mOffset = other.mOffset;
74 length = other.length;
75 xFunction = other.xFunction;
77 mLookUpTable = other.mLookUpTable;
78 mOffset = other.mOffset;
83 void convertToLookUpTable() {
84 if (type == kLookUpTable) {
88 mLookUpTable = LUT16Ref::New(length);
89 uint16_t* dataMutable = mLookUpTable->getData();
90 mData = mLookUpTable->getData();
91 for (uint16_t x = 0; x < length; x++) {
92 dataMutable[x] = mapToIndex(x);
98 uint16_t mapToIndex(uint16_t x)
const {
102 index = x_linear(x, length);
105 index = x_reverse(x, length);
109 index = xFunction(x, length);
117 return index + mOffset;
120 uint16_t getLength()
const {
124 Type getType()
const {
130 XMap(uint16_t length, Type type)
131 : length(length), type(type), mOffset(0) {
135 XFunction xFunction =
nullptr;
136 const uint16_t *mData =
nullptr;
137 LUT16Ref mLookUpTable;
138 uint16_t mOffset = 0;