Mercurial > mplayer.hg
annotate libswscale/yuv2rgb.c @ 30455:cfebff6a5ef9
Use vo_x11_clearwindow instead of XClearWindow, both for consistency and also
because vo_x11_clearwindow works as intended also when the background is
set to None.
author | reimar |
---|---|
date | Wed, 03 Feb 2010 21:12:23 +0000 |
parents | 2eea1f09e2c5 |
children | ef00ce26e9b5 |
rev | line source |
---|---|
28688 | 1 /* |
2 * software YUV to RGB converter | |
3 * | |
4 * Copyright (C) 2009 Konstantin Shishkov | |
5 * | |
6 * 1,4,8bpp support and context / deglobalize stuff | |
7 * by Michael Niedermayer (michaelni@gmx.at) | |
8 * | |
9 * This file is part of FFmpeg. | |
10 * | |
11 * FFmpeg is free software; you can redistribute it and/or | |
12 * modify it under the terms of the GNU Lesser General Public | |
13 * License as published by the Free Software Foundation; either | |
14 * version 2.1 of the License, or (at your option) any later version. | |
15 * | |
16 * FFmpeg is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
19 * Lesser General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU Lesser General Public | |
22 * License along with FFmpeg; if not, write to the Free Software | |
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
24 */ | |
25 | |
26 #include <stdio.h> | |
27 #include <stdlib.h> | |
28 #include <inttypes.h> | |
29 #include <assert.h> | |
30 | |
31 #include "config.h" | |
32 #include "rgb2rgb.h" | |
33 #include "swscale.h" | |
34 #include "swscale_internal.h" | |
28957 | 35 #include "libavutil/x86_cpu.h" |
28688 | 36 |
37 extern const uint8_t dither_8x8_32[8][8]; | |
38 extern const uint8_t dither_8x8_73[8][8]; | |
39 extern const uint8_t dither_8x8_220[8][8]; | |
40 | |
41 const int32_t ff_yuv2rgb_coeffs[8][4] = { | |
42 {117504, 138453, 13954, 34903}, /* no sequence_display_extension */ | |
43 {117504, 138453, 13954, 34903}, /* ITU-R Rec. 709 (1990) */ | |
44 {104597, 132201, 25675, 53279}, /* unspecified */ | |
45 {104597, 132201, 25675, 53279}, /* reserved */ | |
46 {104448, 132798, 24759, 53109}, /* FCC */ | |
47 {104597, 132201, 25675, 53279}, /* ITU-R Rec. 624-4 System B, G */ | |
48 {104597, 132201, 25675, 53279}, /* SMPTE 170M */ | |
49 {117579, 136230, 16907, 35559} /* SMPTE 240M (1987) */ | |
50 }; | |
51 | |
52 #define LOADCHROMA(i) \ | |
53 U = pu[i]; \ | |
54 V = pv[i]; \ | |
55 r = (void *)c->table_rV[V]; \ | |
56 g = (void *)(c->table_gU[U] + c->table_gV[V]); \ | |
57 b = (void *)c->table_bU[U]; | |
58 | |
29441
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
59 #define PUTRGB(dst,src,i) \ |
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
60 Y = src[2*i]; \ |
28688 | 61 dst[2*i ] = r[Y] + g[Y] + b[Y]; \ |
29441
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
62 Y = src[2*i+1]; \ |
28688 | 63 dst[2*i+1] = r[Y] + g[Y] + b[Y]; |
64 | |
65 #define PUTRGB24(dst,src,i) \ | |
66 Y = src[2*i]; \ | |
67 dst[6*i+0] = r[Y]; dst[6*i+1] = g[Y]; dst[6*i+2] = b[Y]; \ | |
68 Y = src[2*i+1]; \ | |
69 dst[6*i+3] = r[Y]; dst[6*i+4] = g[Y]; dst[6*i+5] = b[Y]; | |
70 | |
71 #define PUTBGR24(dst,src,i) \ | |
72 Y = src[2*i]; \ | |
73 dst[6*i+0] = b[Y]; dst[6*i+1] = g[Y]; dst[6*i+2] = r[Y]; \ | |
74 Y = src[2*i+1]; \ | |
75 dst[6*i+3] = b[Y]; dst[6*i+4] = g[Y]; dst[6*i+5] = r[Y]; | |
76 | |
29441
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
77 #define PUTRGBA(dst,ysrc,asrc,i,s) \ |
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
78 Y = ysrc[2*i]; \ |
28975
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
79 dst[2*i ] = r[Y] + g[Y] + b[Y] + (asrc[2*i ]<<s); \ |
29441
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
80 Y = ysrc[2*i+1]; \ |
28975
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
81 dst[2*i+1] = r[Y] + g[Y] + b[Y] + (asrc[2*i+1]<<s); |
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
82 |
29300 | 83 #define PUTRGB48(dst,src,i) \ |
84 Y = src[2*i]; \ | |
85 dst[12*i+ 0] = dst[12*i+ 1] = r[Y]; \ | |
86 dst[12*i+ 2] = dst[12*i+ 3] = g[Y]; \ | |
87 dst[12*i+ 4] = dst[12*i+ 5] = b[Y]; \ | |
88 Y = src[2*i+1]; \ | |
89 dst[12*i+ 6] = dst[12*i+ 7] = r[Y]; \ | |
90 dst[12*i+ 8] = dst[12*i+ 9] = g[Y]; \ | |
91 dst[12*i+10] = dst[12*i+11] = b[Y]; | |
92 | |
28943
cf087cb82252
Add an alpha parameter to the YUV2RGBFUNC macro to ease the upcoming yuva2rgb patch
sdrik
parents:
28738
diff
changeset
|
93 #define YUV2RGBFUNC(func_name, dst_type, alpha) \ |
30264
1032ff2e83f1
Const correctness for src pointer. Remove all constness related warnings in
zuxy
parents:
29481
diff
changeset
|
94 static int func_name(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY, \ |
29481 | 95 int srcSliceH, uint8_t* dst[], int dstStride[]) \ |
96 {\ | |
28688 | 97 int y;\ |
98 \ | |
28975
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
99 if (!alpha && c->srcFormat == PIX_FMT_YUV422P) {\ |
28688 | 100 srcStride[1] *= 2;\ |
101 srcStride[2] *= 2;\ | |
102 }\ | |
103 for (y=0; y<srcSliceH; y+=2) {\ | |
104 dst_type *dst_1 = (dst_type*)(dst[0] + (y+srcSliceY )*dstStride[0]);\ | |
105 dst_type *dst_2 = (dst_type*)(dst[0] + (y+srcSliceY+1)*dstStride[0]);\ | |
106 dst_type av_unused *r, *b;\ | |
107 dst_type *g;\ | |
30264
1032ff2e83f1
Const correctness for src pointer. Remove all constness related warnings in
zuxy
parents:
29481
diff
changeset
|
108 const uint8_t *py_1 = src[0] + y*srcStride[0];\ |
1032ff2e83f1
Const correctness for src pointer. Remove all constness related warnings in
zuxy
parents:
29481
diff
changeset
|
109 const uint8_t *py_2 = py_1 + srcStride[0];\ |
1032ff2e83f1
Const correctness for src pointer. Remove all constness related warnings in
zuxy
parents:
29481
diff
changeset
|
110 const uint8_t *pu = src[1] + (y>>1)*srcStride[1];\ |
1032ff2e83f1
Const correctness for src pointer. Remove all constness related warnings in
zuxy
parents:
29481
diff
changeset
|
111 const uint8_t *pv = src[2] + (y>>1)*srcStride[2];\ |
1032ff2e83f1
Const correctness for src pointer. Remove all constness related warnings in
zuxy
parents:
29481
diff
changeset
|
112 const uint8_t av_unused *pa_1, *pa_2;\ |
28688 | 113 unsigned int h_size = c->dstW>>3;\ |
29481 | 114 if (alpha) {\ |
28975
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
115 pa_1 = src[3] + y*srcStride[3];\ |
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
116 pa_2 = pa_1 + srcStride[3];\ |
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
117 }\ |
28688 | 118 while (h_size--) {\ |
119 int av_unused U, V;\ | |
120 int Y;\ | |
121 | |
122 #define ENDYUV2RGBLINE(dst_delta)\ | |
123 pu += 4;\ | |
124 pv += 4;\ | |
125 py_1 += 8;\ | |
126 py_2 += 8;\ | |
127 dst_1 += dst_delta;\ | |
128 dst_2 += dst_delta;\ | |
129 }\ | |
130 if (c->dstW & 4) {\ | |
131 int av_unused Y, U, V;\ | |
132 | |
133 #define ENDYUV2RGBFUNC()\ | |
134 }\ | |
135 }\ | |
136 return srcSliceH;\ | |
137 } | |
138 | |
139 #define CLOSEYUV2RGBFUNC(dst_delta)\ | |
140 ENDYUV2RGBLINE(dst_delta)\ | |
141 ENDYUV2RGBFUNC() | |
142 | |
29300 | 143 YUV2RGBFUNC(yuv2rgb_c_48, uint8_t, 0) |
144 LOADCHROMA(0); | |
145 PUTRGB48(dst_1,py_1,0); | |
146 PUTRGB48(dst_2,py_2,0); | |
147 | |
148 LOADCHROMA(1); | |
149 PUTRGB48(dst_2,py_2,1); | |
150 PUTRGB48(dst_1,py_1,1); | |
151 | |
152 LOADCHROMA(2); | |
153 PUTRGB48(dst_1,py_1,2); | |
154 PUTRGB48(dst_2,py_2,2); | |
155 | |
156 LOADCHROMA(3); | |
157 PUTRGB48(dst_2,py_2,3); | |
158 PUTRGB48(dst_1,py_1,3); | |
159 ENDYUV2RGBLINE(48) | |
160 LOADCHROMA(0); | |
161 PUTRGB48(dst_1,py_1,0); | |
162 PUTRGB48(dst_2,py_2,0); | |
163 | |
164 LOADCHROMA(1); | |
165 PUTRGB48(dst_2,py_2,1); | |
166 PUTRGB48(dst_1,py_1,1); | |
167 ENDYUV2RGBFUNC() | |
168 | |
28943
cf087cb82252
Add an alpha parameter to the YUV2RGBFUNC macro to ease the upcoming yuva2rgb patch
sdrik
parents:
28738
diff
changeset
|
169 YUV2RGBFUNC(yuv2rgb_c_32, uint32_t, 0) |
28688 | 170 LOADCHROMA(0); |
29441
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
171 PUTRGB(dst_1,py_1,0); |
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
172 PUTRGB(dst_2,py_2,0); |
28688 | 173 |
174 LOADCHROMA(1); | |
29441
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
175 PUTRGB(dst_2,py_2,1); |
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
176 PUTRGB(dst_1,py_1,1); |
28688 | 177 |
178 LOADCHROMA(2); | |
29441
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
179 PUTRGB(dst_1,py_1,2); |
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
180 PUTRGB(dst_2,py_2,2); |
28688 | 181 |
182 LOADCHROMA(3); | |
29441
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
183 PUTRGB(dst_2,py_2,3); |
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
184 PUTRGB(dst_1,py_1,3); |
28688 | 185 ENDYUV2RGBLINE(8) |
186 LOADCHROMA(0); | |
29441
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
187 PUTRGB(dst_1,py_1,0); |
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
188 PUTRGB(dst_2,py_2,0); |
28688 | 189 |
190 LOADCHROMA(1); | |
29441
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
191 PUTRGB(dst_2,py_2,1); |
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
192 PUTRGB(dst_1,py_1,1); |
28688 | 193 ENDYUV2RGBFUNC() |
194 | |
28975
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
195 YUV2RGBFUNC(yuva2rgba_c, uint32_t, 1) |
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
196 LOADCHROMA(0); |
29441
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
197 PUTRGBA(dst_1,py_1,pa_1,0,24); |
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
198 PUTRGBA(dst_2,py_2,pa_2,0,24); |
28975
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
199 |
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
200 LOADCHROMA(1); |
29441
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
201 PUTRGBA(dst_2,py_2,pa_1,1,24); |
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
202 PUTRGBA(dst_1,py_1,pa_2,1,24); |
28975
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
203 |
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
204 LOADCHROMA(2); |
29441
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
205 PUTRGBA(dst_1,py_1,pa_1,2,24); |
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
206 PUTRGBA(dst_2,py_2,pa_2,2,24); |
28975
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
207 |
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
208 LOADCHROMA(3); |
29441
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
209 PUTRGBA(dst_2,py_2,pa_1,3,24); |
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
210 PUTRGBA(dst_1,py_1,pa_2,3,24); |
28975
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
211 pa_1 += 8;\ |
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
212 pa_2 += 8;\ |
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
213 ENDYUV2RGBLINE(8) |
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
214 LOADCHROMA(0); |
29441
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
215 PUTRGBA(dst_1,py_1,pa_1,0,24); |
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
216 PUTRGBA(dst_2,py_2,pa_2,0,24); |
28975
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
217 |
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
218 LOADCHROMA(1); |
29441
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
219 PUTRGBA(dst_2,py_2,pa_1,1,24); |
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
220 PUTRGBA(dst_1,py_1,pa_2,1,24); |
28975
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
221 ENDYUV2RGBFUNC() |
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
222 |
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
223 YUV2RGBFUNC(yuva2argb_c, uint32_t, 1) |
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
224 LOADCHROMA(0); |
29441
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
225 PUTRGBA(dst_1,py_1,pa_1,0,0); |
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
226 PUTRGBA(dst_2,py_2,pa_2,0,0); |
28975
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
227 |
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
228 LOADCHROMA(1); |
29441
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
229 PUTRGBA(dst_2,py_2,pa_2,1,0); |
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
230 PUTRGBA(dst_1,py_1,pa_1,1,0); |
28975
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
231 |
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
232 LOADCHROMA(2); |
29441
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
233 PUTRGBA(dst_1,py_1,pa_1,2,0); |
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
234 PUTRGBA(dst_2,py_2,pa_2,2,0); |
28975
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
235 |
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
236 LOADCHROMA(3); |
29441
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
237 PUTRGBA(dst_2,py_2,pa_2,3,0); |
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
238 PUTRGBA(dst_1,py_1,pa_1,3,0); |
28975
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
239 pa_1 += 8;\ |
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
240 pa_2 += 8;\ |
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
241 ENDYUV2RGBLINE(8) |
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
242 LOADCHROMA(0); |
29441
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
243 PUTRGBA(dst_1,py_1,pa_1,0,0); |
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
244 PUTRGBA(dst_2,py_2,pa_2,0,0); |
28975
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
245 |
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
246 LOADCHROMA(1); |
29441
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
247 PUTRGBA(dst_2,py_2,pa_2,1,0); |
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
248 PUTRGBA(dst_1,py_1,pa_1,1,0); |
28975
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
249 ENDYUV2RGBFUNC() |
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
250 |
28943
cf087cb82252
Add an alpha parameter to the YUV2RGBFUNC macro to ease the upcoming yuva2rgb patch
sdrik
parents:
28738
diff
changeset
|
251 YUV2RGBFUNC(yuv2rgb_c_24_rgb, uint8_t, 0) |
28688 | 252 LOADCHROMA(0); |
253 PUTRGB24(dst_1,py_1,0); | |
254 PUTRGB24(dst_2,py_2,0); | |
255 | |
256 LOADCHROMA(1); | |
257 PUTRGB24(dst_2,py_2,1); | |
258 PUTRGB24(dst_1,py_1,1); | |
259 | |
260 LOADCHROMA(2); | |
261 PUTRGB24(dst_1,py_1,2); | |
262 PUTRGB24(dst_2,py_2,2); | |
263 | |
264 LOADCHROMA(3); | |
265 PUTRGB24(dst_2,py_2,3); | |
266 PUTRGB24(dst_1,py_1,3); | |
267 ENDYUV2RGBLINE(24) | |
268 LOADCHROMA(0); | |
269 PUTRGB24(dst_1,py_1,0); | |
270 PUTRGB24(dst_2,py_2,0); | |
271 | |
272 LOADCHROMA(1); | |
273 PUTRGB24(dst_2,py_2,1); | |
274 PUTRGB24(dst_1,py_1,1); | |
275 ENDYUV2RGBFUNC() | |
276 | |
277 // only trivial mods from yuv2rgb_c_24_rgb | |
28943
cf087cb82252
Add an alpha parameter to the YUV2RGBFUNC macro to ease the upcoming yuva2rgb patch
sdrik
parents:
28738
diff
changeset
|
278 YUV2RGBFUNC(yuv2rgb_c_24_bgr, uint8_t, 0) |
28688 | 279 LOADCHROMA(0); |
280 PUTBGR24(dst_1,py_1,0); | |
281 PUTBGR24(dst_2,py_2,0); | |
282 | |
283 LOADCHROMA(1); | |
284 PUTBGR24(dst_2,py_2,1); | |
285 PUTBGR24(dst_1,py_1,1); | |
286 | |
287 LOADCHROMA(2); | |
288 PUTBGR24(dst_1,py_1,2); | |
289 PUTBGR24(dst_2,py_2,2); | |
290 | |
291 LOADCHROMA(3); | |
292 PUTBGR24(dst_2,py_2,3); | |
293 PUTBGR24(dst_1,py_1,3); | |
294 ENDYUV2RGBLINE(24) | |
295 LOADCHROMA(0); | |
296 PUTBGR24(dst_1,py_1,0); | |
297 PUTBGR24(dst_2,py_2,0); | |
298 | |
299 LOADCHROMA(1); | |
300 PUTBGR24(dst_2,py_2,1); | |
301 PUTBGR24(dst_1,py_1,1); | |
302 ENDYUV2RGBFUNC() | |
303 | |
304 // This is exactly the same code as yuv2rgb_c_32 except for the types of | |
305 // r, g, b, dst_1, dst_2 | |
28943
cf087cb82252
Add an alpha parameter to the YUV2RGBFUNC macro to ease the upcoming yuva2rgb patch
sdrik
parents:
28738
diff
changeset
|
306 YUV2RGBFUNC(yuv2rgb_c_16, uint16_t, 0) |
28688 | 307 LOADCHROMA(0); |
29441
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
308 PUTRGB(dst_1,py_1,0); |
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
309 PUTRGB(dst_2,py_2,0); |
28688 | 310 |
311 LOADCHROMA(1); | |
29441
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
312 PUTRGB(dst_2,py_2,1); |
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
313 PUTRGB(dst_1,py_1,1); |
28688 | 314 |
315 LOADCHROMA(2); | |
29441
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
316 PUTRGB(dst_1,py_1,2); |
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
317 PUTRGB(dst_2,py_2,2); |
28688 | 318 |
319 LOADCHROMA(3); | |
29441
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
320 PUTRGB(dst_2,py_2,3); |
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
321 PUTRGB(dst_1,py_1,3); |
28688 | 322 CLOSEYUV2RGBFUNC(8) |
323 | |
30323 | 324 #if 0 // Currently unused |
28688 | 325 // This is exactly the same code as yuv2rgb_c_32 except for the types of |
326 // r, g, b, dst_1, dst_2 | |
28943
cf087cb82252
Add an alpha parameter to the YUV2RGBFUNC macro to ease the upcoming yuva2rgb patch
sdrik
parents:
28738
diff
changeset
|
327 YUV2RGBFUNC(yuv2rgb_c_8, uint8_t, 0) |
28688 | 328 LOADCHROMA(0); |
29441
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
329 PUTRGB(dst_1,py_1,0); |
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
330 PUTRGB(dst_2,py_2,0); |
28688 | 331 |
332 LOADCHROMA(1); | |
29441
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
333 PUTRGB(dst_2,py_2,1); |
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
334 PUTRGB(dst_1,py_1,1); |
28688 | 335 |
336 LOADCHROMA(2); | |
29441
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
337 PUTRGB(dst_1,py_1,2); |
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
338 PUTRGB(dst_2,py_2,2); |
28688 | 339 |
340 LOADCHROMA(3); | |
29441
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
341 PUTRGB(dst_2,py_2,3); |
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
342 PUTRGB(dst_1,py_1,3); |
28688 | 343 CLOSEYUV2RGBFUNC(8) |
30323 | 344 #endif |
28688 | 345 |
346 // r, g, b, dst_1, dst_2 | |
28943
cf087cb82252
Add an alpha parameter to the YUV2RGBFUNC macro to ease the upcoming yuva2rgb patch
sdrik
parents:
28738
diff
changeset
|
347 YUV2RGBFUNC(yuv2rgb_c_8_ordered_dither, uint8_t, 0) |
28688 | 348 const uint8_t *d32 = dither_8x8_32[y&7]; |
349 const uint8_t *d64 = dither_8x8_73[y&7]; | |
350 #define PUTRGB8(dst,src,i,o) \ | |
351 Y = src[2*i]; \ | |
352 dst[2*i] = r[Y+d32[0+o]] + g[Y+d32[0+o]] + b[Y+d64[0+o]]; \ | |
353 Y = src[2*i+1]; \ | |
354 dst[2*i+1] = r[Y+d32[1+o]] + g[Y+d32[1+o]] + b[Y+d64[1+o]]; | |
355 | |
356 LOADCHROMA(0); | |
357 PUTRGB8(dst_1,py_1,0,0); | |
358 PUTRGB8(dst_2,py_2,0,0+8); | |
359 | |
360 LOADCHROMA(1); | |
361 PUTRGB8(dst_2,py_2,1,2+8); | |
362 PUTRGB8(dst_1,py_1,1,2); | |
363 | |
364 LOADCHROMA(2); | |
365 PUTRGB8(dst_1,py_1,2,4); | |
366 PUTRGB8(dst_2,py_2,2,4+8); | |
367 | |
368 LOADCHROMA(3); | |
369 PUTRGB8(dst_2,py_2,3,6+8); | |
370 PUTRGB8(dst_1,py_1,3,6); | |
371 CLOSEYUV2RGBFUNC(8) | |
372 | |
30323 | 373 #if 0 // Currently unused |
28688 | 374 // This is exactly the same code as yuv2rgb_c_32 except for the types of |
375 // r, g, b, dst_1, dst_2 | |
28943
cf087cb82252
Add an alpha parameter to the YUV2RGBFUNC macro to ease the upcoming yuva2rgb patch
sdrik
parents:
28738
diff
changeset
|
376 YUV2RGBFUNC(yuv2rgb_c_4, uint8_t, 0) |
28688 | 377 int acc; |
378 #define PUTRGB4(dst,src,i) \ | |
379 Y = src[2*i]; \ | |
380 acc = r[Y] + g[Y] + b[Y]; \ | |
381 Y = src[2*i+1]; \ | |
382 acc |= (r[Y] + g[Y] + b[Y])<<4; \ | |
383 dst[i] = acc; | |
384 | |
385 LOADCHROMA(0); | |
386 PUTRGB4(dst_1,py_1,0); | |
387 PUTRGB4(dst_2,py_2,0); | |
388 | |
389 LOADCHROMA(1); | |
390 PUTRGB4(dst_2,py_2,1); | |
391 PUTRGB4(dst_1,py_1,1); | |
392 | |
393 LOADCHROMA(2); | |
394 PUTRGB4(dst_1,py_1,2); | |
395 PUTRGB4(dst_2,py_2,2); | |
396 | |
397 LOADCHROMA(3); | |
398 PUTRGB4(dst_2,py_2,3); | |
399 PUTRGB4(dst_1,py_1,3); | |
400 CLOSEYUV2RGBFUNC(4) | |
30323 | 401 #endif |
28688 | 402 |
28943
cf087cb82252
Add an alpha parameter to the YUV2RGBFUNC macro to ease the upcoming yuva2rgb patch
sdrik
parents:
28738
diff
changeset
|
403 YUV2RGBFUNC(yuv2rgb_c_4_ordered_dither, uint8_t, 0) |
28688 | 404 const uint8_t *d64 = dither_8x8_73[y&7]; |
405 const uint8_t *d128 = dither_8x8_220[y&7]; | |
406 int acc; | |
407 | |
408 #define PUTRGB4D(dst,src,i,o) \ | |
409 Y = src[2*i]; \ | |
410 acc = r[Y+d128[0+o]] + g[Y+d64[0+o]] + b[Y+d128[0+o]]; \ | |
411 Y = src[2*i+1]; \ | |
412 acc |= (r[Y+d128[1+o]] + g[Y+d64[1+o]] + b[Y+d128[1+o]])<<4; \ | |
413 dst[i]= acc; | |
414 | |
415 LOADCHROMA(0); | |
416 PUTRGB4D(dst_1,py_1,0,0); | |
417 PUTRGB4D(dst_2,py_2,0,0+8); | |
418 | |
419 LOADCHROMA(1); | |
420 PUTRGB4D(dst_2,py_2,1,2+8); | |
421 PUTRGB4D(dst_1,py_1,1,2); | |
422 | |
423 LOADCHROMA(2); | |
424 PUTRGB4D(dst_1,py_1,2,4); | |
425 PUTRGB4D(dst_2,py_2,2,4+8); | |
426 | |
427 LOADCHROMA(3); | |
428 PUTRGB4D(dst_2,py_2,3,6+8); | |
429 PUTRGB4D(dst_1,py_1,3,6); | |
430 CLOSEYUV2RGBFUNC(4) | |
431 | |
30323 | 432 #if 0 // Currently unused |
28688 | 433 // This is exactly the same code as yuv2rgb_c_32 except for the types of |
434 // r, g, b, dst_1, dst_2 | |
28943
cf087cb82252
Add an alpha parameter to the YUV2RGBFUNC macro to ease the upcoming yuva2rgb patch
sdrik
parents:
28738
diff
changeset
|
435 YUV2RGBFUNC(yuv2rgb_c_4b, uint8_t, 0) |
28688 | 436 LOADCHROMA(0); |
29441
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
437 PUTRGB(dst_1,py_1,0); |
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
438 PUTRGB(dst_2,py_2,0); |
28688 | 439 |
440 LOADCHROMA(1); | |
29441
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
441 PUTRGB(dst_2,py_2,1); |
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
442 PUTRGB(dst_1,py_1,1); |
28688 | 443 |
444 LOADCHROMA(2); | |
29441
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
445 PUTRGB(dst_1,py_1,2); |
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
446 PUTRGB(dst_2,py_2,2); |
28688 | 447 |
448 LOADCHROMA(3); | |
29441
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
449 PUTRGB(dst_2,py_2,3); |
3b88f0acdc0b
Remove 'offset' argument from PUTRGB* macros since it's unneeded and caused
kostya
parents:
29370
diff
changeset
|
450 PUTRGB(dst_1,py_1,3); |
28688 | 451 CLOSEYUV2RGBFUNC(8) |
30323 | 452 #endif |
28688 | 453 |
28943
cf087cb82252
Add an alpha parameter to the YUV2RGBFUNC macro to ease the upcoming yuva2rgb patch
sdrik
parents:
28738
diff
changeset
|
454 YUV2RGBFUNC(yuv2rgb_c_4b_ordered_dither, uint8_t, 0) |
28688 | 455 const uint8_t *d64 = dither_8x8_73[y&7]; |
456 const uint8_t *d128 = dither_8x8_220[y&7]; | |
457 | |
458 #define PUTRGB4DB(dst,src,i,o) \ | |
459 Y = src[2*i]; \ | |
460 dst[2*i] = r[Y+d128[0+o]] + g[Y+d64[0+o]] + b[Y+d128[0+o]]; \ | |
461 Y = src[2*i+1]; \ | |
462 dst[2*i+1] = r[Y+d128[1+o]] + g[Y+d64[1+o]] + b[Y+d128[1+o]]; | |
463 | |
464 LOADCHROMA(0); | |
465 PUTRGB4DB(dst_1,py_1,0,0); | |
466 PUTRGB4DB(dst_2,py_2,0,0+8); | |
467 | |
468 LOADCHROMA(1); | |
469 PUTRGB4DB(dst_2,py_2,1,2+8); | |
470 PUTRGB4DB(dst_1,py_1,1,2); | |
471 | |
472 LOADCHROMA(2); | |
473 PUTRGB4DB(dst_1,py_1,2,4); | |
474 PUTRGB4DB(dst_2,py_2,2,4+8); | |
475 | |
476 LOADCHROMA(3); | |
477 PUTRGB4DB(dst_2,py_2,3,6+8); | |
478 PUTRGB4DB(dst_1,py_1,3,6); | |
479 CLOSEYUV2RGBFUNC(8) | |
480 | |
28943
cf087cb82252
Add an alpha parameter to the YUV2RGBFUNC macro to ease the upcoming yuva2rgb patch
sdrik
parents:
28738
diff
changeset
|
481 YUV2RGBFUNC(yuv2rgb_c_1_ordered_dither, uint8_t, 0) |
28688 | 482 const uint8_t *d128 = dither_8x8_220[y&7]; |
483 char out_1 = 0, out_2 = 0; | |
484 g= c->table_gU[128] + c->table_gV[128]; | |
485 | |
486 #define PUTRGB1(out,src,i,o) \ | |
487 Y = src[2*i]; \ | |
488 out+= out + g[Y+d128[0+o]]; \ | |
489 Y = src[2*i+1]; \ | |
490 out+= out + g[Y+d128[1+o]]; | |
491 | |
492 PUTRGB1(out_1,py_1,0,0); | |
493 PUTRGB1(out_2,py_2,0,0+8); | |
494 | |
495 PUTRGB1(out_2,py_2,1,2+8); | |
496 PUTRGB1(out_1,py_1,1,2); | |
497 | |
498 PUTRGB1(out_1,py_1,2,4); | |
499 PUTRGB1(out_2,py_2,2,4+8); | |
500 | |
501 PUTRGB1(out_2,py_2,3,6+8); | |
502 PUTRGB1(out_1,py_1,3,6); | |
503 | |
504 dst_1[0]= out_1; | |
505 dst_2[0]= out_2; | |
506 CLOSEYUV2RGBFUNC(1) | |
507 | |
28953
1e56ea9937ce
Consistently use ff_ prefixes for internal symbols.
diego
parents:
28947
diff
changeset
|
508 SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c) |
28688 | 509 { |
510 SwsFunc t = NULL; | |
511 #if (HAVE_MMX2 || HAVE_MMX) && CONFIG_GPL | |
29028 | 512 t = ff_yuv2rgb_init_mmx(c); |
28688 | 513 #endif |
514 #if HAVE_VIS | |
28953
1e56ea9937ce
Consistently use ff_ prefixes for internal symbols.
diego
parents:
28947
diff
changeset
|
515 t = ff_yuv2rgb_init_vis(c); |
28688 | 516 #endif |
517 #if CONFIG_MLIB | |
28953
1e56ea9937ce
Consistently use ff_ prefixes for internal symbols.
diego
parents:
28947
diff
changeset
|
518 t = ff_yuv2rgb_init_mlib(c); |
28688 | 519 #endif |
29370
059ff1f4e280
The AltiVec code in libswscale no longer is under GPL.
diego
parents:
29300
diff
changeset
|
520 #if HAVE_ALTIVEC |
28688 | 521 if (c->flags & SWS_CPU_CAPS_ALTIVEC) |
28953
1e56ea9937ce
Consistently use ff_ prefixes for internal symbols.
diego
parents:
28947
diff
changeset
|
522 t = ff_yuv2rgb_init_altivec(c); |
28688 | 523 #endif |
524 | |
525 #if ARCH_BFIN | |
526 if (c->flags & SWS_CPU_CAPS_BFIN) | |
28953
1e56ea9937ce
Consistently use ff_ prefixes for internal symbols.
diego
parents:
28947
diff
changeset
|
527 t = ff_yuv2rgb_get_func_ptr_bfin(c); |
28688 | 528 #endif |
529 | |
530 if (t) | |
531 return t; | |
532 | |
30328
0e52b96c6199
User friendly warning message that gives out names of source and target formats
zuxy
parents:
30323
diff
changeset
|
533 av_log(c, AV_LOG_WARNING, "No accelerated colorspace conversion found from %s to %s.\n", sws_format_name(c->srcFormat), sws_format_name(c->dstFormat)); |
28688 | 534 |
535 switch (c->dstFormat) { | |
29300 | 536 case PIX_FMT_RGB48BE: |
537 case PIX_FMT_RGB48LE: return yuv2rgb_c_48; | |
28975
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
538 case PIX_FMT_ARGB: |
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
539 case PIX_FMT_ABGR: if (CONFIG_SWSCALE_ALPHA && c->srcFormat == PIX_FMT_YUVA420P) return yuva2argb_c; |
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
540 case PIX_FMT_RGBA: |
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
541 case PIX_FMT_BGRA: return (CONFIG_SWSCALE_ALPHA && c->srcFormat == PIX_FMT_YUVA420P) ? yuva2rgba_c : yuv2rgb_c_32; |
28688 | 542 case PIX_FMT_RGB24: return yuv2rgb_c_24_rgb; |
543 case PIX_FMT_BGR24: return yuv2rgb_c_24_bgr; | |
544 case PIX_FMT_RGB565: | |
545 case PIX_FMT_BGR565: | |
546 case PIX_FMT_RGB555: | |
547 case PIX_FMT_BGR555: return yuv2rgb_c_16; | |
548 case PIX_FMT_RGB8: | |
549 case PIX_FMT_BGR8: return yuv2rgb_c_8_ordered_dither; | |
550 case PIX_FMT_RGB4: | |
551 case PIX_FMT_BGR4: return yuv2rgb_c_4_ordered_dither; | |
552 case PIX_FMT_RGB4_BYTE: | |
553 case PIX_FMT_BGR4_BYTE: return yuv2rgb_c_4b_ordered_dither; | |
554 case PIX_FMT_MONOBLACK: return yuv2rgb_c_1_ordered_dither; | |
555 default: | |
556 assert(0); | |
557 } | |
558 return NULL; | |
559 } | |
560 | |
561 static void fill_table(uint8_t* table[256], const int elemsize, const int inc, uint8_t *y_table) | |
562 { | |
563 int i; | |
564 int64_t cb = 0; | |
565 | |
566 y_table -= elemsize * (inc >> 9); | |
567 | |
568 for (i = 0; i < 256; i++) { | |
569 table[i] = y_table + elemsize * (cb >> 16); | |
570 cb += inc; | |
571 } | |
572 } | |
573 | |
574 static void fill_gv_table(int table[256], const int elemsize, const int inc) | |
575 { | |
576 int i; | |
577 int64_t cb = 0; | |
578 int off = -(inc >> 9); | |
579 | |
580 for (i = 0; i < 256; i++) { | |
581 table[i] = elemsize * (off + (cb >> 16)); | |
582 cb += inc; | |
583 } | |
584 } | |
585 | |
28953
1e56ea9937ce
Consistently use ff_ prefixes for internal symbols.
diego
parents:
28947
diff
changeset
|
586 av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4], int fullRange, |
1e56ea9937ce
Consistently use ff_ prefixes for internal symbols.
diego
parents:
28947
diff
changeset
|
587 int brightness, int contrast, int saturation) |
28688 | 588 { |
589 const int isRgb = c->dstFormat==PIX_FMT_RGB32 | |
590 || c->dstFormat==PIX_FMT_RGB32_1 | |
591 || c->dstFormat==PIX_FMT_BGR24 | |
592 || c->dstFormat==PIX_FMT_RGB565 | |
593 || c->dstFormat==PIX_FMT_RGB555 | |
594 || c->dstFormat==PIX_FMT_RGB8 | |
595 || c->dstFormat==PIX_FMT_RGB4 | |
596 || c->dstFormat==PIX_FMT_RGB4_BYTE | |
597 || c->dstFormat==PIX_FMT_MONOBLACK; | |
30377
2eea1f09e2c5
Use av_get_bits_per_pixel() for computing the bits per pixel of the
stefano
parents:
30328
diff
changeset
|
598 const int bpp = c->dstFormatBpp; |
28688 | 599 uint8_t *y_table; |
600 uint16_t *y_table16; | |
601 uint32_t *y_table32; | |
28975
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
602 int i, base, rbase, gbase, bbase, abase, needAlpha; |
28688 | 603 const int yoffs = fullRange ? 384 : 326; |
604 | |
605 int64_t crv = inv_table[0]; | |
606 int64_t cbu = inv_table[1]; | |
607 int64_t cgu = -inv_table[2]; | |
608 int64_t cgv = -inv_table[3]; | |
609 int64_t cy = 1<<16; | |
610 int64_t oy = 0; | |
611 | |
612 int64_t yb = 0; | |
613 | |
614 if (!fullRange) { | |
615 cy = (cy*255) / 219; | |
616 oy = 16<<16; | |
617 } else { | |
618 crv = (crv*224) / 255; | |
619 cbu = (cbu*224) / 255; | |
620 cgu = (cgu*224) / 255; | |
621 cgv = (cgv*224) / 255; | |
622 } | |
623 | |
624 cy = (cy *contrast ) >> 16; | |
625 crv = (crv*contrast * saturation) >> 32; | |
626 cbu = (cbu*contrast * saturation) >> 32; | |
627 cgu = (cgu*contrast * saturation) >> 32; | |
628 cgv = (cgv*contrast * saturation) >> 32; | |
629 oy -= 256*brightness; | |
630 | |
631 //scale coefficients by cy | |
632 crv = ((crv << 16) + 0x8000) / cy; | |
633 cbu = ((cbu << 16) + 0x8000) / cy; | |
634 cgu = ((cgu << 16) + 0x8000) / cy; | |
635 cgv = ((cgv << 16) + 0x8000) / cy; | |
636 | |
637 av_free(c->yuvTable); | |
638 | |
639 switch (bpp) { | |
640 case 1: | |
641 c->yuvTable = av_malloc(1024); | |
642 y_table = c->yuvTable; | |
643 yb = -(384<<16) - oy; | |
644 for (i = 0; i < 1024-110; i++) { | |
645 y_table[i+110] = av_clip_uint8((yb + 0x8000) >> 16) >> 7; | |
646 yb += cy; | |
647 } | |
648 fill_table(c->table_gU, 1, cgu, y_table + yoffs); | |
649 fill_gv_table(c->table_gV, 1, cgv); | |
650 break; | |
651 case 4: | |
652 case 4|128: | |
653 rbase = isRgb ? 3 : 0; | |
654 gbase = 1; | |
655 bbase = isRgb ? 0 : 3; | |
656 c->yuvTable = av_malloc(1024*3); | |
657 y_table = c->yuvTable; | |
658 yb = -(384<<16) - oy; | |
659 for (i = 0; i < 1024-110; i++) { | |
660 int yval = av_clip_uint8((yb + 0x8000) >> 16); | |
661 y_table[i+110 ] = (yval >> 7) << rbase; | |
662 y_table[i+ 37+1024] = ((yval + 43) / 85) << gbase; | |
663 y_table[i+110+2048] = (yval >> 7) << bbase; | |
664 yb += cy; | |
665 } | |
666 fill_table(c->table_rV, 1, crv, y_table + yoffs); | |
667 fill_table(c->table_gU, 1, cgu, y_table + yoffs + 1024); | |
668 fill_table(c->table_bU, 1, cbu, y_table + yoffs + 2048); | |
669 fill_gv_table(c->table_gV, 1, cgv); | |
670 break; | |
671 case 8: | |
672 rbase = isRgb ? 5 : 0; | |
673 gbase = isRgb ? 2 : 3; | |
674 bbase = isRgb ? 0 : 6; | |
675 c->yuvTable = av_malloc(1024*3); | |
676 y_table = c->yuvTable; | |
677 yb = -(384<<16) - oy; | |
678 for (i = 0; i < 1024-38; i++) { | |
679 int yval = av_clip_uint8((yb + 0x8000) >> 16); | |
680 y_table[i+16 ] = ((yval + 18) / 36) << rbase; | |
681 y_table[i+16+1024] = ((yval + 18) / 36) << gbase; | |
682 y_table[i+37+2048] = ((yval + 43) / 85) << bbase; | |
683 yb += cy; | |
684 } | |
685 fill_table(c->table_rV, 1, crv, y_table + yoffs); | |
686 fill_table(c->table_gU, 1, cgu, y_table + yoffs + 1024); | |
687 fill_table(c->table_bU, 1, cbu, y_table + yoffs + 2048); | |
688 fill_gv_table(c->table_gV, 1, cgv); | |
689 break; | |
690 case 15: | |
691 case 16: | |
692 rbase = isRgb ? bpp - 5 : 0; | |
693 gbase = 5; | |
694 bbase = isRgb ? 0 : (bpp - 5); | |
695 c->yuvTable = av_malloc(1024*3*2); | |
696 y_table16 = c->yuvTable; | |
697 yb = -(384<<16) - oy; | |
698 for (i = 0; i < 1024; i++) { | |
699 uint8_t yval = av_clip_uint8((yb + 0x8000) >> 16); | |
700 y_table16[i ] = (yval >> 3) << rbase; | |
701 y_table16[i+1024] = (yval >> (18 - bpp)) << gbase; | |
702 y_table16[i+2048] = (yval >> 3) << bbase; | |
703 yb += cy; | |
704 } | |
705 fill_table(c->table_rV, 2, crv, y_table16 + yoffs); | |
706 fill_table(c->table_gU, 2, cgu, y_table16 + yoffs + 1024); | |
707 fill_table(c->table_bU, 2, cbu, y_table16 + yoffs + 2048); | |
708 fill_gv_table(c->table_gV, 2, cgv); | |
709 break; | |
710 case 24: | |
29300 | 711 case 48: |
28688 | 712 c->yuvTable = av_malloc(1024); |
713 y_table = c->yuvTable; | |
714 yb = -(384<<16) - oy; | |
715 for (i = 0; i < 1024; i++) { | |
716 y_table[i] = av_clip_uint8((yb + 0x8000) >> 16); | |
717 yb += cy; | |
718 } | |
719 fill_table(c->table_rV, 1, crv, y_table + yoffs); | |
720 fill_table(c->table_gU, 1, cgu, y_table + yoffs); | |
721 fill_table(c->table_bU, 1, cbu, y_table + yoffs); | |
722 fill_gv_table(c->table_gV, 1, cgv); | |
723 break; | |
724 case 32: | |
725 base = (c->dstFormat == PIX_FMT_RGB32_1 || c->dstFormat == PIX_FMT_BGR32_1) ? 8 : 0; | |
726 rbase = base + (isRgb ? 16 : 0); | |
727 gbase = base + 8; | |
728 bbase = base + (isRgb ? 0 : 16); | |
28975
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
729 needAlpha = CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat); |
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
730 if (!needAlpha) |
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
731 abase = (base + 24) & 31; |
28688 | 732 c->yuvTable = av_malloc(1024*3*4); |
733 y_table32 = c->yuvTable; | |
734 yb = -(384<<16) - oy; | |
735 for (i = 0; i < 1024; i++) { | |
736 uint8_t yval = av_clip_uint8((yb + 0x8000) >> 16); | |
28975
bab0430f2e59
Add YUVA420P -> RGBA/BGRA/ARGB/ABGR unscaled converters
sdrik
parents:
28957
diff
changeset
|
737 y_table32[i ] = (yval << rbase) + (needAlpha ? 0 : (255 << abase)); |
28688 | 738 y_table32[i+1024] = yval << gbase; |
739 y_table32[i+2048] = yval << bbase; | |
740 yb += cy; | |
741 } | |
742 fill_table(c->table_rV, 4, crv, y_table32 + yoffs); | |
743 fill_table(c->table_gU, 4, cgu, y_table32 + yoffs + 1024); | |
744 fill_table(c->table_bU, 4, cbu, y_table32 + yoffs + 2048); | |
745 fill_gv_table(c->table_gV, 4, cgv); | |
746 break; | |
747 default: | |
748 c->yuvTable = NULL; | |
749 av_log(c, AV_LOG_ERROR, "%ibpp not supported by yuv2rgb\n", bpp); | |
750 return -1; | |
751 } | |
752 return 0; | |
753 } |