X-Git-Url: https://git.sesse.net/?p=fjl;a=blobdiff_plain;f=idct_float.c;fp=idct.c;h=c8bde1b236ac80c3bc5f5380fc5adcbd9569bc77;hp=c71d599833affb62944c4f915f89c9009aed034b;hb=56779091c47e5c61376d7f942cc58b831673e1d7;hpb=def75cfab6ca4da59ddc2e924898f3a8ed11ec89 diff --git a/idct.c b/idct_float.c similarity index 80% rename from idct.c rename to idct_float.c index c71d599..c8bde1b 100644 --- a/idct.c +++ b/idct_float.c @@ -4,57 +4,6 @@ #include "idct.h" -void* idct_reference_alloc(const uint32_t* quant_table) -{ - uint32_t* qt_copy = (uint32_t*)malloc(DCTSIZE2 * sizeof(uint32_t)); - // FIXME: check for NULL return - - memcpy(qt_copy, quant_table, DCTSIZE2 * sizeof(uint32_t)); - - return qt_copy; -} - -void idct_reference_free(void* userdata) -{ - free(userdata); -} - -void idct_reference(const int16_t* input, const void* userdata, uint8_t* output) -{ - const uint32_t* quant_table = (const uint32_t*)userdata; - double temp[DCTSIZE2]; - - for (unsigned y = 0; y < 8; ++y) { - for (unsigned x = 0; x < 8; ++x) { - double acc = 0.0; - for (unsigned u = 0; u < 8; ++u) { - for (unsigned v = 0; v < 8; ++v) { - double c_u = (u == 0) ? 1/sqrt(2.0) : 1.0; - double c_v = (v == 0) ? 1/sqrt(2.0) : 1.0; - acc += c_u * c_v - * input[u * DCTSIZE + v] * quant_table[u * DCTSIZE + v] - * cos((2 * x + 1) * v * M_PI / 16.0) - * cos((2 * y + 1) * u * M_PI / 16.0); - } - } - temp[y * DCTSIZE + x] = 0.25 * acc; - } - } - - for (unsigned y = 0; y < 8; ++y) { - for (unsigned x = 0; x < 8; ++x) { - double val = temp[y * DCTSIZE + x]; - if (val < 0.0) { - output[y * DCTSIZE + x] = 0; - } else if (val >= 255.0) { - output[y * DCTSIZE + x] = 255; - } else { - output[y * DCTSIZE + x] = (uint8_t)(val + 0.5); - } - } - } -} - // AA&N (Arai, Agui and Nakajima) floating-point IDCT. // This IDCT is based on the same DCT that libjpeg uses -- in fact, exactly the // same figure from the same book ("JPEG: Still Image Data Compression Standard",