FFmpeg
swscale.c
Go to the documentation of this file.
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 
21 #include <inttypes.h>
22 #include "config.h"
23 #include "libswscale/swscale.h"
25 #include "libavutil/attributes.h"
26 #include "libavutil/avassert.h"
27 #include "libavutil/intreadwrite.h"
28 #include "libavutil/x86/cpu.h"
29 #include "libavutil/cpu.h"
30 #include "libavutil/mem_internal.h"
31 #include "libavutil/pixdesc.h"
32 
33 const DECLARE_ALIGNED(8, uint64_t, ff_dither4)[2] = {
34  0x0103010301030103LL,
35  0x0200020002000200LL,};
36 
37 const DECLARE_ALIGNED(8, uint64_t, ff_dither8)[2] = {
38  0x0602060206020602LL,
39  0x0004000400040004LL,};
40 
41 #if HAVE_INLINE_ASM
42 
43 DECLARE_ASM_CONST(8, uint64_t, bF8)= 0xF8F8F8F8F8F8F8F8LL;
44 DECLARE_ASM_CONST(8, uint64_t, bFC)= 0xFCFCFCFCFCFCFCFCLL;
45 
46 DECLARE_ASM_CONST(8, uint64_t, M24A) = 0x00FF0000FF0000FFLL;
47 DECLARE_ASM_CONST(8, uint64_t, M24B) = 0xFF0000FF0000FF00LL;
48 DECLARE_ASM_CONST(8, uint64_t, M24C) = 0x0000FF0000FF0000LL;
49 
50 // MMXEXT versions
51 #if HAVE_MMXEXT_INLINE
52 #undef RENAME
53 #undef COMPILE_TEMPLATE_MMXEXT
54 #define COMPILE_TEMPLATE_MMXEXT 1
55 #define RENAME(a) a ## _mmxext
56 #include "swscale_template.c"
57 #endif
58 
59 void ff_updateMMXDitherTables(SwsInternal *c, int dstY)
60 {
61  const int dstH= c->opts.dst_h;
62  const int flags= c->opts.flags;
63 
64  SwsPlane *lumPlane = &c->slice[c->numSlice-2].plane[0];
65  SwsPlane *chrUPlane = &c->slice[c->numSlice-2].plane[1];
66  SwsPlane *alpPlane = &c->slice[c->numSlice-2].plane[3];
67 
68  int hasAlpha = c->needAlpha;
69  int32_t *vLumFilterPos= c->vLumFilterPos;
70  int32_t *vChrFilterPos= c->vChrFilterPos;
71  int16_t *vLumFilter= c->vLumFilter;
72  int16_t *vChrFilter= c->vChrFilter;
73  int32_t *lumMmxFilter= c->lumMmxFilter;
74  int32_t *chrMmxFilter= c->chrMmxFilter;
75  av_unused int32_t *alpMmxFilter= c->alpMmxFilter;
76  const int vLumFilterSize= c->vLumFilterSize;
77  const int vChrFilterSize= c->vChrFilterSize;
78  const int chrDstY= dstY>>c->chrDstVSubSample;
79  const int firstLumSrcY= vLumFilterPos[dstY]; //First line needed as input
80  const int firstChrSrcY= vChrFilterPos[chrDstY]; //First line needed as input
81 
82  c->blueDither= ff_dither8[dstY&1];
83  if (c->opts.dst_format == AV_PIX_FMT_RGB555 || c->opts.dst_format == AV_PIX_FMT_BGR555)
84  c->greenDither= ff_dither8[dstY&1];
85  else
86  c->greenDither= ff_dither4[dstY&1];
87  c->redDither= ff_dither8[(dstY+1)&1];
88  if (dstY < dstH - 2) {
89  const int16_t **lumSrcPtr = (const int16_t **)(void*) lumPlane->line + firstLumSrcY - lumPlane->sliceY;
90  const int16_t **chrUSrcPtr = (const int16_t **)(void*) chrUPlane->line + firstChrSrcY - chrUPlane->sliceY;
91  const int16_t **alpSrcPtr = (CONFIG_SWSCALE_ALPHA && hasAlpha) ? (const int16_t **)(void*) alpPlane->line + firstLumSrcY - alpPlane->sliceY : NULL;
92 
93  int i;
94  if (firstLumSrcY < 0 || firstLumSrcY + vLumFilterSize > c->opts.src_h) {
95  const int16_t **tmpY = (const int16_t **) lumPlane->tmp;
96 
97  int neg = -firstLumSrcY, i, end = FFMIN(c->opts.src_h - firstLumSrcY, vLumFilterSize);
98  for (i = 0; i < neg; i++)
99  tmpY[i] = lumSrcPtr[neg];
100  for ( ; i < end; i++)
101  tmpY[i] = lumSrcPtr[i];
102  for ( ; i < vLumFilterSize; i++)
103  tmpY[i] = tmpY[i-1];
104  lumSrcPtr = tmpY;
105 
106  if (alpSrcPtr) {
107  const int16_t **tmpA = (const int16_t **) alpPlane->tmp;
108  for (i = 0; i < neg; i++)
109  tmpA[i] = alpSrcPtr[neg];
110  for ( ; i < end; i++)
111  tmpA[i] = alpSrcPtr[i];
112  for ( ; i < vLumFilterSize; i++)
113  tmpA[i] = tmpA[i - 1];
114  alpSrcPtr = tmpA;
115  }
116  }
117  if (firstChrSrcY < 0 || firstChrSrcY + vChrFilterSize > c->chrSrcH) {
118  const int16_t **tmpU = (const int16_t **) chrUPlane->tmp;
119  int neg = -firstChrSrcY, i, end = FFMIN(c->chrSrcH - firstChrSrcY, vChrFilterSize);
120  for (i = 0; i < neg; i++) {
121  tmpU[i] = chrUSrcPtr[neg];
122  }
123  for ( ; i < end; i++) {
124  tmpU[i] = chrUSrcPtr[i];
125  }
126  for ( ; i < vChrFilterSize; i++) {
127  tmpU[i] = tmpU[i - 1];
128  }
129  chrUSrcPtr = tmpU;
130  }
131 
132  if (flags & SWS_ACCURATE_RND) {
133  int s= APCK_SIZE / 8;
134  for (i=0; i<vLumFilterSize; i+=2) {
135  *(const void**)&lumMmxFilter[s*i ]= lumSrcPtr[i ];
136  *(const void**)&lumMmxFilter[s*i+APCK_PTR2/4 ]= lumSrcPtr[i+(vLumFilterSize>1)];
137  lumMmxFilter[s*i+APCK_COEF/4 ]=
138  lumMmxFilter[s*i+APCK_COEF/4+1]= vLumFilter[dstY*vLumFilterSize + i ]
139  + (vLumFilterSize>1 ? vLumFilter[dstY*vLumFilterSize + i + 1] * (1 << 16) : 0);
140  if (CONFIG_SWSCALE_ALPHA && hasAlpha) {
141  *(const void**)&alpMmxFilter[s*i ]= alpSrcPtr[i ];
142  *(const void**)&alpMmxFilter[s*i+APCK_PTR2/4 ]= alpSrcPtr[i+(vLumFilterSize>1)];
143  alpMmxFilter[s*i+APCK_COEF/4 ]=
144  alpMmxFilter[s*i+APCK_COEF/4+1]= lumMmxFilter[s*i+APCK_COEF/4 ];
145  }
146  }
147  for (i=0; i<vChrFilterSize; i+=2) {
148  *(const void**)&chrMmxFilter[s*i ]= chrUSrcPtr[i ];
149  *(const void**)&chrMmxFilter[s*i+APCK_PTR2/4 ]= chrUSrcPtr[i+(vChrFilterSize>1)];
150  chrMmxFilter[s*i+APCK_COEF/4 ]=
151  chrMmxFilter[s*i+APCK_COEF/4+1]= vChrFilter[chrDstY*vChrFilterSize + i ]
152  + (vChrFilterSize>1 ? vChrFilter[chrDstY*vChrFilterSize + i + 1] * (1 << 16) : 0);
153  }
154  } else {
155  for (i=0; i<vLumFilterSize; i++) {
156  *(const void**)&lumMmxFilter[4*i+0]= lumSrcPtr[i];
157  lumMmxFilter[4*i+2]=
158  lumMmxFilter[4*i+3]=
159  ((uint16_t)vLumFilter[dstY*vLumFilterSize + i])*0x10001U;
160  if (CONFIG_SWSCALE_ALPHA && hasAlpha) {
161  *(const void**)&alpMmxFilter[4*i+0]= alpSrcPtr[i];
162  alpMmxFilter[4*i+2]=
163  alpMmxFilter[4*i+3]= lumMmxFilter[4*i+2];
164  }
165  }
166  for (i=0; i<vChrFilterSize; i++) {
167  *(const void**)&chrMmxFilter[4*i+0]= chrUSrcPtr[i];
168  chrMmxFilter[4*i+2]=
169  chrMmxFilter[4*i+3]=
170  ((uint16_t)vChrFilter[chrDstY*vChrFilterSize + i])*0x10001U;
171  }
172  }
173  }
174 }
175 #endif /* HAVE_INLINE_ASM */
176 
177 #define YUV2YUVX_FUNC_MMX(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  if(dstW > 0) \
186  ff_yuv2yuvX_ ##opt(filter, filterSize - 1, 0, dest - offset, dstW + offset, dither, offset); \
187  return; \
188 }
189 
190 #define YUV2YUVX_FUNC(opt, step) \
191 void ff_yuv2yuvX_ ##opt(const int16_t *filter, int filterSize, int srcOffset, \
192  uint8_t *dest, int dstW, \
193  const uint8_t *dither, int offset); \
194 static void yuv2yuvX_ ##opt(const int16_t *filter, int filterSize, \
195  const int16_t **src, uint8_t *dest, int dstW, \
196  const uint8_t *dither, int offset) \
197 { \
198  int remainder = (dstW % step); \
199  int pixelsProcessed = dstW - remainder; \
200  if(((uintptr_t)dest) & 15){ \
201  yuv2yuvX_mmxext(filter, filterSize, src, dest, dstW, dither, offset); \
202  return; \
203  } \
204  if(pixelsProcessed > 0) \
205  ff_yuv2yuvX_ ##opt(filter, filterSize - 1, 0, dest - offset, pixelsProcessed + offset, dither, offset); \
206  if(remainder > 0){ \
207  ff_yuv2yuvX_mmxext(filter, filterSize - 1, pixelsProcessed, dest - offset, pixelsProcessed + remainder + offset, dither, offset); \
208  } \
209  return; \
210 }
211 
212 #if HAVE_MMXEXT_EXTERNAL
213 YUV2YUVX_FUNC_MMX(mmxext, 16)
214 #endif
215 #if HAVE_SSE3_EXTERNAL
216 YUV2YUVX_FUNC(sse3, 32)
217 #endif
218 #if HAVE_AVX2_EXTERNAL
219 YUV2YUVX_FUNC(avx2, 64)
220 #endif
221 
222 #define SCALE_FUNC(filter_n, from_bpc, to_bpc, opt) \
223 void ff_hscale ## from_bpc ## to ## to_bpc ## _ ## filter_n ## _ ## opt( \
224  SwsInternal *c, int16_t *data, \
225  int dstW, const uint8_t *src, \
226  const int16_t *filter, \
227  const int32_t *filterPos, int filterSize)
228 
229 #define SCALE_FUNCS(filter_n, opt) \
230  SCALE_FUNC(filter_n, 8, 15, opt); \
231  SCALE_FUNC(filter_n, 9, 15, opt); \
232  SCALE_FUNC(filter_n, 10, 15, opt); \
233  SCALE_FUNC(filter_n, 12, 15, opt); \
234  SCALE_FUNC(filter_n, 14, 15, opt); \
235  SCALE_FUNC(filter_n, 16, 15, opt); \
236  SCALE_FUNC(filter_n, 8, 19, opt); \
237  SCALE_FUNC(filter_n, 9, 19, opt); \
238  SCALE_FUNC(filter_n, 10, 19, opt); \
239  SCALE_FUNC(filter_n, 12, 19, opt); \
240  SCALE_FUNC(filter_n, 14, 19, opt); \
241  SCALE_FUNC(filter_n, 16, 19, opt)
242 
243 #define SCALE_FUNCS_MMX(opt) \
244  SCALE_FUNCS(4, opt); \
245  SCALE_FUNCS(8, opt); \
246  SCALE_FUNCS(X, opt)
247 
248 #define SCALE_FUNCS_SSE(opt) \
249  SCALE_FUNCS(4, opt); \
250  SCALE_FUNCS(8, opt); \
251  SCALE_FUNCS(X4, opt); \
252  SCALE_FUNCS(X8, opt)
253 
254 SCALE_FUNCS_SSE(sse2);
255 SCALE_FUNCS_SSE(ssse3);
256 SCALE_FUNCS_SSE(sse4);
257 
258 SCALE_FUNC(4, 8, 15, avx2);
259 SCALE_FUNC(X4, 8, 15, avx2);
260 
261 #define VSCALEX_FUNC(size, opt) \
262 void ff_yuv2planeX_ ## size ## _ ## opt(const int16_t *filter, int filterSize, \
263  const int16_t **src, uint8_t *dest, int dstW, \
264  const uint8_t *dither, int offset)
265 #define VSCALEX_FUNCS(opt) \
266  VSCALEX_FUNC(8, opt); \
267  VSCALEX_FUNC(9, opt); \
268  VSCALEX_FUNC(10, opt)
269 
270 VSCALEX_FUNCS(sse2);
271 VSCALEX_FUNCS(sse4);
272 VSCALEX_FUNC(16, sse4);
273 VSCALEX_FUNCS(avx);
274 
275 #define VSCALE_FUNC(size, opt) \
276 void ff_yuv2plane1_ ## size ## _ ## opt(const int16_t *src, uint8_t *dst, int dstW, \
277  const uint8_t *dither, int offset)
278 #define VSCALE_FUNCS(opt1, opt2) \
279  VSCALE_FUNC(8, opt1); \
280  VSCALE_FUNC(9, opt2); \
281  VSCALE_FUNC(10, opt2); \
282  VSCALE_FUNC(16, opt1)
283 
284 VSCALE_FUNCS(sse2, sse2);
285 VSCALE_FUNC(16, sse4);
286 VSCALE_FUNCS(avx, avx);
287 
288 #define INPUT_Y_FUNC(fmt, opt) \
289 void ff_ ## fmt ## ToY_ ## opt(uint8_t *dst, const uint8_t *src, \
290  const uint8_t *unused1, const uint8_t *unused2, \
291  int w, uint32_t *unused, void *opq)
292 #define INPUT_UV_FUNC(fmt, opt) \
293 void ff_ ## fmt ## ToUV_ ## opt(uint8_t *dstU, uint8_t *dstV, \
294  const uint8_t *unused0, \
295  const uint8_t *src1, \
296  const uint8_t *src2, \
297  int w, uint32_t *unused, void *opq)
298 #define INPUT_FUNC(fmt, opt) \
299  INPUT_Y_FUNC(fmt, opt); \
300  INPUT_UV_FUNC(fmt, opt)
301 #define INPUT_FUNCS(opt) \
302  INPUT_FUNC(uyvy, opt); \
303  INPUT_FUNC(yuyv, opt); \
304  INPUT_UV_FUNC(nv12, opt); \
305  INPUT_UV_FUNC(nv21, opt); \
306  INPUT_FUNC(rgba, opt); \
307  INPUT_FUNC(bgra, opt); \
308  INPUT_FUNC(argb, opt); \
309  INPUT_FUNC(abgr, opt); \
310  INPUT_FUNC(rgb24, opt); \
311  INPUT_FUNC(bgr24, opt)
312 
313 INPUT_FUNCS(sse2);
314 INPUT_FUNCS(ssse3);
315 INPUT_FUNCS(avx);
316 INPUT_FUNC(rgba, avx2);
317 INPUT_FUNC(bgra, avx2);
318 INPUT_FUNC(argb, avx2);
319 INPUT_FUNC(abgr, avx2);
320 INPUT_FUNC(rgb24, avx2);
321 INPUT_FUNC(bgr24, avx2);
322 
323 #if ARCH_X86_64
324 #define YUV2NV_DECL(fmt, opt) \
325 void ff_yuv2 ## fmt ## cX_ ## opt(enum AVPixelFormat format, const uint8_t *dither, \
326  const int16_t *filter, int filterSize, \
327  const int16_t **u, const int16_t **v, \
328  uint8_t *dst, int dstWidth)
329 
330 YUV2NV_DECL(nv12, avx2);
331 YUV2NV_DECL(nv21, avx2);
332 
333 #define YUV2GBRP_FN_DECL(fmt, opt) \
334 void ff_yuv2##fmt##_full_X_ ##opt(SwsInternal *c, const int16_t *lumFilter, \
335  const int16_t **lumSrcx, int lumFilterSize, \
336  const int16_t *chrFilter, const int16_t **chrUSrcx, \
337  const int16_t **chrVSrcx, int chrFilterSize, \
338  const int16_t **alpSrcx, uint8_t **dest, \
339  int dstW, int y)
340 
341 #define YUV2GBRP_DECL(opt) \
342 YUV2GBRP_FN_DECL(gbrp, opt); \
343 YUV2GBRP_FN_DECL(gbrap, opt); \
344 YUV2GBRP_FN_DECL(gbrp9le, opt); \
345 YUV2GBRP_FN_DECL(gbrp10le, opt); \
346 YUV2GBRP_FN_DECL(gbrap10le, opt); \
347 YUV2GBRP_FN_DECL(gbrp12le, opt); \
348 YUV2GBRP_FN_DECL(gbrap12le, opt); \
349 YUV2GBRP_FN_DECL(gbrp14le, opt); \
350 YUV2GBRP_FN_DECL(gbrp16le, opt); \
351 YUV2GBRP_FN_DECL(gbrap16le, opt); \
352 YUV2GBRP_FN_DECL(gbrpf32le, opt); \
353 YUV2GBRP_FN_DECL(gbrapf32le, opt); \
354 YUV2GBRP_FN_DECL(gbrp9be, opt); \
355 YUV2GBRP_FN_DECL(gbrp10be, opt); \
356 YUV2GBRP_FN_DECL(gbrap10be, opt); \
357 YUV2GBRP_FN_DECL(gbrp12be, opt); \
358 YUV2GBRP_FN_DECL(gbrap12be, opt); \
359 YUV2GBRP_FN_DECL(gbrp14be, opt); \
360 YUV2GBRP_FN_DECL(gbrp16be, opt); \
361 YUV2GBRP_FN_DECL(gbrap16be, opt); \
362 YUV2GBRP_FN_DECL(gbrpf32be, opt); \
363 YUV2GBRP_FN_DECL(gbrapf32be, opt)
364 
365 YUV2GBRP_DECL(sse2);
366 YUV2GBRP_DECL(sse4);
367 YUV2GBRP_DECL(avx2);
368 
369 #define INPUT_PLANAR_RGB_Y_FN_DECL(fmt, opt) \
370 void ff_planar_##fmt##_to_y_##opt(uint8_t *dst, \
371  const uint8_t *src[4], int w, int32_t *rgb2yuv, \
372  void *opq)
373 
374 #define INPUT_PLANAR_RGB_UV_FN_DECL(fmt, opt) \
375 void ff_planar_##fmt##_to_uv_##opt(uint8_t *dstU, uint8_t *dstV, \
376  const uint8_t *src[4], int w, int32_t *rgb2yuv, \
377  void *opq)
378 
379 #define INPUT_PLANAR_RGB_A_FN_DECL(fmt, opt) \
380 void ff_planar_##fmt##_to_a_##opt(uint8_t *dst, \
381  const uint8_t *src[4], int w, int32_t *rgb2yuv, \
382  void *opq)
383 
384 
385 #define INPUT_PLANAR_RGBXX_A_DECL(fmt, opt) \
386 INPUT_PLANAR_RGB_A_FN_DECL(fmt##le, opt); \
387 INPUT_PLANAR_RGB_A_FN_DECL(fmt##be, opt)
388 
389 #define INPUT_PLANAR_RGBXX_Y_DECL(fmt, opt) \
390 INPUT_PLANAR_RGB_Y_FN_DECL(fmt##le, opt); \
391 INPUT_PLANAR_RGB_Y_FN_DECL(fmt##be, opt)
392 
393 #define INPUT_PLANAR_RGBXX_UV_DECL(fmt, opt) \
394 INPUT_PLANAR_RGB_UV_FN_DECL(fmt##le, opt); \
395 INPUT_PLANAR_RGB_UV_FN_DECL(fmt##be, opt)
396 
397 #define INPUT_PLANAR_RGBXX_YUVA_DECL(fmt, opt) \
398 INPUT_PLANAR_RGBXX_Y_DECL(fmt, opt); \
399 INPUT_PLANAR_RGBXX_UV_DECL(fmt, opt); \
400 INPUT_PLANAR_RGBXX_A_DECL(fmt, opt)
401 
402 #define INPUT_PLANAR_RGBXX_YUV_DECL(fmt, opt) \
403 INPUT_PLANAR_RGBXX_Y_DECL(fmt, opt); \
404 INPUT_PLANAR_RGBXX_UV_DECL(fmt, opt)
405 
406 #define INPUT_PLANAR_RGBXX_UVA_DECL(fmt, opt) \
407 INPUT_PLANAR_RGBXX_UV_DECL(fmt, opt); \
408 INPUT_PLANAR_RGBXX_A_DECL(fmt, opt)
409 
410 #define INPUT_PLANAR_RGB_A_ALL_DECL(opt) \
411 INPUT_PLANAR_RGB_A_FN_DECL(rgb, opt); \
412 INPUT_PLANAR_RGBXX_A_DECL(rgb10, opt); \
413 INPUT_PLANAR_RGBXX_A_DECL(rgb12, opt); \
414 INPUT_PLANAR_RGBXX_A_DECL(rgb16, opt); \
415 INPUT_PLANAR_RGBXX_A_DECL(rgbf32, opt)
416 
417 #define INPUT_PLANAR_RGB_Y_ALL_DECL(opt) \
418 INPUT_PLANAR_RGB_Y_FN_DECL(rgb, opt); \
419 INPUT_PLANAR_RGBXX_Y_DECL(rgb9, opt); \
420 INPUT_PLANAR_RGBXX_Y_DECL(rgb10, opt); \
421 INPUT_PLANAR_RGBXX_Y_DECL(rgb12, opt); \
422 INPUT_PLANAR_RGBXX_Y_DECL(rgb14, opt); \
423 INPUT_PLANAR_RGBXX_Y_DECL(rgb16, opt); \
424 INPUT_PLANAR_RGBXX_Y_DECL(rgbf32, opt)
425 
426 #define INPUT_PLANAR_RGB_UV_ALL_DECL(opt) \
427 INPUT_PLANAR_RGB_UV_FN_DECL(rgb, opt); \
428 INPUT_PLANAR_RGBXX_UV_DECL(rgb9, opt); \
429 INPUT_PLANAR_RGBXX_UV_DECL(rgb10, opt); \
430 INPUT_PLANAR_RGBXX_UV_DECL(rgb12, opt); \
431 INPUT_PLANAR_RGBXX_UV_DECL(rgb14, opt); \
432 INPUT_PLANAR_RGBXX_UV_DECL(rgb16, opt); \
433 INPUT_PLANAR_RGBXX_UV_DECL(rgbf32, opt)
434 
435 INPUT_PLANAR_RGBXX_Y_DECL(rgbf32, sse2);
436 INPUT_PLANAR_RGB_UV_ALL_DECL(sse2);
437 INPUT_PLANAR_RGB_A_ALL_DECL(sse2);
438 
439 INPUT_PLANAR_RGB_Y_ALL_DECL(sse4);
440 INPUT_PLANAR_RGB_UV_ALL_DECL(sse4);
441 INPUT_PLANAR_RGBXX_A_DECL(rgbf32, sse4);
442 
443 INPUT_PLANAR_RGB_Y_ALL_DECL(avx2);
444 INPUT_PLANAR_RGB_UV_ALL_DECL(avx2);
445 INPUT_PLANAR_RGB_A_ALL_DECL(avx2);
446 #endif
447 
448 #define RANGE_CONVERT_FUNCS(opt, bpc) do { \
449  if (c->opts.src_range) { \
450  c->lumConvertRange = ff_lumRangeFromJpeg##bpc##_##opt; \
451  c->chrConvertRange = ff_chrRangeFromJpeg##bpc##_##opt; \
452  } else { \
453  c->lumConvertRange = ff_lumRangeToJpeg##bpc##_##opt; \
454  c->chrConvertRange = ff_chrRangeToJpeg##bpc##_##opt; \
455  } \
456 } while (0)
457 
458 #define RANGE_CONVERT_FUNCS_DECL(opt, bpc) \
459 void ff_lumRangeFromJpeg##bpc##_##opt(int16_t *dst, int width, \
460  uint32_t coeff, int64_t offset); \
461 void ff_chrRangeFromJpeg##bpc##_##opt(int16_t *dstU, int16_t *dstV, int width, \
462  uint32_t coeff, int64_t offset); \
463 void ff_lumRangeToJpeg##bpc##_##opt(int16_t *dst, int width, \
464  uint32_t coeff, int64_t offset); \
465 void ff_chrRangeToJpeg##bpc##_##opt(int16_t *dstU, int16_t *dstV, int width, \
466  uint32_t coeff, int64_t offset); \
467 
469 RANGE_CONVERT_FUNCS_DECL(sse4, 16)
471 RANGE_CONVERT_FUNCS_DECL(avx2, 16)
472 
474 {
475  int cpu_flags = av_get_cpu_flags();
477  if (c->dstBpc <= 14) {
478  RANGE_CONVERT_FUNCS(avx2, 8);
479  } else {
480  RANGE_CONVERT_FUNCS(avx2, 16);
481  }
482  } else if (EXTERNAL_SSE2(cpu_flags) && c->dstBpc <= 14) {
483  RANGE_CONVERT_FUNCS(sse2, 8);
484  } else if (EXTERNAL_SSE4(cpu_flags) && c->dstBpc > 14) {
485  RANGE_CONVERT_FUNCS(sse4, 16);
486  }
487 }
488 
490 {
491  int cpu_flags = av_get_cpu_flags();
492 
493 #if HAVE_MMXEXT_INLINE
495  sws_init_swscale_mmxext(c);
496 #endif
497  if(c->use_mmx_vfilter && !(c->opts.flags & SWS_ACCURATE_RND)) {
498 #if HAVE_MMXEXT_EXTERNAL
500  c->yuv2planeX = yuv2yuvX_mmxext;
501 #endif
502 #if HAVE_SSE3_EXTERNAL
504  c->yuv2planeX = yuv2yuvX_sse3;
505 #endif
506 #if HAVE_AVX2_EXTERNAL
508  c->yuv2planeX = yuv2yuvX_avx2;
509 #endif
510  }
511 
512 #define ASSIGN_SCALE_FUNC2(hscalefn, filtersize, opt1, opt2) do { \
513  if (c->srcBpc == 8) { \
514  hscalefn = c->dstBpc <= 14 ? ff_hscale8to15_ ## filtersize ## _ ## opt2 : \
515  ff_hscale8to19_ ## filtersize ## _ ## opt1; \
516  } else if (c->srcBpc == 9) { \
517  hscalefn = c->dstBpc <= 14 ? ff_hscale9to15_ ## filtersize ## _ ## opt2 : \
518  ff_hscale9to19_ ## filtersize ## _ ## opt1; \
519  } else if (c->srcBpc == 10) { \
520  hscalefn = c->dstBpc <= 14 ? ff_hscale10to15_ ## filtersize ## _ ## opt2 : \
521  ff_hscale10to19_ ## filtersize ## _ ## opt1; \
522  } else if (c->srcBpc == 12) { \
523  hscalefn = c->dstBpc <= 14 ? ff_hscale12to15_ ## filtersize ## _ ## opt2 : \
524  ff_hscale12to19_ ## filtersize ## _ ## opt1; \
525  } else if (c->srcBpc == 14 || ((c->opts.src_format==AV_PIX_FMT_PAL8||isAnyRGB(c->opts.src_format)) && av_pix_fmt_desc_get(c->opts.src_format)->comp[0].depth<16)) { \
526  hscalefn = c->dstBpc <= 14 ? ff_hscale14to15_ ## filtersize ## _ ## opt2 : \
527  ff_hscale14to19_ ## filtersize ## _ ## opt1; \
528  } else { /* c->srcBpc == 16 */ \
529  av_assert0(c->srcBpc == 16);\
530  hscalefn = c->dstBpc <= 14 ? ff_hscale16to15_ ## filtersize ## _ ## opt2 : \
531  ff_hscale16to19_ ## filtersize ## _ ## opt1; \
532  } \
533 } while (0)
534 #define ASSIGN_VSCALEX_FUNC(vscalefn, opt, do_16_case) \
535 switch(c->dstBpc){ \
536  case 16: do_16_case; break; \
537  case 10: if (!isBE(c->opts.dst_format) && !isSemiPlanarYUV(c->opts.dst_format) && !isDataInHighBits(c->opts.dst_format)) vscalefn = ff_yuv2planeX_10_ ## opt; break; \
538  case 9: if (!isBE(c->opts.dst_format)) vscalefn = ff_yuv2planeX_9_ ## opt; break; \
539  case 8: if (!c->use_mmx_vfilter) vscalefn = ff_yuv2planeX_8_ ## opt; break; \
540  }
541 #define ASSIGN_VSCALE_FUNC(vscalefn, opt) \
542  switch(c->dstBpc){ \
543  case 16: if (!isBE(c->opts.dst_format)) vscalefn = ff_yuv2plane1_16_ ## opt; break; \
544  case 10: if (!isBE(c->opts.dst_format) && !isSemiPlanarYUV(c->opts.dst_format) && !isDataInHighBits(c->opts.dst_format)) vscalefn = ff_yuv2plane1_10_ ## opt; break; \
545  case 9: if (!isBE(c->opts.dst_format)) vscalefn = ff_yuv2plane1_9_ ## opt; break; \
546  case 8: vscalefn = ff_yuv2plane1_8_ ## opt; break; \
547  default: av_assert0(c->dstBpc>8); \
548  }
549 #define case_rgb(x, X, opt) \
550  case AV_PIX_FMT_ ## X: \
551  c->lumToYV12 = ff_ ## x ## ToY_ ## opt; \
552  if (!c->chrSrcHSubSample) \
553  c->chrToYV12 = ff_ ## x ## ToUV_ ## opt; \
554  break
555 #define ASSIGN_SSE_SCALE_FUNC(hscalefn, filtersize, opt1, opt2) \
556  switch (filtersize) { \
557  case 4: ASSIGN_SCALE_FUNC2(hscalefn, 4, opt1, opt2); break; \
558  case 8: ASSIGN_SCALE_FUNC2(hscalefn, 8, opt1, opt2); break; \
559  default: if (filtersize & 4) ASSIGN_SCALE_FUNC2(hscalefn, X4, opt1, opt2); \
560  else ASSIGN_SCALE_FUNC2(hscalefn, X8, opt1, opt2); \
561  break; \
562  }
563  if (EXTERNAL_SSE2(cpu_flags)) {
564  ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, sse2, sse2);
565  ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, sse2, sse2);
566  ASSIGN_VSCALEX_FUNC(c->yuv2planeX, sse2, );
567  if (!(c->opts.flags & SWS_ACCURATE_RND))
568  ASSIGN_VSCALE_FUNC(c->yuv2plane1, sse2);
569 
570  switch (c->opts.src_format) {
571  case AV_PIX_FMT_YA8:
572  c->lumToYV12 = ff_yuyvToY_sse2;
573  if (c->needAlpha)
574  c->alpToYV12 = ff_uyvyToY_sse2;
575  break;
576  case AV_PIX_FMT_YUYV422:
577  c->lumToYV12 = ff_yuyvToY_sse2;
578  c->chrToYV12 = ff_yuyvToUV_sse2;
579  break;
580  case AV_PIX_FMT_UYVY422:
581  c->lumToYV12 = ff_uyvyToY_sse2;
582  c->chrToYV12 = ff_uyvyToUV_sse2;
583  break;
584  case AV_PIX_FMT_NV12:
585  c->chrToYV12 = ff_nv12ToUV_sse2;
586  break;
587  case AV_PIX_FMT_NV21:
588  c->chrToYV12 = ff_nv21ToUV_sse2;
589  break;
590  case_rgb(rgb24, RGB24, sse2);
591  case_rgb(bgr24, BGR24, sse2);
592  case_rgb(bgra, BGRA, sse2);
593  case_rgb(rgba, RGBA, sse2);
594  case_rgb(abgr, ABGR, sse2);
595  case_rgb(argb, ARGB, sse2);
596  default:
597  break;
598  }
599  }
600  if (EXTERNAL_SSSE3(cpu_flags)) {
601  ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, ssse3, ssse3);
602  ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, ssse3, ssse3);
603  switch (c->opts.src_format) {
604  case_rgb(rgb24, RGB24, ssse3);
605  case_rgb(bgr24, BGR24, ssse3);
606  default:
607  break;
608  }
609  }
610  if (EXTERNAL_SSE4(cpu_flags)) {
611  /* Xto15 don't need special sse4 functions */
612  ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, sse4, ssse3);
613  ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, sse4, ssse3);
614  ASSIGN_VSCALEX_FUNC(c->yuv2planeX, sse4,
615  if (!isBE(c->opts.dst_format)) c->yuv2planeX = ff_yuv2planeX_16_sse4);
616  if (c->dstBpc == 16 && !isBE(c->opts.dst_format) && !(c->opts.flags & SWS_ACCURATE_RND))
617  c->yuv2plane1 = ff_yuv2plane1_16_sse4;
618  }
619 
620  if (EXTERNAL_AVX(cpu_flags)) {
621  ASSIGN_VSCALEX_FUNC(c->yuv2planeX, avx, );
622  if (!(c->opts.flags & SWS_ACCURATE_RND))
623  ASSIGN_VSCALE_FUNC(c->yuv2plane1, avx);
624 
625  switch (c->opts.src_format) {
626  case AV_PIX_FMT_YUYV422:
627  c->chrToYV12 = ff_yuyvToUV_avx;
628  break;
629  case AV_PIX_FMT_UYVY422:
630  c->chrToYV12 = ff_uyvyToUV_avx;
631  break;
632  case AV_PIX_FMT_NV12:
633  c->chrToYV12 = ff_nv12ToUV_avx;
634  break;
635  case AV_PIX_FMT_NV21:
636  c->chrToYV12 = ff_nv21ToUV_avx;
637  break;
638  case_rgb(rgb24, RGB24, avx);
639  case_rgb(bgr24, BGR24, avx);
640  case_rgb(bgra, BGRA, avx);
641  case_rgb(rgba, RGBA, avx);
642  case_rgb(abgr, ABGR, avx);
643  case_rgb(argb, ARGB, avx);
644  default:
645  break;
646  }
647  }
648 
649 #if ARCH_X86_64
650 #define ASSIGN_AVX2_SCALE_FUNC(hscalefn, filtersize) \
651  switch (filtersize) { \
652  case 4: hscalefn = ff_hscale8to15_4_avx2; break; \
653  default: hscalefn = ff_hscale8to15_X4_avx2; break; \
654  break; \
655  }
656 
658  if ((c->srcBpc == 8) && (c->dstBpc <= 14)) {
659  ASSIGN_AVX2_SCALE_FUNC(c->hcScale, c->hChrFilterSize);
660  ASSIGN_AVX2_SCALE_FUNC(c->hyScale, c->hLumFilterSize);
661  }
662  }
663 
665  if (ARCH_X86_64)
666  switch (c->opts.src_format) {
667  case_rgb(rgb24, RGB24, avx2);
668  case_rgb(bgr24, BGR24, avx2);
669  case_rgb(bgra, BGRA, avx2);
670  case_rgb(rgba, RGBA, avx2);
671  case_rgb(abgr, ABGR, avx2);
672  case_rgb(argb, ARGB, avx2);
673  }
674  if (!(c->opts.flags & SWS_ACCURATE_RND)) // FIXME
675  switch (c->opts.dst_format) {
676  case AV_PIX_FMT_NV12:
677  case AV_PIX_FMT_NV24:
678  c->yuv2nv12cX = ff_yuv2nv12cX_avx2;
679  break;
680  case AV_PIX_FMT_NV21:
681  case AV_PIX_FMT_NV42:
682  c->yuv2nv12cX = ff_yuv2nv21cX_avx2;
683  break;
684  default:
685  break;
686  }
687  }
688 
689 
690 #define INPUT_PLANER_RGB_A_FUNC_CASE_NOBREAK(fmt, name, opt) \
691  case fmt: \
692  c->readAlpPlanar = ff_planar_##name##_to_a_##opt;
693 
694 #define INPUT_PLANER_RGBA_YUV_FUNC_CASE(rgb_fmt, rgba_fmt, name, opt) \
695  case rgba_fmt: \
696  case rgb_fmt: \
697  c->readLumPlanar = ff_planar_##name##_to_y_##opt; \
698  c->readChrPlanar = ff_planar_##name##_to_uv_##opt; \
699  break;
700 
701 #define INPUT_PLANER_RGB_YUV_FUNC_CASE(fmt, name, opt) \
702  case fmt: \
703  c->readLumPlanar = ff_planar_##name##_to_y_##opt; \
704  c->readChrPlanar = ff_planar_##name##_to_uv_##opt; \
705  break;
706 
707 #define INPUT_PLANER_RGB_UV_FUNC_CASE(fmt, name, opt) \
708  case fmt: \
709  c->readChrPlanar = ff_planar_##name##_to_uv_##opt; \
710  break;
711 
712 #define INPUT_PLANER_RGBAXX_YUVA_FUNC_CASE(rgb_fmt, rgba_fmt, name, opt) \
713  INPUT_PLANER_RGB_A_FUNC_CASE_NOBREAK(rgba_fmt##LE, name##le, opt) \
714  INPUT_PLANER_RGB_YUV_FUNC_CASE(rgb_fmt##LE, name##le, opt) \
715  INPUT_PLANER_RGB_A_FUNC_CASE_NOBREAK(rgba_fmt##BE, name##be, opt) \
716  INPUT_PLANER_RGB_YUV_FUNC_CASE(rgb_fmt##BE, name##be, opt)
717 
718 #define INPUT_PLANER_RGBAXX_UVA_FUNC_CASE(rgb_fmt, rgba_fmt, name, opt) \
719  INPUT_PLANER_RGB_A_FUNC_CASE_NOBREAK(rgba_fmt##LE, name##le, opt) \
720  INPUT_PLANER_RGB_UV_FUNC_CASE(rgb_fmt##LE, name##le, opt) \
721  INPUT_PLANER_RGB_A_FUNC_CASE_NOBREAK(rgba_fmt##BE, name##be, opt) \
722  INPUT_PLANER_RGB_UV_FUNC_CASE(rgb_fmt##BE, name##be, opt)
723 
724 #define INPUT_PLANER_RGBAXX_YUV_FUNC_CASE(rgb_fmt, rgba_fmt, name, opt) \
725  INPUT_PLANER_RGBA_YUV_FUNC_CASE(rgb_fmt##LE, rgba_fmt##LE, name##le, opt) \
726  INPUT_PLANER_RGBA_YUV_FUNC_CASE(rgb_fmt##BE, rgba_fmt##BE, name##be, opt)
727 
728 #define INPUT_PLANER_RGBXX_YUV_FUNC_CASE(rgb_fmt, name, opt) \
729  INPUT_PLANER_RGB_YUV_FUNC_CASE(rgb_fmt##LE, name##le, opt) \
730  INPUT_PLANER_RGB_YUV_FUNC_CASE(rgb_fmt##BE, name##be, opt)
731 
732 #define INPUT_PLANER_RGBXX_UV_FUNC_CASE(rgb_fmt, name, opt) \
733  INPUT_PLANER_RGB_UV_FUNC_CASE(rgb_fmt##LE, name##le, opt) \
734  INPUT_PLANER_RGB_UV_FUNC_CASE(rgb_fmt##BE, name##be, opt)
735 
736 #define INPUT_PLANER_RGB_YUVA_ALL_CASES(opt) \
737  INPUT_PLANER_RGB_A_FUNC_CASE_NOBREAK(AV_PIX_FMT_GBRAP, rgb, opt) \
738  INPUT_PLANER_RGB_YUV_FUNC_CASE( AV_PIX_FMT_GBRP, rgb, opt) \
739  INPUT_PLANER_RGBXX_YUV_FUNC_CASE( AV_PIX_FMT_GBRP9, rgb9, opt) \
740  INPUT_PLANER_RGBAXX_YUVA_FUNC_CASE(AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRAP10, rgb10, opt) \
741  INPUT_PLANER_RGBAXX_YUVA_FUNC_CASE(AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRAP12, rgb12, opt) \
742  INPUT_PLANER_RGBXX_YUV_FUNC_CASE( AV_PIX_FMT_GBRP14, rgb14, opt) \
743  INPUT_PLANER_RGBAXX_YUVA_FUNC_CASE(AV_PIX_FMT_GBRP16, AV_PIX_FMT_GBRAP16, rgb16, opt) \
744  INPUT_PLANER_RGBAXX_YUVA_FUNC_CASE(AV_PIX_FMT_GBRPF32, AV_PIX_FMT_GBRAPF32, rgbf32, opt)
745 
746 
747  if (EXTERNAL_SSE2(cpu_flags)) {
748  switch (c->opts.src_format) {
749  INPUT_PLANER_RGB_A_FUNC_CASE_NOBREAK(AV_PIX_FMT_GBRAP, rgb, sse2);
750  INPUT_PLANER_RGB_UV_FUNC_CASE( AV_PIX_FMT_GBRP, rgb, sse2);
751  INPUT_PLANER_RGBXX_UV_FUNC_CASE( AV_PIX_FMT_GBRP9, rgb9, sse2);
752  INPUT_PLANER_RGBAXX_UVA_FUNC_CASE( AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRAP10, rgb10, sse2);
753  INPUT_PLANER_RGBAXX_UVA_FUNC_CASE( AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRAP12, rgb12, sse2);
754  INPUT_PLANER_RGBXX_UV_FUNC_CASE( AV_PIX_FMT_GBRP14, rgb14, sse2);
755  INPUT_PLANER_RGBAXX_UVA_FUNC_CASE( AV_PIX_FMT_GBRP16, AV_PIX_FMT_GBRAP16, rgb16, sse2);
756  INPUT_PLANER_RGBAXX_YUVA_FUNC_CASE(AV_PIX_FMT_GBRPF32, AV_PIX_FMT_GBRAPF32, rgbf32, sse2);
757  default:
758  break;
759  }
760  }
761 
762  if (EXTERNAL_SSE4(cpu_flags)) {
763  switch (c->opts.src_format) {
764  case AV_PIX_FMT_GBRAP:
765  INPUT_PLANER_RGB_YUV_FUNC_CASE( AV_PIX_FMT_GBRP, rgb, sse4);
766  INPUT_PLANER_RGBXX_YUV_FUNC_CASE( AV_PIX_FMT_GBRP9, rgb9, sse4);
767  INPUT_PLANER_RGBAXX_YUV_FUNC_CASE( AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRAP10, rgb10, sse4);
768  INPUT_PLANER_RGBAXX_YUV_FUNC_CASE( AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRAP12, rgb12, sse4);
769  INPUT_PLANER_RGBXX_YUV_FUNC_CASE( AV_PIX_FMT_GBRP14, rgb14, sse4);
770  INPUT_PLANER_RGBAXX_YUV_FUNC_CASE( AV_PIX_FMT_GBRP16, AV_PIX_FMT_GBRAP16, rgb16, sse4);
771  INPUT_PLANER_RGBAXX_YUVA_FUNC_CASE(AV_PIX_FMT_GBRPF32, AV_PIX_FMT_GBRAPF32, rgbf32, sse4);
772  default:
773  break;
774  }
775  }
776 
778  switch (c->opts.src_format) {
779  INPUT_PLANER_RGB_YUVA_ALL_CASES(avx2)
780  default:
781  break;
782  }
783  }
784 
785  if(c->opts.flags & SWS_FULL_CHR_H_INT) {
786 
787 #define YUV2ANYX_FUNC_CASE(fmt, name, opt) \
788  case fmt: \
789  c->yuv2anyX = ff_yuv2##name##_full_X_##opt; \
790  break;
791 
792 #define YUV2ANYX_GBRAP_CASES(opt) \
793  YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRP, gbrp, opt) \
794  YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRAP, gbrap, opt) \
795  YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRP9LE, gbrp9le, opt) \
796  YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRP10LE, gbrp10le, opt) \
797  YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRAP10LE, gbrap10le, opt) \
798  YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRP12LE, gbrp12le, opt) \
799  YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRAP12LE, gbrap12le, opt) \
800  YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRP14LE, gbrp14le, opt) \
801  YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRP16LE, gbrp16le, opt) \
802  YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRAP16LE, gbrap16le, opt) \
803  YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRPF32LE, gbrpf32le, opt) \
804  YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRAPF32LE, gbrapf32le, opt) \
805  YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRP9BE, gbrp9be, opt) \
806  YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRP10BE, gbrp10be, opt) \
807  YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRAP10BE, gbrap10be, opt) \
808  YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRP12BE, gbrp12be, opt) \
809  YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRAP12BE, gbrap12be, opt) \
810  YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRP14BE, gbrp14be, opt) \
811  YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRP16BE, gbrp16be, opt) \
812  YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRAP16BE, gbrap16be, opt) \
813  YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRPF32BE, gbrpf32be, opt) \
814  YUV2ANYX_FUNC_CASE(AV_PIX_FMT_GBRAPF32BE, gbrapf32be, opt)
815 
816  if (EXTERNAL_SSE2(cpu_flags)) {
817  switch (c->opts.dst_format) {
818  YUV2ANYX_GBRAP_CASES(sse2)
819  default:
820  break;
821  }
822  }
823 
824  if (EXTERNAL_SSE4(cpu_flags)) {
825  switch (c->opts.dst_format) {
826  YUV2ANYX_GBRAP_CASES(sse4)
827  default:
828  break;
829  }
830  }
831 
833  switch (c->opts.dst_format) {
834  YUV2ANYX_GBRAP_CASES(avx2)
835  default:
836  break;
837  }
838  }
839  }
840 
841 #endif
842 }
flags
const SwsFlags flags[]
Definition: swscale.c:72
AV_PIX_FMT_GBRAP16
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:565
APCK_PTR2
#define APCK_PTR2
Definition: swscale_internal.h:70
cpu.h
SwsPlane::line
uint8_t ** line
line buffer
Definition: swscale_internal.h:1110
AV_PIX_FMT_YA8
@ AV_PIX_FMT_YA8
8 bits gray, 8 bits alpha
Definition: pixfmt.h:140
mem_internal.h
av_unused
#define av_unused
Definition: attributes.h:156
EXTERNAL_AVX2_FAST
#define EXTERNAL_AVX2_FAST(flags)
Definition: cpu.h:73
pixdesc.h
av_get_cpu_flags
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition: cpu.c:109
cpu_flags
static atomic_int cpu_flags
Definition: cpu.c:56
INPUT_FUNC
#define INPUT_FUNC(fmt, opt)
Definition: swscale.c:298
INPUT_FUNCS
#define INPUT_FUNCS(opt)
Definition: swscale.c:301
rgb
Definition: rpzaenc.c:60
RANGE_CONVERT_FUNCS_DECL
#define RANGE_CONVERT_FUNCS_DECL(opt, bpc)
Definition: swscale.c:458
AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:560
RANGE_CONVERT_FUNCS
#define RANGE_CONVERT_FUNCS(opt, bpc)
Definition: swscale.c:448
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:212
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:558
AV_CPU_FLAG_SLOW_GATHER
#define AV_CPU_FLAG_SLOW_GATHER
CPU has slow gathers.
Definition: cpu.h:62
avassert.h
av_cold
#define av_cold
Definition: attributes.h:111
AV_PIX_FMT_GBRAP10
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:562
intreadwrite.h
s
#define s(width, name)
Definition: cbs_vp9.c:198
AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:563
APCK_COEF
#define APCK_COEF
Definition: swscale_internal.h:71
SwsPlane::tmp
uint8_t ** tmp
Tmp line buffer used by mmx code.
Definition: swscale_internal.h:1111
SCALE_FUNC
#define SCALE_FUNC(filter_n, from_bpc, to_bpc, opt)
Definition: swscale.c:222
VSCALE_FUNCS
#define VSCALE_FUNCS(opt1, opt2)
Definition: swscale.c:278
ASSIGN_VSCALEX_FUNC
#define ASSIGN_VSCALEX_FUNC(vscalefn, opt, do_16_case)
if
if(ret)
Definition: filter_design.txt:179
VSCALEX_FUNC
#define VSCALEX_FUNC(size, opt)
Definition: swscale.c:261
ff_sws_init_range_convert_x86
av_cold void ff_sws_init_range_convert_x86(SwsInternal *c)
Definition: swscale.c:473
AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:561
NULL
#define NULL
Definition: coverity.c:32
ASSIGN_SSE_SCALE_FUNC
#define ASSIGN_SSE_SCALE_FUNC(hscalefn, filtersize, opt1, opt2)
AV_PIX_FMT_YUYV422
@ AV_PIX_FMT_YUYV422
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
Definition: pixfmt.h:74
EXTERNAL_SSE3
#define EXTERNAL_SSE3(flags)
Definition: cpu.h:56
SwsPlane
Slice plane.
Definition: swscale_internal.h:1105
ASSIGN_VSCALE_FUNC
#define ASSIGN_VSCALE_FUNC(vscalefn, opt)
AV_PIX_FMT_GBRP9
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:557
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
isBE
static av_always_inline int isBE(enum AVPixelFormat pix_fmt)
Definition: swscale_internal.h:766
DECLARE_ALIGNED
#define DECLARE_ALIGNED(n, t, v)
Definition: mem_internal.h:104
cpu.h
i
#define i(width, name, range_min, range_max)
Definition: cbs_h264.c:63
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:424
AV_PIX_FMT_GBRPF32
#define AV_PIX_FMT_GBRPF32
Definition: pixfmt.h:578
AV_PIX_FMT_BGR555
#define AV_PIX_FMT_BGR555
Definition: pixfmt.h:532
attributes.h
EXTERNAL_SSE2
#define EXTERNAL_SSE2(flags)
Definition: cpu.h:53
ff_sws_init_swscale_x86
av_cold void ff_sws_init_swscale_x86(SwsInternal *c)
Definition: swscale.c:489
AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:559
DECLARE_ASM_CONST
DECLARE_ASM_CONST(16, double, pd_1)[2]
AV_PIX_FMT_NV24
@ AV_PIX_FMT_NV24
planar YUV 4:4:4, 24bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
Definition: pixfmt.h:371
AV_PIX_FMT_RGB555
#define AV_PIX_FMT_RGB555
Definition: pixfmt.h:527
swscale_internal.h
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
AV_PIX_FMT_NV21
@ AV_PIX_FMT_NV21
as above, but U and V bytes are swapped
Definition: pixfmt.h:97
ff_updateMMXDitherTables
void ff_updateMMXDitherTables(SwsInternal *c, int dstY)
AV_PIX_FMT_NV42
@ AV_PIX_FMT_NV42
as above, but U and V bytes are swapped
Definition: pixfmt.h:372
swscale_template.c
ff_dither8
const uint64_t ff_dither8[2]
Definition: swscale.c:37
SwsInternal
Definition: swscale_internal.h:335
AV_PIX_FMT_NV12
@ AV_PIX_FMT_NV12
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
Definition: pixfmt.h:96
EXTERNAL_AVX
#define EXTERNAL_AVX(flags)
Definition: cpu.h:64
SWS_FULL_CHR_H_INT
@ SWS_FULL_CHR_H_INT
Perform full chroma upsampling when upscaling to RGB.
Definition: swscale.h:133
AV_PIX_FMT_UYVY422
@ AV_PIX_FMT_UYVY422
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
Definition: pixfmt.h:88
EXTERNAL_SSE4
#define EXTERNAL_SSE4(flags)
Definition: cpu.h:62
U
#define U(x)
Definition: vpx_arith.h:37
AV_PIX_FMT_GBRAPF32
#define AV_PIX_FMT_GBRAPF32
Definition: pixfmt.h:579
YUV2YUVX_FUNC_MMX
#define YUV2YUVX_FUNC_MMX(opt, step)
Definition: swscale.c:177
INLINE_MMXEXT
#define INLINE_MMXEXT(flags)
Definition: cpu.h:81
AV_PIX_FMT_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:165
SwsPlane::sliceY
int sliceY
index of first line
Definition: swscale_internal.h:1108
VSCALE_FUNC
#define VSCALE_FUNC(size, opt)
Definition: swscale.c:275
case_rgb
#define case_rgb(x, X, opt)
int32_t
int32_t
Definition: audioconvert.c:56
RGBA
#define RGBA(r, g, b, a)
Definition: dvbsubdec.c:42
YUV2YUVX_FUNC
#define YUV2YUVX_FUNC(opt, step)
Definition: swscale.c:190
SWS_ACCURATE_RND
@ SWS_ACCURATE_RND
Force bit-exact output.
Definition: swscale.h:156
EXTERNAL_SSSE3
#define EXTERNAL_SSSE3(flags)
Definition: cpu.h:59
SCALE_FUNCS_SSE
#define SCALE_FUNCS_SSE(opt)
Definition: swscale.c:248
APCK_SIZE
#define APCK_SIZE
Definition: swscale_internal.h:72
VSCALEX_FUNCS
#define VSCALEX_FUNCS(opt)
Definition: swscale.c:265
EXTERNAL_MMXEXT
#define EXTERNAL_MMXEXT(flags)
Definition: cpu.h:51
swscale.h
ff_dither4
const uint64_t ff_dither4[2]
Definition: swscale.c:33