]> git.sesse.net Git - fjl/commitdiff
Add the level bias we're supposed to have.
authorsgunderson@bigfoot.com <>
Sun, 31 May 2009 14:45:26 +0000 (16:45 +0200)
committersgunderson@bigfoot.com <>
Sun, 31 May 2009 14:45:26 +0000 (16:45 +0200)
idct_float.c
idct_imprecise_int.c
idct_reference.c
idct_test.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);
                        }
                }
        }
index 6dd698349eda339989b86e57994639fa5a5bf750..7048a66c9c2a4ecf221c0d2d2628fa19fcf0bfec 100644 (file)
@@ -14,7 +14,7 @@ struct idct_imprecise_int_userdata {
 };
 
 #define PRECISION 12
-#define ROUND_BIAS (1LL << (PRECISION - 1))
+#define ROUND_BIAS (257LL << (PRECISION - 1))
 
 #define FIX(x) ((int32_t)((x) * (1LL << PRECISION) + 0.5))
 
index e710de3d1306500f151bae818ecec2e767510b43..f74ad0ba2d11aa4d71ffb50c52ad0125108279de 100644 (file)
@@ -43,7 +43,7 @@ void idct_reference(const int16_t* input, const void* userdata, uint8_t* output)
 
        for (unsigned y = 0; y < 8; ++y) {
                for (unsigned x = 0; x < 8; ++x) {
-                       double val = temp[y * DCTSIZE + x];
+                       double val = temp[y * DCTSIZE + x] + 128.0;
                        if (val < 0.0) {
                                output[y * DCTSIZE + x] = 0;
                        } else if (val >= 255.0) {
index d7b543cbc931f3f6f63782ab175524eedb438f8f..bd39c7467e5f0e79ff361daf7b97df92968a55c1 100644 (file)
@@ -76,8 +76,13 @@ void test_dc_becomes_spread_out(idct_alloc_t* idct_alloc, idct_free_t* idct_free
 
        void* userdata = idct_alloc(quant);
 
-       for (unsigned i = 0; i < 255*8; ++i) {  
-               uint32_t reference_value = i / 8;
+       for (unsigned i = -255*8; i < 255*16; ++i) {    
+               int reference_value = i / 8 + 128;
+               if (reference_value < 0) {
+                       reference_value = 0;
+               } else if (reference_value > 255) {
+                       reference_value = 255;
+               }
                coeff[0] = i;
 
                (*idct)(coeff, userdata, output);