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.

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