Skip to content

Commit ac62639

Browse files
committed
swscale/x86/yuv2rgb: Detemplatize
Every function in yuv2rgb_template.c is only compiled exactly once, so detemplatize it.
1 parent 4f7f9b1 commit ac62639

File tree

2 files changed

+162
-193
lines changed

2 files changed

+162
-193
lines changed

libswscale/x86/yuv2rgb.c

Lines changed: 162 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/*
22
* software YUV to RGB converter
33
*
4-
* Copyright (C) 2009 Konstantin Shishkov
4+
* Copyright (C) 2001-2007 Michael Niedermayer
5+
* Copyright (C) 2009-2010 Konstantin Shishkov
56
*
67
* MMX/MMXEXT template stuff (needed for fast movntq support),
78
* 1,4,8bpp support and context / deglobalize stuff
@@ -39,10 +40,166 @@
3940

4041
#if HAVE_X86ASM
4142

42-
//SSSE3 versions
43-
#undef RENAME
44-
#define RENAME(a) a ## _ssse3
45-
#include "yuv2rgb_template.c"
43+
#define YUV2RGB_LOOP(depth) \
44+
h_size = (c->dstW + 7) & ~7; \
45+
if (h_size * depth > FFABS(dstStride[0])) \
46+
h_size -= 8; \
47+
\
48+
vshift = c->srcFormat != AV_PIX_FMT_YUV422P; \
49+
\
50+
for (y = 0; y < srcSliceH; y++) { \
51+
uint8_t *image = dst[0] + (y + srcSliceY) * dstStride[0]; \
52+
const uint8_t *py = src[0] + y * srcStride[0]; \
53+
const uint8_t *pu = src[1] + (y >> vshift) * srcStride[1]; \
54+
const uint8_t *pv = src[2] + (y >> vshift) * srcStride[2]; \
55+
x86_reg index = -h_size / 2; \
56+
57+
extern void ff_yuv_420_rgb24_ssse3(x86_reg index, uint8_t *image, const uint8_t *pu_index,
58+
const uint8_t *pv_index, const uint64_t *pointer_c_dither,
59+
const uint8_t *py_2index);
60+
extern void ff_yuv_420_bgr24_ssse3(x86_reg index, uint8_t *image, const uint8_t *pu_index,
61+
const uint8_t *pv_index, const uint64_t *pointer_c_dither,
62+
const uint8_t *py_2index);
63+
64+
extern void ff_yuv_420_rgb15_ssse3(x86_reg index, uint8_t *image, const uint8_t *pu_index,
65+
const uint8_t *pv_index, const uint64_t *pointer_c_dither,
66+
const uint8_t *py_2index);
67+
extern void ff_yuv_420_rgb16_ssse3(x86_reg index, uint8_t *image, const uint8_t *pu_index,
68+
const uint8_t *pv_index, const uint64_t *pointer_c_dither,
69+
const uint8_t *py_2index);
70+
extern void ff_yuv_420_rgb32_ssse3(x86_reg index, uint8_t *image, const uint8_t *pu_index,
71+
const uint8_t *pv_index, const uint64_t *pointer_c_dither,
72+
const uint8_t *py_2index);
73+
extern void ff_yuv_420_bgr32_ssse3(x86_reg index, uint8_t *image, const uint8_t *pu_index,
74+
const uint8_t *pv_index, const uint64_t *pointer_c_dither,
75+
const uint8_t *py_2index);
76+
extern void ff_yuva_420_rgb32_ssse3(x86_reg index, uint8_t *image, const uint8_t *pu_index,
77+
const uint8_t *pv_index, const uint64_t *pointer_c_dither,
78+
const uint8_t *py_2index, const uint8_t *pa_2index);
79+
extern void ff_yuva_420_bgr32_ssse3(x86_reg index, uint8_t *image, const uint8_t *pu_index,
80+
const uint8_t *pv_index, const uint64_t *pointer_c_dither,
81+
const uint8_t *py_2index, const uint8_t *pa_2index);
82+
83+
static inline int yuv420_rgb15_ssse3(SwsContext *c, const uint8_t *src[],
84+
int srcStride[],
85+
int srcSliceY, int srcSliceH,
86+
uint8_t *dst[], int dstStride[])
87+
{
88+
int y, h_size, vshift;
89+
90+
YUV2RGB_LOOP(2)
91+
92+
c->blueDither = ff_dither8[y & 1];
93+
c->greenDither = ff_dither8[y & 1];
94+
c->redDither = ff_dither8[(y + 1) & 1];
95+
96+
ff_yuv_420_rgb15_ssse3(index, image, pu - index, pv - index, &(c->redDither), py - 2 * index);
97+
}
98+
return srcSliceH;
99+
}
100+
101+
static inline int yuv420_rgb16_ssse3(SwsContext *c, const uint8_t *src[],
102+
int srcStride[],
103+
int srcSliceY, int srcSliceH,
104+
uint8_t *dst[], int dstStride[])
105+
{
106+
int y, h_size, vshift;
107+
108+
YUV2RGB_LOOP(2)
109+
110+
c->blueDither = ff_dither8[y & 1];
111+
c->greenDither = ff_dither4[y & 1];
112+
c->redDither = ff_dither8[(y + 1) & 1];
113+
114+
ff_yuv_420_rgb16_ssse3(index, image, pu - index, pv - index, &(c->redDither), py - 2 * index);
115+
}
116+
return srcSliceH;
117+
}
118+
119+
static inline int yuv420_rgb32_ssse3(SwsContext *c, const uint8_t *src[],
120+
int srcStride[],
121+
int srcSliceY, int srcSliceH,
122+
uint8_t *dst[], int dstStride[])
123+
{
124+
int y, h_size, vshift;
125+
126+
YUV2RGB_LOOP(4)
127+
128+
ff_yuv_420_rgb32_ssse3(index, image, pu - index, pv - index, &(c->redDither), py - 2 * index);
129+
}
130+
return srcSliceH;
131+
}
132+
133+
static inline int yuv420_bgr32_ssse3(SwsContext *c, const uint8_t *src[],
134+
int srcStride[],
135+
int srcSliceY, int srcSliceH,
136+
uint8_t *dst[], int dstStride[])
137+
{
138+
int y, h_size, vshift;
139+
140+
YUV2RGB_LOOP(4)
141+
142+
ff_yuv_420_bgr32_ssse3(index, image, pu - index, pv - index, &(c->redDither), py - 2 * index);
143+
}
144+
return srcSliceH;
145+
}
146+
147+
static inline int yuva420_rgb32_ssse3(SwsContext *c, const uint8_t *src[],
148+
int srcStride[],
149+
int srcSliceY, int srcSliceH,
150+
uint8_t *dst[], int dstStride[])
151+
{
152+
int y, h_size, vshift;
153+
YUV2RGB_LOOP(4)
154+
155+
const uint8_t *pa = src[3] + y * srcStride[3];
156+
ff_yuva_420_rgb32_ssse3(index, image, pu - index, pv - index, &(c->redDither), py - 2 * index, pa - 2 * index);
157+
}
158+
return srcSliceH;
159+
}
160+
161+
static inline int yuva420_bgr32_ssse3(SwsContext *c, const uint8_t *src[],
162+
int srcStride[],
163+
int srcSliceY, int srcSliceH,
164+
uint8_t *dst[], int dstStride[])
165+
{
166+
int y, h_size, vshift;
167+
168+
YUV2RGB_LOOP(4)
169+
170+
const uint8_t *pa = src[3] + y * srcStride[3];
171+
ff_yuva_420_bgr32_ssse3(index, image, pu - index, pv - index, &(c->redDither), py - 2 * index, pa - 2 * index);
172+
}
173+
return srcSliceH;
174+
}
175+
176+
static inline int yuv420_rgb24_ssse3(SwsContext *c, const uint8_t *src[],
177+
int srcStride[],
178+
int srcSliceY, int srcSliceH,
179+
uint8_t *dst[], int dstStride[])
180+
{
181+
int y, h_size, vshift;
182+
183+
YUV2RGB_LOOP(3)
184+
185+
ff_yuv_420_rgb24_ssse3(index, image, pu - index, pv - index, &(c->redDither), py - 2 * index);
186+
}
187+
return srcSliceH;
188+
}
189+
190+
static inline int yuv420_bgr24_ssse3(SwsContext *c, const uint8_t *src[],
191+
int srcStride[],
192+
int srcSliceY, int srcSliceH,
193+
uint8_t *dst[], int dstStride[])
194+
{
195+
int y, h_size, vshift;
196+
197+
YUV2RGB_LOOP(3)
198+
199+
ff_yuv_420_bgr24_ssse3(index, image, pu - index, pv - index, &(c->redDither), py - 2 * index);
200+
}
201+
return srcSliceH;
202+
}
46203

47204
#endif /* HAVE_X86ASM */
48205

libswscale/x86/yuv2rgb_template.c

Lines changed: 0 additions & 188 deletions
This file was deleted.

0 commit comments

Comments
 (0)