Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 pj 1
/*
2
 * Copyright (c) 1995 The Regents of the University of California.
3
 * All rights reserved.
4
 *
5
 * Permission to use, copy, modify, and distribute this software and its
6
 * documentation for any purpose, without fee, and without written agreement is
7
 * hereby granted, provided that the above copyright notice and the following
8
 * two paragraphs appear in all copies of this software.
9
 *
10
 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
11
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
12
 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
13
 * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
 *
15
 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
16
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
17
 * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
18
 * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
19
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
20
 */
21
 
22
extern int LUM_RANGE;
23
extern int CR_RANGE;
24
extern int CB_RANGE;
25
 
26
 
27
#define CB_BASE 1
28
#define CR_BASE (CB_BASE*CB_RANGE)
29
#define LUM_BASE (CR_BASE*CR_RANGE)
30
 
31
extern unsigned char pixel[256];
32
extern unsigned long wpixel[256];
33
extern int *lum_values;
34
extern int *cr_values;
35
extern int *cb_values;
36
 
37
#define Min(x,y) (((x) < (y)) ? (x) : (y))
38
#define Max(x,y) (((x) > (y)) ? (x) : (y))
39
 
40
#define GAMMA_CORRECTION(x) ((int)(pow((x) / 255.0, 1.0 / gammaCorrect) * 255.0))
41
#define CHROMA_CORRECTION256(x) ((x) >= 128 \
42
                        ? 128 + Min(127, (int)(((x) - 128.0) * chromaCorrect)) \
43
                        : 128 - Min(128, (int)((128.0 - (x)) * chromaCorrect)))
44
#define CHROMA_CORRECTION128(x) ((x) >= 0 \
45
                        ? Min(127,  (int)(((x) * chromaCorrect))) \
46
                        : Max(-128, (int)(((x) * chromaCorrect))))
47
#define CHROMA_CORRECTION256D(x) ((x) >= 128 \
48
                        ? 128.0 + Min(127.0, (((x) - 128.0) * chromaCorrect)) \
49
                        : 128.0 - Min(128.0, (((128.0 - (x)) * chromaCorrect))))
50
#define CHROMA_CORRECTION128D(x) ((x) >= 0 \
51
                        ? Min(127.0,  ((x) * chromaCorrect)) \
52
                        : Max(-128.0, ((x) * chromaCorrect)))
53