35 0x0200020002000200LL,};
39 0x0004000400040004LL,};
51 #if HAVE_MMXEXT_INLINE
53 #undef COMPILE_TEMPLATE_MMXEXT
54 #define COMPILE_TEMPLATE_MMXEXT 1
55 #define RENAME(a) a ## _mmxext
61 const int dstH=
c->opts.dst_h;
62 const int flags=
c->opts.flags;
64 SwsPlane *lumPlane = &
c->slice[
c->numSlice-2].plane[0];
65 SwsPlane *chrUPlane = &
c->slice[
c->numSlice-2].plane[1];
66 SwsPlane *alpPlane = &
c->slice[
c->numSlice-2].plane[3];
68 int hasAlpha =
c->needAlpha;
69 int32_t *vLumFilterPos=
c->vLumFilterPos;
70 int32_t *vChrFilterPos=
c->vChrFilterPos;
71 int16_t *vLumFilter=
c->vLumFilter;
72 int16_t *vChrFilter=
c->vChrFilter;
73 int32_t *lumMmxFilter=
c->lumMmxFilter;
74 int32_t *chrMmxFilter=
c->chrMmxFilter;
76 const int vLumFilterSize=
c->vLumFilterSize;
77 const int vChrFilterSize=
c->vChrFilterSize;
78 const int chrDstY= dstY>>
c->chrDstVSubSample;
79 const int firstLumSrcY= vLumFilterPos[dstY];
80 const int firstChrSrcY= vChrFilterPos[chrDstY];
88 if (dstY < dstH - 2) {
89 const int16_t **lumSrcPtr = (
const int16_t **)(
void*) lumPlane->
line + firstLumSrcY - lumPlane->
sliceY;
90 const int16_t **chrUSrcPtr = (
const int16_t **)(
void*) chrUPlane->
line + firstChrSrcY - chrUPlane->
sliceY;
91 const int16_t **alpSrcPtr = (CONFIG_SWSCALE_ALPHA && hasAlpha) ? (
const int16_t **)(
void*) alpPlane->
line + firstLumSrcY - alpPlane->
sliceY :
NULL;
94 if (firstLumSrcY < 0 || firstLumSrcY + vLumFilterSize >
c->opts.src_h) {
95 const int16_t **tmpY = (
const int16_t **) lumPlane->
tmp;
97 int neg = -firstLumSrcY,
i, end =
FFMIN(
c->opts.src_h - firstLumSrcY, vLumFilterSize);
98 for (
i = 0;
i < neg;
i++)
99 tmpY[
i] = lumSrcPtr[neg];
100 for ( ;
i < end;
i++)
101 tmpY[
i] = lumSrcPtr[
i];
102 for ( ;
i < vLumFilterSize;
i++)
107 const int16_t **tmpA = (
const int16_t **) alpPlane->
tmp;
109 tmpA[
i] = alpSrcPtr[neg];
110 for ( ;
i < end;
i++)
111 tmpA[
i] = alpSrcPtr[
i];
112 for ( ;
i < vLumFilterSize;
i++)
113 tmpA[
i] = tmpA[
i - 1];
117 if (firstChrSrcY < 0 || firstChrSrcY + vChrFilterSize >
c->chrSrcH) {
118 const int16_t **tmpU = (
const int16_t **) chrUPlane->
tmp;
119 int neg = -firstChrSrcY,
i, end =
FFMIN(
c->chrSrcH - firstChrSrcY, vChrFilterSize);
120 for (
i = 0;
i < neg;
i++) {
121 tmpU[
i] = chrUSrcPtr[neg];
123 for ( ;
i < end;
i++) {
124 tmpU[
i] = chrUSrcPtr[
i];
126 for ( ;
i < vChrFilterSize;
i++) {
127 tmpU[
i] = tmpU[
i - 1];
134 for (
i=0;
i<vLumFilterSize;
i+=2) {
135 *(
const void**)&lumMmxFilter[
s*
i ]= lumSrcPtr[
i ];
136 *(
const void**)&lumMmxFilter[
s*
i+
APCK_PTR2/4 ]= lumSrcPtr[
i+(vLumFilterSize>1)];
138 lumMmxFilter[
s*
i+
APCK_COEF/4+1]= vLumFilter[dstY*vLumFilterSize +
i ]
139 + (vLumFilterSize>1 ? vLumFilter[dstY*vLumFilterSize +
i + 1] * (1 << 16) : 0);
140 if (CONFIG_SWSCALE_ALPHA && hasAlpha) {
141 *(
const void**)&alpMmxFilter[
s*
i ]= alpSrcPtr[
i ];
142 *(
const void**)&alpMmxFilter[
s*
i+
APCK_PTR2/4 ]= alpSrcPtr[
i+(vLumFilterSize>1)];
147 for (
i=0;
i<vChrFilterSize;
i+=2) {
148 *(
const void**)&chrMmxFilter[
s*
i ]= chrUSrcPtr[
i ];
149 *(
const void**)&chrMmxFilter[
s*
i+
APCK_PTR2/4 ]= chrUSrcPtr[
i+(vChrFilterSize>1)];
151 chrMmxFilter[
s*
i+
APCK_COEF/4+1]= vChrFilter[chrDstY*vChrFilterSize +
i ]
152 + (vChrFilterSize>1 ? vChrFilter[chrDstY*vChrFilterSize +
i + 1] * (1 << 16) : 0);
155 for (
i=0;
i<vLumFilterSize;
i++) {
156 *(
const void**)&lumMmxFilter[4*
i+0]= lumSrcPtr[
i];
159 ((uint16_t)vLumFilter[dstY*vLumFilterSize +
i])*0x10001
U;
160 if (CONFIG_SWSCALE_ALPHA && hasAlpha) {
161 *(
const void**)&alpMmxFilter[4*
i+0]= alpSrcPtr[
i];
163 alpMmxFilter[4*
i+3]= lumMmxFilter[4*
i+2];
166 for (
i=0;
i<vChrFilterSize;
i++) {
167 *(
const void**)&chrMmxFilter[4*
i+0]= chrUSrcPtr[
i];
170 ((uint16_t)vChrFilter[chrDstY*vChrFilterSize +
i])*0x10001
U;
177 #define YUV2YUVX_FUNC_MMX(opt, step) \
178 void ff_yuv2yuvX_ ##opt(const int16_t *filter, int filterSize, int srcOffset, \
179 uint8_t *dest, int dstW, \
180 const uint8_t *dither, int offset); \
181 static void yuv2yuvX_ ##opt(const int16_t *filter, int filterSize, \
182 const int16_t **src, uint8_t *dest, int dstW, \
183 const uint8_t *dither, int offset) \
186 ff_yuv2yuvX_ ##opt(filter, filterSize - 1, 0, dest - offset, dstW + offset, dither, offset); \
190 #define YUV2YUVX_FUNC(opt, step) \
191 void ff_yuv2yuvX_ ##opt(const int16_t *filter, int filterSize, int srcOffset, \
192 uint8_t *dest, int dstW, \
193 const uint8_t *dither, int offset); \
194 static void yuv2yuvX_ ##opt(const int16_t *filter, int filterSize, \
195 const int16_t **src, uint8_t *dest, int dstW, \
196 const uint8_t *dither, int offset) \
198 int remainder = (dstW % step); \
199 int pixelsProcessed = dstW - remainder; \
200 if(((uintptr_t)dest) & 15){ \
201 yuv2yuvX_mmxext(filter, filterSize, src, dest, dstW, dither, offset); \
204 if(pixelsProcessed > 0) \
205 ff_yuv2yuvX_ ##opt(filter, filterSize - 1, 0, dest - offset, pixelsProcessed + offset, dither, offset); \
207 ff_yuv2yuvX_mmxext(filter, filterSize - 1, pixelsProcessed, dest - offset, pixelsProcessed + remainder + offset, dither, offset); \
212 #if HAVE_MMXEXT_EXTERNAL
215 #if HAVE_SSE3_EXTERNAL
218 #if HAVE_AVX2_EXTERNAL
222 #define SCALE_FUNC(filter_n, from_bpc, to_bpc, opt) \
223 void ff_hscale ## from_bpc ## to ## to_bpc ## _ ## filter_n ## _ ## opt( \
224 SwsInternal *c, int16_t *data, \
225 int dstW, const uint8_t *src, \
226 const int16_t *filter, \
227 const int32_t *filterPos, int filterSize)
229 #define SCALE_FUNCS(filter_n, opt) \
230 SCALE_FUNC(filter_n, 8, 15, opt); \
231 SCALE_FUNC(filter_n, 9, 15, opt); \
232 SCALE_FUNC(filter_n, 10, 15, opt); \
233 SCALE_FUNC(filter_n, 12, 15, opt); \
234 SCALE_FUNC(filter_n, 14, 15, opt); \
235 SCALE_FUNC(filter_n, 16, 15, opt); \
236 SCALE_FUNC(filter_n, 8, 19, opt); \
237 SCALE_FUNC(filter_n, 9, 19, opt); \
238 SCALE_FUNC(filter_n, 10, 19, opt); \
239 SCALE_FUNC(filter_n, 12, 19, opt); \
240 SCALE_FUNC(filter_n, 14, 19, opt); \
241 SCALE_FUNC(filter_n, 16, 19, opt)
243 #define SCALE_FUNCS_MMX(opt) \
244 SCALE_FUNCS(4, opt); \
245 SCALE_FUNCS(8, opt); \
248 #define SCALE_FUNCS_SSE(opt) \
249 SCALE_FUNCS(4, opt); \
250 SCALE_FUNCS(8, opt); \
251 SCALE_FUNCS(X4, opt); \
261 #define VSCALEX_FUNC(size, opt) \
262 void ff_yuv2planeX_ ## size ## _ ## opt(const int16_t *filter, int filterSize, \
263 const int16_t **src, uint8_t *dest, int dstW, \
264 const uint8_t *dither, int offset)
265 #define VSCALEX_FUNCS(opt) \
266 VSCALEX_FUNC(8, opt); \
267 VSCALEX_FUNC(9, opt); \
268 VSCALEX_FUNC(10, opt)
276 #define VSCALE_FUNC(size, opt) \
277 void ff_yuv2plane1_ ## size ## _ ## opt(const int16_t *src, uint8_t *dst, int dstW, \
278 const uint8_t *dither, int offset)
279 #define VSCALE_FUNCS(opt1, opt2) \
280 VSCALE_FUNC(8, opt1); \
281 VSCALE_FUNC(9, opt2); \
282 VSCALE_FUNC(10, opt2); \
283 VSCALE_FUNC(16, opt1)
289 #define INPUT_Y_FUNC(fmt, opt) \
290 void ff_ ## fmt ## ToY_ ## opt(uint8_t *dst, const uint8_t *src, \
291 const uint8_t *unused1, const uint8_t *unused2, \
292 int w, uint32_t *unused, void *opq)
293 #define INPUT_UV_FUNC(fmt, opt) \
294 void ff_ ## fmt ## ToUV_ ## opt(uint8_t *dstU, uint8_t *dstV, \
295 const uint8_t *unused0, \
296 const uint8_t *src1, \
297 const uint8_t *src2, \
298 int w, uint32_t *unused, void *opq)
299 #define INPUT_FUNC(fmt, opt) \
300 INPUT_Y_FUNC(fmt, opt); \
301 INPUT_UV_FUNC(fmt, opt)
302 #define INPUT_FUNCS(opt) \
303 INPUT_FUNC(uyvy, opt); \
304 INPUT_FUNC(yuyv, opt); \
305 INPUT_UV_FUNC(nv12, opt); \
306 INPUT_UV_FUNC(nv21, opt); \
307 INPUT_FUNC(rgba, opt); \
308 INPUT_FUNC(bgra, opt); \
309 INPUT_FUNC(argb, opt); \
310 INPUT_FUNC(abgr, opt); \
311 INPUT_FUNC(rgb24, opt); \
312 INPUT_FUNC(bgr24, opt)
325 #define YUV2NV_DECL(fmt, opt) \
326 void ff_yuv2 ## fmt ## cX_ ## opt(enum AVPixelFormat format, const uint8_t *dither, \
327 const int16_t *filter, int filterSize, \
328 const int16_t **u, const int16_t **v, \
329 uint8_t *dst, int dstWidth)
331 YUV2NV_DECL(nv12, avx2);
332 YUV2NV_DECL(nv21, avx2);
334 #define YUV2GBRP_FN_DECL(fmt, opt) \
335 void ff_yuv2##fmt##_full_X_ ##opt(SwsInternal *c, const int16_t *lumFilter, \
336 const int16_t **lumSrcx, int lumFilterSize, \
337 const int16_t *chrFilter, const int16_t **chrUSrcx, \
338 const int16_t **chrVSrcx, int chrFilterSize, \
339 const int16_t **alpSrcx, uint8_t **dest, \
342 #define YUV2GBRP_DECL(opt) \
343 YUV2GBRP_FN_DECL(gbrp, opt); \
344 YUV2GBRP_FN_DECL(gbrap, opt); \
345 YUV2GBRP_FN_DECL(gbrp9le, opt); \
346 YUV2GBRP_FN_DECL(gbrp10le, opt); \
347 YUV2GBRP_FN_DECL(gbrap10le, opt); \
348 YUV2GBRP_FN_DECL(gbrp12le, opt); \
349 YUV2GBRP_FN_DECL(gbrap12le, opt); \
350 YUV2GBRP_FN_DECL(gbrp14le, opt); \
351 YUV2GBRP_FN_DECL(gbrp16le, opt); \
352 YUV2GBRP_FN_DECL(gbrap16le, opt); \
353 YUV2GBRP_FN_DECL(gbrpf32le, opt); \
354 YUV2GBRP_FN_DECL(gbrapf32le, opt); \
355 YUV2GBRP_FN_DECL(gbrp9be, opt); \
356 YUV2GBRP_FN_DECL(gbrp10be, opt); \
357 YUV2GBRP_FN_DECL(gbrap10be, opt); \
358 YUV2GBRP_FN_DECL(gbrp12be, opt); \
359 YUV2GBRP_FN_DECL(gbrap12be, opt); \
360 YUV2GBRP_FN_DECL(gbrp14be, opt); \
361 YUV2GBRP_FN_DECL(gbrp16be, opt); \
362 YUV2GBRP_FN_DECL(gbrap16be, opt); \
363 YUV2GBRP_FN_DECL(gbrpf32be, opt); \
364 YUV2GBRP_FN_DECL(gbrapf32be, opt)
370 #define INPUT_PLANAR_RGB_Y_FN_DECL(fmt, opt) \
371 void ff_planar_##fmt##_to_y_##opt(uint8_t *dst, \
372 const uint8_t *src[4], int w, int32_t *rgb2yuv, \
375 #define INPUT_PLANAR_RGB_UV_FN_DECL(fmt, opt) \
376 void ff_planar_##fmt##_to_uv_##opt(uint8_t *dstU, uint8_t *dstV, \
377 const uint8_t *src[4], int w, int32_t *rgb2yuv, \
380 #define INPUT_PLANAR_RGB_A_FN_DECL(fmt, opt) \
381 void ff_planar_##fmt##_to_a_##opt(uint8_t *dst, \
382 const uint8_t *src[4], int w, int32_t *rgb2yuv, \
386 #define INPUT_PLANAR_RGBXX_A_DECL(fmt, opt) \
387 INPUT_PLANAR_RGB_A_FN_DECL(fmt##le, opt); \
388 INPUT_PLANAR_RGB_A_FN_DECL(fmt##be, opt)
390 #define INPUT_PLANAR_RGBXX_Y_DECL(fmt, opt) \
391 INPUT_PLANAR_RGB_Y_FN_DECL(fmt##le, opt); \
392 INPUT_PLANAR_RGB_Y_FN_DECL(fmt##be, opt)
394 #define INPUT_PLANAR_RGBXX_UV_DECL(fmt, opt) \
395 INPUT_PLANAR_RGB_UV_FN_DECL(fmt##le, opt); \
396 INPUT_PLANAR_RGB_UV_FN_DECL(fmt##be, opt)
398 #define INPUT_PLANAR_RGBXX_YUVA_DECL(fmt, opt) \
399 INPUT_PLANAR_RGBXX_Y_DECL(fmt, opt); \
400 INPUT_PLANAR_RGBXX_UV_DECL(fmt, opt); \
401 INPUT_PLANAR_RGBXX_A_DECL(fmt, opt)
403 #define INPUT_PLANAR_RGBXX_YUV_DECL(fmt, opt) \
404 INPUT_PLANAR_RGBXX_Y_DECL(fmt, opt); \
405 INPUT_PLANAR_RGBXX_UV_DECL(fmt, opt)
407 #define INPUT_PLANAR_RGBXX_UVA_DECL(fmt, opt) \
408 INPUT_PLANAR_RGBXX_UV_DECL(fmt, opt); \
409 INPUT_PLANAR_RGBXX_A_DECL(fmt, opt)
411 #define INPUT_PLANAR_RGB_A_ALL_DECL(opt) \
412 INPUT_PLANAR_RGB_A_FN_DECL(rgb, opt); \
413 INPUT_PLANAR_RGBXX_A_DECL(rgb10, opt); \
414 INPUT_PLANAR_RGBXX_A_DECL(rgb12, opt); \
415 INPUT_PLANAR_RGBXX_A_DECL(rgb16, opt); \
416 INPUT_PLANAR_RGBXX_A_DECL(rgbf32, opt)
418 #define INPUT_PLANAR_RGB_Y_ALL_DECL(opt) \
419 INPUT_PLANAR_RGB_Y_FN_DECL(rgb, opt); \
420 INPUT_PLANAR_RGBXX_Y_DECL(rgb9, opt); \
421 INPUT_PLANAR_RGBXX_Y_DECL(rgb10, opt); \
422 INPUT_PLANAR_RGBXX_Y_DECL(rgb12, opt); \
423 INPUT_PLANAR_RGBXX_Y_DECL(rgb14, opt); \
424 INPUT_PLANAR_RGBXX_Y_DECL(rgb16, opt); \
425 INPUT_PLANAR_RGBXX_Y_DECL(rgbf32, opt)
427 #define INPUT_PLANAR_RGB_UV_ALL_DECL(opt) \
428 INPUT_PLANAR_RGB_UV_FN_DECL(rgb, opt); \
429 INPUT_PLANAR_RGBXX_UV_DECL(rgb9, opt); \
430 INPUT_PLANAR_RGBXX_UV_DECL(rgb10, opt); \
431 INPUT_PLANAR_RGBXX_UV_DECL(rgb12, opt); \
432 INPUT_PLANAR_RGBXX_UV_DECL(rgb14, opt); \
433 INPUT_PLANAR_RGBXX_UV_DECL(rgb16, opt); \
434 INPUT_PLANAR_RGBXX_UV_DECL(rgbf32, opt)
436 INPUT_PLANAR_RGBXX_Y_DECL(rgbf32, sse2);
437 INPUT_PLANAR_RGB_UV_ALL_DECL(sse2);
438 INPUT_PLANAR_RGB_A_ALL_DECL(sse2);
440 INPUT_PLANAR_RGB_Y_ALL_DECL(sse4);
441 INPUT_PLANAR_RGB_UV_ALL_DECL(sse4);
442 INPUT_PLANAR_RGBXX_A_DECL(rgbf32, sse4);
444 INPUT_PLANAR_RGB_Y_ALL_DECL(avx2);
445 INPUT_PLANAR_RGB_UV_ALL_DECL(avx2);
446 INPUT_PLANAR_RGB_A_ALL_DECL(avx2);
449 #define RANGE_CONVERT_FUNCS(opt, bpc) do { \
450 if (c->opts.src_range) { \
451 c->lumConvertRange = ff_lumRangeFromJpeg##bpc##_##opt; \
452 c->chrConvertRange = ff_chrRangeFromJpeg##bpc##_##opt; \
454 c->lumConvertRange = ff_lumRangeToJpeg##bpc##_##opt; \
455 c->chrConvertRange = ff_chrRangeToJpeg##bpc##_##opt; \
459 #define RANGE_CONVERT_FUNCS_DECL(opt, bpc) \
460 void ff_lumRangeFromJpeg##bpc##_##opt(int16_t *dst, int width, \
461 uint32_t coeff, int64_t offset); \
462 void ff_chrRangeFromJpeg##bpc##_##opt(int16_t *dstU, int16_t *dstV, int width, \
463 uint32_t coeff, int64_t offset); \
464 void ff_lumRangeToJpeg##bpc##_##opt(int16_t *dst, int width, \
465 uint32_t coeff, int64_t offset); \
466 void ff_chrRangeToJpeg##bpc##_##opt(int16_t *dstU, int16_t *dstV, int width, \
467 uint32_t coeff, int64_t offset); \
478 if (
c->dstBpc <= 14) {
494 #if HAVE_MMXEXT_INLINE
496 sws_init_swscale_mmxext(
c);
499 #if HAVE_MMXEXT_EXTERNAL
501 c->yuv2planeX = yuv2yuvX_mmxext;
503 #if HAVE_SSE3_EXTERNAL
505 c->yuv2planeX = yuv2yuvX_sse3;
507 #if HAVE_AVX2_EXTERNAL
509 c->yuv2planeX = yuv2yuvX_avx2;
512 #if ARCH_X86_32 && !HAVE_ALIGNED_STACK
516 if (
c->dstBpc == 8 && !
c->use_mmx_vfilter)
517 c->yuv2planeX = ff_yuv2planeX_8_mmxext;
521 #define ASSIGN_SCALE_FUNC2(hscalefn, filtersize, opt1, opt2) do { \
522 if (c->srcBpc == 8) { \
523 hscalefn = c->dstBpc <= 14 ? ff_hscale8to15_ ## filtersize ## _ ## opt2 : \
524 ff_hscale8to19_ ## filtersize ## _ ## opt1; \
525 } else if (c->srcBpc == 9) { \
526 hscalefn = c->dstBpc <= 14 ? ff_hscale9to15_ ## filtersize ## _ ## opt2 : \
527 ff_hscale9to19_ ## filtersize ## _ ## opt1; \
528 } else if (c->srcBpc == 10) { \
529 hscalefn = c->dstBpc <= 14 ? ff_hscale10to15_ ## filtersize ## _ ## opt2 : \
530 ff_hscale10to19_ ## filtersize ## _ ## opt1; \
531 } else if (c->srcBpc == 12) { \
532 hscalefn = c->dstBpc <= 14 ? ff_hscale12to15_ ## filtersize ## _ ## opt2 : \
533 ff_hscale12to19_ ## filtersize ## _ ## opt1; \
534 } else if (c->srcBpc == 14 || ((c->opts.src_format==AV_PIX_FMT_PAL8||isAnyRGB(c->opts.src_format)) && av_pix_fmt_desc_get(c->opts.src_format)->comp[0].depth<16)) { \
535 hscalefn = c->dstBpc <= 14 ? ff_hscale14to15_ ## filtersize ## _ ## opt2 : \
536 ff_hscale14to19_ ## filtersize ## _ ## opt1; \
538 av_assert0(c->srcBpc == 16);\
539 hscalefn = c->dstBpc <= 14 ? ff_hscale16to15_ ## filtersize ## _ ## opt2 : \
540 ff_hscale16to19_ ## filtersize ## _ ## opt1; \
543 #define ASSIGN_VSCALEX_FUNC(vscalefn, opt, do_16_case, condition_8bit) \
545 case 16: do_16_case; break; \
546 case 10: if (!isBE(c->opts.dst_format) && !isSemiPlanarYUV(c->opts.dst_format)) vscalefn = ff_yuv2planeX_10_ ## opt; break; \
547 case 9: if (!isBE(c->opts.dst_format)) vscalefn = ff_yuv2planeX_9_ ## opt; break; \
548 case 8: if ((condition_8bit) && !c->use_mmx_vfilter) vscalefn = ff_yuv2planeX_8_ ## opt; break; \
550 #define ASSIGN_VSCALE_FUNC(vscalefn, opt) \
552 case 16: if (!isBE(c->opts.dst_format)) vscalefn = ff_yuv2plane1_16_ ## opt; break; \
553 case 10: if (!isBE(c->opts.dst_format) && !isSemiPlanarYUV(c->opts.dst_format)) vscalefn = ff_yuv2plane1_10_ ## opt; break; \
554 case 9: if (!isBE(c->opts.dst_format)) vscalefn = ff_yuv2plane1_9_ ## opt; break; \
555 case 8: vscalefn = ff_yuv2plane1_8_ ## opt; break; \
556 default: av_assert0(c->dstBpc>8); \
558 #define case_rgb(x, X, opt) \
559 case AV_PIX_FMT_ ## X: \
560 c->lumToYV12 = ff_ ## x ## ToY_ ## opt; \
561 if (!c->chrSrcHSubSample) \
562 c->chrToYV12 = ff_ ## x ## ToUV_ ## opt; \
564 #define ASSIGN_SSE_SCALE_FUNC(hscalefn, filtersize, opt1, opt2) \
565 switch (filtersize) { \
566 case 4: ASSIGN_SCALE_FUNC2(hscalefn, 4, opt1, opt2); break; \
567 case 8: ASSIGN_SCALE_FUNC2(hscalefn, 8, opt1, opt2); break; \
568 default: if (filtersize & 4) ASSIGN_SCALE_FUNC2(hscalefn, X4, opt1, opt2); \
569 else ASSIGN_SCALE_FUNC2(hscalefn, X8, opt1, opt2); \
576 HAVE_ALIGNED_STACK || ARCH_X86_64);
580 switch (
c->opts.src_format) {
582 c->lumToYV12 = ff_yuyvToY_sse2;
584 c->alpToYV12 = ff_uyvyToY_sse2;
587 c->lumToYV12 = ff_yuyvToY_sse2;
588 c->chrToYV12 = ff_yuyvToUV_sse2;
591 c->lumToYV12 = ff_uyvyToY_sse2;
592 c->chrToYV12 = ff_uyvyToUV_sse2;
595 c->chrToYV12 = ff_nv12ToUV_sse2;
598 c->chrToYV12 = ff_nv21ToUV_sse2;
613 switch (
c->opts.src_format) {
625 if (!
isBE(
c->opts.dst_format))
c->yuv2planeX = ff_yuv2planeX_16_sse4,
626 HAVE_ALIGNED_STACK || ARCH_X86_64);
628 c->yuv2plane1 = ff_yuv2plane1_16_sse4;
633 HAVE_ALIGNED_STACK || ARCH_X86_64);
637 switch (
c->opts.src_format) {
639 c->chrToYV12 = ff_yuyvToUV_avx;
642 c->chrToYV12 = ff_uyvyToUV_avx;
645 c->chrToYV12 = ff_nv12ToUV_avx;
648 c->chrToYV12 = ff_nv21ToUV_avx;
662 #define ASSIGN_AVX2_SCALE_FUNC(hscalefn, filtersize) \
663 switch (filtersize) { \
664 case 4: hscalefn = ff_hscale8to15_4_avx2; break; \
665 default: hscalefn = ff_hscale8to15_X4_avx2; break; \
670 if ((
c->srcBpc == 8) && (
c->dstBpc <= 14)) {
671 ASSIGN_AVX2_SCALE_FUNC(
c->hcScale,
c->hChrFilterSize);
672 ASSIGN_AVX2_SCALE_FUNC(
c->hyScale,
c->hLumFilterSize);
678 switch (
c->opts.src_format) {
687 switch (
c->opts.dst_format) {
690 c->yuv2nv12cX = ff_yuv2nv12cX_avx2;
694 c->yuv2nv12cX = ff_yuv2nv21cX_avx2;
702 #define INPUT_PLANER_RGB_A_FUNC_CASE_NOBREAK(fmt, name, opt) \
704 c->readAlpPlanar = ff_planar_##name##_to_a_##opt;
706 #define INPUT_PLANER_RGBA_YUV_FUNC_CASE(rgb_fmt, rgba_fmt, name, opt) \
709 c->readLumPlanar = ff_planar_##name##_to_y_##opt; \
710 c->readChrPlanar = ff_planar_##name##_to_uv_##opt; \
713 #define INPUT_PLANER_RGB_YUV_FUNC_CASE(fmt, name, opt) \
715 c->readLumPlanar = ff_planar_##name##_to_y_##opt; \
716 c->readChrPlanar = ff_planar_##name##_to_uv_##opt; \
719 #define INPUT_PLANER_RGB_UV_FUNC_CASE(fmt, name, opt) \
721 c->readChrPlanar = ff_planar_##name##_to_uv_##opt; \
724 #define INPUT_PLANER_RGBAXX_YUVA_FUNC_CASE(rgb_fmt, rgba_fmt, name, opt) \
725 INPUT_PLANER_RGB_A_FUNC_CASE_NOBREAK(rgba_fmt##LE, name##le, opt) \
726 INPUT_PLANER_RGB_YUV_FUNC_CASE(rgb_fmt##LE, name##le, opt) \
727 INPUT_PLANER_RGB_A_FUNC_CASE_NOBREAK(rgba_fmt##BE, name##be, opt) \
728 INPUT_PLANER_RGB_YUV_FUNC_CASE(rgb_fmt##BE, name##be, opt)
730 #define INPUT_PLANER_RGBAXX_UVA_FUNC_CASE(rgb_fmt, rgba_fmt, name, opt) \
731 INPUT_PLANER_RGB_A_FUNC_CASE_NOBREAK(rgba_fmt##LE, name##le, opt) \
732 INPUT_PLANER_RGB_UV_FUNC_CASE(rgb_fmt##LE, name##le, opt) \
733 INPUT_PLANER_RGB_A_FUNC_CASE_NOBREAK(rgba_fmt##BE, name##be, opt) \
734 INPUT_PLANER_RGB_UV_FUNC_CASE(rgb_fmt##BE, name##be, opt)
736 #define INPUT_PLANER_RGBAXX_YUV_FUNC_CASE(rgb_fmt, rgba_fmt, name, opt) \
737 INPUT_PLANER_RGBA_YUV_FUNC_CASE(rgb_fmt##LE, rgba_fmt##LE, name##le, opt) \
738 INPUT_PLANER_RGBA_YUV_FUNC_CASE(rgb_fmt##BE, rgba_fmt##BE, name##be, opt)
740 #define INPUT_PLANER_RGBXX_YUV_FUNC_CASE(rgb_fmt, name, opt) \
741 INPUT_PLANER_RGB_YUV_FUNC_CASE(rgb_fmt##LE, name##le, opt) \
742 INPUT_PLANER_RGB_YUV_FUNC_CASE(rgb_fmt##BE, name##be, opt)
744 #define INPUT_PLANER_RGBXX_UV_FUNC_CASE(rgb_fmt, name, opt) \
745 INPUT_PLANER_RGB_UV_FUNC_CASE(rgb_fmt##LE, name##le, opt) \
746 INPUT_PLANER_RGB_UV_FUNC_CASE(rgb_fmt##BE, name##be, opt)
748 #define INPUT_PLANER_RGB_YUVA_ALL_CASES(opt) \
749 INPUT_PLANER_RGB_A_FUNC_CASE_NOBREAK(AV_PIX_FMT_GBRAP, rgb, opt) \
750 INPUT_PLANER_RGB_YUV_FUNC_CASE( AV_PIX_FMT_GBRP, rgb, opt) \
751 INPUT_PLANER_RGBXX_YUV_FUNC_CASE( AV_PIX_FMT_GBRP9, rgb9, opt) \
752 INPUT_PLANER_RGBAXX_YUVA_FUNC_CASE(AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRAP10, rgb10, opt) \
753 INPUT_PLANER_RGBAXX_YUVA_FUNC_CASE(AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRAP12, rgb12, opt) \
754 INPUT_PLANER_RGBXX_YUV_FUNC_CASE( AV_PIX_FMT_GBRP14, rgb14, opt) \
755 INPUT_PLANER_RGBAXX_YUVA_FUNC_CASE(AV_PIX_FMT_GBRP16, AV_PIX_FMT_GBRAP16, rgb16, opt) \
756 INPUT_PLANER_RGBAXX_YUVA_FUNC_CASE(AV_PIX_FMT_GBRPF32, AV_PIX_FMT_GBRAPF32, rgbf32, opt)
760 switch (
c->opts.src_format) {
775 switch (
c->opts.src_format) {
790 switch (
c->opts.src_format) {
791 INPUT_PLANER_RGB_YUVA_ALL_CASES(avx2)
799 #define YUV2ANYX_FUNC_CASE(fmt, name, opt) \
801 c->yuv2anyX = ff_yuv2##name##_full_X_##opt; \
804 #define YUV2ANYX_GBRAP_CASES(opt) \
805 YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRP, gbrp, opt) \
806 YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRAP, gbrap, opt) \
807 YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRP9LE, gbrp9le, opt) \
808 YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRP10LE, gbrp10le, opt) \
809 YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRAP10LE, gbrap10le, opt) \
810 YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRP12LE, gbrp12le, opt) \
811 YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRAP12LE, gbrap12le, opt) \
812 YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRP14LE, gbrp14le, opt) \
813 YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRP16LE, gbrp16le, opt) \
814 YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRAP16LE, gbrap16le, opt) \
815 YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRPF32LE, gbrpf32le, opt) \
816 YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRAPF32LE, gbrapf32le, opt) \
817 YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRP9BE, gbrp9be, opt) \
818 YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRP10BE, gbrp10be, opt) \
819 YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRAP10BE, gbrap10be, opt) \
820 YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRP12BE, gbrp12be, opt) \
821 YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRAP12BE, gbrap12be, opt) \
822 YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRP14BE, gbrp14be, opt) \
823 YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRP16BE, gbrp16be, opt) \
824 YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRAP16BE, gbrap16be, opt) \
825 YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRPF32BE, gbrpf32be, opt) \
826 YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRAPF32BE, gbrapf32be, opt)
829 switch (
c->opts.dst_format) {
830 YUV2ANYX_GBRAP_CASES(sse2)
837 switch (
c->opts.dst_format) {
838 YUV2ANYX_GBRAP_CASES(sse4)
845 switch (
c->opts.dst_format) {
846 YUV2ANYX_GBRAP_CASES(avx2)