326
|
1 // Generic alpha renderers for all YUV modes and RGB depths.
|
|
2 // These are "reference implementations", should be optimized later (MMX, etc)
|
|
3
|
622
|
4 #include "osd.h"
|
|
5
|
326
|
6 void vo_draw_alpha_yv12(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){
|
|
7 int y;
|
|
8 for(y=0;y<h;y++){
|
|
9 register int x;
|
|
10 for(x=0;x<w;x++){
|
|
11 if(srca[x]) dstbase[x]=((dstbase[x]*srca[x])>>8)+src[x];
|
|
12 }
|
|
13 src+=srcstride;
|
|
14 srca+=srcstride;
|
|
15 dstbase+=dststride;
|
|
16 }
|
|
17 return;
|
|
18 }
|
|
19
|
|
20 void vo_draw_alpha_yuy2(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){
|
|
21 int y;
|
|
22 for(y=0;y<h;y++){
|
|
23 register int x;
|
|
24 for(x=0;x<w;x++){
|
|
25 if(srca[x]) dstbase[2*x]=((dstbase[2*x]*srca[x])>>8)+src[x];
|
|
26 }
|
|
27 src+=srcstride;
|
|
28 srca+=srcstride;
|
|
29 dstbase+=dststride;
|
|
30 }
|
|
31 return;
|
|
32 }
|
|
33
|
|
34 void vo_draw_alpha_rgb24(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){
|
|
35 int y;
|
|
36 for(y=0;y<h;y++){
|
|
37 register unsigned char *dst = dstbase;
|
|
38 register int x;
|
|
39 for(x=0;x<w;x++){
|
|
40 if(srca[x]){
|
|
41 dst[0]=((dst[0]*srca[x])>>8)+src[x];
|
|
42 dst[1]=((dst[1]*srca[x])>>8)+src[x];
|
|
43 dst[2]=((dst[2]*srca[x])>>8)+src[x];
|
|
44 }
|
|
45 dst+=3; // 24bpp
|
|
46 }
|
|
47 src+=srcstride;
|
|
48 srca+=srcstride;
|
|
49 dstbase+=dststride;
|
|
50 }
|
|
51 return;
|
|
52 }
|
|
53
|
|
54 void vo_draw_alpha_rgb32(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){
|
|
55 int y;
|
|
56 for(y=0;y<h;y++){
|
|
57 register int x;
|
|
58 for(x=0;x<w;x++){
|
|
59 if(srca[x]){
|
|
60 dstbase[4*x+0]=((dstbase[4*x+0]*srca[x])>>8)+src[x];
|
|
61 dstbase[4*x+1]=((dstbase[4*x+1]*srca[x])>>8)+src[x];
|
|
62 dstbase[4*x+2]=((dstbase[4*x+2]*srca[x])>>8)+src[x];
|
|
63 }
|
|
64 }
|
|
65 src+=srcstride;
|
|
66 srca+=srcstride;
|
|
67 dstbase+=dststride;
|
|
68 }
|
|
69 return;
|
|
70 }
|
|
71
|
|
72 void vo_draw_alpha_rgb15(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){
|
|
73 int y;
|
|
74 for(y=0;y<h;y++){
|
|
75 register unsigned short *dst = (unsigned short*) dstbase;
|
|
76 register int x;
|
|
77 for(x=0;x<w;x++){
|
|
78 if(srca[x]){
|
|
79 unsigned char r=dst[x]&0x1F;
|
|
80 unsigned char g=(dst[x]>>5)&0x1F;
|
|
81 unsigned char b=(dst[x]>>10)&0x1F;
|
|
82 r=(((r*srca[x])>>5)+src[x])>>3;
|
|
83 g=(((g*srca[x])>>5)+src[x])>>3;
|
|
84 b=(((b*srca[x])>>5)+src[x])>>3;
|
|
85 dst[x]=(b<<10)|(g<<5)|r;
|
|
86 }
|
|
87 }
|
|
88 src+=srcstride;
|
|
89 srca+=srcstride;
|
|
90 dstbase+=dststride;
|
|
91 }
|
|
92 return;
|
|
93 }
|
|
94
|
|
95 void vo_draw_alpha_rgb16(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){
|
|
96 int y;
|
|
97 for(y=0;y<h;y++){
|
|
98 register unsigned short *dst = (unsigned short*) dstbase;
|
|
99 register int x;
|
|
100 for(x=0;x<w;x++){
|
|
101 if(srca[x]){
|
|
102 unsigned char r=dst[x]&0x1F;
|
|
103 unsigned char g=(dst[x]>>5)&0x3F;
|
|
104 unsigned char b=(dst[x]>>11)&0x1F;
|
|
105 r=(((r*srca[x])>>5)+src[x])>>3;
|
|
106 g=(((g*srca[x])>>6)+src[x])>>2;
|
|
107 b=(((b*srca[x])>>5)+src[x])>>3;
|
|
108 dst[x]=(b<<11)|(g<<5)|r;
|
|
109 }
|
|
110 }
|
|
111 src+=srcstride;
|
|
112 srca+=srcstride;
|
|
113 dstbase+=dststride;
|
|
114 }
|
|
115 return;
|
|
116 }
|
|
117
|