43 0x0200020002000200LL,};
47 0x0004000400040004LL,};
61 DECLARE_ALIGNED(8,
const uint64_t, ff_bgr2YCoeff) = 0x000000210041000DULL;
62 DECLARE_ALIGNED(8,
const uint64_t, ff_bgr2UCoeff) = 0x0000FFEEFFDC0038ULL;
63 DECLARE_ALIGNED(8,
const uint64_t, ff_bgr2VCoeff) = 0x00000038FFD2FFF8ULL;
65 DECLARE_ALIGNED(8,
const uint64_t, ff_bgr2YCoeff) = 0x000020E540830C8BULL;
66 DECLARE_ALIGNED(8,
const uint64_t, ff_bgr2UCoeff) = 0x0000ED0FDAC23831ULL;
67 DECLARE_ALIGNED(8,
const uint64_t, ff_bgr2VCoeff) = 0x00003831D0E6F6EAULL;
69 DECLARE_ALIGNED(8,
const uint64_t, ff_bgr2YOffset) = 0x1010101010101010ULL;
70 DECLARE_ALIGNED(8,
const uint64_t, ff_bgr2UVOffset) = 0x8080808080808080ULL;
76 #define COMPILE_TEMPLATE_MMXEXT 0
77 #define RENAME(a) a ## _mmx
82 #if HAVE_MMXEXT_INLINE
84 #undef COMPILE_TEMPLATE_MMXEXT
85 #define COMPILE_TEMPLATE_MMXEXT 1
86 #define RENAME(a) a ## _mmxext
110 const int firstLumSrcY= vLumFilterPos[
dstY];
111 const int firstChrSrcY= vChrFilterPos[chrDstY];
119 if (dstY < dstH - 2) {
120 const int16_t **lumSrcPtr= (
const int16_t **) lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
121 const int16_t **chrUSrcPtr= (
const int16_t **) chrUPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
125 if (firstLumSrcY < 0 || firstLumSrcY + vLumFilterSize > c->
srcH) {
126 const int16_t **tmpY = (
const int16_t **) lumPixBuf + 2 * vLumBufSize;
127 int neg = -firstLumSrcY, i, end =
FFMIN(c->
srcH - firstLumSrcY, vLumFilterSize);
128 for (i = 0; i < neg; i++)
129 tmpY[i] = lumSrcPtr[neg];
130 for ( ; i < end; i++)
131 tmpY[i] = lumSrcPtr[i];
137 const int16_t **tmpA = (
const int16_t **) alpPixBuf + 2 * vLumBufSize;
138 for (i = 0; i < neg; i++)
139 tmpA[i] = alpSrcPtr[neg];
140 for ( ; i < end; i++)
141 tmpA[i] = alpSrcPtr[i];
143 tmpA[i] = tmpA[i - 1];
147 if (firstChrSrcY < 0 || firstChrSrcY + vChrFilterSize > c->
chrSrcH) {
148 const int16_t **tmpU = (
const int16_t **) chrUPixBuf + 2 * vChrBufSize;
149 int neg = -firstChrSrcY, i, end =
FFMIN(c->
chrSrcH - firstChrSrcY, vChrFilterSize);
150 for (i = 0; i < neg; i++) {
151 tmpU[i] = chrUSrcPtr[neg];
153 for ( ; i < end; i++) {
154 tmpU[i] = chrUSrcPtr[i];
157 tmpU[i] = tmpU[i - 1];
165 *(
const void**)&lumMmxFilter[s*i ]= lumSrcPtr[i ];
166 *(
const void**)&lumMmxFilter[s*i+
APCK_PTR2/4 ]= lumSrcPtr[i+(vLumFilterSize>1)];
168 lumMmxFilter[s*i+
APCK_COEF/4+1]= vLumFilter[dstY*vLumFilterSize + i ]
169 + (vLumFilterSize>1 ? vLumFilter[dstY*vLumFilterSize + i + 1]<<16 : 0);
171 *(
const void**)&alpMmxFilter[s*i ]= alpSrcPtr[i ];
172 *(
const void**)&alpMmxFilter[s*i+
APCK_PTR2/4 ]= alpSrcPtr[i+(vLumFilterSize>1)];
178 *(
const void**)&chrMmxFilter[s*i ]= chrUSrcPtr[i ];
179 *(
const void**)&chrMmxFilter[s*i+
APCK_PTR2/4 ]= chrUSrcPtr[i+(vChrFilterSize>1)];
181 chrMmxFilter[s*i+
APCK_COEF/4+1]= vChrFilter[chrDstY*vChrFilterSize + i ]
182 + (vChrFilterSize>1 ? vChrFilter[chrDstY*vChrFilterSize + i + 1]<<16 : 0);
186 *(
const void**)&lumMmxFilter[4*i+0]= lumSrcPtr[i];
189 ((uint16_t)vLumFilter[dstY*vLumFilterSize + i])*0x10001;
191 *(
const void**)&alpMmxFilter[4*i+0]= alpSrcPtr[i];
193 alpMmxFilter[4*i+3]= lumMmxFilter[4*i+2];
197 *(
const void**)&chrMmxFilter[4*i+0]= chrUSrcPtr[i];
200 ((uint16_t)vChrFilter[chrDstY*vChrFilterSize + i])*0x10001;
208 #define SCALE_FUNC(filter_n, from_bpc, to_bpc, opt) \
209 void ff_hscale ## from_bpc ## to ## to_bpc ## _ ## filter_n ## _ ## opt( \
210 SwsContext *c, int16_t *data, \
211 int dstW, const uint8_t *src, \
212 const int16_t *filter, \
213 const int32_t *filterPos, int filterSize)
215 #define SCALE_FUNCS(filter_n, opt) \
216 SCALE_FUNC(filter_n, 8, 15, opt); \
217 SCALE_FUNC(filter_n, 9, 15, opt); \
218 SCALE_FUNC(filter_n, 10, 15, opt); \
219 SCALE_FUNC(filter_n, 16, 15, opt); \
220 SCALE_FUNC(filter_n, 8, 19, opt); \
221 SCALE_FUNC(filter_n, 9, 19, opt); \
222 SCALE_FUNC(filter_n, 10, 19, opt); \
223 SCALE_FUNC(filter_n, 16, 19, opt)
225 #define SCALE_FUNCS_MMX(opt) \
226 SCALE_FUNCS(4, opt); \
227 SCALE_FUNCS(8, opt); \
230 #define SCALE_FUNCS_SSE(opt) \
231 SCALE_FUNCS(4, opt); \
232 SCALE_FUNCS(8, opt); \
233 SCALE_FUNCS(X4, opt); \
243 #define VSCALEX_FUNC(size, opt) \
244 void ff_yuv2planeX_ ## size ## _ ## opt(const int16_t *filter, int filterSize, \
245 const int16_t **src, uint8_t *dest, int dstW, \
246 const uint8_t *dither, int offset)
247 #define VSCALEX_FUNCS(opt) \
248 VSCALEX_FUNC(8, opt); \
249 VSCALEX_FUNC(9, opt); \
250 VSCALEX_FUNC(10, opt)
260 #define VSCALE_FUNC(size, opt) \
261 void ff_yuv2plane1_ ## size ## _ ## opt(const int16_t *src, uint8_t *dst, int dstW, \
262 const uint8_t *dither, int offset)
263 #define VSCALE_FUNCS(opt1, opt2) \
264 VSCALE_FUNC(8, opt1); \
265 VSCALE_FUNC(9, opt2); \
266 VSCALE_FUNC(10, opt2); \
267 VSCALE_FUNC(16, opt1)
276 #define INPUT_Y_FUNC(fmt, opt) \
277 void ff_ ## fmt ## ToY_ ## opt(uint8_t *dst, const uint8_t *src, \
278 int w, uint32_t *unused)
279 #define INPUT_UV_FUNC(fmt, opt) \
280 void ff_ ## fmt ## ToUV_ ## opt(uint8_t *dstU, uint8_t *dstV, \
281 const uint8_t *src, const uint8_t *unused1, \
282 int w, uint32_t *unused2)
283 #define INPUT_FUNC(fmt, opt) \
284 INPUT_Y_FUNC(fmt, opt); \
285 INPUT_UV_FUNC(fmt, opt)
286 #define INPUT_FUNCS(opt) \
287 INPUT_FUNC(uyvy, opt); \
288 INPUT_FUNC(yuyv, opt); \
289 INPUT_UV_FUNC(nv12, opt); \
290 INPUT_UV_FUNC(nv21, opt); \
291 INPUT_FUNC(rgba, opt); \
292 INPUT_FUNC(bgra, opt); \
293 INPUT_FUNC(argb, opt); \
294 INPUT_FUNC(abgr, opt); \
295 INPUT_FUNC(rgb24, opt); \
296 INPUT_FUNC(bgr24, opt)
311 sws_init_swscale_mmx(c);
313 #if HAVE_MMXEXT_INLINE
315 sws_init_swscale_mmxext(c);
318 #define ASSIGN_SCALE_FUNC2(hscalefn, filtersize, opt1, opt2) do { \
319 if (c->srcBpc == 8) { \
320 hscalefn = c->dstBpc <= 10 ? ff_hscale8to15_ ## filtersize ## _ ## opt2 : \
321 ff_hscale8to19_ ## filtersize ## _ ## opt1; \
322 } else if (c->srcBpc == 9) { \
323 hscalefn = c->dstBpc <= 10 ? ff_hscale9to15_ ## filtersize ## _ ## opt2 : \
324 ff_hscale9to19_ ## filtersize ## _ ## opt1; \
325 } else if (c->srcBpc == 10) { \
326 hscalefn = c->dstBpc <= 10 ? ff_hscale10to15_ ## filtersize ## _ ## opt2 : \
327 ff_hscale10to19_ ## filtersize ## _ ## opt1; \
329 hscalefn = c->dstBpc <= 10 ? ff_hscale16to15_ ## filtersize ## _ ## opt2 : \
330 ff_hscale16to19_ ## filtersize ## _ ## opt1; \
333 #define ASSIGN_MMX_SCALE_FUNC(hscalefn, filtersize, opt1, opt2) \
334 switch (filtersize) { \
335 case 4: ASSIGN_SCALE_FUNC2(hscalefn, 4, opt1, opt2); break; \
336 case 8: ASSIGN_SCALE_FUNC2(hscalefn, 8, opt1, opt2); break; \
337 default: ASSIGN_SCALE_FUNC2(hscalefn, X, opt1, opt2); break; \
339 #define ASSIGN_VSCALEX_FUNC(vscalefn, opt, do_16_case, condition_8bit) \
341 case 16: do_16_case; break; \
342 case 10: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2planeX_10_ ## opt; break; \
343 case 9: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2planeX_9_ ## opt; break; \
344 default: if (condition_8bit) vscalefn = ff_yuv2planeX_8_ ## opt; break; \
346 #define ASSIGN_VSCALE_FUNC(vscalefn, opt1, opt2, opt2chk) \
348 case 16: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2plane1_16_ ## opt1; break; \
349 case 10: if (!isBE(c->dstFormat) && opt2chk) vscalefn = ff_yuv2plane1_10_ ## opt2; break; \
350 case 9: if (!isBE(c->dstFormat) && opt2chk) vscalefn = ff_yuv2plane1_9_ ## opt2; break; \
351 default: vscalefn = ff_yuv2plane1_8_ ## opt1; break; \
353 #define case_rgb(x, X, opt) \
354 case AV_PIX_FMT_ ## X: \
355 c->lumToYV12 = ff_ ## x ## ToY_ ## opt; \
356 if (!c->chrSrcHSubSample) \
357 c->chrToYV12 = ff_ ## x ## ToUV_ ## opt; \
399 #define ASSIGN_SSE_SCALE_FUNC(hscalefn, filtersize, opt1, opt2) \
400 switch (filtersize) { \
401 case 4: ASSIGN_SCALE_FUNC2(hscalefn, 4, opt1, opt2); break; \
402 case 8: ASSIGN_SCALE_FUNC2(hscalefn, 8, opt1, opt2); break; \
403 default: if (filtersize & 4) ASSIGN_SCALE_FUNC2(hscalefn, X4, opt1, opt2); \
404 else ASSIGN_SCALE_FUNC2(hscalefn, X8, opt1, opt2); \