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