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_mmx(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_mmx(filter, filterSize - 1, pixelsProcessed, dest - offset, pixelsProcessed + remainder + offset, dither, offset); \
  195. } \
  196. return; \
  197. }
  198. #if HAVE_MMX_EXTERNAL
  199. YUV2YUVX_FUNC_MMX(mmx, 16)
  200. #endif
  201. #if HAVE_MMXEXT_EXTERNAL
  202. YUV2YUVX_FUNC_MMX(mmxext, 16)
  203. #endif
  204. #if HAVE_SSE3_EXTERNAL
  205. YUV2YUVX_FUNC(sse3, 32)
  206. #endif
  207. #if HAVE_AVX2_EXTERNAL
  208. YUV2YUVX_FUNC(avx2, 64)
  209. #endif
  210. #define SCALE_FUNC(filter_n, from_bpc, to_bpc, opt) \
  211. void ff_hscale ## from_bpc ## to ## to_bpc ## _ ## filter_n ## _ ## opt( \
  212. SwsContext *c, int16_t *data, \
  213. int dstW, const uint8_t *src, \
  214. const int16_t *filter, \
  215. const int32_t *filterPos, int filterSize)
  216. #define SCALE_FUNCS(filter_n, opt) \
  217. SCALE_FUNC(filter_n, 8, 15, opt); \
  218. SCALE_FUNC(filter_n, 9, 15, opt); \
  219. SCALE_FUNC(filter_n, 10, 15, opt); \
  220. SCALE_FUNC(filter_n, 12, 15, opt); \
  221. SCALE_FUNC(filter_n, 14, 15, opt); \
  222. SCALE_FUNC(filter_n, 16, 15, opt); \
  223. SCALE_FUNC(filter_n, 8, 19, opt); \
  224. SCALE_FUNC(filter_n, 9, 19, opt); \
  225. SCALE_FUNC(filter_n, 10, 19, opt); \
  226. SCALE_FUNC(filter_n, 12, 19, opt); \
  227. SCALE_FUNC(filter_n, 14, 19, opt); \
  228. SCALE_FUNC(filter_n, 16, 19, opt)
  229. #define SCALE_FUNCS_MMX(opt) \
  230. SCALE_FUNCS(4, opt); \
  231. SCALE_FUNCS(8, opt); \
  232. SCALE_FUNCS(X, opt)
  233. #define SCALE_FUNCS_SSE(opt) \
  234. SCALE_FUNCS(4, opt); \
  235. SCALE_FUNCS(8, opt); \
  236. SCALE_FUNCS(X4, opt); \
  237. SCALE_FUNCS(X8, opt)
  238. SCALE_FUNCS_SSE(sse2);
  239. SCALE_FUNCS_SSE(ssse3);
  240. SCALE_FUNCS_SSE(sse4);
  241. SCALE_FUNC(4, 8, 15, avx2);
  242. SCALE_FUNC(X4, 8, 15, avx2);
  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)
  251. VSCALEX_FUNC(8, mmxext);
  252. VSCALEX_FUNCS(sse2);
  253. VSCALEX_FUNCS(sse4);
  254. VSCALEX_FUNC(16, sse4);
  255. VSCALEX_FUNCS(avx);
  256. #define VSCALE_FUNC(size, opt) \
  257. void ff_yuv2plane1_ ## size ## _ ## opt(const int16_t *src, uint8_t *dst, int dstW, \
  258. const uint8_t *dither, int offset)
  259. #define VSCALE_FUNCS(opt1, opt2) \
  260. VSCALE_FUNC(8, opt1); \
  261. VSCALE_FUNC(9, opt2); \
  262. VSCALE_FUNC(10, opt2); \
  263. VSCALE_FUNC(16, opt1)
  264. VSCALE_FUNCS(sse2, sse2);
  265. VSCALE_FUNC(16, sse4);
  266. VSCALE_FUNCS(avx, avx);
  267. #define INPUT_Y_FUNC(fmt, opt) \
  268. void ff_ ## fmt ## ToY_ ## opt(uint8_t *dst, const uint8_t *src, \
  269. const uint8_t *unused1, const uint8_t *unused2, \
  270. int w, uint32_t *unused)
  271. #define INPUT_UV_FUNC(fmt, opt) \
  272. void ff_ ## fmt ## ToUV_ ## opt(uint8_t *dstU, uint8_t *dstV, \
  273. const uint8_t *unused0, \
  274. const uint8_t *src1, \
  275. const uint8_t *src2, \
  276. int w, uint32_t *unused)
  277. #define INPUT_FUNC(fmt, opt) \
  278. INPUT_Y_FUNC(fmt, opt); \
  279. INPUT_UV_FUNC(fmt, opt)
  280. #define INPUT_FUNCS(opt) \
  281. INPUT_FUNC(uyvy, opt); \
  282. INPUT_FUNC(yuyv, opt); \
  283. INPUT_UV_FUNC(nv12, opt); \
  284. INPUT_UV_FUNC(nv21, opt); \
  285. INPUT_FUNC(rgba, opt); \
  286. INPUT_FUNC(bgra, opt); \
  287. INPUT_FUNC(argb, opt); \
  288. INPUT_FUNC(abgr, opt); \
  289. INPUT_FUNC(rgb24, opt); \
  290. INPUT_FUNC(bgr24, opt)
  291. INPUT_FUNCS(sse2);
  292. INPUT_FUNCS(ssse3);
  293. INPUT_FUNCS(avx);
  294. #if ARCH_X86_64
  295. #define YUV2NV_DECL(fmt, opt) \
  296. void ff_yuv2 ## fmt ## cX_ ## opt(enum AVPixelFormat format, const uint8_t *dither, \
  297. const int16_t *filter, int filterSize, \
  298. const int16_t **u, const int16_t **v, \
  299. uint8_t *dst, int dstWidth)
  300. YUV2NV_DECL(nv12, avx2);
  301. YUV2NV_DECL(nv21, avx2);
  302. #define YUV2GBRP_FN_DECL(fmt, opt) \
  303. void ff_yuv2##fmt##_full_X_ ##opt(SwsContext *c, const int16_t *lumFilter, \
  304. const int16_t **lumSrcx, int lumFilterSize, \
  305. const int16_t *chrFilter, const int16_t **chrUSrcx, \
  306. const int16_t **chrVSrcx, int chrFilterSize, \
  307. const int16_t **alpSrcx, uint8_t **dest, \
  308. int dstW, int y)
  309. #define YUV2GBRP_DECL(opt) \
  310. YUV2GBRP_FN_DECL(gbrp, opt); \
  311. YUV2GBRP_FN_DECL(gbrap, opt); \
  312. YUV2GBRP_FN_DECL(gbrp9le, opt); \
  313. YUV2GBRP_FN_DECL(gbrp10le, opt); \
  314. YUV2GBRP_FN_DECL(gbrap10le, opt); \
  315. YUV2GBRP_FN_DECL(gbrp12le, opt); \
  316. YUV2GBRP_FN_DECL(gbrap12le, opt); \
  317. YUV2GBRP_FN_DECL(gbrp14le, opt); \
  318. YUV2GBRP_FN_DECL(gbrp16le, opt); \
  319. YUV2GBRP_FN_DECL(gbrap16le, opt); \
  320. YUV2GBRP_FN_DECL(gbrpf32le, opt); \
  321. YUV2GBRP_FN_DECL(gbrapf32le, opt); \
  322. YUV2GBRP_FN_DECL(gbrp9be, opt); \
  323. YUV2GBRP_FN_DECL(gbrp10be, opt); \
  324. YUV2GBRP_FN_DECL(gbrap10be, opt); \
  325. YUV2GBRP_FN_DECL(gbrp12be, opt); \
  326. YUV2GBRP_FN_DECL(gbrap12be, opt); \
  327. YUV2GBRP_FN_DECL(gbrp14be, opt); \
  328. YUV2GBRP_FN_DECL(gbrp16be, opt); \
  329. YUV2GBRP_FN_DECL(gbrap16be, opt); \
  330. YUV2GBRP_FN_DECL(gbrpf32be, opt); \
  331. YUV2GBRP_FN_DECL(gbrapf32be, opt)
  332. YUV2GBRP_DECL(sse2);
  333. YUV2GBRP_DECL(sse4);
  334. YUV2GBRP_DECL(avx2);
  335. #define INPUT_PLANAR_RGB_Y_FN_DECL(fmt, opt) \
  336. void ff_planar_##fmt##_to_y_##opt(uint8_t *dst, \
  337. const uint8_t *src[4], int w, int32_t *rgb2yuv)
  338. #define INPUT_PLANAR_RGB_UV_FN_DECL(fmt, opt) \
  339. void ff_planar_##fmt##_to_uv_##opt(uint8_t *dstU, uint8_t *dstV, \
  340. const uint8_t *src[4], int w, int32_t *rgb2yuv)
  341. #define INPUT_PLANAR_RGB_A_FN_DECL(fmt, opt) \
  342. void ff_planar_##fmt##_to_a_##opt(uint8_t *dst, \
  343. const uint8_t *src[4], int w, int32_t *rgb2yuv)
  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. ASSIGN_VSCALE_FUNC(c->yuv2plane1, sse2);
  481. switch (c->srcFormat) {
  482. case AV_PIX_FMT_YA8:
  483. c->lumToYV12 = ff_yuyvToY_sse2;
  484. if (c->needAlpha)
  485. c->alpToYV12 = ff_uyvyToY_sse2;
  486. break;
  487. case AV_PIX_FMT_YUYV422:
  488. c->lumToYV12 = ff_yuyvToY_sse2;
  489. c->chrToYV12 = ff_yuyvToUV_sse2;
  490. break;
  491. case AV_PIX_FMT_UYVY422:
  492. c->lumToYV12 = ff_uyvyToY_sse2;
  493. c->chrToYV12 = ff_uyvyToUV_sse2;
  494. break;
  495. case AV_PIX_FMT_NV12:
  496. c->chrToYV12 = ff_nv12ToUV_sse2;
  497. break;
  498. case AV_PIX_FMT_NV21:
  499. c->chrToYV12 = ff_nv21ToUV_sse2;
  500. break;
  501. case_rgb(rgb24, RGB24, sse2);
  502. case_rgb(bgr24, BGR24, sse2);
  503. case_rgb(bgra, BGRA, sse2);
  504. case_rgb(rgba, RGBA, sse2);
  505. case_rgb(abgr, ABGR, sse2);
  506. case_rgb(argb, ARGB, sse2);
  507. default:
  508. break;
  509. }
  510. }
  511. if (EXTERNAL_SSSE3(cpu_flags)) {
  512. ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, ssse3, ssse3);
  513. ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, ssse3, ssse3);
  514. switch (c->srcFormat) {
  515. case_rgb(rgb24, RGB24, ssse3);
  516. case_rgb(bgr24, BGR24, ssse3);
  517. default:
  518. break;
  519. }
  520. }
  521. if (EXTERNAL_SSE4(cpu_flags)) {
  522. /* Xto15 don't need special sse4 functions */
  523. ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, sse4, ssse3);
  524. ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, sse4, ssse3);
  525. ASSIGN_VSCALEX_FUNC(c->yuv2planeX, sse4,
  526. if (!isBE(c->dstFormat)) c->yuv2planeX = ff_yuv2planeX_16_sse4,
  527. HAVE_ALIGNED_STACK || ARCH_X86_64);
  528. if (c->dstBpc == 16 && !isBE(c->dstFormat))
  529. c->yuv2plane1 = ff_yuv2plane1_16_sse4;
  530. }
  531. if (EXTERNAL_AVX(cpu_flags)) {
  532. ASSIGN_VSCALEX_FUNC(c->yuv2planeX, avx, ,
  533. HAVE_ALIGNED_STACK || ARCH_X86_64);
  534. ASSIGN_VSCALE_FUNC(c->yuv2plane1, avx);
  535. switch (c->srcFormat) {
  536. case AV_PIX_FMT_YUYV422:
  537. c->chrToYV12 = ff_yuyvToUV_avx;
  538. break;
  539. case AV_PIX_FMT_UYVY422:
  540. c->chrToYV12 = ff_uyvyToUV_avx;
  541. break;
  542. case AV_PIX_FMT_NV12:
  543. c->chrToYV12 = ff_nv12ToUV_avx;
  544. break;
  545. case AV_PIX_FMT_NV21:
  546. c->chrToYV12 = ff_nv21ToUV_avx;
  547. break;
  548. case_rgb(rgb24, RGB24, avx);
  549. case_rgb(bgr24, BGR24, avx);
  550. case_rgb(bgra, BGRA, avx);
  551. case_rgb(rgba, RGBA, avx);
  552. case_rgb(abgr, ABGR, avx);
  553. case_rgb(argb, ARGB, avx);
  554. default:
  555. break;
  556. }
  557. }
  558. #if ARCH_X86_64
  559. #define ASSIGN_AVX2_SCALE_FUNC(hscalefn, filtersize) \
  560. switch (filtersize) { \
  561. case 4: hscalefn = ff_hscale8to15_4_avx2; break; \
  562. default: hscalefn = ff_hscale8to15_X4_avx2; break; \
  563. break; \
  564. }
  565. if (EXTERNAL_AVX2_FAST(cpu_flags) && !(cpu_flags & AV_CPU_FLAG_SLOW_GATHER)) {
  566. if ((c->srcBpc == 8) && (c->dstBpc <= 14)) {
  567. if (c->chrDstW % 16 == 0)
  568. ASSIGN_AVX2_SCALE_FUNC(c->hcScale, c->hChrFilterSize);
  569. if (c->dstW % 16 == 0)
  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_NOBREAK(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_NOBREAK(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_NOBREAK(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_NOBREAK(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_NOBREAK(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_NOBREAK(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_NOBREAK(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. }