1 /************************************************************************
2 *
3 * yuvrgb24.c, colour space conversion for tmndecode (H.263 decoder)
4 * Copyright (C) 1995, 1996 Telenor R&D, Norway
5 *
6 * Contacts:
7 * Robert Danielsen <Robert.Danielsen@nta.no>
8 *
9 * Telenor Research and Development http://www.nta.no/brukere/DVC/
10 * P.O.Box 83 tel.: +47 63 84 84 00
11 * N-2007 Kjeller, Norway fax.: +47 63 81 00 76
12 *
13 * Copyright (C) 1997 University of BC, Canada
14 * Modified by: Michael Gallant <mikeg@ee.ubc.ca>
15 * Guy Cote <guyc@ee.ubc.ca>
16 * Berna Erol <bernae@ee.ubc.ca>
17 *
18 * Contacts:
19 * Michael Gallant <mikeg@ee.ubc.ca>
20 *
21 * UBC Image Processing Laboratory http://www.ee.ubc.ca/image
22 * 2356 Main Mall tel.: +1 604 822 4051
23 * Vancouver BC Canada V6T1Z4 fax.: +1 604 822 5949
24 *
25 ************************************************************************/
26
27 /* Disclaimer of Warranty
28 *
29 * These software programs are available to the user without any license fee
30 * or royalty on an "as is" basis. The University of British Columbia
31 * disclaims any and all warranties, whether express, implied, or
32 * statuary, including any implied warranties or merchantability or of
33 * fitness for a particular purpose. In no event shall the
34 * copyright-holder be liable for any incidental, punitive, or
35 * consequential damages of any kind whatsoever arising from the use of
36 * these programs.
37 *
38 * This disclaimer of warranty extends to the user of these programs and
39 * user's customers, employees, agents, transferees, successors, and
40 * assigns.
41 *
42 * The University of British Columbia does not represent or warrant that the
43 * programs furnished hereunder are free of infringement of any
44 * third-party patents.
45 *
46 * Commercial implementations of H.263, including shareware, are subject to
47 * royalty fees to patent holders. Many of these patents are general
48 * enough such that they are unavoidable regardless of implementation
49 * design.
50 *
51 */
52
53
54
55 #include "config.h"
56 #include "tmndec.h"
57 #include "global.h"
58
59 /* Data for ConvertYUVtoRGB */
60 #if (defined DISPLAY || defined WINDOWS)
61 long int crv_tab[256];
62 long int cbu_tab[256];
63 long int cgu_tab[256];
64
65 long int cgv_tab[256];
66 long int tab_76309[256];
67
68 void init_dither_tab ()
69 {
70 long int crv, cbu, cgu, cgv;
71 int i;
72
73 crv = 104597;
74 cbu = 132201; /* fra matrise i global.h */
75 cgu = 25675;
76 cgv = 53279;
77
78 for (i = 0; i < 256; i++)
79 {
80 crv_tab[i] = (i - 128) * crv;
81 cbu_tab[i] = (i - 128) * cbu;
82 cgu_tab[i] = (i - 128) * cgu;
83 cgv_tab[i] = (i - 128) * cgv;
84 tab_76309[i] = 76309 * (i - 16);
85 }
86 }
87
88
89
90
91 /**********************************************************************
92 *
93 * Name: ConvertYUVtoRGB
94 * Description: Converts YUV image to RGB (packed mode)
95 *
96 * Input: pointer to source luma, Cr, Cb, destination,
97 * image width and height
98 * Returns:
99 * Side effects:
100 *
101 * Date: 951208 Author: Karl.Lillevold@nta.no
102 *
103 ***********************************************************************/
104
105
106
107 void ConvertYUVtoRGB (src0, src1, src2, dst_ori, width, height)
108 unsigned char *src0, *src1, *src2;
109 unsigned char *dst_ori;
110 int width, height;
111 {
112 extern long int crv_tab[];
113 extern long int cbu_tab[];
114 extern long int cgu_tab[];
115
116 extern long int cgv_tab[];
117 extern long int tab_76309[];
118
119 int y11, y21;
120 int y12, y22;
121 int y13, y23;
122 int y14, y24;
123 int u, v;
124 int i, j;
125 int c11, c21, c31, c41;
126 int c12, c22, c32, c42;
127 unsigned int DW;
128 unsigned int *id1, *id2;
129 unsigned char *py1, *py2, *pu, *pv;
130 unsigned char *d1, *d2;
131
132 d1 = dst_ori;
133 d1 += width * height * 3 - width * 3;
134 d2 = d1 - width * 3;
135
136 py1 = src0;
137 pu = src1;
138 pv = src2;
139 py2 = py1 + width;
140
141 id1 = (unsigned int *) d1;
142 id2 = (unsigned int *) d2;
143
144 for (j = 0; j < height; j += 2)
145 {
146 /* line j + 0 */
147 for (i = 0; i < width; i += 4)
148 {
149 u = *pu++;
150 v = *pv++;
151 c11 = crv_tab[v];
152 c21 = cgu_tab[u];
153 c31 = cgv_tab[v];
154 c41 = cbu_tab[u];
155 u = *pu++;
156 v = *pv++;
157 c12 = crv_tab[v];
158 c22 = cgu_tab[u];
159 c32 = cgv_tab[v];
160 c42 = cbu_tab[u];
161
162 y11 = tab_76309[*py1++]; /* (255/219)*65536 */
163 y12 = tab_76309[*py1++];
164 y13 = tab_76309[*py1++]; /* (255/219)*65536 */
165 y14 = tab_76309[*py1++];
166
167 y21 = tab_76309[*py2++];
168 y22 = tab_76309[*py2++];
169 y23 = tab_76309[*py2++];
170 y24 = tab_76309[*py2++];
171
172 /* RGBR */
173 DW = ((clp[(y11 + c41) >> 16])) |
174 ((clp[(y11 - c21 - c31) >> 16]) << 8) |
175 ((clp[(y11 + c11) >> 16]) << 16) |
176 ((clp[(y12 + c41) >> 16]) << 24);
177 *id1++ = DW;
178
179 /* GBRG */
180 DW = ((clp[(y12 - c21 - c31) >> 16])) |
181 ((clp[(y12 + c11) >> 16]) << 8) |
182 ((clp[(y13 + c42) >> 16]) << 16) |
183 ((clp[(y13 - c22 - c32) >> 16]) << 24);
184 *id1++ = DW;
185
186 /* BRGB */
187 DW = ((clp[(y13 + c12) >> 16])) |
188 ((clp[(y14 + c42) >> 16]) << 8) |
189 ((clp[(y14 - c22 - c32) >> 16]) << 16) |
190 ((clp[(y14 + c12) >> 16]) << 24);
191 *id1++ = DW;
192
193 /* RGBR */
194 DW = ((clp[(y21 + c41) >> 16])) |
195 ((clp[(y21 - c21 - c31) >> 16]) << 8) |
196 ((clp[(y21 + c11) >> 16]) << 16) |
197 ((clp[(y22 + c41) >> 16]) << 24);
198 *id2++ = DW;
199
200 /* GBRG */
201 DW = ((clp[(y22 - c21 - c31) >> 16])) |
202 ((clp[(y22 + c11) >> 16]) << 8) |
203 ((clp[(y23 + c42) >> 16]) << 16) |
204 ((clp[(y23 - c22 - c32) >> 16]) << 24);
205 *id2++ = DW;
206
207 /* BRGB */
208 DW = ((clp[(y23 + c12) >> 16])) |
209 ((clp[(y24 + c42) >> 16]) << 8) |
210 ((clp[(y24 - c22 - c32) >> 16]) << 16) |
211 ((clp[(y24 + c12) >> 16]) << 24);
212 *id2++ = DW;
213 }
214 id1 -= (9 * width) >> 2;
215 id2 -= (9 * width) >> 2;
216 py1 += width;
217 py2 += width;
218 }
219 }
220
221
222 #endif
223
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.