annotate imgconvert_template.c @ 8882:55edd698a8f3 libavcodec

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