18#include <QGlobalStatic>
28inline double toDouble(
const quint8* data,
int channelpos)
30 return (
double)(*((T*)(data + channelpos)));
36 *((T*)(data + channelpos)) = (T)qRound(
v);
42 *((T*)(data + channelpos)) = (T)
v;
49 *((T*)(data + channelpos)) =
value;
50 *isNull =
value == T(0);
57 *((T*)(data + channelpos)) = (T)
v;
58 *isNull = value < std::numeric_limits<T>::epsilon();
64 qint32 depth = src->colorSpace()->colorChannelCount();
67 for (qint32 c = 0; c < cis.count(); ++c) {
77 for (
int i =
rect.y(); i <
rect.height(); i++) {
81 for (
int k = 0; k < depth; k++) {
82 *dstIt = f[k](v1, cis[k]->pos());
92 qint32 channels = cis.count();
94 for (qint32 k = 0; k < channels; k++) {
95 switch (cis[k]->channelValueType()) {
97 f[k] = toDouble<quint8>;
100 f[k] = toDouble<quint16>;
104 f[k] = toDouble<half>;
108 f[k] = toDouble<float>;
111 f[k] = toDouble<qint8>;
114 f[k] = toDouble<qint16>;
117 warnKrita <<
"Unsupported value type in KisMathToolbox";
130 for (qint32 c = 0; c < cis.count(); ++c) {
140 for (
int i =
rect.y(); i <
rect.height(); i++) {
143 quint8* v1 = dstIt->rawData();
144 for (
int k = 0; k < depth; k++) {
145 f[k](v1, cis[k]->pos(), *srcIt);
148 }
while(dstIt->nextPixel());
155 qint32 channels = cis.count();
157 for (qint32 k = 0; k < channels; k++) {
158 switch (cis[k]->channelValueType()) {
160 f[k] = fromDouble<quint8>;
163 f[k] = fromDouble<quint16>;
167 f[k] = fromDoubleF<half>;
171 f[k] = fromDoubleF<float>;
174 f[k] = fromDouble<qint8>;
177 f[k] = fromDouble<qint16>;
180 warnKrita <<
"Unsupported value type in KisMathToolbox";
190 qint32 channels = cis.count();
192 for (qint32 k = 0; k < channels; k++) {
193 switch (cis[k]->channelValueType()) {
195 f[k] = fromDoubleCheckNull<quint8>;
198 f[k] = fromDoubleCheckNull<quint16>;
202 f[k] = fromDoubleCheckNullF<half>;
206 f[k] = fromDoubleCheckNullF<float>;
209 f[k] = fromDoubleCheckNull<qint8>;
212 f[k] = fromDoubleCheckNull<qint16>;
215 warnKrita <<
"Unsupported value type in KisMathToolbox";
261 uint l = (2 * halfsize) * wav->
depth *
sizeof(
float);
262 for (
uint i = 0; i < halfsize; i++) {
264 float * itHL = buff->
coeffs + (i * buff->
size + halfsize) * buff->
depth;
265 float * itLH = buff->
coeffs + (halfsize + i) * buff->
size * buff->
depth;
266 float * itHH = buff->
coeffs + ((halfsize + i) * buff->
size + halfsize) * buff->
depth;
270 float * itS22 = wav->
coeffs + ((2 * i + 1) * wav->
size + 1) * wav->
depth;
271 for (
uint j = 0; j < halfsize; j++) {
273 *(itLL++) = (*itS11 + *itS12 + *itS21 + *itS22) * M_SQRT1_2;
274 *(itHL++) = (*itS11 - *itS12 + *itS21 - *itS22) * M_SQRT1_2;
275 *(itLH++) = (*itS11 + *itS12 - *itS21 - *itS22) * M_SQRT1_2;
276 *(itHH++) = (*(itS11++) - *(itS12++) - *(itS21++) + *(itS22++)) * M_SQRT1_2;
282 for (
uint i = 0; i < halfsize; i++) {
295 uint l = (2 * halfsize) * wav->
depth *
sizeof(
float);
296 for (
uint i = 0; i < halfsize; i++) {
298 float * itHL = wav->
coeffs + (i * buff->
size + halfsize) * buff->
depth;
299 float * itLH = wav->
coeffs + (halfsize + i) * buff->
size * buff->
depth;
300 float * itHH = wav->
coeffs + ((halfsize + i) * buff->
size + halfsize) * buff->
depth;
304 float * itS22 = buff->
coeffs + ((2 * i + 1) * wav->
size + 1) * wav->
depth;
305 for (
uint j = 0; j < halfsize; j++) {
307 *(itS11++) = (*itLL + *itHL + *itLH + *itHH) * 0.25 * M_SQRT2;
308 *(itS12++) = (*itLL - *itHL + *itLH - *itHH) * 0.25 * M_SQRT2;
309 *(itS21++) = (*itLL + *itHL - *itLH - *itHH) * 0.25 * M_SQRT2;
310 *(itS22++) = (*(itLL++) - *(itHL++) - *(itLH++) + *(itHH++)) * 0.25 * M_SQRT2;
316 for (
uint i = 0; i < halfsize; i++) {
323 if (halfsize != wav->
size / 2) {
float value(const T *src, size_t ch)
virtual const quint8 * oldRawData() const =0
virtual bool nextPixel()=0
KisHLineIteratorSP createHLineIteratorNG(qint32 x, qint32 y, qint32 w)
const KoColorSpace * colorSpace() const
@ COLOR
The channel represents a color.
@ UINT8
use this for an unsigned integer 8bits channel
@ UINT16
use this for an integer 16bits channel
@ INT16
use this for an integer 16bits channel
@ INT8
use this for an integer 8bits channel
@ FLOAT32
use this for a float 32bits channel
@ FLOAT16
use this for a float 16bits channel
@ UINT32
use this for an unsigned integer 21bits channel
@ FLOAT64
use this for a float 64bits channel
enumChannelValueType channelValueType() const
QList< KoChannelInfo * > channels
virtual quint32 colorChannelCount() const =0