2
global definitions for dithering
3
Copyright (C) 2000 Martin Vogt
5
This program is free software; you can redistribute it and/or modify
6
it under the terms of the GNU Library General Public License as published by
7
the Free Software Foundation.
9
For more information look at the file COPYRIGHT in this package
33
#if (__GNUC__ < 2 || ( __GNUC__ == 2 && __GNUC_MINOR__ < 91 ) )
35
#warning "inline code disabled! (buggy egcs version)"
36
#undef __NO_MATH_INLINES
37
#define __NO_MATH_INLINES 1
45
/* Gamma correction stuff */
46
extern int gammaCorrectFlag;
47
extern double gammaCorrect;
49
/* Chroma correction stuff */
50
extern int chromaCorrectFlag;
51
extern double chromaCorrect;
55
#define CR_BASE (CB_BASE*CB_RANGE)
56
#define LUM_BASE (CR_BASE*CR_RANGE)
74
#define Min(x,y) (((x) < (y)) ? (x) : (y))
75
#define Max(x,y) (((x) > (y)) ? (x) : (y))
77
#define CHROMA_CORRECTION128(x) ((x) >= 0 \
78
? Min(127, (int)(((x) * chromaCorrect))) \
79
: Max(-128, (int)(((x) * chromaCorrect))))
80
#define CHROMA_CORRECTION256D(x) ((x) >= 128 \
81
? 128.0 + Min(127.0, (((x)-128.0) * chromaCorrect)) \
82
: 128.0 - Min(128.0, (((128.0-(x))* chromaCorrect))))
86
#define GAMMA_CORRECTION(x) ((int)(pow((x) / 255.0, 1.0/gammaCorrect)* 255.0))
88
#define CHROMA_CORRECTION128D(x) ((x) >= 0 \
89
? Min(127.0, ((x) * chromaCorrect)) \
90
: Max(-128.0, ((x) * chromaCorrect)))
92
#define CHROMA_CORRECTION256(x) ((x) >= 128 \
93
? 128 + Min(127, (int)(((x)-128.0) * chromaCorrect)) \
94
: 128 - Min(128, (int)((128.0-(x)) * chromaCorrect)))
96
// Range values for lum, cr, cb.