Mercurial > libavcodec.hg
annotate imgconvert.c @ 676:c3bdb00a98a9 libavcodec
dont store version for bit-exact tests
| author | michaelni |
|---|---|
| date | Sat, 14 Sep 2002 22:07:35 +0000 |
| parents | d6955d0d7d27 |
| children | 918756bffda2 |
| 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 | |
| 0 | 25 /* XXX: totally non optimized */ |
| 26 | |
| 27 static void yuv422_to_yuv420p(UINT8 *lum, UINT8 *cb, UINT8 *cr, | |
| 28 UINT8 *src, int width, int height) | |
| 29 { | |
| 30 int x, y; | |
| 31 UINT8 *p = src; | |
| 32 | |
| 33 for(y=0;y<height;y+=2) { | |
| 34 for(x=0;x<width;x+=2) { | |
| 35 lum[0] = p[0]; | |
| 36 cb[0] = p[1]; | |
| 37 lum[1] = p[2]; | |
| 38 cr[0] = p[3]; | |
| 39 p += 4; | |
| 40 lum += 2; | |
| 41 cb++; | |
| 42 cr++; | |
| 43 } | |
| 44 for(x=0;x<width;x+=2) { | |
| 45 lum[0] = p[0]; | |
| 46 lum[1] = p[2]; | |
| 47 p += 4; | |
| 48 lum += 2; | |
| 49 } | |
| 50 } | |
| 51 } | |
| 52 | |
| 53 #define SCALEBITS 8 | |
| 54 #define ONE_HALF (1 << (SCALEBITS - 1)) | |
| 55 #define FIX(x) ((int) ((x) * (1L<<SCALEBITS) + 0.5)) | |
| 56 | |
| 57 static void rgb24_to_yuv420p(UINT8 *lum, UINT8 *cb, UINT8 *cr, | |
| 58 UINT8 *src, int width, int height) | |
| 59 { | |
| 60 int wrap, wrap3, x, y; | |
| 61 int r, g, b, r1, g1, b1; | |
| 62 UINT8 *p; | |
| 63 | |
| 64 wrap = width; | |
| 65 wrap3 = width * 3; | |
| 66 p = src; | |
| 67 for(y=0;y<height;y+=2) { | |
| 68 for(x=0;x<width;x+=2) { | |
| 69 r = p[0]; | |
| 70 g = p[1]; | |
| 71 b = p[2]; | |
| 72 r1 = r; | |
| 73 g1 = g; | |
| 74 b1 = b; | |
| 75 lum[0] = (FIX(0.29900) * r + FIX(0.58700) * g + | |
| 76 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |
| 77 r = p[3]; | |
| 78 g = p[4]; | |
| 79 b = p[5]; | |
| 80 r1 += r; | |
| 81 g1 += g; | |
| 82 b1 += b; | |
| 83 lum[1] = (FIX(0.29900) * r + FIX(0.58700) * g + | |
| 84 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |
| 85 p += wrap3; | |
| 86 lum += wrap; | |
| 87 | |
| 88 r = p[0]; | |
| 89 g = p[1]; | |
| 90 b = p[2]; | |
| 91 r1 += r; | |
| 92 g1 += g; | |
| 93 b1 += b; | |
| 94 lum[0] = (FIX(0.29900) * r + FIX(0.58700) * g + | |
| 95 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |
| 96 r = p[3]; | |
| 97 g = p[4]; | |
| 98 b = p[5]; | |
| 99 r1 += r; | |
| 100 g1 += g; | |
| 101 b1 += b; | |
| 102 lum[1] = (FIX(0.29900) * r + FIX(0.58700) * g + | |
| 103 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |
| 104 | |
| 105 cb[0] = ((- FIX(0.16874) * r1 - FIX(0.33126) * g1 + | |
| 106 FIX(0.50000) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) + 128; | |
| 107 cr[0] = ((FIX(0.50000) * r1 - FIX(0.41869) * g1 - | |
| 108 FIX(0.08131) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) + 128; | |
| 109 | |
| 110 cb++; | |
| 111 cr++; | |
| 112 p += -wrap3 + 2 * 3; | |
| 113 lum += -wrap + 2; | |
| 114 } | |
| 115 p += wrap3; | |
| 116 lum += wrap; | |
| 117 } | |
| 118 } | |
| 119 | |
| 583 | 120 static void rgba32_to_yuv420p(UINT8 *lum, UINT8 *cb, UINT8 *cr, |
| 121 UINT8 *src, int width, int height) | |
| 122 { | |
| 123 int wrap, wrap4, x, y; | |
| 124 int r, g, b, r1, g1, b1; | |
| 125 UINT8 *p; | |
| 126 | |
| 127 wrap = width; | |
| 128 wrap4 = width * 4; | |
| 129 p = src; | |
| 130 for(y=0;y<height;y+=2) { | |
| 131 for(x=0;x<width;x+=2) { | |
| 132 r = p[0]; | |
| 133 g = p[1]; | |
| 134 b = p[2]; | |
| 135 r1 = r; | |
| 136 g1 = g; | |
| 137 b1 = b; | |
| 138 lum[0] = (FIX(0.29900) * r + FIX(0.58700) * g + | |
| 139 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |
| 140 r = p[4]; | |
| 141 g = p[5]; | |
| 142 b = p[6]; | |
| 143 r1 += r; | |
| 144 g1 += g; | |
| 145 b1 += b; | |
| 146 lum[1] = (FIX(0.29900) * r + FIX(0.58700) * g + | |
| 147 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |
| 148 p += wrap4; | |
| 149 lum += wrap; | |
| 150 | |
| 151 r = p[0]; | |
| 152 g = p[1]; | |
| 153 b = p[2]; | |
| 154 r1 += r; | |
| 155 g1 += g; | |
| 156 b1 += b; | |
| 157 lum[0] = (FIX(0.29900) * r + FIX(0.58700) * g + | |
| 158 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |
| 159 r = p[4]; | |
| 160 g = p[5]; | |
| 161 b = p[6]; | |
| 162 r1 += r; | |
| 163 g1 += g; | |
| 164 b1 += b; | |
| 165 lum[1] = (FIX(0.29900) * r + FIX(0.58700) * g + | |
| 166 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |
| 167 | |
| 168 cb[0] = ((- FIX(0.16874) * r1 - FIX(0.33126) * g1 + | |
| 169 FIX(0.50000) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) + 128; | |
| 170 cr[0] = ((FIX(0.50000) * r1 - FIX(0.41869) * g1 - | |
| 171 FIX(0.08131) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) + 128; | |
| 172 | |
| 173 cb++; | |
| 174 cr++; | |
| 175 p += -wrap4 + 2 * 4; | |
| 176 lum += -wrap + 2; | |
| 177 } | |
| 178 p += wrap4; | |
| 179 lum += wrap; | |
| 180 } | |
| 181 } | |
| 182 | |
| 0 | 183 static void bgr24_to_yuv420p(UINT8 *lum, UINT8 *cb, UINT8 *cr, |
| 184 UINT8 *src, int width, int height) | |
| 185 { | |
| 186 int wrap, wrap3, x, y; | |
| 187 int r, g, b, r1, g1, b1; | |
| 188 UINT8 *p; | |
| 189 | |
| 190 wrap = width; | |
| 191 wrap3 = width * 3; | |
| 192 p = src; | |
| 193 for(y=0;y<height;y+=2) { | |
| 194 for(x=0;x<width;x+=2) { | |
| 195 b = p[0]; | |
| 196 g = p[1]; | |
| 197 r = p[2]; | |
| 198 r1 = r; | |
| 199 g1 = g; | |
| 200 b1 = b; | |
| 201 lum[0] = (FIX(0.29900) * r + FIX(0.58700) * g + | |
| 202 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |
| 203 b = p[3]; | |
| 204 g = p[4]; | |
| 205 r = p[5]; | |
| 206 r1 += r; | |
| 207 g1 += g; | |
| 208 b1 += b; | |
| 209 lum[1] = (FIX(0.29900) * r + FIX(0.58700) * g + | |
| 210 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |
| 211 p += wrap3; | |
| 212 lum += wrap; | |
| 213 | |
| 214 b = p[0]; | |
| 215 g = p[1]; | |
| 216 r = p[2]; | |
| 217 r1 += r; | |
| 218 g1 += g; | |
| 219 b1 += b; | |
| 220 lum[0] = (FIX(0.29900) * r + FIX(0.58700) * g + | |
| 221 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |
| 222 b = p[3]; | |
| 223 g = p[4]; | |
| 224 r = p[5]; | |
| 225 r1 += r; | |
| 226 g1 += g; | |
| 227 b1 += b; | |
| 228 lum[1] = (FIX(0.29900) * r + FIX(0.58700) * g + | |
| 229 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |
| 230 | |
| 231 cb[0] = ((- FIX(0.16874) * r1 - FIX(0.33126) * g1 + | |
| 232 FIX(0.50000) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) + 128; | |
| 233 cr[0] = ((FIX(0.50000) * r1 - FIX(0.41869) * g1 - | |
| 234 FIX(0.08131) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) + 128; | |
| 235 | |
| 236 cb++; | |
| 237 cr++; | |
| 238 p += -wrap3 + 2 * 3; | |
| 239 lum += -wrap + 2; | |
| 240 } | |
| 241 p += wrap3; | |
| 242 lum += wrap; | |
| 243 } | |
| 244 } | |
| 245 | |
| 583 | 246 static void bgra32_to_yuv420p(UINT8 *lum, UINT8 *cb, UINT8 *cr, |
| 247 UINT8 *src, int width, int height) | |
| 248 { | |
| 249 int wrap, wrap4, x, y; | |
| 250 int r, g, b, r1, g1, b1; | |
| 251 UINT8 *p; | |
| 252 | |
| 253 wrap = width; | |
| 254 wrap4 = width * 4; | |
| 255 p = src; | |
| 256 for(y=0;y<height;y+=2) { | |
| 257 for(x=0;x<width;x+=2) { | |
| 258 b = p[0]; | |
| 259 g = p[1]; | |
| 260 r = p[2]; | |
| 261 r1 = r; | |
| 262 g1 = g; | |
| 263 b1 = b; | |
| 264 lum[0] = (FIX(0.29900) * r + FIX(0.58700) * g + | |
| 265 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |
| 266 b = p[4]; | |
| 267 g = p[5]; | |
| 268 r = p[6]; | |
| 269 r1 += r; | |
| 270 g1 += g; | |
| 271 b1 += b; | |
| 272 lum[1] = (FIX(0.29900) * r + FIX(0.58700) * g + | |
| 273 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |
| 274 p += wrap4; | |
| 275 lum += wrap; | |
| 276 | |
| 277 b = p[0]; | |
| 278 g = p[1]; | |
| 279 r = p[2]; | |
| 280 r1 += r; | |
| 281 g1 += g; | |
| 282 b1 += b; | |
| 283 lum[0] = (FIX(0.29900) * r + FIX(0.58700) * g + | |
| 284 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |
| 285 b = p[4]; | |
| 286 g = p[5]; | |
| 287 r = p[6]; | |
| 288 r1 += r; | |
| 289 g1 += g; | |
| 290 b1 += b; | |
| 291 lum[1] = (FIX(0.29900) * r + FIX(0.58700) * g + | |
| 292 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |
| 293 | |
| 294 cb[0] = ((- FIX(0.16874) * r1 - FIX(0.33126) * g1 + | |
| 295 FIX(0.50000) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) + 128; | |
| 296 cr[0] = ((FIX(0.50000) * r1 - FIX(0.41869) * g1 - | |
| 297 FIX(0.08131) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) + 128; | |
| 298 | |
| 299 cb++; | |
| 300 cr++; | |
| 301 p += -wrap4 + 2 * 4; | |
| 302 lum += -wrap + 2; | |
| 303 } | |
| 304 p += wrap4; | |
| 305 lum += wrap; | |
| 306 } | |
| 307 } | |
| 308 | |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
309 /* XXX: use generic filter ? */ |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
310 /* 1x2 -> 1x1 */ |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
311 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
|
312 UINT8 *src, int src_wrap, |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
313 int width, int height) |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
314 { |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
315 int w; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
316 UINT8 *s1, *s2, *d; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
317 |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
318 for(;height > 0; height--) { |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
319 s1 = src; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
320 s2 = s1 + src_wrap; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
321 d = dst; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
322 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
|
323 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
|
324 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
|
325 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
|
326 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
|
327 s1 += 4; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
328 s2 += 4; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
329 d += 4; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
330 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
331 for(;w > 0; w--) { |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
332 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
|
333 s1++; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
334 s2++; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
335 d++; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
336 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
337 src += 2 * src_wrap; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
338 dst += dst_wrap; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
339 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
340 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
341 |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
342 /* 2x2 -> 1x1 */ |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
343 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
|
344 UINT8 *src, int src_wrap, |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
345 int width, int height) |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
346 { |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
347 int w; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
348 UINT8 *s1, *s2, *d; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
349 |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
350 for(;height > 0; height--) { |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
351 s1 = src; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
352 s2 = s1 + src_wrap; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
353 d = dst; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
354 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
|
355 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
|
356 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
|
357 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
|
358 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
|
359 s1 += 8; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
360 s2 += 8; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
361 d += 4; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
362 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
363 for(;w > 0; w--) { |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
364 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
|
365 s1 += 2; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
366 s2 += 2; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
367 d++; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
368 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
369 src += 2 * src_wrap; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
370 dst += dst_wrap; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
371 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
372 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
373 |
|
576
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
374 /* 1x1 -> 2x2 */ |
|
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
375 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
|
376 UINT8 *src, int src_wrap, |
|
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
377 int width, int height) |
|
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
378 { |
|
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
379 int w; |
|
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
380 UINT8 *s1, *d; |
|
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
381 |
|
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
382 for(;height > 0; height--) { |
|
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
383 s1 = src; |
|
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
384 d = dst; |
|
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
385 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
|
386 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
|
387 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
|
388 s1 += 2; |
|
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
389 d += 4; |
|
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
390 } |
|
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
391 for(;w > 0; w--) { |
|
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
392 d[0] = s1[0]; |
|
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
393 s1 ++; |
|
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
394 d++; |
|
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
395 } |
|
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
396 if (height%2) |
|
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
397 src += src_wrap; |
|
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
398 dst += dst_wrap; |
|
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
399 } |
|
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
400 } |
|
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
401 |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
402 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
|
403 UINT8 *src, int src_wrap, |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
404 int width, int height) |
|
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 memcpy(dst, src, width); |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
408 dst += dst_wrap; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
409 src += src_wrap; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
410 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
411 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
412 |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
413 #define SCALE_BITS 10 |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
414 |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
415 #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
|
416 #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
|
417 #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
|
418 #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
|
419 #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
|
420 |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
421 #define RGBOUT(r, g, b, y1)\ |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
422 {\ |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
423 y = (y1 - 16) * C_Y;\ |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
424 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
|
425 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
|
426 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
|
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 /* XXX: no chroma interpolating is done */ |
| 583 | 430 static void yuv420p_to_bgra32(AVPicture *dst, AVPicture *src, |
| 431 int width, int height) | |
| 432 { | |
| 433 UINT8 *y1_ptr, *y2_ptr, *cb_ptr, *cr_ptr, *d, *d1, *d2; | |
| 434 int w, y, cb, cr, r_add, g_add, b_add, width2; | |
| 435 UINT8 *cm = cropTbl + MAX_NEG_CROP; | |
| 436 | |
| 437 d = dst->data[0]; | |
| 438 y1_ptr = src->data[0]; | |
| 439 cb_ptr = src->data[1]; | |
| 440 cr_ptr = src->data[2]; | |
| 441 width2 = width >> 1; | |
| 442 for(;height > 0; height -= 2) { | |
| 443 d1 = d; | |
| 444 d2 = d + dst->linesize[0]; | |
| 445 y2_ptr = y1_ptr + src->linesize[0]; | |
| 446 for(w = width2; w > 0; w --) { | |
| 447 cb = cb_ptr[0] - 128; | |
| 448 cr = cr_ptr[0] - 128; | |
| 449 r_add = C_RV * cr + (1 << (SCALE_BITS - 1)); | |
| 450 g_add = - C_GU * cb - C_GV * cr + (1 << (SCALE_BITS - 1)); | |
| 451 b_add = C_BU * cb + (1 << (SCALE_BITS - 1)); | |
| 452 | |
| 453 /* output 4 pixels */ | |
| 454 RGBOUT(d1[2], d1[1], d1[0], y1_ptr[0]); | |
| 455 RGBOUT(d1[6], d1[5], d1[4], y1_ptr[1]); | |
| 456 RGBOUT(d2[2], d2[1], d2[0], y2_ptr[0]); | |
| 457 RGBOUT(d2[6], d2[5], d2[4], y2_ptr[1]); | |
| 458 | |
| 459 d1[3] = d1[7] = d2[3] = d2[7] = 255; | |
| 460 | |
| 461 d1 += 8; | |
| 462 d2 += 8; | |
| 463 y1_ptr += 2; | |
| 464 y2_ptr += 2; | |
| 465 cb_ptr++; | |
| 466 cr_ptr++; | |
| 467 } | |
| 468 d += 2 * dst->linesize[0]; | |
| 469 y1_ptr += 2 * src->linesize[0] - width; | |
| 470 cb_ptr += src->linesize[1] - width2; | |
| 471 cr_ptr += src->linesize[2] - width2; | |
| 472 } | |
| 473 } | |
| 474 | |
| 475 /* XXX: no chroma interpolating is done */ | |
| 476 static void yuv420p_to_rgba32(AVPicture *dst, AVPicture *src, | |
| 477 int width, int height) | |
| 478 { | |
| 479 UINT8 *y1_ptr, *y2_ptr, *cb_ptr, *cr_ptr, *d, *d1, *d2; | |
| 480 int w, y, cb, cr, r_add, g_add, b_add, width2; | |
| 481 UINT8 *cm = cropTbl + MAX_NEG_CROP; | |
| 482 | |
| 483 d = dst->data[0]; | |
| 484 y1_ptr = src->data[0]; | |
| 485 cb_ptr = src->data[1]; | |
| 486 cr_ptr = src->data[2]; | |
| 487 width2 = width >> 1; | |
| 488 for(;height > 0; height -= 2) { | |
| 489 d1 = d; | |
| 490 d2 = d + dst->linesize[0]; | |
| 491 y2_ptr = y1_ptr + src->linesize[0]; | |
| 492 for(w = width2; w > 0; w --) { | |
| 493 cb = cb_ptr[0] - 128; | |
| 494 cr = cr_ptr[0] - 128; | |
| 495 r_add = C_RV * cr + (1 << (SCALE_BITS - 1)); | |
| 496 g_add = - C_GU * cb - C_GV * cr + (1 << (SCALE_BITS - 1)); | |
| 497 b_add = C_BU * cb + (1 << (SCALE_BITS - 1)); | |
| 498 | |
| 499 /* output 4 pixels */ | |
| 500 RGBOUT(d1[0], d1[1], d1[2], y1_ptr[0]); | |
| 501 RGBOUT(d1[4], d1[5], d1[6], y1_ptr[1]); | |
| 502 RGBOUT(d2[0], d2[1], d2[2], y2_ptr[0]); | |
| 503 RGBOUT(d2[4], d2[5], d2[6], y2_ptr[1]); | |
| 504 | |
| 505 d1[3] = d1[7] = d2[3] = d2[7] = 255; | |
| 506 | |
| 507 d1 += 8; | |
| 508 d2 += 8; | |
| 509 y1_ptr += 2; | |
| 510 y2_ptr += 2; | |
| 511 cb_ptr++; | |
| 512 cr_ptr++; | |
| 513 } | |
| 514 d += 2 * dst->linesize[0]; | |
| 515 y1_ptr += 2 * src->linesize[0] - width; | |
| 516 cb_ptr += src->linesize[1] - width2; | |
| 517 cr_ptr += src->linesize[2] - width2; | |
| 518 } | |
| 519 } | |
| 520 | |
| 521 /* 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
|
522 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
|
523 int width, int height) |
|
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 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
|
526 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
|
527 UINT8 *cm = cropTbl + MAX_NEG_CROP; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
528 |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
529 d = dst->data[0]; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
530 y1_ptr = src->data[0]; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
531 cb_ptr = src->data[1]; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
532 cr_ptr = src->data[2]; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
533 width2 = width >> 1; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
534 for(;height > 0; height -= 2) { |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
535 d1 = d; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
536 d2 = d + dst->linesize[0]; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
537 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
|
538 for(w = width2; w > 0; w --) { |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
539 cb = cb_ptr[0] - 128; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
540 cr = cr_ptr[0] - 128; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
541 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
|
542 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
|
543 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
|
544 |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
545 /* output 4 pixels */ |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
546 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
|
547 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
|
548 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
|
549 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
|
550 |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
551 d1 += 6; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
552 d2 += 6; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
553 y1_ptr += 2; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
554 y2_ptr += 2; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
555 cb_ptr++; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
556 cr_ptr++; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
557 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
558 d += 2 * dst->linesize[0]; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
559 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
|
560 cb_ptr += src->linesize[1] - width2; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
561 cr_ptr += src->linesize[2] - width2; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
562 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
563 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
564 |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
565 /* XXX: no chroma interpolating is done */ |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
566 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
|
567 int width, int height) |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
568 { |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
569 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
|
570 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
|
571 UINT8 *cm = cropTbl + MAX_NEG_CROP; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
572 |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
573 d = dst->data[0]; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
574 y1_ptr = src->data[0]; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
575 cb_ptr = src->data[1]; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
576 cr_ptr = src->data[2]; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
577 width2 = width >> 1; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
578 for(;height > 0; height --) { |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
579 d1 = d; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
580 for(w = width2; w > 0; w --) { |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
581 cb = cb_ptr[0] - 128; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
582 cr = cr_ptr[0] - 128; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
583 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
|
584 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
|
585 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
|
586 |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
587 /* output 2 pixels */ |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
588 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
|
589 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
|
590 |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
591 d1 += 6; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
592 y1_ptr += 2; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
593 cb_ptr++; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
594 cr_ptr++; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
595 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
596 d += dst->linesize[0]; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
597 y1_ptr += src->linesize[0] - width; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
598 cb_ptr += src->linesize[1] - width2; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
599 cr_ptr += src->linesize[2] - width2; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
600 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
601 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
602 |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
603 /* 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
|
604 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
|
605 AVPicture *src, int pix_fmt, |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
606 int width, int height) |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
607 { |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
608 int i; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
609 |
| 315 | 610 assert(pix_fmt != PIX_FMT_ANY && dst_pix_fmt != PIX_FMT_ANY); |
| 611 | |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
612 if (dst_pix_fmt == pix_fmt) { |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
613 switch(pix_fmt) { |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
614 case PIX_FMT_YUV420P: |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
615 for(i=0;i<3;i++) { |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
616 if (i == 1) { |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
617 width >>= 1; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
618 height >>= 1; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
619 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
620 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
|
621 src->data[i], src->linesize[i], |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
622 width, height); |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
623 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
624 break; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
625 default: |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
626 return -1; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
627 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
628 } 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
|
629 |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
630 switch(pix_fmt) { |
|
576
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
631 case PIX_FMT_YUV410P: |
|
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
632 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
|
633 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
|
634 width, height); |
|
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
635 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
|
636 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
|
637 width/2, height/2); |
|
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
638 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
|
639 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
|
640 width/2, height/2); |
|
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
641 break; |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
642 case PIX_FMT_YUV420P: |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
643 for(i=0;i<3;i++) { |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
644 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
|
645 src->data[i], src->linesize[i], |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
646 width, height); |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
647 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
648 break; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
649 case PIX_FMT_YUV422P: |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
650 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
|
651 src->data[0], src->linesize[0], |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
652 width, height); |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
653 width >>= 1; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
654 height >>= 1; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
655 for(i=1;i<3;i++) { |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
656 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
|
657 src->data[i], src->linesize[i], |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
658 width, height); |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
659 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
660 break; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
661 case PIX_FMT_YUV444P: |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
662 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
|
663 src->data[0], src->linesize[0], |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
664 width, height); |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
665 width >>= 1; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
666 height >>= 1; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
667 for(i=1;i<3;i++) { |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
668 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
|
669 src->data[i], src->linesize[i], |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
670 width, height); |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
671 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
672 break; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
673 case PIX_FMT_YUV422: |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
674 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
|
675 src->data[0], width, height); |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
676 break; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
677 case PIX_FMT_RGB24: |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
678 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
|
679 src->data[0], width, height); |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
680 break; |
| 583 | 681 case PIX_FMT_RGBA32: |
| 682 rgba32_to_yuv420p(dst->data[0], dst->data[1], dst->data[2], | |
| 683 src->data[0], width, height); | |
| 684 break; | |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
685 case PIX_FMT_BGR24: |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
686 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
|
687 src->data[0], width, height); |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
688 break; |
| 583 | 689 case PIX_FMT_BGRA32: |
| 690 bgra32_to_yuv420p(dst->data[0], dst->data[1], dst->data[2], | |
| 691 src->data[0], width, height); | |
| 692 break; | |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
693 default: |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
694 return -1; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
695 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
696 } 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
|
697 switch(pix_fmt) { |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
698 case PIX_FMT_YUV420P: |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
699 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
|
700 break; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
701 case PIX_FMT_YUV422P: |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
702 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
|
703 break; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
704 default: |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
705 return -1; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
706 } |
| 583 | 707 } else if (dst_pix_fmt == PIX_FMT_RGBA32) { |
| 708 switch(pix_fmt) { | |
| 709 case PIX_FMT_YUV420P: | |
| 710 yuv420p_to_rgba32(dst, src, width, height); | |
| 711 break; | |
| 712 default: | |
| 713 return -1; | |
| 714 } | |
| 715 } else if (dst_pix_fmt == PIX_FMT_BGRA32) { | |
| 716 switch(pix_fmt) { | |
| 717 case PIX_FMT_YUV420P: | |
| 718 yuv420p_to_bgra32(dst, src, width, height); | |
| 719 break; | |
| 720 default: | |
| 721 return -1; | |
| 722 } | |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
723 } else { |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
724 return -1; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
725 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
726 return 0; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
727 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
728 |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
729 /* filter parameters: [-1 4 2 4 -1] // 8 */ |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
730 static void deinterlace_line(UINT8 *dst, UINT8 *src, int src_wrap, |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
731 int size) |
|
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 UINT8 *cm = cropTbl + MAX_NEG_CROP; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
734 int sum; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
735 UINT8 *s; |
|
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 for(;size > 0;size--) { |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
738 s = src; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
739 sum = -s[0]; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
740 s += src_wrap; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
741 sum += s[0] << 2; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
742 s += src_wrap; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
743 sum += s[0] << 1; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
744 s += src_wrap; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
745 sum += s[0] << 2; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
746 s += src_wrap; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
747 sum += -s[0]; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
748 dst[0] = cm[(sum + 4) >> 3]; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
749 dst++; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
750 src++; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
751 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
752 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
753 |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
754 /* 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
|
755 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
|
756 against the top field. */ |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
757 static void deinterlace_bottom_field(UINT8 *dst, int dst_wrap, |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
758 UINT8 *src1, int src_wrap, |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
759 int width, int height) |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
760 { |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
761 UINT8 *src, *ptr; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
762 int y, y1, i; |
| 64 | 763 UINT8 *buf; |
| 764 | |
|
396
fce0a2520551
removed useless header includes - use av memory functions
glantau
parents:
315
diff
changeset
|
765 buf = (UINT8*)av_malloc(5 * width); |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
766 |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
767 src = src1; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
768 for(y=0;y<height;y+=2) { |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
769 /* copy top field line */ |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
770 memcpy(dst, src, width); |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
771 dst += dst_wrap; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
772 src += (1 - 2) * src_wrap; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
773 y1 = y - 2; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
774 if (y1 >= 0 && (y1 + 4) < height) { |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
775 /* fast case : no edges */ |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
776 deinterlace_line(dst, src, src_wrap, width); |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
777 } else { |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
778 /* in order to use the same function, we use an intermediate buffer */ |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
779 ptr = buf; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
780 for(i=0;i<5;i++) { |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
781 if (y1 < 0) |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
782 memcpy(ptr, src1, width); |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
783 else if (y1 >= height) |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
784 memcpy(ptr, src1 + (height - 1) * src_wrap, width); |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
785 else |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
786 memcpy(ptr, src1 + y1 * src_wrap, width); |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
787 y1++; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
788 ptr += width; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
789 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
790 deinterlace_line(dst, buf, width, width); |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
791 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
792 dst += dst_wrap; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
793 src += (2 + 1) * src_wrap; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
794 } |
|
396
fce0a2520551
removed useless header includes - use av memory functions
glantau
parents:
315
diff
changeset
|
795 av_free(buf); |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
796 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
797 |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
798 |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
799 /* deinterlace, return -1 if format not handled */ |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
800 int avpicture_deinterlace(AVPicture *dst, AVPicture *src, |
| 0 | 801 int pix_fmt, int width, int height) |
| 802 { | |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
803 int i; |
| 0 | 804 |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
805 if (pix_fmt != PIX_FMT_YUV420P && |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
806 pix_fmt != PIX_FMT_YUV422P && |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
807 pix_fmt != PIX_FMT_YUV444P) |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
808 return -1; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
809 if ((width & 1) != 0 || (height & 3) != 0) |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
810 return -1; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
811 |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
812 for(i=0;i<3;i++) { |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
813 if (i == 1) { |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
814 switch(pix_fmt) { |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
815 case PIX_FMT_YUV420P: |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
816 width >>= 1; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
817 height >>= 1; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
818 break; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
819 case PIX_FMT_YUV422P: |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
820 width >>= 1; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
821 break; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
822 default: |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
823 break; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
824 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
825 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
826 deinterlace_bottom_field(dst->data[i], dst->linesize[i], |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
827 src->data[i], src->linesize[i], |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
828 width, height); |
| 0 | 829 } |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
830 return 0; |
| 0 | 831 } |
|
440
000aeeac27a2
* started to cleanup name clashes for onetime compilation
kabi
parents:
429
diff
changeset
|
832 |
|
000aeeac27a2
* started to cleanup name clashes for onetime compilation
kabi
parents:
429
diff
changeset
|
833 #undef FIX |
