annotate imgconvert.c @ 756:f2644bb12a43 libavcodec

fixing h263 decoding (did segfault)
author michaelni
date Sat, 19 Oct 2002 01:31:26 +0000
parents 918756bffda2
children f720b01c0fd5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
1 /*
986e461dc072 Initial revision
glantau
parents:
diff changeset
2 * Misc image convertion routines
429
718a22dc121f license/copyright change
glantau
parents: 396
diff changeset
3 * Copyright (c) 2001, 2002 Fabrice Bellard.
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
4 *
429
718a22dc121f license/copyright change
glantau
parents: 396
diff changeset
5 * This library is free software; you can redistribute it and/or
718a22dc121f license/copyright change
glantau
parents: 396
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
718a22dc121f license/copyright change
glantau
parents: 396
diff changeset
7 * License as published by the Free Software Foundation; either
718a22dc121f license/copyright change
glantau
parents: 396
diff changeset
8 * version 2 of the License, or (at your option) any later version.
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
9 *
429
718a22dc121f license/copyright change
glantau
parents: 396
diff changeset
10 * This library is distributed in the hope that it will be useful,
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
429
718a22dc121f license/copyright change
glantau
parents: 396
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
718a22dc121f license/copyright change
glantau
parents: 396
diff changeset
13 * Lesser General Public License for more details.
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
14 *
429
718a22dc121f license/copyright change
glantau
parents: 396
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
718a22dc121f license/copyright change
glantau
parents: 396
diff changeset
16 * License along with this library; if not, write to the Free Software
718a22dc121f license/copyright change
glantau
parents: 396
diff changeset
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
18 */
986e461dc072 Initial revision
glantau
parents:
diff changeset
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
986e461dc072 Initial revision
glantau
parents:
diff changeset
21
17
b69fe46fd708 Adding fastmemcpy stuff to speedup mplayer project
nickols_k
parents: 0
diff changeset
22 #ifdef USE_FASTMEMCPY
b69fe46fd708 Adding fastmemcpy stuff to speedup mplayer project
nickols_k
parents: 0
diff changeset
23 #include "fastmemcpy.h"
b69fe46fd708 Adding fastmemcpy stuff to speedup mplayer project
nickols_k
parents: 0
diff changeset
24 #endif
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
25 /* XXX: totally non optimized */
986e461dc072 Initial revision
glantau
parents:
diff changeset
26
986e461dc072 Initial revision
glantau
parents:
diff changeset
27 static void yuv422_to_yuv420p(UINT8 *lum, UINT8 *cb, UINT8 *cr,
986e461dc072 Initial revision
glantau
parents:
diff changeset
28 UINT8 *src, int width, int height)
986e461dc072 Initial revision
glantau
parents:
diff changeset
29 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
30 int x, y;
986e461dc072 Initial revision
glantau
parents:
diff changeset
31 UINT8 *p = src;
986e461dc072 Initial revision
glantau
parents:
diff changeset
32
986e461dc072 Initial revision
glantau
parents:
diff changeset
33 for(y=0;y<height;y+=2) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
34 for(x=0;x<width;x+=2) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
35 lum[0] = p[0];
986e461dc072 Initial revision
glantau
parents:
diff changeset
36 cb[0] = p[1];
986e461dc072 Initial revision
glantau
parents:
diff changeset
37 lum[1] = p[2];
986e461dc072 Initial revision
glantau
parents:
diff changeset
38 cr[0] = p[3];
986e461dc072 Initial revision
glantau
parents:
diff changeset
39 p += 4;
986e461dc072 Initial revision
glantau
parents:
diff changeset
40 lum += 2;
986e461dc072 Initial revision
glantau
parents:
diff changeset
41 cb++;
986e461dc072 Initial revision
glantau
parents:
diff changeset
42 cr++;
986e461dc072 Initial revision
glantau
parents:
diff changeset
43 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
44 for(x=0;x<width;x+=2) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
45 lum[0] = p[0];
986e461dc072 Initial revision
glantau
parents:
diff changeset
46 lum[1] = p[2];
986e461dc072 Initial revision
glantau
parents:
diff changeset
47 p += 4;
986e461dc072 Initial revision
glantau
parents:
diff changeset
48 lum += 2;
986e461dc072 Initial revision
glantau
parents:
diff changeset
49 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
50 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
51 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
52
986e461dc072 Initial revision
glantau
parents:
diff changeset
53 #define SCALEBITS 8
986e461dc072 Initial revision
glantau
parents:
diff changeset
54 #define ONE_HALF (1 << (SCALEBITS - 1))
986e461dc072 Initial revision
glantau
parents:
diff changeset
55 #define FIX(x) ((int) ((x) * (1L<<SCALEBITS) + 0.5))
986e461dc072 Initial revision
glantau
parents:
diff changeset
56
986e461dc072 Initial revision
glantau
parents:
diff changeset
57 static void rgb24_to_yuv420p(UINT8 *lum, UINT8 *cb, UINT8 *cr,
986e461dc072 Initial revision
glantau
parents:
diff changeset
58 UINT8 *src, int width, int height)
986e461dc072 Initial revision
glantau
parents:
diff changeset
59 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
60 int wrap, wrap3, x, y;
986e461dc072 Initial revision
glantau
parents:
diff changeset
61 int r, g, b, r1, g1, b1;
986e461dc072 Initial revision
glantau
parents:
diff changeset
62 UINT8 *p;
986e461dc072 Initial revision
glantau
parents:
diff changeset
63
986e461dc072 Initial revision
glantau
parents:
diff changeset
64 wrap = width;
986e461dc072 Initial revision
glantau
parents:
diff changeset
65 wrap3 = width * 3;
986e461dc072 Initial revision
glantau
parents:
diff changeset
66 p = src;
986e461dc072 Initial revision
glantau
parents:
diff changeset
67 for(y=0;y<height;y+=2) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
68 for(x=0;x<width;x+=2) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
69 r = p[0];
986e461dc072 Initial revision
glantau
parents:
diff changeset
70 g = p[1];
986e461dc072 Initial revision
glantau
parents:
diff changeset
71 b = p[2];
986e461dc072 Initial revision
glantau
parents:
diff changeset
72 r1 = r;
986e461dc072 Initial revision
glantau
parents:
diff changeset
73 g1 = g;
986e461dc072 Initial revision
glantau
parents:
diff changeset
74 b1 = b;
986e461dc072 Initial revision
glantau
parents:
diff changeset
75 lum[0] = (FIX(0.29900) * r + FIX(0.58700) * g +
986e461dc072 Initial revision
glantau
parents:
diff changeset
76 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
986e461dc072 Initial revision
glantau
parents:
diff changeset
77 r = p[3];
986e461dc072 Initial revision
glantau
parents:
diff changeset
78 g = p[4];
986e461dc072 Initial revision
glantau
parents:
diff changeset
79 b = p[5];
986e461dc072 Initial revision
glantau
parents:
diff changeset
80 r1 += r;
986e461dc072 Initial revision
glantau
parents:
diff changeset
81 g1 += g;
986e461dc072 Initial revision
glantau
parents:
diff changeset
82 b1 += b;
986e461dc072 Initial revision
glantau
parents:
diff changeset
83 lum[1] = (FIX(0.29900) * r + FIX(0.58700) * g +
986e461dc072 Initial revision
glantau
parents:
diff changeset
84 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
986e461dc072 Initial revision
glantau
parents:
diff changeset
85 p += wrap3;
986e461dc072 Initial revision
glantau
parents:
diff changeset
86 lum += wrap;
986e461dc072 Initial revision
glantau
parents:
diff changeset
87
986e461dc072 Initial revision
glantau
parents:
diff changeset
88 r = p[0];
986e461dc072 Initial revision
glantau
parents:
diff changeset
89 g = p[1];
986e461dc072 Initial revision
glantau
parents:
diff changeset
90 b = p[2];
986e461dc072 Initial revision
glantau
parents:
diff changeset
91 r1 += r;
986e461dc072 Initial revision
glantau
parents:
diff changeset
92 g1 += g;
986e461dc072 Initial revision
glantau
parents:
diff changeset
93 b1 += b;
986e461dc072 Initial revision
glantau
parents:
diff changeset
94 lum[0] = (FIX(0.29900) * r + FIX(0.58700) * g +
986e461dc072 Initial revision
glantau
parents:
diff changeset
95 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
986e461dc072 Initial revision
glantau
parents:
diff changeset
96 r = p[3];
986e461dc072 Initial revision
glantau
parents:
diff changeset
97 g = p[4];
986e461dc072 Initial revision
glantau
parents:
diff changeset
98 b = p[5];
986e461dc072 Initial revision
glantau
parents:
diff changeset
99 r1 += r;
986e461dc072 Initial revision
glantau
parents:
diff changeset
100 g1 += g;
986e461dc072 Initial revision
glantau
parents:
diff changeset
101 b1 += b;
986e461dc072 Initial revision
glantau
parents:
diff changeset
102 lum[1] = (FIX(0.29900) * r + FIX(0.58700) * g +
986e461dc072 Initial revision
glantau
parents:
diff changeset
103 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
986e461dc072 Initial revision
glantau
parents:
diff changeset
104
986e461dc072 Initial revision
glantau
parents:
diff changeset
105 cb[0] = ((- FIX(0.16874) * r1 - FIX(0.33126) * g1 +
986e461dc072 Initial revision
glantau
parents:
diff changeset
106 FIX(0.50000) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) + 128;
986e461dc072 Initial revision
glantau
parents:
diff changeset
107 cr[0] = ((FIX(0.50000) * r1 - FIX(0.41869) * g1 -
986e461dc072 Initial revision
glantau
parents:
diff changeset
108 FIX(0.08131) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) + 128;
986e461dc072 Initial revision
glantau
parents:
diff changeset
109
986e461dc072 Initial revision
glantau
parents:
diff changeset
110 cb++;
986e461dc072 Initial revision
glantau
parents:
diff changeset
111 cr++;
986e461dc072 Initial revision
glantau
parents:
diff changeset
112 p += -wrap3 + 2 * 3;
986e461dc072 Initial revision
glantau
parents:
diff changeset
113 lum += -wrap + 2;
986e461dc072 Initial revision
glantau
parents:
diff changeset
114 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
115 p += wrap3;
986e461dc072 Initial revision
glantau
parents:
diff changeset
116 lum += wrap;
986e461dc072 Initial revision
glantau
parents:
diff changeset
117 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
118 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
119
583
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
120 static void rgba32_to_yuv420p(UINT8 *lum, UINT8 *cb, UINT8 *cr,
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
121 UINT8 *src, int width, int height)
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
122 {
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
123 int wrap, wrap4, x, y;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
124 int r, g, b, r1, g1, b1;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
125 UINT8 *p;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
126
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
127 wrap = width;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
128 wrap4 = width * 4;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
129 p = src;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
130 for(y=0;y<height;y+=2) {
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
131 for(x=0;x<width;x+=2) {
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
132 r = p[0];
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
133 g = p[1];
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
134 b = p[2];
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
135 r1 = r;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
136 g1 = g;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
137 b1 = b;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
138 lum[0] = (FIX(0.29900) * r + FIX(0.58700) * g +
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
139 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
140 r = p[4];
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
141 g = p[5];
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
142 b = p[6];
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
143 r1 += r;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
144 g1 += g;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
145 b1 += b;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
146 lum[1] = (FIX(0.29900) * r + FIX(0.58700) * g +
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
147 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
148 p += wrap4;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
149 lum += wrap;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
150
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
151 r = p[0];
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
152 g = p[1];
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
153 b = p[2];
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
154 r1 += r;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
155 g1 += g;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
156 b1 += b;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
157 lum[0] = (FIX(0.29900) * r + FIX(0.58700) * g +
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
158 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
159 r = p[4];
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
160 g = p[5];
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
161 b = p[6];
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
162 r1 += r;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
163 g1 += g;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
164 b1 += b;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
165 lum[1] = (FIX(0.29900) * r + FIX(0.58700) * g +
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
166 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
167
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
168 cb[0] = ((- FIX(0.16874) * r1 - FIX(0.33126) * g1 +
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
169 FIX(0.50000) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) + 128;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
170 cr[0] = ((FIX(0.50000) * r1 - FIX(0.41869) * g1 -
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
171 FIX(0.08131) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) + 128;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
172
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
173 cb++;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
174 cr++;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
175 p += -wrap4 + 2 * 4;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
176 lum += -wrap + 2;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
177 }
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
178 p += wrap4;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
179 lum += wrap;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
180 }
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
181 }
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
182
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
183 static void bgr24_to_yuv420p(UINT8 *lum, UINT8 *cb, UINT8 *cr,
986e461dc072 Initial revision
glantau
parents:
diff changeset
184 UINT8 *src, int width, int height)
986e461dc072 Initial revision
glantau
parents:
diff changeset
185 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
186 int wrap, wrap3, x, y;
986e461dc072 Initial revision
glantau
parents:
diff changeset
187 int r, g, b, r1, g1, b1;
986e461dc072 Initial revision
glantau
parents:
diff changeset
188 UINT8 *p;
986e461dc072 Initial revision
glantau
parents:
diff changeset
189
986e461dc072 Initial revision
glantau
parents:
diff changeset
190 wrap = width;
986e461dc072 Initial revision
glantau
parents:
diff changeset
191 wrap3 = width * 3;
986e461dc072 Initial revision
glantau
parents:
diff changeset
192 p = src;
986e461dc072 Initial revision
glantau
parents:
diff changeset
193 for(y=0;y<height;y+=2) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
194 for(x=0;x<width;x+=2) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
195 b = p[0];
986e461dc072 Initial revision
glantau
parents:
diff changeset
196 g = p[1];
986e461dc072 Initial revision
glantau
parents:
diff changeset
197 r = p[2];
986e461dc072 Initial revision
glantau
parents:
diff changeset
198 r1 = r;
986e461dc072 Initial revision
glantau
parents:
diff changeset
199 g1 = g;
986e461dc072 Initial revision
glantau
parents:
diff changeset
200 b1 = b;
986e461dc072 Initial revision
glantau
parents:
diff changeset
201 lum[0] = (FIX(0.29900) * r + FIX(0.58700) * g +
986e461dc072 Initial revision
glantau
parents:
diff changeset
202 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
986e461dc072 Initial revision
glantau
parents:
diff changeset
203 b = p[3];
986e461dc072 Initial revision
glantau
parents:
diff changeset
204 g = p[4];
986e461dc072 Initial revision
glantau
parents:
diff changeset
205 r = p[5];
986e461dc072 Initial revision
glantau
parents:
diff changeset
206 r1 += r;
986e461dc072 Initial revision
glantau
parents:
diff changeset
207 g1 += g;
986e461dc072 Initial revision
glantau
parents:
diff changeset
208 b1 += b;
986e461dc072 Initial revision
glantau
parents:
diff changeset
209 lum[1] = (FIX(0.29900) * r + FIX(0.58700) * g +
986e461dc072 Initial revision
glantau
parents:
diff changeset
210 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
986e461dc072 Initial revision
glantau
parents:
diff changeset
211 p += wrap3;
986e461dc072 Initial revision
glantau
parents:
diff changeset
212 lum += wrap;
986e461dc072 Initial revision
glantau
parents:
diff changeset
213
986e461dc072 Initial revision
glantau
parents:
diff changeset
214 b = p[0];
986e461dc072 Initial revision
glantau
parents:
diff changeset
215 g = p[1];
986e461dc072 Initial revision
glantau
parents:
diff changeset
216 r = p[2];
986e461dc072 Initial revision
glantau
parents:
diff changeset
217 r1 += r;
986e461dc072 Initial revision
glantau
parents:
diff changeset
218 g1 += g;
986e461dc072 Initial revision
glantau
parents:
diff changeset
219 b1 += b;
986e461dc072 Initial revision
glantau
parents:
diff changeset
220 lum[0] = (FIX(0.29900) * r + FIX(0.58700) * g +
986e461dc072 Initial revision
glantau
parents:
diff changeset
221 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
986e461dc072 Initial revision
glantau
parents:
diff changeset
222 b = p[3];
986e461dc072 Initial revision
glantau
parents:
diff changeset
223 g = p[4];
986e461dc072 Initial revision
glantau
parents:
diff changeset
224 r = p[5];
986e461dc072 Initial revision
glantau
parents:
diff changeset
225 r1 += r;
986e461dc072 Initial revision
glantau
parents:
diff changeset
226 g1 += g;
986e461dc072 Initial revision
glantau
parents:
diff changeset
227 b1 += b;
986e461dc072 Initial revision
glantau
parents:
diff changeset
228 lum[1] = (FIX(0.29900) * r + FIX(0.58700) * g +
986e461dc072 Initial revision
glantau
parents:
diff changeset
229 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
986e461dc072 Initial revision
glantau
parents:
diff changeset
230
986e461dc072 Initial revision
glantau
parents:
diff changeset
231 cb[0] = ((- FIX(0.16874) * r1 - FIX(0.33126) * g1 +
986e461dc072 Initial revision
glantau
parents:
diff changeset
232 FIX(0.50000) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) + 128;
986e461dc072 Initial revision
glantau
parents:
diff changeset
233 cr[0] = ((FIX(0.50000) * r1 - FIX(0.41869) * g1 -
986e461dc072 Initial revision
glantau
parents:
diff changeset
234 FIX(0.08131) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) + 128;
986e461dc072 Initial revision
glantau
parents:
diff changeset
235
986e461dc072 Initial revision
glantau
parents:
diff changeset
236 cb++;
986e461dc072 Initial revision
glantau
parents:
diff changeset
237 cr++;
986e461dc072 Initial revision
glantau
parents:
diff changeset
238 p += -wrap3 + 2 * 3;
986e461dc072 Initial revision
glantau
parents:
diff changeset
239 lum += -wrap + 2;
986e461dc072 Initial revision
glantau
parents:
diff changeset
240 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
241 p += wrap3;
986e461dc072 Initial revision
glantau
parents:
diff changeset
242 lum += wrap;
986e461dc072 Initial revision
glantau
parents:
diff changeset
243 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
244 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
245
583
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
246 static void bgra32_to_yuv420p(UINT8 *lum, UINT8 *cb, UINT8 *cr,
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
247 UINT8 *src, int width, int height)
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
248 {
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
249 int wrap, wrap4, x, y;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
250 int r, g, b, r1, g1, b1;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
251 UINT8 *p;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
252
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
253 wrap = width;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
254 wrap4 = width * 4;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
255 p = src;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
256 for(y=0;y<height;y+=2) {
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
257 for(x=0;x<width;x+=2) {
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
258 b = p[0];
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
259 g = p[1];
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
260 r = p[2];
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
261 r1 = r;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
262 g1 = g;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
263 b1 = b;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
264 lum[0] = (FIX(0.29900) * r + FIX(0.58700) * g +
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
265 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
266 b = p[4];
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
267 g = p[5];
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
268 r = p[6];
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
269 r1 += r;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
270 g1 += g;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
271 b1 += b;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
272 lum[1] = (FIX(0.29900) * r + FIX(0.58700) * g +
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
273 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
274 p += wrap4;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
275 lum += wrap;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
276
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
277 b = p[0];
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
278 g = p[1];
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
279 r = p[2];
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
280 r1 += r;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
281 g1 += g;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
282 b1 += b;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
283 lum[0] = (FIX(0.29900) * r + FIX(0.58700) * g +
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
284 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
285 b = p[4];
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
286 g = p[5];
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
287 r = p[6];
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
288 r1 += r;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
289 g1 += g;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
290 b1 += b;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
291 lum[1] = (FIX(0.29900) * r + FIX(0.58700) * g +
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
292 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
293
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
294 cb[0] = ((- FIX(0.16874) * r1 - FIX(0.33126) * g1 +
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
295 FIX(0.50000) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) + 128;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
296 cr[0] = ((FIX(0.50000) * r1 - FIX(0.41869) * g1 -
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
297 FIX(0.08131) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) + 128;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
298
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
299 cb++;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
300 cr++;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
301 p += -wrap4 + 2 * 4;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
302 lum += -wrap + 2;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
303 }
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
304 p += wrap4;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
305 lum += wrap;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
306 }
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
307 }
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
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
736
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
402 /* 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
403 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
404 UINT8 *src, int src_wrap,
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
405 int width, int height)
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
406 {
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
407 int w, c;
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
408 UINT8 *s1, *s2, *d;
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
409
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
410 for(;height > 0; height -= 2) {
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
411 s1 = src;
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
412 s2 = src + src_wrap;
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
413 d = dst;
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
414 for(w = width;w > 0; w--) {
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
415 c = (s1[0] + s2[0]) >> 1;
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
416 d[0] = c;
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
417 d[1] = c;
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
418 s1++;
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
419 s2++;
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
420 d += 2;
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
421 }
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
422 src += src_wrap * 2;
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
423 dst += dst_wrap;
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
424 }
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
425 }
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
426
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
427 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
428 UINT8 *src, int src_wrap,
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
429 int width, int height)
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
430 {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
431 for(;height > 0; height--) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
432 memcpy(dst, src, width);
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
433 dst += dst_wrap;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
434 src += src_wrap;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
435 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
436 }
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 #define SCALE_BITS 10
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
439
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
440 #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
441 #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
442 #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
443 #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
444 #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
445
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
446 #define RGBOUT(r, g, b, y1)\
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
447 {\
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
448 y = (y1 - 16) * C_Y;\
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
449 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
450 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
451 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
452 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
453
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
454 /* XXX: no chroma interpolating is done */
583
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
455 static void yuv420p_to_bgra32(AVPicture *dst, AVPicture *src,
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
456 int width, int height)
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
457 {
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
458 UINT8 *y1_ptr, *y2_ptr, *cb_ptr, *cr_ptr, *d, *d1, *d2;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
459 int w, y, cb, cr, r_add, g_add, b_add, width2;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
460 UINT8 *cm = cropTbl + MAX_NEG_CROP;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
461
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
462 d = dst->data[0];
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
463 y1_ptr = src->data[0];
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
464 cb_ptr = src->data[1];
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
465 cr_ptr = src->data[2];
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
466 width2 = width >> 1;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
467 for(;height > 0; height -= 2) {
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
468 d1 = d;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
469 d2 = d + dst->linesize[0];
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
470 y2_ptr = y1_ptr + src->linesize[0];
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
471 for(w = width2; w > 0; w --) {
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
472 cb = cb_ptr[0] - 128;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
473 cr = cr_ptr[0] - 128;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
474 r_add = C_RV * cr + (1 << (SCALE_BITS - 1));
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
475 g_add = - C_GU * cb - C_GV * cr + (1 << (SCALE_BITS - 1));
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
476 b_add = C_BU * cb + (1 << (SCALE_BITS - 1));
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
477
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
478 /* output 4 pixels */
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
479 RGBOUT(d1[2], d1[1], d1[0], y1_ptr[0]);
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
480 RGBOUT(d1[6], d1[5], d1[4], y1_ptr[1]);
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
481 RGBOUT(d2[2], d2[1], d2[0], y2_ptr[0]);
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
482 RGBOUT(d2[6], d2[5], d2[4], y2_ptr[1]);
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
483
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
484 d1[3] = d1[7] = d2[3] = d2[7] = 255;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
485
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
486 d1 += 8;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
487 d2 += 8;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
488 y1_ptr += 2;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
489 y2_ptr += 2;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
490 cb_ptr++;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
491 cr_ptr++;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
492 }
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
493 d += 2 * dst->linesize[0];
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
494 y1_ptr += 2 * src->linesize[0] - width;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
495 cb_ptr += src->linesize[1] - width2;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
496 cr_ptr += src->linesize[2] - width2;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
497 }
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
498 }
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
499
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
500 /* XXX: no chroma interpolating is done */
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
501 static void yuv420p_to_rgba32(AVPicture *dst, AVPicture *src,
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
502 int width, int height)
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
503 {
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
504 UINT8 *y1_ptr, *y2_ptr, *cb_ptr, *cr_ptr, *d, *d1, *d2;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
505 int w, y, cb, cr, r_add, g_add, b_add, width2;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
506 UINT8 *cm = cropTbl + MAX_NEG_CROP;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
507
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
508 d = dst->data[0];
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
509 y1_ptr = src->data[0];
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
510 cb_ptr = src->data[1];
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
511 cr_ptr = src->data[2];
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
512 width2 = width >> 1;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
513 for(;height > 0; height -= 2) {
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
514 d1 = d;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
515 d2 = d + dst->linesize[0];
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
516 y2_ptr = y1_ptr + src->linesize[0];
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
517 for(w = width2; w > 0; w --) {
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
518 cb = cb_ptr[0] - 128;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
519 cr = cr_ptr[0] - 128;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
520 r_add = C_RV * cr + (1 << (SCALE_BITS - 1));
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
521 g_add = - C_GU * cb - C_GV * cr + (1 << (SCALE_BITS - 1));
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
522 b_add = C_BU * cb + (1 << (SCALE_BITS - 1));
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
523
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
524 /* output 4 pixels */
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
525 RGBOUT(d1[0], d1[1], d1[2], y1_ptr[0]);
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
526 RGBOUT(d1[4], d1[5], d1[6], y1_ptr[1]);
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
527 RGBOUT(d2[0], d2[1], d2[2], y2_ptr[0]);
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
528 RGBOUT(d2[4], d2[5], d2[6], y2_ptr[1]);
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
529
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
530 d1[3] = d1[7] = d2[3] = d2[7] = 255;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
531
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
532 d1 += 8;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
533 d2 += 8;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
534 y1_ptr += 2;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
535 y2_ptr += 2;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
536 cb_ptr++;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
537 cr_ptr++;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
538 }
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
539 d += 2 * dst->linesize[0];
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
540 y1_ptr += 2 * src->linesize[0] - width;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
541 cb_ptr += src->linesize[1] - width2;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
542 cr_ptr += src->linesize[2] - width2;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
543 }
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
544 }
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
545
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
546 /* 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
547 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
548 int width, int height)
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
549 {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
550 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
551 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
552 UINT8 *cm = cropTbl + MAX_NEG_CROP;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
553
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
554 d = dst->data[0];
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
555 y1_ptr = src->data[0];
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
556 cb_ptr = src->data[1];
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
557 cr_ptr = src->data[2];
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
558 width2 = width >> 1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
559 for(;height > 0; height -= 2) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
560 d1 = d;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
561 d2 = d + dst->linesize[0];
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
562 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
563 for(w = width2; w > 0; w --) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
564 cb = cb_ptr[0] - 128;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
565 cr = cr_ptr[0] - 128;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
566 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
567 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
568 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
569
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
570 /* output 4 pixels */
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
571 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
572 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
573 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
574 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
575
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
576 d1 += 6;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
577 d2 += 6;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
578 y1_ptr += 2;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
579 y2_ptr += 2;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
580 cb_ptr++;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
581 cr_ptr++;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
582 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
583 d += 2 * dst->linesize[0];
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
584 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
585 cb_ptr += src->linesize[1] - width2;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
586 cr_ptr += src->linesize[2] - width2;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
587 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
588 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
589
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
590 /* XXX: no chroma interpolating is done */
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
591 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
592 int width, int height)
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
593 {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
594 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
595 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
596 UINT8 *cm = cropTbl + MAX_NEG_CROP;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
597
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
598 d = dst->data[0];
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
599 y1_ptr = src->data[0];
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
600 cb_ptr = src->data[1];
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
601 cr_ptr = src->data[2];
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
602 width2 = width >> 1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
603 for(;height > 0; height --) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
604 d1 = d;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
605 for(w = width2; w > 0; w --) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
606 cb = cb_ptr[0] - 128;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
607 cr = cr_ptr[0] - 128;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
608 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
609 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
610 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
611
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
612 /* output 2 pixels */
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
613 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
614 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
615
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
616 d1 += 6;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
617 y1_ptr += 2;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
618 cb_ptr++;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
619 cr_ptr++;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
620 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
621 d += dst->linesize[0];
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
622 y1_ptr += src->linesize[0] - width;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
623 cb_ptr += src->linesize[1] - width2;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
624 cr_ptr += src->linesize[2] - width2;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
625 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
626 }
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 /* 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
629 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
630 AVPicture *src, int pix_fmt,
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
631 int width, int height)
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
632 {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
633 int i;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
634
315
40d8092e2ff0 * using pixtype as enum - by Philip Gladstone
kabi
parents: 64
diff changeset
635 assert(pix_fmt != PIX_FMT_ANY && dst_pix_fmt != PIX_FMT_ANY);
40d8092e2ff0 * using pixtype as enum - by Philip Gladstone
kabi
parents: 64
diff changeset
636
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
637 if (dst_pix_fmt == pix_fmt) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
638 switch(pix_fmt) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
639 case PIX_FMT_YUV420P:
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
640 for(i=0;i<3;i++) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
641 if (i == 1) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
642 width >>= 1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
643 height >>= 1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
644 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
645 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
646 src->data[i], src->linesize[i],
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
647 width, height);
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
648 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
649 break;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
650 default:
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
651 return -1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
652 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
653 } 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
654
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
655 switch(pix_fmt) {
736
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
656 case PIX_FMT_YUV411P:
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
657 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
658 src->data[0], src->linesize[0],
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
659 width, height);
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
660 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
661 src->data[1], src->linesize[1],
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
662 width / 4, height);
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
663 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
664 src->data[2], src->linesize[2],
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
665 width / 4, height);
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
666 break;
576
9aa5f0d0124e YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents: 440
diff changeset
667 case PIX_FMT_YUV410P:
9aa5f0d0124e YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents: 440
diff changeset
668 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
669 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
670 width, height);
9aa5f0d0124e YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents: 440
diff changeset
671 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
672 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
673 width/2, height/2);
9aa5f0d0124e YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents: 440
diff changeset
674 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
675 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
676 width/2, height/2);
9aa5f0d0124e YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents: 440
diff changeset
677 break;
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
678 case PIX_FMT_YUV420P:
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
679 for(i=0;i<3;i++) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
680 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
681 src->data[i], src->linesize[i],
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
682 width, height);
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
683 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
684 break;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
685 case PIX_FMT_YUV422P:
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
686 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
687 src->data[0], src->linesize[0],
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
688 width, height);
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
689 width >>= 1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
690 height >>= 1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
691 for(i=1;i<3;i++) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
692 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
693 src->data[i], src->linesize[i],
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
694 width, height);
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 break;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
697 case PIX_FMT_YUV444P:
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
698 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
699 src->data[0], src->linesize[0],
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
700 width, height);
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
701 width >>= 1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
702 height >>= 1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
703 for(i=1;i<3;i++) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
704 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
705 src->data[i], src->linesize[i],
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
706 width, height);
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
707 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
708 break;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
709 case PIX_FMT_YUV422:
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
710 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
711 src->data[0], width, height);
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
712 break;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
713 case PIX_FMT_RGB24:
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
714 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
715 src->data[0], width, height);
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
716 break;
583
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
717 case PIX_FMT_RGBA32:
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
718 rgba32_to_yuv420p(dst->data[0], dst->data[1], dst->data[2],
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
719 src->data[0], width, height);
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
720 break;
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
721 case PIX_FMT_BGR24:
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
722 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
723 src->data[0], width, height);
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
724 break;
583
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
725 case PIX_FMT_BGRA32:
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
726 bgra32_to_yuv420p(dst->data[0], dst->data[1], dst->data[2],
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
727 src->data[0], width, height);
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
728 break;
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
729 default:
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
730 return -1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
731 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
732 } 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
733 switch(pix_fmt) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
734 case PIX_FMT_YUV420P:
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
735 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
736 break;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
737 case PIX_FMT_YUV422P:
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
738 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
739 break;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
740 default:
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
741 return -1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
742 }
583
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
743 } else if (dst_pix_fmt == PIX_FMT_RGBA32) {
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
744 switch(pix_fmt) {
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
745 case PIX_FMT_YUV420P:
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
746 yuv420p_to_rgba32(dst, src, width, height);
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
747 break;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
748 default:
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
749 return -1;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
750 }
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
751 } else if (dst_pix_fmt == PIX_FMT_BGRA32) {
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
752 switch(pix_fmt) {
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
753 case PIX_FMT_YUV420P:
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
754 yuv420p_to_bgra32(dst, src, width, height);
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
755 break;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
756 default:
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
757 return -1;
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
758 }
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
759 } else {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
760 return -1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
761 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
762 return 0;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
763 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
764
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
765 /* 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
766 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
767 int size)
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
768 {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
769 UINT8 *cm = cropTbl + MAX_NEG_CROP;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
770 int sum;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
771 UINT8 *s;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
772
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
773 for(;size > 0;size--) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
774 s = src;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
775 sum = -s[0];
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
776 s += src_wrap;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
777 sum += s[0] << 2;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
778 s += src_wrap;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
779 sum += s[0] << 1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
780 s += src_wrap;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
781 sum += s[0] << 2;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
782 s += src_wrap;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
783 sum += -s[0];
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
784 dst[0] = cm[(sum + 4) >> 3];
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
785 dst++;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
786 src++;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
787 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
788 }
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 /* 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
791 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
792 against the top field. */
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
793 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
794 UINT8 *src1, int src_wrap,
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
795 int width, int height)
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 UINT8 *src, *ptr;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
798 int y, y1, i;
64
5aa6292a1660 win32 fixes
glantau
parents: 52
diff changeset
799 UINT8 *buf;
5aa6292a1660 win32 fixes
glantau
parents: 52
diff changeset
800
396
fce0a2520551 removed useless header includes - use av memory functions
glantau
parents: 315
diff changeset
801 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
802
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
803 src = src1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
804 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
805 /* copy top field line */
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
806 memcpy(dst, src, width);
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
807 dst += dst_wrap;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
808 src += (1 - 2) * src_wrap;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
809 y1 = y - 2;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
810 if (y1 >= 0 && (y1 + 4) < height) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
811 /* fast case : no edges */
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
812 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
813 } else {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
814 /* 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
815 ptr = buf;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
816 for(i=0;i<5;i++) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
817 if (y1 < 0)
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
818 memcpy(ptr, src1, width);
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
819 else if (y1 >= height)
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
820 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
821 else
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
822 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
823 y1++;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
824 ptr += width;
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_line(dst, buf, width, width);
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
827 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
828 dst += dst_wrap;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
829 src += (2 + 1) * src_wrap;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
830 }
396
fce0a2520551 removed useless header includes - use av memory functions
glantau
parents: 315
diff changeset
831 av_free(buf);
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
832 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
833
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
834
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
835 /* 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
836 int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
837 int pix_fmt, int width, int height)
986e461dc072 Initial revision
glantau
parents:
diff changeset
838 {
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
839 int i;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
840
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
841 if (pix_fmt != PIX_FMT_YUV420P &&
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
842 pix_fmt != PIX_FMT_YUV422P &&
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
843 pix_fmt != PIX_FMT_YUV444P)
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
844 return -1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
845 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
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 for(i=0;i<3;i++) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
849 if (i == 1) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
850 switch(pix_fmt) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
851 case PIX_FMT_YUV420P:
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
852 width >>= 1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
853 height >>= 1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
854 break;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
855 case PIX_FMT_YUV422P:
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
856 width >>= 1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
857 break;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
858 default:
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
859 break;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
860 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
861 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
862 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
863 src->data[i], src->linesize[i],
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
864 width, height);
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
865 }
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
866 return 0;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
867 }
440
000aeeac27a2 * started to cleanup name clashes for onetime compilation
kabi
parents: 429
diff changeset
868
000aeeac27a2 * started to cleanup name clashes for onetime compilation
kabi
parents: 429
diff changeset
869 #undef FIX