annotate imgconvert_template.h @ 4012:f8c649ac09dd libavcodec

add "memory" to the clobber list we change memory so we need it, this also fixes some problems with gcc svn
author michael
date Thu, 12 Oct 2006 21:32:56 +0000
parents c8c591fe26f8
children 23da44e8fd05
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1204
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
1 /*
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
2 * Templates for image convertion routines
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
3 * Copyright (c) 2001, 2002, 2003 Fabrice Bellard.
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
4 *
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;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
32 uint8_t *cm = cropTbl + MAX_NEG_CROP;
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;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
126 uint8_t *cm = cropTbl + MAX_NEG_CROP;
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
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
413 #if !defined(FMT_RGBA32) && defined(RGBA_OUT)
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
414 /* alpha support */
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
415
1488
766a2f4edbea avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents: 1208
diff changeset
416 static void glue(rgba32_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
1204
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
417 int width, int height)
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
418 {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
419 const uint8_t *s;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
420 uint8_t *d;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
421 int src_wrap, dst_wrap, j, y;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
422 unsigned int v, r, g, b, a;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
423
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
424 s = src->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
425 src_wrap = src->linesize[0] - width * 4;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
426
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
427 d = dst->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
428 dst_wrap = dst->linesize[0] - width * BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
429
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
430 for(y=0;y<height;y++) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
431 for(j = 0;j < width; j++) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
432 v = ((const uint32_t *)(s))[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
433 a = (v >> 24) & 0xff;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
434 r = (v >> 16) & 0xff;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
435 g = (v >> 8) & 0xff;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
436 b = v & 0xff;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
437 RGBA_OUT(d, r, g, b, a);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
438 s += 4;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
439 d += BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
440 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
441 s += src_wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
442 d += dst_wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
443 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
444 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
445
1488
766a2f4edbea avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents: 1208
diff changeset
446 static void glue(RGB_NAME, _to_rgba32)(AVPicture *dst, const AVPicture *src,
1204
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
447 int width, int height)
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
448 {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
449 const uint8_t *s;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
450 uint8_t *d;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
451 int src_wrap, dst_wrap, j, y;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
452 unsigned int r, g, b, a;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
453
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
454 s = src->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
455 src_wrap = src->linesize[0] - width * BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
456
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
457 d = dst->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
458 dst_wrap = dst->linesize[0] - width * 4;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
459
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
460 for(y=0;y<height;y++) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
461 for(j = 0;j < width; j++) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
462 RGBA_IN(r, g, b, a, s);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
463 ((uint32_t *)(d))[0] = (a << 24) | (r << 16) | (g << 8) | b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
464 d += 4;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
465 s += BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
466 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
467 s += src_wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
468 d += dst_wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
469 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
470 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
471
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
472 #endif /* !defined(FMT_RGBA32) && defined(RGBA_IN) */
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
473
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
474 #ifndef FMT_RGB24
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
475
1488
766a2f4edbea avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents: 1208
diff changeset
476 static void glue(rgb24_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
1204
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
477 int width, int height)
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
478 {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
479 const uint8_t *s;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
480 uint8_t *d;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
481 int src_wrap, dst_wrap, j, y;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
482 unsigned int r, g, b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
483
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
484 s = src->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
485 src_wrap = src->linesize[0] - width * 3;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
486
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
487 d = dst->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
488 dst_wrap = dst->linesize[0] - width * BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
489
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
490 for(y=0;y<height;y++) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
491 for(j = 0;j < width; j++) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
492 r = s[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
493 g = s[1];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
494 b = s[2];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
495 RGB_OUT(d, r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
496 s += 3;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
497 d += BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
498 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
499 s += src_wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
500 d += dst_wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
501 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
502 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
503
1488
766a2f4edbea avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents: 1208
diff changeset
504 static void glue(RGB_NAME, _to_rgb24)(AVPicture *dst, const AVPicture *src,
1204
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
505 int width, int height)
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
506 {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
507 const uint8_t *s;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
508 uint8_t *d;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
509 int src_wrap, dst_wrap, j, y;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
510 unsigned int r, g , b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
511
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
512 s = src->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
513 src_wrap = src->linesize[0] - width * BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
514
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
515 d = dst->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
516 dst_wrap = dst->linesize[0] - width * 3;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
517
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
518 for(y=0;y<height;y++) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
519 for(j = 0;j < width; j++) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
520 RGB_IN(r, g, b, s)
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
521 d[0] = r;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
522 d[1] = g;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
523 d[2] = b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
524 d += 3;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
525 s += BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
526 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
527 s += src_wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
528 d += dst_wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
529 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
530 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
531
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
532 #endif /* !FMT_RGB24 */
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
533
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
534 #ifdef FMT_RGB24
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
535
1488
766a2f4edbea avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents: 1208
diff changeset
536 static void yuv444p_to_rgb24(AVPicture *dst, const AVPicture *src,
1204
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
537 int width, int height)
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
538 {
1488
766a2f4edbea avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents: 1208
diff changeset
539 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
540 uint8_t *d, *d1;
1204
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
541 int w, y, cb, cr, r_add, g_add, b_add;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
542 uint8_t *cm = cropTbl + MAX_NEG_CROP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
543 unsigned int r, g, b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
544
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
545 d = dst->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
546 y1_ptr = src->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
547 cb_ptr = src->data[1];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
548 cr_ptr = src->data[2];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
549 for(;height > 0; height --) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
550 d1 = d;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
551 for(w = width; w > 0; w--) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
552 YUV_TO_RGB1_CCIR(cb_ptr[0], cr_ptr[0]);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
553
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
554 YUV_TO_RGB2_CCIR(r, g, b, y1_ptr[0]);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
555 RGB_OUT(d1, r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
556 d1 += BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
557
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
558 y1_ptr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
559 cb_ptr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
560 cr_ptr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
561 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
562 d += dst->linesize[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
563 y1_ptr += src->linesize[0] - width;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
564 cb_ptr += src->linesize[1] - width;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
565 cr_ptr += src->linesize[2] - width;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
566 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
567 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
568
1488
766a2f4edbea avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents: 1208
diff changeset
569 static void yuvj444p_to_rgb24(AVPicture *dst, const AVPicture *src,
1204
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
570 int width, int height)
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
571 {
1488
766a2f4edbea avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents: 1208
diff changeset
572 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
573 uint8_t *d, *d1;
1204
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
574 int w, y, cb, cr, r_add, g_add, b_add;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
575 uint8_t *cm = cropTbl + MAX_NEG_CROP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
576 unsigned int r, g, b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
577
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
578 d = dst->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
579 y1_ptr = src->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
580 cb_ptr = src->data[1];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
581 cr_ptr = src->data[2];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
582 for(;height > 0; height --) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
583 d1 = d;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
584 for(w = width; w > 0; w--) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
585 YUV_TO_RGB1(cb_ptr[0], cr_ptr[0]);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
586
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
587 YUV_TO_RGB2(r, g, b, y1_ptr[0]);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
588 RGB_OUT(d1, r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
589 d1 += BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
590
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
591 y1_ptr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
592 cb_ptr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
593 cr_ptr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
594 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
595 d += dst->linesize[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
596 y1_ptr += src->linesize[0] - width;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
597 cb_ptr += src->linesize[1] - width;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
598 cr_ptr += src->linesize[2] - width;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
599 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
600 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
601
1488
766a2f4edbea avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents: 1208
diff changeset
602 static void rgb24_to_yuv444p(AVPicture *dst, const AVPicture *src,
1204
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
603 int width, int height)
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
604 {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
605 int src_wrap, x, y;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
606 int r, g, b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
607 uint8_t *lum, *cb, *cr;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
608 const uint8_t *p;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
609
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
610 lum = dst->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
611 cb = dst->data[1];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
612 cr = dst->data[2];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
613
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
614 src_wrap = src->linesize[0] - width * BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
615 p = src->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
616 for(y=0;y<height;y++) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
617 for(x=0;x<width;x++) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
618 RGB_IN(r, g, b, p);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
619 lum[0] = RGB_TO_Y_CCIR(r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
620 cb[0] = RGB_TO_U_CCIR(r, g, b, 0);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
621 cr[0] = RGB_TO_V_CCIR(r, g, b, 0);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
622 p += BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
623 cb++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
624 cr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
625 lum++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
626 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
627 p += src_wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
628 lum += dst->linesize[0] - width;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
629 cb += dst->linesize[1] - width;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
630 cr += dst->linesize[2] - width;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
631 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
632 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
633
1488
766a2f4edbea avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents: 1208
diff changeset
634 static void rgb24_to_yuvj420p(AVPicture *dst, const AVPicture *src,
1204
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
635 int width, int height)
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
636 {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
637 int wrap, wrap3, width2;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
638 int r, g, b, r1, g1, b1, w;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
639 uint8_t *lum, *cb, *cr;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
640 const uint8_t *p;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
641
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
642 lum = dst->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
643 cb = dst->data[1];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
644 cr = dst->data[2];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
645
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
646 width2 = (width + 1) >> 1;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
647 wrap = dst->linesize[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
648 wrap3 = src->linesize[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
649 p = src->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
650 for(;height>=2;height -= 2) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
651 for(w = width; w >= 2; w -= 2) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
652 RGB_IN(r, g, b, p);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
653 r1 = r;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
654 g1 = g;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
655 b1 = b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
656 lum[0] = RGB_TO_Y(r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
657
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
658 RGB_IN(r, g, b, p + BPP);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
659 r1 += r;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
660 g1 += g;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
661 b1 += b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
662 lum[1] = RGB_TO_Y(r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
663 p += wrap3;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
664 lum += wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
665
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
666 RGB_IN(r, g, b, p);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
667 r1 += r;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
668 g1 += g;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
669 b1 += b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
670 lum[0] = RGB_TO_Y(r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
671
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
672 RGB_IN(r, g, b, p + BPP);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
673 r1 += r;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
674 g1 += g;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
675 b1 += b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
676 lum[1] = RGB_TO_Y(r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
677
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
678 cb[0] = RGB_TO_U(r1, g1, b1, 2);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
679 cr[0] = RGB_TO_V(r1, g1, b1, 2);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
680
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
681 cb++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
682 cr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
683 p += -wrap3 + 2 * BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
684 lum += -wrap + 2;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
685 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
686 if (w) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
687 RGB_IN(r, g, b, p);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
688 r1 = r;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
689 g1 = g;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
690 b1 = b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
691 lum[0] = RGB_TO_Y(r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
692 p += wrap3;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
693 lum += wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
694 RGB_IN(r, g, b, p);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
695 r1 += r;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
696 g1 += g;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
697 b1 += b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
698 lum[0] = RGB_TO_Y(r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
699 cb[0] = RGB_TO_U(r1, g1, b1, 1);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
700 cr[0] = RGB_TO_V(r1, g1, b1, 1);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
701 cb++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
702 cr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
703 p += -wrap3 + BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
704 lum += -wrap + 1;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
705 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
706 p += wrap3 + (wrap3 - width * BPP);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
707 lum += wrap + (wrap - width);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
708 cb += dst->linesize[1] - width2;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
709 cr += dst->linesize[2] - width2;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
710 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
711 /* handle odd height */
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
712 if (height) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
713 for(w = width; w >= 2; w -= 2) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
714 RGB_IN(r, g, b, p);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
715 r1 = r;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
716 g1 = g;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
717 b1 = b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
718 lum[0] = RGB_TO_Y(r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
719
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
720 RGB_IN(r, g, b, p + BPP);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
721 r1 += r;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
722 g1 += g;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
723 b1 += b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
724 lum[1] = RGB_TO_Y(r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
725 cb[0] = RGB_TO_U(r1, g1, b1, 1);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
726 cr[0] = RGB_TO_V(r1, g1, b1, 1);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
727 cb++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
728 cr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
729 p += 2 * BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
730 lum += 2;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
731 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
732 if (w) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
733 RGB_IN(r, g, b, p);
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 cb[0] = RGB_TO_U(r, g, b, 0);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
736 cr[0] = RGB_TO_V(r, g, b, 0);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
737 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
738 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
739 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
740
1488
766a2f4edbea avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents: 1208
diff changeset
741 static void rgb24_to_yuvj444p(AVPicture *dst, const AVPicture *src,
1204
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
742 int width, int height)
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
743 {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
744 int src_wrap, x, y;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
745 int r, g, b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
746 uint8_t *lum, *cb, *cr;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
747 const uint8_t *p;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
748
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
749 lum = dst->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
750 cb = dst->data[1];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
751 cr = dst->data[2];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
752
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
753 src_wrap = src->linesize[0] - width * BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
754 p = src->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
755 for(y=0;y<height;y++) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
756 for(x=0;x<width;x++) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
757 RGB_IN(r, g, b, p);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
758 lum[0] = RGB_TO_Y(r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
759 cb[0] = RGB_TO_U(r, g, b, 0);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
760 cr[0] = RGB_TO_V(r, g, b, 0);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
761 p += BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
762 cb++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
763 cr++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
764 lum++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
765 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
766 p += src_wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
767 lum += dst->linesize[0] - width;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
768 cb += dst->linesize[1] - width;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
769 cr += dst->linesize[2] - width;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
770 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
771 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
772
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
773 #endif /* FMT_RGB24 */
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
774
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
775 #if defined(FMT_RGB24) || defined(FMT_RGBA32)
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
776
1488
766a2f4edbea avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents: 1208
diff changeset
777 static void glue(RGB_NAME, _to_pal8)(AVPicture *dst, const AVPicture *src,
1204
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
778 int width, int height)
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
779 {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
780 const unsigned char *p;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
781 unsigned char *q;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
782 int dst_wrap, src_wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
783 int x, y, has_alpha;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
784 unsigned int r, g, b;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
785
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
786 p = src->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
787 src_wrap = src->linesize[0] - BPP * width;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
788
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
789 q = dst->data[0];
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
790 dst_wrap = dst->linesize[0] - width;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
791 has_alpha = 0;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 1488
diff changeset
792
1204
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
793 for(y=0;y<height;y++) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
794 for(x=0;x<width;x++) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
795 #ifdef RGBA_IN
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
796 {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
797 unsigned int a;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
798 RGBA_IN(r, g, b, a, p);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
799 /* crude approximation for alpha ! */
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
800 if (a < 0x80) {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
801 has_alpha = 1;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
802 q[0] = TRANSP_INDEX;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
803 } else {
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
804 q[0] = gif_clut_index(r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
805 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
806 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
807 #else
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
808 RGB_IN(r, g, b, p);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
809 q[0] = gif_clut_index(r, g, b);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
810 #endif
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
811 q++;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
812 p += BPP;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
813 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
814 p += src_wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
815 q += dst_wrap;
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
816 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
817
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
818 build_rgb_palette(dst->data[1], has_alpha);
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
819 }
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
820
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
821 #endif /* defined(FMT_RGB24) || defined(FMT_RGBA32) */
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 1488
diff changeset
822
1208
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
823 #ifdef RGBA_IN
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
824
1488
766a2f4edbea avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents: 1208
diff changeset
825 static int glue(get_alpha_info_, RGB_NAME)(const AVPicture *src,
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
826 int width, int height)
1208
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
827 {
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
828 const unsigned char *p;
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
829 int src_wrap, ret, x, y;
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
830 unsigned int r, g, b, a;
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
831
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
832 p = src->data[0];
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
833 src_wrap = src->linesize[0] - BPP * width;
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
834 ret = 0;
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
835 for(y=0;y<height;y++) {
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
836 for(x=0;x<width;x++) {
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
837 RGBA_IN(r, g, b, a, p);
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
838 if (a == 0x00) {
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
839 ret |= FF_ALPHA_TRANSP;
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
840 } else if (a != 0xff) {
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
841 ret |= FF_ALPHA_SEMI_TRANSP;
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
842 }
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
843 p += BPP;
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
844 }
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
845 p += src_wrap;
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
846 }
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
847 return ret;
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
848 }
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
849
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
850 #endif /* RGBA_IN */
0f37976aa436 added img_get_alpha_info()
bellard
parents: 1204
diff changeset
851
1204
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
852 #undef RGB_IN
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
853 #undef RGBA_IN
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
854 #undef RGB_OUT
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
855 #undef RGBA_OUT
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
856 #undef BPP
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
857 #undef RGB_NAME
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
858 #undef FMT_RGB24
e55580ae9969 almost exhaustive image conversion support
bellard
parents:
diff changeset
859 #undef FMT_RGBA32