42 0x0200020002000200LL,};
46 0x0004000400040004LL,};
60 DECLARE_ALIGNED(8,
const uint64_t, ff_bgr2YCoeff) = 0x000000210041000DULL;
61 DECLARE_ALIGNED(8,
const uint64_t, ff_bgr2UCoeff) = 0x0000FFEEFFDC0038ULL;
62 DECLARE_ALIGNED(8,
const uint64_t, ff_bgr2VCoeff) = 0x00000038FFD2FFF8ULL;
64 DECLARE_ALIGNED(8,
const uint64_t, ff_bgr2YCoeff) = 0x000020E540830C8BULL;
65 DECLARE_ALIGNED(8,
const uint64_t, ff_bgr2UCoeff) = 0x0000ED0FDAC23831ULL;
66 DECLARE_ALIGNED(8,
const uint64_t, ff_bgr2VCoeff) = 0x00003831D0E6F6EAULL;
68 DECLARE_ALIGNED(8,
const uint64_t, ff_bgr2YOffset) = 0x1010101010101010ULL;
69 DECLARE_ALIGNED(8,
const uint64_t, ff_bgr2UVOffset) = 0x8080808080808080ULL;
75 #define COMPILE_TEMPLATE_MMXEXT 0 76 #define RENAME(a) a ## _mmx 81 #if HAVE_MMXEXT_INLINE 83 #undef COMPILE_TEMPLATE_MMXEXT 84 #define COMPILE_TEMPLATE_MMXEXT 1 85 #define RENAME(a) a ## _mmxext 109 const int firstLumSrcY= vLumFilterPos[
dstY];
110 const int firstChrSrcY= vChrFilterPos[chrDstY];
118 if (dstY < dstH - 2) {
119 const int16_t **lumSrcPtr= (
const int16_t **) lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
120 const int16_t **chrUSrcPtr= (
const int16_t **) chrUPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
124 if (firstLumSrcY < 0 || firstLumSrcY + vLumFilterSize > c->
srcH) {
125 const int16_t **tmpY = (
const int16_t **) lumPixBuf + 2 * vLumBufSize;
126 int neg = -firstLumSrcY, i, end =
FFMIN(c->
srcH - firstLumSrcY, vLumFilterSize);
127 for (i = 0; i < neg; i++)
128 tmpY[i] = lumSrcPtr[neg];
129 for ( ; i < end; i++)
130 tmpY[i] = lumSrcPtr[i];
136 const int16_t **tmpA = (
const int16_t **) alpPixBuf + 2 * vLumBufSize;
137 for (i = 0; i < neg; i++)
138 tmpA[i] = alpSrcPtr[neg];
139 for ( ; i < end; i++)
140 tmpA[i] = alpSrcPtr[i];
142 tmpA[i] = tmpA[i - 1];
146 if (firstChrSrcY < 0 || firstChrSrcY + vChrFilterSize > c->
chrSrcH) {
147 const int16_t **tmpU = (
const int16_t **) chrUPixBuf + 2 * vChrBufSize;
148 int neg = -firstChrSrcY, i, end =
FFMIN(c->
chrSrcH - firstChrSrcY, vChrFilterSize);
149 for (i = 0; i < neg; i++) {
150 tmpU[i] = chrUSrcPtr[neg];
152 for ( ; i < end; i++) {
153 tmpU[i] = chrUSrcPtr[i];
156 tmpU[i] = tmpU[i - 1];
164 *(
const void**)&lumMmxFilter[s*i ]= lumSrcPtr[i ];
165 *(
const void**)&lumMmxFilter[s*i+
APCK_PTR2/4 ]= lumSrcPtr[i+(vLumFilterSize>1)];
167 lumMmxFilter[s*i+
APCK_COEF/4+1]= vLumFilter[dstY*vLumFilterSize + i ]
168 + (vLumFilterSize>1 ? vLumFilter[dstY*vLumFilterSize + i + 1]<<16 : 0);
170 *(
const void**)&alpMmxFilter[s*i ]= alpSrcPtr[i ];
171 *(
const void**)&alpMmxFilter[s*i+
APCK_PTR2/4 ]= alpSrcPtr[i+(vLumFilterSize>1)];
177 *(
const void**)&chrMmxFilter[s*i ]= chrUSrcPtr[i ];
178 *(
const void**)&chrMmxFilter[s*i+
APCK_PTR2/4 ]= chrUSrcPtr[i+(vChrFilterSize>1)];
180 chrMmxFilter[s*i+
APCK_COEF/4+1]= vChrFilter[chrDstY*vChrFilterSize + i ]
181 + (vChrFilterSize>1 ? vChrFilter[chrDstY*vChrFilterSize + i + 1]<<16 : 0);
185 *(
const void**)&lumMmxFilter[4*i+0]= lumSrcPtr[i];
188 ((uint16_t)vLumFilter[dstY*vLumFilterSize + i])*0x10001;
190 *(
const void**)&alpMmxFilter[4*i+0]= alpSrcPtr[i];
192 alpMmxFilter[4*i+3]= lumMmxFilter[4*i+2];
196 *(
const void**)&chrMmxFilter[4*i+0]= chrUSrcPtr[i];
199 ((uint16_t)vChrFilter[chrDstY*vChrFilterSize + i])*0x10001;
207 #define SCALE_FUNC(filter_n, from_bpc, to_bpc, opt) \ 208 void ff_hscale ## from_bpc ## to ## to_bpc ## _ ## filter_n ## _ ## opt( \ 209 SwsContext *c, int16_t *data, \ 210 int dstW, const uint8_t *src, \ 211 const int16_t *filter, \ 212 const int32_t *filterPos, int filterSize) 214 #define SCALE_FUNCS(filter_n, opt) \ 215 SCALE_FUNC(filter_n, 8, 15, opt); \ 216 SCALE_FUNC(filter_n, 9, 15, opt); \ 217 SCALE_FUNC(filter_n, 10, 15, opt); \ 218 SCALE_FUNC(filter_n, 16, 15, opt); \ 219 SCALE_FUNC(filter_n, 8, 19, opt); \ 220 SCALE_FUNC(filter_n, 9, 19, opt); \ 221 SCALE_FUNC(filter_n, 10, 19, opt); \ 222 SCALE_FUNC(filter_n, 16, 19, opt) 224 #define SCALE_FUNCS_MMX(opt) \ 225 SCALE_FUNCS(4, opt); \ 226 SCALE_FUNCS(8, opt); \ 229 #define SCALE_FUNCS_SSE(opt) \ 230 SCALE_FUNCS(4, opt); \ 231 SCALE_FUNCS(8, opt); \ 232 SCALE_FUNCS(X4, opt); \ 242 #define VSCALEX_FUNC(size, opt) \ 243 void ff_yuv2planeX_ ## size ## _ ## opt(const int16_t *filter, int filterSize, \ 244 const int16_t **src, uint8_t *dest, int dstW, \ 245 const uint8_t *dither, int offset) 246 #define VSCALEX_FUNCS(opt) \ 247 VSCALEX_FUNC(8, opt); \ 248 VSCALEX_FUNC(9, opt); \ 249 VSCALEX_FUNC(10, opt) 259 #define VSCALE_FUNC(size, opt) \ 260 void ff_yuv2plane1_ ## size ## _ ## opt(const int16_t *src, uint8_t *dst, int dstW, \ 261 const uint8_t *dither, int offset) 262 #define VSCALE_FUNCS(opt1, opt2) \ 263 VSCALE_FUNC(8, opt1); \ 264 VSCALE_FUNC(9, opt2); \ 265 VSCALE_FUNC(10, opt2); \ 266 VSCALE_FUNC(16, opt1) 275 #define INPUT_Y_FUNC(fmt, opt) \ 276 void ff_ ## fmt ## ToY_ ## opt(uint8_t *dst, const uint8_t *src, \ 277 int w, uint32_t *unused) 278 #define INPUT_UV_FUNC(fmt, opt) \ 279 void ff_ ## fmt ## ToUV_ ## opt(uint8_t *dstU, uint8_t *dstV, \ 280 const uint8_t *src, const uint8_t *unused1, \ 281 int w, uint32_t *unused2) 282 #define INPUT_FUNC(fmt, opt) \ 283 INPUT_Y_FUNC(fmt, opt); \ 284 INPUT_UV_FUNC(fmt, opt) 285 #define INPUT_FUNCS(opt) \ 286 INPUT_FUNC(uyvy, opt); \ 287 INPUT_FUNC(yuyv, opt); \ 288 INPUT_UV_FUNC(nv12, opt); \ 289 INPUT_UV_FUNC(nv21, opt); \ 290 INPUT_FUNC(rgba, opt); \ 291 INPUT_FUNC(bgra, opt); \ 292 INPUT_FUNC(argb, opt); \ 293 INPUT_FUNC(abgr, opt); \ 294 INPUT_FUNC(rgb24, opt); \ 295 INPUT_FUNC(bgr24, opt) 310 sws_init_swscale_mmx(c);
312 #if HAVE_MMXEXT_INLINE 314 sws_init_swscale_mmxext(c);
317 #define ASSIGN_SCALE_FUNC2(hscalefn, filtersize, opt1, opt2) do { \ 318 if (c->srcBpc == 8) { \ 319 hscalefn = c->dstBpc <= 10 ? ff_hscale8to15_ ## filtersize ## _ ## opt2 : \ 320 ff_hscale8to19_ ## filtersize ## _ ## opt1; \ 321 } else if (c->srcBpc == 9) { \ 322 hscalefn = c->dstBpc <= 10 ? ff_hscale9to15_ ## filtersize ## _ ## opt2 : \ 323 ff_hscale9to19_ ## filtersize ## _ ## opt1; \ 324 } else if (c->srcBpc == 10) { \ 325 hscalefn = c->dstBpc <= 10 ? ff_hscale10to15_ ## filtersize ## _ ## opt2 : \ 326 ff_hscale10to19_ ## filtersize ## _ ## opt1; \ 328 hscalefn = c->dstBpc <= 10 ? ff_hscale16to15_ ## filtersize ## _ ## opt2 : \ 329 ff_hscale16to19_ ## filtersize ## _ ## opt1; \ 332 #define ASSIGN_MMX_SCALE_FUNC(hscalefn, filtersize, opt1, opt2) \ 333 switch (filtersize) { \ 334 case 4: ASSIGN_SCALE_FUNC2(hscalefn, 4, opt1, opt2); break; \ 335 case 8: ASSIGN_SCALE_FUNC2(hscalefn, 8, opt1, opt2); break; \ 336 default: ASSIGN_SCALE_FUNC2(hscalefn, X, opt1, opt2); break; \ 338 #define ASSIGN_VSCALEX_FUNC(vscalefn, opt, do_16_case, condition_8bit) \ 340 case 16: do_16_case; break; \ 341 case 10: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2planeX_10_ ## opt; break; \ 342 case 9: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2planeX_9_ ## opt; break; \ 343 default: if (condition_8bit) vscalefn = ff_yuv2planeX_8_ ## opt; break; \ 345 #define ASSIGN_VSCALE_FUNC(vscalefn, opt1, opt2, opt2chk) \ 347 case 16: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2plane1_16_ ## opt1; break; \ 348 case 10: if (!isBE(c->dstFormat) && opt2chk) vscalefn = ff_yuv2plane1_10_ ## opt2; break; \ 349 case 9: if (!isBE(c->dstFormat) && opt2chk) vscalefn = ff_yuv2plane1_9_ ## opt2; break; \ 350 default: vscalefn = ff_yuv2plane1_8_ ## opt1; break; \ 352 #define case_rgb(x, X, opt) \ 353 case AV_PIX_FMT_ ## X: \ 354 c->lumToYV12 = ff_ ## x ## ToY_ ## opt; \ 355 if (!c->chrSrcHSubSample) \ 356 c->chrToYV12 = ff_ ## x ## ToUV_ ## opt; \ 398 #define ASSIGN_SSE_SCALE_FUNC(hscalefn, filtersize, opt1, opt2) \ 399 switch (filtersize) { \ 400 case 4: ASSIGN_SCALE_FUNC2(hscalefn, 4, opt1, opt2); break; \ 401 case 8: ASSIGN_SCALE_FUNC2(hscalefn, 8, opt1, opt2); break; \ 402 default: if (filtersize & 4) ASSIGN_SCALE_FUNC2(hscalefn, X4, opt1, opt2); \ 403 else ASSIGN_SCALE_FUNC2(hscalefn, X8, opt1, opt2); \ #define EXTERNAL_MMX(flags)
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
int16_t ** alpPixBuf
Ring buffer for scaled horizontal alpha plane lines to be fed to the vertical scaler.
void(* hcScale)(struct SwsContext *c, int16_t *dst, int dstW, const uint8_t *src, const int16_t *filter, const int32_t *filterPos, int filterSize)
const uint64_t ff_dither8[2]
int chrBufIndex
Index in ring buffer of the last scaled horizontal chroma line from source.
int chrSrcH
Height of source chroma planes.
8 bits gray, 8 bits alpha
#define VSCALE_FUNC(size, opt)
#define SCALE_FUNCS_MMX(opt)
void updateMMXDitherTables(SwsContext *c, int dstY, int lumBufIndex, int chrBufIndex, int lastInLumBuf, int lastInChrBuf)
#define DECLARE_ALIGNED(n, t, v)
void(* hyScale)(struct SwsContext *c, int16_t *dst, int dstW, const uint8_t *src, const int16_t *filter, const int32_t *filterPos, int filterSize)
Scale one horizontal line of input data using a filter over the input lines, to produce one (differen...
int dstY
Last destination vertical line output from last slice.
#define case_rgb(x, X, opt)
Macro definitions for various function/variable attributes.
#define ASSIGN_SSE_SCALE_FUNC(hscalefn, filtersize, opt1, opt2)
int srcH
Height of source luma/alpha planes.
#define VSCALE_FUNCS(opt1, opt2)
#define EXTERNAL_SSE4(flags)
#define DECLARE_ASM_CONST(n, t, v)
int chrDstVSubSample
Binary logarithm of vertical subsampling factor between luma/alpha and chroma planes in destination i...
int vChrFilterSize
Vertical filter size for chroma pixels.
void(* chrToYV12)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, int width, uint32_t *pal)
Unscaled conversion of chroma planes to YV12 for horizontal scaler.
int16_t ** lumPixBuf
Ring buffer for scaled horizontal luma plane lines to be fed to the vertical scaler.
#define AV_CPU_FLAG_MMXEXT
SSE integer functions or AMD MMX ext.
av_cold void ff_sws_init_swscale_x86(SwsContext *c)
int lastInLumBuf
Last scaled horizontal luma/alpha line from source in the ring buffer.
external api for the swscale stuff
enum AVPixelFormat dstFormat
Destination pixel format.
#define EXTERNAL_SSE2(flags)
#define VSCALEX_FUNCS(opt)
int32_t * vChrFilterPos
Array of vertical filter starting positions for each dst[i] for chroma planes.
int dstH
Height of destination luma/alpha planes.
#define INLINE_MMX(flags)
const uint64_t ff_dither4[2]
int hLumFilterSize
Horizontal filter size for luma/alpha pixels.
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
int vChrBufSize
Number of vertical chroma lines allocated in the ring buffer.
int32_t alpMmxFilter[4 *MAX_FILTER_SIZE]
int hChrFilterSize
Horizontal filter size for chroma pixels.
as above, but U and V bytes are swapped
void(* lumToYV12)(uint8_t *dst, const uint8_t *src, int width, uint32_t *pal)
Unscaled conversion of luma plane to YV12 for horizontal scaler.
yuv2planar1_fn yuv2plane1
int vLumBufSize
Number of vertical luma/alpha lines allocated in the ring buffer.
#define SCALE_FUNCS_SSE(opt)
int16_t ** chrUPixBuf
Ring buffer for scaled horizontal chroma plane lines to be fed to the vertical scaler.
if(ac->has_optimized_func)
int32_t * vLumFilterPos
Array of vertical filter starting positions for each dst[i] for luma/alpha planes.
#define AV_PIX_FMT_BGR555
static av_always_inline int isBE(enum AVPixelFormat pix_fmt)
int32_t lumMmxFilter[4 *MAX_FILTER_SIZE]
#define ASSIGN_MMX_SCALE_FUNC(hscalefn, filtersize, opt1, opt2)
yuv2planarX_fn yuv2planeX
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
#define EXTERNAL_SSSE3(flags)
int vLumFilterSize
Vertical filter size for luma/alpha pixels.
int16_t * vChrFilter
Array of vertical filter coefficients for chroma planes.
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
#define EXTERNAL_MMXEXT(flags)
int lumBufIndex
Index in ring buffer of the last scaled horizontal luma/alpha line from source.
#define VSCALEX_FUNC(size, opt)
#define INLINE_MMXEXT(flags)
int lastInChrBuf
Last scaled horizontal chroma line from source in the ring buffer.
#define CONFIG_SWSCALE_ALPHA
enum AVPixelFormat srcFormat
Source pixel format.
#define HAVE_ALIGNED_STACK
int32_t chrMmxFilter[4 *MAX_FILTER_SIZE]
#define AV_PIX_FMT_RGB555
#define ASSIGN_VSCALEX_FUNC(vscalefn, opt, do_16_case, condition_8bit)
#define ASSIGN_VSCALE_FUNC(vscalefn, opt1, opt2, opt2chk)
int16_t * vLumFilter
Array of vertical filter coefficients for luma/alpha planes.
void(* alpToYV12)(uint8_t *dst, const uint8_t *src, int width, uint32_t *pal)
Unscaled conversion of alpha plane to YV12 for horizontal scaler.
int flags
Flags passed by the user to select scaler algorithm, optimizations, subsampling, etc...
#define EXTERNAL_AVX(flags)