| 141 | // Implement a dithering loop |
| 142 | template<typename srcType, typename dstType> |
| 143 | static inline void DITHER_LOOP( Ditherer dither, State &state, |
| 144 | void (*store)(Ditherer, State &, dstType *, float), |
| 145 | float (*load)(const srcType *), |
| 146 | samplePtr dst, sampleFormat dstFormat, size_t dstStride, |
| 147 | constSamplePtr src, sampleFormat srcFormat, size_t srcStride, size_t len) |
| 148 | { |
| 149 | char *d; |
| 150 | const char *s; |
| 151 | unsigned int ii; |
| 152 | for (d = (char*)dst, s = (char*)src, ii = 0; |
| 153 | ii < len; |
| 154 | ii++, d += SAMPLE_SIZE(dstFormat) * dstStride, |
| 155 | s += SAMPLE_SIZE(srcFormat) * srcStride) { |
| 156 | store(dither, state, reinterpret_cast<dstType *>(d), load(reinterpret_cast<const srcType *>(s))); |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | // Implement a dither. There are only 3 cases where we must dither, |
| 161 | // in all other cases, no dithering is necessary. |