blob: 3a5c03672eac1564c0acbc34ad5c210a8354607f [file] [log] [blame]
Guido van Rossumb6775db1994-08-01 11:34:53 +00001/***********************************************************
Guido van Rossumfd71b9e2000-06-30 23:50:40 +00002Copyright (c) 2000, BeOpen.com.
3Copyright (c) 1995-2000, Corporation for National Research Initiatives.
4Copyright (c) 1990-1995, Stichting Mathematisch Centrum.
5All rights reserved.
Guido van Rossumb6775db1994-08-01 11:34:53 +00006
Guido van Rossumfd71b9e2000-06-30 23:50:40 +00007See the file "Misc/COPYRIGHT" for information on usage and
8redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
Guido van Rossumb6775db1994-08-01 11:34:53 +00009******************************************************************/
10
Sjoerd Mullender6b517fd1993-03-16 12:25:30 +000011#include "yuv.h"
12
13void
14yuv_sv411_to_cl422dc(int invert, void *data, void *yuv, int width, int height)
15{
16 struct yuv411 *in = data;
17 struct yuv422 *out_even = yuv;
18 struct yuv422 *out_odd = out_even + width / 2;
19 int i, j; /* counters */
20
21 for (i = height / 2; i--; ) {
22 for (j = width / 4; j--; ) {
23 YUV422_Y0(*out_even) = YUV411_Y00(*in);
24 YUV422_U0(*out_even) = YUV411_U00(*in);
25 YUV422_V0(*out_even) = YUV411_V00(*in);
26 YUV422_Y1(*out_even) = YUV411_Y01(*in);
27 out_even++;
28 YUV422_Y0(*out_even) = YUV411_Y02(*in);
29 YUV422_U0(*out_even) = YUV411_U02(*in);
30 YUV422_V0(*out_even) = YUV411_V02(*in);
31 YUV422_Y1(*out_even) = YUV411_Y03(*in);
32 out_even++;
33 YUV422_Y0(*out_odd) = YUV411_Y10(*in);
34 YUV422_U0(*out_odd) = YUV411_U10(*in);
35 YUV422_V0(*out_odd) = YUV411_V10(*in);
36 YUV422_Y1(*out_odd) = YUV411_Y11(*in);
37 out_odd++;
38 YUV422_Y0(*out_odd) = YUV411_Y12(*in);
39 YUV422_U0(*out_odd) = YUV411_U12(*in);
40 YUV422_V0(*out_odd) = YUV411_V12(*in);
41 YUV422_Y1(*out_odd) = YUV411_Y13(*in);
42 out_odd++;
43 in++;
44 }
45 out_even += width / 2;
46 out_odd += width / 2;
47 }
48}
49
50void
51yuv_sv411_to_cl422dc_quartersize(int invert, void *data, void *yuv,
52 int width, int height)
53{
54 int w4 = width / 4; /* quarter of width is used often */
55 struct yuv411 *in_even = data;
56 struct yuv411 *in_odd = in_even + w4;
57 struct yuv422 *out_even = yuv;
58 struct yuv422 *out_odd = out_even + w4;
59 int i, j; /* counters */
60 int u, v; /* U and V values */
61
62 for (i = height / 4; i--; ) {
63 for (j = w4; j--; ) {
64 u = YUV411_U00(*in_even);
65 v = YUV411_V00(*in_even);
66
67 YUV422_Y0(*out_even) = YUV411_Y00(*in_even);
68 YUV422_U0(*out_even) = u;
69 YUV422_V0(*out_even) = v;
70 YUV422_Y1(*out_even) = YUV411_Y02(*in_even);
71
72 YUV422_Y0(*out_odd) = YUV411_Y10(*in_odd);
73 YUV422_U0(*out_odd) = u;
74 YUV422_V0(*out_odd) = v;
75 YUV422_Y1(*out_odd) = YUV411_Y12(*in_odd);
76
77 in_even++;
78 in_odd++;
79 out_even++;
80 out_odd++;
81 }
82 in_even += w4;
83 in_odd += w4;
84 out_even += w4;
85 out_odd += w4;
86 }
87}
88
89void
90yuv_sv411_to_cl422dc_sixteenthsize(int invert, void *data, void *yuv,
91 int width, int height)
92{
93 int w4_3 = 3 * width / 4; /* three quarters of width is used often */
94 int w8 = width / 8; /* and so is one eighth */
95 struct yuv411 *in_even = data;
96 struct yuv411 *in_odd = in_even + width / 2;
97 struct yuv422 *out_even = yuv;
98 struct yuv422 *out_odd = out_even + w8;
99 int i, j; /* counters */
100 int u, v; /* U and V values */
101
102 for (i = height / 8; i--; ) {
103 for (j = w8; j--; ) {
104 u = YUV411_U00(in_even[0]);
105 v = YUV411_V00(in_even[0]);
106
107 YUV422_Y0(*out_even) = YUV411_Y00(in_even[0]);
108 YUV422_U0(*out_even) = u;
109 YUV422_V0(*out_even) = v;
110 YUV422_Y1(*out_even) = YUV411_Y00(in_even[1]);
111
112 YUV422_Y0(*out_odd) = YUV411_Y00(in_odd[0]);
113 YUV422_U0(*out_odd) = u;
114 YUV422_V0(*out_odd) = v;
115 YUV422_Y1(*out_odd) = YUV411_Y00(in_even[1]);
116
117 in_even += 2;
118 in_odd += 2;
119 out_even++;
120 out_odd++;
121 }
122 in_even += w4_3;
123 in_odd += w4_3;
124 out_even += w8;
125 out_odd += w8;
126 }
127}