vi_gamma.c
1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <math.h>
void vi_gamma(unsigned int gamma_enable, unsigned int gamma_dither_enable,
unsigned int rgb, unsigned int rand, unsigned int sync,
unsigned int *gamma_rgb, unsigned int *gamma_sync)
{
static unsigned int blank, nblak_reg, sqrt_rgb, dither_rgb, ngamma_rgb, ngamma_sync,
ogamma_rgb, ogamma_sync, oblank_reg, nblank_reg;
*gamma_rgb = ogamma_rgb;
*gamma_sync = ogamma_sync;
blank = sync ? ((rgb & (1 << 7)) >> 7) : oblank_reg;
nblank_reg = blank;
if (gamma_dither_enable)
{
sqrt_rgb = (int) sqrt((float) ((rgb << 6) | rand));
}
else
{
sqrt_rgb = (int) sqrt((float) (rgb << 6));
}
if (rgb != 0xff)
{
dither_rgb = rgb + (gamma_dither_enable & (rand >> 5));
}
else
{
dither_rgb = 255;
}
ngamma_rgb =
sync ? ((rgb & (15 << 1)) >> 1) :
((blank ? 0 : 127) & (gamma_enable ?
sqrt_rgb:
((dither_rgb & (127 << 1)) >> 1)));
ngamma_sync = sync;
ogamma_rgb = ngamma_rgb;
ogamma_sync = ngamma_sync;
oblank_reg = nblank_reg;
}