X-Git-Url: https://git.sesse.net/?p=fjl;a=blobdiff_plain;f=idct_float.c;h=34ff5b690cabb463f1e156ba573b6cd3e865895c;hp=c8bde1b236ac80c3bc5f5380fc5adcbd9569bc77;hb=75e1e46dafe538990da0ea3b021c82d5ed6d5e21;hpb=56779091c47e5c61376d7f942cc58b831673e1d7 diff --git a/idct_float.c b/idct_float.c index c8bde1b..34ff5b6 100644 --- a/idct_float.c +++ b/idct_float.c @@ -50,9 +50,11 @@ static inline void idct1d_float(double y0, double y1, double y2, double y3, doub // constants static const double a1 = 0.7071067811865474; // sqrt(2) static const double a2 = 0.5411961001461971; // cos(3/8 pi) * sqrt(2) - static const double a3 = a1; + // static const double a3 = a1; + static const double a3 = 0.7071067811865474; static const double a4 = 1.3065629648763766; // cos(pi/8) * sqrt(2) - static const double a5 = 0.5 * (a4 - a2); + // static const double a5 = 0.5 * (a4 - a2); + static const double a5 = 0.3826834323650897; // phase 1 const double p1_0 = y0; @@ -157,12 +159,12 @@ void idct_float(const int16_t* input, const void* userdata, uint8_t* output) temp2); for (unsigned x = 0; x < DCTSIZE; ++x) { const double val = temp2[x]; - if (val < 0.0) { + if (val < -128.0) { output[y * DCTSIZE + x] = 0; - } else if (val >= 255.0) { + } else if (val >= 127.0) { output[y * DCTSIZE + x] = 255; } else { - output[y * DCTSIZE + x] = (uint8_t)(val + 0.5); + output[y * DCTSIZE + x] = (uint8_t)(val + 128.5); } } }