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