]> git.sesse.net Git - fjl/blobdiff - idct_float.c
Add the level bias we're supposed to have.
[fjl] / idct_float.c
index c8bde1b236ac80c3bc5f5380fc5adcbd9569bc77..ede97cda9951a598f714e4d5b453dfe15b1115af 100644 (file)
@@ -157,12 +157,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);
                        }
                }
        }