diff options
| author | Philip Heron <phil@sanslogic.co.uk> | 2012-02-26 23:51:15 +0000 |
|---|---|---|
| committer | Philip Heron <phil@sanslogic.co.uk> | 2012-02-26 23:51:15 +0000 |
| commit | 87c302a878a6d925f1dffb8ec93ae38ccc6019e7 (patch) | |
| tree | 9fbd728641f545623c4bff3e4885bbebd9180222 /ssdv.c | |
| parent | 4be6245766c5178c20d7ed206e20db6904ad9c5e (diff) | |
Round to nearest integer when quantising coefficients. Fixes poor image quality.
Diffstat (limited to 'ssdv.c')
| -rw-r--r-- | ssdv.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -20,6 +20,7 @@ #include <stdlib.h> #include <stdint.h> #include <string.h> +#include <math.h> #include "ssdv.h" #include "rs8.h" @@ -123,9 +124,9 @@ static uint8_t *dht_ac[3] = { std_dht10, std_dht11, std_dht11 }; #define DDQT (dqt[s->component][1 + s->acpart]) /* Helpers for converting between DQT tables */ -#define AADJ(i) (SDQT == DDQT ? (i) : (i / DDQT)) -#define UADJ(i) (SDQT == DDQT ? (i) : (i * SDQT)) -#define BADJ(i) (SDQT == DDQT ? (i) : (i * SDQT / DDQT)) +#define AADJ(i) (SDQT == DDQT ? (i) : round((double) i / DDQT)) +#define UADJ(i) (SDQT == DDQT ? (i) : round((double) i * SDQT)) +#define BADJ(i) (SDQT == DDQT ? (i) : round((double) i * SDQT / DDQT)) /* static char *strbits(uint32_t value, uint8_t bits) |
