Mercurial > libavcodec.hg
annotate imgconvert.c @ 922:5fa4d5007dfd libavcodec
remove fake wmv2 codec
author | michaelni |
---|---|
date | Sun, 08 Dec 2002 21:29:37 +0000 |
parents | 48215b2c3888 |
children | ef769ec24115 |
rev | line source |
---|---|
0 | 1 /* |
2 * Misc image convertion routines | |
429 | 3 * Copyright (c) 2001, 2002 Fabrice Bellard. |
0 | 4 * |
429 | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Lesser General Public | |
7 * License as published by the Free Software Foundation; either | |
8 * version 2 of the License, or (at your option) any later version. | |
0 | 9 * |
429 | 10 * This library is distributed in the hope that it will be useful, |
0 | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
429 | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 * Lesser General Public License for more details. | |
0 | 14 * |
429 | 15 * You should have received a copy of the GNU Lesser General Public |
16 * License along with this library; if not, write to the Free Software | |
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
0 | 18 */ |
19 #include "avcodec.h" | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
20 #include "dsputil.h" |
0 | 21 |
17 | 22 #ifdef USE_FASTMEMCPY |
23 #include "fastmemcpy.h" | |
24 #endif | |
801 | 25 |
26 #ifdef HAVE_MMX | |
27 #include "i386/mmx.h" | |
28 #endif | |
0 | 29 /* XXX: totally non optimized */ |
30 | |
31 static void yuv422_to_yuv420p(UINT8 *lum, UINT8 *cb, UINT8 *cr, | |
32 UINT8 *src, int width, int height) | |
33 { | |
34 int x, y; | |
35 UINT8 *p = src; | |
36 | |
37 for(y=0;y<height;y+=2) { | |
38 for(x=0;x<width;x+=2) { | |
39 lum[0] = p[0]; | |
40 cb[0] = p[1]; | |
41 lum[1] = p[2]; | |
42 cr[0] = p[3]; | |
43 p += 4; | |
44 lum += 2; | |
45 cb++; | |
46 cr++; | |
47 } | |
48 for(x=0;x<width;x+=2) { | |
49 lum[0] = p[0]; | |
50 lum[1] = p[2]; | |
51 p += 4; | |
52 lum += 2; | |
53 } | |
54 } | |
55 } | |
56 | |
57 #define SCALEBITS 8 | |
58 #define ONE_HALF (1 << (SCALEBITS - 1)) | |
59 #define FIX(x) ((int) ((x) * (1L<<SCALEBITS) + 0.5)) | |
60 | |
61 static void rgb24_to_yuv420p(UINT8 *lum, UINT8 *cb, UINT8 *cr, | |
62 UINT8 *src, int width, int height) | |
63 { | |
64 int wrap, wrap3, x, y; | |
65 int r, g, b, r1, g1, b1; | |
66 UINT8 *p; | |
67 | |
68 wrap = width; | |
69 wrap3 = width * 3; | |
70 p = src; | |
71 for(y=0;y<height;y+=2) { | |
72 for(x=0;x<width;x+=2) { | |
73 r = p[0]; | |
74 g = p[1]; | |
75 b = p[2]; | |
76 r1 = r; | |
77 g1 = g; | |
78 b1 = b; | |
79 lum[0] = (FIX(0.29900) * r + FIX(0.58700) * g + | |
80 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |
81 r = p[3]; | |
82 g = p[4]; | |
83 b = p[5]; | |
84 r1 += r; | |
85 g1 += g; | |
86 b1 += b; | |
87 lum[1] = (FIX(0.29900) * r + FIX(0.58700) * g + | |
88 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |
89 p += wrap3; | |
90 lum += wrap; | |
91 | |
92 r = p[0]; | |
93 g = p[1]; | |
94 b = p[2]; | |
95 r1 += r; | |
96 g1 += g; | |
97 b1 += b; | |
98 lum[0] = (FIX(0.29900) * r + FIX(0.58700) * g + | |
99 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |
100 r = p[3]; | |
101 g = p[4]; | |
102 b = p[5]; | |
103 r1 += r; | |
104 g1 += g; | |
105 b1 += b; | |
106 lum[1] = (FIX(0.29900) * r + FIX(0.58700) * g + | |
107 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |
108 | |
109 cb[0] = ((- FIX(0.16874) * r1 - FIX(0.33126) * g1 + | |
110 FIX(0.50000) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) + 128; | |
111 cr[0] = ((FIX(0.50000) * r1 - FIX(0.41869) * g1 - | |
112 FIX(0.08131) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) + 128; | |
113 | |
114 cb++; | |
115 cr++; | |
116 p += -wrap3 + 2 * 3; | |
117 lum += -wrap + 2; | |
118 } | |
119 p += wrap3; | |
120 lum += wrap; | |
121 } | |
122 } | |
123 | |
583 | 124 static void rgba32_to_yuv420p(UINT8 *lum, UINT8 *cb, UINT8 *cr, |
125 UINT8 *src, int width, int height) | |
126 { | |
127 int wrap, wrap4, x, y; | |
128 int r, g, b, r1, g1, b1; | |
129 UINT8 *p; | |
130 | |
131 wrap = width; | |
132 wrap4 = width * 4; | |
133 p = src; | |
134 for(y=0;y<height;y+=2) { | |
135 for(x=0;x<width;x+=2) { | |
136 r = p[0]; | |
137 g = p[1]; | |
138 b = p[2]; | |
139 r1 = r; | |
140 g1 = g; | |
141 b1 = b; | |
142 lum[0] = (FIX(0.29900) * r + FIX(0.58700) * g + | |
143 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |
144 r = p[4]; | |
145 g = p[5]; | |
146 b = p[6]; | |
147 r1 += r; | |
148 g1 += g; | |
149 b1 += b; | |
150 lum[1] = (FIX(0.29900) * r + FIX(0.58700) * g + | |
151 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |
152 p += wrap4; | |
153 lum += wrap; | |
154 | |
155 r = p[0]; | |
156 g = p[1]; | |
157 b = p[2]; | |
158 r1 += r; | |
159 g1 += g; | |
160 b1 += b; | |
161 lum[0] = (FIX(0.29900) * r + FIX(0.58700) * g + | |
162 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |
163 r = p[4]; | |
164 g = p[5]; | |
165 b = p[6]; | |
166 r1 += r; | |
167 g1 += g; | |
168 b1 += b; | |
169 lum[1] = (FIX(0.29900) * r + FIX(0.58700) * g + | |
170 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |
171 | |
172 cb[0] = ((- FIX(0.16874) * r1 - FIX(0.33126) * g1 + | |
173 FIX(0.50000) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) + 128; | |
174 cr[0] = ((FIX(0.50000) * r1 - FIX(0.41869) * g1 - | |
175 FIX(0.08131) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) + 128; | |
176 | |
177 cb++; | |
178 cr++; | |
179 p += -wrap4 + 2 * 4; | |
180 lum += -wrap + 2; | |
181 } | |
182 p += wrap4; | |
183 lum += wrap; | |
184 } | |
185 } | |
186 | |
867
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
187 #define rgb565_to_yuv420p(lum,cb,cr,src,width,height) rgbmisc_to_yuv420p((lum),(cb),(cr),(src),(width),(height),0x0800,31, 0x0020,63,0x0001,31) |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
188 #define rgb555_to_yuv420p(lum,cb,cr,src,width,height) rgbmisc_to_yuv420p((lum),(cb),(cr),(src),(width),(height),0x0400,31, 0x0020,31,0x0001,31) |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
189 #define rgb5551_to_yuv420p(lum,cb,cr,src,width,height) rgbmisc_to_yuv420p((lum),(cb),(cr),(src),(width),(height),0x0800,31, 0x0040,31,0x0002,31) |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
190 #define bgr565_to_yuv420p(lum,cb,cr,src,width,height) rgbmisc_to_yuv420p((lum),(cb),(cr),(src),(width),(height),0x0001,31, 0x0020,63,0x0800,31) |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
191 #define bgr555_to_yuv420p(lum,cb,cr,src,width,height) rgbmisc_to_yuv420p((lum),(cb),(cr),(src),(width),(height),0x0001,31, 0x0020,31,0x0400,31) |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
192 #define gbr565_to_yuv420p(lum,cb,cr,src,width,height) rgbmisc_to_yuv420p((lum),(cb),(cr),(src),(width),(height),0x0001,31, 0x0800,31,0x0040,63) |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
193 #define gbr555_to_yuv420p(lum,cb,cr,src,width,height) rgbmisc_to_yuv420p((lum),(cb),(cr),(src),(width),(height),0x0001,31, 0x0400,31,0x0020,31) |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
194 |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
195 static void rgbmisc_to_yuv420p |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
196 (UINT8 *lum, UINT8 *cb, UINT8 *cr, |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
197 UINT8 *src, int width, int height, |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
198 |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
199 UINT16 R_LOWMASK, UINT16 R_MAX, |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
200 UINT16 G_LOWMASK, UINT16 G_MAX, |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
201 UINT16 B_LOWMASK, UINT16 B_MAX |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
202 ) |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
203 { |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
204 int wrap, wrap2, x, y; |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
205 int r, g, b, r1, g1, b1; |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
206 UINT8 *p; |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
207 UINT16 pixel; |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
208 |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
209 wrap = width; |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
210 wrap2 = width * 2; |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
211 p = src; |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
212 for(y=0;y<height;y+=2) { |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
213 for(x=0;x<width;x+=2) { |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
214 pixel = p[0] | (p[1]<<8); |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
215 r = (((pixel/R_LOWMASK) & R_MAX) * (0x100 / (R_MAX+1))); |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
216 g = (((pixel/G_LOWMASK) & G_MAX) * (0x100 / (G_MAX+1))); |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
217 b = (((pixel/B_LOWMASK) & B_MAX) * (0x100 / (B_MAX+1))); |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
218 r1 = r; |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
219 g1 = g; |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
220 b1 = b; |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
221 lum[0] = (FIX(0.29900) * r + FIX(0.58700) * g + |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
222 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
223 |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
224 pixel = p[2] | (p[3]<<8); |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
225 r = (((pixel/R_LOWMASK) & R_MAX) * (0x100 / (R_MAX+1))); |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
226 g = (((pixel/G_LOWMASK) & G_MAX) * (0x100 / (G_MAX+1))); |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
227 b = (((pixel/B_LOWMASK) & B_MAX) * (0x100 / (B_MAX+1))); |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
228 r1 += r; |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
229 g1 += g; |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
230 b1 += b; |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
231 lum[1] = (FIX(0.29900) * r + FIX(0.58700) * g + |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
232 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
233 p += wrap2; |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
234 lum += wrap; |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
235 |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
236 pixel = p[0] | (p[1]<<8); |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
237 r = (((pixel/R_LOWMASK) & R_MAX) * (0x100 / (R_MAX+1))); |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
238 g = (((pixel/G_LOWMASK) & G_MAX) * (0x100 / (G_MAX+1))); |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
239 b = (((pixel/B_LOWMASK) & B_MAX) * (0x100 / (B_MAX+1))); |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
240 r1 += r; |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
241 g1 += g; |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
242 b1 += b; |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
243 lum[0] = (FIX(0.29900) * r + FIX(0.58700) * g + |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
244 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
245 pixel = p[2] | (p[3]<<8); |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
246 r = (((pixel/R_LOWMASK) & R_MAX) * (0x100 / (R_MAX+1))); |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
247 g = (((pixel/G_LOWMASK) & G_MAX) * (0x100 / (G_MAX+1))); |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
248 b = (((pixel/B_LOWMASK) & B_MAX) * (0x100 / (B_MAX+1))); |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
249 r1 += r; |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
250 g1 += g; |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
251 b1 += b; |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
252 lum[1] = (FIX(0.29900) * r + FIX(0.58700) * g + |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
253 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
254 |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
255 cb[0] = ((- FIX(0.16874) * r1 - FIX(0.33126) * g1 + |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
256 FIX(0.50000) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) + 128; |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
257 cr[0] = ((FIX(0.50000) * r1 - FIX(0.41869) * g1 - |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
258 FIX(0.08131) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) + 128; |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
259 |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
260 cb++; |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
261 cr++; |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
262 p += -wrap2 + 2 * 2; |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
263 lum += -wrap + 2; |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
264 } |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
265 p += wrap2; |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
266 lum += wrap; |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
267 } |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
268 } |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
269 |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
270 |
0 | 271 static void bgr24_to_yuv420p(UINT8 *lum, UINT8 *cb, UINT8 *cr, |
272 UINT8 *src, int width, int height) | |
273 { | |
274 int wrap, wrap3, x, y; | |
275 int r, g, b, r1, g1, b1; | |
276 UINT8 *p; | |
277 | |
278 wrap = width; | |
279 wrap3 = width * 3; | |
280 p = src; | |
281 for(y=0;y<height;y+=2) { | |
282 for(x=0;x<width;x+=2) { | |
283 b = p[0]; | |
284 g = p[1]; | |
285 r = p[2]; | |
286 r1 = r; | |
287 g1 = g; | |
288 b1 = b; | |
289 lum[0] = (FIX(0.29900) * r + FIX(0.58700) * g + | |
290 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |
291 b = p[3]; | |
292 g = p[4]; | |
293 r = p[5]; | |
294 r1 += r; | |
295 g1 += g; | |
296 b1 += b; | |
297 lum[1] = (FIX(0.29900) * r + FIX(0.58700) * g + | |
298 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |
299 p += wrap3; | |
300 lum += wrap; | |
301 | |
302 b = p[0]; | |
303 g = p[1]; | |
304 r = p[2]; | |
305 r1 += r; | |
306 g1 += g; | |
307 b1 += b; | |
308 lum[0] = (FIX(0.29900) * r + FIX(0.58700) * g + | |
309 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |
310 b = p[3]; | |
311 g = p[4]; | |
312 r = p[5]; | |
313 r1 += r; | |
314 g1 += g; | |
315 b1 += b; | |
316 lum[1] = (FIX(0.29900) * r + FIX(0.58700) * g + | |
317 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |
318 | |
319 cb[0] = ((- FIX(0.16874) * r1 - FIX(0.33126) * g1 + | |
320 FIX(0.50000) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) + 128; | |
321 cr[0] = ((FIX(0.50000) * r1 - FIX(0.41869) * g1 - | |
322 FIX(0.08131) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) + 128; | |
323 | |
324 cb++; | |
325 cr++; | |
326 p += -wrap3 + 2 * 3; | |
327 lum += -wrap + 2; | |
328 } | |
329 p += wrap3; | |
330 lum += wrap; | |
331 } | |
332 } | |
333 | |
583 | 334 static void bgra32_to_yuv420p(UINT8 *lum, UINT8 *cb, UINT8 *cr, |
335 UINT8 *src, int width, int height) | |
336 { | |
337 int wrap, wrap4, x, y; | |
338 int r, g, b, r1, g1, b1; | |
339 UINT8 *p; | |
340 | |
341 wrap = width; | |
342 wrap4 = width * 4; | |
343 p = src; | |
344 for(y=0;y<height;y+=2) { | |
345 for(x=0;x<width;x+=2) { | |
346 b = p[0]; | |
347 g = p[1]; | |
348 r = p[2]; | |
349 r1 = r; | |
350 g1 = g; | |
351 b1 = b; | |
352 lum[0] = (FIX(0.29900) * r + FIX(0.58700) * g + | |
353 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |
354 b = p[4]; | |
355 g = p[5]; | |
356 r = p[6]; | |
357 r1 += r; | |
358 g1 += g; | |
359 b1 += b; | |
360 lum[1] = (FIX(0.29900) * r + FIX(0.58700) * g + | |
361 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |
362 p += wrap4; | |
363 lum += wrap; | |
364 | |
365 b = p[0]; | |
366 g = p[1]; | |
367 r = p[2]; | |
368 r1 += r; | |
369 g1 += g; | |
370 b1 += b; | |
371 lum[0] = (FIX(0.29900) * r + FIX(0.58700) * g + | |
372 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |
373 b = p[4]; | |
374 g = p[5]; | |
375 r = p[6]; | |
376 r1 += r; | |
377 g1 += g; | |
378 b1 += b; | |
379 lum[1] = (FIX(0.29900) * r + FIX(0.58700) * g + | |
380 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |
381 | |
382 cb[0] = ((- FIX(0.16874) * r1 - FIX(0.33126) * g1 + | |
383 FIX(0.50000) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) + 128; | |
384 cr[0] = ((FIX(0.50000) * r1 - FIX(0.41869) * g1 - | |
385 FIX(0.08131) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) + 128; | |
386 | |
387 cb++; | |
388 cr++; | |
389 p += -wrap4 + 2 * 4; | |
390 lum += -wrap + 2; | |
391 } | |
392 p += wrap4; | |
393 lum += wrap; | |
394 } | |
395 } | |
396 | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
397 /* XXX: use generic filter ? */ |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
398 /* 1x2 -> 1x1 */ |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
399 static void shrink2(UINT8 *dst, int dst_wrap, |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
400 UINT8 *src, int src_wrap, |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
401 int width, int height) |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
402 { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
403 int w; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
404 UINT8 *s1, *s2, *d; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
405 |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
406 for(;height > 0; height--) { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
407 s1 = src; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
408 s2 = s1 + src_wrap; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
409 d = dst; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
410 for(w = width;w >= 4; w-=4) { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
411 d[0] = (s1[0] + s2[0]) >> 1; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
412 d[1] = (s1[1] + s2[1]) >> 1; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
413 d[2] = (s1[2] + s2[2]) >> 1; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
414 d[3] = (s1[3] + s2[3]) >> 1; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
415 s1 += 4; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
416 s2 += 4; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
417 d += 4; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
418 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
419 for(;w > 0; w--) { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
420 d[0] = (s1[0] + s2[0]) >> 1; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
421 s1++; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
422 s2++; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
423 d++; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
424 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
425 src += 2 * src_wrap; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
426 dst += dst_wrap; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
427 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
428 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
429 |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
430 /* 2x2 -> 1x1 */ |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
431 static void shrink22(UINT8 *dst, int dst_wrap, |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
432 UINT8 *src, int src_wrap, |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
433 int width, int height) |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
434 { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
435 int w; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
436 UINT8 *s1, *s2, *d; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
437 |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
438 for(;height > 0; height--) { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
439 s1 = src; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
440 s2 = s1 + src_wrap; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
441 d = dst; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
442 for(w = width;w >= 4; w-=4) { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
443 d[0] = (s1[0] + s1[1] + s2[0] + s2[1] + 2) >> 1; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
444 d[1] = (s1[2] + s1[3] + s2[2] + s2[3] + 2) >> 1; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
445 d[2] = (s1[4] + s1[5] + s2[4] + s2[5] + 2) >> 1; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
446 d[3] = (s1[6] + s1[7] + s2[6] + s2[7] + 2) >> 1; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
447 s1 += 8; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
448 s2 += 8; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
449 d += 4; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
450 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
451 for(;w > 0; w--) { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
452 d[0] = (s1[0] + s1[1] + s2[0] + s2[1] + 2) >> 1; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
453 s1 += 2; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
454 s2 += 2; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
455 d++; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
456 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
457 src += 2 * src_wrap; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
458 dst += dst_wrap; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
459 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
460 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
461 |
576
9aa5f0d0124e
YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
462 /* 1x1 -> 2x2 */ |
9aa5f0d0124e
YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
463 static void grow22(UINT8 *dst, int dst_wrap, |
9aa5f0d0124e
YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
464 UINT8 *src, int src_wrap, |
9aa5f0d0124e
YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
465 int width, int height) |
9aa5f0d0124e
YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
466 { |
9aa5f0d0124e
YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
467 int w; |
9aa5f0d0124e
YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
468 UINT8 *s1, *d; |
9aa5f0d0124e
YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
469 |
9aa5f0d0124e
YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
470 for(;height > 0; height--) { |
9aa5f0d0124e
YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
471 s1 = src; |
9aa5f0d0124e
YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
472 d = dst; |
9aa5f0d0124e
YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
473 for(w = width;w >= 4; w-=4) { |
9aa5f0d0124e
YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
474 d[1] = d[0] = s1[0]; |
9aa5f0d0124e
YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
475 d[3] = d[2] = s1[1]; |
9aa5f0d0124e
YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
476 s1 += 2; |
9aa5f0d0124e
YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
477 d += 4; |
9aa5f0d0124e
YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
478 } |
9aa5f0d0124e
YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
479 for(;w > 0; w--) { |
9aa5f0d0124e
YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
480 d[0] = s1[0]; |
9aa5f0d0124e
YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
481 s1 ++; |
9aa5f0d0124e
YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
482 d++; |
9aa5f0d0124e
YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
483 } |
9aa5f0d0124e
YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
484 if (height%2) |
9aa5f0d0124e
YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
485 src += src_wrap; |
9aa5f0d0124e
YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
486 dst += dst_wrap; |
9aa5f0d0124e
YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
487 } |
9aa5f0d0124e
YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
488 } |
9aa5f0d0124e
YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
489 |
736
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
490 /* 1x2 -> 2x1. width and height are given for the source picture */ |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
491 static void conv411(UINT8 *dst, int dst_wrap, |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
492 UINT8 *src, int src_wrap, |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
493 int width, int height) |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
494 { |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
495 int w, c; |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
496 UINT8 *s1, *s2, *d; |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
497 |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
498 for(;height > 0; height -= 2) { |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
499 s1 = src; |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
500 s2 = src + src_wrap; |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
501 d = dst; |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
502 for(w = width;w > 0; w--) { |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
503 c = (s1[0] + s2[0]) >> 1; |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
504 d[0] = c; |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
505 d[1] = c; |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
506 s1++; |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
507 s2++; |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
508 d += 2; |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
509 } |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
510 src += src_wrap * 2; |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
511 dst += dst_wrap; |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
512 } |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
513 } |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
514 |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
515 static void img_copy(UINT8 *dst, int dst_wrap, |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
516 UINT8 *src, int src_wrap, |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
517 int width, int height) |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
518 { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
519 for(;height > 0; height--) { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
520 memcpy(dst, src, width); |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
521 dst += dst_wrap; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
522 src += src_wrap; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
523 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
524 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
525 |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
526 #define SCALE_BITS 10 |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
527 |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
528 #define C_Y (76309 >> (16 - SCALE_BITS)) |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
529 #define C_RV (117504 >> (16 - SCALE_BITS)) |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
530 #define C_BU (138453 >> (16 - SCALE_BITS)) |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
531 #define C_GU (13954 >> (16 - SCALE_BITS)) |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
532 #define C_GV (34903 >> (16 - SCALE_BITS)) |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
533 |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
534 #define RGBOUT(r, g, b, y1)\ |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
535 {\ |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
536 y = (y1 - 16) * C_Y;\ |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
537 r = cm[(y + r_add) >> SCALE_BITS];\ |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
538 g = cm[(y + g_add) >> SCALE_BITS];\ |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
539 b = cm[(y + b_add) >> SCALE_BITS];\ |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
540 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
541 |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
542 /* XXX: no chroma interpolating is done */ |
583 | 543 static void yuv420p_to_bgra32(AVPicture *dst, AVPicture *src, |
544 int width, int height) | |
545 { | |
546 UINT8 *y1_ptr, *y2_ptr, *cb_ptr, *cr_ptr, *d, *d1, *d2; | |
547 int w, y, cb, cr, r_add, g_add, b_add, width2; | |
548 UINT8 *cm = cropTbl + MAX_NEG_CROP; | |
549 | |
550 d = dst->data[0]; | |
551 y1_ptr = src->data[0]; | |
552 cb_ptr = src->data[1]; | |
553 cr_ptr = src->data[2]; | |
554 width2 = width >> 1; | |
555 for(;height > 0; height -= 2) { | |
556 d1 = d; | |
557 d2 = d + dst->linesize[0]; | |
558 y2_ptr = y1_ptr + src->linesize[0]; | |
559 for(w = width2; w > 0; w --) { | |
560 cb = cb_ptr[0] - 128; | |
561 cr = cr_ptr[0] - 128; | |
562 r_add = C_RV * cr + (1 << (SCALE_BITS - 1)); | |
563 g_add = - C_GU * cb - C_GV * cr + (1 << (SCALE_BITS - 1)); | |
564 b_add = C_BU * cb + (1 << (SCALE_BITS - 1)); | |
565 | |
566 /* output 4 pixels */ | |
567 RGBOUT(d1[2], d1[1], d1[0], y1_ptr[0]); | |
568 RGBOUT(d1[6], d1[5], d1[4], y1_ptr[1]); | |
569 RGBOUT(d2[2], d2[1], d2[0], y2_ptr[0]); | |
570 RGBOUT(d2[6], d2[5], d2[4], y2_ptr[1]); | |
571 | |
572 d1[3] = d1[7] = d2[3] = d2[7] = 255; | |
573 | |
574 d1 += 8; | |
575 d2 += 8; | |
576 y1_ptr += 2; | |
577 y2_ptr += 2; | |
578 cb_ptr++; | |
579 cr_ptr++; | |
580 } | |
581 d += 2 * dst->linesize[0]; | |
582 y1_ptr += 2 * src->linesize[0] - width; | |
583 cb_ptr += src->linesize[1] - width2; | |
584 cr_ptr += src->linesize[2] - width2; | |
585 } | |
586 } | |
587 | |
588 /* XXX: no chroma interpolating is done */ | |
589 static void yuv420p_to_rgba32(AVPicture *dst, AVPicture *src, | |
590 int width, int height) | |
591 { | |
592 UINT8 *y1_ptr, *y2_ptr, *cb_ptr, *cr_ptr, *d, *d1, *d2; | |
593 int w, y, cb, cr, r_add, g_add, b_add, width2; | |
594 UINT8 *cm = cropTbl + MAX_NEG_CROP; | |
595 | |
596 d = dst->data[0]; | |
597 y1_ptr = src->data[0]; | |
598 cb_ptr = src->data[1]; | |
599 cr_ptr = src->data[2]; | |
600 width2 = width >> 1; | |
601 for(;height > 0; height -= 2) { | |
602 d1 = d; | |
603 d2 = d + dst->linesize[0]; | |
604 y2_ptr = y1_ptr + src->linesize[0]; | |
605 for(w = width2; w > 0; w --) { | |
606 cb = cb_ptr[0] - 128; | |
607 cr = cr_ptr[0] - 128; | |
608 r_add = C_RV * cr + (1 << (SCALE_BITS - 1)); | |
609 g_add = - C_GU * cb - C_GV * cr + (1 << (SCALE_BITS - 1)); | |
610 b_add = C_BU * cb + (1 << (SCALE_BITS - 1)); | |
611 | |
612 /* output 4 pixels */ | |
613 RGBOUT(d1[0], d1[1], d1[2], y1_ptr[0]); | |
614 RGBOUT(d1[4], d1[5], d1[6], y1_ptr[1]); | |
615 RGBOUT(d2[0], d2[1], d2[2], y2_ptr[0]); | |
616 RGBOUT(d2[4], d2[5], d2[6], y2_ptr[1]); | |
617 | |
618 d1[3] = d1[7] = d2[3] = d2[7] = 255; | |
619 | |
620 d1 += 8; | |
621 d2 += 8; | |
622 y1_ptr += 2; | |
623 y2_ptr += 2; | |
624 cb_ptr++; | |
625 cr_ptr++; | |
626 } | |
627 d += 2 * dst->linesize[0]; | |
628 y1_ptr += 2 * src->linesize[0] - width; | |
629 cb_ptr += src->linesize[1] - width2; | |
630 cr_ptr += src->linesize[2] - width2; | |
631 } | |
632 } | |
633 | |
634 /* XXX: no chroma interpolating is done */ | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
635 static void yuv420p_to_rgb24(AVPicture *dst, AVPicture *src, |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
636 int width, int height) |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
637 { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
638 UINT8 *y1_ptr, *y2_ptr, *cb_ptr, *cr_ptr, *d, *d1, *d2; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
639 int w, y, cb, cr, r_add, g_add, b_add, width2; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
640 UINT8 *cm = cropTbl + MAX_NEG_CROP; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
641 |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
642 d = dst->data[0]; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
643 y1_ptr = src->data[0]; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
644 cb_ptr = src->data[1]; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
645 cr_ptr = src->data[2]; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
646 width2 = width >> 1; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
647 for(;height > 0; height -= 2) { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
648 d1 = d; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
649 d2 = d + dst->linesize[0]; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
650 y2_ptr = y1_ptr + src->linesize[0]; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
651 for(w = width2; w > 0; w --) { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
652 cb = cb_ptr[0] - 128; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
653 cr = cr_ptr[0] - 128; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
654 r_add = C_RV * cr + (1 << (SCALE_BITS - 1)); |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
655 g_add = - C_GU * cb - C_GV * cr + (1 << (SCALE_BITS - 1)); |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
656 b_add = C_BU * cb + (1 << (SCALE_BITS - 1)); |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
657 |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
658 /* output 4 pixels */ |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
659 RGBOUT(d1[0], d1[1], d1[2], y1_ptr[0]); |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
660 RGBOUT(d1[3], d1[4], d1[5], y1_ptr[1]); |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
661 RGBOUT(d2[0], d2[1], d2[2], y2_ptr[0]); |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
662 RGBOUT(d2[3], d2[4], d2[5], y2_ptr[1]); |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
663 |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
664 d1 += 6; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
665 d2 += 6; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
666 y1_ptr += 2; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
667 y2_ptr += 2; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
668 cb_ptr++; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
669 cr_ptr++; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
670 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
671 d += 2 * dst->linesize[0]; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
672 y1_ptr += 2 * src->linesize[0] - width; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
673 cb_ptr += src->linesize[1] - width2; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
674 cr_ptr += src->linesize[2] - width2; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
675 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
676 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
677 |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
678 /* XXX: no chroma interpolating is done */ |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
679 static void yuv422p_to_rgb24(AVPicture *dst, AVPicture *src, |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
680 int width, int height) |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
681 { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
682 UINT8 *y1_ptr, *cb_ptr, *cr_ptr, *d, *d1; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
683 int w, y, cb, cr, r_add, g_add, b_add, width2; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
684 UINT8 *cm = cropTbl + MAX_NEG_CROP; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
685 |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
686 d = dst->data[0]; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
687 y1_ptr = src->data[0]; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
688 cb_ptr = src->data[1]; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
689 cr_ptr = src->data[2]; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
690 width2 = width >> 1; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
691 for(;height > 0; height --) { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
692 d1 = d; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
693 for(w = width2; w > 0; w --) { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
694 cb = cb_ptr[0] - 128; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
695 cr = cr_ptr[0] - 128; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
696 r_add = C_RV * cr + (1 << (SCALE_BITS - 1)); |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
697 g_add = - C_GU * cb - C_GV * cr + (1 << (SCALE_BITS - 1)); |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
698 b_add = C_BU * cb + (1 << (SCALE_BITS - 1)); |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
699 |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
700 /* output 2 pixels */ |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
701 RGBOUT(d1[0], d1[1], d1[2], y1_ptr[0]); |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
702 RGBOUT(d1[3], d1[4], d1[5], y1_ptr[1]); |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
703 |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
704 d1 += 6; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
705 y1_ptr += 2; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
706 cb_ptr++; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
707 cr_ptr++; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
708 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
709 d += dst->linesize[0]; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
710 y1_ptr += src->linesize[0] - width; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
711 cb_ptr += src->linesize[1] - width2; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
712 cr_ptr += src->linesize[2] - width2; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
713 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
714 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
715 |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
716 /* XXX: always use linesize. Return -1 if not supported */ |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
717 int img_convert(AVPicture *dst, int dst_pix_fmt, |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
718 AVPicture *src, int pix_fmt, |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
719 int width, int height) |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
720 { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
721 int i; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
722 |
315 | 723 assert(pix_fmt != PIX_FMT_ANY && dst_pix_fmt != PIX_FMT_ANY); |
724 | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
725 if (dst_pix_fmt == pix_fmt) { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
726 switch(pix_fmt) { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
727 case PIX_FMT_YUV420P: |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
728 for(i=0;i<3;i++) { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
729 if (i == 1) { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
730 width >>= 1; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
731 height >>= 1; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
732 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
733 img_copy(dst->data[i], dst->linesize[i], |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
734 src->data[i], src->linesize[i], |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
735 width, height); |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
736 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
737 break; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
738 default: |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
739 return -1; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
740 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
741 } else if (dst_pix_fmt == PIX_FMT_YUV420P) { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
742 |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
743 switch(pix_fmt) { |
736
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
744 case PIX_FMT_YUV411P: |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
745 img_copy(dst->data[0], dst->linesize[0], |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
746 src->data[0], src->linesize[0], |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
747 width, height); |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
748 conv411(dst->data[1], dst->linesize[1], |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
749 src->data[1], src->linesize[1], |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
750 width / 4, height); |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
751 conv411(dst->data[2], dst->linesize[2], |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
752 src->data[2], src->linesize[2], |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
753 width / 4, height); |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
754 break; |
576
9aa5f0d0124e
YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
755 case PIX_FMT_YUV410P: |
9aa5f0d0124e
YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
756 img_copy(dst->data[0], dst->linesize[0], |
9aa5f0d0124e
YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
757 src->data[0], src->linesize[0], |
9aa5f0d0124e
YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
758 width, height); |
9aa5f0d0124e
YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
759 grow22(dst->data[1], dst->linesize[1], |
9aa5f0d0124e
YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
760 src->data[1], src->linesize[1], |
9aa5f0d0124e
YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
761 width/2, height/2); |
9aa5f0d0124e
YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
762 grow22(dst->data[2], dst->linesize[2], |
9aa5f0d0124e
YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
763 src->data[2], src->linesize[2], |
9aa5f0d0124e
YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
764 width/2, height/2); |
9aa5f0d0124e
YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
765 break; |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
766 case PIX_FMT_YUV420P: |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
767 for(i=0;i<3;i++) { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
768 img_copy(dst->data[i], dst->linesize[i], |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
769 src->data[i], src->linesize[i], |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
770 width, height); |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
771 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
772 break; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
773 case PIX_FMT_YUV422P: |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
774 img_copy(dst->data[0], dst->linesize[0], |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
775 src->data[0], src->linesize[0], |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
776 width, height); |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
777 width >>= 1; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
778 height >>= 1; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
779 for(i=1;i<3;i++) { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
780 shrink2(dst->data[i], dst->linesize[i], |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
781 src->data[i], src->linesize[i], |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
782 width, height); |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
783 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
784 break; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
785 case PIX_FMT_YUV444P: |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
786 img_copy(dst->data[0], dst->linesize[0], |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
787 src->data[0], src->linesize[0], |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
788 width, height); |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
789 width >>= 1; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
790 height >>= 1; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
791 for(i=1;i<3;i++) { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
792 shrink22(dst->data[i], dst->linesize[i], |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
793 src->data[i], src->linesize[i], |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
794 width, height); |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
795 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
796 break; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
797 case PIX_FMT_YUV422: |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
798 yuv422_to_yuv420p(dst->data[0], dst->data[1], dst->data[2], |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
799 src->data[0], width, height); |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
800 break; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
801 case PIX_FMT_RGB24: |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
802 rgb24_to_yuv420p(dst->data[0], dst->data[1], dst->data[2], |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
803 src->data[0], width, height); |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
804 break; |
583 | 805 case PIX_FMT_RGBA32: |
806 rgba32_to_yuv420p(dst->data[0], dst->data[1], dst->data[2], | |
807 src->data[0], width, height); | |
808 break; | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
809 case PIX_FMT_BGR24: |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
810 bgr24_to_yuv420p(dst->data[0], dst->data[1], dst->data[2], |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
811 src->data[0], width, height); |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
812 break; |
583 | 813 case PIX_FMT_BGRA32: |
814 bgra32_to_yuv420p(dst->data[0], dst->data[1], dst->data[2], | |
815 src->data[0], width, height); | |
816 break; | |
867
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
817 case PIX_FMT_RGB565: |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
818 rgb565_to_yuv420p(dst->data[0], dst->data[1], dst->data[2], |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
819 src->data[0], width, height); |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
820 break; |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
821 case PIX_FMT_RGB555: |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
822 rgb555_to_yuv420p(dst->data[0], dst->data[1], dst->data[2], |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
823 src->data[0], width, height); |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
824 break; |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
825 /* case PIX_FMT_RGB5551: |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
826 rgb5551_to_yuv420p(dst->data[0], dst->data[1], dst->data[2], |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
827 src->data[0], width, height); |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
828 break;*/ |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
829 case PIX_FMT_BGR565: |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
830 bgr565_to_yuv420p(dst->data[0], dst->data[1], dst->data[2], |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
831 src->data[0], width, height); |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
832 break; |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
833 case PIX_FMT_BGR555: |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
834 bgr555_to_yuv420p(dst->data[0], dst->data[1], dst->data[2], |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
835 src->data[0], width, height); |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
836 break; |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
837 /* case PIX_FMT_GBR565: |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
838 gbr565_to_yuv420p(dst->data[0], dst->data[1], dst->data[2], |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
839 src->data[0], width, height); |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
840 break; |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
841 case PIX_FMT_GBR555: |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
842 gbr555_to_yuv420p(dst->data[0], dst->data[1], dst->data[2], |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
843 src->data[0], width, height); |
48215b2c3888
16-bit and 15-bit rgb/bgr patch by (Joel Yliluoma <joel dot yliluoma at w-create dot com>) (note, rare formats disabled)
michaelni
parents:
801
diff
changeset
|
844 break;*/ |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
845 default: |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
846 return -1; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
847 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
848 } else if (dst_pix_fmt == PIX_FMT_RGB24) { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
849 switch(pix_fmt) { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
850 case PIX_FMT_YUV420P: |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
851 yuv420p_to_rgb24(dst, src, width, height); |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
852 break; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
853 case PIX_FMT_YUV422P: |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
854 yuv422p_to_rgb24(dst, src, width, height); |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
855 break; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
856 default: |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
857 return -1; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
858 } |
583 | 859 } else if (dst_pix_fmt == PIX_FMT_RGBA32) { |
860 switch(pix_fmt) { | |
861 case PIX_FMT_YUV420P: | |
862 yuv420p_to_rgba32(dst, src, width, height); | |
863 break; | |
864 default: | |
865 return -1; | |
866 } | |
867 } else if (dst_pix_fmt == PIX_FMT_BGRA32) { | |
868 switch(pix_fmt) { | |
869 case PIX_FMT_YUV420P: | |
870 yuv420p_to_bgra32(dst, src, width, height); | |
871 break; | |
872 default: | |
873 return -1; | |
874 } | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
875 } else { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
876 return -1; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
877 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
878 return 0; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
879 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
880 |
801 | 881 |
882 #ifdef HAVE_MMX | |
883 #define DEINT_INPLACE_LINE_LUM \ | |
884 movd_m2r(lum_m4[0],mm0);\ | |
885 movd_m2r(lum_m3[0],mm1);\ | |
886 movd_m2r(lum_m2[0],mm2);\ | |
887 movd_m2r(lum_m1[0],mm3);\ | |
888 movd_m2r(lum[0],mm4);\ | |
889 punpcklbw_r2r(mm7,mm0);\ | |
890 movd_r2m(mm2,lum_m4[0]);\ | |
891 punpcklbw_r2r(mm7,mm1);\ | |
892 punpcklbw_r2r(mm7,mm2);\ | |
893 punpcklbw_r2r(mm7,mm3);\ | |
894 punpcklbw_r2r(mm7,mm4);\ | |
895 paddw_r2r(mm3,mm1);\ | |
896 psllw_i2r(1,mm2);\ | |
897 paddw_r2r(mm4,mm0);\ | |
898 psllw_i2r(2,mm1);\ | |
899 paddw_r2r(mm6,mm2);\ | |
900 paddw_r2r(mm2,mm1);\ | |
901 psubusw_r2r(mm0,mm1);\ | |
902 psrlw_i2r(3,mm1);\ | |
903 packuswb_r2r(mm7,mm1);\ | |
904 movd_r2m(mm1,lum_m2[0]); | |
905 | |
906 #define DEINT_LINE_LUM \ | |
907 movd_m2r(lum_m4[0],mm0);\ | |
908 movd_m2r(lum_m3[0],mm1);\ | |
909 movd_m2r(lum_m2[0],mm2);\ | |
910 movd_m2r(lum_m1[0],mm3);\ | |
911 movd_m2r(lum[0],mm4);\ | |
912 punpcklbw_r2r(mm7,mm0);\ | |
913 punpcklbw_r2r(mm7,mm1);\ | |
914 punpcklbw_r2r(mm7,mm2);\ | |
915 punpcklbw_r2r(mm7,mm3);\ | |
916 punpcklbw_r2r(mm7,mm4);\ | |
917 paddw_r2r(mm3,mm1);\ | |
918 psllw_i2r(1,mm2);\ | |
919 paddw_r2r(mm4,mm0);\ | |
920 psllw_i2r(2,mm1);\ | |
921 paddw_r2r(mm6,mm2);\ | |
922 paddw_r2r(mm2,mm1);\ | |
923 psubusw_r2r(mm0,mm1);\ | |
924 psrlw_i2r(3,mm1);\ | |
925 packuswb_r2r(mm7,mm1);\ | |
926 movd_r2m(mm1,dst[0]); | |
927 #endif | |
928 | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
929 /* filter parameters: [-1 4 2 4 -1] // 8 */ |
801 | 930 static void deinterlace_line(UINT8 *dst, UINT8 *lum_m4, UINT8 *lum_m3, UINT8 *lum_m2, UINT8 *lum_m1, UINT8 *lum, |
931 int size) | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
932 { |
801 | 933 #ifndef HAVE_MMX |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
934 UINT8 *cm = cropTbl + MAX_NEG_CROP; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
935 int sum; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
936 |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
937 for(;size > 0;size--) { |
801 | 938 sum = -lum_m4[0]; |
939 sum += lum_m3[0] << 2; | |
940 sum += lum_m2[0] << 1; | |
941 sum += lum_m1[0] << 2; | |
942 sum += -lum[0]; | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
943 dst[0] = cm[(sum + 4) >> 3]; |
801 | 944 lum_m4++; |
945 lum_m3++; | |
946 lum_m2++; | |
947 lum_m1++; | |
948 lum++; | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
949 dst++; |
801 | 950 } |
951 #else | |
952 | |
953 for (;size > 3; size-=4) { | |
954 DEINT_LINE_LUM | |
955 lum_m4+=4; | |
956 lum_m3+=4; | |
957 lum_m2+=4; | |
958 lum_m1+=4; | |
959 lum+=4; | |
960 dst+=4; | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
961 } |
801 | 962 #endif |
963 } | |
964 static void deinterlace_line_inplace(UINT8 *lum_m4, UINT8 *lum_m3, UINT8 *lum_m2, UINT8 *lum_m1, UINT8 *lum, | |
965 int size) | |
966 { | |
967 #ifndef HAVE_MMX | |
968 UINT8 *cm = cropTbl + MAX_NEG_CROP; | |
969 int sum; | |
970 | |
971 for(;size > 0;size--) { | |
972 sum = -lum_m4[0]; | |
973 sum += lum_m3[0] << 2; | |
974 sum += lum_m2[0] << 1; | |
975 lum_m4[0]=lum_m2[0]; | |
976 sum += lum_m1[0] << 2; | |
977 sum += -lum[0]; | |
978 lum_m2[0] = cm[(sum + 4) >> 3]; | |
979 lum_m4++; | |
980 lum_m3++; | |
981 lum_m2++; | |
982 lum_m1++; | |
983 lum++; | |
984 } | |
985 #else | |
986 | |
987 for (;size > 3; size-=4) { | |
988 DEINT_INPLACE_LINE_LUM | |
989 lum_m4+=4; | |
990 lum_m3+=4; | |
991 lum_m2+=4; | |
992 lum_m1+=4; | |
993 lum+=4; | |
994 } | |
995 #endif | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
996 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
997 |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
998 /* deinterlacing : 2 temporal taps, 3 spatial taps linear filter. The |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
999 top field is copied as is, but the bottom field is deinterlaced |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1000 against the top field. */ |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1001 static void deinterlace_bottom_field(UINT8 *dst, int dst_wrap, |
801 | 1002 UINT8 *src1, int src_wrap, |
1003 int width, int height) | |
1004 { | |
1005 UINT8 *src_m2, *src_m1, *src_0, *src_p1, *src_p2; | |
1006 int y; | |
1007 | |
1008 src_m2 = src1; | |
1009 src_m1 = src1; | |
1010 src_0=&src_m1[src_wrap]; | |
1011 src_p1=&src_0[src_wrap]; | |
1012 src_p2=&src_p1[src_wrap]; | |
1013 for(y=0;y<(height-2);y+=2) { | |
1014 memcpy(dst,src_m1,width); | |
1015 dst += dst_wrap; | |
1016 deinterlace_line(dst,src_m2,src_m1,src_0,src_p1,src_p2,width); | |
1017 src_m2 = src_0; | |
1018 src_m1 = src_p1; | |
1019 src_0 = src_p2; | |
1020 src_p1 += 2*src_wrap; | |
1021 src_p2 += 2*src_wrap; | |
1022 dst += dst_wrap; | |
1023 } | |
1024 memcpy(dst,src_m1,width); | |
1025 dst += dst_wrap; | |
1026 /* do last line */ | |
1027 deinterlace_line(dst,src_m2,src_m1,src_0,src_0,src_0,width); | |
1028 } | |
1029 | |
1030 static void deinterlace_bottom_field_inplace(UINT8 *src1, int src_wrap, | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1031 int width, int height) |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1032 { |
801 | 1033 UINT8 *src_m1, *src_0, *src_p1, *src_p2; |
1034 int y; | |
64 | 1035 UINT8 *buf; |
801 | 1036 buf = (UINT8*)av_malloc(width); |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1037 |
801 | 1038 src_m1 = src1; |
1039 memcpy(buf,src_m1,width); | |
1040 src_0=&src_m1[src_wrap]; | |
1041 src_p1=&src_0[src_wrap]; | |
1042 src_p2=&src_p1[src_wrap]; | |
1043 for(y=0;y<(height-2);y+=2) { | |
1044 deinterlace_line_inplace(buf,src_m1,src_0,src_p1,src_p2,width); | |
1045 src_m1 = src_p1; | |
1046 src_0 = src_p2; | |
1047 src_p1 += 2*src_wrap; | |
1048 src_p2 += 2*src_wrap; | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1049 } |
801 | 1050 /* do last line */ |
1051 deinterlace_line_inplace(buf,src_m1,src_0,src_0,src_0,width); | |
396
fce0a2520551
removed useless header includes - use av memory functions
glantau
parents:
315
diff
changeset
|
1052 av_free(buf); |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1053 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1054 |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1055 |
801 | 1056 /* deinterlace - if not supported return -1 */ |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1057 int avpicture_deinterlace(AVPicture *dst, AVPicture *src, |
0 | 1058 int pix_fmt, int width, int height) |
1059 { | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1060 int i; |
0 | 1061 |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1062 if (pix_fmt != PIX_FMT_YUV420P && |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1063 pix_fmt != PIX_FMT_YUV422P && |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1064 pix_fmt != PIX_FMT_YUV444P) |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1065 return -1; |
801 | 1066 if ((width & 3) != 0 || (height & 3) != 0) |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1067 return -1; |
801 | 1068 |
1069 #ifdef HAVE_MMX | |
1070 { | |
1071 mmx_t rounder; | |
1072 rounder.uw[0]=4; | |
1073 rounder.uw[1]=4; | |
1074 rounder.uw[2]=4; | |
1075 rounder.uw[3]=4; | |
1076 pxor_r2r(mm7,mm7); | |
1077 movq_m2r(rounder,mm6); | |
1078 } | |
1079 #endif | |
1080 | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1081 |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1082 for(i=0;i<3;i++) { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1083 if (i == 1) { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1084 switch(pix_fmt) { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1085 case PIX_FMT_YUV420P: |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1086 width >>= 1; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1087 height >>= 1; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1088 break; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1089 case PIX_FMT_YUV422P: |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1090 width >>= 1; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1091 break; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1092 default: |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1093 break; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1094 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1095 } |
801 | 1096 if (src == dst) { |
1097 deinterlace_bottom_field_inplace(src->data[i], src->linesize[i], | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1098 width, height); |
801 | 1099 } else { |
1100 deinterlace_bottom_field(dst->data[i],dst->linesize[i], | |
1101 src->data[i], src->linesize[i], | |
1102 width, height); | |
1103 } | |
0 | 1104 } |
801 | 1105 #ifdef HAVE_MMX |
1106 emms(); | |
1107 #endif | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1108 return 0; |
0 | 1109 } |
440
000aeeac27a2
* started to cleanup name clashes for onetime compilation
kabi
parents:
429
diff
changeset
|
1110 |
000aeeac27a2
* started to cleanup name clashes for onetime compilation
kabi
parents:
429
diff
changeset
|
1111 #undef FIX |