annotate imgconvert.c @ 125:42a36eb08c8d libavcodec

* and finaly avoid deadlock at the end of audio stream
author kabi
date Tue, 23 Oct 2001 20:20:01 +0000
parents 5aa6292a1660
children 40d8092e2ff0
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
986e461dc072 Initial revision
glantau
parents:
diff changeset
3 * Copyright (c) 2001 Gerard Lantau.
986e461dc072 Initial revision
glantau
parents:
diff changeset
4 *
986e461dc072 Initial revision
glantau
parents:
diff changeset
5 * This program is free software; you can redistribute it and/or modify
986e461dc072 Initial revision
glantau
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
986e461dc072 Initial revision
glantau
parents:
diff changeset
7 * the Free Software Foundation; either version 2 of the License, or
986e461dc072 Initial revision
glantau
parents:
diff changeset
8 * (at your option) any later version.
986e461dc072 Initial revision
glantau
parents:
diff changeset
9 *
986e461dc072 Initial revision
glantau
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
986e461dc072 Initial revision
glantau
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
986e461dc072 Initial revision
glantau
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
986e461dc072 Initial revision
glantau
parents:
diff changeset
13 * GNU General Public License for more details.
986e461dc072 Initial revision
glantau
parents:
diff changeset
14 *
986e461dc072 Initial revision
glantau
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
986e461dc072 Initial revision
glantau
parents:
diff changeset
16 * along with this program; if not, write to the Free Software
986e461dc072 Initial revision
glantau
parents:
diff changeset
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
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
986e461dc072 Initial revision
glantau
parents:
diff changeset
120 static void bgr24_to_yuv420p(UINT8 *lum, UINT8 *cb, UINT8 *cr,
986e461dc072 Initial revision
glantau
parents:
diff changeset
121 UINT8 *src, int width, int height)
986e461dc072 Initial revision
glantau
parents:
diff changeset
122 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
123 int wrap, wrap3, x, y;
986e461dc072 Initial revision
glantau
parents:
diff changeset
124 int r, g, b, r1, g1, b1;
986e461dc072 Initial revision
glantau
parents:
diff changeset
125 UINT8 *p;
986e461dc072 Initial revision
glantau
parents:
diff changeset
126
986e461dc072 Initial revision
glantau
parents:
diff changeset
127 wrap = width;
986e461dc072 Initial revision
glantau
parents:
diff changeset
128 wrap3 = width * 3;
986e461dc072 Initial revision
glantau
parents:
diff changeset
129 p = src;
986e461dc072 Initial revision
glantau
parents:
diff changeset
130 for(y=0;y<height;y+=2) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
131 for(x=0;x<width;x+=2) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
132 b = p[0];
986e461dc072 Initial revision
glantau
parents:
diff changeset
133 g = p[1];
986e461dc072 Initial revision
glantau
parents:
diff changeset
134 r = p[2];
986e461dc072 Initial revision
glantau
parents:
diff changeset
135 r1 = r;
986e461dc072 Initial revision
glantau
parents:
diff changeset
136 g1 = g;
986e461dc072 Initial revision
glantau
parents:
diff changeset
137 b1 = b;
986e461dc072 Initial revision
glantau
parents:
diff changeset
138 lum[0] = (FIX(0.29900) * r + FIX(0.58700) * g +
986e461dc072 Initial revision
glantau
parents:
diff changeset
139 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
986e461dc072 Initial revision
glantau
parents:
diff changeset
140 b = p[3];
986e461dc072 Initial revision
glantau
parents:
diff changeset
141 g = p[4];
986e461dc072 Initial revision
glantau
parents:
diff changeset
142 r = p[5];
986e461dc072 Initial revision
glantau
parents:
diff changeset
143 r1 += r;
986e461dc072 Initial revision
glantau
parents:
diff changeset
144 g1 += g;
986e461dc072 Initial revision
glantau
parents:
diff changeset
145 b1 += b;
986e461dc072 Initial revision
glantau
parents:
diff changeset
146 lum[1] = (FIX(0.29900) * r + FIX(0.58700) * g +
986e461dc072 Initial revision
glantau
parents:
diff changeset
147 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
986e461dc072 Initial revision
glantau
parents:
diff changeset
148 p += wrap3;
986e461dc072 Initial revision
glantau
parents:
diff changeset
149 lum += wrap;
986e461dc072 Initial revision
glantau
parents:
diff changeset
150
986e461dc072 Initial revision
glantau
parents:
diff changeset
151 b = p[0];
986e461dc072 Initial revision
glantau
parents:
diff changeset
152 g = p[1];
986e461dc072 Initial revision
glantau
parents:
diff changeset
153 r = p[2];
986e461dc072 Initial revision
glantau
parents:
diff changeset
154 r1 += r;
986e461dc072 Initial revision
glantau
parents:
diff changeset
155 g1 += g;
986e461dc072 Initial revision
glantau
parents:
diff changeset
156 b1 += b;
986e461dc072 Initial revision
glantau
parents:
diff changeset
157 lum[0] = (FIX(0.29900) * r + FIX(0.58700) * g +
986e461dc072 Initial revision
glantau
parents:
diff changeset
158 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
986e461dc072 Initial revision
glantau
parents:
diff changeset
159 b = p[3];
986e461dc072 Initial revision
glantau
parents:
diff changeset
160 g = p[4];
986e461dc072 Initial revision
glantau
parents:
diff changeset
161 r = p[5];
986e461dc072 Initial revision
glantau
parents:
diff changeset
162 r1 += r;
986e461dc072 Initial revision
glantau
parents:
diff changeset
163 g1 += g;
986e461dc072 Initial revision
glantau
parents:
diff changeset
164 b1 += b;
986e461dc072 Initial revision
glantau
parents:
diff changeset
165 lum[1] = (FIX(0.29900) * r + FIX(0.58700) * g +
986e461dc072 Initial revision
glantau
parents:
diff changeset
166 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
986e461dc072 Initial revision
glantau
parents:
diff changeset
167
986e461dc072 Initial revision
glantau
parents:
diff changeset
168 cb[0] = ((- FIX(0.16874) * r1 - FIX(0.33126) * g1 +
986e461dc072 Initial revision
glantau
parents:
diff changeset
169 FIX(0.50000) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) + 128;
986e461dc072 Initial revision
glantau
parents:
diff changeset
170 cr[0] = ((FIX(0.50000) * r1 - FIX(0.41869) * g1 -
986e461dc072 Initial revision
glantau
parents:
diff changeset
171 FIX(0.08131) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) + 128;
986e461dc072 Initial revision
glantau
parents:
diff changeset
172
986e461dc072 Initial revision
glantau
parents:
diff changeset
173 cb++;
986e461dc072 Initial revision
glantau
parents:
diff changeset
174 cr++;
986e461dc072 Initial revision
glantau
parents:
diff changeset
175 p += -wrap3 + 2 * 3;
986e461dc072 Initial revision
glantau
parents:
diff changeset
176 lum += -wrap + 2;
986e461dc072 Initial revision
glantau
parents:
diff changeset
177 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
178 p += wrap3;
986e461dc072 Initial revision
glantau
parents:
diff changeset
179 lum += wrap;
986e461dc072 Initial revision
glantau
parents:
diff changeset
180 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
181 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
182
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
183 /* XXX: use generic filter ? */
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
184 /* 1x2 -> 1x1 */
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
185 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
186 UINT8 *src, int src_wrap,
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
187 int width, int height)
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
188 {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
189 int w;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
190 UINT8 *s1, *s2, *d;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
191
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
192 for(;height > 0; height--) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
193 s1 = src;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
194 s2 = s1 + src_wrap;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
195 d = dst;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
196 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
197 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
198 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
199 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
200 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
201 s1 += 4;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
202 s2 += 4;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
203 d += 4;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
204 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
205 for(;w > 0; w--) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
206 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
207 s1++;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
208 s2++;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
209 d++;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
210 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
211 src += 2 * src_wrap;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
212 dst += dst_wrap;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
213 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
214 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
215
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
216 /* 2x2 -> 1x1 */
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
217 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
218 UINT8 *src, int src_wrap,
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
219 int width, int height)
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
220 {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
221 int w;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
222 UINT8 *s1, *s2, *d;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
223
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
224 for(;height > 0; height--) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
225 s1 = src;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
226 s2 = s1 + src_wrap;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
227 d = dst;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
228 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
229 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
230 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
231 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
232 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
233 s1 += 8;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
234 s2 += 8;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
235 d += 4;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
236 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
237 for(;w > 0; w--) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
238 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
239 s1 += 2;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
240 s2 += 2;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
241 d++;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
242 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
243 src += 2 * src_wrap;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
244 dst += dst_wrap;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
245 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
246 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
247
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
248 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
249 UINT8 *src, int src_wrap,
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
250 int width, int height)
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
251 {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
252 for(;height > 0; height--) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
253 memcpy(dst, src, width);
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
254 dst += dst_wrap;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
255 src += src_wrap;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
256 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
257 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
258
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
259 #define SCALE_BITS 10
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
260
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
261 #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
262 #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
263 #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
264 #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
265 #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
266
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
267 #define RGBOUT(r, g, b, y1)\
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
268 {\
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
269 y = (y1 - 16) * C_Y;\
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
270 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
271 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
272 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
273 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
274
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
275 /* XXX: no chroma interpolating is done */
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
276 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
277 int width, int height)
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
278 {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
279 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
280 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
281 UINT8 *cm = cropTbl + MAX_NEG_CROP;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
282
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
283 d = dst->data[0];
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
284 y1_ptr = src->data[0];
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
285 cb_ptr = src->data[1];
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
286 cr_ptr = src->data[2];
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
287 width2 = width >> 1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
288 for(;height > 0; height -= 2) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
289 d1 = d;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
290 d2 = d + dst->linesize[0];
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
291 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
292 for(w = width2; w > 0; w --) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
293 cb = cb_ptr[0] - 128;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
294 cr = cr_ptr[0] - 128;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
295 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
296 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
297 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
298
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
299 /* output 4 pixels */
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
300 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
301 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
302 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
303 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
304
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
305 d1 += 6;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
306 d2 += 6;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
307 y1_ptr += 2;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
308 y2_ptr += 2;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
309 cb_ptr++;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
310 cr_ptr++;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
311 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
312 d += 2 * dst->linesize[0];
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
313 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
314 cb_ptr += src->linesize[1] - width2;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
315 cr_ptr += src->linesize[2] - width2;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
316 }
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
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
319 /* XXX: no chroma interpolating is done */
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
320 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
321 int width, int height)
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
322 {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
323 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
324 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
325 UINT8 *cm = cropTbl + MAX_NEG_CROP;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
326
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
327 d = dst->data[0];
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
328 y1_ptr = src->data[0];
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
329 cb_ptr = src->data[1];
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
330 cr_ptr = src->data[2];
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
331 width2 = width >> 1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
332 for(;height > 0; height --) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
333 d1 = d;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
334 for(w = width2; w > 0; w --) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
335 cb = cb_ptr[0] - 128;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
336 cr = cr_ptr[0] - 128;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
337 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
338 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
339 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
340
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
341 /* output 2 pixels */
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
342 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
343 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
344
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
345 d1 += 6;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
346 y1_ptr += 2;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
347 cb_ptr++;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
348 cr_ptr++;
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 d += dst->linesize[0];
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
351 y1_ptr += src->linesize[0] - width;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
352 cb_ptr += src->linesize[1] - width2;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
353 cr_ptr += src->linesize[2] - width2;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
354 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
355 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
356
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
357 /* 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
358 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
359 AVPicture *src, int pix_fmt,
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
360 int width, int height)
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
361 {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
362 int i;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
363
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
364 if (dst_pix_fmt == pix_fmt) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
365 switch(pix_fmt) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
366 case PIX_FMT_YUV420P:
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
367 for(i=0;i<3;i++) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
368 if (i == 1) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
369 width >>= 1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
370 height >>= 1;
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 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
373 src->data[i], src->linesize[i],
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
374 width, height);
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
375 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
376 break;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
377 default:
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
378 return -1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
379 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
380 } 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
381
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
382 switch(pix_fmt) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
383 case PIX_FMT_YUV420P:
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
384 for(i=0;i<3;i++) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
385 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
386 src->data[i], src->linesize[i],
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
387 width, height);
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
388 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
389 break;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
390 case PIX_FMT_YUV422P:
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
391 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
392 src->data[0], src->linesize[0],
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
393 width, height);
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
394 width >>= 1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
395 height >>= 1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
396 for(i=1;i<3;i++) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
397 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
398 src->data[i], src->linesize[i],
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
399 width, height);
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
400 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
401 break;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
402 case PIX_FMT_YUV444P:
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
403 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
404 src->data[0], src->linesize[0],
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
405 width, height);
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
406 width >>= 1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
407 height >>= 1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
408 for(i=1;i<3;i++) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
409 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
410 src->data[i], src->linesize[i],
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
411 width, height);
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
412 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
413 break;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
414 case PIX_FMT_YUV422:
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
415 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
416 src->data[0], width, height);
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
417 break;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
418 case PIX_FMT_RGB24:
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
419 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
420 src->data[0], width, height);
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
421 break;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
422 case PIX_FMT_BGR24:
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
423 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
424 src->data[0], width, height);
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
425 break;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
426 default:
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
427 return -1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
428 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
429 } 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
430 switch(pix_fmt) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
431 case PIX_FMT_YUV420P:
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
432 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
433 break;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
434 case PIX_FMT_YUV422P:
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
435 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
436 break;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
437 default:
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
438 return -1;
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 } else {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
441 return -1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
442 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
443 return 0;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
444 }
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 /* 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
447 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
448 int size)
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
449 {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
450 UINT8 *cm = cropTbl + MAX_NEG_CROP;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
451 int sum;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
452 UINT8 *s;
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 for(;size > 0;size--) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
455 s = src;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
456 sum = -s[0];
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
457 s += src_wrap;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
458 sum += s[0] << 2;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
459 s += src_wrap;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
460 sum += s[0] << 1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
461 s += src_wrap;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
462 sum += s[0] << 2;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
463 s += src_wrap;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
464 sum += -s[0];
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
465 dst[0] = cm[(sum + 4) >> 3];
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
466 dst++;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
467 src++;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
468 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
469 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
470
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
471 /* 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
472 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
473 against the top field. */
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
474 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
475 UINT8 *src1, int src_wrap,
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
476 int width, int height)
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
477 {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
478 UINT8 *src, *ptr;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
479 int y, y1, i;
64
5aa6292a1660 win32 fixes
glantau
parents: 52
diff changeset
480 UINT8 *buf;
5aa6292a1660 win32 fixes
glantau
parents: 52
diff changeset
481
5aa6292a1660 win32 fixes
glantau
parents: 52
diff changeset
482 buf= (UINT8*) malloc(5 * width);
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
483
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
484 src = src1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
485 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
486 /* copy top field line */
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
487 memcpy(dst, src, width);
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
488 dst += dst_wrap;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
489 src += (1 - 2) * src_wrap;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
490 y1 = y - 2;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
491 if (y1 >= 0 && (y1 + 4) < height) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
492 /* fast case : no edges */
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
493 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
494 } else {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
495 /* 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
496 ptr = buf;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
497 for(i=0;i<5;i++) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
498 if (y1 < 0)
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
499 memcpy(ptr, src1, width);
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
500 else if (y1 >= height)
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
501 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
502 else
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
503 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
504 y1++;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
505 ptr += width;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
506 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
507 deinterlace_line(dst, buf, width, width);
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
508 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
509 dst += dst_wrap;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
510 src += (2 + 1) * src_wrap;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
511 }
64
5aa6292a1660 win32 fixes
glantau
parents: 52
diff changeset
512 free(buf);
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
513 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
514
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
515
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
516 /* 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
517 int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
518 int pix_fmt, int width, int height)
986e461dc072 Initial revision
glantau
parents:
diff changeset
519 {
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
520 int i;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
521
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
522 if (pix_fmt != PIX_FMT_YUV420P &&
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
523 pix_fmt != PIX_FMT_YUV422P &&
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
524 pix_fmt != PIX_FMT_YUV444P)
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
525 return -1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
526 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
527 return -1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
528
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
529 for(i=0;i<3;i++) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
530 if (i == 1) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
531 switch(pix_fmt) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
532 case PIX_FMT_YUV420P:
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
533 width >>= 1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
534 height >>= 1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
535 break;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
536 case PIX_FMT_YUV422P:
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
537 width >>= 1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
538 break;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
539 default:
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
540 break;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
541 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
542 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
543 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
544 src->data[i], src->linesize[i],
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
545 width, height);
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
546 }
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
547 return 0;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
548 }