FFmpeg  4.4.9
swscale_template.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 <stdint.h>
22 
23 #include "libavutil/x86/asm.h"
25 
26 #undef REAL_MOVNTQ
27 #undef MOVNTQ
28 #undef MOVNTQ2
29 #undef PREFETCH
30 
31 
32 #if COMPILE_TEMPLATE_MMXEXT
33 #define REAL_MOVNTQ(a,b) "movntq " #a ", " #b " \n\t"
34 #define MOVNTQ2 "movntq "
35 #else
36 #define REAL_MOVNTQ(a,b) "movq " #a ", " #b " \n\t"
37 #define MOVNTQ2 "movq "
38 #endif
39 #define MOVNTQ(a,b) REAL_MOVNTQ(a,b)
40 
41 #define REAL_NEXT_PIXEL_BLOCK(dstw, index, step_back) \
42  "add $16, "#index" \n\t"\
43  "cmp "dstw", "#index" \n\t"\
44  "lea -8("#index"), "#index" \n\t"\
45  " jbe 1b \n\t"\
46  "cmp "dstw", "#index" \n\t"\
47  " jae 3f \n\t"\
48  "add $8, "#index" \n\t"\
49  "sub "dstw", "#index" \n\t"\
50  step_back \
51  "mov "dstw", "#index" \n\t"\
52  "sub $8, "#index" \n\t"\
53  " jmp 1b \n\t"\
54  "3: \n\t"
55 #define NEXT_PIXEL_BLOCK(dstw, index, step_back) REAL_NEXT_PIXEL_BLOCK(dstw, index, step_back)
56 
57 #define YSCALEYUV2PACKEDX_UV \
58  __asm__ volatile(\
59  "xor %%"FF_REG_a", %%"FF_REG_a" \n\t"\
60  ".p2align 4 \n\t"\
61  "nop \n\t"\
62  "1: \n\t"\
63  "lea "CHR_MMX_FILTER_OFFSET"(%0), %%"FF_REG_d" \n\t"\
64  "mov (%%"FF_REG_d"), %%"FF_REG_S" \n\t"\
65  "movq "VROUNDER_OFFSET"(%0), %%mm3 \n\t"\
66  "movq %%mm3, %%mm4 \n\t"\
67  ".p2align 4 \n\t"\
68  "2: \n\t"\
69  "movq 8(%%"FF_REG_d"), %%mm0 \n\t" /* filterCoeff */\
70  "movq (%%"FF_REG_S", %%"FF_REG_a"), %%mm2 \n\t" /* UsrcData */\
71  "add %6, %%"FF_REG_S" \n\t" \
72  "movq (%%"FF_REG_S", %%"FF_REG_a"), %%mm5 \n\t" /* VsrcData */\
73  "add $16, %%"FF_REG_d" \n\t"\
74  "mov (%%"FF_REG_d"), %%"FF_REG_S" \n\t"\
75  "pmulhw %%mm0, %%mm2 \n\t"\
76  "pmulhw %%mm0, %%mm5 \n\t"\
77  "paddw %%mm2, %%mm3 \n\t"\
78  "paddw %%mm5, %%mm4 \n\t"\
79  "test %%"FF_REG_S", %%"FF_REG_S" \n\t"\
80  " jnz 2b \n\t"\
81 
82 #define YSCALEYUV2PACKEDX_YA(offset,coeff,src1,src2,dst1,dst2) \
83  "lea "offset"(%0), %%"FF_REG_d" \n\t"\
84  "mov (%%"FF_REG_d"), %%"FF_REG_S" \n\t"\
85  "movq "VROUNDER_OFFSET"(%0), "#dst1" \n\t"\
86  "movq "#dst1", "#dst2" \n\t"\
87  ".p2align 4 \n\t"\
88  "2: \n\t"\
89  "movq 8(%%"FF_REG_d"), "#coeff" \n\t" /* filterCoeff */\
90  "movq (%%"FF_REG_S", %%"FF_REG_a", 2), "#src1" \n\t" /* Y1srcData */\
91  "movq 8(%%"FF_REG_S", %%"FF_REG_a", 2), "#src2" \n\t" /* Y2srcData */\
92  "add $16, %%"FF_REG_d" \n\t"\
93  "mov (%%"FF_REG_d"), %%"FF_REG_S" \n\t"\
94  "pmulhw "#coeff", "#src1" \n\t"\
95  "pmulhw "#coeff", "#src2" \n\t"\
96  "paddw "#src1", "#dst1" \n\t"\
97  "paddw "#src2", "#dst2" \n\t"\
98  "test %%"FF_REG_S", %%"FF_REG_S" \n\t"\
99  " jnz 2b \n\t"\
100 
101 #define YSCALEYUV2PACKEDX \
102  YSCALEYUV2PACKEDX_UV \
103  YSCALEYUV2PACKEDX_YA(LUM_MMX_FILTER_OFFSET,%%mm0,%%mm2,%%mm5,%%mm1,%%mm7) \
104 
105 #define YSCALEYUV2PACKEDX_END \
106  :: "r" (&c->redDither), \
107  "m" (dummy), "m" (dummy), "m" (dummy),\
108  "r" (dest), "m" (dstW_reg), "m"(uv_off) \
109  NAMED_CONSTRAINTS_ADD(bF8,bFC) \
110  : "%"FF_REG_a, "%"FF_REG_d, "%"FF_REG_S \
111  );
112 
113 #define YSCALEYUV2PACKEDX_ACCURATE_UV \
114  __asm__ volatile(\
115  "xor %%"FF_REG_a", %%"FF_REG_a" \n\t"\
116  ".p2align 4 \n\t"\
117  "nop \n\t"\
118  "1: \n\t"\
119  "lea "CHR_MMX_FILTER_OFFSET"(%0), %%"FF_REG_d" \n\t"\
120  "mov (%%"FF_REG_d"), %%"FF_REG_S" \n\t"\
121  "pxor %%mm4, %%mm4 \n\t"\
122  "pxor %%mm5, %%mm5 \n\t"\
123  "pxor %%mm6, %%mm6 \n\t"\
124  "pxor %%mm7, %%mm7 \n\t"\
125  ".p2align 4 \n\t"\
126  "2: \n\t"\
127  "movq (%%"FF_REG_S", %%"FF_REG_a"), %%mm0 \n\t" /* UsrcData */\
128  "add %6, %%"FF_REG_S" \n\t" \
129  "movq (%%"FF_REG_S", %%"FF_REG_a"), %%mm2 \n\t" /* VsrcData */\
130  "mov "STR(APCK_PTR2)"(%%"FF_REG_d"), %%"FF_REG_S" \n\t"\
131  "movq (%%"FF_REG_S", %%"FF_REG_a"), %%mm1 \n\t" /* UsrcData */\
132  "movq %%mm0, %%mm3 \n\t"\
133  "punpcklwd %%mm1, %%mm0 \n\t"\
134  "punpckhwd %%mm1, %%mm3 \n\t"\
135  "movq "STR(APCK_COEF)"(%%"FF_REG_d"),%%mm1 \n\t" /* filterCoeff */\
136  "pmaddwd %%mm1, %%mm0 \n\t"\
137  "pmaddwd %%mm1, %%mm3 \n\t"\
138  "paddd %%mm0, %%mm4 \n\t"\
139  "paddd %%mm3, %%mm5 \n\t"\
140  "add %6, %%"FF_REG_S" \n\t" \
141  "movq (%%"FF_REG_S", %%"FF_REG_a"), %%mm3 \n\t" /* VsrcData */\
142  "mov "STR(APCK_SIZE)"(%%"FF_REG_d"), %%"FF_REG_S" \n\t"\
143  "add $"STR(APCK_SIZE)", %%"FF_REG_d" \n\t"\
144  "test %%"FF_REG_S", %%"FF_REG_S" \n\t"\
145  "movq %%mm2, %%mm0 \n\t"\
146  "punpcklwd %%mm3, %%mm2 \n\t"\
147  "punpckhwd %%mm3, %%mm0 \n\t"\
148  "pmaddwd %%mm1, %%mm2 \n\t"\
149  "pmaddwd %%mm1, %%mm0 \n\t"\
150  "paddd %%mm2, %%mm6 \n\t"\
151  "paddd %%mm0, %%mm7 \n\t"\
152  " jnz 2b \n\t"\
153  "psrad $16, %%mm4 \n\t"\
154  "psrad $16, %%mm5 \n\t"\
155  "psrad $16, %%mm6 \n\t"\
156  "psrad $16, %%mm7 \n\t"\
157  "movq "VROUNDER_OFFSET"(%0), %%mm0 \n\t"\
158  "packssdw %%mm5, %%mm4 \n\t"\
159  "packssdw %%mm7, %%mm6 \n\t"\
160  "paddw %%mm0, %%mm4 \n\t"\
161  "paddw %%mm0, %%mm6 \n\t"\
162  "movq %%mm4, "U_TEMP"(%0) \n\t"\
163  "movq %%mm6, "V_TEMP"(%0) \n\t"\
164 
165 #define YSCALEYUV2PACKEDX_ACCURATE_YA(offset) \
166  "lea "offset"(%0), %%"FF_REG_d" \n\t"\
167  "mov (%%"FF_REG_d"), %%"FF_REG_S" \n\t"\
168  "pxor %%mm1, %%mm1 \n\t"\
169  "pxor %%mm5, %%mm5 \n\t"\
170  "pxor %%mm7, %%mm7 \n\t"\
171  "pxor %%mm6, %%mm6 \n\t"\
172  ".p2align 4 \n\t"\
173  "2: \n\t"\
174  "movq (%%"FF_REG_S", %%"FF_REG_a", 2), %%mm0 \n\t" /* Y1srcData */\
175  "movq 8(%%"FF_REG_S", %%"FF_REG_a", 2), %%mm2 \n\t" /* Y2srcData */\
176  "mov "STR(APCK_PTR2)"(%%"FF_REG_d"), %%"FF_REG_S" \n\t"\
177  "movq (%%"FF_REG_S", %%"FF_REG_a", 2), %%mm4 \n\t" /* Y1srcData */\
178  "movq %%mm0, %%mm3 \n\t"\
179  "punpcklwd %%mm4, %%mm0 \n\t"\
180  "punpckhwd %%mm4, %%mm3 \n\t"\
181  "movq "STR(APCK_COEF)"(%%"FF_REG_d"), %%mm4 \n\t" /* filterCoeff */\
182  "pmaddwd %%mm4, %%mm0 \n\t"\
183  "pmaddwd %%mm4, %%mm3 \n\t"\
184  "paddd %%mm0, %%mm1 \n\t"\
185  "paddd %%mm3, %%mm5 \n\t"\
186  "movq 8(%%"FF_REG_S", %%"FF_REG_a", 2), %%mm3 \n\t" /* Y2srcData */\
187  "mov "STR(APCK_SIZE)"(%%"FF_REG_d"), %%"FF_REG_S" \n\t"\
188  "add $"STR(APCK_SIZE)", %%"FF_REG_d" \n\t"\
189  "test %%"FF_REG_S", %%"FF_REG_S" \n\t"\
190  "movq %%mm2, %%mm0 \n\t"\
191  "punpcklwd %%mm3, %%mm2 \n\t"\
192  "punpckhwd %%mm3, %%mm0 \n\t"\
193  "pmaddwd %%mm4, %%mm2 \n\t"\
194  "pmaddwd %%mm4, %%mm0 \n\t"\
195  "paddd %%mm2, %%mm7 \n\t"\
196  "paddd %%mm0, %%mm6 \n\t"\
197  " jnz 2b \n\t"\
198  "psrad $16, %%mm1 \n\t"\
199  "psrad $16, %%mm5 \n\t"\
200  "psrad $16, %%mm7 \n\t"\
201  "psrad $16, %%mm6 \n\t"\
202  "movq "VROUNDER_OFFSET"(%0), %%mm0 \n\t"\
203  "packssdw %%mm5, %%mm1 \n\t"\
204  "packssdw %%mm6, %%mm7 \n\t"\
205  "paddw %%mm0, %%mm1 \n\t"\
206  "paddw %%mm0, %%mm7 \n\t"\
207  "movq "U_TEMP"(%0), %%mm3 \n\t"\
208  "movq "V_TEMP"(%0), %%mm4 \n\t"\
209 
210 #define YSCALEYUV2PACKEDX_ACCURATE \
211  YSCALEYUV2PACKEDX_ACCURATE_UV \
212  YSCALEYUV2PACKEDX_ACCURATE_YA(LUM_MMX_FILTER_OFFSET)
213 
214 #define YSCALEYUV2RGBX \
215  "psubw "U_OFFSET"(%0), %%mm3 \n\t" /* (U-128)8*/\
216  "psubw "V_OFFSET"(%0), %%mm4 \n\t" /* (V-128)8*/\
217  "movq %%mm3, %%mm2 \n\t" /* (U-128)8*/\
218  "movq %%mm4, %%mm5 \n\t" /* (V-128)8*/\
219  "pmulhw "UG_COEFF"(%0), %%mm3 \n\t"\
220  "pmulhw "VG_COEFF"(%0), %%mm4 \n\t"\
221  /* mm2=(U-128)8, mm3=ug, mm4=vg mm5=(V-128)8 */\
222  "pmulhw "UB_COEFF"(%0), %%mm2 \n\t"\
223  "pmulhw "VR_COEFF"(%0), %%mm5 \n\t"\
224  "psubw "Y_OFFSET"(%0), %%mm1 \n\t" /* 8(Y-16)*/\
225  "psubw "Y_OFFSET"(%0), %%mm7 \n\t" /* 8(Y-16)*/\
226  "pmulhw "Y_COEFF"(%0), %%mm1 \n\t"\
227  "pmulhw "Y_COEFF"(%0), %%mm7 \n\t"\
228  /* mm1= Y1, mm2=ub, mm3=ug, mm4=vg mm5=vr, mm7=Y2 */\
229  "paddw %%mm3, %%mm4 \n\t"\
230  "movq %%mm2, %%mm0 \n\t"\
231  "movq %%mm5, %%mm6 \n\t"\
232  "movq %%mm4, %%mm3 \n\t"\
233  "punpcklwd %%mm2, %%mm2 \n\t"\
234  "punpcklwd %%mm5, %%mm5 \n\t"\
235  "punpcklwd %%mm4, %%mm4 \n\t"\
236  "paddw %%mm1, %%mm2 \n\t"\
237  "paddw %%mm1, %%mm5 \n\t"\
238  "paddw %%mm1, %%mm4 \n\t"\
239  "punpckhwd %%mm0, %%mm0 \n\t"\
240  "punpckhwd %%mm6, %%mm6 \n\t"\
241  "punpckhwd %%mm3, %%mm3 \n\t"\
242  "paddw %%mm7, %%mm0 \n\t"\
243  "paddw %%mm7, %%mm6 \n\t"\
244  "paddw %%mm7, %%mm3 \n\t"\
245  /* mm0=B1, mm2=B2, mm3=G2, mm4=G1, mm5=R1, mm6=R2 */\
246  "packuswb %%mm0, %%mm2 \n\t"\
247  "packuswb %%mm6, %%mm5 \n\t"\
248  "packuswb %%mm3, %%mm4 \n\t"\
249 
250 #define REAL_WRITEBGR32(dst, dstw, index, b, g, r, a, q0, q2, q3, t) \
251  "movq "#b", "#q2" \n\t" /* B */\
252  "movq "#r", "#t" \n\t" /* R */\
253  "punpcklbw "#g", "#b" \n\t" /* GBGBGBGB 0 */\
254  "punpcklbw "#a", "#r" \n\t" /* ARARARAR 0 */\
255  "punpckhbw "#g", "#q2" \n\t" /* GBGBGBGB 2 */\
256  "punpckhbw "#a", "#t" \n\t" /* ARARARAR 2 */\
257  "movq "#b", "#q0" \n\t" /* GBGBGBGB 0 */\
258  "movq "#q2", "#q3" \n\t" /* GBGBGBGB 2 */\
259  "punpcklwd "#r", "#q0" \n\t" /* ARGBARGB 0 */\
260  "punpckhwd "#r", "#b" \n\t" /* ARGBARGB 1 */\
261  "punpcklwd "#t", "#q2" \n\t" /* ARGBARGB 2 */\
262  "punpckhwd "#t", "#q3" \n\t" /* ARGBARGB 3 */\
263 \
264  MOVNTQ( q0, (dst, index, 4))\
265  MOVNTQ( b, 8(dst, index, 4))\
266  MOVNTQ( q2, 16(dst, index, 4))\
267  MOVNTQ( q3, 24(dst, index, 4))\
268 \
269  NEXT_PIXEL_BLOCK(dstw, index, )
270 #define WRITEBGR32(dst, dstw, index, b, g, r, a, q0, q2, q3, t) REAL_WRITEBGR32(dst, dstw, index, b, g, r, a, q0, q2, q3, t)
271 
272 static void RENAME(yuv2rgb32_X_ar)(SwsContext *c, const int16_t *lumFilter,
273  const int16_t **lumSrc, int lumFilterSize,
274  const int16_t *chrFilter, const int16_t **chrUSrc,
275  const int16_t **chrVSrc,
276  int chrFilterSize, const int16_t **alpSrc,
277  uint8_t *dest, int dstW, int dstY)
278 {
279  x86_reg dummy=0;
280  x86_reg dstW_reg = dstW;
281  x86_reg uv_off = c->uv_offx2;
282 
283  if (CONFIG_SWSCALE_ALPHA && c->needAlpha) {
286  "movq %%mm2, "U_TEMP"(%0) \n\t"
287  "movq %%mm4, "V_TEMP"(%0) \n\t"
288  "movq %%mm5, "Y_TEMP"(%0) \n\t"
290  "movq "Y_TEMP"(%0), %%mm5 \n\t"
291  "psraw $3, %%mm1 \n\t"
292  "psraw $3, %%mm7 \n\t"
293  "packuswb %%mm7, %%mm1 \n\t"
294  WRITEBGR32(%4, "%5", %%FF_REGa, %%mm3, %%mm4, %%mm5, %%mm1, %%mm0, %%mm7, %%mm2, %%mm6)
296  } else {
299  "pcmpeqd %%mm7, %%mm7 \n\t"
300  WRITEBGR32(%4, "%5", %%FF_REGa, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
302  }
303 }
304 
305 static void RENAME(yuv2rgb32_X)(SwsContext *c, const int16_t *lumFilter,
306  const int16_t **lumSrc, int lumFilterSize,
307  const int16_t *chrFilter, const int16_t **chrUSrc,
308  const int16_t **chrVSrc,
309  int chrFilterSize, const int16_t **alpSrc,
310  uint8_t *dest, int dstW, int dstY)
311 {
312  x86_reg dummy=0;
313  x86_reg dstW_reg = dstW;
314  x86_reg uv_off = c->uv_offx2;
315 
316  if (CONFIG_SWSCALE_ALPHA && c->needAlpha) {
319  YSCALEYUV2PACKEDX_YA(ALP_MMX_FILTER_OFFSET, %%mm0, %%mm3, %%mm6, %%mm1, %%mm7)
320  "psraw $3, %%mm1 \n\t"
321  "psraw $3, %%mm7 \n\t"
322  "packuswb %%mm7, %%mm1 \n\t"
323  WRITEBGR32(%4, "%5", %%FF_REGa, %%mm2, %%mm4, %%mm5, %%mm1, %%mm0, %%mm7, %%mm3, %%mm6)
325  } else {
328  "pcmpeqd %%mm7, %%mm7 \n\t"
329  WRITEBGR32(%4, "%5", %%FF_REGa, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
331  }
332 }
333 
334 static void RENAME(yuv2bgr32_X)(SwsContext *c, const int16_t *lumFilter,
335  const int16_t **lumSrc, int lumFilterSize,
336  const int16_t *chrFilter, const int16_t **chrUSrc,
337  const int16_t **chrVSrc,
338  int chrFilterSize, const int16_t **alpSrc,
339  uint8_t *dest, int dstW, int dstY)
340 {
341  x86_reg dummy=0;
342  x86_reg dstW_reg = dstW;
343  x86_reg uv_off = c->uv_offx2;
344 
345  if (CONFIG_SWSCALE_ALPHA && c->needAlpha) {
348  YSCALEYUV2PACKEDX_YA(ALP_MMX_FILTER_OFFSET, %%mm0, %%mm3, %%mm6, %%mm1, %%mm7)
349  "psraw $3, %%mm1 \n\t"
350  "psraw $3, %%mm7 \n\t"
351  "packuswb %%mm7, %%mm1 \n\t"
352  WRITEBGR32(%4, "%5", %%FF_REGa, %%mm5, %%mm4, %%mm2, %%mm1, %%mm0, %%mm7, %%mm3, %%mm6)
354  } else {
357  "pcmpeqd %%mm7, %%mm7 \n\t"
358  WRITEBGR32(%4, "%5", %%FF_REGa, %%mm5, %%mm4, %%mm2, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
360  }
361 }
362 
363 #define REAL_WRITERGB16(dst, dstw, index) \
364  "pand "MANGLE(bF8)", %%mm2 \n\t" /* B */\
365  "pand "MANGLE(bFC)", %%mm4 \n\t" /* G */\
366  "pand "MANGLE(bF8)", %%mm5 \n\t" /* R */\
367  "psrlq $3, %%mm2 \n\t"\
368 \
369  "movq %%mm2, %%mm1 \n\t"\
370  "movq %%mm4, %%mm3 \n\t"\
371 \
372  "punpcklbw %%mm7, %%mm3 \n\t"\
373  "punpcklbw %%mm5, %%mm2 \n\t"\
374  "punpckhbw %%mm7, %%mm4 \n\t"\
375  "punpckhbw %%mm5, %%mm1 \n\t"\
376 \
377  "psllq $3, %%mm3 \n\t"\
378  "psllq $3, %%mm4 \n\t"\
379 \
380  "por %%mm3, %%mm2 \n\t"\
381  "por %%mm4, %%mm1 \n\t"\
382 \
383  MOVNTQ(%%mm2, (dst, index, 2))\
384  MOVNTQ(%%mm1, 8(dst, index, 2))\
385 \
386  NEXT_PIXEL_BLOCK(dstw, index, )
387 #define WRITERGB16(dst, dstw, index) REAL_WRITERGB16(dst, dstw, index)
388 
389 static void RENAME(yuv2rgb565_X_ar)(SwsContext *c, const int16_t *lumFilter,
390  const int16_t **lumSrc, int lumFilterSize,
391  const int16_t *chrFilter, const int16_t **chrUSrc,
392  const int16_t **chrVSrc,
393  int chrFilterSize, const int16_t **alpSrc,
394  uint8_t *dest, int dstW, int dstY)
395 {
396  x86_reg dummy=0;
397  x86_reg dstW_reg = dstW;
398  x86_reg uv_off = c->uv_offx2;
399 
402  "pxor %%mm7, %%mm7 \n\t"
403  /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
404 #ifdef DITHER1XBPP
405  "paddusb "BLUE_DITHER"(%0), %%mm2\n\t"
406  "paddusb "GREEN_DITHER"(%0), %%mm4\n\t"
407  "paddusb "RED_DITHER"(%0), %%mm5\n\t"
408 #endif
409  WRITERGB16(%4, "%5", %%FF_REGa)
411 }
412 
413 static void RENAME(yuv2rgb565_X)(SwsContext *c, const int16_t *lumFilter,
414  const int16_t **lumSrc, int lumFilterSize,
415  const int16_t *chrFilter, const int16_t **chrUSrc,
416  const int16_t **chrVSrc,
417  int chrFilterSize, const int16_t **alpSrc,
418  uint8_t *dest, int dstW, int dstY)
419 {
420  x86_reg dummy=0;
421  x86_reg dstW_reg = dstW;
422  x86_reg uv_off = c->uv_offx2;
423 
426  "pxor %%mm7, %%mm7 \n\t"
427  /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
428 #ifdef DITHER1XBPP
429  "paddusb "BLUE_DITHER"(%0), %%mm2 \n\t"
430  "paddusb "GREEN_DITHER"(%0), %%mm4 \n\t"
431  "paddusb "RED_DITHER"(%0), %%mm5 \n\t"
432 #endif
433  WRITERGB16(%4, "%5", %%FF_REGa)
435 }
436 
437 #define REAL_WRITERGB15(dst, dstw, index) \
438  "pand "MANGLE(bF8)", %%mm2 \n\t" /* B */\
439  "pand "MANGLE(bF8)", %%mm4 \n\t" /* G */\
440  "pand "MANGLE(bF8)", %%mm5 \n\t" /* R */\
441  "psrlq $3, %%mm2 \n\t"\
442  "psrlq $1, %%mm5 \n\t"\
443 \
444  "movq %%mm2, %%mm1 \n\t"\
445  "movq %%mm4, %%mm3 \n\t"\
446 \
447  "punpcklbw %%mm7, %%mm3 \n\t"\
448  "punpcklbw %%mm5, %%mm2 \n\t"\
449  "punpckhbw %%mm7, %%mm4 \n\t"\
450  "punpckhbw %%mm5, %%mm1 \n\t"\
451 \
452  "psllq $2, %%mm3 \n\t"\
453  "psllq $2, %%mm4 \n\t"\
454 \
455  "por %%mm3, %%mm2 \n\t"\
456  "por %%mm4, %%mm1 \n\t"\
457 \
458  MOVNTQ(%%mm2, (dst, index, 2))\
459  MOVNTQ(%%mm1, 8(dst, index, 2))\
460 \
461  NEXT_PIXEL_BLOCK(dstw, index, )
462 #define WRITERGB15(dst, dstw, index) REAL_WRITERGB15(dst, dstw, index)
463 
464 static void RENAME(yuv2rgb555_X_ar)(SwsContext *c, const int16_t *lumFilter,
465  const int16_t **lumSrc, int lumFilterSize,
466  const int16_t *chrFilter, const int16_t **chrUSrc,
467  const int16_t **chrVSrc,
468  int chrFilterSize, const int16_t **alpSrc,
469  uint8_t *dest, int dstW, int dstY)
470 {
471  x86_reg dummy=0;
472  x86_reg dstW_reg = dstW;
473  x86_reg uv_off = c->uv_offx2;
474 
477  "pxor %%mm7, %%mm7 \n\t"
478  /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
479 #ifdef DITHER1XBPP
480  "paddusb "BLUE_DITHER"(%0), %%mm2\n\t"
481  "paddusb "GREEN_DITHER"(%0), %%mm4\n\t"
482  "paddusb "RED_DITHER"(%0), %%mm5\n\t"
483 #endif
484  WRITERGB15(%4, "%5", %%FF_REGa)
486 }
487 
488 static void RENAME(yuv2rgb555_X)(SwsContext *c, const int16_t *lumFilter,
489  const int16_t **lumSrc, int lumFilterSize,
490  const int16_t *chrFilter, const int16_t **chrUSrc,
491  const int16_t **chrVSrc,
492  int chrFilterSize, const int16_t **alpSrc,
493  uint8_t *dest, int dstW, int dstY)
494 {
495  x86_reg dummy=0;
496  x86_reg dstW_reg = dstW;
497  x86_reg uv_off = c->uv_offx2;
498 
501  "pxor %%mm7, %%mm7 \n\t"
502  /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
503 #ifdef DITHER1XBPP
504  "paddusb "BLUE_DITHER"(%0), %%mm2 \n\t"
505  "paddusb "GREEN_DITHER"(%0), %%mm4 \n\t"
506  "paddusb "RED_DITHER"(%0), %%mm5 \n\t"
507 #endif
508  WRITERGB15(%4, "%5", %%FF_REGa)
510 }
511 
512 #define WRITEBGR24MMX(dst, dstw, index) \
513  /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */\
514  "movq %%mm2, %%mm1 \n\t" /* B */\
515  "movq %%mm5, %%mm6 \n\t" /* R */\
516  "punpcklbw %%mm4, %%mm2 \n\t" /* GBGBGBGB 0 */\
517  "punpcklbw %%mm7, %%mm5 \n\t" /* 0R0R0R0R 0 */\
518  "punpckhbw %%mm4, %%mm1 \n\t" /* GBGBGBGB 2 */\
519  "punpckhbw %%mm7, %%mm6 \n\t" /* 0R0R0R0R 2 */\
520  "movq %%mm2, %%mm0 \n\t" /* GBGBGBGB 0 */\
521  "movq %%mm1, %%mm3 \n\t" /* GBGBGBGB 2 */\
522  "punpcklwd %%mm5, %%mm0 \n\t" /* 0RGB0RGB 0 */\
523  "punpckhwd %%mm5, %%mm2 \n\t" /* 0RGB0RGB 1 */\
524  "punpcklwd %%mm6, %%mm1 \n\t" /* 0RGB0RGB 2 */\
525  "punpckhwd %%mm6, %%mm3 \n\t" /* 0RGB0RGB 3 */\
526 \
527  "movq %%mm0, %%mm4 \n\t" /* 0RGB0RGB 0 */\
528  "movq %%mm2, %%mm6 \n\t" /* 0RGB0RGB 1 */\
529  "movq %%mm1, %%mm5 \n\t" /* 0RGB0RGB 2 */\
530  "movq %%mm3, %%mm7 \n\t" /* 0RGB0RGB 3 */\
531 \
532  "psllq $40, %%mm0 \n\t" /* RGB00000 0 */\
533  "psllq $40, %%mm2 \n\t" /* RGB00000 1 */\
534  "psllq $40, %%mm1 \n\t" /* RGB00000 2 */\
535  "psllq $40, %%mm3 \n\t" /* RGB00000 3 */\
536 \
537  "punpckhdq %%mm4, %%mm0 \n\t" /* 0RGBRGB0 0 */\
538  "punpckhdq %%mm6, %%mm2 \n\t" /* 0RGBRGB0 1 */\
539  "punpckhdq %%mm5, %%mm1 \n\t" /* 0RGBRGB0 2 */\
540  "punpckhdq %%mm7, %%mm3 \n\t" /* 0RGBRGB0 3 */\
541 \
542  "psrlq $8, %%mm0 \n\t" /* 00RGBRGB 0 */\
543  "movq %%mm2, %%mm6 \n\t" /* 0RGBRGB0 1 */\
544  "psllq $40, %%mm2 \n\t" /* GB000000 1 */\
545  "por %%mm2, %%mm0 \n\t" /* GBRGBRGB 0 */\
546  MOVNTQ(%%mm0, (dst))\
547 \
548  "psrlq $24, %%mm6 \n\t" /* 0000RGBR 1 */\
549  "movq %%mm1, %%mm5 \n\t" /* 0RGBRGB0 2 */\
550  "psllq $24, %%mm1 \n\t" /* BRGB0000 2 */\
551  "por %%mm1, %%mm6 \n\t" /* BRGBRGBR 1 */\
552  MOVNTQ(%%mm6, 8(dst))\
553 \
554  "psrlq $40, %%mm5 \n\t" /* 000000RG 2 */\
555  "psllq $8, %%mm3 \n\t" /* RGBRGB00 3 */\
556  "por %%mm3, %%mm5 \n\t" /* RGBRGBRG 2 */\
557  MOVNTQ(%%mm5, 16(dst))\
558 \
559  "add $24, "#dst" \n\t"\
560 \
561  NEXT_PIXEL_BLOCK(dstw, index, "sub "#index", "#dst" \n\t"\
562  "sub "#index", "#dst" \n\t"\
563  "sub "#index", "#dst" \n\t")
564 
565 #define WRITEBGR24MMXEXT(dst, dstw, index) \
566  /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */\
567  "movq "MANGLE(ff_M24A)", %%mm0 \n\t"\
568  "movq "MANGLE(ff_M24C)", %%mm7 \n\t"\
569  "pshufw $0x50, %%mm2, %%mm1 \n\t" /* B3 B2 B3 B2 B1 B0 B1 B0 */\
570  "pshufw $0x50, %%mm4, %%mm3 \n\t" /* G3 G2 G3 G2 G1 G0 G1 G0 */\
571  "pshufw $0x00, %%mm5, %%mm6 \n\t" /* R1 R0 R1 R0 R1 R0 R1 R0 */\
572 \
573  "pand %%mm0, %%mm1 \n\t" /* B2 B1 B0 */\
574  "pand %%mm0, %%mm3 \n\t" /* G2 G1 G0 */\
575  "pand %%mm7, %%mm6 \n\t" /* R1 R0 */\
576 \
577  "psllq $8, %%mm3 \n\t" /* G2 G1 G0 */\
578  "por %%mm1, %%mm6 \n\t"\
579  "por %%mm3, %%mm6 \n\t"\
580  MOVNTQ(%%mm6, (dst))\
581 \
582  "psrlq $8, %%mm4 \n\t" /* 00 G7 G6 G5 G4 G3 G2 G1 */\
583  "pshufw $0xA5, %%mm2, %%mm1 \n\t" /* B5 B4 B5 B4 B3 B2 B3 B2 */\
584  "pshufw $0x55, %%mm4, %%mm3 \n\t" /* G4 G3 G4 G3 G4 G3 G4 G3 */\
585  "pshufw $0xA5, %%mm5, %%mm6 \n\t" /* R5 R4 R5 R4 R3 R2 R3 R2 */\
586 \
587  "pand "MANGLE(ff_M24B)", %%mm1 \n\t" /* B5 B4 B3 */\
588  "pand %%mm7, %%mm3 \n\t" /* G4 G3 */\
589  "pand %%mm0, %%mm6 \n\t" /* R4 R3 R2 */\
590 \
591  "por %%mm1, %%mm3 \n\t" /* B5 G4 B4 G3 B3 */\
592  "por %%mm3, %%mm6 \n\t"\
593  MOVNTQ(%%mm6, 8(dst))\
594 \
595  "pshufw $0xFF, %%mm2, %%mm1 \n\t" /* B7 B6 B7 B6 B7 B6 B6 B7 */\
596  "pshufw $0xFA, %%mm4, %%mm3 \n\t" /* 00 G7 00 G7 G6 G5 G6 G5 */\
597  "pshufw $0xFA, %%mm5, %%mm6 \n\t" /* R7 R6 R7 R6 R5 R4 R5 R4 */\
598 \
599  "pand %%mm7, %%mm1 \n\t" /* B7 B6 */\
600  "pand %%mm0, %%mm3 \n\t" /* G7 G6 G5 */\
601  "pand "MANGLE(ff_M24B)", %%mm6 \n\t" /* R7 R6 R5 */\
602 \
603  "por %%mm1, %%mm3 \n\t"\
604  "por %%mm3, %%mm6 \n\t"\
605  MOVNTQ(%%mm6, 16(dst))\
606 \
607  "add $24, "#dst" \n\t"\
608 \
609  NEXT_PIXEL_BLOCK(dstw, index, "sub "#index", "#dst" \n\t"\
610  "sub "#index", "#dst" \n\t"\
611  "sub "#index", "#dst" \n\t")
612 
613 #if COMPILE_TEMPLATE_MMXEXT
614 #undef WRITEBGR24
615 #define WRITEBGR24(dst, dstw, index) WRITEBGR24MMXEXT(dst, dstw, index)
616 #else
617 #undef WRITEBGR24
618 #define WRITEBGR24(dst, dstw, index) WRITEBGR24MMX(dst, dstw, index)
619 #endif
620 
621 #if HAVE_6REGS
622 static void RENAME(yuv2bgr24_X_ar)(SwsContext *c, const int16_t *lumFilter,
623  const int16_t **lumSrc, int lumFilterSize,
624  const int16_t *chrFilter, const int16_t **chrUSrc,
625  const int16_t **chrVSrc,
626  int chrFilterSize, const int16_t **alpSrc,
627  uint8_t *dest, int dstW, int dstY)
628 {
629  x86_reg dummy=0;
630  x86_reg dstW_reg = dstW;
631  x86_reg uv_off = c->uv_offx2;
632 
635  "pxor %%mm7, %%mm7 \n\t"
636  "lea (%%"FF_REG_a", %%"FF_REG_a", 2), %%"FF_REG_c"\n\t" //FIXME optimize
637  "add %4, %%"FF_REG_c" \n\t"
638  WRITEBGR24(%%FF_REGc, "%5", %%FF_REGa)
639  :: "r" (&c->redDither),
640  "m" (dummy), "m" (dummy), "m" (dummy),
641  "r" (dest), "m" (dstW_reg), "m"(uv_off)
642  NAMED_CONSTRAINTS_ADD(ff_M24A,ff_M24C,ff_M24B)
643  : "%"FF_REG_a, "%"FF_REG_c, "%"FF_REG_d, "%"FF_REG_S
644  );
645 }
646 
647 static void RENAME(yuv2bgr24_X)(SwsContext *c, const int16_t *lumFilter,
648  const int16_t **lumSrc, int lumFilterSize,
649  const int16_t *chrFilter, const int16_t **chrUSrc,
650  const int16_t **chrVSrc,
651  int chrFilterSize, const int16_t **alpSrc,
652  uint8_t *dest, int dstW, int dstY)
653 {
654  x86_reg dummy=0;
655  x86_reg dstW_reg = dstW;
656  x86_reg uv_off = c->uv_offx2;
657 
660  "pxor %%mm7, %%mm7 \n\t"
661  "lea (%%"FF_REG_a", %%"FF_REG_a", 2), %%"FF_REG_c" \n\t" //FIXME optimize
662  "add %4, %%"FF_REG_c" \n\t"
663  WRITEBGR24(%%FF_REGc, "%5", %%FF_REGa)
664  :: "r" (&c->redDither),
665  "m" (dummy), "m" (dummy), "m" (dummy),
666  "r" (dest), "m" (dstW_reg), "m"(uv_off)
667  NAMED_CONSTRAINTS_ADD(ff_M24A,ff_M24C,ff_M24B)
668  : "%"FF_REG_a, "%"FF_REG_c, "%"FF_REG_d, "%"FF_REG_S
669  );
670 }
671 #endif /* HAVE_6REGS */
672 
673 #define REAL_WRITEYUY2(dst, dstw, index) \
674  "packuswb %%mm3, %%mm3 \n\t"\
675  "packuswb %%mm4, %%mm4 \n\t"\
676  "packuswb %%mm7, %%mm1 \n\t"\
677  "punpcklbw %%mm4, %%mm3 \n\t"\
678  "movq %%mm1, %%mm7 \n\t"\
679  "punpcklbw %%mm3, %%mm1 \n\t"\
680  "punpckhbw %%mm3, %%mm7 \n\t"\
681 \
682  MOVNTQ(%%mm1, (dst, index, 2))\
683  MOVNTQ(%%mm7, 8(dst, index, 2))\
684 \
685  NEXT_PIXEL_BLOCK(dstw, index, )
686 #define WRITEYUY2(dst, dstw, index) REAL_WRITEYUY2(dst, dstw, index)
687 
688 static void RENAME(yuv2yuyv422_X_ar)(SwsContext *c, const int16_t *lumFilter,
689  const int16_t **lumSrc, int lumFilterSize,
690  const int16_t *chrFilter, const int16_t **chrUSrc,
691  const int16_t **chrVSrc,
692  int chrFilterSize, const int16_t **alpSrc,
693  uint8_t *dest, int dstW, int dstY)
694 {
695  x86_reg dummy=0;
696  x86_reg dstW_reg = dstW;
697  x86_reg uv_off = c->uv_offx2;
698 
700  /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
701  "psraw $3, %%mm3 \n\t"
702  "psraw $3, %%mm4 \n\t"
703  "psraw $3, %%mm1 \n\t"
704  "psraw $3, %%mm7 \n\t"
705  WRITEYUY2(%4, "%5", %%FF_REGa)
707 }
708 
709 static void RENAME(yuv2yuyv422_X)(SwsContext *c, const int16_t *lumFilter,
710  const int16_t **lumSrc, int lumFilterSize,
711  const int16_t *chrFilter, const int16_t **chrUSrc,
712  const int16_t **chrVSrc,
713  int chrFilterSize, const int16_t **alpSrc,
714  uint8_t *dest, int dstW, int dstY)
715 {
716  x86_reg dummy=0;
717  x86_reg dstW_reg = dstW;
718  x86_reg uv_off = c->uv_offx2;
719 
721  /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
722  "psraw $3, %%mm3 \n\t"
723  "psraw $3, %%mm4 \n\t"
724  "psraw $3, %%mm1 \n\t"
725  "psraw $3, %%mm7 \n\t"
726  WRITEYUY2(%4, "%5", %%FF_REGa)
728 }
729 
730 #define REAL_YSCALEYUV2RGB_UV(index, c) \
731  "xor "#index", "#index" \n\t"\
732  ".p2align 4 \n\t"\
733  "1: \n\t"\
734  "movq (%2, "#index"), %%mm2 \n\t" /* uvbuf0[eax]*/\
735  "movq (%3, "#index"), %%mm3 \n\t" /* uvbuf1[eax]*/\
736  "add "UV_OFF_BYTE"("#c"), "#index" \n\t" \
737  "movq (%2, "#index"), %%mm5 \n\t" /* uvbuf0[eax+2048]*/\
738  "movq (%3, "#index"), %%mm4 \n\t" /* uvbuf1[eax+2048]*/\
739  "sub "UV_OFF_BYTE"("#c"), "#index" \n\t" \
740  "psubw %%mm3, %%mm2 \n\t" /* uvbuf0[eax] - uvbuf1[eax]*/\
741  "psubw %%mm4, %%mm5 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048]*/\
742  "movq "CHR_MMX_FILTER_OFFSET"+8("#c"), %%mm0 \n\t"\
743  "pmulhw %%mm0, %%mm2 \n\t" /* (uvbuf0[eax] - uvbuf1[eax])uvalpha1>>16*/\
744  "pmulhw %%mm0, %%mm5 \n\t" /* (uvbuf0[eax+2048] - uvbuf1[eax+2048])uvalpha1>>16*/\
745  "psraw $4, %%mm3 \n\t" /* uvbuf0[eax] - uvbuf1[eax] >>4*/\
746  "psraw $4, %%mm4 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048] >>4*/\
747  "paddw %%mm2, %%mm3 \n\t" /* uvbuf0[eax]uvalpha1 - uvbuf1[eax](1-uvalpha1)*/\
748  "paddw %%mm5, %%mm4 \n\t" /* uvbuf0[eax+2048]uvalpha1 - uvbuf1[eax+2048](1-uvalpha1)*/\
749  "psubw "U_OFFSET"("#c"), %%mm3 \n\t" /* (U-128)8*/\
750  "psubw "V_OFFSET"("#c"), %%mm4 \n\t" /* (V-128)8*/\
751  "movq %%mm3, %%mm2 \n\t" /* (U-128)8*/\
752  "movq %%mm4, %%mm5 \n\t" /* (V-128)8*/\
753  "pmulhw "UG_COEFF"("#c"), %%mm3 \n\t"\
754  "pmulhw "VG_COEFF"("#c"), %%mm4 \n\t"\
755  /* mm2=(U-128)8, mm3=ug, mm4=vg mm5=(V-128)8 */\
756 
757 #define REAL_YSCALEYUV2RGB_YA(index, c, b1, b2) \
758  "movq ("#b1", "#index", 2), %%mm0 \n\t" /*buf0[eax]*/\
759  "movq ("#b2", "#index", 2), %%mm1 \n\t" /*buf1[eax]*/\
760  "movq 8("#b1", "#index", 2), %%mm6 \n\t" /*buf0[eax]*/\
761  "movq 8("#b2", "#index", 2), %%mm7 \n\t" /*buf1[eax]*/\
762  "psubw %%mm1, %%mm0 \n\t" /* buf0[eax] - buf1[eax]*/\
763  "psubw %%mm7, %%mm6 \n\t" /* buf0[eax] - buf1[eax]*/\
764  "pmulhw "LUM_MMX_FILTER_OFFSET"+8("#c"), %%mm0 \n\t" /* (buf0[eax] - buf1[eax])yalpha1>>16*/\
765  "pmulhw "LUM_MMX_FILTER_OFFSET"+8("#c"), %%mm6 \n\t" /* (buf0[eax] - buf1[eax])yalpha1>>16*/\
766  "psraw $4, %%mm1 \n\t" /* buf0[eax] - buf1[eax] >>4*/\
767  "psraw $4, %%mm7 \n\t" /* buf0[eax] - buf1[eax] >>4*/\
768  "paddw %%mm0, %%mm1 \n\t" /* buf0[eax]yalpha1 + buf1[eax](1-yalpha1) >>16*/\
769  "paddw %%mm6, %%mm7 \n\t" /* buf0[eax]yalpha1 + buf1[eax](1-yalpha1) >>16*/\
770 
771 #define REAL_YSCALEYUV2RGB_COEFF(c) \
772  "pmulhw "UB_COEFF"("#c"), %%mm2 \n\t"\
773  "pmulhw "VR_COEFF"("#c"), %%mm5 \n\t"\
774  "psubw "Y_OFFSET"("#c"), %%mm1 \n\t" /* 8(Y-16)*/\
775  "psubw "Y_OFFSET"("#c"), %%mm7 \n\t" /* 8(Y-16)*/\
776  "pmulhw "Y_COEFF"("#c"), %%mm1 \n\t"\
777  "pmulhw "Y_COEFF"("#c"), %%mm7 \n\t"\
778  /* mm1= Y1, mm2=ub, mm3=ug, mm4=vg mm5=vr, mm7=Y2 */\
779  "paddw %%mm3, %%mm4 \n\t"\
780  "movq %%mm2, %%mm0 \n\t"\
781  "movq %%mm5, %%mm6 \n\t"\
782  "movq %%mm4, %%mm3 \n\t"\
783  "punpcklwd %%mm2, %%mm2 \n\t"\
784  "punpcklwd %%mm5, %%mm5 \n\t"\
785  "punpcklwd %%mm4, %%mm4 \n\t"\
786  "paddw %%mm1, %%mm2 \n\t"\
787  "paddw %%mm1, %%mm5 \n\t"\
788  "paddw %%mm1, %%mm4 \n\t"\
789  "punpckhwd %%mm0, %%mm0 \n\t"\
790  "punpckhwd %%mm6, %%mm6 \n\t"\
791  "punpckhwd %%mm3, %%mm3 \n\t"\
792  "paddw %%mm7, %%mm0 \n\t"\
793  "paddw %%mm7, %%mm6 \n\t"\
794  "paddw %%mm7, %%mm3 \n\t"\
795  /* mm0=B1, mm2=B2, mm3=G2, mm4=G1, mm5=R1, mm6=R2 */\
796  "packuswb %%mm0, %%mm2 \n\t"\
797  "packuswb %%mm6, %%mm5 \n\t"\
798  "packuswb %%mm3, %%mm4 \n\t"\
799 
800 #define YSCALEYUV2RGB_YA(index, c, b1, b2) REAL_YSCALEYUV2RGB_YA(index, c, b1, b2)
801 
802 #define YSCALEYUV2RGB(index, c) \
803  REAL_YSCALEYUV2RGB_UV(index, c) \
804  REAL_YSCALEYUV2RGB_YA(index, c, %0, %1) \
805  REAL_YSCALEYUV2RGB_COEFF(c)
806 
807 /**
808  * vertical bilinear scale YV12 to RGB
809  */
810 static void RENAME(yuv2rgb32_2)(SwsContext *c, const int16_t *buf[2],
811  const int16_t *ubuf[2], const int16_t *vbuf[2],
812  const int16_t *abuf[2], uint8_t *dest,
813  int dstW, int yalpha, int uvalpha, int y)
814 {
815  const int16_t *buf0 = buf[0], *buf1 = buf[1],
816  *ubuf0 = ubuf[0], *ubuf1 = ubuf[1];
817 
818  if (CONFIG_SWSCALE_ALPHA && c->needAlpha) {
819  const int16_t *abuf0 = abuf[0], *abuf1 = abuf[1];
820 #if ARCH_X86_64
821  __asm__ volatile(
822  YSCALEYUV2RGB(%%r8, %5)
823  YSCALEYUV2RGB_YA(%%r8, %5, %6, %7)
824  "psraw $3, %%mm1 \n\t" /* abuf0[eax] - abuf1[eax] >>7*/
825  "psraw $3, %%mm7 \n\t" /* abuf0[eax] - abuf1[eax] >>7*/
826  "packuswb %%mm7, %%mm1 \n\t"
827  WRITEBGR32(%4, DSTW_OFFSET"(%5)", %%r8, %%mm2, %%mm4, %%mm5, %%mm1, %%mm0, %%mm7, %%mm3, %%mm6)
828  :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "r" (dest),
829  "a" (&c->redDither),
830  "r" (abuf0), "r" (abuf1)
831  : "%r8"
832  );
833 #else
834  c->u_temp=(intptr_t)abuf0;
835  c->v_temp=(intptr_t)abuf1;
836  __asm__ volatile(
837  "mov %%"FF_REG_b", "ESP_OFFSET"(%5) \n\t"
838  "mov %4, %%"FF_REG_b" \n\t"
839  "push %%"FF_REG_BP" \n\t"
840  YSCALEYUV2RGB(%%FF_REGBP, %5)
841  "push %0 \n\t"
842  "push %1 \n\t"
843  "mov "U_TEMP"(%5), %0 \n\t"
844  "mov "V_TEMP"(%5), %1 \n\t"
845  YSCALEYUV2RGB_YA(%%FF_REGBP, %5, %0, %1)
846  "psraw $3, %%mm1 \n\t" /* abuf0[eax] - abuf1[eax] >>7*/
847  "psraw $3, %%mm7 \n\t" /* abuf0[eax] - abuf1[eax] >>7*/
848  "packuswb %%mm7, %%mm1 \n\t"
849  "pop %1 \n\t"
850  "pop %0 \n\t"
851  WRITEBGR32(%%FF_REGb, DSTW_OFFSET"(%5)", %%FF_REGBP, %%mm2, %%mm4, %%mm5, %%mm1, %%mm0, %%mm7, %%mm3, %%mm6)
852  "pop %%"FF_REG_BP" \n\t"
853  "mov "ESP_OFFSET"(%5), %%"FF_REG_b" \n\t"
854  :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
855  "a" (&c->redDither)
856  );
857 #endif
858  } else {
859  __asm__ volatile(
860  "mov %%"FF_REG_b", "ESP_OFFSET"(%5) \n\t"
861  "mov %4, %%"FF_REG_b" \n\t"
862  "push %%"FF_REG_BP" \n\t"
863  YSCALEYUV2RGB(%%FF_REGBP, %5)
864  "pcmpeqd %%mm7, %%mm7 \n\t"
865  WRITEBGR32(%%FF_REGb, DSTW_OFFSET"(%5)", %%FF_REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
866  "pop %%"FF_REG_BP" \n\t"
867  "mov "ESP_OFFSET"(%5), %%"FF_REG_b" \n\t"
868  :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
869  "a" (&c->redDither)
870  );
871  }
872 }
873 
874 static void RENAME(yuv2bgr24_2)(SwsContext *c, const int16_t *buf[2],
875  const int16_t *ubuf[2], const int16_t *vbuf[2],
876  const int16_t *abuf[2], uint8_t *dest,
877  int dstW, int yalpha, int uvalpha, int y)
878 {
879  const int16_t *buf0 = buf[0], *buf1 = buf[1],
880  *ubuf0 = ubuf[0], *ubuf1 = ubuf[1];
881 
882  __asm__ volatile(
883  "mov %%"FF_REG_b", "ESP_OFFSET"(%5) \n\t"
884  "mov %4, %%"FF_REG_b" \n\t"
885  "push %%"FF_REG_BP" \n\t"
886  YSCALEYUV2RGB(%%FF_REGBP, %5)
887  "pxor %%mm7, %%mm7 \n\t"
888  WRITEBGR24(%%FF_REGb, DSTW_OFFSET"(%5)", %%FF_REGBP)
889  "pop %%"FF_REG_BP" \n\t"
890  "mov "ESP_OFFSET"(%5), %%"FF_REG_b" \n\t"
891  :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
892  "a" (&c->redDither)
893  NAMED_CONSTRAINTS_ADD(ff_M24A,ff_M24C,ff_M24B)
894  );
895 }
896 
897 static void RENAME(yuv2rgb555_2)(SwsContext *c, const int16_t *buf[2],
898  const int16_t *ubuf[2], const int16_t *vbuf[2],
899  const int16_t *abuf[2], uint8_t *dest,
900  int dstW, int yalpha, int uvalpha, int y)
901 {
902  const int16_t *buf0 = buf[0], *buf1 = buf[1],
903  *ubuf0 = ubuf[0], *ubuf1 = ubuf[1];
904 
905  __asm__ volatile(
906  "mov %%"FF_REG_b", "ESP_OFFSET"(%5) \n\t"
907  "mov %4, %%"FF_REG_b" \n\t"
908  "push %%"FF_REG_BP" \n\t"
909  YSCALEYUV2RGB(%%FF_REGBP, %5)
910  "pxor %%mm7, %%mm7 \n\t"
911  /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
912 #ifdef DITHER1XBPP
913  "paddusb "BLUE_DITHER"(%5), %%mm2 \n\t"
914  "paddusb "GREEN_DITHER"(%5), %%mm4 \n\t"
915  "paddusb "RED_DITHER"(%5), %%mm5 \n\t"
916 #endif
917  WRITERGB15(%%FF_REGb, DSTW_OFFSET"(%5)", %%FF_REGBP)
918  "pop %%"FF_REG_BP" \n\t"
919  "mov "ESP_OFFSET"(%5), %%"FF_REG_b" \n\t"
920  :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
921  "a" (&c->redDither)
923  );
924 }
925 
926 static void RENAME(yuv2rgb565_2)(SwsContext *c, const int16_t *buf[2],
927  const int16_t *ubuf[2], const int16_t *vbuf[2],
928  const int16_t *abuf[2], uint8_t *dest,
929  int dstW, int yalpha, int uvalpha, int y)
930 {
931  const int16_t *buf0 = buf[0], *buf1 = buf[1],
932  *ubuf0 = ubuf[0], *ubuf1 = ubuf[1];
933 
934  __asm__ volatile(
935  "mov %%"FF_REG_b", "ESP_OFFSET"(%5) \n\t"
936  "mov %4, %%"FF_REG_b" \n\t"
937  "push %%"FF_REG_BP" \n\t"
938  YSCALEYUV2RGB(%%FF_REGBP, %5)
939  "pxor %%mm7, %%mm7 \n\t"
940  /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
941 #ifdef DITHER1XBPP
942  "paddusb "BLUE_DITHER"(%5), %%mm2 \n\t"
943  "paddusb "GREEN_DITHER"(%5), %%mm4 \n\t"
944  "paddusb "RED_DITHER"(%5), %%mm5 \n\t"
945 #endif
946  WRITERGB16(%%FF_REGb, DSTW_OFFSET"(%5)", %%FF_REGBP)
947  "pop %%"FF_REG_BP" \n\t"
948  "mov "ESP_OFFSET"(%5), %%"FF_REG_b" \n\t"
949  :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
950  "a" (&c->redDither)
951  NAMED_CONSTRAINTS_ADD(bF8,bFC)
952  );
953 }
954 
955 #define REAL_YSCALEYUV2PACKED(index, c) \
956  "movq "CHR_MMX_FILTER_OFFSET"+8("#c"), %%mm0 \n\t"\
957  "movq "LUM_MMX_FILTER_OFFSET"+8("#c"), %%mm1 \n\t"\
958  "psraw $3, %%mm0 \n\t"\
959  "psraw $3, %%mm1 \n\t"\
960  "movq %%mm0, "CHR_MMX_FILTER_OFFSET"+8("#c") \n\t"\
961  "movq %%mm1, "LUM_MMX_FILTER_OFFSET"+8("#c") \n\t"\
962  "xor "#index", "#index" \n\t"\
963  ".p2align 4 \n\t"\
964  "1: \n\t"\
965  "movq (%2, "#index"), %%mm2 \n\t" /* uvbuf0[eax]*/\
966  "movq (%3, "#index"), %%mm3 \n\t" /* uvbuf1[eax]*/\
967  "add "UV_OFF_BYTE"("#c"), "#index" \n\t" \
968  "movq (%2, "#index"), %%mm5 \n\t" /* uvbuf0[eax+2048]*/\
969  "movq (%3, "#index"), %%mm4 \n\t" /* uvbuf1[eax+2048]*/\
970  "sub "UV_OFF_BYTE"("#c"), "#index" \n\t" \
971  "psubw %%mm3, %%mm2 \n\t" /* uvbuf0[eax] - uvbuf1[eax]*/\
972  "psubw %%mm4, %%mm5 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048]*/\
973  "movq "CHR_MMX_FILTER_OFFSET"+8("#c"), %%mm0 \n\t"\
974  "pmulhw %%mm0, %%mm2 \n\t" /* (uvbuf0[eax] - uvbuf1[eax])uvalpha1>>16*/\
975  "pmulhw %%mm0, %%mm5 \n\t" /* (uvbuf0[eax+2048] - uvbuf1[eax+2048])uvalpha1>>16*/\
976  "psraw $7, %%mm3 \n\t" /* uvbuf0[eax] - uvbuf1[eax] >>4*/\
977  "psraw $7, %%mm4 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048] >>4*/\
978  "paddw %%mm2, %%mm3 \n\t" /* uvbuf0[eax]uvalpha1 - uvbuf1[eax](1-uvalpha1)*/\
979  "paddw %%mm5, %%mm4 \n\t" /* uvbuf0[eax+2048]uvalpha1 - uvbuf1[eax+2048](1-uvalpha1)*/\
980  "movq (%0, "#index", 2), %%mm0 \n\t" /*buf0[eax]*/\
981  "movq (%1, "#index", 2), %%mm1 \n\t" /*buf1[eax]*/\
982  "movq 8(%0, "#index", 2), %%mm6 \n\t" /*buf0[eax]*/\
983  "movq 8(%1, "#index", 2), %%mm7 \n\t" /*buf1[eax]*/\
984  "psubw %%mm1, %%mm0 \n\t" /* buf0[eax] - buf1[eax]*/\
985  "psubw %%mm7, %%mm6 \n\t" /* buf0[eax] - buf1[eax]*/\
986  "pmulhw "LUM_MMX_FILTER_OFFSET"+8("#c"), %%mm0 \n\t" /* (buf0[eax] - buf1[eax])yalpha1>>16*/\
987  "pmulhw "LUM_MMX_FILTER_OFFSET"+8("#c"), %%mm6 \n\t" /* (buf0[eax] - buf1[eax])yalpha1>>16*/\
988  "psraw $7, %%mm1 \n\t" /* buf0[eax] - buf1[eax] >>4*/\
989  "psraw $7, %%mm7 \n\t" /* buf0[eax] - buf1[eax] >>4*/\
990  "paddw %%mm0, %%mm1 \n\t" /* buf0[eax]yalpha1 + buf1[eax](1-yalpha1) >>16*/\
991  "paddw %%mm6, %%mm7 \n\t" /* buf0[eax]yalpha1 + buf1[eax](1-yalpha1) >>16*/\
992 
993 #define YSCALEYUV2PACKED(index, c) REAL_YSCALEYUV2PACKED(index, c)
994 
995 static void RENAME(yuv2yuyv422_2)(SwsContext *c, const int16_t *buf[2],
996  const int16_t *ubuf[2], const int16_t *vbuf[2],
997  const int16_t *abuf[2], uint8_t *dest,
998  int dstW, int yalpha, int uvalpha, int y)
999 {
1000  const int16_t *buf0 = buf[0], *buf1 = buf[1],
1001  *ubuf0 = ubuf[0], *ubuf1 = ubuf[1];
1002 
1003  __asm__ volatile(
1004  "mov %%"FF_REG_b", "ESP_OFFSET"(%5) \n\t"
1005  "mov %4, %%"FF_REG_b" \n\t"
1006  "push %%"FF_REG_BP" \n\t"
1007  YSCALEYUV2PACKED(%%FF_REGBP, %5)
1008  WRITEYUY2(%%FF_REGb, DSTW_OFFSET"(%5)", %%FF_REGBP)
1009  "pop %%"FF_REG_BP" \n\t"
1010  "mov "ESP_OFFSET"(%5), %%"FF_REG_b" \n\t"
1011  :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
1012  "a" (&c->redDither)
1013  );
1014 }
1015 
1016 #define REAL_YSCALEYUV2RGB1(index, c) \
1017  "xor "#index", "#index" \n\t"\
1018  ".p2align 4 \n\t"\
1019  "1: \n\t"\
1020  "movq (%2, "#index"), %%mm3 \n\t" /* uvbuf0[eax]*/\
1021  "add "UV_OFF_BYTE"("#c"), "#index" \n\t" \
1022  "movq (%2, "#index"), %%mm4 \n\t" /* uvbuf0[eax+2048]*/\
1023  "sub "UV_OFF_BYTE"("#c"), "#index" \n\t" \
1024  "psraw $4, %%mm3 \n\t" /* uvbuf0[eax] - uvbuf1[eax] >>4*/\
1025  "psraw $4, %%mm4 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048] >>4*/\
1026  "psubw "U_OFFSET"("#c"), %%mm3 \n\t" /* (U-128)8*/\
1027  "psubw "V_OFFSET"("#c"), %%mm4 \n\t" /* (V-128)8*/\
1028  "movq %%mm3, %%mm2 \n\t" /* (U-128)8*/\
1029  "movq %%mm4, %%mm5 \n\t" /* (V-128)8*/\
1030  "pmulhw "UG_COEFF"("#c"), %%mm3 \n\t"\
1031  "pmulhw "VG_COEFF"("#c"), %%mm4 \n\t"\
1032  /* mm2=(U-128)8, mm3=ug, mm4=vg mm5=(V-128)8 */\
1033  "movq (%0, "#index", 2), %%mm1 \n\t" /*buf0[eax]*/\
1034  "movq 8(%0, "#index", 2), %%mm7 \n\t" /*buf0[eax]*/\
1035  "psraw $4, %%mm1 \n\t" /* buf0[eax] - buf1[eax] >>4*/\
1036  "psraw $4, %%mm7 \n\t" /* buf0[eax] - buf1[eax] >>4*/\
1037  "pmulhw "UB_COEFF"("#c"), %%mm2 \n\t"\
1038  "pmulhw "VR_COEFF"("#c"), %%mm5 \n\t"\
1039  "psubw "Y_OFFSET"("#c"), %%mm1 \n\t" /* 8(Y-16)*/\
1040  "psubw "Y_OFFSET"("#c"), %%mm7 \n\t" /* 8(Y-16)*/\
1041  "pmulhw "Y_COEFF"("#c"), %%mm1 \n\t"\
1042  "pmulhw "Y_COEFF"("#c"), %%mm7 \n\t"\
1043  /* mm1= Y1, mm2=ub, mm3=ug, mm4=vg mm5=vr, mm7=Y2 */\
1044  "paddw %%mm3, %%mm4 \n\t"\
1045  "movq %%mm2, %%mm0 \n\t"\
1046  "movq %%mm5, %%mm6 \n\t"\
1047  "movq %%mm4, %%mm3 \n\t"\
1048  "punpcklwd %%mm2, %%mm2 \n\t"\
1049  "punpcklwd %%mm5, %%mm5 \n\t"\
1050  "punpcklwd %%mm4, %%mm4 \n\t"\
1051  "paddw %%mm1, %%mm2 \n\t"\
1052  "paddw %%mm1, %%mm5 \n\t"\
1053  "paddw %%mm1, %%mm4 \n\t"\
1054  "punpckhwd %%mm0, %%mm0 \n\t"\
1055  "punpckhwd %%mm6, %%mm6 \n\t"\
1056  "punpckhwd %%mm3, %%mm3 \n\t"\
1057  "paddw %%mm7, %%mm0 \n\t"\
1058  "paddw %%mm7, %%mm6 \n\t"\
1059  "paddw %%mm7, %%mm3 \n\t"\
1060  /* mm0=B1, mm2=B2, mm3=G2, mm4=G1, mm5=R1, mm6=R2 */\
1061  "packuswb %%mm0, %%mm2 \n\t"\
1062  "packuswb %%mm6, %%mm5 \n\t"\
1063  "packuswb %%mm3, %%mm4 \n\t"\
1064 
1065 #define YSCALEYUV2RGB1(index, c) REAL_YSCALEYUV2RGB1(index, c)
1066 
1067 // do vertical chrominance interpolation
1068 #define REAL_YSCALEYUV2RGB1b(index, c) \
1069  "xor "#index", "#index" \n\t"\
1070  ".p2align 4 \n\t"\
1071  "1: \n\t"\
1072  "movq (%2, "#index"), %%mm2 \n\t" /* uvbuf0[eax]*/\
1073  "movq (%3, "#index"), %%mm3 \n\t" /* uvbuf1[eax]*/\
1074  "add "UV_OFF_BYTE"("#c"), "#index" \n\t" \
1075  "movq (%2, "#index"), %%mm5 \n\t" /* uvbuf0[eax+2048]*/\
1076  "movq (%3, "#index"), %%mm4 \n\t" /* uvbuf1[eax+2048]*/\
1077  "sub "UV_OFF_BYTE"("#c"), "#index" \n\t" \
1078  "paddw %%mm2, %%mm3 \n\t" /* uvbuf0[eax] + uvbuf1[eax]*/\
1079  "paddw %%mm5, %%mm4 \n\t" /* uvbuf0[eax+2048] + uvbuf1[eax+2048]*/\
1080  "psrlw $5, %%mm3 \n\t" /*FIXME might overflow*/\
1081  "psrlw $5, %%mm4 \n\t" /*FIXME might overflow*/\
1082  "psubw "U_OFFSET"("#c"), %%mm3 \n\t" /* (U-128)8*/\
1083  "psubw "V_OFFSET"("#c"), %%mm4 \n\t" /* (V-128)8*/\
1084  "movq %%mm3, %%mm2 \n\t" /* (U-128)8*/\
1085  "movq %%mm4, %%mm5 \n\t" /* (V-128)8*/\
1086  "pmulhw "UG_COEFF"("#c"), %%mm3 \n\t"\
1087  "pmulhw "VG_COEFF"("#c"), %%mm4 \n\t"\
1088  /* mm2=(U-128)8, mm3=ug, mm4=vg mm5=(V-128)8 */\
1089  "movq (%0, "#index", 2), %%mm1 \n\t" /*buf0[eax]*/\
1090  "movq 8(%0, "#index", 2), %%mm7 \n\t" /*buf0[eax]*/\
1091  "psraw $4, %%mm1 \n\t" /* buf0[eax] - buf1[eax] >>4*/\
1092  "psraw $4, %%mm7 \n\t" /* buf0[eax] - buf1[eax] >>4*/\
1093  "pmulhw "UB_COEFF"("#c"), %%mm2 \n\t"\
1094  "pmulhw "VR_COEFF"("#c"), %%mm5 \n\t"\
1095  "psubw "Y_OFFSET"("#c"), %%mm1 \n\t" /* 8(Y-16)*/\
1096  "psubw "Y_OFFSET"("#c"), %%mm7 \n\t" /* 8(Y-16)*/\
1097  "pmulhw "Y_COEFF"("#c"), %%mm1 \n\t"\
1098  "pmulhw "Y_COEFF"("#c"), %%mm7 \n\t"\
1099  /* mm1= Y1, mm2=ub, mm3=ug, mm4=vg mm5=vr, mm7=Y2 */\
1100  "paddw %%mm3, %%mm4 \n\t"\
1101  "movq %%mm2, %%mm0 \n\t"\
1102  "movq %%mm5, %%mm6 \n\t"\
1103  "movq %%mm4, %%mm3 \n\t"\
1104  "punpcklwd %%mm2, %%mm2 \n\t"\
1105  "punpcklwd %%mm5, %%mm5 \n\t"\
1106  "punpcklwd %%mm4, %%mm4 \n\t"\
1107  "paddw %%mm1, %%mm2 \n\t"\
1108  "paddw %%mm1, %%mm5 \n\t"\
1109  "paddw %%mm1, %%mm4 \n\t"\
1110  "punpckhwd %%mm0, %%mm0 \n\t"\
1111  "punpckhwd %%mm6, %%mm6 \n\t"\
1112  "punpckhwd %%mm3, %%mm3 \n\t"\
1113  "paddw %%mm7, %%mm0 \n\t"\
1114  "paddw %%mm7, %%mm6 \n\t"\
1115  "paddw %%mm7, %%mm3 \n\t"\
1116  /* mm0=B1, mm2=B2, mm3=G2, mm4=G1, mm5=R1, mm6=R2 */\
1117  "packuswb %%mm0, %%mm2 \n\t"\
1118  "packuswb %%mm6, %%mm5 \n\t"\
1119  "packuswb %%mm3, %%mm4 \n\t"\
1120 
1121 #define YSCALEYUV2RGB1b(index, c) REAL_YSCALEYUV2RGB1b(index, c)
1122 
1123 #define REAL_YSCALEYUV2RGB1_ALPHA(index) \
1124  "movq (%1, "#index", 2), %%mm7 \n\t" /* abuf0[index ] */\
1125  "movq 8(%1, "#index", 2), %%mm1 \n\t" /* abuf0[index+4] */\
1126  "psraw $7, %%mm7 \n\t" /* abuf0[index ] >>7 */\
1127  "psraw $7, %%mm1 \n\t" /* abuf0[index+4] >>7 */\
1128  "packuswb %%mm1, %%mm7 \n\t"
1129 #define YSCALEYUV2RGB1_ALPHA(index) REAL_YSCALEYUV2RGB1_ALPHA(index)
1130 
1131 /**
1132  * YV12 to RGB without scaling or interpolating
1133  */
1134 static void RENAME(yuv2rgb32_1)(SwsContext *c, const int16_t *buf0,
1135  const int16_t *ubuf[2], const int16_t *vbuf[2],
1136  const int16_t *abuf0, uint8_t *dest,
1137  int dstW, int uvalpha, int y)
1138 {
1139  const int16_t *ubuf0 = ubuf[0];
1140  const int16_t *buf1= buf0; //FIXME needed for RGB1/BGR1
1141 
1142  if (uvalpha < 2048) { // note this is not correct (shifts chrominance by 0.5 pixels) but it is a bit faster
1143  const int16_t *ubuf1 = ubuf[0];
1144  if (CONFIG_SWSCALE_ALPHA && c->needAlpha) {
1145  __asm__ volatile(
1146  "mov %%"FF_REG_b", "ESP_OFFSET"(%5) \n\t"
1147  "mov %4, %%"FF_REG_b" \n\t"
1148  "push %%"FF_REG_BP" \n\t"
1149  YSCALEYUV2RGB1(%%FF_REGBP, %5)
1150  YSCALEYUV2RGB1_ALPHA(%%FF_REGBP)
1151  WRITEBGR32(%%FF_REGb, DSTW_OFFSET"(%5)", %%FF_REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
1152  "pop %%"FF_REG_BP" \n\t"
1153  "mov "ESP_OFFSET"(%5), %%"FF_REG_b" \n\t"
1154  :: "c" (buf0), "d" (abuf0), "S" (ubuf0), "D" (ubuf1), "m" (dest),
1155  "a" (&c->redDither)
1156  );
1157  } else {
1158  __asm__ volatile(
1159  "mov %%"FF_REG_b", "ESP_OFFSET"(%5) \n\t"
1160  "mov %4, %%"FF_REG_b" \n\t"
1161  "push %%"FF_REG_BP" \n\t"
1162  YSCALEYUV2RGB1(%%FF_REGBP, %5)
1163  "pcmpeqd %%mm7, %%mm7 \n\t"
1164  WRITEBGR32(%%FF_REGb, DSTW_OFFSET"(%5)", %%FF_REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
1165  "pop %%"FF_REG_BP" \n\t"
1166  "mov "ESP_OFFSET"(%5), %%"FF_REG_b" \n\t"
1167  :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
1168  "a" (&c->redDither)
1169  );
1170  }
1171  } else {
1172  const int16_t *ubuf1 = ubuf[1];
1173  if (CONFIG_SWSCALE_ALPHA && c->needAlpha) {
1174  __asm__ volatile(
1175  "mov %%"FF_REG_b", "ESP_OFFSET"(%5) \n\t"
1176  "mov %4, %%"FF_REG_b" \n\t"
1177  "push %%"FF_REG_BP" \n\t"
1178  YSCALEYUV2RGB1b(%%FF_REGBP, %5)
1179  YSCALEYUV2RGB1_ALPHA(%%FF_REGBP)
1180  WRITEBGR32(%%FF_REGb, DSTW_OFFSET"(%5)", %%FF_REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
1181  "pop %%"FF_REG_BP" \n\t"
1182  "mov "ESP_OFFSET"(%5), %%"FF_REG_b" \n\t"
1183  :: "c" (buf0), "d" (abuf0), "S" (ubuf0), "D" (ubuf1), "m" (dest),
1184  "a" (&c->redDither)
1185  );
1186  } else {
1187  __asm__ volatile(
1188  "mov %%"FF_REG_b", "ESP_OFFSET"(%5) \n\t"
1189  "mov %4, %%"FF_REG_b" \n\t"
1190  "push %%"FF_REG_BP" \n\t"
1191  YSCALEYUV2RGB1b(%%FF_REGBP, %5)
1192  "pcmpeqd %%mm7, %%mm7 \n\t"
1193  WRITEBGR32(%%FF_REGb, DSTW_OFFSET"(%5)", %%FF_REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
1194  "pop %%"FF_REG_BP" \n\t"
1195  "mov "ESP_OFFSET"(%5), %%"FF_REG_b" \n\t"
1196  :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
1197  "a" (&c->redDither)
1198  );
1199  }
1200  }
1201 }
1202 
1203 static void RENAME(yuv2bgr24_1)(SwsContext *c, const int16_t *buf0,
1204  const int16_t *ubuf[2], const int16_t *vbuf[2],
1205  const int16_t *abuf0, uint8_t *dest,
1206  int dstW, int uvalpha, int y)
1207 {
1208  const int16_t *ubuf0 = ubuf[0];
1209  const int16_t *buf1= buf0; //FIXME needed for RGB1/BGR1
1210 
1211  if (uvalpha < 2048) { // note this is not correct (shifts chrominance by 0.5 pixels) but it is a bit faster
1212  const int16_t *ubuf1 = ubuf[0];
1213  __asm__ volatile(
1214  "mov %%"FF_REG_b", "ESP_OFFSET"(%5) \n\t"
1215  "mov %4, %%"FF_REG_b" \n\t"
1216  "push %%"FF_REG_BP" \n\t"
1217  YSCALEYUV2RGB1(%%FF_REGBP, %5)
1218  "pxor %%mm7, %%mm7 \n\t"
1219  WRITEBGR24(%%FF_REGb, DSTW_OFFSET"(%5)", %%FF_REGBP)
1220  "pop %%"FF_REG_BP" \n\t"
1221  "mov "ESP_OFFSET"(%5), %%"FF_REG_b" \n\t"
1222  :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
1223  "a" (&c->redDither)
1224  NAMED_CONSTRAINTS_ADD(ff_M24A,ff_M24C,ff_M24B)
1225  );
1226  } else {
1227  const int16_t *ubuf1 = ubuf[1];
1228  __asm__ volatile(
1229  "mov %%"FF_REG_b", "ESP_OFFSET"(%5) \n\t"
1230  "mov %4, %%"FF_REG_b" \n\t"
1231  "push %%"FF_REG_BP" \n\t"
1232  YSCALEYUV2RGB1b(%%FF_REGBP, %5)
1233  "pxor %%mm7, %%mm7 \n\t"
1234  WRITEBGR24(%%FF_REGb, DSTW_OFFSET"(%5)", %%FF_REGBP)
1235  "pop %%"FF_REG_BP" \n\t"
1236  "mov "ESP_OFFSET"(%5), %%"FF_REG_b" \n\t"
1237  :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
1238  "a" (&c->redDither)
1239  NAMED_CONSTRAINTS_ADD(ff_M24A,ff_M24C,ff_M24B)
1240  );
1241  }
1242 }
1243 
1244 static void RENAME(yuv2rgb555_1)(SwsContext *c, const int16_t *buf0,
1245  const int16_t *ubuf[2], const int16_t *vbuf[2],
1246  const int16_t *abuf0, uint8_t *dest,
1247  int dstW, int uvalpha, int y)
1248 {
1249  const int16_t *ubuf0 = ubuf[0];
1250  const int16_t *buf1= buf0; //FIXME needed for RGB1/BGR1
1251 
1252  if (uvalpha < 2048) { // note this is not correct (shifts chrominance by 0.5 pixels) but it is a bit faster
1253  const int16_t *ubuf1 = ubuf[0];
1254  __asm__ volatile(
1255  "mov %%"FF_REG_b", "ESP_OFFSET"(%5) \n\t"
1256  "mov %4, %%"FF_REG_b" \n\t"
1257  "push %%"FF_REG_BP" \n\t"
1258  YSCALEYUV2RGB1(%%FF_REGBP, %5)
1259  "pxor %%mm7, %%mm7 \n\t"
1260  /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
1261 #ifdef DITHER1XBPP
1262  "paddusb "BLUE_DITHER"(%5), %%mm2 \n\t"
1263  "paddusb "GREEN_DITHER"(%5), %%mm4 \n\t"
1264  "paddusb "RED_DITHER"(%5), %%mm5 \n\t"
1265 #endif
1266  WRITERGB15(%%FF_REGb, DSTW_OFFSET"(%5)", %%FF_REGBP)
1267  "pop %%"FF_REG_BP" \n\t"
1268  "mov "ESP_OFFSET"(%5), %%"FF_REG_b" \n\t"
1269  :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
1270  "a" (&c->redDither)
1272  );
1273  } else {
1274  const int16_t *ubuf1 = ubuf[1];
1275  __asm__ volatile(
1276  "mov %%"FF_REG_b", "ESP_OFFSET"(%5) \n\t"
1277  "mov %4, %%"FF_REG_b" \n\t"
1278  "push %%"FF_REG_BP" \n\t"
1279  YSCALEYUV2RGB1b(%%FF_REGBP, %5)
1280  "pxor %%mm7, %%mm7 \n\t"
1281  /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
1282 #ifdef DITHER1XBPP
1283  "paddusb "BLUE_DITHER"(%5), %%mm2 \n\t"
1284  "paddusb "GREEN_DITHER"(%5), %%mm4 \n\t"
1285  "paddusb "RED_DITHER"(%5), %%mm5 \n\t"
1286 #endif
1287  WRITERGB15(%%FF_REGb, DSTW_OFFSET"(%5)", %%FF_REGBP)
1288  "pop %%"FF_REG_BP" \n\t"
1289  "mov "ESP_OFFSET"(%5), %%"FF_REG_b" \n\t"
1290  :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
1291  "a" (&c->redDither)
1293  );
1294  }
1295 }
1296 
1297 static void RENAME(yuv2rgb565_1)(SwsContext *c, const int16_t *buf0,
1298  const int16_t *ubuf[2], const int16_t *vbuf[2],
1299  const int16_t *abuf0, uint8_t *dest,
1300  int dstW, int uvalpha, int y)
1301 {
1302  const int16_t *ubuf0 = ubuf[0];
1303  const int16_t *buf1= buf0; //FIXME needed for RGB1/BGR1
1304 
1305  if (uvalpha < 2048) { // note this is not correct (shifts chrominance by 0.5 pixels) but it is a bit faster
1306  const int16_t *ubuf1 = ubuf[0];
1307  __asm__ volatile(
1308  "mov %%"FF_REG_b", "ESP_OFFSET"(%5) \n\t"
1309  "mov %4, %%"FF_REG_b" \n\t"
1310  "push %%"FF_REG_BP" \n\t"
1311  YSCALEYUV2RGB1(%%FF_REGBP, %5)
1312  "pxor %%mm7, %%mm7 \n\t"
1313  /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
1314 #ifdef DITHER1XBPP
1315  "paddusb "BLUE_DITHER"(%5), %%mm2 \n\t"
1316  "paddusb "GREEN_DITHER"(%5), %%mm4 \n\t"
1317  "paddusb "RED_DITHER"(%5), %%mm5 \n\t"
1318 #endif
1319  WRITERGB16(%%FF_REGb, DSTW_OFFSET"(%5)", %%FF_REGBP)
1320  "pop %%"FF_REG_BP" \n\t"
1321  "mov "ESP_OFFSET"(%5), %%"FF_REG_b" \n\t"
1322  :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
1323  "a" (&c->redDither)
1324  NAMED_CONSTRAINTS_ADD(bF8,bFC)
1325  );
1326  } else {
1327  const int16_t *ubuf1 = ubuf[1];
1328  __asm__ volatile(
1329  "mov %%"FF_REG_b", "ESP_OFFSET"(%5) \n\t"
1330  "mov %4, %%"FF_REG_b" \n\t"
1331  "push %%"FF_REG_BP" \n\t"
1332  YSCALEYUV2RGB1b(%%FF_REGBP, %5)
1333  "pxor %%mm7, %%mm7 \n\t"
1334  /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
1335 #ifdef DITHER1XBPP
1336  "paddusb "BLUE_DITHER"(%5), %%mm2 \n\t"
1337  "paddusb "GREEN_DITHER"(%5), %%mm4 \n\t"
1338  "paddusb "RED_DITHER"(%5), %%mm5 \n\t"
1339 #endif
1340  WRITERGB16(%%FF_REGb, DSTW_OFFSET"(%5)", %%FF_REGBP)
1341  "pop %%"FF_REG_BP" \n\t"
1342  "mov "ESP_OFFSET"(%5), %%"FF_REG_b" \n\t"
1343  :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
1344  "a" (&c->redDither)
1345  NAMED_CONSTRAINTS_ADD(bF8,bFC)
1346  );
1347  }
1348 }
1349 
1350 #define REAL_YSCALEYUV2PACKED1(index, c) \
1351  "xor "#index", "#index" \n\t"\
1352  ".p2align 4 \n\t"\
1353  "1: \n\t"\
1354  "movq (%2, "#index"), %%mm3 \n\t" /* uvbuf0[eax]*/\
1355  "add "UV_OFF_BYTE"("#c"), "#index" \n\t" \
1356  "movq (%2, "#index"), %%mm4 \n\t" /* uvbuf0[eax+2048]*/\
1357  "sub "UV_OFF_BYTE"("#c"), "#index" \n\t" \
1358  "psraw $7, %%mm3 \n\t" \
1359  "psraw $7, %%mm4 \n\t" \
1360  "movq (%0, "#index", 2), %%mm1 \n\t" /*buf0[eax]*/\
1361  "movq 8(%0, "#index", 2), %%mm7 \n\t" /*buf0[eax]*/\
1362  "psraw $7, %%mm1 \n\t" \
1363  "psraw $7, %%mm7 \n\t" \
1364 
1365 #define YSCALEYUV2PACKED1(index, c) REAL_YSCALEYUV2PACKED1(index, c)
1366 
1367 #define REAL_YSCALEYUV2PACKED1b(index, c) \
1368  "xor "#index", "#index" \n\t"\
1369  ".p2align 4 \n\t"\
1370  "1: \n\t"\
1371  "movq (%2, "#index"), %%mm2 \n\t" /* uvbuf0[eax]*/\
1372  "movq (%3, "#index"), %%mm3 \n\t" /* uvbuf1[eax]*/\
1373  "add "UV_OFF_BYTE"("#c"), "#index" \n\t" \
1374  "movq (%2, "#index"), %%mm5 \n\t" /* uvbuf0[eax+2048]*/\
1375  "movq (%3, "#index"), %%mm4 \n\t" /* uvbuf1[eax+2048]*/\
1376  "sub "UV_OFF_BYTE"("#c"), "#index" \n\t" \
1377  "paddw %%mm2, %%mm3 \n\t" /* uvbuf0[eax] + uvbuf1[eax]*/\
1378  "paddw %%mm5, %%mm4 \n\t" /* uvbuf0[eax+2048] + uvbuf1[eax+2048]*/\
1379  "psrlw $8, %%mm3 \n\t" \
1380  "psrlw $8, %%mm4 \n\t" \
1381  "movq (%0, "#index", 2), %%mm1 \n\t" /*buf0[eax]*/\
1382  "movq 8(%0, "#index", 2), %%mm7 \n\t" /*buf0[eax]*/\
1383  "psraw $7, %%mm1 \n\t" \
1384  "psraw $7, %%mm7 \n\t"
1385 #define YSCALEYUV2PACKED1b(index, c) REAL_YSCALEYUV2PACKED1b(index, c)
1386 
1387 static void RENAME(yuv2yuyv422_1)(SwsContext *c, const int16_t *buf0,
1388  const int16_t *ubuf[2], const int16_t *vbuf[2],
1389  const int16_t *abuf0, uint8_t *dest,
1390  int dstW, int uvalpha, int y)
1391 {
1392  const int16_t *ubuf0 = ubuf[0];
1393  const int16_t *buf1= buf0; //FIXME needed for RGB1/BGR1
1394 
1395  if (uvalpha < 2048) { // note this is not correct (shifts chrominance by 0.5 pixels) but it is a bit faster
1396  const int16_t *ubuf1 = ubuf[0];
1397  __asm__ volatile(
1398  "mov %%"FF_REG_b", "ESP_OFFSET"(%5) \n\t"
1399  "mov %4, %%"FF_REG_b" \n\t"
1400  "push %%"FF_REG_BP" \n\t"
1401  YSCALEYUV2PACKED1(%%FF_REGBP, %5)
1402  WRITEYUY2(%%FF_REGb, DSTW_OFFSET"(%5)", %%FF_REGBP)
1403  "pop %%"FF_REG_BP" \n\t"
1404  "mov "ESP_OFFSET"(%5), %%"FF_REG_b" \n\t"
1405  :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
1406  "a" (&c->redDither)
1407  );
1408  } else {
1409  const int16_t *ubuf1 = ubuf[1];
1410  __asm__ volatile(
1411  "mov %%"FF_REG_b", "ESP_OFFSET"(%5) \n\t"
1412  "mov %4, %%"FF_REG_b" \n\t"
1413  "push %%"FF_REG_BP" \n\t"
1414  YSCALEYUV2PACKED1b(%%FF_REGBP, %5)
1415  WRITEYUY2(%%FF_REGb, DSTW_OFFSET"(%5)", %%FF_REGBP)
1416  "pop %%"FF_REG_BP" \n\t"
1417  "mov "ESP_OFFSET"(%5), %%"FF_REG_b" \n\t"
1418  :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
1419  "a" (&c->redDither)
1420  );
1421  }
1422 }
1424 {
1425  enum AVPixelFormat dstFormat = c->dstFormat;
1426  av_unused const int use_mmxext_packed_writers = !(c->flags & SWS_FULL_CHR_H_INT) &&
1427  c->dstW >= 8 && !(c->dstW & 1);
1428 
1429  c->use_mmx_vfilter= 0;
1430  if (!is16BPS(dstFormat) && !isNBPS(dstFormat) && !isSemiPlanarYUV(dstFormat)
1431  && dstFormat != AV_PIX_FMT_GRAYF32BE && dstFormat != AV_PIX_FMT_GRAYF32LE
1432  && !(c->flags & SWS_BITEXACT)) {
1433  if (c->flags & SWS_ACCURATE_RND) {
1434  if (use_mmxext_packed_writers) {
1435  switch (c->dstFormat) {
1436  case AV_PIX_FMT_RGB32: c->yuv2packedX = RENAME(yuv2rgb32_X_ar); break;
1437 #if HAVE_6REGS
1438  case AV_PIX_FMT_BGR24: c->yuv2packedX = RENAME(yuv2bgr24_X_ar); break;
1439 #endif
1440  case AV_PIX_FMT_RGB555: c->yuv2packedX = RENAME(yuv2rgb555_X_ar); break;
1441  case AV_PIX_FMT_RGB565: c->yuv2packedX = RENAME(yuv2rgb565_X_ar); break;
1442  case AV_PIX_FMT_YUYV422: c->yuv2packedX = RENAME(yuv2yuyv422_X_ar); break;
1443  default: break;
1444  }
1445  }
1446  } else {
1447  c->use_mmx_vfilter= 1;
1448  if (use_mmxext_packed_writers) {
1449  switch (c->dstFormat) {
1450  case AV_PIX_FMT_RGB32: c->yuv2packedX = RENAME(yuv2rgb32_X); break;
1451  case AV_PIX_FMT_BGR32: c->yuv2packedX = RENAME(yuv2bgr32_X); break;
1452 #if HAVE_6REGS
1453  case AV_PIX_FMT_BGR24: c->yuv2packedX = RENAME(yuv2bgr24_X); break;
1454 #endif
1455  case AV_PIX_FMT_RGB555: c->yuv2packedX = RENAME(yuv2rgb555_X); break;
1456  case AV_PIX_FMT_RGB565: c->yuv2packedX = RENAME(yuv2rgb565_X); break;
1457  case AV_PIX_FMT_YUYV422: c->yuv2packedX = RENAME(yuv2yuyv422_X); break;
1458  default: break;
1459  }
1460  }
1461  }
1462  if (use_mmxext_packed_writers) {
1463  switch (c->dstFormat) {
1464  case AV_PIX_FMT_RGB32:
1465  c->yuv2packed1 = RENAME(yuv2rgb32_1);
1466  c->yuv2packed2 = RENAME(yuv2rgb32_2);
1467  break;
1468  case AV_PIX_FMT_BGR24:
1469  c->yuv2packed1 = RENAME(yuv2bgr24_1);
1470  c->yuv2packed2 = RENAME(yuv2bgr24_2);
1471  break;
1472  case AV_PIX_FMT_RGB555:
1473  c->yuv2packed1 = RENAME(yuv2rgb555_1);
1474  c->yuv2packed2 = RENAME(yuv2rgb555_2);
1475  break;
1476  case AV_PIX_FMT_RGB565:
1477  c->yuv2packed1 = RENAME(yuv2rgb565_1);
1478  c->yuv2packed2 = RENAME(yuv2rgb565_2);
1479  break;
1480  case AV_PIX_FMT_YUYV422:
1481  c->yuv2packed1 = RENAME(yuv2yuyv422_1);
1482  c->yuv2packed2 = RENAME(yuv2yuyv422_2);
1483  break;
1484  default:
1485  break;
1486  }
1487  }
1488  }
1489 
1490  if (c->srcBpc == 8 && c->dstBpc <= 14) {
1491  // Use the new MMX scaler if the MMXEXT one can't be used (it is faster than the x86 ASM one).
1492 #if COMPILE_TEMPLATE_MMXEXT
1493  if (c->flags & SWS_FAST_BILINEAR && c->canMMXEXTBeUsed) {
1494  c->hyscale_fast = ff_hyscale_fast_mmxext;
1495  c->hcscale_fast = ff_hcscale_fast_mmxext;
1496  } else {
1497 #endif /* COMPILE_TEMPLATE_MMXEXT */
1498  c->hyscale_fast = NULL;
1499  c->hcscale_fast = NULL;
1500 #if COMPILE_TEMPLATE_MMXEXT
1501  }
1502 #endif /* COMPILE_TEMPLATE_MMXEXT */
1503  }
1504 }
__asm__(".macro parse_r var r\n\t" "\\var = -1\n\t" _IFC_REG(0) _IFC_REG(1) _IFC_REG(2) _IFC_REG(3) _IFC_REG(4) _IFC_REG(5) _IFC_REG(6) _IFC_REG(7) _IFC_REG(8) _IFC_REG(9) _IFC_REG(10) _IFC_REG(11) _IFC_REG(12) _IFC_REG(13) _IFC_REG(14) _IFC_REG(15) _IFC_REG(16) _IFC_REG(17) _IFC_REG(18) _IFC_REG(19) _IFC_REG(20) _IFC_REG(21) _IFC_REG(22) _IFC_REG(23) _IFC_REG(24) _IFC_REG(25) _IFC_REG(26) _IFC_REG(27) _IFC_REG(28) _IFC_REG(29) _IFC_REG(30) _IFC_REG(31) ".iflt \\var\n\t" ".error \"Unable to parse register name \\r\"\n\t" ".endif\n\t" ".endm")
#define av_unused
Definition: attributes.h:131
#define av_cold
Definition: attributes.h:88
uint8_t
#define CONFIG_SWSCALE_ALPHA
Definition: config.h:568
#define NULL
Definition: coverity.c:32
#define RENAME(name)
Definition: ffv1.h:197
#define SWS_BITEXACT
Definition: swscale.h:84
#define SWS_ACCURATE_RND
Definition: swscale.h:83
#define SWS_FULL_CHR_H_INT
Definition: swscale.h:79
#define SWS_FAST_BILINEAR
Definition: swscale.h:58
#define NAMED_CONSTRAINTS_ADD(...)
Definition: asm.h:145
int x86_reg
Definition: asm.h:72
int dummy
Definition: motion.c:64
#define AV_PIX_FMT_BGR32
Definition: pixfmt.h:374
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
@ AV_PIX_FMT_GRAYF32LE
IEEE-754 single precision Y, 32bpp, little-endian.
Definition: pixfmt.h:341
@ AV_PIX_FMT_GRAYF32BE
IEEE-754 single precision Y, 32bpp, big-endian.
Definition: pixfmt.h:340
@ AV_PIX_FMT_YUYV422
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
Definition: pixfmt.h:67
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:69
#define AV_PIX_FMT_RGB565
Definition: pixfmt.h:386
#define AV_PIX_FMT_RGB32
Definition: pixfmt.h:372
#define AV_PIX_FMT_RGB555
Definition: pixfmt.h:387
#define Y_TEMP
#define RED_DITHER
#define ALP_MMX_FILTER_OFFSET
#define ESP_OFFSET
static av_always_inline int is16BPS(enum AVPixelFormat pix_fmt)
#define BLUE_DITHER
#define V_TEMP
#define GREEN_DITHER
#define DSTW_OFFSET
static av_always_inline int isSemiPlanarYUV(enum AVPixelFormat pix_fmt)
#define U_TEMP
void ff_hyscale_fast_mmxext(SwsContext *c, int16_t *dst, int dstWidth, const uint8_t *src, int srcW, int xInc)
void ff_hcscale_fast_mmxext(SwsContext *c, int16_t *dst1, int16_t *dst2, int dstWidth, const uint8_t *src1, const uint8_t *src2, int srcW, int xInc)
static av_always_inline int isNBPS(enum AVPixelFormat pix_fmt)
#define WRITEBGR24(dst, dstw, index)
#define YSCALEYUV2PACKED(index, c)
#define YSCALEYUV2RGB1_ALPHA(index)
static void RENAME() yuv2rgb565_X(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, const int16_t **alpSrc, uint8_t *dest, int dstW, int dstY)
static void RENAME() yuv2yuyv422_1(SwsContext *c, const int16_t *buf0, const int16_t *ubuf[2], const int16_t *vbuf[2], const int16_t *abuf0, uint8_t *dest, int dstW, int uvalpha, int y)
#define YSCALEYUV2PACKEDX
#define YSCALEYUV2PACKEDX_YA(offset, coeff, src1, src2, dst1, dst2)
static av_cold void RENAME() sws_init_swscale(SwsContext *c)
static void RENAME() yuv2bgr24_2(SwsContext *c, const int16_t *buf[2], const int16_t *ubuf[2], const int16_t *vbuf[2], const int16_t *abuf[2], uint8_t *dest, int dstW, int yalpha, int uvalpha, int y)
static void RENAME() yuv2rgb555_2(SwsContext *c, const int16_t *buf[2], const int16_t *ubuf[2], const int16_t *vbuf[2], const int16_t *abuf[2], uint8_t *dest, int dstW, int yalpha, int uvalpha, int y)
#define YSCALEYUV2RGB1(index, c)
static void RENAME() yuv2rgb565_2(SwsContext *c, const int16_t *buf[2], const int16_t *ubuf[2], const int16_t *vbuf[2], const int16_t *abuf[2], uint8_t *dest, int dstW, int yalpha, int uvalpha, int y)
static void RENAME() yuv2bgr24_1(SwsContext *c, const int16_t *buf0, const int16_t *ubuf[2], const int16_t *vbuf[2], const int16_t *abuf0, uint8_t *dest, int dstW, int uvalpha, int y)
#define YSCALEYUV2PACKED1(index, c)
static void RENAME() yuv2yuyv422_2(SwsContext *c, const int16_t *buf[2], const int16_t *ubuf[2], const int16_t *vbuf[2], const int16_t *abuf[2], uint8_t *dest, int dstW, int yalpha, int uvalpha, int y)
static void RENAME() yuv2rgb565_X_ar(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, const int16_t **alpSrc, uint8_t *dest, int dstW, int dstY)
static void RENAME() yuv2rgb32_2(SwsContext *c, const int16_t *buf[2], const int16_t *ubuf[2], const int16_t *vbuf[2], const int16_t *abuf[2], uint8_t *dest, int dstW, int yalpha, int uvalpha, int y)
vertical bilinear scale YV12 to RGB
static void RENAME() yuv2yuyv422_X(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, const int16_t **alpSrc, uint8_t *dest, int dstW, int dstY)
static void RENAME() yuv2rgb555_X_ar(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, const int16_t **alpSrc, uint8_t *dest, int dstW, int dstY)
#define WRITERGB16(dst, dstw, index)
static void RENAME() yuv2rgb555_1(SwsContext *c, const int16_t *buf0, const int16_t *ubuf[2], const int16_t *vbuf[2], const int16_t *abuf0, uint8_t *dest, int dstW, int uvalpha, int y)
#define YSCALEYUV2RGB_YA(index, c, b1, b2)
#define YSCALEYUV2RGB1b(index, c)
static void RENAME() yuv2rgb565_1(SwsContext *c, const int16_t *buf0, const int16_t *ubuf[2], const int16_t *vbuf[2], const int16_t *abuf0, uint8_t *dest, int dstW, int uvalpha, int y)
static void RENAME() yuv2bgr32_X(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, const int16_t **alpSrc, uint8_t *dest, int dstW, int dstY)
static void RENAME() yuv2rgb555_X(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, const int16_t **alpSrc, uint8_t *dest, int dstW, int dstY)
static void RENAME() yuv2yuyv422_X_ar(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, const int16_t **alpSrc, uint8_t *dest, int dstW, int dstY)
static void RENAME() yuv2rgb32_X_ar(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, const int16_t **alpSrc, uint8_t *dest, int dstW, int dstY)
#define YSCALEYUV2RGBX
#define WRITERGB15(dst, dstw, index)
#define YSCALEYUV2RGB(index, c)
#define WRITEYUY2(dst, dstw, index)
static void RENAME() yuv2rgb32_X(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, const int16_t **alpSrc, uint8_t *dest, int dstW, int dstY)
#define YSCALEYUV2PACKEDX_END
#define YSCALEYUV2PACKEDX_ACCURATE
static void RENAME() yuv2rgb32_1(SwsContext *c, const int16_t *buf0, const int16_t *ubuf[2], const int16_t *vbuf[2], const int16_t *abuf0, uint8_t *dest, int dstW, int uvalpha, int y)
YV12 to RGB without scaling or interpolating.
#define YSCALEYUV2PACKED1b(index, c)
#define WRITEBGR32(dst, dstw, index, b, g, r, a, q0, q2, q3, t)
#define YSCALEYUV2PACKEDX_ACCURATE_YA(offset)
static double c[64]