swscale.c
Go to the documentation of this file.
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 
21 #include <inttypes.h>
22 #include "config.h"
23 #include "libswscale/swscale.h"
25 #include "libavutil/attributes.h"
26 #include "libavutil/intreadwrite.h"
27 #include "libavutil/x86/asm.h"
28 #include "libavutil/x86/cpu.h"
29 #include "libavutil/cpu.h"
30 #include "libavutil/pixdesc.h"
31 
32 #if HAVE_INLINE_ASM
33 
34 #define DITHER1XBPP
35 
36 DECLARE_ASM_CONST(8, uint64_t, bF8)= 0xF8F8F8F8F8F8F8F8LL;
37 DECLARE_ASM_CONST(8, uint64_t, bFC)= 0xFCFCFCFCFCFCFCFCLL;
38 DECLARE_ASM_CONST(8, uint64_t, w10)= 0x0010001000100010LL;
39 DECLARE_ASM_CONST(8, uint64_t, w02)= 0x0002000200020002LL;
40 
41 const DECLARE_ALIGNED(8, uint64_t, ff_dither4)[2] = {
42  0x0103010301030103LL,
43  0x0200020002000200LL,};
44 
45 const DECLARE_ALIGNED(8, uint64_t, ff_dither8)[2] = {
46  0x0602060206020602LL,
47  0x0004000400040004LL,};
48 
49 DECLARE_ASM_CONST(8, uint64_t, b16Mask)= 0x001F001F001F001FLL;
50 DECLARE_ASM_CONST(8, uint64_t, g16Mask)= 0x07E007E007E007E0LL;
51 DECLARE_ASM_CONST(8, uint64_t, r16Mask)= 0xF800F800F800F800LL;
52 DECLARE_ASM_CONST(8, uint64_t, b15Mask)= 0x001F001F001F001FLL;
53 DECLARE_ASM_CONST(8, uint64_t, g15Mask)= 0x03E003E003E003E0LL;
54 DECLARE_ASM_CONST(8, uint64_t, r15Mask)= 0x7C007C007C007C00LL;
55 
56 DECLARE_ALIGNED(8, const uint64_t, ff_M24A) = 0x00FF0000FF0000FFLL;
57 DECLARE_ALIGNED(8, const uint64_t, ff_M24B) = 0xFF0000FF0000FF00LL;
58 DECLARE_ALIGNED(8, const uint64_t, ff_M24C) = 0x0000FF0000FF0000LL;
59 
60 #ifdef FAST_BGR2YV12
61 DECLARE_ALIGNED(8, const uint64_t, ff_bgr2YCoeff) = 0x000000210041000DULL;
62 DECLARE_ALIGNED(8, const uint64_t, ff_bgr2UCoeff) = 0x0000FFEEFFDC0038ULL;
63 DECLARE_ALIGNED(8, const uint64_t, ff_bgr2VCoeff) = 0x00000038FFD2FFF8ULL;
64 #else
65 DECLARE_ALIGNED(8, const uint64_t, ff_bgr2YCoeff) = 0x000020E540830C8BULL;
66 DECLARE_ALIGNED(8, const uint64_t, ff_bgr2UCoeff) = 0x0000ED0FDAC23831ULL;
67 DECLARE_ALIGNED(8, const uint64_t, ff_bgr2VCoeff) = 0x00003831D0E6F6EAULL;
68 #endif /* FAST_BGR2YV12 */
69 DECLARE_ALIGNED(8, const uint64_t, ff_bgr2YOffset) = 0x1010101010101010ULL;
70 DECLARE_ALIGNED(8, const uint64_t, ff_bgr2UVOffset) = 0x8080808080808080ULL;
71 DECLARE_ALIGNED(8, const uint64_t, ff_w1111) = 0x0001000100010001ULL;
72 
73 //MMX versions
74 #if HAVE_MMX_INLINE
75 #undef RENAME
76 #define COMPILE_TEMPLATE_MMXEXT 0
77 #define RENAME(a) a ## _MMX
78 #include "swscale_template.c"
79 #endif
80 
81 // MMXEXT versions
82 #if HAVE_MMXEXT_INLINE
83 #undef RENAME
84 #undef COMPILE_TEMPLATE_MMXEXT
85 #define COMPILE_TEMPLATE_MMXEXT 1
86 #define RENAME(a) a ## _MMXEXT
87 #include "swscale_template.c"
88 #endif
89 
91  int lastInLumBuf, int lastInChrBuf)
92 {
93  const int dstH= c->dstH;
94  const int flags= c->flags;
95  int16_t **lumPixBuf= c->lumPixBuf;
96  int16_t **chrUPixBuf= c->chrUPixBuf;
97  int16_t **alpPixBuf= c->alpPixBuf;
98  const int vLumBufSize= c->vLumBufSize;
99  const int vChrBufSize= c->vChrBufSize;
102  int16_t *vLumFilter= c->vLumFilter;
103  int16_t *vChrFilter= c->vChrFilter;
107  const int vLumFilterSize= c->vLumFilterSize;
108  const int vChrFilterSize= c->vChrFilterSize;
109  const int chrDstY= dstY>>c->chrDstVSubSample;
110  const int firstLumSrcY= vLumFilterPos[dstY]; //First line needed as input
111  const int firstChrSrcY= vChrFilterPos[chrDstY]; //First line needed as input
112 
113  c->blueDither= ff_dither8[dstY&1];
115  c->greenDither= ff_dither8[dstY&1];
116  else
117  c->greenDither= ff_dither4[dstY&1];
118  c->redDither= ff_dither8[(dstY+1)&1];
119  if (dstY < dstH - 2) {
120  const int16_t **lumSrcPtr= (const int16_t **) lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
121  const int16_t **chrUSrcPtr= (const int16_t **) chrUPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
122  const int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **) alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL;
123  int i;
124 
125  if (firstLumSrcY < 0 || firstLumSrcY + vLumFilterSize > c->srcH) {
126  const int16_t **tmpY = (const int16_t **) lumPixBuf + 2 * vLumBufSize;
127  int neg = -firstLumSrcY, i, end = FFMIN(c->srcH - firstLumSrcY, vLumFilterSize);
128  for (i = 0; i < neg; i++)
129  tmpY[i] = lumSrcPtr[neg];
130  for ( ; i < end; i++)
131  tmpY[i] = lumSrcPtr[i];
132  for ( ; i < vLumFilterSize; i++)
133  tmpY[i] = tmpY[i-1];
134  lumSrcPtr = tmpY;
135 
136  if (alpSrcPtr) {
137  const int16_t **tmpA = (const int16_t **) alpPixBuf + 2 * vLumBufSize;
138  for (i = 0; i < neg; i++)
139  tmpA[i] = alpSrcPtr[neg];
140  for ( ; i < end; i++)
141  tmpA[i] = alpSrcPtr[i];
142  for ( ; i < vLumFilterSize; i++)
143  tmpA[i] = tmpA[i - 1];
144  alpSrcPtr = tmpA;
145  }
146  }
147  if (firstChrSrcY < 0 || firstChrSrcY + vChrFilterSize > c->chrSrcH) {
148  const int16_t **tmpU = (const int16_t **) chrUPixBuf + 2 * vChrBufSize;
149  int neg = -firstChrSrcY, i, end = FFMIN(c->chrSrcH - firstChrSrcY, vChrFilterSize);
150  for (i = 0; i < neg; i++) {
151  tmpU[i] = chrUSrcPtr[neg];
152  }
153  for ( ; i < end; i++) {
154  tmpU[i] = chrUSrcPtr[i];
155  }
156  for ( ; i < vChrFilterSize; i++) {
157  tmpU[i] = tmpU[i - 1];
158  }
159  chrUSrcPtr = tmpU;
160  }
161 
162  if (flags & SWS_ACCURATE_RND) {
163  int s= APCK_SIZE / 8;
164  for (i=0; i<vLumFilterSize; i+=2) {
165  *(const void**)&lumMmxFilter[s*i ]= lumSrcPtr[i ];
166  *(const void**)&lumMmxFilter[s*i+APCK_PTR2/4 ]= lumSrcPtr[i+(vLumFilterSize>1)];
167  lumMmxFilter[s*i+APCK_COEF/4 ]=
168  lumMmxFilter[s*i+APCK_COEF/4+1]= vLumFilter[dstY*vLumFilterSize + i ]
169  + (vLumFilterSize>1 ? vLumFilter[dstY*vLumFilterSize + i + 1]<<16 : 0);
170  if (CONFIG_SWSCALE_ALPHA && alpPixBuf) {
171  *(const void**)&alpMmxFilter[s*i ]= alpSrcPtr[i ];
172  *(const void**)&alpMmxFilter[s*i+APCK_PTR2/4 ]= alpSrcPtr[i+(vLumFilterSize>1)];
173  alpMmxFilter[s*i+APCK_COEF/4 ]=
174  alpMmxFilter[s*i+APCK_COEF/4+1]= lumMmxFilter[s*i+APCK_COEF/4 ];
175  }
176  }
177  for (i=0; i<vChrFilterSize; i+=2) {
178  *(const void**)&chrMmxFilter[s*i ]= chrUSrcPtr[i ];
179  *(const void**)&chrMmxFilter[s*i+APCK_PTR2/4 ]= chrUSrcPtr[i+(vChrFilterSize>1)];
180  chrMmxFilter[s*i+APCK_COEF/4 ]=
181  chrMmxFilter[s*i+APCK_COEF/4+1]= vChrFilter[chrDstY*vChrFilterSize + i ]
182  + (vChrFilterSize>1 ? vChrFilter[chrDstY*vChrFilterSize + i + 1]<<16 : 0);
183  }
184  } else {
185  for (i=0; i<vLumFilterSize; i++) {
186  *(const void**)&lumMmxFilter[4*i+0]= lumSrcPtr[i];
187  lumMmxFilter[4*i+2]=
188  lumMmxFilter[4*i+3]=
189  ((uint16_t)vLumFilter[dstY*vLumFilterSize + i])*0x10001;
190  if (CONFIG_SWSCALE_ALPHA && alpPixBuf) {
191  *(const void**)&alpMmxFilter[4*i+0]= alpSrcPtr[i];
192  alpMmxFilter[4*i+2]=
193  alpMmxFilter[4*i+3]= lumMmxFilter[4*i+2];
194  }
195  }
196  for (i=0; i<vChrFilterSize; i++) {
197  *(const void**)&chrMmxFilter[4*i+0]= chrUSrcPtr[i];
198  chrMmxFilter[4*i+2]=
199  chrMmxFilter[4*i+3]=
200  ((uint16_t)vChrFilter[chrDstY*vChrFilterSize + i])*0x10001;
201  }
202  }
203  }
204 }
205 
206 #endif /* HAVE_INLINE_ASM */
207 
208 #define SCALE_FUNC(filter_n, from_bpc, to_bpc, opt) \
209 extern void ff_hscale ## from_bpc ## to ## to_bpc ## _ ## filter_n ## _ ## opt( \
210  SwsContext *c, int16_t *data, \
211  int dstW, const uint8_t *src, \
212  const int16_t *filter, \
213  const int32_t *filterPos, int filterSize)
214 
215 #define SCALE_FUNCS(filter_n, opt) \
216  SCALE_FUNC(filter_n, 8, 15, opt); \
217  SCALE_FUNC(filter_n, 9, 15, opt); \
218  SCALE_FUNC(filter_n, 10, 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, 16, 19, opt)
224 
225 #define SCALE_FUNCS_MMX(opt) \
226  SCALE_FUNCS(4, opt); \
227  SCALE_FUNCS(8, opt); \
228  SCALE_FUNCS(X, opt)
229 
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 
236 #if ARCH_X86_32
237 SCALE_FUNCS_MMX(mmx);
238 #endif
239 SCALE_FUNCS_SSE(sse2);
240 SCALE_FUNCS_SSE(ssse3);
241 SCALE_FUNCS_SSE(sse4);
242 
243 #define VSCALEX_FUNC(size, opt) \
244 extern 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 
252 #if ARCH_X86_32
253 VSCALEX_FUNCS(mmxext);
254 #endif
255 VSCALEX_FUNCS(sse2);
256 VSCALEX_FUNCS(sse4);
257 VSCALEX_FUNC(16, sse4);
258 VSCALEX_FUNCS(avx);
259 
260 #define VSCALE_FUNC(size, opt) \
261 extern void ff_yuv2plane1_ ## size ## _ ## opt(const int16_t *src, uint8_t *dst, int dstW, \
262  const uint8_t *dither, int offset)
263 #define VSCALE_FUNCS(opt1, opt2) \
264  VSCALE_FUNC(8, opt1); \
265  VSCALE_FUNC(9, opt2); \
266  VSCALE_FUNC(10, opt2); \
267  VSCALE_FUNC(16, opt1)
268 
269 #if ARCH_X86_32
270 VSCALE_FUNCS(mmx, mmxext);
271 #endif
272 VSCALE_FUNCS(sse2, sse2);
273 VSCALE_FUNC(16, sse4);
274 VSCALE_FUNCS(avx, avx);
275 
276 #define INPUT_Y_FUNC(fmt, opt) \
277 extern void ff_ ## fmt ## ToY_ ## opt(uint8_t *dst, const uint8_t *src, \
278  int w, uint32_t *unused)
279 #define INPUT_UV_FUNC(fmt, opt) \
280 extern void ff_ ## fmt ## ToUV_ ## opt(uint8_t *dstU, uint8_t *dstV, \
281  const uint8_t *src, const uint8_t *unused1, \
282  int w, uint32_t *unused2)
283 #define INPUT_FUNC(fmt, opt) \
284  INPUT_Y_FUNC(fmt, opt); \
285  INPUT_UV_FUNC(fmt, opt)
286 #define INPUT_FUNCS(opt) \
287  INPUT_FUNC(uyvy, opt); \
288  INPUT_FUNC(yuyv, opt); \
289  INPUT_UV_FUNC(nv12, opt); \
290  INPUT_UV_FUNC(nv21, opt); \
291  INPUT_FUNC(rgba, opt); \
292  INPUT_FUNC(bgra, opt); \
293  INPUT_FUNC(argb, opt); \
294  INPUT_FUNC(abgr, opt); \
295  INPUT_FUNC(rgb24, opt); \
296  INPUT_FUNC(bgr24, opt)
297 
298 #if ARCH_X86_32
299 INPUT_FUNCS(mmx);
300 #endif
301 INPUT_FUNCS(sse2);
302 INPUT_FUNCS(ssse3);
303 INPUT_FUNCS(avx);
304 
306 {
307  int cpu_flags = av_get_cpu_flags();
308 
309 #if HAVE_INLINE_ASM
310  if (cpu_flags & AV_CPU_FLAG_MMX)
311  sws_init_swScale_MMX(c);
312 #if HAVE_MMXEXT_INLINE
313  if (cpu_flags & AV_CPU_FLAG_MMXEXT)
314  sws_init_swScale_MMXEXT(c);
315 #endif
316 #endif /* HAVE_INLINE_ASM */
317 
318 #define ASSIGN_SCALE_FUNC2(hscalefn, filtersize, opt1, opt2) do { \
319  if (c->srcBpc == 8) { \
320  hscalefn = c->dstBpc <= 10 ? ff_hscale8to15_ ## filtersize ## _ ## opt2 : \
321  ff_hscale8to19_ ## filtersize ## _ ## opt1; \
322  } else if (c->srcBpc == 9) { \
323  hscalefn = c->dstBpc <= 10 ? ff_hscale9to15_ ## filtersize ## _ ## opt2 : \
324  ff_hscale9to19_ ## filtersize ## _ ## opt1; \
325  } else if (c->srcBpc == 10) { \
326  hscalefn = c->dstBpc <= 10 ? ff_hscale10to15_ ## filtersize ## _ ## opt2 : \
327  ff_hscale10to19_ ## filtersize ## _ ## opt1; \
328  } else /* c->srcBpc == 16 */ { \
329  hscalefn = c->dstBpc <= 10 ? ff_hscale16to15_ ## filtersize ## _ ## opt2 : \
330  ff_hscale16to19_ ## filtersize ## _ ## opt1; \
331  } \
332 } while (0)
333 #define ASSIGN_MMX_SCALE_FUNC(hscalefn, filtersize, opt1, opt2) \
334  switch (filtersize) { \
335  case 4: ASSIGN_SCALE_FUNC2(hscalefn, 4, opt1, opt2); break; \
336  case 8: ASSIGN_SCALE_FUNC2(hscalefn, 8, opt1, opt2); break; \
337  default: ASSIGN_SCALE_FUNC2(hscalefn, X, opt1, opt2); break; \
338  }
339 #define ASSIGN_VSCALEX_FUNC(vscalefn, opt, do_16_case, condition_8bit) \
340 switch(c->dstBpc){ \
341  case 16: do_16_case; break; \
342  case 10: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2planeX_10_ ## opt; break; \
343  case 9: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2planeX_9_ ## opt; break; \
344  default: if (condition_8bit) vscalefn = ff_yuv2planeX_8_ ## opt; break; \
345  }
346 #define ASSIGN_VSCALE_FUNC(vscalefn, opt1, opt2, opt2chk) \
347  switch(c->dstBpc){ \
348  case 16: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2plane1_16_ ## opt1; break; \
349  case 10: if (!isBE(c->dstFormat) && opt2chk) vscalefn = ff_yuv2plane1_10_ ## opt2; break; \
350  case 9: if (!isBE(c->dstFormat) && opt2chk) vscalefn = ff_yuv2plane1_9_ ## opt2; break; \
351  default: vscalefn = ff_yuv2plane1_8_ ## opt1; break; \
352  }
353 #define case_rgb(x, X, opt) \
354  case AV_PIX_FMT_ ## X: \
355  c->lumToYV12 = ff_ ## x ## ToY_ ## opt; \
356  if (!c->chrSrcHSubSample) \
357  c->chrToYV12 = ff_ ## x ## ToUV_ ## opt; \
358  break
359 #if ARCH_X86_32
360  if (EXTERNAL_MMX(cpu_flags)) {
361  ASSIGN_MMX_SCALE_FUNC(c->hyScale, c->hLumFilterSize, mmx, mmx);
362  ASSIGN_MMX_SCALE_FUNC(c->hcScale, c->hChrFilterSize, mmx, mmx);
363  ASSIGN_VSCALE_FUNC(c->yuv2plane1, mmx, mmxext, cpu_flags & AV_CPU_FLAG_MMXEXT);
364 
365  switch (c->srcFormat) {
366  case AV_PIX_FMT_Y400A:
367  c->lumToYV12 = ff_yuyvToY_mmx;
368  if (c->alpPixBuf)
369  c->alpToYV12 = ff_uyvyToY_mmx;
370  break;
371  case AV_PIX_FMT_YUYV422:
372  c->lumToYV12 = ff_yuyvToY_mmx;
373  c->chrToYV12 = ff_yuyvToUV_mmx;
374  break;
375  case AV_PIX_FMT_UYVY422:
376  c->lumToYV12 = ff_uyvyToY_mmx;
377  c->chrToYV12 = ff_uyvyToUV_mmx;
378  break;
379  case AV_PIX_FMT_NV12:
380  c->chrToYV12 = ff_nv12ToUV_mmx;
381  break;
382  case AV_PIX_FMT_NV21:
383  c->chrToYV12 = ff_nv21ToUV_mmx;
384  break;
385  case_rgb(rgb24, RGB24, mmx);
386  case_rgb(bgr24, BGR24, mmx);
387  case_rgb(bgra, BGRA, mmx);
388  case_rgb(rgba, RGBA, mmx);
389  case_rgb(abgr, ABGR, mmx);
390  case_rgb(argb, ARGB, mmx);
391  default:
392  break;
393  }
394  }
395  if (EXTERNAL_MMXEXT(cpu_flags)) {
396  ASSIGN_VSCALEX_FUNC(c->yuv2planeX, mmxext, , 1);
397  }
398 #endif /* ARCH_X86_32 */
399 #define ASSIGN_SSE_SCALE_FUNC(hscalefn, filtersize, opt1, opt2) \
400  switch (filtersize) { \
401  case 4: ASSIGN_SCALE_FUNC2(hscalefn, 4, opt1, opt2); break; \
402  case 8: ASSIGN_SCALE_FUNC2(hscalefn, 8, opt1, opt2); break; \
403  default: if (filtersize & 4) ASSIGN_SCALE_FUNC2(hscalefn, X4, opt1, opt2); \
404  else ASSIGN_SCALE_FUNC2(hscalefn, X8, opt1, opt2); \
405  break; \
406  }
407  if (EXTERNAL_SSE2(cpu_flags)) {
408  ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, sse2, sse2);
409  ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, sse2, sse2);
410  ASSIGN_VSCALEX_FUNC(c->yuv2planeX, sse2, ,
412  ASSIGN_VSCALE_FUNC(c->yuv2plane1, sse2, sse2, 1);
413 
414  switch (c->srcFormat) {
415  case AV_PIX_FMT_Y400A:
416  c->lumToYV12 = ff_yuyvToY_sse2;
417  if (c->alpPixBuf)
418  c->alpToYV12 = ff_uyvyToY_sse2;
419  break;
420  case AV_PIX_FMT_YUYV422:
421  c->lumToYV12 = ff_yuyvToY_sse2;
422  c->chrToYV12 = ff_yuyvToUV_sse2;
423  break;
424  case AV_PIX_FMT_UYVY422:
425  c->lumToYV12 = ff_uyvyToY_sse2;
426  c->chrToYV12 = ff_uyvyToUV_sse2;
427  break;
428  case AV_PIX_FMT_NV12:
429  c->chrToYV12 = ff_nv12ToUV_sse2;
430  break;
431  case AV_PIX_FMT_NV21:
432  c->chrToYV12 = ff_nv21ToUV_sse2;
433  break;
434  case_rgb(rgb24, RGB24, sse2);
435  case_rgb(bgr24, BGR24, sse2);
436  case_rgb(bgra, BGRA, sse2);
437  case_rgb(rgba, RGBA, sse2);
438  case_rgb(abgr, ABGR, sse2);
439  case_rgb(argb, ARGB, sse2);
440  default:
441  break;
442  }
443  }
444  if (EXTERNAL_SSSE3(cpu_flags)) {
445  ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, ssse3, ssse3);
446  ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, ssse3, ssse3);
447  switch (c->srcFormat) {
448  case_rgb(rgb24, RGB24, ssse3);
449  case_rgb(bgr24, BGR24, ssse3);
450  default:
451  break;
452  }
453  }
454  if (EXTERNAL_SSE4(cpu_flags)) {
455  /* Xto15 don't need special sse4 functions */
456  ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, sse4, ssse3);
457  ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, sse4, ssse3);
459  if (!isBE(c->dstFormat)) c->yuv2planeX = ff_yuv2planeX_16_sse4,
461  if (c->dstBpc == 16 && !isBE(c->dstFormat))
462  c->yuv2plane1 = ff_yuv2plane1_16_sse4;
463  }
464 
465  if (EXTERNAL_AVX(cpu_flags)) {
468  ASSIGN_VSCALE_FUNC(c->yuv2plane1, avx, avx, 1);
469 
470  switch (c->srcFormat) {
471  case AV_PIX_FMT_YUYV422:
472  c->chrToYV12 = ff_yuyvToUV_avx;
473  break;
474  case AV_PIX_FMT_UYVY422:
475  c->chrToYV12 = ff_uyvyToUV_avx;
476  break;
477  case AV_PIX_FMT_NV12:
478  c->chrToYV12 = ff_nv12ToUV_avx;
479  break;
480  case AV_PIX_FMT_NV21:
481  c->chrToYV12 = ff_nv21ToUV_avx;
482  break;
483  case_rgb(rgb24, RGB24, avx);
484  case_rgb(bgr24, BGR24, avx);
485  case_rgb(bgra, BGRA, avx);
486  case_rgb(rgba, RGBA, avx);
487  case_rgb(abgr, ABGR, avx);
488  case_rgb(argb, ARGB, avx);
489  default:
490  break;
491  }
492  }
493 }
#define EXTERNAL_MMX(flags)
Definition: cpu.h:33
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
Definition: pixfmt.h:82
int16_t ** alpPixBuf
Ring buffer for scaled horizontal alpha plane lines to be fed to the vertical scaler.
const uint64_t ff_dither8[2]
int chrBufIndex
Index in ring buffer of the last scaled horizontal chroma line from source.
int chrSrcH
Height of source chroma planes.
#define VSCALE_FUNC(size, opt)
Definition: swscale.c:260
#define SCALE_FUNCS_MMX(opt)
Definition: swscale.c:225
void updateMMXDitherTables(SwsContext *c, int dstY, int lumBufIndex, int chrBufIndex, int lastInLumBuf, int lastInChrBuf)
uint64_t redDither
8bit gray, 8bit alpha
Definition: pixfmt.h:138
#define RGBA(r, g, b, a)
Definition: dvbsubdec.c:153
int dstY
Last destination vertical line output from last slice.
uint64_t blueDither
#define case_rgb(x, X, opt)
#define ARCH_X86_64
Definition: config.h:35
Macro definitions for various function/variable attributes.
#define ASSIGN_SSE_SCALE_FUNC(hscalefn, filtersize, opt1, opt2)
int srcH
Height of source luma/alpha planes.
#define VSCALE_FUNCS(opt1, opt2)
Definition: swscale.c:263
#define EXTERNAL_SSE4(flags)
Definition: cpu.h:39
int chrDstVSubSample
Binary logarithm of vertical subsampling factor between luma/alpha and chroma planes in destination i...
int vChrFilterSize
Vertical filter size for chroma pixels.
int16_t ** lumPixBuf
Ring buffer for scaled horizontal luma plane lines to be fed to the vertical scaler.
int lastInLumBuf
Last scaled horizontal luma/alpha line from source in the ring buffer.
static int flags
Definition: log.c:42
external api for the swscale stuff
enum AVPixelFormat dstFormat
Destination pixel format.
#define EXTERNAL_SSE2(flags)
Definition: cpu.h:36
#define VSCALEX_FUNCS(opt)
Definition: swscale.c:247
int32_t * vChrFilterPos
Array of vertical filter starting positions for each dst[i] for chroma planes.
int dstH
Height of destination luma/alpha planes.
const uint64_t ff_dither4[2]
int hLumFilterSize
Horizontal filter size for luma/alpha pixels.
#define CONFIG_SWSCALE_ALPHA
Definition: config.h:318
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
Definition: pixfmt.h:90
int vChrBufSize
Number of vertical chroma lines allocated in the ring buffer.
void(* alpToYV12)(uint8_t *dst, const uint8_t *src, int width, uint32_t *pal)
Unscaled conversion of alpha plane to YV12 for horizontal scaler.
int32_t alpMmxFilter[4 *MAX_FILTER_SIZE]
int hChrFilterSize
Horizontal filter size for chroma pixels.
as above, but U and V bytes are swapped
Definition: pixfmt.h:91
#define APCK_SIZE
void(* chrToYV12)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, int width, uint32_t *pal)
Unscaled conversion of chroma planes to YV12 for horizontal scaler.
yuv2planar1_fn yuv2plane1
int vLumBufSize
Number of vertical luma/alpha lines allocated in the ring buffer.
#define SCALE_FUNCS_SSE(opt)
Definition: swscale.c:230
int16_t ** chrUPixBuf
Ring buffer for scaled horizontal chroma plane lines to be fed to the vertical scaler.
int32_t
void(* hcScale)(struct SwsContext *c, int16_t *dst, int dstW, const uint8_t *src, const int16_t *filter, const int32_t *filterPos, int filterSize)
static int cpu_flags
Definition: dct-test.c:76
#define HAVE_ALIGNED_STACK
Definition: config.h:131
int32_t * vLumFilterPos
Array of vertical filter starting positions for each dst[i] for luma/alpha planes.
static av_always_inline int isBE(enum AVPixelFormat pix_fmt)
int32_t lumMmxFilter[4 *MAX_FILTER_SIZE]
NULL
Definition: eval.c:52
#define ASSIGN_MMX_SCALE_FUNC(hscalefn, filtersize, opt1, opt2)
yuv2planarX_fn yuv2planeX
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
Definition: pixfmt.h:66
#define APCK_COEF
#define EXTERNAL_SSSE3(flags)
Definition: cpu.h:38
int vLumFilterSize
Vertical filter size for luma/alpha pixels.
int16_t * vChrFilter
Array of vertical filter coefficients for chroma planes.
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition: cpu.c:25
#define INPUT_FUNCS(opt)
Definition: swscale.c:286
#define SWS_ACCURATE_RND
Definition: swscale.h:78
#define EXTERNAL_MMXEXT(flags)
Definition: cpu.h:34
int lumBufIndex
Index in ring buffer of the last scaled horizontal luma/alpha line from source.
#define VSCALEX_FUNC(size, opt)
Definition: swscale.c:243
int lastInChrBuf
Last scaled horizontal chroma line from source in the ring buffer.
enum AVPixelFormat srcFormat
Source pixel format.
int32_t chrMmxFilter[4 *MAX_FILTER_SIZE]
#define ASSIGN_VSCALEX_FUNC(vscalefn, opt, do_16_case, condition_8bit)
uint64_t greenDither
#define ASSIGN_VSCALE_FUNC(vscalefn, opt1, opt2, opt2chk)
int16_t * vLumFilter
Array of vertical filter coefficients for luma/alpha planes.
av_cold void ff_sws_init_swScale_mmx(SwsContext *c)
Definition: swscale.c:305
#define APCK_PTR2
int flags
Flags passed by the user to select scaler algorithm, optimizations, subsampling, etc...
#define EXTERNAL_AVX(flags)
Definition: cpu.h:41
void(* lumToYV12)(uint8_t *dst, const uint8_t *src, int width, uint32_t *pal)
Unscaled conversion of luma plane to YV12 for horizontal scaler.
void(* hyScale)(struct SwsContext *c, int16_t *dst, int dstW, const uint8_t *src, const int16_t *filter, const int32_t *filterPos, int filterSize)
Scale one horizontal line of input data using a filter over the input lines, to produce one (differen...
if(!(ptr_align%ac->ptr_align)&&samples_align >=aligned_len)