1 /***********************************************************
2 Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
7 Permission to use, copy, modify, and distribute this software and its
8 documentation for any purpose and without fee is hereby granted,
9 provided that the above copyright notice appear in all copies and that
10 both that copyright notice and this permission notice appear in
11 supporting documentation, and that the names of Stichting Mathematisch
12 Centrum or CWI or Corporation for National Research Initiatives or
13 CNRI not be used in advertising or publicity pertaining to
14 distribution of the software without specific, written prior
17 While CWI is the initial source for this software, a modified version
18 is made available by the Corporation for National Research Initiatives
19 (CNRI) at the Internet address ftp://ftp.python.org.
21 STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
22 REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
23 MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
24 CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
25 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
26 PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
27 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
28 PERFORMANCE OF THIS SOFTWARE.
30 ******************************************************************/
35 yuv_sv411_to_cl422dc(int invert
, void *data
, void *yuv
, int width
, int height
)
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 */
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
);
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
);
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
);
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
);
66 out_even
+= width
/ 2;
72 yuv_sv411_to_cl422dc_quartersize(int invert
, void *data
, void *yuv
,
73 int width
, int height
)
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 */
83 for (i
= height
/ 4; i
--; ) {
85 u
= YUV411_U00(*in_even
);
86 v
= YUV411_V00(*in_even
);
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
);
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
);
111 yuv_sv411_to_cl422dc_sixteenthsize(int invert
, void *data
, void *yuv
,
112 int width
, int height
)
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 */
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]);
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]);
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]);