blob: a0fa639c037770eadc140f7c9b9a813e3d92dc03 [file] [log] [blame]
Guido van Rossumb6775db1994-08-01 11:34:53 +00001
Sjoerd Mullender6b517fd1993-03-16 12:25:30 +00002#include "yuv.h"
3
4void
5yuv_sv411_to_cl422dc(int invert, void *data, void *yuv, int width, int height)
6{
Antoine Pitrouc83ea132010-05-09 14:46:46 +00007 struct yuv411 *in = data;
8 struct yuv422 *out_even = yuv;
9 struct yuv422 *out_odd = out_even + width / 2;
10 int i, j; /* counters */
Sjoerd Mullender6b517fd1993-03-16 12:25:30 +000011
Antoine Pitrouc83ea132010-05-09 14:46:46 +000012 for (i = height / 2; i--; ) {
13 for (j = width / 4; j--; ) {
14 YUV422_Y0(*out_even) = YUV411_Y00(*in);
15 YUV422_U0(*out_even) = YUV411_U00(*in);
16 YUV422_V0(*out_even) = YUV411_V00(*in);
17 YUV422_Y1(*out_even) = YUV411_Y01(*in);
18 out_even++;
19 YUV422_Y0(*out_even) = YUV411_Y02(*in);
20 YUV422_U0(*out_even) = YUV411_U02(*in);
21 YUV422_V0(*out_even) = YUV411_V02(*in);
22 YUV422_Y1(*out_even) = YUV411_Y03(*in);
23 out_even++;
24 YUV422_Y0(*out_odd) = YUV411_Y10(*in);
25 YUV422_U0(*out_odd) = YUV411_U10(*in);
26 YUV422_V0(*out_odd) = YUV411_V10(*in);
27 YUV422_Y1(*out_odd) = YUV411_Y11(*in);
28 out_odd++;
29 YUV422_Y0(*out_odd) = YUV411_Y12(*in);
30 YUV422_U0(*out_odd) = YUV411_U12(*in);
31 YUV422_V0(*out_odd) = YUV411_V12(*in);
32 YUV422_Y1(*out_odd) = YUV411_Y13(*in);
33 out_odd++;
34 in++;
35 }
36 out_even += width / 2;
37 out_odd += width / 2;
38 }
Sjoerd Mullender6b517fd1993-03-16 12:25:30 +000039}
40
41void
42yuv_sv411_to_cl422dc_quartersize(int invert, void *data, void *yuv,
Antoine Pitrouc83ea132010-05-09 14:46:46 +000043 int width, int height)
Sjoerd Mullender6b517fd1993-03-16 12:25:30 +000044{
Antoine Pitrouc83ea132010-05-09 14:46:46 +000045 int w4 = width / 4; /* quarter of width is used often */
46 struct yuv411 *in_even = data;
47 struct yuv411 *in_odd = in_even + w4;
48 struct yuv422 *out_even = yuv;
49 struct yuv422 *out_odd = out_even + w4;
50 int i, j; /* counters */
51 int u, v; /* U and V values */
Sjoerd Mullender6b517fd1993-03-16 12:25:30 +000052
Antoine Pitrouc83ea132010-05-09 14:46:46 +000053 for (i = height / 4; i--; ) {
54 for (j = w4; j--; ) {
55 u = YUV411_U00(*in_even);
56 v = YUV411_V00(*in_even);
Sjoerd Mullender6b517fd1993-03-16 12:25:30 +000057
Antoine Pitrouc83ea132010-05-09 14:46:46 +000058 YUV422_Y0(*out_even) = YUV411_Y00(*in_even);
59 YUV422_U0(*out_even) = u;
60 YUV422_V0(*out_even) = v;
61 YUV422_Y1(*out_even) = YUV411_Y02(*in_even);
Sjoerd Mullender6b517fd1993-03-16 12:25:30 +000062
Antoine Pitrouc83ea132010-05-09 14:46:46 +000063 YUV422_Y0(*out_odd) = YUV411_Y10(*in_odd);
64 YUV422_U0(*out_odd) = u;
65 YUV422_V0(*out_odd) = v;
66 YUV422_Y1(*out_odd) = YUV411_Y12(*in_odd);
Sjoerd Mullender6b517fd1993-03-16 12:25:30 +000067
Antoine Pitrouc83ea132010-05-09 14:46:46 +000068 in_even++;
69 in_odd++;
70 out_even++;
71 out_odd++;
72 }
73 in_even += w4;
74 in_odd += w4;
75 out_even += w4;
76 out_odd += w4;
77 }
Sjoerd Mullender6b517fd1993-03-16 12:25:30 +000078}
79
80void
81yuv_sv411_to_cl422dc_sixteenthsize(int invert, void *data, void *yuv,
Antoine Pitrouc83ea132010-05-09 14:46:46 +000082 int width, int height)
Sjoerd Mullender6b517fd1993-03-16 12:25:30 +000083{
Antoine Pitrouc83ea132010-05-09 14:46:46 +000084 int w4_3 = 3 * width / 4; /* three quarters of width is used often */
85 int w8 = width / 8; /* and so is one eighth */
86 struct yuv411 *in_even = data;
87 struct yuv411 *in_odd = in_even + width / 2;
88 struct yuv422 *out_even = yuv;
89 struct yuv422 *out_odd = out_even + w8;
90 int i, j; /* counters */
91 int u, v; /* U and V values */
Sjoerd Mullender6b517fd1993-03-16 12:25:30 +000092
Antoine Pitrouc83ea132010-05-09 14:46:46 +000093 for (i = height / 8; i--; ) {
94 for (j = w8; j--; ) {
95 u = YUV411_U00(in_even[0]);
96 v = YUV411_V00(in_even[0]);
Sjoerd Mullender6b517fd1993-03-16 12:25:30 +000097
Antoine Pitrouc83ea132010-05-09 14:46:46 +000098 YUV422_Y0(*out_even) = YUV411_Y00(in_even[0]);
99 YUV422_U0(*out_even) = u;
100 YUV422_V0(*out_even) = v;
101 YUV422_Y1(*out_even) = YUV411_Y00(in_even[1]);
Sjoerd Mullender6b517fd1993-03-16 12:25:30 +0000102
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000103 YUV422_Y0(*out_odd) = YUV411_Y00(in_odd[0]);
104 YUV422_U0(*out_odd) = u;
105 YUV422_V0(*out_odd) = v;
106 YUV422_Y1(*out_odd) = YUV411_Y00(in_even[1]);
Sjoerd Mullender6b517fd1993-03-16 12:25:30 +0000107
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000108 in_even += 2;
109 in_odd += 2;
110 out_even++;
111 out_odd++;
112 }
113 in_even += w4_3;
114 in_odd += w4_3;
115 out_even += w8;
116 out_odd += w8;
117 }
Sjoerd Mullender6b517fd1993-03-16 12:25:30 +0000118}