Round to nearest integer when quantising coefficients. Fixes poor image quality.

This commit is contained in:
Philip Heron 2012-02-26 23:51:15 +00:00
parent 4be6245766
commit 87c302a878
2 changed files with 5 additions and 4 deletions

View File

@ -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

7
ssdv.c
View File

@ -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)