blob: 69ec47c0fe9edd4bd1a2a0a1db6aa45581500087 [file] [log] [blame]
Guido van Rossumb6775db1994-08-01 11:34:53 +00001/***********************************************************
2Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
3Amsterdam, The Netherlands.
4
5 All Rights Reserved
6
7Permission to use, copy, modify, and distribute this software and its
8documentation for any purpose and without fee is hereby granted,
9provided that the above copyright notice appear in all copies and that
10both that copyright notice and this permission notice appear in
11supporting documentation, and that the names of Stichting Mathematisch
12Centrum or CWI not be used in advertising or publicity pertaining to
13distribution of the software without specific, written prior permission.
14
15STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
16THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
17FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
18FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
20ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
21OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22
23******************************************************************/
24
Sjoerd Mullender6b517fd1993-03-16 12:25:30 +000025#include "yuv.h"
26
27void
28yuv_sv411_to_cl422dc(int invert, void *data, void *yuv, int width, int height)
29{
30 struct yuv411 *in = data;
31 struct yuv422 *out_even = yuv;
32 struct yuv422 *out_odd = out_even + width / 2;
33 int i, j; /* counters */
34
35 for (i = height / 2; i--; ) {
36 for (j = width / 4; j--; ) {
37 YUV422_Y0(*out_even) = YUV411_Y00(*in);
38 YUV422_U0(*out_even) = YUV411_U00(*in);
39 YUV422_V0(*out_even) = YUV411_V00(*in);
40 YUV422_Y1(*out_even) = YUV411_Y01(*in);
41 out_even++;
42 YUV422_Y0(*out_even) = YUV411_Y02(*in);
43 YUV422_U0(*out_even) = YUV411_U02(*in);
44 YUV422_V0(*out_even) = YUV411_V02(*in);
45 YUV422_Y1(*out_even) = YUV411_Y03(*in);
46 out_even++;
47 YUV422_Y0(*out_odd) = YUV411_Y10(*in);
48 YUV422_U0(*out_odd) = YUV411_U10(*in);
49 YUV422_V0(*out_odd) = YUV411_V10(*in);
50 YUV422_Y1(*out_odd) = YUV411_Y11(*in);
51 out_odd++;
52 YUV422_Y0(*out_odd) = YUV411_Y12(*in);
53 YUV422_U0(*out_odd) = YUV411_U12(*in);
54 YUV422_V0(*out_odd) = YUV411_V12(*in);
55 YUV422_Y1(*out_odd) = YUV411_Y13(*in);
56 out_odd++;
57 in++;
58 }
59 out_even += width / 2;
60 out_odd += width / 2;
61 }
62}
63
64void
65yuv_sv411_to_cl422dc_quartersize(int invert, void *data, void *yuv,
66 int width, int height)
67{
68 int w4 = width / 4; /* quarter of width is used often */
69 struct yuv411 *in_even = data;
70 struct yuv411 *in_odd = in_even + w4;
71 struct yuv422 *out_even = yuv;
72 struct yuv422 *out_odd = out_even + w4;
73 int i, j; /* counters */
74 int u, v; /* U and V values */
75
76 for (i = height / 4; i--; ) {
77 for (j = w4; j--; ) {
78 u = YUV411_U00(*in_even);
79 v = YUV411_V00(*in_even);
80
81 YUV422_Y0(*out_even) = YUV411_Y00(*in_even);
82 YUV422_U0(*out_even) = u;
83 YUV422_V0(*out_even) = v;
84 YUV422_Y1(*out_even) = YUV411_Y02(*in_even);
85
86 YUV422_Y0(*out_odd) = YUV411_Y10(*in_odd);
87 YUV422_U0(*out_odd) = u;
88 YUV422_V0(*out_odd) = v;
89 YUV422_Y1(*out_odd) = YUV411_Y12(*in_odd);
90
91 in_even++;
92 in_odd++;
93 out_even++;
94 out_odd++;
95 }
96 in_even += w4;
97 in_odd += w4;
98 out_even += w4;
99 out_odd += w4;
100 }
101}
102
103void
104yuv_sv411_to_cl422dc_sixteenthsize(int invert, void *data, void *yuv,
105 int width, int height)
106{
107 int w4_3 = 3 * width / 4; /* three quarters of width is used often */
108 int w8 = width / 8; /* and so is one eighth */
109 struct yuv411 *in_even = data;
110 struct yuv411 *in_odd = in_even + width / 2;
111 struct yuv422 *out_even = yuv;
112 struct yuv422 *out_odd = out_even + w8;
113 int i, j; /* counters */
114 int u, v; /* U and V values */
115
116 for (i = height / 8; i--; ) {
117 for (j = w8; j--; ) {
118 u = YUV411_U00(in_even[0]);
119 v = YUV411_V00(in_even[0]);
120
121 YUV422_Y0(*out_even) = YUV411_Y00(in_even[0]);
122 YUV422_U0(*out_even) = u;
123 YUV422_V0(*out_even) = v;
124 YUV422_Y1(*out_even) = YUV411_Y00(in_even[1]);
125
126 YUV422_Y0(*out_odd) = YUV411_Y00(in_odd[0]);
127 YUV422_U0(*out_odd) = u;
128 YUV422_V0(*out_odd) = v;
129 YUV422_Y1(*out_odd) = YUV411_Y00(in_even[1]);
130
131 in_even += 2;
132 in_odd += 2;
133 out_even++;
134 out_odd++;
135 }
136 in_even += w4_3;
137 in_odd += w4_3;
138 out_even += w8;
139 out_odd += w8;
140 }
141}