Implement a dither. There are only 3 cases where we must dither, in all other cases, no dithering is necessary.
| 160 | // Implement a dither. There are only 3 cases where we must dither, |
| 161 | // in all other cases, no dithering is necessary. |
| 162 | static inline void DITHER( Ditherer dither, State &state, |
| 163 | samplePtr dst, sampleFormat dstFormat, size_t dstStride, |
| 164 | constSamplePtr src, sampleFormat srcFormat, size_t srcStride, size_t len) |
| 165 | { |
| 166 | if (srcFormat == int24Sample && dstFormat == int16Sample) |
| 167 | DITHER_LOOP<int, short>(dither, state, |
| 168 | DITHER_TO_INT16, FROM_INT24, dst, |
| 169 | int16Sample, dstStride, src, int24Sample, srcStride, len); |
| 170 | else if (srcFormat == floatSample && dstFormat == int16Sample) |
| 171 | DITHER_LOOP<float, short>(dither, state, |
| 172 | DITHER_TO_INT16, FROM_FLOAT, dst, |
| 173 | int16Sample, dstStride, src, floatSample, srcStride, len); |
| 174 | else if (srcFormat == floatSample && dstFormat == int24Sample) |
| 175 | DITHER_LOOP<float, int>(dither, state, |
| 176 | DITHER_TO_INT24, FROM_FLOAT, dst, |
| 177 | int24Sample, dstStride, src, floatSample, srcStride, len); |
| 178 | else { wxASSERT(false); } |
| 179 | } |
| 180 | |
| 181 | |
| 182 | static inline float NoDither(State &, float sample); |