You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

498 lines
19KB

  1. /*
  2. * Copyright (C) 2001-2003 Michael Niedermayer <michaelni@gmx.at>
  3. *
  4. * This file is part of Libav.
  5. *
  6. * Libav 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. * Libav 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 Libav; 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/intreadwrite.h"
  26. #include "libavutil/x86/cpu.h"
  27. #include "libavutil/cpu.h"
  28. #include "libavutil/pixdesc.h"
  29. #if HAVE_INLINE_ASM
  30. #define DITHER1XBPP
  31. DECLARE_ASM_CONST(8, uint64_t, bF8)= 0xF8F8F8F8F8F8F8F8LL;
  32. DECLARE_ASM_CONST(8, uint64_t, bFC)= 0xFCFCFCFCFCFCFCFCLL;
  33. DECLARE_ASM_CONST(8, uint64_t, w10)= 0x0010001000100010LL;
  34. DECLARE_ASM_CONST(8, uint64_t, w02)= 0x0002000200020002LL;
  35. const DECLARE_ALIGNED(8, uint64_t, ff_dither4)[2] = {
  36. 0x0103010301030103LL,
  37. 0x0200020002000200LL,};
  38. const DECLARE_ALIGNED(8, uint64_t, ff_dither8)[2] = {
  39. 0x0602060206020602LL,
  40. 0x0004000400040004LL,};
  41. DECLARE_ASM_CONST(8, uint64_t, b16Mask)= 0x001F001F001F001FLL;
  42. DECLARE_ASM_CONST(8, uint64_t, g16Mask)= 0x07E007E007E007E0LL;
  43. DECLARE_ASM_CONST(8, uint64_t, r16Mask)= 0xF800F800F800F800LL;
  44. DECLARE_ASM_CONST(8, uint64_t, b15Mask)= 0x001F001F001F001FLL;
  45. DECLARE_ASM_CONST(8, uint64_t, g15Mask)= 0x03E003E003E003E0LL;
  46. DECLARE_ASM_CONST(8, uint64_t, r15Mask)= 0x7C007C007C007C00LL;
  47. DECLARE_ALIGNED(8, const uint64_t, ff_M24A) = 0x00FF0000FF0000FFLL;
  48. DECLARE_ALIGNED(8, const uint64_t, ff_M24B) = 0xFF0000FF0000FF00LL;
  49. DECLARE_ALIGNED(8, const uint64_t, ff_M24C) = 0x0000FF0000FF0000LL;
  50. #ifdef FAST_BGR2YV12
  51. DECLARE_ALIGNED(8, const uint64_t, ff_bgr2YCoeff) = 0x000000210041000DULL;
  52. DECLARE_ALIGNED(8, const uint64_t, ff_bgr2UCoeff) = 0x0000FFEEFFDC0038ULL;
  53. DECLARE_ALIGNED(8, const uint64_t, ff_bgr2VCoeff) = 0x00000038FFD2FFF8ULL;
  54. #else
  55. DECLARE_ALIGNED(8, const uint64_t, ff_bgr2YCoeff) = 0x000020E540830C8BULL;
  56. DECLARE_ALIGNED(8, const uint64_t, ff_bgr2UCoeff) = 0x0000ED0FDAC23831ULL;
  57. DECLARE_ALIGNED(8, const uint64_t, ff_bgr2VCoeff) = 0x00003831D0E6F6EAULL;
  58. #endif /* FAST_BGR2YV12 */
  59. DECLARE_ALIGNED(8, const uint64_t, ff_bgr2YOffset) = 0x1010101010101010ULL;
  60. DECLARE_ALIGNED(8, const uint64_t, ff_bgr2UVOffset) = 0x8080808080808080ULL;
  61. DECLARE_ALIGNED(8, const uint64_t, ff_w1111) = 0x0001000100010001ULL;
  62. //MMX versions
  63. #if HAVE_MMX_INLINE
  64. #undef RENAME
  65. #define COMPILE_TEMPLATE_MMXEXT 0
  66. #define RENAME(a) a ## _mmx
  67. #include "swscale_template.c"
  68. #endif
  69. // MMXEXT versions
  70. #if HAVE_MMXEXT_INLINE
  71. #undef RENAME
  72. #undef COMPILE_TEMPLATE_MMXEXT
  73. #define COMPILE_TEMPLATE_MMXEXT 1
  74. #define RENAME(a) a ## _mmxext
  75. #include "swscale_template.c"
  76. #endif
  77. void updateMMXDitherTables(SwsContext *c, int dstY, int lumBufIndex, int chrBufIndex,
  78. int lastInLumBuf, int lastInChrBuf)
  79. {
  80. const int dstH= c->dstH;
  81. const int flags= c->flags;
  82. int16_t **lumPixBuf= c->lumPixBuf;
  83. int16_t **chrUPixBuf= c->chrUPixBuf;
  84. int16_t **alpPixBuf= c->alpPixBuf;
  85. const int vLumBufSize= c->vLumBufSize;
  86. const int vChrBufSize= c->vChrBufSize;
  87. int32_t *vLumFilterPos= c->vLumFilterPos;
  88. int32_t *vChrFilterPos= c->vChrFilterPos;
  89. int16_t *vLumFilter= c->vLumFilter;
  90. int16_t *vChrFilter= c->vChrFilter;
  91. int32_t *lumMmxFilter= c->lumMmxFilter;
  92. int32_t *chrMmxFilter= c->chrMmxFilter;
  93. int32_t av_unused *alpMmxFilter= c->alpMmxFilter;
  94. const int vLumFilterSize= c->vLumFilterSize;
  95. const int vChrFilterSize= c->vChrFilterSize;
  96. const int chrDstY= dstY>>c->chrDstVSubSample;
  97. const int firstLumSrcY= vLumFilterPos[dstY]; //First line needed as input
  98. const int firstChrSrcY= vChrFilterPos[chrDstY]; //First line needed as input
  99. c->blueDither= ff_dither8[dstY&1];
  100. if (c->dstFormat == AV_PIX_FMT_RGB555 || c->dstFormat == AV_PIX_FMT_BGR555)
  101. c->greenDither= ff_dither8[dstY&1];
  102. else
  103. c->greenDither= ff_dither4[dstY&1];
  104. c->redDither= ff_dither8[(dstY+1)&1];
  105. if (dstY < dstH - 2) {
  106. const int16_t **lumSrcPtr= (const int16_t **) lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
  107. const int16_t **chrUSrcPtr= (const int16_t **) chrUPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
  108. const int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **) alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL;
  109. int i;
  110. if (firstLumSrcY < 0 || firstLumSrcY + vLumFilterSize > c->srcH) {
  111. const int16_t **tmpY = (const int16_t **) lumPixBuf + 2 * vLumBufSize;
  112. int neg = -firstLumSrcY, i, end = FFMIN(c->srcH - firstLumSrcY, vLumFilterSize);
  113. for (i = 0; i < neg; i++)
  114. tmpY[i] = lumSrcPtr[neg];
  115. for ( ; i < end; i++)
  116. tmpY[i] = lumSrcPtr[i];
  117. for ( ; i < vLumFilterSize; i++)
  118. tmpY[i] = tmpY[i-1];
  119. lumSrcPtr = tmpY;
  120. if (alpSrcPtr) {
  121. const int16_t **tmpA = (const int16_t **) alpPixBuf + 2 * vLumBufSize;
  122. for (i = 0; i < neg; i++)
  123. tmpA[i] = alpSrcPtr[neg];
  124. for ( ; i < end; i++)
  125. tmpA[i] = alpSrcPtr[i];
  126. for ( ; i < vLumFilterSize; i++)
  127. tmpA[i] = tmpA[i - 1];
  128. alpSrcPtr = tmpA;
  129. }
  130. }
  131. if (firstChrSrcY < 0 || firstChrSrcY + vChrFilterSize > c->chrSrcH) {
  132. const int16_t **tmpU = (const int16_t **) chrUPixBuf + 2 * vChrBufSize;
  133. int neg = -firstChrSrcY, i, end = FFMIN(c->chrSrcH - firstChrSrcY, vChrFilterSize);
  134. for (i = 0; i < neg; i++) {
  135. tmpU[i] = chrUSrcPtr[neg];
  136. }
  137. for ( ; i < end; i++) {
  138. tmpU[i] = chrUSrcPtr[i];
  139. }
  140. for ( ; i < vChrFilterSize; i++) {
  141. tmpU[i] = tmpU[i - 1];
  142. }
  143. chrUSrcPtr = tmpU;
  144. }
  145. if (flags & SWS_ACCURATE_RND) {
  146. int s= APCK_SIZE / 8;
  147. for (i=0; i<vLumFilterSize; i+=2) {
  148. *(const void**)&lumMmxFilter[s*i ]= lumSrcPtr[i ];
  149. *(const void**)&lumMmxFilter[s*i+APCK_PTR2/4 ]= lumSrcPtr[i+(vLumFilterSize>1)];
  150. lumMmxFilter[s*i+APCK_COEF/4 ]=
  151. lumMmxFilter[s*i+APCK_COEF/4+1]= vLumFilter[dstY*vLumFilterSize + i ]
  152. + (vLumFilterSize>1 ? vLumFilter[dstY*vLumFilterSize + i + 1]<<16 : 0);
  153. if (CONFIG_SWSCALE_ALPHA && alpPixBuf) {
  154. *(const void**)&alpMmxFilter[s*i ]= alpSrcPtr[i ];
  155. *(const void**)&alpMmxFilter[s*i+APCK_PTR2/4 ]= alpSrcPtr[i+(vLumFilterSize>1)];
  156. alpMmxFilter[s*i+APCK_COEF/4 ]=
  157. alpMmxFilter[s*i+APCK_COEF/4+1]= lumMmxFilter[s*i+APCK_COEF/4 ];
  158. }
  159. }
  160. for (i=0; i<vChrFilterSize; i+=2) {
  161. *(const void**)&chrMmxFilter[s*i ]= chrUSrcPtr[i ];
  162. *(const void**)&chrMmxFilter[s*i+APCK_PTR2/4 ]= chrUSrcPtr[i+(vChrFilterSize>1)];
  163. chrMmxFilter[s*i+APCK_COEF/4 ]=
  164. chrMmxFilter[s*i+APCK_COEF/4+1]= vChrFilter[chrDstY*vChrFilterSize + i ]
  165. + (vChrFilterSize>1 ? vChrFilter[chrDstY*vChrFilterSize + i + 1]<<16 : 0);
  166. }
  167. } else {
  168. for (i=0; i<vLumFilterSize; i++) {
  169. *(const void**)&lumMmxFilter[4*i+0]= lumSrcPtr[i];
  170. lumMmxFilter[4*i+2]=
  171. lumMmxFilter[4*i+3]=
  172. ((uint16_t)vLumFilter[dstY*vLumFilterSize + i])*0x10001;
  173. if (CONFIG_SWSCALE_ALPHA && alpPixBuf) {
  174. *(const void**)&alpMmxFilter[4*i+0]= alpSrcPtr[i];
  175. alpMmxFilter[4*i+2]=
  176. alpMmxFilter[4*i+3]= lumMmxFilter[4*i+2];
  177. }
  178. }
  179. for (i=0; i<vChrFilterSize; i++) {
  180. *(const void**)&chrMmxFilter[4*i+0]= chrUSrcPtr[i];
  181. chrMmxFilter[4*i+2]=
  182. chrMmxFilter[4*i+3]=
  183. ((uint16_t)vChrFilter[chrDstY*vChrFilterSize + i])*0x10001;
  184. }
  185. }
  186. }
  187. }
  188. #endif /* HAVE_INLINE_ASM */
  189. #define SCALE_FUNC(filter_n, from_bpc, to_bpc, opt) \
  190. void ff_hscale ## from_bpc ## to ## to_bpc ## _ ## filter_n ## _ ## opt( \
  191. SwsContext *c, int16_t *data, \
  192. int dstW, const uint8_t *src, \
  193. const int16_t *filter, \
  194. const int32_t *filterPos, int filterSize)
  195. #define SCALE_FUNCS(filter_n, opt) \
  196. SCALE_FUNC(filter_n, 8, 15, opt); \
  197. SCALE_FUNC(filter_n, 9, 15, opt); \
  198. SCALE_FUNC(filter_n, 10, 15, opt); \
  199. SCALE_FUNC(filter_n, 12, 15, opt); \
  200. SCALE_FUNC(filter_n, 16, 15, opt); \
  201. SCALE_FUNC(filter_n, 8, 19, opt); \
  202. SCALE_FUNC(filter_n, 9, 19, opt); \
  203. SCALE_FUNC(filter_n, 10, 19, opt); \
  204. SCALE_FUNC(filter_n, 12, 19, opt); \
  205. SCALE_FUNC(filter_n, 16, 19, opt)
  206. #define SCALE_FUNCS_MMX(opt) \
  207. SCALE_FUNCS(4, opt); \
  208. SCALE_FUNCS(8, opt); \
  209. SCALE_FUNCS(X, opt)
  210. #define SCALE_FUNCS_SSE(opt) \
  211. SCALE_FUNCS(4, opt); \
  212. SCALE_FUNCS(8, opt); \
  213. SCALE_FUNCS(X4, opt); \
  214. SCALE_FUNCS(X8, opt)
  215. #if ARCH_X86_32
  216. SCALE_FUNCS_MMX(mmx);
  217. #endif
  218. SCALE_FUNCS_SSE(sse2);
  219. SCALE_FUNCS_SSE(ssse3);
  220. SCALE_FUNCS_SSE(sse4);
  221. #define VSCALEX_FUNC(size, opt) \
  222. void ff_yuv2planeX_ ## size ## _ ## opt(const int16_t *filter, int filterSize, \
  223. const int16_t **src, uint8_t *dest, int dstW, \
  224. const uint8_t *dither, int offset)
  225. #define VSCALEX_FUNCS(opt) \
  226. VSCALEX_FUNC(8, opt); \
  227. VSCALEX_FUNC(9, opt); \
  228. VSCALEX_FUNC(10, opt)
  229. #if ARCH_X86_32
  230. VSCALEX_FUNCS(mmxext);
  231. #endif
  232. VSCALEX_FUNCS(sse2);
  233. VSCALEX_FUNCS(sse4);
  234. VSCALEX_FUNC(16, sse4);
  235. VSCALEX_FUNCS(avx);
  236. #define VSCALE_FUNC(size, opt) \
  237. void ff_yuv2plane1_ ## size ## _ ## opt(const int16_t *src, uint8_t *dst, int dstW, \
  238. const uint8_t *dither, int offset)
  239. #define VSCALE_FUNCS(opt1, opt2) \
  240. VSCALE_FUNC(8, opt1); \
  241. VSCALE_FUNC(9, opt2); \
  242. VSCALE_FUNC(10, opt2); \
  243. VSCALE_FUNC(16, opt1)
  244. #if ARCH_X86_32
  245. VSCALE_FUNCS(mmx, mmxext);
  246. #endif
  247. VSCALE_FUNCS(sse2, sse2);
  248. VSCALE_FUNC(16, sse4);
  249. VSCALE_FUNCS(avx, avx);
  250. #define INPUT_Y_FUNC(fmt, opt) \
  251. void ff_ ## fmt ## ToY_ ## opt(uint8_t *dst, const uint8_t *src, \
  252. int w, uint32_t *unused)
  253. #define INPUT_UV_FUNC(fmt, opt) \
  254. void ff_ ## fmt ## ToUV_ ## opt(uint8_t *dstU, uint8_t *dstV, \
  255. const uint8_t *src, const uint8_t *unused1, \
  256. int w, uint32_t *unused2)
  257. #define INPUT_FUNC(fmt, opt) \
  258. INPUT_Y_FUNC(fmt, opt); \
  259. INPUT_UV_FUNC(fmt, opt)
  260. #define INPUT_FUNCS(opt) \
  261. INPUT_FUNC(uyvy, opt); \
  262. INPUT_FUNC(yuyv, opt); \
  263. INPUT_UV_FUNC(nv12, opt); \
  264. INPUT_UV_FUNC(nv21, opt); \
  265. INPUT_FUNC(rgba, opt); \
  266. INPUT_FUNC(bgra, opt); \
  267. INPUT_FUNC(argb, opt); \
  268. INPUT_FUNC(abgr, opt); \
  269. INPUT_FUNC(rgb24, opt); \
  270. INPUT_FUNC(bgr24, opt)
  271. #if ARCH_X86_32
  272. INPUT_FUNCS(mmx);
  273. #endif
  274. INPUT_FUNCS(sse2);
  275. INPUT_FUNCS(ssse3);
  276. INPUT_FUNCS(avx);
  277. av_cold void ff_sws_init_swscale_x86(SwsContext *c)
  278. {
  279. int cpu_flags = av_get_cpu_flags();
  280. #if HAVE_MMX_INLINE
  281. if (INLINE_MMX(cpu_flags))
  282. sws_init_swscale_mmx(c);
  283. #endif
  284. #if HAVE_MMXEXT_INLINE
  285. if (INLINE_MMXEXT(cpu_flags))
  286. sws_init_swscale_mmxext(c);
  287. #endif
  288. #define ASSIGN_SCALE_FUNC2(hscalefn, filtersize, opt1, opt2) do { \
  289. if (c->srcBpc == 8) { \
  290. hscalefn = c->dstBpc <= 15 ? ff_hscale8to15_ ## filtersize ## _ ## opt2 : \
  291. ff_hscale8to19_ ## filtersize ## _ ## opt1; \
  292. } else if (c->srcBpc == 9) { \
  293. hscalefn = c->dstBpc <= 15 ? ff_hscale9to15_ ## filtersize ## _ ## opt2 : \
  294. ff_hscale9to19_ ## filtersize ## _ ## opt1; \
  295. } else if (c->srcBpc == 10) { \
  296. hscalefn = c->dstBpc <= 15 ? ff_hscale10to15_ ## filtersize ## _ ## opt2 : \
  297. ff_hscale10to19_ ## filtersize ## _ ## opt1; \
  298. } else if (c->srcBpc == 12) { \
  299. hscalefn = c->dstBpc <= 15 ? ff_hscale12to15_ ## filtersize ## _ ## opt2 : \
  300. ff_hscale12to19_ ## filtersize ## _ ## opt1; \
  301. } else if (c->srcBpc == 16) { \
  302. hscalefn = c->dstBpc <= 15 ? ff_hscale16to15_ ## filtersize ## _ ## opt2 : \
  303. ff_hscale16to19_ ## filtersize ## _ ## opt1; \
  304. } \
  305. } while (0)
  306. #define ASSIGN_MMX_SCALE_FUNC(hscalefn, filtersize, opt1, opt2) \
  307. switch (filtersize) { \
  308. case 4: ASSIGN_SCALE_FUNC2(hscalefn, 4, opt1, opt2); break; \
  309. case 8: ASSIGN_SCALE_FUNC2(hscalefn, 8, opt1, opt2); break; \
  310. default: ASSIGN_SCALE_FUNC2(hscalefn, X, opt1, opt2); break; \
  311. }
  312. #define ASSIGN_VSCALEX_FUNC(vscalefn, opt, do_16_case, condition_8bit) \
  313. switch(c->dstBpc){ \
  314. case 16: do_16_case; break; \
  315. case 10: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2planeX_10_ ## opt; break; \
  316. case 9: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2planeX_9_ ## opt; break; \
  317. case 8: if (condition_8bit) vscalefn = ff_yuv2planeX_8_ ## opt; break; \
  318. }
  319. #define ASSIGN_VSCALE_FUNC(vscalefn, opt1, opt2, opt2chk) \
  320. switch(c->dstBpc){ \
  321. case 16: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2plane1_16_ ## opt1; break; \
  322. case 10: if (!isBE(c->dstFormat) && opt2chk) vscalefn = ff_yuv2plane1_10_ ## opt2; break; \
  323. case 9: if (!isBE(c->dstFormat) && opt2chk) vscalefn = ff_yuv2plane1_9_ ## opt2; break; \
  324. case 8: vscalefn = ff_yuv2plane1_8_ ## opt1; break; \
  325. }
  326. #define case_rgb(x, X, opt) \
  327. case AV_PIX_FMT_ ## X: \
  328. c->lumToYV12 = ff_ ## x ## ToY_ ## opt; \
  329. if (!c->chrSrcHSubSample) \
  330. c->chrToYV12 = ff_ ## x ## ToUV_ ## opt; \
  331. break
  332. #if ARCH_X86_32
  333. if (EXTERNAL_MMX(cpu_flags)) {
  334. ASSIGN_MMX_SCALE_FUNC(c->hyScale, c->hLumFilterSize, mmx, mmx);
  335. ASSIGN_MMX_SCALE_FUNC(c->hcScale, c->hChrFilterSize, mmx, mmx);
  336. ASSIGN_VSCALE_FUNC(c->yuv2plane1, mmx, mmxext, cpu_flags & AV_CPU_FLAG_MMXEXT);
  337. switch (c->srcFormat) {
  338. case AV_PIX_FMT_YA8:
  339. c->lumToYV12 = ff_yuyvToY_mmx;
  340. if (c->alpPixBuf)
  341. c->alpToYV12 = ff_uyvyToY_mmx;
  342. break;
  343. case AV_PIX_FMT_YUYV422:
  344. c->lumToYV12 = ff_yuyvToY_mmx;
  345. c->chrToYV12 = ff_yuyvToUV_mmx;
  346. break;
  347. case AV_PIX_FMT_UYVY422:
  348. c->lumToYV12 = ff_uyvyToY_mmx;
  349. c->chrToYV12 = ff_uyvyToUV_mmx;
  350. break;
  351. case AV_PIX_FMT_NV12:
  352. c->chrToYV12 = ff_nv12ToUV_mmx;
  353. break;
  354. case AV_PIX_FMT_NV21:
  355. c->chrToYV12 = ff_nv21ToUV_mmx;
  356. break;
  357. case_rgb(rgb24, RGB24, mmx);
  358. case_rgb(bgr24, BGR24, mmx);
  359. case_rgb(bgra, BGRA, mmx);
  360. case_rgb(rgba, RGBA, mmx);
  361. case_rgb(abgr, ABGR, mmx);
  362. case_rgb(argb, ARGB, mmx);
  363. default:
  364. break;
  365. }
  366. }
  367. if (EXTERNAL_MMXEXT(cpu_flags)) {
  368. ASSIGN_VSCALEX_FUNC(c->yuv2planeX, mmxext, , 1);
  369. }
  370. #endif /* ARCH_X86_32 */
  371. #define ASSIGN_SSE_SCALE_FUNC(hscalefn, filtersize, opt1, opt2) \
  372. switch (filtersize) { \
  373. case 4: ASSIGN_SCALE_FUNC2(hscalefn, 4, opt1, opt2); break; \
  374. case 8: ASSIGN_SCALE_FUNC2(hscalefn, 8, opt1, opt2); break; \
  375. default: if (filtersize & 4) ASSIGN_SCALE_FUNC2(hscalefn, X4, opt1, opt2); \
  376. else ASSIGN_SCALE_FUNC2(hscalefn, X8, opt1, opt2); \
  377. break; \
  378. }
  379. if (EXTERNAL_SSE2(cpu_flags)) {
  380. ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, sse2, sse2);
  381. ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, sse2, sse2);
  382. ASSIGN_VSCALEX_FUNC(c->yuv2planeX, sse2, ,
  383. HAVE_ALIGNED_STACK || ARCH_X86_64);
  384. ASSIGN_VSCALE_FUNC(c->yuv2plane1, sse2, sse2, 1);
  385. switch (c->srcFormat) {
  386. case AV_PIX_FMT_YA8:
  387. c->lumToYV12 = ff_yuyvToY_sse2;
  388. if (c->alpPixBuf)
  389. c->alpToYV12 = ff_uyvyToY_sse2;
  390. break;
  391. case AV_PIX_FMT_YUYV422:
  392. c->lumToYV12 = ff_yuyvToY_sse2;
  393. c->chrToYV12 = ff_yuyvToUV_sse2;
  394. break;
  395. case AV_PIX_FMT_UYVY422:
  396. c->lumToYV12 = ff_uyvyToY_sse2;
  397. c->chrToYV12 = ff_uyvyToUV_sse2;
  398. break;
  399. case AV_PIX_FMT_NV12:
  400. c->chrToYV12 = ff_nv12ToUV_sse2;
  401. break;
  402. case AV_PIX_FMT_NV21:
  403. c->chrToYV12 = ff_nv21ToUV_sse2;
  404. break;
  405. case_rgb(rgb24, RGB24, sse2);
  406. case_rgb(bgr24, BGR24, sse2);
  407. case_rgb(bgra, BGRA, sse2);
  408. case_rgb(rgba, RGBA, sse2);
  409. case_rgb(abgr, ABGR, sse2);
  410. case_rgb(argb, ARGB, sse2);
  411. default:
  412. break;
  413. }
  414. }
  415. if (EXTERNAL_SSSE3(cpu_flags)) {
  416. ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, ssse3, ssse3);
  417. ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, ssse3, ssse3);
  418. switch (c->srcFormat) {
  419. case_rgb(rgb24, RGB24, ssse3);
  420. case_rgb(bgr24, BGR24, ssse3);
  421. default:
  422. break;
  423. }
  424. }
  425. if (EXTERNAL_SSE4(cpu_flags)) {
  426. /* Xto15 don't need special sse4 functions */
  427. ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, sse4, ssse3);
  428. ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, sse4, ssse3);
  429. ASSIGN_VSCALEX_FUNC(c->yuv2planeX, sse4,
  430. if (!isBE(c->dstFormat)) c->yuv2planeX = ff_yuv2planeX_16_sse4,
  431. HAVE_ALIGNED_STACK || ARCH_X86_64);
  432. if (c->dstBpc == 16 && !isBE(c->dstFormat))
  433. c->yuv2plane1 = ff_yuv2plane1_16_sse4;
  434. }
  435. if (EXTERNAL_AVX(cpu_flags)) {
  436. ASSIGN_VSCALEX_FUNC(c->yuv2planeX, avx, ,
  437. HAVE_ALIGNED_STACK || ARCH_X86_64);
  438. ASSIGN_VSCALE_FUNC(c->yuv2plane1, avx, avx, 1);
  439. switch (c->srcFormat) {
  440. case AV_PIX_FMT_YUYV422:
  441. c->chrToYV12 = ff_yuyvToUV_avx;
  442. break;
  443. case AV_PIX_FMT_UYVY422:
  444. c->chrToYV12 = ff_uyvyToUV_avx;
  445. break;
  446. case AV_PIX_FMT_NV12:
  447. c->chrToYV12 = ff_nv12ToUV_avx;
  448. break;
  449. case AV_PIX_FMT_NV21:
  450. c->chrToYV12 = ff_nv21ToUV_avx;
  451. break;
  452. case_rgb(rgb24, RGB24, avx);
  453. case_rgb(bgr24, BGR24, avx);
  454. case_rgb(bgra, BGRA, avx);
  455. case_rgb(rgba, RGBA, avx);
  456. case_rgb(abgr, ABGR, avx);
  457. case_rgb(argb, ARGB, avx);
  458. default:
  459. break;
  460. }
  461. }
  462. }