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 | |
| parent | 4be6245766c5178c20d7ed206e20db6904ad9c5e (diff) | |
Round to nearest integer when quantising coefficients. Fixes poor image quality.
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | ssdv.c | 7 |
2 files changed, 5 insertions, 4 deletions
@@ -1,7 +1,7 @@ CC=gcc CFLAGS=-g -Wall -LDFLAGS=-g +LDFLAGS=-g -lm ssdv: main.o ssdv.o rs8.o $(CC) $(LDFLAGS) main.o ssdv.o rs8.o -o ssdv @@ -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) |
