annotate imgconvert_template.h @ 6515:f44ffc9a68c8 libavcodec

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