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