annotate imgconvert_template.h @ 2526:e55fcddd8392 libavcodec

10l (shorten.o missing)
author michael
date Sat, 26 Feb 2005 03:40:29 +0000
parents 766a2f4edbea
children ef2149182f1c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1204
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
1 /*
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
2 * Templates for image convertion routines
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
3 * Copyright (c) 2001, 2002, 2003 Fabrice Bellard.
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
4 *
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
5 * This library is free software; you can redistribute it and/or
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
8 * version 2 of the License, or (at your option) any later version.
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
9 *
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
10 * This library is distributed in the hope that it will be useful,
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
13 * Lesser General Public License for more details.
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
14 *
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
16 * License along with this library; if not, write to the Free Software
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
18 */
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
19
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
20 #ifndef RGB_OUT
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
21 #define RGB_OUT(d, r, g, b) RGBA_OUT(d, r, g, b, 0xff)
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
22 #endif
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
23
1488
766a2f4edbea avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents: 1208
diff changeset
24 static void glue(yuv420p_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
1204
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
25 int width, int height)
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
26 {
1488
766a2f4edbea avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents: 1208
diff changeset
27 const uint8_t *y1_ptr, *y2_ptr, *cb_ptr, *cr_ptr;
766a2f4edbea avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents: 1208
diff changeset
28 uint8_t *d, *d1, *d2;
1204
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
29 int w, y, cb, cr, r_add, g_add, b_add, width2;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
30 uint8_t *cm = cropTbl + MAX_NEG_CROP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
31 unsigned int r, g, b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
32
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
33 d = dst->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
34 y1_ptr = src->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
35 cb_ptr = src->data[1];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
36 cr_ptr = src->data[2];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
37 width2 = (width + 1) >> 1;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
38 for(;height >= 2; height -= 2) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
39 d1 = d;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
40 d2 = d + dst->linesize[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
41 y2_ptr = y1_ptr + src->linesize[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
42 for(w = width; w >= 2; w -= 2) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
43 YUV_TO_RGB1_CCIR(cb_ptr[0], cr_ptr[0]);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
44 /* output 4 pixels */
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
45 YUV_TO_RGB2_CCIR(r, g, b, y1_ptr[0]);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
46 RGB_OUT(d1, r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
47
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
48 YUV_TO_RGB2_CCIR(r, g, b, y1_ptr[1]);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
49 RGB_OUT(d1 + BPP, r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
50
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
51 YUV_TO_RGB2_CCIR(r, g, b, y2_ptr[0]);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
52 RGB_OUT(d2, r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
53
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
54 YUV_TO_RGB2_CCIR(r, g, b, y2_ptr[1]);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
55 RGB_OUT(d2 + BPP, r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
56
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
57 d1 += 2 * BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
58 d2 += 2 * BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
59
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
60 y1_ptr += 2;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
61 y2_ptr += 2;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
62 cb_ptr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
63 cr_ptr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
64 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
65 /* handle odd width */
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
66 if (w) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
67 YUV_TO_RGB1_CCIR(cb_ptr[0], cr_ptr[0]);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
68 YUV_TO_RGB2_CCIR(r, g, b, y1_ptr[0]);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
69 RGB_OUT(d1, r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
70
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
71 YUV_TO_RGB2_CCIR(r, g, b, y2_ptr[0]);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
72 RGB_OUT(d2, r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
73 d1 += BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
74 d2 += BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
75 y1_ptr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
76 y2_ptr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
77 cb_ptr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
78 cr_ptr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
79 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
80 d += 2 * dst->linesize[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
81 y1_ptr += 2 * src->linesize[0] - width;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
82 cb_ptr += src->linesize[1] - width2;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
83 cr_ptr += src->linesize[2] - width2;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
84 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
85 /* handle odd height */
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
86 if (height) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
87 d1 = d;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
88 for(w = width; w >= 2; w -= 2) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
89 YUV_TO_RGB1_CCIR(cb_ptr[0], cr_ptr[0]);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
90 /* output 2 pixels */
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
91 YUV_TO_RGB2_CCIR(r, g, b, y1_ptr[0]);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
92 RGB_OUT(d1, r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
93
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
94 YUV_TO_RGB2_CCIR(r, g, b, y1_ptr[1]);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
95 RGB_OUT(d1 + BPP, r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
96
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
97 d1 += 2 * BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
98
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
99 y1_ptr += 2;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
100 cb_ptr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
101 cr_ptr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
102 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
103 /* handle width */
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
104 if (w) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
105 YUV_TO_RGB1_CCIR(cb_ptr[0], cr_ptr[0]);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
106 /* output 2 pixels */
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
107 YUV_TO_RGB2_CCIR(r, g, b, y1_ptr[0]);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
108 RGB_OUT(d1, r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
109 d1 += BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
110
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
111 y1_ptr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
112 cb_ptr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
113 cr_ptr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
114 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
115 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
116 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
117
1488
766a2f4edbea avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents: 1208
diff changeset
118 static void glue(yuvj420p_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
1204
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
119 int width, int height)
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
120 {
1488
766a2f4edbea avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents: 1208
diff changeset
121 const uint8_t *y1_ptr, *y2_ptr, *cb_ptr, *cr_ptr;
766a2f4edbea avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents: 1208
diff changeset
122 uint8_t *d, *d1, *d2;
1204
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
123 int w, y, cb, cr, r_add, g_add, b_add, width2;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
124 uint8_t *cm = cropTbl + MAX_NEG_CROP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
125 unsigned int r, g, b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
126
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
127 d = dst->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
128 y1_ptr = src->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
129 cb_ptr = src->data[1];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
130 cr_ptr = src->data[2];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
131 width2 = (width + 1) >> 1;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
132 for(;height >= 2; height -= 2) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
133 d1 = d;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
134 d2 = d + dst->linesize[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
135 y2_ptr = y1_ptr + src->linesize[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
136 for(w = width; w >= 2; w -= 2) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
137 YUV_TO_RGB1(cb_ptr[0], cr_ptr[0]);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
138 /* output 4 pixels */
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
139 YUV_TO_RGB2(r, g, b, y1_ptr[0]);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
140 RGB_OUT(d1, r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
141
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
142 YUV_TO_RGB2(r, g, b, y1_ptr[1]);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
143 RGB_OUT(d1 + BPP, r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
144
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
145 YUV_TO_RGB2(r, g, b, y2_ptr[0]);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
146 RGB_OUT(d2, r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
147
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
148 YUV_TO_RGB2(r, g, b, y2_ptr[1]);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
149 RGB_OUT(d2 + BPP, r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
150
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
151 d1 += 2 * BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
152 d2 += 2 * BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
153
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
154 y1_ptr += 2;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
155 y2_ptr += 2;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
156 cb_ptr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
157 cr_ptr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
158 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
159 /* handle odd width */
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
160 if (w) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
161 YUV_TO_RGB1(cb_ptr[0], cr_ptr[0]);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
162 YUV_TO_RGB2(r, g, b, y1_ptr[0]);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
163 RGB_OUT(d1, r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
164
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
165 YUV_TO_RGB2(r, g, b, y2_ptr[0]);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
166 RGB_OUT(d2, r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
167 d1 += BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
168 d2 += BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
169 y1_ptr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
170 y2_ptr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
171 cb_ptr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
172 cr_ptr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
173 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
174 d += 2 * dst->linesize[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
175 y1_ptr += 2 * src->linesize[0] - width;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
176 cb_ptr += src->linesize[1] - width2;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
177 cr_ptr += src->linesize[2] - width2;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
178 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
179 /* handle odd height */
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
180 if (height) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
181 d1 = d;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
182 for(w = width; w >= 2; w -= 2) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
183 YUV_TO_RGB1(cb_ptr[0], cr_ptr[0]);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
184 /* output 2 pixels */
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
185 YUV_TO_RGB2(r, g, b, y1_ptr[0]);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
186 RGB_OUT(d1, r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
187
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
188 YUV_TO_RGB2(r, g, b, y1_ptr[1]);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
189 RGB_OUT(d1 + BPP, r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
190
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
191 d1 += 2 * BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
192
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
193 y1_ptr += 2;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
194 cb_ptr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
195 cr_ptr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
196 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
197 /* handle width */
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
198 if (w) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
199 YUV_TO_RGB1(cb_ptr[0], cr_ptr[0]);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
200 /* output 2 pixels */
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
201 YUV_TO_RGB2(r, g, b, y1_ptr[0]);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
202 RGB_OUT(d1, r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
203 d1 += BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
204
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
205 y1_ptr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
206 cb_ptr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
207 cr_ptr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
208 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
209 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
210 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
211
1488
766a2f4edbea avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents: 1208
diff changeset
212 static void glue(RGB_NAME, _to_yuv420p)(AVPicture *dst, const AVPicture *src,
1204
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
213 int width, int height)
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
214 {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
215 int wrap, wrap3, width2;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
216 int r, g, b, r1, g1, b1, w;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
217 uint8_t *lum, *cb, *cr;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
218 const uint8_t *p;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
219
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
220 lum = dst->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
221 cb = dst->data[1];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
222 cr = dst->data[2];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
223
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
224 width2 = (width + 1) >> 1;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
225 wrap = dst->linesize[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
226 wrap3 = src->linesize[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
227 p = src->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
228 for(;height>=2;height -= 2) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
229 for(w = width; w >= 2; w -= 2) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
230 RGB_IN(r, g, b, p);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
231 r1 = r;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
232 g1 = g;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
233 b1 = b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
234 lum[0] = RGB_TO_Y_CCIR(r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
235
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
236 RGB_IN(r, g, b, p + BPP);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
237 r1 += r;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
238 g1 += g;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
239 b1 += b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
240 lum[1] = RGB_TO_Y_CCIR(r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
241 p += wrap3;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
242 lum += wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
243
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
244 RGB_IN(r, g, b, p);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
245 r1 += r;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
246 g1 += g;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
247 b1 += b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
248 lum[0] = RGB_TO_Y_CCIR(r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
249
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
250 RGB_IN(r, g, b, p + BPP);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
251 r1 += r;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
252 g1 += g;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
253 b1 += b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
254 lum[1] = RGB_TO_Y_CCIR(r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
255
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
256 cb[0] = RGB_TO_U_CCIR(r1, g1, b1, 2);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
257 cr[0] = RGB_TO_V_CCIR(r1, g1, b1, 2);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
258
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
259 cb++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
260 cr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
261 p += -wrap3 + 2 * BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
262 lum += -wrap + 2;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
263 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
264 if (w) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
265 RGB_IN(r, g, b, p);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
266 r1 = r;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
267 g1 = g;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
268 b1 = b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
269 lum[0] = RGB_TO_Y_CCIR(r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
270 p += wrap3;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
271 lum += wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
272 RGB_IN(r, g, b, p);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
273 r1 += r;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
274 g1 += g;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
275 b1 += b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
276 lum[0] = RGB_TO_Y_CCIR(r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
277 cb[0] = RGB_TO_U_CCIR(r1, g1, b1, 1);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
278 cr[0] = RGB_TO_V_CCIR(r1, g1, b1, 1);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
279 cb++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
280 cr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
281 p += -wrap3 + BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
282 lum += -wrap + 1;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
283 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
284 p += wrap3 + (wrap3 - width * BPP);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
285 lum += wrap + (wrap - width);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
286 cb += dst->linesize[1] - width2;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
287 cr += dst->linesize[2] - width2;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
288 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
289 /* handle odd height */
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
290 if (height) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
291 for(w = width; w >= 2; w -= 2) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
292 RGB_IN(r, g, b, p);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
293 r1 = r;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
294 g1 = g;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
295 b1 = b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
296 lum[0] = RGB_TO_Y_CCIR(r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
297
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
298 RGB_IN(r, g, b, p + BPP);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
299 r1 += r;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
300 g1 += g;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
301 b1 += b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
302 lum[1] = RGB_TO_Y_CCIR(r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
303 cb[0] = RGB_TO_U_CCIR(r1, g1, b1, 1);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
304 cr[0] = RGB_TO_V_CCIR(r1, g1, b1, 1);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
305 cb++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
306 cr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
307 p += 2 * BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
308 lum += 2;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
309 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
310 if (w) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
311 RGB_IN(r, g, b, p);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
312 lum[0] = RGB_TO_Y_CCIR(r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
313 cb[0] = RGB_TO_U_CCIR(r, g, b, 0);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
314 cr[0] = RGB_TO_V_CCIR(r, g, b, 0);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
315 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
316 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
317 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
318
1488
766a2f4edbea avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents: 1208
diff changeset
319 static void glue(RGB_NAME, _to_gray)(AVPicture *dst, const AVPicture *src,
1204
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
320 int width, int height)
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
321 {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
322 const unsigned char *p;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
323 unsigned char *q;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
324 int r, g, b, dst_wrap, src_wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
325 int x, y;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
326
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
327 p = src->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
328 src_wrap = src->linesize[0] - BPP * width;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
329
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
330 q = dst->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
331 dst_wrap = dst->linesize[0] - width;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
332
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
333 for(y=0;y<height;y++) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
334 for(x=0;x<width;x++) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
335 RGB_IN(r, g, b, p);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
336 q[0] = RGB_TO_Y(r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
337 q++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
338 p += BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
339 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
340 p += src_wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
341 q += dst_wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
342 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
343 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
344
1488
766a2f4edbea avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents: 1208
diff changeset
345 static void glue(gray_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
1204
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
346 int width, int height)
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
347 {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
348 const unsigned char *p;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
349 unsigned char *q;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
350 int r, dst_wrap, src_wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
351 int x, y;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
352
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
353 p = src->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
354 src_wrap = src->linesize[0] - width;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
355
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
356 q = dst->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
357 dst_wrap = dst->linesize[0] - BPP * width;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
358
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
359 for(y=0;y<height;y++) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
360 for(x=0;x<width;x++) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
361 r = p[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
362 RGB_OUT(q, r, r, r);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
363 q += BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
364 p ++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
365 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
366 p += src_wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
367 q += dst_wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
368 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
369 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
370
1488
766a2f4edbea avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents: 1208
diff changeset
371 static void glue(pal8_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
1204
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
372 int width, int height)
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
373 {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
374 const unsigned char *p;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
375 unsigned char *q;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
376 int r, g, b, dst_wrap, src_wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
377 int x, y;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
378 uint32_t v;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
379 const uint32_t *palette;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
380
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
381 p = src->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
382 src_wrap = src->linesize[0] - width;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
383 palette = (uint32_t *)src->data[1];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
384
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
385 q = dst->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
386 dst_wrap = dst->linesize[0] - BPP * width;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
387
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
388 for(y=0;y<height;y++) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
389 for(x=0;x<width;x++) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
390 v = palette[p[0]];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
391 r = (v >> 16) & 0xff;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
392 g = (v >> 8) & 0xff;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
393 b = (v) & 0xff;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
394 #ifdef RGBA_OUT
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
395 {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
396 int a;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
397 a = (v >> 24) & 0xff;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
398 RGBA_OUT(q, r, g, b, a);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
399 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
400 #else
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
401 RGB_OUT(q, r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
402 #endif
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
403 q += BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
404 p ++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
405 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
406 p += src_wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
407 q += dst_wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
408 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
409 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
410
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
411 #if !defined(FMT_RGBA32) && defined(RGBA_OUT)
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
412 /* alpha support */
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
413
1488
766a2f4edbea avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents: 1208
diff changeset
414 static void glue(rgba32_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
1204
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
415 int width, int height)
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
416 {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
417 const uint8_t *s;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
418 uint8_t *d;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
419 int src_wrap, dst_wrap, j, y;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
420 unsigned int v, r, g, b, a;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
421
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
422 s = src->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
423 src_wrap = src->linesize[0] - width * 4;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
424
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
425 d = dst->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
426 dst_wrap = dst->linesize[0] - width * BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
427
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
428 for(y=0;y<height;y++) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
429 for(j = 0;j < width; j++) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
430 v = ((const uint32_t *)(s))[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
431 a = (v >> 24) & 0xff;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
432 r = (v >> 16) & 0xff;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
433 g = (v >> 8) & 0xff;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
434 b = v & 0xff;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
435 RGBA_OUT(d, r, g, b, a);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
436 s += 4;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
437 d += BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
438 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
439 s += src_wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
440 d += dst_wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
441 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
442 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
443
1488
766a2f4edbea avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents: 1208
diff changeset
444 static void glue(RGB_NAME, _to_rgba32)(AVPicture *dst, const AVPicture *src,
1204
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
445 int width, int height)
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
446 {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
447 const uint8_t *s;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
448 uint8_t *d;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
449 int src_wrap, dst_wrap, j, y;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
450 unsigned int r, g, b, a;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
451
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
452 s = src->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
453 src_wrap = src->linesize[0] - width * BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
454
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
455 d = dst->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
456 dst_wrap = dst->linesize[0] - width * 4;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
457
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
458 for(y=0;y<height;y++) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
459 for(j = 0;j < width; j++) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
460 RGBA_IN(r, g, b, a, s);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
461 ((uint32_t *)(d))[0] = (a << 24) | (r << 16) | (g << 8) | b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
462 d += 4;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
463 s += BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
464 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
465 s += src_wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
466 d += dst_wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
467 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
468 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
469
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
470 #endif /* !defined(FMT_RGBA32) && defined(RGBA_IN) */
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
471
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
472 #ifndef FMT_RGB24
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
473
1488
766a2f4edbea avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents: 1208
diff changeset
474 static void glue(rgb24_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
1204
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
475 int width, int height)
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
476 {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
477 const uint8_t *s;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
478 uint8_t *d;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
479 int src_wrap, dst_wrap, j, y;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
480 unsigned int r, g, b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
481
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
482 s = src->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
483 src_wrap = src->linesize[0] - width * 3;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
484
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
485 d = dst->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
486 dst_wrap = dst->linesize[0] - width * BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
487
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
488 for(y=0;y<height;y++) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
489 for(j = 0;j < width; j++) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
490 r = s[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
491 g = s[1];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
492 b = s[2];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
493 RGB_OUT(d, r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
494 s += 3;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
495 d += BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
496 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
497 s += src_wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
498 d += dst_wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
499 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
500 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
501
1488
766a2f4edbea avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents: 1208
diff changeset
502 static void glue(RGB_NAME, _to_rgb24)(AVPicture *dst, const AVPicture *src,
1204
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
503 int width, int height)
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
504 {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
505 const uint8_t *s;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
506 uint8_t *d;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
507 int src_wrap, dst_wrap, j, y;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
508 unsigned int r, g , b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
509
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
510 s = src->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
511 src_wrap = src->linesize[0] - width * BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
512
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
513 d = dst->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
514 dst_wrap = dst->linesize[0] - width * 3;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
515
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
516 for(y=0;y<height;y++) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
517 for(j = 0;j < width; j++) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
518 RGB_IN(r, g, b, s)
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
519 d[0] = r;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
520 d[1] = g;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
521 d[2] = b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
522 d += 3;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
523 s += BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
524 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
525 s += src_wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
526 d += dst_wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
527 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
528 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
529
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
530 #endif /* !FMT_RGB24 */
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
531
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
532 #ifdef FMT_RGB24
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
533
1488
766a2f4edbea avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents: 1208
diff changeset
534 static void yuv444p_to_rgb24(AVPicture *dst, const AVPicture *src,
1204
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
535 int width, int height)
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
536 {
1488
766a2f4edbea avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents: 1208
diff changeset
537 const uint8_t *y1_ptr, *cb_ptr, *cr_ptr;
766a2f4edbea avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents: 1208
diff changeset
538 uint8_t *d, *d1;
1204
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
539 int w, y, cb, cr, r_add, g_add, b_add;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
540 uint8_t *cm = cropTbl + MAX_NEG_CROP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
541 unsigned int r, g, b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
542
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
543 d = dst->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
544 y1_ptr = src->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
545 cb_ptr = src->data[1];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
546 cr_ptr = src->data[2];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
547 for(;height > 0; height --) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
548 d1 = d;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
549 for(w = width; w > 0; w--) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
550 YUV_TO_RGB1_CCIR(cb_ptr[0], cr_ptr[0]);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
551
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
552 YUV_TO_RGB2_CCIR(r, g, b, y1_ptr[0]);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
553 RGB_OUT(d1, r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
554 d1 += BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
555
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
556 y1_ptr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
557 cb_ptr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
558 cr_ptr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
559 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
560 d += dst->linesize[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
561 y1_ptr += src->linesize[0] - width;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
562 cb_ptr += src->linesize[1] - width;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
563 cr_ptr += src->linesize[2] - width;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
564 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
565 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
566
1488
766a2f4edbea avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents: 1208
diff changeset
567 static void yuvj444p_to_rgb24(AVPicture *dst, const AVPicture *src,
1204
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
568 int width, int height)
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
569 {
1488
766a2f4edbea avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents: 1208
diff changeset
570 const uint8_t *y1_ptr, *cb_ptr, *cr_ptr;
766a2f4edbea avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents: 1208
diff changeset
571 uint8_t *d, *d1;
1204
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
572 int w, y, cb, cr, r_add, g_add, b_add;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
573 uint8_t *cm = cropTbl + MAX_NEG_CROP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
574 unsigned int r, g, b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
575
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
576 d = dst->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
577 y1_ptr = src->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
578 cb_ptr = src->data[1];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
579 cr_ptr = src->data[2];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
580 for(;height > 0; height --) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
581 d1 = d;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
582 for(w = width; w > 0; w--) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
583 YUV_TO_RGB1(cb_ptr[0], cr_ptr[0]);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
584
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
585 YUV_TO_RGB2(r, g, b, y1_ptr[0]);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
586 RGB_OUT(d1, r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
587 d1 += BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
588
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
589 y1_ptr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
590 cb_ptr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
591 cr_ptr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
592 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
593 d += dst->linesize[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
594 y1_ptr += src->linesize[0] - width;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
595 cb_ptr += src->linesize[1] - width;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
596 cr_ptr += src->linesize[2] - width;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
597 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
598 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
599
1488
766a2f4edbea avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents: 1208
diff changeset
600 static void rgb24_to_yuv444p(AVPicture *dst, const AVPicture *src,
1204
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
601 int width, int height)
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
602 {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
603 int src_wrap, x, y;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
604 int r, g, b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
605 uint8_t *lum, *cb, *cr;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
606 const uint8_t *p;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
607
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
608 lum = dst->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
609 cb = dst->data[1];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
610 cr = dst->data[2];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
611
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
612 src_wrap = src->linesize[0] - width * BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
613 p = src->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
614 for(y=0;y<height;y++) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
615 for(x=0;x<width;x++) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
616 RGB_IN(r, g, b, p);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
617 lum[0] = RGB_TO_Y_CCIR(r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
618 cb[0] = RGB_TO_U_CCIR(r, g, b, 0);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
619 cr[0] = RGB_TO_V_CCIR(r, g, b, 0);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
620 p += BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
621 cb++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
622 cr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
623 lum++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
624 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
625 p += src_wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
626 lum += dst->linesize[0] - width;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
627 cb += dst->linesize[1] - width;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
628 cr += dst->linesize[2] - width;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
629 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
630 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
631
1488
766a2f4edbea avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents: 1208
diff changeset
632 static void rgb24_to_yuvj420p(AVPicture *dst, const AVPicture *src,
1204
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
633 int width, int height)
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
634 {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
635 int wrap, wrap3, width2;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
636 int r, g, b, r1, g1, b1, w;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
637 uint8_t *lum, *cb, *cr;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
638 const uint8_t *p;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
639
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
640 lum = dst->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
641 cb = dst->data[1];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
642 cr = dst->data[2];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
643
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
644 width2 = (width + 1) >> 1;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
645 wrap = dst->linesize[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
646 wrap3 = src->linesize[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
647 p = src->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
648 for(;height>=2;height -= 2) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
649 for(w = width; w >= 2; w -= 2) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
650 RGB_IN(r, g, b, p);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
651 r1 = r;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
652 g1 = g;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
653 b1 = b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
654 lum[0] = RGB_TO_Y(r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
655
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
656 RGB_IN(r, g, b, p + BPP);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
657 r1 += r;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
658 g1 += g;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
659 b1 += b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
660 lum[1] = RGB_TO_Y(r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
661 p += wrap3;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
662 lum += wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
663
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
664 RGB_IN(r, g, b, p);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
665 r1 += r;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
666 g1 += g;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
667 b1 += b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
668 lum[0] = RGB_TO_Y(r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
669
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
670 RGB_IN(r, g, b, p + BPP);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
671 r1 += r;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
672 g1 += g;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
673 b1 += b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
674 lum[1] = RGB_TO_Y(r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
675
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
676 cb[0] = RGB_TO_U(r1, g1, b1, 2);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
677 cr[0] = RGB_TO_V(r1, g1, b1, 2);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
678
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
679 cb++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
680 cr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
681 p += -wrap3 + 2 * BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
682 lum += -wrap + 2;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
683 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
684 if (w) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
685 RGB_IN(r, g, b, p);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
686 r1 = r;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
687 g1 = g;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
688 b1 = b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
689 lum[0] = RGB_TO_Y(r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
690 p += wrap3;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
691 lum += wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
692 RGB_IN(r, g, b, p);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
693 r1 += r;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
694 g1 += g;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
695 b1 += b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
696 lum[0] = RGB_TO_Y(r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
697 cb[0] = RGB_TO_U(r1, g1, b1, 1);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
698 cr[0] = RGB_TO_V(r1, g1, b1, 1);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
699 cb++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
700 cr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
701 p += -wrap3 + BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
702 lum += -wrap + 1;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
703 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
704 p += wrap3 + (wrap3 - width * BPP);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
705 lum += wrap + (wrap - width);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
706 cb += dst->linesize[1] - width2;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
707 cr += dst->linesize[2] - width2;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
708 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
709 /* handle odd height */
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
710 if (height) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
711 for(w = width; w >= 2; w -= 2) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
712 RGB_IN(r, g, b, p);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
713 r1 = r;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
714 g1 = g;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
715 b1 = b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
716 lum[0] = RGB_TO_Y(r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
717
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
718 RGB_IN(r, g, b, p + BPP);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
719 r1 += r;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
720 g1 += g;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
721 b1 += b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
722 lum[1] = RGB_TO_Y(r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
723 cb[0] = RGB_TO_U(r1, g1, b1, 1);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
724 cr[0] = RGB_TO_V(r1, g1, b1, 1);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
725 cb++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
726 cr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
727 p += 2 * BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
728 lum += 2;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
729 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
730 if (w) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
731 RGB_IN(r, g, b, p);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
732 lum[0] = RGB_TO_Y(r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
733 cb[0] = RGB_TO_U(r, g, b, 0);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
734 cr[0] = RGB_TO_V(r, g, b, 0);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
735 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
736 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
737 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
738
1488
766a2f4edbea avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents: 1208
diff changeset
739 static void rgb24_to_yuvj444p(AVPicture *dst, const AVPicture *src,
1204
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
740 int width, int height)
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
741 {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
742 int src_wrap, x, y;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
743 int r, g, b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
744 uint8_t *lum, *cb, *cr;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
745 const uint8_t *p;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
746
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
747 lum = dst->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
748 cb = dst->data[1];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
749 cr = dst->data[2];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
750
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
751 src_wrap = src->linesize[0] - width * BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
752 p = src->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
753 for(y=0;y<height;y++) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
754 for(x=0;x<width;x++) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
755 RGB_IN(r, g, b, p);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
756 lum[0] = RGB_TO_Y(r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
757 cb[0] = RGB_TO_U(r, g, b, 0);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
758 cr[0] = RGB_TO_V(r, g, b, 0);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
759 p += BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
760 cb++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
761 cr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
762 lum++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
763 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
764 p += src_wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
765 lum += dst->linesize[0] - width;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
766 cb += dst->linesize[1] - width;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
767 cr += dst->linesize[2] - width;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
768 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
769 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
770
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
771 #endif /* FMT_RGB24 */
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
772
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
773 #if defined(FMT_RGB24) || defined(FMT_RGBA32)
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
774
1488
766a2f4edbea avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents: 1208
diff changeset
775 static void glue(RGB_NAME, _to_pal8)(AVPicture *dst, const AVPicture *src,
1204
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
776 int width, int height)
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
777 {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
778 const unsigned char *p;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
779 unsigned char *q;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
780 int dst_wrap, src_wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
781 int x, y, has_alpha;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
782 unsigned int r, g, b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
783
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
784 p = src->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
785 src_wrap = src->linesize[0] - BPP * width;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
786
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
787 q = dst->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
788 dst_wrap = dst->linesize[0] - width;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
789 has_alpha = 0;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
790
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
791 for(y=0;y<height;y++) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
792 for(x=0;x<width;x++) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
793 #ifdef RGBA_IN
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
794 {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
795 unsigned int a;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
796 RGBA_IN(r, g, b, a, p);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
797 /* crude approximation for alpha ! */
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
798 if (a < 0x80) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
799 has_alpha = 1;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
800 q[0] = TRANSP_INDEX;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
801 } else {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
802 q[0] = gif_clut_index(r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
803 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
804 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
805 #else
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
806 RGB_IN(r, g, b, p);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
807 q[0] = gif_clut_index(r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
808 #endif
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
809 q++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
810 p += BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
811 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
812 p += src_wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
813 q += dst_wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
814 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
815
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
816 build_rgb_palette(dst->data[1], has_alpha);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
817 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
818
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
819 #endif /* defined(FMT_RGB24) || defined(FMT_RGBA32) */
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
820
1208
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
821 #ifdef RGBA_IN
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
822
1488
766a2f4edbea avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents: 1208
diff changeset
823 static int glue(get_alpha_info_, RGB_NAME)(const AVPicture *src,
766a2f4edbea avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents: 1208
diff changeset
824 int width, int height)
1208
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
825 {
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
826 const unsigned char *p;
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
827 int src_wrap, ret, x, y;
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
828 unsigned int r, g, b, a;
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
829
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
830 p = src->data[0];
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
831 src_wrap = src->linesize[0] - BPP * width;
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
832 ret = 0;
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
833 for(y=0;y<height;y++) {
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
834 for(x=0;x<width;x++) {
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
835 RGBA_IN(r, g, b, a, p);
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
836 if (a == 0x00) {
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
837 ret |= FF_ALPHA_TRANSP;
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
838 } else if (a != 0xff) {
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
839 ret |= FF_ALPHA_SEMI_TRANSP;
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
840 }
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
841 p += BPP;
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
842 }
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
843 p += src_wrap;
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
844 }
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
845 return ret;
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
846 }
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
847
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
848 #endif /* RGBA_IN */
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
849
1204
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
850 #undef RGB_IN
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
851 #undef RGBA_IN
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
852 #undef RGB_OUT
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
853 #undef RGBA_OUT
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
854 #undef BPP
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
855 #undef RGB_NAME
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
856 #undef FMT_RGB24
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
857 #undef FMT_RGBA32