swscale.c 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808
  1. /*
  2. * Copyright (C) 2001-2011 Michael Niedermayer <michaelni@gmx.at>
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include <inttypes.h>
  21. #include "config.h"
  22. #include "libswscale/swscale.h"
  23. #include "libswscale/swscale_internal.h"
  24. #include "libavutil/attributes.h"
  25. #include "libavutil/avassert.h"
  26. #include "libavutil/intreadwrite.h"
  27. #include "libavutil/x86/cpu.h"
  28. #include "libavutil/cpu.h"
  29. #include "libavutil/mem_internal.h"
  30. #include "libavutil/pixdesc.h"
  31. const DECLARE_ALIGNED(8, uint64_t, ff_dither4)[2] = {
  32. 0x0103010301030103LL,
  33. 0x0200020002000200LL,};
  34. const DECLARE_ALIGNED(8, uint64_t, ff_dither8)[2] = {
  35. 0x0602060206020602LL,
  36. 0x0004000400040004LL,};
  37. #if HAVE_INLINE_ASM
  38. #define DITHER1XBPP
  39. DECLARE_ASM_CONST(8, uint64_t, bF8)= 0xF8F8F8F8F8F8F8F8LL;
  40. DECLARE_ASM_CONST(8, uint64_t, bFC)= 0xFCFCFCFCFCFCFCFCLL;
  41. DECLARE_ASM_ALIGNED(8, const uint64_t, ff_M24A) = 0x00FF0000FF0000FFLL;
  42. DECLARE_ASM_ALIGNED(8, const uint64_t, ff_M24B) = 0xFF0000FF0000FF00LL;
  43. DECLARE_ASM_ALIGNED(8, const uint64_t, ff_M24C) = 0x0000FF0000FF0000LL;
  44. DECLARE_ASM_ALIGNED(8, const uint64_t, ff_bgr2YOffset) = 0x1010101010101010ULL;
  45. DECLARE_ASM_ALIGNED(8, const uint64_t, ff_bgr2UVOffset) = 0x8080808080808080ULL;
  46. DECLARE_ASM_ALIGNED(8, const uint64_t, ff_w1111) = 0x0001000100010001ULL;
  47. // MMXEXT versions
  48. #if HAVE_MMXEXT_INLINE
  49. #undef RENAME
  50. #undef COMPILE_TEMPLATE_MMXEXT
  51. #define COMPILE_TEMPLATE_MMXEXT 1
  52. #define RENAME(a) a ## _mmxext
  53. #include "swscale_template.c"
  54. #endif
  55. void ff_updateMMXDitherTables(SwsContext *c, int dstY)
  56. {
  57. const int dstH= c->dstH;
  58. const int flags= c->flags;
  59. SwsPlane *lumPlane = &c->slice[c->numSlice-2].plane[0];
  60. SwsPlane *chrUPlane = &c->slice[c->numSlice-2].plane[1];
  61. SwsPlane *alpPlane = &c->slice[c->numSlice-2].plane[3];
  62. int hasAlpha = c->needAlpha;
  63. int32_t *vLumFilterPos= c->vLumFilterPos;
  64. int32_t *vChrFilterPos= c->vChrFilterPos;
  65. int16_t *vLumFilter= c->vLumFilter;
  66. int16_t *vChrFilter= c->vChrFilter;
  67. int32_t *lumMmxFilter= c->lumMmxFilter;
  68. int32_t *chrMmxFilter= c->chrMmxFilter;
  69. int32_t av_unused *alpMmxFilter= c->alpMmxFilter;
  70. const int vLumFilterSize= c->vLumFilterSize;
  71. const int vChrFilterSize= c->vChrFilterSize;
  72. const int chrDstY= dstY>>c->chrDstVSubSample;
  73. const int firstLumSrcY= vLumFilterPos[dstY]; //First line needed as input
  74. const int firstChrSrcY= vChrFilterPos[chrDstY]; //First line needed as input
  75. c->blueDither= ff_dither8[dstY&1];
  76. if (c->dstFormat == AV_PIX_FMT_RGB555 || c->dstFormat == AV_PIX_FMT_BGR555)
  77. c->greenDither= ff_dither8[dstY&1];
  78. else
  79. c->greenDither= ff_dither4[dstY&1];
  80. c->redDither= ff_dither8[(dstY+1)&1];
  81. if (dstY < dstH - 2) {
  82. const int16_t **lumSrcPtr = (const int16_t **)(void*) lumPlane->line + firstLumSrcY - lumPlane->sliceY;
  83. const int16_t **chrUSrcPtr = (const int16_t **)(void*) chrUPlane->line + firstChrSrcY - chrUPlane->sliceY;
  84. const int16_t **alpSrcPtr = (CONFIG_SWSCALE_ALPHA && hasAlpha) ? (const int16_t **)(void*) alpPlane->line + firstLumSrcY - alpPlane->sliceY : NULL;
  85. int i;
  86. if (firstLumSrcY < 0 || firstLumSrcY + vLumFilterSize > c->srcH) {
  87. const int16_t **tmpY = (const int16_t **) lumPlane->tmp;
  88. int neg = -firstLumSrcY, i, end = FFMIN(c->srcH - firstLumSrcY, vLumFilterSize);
  89. for (i = 0; i < neg; i++)
  90. tmpY[i] = lumSrcPtr[neg];
  91. for ( ; i < end; i++)
  92. tmpY[i] = lumSrcPtr[i];
  93. for ( ; i < vLumFilterSize; i++)
  94. tmpY[i] = tmpY[i-1];
  95. lumSrcPtr = tmpY;
  96. if (alpSrcPtr) {
  97. const int16_t **tmpA = (const int16_t **) alpPlane->tmp;
  98. for (i = 0; i < neg; i++)
  99. tmpA[i] = alpSrcPtr[neg];
  100. for ( ; i < end; i++)
  101. tmpA[i] = alpSrcPtr[i];
  102. for ( ; i < vLumFilterSize; i++)
  103. tmpA[i] = tmpA[i - 1];
  104. alpSrcPtr = tmpA;
  105. }
  106. }
  107. if (firstChrSrcY < 0 || firstChrSrcY + vChrFilterSize > c->chrSrcH) {
  108. const int16_t **tmpU = (const int16_t **) chrUPlane->tmp;
  109. int neg = -firstChrSrcY, i, end = FFMIN(c->chrSrcH - firstChrSrcY, vChrFilterSize);
  110. for (i = 0; i < neg; i++) {
  111. tmpU[i] = chrUSrcPtr[neg];
  112. }
  113. for ( ; i < end; i++) {
  114. tmpU[i] = chrUSrcPtr[i];
  115. }
  116. for ( ; i < vChrFilterSize; i++) {
  117. tmpU[i] = tmpU[i - 1];
  118. }
  119. chrUSrcPtr = tmpU;
  120. }
  121. if (flags & SWS_ACCURATE_RND) {
  122. int s= APCK_SIZE / 8;
  123. for (i=0; i<vLumFilterSize; i+=2) {
  124. *(const void**)&lumMmxFilter[s*i ]= lumSrcPtr[i ];
  125. *(const void**)&lumMmxFilter[s*i+APCK_PTR2/4 ]= lumSrcPtr[i+(vLumFilterSize>1)];
  126. lumMmxFilter[s*i+APCK_COEF/4 ]=
  127. lumMmxFilter[s*i+APCK_COEF/4+1]= vLumFilter[dstY*vLumFilterSize + i ]
  128. + (vLumFilterSize>1 ? vLumFilter[dstY*vLumFilterSize + i + 1] * (1 << 16) : 0);
  129. if (CONFIG_SWSCALE_ALPHA && hasAlpha) {
  130. *(const void**)&alpMmxFilter[s*i ]= alpSrcPtr[i ];
  131. *(const void**)&alpMmxFilter[s*i+APCK_PTR2/4 ]= alpSrcPtr[i+(vLumFilterSize>1)];
  132. alpMmxFilter[s*i+APCK_COEF/4 ]=
  133. alpMmxFilter[s*i+APCK_COEF/4+1]= lumMmxFilter[s*i+APCK_COEF/4 ];
  134. }
  135. }
  136. for (i=0; i<vChrFilterSize; i+=2) {
  137. *(const void**)&chrMmxFilter[s*i ]= chrUSrcPtr[i ];
  138. *(const void**)&chrMmxFilter[s*i+APCK_PTR2/4 ]= chrUSrcPtr[i+(vChrFilterSize>1)];
  139. chrMmxFilter[s*i+APCK_COEF/4 ]=
  140. chrMmxFilter[s*i+APCK_COEF/4+1]= vChrFilter[chrDstY*vChrFilterSize + i ]
  141. + (vChrFilterSize>1 ? vChrFilter[chrDstY*vChrFilterSize + i + 1] * (1 << 16) : 0);
  142. }
  143. } else {
  144. for (i=0; i<vLumFilterSize; i++) {
  145. *(const void**)&lumMmxFilter[4*i+0]= lumSrcPtr[i];
  146. lumMmxFilter[4*i+2]=
  147. lumMmxFilter[4*i+3]=
  148. ((uint16_t)vLumFilter[dstY*vLumFilterSize + i])*0x10001U;
  149. if (CONFIG_SWSCALE_ALPHA && hasAlpha) {
  150. *(const void**)&alpMmxFilter[4*i+0]= alpSrcPtr[i];
  151. alpMmxFilter[4*i+2]=
  152. alpMmxFilter[4*i+3]= lumMmxFilter[4*i+2];
  153. }
  154. }
  155. for (i=0; i<vChrFilterSize; i++) {
  156. *(const void**)&chrMmxFilter[4*i+0]= chrUSrcPtr[i];
  157. chrMmxFilter[4*i+2]=
  158. chrMmxFilter[4*i+3]=
  159. ((uint16_t)vChrFilter[chrDstY*vChrFilterSize + i])*0x10001U;
  160. }
  161. }
  162. }
  163. }
  164. #endif /* HAVE_INLINE_ASM */
  165. #define YUV2YUVX_FUNC_MMX(opt, step) \
  166. void ff_yuv2yuvX_ ##opt(const int16_t *filter, int filterSize, int srcOffset, \
  167. uint8_t *dest, int dstW, \
  168. const uint8_t *dither, int offset); \
  169. static void yuv2yuvX_ ##opt(const int16_t *filter, int filterSize, \
  170. const int16_t **src, uint8_t *dest, int dstW, \
  171. const uint8_t *dither, int offset) \
  172. { \
  173. if(dstW > 0) \
  174. ff_yuv2yuvX_ ##opt(filter, filterSize - 1, 0, dest - offset, dstW + offset, dither, offset); \
  175. return; \
  176. }
  177. #define YUV2YUVX_FUNC(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) \
  184. { \
  185. int remainder = (dstW % step); \
  186. int pixelsProcessed = dstW - remainder; \
  187. if(((uintptr_t)dest) & 15){ \
  188. yuv2yuvX_mmxext(filter, filterSize, src, dest, dstW, dither, offset); \
  189. return; \
  190. } \
  191. if(pixelsProcessed > 0) \
  192. ff_yuv2yuvX_ ##opt(filter, filterSize - 1, 0, dest - offset, pixelsProcessed + offset, dither, offset); \
  193. if(remainder > 0){ \
  194. ff_yuv2yuvX_mmxext(filter, filterSize - 1, pixelsProcessed, dest - offset, pixelsProcessed + remainder + offset, dither, offset); \
  195. } \
  196. return; \
  197. }
  198. #if HAVE_MMXEXT_EXTERNAL
  199. YUV2YUVX_FUNC_MMX(mmxext, 16)
  200. #endif
  201. #if HAVE_SSE3_EXTERNAL
  202. YUV2YUVX_FUNC(sse3, 32)
  203. #endif
  204. #if HAVE_AVX2_EXTERNAL
  205. YUV2YUVX_FUNC(avx2, 64)
  206. #endif
  207. #define SCALE_FUNC(filter_n, from_bpc, to_bpc, opt) \
  208. void ff_hscale ## from_bpc ## to ## to_bpc ## _ ## filter_n ## _ ## opt( \
  209. SwsContext *c, int16_t *data, \
  210. int dstW, const uint8_t *src, \
  211. const int16_t *filter, \
  212. const int32_t *filterPos, int filterSize)
  213. #define SCALE_FUNCS(filter_n, opt) \
  214. SCALE_FUNC(filter_n, 8, 15, opt); \
  215. SCALE_FUNC(filter_n, 9, 15, opt); \
  216. SCALE_FUNC(filter_n, 10, 15, opt); \
  217. SCALE_FUNC(filter_n, 12, 15, opt); \
  218. SCALE_FUNC(filter_n, 14, 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, 12, 19, opt); \
  224. SCALE_FUNC(filter_n, 14, 19, opt); \
  225. SCALE_FUNC(filter_n, 16, 19, opt)
  226. #define SCALE_FUNCS_MMX(opt) \
  227. SCALE_FUNCS(4, opt); \
  228. SCALE_FUNCS(8, opt); \
  229. SCALE_FUNCS(X, opt)
  230. #define SCALE_FUNCS_SSE(opt) \
  231. SCALE_FUNCS(4, opt); \
  232. SCALE_FUNCS(8, opt); \
  233. SCALE_FUNCS(X4, opt); \
  234. SCALE_FUNCS(X8, opt)
  235. SCALE_FUNCS_SSE(sse2);
  236. SCALE_FUNCS_SSE(ssse3);
  237. SCALE_FUNCS_SSE(sse4);
  238. SCALE_FUNC(4, 8, 15, avx2);
  239. SCALE_FUNC(X4, 8, 15, avx2);
  240. #define VSCALEX_FUNC(size, opt) \
  241. void ff_yuv2planeX_ ## size ## _ ## opt(const int16_t *filter, int filterSize, \
  242. const int16_t **src, uint8_t *dest, int dstW, \
  243. const uint8_t *dither, int offset)
  244. #define VSCALEX_FUNCS(opt) \
  245. VSCALEX_FUNC(8, opt); \
  246. VSCALEX_FUNC(9, opt); \
  247. VSCALEX_FUNC(10, opt)
  248. VSCALEX_FUNC(8, mmxext);
  249. VSCALEX_FUNCS(sse2);
  250. VSCALEX_FUNCS(sse4);
  251. VSCALEX_FUNC(16, sse4);
  252. VSCALEX_FUNCS(avx);
  253. #define VSCALE_FUNC(size, opt) \
  254. void ff_yuv2plane1_ ## size ## _ ## opt(const int16_t *src, uint8_t *dst, int dstW, \
  255. const uint8_t *dither, int offset)
  256. #define VSCALE_FUNCS(opt1, opt2) \
  257. VSCALE_FUNC(8, opt1); \
  258. VSCALE_FUNC(9, opt2); \
  259. VSCALE_FUNC(10, opt2); \
  260. VSCALE_FUNC(16, opt1)
  261. VSCALE_FUNCS(sse2, sse2);
  262. VSCALE_FUNC(16, sse4);
  263. VSCALE_FUNCS(avx, avx);
  264. #define INPUT_Y_FUNC(fmt, opt) \
  265. void ff_ ## fmt ## ToY_ ## opt(uint8_t *dst, const uint8_t *src, \
  266. const uint8_t *unused1, const uint8_t *unused2, \
  267. int w, uint32_t *unused, void *opq)
  268. #define INPUT_UV_FUNC(fmt, opt) \
  269. void ff_ ## fmt ## ToUV_ ## opt(uint8_t *dstU, uint8_t *dstV, \
  270. const uint8_t *unused0, \
  271. const uint8_t *src1, \
  272. const uint8_t *src2, \
  273. int w, uint32_t *unused, void *opq)
  274. #define INPUT_FUNC(fmt, opt) \
  275. INPUT_Y_FUNC(fmt, opt); \
  276. INPUT_UV_FUNC(fmt, opt)
  277. #define INPUT_FUNCS(opt) \
  278. INPUT_FUNC(uyvy, opt); \
  279. INPUT_FUNC(yuyv, opt); \
  280. INPUT_UV_FUNC(nv12, opt); \
  281. INPUT_UV_FUNC(nv21, opt); \
  282. INPUT_FUNC(rgba, opt); \
  283. INPUT_FUNC(bgra, opt); \
  284. INPUT_FUNC(argb, opt); \
  285. INPUT_FUNC(abgr, opt); \
  286. INPUT_FUNC(rgb24, opt); \
  287. INPUT_FUNC(bgr24, opt)
  288. INPUT_FUNCS(sse2);
  289. INPUT_FUNCS(ssse3);
  290. INPUT_FUNCS(avx);
  291. #if ARCH_X86_64
  292. #define YUV2NV_DECL(fmt, opt) \
  293. void ff_yuv2 ## fmt ## cX_ ## opt(enum AVPixelFormat format, const uint8_t *dither, \
  294. const int16_t *filter, int filterSize, \
  295. const int16_t **u, const int16_t **v, \
  296. uint8_t *dst, int dstWidth)
  297. YUV2NV_DECL(nv12, avx2);
  298. YUV2NV_DECL(nv21, avx2);
  299. #define YUV2GBRP_FN_DECL(fmt, opt) \
  300. void ff_yuv2##fmt##_full_X_ ##opt(SwsContext *c, const int16_t *lumFilter, \
  301. const int16_t **lumSrcx, int lumFilterSize, \
  302. const int16_t *chrFilter, const int16_t **chrUSrcx, \
  303. const int16_t **chrVSrcx, int chrFilterSize, \
  304. const int16_t **alpSrcx, uint8_t **dest, \
  305. int dstW, int y)
  306. #define YUV2GBRP_DECL(opt) \
  307. YUV2GBRP_FN_DECL(gbrp, opt); \
  308. YUV2GBRP_FN_DECL(gbrap, opt); \
  309. YUV2GBRP_FN_DECL(gbrp9le, opt); \
  310. YUV2GBRP_FN_DECL(gbrp10le, opt); \
  311. YUV2GBRP_FN_DECL(gbrap10le, opt); \
  312. YUV2GBRP_FN_DECL(gbrp12le, opt); \
  313. YUV2GBRP_FN_DECL(gbrap12le, opt); \
  314. YUV2GBRP_FN_DECL(gbrp14le, opt); \
  315. YUV2GBRP_FN_DECL(gbrp16le, opt); \
  316. YUV2GBRP_FN_DECL(gbrap16le, opt); \
  317. YUV2GBRP_FN_DECL(gbrpf32le, opt); \
  318. YUV2GBRP_FN_DECL(gbrapf32le, opt); \
  319. YUV2GBRP_FN_DECL(gbrp9be, opt); \
  320. YUV2GBRP_FN_DECL(gbrp10be, opt); \
  321. YUV2GBRP_FN_DECL(gbrap10be, opt); \
  322. YUV2GBRP_FN_DECL(gbrp12be, opt); \
  323. YUV2GBRP_FN_DECL(gbrap12be, opt); \
  324. YUV2GBRP_FN_DECL(gbrp14be, opt); \
  325. YUV2GBRP_FN_DECL(gbrp16be, opt); \
  326. YUV2GBRP_FN_DECL(gbrap16be, opt); \
  327. YUV2GBRP_FN_DECL(gbrpf32be, opt); \
  328. YUV2GBRP_FN_DECL(gbrapf32be, opt)
  329. YUV2GBRP_DECL(sse2);
  330. YUV2GBRP_DECL(sse4);
  331. YUV2GBRP_DECL(avx2);
  332. #define INPUT_PLANAR_RGB_Y_FN_DECL(fmt, opt) \
  333. void ff_planar_##fmt##_to_y_##opt(uint8_t *dst, \
  334. const uint8_t *src[4], int w, int32_t *rgb2yuv, \
  335. void *opq)
  336. #define INPUT_PLANAR_RGB_UV_FN_DECL(fmt, opt) \
  337. void ff_planar_##fmt##_to_uv_##opt(uint8_t *dstU, uint8_t *dstV, \
  338. const uint8_t *src[4], int w, int32_t *rgb2yuv, \
  339. void *opq)
  340. #define INPUT_PLANAR_RGB_A_FN_DECL(fmt, opt) \
  341. void ff_planar_##fmt##_to_a_##opt(uint8_t *dst, \
  342. const uint8_t *src[4], int w, int32_t *rgb2yuv, \
  343. void *opq)
  344. #define INPUT_PLANAR_RGBXX_A_DECL(fmt, opt) \
  345. INPUT_PLANAR_RGB_A_FN_DECL(fmt##le, opt); \
  346. INPUT_PLANAR_RGB_A_FN_DECL(fmt##be, opt)
  347. #define INPUT_PLANAR_RGBXX_Y_DECL(fmt, opt) \
  348. INPUT_PLANAR_RGB_Y_FN_DECL(fmt##le, opt); \
  349. INPUT_PLANAR_RGB_Y_FN_DECL(fmt##be, opt)
  350. #define INPUT_PLANAR_RGBXX_UV_DECL(fmt, opt) \
  351. INPUT_PLANAR_RGB_UV_FN_DECL(fmt##le, opt); \
  352. INPUT_PLANAR_RGB_UV_FN_DECL(fmt##be, opt)
  353. #define INPUT_PLANAR_RGBXX_YUVA_DECL(fmt, opt) \
  354. INPUT_PLANAR_RGBXX_Y_DECL(fmt, opt); \
  355. INPUT_PLANAR_RGBXX_UV_DECL(fmt, opt); \
  356. INPUT_PLANAR_RGBXX_A_DECL(fmt, opt)
  357. #define INPUT_PLANAR_RGBXX_YUV_DECL(fmt, opt) \
  358. INPUT_PLANAR_RGBXX_Y_DECL(fmt, opt); \
  359. INPUT_PLANAR_RGBXX_UV_DECL(fmt, opt)
  360. #define INPUT_PLANAR_RGBXX_UVA_DECL(fmt, opt) \
  361. INPUT_PLANAR_RGBXX_UV_DECL(fmt, opt); \
  362. INPUT_PLANAR_RGBXX_A_DECL(fmt, opt)
  363. #define INPUT_PLANAR_RGB_A_ALL_DECL(opt) \
  364. INPUT_PLANAR_RGB_A_FN_DECL(rgb, opt); \
  365. INPUT_PLANAR_RGBXX_A_DECL(rgb10, opt); \
  366. INPUT_PLANAR_RGBXX_A_DECL(rgb12, opt); \
  367. INPUT_PLANAR_RGBXX_A_DECL(rgb16, opt); \
  368. INPUT_PLANAR_RGBXX_A_DECL(rgbf32, opt)
  369. #define INPUT_PLANAR_RGB_Y_ALL_DECL(opt) \
  370. INPUT_PLANAR_RGB_Y_FN_DECL(rgb, opt); \
  371. INPUT_PLANAR_RGBXX_Y_DECL(rgb9, opt); \
  372. INPUT_PLANAR_RGBXX_Y_DECL(rgb10, opt); \
  373. INPUT_PLANAR_RGBXX_Y_DECL(rgb12, opt); \
  374. INPUT_PLANAR_RGBXX_Y_DECL(rgb14, opt); \
  375. INPUT_PLANAR_RGBXX_Y_DECL(rgb16, opt); \
  376. INPUT_PLANAR_RGBXX_Y_DECL(rgbf32, opt)
  377. #define INPUT_PLANAR_RGB_UV_ALL_DECL(opt) \
  378. INPUT_PLANAR_RGB_UV_FN_DECL(rgb, opt); \
  379. INPUT_PLANAR_RGBXX_UV_DECL(rgb9, opt); \
  380. INPUT_PLANAR_RGBXX_UV_DECL(rgb10, opt); \
  381. INPUT_PLANAR_RGBXX_UV_DECL(rgb12, opt); \
  382. INPUT_PLANAR_RGBXX_UV_DECL(rgb14, opt); \
  383. INPUT_PLANAR_RGBXX_UV_DECL(rgb16, opt); \
  384. INPUT_PLANAR_RGBXX_UV_DECL(rgbf32, opt)
  385. INPUT_PLANAR_RGBXX_Y_DECL(rgbf32, sse2);
  386. INPUT_PLANAR_RGB_UV_ALL_DECL(sse2);
  387. INPUT_PLANAR_RGB_A_ALL_DECL(sse2);
  388. INPUT_PLANAR_RGB_Y_ALL_DECL(sse4);
  389. INPUT_PLANAR_RGB_UV_ALL_DECL(sse4);
  390. INPUT_PLANAR_RGBXX_A_DECL(rgbf32, sse4);
  391. INPUT_PLANAR_RGB_Y_ALL_DECL(avx2);
  392. INPUT_PLANAR_RGB_UV_ALL_DECL(avx2);
  393. INPUT_PLANAR_RGB_A_ALL_DECL(avx2);
  394. #endif
  395. av_cold void ff_sws_init_swscale_x86(SwsContext *c)
  396. {
  397. int cpu_flags = av_get_cpu_flags();
  398. #if HAVE_MMXEXT_INLINE
  399. if (INLINE_MMXEXT(cpu_flags))
  400. sws_init_swscale_mmxext(c);
  401. #endif
  402. if(c->use_mmx_vfilter && !(c->flags & SWS_ACCURATE_RND)) {
  403. #if HAVE_MMXEXT_EXTERNAL
  404. if (EXTERNAL_MMXEXT(cpu_flags))
  405. c->yuv2planeX = yuv2yuvX_mmxext;
  406. #endif
  407. #if HAVE_SSE3_EXTERNAL
  408. if (EXTERNAL_SSE3(cpu_flags))
  409. c->yuv2planeX = yuv2yuvX_sse3;
  410. #endif
  411. #if HAVE_AVX2_EXTERNAL
  412. if (EXTERNAL_AVX2_FAST(cpu_flags))
  413. c->yuv2planeX = yuv2yuvX_avx2;
  414. #endif
  415. }
  416. #if ARCH_X86_32 && !HAVE_ALIGNED_STACK
  417. // The better yuv2planeX_8 functions need aligned stack on x86-32,
  418. // so we use MMXEXT in this case if they are not available.
  419. if (EXTERNAL_MMXEXT(cpu_flags)) {
  420. if (c->dstBpc == 8 && !c->use_mmx_vfilter)
  421. c->yuv2planeX = ff_yuv2planeX_8_mmxext;
  422. }
  423. #endif /* ARCH_X86_32 && !HAVE_ALIGNED_STACK */
  424. #define ASSIGN_SCALE_FUNC2(hscalefn, filtersize, opt1, opt2) do { \
  425. if (c->srcBpc == 8) { \
  426. hscalefn = c->dstBpc <= 14 ? ff_hscale8to15_ ## filtersize ## _ ## opt2 : \
  427. ff_hscale8to19_ ## filtersize ## _ ## opt1; \
  428. } else if (c->srcBpc == 9) { \
  429. hscalefn = c->dstBpc <= 14 ? ff_hscale9to15_ ## filtersize ## _ ## opt2 : \
  430. ff_hscale9to19_ ## filtersize ## _ ## opt1; \
  431. } else if (c->srcBpc == 10) { \
  432. hscalefn = c->dstBpc <= 14 ? ff_hscale10to15_ ## filtersize ## _ ## opt2 : \
  433. ff_hscale10to19_ ## filtersize ## _ ## opt1; \
  434. } else if (c->srcBpc == 12) { \
  435. hscalefn = c->dstBpc <= 14 ? ff_hscale12to15_ ## filtersize ## _ ## opt2 : \
  436. ff_hscale12to19_ ## filtersize ## _ ## opt1; \
  437. } else if (c->srcBpc == 14 || ((c->srcFormat==AV_PIX_FMT_PAL8||isAnyRGB(c->srcFormat)) && av_pix_fmt_desc_get(c->srcFormat)->comp[0].depth<16)) { \
  438. hscalefn = c->dstBpc <= 14 ? ff_hscale14to15_ ## filtersize ## _ ## opt2 : \
  439. ff_hscale14to19_ ## filtersize ## _ ## opt1; \
  440. } else { /* c->srcBpc == 16 */ \
  441. av_assert0(c->srcBpc == 16);\
  442. hscalefn = c->dstBpc <= 14 ? ff_hscale16to15_ ## filtersize ## _ ## opt2 : \
  443. ff_hscale16to19_ ## filtersize ## _ ## opt1; \
  444. } \
  445. } while (0)
  446. #define ASSIGN_VSCALEX_FUNC(vscalefn, opt, do_16_case, condition_8bit) \
  447. switch(c->dstBpc){ \
  448. case 16: do_16_case; break; \
  449. case 10: if (!isBE(c->dstFormat) && !isSemiPlanarYUV(c->dstFormat)) vscalefn = ff_yuv2planeX_10_ ## opt; break; \
  450. case 9: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2planeX_9_ ## opt; break; \
  451. case 8: if ((condition_8bit) && !c->use_mmx_vfilter) vscalefn = ff_yuv2planeX_8_ ## opt; break; \
  452. }
  453. #define ASSIGN_VSCALE_FUNC(vscalefn, opt) \
  454. switch(c->dstBpc){ \
  455. case 16: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2plane1_16_ ## opt; break; \
  456. case 10: if (!isBE(c->dstFormat) && !isSemiPlanarYUV(c->dstFormat)) vscalefn = ff_yuv2plane1_10_ ## opt; break; \
  457. case 9: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2plane1_9_ ## opt; break; \
  458. case 8: vscalefn = ff_yuv2plane1_8_ ## opt; break; \
  459. default: av_assert0(c->dstBpc>8); \
  460. }
  461. #define case_rgb(x, X, opt) \
  462. case AV_PIX_FMT_ ## X: \
  463. c->lumToYV12 = ff_ ## x ## ToY_ ## opt; \
  464. if (!c->chrSrcHSubSample) \
  465. c->chrToYV12 = ff_ ## x ## ToUV_ ## opt; \
  466. break
  467. #define ASSIGN_SSE_SCALE_FUNC(hscalefn, filtersize, opt1, opt2) \
  468. switch (filtersize) { \
  469. case 4: ASSIGN_SCALE_FUNC2(hscalefn, 4, opt1, opt2); break; \
  470. case 8: ASSIGN_SCALE_FUNC2(hscalefn, 8, opt1, opt2); break; \
  471. default: if (filtersize & 4) ASSIGN_SCALE_FUNC2(hscalefn, X4, opt1, opt2); \
  472. else ASSIGN_SCALE_FUNC2(hscalefn, X8, opt1, opt2); \
  473. break; \
  474. }
  475. if (EXTERNAL_SSE2(cpu_flags)) {
  476. ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, sse2, sse2);
  477. ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, sse2, sse2);
  478. ASSIGN_VSCALEX_FUNC(c->yuv2planeX, sse2, ,
  479. HAVE_ALIGNED_STACK || ARCH_X86_64);
  480. if (!(c->flags & SWS_ACCURATE_RND))
  481. ASSIGN_VSCALE_FUNC(c->yuv2plane1, sse2);
  482. switch (c->srcFormat) {
  483. case AV_PIX_FMT_YA8:
  484. c->lumToYV12 = ff_yuyvToY_sse2;
  485. if (c->needAlpha)
  486. c->alpToYV12 = ff_uyvyToY_sse2;
  487. break;
  488. case AV_PIX_FMT_YUYV422:
  489. c->lumToYV12 = ff_yuyvToY_sse2;
  490. c->chrToYV12 = ff_yuyvToUV_sse2;
  491. break;
  492. case AV_PIX_FMT_UYVY422:
  493. c->lumToYV12 = ff_uyvyToY_sse2;
  494. c->chrToYV12 = ff_uyvyToUV_sse2;
  495. break;
  496. case AV_PIX_FMT_NV12:
  497. c->chrToYV12 = ff_nv12ToUV_sse2;
  498. break;
  499. case AV_PIX_FMT_NV21:
  500. c->chrToYV12 = ff_nv21ToUV_sse2;
  501. break;
  502. case_rgb(rgb24, RGB24, sse2);
  503. case_rgb(bgr24, BGR24, sse2);
  504. case_rgb(bgra, BGRA, sse2);
  505. case_rgb(rgba, RGBA, sse2);
  506. case_rgb(abgr, ABGR, sse2);
  507. case_rgb(argb, ARGB, sse2);
  508. default:
  509. break;
  510. }
  511. }
  512. if (EXTERNAL_SSSE3(cpu_flags)) {
  513. ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, ssse3, ssse3);
  514. ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, ssse3, ssse3);
  515. switch (c->srcFormat) {
  516. case_rgb(rgb24, RGB24, ssse3);
  517. case_rgb(bgr24, BGR24, ssse3);
  518. default:
  519. break;
  520. }
  521. }
  522. if (EXTERNAL_SSE4(cpu_flags)) {
  523. /* Xto15 don't need special sse4 functions */
  524. ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, sse4, ssse3);
  525. ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, sse4, ssse3);
  526. ASSIGN_VSCALEX_FUNC(c->yuv2planeX, sse4,
  527. if (!isBE(c->dstFormat)) c->yuv2planeX = ff_yuv2planeX_16_sse4,
  528. HAVE_ALIGNED_STACK || ARCH_X86_64);
  529. if (c->dstBpc == 16 && !isBE(c->dstFormat) && !(c->flags & SWS_ACCURATE_RND))
  530. c->yuv2plane1 = ff_yuv2plane1_16_sse4;
  531. }
  532. if (EXTERNAL_AVX(cpu_flags)) {
  533. ASSIGN_VSCALEX_FUNC(c->yuv2planeX, avx, ,
  534. HAVE_ALIGNED_STACK || ARCH_X86_64);
  535. if (!(c->flags & SWS_ACCURATE_RND))
  536. ASSIGN_VSCALE_FUNC(c->yuv2plane1, avx);
  537. switch (c->srcFormat) {
  538. case AV_PIX_FMT_YUYV422:
  539. c->chrToYV12 = ff_yuyvToUV_avx;
  540. break;
  541. case AV_PIX_FMT_UYVY422:
  542. c->chrToYV12 = ff_uyvyToUV_avx;
  543. break;
  544. case AV_PIX_FMT_NV12:
  545. c->chrToYV12 = ff_nv12ToUV_avx;
  546. break;
  547. case AV_PIX_FMT_NV21:
  548. c->chrToYV12 = ff_nv21ToUV_avx;
  549. break;
  550. case_rgb(rgb24, RGB24, avx);
  551. case_rgb(bgr24, BGR24, avx);
  552. case_rgb(bgra, BGRA, avx);
  553. case_rgb(rgba, RGBA, avx);
  554. case_rgb(abgr, ABGR, avx);
  555. case_rgb(argb, ARGB, avx);
  556. default:
  557. break;
  558. }
  559. }
  560. #if ARCH_X86_64
  561. #define ASSIGN_AVX2_SCALE_FUNC(hscalefn, filtersize) \
  562. switch (filtersize) { \
  563. case 4: hscalefn = ff_hscale8to15_4_avx2; break; \
  564. default: hscalefn = ff_hscale8to15_X4_avx2; break; \
  565. break; \
  566. }
  567. if (EXTERNAL_AVX2_FAST(cpu_flags) && !(cpu_flags & AV_CPU_FLAG_SLOW_GATHER)) {
  568. if ((c->srcBpc == 8) && (c->dstBpc <= 14)) {
  569. ASSIGN_AVX2_SCALE_FUNC(c->hcScale, c->hChrFilterSize);
  570. ASSIGN_AVX2_SCALE_FUNC(c->hyScale, c->hLumFilterSize);
  571. }
  572. }
  573. if (EXTERNAL_AVX2_FAST(cpu_flags)) {
  574. switch (c->dstFormat) {
  575. case AV_PIX_FMT_NV12:
  576. case AV_PIX_FMT_NV24:
  577. c->yuv2nv12cX = ff_yuv2nv12cX_avx2;
  578. break;
  579. case AV_PIX_FMT_NV21:
  580. case AV_PIX_FMT_NV42:
  581. c->yuv2nv12cX = ff_yuv2nv21cX_avx2;
  582. break;
  583. default:
  584. break;
  585. }
  586. }
  587. #define INPUT_PLANER_RGB_A_FUNC_CASE(fmt, name, opt) \
  588. case fmt: \
  589. c->readAlpPlanar = ff_planar_##name##_to_a_##opt;
  590. #define INPUT_PLANER_RGBA_YUV_FUNC_CASE(rgb_fmt, rgba_fmt, name, opt) \
  591. case rgba_fmt: \
  592. case rgb_fmt: \
  593. c->readLumPlanar = ff_planar_##name##_to_y_##opt; \
  594. c->readChrPlanar = ff_planar_##name##_to_uv_##opt; \
  595. break;
  596. #define INPUT_PLANER_RGB_YUV_FUNC_CASE(fmt, name, opt) \
  597. case fmt: \
  598. c->readLumPlanar = ff_planar_##name##_to_y_##opt; \
  599. c->readChrPlanar = ff_planar_##name##_to_uv_##opt; \
  600. break;
  601. #define INPUT_PLANER_RGB_UV_FUNC_CASE(fmt, name, opt) \
  602. case fmt: \
  603. c->readChrPlanar = ff_planar_##name##_to_uv_##opt; \
  604. break;
  605. #define INPUT_PLANER_RGBAXX_YUVA_FUNC_CASE(rgb_fmt, rgba_fmt, name, opt) \
  606. INPUT_PLANER_RGB_A_FUNC_CASE(rgba_fmt##LE, name##le, opt) \
  607. INPUT_PLANER_RGB_YUV_FUNC_CASE(rgb_fmt##LE, name##le, opt) \
  608. INPUT_PLANER_RGB_A_FUNC_CASE(rgba_fmt##BE, name##be, opt) \
  609. INPUT_PLANER_RGB_YUV_FUNC_CASE(rgb_fmt##BE, name##be, opt)
  610. #define INPUT_PLANER_RGBAXX_UVA_FUNC_CASE(rgb_fmt, rgba_fmt, name, opt) \
  611. INPUT_PLANER_RGB_A_FUNC_CASE(rgba_fmt##LE, name##le, opt) \
  612. INPUT_PLANER_RGB_UV_FUNC_CASE(rgb_fmt##LE, name##le, opt) \
  613. INPUT_PLANER_RGB_A_FUNC_CASE(rgba_fmt##BE, name##be, opt) \
  614. INPUT_PLANER_RGB_UV_FUNC_CASE(rgb_fmt##BE, name##be, opt)
  615. #define INPUT_PLANER_RGBAXX_YUV_FUNC_CASE(rgb_fmt, rgba_fmt, name, opt) \
  616. INPUT_PLANER_RGBA_YUV_FUNC_CASE(rgb_fmt##LE, rgba_fmt##LE, name##le, opt) \
  617. INPUT_PLANER_RGBA_YUV_FUNC_CASE(rgb_fmt##BE, rgba_fmt##BE, name##be, opt)
  618. #define INPUT_PLANER_RGBXX_YUV_FUNC_CASE(rgb_fmt, name, opt) \
  619. INPUT_PLANER_RGB_YUV_FUNC_CASE(rgb_fmt##LE, name##le, opt) \
  620. INPUT_PLANER_RGB_YUV_FUNC_CASE(rgb_fmt##BE, name##be, opt)
  621. #define INPUT_PLANER_RGBXX_UV_FUNC_CASE(rgb_fmt, name, opt) \
  622. INPUT_PLANER_RGB_UV_FUNC_CASE(rgb_fmt##LE, name##le, opt) \
  623. INPUT_PLANER_RGB_UV_FUNC_CASE(rgb_fmt##BE, name##be, opt)
  624. #define INPUT_PLANER_RGB_YUVA_ALL_CASES(opt) \
  625. INPUT_PLANER_RGB_A_FUNC_CASE( AV_PIX_FMT_GBRAP, rgb, opt) \
  626. INPUT_PLANER_RGB_YUV_FUNC_CASE( AV_PIX_FMT_GBRP, rgb, opt) \
  627. INPUT_PLANER_RGBXX_YUV_FUNC_CASE( AV_PIX_FMT_GBRP9, rgb9, opt) \
  628. INPUT_PLANER_RGBAXX_YUVA_FUNC_CASE(AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRAP10, rgb10, opt) \
  629. INPUT_PLANER_RGBAXX_YUVA_FUNC_CASE(AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRAP12, rgb12, opt) \
  630. INPUT_PLANER_RGBXX_YUV_FUNC_CASE( AV_PIX_FMT_GBRP14, rgb14, opt) \
  631. INPUT_PLANER_RGBAXX_YUVA_FUNC_CASE(AV_PIX_FMT_GBRP16, AV_PIX_FMT_GBRAP16, rgb16, opt) \
  632. INPUT_PLANER_RGBAXX_YUVA_FUNC_CASE(AV_PIX_FMT_GBRPF32, AV_PIX_FMT_GBRAPF32, rgbf32, opt)
  633. if (EXTERNAL_SSE2(cpu_flags)) {
  634. switch (c->srcFormat) {
  635. INPUT_PLANER_RGB_A_FUNC_CASE( AV_PIX_FMT_GBRAP, rgb, sse2);
  636. INPUT_PLANER_RGB_UV_FUNC_CASE( AV_PIX_FMT_GBRP, rgb, sse2);
  637. INPUT_PLANER_RGBXX_UV_FUNC_CASE( AV_PIX_FMT_GBRP9, rgb9, sse2);
  638. INPUT_PLANER_RGBAXX_UVA_FUNC_CASE( AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRAP10, rgb10, sse2);
  639. INPUT_PLANER_RGBAXX_UVA_FUNC_CASE( AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRAP12, rgb12, sse2);
  640. INPUT_PLANER_RGBXX_UV_FUNC_CASE( AV_PIX_FMT_GBRP14, rgb14, sse2);
  641. INPUT_PLANER_RGBAXX_UVA_FUNC_CASE( AV_PIX_FMT_GBRP16, AV_PIX_FMT_GBRAP16, rgb16, sse2);
  642. INPUT_PLANER_RGBAXX_YUVA_FUNC_CASE(AV_PIX_FMT_GBRPF32, AV_PIX_FMT_GBRAPF32, rgbf32, sse2);
  643. default:
  644. break;
  645. }
  646. }
  647. if (EXTERNAL_SSE4(cpu_flags)) {
  648. switch (c->srcFormat) {
  649. case AV_PIX_FMT_GBRAP:
  650. INPUT_PLANER_RGB_YUV_FUNC_CASE( AV_PIX_FMT_GBRP, rgb, sse4);
  651. INPUT_PLANER_RGBXX_YUV_FUNC_CASE( AV_PIX_FMT_GBRP9, rgb9, sse4);
  652. INPUT_PLANER_RGBAXX_YUV_FUNC_CASE( AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRAP10, rgb10, sse4);
  653. INPUT_PLANER_RGBAXX_YUV_FUNC_CASE( AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRAP12, rgb12, sse4);
  654. INPUT_PLANER_RGBXX_YUV_FUNC_CASE( AV_PIX_FMT_GBRP14, rgb14, sse4);
  655. INPUT_PLANER_RGBAXX_YUV_FUNC_CASE( AV_PIX_FMT_GBRP16, AV_PIX_FMT_GBRAP16, rgb16, sse4);
  656. INPUT_PLANER_RGBAXX_YUVA_FUNC_CASE(AV_PIX_FMT_GBRPF32, AV_PIX_FMT_GBRAPF32, rgbf32, sse4);
  657. default:
  658. break;
  659. }
  660. }
  661. if (EXTERNAL_AVX2_FAST(cpu_flags)) {
  662. switch (c->srcFormat) {
  663. INPUT_PLANER_RGB_YUVA_ALL_CASES(avx2)
  664. default:
  665. break;
  666. }
  667. }
  668. if(c->flags & SWS_FULL_CHR_H_INT) {
  669. /* yuv2gbrp uses the SwsContext for yuv coefficients
  670. if struct offsets change the asm needs to be updated too */
  671. av_assert0(offsetof(SwsContext, yuv2rgb_y_offset) == 40292);
  672. #define YUV2ANYX_FUNC_CASE(fmt, name, opt) \
  673. case fmt: \
  674. c->yuv2anyX = ff_yuv2##name##_full_X_##opt; \
  675. break;
  676. #define YUV2ANYX_GBRAP_CASES(opt) \
  677. YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRP, gbrp, opt) \
  678. YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRAP, gbrap, opt) \
  679. YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRP9LE, gbrp9le, opt) \
  680. YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRP10LE, gbrp10le, opt) \
  681. YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRAP10LE, gbrap10le, opt) \
  682. YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRP12LE, gbrp12le, opt) \
  683. YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRAP12LE, gbrap12le, opt) \
  684. YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRP14LE, gbrp14le, opt) \
  685. YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRP16LE, gbrp16le, opt) \
  686. YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRAP16LE, gbrap16le, opt) \
  687. YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRPF32LE, gbrpf32le, opt) \
  688. YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRAPF32LE, gbrapf32le, opt) \
  689. YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRP9BE, gbrp9be, opt) \
  690. YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRP10BE, gbrp10be, opt) \
  691. YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRAP10BE, gbrap10be, opt) \
  692. YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRP12BE, gbrp12be, opt) \
  693. YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRAP12BE, gbrap12be, opt) \
  694. YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRP14BE, gbrp14be, opt) \
  695. YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRP16BE, gbrp16be, opt) \
  696. YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRAP16BE, gbrap16be, opt) \
  697. YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRPF32BE, gbrpf32be, opt) \
  698. YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRAPF32BE, gbrapf32be, opt)
  699. if (EXTERNAL_SSE2(cpu_flags)) {
  700. switch (c->dstFormat) {
  701. YUV2ANYX_GBRAP_CASES(sse2)
  702. default:
  703. break;
  704. }
  705. }
  706. if (EXTERNAL_SSE4(cpu_flags)) {
  707. switch (c->dstFormat) {
  708. YUV2ANYX_GBRAP_CASES(sse4)
  709. default:
  710. break;
  711. }
  712. }
  713. if (EXTERNAL_AVX2_FAST(cpu_flags)) {
  714. switch (c->dstFormat) {
  715. YUV2ANYX_GBRAP_CASES(avx2)
  716. default:
  717. break;
  718. }
  719. }
  720. }
  721. #endif
  722. }