srgb.lst
来自「台湾联咏NT68663 LCD MONITOR 控制程序(完整版)」· LST 代码 · 共 212 行
LST
212 行
C51 COMPILER V6.12 SRGB 03/05/2008 14:11:20 PAGE 1
C51 COMPILER V6.12, COMPILATION OF MODULE SRGB
OBJECT MODULE PLACED IN .\BIN\sRGB.obj
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE .\SRC\sRGB.C OPTIMIZE(9,SIZE) DEFINE(X17,TW2600XW02) DEBUG OBJECTEXTEND PRI
-NT(.\LST\sRGB.lst) OBJECT(.\BIN\sRGB.obj)
stmt level source
1 #include "IIC.H"
2 #include "Scaler.H"
3 #include "MyDef.H"
4 #include "RAM.H"
5 #include <stdio.h>
6
7 code int rgb2yuv[3][3]={
8 { 0x041B, 0x0810, 0x0191 },
9 { -0x025F, -0x04A7, 0x0707 },
10 { 0x0707, -0x05E2, -0x0124 }
11 };
12
13 code int yuv2rgb[3][3]={
14 { 0x12A1, 0x0000, 0x1989 },
15 { 0x12A1, -0x0644, -0x0D01 },
16 { 0x12A1, 0x2046, 0x0000 }
17 };
18
19 code int sincos_tbl[65]={
20 0x0000,0x0064,0x00C9,0x012D,0x0191,0x01F5,0x0259,0x02BC,0x031F,0x0381,
21 0x03E3,0x0444,0x04A5,0x0505,0x0564,0x05C2,0x061F,0x067B,0x06D7,0x0731,
22 0x078A,0x07E3,0x083A,0x088F,0x08E3,0x0937,0x0988,0x09D8,0x0A26,0x0A73,
23 0x0ABF,0x0B08,0x0B50,0x0B97,0x0BDB,0x0C1E,0x0C5E,0x0C9D,0x0CDA,0x0D15,
24 0x0D4D,0x0D85,0x0DB9,0x0DEC,0x0E1C,0x0E4B,0x0E77,0x0EA1,0x0EC8,0x0EEE,
25 0x0F10,0x0F31,0x0F4F,0x0F6C,0x0F85,0x0F9C,0x0FB1,0x0FC4,0x0FD4,0x0FE1,
26 0x0FEC,0x0FF5,0x0FFB,0x0FFE,0x1000
27 };
28
29 #if 0
int sine(unsigned char alpha)
{
unsigned char value = alpha & 0x3f;
switch (alpha & 0xC0){
case 0x00:
return( sincos_tbl[value ]);
break;
case 0x40:
return( sincos_tbl[(64 - value) ]);
break;
case 0x80:
return(-sincos_tbl[value ]);
break;
case 0xC0:
return(-sincos_tbl[(64 - value) ]);
break;
}
}
int cosine(unsigned char alpha)
{
return (sine(alpha + 64));
}
void product(int *first, int * second, int *result)
C51 COMPILER V6.12 SRGB 03/05/2008 14:11:20 PAGE 2
{
unsigned char i,j,k;
long res;
for ( i=0;i<3;i++){
for ( j=0;j<3;j++){
res = 0;
for ( k=0;k<3;k++){
res += (long)*(first + i*3 + k) * (long)*(second + k*3 + j);
}
//*(result + i*3 + j) = ((res)>>12);
*(result + i*3 + j) = ((res + 2048)>>12);
}
}
}
void sRGB(Byte Contrast,Byte RedGain,Byte GreenGain,Byte BlueGain)
{
xdata Byte i,j;
xdata Word ss,hh;
xdata short temp,gain[3];
xdata short result[3][3];
xdata short adjust[3][3];
xdata short UVrotated[3][3];
xdata short UserPrefContrast;
#define Saturation 50
#define Tint 50
gain[0] = (Word)(RedGain+0x80);//((Word)RedGain << 1) + 56;
gain[1] = (Word)(GreenGain+0x80);//((Word)GreenGain<< 1) + 56;
gain[2] = (Word)(BlueGain+0x80);//((Word)BlueGain<< 1) + 56;
// gain[0] = (Word)(RedGain);//((Word)RedGain << 1) + 56;
// gain[1] = (Word)(GreenGain);//((Word)GreenGain<< 1) + 56;
// gain[2] = (Word)(BlueGain);//((Word)BlueGain<< 1) + 56;
//ss = ((Word)Saturation * 256 + 50) / 100;
//hh = (((Word)Tint * 256 + 50) / 100) - 128;
if(FuncBuf[pVIDEOSOURCE] < 3){
ss = ((Word)FuncBuf[pSATURATION] * 256 + 50) / 100;
hh = (((Word)FuncBuf[pTINT] * 256 + 50) / 100) - 128;
}
else{
ss = 128;
hh = 0;
}
UserPrefContrast = (Word)(Contrast * 25) / 10;
//UserPrefContrast = (Word)Contrast;
for(i=0; i<3; i++){
UVrotated[i][0] = 0;
}
for(i=0; i<3; i++){
UVrotated[0][i] = 0;
}
UVrotated[1][1] = (((((long)ss<<5) * (long)cosine(hh))+2048)>>12);
UVrotated[1][2] = (((((long)ss<<5) * (long)sine(hh) )+2048)>>12);
UVrotated[2][1] = (((-(long)sine(hh)*((long)ss<<5))+2048)>>12);
UVrotated[2][2] = ((( (long)cosine(hh)*((long)ss<<5))+2048)>>12);
product(&UVrotated[0][0], &rgb2yuv[0][0], &adjust[0][0]);
for(i=0; i<3; i++){
adjust[0][i] =((((long)rgb2yuv[0][i]*((long)UserPrefContrast << 5))+2048)>>12);
C51 COMPILER V6.12 SRGB 03/05/2008 14:11:20 PAGE 3
}
product(&yuv2rgb[0][0],&adjust[0][0],&result[0][0]);
for(i=0; i<3; i++){
WriteIIC563(0x1d0,((i * 2) + 0x21));
for(j=0; j<3; j++){
temp = (((((long)(result[i][j]+8)>>4)*((long)gain[i]<<4))+2048)>>12);
if(temp < 0){
temp = temp ^ 0xffff;
temp +=1 ;
temp |= 0xf400;
}
WriteWordIIC563((0x1d1+(j*2)),temp);
}
}
WriteIIC563(0x1d0,0x2d);
}
#else
136 void sRGB(Byte Contrast,Byte RedGain,Byte GreenGain,Byte BlueGain)
137 {
138 1 #define Saturation 50
139 1 #define Tint 50
140 1 xdata Byte i,j;
141 1 xdata Word ss,hh;
142 1 xdata short temp,gain[3];
143 1 xdata short UserPrefContrast;
144 1 code Byte arry[3][3]={
145 1 {1,0,0},
146 1 {0,1,0},
147 1 {0,0,1}
148 1 };
149 1 gain[0] = (Word)(RedGain + 0x80);//((Word)RedGain << 1) + 56;
150 1 gain[1] = (Word)(GreenGain + 0x80);//((Word)GreenGain<< 1) + 56;
151 1 gain[2] = (Word)(BlueGain + 0x80);//((Word)BlueGain<< 1) + 56;
152 1
153 1 ss = ((Word)Saturation * 256 + 50) / 100;
154 1 hh = (((Word)Tint * 256 + 50) / 100) - 128;
155 1
156 1 //UserPrefContrast = (Word)(Contrast * 25) / 10;
157 1 UserPrefContrast = (Word)Contrast * 256 /100;
158 1 for(i=0; i<3; i++){
159 2 //if(SCRev > 2) //C version srgb dithering
160 2 WriteIIC563(0x1d0,((i * 2) + 0x21));
161 2 //else //A and B version srgb dithering
162 2 // WriteIIC563(0x1d0,((i * 2) + 0x31));
163 2 for(j=0; j<3; j++){
164 3 temp = ((((long)(UserPrefContrast)*((long)gain[i]<<5))+2048)>>12)*(long)arry[i][j];
165 3 if(temp < 0){
166 4 temp = temp ^ 0xffff;
167 4 temp +=1 ;
168 4 temp |= 0xf400;
169 4 }
170 3 WriteWordIIC563((0x1d1+(j*2)),temp);
171 3 }
172 2 }
173 1 //if(SCRev > 2) //C version srgb dithering
174 1 WriteIIC563(0x1d0,0x2d);
175 1 //else //A and B version srgb dithering
176 1 // WriteIIC563(0x1d0,0x3d);
177 1 }
178
C51 COMPILER V6.12 SRGB 03/05/2008 14:11:20 PAGE 4
179 #endif
180
181
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 335 ----
CONSTANT SIZE = 175 ----
XDATA SIZE = ---- 16
PDATA SIZE = ---- ----
DATA SIZE = ---- 4
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?