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.

493 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, 16, 15, opt); \
  200. SCALE_FUNC(filter_n, 8, 19, opt); \
  201. SCALE_FUNC(filter_n, 9, 19, opt); \
  202. SCALE_FUNC(filter_n, 10, 19, opt); \
  203. SCALE_FUNC(filter_n, 16, 19, opt)
  204. #define SCALE_FUNCS_MMX(opt) \
  205. SCALE_FUNCS(4, opt); \
  206. SCALE_FUNCS(8, opt); \
  207. SCALE_FUNCS(X, opt)
  208. #define SCALE_FUNCS_SSE(opt) \
  209. SCALE_FUNCS(4, opt); \
  210. SCALE_FUNCS(8, opt); \
  211. SCALE_FUNCS(X4, opt); \
  212. SCALE_FUNCS(X8, opt)
  213. #if ARCH_X86_32
  214. SCALE_FUNCS_MMX(mmx);
  215. #endif
  216. SCALE_FUNCS_SSE(sse2);
  217. SCALE_FUNCS_SSE(ssse3);
  218. SCALE_FUNCS_SSE(sse4);
  219. #define VSCALEX_FUNC(size, opt) \
  220. void ff_yuv2planeX_ ## size ## _ ## opt(const int16_t *filter, int filterSize, \
  221. const int16_t **src, uint8_t *dest, int dstW, \
  222. const uint8_t *dither, int offset)
  223. #define VSCALEX_FUNCS(opt) \
  224. VSCALEX_FUNC(8, opt); \
  225. VSCALEX_FUNC(9, opt); \
  226. VSCALEX_FUNC(10, opt)
  227. #if ARCH_X86_32
  228. VSCALEX_FUNCS(mmxext);
  229. #endif
  230. VSCALEX_FUNCS(sse2);
  231. VSCALEX_FUNCS(sse4);
  232. VSCALEX_FUNC(16, sse4);
  233. VSCALEX_FUNCS(avx);
  234. #define VSCALE_FUNC(size, opt) \
  235. void ff_yuv2plane1_ ## size ## _ ## opt(const int16_t *src, uint8_t *dst, int dstW, \
  236. const uint8_t *dither, int offset)
  237. #define VSCALE_FUNCS(opt1, opt2) \
  238. VSCALE_FUNC(8, opt1); \
  239. VSCALE_FUNC(9, opt2); \
  240. VSCALE_FUNC(10, opt2); \
  241. VSCALE_FUNC(16, opt1)
  242. #if ARCH_X86_32
  243. VSCALE_FUNCS(mmx, mmxext);
  244. #endif
  245. VSCALE_FUNCS(sse2, sse2);
  246. VSCALE_FUNC(16, sse4);
  247. VSCALE_FUNCS(avx, avx);
  248. #define INPUT_Y_FUNC(fmt, opt) \
  249. void ff_ ## fmt ## ToY_ ## opt(uint8_t *dst, const uint8_t *src, \
  250. int w, uint32_t *unused)
  251. #define INPUT_UV_FUNC(fmt, opt) \
  252. void ff_ ## fmt ## ToUV_ ## opt(uint8_t *dstU, uint8_t *dstV, \
  253. const uint8_t *src, const uint8_t *unused1, \
  254. int w, uint32_t *unused2)
  255. #define INPUT_FUNC(fmt, opt) \
  256. INPUT_Y_FUNC(fmt, opt); \
  257. INPUT_UV_FUNC(fmt, opt)
  258. #define INPUT_FUNCS(opt) \
  259. INPUT_FUNC(uyvy, opt); \
  260. INPUT_FUNC(yuyv, opt); \
  261. INPUT_UV_FUNC(nv12, opt); \
  262. INPUT_UV_FUNC(nv21, opt); \
  263. INPUT_FUNC(rgba, opt); \
  264. INPUT_FUNC(bgra, opt); \
  265. INPUT_FUNC(argb, opt); \
  266. INPUT_FUNC(abgr, opt); \
  267. INPUT_FUNC(rgb24, opt); \
  268. INPUT_FUNC(bgr24, opt)
  269. #if ARCH_X86_32
  270. INPUT_FUNCS(mmx);
  271. #endif
  272. INPUT_FUNCS(sse2);
  273. INPUT_FUNCS(ssse3);
  274. INPUT_FUNCS(avx);
  275. av_cold void ff_sws_init_swscale_x86(SwsContext *c)
  276. {
  277. int cpu_flags = av_get_cpu_flags();
  278. #if HAVE_MMX_INLINE
  279. if (INLINE_MMX(cpu_flags))
  280. sws_init_swscale_mmx(c);
  281. #endif
  282. #if HAVE_MMXEXT_INLINE
  283. if (INLINE_MMXEXT(cpu_flags))
  284. sws_init_swscale_mmxext(c);
  285. #endif
  286. #define ASSIGN_SCALE_FUNC2(hscalefn, filtersize, opt1, opt2) do { \
  287. if (c->srcBpc == 8) { \
  288. hscalefn = c->dstBpc <= 10 ? ff_hscale8to15_ ## filtersize ## _ ## opt2 : \
  289. ff_hscale8to19_ ## filtersize ## _ ## opt1; \
  290. } else if (c->srcBpc == 9) { \
  291. hscalefn = c->dstBpc <= 10 ? ff_hscale9to15_ ## filtersize ## _ ## opt2 : \
  292. ff_hscale9to19_ ## filtersize ## _ ## opt1; \
  293. } else if (c->srcBpc == 10) { \
  294. hscalefn = c->dstBpc <= 10 ? ff_hscale10to15_ ## filtersize ## _ ## opt2 : \
  295. ff_hscale10to19_ ## filtersize ## _ ## opt1; \
  296. } else /* c->srcBpc == 16 */ { \
  297. hscalefn = c->dstBpc <= 10 ? ff_hscale16to15_ ## filtersize ## _ ## opt2 : \
  298. ff_hscale16to19_ ## filtersize ## _ ## opt1; \
  299. } \
  300. } while (0)
  301. #define ASSIGN_MMX_SCALE_FUNC(hscalefn, filtersize, opt1, opt2) \
  302. switch (filtersize) { \
  303. case 4: ASSIGN_SCALE_FUNC2(hscalefn, 4, opt1, opt2); break; \
  304. case 8: ASSIGN_SCALE_FUNC2(hscalefn, 8, opt1, opt2); break; \
  305. default: ASSIGN_SCALE_FUNC2(hscalefn, X, opt1, opt2); break; \
  306. }
  307. #define ASSIGN_VSCALEX_FUNC(vscalefn, opt, do_16_case, condition_8bit) \
  308. switch(c->dstBpc){ \
  309. case 16: do_16_case; break; \
  310. case 10: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2planeX_10_ ## opt; break; \
  311. case 9: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2planeX_9_ ## opt; break; \
  312. default: if (condition_8bit) vscalefn = ff_yuv2planeX_8_ ## opt; break; \
  313. }
  314. #define ASSIGN_VSCALE_FUNC(vscalefn, opt1, opt2, opt2chk) \
  315. switch(c->dstBpc){ \
  316. case 16: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2plane1_16_ ## opt1; break; \
  317. case 10: if (!isBE(c->dstFormat) && opt2chk) vscalefn = ff_yuv2plane1_10_ ## opt2; break; \
  318. case 9: if (!isBE(c->dstFormat) && opt2chk) vscalefn = ff_yuv2plane1_9_ ## opt2; break; \
  319. default: vscalefn = ff_yuv2plane1_8_ ## opt1; break; \
  320. }
  321. #define case_rgb(x, X, opt) \
  322. case AV_PIX_FMT_ ## X: \
  323. c->lumToYV12 = ff_ ## x ## ToY_ ## opt; \
  324. if (!c->chrSrcHSubSample) \
  325. c->chrToYV12 = ff_ ## x ## ToUV_ ## opt; \
  326. break
  327. #if ARCH_X86_32
  328. if (EXTERNAL_MMX(cpu_flags)) {
  329. ASSIGN_MMX_SCALE_FUNC(c->hyScale, c->hLumFilterSize, mmx, mmx);
  330. ASSIGN_MMX_SCALE_FUNC(c->hcScale, c->hChrFilterSize, mmx, mmx);
  331. ASSIGN_VSCALE_FUNC(c->yuv2plane1, mmx, mmxext, cpu_flags & AV_CPU_FLAG_MMXEXT);
  332. switch (c->srcFormat) {
  333. case AV_PIX_FMT_YA8:
  334. c->lumToYV12 = ff_yuyvToY_mmx;
  335. if (c->alpPixBuf)
  336. c->alpToYV12 = ff_uyvyToY_mmx;
  337. break;
  338. case AV_PIX_FMT_YUYV422:
  339. c->lumToYV12 = ff_yuyvToY_mmx;
  340. c->chrToYV12 = ff_yuyvToUV_mmx;
  341. break;
  342. case AV_PIX_FMT_UYVY422:
  343. c->lumToYV12 = ff_uyvyToY_mmx;
  344. c->chrToYV12 = ff_uyvyToUV_mmx;
  345. break;
  346. case AV_PIX_FMT_NV12:
  347. c->chrToYV12 = ff_nv12ToUV_mmx;
  348. break;
  349. case AV_PIX_FMT_NV21:
  350. c->chrToYV12 = ff_nv21ToUV_mmx;
  351. break;
  352. case_rgb(rgb24, RGB24, mmx);
  353. case_rgb(bgr24, BGR24, mmx);
  354. case_rgb(bgra, BGRA, mmx);
  355. case_rgb(rgba, RGBA, mmx);
  356. case_rgb(abgr, ABGR, mmx);
  357. case_rgb(argb, ARGB, mmx);
  358. default:
  359. break;
  360. }
  361. }
  362. if (EXTERNAL_MMXEXT(cpu_flags)) {
  363. ASSIGN_VSCALEX_FUNC(c->yuv2planeX, mmxext, , 1);
  364. }
  365. #endif /* ARCH_X86_32 */
  366. #define ASSIGN_SSE_SCALE_FUNC(hscalefn, filtersize, opt1, opt2) \
  367. switch (filtersize) { \
  368. case 4: ASSIGN_SCALE_FUNC2(hscalefn, 4, opt1, opt2); break; \
  369. case 8: ASSIGN_SCALE_FUNC2(hscalefn, 8, opt1, opt2); break; \
  370. default: if (filtersize & 4) ASSIGN_SCALE_FUNC2(hscalefn, X4, opt1, opt2); \
  371. else ASSIGN_SCALE_FUNC2(hscalefn, X8, opt1, opt2); \
  372. break; \
  373. }
  374. if (EXTERNAL_SSE2(cpu_flags)) {
  375. ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, sse2, sse2);
  376. ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, sse2, sse2);
  377. ASSIGN_VSCALEX_FUNC(c->yuv2planeX, sse2, ,
  378. HAVE_ALIGNED_STACK || ARCH_X86_64);
  379. ASSIGN_VSCALE_FUNC(c->yuv2plane1, sse2, sse2, 1);
  380. switch (c->srcFormat) {
  381. case AV_PIX_FMT_YA8:
  382. c->lumToYV12 = ff_yuyvToY_sse2;
  383. if (c->alpPixBuf)
  384. c->alpToYV12 = ff_uyvyToY_sse2;
  385. break;
  386. case AV_PIX_FMT_YUYV422:
  387. c->lumToYV12 = ff_yuyvToY_sse2;
  388. c->chrToYV12 = ff_yuyvToUV_sse2;
  389. break;
  390. case AV_PIX_FMT_UYVY422:
  391. c->lumToYV12 = ff_uyvyToY_sse2;
  392. c->chrToYV12 = ff_uyvyToUV_sse2;
  393. break;
  394. case AV_PIX_FMT_NV12:
  395. c->chrToYV12 = ff_nv12ToUV_sse2;
  396. break;
  397. case AV_PIX_FMT_NV21:
  398. c->chrToYV12 = ff_nv21ToUV_sse2;
  399. break;
  400. case_rgb(rgb24, RGB24, sse2);
  401. case_rgb(bgr24, BGR24, sse2);
  402. case_rgb(bgra, BGRA, sse2);
  403. case_rgb(rgba, RGBA, sse2);
  404. case_rgb(abgr, ABGR, sse2);
  405. case_rgb(argb, ARGB, sse2);
  406. default:
  407. break;
  408. }
  409. }
  410. if (EXTERNAL_SSSE3(cpu_flags)) {
  411. ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, ssse3, ssse3);
  412. ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, ssse3, ssse3);
  413. switch (c->srcFormat) {
  414. case_rgb(rgb24, RGB24, ssse3);
  415. case_rgb(bgr24, BGR24, ssse3);
  416. default:
  417. break;
  418. }
  419. }
  420. if (EXTERNAL_SSE4(cpu_flags)) {
  421. /* Xto15 don't need special sse4 functions */
  422. ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, sse4, ssse3);
  423. ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, sse4, ssse3);
  424. ASSIGN_VSCALEX_FUNC(c->yuv2planeX, sse4,
  425. if (!isBE(c->dstFormat)) c->yuv2planeX = ff_yuv2planeX_16_sse4,
  426. HAVE_ALIGNED_STACK || ARCH_X86_64);
  427. if (c->dstBpc == 16 && !isBE(c->dstFormat))
  428. c->yuv2plane1 = ff_yuv2plane1_16_sse4;
  429. }
  430. if (EXTERNAL_AVX(cpu_flags)) {
  431. ASSIGN_VSCALEX_FUNC(c->yuv2planeX, avx, ,
  432. HAVE_ALIGNED_STACK || ARCH_X86_64);
  433. ASSIGN_VSCALE_FUNC(c->yuv2plane1, avx, avx, 1);
  434. switch (c->srcFormat) {
  435. case AV_PIX_FMT_YUYV422:
  436. c->chrToYV12 = ff_yuyvToUV_avx;
  437. break;
  438. case AV_PIX_FMT_UYVY422:
  439. c->chrToYV12 = ff_uyvyToUV_avx;
  440. break;
  441. case AV_PIX_FMT_NV12:
  442. c->chrToYV12 = ff_nv12ToUV_avx;
  443. break;
  444. case AV_PIX_FMT_NV21:
  445. c->chrToYV12 = ff_nv21ToUV_avx;
  446. break;
  447. case_rgb(rgb24, RGB24, avx);
  448. case_rgb(bgr24, BGR24, avx);
  449. case_rgb(bgra, BGRA, avx);
  450. case_rgb(rgba, RGBA, avx);
  451. case_rgb(abgr, ABGR, avx);
  452. case_rgb(argb, ARGB, avx);
  453. default:
  454. break;
  455. }
  456. }
  457. }