~ubuntu-branches/ubuntu/hoary/kdemultimedia/hoary

« back to all changes in this revision

Viewing changes to mpeglib/lib/util/render/dither/ditherDef.h

  • Committer: Bazaar Package Importer
  • Author(s): Martin Schulze
  • Date: 2003-01-22 15:00:51 UTC
  • Revision ID: james.westby@ubuntu.com-20030122150051-uihwkdoxf15mi1tn
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  global definitions for dithering
 
3
  Copyright (C) 2000  Martin Vogt
 
4
 
 
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.
 
8
 
 
9
  For more information look at the file COPYRIGHT in this package
 
10
 
 
11
 */
 
12
 
 
13
 
 
14
 
 
15
#ifndef __DITHERDEF_H
 
16
#define __DITHERDEF_H
 
17
 
 
18
 
 
19
#ifdef HAVE_CONFIG_H
 
20
#include "config.h"
 
21
#endif
 
22
 
 
23
#include <iostream.h>
 
24
 
 
25
extern "C" {
 
26
#include <string.h>
 
27
#include <stdio.h>
 
28
#include <stdlib.h>
 
29
}
 
30
 
 
31
 
 
32
#ifdef __GNUC__
 
33
#if (__GNUC__ < 2 || ( __GNUC__ == 2 && __GNUC_MINOR__ < 91 ) )
 
34
#ifndef _AIX
 
35
#warning "inline code disabled! (buggy egcs version)"
 
36
#undef __NO_MATH_INLINES
 
37
#define __NO_MATH_INLINES 1
 
38
#endif
 
39
#endif
 
40
#endif
 
41
#include <math.h>
 
42
 
 
43
 
 
44
 
 
45
/* Gamma correction stuff */
 
46
extern int gammaCorrectFlag;
 
47
extern double gammaCorrect;
 
48
 
 
49
/* Chroma correction stuff */
 
50
extern int chromaCorrectFlag;
 
51
extern double chromaCorrect;
 
52
 
 
53
 
 
54
#define CB_BASE 1
 
55
#define CR_BASE (CB_BASE*CB_RANGE)
 
56
#define LUM_BASE (CR_BASE*CR_RANGE)
 
57
 
 
58
#define TABTYPE short
 
59
 
 
60
#ifdef SIXTYFOUR_BIT
 
61
#define PIXVAL long
 
62
#else
 
63
#define PIXVAL int
 
64
#endif
 
65
 
 
66
#ifdef SIXTYFOUR_BIT
 
67
#define ONE_TWO 1
 
68
#else
 
69
#define ONE_TWO 2
 
70
#endif
 
71
 
 
72
 
 
73
 
 
74
#define Min(x,y) (((x) < (y)) ? (x) : (y))
 
75
#define Max(x,y) (((x) > (y)) ? (x) : (y))
 
76
 
 
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))))
 
83
 
 
84
 
 
85
 
 
86
#define GAMMA_CORRECTION(x) ((int)(pow((x) / 255.0, 1.0/gammaCorrect)* 255.0))
 
87
 
 
88
#define CHROMA_CORRECTION128D(x) ((x) >= 0 \
 
89
                        ? Min(127.0,  ((x) * chromaCorrect)) \
 
90
                        : Max(-128.0, ((x) * chromaCorrect)))
 
91
 
 
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)))
 
95
 
 
96
// Range values for lum, cr, cb. 
 
97
#define  LUM_RANGE  8
 
98
#define  CR_RANGE   4
 
99
#define  CB_RANGE   4
 
100
 
 
101
 
 
102
#endif